datafolder 1.0.17 → 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/README.md +9 -0
- package/package.json +17 -17
- package/sample.js +12 -0
- package/scripts/fastify.js +1 -0
- package/scripts/hnsw.js +39 -0
- package/src/QyAcl.js +109 -87
- package/src/QyBatch.d.ts +5 -0
- package/src/QyBatch.js +213 -129
- package/src/QyBinWriter.d.ts +5 -9
- package/src/QyBinWriter.js +36 -45
- package/src/QyBinaryHeap.d.ts +10 -0
- package/src/QyBinaryHeap.js +55 -0
- package/src/QyCD.d.ts +3 -0
- package/src/QyCD.js +51 -38
- package/src/QyCache.d.ts +11 -1
- package/src/QyCache.js +132 -90
- package/src/QyDB.js +4 -7
- package/src/QyDefaultOptions.js +8 -0
- package/src/QyEmbeddingWriter.d.ts +12 -0
- package/src/QyEmbeddingWriter.js +55 -0
- package/src/QyEmbeddings.d.ts +15 -0
- package/src/QyEmbeddings.js +128 -0
- package/src/QyFile.js +8 -7
- package/src/QyFileContentUtils.d.ts +0 -1
- package/src/QyFileContentUtils.js +138 -127
- package/src/QyHNSW.d.ts +7 -0
- package/src/QyHNSW.js +49 -0
- package/src/QyIndex.js +28 -27
- package/src/QyIndexPropTree.js +3 -1
- package/src/QySnapshots.js +127 -131
- package/src/QyTrigger.js +5 -6
- package/src/QyUtils.d.ts +7 -0
- package/src/QyUtils.js +130 -104
- package/static/codemirror.bundle/editor.bundle.js +33 -12
- package/test/testQyDocumentDB.js +38 -0
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
|
|
9
|
+
import i, {
|
|
10
|
+
readSync as u
|
|
11
|
+
} from "node:fs";
|
|
10
12
|
|
|
11
13
|
import o from "node:timers/promises";
|
|
12
14
|
|
|
@@ -14,104 +16,113 @@ import {
|
|
|
14
16
|
fileURLToPath as r
|
|
15
17
|
} from "node:url";
|
|
16
18
|
|
|
19
|
+
import a from "node:util";
|
|
20
|
+
|
|
17
21
|
import {
|
|
18
|
-
logger as
|
|
22
|
+
logger as f
|
|
19
23
|
} from "../src/QyLogger.js";
|
|
20
24
|
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let c = Array.isArray, {
|
|
26
|
+
isDate: s,
|
|
27
|
+
isFloat32Array: d,
|
|
28
|
+
isUint8Array: m
|
|
29
|
+
} = a.types;
|
|
30
|
+
|
|
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" ],
|
|
30
41
|
IndexPropPathsFileName: "propPaths"
|
|
31
42
|
};
|
|
32
43
|
|
|
33
|
-
function
|
|
44
|
+
function g(r) {
|
|
34
45
|
return r.startsWith("{") && r.endsWith("}");
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
function
|
|
38
|
-
return
|
|
48
|
+
function v(r) {
|
|
49
|
+
return g(r) && r.substring(1, r.length - 1);
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
function
|
|
52
|
+
function b(r) {
|
|
42
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();
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
function
|
|
56
|
+
function $(r, t = 10) {
|
|
46
57
|
return n.createHash("sha256").update(r, "utf8").digest("base64url").slice(0, t);
|
|
47
58
|
}
|
|
48
59
|
|
|
49
|
-
var
|
|
60
|
+
var w = 11;
|
|
50
61
|
|
|
51
|
-
function
|
|
62
|
+
function P(r) {
|
|
52
63
|
return "d" + r;
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
function
|
|
66
|
+
function S(r) {
|
|
56
67
|
return "f" + r;
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
function
|
|
70
|
+
function x(r) {
|
|
60
71
|
return "c" + r;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
function
|
|
74
|
+
function D(r = 8) {
|
|
64
75
|
return n.randomBytes(r).toString("hex");
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
function
|
|
78
|
+
function j(r) {
|
|
68
79
|
if (null != r) for (var t in r) if (null != r[t]) return !1;
|
|
69
80
|
return !0;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
|
-
function
|
|
73
|
-
return null != r && "object" == typeof r && !(r
|
|
83
|
+
function B(r) {
|
|
84
|
+
return null != r && "object" == typeof r && !s(r);
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
function
|
|
87
|
+
function M(r) {
|
|
77
88
|
return "string" == typeof r;
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
function
|
|
91
|
+
function T(r) {
|
|
81
92
|
return "number" == typeof r;
|
|
82
93
|
}
|
|
83
94
|
|
|
84
|
-
function
|
|
95
|
+
function N(r) {
|
|
85
96
|
return "boolean" == typeof r;
|
|
86
97
|
}
|
|
87
98
|
|
|
88
|
-
function
|
|
99
|
+
function W(r) {
|
|
89
100
|
return "function" == typeof r;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
function
|
|
103
|
+
function E(r) {
|
|
93
104
|
var t = typeof r;
|
|
94
|
-
return "string" == t || "number" == t || "boolean" == t || r
|
|
105
|
+
return "string" == t || "number" == t || "boolean" == t || m(r) || s(r);
|
|
95
106
|
}
|
|
96
107
|
|
|
97
|
-
function
|
|
108
|
+
function R(r) {
|
|
98
109
|
let t = r.length;
|
|
99
110
|
for (;null == r[t - 1] && 0 < t; ) --t;
|
|
100
111
|
return r.length = t, r;
|
|
101
112
|
}
|
|
102
113
|
|
|
103
|
-
function
|
|
114
|
+
function H(n) {
|
|
104
115
|
return n.promise || (n.promise = new Promise((r, t) => Object.assign(n, {
|
|
105
116
|
resolve: r,
|
|
106
117
|
reject: t
|
|
107
118
|
}))), n;
|
|
108
119
|
}
|
|
109
120
|
|
|
110
|
-
function
|
|
121
|
+
function L(r) {
|
|
111
122
|
return Buffer.isBuffer(r) ? r : Buffer.from(r);
|
|
112
123
|
}
|
|
113
124
|
|
|
114
|
-
function
|
|
125
|
+
function G(r) {
|
|
115
126
|
return 1 < r ? "s" : "";
|
|
116
127
|
}
|
|
117
128
|
|
|
@@ -121,11 +132,11 @@ function F(r) {
|
|
|
121
132
|
});
|
|
122
133
|
}
|
|
123
134
|
|
|
124
|
-
function
|
|
135
|
+
function I(r) {
|
|
125
136
|
return F(t.dirname(r));
|
|
126
137
|
}
|
|
127
138
|
|
|
128
|
-
async function
|
|
139
|
+
async function O(r) {
|
|
129
140
|
try {
|
|
130
141
|
return (await l.stat(r)).size;
|
|
131
142
|
} catch (r) {
|
|
@@ -133,95 +144,95 @@ async function k(r) {
|
|
|
133
144
|
}
|
|
134
145
|
}
|
|
135
146
|
|
|
136
|
-
async function
|
|
137
|
-
return !1 !== await
|
|
147
|
+
async function J(r) {
|
|
148
|
+
return !1 !== await O(r);
|
|
138
149
|
}
|
|
139
150
|
|
|
140
|
-
function
|
|
151
|
+
function Q(r, t = void 0) {
|
|
141
152
|
r *= 1e3;
|
|
142
153
|
return t ? o.setTimeout(r, !0, {
|
|
143
154
|
signal: t
|
|
144
155
|
}) : o.setTimeout(r);
|
|
145
156
|
}
|
|
146
157
|
|
|
147
|
-
let
|
|
158
|
+
let U;
|
|
148
159
|
|
|
149
|
-
async function
|
|
160
|
+
async function z(t) {
|
|
150
161
|
try {
|
|
151
|
-
await
|
|
162
|
+
await I(t);
|
|
152
163
|
var r = new Date().toISOString() + ": " + e.argv.join(" ");
|
|
153
164
|
function n() {
|
|
154
|
-
for (var r of Object.keys(
|
|
165
|
+
for (var r of Object.keys(U)) k(r);
|
|
155
166
|
}
|
|
156
167
|
await l.writeFile(t, r, {
|
|
157
168
|
flag: "wx",
|
|
158
169
|
flush: !0
|
|
159
|
-
}),
|
|
170
|
+
}), f.info("Locked " + t), U ? U[t] = 1 : (U = {
|
|
160
171
|
[t]: 1
|
|
161
172
|
}, e.on("exit", n), e.on("SIGINT", n));
|
|
162
173
|
} catch (r) {
|
|
163
|
-
throw "EEXIST" == r.code &&
|
|
174
|
+
throw "EEXIST" == r.code && f.error(`Already started by ${(await l.readFile(t)).toString()}:`, r),
|
|
164
175
|
r;
|
|
165
176
|
}
|
|
166
177
|
}
|
|
167
178
|
|
|
168
|
-
function
|
|
179
|
+
function k(r) {
|
|
169
180
|
try {
|
|
170
|
-
i.unlinkSync(r),
|
|
181
|
+
i.unlinkSync(r), f.info("Unlocked " + r);
|
|
171
182
|
} catch (r) {}
|
|
172
183
|
}
|
|
173
184
|
|
|
174
|
-
function
|
|
185
|
+
function K(r) {
|
|
175
186
|
return r.startsWith("[") && r.endsWith("]") ? JSON.parse(r) : r;
|
|
176
187
|
}
|
|
177
188
|
|
|
178
|
-
function
|
|
179
|
-
return
|
|
189
|
+
function X(r) {
|
|
190
|
+
return c(r) ? 1 == r.length ? r[0] : JSON.stringify(r) : r;
|
|
180
191
|
}
|
|
181
192
|
|
|
182
|
-
function
|
|
193
|
+
function q(r) {
|
|
183
194
|
r = r.split("/");
|
|
184
195
|
return r[0] || (r[0] = "/"), r;
|
|
185
196
|
}
|
|
186
197
|
|
|
187
|
-
function
|
|
198
|
+
function A(r) {
|
|
188
199
|
return r.split(".");
|
|
189
200
|
}
|
|
190
201
|
|
|
191
|
-
function
|
|
192
|
-
return
|
|
202
|
+
function C(r) {
|
|
203
|
+
return M(r) ? [ A(r) ] : c(r) ? r.map(r => M(r) ? A(r) : r) : void 0;
|
|
193
204
|
}
|
|
194
205
|
|
|
195
|
-
function
|
|
206
|
+
function V(r) {
|
|
196
207
|
return r.join(".");
|
|
197
208
|
}
|
|
198
209
|
|
|
199
|
-
function
|
|
210
|
+
function Y(r, t = 0) {
|
|
200
211
|
return Math.floor(Math.random() * (r - t)) + t;
|
|
201
212
|
}
|
|
202
213
|
|
|
203
|
-
function
|
|
214
|
+
function Z(r) {
|
|
204
215
|
var t, n = {};
|
|
205
216
|
for (t of r) n[t] = 1;
|
|
206
217
|
return n;
|
|
207
218
|
}
|
|
208
219
|
|
|
209
|
-
async function
|
|
220
|
+
async function _(t, n, e, i) {
|
|
210
221
|
var o = Buffer.allocUnsafe(i);
|
|
211
222
|
for (let r = 0; r < i; ) {
|
|
212
223
|
var a = (await n.read(o, r, i - r, e + r)).bytesRead;
|
|
213
|
-
if (0 == a) return void
|
|
224
|
+
if (0 == a) return void f.error(`read ${t} at ${e + r} returning 0 byte`);
|
|
214
225
|
r += a;
|
|
215
226
|
}
|
|
216
227
|
return o;
|
|
217
228
|
}
|
|
218
229
|
|
|
219
|
-
function
|
|
230
|
+
function rr() {
|
|
220
231
|
var r = e.availableMemory();
|
|
221
232
|
return Math.round(r / (e.memoryUsage.rss() + r) * 100);
|
|
222
233
|
}
|
|
223
234
|
|
|
224
|
-
async function*
|
|
235
|
+
async function* tr(e, t = 3) {
|
|
225
236
|
var n = e.length, i = (n < t && (t = n), new Array(n));
|
|
226
237
|
for (let r = 0; r < t; ++r) {
|
|
227
238
|
var o = i[r] = {};
|
|
@@ -247,58 +258,73 @@ async function* V(e, t = 3) {
|
|
|
247
258
|
}
|
|
248
259
|
}
|
|
249
260
|
|
|
250
|
-
function
|
|
261
|
+
function nr(r = new Date()) {
|
|
251
262
|
return r.getTime();
|
|
252
263
|
}
|
|
253
264
|
|
|
254
|
-
function
|
|
265
|
+
function er(r = new Date()) {
|
|
255
266
|
r = r.getTime();
|
|
256
267
|
return r - r % 1e3;
|
|
257
268
|
}
|
|
258
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
|
+
|
|
259
280
|
export * as default from "./QyUtils.js";
|
|
260
281
|
|
|
261
282
|
export {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
m as
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
g as
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
w as
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
x as
|
|
277
|
-
|
|
278
|
-
j as
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
E as
|
|
283
|
+
c as isArray,
|
|
284
|
+
s as isDate,
|
|
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,
|
|
285
310
|
F as ensureDir,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
|
304
330
|
};
|
|
@@ -4681,10 +4681,23 @@
|
|
|
4681
4681
|
directly at `from` but not including `to`.
|
|
4682
4682
|
*/
|
|
4683
4683
|
class BlockWrapper extends RangeValue {
|
|
4684
|
-
constructor(
|
|
4684
|
+
constructor(
|
|
4685
|
+
/**
|
|
4686
|
+
@internal
|
|
4687
|
+
*/
|
|
4688
|
+
tagName,
|
|
4689
|
+
/**
|
|
4690
|
+
@internal
|
|
4691
|
+
*/
|
|
4692
|
+
attributes,
|
|
4693
|
+
/**
|
|
4694
|
+
@internal
|
|
4695
|
+
*/
|
|
4696
|
+
rank) {
|
|
4685
4697
|
super();
|
|
4686
4698
|
this.tagName = tagName;
|
|
4687
4699
|
this.attributes = attributes;
|
|
4700
|
+
this.rank = rank;
|
|
4688
4701
|
}
|
|
4689
4702
|
eq(other) {
|
|
4690
4703
|
return other == this ||
|
|
@@ -4695,7 +4708,7 @@
|
|
|
4695
4708
|
attributes.
|
|
4696
4709
|
*/
|
|
4697
4710
|
static create(spec) {
|
|
4698
|
-
return new BlockWrapper(spec.tagName, spec.attributes || noAttrs$1);
|
|
4711
|
+
return new BlockWrapper(spec.tagName, spec.attributes || noAttrs$1, spec.rank == null ? 50 : Math.max(0, Math.min(spec.rank, 100)));
|
|
4699
4712
|
}
|
|
4700
4713
|
/**
|
|
4701
4714
|
Create a range set from the given block wrapper ranges.
|
|
@@ -6695,7 +6708,8 @@
|
|
|
6695
6708
|
this.wrappers.splice(i, 1);
|
|
6696
6709
|
for (let cur = this.blockWrappers; cur.value && cur.from <= this.pos; cur.next())
|
|
6697
6710
|
if (cur.to >= this.pos) {
|
|
6698
|
-
let
|
|
6711
|
+
let rank = (cur.rank * 102) + cur.value.rank;
|
|
6712
|
+
let wrap = new OpenWrapper(cur.from, cur.to, cur.value, rank), i = this.wrappers.length;
|
|
6699
6713
|
while (i > 0 && (this.wrappers[i - 1].rank - wrap.rank || this.wrappers[i - 1].to - wrap.to) < 0)
|
|
6700
6714
|
i--;
|
|
6701
6715
|
this.wrappers.splice(i, 0, wrap);
|
|
@@ -6902,6 +6916,7 @@
|
|
|
6902
6916
|
if (composition && next.fromA <= composition.range.fromA && next.toA >= composition.range.toA) {
|
|
6903
6917
|
this.forward(next.fromA, composition.range.fromA, composition.range.fromA < composition.range.toA ? 1 : -1);
|
|
6904
6918
|
this.emit(posB, composition.range.fromB);
|
|
6919
|
+
this.builder.flushBuffer();
|
|
6905
6920
|
this.cache.clear(); // Must not reuse DOM across composition
|
|
6906
6921
|
this.builder.addComposition(composition, compositionContext);
|
|
6907
6922
|
this.text.skip(composition.range.toB - composition.range.fromB);
|
|
@@ -8115,12 +8130,11 @@
|
|
|
8115
8130
|
}
|
|
8116
8131
|
// Scan through the rectangles for the content of a tile with inline
|
|
8117
8132
|
// content, looking for one that overlaps the queried position
|
|
8118
|
-
// vertically
|
|
8119
|
-
//
|
|
8120
|
-
//
|
|
8121
|
-
//
|
|
8122
|
-
// these will be
|
|
8123
|
-
// 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.
|
|
8124
8138
|
scan(positions, getRects, recursed = false) {
|
|
8125
8139
|
let lo = 0, hi = positions.length - 1, seen = new Set();
|
|
8126
8140
|
let bidi = this.bidiIn(positions[0], positions[hi]);
|
|
@@ -8192,6 +8206,8 @@
|
|
|
8192
8206
|
// If no element with y overlap is found, find the nearest element
|
|
8193
8207
|
// on the y axis, move this.y into it, and retry the scan.
|
|
8194
8208
|
if (!closestRect) {
|
|
8209
|
+
if (!below && !above)
|
|
8210
|
+
return { i: positions[0], after: false };
|
|
8195
8211
|
let side = above && (!below || (this.y - above.bottom < below.top - this.y)) ? above : below;
|
|
8196
8212
|
this.y = (side.top + side.bottom) / 2;
|
|
8197
8213
|
return this.scan(positions, getRects, true);
|
|
@@ -11084,6 +11100,7 @@
|
|
|
11084
11100
|
padding: "0 2px 0 6px"
|
|
11085
11101
|
},
|
|
11086
11102
|
".cm-layer": {
|
|
11103
|
+
userSelect: "none", // #1708
|
|
11087
11104
|
position: "absolute",
|
|
11088
11105
|
left: 0,
|
|
11089
11106
|
top: 0,
|
|
@@ -24102,7 +24119,7 @@
|
|
|
24102
24119
|
let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
|
|
24103
24120
|
if (!result)
|
|
24104
24121
|
return new ActiveSource(this.source, 0 /* State.Inactive */);
|
|
24105
|
-
return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit),
|
|
24122
|
+
return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
|
|
24106
24123
|
}
|
|
24107
24124
|
touches(tr) {
|
|
24108
24125
|
return tr.changes.touchesRange(this.from, this.to);
|
|
@@ -24554,6 +24571,9 @@
|
|
|
24554
24571
|
for (let line of template.split(/\r\n?|\n/)) {
|
|
24555
24572
|
while (m = /[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(line)) {
|
|
24556
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;
|
|
24557
24577
|
let name = rawName.replace(/\\[{}]/g, m => m[1]);
|
|
24558
24578
|
for (let i = 0; i < fields.length; i++) {
|
|
24559
24579
|
if (seq != null ? fields[i].seq == seq : name ? fields[i].name == name : false)
|
|
@@ -24668,7 +24688,8 @@
|
|
|
24668
24688
|
|
|
24669
24689
|
The order of fields defaults to textual order, but you can add
|
|
24670
24690
|
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
|
24671
|
-
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.
|
|
24672
24693
|
|
|
24673
24694
|
To include a literal `{` or `}` in your template, put a backslash
|
|
24674
24695
|
in front of it. This will be removed and the brace will not be
|
|
@@ -25234,7 +25255,7 @@
|
|
|
25234
25255
|
return {
|
|
25235
25256
|
pos: start,
|
|
25236
25257
|
end: end,
|
|
25237
|
-
above:
|
|
25258
|
+
above: true,
|
|
25238
25259
|
create() {
|
|
25239
25260
|
return { dom: diagnosticsTooltip(view, found) };
|
|
25240
25261
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import { deepEqual } from "node:assert/strict";
|
|
3
|
+
import { QyDB } from "../src/QyDB.js";
|
|
4
|
+
import { logger } from "../src/QyLogger.js";
|
|
5
|
+
logger.level = "warn";
|
|
6
|
+
const documentDBData = {
|
|
7
|
+
_id: "ab6ad8f119b5bca3efa2c7ae",
|
|
8
|
+
restaurantId: "REST-CRT9BL",
|
|
9
|
+
name: "Thai Curry Palace",
|
|
10
|
+
description: "Amazing Restaurant, must visit",
|
|
11
|
+
cuisine: "Thai",
|
|
12
|
+
address: {
|
|
13
|
+
street: "914 Park Street",
|
|
14
|
+
city: "Bryan",
|
|
15
|
+
state: "AL",
|
|
16
|
+
zipCode: "96865",
|
|
17
|
+
location: { type: "Point", coordinates: [-25.4619, 8.389] },
|
|
18
|
+
},
|
|
19
|
+
contact: { phone: "(669) 915-9056 x6657" },
|
|
20
|
+
rating: { average: 3.4, totalReviews: 275 },
|
|
21
|
+
priceRange: "$",
|
|
22
|
+
menu: [{ category: "Appetizers", items: [{ name: "Buffalo Chicken Wings", price: 13.42 }] }],
|
|
23
|
+
features: ["Private Dining"],
|
|
24
|
+
isActive: false,
|
|
25
|
+
michelin: { star: 3, ranking_years: 4 },
|
|
26
|
+
};
|
|
27
|
+
test("test QyDocumentDB", { skip: false }, async (context) => {
|
|
28
|
+
context.after(async (t) => {
|
|
29
|
+
await qyDB.stop();
|
|
30
|
+
});
|
|
31
|
+
const dataFolder = "./tmp/QyDocumentDB/1";
|
|
32
|
+
const qyDB = new QyDB(dataFolder);
|
|
33
|
+
await qyDB.start();
|
|
34
|
+
qyDB.insert(`restaurants/${documentDBData.restaurantId}`, documentDBData);
|
|
35
|
+
await qyDB.stop();
|
|
36
|
+
await qyDB.start();
|
|
37
|
+
deepEqual(qyDB.queryFiles("restaurants", { priceRange: "$" })[0].view(), documentDBData);
|
|
38
|
+
});
|