datafolder 1.0.32 → 1.0.33

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/src/QyFile.js CHANGED
@@ -8,9 +8,8 @@ import {
8
8
  getContentKey as r,
9
9
  isNotNullObj as l,
10
10
  isSimpleType as h,
11
- fromSingleName as s,
12
11
  isEmptyObj as n,
13
- getNowTime as a,
12
+ getNowTime as s,
14
13
  isArray as u
15
14
  } from "./QyUtils.js";
16
15
 
@@ -19,19 +18,19 @@ import {
19
18
  } from "./QyFileContentUtils.js";
20
19
 
21
20
  import {
22
- QyIndexPropTree as f
21
+ QyIndexPropTree as a
23
22
  } from "./QyIndexPropTree.js";
24
23
 
25
24
  import {
26
- handleExpiredProps as d
25
+ handleExpiredProps as f
27
26
  } from "./QyExpire.js";
28
27
 
29
- let p = i.IndexPropPathsFileName, {
30
- $raw: C,
31
- $clone: c
28
+ let d = i.IndexPropPathsFileName, {
29
+ $raw: p,
30
+ $clone: C
32
31
  } = t;
33
32
 
34
- class v extends e {
33
+ class c extends e {
35
34
  _fileContentKey;
36
35
  _fileContent;
37
36
  cChangeId = 0;
@@ -63,10 +62,10 @@ class v extends e {
63
62
  underHiddenFolder: r,
64
63
  parentDir: n
65
64
  } = this;
66
- if (e && r && t === p) {
65
+ if (e && r && t === d) {
67
66
  let e = this._qyIndexPropTree;
68
- if (void 0 === e) for (var o in e = this._qyIndexPropTree = new f(n),
69
- i) e.insert(s(o));
67
+ if (void 0 === e) for (var o in e = this._qyIndexPropTree = new a(n),
68
+ i) e.insertPropPath(JSON.parse(o));
70
69
  return e;
71
70
  }
72
71
  }
@@ -80,10 +79,10 @@ class v extends e {
80
79
  get clonedContent() {
81
80
  return structuredClone(this.fileContent);
82
81
  }
83
- view(e = c, t) {
82
+ view(e = C, t) {
84
83
  var i = this.fileContent;
85
84
  return void 0 === i || h(i) ? i : function t(i, r, n, o) {
86
- if (n === C) return r;
85
+ if (n === p) return r;
87
86
  if (void 0 === n) return;
88
87
  if (h(n)) return n ? o ? r : structuredClone(r) : void 0;
89
88
  let e = n.$link;
@@ -105,9 +104,9 @@ class v extends e {
105
104
  return s;
106
105
  }(this, i, e, t);
107
106
  }
108
- prop(e, t = c, i) {
107
+ prop(e, t = C, i) {
109
108
  var r;
110
- if (t) return e = o(this.fileContent, u(e) ? e : [ e ]), r = t.$link, void 0 !== r ? y(this, e, r, t.$spec, i) : i || t === C ? e : structuredClone(e);
109
+ if (t) return e = o(this.fileContent, u(e) ? e : [ e ]), r = t.$link, void 0 !== r ? y(this, e, r, t.$spec, i) : i || t === p ? e : structuredClone(e);
111
110
  }
112
111
  unloadFileContent() {
113
112
  this.created && this.fileContentLoaded && void 0 !== this._fileContent && (this._fileContent = void 0,
@@ -124,7 +123,7 @@ class v extends e {
124
123
  !r.cExpireChecked && (r.cExpireChecked = !0, t = e.getExpireInfoFile(r.fullPathHash, "c")) && ({
125
124
  expiredProps: t,
126
125
  remainingExpireInfoObj: i
127
- } = ((e, t = a()) => {
126
+ } = ((e, t = s()) => {
128
127
  let i, r = {};
129
128
  for (var n in e) {
130
129
  var o = e[n];
@@ -134,14 +133,14 @@ class v extends e {
134
133
  expiredProps: i,
135
134
  remainingExpireInfoObj: r
136
135
  };
137
- })(t.fileContent), t && d(e.qyDB, r, t), n(i) || e.monitorContentExpire(r, i));
136
+ })(t.fileContent), t && f(e.qyDB, r, t), n(i) || e.monitorContentExpire(r, i));
138
137
  }
139
138
  }
140
139
  return this;
141
140
  }
142
141
  }
143
142
 
144
- function m(e, t, i, r) {
143
+ function v(e, t, i, r) {
145
144
  if (e) {
146
145
  e = e.getFile(t);
147
146
  if (e) return e.view(i, r);
@@ -151,15 +150,15 @@ function m(e, t, i, r) {
151
150
 
152
151
  function y(e, t, i, r, n = !1) {
153
152
  let o = e.qyCache.getDir(i);
154
- if (u(t)) return t.map(e => m(o, e, r, n));
153
+ if (u(t)) return t.map(e => v(o, e, r, n));
155
154
  if (l(t)) {
156
155
  var s, a = {};
157
- for (s in t) a[s] = m(o, s, r, n);
156
+ for (s in t) a[s] = v(o, s, r, n);
158
157
  return a;
159
158
  }
160
- return m(o, t, r, n);
159
+ return v(o, t, r, n);
161
160
  }
162
161
 
163
162
  export {
164
- v as QyFile
163
+ c as QyFile
165
164
  };
@@ -4,9 +4,9 @@ declare class QyIndexPropNode {
4
4
  children: any;
5
5
  childCount: number;
6
6
  constructor(name?: any, parent?: any);
7
- insert(indexPropPath: any, _index_dir?: any): any;
7
+ insertPropPath(indexPropPath: any, _index_dir?: any): any;
8
8
  insertFromQueryNode(queryObj: any, nodeList: any, _index_dir?: any, dir?: any): void;
9
- remove(indexPropPath: any): any[];
9
+ removePropPath(indexPropPath: any): any[];
10
10
  getAllLeafNodes(nodeList: any): void;
11
11
  }
12
12
  export declare function isCmpObj(queryObj: any): boolean;
@@ -18,10 +18,10 @@ export declare class QyIndexPropTree {
18
18
  _index_dir: any;
19
19
  nodeList: any[];
20
20
  constructor(_index_dir?: any);
21
- insert(indexPropPath: any): any;
21
+ insertPropPath(indexPropPath: any): any;
22
22
  insertPropPathList(indexPropPathList: any): any[];
23
23
  insertFromQueryObj(queryObj: any): any[];
24
- remove(indexPropPath: any): any[];
24
+ removePropPath(indexPropPath: any): any[];
25
25
  get allLeafNodes(): never[];
26
26
  }
27
27
  export {};
@@ -1,5 +1,5 @@
1
1
  import {
2
- isArray as h,
2
+ isArray as s,
3
3
  isFunction as v,
4
4
  isSimpleType as l
5
5
  } from "./QyUtils.js";
@@ -9,69 +9,69 @@ class o {
9
9
  parent;
10
10
  children;
11
11
  childCount = 0;
12
- constructor(e = void 0, i = void 0) {
13
- this.name = e, this.parent = i;
12
+ constructor(e = void 0, r = void 0) {
13
+ this.name = e, this.parent = r;
14
14
  }
15
- insert(e, i = void 0) {
16
- let r = this;
17
- for (var t of e) r = u(r, t);
18
- if (void 0 === r.indexPropPath) return r.indexPropPath = e, void 0 !== i && (r.indexPropDir = i.searchOrCreateSubdir(e)),
19
- r;
15
+ insertPropPath(e, r = void 0) {
16
+ let i = this;
17
+ for (var t of e) i = u(i, t);
18
+ if (void 0 === i.indexPropPath) return i.indexPropPath = e, void 0 !== r && (i.indexPropDir = r.searchOrCreateSubdir(e)),
19
+ i;
20
20
  }
21
- insertFromQueryNode(e, i, r = void 0, t = void 0) {
22
- if (void 0 === (o = e) || l(o) || v(o) || c(o)) void 0 === this.indexPropPath && void 0 !== t && (this.indexPropPath = t.getRelativeNamePath(r),
23
- this.indexPropDir = t, i.push(this)); else {
21
+ insertFromQueryNode(e, r, i = void 0, t = void 0) {
22
+ if (void 0 === (o = e) || l(o) || v(o) || P(o)) void 0 === this.indexPropPath && void 0 !== t && (this.indexPropPath = t.getRelativeNamePath(i),
23
+ this.indexPropDir = t, r.push(this)); else {
24
24
  var o = e.$or || e.$and;
25
- if (void 0 !== o) if (h(o)) for (var n of o) this.insertFromQueryNode(n, i, r, t); else this.insertFromQueryNode(o, i, r, t); else for (var d in e) {
26
- var s = u(this, d), a = (t ?? r).getOrCreateSubdir(d);
27
- s.insertFromQueryNode(e[d], i, r, a);
25
+ if (void 0 !== o) if (s(o)) for (var n of o) this.insertFromQueryNode(n, r, i, t); else this.insertFromQueryNode(o, r, i, t); else for (var d in e) {
26
+ var a = u(this, d), h = (t ?? i).getOrCreateSubdir(d);
27
+ a.insertFromQueryNode(e[d], r, i, h);
28
28
  }
29
29
  }
30
30
  }
31
- remove(e) {
32
- let t = this, i = !1, o = !1;
33
- for (var r of e) {
34
- void 0 !== t.indexPropPath && (i = !0);
31
+ removePropPath(e) {
32
+ let t = this, r = !1, o = !1;
33
+ for (var i of e) {
34
+ void 0 !== t.indexPropPath && (r = !0);
35
35
  var n = t.children;
36
- if (void 0 === (t = void 0 !== n && n[r])) break;
36
+ if (void 0 === (t = void 0 !== n && n[i])) break;
37
37
  }
38
38
  if (void 0 !== t) {
39
39
  let {
40
40
  parent: e,
41
- name: i,
42
- indexPropPath: r
41
+ name: r,
42
+ indexPropPath: i
43
43
  } = t;
44
- void 0 !== r && (o = !0, t.indexPropPath = void 0), e && d(t) && !function e(i, r) {
44
+ void 0 !== i && (o = !0, t.indexPropPath = void 0), e && d(t) && !function e(r, i) {
45
45
  let {
46
46
  children: t,
47
47
  parent: o,
48
48
  name: n
49
- } = i;
50
- t[r] && (delete t[r], 0 == --i.childCount && (i.children = void 0),
51
- o) && d(i) && e(o, n);
52
- }(e, i);
49
+ } = r;
50
+ t[i] && (delete t[i], 0 == --r.childCount && (r.children = void 0),
51
+ o) && d(r) && e(o, n);
52
+ }(e, r);
53
53
  }
54
- return [ o, i, t ];
54
+ return [ o, r, t ];
55
55
  }
56
56
  getAllLeafNodes(e) {
57
57
  var {
58
- children: i,
59
- indexPropPath: r
58
+ children: r,
59
+ indexPropPath: i
60
60
  } = this;
61
- if (void 0 !== r) e.push(this); else if (void 0 !== i) for (var t in i) i[t].getAllLeafNodes(e);
61
+ if (void 0 !== i) e.push(this); else if (void 0 !== r) for (var t in r) r[t].getAllLeafNodes(e);
62
62
  }
63
63
  }
64
64
 
65
- function u(e, i) {
66
- let r = e.children, t = (r = void 0 === r ? e.children = {} : r)[i];
67
- return void 0 === t && (t = r[i] = new o(i, e), ++e.childCount), t;
65
+ function u(e, r) {
66
+ let i = e.children, t = (i = void 0 === i ? e.children = {} : i)[r];
67
+ return void 0 === t && (t = i[r] = new o(r, e), ++e.childCount), t;
68
68
  }
69
69
 
70
70
  function d(e) {
71
71
  return void 0 === e.indexPropPath && 0 === e.childCount;
72
72
  }
73
73
 
74
- function c(e) {
74
+ function P(e) {
75
75
  return void 0 !== e && void 0 !== (e.$gt ?? e.$lt ?? e.$gte ?? e.$lte);
76
76
  }
77
77
 
@@ -85,50 +85,50 @@ class e {
85
85
  constructor(e = void 0) {
86
86
  this._index_dir = e;
87
87
  }
88
- insert(e) {
89
- if (0 < (e = h(e) ? e : [ e ]).length) {
88
+ insertPropPath(e) {
89
+ if (0 < (e = s(e) ? e : [ e ]).length) {
90
90
  var {
91
- rootNode: i,
92
- _index_dir: r
93
- } = this, i = i.insert(e, r);
94
- if (void 0 !== i) return ++this.changeCount, i;
91
+ rootNode: r,
92
+ _index_dir: i
93
+ } = this, r = r.insertPropPath(e, i);
94
+ if (void 0 !== r) return ++this.changeCount, r;
95
95
  }
96
96
  }
97
97
  insertPropPathList(e) {
98
- var i, r = this.nodeList;
99
- r.length = 0;
100
- for (i of e) {
101
- var t = this.insert(i);
102
- void 0 !== t && r.push(t);
98
+ var r, i = this.nodeList;
99
+ i.length = 0;
100
+ for (r of e) {
101
+ var t = this.insertPropPath(r);
102
+ void 0 !== t && i.push(t);
103
103
  }
104
- return r;
104
+ return i;
105
105
  }
106
106
  insertFromQueryObj(e) {
107
107
  var {
108
- nodeList: i,
109
- rootNode: r,
108
+ nodeList: r,
109
+ rootNode: i,
110
110
  _index_dir: t
111
111
  } = this;
112
- return i.length = 0, r.insertFromQueryNode(e, i, t), i;
112
+ return r.length = 0, i.insertFromQueryNode(e, r, t), r;
113
113
  }
114
- remove(e) {
115
- h(e) || (e = [ e ]);
116
- e = this.rootNode.remove(e);
114
+ removePropPath(e) {
115
+ s(e) || (e = [ e ]);
116
+ e = this.rootNode.removePropPath(e);
117
117
  return e[0] && ++this.changeCount, e;
118
118
  }
119
119
  get allLeafNodes() {
120
120
  var {
121
121
  _cachedChangeCount: e,
122
- _allLeafNodes: i,
123
- rootNode: r,
122
+ _allLeafNodes: r,
123
+ rootNode: i,
124
124
  changeCount: t
125
125
  } = this;
126
- return e !== t && (i.length = 0, r.getAllLeafNodes(i), this._cachedChangeCount = t),
127
- i;
126
+ return e !== t && (r.length = 0, i.getAllLeafNodes(r), this._cachedChangeCount = t),
127
+ r;
128
128
  }
129
129
  }
130
130
 
131
131
  export {
132
- c as isCmpObj,
132
+ P as isCmpObj,
133
133
  e as QyIndexPropTree
134
134
  };
package/src/QyLogger.d.ts CHANGED
@@ -4,6 +4,9 @@ declare class QyLogger {
4
4
  fileConsole: any;
5
5
  stdout: any;
6
6
  stderr: any;
7
+ outBuf: any[];
8
+ errBuf: any[];
9
+ mainBuf: any[];
7
10
  constructor();
8
11
  get level(): string;
9
12
  set level(val: string);
package/src/QyLogger.js CHANGED
@@ -1,14 +1,14 @@
1
- import o from "node:fs";
1
+ import u from "node:fs";
2
2
 
3
- import r from "node:path";
3
+ import f from "node:path";
4
4
 
5
5
  import {
6
- Console as i
6
+ Console as c
7
7
  } from "node:console";
8
8
 
9
9
  import {
10
- parentPort as n,
11
- isMainThread as l,
10
+ parentPort as r,
11
+ isMainThread as p,
12
12
  threadId as e
13
13
  } from "node:worker_threads";
14
14
 
@@ -16,23 +16,26 @@ import {
16
16
  Writable as t
17
17
  } from "node:stream";
18
18
 
19
- let a = l ? "" : `W${e}:`, d = {
19
+ let i = p ? "" : `W${e}:`, n = {
20
20
  info: 1,
21
21
  debug: 2,
22
22
  log: 3,
23
23
  warn: 4,
24
24
  error: 5,
25
25
  none: 6
26
- }, s = Object.fromEntries(Object.entries(d).map(([ e, t ]) => [ t, e ]));
26
+ }, o = Object.fromEntries(Object.entries(n).map(([ e, t ]) => [ t, e ]));
27
27
 
28
- class h {
29
- _level = d.debug;
28
+ class s {
29
+ _level = n.debug;
30
30
  fileConsole;
31
31
  stdout;
32
32
  stderr;
33
+ outBuf = [];
34
+ errBuf = [];
35
+ mainBuf = [];
33
36
  constructor() {
34
37
  var e, t;
35
- l || (e = this.stdout = p("%o_"), t = this.stderr = p("%e_"), this.fileConsole = new i({
38
+ p || (e = this.stdout = a("%o_"), t = this.stderr = a("%e_"), this.fileConsole = new c({
36
39
  stdout: e,
37
40
  stderr: t,
38
41
  inspectOptions: {
@@ -42,90 +45,115 @@ class h {
42
45
  }));
43
46
  }
44
47
  get level() {
45
- return s[this._level];
48
+ return o[this._level];
46
49
  }
47
50
  set level(e) {
48
- this._level = d[e];
51
+ this._level = n[e];
49
52
  }
50
53
  info(...e) {
51
- c(this, "info", e);
54
+ l(this, "info", e);
52
55
  }
53
56
  log(...e) {
54
- c(this, "log", e);
57
+ l(this, "log", e);
55
58
  }
56
59
  debug(...e) {
57
- c(this, "debug", e);
60
+ l(this, "debug", e);
58
61
  }
59
62
  warn(...e) {
60
- c(this, "warn", e);
63
+ l(this, "warn", e);
61
64
  }
62
65
  error(...e) {
63
- c(this, "error", e);
66
+ l(this, "error", e);
64
67
  }
65
68
  handleOutMsg(e) {
66
- l ? u(this.stdout, e) : n?.postMessage(e);
69
+ var t, o;
70
+ p ? ({
71
+ stdout: t,
72
+ outBuf: o
73
+ } = this, void 0 !== t ? g(t, e) : o.push(e)) : r?.postMessage(e);
67
74
  }
68
75
  handleErrMsg(e) {
69
- l ? u(this.stderr, e) : n?.postMessage(e);
76
+ var t, o;
77
+ p ? ({
78
+ stderr: t,
79
+ errBuf: o
80
+ } = this, void 0 !== t ? g(t, e) : o.push(e)) : r?.postMessage(e);
70
81
  }
71
82
  closeFileConsole() {
72
- l && (this.fileConsole = void 0, this.stdout && (this.stdout.close(), this.stdout = void 0),
83
+ p && (this.fileConsole = void 0, this.stdout && (this.stdout.close(), this.stdout = void 0),
73
84
  this.stderr) && (this.stderr.close(), this.stderr = void 0);
74
85
  }
75
86
  setFileConsoleDateDirPath(e, t = !1) {
76
- var s;
77
- l && (this.closeFileConsole(), t = {
78
- flags: t ? "w" : "a",
79
- flush: !0,
80
- autoClose: !1
81
- }, s = this.stdout = o.createWriteStream(r.join(e, "stdout.txt"), t), e = this.stderr = o.createWriteStream(r.join(e, "stderr.txt"), t),
82
- this.fileConsole = new i({
83
- stdout: s,
84
- stderr: e,
85
- inspectOptions: {
86
- depth: 3,
87
- colors: !1
87
+ if (p) {
88
+ this.closeFileConsole();
89
+ var t = {
90
+ flags: t ? "w" : "a",
91
+ flush: !0,
92
+ autoClose: !1
93
+ }, o = this.stdout = u.createWriteStream(f.join(e, "stdout.txt"), t), e = this.stderr = u.createWriteStream(f.join(e, "stderr.txt"), t), t = this.fileConsole = new c({
94
+ stdout: o,
95
+ stderr: e,
96
+ inspectOptions: {
97
+ depth: 3,
98
+ colors: !1
99
+ }
100
+ }), s = o, r = e, i = t, {
101
+ outBuf: o,
102
+ errBuf: e,
103
+ mainBuf: t
104
+ } = o = this;
105
+ if (0 < o.length) {
106
+ for (var n of o) g(s, n);
107
+ o.length = 0;
88
108
  }
89
- }));
109
+ if (0 < e.length) {
110
+ for (var l of e) g(r, l);
111
+ e.length = 0;
112
+ }
113
+ if (0 < t.length) {
114
+ for (var [ a, h, d ] of t) i[a](h, ...d);
115
+ t.length = 0;
116
+ }
117
+ }
90
118
  }
91
119
  }
92
120
 
93
- function u(e, t) {
94
- var s, o;
121
+ function g(e, t) {
122
+ var o, s;
95
123
  e && ({
96
124
  chunks: t,
97
- chunk: s,
98
- encoding: o
99
- } = t, t ? e.writev(t) : e.write(s, o));
125
+ chunk: o,
126
+ encoding: s
127
+ } = t, t ? e.writev(t) : e.write(o, s));
100
128
  }
101
129
 
102
- function c(e, t, s) {
103
- var o;
104
- e._level <= d[t] && (o = ((o = (o = new Error().stack?.split("\n")) && /([^/\\()]+)\)?$/.exec(o[3] ?? "")) && o[1]) ?? "",
105
- o = `${new Date().toISOString()} ${a}${o}:${t}:`, console[t](o, ...s), e.fileConsole) && e.fileConsole[t](o, ...s);
130
+ function l(e, t, o) {
131
+ var s;
132
+ e._level <= n[t] && (s = ((s = (s = new Error().stack?.split("\n")) && /([^/\\()]+)\)?$/.exec(s[3] ?? "")) && s[1]) ?? "",
133
+ s = `${new Date().toISOString()} ${i}${s}:${t}:`, console[t](s, ...o), e.fileConsole ? e.fileConsole[t](s, ...o) : e.mainBuf.push([ t, s, o ]));
106
134
  }
107
135
 
108
- function p(o) {
136
+ function a(s) {
109
137
  return new t({
110
- write(e, t, s) {
111
- return n?.postMessage({
112
- opName: o,
138
+ write(e, t, o) {
139
+ return r?.postMessage({
140
+ opName: s,
113
141
  chunk: e,
114
142
  encoding: t
115
- }), s && s(), !0;
143
+ }), o && o(), !0;
116
144
  },
117
145
  writev(e, t) {
118
- return n?.postMessage({
119
- opName: o,
146
+ return r?.postMessage({
147
+ opName: s,
120
148
  chunks: e
121
149
  }), t && t(), !0;
122
150
  }
123
151
  });
124
152
  }
125
153
 
126
- var f = new h();
154
+ var h = new s();
127
155
 
128
156
  export {
129
- a as ThreadMark,
130
- f as logger
157
+ i as ThreadMark,
158
+ h as logger
131
159
  };
package/src/QyMessager.js CHANGED
@@ -71,7 +71,7 @@ class r {
71
71
  ack: o,
72
72
  result: s
73
73
  } = e;
74
- r ? "%o_" === r ? n.handleOutMsg(e) : "%e_" === r ? n.handleErrMsg(e) : (e = e.args || [],
74
+ void 0 !== r ? "%o_" === r ? n.handleOutMsg(e) : "%e_" === r ? n.handleErrMsg(e) : (e = e.args || [],
75
75
  t[r](...e)) : a[o]?.shift().resolve(s);
76
76
  }), i.on("exit", e => {
77
77
  for (var r in i.removeAllListeners(), 0 !== e ? n.warn(`Worker ${s} stopped with exitCode ` + e) : n.info(`Worker ${s} stopped.`),
package/src/QyUtils.d.ts CHANGED
@@ -44,8 +44,6 @@ export declare function folderOrFileExists(folderPath: any): Promise<boolean>;
44
44
  export declare function sleep(seconds: number, signal?: undefined): Promise<boolean> | Promise<void>;
45
45
  export declare function lockExclusiveFilePath(exclusiveFilePath: any): Promise<void>;
46
46
  export declare function unlockExclusiveFilePath(exclusiveFilePath: any): void;
47
- export declare function fromSingleName(name: any): any;
48
- export declare function toSingleName(list: any): any;
49
47
  export declare function pathSplit(itemPath: any): any;
50
48
  export declare function ensurePropNamePathList(propNamePathList: any): any[] | undefined;
51
49
  export declare function propNameJoin(propName: any): any;