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/QyDir.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
let QyItem = require("./QyItem.js").QyItem, {
|
|
2
|
+
getSubdirMapKey,
|
|
3
|
+
getFileMapKey,
|
|
4
|
+
SpecialFilePaths,
|
|
5
|
+
arrayLast
|
|
6
|
+
} = require("./QyUtils.js"), QyFile = require("./QyFile.js").QyFile, HiddenFolderName = SpecialFilePaths.HiddenFolderName;
|
|
7
|
+
|
|
8
|
+
class QyDir extends QyItem {
|
|
9
|
+
constructor(e, i, t, r) {
|
|
10
|
+
super(e, i, t), r && (this._qyCache = r), Object.assign(this, {
|
|
11
|
+
_subdirCount: 0,
|
|
12
|
+
_fileCount: 0,
|
|
13
|
+
subdirMapChangeCount: 0,
|
|
14
|
+
fileMapChangeCount: 0,
|
|
15
|
+
dChangeId: 0,
|
|
16
|
+
fChangeId: 0,
|
|
17
|
+
cache: {}
|
|
18
|
+
}), t && i && (++t._subdirCount, ++t.subdirMapChangeCount);
|
|
19
|
+
}
|
|
20
|
+
get created() {
|
|
21
|
+
return this._created;
|
|
22
|
+
}
|
|
23
|
+
set created(e) {
|
|
24
|
+
var i;
|
|
25
|
+
this._created != (e = !!e) && (this._created = e, i = this.parentDir, i) && (i._subdirCount += e ? 1 : -1,
|
|
26
|
+
++i.subdirMapChangeCount);
|
|
27
|
+
}
|
|
28
|
+
get fileCount() {
|
|
29
|
+
return this._ensureFileMapLoaded(), this._fileCount;
|
|
30
|
+
}
|
|
31
|
+
get subdirCount() {
|
|
32
|
+
return this._ensureSubdirMapLoaded(), this._subdirCount;
|
|
33
|
+
}
|
|
34
|
+
get isDir() {
|
|
35
|
+
return !0;
|
|
36
|
+
}
|
|
37
|
+
get isEmpty() {
|
|
38
|
+
return 0 == this.fileCount && 0 == this.subdirCount;
|
|
39
|
+
}
|
|
40
|
+
get isHiddenFolder() {
|
|
41
|
+
return this.name == HiddenFolderName;
|
|
42
|
+
}
|
|
43
|
+
get subdirMapKey() {
|
|
44
|
+
return this._subdirMapKey || (this._subdirMapKey = getSubdirMapKey(this.fullPathHash));
|
|
45
|
+
}
|
|
46
|
+
get fileMapKey() {
|
|
47
|
+
return this._fileMapKey || (this._fileMapKey = getFileMapKey(this.fullPathHash));
|
|
48
|
+
}
|
|
49
|
+
get subdirMap() {
|
|
50
|
+
return this._ensureSubdirMapLoaded(), this._subdirMap;
|
|
51
|
+
}
|
|
52
|
+
get fileMap() {
|
|
53
|
+
return this._ensureFileMapLoaded(), this._fileMap;
|
|
54
|
+
}
|
|
55
|
+
getSubdir(e) {
|
|
56
|
+
var i;
|
|
57
|
+
if (this.created) return "." === e ? this : ".." === e ? this.parentDir || this : "/" === e ? this.qyCache.rootDir : (i = this.subdirMap,
|
|
58
|
+
(i = i && i[e])?.created ? i : void 0);
|
|
59
|
+
}
|
|
60
|
+
getFile(e) {
|
|
61
|
+
var {
|
|
62
|
+
created: i,
|
|
63
|
+
fileMap: t
|
|
64
|
+
} = this, i = i && t && t[e];
|
|
65
|
+
return i?.created ? i : void 0;
|
|
66
|
+
}
|
|
67
|
+
getOrCreateSubdir(e, i) {
|
|
68
|
+
if ("." === e) return this;
|
|
69
|
+
if (".." === e) return this.parentDir || this;
|
|
70
|
+
if ("/" === e) return this.qyCache.rootDir;
|
|
71
|
+
let t = this.subdirMap;
|
|
72
|
+
var r = (t = t || (this._subdirMap = {}))[e];
|
|
73
|
+
return r || (r = t[e] = new QyDir(e, i, this), this.setChildTriggerNodes(r)),
|
|
74
|
+
r;
|
|
75
|
+
}
|
|
76
|
+
getOrCreateFile(e, i) {
|
|
77
|
+
let t = this.fileMap;
|
|
78
|
+
var r = (t = t || (this._fileMap = {}))[e];
|
|
79
|
+
return r || (r = t[e] = new QyFile(e, i, this), this.setChildTriggerNodes(r)),
|
|
80
|
+
r;
|
|
81
|
+
}
|
|
82
|
+
searchSubdir(i, t = i.length) {
|
|
83
|
+
let r = this;
|
|
84
|
+
for (let e = 0; e < t; ++e) {
|
|
85
|
+
var s = i[e];
|
|
86
|
+
if (null != s && "" !== s && !(r = r.getSubdir(s))) return;
|
|
87
|
+
}
|
|
88
|
+
return r;
|
|
89
|
+
}
|
|
90
|
+
searchOrCreateSubdir(i, t, r = i.length) {
|
|
91
|
+
let s = this;
|
|
92
|
+
for (let e = 0; e < r; ++e) {
|
|
93
|
+
var a = i[e];
|
|
94
|
+
null != a && "" !== a && (s = s.getOrCreateSubdir(a, t));
|
|
95
|
+
}
|
|
96
|
+
return s;
|
|
97
|
+
}
|
|
98
|
+
searchFile(e) {
|
|
99
|
+
var i = this.searchSubdir(e, e.length - 1);
|
|
100
|
+
if (i) return i.getFile(arrayLast(e));
|
|
101
|
+
}
|
|
102
|
+
searchOrCreateFile(e, i) {
|
|
103
|
+
return this.searchOrCreateSubdir(e, i, e.length - 1).getOrCreateFile(arrayLast(e));
|
|
104
|
+
}
|
|
105
|
+
get subdirList() {
|
|
106
|
+
return this._getCachedValue("_subdirList", this.subdirMapChangeCount, () => this.created && this.subdirMap ? Object.values(this.subdirMap).filter(e => e.created) : []);
|
|
107
|
+
}
|
|
108
|
+
get subdirNameList() {
|
|
109
|
+
return this._getCachedValue("_subdirNameList", this.subdirMapChangeCount, () => this.subdirList.map(e => e.name));
|
|
110
|
+
}
|
|
111
|
+
get sortedSubdirList() {
|
|
112
|
+
return this._getCachedValue("_sortedSubdirList", this.subdirMapChangeCount, () => this.subdirList.sort((e, i) => e.cmp(i)));
|
|
113
|
+
}
|
|
114
|
+
get sortedSubdirNameList() {
|
|
115
|
+
return this._getCachedValue("_sortedSubdirNameList", this.subdirMapChangeCount, () => this.sortedSubdirList.map(e => e.nameNum));
|
|
116
|
+
}
|
|
117
|
+
get fileList() {
|
|
118
|
+
return this._getCachedValue("_fileList", this.fileMapChangeCount, () => this.created && this.fileMap ? Object.values(this.fileMap).filter(e => e.created) : []);
|
|
119
|
+
}
|
|
120
|
+
get fileNameList() {
|
|
121
|
+
return this._getCachedValue("_fileNameList", this.fileMapChangeCount, () => this.fileList.map(e => e.name));
|
|
122
|
+
}
|
|
123
|
+
get sortedFileList() {
|
|
124
|
+
return this._getCachedValue("_sortedFileList", this.fileMapChangeCount, () => this.fileList.sort((e, i) => e.cmp(i)));
|
|
125
|
+
}
|
|
126
|
+
get sortedFileNameList() {
|
|
127
|
+
return this._getCachedValue("_sortedFileNameList", this.fileMapChangeCount, () => this.sortedFileList.map(e => e.nameNum));
|
|
128
|
+
}
|
|
129
|
+
*allSubdirs() {
|
|
130
|
+
var e, i, t = this.subdirList;
|
|
131
|
+
for (e of t) e.isHiddenFolder || (yield* e.allSubdirs());
|
|
132
|
+
for (i of t) i.isHiddenFolder || (yield i);
|
|
133
|
+
}
|
|
134
|
+
*allLeafSubdirs() {
|
|
135
|
+
for (var e of this.allSubdirs()) 0 == e.subdirCount && (yield e);
|
|
136
|
+
}
|
|
137
|
+
*allFiles() {
|
|
138
|
+
for (var e of this.allSubdirs()) for (var i of e.fileList) yield i;
|
|
139
|
+
for (var t of this.fileList) yield t;
|
|
140
|
+
}
|
|
141
|
+
*allLoadedSubdirs() {
|
|
142
|
+
if (this.subdirMapLoaded) for (var e of this.subdirList) e.isHiddenFolder || (yield* e.allLoadedSubdirs(),
|
|
143
|
+
yield e);
|
|
144
|
+
}
|
|
145
|
+
setChildTriggerNodes(e) {
|
|
146
|
+
var i = this.triggerNodes;
|
|
147
|
+
if (i) {
|
|
148
|
+
var t, r, s = e.triggerNodes || [], a = (s.length = 0, e).name;
|
|
149
|
+
for ({
|
|
150
|
+
children: {
|
|
151
|
+
"*": t,
|
|
152
|
+
[a]: r
|
|
153
|
+
}
|
|
154
|
+
} of i) t && s.push(t), r && s.push(r);
|
|
155
|
+
e.triggerNodes = 0 < s.length ? s : void 0;
|
|
156
|
+
} else e.triggerNodes = void 0;
|
|
157
|
+
}
|
|
158
|
+
_getCachedValue(e, i, t) {
|
|
159
|
+
var r = this.cache, s = e + "ChangeCount";
|
|
160
|
+
return r[e] && r[s] == i || (r[e] = t(), r[s] = i), r[e];
|
|
161
|
+
}
|
|
162
|
+
_ensureSubdirMapLoaded() {
|
|
163
|
+
if (this.created && !this._subdirMap && !this.subdirMapLoaded) {
|
|
164
|
+
this.subdirMapLoaded = !0;
|
|
165
|
+
var e = this.qyCache;
|
|
166
|
+
if (e) {
|
|
167
|
+
e = e.qyKVData.getValueSync(this.subdirMapKey);
|
|
168
|
+
if (e) {
|
|
169
|
+
var i, t = this._subdirMap = {};
|
|
170
|
+
for (i in e) t[i] = new QyDir(i, !0, this);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
_ensureFileMapLoaded() {
|
|
176
|
+
if (this.created && !this._fileMap && !this.fileMapLoaded) {
|
|
177
|
+
this.fileMapLoaded = !0;
|
|
178
|
+
var e = this.qyCache;
|
|
179
|
+
if (e) {
|
|
180
|
+
e = e.qyKVData.getValueSync(this.fileMapKey);
|
|
181
|
+
if (e) {
|
|
182
|
+
var i, t = this._fileMap = {};
|
|
183
|
+
for (i in e) t[i] = new QyFile(i, !0, this);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
Object.assign(module.exports, {
|
|
191
|
+
QyDir: QyDir
|
|
192
|
+
});
|
package/src/QyFetch.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
let QyCD = require("./QyCD.js").QyCD;
|
|
2
|
+
|
|
3
|
+
class QyFetch extends QyCD {
|
|
4
|
+
constructor(s) {
|
|
5
|
+
super(s), Object.assign(this, {
|
|
6
|
+
stack: []
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
dir(s, e) {
|
|
10
|
+
return this._push(super.dir(s, e));
|
|
11
|
+
}
|
|
12
|
+
indexDir(s, e, r) {
|
|
13
|
+
return this._push(super.indexDir(s, e, r));
|
|
14
|
+
}
|
|
15
|
+
file(s, e) {
|
|
16
|
+
return this._push(super.file(s, e));
|
|
17
|
+
}
|
|
18
|
+
view(s, e, r) {
|
|
19
|
+
return this._push(super.view(s, e, r));
|
|
20
|
+
}
|
|
21
|
+
queryFiles(s, e, r, t, u) {
|
|
22
|
+
return this._push(super.queryFiles(s, e, r, t, u));
|
|
23
|
+
}
|
|
24
|
+
queryFilesMulti(s, e, r, t) {
|
|
25
|
+
return this._push(super.queryFilesMulti(s, e, r, t));
|
|
26
|
+
}
|
|
27
|
+
run() {
|
|
28
|
+
var s = this.stack;
|
|
29
|
+
return this.stack = [], this.resetCurrentDir(), s;
|
|
30
|
+
}
|
|
31
|
+
_push(s) {
|
|
32
|
+
return this.stack.push(s), this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Object.assign(module.exports, {
|
|
37
|
+
QyFetch: QyFetch
|
|
38
|
+
});
|
package/src/QyFile.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
let QyItem = require("./QyItem.js").QyItem, {
|
|
2
|
+
SpecialOperators,
|
|
3
|
+
SpecialFilePaths,
|
|
4
|
+
getContentKey,
|
|
5
|
+
isNotNullObj,
|
|
6
|
+
isSimpleType,
|
|
7
|
+
fromSingleName
|
|
8
|
+
} = require("./QyUtils.js"), getValByNamePath = require("./QyFileContentUtils.js").getValByNamePath, QyIndexPropTree = require("./QyIndexPropTree.js").QyIndexPropTree, isArray = Array.isArray, IndexPropPathsFileName = SpecialFilePaths.IndexPropPathsFileName, {
|
|
9
|
+
$spec,
|
|
10
|
+
$raw,
|
|
11
|
+
$clone
|
|
12
|
+
} = SpecialOperators;
|
|
13
|
+
|
|
14
|
+
class QyFile extends QyItem {
|
|
15
|
+
constructor(e, t, i) {
|
|
16
|
+
super(e, t, i), t && (++i._fileCount, ++i.fileMapChangeCount), this.cChangeId = 0;
|
|
17
|
+
}
|
|
18
|
+
get created() {
|
|
19
|
+
return this._created;
|
|
20
|
+
}
|
|
21
|
+
set created(e) {
|
|
22
|
+
var t;
|
|
23
|
+
this._created != (e = !!e) && (this._created = e, t = this.parentDir, t._fileCount += e ? 1 : -1,
|
|
24
|
+
++t.fileMapChangeCount);
|
|
25
|
+
}
|
|
26
|
+
get fileContentKey() {
|
|
27
|
+
return this._fileContentKey || (this._fileContentKey = getContentKey(this.fullPathHash));
|
|
28
|
+
}
|
|
29
|
+
get fileContent() {
|
|
30
|
+
return this._ensureFileContentLoaded(), this.visited = !0, this._fileContent;
|
|
31
|
+
}
|
|
32
|
+
set fileContent(e) {
|
|
33
|
+
this.visited = !0, this._fileContent = e;
|
|
34
|
+
}
|
|
35
|
+
get qyIndexPropTree() {
|
|
36
|
+
var {
|
|
37
|
+
created: e,
|
|
38
|
+
_qyIndexPropTree: t,
|
|
39
|
+
name: i,
|
|
40
|
+
fileContent: n,
|
|
41
|
+
underHiddenFolder: r
|
|
42
|
+
} = this;
|
|
43
|
+
if (e && r && i == IndexPropPathsFileName) {
|
|
44
|
+
if (t) return t;
|
|
45
|
+
var l, s = this._qyIndexPropTree = new QyIndexPropTree();
|
|
46
|
+
for (l in n) s.insert(fromSingleName(l));
|
|
47
|
+
return s;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get isFile() {
|
|
51
|
+
return !0;
|
|
52
|
+
}
|
|
53
|
+
get contentAsText() {
|
|
54
|
+
var e = this.fileContent;
|
|
55
|
+
return null == e ? "" : isNotNullObj(e) ? JSON.stringify(e) : e.toString();
|
|
56
|
+
}
|
|
57
|
+
get clonedContent() {
|
|
58
|
+
return structuredClone(this.fileContent);
|
|
59
|
+
}
|
|
60
|
+
setContent(e) {
|
|
61
|
+
this.fileContent = e;
|
|
62
|
+
}
|
|
63
|
+
view(e = $clone, t) {
|
|
64
|
+
var i = this.fileContent;
|
|
65
|
+
return null == i || isSimpleType(i) ? i : this._viewBySpec(i, e, t);
|
|
66
|
+
}
|
|
67
|
+
getProp(e, t = $clone, i) {
|
|
68
|
+
var n;
|
|
69
|
+
if (t) return e = getValByNamePath(this.fileContent, isArray(e) ? e : [ e ]),
|
|
70
|
+
n = t.$link, null != n ? this._link(e, n, t[$spec], i) : i || t === $raw ? e : structuredClone(e);
|
|
71
|
+
}
|
|
72
|
+
unloadFileContent() {
|
|
73
|
+
this.created && this.fileContentLoaded && null != this._fileContent && (this._fileContent = void 0,
|
|
74
|
+
this.fileContentLoaded = !1);
|
|
75
|
+
}
|
|
76
|
+
_ensureFileContentLoaded() {
|
|
77
|
+
var e;
|
|
78
|
+
this.created && null == this._fileContent && !this.fileContentLoaded && (this.fileContentLoaded = !0,
|
|
79
|
+
e = this.qyCache, e) && (this._fileContent = e.qyKVData.getValueSync(this.fileContentKey));
|
|
80
|
+
}
|
|
81
|
+
_link(e, t, i, n) {
|
|
82
|
+
let r = this.qyCache.getDir(t);
|
|
83
|
+
if (isArray(e)) return e.map(e => this._getLinkedFileContent(r, e, i, n));
|
|
84
|
+
if (isNotNullObj(e)) {
|
|
85
|
+
var l, s = {};
|
|
86
|
+
for (l in e) s[l] = this._getLinkedFileContent(r, l, i, n);
|
|
87
|
+
return s;
|
|
88
|
+
}
|
|
89
|
+
return this._getLinkedFileContent(r, e, i, n);
|
|
90
|
+
}
|
|
91
|
+
_getLinkedFileContent(e, t, i, n) {
|
|
92
|
+
if (e) {
|
|
93
|
+
e = e.getFile(t);
|
|
94
|
+
if (e) return e.view(i, n);
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
}
|
|
98
|
+
_viewBySpec(e, t, i) {
|
|
99
|
+
if (t === $raw) return e;
|
|
100
|
+
if (null != t) {
|
|
101
|
+
if (isSimpleType(t)) return t ? i ? e : structuredClone(e) : void 0;
|
|
102
|
+
var n = t.$link;
|
|
103
|
+
if (null != n) return this._link(e, n, t[$spec]);
|
|
104
|
+
if (isSimpleType(e)) return e;
|
|
105
|
+
isArray(t) && (t = Object.fromEntries(t.filter(e => e).map(e => [ e, 1 ])));
|
|
106
|
+
var r = isArray(e) ? [] : {}, {
|
|
107
|
+
$all: l,
|
|
108
|
+
"**": s
|
|
109
|
+
} = t;
|
|
110
|
+
if (l || s) for (var o in e) {
|
|
111
|
+
var a = t[o] ?? l ?? s;
|
|
112
|
+
a && (r[o] = this._viewBySpec(e[o], a, i));
|
|
113
|
+
} else for (var h in t) {
|
|
114
|
+
var u = t[h];
|
|
115
|
+
u && (r[h] = this._viewBySpec(e[h], u, i));
|
|
116
|
+
}
|
|
117
|
+
return r;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Object.assign(module.exports, {
|
|
123
|
+
QyFile: QyFile
|
|
124
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
let {
|
|
2
|
+
isNotNullObj,
|
|
3
|
+
arrayLast,
|
|
4
|
+
trimArrayTail,
|
|
5
|
+
isSimpleType,
|
|
6
|
+
SpecialOperators
|
|
7
|
+
} = require("./QyUtils.js"), isArray = Array.isArray, {
|
|
8
|
+
$del,
|
|
9
|
+
$rpl,
|
|
10
|
+
$ext
|
|
11
|
+
} = SpecialOperators;
|
|
12
|
+
|
|
13
|
+
function mergeContent(e, n) {
|
|
14
|
+
if (null == n) return e;
|
|
15
|
+
if (n !== $del) {
|
|
16
|
+
if (isSimpleType(n)) return n;
|
|
17
|
+
var r = n[$rpl];
|
|
18
|
+
if (null != r) return r;
|
|
19
|
+
if (null == e || isSimpleType(e)) return n;
|
|
20
|
+
if (e != n) {
|
|
21
|
+
var l, t = isArray(e);
|
|
22
|
+
for (l in n) {
|
|
23
|
+
var a = mergeContent(e[l], n[l]);
|
|
24
|
+
null == a ? (delete e[l], t && trimArrayTail(e)) : e[l] = a;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function mergeContentChanges(e, n) {
|
|
32
|
+
if (n == $del) return $del;
|
|
33
|
+
if (null != n[$rpl]) return n;
|
|
34
|
+
var r = e[$rpl];
|
|
35
|
+
if (null != r) e[$rpl] = mergeContent(r, n); else {
|
|
36
|
+
if (e == $del) return {
|
|
37
|
+
[$rpl]: cleanContent(n)
|
|
38
|
+
};
|
|
39
|
+
if (isSimpleType(e) || isSimpleType(n)) return n;
|
|
40
|
+
for (var l in n) {
|
|
41
|
+
var t = n[l], a = e[l];
|
|
42
|
+
e[l] = null == a ? t : mergeContentChanges(a, t);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return e;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function mergeContentAndGenDelta(e, n) {
|
|
49
|
+
let r = {
|
|
50
|
+
oldValue: {},
|
|
51
|
+
newValue: {}
|
|
52
|
+
};
|
|
53
|
+
e = _mergeContentAndGenDelta_rec(e, n, [], 0, r);
|
|
54
|
+
return r.oldValue = cleanContent(r.oldValue, !0, !0), r.newValue = cleanContent(r.newValue, !1, !1),
|
|
55
|
+
{
|
|
56
|
+
merged: e,
|
|
57
|
+
delta: r = r.oldValue || r.newValue ? r : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _mergeArrayOrObj(e, n, r, l, t) {
|
|
62
|
+
if (e != n) {
|
|
63
|
+
var a, i = isArray(e);
|
|
64
|
+
for (a in n) {
|
|
65
|
+
r[l] = a, r.length = l + 1;
|
|
66
|
+
var u = _mergeContentAndGenDelta_rec(e[a], n[a], r, l + 1, t);
|
|
67
|
+
null == u ? (delete e[a], i && trimArrayTail(e)) : e[a] = u;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return e;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function _mergeContentAndGenDelta_rec(n, r, l, t, a) {
|
|
74
|
+
if (null == r) return n;
|
|
75
|
+
if (r !== $del) {
|
|
76
|
+
if (null == n || isSimpleType(n) || isSimpleType(r)) return _genRpl(n, r, l, a);
|
|
77
|
+
var i = r[$rpl];
|
|
78
|
+
if (null != i) return _genRpl(n, i, l, a);
|
|
79
|
+
let e = r[$ext];
|
|
80
|
+
return null != e ? (isArray(e) || (e = [ e ]), (isArray(n) ? _genExt : _genRpl)(n, e, l, a)) : isArray(n) && !isArray(r) || !isArray(n) && isArray(r) ? _genRpl(n, r, l, a) : _mergeArrayOrObj(n, r, l, t, a);
|
|
81
|
+
}
|
|
82
|
+
null != n && setDeltaValues(a, l, n, $del);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function _genExt(n, r, e, l) {
|
|
86
|
+
r = cleanContent(r);
|
|
87
|
+
var t = {};
|
|
88
|
+
for (let e = 0; e < r.length; ++e) {
|
|
89
|
+
var a = r[e];
|
|
90
|
+
null != a && (t[e + n.length] = isSimpleType(a) ? a : {
|
|
91
|
+
[$rpl]: a
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return setDeltaValues(l, e, n, t), n.concat(r);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function _genRpl(e, n, r, l) {
|
|
98
|
+
n = cleanContent(n);
|
|
99
|
+
return e === n ? e : null != n ? (null == e ? setDeltaValues(l, r, 0 == r.length ? void 0 : null, isSimpleType(n) ? n : {
|
|
100
|
+
[$rpl]: n
|
|
101
|
+
}) : setDeltaValues(l, r, e, isSimpleType(e) ? n : {
|
|
102
|
+
[$rpl]: n
|
|
103
|
+
}), n) : void setDeltaValues(l, r, e, $del);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function setDeltaValues(e, n, r, l) {
|
|
107
|
+
e.oldValue = setValByNamePath(e.oldValue, n, r), e.newValue = setValByNamePath(e.newValue, n, l);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function setValByNamePath(e, n, r) {
|
|
111
|
+
if (!n || 0 == n.length) return r;
|
|
112
|
+
let l = e;
|
|
113
|
+
for (let e = 0; e < n.length - 1; ++e) {
|
|
114
|
+
var t = n[e];
|
|
115
|
+
isNotNullObj(l[t]) || (l[t] = {}), l = l[t];
|
|
116
|
+
}
|
|
117
|
+
return l[arrayLast(n)] = r, e;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getValByNamePath(e, n) {
|
|
121
|
+
if (null != n && null != (e = _getValFromObj(e))) {
|
|
122
|
+
if (!isArray(n)) return "" == n ? e : _getValFromObj(e[n]);
|
|
123
|
+
if (0 != n.length && (1 != n.length || "" != n[0])) for (var r of n) if (null == (e = _getValFromObj(e[r]))) return;
|
|
124
|
+
return e;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function _getValFromObj(e) {
|
|
129
|
+
if (null != e && e != $del) {
|
|
130
|
+
for (;null != e[$rpl]; ) if ((e = e[$rpl]) == $del) return;
|
|
131
|
+
return e;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function cleanContent(e, n = !0, r = !1) {
|
|
136
|
+
return _cleanContent_rec(e, n, r);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _cleanContent_rec(e, n, r) {
|
|
140
|
+
if (e instanceof Date) return e.toISOString();
|
|
141
|
+
if (!isNotNullObj(e)) return (r ? void 0 === e : null == e) || n && e === $del ? void 0 : e;
|
|
142
|
+
if (n) {
|
|
143
|
+
var l = e[$rpl];
|
|
144
|
+
if (null != l) return _cleanContent_rec(l, n, r);
|
|
145
|
+
l = e[$ext];
|
|
146
|
+
if (null != l) return _cleanContent_rec(isArray(l) ? l : [ l ], n, r);
|
|
147
|
+
}
|
|
148
|
+
var t, a = isArray(e);
|
|
149
|
+
let i = !0;
|
|
150
|
+
for (t in e) {
|
|
151
|
+
var u = _cleanContent_rec(e[t], n, r);
|
|
152
|
+
(r ? void 0 === u : null == u) ? (delete e[t], a && trimArrayTail(e)) : (e[t] = u,
|
|
153
|
+
i = !1);
|
|
154
|
+
}
|
|
155
|
+
return i ? void 0 : e;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function objToDelMarks(e) {
|
|
159
|
+
if (isSimpleType(e)) return e ? $del : void 0;
|
|
160
|
+
for (var n in e) {
|
|
161
|
+
var r = objToDelMarks(e[n]);
|
|
162
|
+
r ? e[n] = r : delete e[n];
|
|
163
|
+
}
|
|
164
|
+
return isArray(e) && trimArrayTail(e), e;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
Object.assign(module.exports, {
|
|
168
|
+
mergeContent: mergeContent,
|
|
169
|
+
mergeContentAndGenDelta: mergeContentAndGenDelta,
|
|
170
|
+
mergeContentChanges: mergeContentChanges,
|
|
171
|
+
setValByNamePath: setValByNamePath,
|
|
172
|
+
getValByNamePath: getValByNamePath,
|
|
173
|
+
cleanContent: cleanContent,
|
|
174
|
+
objToDelMarks: objToDelMarks
|
|
175
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
let path = require("node:path"), {
|
|
2
|
+
setFileConsoleDateDirPath,
|
|
3
|
+
closeFileConsole
|
|
4
|
+
} = require("./QyLogger.js"), ensureDir = require("./QyUtils.js").ensureDir, getDefaultOptions = require("./QyDefaultOptions.js").getDefaultOptions, QyOpRunner = require("./QyOpRunner.js").QyOpRunner, QyLogFileSaver = require("./QyLogFileSaver.js").QyLogFileSaver;
|
|
5
|
+
|
|
6
|
+
class QyFileLogger extends QyOpRunner {
|
|
7
|
+
constructor(e, t) {
|
|
8
|
+
(t = {
|
|
9
|
+
...getDefaultOptions("QyFileLogger"),
|
|
10
|
+
...t
|
|
11
|
+
}).append = !t.clearLogAtStart, super(t, [ "stop" ], [ "startFileConsole", "switchFileConsole" ]),
|
|
12
|
+
Object.assign(this, {
|
|
13
|
+
logFileFolder: e,
|
|
14
|
+
qyLogFileSaver: new QyLogFileSaver(this, t)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
save(e, t) {
|
|
18
|
+
return this.qyLogFileSaver.save(e, t);
|
|
19
|
+
}
|
|
20
|
+
getDateDirPath() {
|
|
21
|
+
return this.dateDirPath;
|
|
22
|
+
}
|
|
23
|
+
async start() {
|
|
24
|
+
var e = new Date(), e = (this.timeoutRef = setTimeout(() => this.switch(), this._getRemainingMilliSeconds(e)),
|
|
25
|
+
this.dateDirPath = this._genDateDirPath(e));
|
|
26
|
+
this.qyLogFileSaver.start(path.join(e, "change.txt")), await this.startFileConsole(e);
|
|
27
|
+
}
|
|
28
|
+
switch() {
|
|
29
|
+
var e = new Date(), e = (this.timeoutRef = setTimeout(() => this.switch(), this._getRemainingMilliSeconds(e)),
|
|
30
|
+
this._genDateDirPath(e));
|
|
31
|
+
return this.dateDirPath != e && (this.dateDirPath = e, this.qyLogFileSaver.switch(path.join(e, "change.txt")),
|
|
32
|
+
this.switchFileConsole(e)), this;
|
|
33
|
+
}
|
|
34
|
+
async _op_startFileConsole(e) {
|
|
35
|
+
await ensureDir(e), setFileConsoleDateDirPath(e, this.options.clearLogAtStart);
|
|
36
|
+
}
|
|
37
|
+
async _op_stop() {
|
|
38
|
+
clearTimeout(this.timeoutRef), this.timeoutRef = void 0, closeFileConsole(),
|
|
39
|
+
await this.qyLogFileSaver.stop();
|
|
40
|
+
}
|
|
41
|
+
async _op_switchFileConsole(e) {
|
|
42
|
+
await ensureDir(e), setFileConsoleDateDirPath(e, this.options.clearLogAtStart);
|
|
43
|
+
}
|
|
44
|
+
_genDateDirPath(e) {
|
|
45
|
+
var t = e.getUTCFullYear(), i = e.getUTCMonth() + 1, s = e.getUTCDate(), e = e.getUTCHours();
|
|
46
|
+
return path.join(this.logFileFolder, t.toString(), this._patch(i), this._patch(s), this._patch(e));
|
|
47
|
+
}
|
|
48
|
+
_patch(e) {
|
|
49
|
+
return e.toString().padStart(2, "0");
|
|
50
|
+
}
|
|
51
|
+
_getRemainingMilliSeconds(e) {
|
|
52
|
+
return 1e3 * (60 * (60 - e.getUTCMinutes()) - e.getUTCSeconds());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Object.assign(module.exports, {
|
|
57
|
+
QyFileLogger: QyFileLogger
|
|
58
|
+
});
|