datafolder 1.0.12 → 1.0.14
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/README.md +14 -2
- package/package.json +1 -1
- package/scripts/airbnb.js +1 -1
- package/scripts/airbnb2.js +1 -1
- package/scripts/flights.js +2 -2
- package/scripts/flights2.js +2 -2
- package/src/QyBatch.d.ts +13 -6
- package/src/QyBatch.js +209 -126
- package/src/QyCache.d.ts +6 -3
- package/src/QyCache.js +86 -68
- package/src/QyDB.d.ts +3 -0
- package/src/QyDB.js +36 -21
- package/src/QyDefaultOptions.js +0 -3
- package/src/QyDir.d.ts +1 -0
- package/src/QyDir.js +49 -20
- package/src/QyExpire.d.ts +9 -15
- package/src/QyExpire.js +60 -68
- package/src/QyExpireInfo.d.ts +10 -0
- package/src/QyExpireInfo.js +92 -0
- package/src/QyExpire_Worker.d.ts +13 -14
- package/src/QyExpire_Worker.js +74 -89
- package/src/QyFile.d.ts +1 -1
- package/src/QyFile.js +58 -43
- package/src/QyFileContentUtils.d.ts +1 -0
- package/src/QyFileContentUtils.js +107 -93
- package/src/QyItem.d.ts +6 -0
- package/src/QyItem.js +25 -7
- package/src/QyKVData.d.ts +3 -1
- package/src/QyKVData.js +70 -63
- package/src/QyUtils.d.ts +3 -1
- package/src/QyUtils.js +41 -34
- package/src/rpc/evalCode.js +7 -9
- package/src/rpc/getFileContent.js +13 -16
- package/src/rpc/getRpcFiles.js +3 -1
- package/src/rpc/getSubItems.js +17 -16
- package/src/rpc/getTriggerFiles.js +3 -1
- package/src/rpc/queryFiles.js +4 -10
- package/src/rpc/reloadRpc.js +1 -1
- package/static/codemirror.bundle/editor.bundle.js +6 -1
- package/src/QyExpireClock.d.ts +0 -15
- package/src/QyExpireClock.js +0 -53
package/src/QyCache.js
CHANGED
|
@@ -5,70 +5,72 @@ import {
|
|
|
5
5
|
import r from "node:events";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
QyDir as
|
|
8
|
+
QyDir as p
|
|
9
9
|
} from "./QyDir.js";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
QyFileLogger as
|
|
12
|
+
QyFileLogger as u
|
|
13
13
|
} from "./QyFileLogger.js";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
QyKVData as
|
|
16
|
+
QyKVData as d
|
|
17
17
|
} from "./QyKVData.js";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
QyTriggerNode as f,
|
|
21
|
-
updateTriggerNodes as
|
|
21
|
+
updateTriggerNodes as s
|
|
22
22
|
} from "./QyTrigger.js";
|
|
23
23
|
|
|
24
24
|
import {
|
|
25
|
-
isString as
|
|
26
|
-
lockExclusiveFilePath as
|
|
25
|
+
isString as x,
|
|
26
|
+
lockExclusiveFilePath as C,
|
|
27
27
|
unlockExclusiveFilePath as i
|
|
28
28
|
} from "./QyUtils.js";
|
|
29
29
|
|
|
30
30
|
import {
|
|
31
|
-
dumpStructure as
|
|
31
|
+
dumpStructure as q
|
|
32
32
|
} from "./QyStructure.js";
|
|
33
33
|
|
|
34
34
|
import {
|
|
35
|
-
getIndexPropPaths as
|
|
36
|
-
parseNamePathAndQuery as
|
|
35
|
+
getIndexPropPaths as n,
|
|
36
|
+
parseNamePathAndQuery as g
|
|
37
37
|
} from "./QyIndex.js";
|
|
38
38
|
|
|
39
39
|
import {
|
|
40
|
-
getDefaultOptions as
|
|
40
|
+
getDefaultOptions as h
|
|
41
41
|
} from "./QyDefaultOptions.js";
|
|
42
42
|
|
|
43
43
|
import {
|
|
44
|
-
ensureDir as
|
|
44
|
+
ensureDir as R,
|
|
45
45
|
SpecialFilePaths as e
|
|
46
46
|
} from "./QyUtils.js";
|
|
47
47
|
|
|
48
48
|
import {
|
|
49
|
-
QueryCounter as
|
|
49
|
+
QueryCounter as l
|
|
50
50
|
} from "./QyUnionNode.js";
|
|
51
51
|
|
|
52
52
|
import {
|
|
53
|
-
QyKVDataLoader as
|
|
53
|
+
QyKVDataLoader as Q
|
|
54
54
|
} from "./QyKVDataLoader.js";
|
|
55
55
|
|
|
56
56
|
import {
|
|
57
|
-
requireFromModCode as
|
|
57
|
+
requireFromModCode as c
|
|
58
58
|
} from "./QyMod.js";
|
|
59
59
|
|
|
60
60
|
import {
|
|
61
|
-
logger as
|
|
61
|
+
logger as O
|
|
62
62
|
} from "./QyLogger.js";
|
|
63
63
|
|
|
64
64
|
let {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
HiddenFolderName: D,
|
|
66
|
+
IndexDirPath: F,
|
|
67
|
+
TriggerDirPath: P,
|
|
68
|
+
RpcDirPath: S,
|
|
69
|
+
ExpireDirPath: m,
|
|
70
|
+
MetaFilePath: t
|
|
69
71
|
} = e;
|
|
70
72
|
|
|
71
|
-
class
|
|
73
|
+
class o extends r {
|
|
72
74
|
rootFolder;
|
|
73
75
|
options;
|
|
74
76
|
qyDB;
|
|
@@ -85,20 +87,27 @@ class t extends r {
|
|
|
85
87
|
rpcFunMap = {};
|
|
86
88
|
constructor(r, e, t) {
|
|
87
89
|
super(), e = {
|
|
88
|
-
...
|
|
90
|
+
...h("QyCache"),
|
|
89
91
|
...e
|
|
90
92
|
};
|
|
91
|
-
var i = v(r, "qykv");
|
|
92
|
-
|
|
93
|
+
var i = v(r, "qykv"), o = m.at(-1), a = F.at(-1), s = new p("", !0, void 0, this), n = new p(D, !0, s), g = new p(o, !0, n), l = new p(a, !0, n);
|
|
94
|
+
s._subdirMap = {
|
|
95
|
+
[D]: n
|
|
96
|
+
}, n._subdirMap = {
|
|
97
|
+
[o]: g,
|
|
98
|
+
[a]: l
|
|
99
|
+
}, Object.assign(this, {
|
|
93
100
|
rootFolder: r,
|
|
94
101
|
options: e,
|
|
95
102
|
qyDB: t,
|
|
96
103
|
kvFolder: i,
|
|
104
|
+
rootDir: s,
|
|
105
|
+
expireRootDir: g,
|
|
106
|
+
indexRootDir: l,
|
|
97
107
|
rpcFolder: v(r, "rpc"),
|
|
98
|
-
rootDir: new o("", !0, void 0, this),
|
|
99
108
|
exclusiveFilePath: v(r, ".opened"),
|
|
100
|
-
qyKVData: new
|
|
101
|
-
qyFileLogger: new
|
|
109
|
+
qyKVData: new d(i, e, this),
|
|
110
|
+
qyFileLogger: new u(v(r, "qylog"), e)
|
|
102
111
|
});
|
|
103
112
|
}
|
|
104
113
|
async start() {
|
|
@@ -111,15 +120,15 @@ class t extends r {
|
|
|
111
120
|
exclusiveFilePath: a,
|
|
112
121
|
rootDir: s
|
|
113
122
|
} = this;
|
|
114
|
-
|
|
123
|
+
O.log(`Starting at ${r}...`);
|
|
115
124
|
try {
|
|
116
|
-
await
|
|
125
|
+
await R(e), o.start();
|
|
117
126
|
var [ {
|
|
118
127
|
maxChangeId: n,
|
|
119
128
|
loadedMaxAclNum: g,
|
|
120
129
|
qySnapshots: l,
|
|
121
130
|
aclKeyValueMap: p
|
|
122
|
-
} ] = await Promise.all([ ((r, e) => (r = new
|
|
131
|
+
} ] = await Promise.all([ ((r, e) => (r = new Q(r, e)).load())(e, t), C(a) ]);
|
|
123
132
|
i.start(n, g, l, p);
|
|
124
133
|
} catch (r) {
|
|
125
134
|
throw o.stop(), r;
|
|
@@ -130,36 +139,36 @@ class t extends r {
|
|
|
130
139
|
fileMap: i
|
|
131
140
|
} = e;
|
|
132
141
|
for (var o of t) r(o);
|
|
133
|
-
}(s)
|
|
142
|
+
}(s);
|
|
134
143
|
var u = this, e = u.rootDir;
|
|
135
144
|
e.triggerNodes = [ new f() ];
|
|
136
|
-
for (d of (e = u.triggerRootDir = e.searchOrCreateSubdir(
|
|
145
|
+
for (d of (e = u.triggerRootDir = e.searchOrCreateSubdir(P)).fileList) {
|
|
137
146
|
var {
|
|
138
147
|
name: d,
|
|
139
148
|
fileContent: h
|
|
140
149
|
} = d, [ h, c, D ] = h;
|
|
141
150
|
u.insertTriggerToTree(d, h, c, D);
|
|
142
151
|
}
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
for (
|
|
152
|
+
var F = this;
|
|
153
|
+
F.rpcRootDir = F.rootDir.searchOrCreateSubdir(S);
|
|
154
|
+
for (m of F.rpcRootDir.fileList) {
|
|
146
155
|
var {
|
|
147
|
-
name:
|
|
148
|
-
fileContent:
|
|
149
|
-
} =
|
|
150
|
-
|
|
156
|
+
name: m,
|
|
157
|
+
fileContent: y
|
|
158
|
+
} = m;
|
|
159
|
+
x(y) && F.insertRpc(m, y);
|
|
151
160
|
}
|
|
152
|
-
return t.dumpStructureAtStart && await
|
|
161
|
+
return t.dumpStructureAtStart && await q(v(r, "qystruct"), s), O.log("Started."),
|
|
153
162
|
this;
|
|
154
163
|
}
|
|
155
164
|
async stop() {
|
|
156
|
-
|
|
165
|
+
O.log("Stopping...");
|
|
157
166
|
var {
|
|
158
167
|
qyKVData: r,
|
|
159
168
|
qyFileLogger: e,
|
|
160
169
|
exclusiveFilePath: t
|
|
161
170
|
} = this;
|
|
162
|
-
return await r.stop(),
|
|
171
|
+
return await r.stop(), O.log("QyFileLogger stopped."), await e.stop(), i(t),
|
|
163
172
|
Object.assign(this, {
|
|
164
173
|
rootDir: void 0,
|
|
165
174
|
indexRootDir: void 0,
|
|
@@ -170,7 +179,7 @@ class t extends r {
|
|
|
170
179
|
rpcFunMap: void 0,
|
|
171
180
|
qyDB: void 0,
|
|
172
181
|
qyFileLogger: void 0
|
|
173
|
-
}),
|
|
182
|
+
}), O.log("Stopped."), this;
|
|
174
183
|
}
|
|
175
184
|
increaseChangeId() {
|
|
176
185
|
return this.qyKVData.increaseChangeId();
|
|
@@ -186,22 +195,22 @@ class t extends r {
|
|
|
186
195
|
return t && s.save(r, t), a.save(r, e, i, o);
|
|
187
196
|
}
|
|
188
197
|
getFile(r, e = this.rootDir) {
|
|
189
|
-
return r.isFile ? r :
|
|
198
|
+
return r.isFile ? r : x(r) ? e.getFile(r) : e.searchFile(r);
|
|
190
199
|
}
|
|
191
200
|
getDir(r, e = this.rootDir) {
|
|
192
|
-
return r.isDir ? r :
|
|
201
|
+
return r.isDir ? r : x(r) ? e.getSubdir(r) : e.searchSubdir(r);
|
|
193
202
|
}
|
|
194
203
|
getOrCreateFile(r, e = this.rootDir) {
|
|
195
|
-
return r.isFile ? r :
|
|
204
|
+
return r.isFile ? r : x(r) ? e.getOrCreateFile(r) : e.searchOrCreateFile(r);
|
|
196
205
|
}
|
|
197
206
|
getOrCreateDir(r, e = this.rootDir) {
|
|
198
|
-
return r.isDir ? r :
|
|
207
|
+
return r.isDir ? r : x(r) ? e.getOrCreateSubdir(r) : e.searchOrCreateSubdir(r);
|
|
199
208
|
}
|
|
200
209
|
getIndexDir(r) {
|
|
201
|
-
return this.indexRootDir.searchSubdir(
|
|
210
|
+
return this.indexRootDir.searchSubdir(y(r.fullPathHash));
|
|
202
211
|
}
|
|
203
212
|
getOrCreateIndexDir(r) {
|
|
204
|
-
return this.indexRootDir.searchOrCreateSubdir(
|
|
213
|
+
return this.indexRootDir.searchOrCreateSubdir(y(r.fullPathHash));
|
|
205
214
|
}
|
|
206
215
|
getTriggerFile(r) {
|
|
207
216
|
return this.triggerRootDir.getFile(r);
|
|
@@ -209,11 +218,11 @@ class t extends r {
|
|
|
209
218
|
getOrCreateTriggerFile(r) {
|
|
210
219
|
return this.triggerRootDir.getOrCreateFile(r);
|
|
211
220
|
}
|
|
212
|
-
getExpireInfoFile(r, e =
|
|
213
|
-
return this.expireRootDir.searchFile(
|
|
221
|
+
getExpireInfoFile(r, e = "c") {
|
|
222
|
+
return this.expireRootDir.searchFile(a(r, e));
|
|
214
223
|
}
|
|
215
|
-
getOrCreateExpireInfoFile(r, e =
|
|
216
|
-
return this.expireRootDir.searchOrCreateFile(
|
|
224
|
+
getOrCreateExpireInfoFile(r, e = "c") {
|
|
225
|
+
return this.expireRootDir.searchOrCreateFile(a(r, e));
|
|
217
226
|
}
|
|
218
227
|
get triggerFileList() {
|
|
219
228
|
return this.triggerRootDir.fileList;
|
|
@@ -227,45 +236,54 @@ class t extends r {
|
|
|
227
236
|
get rpcFileList() {
|
|
228
237
|
return this.rpcRootDir.fileList;
|
|
229
238
|
}
|
|
239
|
+
get metaFile() {
|
|
240
|
+
return this.rootDir.searchOrCreateFile(t);
|
|
241
|
+
}
|
|
230
242
|
insertTriggerToTree(r, e, t, i) {
|
|
231
243
|
var {
|
|
232
244
|
rootDir: o,
|
|
233
245
|
qyDB: a
|
|
234
|
-
} = this, i =
|
|
235
|
-
o.triggerNodes[0].insertTrigger(r, e, t, i),
|
|
246
|
+
} = this, i = c("trigger", r, i, a);
|
|
247
|
+
o.triggerNodes[0].insertTrigger(r, e, t, i), s(o, e);
|
|
236
248
|
}
|
|
237
249
|
removeTriggerFromTree(r, e) {
|
|
238
250
|
var t = this.rootDir;
|
|
239
|
-
t.triggerNodes[0].removeTrigger(r, e) &&
|
|
251
|
+
t.triggerNodes[0].removeTrigger(r, e) && s(t, e);
|
|
240
252
|
}
|
|
241
253
|
insertRpc(r, e) {
|
|
242
254
|
var {
|
|
243
255
|
rpcFunMap: t,
|
|
244
256
|
qyDB: i
|
|
245
|
-
} = this, e =
|
|
257
|
+
} = this, e = c("rpc", r, e, i);
|
|
246
258
|
e && (t[r] = e);
|
|
247
259
|
}
|
|
248
260
|
removeRpc(r) {
|
|
249
261
|
delete this.rpcFunMap[r];
|
|
250
262
|
}
|
|
251
263
|
queryFiles(r, e, t, i, o = this.rootDir) {
|
|
252
|
-
var a = [], t = (
|
|
253
|
-
return
|
|
264
|
+
var a = [], t = (x(e) && !t && (t = 1), new l(t, i)), i = this.options.queryAutoCreateIndex;
|
|
265
|
+
return w(r, e, a, t, o, i), a;
|
|
254
266
|
}
|
|
255
267
|
queryFilesMulti(r, e, t, i = this.rootDir) {
|
|
256
|
-
var o, a, s = [], n = new
|
|
257
|
-
for ([ o, a ] of r)
|
|
268
|
+
var o, a, s = [], n = new l(e, t), g = this.options.queryAutoCreateIndex;
|
|
269
|
+
for ([ o, a ] of r) w(o, a, s, n, i, g);
|
|
258
270
|
return s;
|
|
259
271
|
}
|
|
260
272
|
async callRpc(e, r, t) {
|
|
261
273
|
var i, o = this.rpcFunMap[e];
|
|
262
|
-
if (!o) return
|
|
274
|
+
if (!o) return O.warn(i = `RPC ${e} not implemented.`), new Error(i);
|
|
263
275
|
try {
|
|
264
276
|
return await o(r, t);
|
|
265
277
|
} catch (r) {
|
|
266
|
-
return
|
|
278
|
+
return O.error(`Calling RPC ${e} failed:`, r), r;
|
|
267
279
|
}
|
|
268
280
|
}
|
|
281
|
+
monitorItemExpire(r, e) {
|
|
282
|
+
this.qyKVData.monitorItemExpire(r, e);
|
|
283
|
+
}
|
|
284
|
+
unmonitorItemExpire(r) {
|
|
285
|
+
this.qyKVData.unmonitorItemExpire(r);
|
|
286
|
+
}
|
|
269
287
|
monitorContentExpire(r, e) {
|
|
270
288
|
this.qyKVData.monitorContentExpire(r, e);
|
|
271
289
|
}
|
|
@@ -274,18 +292,18 @@ class t extends r {
|
|
|
274
292
|
}
|
|
275
293
|
}
|
|
276
294
|
|
|
277
|
-
function
|
|
278
|
-
return [ e
|
|
295
|
+
function a(r, e) {
|
|
296
|
+
return [ e, r.substring(0, 2), r ];
|
|
279
297
|
}
|
|
280
298
|
|
|
281
|
-
function
|
|
299
|
+
function y(r) {
|
|
282
300
|
return [ r[0], r ];
|
|
283
301
|
}
|
|
284
302
|
|
|
285
|
-
function
|
|
286
|
-
e && (a = a ?
|
|
303
|
+
function w(r, e, t, i, o, a) {
|
|
304
|
+
e && (a = a ? n(e) : void 0, g(r, o, a, e, t, i));
|
|
287
305
|
}
|
|
288
306
|
|
|
289
307
|
export {
|
|
290
|
-
|
|
308
|
+
o as QyCache
|
|
291
309
|
};
|
package/src/QyDB.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ export declare class QyDB extends QyCD {
|
|
|
7
7
|
fetch: any;
|
|
8
8
|
batch: any;
|
|
9
9
|
_immediate: any;
|
|
10
|
+
creationTime: any;
|
|
10
11
|
constructor(rootFolder?: string, options?: {});
|
|
11
12
|
start(options?: {}): Promise<this>;
|
|
12
13
|
stop(): Promise<void>;
|
|
14
|
+
get age(): number;
|
|
15
|
+
get ageSecond(): number;
|
|
13
16
|
get currentBatch(): any;
|
|
14
17
|
createDir(namePath: string | string[]): QyDir;
|
|
15
18
|
createFile(namePath: string | string[]): QyFile;
|
package/src/QyDB.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "node:path";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
QyFetch as
|
|
6
|
+
QyFetch as i
|
|
7
7
|
} from "./QyFetch.js";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
|
-
QyBatch as
|
|
10
|
+
QyBatch as r
|
|
11
11
|
} from "./QyBatch.js";
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -24,25 +24,32 @@ import {
|
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
26
|
isNotNullObj as s,
|
|
27
|
-
__dirname as
|
|
27
|
+
__dirname as n,
|
|
28
|
+
getNowTime as c,
|
|
29
|
+
getNowRounded as h
|
|
28
30
|
} from "./QyUtils.js";
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
import {
|
|
33
|
+
logger as m
|
|
34
|
+
} from "./QyLogger.js";
|
|
35
|
+
|
|
36
|
+
let p = e(n, "../data/sampleDataFolder");
|
|
31
37
|
|
|
32
|
-
class
|
|
38
|
+
class l extends t {
|
|
33
39
|
rootFolder;
|
|
34
40
|
options;
|
|
35
41
|
fetch;
|
|
36
42
|
batch;
|
|
37
43
|
_immediate;
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
creationTime;
|
|
45
|
+
constructor(e = p, t) {
|
|
46
|
+
s(e) && (t = e, e = p), super(), this.options = {
|
|
40
47
|
...o("QyDB"),
|
|
41
48
|
...t
|
|
42
49
|
}, this.rootFolder = e;
|
|
43
|
-
for (let
|
|
50
|
+
for (let i of [ "createIndex", "delIndex", "insert", "put", "remove", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "expireFile", "expireDir", "expireContent", "expireFileM", "expireDirM", "expireContentM", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[i] = (...e) => {
|
|
44
51
|
var t = this.currentBatch;
|
|
45
|
-
return t[
|
|
52
|
+
return t[i].apply(t, e).run();
|
|
46
53
|
};
|
|
47
54
|
}
|
|
48
55
|
async start(e) {
|
|
@@ -50,28 +57,36 @@ class n extends t {
|
|
|
50
57
|
return this.qyCache || (e = {
|
|
51
58
|
...this.options,
|
|
52
59
|
...e
|
|
53
|
-
}, t = new a(this.rootFolder, e, this), Object.assign(this, {
|
|
60
|
+
}, t = new a(this.rootFolder, e, this), e = (Object.assign(this, {
|
|
54
61
|
qyCache: t,
|
|
55
|
-
fetch: new
|
|
56
|
-
batch: new
|
|
57
|
-
_immediate: new
|
|
58
|
-
}), await t.start()), this
|
|
62
|
+
fetch: new i(t),
|
|
63
|
+
batch: new r(t, e),
|
|
64
|
+
_immediate: new r(t, e)
|
|
65
|
+
}), await t.start(), t).metaFile, e.created ? this.creationTime = e.fileContent.creationTime : this.insert(e, {
|
|
66
|
+
creationTime: this.creationTime = h()
|
|
67
|
+
}, !0), m.log("CreationTime:" + new Date(this.creationTime))), this;
|
|
59
68
|
}
|
|
60
69
|
async stop() {
|
|
61
70
|
var {
|
|
62
71
|
qyCache: e,
|
|
63
72
|
fetch: t,
|
|
64
|
-
batch:
|
|
65
|
-
_immediate:
|
|
73
|
+
batch: i,
|
|
74
|
+
_immediate: r
|
|
66
75
|
} = this;
|
|
67
|
-
e && (await e.stop(), t && (t.qyCache = void 0),
|
|
68
|
-
|
|
76
|
+
e && (await e.stop(), t && (t.qyCache = void 0), i && (i.qyCache = void 0),
|
|
77
|
+
r && (r.qyCache = void 0), Object.assign(this, {
|
|
69
78
|
qyCache: void 0,
|
|
70
79
|
fetch: void 0,
|
|
71
80
|
batch: void 0,
|
|
72
81
|
_immediate: void 0
|
|
73
82
|
}));
|
|
74
83
|
}
|
|
84
|
+
get age() {
|
|
85
|
+
return c() - this.creationTime;
|
|
86
|
+
}
|
|
87
|
+
get ageSecond() {
|
|
88
|
+
return Math.floor(this.age / 1e3);
|
|
89
|
+
}
|
|
75
90
|
get currentBatch() {
|
|
76
91
|
var {
|
|
77
92
|
batch: e,
|
|
@@ -88,11 +103,11 @@ class n extends t {
|
|
|
88
103
|
on(e, t) {
|
|
89
104
|
return this.qyCache?.on(e, t);
|
|
90
105
|
}
|
|
91
|
-
callRpc(e, t,
|
|
92
|
-
return this.qyCache?.callRpc(e, t,
|
|
106
|
+
callRpc(e, t, i = void 0) {
|
|
107
|
+
return this.qyCache?.callRpc(e, t, i);
|
|
93
108
|
}
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
export {
|
|
97
|
-
|
|
112
|
+
l as QyDB
|
|
98
113
|
};
|
package/src/QyDefaultOptions.js
CHANGED
package/src/QyDir.d.ts
CHANGED
|
@@ -45,4 +45,5 @@ export declare class QyDir extends QyItem {
|
|
|
45
45
|
filterSubdirNames(filterFun: any): Generator<QyDir, void, unknown>;
|
|
46
46
|
compareSubdirRangeL2H(cmpFun: any): Generator<QyDir, void, unknown>;
|
|
47
47
|
compareSubdirRangeH2L(cmpFun: any): Generator<QyDir | undefined, void, unknown>;
|
|
48
|
+
ensureAllLoaded(): this;
|
|
48
49
|
}
|
package/src/QyDir.js
CHANGED
|
@@ -6,14 +6,19 @@ import {
|
|
|
6
6
|
getSubdirMapKey as i,
|
|
7
7
|
getFileMapKey as t,
|
|
8
8
|
SpecialFilePaths as r,
|
|
9
|
-
isString as d
|
|
9
|
+
isString as d,
|
|
10
|
+
getNowTime as l
|
|
10
11
|
} from "./QyUtils.js";
|
|
11
12
|
|
|
12
13
|
import {
|
|
13
|
-
QyFile as
|
|
14
|
+
QyFile as a
|
|
14
15
|
} from "./QyFile.js";
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
import {
|
|
18
|
+
handleExpiredItem as o
|
|
19
|
+
} from "./QyExpire.js";
|
|
20
|
+
|
|
21
|
+
let s = r.HiddenFolderName;
|
|
17
22
|
|
|
18
23
|
class u extends e {
|
|
19
24
|
_subdirCount = 0;
|
|
@@ -35,10 +40,10 @@ class u extends e {
|
|
|
35
40
|
++i.subdirMapChangeCount);
|
|
36
41
|
}
|
|
37
42
|
get fileCount() {
|
|
38
|
-
return
|
|
43
|
+
return f(this), this._fileCount;
|
|
39
44
|
}
|
|
40
45
|
get subdirCount() {
|
|
41
|
-
return
|
|
46
|
+
return n(this), this._subdirCount;
|
|
42
47
|
}
|
|
43
48
|
get isDir() {
|
|
44
49
|
return !0;
|
|
@@ -47,7 +52,7 @@ class u extends e {
|
|
|
47
52
|
return 0 == this.fileCount && 0 == this.subdirCount;
|
|
48
53
|
}
|
|
49
54
|
get isHiddenFolder() {
|
|
50
|
-
return this.name ==
|
|
55
|
+
return this.name == s;
|
|
51
56
|
}
|
|
52
57
|
get subdirMapKey() {
|
|
53
58
|
return this._subdirMapKey || (this._subdirMapKey = i(this.fullPathHash));
|
|
@@ -56,10 +61,10 @@ class u extends e {
|
|
|
56
61
|
return this._fileMapKey || (this._fileMapKey = t(this.fullPathHash));
|
|
57
62
|
}
|
|
58
63
|
get subdirMap() {
|
|
59
|
-
return
|
|
64
|
+
return n(this), this._subdirMap;
|
|
60
65
|
}
|
|
61
66
|
get fileMap() {
|
|
62
|
-
return
|
|
67
|
+
return f(this), this._fileMap;
|
|
63
68
|
}
|
|
64
69
|
getSubdir(e) {
|
|
65
70
|
var i;
|
|
@@ -85,7 +90,7 @@ class u extends e {
|
|
|
85
90
|
getOrCreateFile(e, i = !1) {
|
|
86
91
|
let t = this.fileMap;
|
|
87
92
|
var r = (t = t || (this._fileMap = {}))[e];
|
|
88
|
-
return r || (r = t[e] = new
|
|
93
|
+
return r || (r = t[e] = new a(e, i, this), this.setChildTriggerNodes(r)),
|
|
89
94
|
r;
|
|
90
95
|
}
|
|
91
96
|
searchSubdir(i, t = i.length) {
|
|
@@ -187,6 +192,10 @@ class u extends e {
|
|
|
187
192
|
} else if (i(a)) yield s, r = !0; else if (r) return;
|
|
188
193
|
}
|
|
189
194
|
}
|
|
195
|
+
ensureAllLoaded() {
|
|
196
|
+
for (var e of this.allFiles()) e.ensureLoaded();
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
190
199
|
}
|
|
191
200
|
|
|
192
201
|
function h(e, i, t, r) {
|
|
@@ -194,34 +203,54 @@ function h(e, i, t, r) {
|
|
|
194
203
|
return e[i] && e[s] == t || (e[i] = r(), e[s] = t), e[i];
|
|
195
204
|
}
|
|
196
205
|
|
|
197
|
-
function
|
|
198
|
-
if (e.created && !e.
|
|
206
|
+
function n(e) {
|
|
207
|
+
if (e.created && !e.subdirMapLoaded) {
|
|
199
208
|
e.subdirMapLoaded = !0;
|
|
200
209
|
var i = e.qyCache;
|
|
201
210
|
if (i) {
|
|
202
|
-
|
|
203
|
-
if (
|
|
204
|
-
var
|
|
205
|
-
for (
|
|
211
|
+
var t = i.qyKVData.getValueSync(e.subdirMapKey);
|
|
212
|
+
if (t) {
|
|
213
|
+
var r, s = e._subdirMap || (e._subdirMap = {});
|
|
214
|
+
for (r in t) r in s || (s[r] = new u(r, !0, e));
|
|
215
|
+
e.underHiddenFolder || p(e, i, "d");
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
218
|
}
|
|
209
219
|
}
|
|
210
220
|
|
|
211
|
-
function
|
|
221
|
+
function f(e) {
|
|
212
222
|
if (e.created && !e._fileMap && !e.fileMapLoaded) {
|
|
213
223
|
e.fileMapLoaded = !0;
|
|
214
224
|
var i = e.qyCache;
|
|
215
225
|
if (i) {
|
|
216
|
-
|
|
217
|
-
if (
|
|
218
|
-
var
|
|
219
|
-
for (
|
|
226
|
+
var t = i.qyKVData.getValueSync(e.fileMapKey);
|
|
227
|
+
if (t) {
|
|
228
|
+
var r, s = e._fileMap = {};
|
|
229
|
+
for (r in t) s[r] = new a(r, !0, e);
|
|
230
|
+
e.underHiddenFolder || p(e, i, "f");
|
|
220
231
|
}
|
|
221
232
|
}
|
|
222
233
|
}
|
|
223
234
|
}
|
|
224
235
|
|
|
236
|
+
function p(e, i, t) {
|
|
237
|
+
if ("d" == t) {
|
|
238
|
+
if (e.dExpireChecked) return;
|
|
239
|
+
e.dExpireChecked = !0;
|
|
240
|
+
} else {
|
|
241
|
+
if (e.fExpireChecked) return;
|
|
242
|
+
e.fExpireChecked = !0;
|
|
243
|
+
}
|
|
244
|
+
var r = i.getExpireInfoFile(e.fullPathHash, t);
|
|
245
|
+
if (r) {
|
|
246
|
+
var s, a = r.fileContent, d = l(), u = i.qyDB;
|
|
247
|
+
for (s in a) {
|
|
248
|
+
var h = "d" == t ? e.getOrCreateSubdir(s) : e.getOrCreateFile(s), n = a[s];
|
|
249
|
+
n <= d ? o(u, h) : i.monitorItemExpire(h, n);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
225
254
|
export {
|
|
226
255
|
u as QyDir
|
|
227
256
|
};
|
package/src/QyExpire.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
import { QyMessager } from "./QyMessager.ts";
|
|
2
|
-
export declare const WholeFileProp = "[\"\"]";
|
|
3
2
|
export declare class QyExpire extends QyMessager {
|
|
4
3
|
qyCache: any;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
startTime: any;
|
|
4
|
+
expireMap: {};
|
|
5
|
+
roundedStartTime: any;
|
|
8
6
|
constructor(qyCache: any, options?: any);
|
|
9
|
-
|
|
7
|
+
monitorItemExpire(item: any, expireAbsTime: any): void;
|
|
8
|
+
unmonitorItemExpire(item: any): void;
|
|
9
|
+
monitorContentExpire(file: any, flattedAbsTimeObj: any): void;
|
|
10
10
|
unmonitorContentExpire(file: any, flattedDelObj: any): void;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onContentExpired(expiredInfoMap: any): void;
|
|
11
|
+
onEmptyHashList(emptyHashList: any): void;
|
|
12
|
+
onExpired(hashExpiredInfoMap: any): void;
|
|
14
13
|
}
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
expiredProps: any[];
|
|
18
|
-
remainingExpireInfoObj: {};
|
|
19
|
-
toDeleteFile: any;
|
|
20
|
-
};
|
|
21
|
-
export declare function handleExpiredProps(qyDB: any, file: any, expiredProps: any, toDeleteFile: any): void;
|
|
14
|
+
export declare function handleExpiredItem(qyDB: any, item: any): void;
|
|
15
|
+
export declare function handleExpiredProps(qyDB: any, file: any, expiredProps: any): void;
|