typerighter 0.0.0 → 0.1.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.

Files changed (112) hide show
  1. package/LICENSE +674 -0
  2. package/dist/app-bn8sNpDS.js +180 -0
  3. package/dist/brand-DSd9HWVy.js +19 -0
  4. package/dist/chunk-DfAF0w94-EwUSVR-h.js +13 -0
  5. package/dist/client/app/components/Content.d.ts +4 -0
  6. package/dist/client/app/components/Content.d.ts.map +1 -0
  7. package/dist/client/app/composables/useTdContent.d.ts +4 -0
  8. package/dist/client/app/composables/useTdContent.d.ts.map +1 -0
  9. package/dist/client/app/composables/useTheme.d.ts +9 -0
  10. package/dist/client/app/composables/useTheme.d.ts.map +1 -0
  11. package/dist/client/app/index.d.ts +22 -0
  12. package/dist/client/app/index.d.ts.map +1 -1
  13. package/dist/client/app/router.d.ts +24 -0
  14. package/dist/client/app/router.d.ts.map +1 -0
  15. package/dist/client/index.d.ts +1 -0
  16. package/dist/client/index.d.ts.map +1 -1
  17. package/dist/client/theme-default.js +339 -0
  18. package/dist/client.js +2 -0
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +185 -4
  22. package/dist/lib-CBtriEt5-Ch50D04V.js +3309 -0
  23. package/dist/liteDOM-Cp0aN3bP-YwW1TGWI.js +741 -0
  24. package/dist/logger-DZLd8EDg.js +78 -0
  25. package/dist/node/build/codegen.d.ts +13 -0
  26. package/dist/node/build/codegen.d.ts.map +1 -0
  27. package/dist/node/build/html.d.ts +20 -0
  28. package/dist/node/build/html.d.ts.map +1 -0
  29. package/dist/node/build/index.d.ts +17 -0
  30. package/dist/node/build/index.d.ts.map +1 -0
  31. package/dist/node/build/render.d.ts +14 -0
  32. package/dist/node/build/render.d.ts.map +1 -0
  33. package/dist/node/cli/index.d.ts +2 -0
  34. package/dist/node/cli/index.d.ts.map +1 -0
  35. package/dist/node/cli/server.d.ts +5 -0
  36. package/dist/node/cli/server.d.ts.map +1 -0
  37. package/dist/node/index.d.ts +3 -1
  38. package/dist/node/index.d.ts.map +1 -1
  39. package/dist/node/lib/index.d.ts +4 -0
  40. package/dist/node/lib/index.d.ts.map +1 -0
  41. package/dist/node/lib/logger.d.ts +6 -0
  42. package/dist/node/lib/logger.d.ts.map +1 -0
  43. package/dist/node/lib/markdown/index.d.ts +5 -0
  44. package/dist/node/lib/markdown/index.d.ts.map +1 -0
  45. package/dist/node/lib/markdown/plugins/container.d.ts +3 -0
  46. package/dist/node/lib/markdown/plugins/container.d.ts.map +1 -0
  47. package/dist/node/lib/markdown/plugins/highlight.d.ts +2 -0
  48. package/dist/node/lib/markdown/plugins/highlight.d.ts.map +1 -0
  49. package/dist/node/lib/markdown/plugins/image.d.ts +3 -0
  50. package/dist/node/lib/markdown/plugins/image.d.ts.map +1 -0
  51. package/dist/node/lib/markdown/plugins/line-number.d.ts +3 -0
  52. package/dist/node/lib/markdown/plugins/line-number.d.ts.map +1 -0
  53. package/dist/node/lib/markdown/plugins/link.d.ts +3 -0
  54. package/dist/node/lib/markdown/plugins/link.d.ts.map +1 -0
  55. package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts +6 -0
  56. package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts.map +1 -0
  57. package/dist/node/lib/markdown/plugins/restore-entities.d.ts +3 -0
  58. package/dist/node/lib/markdown/plugins/restore-entities.d.ts.map +1 -0
  59. package/dist/node/lib/markdown/plugins/table.d.ts +3 -0
  60. package/dist/node/lib/markdown/plugins/table.d.ts.map +1 -0
  61. package/dist/node/lib/render/index.d.ts +2 -0
  62. package/dist/node/lib/render/index.d.ts.map +1 -0
  63. package/dist/node/lib/render/vue.d.ts +11 -0
  64. package/dist/node/lib/render/vue.d.ts.map +1 -0
  65. package/dist/node/lib/typedown-context.d.ts +29 -0
  66. package/dist/node/lib/typedown-context.d.ts.map +1 -0
  67. package/dist/node/plugin/codegen.d.ts +16 -0
  68. package/dist/node/plugin/codegen.d.ts.map +1 -0
  69. package/dist/node/plugin/codegen.test.d.ts +2 -0
  70. package/dist/node/plugin/codegen.test.d.ts.map +1 -0
  71. package/dist/node/plugin/constants.d.ts +4 -0
  72. package/dist/node/plugin/constants.d.ts.map +1 -0
  73. package/dist/node/plugin/index.d.ts +2 -0
  74. package/dist/node/plugin/index.d.ts.map +1 -0
  75. package/dist/node/plugin/vite.d.ts +3 -0
  76. package/dist/node/plugin/vite.d.ts.map +1 -0
  77. package/dist/shared/brand.d.ts +7 -0
  78. package/dist/shared/brand.d.ts.map +1 -0
  79. package/dist/shared/index.d.ts +3 -0
  80. package/dist/shared/index.d.ts.map +1 -1
  81. package/dist/shared/regexes.d.ts +2 -0
  82. package/dist/shared/regexes.d.ts.map +1 -0
  83. package/dist/shared/types/content.d.ts +10 -0
  84. package/dist/shared/types/content.d.ts.map +1 -0
  85. package/dist/shared/types/index.d.ts +4 -0
  86. package/dist/shared/types/index.d.ts.map +1 -0
  87. package/dist/shared/types/markdown.d.ts +62 -0
  88. package/dist/shared/types/markdown.d.ts.map +1 -0
  89. package/dist/shared/types/ssg.d.ts +23 -0
  90. package/dist/shared/types/ssg.d.ts.map +1 -0
  91. package/dist/shared/utils/content.d.ts +6 -0
  92. package/dist/shared/utils/content.d.ts.map +1 -0
  93. package/dist/shared/utils/environment.d.ts +2 -0
  94. package/dist/shared/utils/environment.d.ts.map +1 -0
  95. package/dist/shared/utils/highlight.d.ts +3 -0
  96. package/dist/shared/utils/highlight.d.ts.map +1 -0
  97. package/dist/shared/utils/index.d.ts +5 -0
  98. package/dist/shared/utils/index.d.ts.map +1 -0
  99. package/dist/shared/utils/url.d.ts +3 -0
  100. package/dist/shared/utils/url.d.ts.map +1 -0
  101. package/dist/shared-DzTfF-_d.js +14 -0
  102. package/dist/tex-svg-full-BI3fonbT-CfoPQ3xc.js +60224 -0
  103. package/dist/typedown-context-CWA07Yb7.js +9436 -0
  104. package/dist/typedown-context-D78bYNhH.js +2 -0
  105. package/dist/typerighter.css +2 -0
  106. package/dist/vite.js +174 -0
  107. package/dist/wgxpath.install-node-Csk64Aj9-C0enUGLs.js +1094 -0
  108. package/dist/xypic-DrMJn58R-B4fw2rYo.js +14846 -0
  109. package/package.json +49 -16
  110. package/dist/client/theme-default/index.d.ts +0 -1
  111. package/dist/client/theme-default/index.d.ts.map +0 -1
  112. package/dist/index.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,6 +1,187 @@
