zen-fs-config 0.5.39 → 0.5.40

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.
@@ -9,7 +9,7 @@ import {
9
9
  registerBackend,
10
10
  unregisterBackend,
11
11
  wrapZenFSFileSystem
12
- } from "./chunk-6OS2F54Z.mjs";
12
+ } from "./chunk-NSEXSKVW.mjs";
13
13
  export {
14
14
  createBackend,
15
15
  getAccountFields,
@@ -122,6 +122,9 @@ async function wrapZenFSFileSystem(config) {
122
122
  if (typeof isolatedFS.writeFileWithMtime === "function") {
123
123
  backend.writeFileWithMtime = (path, data, mtimeMs) => isolatedFS.writeFileWithMtime(path, data, mtimeMs);
124
124
  }
125
+ if (typeof isolatedFS.shouldSync === "function") {
126
+ backend.shouldSync = (...args) => isolatedFS.shouldSync(...args);
127
+ }
125
128
  return backend;
126
129
  }
127
130
  var inMemoryCounter = 0;
@@ -185,7 +188,8 @@ var OPTIONAL_BACKEND_GLOBALS = {
185
188
  // third-party Gitee widget) would shadow the real backend and break mounting
186
189
  // with "Invalid mount configuration".
187
190
  "zen-fs-gitee": ["ZenFSGitee"],
188
- "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"]
191
+ "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"],
192
+ "zen-fs-webdav": ["ZenFSWebDAV"]
189
193
  };
