typerighter 0.42.1 → 0.43.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-xAspP0Kq.js → app-DjpuKzvd.js} +17 -5
- package/dist/{cli-CThN6kIr.js → cli-BnRDeJy2.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/app/index.d.ts +29 -5
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/app/router.d.ts.map +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/theme-default.js +822 -715
- package/dist/client.js +1 -1
- package/dist/fonts.css +2 -0
- package/dist/index.js +3 -3
- package/dist/{init-DSA-JLUJ.js → init-BCfVnwE1.js} +3 -2
- package/dist/inlineRe-Cn-J_E76.js +4 -0
- package/dist/{jsonld-Du1iJ_fG.js → jsonld-ODTuVGMh.js} +2 -2
- package/dist/node/build/fonts.d.ts +2 -0
- package/dist/node/build/fonts.d.ts.map +1 -0
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/build/prerender.d.ts.map +1 -1
- package/dist/node/cli/init.d.ts.map +1 -1
- package/dist/node/lib/codegen/app-entry.d.ts +30 -0
- package/dist/node/lib/codegen/app-entry.d.ts.map +1 -0
- package/dist/node/lib/codegen/components.d.ts +7 -0
- package/dist/node/lib/codegen/components.d.ts.map +1 -0
- package/dist/node/lib/codegen/index.d.ts +4 -0
- package/dist/node/lib/codegen/index.d.ts.map +1 -0
- package/dist/node/lib/codegen/theme.d.ts +6 -0
- package/dist/node/lib/codegen/theme.d.ts.map +1 -0
- package/dist/node/lib/codegen/theme.test.d.ts +2 -0
- package/dist/node/lib/codegen/theme.test.d.ts.map +1 -0
- package/dist/node/lib/{htmlTemplate.d.ts → html-template.d.ts} +1 -1
- package/dist/node/lib/html-template.d.ts.map +1 -0
- package/dist/node/lib/render/postprocess.d.ts +1 -0
- package/dist/node/lib/render/postprocess.d.ts.map +1 -1
- package/dist/node/lib/render/vue.d.ts.map +1 -1
- package/dist/node/plugin/vite/constants.d.ts +2 -0
- package/dist/node/plugin/vite/constants.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts +1 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/virtual/app.d.ts +3 -21
- package/dist/node/plugin/vite/virtual/app.d.ts.map +1 -1
- package/dist/node/plugin/vite/virtual/theme.d.ts +7 -0
- package/dist/node/plugin/vite/virtual/theme.d.ts.map +1 -0
- package/dist/prerenderWorker.js +2 -2
- package/dist/renderMath-C2Z7HdfG.js +19 -0
- package/dist/shared/types/ssg.d.ts +4 -0
- package/dist/shared/types/ssg.d.ts.map +1 -1
- package/dist/shared/utils/format.d.ts +2 -0
- package/dist/shared/utils/format.d.ts.map +1 -1
- package/dist/shared/utils/format.test.d.ts +2 -0
- package/dist/shared/utils/format.test.d.ts.map +1 -0
- package/dist/{shared-BMujDY3P.js → shared-QuBFygxT.js} +104 -98
- package/dist/shared.js +1 -1
- package/dist/typedown.schema.json +133 -0
- package/dist/typerighter.css +1 -1
- package/dist/{vite-Dup9wBL7.js → vite-C9pVUTyV.js} +552 -426
- package/dist/vite.js +1 -1
- package/package.json +6 -4
- package/dist/node/lib/htmlTemplate.d.ts.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { D as e, E as t, F as n,
|
|
2
|
-
import { a as
|
|
1
|
+
import { D as e, E as t, F as n, G as r, H as i, J as a, L as o, P as s, Q as c, R as l, V as u, Y as d, Z as f, _ as p, b as m, c as h, d as g, g as _, h as v, i as y, p as b, v as x, w as S, y as C, z as w } from "./shared-QuBFygxT.js";
|
|
2
|
+
import { a as T, i as E, n as D, o as O, r as ee, s as k, t as te } from "./jsonld-ODTuVGMh.js";
|
|
3
3
|
import { t as ne } from "./temml-D47Z4xZ2.js";
|
|
4
4
|
import { a as re, i as ie, n as ae, r as oe } from "./context-CSvoDxVt.js";
|
|
5
5
|
import { t as se } from "./es-ClqUVRJn.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import A, { resolve as j } from "node:path";
|
|
7
|
+
import M from "picocolors";
|
|
8
8
|
import ce from "@tailwindcss/vite";
|
|
9
9
|
import le from "@vitejs/plugin-vue";
|
|
10
|
-
import { build as
|
|
11
|
-
import N from "node:fs/promises";
|
|
12
|
-
import { fileURLToPath as
|
|
13
|
-
import
|
|
14
|
-
import { Worker as
|
|
15
|
-
import { createHighlighter as
|
|
16
|
-
import { createReadStream as
|
|
17
|
-
import { createRequire as
|
|
10
|
+
import { build as ue, normalizePath as de } from "vite";
|
|
11
|
+
import N, { readdir as fe } from "node:fs/promises";
|
|
12
|
+
import { fileURLToPath as pe } from "node:url";
|
|
13
|
+
import me from "node:os";
|
|
14
|
+
import { Worker as he } from "node:worker_threads";
|
|
15
|
+
import { createHighlighter as ge, guessEmbeddedLanguages as _e, isSpecialLang as ve } from "shiki";
|
|
16
|
+
import { createReadStream as ye, existsSync as be, globSync as xe, readFileSync as Se, statSync as Ce } from "node:fs";
|
|
17
|
+
import { createRequire as we } from "node:module";
|
|
18
18
|
//#region src/node/lib/worker-pool/index.ts
|
|
19
|
-
var
|
|
19
|
+
var Te = class {
|
|
20
20
|
workers = [];
|
|
21
21
|
queue = [];
|
|
22
22
|
destroyed = !1;
|
|
23
23
|
startupError;
|
|
24
24
|
constructor(e) {
|
|
25
|
-
let t = e.concurrency ?? Math.max(1, Math.floor(
|
|
25
|
+
let t = e.concurrency ?? Math.max(1, Math.floor(me.cpus().length / 2));
|
|
26
26
|
for (let n = 0; n < t; n++) {
|
|
27
|
-
let t = new
|
|
27
|
+
let t = new he(e.filename, { workerData: e.workerData }), n = { worker: t };
|
|
28
28
|
this.workers.push(n), t.on("message", (e) => {
|
|
29
29
|
let t = n.pending;
|
|
30
30
|
n.pending = void 0, e.error === void 0 ? t?.resolve(e.result) : t?.reject(Error(e.error)), this.dispatch(n);
|
|
@@ -62,18 +62,18 @@ var Ce = class {
|
|
|
62
62
|
};
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/node/build/seo/sitemap.ts
|
|
65
|
-
function
|
|
65
|
+
function Ee(e, t, n, r) {
|
|
66
66
|
let i = 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>${a === void 0 ? "" : `<lastmod>${
|
|
70
|
+
let n = h(i + t + s(e)), a = r?.get(e);
|
|
71
|
+
return ` <url><loc>${n}</loc>${a === void 0 ? "" : `<lastmod>${y(a)}</lastmod>`}</url>`;
|
|
72
72
|
}).join("\n")}
|
|
73
73
|
</urlset>
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function De(e, t) {
|
|
77
77
|
return `User-agent: *
|
|
78
78
|
Allow: /
|
|
79
79
|
|
|
@@ -82,13 +82,13 @@ Sitemap: ${e}${t}sitemap.xml
|
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/node/build/seo/feed.ts
|
|
85
|
-
function
|
|
85
|
+
function Oe(e, t, n, r, i, a) {
|
|
86
86
|
let o = [...e].filter((e) => e.fileMetadata.mtime > 0).sort((e, t) => t.fileMetadata.mtime - e.fileMetadata.mtime).slice(0, 50).map((e) => {
|
|
87
|
-
let r =
|
|
87
|
+
let r = u(e.filepath), i = `${n}${t}${r}`, a = new Date(e.fileMetadata.mtime).toUTCString(), o = h(e.label ?? r), s = e.excerpt === void 0 ? "" : `<![CDATA[${e.excerpt}]]>`;
|
|
88
88
|
return ` <item>
|
|
89
89
|
<title>${o}</title>
|
|
90
|
-
<link>${
|
|
91
|
-
<guid>${
|
|
90
|
+
<link>${h(i)}</link>
|
|
91
|
+
<guid>${h(i)}</guid>
|
|
92
92
|
<pubDate>${a}</pubDate>
|
|
93
93
|
<description>${s}</description>
|
|
94
94
|
</item>`;
|
|
@@ -96,26 +96,32 @@ function Ee(e, t, n, r, i, a) {
|
|
|
96
96
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
97
97
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
98
98
|
<channel>
|
|
99
|
-
<title>${
|
|
100
|
-
<link>${
|
|
101
|
-
<description>${
|
|
99
|
+
<title>${h(r)}</title>
|
|
100
|
+
<link>${h(n + t)}</link>
|
|
101
|
+
<description>${h(i)}</description>
|
|
102
102
|
<language>${a}</language>
|
|
103
|
-
<atom:link href="${
|
|
103
|
+
<atom:link href="${h(n + t)}feed.xml" rel="self" type="application/rss+xml"/>
|
|
104
104
|
${o}
|
|
105
105
|
</channel>
|
|
106
106
|
</rss>
|
|
107
107
|
`;
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
|
+
//#region src/node/build/fonts.ts
|
|
111
|
+
function ke(e) {
|
|
112
|
+
let t = A.basename(e);
|
|
113
|
+
return t.endsWith(".woff2") && t.includes("-latin-") && !t.includes("-latin-ext-");
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
110
116
|
//#region src/node/build/prerender.ts
|
|
111
|
-
var
|
|
112
|
-
async function
|
|
113
|
-
let { clientEntry: t, cssFiles: n,
|
|
114
|
-
e.pagePaths.length >=
|
|
115
|
-
}
|
|
116
|
-
async function
|
|
117
|
-
let r = new
|
|
118
|
-
filename:
|
|
117
|
+
var Ae = 64;
|
|
118
|
+
async function je(e) {
|
|
119
|
+
let { clientEntry: t, cssFiles: n, fontFiles: r } = await Pe(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;
|
|
120
|
+
e.pagePaths.length >= Ae ? await Me(e, t, i) : await Ne(e, t, i);
|
|
121
|
+
}
|
|
122
|
+
async function Me(e, t, n) {
|
|
123
|
+
let r = new Te({
|
|
124
|
+
filename: A.resolve(pe(import.meta.url), "../prerenderWorker.js"),
|
|
119
125
|
workerData: {
|
|
120
126
|
ssrEntryPath: e.ssrEntryPath,
|
|
121
127
|
base: e.base,
|
|
@@ -129,23 +135,23 @@ async function ke(e, t, n) {
|
|
|
129
135
|
}), i = 0, a = e.pagePaths.length;
|
|
130
136
|
try {
|
|
131
137
|
await Promise.all(e.pagePaths.map(async (t) => {
|
|
132
|
-
let n = await r.run(t), o =
|
|
133
|
-
await N.mkdir(
|
|
138
|
+
let n = await r.run(t), o = A.join(e.outDir, n.fileName);
|
|
139
|
+
await N.mkdir(A.dirname(o), { recursive: !0 }), await N.writeFile(o, n.html), i++, e.progress?.update(i, a);
|
|
134
140
|
}));
|
|
135
141
|
} finally {
|
|
136
142
|
await r.destroy();
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
async function
|
|
145
|
+
async function Ne(e, t, n) {
|
|
140
146
|
let r = await (await import(e.ssrEntryPath)).createRenderer(), i = e.pagePaths.length, a = 0;
|
|
141
|
-
for (let
|
|
142
|
-
let c = await r(
|
|
147
|
+
for (let o of e.pagePaths) {
|
|
148
|
+
let c = await r(o), l = O(c.pageData), u = T(c.pageData), d = ee(c.pageData), f = e.base + s(o), p = [te({
|
|
143
149
|
title: l,
|
|
144
150
|
description: u,
|
|
145
151
|
canonicalUrl: f,
|
|
146
152
|
author: e.author,
|
|
147
153
|
dateModified: d
|
|
148
|
-
}),
|
|
154
|
+
}), D(o, l)].filter((e) => e !== void 0), m = k({
|
|
149
155
|
title: l,
|
|
150
156
|
description: u,
|
|
151
157
|
siteTitle: e.siteTitle,
|
|
@@ -155,31 +161,177 @@ async function Ae(e, t, n) {
|
|
|
155
161
|
lang: e.lang,
|
|
156
162
|
entryScript: t,
|
|
157
163
|
canonicalUrl: f,
|
|
158
|
-
ogImagePath:
|
|
164
|
+
ogImagePath: E(c.pageData),
|
|
159
165
|
jsonLdBlocks: p,
|
|
160
166
|
headExtra: n,
|
|
161
167
|
appContent: c.html
|
|
162
|
-
}), h =
|
|
163
|
-
await N.mkdir(
|
|
168
|
+
}), h = o === "/" ? "index.html" : `${s(o)}.html`, g = A.join(e.outDir, h);
|
|
169
|
+
await N.mkdir(A.dirname(g), { recursive: !0 }), await N.writeFile(g, m), a++, e.progress?.update(a, i);
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
|
-
async function
|
|
167
|
-
let t =
|
|
168
|
-
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) : e.file
|
|
172
|
+
async function Pe(e) {
|
|
173
|
+
let t = A.join(e, ".vite", "manifest.json"), n = await N.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
|
|
174
|
+
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) : ke(e.file) && o.push(e.file);
|
|
169
175
|
return {
|
|
170
176
|
clientEntry: i,
|
|
171
177
|
cssFiles: a,
|
|
172
|
-
|
|
178
|
+
fontFiles: o
|
|
173
179
|
};
|
|
174
180
|
}
|
|
175
181
|
//#endregion
|
|
182
|
+
//#region src/node/lib/codegen/app-entry.ts
|
|
183
|
+
function P(e, t) {
|
|
184
|
+
let { rootDir: n = ".", userComponents: r = [] } = e, i = r.map((e) => `import ${e.name} from ${JSON.stringify(e.absolutePath)};`).join("\n"), o = r.map((e) => `app.component(${JSON.stringify(e.name)}, ${e.name});`).join("\n"), s = JSON.stringify({
|
|
185
|
+
title: e.siteTitle,
|
|
186
|
+
description: e.siteDescription,
|
|
187
|
+
basePath: e.basePath ?? "/",
|
|
188
|
+
origin: e.origin,
|
|
189
|
+
lang: e.lang,
|
|
190
|
+
repo: e.repo,
|
|
191
|
+
author: e.author,
|
|
192
|
+
license: e.license,
|
|
193
|
+
rootDir: n,
|
|
194
|
+
nav: e.nav
|
|
195
|
+
});
|
|
196
|
+
return `
|
|
197
|
+
${[i, "import 'typerighter/style.css';"].filter(Boolean).join("\n")}
|
|
198
|
+
import 'typerighter/fonts.css';
|
|
199
|
+
import('typerighter/math.css');
|
|
200
|
+
import { createTypedownApp } from 'typerighter/client';
|
|
201
|
+
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
202
|
+
import { isIndexUrl, getDirectoryFromPageUrl, getParentUrl, path } from 'typerighter/shared';
|
|
203
|
+
import { h } from 'vue';
|
|
204
|
+
import theme from '${t.theme}';
|
|
205
|
+
import { pages as initialPages } from '${t.pages}';
|
|
206
|
+
import initialSiteData from '${t.siteData}';
|
|
207
|
+
let pages = initialPages;
|
|
208
|
+
const contentExts = ${JSON.stringify(a)};
|
|
209
|
+
|
|
210
|
+
function findPage(base) {
|
|
211
|
+
for (const ext of contentExts) {
|
|
212
|
+
const key = base + ext;
|
|
213
|
+
if (pages[key]) return pages[key];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async function loadPageModule(pagePath) {
|
|
218
|
+
const loader = findPage(path.join('/', '${n}', pagePath));
|
|
219
|
+
if (loader) return loader();
|
|
220
|
+
|
|
221
|
+
if (isIndexUrl(pagePath)) {
|
|
222
|
+
const dirPath = getDirectoryFromPageUrl(pagePath);
|
|
223
|
+
const dir = siteData.value.directoryListings[dirPath];
|
|
224
|
+
if (dir) return {
|
|
225
|
+
default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
|
|
226
|
+
pageData: { frontmatter: {}, headings: [], title: dir.title },
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme, ${s}, initialSiteData);
|
|
234
|
+
${o}
|
|
235
|
+
app.mount('#app');
|
|
236
|
+
|
|
237
|
+
// Load search index in the background after the app is mounted
|
|
238
|
+
import('${t.searchIndex}').then((m) => { searchIndexRef.value = m.default; });
|
|
239
|
+
|
|
240
|
+
// Accept HMR so modules update without a full page reload
|
|
241
|
+
if (import.meta.hot) {
|
|
242
|
+
import.meta.hot.accept('${t.pages}', (m) => {
|
|
243
|
+
if (!m) return;
|
|
244
|
+
const base = path.join('/', '${n}', router.route.path);
|
|
245
|
+
const hadPage = !!findPage(base);
|
|
246
|
+
pages = m.pages;
|
|
247
|
+
const hasPage = !!findPage(base);
|
|
248
|
+
// Current page was removed (deleted or renamed away)
|
|
249
|
+
if (hadPage && !hasPage) router.go(getParentUrl(router.route.path));
|
|
250
|
+
// A real page appeared where a directory index was shown
|
|
251
|
+
if (!hadPage && hasPage) router.go(router.route.path);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
import.meta.hot.accept('${t.searchIndex}', (m) => {
|
|
255
|
+
if (m) searchIndexRef.value = m.default;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
import.meta.hot.accept('${t.siteData}', (m) => {
|
|
259
|
+
if (m) siteData.value = m.default;
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Update route.data directly when content changes - Vue SFC setup only re-runs on script block changes
|
|
263
|
+
import.meta.hot.on('${t.pageDataEvent}', ({ filepath, pageData }) => {
|
|
264
|
+
const eventBase = path.join('/', '${n}', path.stripExtension(filepath));
|
|
265
|
+
const routeBase = path.join('/', '${n}', router.route.path);
|
|
266
|
+
if (eventBase === routeBase) {
|
|
267
|
+
router.route.data = pageData;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/node/lib/codegen/theme.ts
|
|
275
|
+
var F = "typerighter/client/theme-default";
|
|
276
|
+
function I(e, t) {
|
|
277
|
+
let n = e?.notFound ? `import CustomNotFound from ${JSON.stringify(t ? A.resolve(t, e.notFound) : e.notFound)};` : "", i = e?.notFound ? ", NotFound: CustomNotFound" : "";
|
|
278
|
+
if (e?.component) {
|
|
279
|
+
let r = t ? A.resolve(t, e.component) : e.component;
|
|
280
|
+
return [
|
|
281
|
+
`import CustomLayout from ${JSON.stringify(r)};`,
|
|
282
|
+
n,
|
|
283
|
+
`export default { Layout: CustomLayout${i} };`
|
|
284
|
+
].filter(Boolean).join("\n");
|
|
285
|
+
}
|
|
286
|
+
let a = Object.entries(e?.slots ?? {});
|
|
287
|
+
if (0 < a.length) {
|
|
288
|
+
let e = a.map(([e, t]) => `${JSON.stringify(r(e))}: () => h(resolveComponent(${JSON.stringify(t)}))`).join(", ");
|
|
289
|
+
return [
|
|
290
|
+
`import DefaultTheme from ${JSON.stringify(F)};`,
|
|
291
|
+
"import { h, resolveComponent } from 'vue';",
|
|
292
|
+
n,
|
|
293
|
+
`export default { Layout: { render() { return h(DefaultTheme.Layout, null, { ${e} }); } }${i} };`
|
|
294
|
+
].filter(Boolean).join("\n");
|
|
295
|
+
}
|
|
296
|
+
return n ? [
|
|
297
|
+
`import DefaultTheme from ${JSON.stringify(F)};`,
|
|
298
|
+
n,
|
|
299
|
+
`export default { ...DefaultTheme${i} };`
|
|
300
|
+
].join("\n") : `export { default } from ${JSON.stringify(F)};`;
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/node/lib/codegen/components.ts
|
|
304
|
+
async function Fe(e, t) {
|
|
305
|
+
let n = [];
|
|
306
|
+
for (let r of e) if (r.kind === "dir") {
|
|
307
|
+
let e = A.resolve(t, r.path), i;
|
|
308
|
+
try {
|
|
309
|
+
i = await fe(e);
|
|
310
|
+
} catch {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
for (let t of i) {
|
|
314
|
+
if (!t.endsWith(".vue")) continue;
|
|
315
|
+
let r = t.slice(0, -4);
|
|
316
|
+
n.push({
|
|
317
|
+
name: r,
|
|
318
|
+
absolutePath: A.join(e, t)
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
} else n.push({
|
|
322
|
+
name: r.name,
|
|
323
|
+
absolutePath: A.resolve(t, r.source)
|
|
324
|
+
});
|
|
325
|
+
return n;
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
176
328
|
//#region src/node/lib/progress.ts
|
|
177
|
-
var
|
|
329
|
+
var L = [
|
|
178
330
|
"◐",
|
|
179
331
|
"◓",
|
|
180
332
|
"◑",
|
|
181
333
|
"◒"
|
|
182
|
-
],
|
|
334
|
+
], R = class {
|
|
183
335
|
logger;
|
|
184
336
|
label;
|
|
185
337
|
start;
|
|
@@ -187,8 +339,8 @@ var P = [
|
|
|
187
339
|
constructor(e, t) {
|
|
188
340
|
if (this.logger = e, this.label = t, this.start = performance.now(), process.stdout.isTTY) {
|
|
189
341
|
let e = 0;
|
|
190
|
-
process.stdout.write(
|
|
191
|
-
e = (e + 1) %
|
|
342
|
+
process.stdout.write(M.cyan(`${L[0]} ${t}`)), this.spinnerInterval = setInterval(() => {
|
|
343
|
+
e = (e + 1) % L.length, process.stdout.write(`\r${M.cyan(`${L[e]} ${this.label}`)}`);
|
|
192
344
|
}, 120).unref();
|
|
193
345
|
} else this.logger.start(t);
|
|
194
346
|
}
|
|
@@ -200,67 +352,82 @@ var P = [
|
|
|
200
352
|
done(e) {
|
|
201
353
|
this.stopSpinner(), process.stdout.isTTY && process.stdout.write("\r\x1B[K");
|
|
202
354
|
let t = Math.round(performance.now() - this.start);
|
|
203
|
-
this.logger.success(`${e} (${
|
|
355
|
+
this.logger.success(`${e} (${Ie(t)})`);
|
|
204
356
|
}
|
|
205
357
|
stopSpinner() {
|
|
206
358
|
this.spinnerInterval &&= (clearInterval(this.spinnerInterval), void 0);
|
|
207
359
|
}
|
|
208
360
|
};
|
|
209
|
-
function
|
|
361
|
+
function Ie(e) {
|
|
210
362
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
211
363
|
}
|
|
212
364
|
//#endregion
|
|
213
365
|
//#region src/node/build/index.ts
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
let { root: n, logger: r } = e, i = k.resolve(n, t.outDir ?? "dist"), a = k.join(i, ".client"), o = k.join(i, ".server");
|
|
366
|
+
async function Le(e, t = {}) {
|
|
367
|
+
let { root: n, logger: r } = e, i = A.resolve(n, t.outDir ?? "dist"), a = A.join(i, ".client"), o = A.join(i, ".server");
|
|
217
368
|
await N.rm(i, {
|
|
218
369
|
recursive: !0,
|
|
219
370
|
force: !0
|
|
220
371
|
});
|
|
221
|
-
let s = await e.getTdContext(), [
|
|
372
|
+
let s = await e.getTdContext(), [c, l, d] = await Promise.all([
|
|
222
373
|
s.getConfig(),
|
|
223
374
|
s.listFiles(),
|
|
224
375
|
s.listSidebar()
|
|
225
|
-
]), f =
|
|
376
|
+
]), f = c.origin ?? void 0, p = c.author ?? void 0, m = c.license ?? void 0, h = c.repo ?? void 0, g = t.base ?? c.basePath ?? "/", _ = g.endsWith("/") ? g : g + "/", y = d.map((e) => ({
|
|
226
377
|
...e,
|
|
227
378
|
header: {}
|
|
228
|
-
})), b =
|
|
229
|
-
title:
|
|
230
|
-
description:
|
|
231
|
-
basePath:
|
|
379
|
+
})), b = v(y), x = JSON.stringify({
|
|
380
|
+
title: c.siteTitle,
|
|
381
|
+
description: c.siteDescription,
|
|
382
|
+
basePath: _,
|
|
232
383
|
origin: f,
|
|
233
|
-
lang:
|
|
234
|
-
|
|
384
|
+
lang: c.lang,
|
|
385
|
+
rootDir: c.rootDir,
|
|
386
|
+
repo: h,
|
|
387
|
+
author: p,
|
|
388
|
+
license: m,
|
|
389
|
+
nav: c.nav
|
|
235
390
|
}), S = JSON.stringify({
|
|
236
391
|
ready: !0,
|
|
237
392
|
contentTree: b
|
|
238
|
-
}), C =
|
|
393
|
+
}), C = A.join(n, "node_modules", ".typerighter");
|
|
239
394
|
await N.mkdir(C, { recursive: !0 });
|
|
240
|
-
let w =
|
|
241
|
-
await Promise.all([
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
395
|
+
let w = A.join(C, "client-entry.js"), T = A.join(C, "ssr-entry.js"), E = A.join(C, "theme.js"), D = await Fe(c.components, n), O = I(c.layout ?? void 0, n);
|
|
396
|
+
await Promise.all([
|
|
397
|
+
N.writeFile(w, P({
|
|
398
|
+
rootDir: c.rootDir,
|
|
399
|
+
basePath: _,
|
|
400
|
+
origin: f,
|
|
401
|
+
lang: c.lang,
|
|
402
|
+
siteTitle: c.siteTitle,
|
|
403
|
+
siteDescription: c.siteDescription,
|
|
404
|
+
repo: h,
|
|
405
|
+
author: p,
|
|
406
|
+
license: m,
|
|
407
|
+
nav: c.nav,
|
|
408
|
+
userComponents: D
|
|
409
|
+
}, {
|
|
410
|
+
theme: X,
|
|
411
|
+
pages: K,
|
|
412
|
+
siteData: J,
|
|
413
|
+
searchIndex: Y,
|
|
414
|
+
pageDataEvent: Z
|
|
415
|
+
})),
|
|
416
|
+
N.writeFile(T, Re({
|
|
417
|
+
rootDir: c.rootDir,
|
|
418
|
+
siteConfig: x,
|
|
419
|
+
siteData: S,
|
|
420
|
+
themeModulePath: E,
|
|
421
|
+
userComponents: D
|
|
422
|
+
})),
|
|
423
|
+
N.writeFile(E, O)
|
|
424
|
+
]);
|
|
258
425
|
try {
|
|
259
|
-
let s = $({ context: e }), m = e.createViteLogger(), h = new
|
|
260
|
-
await
|
|
426
|
+
let s = $t({ context: e }), m = e.createViteLogger(), h = new R(r, "Building client bundle...");
|
|
427
|
+
await ue({
|
|
261
428
|
...t.viteConfig,
|
|
262
429
|
root: n,
|
|
263
|
-
base:
|
|
430
|
+
base: _,
|
|
264
431
|
plugins: s,
|
|
265
432
|
customLogger: m,
|
|
266
433
|
logLevel: "silent",
|
|
@@ -275,13 +442,13 @@ async function I(e, t = {}) {
|
|
|
275
442
|
}
|
|
276
443
|
}
|
|
277
444
|
});
|
|
278
|
-
let g = await N.readdir(
|
|
445
|
+
let g = await N.readdir(A.join(a, "assets")).catch(() => []);
|
|
279
446
|
h.done(`Client bundle (${g.length} chunks)`);
|
|
280
|
-
let
|
|
281
|
-
await
|
|
447
|
+
let v = new R(r, "Building SSR bundle...");
|
|
448
|
+
await ue({
|
|
282
449
|
...t.viteConfig,
|
|
283
450
|
root: n,
|
|
284
|
-
base:
|
|
451
|
+
base: _,
|
|
285
452
|
plugins: s,
|
|
286
453
|
customLogger: m,
|
|
287
454
|
logLevel: "silent",
|
|
@@ -291,36 +458,36 @@ async function I(e, t = {}) {
|
|
|
291
458
|
ssr: T,
|
|
292
459
|
emptyOutDir: !0
|
|
293
460
|
}
|
|
294
|
-
}),
|
|
295
|
-
let y =
|
|
296
|
-
let t =
|
|
461
|
+
}), v.done("SSR bundle");
|
|
462
|
+
let y = l.map((e) => {
|
|
463
|
+
let t = u(e);
|
|
297
464
|
return t === "index" ? "/" : `/${t}`;
|
|
298
465
|
});
|
|
299
|
-
y.push("/"),
|
|
300
|
-
let x = new
|
|
301
|
-
await
|
|
302
|
-
ssrEntryPath:
|
|
466
|
+
y.push("/"), Be(b.entries, "", y);
|
|
467
|
+
let x = new R(r, "Pre-rendering pages...");
|
|
468
|
+
await je({
|
|
469
|
+
ssrEntryPath: A.join(o, "ssr-entry.js"),
|
|
303
470
|
clientOutDir: a,
|
|
304
471
|
outDir: i,
|
|
305
|
-
base:
|
|
472
|
+
base: _,
|
|
306
473
|
origin: f,
|
|
307
|
-
lang:
|
|
474
|
+
lang: c.lang,
|
|
308
475
|
pagePaths: y,
|
|
309
|
-
siteTitle:
|
|
476
|
+
siteTitle: c.siteTitle,
|
|
310
477
|
author: p,
|
|
311
478
|
progress: x
|
|
312
479
|
}), x.done(`Pre-rendered ${y.length} pages`);
|
|
313
480
|
let S = /* @__PURE__ */ new Map();
|
|
314
481
|
for (let e of d) {
|
|
315
|
-
let t =
|
|
482
|
+
let t = u(e.filepath), n = t === "index" ? "/" : `/${t}`;
|
|
316
483
|
S.set(n, e.fileMetadata.mtime);
|
|
317
484
|
}
|
|
318
|
-
let C =
|
|
319
|
-
f !== void 0 && (E.push(N.writeFile(
|
|
320
|
-
let
|
|
321
|
-
await N.cp(
|
|
322
|
-
let
|
|
323
|
-
await N.cp(
|
|
485
|
+
let C = Ee(y, _, f, S), E = [N.writeFile(A.join(i, "sitemap.xml"), C)];
|
|
486
|
+
f !== void 0 && (E.push(N.writeFile(A.join(i, "robots.txt"), De(f, _))), E.push(N.writeFile(A.join(i, "feed.xml"), Oe(d, _, f, c.siteTitle, c.siteDescription, c.lang)))), await Promise.all(E);
|
|
487
|
+
let D = A.join(a, "assets"), O = A.join(i, "assets");
|
|
488
|
+
await N.cp(D, O, { recursive: !0 }).catch(() => {}), await ze(A.join(n, c.rootDir), i);
|
|
489
|
+
let ee = A.join(n, c.publicDir);
|
|
490
|
+
await N.cp(ee, i, { recursive: !0 }).catch(() => {});
|
|
324
491
|
} finally {
|
|
325
492
|
await Promise.all([
|
|
326
493
|
N.rm(C, {
|
|
@@ -339,21 +506,21 @@ async function I(e, t = {}) {
|
|
|
339
506
|
}
|
|
340
507
|
r.log(`\nBuild complete. Output: ${i}`);
|
|
341
508
|
}
|
|
342
|
-
function
|
|
343
|
-
let t = `/${e.rootDir}/${
|
|
509
|
+
function Re(e) {
|
|
510
|
+
let t = `/${e.rootDir}/${d}`, n = JSON.parse(e.siteConfig), r = JSON.parse(e.siteData), i = r.contentTree ?? { entries: [] }, o = _(i.entries ?? [], n.title ?? ""), s = JSON.stringify({
|
|
344
511
|
...r,
|
|
345
512
|
directoryListings: o
|
|
346
|
-
});
|
|
513
|
+
}), c = e.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");
|
|
347
514
|
return `
|
|
348
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
515
|
+
${[l, "import { createTypedownApp } from 'typerighter/client';"].filter(Boolean).join("\n")}
|
|
349
516
|
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
350
517
|
import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
|
|
351
518
|
import { renderToString } from 'vue/server-renderer';
|
|
352
519
|
import { h } from 'vue';
|
|
353
|
-
import theme from
|
|
520
|
+
import theme from ${JSON.stringify(e.themeModulePath)};
|
|
354
521
|
|
|
355
522
|
const pages = import.meta.glob('${t}', { eager: true });
|
|
356
|
-
const contentExts = ${JSON.stringify(
|
|
523
|
+
const contentExts = ${JSON.stringify(a)};
|
|
357
524
|
const siteData = ${s};
|
|
358
525
|
|
|
359
526
|
function findPage(base) {
|
|
@@ -381,7 +548,8 @@ function loadPageModule(pagePath) {
|
|
|
381
548
|
}
|
|
382
549
|
|
|
383
550
|
export async function createRenderer() {
|
|
384
|
-
const { app, router } = await createTypedownApp(loadPageModule, theme
|
|
551
|
+
const { app, router } = await createTypedownApp(loadPageModule, theme, ${e.siteConfig}, siteData);
|
|
552
|
+
${u}
|
|
385
553
|
return async function render(url) {
|
|
386
554
|
await router.go(url, { replace: true });
|
|
387
555
|
const html = await renderToString(app);
|
|
@@ -390,32 +558,32 @@ export async function createRenderer() {
|
|
|
390
558
|
}
|
|
391
559
|
`;
|
|
392
560
|
}
|
|
393
|
-
async function
|
|
561
|
+
async function ze(e, t) {
|
|
394
562
|
let n = (await N.readdir(e, {
|
|
395
563
|
recursive: !0,
|
|
396
564
|
withFileTypes: !0
|
|
397
|
-
})).filter((e) => e.isFile() && !
|
|
398
|
-
let r =
|
|
399
|
-
return N.mkdir(
|
|
565
|
+
})).filter((e) => e.isFile() && !l(e.name)).map(async (n) => {
|
|
566
|
+
let r = A.join(n.parentPath, n.name), i = A.relative(e, r), a = A.join(t, i);
|
|
567
|
+
return N.mkdir(A.dirname(a), { recursive: !0 }).then(() => N.copyFile(r, a));
|
|
400
568
|
});
|
|
401
569
|
await Promise.all(n);
|
|
402
570
|
}
|
|
403
|
-
function
|
|
571
|
+
function Be(e, t, n) {
|
|
404
572
|
for (let r of e) {
|
|
405
573
|
if (r.kind !== "dir") continue;
|
|
406
574
|
let e = `${t}/${r.node.name}`;
|
|
407
|
-
|
|
575
|
+
p(r.node) || n.push(S(e)), Be(r.node.entries, e, n);
|
|
408
576
|
}
|
|
409
577
|
}
|
|
410
578
|
//#endregion
|
|
411
579
|
//#region ../../node_modules/.pnpm/@shikijs+transformers@4.4.3/node_modules/@shikijs/transformers/dist/index.mjs
|
|
412
|
-
var
|
|
580
|
+
var Ve = /(\s+\/\/)/, He = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/, Ue = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/, We = [
|
|
413
581
|
[/^(<!--)(.+)(-->)$/, !1],
|
|
414
582
|
[/^(\/\*)(.+)(\*\/)$/, !1],
|
|
415
583
|
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, !0],
|
|
416
584
|
[/^(\*)(.+)$/, !0]
|
|
417
585
|
];
|
|
418
|
-
function
|
|
586
|
+
function Ge(e, t, n) {
|
|
419
587
|
let r = [];
|
|
420
588
|
for (let i of e) {
|
|
421
589
|
if (n === "v3") {
|
|
@@ -424,8 +592,8 @@ function Be(e, t, n) {
|
|
|
424
592
|
let n = e.children[0];
|
|
425
593
|
if (n.type !== "text") return e;
|
|
426
594
|
let r = t === i.children.length - 1;
|
|
427
|
-
if (!
|
|
428
|
-
let a = n.value.split(
|
|
595
|
+
if (!z(n.value, r)) return e;
|
|
596
|
+
let a = n.value.split(Ve);
|
|
429
597
|
if (a.length <= 1) return e;
|
|
430
598
|
let o = [a[0]];
|
|
431
599
|
for (let e = 1; e < a.length; e += 2) o.push(a[e] + (a[e + 1] || ""));
|
|
@@ -446,13 +614,13 @@ function Be(e, t, n) {
|
|
|
446
614
|
if (a.type !== "element") continue;
|
|
447
615
|
let o = a.children.at(0);
|
|
448
616
|
if (o?.type !== "text") continue;
|
|
449
|
-
let s = n === e.length - 1, c =
|
|
617
|
+
let s = n === e.length - 1, c = z(o.value, s), l;
|
|
450
618
|
if (!c && n > 0 && o.value.trim().startsWith("[!code")) {
|
|
451
619
|
let t = e[n - 1];
|
|
452
620
|
if (t?.type === "element") {
|
|
453
621
|
let n = t.children.at(0);
|
|
454
622
|
if (n?.type === "text" && n.value.includes("//")) {
|
|
455
|
-
let l =
|
|
623
|
+
let l = z(n.value + o.value, s);
|
|
456
624
|
if (l) {
|
|
457
625
|
c = l, r.push({
|
|
458
626
|
info: l,
|
|
@@ -469,7 +637,7 @@ function Be(e, t, n) {
|
|
|
469
637
|
}
|
|
470
638
|
if (c) {
|
|
471
639
|
if (t && !s && n !== 0) {
|
|
472
|
-
let t =
|
|
640
|
+
let t = Ke(e[n - 1], "{") && Ke(e[n + 1], "}");
|
|
473
641
|
r.push({
|
|
474
642
|
info: c,
|
|
475
643
|
line: i,
|
|
@@ -491,16 +659,16 @@ function Be(e, t, n) {
|
|
|
491
659
|
}
|
|
492
660
|
return r;
|
|
493
661
|
}
|
|
494
|
-
function
|
|
662
|
+
function Ke(e, t) {
|
|
495
663
|
if (e.type !== "element") return !1;
|
|
496
664
|
let n = e.children[0];
|
|
497
665
|
return n.type === "text" && n.value.trim() === t;
|
|
498
666
|
}
|
|
499
|
-
function
|
|
667
|
+
function z(e, t) {
|
|
500
668
|
let n = e.trimStart(), r = e.length - n.length;
|
|
501
669
|
n = n.trimEnd();
|
|
502
670
|
let i = e.length - n.length - r;
|
|
503
|
-
for (let [e, a] of
|
|
671
|
+
for (let [e, a] of We) {
|
|
504
672
|
if (a && !t) continue;
|
|
505
673
|
let o = e.exec(n);
|
|
506
674
|
if (o) return [
|
|
@@ -510,22 +678,22 @@ function R(e, t) {
|
|
|
510
678
|
];
|
|
511
679
|
}
|
|
512
680
|
}
|
|
513
|
-
function
|
|
514
|
-
let t = e.match(
|
|
681
|
+
function qe(e) {
|
|
682
|
+
let t = e.match(He);
|
|
515
683
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index) : e;
|
|
516
684
|
}
|
|
517
|
-
function
|
|
518
|
-
let t = e.match(
|
|
685
|
+
function Je(e) {
|
|
686
|
+
let t = e.match(Ue);
|
|
519
687
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index).trimEnd() : e;
|
|
520
688
|
}
|
|
521
|
-
function
|
|
689
|
+
function Ye(e, t, n, r) {
|
|
522
690
|
return r ??= "v3", {
|
|
523
691
|
name: e,
|
|
524
692
|
code(e) {
|
|
525
693
|
let i = e.children.filter((e) => e.type === "element"), a = [];
|
|
526
694
|
e.data ??= {};
|
|
527
695
|
let o = e.data;
|
|
528
|
-
o._shiki_notation ??=
|
|
696
|
+
o._shiki_notation ??= Ge(i, ["jsx", "tsx"].includes(this.options.lang), r);
|
|
529
697
|
let s = o._shiki_notation;
|
|
530
698
|
for (let e of s) {
|
|
531
699
|
if (e.info[1].length === 0) continue;
|
|
@@ -533,7 +701,7 @@ function We(e, t, n, r) {
|
|
|
533
701
|
e.isLineCommentOnly && r !== "v1" && o++;
|
|
534
702
|
let s = !1;
|
|
535
703
|
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;
|
|
536
|
-
r === "v1" ? e.info[1] =
|
|
704
|
+
r === "v1" ? e.info[1] = qe(e.info[1]) : r === "v3" && (e.info[1] = Je(e.info[1]));
|
|
537
705
|
let c = e.info[1].trim().length === 0;
|
|
538
706
|
if (c && (e.info[1] = ""), c && e.isLineCommentOnly) a.push(e.line);
|
|
539
707
|
else if (c && e.isJsxStyle) e.line.children.splice(e.line.children.indexOf(e.token) - 1, 3);
|
|
@@ -558,44 +726,44 @@ function We(e, t, n, r) {
|
|
|
558
726
|
}
|
|
559
727
|
};
|
|
560
728
|
}
|
|
561
|
-
var
|
|
562
|
-
function
|
|
729
|
+
var Xe = /\{([\d,-]+)\}/;
|
|
730
|
+
function Ze(e) {
|
|
563
731
|
if (!e) return null;
|
|
564
|
-
let t = e.match(
|
|
732
|
+
let t = e.match(Xe);
|
|
565
733
|
return t ? t[1].split(",").flatMap((e) => {
|
|
566
734
|
let t = e.split("-").map((e) => Number.parseInt(e, 10));
|
|
567
735
|
return t.length === 1 ? [t[0]] : Array.from({ length: t[1] - t[0] + 1 }, (e, n) => t[0] + n);
|
|
568
736
|
}) : null;
|
|
569
737
|
}
|
|
570
|
-
var
|
|
571
|
-
function
|
|
738
|
+
var Qe = Symbol("highlighted-lines");
|
|
739
|
+
function $e(e = {}) {
|
|
572
740
|
let { className: t = "highlighted", zeroIndexed: n = !1 } = e;
|
|
573
741
|
return {
|
|
574
742
|
name: "@shikijs/transformers:meta-highlight",
|
|
575
743
|
line(e, r) {
|
|
576
744
|
if (!this.options.meta?.__raw) return;
|
|
577
745
|
let i = this.meta;
|
|
578
|
-
i[
|
|
579
|
-
let a = i[
|
|
746
|
+
i[Qe] ??= Ze(this.options.meta.__raw);
|
|
747
|
+
let a = i[Qe] ?? [], o = n ? r - 1 : r;
|
|
580
748
|
return a.includes(o) && this.addClassToHast(e, t), e;
|
|
581
749
|
}
|
|
582
750
|
};
|
|
583
751
|
}
|
|
584
|
-
var
|
|
585
|
-
function
|
|
586
|
-
return e.replace(
|
|
752
|
+
var et = /[.*+?^${}()|[\]\\]/g;
|
|
753
|
+
function tt(e) {
|
|
754
|
+
return e.replace(et, "\\$&");
|
|
587
755
|
}
|
|
588
|
-
function
|
|
756
|
+
function B(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
589
757
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
590
|
-
return
|
|
758
|
+
return Ye(t, RegExp(`#?\\s*\\[!code (${Object.keys(n).map(tt).join("|")})(:\\d+)?\\]`, "gi"), function([e, t, a = ":1"], o, s, c, l) {
|
|
591
759
|
let u = Number.parseInt(a.slice(1), 10);
|
|
592
760
|
for (let e = l; e < Math.min(l + u, c.length); e++) this.addClassToHast(c[e], n[t]);
|
|
593
761
|
return r && this.addClassToHast(this.pre, r), i && this.addClassToHast(this.code, i), !0;
|
|
594
762
|
}, e.matchAlgorithm);
|
|
595
763
|
}
|
|
596
|
-
function
|
|
764
|
+
function nt(e = {}) {
|
|
597
765
|
let { classLineAdd: t = "diff add", classLineRemove: n = "diff remove", classActivePre: r = "has-diff", classActiveCode: i } = e;
|
|
598
|
-
return
|
|
766
|
+
return B({
|
|
599
767
|
classMap: {
|
|
600
768
|
"++": t,
|
|
601
769
|
"--": n
|
|
@@ -605,31 +773,31 @@ function Ze(e = {}) {
|
|
|
605
773
|
matchAlgorithm: e.matchAlgorithm
|
|
606
774
|
}, "@shikijs/transformers:notation-diff");
|
|
607
775
|
}
|
|
608
|
-
function
|
|
776
|
+
function rt(e = {}) {
|
|
609
777
|
let { classMap: t = {
|
|
610
778
|
error: ["highlighted", "error"],
|
|
611
779
|
warning: ["highlighted", "warning"],
|
|
612
780
|
info: ["highlighted", "info"]
|
|
613
781
|
}, classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
614
|
-
return
|
|
782
|
+
return B({
|
|
615
783
|
classMap: t,
|
|
616
784
|
classActivePre: n,
|
|
617
785
|
classActiveCode: r,
|
|
618
786
|
matchAlgorithm: e.matchAlgorithm
|
|
619
787
|
}, "@shikijs/transformers:notation-error-level");
|
|
620
788
|
}
|
|
621
|
-
function
|
|
789
|
+
function it(e = {}) {
|
|
622
790
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
623
|
-
return
|
|
791
|
+
return B({
|
|
624
792
|
classMap: { focus: t },
|
|
625
793
|
classActivePre: n,
|
|
626
794
|
classActiveCode: r,
|
|
627
795
|
matchAlgorithm: e.matchAlgorithm
|
|
628
796
|
}, "@shikijs/transformers:notation-focus");
|
|
629
797
|
}
|
|
630
|
-
function
|
|
798
|
+
function at(e = {}) {
|
|
631
799
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
632
|
-
return
|
|
800
|
+
return B({
|
|
633
801
|
classMap: {
|
|
634
802
|
highlight: t,
|
|
635
803
|
hl: t
|
|
@@ -641,42 +809,42 @@ function et(e = {}) {
|
|
|
641
809
|
}
|
|
642
810
|
//#endregion
|
|
643
811
|
//#region src/node/lib/render/highlight/language.ts
|
|
644
|
-
var
|
|
812
|
+
var ot = [
|
|
645
813
|
"shellscript",
|
|
646
814
|
"shell",
|
|
647
815
|
"bash",
|
|
648
816
|
"sh",
|
|
649
817
|
"zsh"
|
|
650
818
|
];
|
|
651
|
-
function
|
|
652
|
-
return
|
|
819
|
+
function st(e) {
|
|
820
|
+
return ot.includes(e);
|
|
653
821
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
656
|
-
return
|
|
822
|
+
var ct = /^[a-zA-Z0-9-_]+/;
|
|
823
|
+
function lt(e) {
|
|
824
|
+
return ct.exec(e)?.[0] || "";
|
|
657
825
|
}
|
|
658
826
|
//#endregion
|
|
659
827
|
//#region src/node/lib/render/highlight/index.ts
|
|
660
|
-
var
|
|
828
|
+
var ut = new FinalizationRegistry((e) => {
|
|
661
829
|
e();
|
|
662
|
-
}),
|
|
830
|
+
}), V = {
|
|
663
831
|
light: "github-light",
|
|
664
832
|
dark: "github-dark"
|
|
665
833
|
};
|
|
666
|
-
async function
|
|
667
|
-
let e = await
|
|
668
|
-
themes: [
|
|
834
|
+
async function dt() {
|
|
835
|
+
let e = await ge({
|
|
836
|
+
themes: [V.light, V.dark],
|
|
669
837
|
langs: []
|
|
670
838
|
}), t = [
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
839
|
+
$e(),
|
|
840
|
+
nt(),
|
|
841
|
+
it({
|
|
674
842
|
classActiveLine: "has-focus",
|
|
675
843
|
classActivePre: "has-focused-lines"
|
|
676
844
|
}),
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
845
|
+
at(),
|
|
846
|
+
rt(),
|
|
847
|
+
ft(),
|
|
680
848
|
{
|
|
681
849
|
name: "typedown:add-dir",
|
|
682
850
|
pre(e) {
|
|
@@ -685,19 +853,19 @@ async function ot() {
|
|
|
685
853
|
}
|
|
686
854
|
], n = new Set(e.getLoadedLanguages());
|
|
687
855
|
async function r(r, i, a) {
|
|
688
|
-
let o =
|
|
856
|
+
let o = lt(i);
|
|
689
857
|
if (o) {
|
|
690
858
|
let e = i;
|
|
691
859
|
i = o.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
692
860
|
}
|
|
693
861
|
i ||= "txt";
|
|
694
862
|
try {
|
|
695
|
-
!
|
|
863
|
+
!ve(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
696
864
|
} catch {
|
|
697
865
|
re.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
698
866
|
}
|
|
699
867
|
r = r.trimEnd();
|
|
700
|
-
let s =
|
|
868
|
+
let s = _e(r, i, e);
|
|
701
869
|
return await e.loadLanguage(...s), e.codeToHtml(r, {
|
|
702
870
|
lang: i,
|
|
703
871
|
transformers: [...t, {
|
|
@@ -714,7 +882,7 @@ async function ot() {
|
|
|
714
882
|
}
|
|
715
883
|
}],
|
|
716
884
|
meta: { __raw: a },
|
|
717
|
-
themes:
|
|
885
|
+
themes: V,
|
|
718
886
|
defaultColor: !1,
|
|
719
887
|
colorReplacements: {
|
|
720
888
|
"github-light": {
|
|
@@ -739,13 +907,13 @@ async function ot() {
|
|
|
739
907
|
}
|
|
740
908
|
});
|
|
741
909
|
}
|
|
742
|
-
return
|
|
910
|
+
return ut.register(r, () => e.dispose()), r;
|
|
743
911
|
}
|
|
744
|
-
function
|
|
912
|
+
function ft() {
|
|
745
913
|
return {
|
|
746
914
|
name: "typedown:disable-shell-symbol-select",
|
|
747
915
|
tokens(e) {
|
|
748
|
-
if (
|
|
916
|
+
if (st(this.options.lang)) for (let t of e) {
|
|
749
917
|
if (t.length < 2) continue;
|
|
750
918
|
let e = t[0].content.trim();
|
|
751
919
|
(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));
|
|
@@ -755,20 +923,26 @@ function st() {
|
|
|
755
923
|
}
|
|
756
924
|
//#endregion
|
|
757
925
|
//#region src/node/lib/render/postprocess.ts
|
|
758
|
-
var
|
|
759
|
-
async function
|
|
760
|
-
return e = await
|
|
926
|
+
var H;
|
|
927
|
+
async function pt(e) {
|
|
928
|
+
return e = await gt(e), e = bt(e), e;
|
|
929
|
+
}
|
|
930
|
+
function mt() {
|
|
931
|
+
return H ||= dt(), H;
|
|
761
932
|
}
|
|
762
|
-
|
|
763
|
-
|
|
933
|
+
var ht = /<pre class="td-code-placeholder"([^>]*)><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
934
|
+
function U(e, t) {
|
|
935
|
+
return e.match(RegExp(`${t}="([^"]*)"`))?.[1];
|
|
764
936
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
let t = await lt(), n = [...e.matchAll(ut)];
|
|
937
|
+
async function gt(e) {
|
|
938
|
+
let t = await mt(), n = [...e.matchAll(ht)];
|
|
768
939
|
if (n.length === 0) return e;
|
|
769
940
|
let r = await Promise.all(n.map(async (e) => {
|
|
770
|
-
let n = e[1]
|
|
771
|
-
return
|
|
941
|
+
let n = e[1], r = U(n, "data-lang") ?? "", i = U(n, "data-meta") ?? "", a = U(n, "data-title"), o = U(n, "data-line-numbers"), s = g(e[2]);
|
|
942
|
+
return _t(await t(s, r, i), r, {
|
|
943
|
+
title: a,
|
|
944
|
+
lineNumbers: o
|
|
945
|
+
});
|
|
772
946
|
})), i = e;
|
|
773
947
|
for (let e = n.length - 1; 0 <= e; e--) {
|
|
774
948
|
let t = n[e];
|
|
@@ -776,25 +950,39 @@ async function dt(e) {
|
|
|
776
950
|
}
|
|
777
951
|
return i;
|
|
778
952
|
}
|
|
779
|
-
function
|
|
953
|
+
function _t(e, t, n) {
|
|
780
954
|
t ||= "txt";
|
|
781
|
-
let r = t.replace(/_/g, " "), i =
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
let
|
|
786
|
-
|
|
955
|
+
let r = n.title ?? t.replace(/_/g, " "), i = ["language-" + t];
|
|
956
|
+
n.title && i.push("has-title"), n.lineNumbers !== void 0 && i.push("line-numbers-mode");
|
|
957
|
+
let a = `<div class="${i.join(" ")}"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">${h(r)}</span>` + e;
|
|
958
|
+
if (n.lineNumbers !== void 0) {
|
|
959
|
+
let e = parseInt(n.lineNumbers) || 1, t = a.slice(a.indexOf("<code>"), a.indexOf("</code>")).split("\n").length, r = [...Array(t)].map((t, n) => `<span class="line-number">${n + e}</span><br>`).join("");
|
|
960
|
+
a += `<div class="line-numbers-wrapper" aria-hidden="true">${r}</div>`;
|
|
787
961
|
}
|
|
788
|
-
return
|
|
789
|
-
}
|
|
790
|
-
var
|
|
791
|
-
function
|
|
792
|
-
return e = e.replace(
|
|
962
|
+
return a += "</div>", a;
|
|
963
|
+
}
|
|
964
|
+
var vt = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, yt = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
965
|
+
function bt(e) {
|
|
966
|
+
return e = e.replace(vt, (e, t) => W(t, !1)), e = e.replace(yt, (e, t) => W(t, !0)), e;
|
|
967
|
+
}
|
|
968
|
+
var xt = /`([^`]+)`|\$([^$]+)\$/g;
|
|
969
|
+
function St(e) {
|
|
970
|
+
let t = 0, n = "";
|
|
971
|
+
for (let r of e.matchAll(xt)) {
|
|
972
|
+
if (n += h(e.slice(t, r.index)), r[1] !== void 0) n += `<code>${h(r[1])}</code>`;
|
|
973
|
+
else if (r[2] !== void 0) try {
|
|
974
|
+
n += ne.renderToString(r[2], { throwOnError: !1 });
|
|
975
|
+
} catch {
|
|
976
|
+
n += h(r[0]);
|
|
977
|
+
}
|
|
978
|
+
t = r.index + r[0].length;
|
|
979
|
+
}
|
|
980
|
+
return n += h(e.slice(t)), n;
|
|
793
981
|
}
|
|
794
|
-
function
|
|
982
|
+
function W(e, t) {
|
|
795
983
|
let n = t ? "div" : "span";
|
|
796
984
|
try {
|
|
797
|
-
return ne.renderToString(
|
|
985
|
+
return ne.renderToString(g(e), {
|
|
798
986
|
throwOnError: !1,
|
|
799
987
|
displayMode: t
|
|
800
988
|
});
|
|
@@ -804,22 +992,24 @@ function H(e, t) {
|
|
|
804
992
|
}
|
|
805
993
|
//#endregion
|
|
806
994
|
//#region src/node/lib/render/vue.ts
|
|
807
|
-
async function
|
|
808
|
-
let r = t.title || t.label || (
|
|
995
|
+
async function G(e, t, n) {
|
|
996
|
+
let r = t.title || t.label || (m(n) ? x(n, (await e.getConfig()).siteTitle) : C(n));
|
|
809
997
|
return {
|
|
810
998
|
schema: t.schema,
|
|
811
999
|
schemaLabel: t.schemaLabel,
|
|
812
1000
|
label: t.label,
|
|
813
1001
|
icon: t.icon,
|
|
814
1002
|
frontmatter: t.header ?? {},
|
|
815
|
-
headings:
|
|
1003
|
+
headings: wt(t.headings),
|
|
816
1004
|
title: r,
|
|
1005
|
+
titleHtml: St(r),
|
|
1006
|
+
filepath: n,
|
|
817
1007
|
fileMetadata: t.fileMetadata,
|
|
818
1008
|
seoMetadata: t.seoMetadata
|
|
819
1009
|
};
|
|
820
1010
|
}
|
|
821
|
-
async function
|
|
822
|
-
let r = await
|
|
1011
|
+
async function Ct(e, t, n) {
|
|
1012
|
+
let r = await pt(t.content), i = await G(e, t, n), a = JSON.stringify(`@typedown/pages?resource=${encodeURIComponent(n)}`);
|
|
823
1013
|
return {
|
|
824
1014
|
vueSrc: [
|
|
825
1015
|
"<script>",
|
|
@@ -831,12 +1021,12 @@ async function gt(e, t, n) {
|
|
|
831
1021
|
`import { pageData } from ${a}`,
|
|
832
1022
|
"useRouter().route.data = pageData",
|
|
833
1023
|
"<\/script>",
|
|
834
|
-
`<template><div class="typedown-content">\n${
|
|
1024
|
+
`<template><div class="typedown-content">\n${Tt(r)}\n</div></template>`
|
|
835
1025
|
].join("\n"),
|
|
836
1026
|
pageData: i
|
|
837
1027
|
};
|
|
838
1028
|
}
|
|
839
|
-
function
|
|
1029
|
+
function wt(e) {
|
|
840
1030
|
let t = [], n = [];
|
|
841
1031
|
for (let r of e) {
|
|
842
1032
|
let e = {
|
|
@@ -852,17 +1042,17 @@ function _t(e) {
|
|
|
852
1042
|
}
|
|
853
1043
|
return t;
|
|
854
1044
|
}
|
|
855
|
-
function
|
|
1045
|
+
function Tt(e) {
|
|
856
1046
|
return e.replaceAll("{{", "{{").replaceAll("}}", "}}");
|
|
857
1047
|
}
|
|
858
1048
|
//#endregion
|
|
859
1049
|
//#region src/node/plugin/vite/constants.ts
|
|
860
|
-
var
|
|
861
|
-
|
|
862
|
-
var q = "\0@typedown/pages?resource=", J = "@typedown/site-data",
|
|
1050
|
+
var Et = "@typedown/app", Dt = "\0@typedown/app", K = "@typedown/pages", Ot = "\0" + K;
|
|
1051
|
+
K + "";
|
|
1052
|
+
var q = "\0@typedown/pages?resource=", J = "@typedown/site-data", kt = "\0@typedown/site-data", Y = "@typedown/search-index", At = "\0@typedown/search-index", X = "@typedown/theme", jt = "\0@typedown/theme", Z = "typedown:page-data";
|
|
863
1053
|
//#endregion
|
|
864
1054
|
//#region src/node/plugin/vite/virtual/utils.ts
|
|
865
|
-
function
|
|
1055
|
+
function Q(e, t) {
|
|
866
1056
|
let n = e.moduleGraph.getModuleById(t);
|
|
867
1057
|
if (n) {
|
|
868
1058
|
e.moduleGraph.invalidateModule(n);
|
|
@@ -879,108 +1069,33 @@ function Z(e, t) {
|
|
|
879
1069
|
}
|
|
880
1070
|
//#endregion
|
|
881
1071
|
//#region src/node/plugin/vite/virtual/app.ts
|
|
882
|
-
var
|
|
1072
|
+
var Mt = class {
|
|
883
1073
|
async load(e) {
|
|
884
|
-
let t = await e.getConfig();
|
|
885
|
-
return
|
|
886
|
-
|
|
887
|
-
|
|
1074
|
+
let t = await (await e.getTdContext()).getConfig(), n = await Fe(t.components, e.root);
|
|
1075
|
+
return P({
|
|
1076
|
+
rootDir: t.rootDir,
|
|
1077
|
+
basePath: t.basePath,
|
|
1078
|
+
origin: t.origin ?? void 0,
|
|
1079
|
+
lang: t.lang,
|
|
1080
|
+
siteTitle: t.siteTitle,
|
|
1081
|
+
siteDescription: t.siteDescription,
|
|
1082
|
+
repo: t.repo ?? void 0,
|
|
1083
|
+
author: t.author ?? void 0,
|
|
1084
|
+
license: t.license ?? void 0,
|
|
1085
|
+
nav: t.nav,
|
|
1086
|
+
userComponents: n
|
|
1087
|
+
}, {
|
|
1088
|
+
theme: X,
|
|
1089
|
+
pages: K,
|
|
1090
|
+
siteData: J,
|
|
1091
|
+
searchIndex: Y,
|
|
1092
|
+
pageDataEvent: Z
|
|
888
1093
|
});
|
|
889
1094
|
}
|
|
890
1095
|
invalidate(e) {
|
|
891
|
-
|
|
1096
|
+
Q(e, Dt);
|
|
892
1097
|
}
|
|
893
|
-
}
|
|
894
|
-
function Q(e) {
|
|
895
|
-
let { rootDir: t = "." } = e, n = JSON.stringify({
|
|
896
|
-
title: e.siteTitle,
|
|
897
|
-
description: e.siteDescription,
|
|
898
|
-
basePath: e.basePath ?? "/",
|
|
899
|
-
origin: e.origin,
|
|
900
|
-
lang: e.lang,
|
|
901
|
-
repo: e.repo,
|
|
902
|
-
author: e.author,
|
|
903
|
-
license: e.license,
|
|
904
|
-
nav: e.nav
|
|
905
|
-
});
|
|
906
|
-
return `
|
|
907
|
-
import 'typerighter/style.css';
|
|
908
|
-
import('typerighter/math.css');
|
|
909
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
910
|
-
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
911
|
-
import { isIndexUrl, getDirectoryFromPageUrl, getParentUrl, path } from 'typerighter/shared';
|
|
912
|
-
import { h } from 'vue';
|
|
913
|
-
import theme from 'typerighter/client/theme-default';
|
|
914
|
-
import { pages as initialPages } from '${G}';
|
|
915
|
-
import initialSiteData from '${J}';
|
|
916
|
-
let pages = initialPages;
|
|
917
|
-
const contentExts = ${JSON.stringify(i)};
|
|
918
|
-
|
|
919
|
-
function findPage(base) {
|
|
920
|
-
for (const ext of contentExts) {
|
|
921
|
-
const key = base + ext;
|
|
922
|
-
if (pages[key]) return pages[key];
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
async function loadPageModule(pagePath) {
|
|
927
|
-
const loader = findPage(path.join('/', '${t}', pagePath));
|
|
928
|
-
if (loader) return loader();
|
|
929
|
-
|
|
930
|
-
if (isIndexUrl(pagePath)) {
|
|
931
|
-
const dirPath = getDirectoryFromPageUrl(pagePath);
|
|
932
|
-
const dir = siteData.value.directoryListings[dirPath];
|
|
933
|
-
if (dir) return {
|
|
934
|
-
default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
|
|
935
|
-
pageData: { frontmatter: {}, headings: [], title: dir.title },
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
return undefined;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme.Layout, ${n}, initialSiteData);
|
|
943
|
-
app.mount('#app');
|
|
944
|
-
|
|
945
|
-
// Load search index in the background after the app is mounted
|
|
946
|
-
import('${Y}').then((m) => { searchIndexRef.value = m.default; });
|
|
947
|
-
|
|
948
|
-
// Accept HMR so modules update without a full page reload
|
|
949
|
-
if (import.meta.hot) {
|
|
950
|
-
import.meta.hot.accept('${G}', (m) => {
|
|
951
|
-
if (!m) return;
|
|
952
|
-
const base = path.join('/', '${t}', router.route.path);
|
|
953
|
-
const hadPage = !!findPage(base);
|
|
954
|
-
pages = m.pages;
|
|
955
|
-
const hasPage = !!findPage(base);
|
|
956
|
-
// Current page was removed (deleted or renamed away)
|
|
957
|
-
if (hadPage && !hasPage) router.go(getParentUrl(router.route.path));
|
|
958
|
-
// A real page appeared where a directory index was shown
|
|
959
|
-
if (!hadPage && hasPage) router.go(router.route.path);
|
|
960
|
-
});
|
|
961
|
-
|
|
962
|
-
import.meta.hot.accept('${Y}', (m) => {
|
|
963
|
-
if (m) searchIndexRef.value = m.default;
|
|
964
|
-
});
|
|
965
|
-
|
|
966
|
-
import.meta.hot.accept('${J}', (m) => {
|
|
967
|
-
if (m) siteData.value = m.default;
|
|
968
|
-
});
|
|
969
|
-
|
|
970
|
-
// Update route.data directly when content changes - Vue SFC setup only re-runs on script block changes
|
|
971
|
-
import.meta.hot.on('${X}', ({ filepath, pageData }) => {
|
|
972
|
-
const eventBase = path.join('/', '${t}', path.stripExtension(filepath));
|
|
973
|
-
const routeBase = path.join('/', '${t}', router.route.path);
|
|
974
|
-
if (eventBase === routeBase) {
|
|
975
|
-
router.route.data = pageData;
|
|
976
|
-
}
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
`;
|
|
980
|
-
}
|
|
981
|
-
//#endregion
|
|
982
|
-
//#region src/node/plugin/vite/virtual/pages.ts
|
|
983
|
-
var Ct = class {
|
|
1098
|
+
}, Nt = class {
|
|
984
1099
|
async load(e) {
|
|
985
1100
|
let t = (await e.getConfig()).rootDir ?? ".";
|
|
986
1101
|
return `export const pages = import.meta.glob('${t === "." ? "/**/*.{td,md}" : `/${t}/**/*.{td,md}`}');`;
|
|
@@ -992,18 +1107,18 @@ var Ct = class {
|
|
|
992
1107
|
return e.startsWith(q);
|
|
993
1108
|
}
|
|
994
1109
|
async loadPageData(e, t) {
|
|
995
|
-
let n = decodeURIComponent(e.slice(q.length)), r = await
|
|
1110
|
+
let n = decodeURIComponent(e.slice(q.length)), r = await G(t, await t.getFile(n), n);
|
|
996
1111
|
return `export const pageData = ${JSON.stringify(r)}`;
|
|
997
1112
|
}
|
|
998
1113
|
invalidatePageData(e, t) {
|
|
999
|
-
|
|
1114
|
+
Q(e, q + encodeURIComponent(t));
|
|
1000
1115
|
}
|
|
1001
1116
|
sendPageData(e, t, n) {
|
|
1002
1117
|
t.getFile(n).then(async (r) => {
|
|
1003
|
-
let i = await
|
|
1118
|
+
let i = await G(t, r, n);
|
|
1004
1119
|
e.hot.send({
|
|
1005
1120
|
type: "custom",
|
|
1006
|
-
event:
|
|
1121
|
+
event: Z,
|
|
1007
1122
|
data: {
|
|
1008
1123
|
filepath: n,
|
|
1009
1124
|
pageData: i
|
|
@@ -1014,55 +1129,62 @@ var Ct = class {
|
|
|
1014
1129
|
});
|
|
1015
1130
|
}
|
|
1016
1131
|
invalidate(e) {
|
|
1017
|
-
|
|
1132
|
+
Q(e, Ot);
|
|
1018
1133
|
}
|
|
1019
|
-
},
|
|
1134
|
+
}, Pt = class {
|
|
1135
|
+
async load(e) {
|
|
1136
|
+
return I((await (await e.getTdContext()).getConfig()).layout ?? void 0, e.root);
|
|
1137
|
+
}
|
|
1138
|
+
invalidate(e) {
|
|
1139
|
+
Q(e, jt);
|
|
1140
|
+
}
|
|
1141
|
+
}, Ft = "\0@typedown/site-data", It = {
|
|
1020
1142
|
ready: !1,
|
|
1021
1143
|
contentTree: { entries: [] },
|
|
1022
1144
|
schemas: {},
|
|
1023
1145
|
directoryListings: {}
|
|
1024
|
-
},
|
|
1146
|
+
}, Lt = class {
|
|
1025
1147
|
data;
|
|
1026
1148
|
scan(e) {
|
|
1027
|
-
let t =
|
|
1149
|
+
let t = xe("**/*.td", {
|
|
1028
1150
|
cwd: e,
|
|
1029
1151
|
exclude: (e) => e.startsWith("_")
|
|
1030
1152
|
}).map((e) => ({
|
|
1031
1153
|
filepath: e,
|
|
1032
|
-
label:
|
|
1154
|
+
label: C(e),
|
|
1033
1155
|
header: {}
|
|
1034
|
-
})), n =
|
|
1156
|
+
})), n = v(t);
|
|
1035
1157
|
this.data = {
|
|
1036
1158
|
contentTree: n,
|
|
1037
1159
|
schemas: {},
|
|
1038
|
-
directoryListings:
|
|
1160
|
+
directoryListings: _(n.entries, "")
|
|
1039
1161
|
};
|
|
1040
1162
|
}
|
|
1041
1163
|
load(e) {
|
|
1042
1164
|
let t = this.data ? {
|
|
1043
1165
|
ready: !0,
|
|
1044
1166
|
...this.data
|
|
1045
|
-
} :
|
|
1167
|
+
} : It;
|
|
1046
1168
|
return `export default ${JSON.stringify(t)}`;
|
|
1047
1169
|
}
|
|
1048
1170
|
clear() {
|
|
1049
1171
|
this.data = void 0;
|
|
1050
1172
|
}
|
|
1051
|
-
fetch =
|
|
1052
|
-
|
|
1173
|
+
fetch = b((e, t) => {
|
|
1174
|
+
Rt(e).then((e) => {
|
|
1053
1175
|
this.data = e, t && this.invalidate(t);
|
|
1054
1176
|
}).catch((e) => {
|
|
1055
1177
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1056
1178
|
});
|
|
1057
1179
|
}, 200);
|
|
1058
1180
|
async fetchSync(e) {
|
|
1059
|
-
this.data = await
|
|
1181
|
+
this.data = await Rt(e);
|
|
1060
1182
|
}
|
|
1061
1183
|
invalidate(e) {
|
|
1062
|
-
|
|
1184
|
+
Q(e, Ft);
|
|
1063
1185
|
}
|
|
1064
1186
|
};
|
|
1065
|
-
async function
|
|
1187
|
+
async function Rt(e) {
|
|
1066
1188
|
let [t, n, r] = await Promise.all([
|
|
1067
1189
|
e.getConfig(),
|
|
1068
1190
|
e.listSidebar(),
|
|
@@ -1070,21 +1192,21 @@ async function Dt(e) {
|
|
|
1070
1192
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1071
1193
|
...e,
|
|
1072
1194
|
header: {}
|
|
1073
|
-
})), s =
|
|
1195
|
+
})), s = v(o);
|
|
1074
1196
|
return {
|
|
1075
1197
|
contentTree: s,
|
|
1076
1198
|
schemas: a,
|
|
1077
|
-
directoryListings:
|
|
1199
|
+
directoryListings: _(s.entries, t.siteTitle)
|
|
1078
1200
|
};
|
|
1079
1201
|
}
|
|
1080
1202
|
//#endregion
|
|
1081
1203
|
//#region src/node/lib/search-indexer/index.ts
|
|
1082
|
-
var
|
|
1204
|
+
var zt = class {
|
|
1083
1205
|
index;
|
|
1084
1206
|
constructor() {
|
|
1085
1207
|
this.index = new se({
|
|
1086
|
-
fields:
|
|
1087
|
-
storeFields:
|
|
1208
|
+
fields: f,
|
|
1209
|
+
storeFields: c
|
|
1088
1210
|
});
|
|
1089
1211
|
}
|
|
1090
1212
|
addAll(e) {
|
|
@@ -1103,20 +1225,20 @@ var Ot = class {
|
|
|
1103
1225
|
};
|
|
1104
1226
|
//#endregion
|
|
1105
1227
|
//#region src/node/lib/search-indexer/scan.ts
|
|
1106
|
-
function
|
|
1107
|
-
let n =
|
|
1228
|
+
function Bt(e, t) {
|
|
1229
|
+
let n = Wt(e), r = [];
|
|
1108
1230
|
for (let t of n) {
|
|
1109
|
-
let n =
|
|
1231
|
+
let n = Ut(e, t);
|
|
1110
1232
|
n && r.push(n);
|
|
1111
1233
|
}
|
|
1112
1234
|
t.addAll(r);
|
|
1113
1235
|
}
|
|
1114
|
-
function
|
|
1115
|
-
let i =
|
|
1236
|
+
function Vt(e, n, r) {
|
|
1237
|
+
let i = Ut(e, j(e, n));
|
|
1116
1238
|
i ? r.addPage(i) : r.discardPage(t(n));
|
|
1117
1239
|
}
|
|
1118
|
-
function
|
|
1119
|
-
let n =
|
|
1240
|
+
function Ht(e, t) {
|
|
1241
|
+
let n = C(e);
|
|
1120
1242
|
if (!t.startsWith("---")) return {
|
|
1121
1243
|
title: n,
|
|
1122
1244
|
body: t
|
|
@@ -1132,56 +1254,56 @@ function jt(e, t) {
|
|
|
1132
1254
|
body: a
|
|
1133
1255
|
};
|
|
1134
1256
|
}
|
|
1135
|
-
function
|
|
1257
|
+
function Ut(e, n) {
|
|
1136
1258
|
let r;
|
|
1137
1259
|
try {
|
|
1138
|
-
r =
|
|
1260
|
+
r = Se(n, "utf-8");
|
|
1139
1261
|
} catch {
|
|
1140
1262
|
return;
|
|
1141
1263
|
}
|
|
1142
1264
|
if (!r.trim()) return;
|
|
1143
|
-
let i = n.slice(e.length + 1), { title: a, body: o } =
|
|
1265
|
+
let i = n.slice(e.length + 1), { title: a, body: o } = Ht(i, r);
|
|
1144
1266
|
return {
|
|
1145
1267
|
id: t(i),
|
|
1146
1268
|
title: a,
|
|
1147
1269
|
text: `${a}\n${o}`
|
|
1148
1270
|
};
|
|
1149
1271
|
}
|
|
1150
|
-
function
|
|
1151
|
-
return
|
|
1272
|
+
function Wt(e) {
|
|
1273
|
+
return xe("**/*.td", {
|
|
1152
1274
|
cwd: e,
|
|
1153
1275
|
exclude: (e) => e.startsWith("_")
|
|
1154
|
-
}).map((t) =>
|
|
1276
|
+
}).map((t) => j(e, t));
|
|
1155
1277
|
}
|
|
1156
1278
|
//#endregion
|
|
1157
1279
|
//#region src/node/plugin/vite/virtual/search-index.ts
|
|
1158
|
-
var
|
|
1159
|
-
indexer = new
|
|
1280
|
+
var Gt = "\0@typedown/search-index", Kt = class {
|
|
1281
|
+
indexer = new zt();
|
|
1160
1282
|
load(e) {
|
|
1161
1283
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1162
1284
|
}
|
|
1163
1285
|
index(e) {
|
|
1164
|
-
|
|
1286
|
+
Bt(e, this.indexer);
|
|
1165
1287
|
}
|
|
1166
1288
|
reindex(e, t) {
|
|
1167
|
-
|
|
1289
|
+
Vt(e, t, this.indexer);
|
|
1168
1290
|
}
|
|
1169
1291
|
invalidate(e) {
|
|
1170
|
-
|
|
1292
|
+
Q(e, Gt);
|
|
1171
1293
|
}
|
|
1172
|
-
},
|
|
1173
|
-
function
|
|
1294
|
+
}, qt = we(import.meta.url);
|
|
1295
|
+
function Jt() {
|
|
1174
1296
|
return [{
|
|
1175
1297
|
find: "vue/server-renderer",
|
|
1176
|
-
replacement:
|
|
1298
|
+
replacement: qt.resolve("vue/server-renderer")
|
|
1177
1299
|
}, {
|
|
1178
1300
|
find: "vue",
|
|
1179
|
-
replacement:
|
|
1301
|
+
replacement: qt.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1180
1302
|
}];
|
|
1181
1303
|
}
|
|
1182
1304
|
//#endregion
|
|
1183
1305
|
//#region src/node/plugin/vite/middleware/vault-assets.ts
|
|
1184
|
-
var
|
|
1306
|
+
var Yt = {
|
|
1185
1307
|
jpg: "image/jpeg",
|
|
1186
1308
|
jpeg: "image/jpeg",
|
|
1187
1309
|
png: "image/png",
|
|
@@ -1199,17 +1321,17 @@ var Rt = {
|
|
|
1199
1321
|
woff: "font/woff",
|
|
1200
1322
|
ttf: "font/ttf"
|
|
1201
1323
|
};
|
|
1202
|
-
function
|
|
1203
|
-
return (i,
|
|
1204
|
-
if (!i.url || i.method !== "GET" ||
|
|
1324
|
+
function Xt(t, r) {
|
|
1325
|
+
return (i, a, s) => {
|
|
1326
|
+
if (!i.url || i.method !== "GET" || a.writableEnded) return s();
|
|
1205
1327
|
let c = e(i.url);
|
|
1206
1328
|
if (c.startsWith("/@") || c.startsWith("/node_modules")) return s();
|
|
1207
|
-
let l = n(r.basePath), u = (l && c.startsWith(l) ? c.slice(l.length) : c).replace(/^\//, ""), d =
|
|
1208
|
-
if (
|
|
1209
|
-
let e =
|
|
1329
|
+
let l = n(r.basePath), u = (l && c.startsWith(l) ? c.slice(l.length) : c).replace(/^\//, ""), d = j(t.config.root, r.rootDirectory, u);
|
|
1330
|
+
if (be(d)) try {
|
|
1331
|
+
let e = Ce(d);
|
|
1210
1332
|
if (e.isFile()) {
|
|
1211
|
-
let t =
|
|
1212
|
-
|
|
1333
|
+
let t = Yt[o(d).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1334
|
+
a.setHeader("Content-Type", t), a.setHeader("Content-Length", e.size), ye(d).pipe(a);
|
|
1213
1335
|
return;
|
|
1214
1336
|
}
|
|
1215
1337
|
} catch {}
|
|
@@ -1218,7 +1340,7 @@ function zt(t, r) {
|
|
|
1218
1340
|
}
|
|
1219
1341
|
//#endregion
|
|
1220
1342
|
//#region src/node/plugin/vite/middleware/virtual-html.ts
|
|
1221
|
-
function
|
|
1343
|
+
function Zt(t, r, i) {
|
|
1222
1344
|
return (a, o, s) => {
|
|
1223
1345
|
if (!a.url) return s();
|
|
1224
1346
|
let c = n(e(a.url)), l = n(i.basePath);
|
|
@@ -1226,28 +1348,28 @@ function Bt(t, r, i) {
|
|
|
1226
1348
|
let u = c.slice(l.length);
|
|
1227
1349
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return s();
|
|
1228
1350
|
r.getConfig().then(async (e) => {
|
|
1229
|
-
let n = await t.transformIndexHtml(a.url ?? "",
|
|
1351
|
+
let n = await t.transformIndexHtml(a.url ?? "", Qt(i, e));
|
|
1230
1352
|
o.setHeader("Content-Type", "text/html"), o.end(n);
|
|
1231
1353
|
}).catch(() => s());
|
|
1232
1354
|
};
|
|
1233
1355
|
}
|
|
1234
|
-
function
|
|
1235
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1356
|
+
function Qt(e, t) {
|
|
1357
|
+
return e.devHtml === void 0 && (e.devHtml = k({
|
|
1236
1358
|
title: t.siteTitle,
|
|
1237
1359
|
description: t.siteDescription,
|
|
1238
1360
|
base: "/",
|
|
1239
|
-
entryScript:
|
|
1361
|
+
entryScript: Et
|
|
1240
1362
|
})), e.devHtml;
|
|
1241
1363
|
}
|
|
1242
1364
|
//#endregion
|
|
1243
1365
|
//#region src/node/plugin/vite/index.ts
|
|
1244
|
-
function $(e = {}) {
|
|
1245
|
-
let t = e.context, n,
|
|
1366
|
+
function $t(e = {}) {
|
|
1367
|
+
let t = e.context, n, r, a, o = new Mt(), s = new Pt(), c = new Nt(), u = new Lt(), d = new Kt(), f = {
|
|
1246
1368
|
devHtml: void 0,
|
|
1247
1369
|
basePath: "/",
|
|
1248
1370
|
rootDirectory: "vault"
|
|
1249
1371
|
};
|
|
1250
|
-
function
|
|
1372
|
+
function p() {
|
|
1251
1373
|
if (t === void 0) throw Error("typedown plugin not initialized");
|
|
1252
1374
|
return t.getTdContext();
|
|
1253
1375
|
}
|
|
@@ -1257,11 +1379,11 @@ function $(e = {}) {
|
|
|
1257
1379
|
enforce: "pre",
|
|
1258
1380
|
async config(n) {
|
|
1259
1381
|
if (!t) {
|
|
1260
|
-
let r = e.root ?
|
|
1382
|
+
let r = e.root ? j(n.root ?? process.cwd(), e.root) : oe(n.root ?? process.cwd());
|
|
1261
1383
|
t = ae(r);
|
|
1262
1384
|
}
|
|
1263
1385
|
a = n.base ?? "/";
|
|
1264
|
-
let r = await (await
|
|
1386
|
+
let r = await (await p()).getConfig();
|
|
1265
1387
|
return {
|
|
1266
1388
|
base: n.base ?? r.basePath,
|
|
1267
1389
|
publicDir: r.publicDir,
|
|
@@ -1269,56 +1391,60 @@ function $(e = {}) {
|
|
|
1269
1391
|
port: n.server?.port ?? 8686,
|
|
1270
1392
|
strictPort: n.server?.strictPort ?? !1
|
|
1271
1393
|
},
|
|
1272
|
-
resolve: { alias:
|
|
1394
|
+
resolve: { alias: Jt() },
|
|
1273
1395
|
ssr: { noExternal: ["typerighter"] }
|
|
1274
1396
|
};
|
|
1275
1397
|
},
|
|
1276
1398
|
configResolved(e) {
|
|
1277
|
-
|
|
1399
|
+
r = j(e.root, e.build.outDir);
|
|
1278
1400
|
},
|
|
1279
1401
|
async buildStart() {
|
|
1280
1402
|
if (n) return;
|
|
1281
|
-
let e = await
|
|
1282
|
-
|
|
1403
|
+
let e = await p(), t = await e.getConfig(), r = j(t.rootDir);
|
|
1404
|
+
d.index(r), await u.fetchSync(e);
|
|
1283
1405
|
let i = await e.checkVault();
|
|
1284
|
-
if (
|
|
1406
|
+
if (rn(i.diagnostics), 0 < i.errorCount) {
|
|
1285
1407
|
let e = i.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1286
1408
|
this.error(`Vault check failed with ${i.errorCount} error(s):\n${e.join("\n")}`);
|
|
1287
1409
|
}
|
|
1288
1410
|
},
|
|
1289
1411
|
resolveId(e) {
|
|
1290
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1291
|
-
if (e === "@typedown/pages") return
|
|
1412
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return Dt;
|
|
1413
|
+
if (e === "@typedown/pages") return Ot;
|
|
1292
1414
|
if (e.startsWith("@typedown/pages?resource=")) return c.resolvePageData(e);
|
|
1293
|
-
if (e === "@typedown/site-data") return
|
|
1294
|
-
if (e === "@typedown/search-index") return
|
|
1415
|
+
if (e === "@typedown/site-data") return kt;
|
|
1416
|
+
if (e === "@typedown/search-index") return At;
|
|
1417
|
+
if (e === "@typedown/theme") return jt;
|
|
1295
1418
|
},
|
|
1296
1419
|
async load(e) {
|
|
1297
|
-
if (c.isPageDataModule(e)) return c.loadPageData(e, await
|
|
1298
|
-
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app") return;
|
|
1299
|
-
let
|
|
1300
|
-
if (e === "\0@typedown/search-index") return
|
|
1301
|
-
if (e === "\0@typedown/site-data") return
|
|
1302
|
-
if (e === "\0@typedown/pages") return c.load(
|
|
1420
|
+
if (c.isPageDataModule(e)) return c.loadPageData(e, await p());
|
|
1421
|
+
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app" && e !== "\0@typedown/theme") return;
|
|
1422
|
+
let n = await p();
|
|
1423
|
+
if (e === "\0@typedown/search-index") return d.load(n);
|
|
1424
|
+
if (e === "\0@typedown/site-data") return u.load(n);
|
|
1425
|
+
if (e === "\0@typedown/pages") return c.load(n);
|
|
1303
1426
|
if (e === "\0@typedown/app") return o.load(t);
|
|
1427
|
+
if (e === "\0@typedown/theme") return s.load(t);
|
|
1304
1428
|
},
|
|
1305
1429
|
async configureServer(e) {
|
|
1306
1430
|
n = e;
|
|
1307
|
-
let t = await
|
|
1308
|
-
|
|
1431
|
+
let t = await p(), r = await t.getConfig(), i = j(r.rootDir);
|
|
1432
|
+
d.index(i), u.scan(i), u.fetch(t, n), e.httpServer?.once("listening", async () => {
|
|
1309
1433
|
let e = await t.checkVault();
|
|
1310
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1434
|
+
0 < e.diagnostics.length && (console.error(""), rn(e.diagnostics));
|
|
1311
1435
|
}), t.rpc.onConfigChanged(() => {
|
|
1312
|
-
n && (
|
|
1436
|
+
n && (f.devHtml = void 0, u.clear(), o.invalidate(n), s.invalidate(n), c.invalidate(n), $(n), u.fetch(t, n));
|
|
1437
|
+
}), t.rpc.onComponentContractChanged(() => {
|
|
1438
|
+
n && (o.invalidate(n), $(n));
|
|
1313
1439
|
});
|
|
1314
1440
|
function a(...e) {
|
|
1315
1441
|
n && t.getConfig().then((t) => {
|
|
1316
1442
|
if (!n) return;
|
|
1317
1443
|
let r = [];
|
|
1318
1444
|
for (let i of e) {
|
|
1319
|
-
let e =
|
|
1445
|
+
let e = de(j(n.config.root, t.rootDir, i)), a = n.moduleGraph.getModulesByFile(e);
|
|
1320
1446
|
if (a?.size) {
|
|
1321
|
-
for (let e of a) n.moduleGraph.invalidateModule(e), r.push(
|
|
1447
|
+
for (let e of a) n.moduleGraph.invalidateModule(e), r.push(nn(e));
|
|
1322
1448
|
c.invalidatePageData(n, i);
|
|
1323
1449
|
}
|
|
1324
1450
|
}
|
|
@@ -1329,29 +1455,29 @@ function $(e = {}) {
|
|
|
1329
1455
|
}).catch(() => {});
|
|
1330
1456
|
}
|
|
1331
1457
|
t.rpc.onContentUpdated(({ filepath: e, affectedFiles: r = [] }) => {
|
|
1332
|
-
n && (
|
|
1458
|
+
n && (d.reindex(i, e), d.invalidate(n), c.invalidate(n), u.fetch(t, n), a(e, ...r), c.sendPageData(n, t, e));
|
|
1333
1459
|
}), t.rpc.onContentDeleted(({ filepath: e }) => {
|
|
1334
|
-
n && (
|
|
1460
|
+
n && (d.reindex(i, e), d.invalidate(n), c.invalidate(n), u.fetch(t, n), a(e));
|
|
1335
1461
|
});
|
|
1336
|
-
function
|
|
1337
|
-
n && (
|
|
1462
|
+
function l() {
|
|
1463
|
+
n && (u.clear(), tn(n), u.fetch(t, n));
|
|
1338
1464
|
}
|
|
1339
|
-
t.rpc.onSchemaUpdated(
|
|
1340
|
-
let
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}), e.middlewares.use(
|
|
1465
|
+
t.rpc.onSchemaUpdated(l), t.rpc.onSchemaDeleted(l);
|
|
1466
|
+
let m = await t.getConfig();
|
|
1467
|
+
f.basePath = m.basePath, f.rootDirectory = m.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1468
|
+
f.basePath = e.basePath, f.rootDirectory = e.rootDir, f.devHtml = void 0;
|
|
1469
|
+
}), e.middlewares.use(Xt(e, f)), e.middlewares.use(Zt(e, t, f));
|
|
1344
1470
|
},
|
|
1345
1471
|
async transform(e, t) {
|
|
1346
1472
|
let n = t.split("?")[0];
|
|
1347
|
-
if (!
|
|
1348
|
-
if (
|
|
1349
|
-
code:
|
|
1473
|
+
if (!l(n)) return;
|
|
1474
|
+
if (w(n)) return {
|
|
1475
|
+
code: `<script>import theme from '${X}'; import { TdNotFound } from 'typerighter/client/theme-default'; export default theme.NotFound || TdNotFound; export const pageData = { frontmatter: {}, headings: [], title: '' };<\/script>`,
|
|
1350
1476
|
map: null
|
|
1351
1477
|
};
|
|
1352
|
-
let
|
|
1478
|
+
let r = await p(), a = await r.getConfig(), o = i(n, a.rootDir);
|
|
1353
1479
|
try {
|
|
1354
|
-
let { vueSrc: e } = await
|
|
1480
|
+
let { vueSrc: e } = await Ct(r, await r.getFile(o), o);
|
|
1355
1481
|
return {
|
|
1356
1482
|
code: e,
|
|
1357
1483
|
map: null
|
|
@@ -1363,13 +1489,13 @@ function $(e = {}) {
|
|
|
1363
1489
|
}
|
|
1364
1490
|
},
|
|
1365
1491
|
handleHotUpdate({ file: e }) {
|
|
1366
|
-
if (
|
|
1492
|
+
if (l(e)) return [];
|
|
1367
1493
|
},
|
|
1368
1494
|
async closeBundle() {
|
|
1369
1495
|
if (!e.context && t) try {
|
|
1370
1496
|
let e = (await (await t.getTdContext()).getConfig()).basePath, n = e.startsWith(a) ? e.slice(a.length) : e.replace(/^\//, "");
|
|
1371
|
-
await
|
|
1372
|
-
outDir:
|
|
1497
|
+
await Le(t, {
|
|
1498
|
+
outDir: j(r, n),
|
|
1373
1499
|
base: e
|
|
1374
1500
|
});
|
|
1375
1501
|
} finally {
|
|
@@ -1384,21 +1510,21 @@ function $(e = {}) {
|
|
|
1384
1510
|
...ce()
|
|
1385
1511
|
];
|
|
1386
1512
|
}
|
|
1387
|
-
function
|
|
1513
|
+
function en(e) {
|
|
1388
1514
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1389
1515
|
}
|
|
1390
|
-
function
|
|
1391
|
-
for (let t of
|
|
1516
|
+
function $(e) {
|
|
1517
|
+
for (let t of en(e)) e.moduleGraph.invalidateModule(t);
|
|
1392
1518
|
e.hot.send({ type: "full-reload" });
|
|
1393
1519
|
}
|
|
1394
|
-
function
|
|
1395
|
-
let t =
|
|
1520
|
+
function tn(e) {
|
|
1521
|
+
let t = en(e).map((t) => (e.moduleGraph.invalidateModule(t), nn(t)));
|
|
1396
1522
|
0 < t.length && e.hot.send({
|
|
1397
1523
|
type: "update",
|
|
1398
1524
|
updates: t
|
|
1399
1525
|
});
|
|
1400
1526
|
}
|
|
1401
|
-
function
|
|
1527
|
+
function nn(e) {
|
|
1402
1528
|
return {
|
|
1403
1529
|
type: "js-update",
|
|
1404
1530
|
path: e.url,
|
|
@@ -1406,11 +1532,11 @@ function Gt(e) {
|
|
|
1406
1532
|
timestamp: Date.now()
|
|
1407
1533
|
};
|
|
1408
1534
|
}
|
|
1409
|
-
function
|
|
1535
|
+
function rn(e) {
|
|
1410
1536
|
for (let t of e) {
|
|
1411
|
-
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ?
|
|
1412
|
-
console.error(` ${n} ${e} ${t.message} ${
|
|
1537
|
+
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? M.red("error") : M.yellow("warn");
|
|
1538
|
+
console.error(` ${n} ${e} ${t.message} ${M.dim(`(${t.code})`)}`);
|
|
1413
1539
|
}
|
|
1414
1540
|
}
|
|
1415
1541
|
//#endregion
|
|
1416
|
-
export {
|
|
1542
|
+
export { J as a, Y as i, K as n, X as o, Z as r, Le as s, $t as t };
|