typerighter 0.2.2 → 0.3.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/bin/typerighter.js +1 -1
- package/dist/cli-VgaueuJP.js +585 -0
- package/dist/cli.js +1 -1
- package/dist/{vite-BNDqb1zM.js → constants-B7b8AsH0.js} +126 -315
- package/dist/index.js +4 -4
- package/dist/init-Ci83UWu-.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 -3
- 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/codegen.d.ts +2 -0
- package/dist/node/plugin/vite/codegen.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-DRzll98J.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-D9ePlTzy.js +229 -0
- package/dist/vite.js +2 -2
- package/package.json +6 -3
- package/dist/cli-CfMrevh1.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-B-At85hl.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,85 +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
|
-
}
|
|
8244
|
-
phase(s) {
|
|
8245
|
-
console.log(import_picocolors_browser.default.bold(import_picocolors_browser.default.cyan(s)));
|
|
8246
|
-
},
|
|
8216
|
+
console.log(pc.cyan(`ℹ ${s}`)), this.writeToFile("INFO", s);
|
|
8217
|
+
}
|
|
8247
8218
|
warn(s) {
|
|
8248
|
-
console.warn(
|
|
8249
|
-
}
|
|
8219
|
+
console.warn(pc.yellow(`⚠ ${s}`)), this.writeToFile("WARN", s);
|
|
8220
|
+
}
|
|
8250
8221
|
error(s) {
|
|
8251
|
-
console.error(
|
|
8222
|
+
console.error(pc.red(`✖ ${s}`)), this.writeToFile("ERROR", s);
|
|
8252
8223
|
}
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
}
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
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) => {
|
|
8270
8242
|
s();
|
|
8271
8243
|
}), THEME = {
|
|
8272
8244
|
light: "github-light",
|
|
@@ -8303,7 +8275,7 @@ async function createHighlighter$1() {
|
|
|
8303
8275
|
try {
|
|
8304
8276
|
!isSpecialLang(p) && !d.has(p) && (await s.loadLanguage(p), d.add(p));
|
|
8305
8277
|
} catch {
|
|
8306
|
-
|
|
8278
|
+
consoleLogger.warn(`\nThe language '${p}' is not loaded, falling back to 'txt' for syntax highlighting.`), p = "txt";
|
|
8307
8279
|
}
|
|
8308
8280
|
f = f.trimEnd();
|
|
8309
8281
|
let g = guessEmbeddedLanguages(f, p, s);
|
|
@@ -9423,7 +9395,7 @@ var TypedownContext = class {
|
|
|
9423
9395
|
createMarkdownRenderer(s).then((s) => {
|
|
9424
9396
|
this.configVersion === u && (this._md = s);
|
|
9425
9397
|
}).catch((s) => {
|
|
9426
|
-
|
|
9398
|
+
console.error(`Failed to recreate markdown renderer: ${s}`);
|
|
9427
9399
|
});
|
|
9428
9400
|
}), s.onContentChanged(({ content: s }) => {
|
|
9429
9401
|
this.cachedFileMap.delete(s), this.cachedFilesGroupedBySchema = void 0;
|
|
@@ -9477,243 +9449,82 @@ var TypedownContext = class {
|
|
|
9477
9449
|
get md() {
|
|
9478
9450
|
return this._md;
|
|
9479
9451
|
}
|
|
9480
|
-
};
|
|
9481
|
-
|
|
9482
|
-
let
|
|
9483
|
-
|
|
9484
|
-
s
|
|
9485
|
-
|
|
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
|
+
});
|
|
9486
9483
|
});
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
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);
|
|
9494
9492
|
}
|
|
9495
|
-
return process.on("exit", m), process.on("SIGINT", () => {
|
|
9496
|
-
m(), process.exit(0);
|
|
9497
|
-
}), process.on("SIGTERM", () => {
|
|
9498
|
-
m(), process.exit(0);
|
|
9499
|
-
}), p;
|
|
9500
|
-
}
|
|
9501
|
-
var _tdContext;
|
|
9502
|
-
async function getTdContext() {
|
|
9503
|
-
return _tdContext ||= await initializeTypedownContext(), _tdContext;
|
|
9504
|
-
}
|
|
9505
|
-
//#endregion
|
|
9506
|
-
//#region src/node/lib/render/vue.ts
|
|
9507
|
-
async function renderToVueSfc(s, u, d) {
|
|
9508
|
-
let f = {
|
|
9509
|
-
path: d,
|
|
9510
|
-
relativePath: d,
|
|
9511
|
-
cleanUrls: !0
|
|
9512
|
-
}, p = await s.renderAsync(u.content, f), m = f.title || getResourceTitle(u.header, d), h = {
|
|
9513
|
-
schema: u.schema,
|
|
9514
|
-
frontmatter: u.header,
|
|
9515
|
-
headings: f.headers ?? [],
|
|
9516
|
-
title: m
|
|
9517
|
-
}, g = JSON.stringify(JSON.stringify(h)), _ = JSON.stringify(p);
|
|
9518
9493
|
return {
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
"<template><div v-html=\"__html\" /></template>"
|
|
9525
|
-
].join("\n"),
|
|
9526
|
-
pageData: h
|
|
9494
|
+
root: s,
|
|
9495
|
+
logger: u,
|
|
9496
|
+
getTdContext: v,
|
|
9497
|
+
createViteLogger: d,
|
|
9498
|
+
dispose: y
|
|
9527
9499
|
};
|
|
9528
9500
|
}
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
const pages = import.meta.glob('${`/${u}/**/*.td`}');
|
|
9539
|
-
${d ? "" : `pages['/${u}/${VIRTUAL_INDEX_ID}'] = () => import('${VIRTUAL_INDEX_ID}');`}
|
|
9540
|
-
|
|
9541
|
-
async function loadPageModule(pagePath) {
|
|
9542
|
-
const key = '/${u}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
9543
|
-
const altKey = '/${u}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
9544
|
-
const loader = pages[key] || pages[altKey]${d ? "" : ` || (pagePath === '/' ? pages['/${u}/${VIRTUAL_INDEX_ID}'] : undefined)`};
|
|
9545
|
-
if (!loader) return undefined;
|
|
9546
|
-
return loader();
|
|
9547
|
-
}
|
|
9548
|
-
|
|
9549
|
-
const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
|
|
9550
|
-
title: s.siteTitle,
|
|
9551
|
-
description: s.siteDescription
|
|
9552
|
-
})}, ${JSON.stringify({ sidebarGroups: s.sidebarGroups })});
|
|
9553
|
-
app.mount('#app');
|
|
9554
|
-
`;
|
|
9555
|
-
}
|
|
9556
|
-
function generateIndexSfc(s) {
|
|
9557
|
-
let u = JSON.stringify(s).replace(/'/g, "\\'"), d = JSON.stringify({
|
|
9558
|
-
schema: "",
|
|
9559
|
-
frontmatter: {},
|
|
9560
|
-
headings: [],
|
|
9561
|
-
title: "Index"
|
|
9562
|
-
});
|
|
9563
|
-
return `<script>
|
|
9564
|
-
import { TdOverview } from 'typerighter/client/theme-default';
|
|
9565
|
-
export const __pageData = JSON.parse(${JSON.stringify(d)})
|
|
9566
|
-
export default { name: "index", components: { TdOverview } }
|
|
9567
|
-
<\/script>
|
|
9568
|
-
<template><TdOverview :groups='${u}' /></template>`;
|
|
9569
|
-
}
|
|
9570
|
-
function generateSsrEntry(s) {
|
|
9571
|
-
let u = `/${s.contentDir}/**/*.td`;
|
|
9572
|
-
return `
|
|
9573
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
9574
|
-
import { renderToString } from 'vue/server-renderer';
|
|
9575
|
-
import theme from '${s.layoutImport}';
|
|
9576
|
-
|
|
9577
|
-
const pages = import.meta.glob('${u}', { eager: true });
|
|
9578
|
-
|
|
9579
|
-
function loadPageModule(pagePath) {
|
|
9580
|
-
const key = '/${s.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
9581
|
-
const altKey = '/${s.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
9582
|
-
return Promise.resolve(pages[key] || pages[altKey]);
|
|
9583
|
-
}
|
|
9584
|
-
|
|
9585
|
-
export async function render(url) {
|
|
9586
|
-
const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${s.siteConfig}, ${s.siteData});
|
|
9587
|
-
await router.go(url, { replace: true });
|
|
9588
|
-
const html = await renderToString(app);
|
|
9589
|
-
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);
|
|
9590
9510
|
}
|
|
9591
|
-
|
|
9511
|
+
function hasConfigFile(s) {
|
|
9512
|
+
return CONFIG_FILE_NAMES.some((u) => fs.existsSync(path.join(s, u)));
|
|
9592
9513
|
}
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
}
|
|
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
|
+
}
|
|
9604
9525
|
}
|
|
9605
9526
|
//#endregion
|
|
9606
|
-
//#region src/node/plugin/vite/
|
|
9607
|
-
|
|
9608
|
-
let s;
|
|
9609
|
-
return [
|
|
9610
|
-
{
|
|
9611
|
-
name: "vite-plugin-typedown",
|
|
9612
|
-
enforce: "pre",
|
|
9613
|
-
config() {
|
|
9614
|
-
return {
|
|
9615
|
-
resolve: { alias: resolveAliases() },
|
|
9616
|
-
ssr: { noExternal: ["typerighter"] }
|
|
9617
|
-
};
|
|
9618
|
-
},
|
|
9619
|
-
resolveId(s) {
|
|
9620
|
-
if (s === "/@typedown/app" || s === "@typedown/app") return RESOLVED_VIRTUAL_APP_ID;
|
|
9621
|
-
if (s.endsWith("__typedown_index__.td")) return s;
|
|
9622
|
-
},
|
|
9623
|
-
async load(s) {
|
|
9624
|
-
let u = await getTdContext();
|
|
9625
|
-
if (s === "\0@typedown/app") {
|
|
9626
|
-
let [s, d, f] = await Promise.all([
|
|
9627
|
-
u.getConfig(),
|
|
9628
|
-
u.listFiles(),
|
|
9629
|
-
u.listFilesGroupedBySchema()
|
|
9630
|
-
]), p = d.some((s) => s === "index.td");
|
|
9631
|
-
return generateAppEntry({
|
|
9632
|
-
...s,
|
|
9633
|
-
hasIndex: p,
|
|
9634
|
-
sidebarGroups: f
|
|
9635
|
-
});
|
|
9636
|
-
}
|
|
9637
|
-
if (s.endsWith("__typedown_index__.td")) return generateIndexSfc(await u.listFilesGroupedBySchema());
|
|
9638
|
-
},
|
|
9639
|
-
async configureServer(u) {
|
|
9640
|
-
s = u;
|
|
9641
|
-
let d = await getTdContext();
|
|
9642
|
-
return d.rpc.onConfigChanged(() => s && hmrFullReload(s)), d.rpc.onContentChanged(({ content: u }) => {
|
|
9643
|
-
if (s) {
|
|
9644
|
-
for (let d of s.moduleGraph.idToModuleMap.values()) if (d.file?.endsWith(u)) {
|
|
9645
|
-
s.moduleGraph.invalidateModule(d), s.hot.send({
|
|
9646
|
-
type: "update",
|
|
9647
|
-
updates: [{
|
|
9648
|
-
type: "js-update",
|
|
9649
|
-
path: d.url,
|
|
9650
|
-
acceptedPath: d.url,
|
|
9651
|
-
timestamp: Date.now()
|
|
9652
|
-
}]
|
|
9653
|
-
});
|
|
9654
|
-
break;
|
|
9655
|
-
}
|
|
9656
|
-
}
|
|
9657
|
-
}), 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)), () => {
|
|
9658
|
-
u.middlewares.use((s, u, f) => {
|
|
9659
|
-
if (!s.url || u.writableEnded || s.url.startsWith("/@") || s.url.startsWith("/node_modules") || s.url.includes(".")) return f();
|
|
9660
|
-
d.getConfig().then((s) => {
|
|
9661
|
-
let d = `<!DOCTYPE html>
|
|
9662
|
-
<html lang="en">
|
|
9663
|
-
<head>
|
|
9664
|
-
<meta charset="UTF-8">
|
|
9665
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9666
|
-
<title>${escapeHtml$2(s.siteTitle)}</title>
|
|
9667
|
-
<link rel="icon" type="image/svg+xml" href="${BRAND_FAVICON_URI}">
|
|
9668
|
-
</head>
|
|
9669
|
-
<body>
|
|
9670
|
-
<div id="app"></div>
|
|
9671
|
-
<script type="module" src="/${VIRTUAL_APP_ID}"><\/script>
|
|
9672
|
-
</body>
|
|
9673
|
-
</html>`;
|
|
9674
|
-
u.setHeader("Content-Type", "text/html"), u.end(d);
|
|
9675
|
-
}).catch(f);
|
|
9676
|
-
});
|
|
9677
|
-
};
|
|
9678
|
-
},
|
|
9679
|
-
async transform(s, u) {
|
|
9680
|
-
let d = u.split("?")[0];
|
|
9681
|
-
if (!d.endsWith(".td") || d.includes("__typedown_index__.td")) return;
|
|
9682
|
-
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);
|
|
9683
|
-
return {
|
|
9684
|
-
code: g,
|
|
9685
|
-
map: null
|
|
9686
|
-
};
|
|
9687
|
-
},
|
|
9688
|
-
handleHotUpdate({ file: s }) {
|
|
9689
|
-
if (s.endsWith(".td")) return [];
|
|
9690
|
-
}
|
|
9691
|
-
},
|
|
9692
|
-
vue({ include: /\.(?:vue|td)$/ }),
|
|
9693
|
-
...tailwindcss()
|
|
9694
|
-
];
|
|
9695
|
-
}
|
|
9696
|
-
function getTdModules(s) {
|
|
9697
|
-
return [...s.moduleGraph.idToModuleMap.entries()].filter(([s]) => s.endsWith(".td")).map(([, s]) => s);
|
|
9698
|
-
}
|
|
9699
|
-
function hmrFullReload(s) {
|
|
9700
|
-
for (let u of getTdModules(s)) s.moduleGraph.invalidateModule(u);
|
|
9701
|
-
s.hot.send({ type: "full-reload" });
|
|
9702
|
-
}
|
|
9703
|
-
function hmrInvalidateAll(s) {
|
|
9704
|
-
let u = getTdModules(s).map((u) => (s.moduleGraph.invalidateModule(u), makeHmrUpdate(u)));
|
|
9705
|
-
0 < u.length && s.hot.send({
|
|
9706
|
-
type: "update",
|
|
9707
|
-
updates: u
|
|
9708
|
-
});
|
|
9709
|
-
}
|
|
9710
|
-
function makeHmrUpdate(s) {
|
|
9711
|
-
return {
|
|
9712
|
-
type: "js-update",
|
|
9713
|
-
path: s.url,
|
|
9714
|
-
acceptedPath: s.url,
|
|
9715
|
-
timestamp: Date.now()
|
|
9716
|
-
};
|
|
9717
|
-
}
|
|
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";
|
|
9718
9529
|
//#endregion
|
|
9719
|
-
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-VgaueuJP.js";
|
|
2
|
+
import { t as n } from "./vite-D9ePlTzy.js";
|
|
3
|
+
import "./plugin-DRzll98J.js";
|
|
4
|
+
export { e as buildSite, t as cli, n as typedown };
|