Miscellaneous

Miscellaneous

Export Index

Root runtime exports

ExportDescription
digOriginalUnwraps nested wrappers to root filesystem. See file system.
prefixWrapperExposes a prefixed directory as an Fs root. See file system.
setNeedMigrationAdds migration confirmation behavior to a setting toggle.
pipeTransfer a file between two filesystems with auto-streaming. See file system.
readWithSizeRead a file with auto-streaming by size threshold. See file system.
writeWithValueWrite a value with auto-streaming by input type. See file system.

setNeedMigration

setNeedMigration adds migration confirmation behavior to an Obsidian ToggleComponent. It is useful for settings whose existing value changes the remote file layout or representation.

ts
import { setNeedMigration } from '@hesprs/sync-engine-sdk';

setNeedMigration(ctx, {
  toggle,
  needMigration: (value) => recordStoreExists(),
  content: (value) => (value ? 'Encryption will be enabled.' : 'Encryption will be disabled.'),
  apply: async (value) => {
    settings.enabled = value;
    await ctx.saveSettings();
  },
});

When needMigration returns false or is omitted, apply runs immediately. When it returns true, the toggle is reverted until the user either starts migration or chooses to toggle without migration. The helper is the public API; its internal migration modal is not exported.

/dev runtime exports

ExportDescription
debugWrapperFS wrapper that logs calls. See debug and testing.
testKitTest harness utilities. See debug and testing.
syncEngineTransformTsdown plugin rewriting obsidian imports. See writing a module.
sha256SHA-256 hash utility. See distribution.

Root type exports

GroupExports
ContextContext, Settings, Events, Translations, SelectFromContext
EventsDispatch, On
Core dataBinary, MaybePromise, Progress, FileStat, FolderStat, Stat, StatsMap, RecordStat, RecordStatsMap
FilesystemRootFs, WrappedFs, Fs, WriteAtom, DeleteAtom, MoveAtom, MkdirAtom, InputAtom, CustomAtom, OutputAtom, OptimizerInput, OptimizerOutput, BatchOptimizer
RegistrationFsWrapperEntry, RemoteFsEntry, RemoteRequestMiddlewareEntry, LocalRequestMiddlewareEntry, RemoteLister, RemoteListerEntry, DeciderEntry, OptimizerEntry, SettingEntry, ConflictResolverEntry, Request, CheckConnectionResult
SyncTaskNames, BaseTask, AddRecord, RemoveRecord, Download, Upload, CreateLocalDir, CreateRemoteDir, RemoveLocal, RemoveRemote, MoveLocal, MoveRemote, ResolveConflict, TaskFactory, DeciderInput, Decider, ConflictResolver, ConflictResolverPayload, SyncTerminateReason
StorageRecordStore, StoreAsync, StoreSync, DatabaseAsync, DatabaseSync
ModulesModuleMeta, AugmentedModuleMeta
RequestVaultRequest, RequestParam, RequestResponse (the response type returned by Request)
InternationalizationObsidianLanguageCode, Fragment, TranslationResource, Translate
OtherExistingMemoryDB

Internal supporting types can appear in exported signatures but are not standalone root exports. They include TogglableValue, GlobMatchRule, Infras, BaseTaskOptions, TaskOptions, TaskOptionsMap, TaskInfo, FailedTaskInfo, DeleteConfirmReturn, CustomHeaders, and InterpolationValues.

Settings

Settings is a merged object at ctx.settings. For descriptions of each setting, see usage: settings.

KeyType
moduleSourcesArray<string> of registry URLs
modulesRecord<string, object> of per-module settings
moduleAutoUpdateboolean
remoteFsstring selected backend ID
deciderstring selected decider ID
conflictResolverstring selected conflict-resolver ID
maxFileSizeTogglableValue max file size in bytes
confirmTasksInSyncboolean
confirmDeleteInAutoSyncboolean
noticeStatusOnMobileboolean
startupSyncTogglableValue delay in milliseconds
scheduledSyncTogglableValue interval in milliseconds
realtimeSyncTogglableValue debounce delay in milliseconds
inclusionRulesArray<GlobMatchRule>
exclusionRulesArray<GlobMatchRule>
maxMemoryConsumptionTogglableValue in bytes
maxRequestConcurrencyTogglableValue
minRequestIntervalTogglableValue in milliseconds
realtimeSyncFastModeboolean
asymmetricStorageboolean
customHeadersArray<{ type: 'plaintext' | 'secret'; value: string; key: string }>

