typerighter 0.1.3 → 0.1.5

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 (53) hide show
  1. package/bin/typedown.js +5 -0
  2. package/dist/{app-bn8sNpDS.js → app-CM3biamr.js} +18 -14
  3. package/dist/cli-2dHfEihR.js +158 -0
  4. package/dist/cli.js +2 -0
  5. package/dist/client/app/composables/useTdContent.d.ts +2 -1
  6. package/dist/client/app/composables/useTdContent.d.ts.map +1 -1
  7. package/dist/client/theme-default.js +1 -1
  8. package/dist/client.js +1 -1
  9. package/dist/html-cZxXrc6x.js +24 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -187
  13. package/dist/init-fZWFQnOM.js +646 -0
  14. package/dist/node/build/html.d.ts +1 -0
  15. package/dist/node/build/html.d.ts.map +1 -1
  16. package/dist/node/build/html.test.d.ts +2 -0
  17. package/dist/node/build/html.test.d.ts.map +1 -0
  18. package/dist/node/build/index.d.ts +0 -4
  19. package/dist/node/build/index.d.ts.map +1 -1
  20. package/dist/node/cli/index.d.ts +1 -1
  21. package/dist/node/cli/index.d.ts.map +1 -1
  22. package/dist/node/cli/init.d.ts +2 -0
  23. package/dist/node/cli/init.d.ts.map +1 -0
  24. package/dist/node/index.d.ts +1 -1
  25. package/dist/node/index.d.ts.map +1 -1
  26. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  27. package/dist/node/plugin/{codegen.d.ts → vite/codegen.d.ts} +11 -0
  28. package/dist/node/plugin/vite/codegen.d.ts.map +1 -0
  29. package/dist/node/plugin/vite/codegen.test.d.ts.map +1 -0
  30. package/dist/node/plugin/vite/constants.d.ts.map +1 -0
  31. package/dist/node/plugin/{vite.d.ts → vite/index.d.ts} +1 -1
  32. package/dist/node/plugin/vite/index.d.ts.map +1 -0
  33. package/dist/plugin-t6FyO8wM.js +1 -0
  34. package/dist/rolldown-runtime-Dqa2HsxW.js +20 -0
  35. package/dist/{typedown-context-CWA07Yb7.js → typedown-context-C5kvAxE0.js} +65 -5
  36. package/dist/typedown-context-uGzfOyIE.js +2 -0
  37. package/dist/vite-CrIemqE7.js +206 -0
  38. package/dist/vite.js +3 -174
  39. package/package.json +9 -5
  40. package/dist/logger-DZLd8EDg.js +0 -78
  41. package/dist/node/build/codegen.d.ts +0 -13
  42. package/dist/node/build/codegen.d.ts.map +0 -1
  43. package/dist/node/cli/server.d.ts +0 -5
  44. package/dist/node/cli/server.d.ts.map +0 -1
  45. package/dist/node/plugin/codegen.d.ts.map +0 -1
  46. package/dist/node/plugin/codegen.test.d.ts.map +0 -1
  47. package/dist/node/plugin/constants.d.ts.map +0 -1
  48. package/dist/node/plugin/vite.d.ts.map +0 -1
  49. package/dist/node/plugin.d.ts +0 -3
  50. package/dist/node/plugin.d.ts.map +0 -1
  51. package/dist/typedown-context-D78bYNhH.js +0 -2
  52. /package/dist/node/plugin/{codegen.test.d.ts → vite/codegen.test.d.ts} +0 -0
  53. /package/dist/node/plugin/{constants.d.ts → vite/constants.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ export declare function initialize(targetDirectory: string): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/node/cli/init.ts"],"names":[],"mappings":"AAUA,wBAAsB,UAAU,CAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDxE"}
@@ -1,4 +1,4 @@
1
1
  export * from './plugin';
2
- export * from './cli';
3
2
  export * from './build';
3
+ export * from './cli';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"typedown-context.d.ts","sourceRoot":"","sources":["../../../src/node/lib/typedown-context.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,eAAe,EAAE,YAAY,EAAE,YAAY,EAC5C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACmB,KAAK,gBAAgB,EAC9C,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EACV,aAAa,EACd,MAAM,UAAU,CAAC;AAIlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,GAAG,CAAmB;gBAEjB,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB;IAMpD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,0BAA0B,CAA4B;IAC9D,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,aAAa,CAAsC;IAE3D,OAAO,CAAC,aAAa,CAAK;IAE1B,OAAO,CAAC,4BAA4B;IA8DpC,IAAI,GAAG,IAAK,SAAS,CAEpB;IAIK,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpD,QAAQ,CAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAatD,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ/B,wBAAwB,IAAK,OAAO,CAAC,aAAa,CAAC;IAgBnD,SAAS,IAAK,OAAO,CAAC,YAAY,CAAC;IASnC,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM/C,SAAS,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAYjD,WAAW,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQvC,IAAI,EAAE,IAAK,gBAAgB,CAE1B;CACF;AAiDD,eAAO,MAAM,SAAS,iBAAoC,CAAC"}
1
+ {"version":3,"file":"typedown-context.d.ts","sourceRoot":"","sources":["../../../src/node/lib/typedown-context.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,eAAe,EAAE,YAAY,EAAE,YAAY,EAC5C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACmB,KAAK,gBAAgB,EAC9C,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EACV,aAAa,EACd,MAAM,UAAU,CAAC;AAIlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,GAAG,CAAmB;gBAEjB,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB;IAMpD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,0BAA0B,CAA4B;IAC9D,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,aAAa,CAAsC;IAE3D,OAAO,CAAC,aAAa,CAAK;IAE1B,OAAO,CAAC,4BAA4B;IA8DpC,IAAI,GAAG,IAAK,SAAS,CAEpB;IAIK,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpD,QAAQ,CAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAatD,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ/B,wBAAwB,IAAK,OAAO,CAAC,aAAa,CAAC;IAgBnD,SAAS,IAAK,OAAO,CAAC,YAAY,CAAC;IASnC,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM/C,SAAS,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAYjD,WAAW,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQvC,IAAI,EAAE,IAAK,gBAAgB,CAE1B;CACF;AAoDD,eAAO,MAAM,SAAS,iBAAoC,CAAC"}
@@ -11,6 +11,17 @@ export interface AppEntryOptions {
11
11
  /** Content files grouped by schema for the sidebar */
12
12
  sidebarGroups: SidebarGroups;
13
13
  }
14
+ export interface SsrEntryOptions {
15
+ /** Content directory relative to project root */
16
+ contentDir: string;
17
+ /** Import path for the theme */
18
+ layoutImport: string;
19
+ /** Serialized siteConfig JSON */
20
+ siteConfig: string;
21
+ /** Serialized siteData JSON */
22
+ siteData: string;
23
+ }
14
24
  export declare function generateAppEntry(options: AppEntryOptions): string;
15
25
  export declare function generateIndexSfc(groups: Record<string, unknown[]>): string;
26
+ export declare function generateSsrEntry(options: SsrEntryOptions): string;
16
27
  //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAGD,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAwClE;AAGD,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAe3E;AAGD,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAuBlE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.test.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/codegen.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,uBAAuB,QAAwB,CAAC;AAC7D,eAAO,MAAM,gBAAgB,0BAA0B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from 'vite';
2
2
  export declare function typedown(): Plugin[];
3
- //# sourceMappingURL=vite.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,MAAM,CAAC;AAqBd,wBAAgB,QAAQ,IAAK,MAAM,EAAE,CA+KpC"}
@@ -0,0 +1 @@
1
+ import "./vite-CrIemqE7.js";
@@ -0,0 +1,20 @@
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));
19
+ //#endregion
20
+ export { s as n, l as r, o as t };
@@ -1,4 +1,4 @@
1
- import { i as __toESM, n as __commonJSMin, r as __exportAll, t as logger } from "./logger-DZLd8EDg.js";
1
+ import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-Dqa2HsxW.js";
2
2
  import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
