md2x 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.
Files changed (127) hide show
  1. package/README.md +43 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.mjs +128069 -0
  4. package/dist/md2x.mjs +128296 -0
  5. package/dist/renderer/puppeteer-render-worker.js +815 -0
  6. package/dist/renderer/puppeteer-render.html +2829 -0
  7. package/dist/themes/code-themes/business-contrast.json +31 -0
  8. package/dist/themes/code-themes/colorful.json +32 -0
  9. package/dist/themes/code-themes/cool-modern.json +31 -0
  10. package/dist/themes/code-themes/high-contrast.json +31 -0
  11. package/dist/themes/code-themes/light-clean.json +31 -0
  12. package/dist/themes/code-themes/warm-book.json +31 -0
  13. package/dist/themes/color-schemes/candy.json +34 -0
  14. package/dist/themes/color-schemes/cool.json +34 -0
  15. package/dist/themes/color-schemes/coral.json +34 -0
  16. package/dist/themes/color-schemes/dino.json +34 -0
  17. package/dist/themes/color-schemes/forest.json +34 -0
  18. package/dist/themes/color-schemes/garden.json +34 -0
  19. package/dist/themes/color-schemes/neutral.json +34 -0
  20. package/dist/themes/color-schemes/ocean.json +34 -0
  21. package/dist/themes/color-schemes/rainbow.json +43 -0
  22. package/dist/themes/color-schemes/sakura.json +34 -0
  23. package/dist/themes/color-schemes/sepia.json +34 -0
  24. package/dist/themes/color-schemes/space.json +34 -0
  25. package/dist/themes/color-schemes/starry.json +34 -0
  26. package/dist/themes/color-schemes/sunset.json +34 -0
  27. package/dist/themes/color-schemes/warm.json +34 -0
  28. package/dist/themes/font-config.json +184 -0
  29. package/dist/themes/layout-schemes/academic.json +40 -0
  30. package/dist/themes/layout-schemes/book.json +40 -0
  31. package/dist/themes/layout-schemes/document.json +40 -0
  32. package/dist/themes/layout-schemes/magazine.json +40 -0
  33. package/dist/themes/layout-schemes/student.json +40 -0
  34. package/dist/themes/layout-schemes/technical.json +40 -0
  35. package/dist/themes/presets/academic.json +24 -0
  36. package/dist/themes/presets/business.json +22 -0
  37. package/dist/themes/presets/candy.json +23 -0
  38. package/dist/themes/presets/century.json +22 -0
  39. package/dist/themes/presets/coral.json +22 -0
  40. package/dist/themes/presets/default.json +22 -0
  41. package/dist/themes/presets/dinosaur.json +23 -0
  42. package/dist/themes/presets/elegant.json +22 -0
  43. package/dist/themes/presets/forest.json +22 -0
  44. package/dist/themes/presets/garamond.json +22 -0
  45. package/dist/themes/presets/garden.json +23 -0
  46. package/dist/themes/presets/handwritten.json +23 -0
  47. package/dist/themes/presets/heiti.json +22 -0
  48. package/dist/themes/presets/magazine.json +24 -0
  49. package/dist/themes/presets/manuscript.json +22 -0
  50. package/dist/themes/presets/minimal.json +22 -0
  51. package/dist/themes/presets/mixed.json +24 -0
  52. package/dist/themes/presets/newspaper.json +24 -0
  53. package/dist/themes/presets/ocean.json +22 -0
  54. package/dist/themes/presets/palatino.json +22 -0
  55. package/dist/themes/presets/rainbow.json +23 -0
  56. package/dist/themes/presets/space.json +23 -0
  57. package/dist/themes/presets/starry.json +23 -0
  58. package/dist/themes/presets/sunset.json +22 -0
  59. package/dist/themes/presets/swiss.json +22 -0
  60. package/dist/themes/presets/technical.json +22 -0
  61. package/dist/themes/presets/typewriter.json +23 -0
  62. package/dist/themes/presets/verdana.json +22 -0
  63. package/dist/themes/presets/water.json +22 -0
  64. package/dist/themes/registry.json +270 -0
  65. package/dist/themes/table-styles/academic.json +30 -0
  66. package/dist/themes/table-styles/borderless.json +26 -0
  67. package/dist/themes/table-styles/compact.json +24 -0
  68. package/dist/themes/table-styles/grid.json +22 -0
  69. package/dist/themes/table-styles/high-contrast.json +22 -0
  70. package/dist/themes/table-styles/minimal-gray.json +26 -0
  71. package/dist/themes/table-styles/modern-tech.json +34 -0
  72. package/dist/themes/table-styles/professional.json +34 -0
  73. package/dist/themes/table-styles/zebra.json +22 -0
  74. package/dist/types/node/src/host/browser-renderer.d.ts +40 -0
  75. package/dist/types/node/src/host/node-exporter.d.ts +63 -0
  76. package/dist/types/node/src/host/node-platform.d.ts +30 -0
  77. package/dist/types/node/src/index.d.ts +8 -0
  78. package/dist/types/src/core/markdown-block-splitter.d.ts +16 -0
  79. package/dist/types/src/core/markdown-document.d.ts +286 -0
  80. package/dist/types/src/core/markdown-processor.d.ts +228 -0
  81. package/dist/types/src/core/viewer/viewer-controller.d.ts +85 -0
  82. package/dist/types/src/exporters/docx-blockquote-converter.d.ts +24 -0
  83. package/dist/types/src/exporters/docx-code-highlighter.d.ts +14 -0
  84. package/dist/types/src/exporters/docx-download.d.ts +27 -0
  85. package/dist/types/src/exporters/docx-exporter.d.ts +77 -0
  86. package/dist/types/src/exporters/docx-image-utils.d.ts +71 -0
  87. package/dist/types/src/exporters/docx-inline-converter.d.ts +124 -0
  88. package/dist/types/src/exporters/docx-list-converter.d.ts +50 -0
  89. package/dist/types/src/exporters/docx-math-converter.d.ts +11 -0
  90. package/dist/types/src/exporters/docx-table-converter.d.ts +22 -0
  91. package/dist/types/src/exporters/mml2omml.d.ts +2 -0
  92. package/dist/types/src/exporters/theme-to-docx.d.ts +144 -0
  93. package/dist/types/src/plugins/base-plugin.d.ts +67 -0
  94. package/dist/types/src/plugins/canvas-plugin.d.ts +9 -0
  95. package/dist/types/src/plugins/dot-plugin.d.ts +9 -0
  96. package/dist/types/src/plugins/html-plugin.d.ts +28 -0
  97. package/dist/types/src/plugins/index.d.ts +56 -0
  98. package/dist/types/src/plugins/infographic-plugin.d.ts +9 -0
  99. package/dist/types/src/plugins/mermaid-plugin.d.ts +9 -0
  100. package/dist/types/src/plugins/plugin-content-utils.d.ts +40 -0
  101. package/dist/types/src/plugins/plugin-html-utils.d.ts +23 -0
  102. package/dist/types/src/plugins/rehype-image-uri.d.ts +13 -0
  103. package/dist/types/src/plugins/remark-super-sub.d.ts +17 -0
  104. package/dist/types/src/plugins/remark-toc-filter.d.ts +10 -0
  105. package/dist/types/src/plugins/svg-plugin.d.ts +51 -0
  106. package/dist/types/src/plugins/vega-plugin.d.ts +10 -0
  107. package/dist/types/src/plugins/vegalite-plugin.d.ts +23 -0
  108. package/dist/types/src/types/cache.d.ts +85 -0
  109. package/dist/types/src/types/core.d.ts +99 -0
  110. package/dist/types/src/types/docx.d.ts +240 -0
  111. package/dist/types/src/types/index.d.ts +18 -0
  112. package/dist/types/src/types/messaging.d.ts +142 -0
  113. package/dist/types/src/types/platform.d.ts +203 -0
  114. package/dist/types/src/types/plugin.d.ts +101 -0
  115. package/dist/types/src/types/render.d.ts +57 -0
  116. package/dist/types/src/types/theme.d.ts +234 -0
  117. package/dist/types/src/types/toolbar.d.ts +53 -0
  118. package/dist/types/src/ui/popup/i18n-helpers.d.ts +21 -0
  119. package/dist/types/src/ui/popup/settings-tab.d.ts +56 -0
  120. package/dist/types/src/ui/popup/storage-helper.d.ts +12 -0
  121. package/dist/types/src/utils/fetch-utils.d.ts +12 -0
  122. package/dist/types/src/utils/hash.d.ts +17 -0
  123. package/dist/types/src/utils/html-sanitizer.d.ts +26 -0
  124. package/dist/types/src/utils/localization.d.ts +49 -0
  125. package/dist/types/src/utils/theme-manager.d.ts +152 -0
  126. package/dist/types/src/utils/theme-to-css.d.ts +171 -0
  127. package/package.json +47 -0
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Messaging Type Definitions
3
+ *
4
+ * NOTE: This file defines the type-level contract only.
5
+ * Runtime implementations live under src/messaging/.
6
+ */
7
+ import type { FileState } from './core';
8
+ import type { RendererThemeConfig, RenderResult } from './render';
9
+ export declare const RenderMessageType: {
10
+ readonly RENDER_DIAGRAM: "RENDER_DIAGRAM";
11
+ readonly SET_THEME_CONFIG: "SET_THEME_CONFIG";
12
+ readonly PING: "PING";
13
+ readonly READY: "READY";
14
+ readonly READY_ACK: "READY_ACK";
15
+ };
16
+ export type RenderMessageType = typeof RenderMessageType[keyof typeof RenderMessageType];
17
+ export declare const ServiceMessageType: {
18
+ readonly STORAGE_GET: "STORAGE_GET";
19
+ readonly STORAGE_SET: "STORAGE_SET";
20
+ readonly STORAGE_REMOVE: "STORAGE_REMOVE";
21
+ readonly OFFSCREEN_READY: "OFFSCREEN_READY";
22
+ readonly OFFSCREEN_DOM_READY: "OFFSCREEN_DOM_READY";
23
+ readonly OFFSCREEN_ERROR: "OFFSCREEN_ERROR";
24
+ readonly LOCALE_CHANGED: "LOCALE_CHANGED";
25
+ readonly THEME_CHANGED: "THEME_CHANGED";
26
+ readonly CACHE_OPERATION: "CACHE_OPERATION";
27
+ readonly FILE_STATE_OPERATION: "FILE_STATE_OPERATION";
28
+ readonly SCROLL_OPERATION: "SCROLL_OPERATION";
29
+ readonly UPLOAD_OPERATION: "UPLOAD_OPERATION";
30
+ readonly DOCX_DOWNLOAD_FINALIZE: "DOCX_DOWNLOAD_FINALIZE";
31
+ readonly FETCH_ASSET: "FETCH_ASSET";
32
+ readonly INJECT_CONTENT_SCRIPT: "INJECT_CONTENT_SCRIPT";
33
+ readonly READ_LOCAL_FILE: "READ_LOCAL_FILE";
34
+ readonly DOWNLOAD_FILE: "DOWNLOAD_FILE";
35
+ };
36
+ export type ServiceMessageType = typeof ServiceMessageType[keyof typeof ServiceMessageType];
37
+ export declare const CommonMessageType: {
38
+ readonly RESPONSE: "RESPONSE";
39
+ };
40
+ export type CommonMessageType = typeof CommonMessageType[keyof typeof CommonMessageType];
41
+ export type AnyMessageType = RenderMessageType | ServiceMessageType | CommonMessageType;
42
+ export type RenderPayloadMap = {
43
+ RENDER_DIAGRAM: {
44
+ renderType: string;
45
+ input: string | object;
46
+ themeConfig?: RendererThemeConfig | null;
47
+ };
48
+ SET_THEME_CONFIG: {
49
+ config: RendererThemeConfig;
50
+ };
51
+ PING: Record<string, never>;
52
+ READY: Record<string, never>;
53
+ READY_ACK: Record<string, never>;
54
+ };
55
+ export type ServicePayloadMap = {
56
+ STORAGE_GET: {
57
+ keys: string | string[];
58
+ };
59
+ STORAGE_SET: {
60
+ items: Record<string, unknown>;
61
+ };
62
+ STORAGE_REMOVE: {
63
+ keys: string | string[];
64
+ };
65
+ OFFSCREEN_READY: Record<string, never>;
66
+ OFFSCREEN_DOM_READY: Record<string, never>;
67
+ OFFSCREEN_ERROR: {
68
+ error: string;
69
+ filename?: string;
70
+ lineno?: number;
71
+ };
72
+ LOCALE_CHANGED: {
73
+ locale: string;
74
+ };
75
+ THEME_CHANGED: {
76
+ themeId: string;
77
+ };
78
+ CACHE_OPERATION: {
79
+ operation: 'get' | 'set' | 'clear' | 'getStats' | 'delete';
80
+ key?: string;
81
+ value?: unknown;
82
+ dataType?: string;
83
+ };
84
+ FILE_STATE_OPERATION: {
85
+ operation: 'get' | 'set' | 'clear';
86
+ url: string;
87
+ state?: FileState;
88
+ };
89
+ SCROLL_OPERATION: {
90
+ operation: 'get' | 'clear';
91
+ url: string;
92
+ };
93
+ UPLOAD_OPERATION: {
94
+ operation: 'init' | 'chunk' | 'finalize' | 'abort';
95
+ purpose?: string;
96
+ encoding?: 'text' | 'base64';
97
+ expectedSize?: number;
98
+ metadata?: Record<string, unknown>;
99
+ chunkSize?: number;
100
+ token?: string;
101
+ chunk?: string;
102
+ };
103
+ DOCX_DOWNLOAD_FINALIZE: {
104
+ token: string;
105
+ };
106
+ FETCH_ASSET: {
107
+ path: string;
108
+ };
109
+ INJECT_CONTENT_SCRIPT: {
110
+ url: string;
111
+ };
112
+ READ_LOCAL_FILE: {
113
+ filePath: string;
114
+ binary?: boolean;
115
+ };
116
+ DOWNLOAD_FILE: {
117
+ filename: string;
118
+ data: string;
119
+ mimeType?: string;
120
+ };
121
+ };
122
+ export type RequestEnvelope<TType extends AnyMessageType, TPayload> = {
123
+ id: string;
124
+ type: TType;
125
+ payload: TPayload;
126
+ timestamp: number;
127
+ source?: string;
128
+ };
129
+ export type ResponseEnvelope = {
130
+ type: 'RESPONSE';
131
+ requestId: string;
132
+ ok: boolean;
133
+ data?: unknown;
134
+ error?: {
135
+ code?: string;
136
+ message: string;
137
+ details?: unknown;
138
+ };
139
+ };
140
+ export type RenderRequestEnvelope<T extends RenderMessageType> = RequestEnvelope<T, T extends keyof RenderPayloadMap ? RenderPayloadMap[T] : unknown>;
141
+ export type ServiceRequestEnvelope<T extends ServiceMessageType> = RequestEnvelope<T, T extends keyof ServicePayloadMap ? ServicePayloadMap[T] : unknown>;
142
+ export type RenderResponseData = RenderResult;
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Platform Type Definitions
3
+ * Types for platform abstraction layer
4
+ */
5
+ import type { RendererThemeConfig, RenderResult } from './render';
6
+ import type { CacheStats, SimpleCacheStats } from './cache';
7
+ import type { FileState } from './core';
8
+ export type PlatformType = 'chrome' | 'firefox' | 'mobile' | 'vscode' | 'node';
9
+ /**
10
+ * Platform message API
11
+ */
12
+ export interface PlatformMessageAPI {
13
+ send(message: Record<string, unknown>): Promise<unknown>;
14
+ addListener(handler: (message: unknown) => void): void;
15
+ }
16
+ /**
17
+ * Platform storage API
18
+ */
19
+ export interface PlatformStorageAPI {
20
+ get(keys: string[]): Promise<Record<string, unknown>>;
21
+ set(items: Record<string, unknown>): Promise<void>;
22
+ }
23
+ /**
24
+ * Platform resource API
25
+ */
26
+ export interface PlatformResourceAPI {
27
+ fetch(path: string): Promise<string>;
28
+ getURL(path: string): string;
29
+ }
30
+ /**
31
+ * Platform i18n API
32
+ */
33
+ export interface PlatformI18nAPI {
34
+ translate(key: string, substitutions?: string | string[]): string;
35
+ getUILanguage(): string;
36
+ }
37
+ /**
38
+ * Platform bridge API (mobile WebView ↔ host)
39
+ */
40
+ export interface PlatformBridgeAPI {
41
+ sendRequest<T = unknown>(type: string, payload: unknown): Promise<T>;
42
+ postMessage(type: string, payload: unknown): void;
43
+ addListener(handler: (message: unknown) => void): () => void;
44
+ }
45
+ /**
46
+ * Download options
47
+ */
48
+ export interface DownloadOptions {
49
+ saveAs?: boolean;
50
+ mimeType?: string;
51
+ onProgress?: (progress: {
52
+ uploaded: number;
53
+ total: number;
54
+ }) => void;
55
+ }
56
+ /**
57
+ * Cache service interface
58
+ */
59
+ export interface CacheService {
60
+ init(): Promise<void>;
61
+ calculateHash(text: string): Promise<string>;
62
+ generateKey(content: string, type: string, themeConfig?: RendererThemeConfig | null): Promise<string>;
63
+ get(key: string): Promise<unknown>;
64
+ set(key: string, value: unknown, type?: string): Promise<boolean>;
65
+ clear(): Promise<boolean>;
66
+ getStats(): Promise<CacheStats | SimpleCacheStats | null>;
67
+ }
68
+ /**
69
+ * Renderer service interface
70
+ */
71
+ export interface RendererService {
72
+ init(): Promise<void>;
73
+ setThemeConfig(config: RendererThemeConfig): void;
74
+ getThemeConfig(): RendererThemeConfig | null;
75
+ render(type: string, content: string | object): Promise<RenderResult>;
76
+ }
77
+ /**
78
+ * Storage service interface
79
+ */
80
+ export interface StorageService {
81
+ get(keys: string[]): Promise<Record<string, unknown>>;
82
+ set(data: Record<string, unknown>): Promise<void>;
83
+ remove(keys: string[]): Promise<void>;
84
+ }
85
+ /**
86
+ * File service interface
87
+ */
88
+ export interface FileService {
89
+ download(blob: Blob | string, filename: string, options?: DownloadOptions): Promise<void>;
90
+ }
91
+ /**
92
+ * File state service interface
93
+ */
94
+ export interface FileStateService {
95
+ get(url: string): Promise<FileState>;
96
+ set(url: string, state: FileState): void;
97
+ clear(url: string): Promise<void>;
98
+ }
99
+ /**
100
+ * Resource service interface
101
+ */
102
+ export interface ResourceService {
103
+ fetch(path: string): Promise<string>;
104
+ getURL(path: string): string;
105
+ }
106
+ /**
107
+ * I18n service interface
108
+ */
109
+ export interface I18nService {
110
+ translate(key: string, substitutions?: string | string[]): string;
111
+ getUILanguage(): string;
112
+ setLocale?(locale: string): Promise<void>;
113
+ }
114
+ /**
115
+ * Message service interface
116
+ */
117
+ export interface MessageService {
118
+ send(message: Record<string, unknown>): Promise<unknown>;
119
+ addListener(handler: (message: unknown) => void): void;
120
+ }
121
+ /**
122
+ * Read file options
123
+ */
124
+ export interface ReadFileOptions {
125
+ /** If true, returns base64-encoded content for binary files */
126
+ binary?: boolean;
127
+ }
128
+ /**
129
+ * Unified document service for file operations and document context.
130
+ * Replaces scattered platform detection and file reading logic.
131
+ *
132
+ * Platform implementations:
133
+ * - Chrome/Firefox: Uses window.location.href as base, READ_LOCAL_FILE message
134
+ * - VS Code: Uses host-provided paths, READ_LOCAL_FILE/FETCH_REMOTE_IMAGE messages
135
+ * - Mobile: Uses Flutter bridge, READ_RELATIVE_FILE message
136
+ */
137
+ export interface DocumentService {
138
+ /** Absolute path to the current document (e.g., /Users/x/doc.md) */
139
+ readonly documentPath: string;
140
+ /** Directory containing the document (e.g., /Users/x/) */
141
+ readonly documentDir: string;
142
+ /** Base URL for resolving relative paths (platform-specific) */
143
+ readonly baseUrl: string;
144
+ /** Whether relative image paths need URI rewriting (VS Code only) */
145
+ readonly needsUriRewrite: boolean;
146
+ /**
147
+ * Read a local file by absolute path.
148
+ * @param absolutePath - Full path to the file
149
+ * @param options - Read options (binary mode, etc.)
150
+ * @returns File content (string or base64 if binary)
151
+ */
152
+ readFile(absolutePath: string, options?: ReadFileOptions): Promise<string>;
153
+ /**
154
+ * Read a file relative to the current document.
155
+ * @param relativePath - Path relative to documentDir
156
+ * @param options - Read options (binary mode, etc.)
157
+ * @returns File content (string or base64 if binary)
158
+ */
159
+ readRelativeFile(relativePath: string, options?: ReadFileOptions): Promise<string>;
160
+ /**
161
+ * Fetch a remote resource (HTTP/HTTPS).
162
+ * On VS Code, this bypasses CSP by proxying through the host.
163
+ * @param url - Remote URL
164
+ * @returns Binary content as Uint8Array
165
+ */
166
+ fetchRemote(url: string): Promise<Uint8Array>;
167
+ /**
168
+ * Resolve a relative path to an absolute path.
169
+ * @param relativePath - Path relative to documentDir
170
+ * @returns Absolute file path
171
+ */
172
+ resolvePath(relativePath: string): string;
173
+ /**
174
+ * Convert a local file path to a URL suitable for the current platform.
175
+ * - Chrome/Firefox: file:// URL
176
+ * - VS Code: vscode-webview-resource:// URL
177
+ * - Mobile: file:// URL
178
+ */
179
+ toResourceUrl(absolutePath: string): string;
180
+ /**
181
+ * Set the current document path.
182
+ * Called by the platform when a new document is opened.
183
+ * @param path - Absolute path to the document
184
+ * @param baseUrl - Optional base URL for resource loading (VS Code)
185
+ */
186
+ setDocumentPath(path: string, baseUrl?: string): void;
187
+ }
188
+ /**
189
+ * Complete platform API interface
190
+ */
191
+ export interface PlatformAPI {
192
+ platform: PlatformType;
193
+ cache: CacheService;
194
+ renderer: RendererService;
195
+ storage: StorageService;
196
+ file: FileService;
197
+ fileState: FileStateService;
198
+ resource: ResourceService;
199
+ i18n: I18nService;
200
+ message: MessageService;
201
+ /** Unified document service for file operations (Phase 1) */
202
+ document?: DocumentService;
203
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Plugin Type Definitions
3
+ * Types for plugin system and async task queue
4
+ */
5
+ import type { TranslateFunction } from './core';
6
+ /**
7
+ * Task status enumeration
8
+ */
9
+ export type TaskStatus = 'ready' | 'fetching' | 'error' | 'completed';
10
+ /**
11
+ * Task data
12
+ */
13
+ export interface TaskData {
14
+ id: string;
15
+ code?: string;
16
+ sourceHash: string;
17
+ [key: string]: unknown;
18
+ }
19
+ /**
20
+ * Async task object
21
+ */
22
+ export interface AsyncTaskObject {
23
+ id: string;
24
+ callback: (data: TaskData) => Promise<void>;
25
+ data: TaskData;
26
+ type: string;
27
+ status: TaskStatus;
28
+ error: Error | null;
29
+ setReady: () => void;
30
+ setError: (error: Error) => void;
31
+ }
32
+ /**
33
+ * Placeholder result for async task
34
+ */
35
+ export interface PlaceholderResult {
36
+ type: 'html';
37
+ value: string;
38
+ }
39
+ /**
40
+ * Async task registration result
41
+ */
42
+ export interface AsyncTaskResult {
43
+ task: AsyncTaskObject;
44
+ placeholder: PlaceholderResult;
45
+ }
46
+ /**
47
+ * Async task plugin interface
48
+ */
49
+ export interface AsyncTaskPlugin {
50
+ type: string;
51
+ isInline: () => boolean;
52
+ }
53
+ /**
54
+ * Async task queue manager interface
55
+ */
56
+ export interface AsyncTaskQueueManager {
57
+ asyncTask: (callback: (data: TaskData) => Promise<void>, data?: Record<string, unknown>, plugin?: AsyncTaskPlugin | null, translate?: TranslateFunction | null, initialStatus?: TaskStatus) => AsyncTaskResult;
58
+ processAsyncTasks: (translate: TranslateFunction, showProcessingIndicator: () => void, hideProcessingIndicator: () => void, updateProgress: (completed: number, total: number) => void) => Promise<void>;
59
+ getQueueLength: () => number;
60
+ }
61
+ /**
62
+ * AST Node for markdown processing
63
+ */
64
+ export interface ASTNode {
65
+ type: string;
66
+ value?: string;
67
+ lang?: string;
68
+ meta?: string;
69
+ url?: string;
70
+ alt?: string;
71
+ title?: string;
72
+ children?: ASTNode[];
73
+ data?: unknown;
74
+ }
75
+ /**
76
+ * Plugin interface
77
+ */
78
+ export interface IPlugin {
79
+ type: string;
80
+ match(node: ASTNode): boolean;
81
+ transform(node: ASTNode, context: unknown): string;
82
+ render?(data: unknown): Promise<string>;
83
+ isInline?(): boolean;
84
+ createTaskData?(content: string): TaskData;
85
+ }
86
+ /**
87
+ * Renderer interface used by plugins
88
+ */
89
+ export interface PluginRenderer {
90
+ render(type: string, content: string | object): Promise<PluginRenderResult | null>;
91
+ }
92
+ /**
93
+ * Render result from plugin renderer
94
+ */
95
+ export interface PluginRenderResult {
96
+ base64?: string;
97
+ width: number;
98
+ height: number;
99
+ format: string;
100
+ error?: string;
101
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Render Type Definitions
3
+ * Types for rendering system (diagrams, charts, SVG, etc.)
4
+ */
5
+ /**
6
+ * Render result from renderers
7
+ */
8
+ export interface RenderResult {
9
+ base64?: string;
10
+ width: number;
11
+ height: number;
12
+ format: string;
13
+ success?: boolean;
14
+ error?: string;
15
+ }
16
+ /**
17
+ * Render result type enumeration
18
+ */
19
+ export type RenderResultType = 'image' | 'text' | 'error' | 'empty';
20
+ /**
21
+ * Unified render result content
22
+ */
23
+ export interface RenderResultContent {
24
+ data?: Uint8Array;
25
+ base64?: string;
26
+ text?: string;
27
+ width?: number;
28
+ height?: number;
29
+ format?: string;
30
+ }
31
+ /**
32
+ * Unified render result display options
33
+ */
34
+ export interface RenderResultDisplay {
35
+ inline: boolean;
36
+ alignment: 'left' | 'center' | 'right';
37
+ }
38
+ /**
39
+ * Unified render result (used by plugin system)
40
+ */
41
+ export interface UnifiedRenderResult {
42
+ type: RenderResultType;
43
+ content: RenderResultContent;
44
+ display: RenderResultDisplay;
45
+ }
46
+ /**
47
+ * Theme configuration for renderers
48
+ * This is a simplified config passed to render workers
49
+ */
50
+ export interface RendererThemeConfig {
51
+ fontFamily?: string;
52
+ fontSize?: number;
53
+ background?: string;
54
+ foreground?: string;
55
+ /** Diagram rendering style: 'normal' or 'handDrawn' */
56
+ diagramStyle?: 'normal' | 'handDrawn';
57
+ }