typerighter 0.2.2 → 0.3.1

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 (47) hide show
  1. package/bin/typerighter.js +1 -1
  2. package/dist/cli-VgaueuJP.js +585 -0
  3. package/dist/cli.js +1 -1
  4. package/dist/{vite-BNDqb1zM.js → constants-B7b8AsH0.js} +126 -315
  5. package/dist/index.js +4 -4
  6. package/dist/init-Ci83UWu-.js +2358 -0
  7. package/dist/node/build/index.d.ts +2 -3
  8. package/dist/node/build/index.d.ts.map +1 -1
  9. package/dist/node/build/{render.d.ts → prerender.d.ts} +6 -3
  10. package/dist/node/build/prerender.d.ts.map +1 -0
  11. package/dist/node/cli/index.d.ts +1 -1
  12. package/dist/node/cli/index.d.ts.map +1 -1
  13. package/dist/node/cli/init.d.ts +1 -1
  14. package/dist/node/cli/init.d.ts.map +1 -1
  15. package/dist/node/context.d.ts +14 -0
  16. package/dist/node/context.d.ts.map +1 -0
  17. package/dist/node/lib/logger.d.ts +10 -3
  18. package/dist/node/lib/logger.d.ts.map +1 -1
  19. package/dist/node/lib/progress.d.ts +10 -0
  20. package/dist/node/lib/progress.d.ts.map +1 -0
  21. package/dist/node/lib/typedown-context.d.ts +1 -3
  22. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  23. package/dist/node/plugin/vite/codegen.d.ts +2 -0
  24. package/dist/node/plugin/vite/codegen.d.ts.map +1 -1
  25. package/dist/node/plugin/vite/index.d.ts +5 -1
  26. package/dist/node/plugin/vite/index.d.ts.map +1 -1
  27. package/dist/plugin-DRzll98J.js +1 -0
  28. package/dist/rolldown-runtime-Dqa2HsxW.js +20 -0
  29. package/dist/shared/utils/format.d.ts +2 -0
  30. package/dist/shared/utils/format.d.ts.map +1 -0
  31. package/dist/shared/utils/html.d.ts +2 -0
  32. package/dist/shared/utils/html.d.ts.map +1 -0
  33. package/dist/shared/utils/html.test.d.ts.map +1 -0
  34. package/dist/shared/utils/index.d.ts +2 -0
  35. package/dist/shared/utils/index.d.ts.map +1 -1
  36. package/dist/vite-D9ePlTzy.js +229 -0
  37. package/dist/vite.js +2 -2
  38. package/package.json +6 -3
  39. package/dist/cli-CfMrevh1.js +0 -160
  40. package/dist/constants-BN1OmC7K.js +0 -46
  41. package/dist/init-0BIO3hYI.js +0 -647
  42. package/dist/node/build/html.d.ts +0 -21
  43. package/dist/node/build/html.d.ts.map +0 -1
  44. package/dist/node/build/html.test.d.ts.map +0 -1
  45. package/dist/node/build/render.d.ts.map +0 -1
  46. package/dist/plugin-B-At85hl.js +0 -1
  47. /package/dist/{node/build → shared/utils}/html.test.d.ts +0 -0
@@ -1,7 +1,6 @@
1
1
  import { type InlineConfig } from 'vite';