3
3
  import { n as isLinkToPage, r as EXTERNAL_URL_RE, t as isExternal } from "./shared-DzTfF-_d.js";
4
4
  import path from "node:path";
@@ -8183,8 +8183,66 @@ function transformerNotationHighlight(s = {}) {
8183
8183
  }, "@shikijs/transformers:notation-highlight");
8184
8184
  }
8185
8185
  //#endregion
8186
- //#region src/shared/utils/highlight.ts
8187
- var shellLangs = [
8186
+ //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js
8187
+ var require_picocolors_browser = /* @__PURE__ */ __commonJSMin(((s, u) => {
8188
+ var d = String, f = function() {
8189
+ return {
8190
+ isColorSupported: !1,
8191
+ reset: d,
8192
+ bold: d,
8193
+ dim: d,
8194
+ italic: d,
8195
+ underline: d,
8196
+ inverse: d,
8197
+ hidden: d,
8198
+ strikethrough: d,
8199
+ black: d,
8200
+ red: d,
8201
+ green: d,
8202
+ yellow: d,
8203
+ blue: d,
8204
+ magenta: d,
8205
+ cyan: d,
8206
+ white: d,
8207
+ gray: d,
8208
+ bgBlack: d,
8209
+ bgRed: d,
8210
+ bgGreen: d,
8211
+ bgYellow: d,
8212
+ bgBlue: d,
8213
+ bgMagenta: d,
8214
+ bgCyan: d,
8215
+ bgWhite: d,
8216
+ blackBright: d,
8217
+ redBright: d,
8218
+ greenBright: d,
8219
+ yellowBright: d,
8220
+ blueBright: d,
8221
+ magentaBright: d,
8222
+ cyanBright: d,
8223
+ whiteBright: d,
8224
+ bgBlackBright: d,
8225
+ bgRedBright: d,
8226
+ bgGreenBright: d,
8227
+ bgYellowBright: d,
8228
+ bgBlueBright: d,
8229
+ bgMagentaBright: d,
8230
+ bgCyanBright: d,
8231
+ bgWhiteBright: d
8232
+ };
8233
+ };
8234
+ u.exports = f(), u.exports.createColors = f;
8235
+ })), import_picocolors_browser = /* @__PURE__ */ __toESM(require_picocolors_browser(), 1), logger = {
8236
+ info(s) {
8237
+ console.log(import_picocolors_browser.default.cyan(s));
8238
+ },
8239
+ warn(s) {
8240
+ console.warn(import_picocolors_browser.default.yellow(s));
8241
+ },
8242
+ error(s) {
8243
+ console.error(import_picocolors_browser.default.red(s));
8244
+ }
8245
+ }, shellLangs = [
8188
8246
  "shellscript",
8189
8247
  "shell",
8190
8248
  "bash",
@@ -9421,7 +9479,9 @@ async function initializeTypedownContext() {
9421
9479
  });
9422
9480
  let u = s.address, d = s.port;
9423
9481
  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;
9482
+ let f = await RpcClient.connect(new URL(u).hostname, d), p = new TypedownContext(f, await createMarkdownRenderer(await f.getConfig()));
9483
+ s.unref();
9484
+ let m = !1;
9425
9485
  function h() {
9426
9486
  m || (m = !0, s.close());
9427
9487
  }
@@ -9433,4 +9493,4 @@ async function initializeTypedownContext() {
9433
9493
  }
9434
9494
  var tdContext = await initializeTypedownContext();
9435
9495
  //#endregion
9436
- export { tdContext as n, TypedownContext as t };
9496
+ export { require_picocolors_browser as i, tdContext as n, logger as r, TypedownContext as t };
@@ -0,0 +1,2 @@
1
+ import { n as e } from "./typedown-context-C5kvAxE0.js";
2
+ export { e as tdContext };
@@ -0,0 +1,206 @@
1
+ import { n as e } from "./typedown-context-C5kvAxE0.js";
2
+ import "./shared-DzTfF-_d.js";
3
+ import { c as t, r as n } from "./brand-DSd9HWVy.js";
4
+ import { t as r } from "./html-cZxXrc6x.js";
5
+ import i from "@tailwindcss/vite";
6
+ import a from "@vitejs/plugin-vue";
7
+ //#region src/node/lib/render/vue.ts
8
+ async function o(e, n, r) {
9
+ let i = {
10
+ path: r,
11
+ relativePath: r,
12
+ cleanUrls: !0
13
+ }, a = await e.renderAsync(n.content, i), o = i.title || t(n.header, r), s = {
14
+ schema: n.schema,
15
+ frontmatter: n.header,
16
+ headings: i.headers ?? [],
17
+ title: o
18
+ }, c = JSON.stringify(JSON.stringify(s)), l = JSON.stringify(a);
19
+ return {
20
+ vueSrc: [
21
+ "<script>",
22
+ `export const __pageData = JSON.parse(${c})`,
23
+ `export default { name: ${JSON.stringify(r)}, data() { return { __html: ${l} } } }`,
24
+ "<\/script>",
25
+ "<template><div v-html=\"__html\" /></template>"
26
+ ].join("\n"),
27
+ pageData: s
28
+ };
29
+ }
30
+ //#endregion
31
+ //#region src/node/plugin/vite/constants.ts
32
+ var s = "@typedown/app", c = "\0@typedown/app", l = "__typedown_index__.td";
33
+ //#endregion
34
+ //#region src/node/plugin/vite/codegen.ts
35
+ function u(e) {
36
+ let { contentDir: t, hasIndex: n } = e;
37
+ return `
38
+ import 'typerighter/style.css';
39
+ import { createTypedownApp } from 'typerighter/client';
40
+ import theme from 'typerighter/client/theme-default';
41
+
42
+ const pages = import.meta.glob('${`/${t}/**/*.td`}');
43
+ ${n ? "" : `pages['/${t}/${l}'] = () => import('${l}');`}
44
+
45
+ async function loadPageModule(pagePath) {
46
+ const key = '/${t}/' + pagePath.replace(/^\\//, '') + '.td';
47
+ const altKey = '/${t}/' + pagePath.replace(/^\\//, '') + '/index.td';
48
+ const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${l}'] : undefined)`};
49
+ if (!loader) return undefined;
50
+ return loader();
51
+ }
52
+
53
+ const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.stringify({
54
+ title: e.siteTitle,
55
+ description: e.siteDescription
56
+ })}, ${JSON.stringify({ sidebarGroups: e.sidebarGroups })});
57
+ app.mount('#app');
58
+ `;
59
+ }
60
+ function d(e) {
61
+ let t = JSON.stringify(e).replace(/'/g, "\\'"), n = JSON.stringify({
62
+ schema: "",
63
+ frontmatter: {},
64
+ headings: [],
65
+ title: "Index"
66
+ });
67
+ return `<script>
68
+ import { TdOverview } from 'typerighter/client/theme-default';
69
+ export const __pageData = JSON.parse(${JSON.stringify(n)})
70
+ export default { name: "index", components: { TdOverview } }
71
+ <\/script>
72
+ <template><TdOverview :groups='${t}' /></template>`;
73
+ }
74
+ function f(e) {
75
+ let t = `/${e.contentDir}/**/*.td`;
76
+ return `
77
+ import { createTypedownApp } from 'typerighter/client';
78
+ import { renderToString } from 'vue/server-renderer';
79
+ import theme from '${e.layoutImport}';
80
+
81
+ const pages = import.meta.glob('${t}', { eager: true });
82
+
83
+ function loadPageModule(pagePath) {
84
+ const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
85
+ const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
86
+ return Promise.resolve(pages[key] || pages[altKey]);
87
+ }
88
+
89
+ export async function render(url) {
90
+ const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${e.siteConfig}, ${e.siteData});
91
+ await router.go(url, { replace: true });
92
+ const html = await renderToString(app);
93
+ return { html, pageData: router.route.data };
94
+ }
95
+ `;
96
+ }
97
+ //#endregion
98
+ //#region src/node/plugin/vite/index.ts
99
+ function p() {
100
+ let t;
101
+ return [
102
+ {
103
+ name: "vite-plugin-typedown",
104
+ enforce: "pre",
105
+ async transformIndexHtml(t) {
106
+ let i = await e.getConfig();
107
+ return t.replace(/<title>.*?<\/title>/, `<title>${r(i.siteTitle)}</title>`).replace("</head>", ` <link rel="icon" type="image/svg+xml" href="${n}">\n</head>`).replace("</body>", ` <script type="module" src="/${s}"><\/script>\n</body>`);
108
+ },
109
+ resolveId(e) {
110
+ if (e === "/@typedown/app" || e === "@typedown/app") return c;
111
+ if (e.endsWith("__typedown_index__.td")) return e;
112
+ },
113
+ async load(t) {
114
+ if (t === "\0@typedown/app") {
115
+ let [t, n, r] = await Promise.all([
116
+ e.getConfig(),
117
+ e.listFiles(),
118
+ e.listFilesGroupedBySchema()
119
+ ]), i = n.some((e) => e === "index.td");
120
+ return u({
121
+ ...t,
122
+ hasIndex: i,
123
+ sidebarGroups: r
124
+ });
125
+ }
126
+ if (t.endsWith("__typedown_index__.td")) return d(await e.listFilesGroupedBySchema());
127
+ },
128
+ configureServer(i) {
129
+ return t = i, e.rpc.onConfigChanged(() => t && h(t)), e.rpc.onContentChanged(({ content: e }) => {
130
+ if (t) {
131
+ for (let n of t.moduleGraph.idToModuleMap.values()) if (n.file?.endsWith(e)) {
132
+ t.moduleGraph.invalidateModule(n), t.hot.send({
133
+ type: "update",
134
+ updates: [{
135
+ type: "js-update",
136
+ path: n.url,
137
+ acceptedPath: n.url,
138
+ timestamp: Date.now()
139
+ }]
140
+ });
141
+ break;
142
+ }
143
+ }
144
+ }), e.rpc.onContentCreated(() => t && g(t)), e.rpc.onContentDeleted(() => t && g(t)), e.rpc.onSchemaChanged(() => t && g(t)), e.rpc.onSchemaCreated(() => t && g(t)), e.rpc.onSchemaDeleted(() => t && g(t)), () => {
145
+ i.middlewares.use((t, i, a) => {
146
+ if (!t.url || i.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return a();
147
+ e.getConfig().then((e) => {
148
+ let t = `<!DOCTYPE html>
149
+ <html lang="en">
150
+ <head>
151
+ <meta charset="UTF-8">
152
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
153
+ <title>${r(e.siteTitle)}</title>
154
+ <link rel="icon" type="image/svg+xml" href="${n}">
155
+ </head>
156
+ <body>
157
+ <div id="app"></div>
158
+ <script type="module" src="/${s}"><\/script>
159
+ </body>
160
+ </html>`;
161
+ i.setHeader("Content-Type", "text/html"), i.end(t);
162
+ }).catch(a);
163
+ });
164
+ };
165
+ },
166
+ async transform(t, n) {
167
+ let r = n.split("?")[0];
168
+ if (!r.endsWith(".td") || r.includes("__typedown_index__.td")) return;
169
+ let i = (await e.getConfig()).contentDir, a = r.includes(i) ? r.slice(r.indexOf(i) + i.length + 1) : r, s = await e.getFile(a), { vueSrc: c } = await o(e.md, s, a);
170
+ return {
171
+ code: c,
172
+ map: null
173
+ };
174
+ },
175
+ handleHotUpdate({ file: e }) {
176
+ if (e.endsWith(".td")) return [];
177
+ }
178
+ },
179
+ a({ include: /\.(?:vue|td)$/ }),
180
+ ...i()
181
+ ];
182
+ }
183
+ function m(e) {
184
+ return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
185
+ }
186
+ function h(e) {
187
+ for (let t of m(e)) e.moduleGraph.invalidateModule(t);
188
+ e.hot.send({ type: "full-reload" });
189
+ }
190
+ function g(e) {
191
+ let t = m(e).map((t) => (e.moduleGraph.invalidateModule(t), _(t)));
192
+ 0 < t.length && e.hot.send({
193
+ type: "update",
194
+ updates: t
195
+ });
196
+ }
197
+ function _(e) {
198
+ return {
199
+ type: "js-update",
200
+ path: e.url,
201
+ acceptedPath: e.url,
202
+ timestamp: Date.now()
203
+ };
204
+ }
205
+ //#endregion
206
+ export { u as n, f as r, p as t };
package/dist/vite.js CHANGED
@@ -1,174 +1,3 @@
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 "./vite-CrIemqE7.js";
2
+ import "./plugin-t6FyO8wM.js";
3
+ export { e as typedown };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "typerighter",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "description": "Typedown: A typed content framework.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,6 +9,9 @@
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.3",
73
- "@typerighter/rpc-server": "0.1.3"
77
+ "@typerighter/rpc-client": "0.1.5",
78
+ "@typerighter/rpc-server": "0.1.5"
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
  },