sliftutils 0.11.0 → 0.13.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/.gitignore +2 -1
- package/builders/dist/generateIndexDts.ts.cache +3 -3
- package/builders/generateIndexDts.ts +1 -1
- package/index.d.ts +503 -12
- package/package.json +2 -1
- package/render-utils/Anchor.tsx +62 -0
- package/render-utils/URLParam.d.ts +16 -12
- package/render-utils/URLParam.ts +74 -57
- package/render-utils/niceStringify.d.ts +5 -0
- package/render-utils/niceStringify.ts +83 -0
- 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
- package/web/browser.tsx +3 -0
package/.gitignore
CHANGED
|
@@ -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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gICAgICBjb25zdCBkdHNGaWxlcyA9IGdldEFsbER0c0ZpbGVzKGZvbGRlclBhdGgpO1xuXG4gICAgICAgIGNvbnN0IG1vZHVsZXMgPSBkdHNGaWxlc1xuICAgICAgICAgICAgLm1hcChmaWxlUGF0aCA9PiB7XG4gICAgICAgICAgICAgICAgY29uc3QgcmVsYXRpdmVQYXRoID0gcGF0aC5yZWxhdGl2ZShmb2xkZXJQYXRoLCBmaWxlUGF0aCk7XG4gICAgICAgICAgICAgICAgY29uc3Qgd2l0aG91dEV4dCA9IHJlbGF0aXZlUGF0aC5yZXBsYWNlKC9cXC5kXFwudHMkLywgXCJcIik7XG4gICAgICAgICAgICAgICAgY29uc3QgbW9kdWxlUGF0aCA9IFwic2xpZnR1dGlscy9cIiArIGZvbGRlck5hbWUgKyBcIi9cIiArIHdpdGhvdXRFeHQucmVwbGFjZSgvXFxcXC9nLCBcIi9cIik7XG5cbiAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50ID0gZnMucmVhZEZpbGVTeW5jKGZpbGVQYXRoLCBcInV0ZjhcIik7XG4gICAgICAgICAgICAgICAgY29uc3QgaW5kZW50ZWRDb250ZW50ID0gY29udGVudFxuICAgICAgICAgICAgICAgICAgICAuc3BsaXQoXCJcXG5cIilcbiAgICAgICAgICAgICAgICAgICAgLm1hcChsaW5lID0+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
|
@@ -318,19 +318,23 @@ declare module "sliftutils/render-utils/Table" {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
declare module "sliftutils/render-utils/URLParam" {
|
|
321
|
-
export declare class
|
|
322
|
-
readonly
|
|
323
|
-
private
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
321
|
+
export declare class URLParam<T = unknown> {
|
|
322
|
+
readonly key: string;
|
|
323
|
+
private defaultValue;
|
|
324
|
+
constructor(key: string, defaultValue?: T);
|
|
325
|
+
valueSeqNum: {
|
|
326
|
+
value: number;
|
|
327
|
+
};
|
|
328
|
+
get(): T;
|
|
329
|
+
set(value: T): void;
|
|
330
|
+
reset(): void;
|
|
331
|
+
getOverride(value: T): [string, string];
|
|
332
|
+
get value(): T;
|
|
333
|
+
set value(value: T);
|
|
331
334
|
}
|
|
332
|
-
export declare function
|
|
333
|
-
export declare function
|
|
335
|
+
export declare function getResolvedParam(param: [URLParam, unknown] | [string, string]): [string, string];
|
|
336
|
+
export declare function batchURLParamUpdate(params: ([URLParam, unknown] | [string, string])[]): void;
|
|
337
|
+
export declare function getCurrentUrl(): string;
|
|
334
338
|
|
|
335
339
|
}
|
|
336
340
|
|
|
@@ -356,6 +360,15 @@ declare module "sliftutils/render-utils/modal" {
|
|
|
356
360
|
|
|
357
361
|
}
|
|
358
362
|
|
|
363
|
+
declare module "sliftutils/render-utils/niceStringify" {
|
|
364
|
+
export declare const niceStringifyTrue = "";
|
|
365
|
+
export declare const niceStringifyNan = "{NaN}";
|
|
366
|
+
export declare const niceStringifyUndefined = "{Undefined}";
|
|
367
|
+
export declare function niceStringify(value: unknown): string;
|
|
368
|
+
export declare function niceParse(str: string | undefined, noSpecialTrue?: boolean): unknown;
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
359
372
|
declare module "sliftutils/render-utils/observer" {
|
|
360
373
|
import * as preact from "preact";
|
|
361
374
|
import { Reaction } from "mobx";
|
|
@@ -376,3 +389,481 @@ declare module "sliftutils/render-utils/observer" {
|
|
|
376
389
|
} & T;
|
|
377
390
|
|
|
378
391
|
}
|
|
392
|
+
|
|
393
|
+
declare module "sliftutils/storage/CachedStorage" {
|
|
394
|
+
import { StorageSync } from "./StorageObservable";
|
|
395
|
+
export declare function newCachedStrStorage<T>(folder: string, getValue: (key: string) => Promise<T>): StorageSync<T>;
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare module "sliftutils/storage/DelayedStorage" {
|
|
400
|
+
import { IStorage } from "./IStorage";
|
|
401
|
+
export declare class DelayedStorage<T> implements IStorage<T> {
|
|
402
|
+
private storage;
|
|
403
|
+
constructor(storage: Promise<IStorage<T>>);
|
|
404
|
+
get(key: string): Promise<T | undefined>;
|
|
405
|
+
set(key: string, value: T): Promise<void>;
|
|
406
|
+
remove(key: string): Promise<void>;
|
|
407
|
+
getKeys(): Promise<string[]>;
|
|
408
|
+
getInfo(key: string): Promise<{
|
|
409
|
+
size: number;
|
|
410
|
+
lastModified: number;
|
|
411
|
+
} | undefined>;
|
|
412
|
+
reset(): Promise<void>;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
declare module "sliftutils/storage/DiskCollection" {
|
|
418
|
+
/// <reference types="node" />
|
|
419
|
+
/// <reference types="node" />
|
|
420
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
421
|
+
import { StorageSync } from "./StorageObservable";
|
|
422
|
+
import { TransactionStorage } from "./TransactionStorage";
|
|
423
|
+
export declare class DiskCollection<T> implements IStorageSync<T> {
|
|
424
|
+
private collectionName;
|
|
425
|
+
private writeDelay?;
|
|
426
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
427
|
+
transactionStorage: TransactionStorage | undefined;
|
|
428
|
+
initStorage(): Promise<IStorage<T>>;
|
|
429
|
+
baseStorage: Promise<IStorage<T>>;
|
|
430
|
+
private synced;
|
|
431
|
+
get(key: string): T | undefined;
|
|
432
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
433
|
+
set(key: string, value: T): void;
|
|
434
|
+
remove(key: string): void;
|
|
435
|
+
getKeys(): string[];
|
|
436
|
+
getKeysPromise(): Promise<string[]>;
|
|
437
|
+
getEntries(): [string, T][];
|
|
438
|
+
getValues(): T[];
|
|
439
|
+
getValuesPromise(): Promise<T[]>;
|
|
440
|
+
getInfo(key: string): {
|
|
441
|
+
size: number;
|
|
442
|
+
lastModified: number;
|
|
443
|
+
} | undefined;
|
|
444
|
+
reset(): Promise<void>;
|
|
445
|
+
}
|
|
446
|
+
export declare class DiskCollectionBrowser<T> implements IStorageSync<T> {
|
|
447
|
+
private collectionName;
|
|
448
|
+
private writeDelay?;
|
|
449
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
450
|
+
transactionStorage: TransactionStorage | undefined;
|
|
451
|
+
initStorage(): Promise<IStorage<T>>;
|
|
452
|
+
baseStorage: Promise<IStorage<T>>;
|
|
453
|
+
private synced;
|
|
454
|
+
get(key: string): T | undefined;
|
|
455
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
456
|
+
set(key: string, value: T): void;
|
|
457
|
+
remove(key: string): void;
|
|
458
|
+
getKeys(): string[];
|
|
459
|
+
getKeysPromise(): Promise<string[]>;
|
|
460
|
+
getEntries(): [string, T][];
|
|
461
|
+
getValues(): T[];
|
|
462
|
+
getValuesPromise(): Promise<T[]>;
|
|
463
|
+
getInfo(key: string): {
|
|
464
|
+
size: number;
|
|
465
|
+
lastModified: number;
|
|
466
|
+
} | undefined;
|
|
467
|
+
reset(): Promise<void>;
|
|
468
|
+
}
|
|
469
|
+
export declare class DiskCollectionPromise<T> implements IStorage<T> {
|
|
470
|
+
private collectionName;
|
|
471
|
+
private writeDelay?;
|
|
472
|
+
constructor(collectionName: string, writeDelay?: number | undefined);
|
|
473
|
+
initStorage(): Promise<IStorage<T>>;
|
|
474
|
+
private synced;
|
|
475
|
+
get(key: string): Promise<T | undefined>;
|
|
476
|
+
set(key: string, value: T): Promise<void>;
|
|
477
|
+
remove(key: string): Promise<void>;
|
|
478
|
+
getKeys(): Promise<string[]>;
|
|
479
|
+
getInfo(key: string): Promise<{
|
|
480
|
+
size: number;
|
|
481
|
+
lastModified: number;
|
|
482
|
+
} | undefined>;
|
|
483
|
+
reset(): Promise<void>;
|
|
484
|
+
}
|
|
485
|
+
export declare class DiskCollectionRaw implements IStorage<Buffer> {
|
|
486
|
+
private collectionName;
|
|
487
|
+
constructor(collectionName: string);
|
|
488
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
489
|
+
private synced;
|
|
490
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
491
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
492
|
+
remove(key: string): Promise<void>;
|
|
493
|
+
getKeys(): Promise<string[]>;
|
|
494
|
+
getInfo(key: string): Promise<{
|
|
495
|
+
size: number;
|
|
496
|
+
lastModified: number;
|
|
497
|
+
} | undefined>;
|
|
498
|
+
reset(): Promise<void>;
|
|
499
|
+
}
|
|
500
|
+
export declare class DiskCollectionRawBrowser {
|
|
501
|
+
private collectionName;
|
|
502
|
+
constructor(collectionName: string);
|
|
503
|
+
initStorage(): Promise<IStorage<Buffer>>;
|
|
504
|
+
private synced;
|
|
505
|
+
get(key: string): Buffer | undefined;
|
|
506
|
+
getPromise(key: string): Promise<Buffer | undefined>;
|
|
507
|
+
set(key: string, value: Buffer): void;
|
|
508
|
+
getKeys(): Promise<string[]>;
|
|
509
|
+
getInfo(key: string): Promise<{
|
|
510
|
+
size: number;
|
|
511
|
+
lastModified: number;
|
|
512
|
+
} | undefined>;
|
|
513
|
+
reset(): Promise<void>;
|
|
514
|
+
}
|
|
515
|
+
export declare function newFileStorageBufferSyncer(folder?: string): StorageSync<Buffer>;
|
|
516
|
+
export declare function newFileStorageJSONSyncer<T>(folder?: string): StorageSync<T>;
|
|
517
|
+
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
declare module "sliftutils/storage/FileFolderAPI" {
|
|
521
|
+
/// <reference types="node" />
|
|
522
|
+
/// <reference types="node" />
|
|
523
|
+
import { IStorageRaw } from "./IStorage";
|
|
524
|
+
type FileWrapper = {
|
|
525
|
+
getFile(): Promise<{
|
|
526
|
+
size: number;
|
|
527
|
+
lastModified: number;
|
|
528
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
529
|
+
}>;
|
|
530
|
+
createWritable(config?: {
|
|
531
|
+
keepExistingData?: boolean;
|
|
532
|
+
}): Promise<{
|
|
533
|
+
seek(offset: number): Promise<void>;
|
|
534
|
+
write(value: Buffer): Promise<void>;
|
|
535
|
+
close(): Promise<void>;
|
|
536
|
+
}>;
|
|
537
|
+
};
|
|
538
|
+
type DirectoryWrapper = {
|
|
539
|
+
removeEntry(key: string, options?: {
|
|
540
|
+
recursive?: boolean;
|
|
541
|
+
}): Promise<void>;
|
|
542
|
+
getFileHandle(key: string, options?: {
|
|
543
|
+
create?: boolean;
|
|
544
|
+
}): Promise<FileWrapper>;
|
|
545
|
+
getDirectoryHandle(key: string, options?: {
|
|
546
|
+
create?: boolean;
|
|
547
|
+
}): Promise<DirectoryWrapper>;
|
|
548
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<[
|
|
549
|
+
string,
|
|
550
|
+
{
|
|
551
|
+
kind: "file";
|
|
552
|
+
name: string;
|
|
553
|
+
getFile(): Promise<FileWrapper>;
|
|
554
|
+
} | {
|
|
555
|
+
kind: "directory";
|
|
556
|
+
name: string;
|
|
557
|
+
getDirectoryHandle(key: string, options?: {
|
|
558
|
+
create?: boolean;
|
|
559
|
+
}): Promise<DirectoryWrapper>;
|
|
560
|
+
}
|
|
561
|
+
]>;
|
|
562
|
+
};
|
|
563
|
+
export declare const getDirectoryHandle: {
|
|
564
|
+
(): Promise<DirectoryWrapper>;
|
|
565
|
+
reset(): void;
|
|
566
|
+
set(newValue: Promise<DirectoryWrapper>): void;
|
|
567
|
+
};
|
|
568
|
+
export declare const getFileStorageNested: {
|
|
569
|
+
(key: string): Promise<FileStorage>;
|
|
570
|
+
clear(key: string): void;
|
|
571
|
+
clearAll(): void;
|
|
572
|
+
forceSet(key: string, value: Promise<FileStorage>): void;
|
|
573
|
+
getAllKeys(): string[];
|
|
574
|
+
get(key: string): Promise<FileStorage> | undefined;
|
|
575
|
+
};
|
|
576
|
+
export declare const getFileStorage: {
|
|
577
|
+
(): Promise<FileStorage>;
|
|
578
|
+
reset(): void;
|
|
579
|
+
set(newValue: Promise<FileStorage>): void;
|
|
580
|
+
};
|
|
581
|
+
export declare function resetStorageLocation(): void;
|
|
582
|
+
export type NestedFileStorage = {
|
|
583
|
+
hasKey(key: string): Promise<boolean>;
|
|
584
|
+
getStorage(key: string): Promise<FileStorage>;
|
|
585
|
+
removeStorage(key: string): Promise<void>;
|
|
586
|
+
getKeys(): Promise<string[]>;
|
|
587
|
+
};
|
|
588
|
+
export type FileStorage = IStorageRaw & {
|
|
589
|
+
folder: NestedFileStorage;
|
|
590
|
+
};
|
|
591
|
+
export {};
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
declare module "sliftutils/storage/IStorage" {
|
|
596
|
+
/// <reference types="node" />
|
|
597
|
+
/// <reference types="node" />
|
|
598
|
+
export type IStorageSync<T> = {
|
|
599
|
+
get(key: string): T | undefined;
|
|
600
|
+
set(key: string, value: T): void;
|
|
601
|
+
remove(key: string): void;
|
|
602
|
+
getKeys(): string[];
|
|
603
|
+
getValues(): T[];
|
|
604
|
+
getEntries(): [string, T][];
|
|
605
|
+
getInfo(key: string): {
|
|
606
|
+
size: number;
|
|
607
|
+
lastModified: number;
|
|
608
|
+
} | undefined;
|
|
609
|
+
reset(): Promise<void>;
|
|
610
|
+
};
|
|
611
|
+
export type IStorage<T> = {
|
|
612
|
+
get(key: string): Promise<T | undefined>;
|
|
613
|
+
set(key: string, value: T): Promise<void>;
|
|
614
|
+
remove(key: string): Promise<void>;
|
|
615
|
+
getKeys(): Promise<string[]>;
|
|
616
|
+
getInfo(key: string): Promise<undefined | {
|
|
617
|
+
size: number;
|
|
618
|
+
lastModified: number;
|
|
619
|
+
}>;
|
|
620
|
+
reset(): Promise<void>;
|
|
621
|
+
};
|
|
622
|
+
export type IStorageRaw = {
|
|
623
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
624
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
625
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
626
|
+
remove(key: string): Promise<void>;
|
|
627
|
+
getKeys(): Promise<string[]>;
|
|
628
|
+
getInfo(key: string): Promise<undefined | {
|
|
629
|
+
size: number;
|
|
630
|
+
lastModified: number;
|
|
631
|
+
}>;
|
|
632
|
+
reset(): Promise<void>;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
declare module "sliftutils/storage/IndexedDBFileFolderAPI" {
|
|
638
|
+
import { FileStorage } from "./FileFolderAPI";
|
|
639
|
+
export declare const getFileStorageIndexDB: {
|
|
640
|
+
(): Promise<FileStorage>;
|
|
641
|
+
reset(): void;
|
|
642
|
+
set(newValue: Promise<FileStorage>): void;
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
declare module "sliftutils/storage/JSONStorage" {
|
|
648
|
+
/// <reference types="node" />
|
|
649
|
+
/// <reference types="node" />
|
|
650
|
+
import { IStorage } from "./IStorage";
|
|
651
|
+
export declare class JSONStorage<T> implements IStorage<T> {
|
|
652
|
+
private storage;
|
|
653
|
+
constructor(storage: IStorage<Buffer>);
|
|
654
|
+
get(key: string): Promise<T | undefined>;
|
|
655
|
+
set(key: string, value: T): Promise<void>;
|
|
656
|
+
remove(key: string): Promise<void>;
|
|
657
|
+
getKeys(): Promise<string[]>;
|
|
658
|
+
getInfo(key: string): Promise<{
|
|
659
|
+
size: number;
|
|
660
|
+
lastModified: number;
|
|
661
|
+
} | undefined>;
|
|
662
|
+
reset(): Promise<void>;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
declare module "sliftutils/storage/PendingManager" {
|
|
668
|
+
import preact from "preact";
|
|
669
|
+
export declare function setPending(group: string, message: string): void;
|
|
670
|
+
export declare function hasPending(): boolean;
|
|
671
|
+
export declare class PendingDisplay extends preact.Component {
|
|
672
|
+
render(): preact.JSX.Element;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
declare module "sliftutils/storage/PendingStorage" {
|
|
678
|
+
import { IStorage } from "./IStorage";
|
|
679
|
+
export declare class PendingStorage<T> implements IStorage<T> {
|
|
680
|
+
private pendingGroup;
|
|
681
|
+
private storage;
|
|
682
|
+
pending: Map<string, number>;
|
|
683
|
+
constructor(pendingGroup: string, storage: IStorage<T>);
|
|
684
|
+
get(key: string): Promise<T | undefined>;
|
|
685
|
+
set(key: string, value: T): Promise<void>;
|
|
686
|
+
remove(key: string): Promise<void>;
|
|
687
|
+
getKeys(): Promise<string[]>;
|
|
688
|
+
getInfo(key: string): Promise<{
|
|
689
|
+
size: number;
|
|
690
|
+
lastModified: number;
|
|
691
|
+
} | undefined>;
|
|
692
|
+
private watchPending;
|
|
693
|
+
private updatePending;
|
|
694
|
+
reset(): Promise<void>;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
declare module "sliftutils/storage/PrivateFileSystemStorage" {
|
|
700
|
+
/// <reference types="node" />
|
|
701
|
+
/// <reference types="node" />
|
|
702
|
+
import { IStorageRaw } from "./IStorage";
|
|
703
|
+
export declare class PrivateFileSystemStorage implements IStorageRaw {
|
|
704
|
+
private path;
|
|
705
|
+
private rootHandle;
|
|
706
|
+
constructor(path: string);
|
|
707
|
+
private ensureInitialized;
|
|
708
|
+
private directoryExists;
|
|
709
|
+
private getDirectoryHandle;
|
|
710
|
+
private getFileHandle;
|
|
711
|
+
private fileExists;
|
|
712
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
713
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
714
|
+
append(key: string, value: Buffer): Promise<void>;
|
|
715
|
+
remove(key: string): Promise<void>;
|
|
716
|
+
getKeys(): Promise<string[]>;
|
|
717
|
+
getInfo(key: string): Promise<undefined | {
|
|
718
|
+
size: number;
|
|
719
|
+
lastModified: number;
|
|
720
|
+
}>;
|
|
721
|
+
reset(): Promise<void>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
declare module "sliftutils/storage/StorageObservable" {
|
|
727
|
+
import { IStorage, IStorageSync } from "./IStorage";
|
|
728
|
+
export declare class StorageSync<T> implements IStorageSync<T> {
|
|
729
|
+
storage: IStorage<T>;
|
|
730
|
+
cached: import("mobx").ObservableMap<string, T | undefined>;
|
|
731
|
+
infoCached: import("mobx").ObservableMap<string, {
|
|
732
|
+
size: number;
|
|
733
|
+
lastModified: number;
|
|
734
|
+
} | undefined>;
|
|
735
|
+
keys: Set<string>;
|
|
736
|
+
synced: {
|
|
737
|
+
keySeqNum: number;
|
|
738
|
+
};
|
|
739
|
+
constructor(storage: IStorage<T>);
|
|
740
|
+
get(key: string): T | undefined;
|
|
741
|
+
set(key: string, value: T): void;
|
|
742
|
+
remove(key: string): void;
|
|
743
|
+
private loadedKeys;
|
|
744
|
+
getKeys(): string[];
|
|
745
|
+
getInfo(key: string): {
|
|
746
|
+
size: number;
|
|
747
|
+
lastModified: number;
|
|
748
|
+
} | undefined;
|
|
749
|
+
getValues(): T[];
|
|
750
|
+
getEntries(): [string, T][];
|
|
751
|
+
getPromise(key: string): Promise<T | undefined>;
|
|
752
|
+
private pendingGetKeys;
|
|
753
|
+
getKeysPromise(): Promise<string[]>;
|
|
754
|
+
reload(): void;
|
|
755
|
+
reloadKeys(): void;
|
|
756
|
+
reloadKey(key: string): void;
|
|
757
|
+
reset(): Promise<void>;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
declare module "sliftutils/storage/TransactionStorage" {
|
|
763
|
+
/// <reference types="node" />
|
|
764
|
+
/// <reference types="node" />
|
|
765
|
+
import { IStorage, IStorageRaw } from "./IStorage";
|
|
766
|
+
interface TransactionEntry {
|
|
767
|
+
key: string;
|
|
768
|
+
value: Buffer | undefined;
|
|
769
|
+
isZipped: boolean;
|
|
770
|
+
time: number;
|
|
771
|
+
}
|
|
772
|
+
export declare class TransactionStorage implements IStorage<Buffer> {
|
|
773
|
+
private rawStorage;
|
|
774
|
+
private debugName;
|
|
775
|
+
private writeDelay;
|
|
776
|
+
cache: Map<string, TransactionEntry>;
|
|
777
|
+
private currentChunk;
|
|
778
|
+
private currentChunkSize;
|
|
779
|
+
private entryCount;
|
|
780
|
+
private static allStorage;
|
|
781
|
+
constructor(rawStorage: IStorageRaw, debugName: string, writeDelay?: number);
|
|
782
|
+
static compressAll(): Promise<void>;
|
|
783
|
+
private init;
|
|
784
|
+
private getChunk;
|
|
785
|
+
get(key: string): Promise<Buffer | undefined>;
|
|
786
|
+
set(key: string, value: Buffer): Promise<void>;
|
|
787
|
+
remove(key: string): Promise<void>;
|
|
788
|
+
getInfo(key: string): Promise<{
|
|
789
|
+
size: number;
|
|
790
|
+
lastModified: number;
|
|
791
|
+
} | undefined>;
|
|
792
|
+
private pendingAppends;
|
|
793
|
+
private extraAppends;
|
|
794
|
+
private pendingWrite;
|
|
795
|
+
pushAppend(entry: TransactionEntry): Promise<void>;
|
|
796
|
+
private updatePendingAppends;
|
|
797
|
+
getKeys(): Promise<string[]>;
|
|
798
|
+
private loadAllTransactions;
|
|
799
|
+
private loadTransactionFile;
|
|
800
|
+
private readTransactionEntry;
|
|
801
|
+
private serializeTransactionEntry;
|
|
802
|
+
private getHeader;
|
|
803
|
+
private chunkBuffers;
|
|
804
|
+
private compressing;
|
|
805
|
+
private compressTransactionLog;
|
|
806
|
+
reset(): Promise<void>;
|
|
807
|
+
}
|
|
808
|
+
export {};
|
|
809
|
+
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
declare module "sliftutils/storage/fileSystemPointer" {
|
|
813
|
+
export type FileSystemPointer = string;
|
|
814
|
+
export declare function storeFileSystemPointer(config: {
|
|
815
|
+
mode: "read" | "readwrite";
|
|
816
|
+
handle: FileSystemFileHandle | FileSystemDirectoryHandle;
|
|
817
|
+
}): Promise<FileSystemPointer>;
|
|
818
|
+
export declare function deleteFileSystemPointer(pointer: FileSystemPointer): Promise<void>;
|
|
819
|
+
export declare function getFileSystemPointer(config: {
|
|
820
|
+
pointer: FileSystemPointer;
|
|
821
|
+
}): Promise<{
|
|
822
|
+
onUserActivation(modeOverride?: "read" | "readwrite"): Promise<FileSystemFileHandle | FileSystemDirectoryHandle>;
|
|
823
|
+
} | undefined>;
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
declare module "sliftutils/storage/storage" {
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
declare module "node-forge" {
|
|
831
|
+
declare type Ed25519PublicKey = {
|
|
832
|
+
publicKeyBytes: Buffer;
|
|
833
|
+
} & Buffer;
|
|
834
|
+
declare type Ed25519PrivateKey = {
|
|
835
|
+
privateKeyBytes: Buffer;
|
|
836
|
+
} & Buffer;
|
|
837
|
+
class ed25519 {
|
|
838
|
+
static generateKeyPair(): { publicKey: Ed25519PublicKey, privateKey: Ed25519PrivateKey };
|
|
839
|
+
static privateKeyToPem(key: Ed25519PrivateKey): string;
|
|
840
|
+
static privateKeyFromPem(pem: string): Ed25519PrivateKey;
|
|
841
|
+
static publicKeyToPem(key: Ed25519PublicKey): string;
|
|
842
|
+
static publicKeyFromPem(pem: string): Ed25519PublicKey;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
interface FileSystemDirectoryHandle {
|
|
848
|
+
[Symbol.asyncIterator](): AsyncIterator<[string, FileSystemFileHandle | FileSystemDirectoryHandle]>;
|
|
849
|
+
requestPermission(config: { mode: "read" | "readwrite" }): Promise<void>;
|
|
850
|
+
}
|
|
851
|
+
interface FileSystemFileHandle {
|
|
852
|
+
getFile(): File;
|
|
853
|
+
createWritable(): FileSystemWritableFileStream;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
interface Window {
|
|
857
|
+
showSaveFilePicker(config?: {
|
|
858
|
+
types: {
|
|
859
|
+
description: string; accept: { [mimeType: string]: string[] }
|
|
860
|
+
}[];
|
|
861
|
+
}): Promise<FileSystemFileHandle>;
|
|
862
|
+
showDirectoryPicker(): Promise<FileSystemDirectoryHandle>;
|
|
863
|
+
showOpenFilePicker(config?: {
|
|
864
|
+
types: {
|
|
865
|
+
description: string; accept: { [mimeType: string]: string[] }
|
|
866
|
+
}[];
|
|
867
|
+
}): Promise<FileSystemFileHandle[]>;
|
|
868
|
+
}
|
|
869
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sliftutils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"update-types": "yarn emit-dts && yarn generate-index-dts",
|
|
13
13
|
"emit-dts": "yarn tsc --project tsconfig.declarations.json || true",
|
|
14
14
|
"generate-index-dts": "typenode ./builders/generateIndexDts.ts",
|
|
15
|
+
"prepublishOnly": "yarn update-types",
|
|
15
16
|
"run-nodejs": "node ./build-nodejs/server.js",
|
|
16
17
|
"run-nodejs-dev": "typenode ./nodejs/server.ts",
|
|
17
18
|
"run-web": "node ./builders/webRun.js",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import preact from "preact";
|
|
2
|
+
import { URLParam, batchURLParamUpdate, getResolvedParam } from "./URLParam";
|
|
3
|
+
import { css, isNode } from "typesafecss";
|
|
4
|
+
|
|
5
|
+
export const AnchorClass = (
|
|
6
|
+
css.textDecoration("none").color("hsl(210, 75%, 65%)").opacity(0.8, "hover")
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export class Anchor extends preact.Component<{
|
|
10
|
+
className?: string;
|
|
11
|
+
params: ([URLParam, unknown] | [string, string])[];
|
|
12
|
+
button?: boolean;
|
|
13
|
+
} & Omit<preact.JSX.HTMLAttributes<HTMLAnchorElement>, "href">> {
|
|
14
|
+
render() {
|
|
15
|
+
const { params, button, className, ...remaining } = this.props;
|
|
16
|
+
let resolvedParams = params.map(getResolvedParam);
|
|
17
|
+
let searchObj = new URLSearchParams(window.location.search);
|
|
18
|
+
let selected = resolvedParams.every(([param, value]) => searchObj.get(param) === value);
|
|
19
|
+
let link = (
|
|
20
|
+
<a
|
|
21
|
+
{...remaining}
|
|
22
|
+
className={
|
|
23
|
+
css.textDecoration("none")
|
|
24
|
+
.opacity(0.8, "hover")
|
|
25
|
+
+ (selected && css.color("hsl(110, 75%, 65%)", "soft"))
|
|
26
|
+
+ (!selected && css.color("hsl(210, 75%, 65%)", "soft"))
|
|
27
|
+
+ className
|
|
28
|
+
}
|
|
29
|
+
href={createLink(resolvedParams)}
|
|
30
|
+
onClick={e => {
|
|
31
|
+
if (this.props.target) return;
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
batchURLParamUpdate(params);
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{this.props.children}
|
|
38
|
+
</a>
|
|
39
|
+
);
|
|
40
|
+
if (button) {
|
|
41
|
+
return <button className={css.button} onClick={() => {
|
|
42
|
+
batchURLParamUpdate(params);
|
|
43
|
+
}}>
|
|
44
|
+
{link}
|
|
45
|
+
</button>;
|
|
46
|
+
}
|
|
47
|
+
return link;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createLink(params: ([string, string])[]) {
|
|
52
|
+
let searchParams = new URLSearchParams(isNode() ? "https://planquickly.com" : window.location.search);
|
|
53
|
+
for (let [param, value] of params) {
|
|
54
|
+
searchParams.set(param, value);
|
|
55
|
+
}
|
|
56
|
+
return "?" + searchParams.toString();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function createLinkRaw(params: ([URLParam, unknown])[]) {
|
|
60
|
+
let paramsText = params.map(getResolvedParam);
|
|
61
|
+
return createLink(paramsText);
|
|
62
|
+
}
|