@hesprs/sync-engine-sdk 3.1.1 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- import e from"./debug-wrapper.js";import t from"./plugin/test/test-kit.js";import n from"./plugin/src/utils/sha-256.js";import r from"./transform.js";export{e as debugWrapper,n as sha256,r as syncEngineTransform,t as testKit};
1
+ import e from"./debug-wrapper.js";import t from"./plugin/test/test-kit.js";import n from"./plugin/src/utils/sha-256.js";export{e as debugWrapper,n as sha256,t as testKit};
@@ -1,4 +1,4 @@
1
- import { $ as RootFs, G as Fs, P as TaskNames, ct as RecordStat, dt as StatsMap, et as WrappedFs, h as RequestParam, it as FolderStat, lt as RecordStatsMap, m as Request, nt as Binary, rt as FileStat, ut as Stat, v as Decider } from "./index-LOl_cerr.spec.js";
1
+ import { $ as RootFs, G as Fs, P as TaskNames, ct as RecordStatsMap, et as WrappedFs, ft as Binary, h as RequestParam, lt as Stat, m as Request, nt as FileStat, rt as FolderStat, st as RecordStat, ut as StatsMap, v as Decider } from "./index-g3mTMY1u.spec.js";
2
2
  //#region src/sdk/debug-wrapper.d.ts
3
3
  declare function debugWrapper(original: Fs, log: (content: string) => void): WrappedFs;
4
4
  //#endregion
