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/client.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, l as r, o as i, t as a, u as o } from "./app-Bf0aLzaG.js";
1
+ import { a as e, c as t, i as n, l as r, o as i, t as a, u as o } from "./app-Dn-65wMj.js";
2
2
  export { t as Content, a as createTypedownApp, r as useRoute, o as useRouter, n as useSiteConfig, e as useSiteData, i as useTdContent };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "./vite-DnP-_NzR.js";
1
+ import { n as e, t } from "./vite-CASZdq-i.js";
2
2
  import "./vite.js";
3
- import { n, t as r } from "./cli-CDd4TNg1.js";
3
+ import { n, t as r } from "./cli-Doj0ofRb.js";
4
4
  export { n as buildSite, r as cli, t as generateClientAppEntry, e as typedown };
@@ -1,6 +1,6 @@
1
- import { a as e, c as t, i as n } from "./constants-DJbUAb1-.js";
2
- import "./shared-CpPZZ8IH.js";
3
- import { o as r, r as i } from "./brand-BfamszbH.js";
1
+ import { s as e, z as t } from "./shared-BIdsxcZ2.js";
2
+ import { i as n, r } from "./vite-CASZdq-i.js";
3
+ import { r as i } from "./brand-CJDq15GW.js";
4
4
  import a from "node:path";
5
5
  import "node:fs";
6
6
  import o from "node:fs/promises";
@@ -2244,34 +2244,34 @@ async function Zr() {
2244
2244
  });
2245
2245
  (hr(e) || e === "cancel") && (Hr("Cancelled."), process.exit(0));
2246
2246
  }