TogglableValue has shape { enabled: boolean; value: number }.

Other Context Members

These Context members are not commonly used by modules. Explore source code to obtain usage patterns.

Module Management

MemberPurpose
discoveredModulesMap from discovered module ID to AugmentedModuleMeta.
loadedModulesMap from loaded module ID to module constructor.
fetchSources(manual?)Fetches module metadata from sources. manual: true forces refetch; false uses in-memory cache.
loadAllModules()Loads all enabled installed modules.
loadModule(meta, start?)Loads named module; optional second argument starts it.
unloadModule(id)Unloads named module.
updateModules()Finds and downloads available module updates.
downloadModule(meta)Downloads one module from URL.
deleteModule(id)Deletes named installed module.
enableModule(id)Enables and loads a module.
disableModule(id)Unloads and disables a module.
updateModuleMeta(meta)Updates stored module metadata.
addSettingTab(plugin)Adds Sync Engine setting tab to supplied Obsidian plugin.
openModuleManagement()Opens module-management UI.
closeModuleManagement()Closes module-management UI.

Filesystem and Sync

MemberPurpose
createLocalFs()Creates wrapped local filesystem.
createRemoteFs(id?)Creates selected wrapped remote filesystem.
getRequest()Gets composed remote request function.
getVaultRequest()Gets composed local vault request function.
getNamespace(local?, remote?)Creates storage namespace for optional local/remote FS pair.
initializeSync()Creates local FS, remote FS, and record store for sync.
getCheckConnection()Gets selected backend connection-check function.
getDecider()Gets selected Decider.
getConflictResolver()Gets selected ConflictResolver.
optimizeLocal(input)Applies selected local BatchOptimizer.
optimizeRemote(input)Applies selected remote BatchOptimizer.
listRemote(info)Lists remote entries for a sync trigger.
executeSync(tasks)Executes synchronization immediately.
requestSync(trigger)Queues sync; resolves with SyncTerminateReason.
remoteFsRegistryMap<string, RemoteFsEntry>.
deciderRegistryMap<string, DeciderEntry>.
conflictResolverRegistryMap<string, ConflictResolverEntry>.

UI and Observability

MemberPurpose
executionProgressReactive Progress for task execution.
walkProgressReactive Progress for remote traversal.
syncStageReactive current sync stage.
showProgress()Opens progress UI.
hideProgress()Hides progress UI.
getLogs()Returns formatted current logs.
exportLogs()Exports logs to vault file.
startScheduledSync()Starts interval sync.
stopScheduledSync()Stops interval sync.

Core and Host

MemberPurpose
settingsMerged Settings object.
eventsMerged Events map.
i18nMerged Translations resource map.
appObsidian App instance.
addCommand(cmd)Registers Obsidian command and returns it.
registerEvent(ref)Registers Obsidian EventRef for automatic cleanup.
addRibbonIcon(...)Adds ribbon icon and returns element.
addStatusBarItem()Adds and returns status-bar element.
saveSettings()Persists current settings.
on(key, cb)Subscribes to typed SDK event. See events.
dispatch(key, payload?)Dispatches typed SDK event. See events.
isIdleSynthKernel Ref<boolean> for sync-idle state.
translateTranslates a key from merged resources. See i18n.
rerenderSettingTab()Renders contributed settings again.

Framework Members

SynthKernel internal members. Module code normally should not call them.

MemberPurpose
__modules__Internal module-instance WeakMap.
__getModule__Gets internal module instance.
__addModule__Adds module constructor to context.
__assign__Extends context with merged values.

All content licensed under the CC BY 4.0 License.