typerighter 0.4.3 → 0.30.3

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.
Files changed (118) hide show
  1. package/dist/app-gH0dpuch.js +2382 -0
  2. package/dist/brand-CG1fQshq.js +5 -0
  3. package/dist/cli-BFgBPypP.js +440 -0
  4. package/dist/cli.js +1 -1
  5. package/dist/client/app/index.d.ts +43 -4
  6. package/dist/client/app/index.d.ts.map +1 -1
  7. package/dist/client/app/router.d.ts +6 -2
  8. package/dist/client/app/router.d.ts.map +1 -1
  9. package/dist/client/theme-default.js +2314 -593
  10. package/dist/client.js +1 -1
  11. package/dist/fonts.css +2 -0
  12. package/dist/index.js +3 -4
  13. package/dist/init-EKDV1L4U.js +821 -0
  14. package/dist/math.css +1 -0
  15. package/dist/node/build/index.d.ts.map +1 -1
  16. package/dist/node/build/prerender.d.ts +2 -0
  17. package/dist/node/build/prerender.d.ts.map +1 -1
  18. package/dist/node/cli/index.d.ts.map +1 -1
  19. package/dist/node/cli/init.d.ts +7 -1
  20. package/dist/node/cli/init.d.ts.map +1 -1
  21. package/dist/node/context.d.ts.map +1 -1
  22. package/dist/node/lib/html-template.d.ts +22 -0
  23. package/dist/node/lib/html-template.d.ts.map +1 -0
  24. package/dist/node/lib/image-dimensions.d.ts +6 -0
  25. package/dist/node/lib/image-dimensions.d.ts.map +1 -0
  26. package/dist/node/lib/index.d.ts +0 -1
  27. package/dist/node/lib/index.d.ts.map +1 -1
  28. package/dist/node/lib/progress.d.ts +2 -0
  29. package/dist/node/lib/progress.d.ts.map +1 -1
  30. package/dist/node/lib/render/highlight/index.d.ts.map +1 -0
  31. package/dist/node/lib/render/highlight/language.d.ts.map +1 -0
  32. package/dist/node/lib/render/postprocess.d.ts +2 -0
  33. package/dist/node/lib/render/postprocess.d.ts.map +1 -0
  34. package/dist/node/lib/render/vue.d.ts +1 -0
  35. package/dist/node/lib/render/vue.d.ts.map +1 -1
  36. package/dist/node/{plugin/vite/search.d.ts → lib/search-indexer/index.d.ts} +2 -3
  37. package/dist/node/lib/search-indexer/index.d.ts.map +1 -0
  38. package/dist/node/lib/search-indexer/scan.d.ts +4 -0
  39. package/dist/node/lib/search-indexer/scan.d.ts.map +1 -0
  40. package/dist/node/lib/typedown-context.d.ts +6 -10
  41. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  42. package/dist/node/plugin/vite/constants.d.ts +6 -0
  43. package/dist/node/plugin/vite/constants.d.ts.map +1 -1
  44. package/dist/node/plugin/vite/index.d.ts +7 -13
  45. package/dist/node/plugin/vite/index.d.ts.map +1 -1
  46. package/dist/node/plugin/vite/middleware/index.d.ts +3 -0
  47. package/dist/node/plugin/vite/middleware/index.d.ts.map +1 -0
  48. package/dist/node/plugin/vite/middleware/vault-assets.d.ts +5 -0
  49. package/dist/node/plugin/vite/middleware/vault-assets.d.ts.map +1 -0
  50. package/dist/node/plugin/vite/middleware/virtual-html.d.ts +6 -0
  51. package/dist/node/plugin/vite/middleware/virtual-html.d.ts.map +1 -0
  52. package/dist/node/plugin/vite/virtual/app.d.ts +23 -0
  53. package/dist/node/plugin/vite/virtual/app.d.ts.map +1 -0
  54. package/dist/node/plugin/vite/virtual/pages.d.ts +12 -0
  55. package/dist/node/plugin/vite/virtual/pages.d.ts.map +1 -0
  56. package/dist/node/plugin/vite/virtual/search-index.d.ts +11 -0
  57. package/dist/node/plugin/vite/virtual/search-index.d.ts.map +1 -0
  58. package/dist/node/plugin/vite/virtual/site-data.d.ts +13 -0
  59. package/dist/node/plugin/vite/virtual/site-data.d.ts.map +1 -0
  60. package/dist/node/plugin/vite/virtual/utils.d.ts +8 -0
  61. package/dist/node/plugin/vite/virtual/utils.d.ts.map +1 -0
  62. package/dist/shared/constants.d.ts.map +1 -1
  63. package/dist/shared/types/content.d.ts +42 -11
  64. package/dist/shared/types/content.d.ts.map +1 -1
  65. package/dist/shared/types/index.d.ts +0 -1
  66. package/dist/shared/types/index.d.ts.map +1 -1
  67. package/dist/shared/types/ssg.d.ts +15 -3
  68. package/dist/shared/types/ssg.d.ts.map +1 -1
  69. package/dist/shared/utils/content.d.ts +5 -3
  70. package/dist/shared/utils/content.d.ts.map +1 -1
  71. package/dist/shared/utils/field.d.ts +2 -0
  72. package/dist/shared/utils/field.d.ts.map +1 -0
  73. package/dist/shared/utils/html.d.ts +1 -0
  74. package/dist/shared/utils/html.d.ts.map +1 -1
  75. package/dist/shared/utils/index.d.ts +1 -0
  76. package/dist/shared/utils/index.d.ts.map +1 -1
  77. package/dist/shared/utils/path.d.ts +1 -0
  78. package/dist/shared/utils/path.d.ts.map +1 -1
  79. package/dist/shared/utils/url.d.ts +9 -1
  80. package/dist/shared/utils/url.d.ts.map +1 -1
  81. package/dist/shared-BuA2cqMO.js +401 -0
  82. package/dist/shared.js +2 -0
  83. package/dist/temml-DZbhOfRE.js +8146 -0
  84. package/dist/typerighter.css +1 -1
  85. package/dist/vite-CYozrIIG.js +1468 -0
  86. package/dist/vite.js +2 -2
  87. package/package.json +26 -40
  88. package/dist/app-Bw90hv7G.js +0 -266
  89. package/dist/brand-CmL-6h9U.js +0 -203
  90. package/dist/cli-BbvLsY1i.js +0 -640
  91. package/dist/constants-7heqadyd.js +0 -32183
  92. package/dist/init-DCkztTxJ.js +0 -2356
  93. package/dist/node/lib/markdown/index.d.ts +0 -5
  94. package/dist/node/lib/markdown/index.d.ts.map +0 -1
  95. package/dist/node/lib/markdown/plugins/callout-container.d.ts +0 -4
  96. package/dist/node/lib/markdown/plugins/callout-container.d.ts.map +0 -1
  97. package/dist/node/lib/markdown/plugins/custom-container.d.ts +0 -3
  98. package/dist/node/lib/markdown/plugins/custom-container.d.ts.map +0 -1
  99. package/dist/node/lib/markdown/plugins/highlight/index.d.ts.map +0 -1
  100. package/dist/node/lib/markdown/plugins/highlight/language.d.ts.map +0 -1
  101. package/dist/node/lib/markdown/plugins/image.d.ts +0 -3
  102. package/dist/node/lib/markdown/plugins/image.d.ts.map +0 -1
  103. package/dist/node/lib/markdown/plugins/line-number.d.ts +0 -3
  104. package/dist/node/lib/markdown/plugins/line-number.d.ts.map +0 -1
  105. package/dist/node/lib/markdown/plugins/link.d.ts +0 -3
  106. package/dist/node/lib/markdown/plugins/link.d.ts.map +0 -1
  107. package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts +0 -6
  108. package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts.map +0 -1
  109. package/dist/node/lib/markdown/plugins/restore-entities.d.ts +0 -3
  110. package/dist/node/lib/markdown/plugins/restore-entities.d.ts.map +0 -1
  111. package/dist/node/lib/markdown/plugins/table.d.ts +0 -3
  112. package/dist/node/lib/markdown/plugins/table.d.ts.map +0 -1
  113. package/dist/node/plugin/vite/search.d.ts.map +0 -1
  114. package/dist/shared/types/markdown.d.ts +0 -62
  115. package/dist/shared/types/markdown.d.ts.map +0 -1
  116. package/dist/vite-B-ktlRz9.js +0 -309
  117. /package/dist/node/lib/{markdown/plugins → render}/highlight/index.d.ts +0 -0
  118. /package/dist/node/lib/{markdown/plugins → render}/highlight/language.d.ts +0 -0
