Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222// src/plugin/__tests__/exports.test.tsimport { describe, it, expect } from 'vitest'import { Events, Component, Plugin, App, Vault, Workspace, WorkspaceLeaf, Editor, EditorSuggest, PopoverSuggest, View, ItemView, TextFileView, MarkdownView, TAbstractFile, TFile, TFolder, PluginSettingTab, SettingTab, // Loader exports PluginLoader, PluginRegistry, PluginSettingsStore, EnabledStateStore, validateManifest, parseManifestJson, ManifestValidationError, REAMS_VERSION, compareSemver, isVersionCompatible, // FileManager FileManager, // Event bus exports Debouncer, DebouncedEventRef,} from '../index'import type { PluginManifest, Command, EventRef, EditorPosition, EditorRange, EditorSelection, EditorTransaction, Hotkey, Modifier, MarkdownPostProcessor, ViewCreator, FileStats, MarkdownViewModeType, // New loader types PluginState, PluginSource,} from '../index'
// Type assertions to ensure the types are exported correctly// These are compile-time type checks only, the values are not used at runtime// @ts-expect-error - This function is for type checking onlyfunction _typeChecks() { const pluginManifest: PluginManifest = { id: 'test', name: 'Test', author: 'Author', version: '1.0.0', minAppVersion: '1.0.0', description: 'Test', } const command: Command = { id: 'test', name: 'Test' } const eventRef: EventRef = { e: new Events(), n: 'test', fn: () => {} } const editorPos: EditorPosition = { line: 0, ch: 0 } const editorRange: EditorRange = { from: editorPos, to: editorPos } const editorSelection: EditorSelection = { anchor: editorPos, head: editorPos } const editorTx: EditorTransaction = {} const hotkey: Hotkey = { modifiers: [], key: 'a' } const modifier: Modifier = 'Mod' const postProcessor: MarkdownPostProcessor = () => {} // MarkdownPostProcessor is an interface with optional sortOrder property (Obsidian 0.10.12+) postProcessor.sortOrder = 10 // Just a type-surface check — actual ItemView construction requires a leaf // and superclass init. Cast through unknown to satisfy the signature. const viewCreator: ViewCreator = (() => null) as unknown as ViewCreator const fileStats: FileStats = { ctime: 0, mtime: 0, size: 0 } // MetadataCache is now exported from src/services/metadata, not plugin/index const viewMode: MarkdownViewModeType = 'source' // Loader types const pluginState: PluginState = 'active' const pluginSource: PluginSource = { manifest: pluginManifest, entryUrl: '/test.js' } // Prevent unused variable warnings return { pluginManifest, command, eventRef, editorRange, editorSelection, editorTx, hotkey, modifier, postProcessor, viewCreator, fileStats, viewMode, pluginState, pluginSource }}
describe('public API exports', () => { it('exports Events', () => { expect(Events).toBeDefined() })
it('exports Component', () => { expect(Component).toBeDefined() })
it('exports Plugin', () => { expect(Plugin).toBeDefined() })
it('exports App', () => { expect(App).toBeDefined() })
it('exports Vault', () => { expect(Vault).toBeDefined() })
it('exports Workspace', () => { expect(Workspace).toBeDefined() })
it('exports WorkspaceLeaf', () => { expect(WorkspaceLeaf).toBeDefined() })
it('exports Editor', () => { expect(Editor).toBeDefined() })
it('exports EditorSuggest', () => { expect(EditorSuggest).toBeDefined() })
it('exports PopoverSuggest', () => { expect(PopoverSuggest).toBeDefined() })
it('exports ItemView', () => { expect(ItemView).toBeDefined() })
it('exports View', () => { expect(View).toBeDefined() })
it('exports TextFileView', () => { expect(TextFileView).toBeDefined() })
it('exports MarkdownView', () => { expect(MarkdownView).toBeDefined() })
it('exports TAbstractFile', () => { expect(TAbstractFile).toBeDefined() })
it('exports TFile', () => { expect(TFile).toBeDefined() })
it('exports TFolder', () => { expect(TFolder).toBeDefined() })
it('exports PluginSettingTab', () => { expect(PluginSettingTab).toBeDefined() })
it('exports SettingTab', () => { expect(SettingTab).toBeDefined() })
it('exports FileManager', () => { expect(FileManager).toBeDefined() })})
describe('loader exports', () => { it('exports PluginLoader', () => { expect(PluginLoader).toBeDefined() })
it('exports PluginRegistry', () => { expect(PluginRegistry).toBeDefined() })
it('exports PluginSettingsStore', () => { expect(PluginSettingsStore).toBeDefined() })
it('exports EnabledStateStore', () => { expect(EnabledStateStore).toBeDefined() })
it('exports REAMS_VERSION', () => { expect(REAMS_VERSION).toBeDefined() expect(typeof REAMS_VERSION).toBe('string') })
it('exports validation utilities', () => { expect(validateManifest).toBeDefined() expect(parseManifestJson).toBeDefined() expect(ManifestValidationError).toBeDefined() })
it('exports version utilities', () => { expect(compareSemver).toBeDefined() expect(isVersionCompatible).toBeDefined() })})
describe('event bus exports', () => { it('exports Debouncer', () => { expect(Debouncer).toBeDefined() })
it('exports DebouncedEventRef', () => { expect(DebouncedEventRef).toBeDefined() })})