2247
- async function Qr(t) {
2248
- let n = {
2247
+ async function Qr(e) {
2248
+ let t = {
2249
2249
  hasPackageJson: !1,
2250
2250
  hasTypedownYaml: !1,
2251
2251
  packageName: void 0,
2252
2252
  siteTitle: void 0,
2253
2253
  siteDescription: void 0
2254
- }, r = a.join(t, "package.json");
2254
+ }, r = a.join(e, "package.json");
2255
2255
  try {
2256
- let e = await o.readFile(r, "utf-8"), t = JSON.parse(e);
2257
- n.hasPackageJson = !0, typeof t.name == "string" && 0 < t.name.length && (n.packageName = t.name);
2256
+ let e = await o.readFile(r, "utf-8"), n = JSON.parse(e);
2257
+ t.hasPackageJson = !0, typeof n.name == "string" && 0 < n.name.length && (t.packageName = n.name);
2258
2258
  } catch {}
2259
- for (let r of e) try {
2260
- let e = Nn(await o.readFile(a.join(t, r), "utf-8"));
2261
- n.hasTypedownYaml = !0;
2262
- let i = e?.site;
2263
- typeof i?.title == "string" && (n.siteTitle = i.title), typeof i?.description == "string" && (n.siteDescription = i.description);
2259
+ for (let r of n) try {
2260
+ let n = Nn(await o.readFile(a.join(e, r), "utf-8"));
2261
+ t.hasTypedownYaml = !0;
2262
+ let i = n?.site;
2263
+ typeof i?.title == "string" && (t.siteTitle = i.title), typeof i?.description == "string" && (t.siteDescription = i.description);
2264
2264
  break;
2265
2265
  } catch {}
2266
- return n;
2266
+ return t;
2267
2267
  }
2268
- function $r(e) {
2268
+ function $r(t) {
2269
2269
  return `<!doctype html>
2270
2270
  <html lang="en">
2271
2271
  <head>
2272
2272
  <meta charset="UTF-8" />
2273
2273
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
2274
- <title>${r(e.siteTitle)}</title>
2274
+ <title>${e(t.siteTitle)}</title>
2275
2275
  <link
2276
2276
  rel="icon"
2277
2277
  type="image/svg+xml"
@@ -2282,7 +2282,7 @@ function $r(e) {
2282
2282
  <div id="app"></div>
2283
2283
  <script
2284
2284
  type="module"
2285
- src="/${n}"
2285
+ src="/${r}"
2286
2286
  ><\/script>
2287
2287
  </body>
2288
2288
  </html>
@@ -2299,7 +2299,7 @@ function ei(e) {
2299
2299
  build: "typerighter build",
2300
2300
  preview: "typerighter preview"
2301
2301
  },
2302
- devDependencies: { typerighter: "^0.7.0" }
2302
+ devDependencies: { typerighter: "^0.8.0" }
2303
2303
  }, void 0, 2) + "\n";
2304
2304
  }
2305
2305
  function ti() {
@@ -0,0 +1,2 @@
1
+ export declare function isBuiltinField(key: string): boolean;
2
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/field.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD"}
@@ -1,5 +1,6 @@
1
1
  export * from './content';
2
2
  export * from './debounce';
3
+ export * from './field';
3
4
  export * from './format';
4
5
  export * from './html';
5
6
  export * as path from './path';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC"}
@@ -1,8 +1,13 @@
1
+ export declare function getDirectoryFromPageUrl(url: string): string;
1
2
  export declare function getDirectoryUrl(urlPrefix: string, name: string): string;
3
+ export declare function getIndexUrl(directoryUrl: string): string;
2
4
  export declare function getParentUrl(urlPath: string): string;
3
5
  export declare function getTdContentUrl(filepath: string): string;
6
+ export declare function isIndexUrl(url: string): boolean;
4
7
  export declare function isUrlAncestorOf(directoryUrl: string, path: string): boolean;
5
8
  export declare function isUrlExternal(path: string): boolean;
6
9
  export declare function isUrlToPage(filename: string): boolean;
10
+ export declare function resolveRootUrl(url: string): string;
7
11
  export declare function stripAnchor(url: string): string;
12
+ export declare function stripTrailingSlash(url: string): string;
8
13
  //# sourceMappingURL=url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/url.ts"],"names":[],"mappings":"AAoBA,wBAAgB,eAAe,CAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAgB,eAAe,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5E;AAGD,wBAAgB,aAAa,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAGD,wBAAgB,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAItD;AAGD,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/url.ts"],"names":[],"mappings":"AAqBA,wBAAgB,uBAAuB,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,eAAe,CAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAExE;AAGD,wBAAgB,WAAW,CAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIzD;AAGD,wBAAgB,UAAU,CAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,eAAe,CAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5E;AAGD,wBAAgB,aAAa,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAGD,wBAAgB,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAItD;AAED,wBAAgB,cAAc,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAGD,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED,wBAAgB,kBAAkB,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,265 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
3
+ let r = {};
4
+ for (var i in e) t(r, i, {
5
+ get: e[i],
6
+ enumerable: !0
7
+ });
8
+ return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ }, c = (e, i, o, s) => {
10
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
11
+ get: ((e) => i[e]).bind(null, d),
12
+ enumerable: !(s = n(i, d)) || s.enumerable
13
+ });
14
+ return e;
15
+ }, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
16
+ value: n,
17
+ enumerable: !0
18
+ }) : a, n)), u = "index", d = [".td", ".md"], f = "**/*.{td,md}", p = [
19
+ "title",
20
+ "titles",
21
+ "text"
22
+ ], m = ["title", "titles"], h = /^[a-z]+:/i;
23
+ //#endregion
24
+ //#region src/shared/utils/format.ts
25
+ function g(e) {
26
+ let t = e.match(/^(\d+)[-_](.+)$/);
27
+ return t ? {
28
+ order: Number(t[1]),
29
+ rest: t[2]
30
+ } : {
31
+ order: Infinity,
32
+ rest: e
33
+ };
34
+ }
35
+ function _(e) {
36
+ let { rest: t } = g(e), n = t.replace(/[-_]/g, " ").split(" ");
37
+ return 0 < n.length && (n[0] = n[0].charAt(0).toUpperCase() + n[0].slice(1)), n.join(" ");
38
+ }
39
+ //#endregion
40
+ //#region src/shared/utils/path.ts
41
+ var v = /* @__PURE__ */ s({
42
+ basename: () => y,
43
+ dirname: () => b,
44
+ extname: () => x,
45
+ filestem: () => S,
46
+ isContentFile: () => C,
47
+ join: () => w,
48
+ stripExtension: () => T
49
+ });
50
+ function y(e, t) {
51
+ let n = E(e).split("/").pop() ?? "";
52
+ return t !== void 0 && n.endsWith(t) ? n.slice(0, -t.length) : n;
53
+ }
54
+ function b(e) {
55
+ let t = E(e).split("/");
56
+ return t.pop(), t.join("/");
57
+ }
58
+ function x(e) {
59
+ let t = y(e), n = t.lastIndexOf(".");
60
+ return n <= 0 ? "" : t.slice(n);
61
+ }
62
+ function S(e) {
63
+ let t = y(e), n = t.lastIndexOf(".");
64
+ return n <= 0 ? t : t.slice(0, n);
65
+ }
66
+ function C(e) {
67
+ return d.includes(x(e));
68
+ }
69
+ function w(...e) {
70
+ return e.filter(Boolean).join("/").replace(/\\+/g, "/").replace(/\/+/g, "/").replace(/\/$/, "") || "/";
71
+ }
72
+ function T(e) {
73
+ let t = x(e);
74
+ return t ? e.slice(0, -t.length) : e;
75
+ }
76
+ function E(e) {
77
+ return e.replace(/\\/g, "/");
78
+ }
79
+ //#endregion
80
+ //#region src/shared/utils/url.ts
81
+ var ee = new Set("3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,yaml,yml,zip".split(","));
82
+ function D(e) {
83
+ return M(e) ? A(e) : e;
84
+ }
85
+ function O(e, t) {
86
+ return `${e}/${t}`;
87
+ }
88
+ function k(e) {
89
+ return e === "/" ? "/index" : e + "/index";
90
+ }
91
+ function A(e) {
92
+ return b(P(e)) || "/";
93
+ }
94
+ function j(e) {
95
+ let t = S(e);
96
+ return "/" + w(b(e), t);
97
+ }
98
+ function M(e) {
99
+ return e === "/index" || e.endsWith("/index");
100
+ }
101
+ function N(e, t) {
102
+ return t.startsWith(e + "/") || t === e;
103
+ }
104
+ function te(e) {
105
+ return h.test(e);
106
+ }
107
+ function ne(e) {
108
+ let t = x(e).slice(1);
109
+ return t === "" || !ee.has(t.toLowerCase());
110
+ }
111
+ function re(e) {
112
+ return e === "/" ? "/index" : e;
113
+ }
114
+ function ie(e) {
115
+ let t = e.indexOf("#");
116
+ return 0 <= t ? e.slice(0, t) : e;
117
+ }
118
+ function P(e) {
119
+ return e.replace(/\/$/, "") || "/";
120
+ }
121
+ //#endregion
122
+ //#region src/shared/utils/content.ts
123
+ function F(e) {
124
+ let t = {
125
+ name: "",
126
+ children: [],
127
+ items: []
128
+ };
129
+ for (let n of e) {
130
+ let e = n.filepath.split("/").slice(0, -1), r = t;
131
+ for (let t of e) {
132
+ let e = r.children.find((e) => e.name === t);
133
+ e || (e = {
134
+ name: t,
135
+ children: [],
136
+ items: []
137
+ }, r.children.push(e)), r = e;
138
+ }
139
+ r.items.push(n);
140
+ }
141
+ return z(t), {
142
+ rootItems: t.items,
143
+ children: t.children
144
+ };
145
+ }
146
+ function I(e, t) {
147
+ let n = {};
148
+ function r(e) {
149
+ let t = e.items.length;
150
+ for (let n of e.children) t += r(n);
151
+ return t;
152
+ }
153
+ function i(e, t) {
154
+ let n = e.items.find((e) => S(e.filepath) === u);
155
+ return n ? j(n.filepath) : k(`${t}/${e.name}`);
156
+ }
157
+ function a(e, t) {
158
+ for (let o of e) {
159
+ let e = t ? `${t}/${o.name}` : `/${o.name}`;
160
+ n[e] = {
161
+ title: _(o.name),
162
+ url: e,
163
+ subdirectories: o.children.map((t) => ({
164
+ name: _(t.name),
165
+ url: i(t, e),
166
+ count: r(t)
167
+ })),
168
+ items: o.items.map((e) => ({
169
+ name: R(e.header, e.filepath),
170
+ url: j(e.filepath)
171
+ }))
172
+ }, a(o.children, e);
173
+ }
174
+ }
175
+ return n["/"] = {
176
+ title: t,
177
+ url: "/",
178
+ subdirectories: e.map((e) => ({
179
+ name: _(e.name),
180
+ url: i(e, ""),
181
+ count: r(e)
182
+ })),
183
+ items: []
184
+ }, a(e, ""), n;
185
+ }
186
+ function L(e, t) {
187
+ let n = y(b(e));
188
+ return n ? _(n) : t;
189
+ }
190
+ function R(e, t) {
191
+ if (e._label !== void 0) return String(e._label);
192
+ let n = S(t);
193
+ if (n === "index") {
194
+ let e = y(b(t));
195
+ return e ? _(e) : n;
196
+ }
197
+ return _(n);
198
+ }
199
+ function z(e) {
200
+ e.children.sort((e, t) => {
201
+ let n = g(e.name), r = g(t.name);
202
+ return n.order === r.order ? n.rest.localeCompare(r.rest) : n.order - r.order;
203
+ }), e.items.sort((e, t) => {
204
+ let n = g(S(e.filepath)), r = g(S(t.filepath));
205
+ return n.order === r.order ? R(e.header, e.filepath).localeCompare(R(t.header, t.filepath)) : n.order - r.order;
206
+ });
207
+ for (let t of e.children) z(t);
208
+ }
209
+ //#endregion
210
+ //#region src/shared/utils/debounce.ts
211
+ function B(e, t) {
212
+ let n;
213
+ return (...r) => {
214
+ clearTimeout(n), n = setTimeout(() => e(...r), t);
215
+ };
216
+ }
217
+ //#endregion
218
+ //#region src/shared/utils/field.ts
219
+ function V(e) {
220
+ return e.startsWith("_");
221
+ }
222
+ //#endregion
223
+ //#region src/shared/utils/html.ts
224
+ function H(e) {
225
+ return e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
226
+ }
227
+ function U(e) {
228
+ return e.replace(/<(style|script)[^>]*>[\s\S]*?<\/\1>/gi, "").replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim();
229
+ }
230
+ //#endregion
231
+ //#region src/shared/utils/regex.ts
232
+ function W(e) {
233
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
234
+ }
235
+ //#endregion
236
+ //#region src/shared/utils/time.ts
237
+ var G = 60, K = 60 * G, q = 24 * K, J = 7 * q, Y = 30 * q, X = 365 * q, Z = 2 * J;
238
+ function Q(e) {
239
+ return (/* @__PURE__ */ new Date(e * 1e3)).toLocaleDateString("en-US", {
240
+ year: "numeric",
241
+ month: "short",
242
+ day: "numeric"
243
+ });
244
+ }
245
+ function ae(e, t) {
246
+ return Math.floor(Date.now() / 1e3) - e < Z ? `${t} ${$(e)}` : `${t} at ${Q(e)}`;
247
+ }
248
+ function $(e) {
249
+ let t = Math.floor(Date.now() / 1e3) - e;
250
+ return t < G ? "just now" : t < K ? `${Math.floor(t / G)}m ago` : t < q ? `${Math.floor(t / K)}h ago` : t < J ? `${Math.floor(t / q)}d ago` : t < Y ? `${Math.floor(t / J)}w ago` : t < X ? `${Math.floor(t / Y)}mo ago` : `${Math.floor(t / X)}y ago`;
251
+ }
252
+ var oe = new Intl.DateTimeFormat("en-US", {
253
+ year: "numeric",
254
+ month: "short",
255
+ day: "numeric"
256
+ });
257
+ function se(e) {
258
+ let t = new Date(e);
259
+ return Number.isNaN(t.getTime()) ? e : oe.format(t);
260
+ }
261
+ function ce(e) {
262
+ return Math.floor(Date.now() / 1e3) - e < Z ? $(e) : Q(e);
263
+ }
264
+ //#endregion
265
+ export { T as A, l as B, ne as C, S as D, P as E, f as F, u as I, p as L, _ as M, h as N, C as O, d as P, m as R, te as S, ie as T, k as _, ce as a, M as b, U as c, F as d, I as f, O as g, D as h, $ as i, g as j, v as k, V as l, R as m, se as n, W as o, L as p, ae as r, H as s, Q as t, B as u, A as v, re as w, N as x, j as y, o as z };
package/dist/shared.js ADDED
@@ -0,0 +1,2 @@
1
+ import { C as e, E as t, F as n, I as r, L as i, M as a, N as o, P as s, R as c, S as l, T as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, i as y, j as b, k as x, l as S, m as C, n as w, o as T, p as E, r as D, s as O, t as k, u as A, v as j, w as M, x as N, y as P } from "./shared-BIdsxcZ2.js";
2
+ export { s as CONTENT_EXTENSIONS, n as CONTENT_GLOB, o as EXTERNAL_URL_RE, r as INDEX_FILENAME, i as SEARCH_FIELDS, c as SEARCH_STORE_FIELDS, h as buildContentTree, g as buildDirectoryListingMap, A as debounce, O as escapeHtml, T as escapeRegex, k as formatAbsoluteTime, w as formatDateString, D as formatEditTime, y as formatRelativeTime, f as formatTime, v as getDirectoryFromPageUrl, _ as getDirectoryUrl, d as getIndexUrl, j as getParentUrl, P as getTdContentUrl, E as getTdIndexTitle, C as getTdResourceTitle, S as isBuiltinField, p as isIndexUrl, N as isUrlAncestorOf, l as isUrlExternal, e as isUrlToPage, b as parseNumericPrefix, x as path, M as resolveRootUrl, u as stripAnchor, m as stripHtml, t as stripTrailingSlash, a as unslugify };