zen-fs-config 0.2.1 → 0.3.0
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/index.js +93 -0
- package/dist/index.mjs +93 -0
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -364,6 +364,99 @@ registerBackend("InMemory", async (options) => {
|
|
|
364
364
|
};
|
|
365
365
|
return backend;
|
|
366
366
|
});
|
|
367
|
+
var idbCounter = 0;
|
|
368
|
+
registerBackend("IndexedDB", async (options) => {
|
|
369
|
+
const zenfs = await import("@zenfs/core");
|
|
370
|
+
const { IndexedDB } = await import("@zenfs/dom");
|
|
371
|
+
const storeName = options.storeName ?? `zen-fs-config-${++idbCounter}`;
|
|
372
|
+
await zenfs.configureSingle({ backend: IndexedDB, storeName });
|
|
373
|
+
const pfs = zenfs.fs.promises;
|
|
374
|
+
const backend = {
|
|
375
|
+
async readFile(path, ...args) {
|
|
376
|
+
return args.length > 0 ? pfs.readFile(path, ...args) : pfs.readFile(path);
|
|
377
|
+
},
|
|
378
|
+
async writeFile(path, data, options2) {
|
|
379
|
+
return pfs.writeFile(path, data, options2);
|
|
380
|
+
},
|
|
381
|
+
async readdir(path) {
|
|
382
|
+
const entries = await pfs.readdir(path);
|
|
383
|
+
return entries.map((e) => typeof e === "string" ? e : e.name);
|
|
384
|
+
},
|
|
385
|
+
async stat(path, ...args) {
|
|
386
|
+
return pfs.stat(path, ...args);
|
|
387
|
+
},
|
|
388
|
+
async exists(path) {
|
|
389
|
+
try {
|
|
390
|
+
await pfs.stat(path);
|
|
391
|
+
return true;
|
|
392
|
+
} catch {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
async mkdir(path, options2) {
|
|
397
|
+
return pfs.mkdir(path, options2);
|
|
398
|
+
},
|
|
399
|
+
async unlink(path) {
|
|
400
|
+
return pfs.unlink(path);
|
|
401
|
+
},
|
|
402
|
+
async rmdir(path) {
|
|
403
|
+
return pfs.rmdir(path);
|
|
404
|
+
},
|
|
405
|
+
async rename(oldPath, newPath) {
|
|
406
|
+
return pfs.rename(oldPath, newPath);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
return backend;
|
|
410
|
+
});
|
|
411
|
+
registerBackend("WebStorage", async (options) => {
|
|
412
|
+
const zenfs = await import("@zenfs/core");
|
|
413
|
+
const { WebStorage } = await import("@zenfs/dom");
|
|
414
|
+
const storageType = options.storageType ?? "localStorage";
|
|
415
|
+
let storage;
|
|
416
|
+
if (storageType === "sessionStorage" && typeof sessionStorage !== "undefined") {
|
|
417
|
+
storage = sessionStorage;
|
|
418
|
+
} else {
|
|
419
|
+
storage = localStorage;
|
|
420
|
+
}
|
|
421
|
+
await zenfs.configureSingle({ backend: WebStorage, storage });
|
|
422
|
+
const pfs = zenfs.fs.promises;
|
|
423
|
+
const backend = {
|
|
424
|
+
async readFile(path, ...args) {
|
|
425
|
+
return args.length > 0 ? pfs.readFile(path, ...args) : pfs.readFile(path);
|
|
426
|
+
},
|
|
427
|
+
async writeFile(path, data, options2) {
|
|
428
|
+
return pfs.writeFile(path, data, options2);
|
|
429
|
+
},
|
|
430
|
+
async readdir(path) {
|
|
431
|
+
const entries = await pfs.readdir(path);
|
|
432
|
+
return entries.map((e) => typeof e === "string" ? e : e.name);
|
|
433
|
+
},
|
|
434
|
+
async stat(path, ...args) {
|
|
435
|
+
return pfs.stat(path, ...args);
|
|
436
|
+
},
|
|
437
|
+
async exists(path) {
|
|
438
|
+
try {
|
|
439
|
+
await pfs.stat(path);
|
|
440
|
+
return true;
|
|
441
|
+
} catch {
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
async mkdir(path, options2) {
|
|
446
|
+
return pfs.mkdir(path, options2);
|
|
447
|
+
},
|
|
448
|
+
async unlink(path) {
|
|
449
|
+
return pfs.unlink(path);
|
|
450
|
+
},
|
|
451
|
+
async rmdir(path) {
|
|
452
|
+
return pfs.rmdir(path);
|
|
453
|
+
},
|
|
454
|
+
async rename(oldPath, newPath) {
|
|
455
|
+
return pfs.rename(oldPath, newPath);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
return backend;
|
|
459
|
+
});
|
|
367
460
|
registerBackend("GitHub", async (options) => {
|
|
368
461
|
const token = options.token ?? "";
|
|
369
462
|
const owner = options.owner ?? "";
|
package/dist/index.mjs
CHANGED
|
@@ -317,6 +317,99 @@ registerBackend("InMemory", async (options) => {
|
|
|
317
317
|
};
|
|
318
318
|
return backend;
|
|
319
319
|
});
|
|
320
|
+
var idbCounter = 0;
|
|
321
|
+
registerBackend("IndexedDB", async (options) => {
|
|
322
|
+
const zenfs = await import("@zenfs/core");
|
|
323
|
+
const { IndexedDB } = await import("@zenfs/dom");
|
|
324
|
+
const storeName = options.storeName ?? `zen-fs-config-${++idbCounter}`;
|
|
325
|
+
await zenfs.configureSingle({ backend: IndexedDB, storeName });
|
|
326
|
+
const pfs = zenfs.fs.promises;
|
|
327
|
+
const backend = {
|
|
328
|
+
async readFile(path, ...args) {
|
|
329
|
+
return args.length > 0 ? pfs.readFile(path, ...args) : pfs.readFile(path);
|
|
330
|
+
},
|
|
331
|
+
async writeFile(path, data, options2) {
|
|
332
|
+
return pfs.writeFile(path, data, options2);
|
|
333
|
+
},
|
|
334
|
+
async readdir(path) {
|
|
335
|
+
const entries = await pfs.readdir(path);
|
|
336
|
+
return entries.map((e) => typeof e === "string" ? e : e.name);
|
|
337
|
+
},
|
|
338
|
+
async stat(path, ...args) {
|
|
339
|
+
return pfs.stat(path, ...args);
|
|
340
|
+
},
|
|
341
|
+
async exists(path) {
|
|
342
|
+
try {
|
|
343
|
+
await pfs.stat(path);
|
|
344
|
+
return true;
|
|
345
|
+
} catch {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
async mkdir(path, options2) {
|
|
350
|
+
return pfs.mkdir(path, options2);
|
|
351
|
+
},
|
|
352
|
+
async unlink(path) {
|
|
353
|
+
return pfs.unlink(path);
|
|
354
|
+
},
|
|
355
|
+
async rmdir(path) {
|
|
356
|
+
return pfs.rmdir(path);
|
|
357
|
+
},
|
|
358
|
+
async rename(oldPath, newPath) {
|
|
359
|
+
return pfs.rename(oldPath, newPath);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return backend;
|
|
363
|
+
});
|
|
364
|
+
registerBackend("WebStorage", async (options) => {
|
|
365
|
+
const zenfs = await import("@zenfs/core");
|
|
366
|
+
const { WebStorage } = await import("@zenfs/dom");
|
|
367
|
+
const storageType = options.storageType ?? "localStorage";
|
|
368
|
+
let storage;
|
|
369
|
+
if (storageType === "sessionStorage" && typeof sessionStorage !== "undefined") {
|
|
370
|
+
storage = sessionStorage;
|
|
371
|
+
} else {
|
|
372
|
+
storage = localStorage;
|
|
373
|
+
}
|
|
374
|
+
await zenfs.configureSingle({ backend: WebStorage, storage });
|
|
375
|
+
const pfs = zenfs.fs.promises;
|
|
376
|
+
const backend = {
|
|
377
|
+
async readFile(path, ...args) {
|
|
378
|
+
return args.length > 0 ? pfs.readFile(path, ...args) : pfs.readFile(path);
|
|
379
|
+
},
|
|
380
|
+
async writeFile(path, data, options2) {
|
|
381
|
+
return pfs.writeFile(path, data, options2);
|
|
382
|
+
},
|
|
383
|
+
async readdir(path) {
|
|
384
|
+
const entries = await pfs.readdir(path);
|
|
385
|
+
return entries.map((e) => typeof e === "string" ? e : e.name);
|
|
386
|
+
},
|
|
387
|
+
async stat(path, ...args) {
|
|
388
|
+
return pfs.stat(path, ...args);
|
|
389
|
+
},
|
|
390
|
+
async exists(path) {
|
|
391
|
+
try {
|
|
392
|
+
await pfs.stat(path);
|
|
393
|
+
return true;
|
|
394
|
+
} catch {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
async mkdir(path, options2) {
|
|
399
|
+
return pfs.mkdir(path, options2);
|
|
400
|
+
},
|
|
401
|
+
async unlink(path) {
|
|
402
|
+
return pfs.unlink(path);
|
|
403
|
+
},
|
|
404
|
+
async rmdir(path) {
|
|
405
|
+
return pfs.rmdir(path);
|
|
406
|
+
},
|
|
407
|
+
async rename(oldPath, newPath) {
|
|
408
|
+
return pfs.rename(oldPath, newPath);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
return backend;
|
|
412
|
+
});
|
|
320
413
|
registerBackend("GitHub", async (options) => {
|
|
321
414
|
const token = options.token ?? "";
|
|
322
415
|
const owner = options.owner ?? "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-fs-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"zen-fs-cache": "^1.0.1",
|
|
49
49
|
"zen-fs-sync": "^0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@zenfs/dom": "^1.2.9"
|
|
50
53
|
}
|
|
51
54
|
}
|