190
194
  async function importOptionalBackend(pkg) {
191
195
  const candidates = OPTIONAL_BACKEND_GLOBALS[pkg];
@@ -333,6 +337,53 @@ registerBackend("RemoteStorage", async (options) => {
333
337
  // connections to the same endpoint with different tuning are deduplicated.
334
338
  identityFields: ["href", "token", "basePath"]
335
339
  });
340
+ registerBackend("WebDAV", async (options) => {
341
+ const _dav = await importOptionalBackend("zen-fs-webdav");
342
+ const SyncableWebDAVFS = _dav?.SyncableWebDAVFS ?? _dav?.default?.SyncableWebDAVFS ?? globalThis.ZenFSWebDAV?.SyncableWebDAVFS;
343
+ if (typeof SyncableWebDAVFS !== "function") {
344
+ throw new Error(
345
+ `Backend package "zen-fs-webdav" loaded, but its SyncableWebDAVFS export is not a constructor (typeof=${typeof SyncableWebDAVFS}). Run: npm install zen-fs-webdav, or load its UMD bundle via <script src=".../zen-fs-webdav.global.js"> so it exposes the global "ZenFSWebDAV".`
346
+ );
347
+ }
348
+ const instance = new SyncableWebDAVFS({
349
+ baseUrl: options.baseUrl,
350
+ username: options.username,
351
+ password: options.password,
352
+ token: options.token,
353
+ headers: options.headers,
354
+ timeout: options.timeout,
355
+ preciseMtime: true
356
+ });
357
+ if (options.purgeLegacyMtime === true) {
358
+ try {
359
+ await instance.purgeLegacyMtimeSidecars({ root: options.basePath ?? "/" });
360
+ } catch {
361
+ }
362
+ }
363
+ return instance;
364
+ }, {
365
+ type: "WebDAV",
366
+ label: "WebDAV",
367
+ icon: "\u2601\uFE0F",
368
+ fields: [
369
+ { key: "baseUrl", label: "Base URL", type: "text", placeholder: "https://dav.example.com/remote.php/dav/files/user/", required: true },
370
+ { key: "username", label: "Username", type: "text", placeholder: "admin" },
371
+ { key: "password", label: "Password", type: "password" },
372
+ { key: "token", label: "Token", type: "password", placeholder: "Bearer token (optional)" },
373
+ { key: "basePath", label: "Base Path", type: "text", placeholder: "/zen-fs-config/" },
374
+ { key: "purgeLegacyMtime", label: "Purge legacy .mtime sidecars", type: "select", options: [
375
+ { value: "false", label: "no (default)" },
376
+ { value: "true", label: "yes (one-time migration)" }
377
+ ] }
378
+ ],
379
+ defaultOptions: { baseUrl: "", username: "", password: "", token: "", basePath: "/", purgeLegacyMtime: "false" },
380
+ // accountFields: credentials live on the endpoint, so a data-sync group can
381
+ // reuse them from an already-connected config-sync WebDAV backend.
382
+ accountFields: ["username", "password", "token"],
383
+ // identity = the WebDAV endpoint. Credentials are auth, not location, so two
384
+ // connections to the same URL are deduplicated as one replica.
385
+ identityFields: ["baseUrl"]
386
+ });
336
387
 
337
388
  export {
338
389
  registerBackend,
package/dist/index.js CHANGED
@@ -165,6 +165,9 @@ async function wrapZenFSFileSystem(config) {
165
165
  if (typeof isolatedFS.writeFileWithMtime === "function") {
166
166
  backend.writeFileWithMtime = (path, data, mtimeMs) => isolatedFS.writeFileWithMtime(path, data, mtimeMs);
167
167
  }
168
+ if (typeof isolatedFS.shouldSync === "function") {
169
+ backend.shouldSync = (...args) => isolatedFS.shouldSync(...args);
170
+ }
168
171
  return backend;
169
172
  }
170
173
  function _cacheGet(key) {
@@ -260,7 +263,8 @@ var init_backend_registry = __esm({
260
263
  // third-party Gitee widget) would shadow the real backend and break mounting
261
264
  // with "Invalid mount configuration".
262
265
  "zen-fs-gitee": ["ZenFSGitee"],
263
- "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"]
266
+ "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"],
267
+ "zen-fs-webdav": ["ZenFSWebDAV"]
264
268
  };
265
269
  registerBackend("GitHub", async (options) => {
266
270
  const _gh = await importOptionalBackend("zen-fs-github");
@@ -382,6 +386,53 @@ var init_backend_registry = __esm({
382
386
  // connections to the same endpoint with different tuning are deduplicated.
383
387
  identityFields: ["href", "token", "basePath"]
384
388
  });
389
+ registerBackend("WebDAV", async (options) => {
390
+ const _dav = await importOptionalBackend("zen-fs-webdav");
391
+ const SyncableWebDAVFS = _dav?.SyncableWebDAVFS ?? _dav?.default?.SyncableWebDAVFS ?? globalThis.ZenFSWebDAV?.SyncableWebDAVFS;
392
+ if (typeof SyncableWebDAVFS !== "function") {
393
+ throw new Error(
394
+ `Backend package "zen-fs-webdav" loaded, but its SyncableWebDAVFS export is not a constructor (typeof=${typeof SyncableWebDAVFS}). Run: npm install zen-fs-webdav, or load its UMD bundle via <script src=".../zen-fs-webdav.global.js"> so it exposes the global "ZenFSWebDAV".`
395
+ );
396
+ }
397
+ const instance = new SyncableWebDAVFS({
398
+ baseUrl: options.baseUrl,
399
+ username: options.username,
400
+ password: options.password,
401
+ token: options.token,
402
+ headers: options.headers,
403
+ timeout: options.timeout,
404
+ preciseMtime: true
405
+ });
406
+ if (options.purgeLegacyMtime === true) {
407
+ try {
408
+ await instance.purgeLegacyMtimeSidecars({ root: options.basePath ?? "/" });
409
+ } catch {
410
+ }
411
+ }
412
+ return instance;
413
+ }, {
414
+ type: "WebDAV",
415
+ label: "WebDAV",
416
+ icon: "\u2601\uFE0F",
417
+ fields: [
418
+ { key: "baseUrl", label: "Base URL", type: "text", placeholder: "https://dav.example.com/remote.php/dav/files/user/", required: true },
419
+ { key: "username", label: "Username", type: "text", placeholder: "admin" },
420
+ { key: "password", label: "Password", type: "password" },
421
+ { key: "token", label: "Token", type: "password", placeholder: "Bearer token (optional)" },
422
+ { key: "basePath", label: "Base Path", type: "text", placeholder: "/zen-fs-config/" },
423
+ { key: "purgeLegacyMtime", label: "Purge legacy .mtime sidecars", type: "select", options: [
424
+ { value: "false", label: "no (default)" },
425
+ { value: "true", label: "yes (one-time migration)" }
426
+ ] }
427
+ ],
428
+ defaultOptions: { baseUrl: "", username: "", password: "", token: "", basePath: "/", purgeLegacyMtime: "false" },
429
+ // accountFields: credentials live on the endpoint, so a data-sync group can
430
+ // reuse them from an already-connected config-sync WebDAV backend.
431
+ accountFields: ["username", "password", "token"],
432
+ // identity = the WebDAV endpoint. Credentials are auth, not location, so two
433
+ // connections to the same URL are deduplicated as one replica.
434
+ identityFields: ["baseUrl"]
435
+ });
385
436
  }
386
437
  });
387
438
 
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  registerBackend,
10
10
  unregisterBackend,
11
11
  wrapZenFSFileSystem
12
- } from "./chunk-6OS2F54Z.mjs";
12
+ } from "./chunk-NSEXSKVW.mjs";
13
13
 
14
14
  // src/config-repo.ts
