datafolder 1.0.17 → 1.0.18
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 +7 -0
- package/package.json +17 -17
- package/sample.js +3 -0
- package/src/QyAcl.js +109 -87
- package/src/QyBatch.d.ts +4 -0
- package/src/QyBatch.js +150 -107
- package/src/QyBinaryHeap.d.ts +10 -0
- package/src/QyBinaryHeap.js +55 -0
- package/src/QyCD.d.ts +3 -0
- package/src/QyCD.js +68 -57
- package/src/QyCache.d.ts +8 -0
- package/src/QyCache.js +108 -70
- package/src/QyDB.js +4 -4
- package/src/QyFile.js +8 -7
- package/src/QyFileContentUtils.d.ts +0 -1
- package/src/QyFileContentUtils.js +123 -124
- package/src/QyHNSW.d.ts +10 -0
- package/src/QyHNSW.js +57 -0
- package/src/QyIndex.js +28 -27
- package/src/QyIndexPropTree.js +3 -1
- package/src/QySnapshots.js +209 -206
- package/src/QyTrigger.js +5 -6
- package/src/QyUtils.d.ts +5 -0
- package/src/QyUtils.js +108 -98
- package/static/codemirror.bundle/editor.bundle.js +17 -3
- package/test/testQyDocumentDB.js +38 -0
package/src/QyBatch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isDeepStrictEqual as
|
|
2
|
+
isDeepStrictEqual as o
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -8,52 +8,55 @@ import {
|
|
|
8
8
|
} from "./QyFileContentUtils.js";
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
pathSplit as
|
|
11
|
+
pathSplit as s,
|
|
12
12
|
ensurePropNamePathList as n,
|
|
13
13
|
isString as c,
|
|
14
14
|
SpecialOperators as e,
|
|
15
15
|
getSuffix as g,
|
|
16
16
|
SpecialFilePaths as t,
|
|
17
|
-
toSingleName as
|
|
17
|
+
toSingleName as p,
|
|
18
18
|
isSimpleType as h,
|
|
19
19
|
isEmptyObj as d,
|
|
20
20
|
isNumber as a,
|
|
21
|
-
getNowRounded as m
|
|
21
|
+
getNowRounded as m,
|
|
22
|
+
isDate as u,
|
|
23
|
+
isArray as f,
|
|
24
|
+
isFloat32Array as C
|
|
22
25
|
} from "./QyUtils.js";
|
|
23
26
|
|
|
24
27
|
import {
|
|
25
28
|
QyAclCmdGenerator as i,
|
|
26
|
-
CmdNames as
|
|
29
|
+
CmdNames as y
|
|
27
30
|
} from "./QyAcl.js";
|
|
28
31
|
|
|
29
32
|
import {
|
|
30
|
-
calDifferenceList as
|
|
33
|
+
calDifferenceList as v
|
|
31
34
|
} from "./QyIndex.js";
|
|
32
35
|
|
|
33
36
|
import {
|
|
34
|
-
getDefaultOptions as
|
|
37
|
+
getDefaultOptions as _
|
|
35
38
|
} from "./QyDefaultOptions.js";
|
|
36
39
|
|
|
37
40
|
import {
|
|
38
|
-
QyCD as
|
|
41
|
+
QyCD as D
|
|
39
42
|
} from "./QyCD.js";
|
|
40
43
|
|
|
41
44
|
import {
|
|
42
|
-
getPrefixPropPaths as
|
|
45
|
+
getPrefixPropPaths as x
|
|
43
46
|
} from "./QyIndexPropTree.js";
|
|
44
47
|
|
|
45
48
|
import {
|
|
46
|
-
logger as
|
|
49
|
+
logger as F
|
|
47
50
|
} from "./QyLogger.js";
|
|
48
51
|
|
|
49
|
-
let
|
|
52
|
+
let O = e.$del, L = t.IndexPropPathsFileName, q = {
|
|
50
53
|
none: 0,
|
|
51
54
|
basic: 1,
|
|
52
55
|
delta: 2,
|
|
53
56
|
all: 3
|
|
54
57
|
};
|
|
55
58
|
|
|
56
|
-
class
|
|
59
|
+
class Q extends D {
|
|
57
60
|
fileLogLevel;
|
|
58
61
|
actionQueue;
|
|
59
62
|
changeId;
|
|
@@ -64,46 +67,46 @@ class L extends v {
|
|
|
64
67
|
running;
|
|
65
68
|
constructor(e, t) {
|
|
66
69
|
super(e), t = {
|
|
67
|
-
...
|
|
70
|
+
..._("QyBatch"),
|
|
68
71
|
...t
|
|
69
72
|
};
|
|
70
|
-
e =
|
|
73
|
+
e = q[t.fileLogLevel.toLowerCase()];
|
|
71
74
|
Object.assign(this, {
|
|
72
75
|
options: t,
|
|
73
76
|
fileLogLevel: e ?? 1,
|
|
74
77
|
qyAclCmdGenerator: new i(),
|
|
75
|
-
qyCmdObjHistory: new
|
|
78
|
+
qyCmdObjHistory: new H(t.maxHistoryCmdObjCount),
|
|
76
79
|
actionQueue: [],
|
|
77
80
|
changeList: [],
|
|
78
81
|
syncList: []
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
84
|
createDir(e, t = this.currentDir) {
|
|
82
|
-
return c(e) && (e =
|
|
85
|
+
return c(e) && (e = s(e)), N(this, "createDir", this.qyCache.getOrCreateDir(e, t));
|
|
83
86
|
}
|
|
84
87
|
delDir(e, t = this.currentDir) {
|
|
85
|
-
return c(e) && (e =
|
|
88
|
+
return c(e) && (e = s(e)), N(this, "delDir", this.qyCache.getOrCreateDir(e, t).ensureAllLoaded());
|
|
86
89
|
}
|
|
87
90
|
createFile(e, t = this.currentDir) {
|
|
88
|
-
return c(e) && (e =
|
|
91
|
+
return c(e) && (e = s(e)), N(this, "createFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
89
92
|
}
|
|
90
93
|
delFile(e, t = this.currentDir) {
|
|
91
|
-
return c(e) && (e =
|
|
94
|
+
return c(e) && (e = s(e)), N(this, "delFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
92
95
|
}
|
|
93
96
|
expireFile(e, t, i = this.currentDir) {
|
|
94
97
|
return this.expireFileM(e, 1e3 * t, i);
|
|
95
98
|
}
|
|
96
99
|
expireFileM(e, t, i = this.currentDir) {
|
|
97
|
-
return
|
|
100
|
+
return T(this, e, t, "f", i);
|
|
98
101
|
}
|
|
99
102
|
expireDir(e, t, i = this.currentDir) {
|
|
100
103
|
return this.expireDirM(e, 1e3 * t, i);
|
|
101
104
|
}
|
|
102
105
|
expireDirM(e, t, i = this.currentDir) {
|
|
103
|
-
return
|
|
106
|
+
return T(this, e, t, "d", i);
|
|
104
107
|
}
|
|
105
108
|
expireContent(e, t, i, r = this.currentDir) {
|
|
106
|
-
c(e) && (e =
|
|
109
|
+
c(e) && (e = s(e));
|
|
107
110
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
108
111
|
return N(this, "expireContent", e, {
|
|
109
112
|
expireInfoObj: t,
|
|
@@ -114,13 +117,13 @@ class L extends v {
|
|
|
114
117
|
return this.expireContent(e, t, !0, i);
|
|
115
118
|
}
|
|
116
119
|
removeFileExpire(e, t = !1, i = this.currentDir) {
|
|
117
|
-
return
|
|
120
|
+
return M(this, e, "f", t, i);
|
|
118
121
|
}
|
|
119
122
|
removeDirExpire(e, t = !1, i = this.currentDir) {
|
|
120
|
-
return
|
|
123
|
+
return M(this, e, "d", t, i);
|
|
121
124
|
}
|
|
122
125
|
removeContentExpire(e, t, i = !1, r = this.currentDir) {
|
|
123
|
-
c(e) && (e =
|
|
126
|
+
c(e) && (e = s(e));
|
|
124
127
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
125
128
|
return N(this, "removeContentExpire", e, {
|
|
126
129
|
expireInfoObj: t,
|
|
@@ -128,23 +131,36 @@ class L extends v {
|
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
createIndex(e, t, i = this.currentDir) {
|
|
131
|
-
return c(e) && (e =
|
|
134
|
+
return c(e) && (e = s(e)), f(t) || (t = [ t ]), N(this, "createIndex", this.qyCache.getOrCreateDir(e, i), {
|
|
132
135
|
indexPropPathList: t
|
|
133
136
|
});
|
|
134
137
|
}
|
|
135
138
|
delIndex(e, t, i = this.currentDir) {
|
|
136
|
-
return c(e) && (e =
|
|
139
|
+
return c(e) && (e = s(e)), N(this, "delIndex", this.qyCache.getOrCreateDir(e, i), {
|
|
137
140
|
indexPropPath: t
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
143
|
insert(e, t, i = !1, r = !1, n = this.currentDir) {
|
|
141
|
-
c(e) && (e =
|
|
144
|
+
c(e) && (e = s(e));
|
|
142
145
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
143
146
|
return N(this, "insert", e, {
|
|
144
147
|
content: i || h(t) ? t : structuredClone(t),
|
|
145
148
|
noCreate: r
|
|
146
149
|
});
|
|
147
150
|
}
|
|
151
|
+
insertEmbedding(e, t, i = this.currentDir) {
|
|
152
|
+
var r = this.qyCache, e = (c(e) && (e = s(e)), r.getOrCreateFile(e, i));
|
|
153
|
+
return N(this, "insertEmbedding", r.getOrCreateEmbeddingFile(e.fullPathHash), {
|
|
154
|
+
content: C(t) ? t : new Float32Array(t),
|
|
155
|
+
srcFile: e
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
delEmbedding(e, t = this.currentDir) {
|
|
159
|
+
var i = this.qyCache, e = (c(e) && (e = s(e)), i.getOrCreateFile(e, t));
|
|
160
|
+
return N(this, "delEmbedding", i.getOrCreateEmbeddingFile(e.fullPathHash), {
|
|
161
|
+
srcFile: e
|
|
162
|
+
});
|
|
163
|
+
}
|
|
148
164
|
remove(e, t, i = this.currentDir) {
|
|
149
165
|
return this.insert(e, r(t), !0, !0, i);
|
|
150
166
|
}
|
|
@@ -154,10 +170,10 @@ class L extends v {
|
|
|
154
170
|
}, i, !1, r);
|
|
155
171
|
}
|
|
156
172
|
delContent(e, t = this.currentDir) {
|
|
157
|
-
return c(e) && (e =
|
|
173
|
+
return c(e) && (e = s(e)), N(this, "delContent", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
158
174
|
}
|
|
159
175
|
insertTrigger(e, t, i, r) {
|
|
160
|
-
return c(t) && (t =
|
|
176
|
+
return c(t) && (t = s(t)), i = n(i), N(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
|
|
161
177
|
fileNamePath: t,
|
|
162
178
|
propNamePathList: i,
|
|
163
179
|
modCode: r
|
|
@@ -188,27 +204,27 @@ class L extends v {
|
|
|
188
204
|
i.length = 0, this.running = !1, this.resetCurrentDir();
|
|
189
205
|
var {
|
|
190
206
|
changeList: i,
|
|
191
|
-
qyAclCmdGenerator:
|
|
192
|
-
qyCmdObjHistory:
|
|
207
|
+
qyAclCmdGenerator: s,
|
|
208
|
+
qyCmdObjHistory: o,
|
|
193
209
|
syncList: l
|
|
194
210
|
} = this, c = i.length;
|
|
195
211
|
if (0 == c) return n.decreaseChangeId(), 0;
|
|
196
|
-
var h = g(c),
|
|
212
|
+
var h = g(c), s = s.takeCmdArgAsListObj();
|
|
197
213
|
let d;
|
|
198
214
|
0 < r && (r = i.map(({
|
|
199
215
|
logStr: e
|
|
200
216
|
}) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
|
|
201
217
|
${r}
|
|
202
218
|
`);
|
|
203
|
-
var m, u, c = n.save(t,
|
|
219
|
+
var m, u, c = n.save(t, s, d, (e => {
|
|
204
220
|
var t = e.syncList, i = t.length;
|
|
205
221
|
for (let e = 0; e < i; e += 2) {
|
|
206
|
-
var r, n = e + 1, a = t[e],
|
|
207
|
-
a.startsWith("d") ? (r =
|
|
208
|
-
t[n] = 0 < r.length ? r : void 0) : t[n] =
|
|
222
|
+
var r, n = e + 1, a = t[e], s = t[n];
|
|
223
|
+
a.startsWith("d") ? (r = s.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = s.fileNameList,
|
|
224
|
+
t[n] = 0 < r.length ? r : void 0) : t[n] = s.fileContent;
|
|
209
225
|
}
|
|
210
226
|
if (0 < i) return t;
|
|
211
|
-
})(this), e), h = (l.length = 0,
|
|
227
|
+
})(this), e), h = (l.length = 0, o.push(s), i.filter(({
|
|
212
228
|
item: e,
|
|
213
229
|
delta: t
|
|
214
230
|
}) => t && 0 < e.triggerNodes?.length));
|
|
@@ -231,12 +247,12 @@ ${r}
|
|
|
231
247
|
modCode: n
|
|
232
248
|
} = e, {
|
|
233
249
|
name: a,
|
|
234
|
-
fileContent:
|
|
235
|
-
} = e,
|
|
250
|
+
fileContent: s
|
|
251
|
+
} = e, s = s && s[0], e = this._action_insert({
|
|
236
252
|
item: e,
|
|
237
253
|
content: [ i, r, n ]
|
|
238
254
|
});
|
|
239
|
-
return e && (t = this.qyCache,
|
|
255
|
+
return e && (t = this.qyCache, s && !o(s, i) && t.removeTriggerFromTree(a, s),
|
|
240
256
|
t.insertTriggerToTree(a, i, r, n)), e;
|
|
241
257
|
}
|
|
242
258
|
_action_removeTrigger(e) {
|
|
@@ -272,23 +288,23 @@ ${r}
|
|
|
272
288
|
var e, {
|
|
273
289
|
item: t,
|
|
274
290
|
indexPropPathList: i
|
|
275
|
-
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(
|
|
291
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(L), {
|
|
276
292
|
fileContent: a,
|
|
277
|
-
qyIndexPropTree:
|
|
293
|
+
qyIndexPropTree: s
|
|
278
294
|
} = (n.created || this._action_createFile({
|
|
279
295
|
item: n
|
|
280
|
-
}), n),
|
|
296
|
+
}), n), o = [], l = {};
|
|
281
297
|
for (e of i) {
|
|
282
|
-
var c =
|
|
283
|
-
a && a[c] || (
|
|
298
|
+
var c = p(e);
|
|
299
|
+
a && a[c] || (o.push(e), l[c] = 1, s.insert(e));
|
|
284
300
|
}
|
|
285
|
-
if (0 !=
|
|
286
|
-
|
|
301
|
+
if (0 != o.length) {
|
|
302
|
+
F.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath), this._action_insert({
|
|
287
303
|
item: n,
|
|
288
304
|
content: l
|
|
289
305
|
});
|
|
290
306
|
{
|
|
291
|
-
var h, d = this, m = t, u = r, i =
|
|
307
|
+
var h, d = this, m = t, u = r, i = x(o);
|
|
292
308
|
let e;
|
|
293
309
|
for (h of i) {
|
|
294
310
|
var f = u.searchOrCreateSubdir(h);
|
|
@@ -299,9 +315,9 @@ ${r}
|
|
|
299
315
|
for (var g of e = e || m.fileList) {
|
|
300
316
|
var {
|
|
301
317
|
fileContent: g,
|
|
302
|
-
name:
|
|
318
|
+
name: C
|
|
303
319
|
} = g;
|
|
304
|
-
null != g &&
|
|
320
|
+
null != g && E(d, f, h, C, void 0, g);
|
|
305
321
|
}
|
|
306
322
|
}
|
|
307
323
|
}
|
|
@@ -314,10 +330,10 @@ ${r}
|
|
|
314
330
|
item: e,
|
|
315
331
|
indexPropPath: r
|
|
316
332
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
317
|
-
e && ((i = e.getFile(
|
|
333
|
+
e && ((i = e.getFile(L)) ? (t = i.qyIndexPropTree, this._action_insert({
|
|
318
334
|
item: i,
|
|
319
335
|
content: {
|
|
320
|
-
[
|
|
336
|
+
[p(r)]: O
|
|
321
337
|
}
|
|
322
338
|
}), t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
|
|
323
339
|
item: i
|
|
@@ -336,7 +352,7 @@ ${r}
|
|
|
336
352
|
parentDir: r,
|
|
337
353
|
name: n
|
|
338
354
|
} = i;
|
|
339
|
-
return i.created = !1,
|
|
355
|
+
return i.created = !1, b(this, e), t || P(this, r, y.R, r.fileMapKey, n),
|
|
340
356
|
!0;
|
|
341
357
|
}
|
|
342
358
|
_action_delDir(e) {
|
|
@@ -348,17 +364,17 @@ ${r}
|
|
|
348
364
|
name: r,
|
|
349
365
|
subdirMap: n,
|
|
350
366
|
fileMap: a,
|
|
351
|
-
subdirMapKey:
|
|
352
|
-
fileMapKey:
|
|
367
|
+
subdirMapKey: s,
|
|
368
|
+
fileMapKey: o
|
|
353
369
|
} = t;
|
|
354
370
|
if (a) {
|
|
355
|
-
|
|
371
|
+
P(this, t, y.D, o);
|
|
356
372
|
for (var l of t.fileList) this._action_delFile({
|
|
357
373
|
item: l
|
|
358
374
|
}, !0);
|
|
359
375
|
}
|
|
360
376
|
if (n) {
|
|
361
|
-
|
|
377
|
+
P(this, t, y.D, s);
|
|
362
378
|
for (var c of t.allSubdirs()) {
|
|
363
379
|
let {
|
|
364
380
|
subdirMap: e,
|
|
@@ -366,19 +382,19 @@ ${r}
|
|
|
366
382
|
subdirMapKey: i,
|
|
367
383
|
fileMapKey: r
|
|
368
384
|
} = c;
|
|
369
|
-
if (e &&
|
|
370
|
-
|
|
385
|
+
if (e && P(this, c, y.D, i), t) {
|
|
386
|
+
P(this, c, y.D, r);
|
|
371
387
|
for (var h of c.fileList) this._action_delFile({
|
|
372
388
|
item: h
|
|
373
389
|
}, !0);
|
|
374
390
|
}
|
|
375
|
-
|
|
391
|
+
b(this, {
|
|
376
392
|
actionName: "delDir",
|
|
377
393
|
item: c
|
|
378
394
|
}), c.created = !1;
|
|
379
395
|
}
|
|
380
396
|
}
|
|
381
|
-
return !!i && (t.created = !1,
|
|
397
|
+
return !!i && (t.created = !1, b(this, e), P(this, i, y.R, i.subdirMapKey, r),
|
|
382
398
|
!0);
|
|
383
399
|
}
|
|
384
400
|
_action_delContent(e) {
|
|
@@ -388,9 +404,36 @@ ${r}
|
|
|
388
404
|
content: i,
|
|
389
405
|
delta: {
|
|
390
406
|
oldValue: i,
|
|
391
|
-
newValue:
|
|
407
|
+
newValue: O
|
|
392
408
|
}
|
|
393
|
-
}),
|
|
409
|
+
}), b(this, e), P(this, t, y.D, t.fileContentKey), I(this, t, i), !0);
|
|
410
|
+
}
|
|
411
|
+
_action_insertEmbedding(e) {
|
|
412
|
+
e.actionName = "insertEmbedding";
|
|
413
|
+
var {
|
|
414
|
+
item: e,
|
|
415
|
+
content: t,
|
|
416
|
+
srcFile: i
|
|
417
|
+
} = e, i = (this._action_insert({
|
|
418
|
+
item: this.qyCache.getOrCreateH2FFile(i.fullPathHash),
|
|
419
|
+
content: i.namePath
|
|
420
|
+
}), this._action_insert({
|
|
421
|
+
item: e,
|
|
422
|
+
content: t
|
|
423
|
+
}));
|
|
424
|
+
return i;
|
|
425
|
+
}
|
|
426
|
+
_action_delEmbedding(e) {
|
|
427
|
+
e.actionName = "delEmbedding";
|
|
428
|
+
var {
|
|
429
|
+
item: e,
|
|
430
|
+
srcFile: t
|
|
431
|
+
} = e, e = this._action_delFile({
|
|
432
|
+
item: e
|
|
433
|
+
});
|
|
434
|
+
return e && this._action_delFile({
|
|
435
|
+
item: this.qyCache.getOrCreateH2FFile(t.fullPathHash)
|
|
436
|
+
}), e;
|
|
394
437
|
}
|
|
395
438
|
_action_insert(e) {
|
|
396
439
|
e.actionName = "insert";
|
|
@@ -399,7 +442,7 @@ ${r}
|
|
|
399
442
|
content: i,
|
|
400
443
|
noCreate: r
|
|
401
444
|
} = e;
|
|
402
|
-
if (null == i) return
|
|
445
|
+
if (null == i) return F.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
403
446
|
!1;
|
|
404
447
|
if (!t.created) {
|
|
405
448
|
if (r) return !1;
|
|
@@ -409,13 +452,13 @@ ${r}
|
|
|
409
452
|
}
|
|
410
453
|
var n, a, r = l(t.fileContent, i), {
|
|
411
454
|
merged: i,
|
|
412
|
-
delta:
|
|
455
|
+
delta: s
|
|
413
456
|
} = r;
|
|
414
|
-
return !!
|
|
415
|
-
oldValue:
|
|
457
|
+
return !!s && ({
|
|
458
|
+
oldValue: s,
|
|
416
459
|
newValue: n
|
|
417
|
-
} =
|
|
418
|
-
Object.assign(e, r),
|
|
460
|
+
} = s, !!n) && (a = t.fileContentKey, null == i ? P(this, t, y.D, a) : P(this, t, y.M, a, n),
|
|
461
|
+
Object.assign(e, r), b(this, e), t.fileContent = i, I(this, t, s, n, i),
|
|
419
462
|
!0);
|
|
420
463
|
}
|
|
421
464
|
_action_createFile(e) {
|
|
@@ -426,7 +469,7 @@ ${r}
|
|
|
426
469
|
}), Object.assign(i, {
|
|
427
470
|
created: !0,
|
|
428
471
|
fileContentLoaded: !0
|
|
429
|
-
}),
|
|
472
|
+
}), b(this, e), P(this, t, y.A, t.fileMapKey, i.name), !0);
|
|
430
473
|
}
|
|
431
474
|
_action_createDir(e) {
|
|
432
475
|
e.actionName = "createDir";
|
|
@@ -438,12 +481,12 @@ ${r}
|
|
|
438
481
|
created: !0,
|
|
439
482
|
subdirMapLoaded: !0,
|
|
440
483
|
fileMapLoaded: !0
|
|
441
|
-
}),
|
|
484
|
+
}), b(this, {
|
|
442
485
|
actionName: "createDir",
|
|
443
486
|
item: e
|
|
444
487
|
});
|
|
445
488
|
var r = e.parentDir;
|
|
446
|
-
|
|
489
|
+
P(this, r, y.A, r.subdirMapKey, e.name);
|
|
447
490
|
}
|
|
448
491
|
return !0;
|
|
449
492
|
}
|
|
@@ -456,7 +499,7 @@ ${r}
|
|
|
456
499
|
parentDir: r,
|
|
457
500
|
name: n
|
|
458
501
|
} = e;
|
|
459
|
-
return !!r && null != (i =
|
|
502
|
+
return !!r && null != (i = S(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
|
|
460
503
|
(r = this._action_insert({
|
|
461
504
|
item: r,
|
|
462
505
|
content: {
|
|
@@ -476,7 +519,7 @@ ${r}
|
|
|
476
519
|
return !!r && (t = this.qyCache, !!(r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
|
|
477
520
|
item: r,
|
|
478
521
|
content: {
|
|
479
|
-
[n]:
|
|
522
|
+
[n]: O
|
|
480
523
|
}
|
|
481
524
|
})) && (d(r.fileContent) && this._action_delFile({
|
|
482
525
|
item: r
|
|
@@ -489,13 +532,13 @@ ${r}
|
|
|
489
532
|
expireInfoObj: i,
|
|
490
533
|
isMilliSecond: r
|
|
491
534
|
} = e, n = m();
|
|
492
|
-
var e =
|
|
493
|
-
item:
|
|
535
|
+
var e = j(i, e => S(e, r, n)), a = this.qyCache, s = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), s = this._action_insert({
|
|
536
|
+
item: s,
|
|
494
537
|
content: {
|
|
495
538
|
...e
|
|
496
539
|
}
|
|
497
540
|
});
|
|
498
|
-
return
|
|
541
|
+
return s && a.monitorContentExpire(t, e), s;
|
|
499
542
|
}
|
|
500
543
|
_action_removeContentExpire(e) {
|
|
501
544
|
e.actionName = "removeContentExpire";
|
|
@@ -504,7 +547,7 @@ ${r}
|
|
|
504
547
|
expireInfoObj: i,
|
|
505
548
|
infoFileOnly: r
|
|
506
549
|
} = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
507
|
-
return !!a && (i =
|
|
550
|
+
return !!a && (i = f(i) ? Object.fromEntries(i.map(e => [ e, O ])) : j(i, e => e ? O : void 0),
|
|
508
551
|
(t = this._action_insert({
|
|
509
552
|
item: a,
|
|
510
553
|
content: i
|
|
@@ -522,7 +565,7 @@ function N(e, t, i, r) {
|
|
|
522
565
|
}), e;
|
|
523
566
|
}
|
|
524
567
|
|
|
525
|
-
function
|
|
568
|
+
function b(e, t) {
|
|
526
569
|
var {
|
|
527
570
|
changeList: e,
|
|
528
571
|
fileLogLevel: i
|
|
@@ -546,41 +589,41 @@ function I(e, t) {
|
|
|
546
589
|
})(t, i)), e.push(t);
|
|
547
590
|
}
|
|
548
591
|
|
|
549
|
-
function
|
|
592
|
+
function P(e, t, i, r, n = void 0) {
|
|
550
593
|
var {
|
|
551
594
|
qyAclCmdGenerator: e,
|
|
552
595
|
qyCache: a,
|
|
553
|
-
syncList:
|
|
554
|
-
changeId:
|
|
596
|
+
syncList: s,
|
|
597
|
+
changeId: o
|
|
555
598
|
} = e;
|
|
556
|
-
e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId =
|
|
557
|
-
a && a.qyKVData.removeKey(r) &&
|
|
599
|
+
e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = o : r.startsWith("f") ? t.fChangeId = o : t.cChangeId = o,
|
|
600
|
+
a && a.qyKVData.removeKey(r) && s.push(r, t);
|
|
558
601
|
}
|
|
559
602
|
|
|
560
|
-
function
|
|
603
|
+
function I(e, t, i, r = void 0, n = void 0) {
|
|
561
604
|
var {
|
|
562
605
|
underHiddenFolder: t,
|
|
563
606
|
name: a,
|
|
564
|
-
parentDir:
|
|
607
|
+
parentDir: s
|
|
565
608
|
} = t;
|
|
566
609
|
if (!t) {
|
|
567
|
-
var
|
|
568
|
-
if (
|
|
569
|
-
t =
|
|
570
|
-
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths())
|
|
610
|
+
var o = e.qyCache.getIndexDir(s);
|
|
611
|
+
if (o) {
|
|
612
|
+
t = o.getFile(L);
|
|
613
|
+
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, o.searchOrCreateSubdir(l), l, a, i, r, n);
|
|
571
614
|
}
|
|
572
615
|
}
|
|
573
616
|
}
|
|
574
617
|
|
|
575
|
-
function
|
|
576
|
-
e =
|
|
618
|
+
function E(t, e, i, r, n, a, s = void 0) {
|
|
619
|
+
e = v(e, i, r, n, a, s);
|
|
577
620
|
if (e) {
|
|
578
|
-
var
|
|
621
|
+
var o, l, c, {
|
|
579
622
|
toAddFileList: i,
|
|
580
623
|
toDelFileList: r
|
|
581
624
|
} = e;
|
|
582
|
-
for (
|
|
583
|
-
item:
|
|
625
|
+
for (o of i) t._action_createFile({
|
|
626
|
+
item: o
|
|
584
627
|
});
|
|
585
628
|
for (l of r) t._action_delFile({
|
|
586
629
|
item: l
|
|
@@ -594,7 +637,7 @@ function b(t, e, i, r, n, a, o = void 0) {
|
|
|
594
637
|
}
|
|
595
638
|
}
|
|
596
639
|
|
|
597
|
-
class
|
|
640
|
+
class H {
|
|
598
641
|
maxLength;
|
|
599
642
|
actionQueue;
|
|
600
643
|
nextPos;
|
|
@@ -622,35 +665,35 @@ class j {
|
|
|
622
665
|
}
|
|
623
666
|
}
|
|
624
667
|
|
|
625
|
-
function
|
|
668
|
+
function j(e, t = void 0, i = [], r = {}) {
|
|
626
669
|
if (h(e)) {
|
|
627
670
|
var n = t ? t(e) : e;
|
|
628
671
|
null != n && (r[JSON.stringify(i)] = n);
|
|
629
672
|
} else {
|
|
630
|
-
var a,
|
|
631
|
-
for (a in e) i.push(a),
|
|
673
|
+
var a, s = i.length;
|
|
674
|
+
for (a in e) i.push(a), j(e[a], t, i, r), i.length = s;
|
|
632
675
|
}
|
|
633
676
|
return r;
|
|
634
677
|
}
|
|
635
678
|
|
|
636
|
-
function
|
|
637
|
-
return a(e) ? (t ? e : 1e3 * e) + i : c(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !(e
|
|
679
|
+
function S(e, t, i) {
|
|
680
|
+
return a(e) ? (t ? e : 1e3 * e) + i : c(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !u(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
638
681
|
}
|
|
639
682
|
|
|
640
|
-
function
|
|
641
|
-
var a = e.qyCache, r = (c(t) && (t =
|
|
683
|
+
function T(e, t, i, r, n) {
|
|
684
|
+
var a = e.qyCache, r = (c(t) && (t = s(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
642
685
|
return N(e, "expireItem", r, {
|
|
643
686
|
milliSecond: i
|
|
644
687
|
});
|
|
645
688
|
}
|
|
646
689
|
|
|
647
|
-
function
|
|
648
|
-
var a = e.qyCache, i = (c(t) && (t =
|
|
690
|
+
function M(e, t, i, r, n) {
|
|
691
|
+
var a = e.qyCache, i = (c(t) && (t = s(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
649
692
|
return N(e, "removeItemExpire", i, {
|
|
650
693
|
infoFileOnly: r
|
|
651
694
|
});
|
|
652
695
|
}
|
|
653
696
|
|
|
654
697
|
export {
|
|
655
|
-
|
|
698
|
+
Q as QyBatch
|
|
656
699
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class t {
|
|
2
|
+
items = [];
|
|
3
|
+
cmpFun;
|
|
4
|
+
constructor(t = (t, e) => t - e) {
|
|
5
|
+
this.cmpFun = t;
|
|
6
|
+
}
|
|
7
|
+
get size() {
|
|
8
|
+
return this.items.length;
|
|
9
|
+
}
|
|
10
|
+
get isEmpty() {
|
|
11
|
+
return 0 == this.items.length;
|
|
12
|
+
}
|
|
13
|
+
peek() {
|
|
14
|
+
return this.items[0];
|
|
15
|
+
}
|
|
16
|
+
push(t) {
|
|
17
|
+
var e = this.items;
|
|
18
|
+
e.push(t), i(this);
|
|
19
|
+
}
|
|
20
|
+
pop() {
|
|
21
|
+
if (!this.isEmpty) {
|
|
22
|
+
for (var t = this.items, e = t[0], [ t, i = 0 ] = (t[0] = t.at(-1),
|
|
23
|
+
--t.length, [ this ]), {
|
|
24
|
+
items: s,
|
|
25
|
+
cmpFun: r
|
|
26
|
+
} = t, h = s.length; i < h; ) {
|
|
27
|
+
var n = 2 * i + 1;
|
|
28
|
+
if (!(n < h)) break;
|
|
29
|
+
{
|
|
30
|
+
let t = i;
|
|
31
|
+
0 < r(s[n], s[t]) && (t = n);
|
|
32
|
+
n = 1 + n;
|
|
33
|
+
if ((t = n < h && 0 < r(s[n], s[t]) ? n : t) == i) break;
|
|
34
|
+
[ s[i], s[t] ] = [ s[t], s[i] ], i = t;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function i(t, e = t.items.length - 1) {
|
|
43
|
+
for (var {
|
|
44
|
+
items: i,
|
|
45
|
+
cmpFun: s
|
|
46
|
+
} = t; 0 < e; ) {
|
|
47
|
+
var r = Math.floor((e - 1) / 2);
|
|
48
|
+
if (!(0 < s(i[e], i[r]))) break;
|
|
49
|
+
[ i[e], i[r] ] = [ i[r], i[e] ], e = r;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
t as QyBinaryHeap
|
|
55
|
+
};
|