typerighter 0.54.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-DxLZjnyG.js → app-C1ognrj1.js} +40 -40
- package/dist/builtin-components.json +22 -1
- package/dist/{cli-Bwui1Hg7.js → cli-Cfn9ef18.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/theme-default.js +2029 -1049
- package/dist/client.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-CDdP9swK.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/postprocess.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-CxusSg92.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/json-schema.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-v0btHVwj.js → shared-BK7uzYmy.js} +102 -96
- package/dist/shared.js +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/{vite-0T8QXeWH.js → vite-B9tiBEhg.js} +522 -508
- package/dist/vite.js +1 -1
- package/package.json +3 -3
- package/dist/jsonld-CByNA46l.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,73 +1000,86 @@ async function wt(e) {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
return i;
|
|
1003
1002
|
}
|
|
1004
|
-
var
|
|
1005
|
-
typescript: "
|
|
1006
|
-
javascript: "
|
|
1003
|
+
var xt = {
|
|
1004
|
+
typescript: "TypeScript",
|
|
1005
|
+
javascript: "JavaScript",
|
|
1007
1006
|
tsx: "TSX",
|
|
1008
1007
|
jsx: "JSX",
|
|
1009
|
-
python: "
|
|
1010
|
-
rust: "
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1008
|
+
python: "Python",
|
|
1009
|
+
rust: "Rust",
|
|
1010
|
+
rs: "Rust",
|
|
1011
|
+
go: "Go",
|
|
1012
|
+
java: "Java",
|
|
1013
|
+
kotlin: "Kotlin",
|
|
1014
|
+
swift: "Swift",
|
|
1015
|
+
ruby: "Ruby",
|
|
1016
1016
|
php: "PHP",
|
|
1017
1017
|
csharp: "C#",
|
|
1018
1018
|
cpp: "C++",
|
|
1019
1019
|
c: "C",
|
|
1020
|
-
bash: "
|
|
1021
|
-
sh: "
|
|
1022
|
-
shell: "
|
|
1023
|
-
zsh: "
|
|
1020
|
+
bash: "Bash",
|
|
1021
|
+
sh: "Bash",
|
|
1022
|
+
shell: "Shell",
|
|
1023
|
+
zsh: "Zsh",
|
|
1024
1024
|
html: "HTML",
|
|
1025
1025
|
css: "CSS",
|
|
1026
1026
|
scss: "SCSS",
|
|
1027
|
-
sass: "
|
|
1027
|
+
sass: "Sass",
|
|
1028
1028
|
json: "JSON",
|
|
1029
|
-
yaml: "
|
|
1030
|
-
yml: "
|
|
1029
|
+
yaml: "YAML",
|
|
1030
|
+
yml: "YAML",
|
|
1031
1031
|
toml: "TOML",
|
|
1032
1032
|
xml: "XML",
|
|
1033
1033
|
sql: "SQL",
|
|
1034
|
-
markdown: "
|
|
1035
|
-
vue: "
|
|
1036
|
-
svelte: "
|
|
1037
|
-
|
|
1034
|
+
markdown: "Markdown",
|
|
1035
|
+
vue: "Vue",
|
|
1036
|
+
svelte: "Svelte",
|
|
1037
|
+
racket: "Racket",
|
|
1038
|
+
haskell: "Haskell",
|
|
1039
|
+
elixir: "Elixir",
|
|
1040
|
+
clojure: "Clojure",
|
|
1041
|
+
lua: "Lua",
|
|
1042
|
+
r: "R",
|
|
1043
|
+
dart: "Dart",
|
|
1044
|
+
zig: "Zig",
|
|
1045
|
+
nim: "Nim",
|
|
1046
|
+
ocaml: "OCaml",
|
|
1047
|
+
erlang: "Erlang",
|
|
1048
|
+
scala: "Scala",
|
|
1049
|
+
txt: "Text"
|
|
1038
1050
|
};
|
|
1039
|
-
function
|
|
1040
|
-
return
|
|
1051
|
+
function St(e) {
|
|
1052
|
+
return xt[e.toLowerCase()] ?? e;
|
|
1041
1053
|
}
|
|
1042
|
-
function
|
|
1054
|
+
function Ct(e, t, n) {
|
|
1043
1055
|
t ||= "txt";
|
|
1044
|
-
let r =
|
|
1056
|
+
let r = St(t), i = ["td-code-block", "language-" + t];
|
|
1045
1057
|
n.title && i.push("has-title"), n.lineNumbers !== void 0 && i.push("line-numbers-mode");
|
|
1046
1058
|
let a = `<figure class="${i.join(" ")}">`;
|
|
1047
|
-
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;
|
|
1048
1060
|
}
|
|
1049
|
-
var
|
|
1050
|
-
function
|
|
1051
|
-
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;
|
|
1052
1064
|
}
|
|
1053
|
-
var
|
|
1054
|
-
function
|
|
1065
|
+
var Dt = /`([^`]+)`|\$([^$]+)\$/g;
|
|
1066
|
+
function Ot(e) {
|
|
1055
1067
|
let t = 0, n = "";
|
|
1056
|
-
for (let r of e.matchAll(
|
|
1057
|
-
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>`;
|
|
1058
1070
|
else if (r[2] !== void 0) try {
|
|
1059
|
-
n +=
|
|
1071
|
+
n += k.renderToString(r[2], { throwOnError: !1 });
|
|
1060
1072
|
} catch {
|
|
1061
|
-
n +=
|
|
1073
|
+
n += p(r[0]);
|
|
1062
1074
|
}
|
|
1063
1075
|
t = r.index + r[0].length;
|
|
1064
1076
|
}
|
|
1065
|
-
return n +=
|
|
1077
|
+
return n += p(e.slice(t)), n;
|
|
1066
1078
|
}
|
|
1067
|
-
function
|
|
1079
|
+
function kt(e, t) {
|
|
1068
1080
|
let n = t ? "div" : "span";
|
|
1069
1081
|
try {
|
|
1070
|
-
return
|
|
1082
|
+
return k.renderToString(m(e), {
|
|
1071
1083
|
throwOnError: !1,
|
|
1072
1084
|
displayMode: t
|
|
1073
1085
|
});
|
|
@@ -1077,23 +1089,24 @@ function Nt(e, t) {
|
|
|
1077
1089
|
}
|
|
1078
1090
|
// src/node/lib/render/vue.ts
|
|
1079
1091
|
async function U(e, t, n) {
|
|
1080
|
-
let r = t.title || t.label || (
|
|
1092
|
+
let r = t.title || t.label || (f(n) ? C(n, (await e.getConfig()).siteTitle) : T(n));
|
|
1081
1093
|
return {
|
|
1082
1094
|
schema: t.schema,
|
|
1083
1095
|
schemaLabel: t.schemaLabel,
|
|
1084
1096
|
label: t.label,
|
|
1085
1097
|
icon: t.icon,
|
|
1086
1098
|
frontmatter: t.header ?? {},
|
|
1087
|
-
headings:
|
|
1099
|
+
headings: jt(t.headings),
|
|
1088
1100
|
title: r,
|
|
1089
|
-
titleHtml:
|
|
1101
|
+
titleHtml: Ot(r),
|
|
1090
1102
|
filepath: n,
|
|
1091
1103
|
fileMetadata: t.fileMetadata,
|
|
1092
|
-
seoMetadata: t.seoMetadata
|
|
1104
|
+
seoMetadata: t.seoMetadata,
|
|
1105
|
+
excerpt: t.excerpt
|
|
1093
1106
|
};
|
|
1094
1107
|
}
|
|
1095
|
-
async function
|
|
1096
|
-
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)}`);
|
|
1097
1110
|
return {
|
|
1098
1111
|
vueSrc: [
|
|
1099
1112
|
"<script>",
|
|
@@ -1105,12 +1118,12 @@ async function Pt(e, t, n) {
|
|
|
1105
1118
|
`import { pageData } from ${a}`,
|
|
1106
1119
|
"useRouter().route.data = pageData",
|
|
1107
1120
|
"<\/script>",
|
|
1108
|
-
`<template><div class="typedown-content">\n${
|
|
1121
|
+
`<template><div class="typedown-content">\n${Mt(r)}\n</div></template>`
|
|
1109
1122
|
].join("\n"),
|
|
1110
1123
|
pageData: i
|
|
1111
1124
|
};
|
|
1112
1125
|
}
|
|
1113
|
-
function
|
|
1126
|
+
function jt(e) {
|
|
1114
1127
|
let t = [], n = [];
|
|
1115
1128
|
for (let r of e) {
|
|
1116
1129
|
let e = {
|
|
@@ -1126,13 +1139,13 @@ function Ft(e) {
|
|
|
1126
1139
|
}
|
|
1127
1140
|
return t;
|
|
1128
1141
|
}
|
|
1129
|
-
function
|
|
1142
|
+
function Mt(e) {
|
|
1130
1143
|
return e.replaceAll("{{", "{{").replaceAll("}}", "}}");
|
|
1131
1144
|
}
|
|
1132
1145
|
// src/node/plugin/vite/constants.ts
|
|
1133
|
-
var
|
|
1146
|
+
var Nt = "@typedown/app", Pt = "\0@typedown/app", W = "@typedown/pages", Ft = "\0" + W;
|
|
1134
1147
|
W + "";
|
|
1135
|
-
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";
|
|
1136
1149
|
// src/node/plugin/vite/virtual/utils.ts
|
|
1137
1150
|
function X(e, t) {
|
|
1138
1151
|
let n = e.moduleGraph.getModuleById(t);
|
|
@@ -1150,14 +1163,14 @@ function X(e, t) {
|
|
|
1150
1163
|
}
|
|
1151
1164
|
}
|
|
1152
1165
|
// src/node/plugin/vite/virtual/app.ts
|
|
1153
|
-
var
|
|
1166
|
+
var zt = class {
|
|
1154
1167
|
mountPath;
|
|
1155
1168
|
constructor(e = "") {
|
|
1156
1169
|
this.mountPath = e;
|
|
1157
1170
|
}
|
|
1158
1171
|
async load(e) {
|
|
1159
|
-
let t = await (await e.getTdContext()).getConfig(), n = await
|
|
1160
|
-
return
|
|
1172
|
+
let t = await (await e.getTdContext()).getConfig(), n = await L(t.components, e.root);
|
|
1173
|
+
return Ne({
|
|
1161
1174
|
rootDir: t.rootDir,
|
|
1162
1175
|
mountPath: this.mountPath,
|
|
1163
1176
|
basePath: t.basePath,
|
|
@@ -1179,9 +1192,9 @@ var Ut = class {
|
|
|
1179
1192
|
});
|
|
1180
1193
|
}
|
|
1181
1194
|
invalidate(e) {
|
|
1182
|
-
X(e,
|
|
1195
|
+
X(e, Pt);
|
|
1183
1196
|
}
|
|
1184
|
-
},
|
|
1197
|
+
}, Bt = class {
|
|
1185
1198
|
mountPath;
|
|
1186
1199
|
constructor(e = "") {
|
|
1187
1200
|
this.mountPath = e;
|
|
@@ -1219,62 +1232,62 @@ var Ut = class {
|
|
|
1219
1232
|
});
|
|
1220
1233
|
}
|
|
1221
1234
|
invalidate(e) {
|
|
1222
|
-
X(e,
|
|
1235
|
+
X(e, Ft);
|
|
1223
1236
|
}
|
|
1224
|
-
},
|
|
1237
|
+
}, Vt = class {
|
|
1225
1238
|
async load(e) {
|
|
1226
|
-
return
|
|
1239
|
+
return Pe((await (await e.getTdContext()).getConfig()).layout ?? void 0, e.root);
|
|
1227
1240
|
}
|
|
1228
1241
|
invalidate(e) {
|
|
1229
|
-
X(e,
|
|
1242
|
+
X(e, Rt);
|
|
1230
1243
|
}
|
|
1231
|
-
},
|
|
1244
|
+
}, Ht = "\0@typedown/site-data", Ut = {
|
|
1232
1245
|
ready: !1,
|
|
1233
1246
|
contentTree: { entries: [] },
|
|
1234
1247
|
schemas: {},
|
|
1235
1248
|
directoryListings: {}
|
|
1236
|
-
},
|
|
1249
|
+
}, Wt = class {
|
|
1237
1250
|
data;
|
|
1238
1251
|
scan(e) {
|
|
1239
|
-
let t =
|
|
1252
|
+
let t = me("**/*.td", {
|
|
1240
1253
|
cwd: e,
|
|
1241
1254
|
exclude: (e) => e.startsWith("_")
|
|
1242
1255
|
}).map((e) => ({
|
|
1243
1256
|
filepath: e,
|
|
1244
|
-
label:
|
|
1257
|
+
label: T(e),
|
|
1245
1258
|
header: {}
|
|
1246
|
-
})), n =
|
|
1259
|
+
})), n = _(t);
|
|
1247
1260
|
this.data = {
|
|
1248
1261
|
contentTree: n,
|
|
1249
1262
|
schemas: {},
|
|
1250
|
-
directoryListings:
|
|
1263
|
+
directoryListings: g(n.entries, "")
|
|
1251
1264
|
};
|
|
1252
1265
|
}
|
|
1253
1266
|
load(e) {
|
|
1254
1267
|
let t = this.data ? {
|
|
1255
1268
|
ready: !0,
|
|
1256
1269
|
...this.data
|
|
1257
|
-
} :
|
|
1270
|
+
} : Ut;
|
|
1258
1271
|
return `export default ${JSON.stringify(t)}`;
|
|
1259
1272
|
}
|
|
1260
1273
|
clear() {
|
|
1261
1274
|
this.data = void 0;
|
|
1262
1275
|
}
|
|
1263
1276
|
fetch = b((e, t) => {
|
|
1264
|
-
|
|
1277
|
+
Gt(e).then((e) => {
|
|
1265
1278
|
this.data = e, t && this.invalidate(t);
|
|
1266
1279
|
}).catch((e) => {
|
|
1267
1280
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1268
1281
|
});
|
|
1269
1282
|
}, 200);
|
|
1270
1283
|
async fetchSync(e) {
|
|
1271
|
-
this.data = await
|
|
1284
|
+
this.data = await Gt(e);
|
|
1272
1285
|
}
|
|
1273
1286
|
invalidate(e) {
|
|
1274
|
-
X(e,
|
|
1287
|
+
X(e, Ht);
|
|
1275
1288
|
}
|
|
1276
1289
|
};
|
|
1277
|
-
async function
|
|
1290
|
+
async function Gt(e) {
|
|
1278
1291
|
let [t, n, r] = await Promise.all([
|
|
1279
1292
|
e.getConfig(),
|
|
1280
1293
|
e.listSidebar(),
|
|
@@ -1282,20 +1295,20 @@ async function Yt(e) {
|
|
|
1282
1295
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1283
1296
|
...e,
|
|
1284
1297
|
header: {}
|
|
1285
|
-
})), s =
|
|
1298
|
+
})), s = _(o);
|
|
1286
1299
|
return {
|
|
1287
1300
|
contentTree: s,
|
|
1288
1301
|
schemas: a,
|
|
1289
|
-
directoryListings:
|
|
1302
|
+
directoryListings: g(s.entries, t.siteTitle)
|
|
1290
1303
|
};
|
|
1291
1304
|
}
|
|
1292
1305
|
// src/node/lib/search-indexer/index.ts
|
|
1293
|
-
var
|
|
1306
|
+
var Kt = class {
|
|
1294
1307
|
index;
|
|
1295
1308
|
constructor() {
|
|
1296
|
-
this.index = new
|
|
1297
|
-
fields:
|
|
1298
|
-
storeFields:
|
|
1309
|
+
this.index = new ie({
|
|
1310
|
+
fields: y,
|
|
1311
|
+
storeFields: S
|
|
1299
1312
|
});
|
|
1300
1313
|
}
|
|
1301
1314
|
addAll(e) {
|
|
@@ -1313,20 +1326,20 @@ var Xt = class {
|
|
|
1313
1326
|
}
|
|
1314
1327
|
};
|
|
1315
1328
|
// src/node/lib/search-indexer/scan.ts
|
|
1316
|
-
function
|
|
1317
|
-
let n =
|
|
1329
|
+
function qt(e, t) {
|
|
1330
|
+
let n = Zt(e), r = [];
|
|
1318
1331
|
for (let t of n) {
|
|
1319
|
-
let n =
|
|
1332
|
+
let n = Xt(e, t);
|
|
1320
1333
|
n && r.push(n);
|
|
1321
1334
|
}
|
|
1322
1335
|
t.addAll(r);
|
|
1323
1336
|
}
|
|
1324
|
-
function
|
|
1325
|
-
let i =
|
|
1326
|
-
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));
|
|
1327
1340
|
}
|
|
1328
|
-
function
|
|
1329
|
-
let n =
|
|
1341
|
+
function Yt(e, t) {
|
|
1342
|
+
let n = T(e);
|
|
1330
1343
|
if (!t.startsWith("---")) return {
|
|
1331
1344
|
title: n,
|
|
1332
1345
|
body: t
|
|
@@ -1342,54 +1355,54 @@ function $t(e, t) {
|
|
|
1342
1355
|
body: a
|
|
1343
1356
|
};
|
|
1344
1357
|
}
|
|
1345
|
-
function
|
|
1358
|
+
function Xt(e, t) {
|
|
1346
1359
|
let r;
|
|
1347
1360
|
try {
|
|
1348
|
-
r =
|
|
1361
|
+
r = he(t, "utf-8");
|
|
1349
1362
|
} catch {
|
|
1350
1363
|
return;
|
|
1351
1364
|
}
|
|
1352
1365
|
if (!r.trim()) return;
|
|
1353
|
-
let i =
|
|
1366
|
+
let i = t.slice(e.length + 1), { title: a, body: o } = Yt(i, r);
|
|
1354
1367
|
return {
|
|
1355
|
-
id:
|
|
1368
|
+
id: n(i),
|
|
1356
1369
|
title: a,
|
|
1357
1370
|
text: `${a}\n${o}`
|
|
1358
1371
|
};
|
|
1359
1372
|
}
|
|
1360
|
-
function
|
|
1361
|
-
return
|
|
1373
|
+
function Zt(e) {
|
|
1374
|
+
return me("**/*.td", {
|
|
1362
1375
|
cwd: e,
|
|
1363
1376
|
exclude: (e) => e.startsWith("_")
|
|
1364
|
-
}).map((t) =>
|
|
1377
|
+
}).map((t) => j(e, t));
|
|
1365
1378
|
}
|
|
1366
1379
|
// src/node/plugin/vite/virtual/search-index.ts
|
|
1367
|
-
var
|
|
1368
|
-
indexer = new
|
|
1380
|
+
var Qt = "\0@typedown/search-index", $t = class {
|
|
1381
|
+
indexer = new Kt();
|
|
1369
1382
|
load(e) {
|
|
1370
1383
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1371
1384
|
}
|
|
1372
1385
|
index(e) {
|
|
1373
|
-
|
|
1386
|
+
qt(e, this.indexer);
|
|
1374
1387
|
}
|
|
1375
1388
|
reindex(e, t) {
|
|
1376
|
-
|
|
1389
|
+
Jt(e, t, this.indexer);
|
|
1377
1390
|
}
|
|
1378
1391
|
invalidate(e) {
|
|
1379
|
-
X(e,
|
|
1392
|
+
X(e, Qt);
|
|
1380
1393
|
}
|
|
1381
|
-
},
|
|
1382
|
-
function
|
|
1394
|
+
}, en = _e(import.meta.url);
|
|
1395
|
+
function tn() {
|
|
1383
1396
|
return [{
|
|
1384
1397
|
find: "vue/server-renderer",
|
|
1385
|
-
replacement:
|
|
1398
|
+
replacement: en.resolve("vue/server-renderer")
|
|
1386
1399
|
}, {
|
|
1387
1400
|
find: "vue",
|
|
1388
|
-
replacement:
|
|
1401
|
+
replacement: en.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1389
1402
|
}];
|
|
1390
1403
|
}
|
|
1391
1404
|
// src/node/plugin/vite/middleware/vault-assets.ts
|
|
1392
|
-
var
|
|
1405
|
+
var nn = {
|
|
1393
1406
|
jpg: "image/jpeg",
|
|
1394
1407
|
jpeg: "image/jpeg",
|
|
1395
1408
|
png: "image/png",
|
|
@@ -1407,50 +1420,51 @@ var sn = {
|
|
|
1407
1420
|
woff: "font/woff",
|
|
1408
1421
|
ttf: "font/ttf"
|
|
1409
1422
|
};
|
|
1410
|
-
function
|
|
1411
|
-
return (
|
|
1412
|
-
if (!
|
|
1413
|
-
let c =
|
|
1414
|
-
if (c.startsWith("/@") || c.startsWith("/node_modules")) return
|
|
1415
|
-
let l =
|
|
1416
|
-
if (
|
|
1417
|
-
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);
|
|
1418
1431
|
if (e.isFile()) {
|
|
1419
|
-
let t =
|
|
1420
|
-
|
|
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);
|
|
1421
1434
|
return;
|
|
1422
1435
|
}
|
|
1423
1436
|
} catch {}
|
|
1424
|
-
|
|
1437
|
+
i();
|
|
1425
1438
|
};
|
|
1426
1439
|
}
|
|
1427
1440
|
// src/node/plugin/vite/middleware/virtual-html.ts
|
|
1428
|
-
function
|
|
1429
|
-
return (
|
|
1430
|
-
if (!
|
|
1431
|
-
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);
|
|
1432
1445
|
if (c.startsWith("/@") || c.startsWith("/node_modules") || !c.startsWith(l)) return s();
|
|
1433
1446
|
let u = c.slice(l.length);
|
|
1434
1447
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return s();
|
|
1435
|
-
|
|
1436
|
-
let
|
|
1437
|
-
|
|
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);
|
|
1438
1451
|
}).catch(() => s());
|
|
1439
1452
|
};
|
|
1440
1453
|
}
|
|
1441
|
-
function
|
|
1442
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1454
|
+
function on(e, t) {
|
|
1455
|
+
return e.devHtml === void 0 && (e.devHtml = D({
|
|
1443
1456
|
title: t.siteTitle,
|
|
1444
1457
|
description: t.siteDescription,
|
|
1445
1458
|
base: "/",
|
|
1446
|
-
|
|
1459
|
+
ogType: "website",
|
|
1460
|
+
entryScript: Nt
|
|
1447
1461
|
})), e.devHtml;
|
|
1448
1462
|
}
|
|
1449
1463
|
// src/node/lib/prop-schema.ts
|
|
1450
|
-
function
|
|
1464
|
+
function sn(e, t, n) {
|
|
1451
1465
|
let r = {};
|
|
1452
1466
|
for (let i of e) {
|
|
1453
|
-
let e = `./${
|
|
1467
|
+
let e = `./${A.relative(t, i.absolutePath)}`;
|
|
1454
1468
|
try {
|
|
1455
1469
|
let t = n.getComponentMeta(i.absolutePath), a = {}, o = !1;
|
|
1456
1470
|
for (let e of t.props) {
|
|
@@ -1473,7 +1487,7 @@ function dn(e, t, n) {
|
|
|
1473
1487
|
}
|
|
1474
1488
|
return r;
|
|
1475
1489
|
}
|
|
1476
|
-
function
|
|
1490
|
+
function cn(e) {
|
|
1477
1491
|
if (!e || e.length !== 1) return;
|
|
1478
1492
|
let t = Q(e[0]);
|
|
1479
1493
|
return t === void 0 ? void 0 : {
|
|
@@ -1481,8 +1495,8 @@ function fn(e) {
|
|
|
1481
1495
|
items: t
|
|
1482
1496
|
};
|
|
1483
1497
|
}
|
|
1484
|
-
function
|
|
1485
|
-
if (t && 0 < Object.keys(t).length) return
|
|
1498
|
+
function ln(e, t) {
|
|
1499
|
+
if (t && 0 < Object.keys(t).length) return un(t);
|
|
1486
1500
|
let n = /^(?:Record<string,\s*(\w+)>|\{\s*\[key:\s*string\]:\s*(\w+);\s*\})$/.exec(e);
|
|
1487
1501
|
if (!n) return;
|
|
1488
1502
|
let r = Z(n[1] ?? n[2]);
|
|
@@ -1515,7 +1529,7 @@ function Z(e) {
|
|
|
1515
1529
|
return;
|
|
1516
1530
|
}
|
|
1517
1531
|
}
|
|
1518
|
-
function
|
|
1532
|
+
function un(e) {
|
|
1519
1533
|
let t = {}, n = [];
|
|
1520
1534
|
for (let [r, i] of Object.entries(e)) {
|
|
1521
1535
|
let e = Q(i.schema);
|
|
@@ -1532,14 +1546,14 @@ function mn(e) {
|
|
|
1532
1546
|
function Q(e) {
|
|
1533
1547
|
if (typeof e == "string") return Z(e);
|
|
1534
1548
|
switch (e.kind) {
|
|
1535
|
-
case "enum": return
|
|
1536
|
-
case "array": return
|
|
1537
|
-
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);
|
|
1538
1552
|
case "literal": return "value" in e ? { const: e.value } : void 0;
|
|
1539
1553
|
default: return;
|
|
1540
1554
|
}
|
|
1541
1555
|
}
|
|
1542
|
-
function
|
|
1556
|
+
function dn(e) {
|
|
1543
1557
|
let t = e ?? [], n = t.some((e) => e === "undefined" || e === "null"), r = t.filter((e) => e !== "undefined" && e !== "null");
|
|
1544
1558
|
if (r.length === 0) return;
|
|
1545
1559
|
if (r.length === 1) {
|
|
@@ -1566,43 +1580,43 @@ function hn(e) {
|
|
|
1566
1580
|
return n ? u(a) : a;
|
|
1567
1581
|
}
|
|
1568
1582
|
// src/node/plugin/vite/subplugins/component-contract.ts
|
|
1569
|
-
var
|
|
1570
|
-
function
|
|
1583
|
+
var fn = ".typedown/components.json";
|
|
1584
|
+
function pn(e) {
|
|
1571
1585
|
return {
|
|
1572
1586
|
name: "vite-plugin-typedown-component-contract",
|
|
1573
1587
|
async buildStart() {
|
|
1574
1588
|
let t = e();
|
|
1575
1589
|
if (!t) return;
|
|
1576
|
-
let n = await
|
|
1590
|
+
let n = await L((await (await t.getTdContext()).getConfig()).components, t.root);
|
|
1577
1591
|
$(t.root, n);
|
|
1578
1592
|
},
|
|
1579
1593
|
configureServer(t) {
|
|
1580
1594
|
let n = e();
|
|
1581
1595
|
n && n.getTdContext().then(async (e) => {
|
|
1582
|
-
let r = await e.getConfig(), i = await
|
|
1583
|
-
$(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);
|
|
1584
1598
|
}).catch(() => {});
|
|
1585
1599
|
}
|
|
1586
1600
|
};
|
|
1587
1601
|
}
|
|
1588
|
-
function
|
|
1589
|
-
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))));
|
|
1590
1604
|
for (let t of i) e.watcher.add(t);
|
|
1591
1605
|
let a = (a) => {
|
|
1592
|
-
|
|
1606
|
+
hn(a, r, i) && (e.config.logger.info("[typedown] component changed, rebuilding contract..."), L(t, n).then((e) => $(n, e)).catch(() => {}));
|
|
1593
1607
|
};
|
|
1594
1608
|
e.watcher.on("change", a), e.watcher.on("add", a), e.watcher.on("unlink", a);
|
|
1595
1609
|
}
|
|
1596
|
-
function
|
|
1610
|
+
function hn(e, t, n) {
|
|
1597
1611
|
if (!e.endsWith(".vue")) return !1;
|
|
1598
|
-
let r =
|
|
1612
|
+
let r = N(e);
|
|
1599
1613
|
if (t.has(r)) return !0;
|
|
1600
1614
|
for (let e of n) if (r.startsWith(e + "/")) return !0;
|
|
1601
1615
|
return !1;
|
|
1602
1616
|
}
|
|
1603
|
-
function
|
|
1617
|
+
function gn() {
|
|
1604
1618
|
try {
|
|
1605
|
-
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"));
|
|
1606
1620
|
for (let e of Object.values(n)) if (typeof e == "object" && e && "source" in e) {
|
|
1607
1621
|
let t = e;
|
|
1608
1622
|
typeof t.source == "string" && t.source.startsWith("./") && (t.source = `typerighter/${t.source.slice(2)}`);
|
|
@@ -1612,180 +1626,180 @@ function bn() {
|
|
|
1612
1626
|
return {};
|
|
1613
1627
|
}
|
|
1614
1628
|
}
|
|
1615
|
-
var
|
|
1629
|
+
var _n = gn();
|
|
1616
1630
|
function $(e, t) {
|
|
1617
|
-
if (!(0 < Object.keys(
|
|
1618
|
-
let n = 0 < t.length ?
|
|
1619
|
-
...
|
|
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,
|
|
1620
1634
|
...n
|
|
1621
|
-
}, i =
|
|
1622
|
-
|
|
1635
|
+
}, i = A.join(e, fn);
|
|
1636
|
+
F.mkdirSync(A.dirname(i), { recursive: !0 }), F.writeFileSync(i, JSON.stringify(r, null, 2));
|
|
1623
1637
|
}
|
|
1624
1638
|
// src/node/plugin/vite/index.ts
|
|
1625
|
-
function
|
|
1626
|
-
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 = {
|
|
1627
1641
|
devHtml: void 0,
|
|
1628
1642
|
basePath: "/",
|
|
1629
1643
|
rootDirectory: "vault"
|
|
1630
1644
|
};
|
|
1631
1645
|
function p() {
|
|
1632
|
-
if (
|
|
1633
|
-
return
|
|
1646
|
+
if (n === void 0) throw Error("typedown plugin not initialized");
|
|
1647
|
+
return n.getTdContext();
|
|
1634
1648
|
}
|
|
1635
1649
|
let m = {
|
|
1636
1650
|
name: "vite-plugin-typedown",
|
|
1637
1651
|
enforce: "pre",
|
|
1638
|
-
async config(
|
|
1639
|
-
if (!
|
|
1640
|
-
let r = e.root ?
|
|
1641
|
-
|
|
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);
|
|
1642
1656
|
}
|
|
1643
|
-
a =
|
|
1657
|
+
a = t.base ?? "/";
|
|
1644
1658
|
let r = await (await p()).getConfig();
|
|
1645
1659
|
return {
|
|
1646
|
-
base:
|
|
1660
|
+
base: t.base ?? r.basePath,
|
|
1647
1661
|
publicDir: r.publicDir,
|
|
1648
1662
|
server: {
|
|
1649
|
-
port:
|
|
1650
|
-
strictPort:
|
|
1663
|
+
port: t.server?.port ?? 8686,
|
|
1664
|
+
strictPort: t.server?.strictPort ?? !1
|
|
1651
1665
|
},
|
|
1652
|
-
resolve: { alias:
|
|
1666
|
+
resolve: { alias: tn() },
|
|
1653
1667
|
ssr: { noExternal: ["typerighter"] }
|
|
1654
1668
|
};
|
|
1655
1669
|
},
|
|
1656
1670
|
configResolved(e) {
|
|
1657
|
-
i =
|
|
1671
|
+
i = j(e.root, e.build.outDir);
|
|
1658
1672
|
},
|
|
1659
1673
|
async buildStart() {
|
|
1660
|
-
if (
|
|
1661
|
-
let e = await p(), t = await e.getConfig(),
|
|
1662
|
-
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);
|
|
1663
1677
|
let i = await e.checkVault();
|
|
1664
|
-
if (
|
|
1678
|
+
if (Cn(i.diagnostics), 0 < i.errorCount) {
|
|
1665
1679
|
let e = i.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1666
1680
|
this.error(`Vault check failed with ${i.errorCount} error(s):\n${e.join("\n")}`);
|
|
1667
1681
|
}
|
|
1668
1682
|
},
|
|
1669
1683
|
resolveId(e) {
|
|
1670
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1671
|
-
if (e === "@typedown/pages") return
|
|
1672
|
-
if (e.startsWith("@typedown/pages?resource=")) return
|
|
1673
|
-
if (e === "@typedown/site-data") return
|
|
1674
|
-
if (e === "@typedown/search-index") return
|
|
1675
|
-
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;
|
|
1676
1690
|
},
|
|
1677
1691
|
async load(e) {
|
|
1678
|
-
if (
|
|
1692
|
+
if (c.isPageDataModule(e)) return c.loadPageData(e, await p());
|
|
1679
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;
|
|
1680
|
-
let
|
|
1681
|
-
if (e === "\0@typedown/search-index") return d.load(
|
|
1682
|
-
if (e === "\0@typedown/site-data") return u.load(
|
|
1683
|
-
if (e === "\0@typedown/pages") return
|
|
1684
|
-
if (e === "\0@typedown/app") return o.load(
|
|
1685
|
-
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);
|
|
1686
1700
|
},
|
|
1687
1701
|
async configureServer(e) {
|
|
1688
|
-
|
|
1689
|
-
let t = await p(),
|
|
1690
|
-
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 () => {
|
|
1691
1705
|
let e = await t.checkVault();
|
|
1692
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1706
|
+
0 < e.diagnostics.length && (console.error(""), Cn(e.diagnostics));
|
|
1693
1707
|
}), t.rpc.onConfigChanged(() => {
|
|
1694
|
-
|
|
1708
|
+
r && (f.devHtml = void 0, u.clear(), o.invalidate(r), s.invalidate(r), c.invalidate(r), bn(r), u.fetch(t, r));
|
|
1695
1709
|
}), t.rpc.onComponentContractChanged(() => {
|
|
1696
|
-
|
|
1710
|
+
r && (o.invalidate(r), bn(r));
|
|
1697
1711
|
});
|
|
1698
1712
|
function a(...e) {
|
|
1699
|
-
|
|
1700
|
-
if (!
|
|
1701
|
-
let
|
|
1713
|
+
r && t.getConfig().then((t) => {
|
|
1714
|
+
if (!r) return;
|
|
1715
|
+
let n = [];
|
|
1702
1716
|
for (let i of e) {
|
|
1703
|
-
let e =
|
|
1717
|
+
let e = N(j(r.config.root, t.rootDir, i)), a = r.moduleGraph.getModulesByFile(e);
|
|
1704
1718
|
if (a?.size) {
|
|
1705
|
-
for (let e of a)
|
|
1706
|
-
|
|
1719
|
+
for (let e of a) r.moduleGraph.invalidateModule(e), n.push(Sn(e));
|
|
1720
|
+
c.invalidatePageData(r, i);
|
|
1707
1721
|
}
|
|
1708
1722
|
}
|
|
1709
|
-
0 <
|
|
1723
|
+
0 < n.length && r.hot.send({
|
|
1710
1724
|
type: "update",
|
|
1711
|
-
updates:
|
|
1725
|
+
updates: n
|
|
1712
1726
|
});
|
|
1713
1727
|
}).catch(() => {});
|
|
1714
1728
|
}
|
|
1715
|
-
t.rpc.onContentUpdated(({ filepath: e, affectedFiles:
|
|
1716
|
-
|
|
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));
|
|
1717
1731
|
}), t.rpc.onContentDeleted(({ filepath: e }) => {
|
|
1718
|
-
|
|
1732
|
+
r && (d.reindex(i, e), d.invalidate(r), c.invalidate(r), u.fetch(t, r), a(e));
|
|
1719
1733
|
});
|
|
1720
|
-
function
|
|
1721
|
-
|
|
1734
|
+
function l() {
|
|
1735
|
+
r && (u.clear(), xn(r), u.fetch(t, r));
|
|
1722
1736
|
}
|
|
1723
|
-
t.rpc.onSchemaUpdated(
|
|
1737
|
+
t.rpc.onSchemaUpdated(l), t.rpc.onSchemaDeleted(l);
|
|
1724
1738
|
let m = await t.getConfig();
|
|
1725
1739
|
f.basePath = m.basePath, f.rootDirectory = m.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1726
1740
|
f.basePath = e.basePath, f.rootDirectory = e.rootDir, f.devHtml = void 0;
|
|
1727
|
-
}), e.middlewares.use(
|
|
1741
|
+
}), e.middlewares.use(rn(e, f)), e.middlewares.use(an(e, t, f));
|
|
1728
1742
|
},
|
|
1729
|
-
async transform(e,
|
|
1730
|
-
let
|
|
1731
|
-
if (!
|
|
1732
|
-
if (
|
|
1743
|
+
async transform(e, n) {
|
|
1744
|
+
let r = n.split("?")[0];
|
|
1745
|
+
if (!E(r)) return;
|
|
1746
|
+
if (t(r)) return {
|
|
1733
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>`,
|
|
1734
1748
|
map: null
|
|
1735
1749
|
};
|
|
1736
|
-
let i = await p(), a = await i.getConfig(), o = r
|
|
1750
|
+
let i = await p(), a = await i.getConfig(), o = l(r, a.rootDir);
|
|
1737
1751
|
try {
|
|
1738
|
-
let { vueSrc: e } = await
|
|
1752
|
+
let { vueSrc: e } = await At(i, await i.getFile(o), o);
|
|
1739
1753
|
return {
|
|
1740
1754
|
code: e,
|
|
1741
1755
|
map: null
|
|
1742
1756
|
};
|
|
1743
1757
|
} catch (e) {
|
|
1744
|
-
if (
|
|
1758
|
+
if (te(e)) return;
|
|
1745
1759
|
let t = e instanceof Error ? e.message : String(e);
|
|
1746
1760
|
this.error(`[typedown] Failed to transform ${o}: ${t}`);
|
|
1747
1761
|
}
|
|
1748
1762
|
},
|
|
1749
1763
|
handleHotUpdate({ file: e }) {
|
|
1750
|
-
if (
|
|
1764
|
+
if (E(e)) return [];
|
|
1751
1765
|
},
|
|
1752
1766
|
async closeBundle() {
|
|
1753
|
-
if (!e.context &&
|
|
1754
|
-
let e = (await (await
|
|
1755
|
-
await
|
|
1756
|
-
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),
|
|
1757
1771
|
base: e
|
|
1758
1772
|
});
|
|
1759
1773
|
} finally {
|
|
1760
|
-
|
|
1774
|
+
n.dispose();
|
|
1761
1775
|
}
|
|
1762
1776
|
}
|
|
1763
|
-
}, h =
|
|
1777
|
+
}, h = oe({
|
|
1764
1778
|
include: e.root ? RegExp(`${e.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1765
1779
|
template: { transformAssetUrls: !1 }
|
|
1766
1780
|
});
|
|
1767
1781
|
return [
|
|
1768
1782
|
m,
|
|
1769
|
-
|
|
1783
|
+
pn(() => n),
|
|
1770
1784
|
h,
|
|
1771
|
-
...
|
|
1785
|
+
...ae()
|
|
1772
1786
|
];
|
|
1773
1787
|
}
|
|
1774
|
-
function
|
|
1788
|
+
function yn(e) {
|
|
1775
1789
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1776
1790
|
}
|
|
1777
|
-
function
|
|
1778
|
-
for (let t of
|
|
1791
|
+
function bn(e) {
|
|
1792
|
+
for (let t of yn(e)) e.moduleGraph.invalidateModule(t);
|
|
1779
1793
|
e.hot.send({ type: "full-reload" });
|
|
1780
1794
|
}
|
|
1781
|
-
function
|
|
1782
|
-
let t =
|
|
1795
|
+
function xn(e) {
|
|
1796
|
+
let t = yn(e).map((t) => (e.moduleGraph.invalidateModule(t), Sn(t)));
|
|
1783
1797
|
0 < t.length && e.hot.send({
|
|
1784
1798
|
type: "update",
|
|
1785
1799
|
updates: t
|
|
1786
1800
|
});
|
|
1787
1801
|
}
|
|
1788
|
-
function
|
|
1802
|
+
function Sn(e) {
|
|
1789
1803
|
return {
|
|
1790
1804
|
type: "js-update",
|
|
1791
1805
|
path: e.url,
|
|
@@ -1793,10 +1807,10 @@ function En(e) {
|
|
|
1793
1807
|
timestamp: Date.now()
|
|
1794
1808
|
};
|
|
1795
1809
|
}
|
|
1796
|
-
function
|
|
1810
|
+
function Cn(e) {
|
|
1797
1811
|
for (let t of e) {
|
|
1798
|
-
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ?
|
|
1799
|
-
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})`)}`);
|
|
1800
1814
|
}
|
|
1801
1815
|
}
|
|
1802
|
-
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 };
|