sliftutils 0.11.0 → 0.12.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/builders/dist/generateIndexDts.ts.cache +3 -3
- package/builders/generateIndexDts.ts +1 -1
- package/index.d.ts +478 -0
- package/package.json +1 -1
- package/storage/CachedStorage.d.ts +2 -0
- package/storage/DelayedStorage.d.ts +14 -0
- package/storage/DiskCollection.d.ts +99 -0
- package/storage/FileFolderAPI.d.ts +71 -0
- package/storage/IStorage.d.ts +38 -0
- package/storage/IndexedDBFileFolderAPI.d.ts +6 -0
- package/storage/JSONStorage.d.ts +16 -0
- package/storage/PendingManager.d.ts +6 -0
- package/storage/PendingStorage.d.ts +18 -0
- package/storage/PrivateFileSystemStorage.d.ts +23 -0
- package/storage/StorageObservable.d.ts +32 -0
- package/storage/TransactionStorage.d.ts +46 -0
- package/storage/fileSystemPointer.d.ts +11 -0
- package/tsconfig.declarations.json +3 -1
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true , configurable: true});
|
|
26
26
|
const fs = __importStar(require("fs"));
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
|
-
const FOLDERS_TO_INCLUDE = ["render-utils", "misc"];
|
|
28
|
+
const FOLDERS_TO_INCLUDE = ["render-utils", "misc", "storage"];
|
|
29
29
|
function getAllDtsFiles(dir, fileList = []) {
|
|
30
30
|
const files = fs.readdirSync(dir);
|
|
31
31
|
for (const file of files) {
|
|
@@ -70,5 +70,5 @@ function generateIndexDts() {
|
|
|
70
70
|
console.log(`Generated ${outputPath} with ${allModules.length} module declarations`);
|
|
71
71
|
}
|
|
72
72
|
generateIndexDts();
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
74
|
-
/* _JS_SOURCE_HASH = "
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ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gICAgICAgY29uc3QgcmVsYXRpdmVQYXRoID0gcGF0aC5yZWxhdGl2ZShmb2xkZXJQYXRoLCBmaWxlUGF0aCk7XG4gICAgICAgICAgICAgICAgY29uc3Qgd2l0aG91dEV4dCA9IHJlbGF0aXZlUGF0aC5yZXBsYWNlKC9cXC5kXFwudHMkLywgXCJcIik7XG4gICAgICAgICAgICAgICAgY29uc3QgbW9kdWxlUGF0aCA9IFwic2xpZnR1dGlscy9cIiArIGZvbGRlck5hbWUgKyBcIi9cIiArIHdpdGhvdXRFeHQucmVwbGFjZSgvXFxcXC9nLCBcIi9cIik7XG5cbiAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50ID0gZnMucmVhZEZpbGVTeW5jKGZpbGVQYXRoLCBcInV0ZjhcIik7XG4gICAgICAgICAgICAgICAgY29uc3QgaW5kZW50ZWRDb250ZW50ID0gY29udGVudFxuICAgICAgICAgICAgICAgICAgICAuc3BsaXQoXCJcXG5cIilcbiAgICAgICAgICAgICAgICAgICAgLm1hcChsaW5lID0+IGxpbmUgPyBcIiAgICBcIiArIGxpbmUgOiBsaW5lKVxuICAgICAgICAgICAgICAgICAgICAuam9pbihcIlxcblwiKTtcblxuICAgICAgICAgICAgICAgIHJldHVybiBgZGVjbGFyZSBtb2R1bGUgXCIke21vZHVsZVBhdGh9XCIge1xcbiR7aW5kZW50ZWRDb250ZW50fVxcbn1gO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgYWxsTW9kdWxlcy5wdXNoKC4uLm1vZHVsZXMpO1xuICAgIH1cblxuICAgIGNvbnN0IHNvcnRlZE1vZHVsZXMgPSBhbGxNb2R1bGVzLnNvcnQoKS5qb2luKFwiXFxuXFxuXCIpO1xuICAgIGNvbnN0IG91dHB1dFBhdGggPSBwYXRoLmpvaW4oX19kaXJuYW1lLCBcIi4uXCIsIFwiaW5kZXguZC50c1wiKTtcbiAgICBjb25zdCBoZWFkZXIgPSBgLy8gQXV0by1nZW5lcmF0ZWQgZmlsZS4gRG8gbm90IGVkaXQgbWFudWFsbHkuXFxuLy8gR2VuZXJhdGVkIGJ5OiB5YXJuIGdlbmVyYXRlLWluZGV4LWR0c1xcblxcbmA7XG5cbiAgICBmcy53cml0ZUZpbGVTeW5jKG91dHB1dFBhdGgsIGhlYWRlciArIHNvcnRlZE1vZHVsZXMgKyBcIlxcblwiLCBcInV0ZjhcIik7XG4gICAgY29uc29sZS5sb2coYEdlbmVyYXRlZCAke291dHB1dFBhdGh9IHdpdGggJHthbGxNb2R1bGVzLmxlbmd0aH0gbW9kdWxlIGRlY2xhcmF0aW9uc2ApO1xufVxuXG5nZW5lcmF0ZUluZGV4RHRzKCk7XG5cbiJdfQ==
|
|
74
|
+
/* _JS_SOURCE_HASH = "396b7ba67cc84f07dc98f22fe7d79e8fe6b153ca5bc3146e063afd6fc30913cf"; */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
|
|
4
|
-
const FOLDERS_TO_INCLUDE = ["render-utils", "misc"];
|
|
4
|
+
const FOLDERS_TO_INCLUDE = ["render-utils", "misc", "storage"];
|
|
5
5
|
|
|
6
6
|
function getAllDtsFiles(dir: string, fileList: string[] = []): string[] {
|
|
7
7
|
const files = fs.readdirSync(dir);
|
package/index.d.ts
CHANGED
|
@@ -376,3 +376,481 @@ declare module "sliftutils/render-utils/observer" {
|
|
|
376
376
|
} & T;
|
|
377
377
|
|
|
378
378
|
}
|
|
379
|
+
|
|
380
|
+
declare module "sliftutils/storage/CachedStorage" {
|
|
381
|
+
import { StorageSync } from "./StorageObservable";
|
|
382
|
+
export declare function newCachedStrStorage<T>(folder: string, getValue: (key: string) => Promise<T>): StorageSync<T>;
|
|
383
|
+
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare module "sliftutils/storage/DelayedStorage" {
|
|
387
|
+
import { IStorage } from "./IStorage";
|
|
388
|
+
export declare class DelayedStorage<T> implements IStorage<T> {
|
|
389
|
+
private storage;
|
|
390
|
+
constructor(storage: Promise<IStorage<T>>);
|
|
391
|
+
get(key: string): Promise<T | undefined>;
|
|
392
|
+
set(key: string, value: T): Promise<void>;
|
|
393
|
+
remove(key: string): Promise<void>;
|
|
394
|
+
getKeys(): Promise<string[]>;
|
|
395
|
+
getInfo(key: string): Promise<{
|
|
396
|
+
size: number;
|
|
397
|
+
lastModified: number;
|
|
398
|
+
} | undefined>;
|
|
399
|
+
reset(): Promise<void>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
declare module "sliftutils/storage/DiskCollection" {
|
|
405
|
+
/// <reference types="node" />
|
|
406
|
+
/// <reference types="node" />
|
|
407
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
408
|
+
import { StorageSync } from "./StorageObservable";
|
|
409
|
+
import { TransactionStorage } from "./TransactionStorage";
|
|
410
|
+
export declare class DiskCollection<T> implements IStorageSync<T> {
|
|
411
|
+
private collectionName;
|
|
412
|
+
private writeDelay?;
|
|
413
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
414
|
+
transactionStorage: TransactionStorage | undefined;
|
|
415
|
+
initStorage(): Promise<IStorage<T>>;
|
|
416
|
+
baseStorage: Promise<IStorage<T>>;
|
|
417
|
+
private synced;
|
|
418
|
+
get(key: string): T | undefined;
|
|
419
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
420
|
+
set(key: string, value: T): void;
|
|
421
|
+
remove(key: string): void;
|
|
422
|
+
getKeys(): string[];
|
|
423
|
+
getKeysPromise(): Promise<string[]>;
|
|
424
|
+
getEntries(): [string, T][];
|
|
425
|
+
getValues(): T[];
|
|
426
|
+
getValuesPromise(): Promise<T[]>;
|
|
427
|
+
getInfo(key: string): {
|
|
428
|
+
size: number;
|
|
429
|
+
lastModified: number;
|
|
430
|
+
} | undefined;
|
|
431
|
+
reset(): Promise<void>;
|
|
432
|
+
}
|
|
433
|
+
export declare class DiskCollectionBrowser<T> implements IStorageSync<T> {
|
|
434
|
+
private collectionName;
|
|
435
|
+
private writeDelay?;
|
|
436
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
437
|
+
transactionStorage: TransactionStorage | undefined;
|
|
438
|
+
initStorage(): Promise<IStorage<T>>;
|
|
439
|
+
baseStorage: Promise<IStorage<T>>;
|
|
440
|
+
private synced;
|
|
441
|
+
get(key: string): T | undefined;
|
|
442
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
443
|
+
set(key: string, value: T): void;
|
|
444
|
+
remove(key: string): void;
|
|
445
|
+
getKeys(): string[];
|
|
446
|
+
getKeysPromise(): Promise<string[]>;
|
|
447
|
+
getEntries(): [string, T][];
|
|
448
|
+
getValues(): T[];
|
|
449
|
+
getValuesPromise(): Promise<T[]>;
|
|
450
|
+
getInfo(key: string): {
|
|
451
|
+
size: number;
|
|
452
|
+
lastModified: number;
|
|
453
|
+
} | undefined;
|
|
454
|
+
reset(): Promise<void>;
|
|
455
|
+
}
|
|
456
|
+
export declare class DiskCollectionPromise<T> implements IStorage<T> {
|
|
457
|
+
private collectionName;
|
|
458
|
+
private writeDelay?;
|
|
459
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
460
|
+
initStorage(): Promise<IStorage<T>>;
|
|
461
|
+
private synced;
|
|
462
|
+
get(key: string): Promise<T | undefined>;
|
|
463
|
+
set(key: string, value: T): Promise<void>;
|
|
464
|
+
remove(key: string): Promise<void>;
|
|
465
|
+
getKeys(): Promise<string[]>;
|
|
466
|
+
getInfo(key: string): Promise<{
|
|
467
|
+
size: number;
|
|
468
|
+
lastModified: number;
|
|
469
|
+
} | undefined>;
|
|
470
|
+
reset(): Promise<void>;
|
|
471
|
+
}
|
|
472
|
+
export declare class DiskCollectionRaw implements IStorage<Buffer> {
|
|
473
|
+
private collectionName;
|
|
474
|
+
constructor(collectionName: string);
|
|
475
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
476
|
+
private synced;
|
|
477
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
478
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
479
|
+
remove(key: string): Promise<void>;
|
|
480
|
+
getKeys(): Promise<string[]>;
|
|
481
|
+
getInfo(key: string): Promise<{
|
|
482
|
+
size: number;
|
|
483
|
+
lastModified: number;
|
|
484
|
+
} | undefined>;
|
|
485
|
+
reset(): Promise<void>;
|
|
486
|
+
}
|
|
487
|
+
export declare class DiskCollectionRawBrowser {
|
|
488
|
+
private collectionName;
|
|
489
|
+
constructor(collectionName: string);
|
|
490
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
491
|
+
private synced;
|
|
492
|
+
get(key: string): Buffer | undefined;
|
|
493
|
+
getPromise(key: string): Promise<Buffer | undefined>;
|
|
494
|
+
set(key: string, value: Buffer): void;
|
|
495
|
+
getKeys(): Promise<string[]>;
|
|
496
|
+
getInfo(key: string): Promise<{
|
|
497
|
+
size: number;
|
|
498
|
+
lastModified: number;
|
|
499
|
+
} | undefined>;
|
|
500
|
+
reset(): Promise<void>;
|
|
501
|
+
}
|
|
502
|
+
export declare function newFileStorageBufferSyncer(folder?: string): StorageSync<Buffer>;
|
|
503
|
+
export declare function newFileStorageJSONSyncer<T>(folder?: string): StorageSync<T>;
|
|
504
|
+
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
declare module "sliftutils/storage/FileFolderAPI" {
|
|
508
|
+
/// <reference types="node" />
|
|
509
|
+
/// <reference types="node" />
|
|
510
|
+
import { IStorageRaw } from "./IStorage";
|
|
511
|
+
type FileWrapper = {
|
|
512
|
+
getFile(): Promise<{
|
|
513
|
+
size: number;
|
|
514
|
+
lastModified: number;
|
|
515
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
516
|
+
}>;
|
|
517
|
+
createWritable(config?: {
|
|
518
|
+
keepExistingData?: boolean;
|
|
519
|
+
}): Promise<{
|
|
520
|
+
seek(offset: number): Promise<void>;
|
|
521
|
+
write(value: Buffer): Promise<void>;
|
|
522
|
+
close(): Promise<void>;
|
|
523
|
+
}>;
|
|
524
|
+
};
|
|
525
|
+
type DirectoryWrapper = {
|
|
526
|
+
removeEntry(key: string, options?: {
|
|
527
|
+
recursive?: boolean;
|
|
528
|
+
}): Promise<void>;
|
|
529
|
+
getFileHandle(key: string, options?: {
|
|
530
|
+
create?: boolean;
|
|
531
|
+
}): Promise<FileWrapper>;
|
|
532
|
+
getDirectoryHandle(key: string, options?: {
|
|
533
|
+
create?: boolean;
|
|
534
|
+
}): Promise<DirectoryWrapper>;
|
|
535
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<[
|
|
536
|
+
string,
|
|
537
|
+
{
|
|
538
|
+
kind: "file";
|
|
539
|
+
name: string;
|
|
540
|
+
getFile(): Promise<FileWrapper>;
|
|
541
|
+
} | {
|
|
542
|
+
kind: "directory";
|
|
543
|
+
name: string;
|
|
544
|
+
getDirectoryHandle(key: string, options?: {
|
|
545
|
+
create?: boolean;
|
|
546
|
+
}): Promise<DirectoryWrapper>;
|
|
547
|
+
}
|
|
548
|
+
]>;
|
|
549
|
+
};
|
|
550
|
+
export declare const getDirectoryHandle: {
|
|
551
|
+
(): Promise<DirectoryWrapper>;
|
|
552
|
+
reset(): void;
|
|
553
|
+
set(newValue: Promise<DirectoryWrapper>): void;
|
|
554
|
+
};
|
|
555
|
+
export declare const getFileStorageNested: {
|
|
556
|
+
(key: string): Promise<FileStorage>;
|
|
557
|
+
clear(key: string): void;
|
|
558
|
+
clearAll(): void;
|
|
559
|
+
forceSet(key: string, value: Promise<FileStorage>): void;
|
|
560
|
+
getAllKeys(): string[];
|
|
561
|
+
get(key: string): Promise<FileStorage> | undefined;
|
|
562
|
+
};
|
|
563
|
+
export declare const getFileStorage: {
|
|
564
|
+
(): Promise<FileStorage>;
|
|
565
|
+
reset(): void;
|
|
566
|
+
set(newValue: Promise<FileStorage>): void;
|
|
567
|
+
};
|
|
568
|
+
export declare function resetStorageLocation(): void;
|
|
569
|
+
export type NestedFileStorage = {
|
|
570
|
+
hasKey(key: string): Promise<boolean>;
|
|
571
|
+
getStorage(key: string): Promise<FileStorage>;
|
|
572
|
+
removeStorage(key: string): Promise<void>;
|
|
573
|
+
getKeys(): Promise<string[]>;
|
|
574
|
+
};
|
|
575
|
+
export type FileStorage = IStorageRaw & {
|
|
576
|
+
folder: NestedFileStorage;
|
|
577
|
+
};
|
|
578
|
+
export {};
|
|
579
|
+
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
declare module "sliftutils/storage/IStorage" {
|
|
583
|
+
/// <reference types="node" />
|
|
584
|
+
/// <reference types="node" />
|
|
585
|
+
export type IStorageSync<T> = {
|
|
586
|
+
get(key: string): T | undefined;
|
|
587
|
+
set(key: string, value: T): void;
|
|
588
|
+
remove(key: string): void;
|
|
589
|
+
getKeys(): string[];
|
|
590
|
+
getValues(): T[];
|
|
591
|
+
getEntries(): [string, T][];
|
|
592
|
+
getInfo(key: string): {
|
|
593
|
+
size: number;
|
|
594
|
+
lastModified: number;
|
|
595
|
+
} | undefined;
|
|
596
|
+
reset(): Promise<void>;
|
|
597
|
+
};
|
|
598
|
+
export type IStorage<T> = {
|
|
599
|
+
get(key: string): Promise<T | undefined>;
|
|
600
|
+
set(key: string, value: T): Promise<void>;
|
|
601
|
+
remove(key: string): Promise<void>;
|
|
602
|
+
getKeys(): Promise<string[]>;
|
|
603
|
+
getInfo(key: string): Promise<undefined | {
|
|
604
|
+
size: number;
|
|
605
|
+
lastModified: number;
|
|
606
|
+
}>;
|
|
607
|
+
reset(): Promise<void>;
|
|
608
|
+
};
|
|
609
|
+
export type IStorageRaw = {
|
|
610
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
611
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
612
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
613
|
+
remove(key: string): Promise<void>;
|
|
614
|
+
getKeys(): Promise<string[]>;
|
|
615
|
+
getInfo(key: string): Promise<undefined | {
|
|
616
|
+
size: number;
|
|
617
|
+
lastModified: number;
|
|
618
|
+
}>;
|
|
619
|
+
reset(): Promise<void>;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
declare module "sliftutils/storage/IndexedDBFileFolderAPI" {
|
|
625
|
+
import { FileStorage } from "./FileFolderAPI";
|
|
626
|
+
export declare const getFileStorageIndexDB: {
|
|
627
|
+
(): Promise<FileStorage>;
|
|
628
|
+
reset(): void;
|
|
629
|
+
set(newValue: Promise<FileStorage>): void;
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
declare module "sliftutils/storage/JSONStorage" {
|
|
635
|
+
/// <reference types="node" />
|
|
636
|
+
/// <reference types="node" />
|
|
637
|
+
import { IStorage } from "./IStorage";
|
|
638
|
+
export declare class JSONStorage<T> implements IStorage<T> {
|
|
639
|
+
private storage;
|
|
640
|
+
constructor(storage: IStorage<Buffer>);
|
|
641
|
+
get(key: string): Promise<T | undefined>;
|
|
642
|
+
set(key: string, value: T): Promise<void>;
|
|
643
|
+
remove(key: string): Promise<void>;
|
|
644
|
+
getKeys(): Promise<string[]>;
|
|
645
|
+
getInfo(key: string): Promise<{
|
|
646
|
+
size: number;
|
|
647
|
+
lastModified: number;
|
|
648
|
+
} | undefined>;
|
|
649
|
+
reset(): Promise<void>;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
declare module "sliftutils/storage/PendingManager" {
|
|
655
|
+
import preact from "preact";
|
|
656
|
+
export declare function setPending(group: string, message: string): void;
|
|
657
|
+
export declare function hasPending(): boolean;
|
|
658
|
+
export declare class PendingDisplay extends preact.Component {
|
|
659
|
+
render(): preact.JSX.Element;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
declare module "sliftutils/storage/PendingStorage" {
|
|
665
|
+
import { IStorage } from "./IStorage";
|
|
666
|
+
export declare class PendingStorage<T> implements IStorage<T> {
|
|
667
|
+
private pendingGroup;
|
|
668
|
+
private storage;
|
|
669
|
+
pending: Map<string, number>;
|
|
670
|
+
constructor(pendingGroup: string, storage: IStorage<T>);
|
|
671
|
+
get(key: string): Promise<T | undefined>;
|
|
672
|
+
set(key: string, value: T): Promise<void>;
|
|
673
|
+
remove(key: string): Promise<void>;
|
|
674
|
+
getKeys(): Promise<string[]>;
|
|
675
|
+
getInfo(key: string): Promise<{
|
|
676
|
+
size: number;
|
|
677
|
+
lastModified: number;
|
|
678
|
+
} | undefined>;
|
|
679
|
+
private watchPending;
|
|
680
|
+
private updatePending;
|
|
681
|
+
reset(): Promise<void>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
declare module "sliftutils/storage/PrivateFileSystemStorage" {
|
|
687
|
+
/// <reference types="node" />
|
|
688
|
+
/// <reference types="node" />
|
|
689
|
+
import { IStorageRaw } from "./IStorage";
|
|
690
|
+
export declare class PrivateFileSystemStorage implements IStorageRaw {
|
|
691
|
+
private path;
|
|
692
|
+
private rootHandle;
|
|
693
|
+
constructor(path: string);
|
|
694
|
+
private ensureInitialized;
|
|
695
|
+
private directoryExists;
|
|
696
|
+
private getDirectoryHandle;
|
|
697
|
+
private getFileHandle;
|
|
698
|
+
private fileExists;
|
|
699
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
700
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
701
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
702
|
+
remove(key: string): Promise<void>;
|
|
703
|
+
getKeys(): Promise<string[]>;
|
|
704
|
+
getInfo(key: string): Promise<undefined | {
|
|
705
|
+
size: number;
|
|
706
|
+
lastModified: number;
|
|
707
|
+
}>;
|
|
708
|
+
reset(): Promise<void>;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
declare module "sliftutils/storage/StorageObservable" {
|
|
714
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
715
|
+
export declare class StorageSync<T> implements IStorageSync<T> {
|
|
716
|
+
storage: IStorage<T>;
|
|
717
|
+
cached: import("mobx").ObservableMap<string, T | undefined>;
|
|
718
|
+
infoCached: import("mobx").ObservableMap<string, {
|
|
719
|
+
size: number;
|
|
720
|
+
lastModified: number;
|
|
721
|
+
} | undefined>;
|
|
722
|
+
keys: Set<string>;
|
|
723
|
+
synced: {
|
|
724
|
+
keySeqNum: number;
|
|
725
|
+
};
|
|
726
|
+
constructor(storage: IStorage<T>);
|
|
727
|
+
get(key: string): T | undefined;
|
|
728
|
+
set(key: string, value: T): void;
|
|
729
|
+
remove(key: string): void;
|
|
730
|
+
private loadedKeys;
|
|
731
|
+
getKeys(): string[];
|
|
732
|
+
getInfo(key: string): {
|
|
733
|
+
size: number;
|
|
734
|
+
lastModified: number;
|
|
735
|
+
} | undefined;
|
|
736
|
+
getValues(): T[];
|
|
737
|
+
getEntries(): [string, T][];
|
|
738
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
739
|
+
private pendingGetKeys;
|
|
740
|
+
getKeysPromise(): Promise<string[]>;
|
|
741
|
+
reload(): void;
|
|
742
|
+
reloadKeys(): void;
|
|
743
|
+
reloadKey(key: string): void;
|
|
744
|
+
reset(): Promise<void>;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
declare module "sliftutils/storage/TransactionStorage" {
|
|
750
|
+
/// <reference types="node" />
|
|
751
|
+
/// <reference types="node" />
|
|
752
|
+
import { IStorage, IStorageRaw } from "./IStorage";
|
|
753
|
+
interface TransactionEntry {
|
|
754
|
+
key: string;
|
|
755
|
+
value: Buffer | undefined;
|
|
756
|
+
isZipped: boolean;
|
|
757
|
+
time: number;
|
|
758
|
+
}
|
|
759
|
+
export declare class TransactionStorage implements IStorage<Buffer> {
|
|
760
|
+
private rawStorage;
|
|
761
|
+
private debugName;
|
|
762
|
+
private writeDelay;
|
|
763
|
+
cache: Map<string, TransactionEntry>;
|
|
764
|
+
private currentChunk;
|
|
765
|
+
private currentChunkSize;
|
|
766
|
+
private entryCount;
|
|
767
|
+
private static allStorage;
|
|
768
|
+
constructor(rawStorage: IStorageRaw, debugName: string, writeDelay?: number);
|
|
769
|
+
static compressAll(): Promise<void>;
|
|
770
|
+
private init;
|
|
771
|
+
private getChunk;
|
|
772
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
773
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
774
|
+
remove(key: string): Promise<void>;
|
|
775
|
+
getInfo(key: string): Promise<{
|
|
776
|
+
size: number;
|
|
777
|
+
lastModified: number;
|
|
778
|
+
} | undefined>;
|
|
779
|
+
private pendingAppends;
|
|
780
|
+
private extraAppends;
|
|
781
|
+
private pendingWrite;
|
|
782
|
+
pushAppend(entry: TransactionEntry): Promise<void>;
|
|
783
|
+
private updatePendingAppends;
|
|
784
|
+
getKeys(): Promise<string[]>;
|
|
785
|
+
private loadAllTransactions;
|
|
786
|
+
private loadTransactionFile;
|
|
787
|
+
private readTransactionEntry;
|
|
788
|
+
private serializeTransactionEntry;
|
|
789
|
+
private getHeader;
|
|
790
|
+
private chunkBuffers;
|
|
791
|
+
private compressing;
|
|
792
|
+
private compressTransactionLog;
|
|
793
|
+
reset(): Promise<void>;
|
|
794
|
+
}
|
|
795
|
+
export {};
|
|
796
|
+
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
declare module "sliftutils/storage/fileSystemPointer" {
|
|
800
|
+
export type FileSystemPointer = string;
|
|
801
|
+
export declare function storeFileSystemPointer(config: {
|
|
802
|
+
mode: "read" | "readwrite";
|
|
803
|
+
handle: FileSystemFileHandle | FileSystemDirectoryHandle;
|
|
804
|
+
}): Promise<FileSystemPointer>;
|
|
805
|
+
export declare function deleteFileSystemPointer(pointer: FileSystemPointer): Promise<void>;
|
|
806
|
+
export declare function getFileSystemPointer(config: {
|
|
807
|
+
pointer: FileSystemPointer;
|
|
808
|
+
}): Promise<{
|
|
809
|
+
onUserActivation(modeOverride?: "read" | "readwrite"): Promise<FileSystemFileHandle | FileSystemDirectoryHandle>;
|
|
810
|
+
} | undefined>;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
declare module "sliftutils/storage/storage" {
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
declare module "node-forge" {
|
|
818
|
+
declare type Ed25519PublicKey = {
|
|
819
|
+
publicKeyBytes: Buffer;
|
|
820
|
+
} & Buffer;
|
|
821
|
+
declare type Ed25519PrivateKey = {
|
|
822
|
+
privateKeyBytes: Buffer;
|
|
823
|
+
} & Buffer;
|
|
824
|
+
class ed25519 {
|
|
825
|
+
static generateKeyPair(): { publicKey: Ed25519PublicKey, privateKey: Ed25519PrivateKey };
|
|
826
|
+
static privateKeyToPem(key: Ed25519PrivateKey): string;
|
|
827
|
+
static privateKeyFromPem(pem: string): Ed25519PrivateKey;
|
|
828
|
+
static publicKeyToPem(key: Ed25519PublicKey): string;
|
|
829
|
+
static publicKeyFromPem(pem: string): Ed25519PublicKey;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
interface FileSystemDirectoryHandle {
|
|
835
|
+
[Symbol.asyncIterator](): AsyncIterator<[string, FileSystemFileHandle | FileSystemDirectoryHandle]>;
|
|
836
|
+
requestPermission(config: { mode: "read" | "readwrite" }): Promise<void>;
|
|
837
|
+
}
|
|
838
|
+
interface FileSystemFileHandle {
|
|
839
|
+
getFile(): File;
|
|
840
|
+
createWritable(): FileSystemWritableFileStream;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
interface Window {
|
|
844
|
+
showSaveFilePicker(config?: {
|
|
845
|
+
types: {
|
|
846
|
+
description: string; accept: { [mimeType: string]: string[] }
|
|
847
|
+
}[];
|
|
848
|
+
}): Promise<FileSystemFileHandle>;
|
|
849
|
+
showDirectoryPicker(): Promise<FileSystemDirectoryHandle>;
|
|
850
|
+
showOpenFilePicker(config?: {
|
|
851
|
+
types: {
|
|
852
|
+
description: string; accept: { [mimeType: string]: string[] }
|
|
853
|
+
}[];
|
|
854
|
+
}): Promise<FileSystemFileHandle[]>;
|
|
855
|
+
}
|
|
856
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IStorage } from "./IStorage";
|
|
2
|
+
export declare class DelayedStorage<T> implements IStorage<T> {
|
|
3
|
+
private storage;
|
|
4
|
+
constructor(storage: Promise<IStorage<T>>);
|
|
5
|
+
get(key: string): Promise<T | undefined>;
|
|
6
|
+
set(key: string, value: T): Promise<void>;
|
|
7
|
+
remove(key: string): Promise<void>;
|
|
8
|
+
getKeys(): Promise<string[]>;
|
|
9
|
+
getInfo(key: string): Promise<{
|
|
10
|
+
size: number;
|
|
11
|
+
lastModified: number;
|
|
12
|
+
} | undefined>;
|
|
13
|
+
reset(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
4
|
+
import { StorageSync } from "./StorageObservable";
|
|
5
|
+
import { TransactionStorage } from "./TransactionStorage";
|
|
6
|
+
export declare class DiskCollection<T> implements IStorageSync<T> {
|
|
7
|
+
private collectionName;
|
|
8
|
+
private writeDelay?;
|
|
9
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
10
|
+
transactionStorage: TransactionStorage | undefined;
|
|
11
|
+
initStorage(): Promise<IStorage<T>>;
|
|
12
|
+
baseStorage: Promise<IStorage<T>>;
|
|
13
|
+
private synced;
|
|
14
|
+
get(key: string): T | undefined;
|
|
15
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
16
|
+
set(key: string, value: T): void;
|
|
17
|
+
remove(key: string): void;
|
|
18
|
+
getKeys(): string[];
|
|
19
|
+
getKeysPromise(): Promise<string[]>;
|
|
20
|
+
getEntries(): [string, T][];
|
|
21
|
+
getValues(): T[];
|
|
22
|
+
getValuesPromise(): Promise<T[]>;
|
|
23
|
+
getInfo(key: string): {
|
|
24
|
+
size: number;
|
|
25
|
+
lastModified: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
reset(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare class DiskCollectionBrowser<T> implements IStorageSync<T> {
|
|
30
|
+
private collectionName;
|
|
31
|
+
private writeDelay?;
|
|
32
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
33
|
+
transactionStorage: TransactionStorage | undefined;
|
|
34
|
+
initStorage(): Promise<IStorage<T>>;
|
|
35
|
+
baseStorage: Promise<IStorage<T>>;
|
|
36
|
+
private synced;
|
|
37
|
+
get(key: string): T | undefined;
|
|
38
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
39
|
+
set(key: string, value: T): void;
|
|
40
|
+
remove(key: string): void;
|
|
41
|
+
getKeys(): string[];
|
|
42
|
+
getKeysPromise(): Promise<string[]>;
|
|
43
|
+
getEntries(): [string, T][];
|
|
44
|
+
getValues(): T[];
|
|
45
|
+
getValuesPromise(): Promise<T[]>;
|
|
46
|
+
getInfo(key: string): {
|
|
47
|
+
size: number;
|
|
48
|
+
lastModified: number;
|
|
49
|
+
} | undefined;
|
|
50
|
+
reset(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare class DiskCollectionPromise<T> implements IStorage<T> {
|
|
53
|
+
private collectionName;
|
|
54
|
+
private writeDelay?;
|
|
55
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
56
|
+
initStorage(): Promise<IStorage<T>>;
|
|
57
|
+
private synced;
|
|
58
|
+
get(key: string): Promise<T | undefined>;
|
|
59
|
+
set(key: string, value: T): Promise<void>;
|
|
60
|
+
remove(key: string): Promise<void>;
|
|
61
|
+
getKeys(): Promise<string[]>;
|
|
62
|
+
getInfo(key: string): Promise<{
|
|
63
|
+
size: number;
|
|
64
|
+
lastModified: number;
|
|
65
|
+
} | undefined>;
|
|
66
|
+
reset(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export declare class DiskCollectionRaw implements IStorage<Buffer> {
|
|
69
|
+
private collectionName;
|
|
70
|
+
constructor(collectionName: string);
|
|
71
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
72
|
+
private synced;
|
|
73
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
74
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
75
|
+
remove(key: string): Promise<void>;
|
|
76
|
+
getKeys(): Promise<string[]>;
|
|
77
|
+
getInfo(key: string): Promise<{
|
|
78
|
+
size: number;
|
|
79
|
+
lastModified: number;
|
|
80
|
+
} | undefined>;
|
|
81
|
+
reset(): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
export declare class DiskCollectionRawBrowser {
|
|
84
|
+
private collectionName;
|
|
85
|
+
constructor(collectionName: string);
|
|
86
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
87
|
+
private synced;
|
|
88
|
+
get(key: string): Buffer | undefined;
|
|
89
|
+
getPromise(key: string): Promise<Buffer | undefined>;
|
|
90
|
+
set(key: string, value: Buffer): void;
|
|
91
|
+
getKeys(): Promise<string[]>;
|
|
92
|
+
getInfo(key: string): Promise<{
|
|
93
|
+
size: number;
|
|
94
|
+
lastModified: number;
|
|
95
|
+
} | undefined>;
|
|
96
|
+
reset(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export declare function newFileStorageBufferSyncer(folder?: string): StorageSync<Buffer>;
|
|
99
|
+
export declare function newFileStorageJSONSyncer<T>(folder?: string): StorageSync<T>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IStorageRaw } from "./IStorage";
|
|
4
|
+
type FileWrapper = {
|
|
5
|
+
getFile(): Promise<{
|
|
6
|
+
size: number;
|
|
7
|
+
lastModified: number;
|
|
8
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
9
|
+
}>;
|
|
10
|
+
createWritable(config?: {
|
|
11
|
+
keepExistingData?: boolean;
|
|
12
|
+
}): Promise<{
|
|
13
|
+
seek(offset: number): Promise<void>;
|
|
14
|
+
write(value: Buffer): Promise<void>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
type DirectoryWrapper = {
|
|
19
|
+
removeEntry(key: string, options?: {
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
getFileHandle(key: string, options?: {
|
|
23
|
+
create?: boolean;
|
|
24
|
+
}): Promise<FileWrapper>;
|
|
25
|
+
getDirectoryHandle(key: string, options?: {
|
|
26
|
+
create?: boolean;
|
|
27
|
+
}): Promise<DirectoryWrapper>;
|
|
28
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<[
|
|
29
|
+
string,
|
|
30
|
+
{
|
|
31
|
+
kind: "file";
|
|
32
|
+
name: string;
|
|
33
|
+
getFile(): Promise<FileWrapper>;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "directory";
|
|
36
|
+
name: string;
|
|
37
|
+
getDirectoryHandle(key: string, options?: {
|
|
38
|
+
create?: boolean;
|
|
39
|
+
}): Promise<DirectoryWrapper>;
|
|
40
|
+
}
|
|
41
|
+
]>;
|
|
42
|
+
};
|
|
43
|
+
export declare const getDirectoryHandle: {
|
|
44
|
+
(): Promise<DirectoryWrapper>;
|
|
45
|
+
reset(): void;
|
|
46
|
+
set(newValue: Promise<DirectoryWrapper>): void;
|
|
47
|
+
};
|
|
48
|
+
export declare const getFileStorageNested: {
|
|
49
|
+
(key: string): Promise<FileStorage>;
|
|
50
|
+
clear(key: string): void;
|
|
51
|
+
clearAll(): void;
|
|
52
|
+
forceSet(key: string, value: Promise<FileStorage>): void;
|
|
53
|
+
getAllKeys(): string[];
|
|
54
|
+
get(key: string): Promise<FileStorage> | undefined;
|
|
55
|
+
};
|
|
56
|
+
export declare const getFileStorage: {
|
|
57
|
+
(): Promise<FileStorage>;
|
|
58
|
+
reset(): void;
|
|
59
|
+
set(newValue: Promise<FileStorage>): void;
|
|
60
|
+
};
|
|
61
|
+
export declare function resetStorageLocation(): void;
|
|
62
|
+
export type NestedFileStorage = {
|
|
63
|
+
hasKey(key: string): Promise<boolean>;
|
|
64
|
+
getStorage(key: string): Promise<FileStorage>;
|
|
65
|
+
removeStorage(key: string): Promise<void>;
|
|
66
|
+
getKeys(): Promise<string[]>;
|
|
67
|
+
};
|
|
68
|
+
export type FileStorage = IStorageRaw & {
|
|
69
|
+
folder: NestedFileStorage;
|
|
70
|
+
};
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export type IStorageSync<T> = {
|
|
4
|
+
get(key: string): T | undefined;
|
|
5
|
+
set(key: string, value: T): void;
|
|
6
|
+
remove(key: string): void;
|
|
7
|
+
getKeys(): string[];
|
|
8
|
+
getValues(): T[];
|
|
9
|
+
getEntries(): [string, T][];
|
|
10
|
+
getInfo(key: string): {
|
|
11
|
+
size: number;
|
|
12
|
+
lastModified: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
reset(): Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export type IStorage<T> = {
|
|
17
|
+
get(key: string): Promise<T | undefined>;
|
|
18
|
+
set(key: string, value: T): Promise<void>;
|
|
19
|
+
remove(key: string): Promise<void>;
|
|
20
|
+
getKeys(): Promise<string[]>;
|
|
21
|
+
getInfo(key: string): Promise<undefined | {
|
|
22
|
+
size: number;
|
|
23
|
+
lastModified: number;
|
|
24
|
+
}>;
|
|
25
|
+
reset(): Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
export type IStorageRaw = {
|
|
28
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
29
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
30
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
31
|
+
remove(key: string): Promise<void>;
|
|
32
|
+
getKeys(): Promise<string[]>;
|
|
33
|
+
getInfo(key: string): Promise<undefined | {
|
|
34
|
+
size: number;
|
|
35
|
+
lastModified: number;
|
|
36
|
+
}>;
|
|
37
|
+
reset(): Promise<void>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IStorage } from "./IStorage";
|
|
4
|
+
export declare class JSONStorage<T> implements IStorage<T> {
|
|
5
|
+
private storage;
|
|
6
|
+
constructor(storage: IStorage<Buffer>);
|
|
7
|
+
get(key: string): Promise<T | undefined>;
|
|
8
|
+
set(key: string, value: T): Promise<void>;
|
|
9
|
+
remove(key: string): Promise<void>;
|
|
10
|
+
getKeys(): Promise<string[]>;
|
|
11
|
+
getInfo(key: string): Promise<{
|
|
12
|
+
size: number;
|
|
13
|
+
lastModified: number;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
reset(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IStorage } from "./IStorage";
|
|
2
|
+
export declare class PendingStorage<T> implements IStorage<T> {
|
|
3
|
+
private pendingGroup;
|
|
4
|
+
private storage;
|
|
5
|
+
pending: Map<string, number>;
|
|
6
|
+
constructor(pendingGroup: string, storage: IStorage<T>);
|
|
7
|
+
get(key: string): Promise<T | undefined>;
|
|
8
|
+
set(key: string, value: T): Promise<void>;
|
|
9
|
+
remove(key: string): Promise<void>;
|
|
10
|
+
getKeys(): Promise<string[]>;
|
|
11
|
+
getInfo(key: string): Promise<{
|
|
12
|
+
size: number;
|
|
13
|
+
lastModified: number;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
private watchPending;
|
|
16
|
+
private updatePending;
|
|
17
|
+
reset(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IStorageRaw } from "./IStorage";
|
|
4
|
+
export declare class PrivateFileSystemStorage implements IStorageRaw {
|
|
5
|
+
private path;
|
|
6
|
+
private rootHandle;
|
|
7
|
+
constructor(path: string);
|
|
8
|
+
private ensureInitialized;
|
|
9
|
+
private directoryExists;
|
|
10
|
+
private getDirectoryHandle;
|
|
11
|
+
private getFileHandle;
|
|
12
|
+
private fileExists;
|
|
13
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
14
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
15
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
16
|
+
remove(key: string): Promise<void>;
|
|
17
|
+
getKeys(): Promise<string[]>;
|
|
18
|
+
getInfo(key: string): Promise<undefined | {
|
|
19
|
+
size: number;
|
|
20
|
+
lastModified: number;
|
|
21
|
+
}>;
|
|
22
|
+
reset(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
2
|
+
export declare class StorageSync<T> implements IStorageSync<T> {
|
|
3
|
+
storage: IStorage<T>;
|
|
4
|
+
cached: import("mobx").ObservableMap<string, T | undefined>;
|
|
5
|
+
infoCached: import("mobx").ObservableMap<string, {
|
|
6
|
+
size: number;
|
|
7
|
+
lastModified: number;
|
|
8
|
+
} | undefined>;
|
|
9
|
+
keys: Set<string>;
|
|
10
|
+
synced: {
|
|
11
|
+
keySeqNum: number;
|
|
12
|
+
};
|
|
13
|
+
constructor(storage: IStorage<T>);
|
|
14
|
+
get(key: string): T | undefined;
|
|
15
|
+
set(key: string, value: T): void;
|
|
16
|
+
remove(key: string): void;
|
|
17
|
+
private loadedKeys;
|
|
18
|
+
getKeys(): string[];
|
|
19
|
+
getInfo(key: string): {
|
|
20
|
+
size: number;
|
|
21
|
+
lastModified: number;
|
|
22
|
+
} | undefined;
|
|
23
|
+
getValues(): T[];
|
|
24
|
+
getEntries(): [string, T][];
|
|
25
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
26
|
+
private pendingGetKeys;
|
|
27
|
+
getKeysPromise(): Promise<string[]>;
|
|
28
|
+
reload(): void;
|
|
29
|
+
reloadKeys(): void;
|
|
30
|
+
reloadKey(key: string): void;
|
|
31
|
+
reset(): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { IStorage, IStorageRaw } from "./IStorage";
|
|
4
|
+
interface TransactionEntry {
|
|
5
|
+
key: string;
|
|
6
|
+
value: Buffer | undefined;
|
|
7
|
+
isZipped: boolean;
|
|
8
|
+
time: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class TransactionStorage implements IStorage<Buffer> {
|
|
11
|
+
private rawStorage;
|
|
12
|
+
private debugName;
|
|
13
|
+
private writeDelay;
|
|
14
|
+
cache: Map<string, TransactionEntry>;
|
|
15
|
+
private currentChunk;
|
|
16
|
+
private currentChunkSize;
|
|
17
|
+
private entryCount;
|
|
18
|
+
private static allStorage;
|
|
19
|
+
constructor(rawStorage: IStorageRaw, debugName: string, writeDelay?: number);
|
|
20
|
+
static compressAll(): Promise<void>;
|
|
21
|
+
private init;
|
|
22
|
+
private getChunk;
|
|
23
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
24
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
25
|
+
remove(key: string): Promise<void>;
|
|
26
|
+
getInfo(key: string): Promise<{
|
|
27
|
+
size: number;
|
|
28
|
+
lastModified: number;
|
|
29
|
+
} | undefined>;
|
|
30
|
+
private pendingAppends;
|
|
31
|
+
private extraAppends;
|
|
32
|
+
private pendingWrite;
|
|
33
|
+
pushAppend(entry: TransactionEntry): Promise<void>;
|
|
34
|
+
private updatePendingAppends;
|
|
35
|
+
getKeys(): Promise<string[]>;
|
|
36
|
+
private loadAllTransactions;
|
|
37
|
+
private loadTransactionFile;
|
|
38
|
+
private readTransactionEntry;
|
|
39
|
+
private serializeTransactionEntry;
|
|
40
|
+
private getHeader;
|
|
41
|
+
private chunkBuffers;
|
|
42
|
+
private compressing;
|
|
43
|
+
private compressTransactionLog;
|
|
44
|
+
reset(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type FileSystemPointer = string;
|
|
2
|
+
export declare function storeFileSystemPointer(config: {
|
|
3
|
+
mode: "read" | "readwrite";
|
|
4
|
+
handle: FileSystemFileHandle | FileSystemDirectoryHandle;
|
|
5
|
+
}): Promise<FileSystemPointer>;
|
|
6
|
+
export declare function deleteFileSystemPointer(pointer: FileSystemPointer): Promise<void>;
|
|
7
|
+
export declare function getFileSystemPointer(config: {
|
|
8
|
+
pointer: FileSystemPointer;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
onUserActivation(modeOverride?: "read" | "readwrite"): Promise<FileSystemFileHandle | FileSystemDirectoryHandle>;
|
|
11
|
+
} | undefined>;
|