datafolder 1.0.30 → 1.0.32
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/ChangeLog.md +2 -0
- package/package.json +4 -4
- package/scripts/fastify.js +4 -3
- package/scripts/flights2.js +31 -13
- package/src/QyAcl.js +4 -4
- package/src/QyBatch.d.ts +7 -4
- package/src/QyBatch.js +169 -181
- package/src/QyBinWriter.js +6 -6
- package/src/QyCD.js +36 -36
- package/src/QyCache.js +38 -39
- package/src/QyDB.js +2 -2
- package/src/QyDefaultOptions.js +1 -1
- package/src/QyDir.js +4 -4
- package/src/QyEmbeddingWriter.js +1 -1
- package/src/QyEmbeddings.js +1 -1
- package/src/QyExpire.d.ts +1 -1
- package/src/QyExpire.js +3 -3
- package/src/QyExpire_Worker.js +37 -35
- package/src/QyFile.js +22 -23
- package/src/QyFileContentUtils.d.ts +1 -4
- package/src/QyFileContentUtils.js +90 -108
- package/src/QyIndex.d.ts +2 -6
- package/src/QyIndex.js +110 -140
- package/src/QyIndexPropTree.d.ts +25 -9
- package/src/QyIndexPropTree.js +101 -70
- package/src/QyIntersectNode.js +3 -3
- package/src/QyItem.d.ts +1 -1
- package/src/QyItem.js +2 -2
- package/src/QyKVData.js +14 -14
- package/src/QyKVDataCleaner_Worker.js +40 -40
- package/src/QyMessager.js +3 -3
- package/src/QyOpRunner.js +2 -2
- package/src/QySaver.js +2 -2
- package/src/QySnapshotCompactor_Worker.js +6 -6
- package/src/QySnapshotSaver_Worker.js +1 -1
- package/src/QySnapshots.js +1 -1
- package/src/QyStructure.js +6 -6
- package/src/QyTrigger.js +29 -29
- package/src/QyUnionNode.js +2 -2
- package/src/QyUtils.js +3 -3
- package/src/rpc/getFileContent.js +1 -1
- package/src/rpc/getSubItems.js +1 -1
- package/static/codemirror.bundle/editor.bundle.js +70 -37
package/src/QyBatch.js
CHANGED
|
@@ -9,21 +9,21 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
pathSplit as o,
|
|
11
11
|
ensurePropNamePathList as n,
|
|
12
|
-
isString as
|
|
12
|
+
isString as h,
|
|
13
13
|
getSuffix as g,
|
|
14
14
|
SpecialFilePaths as e,
|
|
15
|
-
toSingleName as
|
|
16
|
-
isSimpleType as
|
|
17
|
-
isEmptyObj as
|
|
15
|
+
toSingleName as f,
|
|
16
|
+
isSimpleType as d,
|
|
17
|
+
isEmptyObj as l,
|
|
18
18
|
isNumber as r,
|
|
19
19
|
getNowRounded as m,
|
|
20
20
|
isDate as a,
|
|
21
21
|
isArray as u,
|
|
22
|
-
isFloat32Array as
|
|
22
|
+
isFloat32Array as p
|
|
23
23
|
} from "./QyUtils.js";
|
|
24
24
|
|
|
25
25
|
import {
|
|
26
|
-
QyAclCmdGenerator as
|
|
26
|
+
QyAclCmdGenerator as t,
|
|
27
27
|
CmdNames as C
|
|
28
28
|
} from "./QyAcl.js";
|
|
29
29
|
|
|
@@ -32,70 +32,59 @@ import {
|
|
|
32
32
|
} from "./QyIndex.js";
|
|
33
33
|
|
|
34
34
|
import {
|
|
35
|
-
getDefaultOptions as
|
|
35
|
+
getDefaultOptions as i
|
|
36
36
|
} from "./QyDefaultOptions.js";
|
|
37
37
|
|
|
38
38
|
import {
|
|
39
|
-
QyCD as
|
|
39
|
+
QyCD as v
|
|
40
40
|
} from "./QyCD.js";
|
|
41
41
|
|
|
42
42
|
import {
|
|
43
|
-
|
|
44
|
-
} from "./QyIndexPropTree.js";
|
|
45
|
-
|
|
46
|
-
import {
|
|
47
|
-
logger as x
|
|
43
|
+
logger as y
|
|
48
44
|
} from "./QyLogger.js";
|
|
49
45
|
|
|
50
|
-
let
|
|
46
|
+
let x = e.IndexPropPathsFileName, D = {
|
|
51
47
|
none: 0,
|
|
52
48
|
basic: 1,
|
|
53
49
|
delta: 2,
|
|
54
50
|
all: 3
|
|
55
51
|
};
|
|
56
52
|
|
|
57
|
-
class
|
|
53
|
+
class F extends v {
|
|
58
54
|
fileLogLevel;
|
|
59
|
-
actionQueue;
|
|
60
55
|
changeId;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
actionQueue = [];
|
|
57
|
+
changeList = [];
|
|
58
|
+
syncList = [];
|
|
64
59
|
qyCmdObjHistory;
|
|
65
60
|
running;
|
|
61
|
+
qyAclCmdGenerator = new t();
|
|
62
|
+
options;
|
|
66
63
|
constructor(e, t) {
|
|
67
64
|
super(e), t = {
|
|
68
|
-
...
|
|
65
|
+
...i("QyBatch"),
|
|
69
66
|
...t
|
|
70
67
|
};
|
|
71
|
-
e =
|
|
72
|
-
|
|
73
|
-
options: t,
|
|
74
|
-
fileLogLevel: e ?? 1,
|
|
75
|
-
qyAclCmdGenerator: new i(),
|
|
76
|
-
qyCmdObjHistory: new I(t.maxHistoryCmdObjCount),
|
|
77
|
-
actionQueue: [],
|
|
78
|
-
changeList: [],
|
|
79
|
-
syncList: []
|
|
80
|
-
});
|
|
68
|
+
e = D[t.fileLogLevel.toLowerCase()];
|
|
69
|
+
this.options = t, this.fileLogLevel = e ?? 1, this.qyCmdObjHistory = new b(t.maxHistoryCmdObjCount);
|
|
81
70
|
}
|
|
82
71
|
createDir(e, t = this.currentDir) {
|
|
83
|
-
return
|
|
72
|
+
return h(e) && (e = o(e)), O(this, this._action_createDir, {
|
|
84
73
|
item: this.qyCache.getOrCreateDir(e, t)
|
|
85
74
|
});
|
|
86
75
|
}
|
|
87
76
|
delDir(e, t = this.currentDir) {
|
|
88
|
-
return
|
|
77
|
+
return h(e) && (e = o(e)), O(this, this._action_delDir, {
|
|
89
78
|
item: this.qyCache.getOrCreateDir(e, t).ensureAllLoaded()
|
|
90
79
|
});
|
|
91
80
|
}
|
|
92
81
|
createFile(e, t = this.currentDir) {
|
|
93
|
-
return
|
|
82
|
+
return h(e) && (e = o(e)), O(this, this._action_createFile, {
|
|
94
83
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
95
84
|
});
|
|
96
85
|
}
|
|
97
86
|
delFile(e, t = this.currentDir) {
|
|
98
|
-
return
|
|
87
|
+
return h(e) && (e = o(e)), O(this, this._action_delFile, {
|
|
99
88
|
item: this.qyCache.getOrCreateFile(e, t).ensureLoaded()
|
|
100
89
|
});
|
|
101
90
|
}
|
|
@@ -103,18 +92,18 @@ class O extends t {
|
|
|
103
92
|
return this.expireFileM(e, 1e3 * t, i);
|
|
104
93
|
}
|
|
105
94
|
expireFileM(e, t, i = this.currentDir) {
|
|
106
|
-
return
|
|
95
|
+
return j(this, e, t, "f", i);
|
|
107
96
|
}
|
|
108
97
|
expireDir(e, t, i = this.currentDir) {
|
|
109
98
|
return this.expireDirM(e, 1e3 * t, i);
|
|
110
99
|
}
|
|
111
100
|
expireDirM(e, t, i = this.currentDir) {
|
|
112
|
-
return
|
|
101
|
+
return j(this, e, t, "d", i);
|
|
113
102
|
}
|
|
114
103
|
expireContent(e, t, i, r = this.currentDir) {
|
|
115
|
-
|
|
104
|
+
h(e) && (e = o(e));
|
|
116
105
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
117
|
-
return
|
|
106
|
+
return O(this, this._action_expireContent, {
|
|
118
107
|
item: e,
|
|
119
108
|
expireInfoObj: t,
|
|
120
109
|
isMilliSecond: i
|
|
@@ -124,56 +113,64 @@ class O extends t {
|
|
|
124
113
|
return this.expireContent(e, t, !0, i);
|
|
125
114
|
}
|
|
126
115
|
removeFileExpire(e, t = !1, i = this.currentDir) {
|
|
127
|
-
return
|
|
116
|
+
return T(this, e, "f", t, i);
|
|
128
117
|
}
|
|
129
118
|
removeDirExpire(e, t = !1, i = this.currentDir) {
|
|
130
|
-
return
|
|
119
|
+
return T(this, e, "d", t, i);
|
|
131
120
|
}
|
|
132
121
|
removeContentExpire(e, t, i = !1, r = this.currentDir) {
|
|
133
|
-
|
|
122
|
+
h(e) && (e = o(e));
|
|
134
123
|
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
135
|
-
return
|
|
124
|
+
return O(this, this._action_removeContentExpire, {
|
|
136
125
|
item: e,
|
|
137
126
|
expireInfoObj: t,
|
|
138
127
|
infoFileOnly: i
|
|
139
128
|
});
|
|
140
129
|
}
|
|
141
130
|
createIndex(e, t, i = this.currentDir) {
|
|
142
|
-
|
|
131
|
+
h(e) && (e = o(e)), u(t) || (t = [ t ]);
|
|
143
132
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
144
|
-
return
|
|
133
|
+
return O(this, this._action_createIndex, {
|
|
145
134
|
item: e,
|
|
146
135
|
indexPropPathList: t
|
|
147
136
|
});
|
|
148
137
|
}
|
|
138
|
+
createIndexFromQuery(e, t, i = this.currentDir) {
|
|
139
|
+
h(e) && (e = o(e));
|
|
140
|
+
e = this.qyCache.getOrCreateDir(e, i);
|
|
141
|
+
return O(this, this._action_createIndex, {
|
|
142
|
+
item: e,
|
|
143
|
+
queryObj: t
|
|
144
|
+
});
|
|
145
|
+
}
|
|
149
146
|
delIndex(e, t, i = this.currentDir) {
|
|
150
|
-
|
|
147
|
+
h(e) && (e = o(e));
|
|
151
148
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
152
|
-
return
|
|
149
|
+
return O(this, this._action_delIndex, {
|
|
153
150
|
item: e,
|
|
154
151
|
indexPropPath: t
|
|
155
152
|
});
|
|
156
153
|
}
|
|
157
154
|
insert(e, t, i = !0, r = !1, n = this.currentDir) {
|
|
158
|
-
|
|
155
|
+
h(e) && (e = o(e));
|
|
159
156
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
160
|
-
return t = i ||
|
|
157
|
+
return t = i || d(t) ? t : structuredClone(t), O(this, this._action_insert, {
|
|
161
158
|
item: e,
|
|
162
159
|
content: t,
|
|
163
160
|
noCreate: r
|
|
164
161
|
});
|
|
165
162
|
}
|
|
166
163
|
insertEmbedding(e, t, i = this.currentDir) {
|
|
167
|
-
var r = this.qyCache, r = (
|
|
164
|
+
var r = this.qyCache, r = (p(t) || (t = new Float32Array(t)), h(e) && (e = o(e)),
|
|
168
165
|
r.getOrCreateFile(e, i));
|
|
169
|
-
return
|
|
166
|
+
return O(this, this._action_insertEmbedding, {
|
|
170
167
|
item: r,
|
|
171
168
|
embedding: t
|
|
172
169
|
});
|
|
173
170
|
}
|
|
174
171
|
delEmbedding(e, t = this.currentDir) {
|
|
175
|
-
var i = this.qyCache, i = (
|
|
176
|
-
return
|
|
172
|
+
var i = this.qyCache, i = (h(e) && (e = o(e)), i.getOrCreateFile(e, t));
|
|
173
|
+
return O(this, this._action_delEmbedding, {
|
|
177
174
|
item: i
|
|
178
175
|
});
|
|
179
176
|
}
|
|
@@ -181,16 +178,16 @@ class O extends t {
|
|
|
181
178
|
return this.insert(e, t, r, n, a), this.insertEmbedding(e, i, a);
|
|
182
179
|
}
|
|
183
180
|
delContent(e, t = this.currentDir) {
|
|
184
|
-
|
|
181
|
+
h(e) && (e = o(e));
|
|
185
182
|
e = this.qyCache.getOrCreateFile(e, t).ensureLoaded();
|
|
186
|
-
return
|
|
183
|
+
return O(this, this._action_delContent, {
|
|
187
184
|
item: e
|
|
188
185
|
});
|
|
189
186
|
}
|
|
190
187
|
insertTrigger(e, t, i, r) {
|
|
191
|
-
|
|
188
|
+
h(t) && (t = o(t)), i = n(i);
|
|
192
189
|
e = this.qyCache.getOrCreateTriggerFile(e);
|
|
193
|
-
return
|
|
190
|
+
return O(this, this._action_insertTrigger, {
|
|
194
191
|
item: e,
|
|
195
192
|
fileNamePath: t,
|
|
196
193
|
propNamePathList: i,
|
|
@@ -198,19 +195,19 @@ class O extends t {
|
|
|
198
195
|
});
|
|
199
196
|
}
|
|
200
197
|
removeTrigger(e) {
|
|
201
|
-
return
|
|
198
|
+
return O(this, this._action_removeTrigger, {
|
|
202
199
|
item: this.qyCache.getOrCreateTriggerFile(e)
|
|
203
200
|
});
|
|
204
201
|
}
|
|
205
202
|
insertRpc(e, t) {
|
|
206
203
|
e = this.qyCache.getOrCreateRpcFile(e);
|
|
207
|
-
return
|
|
204
|
+
return O(this, this._action_insertRpc, {
|
|
208
205
|
item: e,
|
|
209
206
|
modCode: t
|
|
210
207
|
});
|
|
211
208
|
}
|
|
212
209
|
removeRpc(e) {
|
|
213
|
-
return
|
|
210
|
+
return O(this, this._action_removeRpc, {
|
|
214
211
|
item: this.qyCache.getOrCreateRpcFile(e)
|
|
215
212
|
});
|
|
216
213
|
}
|
|
@@ -230,17 +227,17 @@ class O extends t {
|
|
|
230
227
|
changeList: i,
|
|
231
228
|
qyAclCmdGenerator: o,
|
|
232
229
|
qyCmdObjHistory: s,
|
|
233
|
-
syncList:
|
|
234
|
-
} = this,
|
|
235
|
-
if (0 ===
|
|
236
|
-
var c = g(
|
|
237
|
-
let
|
|
230
|
+
syncList: h
|
|
231
|
+
} = this, d = i.length;
|
|
232
|
+
if (0 === d) return n.decreaseChangeId(), 0;
|
|
233
|
+
var c = g(d), o = o.takeCmdArgAsListObj();
|
|
234
|
+
let l;
|
|
238
235
|
0 < r && (r = i.map(({
|
|
239
236
|
logStr: e
|
|
240
|
-
}) => e).join("\n"),
|
|
237
|
+
}) => e).join("\n"), l = new Date().toISOString() + `: ${d} change${c}:
|
|
241
238
|
${r}
|
|
242
239
|
`);
|
|
243
|
-
var m, u,
|
|
240
|
+
var m, u, d = n.save(t, o, l, (e => {
|
|
244
241
|
var t = e.syncList, i = t.length;
|
|
245
242
|
for (let e = 0; e < i; e += 2) {
|
|
246
243
|
var r, n = e + 1, a = t[e], o = t[n];
|
|
@@ -248,16 +245,16 @@ ${r}
|
|
|
248
245
|
t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
|
|
249
246
|
}
|
|
250
247
|
if (0 < i) return t;
|
|
251
|
-
})(this), e), c = (
|
|
248
|
+
})(this), e), c = (h.length = 0, s.push(o), i.filter(({
|
|
252
249
|
item: e,
|
|
253
250
|
delta: t
|
|
254
|
-
}) => t && 0 < e.triggerNodes?.length));
|
|
251
|
+
}) => void 0 !== t && 0 < e.triggerNodes?.length));
|
|
255
252
|
i.length = 0;
|
|
256
253
|
for ({
|
|
257
254
|
item: m,
|
|
258
255
|
delta: u
|
|
259
256
|
} of c) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
260
|
-
return e ?
|
|
257
|
+
return e ? d : t;
|
|
261
258
|
}
|
|
262
259
|
getTopHistoryCmdObj() {
|
|
263
260
|
return this.qyCmdObjHistory.top();
|
|
@@ -309,39 +306,38 @@ ${r}
|
|
|
309
306
|
}
|
|
310
307
|
_action_createIndex(t) {
|
|
311
308
|
t.actionName = "createIndex";
|
|
312
|
-
var
|
|
309
|
+
var {
|
|
313
310
|
item: t,
|
|
314
|
-
indexPropPathList:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
} =
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (0 !== s.length) {
|
|
326
|
-
x.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
|
|
327
|
-
item: n,
|
|
328
|
-
content: l
|
|
311
|
+
indexPropPathList: e,
|
|
312
|
+
queryObj: i
|
|
313
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), r = r.getOrCreateFile(x), n = (r.created || this._action_createFile({
|
|
314
|
+
item: r
|
|
315
|
+
}), r).qyIndexPropTree, i = void 0 !== i ? n.insertFromQueryObj(i) : n.insertPropPathList(e);
|
|
316
|
+
if (0 !== i.length) {
|
|
317
|
+
var a, o = {};
|
|
318
|
+
for (a of i) o[f(a.indexPropPath)] = 1;
|
|
319
|
+
y.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath), this._action_insert({
|
|
320
|
+
item: r,
|
|
321
|
+
content: o
|
|
329
322
|
});
|
|
330
323
|
{
|
|
331
|
-
var
|
|
324
|
+
var s, h = this, d = t;
|
|
332
325
|
let e;
|
|
333
|
-
for (
|
|
334
|
-
var
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
for (s of i) {
|
|
327
|
+
var {
|
|
328
|
+
indexPropPath: c,
|
|
329
|
+
indexPropDir: l
|
|
330
|
+
} = s;
|
|
331
|
+
if (!l.created) {
|
|
332
|
+
h._action_createDir({
|
|
333
|
+
item: l
|
|
338
334
|
});
|
|
339
|
-
for (var
|
|
335
|
+
for (var m of e = void 0 === e ? d.fileList : e) {
|
|
340
336
|
var {
|
|
341
|
-
fileContent:
|
|
342
|
-
name:
|
|
343
|
-
} =
|
|
344
|
-
void 0 !==
|
|
337
|
+
fileContent: m,
|
|
338
|
+
name: u
|
|
339
|
+
} = m;
|
|
340
|
+
void 0 !== m && N(h, l, c, u, void 0, m);
|
|
345
341
|
}
|
|
346
342
|
}
|
|
347
343
|
}
|
|
@@ -354,8 +350,8 @@ ${r}
|
|
|
354
350
|
item: e,
|
|
355
351
|
indexPropPath: r
|
|
356
352
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
357
|
-
e && ((i = e.getFile(
|
|
358
|
-
t.remove(r)
|
|
353
|
+
void 0 !== e && ((i = e.getFile(x)) ? (t = i.qyIndexPropTree, [ i, t, r ] = (this._setProp(i, f(r), null),
|
|
354
|
+
t.remove(r)), i && !t && void 0 !== r && (i = r.indexPropDir, void 0 !== i) && this._action_delDir({
|
|
359
355
|
item: i
|
|
360
356
|
})) : this._action_delDir({
|
|
361
357
|
item: e
|
|
@@ -372,7 +368,7 @@ ${r}
|
|
|
372
368
|
parentDir: r,
|
|
373
369
|
name: n
|
|
374
370
|
} = i;
|
|
375
|
-
return i.created = !1,
|
|
371
|
+
return i.created = !1, P(this, e), t || q(this, r, C.R, r.fileMapKey, n),
|
|
376
372
|
!0;
|
|
377
373
|
}
|
|
378
374
|
_action_delDir(e) {
|
|
@@ -389,62 +385,60 @@ ${r}
|
|
|
389
385
|
} = t;
|
|
390
386
|
if (a) {
|
|
391
387
|
q(this, t, C.D, s);
|
|
392
|
-
for (var
|
|
393
|
-
item:
|
|
388
|
+
for (var h of t.fileList) this._action_delFile({
|
|
389
|
+
item: h
|
|
394
390
|
}, !0);
|
|
395
391
|
}
|
|
396
392
|
if (n) {
|
|
397
393
|
q(this, t, C.D, o);
|
|
398
|
-
for (var
|
|
394
|
+
for (var d of t.allSubdirs()) {
|
|
399
395
|
let {
|
|
400
396
|
subdirMap: e,
|
|
401
397
|
fileMap: t,
|
|
402
398
|
subdirMapKey: i,
|
|
403
399
|
fileMapKey: r
|
|
404
|
-
} =
|
|
405
|
-
if (e && q(this,
|
|
406
|
-
q(this,
|
|
407
|
-
for (var c of
|
|
400
|
+
} = d;
|
|
401
|
+
if (e && q(this, d, C.D, i), t) {
|
|
402
|
+
q(this, d, C.D, r);
|
|
403
|
+
for (var c of d.fileList) this._action_delFile({
|
|
408
404
|
item: c
|
|
409
405
|
}, !0);
|
|
410
406
|
}
|
|
411
|
-
|
|
407
|
+
P(this, {
|
|
412
408
|
actionName: "delDir",
|
|
413
|
-
item:
|
|
414
|
-
}),
|
|
409
|
+
item: d
|
|
410
|
+
}), d.created = !1;
|
|
415
411
|
}
|
|
416
412
|
}
|
|
417
|
-
return
|
|
413
|
+
return void 0 !== i && (t.created = !1, P(this, e), q(this, i, C.R, i.subdirMapKey, r),
|
|
418
414
|
!0);
|
|
419
415
|
}
|
|
420
416
|
_action_delContent(e) {
|
|
421
417
|
e.actionName = "delContent";
|
|
422
418
|
var t = e.item, i = t.fileContent;
|
|
423
|
-
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta =
|
|
424
|
-
|
|
425
|
-
newValue: null
|
|
426
|
-
}, L(this, e), q(this, t, C.D, t.fileContentKey), b(this, t, i), !0);
|
|
419
|
+
return void 0 !== i && (t.fileContent = void 0, e.content = i, e.delta = [ i, null ],
|
|
420
|
+
P(this, e), q(this, t, C.D, t.fileContentKey), L(this, t, i), !0);
|
|
427
421
|
}
|
|
428
422
|
_action_insertEmbedding(e) {
|
|
429
423
|
e.actionName = "insertEmbedding";
|
|
430
424
|
var t, i, r = this.qyCache, n = r.qyEmbeddings, {
|
|
431
425
|
item: a,
|
|
432
426
|
embedding: o
|
|
433
|
-
} = e, s = o.length, r = r.getOrCreateInfoFile(a),
|
|
434
|
-
let
|
|
435
|
-
return r.created &&
|
|
436
|
-
c(o, i) || ((i = n.updateEmbedding(t, o,
|
|
437
|
-
|
|
427
|
+
} = e, s = o.length, r = r.getOrCreateInfoFile(a), h = r.fileContent;
|
|
428
|
+
let d = !1;
|
|
429
|
+
return r.created && h.length === s ? (t = a.fullPathHash, h = h.idx, i = n.getEmbedding(t, s, h),
|
|
430
|
+
c(o, i) || ((i = n.updateEmbedding(t, o, h)) !== h && this._setProp(r, "idx", i),
|
|
431
|
+
d = !0)) : ({
|
|
438
432
|
fullPathHash: t,
|
|
439
|
-
namePath:
|
|
433
|
+
namePath: h
|
|
440
434
|
} = a, i = n.addEmbedding(t, o), this._action_insert({
|
|
441
435
|
item: r,
|
|
442
436
|
content: {
|
|
443
437
|
length: s,
|
|
444
438
|
idx: i,
|
|
445
|
-
namePath: r.created ? void 0 :
|
|
439
|
+
namePath: r.created ? void 0 : h
|
|
446
440
|
}
|
|
447
|
-
}),
|
|
441
|
+
}), d = !0), d && P(this, e), d;
|
|
448
442
|
}
|
|
449
443
|
_action_delEmbedding(e) {
|
|
450
444
|
e.actionName = "delEmbedding";
|
|
@@ -454,7 +448,7 @@ ${r}
|
|
|
454
448
|
if (t && (o = t.fileContent, o) && (n = o.length, a = o.idx), i.delEmbedding(r.fullPathHash, n, a),
|
|
455
449
|
t) return this._action_delFile({
|
|
456
450
|
item: t
|
|
457
|
-
}),
|
|
451
|
+
}), P(this, e), !0;
|
|
458
452
|
}
|
|
459
453
|
_action_put(e) {
|
|
460
454
|
e.actionName = "put";
|
|
@@ -462,13 +456,13 @@ ${r}
|
|
|
462
456
|
item: t,
|
|
463
457
|
content: i
|
|
464
458
|
} = e;
|
|
465
|
-
if (void 0 === i) return
|
|
459
|
+
if (void 0 === i) return y.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
466
460
|
!1;
|
|
467
461
|
t.created || this._action_createFile({
|
|
468
462
|
item: t
|
|
469
463
|
});
|
|
470
464
|
var r = t.fileContentKey;
|
|
471
|
-
return i.$rpl = 1, q(this, t, C.M, r, i),
|
|
465
|
+
return i.$rpl = 1, q(this, t, C.M, r, i), P(this, e), t.fileContent = i,
|
|
472
466
|
!0;
|
|
473
467
|
}
|
|
474
468
|
_setProp(e, t, i) {
|
|
@@ -494,7 +488,7 @@ ${r}
|
|
|
494
488
|
merged: a,
|
|
495
489
|
delta: o
|
|
496
490
|
} = e;
|
|
497
|
-
if (void 0 === o && void 0 === r) return
|
|
491
|
+
if (void 0 === o && void 0 === r) return y.warn(`Saving undefined to ${i.fullPath}. Not making any change.`),
|
|
498
492
|
!1;
|
|
499
493
|
if (!i.created) {
|
|
500
494
|
if (n) return !1;
|
|
@@ -502,12 +496,9 @@ ${r}
|
|
|
502
496
|
item: i
|
|
503
497
|
});
|
|
504
498
|
}
|
|
505
|
-
return void 0 === a && void 0 === o && (
|
|
506
|
-
o =
|
|
507
|
-
|
|
508
|
-
newValue: n
|
|
509
|
-
} = o, t = i.fileContentKey, void 0 === a ? q(this, i, C.D, t) : q(this, i, C.M, t, n),
|
|
510
|
-
e.merged = a, e.delta = o, L(this, e), i.fileContent = a, b(this, i, r, n, a),
|
|
499
|
+
return void 0 === a && void 0 === o && ([ a, o ] = s(i.fileContent, r)),
|
|
500
|
+
void 0 !== o && ([ n, r ] = o, t = i.fileContentKey, void 0 === a ? q(this, i, C.D, t) : q(this, i, C.M, t, r),
|
|
501
|
+
e.merged = a, e.delta = o, P(this, e), i.fileContent = a, L(this, i, n, r, a),
|
|
511
502
|
!0);
|
|
512
503
|
}
|
|
513
504
|
_action_createFile(e) {
|
|
@@ -515,7 +506,7 @@ ${r}
|
|
|
515
506
|
var t, i = e.item;
|
|
516
507
|
return !i.created && (t = i.parentDir, this._action_createDir({
|
|
517
508
|
item: t
|
|
518
|
-
}), i.created = !0, i.fileContentLoaded = !0,
|
|
509
|
+
}), i.created = !0, i.fileContentLoaded = !0, P(this, e), q(this, t, C.A, t.fileMapKey, i.name),
|
|
519
510
|
!0);
|
|
520
511
|
}
|
|
521
512
|
_action_createDir(e) {
|
|
@@ -524,7 +515,7 @@ ${r}
|
|
|
524
515
|
if (t.created) return !1;
|
|
525
516
|
for (var i = []; !t.created; ) i.push(t), t = t.parentDir;
|
|
526
517
|
for (let e of i.reverse()) {
|
|
527
|
-
e.created = !0, e.subdirMapLoaded = !0, e.fileMapLoaded = !0,
|
|
518
|
+
e.created = !0, e.subdirMapLoaded = !0, e.fileMapLoaded = !0, P(this, {
|
|
528
519
|
actionName: "createDir",
|
|
529
520
|
item: e
|
|
530
521
|
});
|
|
@@ -542,8 +533,8 @@ ${r}
|
|
|
542
533
|
parentDir: r,
|
|
543
534
|
name: n
|
|
544
535
|
} = e;
|
|
545
|
-
return
|
|
546
|
-
(r = this._action_insert({
|
|
536
|
+
return void 0 !== r && void 0 !== (i = E(i, !0, m())) && (t = this.qyCache,
|
|
537
|
+
r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"), (r = this._action_insert({
|
|
547
538
|
item: r,
|
|
548
539
|
content: {
|
|
549
540
|
[n]: i
|
|
@@ -559,14 +550,14 @@ ${r}
|
|
|
559
550
|
parentDir: r,
|
|
560
551
|
name: n
|
|
561
552
|
} = e;
|
|
562
|
-
return
|
|
553
|
+
return void 0 !== r && (t = this.qyCache, void 0 !== (r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
|
|
563
554
|
item: r,
|
|
564
555
|
content: {
|
|
565
556
|
[n]: null
|
|
566
557
|
}
|
|
567
|
-
})) && (
|
|
558
|
+
})) && (l(r.fileContent) && this._action_delFile({
|
|
568
559
|
item: r
|
|
569
|
-
}), i
|
|
560
|
+
}), void 0 === i) && t.unmonitorItemExpire(e), n);
|
|
570
561
|
}
|
|
571
562
|
_action_expireContent(e) {
|
|
572
563
|
e.actionName = "expireContent";
|
|
@@ -575,7 +566,7 @@ ${r}
|
|
|
575
566
|
expireInfoObj: i,
|
|
576
567
|
isMilliSecond: r
|
|
577
568
|
} = e, n = m();
|
|
578
|
-
var e =
|
|
569
|
+
var e = I(i, e => E(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
|
|
579
570
|
item: o,
|
|
580
571
|
content: {
|
|
581
572
|
...e
|
|
@@ -590,22 +581,22 @@ ${r}
|
|
|
590
581
|
expireInfoObj: i,
|
|
591
582
|
infoFileOnly: r
|
|
592
583
|
} = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
593
|
-
return
|
|
584
|
+
return void 0 !== a && (i = u(i) ? Object.fromEntries(i.map(e => [ e, null ])) : I(i, e => e ? null : void 0),
|
|
594
585
|
(t = this._action_insert({
|
|
595
586
|
item: a,
|
|
596
587
|
content: i
|
|
597
|
-
})) && (
|
|
588
|
+
})) && (l(a.fileContent, !0) && this._action_delFile({
|
|
598
589
|
item: a
|
|
599
590
|
}), r || n.unmonitorContentExpire(e, i)), t);
|
|
600
591
|
}
|
|
601
592
|
}
|
|
602
593
|
|
|
603
|
-
function
|
|
594
|
+
function O(e, t, i) {
|
|
604
595
|
return e.running ? t.call(e, i) : (i.actionFun = t, e.actionQueue.push(i)),
|
|
605
596
|
e;
|
|
606
597
|
}
|
|
607
598
|
|
|
608
|
-
function
|
|
599
|
+
function P(e, t) {
|
|
609
600
|
var {
|
|
610
601
|
changeList: e,
|
|
611
602
|
fileLogLevel: i
|
|
@@ -620,10 +611,7 @@ function L(e, t) {
|
|
|
620
611
|
} = e, i = e + ` "${i.fullPath ?? i}"`;
|
|
621
612
|
if ("delContent" === e) {
|
|
622
613
|
if (3 === t) return i + " " + JSON.stringify(r);
|
|
623
|
-
} else if ("insert" === e && 2 <= t) return {
|
|
624
|
-
oldValue: r,
|
|
625
|
-
newValue: e
|
|
626
|
-
} = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
614
|
+
} else if ("insert" === e && 2 <= t) return [ r, e ] = a, a = `${void 0 === r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
627
615
|
2 === t ? i + " " + a : i + ` ${a}. ` + (void 0 !== r ? "new: " + JSON.stringify(n) : "");
|
|
628
616
|
return i;
|
|
629
617
|
})(t, i)), e.push(t);
|
|
@@ -634,20 +622,23 @@ function q(e, t, i, r, n = void 0, a = void 0) {
|
|
|
634
622
|
qyAclCmdGenerator: e,
|
|
635
623
|
qyCache: o,
|
|
636
624
|
syncList: s,
|
|
637
|
-
changeId:
|
|
625
|
+
changeId: h
|
|
638
626
|
} = e;
|
|
639
|
-
e.pushCmd(i, r, n, a), r.startsWith("d") ? t.dChangeId =
|
|
627
|
+
e.pushCmd(i, r, n, a), r.startsWith("d") ? t.dChangeId = h : r.startsWith("f") ? t.fChangeId = h : t.cChangeId = h,
|
|
640
628
|
o && o.qyKVData.removeKey(r) && s.push(r, t);
|
|
641
629
|
}
|
|
642
630
|
|
|
643
|
-
function
|
|
631
|
+
function L(e, t, i, r = void 0, n = void 0) {
|
|
644
632
|
if (!t.underHiddenFolder) {
|
|
645
633
|
var a = e.qyCache.getIndexDir(t.parentDir);
|
|
646
|
-
if (a) {
|
|
647
|
-
|
|
648
|
-
if (
|
|
649
|
-
var s,
|
|
650
|
-
for (
|
|
634
|
+
if (void 0 !== a) {
|
|
635
|
+
a = a.getFile(x);
|
|
636
|
+
if (void 0 !== a) {
|
|
637
|
+
var o, s, h = t.name;
|
|
638
|
+
for ({
|
|
639
|
+
indexPropDir: o,
|
|
640
|
+
indexPropPath: s
|
|
641
|
+
} of a.qyIndexPropTree.allLeafNodes) N(e, o, s, h, i, r, n);
|
|
651
642
|
}
|
|
652
643
|
}
|
|
653
644
|
}
|
|
@@ -655,29 +646,26 @@ function b(e, t, i, r = void 0, n = void 0) {
|
|
|
655
646
|
|
|
656
647
|
function N(t, e, i, r, n, a, o = void 0) {
|
|
657
648
|
e = _(e, i, n, a, o);
|
|
658
|
-
if (e) {
|
|
659
|
-
var s,
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
for (l of n) l.created && t._setProp(l, r, null);
|
|
665
|
-
for (h of n) if (h.created) {
|
|
666
|
-
var c = h.fileContent;
|
|
667
|
-
if (void 0 === c || d(c)) {
|
|
649
|
+
if (void 0 !== e) {
|
|
650
|
+
var s, h, [ i, n ] = e;
|
|
651
|
+
for (s of i) {
|
|
652
|
+
t._setProp(s, r, null);
|
|
653
|
+
var d = s.fileContent;
|
|
654
|
+
if (void 0 === d || l(d)) {
|
|
668
655
|
t._action_delFile({
|
|
669
|
-
item:
|
|
656
|
+
item: s
|
|
670
657
|
});
|
|
671
|
-
let e =
|
|
658
|
+
let e = s.parentDir;
|
|
672
659
|
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
673
660
|
item: e
|
|
674
661
|
}), e = e.parentDir;
|
|
675
662
|
}
|
|
676
663
|
}
|
|
664
|
+
for (h of n) t._setProp(h, r, 1);
|
|
677
665
|
}
|
|
678
666
|
}
|
|
679
667
|
|
|
680
|
-
class
|
|
668
|
+
class b {
|
|
681
669
|
maxLength;
|
|
682
670
|
actionQueue;
|
|
683
671
|
nextPos;
|
|
@@ -705,37 +693,37 @@ class I {
|
|
|
705
693
|
}
|
|
706
694
|
}
|
|
707
695
|
|
|
708
|
-
function
|
|
709
|
-
if (
|
|
696
|
+
function I(e, t = void 0, i = [], r = {}) {
|
|
697
|
+
if (d(e)) {
|
|
710
698
|
var n = t ? t(e) : e;
|
|
711
699
|
void 0 !== n && (r[JSON.stringify(i)] = n);
|
|
712
700
|
} else {
|
|
713
701
|
var a, o = i.length;
|
|
714
|
-
for (a in e) i.push(a),
|
|
702
|
+
for (a in e) i.push(a), I(e[a], t, i, r), i.length = o;
|
|
715
703
|
}
|
|
716
704
|
return r;
|
|
717
705
|
}
|
|
718
706
|
|
|
719
|
-
function
|
|
720
|
-
return r(e) ? (t ? e : 1e3 * e) + i :
|
|
707
|
+
function E(e, t, i) {
|
|
708
|
+
return r(e) ? (t ? e : 1e3 * e) + i : h(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !a(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
721
709
|
}
|
|
722
710
|
|
|
723
|
-
function
|
|
724
|
-
var a = e.qyCache, r = (
|
|
725
|
-
return
|
|
711
|
+
function j(e, t, i, r, n) {
|
|
712
|
+
var a = e.qyCache, r = (h(t) && (t = o(t)), "f" === r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
713
|
+
return O(e, e._action_expireItem, {
|
|
726
714
|
item: r,
|
|
727
715
|
milliSecond: i
|
|
728
716
|
});
|
|
729
717
|
}
|
|
730
718
|
|
|
731
|
-
function
|
|
732
|
-
var a = e.qyCache, i = (
|
|
733
|
-
return
|
|
719
|
+
function T(e, t, i, r, n) {
|
|
720
|
+
var a = e.qyCache, i = (h(t) && (t = o(t)), "f" === i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
721
|
+
return O(e, e._action_removeItemExpire, {
|
|
734
722
|
item: i,
|
|
735
723
|
infoFileOnly: r
|
|
736
724
|
});
|
|
737
725
|
}
|
|
738
726
|
|
|
739
727
|
export {
|
|
740
|
-
|
|
728
|
+
F as QyBatch
|
|
741
729
|
};
|