Replace complex heuristic with precise pattern matching for absolute paths:
- Unix paths: starts with /
- Windows drive letters: C:\ or C:/ using regex /^[a-zA-Z]:[/\\]/
- Windows UNC paths: \\server\share
Removes unreliable temp/tmp path indicators and file: URL checks while
maintaining fs fallback behavior for proper external file processing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced vulnerable string operations (startsWith/includes) with normalized path comparison
- Uses normalizePath() for proper cross-platform path normalization
- Constructs explicit temp directory paths for precise validation
- Prevents path traversal attacks like '../../../etc/passwd' or similar
- Ensures directory validation is based on actual path structure, not string matching
- Maintains functionality while improving security posture
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fix pathUtils.fileExists() to handle absolute filesystem paths
- Add proper conversion from absolute to vault-relative paths
- Add fs fallback for external files outside vault
- Resolves 'File not found' errors for embedded PDF, image, and document files
- Maintains compatibility with both vault-relative and absolute paths
This fixes the path resolution issue that occurred after migrating to vault.adapter,
where embedded files were showing as 'not found' because absolute paths were being
passed to vault.adapter.exists() which only accepts vault-relative paths.
- Updated TempDirectoryManager to use vault.adapter methods exclusively
- Made all temp directory operations async (ensureTempDir, cleanupTempDir, cleanupAllTempDirs)
- Removed unnecessary fs fallback since App instance is always available in Obsidian plugins
- Updated calling code in PandocTypstConverter and ExportOrchestrator to handle async
- Updated PluginLifecycle cleanup methods to use fire-and-forget async pattern
- All path operations now use normalizePath for cross-platform compatibility
- Simplified interface - App parameter is now required as it should be
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add ABOUTME comments following guidelines
- Implement safe FileSystemAdapter access with proper type checking
- Use vault.adapter methods (exists, mkdir, list, remove)
- Use normalizePath() consistently for all paths
- Match existing patterns (cleanupDir only removes files, returns boolean)
- Add user-friendly error messages with Notice
- Place in src/core/ alongside other core utilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes 23 TypeScript errors in 8 files by properly handling type assertions
and template variable types:
**DataAdapter Casting Issues (8 fixes):**
- Use double assertion `as unknown as { basePath: string }` instead of
direct casting to avoid TypeScript's type overlap validation
- Files: BinaryLocator, ExportOrchestrator, PathResolver, PluginLifecycle, TemplateManager
**Template Variables Type Issues (15 fixes):**
- Add `undefined` to Record<string, string|number|boolean> union type
- Convert template variable values to appropriate types before passing to UI methods:
- String() for dropdown setValue() methods
- Number() for slider setValue() methods
- Update interface definitions in modalTypes.ts and ModalState.ts
The double assertion pattern is required because basePath exists at runtime
in Obsidian's FileSystemAdapter but isn't in the TypeScript definitions.
Adding undefined to template variables properly handles uninitialized values.
All changes maintain full functionality while ensuring type safety.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace all @typescript-eslint/no-explicit-any warnings with proper type assertions
and union types to meet Obsidian plugin review requirements.
Changes:
- Replace (adapter as any).basePath with (adapter as { basePath: string }).basePath
- Change template variable types from Record<string, any> to Record<string, string | number | boolean>
- Change frontmatter types from Record<string, any> to Record<string, unknown>
- Fix error handling in PdfCliExecutor with proper type assertion
- Update method signatures in TypstVariableMapper for type safety
This eliminates all 42 @typescript-eslint/no-explicit-any warnings while
maintaining full functionality and improving type safety.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused imports and variables across multiple files
- Fix prefer-const warnings by changing let to const
- Remove unused catch block variables or convert to parameter-less catch blocks
- Update package-lock.json with TypeScript-ESLint v8 dependencies
- Reduce ESLint warnings from 42 to 22 (remaining are necessary 'any' types)
- All remaining warnings are for Obsidian API compatibility
Fixes improve code quality while maintaining functionality.
Remaining 'any' type warnings are appropriate for Obsidian plugin development.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Update TypeScript to v5.9.2 for compatibility with typescript-eslint v8
- Install typescript-eslint v8.43.0 for consolidated TypeScript ESLint support
- Rewrite eslint.config.mjs using modern flat config format without FlatCompat
- Incorporate Obsidian sample plugin ESLint rules and best practices:
* Allow @ts-ignore comments for Obsidian API quirks
* Allow require() imports for mixed module environment
* Allow empty functions common in plugin architecture
* Configure no-unused-vars as warnings with ignore patterns
- Configure proper Node.js and ES2022 globals
- Add comprehensive ignore patterns for build artifacts
- Reduce linting issues from 261 errors to 0 errors, 42 warnings
- All builds now pass with TypeScript checking and ESLint validation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing ExportErrorHandler import in SettingsTab.ts
- Add customEnvironmentVariables property to settings interface
- Fix undefined metadata access with optional chaining in EmbedProcessor.ts
- Update ModalState.ts to use new nested settings structure
- Simplify ExportConfigModal.ts to use full settings object
- Add null safety checks for templateDropdown in GeneralSection.ts
- Replace all 'any' types with proper TypeScript types throughout codebase
- Fix processedResult parameters to use PreprocessingResult interface
- Update UI modal types: app parameter (App), pluginDefaults (obsidianTypstPDFExportSettings)
- Fix dropdown components to use DropdownComponent from Obsidian API
- Replace plugin 'any' types with obsidianTypstPDFExport throughout converters
- Fix margins parameter to use proper interface structure
- Update fs parameter to use proper Node.js fs module type
- Improve error handling with proper unknown type and type guards
- Remove unused PdfEmbedProcessor and clean up imports
Achieves complete type safety with zero remaining 'any' types across src/ directory.
Provides better IDE support, compile-time error detection, and maintainability.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move showDependencyStatus() and checkDependenciesAsync() from main.ts to DependencyChecker.ts as static methods
- Replace 31-line implementations with 12-line delegation calls in main.ts
- Add necessary imports (Notice, ExportErrorHandler) to DependencyChecker.ts
- Maintain same public API while improving separation of concerns
- Reduce main.ts from 280 to 253 lines (total 79% reduction from original 1233 lines)
This completes Step 1.10 of the refactoring plan, achieving clean delegation
of dependency management functionality while preserving backward compatibility.
Build verified: ✅ TypeScript compilation successful
- Update default ImageMagick executable from 'convert' to 'magick' in constants
- Remove deprecated 'convert' subcommand from ImageMagick spawn calls
- Update UI labels and settings descriptions to reflect 'magick' command
- Fix pdf2img PATH environment to include Node.js installation paths
This resolves ImageMagick v7 deprecation warning and fixes pdf2img execution
failure caused by missing Node.js in PATH. The 'convert' command was deprecated
in ImageMagick v7 in favor of the unified 'magick' command.
Fixes: "env: node: No such file or directory" error in pdf2img execution
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add support for user-configured additionalPaths in dependency checking
- Implement comprehensive default system paths (home-relative and absolute)
- Update path resolution to handle both full paths and bare executable names
- Use 'which' command fallback with augmented PATH for executable discovery
- Ensure consistent path handling across sync and async dependency methods
This resolves issues where executables installed in common locations like
/opt/homebrew/bin were not found when executable path settings were empty.
The plugin now searches standard package manager installation directories
by default while respecting user-configured additional paths.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace hardcoded '.obsidian' paths with Vault#configDir for proper config directory support
- Move inline styles to CSS classes for better theme compatibility
- Remove unnecessary type casting by using proper type predicates
- Add proper TypeScript type narrowing for filtered arrays
This addresses all required issues identified by the Obsidian Review Bot:
* TempDirectoryManager now accepts configDir parameter from app.vault.configDir
* PdfToImageConverter uses configDir instead of hardcoded '.obsidian'
* ExportConfigModal uses CSS classes (.export-progress-visible, .export-form-hidden) instead of inline styles
* Progress bar width controlled via CSS custom property --progress-width
* Removed 'as TFile[]' casting by implementing isMarkdownFile type predicate
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updates the plugin's name from "Obsidian Typst PDF Export" to "Typst PDF Export".
This change simplifies the plugin's identifier and display name,
making it more concise and user-friendly. It involves updates to
the manifest file, plugin configuration, and references within the
codebase.
- Add embedPdfFiles setting to control PDF attachment embedding
- Add printFrontmatter setting to display frontmatter as formatted text
- Implement frontmatter formatting with proper line breaks and bullet lists
- Add settings toggles to both plugin settings and export modal
- Fix filename sanitization for PDF preview images with spaces
- Ensure modal export config includes new behavior settings
- Always generate PDF preview images regardless of embedding setting
The frontmatter display formats long comma-separated values (like email lists)
as bulleted lists and adds proper line breaks after each property label.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Specifies the types for data and close events in process handlers.
This improves code clarity and maintainability by ensuring that the
data received from stdout and stderr streams is treated as a Buffer,
and the close event receives a number or null for the exit code.
Enhances security by validating output paths and executable paths.
This prevents path traversal attacks and command injection vulnerabilities
by ensuring that users can only specify valid relative paths within the vault
and safe executable paths. It also displays notices when the path is deemed unsafe.
Replaces `child_process.exec` with `child_process.spawn` for both asynchronous and synchronous dependency checks.
This change mitigates potential command injection vulnerabilities by passing arguments separately, enhancing the security of the application.
Moves components and modules to more appropriate directories.
This change improves project organization and maintainability by grouping related files into logical directories, enhancing code discoverability and reducing potential naming conflicts.
Centralizes temporary directory creation and cleanup using a dedicated `TempDirectoryManager` class.
This change improves code maintainability and reduces redundancy by encapsulating temporary directory logic.
It also ensures that temporary directories are properly cleaned up after export operations, preventing potential disk space issues.
Introduces `ExportErrorHandler` to manage export-related errors, progress notices, and batch results.
This change provides a unified way to handle errors, display progress, and report results of export operations, improving code maintainability and user experience.
Introduces a helper class to encapsulate the logic for preparing the export configuration modal settings.
This improves code readability and maintainability by extracting the complex settings preparation logic from the main plugin file.
The helper handles both single and multi-file export scenarios, ensuring consistent settings across different export contexts.
Consolidates dependency checking logic into a dedicated `DependencyChecker` class.
This improves code organization and reusability.
It now uses a single method for checking all dependencies, both asynchronously (for displaying status) and synchronously (for startup checks).
It also augments the PATH environment variable to include common binary locations to improve detection.
The status modal now displays more detailed information about each dependency.
Updates the margin settings to directly use centimeters, removing unnecessary conversions to points.
This simplifies the configuration and improves accuracy in setting page margins for PDF exports.
The settings tab and modal now accept and display margins in centimeters.
Adds sections to the export configuration modal for behavior, page setup, and typography.
These sections allow users to configure export behavior like opening the PDF after export and preserving folder structure, as well as page setup options like page size, orientation, and margins.
Additionally, typography options for font selection and size configuration are included.
Updates default settings for export format and adds default values for new settings.
Removes the old TypographySection file.
Major improvements to PDF export functionality and code organization:
- BREAKING: Refactor main.ts from 4224 to 994 lines by extracting modular components
- Replace broken PDF links with proper Typst pdf.embed() attachments
- Filter out unnecessary "Open:" links and Mail.app links from exports
- Fix duplicate title issue by replacing frontmatter title with filename
- Move temp file processing from system temp to plugin folder
- Clean up temp-images and temp-pandoc directories after export
- Remove timestamp from export filenames to match note names exactly
- Handle Unicode line separators (0x2028, 0x2029) in email content
- Improve markdown preprocessing with better frontmatter handling
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>