typerighter 0.1.5 → 0.2.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/dist/brand-CeSqpEQ2.js +4 -0
- package/dist/cli-ClyVBBVW.js +160 -0
- package/dist/cli.js +1 -1
- package/dist/client/theme-default.js +90 -89
- package/dist/constants-BN1OmC7K.js +46 -0
- package/dist/content-BM3UKxcc.js +16 -0
- package/dist/index.js +3 -3
- package/dist/{init-fZWFQnOM.js → init-0BIO3hYI.js} +136 -135
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/cli/init.d.ts.map +1 -1
- package/dist/node/lib/typedown-context.d.ts +1 -1
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/plugin-DStheS2n.js +1 -0
- package/dist/{typedown-context-C5kvAxE0.js → vite-Di36EFu3.js} +217 -4
- package/dist/vite.js +2 -2
- package/package.json +5 -8
- package/dist/brand-DSd9HWVy.js +0 -19
- package/dist/cli-2dHfEihR.js +0 -158
- package/dist/html-cZxXrc6x.js +0 -24
- package/dist/plugin-t6FyO8wM.js +0 -1
- package/dist/rolldown-runtime-Dqa2HsxW.js +0 -20
- package/dist/typedown-context-uGzfOyIE.js +0 -2
- package/dist/vite-CrIemqE7.js +0 -206
- /package/bin/{typedown.js → typerighter.js} +0 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { c as __toESM, i as escapeHtml$2, n as VIRTUAL_APP_ID, o as __commonJSMin, r as VIRTUAL_INDEX_ID, s as __exportAll, t as RESOLVED_VIRTUAL_APP_ID } from "./constants-BN1OmC7K.js";
|
|
2
2
|
import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
|
|
3
3
|
import { n as isLinkToPage, r as EXTERNAL_URL_RE, t as isExternal } from "./shared-DzTfF-_d.js";
|
|
4
|
+
import { r as getResourceTitle } from "./content-BM3UKxcc.js";
|
|
5
|
+
import { r as BRAND_FAVICON_URI } from "./brand-CeSqpEQ2.js";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
8
|
+
import vue from "@vitejs/plugin-vue";
|
|
4
9
|
import path from "node:path";
|
|
5
10
|
import { RpcServer } from "@typerighter/rpc-server";
|
|
6
11
|
import { RpcClient } from "@typerighter/rpc-client";
|
|
@@ -9483,7 +9488,7 @@ async function initializeTypedownContext() {
|
|
|
9483
9488
|
s.unref();
|
|
9484
9489
|
let m = !1;
|
|
9485
9490
|
function h() {
|
|
9486
|
-
m || (m = !0, s.close());
|
|
9491
|
+
m || (m = !0, f.free(), s.close());
|
|
9487
9492
|
}
|
|
9488
9493
|
return process.on("exit", h), process.on("SIGINT", () => {
|
|
9489
9494
|
h(), process.exit(0);
|
|
@@ -9491,6 +9496,214 @@ async function initializeTypedownContext() {
|
|
|
9491
9496
|
h(), process.exit(0);
|
|
9492
9497
|
}), p;
|
|
9493
9498
|
}
|
|
9494
|
-
var
|
|
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
|
+
return {
|
|
9517
|
+
vueSrc: [
|
|
9518
|
+
"<script>",
|
|
9519
|
+
`export const __pageData = JSON.parse(${g})`,
|
|
9520
|
+
`export default { name: ${JSON.stringify(d)}, data() { return { __html: ${_} } } }`,
|
|
9521
|
+
"<\/script>",
|
|
9522
|
+
"<template><div v-html=\"__html\" /></template>"
|
|
9523
|
+
].join("\n"),
|
|
9524
|
+
pageData: h
|
|
9525
|
+
};
|
|
9526
|
+
}
|
|
9527
|
+
//#endregion
|
|
9528
|
+
//#region src/node/plugin/vite/codegen.ts
|
|
9529
|
+
function generateAppEntry(s) {
|
|
9530
|
+
let { contentDir: u, hasIndex: d } = s;
|
|
9531
|
+
return `
|
|
9532
|
+
import 'typerighter/style.css';
|
|
9533
|
+
import { createTypedownApp } from 'typerighter/client';
|
|
9534
|
+
import theme from 'typerighter/client/theme-default';
|
|
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 };
|
|
9588
|
+
}
|
|
9589
|
+
`;
|
|
9590
|
+
}
|
|
9591
|
+
//#endregion
|
|
9592
|
+
//#region src/node/plugin/vite/index.ts
|
|
9593
|
+
var require$1 = createRequire(import.meta.url);
|
|
9594
|
+
function typedown() {
|
|
9595
|
+
let s;
|
|
9596
|
+
return [
|
|
9597
|
+
{
|
|
9598
|
+
name: "vite-plugin-typedown",
|
|
9599
|
+
enforce: "pre",
|
|
9600
|
+
config() {
|
|
9601
|
+
return { resolve: { alias: [{
|
|
9602
|
+
find: "vue/server-renderer",
|
|
9603
|
+
replacement: require$1.resolve("vue/server-renderer")
|
|
9604
|
+
}, {
|
|
9605
|
+
find: "vue",
|
|
9606
|
+
replacement: require$1.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
9607
|
+
}] } };
|
|
9608
|
+
},
|
|
9609
|
+
resolveId(s) {
|
|
9610
|
+
if (s === "/@typedown/app" || s === "@typedown/app") return RESOLVED_VIRTUAL_APP_ID;
|
|
9611
|
+
if (s.endsWith("__typedown_index__.td")) return s;
|
|
9612
|
+
},
|
|
9613
|
+
async load(s) {
|
|
9614
|
+
let u = await getTdContext();
|
|
9615
|
+
if (s === "\0@typedown/app") {
|
|
9616
|
+
let [s, d, f] = await Promise.all([
|
|
9617
|
+
u.getConfig(),
|
|
9618
|
+
u.listFiles(),
|
|
9619
|
+
u.listFilesGroupedBySchema()
|
|
9620
|
+
]), p = d.some((s) => s === "index.td");
|
|
9621
|
+
return generateAppEntry({
|
|
9622
|
+
...s,
|
|
9623
|
+
hasIndex: p,
|
|
9624
|
+
sidebarGroups: f
|
|
9625
|
+
});
|
|
9626
|
+
}
|
|
9627
|
+
if (s.endsWith("__typedown_index__.td")) return generateIndexSfc(await u.listFilesGroupedBySchema());
|
|
9628
|
+
},
|
|
9629
|
+
async configureServer(u) {
|
|
9630
|
+
s = u;
|
|
9631
|
+
let d = await getTdContext();
|
|
9632
|
+
return d.rpc.onConfigChanged(() => s && hmrFullReload(s)), d.rpc.onContentChanged(({ content: u }) => {
|
|
9633
|
+
if (s) {
|
|
9634
|
+
for (let d of s.moduleGraph.idToModuleMap.values()) if (d.file?.endsWith(u)) {
|
|
9635
|
+
s.moduleGraph.invalidateModule(d), s.hot.send({
|
|
9636
|
+
type: "update",
|
|
9637
|
+
updates: [{
|
|
9638
|
+
type: "js-update",
|
|
9639
|
+
path: d.url,
|
|
9640
|
+
acceptedPath: d.url,
|
|
9641
|
+
timestamp: Date.now()
|
|
9642
|
+
}]
|
|
9643
|
+
});
|
|
9644
|
+
break;
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
}), 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)), () => {
|
|
9648
|
+
u.middlewares.use((s, u, f) => {
|
|
9649
|
+
if (!s.url || u.writableEnded || s.url.startsWith("/@") || s.url.startsWith("/node_modules") || s.url.includes(".")) return f();
|
|
9650
|
+
d.getConfig().then((s) => {
|
|
9651
|
+
let d = `<!DOCTYPE html>
|
|
9652
|
+
<html lang="en">
|
|
9653
|
+
<head>
|
|
9654
|
+
<meta charset="UTF-8">
|
|
9655
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9656
|
+
<title>${escapeHtml$2(s.siteTitle)}</title>
|
|
9657
|
+
<link rel="icon" type="image/svg+xml" href="${BRAND_FAVICON_URI}">
|
|
9658
|
+
</head>
|
|
9659
|
+
<body>
|
|
9660
|
+
<div id="app"></div>
|
|
9661
|
+
<script type="module" src="/${VIRTUAL_APP_ID}"><\/script>
|
|
9662
|
+
</body>
|
|
9663
|
+
</html>`;
|
|
9664
|
+
u.setHeader("Content-Type", "text/html"), u.end(d);
|
|
9665
|
+
}).catch(f);
|
|
9666
|
+
});
|
|
9667
|
+
};
|
|
9668
|
+
},
|
|
9669
|
+
async transform(s, u) {
|
|
9670
|
+
let d = u.split("?")[0];
|
|
9671
|
+
if (!d.endsWith(".td") || d.includes("__typedown_index__.td")) return;
|
|
9672
|
+
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);
|
|
9673
|
+
return {
|
|
9674
|
+
code: g,
|
|
9675
|
+
map: null
|
|
9676
|
+
};
|
|
9677
|
+
},
|
|
9678
|
+
handleHotUpdate({ file: s }) {
|
|
9679
|
+
if (s.endsWith(".td")) return [];
|
|
9680
|
+
}
|
|
9681
|
+
},
|
|
9682
|
+
vue({ include: /\.(?:vue|td)$/ }),
|
|
9683
|
+
...tailwindcss()
|
|
9684
|
+
];
|
|
9685
|
+
}
|
|
9686
|
+
function getTdModules(s) {
|
|
9687
|
+
return [...s.moduleGraph.idToModuleMap.entries()].filter(([s]) => s.endsWith(".td")).map(([, s]) => s);
|
|
9688
|
+
}
|
|
9689
|
+
function hmrFullReload(s) {
|
|
9690
|
+
for (let u of getTdModules(s)) s.moduleGraph.invalidateModule(u);
|
|
9691
|
+
s.hot.send({ type: "full-reload" });
|
|
9692
|
+
}
|
|
9693
|
+
function hmrInvalidateAll(s) {
|
|
9694
|
+
let u = getTdModules(s).map((u) => (s.moduleGraph.invalidateModule(u), makeHmrUpdate(u)));
|
|
9695
|
+
0 < u.length && s.hot.send({
|
|
9696
|
+
type: "update",
|
|
9697
|
+
updates: u
|
|
9698
|
+
});
|
|
9699
|
+
}
|
|
9700
|
+
function makeHmrUpdate(s) {
|
|
9701
|
+
return {
|
|
9702
|
+
type: "js-update",
|
|
9703
|
+
path: s.url,
|
|
9704
|
+
acceptedPath: s.url,
|
|
9705
|
+
timestamp: Date.now()
|
|
9706
|
+
};
|
|
9707
|
+
}
|
|
9495
9708
|
//#endregion
|
|
9496
|
-
export {
|
|
9709
|
+
export { logger as a, getTdContext as i, generateAppEntry as n, require_picocolors_browser as o, generateSsrEntry as r, typedown as t };
|
package/dist/vite.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as e } from "./vite-
|
|
2
|
-
import "./plugin-
|
|
1
|
+
import { t as e } from "./vite-Di36EFu3.js";
|
|
2
|
+
import "./plugin-DStheS2n.js";
|
|
3
3
|
export { e as typedown };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "typerighter",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Typedown: A typed content framework.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"bin": {
|
|
13
|
-
"
|
|
13
|
+
"typerighter": "./bin/typerighter.js"
|
|
14
14
|
},
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
@@ -74,12 +74,10 @@
|
|
|
74
74
|
"picocolors": "^1.1.1",
|
|
75
75
|
"shiki": "^4.3.1",
|
|
76
76
|
"tailwindcss": "^4.3.3",
|
|
77
|
-
"@typerighter/rpc-client": "0.1.5",
|
|
78
|
-
"@typerighter/rpc-server": "0.1.5"
|
|
79
|
-
},
|
|
80
|
-
"peerDependencies": {
|
|
81
77
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
82
|
-
"vue": "^3.0.0"
|
|
78
|
+
"vue": "^3.0.0",
|
|
79
|
+
"@typerighter/rpc-client": "0.2.0",
|
|
80
|
+
"@typerighter/rpc-server": "0.2.0"
|
|
83
81
|
},
|
|
84
82
|
"devDependencies": {
|
|
85
83
|
"@hdnax/nuclint": "^0.17.4",
|
|
@@ -88,7 +86,6 @@
|
|
|
88
86
|
"@types/markdown-it-emoji": "^3.0.1",
|
|
89
87
|
"@types/node": "~24.13.3",
|
|
90
88
|
"typescript": "^6.0.3",
|
|
91
|
-
"vite": "^8.0.16",
|
|
92
89
|
"vitest": "^4.1.5"
|
|
93
90
|
},
|
|
94
91
|
"scripts": {
|
package/dist/brand-DSd9HWVy.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/shared/utils/content.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return n(e.header, e.path);
|
|
4
|
-
}
|
|
5
|
-
function t(e) {
|
|
6
|
-
return "/" + e.path.replace(/\.td$/, "");
|
|
7
|
-
}
|
|
8
|
-
function n(e, t) {
|
|
9
|
-
return e._label === void 0 ? e.name === void 0 ? r(t.replace(/\.td$/, "").split("/").pop() ?? "") : String(e.name) : String(e._label);
|
|
10
|
-
}
|
|
11
|
-
function r(e) {
|
|
12
|
-
let t = e.replace(/[-_]/g, " ").split(" ");
|
|
13
|
-
return 0 < t.length && (t[0] = t[0].charAt(0).toUpperCase() + t[0].slice(1)), t.join(" ");
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/shared/brand.ts
|
|
17
|
-
var i = "m15 10c-2.7614 0-5 2.2386-5 5v98c0 2.761 2.2386 5 5 5h178c2.761 0 5-2.239 5-5v-98c0-2.7614-2.239-5-5-5zm-15 5c0-8.28427 6.71573-15 15-15h178c8.284 0 15 6.71573 15 15v98c0 8.284-6.716 15-15 15h-178c-8.28427 0-15-6.716-15-15z", a = "M30 30h70v16h-27v52h-16v-52h-27z", o = "m155 98-30-33h20v-35h20v35h20z", s = "0 0 208 128", c = "#a0522d", l = `<svg fill='none' viewBox='${s}' xmlns='http://www.w3.org/2000/svg'><path clip-rule='evenodd' d='${i}' fill-rule='evenodd' fill='${c}'/><path d='${a}' fill='${c}'/><path d='${o}' fill='${c}'/></svg>`, u = `data:image/svg+xml,${encodeURIComponent(l)}`;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { s as a, n as c, a as i, i as n, e as o, u as r, t as s, o as t };
|
package/dist/cli-2dHfEihR.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { r as e } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
2
|
-
import { i as t, r as n } from "./typedown-context-C5kvAxE0.js";
|
|
3
|
-
import { n as r, r as i, t as a } from "./vite-CrIemqE7.js";
|
|
4
|
-
import { n as o } from "./html-cZxXrc6x.js";
|
|
5
|
-
import s from "node:path";
|
|
6
|
-
import c from "node:fs/promises";
|
|
7
|
-
import l from "node:os";
|
|
8
|
-
import { build as u, createLogger as d, createServer as f } from "vite";
|
|
9
|
-
//#region src/node/build/render.ts
|
|
10
|
-
var p = /* @__PURE__ */ e(t(), 1);
|
|
11
|
-
async function m(e) {
|
|
12
|
-
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await h(e.clientOutDir);
|
|
13
|
-
for (let a = 0; a < e.pagePaths.length; a += 8) {
|
|
14
|
-
let l = e.pagePaths.slice(a, a + 8);
|
|
15
|
-
await Promise.all(l.map(async (a) => {
|
|
16
|
-
let l = await t.render(a), u = o({
|
|
17
|
-
content: l.html,
|
|
18
|
-
title: l.pageData.title,
|
|
19
|
-
description: l.pageData.frontmatter.description === void 0 ? "" : String(l.pageData.frontmatter.description),
|
|
20
|
-
clientEntry: n,
|
|
21
|
-
cssFiles: r,
|
|
22
|
-
jsFiles: i,
|
|
23
|
-
base: e.base
|
|
24
|
-
}), d = a === "/" ? "index.html" : `${a.replace(/^\//, "")}.html`, f = s.join(e.outDir, d);
|
|
25
|
-
await c.mkdir(s.dirname(f), { recursive: !0 }), await c.writeFile(f, u);
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async function h(e) {
|
|
30
|
-
let t = s.join(e, "assets"), n = [], r = await c.readdir(t).catch(() => n), i = [], a = [], o = "";
|
|
31
|
-
for (let e of r) e.endsWith(".css") ? i.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? o = `assets/${e}` : a.push(`assets/${e}`));
|
|
32
|
-
return !o && a.length > 0 && (o = a[0], a.splice(0, 1)), {
|
|
33
|
-
clientEntry: o,
|
|
34
|
-
cssFiles: i,
|
|
35
|
-
jsFiles: a
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/node/build/index.ts
|
|
40
|
-
var g = "typerighter/client/theme-default";
|
|
41
|
-
async function _(e) {
|
|
42
|
-
let t = s.resolve(e.root), a = s.resolve(t, e.outDir ?? "dist"), o = e.base ?? "/", d = s.join(a, ".client"), f = s.join(a, ".server"), { tdContext: p } = await import("./typedown-context-uGzfOyIE.js"), [h, _, y] = await Promise.all([
|
|
43
|
-
p.getConfig(),
|
|
44
|
-
p.listFiles(),
|
|
45
|
-
p.listFilesGroupedBySchema()
|
|
46
|
-
]), b = _.some((e) => e === "index.td"), x = JSON.stringify({
|
|
47
|
-
title: h.siteTitle,
|
|
48
|
-
description: h.siteDescription
|
|
49
|
-
}), S = JSON.stringify({ sidebarGroups: y }), C = await c.mkdtemp(s.join(l.tmpdir(), "typerighter-")), w = s.join(C, "client-entry.js"), T = s.join(C, "ssr-entry.js");
|
|
50
|
-
await Promise.all([c.writeFile(w, r({
|
|
51
|
-
contentDir: h.contentDir,
|
|
52
|
-
siteTitle: h.siteTitle,
|
|
53
|
-
siteDescription: h.siteDescription,
|
|
54
|
-
hasIndex: b,
|
|
55
|
-
sidebarGroups: y
|
|
56
|
-
})), c.writeFile(T, i({
|
|
57
|
-
contentDir: h.contentDir,
|
|
58
|
-
layoutImport: g,
|
|
59
|
-
siteConfig: x,
|
|
60
|
-
siteData: S
|
|
61
|
-
}))]);
|
|
62
|
-
try {
|
|
63
|
-
n.info("Phase 1: Building client bundle..."), await u({
|
|
64
|
-
...e.viteConfig,
|
|
65
|
-
root: t,
|
|
66
|
-
base: o,
|
|
67
|
-
build: {
|
|
68
|
-
...e.viteConfig?.build,
|
|
69
|
-
outDir: d,
|
|
70
|
-
ssrManifest: !0,
|
|
71
|
-
emptyOutDir: !0,
|
|
72
|
-
rollupOptions: {
|
|
73
|
-
...e.viteConfig?.build?.rollupOptions,
|
|
74
|
-
input: w
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}), n.info("Phase 2: Building SSR bundle..."), await u({
|
|
78
|
-
...e.viteConfig,
|
|
79
|
-
root: t,
|
|
80
|
-
base: o,
|
|
81
|
-
build: {
|
|
82
|
-
...e.viteConfig?.build,
|
|
83
|
-
outDir: f,
|
|
84
|
-
ssr: T,
|
|
85
|
-
emptyOutDir: !0
|
|
86
|
-
}
|
|
87
|
-
}), n.info("Phase 3: Pre-rendering pages...");
|
|
88
|
-
let r = _.map((e) => {
|
|
89
|
-
let t = e.replace(/\.td$/, "");
|
|
90
|
-
return t === "index" ? "/" : `/${t}`;
|
|
91
|
-
});
|
|
92
|
-
await m({
|
|
93
|
-
ssrEntryPath: s.join(f, "ssr-entry.js"),
|
|
94
|
-
clientOutDir: d,
|
|
95
|
-
outDir: a,
|
|
96
|
-
base: o,
|
|
97
|
-
pagePaths: r
|
|
98
|
-
});
|
|
99
|
-
let i = s.join(d, "assets"), l = s.join(a, "assets");
|
|
100
|
-
await c.cp(i, l, { recursive: !0 }).catch(() => {}), await v(s.join(t, h.contentDir), a);
|
|
101
|
-
} finally {
|
|
102
|
-
await Promise.all([
|
|
103
|
-
c.rm(C, {
|
|
104
|
-
recursive: !0,
|
|
105
|
-
force: !0
|
|
106
|
-
}),
|
|
107
|
-
c.rm(d, {
|
|
108
|
-
recursive: !0,
|
|
109
|
-
force: !0
|
|
110
|
-
}),
|
|
111
|
-
c.rm(f, {
|
|
112
|
-
recursive: !0,
|
|
113
|
-
force: !0
|
|
114
|
-
})
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
n.info(`Build complete. Output: ${a}`);
|
|
118
|
-
}
|
|
119
|
-
async function v(e, t) {
|
|
120
|
-
let n = (await c.readdir(e, {
|
|
121
|
-
recursive: !0,
|
|
122
|
-
withFileTypes: !0
|
|
123
|
-
})).filter((e) => e.isFile() && !e.name.endsWith(".td")).map((n) => {
|
|
124
|
-
let r = s.join(n.parentPath, n.name), i = s.relative(e, r), a = s.join(t, i);
|
|
125
|
-
return c.mkdir(s.dirname(a), { recursive: !0 }).then(() => c.copyFile(r, a));
|
|
126
|
-
});
|
|
127
|
-
await Promise.all(n);
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/node/cli/index.ts
|
|
131
|
-
async function y() {
|
|
132
|
-
let e = process.argv.slice(2), t = e[0], n = e[1] ?? process.cwd();
|
|
133
|
-
try {
|
|
134
|
-
if (!t || t === "dev") {
|
|
135
|
-
let e = await f({
|
|
136
|
-
root: n,
|
|
137
|
-
configFile: !1,
|
|
138
|
-
plugins: [a()]
|
|
139
|
-
});
|
|
140
|
-
await e.listen(), e.printUrls();
|
|
141
|
-
} else if (t === "build") await _({ root: n });
|
|
142
|
-
else if (t === "init") {
|
|
143
|
-
let { initialize: e } = await import("./init-fZWFQnOM.js");
|
|
144
|
-
await e(n);
|
|
145
|
-
} else if (t === "preview") {
|
|
146
|
-
let { preview: e } = await import("vite");
|
|
147
|
-
(await e({ root: n })).printUrls();
|
|
148
|
-
} else b(`unknown command "${t}".`);
|
|
149
|
-
} catch (e) {
|
|
150
|
-
b(`${t ?? "dev"} error:`, e);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function b(e, t) {
|
|
154
|
-
let n = d(), r = [p.default.red(e)];
|
|
155
|
-
t instanceof Error && (r.push(t.message), t.stack && r.push(t.stack)), n.error(r.join("\n")), process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
export { _ as n, y as t };
|
package/dist/html-cZxXrc6x.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/node/build/html.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
let n = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), r = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
|
|
4
|
-
return `<!DOCTYPE html>
|
|
5
|
-
<html lang="${e.lang ?? "en"}">
|
|
6
|
-
<head>
|
|
7
|
-
<meta charset="UTF-8">
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
-
<title>${t(e.title)}</title>
|
|
10
|
-
<meta name="description" content="${t(e.description)}">
|
|
11
|
-
${n}
|
|
12
|
-
${r}
|
|
13
|
-
</head>
|
|
14
|
-
<body>
|
|
15
|
-
<div id="app">${e.content}</div>
|
|
16
|
-
<script type="module" src="${e.base}${e.clientEntry}"><\/script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>`;
|
|
19
|
-
}
|
|
20
|
-
function t(e) {
|
|
21
|
-
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { e as n, t };
|
package/dist/plugin-t6FyO8wM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./vite-CrIemqE7.js";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
-
let r = {};
|
|
4
|
-
for (var i in e) t(r, i, {
|
|
5
|
-
get: e[i],
|
|
6
|
-
enumerable: !0
|
|
7
|
-
});
|
|
8
|
-
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
-
}, c = (e, i, o, s) => {
|
|
10
|
-
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
-
get: ((e) => i[e]).bind(null, d),
|
|
12
|
-
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
-
});
|
|
14
|
-
return e;
|
|
15
|
-
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
-
value: n,
|
|
17
|
-
enumerable: !0
|
|
18
|
-
}) : a, n));
|
|
19
|
-
//#endregion
|
|
20
|
-
export { s as n, l as r, o as t };
|