refactor: extract ResourcePathResolver from PandocCommandBuilder

Create dedicated ResourcePathResolver to handle resource path discovery and caching:

- Extract resource path caching logic (~110 lines)
- Move vault scanning and attachment directory discovery
- Eliminate code duplication: remove duplicate resolveExecutablePath()
- Simplify PandocCommandBuilder from ~287 to ~204 lines

Changes:
- NEW: src/converters/pandoc/ResourcePathResolver.ts
- MODIFIED: PandocCommandBuilder - use ResourcePathResolver and PathResolver
- MODIFIED: PandocTypstConverter - use centralized PathResolver

Benefits:
- Clear separation of concerns
- Reusable resource path logic
- Reduced code duplication
- Better maintainability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jarvis committed 2025-09-10 12:05:57 +02:00
1 parent 84bd5fb674
commit 1fc47fe9ae
3 files changed
+154 -124

No files matched your search

+4 -1
View File
@@ -14,12 +14,14 @@ import type { obsidianTypstPDFExportSettings } from '../core/settings';
import { TempDirectoryManager } from '../core/TempDirectoryManager';
import { PandocCommandBuilder } from './pandoc/PandocCommandBuilder';
import { PathResolver } from '../plugin/PathResolver';
export class PandocTypstConverter {
private tempDir: string | null = null;
private cleanupHandlers: (() => void)[] = [];
private plugin: any; // Will be properly typed when we refactor the main plugin class
private commandBuilder: PandocCommandBuilder;
private pathResolver: PathResolver;
/**
* Create a new PandocTypstConverter instance
@@ -34,6 +36,7 @@ export class PandocTypstConverter {
) {
this.plugin = plugin;
this.commandBuilder = new PandocCommandBuilder(plugin);
this.pathResolver = new PathResolver(plugin);
// Set up cleanup handlers for process termination
this.setupCleanup();
}
@@ -272,7 +275,7 @@ export class PandocTypstConverter {
*/
private async executePandoc(args: string[], progressCallback?: ProgressCallback): Promise<ConversionResult> {
return new Promise((resolve) => {
const pandocPath = this.commandBuilder.resolveExecutablePath(this.pandocOptions.pandocPath, 'pandoc');
const pandocPath = this.pathResolver.resolveExecutablePath(this.pandocOptions.pandocPath, 'pandoc');
const timeout = this.pandocOptions.timeout || 60000;
// Log the exact command being executed for debugging