@@ -1,5 +0,0 @@
1
- import { MarkdownItAsync } from 'markdown-it-async';
2
- import type { TdSiteConfig } from '@typerighter/rpc-client';
3
- export type MarkdownRenderer = MarkdownItAsync;
4
- export declare function createMarkdownRenderer(config: TdSiteConfig): Promise<MarkdownRenderer>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/lib/markdown/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EACL,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EACV,YAAY,EACb,MAAM,yBAAyB,CAAC;AA8BjC,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAmH3B"}
@@ -1,4 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function calloutContainerPlugin(md: MarkdownItAsync): void;
3
- export declare const DEFAULT_TITLES: Record<string, string>;
4
- //# sourceMappingURL=callout-container.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"callout-container.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/callout-container.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAK3B,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,eAAe,GAClB,IAAI,CAQN;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASjD,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function componentContainerPlugin(md: MarkdownItAsync): void;
3
- //# sourceMappingURL=custom-container.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-container.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/custom-container.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AA8B3B,wBAAgB,wBAAwB,CAAE,EAAE,EAAE,eAAe,GAAG,IAAI,CA8LnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/node/lib/markdown/plugins/highlight/index.ts"],"names":[],"mappings":"AAqCA,wBAAsB,iBAAiB,IAAK,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAuIzH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../../../../../src/node/lib/markdown/plugins/highlight/language.ts"],"names":[],"mappings":"AASA,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAKD,wBAAgB,eAAe,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function imagePlugin(md: MarkdownItAsync): void;
3
- //# sourceMappingURL=image.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/image.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAS3B,wBAAgB,WAAW,CACzB,EAAE,EAAE,eAAe,GAClB,IAAI,CA0BN"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function lineNumberPlugin(md: MarkdownItAsync, enable?: boolean): void;
3
- //# sourceMappingURL=line-number.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"line-number.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/line-number.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,gBAAgB,CAAE,EAAE,EAAE,eAAe,EAAE,MAAM,UAAQ,GAAG,IAAI,CAsD3E"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function linkPlugin(md: MarkdownItAsync, externalAttrs: Record<string, string>, base: string, slugify: (string_: string) => string): void;
3
- //# sourceMappingURL=link.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/link.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAa3B,wBAAgB,UAAU,CACxB,EAAE,EAAE,eAAe,EACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACnC,IAAI,CA4JN"}
@@ -1,6 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export interface PreWrapperOptions {
3
- languageLabel?: Record<string, string>;
4
- }
5
- export declare function preWrapperPlugin(md: MarkdownItAsync, options?: PreWrapperOptions): void;
6
- //# sourceMappingURL=pre-wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pre-wrapper.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/pre-wrapper.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAK3B,MAAM,WAAW,iBAAiB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,wBAAgB,gBAAgB,CAAE,EAAE,EAAE,eAAe,EAAE,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAkC5F"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function restoreEntities(md: MarkdownItAsync): void;
3
- //# sourceMappingURL=restore-entities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restore-entities.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/restore-entities.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAO3B,wBAAgB,eAAe,CAAE,EAAE,EAAE,eAAe,GAAG,IAAI,CAK1D"}
@@ -1,3 +0,0 @@
1
- import type { MarkdownItAsync } from 'markdown-it-async';
2
- export declare function tablePlugin(md: MarkdownItAsync): void;
3
- //# sourceMappingURL=table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../src/node/lib/markdown/plugins/table.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,WAAW,CAAE,EAAE,EAAE,eAAe,GAAG,IAAI,CAiBtD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/search.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAeD,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAA+B;IAE5C,OAAO,CAAC,UAAU,CAA+B;;IAUjD,MAAM,CAAE,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI;IAatC,OAAO,CAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IA2BpC,WAAW,CAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAUlC,SAAS,IAAK,MAAM;CAGrB"}
@@ -1,62 +0,0 @@
1
- export interface MarkdownEnv {
2
- /**
3
- * The raw Markdown content without frontmatter
4
- */
5
- content?: string;
6
- /**
7
- * The excerpt that extracted by `@mdit-vue/plugin-frontmatter`
8
- *
9
- * - Would be the rendered HTML when `renderExcerpt` is enabled
10
- * - Would be the raw Markdown when `renderExcerpt` is disabled
11
- */
12
- excerpt?: string;
13
- /**
14
- * The frontmatter that extracted by `@mdit-vue/plugin-frontmatter`
15
- */
16
- frontmatter?: Record<string, unknown>;
17
- /**
18
- * Populated by `@mdit-vue/plugin-headers`
19
- */
20
- headers?: MarkdownHeading[];
21
- /**
22
- * The title that extracted by `@mdit-vue/plugin-title`
23
- */
24
- title?: string;
25
- path: string;
26
- relativePath: string;
27
- cleanUrls: boolean;
28
- links?: string[];
29
- linkLines?: number[];
30
- includes?: string[];
31
- realPath?: string;
32
- localeIndex?: string;
33
- }
34
- export interface MarkdownHeading {
35
- /**
36
- * The level of the header
37
- *
38
- * `1` to `6` for `<h1>` to `<h6>`
39
- */
40
- level: number;
41
- /**
42
- * The title of the header
43
- */
44
- title: string;
45
- /**
46
- * The slug of the header
47
- *
48
- * Typically the `id` attr of the header anchor
49
- */
50
- slug: string;
51
- /**
52
- * Link of the header
53
- *
54
- * Typically using `#${slug}` as the anchor hash
55
- */
56
- link: string;
57
- /**
58
- * The children of the header
59
- */
60
- children: MarkdownHeading[];
61
- }
62
- //# sourceMappingURL=markdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/shared/types/markdown.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B"}
@@ -1,309 +0,0 @@
1
- import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-7heqadyd.js";
2
- import { A as o, E as s, O as c, S as l, _ as u, d, f, k as p, l as m, m as h, p as g, r as _, u as v, x as y } from "./brand-CmL-6h9U.js";
3
- import { t as b } from "./es-ClqUVRJn.js";
4
- import { resolve as x } from "node:path";
5
- import S from "@tailwindcss/vite";
6
- import C from "@vitejs/plugin-vue";
7
- import { normalizePath as w } from "vite";
8
- import { createRequire as T } from "node:module";
9
- //#region src/node/lib/render/vue.ts
10
- async function E(e, t, n) {
11
- let r = {
12
- path: n,
13
- relativePath: n,
14
- cleanUrls: !0
15
- }, i = await e.md.renderAsync(t.content, r), a = y(n) === c, o = r.title || (a ? g(n, (await e.getConfig()).siteTitle) : h(t.header, n)), s = {
16
- schema: t.schema,
17
- frontmatter: t.header,
18
- headings: r.headers ?? [],
19
- title: o,
20
- metadata: t.metadata
21
- };
22
- return {
23
- vueSrc: [
24
- "<script>",
25
- `export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(s))})`,
26
- `export default { name: ${JSON.stringify(n)} }`,
27
- "<\/script>",
28
- `<template><div class="typedown-content">\n${D(i)}\n</div></template>`
29
- ].join("\n"),
30
- pageData: s
31
- };
32
- }
33
- function D(e) {
34
- return e.replaceAll("{{", "&#123;&#123;");
35
- }
36
- //#endregion
37
- //#region src/node/plugin/vite/search.ts
38
- var O = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, k = /(.*)<a.*? href="#(.*?)".*?>.*?<\/a>/i, A = class {
39
- index;
40
- pageDocIds = /* @__PURE__ */ new Map();
41
- constructor() {
42
- this.index = new b({
43
- fields: p,
44
- storeFields: o
45
- });
46
- }
47
- addAll(e) {
48
- let t = new Set(e.map((e) => e.id));
49
- for (let e of this.pageDocIds.keys()) t.has(e) || this.discardPage(e);
50
- for (let t of e) this.addPage(t);
51
- }
52
- addPage(e) {
53
- this.discardPage(e.id);
54
- let t = [];
55
- for (let n of j(e.html)) {
56
- let r = n.anchor ? `${e.id}#${n.anchor}` : e.id;
57
- this.index.has(r) && this.index.discard(r), this.index.add({
58
- id: r,
59
- text: n.text,
60
- title: n.titles.at(-1) ?? e.title,
61
- titles: 1 < n.titles.length ? n.titles.slice(0, -1) : [e.title]
62
- }), t.push(r);
63
- }
64
- this.pageDocIds.set(e.id, t);
65
- }
66
- discardPage(e) {
67
- let t = this.pageDocIds.get(e);
68
- if (t) {
69
- for (let e of t) this.index.has(e) && this.index.discard(e);
70
- this.pageDocIds.delete(e);
71
- }
72
- }
73
- serialize() {
74
- return JSON.stringify(this.index);
75
- }
76
- };
77
- function* j(e) {
78
- let t = e.split(O);
79
- t.shift();
80
- let n = [];
81
- for (let e = 0; e < t.length; e += 3) {
82
- let r = Number.parseInt(t[e]) - 1, i = t[e + 1], a = k.exec(i), o = v(a?.[1] ?? "").trim(), s = a?.[2] ?? "", c = t[e + 2];
83
- if (!o || !c) continue;
84
- let l = n.slice(0, r);
85
- l[r] = o, yield {
86
- anchor: s,
87
- titles: l.filter(Boolean),
88
- text: v(c)
89
- }, r === 0 ? (n.length = 0, n[0] = o) : n[r] = o;
90
- }
91
- }
92
- //#endregion
93
- //#region src/node/plugin/vite/alias.ts
94
- var M = T(import.meta.url);
95
- function N() {
96
- return [{
97
- find: "vue/server-renderer",
98
- replacement: M.resolve("vue/server-renderer")
99
- }, {
100
- find: "vue",
101
- replacement: M.resolve("vue/dist/vue.runtime.esm-bundler.js")
102
- }];
103
- }
104
- //#endregion
105
- //#region src/node/plugin/vite/index.ts
106
- function P(e) {
107
- let { contentDir: t } = e, n = `/${t}/**/*.{td,md}`, i = JSON.stringify({
108
- title: e.siteTitle,
109
- description: e.siteDescription
110
- }), a = JSON.stringify({
111
- contentTree: e.contentTree,
112
- schemas: e.schemas ?? {}
113
- }), o = f(e.contentTree.children, e.siteTitle);
114
- return `
115
- import 'typerighter/style.css';
116
- import { createTypedownApp } from 'typerighter/client';
117
- import { TdDirectoryIndex } from 'typerighter/client/theme-default';
118
- import { h } from 'vue';
119
- import theme from 'typerighter/client/theme-default';
120
- import searchIndex from '${r}';
121
-
122
- const pages = import.meta.glob('${n}');
123
- const contentExts = ${JSON.stringify(s)};
124
-
125
- const directoryIndex = ${JSON.stringify(o)};
126
-
127
- function findPage(base) {
128
- for (const ext of contentExts) {
129
- const key = base + ext;
130
- if (pages[key]) return pages[key];
131
- const indexKey = base + '/index' + ext;
132
- if (pages[indexKey]) return pages[indexKey];
133
- }
134
- }
135
-
136
- async function loadPageModule(pagePath) {
137
- const base = ('/${t}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
138
- const loader = findPage(base);
139
- if (loader) return loader();
140
-
141
- const dir = directoryIndex[pagePath] || directoryIndex[pagePath + '/'];
142
- if (dir) return {
143
- default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex, dir); } },
144
- __pageData: { frontmatter: {}, headings: [], title: dir.title },
145
- };
146
-
147
- return undefined;
148
- }
149
-
150
- const { app, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme.Layout, ${i}, { ...${a}, searchIndex });
151
- app.mount('#app');
152
-
153
- // Accept HMR for the search index so it updates without a full reload
154
- if (import.meta.hot) {
155
- import.meta.hot.accept('${r}', (m) => {
156
- if (m) searchIndexRef.value = m.default;
157
- });
158
- }
159
- `;
160
- }
161
- function F(r = {}) {
162
- let o = r.context, s, c = new A(), u;
163
- function f() {
164
- if (o === void 0) throw Error("typedown plugin not initialized");
165
- return o.getTdContext();
166
- }
167
- return [
168
- {
169
- name: "vite-plugin-typedown",
170
- enforce: "pre",
171
- configResolved(e) {
172
- o ||= n(i(e.root));
173
- },
174
- config() {
175
- return {
176
- resolve: { alias: N() },
177
- ssr: { noExternal: ["typerighter"] }
178
- };
179
- },
180
- resolveId(e) {
181
- if (e === "/@typedown/app" || e === "@typedown/app") return t;
182
- if (e === "@typedown/search-index") return a;
183
- },
184
- async load(e) {
185
- if (e === "\0@typedown/search-index") return u ||= B(await f(), c), await u, `export default ${JSON.stringify(c.serialize())}`;
186
- if (e !== "\0@typedown/app") return;
187
- let t = await f(), [n, r, i] = await Promise.all([
188
- t.getConfig(),
189
- t.listFilesGroupedBySchema(),
190
- t.listSchemas()
191
- ]), a = await Promise.all(i.map(async (e) => [e, (await t.getSchema(e)).properties])), o = Object.fromEntries(a), s = d(Object.values(r).flat());
192
- return P({
193
- ...n,
194
- contentTree: s,
195
- schemas: o
196
- });
197
- },
198
- async configureServer(t) {
199
- s = t;
200
- let n = await f();
201
- n.rpc.onConfigChanged(() => s && R(s)), n.rpc.onContentChanged(({ content: e }) => {
202
- s && (I(n, e).then((e) => {
203
- e && s && (c.addPage(e), V(s));
204
- }).catch(() => {}), n.getConfig().then((t) => {
205
- if (!s) return;
206
- let n = w(x(s.config.root, t.contentDir, e)), r = s.moduleGraph.getModulesByFile(n);
207
- if (!r?.size) return;
208
- let i = [...r].map((e) => (s?.moduleGraph.invalidateModule(e), H(e)));
209
- s.hot.send({
210
- type: "update",
211
- updates: i
212
- });
213
- }).catch(() => {}));
214
- });
215
- function r() {
216
- s && (u = B(n, c), u.then(() => {
217
- s && V(s);
218
- }), z(s));
219
- }
220
- return n.rpc.onContentCreated(r), n.rpc.onContentDeleted(r), n.rpc.onSchemaChanged(() => s && z(s)), n.rpc.onSchemaCreated(() => s && z(s)), n.rpc.onSchemaDeleted(() => s && z(s)), () => {
221
- t.middlewares.use((t, r, i) => {
222
- if (!t.url || r.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return i();
223
- n.getConfig().then((t) => {
224
- let n = `<!DOCTYPE html>
225
- <html lang="en">
226
- <head>
227
- <meta charset="UTF-8">
228
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
229
- <title>${m(t.siteTitle)}</title>
230
- <link rel="icon" type="image/svg+xml" href="${_}">
231
- </head>
232
- <body>
233
- <div id="app"></div>
234
- <script type="module" src="/${e}"><\/script>
235
- </body>
236
- </html>`;
237
- r.setHeader("Content-Type", "text/html"), r.end(n);
238
- }).catch(i);
239
- });
240
- };
241
- },
242
- async transform(e, t) {
243
- let n = t.split("?")[0];
244
- if (!l(n)) return;
245
- let r = await f(), i = (await r.getConfig()).contentDir, a = n.includes(i) ? n.slice(n.indexOf(i) + i.length + 1) : n, { vueSrc: o } = await E(r, await r.getFile(a), a);
246
- return {
247
- code: o,
248
- map: null
249
- };
250
- },
251
- handleHotUpdate({ file: e }) {
252
- if (l(e)) return [];
253
- }
254
- },
255
- C({ include: /\.(?:vue|td)$/ }),
256
- ...S()
257
- ];
258
- }
259
- async function I(e, t) {
260
- try {
261
- let n = await e.getFile(t), r = await e.md.renderAsync(n.content, {
262
- path: t,
263
- relativePath: t,
264
- cleanUrls: !0
265
- });
266
- return {
267
- id: u(t),
268
- title: h(n.header, t),
269
- html: r
270
- };
271
- } catch {
272
- return;
273
- }
274
- }
275
- function L(e) {
276
- return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
277
- }
278
- function R(e) {
279
- for (let t of L(e)) e.moduleGraph.invalidateModule(t);
280
- e.hot.send({ type: "full-reload" });
281
- }
282
- function z(e) {
283
- let t = L(e).map((t) => (e.moduleGraph.invalidateModule(t), H(t)));
284
- 0 < t.length && e.hot.send({
285
- type: "update",
286
- updates: t
287
- });
288
- }
289
- async function B(e, t) {
290
- let n = await e.listFiles(), r = await Promise.all(n.map((t) => I(e, t)));
291
- t.addAll(r.filter((e) => e !== void 0));
292
- }
293
- function V(e) {
294
- let t = e.moduleGraph.getModuleById(a);
295
- t && (e.moduleGraph.invalidateModule(t), e.hot.send({
296
- type: "update",
297
- updates: [H(t)]
298
- }));
299
- }
300
- function H(e) {
301
- return {
302
- type: "js-update",
303
- path: e.url,
304
- acceptedPath: e.url,
305
- timestamp: Date.now()
306
- };
307
- }
308
- //#endregion
309
- export { F as n, P as t };