datafolder 1.0.19 → 1.0.20

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/src/QyBatch.js CHANGED
@@ -1,32 +1,32 @@
1
1
  import {
2
- isDeepStrictEqual as c
2
+ isDeepStrictEqual as h
3
3
  } from "node:util";
4
4
 
5
5
  import {
6
- mergeContentAndGenDelta as o,
6
+ mergeContentAndGenDelta as s,
7
7
  objToDelMarks as r
8
8
  } from "./QyFileContentUtils.js";
9
9
 
10
10
  import {
11
- pathSplit as s,
11
+ pathSplit as o,
12
12
  ensurePropNamePathList as n,
13
13
  isString as l,
14
14
  SpecialOperators as e,
15
15
  getSuffix as f,
16
16
  SpecialFilePaths as t,
17
- toSingleName as C,
18
- isSimpleType as h,
19
- isEmptyObj as d,
17
+ toSingleName as p,
18
+ isSimpleType as c,
19
+ isEmptyObj as m,
20
20
  isNumber as a,
21
- getNowRounded as m,
21
+ getNowRounded as d,
22
22
  isDate as u,
23
23
  isArray as g,
24
- isFloat32Array as p
24
+ isFloat32Array as C
25
25
  } from "./QyUtils.js";
26
26
 
27
27
  import {
28
28
  QyAclCmdGenerator as i,
29
- CmdNames as y
29
+ CmdNames as _
30
30
  } from "./QyAcl.js";
31
31
 