1
- //#region src/node/plugin.ts
2
- function e() {
3
- return { name: "vite-plugin-typedown" };
1
+ import { t as e } from "./logger-DZLd8EDg.js";
2
+ import { build as t, createServer as n } from "vite";
3
+ import r from "node:path";
4
+ import i from "node:fs/promises";
5
+ import a from "node:os";
6
+ //#region src/node/cli/server.ts
7
+ async function o(e = {}, t) {
8
+ return n({
9
+ root: t.root,
10
+ base: t.base,
11
+ cacheDir: t.cacheDir,
12
+ plugins: [],
13
+ server: e,
14
+ customLogger: t.logger,
15
+ configFile: t.configFile
16
+ });
4
17
  }
5
18
  //#endregion
6
- export { e as default };
19
+ //#region src/node/build/html.ts
20
+ function s(e) {
21
+ let t = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), n = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
22
+ return `<!DOCTYPE html>
23
+ <html lang="${e.lang ?? "en"}">
24
+ <head>
25
+ <meta charset="UTF-8">
26
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
27
+ <title>${c(e.title)}</title>
28
+ <meta name="description" content="${c(e.description)}">
29
+ ${t}
30
+ ${n}
31
+ </head>
32
+ <body>
33
+ <div id="app">${e.content}</div>
34
+ <script type="module" src="${e.base}${e.clientEntry}"><\/script>
35
+ </body>
36
+ </html>`;
37
+ }
38
+ function c(e) {
39
+ return e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
40
+ }
41
+ //#endregion
42
+ //#region src/node/build/render.ts
43
+ async function l(e) {
44
+ let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: a, jsFiles: o } = await u(e.clientOutDir);
45
+ for (let c = 0; c < e.pagePaths.length; c += 8) {
46
+ let l = e.pagePaths.slice(c, c + 8);
47
+ await Promise.all(l.map(async (c) => {
48
+ let l = await t.render(c), u = s({
49
+ content: l.html,
50
+ title: l.pageData.title,
51
+ description: l.pageData.frontmatter.description === void 0 ? "" : String(l.pageData.frontmatter.description),
52
+ clientEntry: n,
53
+ cssFiles: a,
54
+ jsFiles: o,
55
+ base: e.base
56
+ }), d = c === "/" ? "index.html" : `${c.replace(/^\//, "")}.html`, f = r.join(e.outDir, d);
57
+ await i.mkdir(r.dirname(f), { recursive: !0 }), await i.writeFile(f, u);
58
+ }));
59
+ }
60
+ }
61
+ async function u(e) {
62
+ let t = r.join(e, "assets"), n = [], a = await i.readdir(t).catch(() => n), o = [], s = [], c = "";
63
+ for (let e of a) e.endsWith(".css") ? o.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? c = `assets/${e}` : s.push(`assets/${e}`));
64
+ return !c && s.length > 0 && (c = s[0], s.splice(0, 1)), {
65
+ clientEntry: c,
66
+ cssFiles: o,
67
+ jsFiles: s
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/node/build/codegen.ts
72
+ function d(e) {
73
+ let t = `/${e.contentDir}/**/*.td`;
74
+ return `\
75
+ import { createTypedownApp } from '${e.typerighterPackage}/dist/client';
76
+ import Layout from '${e.layoutImport}';
77
+
78
+ const pages = import.meta.glob('${t}');
79
+
80
+ async function loadPageModule(pagePath) {
81
+ const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
82
+ const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
83
+ const loader = pages[key] || pages[altKey];
84
+ if (!loader) return undefined;
85
+ return loader();
86
+ }
87
+
88
+ async function main() {
89
+ const { app } = await createTypedownApp(loadPageModule, Layout);
90
+ app.mount('#app');
91
+ }
92
+
93
+ main();
94
+ `;
95
+ }
96
+ function f(e) {
97
+ let t = `/${e.contentDir}/**/*.td`;
98
+ return `\
99
+ import { createTypedownApp } from '${e.typerighterPackage}/dist/client';
100
+ import { renderToString } from 'vue/server-renderer';
101
+ import Layout from '${e.layoutImport}';
102
+
103
+ const pages = import.meta.glob('${t}', { eager: true });
104
+
105
+ function loadPageModule(pagePath) {
106
+ const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
107
+ const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
108
+ return Promise.resolve(pages[key] || pages[altKey]);
109
+ }
110
+
111
+ export async function render(url) {
112
+ const { app, router } = await createTypedownApp(loadPageModule, Layout);
113
+
114
+ await router.go(url, { replace: true });
115
+
116
+ const html = await renderToString(app);
117
+
118
+ return {
119
+ html,
120
+ pageData: router.route.data,
121
+ };
122
+ }
123
+ `;
124
+ }
125
+ //#endregion
126
+ //#region src/node/build/index.ts
127
+ async function p(n) {
128
+ let o = r.resolve(n.root), s = r.resolve(o, n.outDir ?? "dist"), c = n.base ?? "/", u = r.join(s, ".client"), p = r.join(s, ".server"), { tdContext: m } = await import("./typedown-context-D78bYNhH.js"), h = (await m.getConfig()).contentDir, g = await i.mkdtemp(r.join(a.tmpdir(), "typerighter-")), _ = {
129
+ contentDir: h,
130
+ layoutImport: n.layoutImport,
131
+ notFoundImport: n.notFoundImport,
132
+ typerighterPackage: "typerighter"
133
+ }, v = r.join(g, "client-entry.js"), y = r.join(g, "ssr-entry.js");
134
+ await i.writeFile(v, d(_)), await i.writeFile(y, f(_)), e.info("Phase 1: Building client bundle..."), await t({
135
+ ...n.viteConfig,
136
+ root: o,
137
+ base: c,
138
+ build: {
139
+ ...n.viteConfig?.build,
140
+ outDir: u,
141
+ ssrManifest: !0,
142
+ emptyOutDir: !0,
143
+ rollupOptions: {
144
+ ...n.viteConfig?.build?.rollupOptions,
145
+ input: v
146
+ }
147
+ }
148
+ }), e.info("Phase 2: Building SSR bundle..."), await t({
149
+ ...n.viteConfig,
150
+ root: o,
151
+ base: c,
152
+ build: {
153
+ ...n.viteConfig?.build,
154
+ outDir: p,
155
+ ssr: y,
156
+ emptyOutDir: !0
157
+ }
158
+ }), e.info("Phase 3: Pre-rendering pages...");
159
+ let b = (await m.listFiles()).map((e) => {
160
+ let t = e.replace(/\.td$/, "");
161
+ return t === "index" ? "/" : `/${t}`;
162
+ });
163
+ await l({
164
+ ssrEntryPath: r.join(p, "ssr-entry.js"),
165
+ clientOutDir: u,
166
+ outDir: s,
167
+ base: c,
168
+ pagePaths: b
169
+ });
170
+ let x = r.join(u, "assets"), S = r.join(s, "assets");
171
+ await i.cp(x, S, { recursive: !0 }).catch(() => {}), await Promise.all([
172
+ i.rm(g, {
173
+ recursive: !0,
174
+ force: !0
175
+ }),
176
+ i.rm(u, {
177
+ recursive: !0,
178
+ force: !0
179
+ }),
180
+ i.rm(p, {
181
+ recursive: !0,
182
+ force: !0
183
+ })
184
+ ]), e.info(`Build complete. Output: ${s}`);
185
+ }
186
+ //#endregion
187
+ export { p as buildSite, o as createViteServer };