datafolder 1.0.18 → 1.0.19

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/QyUtils.js CHANGED
@@ -6,7 +6,9 @@ import e from "node:process";
6
6
 
7
7
  import l from "node:fs/promises";
8
8
 
9
- import i from "node:fs";
9
+ import i, {
10
+ readSync as u
11
+ } from "node:fs";
10
12
 
11
13
  import o from "node:timers/promises";
12
14
 
@@ -17,122 +19,124 @@ import {
17
19
  import a from "node:util";
18
20
 
19
21
  import {
20
- logger as u
22
+ logger as f
21
23
  } from "../src/QyLogger.js";
22
24
 
23
- let f = Array.isArray, {
25
+ let c = Array.isArray, {
24
26
  isDate: s,
25
- isFloat32Array: c
27
+ isFloat32Array: d,
28
+ isUint8Array: m
26
29
  } = a.types;
27
30
 
28
- var m = t.dirname(r(import.meta.url)), d = Object.fromEntries([ "$del", "$link", "$rpl", "$spec", "$raw", "$all", "$clone", "$ext", "$or", "$and", "$gt", "$lt", "$gte", "$lte", "$f32" ].map(r => [ r, r ])), p = "%", p = {
29
- HiddenFolderName: p,
30
- TriggerDirPath: [ p, "trigger" ],
31
- RpcDirPath: [ p, "rpc" ],
32
- IndexDirPath: [ p, "index" ],
33
- ExpireDirPath: [ p, "expire" ],
34
- EmbeddingDirPath: [ p, "embedding" ],
35
- H2FDirPath: [ p, "h2F" ],
36
- MetaFilePath: [ p, "meta" ],
31
+ var p = t.dirname(r(import.meta.url)), h = Object.fromEntries([ "$del", "$link", "$rpl", "$spec", "$raw", "$all", "$clone", "$ext", "$pop", "$or", "$and", "$gt", "$lt", "$gte", "$lte", "$u8" ].map(r => [ r, r ])), y = "%", y = {
32
+ HiddenFolderName: y,
33
+ TriggerDirPath: [ y, "trigger" ],
34
+ RpcDirPath: [ y, "rpc" ],
35
+ IndexDirPath: [ y, "index" ],
36
+ ExpireDirPath: [ y, "expire" ],
37
+ HNSWDirPath: [ y, "hnsw" ],
38
+ InfoDirPath: [ y, "info" ],
39
+ RecycleDirPath: [ y, "recycle" ],
40
+ MetaFilePath: [ y, "meta" ],
37
41
  IndexPropPathsFileName: "propPaths"
38
42
  };
39
43
 
40
- function h(r) {
44
+ function g(r) {
41
45
  return r.startsWith("{") && r.endsWith("}");
42
46
  }
43
47
 
44
- function g(r) {
45
- return h(r) && r.substring(1, r.length - 1);
48
+ function v(r) {
49
+ return g(r) && r.substring(1, r.length - 1);
46
50
  }
47
51
 
48
- function y(r) {
52
+ function b(r) {
49
53
  return 1e12 < r ? Math.round(100 * r / 1e12) / 100 + "TB" : 1e9 < r ? Math.round(100 * r / 1e9) / 100 + "GB" : 1e6 < r ? Math.round(100 * r / 1e6) / 100 + "MB" : 1e3 < r ? Math.round(100 * r / 1e3) / 100 + "KB" : r.toString();
50
54
  }
51
55
 
52
- function b(r, t = 10) {
56
+ function $(r, t = 10) {
53
57
  return n.createHash("sha256").update(r, "utf8").digest("base64url").slice(0, t);
54
58
  }
55
59
 
56
- var v = 11;
60
+ var w = 11;
57
61
 
58
- function $(r) {
62
+ function P(r) {
59
63
  return "d" + r;
60
64
  }
61
65
 
62
- function w(r) {
66
+ function S(r) {
63
67
  return "f" + r;
64
68
  }
65
69
 
66
- function P(r) {
70
+ function x(r) {
67
71
  return "c" + r;
68
72
  }
69
73
 
70
- function x(r = 8) {
74
+ function D(r = 8) {
71
75
  return n.randomBytes(r).toString("hex");
72
76
  }
73
77
 
74
- function S(r) {
78
+ function j(r) {
75
79
  if (null != r) for (var t in r) if (null != r[t]) return !1;
76
80
  return !0;
77
81
  }
78
82
 
79
- function j(r) {
83
+ function B(r) {
80
84
  return null != r && "object" == typeof r && !s(r);
81
85
  }
82
86
 
83
- function D(r) {
87
+ function M(r) {
84
88
  return "string" == typeof r;
85
89
  }
86
90
 
87
- function F(r) {
91
+ function T(r) {
88
92
  return "number" == typeof r;
89
93
  }
90
94
 
91
- function M(r) {
95
+ function N(r) {
92
96
  return "boolean" == typeof r;
93
97
  }
94
98
 
95
- function B(r) {
99
+ function W(r) {
96
100
  return "function" == typeof r;
97
101
  }
98
102
 
99
- function N(r) {
103
+ function E(r) {
100
104
  var t = typeof r;
101
- return "string" == t || "number" == t || "boolean" == t || c(r) || s(r);
105
+ return "string" == t || "number" == t || "boolean" == t || m(r) || s(r);
102
106
  }
103
107
 
104
- function U(r) {
108
+ function R(r) {
105
109
  let t = r.length;
106
110
  for (;null == r[t - 1] && 0 < t; ) --t;
107
111
  return r.length = t, r;
108
112
  }
109
113
 
110
- function W(n) {
114
+ function H(n) {
111
115
  return n.promise || (n.promise = new Promise((r, t) => Object.assign(n, {
112
116
  resolve: r,
113
117
  reject: t
114
118
  }))), n;
115
119
  }
116
120
 
117
- function H(r) {
121
+ function L(r) {
118
122
  return Buffer.isBuffer(r) ? r : Buffer.from(r);
119
123
  }
120
124
 
121
- function L(r) {
125
+ function G(r) {
122
126
  return 1 < r ? "s" : "";
123
127
  }
124
128
 
125
- function T(r) {
129
+ function F(r) {
126
130
  return l.mkdir(r, {
127
131
  recursive: !0
128
132
  });
129
133
  }
130
134
 
131
- function O(r) {
132
- return T(t.dirname(r));
135
+ function I(r) {
136
+ return F(t.dirname(r));
133
137
  }
134
138
 
135
- async function k(r) {
139
+ async function O(r) {
136
140
  try {
137
141
  return (await l.stat(r)).size;
138
142
  } catch (r) {
@@ -140,111 +144,111 @@ async function k(r) {
140
144
  }
141
145
  }
142
146
 
143
- async function R(r) {
144
- return !1 !== await k(r);
147
+ async function J(r) {
148
+ return !1 !== await O(r);
145
149
  }
146
150
 
147
- function G(r, t = void 0) {
151
+ function Q(r, t = void 0) {
148
152
  r *= 1e3;
149
153
  return t ? o.setTimeout(r, !0, {
150
154
  signal: t
151
155
  }) : o.setTimeout(r);
152
156
  }
153
157
 
154
- let I;
158
+ let U;
155
159
 
156
- async function J(t) {
160
+ async function z(t) {
157
161
  try {
158
- await O(t);
162
+ await I(t);
159
163
  var r = new Date().toISOString() + ": " + e.argv.join(" ");
160
164
  function n() {
161
- for (var r of Object.keys(I)) A(r);
165
+ for (var r of Object.keys(U)) k(r);
162
166
  }
163
167
  await l.writeFile(t, r, {
164
168
  flag: "wx",
165
169
  flush: !0
166
- }), u.info("Locked " + t), I ? I[t] = 1 : (I = {
170
+ }), f.info("Locked " + t), U ? U[t] = 1 : (U = {
167
171
  [t]: 1
168
172
  }, e.on("exit", n), e.on("SIGINT", n));
169
173
  } catch (r) {
170
- throw "EEXIST" == r.code && u.error(`Already started by ${(await l.readFile(t)).toString()}:`, r),
174
+ throw "EEXIST" == r.code && f.error(`Already started by ${(await l.readFile(t)).toString()}:`, r),
171
175
  r;
172
176
  }
173
177
  }
174
178
 
175
- function A(r) {
179
+ function k(r) {
176
180
  try {
177
- i.unlinkSync(r), u.info("Unlocked " + r);
181
+ i.unlinkSync(r), f.info("Unlocked " + r);
178
182
  } catch (r) {}
179
183
  }
180
184
 
181
- function Q(r) {
185
+ function K(r) {
182
186
  return r.startsWith("[") && r.endsWith("]") ? JSON.parse(r) : r;
183
187
  }
184
188
 
185
- function z(r) {
186
- return f(r) ? 1 == r.length ? r[0] : JSON.stringify(r) : r;
189
+ function X(r) {
190
+ return c(r) ? 1 == r.length ? r[0] : JSON.stringify(r) : r;
187
191
  }
188
192
 
189
- function K(r) {
193
+ function q(r) {
190
194
  r = r.split("/");
191
195
  return r[0] || (r[0] = "/"), r;
192
196
  }
193
197
 
194
- function E(r) {
198
+ function A(r) {
195
199
  return r.split(".");
196
200
  }
197
201
 
198
- function X(r) {
199
- return D(r) ? [ E(r) ] : f(r) ? r.map(r => D(r) ? E(r) : r) : void 0;
202
+ function C(r) {
203
+ return M(r) ? [ A(r) ] : c(r) ? r.map(r => M(r) ? A(r) : r) : void 0;
200
204
  }
201
205
 
202
- function q(r) {
206
+ function V(r) {
203
207
  return r.join(".");
204
208
  }
205
209
 
206
- function C(r, t = 0) {
210
+ function Y(r, t = 0) {
207
211
  return Math.floor(Math.random() * (r - t)) + t;
208
212
  }
209
213
 
210
- function V(r) {
214
+ function Z(r) {
211
215
  var t, n = {};
212
216
  for (t of r) n[t] = 1;
213
217
  return n;
214
218
  }
215
219
 
216
- async function Y(t, n, e, i) {
220
+ async function _(t, n, e, i) {
217
221
  var o = Buffer.allocUnsafe(i);
218
222
  for (let r = 0; r < i; ) {
219
223
  var a = (await n.read(o, r, i - r, e + r)).bytesRead;
220
- if (0 == a) return void u.error(`read ${t} at ${e + r} returning 0 byte`);
224
+ if (0 == a) return void f.error(`read ${t} at ${e + r} returning 0 byte`);
221
225
  r += a;
222
226
  }
223
227
  return o;
224
228
  }
225
229
 
226
- function Z() {
230
+ function rr() {
227
231
  var r = e.availableMemory();
228
232
  return Math.round(r / (e.memoryUsage.rss() + r) * 100);
229
233
  }
230
234
 
231
- async function* _(e, t = 3) {
235
+ async function* tr(e, t = 3) {
232
236
  var n = e.length, i = (n < t && (t = n), new Array(n));
233
237
  for (let r = 0; r < t; ++r) {
234
238
  var o = i[r] = {};
235
- c(r, o);
239
+ s(r, o);
236
240
  }
237
241
  for (let r = 0; r < n; ++r) {
238
242
  var a = i[r % t], {
239
243
  filePath: u,
240
244
  bin: f
241
- } = (a.bin || await a.promise, a), s = r + t;
242
- s < n && c(s, a), yield {
245
+ } = (a.bin || await a.promise, a), c = r + t;
246
+ c < n && s(c, a), yield {
243
247
  filePath: u,
244
248
  bin: f
245
249
  };
246
250
  }
247
- async function c(r, t) {
251
+ async function s(r, t) {
248
252
  var r = e[r], n = l.readFile(r);
249
253
  Object.assign(t, {
250
254
  filePath: r,
@@ -254,61 +258,73 @@ async function* _(e, t = 3) {
254
258
  }
255
259
  }
256
260
 
257
- function rr(r = new Date()) {
261
+ function nr(r = new Date()) {
258
262
  return r.getTime();
259
263
  }
260
264
 
261
- function tr(r = new Date()) {
265
+ function er(r = new Date()) {
262
266
  r = r.getTime();
263
267
  return r - r % 1e3;
264
268
  }
265
269
 
270
+ function ir(t, n, e, i) {
271
+ var o = Buffer.allocUnsafe(i);
272
+ for (let r = 0; r < i; ) {
273
+ var a = u(t, o, r, i - r, e + r);
274
+ if (0 == a) return void f.error(`readSync ${n} at ${e + r} returning 0 byte`);
275
+ r += a;
276
+ }
277
+ return o;
278
+ }
279
+
266
280
  export * as default from "./QyUtils.js";
267
281
 
268
282
  export {
269
- f as isArray,
283
+ c as isArray,
270
284
  s as isDate,
271
- c as isFloat32Array,
272
- m as __dirname,
273
- d as SpecialOperators,
274
- p as SpecialFilePaths,
275
- h as isMatchName,
276
- g as getMatchParam,
277
- y as getSizeStr,
278
- b as calHash,
279
- v as Hash_Key_Length,
280
- $ as getSubdirMapKey,
281
- w as getFileMapKey,
282
- P as getContentKey,
283
- x as getRandomStr,
284
- S as isEmptyObj,
285
- j as isNotNullObj,
286
- D as isString,
287
- F as isNumber,
288
- M as isBoolean,
289
- B as isFunction,
290
- N as isSimpleType,
291
- U as trimArrayTail,
292
- W as setPromise,
293
- H as toBuffer,
294
- L as getSuffix,
295
- T as ensureDir,
296
- O as ensureParentDir,
297
- k as getSize,
298
- R as folderOrFileExists,
299
- G as sleep,
300
- J as lockExclusiveFilePath,
301
- A as unlockExclusiveFilePath,
302
- Q as fromSingleName,
303
- z as toSingleName,
304
- K as pathSplit,
305
- X as ensurePropNamePathList,
306
- q as propNameJoin,
307
- C as randomInt,
308
- V as listToMap,
309
- Y as readBufferAsync,
310
- Z as memoryPercent,
311
- _ as loadFileList,
312
- rr as getNowTime,
313
- tr as getNowRounded
285
+ d as isFloat32Array,
286
+ m as isUint8Array,
287
+ p as __dirname,
288
+ h as SpecialOperators,
289
+ y as SpecialFilePaths,
290
+ g as isMatchName,
291
+ v as getMatchParam,
292
+ b as getSizeStr,
293
+ $ as calHash,
294
+ w as Hash_Key_Length,
295
+ P as getSubdirMapKey,
296
+ S as getFileMapKey,
297
+ x as getContentKey,
298
+ D as getRandomStr,
299
+ j as isEmptyObj,
300
+ B as isNotNullObj,
301
+ M as isString,
302
+ T as isNumber,
303
+ N as isBoolean,
304
+ W as isFunction,
305
+ E as isSimpleType,
306
+ R as trimArrayTail,
307
+ H as setPromise,
308
+ L as toBuffer,
309
+ G as getSuffix,
310
+ F as ensureDir,
311
+ I as ensureParentDir,
312
+ O as getSize,
313
+ J as folderOrFileExists,
314
+ Q as sleep,
315
+ z as lockExclusiveFilePath,
316
+ k as unlockExclusiveFilePath,
317
+ K as fromSingleName,
318
+ X as toSingleName,
319
+ q as pathSplit,
320
+ C as ensurePropNamePathList,
321
+ V as propNameJoin,
322
+ Y as randomInt,
323
+ Z as listToMap,
324
+ _ as readBufferAsync,
325
+ rr as memoryPercent,
326
+ tr as loadFileList,
327
+ nr as getNowTime,
328
+ er as getNowRounded,
329
+ ir as readBufferFromFD
314
330
  };
@@ -6916,6 +6916,7 @@
6916
6916
  if (composition && next.fromA <= composition.range.fromA && next.toA >= composition.range.toA) {
6917
6917
  this.forward(next.fromA, composition.range.fromA, composition.range.fromA < composition.range.toA ? 1 : -1);
6918
6918
  this.emit(posB, composition.range.fromB);
6919
+ this.builder.flushBuffer();
6919
6920
  this.cache.clear(); // Must not reuse DOM across composition
6920
6921
  this.builder.addComposition(composition, compositionContext);
6921
6922
  this.text.skip(composition.range.toB - composition.range.fromB);
@@ -8129,12 +8130,11 @@
8129
8130
  }
8130
8131
  // Scan through the rectangles for the content of a tile with inline
8131
8132
  // content, looking for one that overlaps the queried position
8132
- // vertically andis
8133
- // closest horizontally. The caller is responsible for dividing its
8134
- // content into N pieces, and pass an array with N+1 positions
8135
- // (including the position after the last piece). For a text tile,
8136
- // these will be character clusters, for a composite tile, these
8137
- // will be child tiles.
8133
+ // vertically and is closest horizontally. The caller is responsible
8134
+ // for dividing its content into N pieces, and pass an array with
8135
+ // N+1 positions (including the position after the last piece). For
8136
+ // a text tile, these will be character clusters, for a composite
8137
+ // tile, these will be child tiles.
8138
8138
  scan(positions, getRects, recursed = false) {
8139
8139
  let lo = 0, hi = positions.length - 1, seen = new Set();
8140
8140
  let bidi = this.bidiIn(positions[0], positions[hi]);
@@ -8206,6 +8206,8 @@
8206
8206
  // If no element with y overlap is found, find the nearest element
8207
8207
  // on the y axis, move this.y into it, and retry the scan.
8208
8208
  if (!closestRect) {
8209
+ if (!below && !above)
8210
+ return { i: positions[0], after: false };
8209
8211
  let side = above && (!below || (this.y - above.bottom < below.top - this.y)) ? above : below;
8210
8212
  this.y = (side.top + side.bottom) / 2;
8211
8213
  return this.scan(positions, getRects, true);
@@ -11098,6 +11100,7 @@
11098
11100
  padding: "0 2px 0 6px"
11099
11101
  },
11100
11102
  ".cm-layer": {
11103
+ userSelect: "none", // #1708
11101
11104
  position: "absolute",
11102
11105
  left: 0,
11103
11106
  top: 0,
@@ -24116,7 +24119,7 @@
24116
24119
  let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
24117
24120
  if (!result)
24118
24121
  return new ActiveSource(this.source, 0 /* State.Inactive */);
24119
- return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
24122
+ return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
24120
24123
  }
24121
24124
  touches(tr) {
24122
24125
  return tr.changes.touchesRange(this.from, this.to);
@@ -24568,6 +24571,9 @@
24568
24571
  for (let line of template.split(/\r\n?|\n/)) {
24569
24572
  while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
24570
24573
  let seq = m[1] ? +m[1] : null, rawName = m[2] || m[3] || "", found = -1;
24574
+ // `${0}` is the cursor's final position, after every other tab stop.
24575
+ if (seq === 0)
24576
+ seq = 1e9;
24571
24577
  let name = rawName.replace(/\\[{}]/g, m => m[1]);
24572
24578
  for (let i = 0; i < fields.length; i++) {
24573
24579
  if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
@@ -24682,7 +24688,8 @@
24682
24688
 
24683
24689
  The order of fields defaults to textual order, but you can add
24684
24690
  numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
24685
- a custom order.
24691
+ a custom order. `${0}` is special—it is always the last stop, where
24692
+ the cursor ends up after tabbing through the other fields.
24686
24693
 
24687
24694
  To include a literal `{` or `}` in your template, put a backslash
24688
24695
  in front of it. This will be removed and the brace will not be
@@ -25248,7 +25255,7 @@
25248
25255
  return {
25249
25256
  pos: start,
25250
25257
  end: end,
25251
- above: view.state.doc.lineAt(start).to < end,
25258
+ above: true,
25252
25259
  create() {
25253
25260
  return { dom: diagnosticsTooltip(view, found) };
25254
25261
  }