zen-fs-config 0.5.30 → 0.5.31

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-XLOBWTYJ.mjs";
12
+ } from "./chunk-UDEOYFWS.mjs";
13
13
  export {
14
14
  createBackend,
15
15
  getAccountFields,
@@ -184,15 +184,24 @@ var OPTIONAL_BACKEND_GLOBALS = {
184
184
  };
185
185
  async function importOptionalBackend(pkg) {
186
186
  const candidates = OPTIONAL_BACKEND_GLOBALS[pkg];
187
+ const fromGlobal = () => {
188
+ if (!candidates) return void 0;
189
+ for (const name of candidates) {
190
+ const g = globalThis[name];
191
+ if (g) return g;
192
+ }
193
+ return void 0;
194
+ };
187
195
  try {
188
- return await import(pkg);
189
- } catch {
190
- if (candidates) {
191
- for (const name of candidates) {
192
- const g = globalThis[name];
193
- if (g) return g;
194
- }
196
+ const mod = await import(pkg);
197
+ if (mod && Object.keys(mod).length === 0) {
198
+ const g = fromGlobal();
199
+ if (g) return g;
195
200
  }
201
+ return mod;
202
+ } catch {
203
+ const g = fromGlobal();
204
+ if (g) return g;
196
205
  const globalHint = candidates?.length ? `, or load its UMD bundle via <script src=".../${pkg}.js"> (exposes global "${candidates[0]}")` : "";
197
206
  throw new Error(
198
207
  `Backend package "${pkg}" is not available. In a bundler/import-map environment run: npm install ${pkg}${globalHint}.`
@@ -200,7 +209,13 @@ async function importOptionalBackend(pkg) {
200
209
  }
201
210
  }
202
211
  registerBackend("GitHub", async (options) => {
203
- const { Github } = await importOptionalBackend("zen-fs-github");
212
+ const _gh = await importOptionalBackend("zen-fs-github");
213
+ const Github = _gh?.Github ?? _gh?.default;
214
+ if (typeof Github !== "function") {
215
+ throw new Error(
216
+ `Backend package "zen-fs-github" loaded, but its Github export is not a constructor (typeof=${typeof Github}). Load its UMD bundle so it exposes the global "ZenFSGitHub".`
217
+ );
218
+ }
204
219
  const backend = await wrapZenFSFileSystem({
205
220
  backend: Github,
206
221
  token: options.token,
@@ -248,7 +263,13 @@ registerBackend("GitHub", async (options) => {
248
263
  accountFields: ["token", "owner", "baseUrl"]
249
264
  });
250
265
  registerBackend("Gitee", async (options) => {
251
- const { Gitee } = await importOptionalBackend("zen-fs-gitee");
266
+ const _gt = await importOptionalBackend("zen-fs-gitee");
267
+ const Gitee = _gt?.Gitee ?? _gt?.default;
268
+ if (typeof Gitee !== "function") {
269
+ throw new Error(
270
+ `Backend package "zen-fs-gitee" loaded, but its Gitee export is not a constructor (typeof=${typeof Gitee}). Load its UMD bundle so it exposes the global "ZenFSGitee".`
271
+ );
272
+ }
252
273
  return wrapZenFSFileSystem({
253
274
  backend: Gitee,
254
275
  token: options.token,
@@ -272,7 +293,13 @@ registerBackend("Gitee", async (options) => {
272
293
  accountFields: ["token", "owner", "baseUrl"]
273
294
  });
274
295
  registerBackend("RemoteStorage", async (options) => {
275
- const { RemoteStorageFileSystem } = await importOptionalBackend("zen-fs-remotestoragejs");
296
+ const _rs = await importOptionalBackend("zen-fs-remotestoragejs");
297
+ const RemoteStorageFileSystem = _rs?.RemoteStorageFileSystem ?? _rs?.default ?? (typeof _rs === "function" ? _rs : void 0);
298
+ if (typeof RemoteStorageFileSystem !== "function") {
299
+ throw new Error(
300
+ `Backend package "zen-fs-remotestoragejs" loaded, but its RemoteStorageFileSystem export is not a constructor (typeof=${typeof RemoteStorageFileSystem}). Load its UMD bundle via <script src=".../zen-fs-remotestoragejs.global.js"> so it exposes the global "ZenFSRemoteStorage".`
301
+ );
302
+ }
276
303
  return new RemoteStorageFileSystem({
277
304
  href: options.href,
278
305
  token: options.token,
package/dist/index.js CHANGED
@@ -187,15 +187,24 @@ function _cacheSet(key, value) {
187
187
  }
188
188
  async function importOptionalBackend(pkg) {
189
189
  const candidates = OPTIONAL_BACKEND_GLOBALS[pkg];
190
+ const fromGlobal = () => {
191
+ if (!candidates) return void 0;
192
+ for (const name of candidates) {
193
+ const g = globalThis[name];
194
+ if (g) return g;
195
+ }
196
+ return void 0;
197
+ };
190
198
  try {
191
- return await import(pkg);
192
- } catch {
193
- if (candidates) {
194
- for (const name of candidates) {
195
- const g = globalThis[name];
196
- if (g) return g;
197
- }
199
+ const mod = await import(pkg);
200
+ if (mod && Object.keys(mod).length === 0) {
201
+ const g = fromGlobal();
202
+ if (g) return g;
198
203
  }
204
+ return mod;
205
+ } catch {
206
+ const g = fromGlobal();
207
+ if (g) return g;
199
208
  const globalHint = candidates?.length ? `, or load its UMD bundle via <script src=".../${pkg}.js"> (exposes global "${candidates[0]}")` : "";
200
209
  throw new Error(
201
210
  `Backend package "${pkg}" is not available. In a bundler/import-map environment run: npm install ${pkg}${globalHint}.`
@@ -249,7 +258,13 @@ var init_backend_registry = __esm({
249
258
  "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"]
250
259
  };
251
260
  registerBackend("GitHub", async (options) => {
252
- const { Github } = await importOptionalBackend("zen-fs-github");
261
+ const _gh = await importOptionalBackend("zen-fs-github");
262
+ const Github = _gh?.Github ?? _gh?.default;
263
+ if (typeof Github !== "function") {
264
+ throw new Error(
265
+ `Backend package "zen-fs-github" loaded, but its Github export is not a constructor (typeof=${typeof Github}). Load its UMD bundle so it exposes the global "ZenFSGitHub".`
266
+ );
267
+ }
253
268
  const backend = await wrapZenFSFileSystem({
254
269
  backend: Github,
255
270
  token: options.token,
@@ -297,7 +312,13 @@ var init_backend_registry = __esm({
297
312
  accountFields: ["token", "owner", "baseUrl"]
298
313
  });
299
314
  registerBackend("Gitee", async (options) => {
300
- const { Gitee } = await importOptionalBackend("zen-fs-gitee");
315
+ const _gt = await importOptionalBackend("zen-fs-gitee");
316
+ const Gitee = _gt?.Gitee ?? _gt?.default;
317
+ if (typeof Gitee !== "function") {
318
+ throw new Error(
319
+ `Backend package "zen-fs-gitee" loaded, but its Gitee export is not a constructor (typeof=${typeof Gitee}). Load its UMD bundle so it exposes the global "ZenFSGitee".`
320
+ );
321
+ }
301
322
  return wrapZenFSFileSystem({
302
323
  backend: Gitee,
303
324
  token: options.token,
@@ -321,7 +342,13 @@ var init_backend_registry = __esm({
321
342
  accountFields: ["token", "owner", "baseUrl"]
322
343
  });
323
344
  registerBackend("RemoteStorage", async (options) => {
324
- const { RemoteStorageFileSystem } = await importOptionalBackend("zen-fs-remotestoragejs");
345
+ const _rs = await importOptionalBackend("zen-fs-remotestoragejs");
346
+ const RemoteStorageFileSystem = _rs?.RemoteStorageFileSystem ?? _rs?.default ?? (typeof _rs === "function" ? _rs : void 0);
347
+ if (typeof RemoteStorageFileSystem !== "function") {
348
+ throw new Error(
349
+ `Backend package "zen-fs-remotestoragejs" loaded, but its RemoteStorageFileSystem export is not a constructor (typeof=${typeof RemoteStorageFileSystem}). Load its UMD bundle via <script src=".../zen-fs-remotestoragejs.global.js"> so it exposes the global "ZenFSRemoteStorage".`
350
+ );
351
+ }
325
352
  return new RemoteStorageFileSystem({
326
353
  href: options.href,
327
354
  token: options.token,
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  registerBackend,
10
10
  unregisterBackend,
11
11
  wrapZenFSFileSystem
12
- } from "./chunk-XLOBWTYJ.mjs";
12
+ } from "./chunk-UDEOYFWS.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-7OTQSRXY.mjs")).wrapZenFSFileSystem({ backend: FolderBackend, path: dir, label: options.label });
354
+ return (await import("./backend-registry-7QGFWLM7.mjs")).wrapZenFSFileSystem({ backend: FolderBackend, path: dir, label: options.label });
355
355
  },
356
356
  {
357
357
  type: "Folder",
@@ -24500,15 +24500,24 @@ var ZenFSConfig = (() => {
24500
24500
  }
24501
24501
  async function importOptionalBackend(pkg) {
24502
24502
  const candidates = OPTIONAL_BACKEND_GLOBALS[pkg];
24503
+ const fromGlobal = () => {
24504
+ if (!candidates) return void 0;
24505
+ for (const name of candidates) {
24506
+ const g = globalThis[name];
24507
+ if (g) return g;
24508
+ }
24509
+ return void 0;
24510
+ };
24503
24511
  try {
24504
- return await import(pkg);
24505
- } catch {
24506
- if (candidates) {
24507
- for (const name of candidates) {
24508
- const g = globalThis[name];
24509
- if (g) return g;
24510
- }
24512
+ const mod = await import(pkg);
24513
+ if (mod && Object.keys(mod).length === 0) {
24514
+ const g = fromGlobal();
24515
+ if (g) return g;
24511
24516
  }
24517
+ return mod;
24518
+ } catch {
24519
+ const g = fromGlobal();
24520
+ if (g) return g;
24512
24521
  const globalHint = candidates?.length ? `, or load its UMD bundle via <script src=".../${pkg}.js"> (exposes global "${candidates[0]}")` : "";
24513
24522
  throw new Error(
24514
24523
  `Backend package "${pkg}" is not available. In a bundler/import-map environment run: npm install ${pkg}${globalHint}.`
@@ -24562,7 +24571,13 @@ var ZenFSConfig = (() => {
24562
24571
  "zen-fs-remotestoragejs": ["ZenFSRemoteStorage", "RemoteStorageFileSystem"]
24563
24572
  };
24564
24573
  registerBackend("GitHub", async (options) => {
24565
- const { Github } = await importOptionalBackend("zen-fs-github");
24574
+ const _gh = await importOptionalBackend("zen-fs-github");
24575
+ const Github = _gh?.Github ?? _gh?.default;
24576
+ if (typeof Github !== "function") {
24577
+ throw new Error(
24578
+ `Backend package "zen-fs-github" loaded, but its Github export is not a constructor (typeof=${typeof Github}). Load its UMD bundle so it exposes the global "ZenFSGitHub".`
24579
+ );
24580
+ }
24566
24581
  const backend = await wrapZenFSFileSystem({
24567
24582
  backend: Github,
24568
24583
  token: options.token,
@@ -24610,7 +24625,13 @@ var ZenFSConfig = (() => {
24610
24625
  accountFields: ["token", "owner", "baseUrl"]
24611
24626
  });
24612
24627
  registerBackend("Gitee", async (options) => {
24613
- const { Gitee } = await importOptionalBackend("zen-fs-gitee");
24628
+ const _gt = await importOptionalBackend("zen-fs-gitee");
24629
+ const Gitee = _gt?.Gitee ?? _gt?.default;
24630
+ if (typeof Gitee !== "function") {
24631
+ throw new Error(
24632
+ `Backend package "zen-fs-gitee" loaded, but its Gitee export is not a constructor (typeof=${typeof Gitee}). Load its UMD bundle so it exposes the global "ZenFSGitee".`
24633
+ );
24634
+ }
24614
24635
  return wrapZenFSFileSystem({
24615
24636
  backend: Gitee,
24616
24637
  token: options.token,
@@ -24634,7 +24655,13 @@ var ZenFSConfig = (() => {
24634
24655
  accountFields: ["token", "owner", "baseUrl"]
24635
24656
  });
24636
24657
  registerBackend("RemoteStorage", async (options) => {
24637
- const { RemoteStorageFileSystem } = await importOptionalBackend("zen-fs-remotestoragejs");
24658
+ const _rs = await importOptionalBackend("zen-fs-remotestoragejs");
24659
+ const RemoteStorageFileSystem = _rs?.RemoteStorageFileSystem ?? _rs?.default ?? (typeof _rs === "function" ? _rs : void 0);
24660
+ if (typeof RemoteStorageFileSystem !== "function") {
24661
+ throw new Error(
24662
+ `Backend package "zen-fs-remotestoragejs" loaded, but its RemoteStorageFileSystem export is not a constructor (typeof=${typeof RemoteStorageFileSystem}). Load its UMD bundle via <script src=".../zen-fs-remotestoragejs.global.js"> so it exposes the global "ZenFSRemoteStorage".`
24663
+ );
24664
+ }
24638
24665
  return new RemoteStorageFileSystem({
24639
24666
  href: options.href,
24640
24667
  token: options.token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.5.30",
3
+ "version": "0.5.31",
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",