typerighter 0.1.3 → 0.1.5
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/typedown.js +5 -0
- package/dist/{app-bn8sNpDS.js → app-CM3biamr.js} +18 -14
- package/dist/cli-2dHfEihR.js +158 -0
- package/dist/cli.js +2 -0
- package/dist/client/app/composables/useTdContent.d.ts +2 -1
- package/dist/client/app/composables/useTdContent.d.ts.map +1 -1
- package/dist/client/theme-default.js +1 -1
- package/dist/client.js +1 -1
- package/dist/html-cZxXrc6x.js +24 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -187
- package/dist/init-fZWFQnOM.js +646 -0
- package/dist/node/build/html.d.ts +1 -0
- package/dist/node/build/html.d.ts.map +1 -1
- package/dist/node/build/html.test.d.ts +2 -0
- package/dist/node/build/html.test.d.ts.map +1 -0
- package/dist/node/build/index.d.ts +0 -4
- package/dist/node/build/index.d.ts.map +1 -1
- 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 +2 -0
- package/dist/node/cli/init.d.ts.map +1 -0
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/{codegen.d.ts → vite/codegen.d.ts} +11 -0
- package/dist/node/plugin/vite/codegen.d.ts.map +1 -0
- package/dist/node/plugin/vite/codegen.test.d.ts.map +1 -0
- package/dist/node/plugin/vite/constants.d.ts.map +1 -0
- package/dist/node/plugin/{vite.d.ts → vite/index.d.ts} +1 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -0
- package/dist/plugin-t6FyO8wM.js +1 -0
- package/dist/rolldown-runtime-Dqa2HsxW.js +20 -0
- package/dist/{typedown-context-CWA07Yb7.js → typedown-context-C5kvAxE0.js} +65 -5
- package/dist/typedown-context-uGzfOyIE.js +2 -0
- package/dist/vite-CrIemqE7.js +206 -0
- package/dist/vite.js +3 -174
- package/package.json +9 -5
- package/dist/logger-DZLd8EDg.js +0 -78
- package/dist/node/build/codegen.d.ts +0 -13
- package/dist/node/build/codegen.d.ts.map +0 -1
- package/dist/node/cli/server.d.ts +0 -5
- package/dist/node/cli/server.d.ts.map +0 -1
- package/dist/node/plugin/codegen.d.ts.map +0 -1
- package/dist/node/plugin/codegen.test.d.ts.map +0 -1
- package/dist/node/plugin/constants.d.ts.map +0 -1
- package/dist/node/plugin/vite.d.ts.map +0 -1
- package/dist/node/plugin.d.ts +0 -3
- package/dist/node/plugin.d.ts.map +0 -1
- package/dist/typedown-context-D78bYNhH.js +0 -2
- /package/dist/node/plugin/{codegen.test.d.ts → vite/codegen.test.d.ts} +0 -0
- /package/dist/node/plugin/{constants.d.ts → vite/constants.d.ts} +0 -0
package/bin/typedown.js
ADDED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "./shared-DzTfF-_d.js";
|
|
2
|
-
import { computed as e, createApp as t, defineComponent as n, h as r, inject as i, markRaw as a, nextTick as o,
|
|
3
|
-
import { createInjectionState as u } from "@vueuse/core";
|
|
2
|
+
import { computed as e, createApp as t, defineComponent as n, h as r, inject as i, markRaw as a, nextTick as o, provide as s, reactive as c, readonly as l, ref as u } from "vue";
|
|
4
3
|
//#region src/shared/utils/environment.ts
|
|
5
4
|
var d = typeof window < "u", f = Symbol("typedown-router"), p = {
|
|
6
5
|
schema: "",
|
|
@@ -9,7 +8,7 @@ var d = typeof window < "u", f = Symbol("typedown-router"), p = {
|
|
|
9
8
|
title: "Not Found"
|
|
10
9
|
};
|
|
11
10
|
function m(e, t) {
|
|
12
|
-
let n =
|
|
11
|
+
let n = c({
|
|
13
12
|
path: "/",
|
|
14
13
|
hash: "",
|
|
15
14
|
query: "",
|
|
@@ -18,10 +17,10 @@ function m(e, t) {
|
|
|
18
17
|
}), r = {
|
|
19
18
|
route: n,
|
|
20
19
|
async go(e, t) {
|
|
21
|
-
e = y(e), await r.onBeforeRouteChange?.(e) !== !1 && ((!d || t?.initialLoad || v(e, t)) && await
|
|
20
|
+
e = y(e), await r.onBeforeRouteChange?.(e) !== !1 && ((!d || t?.initialLoad || v(e, t)) && await s(e), l(), await r.onAfterRouteChange?.(e));
|
|
22
21
|
}
|
|
23
22
|
}, i;
|
|
24
|
-
async function
|
|
23
|
+
async function s(r) {
|
|
25
24
|
let s = new URL(r, "http://a.com"), c = i = s.pathname;
|
|
26
25
|
try {
|
|
27
26
|
let t = await e(c);
|
|
@@ -54,7 +53,7 @@ function m(e, t) {
|
|
|
54
53
|
}, { capture: !0 }), window.addEventListener("popstate", async (e) => {
|
|
55
54
|
if (e.state == null) return;
|
|
56
55
|
let t = y(location.href);
|
|
57
|
-
await
|
|
56
|
+
await s(t), l(), await r.onAfterRouteChange?.(t);
|
|
58
57
|
}), window.addEventListener("hashchange", (e) => {
|
|
59
58
|
e.preventDefault(), l();
|
|
60
59
|
})), r;
|
|
@@ -105,7 +104,7 @@ function S(e) {
|
|
|
105
104
|
function C() {
|
|
106
105
|
return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
107
106
|
}
|
|
108
|
-
var w =
|
|
107
|
+
var w = u("system"), T = u(C()), E = !1;
|
|
109
108
|
function D() {
|
|
110
109
|
O();
|
|
111
110
|
let t = e(() => w.value === "system" ? T.value : w.value), n = e(() => t.value === "dark");
|
|
@@ -116,7 +115,7 @@ function D() {
|
|
|
116
115
|
r(t.value === "light" ? "dark" : "light");
|
|
117
116
|
}
|
|
118
117
|
return {
|
|
119
|
-
theme:
|
|
118
|
+
theme: l(w),
|
|
120
119
|
effectiveTheme: t,
|
|
121
120
|
isDark: n,
|
|
122
121
|
setTheme: r,
|
|
@@ -136,15 +135,20 @@ function O() {
|
|
|
136
135
|
}
|
|
137
136
|
//#endregion
|
|
138
137
|
//#region src/client/app/composables/useTdContent.ts
|
|
139
|
-
var
|
|
140
|
-
function
|
|
141
|
-
let n = D()
|
|
142
|
-
return {
|
|
138
|
+
var k = Symbol("td-content");
|
|
139
|
+
function A(t) {
|
|
140
|
+
let n = D(), r = {
|
|
143
141
|
page: e(() => t.data),
|
|
144
142
|
frontmatter: e(() => t.data.frontmatter),
|
|
145
143
|
title: e(() => t.data.title),
|
|
146
144
|
isDark: e(() => n.isDark.value)
|
|
147
145
|
};
|
|
146
|
+
return s(k, r), r;
|
|
147
|
+
}
|
|
148
|
+
function j() {
|
|
149
|
+
let e = i(k);
|
|
150
|
+
if (e === void 0) throw Error("useTdContent() called without a parent provideTdContent()");
|
|
151
|
+
return e;
|
|
148
152
|
}
|
|
149
153
|
//#endregion
|
|
150
154
|
//#region src/client/app/index.ts
|
|
@@ -156,7 +160,7 @@ async function P(e, i, a = {}, o = {}) {
|
|
|
156
160
|
}, c = { sidebarGroups: o.sidebarGroups ?? {} }, l = m(e), u = t(n({
|
|
157
161
|
name: "TypedownApp",
|
|
158
162
|
setup() {
|
|
159
|
-
return
|
|
163
|
+
return A(l.route), () => r(i);
|
|
160
164
|
}
|
|
161
165
|
}));
|
|
162
166
|
return u.provide(f, l), u.provide(M, s), u.provide(N, c), u.component("TypedownContent", b), d && await l.go(location.href, {
|
|
@@ -177,4 +181,4 @@ function I() {
|
|
|
177
181
|
return i(N, { sidebarGroups: {} });
|
|
178
182
|
}
|
|
179
183
|
//#endregion
|
|
180
|
-
export { D as a, _ as c,
|
|
184
|
+
export { D as a, _ as c, j as i, F as n, b as o, I as r, g as s, P as t };
|
|
@@ -0,0 +1,158 @@
|
|
|
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/cli.js
ADDED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Route } from '../router';
|
|
2
2
|
import type { TypedownData } from '@/shared';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function provideTdContent(route: Route): TypedownData;
|
|
4
|
+
export declare function useTdContent(): TypedownData;
|
|
4
5
|
//# sourceMappingURL=useTdContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTdContent.d.ts","sourceRoot":"","sources":["../../../../src/client/app/composables/useTdContent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EACV,YAAY,EACb,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useTdContent.d.ts","sourceRoot":"","sources":["../../../../src/client/app/composables/useTdContent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EACV,YAAY,EACb,MAAM,UAAU,CAAC;AAKlB,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,KAAK,GAAG,YAAY,CAY5D;AAGD,wBAAgB,YAAY,IAAK,YAAY,CAQ5C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../shared-DzTfF-_d.js";
|
|
2
2
|
import { a as e, i as t, n, o as r, s as i, t as a } from "../brand-DSd9HWVy.js";
|
|
3
|
-
import { a as o, i as s, n as c, o as l, r as ee, s as te } from "../app-
|
|
3
|
+
import { a as o, i as s, n as c, o as l, r as ee, s as te } from "../app-CM3biamr.js";
|
|
4
4
|
import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, createTextVNode as ne, createVNode as g, defineComponent as _, h as v, normalizeClass as y, onMounted as b, onUnmounted as x, openBlock as S, readonly as re, ref as C, renderList as w, renderSlot as T, toDisplayString as E, unref as D, watch as O, withCtx as k } from "vue";
|
|
5
5
|
//#region ../../node_modules/.pnpm/lucide-vue-next@1.0.0_vue@3.5.40_typescript@6.0.3_/node_modules/lucide-vue-next/dist/esm/shared/src/utils/hasA11yProp.js
|
|
6
6
|
var ie = (e) => {
|
package/dist/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as e, i as t, n, o as r, r as i, s as a, t as o } from "./app-
|
|
1
|
+
import { c as e, i as t, n, o as r, r as i, s as a, t as o } from "./app-CM3biamr.js";
|
|
2
2
|
export { r as Content, o as createTypedownApp, a as useRoute, e as useRouter, n as useSiteConfig, i as useSiteData, t as useTdContent };
|
|
@@ -0,0 +1,24 @@
|
|
|
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/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './node
|
|
1
|
+
export * from './node';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,187 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import a from "node:os";
|
|
6
|
-
//#region src/node/cli/server.ts
|
|
7
|
-
async function o(e = {}, t) {
|
|
8
|
-
return n({
|
|
9
|
-
root: t.root,
|
|
10
|
-
base: t.base,
|
|
11
|
-
cacheDir: t.cacheDir,
|
|
12
|
-
plugins: [],
|
|
13
|
-
server: e,
|
|
14
|
-
customLogger: t.logger,
|
|
15
|
-
configFile: t.configFile
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/node/build/html.ts
|
|
20
|
-
function s(e) {
|
|
21
|
-
let t = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), n = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
|
|
22
|
-
return `<!DOCTYPE html>
|
|
23
|
-
<html lang="${e.lang ?? "en"}">
|
|
24
|
-
<head>
|
|
25
|
-
<meta charset="UTF-8">
|
|
26
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
27
|
-
<title>${c(e.title)}</title>
|
|
28
|
-
<meta name="description" content="${c(e.description)}">
|
|
29
|
-
${t}
|
|
30
|
-
${n}
|
|
31
|
-
</head>
|
|
32
|
-
<body>
|
|
33
|
-
<div id="app">${e.content}</div>
|
|
34
|
-
<script type="module" src="${e.base}${e.clientEntry}"><\/script>
|
|
35
|
-
</body>
|
|
36
|
-
</html>`;
|
|
37
|
-
}
|
|
38
|
-
function c(e) {
|
|
39
|
-
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/node/build/render.ts
|
|
43
|
-
async function l(e) {
|
|
44
|
-
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: a, jsFiles: o } = await u(e.clientOutDir);
|
|
45
|
-
for (let c = 0; c < e.pagePaths.length; c += 8) {
|
|
46
|
-
let l = e.pagePaths.slice(c, c + 8);
|
|
47
|
-
await Promise.all(l.map(async (c) => {
|
|
48
|
-
let l = await t.render(c), u = s({
|
|
49
|
-
content: l.html,
|
|
50
|
-
title: l.pageData.title,
|
|
51
|
-
description: l.pageData.frontmatter.description === void 0 ? "" : String(l.pageData.frontmatter.description),
|
|
52
|
-
clientEntry: n,
|
|
53
|
-
cssFiles: a,
|
|
54
|
-
jsFiles: o,
|
|
55
|
-
base: e.base
|
|
56
|
-
}), d = c === "/" ? "index.html" : `${c.replace(/^\//, "")}.html`, f = r.join(e.outDir, d);
|
|
57
|
-
await i.mkdir(r.dirname(f), { recursive: !0 }), await i.writeFile(f, u);
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function u(e) {
|
|
62
|
-
let t = r.join(e, "assets"), n = [], a = await i.readdir(t).catch(() => n), o = [], s = [], c = "";
|
|
63
|
-
for (let e of a) e.endsWith(".css") ? o.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? c = `assets/${e}` : s.push(`assets/${e}`));
|
|
64
|
-
return !c && s.length > 0 && (c = s[0], s.splice(0, 1)), {
|
|
65
|
-
clientEntry: c,
|
|
66
|
-
cssFiles: o,
|
|
67
|
-
jsFiles: s
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/node/build/codegen.ts
|
|
72
|
-
function d(e) {
|
|
73
|
-
let t = `/${e.contentDir}/**/*.td`;
|
|
74
|
-
return `\
|
|
75
|
-
import { createTypedownApp } from '${e.typerighterPackage}/dist/client';
|
|
76
|
-
import Layout from '${e.layoutImport}';
|
|
77
|
-
|
|
78
|
-
const pages = import.meta.glob('${t}');
|
|
79
|
-
|
|
80
|
-
async function loadPageModule(pagePath) {
|
|
81
|
-
const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
82
|
-
const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
83
|
-
const loader = pages[key] || pages[altKey];
|
|
84
|
-
if (!loader) return undefined;
|
|
85
|
-
return loader();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function main() {
|
|
89
|
-
const { app } = await createTypedownApp(loadPageModule, Layout);
|
|
90
|
-
app.mount('#app');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
main();
|
|
94
|
-
`;
|
|
95
|
-
}
|
|
96
|
-
function f(e) {
|
|
97
|
-
let t = `/${e.contentDir}/**/*.td`;
|
|
98
|
-
return `\
|
|
99
|
-
import { createTypedownApp } from '${e.typerighterPackage}/dist/client';
|
|
100
|
-
import { renderToString } from 'vue/server-renderer';
|
|
101
|
-
import Layout from '${e.layoutImport}';
|
|
102
|
-
|
|
103
|
-
const pages = import.meta.glob('${t}', { eager: true });
|
|
104
|
-
|
|
105
|
-
function loadPageModule(pagePath) {
|
|
106
|
-
const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
107
|
-
const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
108
|
-
return Promise.resolve(pages[key] || pages[altKey]);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export async function render(url) {
|
|
112
|
-
const { app, router } = await createTypedownApp(loadPageModule, Layout);
|
|
113
|
-
|
|
114
|
-
await router.go(url, { replace: true });
|
|
115
|
-
|
|
116
|
-
const html = await renderToString(app);
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
html,
|
|
120
|
-
pageData: router.route.data,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
`;
|
|
124
|
-
}
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/node/build/index.ts
|
|
127
|
-
async function p(n) {
|
|
128
|
-
let o = r.resolve(n.root), s = r.resolve(o, n.outDir ?? "dist"), c = n.base ?? "/", u = r.join(s, ".client"), p = r.join(s, ".server"), { tdContext: m } = await import("./typedown-context-D78bYNhH.js"), h = (await m.getConfig()).contentDir, g = await i.mkdtemp(r.join(a.tmpdir(), "typerighter-")), _ = {
|
|
129
|
-
contentDir: h,
|
|
130
|
-
layoutImport: n.layoutImport,
|
|
131
|
-
notFoundImport: n.notFoundImport,
|
|
132
|
-
typerighterPackage: "typerighter"
|
|
133
|
-
}, v = r.join(g, "client-entry.js"), y = r.join(g, "ssr-entry.js");
|
|
134
|
-
await i.writeFile(v, d(_)), await i.writeFile(y, f(_)), e.info("Phase 1: Building client bundle..."), await t({
|
|
135
|
-
...n.viteConfig,
|
|
136
|
-
root: o,
|
|
137
|
-
base: c,
|
|
138
|
-
build: {
|
|
139
|
-
...n.viteConfig?.build,
|
|
140
|
-
outDir: u,
|
|
141
|
-
ssrManifest: !0,
|
|
142
|
-
emptyOutDir: !0,
|
|
143
|
-
rollupOptions: {
|
|
144
|
-
...n.viteConfig?.build?.rollupOptions,
|
|
145
|
-
input: v
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}), e.info("Phase 2: Building SSR bundle..."), await t({
|
|
149
|
-
...n.viteConfig,
|
|
150
|
-
root: o,
|
|
151
|
-
base: c,
|
|
152
|
-
build: {
|
|
153
|
-
...n.viteConfig?.build,
|
|
154
|
-
outDir: p,
|
|
155
|
-
ssr: y,
|
|
156
|
-
emptyOutDir: !0
|
|
157
|
-
}
|
|
158
|
-
}), e.info("Phase 3: Pre-rendering pages...");
|
|
159
|
-
let b = (await m.listFiles()).map((e) => {
|
|
160
|
-
let t = e.replace(/\.td$/, "");
|
|
161
|
-
return t === "index" ? "/" : `/${t}`;
|
|
162
|
-
});
|
|
163
|
-
await l({
|
|
164
|
-
ssrEntryPath: r.join(p, "ssr-entry.js"),
|
|
165
|
-
clientOutDir: u,
|
|
166
|
-
outDir: s,
|
|
167
|
-
base: c,
|
|
168
|
-
pagePaths: b
|
|
169
|
-
});
|
|
170
|
-
let x = r.join(u, "assets"), S = r.join(s, "assets");
|
|
171
|
-
await i.cp(x, S, { recursive: !0 }).catch(() => {}), await Promise.all([
|
|
172
|
-
i.rm(g, {
|
|
173
|
-
recursive: !0,
|
|
174
|
-
force: !0
|
|
175
|
-
}),
|
|
176
|
-
i.rm(u, {
|
|
177
|
-
recursive: !0,
|
|
178
|
-
force: !0
|
|
179
|
-
}),
|
|
180
|
-
i.rm(p, {
|
|
181
|
-
recursive: !0,
|
|
182
|
-
force: !0
|
|
183
|
-
})
|
|
184
|
-
]), e.info(`Build complete. Output: ${s}`);
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
export { p as buildSite, o as createViteServer };
|
|
1
|
+
import { t as e } from "./vite-CrIemqE7.js";
|
|
2
|
+
import "./plugin-t6FyO8wM.js";
|
|
3
|
+
import { n as t, t as n } from "./cli-2dHfEihR.js";
|
|
4
|
+
export { t as buildSite, n as cli, e as typedown };
|