@filebox/core 1.0.10
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/LICENSE +9 -0
- package/README.md +599 -0
- package/dist/index.browser.js +29 -0
- package/dist/index.cjs +33 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.mjs +29 -0
- package/dist/src/cache/cache.d.ts +104 -0
- package/dist/src/cache/dependencies.d.ts +60 -0
- package/dist/src/cache/index.d.ts +8 -0
- package/dist/src/cache/operations.d.ts +52 -0
- package/dist/src/cache/strategies/index.d.ts +1 -0
- package/dist/src/cache/strategies/lru.d.ts +15 -0
- package/dist/src/cache/types.d.ts +79 -0
- package/dist/src/cache1.d.ts +230 -0
- package/dist/src/constant.d.ts +2 -0
- package/dist/src/crypt/eme-cipher.d.ts +37 -0
- package/dist/src/crypt/file-encryptor.d.ts +168 -0
- package/dist/src/crypt/fs-crypt.d.ts +24 -0
- package/dist/src/crypt/index.d.ts +9 -0
- package/dist/src/crypt/protocol.d.ts +27 -0
- package/dist/src/crypt/utils.d.ts +7 -0
- package/dist/src/crypt.d.ts +2 -0
- package/dist/src/crypto-shim.d.ts +2 -0
- package/dist/src/debug.d.ts +9 -0
- package/dist/src/enums/index.d.ts +8 -0
- package/dist/src/error.d.ts +6 -0
- package/dist/src/filter.d.ts +12 -0
- package/dist/src/fs/http_fs.d.ts +40 -0
- package/dist/src/fs/index.d.ts +95 -0
- package/dist/src/index.d.ts +51 -0
- package/dist/src/lock.d.ts +9 -0
- package/dist/src/path.d.ts +65 -0
- package/dist/src/plugin.d.ts +16 -0
- package/dist/src/stat.d.ts +64 -0
- package/dist/src/type.d.ts +47 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/volume.d.ts +48 -0
- package/package.json +59 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { CacheOptions, CacheOperation, CacheStatus, ScanOptions } from "./types";
|
|
2
|
+
interface ExtendedCacheOptions extends CacheOptions {
|
|
3
|
+
fs?: any;
|
|
4
|
+
}
|
|
5
|
+
export declare class Cache {
|
|
6
|
+
private strategy;
|
|
7
|
+
private inited;
|
|
8
|
+
private cacheStatus;
|
|
9
|
+
private fs;
|
|
10
|
+
private dependencyManager;
|
|
11
|
+
private operationsHandler;
|
|
12
|
+
/**
|
|
13
|
+
* 创建新的缓存实例
|
|
14
|
+
* @param options 缓存选项
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: ExtendedCacheOptions);
|
|
17
|
+
/**
|
|
18
|
+
* 初始化缓存
|
|
19
|
+
*/
|
|
20
|
+
init(): Promise<Cache>;
|
|
21
|
+
fullkey(key: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* 从缓存中获取值,包含状态检查
|
|
24
|
+
*/
|
|
25
|
+
get(key: string): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* 将值存储到缓存中
|
|
28
|
+
* @param ttl 可选的生存时间(毫秒)
|
|
29
|
+
*/
|
|
30
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* 从缓存中删除值
|
|
33
|
+
*/
|
|
34
|
+
del(key: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 检查键是否存在于缓存中
|
|
37
|
+
*/
|
|
38
|
+
has(key: string): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* 扫描以特定前缀开头的所有键
|
|
41
|
+
* @param prefix 前缀字符串
|
|
42
|
+
* @param opts 扫描选项
|
|
43
|
+
*/
|
|
44
|
+
scan(prefix: string, opts?: ScanOptions): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* 关闭/清理缓存资源
|
|
47
|
+
*/
|
|
48
|
+
close(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* 获取底层策略实例
|
|
51
|
+
*/
|
|
52
|
+
getStrategy(): import("./types").ICacheStrategy;
|
|
53
|
+
/**
|
|
54
|
+
* 标记路径状态
|
|
55
|
+
* @param path 路径
|
|
56
|
+
* @param status 状态
|
|
57
|
+
*/
|
|
58
|
+
markStatus(path: string, status: CacheStatus): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* 使子路径缓存无效
|
|
61
|
+
* 使用前缀匹配扫描找到并标记所有子路径
|
|
62
|
+
* @param path 父路径
|
|
63
|
+
*/
|
|
64
|
+
private invalidateChildPaths;
|
|
65
|
+
/**
|
|
66
|
+
* 批量标记路径状态
|
|
67
|
+
* @param pathPattern 路径模式
|
|
68
|
+
* @param status 状态
|
|
69
|
+
*/
|
|
70
|
+
markPathsMatching(pathPattern: string, status: CacheStatus): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* 标记路径需要刷新
|
|
73
|
+
*/
|
|
74
|
+
markForRefresh(path: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* 标记路径已失效
|
|
77
|
+
*/
|
|
78
|
+
invalidate(path: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* 调度缓存刷新
|
|
81
|
+
*/
|
|
82
|
+
private scheduleRefresh;
|
|
83
|
+
/**
|
|
84
|
+
* 统一处理缓存操作的接口
|
|
85
|
+
*/
|
|
86
|
+
handleOperation(op: CacheOperation): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated 使用handleOperation代替
|
|
89
|
+
*/
|
|
90
|
+
mkdir(path: string, data: any): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated 使用handleOperation代替
|
|
93
|
+
*/
|
|
94
|
+
remove(path: any, fs: any): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated 使用handleOperation代替
|
|
97
|
+
*/
|
|
98
|
+
rename(path: any, fs: any, data: any): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated 使用handleOperation代替
|
|
101
|
+
*/
|
|
102
|
+
move(srcPath: any, destPath: any, srcStat: any, tarStat: any, fs: any, data: any): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存依赖关系管理类接口
|
|
3
|
+
*/
|
|
4
|
+
export interface IDependencyManager {
|
|
5
|
+
addDependency(key: string, dependency: string): void;
|
|
6
|
+
addDependencies(key: string, dependencies: string[]): void;
|
|
7
|
+
addPathHierarchyDependencies(path: string): void;
|
|
8
|
+
removeDependencies(key: string): void;
|
|
9
|
+
getDependents(key: string): string[];
|
|
10
|
+
getDependencies(key: string): string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 缓存依赖关系管理类
|
|
14
|
+
* 管理缓存项之间的依赖关系
|
|
15
|
+
*/
|
|
16
|
+
export declare class DependencyManager implements IDependencyManager {
|
|
17
|
+
private cacheDependencies;
|
|
18
|
+
private cacheReverseDependencies;
|
|
19
|
+
/**
|
|
20
|
+
* 添加单个缓存依赖关系
|
|
21
|
+
* @param key 缓存键
|
|
22
|
+
* @param dependency 该键依赖的缓存键
|
|
23
|
+
*/
|
|
24
|
+
addDependency(key: string, dependency: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* 添加多个缓存依赖
|
|
27
|
+
* @param key 缓存键
|
|
28
|
+
* @param dependencies 依赖列表
|
|
29
|
+
*/
|
|
30
|
+
addDependencies(key: string, dependencies: string[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* 自动创建路径层级依赖关系
|
|
33
|
+
* 为路径创建与其所有父路径的依赖关系
|
|
34
|
+
* @param path 路径
|
|
35
|
+
*/
|
|
36
|
+
addPathHierarchyDependencies(path: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* 移除所有与指定键相关的依赖关系
|
|
39
|
+
* @param key 缓存键
|
|
40
|
+
*/
|
|
41
|
+
removeDependencies(key: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* 获取依赖于指定键的所有缓存键(包括间接依赖)
|
|
44
|
+
* @param key 缓存键
|
|
45
|
+
* @returns 依赖于此键的所有键列表
|
|
46
|
+
*/
|
|
47
|
+
getDependents(key: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* 递归收集所有依赖于指定键的缓存键
|
|
50
|
+
* @param key 缓存键
|
|
51
|
+
* @param result 结果集合
|
|
52
|
+
*/
|
|
53
|
+
private collectDependents;
|
|
54
|
+
/**
|
|
55
|
+
* 获取指定键依赖的所有缓存键
|
|
56
|
+
* @param key 缓存键
|
|
57
|
+
* @returns 此键依赖的所有键列表
|
|
58
|
+
*/
|
|
59
|
+
getDependencies(key: string): string[];
|
|
60
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./strategies";
|
|
3
|
+
export { Cache } from "./cache";
|
|
4
|
+
export { DependencyManager } from "./dependencies";
|
|
5
|
+
export type { IDependencyManager } from "./dependencies";
|
|
6
|
+
export { OperationsHandler } from "./operations";
|
|
7
|
+
import { Cache } from "./cache";
|
|
8
|
+
export default Cache;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CacheOperation, CacheStatus } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 缓存操作处理类
|
|
4
|
+
* 处理各种缓存操作(创建、更新、删除、移动、复制、重命名)
|
|
5
|
+
*/
|
|
6
|
+
export declare class OperationsHandler {
|
|
7
|
+
/**
|
|
8
|
+
* 处理缓存操作
|
|
9
|
+
* @param op 操作对象
|
|
10
|
+
* @param cache 缓存实例接口
|
|
11
|
+
*/
|
|
12
|
+
handleOperation(op: CacheOperation, cache: {
|
|
13
|
+
get: (key: string) => Promise<any>;
|
|
14
|
+
set: (key: string, value: any, ttl?: number) => Promise<void>;
|
|
15
|
+
markForRefresh: (path: string) => Promise<void>;
|
|
16
|
+
invalidate: (path: string) => Promise<void>;
|
|
17
|
+
markPathsMatching: (pathPattern: string, status: CacheStatus) => Promise<void>;
|
|
18
|
+
markStatus: (path: string, status: CacheStatus) => Promise<void>;
|
|
19
|
+
fullkey: (path: string) => string;
|
|
20
|
+
del: (path: string) => Promise<void>;
|
|
21
|
+
scan: (pathPattern: string, opts?: any) => Promise<string[]>;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* 处理创建操作
|
|
25
|
+
*/
|
|
26
|
+
private handleCreate;
|
|
27
|
+
/**
|
|
28
|
+
* 处理更新操作
|
|
29
|
+
*/
|
|
30
|
+
private handleUpdate;
|
|
31
|
+
/**
|
|
32
|
+
* 处理删除操作
|
|
33
|
+
*/
|
|
34
|
+
private handleDelete;
|
|
35
|
+
/**
|
|
36
|
+
* 使用前缀匹配扫描进行级联删除
|
|
37
|
+
* 删除指定路径及其所有子路径的缓存项
|
|
38
|
+
*/
|
|
39
|
+
private cascadeDeleteWithPrefix;
|
|
40
|
+
/**
|
|
41
|
+
* 处理移动操作
|
|
42
|
+
*/
|
|
43
|
+
private handleMove;
|
|
44
|
+
/**
|
|
45
|
+
* 处理复制操作
|
|
46
|
+
*/
|
|
47
|
+
private handleCopy;
|
|
48
|
+
/**
|
|
49
|
+
* 处理重命名操作
|
|
50
|
+
*/
|
|
51
|
+
private handleRename;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LRUCacheStrategy } from "./lru";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ICacheStrategy, CacheOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* LRU缓存策略实现 (默认本地内存缓存)
|
|
4
|
+
*/
|
|
5
|
+
export declare class LRUCacheStrategy implements ICacheStrategy {
|
|
6
|
+
private cache;
|
|
7
|
+
prefix: string;
|
|
8
|
+
constructor(options?: CacheOptions);
|
|
9
|
+
private normalize;
|
|
10
|
+
has(key: string): Promise<boolean>;
|
|
11
|
+
get(key: string): Promise<any>;
|
|
12
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
13
|
+
del(key: string): Promise<void>;
|
|
14
|
+
scan(prefix: string): Promise<string[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存状态枚举
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CacheStatus {
|
|
5
|
+
VALID = 0,// 缓存有效
|
|
6
|
+
NEEDS_REFRESH = 1,// 需要刷新但可以暂时使用
|
|
7
|
+
INVALID = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 缓存操作类型
|
|
11
|
+
*/
|
|
12
|
+
export type CacheOperationType = "create" | "update" | "delete" | "move" | "copy" | "rename";
|
|
13
|
+
/**
|
|
14
|
+
* 缓存操作接口
|
|
15
|
+
*/
|
|
16
|
+
export interface CacheOperation {
|
|
17
|
+
type: CacheOperationType;
|
|
18
|
+
path: string;
|
|
19
|
+
parentPath?: string;
|
|
20
|
+
newItem?: any;
|
|
21
|
+
targetPath?: string;
|
|
22
|
+
newName?: string;
|
|
23
|
+
result?: any;
|
|
24
|
+
fs?: any;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 缓存策略接口 - 用户可以实现此接口来创建自定义缓存后端
|
|
28
|
+
*/
|
|
29
|
+
export interface ICacheStrategy {
|
|
30
|
+
/**
|
|
31
|
+
* 缓存前缀(字符串或函数)
|
|
32
|
+
*/
|
|
33
|
+
prefix?: string | ((context?: any) => string);
|
|
34
|
+
/**
|
|
35
|
+
* 检查键是否存在于缓存中
|
|
36
|
+
*/
|
|
37
|
+
has(key: string): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* 从缓存中获取值
|
|
40
|
+
*/
|
|
41
|
+
get(key: string): Promise<any>;
|
|
42
|
+
/**
|
|
43
|
+
* 将值存储到缓存中
|
|
44
|
+
* @param ttl 可选的生存时间(毫秒)
|
|
45
|
+
*/
|
|
46
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* 从缓存中删除值
|
|
49
|
+
*/
|
|
50
|
+
del(key: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* 扫描以特定前缀开头的所有键
|
|
53
|
+
*/
|
|
54
|
+
scan(prefix: string): Promise<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* 初始化缓存策略(可选)
|
|
57
|
+
*/
|
|
58
|
+
init?(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* 关闭/清理缓存资源(可选)
|
|
61
|
+
*/
|
|
62
|
+
close?(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
export interface CacheOptions {
|
|
65
|
+
max?: number;
|
|
66
|
+
maxSize?: number;
|
|
67
|
+
ttl?: number;
|
|
68
|
+
sizeCalculation?: (value: any, key: string) => number;
|
|
69
|
+
prefix?: string | ((context?: any) => string);
|
|
70
|
+
strategy?: ICacheStrategy;
|
|
71
|
+
enableDependencyCollection?: boolean;
|
|
72
|
+
fs?: any;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 缓存扫描选项
|
|
76
|
+
*/
|
|
77
|
+
export interface ScanOptions {
|
|
78
|
+
includeDependencies?: boolean;
|
|
79
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存状态枚举
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CacheStatus {
|
|
5
|
+
VALID = 0,// 缓存有效
|
|
6
|
+
NEEDS_REFRESH = 1,// 需要刷新但可以暂时使用
|
|
7
|
+
INVALID = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 缓存操作类型
|
|
11
|
+
*/
|
|
12
|
+
export type CacheOperationType = "create" | "update" | "delete" | "move" | "copy" | "rename";
|
|
13
|
+
/**
|
|
14
|
+
* 缓存操作接口
|
|
15
|
+
*/
|
|
16
|
+
export interface CacheOperation {
|
|
17
|
+
type: CacheOperationType;
|
|
18
|
+
path: string;
|
|
19
|
+
parentPath?: string;
|
|
20
|
+
newItem?: any;
|
|
21
|
+
targetPath?: string;
|
|
22
|
+
newName?: string;
|
|
23
|
+
result?: any;
|
|
24
|
+
fs?: any;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 缓存策略接口 - 用户可以实现此接口来创建自定义缓存后端
|
|
28
|
+
*/
|
|
29
|
+
export interface ICacheStrategy {
|
|
30
|
+
/**
|
|
31
|
+
* 检查键是否存在于缓存中
|
|
32
|
+
*/
|
|
33
|
+
has(key: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* 从缓存中获取值
|
|
36
|
+
*/
|
|
37
|
+
get(key: string): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* 将值存储到缓存中
|
|
40
|
+
* @param ttl 可选的生存时间(毫秒)
|
|
41
|
+
*/
|
|
42
|
+
set(key: string, value: any, ttl?: number): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* 从缓存中删除值
|
|
45
|
+
*/
|
|
46
|
+
del(key: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* 扫描以特定前缀开头的所有键
|
|
49
|
+
*/
|
|
50
|
+
scan(prefix: string): Promise<string[]>;
|
|
51
|
+
/**
|
|
52
|
+
* 初始化缓存策略(可选)
|
|
53
|
+
*/
|
|
54
|
+
init?(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* 关闭/清理缓存资源(可选)
|
|
57
|
+
*/
|
|
58
|
+
close?(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
export interface CacheOptions {
|
|
61
|
+
max?: number;
|
|
62
|
+
maxSize?: number;
|
|
63
|
+
ttl?: number;
|
|
64
|
+
sizeCalculation?: (value: any, key: string) => number;
|
|
65
|
+
prefix?: string;
|
|
66
|
+
strategy?: ICacheStrategy;
|
|
67
|
+
enableDependencyCollection?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 主缓存类 - 轻量级门面
|
|
71
|
+
*
|
|
72
|
+
* 该类可通过以下方式使用:
|
|
73
|
+
* 1. 直接实例化: `new Cache(options)`
|
|
74
|
+
* 2. 单例模式: `Cache.getInstance(options)`
|
|
75
|
+
* 3. 自定义缓存后端: 传入实现ICacheStrategy接口的对象
|
|
76
|
+
*/
|
|
77
|
+
export declare class Cache {
|
|
78
|
+
private strategy;
|
|
79
|
+
private inited;
|
|
80
|
+
private cacheStatus;
|
|
81
|
+
private cacheDependencies;
|
|
82
|
+
private cacheReverseDependencies;
|
|
83
|
+
private enableDependencyCollection;
|
|
84
|
+
/**
|
|
85
|
+
* 创建新的缓存实例
|
|
86
|
+
* @param options 缓存选项
|
|
87
|
+
*/
|
|
88
|
+
constructor(options?: CacheOptions);
|
|
89
|
+
/**
|
|
90
|
+
* 初始化缓存
|
|
91
|
+
*/
|
|
92
|
+
init(): Promise<Cache>;
|
|
93
|
+
/**
|
|
94
|
+
* 从缓存中获取值,包含状态检查
|
|
95
|
+
*/
|
|
96
|
+
get(key: string): Promise<any>;
|
|
97
|
+
/**
|
|
98
|
+
* 将值存储到缓存中
|
|
99
|
+
* @param ttl 可选的生存时间(毫秒)
|
|
100
|
+
* @param dependencies 可选的依赖项列表
|
|
101
|
+
*/
|
|
102
|
+
set(key: string, value: any, ttl?: number, dependencies?: string[]): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* 从缓存中删除值
|
|
105
|
+
*/
|
|
106
|
+
del(key: string): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* 检查键是否存在于缓存中
|
|
109
|
+
*/
|
|
110
|
+
has(key: string): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* 扫描以特定前缀开头的所有键
|
|
113
|
+
* @param prefix 前缀字符串
|
|
114
|
+
* @param opts 选项 {includeDependencies: boolean} 是否包含依赖此前缀的键
|
|
115
|
+
*/
|
|
116
|
+
scan(prefix: string, opts?: {
|
|
117
|
+
includeDependencies?: boolean;
|
|
118
|
+
}): Promise<string[]>;
|
|
119
|
+
/**
|
|
120
|
+
* 关闭/清理缓存资源
|
|
121
|
+
*/
|
|
122
|
+
close(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* 获取底层策略实例
|
|
125
|
+
*/
|
|
126
|
+
getStrategy(): ICacheStrategy;
|
|
127
|
+
/**
|
|
128
|
+
* 标记路径状态
|
|
129
|
+
* @param path 路径
|
|
130
|
+
* @param status 状态
|
|
131
|
+
*/
|
|
132
|
+
markStatus(path: string, status: CacheStatus): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* 批量标记路径状态
|
|
135
|
+
* @param pathPattern 路径模式
|
|
136
|
+
* @param status 状态
|
|
137
|
+
*/
|
|
138
|
+
markPathsMatching(pathPattern: string, status: CacheStatus): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* 标记路径需要刷新
|
|
141
|
+
*/
|
|
142
|
+
markForRefresh(path: string): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* 标记路径已失效
|
|
145
|
+
*/
|
|
146
|
+
invalidate(path: string): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* 添加单个缓存依赖关系
|
|
149
|
+
* @param key 缓存键
|
|
150
|
+
* @param dependency 该键依赖的缓存键
|
|
151
|
+
*/
|
|
152
|
+
addDependency(key: string, dependency: string): void;
|
|
153
|
+
/**
|
|
154
|
+
* 添加多个缓存依赖
|
|
155
|
+
* @param key 缓存键
|
|
156
|
+
* @param dependencies 依赖列表
|
|
157
|
+
*/
|
|
158
|
+
addDependencies(key: string, dependencies: string[]): void;
|
|
159
|
+
/**
|
|
160
|
+
* 移除所有与指定键相关的依赖关系
|
|
161
|
+
* @param key 缓存键
|
|
162
|
+
*/
|
|
163
|
+
removeDependencies(key: string): void;
|
|
164
|
+
/**
|
|
165
|
+
* 获取依赖于指定键的所有缓存键
|
|
166
|
+
* @param key 缓存键
|
|
167
|
+
* @returns 依赖于此键的所有键列表
|
|
168
|
+
*/
|
|
169
|
+
getDependents(key: string): string[];
|
|
170
|
+
/**
|
|
171
|
+
* 获取指定键依赖的所有缓存键
|
|
172
|
+
* @param key 缓存键
|
|
173
|
+
* @returns 此键依赖的所有键列表
|
|
174
|
+
*/
|
|
175
|
+
getDependencies(key: string): string[];
|
|
176
|
+
/**
|
|
177
|
+
* 使依赖于指定键的所有缓存项无效
|
|
178
|
+
* @param key 缓存键
|
|
179
|
+
*/
|
|
180
|
+
invalidateDependents(key: string): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* 调度缓存刷新
|
|
183
|
+
*/
|
|
184
|
+
private scheduleRefresh;
|
|
185
|
+
/**
|
|
186
|
+
* 统一处理缓存操作的接口
|
|
187
|
+
*/
|
|
188
|
+
handleOperation(op: CacheOperation): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* 处理创建操作
|
|
191
|
+
*/
|
|
192
|
+
private handleCreate;
|
|
193
|
+
/**
|
|
194
|
+
* 处理更新操作
|
|
195
|
+
*/
|
|
196
|
+
private handleUpdate;
|
|
197
|
+
/**
|
|
198
|
+
* 处理删除操作
|
|
199
|
+
*/
|
|
200
|
+
private handleDelete;
|
|
201
|
+
/**
|
|
202
|
+
* 处理移动操作
|
|
203
|
+
*/
|
|
204
|
+
private handleMove;
|
|
205
|
+
/**
|
|
206
|
+
* 处理复制操作
|
|
207
|
+
*/
|
|
208
|
+
private handleCopy;
|
|
209
|
+
/**
|
|
210
|
+
* 处理重命名操作
|
|
211
|
+
*/
|
|
212
|
+
private handleRename;
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated 使用handleOperation代替
|
|
215
|
+
*/
|
|
216
|
+
mkdir(path: string, data: any): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated 使用handleOperation代替
|
|
219
|
+
*/
|
|
220
|
+
remove(path: any, fs: any): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated 使用handleOperation代替
|
|
223
|
+
*/
|
|
224
|
+
rename(path: any, fs: any, data: any): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated 使用handleOperation代替
|
|
227
|
+
*/
|
|
228
|
+
move(srcPath: any, destPath: any, srcStat: any, tarStat: any, fs: any, data: any): Promise<void>;
|
|
229
|
+
}
|
|
230
|
+
export default Cache;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EME (ECB-Mix-ECB) 加密模式实现
|
|
3
|
+
* 用于文件名加密,产生更短的密文
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* EME 加密器
|
|
7
|
+
*/
|
|
8
|
+
export declare class EMECipher {
|
|
9
|
+
private key;
|
|
10
|
+
private blockSize;
|
|
11
|
+
private nodeCrypto;
|
|
12
|
+
constructor(key: Uint8Array);
|
|
13
|
+
/**
|
|
14
|
+
* 加密单个块(使用 ECB 模式)
|
|
15
|
+
*/
|
|
16
|
+
private _encryptBlock;
|
|
17
|
+
/**
|
|
18
|
+
* 解密单个块(使用 ECB 模式)
|
|
19
|
+
*/
|
|
20
|
+
private _decryptBlock;
|
|
21
|
+
/**
|
|
22
|
+
* 异或操作
|
|
23
|
+
*/
|
|
24
|
+
private _xor;
|
|
25
|
+
/**
|
|
26
|
+
* GF(2^128) 乘法
|
|
27
|
+
*/
|
|
28
|
+
private _gfMultiply;
|
|
29
|
+
/**
|
|
30
|
+
* 加密数据
|
|
31
|
+
*/
|
|
32
|
+
encrypt(plaintext: Uint8Array): Promise<Uint8Array>;
|
|
33
|
+
/**
|
|
34
|
+
* 解密数据
|
|
35
|
+
*/
|
|
36
|
+
decrypt(ciphertext: Uint8Array): Promise<Uint8Array>;
|
|
37
|
+
}
|