typerighter 0.1.2 → 0.1.4

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 (45) hide show
  1. package/bin/typedown.js +3 -0
  2. package/dist/{app-bn8sNpDS.js → app-CM3biamr.js} +18 -14
  3. package/dist/client/app/composables/useTdContent.d.ts +2 -1
  4. package/dist/client/app/composables/useTdContent.d.ts.map +1 -1
  5. package/dist/client/theme-default.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/index.js +103 -163
  8. package/dist/node/build/html.d.ts +1 -0
  9. package/dist/node/build/html.d.ts.map +1 -1
  10. package/dist/node/build/html.test.d.ts +2 -0
  11. package/dist/node/build/html.test.d.ts.map +1 -0
  12. package/dist/node/build/index.d.ts +0 -4
  13. package/dist/node/build/index.d.ts.map +1 -1
  14. package/dist/node/cli/index.d.ts +1 -1
  15. package/dist/node/cli/index.d.ts.map +1 -1
  16. package/dist/node/cli/init.d.ts +2 -0
  17. package/dist/node/cli/init.d.ts.map +1 -0
  18. package/dist/node/index.d.ts +0 -1
  19. package/dist/node/index.d.ts.map +1 -1
  20. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  21. package/dist/node/plugin/{codegen.d.ts → vite/codegen.d.ts} +11 -0
  22. package/dist/node/plugin/vite/codegen.d.ts.map +1 -0
  23. package/dist/node/plugin/vite/codegen.test.d.ts.map +1 -0
  24. package/dist/node/plugin/vite/constants.d.ts.map +1 -0
  25. package/dist/node/plugin/{vite.d.ts → vite/index.d.ts} +1 -1
  26. package/dist/node/plugin/vite/index.d.ts.map +1 -0
  27. package/dist/plugin-C-rHOs3n.js +228 -0
  28. package/dist/{typedown-context-CWA07Yb7.js → typedown-context-WluCH44c.js} +82 -7
  29. package/dist/typedown-context-lK0KGe3B.js +2 -0
  30. package/dist/vite.js +2 -174
  31. package/package.json +10 -6
  32. package/dist/logger-DZLd8EDg.js +0 -78
  33. package/dist/node/build/codegen.d.ts +0 -13
  34. package/dist/node/build/codegen.d.ts.map +0 -1
  35. package/dist/node/cli/server.d.ts +0 -5
  36. package/dist/node/cli/server.d.ts.map +0 -1
  37. package/dist/node/plugin/codegen.d.ts.map +0 -1
  38. package/dist/node/plugin/codegen.test.d.ts.map +0 -1
  39. package/dist/node/plugin/constants.d.ts.map +0 -1
  40. package/dist/node/plugin/vite.d.ts.map +0 -1
  41. package/dist/node/plugin.d.ts +0 -3
  42. package/dist/node/plugin.d.ts.map +0 -1
  43. package/dist/typedown-context-D78bYNhH.js +0 -2
  44. /package/dist/node/plugin/{codegen.test.d.ts → vite/codegen.test.d.ts} +0 -0
  45. /package/dist/node/plugin/{constants.d.ts → vite/constants.d.ts} +0 -0
