feat: add comprehensive template embedding and release automation

Implements dual-strategy template distribution for reliable plugin deployment:

Template Embedding System:
- Add esbuild plugin to embed .typ templates as base64 strings in main.js
- Create EmbeddedTemplateManager for automatic template extraction
- Add TypeScript declarations for virtual template-embed module
- Templates auto-extract on plugin load if missing from disk

Release Automation:
- Add GitHub Actions workflow for automated ZIP releases
- Create package-plugin.js script for complete distribution packages
- Update version-bump.mjs for Obsidian-compliant tags (no 'v' prefix)
- Ensure releases include templates/ directory for manual installations

Documentation Updates:
- Comprehensive installation instructions with troubleshooting
- Clear warnings about requiring complete ZIP packages
- Multiple installation methods including manual and automated

This ensures the plugin works regardless of installation method:
- ZIP releases provide templates/ directory (primary method)
- Embedded templates auto-extract as fallback (secondary method)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jarvis committed 2025-09-05 15:34:00 +02:00
1 parent d40253e6c4
commit 8557720f43
10 files changed
+1619 -21

No files matched your search

+22
View File
@@ -32,6 +32,7 @@ import { MarkdownPreprocessor } from './src/converters/MarkdownPreprocessor';
import { ExportConfigModal } from './src/ui/modal/ExportConfigModal';
import { ExportConfig, ExportConfigModalSettings } from './src/ui/modal/modalTypes';
import { TemplateManager } from './src/templates/TemplateManager';
import { EmbeddedTemplateManager } from './src/templates/embeddedTemplates';
import { FolderSuggest } from './src/ui/components/FolderSuggest';
import { SUPPORTED_PAPER_SIZES } from './src/utils/paperSizeMapper';
import * as path from 'path';
@@ -41,11 +42,32 @@ export class obsidianTypstPDFExport extends Plugin {
settings: obsidianTypstPDFExportSettings;
private converter: PandocTypstConverter;
templateManager: TemplateManager;
private embeddedTemplateManager: EmbeddedTemplateManager;
private currentExportController: AbortController | null = null;
async onload() {
await this.loadSettings();
// Initialize embedded template manager
const vaultPath = (this.app.vault.adapter as any).basePath;
const pluginDir = path.join(vaultPath, this.manifest.dir!);
this.embeddedTemplateManager = new EmbeddedTemplateManager(pluginDir);
// Extract any missing templates from embedded data
try {
const extractionResult = this.embeddedTemplateManager.extractAllMissingTemplates();
if (extractionResult.extracted.length > 0) {
console.log(`Extracted ${extractionResult.extracted.length} embedded templates:`, extractionResult.extracted);
}
if (extractionResult.failed.length > 0) {
console.warn(`Failed to extract ${extractionResult.failed.length} templates:`, extractionResult.failed);
new Notice(`Warning: Failed to extract some templates. Plugin may not work correctly.`);
}
} catch (error) {
console.error('Error during template extraction:', error);
new Notice(`Error extracting templates: ${error.message}`);
}
// Initialize components
this.converter = new PandocTypstConverter(this);
this.templateManager = new TemplateManager(this);