typerighter 0.48.2 → 0.49.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/{cli-Buzmo77S.js → cli-B8atPbzb.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/theme-default.js +384 -318
- package/dist/index.js +2 -2
- package/dist/{init-BGjN-_Rb.js → init-wSHpq5lP.js} +1 -1
- package/dist/node/lib/render/highlight/index.d.ts +1 -1
- package/dist/node/lib/render/highlight/index.d.ts.map +1 -1
- package/dist/node/lib/render/postprocess.d.ts.map +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/{vite-BDEPUy7V.js → vite-1F0Ui0Iu.js} +209 -137
- package/dist/vite.js +1 -1
- package/package.json +3 -3
|
@@ -449,7 +449,7 @@ async function Ue(e, t = {}) {
|
|
|
449
449
|
N.writeFile(E, O)
|
|
450
450
|
]);
|
|
451
451
|
try {
|
|
452
|
-
let s =
|
|
452
|
+
let s = Sn({ context: e }), m = e.createViteLogger(), h = new R(r, "Building client bundle...");
|
|
453
453
|
await fe({
|
|
454
454
|
...t.viteConfig,
|
|
455
455
|
root: n,
|
|
@@ -878,11 +878,11 @@ async function _t() {
|
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
], n = new Set(e.getLoadedLanguages());
|
|
881
|
-
async function r(r, i, a) {
|
|
882
|
-
let
|
|
883
|
-
if (
|
|
881
|
+
async function r(r, i, a, o) {
|
|
882
|
+
let s = ht(i);
|
|
883
|
+
if (s) {
|
|
884
884
|
let e = i;
|
|
885
|
-
i =
|
|
885
|
+
i = s.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
886
886
|
}
|
|
887
887
|
i ||= "txt";
|
|
888
888
|
try {
|
|
@@ -891,22 +891,29 @@ async function _t() {
|
|
|
891
891
|
ae.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
892
892
|
}
|
|
893
893
|
r = r.trimEnd();
|
|
894
|
-
let
|
|
895
|
-
return await e.loadLanguage(...
|
|
894
|
+
let c = Ee(r, i, e);
|
|
895
|
+
return await e.loadLanguage(...c), e.codeToHtml(r, {
|
|
896
896
|
lang: i,
|
|
897
|
-
transformers: [
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
tagName
|
|
904
|
-
|
|
905
|
-
|
|
897
|
+
transformers: [
|
|
898
|
+
...t,
|
|
899
|
+
{
|
|
900
|
+
name: "typedown:empty-line",
|
|
901
|
+
code(e) {
|
|
902
|
+
e.children.forEach((e) => {
|
|
903
|
+
e.type === "element" && e.tagName === "span" && Array.isArray(e.properties.class) && e.properties.class.includes("line") && e.children.length === 0 && e.children.push(o === void 0 ? {
|
|
904
|
+
type: "element",
|
|
905
|
+
tagName: "wbr",
|
|
906
|
+
properties: {},
|
|
907
|
+
children: []
|
|
908
|
+
} : {
|
|
909
|
+
type: "text",
|
|
910
|
+
value: " "
|
|
911
|
+
});
|
|
906
912
|
});
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
...o === void 0 ? [] : [yt(o)]
|
|
916
|
+
],
|
|
910
917
|
meta: { __raw: a },
|
|
911
918
|
themes: V,
|
|
912
919
|
defaultColor: !1,
|
|
@@ -947,25 +954,56 @@ function vt() {
|
|
|
947
954
|
}
|
|
948
955
|
};
|
|
949
956
|
}
|
|
957
|
+
function yt(e) {
|
|
958
|
+
return {
|
|
959
|
+
name: "typedown:line-numbers",
|
|
960
|
+
code(t) {
|
|
961
|
+
let n = 0;
|
|
962
|
+
t.children = t.children.filter((e) => e.type === "element").map((t) => {
|
|
963
|
+
if (t.tagName !== "span") return t;
|
|
964
|
+
let r = e + n++;
|
|
965
|
+
return {
|
|
966
|
+
type: "element",
|
|
967
|
+
tagName: "div",
|
|
968
|
+
properties: { class: ["td-code-row", ...(Array.isArray(t.properties.class) ? t.properties.class : []).filter((e) => e !== "line")] },
|
|
969
|
+
children: [{
|
|
970
|
+
type: "element",
|
|
971
|
+
tagName: "span",
|
|
972
|
+
properties: { class: ["td-code-num"] },
|
|
973
|
+
children: [{
|
|
974
|
+
type: "text",
|
|
975
|
+
value: String(r)
|
|
976
|
+
}]
|
|
977
|
+
}, {
|
|
978
|
+
type: "element",
|
|
979
|
+
tagName: "span",
|
|
980
|
+
properties: { class: ["td-code-col"] },
|
|
981
|
+
children: t.children
|
|
982
|
+
}]
|
|
983
|
+
};
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
}
|
|
950
988
|
//#endregion
|
|
951
989
|
//#region src/node/lib/render/postprocess.ts
|
|
952
|
-
var
|
|
953
|
-
async function
|
|
954
|
-
return e = await
|
|
990
|
+
var bt;
|
|
991
|
+
async function xt(e) {
|
|
992
|
+
return e = await wt(e), e = At(e), e;
|
|
955
993
|
}
|
|
956
|
-
function
|
|
957
|
-
return
|
|
994
|
+
function St() {
|
|
995
|
+
return bt ||= _t(), bt;
|
|
958
996
|
}
|
|
959
|
-
var
|
|
997
|
+
var Ct = /<pre class="td-code-placeholder"([^>]*)><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
960
998
|
function H(e, t) {
|
|
961
999
|
return e.match(RegExp(`${t}="([^"]*)"`))?.[1];
|
|
962
1000
|
}
|
|
963
|
-
async function
|
|
964
|
-
let t = await
|
|
1001
|
+
async function wt(e) {
|
|
1002
|
+
let t = await St(), n = [...e.matchAll(Ct)];
|
|
965
1003
|
if (n.length === 0) return e;
|
|
966
1004
|
let r = await Promise.all(n.map(async (e) => {
|
|
967
1005
|
let n = e[1], r = H(n, "data-lang") ?? "", i = H(n, "data-meta") ?? "", a = H(n, "data-title"), o = H(n, "data-line-numbers"), s = h(e[2]);
|
|
968
|
-
return
|
|
1006
|
+
return Dt(await t(s, r, i, o === void 0 ? void 0 : parseInt(o) || 1), r, {
|
|
969
1007
|
title: a,
|
|
970
1008
|
lineNumbers: o
|
|
971
1009
|
});
|
|
@@ -976,25 +1014,59 @@ async function Ct(e) {
|
|
|
976
1014
|
}
|
|
977
1015
|
return i;
|
|
978
1016
|
}
|
|
979
|
-
|
|
1017
|
+
var Tt = {
|
|
1018
|
+
typescript: "TS",
|
|
1019
|
+
javascript: "JS",
|
|
1020
|
+
tsx: "TSX",
|
|
1021
|
+
jsx: "JSX",
|
|
1022
|
+
python: "PY",
|
|
1023
|
+
rust: "RS",
|
|
1024
|
+
go: "GO",
|
|
1025
|
+
java: "JAVA",
|
|
1026
|
+
kotlin: "KT",
|
|
1027
|
+
swift: "SWIFT",
|
|
1028
|
+
ruby: "RB",
|
|
1029
|
+
php: "PHP",
|
|
1030
|
+
csharp: "C#",
|
|
1031
|
+
cpp: "C++",
|
|
1032
|
+
c: "C",
|
|
1033
|
+
bash: "SH",
|
|
1034
|
+
sh: "SH",
|
|
1035
|
+
shell: "SH",
|
|
1036
|
+
zsh: "SH",
|
|
1037
|
+
html: "HTML",
|
|
1038
|
+
css: "CSS",
|
|
1039
|
+
scss: "SCSS",
|
|
1040
|
+
sass: "SASS",
|
|
1041
|
+
json: "JSON",
|
|
1042
|
+
yaml: "YML",
|
|
1043
|
+
yml: "YML",
|
|
1044
|
+
toml: "TOML",
|
|
1045
|
+
xml: "XML",
|
|
1046
|
+
sql: "SQL",
|
|
1047
|
+
markdown: "MD",
|
|
1048
|
+
vue: "VUE",
|
|
1049
|
+
svelte: "SV",
|
|
1050
|
+
txt: "TXT"
|
|
1051
|
+
};
|
|
1052
|
+
function Et(e) {
|
|
1053
|
+
return Tt[e.toLowerCase()] ?? e.slice(0, 4).toUpperCase();
|
|
1054
|
+
}
|
|
1055
|
+
function Dt(e, t, n) {
|
|
980
1056
|
t ||= "txt";
|
|
981
|
-
let r =
|
|
1057
|
+
let r = Et(t), i = ["td-code-block", "language-" + t];
|
|
982
1058
|
n.title && i.push("has-title"), n.lineNumbers !== void 0 && i.push("line-numbers-mode");
|
|
983
1059
|
let a = `<figure class="${i.join(" ")}">`;
|
|
984
|
-
|
|
985
|
-
let e = parseInt(n.lineNumbers) || 1, t = a.slice(a.indexOf("<code>"), a.indexOf("</code>")).split("\n").length, r = [...Array(t)].map((t, n) => `<span class="line-number">${n + e}</span><br>`).join("");
|
|
986
|
-
a += `<div class="line-numbers-wrapper" aria-hidden="true">${r}</div>`;
|
|
987
|
-
}
|
|
988
|
-
return a += "</figure>", a;
|
|
1060
|
+
return a += "<figcaption class=\"td-code-header\">", a += "<span class=\"td-code-left\">", a += `<span class="td-code-lang">${m(r)}</span>`, n.title && (a += `<span class="td-code-label">${m(n.title)}</span>`), a += "</span>", a += "<span class=\"td-code-actions\">", a += "<button type=\"button\" aria-label=\"Copy code\" data-copied=\"Copied\" class=\"td-code-copy\">", a += "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg>", a += "<span class=\"td-code-copy-text\">Copy</span>", a += "</button>", a += "</span>", a += "</figcaption>", a += e, a += "</figure>", a;
|
|
989
1061
|
}
|
|
990
|
-
var
|
|
991
|
-
function
|
|
992
|
-
return e = e.replace(
|
|
1062
|
+
var Ot = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, kt = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
1063
|
+
function At(e) {
|
|
1064
|
+
return e = e.replace(Ot, (e, t) => Nt(t, !1)), e = e.replace(kt, (e, t) => Nt(t, !0)), e;
|
|
993
1065
|
}
|
|
994
|
-
var
|
|
995
|
-
function
|
|
1066
|
+
var jt = /`([^`]+)`|\$([^$]+)\$/g;
|
|
1067
|
+
function Mt(e) {
|
|
996
1068
|
let t = 0, n = "";
|
|
997
|
-
for (let r of e.matchAll(
|
|
1069
|
+
for (let r of e.matchAll(jt)) {
|
|
998
1070
|
if (n += m(e.slice(t, r.index)), r[1] !== void 0) n += `<code>${m(r[1])}</code>`;
|
|
999
1071
|
else if (r[2] !== void 0) try {
|
|
1000
1072
|
n += ie.renderToString(r[2], { throwOnError: !1 });
|
|
@@ -1005,7 +1077,7 @@ function kt(e) {
|
|
|
1005
1077
|
}
|
|
1006
1078
|
return n += m(e.slice(t)), n;
|
|
1007
1079
|
}
|
|
1008
|
-
function
|
|
1080
|
+
function Nt(e, t) {
|
|
1009
1081
|
let n = t ? "div" : "span";
|
|
1010
1082
|
try {
|
|
1011
1083
|
return ie.renderToString(h(e), {
|
|
@@ -1026,16 +1098,16 @@ async function U(e, t, n) {
|
|
|
1026
1098
|
label: t.label,
|
|
1027
1099
|
icon: t.icon,
|
|
1028
1100
|
frontmatter: t.header ?? {},
|
|
1029
|
-
headings:
|
|
1101
|
+
headings: Ft(t.headings),
|
|
1030
1102
|
title: r,
|
|
1031
|
-
titleHtml:
|
|
1103
|
+
titleHtml: Mt(r),
|
|
1032
1104
|
filepath: n,
|
|
1033
1105
|
fileMetadata: t.fileMetadata,
|
|
1034
1106
|
seoMetadata: t.seoMetadata
|
|
1035
1107
|
};
|
|
1036
1108
|
}
|
|
1037
|
-
async function
|
|
1038
|
-
let r = await
|
|
1109
|
+
async function Pt(e, t, n) {
|
|
1110
|
+
let r = await xt(t.content), i = await U(e, t, n), a = JSON.stringify(`@typedown/pages?resource=${encodeURIComponent(n)}`);
|
|
1039
1111
|
return {
|
|
1040
1112
|
vueSrc: [
|
|
1041
1113
|
"<script>",
|
|
@@ -1047,12 +1119,12 @@ async function jt(e, t, n) {
|
|
|
1047
1119
|
`import { pageData } from ${a}`,
|
|
1048
1120
|
"useRouter().route.data = pageData",
|
|
1049
1121
|
"<\/script>",
|
|
1050
|
-
`<template><div class="typedown-content">\n${
|
|
1122
|
+
`<template><div class="typedown-content">\n${It(r)}\n</div></template>`
|
|
1051
1123
|
].join("\n"),
|
|
1052
1124
|
pageData: i
|
|
1053
1125
|
};
|
|
1054
1126
|
}
|
|
1055
|
-
function
|
|
1127
|
+
function Ft(e) {
|
|
1056
1128
|
let t = [], n = [];
|
|
1057
1129
|
for (let r of e) {
|
|
1058
1130
|
let e = {
|
|
@@ -1068,14 +1140,14 @@ function Mt(e) {
|
|
|
1068
1140
|
}
|
|
1069
1141
|
return t;
|
|
1070
1142
|
}
|
|
1071
|
-
function
|
|
1143
|
+
function It(e) {
|
|
1072
1144
|
return e.replaceAll("{{", "{{").replaceAll("}}", "}}");
|
|
1073
1145
|
}
|
|
1074
1146
|
//#endregion
|
|
1075
1147
|
//#region src/node/plugin/vite/constants.ts
|
|
1076
|
-
var
|
|
1148
|
+
var Lt = "@typedown/app", Rt = "\0@typedown/app", W = "@typedown/pages", zt = "\0" + W;
|
|
1077
1149
|
W + "";
|
|
1078
|
-
var G = "\0@typedown/pages?resource=", K = "@typedown/site-data",
|
|
1150
|
+
var G = "\0@typedown/pages?resource=", K = "@typedown/site-data", Bt = "\0@typedown/site-data", q = "@typedown/search-index", Vt = "\0@typedown/search-index", J = "@typedown/theme", Ht = "\0@typedown/theme", Y = "typedown:page-data";
|
|
1079
1151
|
//#endregion
|
|
1080
1152
|
//#region src/node/plugin/vite/virtual/utils.ts
|
|
1081
1153
|
function X(e, t) {
|
|
@@ -1095,7 +1167,7 @@ function X(e, t) {
|
|
|
1095
1167
|
}
|
|
1096
1168
|
//#endregion
|
|
1097
1169
|
//#region src/node/plugin/vite/virtual/app.ts
|
|
1098
|
-
var
|
|
1170
|
+
var Ut = class {
|
|
1099
1171
|
mountPath;
|
|
1100
1172
|
constructor(e = "") {
|
|
1101
1173
|
this.mountPath = e;
|
|
@@ -1124,9 +1196,9 @@ var Bt = class {
|
|
|
1124
1196
|
});
|
|
1125
1197
|
}
|
|
1126
1198
|
invalidate(e) {
|
|
1127
|
-
X(e,
|
|
1199
|
+
X(e, Rt);
|
|
1128
1200
|
}
|
|
1129
|
-
},
|
|
1201
|
+
}, Wt = class {
|
|
1130
1202
|
mountPath;
|
|
1131
1203
|
constructor(e = "") {
|
|
1132
1204
|
this.mountPath = e;
|
|
@@ -1164,21 +1236,21 @@ var Bt = class {
|
|
|
1164
1236
|
});
|
|
1165
1237
|
}
|
|
1166
1238
|
invalidate(e) {
|
|
1167
|
-
X(e,
|
|
1239
|
+
X(e, zt);
|
|
1168
1240
|
}
|
|
1169
|
-
},
|
|
1241
|
+
}, Gt = class {
|
|
1170
1242
|
async load(e) {
|
|
1171
1243
|
return ze((await (await e.getTdContext()).getConfig()).layout ?? void 0, e.root);
|
|
1172
1244
|
}
|
|
1173
1245
|
invalidate(e) {
|
|
1174
|
-
X(e,
|
|
1246
|
+
X(e, Ht);
|
|
1175
1247
|
}
|
|
1176
|
-
},
|
|
1248
|
+
}, Kt = "\0@typedown/site-data", qt = {
|
|
1177
1249
|
ready: !1,
|
|
1178
1250
|
contentTree: { entries: [] },
|
|
1179
1251
|
schemas: {},
|
|
1180
1252
|
directoryListings: {}
|
|
1181
|
-
},
|
|
1253
|
+
}, Jt = class {
|
|
1182
1254
|
data;
|
|
1183
1255
|
scan(e) {
|
|
1184
1256
|
let t = ye("**/*.td", {
|
|
@@ -1199,27 +1271,27 @@ var Bt = class {
|
|
|
1199
1271
|
let t = this.data ? {
|
|
1200
1272
|
ready: !0,
|
|
1201
1273
|
...this.data
|
|
1202
|
-
} :
|
|
1274
|
+
} : qt;
|
|
1203
1275
|
return `export default ${JSON.stringify(t)}`;
|
|
1204
1276
|
}
|
|
1205
1277
|
clear() {
|
|
1206
1278
|
this.data = void 0;
|
|
1207
1279
|
}
|
|
1208
1280
|
fetch = b((e, t) => {
|
|
1209
|
-
|
|
1281
|
+
Yt(e).then((e) => {
|
|
1210
1282
|
this.data = e, t && this.invalidate(t);
|
|
1211
1283
|
}).catch((e) => {
|
|
1212
1284
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1213
1285
|
});
|
|
1214
1286
|
}, 200);
|
|
1215
1287
|
async fetchSync(e) {
|
|
1216
|
-
this.data = await
|
|
1288
|
+
this.data = await Yt(e);
|
|
1217
1289
|
}
|
|
1218
1290
|
invalidate(e) {
|
|
1219
|
-
X(e,
|
|
1291
|
+
X(e, Kt);
|
|
1220
1292
|
}
|
|
1221
1293
|
};
|
|
1222
|
-
async function
|
|
1294
|
+
async function Yt(e) {
|
|
1223
1295
|
let [t, n, r] = await Promise.all([
|
|
1224
1296
|
e.getConfig(),
|
|
1225
1297
|
e.listSidebar(),
|
|
@@ -1236,7 +1308,7 @@ async function Kt(e) {
|
|
|
1236
1308
|
}
|
|
1237
1309
|
//#endregion
|
|
1238
1310
|
//#region src/node/lib/search-indexer/index.ts
|
|
1239
|
-
var
|
|
1311
|
+
var Xt = class {
|
|
1240
1312
|
index;
|
|
1241
1313
|
constructor() {
|
|
1242
1314
|
this.index = new le({
|
|
@@ -1260,19 +1332,19 @@ var qt = class {
|
|
|
1260
1332
|
};
|
|
1261
1333
|
//#endregion
|
|
1262
1334
|
//#region src/node/lib/search-indexer/scan.ts
|
|
1263
|
-
function
|
|
1264
|
-
let n =
|
|
1335
|
+
function Zt(e, t) {
|
|
1336
|
+
let n = tn(e), r = [];
|
|
1265
1337
|
for (let t of n) {
|
|
1266
|
-
let n =
|
|
1338
|
+
let n = en(e, t);
|
|
1267
1339
|
n && r.push(n);
|
|
1268
1340
|
}
|
|
1269
1341
|
t.addAll(r);
|
|
1270
1342
|
}
|
|
1271
|
-
function
|
|
1272
|
-
let i =
|
|
1343
|
+
function Qt(e, n, r) {
|
|
1344
|
+
let i = en(e, A(e, n));
|
|
1273
1345
|
i ? r.addPage(i) : r.discardPage(t(n));
|
|
1274
1346
|
}
|
|
1275
|
-
function
|
|
1347
|
+
function $t(e, t) {
|
|
1276
1348
|
let n = w(e);
|
|
1277
1349
|
if (!t.startsWith("---")) return {
|
|
1278
1350
|
title: n,
|
|
@@ -1289,7 +1361,7 @@ function Xt(e, t) {
|
|
|
1289
1361
|
body: a
|
|
1290
1362
|
};
|
|
1291
1363
|
}
|
|
1292
|
-
function
|
|
1364
|
+
function en(e, n) {
|
|
1293
1365
|
let r;
|
|
1294
1366
|
try {
|
|
1295
1367
|
r = be(n, "utf-8");
|
|
@@ -1297,14 +1369,14 @@ function Zt(e, n) {
|
|
|
1297
1369
|
return;
|
|
1298
1370
|
}
|
|
1299
1371
|
if (!r.trim()) return;
|
|
1300
|
-
let i = n.slice(e.length + 1), { title: a, body: o } =
|
|
1372
|
+
let i = n.slice(e.length + 1), { title: a, body: o } = $t(i, r);
|
|
1301
1373
|
return {
|
|
1302
1374
|
id: t(i),
|
|
1303
1375
|
title: a,
|
|
1304
1376
|
text: `${a}\n${o}`
|
|
1305
1377
|
};
|
|
1306
1378
|
}
|
|
1307
|
-
function
|
|
1379
|
+
function tn(e) {
|
|
1308
1380
|
return ye("**/*.td", {
|
|
1309
1381
|
cwd: e,
|
|
1310
1382
|
exclude: (e) => e.startsWith("_")
|
|
@@ -1312,33 +1384,33 @@ function Qt(e) {
|
|
|
1312
1384
|
}
|
|
1313
1385
|
//#endregion
|
|
1314
1386
|
//#region src/node/plugin/vite/virtual/search-index.ts
|
|
1315
|
-
var
|
|
1316
|
-
indexer = new
|
|
1387
|
+
var nn = "\0@typedown/search-index", rn = class {
|
|
1388
|
+
indexer = new Xt();
|
|
1317
1389
|
load(e) {
|
|
1318
1390
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1319
1391
|
}
|
|
1320
1392
|
index(e) {
|
|
1321
|
-
|
|
1393
|
+
Zt(e, this.indexer);
|
|
1322
1394
|
}
|
|
1323
1395
|
reindex(e, t) {
|
|
1324
|
-
|
|
1396
|
+
Qt(e, t, this.indexer);
|
|
1325
1397
|
}
|
|
1326
1398
|
invalidate(e) {
|
|
1327
|
-
X(e,
|
|
1399
|
+
X(e, nn);
|
|
1328
1400
|
}
|
|
1329
|
-
},
|
|
1330
|
-
function
|
|
1401
|
+
}, an = Se(import.meta.url);
|
|
1402
|
+
function on() {
|
|
1331
1403
|
return [{
|
|
1332
1404
|
find: "vue/server-renderer",
|
|
1333
|
-
replacement:
|
|
1405
|
+
replacement: an.resolve("vue/server-renderer")
|
|
1334
1406
|
}, {
|
|
1335
1407
|
find: "vue",
|
|
1336
|
-
replacement:
|
|
1408
|
+
replacement: an.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1337
1409
|
}];
|
|
1338
1410
|
}
|
|
1339
1411
|
//#endregion
|
|
1340
1412
|
//#region src/node/plugin/vite/middleware/vault-assets.ts
|
|
1341
|
-
var
|
|
1413
|
+
var sn = {
|
|
1342
1414
|
jpg: "image/jpeg",
|
|
1343
1415
|
jpeg: "image/jpeg",
|
|
1344
1416
|
png: "image/png",
|
|
@@ -1356,7 +1428,7 @@ var rn = {
|
|
|
1356
1428
|
woff: "font/woff",
|
|
1357
1429
|
ttf: "font/ttf"
|
|
1358
1430
|
};
|
|
1359
|
-
function
|
|
1431
|
+
function cn(t, r) {
|
|
1360
1432
|
return (i, o, s) => {
|
|
1361
1433
|
if (!i.url || i.method !== "GET" || o.writableEnded) return s();
|
|
1362
1434
|
let c = e(i.url);
|
|
@@ -1365,7 +1437,7 @@ function an(t, r) {
|
|
|
1365
1437
|
if (ve(d)) try {
|
|
1366
1438
|
let e = xe(d);
|
|
1367
1439
|
if (e.isFile()) {
|
|
1368
|
-
let t =
|
|
1440
|
+
let t = sn[a(d).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1369
1441
|
o.setHeader("Content-Type", t), o.setHeader("Content-Length", e.size), _e(d).pipe(o);
|
|
1370
1442
|
return;
|
|
1371
1443
|
}
|
|
@@ -1375,7 +1447,7 @@ function an(t, r) {
|
|
|
1375
1447
|
}
|
|
1376
1448
|
//#endregion
|
|
1377
1449
|
//#region src/node/plugin/vite/middleware/virtual-html.ts
|
|
1378
|
-
function
|
|
1450
|
+
function ln(t, r, i) {
|
|
1379
1451
|
return (a, o, s) => {
|
|
1380
1452
|
if (!a.url) return s();
|
|
1381
1453
|
let c = n(e(a.url)), l = n(i.basePath);
|
|
@@ -1383,22 +1455,22 @@ function on(t, r, i) {
|
|
|
1383
1455
|
let u = c.slice(l.length);
|
|
1384
1456
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return s();
|
|
1385
1457
|
r.getConfig().then(async (e) => {
|
|
1386
|
-
let n = await t.transformIndexHtml(a.url ?? "",
|
|
1458
|
+
let n = await t.transformIndexHtml(a.url ?? "", un(i, e));
|
|
1387
1459
|
o.setHeader("Content-Type", "text/html"), o.end(n);
|
|
1388
1460
|
}).catch(() => s());
|
|
1389
1461
|
};
|
|
1390
1462
|
}
|
|
1391
|
-
function
|
|
1463
|
+
function un(e, t) {
|
|
1392
1464
|
return e.devHtml === void 0 && (e.devHtml = ne({
|
|
1393
1465
|
title: t.siteTitle,
|
|
1394
1466
|
description: t.siteDescription,
|
|
1395
1467
|
base: "/",
|
|
1396
|
-
entryScript:
|
|
1468
|
+
entryScript: Lt
|
|
1397
1469
|
})), e.devHtml;
|
|
1398
1470
|
}
|
|
1399
1471
|
//#endregion
|
|
1400
1472
|
//#region src/node/lib/prop-schema.ts
|
|
1401
|
-
function
|
|
1473
|
+
function dn(e, t, n) {
|
|
1402
1474
|
let r = {};
|
|
1403
1475
|
for (let i of e) {
|
|
1404
1476
|
let e = `./${k.relative(t, i.absolutePath)}`;
|
|
@@ -1424,7 +1496,7 @@ function cn(e, t, n) {
|
|
|
1424
1496
|
}
|
|
1425
1497
|
return r;
|
|
1426
1498
|
}
|
|
1427
|
-
function
|
|
1499
|
+
function fn(e) {
|
|
1428
1500
|
if (!e || e.length !== 1) return;
|
|
1429
1501
|
let t = Z(e[0]);
|
|
1430
1502
|
return t === void 0 ? void 0 : {
|
|
@@ -1432,17 +1504,17 @@ function ln(e) {
|
|
|
1432
1504
|
items: t
|
|
1433
1505
|
};
|
|
1434
1506
|
}
|
|
1435
|
-
function
|
|
1436
|
-
if (t && 0 < Object.keys(t).length) return
|
|
1507
|
+
function pn(e, t) {
|
|
1508
|
+
if (t && 0 < Object.keys(t).length) return hn(t);
|
|
1437
1509
|
let n = /^(?:Record<string,\s*(\w+)>|\{\s*\[key:\s*string\]:\s*(\w+);\s*\})$/.exec(e);
|
|
1438
1510
|
if (!n) return;
|
|
1439
|
-
let r =
|
|
1511
|
+
let r = mn(n[1] ?? n[2]);
|
|
1440
1512
|
return r === void 0 ? void 0 : {
|
|
1441
1513
|
type: "object",
|
|
1442
1514
|
additionalProperties: r
|
|
1443
1515
|
};
|
|
1444
1516
|
}
|
|
1445
|
-
function
|
|
1517
|
+
function mn(e) {
|
|
1446
1518
|
switch (e) {
|
|
1447
1519
|
case "string": return { type: "string" };
|
|
1448
1520
|
case "number": return { type: "number" };
|
|
@@ -1450,7 +1522,7 @@ function dn(e) {
|
|
|
1450
1522
|
default: return;
|
|
1451
1523
|
}
|
|
1452
1524
|
}
|
|
1453
|
-
function
|
|
1525
|
+
function hn(e) {
|
|
1454
1526
|
let t = {}, n = [];
|
|
1455
1527
|
for (let [r, i] of Object.entries(e)) {
|
|
1456
1528
|
let e = Z(i.schema);
|
|
@@ -1465,15 +1537,15 @@ function fn(e) {
|
|
|
1465
1537
|
return 0 < n.length && (r.required = n), r;
|
|
1466
1538
|
}
|
|
1467
1539
|
function Z(e) {
|
|
1468
|
-
if (typeof e == "string") return
|
|
1540
|
+
if (typeof e == "string") return mn(e);
|
|
1469
1541
|
switch (e.kind) {
|
|
1470
|
-
case "enum": return
|
|
1471
|
-
case "array": return
|
|
1472
|
-
case "object": return
|
|
1542
|
+
case "enum": return gn(e.schema);
|
|
1543
|
+
case "array": return fn(e.schema);
|
|
1544
|
+
case "object": return pn(e.type, e.schema);
|
|
1473
1545
|
default: return;
|
|
1474
1546
|
}
|
|
1475
1547
|
}
|
|
1476
|
-
function
|
|
1548
|
+
function gn(e) {
|
|
1477
1549
|
let t = e ?? [], n = t.some((e) => e === "undefined" || e === "null"), r = t.filter((e) => e !== "undefined" && e !== "null");
|
|
1478
1550
|
if (r.length !== 0) {
|
|
1479
1551
|
if (r.length === 1) {
|
|
@@ -1493,8 +1565,8 @@ function pn(e) {
|
|
|
1493
1565
|
}
|
|
1494
1566
|
//#endregion
|
|
1495
1567
|
//#region src/node/plugin/vite/subplugins/component-contract.ts
|
|
1496
|
-
var
|
|
1497
|
-
function
|
|
1568
|
+
var _n = ".typedown/components.json";
|
|
1569
|
+
function vn(e) {
|
|
1498
1570
|
return {
|
|
1499
1571
|
name: "vite-plugin-typedown-component-contract",
|
|
1500
1572
|
async buildStart() {
|
|
@@ -1507,27 +1579,27 @@ function hn(e) {
|
|
|
1507
1579
|
let n = e();
|
|
1508
1580
|
n && n.getTdContext().then(async (e) => {
|
|
1509
1581
|
let r = await e.getConfig(), i = await I(r.components, n.root);
|
|
1510
|
-
$(n.root, i),
|
|
1582
|
+
$(n.root, i), yn(t, r.components, n.root);
|
|
1511
1583
|
}).catch(() => {});
|
|
1512
1584
|
}
|
|
1513
1585
|
};
|
|
1514
1586
|
}
|
|
1515
|
-
function
|
|
1587
|
+
function yn(e, t, n) {
|
|
1516
1588
|
let r = new Set(t.filter((e) => e.kind === "explicit").map((e) => M(k.resolve(n, e.source)))), i = new Set(t.filter((e) => e.kind === "dir").map((e) => M(k.resolve(n, e.path))));
|
|
1517
1589
|
for (let t of i) e.watcher.add(t);
|
|
1518
1590
|
let a = (a) => {
|
|
1519
|
-
|
|
1591
|
+
bn(a, r, i) && (e.config.logger.info("[typedown] component changed, rebuilding contract..."), I(t, n).then((e) => $(n, e)).catch(() => {}));
|
|
1520
1592
|
};
|
|
1521
1593
|
e.watcher.on("change", a), e.watcher.on("add", a), e.watcher.on("unlink", a);
|
|
1522
1594
|
}
|
|
1523
|
-
function
|
|
1595
|
+
function bn(e, t, n) {
|
|
1524
1596
|
if (!e.endsWith(".vue")) return !1;
|
|
1525
1597
|
let r = M(e);
|
|
1526
1598
|
if (t.has(r)) return !0;
|
|
1527
1599
|
for (let e of n) if (r.startsWith(e + "/")) return !0;
|
|
1528
1600
|
return !1;
|
|
1529
1601
|
}
|
|
1530
|
-
function
|
|
1602
|
+
function xn() {
|
|
1531
1603
|
try {
|
|
1532
1604
|
let e = k.dirname(me(import.meta.url)), t = k.resolve(e, "builtin-components.json"), n = JSON.parse(P.readFileSync(t, "utf-8"));
|
|
1533
1605
|
for (let e of Object.values(n)) if (typeof e == "object" && e && "source" in e) {
|
|
@@ -1539,19 +1611,19 @@ function vn() {
|
|
|
1539
1611
|
return {};
|
|
1540
1612
|
}
|
|
1541
1613
|
}
|
|
1542
|
-
var Q =
|
|
1614
|
+
var Q = xn();
|
|
1543
1615
|
function $(e, t) {
|
|
1544
1616
|
if (!(0 < Object.keys(Q).length) && t.length === 0) return;
|
|
1545
|
-
let n = 0 < t.length ?
|
|
1617
|
+
let n = 0 < t.length ? dn(t, e, Be(e)) : {}, r = {
|
|
1546
1618
|
...Q,
|
|
1547
1619
|
...n
|
|
1548
|
-
}, i = k.join(e,
|
|
1620
|
+
}, i = k.join(e, _n);
|
|
1549
1621
|
P.mkdirSync(k.dirname(i), { recursive: !0 }), P.writeFileSync(i, JSON.stringify(r, null, 2));
|
|
1550
1622
|
}
|
|
1551
1623
|
//#endregion
|
|
1552
1624
|
//#region src/node/plugin/vite/index.ts
|
|
1553
|
-
function
|
|
1554
|
-
let t = e.context, n, i, a, o = new
|
|
1625
|
+
function Sn(e = {}) {
|
|
1626
|
+
let t = e.context, n, i, a, o = new Ut(e.root ?? ""), s = new Gt(), l = new Wt(e.root ?? ""), u = new Jt(), d = new rn(), f = {
|
|
1555
1627
|
devHtml: void 0,
|
|
1556
1628
|
basePath: "/",
|
|
1557
1629
|
rootDirectory: "vault"
|
|
@@ -1577,7 +1649,7 @@ function yn(e = {}) {
|
|
|
1577
1649
|
port: n.server?.port ?? 8686,
|
|
1578
1650
|
strictPort: n.server?.strictPort ?? !1
|
|
1579
1651
|
},
|
|
1580
|
-
resolve: { alias:
|
|
1652
|
+
resolve: { alias: on() },
|
|
1581
1653
|
ssr: { noExternal: ["typerighter"] }
|
|
1582
1654
|
};
|
|
1583
1655
|
},
|
|
@@ -1589,18 +1661,18 @@ function yn(e = {}) {
|
|
|
1589
1661
|
let e = await p(), t = await e.getConfig(), r = A(t.rootDir);
|
|
1590
1662
|
d.index(r), await u.fetchSync(e);
|
|
1591
1663
|
let i = await e.checkVault();
|
|
1592
|
-
if (
|
|
1664
|
+
if (Dn(i.diagnostics), 0 < i.errorCount) {
|
|
1593
1665
|
let e = i.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1594
1666
|
this.error(`Vault check failed with ${i.errorCount} error(s):\n${e.join("\n")}`);
|
|
1595
1667
|
}
|
|
1596
1668
|
},
|
|
1597
1669
|
resolveId(e) {
|
|
1598
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1599
|
-
if (e === "@typedown/pages") return
|
|
1670
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return Rt;
|
|
1671
|
+
if (e === "@typedown/pages") return zt;
|
|
1600
1672
|
if (e.startsWith("@typedown/pages?resource=")) return l.resolvePageData(e);
|
|
1601
|
-
if (e === "@typedown/site-data") return
|
|
1602
|
-
if (e === "@typedown/search-index") return
|
|
1603
|
-
if (e === "@typedown/theme") return
|
|
1673
|
+
if (e === "@typedown/site-data") return Bt;
|
|
1674
|
+
if (e === "@typedown/search-index") return Vt;
|
|
1675
|
+
if (e === "@typedown/theme") return Ht;
|
|
1604
1676
|
},
|
|
1605
1677
|
async load(e) {
|
|
1606
1678
|
if (l.isPageDataModule(e)) return l.loadPageData(e, await p());
|
|
@@ -1617,11 +1689,11 @@ function yn(e = {}) {
|
|
|
1617
1689
|
let t = await p(), r = await t.getConfig(), i = A(r.rootDir);
|
|
1618
1690
|
d.index(i), u.scan(i), u.fetch(t, n), e.httpServer?.once("listening", async () => {
|
|
1619
1691
|
let e = await t.checkVault();
|
|
1620
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1692
|
+
0 < e.diagnostics.length && (console.error(""), Dn(e.diagnostics));
|
|
1621
1693
|
}), t.rpc.onConfigChanged(() => {
|
|
1622
|
-
n && (f.devHtml = void 0, u.clear(), o.invalidate(n), s.invalidate(n), l.invalidate(n),
|
|
1694
|
+
n && (f.devHtml = void 0, u.clear(), o.invalidate(n), s.invalidate(n), l.invalidate(n), wn(n), u.fetch(t, n));
|
|
1623
1695
|
}), t.rpc.onComponentContractChanged(() => {
|
|
1624
|
-
n && (o.invalidate(n),
|
|
1696
|
+
n && (o.invalidate(n), wn(n));
|
|
1625
1697
|
});
|
|
1626
1698
|
function a(...e) {
|
|
1627
1699
|
n && t.getConfig().then((t) => {
|
|
@@ -1630,7 +1702,7 @@ function yn(e = {}) {
|
|
|
1630
1702
|
for (let i of e) {
|
|
1631
1703
|
let e = M(A(n.config.root, t.rootDir, i)), a = n.moduleGraph.getModulesByFile(e);
|
|
1632
1704
|
if (a?.size) {
|
|
1633
|
-
for (let e of a) n.moduleGraph.invalidateModule(e), r.push(
|
|
1705
|
+
for (let e of a) n.moduleGraph.invalidateModule(e), r.push(En(e));
|
|
1634
1706
|
l.invalidatePageData(n, i);
|
|
1635
1707
|
}
|
|
1636
1708
|
}
|
|
@@ -1646,13 +1718,13 @@ function yn(e = {}) {
|
|
|
1646
1718
|
n && (d.reindex(i, e), d.invalidate(n), l.invalidate(n), u.fetch(t, n), a(e));
|
|
1647
1719
|
});
|
|
1648
1720
|
function c() {
|
|
1649
|
-
n && (u.clear(),
|
|
1721
|
+
n && (u.clear(), Tn(n), u.fetch(t, n));
|
|
1650
1722
|
}
|
|
1651
1723
|
t.rpc.onSchemaUpdated(c), t.rpc.onSchemaDeleted(c);
|
|
1652
1724
|
let m = await t.getConfig();
|
|
1653
1725
|
f.basePath = m.basePath, f.rootDirectory = m.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1654
1726
|
f.basePath = e.basePath, f.rootDirectory = e.rootDir, f.devHtml = void 0;
|
|
1655
|
-
}), e.middlewares.use(
|
|
1727
|
+
}), e.middlewares.use(cn(e, f)), e.middlewares.use(ln(e, t, f));
|
|
1656
1728
|
},
|
|
1657
1729
|
async transform(e, t) {
|
|
1658
1730
|
let n = t.split("?")[0];
|
|
@@ -1663,7 +1735,7 @@ function yn(e = {}) {
|
|
|
1663
1735
|
};
|
|
1664
1736
|
let i = await p(), a = await i.getConfig(), o = r(n, a.rootDir);
|
|
1665
1737
|
try {
|
|
1666
|
-
let { vueSrc: e } = await
|
|
1738
|
+
let { vueSrc: e } = await Pt(i, await i.getFile(o), o);
|
|
1667
1739
|
return {
|
|
1668
1740
|
code: e,
|
|
1669
1741
|
map: null
|
|
@@ -1694,26 +1766,26 @@ function yn(e = {}) {
|
|
|
1694
1766
|
});
|
|
1695
1767
|
return [
|
|
1696
1768
|
m,
|
|
1697
|
-
|
|
1769
|
+
vn(() => t),
|
|
1698
1770
|
h,
|
|
1699
1771
|
...ue()
|
|
1700
1772
|
];
|
|
1701
1773
|
}
|
|
1702
|
-
function
|
|
1774
|
+
function Cn(e) {
|
|
1703
1775
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1704
1776
|
}
|
|
1705
|
-
function
|
|
1706
|
-
for (let t of
|
|
1777
|
+
function wn(e) {
|
|
1778
|
+
for (let t of Cn(e)) e.moduleGraph.invalidateModule(t);
|
|
1707
1779
|
e.hot.send({ type: "full-reload" });
|
|
1708
1780
|
}
|
|
1709
|
-
function
|
|
1710
|
-
let t =
|
|
1781
|
+
function Tn(e) {
|
|
1782
|
+
let t = Cn(e).map((t) => (e.moduleGraph.invalidateModule(t), En(t)));
|
|
1711
1783
|
0 < t.length && e.hot.send({
|
|
1712
1784
|
type: "update",
|
|
1713
1785
|
updates: t
|
|
1714
1786
|
});
|
|
1715
1787
|
}
|
|
1716
|
-
function
|
|
1788
|
+
function En(e) {
|
|
1717
1789
|
return {
|
|
1718
1790
|
type: "js-update",
|
|
1719
1791
|
path: e.url,
|
|
@@ -1721,11 +1793,11 @@ function Cn(e) {
|
|
|
1721
1793
|
timestamp: Date.now()
|
|
1722
1794
|
};
|
|
1723
1795
|
}
|
|
1724
|
-
function
|
|
1796
|
+
function Dn(e) {
|
|
1725
1797
|
for (let t of e) {
|
|
1726
1798
|
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? j.red("error") : j.yellow("warn");
|
|
1727
1799
|
console.error(` ${n} ${e} ${t.message} ${j.dim(`(${t.code})`)}`);
|
|
1728
1800
|
}
|
|
1729
1801
|
}
|
|
1730
1802
|
//#endregion
|
|
1731
|
-
export { K as a, q as i, W as n, J as o, Y as r, Ue as s,
|
|
1803
|
+
export { K as a, q as i, W as n, J as o, Y as r, Ue as s, Sn as t };
|