@@ -0,0 +1,228 @@
1
+ import { n as e } from "./typedown-context-WluCH44c.js";
2
+ import "./shared-DzTfF-_d.js";
3
+ import { c as t, r as n } from "./brand-DSd9HWVy.js";
4
+ import r from "@tailwindcss/vite";
5
+ import i from "@vitejs/plugin-vue";
6
+ //#region src/node/lib/render/vue.ts
7
+ async function a(e, n, r) {
8
+ let i = {
9
+ path: r,
10
+ relativePath: r,
11
+ cleanUrls: !0
12
+ }, a = await e.renderAsync(n.content, i), o = i.title || t(n.header, r), s = {
13
+ schema: n.schema,
14
+ frontmatter: n.header,
15
+ headings: i.headers ?? [],
16
+ title: o
17
+ }, c = JSON.stringify(JSON.stringify(s)), l = JSON.stringify(a);
18
+ return {
19
+ vueSrc: [
20
+ "<script>",
21
+ `export const __pageData = JSON.parse(${c})`,
22
+ `export default { name: ${JSON.stringify(r)}, data() { return { __html: ${l} } } }`,
23
+ "<\/script>",
24
+ "<template><div v-html=\"__html\" /></template>"
25
+ ].join("\n"),
26
+ pageData: s
27
+ };
28
+ }
29
+ //#endregion
30
+ //#region src/node/build/html.ts
31
+ function o(e) {
32
+ 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");
33
+ return `<!DOCTYPE html>
34
+ <html lang="${e.lang ?? "en"}">
35
+ <head>
36
+ <meta charset="UTF-8">
37
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
38
+ <title>${s(e.title)}</title>
39
+ <meta name="description" content="${s(e.description)}">
40
+ ${t}
41
+ ${n}
42
+ </head>
43
+ <body>
44
+ <div id="app">${e.content}</div>
45
+ <script type="module" src="${e.base}${e.clientEntry}"><\/script>
46
+ </body>
47
+ </html>`;
48
+ }
49
+ function s(e) {
50
+ return e.replaceAll("&", "&amp;").replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
51
+ }
52
+ //#endregion
53
+ //#region src/node/plugin/vite/constants.ts
54
+ var c = "@typedown/app", l = "\0@typedown/app", u = "__typedown_index__.td";
55
+ //#endregion
56
+ //#region src/node/plugin/vite/codegen.ts
57
+ function d(e) {
58
+ let { contentDir: t, hasIndex: n } = e;
59
+ return `
60
+ import 'typerighter/style.css';
61
+ import { createTypedownApp } from 'typerighter/client';
62
+ import theme from 'typerighter/client/theme-default';
63
+
64
+ const pages = import.meta.glob('${`/${t}/**/*.td`}');
65
+ ${n ? "" : `pages['/${t}/${u}'] = () => import('${u}');`}
66
+
67
+ async function loadPageModule(pagePath) {
68
+ const key = '/${t}/' + pagePath.replace(/^\\//, '') + '.td';
69
+ const altKey = '/${t}/' + pagePath.replace(/^\\//, '') + '/index.td';
70
+ const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${u}'] : undefined)`};
71
+ if (!loader) return undefined;
72
+ return loader();
73
+ }
74
+
75
+ const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
76
+ title: e.siteTitle,
77
+ description: e.siteDescription
78
+ })}, ${JSON.stringify({ sidebarGroups: e.sidebarGroups })});
79
+ app.mount('#app');
80
+ `;
81
+ }
82
+ function f(e) {
83
+ let t = JSON.stringify(e).replace(/'/g, "\\'"), n = JSON.stringify({
84
+ schema: "",
85
+ frontmatter: {},
86
+ headings: [],
87
+ title: "Index"
88
+ });
89
+ return `<script>
90
+ import { TdOverview } from 'typerighter/client/theme-default';
91
+ export const __pageData = JSON.parse(${JSON.stringify(n)})
92
+ export default { name: "index", components: { TdOverview } }
93
+ <\/script>
94
+ <template><TdOverview :groups='${t}' /></template>`;
95
+ }
96
+ function p(e) {
97
+ let t = `/${e.contentDir}/**/*.td`;
98
+ return `
99
+ import { createTypedownApp } from 'typerighter/client';
100
+ import { renderToString } from 'vue/server-renderer';
101
+ import theme 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, theme.Layout, ${e.siteConfig}, ${e.siteData});
113
+ await router.go(url, { replace: true });
114
+ const html = await renderToString(app);
115
+ return { html, pageData: router.route.data };
116
+ }
117
+ `;
118
+ }
119
+ //#endregion
120
+ //#region src/node/plugin/vite/index.ts
121
+ function m() {
122
+ let t;
123
+ return [
124
+ {
125
+ name: "vite-plugin-typedown",
126
+ enforce: "pre",
127
+ async transformIndexHtml(t) {
128
+ let r = await e.getConfig();
129
+ return t.replace(/<title>.*?<\/title>/, `<title>${s(r.siteTitle)}</title>`).replace("</head>", ` <link rel="icon" type="image/svg+xml" href="${n}">\n</head>`).replace("</body>", ` <script type="module" src="/${c}"><\/script>\n</body>`);
130
+ },
131
+ resolveId(e) {
132
+ if (e === "/@typedown/app" || e === "@typedown/app") return l;
133
+ if (e.endsWith("__typedown_index__.td")) return e;
134
+ },
135
+ async load(t) {
136
+ if (t === "\0@typedown/app") {
137
+ let [t, n, r] = await Promise.all([
138
+ e.getConfig(),
139
+ e.listFiles(),
140
+ e.listFilesGroupedBySchema()
141
+ ]), i = n.some((e) => e === "index.td");
142
+ return d({
143
+ ...t,
144
+ hasIndex: i,
145
+ sidebarGroups: r
146
+ });
147
+ }
148
+ if (t.endsWith("__typedown_index__.td")) return f(await e.listFilesGroupedBySchema());
149
+ },
150
+ configureServer(r) {
151
+ return t = r, e.rpc.onConfigChanged(() => t && g(t)), e.rpc.onContentChanged(({ content: e }) => {
152
+ if (t) {
153
+ for (let n of t.moduleGraph.idToModuleMap.values()) if (n.file?.endsWith(e)) {
154
+ t.moduleGraph.invalidateModule(n), t.hot.send({
155
+ type: "update",
156
+ updates: [{
157
+ type: "js-update",
158
+ path: n.url,
159
+ acceptedPath: n.url,
160
+ timestamp: Date.now()
161
+ }]
162
+ });
163
+ break;
164
+ }
165
+ }
166
+ }), e.rpc.onContentCreated(() => t && _(t)), e.rpc.onContentDeleted(() => t && _(t)), e.rpc.onSchemaChanged(() => t && _(t)), e.rpc.onSchemaCreated(() => t && _(t)), e.rpc.onSchemaDeleted(() => t && _(t)), () => {
167
+ r.middlewares.use((t, r, i) => {
168
+ if (!t.url || r.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return i();
169
+ e.getConfig().then((e) => {
170
+ let t = `<!DOCTYPE html>
171
+ <html lang="en">
172
+ <head>
173
+ <meta charset="UTF-8">
174
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
175
+ <title>${s(e.siteTitle)}</title>
176
+ <link rel="icon" type="image/svg+xml" href="${n}">
177
+ </head>
178
+ <body>
179
+ <div id="app"></div>
180
+ <script type="module" src="/${c}"><\/script>
181
+ </body>
182
+ </html>`;
183
+ r.setHeader("Content-Type", "text/html"), r.end(t);
184
+ }).catch(i);
185
+ });
186
+ };
187
+ },
188
+ async transform(t, n) {
189
+ let r = n.split("?")[0];
190
+ if (!r.endsWith(".td") || r.includes("__typedown_index__.td")) return;
191
+ let i = (await e.getConfig()).contentDir, o = r.includes(i) ? r.slice(r.indexOf(i) + i.length + 1) : r, s = await e.getFile(o), { vueSrc: c } = await a(e.md, s, o);
192
+ return {
193
+ code: c,
194
+ map: null
195
+ };
196
+ },
197
+ handleHotUpdate({ file: e }) {
198
+ if (e.endsWith(".td")) return [];
199
+ }
200
+ },
201
+ i({ include: /\.(?:vue|td)$/ }),
202
+ ...r()
203
+ ];
204
+ }
205
+ function h(e) {
206
+ return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
207
+ }
208
+ function g(e) {
209
+ for (let t of h(e)) e.moduleGraph.invalidateModule(t);
210
+ e.hot.send({ type: "full-reload" });
211
+ }
212
+ function _(e) {
213
+ let t = h(e).map((t) => (e.moduleGraph.invalidateModule(t), v(t)));
214
+ 0 < t.length && e.hot.send({
215
+ type: "update",
216
+ updates: t
217
+ });
218
+ }
219
+ function v(e) {
220
+ return {
221
+ type: "js-update",
222
+ path: e.url,
223
+ acceptedPath: e.url,
224
+ timestamp: Date.now()
225
+ };
226
+ }
227
+ //#endregion
228
+ export { o as i, d as n, p as r, m as t };
@@ -1,4 +1,3 @@
1
- import { i as __toESM, n as __commonJSMin, r as __exportAll, t as logger } from "./logger-DZLd8EDg.js";
2
1
  import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
3
2
  import { n as isLinkToPage, r as EXTERNAL_URL_RE, t as isExternal } from "./shared-DzTfF-_d.js";
4
3
  import path from "node:path";
@@ -8,8 +7,24 @@ import MarkdownIt from "markdown-it";
8
7
  import { createHighlighter, guessEmbeddedLanguages, isSpecialLang } from "shiki";
9
8
  import fs from "node:fs";
10
9
  import { URL as URL$1 } from "node:url";
11
- //#region __vite-browser-external
12
- var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((s, u) => {
10
+ //#region \0rolldown/runtime.js
11
+ var __create = Object.create, __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __getOwnPropNames$1 = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp$1 = Object.prototype.hasOwnProperty, __commonJSMin = (s, u) => () => (u || (s((u = { exports: {} }).exports, u), s = null), u.exports), __exportAll = (s, u) => {
12
+ let d = {};
13
+ for (var f in s) __defProp$1(d, f, {
14
+ get: s[f],
15
+ enumerable: !0
16
+ });
17
+ return u || __defProp$1(d, Symbol.toStringTag, { value: "Module" }), d;
18
+ }, __copyProps$1 = (s, u, d, f) => {
19
+ if (u && typeof u == "object" || typeof u == "function") for (var p = __getOwnPropNames$1(u), m = 0, h = p.length, g; m < h; m++) g = p[m], !__hasOwnProp$1.call(s, g) && g !== d && __defProp$1(s, g, {
20
+ get: ((s) => u[s]).bind(null, g),
21
+ enumerable: !(f = __getOwnPropDesc$1(u, g)) || f.enumerable
22
+ });
23
+ return s;
24
+ }, __toESM = (s, u, d) => (d = s == null ? {} : __create(__getProtoOf(s)), __copyProps$1(u || !s || !s.__esModule ? __defProp$1(d, "default", {
25
+ value: s,
26
+ enumerable: !0
27
+ }) : d, s)), require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((s, u) => {
13
28
  u.exports = {};
14
29
  })), require_kind_of = /* @__PURE__ */ __commonJSMin(((s, u) => {
15
30
  var d = Object.prototype.toString;
@@ -8183,8 +8198,66 @@ function transformerNotationHighlight(s = {}) {
8183
8198
  }, "@shikijs/transformers:notation-highlight");
8184
8199
  }
8185
8200
  //#endregion
8186
- //#region src/shared/utils/highlight.ts
8187
- var shellLangs = [
8201
+ //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js
8202
+ var require_picocolors_browser = /* @__PURE__ */ __commonJSMin(((s, u) => {
8203
+ var d = String, f = function() {
8204
+ return {
8205
+ isColorSupported: !1,
8206
+ reset: d,
8207
+ bold: d,
8208
+ dim: d,
8209
+ italic: d,
8210
+ underline: d,
8211
+ inverse: d,
8212
+ hidden: d,
8213
+ strikethrough: d,
8214
+ black: d,
8215
+ red: d,
8216
+ green: d,
8217
+ yellow: d,
8218
+ blue: d,
8219
+ magenta: d,
8220
+ cyan: d,
8221
+ white: d,
8222
+ gray: d,
8223
+ bgBlack: d,
8224
+ bgRed: d,
8225
+ bgGreen: d,
8226
+ bgYellow: d,
8227
+ bgBlue: d,
8228
+ bgMagenta: d,
8229
+ bgCyan: d,
8230
+ bgWhite: d,
8231
+ blackBright: d,
8232
+ redBright: d,
8233
+ greenBright: d,
8234
+ yellowBright: d,
8235
+ blueBright: d,
8236
+ magentaBright: d,
8237
+ cyanBright: d,
8238
+ whiteBright: d,
8239
+ bgBlackBright: d,
8240
+ bgRedBright: d,
8241
+ bgGreenBright: d,
8242
+ bgYellowBright: d,
8243
+ bgBlueBright: d,
8244
+ bgMagentaBright: d,
8245
+ bgCyanBright: d,
8246
+ bgWhiteBright: d
8247
+ };
8248
+ };
8249
+ u.exports = f(), u.exports.createColors = f;
8250
+ })), import_picocolors_browser = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1), logger = {
8251
+ info(s) {
8252
+ console.log(import_picocolors_browser.default.cyan(s));
8253
+ },
8254
+ warn(s) {
8255
+ console.warn(import_picocolors_browser.default.yellow(s));
8256
+ },
8257
+ error(s) {
8258
+ console.error(import_picocolors_browser.default.red(s));
8259
+ }
8260
+ }, shellLangs = [
8188
8261
  "shellscript",
8189
8262
  "shell",
8190
8263
  "bash",
@@ -9421,7 +9494,9 @@ async function initializeTypedownContext() {
9421
9494
  });
9422
9495
  let u = s.address, d = s.port;
9423
9496
  if (u === void 0 || d === void 0) throw Error("RPC server started but address/port not available");
9424
- let f = await RpcClient.connect(new URL(u).hostname, d), p = new TypedownContext(f, await createMarkdownRenderer(await f.getConfig())), m = !1;
9497
+ let f = await RpcClient.connect(new URL(u).hostname, d), p = new TypedownContext(f, await createMarkdownRenderer(await f.getConfig()));
9498
+ s.unref();
9499
+ let m = !1;
9425
9500
  function h() {
9426
9501
  m || (m = !0, s.close());
9427
9502
  }
@@ -9433,4 +9508,4 @@ async function initializeTypedownContext() {
9433
9508
  }
9434
9509
  var tdContext = await initializeTypedownContext();
9435
9510
  //#endregion
9436
- export { tdContext as n, TypedownContext as t };
9511
+ export { tdContext as n, logger as r, TypedownContext as t };
@@ -0,0 +1,2 @@
1
+ import { n as e } from "./typedown-context-WluCH44c.js";
2
+ export { e as tdContext };
package/dist/vite.js CHANGED
@@ -1,174 +1,2 @@
1
- import { n as e } from "./typedown-context-CWA07Yb7.js";
2
- import "./shared-DzTfF-_d.js";
3
- import { c as t, r as n } from "./brand-DSd9HWVy.js";
4
- import r from "@vitejs/plugin-vue";
5
- //#region src/node/lib/render/vue.ts
6
- async function i(e, n, r) {
7
- let i = {
8
- path: r,
9
- relativePath: r,
10
- cleanUrls: !0
11
- }, a = await e.renderAsync(n.content, i), o = i.title || t(n.header, r), s = {
12
- schema: n.schema,
13
- frontmatter: n.header,
14
- headings: i.headers ?? [],
15
- title: o
16
- }, c = JSON.stringify(JSON.stringify(s)), l = JSON.stringify(a);
17
- return {
18
- vueSrc: [
19
- "<script>",
20
- `export const __pageData = JSON.parse(${c})`,
21
- `export default { name: ${JSON.stringify(r)}, data() { return { __html: ${l} } } }`,
22
- "<\/script>",
23
- "<template><div v-html=\"__html\" /></template>"
24
- ].join("\n"),
25
- pageData: s
26
- };
27
- }
28
- //#endregion
29
- //#region src/node/plugin/constants.ts
30
- var a = "@typedown/app", o = "\0@typedown/app", s = "__typedown_index__.td";
31
- //#endregion
32
- //#region src/node/plugin/codegen.ts
33
- function c(e) {
34
- let { contentDir: t, hasIndex: n } = e;
35
- return `
36
- import 'typerighter/style.css';
37
- import { createTypedownApp } from 'typerighter/client';
38
- import theme from 'typerighter/client/theme-default';
39
-
40
- const pages = import.meta.glob('${`/${t}/**/*.td`}');
41
- ${n ? "" : `pages['/${t}/${s}'] = () => import('${s}');`}
42
-
43
- async function loadPageModule(pagePath) {
44
- const key = '/${t}/' + pagePath.replace(/^\\//, '') + '.td';
45
- const altKey = '/${t}/' + pagePath.replace(/^\\//, '') + '/index.td';
46
- const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${s}'] : undefined)`};
47
- if (!loader) return undefined;
48
- return loader();
49
- }
50
-
51
- const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
52
- title: e.siteTitle,
53
- description: e.siteDescription
54
- })}, ${JSON.stringify({ sidebarGroups: e.sidebarGroups })});
55
- app.mount('#app');
56
- `;
57
- }
58
- function l(e) {
59
- let t = JSON.stringify(e).replace(/'/g, "\\'"), n = JSON.stringify({
60
- schema: "",
61
- frontmatter: {},
62
- headings: [],
63
- title: "Index"
64
- });
65
- return `<script>
66
- import { TdOverview } from 'typerighter/client/theme-default';
67
- export const __pageData = JSON.parse(${JSON.stringify(n)})
68
- export default { name: "index", components: { TdOverview } }
69
- <\/script>
70
- <template><TdOverview :groups='${t}' /></template>`;
71
- }
72
- //#endregion
73
- //#region src/node/plugin/vite.ts
74
- function u() {
75
- let t;
76
- return [{
77
- name: "vite-plugin-typedown",
78
- enforce: "pre",
79
- transformIndexHtml(e) {
80
- return e.replace("</head>", ` <link rel="icon" type="image/svg+xml" href="${n}">\n</head>`).replace("</body>", ` <script type="module" src="/${a}"><\/script>\n</body>`);
81
- },
82
- resolveId(e) {
83
- if (e === "/@typedown/app" || e === "@typedown/app") return o;
84
- if (e.endsWith("__typedown_index__.td")) return e;
85
- },
86
- async load(t) {
87
- if (t === "\0@typedown/app") {
88
- let [t, n, r] = await Promise.all([
89
- e.getConfig(),
90
- e.listFiles(),
91
- e.listFilesGroupedBySchema()
92
- ]), i = n.some((e) => e === "index.td");
93
- return c({
94
- ...t,
95
- hasIndex: i,
96
- sidebarGroups: r
97
- });
98
- }
99
- if (t.endsWith("__typedown_index__.td")) return l(await e.listFilesGroupedBySchema());
100
- },
101
- configureServer(r) {
102
- return t = r, e.rpc.onConfigChanged(() => t && f(t)), e.rpc.onContentChanged(({ content: e }) => {
103
- if (t) {
104
- for (let n of t.moduleGraph.idToModuleMap.values()) if (n.file?.endsWith(e)) {
105
- t.moduleGraph.invalidateModule(n), t.hot.send({
106
- type: "update",
107
- updates: [{
108
- type: "js-update",
109
- path: n.url,
110
- acceptedPath: n.url,
111
- timestamp: Date.now()
112
- }]
113
- });
114
- break;
115
- }
116
- }
117
- }), e.rpc.onContentCreated(() => t && p(t)), e.rpc.onContentDeleted(() => t && p(t)), e.rpc.onSchemaChanged(() => t && p(t)), e.rpc.onSchemaCreated(() => t && p(t)), e.rpc.onSchemaDeleted(() => t && p(t)), () => {
118
- r.middlewares.use((e, t, r) => {
119
- if (!e.url || t.writableEnded || e.url.startsWith("/@") || e.url.startsWith("/node_modules") || e.url.includes(".")) return r();
120
- let i = `<!DOCTYPE html>
121
- <html lang="en">
122
- <head>
123
- <meta charset="UTF-8">
124
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
125
- <title>Typedown</title>
126
- <link rel="icon" type="image/svg+xml" href="${n}">
127
- </head>
128
- <body>
129
- <div id="app"></div>
130
- <script type="module" src="/${a}"><\/script>
131
- </body>
132
- </html>`;
133
- t.setHeader("Content-Type", "text/html"), t.end(i);
134
- });
135
- };
136
- },
137
- async transform(t, n) {
138
- let r = n.split("?")[0];
139
- if (!r.endsWith(".td") || r.includes("__typedown_index__.td")) return;
140
- let a = (await e.getConfig()).contentDir, o = r.includes(a) ? r.slice(r.indexOf(a) + a.length + 1) : r, s = await e.getFile(o), { vueSrc: c } = await i(e.md, s, o);
141
- return {
142
- code: c,
143
- map: null
144
- };
145
- },
146
- handleHotUpdate({ file: e }) {
147
- if (e.endsWith(".td")) return [];
148
- }
149
- }, r({ include: /\.(?:vue|td)$/ })];
150
- }
151
- function d(e) {
152
- return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
153
- }
154
- function f(e) {
155
- for (let t of d(e)) e.moduleGraph.invalidateModule(t);
156
- e.hot.send({ type: "full-reload" });
157
- }
158
- function p(e) {
159
- let t = d(e).map((t) => (e.moduleGraph.invalidateModule(t), m(t)));
160
- 0 < t.length && e.hot.send({
161
- type: "update",
162
- updates: t
163
- });
164
- }
165
- function m(e) {
166
- return {
167
- type: "js-update",
168
- path: e.url,
169
- acceptedPath: e.url,
170
- timestamp: Date.now()
171
- };
172
- }
173
- //#endregion
174
- export { u as typedown };
1
+ import { t as e } from "./plugin-C-rHOs3n.js";
2
+ export { e as typedown };
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "typerighter",
4
- "version": "0.1.2",
5
- "description": "Typedown: A typed content framework. Work in progress.",
4
+ "version": "0.1.4",
5
+ "description": "Typedown: A typed content framework.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/huydo862003/typerighter.git",
9
9
  "directory": "packages/typedown"
10
10
  },
11
11
  "type": "module",
12
+ "bin": {
13
+ "typedown": "./bin/typedown.js"
14
+ },
12
15
  "main": "./dist/index.js",
13
16
  "types": "./dist/index.d.ts",
14
17
  "exports": {
@@ -31,6 +34,7 @@
31
34
  "./style.css": "./dist/typerighter.css"
32
35
  },
33
36
  "files": [
37
+ "bin",
34
38
  "dist"
35
39
  ],
36
40
  "keywords": [
@@ -41,6 +45,7 @@
41
45
  "author": "Huy-DNA <huydo862003@gmail.com>",
42
46
  "license": "AGPL-3.0-only",
43
47
  "dependencies": {
48
+ "@clack/prompts": "^1.7.0",
44
49
  "@fontsource-variable/archivo": "^5.3.0",
45
50
  "@fontsource-variable/jetbrains-mono": "^5.3.0",
46
51
  "@mdit-vue/plugin-frontmatter": "^3.0.2",
@@ -56,7 +61,7 @@
56
61
  "@shikijs/transformers": "^4.3.1",
57
62
  "@shikijs/types": "^4.3.1",
58
63
  "@tailwindcss/vite": "^4.3.3",
59
- "@vueuse/core": "^14.3.0",
64
+ "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
60
65
  "image-size": "^2.0.2",
61
66
  "lucide-vue-next": "^1.0.0",
62
67
  "markdown-it": "^14.0.0",
@@ -69,11 +74,10 @@
69
74
  "picocolors": "^1.1.1",
70
75
  "shiki": "^4.3.1",
71
76
  "tailwindcss": "^4.3.3",
72
- "@typerighter/rpc-client": "0.1.2",
73
- "@typerighter/rpc-server": "0.1.2"
77
+ "@typerighter/rpc-client": "0.1.4",
78
+ "@typerighter/rpc-server": "0.1.4"
74
79
  },
75
80
  "peerDependencies": {
76
- "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
77
81
  "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
78
82
  "vue": "^3.0.0"
79
83
  },
@@ -1,78 +0,0 @@
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 = /* @__PURE__ */ l((/* @__PURE__ */ o(((e, t) => {
19
- var n = String, r = function() {
20
- return {
21
- isColorSupported: !1,
22
- reset: n,
23
- bold: n,
24
- dim: n,
25
- italic: n,
26
- underline: n,
27
- inverse: n,
28
- hidden: n,
29
- strikethrough: n,
30
- black: n,
31
- red: n,
32
- green: n,
33
- yellow: n,
34
- blue: n,
35
- magenta: n,
36
- cyan: n,
37
- white: n,
38
- gray: n,
39
- bgBlack: n,
40
- bgRed: n,
41
- bgGreen: n,
42
- bgYellow: n,
43
- bgBlue: n,
44
- bgMagenta: n,
45
- bgCyan: n,
46
- bgWhite: n,
47
- blackBright: n,
48
- redBright: n,
49
- greenBright: n,
50
- yellowBright: n,
51
- blueBright: n,
52
- magentaBright: n,
53
- cyanBright: n,
54
- whiteBright: n,
55
- bgBlackBright: n,
56
- bgRedBright: n,
57
- bgGreenBright: n,
58
- bgYellowBright: n,
59
- bgBlueBright: n,
60
- bgMagentaBright: n,
61
- bgCyanBright: n,
62
- bgWhiteBright: n
63
- };
64
- };
65
- t.exports = r(), t.exports.createColors = r;
66
- })))(), 1), d = {
67
- info(e) {
68
- console.log(u.default.cyan(e));
69
- },
70
- warn(e) {
71
- console.warn(u.default.yellow(e));
72
- },
73
- error(e) {
74
- console.error(u.default.red(e));
75
- }
76
- };
77
- //#endregion
78
- export { l as i, o as n, s as r, d as t };
@@ -1,13 +0,0 @@
1
- export interface CodegenOptions {
2
- /** Content directory relative to the Vite root (for import.meta.glob) */
3
- contentDir: string;
4
- /** Import path for the theme's Layout component */
5
- layoutImport: string;
6
- /** Import path for the theme's NotFound component */
7
- notFoundImport: string;
8
- /** Package name for importing createTypedownApp */
9
- typerighterPackage: string;
10
- }
11
- export declare function generateClientEntry(options: CodegenOptions): string;
12
- export declare function generateSsrEntry(options: CodegenOptions): string;
13
- //# sourceMappingURL=codegen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../src/node/build/codegen.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAGD,wBAAgB,mBAAmB,CAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAwBpE;AAGD,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CA6BjE"}
@@ -1,5 +0,0 @@
1
- import type { ResolvedConfig, ServerOptions } from 'vite';
2
- export type ViteServerConfig = ResolvedConfig;
3
- export type ViteServerOptions = ServerOptions;
4
- export declare function createViteServer(options: ViteServerOptions | undefined, config: ViteServerConfig): Promise<import("vite").ViteDevServer>;
5
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/node/cli/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,MAAM,CAAC;AAKd,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC9C,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAK9C,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,iBAAiB,YAAK,EAC/B,MAAM,EAAE,gBAAgB,yCAWzB"}