datafolder 1.0.2 → 1.0.4
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 +34 -31
- package/index.js +1 -3
- package/package.json +5 -3
- package/sample.js +37 -37
- package/scripts/airbnb.js +10 -11
- package/scripts/airbnb2.js +10 -11
- package/scripts/airbnb2_queries.js +20 -22
- package/scripts/airbnb_queries.js +23 -22
- package/scripts/downloadFile.js +29 -31
- package/scripts/express.js +7 -5
- package/scripts/fastify.js +12 -11
- package/scripts/flights.js +9 -9
- package/scripts/flights2.js +9 -9
- package/scripts/flights2_queries.js +107 -105
- package/scripts/flights_queries.js +113 -109
- package/src/QyAcl.js +153 -152
- package/src/QyAclSaver.js +16 -10
- package/src/QyAclSaver_Worker.js +21 -15
- package/src/QyAclWriter.js +23 -13
- package/src/QyBatch.js +298 -263
- package/src/QyBinWriter.js +49 -37
- package/src/QyCD.js +13 -14
- package/src/QyCache.js +177 -140
- package/src/QyCompressor.js +71 -45
- package/src/QyCompressor_Worker.js +17 -9
- package/src/QyDB.js +67 -12
- package/src/QyDefaultOptions.js +13 -10
- package/src/QyDir.js +89 -53
- package/src/QyFetch.js +27 -24
- package/src/QyFile.js +89 -77
- package/src/QyFileContentUtils.js +129 -132
- package/src/QyFileLogger.js +63 -41
- package/src/QyIndex.js +175 -197
- package/src/QyIndexPropTree.js +25 -25
- package/src/QyIntersectNode.js +34 -31
- package/src/QyItem.js +54 -52
- package/src/QyJsonSaver.js +12 -6
- package/src/QyKVData.js +279 -245
- package/src/QyKVDataCleaner.js +12 -6
- package/src/QyKVDataCleaner_Worker.js +77 -59
- package/src/QyKVDataLoader.js +67 -46
- package/src/QyKVDataSaver.js +15 -9
- package/src/QyKVDataSaver_Worker.js +83 -60
- package/src/QyLogFileSaver.js +12 -6
- package/src/QyLogFileSaver_Worker.js +24 -14
- package/src/QyLogger.js +51 -40
- package/src/QyMessageWorker.js +43 -29
- package/src/QyMessager.js +74 -54
- package/src/QyMessager_Run.js +20 -7
- package/src/QyMod.js +15 -11
- package/src/QyOpRunner.js +58 -41
- package/src/QyQueue.js +35 -30
- package/src/QySaver.js +52 -29
- package/src/QySnapshotCompactor.js +15 -9
- package/src/QySnapshotCompactor_Worker.js +131 -110
- package/src/QySnapshotSaver.js +15 -9
- package/src/QySnapshotSaver_Worker.js +125 -110
- package/src/QySnapshots.js +264 -242
- package/src/QyStructure.js +35 -27
- package/src/QyTrigger.js +62 -55
- package/src/QyUnionNode.js +54 -56
- package/src/QyUtils.js +170 -158
- package/src/QyWorker.js +34 -20
- package/src/hackernews.js +63 -71
- package/src/rpc/getFileContent.js +7 -7
- package/src/rpc/getSubItems.js +12 -28
- package/src/rpc/queryFiles.js +2 -25
- package/src/simulate.js +85 -80
- package/src/simulate2.js +77 -78
- package/src/soc_pokec.js +44 -32
- package/static/datafolderui/QyStyledElement.js +12 -12
- package/static/datafolderui/QyUIFolderTree.js +20 -20
- package/static/datafolderui/QyUIUtils.js +8 -8
- package/static/datafolderui/explore-tree.js +31 -31
- package/static/datafolderui/folder-tree.js +2 -2
- package/static/datafolderui/hscrpt.js +9 -17
- package/static/datafolderui/json-view.js +3 -5
- package/static/datafolderui/kv-input.js +15 -15
- package/static/datafolderui/list-input.js +17 -17
- package/static/datafolderui/main-page.js +18 -18
- package/static/datafolderui/num-input.js +5 -5
- package/static/datafolderui/query-editor.js +6 -1
- package/static/datafolderui/querySelectorShadowRoot.js +15 -19
- package/static/datafolderui/resizable-input.js +18 -18
package/src/QyBatch.js
CHANGED
|
@@ -1,208 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import {
|
|
2
|
+
isDeepStrictEqual as o
|
|
3
|
+
} from "node:util";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
mergeContentAndGenDelta as l,
|
|
7
|
+
objToDelMarks as i
|
|
8
|
+
} from "./QyFileContentUtils.js";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
pathSplit as n,
|
|
12
|
+
propNameSplit as a,
|
|
13
|
+
isString as s,
|
|
14
|
+
SpecialOperators as e,
|
|
15
|
+
getSuffix as g,
|
|
16
|
+
SpecialFilePaths as t,
|
|
17
|
+
toSingleName as C,
|
|
18
|
+
isSimpleType as c
|
|
19
|
+
} from "./QyUtils.js";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
QyAclCmdGenerator as r
|
|
23
|
+
} from "./QyAcl.js";
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
calDifferenceList as h
|
|
27
|
+
} from "./QyIndex.js";
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
getDefaultOptions as d
|
|
31
|
+
} from "./QyDefaultOptions.js";
|
|
32
|
+
|
|
33
|
+
import {
|
|
34
|
+
QyCD as m
|
|
35
|
+
} from "./QyCD.js";
|
|
36
|
+
|
|
37
|
+
import {
|
|
38
|
+
getPrefixPropPaths as y
|
|
39
|
+
} from "./QyIndexPropTree.js";
|
|
40
|
+
|
|
41
|
+
let u = Array.isArray, f = e.$del, D = t.IndexPropPathsFileName, p = {
|
|
14
42
|
none: 0,
|
|
15
43
|
basic: 1,
|
|
16
44
|
delta: 2,
|
|
17
45
|
all: 3
|
|
18
46
|
};
|
|
19
47
|
|
|
20
|
-
class
|
|
48
|
+
class v extends m {
|
|
21
49
|
constructor(e, t) {
|
|
22
50
|
super(e), t = {
|
|
23
|
-
...
|
|
51
|
+
...d("QyBatch"),
|
|
24
52
|
...t
|
|
25
53
|
};
|
|
26
|
-
e =
|
|
54
|
+
e = p[t.fileLogLevel.toLowerCase()];
|
|
27
55
|
Object.assign(this, {
|
|
28
56
|
options: t,
|
|
29
57
|
fileLogLevel: e ?? 1,
|
|
30
|
-
qyAclCmdGenerator: new
|
|
31
|
-
qyCmdObjHistory: new
|
|
58
|
+
qyAclCmdGenerator: new r(),
|
|
59
|
+
qyCmdObjHistory: new O(t.maxHistoryCmdObjCount),
|
|
32
60
|
actionQueue: [],
|
|
33
61
|
changeList: [],
|
|
34
62
|
syncList: []
|
|
35
63
|
});
|
|
36
64
|
}
|
|
37
65
|
createDir(e, t = this.currentDir) {
|
|
38
|
-
return
|
|
66
|
+
return s(e) && (e = n(e)), this.createDirP(e, t);
|
|
39
67
|
}
|
|
40
68
|
createDirP(e, t = this.currentDir) {
|
|
41
|
-
return this
|
|
69
|
+
return _(this, "createDir", this.qyCache.getOrCreateDir(e, t));
|
|
42
70
|
}
|
|
43
71
|
delDir(e, t = this.currentDir) {
|
|
44
|
-
return
|
|
72
|
+
return s(e) && (e = n(e)), this.delDirP(e, t);
|
|
45
73
|
}
|
|
46
74
|
delDirP(e, t = this.currentDir) {
|
|
47
|
-
return this
|
|
75
|
+
return _(this, "delDir", this.qyCache.getOrCreateDir(e, t));
|
|
48
76
|
}
|
|
49
77
|
createFile(e, t = this.currentDir) {
|
|
50
|
-
return
|
|
78
|
+
return s(e) && (e = n(e)), this.createFileP(e, t);
|
|
51
79
|
}
|
|
52
80
|
createFileP(e, t = this.currentDir) {
|
|
53
|
-
return this
|
|
81
|
+
return _(this, "createFile", this.qyCache.getOrCreateFile(e, t));
|
|
54
82
|
}
|
|
55
83
|
delFile(e, t = this.currentDir) {
|
|
56
|
-
return
|
|
84
|
+
return s(e) && (e = n(e)), this.delFileP(e, t);
|
|
57
85
|
}
|
|
58
86
|
delFileP(e, t = this.currentDir) {
|
|
59
|
-
return this
|
|
87
|
+
return _(this, "delFile", this.qyCache.getOrCreateFile(e, t));
|
|
60
88
|
}
|
|
61
|
-
createIndex(e, t,
|
|
62
|
-
return
|
|
89
|
+
createIndex(e, t, r = this.currentDir) {
|
|
90
|
+
return s(e) && (e = n(e)), this.createIndexP(e, t, r);
|
|
63
91
|
}
|
|
64
|
-
createIndexP(e, t,
|
|
65
|
-
return
|
|
92
|
+
createIndexP(e, t, r = this.currentDir) {
|
|
93
|
+
return u(t) || (t = [ t ]), _(this, "createIndex", this.qyCache.getOrCreateDir(e, r), {
|
|
66
94
|
indexPropPathList: t
|
|
67
95
|
});
|
|
68
96
|
}
|
|
69
|
-
delIndex(e, t,
|
|
70
|
-
return
|
|
97
|
+
delIndex(e, t, r = this.currentDir) {
|
|
98
|
+
return s(e) && (e = n(e)), this.delIndexP(e, t, r);
|
|
71
99
|
}
|
|
72
|
-
delIndexP(e, t,
|
|
73
|
-
return this
|
|
100
|
+
delIndexP(e, t, r = this.currentDir) {
|
|
101
|
+
return _(this, "delIndex", this.qyCache.getOrCreateDir(e, r), {
|
|
74
102
|
indexPropPath: t
|
|
75
103
|
});
|
|
76
104
|
}
|
|
77
|
-
insert(e, t,
|
|
78
|
-
return
|
|
105
|
+
insert(e, t, r = this.currentDir) {
|
|
106
|
+
return s(e) && (e = n(e)), this.insertP(e, t, r);
|
|
79
107
|
}
|
|
80
|
-
insertP(e, t,
|
|
81
|
-
return this
|
|
82
|
-
content:
|
|
108
|
+
insertP(e, t, r = this.currentDir) {
|
|
109
|
+
return _(this, "insert", this.qyCache.getOrCreateFile(e, r), {
|
|
110
|
+
content: c(t) ? t : structuredClone(t)
|
|
83
111
|
});
|
|
84
112
|
}
|
|
85
|
-
remove(e, t,
|
|
86
|
-
return this.insert(e,
|
|
113
|
+
remove(e, t, r = this.currentDir) {
|
|
114
|
+
return this.insert(e, i(t), r);
|
|
87
115
|
}
|
|
88
|
-
removeP(e, t,
|
|
89
|
-
return this.insertP(e,
|
|
116
|
+
removeP(e, t, r = this.currentDir) {
|
|
117
|
+
return this.insertP(e, i(t), r);
|
|
90
118
|
}
|
|
91
|
-
replace(e, t,
|
|
119
|
+
replace(e, t, r = this.currentDir) {
|
|
92
120
|
return this.insert(e, {
|
|
93
121
|
$rpl: t
|
|
94
|
-
},
|
|
122
|
+
}, r);
|
|
95
123
|
}
|
|
96
|
-
replaceP(e, t,
|
|
124
|
+
replaceP(e, t, r = this.currentDir) {
|
|
97
125
|
return this.insertP(e, {
|
|
98
126
|
$rpl: t
|
|
99
|
-
},
|
|
127
|
+
}, r);
|
|
100
128
|
}
|
|
101
129
|
delContent(e, t = this.currentDir) {
|
|
102
|
-
return
|
|
130
|
+
return s(e) && (e = n(e)), this.delContentP(e, t);
|
|
103
131
|
}
|
|
104
132
|
delContentP(e, t = this.currentDir) {
|
|
105
|
-
return this
|
|
133
|
+
return _(this, "delContent", this.qyCache.getOrCreateFile(e, t));
|
|
106
134
|
}
|
|
107
|
-
insertTrigger(e, t,
|
|
108
|
-
return
|
|
109
|
-
this
|
|
135
|
+
insertTrigger(e, t, r, i) {
|
|
136
|
+
return s(t) && (t = n(t)), r = (r = s(r) ? [ r ] : r).map(e => s(e) ? a(e) : e),
|
|
137
|
+
_(this, "insertTrigger", this.qyCache.getOrCreateTriggerFile(e), {
|
|
110
138
|
fileNamePath: t,
|
|
111
|
-
propNamePathList:
|
|
112
|
-
modCode:
|
|
139
|
+
propNamePathList: r,
|
|
140
|
+
modCode: i
|
|
113
141
|
});
|
|
114
142
|
}
|
|
115
143
|
removeTrigger(e) {
|
|
116
|
-
return this
|
|
144
|
+
return _(this, "removeTrigger", this.qyCache.getOrCreateTriggerFile(e));
|
|
117
145
|
}
|
|
118
146
|
insertRpc(e, t) {
|
|
119
|
-
return this
|
|
147
|
+
return _(this, "insertRpc", this.qyCache.getOrCreateRpcFile(e), {
|
|
120
148
|
modCode: t
|
|
121
149
|
});
|
|
122
150
|
}
|
|
123
151
|
removeRpc(e) {
|
|
124
|
-
return this
|
|
152
|
+
return _(this, "removeRpc", this.qyCache.getOrCreateRpcFile(e));
|
|
125
153
|
}
|
|
126
154
|
run(e) {
|
|
127
155
|
var {
|
|
128
156
|
actionQueue: t,
|
|
129
|
-
fileLogLevel:
|
|
130
|
-
qyCache:
|
|
157
|
+
fileLogLevel: r,
|
|
158
|
+
qyCache: i
|
|
131
159
|
} = this;
|
|
132
160
|
if (0 == t.length) return 0;
|
|
133
|
-
var n, a = this.changeId =
|
|
161
|
+
var n, a = this.changeId = i.increaseChangeId();
|
|
134
162
|
for (n of t) this["_action_" + n.actionName](n);
|
|
135
163
|
t.length = 0, this.resetCurrentDir();
|
|
136
164
|
var {
|
|
137
165
|
changeList: t,
|
|
138
166
|
qyAclCmdGenerator: s,
|
|
139
167
|
qyCmdObjHistory: o,
|
|
140
|
-
syncList:
|
|
141
|
-
} = this,
|
|
142
|
-
if (0 ==
|
|
143
|
-
var
|
|
168
|
+
syncList: l
|
|
169
|
+
} = this, c = t.length;
|
|
170
|
+
if (0 == c) return i.decreaseChangeId(), 0;
|
|
171
|
+
var h = g(c), s = s.takeCmdArgAsListObj();
|
|
144
172
|
let d;
|
|
145
|
-
0 <
|
|
173
|
+
0 < r && (r = t.map(({
|
|
146
174
|
logStr: e
|
|
147
|
-
}) => e).join("\n"), d = new Date().toISOString() + `: ${
|
|
148
|
-
${
|
|
175
|
+
}) => e).join("\n"), d = new Date().toISOString() + `: ${c} change${h}:
|
|
176
|
+
${r}
|
|
149
177
|
`);
|
|
150
|
-
var
|
|
151
|
-
|
|
178
|
+
var m, u, c = i.save(a, s, d, (e => {
|
|
179
|
+
var t = e.syncList, r = t.length;
|
|
180
|
+
for (let e = 0; e < r; e += 2) {
|
|
181
|
+
var i, n = e + 1, a = t[e], s = t[n];
|
|
182
|
+
a.startsWith("d") ? (i = s.subdirNameList, t[n] = 0 < i.length ? i : void 0) : a.startsWith("f") ? (i = s.fileNameList,
|
|
183
|
+
t[n] = 0 < i.length ? i : void 0) : t[n] = s.fileContent;
|
|
184
|
+
}
|
|
185
|
+
if (0 < r) return t;
|
|
186
|
+
})(this), e), h = (l.length = 0, o.push(s), t.filter(({
|
|
152
187
|
item: e,
|
|
153
188
|
delta: t
|
|
154
189
|
}) => t && 0 < e.triggerNodes?.length));
|
|
155
190
|
t.length = 0;
|
|
156
191
|
for ({
|
|
157
|
-
item:
|
|
158
|
-
delta:
|
|
159
|
-
} of
|
|
160
|
-
return e ?
|
|
192
|
+
item: m,
|
|
193
|
+
delta: u
|
|
194
|
+
} of h) for (var f of m.triggerNodes) f.checkTrigger(m, u);
|
|
195
|
+
return e ? c : a;
|
|
161
196
|
}
|
|
162
197
|
getTopHistoryCmdObj() {
|
|
163
198
|
return this.qyCmdObjHistory.top();
|
|
164
199
|
}
|
|
165
|
-
_updateIndex(e, t, i, r) {
|
|
166
|
-
var {
|
|
167
|
-
underHiddenFolder: e,
|
|
168
|
-
name: n,
|
|
169
|
-
parentDir: a
|
|
170
|
-
} = e;
|
|
171
|
-
if (!e) {
|
|
172
|
-
var s = this.qyCache.getIndexDir(a);
|
|
173
|
-
if (s) {
|
|
174
|
-
e = s.getFile(IndexPropPathsFileName);
|
|
175
|
-
if (e) for (var o of e.qyIndexPropTree.getAllIndexPropPaths()) this._createLinksInIndexPropDir(s.searchOrCreateSubdir(o), o, n, t, i, r);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
_createLinksInIndexPropDir(e, t, i, r, n, a) {
|
|
180
|
-
e = calDifferenceList(e, t, i, r, n, a);
|
|
181
|
-
if (e) {
|
|
182
|
-
var s, o, h, {
|
|
183
|
-
toAddFileList: t,
|
|
184
|
-
toDelFileList: i
|
|
185
|
-
} = e;
|
|
186
|
-
for (s of t) this._action_createFile({
|
|
187
|
-
item: s
|
|
188
|
-
});
|
|
189
|
-
for (o of i) this._action_delFile({
|
|
190
|
-
item: o
|
|
191
|
-
});
|
|
192
|
-
for (h of i) {
|
|
193
|
-
let e = h.parentDir;
|
|
194
|
-
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) this._action_delDir({
|
|
195
|
-
item: e
|
|
196
|
-
}), e = e.parentDir;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
200
|
_action_insertTrigger(e) {
|
|
201
201
|
e.actionName = "insertTrigger";
|
|
202
202
|
var t, {
|
|
203
203
|
item: e,
|
|
204
|
-
fileNamePath:
|
|
205
|
-
propNamePathList:
|
|
204
|
+
fileNamePath: r,
|
|
205
|
+
propNamePathList: i,
|
|
206
206
|
modCode: n
|
|
207
207
|
} = e, {
|
|
208
208
|
name: a,
|
|
@@ -210,36 +210,36 @@ ${i}
|
|
|
210
210
|
} = e, e = this._action_insert({
|
|
211
211
|
item: e,
|
|
212
212
|
content: {
|
|
213
|
-
fileNamePath:
|
|
214
|
-
propNamePathList:
|
|
213
|
+
fileNamePath: r,
|
|
214
|
+
propNamePathList: i,
|
|
215
215
|
modCode: n
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
|
-
return e && (t = this.qyCache, s && !
|
|
219
|
-
t.insertTriggerToTree(a,
|
|
218
|
+
return e && (t = this.qyCache, s && !o(s.fileNamePath, r) && t.removeTriggerFromTree(a, s.fileNamePath),
|
|
219
|
+
t.insertTriggerToTree(a, r, i, n)), e;
|
|
220
220
|
}
|
|
221
221
|
_action_removeTrigger(e) {
|
|
222
222
|
e.actionName = "removeTrigger";
|
|
223
223
|
var e = e.item, {
|
|
224
224
|
fileContent: t,
|
|
225
|
-
name:
|
|
225
|
+
name: r
|
|
226
226
|
} = e;
|
|
227
227
|
return !!this._action_delFile({
|
|
228
228
|
item: e
|
|
229
|
-
}) && (this.qyCache.removeTriggerFromTree(
|
|
229
|
+
}) && (this.qyCache.removeTriggerFromTree(r, t.fileNamePath), !0);
|
|
230
230
|
}
|
|
231
231
|
_action_insertRpc(e) {
|
|
232
232
|
e.actionName = "insertRpc";
|
|
233
233
|
var {
|
|
234
234
|
item: e,
|
|
235
235
|
modCode: t
|
|
236
|
-
} = e,
|
|
236
|
+
} = e, r = this._action_insert({
|
|
237
237
|
item: e,
|
|
238
238
|
content: {
|
|
239
239
|
modCode: t
|
|
240
240
|
}
|
|
241
241
|
});
|
|
242
|
-
return
|
|
242
|
+
return r && this.qyCache.insertRpc(e.name, t), r;
|
|
243
243
|
}
|
|
244
244
|
_action_removeRpc(e) {
|
|
245
245
|
e.actionName = "removeRpc";
|
|
@@ -248,57 +248,77 @@ ${i}
|
|
|
248
248
|
item: e
|
|
249
249
|
}) && (this.qyCache.removeRpc(e.name), !0);
|
|
250
250
|
}
|
|
251
|
-
_action_createIndex(
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
item:
|
|
255
|
-
indexPropPathList:
|
|
256
|
-
} =
|
|
251
|
+
_action_createIndex(t) {
|
|
252
|
+
t.actionName = "createIndex";
|
|
253
|
+
var e, {
|
|
254
|
+
item: t,
|
|
255
|
+
indexPropPathList: r
|
|
256
|
+
} = t, i = this.qyCache.getOrCreateIndexDir(t), n = i.getOrCreateFile(D), {
|
|
257
257
|
fileContent: a,
|
|
258
258
|
qyIndexPropTree: s
|
|
259
259
|
} = (n.created || this._action_createFile({
|
|
260
260
|
item: n
|
|
261
|
-
}), n), o = [],
|
|
262
|
-
for (
|
|
263
|
-
var
|
|
264
|
-
a && a[
|
|
261
|
+
}), n), o = [], l = {};
|
|
262
|
+
for (e of r) {
|
|
263
|
+
var c = C(e);
|
|
264
|
+
a && a[c] || (o.push(e), l[c] = 1, s.insert(e));
|
|
265
|
+
}
|
|
266
|
+
if (0 != o.length) {
|
|
267
|
+
logger.log(`Creating index ${JSON.stringify(o)} for ` + t.fullPath),
|
|
268
|
+
this._action_insert({
|
|
269
|
+
item: n,
|
|
270
|
+
content: l
|
|
271
|
+
});
|
|
272
|
+
{
|
|
273
|
+
var h, d = this, m = t, u = i, r = y(o);
|
|
274
|
+
let e;
|
|
275
|
+
for (h of r) {
|
|
276
|
+
var f = u.searchOrCreateSubdir(h);
|
|
277
|
+
if (!f.created) {
|
|
278
|
+
d._action_createDir({
|
|
279
|
+
item: f
|
|
280
|
+
});
|
|
281
|
+
for (var g of e = e || m.fileList) {
|
|
282
|
+
var {
|
|
283
|
+
fileContent: g,
|
|
284
|
+
name: p
|
|
285
|
+
} = g;
|
|
286
|
+
null != g && N(d, f, h, p, void 0, g);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
265
291
|
}
|
|
266
|
-
0 != o.length && (logger.log(`Creating index ${JSON.stringify(o)} for ` + e.fullPath),
|
|
267
|
-
this._action_insert({
|
|
268
|
-
item: n,
|
|
269
|
-
content: h
|
|
270
|
-
}), this._addNewIndexPropPaths(e, r, getPrefixPropPaths(o)));
|
|
271
292
|
}
|
|
272
293
|
_action_delIndex(e) {
|
|
273
294
|
e.actionName = "delIndex";
|
|
274
|
-
var t,
|
|
295
|
+
var t, r, {
|
|
275
296
|
item: e,
|
|
276
|
-
indexPropPath:
|
|
297
|
+
indexPropPath: i
|
|
277
298
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
278
|
-
e && ((
|
|
279
|
-
|
|
280
|
-
item: i,
|
|
299
|
+
e && ((r = e.getFile(D)) ? (t = r.qyIndexPropTree, this._action_insert({
|
|
300
|
+
item: r,
|
|
281
301
|
content: {
|
|
282
|
-
[
|
|
302
|
+
[C(i)]: f
|
|
283
303
|
}
|
|
284
|
-
}), t.remove(
|
|
285
|
-
item:
|
|
304
|
+
}), t.remove(i).hasPrefix || (r = e.getSubdir(i)) && this._action_delDir({
|
|
305
|
+
item: r
|
|
286
306
|
})) : this._action_delDir({
|
|
287
307
|
item: e
|
|
288
308
|
}));
|
|
289
309
|
}
|
|
290
310
|
_action_delFile(e, t) {
|
|
291
311
|
e.actionName = "delFile";
|
|
292
|
-
var
|
|
293
|
-
if (!
|
|
294
|
-
null !=
|
|
295
|
-
item:
|
|
312
|
+
var r = e.item;
|
|
313
|
+
if (!r.created) return !1;
|
|
314
|
+
null != r.fileContent && this._action_delContent({
|
|
315
|
+
item: r
|
|
296
316
|
});
|
|
297
317
|
var {
|
|
298
|
-
parentDir:
|
|
318
|
+
parentDir: i,
|
|
299
319
|
name: n
|
|
300
|
-
} =
|
|
301
|
-
return
|
|
320
|
+
} = r;
|
|
321
|
+
return r.created = !1, P(this, e), t || x(this, i, "R", i.fileMapKey, n),
|
|
302
322
|
!0;
|
|
303
323
|
}
|
|
304
324
|
_action_delDir(e) {
|
|
@@ -306,196 +326,211 @@ ${i}
|
|
|
306
326
|
var t = e.item;
|
|
307
327
|
if (!t.created) return !1;
|
|
308
328
|
let {
|
|
309
|
-
parentDir:
|
|
310
|
-
name:
|
|
329
|
+
parentDir: r,
|
|
330
|
+
name: i,
|
|
311
331
|
subdirMap: n,
|
|
312
332
|
fileMap: a,
|
|
313
333
|
subdirMapKey: s,
|
|
314
334
|
fileMapKey: o
|
|
315
335
|
} = t;
|
|
316
336
|
if (a) {
|
|
317
|
-
this
|
|
318
|
-
for (var
|
|
319
|
-
item:
|
|
337
|
+
x(this, t, "D", o);
|
|
338
|
+
for (var l of t.fileList) this._action_delFile({
|
|
339
|
+
item: l
|
|
320
340
|
}, !0);
|
|
321
341
|
}
|
|
322
342
|
if (n) {
|
|
323
|
-
this
|
|
324
|
-
for (var
|
|
343
|
+
x(this, t, "D", s);
|
|
344
|
+
for (var c of t.allSubdirs()) {
|
|
325
345
|
let {
|
|
326
346
|
subdirMap: e,
|
|
327
347
|
fileMap: t,
|
|
328
|
-
subdirMapKey:
|
|
329
|
-
fileMapKey:
|
|
330
|
-
} =
|
|
331
|
-
if (e && this
|
|
332
|
-
this
|
|
333
|
-
for (var
|
|
334
|
-
item:
|
|
348
|
+
subdirMapKey: r,
|
|
349
|
+
fileMapKey: i
|
|
350
|
+
} = c;
|
|
351
|
+
if (e && x(this, c, "D", r), t) {
|
|
352
|
+
x(this, c, "D", i);
|
|
353
|
+
for (var h of c.fileList) this._action_delFile({
|
|
354
|
+
item: h
|
|
335
355
|
}, !0);
|
|
336
356
|
}
|
|
337
|
-
this
|
|
357
|
+
P(this, {
|
|
338
358
|
actionName: "delDir",
|
|
339
|
-
item:
|
|
340
|
-
}),
|
|
359
|
+
item: c
|
|
360
|
+
}), c.created = !1;
|
|
341
361
|
}
|
|
342
362
|
}
|
|
343
|
-
return !!
|
|
363
|
+
return !!r && (t.created = !1, P(this, e), x(this, r, "R", r.subdirMapKey, i),
|
|
344
364
|
!0);
|
|
345
365
|
}
|
|
346
366
|
_action_delContent(e) {
|
|
347
367
|
e.actionName = "delContent";
|
|
348
|
-
var t = e.item,
|
|
349
|
-
return null !=
|
|
350
|
-
content:
|
|
368
|
+
var t = e.item, r = t.fileContent;
|
|
369
|
+
return null != r && (t.setContent(void 0), Object.assign(e, {
|
|
370
|
+
content: r,
|
|
351
371
|
delta: {
|
|
352
|
-
oldValue:
|
|
353
|
-
newValue:
|
|
372
|
+
oldValue: r,
|
|
373
|
+
newValue: f
|
|
354
374
|
}
|
|
355
|
-
}), this
|
|
356
|
-
!0);
|
|
375
|
+
}), P(this, e), x(this, t, "D", t.fileContentKey), F(this, t, r), !0);
|
|
357
376
|
}
|
|
358
377
|
_action_insert(e) {
|
|
359
378
|
e.actionName = "insert";
|
|
360
379
|
var {
|
|
361
380
|
item: t,
|
|
362
|
-
content:
|
|
381
|
+
content: r
|
|
363
382
|
} = e;
|
|
364
|
-
if (null ==
|
|
383
|
+
if (null == r) return logger.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
365
384
|
!1;
|
|
366
385
|
t.created || this._action_createFile({
|
|
367
386
|
item: t
|
|
368
387
|
});
|
|
369
|
-
var
|
|
388
|
+
var i, n, r = l(t.fileContent, r), {
|
|
370
389
|
merged: a,
|
|
371
390
|
delta: s
|
|
372
|
-
} =
|
|
391
|
+
} = r;
|
|
373
392
|
return !!s && ({
|
|
374
393
|
oldValue: s,
|
|
375
|
-
newValue:
|
|
376
|
-
} = s, !!
|
|
377
|
-
Object.assign(e,
|
|
378
|
-
!0);
|
|
394
|
+
newValue: i
|
|
395
|
+
} = s, !!i) && (n = t.fileContentKey, null == a ? x(this, t, "D", n) : x(this, t, "M", n, i),
|
|
396
|
+
Object.assign(e, r), P(this, e), t.setContent(a), F(this, t, s, i, a), !0);
|
|
379
397
|
}
|
|
380
398
|
_action_createFile(e) {
|
|
381
399
|
e.actionName = "createFile";
|
|
382
|
-
var t,
|
|
383
|
-
return !
|
|
400
|
+
var t, r = e.item;
|
|
401
|
+
return !r.created && (t = r.parentDir, this._action_createDir({
|
|
384
402
|
item: t
|
|
385
|
-
}), Object.assign(
|
|
403
|
+
}), Object.assign(r, {
|
|
386
404
|
created: !0,
|
|
387
405
|
fileContentLoaded: !0
|
|
388
|
-
}), this
|
|
406
|
+
}), P(this, e), x(this, t, "A", t.fileMapKey, r.name), !0);
|
|
389
407
|
}
|
|
390
408
|
_action_createDir(e) {
|
|
391
409
|
e.actionName = "createDir";
|
|
392
410
|
let t = e.item;
|
|
393
411
|
if (t.created) return !1;
|
|
394
|
-
for (var
|
|
395
|
-
for (let e of
|
|
412
|
+
for (var r = []; !t.created; ) r.push(t), t = t.parentDir;
|
|
413
|
+
for (let e of r.reverse()) {
|
|
396
414
|
Object.assign(e, {
|
|
397
415
|
created: !0,
|
|
398
416
|
subdirMapLoaded: !0,
|
|
399
417
|
fileMapLoaded: !0
|
|
400
|
-
}), this
|
|
418
|
+
}), P(this, {
|
|
401
419
|
actionName: "createDir",
|
|
402
420
|
item: e
|
|
403
421
|
});
|
|
404
|
-
var
|
|
405
|
-
this
|
|
422
|
+
var i = e.parentDir;
|
|
423
|
+
x(this, i, "A", i.subdirMapKey, e.name);
|
|
406
424
|
}
|
|
407
425
|
return !0;
|
|
408
426
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
_pushChange(e) {
|
|
428
|
-
var {
|
|
429
|
-
changeList: t,
|
|
430
|
-
fileLogLevel: i
|
|
431
|
-
} = this;
|
|
432
|
-
0 < i && (e.logStr = this._toLogStr(e, i)), t.push(e);
|
|
433
|
-
}
|
|
434
|
-
_toLogStr(e, t) {
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function _(e, t, r, i) {
|
|
430
|
+
return e.actionQueue.push({
|
|
431
|
+
actionName: t,
|
|
432
|
+
item: r,
|
|
433
|
+
...i
|
|
434
|
+
}), e;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function P(e, t) {
|
|
438
|
+
var {
|
|
439
|
+
changeList: e,
|
|
440
|
+
fileLogLevel: r
|
|
441
|
+
} = e;
|
|
442
|
+
0 < r && (t.logStr = ((e, t) => {
|
|
435
443
|
var {
|
|
436
444
|
actionName: e,
|
|
437
|
-
item:
|
|
438
|
-
content:
|
|
445
|
+
item: r,
|
|
446
|
+
content: i,
|
|
439
447
|
merged: n,
|
|
440
448
|
delta: a
|
|
441
|
-
} = e,
|
|
449
|
+
} = e, r = e + ` "${r.fullPath ?? r}"`;
|
|
442
450
|
if ("delContent" === e) {
|
|
443
|
-
if (3 == t) return
|
|
451
|
+
if (3 == t) return r + " " + JSON.stringify(i);
|
|
444
452
|
} else if ("insert" === e && 2 <= t) return {
|
|
445
|
-
oldValue:
|
|
453
|
+
oldValue: i,
|
|
446
454
|
newValue: e
|
|
447
|
-
} = a, a = `${null ==
|
|
448
|
-
2 == t ?
|
|
449
|
-
return
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
} = a, a = `${null == i ? "" : "delta:"} ${JSON.stringify(i)} -> ` + JSON.stringify(e),
|
|
456
|
+
2 == t ? r + " " + a : r + ` ${a}. ` + (null != i ? "new: " + JSON.stringify(n) : "");
|
|
457
|
+
return r;
|
|
458
|
+
})(t, r)), e.push(t);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function x(e, t, r, i, n) {
|
|
462
|
+
var {
|
|
463
|
+
qyAclCmdGenerator: e,
|
|
464
|
+
qyCache: a,
|
|
465
|
+
syncList: s,
|
|
466
|
+
changeId: o
|
|
467
|
+
} = e;
|
|
468
|
+
e.pushCmd(r, i, n), i.startsWith("d") ? t.dChangeId = o : i.startsWith("f") ? t.fChangeId = o : t.cChangeId = o,
|
|
469
|
+
a && a.qyKVData.removeKey(i) && s.push(i, t);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function F(e, t, r, i, n) {
|
|
473
|
+
var {
|
|
474
|
+
underHiddenFolder: t,
|
|
475
|
+
name: a,
|
|
476
|
+
parentDir: s
|
|
477
|
+
} = t;
|
|
478
|
+
if (!t) {
|
|
479
|
+
var o = e.qyCache.getIndexDir(s);
|
|
480
|
+
if (o) {
|
|
481
|
+
t = o.getFile(D);
|
|
482
|
+
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) N(e, o.searchOrCreateSubdir(l), l, a, r, i, n);
|
|
483
|
+
}
|
|
457
484
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
for (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function N(t, e, r, i, n, a, s) {
|
|
488
|
+
e = h(e, r, i, n, a, s);
|
|
489
|
+
if (e) {
|
|
490
|
+
var o, l, c, {
|
|
491
|
+
toAddFileList: r,
|
|
492
|
+
toDelFileList: i
|
|
493
|
+
} = e;
|
|
494
|
+
for (o of r) t._action_createFile({
|
|
495
|
+
item: o
|
|
496
|
+
});
|
|
497
|
+
for (l of i) t._action_delFile({
|
|
498
|
+
item: l
|
|
499
|
+
});
|
|
500
|
+
for (c of i) {
|
|
501
|
+
let e = c.parentDir;
|
|
502
|
+
for (;e.created && !e.isHiddenFolder && e.isEmpty; ) t._action_delDir({
|
|
503
|
+
item: e
|
|
504
|
+
}), e = e.parentDir;
|
|
474
505
|
}
|
|
475
|
-
if (0 < i) return t;
|
|
476
506
|
}
|
|
477
507
|
}
|
|
478
508
|
|
|
479
|
-
class
|
|
480
|
-
nextPos = 0;
|
|
481
|
-
actionQueue = [];
|
|
509
|
+
class O {
|
|
482
510
|
constructor(e) {
|
|
483
|
-
this
|
|
511
|
+
Object.assign(this, {
|
|
512
|
+
maxLength: e,
|
|
513
|
+
nextPos: 0,
|
|
514
|
+
actionQueue: []
|
|
515
|
+
});
|
|
484
516
|
}
|
|
485
517
|
push(e) {
|
|
486
|
-
|
|
518
|
+
var {
|
|
519
|
+
maxLength: t,
|
|
520
|
+
nextPos: r
|
|
521
|
+
} = this;
|
|
522
|
+
this.actionQueue[r] = e, this.nextPos = ((e, t) => (t += 1) < e ? t : 0)(t, r);
|
|
487
523
|
}
|
|
488
524
|
top() {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return 0 < e ? e - 1 : this.maxLength - 1;
|
|
525
|
+
var {
|
|
526
|
+
actionQueue: e,
|
|
527
|
+
maxLength: t,
|
|
528
|
+
nextPos: r
|
|
529
|
+
} = this;
|
|
530
|
+
return e[e = t, (0 < (t = r) ? t : e) - 1];
|
|
496
531
|
}
|
|
497
532
|
}
|
|
498
533
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
534
|
+
export {
|
|
535
|
+
v as QyBatch
|
|
536
|
+
};
|