typerighter 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/typerighter.js +1 -1
- package/dist/cli-CoyGXgR1.js +579 -0
- package/dist/cli.js +1 -1
- package/dist/{vite-BbjHwKzf.js → constants-B7b8AsH0.js} +126 -313
- package/dist/index.js +4 -4
- package/dist/init-CUo89E7j.js +2358 -0
- package/dist/node/build/index.d.ts +2 -3
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/build/{render.d.ts → prerender.d.ts} +6 -3
- package/dist/node/build/prerender.d.ts.map +1 -0
- package/dist/node/cli/index.d.ts +1 -1
- package/dist/node/cli/index.d.ts.map +1 -1
- package/dist/node/cli/init.d.ts +1 -1
- package/dist/node/cli/init.d.ts.map +1 -1
- package/dist/node/context.d.ts +14 -0
- package/dist/node/context.d.ts.map +1 -0
- package/dist/node/lib/logger.d.ts +10 -2
- package/dist/node/lib/logger.d.ts.map +1 -1
- package/dist/node/lib/progress.d.ts +10 -0
- package/dist/node/lib/progress.d.ts.map +1 -0
- package/dist/node/lib/typedown-context.d.ts +1 -3
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts +5 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/plugin-D2xuSVM4.js +1 -0
- package/dist/rolldown-runtime-Dqa2HsxW.js +20 -0
- package/dist/shared/utils/format.d.ts +2 -0
- package/dist/shared/utils/format.d.ts.map +1 -0
- package/dist/shared/utils/html.d.ts +2 -0
- package/dist/shared/utils/html.d.ts.map +1 -0
- package/dist/shared/utils/html.test.d.ts.map +1 -0
- package/dist/shared/utils/index.d.ts +2 -0
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/vite-BxXQPieu.js +228 -0
- package/dist/vite.js +2 -2
- package/package.json +6 -3
- package/dist/cli-Dq8LM0iJ.js +0 -160
- package/dist/constants-BN1OmC7K.js +0 -46
- package/dist/init-0BIO3hYI.js +0 -647
- package/dist/node/build/html.d.ts +0 -21
- package/dist/node/build/html.d.ts.map +0 -1
- package/dist/node/build/html.test.d.ts.map +0 -1
- package/dist/node/build/render.d.ts.map +0 -1
- package/dist/plugin-6igA2bKK.js +0 -1
- /package/dist/{node/build → shared/utils}/html.test.d.ts +0 -0
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
|
|
1
|
+
import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
3
2
|
import { n as isLinkToPage, r as EXTERNAL_URL_RE, t as isExternal } from "./shared-DzTfF-_d.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
7
|
-
import vue from "@vitejs/plugin-vue";
|
|
3
|
+
import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
|
|
4
|
+
import fs from "node:fs";
|
|
8
5
|
import path from "node:path";
|
|
6
|
+
import { createLogger } from "vite";
|
|
9
7
|
import { RpcServer } from "@typerighter/rpc-server";
|
|
10
8
|
import { RpcClient } from "@typerighter/rpc-client";
|
|
11
9
|
import MarkdownIt from "markdown-it";
|
|
12
10
|
import { createHighlighter, guessEmbeddedLanguages, isSpecialLang } from "shiki";
|
|
13
|
-
import
|
|
11
|
+
import pc from "picocolors";
|
|
14
12
|
import { URL as URL$1 } from "node:url";
|
|
15
|
-
|
|
13
|
+
//#region src/shared/utils/highlight.ts
|
|
14
|
+
var shellLangs = [
|
|
15
|
+
"shellscript",
|
|
16
|
+
"shell",
|
|
17
|
+
"bash",
|
|
18
|
+
"sh",
|
|
19
|
+
"zsh"
|
|
20
|
+
];
|
|
21
|
+
function isShell(s) {
|
|
22
|
+
return shellLangs.includes(s);
|
|
23
|
+
}
|
|
24
|
+
var LANGUAGE_RE = /^[a-zA-Z0-9-_]+/;
|
|
25
|
+
function extractLanguage(s) {
|
|
26
|
+
return LANGUAGE_RE.exec(s)?.[0] || "";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/shared/utils/html.ts
|
|
30
|
+
function escapeHtml$2(s) {
|
|
31
|
+
return s.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
16
34
|
//#region __vite-browser-external
|
|
17
35
|
var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((s, u) => {
|
|
18
36
|
u.exports = {};
|
|
@@ -8188,82 +8206,39 @@ function transformerNotationHighlight(s = {}) {
|
|
|
8188
8206
|
}, "@shikijs/transformers:notation-highlight");
|
|
8189
8207
|
}
|
|
8190
8208
|
//#endregion
|
|
8191
|
-
//#region
|
|
8192
|
-
var
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
bold: d,
|
|
8198
|
-
dim: d,
|
|
8199
|
-
italic: d,
|
|
8200
|
-
underline: d,
|
|
8201
|
-
inverse: d,
|
|
8202
|
-
hidden: d,
|
|
8203
|
-
strikethrough: d,
|
|
8204
|
-
black: d,
|
|
8205
|
-
red: d,
|
|
8206
|
-
green: d,
|
|
8207
|
-
yellow: d,
|
|
8208
|
-
blue: d,
|
|
8209
|
-
magenta: d,
|
|
8210
|
-
cyan: d,
|
|
8211
|
-
white: d,
|
|
8212
|
-
gray: d,
|
|
8213
|
-
bgBlack: d,
|
|
8214
|
-
bgRed: d,
|
|
8215
|
-
bgGreen: d,
|
|
8216
|
-
bgYellow: d,
|
|
8217
|
-
bgBlue: d,
|
|
8218
|
-
bgMagenta: d,
|
|
8219
|
-
bgCyan: d,
|
|
8220
|
-
bgWhite: d,
|
|
8221
|
-
blackBright: d,
|
|
8222
|
-
redBright: d,
|
|
8223
|
-
greenBright: d,
|
|
8224
|
-
yellowBright: d,
|
|
8225
|
-
blueBright: d,
|
|
8226
|
-
magentaBright: d,
|
|
8227
|
-
cyanBright: d,
|
|
8228
|
-
whiteBright: d,
|
|
8229
|
-
bgBlackBright: d,
|
|
8230
|
-
bgRedBright: d,
|
|
8231
|
-
bgGreenBright: d,
|
|
8232
|
-
bgYellowBright: d,
|
|
8233
|
-
bgBlueBright: d,
|
|
8234
|
-
bgMagentaBright: d,
|
|
8235
|
-
bgCyanBright: d,
|
|
8236
|
-
bgWhiteBright: d
|
|
8237
|
-
};
|
|
8238
|
-
};
|
|
8239
|
-
u.exports = f(), u.exports.createColors = f;
|
|
8240
|
-
})), import_picocolors_browser = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1), logger = {
|
|
8209
|
+
//#region src/node/lib/logger.ts
|
|
8210
|
+
var ANSI_RE = /\u001B\[[0-9;]*m/g, TdLogger = class {
|
|
8211
|
+
logStream;
|
|
8212
|
+
constructor(s) {
|
|
8213
|
+
s !== void 0 && (this.logStream = fs.createWriteStream(s, { flags: "a" }), process.once("exit", () => this.close()));
|
|
8214
|
+
}
|
|
8241
8215
|
info(s) {
|
|
8242
|
-
console.log(
|
|
8243
|
-
}
|
|
8216
|
+
console.log(pc.cyan(`ℹ ${s}`)), this.writeToFile("INFO", s);
|
|
8217
|
+
}
|
|
8244
8218
|
warn(s) {
|
|
8245
|
-
console.warn(
|
|
8246
|
-
}
|
|
8219
|
+
console.warn(pc.yellow(`⚠ ${s}`)), this.writeToFile("WARN", s);
|
|
8220
|
+
}
|
|
8247
8221
|
error(s) {
|
|
8248
|
-
console.error(
|
|
8222
|
+
console.error(pc.red(`✖ ${s}`)), this.writeToFile("ERROR", s);
|
|
8249
8223
|
}
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
}
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8224
|
+
success(s) {
|
|
8225
|
+
console.log(pc.green(`✔ ${s}`)), this.writeToFile("SUCCESS", s);
|
|
8226
|
+
}
|
|
8227
|
+
start(s) {
|
|
8228
|
+
console.log(pc.cyan(`◐ ${s}`)), this.writeToFile("START", s);
|
|
8229
|
+
}
|
|
8230
|
+
log(s) {
|
|
8231
|
+
console.log(s), this.writeToFile("LOG", s);
|
|
8232
|
+
}
|
|
8233
|
+
writeToFile(s, u) {
|
|
8234
|
+
if (!this.logStream) return;
|
|
8235
|
+
let d = (/* @__PURE__ */ new Date()).toISOString(), f = u.replace(ANSI_RE, "");
|
|
8236
|
+
this.logStream.write(`${d} [${s}] ${f}\n`);
|
|
8237
|
+
}
|
|
8238
|
+
close() {
|
|
8239
|
+
this.logStream?.end(), this.logStream = void 0;
|
|
8240
|
+
}
|
|
8241
|
+
}, consoleLogger = new TdLogger(), highlighterRegistry = new FinalizationRegistry((s) => {
|
|
8267
8242
|
s();
|
|
8268
8243
|
}), THEME = {
|
|
8269
8244
|
light: "github-light",
|
|
@@ -8300,7 +8275,7 @@ async function createHighlighter$1() {
|
|
|
8300
8275
|
try {
|
|
8301
8276
|
!isSpecialLang(p) && !d.has(p) && (await s.loadLanguage(p), d.add(p));
|
|
8302
8277
|
} catch {
|
|
8303
|
-
|
|
8278
|
+
consoleLogger.warn(`\nThe language '${p}' is not loaded, falling back to 'txt' for syntax highlighting.`), p = "txt";
|
|
8304
8279
|
}
|
|
8305
8280
|
f = f.trimEnd();
|
|
8306
8281
|
let g = guessEmbeddedLanguages(f, p, s);
|
|
@@ -9420,7 +9395,7 @@ var TypedownContext = class {
|
|
|
9420
9395
|
createMarkdownRenderer(s).then((s) => {
|
|
9421
9396
|
this.configVersion === u && (this._md = s);
|
|
9422
9397
|
}).catch((s) => {
|
|
9423
|
-
|
|
9398
|
+
console.error(`Failed to recreate markdown renderer: ${s}`);
|
|
9424
9399
|
});
|
|
9425
9400
|
}), s.onContentChanged(({ content: s }) => {
|
|
9426
9401
|
this.cachedFileMap.delete(s), this.cachedFilesGroupedBySchema = void 0;
|
|
@@ -9474,244 +9449,82 @@ var TypedownContext = class {
|
|
|
9474
9449
|
get md() {
|
|
9475
9450
|
return this._md;
|
|
9476
9451
|
}
|
|
9477
|
-
};
|
|
9478
|
-
|
|
9479
|
-
let
|
|
9480
|
-
|
|
9481
|
-
s
|
|
9482
|
-
|
|
9452
|
+
}, CONFIG_FILE_NAMES = ["typedown.yaml", "typedown.yml"];
|
|
9453
|
+
function createAppContext(s) {
|
|
9454
|
+
let u = new TdLogger(initializeLogFile(s));
|
|
9455
|
+
function d() {
|
|
9456
|
+
let s = createLogger("warn");
|
|
9457
|
+
return {
|
|
9458
|
+
...s,
|
|
9459
|
+
info(s) {
|
|
9460
|
+
u.writeToFile("VITE", s);
|
|
9461
|
+
},
|
|
9462
|
+
warn(d) {
|
|
9463
|
+
s.warn(d), u.writeToFile("VITE:WARN", d);
|
|
9464
|
+
},
|
|
9465
|
+
error(d) {
|
|
9466
|
+
s.error(d), u.writeToFile("VITE:ERROR", d);
|
|
9467
|
+
}
|
|
9468
|
+
};
|
|
9469
|
+
}
|
|
9470
|
+
let f, p, m, h = !1;
|
|
9471
|
+
function g() {
|
|
9472
|
+
y(), process.exit(0);
|
|
9473
|
+
}
|
|
9474
|
+
function _() {
|
|
9475
|
+
y();
|
|
9476
|
+
}
|
|
9477
|
+
async function v() {
|
|
9478
|
+
if (f) return f;
|
|
9479
|
+
process.on("SIGINT", g), process.on("SIGTERM", g), p = new RpcServer(), await new Promise((s, u) => {
|
|
9480
|
+
p?.once("error", u), p?.listen(() => {
|
|
9481
|
+
p?.removeListener("error", u), s();
|
|
9482
|
+
});
|
|
9483
9483
|
});
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
function
|
|
9491
|
-
|
|
9484
|
+
let s = p.address, u = p.port;
|
|
9485
|
+
if (s === void 0 || u === void 0) throw Error("RPC server started but address/port not available");
|
|
9486
|
+
m = await RpcClient.connect(new URL(s).hostname, u);
|
|
9487
|
+
let d = await createMarkdownRenderer(await m.getConfig());
|
|
9488
|
+
return f = new TypedownContext(m, d), p.unref(), process.on("exit", _), f;
|
|
9489
|
+
}
|
|
9490
|
+
function y() {
|
|
9491
|
+
h || (h = !0, process.removeListener("exit", _), process.removeListener("SIGINT", g), process.removeListener("SIGTERM", g), m?.close(), p?.close(), f = void 0, p = void 0, m = void 0);
|
|
9492
9492
|
}
|
|
9493
|
-
return process.on("exit", h), process.on("SIGINT", () => {
|
|
9494
|
-
h(), process.exit(0);
|
|
9495
|
-
}), process.on("SIGTERM", () => {
|
|
9496
|
-
h(), process.exit(0);
|
|
9497
|
-
}), p;
|
|
9498
|
-
}
|
|
9499
|
-
var _tdContext;
|
|
9500
|
-
async function getTdContext() {
|
|
9501
|
-
return _tdContext ||= await initializeTypedownContext(), _tdContext;
|
|
9502
|
-
}
|
|
9503
|
-
//#endregion
|
|
9504
|
-
//#region src/node/lib/render/vue.ts
|
|
9505
|
-
async function renderToVueSfc(s, u, d) {
|
|
9506
|
-
let f = {
|
|
9507
|
-
path: d,
|
|
9508
|
-
relativePath: d,
|
|
9509
|
-
cleanUrls: !0
|
|
9510
|
-
}, p = await s.renderAsync(u.content, f), m = f.title || getResourceTitle(u.header, d), h = {
|
|
9511
|
-
schema: u.schema,
|
|
9512
|
-
frontmatter: u.header,
|
|
9513
|
-
headings: f.headers ?? [],
|
|
9514
|
-
title: m
|
|
9515
|
-
}, g = JSON.stringify(JSON.stringify(h)), _ = JSON.stringify(p);
|
|
9516
9493
|
return {
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
"<template><div v-html=\"__html\" /></template>"
|
|
9523
|
-
].join("\n"),
|
|
9524
|
-
pageData: h
|
|
9494
|
+
root: s,
|
|
9495
|
+
logger: u,
|
|
9496
|
+
getTdContext: v,
|
|
9497
|
+
createViteLogger: d,
|
|
9498
|
+
dispose: y
|
|
9525
9499
|
};
|
|
9526
9500
|
}
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
const pages = import.meta.glob('${`/${u}/**/*.td`}');
|
|
9537
|
-
${d ? "" : `pages['/${u}/${VIRTUAL_INDEX_ID}'] = () => import('${VIRTUAL_INDEX_ID}');`}
|
|
9538
|
-
|
|
9539
|
-
async function loadPageModule(pagePath) {
|
|
9540
|
-
const key = '/${u}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
9541
|
-
const altKey = '/${u}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
9542
|
-
const loader = pages[key] || pages[altKey]${d ? "" : ` || (pagePath === '/' ? pages['/${u}/${VIRTUAL_INDEX_ID}'] : undefined)`};
|
|
9543
|
-
if (!loader) return undefined;
|
|
9544
|
-
return loader();
|
|
9545
|
-
}
|
|
9546
|
-
|
|
9547
|
-
const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
|
|
9548
|
-
title: s.siteTitle,
|
|
9549
|
-
description: s.siteDescription
|
|
9550
|
-
})}, ${JSON.stringify({ sidebarGroups: s.sidebarGroups })});
|
|
9551
|
-
app.mount('#app');
|
|
9552
|
-
`;
|
|
9553
|
-
}
|
|
9554
|
-
function generateIndexSfc(s) {
|
|
9555
|
-
let u = JSON.stringify(s).replace(/'/g, "\\'"), d = JSON.stringify({
|
|
9556
|
-
schema: "",
|
|
9557
|
-
frontmatter: {},
|
|
9558
|
-
headings: [],
|
|
9559
|
-
title: "Index"
|
|
9560
|
-
});
|
|
9561
|
-
return `<script>
|
|
9562
|
-
import { TdOverview } from 'typerighter/client/theme-default';
|
|
9563
|
-
export const __pageData = JSON.parse(${JSON.stringify(d)})
|
|
9564
|
-
export default { name: "index", components: { TdOverview } }
|
|
9565
|
-
<\/script>
|
|
9566
|
-
<template><TdOverview :groups='${u}' /></template>`;
|
|
9567
|
-
}
|
|
9568
|
-
function generateSsrEntry(s) {
|
|
9569
|
-
let u = `/${s.contentDir}/**/*.td`;
|
|
9570
|
-
return `
|
|
9571
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
9572
|
-
import { renderToString } from 'vue/server-renderer';
|
|
9573
|
-
import theme from '${s.layoutImport}';
|
|
9574
|
-
|
|
9575
|
-
const pages = import.meta.glob('${u}', { eager: true });
|
|
9576
|
-
|
|
9577
|
-
function loadPageModule(pagePath) {
|
|
9578
|
-
const key = '/${s.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
9579
|
-
const altKey = '/${s.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
9580
|
-
return Promise.resolve(pages[key] || pages[altKey]);
|
|
9581
|
-
}
|
|
9582
|
-
|
|
9583
|
-
export async function render(url) {
|
|
9584
|
-
const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${s.siteConfig}, ${s.siteData});
|
|
9585
|
-
await router.go(url, { replace: true });
|
|
9586
|
-
const html = await renderToString(app);
|
|
9587
|
-
return { html, pageData: router.route.data };
|
|
9501
|
+
function resolveProjectRoot(s) {
|
|
9502
|
+
let u = path.resolve(s);
|
|
9503
|
+
for (;;) {
|
|
9504
|
+
if (hasConfigFile(u)) return u;
|
|
9505
|
+
let s = path.dirname(u);
|
|
9506
|
+
if (s === u) break;
|
|
9507
|
+
u = s;
|
|
9508
|
+
}
|
|
9509
|
+
return path.resolve(s);
|
|
9588
9510
|
}
|
|
9589
|
-
|
|
9511
|
+
function hasConfigFile(s) {
|
|
9512
|
+
return CONFIG_FILE_NAMES.some((u) => fs.existsSync(path.join(s, u)));
|
|
9590
9513
|
}
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
}
|
|
9514
|
+
function initializeLogFile(s) {
|
|
9515
|
+
try {
|
|
9516
|
+
let u = path.join(s, ".typedown", ".local"), d = path.join(u, "logs");
|
|
9517
|
+
fs.mkdirSync(d, { recursive: !0 });
|
|
9518
|
+
let f = path.join(u, ".gitignore");
|
|
9519
|
+
fs.existsSync(f) || fs.writeFileSync(f, "*\n");
|
|
9520
|
+
let p = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
9521
|
+
return path.join(d, `${p}.log`);
|
|
9522
|
+
} catch {
|
|
9523
|
+
return;
|
|
9524
|
+
}
|
|
9602
9525
|
}
|
|
9603
9526
|
//#endregion
|
|
9604
|
-
//#region src/node/plugin/vite/
|
|
9605
|
-
|
|
9606
|
-
let s;
|
|
9607
|
-
return [
|
|
9608
|
-
{
|
|
9609
|
-
name: "vite-plugin-typedown",
|
|
9610
|
-
enforce: "pre",
|
|
9611
|
-
config() {
|
|
9612
|
-
return {
|
|
9613
|
-
resolve: { alias: resolveAliases() },
|
|
9614
|
-
ssr: { noExternal: ["typerighter"] }
|
|
9615
|
-
};
|
|
9616
|
-
},
|
|
9617
|
-
resolveId(s) {
|
|
9618
|
-
if (s === "/@typedown/app" || s === "@typedown/app") return RESOLVED_VIRTUAL_APP_ID;
|
|
9619
|
-
if (s.endsWith("__typedown_index__.td")) return s;
|
|
9620
|
-
},
|
|
9621
|
-
async load(s) {
|
|
9622
|
-
let u = await getTdContext();
|
|
9623
|
-
if (s === "\0@typedown/app") {
|
|
9624
|
-
let [s, d, f] = await Promise.all([
|
|
9625
|
-
u.getConfig(),
|
|
9626
|
-
u.listFiles(),
|
|
9627
|
-
u.listFilesGroupedBySchema()
|
|
9628
|
-
]), p = d.some((s) => s === "index.td");
|
|
9629
|
-
return generateAppEntry({
|
|
9630
|
-
...s,
|
|
9631
|
-
hasIndex: p,
|
|
9632
|
-
sidebarGroups: f
|
|
9633
|
-
});
|
|
9634
|
-
}
|
|
9635
|
-
if (s.endsWith("__typedown_index__.td")) return generateIndexSfc(await u.listFilesGroupedBySchema());
|
|
9636
|
-
},
|
|
9637
|
-
async configureServer(u) {
|
|
9638
|
-
s = u;
|
|
9639
|
-
let d = await getTdContext();
|
|
9640
|
-
return d.rpc.onConfigChanged(() => s && hmrFullReload(s)), d.rpc.onContentChanged(({ content: u }) => {
|
|
9641
|
-
if (s) {
|
|
9642
|
-
for (let d of s.moduleGraph.idToModuleMap.values()) if (d.file?.endsWith(u)) {
|
|
9643
|
-
s.moduleGraph.invalidateModule(d), s.hot.send({
|
|
9644
|
-
type: "update",
|
|
9645
|
-
updates: [{
|
|
9646
|
-
type: "js-update",
|
|
9647
|
-
path: d.url,
|
|
9648
|
-
acceptedPath: d.url,
|
|
9649
|
-
timestamp: Date.now()
|
|
9650
|
-
}]
|
|
9651
|
-
});
|
|
9652
|
-
break;
|
|
9653
|
-
}
|
|
9654
|
-
}
|
|
9655
|
-
}), d.rpc.onContentCreated(() => s && hmrInvalidateAll(s)), d.rpc.onContentDeleted(() => s && hmrInvalidateAll(s)), d.rpc.onSchemaChanged(() => s && hmrInvalidateAll(s)), d.rpc.onSchemaCreated(() => s && hmrInvalidateAll(s)), d.rpc.onSchemaDeleted(() => s && hmrInvalidateAll(s)), () => {
|
|
9656
|
-
u.middlewares.use((s, u, f) => {
|
|
9657
|
-
if (!s.url || u.writableEnded || s.url.startsWith("/@") || s.url.startsWith("/node_modules") || s.url.includes(".")) return f();
|
|
9658
|
-
d.getConfig().then((s) => {
|
|
9659
|
-
let d = `<!DOCTYPE html>
|
|
9660
|
-
<html lang="en">
|
|
9661
|
-
<head>
|
|
9662
|
-
<meta charset="UTF-8">
|
|
9663
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9664
|
-
<title>${escapeHtml$2(s.siteTitle)}</title>
|
|
9665
|
-
<link rel="icon" type="image/svg+xml" href="${BRAND_FAVICON_URI}">
|
|
9666
|
-
</head>
|
|
9667
|
-
<body>
|
|
9668
|
-
<div id="app"></div>
|
|
9669
|
-
<script type="module" src="/${VIRTUAL_APP_ID}"><\/script>
|
|
9670
|
-
</body>
|
|
9671
|
-
</html>`;
|
|
9672
|
-
u.setHeader("Content-Type", "text/html"), u.end(d);
|
|
9673
|
-
}).catch(f);
|
|
9674
|
-
});
|
|
9675
|
-
};
|
|
9676
|
-
},
|
|
9677
|
-
async transform(s, u) {
|
|
9678
|
-
let d = u.split("?")[0];
|
|
9679
|
-
if (!d.endsWith(".td") || d.includes("__typedown_index__.td")) return;
|
|
9680
|
-
let f = await getTdContext(), p = (await f.getConfig()).contentDir, m = d.includes(p) ? d.slice(d.indexOf(p) + p.length + 1) : d, h = await f.getFile(m), { vueSrc: g } = await renderToVueSfc(f.md, h, m);
|
|
9681
|
-
return {
|
|
9682
|
-
code: g,
|
|
9683
|
-
map: null
|
|
9684
|
-
};
|
|
9685
|
-
},
|
|
9686
|
-
handleHotUpdate({ file: s }) {
|
|
9687
|
-
if (s.endsWith(".td")) return [];
|
|
9688
|
-
}
|
|
9689
|
-
},
|
|
9690
|
-
vue({ include: /\.(?:vue|td)$/ }),
|
|
9691
|
-
...tailwindcss()
|
|
9692
|
-
];
|
|
9693
|
-
}
|
|
9694
|
-
function getTdModules(s) {
|
|
9695
|
-
return [...s.moduleGraph.idToModuleMap.entries()].filter(([s]) => s.endsWith(".td")).map(([, s]) => s);
|
|
9696
|
-
}
|
|
9697
|
-
function hmrFullReload(s) {
|
|
9698
|
-
for (let u of getTdModules(s)) s.moduleGraph.invalidateModule(u);
|
|
9699
|
-
s.hot.send({ type: "full-reload" });
|
|
9700
|
-
}
|
|
9701
|
-
function hmrInvalidateAll(s) {
|
|
9702
|
-
let u = getTdModules(s).map((u) => (s.moduleGraph.invalidateModule(u), makeHmrUpdate(u)));
|
|
9703
|
-
0 < u.length && s.hot.send({
|
|
9704
|
-
type: "update",
|
|
9705
|
-
updates: u
|
|
9706
|
-
});
|
|
9707
|
-
}
|
|
9708
|
-
function makeHmrUpdate(s) {
|
|
9709
|
-
return {
|
|
9710
|
-
type: "js-update",
|
|
9711
|
-
path: s.url,
|
|
9712
|
-
acceptedPath: s.url,
|
|
9713
|
-
timestamp: Date.now()
|
|
9714
|
-
};
|
|
9715
|
-
}
|
|
9527
|
+
//#region src/node/plugin/vite/constants.ts
|
|
9528
|
+
var VIRTUAL_APP_ID = "@typedown/app", RESOLVED_VIRTUAL_APP_ID = "\0@typedown/app", VIRTUAL_INDEX_ID = "__typedown_index__.td";
|
|
9716
9529
|
//#endregion
|
|
9717
|
-
export {
|
|
9530
|
+
export { createAppContext as a, CONFIG_FILE_NAMES as i, VIRTUAL_APP_ID as n, resolveProjectRoot as o, VIRTUAL_INDEX_ID as r, escapeHtml$2 as s, RESOLVED_VIRTUAL_APP_ID as t };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
1
|
+
import { n as e, t } from "./cli-CoyGXgR1.js";
|
|
2
|
+
import { t as n } from "./vite-BxXQPieu.js";
|
|
3
|
+
import "./plugin-D2xuSVM4.js";
|
|
4
|
+
export { e as buildSite, t as cli, n as typedown };
|