From 3cff3ff70a8e67099347bdd42c10409ff99c40d8 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 5 Sep 2025 16:57:23 +0200 Subject: [PATCH 1/3] Renames plugin to "Typst PDF Export" 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. --- .github/workflows/release.yml | 8 ++++---- main.ts | 8 ++++---- manifest.json | 2 +- scripts/package-plugin.js | 2 +- src/converters/PdfToImageConverter.ts | 6 +++--- src/core/TempDirectoryManager.ts | 4 ++-- src/templates/TemplateManager.ts | 2 +- src/ui/modal/sections/TypographySection.ts | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88200c9..0ec367f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ on: - '[0-9]+.[0-9]+.[0-9]+-*' env: - PLUGIN_NAME: obsidian-typst-pdf-export + PLUGIN_NAME: typst-pdf-export jobs: build: @@ -39,7 +39,7 @@ jobs: const path = require('path'); const archiver = require('archiver'); - const pluginName = process.env.PLUGIN_NAME || 'obsidian-typst-pdf-export'; + const pluginName = process.env.PLUGIN_NAME || 'typst-pdf-export'; const outputPath = `${pluginName}.zip`; console.log(`Creating release package: ${outputPath}`); @@ -117,7 +117,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref_name }} - name: Release ${{ steps.version.outputs.version }} + name: ${{ steps.version.outputs.version }} body: | # Obsidian Typst PDF Export ${{ steps.version.outputs.version }} @@ -130,7 +130,7 @@ jobs: ### Manual Installation 1. Download the `${{ env.PLUGIN_NAME }}.zip` file from this release - 2. Extract the ZIP file to your vault's plugins directory: `VaultFolder/.obsidian/plugins/obsidian-typst-pdf-export/` + 2. Extract the ZIP file to your vault's plugins directory: `VaultFolder/.obsidian/plugins/typst-pdf-export/` 3. Make sure the `templates/` directory is included 4. Reload Obsidian 5. Enable the plugin in Settings → Community Plugins diff --git a/main.ts b/main.ts index 44b201c..b3c77db 100644 --- a/main.ts +++ b/main.ts @@ -155,7 +155,7 @@ export class obsidianTypstPDFExport extends Plugin { typstPath: typstPath }; - await this.app.vault.adapter.write('.obsidian/plugins/obsidian-typst-pdf-export/fonts-cache.json', + await this.app.vault.adapter.write('.obsidian/plugins/typst-pdf-export/fonts-cache.json', JSON.stringify(cacheData, null, 2)); } catch (error) { console.error('Failed to cache fonts from typst:', error); @@ -178,7 +178,7 @@ export class obsidianTypstPDFExport extends Plugin { error: error.message }; - await this.app.vault.adapter.write('.obsidian/plugins/obsidian-typst-pdf-export/fonts-cache.json', + await this.app.vault.adapter.write('.obsidian/plugins/typst-pdf-export/fonts-cache.json', JSON.stringify(cacheData, null, 2)); } } @@ -188,7 +188,7 @@ export class obsidianTypstPDFExport extends Plugin { */ async getCachedFonts(): Promise { try { - const cacheContent = await this.app.vault.adapter.read('.obsidian/plugins/obsidian-typst-pdf-export/fonts-cache.json'); + const cacheContent = await this.app.vault.adapter.read('.obsidian/plugins/typst-pdf-export/fonts-cache.json'); const cacheData = JSON.parse(cacheContent); // Check if cache is older than 24 hours or typst path changed @@ -776,7 +776,7 @@ ${dependencyResult.allAvailable const fs = require('fs'); // Copy image to vault temp directory for access - const vaultTempImagesDir = pathModule.join(vaultBasePath, '.obsidian', 'plugins', 'obsidian-typst-pdf-export', 'temp-images'); + const vaultTempImagesDir = pathModule.join(vaultBasePath, '.obsidian', 'plugins', 'typst-pdf-export', 'temp-images'); await fs.promises.mkdir(vaultTempImagesDir, { recursive: true }); // Sanitize the basename for use in filename - replace problematic characters diff --git a/manifest.json b/manifest.json index cb76719..3dd7384 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "id": "obsidian-typst-pdf-export", + "id": "typst-pdf-export", "name": "Typst PDF Export", "version": "1.0.0", "minAppVersion": "1.9.12", diff --git a/scripts/package-plugin.js b/scripts/package-plugin.js index 2bd23de..ce0ca19 100644 --- a/scripts/package-plugin.js +++ b/scripts/package-plugin.js @@ -12,7 +12,7 @@ const fs = require('fs'); const path = require('path'); const archiver = require('archiver'); -const PLUGIN_NAME = 'obsidian-typst-pdf-export'; +const PLUGIN_NAME = 'typst-pdf-export'; async function packagePlugin() { const projectRoot = path.resolve(__dirname, '..'); diff --git a/src/converters/PdfToImageConverter.ts b/src/converters/PdfToImageConverter.ts index e7b06b7..a383c33 100644 --- a/src/converters/PdfToImageConverter.ts +++ b/src/converters/PdfToImageConverter.ts @@ -130,11 +130,11 @@ export class PdfToImageConverter { // Try multiple strategies to find the plugin directory const possiblePluginDirs = [ // Strategy 1: From process.cwd() if it's in the vault - path.join(process.cwd(), '.obsidian', 'plugins', 'obsidian-typst-pdf-export'), + path.join(process.cwd(), '.obsidian', 'plugins', 'typst-pdf-export'), // Strategy 2: Assuming we're running from vault root - path.join('.obsidian', 'plugins', 'obsidian-typst-pdf-export'), + path.join('.obsidian', 'plugins', 'typst-pdf-export'), // Strategy 3: Direct path if running in development - '/Users/alex/Obsidian/Dev/.obsidian/plugins/obsidian-typst-pdf-export' + '/Users/alex/Obsidian/Dev/.obsidian/plugins/typst-pdf-export' ]; // Find the first directory that exists and has node_modules diff --git a/src/core/TempDirectoryManager.ts b/src/core/TempDirectoryManager.ts index 27bc2bc..1a2f400 100644 --- a/src/core/TempDirectoryManager.ts +++ b/src/core/TempDirectoryManager.ts @@ -7,7 +7,7 @@ import { PLUGIN_DIRS } from './constants'; export interface TempDirectoryOptions { /** Base path for the vault */ vaultPath: string; - /** Plugin directory name (defaults to 'obsidian-typst-pdf-export') */ + /** Plugin directory name (defaults to 'typst-pdf-export') */ pluginName?: string; } @@ -19,7 +19,7 @@ export class TempDirectoryManager { constructor(options: TempDirectoryOptions) { this.vaultPath = options.vaultPath; - this.pluginName = options.pluginName || 'obsidian-typst-pdf-export'; + this.pluginName = options.pluginName || 'typst-pdf-export'; } /** diff --git a/src/templates/TemplateManager.ts b/src/templates/TemplateManager.ts index 22c8a52..7c13827 100644 --- a/src/templates/TemplateManager.ts +++ b/src/templates/TemplateManager.ts @@ -16,7 +16,7 @@ export class TemplateManager { // Templates are stored in the plugin directory this.templatesPath = path.join( (this.plugin.app.vault.adapter as any).basePath, - '.obsidian/plugins/obsidian-typst-pdf-export/templates' + '.obsidian/plugins/typst-pdf-export/templates' ); } diff --git a/src/ui/modal/sections/TypographySection.ts b/src/ui/modal/sections/TypographySection.ts index 1a94662..6c6c287 100644 --- a/src/ui/modal/sections/TypographySection.ts +++ b/src/ui/modal/sections/TypographySection.ts @@ -123,7 +123,7 @@ export class TypographySection implements ModalSection { try { // Access the plugin instance through the app // @ts-ignore - accessing private plugin manager - const plugin = this.app?.plugins?.plugins?.['obsidian-typst-pdf-export']; + const plugin = this.app?.plugins?.plugins?.['typst-pdf-export']; if (plugin && plugin.getCachedFonts) { return await plugin.getCachedFonts(); } From 5519c9895744c25bae1f1fd982f014d74a70d3cd Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 5 Sep 2025 17:56:56 +0200 Subject: [PATCH 2/3] Improves plugin directory path handling dynamically Updates file path resolution to use plugin manifest directory dynamically Replaces hardcoded plugin directory paths with more flexible approach - Uses `this.manifest.dir!` to determine plugin directory - Supports better cross-platform and installation compatibility - Removes static path references in multiple plugin components Enhances plugin robustness by making directory paths more configurable --- README.md | 16 ++++++++-------- main.ts | 11 +++++++---- src/converters/PdfToImageConverter.ts | 9 +++++---- src/templates/TemplateManager.ts | 3 ++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7ba63b4..4f32656 100644 --- a/README.md +++ b/README.md @@ -59,11 +59,11 @@ Typst offers several advantages over standard PDF export: **⚠️ Important**: This plugin requires template files to function. Always use the complete ZIP package. 1. Go to [GitHub Releases](https://github.com/akucera/obsidian-typst-pdf-export/releases) -2. Download the **complete ZIP package** (`obsidian-typst-pdf-export.zip`) - **NOT just main.js** -3. Extract the entire contents to `{VaultFolder}/.obsidian/plugins/obsidian-typst-pdf-export/` +2. Download the **complete ZIP package** (`typst-pdf-export.zip`) - **NOT just main.js** +3. Extract the entire contents to `{VaultFolder}/.obsidian/plugins/typst-pdf-export/` 4. Ensure the `templates/` directory is included with all `.typ` files: ``` - .obsidian/plugins/obsidian-typst-pdf-export/ + .obsidian/plugins/typst-pdf-export/ ├── main.js ├── manifest.json ├── styles.css @@ -90,8 +90,8 @@ For development or the latest changes: 1. Clone the repository to your vault's plugins folder: ```bash cd {VaultFolder}/.obsidian/plugins/ - git clone https://github.com/akucera/obsidian-typst-pdf-export.git - cd obsidian-typst-pdf-export + git clone https://github.com/akucera/obsidian-typst-pdf-export.git typst-pdf-export + cd typst-pdf-export ``` 2. Install dependencies and build: ```bash @@ -268,8 +268,8 @@ JB ```bash # Clone the repository -git clone https://github.com/akucera/obsidian-typst-pdf-export.git -cd obsidian-typst-pdf-export +git clone https://github.com/akucera/obsidian-typst-pdf-export.git typst-pdf-export +cd typst-pdf-export # Install dependencies npm install @@ -281,7 +281,7 @@ npm run dev ### Project Structure ``` -obsidian-typst-pdf-export/ +typst-pdf-export/ ├── src/ │ ├── core/ # Core system components │ ├── converters/ # Conversion pipeline diff --git a/main.ts b/main.ts index b3c77db..ca0d402 100644 --- a/main.ts +++ b/main.ts @@ -155,7 +155,8 @@ export class obsidianTypstPDFExport extends Plugin { typstPath: typstPath }; - await this.app.vault.adapter.write('.obsidian/plugins/typst-pdf-export/fonts-cache.json', + const fontsCachePath = path.join(this.manifest.dir!, 'fonts-cache.json'); + await this.app.vault.adapter.write(fontsCachePath, JSON.stringify(cacheData, null, 2)); } catch (error) { console.error('Failed to cache fonts from typst:', error); @@ -178,7 +179,8 @@ export class obsidianTypstPDFExport extends Plugin { error: error.message }; - await this.app.vault.adapter.write('.obsidian/plugins/typst-pdf-export/fonts-cache.json', + const fontsCachePath = path.join(this.manifest.dir!, 'fonts-cache.json'); + await this.app.vault.adapter.write(fontsCachePath, JSON.stringify(cacheData, null, 2)); } } @@ -188,7 +190,8 @@ export class obsidianTypstPDFExport extends Plugin { */ async getCachedFonts(): Promise { try { - const cacheContent = await this.app.vault.adapter.read('.obsidian/plugins/typst-pdf-export/fonts-cache.json'); + const fontsCachePath = path.join(this.manifest.dir!, 'fonts-cache.json'); + const cacheContent = await this.app.vault.adapter.read(fontsCachePath); const cacheData = JSON.parse(cacheContent); // Check if cache is older than 24 hours or typst path changed @@ -776,7 +779,7 @@ ${dependencyResult.allAvailable const fs = require('fs'); // Copy image to vault temp directory for access - const vaultTempImagesDir = pathModule.join(vaultBasePath, '.obsidian', 'plugins', 'typst-pdf-export', 'temp-images'); + const vaultTempImagesDir = pathModule.join(vaultBasePath, this.manifest.dir!, 'temp-images'); await fs.promises.mkdir(vaultTempImagesDir, { recursive: true }); // Sanitize the basename for use in filename - replace problematic characters diff --git a/src/converters/PdfToImageConverter.ts b/src/converters/PdfToImageConverter.ts index a383c33..9576b1a 100644 --- a/src/converters/PdfToImageConverter.ts +++ b/src/converters/PdfToImageConverter.ts @@ -128,13 +128,14 @@ export class PdfToImageConverter { let pluginDir: string; // Try multiple strategies to find the plugin directory + const pluginDirName = this.plugin?.manifest?.dir || 'typst-pdf-export'; const possiblePluginDirs = [ // Strategy 1: From process.cwd() if it's in the vault - path.join(process.cwd(), '.obsidian', 'plugins', 'typst-pdf-export'), + path.join(process.cwd(), '.obsidian', 'plugins', pluginDirName), // Strategy 2: Assuming we're running from vault root - path.join('.obsidian', 'plugins', 'typst-pdf-export'), - // Strategy 3: Direct path if running in development - '/Users/alex/Obsidian/Dev/.obsidian/plugins/typst-pdf-export' + path.join('.obsidian', 'plugins', pluginDirName), + // Strategy 3: From vault base path if plugin is available + ...(this.plugin ? [path.join((this.plugin.app.vault.adapter as any).basePath, this.plugin.manifest.dir!)] : []) ]; // Find the first directory that exists and has node_modules diff --git a/src/templates/TemplateManager.ts b/src/templates/TemplateManager.ts index 7c13827..ca4ffa0 100644 --- a/src/templates/TemplateManager.ts +++ b/src/templates/TemplateManager.ts @@ -16,7 +16,8 @@ export class TemplateManager { // Templates are stored in the plugin directory this.templatesPath = path.join( (this.plugin.app.vault.adapter as any).basePath, - '.obsidian/plugins/typst-pdf-export/templates' + this.plugin.manifest.dir!, + 'templates' ); } From 38fca744cd6bc8aff039001e6a53911ff2425cc7 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 5 Sep 2025 18:01:16 +0200 Subject: [PATCH 3/3] Improves plugin path resolution and versioning Fixes dynamic path detection for plugin resources Updates version to 1.0.1 across manifest files Adds version compatibility mapping Resolves issues with hardcoded directory paths Ensures more robust plugin directory detection and resource loading --- CHANGELOG.md | 8 ++++++++ manifest.json | 2 +- package.json | 2 +- versions.json | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ac98fe..9f8abcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to the Obsidian Typst PDF Export plugin will be documented i The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] + +### Fixed +- **Dynamic Path Resolution**: Fixed font caching, template loading, and temp directory paths to use dynamic plugin directory resolution instead of hardcoded "obsidian-typst-pdf-export" paths +- **Plugin Directory Detection**: Updated PdfToImageConverter to dynamically detect plugin directory name from manifest +- **Template Manager Paths**: Fixed template directory path resolution to work with renamed plugin folder +- **Documentation**: Updated README.md to reflect correct folder name "typst-pdf-export" in all installation instructions + ## [1.0.0] ### Added diff --git a/manifest.json b/manifest.json index 3dd7384..cdfcde0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "typst-pdf-export", "name": "Typst PDF Export", - "version": "1.0.0", + "version": "1.0.1", "minAppVersion": "1.9.12", "description": "Exports a note or collection of notes to a pretty Typst PDF.", "author": "Alexander Kucera", diff --git a/package.json b/package.json index bdf541f..9877660 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-typst-pdf-export", - "version": "1.0.0", + "version": "1.0.1", "description": "Exports a note or collection of notes to a pretty Typst PDF.", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index 0a874dd..f6716ca 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ { - "1.0.0": "1.9.12" + "1.0.0": "1.9.12", + "1.0.1": "1.9.12" }