datafolder 1.0.11 → 1.0.13
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 +16 -0
- 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 +4 -2
- package/src/QyAcl.d.ts +13 -7
- package/src/QyAcl.js +122 -138
- package/src/QyAclSaver.js +2 -2
- package/src/QyAclSaver_Worker.d.ts +2 -2
- package/src/QyBatch.d.ts +16 -12
- package/src/QyBatch.js +339 -228
- package/src/QyBinWriter.d.ts +1 -1
- package/src/QyBinWriter.js +15 -15
- package/src/QyCD.d.ts +2 -2
- package/src/QyCD.js +29 -29
- package/src/QyCache.d.ts +9 -1
- package/src/QyCache.js +110 -73
- package/src/QyCompressor.d.ts +2 -2
- package/src/QyCompressor.js +13 -13
- package/src/QyDB.d.ts +4 -22
- package/src/QyDB.js +49 -89
- package/src/QyDefaultOptions.js +2 -0
- package/src/QyDir.d.ts +1 -0
- package/src/QyDir.js +58 -30
- package/src/QyExpire.d.ts +15 -0
- package/src/QyExpire.js +105 -0
- package/src/QyExpireInfo.d.ts +10 -0
- package/src/QyExpireInfo.js +92 -0
- package/src/QyExpire_Worker.d.ts +19 -0
- package/src/QyExpire_Worker.js +112 -0
- package/src/QyFile.d.ts +1 -1
- package/src/QyFile.js +68 -42
- package/src/QyFileContentUtils.d.ts +1 -0
- package/src/QyFileContentUtils.js +108 -94
- package/src/QyItem.d.ts +7 -0
- package/src/QyItem.js +39 -15
- package/src/QyJsonSaver.d.ts +1 -1
- package/src/QyJsonSaver.js +1 -1
- package/src/QyKVData.d.ts +6 -1
- package/src/QyKVData.js +176 -157
- package/src/QyKVDataCleaner.js +2 -2
- package/src/QyKVDataSaver.js +2 -2
- package/src/QyKVDataSaver_Worker.d.ts +2 -2
- package/src/QyKVDataSaver_Worker.js +5 -5
- package/src/QyLogFileSaver.js +2 -2
- package/src/QyMessageWorker.d.ts +1 -1
- package/src/QyMessageWorker.js +10 -10
- package/src/QyMessager.d.ts +1 -1
- package/src/QyMessager.js +37 -36
- package/src/QyMessager_Run.js +9 -6
- package/src/QyQueue.js +8 -12
- package/src/QySaver.d.ts +1 -1
- package/src/QySaver.js +1 -1
- package/src/QySnapshotCompactor.js +2 -2
- package/src/QySnapshotCompactor_Worker.js +1 -1
- package/src/QySnapshotSaver.js +2 -2
- package/src/QySnapshotSaver_Worker.js +1 -1
- package/src/QyTrigger.d.ts +1 -1
- package/src/QyTrigger.js +20 -21
- package/src/QyUtils.d.ts +5 -2
- package/src/QyUtils.js +112 -98
- package/src/hackernews.js +1 -1
- package/src/simulate.js +6 -6
- package/src/simulate2.js +4 -4
- package/src/soc_pokec.js +1 -1
- package/static/codemirror.bundle/editor.bundle.js +49 -10
- package/static/datafolderui/QyUIFolderViewer.js +1 -5
- package/src/rpc/evalCode.js +0 -9
- package/src/rpc/getFileContent.js +0 -16
- package/src/rpc/getRpcFiles.js +0 -1
- package/src/rpc/getSubItems.js +0 -16
- package/src/rpc/getTriggerFiles.js +0 -1
- package/src/rpc/queryFiles.js +0 -10
- package/src/rpc/reloadRpc.js +0 -1
package/src/QyBatch.js
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isDeepStrictEqual as
|
|
2
|
+
isDeepStrictEqual as s
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
mergeContentAndGenDelta as
|
|
7
|
-
objToDelMarks as
|
|
6
|
+
mergeContentAndGenDelta as l,
|
|
7
|
+
objToDelMarks as r
|
|
8
8
|
} from "./QyFileContentUtils.js";
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
pathSplit as
|
|
12
|
-
|
|
13
|
-
isString as
|
|
11
|
+
pathSplit as o,
|
|
12
|
+
ensurePropNamePathList as n,
|
|
13
|
+
isString as c,
|
|
14
14
|
SpecialOperators as e,
|
|
15
15
|
getSuffix as g,
|
|
16
16
|
SpecialFilePaths as t,
|
|
17
17
|
toSingleName as C,
|
|
18
|
-
isSimpleType as
|
|
18
|
+
isSimpleType as h,
|
|
19
|
+
isEmptyObj as d,
|
|
20
|
+
isNumber as a,
|
|
21
|
+
getNowRounded as m
|
|
19
22
|
} from "./QyUtils.js";
|
|
20
23
|
|
|
21
24
|
import {
|
|
22
|
-
QyAclCmdGenerator as
|
|
25
|
+
QyAclCmdGenerator as i,
|
|
26
|
+
CmdNames as u
|
|
23
27
|
} from "./QyAcl.js";
|
|
24
28
|
|
|
25
29
|
import {
|
|
26
|
-
calDifferenceList as
|
|
30
|
+
calDifferenceList as f
|
|
27
31
|
} from "./QyIndex.js";
|
|
28
32
|
|
|
29
33
|
import {
|
|
30
|
-
getDefaultOptions as
|
|
34
|
+
getDefaultOptions as p
|
|
31
35
|
} from "./QyDefaultOptions.js";
|
|
32
36
|
|
|
33
37
|
import {
|
|
34
|
-
QyCD as
|
|
38
|
+
QyCD as v
|
|
35
39
|
} from "./QyCD.js";
|
|
36
40
|
|
|
37
41
|
import {
|
|
@@ -39,17 +43,19 @@ import {
|
|
|
39
43
|
} from "./QyIndexPropTree.js";
|
|
40
44
|
|
|
41
45
|
import {
|
|
42
|
-
logger as
|
|
46
|
+
logger as _
|
|
43
47
|
} from "./QyLogger.js";
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
import "node:process";
|
|
50
|
+
|
|
51
|
+
let D = Array.isArray, x = e.$del, O = t.IndexPropPathsFileName, F = {
|
|
46
52
|
none: 0,
|
|
47
53
|
basic: 1,
|
|
48
54
|
delta: 2,
|
|
49
55
|
all: 3
|
|
50
56
|
};
|
|
51
57
|
|
|
52
|
-
class
|
|
58
|
+
class L extends v {
|
|
53
59
|
fileLogLevel;
|
|
54
60
|
actionQueue;
|
|
55
61
|
changeId;
|
|
@@ -57,153 +63,163 @@ class _ extends m {
|
|
|
57
63
|
syncList;
|
|
58
64
|
qyAclCmdGenerator;
|
|
59
65
|
qyCmdObjHistory;
|
|
66
|
+
running;
|
|
60
67
|
constructor(e, t) {
|
|
61
68
|
super(e), t = {
|
|
62
|
-
...
|
|
69
|
+
...p("QyBatch"),
|
|
63
70
|
...t
|
|
64
71
|
};
|
|
65
|
-
e =
|
|
72
|
+
e = F[t.fileLogLevel.toLowerCase()];
|
|
66
73
|
Object.assign(this, {
|
|
67
74
|
options: t,
|
|
68
75
|
fileLogLevel: e ?? 1,
|
|
69
|
-
qyAclCmdGenerator: new
|
|
70
|
-
qyCmdObjHistory: new
|
|
76
|
+
qyAclCmdGenerator: new i(),
|
|
77
|
+
qyCmdObjHistory: new j(t.maxHistoryCmdObjCount),
|
|
71
78
|
actionQueue: [],
|
|
72
79
|
changeList: [],
|
|
73
80
|
syncList: []
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
createDir(e, t = this.currentDir) {
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
createDirP(e, t = this.currentDir) {
|
|
80
|
-
return P(this, "createDir", this.qyCache?.getOrCreateDir(e, t));
|
|
84
|
+
return c(e) && (e = o(e)), N(this, "createDir", this.qyCache.getOrCreateDir(e, t));
|
|
81
85
|
}
|
|
82
86
|
delDir(e, t = this.currentDir) {
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
delDirP(e, t = this.currentDir) {
|
|
86
|
-
return P(this, "delDir", this.qyCache.getOrCreateDir(e, t));
|
|
87
|
+
return c(e) && (e = o(e)), N(this, "delDir", this.qyCache.getOrCreateDir(e, t).ensureAllLoaded());
|
|
87
88
|
}
|
|
88
89
|
createFile(e, t = this.currentDir) {
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
createFileP(e, t = this.currentDir) {
|
|
92
|
-
return P(this, "createFile", this.qyCache.getOrCreateFile(e, t));
|
|
90
|
+
return c(e) && (e = o(e)), N(this, "createFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
93
91
|
}
|
|
94
92
|
delFile(e, t = this.currentDir) {
|
|
95
|
-
return
|
|
93
|
+
return c(e) && (e = o(e)), N(this, "delFile", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
return
|
|
95
|
+
expireFile(e, t, i = this.currentDir) {
|
|
96
|
+
return this.expireFileM(e, 1e3 * t, i);
|
|
99
97
|
}
|
|
100
|
-
|
|
101
|
-
return
|
|
98
|
+
expireFileM(e, t, i = this.currentDir) {
|
|
99
|
+
return M(this, e, t, "f", i);
|
|
102
100
|
}
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
|
|
101
|
+
expireDir(e, t, i = this.currentDir) {
|
|
102
|
+
return this.expireDirM(e, 1e3 * t, i);
|
|
103
|
+
}
|
|
104
|
+
expireDirM(e, t, i = this.currentDir) {
|
|
105
|
+
return M(this, e, t, "d", i);
|
|
106
|
+
}
|
|
107
|
+
expireContent(e, t, i, r = this.currentDir) {
|
|
108
|
+
c(e) && (e = o(e));
|
|
109
|
+
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
110
|
+
return N(this, "expireContent", e, {
|
|
111
|
+
expireInfoObj: t,
|
|
112
|
+
isMilliSecond: i
|
|
106
113
|
});
|
|
107
114
|
}
|
|
108
|
-
|
|
109
|
-
return
|
|
115
|
+
expireContentM(e, t, i = this.currentDir) {
|
|
116
|
+
return this.expireContent(e, t, !0, i);
|
|
110
117
|
}
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
|
|
118
|
+
removeFileExpire(e, t = !1, i = this.currentDir) {
|
|
119
|
+
return E(this, e, "f", t, i);
|
|
120
|
+
}
|
|
121
|
+
removeDirExpire(e, t = !1, i = this.currentDir) {
|
|
122
|
+
return E(this, e, "d", t, i);
|
|
123
|
+
}
|
|
124
|
+
removeContentExpire(e, t, i = !1, r = this.currentDir) {
|
|
125
|
+
c(e) && (e = o(e));
|
|
126
|
+
e = this.qyCache.getOrCreateFile(e, r).ensureLoaded();
|
|
127
|
+
return N(this, "removeContentExpire", e, {
|
|
128
|
+
expireInfoObj: t,
|
|
129
|
+
infoFileOnly: i
|
|
114
130
|
});
|
|
115
131
|
}
|
|
116
|
-
|
|
117
|
-
return
|
|
132
|
+
createIndex(e, t, i = this.currentDir) {
|
|
133
|
+
return c(e) && (e = o(e)), D(t) || (t = [ t ]), N(this, "createIndex", this.qyCache.getOrCreateDir(e, i), {
|
|
134
|
+
indexPropPathList: t
|
|
135
|
+
});
|
|
118
136
|
}
|
|
119
|
-
|
|
120
|
-
return
|
|
121
|
-
|
|
137
|
+
delIndex(e, t, i = this.currentDir) {
|
|
138
|
+
return c(e) && (e = o(e)), N(this, "delIndex", this.qyCache.getOrCreateDir(e, i), {
|
|
139
|
+
indexPropPath: t
|
|
122
140
|
});
|
|
123
141
|
}
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
insert(e, t, i = !1, r = !1, n = this.currentDir) {
|
|
143
|
+
c(e) && (e = o(e));
|
|
144
|
+
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
145
|
+
return N(this, "insert", e, {
|
|
146
|
+
content: i || h(t) ? t : structuredClone(t),
|
|
147
|
+
noCreate: r
|
|
148
|
+
});
|
|
126
149
|
}
|
|
127
|
-
|
|
128
|
-
return this.
|
|
150
|
+
remove(e, t, i = this.currentDir) {
|
|
151
|
+
return this.insert(e, r(t), !0, !0, i);
|
|
129
152
|
}
|
|
130
|
-
|
|
153
|
+
put(e, t, i = !1, r = this.currentDir) {
|
|
131
154
|
return this.insert(e, {
|
|
132
155
|
$rpl: t
|
|
133
|
-
}, r);
|
|
134
|
-
}
|
|
135
|
-
replaceP(e, t, r = this.currentDir) {
|
|
136
|
-
return this.insertP(e, {
|
|
137
|
-
$rpl: t
|
|
138
|
-
}, r);
|
|
156
|
+
}, i, !1, r);
|
|
139
157
|
}
|
|
140
158
|
delContent(e, t = this.currentDir) {
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
delContentP(e, t = this.currentDir) {
|
|
144
|
-
return P(this, "delContent", this.qyCache.getOrCreateFile(e, t));
|
|
159
|
+
return c(e) && (e = o(e)), N(this, "delContent", this.qyCache.getOrCreateFile(e, t).ensureLoaded());
|
|
145
160
|
}
|
|
146
|
-
insertTrigger(e, t,
|
|
147
|
-
return
|
|
148
|
-
P(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
|
|
161
|
+
insertTrigger(e, t, i, r) {
|
|
162
|
+
return c(t) && (t = o(t)), i = n(i), N(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
|
|
149
163
|
fileNamePath: t,
|
|
150
|
-
propNamePathList:
|
|
151
|
-
modCode:
|
|
164
|
+
propNamePathList: i,
|
|
165
|
+
modCode: r
|
|
152
166
|
});
|
|
153
167
|
}
|
|
154
168
|
removeTrigger(e) {
|
|
155
|
-
return
|
|
169
|
+
return N(this, "removeTrigger", this.qyCache.getOrCreateTriggerFile(e));
|
|
156
170
|
}
|
|
157
171
|
insertRpc(e, t) {
|
|
158
|
-
return
|
|
172
|
+
return N(this, "insertRpc", this.qyCache.getOrCreateRpcFile(e), {
|
|
159
173
|
modCode: t
|
|
160
174
|
});
|
|
161
175
|
}
|
|
162
176
|
removeRpc(e) {
|
|
163
|
-
return
|
|
177
|
+
return N(this, "removeRpc", this.qyCache.getOrCreateRpcFile(e));
|
|
164
178
|
}
|
|
165
179
|
run(e = !1) {
|
|
166
180
|
var {
|
|
167
|
-
|
|
181
|
+
running: t,
|
|
182
|
+
actionQueue: i,
|
|
168
183
|
fileLogLevel: r,
|
|
169
|
-
qyCache:
|
|
184
|
+
qyCache: n
|
|
170
185
|
} = this;
|
|
171
|
-
if (0 ==
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
if (t || 0 == i.length) return 0;
|
|
187
|
+
this.running = !0;
|
|
188
|
+
var a, t = this.changeId = n.increaseChangeId();
|
|
189
|
+
for (a of i) this["_action_" + a.actionName](a);
|
|
190
|
+
i.length = 0, this.running = !1, this.resetCurrentDir();
|
|
175
191
|
var {
|
|
176
|
-
changeList:
|
|
177
|
-
qyAclCmdGenerator:
|
|
178
|
-
qyCmdObjHistory:
|
|
179
|
-
syncList:
|
|
180
|
-
} = this,
|
|
181
|
-
if (0 ==
|
|
182
|
-
var h = g(
|
|
192
|
+
changeList: i,
|
|
193
|
+
qyAclCmdGenerator: o,
|
|
194
|
+
qyCmdObjHistory: s,
|
|
195
|
+
syncList: l
|
|
196
|
+
} = this, c = i.length;
|
|
197
|
+
if (0 == c) return n.decreaseChangeId(), 0;
|
|
198
|
+
var h = g(c), o = o.takeCmdArgAsListObj();
|
|
183
199
|
let d;
|
|
184
|
-
0 < r && (r =
|
|
200
|
+
0 < r && (r = i.map(({
|
|
185
201
|
logStr: e
|
|
186
|
-
}) => e).join("\n"), d = new Date().toISOString() + `: ${
|
|
202
|
+
}) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
|
|
187
203
|
${r}
|
|
188
204
|
`);
|
|
189
|
-
var m, u,
|
|
190
|
-
var t = e.syncList,
|
|
191
|
-
for (let e = 0; e <
|
|
192
|
-
var
|
|
193
|
-
a.startsWith("d") ? (
|
|
194
|
-
t[n] = 0 <
|
|
205
|
+
var m, u, c = n.save(t, o, d, (e => {
|
|
206
|
+
var t = e.syncList, i = t.length;
|
|
207
|
+
for (let e = 0; e < i; e += 2) {
|
|
208
|
+
var r, n = e + 1, a = t[e], o = t[n];
|
|
209
|
+
a.startsWith("d") ? (r = o.subdirNameList, t[n] = 0 < r.length ? r : void 0) : a.startsWith("f") ? (r = o.fileNameList,
|
|
210
|
+
t[n] = 0 < r.length ? r : void 0) : t[n] = o.fileContent;
|
|
195
211
|
}
|
|
196
|
-
if (0 <
|
|
197
|
-
})(this), e), h = (
|
|
212
|
+
if (0 < i) return t;
|
|
213
|
+
})(this), e), h = (l.length = 0, s.push(o), i.filter(({
|
|
198
214
|
item: e,
|
|
199
215
|
delta: t
|
|
200
216
|
}) => t && 0 < e.triggerNodes?.length));
|
|
201
|
-
|
|
217
|
+
i.length = 0;
|
|
202
218
|
for ({
|
|
203
219
|
item: m,
|
|
204
220
|
delta: u
|
|
205
221
|
} of h) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
206
|
-
return e ?
|
|
222
|
+
return e ? c : t;
|
|
207
223
|
}
|
|
208
224
|
getTopHistoryCmdObj() {
|
|
209
225
|
return this.qyCmdObjHistory.top();
|
|
@@ -212,43 +228,39 @@ ${r}
|
|
|
212
228
|
e.actionName = "insertTrigger";
|
|
213
229
|
var t, {
|
|
214
230
|
item: e,
|
|
215
|
-
fileNamePath:
|
|
216
|
-
propNamePathList:
|
|
231
|
+
fileNamePath: i,
|
|
232
|
+
propNamePathList: r,
|
|
217
233
|
modCode: n
|
|
218
234
|
} = e, {
|
|
219
235
|
name: a,
|
|
220
|
-
fileContent:
|
|
221
|
-
} = e, e = this._action_insert({
|
|
236
|
+
fileContent: o
|
|
237
|
+
} = e, o = o && o[0], e = this._action_insert({
|
|
222
238
|
item: e,
|
|
223
|
-
content:
|
|
224
|
-
fileNamePath: r,
|
|
225
|
-
propNamePathList: i,
|
|
226
|
-
modCode: n
|
|
227
|
-
}
|
|
239
|
+
content: [ i, r, n ]
|
|
228
240
|
});
|
|
229
|
-
return e && (t = this.qyCache,
|
|
230
|
-
t.insertTriggerToTree(a,
|
|
241
|
+
return e && (t = this.qyCache, o && !s(o, i) && t.removeTriggerFromTree(a, o),
|
|
242
|
+
t.insertTriggerToTree(a, i, r, n)), e;
|
|
231
243
|
}
|
|
232
244
|
_action_removeTrigger(e) {
|
|
233
245
|
e.actionName = "removeTrigger";
|
|
234
246
|
var e = e.item, {
|
|
235
247
|
fileContent: t,
|
|
236
|
-
name:
|
|
248
|
+
name: i
|
|
237
249
|
} = e;
|
|
238
250
|
return !!this._action_delFile({
|
|
239
251
|
item: e
|
|
240
|
-
}) && (this.qyCache.removeTriggerFromTree(
|
|
252
|
+
}) && (this.qyCache.removeTriggerFromTree(i, t[0]), !0);
|
|
241
253
|
}
|
|
242
254
|
_action_insertRpc(e) {
|
|
243
255
|
e.actionName = "insertRpc";
|
|
244
256
|
var {
|
|
245
257
|
item: e,
|
|
246
258
|
modCode: t
|
|
247
|
-
} = e,
|
|
259
|
+
} = e, i = this._action_insert({
|
|
248
260
|
item: e,
|
|
249
261
|
content: t
|
|
250
262
|
});
|
|
251
|
-
return
|
|
263
|
+
return i && this.qyCache.insertRpc(e.name, t), i;
|
|
252
264
|
}
|
|
253
265
|
_action_removeRpc(e) {
|
|
254
266
|
e.actionName = "removeRpc";
|
|
@@ -261,26 +273,26 @@ ${r}
|
|
|
261
273
|
t.actionName = "createIndex";
|
|
262
274
|
var e, {
|
|
263
275
|
item: t,
|
|
264
|
-
indexPropPathList:
|
|
265
|
-
} = t,
|
|
276
|
+
indexPropPathList: i
|
|
277
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(O), {
|
|
266
278
|
fileContent: a,
|
|
267
|
-
qyIndexPropTree:
|
|
279
|
+
qyIndexPropTree: o
|
|
268
280
|
} = (n.created || this._action_createFile({
|
|
269
281
|
item: n
|
|
270
|
-
}), n),
|
|
271
|
-
for (e of
|
|
272
|
-
var
|
|
273
|
-
a && a[
|
|
282
|
+
}), n), s = [], l = {};
|
|
283
|
+
for (e of i) {
|
|
284
|
+
var c = C(e);
|
|
285
|
+
a && a[c] || (s.push(e), l[c] = 1, o.insert(e));
|
|
274
286
|
}
|
|
275
|
-
if (0 !=
|
|
276
|
-
|
|
287
|
+
if (0 != s.length) {
|
|
288
|
+
_.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
|
|
277
289
|
item: n,
|
|
278
|
-
content:
|
|
290
|
+
content: l
|
|
279
291
|
});
|
|
280
292
|
{
|
|
281
|
-
var h, d = this, m = t, u =
|
|
293
|
+
var h, d = this, m = t, u = r, i = y(s);
|
|
282
294
|
let e;
|
|
283
|
-
for (h of
|
|
295
|
+
for (h of i) {
|
|
284
296
|
var f = u.searchOrCreateSubdir(h);
|
|
285
297
|
if (!f.created) {
|
|
286
298
|
d._action_createDir({
|
|
@@ -291,7 +303,7 @@ ${r}
|
|
|
291
303
|
fileContent: g,
|
|
292
304
|
name: p
|
|
293
305
|
} = g;
|
|
294
|
-
null != g &&
|
|
306
|
+
null != g && b(d, f, h, p, void 0, g);
|
|
295
307
|
}
|
|
296
308
|
}
|
|
297
309
|
}
|
|
@@ -300,33 +312,33 @@ ${r}
|
|
|
300
312
|
}
|
|
301
313
|
_action_delIndex(e) {
|
|
302
314
|
e.actionName = "delIndex";
|
|
303
|
-
var t,
|
|
315
|
+
var t, i, {
|
|
304
316
|
item: e,
|
|
305
|
-
indexPropPath:
|
|
317
|
+
indexPropPath: r
|
|
306
318
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
307
|
-
e && ((
|
|
308
|
-
item:
|
|
319
|
+
e && ((i = e.getFile(O)) ? (t = i.qyIndexPropTree, this._action_insert({
|
|
320
|
+
item: i,
|
|
309
321
|
content: {
|
|
310
|
-
[C(
|
|
322
|
+
[C(r)]: x
|
|
311
323
|
}
|
|
312
|
-
}), t.remove(
|
|
313
|
-
item:
|
|
324
|
+
}), t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
|
|
325
|
+
item: i
|
|
314
326
|
})) : this._action_delDir({
|
|
315
327
|
item: e
|
|
316
328
|
}));
|
|
317
329
|
}
|
|
318
330
|
_action_delFile(e, t = !1) {
|
|
319
331
|
e.actionName = "delFile";
|
|
320
|
-
var
|
|
321
|
-
if (!
|
|
322
|
-
null !=
|
|
323
|
-
item:
|
|
332
|
+
var i = e.item;
|
|
333
|
+
if (!i.created) return !1;
|
|
334
|
+
null != i.fileContent && this._action_delContent({
|
|
335
|
+
item: i
|
|
324
336
|
});
|
|
325
337
|
var {
|
|
326
|
-
parentDir:
|
|
338
|
+
parentDir: r,
|
|
327
339
|
name: n
|
|
328
|
-
} =
|
|
329
|
-
return
|
|
340
|
+
} = i;
|
|
341
|
+
return i.created = !1, I(this, e), t || q(this, r, u.R, r.fileMapKey, n),
|
|
330
342
|
!0;
|
|
331
343
|
}
|
|
332
344
|
_action_delDir(e) {
|
|
@@ -334,179 +346,249 @@ ${r}
|
|
|
334
346
|
var t = e.item;
|
|
335
347
|
if (!t.created) return !1;
|
|
336
348
|
let {
|
|
337
|
-
parentDir:
|
|
338
|
-
name:
|
|
349
|
+
parentDir: i,
|
|
350
|
+
name: r,
|
|
339
351
|
subdirMap: n,
|
|
340
352
|
fileMap: a,
|
|
341
|
-
subdirMapKey:
|
|
342
|
-
fileMapKey:
|
|
353
|
+
subdirMapKey: o,
|
|
354
|
+
fileMapKey: s
|
|
343
355
|
} = t;
|
|
344
356
|
if (a) {
|
|
345
|
-
|
|
346
|
-
for (var
|
|
347
|
-
item:
|
|
357
|
+
q(this, t, u.D, s);
|
|
358
|
+
for (var l of t.fileList) this._action_delFile({
|
|
359
|
+
item: l
|
|
348
360
|
}, !0);
|
|
349
361
|
}
|
|
350
362
|
if (n) {
|
|
351
|
-
|
|
352
|
-
for (var
|
|
363
|
+
q(this, t, u.D, o);
|
|
364
|
+
for (var c of t.allSubdirs()) {
|
|
353
365
|
let {
|
|
354
366
|
subdirMap: e,
|
|
355
367
|
fileMap: t,
|
|
356
|
-
subdirMapKey:
|
|
357
|
-
fileMapKey:
|
|
358
|
-
} =
|
|
359
|
-
if (e &&
|
|
360
|
-
|
|
361
|
-
for (var h of
|
|
368
|
+
subdirMapKey: i,
|
|
369
|
+
fileMapKey: r
|
|
370
|
+
} = c;
|
|
371
|
+
if (e && q(this, c, u.D, i), t) {
|
|
372
|
+
q(this, c, u.D, r);
|
|
373
|
+
for (var h of c.fileList) this._action_delFile({
|
|
362
374
|
item: h
|
|
363
375
|
}, !0);
|
|
364
376
|
}
|
|
365
|
-
|
|
377
|
+
I(this, {
|
|
366
378
|
actionName: "delDir",
|
|
367
|
-
item:
|
|
368
|
-
}),
|
|
379
|
+
item: c
|
|
380
|
+
}), c.created = !1;
|
|
369
381
|
}
|
|
370
382
|
}
|
|
371
|
-
return !!
|
|
383
|
+
return !!i && (t.created = !1, I(this, e), q(this, i, u.R, i.subdirMapKey, r),
|
|
372
384
|
!0);
|
|
373
385
|
}
|
|
374
386
|
_action_delContent(e) {
|
|
375
387
|
e.actionName = "delContent";
|
|
376
|
-
var t = e.item,
|
|
377
|
-
return null !=
|
|
378
|
-
content:
|
|
388
|
+
var t = e.item, i = t.fileContent;
|
|
389
|
+
return null != i && (t.fileContent = void 0, Object.assign(e, {
|
|
390
|
+
content: i,
|
|
379
391
|
delta: {
|
|
380
|
-
oldValue:
|
|
381
|
-
newValue:
|
|
392
|
+
oldValue: i,
|
|
393
|
+
newValue: x
|
|
382
394
|
}
|
|
383
|
-
}),
|
|
395
|
+
}), I(this, e), q(this, t, u.D, t.fileContentKey), P(this, t, i), !0);
|
|
384
396
|
}
|
|
385
397
|
_action_insert(e) {
|
|
386
398
|
e.actionName = "insert";
|
|
387
399
|
var {
|
|
388
400
|
item: t,
|
|
389
|
-
content:
|
|
401
|
+
content: i,
|
|
402
|
+
noCreate: r
|
|
390
403
|
} = e;
|
|
391
|
-
if (null ==
|
|
404
|
+
if (null == i) return _.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
392
405
|
!1;
|
|
393
|
-
t.created
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
406
|
+
if (!t.created) {
|
|
407
|
+
if (r) return !1;
|
|
408
|
+
this._action_createFile({
|
|
409
|
+
item: t
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
var n, a, r = l(t.fileContent, i), {
|
|
413
|
+
merged: i,
|
|
414
|
+
delta: o
|
|
399
415
|
} = r;
|
|
400
|
-
return !!
|
|
401
|
-
oldValue:
|
|
402
|
-
newValue:
|
|
403
|
-
} =
|
|
404
|
-
Object.assign(e, r),
|
|
416
|
+
return !!o && ({
|
|
417
|
+
oldValue: o,
|
|
418
|
+
newValue: n
|
|
419
|
+
} = o, !!n) && (a = t.fileContentKey, null == i ? q(this, t, u.D, a) : q(this, t, u.M, a, n),
|
|
420
|
+
Object.assign(e, r), I(this, e), t.fileContent = i, P(this, t, o, n, i),
|
|
421
|
+
!0);
|
|
405
422
|
}
|
|
406
423
|
_action_createFile(e) {
|
|
407
424
|
e.actionName = "createFile";
|
|
408
|
-
var t,
|
|
409
|
-
return !
|
|
425
|
+
var t, i = e.item;
|
|
426
|
+
return !i.created && (t = i.parentDir, this._action_createDir({
|
|
410
427
|
item: t
|
|
411
|
-
}), Object.assign(
|
|
428
|
+
}), Object.assign(i, {
|
|
412
429
|
created: !0,
|
|
413
430
|
fileContentLoaded: !0
|
|
414
|
-
}),
|
|
431
|
+
}), I(this, e), q(this, t, u.A, t.fileMapKey, i.name), !0);
|
|
415
432
|
}
|
|
416
433
|
_action_createDir(e) {
|
|
417
434
|
e.actionName = "createDir";
|
|
418
435
|
let t = e.item;
|
|
419
436
|
if (t.created) return !1;
|
|
420
|
-
for (var
|
|
421
|
-
for (let e of
|
|
437
|
+
for (var i = []; !t.created; ) i.push(t), t = t.parentDir;
|
|
438
|
+
for (let e of i.reverse()) {
|
|
422
439
|
Object.assign(e, {
|
|
423
440
|
created: !0,
|
|
424
441
|
subdirMapLoaded: !0,
|
|
425
442
|
fileMapLoaded: !0
|
|
426
|
-
}),
|
|
443
|
+
}), I(this, {
|
|
427
444
|
actionName: "createDir",
|
|
428
445
|
item: e
|
|
429
446
|
});
|
|
430
|
-
var
|
|
431
|
-
|
|
447
|
+
var r = e.parentDir;
|
|
448
|
+
q(this, r, u.A, r.subdirMapKey, e.name);
|
|
432
449
|
}
|
|
433
450
|
return !0;
|
|
434
451
|
}
|
|
452
|
+
_action_expireItem(e) {
|
|
453
|
+
e.actionName = "expireItem";
|
|
454
|
+
var t, {
|
|
455
|
+
item: e,
|
|
456
|
+
milliSecond: i
|
|
457
|
+
} = e, {
|
|
458
|
+
parentDir: r,
|
|
459
|
+
name: n
|
|
460
|
+
} = e;
|
|
461
|
+
return !!r && null != (i = T(i, !0, m())) && (t = this.qyCache, r = t.getOrCreateExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"),
|
|
462
|
+
(r = this._action_insert({
|
|
463
|
+
item: r,
|
|
464
|
+
content: {
|
|
465
|
+
[n]: i
|
|
466
|
+
}
|
|
467
|
+
})) && t.monitorItemExpire(e, i), r);
|
|
468
|
+
}
|
|
469
|
+
_action_removeItemExpire(e) {
|
|
470
|
+
e.actionName = "removeItemExpire";
|
|
471
|
+
var t, {
|
|
472
|
+
item: e,
|
|
473
|
+
infoFileOnly: i
|
|
474
|
+
} = e, {
|
|
475
|
+
parentDir: r,
|
|
476
|
+
name: n
|
|
477
|
+
} = e;
|
|
478
|
+
return !!r && (t = this.qyCache, !!(r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
|
|
479
|
+
item: r,
|
|
480
|
+
content: {
|
|
481
|
+
[n]: x
|
|
482
|
+
}
|
|
483
|
+
})) && (d(r.fileContent) && this._action_delFile({
|
|
484
|
+
item: r
|
|
485
|
+
}), i || t.unmonitorItemExpire(e)), n);
|
|
486
|
+
}
|
|
487
|
+
_action_expireContent(e) {
|
|
488
|
+
e.actionName = "expireContent";
|
|
489
|
+
let {
|
|
490
|
+
item: t,
|
|
491
|
+
expireInfoObj: i,
|
|
492
|
+
isMilliSecond: r
|
|
493
|
+
} = e, n = m();
|
|
494
|
+
var e = S(i, e => T(e, r, n)), a = this.qyCache, o = a.getOrCreateExpireInfoFile(t.fullPathHash, "c"), o = this._action_insert({
|
|
495
|
+
item: o,
|
|
496
|
+
content: {
|
|
497
|
+
...e
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
return o && a.monitorContentExpire(t, e), o;
|
|
501
|
+
}
|
|
502
|
+
_action_removeContentExpire(e) {
|
|
503
|
+
e.actionName = "removeContentExpire";
|
|
504
|
+
var t, {
|
|
505
|
+
item: e,
|
|
506
|
+
expireInfoObj: i,
|
|
507
|
+
infoFileOnly: r
|
|
508
|
+
} = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
509
|
+
return !!a && (i = D(i) ? Object.fromEntries(i.map(e => [ e, x ])) : S(i, e => e ? x : void 0),
|
|
510
|
+
(t = this._action_insert({
|
|
511
|
+
item: a,
|
|
512
|
+
content: i
|
|
513
|
+
})) && (d(a.fileContent) && this._action_delFile({
|
|
514
|
+
item: a
|
|
515
|
+
}), r || n.unmonitorContentExpire(e, i)), t);
|
|
516
|
+
}
|
|
435
517
|
}
|
|
436
518
|
|
|
437
|
-
function
|
|
519
|
+
function N(e, t, i, r) {
|
|
438
520
|
return e.actionQueue.push({
|
|
439
521
|
actionName: t,
|
|
440
|
-
item:
|
|
441
|
-
...
|
|
522
|
+
item: i,
|
|
523
|
+
...r
|
|
442
524
|
}), e;
|
|
443
525
|
}
|
|
444
526
|
|
|
445
|
-
function
|
|
527
|
+
function I(e, t) {
|
|
446
528
|
var {
|
|
447
529
|
changeList: e,
|
|
448
|
-
fileLogLevel:
|
|
530
|
+
fileLogLevel: i
|
|
449
531
|
} = e;
|
|
450
|
-
0 <
|
|
532
|
+
0 < i && (t.logStr = ((e, t) => {
|
|
451
533
|
var {
|
|
452
534
|
actionName: e,
|
|
453
|
-
item:
|
|
454
|
-
content:
|
|
535
|
+
item: i,
|
|
536
|
+
content: r,
|
|
455
537
|
merged: n,
|
|
456
538
|
delta: a
|
|
457
|
-
} = e,
|
|
539
|
+
} = e, i = e + ` "${i.fullPath ?? i}"`;
|
|
458
540
|
if ("delContent" === e) {
|
|
459
|
-
if (3 == t) return
|
|
541
|
+
if (3 == t) return i + " " + JSON.stringify(r);
|
|
460
542
|
} else if ("insert" === e && 2 <= t) return {
|
|
461
|
-
oldValue:
|
|
543
|
+
oldValue: r,
|
|
462
544
|
newValue: e
|
|
463
|
-
} = a, a = `${null ==
|
|
464
|
-
2 == t ?
|
|
465
|
-
return
|
|
466
|
-
})(t,
|
|
545
|
+
} = a, a = `${null == r ? "" : "delta:"} ${JSON.stringify(r)} -> ` + JSON.stringify(e),
|
|
546
|
+
2 == t ? i + " " + a : i + ` ${a}. ` + (null != r ? "new: " + JSON.stringify(n) : "");
|
|
547
|
+
return i;
|
|
548
|
+
})(t, i)), e.push(t);
|
|
467
549
|
}
|
|
468
550
|
|
|
469
|
-
function
|
|
551
|
+
function q(e, t, i, r, n = void 0) {
|
|
470
552
|
var {
|
|
471
553
|
qyAclCmdGenerator: e,
|
|
472
554
|
qyCache: a,
|
|
473
|
-
syncList:
|
|
474
|
-
changeId:
|
|
555
|
+
syncList: o,
|
|
556
|
+
changeId: s
|
|
475
557
|
} = e;
|
|
476
|
-
e.pushCmd(
|
|
477
|
-
a && a.qyKVData.removeKey(
|
|
558
|
+
e.pushCmd(i, r, n), r.startsWith("d") ? t.dChangeId = s : r.startsWith("f") ? t.fChangeId = s : t.cChangeId = s,
|
|
559
|
+
a && a.qyKVData.removeKey(r) && o.push(r, t);
|
|
478
560
|
}
|
|
479
561
|
|
|
480
|
-
function
|
|
562
|
+
function P(e, t, i, r = void 0, n = void 0) {
|
|
481
563
|
var {
|
|
482
564
|
underHiddenFolder: t,
|
|
483
565
|
name: a,
|
|
484
|
-
parentDir:
|
|
566
|
+
parentDir: o
|
|
485
567
|
} = t;
|
|
486
568
|
if (!t) {
|
|
487
|
-
var
|
|
488
|
-
if (
|
|
489
|
-
t =
|
|
490
|
-
if (t) for (var
|
|
569
|
+
var s = e.qyCache.getIndexDir(o);
|
|
570
|
+
if (s) {
|
|
571
|
+
t = s.getFile(O);
|
|
572
|
+
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) b(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
|
|
491
573
|
}
|
|
492
574
|
}
|
|
493
575
|
}
|
|
494
576
|
|
|
495
|
-
function
|
|
496
|
-
e =
|
|
577
|
+
function b(t, e, i, r, n, a, o = void 0) {
|
|
578
|
+
e = f(e, i, r, n, a, o);
|
|
497
579
|
if (e) {
|
|
498
|
-
var
|
|
499
|
-
toAddFileList:
|
|
500
|
-
toDelFileList:
|
|
580
|
+
var s, l, c, {
|
|
581
|
+
toAddFileList: i,
|
|
582
|
+
toDelFileList: r
|
|
501
583
|
} = e;
|
|
502
|
-
for (
|
|
503
|
-
item:
|
|
584
|
+
for (s of i) t._action_createFile({
|
|
585
|
+
item: s
|
|
504
586
|
});
|
|
505
|
-
for (
|
|
506
|
-
item:
|
|
587
|
+
for (l of r) t._action_delFile({
|
|
588
|
+
item: l
|
|
507
589
|
});
|
|
508
|
-
for (
|
|
509
|
-
let e =
|
|
590
|
+
for (c of r) {
|
|
591
|
+
let e = c.parentDir;
|
|
510
592
|
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
511
593
|
item: e
|
|
512
594
|
}), e = e.parentDir;
|
|
@@ -514,7 +596,7 @@ function N(t, e, r, i, n, a, s = void 0) {
|
|
|
514
596
|
}
|
|
515
597
|
}
|
|
516
598
|
|
|
517
|
-
class
|
|
599
|
+
class j {
|
|
518
600
|
maxLength;
|
|
519
601
|
actionQueue;
|
|
520
602
|
nextPos;
|
|
@@ -528,20 +610,49 @@ class O {
|
|
|
528
610
|
push(e) {
|
|
529
611
|
var {
|
|
530
612
|
maxLength: t,
|
|
531
|
-
nextPos:
|
|
613
|
+
nextPos: i
|
|
532
614
|
} = this;
|
|
533
|
-
this.actionQueue[
|
|
615
|
+
this.actionQueue[i] = e, this.nextPos = ((e, t) => (t += 1) < e ? t : 0)(t, i);
|
|
534
616
|
}
|
|
535
617
|
top() {
|
|
536
618
|
var {
|
|
537
619
|
actionQueue: e,
|
|
538
620
|
maxLength: t,
|
|
539
|
-
nextPos:
|
|
621
|
+
nextPos: i
|
|
540
622
|
} = this;
|
|
541
|
-
return e[e = t, (0 < (t =
|
|
623
|
+
return e[e = t, (0 < (t = i) ? t : e) - 1];
|
|
542
624
|
}
|
|
543
625
|
}
|
|
544
626
|
|
|
627
|
+
function S(e, t = void 0, i = [], r = {}) {
|
|
628
|
+
if (h(e)) {
|
|
629
|
+
var n = t ? t(e) : e;
|
|
630
|
+
null != n && (r[JSON.stringify(i)] = n);
|
|
631
|
+
} else {
|
|
632
|
+
var a, o = i.length;
|
|
633
|
+
for (a in e) i.push(a), S(e[a], t, i, r), i.length = o;
|
|
634
|
+
}
|
|
635
|
+
return r;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function T(e, t, i) {
|
|
639
|
+
return a(e) ? (t ? e : 1e3 * e) + i : c(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !(e instanceof Date) || (t = e.getTime()) <= i ? void 0 : t;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function M(e, t, i, r, n) {
|
|
643
|
+
var a = e.qyCache, r = (c(t) && (t = o(t)), "f" == r ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
644
|
+
return N(e, "expireItem", r, {
|
|
645
|
+
milliSecond: i
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function E(e, t, i, r, n) {
|
|
650
|
+
var a = e.qyCache, i = (c(t) && (t = o(t)), "f" == i ? a.getOrCreateFile(t, n) : a.getOrCreateDir(t, n));
|
|
651
|
+
return N(e, "removeItemExpire", i, {
|
|
652
|
+
infoFileOnly: r
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
545
656
|
export {
|
|
546
|
-
|
|
657
|
+
L as QyBatch
|
|
547
658
|
};
|