32
32
  import {
@@ -34,7 +34,7 @@ import {
34
34
  } from "./QyIndex.js";
35
35
 
36
36
  import {
37
- getDefaultOptions as _
37
+ getDefaultOptions as y
38
38
  } from "./QyDefaultOptions.js";
39
39
 
40
40
  import {
@@ -67,7 +67,7 @@ class Q extends D {
67
67
  running;
68
68
  constructor(e, t) {
69
69
  super(e), t = {
70
- ..._("QyBatch"),
70
+ ...y("QyBatch"),
71
71
  ...t
72
72
  };
73
73
  e = L[t.fileLogLevel.toLowerCase()];
@@ -82,22 +82,22 @@ class Q extends D {
82
82
  });
83
83
  }
84
84
  createDir(e, t = this.currentDir) {
85
- return l(e) && (e = s(e)), q(this, "createDir", {
85
+ return l(e) && (e = o(e)), q(this, this._action_createDir, {
86
86
  item: this.qyCache.getOrCreateDir(e, t)
87
87
  });
88
88
  }
89
89
  delDir(e, t = this.currentDir) {
90
- return l(e) && (e = s(e)), q(this, "delDir", {
90
+ return l(e) && (e = o(e)), q(this, this._action_delDir, {
91
91
  item: this.qyCache.getOrCreateDir(e, t).ensureAllLoaded()
92
92
  });
93
93
  }
94
94
  createFile(e, t = this.currentDir) {
95
- return l(e) && (e = s(e)), q(this, "createFile", {
95
+ return l(e) && (e = o(e)), q(this, this._action_createFile, {
96
96
  item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
97
97
  });
98
98
  }
99
99
  delFile(e, t = this.currentDir) {
100
- return l(e) && (e = s(e)), q(this, "delFile", {
100
+ return l(e) && (e = o(e)), q(this, this._action_delFile, {
101
101
  item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
102
102
  });
103
103
  }
@@ -114,9 +114,9 @@ class Q extends D {
114
114
  return T(this, e, t, "d", i);
115
115
  }
116
116
  expireContent(e, t, i, r = this.currentDir) {
117
- l(e) && (e = s(e));
117
+ l(e) && (e = o(e));
118
118
  e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
119
- return q(this, "expireContent", {
119
+ return q(this, this._action_expireContent, {
120
120
  item: e,
121
121
  expireInfoObj: t,
122
122
  isMilliSecond: i
@@ -132,50 +132,50 @@ class Q extends D {
132
132
  return M(this, e, "d", t, i);
133
133
  }
134
134
  removeContentExpire(e, t, i = !1, r = this.currentDir) {
135
- l(e) && (e = s(e));
135
+ l(e) && (e = o(e));
136
136
  e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
137
- return q(this, "removeContentExpire", {
137
+ return q(this, this._action_removeContentExpire, {
138
138
  item: e,
139
139
  expireInfoObj: t,
140
140
  infoFileOnly: i
141
141
  });
142
142
  }
143
143
  createIndex(e, t, i = this.currentDir) {
144
- l(e) && (e = s(e)), g(t) || (t = [ t ]);
144
+ l(e) && (e = o(e)), g(t) || (t = [ t ]);
145
145
  e = this.qyCache.getOrCreateDir(e, i);
146
- return q(this, "createIndex", {
146
+ return q(this, this._action_createIndex, {
147
147
  item: e,
148
148
  indexPropPathList: t
149
149
  });
150
150
  }
151
151
  delIndex(e, t, i = this.currentDir) {
152
- l(e) && (e = s(e));
152
+ l(e) && (e = o(e));
153
153
  e = this.qyCache.getOrCreateDir(e, i);
154
- return q(this, "delIndex", {
154
+ return q(this, this._action_delIndex, {
155
155
  item: e,
156
156
  indexPropPath: t
157
157
  });
158
158
  }
159
159
  insert(e, t, i = !1, r = !1, n = this.currentDir) {
160
- l(e) && (e = s(e));
160
+ l(e) && (e = o(e));
161
161
  e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
162
- return q(this, "insert", {
162
+ return t = i || c(t) ? t : structuredClone(t), q(this, this._action_insert, {
163
163
  item: e,
164
- content: t = i || h(t) ? t : structuredClone(t),
164
+ content: t,
165
165
  noCreate: r
166
166
  });
167
167
  }
168
168
  insertEmbedding(e, t, i = this.currentDir) {
169
- var r = this.qyCache, r = (p(t) || (t = new Float32Array(t)), l(e) && (e = s(e)),
169
+ var r = this.qyCache, r = (C(t) || (t = new Float32Array(t)), l(e) && (e = o(e)),
170
170
  r.getOrCreateFile(e, i));
171
- return q(this, "insertEmbedding", {
171
+ return q(this, this._action_insertEmbedding, {
172
172
  item: r,
173
173
  embedding: t
174
174
  });
175
175
  }
176
176
  delEmbedding(e, t = this.currentDir) {
177
- var i = this.qyCache, i = (l(e) && (e = s(e)), i.getOrCreateFile(e, t));
178
- return q(this, "delEmbedding", {
177
+ var i = this.qyCache, i = (l(e) && (e = o(e)), i.getOrCreateFile(e, t));
178
+ return q(this, this._action_delEmbedding, {
179
179
  item: i
180
180
  });
181
181
  }
@@ -185,22 +185,25 @@ class Q extends D {
185
185
  remove(e, t, i = this.currentDir) {
186
186
  return this.insert(e, r(t), !0, !0, i);
187
187
  }
188
- put(e, t, i = !1, r = this.currentDir) {
189
- return this.insert(e, {
190
- $rpl: t
191
- }, i, !1, r);
188
+ put(e, t, i = this.currentDir) {
189
+ l(e) && (e = o(e));
190
+ e = this.qyCache.getOrCreateFile(e, i).ensureLoaded();
191
+ return q(this, this._action_put, {
192
+ item: e,
193
+ content: t
194
+ });
192
195
  }
193
196
  delContent(e, t = this.currentDir) {
194
- l(e) && (e = s(e));
197
+ l(e) && (e = o(e));
195
198
  e = this.qyCache.getOrCreateFile(e, t).ensureLoaded();
196
- return q(this, "delContent", {
199
+ return q(this, this._action_delContent, {
197
200
  item: e
198
201
  });
199
202
  }
200
203
  insertTrigger(e, t, i, r) {
201
- l(t) && (t = s(t)), i = n(i);
204
+ l(t) && (t = o(t)), i = n(i);
202
205
  e = this.qyCache.getOrCreateTriggerFile(e);
203
- return q(this, "insertTrigger", {
206
+ return q(this, this._action_insertTrigger, {
204
207
  item: e,
205
208
  fileNamePath: t,
206
209
  propNamePathList: i,
@@ -208,19 +211,19 @@ class Q extends D {
208
211
  });
209
212
  }
210
213
  removeTrigger(e) {
211
- return q(this, "removeTrigger", {
214
+ return q(this, this._action_removeTrigger, {
212
215
  item: this.qyCache.getOrCreateTriggerFile(e)
213
216
  });
214
217
  }
215
218
  insertRpc(e, t) {
216
219
  e = this.qyCache.getOrCreateRpcFile(e);
217
- return q(this, "insertRpc", {
220
+ return q(this, this._action_insertRpc, {
218
221
  item: e,
219
222
  modCode: t
220
223
  });
221
224
  }
222
225
  removeRpc(e) {
223
- return q(this, "removeRpc", {
226
+ return q(this, this._action_removeRpc, {
224
227
  item: this.qyCache.getOrCreateRpcFile(e)
225
228
  });
226
229
  }
@@ -234,31 +237,31 @@ class Q extends D {
234
237
  if (t || 0 == i.length) return 0;
235
238
  this.running = !0;
236
239
  var a, t = this.changeId = n.increaseChangeId();
237
- for (a of i) this["_action_" + a.actionName](a);
240
+ for (a of i) a.actionFun.call(this, a);
238
241
  i.length = 0, this.running = !1, this.resetCurrentDir();
239
242
  var {
240
243
  changeList: i,
241
- qyAclCmdGenerator: s,
242
- qyCmdObjHistory: o,
244
+ qyAclCmdGenerator: o,
245
+ qyCmdObjHistory: s,
243
246
  syncList: l
244
247
  } = this, c = i.length;
245
248
  if (0 == c) return n.decreaseChangeId(), 0;
246
- var h = f(c), s = s.takeCmdArgAsListObj();
249
+ var h = f(c), o = o.takeCmdArgAsListObj();
247
250
  let d;
248
251
  0 < r && (r = i.map(({
249
252
  logStr: e
250
253
  }) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
251
254
  ${r}
252
255
  `);
253
- var m, u, c = n.save(t, s, d, (e => {
256
+ var m, u, c = n.save(t, o, d, (e => {
254
257
  var t = e.syncList, i = t.length;
255
258
  for (let e = 0; e < i; e += 2) {
256
- var r, n = e + 1, a = t[e], s = t[n];
257
- a.startsWith("d") ? (r = s.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = s.fileNameList,
258
- t[n] = 0 < r.length ? r : void 0) : t[n] = s.fileContent;
259
+ var r, n = e + 1, a = t[e], o = t[n];
260
+ a.startsWith("d") ? (r = o.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = o.fileNameList,
261
+ t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
259
262
  }
260
263
  if (0 < i) return t;
261
- })(this), e), h = (l.length = 0, o.push(s), i.filter(({
264
+ })(this), e), h = (l.length = 0, s.push(o), i.filter(({
262
265
  item: e,
263
266
  delta: t
264
267
  }) => t && 0 < e.triggerNodes?.length));
@@ -281,12 +284,12 @@ ${r}
281
284
  modCode: n
282
285
  } = e, {
283
286
  name: a,
284
- fileContent: s
285
- } = e, s = s && s[0], e = this._action_insert({
287
+ fileContent: o
288
+ } = e, o = o && o[0], e = this._action_insert({
286
289
  item: e,
287
290
  content: [ i, r, n ]
288
291
  });
289
- return e && (t = this.qyCache, s && !c(s, i) && t.removeTriggerFromTree(a, s),
292
+ return e && (t = this.qyCache, o && !h(o, i) && t.removeTriggerFromTree(a, o),
290
293
  t.insertTriggerToTree(a, i, r, n)), e;
291
294
  }
292
295
  _action_removeTrigger(e) {
@@ -324,21 +327,21 @@ ${r}
324
327
  indexPropPathList: i
325
328
  } = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(b), {
326
329
  fileContent: a,
327
- qyIndexPropTree: s
330
+ qyIndexPropTree: o
328
331
  } = (n.created || this._action_createFile({
329
332
  item: n
330
- }), n), o = [], l = {};
333
+ }), n), s = [], l = {};
331
334
  for (e of i) {
332
- var c = C(e);
333
- a && a[c] || (o.push(e), l[c] = 1, s.insert(e));
335
+ var c = p(e);
336
+ a && a[c] || (s.push(e), l[c] = 1, o.insert(e));
334
337
  }
335
- if (0 != o.length) {
336
- F.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath), this._action_insert({
338
+ if (0 != s.length) {
339
+ F.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
337
340
  item: n,
338
341
  content: l
339
342
  });
340
343
  {
341
- var h, d = this, m = t, u = r, i = x(o);
344
+ var h, d = this, m = t, u = r, i = x(s);
342
345
  let e;
343
346
  for (h of i) {
344
347
  var g = u.searchOrCreateSubdir(h);
@@ -349,9 +352,9 @@ ${r}
349
352
  for (var f of e = e || m.fileList) {
350
353
  var {
351
354
  fileContent: f,
352
- name: p
355
+ name: C
353
356
  } = f;
354
- null != f && E(d, g, h, p, void 0, f);
357
+ null != f && E(d, g, h, C, void 0, f);
355
358
  }
356
359
  }
357
360
  }
@@ -367,7 +370,7 @@ ${r}
367
370
  e && ((i = e.getFile(b)) ? (t = i.qyIndexPropTree, this._action_insert({
368
371
  item: i,
369
372
  content: {
370
- [C(r)]: O
373
+ [p(r)]: O
371
374
  }
372
375
  }), t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
373
376
  item: i
@@ -386,7 +389,7 @@ ${r}
386
389
  parentDir: r,
387
390
  name: n
388
391
  } = i;
389
- return i.created = !1, N(this, e), t || I(this, r, y.R, r.fileMapKey, n),
392
+ return i.created = !1, N(this, e), t || I(this, r, _.R, r.fileMapKey, n),
390
393
  !0;
391
394
  }
392
395
  _action_delDir(e) {
@@ -398,17 +401,17 @@ ${r}
398
401
  name: r,
399
402
  subdirMap: n,
400
403
  fileMap: a,
401
- subdirMapKey: s,
402
- fileMapKey: o
404
+ subdirMapKey: o,
405
+ fileMapKey: s
403
406
  } = t;
404
407
  if (a) {
405
- I(this, t, y.D, o);
408
+ I(this, t, _.D, s);
406
409
  for (var l of t.fileList) this._action_delFile({
407
410
  item: l
408
411
  }, !0);
409
412
  }
410
413
  if (n) {
411
- I(this, t, y.D, s);
414
+ I(this, t, _.D, o);
412
415
  for (var c of t.allSubdirs()) {
413
416
  let {
414
417
  subdirMap: e,
@@ -416,8 +419,8 @@ ${r}
416
419
  subdirMapKey: i,
417
420
  fileMapKey: r
418
421
  } = c;
419
- if (e && I(this, c, y.D, i), t) {
420
- I(this, c, y.D, r);
422
+ if (e && I(this, c, _.D, i), t) {
423
+ I(this, c, _.D, r);
421
424
  for (var h of c.fileList) this._action_delFile({
422
425
  item: h
423
426
  }, !0);
@@ -428,7 +431,7 @@ ${r}
428
431
  }), c.created = !1;
429
432
  }
430
433
  }
431
- return !!i && (t.created = !1, N(this, e), I(this, i, y.R, i.subdirMapKey, r),
434
+ return !!i && (t.created = !1, N(this, e), I(this, i, _.R, i.subdirMapKey, r),
432
435
  !0);
433
436
  }
434
437
  _action_delContent(e) {
@@ -440,42 +443,58 @@ ${r}
440
443
  oldValue: i,
441
444
  newValue: O
442
445
  }
443
- }), N(this, e), I(this, t, y.D, t.fileContentKey), P(this, t, i), !0);
446
+ }), N(this, e), I(this, t, _.D, t.fileContentKey), P(this, t, i), !0);
444
447
  }
445
448
  _action_insertEmbedding(e) {
446
449
  e.actionName = "insertEmbedding";
447
450
  var t, i, r = this.qyCache, n = r.qyEmbeddings, {
448
- item: e,
449
- embedding: a
450
- } = e, s = a.length, r = r.getOrCreateInfoFile(e), o = r.fileContent;
451
- let l = !1;
452
- return r.created && o.length == s ? (t = e.fullPathHash, o = o.idx, i = n.getEmbedding(t, s, o),
453
- c(a, i) || ((i = n.updateEmbedding(t, a, o)) != o && this._action_insert({
451
+ item: a,
452
+ embedding: o
453
+ } = e, s = o.length, r = r.getOrCreateInfoFile(a), l = r.fileContent;
454
+ let c = !1;
455
+ return r.created && l.length == s ? (t = a.fullPathHash, l = l.idx, i = n.getEmbedding(t, s, l),
456
+ h(o, i) || ((i = n.updateEmbedding(t, o, l)) != l && this._action_insert({
454
457
  item: r,
455
458
  content: {
456
459
  idx: i
457
460
  }
458
- }), l = !0)) : ({
461
+ }), c = !0)) : ({
459
462
  fullPathHash: t,
460
- namePath: o
461
- } = e, i = n.addEmbedding(t, a), this._action_insert({
463
+ namePath: l
464
+ } = a, i = n.addEmbedding(t, o), this._action_insert({
462
465
  item: r,
463
466
  content: {
464
467
  length: s,
465
468
  idx: i,
466
- namePath: r.created ? void 0 : o
469
+ namePath: r.created ? void 0 : l
467
470
  }
468
- }), l = !0), l, l;
471
+ }), c = !0), c && N(this, e), c;
469
472
  }
470
473
  _action_delEmbedding(e) {
471
474
  e.actionName = "delEmbedding";
472
- var t = this.qyCache, i = t.qyEmbeddings, e = e.item;
473
- let r, n;
474
- var a, t = t.getInfoFile(e);
475
- if (t && (a = t.fileContent, a) && (r = a.length, n = a.idx), i.delEmbedding(e.fullPathHash, r, n),
475
+ var t = this.qyCache, i = t.qyEmbeddings, r = e.item;
476
+ let n, a;
477
+ var o, t = t.getInfoFile(r);
478
+ if (t && (o = t.fileContent, o) && (n = o.length, a = o.idx), i.delEmbedding(r.fullPathHash, n, a),
476
479
  t) return this._action_delFile({
477
480
  item: t
478
- }), !0;
481
+ }), N(this, e), !0;
482
+ }
483
+ _action_put(e) {
484
+ e.actionName = "put";
485
+ var {
486
+ item: t,
487
+ content: i
488
+ } = e;
489
+ if (null == i) return F.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
490
+ !1;
491
+ t.created || this._action_createFile({
492
+ item: t
493
+ });
494
+ var r = t.fileContentKey;
495
+ return I(this, t, _.M, r, {
496
+ $rpl: i
497
+ }), N(this, e), t.fileContent = i, !0;
479
498
  }
480
499
  _action_insert(e) {
481
500
  e.actionName = "insert";
@@ -492,15 +511,15 @@ ${r}
492
511
  item: t
493
512
  });
494
513
  }
495
- var n, a, r = o(t.fileContent, i), {
514
+ var n, a, r = s(t.fileContent, i), {
496
515
  merged: i,
497
- delta: s
516
+ delta: o
498
517
  } = r;
499
- return !!s && ({
500
- oldValue: s,
518
+ return !!o && ({
519
+ oldValue: o,
501
520
  newValue: n
502
- } = s, !!n) && (a = t.fileContentKey, null == i ? I(this, t, y.D, a) : I(this, t, y.M, a, n),
503
- Object.assign(e, r), N(this, e), t.fileContent = i, P(this, t, s, n, i),
521
+ } = o, !!n) && (a = t.fileContentKey, null == i ? I(this, t, _.D, a) : I(this, t, _.M, a, n),
522
+ Object.assign(e, r), N(this, e), t.fileContent = i, P(this, t, o, n, i),
504
523
  !0);
505
524
  }
506
525
  _action_createFile(e) {
@@ -511,7 +530,7 @@ ${r}
511
530
  }), Object.assign(i, {
512
531
  created: !0,
513
532
  fileContentLoaded: !0
514
- }), N(this, e), I(this, t, y.A, t.fileMapKey, i.name), !0);
533
+ }), N(this, e), I(this, t, _.A, t.fileMapKey, i.name), !0);
515
534
  }
516
535
  _action_createDir(e) {
517
536
  e.actionName = "createDir";
@@ -528,7 +547,7 @@ ${r}
528
547
  item: e
529
548
  });
530
549
  var r = e.parentDir;
531
- I(this, r, y.A, r.subdirMapKey, e.name);
550
+ I(this, r, _.A, r.subdirMapKey, e.name);
532
551
  }
533
552
  return !0;
534
553
  }
@@ -541,7 +560,7 @@ ${r}
541
560
  parentDir: r,
542
561
  name: n
543
562
  } = e;
544
- return !!r && null != (i = S(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
563
+ return !!r && null != (i = S(i, !0, d())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
545
564
  (r = this._action_insert({
546
565
  item: r,
547
566
  content: {
@@ -563,7 +582,7 @@ ${r}
563
582
  content: {
564
583
  [n]: O
565
584
  }
566
- })) && (d(r.fileContent) && this._action_delFile({
585
+ })) && (m(r.fileContent) && this._action_delFile({
567
586
  item: r
568
587
  }), i || t.unmonitorItemExpire(e)), n);
569
588
  }
@@ -573,14 +592,14 @@ ${r}
573
592
  item: t,
574
593
  expireInfoObj: i,
575
594
  isMilliSecond: r
576
- } = e, n = m();
577
- var e = j(i, e => S(e, r, n)), a = this.qyCache, s = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), s = this._action_insert({
578
- item: s,
595
+ } = e, n = d();
596
+ var e = j(i, e => S(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
597
+ item: o,
579
598
  content: {
580
599
  ...e
581
600
  }
582
601
  });
583
- return s && a.monitorContentExpire(t, e), s;
602
+ return o && a.monitorContentExpire(t, e), o;
584
603
  }
585
604
  _action_removeContentExpire(e) {
586
605
  e.actionName = "removeContentExpire";
@@ -593,14 +612,14 @@ ${r}
593
612
  (t = this._action_insert({
594
613
  item: a,
595
614
  content: i
596
- })) && (d(a.fileContent) && this._action_delFile({
615
+ })) && (m(a.fileContent) && this._action_delFile({
597
616
  item: a
598
617
  }), r || n.unmonitorContentExpire(e, i)), t);
599
618
  }
600
619
  }
601
620
 
602
621
  function q(e, t, i) {
603
- return e.running ? e["_action_" + t](i) : (i.actionName = t, e.actionQueue.push(i)),
622
+ return e.running ? t.call(e, i) : (i.actionFun = t, e.actionQueue.push(i)),
604
623
  e;
605
624
  }
606
625
 
@@ -632,42 +651,53 @@ function I(e, t, i, r, n = void 0) {
632
651
  var {
633
652
  qyAclCmdGenerator: e,
634
653
  qyCache: a,
635
- syncList: s,
636
- changeId: o
654
+ syncList: o,
655
+ changeId: s
637
656
  } = e;
638
- e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = o : r.startsWith("f") ? t.fChangeId = o : t.cChangeId = o,
639
- a && a.qyKVData.removeKey(r) && s.push(r, t);
657
+ e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = s : r.startsWith("f") ? t.fChangeId = s : t.cChangeId = s,
658
+ a && a.qyKVData.removeKey(r) && o.push(r, t);
640
659
  }
641
660
 
642
661
  function P(e, t, i, r = void 0, n = void 0) {
643
662
  var {
644
663
  underHiddenFolder: t,
645
664
  name: a,
646
- parentDir: s
665
+ parentDir: o
647
666
  } = t;
648
667
  if (!t) {
649
- var o = e.qyCache.getIndexDir(s);
650
- if (o) {
651
- t = o.getFile(b);
652
- if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, o.searchOrCreateSubdir(l), l, a, i, r, n);
668
+ var s = e.qyCache.getIndexDir(o);
669
+ if (s) {
670
+ t = s.getFile(b);
671
+ if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
653
672
  }
654
673
  }
655
674
  }
656
675
 
657
- function E(t, e, i, r, n, a, s = void 0) {
658
- e = v(e, i, r, n, a, s);
676
+ function E(t, e, i, r, n, a, o = void 0) {
677
+ e = v(e, i, n, a, o);
659
678
  if (e) {
660
- var o, l, c, {
679
+ var s, l, c, {
661
680
  toAddFileList: i,
662
- toDelFileList: r
681
+ toDelFileList: n
663
682
  } = e;
664
- for (o of i) t._action_createFile({
665
- item: o
666
- });
667
- for (l of r) t._action_delFile({
668
- item: l
669
- });
670
- for (c of r) {
683
+ for (s of i) {
684
+ var h = s.fileContent ?? {};
685
+ h[r] = 1, t._action_put({
686
+ item: s,
687
+ content: h
688
+ });
689
+ }
690
+ for (l of n) {
691
+ var d = l.fileContent;
692
+ null != d && Object.hasOwn(d, r) && (delete d[r], t._action_put({
693
+ item: l,
694
+ content: d
695
+ }));
696
+ }
697
+ for (c of n) if (m(c.fileContent)) {
698
+ t._action_delFile({
699
+ item: c
700
+ });
671
701
  let e = c.parentDir;
672
702
  for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
673
703
  item: e
@@ -705,12 +735,12 @@ class A {
705
735
  }
706
736
 
707
737
  function j(e, t = void 0, i = [], r = {}) {
708
- if (h(e)) {
738
+ if (c(e)) {
709
739
  var n = t ? t(e) : e;
710
740
  null != n && (r[JSON.stringify(i)] = n);
711
741
  } else {
712
- var a, s = i.length;
713
- for (a in e) i.push(a), j(e[a], t, i, r), i.length = s;
742
+ var a, o = i.length;
743
+ for (a in e) i.push(a), j(e[a], t, i, r), i.length = o;
714
744
  }
715
745
  return r;
716
746
  }
@@ -720,16 +750,16 @@ function S(e, t, i) {
720
750
  }
721
751
 
722
752
  function T(e, t, i, r, n) {
723
- var a = e.qyCache, r = (l(t) && (t = s(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
724
- return q(e, "expireItem", {
753
+ var a = e.qyCache, r = (l(t) && (t = o(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
754
+ return q(e, e._action_expireItem, {
725
755
  item: r,
726
756
  milliSecond: i
727
757
  });
728
758
  }
729
759
 
730
760
  function M(e, t, i, r, n) {
731
- var a = e.qyCache, i = (l(t) && (t = s(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
732
- return q(e, "removeItemExpire", {
761
+ var a = e.qyCache, i = (l(t) && (t = o(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
762
+ return q(e, e._action_removeItemExpire, {
733
763
  item: i,
734
764
  infoFileOnly: r
735
765
  });
package/src/QyDir.d.ts CHANGED
@@ -22,7 +22,7 @@ export declare class QyDir extends QyItem {
22
22
  get subdirMap(): {};
23
23
  get fileMap(): {};
24
24
  getSubdir(name: string): QyDir | undefined;
25
- getFile(fileName: string): QyFile | undefined;
25
+ getFile(fileName: string | number): QyFile | undefined;
26
26
  getOrCreateSubdir(name: string, created?: boolean): QyDir;
27
27
  getOrCreateFile(fileName: string, created?: boolean): QyFile;
28
28
  searchSubdir(namePath: string[], endIdx?: number): QyDir | undefined;
@@ -43,7 +43,7 @@ export declare class QyDir extends QyItem {
43
43
  allLoadedSubdirs(): any;
44
44
  setChildTriggerNodes(child: QyDir): void;
45
45
  filterSubdirNames(filterFun: any): Generator<QyDir, void, unknown>;
46
- compareSubdirRangeL2H(cmpFun: any): Generator<QyDir, void, unknown>;
47
- compareSubdirRangeH2L(cmpFun: any): Generator<QyDir | undefined, void, unknown>;
46
+ filterFileNames(filterFun: any): Generator<QyFile, void, unknown>;
47
+ compareItemRange(cmpFun: any, isFile?: boolean, reverse?: boolean): Generator<QyDir | QyFile | undefined, void, unknown>;
48
48
  ensureAllLoaded(): this;
49
49
  }