datafolder 1.0.0
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 +169 -0
- package/index.js +3 -0
- package/package.json +27 -0
- package/sample.js +37 -0
- package/scripts/airbnb.js +73 -0
- package/scripts/airbnb2.js +74 -0
- package/scripts/airbnb2_queries.js +231 -0
- package/scripts/airbnb_queries.js +264 -0
- package/scripts/downloadFile.js +42 -0
- package/scripts/express.js +46 -0
- package/scripts/fastify.js +79 -0
- package/scripts/flights.js +75 -0
- package/scripts/flights2.js +81 -0
- package/scripts/flights2_queries.js +453 -0
- package/scripts/flights_queries.js +403 -0
- package/src/QyAcl.js +252 -0
- package/src/QyAclSaver.js +14 -0
- package/src/QyAclSaver_Worker.js +29 -0
- package/src/QyAclWriter.js +19 -0
- package/src/QyBatch.js +501 -0
- package/src/QyBinWriter.js +140 -0
- package/src/QyCD.js +61 -0
- package/src/QyCache.js +212 -0
- package/src/QyCompressor.js +60 -0
- package/src/QyCompressor_Worker.js +13 -0
- package/src/QyDB.js +122 -0
- package/src/QyDefaultOptions.js +59 -0
- package/src/QyDir.js +192 -0
- package/src/QyFetch.js +38 -0
- package/src/QyFile.js +124 -0
- package/src/QyFileContentUtils.js +175 -0
- package/src/QyFileLogger.js +58 -0
- package/src/QyIndex.js +237 -0
- package/src/QyIndexPropTree.js +92 -0
- package/src/QyIntersectNode.js +48 -0
- package/src/QyItem.js +105 -0
- package/src/QyJsonSaver.js +20 -0
- package/src/QyKVData.js +289 -0
- package/src/QyKVDataCleaner.js +17 -0
- package/src/QyKVDataCleaner_Worker.js +94 -0
- package/src/QyKVDataLoader.js +65 -0
- package/src/QyKVDataSaver.js +17 -0
- package/src/QyKVDataSaver_Worker.js +81 -0
- package/src/QyLogFileSaver.js +14 -0
- package/src/QyLogFileSaver_Worker.js +26 -0
- package/src/QyLogger.js +76 -0
- package/src/QyMessageWorker.js +41 -0
- package/src/QyMessager.js +84 -0
- package/src/QyMessager_Run.js +13 -0
- package/src/QyMod.js +15 -0
- package/src/QyOpRunner.js +73 -0
- package/src/QyQueue.js +60 -0
- package/src/QySaver.js +83 -0
- package/src/QySnapshotCompactor.js +17 -0
- package/src/QySnapshotCompactor_Worker.js +151 -0
- package/src/QySnapshotSaver.js +17 -0
- package/src/QySnapshotSaver_Worker.js +164 -0
- package/src/QySnapshots.js +354 -0
- package/src/QyStructure.js +50 -0
- package/src/QyTrigger.js +133 -0
- package/src/QyUnionNode.js +105 -0
- package/src/QyUtils.js +250 -0
- package/src/QyWorker.js +33 -0
- package/src/hackernews.js +93 -0
- package/src/rpc/evalCode.js +9 -0
- package/src/rpc/getFileContent.js +16 -0
- package/src/rpc/getSubItems.js +32 -0
- package/src/rpc/queryFiles.js +33 -0
- package/src/rpc/reloadRpc.js +1 -0
- package/src/simulate.js +114 -0
- package/src/simulate2.js +110 -0
- package/src/soc_pokec.js +43 -0
- package/static/bootstrap-5.3.8-dist/css/bootstrap.min.css +6 -0
- package/static/bootstrap-5.3.8-dist/js/bootstrap.bundle.js +6312 -0
- package/static/datafolderui/QyStyledElement.js +30 -0
- package/static/datafolderui/QyUIFolderTree.js +203 -0
- package/static/datafolderui/QyUIUtils.js +42 -0
- package/static/datafolderui/display-tree.js +108 -0
- package/static/datafolderui/explore-tree.js +122 -0
- package/static/datafolderui/folder-tree.js +5 -0
- package/static/datafolderui/hscrpt.js +25 -0
- package/static/datafolderui/index.css +6 -0
- package/static/datafolderui/index.html +20 -0
- package/static/datafolderui/json-view.js +74 -0
- package/static/datafolderui/kv-input.js +66 -0
- package/static/datafolderui/list-input.js +52 -0
- package/static/datafolderui/main-page.js +98 -0
- package/static/datafolderui/num-input.js +27 -0
- package/static/datafolderui/query-editor.js +229 -0
- package/static/datafolderui/querySelectorShadowRoot.js +24 -0
- package/static/datafolderui/resizable-input.js +67 -0
- package/static/favicon.ico +0 -0
- package/static/icons-1.13.1/font/bootstrap-icons.min.css +5 -0
- package/static/icons-1.13.1/font/fonts/bootstrap-icons.woff +0 -0
- package/static/icons-1.13.1/font/fonts/bootstrap-icons.woff2 +0 -0
- package/static/json-view/dist/jsonview.js +433 -0
- package/static/tree.js/tree.css +106 -0
- package/static/tree.js/tree.js +374 -0
- package/static/w2ui/dist/w2ui.min.css +2 -0
- package/static/w2ui/src/less/icons/icons.json +1 -0
- package/static/w2ui/src/less/icons/preview.html +33 -0
- package/static/w2ui/src/less/icons/readme.md +15 -0
- package/static/w2ui/src/less/icons/svg/box.svg +3 -0
- package/static/w2ui/src/less/icons/svg/check.svg +3 -0
- package/static/w2ui/src/less/icons/svg/colors.svg +3 -0
- package/static/w2ui/src/less/icons/svg/columns.svg +5 -0
- package/static/w2ui/src/less/icons/svg/cross.svg +4 -0
- package/static/w2ui/src/less/icons/svg/drop.svg +6 -0
- package/static/w2ui/src/less/icons/svg/empty.svg +3 -0
- package/static/w2ui/src/less/icons/svg/eye-dropper.svg +4 -0
- package/static/w2ui/src/less/icons/svg/info.svg +8 -0
- package/static/w2ui/src/less/icons/svg/paste.svg +4 -0
- package/static/w2ui/src/less/icons/svg/pencil.svg +5 -0
- package/static/w2ui/src/less/icons/svg/plus.svg +3 -0
- package/static/w2ui/src/less/icons/svg/reload.svg +5 -0
- package/static/w2ui/src/less/icons/svg/search.svg +3 -0
- package/static/w2ui/src/less/icons/svg/settings.svg +8 -0
- package/static/w2ui/src/less/icons/w2ui-font.css +36 -0
- package/static/w2ui/src/less/icons/w2ui-font.woff +0 -0
- package/static/w2ui/src/less/src/buttons.less +184 -0
- package/static/w2ui/src/less/src/common.less +541 -0
- package/static/w2ui/src/less/src/fields.less +302 -0
- package/static/w2ui/src/less/src/form.less +319 -0
- package/static/w2ui/src/less/src/grid.less +1057 -0
- package/static/w2ui/src/less/src/icons.less +37 -0
- package/static/w2ui/src/less/src/layout.less +86 -0
- package/static/w2ui/src/less/src/mixins.less +87 -0
- package/static/w2ui/src/less/src/popup.less +277 -0
- package/static/w2ui/src/less/src/sidebar.less +343 -0
- package/static/w2ui/src/less/src/tabs.less +145 -0
- package/static/w2ui/src/less/src/toolbar.less +219 -0
- package/static/w2ui/src/less/src/tooltip.less +948 -0
- package/static/w2ui/src/less/w2ui.less +196 -0
- package/static/w2ui/src/locale/az-az.json +114 -0
- package/static/w2ui/src/locale/ba-ba.json +114 -0
- package/static/w2ui/src/locale/bg-bg.json +114 -0
- package/static/w2ui/src/locale/ca-es.json +114 -0
- package/static/w2ui/src/locale/da-dk.json +114 -0
- package/static/w2ui/src/locale/de-de.json +114 -0
- package/static/w2ui/src/locale/en-gb.json +17 -0
- package/static/w2ui/src/locale/en-us.json +17 -0
- package/static/w2ui/src/locale/es-ar.json +115 -0
- package/static/w2ui/src/locale/es-cr.json +119 -0
- package/static/w2ui/src/locale/es-es.json +114 -0
- package/static/w2ui/src/locale/es-mx.json +114 -0
- package/static/w2ui/src/locale/fr-fr.json +114 -0
- package/static/w2ui/src/locale/gl-es.json +114 -0
- package/static/w2ui/src/locale/hr-hr.json +114 -0
- package/static/w2ui/src/locale/hu-hu.json +114 -0
- package/static/w2ui/src/locale/id-id.json +114 -0
- package/static/w2ui/src/locale/it-it.json +114 -0
- package/static/w2ui/src/locale/ja-jp.json +114 -0
- package/static/w2ui/src/locale/kk-kz.json +116 -0
- package/static/w2ui/src/locale/ko-kr.json +114 -0
- package/static/w2ui/src/locale/lt-lt.json +114 -0
- package/static/w2ui/src/locale/nl-nl.json +114 -0
- package/static/w2ui/src/locale/no-no.json +114 -0
- package/static/w2ui/src/locale/pl-pl.json +114 -0
- package/static/w2ui/src/locale/pt-br.json +114 -0
- package/static/w2ui/src/locale/ru-ru.json +116 -0
- package/static/w2ui/src/locale/sk-sk.json +114 -0
- package/static/w2ui/src/locale/sl-si.json +116 -0
- package/static/w2ui/src/locale/sr-rs.json +114 -0
- package/static/w2ui/src/locale/tr-tr.json +114 -0
- package/static/w2ui/src/locale/uk-ua.json +114 -0
- package/static/w2ui/src/locale/zh-cn.json +114 -0
- package/static/w2ui/src/locale/zh-tw.json +114 -0
- package/static/w2ui/src/query.js +583 -0
- package/static/w2ui/src/readme.md +11 -0
- package/static/w2ui/src/w2base.js +311 -0
- package/static/w2ui/src/w2compat.js +207 -0
- package/static/w2ui/src/w2field.js +1854 -0
- package/static/w2ui/src/w2form.js +2411 -0
- package/static/w2ui/src/w2grid.js +8916 -0
- package/static/w2ui/src/w2layout.js +1194 -0
- package/static/w2ui/src/w2locale.js +129 -0
- package/static/w2ui/src/w2popup.js +909 -0
- package/static/w2ui/src/w2sidebar.js +1769 -0
- package/static/w2ui/src/w2tabs.js +669 -0
- package/static/w2ui/src/w2toolbar.js +1180 -0
- package/static/w2ui/src/w2tooltip.js +3134 -0
- package/static/w2ui/src/w2utils.js +2457 -0
package/src/QyIndex.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
let {
|
|
2
|
+
pathSplit,
|
|
3
|
+
isSimpleType,
|
|
4
|
+
isFunction,
|
|
5
|
+
isString,
|
|
6
|
+
isNotNullObj,
|
|
7
|
+
SpecialOperators,
|
|
8
|
+
getSuffix,
|
|
9
|
+
fromSingleName,
|
|
10
|
+
toSingleName
|
|
11
|
+
} = require("./QyUtils.js"), getValByNamePath = require("./QyFileContentUtils.js").getValByNamePath, QyUnionNode = require("./QyUnionNode.js").QyUnionNode, QyIntersectNode = require("./QyIntersectNode.js").QyIntersectNode, isArray = Array.isArray, {
|
|
12
|
+
$or,
|
|
13
|
+
$and
|
|
14
|
+
} = SpecialOperators, Empty_Union_Node = new QyUnionNode();
|
|
15
|
+
|
|
16
|
+
function getIndexPropPaths(e) {
|
|
17
|
+
if (null != e && !isString(e)) return _getIndexPropPaths_rec(e, e = {}, [], 0),
|
|
18
|
+
Object.keys(e).map(e => fromSingleName(e));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function calDifferenceList(e, r, i, t, n, l) {
|
|
22
|
+
t = getValByNamePath(t, r), n = getValByNamePath(n, r);
|
|
23
|
+
if (t !== n) {
|
|
24
|
+
var o, a, s, u, l = isArray(n) || isArray(getValByNamePath(l, r)), f = Object.fromEntries(_itemToPropValList(t, l).map(e => [ JSON.stringify(e), e ])), d = Object.fromEntries(_itemToPropValList(n, l).map(e => [ JSON.stringify(e), e ])), c = [], y = [];
|
|
25
|
+
for (o in f) d[o] || (a = f[o], (a = e.searchSubdir(a)) && (a = a.getFile(i)) && y.push(a));
|
|
26
|
+
for (s in d) f[s] || (u = d[s], u = e.searchOrCreateSubdir(u), c.push(u.getOrCreateFile(i)));
|
|
27
|
+
return {
|
|
28
|
+
toAddFileList: c,
|
|
29
|
+
toDelFileList: y
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseNamePathAndQuery(e, r, i, t, n, l) {
|
|
35
|
+
if (isString(t) || isNotNullObj(t)) if (e.isDir) _queryIndexHostDir(e, i, t, n, l); else {
|
|
36
|
+
var o = e.$or;
|
|
37
|
+
if (o) {
|
|
38
|
+
for (var a of o) if (parseNamePathAndQuery(a, r, i, t, n, l), l?.isFull) return;
|
|
39
|
+
} else for (var s of _getMatchedDirs(e = isString(e) ? pathSplit(e) : e, r)) if (_queryIndexHostDir(s, i, t, n, l),
|
|
40
|
+
l?.isFull) return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function* _getMatchedDirs(e, r, i = 0) {
|
|
45
|
+
i == e.length ? yield r : yield* _getMatchedDirsWithPattern(e, e[i], r, i);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function* _getMatchedDirsWithPattern(e, r, i, t) {
|
|
49
|
+
if ("**" == r) {
|
|
50
|
+
i.isHiddenFolder || (yield i);
|
|
51
|
+
for (var n of i.allSubdirs()) yield n;
|
|
52
|
+
} else if ("*" == r) for (var l of i.subdirList) yield* _getMatchedDirs(e, l, t + 1); else if (isFunction(r)) for (var o of i.subdirList) r(o.name) && (yield* _getMatchedDirs(e, o, t + 1)); else if (isArray(r)) for (var a of r) yield* _getMatchedDirsWithPattern(e, a, i, t); else {
|
|
53
|
+
var s = r.$or;
|
|
54
|
+
if (s) for (var u of s) yield* _getMatchedDirsWithPattern(e, u, i, t); else {
|
|
55
|
+
s = i.getSubdir(r);
|
|
56
|
+
s && (yield* _getMatchedDirs(e, s, t + 1));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _queryIndexHostDir(r, i, t, n, l) {
|
|
62
|
+
var o = r.fileCount;
|
|
63
|
+
if (!(o <= 0)) {
|
|
64
|
+
let e = 0;
|
|
65
|
+
if (isString(t)) {
|
|
66
|
+
var a = r.getFile(t);
|
|
67
|
+
a && l.countOne() && (n.push(a), ++e);
|
|
68
|
+
} else {
|
|
69
|
+
var s, a = r.qyCache, i = (0 < i?.length && a.qyDB.createIndex(r, i),
|
|
70
|
+
a.getIndexDir(r));
|
|
71
|
+
if (!i) return;
|
|
72
|
+
for (s in _constructQueryNode(i, t).getFileMap(l)) n.push(r.getFile(s)),
|
|
73
|
+
++e;
|
|
74
|
+
}
|
|
75
|
+
logger.info(`Checking ${o} file${getSuffix(o)}, result: ${e} file` + getSuffix(e));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _isValidSimpleValue(e) {
|
|
80
|
+
var r = typeof e;
|
|
81
|
+
return "number" == r || "boolean" == r || "string" == r && !(e in SpecialOperators);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _filterSubdirs(e, r) {
|
|
85
|
+
var i, t = new QyUnionNode();
|
|
86
|
+
for (i of e.subdirList) r(i.name) && t.addDir(i);
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function _filterSubdirsHtoL(e, r) {
|
|
91
|
+
var i = e.sortedSubdirList, t = new QyUnionNode();
|
|
92
|
+
for (let e = i.length - 1; 0 <= e; --e) {
|
|
93
|
+
var n = i[e], l = n.nameNum;
|
|
94
|
+
if (!isNaN(l)) {
|
|
95
|
+
if (!r(l)) break;
|
|
96
|
+
t.addDir(n);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return t;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function _filterSubdirsLtoH(e, r) {
|
|
103
|
+
var i = e.sortedSubdirList, t = new QyUnionNode();
|
|
104
|
+
for (let e = 0; e < i.length; ++e) {
|
|
105
|
+
var n = i[e], l = n.nameNum;
|
|
106
|
+
if (!isNaN(l)) {
|
|
107
|
+
if (!r(l)) break;
|
|
108
|
+
t.addDir(n);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return t;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _isSimpleQueryObj(e) {
|
|
115
|
+
var r, i, t;
|
|
116
|
+
return !(null != e && !isSimpleType(e) && !isFunction(e)) || ({
|
|
117
|
+
$gt: e,
|
|
118
|
+
$lt: r,
|
|
119
|
+
$gte: i,
|
|
120
|
+
$lte: t
|
|
121
|
+
} = e, null != (e ?? r ?? i ?? t));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _getIndexPropPaths_rec(e, r, i, t) {
|
|
125
|
+
if (_isSimpleQueryObj(e)) 0 < i.length && (r[toSingleName(i)] = 1); else {
|
|
126
|
+
var n = e[$or] || e[$and];
|
|
127
|
+
if (null != n) if (isArray(n)) for (var l of n) _getIndexPropPaths_rec(l, r, i, t),
|
|
128
|
+
i.length = t; else _getIndexPropPaths_rec(n, r, i, t), i.length = t; else for (var o in e) i.push(o),
|
|
129
|
+
_getIndexPropPaths_rec(e[o], r, i, t + 1), i.length = t;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function _constructComparingNode(e, r, i, t, n) {
|
|
134
|
+
if (null != r && null != i && (i <= r ? i = void 0 : r = void 0), null != n && null != t && (n <= t ? t = void 0 : n = void 0),
|
|
135
|
+
null != r) if (null != n) {
|
|
136
|
+
if (r < n) return _filterSubdirs(e, e => r < e && e < n);
|
|
137
|
+
} else {
|
|
138
|
+
if (null == t) return _filterSubdirsHtoL(e, e => r < e);
|
|
139
|
+
if (r < t) return _filterSubdirs(e, e => r < e && e <= t);
|
|
140
|
+
} else if (null != i) if (null != n) {
|
|
141
|
+
if (i < n) return _filterSubdirs(e, e => i <= e && e < n);
|
|
142
|
+
} else {
|
|
143
|
+
if (null == t) return _filterSubdirsHtoL(e, e => i <= e);
|
|
144
|
+
if (i < t) return _filterSubdirs(e, e => i <= e && e <= t);
|
|
145
|
+
if (i == t) return new QyUnionNode(e.getSubdir(i));
|
|
146
|
+
} else {
|
|
147
|
+
if (null != n) return _filterSubdirsLtoH(e, e => e < n);
|
|
148
|
+
if (null != t) return _filterSubdirsLtoH(e, e => e <= t);
|
|
149
|
+
}
|
|
150
|
+
return Empty_Union_Node;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function _matchObj(r, i, t) {
|
|
154
|
+
if (null == i) return !1;
|
|
155
|
+
if (isSimpleType(t)) return isArray(i) ? i.includes(t) : isNotNullObj(i) ? i[t] : i == t;
|
|
156
|
+
if (isFunction(t)) return t(i);
|
|
157
|
+
if (isArray(t)) {
|
|
158
|
+
if (isArray(i)) {
|
|
159
|
+
for (let e = 0; e < t.length; ++e) if (!_matchObj(r, i[e], t[e])) return !1;
|
|
160
|
+
return !0;
|
|
161
|
+
}
|
|
162
|
+
return !1;
|
|
163
|
+
}
|
|
164
|
+
var e, {
|
|
165
|
+
$link: n,
|
|
166
|
+
$spec: l
|
|
167
|
+
} = t;
|
|
168
|
+
if (n) {
|
|
169
|
+
if (isSimpleType(i)) return _matchLink(r, n, i, l);
|
|
170
|
+
if (isArray(i)) {
|
|
171
|
+
for (var o of i) if (_matchLink(r, n, o, l)) return !0;
|
|
172
|
+
} else for (var a in i) if (_matchLink(r, n, a, l)) return !0;
|
|
173
|
+
return !1;
|
|
174
|
+
}
|
|
175
|
+
if (isSimpleType(i) || isArray(i)) return !1;
|
|
176
|
+
for (e in t) if (!_matchObj(r, i[e], t[e])) return !1;
|
|
177
|
+
return !0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function _matchLink(e, r, i, t) {
|
|
181
|
+
var r = e.getDir(r);
|
|
182
|
+
return !!r && !!(r = r.getFile(i)) && (null == t || _matchObj(e, r.fileContent, t));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _constructQueryNode(e, r) {
|
|
186
|
+
if (null == r) return Empty_Union_Node;
|
|
187
|
+
if (isSimpleType(r)) return new QyUnionNode(e.getSubdir(r));
|
|
188
|
+
if (isFunction(r)) return _filterSubdirs(e, r);
|
|
189
|
+
var {
|
|
190
|
+
$gt: i,
|
|
191
|
+
$lt: t,
|
|
192
|
+
$gte: n,
|
|
193
|
+
$lte: l
|
|
194
|
+
} = r;
|
|
195
|
+
if (null != (i ?? t ?? n ?? l)) return _constructComparingNode(e, i, n, l, t);
|
|
196
|
+
var {
|
|
197
|
+
$link: o,
|
|
198
|
+
$spec: a
|
|
199
|
+
} = r;
|
|
200
|
+
if (null != o) {
|
|
201
|
+
var s, u = new QyUnionNode(), {
|
|
202
|
+
qyCache: f,
|
|
203
|
+
subdirList: i
|
|
204
|
+
} = e;
|
|
205
|
+
for (s of i) _matchLink(f, o, s.name, a) && u.addDir(s);
|
|
206
|
+
return u;
|
|
207
|
+
}
|
|
208
|
+
var d = new QyIntersectNode();
|
|
209
|
+
if (isArray(r)) for (var c of r) d.addNode(_constructQueryNode(e, c)); else for (var y in r) {
|
|
210
|
+
var g = r[y];
|
|
211
|
+
if (y == $or) if (isArray(g)) {
|
|
212
|
+
var _, N = new QyUnionNode();
|
|
213
|
+
for (_ of g) N.addNode(_constructQueryNode(e, _));
|
|
214
|
+
d.addNode(N);
|
|
215
|
+
} else d.addNode(_constructQueryNode(e, g)); else if (y == $and) if (isArray(g)) for (var h of g) d.addNode(_constructQueryNode(e, h)); else d.addNode(_constructQueryNode(e, g)); else {
|
|
216
|
+
y = e.getSubdir(y);
|
|
217
|
+
if (null == y) return Empty_Union_Node;
|
|
218
|
+
d.addNode(_constructQueryNode(y, g));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return d;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function _itemToPropValList(e, r, i = [], t = [], n = 0) {
|
|
225
|
+
if (null != e) if (_isValidSimpleValue(e = isNotNullObj(e) && r ? Object.values(e) : e)) t[n] = e,
|
|
226
|
+
t.length = n + 1, i.push([ ...t ]); else if (isArray(e)) {
|
|
227
|
+
t.length = n + 1;
|
|
228
|
+
for (var l of e.filter(e => _isValidSimpleValue(e))) t[n] = l, i.push([ ...t ]);
|
|
229
|
+
} else if (isNotNullObj(e)) for (var o in e) t[n] = o, t.length = n + 1, _itemToPropValList(e[o], !1, i, t, n + 1);
|
|
230
|
+
return i;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
Object.assign(module.exports, {
|
|
234
|
+
calDifferenceList: calDifferenceList,
|
|
235
|
+
getIndexPropPaths: getIndexPropPaths,
|
|
236
|
+
parseNamePathAndQuery: parseNamePathAndQuery
|
|
237
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
let isArray = Array.isArray;
|
|
2
|
+
|
|
3
|
+
class QyIndexPropNode {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
Object.assign(this, {
|
|
6
|
+
name: e,
|
|
7
|
+
parent: t,
|
|
8
|
+
childCount: 0
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
insert(e, t) {
|
|
12
|
+
var r = this.children;
|
|
13
|
+
if (t == e.length) return !this.indexPropPath && (this.indexPropPath = e,
|
|
14
|
+
!0);
|
|
15
|
+
var n = e[t];
|
|
16
|
+
let h;
|
|
17
|
+
return r ? (h = r[n]) || (h = r[n] = new QyIndexPropNode(n, this), ++this.childCount) : (h = new QyIndexPropNode(n, this),
|
|
18
|
+
this.children = {
|
|
19
|
+
[n]: h
|
|
20
|
+
}, ++this.childCount), h.insert(e, t + 1);
|
|
21
|
+
}
|
|
22
|
+
remove(e, t = 0, r = {}) {
|
|
23
|
+
var {
|
|
24
|
+
parent: n,
|
|
25
|
+
name: h,
|
|
26
|
+
children: i
|
|
27
|
+
} = this;
|
|
28
|
+
if (t == e.length) return this.indexPropPath && (r.removed = !0, delete this.indexPropPath),
|
|
29
|
+
n && this._isEmpty() && n._removeChild(h), r;
|
|
30
|
+
this.indexPropPath && (r.hasPrefix = !0);
|
|
31
|
+
n = i && i[e[t]];
|
|
32
|
+
return n ? n.remove(e, t + 1, r) : r;
|
|
33
|
+
}
|
|
34
|
+
getAllIndexPropPaths(e) {
|
|
35
|
+
var {
|
|
36
|
+
children: t,
|
|
37
|
+
indexPropPath: r
|
|
38
|
+
} = this;
|
|
39
|
+
if (r) e.push(r); else for (var n in t) t[n].getAllIndexPropPaths(e);
|
|
40
|
+
}
|
|
41
|
+
_removeChild(e) {
|
|
42
|
+
var {
|
|
43
|
+
children: t,
|
|
44
|
+
parent: r,
|
|
45
|
+
name: n
|
|
46
|
+
} = this;
|
|
47
|
+
t[e] && (delete t[e], 0 == --this.childCount && delete this.children, r) && this._isEmpty() && r._removeChild(n);
|
|
48
|
+
}
|
|
49
|
+
_isEmpty() {
|
|
50
|
+
return !this.indexPropPath && 0 == this.childCount;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class QyIndexPropTree {
|
|
55
|
+
constructor() {
|
|
56
|
+
Object.assign(this, {
|
|
57
|
+
rootNode: new QyIndexPropNode(),
|
|
58
|
+
changeCount: 0,
|
|
59
|
+
allIndexPropPaths: []
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
insert(e) {
|
|
63
|
+
0 < (e = isArray(e) ? e : [ e ]).length && this.rootNode.insert(e, 0) && ++this.changeCount;
|
|
64
|
+
}
|
|
65
|
+
remove(e) {
|
|
66
|
+
isArray(e) || (e = [ e ]);
|
|
67
|
+
e = this.rootNode.remove(e);
|
|
68
|
+
return e.removed && ++this.changeCount, e;
|
|
69
|
+
}
|
|
70
|
+
getAllIndexPropPaths() {
|
|
71
|
+
var {
|
|
72
|
+
_cachedChangeCount: e,
|
|
73
|
+
allIndexPropPaths: t,
|
|
74
|
+
rootNode: r,
|
|
75
|
+
changeCount: n
|
|
76
|
+
} = this;
|
|
77
|
+
return e != n && (t.length = 0, r.getAllIndexPropPaths(t), this._cachedChangeCount = n),
|
|
78
|
+
t;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getPrefixPropPaths(e) {
|
|
83
|
+
if (0 == e.length) return [];
|
|
84
|
+
var t, r = new QyIndexPropTree();
|
|
85
|
+
for (t of e) r.insert(t);
|
|
86
|
+
return r.getAllIndexPropPaths();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Object.assign(module.exports, {
|
|
90
|
+
QyIndexPropTree: QyIndexPropTree,
|
|
91
|
+
getPrefixPropPaths: getPrefixPropPaths
|
|
92
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
let QyQueryNode = require("./QyUnionNode.js").QyQueryNode;
|
|
2
|
+
|
|
3
|
+
class QyIntersectNode extends QyQueryNode {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(), Object.assign(this, {
|
|
6
|
+
fileCount: void 0
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
containsFile(e) {
|
|
10
|
+
var {
|
|
11
|
+
nodeList: t,
|
|
12
|
+
fileCount: n
|
|
13
|
+
} = this;
|
|
14
|
+
if (0 != t.length && 0 != n) return this._ensureSorted(), t[0].containsFile(e) && this._inAllOthers(e);
|
|
15
|
+
}
|
|
16
|
+
getFileMap(e) {
|
|
17
|
+
var {
|
|
18
|
+
nodeList: t,
|
|
19
|
+
fileCount: n
|
|
20
|
+
} = this;
|
|
21
|
+
if (0 == t.length || 0 == n) return {};
|
|
22
|
+
this._ensureSorted();
|
|
23
|
+
var i, s = {};
|
|
24
|
+
for (i in t[0].getFileMap()) if (!s[i] && this._inAllOthers(i) && this.encounterOne(s, i, e)) return s;
|
|
25
|
+
return s;
|
|
26
|
+
}
|
|
27
|
+
addNode(e) {
|
|
28
|
+
var t, n;
|
|
29
|
+
e && null != e.fileCount && ({
|
|
30
|
+
fileCount: t,
|
|
31
|
+
nodeList: n
|
|
32
|
+
} = this, 0 < n.length && 0 == t || (e instanceof QyIntersectNode ? (n.push(...e.nodeList),
|
|
33
|
+
this.sorted = !1) : n.push(e), (null == t || t > e.fileCount) && (this.fileCount = e.fileCount)));
|
|
34
|
+
}
|
|
35
|
+
_ensureSorted() {
|
|
36
|
+
this.sorted || (this.nodeList.sort((e, t) => e.fileCount - t.fileCount),
|
|
37
|
+
this.sorted = !0);
|
|
38
|
+
}
|
|
39
|
+
_inAllOthers(t) {
|
|
40
|
+
var n = this.nodeList;
|
|
41
|
+
for (let e = 1; e < n.length; ++e) if (!n[e].containsFile(t)) return !1;
|
|
42
|
+
return !0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
Object.assign(module.exports, {
|
|
47
|
+
QyIntersectNode: QyIntersectNode
|
|
48
|
+
});
|
package/src/QyItem.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
let {
|
|
2
|
+
calHash,
|
|
3
|
+
SpecialFilePaths
|
|
4
|
+
} = require("./QyUtils.js"), HiddenFolderName = SpecialFilePaths.HiddenFolderName, Flag_Created = 1, Flag_UnderHiddenFolder = 2, Flag_SubdirMapLoaded = 4, Flag_FileMapLoaded = 8, Flag_FileContentLoaded = 16, Flag_Visited = 32;
|
|
5
|
+
|
|
6
|
+
class QyItem {
|
|
7
|
+
constructor(e, t, a) {
|
|
8
|
+
e = e.toString(), Object.assign(this, {
|
|
9
|
+
name: e,
|
|
10
|
+
parentDir: a,
|
|
11
|
+
flagInt: 0
|
|
12
|
+
}), this._created = t, a && (a.name == HiddenFolderName || a.underHiddenFolder) && (this.flagInt |= Flag_UnderHiddenFolder);
|
|
13
|
+
}
|
|
14
|
+
_getFlag(e) {
|
|
15
|
+
return 0 != (this.flagInt & e);
|
|
16
|
+
}
|
|
17
|
+
_setFlag(e, t) {
|
|
18
|
+
t ? this.flagInt |= e : this.flagInt &= ~e;
|
|
19
|
+
}
|
|
20
|
+
get qyCache() {
|
|
21
|
+
var e = this.parentDir;
|
|
22
|
+
return e ? e.qyCache : this._qyCache;
|
|
23
|
+
}
|
|
24
|
+
get _created() {
|
|
25
|
+
return this._getFlag(Flag_Created);
|
|
26
|
+
}
|
|
27
|
+
set _created(e) {
|
|
28
|
+
this._setFlag(Flag_Created, e);
|
|
29
|
+
}
|
|
30
|
+
get subdirMapLoaded() {
|
|
31
|
+
return this._getFlag(Flag_SubdirMapLoaded);
|
|
32
|
+
}
|
|
33
|
+
set subdirMapLoaded(e) {
|
|
34
|
+
return this._setFlag(Flag_SubdirMapLoaded, e);
|
|
35
|
+
}
|
|
36
|
+
get fileMapLoaded() {
|
|
37
|
+
return this._getFlag(Flag_FileMapLoaded);
|
|
38
|
+
}
|
|
39
|
+
set fileMapLoaded(e) {
|
|
40
|
+
this._setFlag(Flag_FileMapLoaded, e);
|
|
41
|
+
}
|
|
42
|
+
get fileContentLoaded() {
|
|
43
|
+
return this._getFlag(Flag_FileContentLoaded);
|
|
44
|
+
}
|
|
45
|
+
set fileContentLoaded(e) {
|
|
46
|
+
this._setFlag(Flag_FileContentLoaded, e);
|
|
47
|
+
}
|
|
48
|
+
get visited() {
|
|
49
|
+
return this._getFlag(Flag_Visited);
|
|
50
|
+
}
|
|
51
|
+
set visited(e) {
|
|
52
|
+
this._setFlag(Flag_Visited, e);
|
|
53
|
+
}
|
|
54
|
+
get nameNum() {
|
|
55
|
+
var e;
|
|
56
|
+
return this._nameNum || (e = +this.name, this._nameNum = isNaN(e) ? this.name : e);
|
|
57
|
+
}
|
|
58
|
+
cmp({
|
|
59
|
+
nameNum: e
|
|
60
|
+
}) {
|
|
61
|
+
var t = this.nameNum;
|
|
62
|
+
return t < e ? -1 : e < t ? 1 : 0;
|
|
63
|
+
}
|
|
64
|
+
get fullPath() {
|
|
65
|
+
var e, t;
|
|
66
|
+
return null == this._fullPath && ({
|
|
67
|
+
parentDir: e,
|
|
68
|
+
name: t
|
|
69
|
+
} = this, this._fullPath = e ? e.fullPath + "/" + t : t), this._fullPath;
|
|
70
|
+
}
|
|
71
|
+
get fullPathHash() {
|
|
72
|
+
var e, t;
|
|
73
|
+
return null == this._fullPathHash && ({
|
|
74
|
+
parentDir: e,
|
|
75
|
+
name: t
|
|
76
|
+
} = this, this._fullPathHash = calHash(e ? e.fullPathHash + t : t)), this._fullPathHash;
|
|
77
|
+
}
|
|
78
|
+
get isItem() {
|
|
79
|
+
return !0;
|
|
80
|
+
}
|
|
81
|
+
get underHiddenFolder() {
|
|
82
|
+
return this.flagInt & Flag_UnderHiddenFolder;
|
|
83
|
+
}
|
|
84
|
+
get parentList() {
|
|
85
|
+
if (null == this._parentList) {
|
|
86
|
+
var t = this._parentList = [];
|
|
87
|
+
let e = this.parentDir;
|
|
88
|
+
for (;e.parentDir; ) t.push(e), e = e.parentDir;
|
|
89
|
+
t.reverse();
|
|
90
|
+
}
|
|
91
|
+
return this._parentList;
|
|
92
|
+
}
|
|
93
|
+
get parentNamePath() {
|
|
94
|
+
return null == this._parentNameList && (this._parentNameList = this.parentList.map(e => e.name)),
|
|
95
|
+
this._parentNameList;
|
|
96
|
+
}
|
|
97
|
+
get namePath() {
|
|
98
|
+
return null == this._namePath && (this._namePath = [ ...this.parentNamePath, this.name ]),
|
|
99
|
+
this._namePath;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
Object.assign(module.exports, {
|
|
104
|
+
QyItem: QyItem
|
|
105
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let getDefaultOptions = require("./QyDefaultOptions.js").getDefaultOptions, QySaver = require("./QySaver.js").QySaver;
|
|
2
|
+
|
|
3
|
+
class QyJsonSaver extends QySaver {
|
|
4
|
+
constructor(e, r) {
|
|
5
|
+
super(e, {
|
|
6
|
+
...getDefaultOptions("QyJsonSaver"),
|
|
7
|
+
...r
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
processAfterLoad(e, r) {
|
|
11
|
+
return JSON.parse(super.processAfterLoad(e, r));
|
|
12
|
+
}
|
|
13
|
+
processBeforeSave(e, r) {
|
|
14
|
+
return super.processBeforeSave(JSON.stringify(e), r);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Object.assign(module.exports, {
|
|
19
|
+
QyJsonSaver: QyJsonSaver
|
|
20
|
+
});
|