typerighter 0.0.0 → 0.1.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.
Potentially problematic release.
This version of typerighter might be problematic. Click here for more details.
- package/LICENSE +674 -0
- package/dist/app-bn8sNpDS.js +180 -0
- package/dist/brand-DSd9HWVy.js +19 -0
- package/dist/chunk-DfAF0w94-EwUSVR-h.js +13 -0
- package/dist/client/app/components/Content.d.ts +4 -0
- package/dist/client/app/components/Content.d.ts.map +1 -0
- package/dist/client/app/composables/useTdContent.d.ts +4 -0
- package/dist/client/app/composables/useTdContent.d.ts.map +1 -0
- package/dist/client/app/composables/useTheme.d.ts +9 -0
- package/dist/client/app/composables/useTheme.d.ts.map +1 -0
- package/dist/client/app/index.d.ts +22 -0
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/app/router.d.ts +24 -0
- package/dist/client/app/router.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/theme-default.js +339 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -4
- package/dist/lib-CBtriEt5-Ch50D04V.js +3309 -0
- package/dist/liteDOM-Cp0aN3bP-YwW1TGWI.js +741 -0
- package/dist/logger-DZLd8EDg.js +78 -0
- package/dist/node/build/codegen.d.ts +13 -0
- package/dist/node/build/codegen.d.ts.map +1 -0
- package/dist/node/build/html.d.ts +20 -0
- package/dist/node/build/html.d.ts.map +1 -0
- package/dist/node/build/index.d.ts +17 -0
- package/dist/node/build/index.d.ts.map +1 -0
- package/dist/node/build/render.d.ts +14 -0
- package/dist/node/build/render.d.ts.map +1 -0
- package/dist/node/cli/index.d.ts +2 -0
- package/dist/node/cli/index.d.ts.map +1 -0
- package/dist/node/cli/server.d.ts +5 -0
- package/dist/node/cli/server.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/lib/index.d.ts +4 -0
- package/dist/node/lib/index.d.ts.map +1 -0
- package/dist/node/lib/logger.d.ts +6 -0
- package/dist/node/lib/logger.d.ts.map +1 -0
- package/dist/node/lib/markdown/index.d.ts +5 -0
- package/dist/node/lib/markdown/index.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/container.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/container.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/highlight.d.ts +2 -0
- package/dist/node/lib/markdown/plugins/highlight.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/image.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/image.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/line-number.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/line-number.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/link.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/link.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts +6 -0
- package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/restore-entities.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/restore-entities.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/table.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/table.d.ts.map +1 -0
- package/dist/node/lib/render/index.d.ts +2 -0
- package/dist/node/lib/render/index.d.ts.map +1 -0
- package/dist/node/lib/render/vue.d.ts +11 -0
- package/dist/node/lib/render/vue.d.ts.map +1 -0
- package/dist/node/lib/typedown-context.d.ts +29 -0
- package/dist/node/lib/typedown-context.d.ts.map +1 -0
- package/dist/node/plugin/codegen.d.ts +16 -0
- package/dist/node/plugin/codegen.d.ts.map +1 -0
- package/dist/node/plugin/codegen.test.d.ts +2 -0
- package/dist/node/plugin/codegen.test.d.ts.map +1 -0
- package/dist/node/plugin/constants.d.ts +4 -0
- package/dist/node/plugin/constants.d.ts.map +1 -0
- package/dist/node/plugin/index.d.ts +2 -0
- package/dist/node/plugin/index.d.ts.map +1 -0
- package/dist/node/plugin/vite.d.ts +3 -0
- package/dist/node/plugin/vite.d.ts.map +1 -0
- package/dist/shared/brand.d.ts +7 -0
- package/dist/shared/brand.d.ts.map +1 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/regexes.d.ts +2 -0
- package/dist/shared/regexes.d.ts.map +1 -0
- package/dist/shared/types/content.d.ts +10 -0
- package/dist/shared/types/content.d.ts.map +1 -0
- package/dist/shared/types/index.d.ts +4 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/shared/types/markdown.d.ts +62 -0
- package/dist/shared/types/markdown.d.ts.map +1 -0
- package/dist/shared/types/ssg.d.ts +23 -0
- package/dist/shared/types/ssg.d.ts.map +1 -0
- package/dist/shared/utils/content.d.ts +6 -0
- package/dist/shared/utils/content.d.ts.map +1 -0
- package/dist/shared/utils/environment.d.ts +2 -0
- package/dist/shared/utils/environment.d.ts.map +1 -0
- package/dist/shared/utils/highlight.d.ts +3 -0
- package/dist/shared/utils/highlight.d.ts.map +1 -0
- package/dist/shared/utils/index.d.ts +5 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/url.d.ts +3 -0
- package/dist/shared/utils/url.d.ts.map +1 -0
- package/dist/shared-DzTfF-_d.js +14 -0
- package/dist/tex-svg-full-BI3fonbT-CfoPQ3xc.js +60224 -0
- package/dist/typedown-context-CWA07Yb7.js +9436 -0
- package/dist/typedown-context-D78bYNhH.js +2 -0
- package/dist/typerighter.css +2 -0
- package/dist/vite.js +174 -0
- package/dist/wgxpath.install-node-Csk64Aj9-C0enUGLs.js +1094 -0
- package/dist/xypic-DrMJn58R-B4fw2rYo.js +14846 -0
- package/package.json +49 -16
- package/dist/client/theme-default/index.d.ts +0 -1
- package/dist/client/theme-default/index.d.ts.map +0 -1
- package/dist/index.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,187 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { t as e } from "./logger-DZLd8EDg.js";
|
|
2
|
+
import { build as t, createServer as n } from "vite";
|
|
3
|
+
import r from "node:path";
|
|
4
|
+
import i from "node:fs/promises";
|
|
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
|
+
});
|
|
4
17
|
}
|
|
5
18
|
//#endregion
|
|
6
|
-
|
|
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 };
|