@@ -80,18 +80,4 @@ declare const testKit: {
80
80
  //#region src/utils/sha-256.d.ts
81
81
  declare function sha256(input: string): Promise<string>;
82
82
  //#endregion
83
- //#region src/sdk/transform.d.ts
84
- type SyncEngineConfig = {
85
- deps?: {
86
- neverBundle?: true | string | RegExp | Array<string | RegExp> | ((id: string, parentId: string | undefined, isResolved: boolean) => boolean | null | undefined);
87
- };
88
- };
89
- declare function syncEngineTransform(): {
90
- name: string;
91
- renderChunk(code: string): {
92
- code: string;
93
- } | undefined;
94
- tsdownConfig(config: SyncEngineConfig): void;
95
- };
96
- //#endregion
97
- export { debugWrapper, sha256, syncEngineTransform, testKit };
83
+ export { debugWrapper, sha256, testKit };
@@ -1,7 +1,10 @@
1
1
  import { App, ListedFiles, RequestUrlParam, Stat } from "obsidian";
2
- //#region test/e2e-utils.d.ts
2
+ //#region ../shared/src/e2e-utils.spec.d.ts
3
3
  type General = any;
4
4
  //#endregion
5
+ //#region ../shared/src/binary.d.ts
6
+ type Binary = Uint8Array<ArrayBuffer>;
7
+ //#endregion
5
8
  //#region src/types.d.ts
6
9
  type MaybePromise<T> = Promise<T> | T;
7
10
  type TogglableValue<T = number> = {
@@ -38,7 +41,6 @@ type Progress<T = string> = {
38
41
  completed: number;
39
42
  current?: T;
40
43
  };
41
- type Binary = Uint8Array<ArrayBuffer>;
42
44
  //#endregion
43
45
  //#region src/fs/interface.d.ts
44
46
  /**
@@ -459,7 +461,7 @@ declare class Registrar {
459
461
  root: {
460
462
  conflictResolverRegistry: Map<string, ConflictResolverEntry>;
461
463
  createLocalFs: () => Fs;
462
- createRemoteFs: (remoteFs?: string) => RootFs;
464
+ createRemoteFs: (remoteFs?: string) => Fs;
463
465
  deciderRegistry: Map<string, DeciderEntry>;
464
466
  getCheckConnection: (remoteFs?: string) => () => MaybePromise<CheckConnectionResult>;
465
467
  getConflictResolver: () => ConflictResolver;
@@ -555,4 +557,4 @@ type VaultRequestResponseMap = {
555
557
  };
556
558
  type VaultRequest = <T extends VaultRequestParam>(params: T) => Promise<VaultRequestResponseMap[T['method']]>;
557
559
  //#endregion
558
- export { RootFs as $, AddRecord as A, StoreOperations as B, RemoveRemote as C, MoveLocal as D, MoveRemote as E, RecordStore as F, Fs as G, BatchOptimizer as H, Storage as I, MkdirAtom as J, InputAtom as K, DatabaseAsync as L, ConflictResolver as M, ConflictResolverPayload as N, Download as O, TaskNames as P, OutputAtom as Q, DatabaseSync as R, ResolveConflict as S, RemoveLocal as T, CustomAtom as U, StoreSync as V, DeleteAtom as W, OptimizerInput as X, MoveAtom as Y, OptimizerOutput as Z, CreateLocalDir as _, FsWrapperEntry as a, GlobMatchRule as at, TaskFactory as b, OptimizerEntry as c, RecordStat as ct, RemoteLister as d, StatsMap as dt, WrappedFs as et, RemoteListerEntry as f, TogglableValue as ft, RequestResponse as g, RequestParam as h, DeciderEntry as i, FolderStat as it, BaseTask as j, CreateRemoteDir as k, Registrar as l, RecordStatsMap as lt, Request as m, CheckConnectionResult as n, Binary as nt, Infras as o, MaybePromise as ot, RemoteRequestMiddlewareEntry as p, General as pt, ListReporter as q, ConflictResolverEntry as r, FileStat as rt, LocalRequestMiddlewareEntry as s, Progress as st, VaultRequest as t, WriteAtom as tt, RemoteFsEntry as u, Stat$1 as ut, Decider as v, RemoveRecord as w, Upload as x, DeciderInput as y, StoreAsync as z };
560
+ export { RootFs as $, AddRecord as A, StoreOperations as B, RemoveRemote as C, MoveLocal as D, MoveRemote as E, RecordStore as F, Fs as G, BatchOptimizer as H, Storage as I, MkdirAtom as J, InputAtom as K, DatabaseAsync as L, ConflictResolver as M, ConflictResolverPayload as N, Download as O, TaskNames as P, OutputAtom as Q, DatabaseSync as R, ResolveConflict as S, RemoveLocal as T, CustomAtom as U, StoreSync as V, DeleteAtom as W, OptimizerInput as X, MoveAtom as Y, OptimizerOutput as Z, CreateLocalDir as _, FsWrapperEntry as a, MaybePromise as at, TaskFactory as b, OptimizerEntry as c, RecordStatsMap as ct, RemoteLister as d, TogglableValue as dt, WrappedFs as et, RemoteListerEntry as f, Binary as ft, RequestResponse as g, RequestParam as h, DeciderEntry as i, GlobMatchRule as it, BaseTask as j, CreateRemoteDir as k, Registrar as l, Stat$1 as lt, Request as m, CheckConnectionResult as n, FileStat as nt, Infras as o, Progress as ot, RemoteRequestMiddlewareEntry as p, General as pt, ListReporter as q, ConflictResolverEntry as r, FolderStat as rt, LocalRequestMiddlewareEntry as s, RecordStat as st, VaultRequest as t, WriteAtom as tt, RemoteFsEntry as u, StatsMap as ut, Decider as v, RemoveRecord as w, Upload as x, DeciderInput as y, StoreAsync as z };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{pipe as e,readWithSize as t,writeWithValue as n}from"./plugin/src/utils/pipe.js";import r from"./plugin/src/components/MigrationModal.js";import i from"./prefix.js";import{s as a}from"./plugin/src/settings/utils.js";function o(e){let t=e;for(;`original`in t;)t=t.original;return t}export{o as digOriginal,e as pipe,i as prefixWrapper,t as readWithSize,a as s,r as setNeedMigration,n as writeWithValue};
1
+ import{chunkSize as e,concurrency as t,pipe as n,readWithSize as r,writeWithValue as i}from"./plugin/src/utils/pipe.js";import a from"./plugin/src/components/MigrationModal.js";import o from"./prefix.js";import{generateEditableList as s,reactivelyValidate as c,s as l}from"./plugin/src/settings/utils.js";function u(e){let t=e;for(;`original`in t;)t=t.original;return t}export{e as chunkSize,t as concurrency,u as digOriginal,s as generateEditableList,n as pipe,o as prefixWrapper,c as reactivelyValidate,r as readWithSize,l as s,a as setNeedMigration,i as writeWithValue};
@@ -1,5 +1,5 @@
1
- import { $ as RootFs, A as AddRecord, B as StoreOperations, C as RemoveRemote, D as MoveLocal, E as MoveRemote, F as RecordStore, G as Fs, H as BatchOptimizer, I as Storage, J as MkdirAtom, K as InputAtom, L as DatabaseAsync, M as ConflictResolver, N as ConflictResolverPayload, O as Download, P as TaskNames, Q as OutputAtom, R as DatabaseSync, S as ResolveConflict, T as RemoveLocal, U as CustomAtom, V as StoreSync, W as DeleteAtom, X as OptimizerInput, Y as MoveAtom, Z as OptimizerOutput, _ as CreateLocalDir, a as FsWrapperEntry, at as GlobMatchRule, b as TaskFactory, c as OptimizerEntry, ct as RecordStat, d as RemoteLister, dt as StatsMap, et as WrappedFs, f as RemoteListerEntry, ft as TogglableValue, g as RequestResponse, h as RequestParam, i as DeciderEntry, it as FolderStat, j as BaseTask, k as CreateRemoteDir, l as Registrar, lt as RecordStatsMap, m as Request, n as CheckConnectionResult, nt as Binary, o as Infras, ot as MaybePromise, p as RemoteRequestMiddlewareEntry, pt as General$1, q as ListReporter, r as ConflictResolverEntry, rt as FileStat, s as LocalRequestMiddlewareEntry, st as Progress, t as VaultRequest, tt as WriteAtom, u as RemoteFsEntry, ut as Stat, v as Decider, w as RemoveRecord, x as Upload, y as DeciderInput, z as StoreAsync } from "./index-LOl_cerr.spec.js";
2
- import { App, Command, EventRef, IconName, Modal, Plugin, Setting, SettingDefinition, SettingDefinitionGroup, SettingDefinitionItem, SettingDefinitionList, SettingDefinitionPage, ToggleComponent } from "obsidian";
1
+ import { $ as RootFs, A as AddRecord, B as StoreOperations, C as RemoveRemote, D as MoveLocal, E as MoveRemote, F as RecordStore, G as Fs, H as BatchOptimizer, I as Storage, J as MkdirAtom, K as InputAtom, L as DatabaseAsync, M as ConflictResolver, N as ConflictResolverPayload, O as Download, P as TaskNames, Q as OutputAtom, R as DatabaseSync, S as ResolveConflict, T as RemoveLocal, U as CustomAtom, V as StoreSync, W as DeleteAtom, X as OptimizerInput, Y as MoveAtom, Z as OptimizerOutput, _ as CreateLocalDir, a as FsWrapperEntry, at as MaybePromise, b as TaskFactory, c as OptimizerEntry, ct as RecordStatsMap, d as RemoteLister, dt as TogglableValue, et as WrappedFs, f as RemoteListerEntry, ft as Binary, g as RequestResponse, h as RequestParam, i as DeciderEntry, it as GlobMatchRule, j as BaseTask, k as CreateRemoteDir, l as Registrar, lt as Stat, m as Request, n as CheckConnectionResult, nt as FileStat, o as Infras, ot as Progress, p as RemoteRequestMiddlewareEntry, pt as General$1, q as ListReporter, r as ConflictResolverEntry, rt as FolderStat, s as LocalRequestMiddlewareEntry, st as RecordStat, t as VaultRequest, tt as WriteAtom, u as RemoteFsEntry, ut as StatsMap, v as Decider, w as RemoveRecord, x as Upload, y as DeciderInput, z as StoreAsync } from "./index-g3mTMY1u.spec.js";
2
+ import { App, Command, EventRef, ExtraButtonComponent, IconName, Modal, Plugin, Setting, SettingDefinition, SettingDefinitionGroup, SettingDefinitionItem, SettingDefinitionList, SettingDefinitionPage, TextComponent, ToggleComponent } from "obsidian";
3
3
  //#region ../../node_modules/.bun/synthkernel@.+synthkernel.tgz/node_modules/synthkernel/dist/context.d.ts
4
4
  //#region src/context.d.ts
5
5
  type General = any;
@@ -113,8 +113,6 @@ type FailedTaskInfo = TaskInfo & {
113
113
  };
114
114
  declare class Sync {
115
115
  private readonly ctx;
116
- dispatch: Dispatch<Events>;
117
- on: On<Events>;
118
116
  constructor(ctx: {
119
117
  dispatch: Dispatch<Events>;
120
118
  initializeSync: () => Infras;
@@ -151,16 +149,7 @@ declare class Sync {
151
149
  private readonly executeSync;
152
150
  private readonly convertDeleteToUpload;
153
151
  root: {
154
- executeSync: (trigger: string) => Promise<{
155
- result: 'cancelled';
156
- } | {
157
- result: 'completed';
158
- } | {
159
- result: 'failed';
160
- error: string;
161
- } | {
162
- result: 'noop';
163
- }>;
152
+ executeSync: (trigger: string) => Promise<SyncTerminateReason>;
164
153
  };
165
154
  }
166
155
  //#endregion
@@ -170,6 +159,7 @@ type AddRibbonIcon = (icon: IconName, title: string, callback: (evt: MouseEvent)
170
159
  declare class Observability {
171
160
  private readonly ctx;
172
161
  private lastSyncTime;
162
+ private lastFailure?;
173
163
  private readonly sinceLastSyncText;
174
164
  private readonly syncStage;
175
165
  private readonly walkProgress;
@@ -237,6 +227,7 @@ type ModuleMeta = {
237
227
  main: string;
238
228
  icon?: string;
239
229
  minPluginVersion?: string;
230
+ readme?: string;
240
231
  integrity: string;
241
232
  };
242
233
  type AugmentedModuleMeta = ModuleMeta & {
@@ -282,6 +273,7 @@ declare class Extensibility {
282
273
  private readonly loadAllModules;
283
274
  private readonly loadModule;
284
275
  private readonly unloadModule;
276
+ private readonly installModule;
285
277
  private readonly downloadModule;
286
278
  private readonly deleteModule;
287
279
  private readonly fetchSources;
@@ -299,6 +291,7 @@ declare class Extensibility {
299
291
  downloadModule: (meta: AugmentedModuleMeta, waitIdle?: boolean) => Promise<void>;
300
292
  enableModule: (id: string) => Promise<void>;
301
293
  fetchSources: (manual?: boolean) => Promise<AugmentedModuleMeta[]>;
294
+ installModule: (meta: AugmentedModuleMeta, module: string) => Promise<void>;
302
295
  loadAllModules: () => Promise<void>;
303
296
  loadModule: (meta: AugmentedModuleMeta, start?: boolean, module?: string) => Promise<void>;
304
297
  loadedModules: Map<string, ModuleCtor>;
@@ -309,27 +302,6 @@ declare class Extensibility {
309
302
  };
310
303
  }
311
304
  //#endregion
312
- //#region src/components/ModuleEditorModal.d.ts
313
- type ModuleEditorTranslations = {
314
- editModuleInformation: string;
315
- enable: string;
316
- name: string;
317
- namePlaceholder: string;
318
- description: string;
319
- descriptionPlaceholder: string;
320
- icon: string;
321
- iconDescription: Fragment;
322
- iconPlaceholder: string;
323
- updateSource: string;
324
- updateSourceDescription: string;
325
- updateSourcePlaceholder: string;
326
- invalidValue: string;
327
- integrityVerification: string;
328
- integrityVerificationDescription: Fragment;
329
- save: string;
330
- cancel: string;
331
- };
332
- //#endregion
333
305
  //#region src/components/UnknownModuleModal.d.ts
334
306
  type FileInfo = {
335
307
  path: string;
@@ -403,6 +375,14 @@ declare class Setting$1 {
403
375
  }
404
376
  //#endregion
405
377
  //#region src/settings/utils.d.ts
378
+ type EphemeralEditableItem<T> = {
379
+ valid: boolean;
380
+ new: boolean;
381
+ value: T;
382
+ };
383
+ type EphemeralEditableListSchema = {
384
+ ephemeralEditableLists: Array<EphemeralEditableItem<General$1>>;
385
+ };
406
386
  type AugmentedSettingDefinitionItem<K extends string = string> = SettingDefinitionGroup<K> | SettingDefinitionList<K> | (SettingDefinitionPage<K> & {
407
387
  labels?: Array<LabelDefinition>;
408
388
  }) | (SettingDefinition<K> & {
@@ -415,6 +395,28 @@ type LabelDefinition = {
415
395
  textColor?: string;
416
396
  };
417
397
  declare function s(parent: (self: SettingTree) => AugmentedSettingDefinitionItem, children?: CallableOrObjectTree): CallableOrObjectTree;
398
+ declare function reactivelyValidate<T>({ text, parse, onSave, format, immediate }: {
399
+ text: TextComponent;
400
+ parse: (value: string) => T | undefined;
401
+ format?: (value: T) => string;
402
+ onSave: (value: T) => void;
403
+ immediate?: boolean;
404
+ }): void;
405
+ declare function generateEditableList<T>({ memoryDB, items, identifier, saveSettings, rerenderSettingTab, defaultValue, render, translations: { add, empty, heading }, extraButtons }: {
406
+ memoryDB: DatabaseSync<EphemeralEditableListSchema>;
407
+ items: Array<T>;
408
+ identifier: string;
409
+ saveSettings: () => Promise<void>;
410
+ rerenderSettingTab: () => void;
411
+ defaultValue: T;
412
+ render: (setting: Setting, item: EphemeralEditableItem<T>, save: () => void) => void | (() => void);
413
+ translations: {
414
+ add: string;
415
+ empty: string;
416
+ heading?: string;
417
+ };
418
+ extraButtons?: Array<(button: ExtraButtonComponent, list: Array<EphemeralEditableItem<T>>, save: () => void) => void>;
419
+ }): SettingDefinitionList;
418
420
  //#endregion
419
421
  //#region src/settings/controls.d.ts
420
422
  type ControlsSettingTranslations = {
@@ -568,6 +570,8 @@ type MiscellaneousSettingTranslations = {
568
570
  headerKeyPlaceholder: string;
569
571
  headerValuePlaceholder: string;
570
572
  addSecretHeader: string;
573
+ avoidAutoSyncWhenOffline: string;
574
+ avoidAutoSyncWhenOfflineDescription: string;
571
575
  };
572
576
  //#endregion
573
577
  //#region src/components/module-management/index.d.ts
@@ -586,13 +590,42 @@ type ModuleManagementTranslations = {
586
590
  editModuleInformation: string;
587
591
  official: string;
588
592
  someModulesHidden: string;
593
+ openReadme: string;
594
+ };
595
+ //#endregion
596
+ //#region src/components/ModuleEditorModal.d.ts
597
+ type ModuleEditorTranslations = {
598
+ editModuleInformation: string;
599
+ enable: string;
600
+ enableDescription: string;
601
+ name: string;
602
+ namePlaceholder: string;
603
+ nameDescription: string;
604
+ description: string;
605
+ descriptionDescription: string;
606
+ descriptionPlaceholder: string;
607
+ icon: string;
608
+ iconDescription: Fragment;
609
+ iconPlaceholder: string;
610
+ update: string;
611
+ updateDescription: string;
612
+ updatePlaceholder: string;
613
+ integrityVerification: string;
614
+ integrityVerificationDescription: Fragment;
615
+ save: string;
616
+ cancel: string;
617
+ readmePage: string;
618
+ readmePageDescription: string;
619
+ readmePagePlaceholder: string;
589
620
  };
590
621
  //#endregion
591
622
  //#region src/settings/module-management.d.ts
592
- type ModulesTranslations = ModuleManagementTranslations & {
623
+ type ModulesTranslations = ModuleEditorTranslations & ModuleManagementTranslations & {
593
624
  searchModules: string;
594
625
  moduleManagement: string;
595
626
  showInstalledOnly: string;
627
+ installModuleFromFile: string;
628
+ moduleExtensionWarning: Fragment;
596
629
  };
597
630
  //#endregion
598
631
  //#region src/modules/Bootstrap.d.ts
@@ -628,7 +661,7 @@ declare class Bootstrap {
628
661
  keepRemote: string;
629
662
  renameAndKeepBoth: string;
630
663
  skip: string;
631
- } & ControlsSettingTranslations & DevelopmentSettingTranslations & FeaturesSettingTranslations & FilterSettingTranslations & HeadSettingTranslations & MiscellaneousSettingTranslations & UnknownModuleTranslations & ModuleEditorTranslations & FileTreeTranslations & ModulesTranslations;
664
+ } & ControlsSettingTranslations & DevelopmentSettingTranslations & FeaturesSettingTranslations & FilterSettingTranslations & HeadSettingTranslations & MiscellaneousSettingTranslations & UnknownModuleTranslations & FileTreeTranslations & ModulesTranslations;
632
665
  readonly settings: {
633
666
  maxMemoryConsumption: TogglableValue;
634
667
  maxRequestConcurrency: TogglableValue;
@@ -738,6 +771,7 @@ declare class Scheduler {
738
771
  registerEvent: (ref: EventRef) => void;
739
772
  app: App;
740
773
  isIdle: Ref<boolean>;
774
+ dispatch: Dispatch<Events>;
741
775
  });
742
776
  settings: {
743
777
  startupSync: TogglableValue;
@@ -745,6 +779,7 @@ declare class Scheduler {
745
779
  realtimeSync: TogglableValue;
746
780
  exclusionRules: Array<GlobMatchRule>;
747
781
  inclusionRules: Array<GlobMatchRule>;
782
+ avoidAutoSyncWhenOffline: boolean;
748
783
  };
749
784
  private readonly requestSync;
750
785
  start: () => void;
@@ -781,6 +816,7 @@ type Translations = MergeSingleKey<InternalModules, 'i18n'>;
781
816
  declare function prefixWrapper(original: Fs, prefix: string): WrappedFs;
782
817
  //#endregion
783
818
  //#region src/utils/pipe.d.ts
819
+ declare const chunkSize: number, concurrency: number;
784
820
  declare function pipe({ from, to, stat, key }: {
785
821
  from: Fs;
786
822
  to: Fs;
@@ -794,4 +830,4 @@ declare function writeWithValue(fs: Fs, key: string, value: Binary | ReadableStr
794
830
  declare function digOriginal(wrapped: Fs): RootFs;
795
831
  type SelectFromContext<O extends object> = Context extends O ? O : never;
796
832
  //#endregion
797
- export { type AddRecord, type AugmentedModuleMeta, type BaseTask, type BatchOptimizer, type Binary, type CallableOrObjectTree, type CheckConnectionResult, type ConflictResolver, type ConflictResolverEntry, type ConflictResolverPayload, type Context, type CreateLocalDir, type CreateRemoteDir, type CustomAtom, type DatabaseAsync, type DatabaseSync, type Decider, type DeciderEntry, type DeciderInput, type DeleteAtom, type Dispatch, type Download, type Events, type ExistingMemoryDB, type FileStat, type FolderStat, type Fragment, type Fs, type FsWrapperEntry, type InputAtom, type LabelDefinition, type ListReporter, type LocalRequestMiddlewareEntry, type MaybePromise, type MkdirAtom, type ModuleMeta, type MoveAtom, type MoveLocal, type MoveRemote, type ObsidianLanguageCode, type On, type OptimizerEntry, type OptimizerInput, type OptimizerOutput, type OutputAtom, type Progress, type RecordStat, type RecordStatsMap, type RecordStore, type RemoteFsEntry, type RemoteLister, type RemoteListerEntry, type RemoteRequestMiddlewareEntry, type RemoveLocal, type RemoveRecord, type RemoveRemote, type Request, type RequestParam, type RequestResponse, type ResolveConflict, type RootFs, SelectFromContext, type SettingEntry, type Settings, type Stat, type StatsMap, type StoreAsync, type StoreOperations, type StoreSync, type SyncTerminateReason, type TaskFactory, type TaskNames, type Translate, type TranslationResource, type Translations, type Upload, type VaultRequest, type WrappedFs, type WriteAtom, digOriginal, pipe, prefixWrapper, readWithSize, s, setNeedMigration, writeWithValue };
833
+ export { type AddRecord, type AugmentedModuleMeta, type BaseTask, type BatchOptimizer, type Binary, type CallableOrObjectTree, type CheckConnectionResult, type ConflictResolver, type ConflictResolverEntry, type ConflictResolverPayload, type Context, type CreateLocalDir, type CreateRemoteDir, type CustomAtom, type DatabaseAsync, type DatabaseSync, type Decider, type DeciderEntry, type DeciderInput, type DeleteAtom, type Dispatch, type Download, type Events, type ExistingMemoryDB, type FileStat, type FolderStat, type Fragment, type Fs, type FsWrapperEntry, type InputAtom, type LabelDefinition, type ListReporter, type LocalRequestMiddlewareEntry, type MaybePromise, type MkdirAtom, type ModuleMeta, type MoveAtom, type MoveLocal, type MoveRemote, type ObsidianLanguageCode, type On, type OptimizerEntry, type OptimizerInput, type OptimizerOutput, type OutputAtom, type Progress, type RecordStat, type RecordStatsMap, type RecordStore, type RemoteFsEntry, type RemoteLister, type RemoteListerEntry, type RemoteRequestMiddlewareEntry, type RemoveLocal, type RemoveRecord, type RemoveRemote, type Request, type RequestParam, type RequestResponse, type ResolveConflict, type RootFs, SelectFromContext, type SettingEntry, type Settings, type Stat, type StatsMap, type StoreAsync, type StoreOperations, type StoreSync, type SyncTerminateReason, type TaskFactory, type TaskNames, type Translate, type TranslationResource, type Translations, type Upload, type VaultRequest, type WrappedFs, type WriteAtom, chunkSize, concurrency, digOriginal, generateEditableList, pipe, prefixWrapper, reactivelyValidate, readWithSize, s, setNeedMigration, writeWithValue };
@@ -0,0 +1 @@
1
+ import{Platform as e}from"obsidian";function t(e){let t=e,n=[t.status,t.res?.status,t.response?.status];for(let e of n)if(typeof e==`number`)return e}function n(){let t=5*1024**2;`deviceMemory`in navigator&&typeof navigator.deviceMemory==`number`?navigator.deviceMemory<=4&&(t/=2):navigator.hardwareConcurrency<=4&&(t/=2),e.isAndroidApp&&(t/=2);let n=t*.8;return{chunkSize:n,concurrency:Math.floor(16777216/n),streamThreshold:t}}const{chunkSize:r,concurrency:i,streamThreshold:a}=n();async function o({from:e,to:t,stat:n,key:r}){let i=await s(e,r,n);if(i)return c(t,r,i,n)}async function s(e,t,n){try{return n.size>a?await e.readStream(t,n):await e.read(t,n)}catch(e){if(l(e))return;throw e}}function c(e,t,n,r){return n instanceof ReadableStream?e.writeStream(t,n,r):e.write(t,n,r)}function l(e){return t(e)===404||(e.message??String(e)).toLocaleUpperCase().includes(`ENOENT`)}export{c as a,s as i,i as n,o as r,r as t};
@@ -0,0 +1 @@
1
+ const e=16777216;export{e as STREAM_RESERVATION_SIZE};
@@ -1 +1 @@
1
- import"obsidian";function e(e,t){return t?Object.assign(e,t):e}export{e as s};
1
+ import{encodeURIComponent3986 as e}from"../../../shared/src/path.js";import{setIcon as t}from"obsidian";function n(e,t){return t?Object.assign(e,t):e}function r(){let n=`--sync-engine-warning`;if(activeDocument.body.style.getPropertyValue(n))return;let r=createDiv();t(r,`triangle-alert`),r.firstElementChild.setAttr(`stroke`,getComputedStyle(activeDocument.body).getPropertyValue(`--text-warning`)),activeDocument.body.style.setProperty(n,`url("data:image/svg+xml,${e(r.innerHTML)}")`)}function i({text:e,parse:t,onSave:n,format:i=String,immediate:a=!1}){r();let o,s=`sync-engine-invalid-input`,c=n=>{o=t(n),o===void 0?e.inputEl.addClass(s):e.inputEl.removeClass(s)};e.onChange(c).inputEl.addEventListener(`blur`,()=>{o!==void 0&&(n(o),e.setValue(i(o)))}),a&&c(e.getValue())}function a({memoryDB:e,items:t,identifier:n,saveSettings:r,rerenderSettingTab:i,defaultValue:a,render:o,translations:{add:s,empty:c,heading:l},extraButtons:u}){let d=e.getStore(`ephemeralEditableLists`),f=d.get(n),p;f?p=f:(p=t.map(e=>({new:!1,valid:!0,value:e})),d.set(n,p));let m=()=>{let e=p.filter(({valid:e})=>e).map(({value:e})=>e);JSON.stringify(e)!==JSON.stringify(t)&&(t.length=0,t.push(...e),r())};return{addItem:{action:()=>{p.push({new:!0,valid:!1,value:structuredClone(a)}),i()},name:s},emptyState:c,extraButtons:u?u.map(e=>t=>e(t,p,m)):void 0,heading:l,items:p.map(e=>({name:``,render:t=>(t.settingEl.addClass(`sync-engine-editable-list`),t.settingEl.querySelector(`.setting-item-control`)?.addClass(`w-100%!`),o(t,e,m)),searchable:!1})),onDelete:e=>{p.splice(e,1),m(),i()},type:`list`}}export{a as generateEditableList,i as reactivelyValidate,n as s};
@@ -1 +1 @@
1
- import{getStatus as e}from"../../../shared/src/get-status.js";const t=2.5*1024**2;async function n({from:e,to:t,stat:n,key:a}){let o=await r(e,a,n);if(o)return i(t,a,o,n)}async function r(e,n,r){try{return r.size>t?await e.readStream(n,r):await e.read(n,r)}catch(e){if(a(e))return;throw e}}function i(e,t,n,r){return n instanceof ReadableStream?e.writeStream(t,n,r):e.write(t,n,r)}function a(t){return e(t)===404||(t.message??String(t)).toLocaleUpperCase().includes(`ENOENT`)}export{n as pipe,r as readWithSize,i as writeWithValue};
1
+ import{getStatus as e}from"../../../shared/src/get-status.js";import{STREAM_RESERVATION_SIZE as t}from"../fs/wrappers/memory-control.js";import{Platform as n}from"obsidian";function r(){let e=5*1024**2;`deviceMemory`in navigator&&typeof navigator.deviceMemory==`number`?navigator.deviceMemory<=4&&(e/=2):navigator.hardwareConcurrency<=4&&(e/=2),n.isAndroidApp&&(e/=2);let r=e*.8;return{chunkSize:r,concurrency:Math.floor(t/r),streamThreshold:e}}const{chunkSize:i,concurrency:a,streamThreshold:o}=r();async function s({from:e,to:t,stat:n,key:r}){let i=await c(e,r,n);if(i)return l(t,r,i,n)}async function c(e,t,n){try{return n.size>o?await e.readStream(t,n):await e.read(t,n)}catch(e){if(u(e))return;throw e}}function l(e,t,n,r){return n instanceof ReadableStream?e.writeStream(t,n,r):e.write(t,n,r)}function u(t){return e(t)===404||(t.message??String(t)).toLocaleUpperCase().includes(`ENOENT`)}export{i as chunkSize,a as concurrency,s as pipe,c as readWithSize,l as writeWithValue};
@@ -1 +1 @@
1
- function e(e){return e.split(`/`).map(e=>decodeURIComponent(e.normalize(`NFC`))).join(`/`)}function t(e,t){let n=e.split(`/`).filter(e=>e!==``).join(`/`);return t?`${n}/`:n}function n(n){return t(e(n),!0)}export{n as normalizeBaseDir,e as normalizeChar,t as normalizeKey};
1
+ function e(e){return e.split(`/`).map(e=>decodeURIComponent(e.normalize(`NFC`))).join(`/`)}function t(e,t){let n=e.split(`/`).filter(e=>e!==``).join(`/`);return t?`${n}/`:n}function n(n){return t(e(n),!0)}function r(e){return encodeURIComponent(e).replaceAll(`!`,`%21`).replaceAll(`'`,`%27`).replaceAll(`(`,`%28`).replaceAll(`)`,`%29`).replaceAll(`*`,`%2A`)}export{r as encodeURIComponent3986,n as normalizeBaseDir,e as normalizeChar,t as normalizeKey};
@@ -0,0 +1,2 @@
1
+ const e=[`name`,`icon`,`description`,`source`,`version`,`readme`];function t(t){return`/*!\n${e.filter(e=>t[e]).map(e=>`${e}: ${t[e]}`).join(`
2
+ `)}\n*/\n`}function n(e,t){return Array.isArray(e)?e.find(({id:e})=>e===t):typeof Object.values(e)[0]==`object`?e[t]:e}function r(e){return{name:`sync-engine-module`,renderChunk(r,i){let a=r.replaceAll(/^[ \t]*import\s+['"]obsidian['"]\s*;?[ \t]*$/gmu,``).replaceAll(/^\s*import\s+(?<name>[A-Za-z_$][\w$]*)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`).replaceAll(/^\s*import\s+\*\s+as\s+(?<name>[A-Za-z_$][\w$]*)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`).replaceAll(/^\s*import\s+(?!(?:type\b|\*\s+as\s+))(?<name>.+?)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`),o=i.isEntry&&e?n(e,i.name):void 0,s=o&&Object.keys(o).length>0?t(o)+a:a;return s===r?void 0:{code:s}},tsdownConfig(e){e.deps??={};let{neverBundle:t}=e.deps;t!==!0&&(typeof t==`function`?e.deps.neverBundle=(e,n,r)=>e===`obsidian`||t(e,n,r):Array.isArray(t)?t.push(`obsidian`):t?e.deps.neverBundle=[t,`obsidian`]:e.deps.neverBundle=[`obsidian`])}}}export{r as default};
@@ -0,0 +1,22 @@
1
+ //#region src/sdk/tsdown-plugin.d.ts
2
+ type SyncEngineConfig = {
3
+ deps?: {
4
+ neverBundle?: true | string | RegExp | Array<string | RegExp> | ((id: string, parentId: string | undefined, isResolved: boolean) => boolean | null | undefined);
5
+ };
6
+ };
7
+ type ModuleMeta = Partial<Record<'name' | 'icon' | 'description' | 'source' | 'version' | 'readme', string>>;
8
+ type ModuleMetaWithId = ModuleMeta & {
9
+ id: string;
10
+ };
11
+ declare function syncEngineModule(meta?: ModuleMeta | Array<ModuleMetaWithId> | Record<string, ModuleMeta>): {
12
+ name: string;
13
+ renderChunk(code: string, chunk: {
14
+ name: string;
15
+ isEntry: boolean;
16
+ }): {
17
+ code: string;
18
+ } | undefined;
19
+ tsdownConfig(config: SyncEngineConfig): void;
20
+ };
21
+ //#endregion
22
+ export { syncEngineModule as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hesprs/sync-engine-sdk",
3
- "version": "3.1.1",
3
+ "version": "3.1.4",
4
4
  "description": "Official SDK for developing modules targeting Sync Engine, the extensible Obsidian syncing plugin.",
5
5
  "keywords": [
6
6
  "obsidian-plugin",
@@ -35,6 +35,10 @@
35
35
  "./dev": {
36
36
  "types": "./dist/dev.spec.d.ts",
37
37
  "default": "./dist/dev.js"
38
+ },
39
+ "./tsdown-plugin": {
40
+ "types": "./dist/tsdown-plugin.spec.d.ts",
41
+ "default": "./dist/tsdown-plugin.js"
38
42
  }
39
43
  },
40
44
  "publishConfig": {
@@ -1 +0,0 @@
1
- function e(e){let t=e,n=[t.status,t.res?.status,t.response?.status];for(let e of n)if(typeof e==`number`)return e}const t=2.5*1024**2;async function n({from:e,to:t,stat:n,key:a}){let o=await r(e,a,n);if(o)return i(t,a,o,n)}async function r(e,n,r){try{return r.size>t?await e.readStream(n,r):await e.read(n,r)}catch(e){if(a(e))return;throw e}}function i(e,t,n,r){return n instanceof ReadableStream?e.writeStream(t,n,r):e.write(t,n,r)}function a(t){return e(t)===404||(t.message??String(t)).toLocaleUpperCase().includes(`ENOENT`)}export{r as n,i as r,n as t};
package/dist/transform.js DELETED
@@ -1 +0,0 @@
1
- function e(){return{name:`sync-engine-transform`,renderChunk(e){let t=e.replaceAll(/^[ \t]*import\s+['"]obsidian['"]\s*;?[ \t]*$/gmu,``).replaceAll(/^\s*import\s+(?<name>[A-Za-z_$][\w$]*)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`).replaceAll(/^\s*import\s+\*\s+as\s+(?<name>[A-Za-z_$][\w$]*)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`).replaceAll(/^\s*import\s+(?!(?:type\b|\*\s+as\s+))(?<name>.+?)\s+from\s+(?<quote>['"])obsidian\k<quote>\s*;?\s*$/gmu,(e,t)=>`const ${t} = window.syncEngineApiBridge;`);return t===e?void 0:{code:t}},tsdownConfig(e){e.deps??={};let{neverBundle:t}=e.deps;t!==!0&&(typeof t==`function`?e.deps.neverBundle=(e,n,r)=>e===`obsidian`||t(e,n,r):Array.isArray(t)?t.push(`obsidian`):t?e.deps.neverBundle=[t,`obsidian`]:e.deps.neverBundle=[`obsidian`])}}}export{e as default};