typerighter 0.1.6 → 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 +4 -5
- package/dist/brand-DSd9HWVy.js +0 -19
- package/dist/cli-CrGQH71K.js +0 -158
- package/dist/html-cZxXrc6x.js +0 -24
- package/dist/plugin-B4GVd-re.js +0 -1
- package/dist/rolldown-runtime-Dqa2HsxW.js +0 -20
- package/dist/typedown-context-uGzfOyIE.js +0 -2
- package/dist/vite-QefJNNFo.js +0 -202
- /package/bin/{typedown.js → typerighter.js} +0 -0
package/dist/vite-QefJNNFo.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./typedown-context-C5kvAxE0.js";
|
|
2
|
-
import "./shared-DzTfF-_d.js";
|
|
3
|
-
import { c as t, r as n } from "./brand-DSd9HWVy.js";
|
|
4
|
-
import { t as r } from "./html-cZxXrc6x.js";
|
|
5
|
-
import i from "@tailwindcss/vite";
|
|
6
|
-
import a from "@vitejs/plugin-vue";
|
|
7
|
-
//#region src/node/lib/render/vue.ts
|
|
8
|
-
async function o(e, n, r) {
|
|
9
|
-
let i = {
|
|
10
|
-
path: r,
|
|
11
|
-
relativePath: r,
|
|
12
|
-
cleanUrls: !0
|
|
13
|
-
}, a = await e.renderAsync(n.content, i), o = i.title || t(n.header, r), s = {
|
|
14
|
-
schema: n.schema,
|
|
15
|
-
frontmatter: n.header,
|
|
16
|
-
headings: i.headers ?? [],
|
|
17
|
-
title: o
|
|
18
|
-
}, c = JSON.stringify(JSON.stringify(s)), l = JSON.stringify(a);
|
|
19
|
-
return {
|
|
20
|
-
vueSrc: [
|
|
21
|
-
"<script>",
|
|
22
|
-
`export const __pageData = JSON.parse(${c})`,
|
|
23
|
-
`export default { name: ${JSON.stringify(r)}, data() { return { __html: ${l} } } }`,
|
|
24
|
-
"<\/script>",
|
|
25
|
-
"<template><div v-html=\"__html\" /></template>"
|
|
26
|
-
].join("\n"),
|
|
27
|
-
pageData: s
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/node/plugin/vite/constants.ts
|
|
32
|
-
var s = "@typedown/app", c = "\0@typedown/app", l = "__typedown_index__.td";
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/node/plugin/vite/codegen.ts
|
|
35
|
-
function u(e) {
|
|
36
|
-
let { contentDir: t, hasIndex: n } = e;
|
|
37
|
-
return `
|
|
38
|
-
import 'typerighter/style.css';
|
|
39
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
40
|
-
import theme from 'typerighter/client/theme-default';
|
|
41
|
-
|
|
42
|
-
const pages = import.meta.glob('${`/${t}/**/*.td`}');
|
|
43
|
-
${n ? "" : `pages['/${t}/${l}'] = () => import('${l}');`}
|
|
44
|
-
|
|
45
|
-
async function loadPageModule(pagePath) {
|
|
46
|
-
const key = '/${t}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
47
|
-
const altKey = '/${t}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
48
|
-
const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${l}'] : undefined)`};
|
|
49
|
-
if (!loader) return undefined;
|
|
50
|
-
return loader();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
|
|
54
|
-
title: e.siteTitle,
|
|
55
|
-
description: e.siteDescription
|
|
56
|
-
})}, ${JSON.stringify({ sidebarGroups: e.sidebarGroups })});
|
|
57
|
-
app.mount('#app');
|
|
58
|
-
`;
|
|
59
|
-
}
|
|
60
|
-
function d(e) {
|
|
61
|
-
let t = JSON.stringify(e).replace(/'/g, "\\'"), n = JSON.stringify({
|
|
62
|
-
schema: "",
|
|
63
|
-
frontmatter: {},
|
|
64
|
-
headings: [],
|
|
65
|
-
title: "Index"
|
|
66
|
-
});
|
|
67
|
-
return `<script>
|
|
68
|
-
import { TdOverview } from 'typerighter/client/theme-default';
|
|
69
|
-
export const __pageData = JSON.parse(${JSON.stringify(n)})
|
|
70
|
-
export default { name: "index", components: { TdOverview } }
|
|
71
|
-
<\/script>
|
|
72
|
-
<template><TdOverview :groups='${t}' /></template>`;
|
|
73
|
-
}
|
|
74
|
-
function f(e) {
|
|
75
|
-
let t = `/${e.contentDir}/**/*.td`;
|
|
76
|
-
return `
|
|
77
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
78
|
-
import { renderToString } from 'vue/server-renderer';
|
|
79
|
-
import theme from '${e.layoutImport}';
|
|
80
|
-
|
|
81
|
-
const pages = import.meta.glob('${t}', { eager: true });
|
|
82
|
-
|
|
83
|
-
function loadPageModule(pagePath) {
|
|
84
|
-
const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
85
|
-
const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
86
|
-
return Promise.resolve(pages[key] || pages[altKey]);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export async function render(url) {
|
|
90
|
-
const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${e.siteConfig}, ${e.siteData});
|
|
91
|
-
await router.go(url, { replace: true });
|
|
92
|
-
const html = await renderToString(app);
|
|
93
|
-
return { html, pageData: router.route.data };
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/node/plugin/vite/index.ts
|
|
99
|
-
function p() {
|
|
100
|
-
let t;
|
|
101
|
-
return [
|
|
102
|
-
{
|
|
103
|
-
name: "vite-plugin-typedown",
|
|
104
|
-
enforce: "pre",
|
|
105
|
-
resolveId(e) {
|
|
106
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return c;
|
|
107
|
-
if (e.endsWith("__typedown_index__.td")) return e;
|
|
108
|
-
},
|
|
109
|
-
async load(t) {
|
|
110
|
-
if (t === "\0@typedown/app") {
|
|
111
|
-
let [t, n, r] = await Promise.all([
|
|
112
|
-
e.getConfig(),
|
|
113
|
-
e.listFiles(),
|
|
114
|
-
e.listFilesGroupedBySchema()
|
|
115
|
-
]), i = n.some((e) => e === "index.td");
|
|
116
|
-
return u({
|
|
117
|
-
...t,
|
|
118
|
-
hasIndex: i,
|
|
119
|
-
sidebarGroups: r
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (t.endsWith("__typedown_index__.td")) return d(await e.listFilesGroupedBySchema());
|
|
123
|
-
},
|
|
124
|
-
configureServer(i) {
|
|
125
|
-
return t = i, e.rpc.onConfigChanged(() => t && h(t)), e.rpc.onContentChanged(({ content: e }) => {
|
|
126
|
-
if (t) {
|
|
127
|
-
for (let n of t.moduleGraph.idToModuleMap.values()) if (n.file?.endsWith(e)) {
|
|
128
|
-
t.moduleGraph.invalidateModule(n), t.hot.send({
|
|
129
|
-
type: "update",
|
|
130
|
-
updates: [{
|
|
131
|
-
type: "js-update",
|
|
132
|
-
path: n.url,
|
|
133
|
-
acceptedPath: n.url,
|
|
134
|
-
timestamp: Date.now()
|
|
135
|
-
}]
|
|
136
|
-
});
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}), e.rpc.onContentCreated(() => t && g(t)), e.rpc.onContentDeleted(() => t && g(t)), e.rpc.onSchemaChanged(() => t && g(t)), e.rpc.onSchemaCreated(() => t && g(t)), e.rpc.onSchemaDeleted(() => t && g(t)), () => {
|
|
141
|
-
i.middlewares.use((t, i, a) => {
|
|
142
|
-
if (!t.url || i.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return a();
|
|
143
|
-
e.getConfig().then((e) => {
|
|
144
|
-
let t = `<!DOCTYPE html>
|
|
145
|
-
<html lang="en">
|
|
146
|
-
<head>
|
|
147
|
-
<meta charset="UTF-8">
|
|
148
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
149
|
-
<title>${r(e.siteTitle)}</title>
|
|
150
|
-
<link rel="icon" type="image/svg+xml" href="${n}">
|
|
151
|
-
</head>
|
|
152
|
-
<body>
|
|
153
|
-
<div id="app"></div>
|
|
154
|
-
<script type="module" src="/${s}"><\/script>
|
|
155
|
-
</body>
|
|
156
|
-
</html>`;
|
|
157
|
-
i.setHeader("Content-Type", "text/html"), i.end(t);
|
|
158
|
-
}).catch(a);
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
},
|
|
162
|
-
async transform(t, n) {
|
|
163
|
-
let r = n.split("?")[0];
|
|
164
|
-
if (!r.endsWith(".td") || r.includes("__typedown_index__.td")) return;
|
|
165
|
-
let i = (await e.getConfig()).contentDir, a = r.includes(i) ? r.slice(r.indexOf(i) + i.length + 1) : r, s = await e.getFile(a), { vueSrc: c } = await o(e.md, s, a);
|
|
166
|
-
return {
|
|
167
|
-
code: c,
|
|
168
|
-
map: null
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
handleHotUpdate({ file: e }) {
|
|
172
|
-
if (e.endsWith(".td")) return [];
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
a({ include: /\.(?:vue|td)$/ }),
|
|
176
|
-
...i()
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
function m(e) {
|
|
180
|
-
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
181
|
-
}
|
|
182
|
-
function h(e) {
|
|
183
|
-
for (let t of m(e)) e.moduleGraph.invalidateModule(t);
|
|
184
|
-
e.hot.send({ type: "full-reload" });
|
|
185
|
-
}
|
|
186
|
-
function g(e) {
|
|
187
|
-
let t = m(e).map((t) => (e.moduleGraph.invalidateModule(t), _(t)));
|
|
188
|
-
0 < t.length && e.hot.send({
|
|
189
|
-
type: "update",
|
|
190
|
-
updates: t
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
function _(e) {
|
|
194
|
-
return {
|
|
195
|
-
type: "js-update",
|
|
196
|
-
path: e.url,
|
|
197
|
-
acceptedPath: e.url,
|
|
198
|
-
timestamp: Date.now()
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
//#endregion
|
|
202
|
-
export { u as n, f as r, p as t };
|
|
File without changes
|