typerighter 0.7.0 → 0.8.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/dist/app-Dn-65wMj.js +373 -0
- package/dist/{es-ClqUVRJn.js → brand-CJDq15GW.js} +2 -2
- package/dist/{cli-CDd4TNg1.js → cli-Doj0ofRb.js} +53 -54
- package/dist/cli.js +1 -1
- package/dist/client/app/index.d.ts +12 -3
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/app/router.d.ts +6 -2
- package/dist/client/app/router.d.ts.map +1 -1
- package/dist/client/theme-default.js +513 -415
- package/dist/client.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-Bfnl0t1B.js → init-cYe8Z2-E.js} +18 -18
- package/dist/shared/utils/field.d.ts +2 -0
- package/dist/shared/utils/field.d.ts.map +1 -0
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/url.d.ts +5 -0
- package/dist/shared/utils/url.d.ts.map +1 -1
- package/dist/shared-BIdsxcZ2.js +265 -0
- package/dist/shared.js +2 -0
- package/dist/typerighter.css +1 -1
- package/dist/{constants-DJbUAb1-.js → vite-CASZdq-i.js} +323 -16
- package/dist/vite.js +1 -1
- package/package.json +7 -3
- package/dist/app-Bf0aLzaG.js +0 -370
- package/dist/brand-BfamszbH.js +0 -12
- package/dist/client/app/composables/useUrl.d.ts +0 -6
- package/dist/client/app/composables/useUrl.d.ts.map +0 -1
- package/dist/shared-CpPZZ8IH.js +0 -196
- package/dist/vite-DnP-_NzR.js +0 -326
package/dist/vite-DnP-_NzR.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-DJbUAb1-.js";
|
|
2
|
-
import { C as o, S as s, a as c, b as l, g as u, h as d, i as f, o as p, s as m, u as h, w as g } from "./shared-CpPZZ8IH.js";
|
|
3
|
-
import { o as _, r as v, s as y } from "./brand-BfamszbH.js";
|
|
4
|
-
import { t as b } from "./es-ClqUVRJn.js";
|
|
5
|
-
import { resolve as x } from "node:path";
|
|
6
|
-
import S from "picocolors";
|
|
7
|
-
import C from "@tailwindcss/vite";
|
|
8
|
-
import w from "@vitejs/plugin-vue";
|
|
9
|
-
import { normalizePath as T } from "vite";
|
|
10
|
-
import { createRequire as E } from "node:module";
|
|
11
|
-
//#region src/node/lib/render/vue.ts
|
|
12
|
-
async function D(e, t, n) {
|
|
13
|
-
let r = {
|
|
14
|
-
path: n,
|
|
15
|
-
relativePath: n,
|
|
16
|
-
cleanUrls: !0
|
|
17
|
-
}, i = await e.md.renderAsync(t.content, r), a = d(n) === s, o = r.title || (a ? p(n, (await e.getConfig()).siteTitle) : m(t.header, n)), c = {
|
|
18
|
-
schema: t.schema,
|
|
19
|
-
frontmatter: t.header,
|
|
20
|
-
headings: r.headers ?? [],
|
|
21
|
-
title: o,
|
|
22
|
-
metadata: t.metadata
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
vueSrc: [
|
|
26
|
-
"<script>",
|
|
27
|
-
`export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(c))})`,
|
|
28
|
-
`export default { name: ${JSON.stringify(n)} }`,
|
|
29
|
-
"<\/script>",
|
|
30
|
-
`<template><div class="typedown-content">\n${O(i)}\n</div></template>`
|
|
31
|
-
].join("\n"),
|
|
32
|
-
pageData: c
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function O(e) {
|
|
36
|
-
return e.replaceAll("{{", "{{");
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/node/plugin/vite/search.ts
|
|
40
|
-
var k = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, A = /(.*)<a.*? href="#(.*?)".*?>.*?<\/a>/i, j = class {
|
|
41
|
-
index;
|
|
42
|
-
pageDocIds = /* @__PURE__ */ new Map();
|
|
43
|
-
constructor() {
|
|
44
|
-
this.index = new b({
|
|
45
|
-
fields: o,
|
|
46
|
-
storeFields: g
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
addAll(e) {
|
|
50
|
-
let t = new Set(e.map((e) => e.id));
|
|
51
|
-
for (let e of this.pageDocIds.keys()) t.has(e) || this.discardPage(e);
|
|
52
|
-
for (let t of e) this.addPage(t);
|
|
53
|
-
}
|
|
54
|
-
addPage(e) {
|
|
55
|
-
this.discardPage(e.id);
|
|
56
|
-
let t = [];
|
|
57
|
-
for (let n of M(e.html)) {
|
|
58
|
-
let r = n.anchor ? `${e.id}#${n.anchor}` : e.id;
|
|
59
|
-
this.index.has(r) && this.index.discard(r), this.index.add({
|
|
60
|
-
id: r,
|
|
61
|
-
text: n.text,
|
|
62
|
-
title: n.titles.at(-1) ?? e.title,
|
|
63
|
-
titles: 1 < n.titles.length ? n.titles.slice(0, -1) : [e.title]
|
|
64
|
-
}), t.push(r);
|
|
65
|
-
}
|
|
66
|
-
this.pageDocIds.set(e.id, t);
|
|
67
|
-
}
|
|
68
|
-
discardPage(e) {
|
|
69
|
-
let t = this.pageDocIds.get(e);
|
|
70
|
-
if (t) {
|
|
71
|
-
for (let e of t) this.index.has(e) && this.index.discard(e);
|
|
72
|
-
this.pageDocIds.delete(e);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
serialize() {
|
|
76
|
-
return JSON.stringify(this.index);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
function* M(e) {
|
|
80
|
-
let t = e.split(k);
|
|
81
|
-
t.shift();
|
|
82
|
-
let n = [];
|
|
83
|
-
for (let e = 0; e < t.length; e += 3) {
|
|
84
|
-
let r = Number.parseInt(t[e]) - 1, i = t[e + 1], a = A.exec(i), o = y(a?.[1] ?? "").trim(), s = a?.[2] ?? "", c = t[e + 2];
|
|
85
|
-
if (!o || !c) continue;
|
|
86
|
-
let l = n.slice(0, r);
|
|
87
|
-
l[r] = o, yield {
|
|
88
|
-
anchor: s,
|
|
89
|
-
titles: l.filter(Boolean),
|
|
90
|
-
text: y(c)
|
|
91
|
-
}, r === 0 ? (n.length = 0, n[0] = o) : n[r] = o;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/node/plugin/vite/alias.ts
|
|
96
|
-
var N = E(import.meta.url);
|
|
97
|
-
function P() {
|
|
98
|
-
return [{
|
|
99
|
-
find: "vue/server-renderer",
|
|
100
|
-
replacement: N.resolve("vue/server-renderer")
|
|
101
|
-
}, {
|
|
102
|
-
find: "vue",
|
|
103
|
-
replacement: N.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
104
|
-
}];
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/node/plugin/vite/index.ts
|
|
108
|
-
function F(e) {
|
|
109
|
-
let { contentDir: t } = e, n = `/${t}/**/*.{td,md}`, i = JSON.stringify({
|
|
110
|
-
title: e.siteTitle,
|
|
111
|
-
description: e.siteDescription,
|
|
112
|
-
basePath: e.basePath ?? "/",
|
|
113
|
-
repo: e.repo
|
|
114
|
-
}), a = c(e.contentTree.children, e.siteTitle), o = JSON.stringify({
|
|
115
|
-
contentTree: e.contentTree,
|
|
116
|
-
schemas: e.schemas ?? {},
|
|
117
|
-
directoryListings: a
|
|
118
|
-
});
|
|
119
|
-
return `
|
|
120
|
-
import 'typerighter/style.css';
|
|
121
|
-
import { createTypedownApp } from 'typerighter/client';
|
|
122
|
-
import { TdDirectoryIndex } from 'typerighter/client/theme-default';
|
|
123
|
-
import { h } from 'vue';
|
|
124
|
-
import theme from 'typerighter/client/theme-default';
|
|
125
|
-
import searchIndex from '${r}';
|
|
126
|
-
|
|
127
|
-
const pages = import.meta.glob('${n}');
|
|
128
|
-
const contentExts = ${JSON.stringify(l)};
|
|
129
|
-
const siteData = { ...${o}, searchIndex };
|
|
130
|
-
|
|
131
|
-
function findPage(base) {
|
|
132
|
-
for (const ext of contentExts) {
|
|
133
|
-
const key = base + ext;
|
|
134
|
-
if (pages[key]) return pages[key];
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async function loadPageModule(pagePath) {
|
|
139
|
-
const base = ('/${t}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
|
|
140
|
-
const loader = findPage(base);
|
|
141
|
-
if (loader) return loader();
|
|
142
|
-
|
|
143
|
-
// Only /xxx/index paths get the directory listing fallback
|
|
144
|
-
if (pagePath.endsWith('/index')) {
|
|
145
|
-
const dirPath = pagePath.slice(0, -'/index'.length) || '/';
|
|
146
|
-
const dir = siteData.directoryListings[dirPath] || siteData.directoryListings[dirPath + '/'];
|
|
147
|
-
if (dir) return {
|
|
148
|
-
default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
|
|
149
|
-
__pageData: { frontmatter: {}, headings: [], title: dir.title },
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const { app, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme.Layout, ${i}, siteData);
|
|
157
|
-
app.mount('#app');
|
|
158
|
-
|
|
159
|
-
// Accept HMR for the search index so it updates without a full reload
|
|
160
|
-
if (import.meta.hot) {
|
|
161
|
-
import.meta.hot.accept('${r}', (m) => {
|
|
162
|
-
if (m) searchIndexRef.value = m.default;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
`;
|
|
166
|
-
}
|
|
167
|
-
function I(r = {}) {
|
|
168
|
-
let o = r.context, s, c = new j(), l;
|
|
169
|
-
function d() {
|
|
170
|
-
if (o === void 0) throw Error("typedown plugin not initialized");
|
|
171
|
-
return o.getTdContext();
|
|
172
|
-
}
|
|
173
|
-
return [
|
|
174
|
-
{
|
|
175
|
-
name: "vite-plugin-typedown",
|
|
176
|
-
enforce: "pre",
|
|
177
|
-
configResolved(e) {
|
|
178
|
-
o ||= n(i(e.root));
|
|
179
|
-
},
|
|
180
|
-
config() {
|
|
181
|
-
return {
|
|
182
|
-
resolve: { alias: P() },
|
|
183
|
-
ssr: { noExternal: ["typerighter"] }
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
async buildStart() {
|
|
187
|
-
let e = await (await d()).checkVault();
|
|
188
|
-
if (0 < e.errorCount || 0 < e.warningCount) for (let t of e.diagnostics) {
|
|
189
|
-
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? S.red("error") : S.yellow("warn");
|
|
190
|
-
console.error(` ${n} ${e} ${t.message} ${S.dim(`(${t.code})`)}`);
|
|
191
|
-
}
|
|
192
|
-
if (!s && 0 < e.errorCount) {
|
|
193
|
-
let t = e.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
194
|
-
this.error(`Vault check failed with ${e.errorCount} error(s):\n${t.join("\n")}`);
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
resolveId(e) {
|
|
198
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return t;
|
|
199
|
-
if (e === "@typedown/search-index") return a;
|
|
200
|
-
},
|
|
201
|
-
async load(e) {
|
|
202
|
-
if (e === "\0@typedown/search-index") return l ||= V(await d(), c), await l, `export default ${JSON.stringify(c.serialize())}`;
|
|
203
|
-
if (e !== "\0@typedown/app") return;
|
|
204
|
-
let t = await d(), [n, r, i] = await Promise.all([
|
|
205
|
-
t.getConfig(),
|
|
206
|
-
t.listFilesGroupedBySchema(),
|
|
207
|
-
t.listSchemas()
|
|
208
|
-
]), a = await Promise.all(i.map(async (e) => [e, (await t.getSchema(e)).properties])), o = Object.fromEntries(a), s = f(Object.values(r).flat());
|
|
209
|
-
return F({
|
|
210
|
-
...n,
|
|
211
|
-
contentTree: s,
|
|
212
|
-
schemas: o
|
|
213
|
-
});
|
|
214
|
-
},
|
|
215
|
-
async configureServer(t) {
|
|
216
|
-
s = t;
|
|
217
|
-
let n = await d();
|
|
218
|
-
n.rpc.onConfigChanged(() => s && z(s)), n.rpc.onContentChanged(({ content: e }) => {
|
|
219
|
-
s && (L(n, e).then((e) => {
|
|
220
|
-
e && s && (c.addPage(e), H(s));
|
|
221
|
-
}).catch(() => {}), n.getConfig().then((t) => {
|
|
222
|
-
if (!s) return;
|
|
223
|
-
let n = T(x(s.config.root, t.contentDir, e)), r = s.moduleGraph.getModulesByFile(n);
|
|
224
|
-
if (!r?.size) return;
|
|
225
|
-
let i = [...r].map((e) => (s?.moduleGraph.invalidateModule(e), U(e)));
|
|
226
|
-
s.hot.send({
|
|
227
|
-
type: "update",
|
|
228
|
-
updates: i
|
|
229
|
-
});
|
|
230
|
-
}).catch(() => {}));
|
|
231
|
-
});
|
|
232
|
-
function r() {
|
|
233
|
-
s && (l = V(n, c), l.then(() => {
|
|
234
|
-
s && H(s);
|
|
235
|
-
}), B(s));
|
|
236
|
-
}
|
|
237
|
-
return n.rpc.onContentCreated(r), n.rpc.onContentDeleted(r), n.rpc.onSchemaChanged(() => s && B(s)), n.rpc.onSchemaCreated(() => s && B(s)), n.rpc.onSchemaDeleted(() => s && B(s)), () => {
|
|
238
|
-
t.middlewares.use((t, r, i) => {
|
|
239
|
-
if (!t.url || r.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return i();
|
|
240
|
-
n.getConfig().then((t) => {
|
|
241
|
-
let n = `<!DOCTYPE html>
|
|
242
|
-
<html lang="en">
|
|
243
|
-
<head>
|
|
244
|
-
<meta charset="UTF-8">
|
|
245
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
246
|
-
<title>${_(t.siteTitle)}</title>
|
|
247
|
-
<link rel="icon" type="image/svg+xml" href="${v}">
|
|
248
|
-
</head>
|
|
249
|
-
<body>
|
|
250
|
-
<div id="app"></div>
|
|
251
|
-
<script type="module" src="/${e}"><\/script>
|
|
252
|
-
</body>
|
|
253
|
-
</html>`;
|
|
254
|
-
r.setHeader("Content-Type", "text/html"), r.end(n);
|
|
255
|
-
}).catch(i);
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
},
|
|
259
|
-
async transform(e, t) {
|
|
260
|
-
let n = t.split("?")[0];
|
|
261
|
-
if (!u(n)) return;
|
|
262
|
-
let r = await d(), i = (await r.getConfig()).contentDir, a = n.includes(i) ? n.slice(n.indexOf(i) + i.length + 1) : n, { vueSrc: o } = await D(r, await r.getFile(a), a);
|
|
263
|
-
return {
|
|
264
|
-
code: o,
|
|
265
|
-
map: null
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
handleHotUpdate({ file: e }) {
|
|
269
|
-
if (u(e)) return [];
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
w({ include: /\.(?:vue|td)$/ }),
|
|
273
|
-
...C()
|
|
274
|
-
];
|
|
275
|
-
}
|
|
276
|
-
async function L(e, t) {
|
|
277
|
-
try {
|
|
278
|
-
let n = await e.getFile(t), r = await e.md.renderAsync(n.content, {
|
|
279
|
-
path: t,
|
|
280
|
-
relativePath: t,
|
|
281
|
-
cleanUrls: !0
|
|
282
|
-
});
|
|
283
|
-
return {
|
|
284
|
-
id: h(t),
|
|
285
|
-
title: m(n.header, t),
|
|
286
|
-
html: r
|
|
287
|
-
};
|
|
288
|
-
} catch {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function R(e) {
|
|
293
|
-
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
294
|
-
}
|
|
295
|
-
function z(e) {
|
|
296
|
-
for (let t of R(e)) e.moduleGraph.invalidateModule(t);
|
|
297
|
-
e.hot.send({ type: "full-reload" });
|
|
298
|
-
}
|
|
299
|
-
function B(e) {
|
|
300
|
-
let t = R(e).map((t) => (e.moduleGraph.invalidateModule(t), U(t)));
|
|
301
|
-
0 < t.length && e.hot.send({
|
|
302
|
-
type: "update",
|
|
303
|
-
updates: t
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
async function V(e, t) {
|
|
307
|
-
let n = await e.listFiles(), r = await Promise.all(n.map((t) => L(e, t)));
|
|
308
|
-
t.addAll(r.filter((e) => e !== void 0));
|
|
309
|
-
}
|
|
310
|
-
function H(e) {
|
|
311
|
-
let t = e.moduleGraph.getModuleById(a);
|
|
312
|
-
t && (e.moduleGraph.invalidateModule(t), e.hot.send({
|
|
313
|
-
type: "update",
|
|
314
|
-
updates: [U(t)]
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
function U(e) {
|
|
318
|
-
return {
|
|
319
|
-
type: "js-update",
|
|
320
|
-
path: e.url,
|
|
321
|
-
acceptedPath: e.url,
|
|
322
|
-
timestamp: Date.now()
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
//#endregion
|
|
326
|
-
export { I as n, F as t };
|