typerighter 0.5.1 → 0.7.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-Bf0aLzaG.js +370 -0
- package/dist/brand-BfamszbH.js +12 -0
- package/dist/{cli-CAvgSpyx.js → cli-CDd4TNg1.js} +22 -17
- package/dist/cli.js +1 -1
- package/dist/client/app/composables/useUrl.d.ts +6 -0
- package/dist/client/app/composables/useUrl.d.ts.map +1 -0
- package/dist/client/app/index.d.ts +8 -1
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/theme-default.js +655 -427
- package/dist/client.js +1 -1
- package/dist/{constants-BVW9e5iH.js → constants-DJbUAb1-.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-Dfj-Yf9i.js → init-Bfnl0t1B.js} +4 -3
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts +4 -0
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/shared/utils/content.d.ts.map +1 -1
- package/dist/shared/utils/url.d.ts +2 -1
- package/dist/shared/utils/url.d.ts.map +1 -1
- package/dist/{brand-C6VJ3Tpf.js → shared-CpPZZ8IH.js} +62 -65
- package/dist/typerighter.css +1 -1
- package/dist/{vite-DPRlAukM.js → vite-DnP-_NzR.js} +46 -41
- package/dist/vite.js +1 -1
- package/package.json +3 -3
- package/dist/app-DZLkaV9-.js +0 -266
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-
|
|
2
|
-
import {
|
|
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";
|
|
3
4
|
import { t as b } from "./es-ClqUVRJn.js";
|
|
4
5
|
import { resolve as x } from "node:path";
|
|
5
6
|
import S from "picocolors";
|
|
@@ -13,7 +14,7 @@ async function D(e, t, n) {
|
|
|
13
14
|
path: n,
|
|
14
15
|
relativePath: n,
|
|
15
16
|
cleanUrls: !0
|
|
16
|
-
}, i = await e.md.renderAsync(t.content, r), a =
|
|
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 = {
|
|
17
18
|
schema: t.schema,
|
|
18
19
|
frontmatter: t.header,
|
|
19
20
|
headings: r.headers ?? [],
|
|
@@ -23,12 +24,12 @@ async function D(e, t, n) {
|
|
|
23
24
|
return {
|
|
24
25
|
vueSrc: [
|
|
25
26
|
"<script>",
|
|
26
|
-
`export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(
|
|
27
|
+
`export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(c))})`,
|
|
27
28
|
`export default { name: ${JSON.stringify(n)} }`,
|
|
28
29
|
"<\/script>",
|
|
29
30
|
`<template><div class="typedown-content">\n${O(i)}\n</div></template>`
|
|
30
31
|
].join("\n"),
|
|
31
|
-
pageData:
|
|
32
|
+
pageData: c
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
function O(e) {
|
|
@@ -41,8 +42,8 @@ var k = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, A = /(.*)<a.*?
|
|
|
41
42
|
pageDocIds = /* @__PURE__ */ new Map();
|
|
42
43
|
constructor() {
|
|
43
44
|
this.index = new b({
|
|
44
|
-
fields:
|
|
45
|
-
storeFields:
|
|
45
|
+
fields: o,
|
|
46
|
+
storeFields: g
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
addAll(e) {
|
|
@@ -80,13 +81,13 @@ function* M(e) {
|
|
|
80
81
|
t.shift();
|
|
81
82
|
let n = [];
|
|
82
83
|
for (let e = 0; e < t.length; e += 3) {
|
|
83
|
-
let r = Number.parseInt(t[e]) - 1, i = t[e + 1], a = A.exec(i), o =
|
|
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];
|
|
84
85
|
if (!o || !c) continue;
|
|
85
86
|
let l = n.slice(0, r);
|
|
86
87
|
l[r] = o, yield {
|
|
87
88
|
anchor: s,
|
|
88
89
|
titles: l.filter(Boolean),
|
|
89
|
-
text:
|
|
90
|
+
text: y(c)
|
|
90
91
|
}, r === 0 ? (n.length = 0, n[0] = o) : n[r] = o;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -107,11 +108,14 @@ function P() {
|
|
|
107
108
|
function F(e) {
|
|
108
109
|
let { contentDir: t } = e, n = `/${t}/**/*.{td,md}`, i = JSON.stringify({
|
|
109
110
|
title: e.siteTitle,
|
|
110
|
-
description: e.siteDescription
|
|
111
|
-
|
|
111
|
+
description: e.siteDescription,
|
|
112
|
+
basePath: e.basePath ?? "/",
|
|
113
|
+
repo: e.repo
|
|
114
|
+
}), a = c(e.contentTree.children, e.siteTitle), o = JSON.stringify({
|
|
112
115
|
contentTree: e.contentTree,
|
|
113
|
-
schemas: e.schemas ?? {}
|
|
114
|
-
|
|
116
|
+
schemas: e.schemas ?? {},
|
|
117
|
+
directoryListings: a
|
|
118
|
+
});
|
|
115
119
|
return `
|
|
116
120
|
import 'typerighter/style.css';
|
|
117
121
|
import { createTypedownApp } from 'typerighter/client';
|
|
@@ -121,16 +125,13 @@ import theme from 'typerighter/client/theme-default';
|
|
|
121
125
|
import searchIndex from '${r}';
|
|
122
126
|
|
|
123
127
|
const pages = import.meta.glob('${n}');
|
|
124
|
-
const contentExts = ${JSON.stringify(
|
|
125
|
-
|
|
126
|
-
const directoryIndex = ${JSON.stringify(o)};
|
|
128
|
+
const contentExts = ${JSON.stringify(l)};
|
|
129
|
+
const siteData = { ...${o}, searchIndex };
|
|
127
130
|
|
|
128
131
|
function findPage(base) {
|
|
129
132
|
for (const ext of contentExts) {
|
|
130
133
|
const key = base + ext;
|
|
131
134
|
if (pages[key]) return pages[key];
|
|
132
|
-
const indexKey = base + '/index' + ext;
|
|
133
|
-
if (pages[indexKey]) return pages[indexKey];
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -139,16 +140,20 @@ async function loadPageModule(pagePath) {
|
|
|
139
140
|
const loader = findPage(base);
|
|
140
141
|
if (loader) return loader();
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
+
}
|
|
147
152
|
|
|
148
153
|
return undefined;
|
|
149
154
|
}
|
|
150
155
|
|
|
151
|
-
const { app, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme.Layout, ${i},
|
|
156
|
+
const { app, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme.Layout, ${i}, siteData);
|
|
152
157
|
app.mount('#app');
|
|
153
158
|
|
|
154
159
|
// Accept HMR for the search index so it updates without a full reload
|
|
@@ -160,8 +165,8 @@ if (import.meta.hot) {
|
|
|
160
165
|
`;
|
|
161
166
|
}
|
|
162
167
|
function I(r = {}) {
|
|
163
|
-
let o = r.context, s, c = new j(),
|
|
164
|
-
function
|
|
168
|
+
let o = r.context, s, c = new j(), l;
|
|
169
|
+
function d() {
|
|
165
170
|
if (o === void 0) throw Error("typedown plugin not initialized");
|
|
166
171
|
return o.getTdContext();
|
|
167
172
|
}
|
|
@@ -179,12 +184,12 @@ function I(r = {}) {
|
|
|
179
184
|
};
|
|
180
185
|
},
|
|
181
186
|
async buildStart() {
|
|
182
|
-
let e = await (await
|
|
183
|
-
if (e.errorCount
|
|
187
|
+
let e = await (await d()).checkVault();
|
|
188
|
+
if (0 < e.errorCount || 0 < e.warningCount) for (let t of e.diagnostics) {
|
|
184
189
|
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? S.red("error") : S.yellow("warn");
|
|
185
190
|
console.error(` ${n} ${e} ${t.message} ${S.dim(`(${t.code})`)}`);
|
|
186
191
|
}
|
|
187
|
-
if (!s && e.errorCount
|
|
192
|
+
if (!s && 0 < e.errorCount) {
|
|
188
193
|
let t = e.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
189
194
|
this.error(`Vault check failed with ${e.errorCount} error(s):\n${t.join("\n")}`);
|
|
190
195
|
}
|
|
@@ -194,13 +199,13 @@ function I(r = {}) {
|
|
|
194
199
|
if (e === "@typedown/search-index") return a;
|
|
195
200
|
},
|
|
196
201
|
async load(e) {
|
|
197
|
-
if (e === "\0@typedown/search-index") return
|
|
202
|
+
if (e === "\0@typedown/search-index") return l ||= V(await d(), c), await l, `export default ${JSON.stringify(c.serialize())}`;
|
|
198
203
|
if (e !== "\0@typedown/app") return;
|
|
199
|
-
let t = await
|
|
204
|
+
let t = await d(), [n, r, i] = await Promise.all([
|
|
200
205
|
t.getConfig(),
|
|
201
206
|
t.listFilesGroupedBySchema(),
|
|
202
207
|
t.listSchemas()
|
|
203
|
-
]), a = await Promise.all(i.map(async (e) => [e, (await t.getSchema(e)).properties])), o = Object.fromEntries(a), s =
|
|
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());
|
|
204
209
|
return F({
|
|
205
210
|
...n,
|
|
206
211
|
contentTree: s,
|
|
@@ -209,7 +214,7 @@ function I(r = {}) {
|
|
|
209
214
|
},
|
|
210
215
|
async configureServer(t) {
|
|
211
216
|
s = t;
|
|
212
|
-
let n = await
|
|
217
|
+
let n = await d();
|
|
213
218
|
n.rpc.onConfigChanged(() => s && z(s)), n.rpc.onContentChanged(({ content: e }) => {
|
|
214
219
|
s && (L(n, e).then((e) => {
|
|
215
220
|
e && s && (c.addPage(e), H(s));
|
|
@@ -225,7 +230,7 @@ function I(r = {}) {
|
|
|
225
230
|
}).catch(() => {}));
|
|
226
231
|
});
|
|
227
232
|
function r() {
|
|
228
|
-
s && (
|
|
233
|
+
s && (l = V(n, c), l.then(() => {
|
|
229
234
|
s && H(s);
|
|
230
235
|
}), B(s));
|
|
231
236
|
}
|
|
@@ -238,8 +243,8 @@ function I(r = {}) {
|
|
|
238
243
|
<head>
|
|
239
244
|
<meta charset="UTF-8">
|
|
240
245
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
241
|
-
<title>${
|
|
242
|
-
<link rel="icon" type="image/svg+xml" href="${
|
|
246
|
+
<title>${_(t.siteTitle)}</title>
|
|
247
|
+
<link rel="icon" type="image/svg+xml" href="${v}">
|
|
243
248
|
</head>
|
|
244
249
|
<body>
|
|
245
250
|
<div id="app"></div>
|
|
@@ -253,15 +258,15 @@ function I(r = {}) {
|
|
|
253
258
|
},
|
|
254
259
|
async transform(e, t) {
|
|
255
260
|
let n = t.split("?")[0];
|
|
256
|
-
if (!
|
|
257
|
-
let r = await
|
|
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);
|
|
258
263
|
return {
|
|
259
264
|
code: o,
|
|
260
265
|
map: null
|
|
261
266
|
};
|
|
262
267
|
},
|
|
263
268
|
handleHotUpdate({ file: e }) {
|
|
264
|
-
if (
|
|
269
|
+
if (u(e)) return [];
|
|
265
270
|
}
|
|
266
271
|
},
|
|
267
272
|
w({ include: /\.(?:vue|td)$/ }),
|
|
@@ -276,8 +281,8 @@ async function L(e, t) {
|
|
|
276
281
|
cleanUrls: !0
|
|
277
282
|
});
|
|
278
283
|
return {
|
|
279
|
-
id:
|
|
280
|
-
title:
|
|
284
|
+
id: h(t),
|
|
285
|
+
title: m(n.header, t),
|
|
281
286
|
html: r
|
|
282
287
|
};
|
|
283
288
|
} catch {
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./vite-
|
|
1
|
+
import { n as e, t } from "./vite-DnP-_NzR.js";
|
|
2
2
|
export { t as generateClientAppEntry, 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.7.0",
|
|
5
5
|
"description": "Typedown: A typed content framework.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"tailwindcss": "^4.3.3",
|
|
82
82
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
83
83
|
"vue": "^3.0.0",
|
|
84
|
-
"@typerighter/rpc-client": "0.
|
|
85
|
-
"@typerighter/rpc-server": "0.
|
|
84
|
+
"@typerighter/rpc-client": "0.7.0",
|
|
85
|
+
"@typerighter/rpc-server": "0.7.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@hdnax/nuclint": "^0.17.4",
|
package/dist/app-DZLkaV9-.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { computed as e, createApp as t, createElementBlock as n, createElementVNode as r, defineComponent as i, h as a, inject as o, markRaw as s, mergeProps as c, nextTick as l, openBlock as u, provide as d, reactive as f, readonly as p, ref as m, renderSlot as h, shallowRef as g, toDisplayString as _, watch as v, withKeys as y, withModifiers as b } from "vue";
|
|
2
|
-
//#region src/client/theme-default/components/custom/TdFlashcard.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
-
var x = [
|
|
4
|
-
"id",
|
|
5
|
-
"tabindex",
|
|
6
|
-
"aria-pressed",
|
|
7
|
-
"aria-label",
|
|
8
|
-
"onKeydown"
|
|
9
|
-
], ee = { class: "flashcard__face flashcard__face--question" }, S = { class: "flashcard__label" }, C = { class: "flashcard__body" }, w = { class: "flashcard__face flashcard__face--key" }, T = { class: "flashcard__label" }, E = { class: "flashcard__body" }, te = /*@__PURE__*/ i({
|
|
10
|
-
inheritAttrs: !1,
|
|
11
|
-
__name: "TdFlashcard",
|
|
12
|
-
props: {
|
|
13
|
-
id: { default: () => void 0 },
|
|
14
|
-
revealed: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: !1
|
|
17
|
-
},
|
|
18
|
-
disabled: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
default: !1
|
|
21
|
-
},
|
|
22
|
-
questionLabel: { default: "Question" },
|
|
23
|
-
keyLabel: { default: "Answer" }
|
|
24
|
-
},
|
|
25
|
-
setup(e, { expose: t }) {
|
|
26
|
-
let i = m(e.revealed);
|
|
27
|
-
v(() => e.revealed, () => {
|
|
28
|
-
i.value = e.revealed;
|
|
29
|
-
});
|
|
30
|
-
function a() {
|
|
31
|
-
if (e.disabled) return i.value;
|
|
32
|
-
let t = i.value;
|
|
33
|
-
return i.value = !i.value, t;
|
|
34
|
-
}
|
|
35
|
-
function o() {
|
|
36
|
-
let e = i.value;
|
|
37
|
-
return i.value = !0, e;
|
|
38
|
-
}
|
|
39
|
-
function s() {
|
|
40
|
-
let e = i.value;
|
|
41
|
-
return i.value = !1, e;
|
|
42
|
-
}
|
|
43
|
-
return t({
|
|
44
|
-
flip: a,
|
|
45
|
-
showQuestion: s,
|
|
46
|
-
showKey: o,
|
|
47
|
-
state: p(i)
|
|
48
|
-
}), (t, o) => (u(), n("div", c(t.$attrs, {
|
|
49
|
-
id: e.id,
|
|
50
|
-
class: ["flashcard", {
|
|
51
|
-
"is-revealed": i.value,
|
|
52
|
-
"is-disabled": e.disabled
|
|
53
|
-
}],
|
|
54
|
-
role: "button",
|
|
55
|
-
tabindex: e.disabled ? -1 : 0,
|
|
56
|
-
"aria-pressed": i.value,
|
|
57
|
-
"aria-label": i.value ? e.keyLabel : e.questionLabel,
|
|
58
|
-
onClick: a,
|
|
59
|
-
onKeydown: [y(b(a, ["prevent"]), ["enter"]), y(b(a, ["prevent"]), ["space"])]
|
|
60
|
-
}), [r("div", ee, [r("p", S, _(e.questionLabel), 1), r("div", C, [h(t.$slots, "default")])]), r("div", w, [r("p", T, _(e.keyLabel), 1), r("div", E, [h(t.$slots, "key")])])], 16, x));
|
|
61
|
-
}
|
|
62
|
-
}), D = (e, t) => {
|
|
63
|
-
let n = e.__vccOpts || e;
|
|
64
|
-
for (let [e, r] of t) n[e] = r;
|
|
65
|
-
return n;
|
|
66
|
-
}, O = /*#__PURE__*/ D(te, [["__scopeId", "data-v-120343d9"]]), k = typeof window < "u", A = Symbol("typedown-router"), j = {
|
|
67
|
-
frontmatter: {},
|
|
68
|
-
headings: [],
|
|
69
|
-
title: "Not Found"
|
|
70
|
-
};
|
|
71
|
-
function M(e, t) {
|
|
72
|
-
let n = f({
|
|
73
|
-
path: "/",
|
|
74
|
-
hash: "",
|
|
75
|
-
query: "",
|
|
76
|
-
contentSfc: void 0,
|
|
77
|
-
data: j
|
|
78
|
-
}), r = {
|
|
79
|
-
route: n,
|
|
80
|
-
async go(e, t) {
|
|
81
|
-
e = L(e), await r.onBeforeRouteChange?.(e) !== !1 && ((!k || t?.initialLoad || I(e, t)) && await a(e), o(), await r.onAfterRouteChange?.(e));
|
|
82
|
-
}
|
|
83
|
-
}, i;
|
|
84
|
-
async function a(r) {
|
|
85
|
-
let a = new URL(r, "http://a.com"), c = i = a.pathname;
|
|
86
|
-
try {
|
|
87
|
-
let t = await e(c);
|
|
88
|
-
if (!t) throw Error(`Page not found: ${c}`);
|
|
89
|
-
if (i === c) {
|
|
90
|
-
i = void 0;
|
|
91
|
-
let { default: e, __pageData: r } = t;
|
|
92
|
-
n.path = c, n.contentSfc = s(e), n.data = s(r), o(a), k && l(() => {
|
|
93
|
-
N(a.hash);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
} catch {
|
|
97
|
-
i === c && (i = void 0, n.path = c, n.contentSfc = t ? s(t) : void 0, n.data = j, o(a));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function o(e = k ? location : {
|
|
101
|
-
search: "",
|
|
102
|
-
hash: ""
|
|
103
|
-
}) {
|
|
104
|
-
n.query = e.search, n.hash = decodeURIComponent(e.hash);
|
|
105
|
-
}
|
|
106
|
-
return k && (history.state ?? history.replaceState({}, ""), window.addEventListener("click", (e) => {
|
|
107
|
-
if (e.defaultPrevented || !(e.target instanceof Element) || e.button !== 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return;
|
|
108
|
-
let t = e.target.closest("a");
|
|
109
|
-
if (!t || t.hasAttribute("download") || t.hasAttribute("target")) return;
|
|
110
|
-
let n = t.getAttribute("href");
|
|
111
|
-
if (n === null) return;
|
|
112
|
-
let { href: i, origin: a, pathname: o } = new URL(n, t.baseURI);
|
|
113
|
-
a === location.origin && !o.match(/\.\w+$/) && (e.preventDefault(), r.go(i));
|
|
114
|
-
}, { capture: !0 }), window.addEventListener("popstate", async (e) => {
|
|
115
|
-
if (e.state == null) return;
|
|
116
|
-
let t = L(location.href);
|
|
117
|
-
await a(t), o(), await r.onAfterRouteChange?.(t);
|
|
118
|
-
}), window.addEventListener("hashchange", (e) => {
|
|
119
|
-
e.preventDefault(), o();
|
|
120
|
-
})), r;
|
|
121
|
-
}
|
|
122
|
-
function N(e) {
|
|
123
|
-
if (!e) return;
|
|
124
|
-
let t;
|
|
125
|
-
try {
|
|
126
|
-
t = document.getElementById(decodeURIComponent(e).slice(1)) ?? void 0;
|
|
127
|
-
} catch {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
t?.scrollIntoView({ block: "start" });
|
|
131
|
-
}
|
|
132
|
-
function P() {
|
|
133
|
-
return F().route;
|
|
134
|
-
}
|
|
135
|
-
function F() {
|
|
136
|
-
let e = o(A);
|
|
137
|
-
if (!e) throw Error("useRouter() called outside of Typedown app");
|
|
138
|
-
return e;
|
|
139
|
-
}
|
|
140
|
-
function I(e, { replace: t = !1 } = {}) {
|
|
141
|
-
let n = L(location.href);
|
|
142
|
-
if (e === n) return N(new URL(e, "http://a.com").hash), !1;
|
|
143
|
-
t ? history.replaceState({}, "", e) : (history.replaceState({ scrollPosition: window.scrollY }, ""), history.pushState({}, "", e));
|
|
144
|
-
let r = new URL(e, location.origin), i = new URL(n, location.origin);
|
|
145
|
-
return r.pathname === i.pathname ? (N(r.hash), !1) : !0;
|
|
146
|
-
}
|
|
147
|
-
function L(e) {
|
|
148
|
-
let t = new URL(e, "http://a.com");
|
|
149
|
-
return t.pathname = t.pathname.replace(/\.html$/, ""), t.pathname + t.search + t.hash;
|
|
150
|
-
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/client/app/components/Content.ts
|
|
153
|
-
var R = i({
|
|
154
|
-
name: "TypedownContent",
|
|
155
|
-
setup() {
|
|
156
|
-
let e = P();
|
|
157
|
-
return () => e.contentSfc ? a(e.contentSfc) : void 0;
|
|
158
|
-
}
|
|
159
|
-
}), z = "td-theme";
|
|
160
|
-
function B(e) {
|
|
161
|
-
if (typeof document > "u") return;
|
|
162
|
-
let t = e === "system" ? V() : e;
|
|
163
|
-
document.documentElement.classList.toggle("dark", t === "dark");
|
|
164
|
-
}
|
|
165
|
-
function V() {
|
|
166
|
-
return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
167
|
-
}
|
|
168
|
-
var H = m("system"), U = m(V()), W = !1;
|
|
169
|
-
function G() {
|
|
170
|
-
K();
|
|
171
|
-
let t = e(() => H.value === "system" ? U.value : H.value), n = e(() => t.value === "dark");
|
|
172
|
-
function r(e) {
|
|
173
|
-
H.value = e, B(e), typeof localStorage < "u" && localStorage.setItem(z, e);
|
|
174
|
-
}
|
|
175
|
-
function i() {
|
|
176
|
-
r(t.value === "light" ? "dark" : "light");
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
theme: p(H),
|
|
180
|
-
effectiveTheme: t,
|
|
181
|
-
isDark: n,
|
|
182
|
-
setTheme: r,
|
|
183
|
-
toggle: i
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function K() {
|
|
187
|
-
if (!W) {
|
|
188
|
-
if (W = !0, typeof localStorage < "u") {
|
|
189
|
-
let e = localStorage.getItem(z);
|
|
190
|
-
(e === "light" || e === "dark" || e === "system") && (H.value = e);
|
|
191
|
-
}
|
|
192
|
-
B(H.value), typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
|
|
193
|
-
U.value = V(), H.value === "system" && B("system");
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/client/app/composables/useTdContent.ts
|
|
199
|
-
var q = Symbol("td-content");
|
|
200
|
-
function J(t) {
|
|
201
|
-
let n = G(), r = {
|
|
202
|
-
page: e(() => t.data),
|
|
203
|
-
frontmatter: e(() => t.data.frontmatter),
|
|
204
|
-
title: e(() => t.data.title),
|
|
205
|
-
isDark: e(() => n.isDark.value)
|
|
206
|
-
};
|
|
207
|
-
return d(q, r), r;
|
|
208
|
-
}
|
|
209
|
-
function Y() {
|
|
210
|
-
let e = o(q);
|
|
211
|
-
if (e === void 0) throw Error("useTdContent() called without a parent provideTdContent()");
|
|
212
|
-
return e;
|
|
213
|
-
}
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region src/client/app/index.ts
|
|
216
|
-
var X = Symbol("typedown-site-config"), Z = Symbol("typedown-site-data"), Q = Symbol("typedown-page-loader"), $ = Symbol("typedown-search-index");
|
|
217
|
-
async function ne(e, n, r = {}, o = {}) {
|
|
218
|
-
let s = {
|
|
219
|
-
title: r.title ?? "",
|
|
220
|
-
description: r.description ?? ""
|
|
221
|
-
}, c = {
|
|
222
|
-
contentTree: o.contentTree ?? {
|
|
223
|
-
rootItems: [],
|
|
224
|
-
children: []
|
|
225
|
-
},
|
|
226
|
-
schemas: o.schemas ?? {}
|
|
227
|
-
}, l = M(e), u = t(i({
|
|
228
|
-
name: "TypedownApp",
|
|
229
|
-
setup() {
|
|
230
|
-
return J(l.route), () => a(n);
|
|
231
|
-
}
|
|
232
|
-
}));
|
|
233
|
-
u.provide(A, l), u.provide(X, s), u.provide(Z, c), u.provide(Q, e);
|
|
234
|
-
let d = g(o.searchIndex);
|
|
235
|
-
return u.provide($, d), u.component("TypedownContent", R), u.component("Flashcard", O), typeof window < "u" && await l.go(location.href, {
|
|
236
|
-
replace: !0,
|
|
237
|
-
initialLoad: !0
|
|
238
|
-
}), {
|
|
239
|
-
app: u,
|
|
240
|
-
router: l,
|
|
241
|
-
searchIndex: d
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
function re() {
|
|
245
|
-
return o(Q, void 0);
|
|
246
|
-
}
|
|
247
|
-
function ie() {
|
|
248
|
-
return o($, g(void 0));
|
|
249
|
-
}
|
|
250
|
-
function ae() {
|
|
251
|
-
return o(X, {
|
|
252
|
-
title: "",
|
|
253
|
-
description: ""
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
function oe() {
|
|
257
|
-
return o(Z, {
|
|
258
|
-
contentTree: {
|
|
259
|
-
rootItems: [],
|
|
260
|
-
children: []
|
|
261
|
-
},
|
|
262
|
-
schemas: {}
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
//#endregion
|
|
266
|
-
export { oe as a, R as c, D as d, ae as i, P as l, re as n, Y as o, ie as r, G as s, ne as t, F as u };
|