15
15
  import {
@@ -351,7 +351,7 @@ function registerFolderBackend() {
351
351
  const pathMod = await import("path");
352
352
  const dir = options.path;
353
353
  const store = new FolderStore({ path: dir, label: options.label, fs, pathMod });
354
- return (await import("./backend-registry-3FVPYPZL.mjs")).wrapZenFSFileSystem({ backend: FolderBackend, path: dir, label: options.label });
354
+ return (await import("./backend-registry-ZFTXH537.mjs")).wrapZenFSFileSystem({ backend: FolderBackend, path: dir, label: options.label });
355
355
  },
356
356
  {
357
357
  type: "Folder",
@@ -24478,6 +24478,9 @@ var ZenFSConfig = (() => {
24478
24478
  if (typeof isolatedFS.writeFileWithMtime === "function") {
24479
24479
  backend.writeFileWithMtime = (path, data, mtimeMs) => isolatedFS.writeFileWithMtime(path, data, mtimeMs);
24480
24480
  }
24481
+ if (typeof isolatedFS.shouldSync === "function") {
24482
+ backend.shouldSync = (...args) => isolatedFS.shouldSync(...args);
24483
+ }
24481
24484
  return backend;
24482
24485
  }
24483
24486
  function _cacheGet(key) {
@@ -24573,7 +24576,8 @@ var ZenFSConfig = (() => {
24573
24576
  // third-party Gitee widget) would shadow the real backend and break mounting
24574
24577
  // with "Invalid mount configuration".
24575
24578
  "zen-fs-gitee": ["ZenFSGitee"],
24576
- "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"]
24579
+ "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"],
24580
+ "zen-fs-webdav": ["ZenFSWebDAV"]
24577
24581
  };
24578
24582
  registerBackend("GitHub", async (options) => {
24579
24583
  const _gh = await importOptionalBackend("zen-fs-github");
@@ -24695,6 +24699,53 @@ var ZenFSConfig = (() => {
24695
24699
  // connections to the same endpoint with different tuning are deduplicated.
24696
24700
  identityFields: ["href", "token", "basePath"]
24697
24701
  });
24702
+ registerBackend("WebDAV", async (options) => {
24703
+ const _dav = await importOptionalBackend("zen-fs-webdav");
24704
+ const SyncableWebDAVFS = _dav?.SyncableWebDAVFS ?? _dav?.default?.SyncableWebDAVFS ?? globalThis.ZenFSWebDAV?.SyncableWebDAVFS;
24705
+ if (typeof SyncableWebDAVFS !== "function") {
24706
+ throw new Error(
24707
+ `Backend package "zen-fs-webdav" loaded, but its SyncableWebDAVFS export is not a constructor (typeof=${typeof SyncableWebDAVFS}). Run: npm install zen-fs-webdav, or load its UMD bundle via <script src=".../zen-fs-webdav.global.js"> so it exposes the global "ZenFSWebDAV".`
24708
+ );
24709
+ }
24710
+ const instance = new SyncableWebDAVFS({
24711
+ baseUrl: options.baseUrl,
24712
+ username: options.username,
24713
+ password: options.password,
24714
+ token: options.token,
24715
+ headers: options.headers,
24716
+ timeout: options.timeout,
24717
+ preciseMtime: true
24718
+ });
24719
+ if (options.purgeLegacyMtime === true) {
24720
+ try {
24721
+ await instance.purgeLegacyMtimeSidecars({ root: options.basePath ?? "/" });
24722
+ } catch {
24723
+ }
24724
+ }
24725
+ return instance;
24726
+ }, {
24727
+ type: "WebDAV",
24728
+ label: "WebDAV",
24729
+ icon: "\u2601\uFE0F",
24730
+ fields: [
24731
+ { key: "baseUrl", label: "Base URL", type: "text", placeholder: "https://dav.example.com/remote.php/dav/files/user/", required: true },
24732
+ { key: "username", label: "Username", type: "text", placeholder: "admin" },
24733
+ { key: "password", label: "Password", type: "password" },
24734
+ { key: "token", label: "Token", type: "password", placeholder: "Bearer token (optional)" },
24735
+ { key: "basePath", label: "Base Path", type: "text", placeholder: "/zen-fs-config/" },
24736
+ { key: "purgeLegacyMtime", label: "Purge legacy .mtime sidecars", type: "select", options: [
24737
+ { value: "false", label: "no (default)" },
24738
+ { value: "true", label: "yes (one-time migration)" }
24739
+ ] }
24740
+ ],
24741
+ defaultOptions: { baseUrl: "", username: "", password: "", token: "", basePath: "/", purgeLegacyMtime: "false" },
24742
+ // accountFields: credentials live on the endpoint, so a data-sync group can
24743
+ // reuse them from an already-connected config-sync WebDAV backend.
24744
+ accountFields: ["username", "password", "token"],
24745
+ // identity = the WebDAV endpoint. Credentials are auth, not location, so two
24746
+ // connections to the same URL are deduplicated as one replica.
24747
+ identityFields: ["baseUrl"]
24748
+ });
24698
24749
  }
24699
24750
  });
24700
24751
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.5.39",
3
+ "version": "0.5.40",
4
4
  "description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -52,7 +52,8 @@
52
52
  "zen-fs-sync": ">=0.4.7",
53
53
  "zen-fs-github": "*",
54
54
  "zen-fs-gitee": "*",
55
- "zen-fs-remotestoragejs": "*"
55
+ "zen-fs-remotestoragejs": "*",
56
+ "zen-fs-webdav": "*"
56
57
  },
57
58
  "dependencies": {
58
59
  "@richard432/localstorage-logger": "^0.1.0"
@@ -72,6 +73,9 @@
72
73
  },
73
74
  "zen-fs-remotestoragejs": {
74
75
  "optional": true
76
+ },
77
+ "zen-fs-webdav": {
78
+ "optional": true
75
79
  }
76
80
  },
77
81
  "devDependencies": {