@hesprs/sync-engine-sdk 3.1.3 → 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 syncEngineModule,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};
@@ -80,25 +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
- type ModuleMeta = Partial<Record<'name' | 'icon' | 'description' | 'source' | 'version' | 'readme', string>>;
90
- type ModuleMetaWithId = ModuleMeta & {
91
- id: string;
92
- };
93
- declare function syncEngineModule(meta?: ModuleMeta | Array<ModuleMetaWithId> | Record<string, ModuleMeta>): {
94
- name: string;
95
- renderChunk(code: string, chunk: {
96
- name: string;
97
- isEntry: boolean;
98
- }): {
99
- code: string;
100
- } | undefined;
101
- tsdownConfig(config: SyncEngineConfig): void;
102
- };
103
- //#endregion
104
- export { debugWrapper, sha256, syncEngineModule, testKit };
83
+ export { debugWrapper, sha256, testKit };
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{generateEditableList as a,reactivelyValidate as o,s}from"./plugin/src/settings/utils.js";function c(e){let t=e;for(;`original`in t;)t=t.original;return t}export{c as digOriginal,a as generateEditableList,e as pipe,i as prefixWrapper,o as reactivelyValidate,t as readWithSize,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};
@@ -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;
@@ -580,6 +570,8 @@ type MiscellaneousSettingTranslations = {
580
570
  headerKeyPlaceholder: string;
581
571
  headerValuePlaceholder: string;
582
572
  addSecretHeader: string;
573
+ avoidAutoSyncWhenOffline: string;
574
+ avoidAutoSyncWhenOfflineDescription: string;
583
575
  };
584
576
  //#endregion
585
577
  //#region src/components/module-management/index.d.ts
@@ -779,6 +771,7 @@ declare class Scheduler {
779
771
  registerEvent: (ref: EventRef) => void;
780
772
  app: App;
781
773
  isIdle: Ref<boolean>;
774
+ dispatch: Dispatch<Events>;
782
775
  });
783
776
  settings: {
784
777
  startupSync: TogglableValue;
@@ -786,6 +779,7 @@ declare class Scheduler {
786
779
  realtimeSync: TogglableValue;
787
780
  exclusionRules: Array<GlobMatchRule>;
788
781
  inclusionRules: Array<GlobMatchRule>;
782
+ avoidAutoSyncWhenOffline: boolean;
789
783
  };
790
784
  private readonly requestSync;
791
785
  start: () => void;
@@ -822,6 +816,7 @@ type Translations = MergeSingleKey<InternalModules, 'i18n'>;
822
816
  declare function prefixWrapper(original: Fs, prefix: string): WrappedFs;
823
817
  //#endregion
824
818
  //#region src/utils/pipe.d.ts
819
+ declare const chunkSize: number, concurrency: number;
825
820
  declare function pipe({ from, to, stat, key }: {
826
821
  from: Fs;
827
822
  to: Fs;
@@ -835,4 +830,4 @@ declare function writeWithValue(fs: Fs, key: string, value: Binary | ReadableStr
835
830
  declare function digOriginal(wrapped: Fs): RootFs;
836
831
  type SelectFromContext<O extends object> = Context extends O ? O : never;
837
832
  //#endregion
838
- 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, generateEditableList, pipe, prefixWrapper, reactivelyValidate, 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{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};
@@ -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.3",
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};
File without changes