2
+ import type { AppContext } from '../context';
2
3
  export interface BuildOptions {
3
- /** Root directory of the Vite project */
4
- root: string;
5
4
  /** Output directory for the final build (default: "dist") */
6
5
  outDir?: string;
7
6
  /** Base public path (default: "/") */
@@ -9,5 +8,5 @@ export interface BuildOptions {
9
8
  /** Additional Vite config overrides */
10
9
  viteConfig?: InlineConfig;
11
10
  }
12
- export declare function buildSite(options: BuildOptions): Promise<void>;
11
+ export declare function buildSite(ctx: AppContext, options?: BuildOptions): Promise<void>;
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/build/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACE,KAAK,YAAY,EACzB,MAAM,MAAM,CAAC;AAiBd,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAGD,wBAAsB,SAAS,CAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA+HrE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/build/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACE,KAAK,YAAY,EACzB,MAAM,MAAM,CAAC;AAad,OAAO,KAAK,EACV,UAAU,EACX,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAGD,wBAAsB,SAAS,CAAE,GAAG,EAAE,UAAU,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoJ3F"}
@@ -1,4 +1,5 @@
1
- export interface RenderContext {
1
+ import type { ProgressLogger } from '../lib/progress';
2
+ export interface PrerenderContext {
2
3
  /** Absolute path to the SSR bundle entry */
3
4
  ssrEntryPath: string;
4
5
  /** Absolute path to the client output directory */
@@ -9,6 +10,8 @@ export interface RenderContext {
9
10
  base: string;
10
11
  /** List of page paths to render (e.g. ["/", "/posts/hello"]) */
11
12
  pagePaths: string[];
13
+ /** Progress logger for reporting render progress */
14
+ progress?: ProgressLogger;
12
15
  }
13
- export declare function renderPages(context: RenderContext): Promise<void>;
14
- //# sourceMappingURL=render.d.ts.map
16
+ export declare function prerenderHtmlPages(context: PrerenderContext): Promise<void>;
17
+ //# sourceMappingURL=prerender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../../src/node/build/prerender.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAID,wBAAsB,kBAAkB,CAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmClF"}
@@ -1,2 +1,2 @@
1
- export declare function cli(): Promise<void>;
1
+ export declare function cli(): void;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":"AAWA,wBAAsB,GAAG,kBA2CxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":"AAkBA,wBAAgB,GAAG,SA4FlB"}
@@ -1,2 +1,2 @@
1
- export declare function initialize(targetDirectory: string): Promise<void>;
1
+ export declare function initialize(root: string): Promise<void>;
2
2
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/node/cli/init.ts"],"names":[],"mappings":"AAgBA,wBAAsB,UAAU,CAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDxE"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/node/cli/init.ts"],"names":[],"mappings":"AAsBA,wBAAsB,UAAU,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7D"}
@@ -0,0 +1,14 @@
1
+ import { type Logger } from 'vite';
2
+ import { TypedownContext } from './lib/typedown-context';
3
+ import { TdLogger } from './lib/logger';
4
+ export interface AppContext {
5
+ root: string;
6
+ logger: TdLogger;
7
+ getTdContext: () => Promise<TypedownContext>;
8
+ createViteLogger: () => Logger;
9
+ dispose: () => void;
10
+ }
11
+ export declare const CONFIG_FILE_NAMES: string[];
12
+ export declare function createAppContext(root: string): AppContext;
13
+ export declare function resolveProjectRoot(from: string): string;
14
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":"AAEA,OAAO,EACS,KAAK,MAAM,EAC1B,MAAM,MAAM,CAAC;AAOd,OAAO,EACL,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,QAAQ,EACT,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,UAG7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAmG1D;AAGD,wBAAgB,kBAAkB,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAaxD"}
@@ -1,7 +1,14 @@
1
- export declare const logger: {
1
+ export declare class TdLogger {
2
+ private logStream;
3
+ constructor(logFilePath?: string);
2
4
  info(message: string): void;
3
- phase(message: string): void;
4
5
  warn(message: string): void;
5
6
  error(message: string): void;
6
- };
7
+ success(message: string): void;
8
+ start(message: string): void;
9
+ log(message: string): void;
10
+ writeToFile(level: string, message: string): void;
11
+ close(): void;
12
+ }
13
+ export declare const consoleLogger: TdLogger;
7
14
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/node/lib/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;kBACF,MAAM,GAAG,IAAI;mBAIZ,MAAM,GAAG,IAAI;kBAId,MAAM,GAAG,IAAI;mBAIZ,MAAM,GAAG,IAAI;CAG9B,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/node/lib/logger.ts"],"names":[],"mappings":"AAKA,qBAAa,QAAQ;IACnB,OAAO,CAAC,SAAS,CAA6B;gBAEjC,WAAW,CAAC,EAAE,MAAM;IASjC,IAAI,CAAE,OAAO,EAAE,MAAM;IAKrB,IAAI,CAAE,OAAO,EAAE,MAAM;IAKrB,KAAK,CAAE,OAAO,EAAE,MAAM;IAKtB,OAAO,CAAE,OAAO,EAAE,MAAM;IAKxB,KAAK,CAAE,OAAO,EAAE,MAAM;IAKtB,GAAG,CAAE,OAAO,EAAE,MAAM;IAKpB,WAAW,CAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAS3C,KAAK;CAIN;AAED,eAAO,MAAM,aAAa,UAAiB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { TdLogger } from './logger';
2
+ export declare class ProgressLogger {
3
+ private logger;
4
+ private label;
5
+ private start;
6
+ constructor(logger: TdLogger, label: string);
7
+ update(current: number, total: number): void;
8
+ done(message: string): void;
9
+ }
10
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/node/lib/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACT,MAAM,UAAU,CAAC;AAKlB,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,KAAK,CAAS;gBAET,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM;IAO5C,MAAM,CAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQtC,IAAI,CAAE,OAAO,EAAE,MAAM;CAStB"}
@@ -1,5 +1,4 @@
1
- import { RpcClient } from '@typerighter/rpc-client';
2
- import type { TdBuiltResource, TdSiteConfig, TdSchemaInfo } from '@typerighter/rpc-client';
1
+ import type { RpcClient, TdBuiltResource, TdSiteConfig, TdSchemaInfo } from '@typerighter/rpc-client';
3
2
  import { type MarkdownRenderer } from './markdown';
4
3
  import type { SidebarGroups } from '@/shared';
5
4
  export declare class TypedownContext {
@@ -25,5 +24,4 @@ export declare class TypedownContext {
25
24
  listSchemas(): Promise<string[]>;
26
25
  get md(): MarkdownRenderer;
27
26
  }
28
- export declare function getTdContext(): Promise<TypedownContext>;
29
27
  //# sourceMappingURL=typedown-context.d.ts.map
@@ -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;gBACjB,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,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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"}
@@ -20,6 +20,8 @@ export interface SsrEntryOptions {
20
20
  siteConfig: string;
21
21
  /** Serialized siteData JSON */
22
22
  siteData: string;
23
+ /** Whether the vault has an index.td file */
24
+ hasIndex: boolean;
23
25
  }
24
26
  export declare function generateAppEntry(options: AppEntryOptions): string;
25
27
  export declare function generateIndexSfc(groups: Record<string, unknown[]>): string;
@@ -1 +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,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} from 'vite';
2
- export declare function typedown(): Plugin[];
2
+ import { type AppContext } from '../../context';
3
+ export interface TypedownPluginOptions {
4
+ context?: AppContext;
5
+ }
6
+ export declare function typedown(options?: TypedownPluginOptions): Plugin[];
3
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;AAwBd,wBAAgB,QAAQ,IAAK,MAAM,EAAE,CA6KpC"}
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;AAId,OAAO,EACiC,KAAK,UAAU,EACtD,MAAM,eAAe,CAAC;AAkBvB,MAAM,WAAW,qBAAqB;IAEpC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,wBAAgB,QAAQ,CAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,EAAE,CA2LvE"}
@@ -0,0 +1 @@
1
+ import "./vite-D9ePlTzy.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 };
@@ -0,0 +1,2 @@
1
+ export declare function formatMs(ms: number): string;
2
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/format.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5C"}
@@ -0,0 +1,2 @@
1
+ export declare function escapeHtml(value: string): string;
2
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/html.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.test.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/html.test.ts"],"names":[],"mappings":""}
@@ -2,4 +2,6 @@ export * from './content';
2
2
  export * from './environment';
3
3
  export * from './highlight';
4
4
  export * from './url';
5
+ export * from './html';
6
+ export * from './format';
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,229 @@
1
+ import "./shared-DzTfF-_d.js";
2
+ import { r as e } from "./content-BM3UKxcc.js";
3
+ import { a as t, n, o as r, r as i, s as a, t as o } from "./constants-B7b8AsH0.js";
4
+ import { r as s } from "./brand-CeSqpEQ2.js";
5
+ import c from "@tailwindcss/vite";
6
+ import l from "@vitejs/plugin-vue";
7
+ import { createRequire as u } from "node:module";
8
+ //#region src/node/lib/render/vue.ts
9
+ async function d(t, n, r) {
10
+ let i = {
11
+ path: r,
12
+ relativePath: r,
13
+ cleanUrls: !0
14
+ }, a = await t.renderAsync(n.content, i), o = i.title || e(n.header, r), s = {
15
+ schema: n.schema,
16
+ frontmatter: n.header,
17
+ headings: i.headers ?? [],
18
+ title: o
19
+ }, c = JSON.stringify(JSON.stringify(s)), l = JSON.stringify(a);
20
+ return {
21
+ vueSrc: [
22
+ "<script>",
23
+ `export const __pageData = JSON.parse(${c})`,
24
+ `export default { name: ${JSON.stringify(r)}, data() { return { __html: ${l} } } }`,
25
+ "<\/script>",
26
+ "<template><div v-html=\"__html\" /></template>"
27
+ ].join("\n"),
28
+ pageData: s
29
+ };
30
+ }
31
+ //#endregion
32
+ //#region src/node/plugin/vite/codegen.ts
33
+ function f(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}/${i}'] = () => import('${i}');`}
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}/${i}'] : 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 p(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
+ function m(e) {
73
+ let t = `/${e.contentDir}/**/*.td`, n = e.hasIndex ? "" : `pages['/${e.contentDir}/${i}'] = import('${i}');`, r = e.hasIndex ? "" : ` || (pagePath === '/' ? pages['/${e.contentDir}/${i}'] : undefined)`;
74
+ return `
75
+ import { createTypedownApp } from 'typerighter/client';
76
+ import { renderToString } from 'vue/server-renderer';
77
+ import theme from '${e.layoutImport}';
78
+
79
+ const pages = import.meta.glob('${t}', { eager: true });
80
+ ${n}
81
+
82
+ function loadPageModule(pagePath) {
83
+ const key = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '.td';
84
+ const altKey = '/${e.contentDir}/' + pagePath.replace(/^\\//, '') + '/index.td';
85
+ return Promise.resolve(pages[key] || pages[altKey]${r});
86
+ }
87
+
88
+ export async function render(url) {
89
+ const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${e.siteConfig}, ${e.siteData});
90
+ await router.go(url, { replace: true });
91
+ const html = await renderToString(app);
92
+ return { html, pageData: router.route.data };
93
+ }
94
+ `;
95
+ }
96
+ //#endregion
97
+ //#region src/node/plugin/vite/alias.ts
98
+ var h = u(import.meta.url);
99
+ function g() {
100
+ return [{
101
+ find: "vue/server-renderer",
102
+ replacement: h.resolve("vue/server-renderer")
103
+ }, {
104
+ find: "vue",
105
+ replacement: h.resolve("vue/dist/vue.runtime.esm-bundler.js")
106
+ }];
107
+ }
108
+ //#endregion
109
+ //#region src/node/plugin/vite/index.ts
110
+ function _(e = {}) {
111
+ let i = e.context, u;
112
+ function m() {
113
+ if (i === void 0) throw Error("typedown plugin not initialized");
114
+ return i.getTdContext();
115
+ }
116
+ return [
117
+ {
118
+ name: "vite-plugin-typedown",
119
+ enforce: "pre",
120
+ configResolved(e) {
121
+ i ||= t(r(e.root));
122
+ },
123
+ config() {
124
+ return {
125
+ resolve: { alias: g() },
126
+ ssr: { noExternal: ["typerighter"] }
127
+ };
128
+ },
129
+ resolveId(e) {
130
+ if (e === "/@typedown/app" || e === "@typedown/app") return o;
131
+ if (e.endsWith("__typedown_index__.td")) return e;
132
+ },
133
+ async load(e) {
134
+ let t = await m();
135
+ if (e === "\0@typedown/app") {
136
+ let [e, n, r] = await Promise.all([
137
+ t.getConfig(),
138
+ t.listFiles(),
139
+ t.listFilesGroupedBySchema()
140
+ ]), i = n.some((e) => e === "index.td");
141
+ return f({
142
+ ...e,
143
+ hasIndex: i,
144
+ sidebarGroups: r
145
+ });
146
+ }
147
+ if (e.endsWith("__typedown_index__.td")) return p(await t.listFilesGroupedBySchema());
148
+ },
149
+ async configureServer(e) {
150
+ u = e;
151
+ let t = await m();
152
+ return t.rpc.onConfigChanged(() => u && y(u)), t.rpc.onContentChanged(({ content: e }) => {
153
+ if (u) {
154
+ for (let t of u.moduleGraph.idToModuleMap.values()) if (t.file?.endsWith(e)) {
155
+ u.moduleGraph.invalidateModule(t), u.hot.send({
156
+ type: "update",
157
+ updates: [{
158
+ type: "js-update",
159
+ path: t.url,
160
+ acceptedPath: t.url,
161
+ timestamp: Date.now()
162
+ }]
163
+ });
164
+ break;
165
+ }
166
+ }
167
+ }), t.rpc.onContentCreated(() => u && b(u)), t.rpc.onContentDeleted(() => u && b(u)), t.rpc.onSchemaChanged(() => u && b(u)), t.rpc.onSchemaCreated(() => u && b(u)), t.rpc.onSchemaDeleted(() => u && b(u)), () => {
168
+ e.middlewares.use((e, r, i) => {
169
+ if (!e.url || r.writableEnded || e.url.startsWith("/@") || e.url.startsWith("/node_modules") || e.url.includes(".")) return i();
170
+ t.getConfig().then((e) => {
171
+ let t = `<!DOCTYPE html>
172
+ <html lang="en">
173
+ <head>
174
+ <meta charset="UTF-8">
175
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
176
+ <title>${a(e.siteTitle)}</title>
177
+ <link rel="icon" type="image/svg+xml" href="${s}">
178
+ </head>
179
+ <body>
180
+ <div id="app"></div>
181
+ <script type="module" src="/${n}"><\/script>
182
+ </body>
183
+ </html>`;
184
+ r.setHeader("Content-Type", "text/html"), r.end(t);
185
+ }).catch(i);
186
+ });
187
+ };
188
+ },
189
+ async transform(e, t) {
190
+ let n = t.split("?")[0];
191
+ if (!n.endsWith(".td") || n.includes("__typedown_index__.td")) return;
192
+ let r = await m(), i = (await r.getConfig()).contentDir, a = n.includes(i) ? n.slice(n.indexOf(i) + i.length + 1) : n, o = await r.getFile(a), { vueSrc: s } = await d(r.md, o, a);
193
+ return {
194
+ code: s,
195
+ map: null
196
+ };
197
+ },
198
+ handleHotUpdate({ file: e }) {
199
+ if (e.endsWith(".td")) return [];
200
+ }
201
+ },
202
+ l({ include: /\.(?:vue|td)$/ }),
203
+ ...c()
204
+ ];
205
+ }
206
+ function v(e) {
207
+ return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
208
+ }
209
+ function y(e) {
210
+ for (let t of v(e)) e.moduleGraph.invalidateModule(t);
211
+ e.hot.send({ type: "full-reload" });
212
+ }
213
+ function b(e) {
214
+ let t = v(e).map((t) => (e.moduleGraph.invalidateModule(t), x(t)));
215
+ 0 < t.length && e.hot.send({
216
+ type: "update",
217
+ updates: t
218
+ });
219
+ }
220
+ function x(e) {
221
+ return {
222
+ type: "js-update",
223
+ path: e.url,
224
+ acceptedPath: e.url,
225
+ timestamp: Date.now()
226
+ };
227
+ }
228
+ //#endregion
229
+ export { f as n, m as r, _ as t };
package/dist/vite.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as e } from "./vite-BNDqb1zM.js";
2
- import "./plugin-B-At85hl.js";
1
+ import { t as e } from "./vite-D9ePlTzy.js";
2
+ import "./plugin-DRzll98J.js";
3
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.2.2",
4
+ "version": "0.3.1",
5
5
  "description": "Typedown: A typed content framework.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -62,7 +62,9 @@
62
62
  "@shikijs/types": "^4.3.1",
63
63
  "@tailwindcss/vite": "^4.3.3",
64
64
  "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
65
+ "cac": "^7.0.0",
65
66
  "image-size": "^2.0.2",
67
+ "js-yaml": "^5.2.3",
66
68
  "lucide-vue-next": "^1.0.0",
67
69
  "markdown-it": "^14.0.0",
68
70
  "markdown-it-anchor": "^9.0.0",
@@ -76,11 +78,12 @@
76
78
  "tailwindcss": "^4.3.3",
77
79
  "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
78
80
  "vue": "^3.0.0",
79
- "@typerighter/rpc-client": "0.2.2",
80
- "@typerighter/rpc-server": "0.2.2"
81
+ "@typerighter/rpc-client": "0.3.1",
82
+ "@typerighter/rpc-server": "0.3.1"
81
83
  },
82
84
  "devDependencies": {
83
85
  "@hdnax/nuclint": "^0.17.4",
86
+ "@types/js-yaml": "^4.0.9",
84
87
  "@types/markdown-it": "^14.0.0",
85
88
  "@types/markdown-it-container": "^4.0.0",
86
89
  "@types/markdown-it-emoji": "^3.0.1",