datafolder 1.0.27 → 1.0.28
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/ChangeLog.md +2 -0
- package/package.json +1 -1
- package/scripts/flights2.js +3 -3
- package/src/QyAcl.d.ts +3 -2
- package/src/QyAcl.js +87 -87
- package/src/QyBatch.d.ts +0 -1
- package/src/QyBatch.js +59 -67
- package/src/QyDB.js +1 -1
- package/src/QyFileContentUtils.d.ts +1 -3
- package/src/QyFileContentUtils.js +111 -161
- package/src/QySnapshots.js +1 -1
- package/src/QyUtils.js +1 -1
package/ChangeLog.md
CHANGED
package/package.json
CHANGED
package/scripts/flights2.js
CHANGED
|
@@ -19,7 +19,7 @@ function insertAirports() {
|
|
|
19
19
|
const { batch } = qyDB;
|
|
20
20
|
for (const record of data) {
|
|
21
21
|
const { country, state, city } = record;
|
|
22
|
-
batch.
|
|
22
|
+
batch.insert(`airports/${country}/${state}/${city}/${record._key}`, record);
|
|
23
23
|
}
|
|
24
24
|
batch.run();
|
|
25
25
|
console.timeEnd("insertAirports");
|
|
@@ -32,8 +32,8 @@ function insertFlights() {
|
|
|
32
32
|
for (let i = 0; i < data.length; ++i) {
|
|
33
33
|
const record = data[i];
|
|
34
34
|
const { Year, Month, Day } = record;
|
|
35
|
-
batch.
|
|
36
|
-
|
|
35
|
+
// batch.insert(`flights/${Year}/${Month}/${Day}/${i}`, record);
|
|
36
|
+
batch.insert(["flights", Year, Month, Day, i], record);
|
|
37
37
|
}
|
|
38
38
|
batch.run();
|
|
39
39
|
console.timeEnd("insertFlights");
|
package/src/QyAcl.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ export declare const CmdNames: {
|
|
|
4
4
|
R: number;
|
|
5
5
|
D: number;
|
|
6
6
|
};
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function applyAclCmdObj(aclKeyValueMap: any, cmdArgAsListObj: any): void;
|
|
8
8
|
export declare function iterCmdKeys(cmdArgAsListObj: any, fun: any): void;
|
|
9
|
+
export declare function applyChange(oldContent: any, newValue: any): any;
|
|
9
10
|
export declare class QyAclCmdGenerator {
|
|
10
|
-
|
|
11
|
+
cmdArgAsMapChangeObj: any[];
|
|
11
12
|
cmdCount: number;
|
|
12
13
|
batchSize: number;
|
|
13
14
|
constructor();
|
package/src/QyAcl.js
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import c from "node:fs/promises";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
cleanContent as s,
|
|
5
|
-
mergeContent as g,
|
|
6
4
|
setValByNamePath as a
|
|
7
5
|
} from "./QyFileContentUtils.js";
|
|
8
6
|
|
|
9
7
|
import {
|
|
10
|
-
isEmptyObj as
|
|
8
|
+
isEmptyObj as g,
|
|
11
9
|
toBuffer as n,
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
isSimpleType as i,
|
|
11
|
+
isArray as s,
|
|
12
|
+
trimArrayTail as o
|
|
14
13
|
} from "./QyUtils.js";
|
|
15
14
|
|
|
16
15
|
import {
|
|
17
16
|
logger as h
|
|
18
17
|
} from "./QyLogger.js";
|
|
19
18
|
|
|
20
|
-
let {
|
|
21
|
-
$del: f,
|
|
22
|
-
$rpl: l
|
|
23
|
-
} = r, u = {
|
|
19
|
+
let f = {
|
|
24
20
|
M: 0,
|
|
25
21
|
A: 1,
|
|
26
22
|
R: 2,
|
|
27
23
|
D: 3
|
|
28
24
|
};
|
|
29
25
|
|
|
30
|
-
function
|
|
26
|
+
function r(r, t) {
|
|
31
27
|
var e, a, n, i, [ s, o, f, t ] = t;
|
|
32
28
|
for (e in t) null != r[e] && (r[e] = void 0);
|
|
33
29
|
for (a in o) {
|
|
34
|
-
var
|
|
35
|
-
for (
|
|
30
|
+
var u, l = r[a] || (r[a] = {});
|
|
31
|
+
for (u of o[a]) l[u] = 1;
|
|
36
32
|
}
|
|
37
33
|
for (n in f) {
|
|
38
34
|
var c = r[n];
|
|
@@ -40,57 +36,60 @@ function t(r, t) {
|
|
|
40
36
|
var h = f[n];
|
|
41
37
|
if (h) {
|
|
42
38
|
for (var d of h) delete c[d];
|
|
43
|
-
|
|
39
|
+
g(c) && (r[n] = void 0);
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
|
-
for (i in s) r[i] =
|
|
43
|
+
for (i in s) r[i] = v(r[i], s[i]);
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
function
|
|
46
|
+
function t(r, t) {
|
|
51
47
|
for (var e of r) for (var a in e) t(a);
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
function v(r, t) {
|
|
51
|
+
if (null !== t) {
|
|
52
|
+
var e, a = t.$u8;
|
|
53
|
+
if (a) return new Uint8Array(a);
|
|
54
|
+
if (null == r || i(r) || i(t) || s(t) || t.$rpl) return t;
|
|
55
|
+
for (e in t) {
|
|
56
|
+
var n = v(r[e], t[e]);
|
|
57
|
+
null != n ? r[e] = n : delete r[e];
|
|
58
|
+
}
|
|
59
|
+
return s(r) && o(r), r;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
class e {
|
|
64
|
+
cmdArgAsMapChangeObj = [];
|
|
56
65
|
cmdCount = 0;
|
|
57
66
|
batchSize = 0;
|
|
58
67
|
constructor() {}
|
|
59
68
|
pushCmd(r, t, e = void 0) {
|
|
60
69
|
switch (++this.cmdCount, r) {
|
|
61
|
-
case
|
|
62
|
-
|
|
70
|
+
case f.A:
|
|
71
|
+
u(this, [ f.A, t, e ]), l(this, [ f.R, t, e ]);
|
|
63
72
|
break;
|
|
64
73
|
|
|
65
|
-
case
|
|
66
|
-
|
|
74
|
+
case f.R:
|
|
75
|
+
u(this, [ f.R, t, e ]), l(this, [ f.A, t, e ]);
|
|
67
76
|
break;
|
|
68
77
|
|
|
69
|
-
case
|
|
70
|
-
if (
|
|
78
|
+
case f.D:
|
|
79
|
+
if (u(this, [ f.D, t ]), t.startsWith("c")) l(this, [ f.M, t ]); else for (var a of [ f.A, f.R ]) l(this, [ a, t ]);
|
|
71
80
|
break;
|
|
72
81
|
|
|
73
|
-
case
|
|
82
|
+
case f.M:
|
|
74
83
|
{
|
|
75
|
-
var n = this.
|
|
84
|
+
var n = this.cmdArgAsMapChangeObj;
|
|
76
85
|
let [ r ] = n;
|
|
77
|
-
n = (r = null == r ? n[
|
|
78
|
-
r[t] = null != n ? function
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
if (null
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (a == f) return {
|
|
85
|
-
[l]: s(n)
|
|
86
|
-
};
|
|
87
|
-
if (o(a) || o(n)) return n;
|
|
88
|
-
if (n.$u8) return n;
|
|
89
|
-
for (var i of Object.keys(n)) {
|
|
90
|
-
let r = n[i], t = a[i];
|
|
91
|
-
null == t ? a[i] = r : a[i] = e(t, r);
|
|
92
|
-
}
|
|
93
|
-
return a;
|
|
86
|
+
n = (r = null == r ? n[f.M] = {} : r)[t];
|
|
87
|
+
r[t] = null != n ? function r(t, e) {
|
|
88
|
+
if (null === e) return null;
|
|
89
|
+
if (void 0 === t || i(e) || s(e) || e.$rpl || e.$u8) return e;
|
|
90
|
+
if (null === t || i(t)) return e.$rpl = 1, e;
|
|
91
|
+
for (var a in e) t[a] = r(t[a], e[a]);
|
|
92
|
+
return t;
|
|
94
93
|
}(n, e) : e;
|
|
95
94
|
break;
|
|
96
95
|
}
|
|
@@ -101,101 +100,101 @@ class i {
|
|
|
101
100
|
}
|
|
102
101
|
pushCmdArgAsListObj(r) {
|
|
103
102
|
if (r) {
|
|
104
|
-
for (var t in ++this.batchSize, r[
|
|
105
|
-
for (var e of [
|
|
103
|
+
for (var t in ++this.batchSize, r[f.D]) this.pushCmd(f.D, t);
|
|
104
|
+
for (var e of [ f.A, f.R ]) {
|
|
106
105
|
var a, n = r[e];
|
|
107
106
|
for (a in n) for (var i of n[a]) this.pushCmd(e, a, i);
|
|
108
107
|
}
|
|
109
108
|
var s, [ o ] = r;
|
|
110
|
-
for (s in o) this.pushCmd(
|
|
109
|
+
for (s in o) this.pushCmd(f.M, s, o[s]);
|
|
111
110
|
}
|
|
112
111
|
return this;
|
|
113
112
|
}
|
|
114
113
|
takeCmdArgAsListObj() {
|
|
115
|
-
var r, t = this.
|
|
114
|
+
var r, t = this.cmdArgAsMapChangeObj;
|
|
116
115
|
Object.assign(this, {
|
|
117
|
-
|
|
116
|
+
cmdArgAsMapChangeObj: [],
|
|
118
117
|
cmdCount: 0,
|
|
119
118
|
batchSize: 0
|
|
120
119
|
});
|
|
121
|
-
for (r of [
|
|
120
|
+
for (r of [ f.A, f.R ]) {
|
|
122
121
|
var e, a = t[r];
|
|
123
122
|
for (e in a) {
|
|
124
123
|
var n = Object.keys(a[e]);
|
|
125
124
|
0 < n.length ? a[e] = n : delete a[e];
|
|
126
125
|
}
|
|
127
|
-
|
|
126
|
+
g(a) && delete t[r];
|
|
128
127
|
}
|
|
129
|
-
var i = t[
|
|
130
|
-
return i &&
|
|
128
|
+
var i = t[f.D], i = (i && g(i) && delete t[f.D], t[f.M]);
|
|
129
|
+
return i && g(i) && delete t[f.M], t;
|
|
131
130
|
}
|
|
132
131
|
toAclBuffer(r) {
|
|
133
132
|
var t = this.batchSize;
|
|
134
|
-
if (0 < t) return
|
|
133
|
+
if (0 < t) return b(r, t, JSON.stringify(this.takeCmdArgAsListObj()));
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
function
|
|
139
|
-
a(r.
|
|
137
|
+
function u(r, t, e = 1) {
|
|
138
|
+
a(r.cmdArgAsMapChangeObj, t, e);
|
|
140
139
|
}
|
|
141
140
|
|
|
142
|
-
function
|
|
143
|
-
let e = r.
|
|
141
|
+
function l(r, t) {
|
|
142
|
+
let e = r.cmdArgAsMapChangeObj;
|
|
144
143
|
if (e && t && !(t.length <= 1)) {
|
|
145
144
|
for (let r = 0; r < t.length - 1; ++r) if (null == (e = e[t[r]])) return;
|
|
146
145
|
delete e[t.at(-1)];
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
async function
|
|
149
|
+
async function d(t, r = !1, e = 0) {
|
|
151
150
|
try {
|
|
152
|
-
return await
|
|
151
|
+
return await w(t, await c.readFile(t), r, e);
|
|
153
152
|
} catch (r) {
|
|
154
153
|
throw h.error(`Reading ${t} failed:`, r), r;
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
let
|
|
157
|
+
let m = [ 1, 2, 4, 8 ];
|
|
159
158
|
|
|
160
|
-
function
|
|
159
|
+
function A(t) {
|
|
161
160
|
var e = t.length, a = new Array(e), n = new Array(e);
|
|
162
161
|
let i = e << 6, s = 1;
|
|
163
162
|
for (let r = 0; r < e; ++r) {
|
|
164
163
|
var o = a[r] = (o = t[r]) <= 255 ? 0 : o <= 65535 ? 1 : o <= 4294967295 ? 2 : 3, o = (i |= o << (r << 1),
|
|
165
|
-
n[r] =
|
|
164
|
+
n[r] = m[o]);
|
|
166
165
|
s += o;
|
|
167
166
|
}
|
|
168
167
|
var f = Buffer.allocUnsafe(s);
|
|
169
168
|
f.writeUInt8(i);
|
|
170
|
-
let
|
|
169
|
+
let u = 1;
|
|
171
170
|
for (let r = 0; r < e; ++r) {
|
|
172
|
-
d = h = c =
|
|
173
|
-
var [
|
|
171
|
+
d = h = c = l = void 0;
|
|
172
|
+
var [ l, c, h, d = 0 ] = [ f, t[r], n[r], u ];
|
|
174
173
|
switch (h) {
|
|
175
174
|
case 1:
|
|
176
|
-
|
|
175
|
+
l.writeUInt8(c, d);
|
|
177
176
|
break;
|
|
178
177
|
|
|
179
178
|
case 2:
|
|
180
|
-
|
|
179
|
+
l.writeUInt16BE(c, d);
|
|
181
180
|
break;
|
|
182
181
|
|
|
183
182
|
case 4:
|
|
184
|
-
|
|
183
|
+
l.writeUInt32BE(c, d);
|
|
185
184
|
break;
|
|
186
185
|
|
|
187
186
|
default:
|
|
188
|
-
|
|
187
|
+
l.writeBigUInt64BE(BigInt(c), d);
|
|
189
188
|
}
|
|
190
|
-
|
|
189
|
+
u += n[r];
|
|
191
190
|
}
|
|
192
191
|
return f;
|
|
193
192
|
}
|
|
194
193
|
|
|
195
|
-
function
|
|
194
|
+
function p(t, e, a) {
|
|
196
195
|
var n = t.readUInt8(e), i = (++e, n >> 6 & 3);
|
|
197
196
|
for (let r = 0; r < i; ++r) {
|
|
198
|
-
var s =
|
|
197
|
+
var s = m[n >> (r << 1) & 3];
|
|
199
198
|
a[r] = ((r, t, e = 0) => {
|
|
200
199
|
switch (t) {
|
|
201
200
|
case 1:
|
|
@@ -215,21 +214,21 @@ function C(t, e, a) {
|
|
|
215
214
|
return e;
|
|
216
215
|
}
|
|
217
216
|
|
|
218
|
-
function
|
|
217
|
+
function b(r, t, e) {
|
|
219
218
|
e = n(e);
|
|
220
|
-
return Buffer.concat([
|
|
219
|
+
return Buffer.concat([ A([ r, t, e.length ]), e ]);
|
|
221
220
|
}
|
|
222
221
|
|
|
223
|
-
async function
|
|
222
|
+
async function w(e, r, a, n) {
|
|
224
223
|
var i = [];
|
|
225
224
|
for (let t = 0; t < r.length; ) {
|
|
226
|
-
var s = [], o =
|
|
225
|
+
var s = [], o = p(r, t, s), [ s, f, u ] = s;
|
|
227
226
|
if (s <= n) h.warn(`changeId ${s} <= currentChangeId ${n} at ${e}:${t}. Ignored.`),
|
|
228
|
-
t = o +
|
|
227
|
+
t = o + u; else {
|
|
229
228
|
n + f != s && h.warn(`currentChangeId ${n} + batchSize ${f} != changeId ` + s);
|
|
230
229
|
try {
|
|
231
|
-
var
|
|
232
|
-
i.push([ s,
|
|
230
|
+
var l = JSON.parse(r.subarray(o, o + u));
|
|
231
|
+
i.push([ s, l ]), n = s, t = o + u;
|
|
233
232
|
} catch (r) {
|
|
234
233
|
if (h.error(`Parse ${e} failed at ${t}:`, r), a) return h.warn(`Autorepair by truncating ${e} to ` + t),
|
|
235
234
|
null == (f = await c.truncate(e, t)) ? h.log("truncate success") : h.error("truncate failed:", f),
|
|
@@ -242,13 +241,14 @@ async function y(e, r, a, n) {
|
|
|
242
241
|
}
|
|
243
242
|
|
|
244
243
|
export {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
244
|
+
f as CmdNames,
|
|
245
|
+
r as applyAclCmdObj,
|
|
246
|
+
t as iterCmdKeys,
|
|
247
|
+
v as applyChange,
|
|
248
|
+
e as QyAclCmdGenerator,
|
|
249
|
+
d as readAclFile,
|
|
250
|
+
A as numsToBuffer,
|
|
251
|
+
p as bufferToNums,
|
|
252
|
+
b as toAclBuffer,
|
|
253
|
+
w as readAclBuffer
|
|
254
254
|
};
|
package/src/QyBatch.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export declare class QyBatch extends QyCD {
|
|
|
28
28
|
insertEmbedding(namePath: any, embedding: any, parentDir?: any): any;
|
|
29
29
|
delEmbedding(namePath: any, parentDir?: any): any;
|
|
30
30
|
insertWithEmbedding(namePath: any, content: any, embedding: any, noClone?: boolean, noCreate?: boolean, parentDir?: any): any;
|
|
31
|
-
remove(namePath: any, content: any, parentDir?: any): any;
|
|
32
31
|
put(namePath: any, content: any, parentDir?: any): any;
|
|
33
32
|
delContent(namePath: any, parentDir?: any): any;
|
|
34
33
|
insertTrigger(triggerName: any, fileNamePath: any, propNamePathList: any, modCode: any): any;
|
package/src/QyBatch.js
CHANGED
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
mergeContentAndGenDelta as s
|
|
7
|
-
objToDelMarks as r
|
|
6
|
+
mergeContentAndGenDelta as s
|
|
8
7
|
} from "./QyFileContentUtils.js";
|
|
9
8
|
|
|
10
9
|
import {
|
|
@@ -12,33 +11,33 @@ import {
|
|
|
12
11
|
ensurePropNamePathList as n,
|
|
13
12
|
isString as l,
|
|
14
13
|
SpecialOperators as e,
|
|
15
|
-
getSuffix as
|
|
14
|
+
getSuffix as f,
|
|
16
15
|
SpecialFilePaths as t,
|
|
17
|
-
toSingleName as
|
|
16
|
+
toSingleName as _,
|
|
18
17
|
isSimpleType as c,
|
|
19
18
|
isEmptyObj as m,
|
|
20
|
-
isNumber as
|
|
19
|
+
isNumber as r,
|
|
21
20
|
getNowRounded as d,
|
|
22
|
-
isDate as
|
|
23
|
-
isArray as
|
|
24
|
-
isFloat32Array as
|
|
21
|
+
isDate as a,
|
|
22
|
+
isArray as u,
|
|
23
|
+
isFloat32Array as g
|
|
25
24
|
} from "./QyUtils.js";
|
|
26
25
|
|
|
27
26
|
import {
|
|
28
27
|
QyAclCmdGenerator as i,
|
|
29
|
-
CmdNames as
|
|
28
|
+
CmdNames as C
|
|
30
29
|
} from "./QyAcl.js";
|
|
31
30
|
|
|
32
31
|
import {
|
|
33
|
-
calDifferenceList as
|
|
32
|
+
calDifferenceList as p
|
|
34
33
|
} from "./QyIndex.js";
|
|
35
34
|
|
|
36
35
|
import {
|
|
37
|
-
getDefaultOptions as
|
|
36
|
+
getDefaultOptions as v
|
|
38
37
|
} from "./QyDefaultOptions.js";
|
|
39
38
|
|
|
40
39
|
import {
|
|
41
|
-
QyCD as
|
|
40
|
+
QyCD as y
|
|
42
41
|
} from "./QyCD.js";
|
|
43
42
|
|
|
44
43
|
import {
|
|
@@ -46,17 +45,17 @@ import {
|
|
|
46
45
|
} from "./QyIndexPropTree.js";
|
|
47
46
|
|
|
48
47
|
import {
|
|
49
|
-
logger as
|
|
48
|
+
logger as D
|
|
50
49
|
} from "./QyLogger.js";
|
|
51
50
|
|
|
52
|
-
let
|
|
51
|
+
let F = e.$del, O = t.IndexPropPathsFileName, b = {
|
|
53
52
|
none: 0,
|
|
54
53
|
basic: 1,
|
|
55
54
|
delta: 2,
|
|
56
55
|
all: 3
|
|
57
56
|
};
|
|
58
57
|
|
|
59
|
-
class
|
|
58
|
+
class L extends y {
|
|
60
59
|
fileLogLevel;
|
|
61
60
|
actionQueue;
|
|
62
61
|
changeId;
|
|
@@ -67,15 +66,15 @@ class Q extends D {
|
|
|
67
66
|
running;
|
|
68
67
|
constructor(e, t) {
|
|
69
68
|
super(e), t = {
|
|
70
|
-
...
|
|
69
|
+
...v("QyBatch"),
|
|
71
70
|
...t
|
|
72
71
|
};
|
|
73
|
-
e =
|
|
72
|
+
e = b[t.fileLogLevel.toLowerCase()];
|
|
74
73
|
Object.assign(this, {
|
|
75
74
|
options: t,
|
|
76
75
|
fileLogLevel: e ?? 1,
|
|
77
76
|
qyAclCmdGenerator: new i(),
|
|
78
|
-
qyCmdObjHistory: new
|
|
77
|
+
qyCmdObjHistory: new Q(t.maxHistoryCmdObjCount),
|
|
79
78
|
actionQueue: [],
|
|
80
79
|
changeList: [],
|
|
81
80
|
syncList: []
|
|
@@ -141,7 +140,7 @@ class Q extends D {
|
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
142
|
createIndex(e, t, i = this.currentDir) {
|
|
144
|
-
l(e) && (e = o(e)),
|
|
143
|
+
l(e) && (e = o(e)), u(t) || (t = [ t ]);
|
|
145
144
|
e = this.qyCache.getOrCreateDir(e, i);
|
|
146
145
|
return q(this, this._action_createIndex, {
|
|
147
146
|
item: e,
|
|
@@ -156,7 +155,7 @@ class Q extends D {
|
|
|
156
155
|
indexPropPath: t
|
|
157
156
|
});
|
|
158
157
|
}
|
|
159
|
-
insert(e, t, i = !
|
|
158
|
+
insert(e, t, i = !0, r = !1, n = this.currentDir) {
|
|
160
159
|
l(e) && (e = o(e));
|
|
161
160
|
e = this.qyCache.getOrCreateFile(e, n).ensureLoaded();
|
|
162
161
|
return t = i || c(t) ? t : structuredClone(t), q(this, this._action_insert, {
|
|
@@ -166,7 +165,7 @@ class Q extends D {
|
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
167
|
insertEmbedding(e, t, i = this.currentDir) {
|
|
169
|
-
var r = this.qyCache, r = (
|
|
168
|
+
var r = this.qyCache, r = (g(t) || (t = new Float32Array(t)), l(e) && (e = o(e)),
|
|
170
169
|
r.getOrCreateFile(e, i));
|
|
171
170
|
return q(this, this._action_insertEmbedding, {
|
|
172
171
|
item: r,
|
|
@@ -182,9 +181,6 @@ class Q extends D {
|
|
|
182
181
|
insertWithEmbedding(e, t, i, r = !1, n = !1, a = this.currentDir) {
|
|
183
182
|
return this.insert(e, t, r, n, a), this.insertEmbedding(e, i, a);
|
|
184
183
|
}
|
|
185
|
-
remove(e, t, i = this.currentDir) {
|
|
186
|
-
return this.insert(e, r(t), !0, !0, i);
|
|
187
|
-
}
|
|
188
184
|
put(e, t, i = this.currentDir) {
|
|
189
185
|
l(e) && (e = o(e));
|
|
190
186
|
e = this.qyCache.getOrCreateFile(e, i).ensureLoaded();
|
|
@@ -246,7 +242,7 @@ class Q extends D {
|
|
|
246
242
|
syncList: l
|
|
247
243
|
} = this, c = i.length;
|
|
248
244
|
if (0 == c) return n.decreaseChangeId(), 0;
|
|
249
|
-
var h =
|
|
245
|
+
var h = f(c), o = o.takeCmdArgAsListObj();
|
|
250
246
|
let d;
|
|
251
247
|
0 < r && (r = i.map(({
|
|
252
248
|
logStr: e
|
|
@@ -269,7 +265,7 @@ ${r}
|
|
|
269
265
|
for ({
|
|
270
266
|
item: m,
|
|
271
267
|
delta: u
|
|
272
|
-
} of h) for (var
|
|
268
|
+
} of h) for (var g of m.triggerNodes) g.checkTrigger(m, u);
|
|
273
269
|
return e ? c : t;
|
|
274
270
|
}
|
|
275
271
|
getTopHistoryCmdObj() {
|
|
@@ -325,18 +321,18 @@ ${r}
|
|
|
325
321
|
var e, {
|
|
326
322
|
item: t,
|
|
327
323
|
indexPropPathList: i
|
|
328
|
-
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(
|
|
324
|
+
} = t, r = this.qyCache.getOrCreateIndexDir(t), n = r.getOrCreateFile(O), {
|
|
329
325
|
fileContent: a,
|
|
330
326
|
qyIndexPropTree: o
|
|
331
327
|
} = (n.created || this._action_createFile({
|
|
332
328
|
item: n
|
|
333
329
|
}), n), s = [], l = {};
|
|
334
330
|
for (e of i) {
|
|
335
|
-
var c =
|
|
331
|
+
var c = _(e);
|
|
336
332
|
a && a[c] || (s.push(e), l[c] = 1, o.insert(e));
|
|
337
333
|
}
|
|
338
334
|
if (0 != s.length) {
|
|
339
|
-
|
|
335
|
+
D.log(`Creating index ${JSON.stringify(s)} for ` + t.fullPath), this._action_insert({
|
|
340
336
|
item: n,
|
|
341
337
|
content: l
|
|
342
338
|
});
|
|
@@ -344,17 +340,17 @@ ${r}
|
|
|
344
340
|
var h, d = this, m = t, u = r, i = x(s);
|
|
345
341
|
let e;
|
|
346
342
|
for (h of i) {
|
|
347
|
-
var
|
|
348
|
-
if (!
|
|
343
|
+
var g = u.searchOrCreateSubdir(h);
|
|
344
|
+
if (!g.created) {
|
|
349
345
|
d._action_createDir({
|
|
350
|
-
item:
|
|
346
|
+
item: g
|
|
351
347
|
});
|
|
352
|
-
for (var
|
|
348
|
+
for (var f of e = e || m.fileList) {
|
|
353
349
|
var {
|
|
354
|
-
fileContent:
|
|
350
|
+
fileContent: f,
|
|
355
351
|
name: C
|
|
356
|
-
} =
|
|
357
|
-
null !=
|
|
352
|
+
} = f;
|
|
353
|
+
null != f && E(d, g, h, C, void 0, f);
|
|
358
354
|
}
|
|
359
355
|
}
|
|
360
356
|
}
|
|
@@ -367,10 +363,10 @@ ${r}
|
|
|
367
363
|
item: e,
|
|
368
364
|
indexPropPath: r
|
|
369
365
|
} = e, e = this.qyCache.getIndexDir(e);
|
|
370
|
-
e && ((i = e.getFile(
|
|
366
|
+
e && ((i = e.getFile(O)) ? (t = i.qyIndexPropTree, this._action_insert({
|
|
371
367
|
item: i,
|
|
372
368
|
content: {
|
|
373
|
-
[
|
|
369
|
+
[_(r)]: F
|
|
374
370
|
}
|
|
375
371
|
}), t.remove(r).hasPrefix || (i = e.getSubdir(r)) && this._action_delDir({
|
|
376
372
|
item: i
|
|
@@ -389,7 +385,7 @@ ${r}
|
|
|
389
385
|
parentDir: r,
|
|
390
386
|
name: n
|
|
391
387
|
} = i;
|
|
392
|
-
return i.created = !1, N(this, e), t || I(this, r,
|
|
388
|
+
return i.created = !1, N(this, e), t || I(this, r, C.R, r.fileMapKey, n),
|
|
393
389
|
!0;
|
|
394
390
|
}
|
|
395
391
|
_action_delDir(e) {
|
|
@@ -405,13 +401,13 @@ ${r}
|
|
|
405
401
|
fileMapKey: s
|
|
406
402
|
} = t;
|
|
407
403
|
if (a) {
|
|
408
|
-
I(this, t,
|
|
404
|
+
I(this, t, C.D, s);
|
|
409
405
|
for (var l of t.fileList) this._action_delFile({
|
|
410
406
|
item: l
|
|
411
407
|
}, !0);
|
|
412
408
|
}
|
|
413
409
|
if (n) {
|
|
414
|
-
I(this, t,
|
|
410
|
+
I(this, t, C.D, o);
|
|
415
411
|
for (var c of t.allSubdirs()) {
|
|
416
412
|
let {
|
|
417
413
|
subdirMap: e,
|
|
@@ -419,8 +415,8 @@ ${r}
|
|
|
419
415
|
subdirMapKey: i,
|
|
420
416
|
fileMapKey: r
|
|
421
417
|
} = c;
|
|
422
|
-
if (e && I(this, c,
|
|
423
|
-
I(this, c,
|
|
418
|
+
if (e && I(this, c, C.D, i), t) {
|
|
419
|
+
I(this, c, C.D, r);
|
|
424
420
|
for (var h of c.fileList) this._action_delFile({
|
|
425
421
|
item: h
|
|
426
422
|
}, !0);
|
|
@@ -431,7 +427,7 @@ ${r}
|
|
|
431
427
|
}), c.created = !1;
|
|
432
428
|
}
|
|
433
429
|
}
|
|
434
|
-
return !!i && (t.created = !1, N(this, e), I(this, i,
|
|
430
|
+
return !!i && (t.created = !1, N(this, e), I(this, i, C.R, i.subdirMapKey, r),
|
|
435
431
|
!0);
|
|
436
432
|
}
|
|
437
433
|
_action_delContent(e) {
|
|
@@ -441,9 +437,9 @@ ${r}
|
|
|
441
437
|
content: i,
|
|
442
438
|
delta: {
|
|
443
439
|
oldValue: i,
|
|
444
|
-
newValue:
|
|
440
|
+
newValue: F
|
|
445
441
|
}
|
|
446
|
-
}), N(this, e), I(this, t,
|
|
442
|
+
}), N(this, e), I(this, t, C.D, t.fileContentKey), P(this, t, i), !0);
|
|
447
443
|
}
|
|
448
444
|
_action_insertEmbedding(e) {
|
|
449
445
|
e.actionName = "insertEmbedding";
|
|
@@ -486,18 +482,14 @@ ${r}
|
|
|
486
482
|
item: t,
|
|
487
483
|
content: i
|
|
488
484
|
} = e;
|
|
489
|
-
if (null == i) return
|
|
485
|
+
if (null == i) return D.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
490
486
|
!1;
|
|
491
487
|
t.created || this._action_createFile({
|
|
492
488
|
item: t
|
|
493
489
|
});
|
|
494
|
-
var
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
} = t;
|
|
498
|
-
return I(this, t, _.M, r, {
|
|
499
|
-
$rpl: i
|
|
500
|
-
}), N(this, e), t.fileContent = i, P(this, t, n, i, i), !0;
|
|
490
|
+
var r = t.fileContentKey;
|
|
491
|
+
return i.$rpl = 1, I(this, t, C.M, r, i), N(this, e), t.fileContent = i,
|
|
492
|
+
!0;
|
|
501
493
|
}
|
|
502
494
|
_action_insert(e) {
|
|
503
495
|
e.actionName = "insert";
|
|
@@ -506,7 +498,7 @@ ${r}
|
|
|
506
498
|
content: i,
|
|
507
499
|
noCreate: r
|
|
508
500
|
} = e;
|
|
509
|
-
if (null == i) return
|
|
501
|
+
if (null == i) return D.warn(`Saving undefined to ${t.fullPath}. Not making any change.`),
|
|
510
502
|
!1;
|
|
511
503
|
if (!t.created) {
|
|
512
504
|
if (r) return !1;
|
|
@@ -521,7 +513,7 @@ ${r}
|
|
|
521
513
|
return !!o && ({
|
|
522
514
|
oldValue: o,
|
|
523
515
|
newValue: n
|
|
524
|
-
} = o,
|
|
516
|
+
} = o, a = t.fileContentKey, null == i ? I(this, t, C.D, a) : I(this, t, C.M, a, n),
|
|
525
517
|
Object.assign(e, r), N(this, e), t.fileContent = i, P(this, t, o, n, i),
|
|
526
518
|
!0);
|
|
527
519
|
}
|
|
@@ -533,7 +525,7 @@ ${r}
|
|
|
533
525
|
}), Object.assign(i, {
|
|
534
526
|
created: !0,
|
|
535
527
|
fileContentLoaded: !0
|
|
536
|
-
}), N(this, e), I(this, t,
|
|
528
|
+
}), N(this, e), I(this, t, C.A, t.fileMapKey, i.name), !0);
|
|
537
529
|
}
|
|
538
530
|
_action_createDir(e) {
|
|
539
531
|
e.actionName = "createDir";
|
|
@@ -550,7 +542,7 @@ ${r}
|
|
|
550
542
|
item: e
|
|
551
543
|
});
|
|
552
544
|
var r = e.parentDir;
|
|
553
|
-
I(this, r,
|
|
545
|
+
I(this, r, C.A, r.subdirMapKey, e.name);
|
|
554
546
|
}
|
|
555
547
|
return !0;
|
|
556
548
|
}
|
|
@@ -583,7 +575,7 @@ ${r}
|
|
|
583
575
|
return !!r && (t = this.qyCache, !!(r = t.getExpireInfoFile(r.fullPathHash, e.isFile ? "f" : "d"))) && ((n = this._action_insert({
|
|
584
576
|
item: r,
|
|
585
577
|
content: {
|
|
586
|
-
[n]:
|
|
578
|
+
[n]: F
|
|
587
579
|
}
|
|
588
580
|
})) && (m(r.fileContent) && this._action_delFile({
|
|
589
581
|
item: r
|
|
@@ -611,7 +603,7 @@ ${r}
|
|
|
611
603
|
expireInfoObj: i,
|
|
612
604
|
infoFileOnly: r
|
|
613
605
|
} = e, n = this.qyCache, a = n.getExpireInfoFile(e.fullPathHash, "c");
|
|
614
|
-
return !!a && (i =
|
|
606
|
+
return !!a && (i = u(i) ? Object.fromEntries(i.map(e => [ e, F ])) : j(i, e => e ? F : void 0),
|
|
615
607
|
(t = this._action_insert({
|
|
616
608
|
item: a,
|
|
617
609
|
content: i
|
|
@@ -670,14 +662,14 @@ function P(e, t, i, r = void 0, n = void 0) {
|
|
|
670
662
|
if (!t) {
|
|
671
663
|
var s = e.qyCache.getIndexDir(o);
|
|
672
664
|
if (s) {
|
|
673
|
-
t = s.getFile(
|
|
665
|
+
t = s.getFile(O);
|
|
674
666
|
if (t) for (var l of t.qyIndexPropTree.getAllIndexPropPaths()) E(e, s.searchOrCreateSubdir(l), l, a, i, r, n);
|
|
675
667
|
}
|
|
676
668
|
}
|
|
677
669
|
}
|
|
678
670
|
|
|
679
671
|
function E(t, e, i, r, n, a, o = void 0) {
|
|
680
|
-
e =
|
|
672
|
+
e = p(e, i, n, a, o);
|
|
681
673
|
if (e) {
|
|
682
674
|
var s, l, c, {
|
|
683
675
|
toAddFileList: i,
|
|
@@ -685,14 +677,14 @@ function E(t, e, i, r, n, a, o = void 0) {
|
|
|
685
677
|
} = e;
|
|
686
678
|
for (s of i) {
|
|
687
679
|
var h = s.fileContent ?? {};
|
|
688
|
-
h[r] = 1, t.
|
|
680
|
+
h[r] = 1, t._action_insert({
|
|
689
681
|
item: s,
|
|
690
682
|
content: h
|
|
691
683
|
});
|
|
692
684
|
}
|
|
693
685
|
for (l of n) {
|
|
694
686
|
var d = l.fileContent;
|
|
695
|
-
null != d && Object.hasOwn(d, r) && (delete d[r], t.
|
|
687
|
+
null != d && Object.hasOwn(d, r) && (delete d[r], t._action_insert({
|
|
696
688
|
item: l,
|
|
697
689
|
content: d
|
|
698
690
|
}));
|
|
@@ -709,7 +701,7 @@ function E(t, e, i, r, n, a, o = void 0) {
|
|
|
709
701
|
}
|
|
710
702
|
}
|
|
711
703
|
|
|
712
|
-
class
|
|
704
|
+
class Q {
|
|
713
705
|
maxLength;
|
|
714
706
|
actionQueue;
|
|
715
707
|
nextPos;
|
|
@@ -749,7 +741,7 @@ function j(e, t = void 0, i = [], r = {}) {
|
|
|
749
741
|
}
|
|
750
742
|
|
|
751
743
|
function S(e, t, i) {
|
|
752
|
-
return
|
|
744
|
+
return r(e) ? (t ? e : 1e3 * e) + i : l(e) ? (t = new Date(e).getTime(), isNaN(t) || t <= i ? void 0 : t) : !a(e) || (t = e.getTime()) <= i ? void 0 : t;
|
|
753
745
|
}
|
|
754
746
|
|
|
755
747
|
function T(e, t, i, r, n) {
|
|
@@ -769,5 +761,5 @@ function M(e, t, i, r, n) {
|
|
|
769
761
|
}
|
|
770
762
|
|
|
771
763
|
export {
|
|
772
|
-
|
|
764
|
+
L as QyBatch
|
|
773
765
|
};
|
package/src/QyDB.js
CHANGED
|
@@ -47,7 +47,7 @@ class l extends t {
|
|
|
47
47
|
...o("QyDB"),
|
|
48
48
|
...t
|
|
49
49
|
}, this.rootFolder = e;
|
|
50
|
-
for (let t of [ "createIndex", "delIndex", "insert", "put", "
|
|
50
|
+
for (let t of [ "createIndex", "delIndex", "insert", "put", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "insertEmbedding", "delEmbedding", "insertWithEmbedding", "expireFile", "expireDir", "expireContent", "expireFileM", "expireDirM", "expireContentM", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[t] = (...e) => this.currentBatch[t](...e).run();
|
|
51
51
|
}
|
|
52
52
|
async start(e) {
|
|
53
53
|
var t;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function mergeContent(oldContent: any, newContent: any): any;
|
|
2
1
|
export declare function mergeContentAndGenDelta(oldContent: any, newContent: any): {
|
|
3
2
|
merged: any;
|
|
4
3
|
delta: any;
|
|
@@ -6,5 +5,4 @@ export declare function mergeContentAndGenDelta(oldContent: any, newContent: any
|
|
|
6
5
|
export declare function setValByNamePath(rootObj: any, namePath: any, value: any): any;
|
|
7
6
|
export declare function getValByNamePath(obj: any, namePath: any): any;
|
|
8
7
|
export declare function delValByNamePath(obj: any, propPath: any, keepEmptyObj?: boolean, idx?: number): any;
|
|
9
|
-
export declare function cleanContent(obj: any
|
|
10
|
-
export declare function objToDelMarks(obj: any): any;
|
|
8
|
+
export declare function cleanContent(obj: any): any;
|
|
@@ -1,195 +1,145 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isDeepStrictEqual as
|
|
2
|
+
isDeepStrictEqual as u
|
|
3
3
|
} from "node:util";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
isDate as
|
|
7
|
-
isArray as
|
|
8
|
-
isNotNullObj as
|
|
9
|
-
trimArrayTail as
|
|
10
|
-
isSimpleType as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
isUint8Array as u,
|
|
6
|
+
isDate as n,
|
|
7
|
+
isArray as V,
|
|
8
|
+
isNotNullObj as i,
|
|
9
|
+
trimArrayTail as a,
|
|
10
|
+
isSimpleType as m,
|
|
11
|
+
isEmptyObj as o,
|
|
12
|
+
isUint8Array as f,
|
|
14
13
|
isNumber as c
|
|
15
14
|
} from "./QyUtils.js";
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (e != n) {
|
|
38
|
-
var t, u = d(e);
|
|
39
|
-
for (t in n) {
|
|
40
|
-
var i = h(e[t], n[t]);
|
|
41
|
-
null == i ? (delete e[t], u && o(e)) : e[t] = i;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function e(r, e) {
|
|
49
|
-
let n = {
|
|
16
|
+
function l(l, e) {
|
|
17
|
+
let r = e, n;
|
|
18
|
+
var t;
|
|
19
|
+
return void 0 === e ? r = l : null === e ? (r = void 0, null != l && (n = {
|
|
20
|
+
oldValue: l,
|
|
21
|
+
newValue: null
|
|
22
|
+
})) : f(e) ? f(l) && u(l, e) || (n = {
|
|
23
|
+
newValue: {
|
|
24
|
+
$u8: Array.from(e)
|
|
25
|
+
},
|
|
26
|
+
oldValue: l
|
|
27
|
+
}) : null == l ? n = {
|
|
28
|
+
newValue: e
|
|
29
|
+
} : m(e) || m(l) ? e !== l && (n = {
|
|
30
|
+
oldValue: l,
|
|
31
|
+
newValue: e
|
|
32
|
+
}) : e.$rpl ? n = {
|
|
33
|
+
oldValue: l,
|
|
34
|
+
newValue: e
|
|
35
|
+
} : (t = {}, n = {
|
|
50
36
|
oldValue: {},
|
|
51
|
-
newValue:
|
|
52
|
-
}
|
|
53
|
-
r = $(r, e, [], 0, n);
|
|
54
|
-
return n.oldValue = A(n.oldValue, !0), n.newValue = A(n.newValue, !1), {
|
|
37
|
+
newValue: t
|
|
38
|
+
}, r = $(l, e, n), o(t) && (n = void 0)), {
|
|
55
39
|
merged: r,
|
|
56
|
-
delta: n
|
|
40
|
+
delta: n
|
|
57
41
|
};
|
|
58
42
|
}
|
|
59
43
|
|
|
60
|
-
function
|
|
61
|
-
if (!e || 0 == e.length) return
|
|
62
|
-
let
|
|
63
|
-
for (let
|
|
64
|
-
var t = e[
|
|
65
|
-
|
|
44
|
+
function t(l, e, r) {
|
|
45
|
+
if (!e || 0 == e.length) return r;
|
|
46
|
+
let n = l;
|
|
47
|
+
for (let l = 0; l < e.length - 1; ++l) {
|
|
48
|
+
var t = e[l];
|
|
49
|
+
i(n[t]) || (n[t] = {}), n = n[t];
|
|
66
50
|
}
|
|
67
51
|
var u = e.at(-1);
|
|
68
|
-
return void 0 ===
|
|
52
|
+
return void 0 === r ? delete n[u] : n[u] = r, l;
|
|
69
53
|
}
|
|
70
54
|
|
|
71
|
-
function
|
|
72
|
-
if (null != e && null !=
|
|
73
|
-
if (!
|
|
74
|
-
if (0 != e.length && (1 != e.length || "" != e[0])) for (var
|
|
75
|
-
return
|
|
55
|
+
function e(l, e) {
|
|
56
|
+
if (null != e && null != l) {
|
|
57
|
+
if (!V(e)) return "" == e ? l : l[e];
|
|
58
|
+
if (0 != e.length && (1 != e.length || "" != e[0])) for (var r of e) if (null == (l = l[r])) return;
|
|
59
|
+
return l;
|
|
76
60
|
}
|
|
77
61
|
}
|
|
78
62
|
|
|
79
|
-
function
|
|
80
|
-
var t = e[
|
|
81
|
-
if (
|
|
82
|
-
var u =
|
|
83
|
-
if (
|
|
84
|
-
u =
|
|
85
|
-
if (null == u && !
|
|
86
|
-
|
|
63
|
+
function v(l, e, r = !1, n = 0) {
|
|
64
|
+
var t = e[n];
|
|
65
|
+
if (n == e.length - 1) return delete l[t], !r && o(l) ? void 0 : l;
|
|
66
|
+
var u = l[t];
|
|
67
|
+
if (i(u)) {
|
|
68
|
+
u = v(u, e, r, n + 1);
|
|
69
|
+
if (null == u && !r) return delete l[t], o(l) ? void 0 : l;
|
|
70
|
+
l[t] = u;
|
|
87
71
|
}
|
|
88
|
-
return
|
|
72
|
+
return l;
|
|
89
73
|
}
|
|
90
74
|
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (null != r) return l(r, u);
|
|
98
|
-
let e = t[V];
|
|
99
|
-
if (null != e) return l(d(e) ? e : [ e ], u);
|
|
100
|
-
let n = t[m];
|
|
101
|
-
if (null != n) return;
|
|
75
|
+
function d(l) {
|
|
76
|
+
if (null != l) {
|
|
77
|
+
if (m(l)) return n(l) ? l.toISOString() : l;
|
|
78
|
+
for (var e in l) {
|
|
79
|
+
var r = d(l[e]);
|
|
80
|
+
null == r ? delete l[e] : l[e] = r;
|
|
102
81
|
}
|
|
103
|
-
|
|
104
|
-
let n = !0;
|
|
105
|
-
for (var i in t) {
|
|
106
|
-
let r = l(t[i], u);
|
|
107
|
-
void 0 === r ? (delete t[i], e && o(t)) : (t[i] = r, n = !1);
|
|
108
|
-
}
|
|
109
|
-
return n ? void 0 : t;
|
|
110
|
-
}(r, e);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function l(r) {
|
|
114
|
-
if (s(r)) return r ? g : void 0;
|
|
115
|
-
for (var e in r) {
|
|
116
|
-
var n = l(r[e]);
|
|
117
|
-
n ? r[e] = n : delete r[e];
|
|
82
|
+
return V(l) ? a(l) : l.$rpl && delete l.$rpl, l;
|
|
118
83
|
}
|
|
119
|
-
return d(r) && o(r), r;
|
|
120
84
|
}
|
|
121
85
|
|
|
122
|
-
function
|
|
123
|
-
if (
|
|
124
|
-
var
|
|
125
|
-
for (
|
|
126
|
-
n
|
|
127
|
-
var
|
|
128
|
-
|
|
86
|
+
function $(l, e, r, n = []) {
|
|
87
|
+
if (l !== e) {
|
|
88
|
+
var t, u = n.length;
|
|
89
|
+
for (t in e) {
|
|
90
|
+
n.length = u + 1;
|
|
91
|
+
var i = ((l, e, r, n) => {
|
|
92
|
+
if (void 0 === e) return l;
|
|
93
|
+
if (null !== e) {
|
|
94
|
+
if (null == l || m(l) || m(e)) return l !== e && w(r, n, l, e),
|
|
95
|
+
e;
|
|
96
|
+
if (e.$rpl) return w(r, n, l, e), e;
|
|
97
|
+
if (i = e.$extend, null != i) {
|
|
98
|
+
var t = l, u = i, i = r, a = n;
|
|
99
|
+
if (V(t)) {
|
|
100
|
+
V(u) || (u = [ u ]);
|
|
101
|
+
var o = t.length, f = {};
|
|
102
|
+
for (let l = 0; l < u.length; ++l) {
|
|
103
|
+
var v = u[l];
|
|
104
|
+
null != v && (f[l + o] = v);
|
|
105
|
+
}
|
|
106
|
+
w(i, a, {}, f), t.push(...u);
|
|
107
|
+
}
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
if (i = e.$pop, null == i) return (a = V(l)) == V(e) ? $(l, e, r, n) : (w(r, n, l, e),
|
|
111
|
+
a && (e.$rpl = 1), e);
|
|
112
|
+
var d = l, t = r, e = n;
|
|
113
|
+
if ((i = i) && V(d)) {
|
|
114
|
+
var s = d.length;
|
|
115
|
+
if (0 < s) {
|
|
116
|
+
var p = {}, g = {}, i = c(i) ? Math.min(i, s) : 1;
|
|
117
|
+
for (let l = s - i; l < s; ++l) {
|
|
118
|
+
var h = d[l];
|
|
119
|
+
null != h && (p[l] = h, g[l] = null);
|
|
120
|
+
}
|
|
121
|
+
w(t, e, p, g), d.length -= i;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return d;
|
|
125
|
+
}
|
|
126
|
+
void 0 !== l && w(r, n, l, null);
|
|
127
|
+
})(l[n[u] = t], e[t], r, n);
|
|
128
|
+
null == i ? delete l[t] : l[t] = i;
|
|
129
129
|
}
|
|
130
|
+
V(l) && a(l);
|
|
130
131
|
}
|
|
131
|
-
return
|
|
132
|
+
return l;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
if (n !== g && null !== n) {
|
|
137
|
-
if (null == e || s(e) || s(n)) return O(e, n, l, u);
|
|
138
|
-
var i = n[p];
|
|
139
|
-
if (null != i) return O(e, i, l, u);
|
|
140
|
-
let r = n[V];
|
|
141
|
-
if (null != r) return d(r) || (r = [ r ]), (d(e) ? (e, n, r, l) => {
|
|
142
|
-
n = A(n);
|
|
143
|
-
var t = {};
|
|
144
|
-
for (let r = 0; r < n.length; ++r) {
|
|
145
|
-
var u = n[r];
|
|
146
|
-
null != u && (t[r + e.length] = s(u) ? u : {
|
|
147
|
-
[p]: u
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
return U(l, r, e, t), e.concat(n);
|
|
151
|
-
} : O)(e, r, l, u);
|
|
152
|
-
i = n[m];
|
|
153
|
-
if (null == i) return d(e) && !d(n) || !d(e) && d(n) ? O(e, n, l, u) : S(e, n, l, t, u);
|
|
154
|
-
var n = e, f = l, a = u;
|
|
155
|
-
if (!i || !d(n)) return n;
|
|
156
|
-
var o = n.length, v = [];
|
|
157
|
-
for (let r = c(i) ? i <= o ? i : o : 1; 0 < r; --r) v[o - r] = g;
|
|
158
|
-
return S(n, v, f, t, a);
|
|
159
|
-
}
|
|
160
|
-
null != e && U(u, l, e, g);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function O(r, e, n, l) {
|
|
164
|
-
e = A(e);
|
|
165
|
-
return r === e || u(r) && u(e) && t(r, e) ? r : null != e ? (null == r ? U(l, n, 0 == n.length ? void 0 : null, u(e) ? {
|
|
166
|
-
[v]: Array.from(e)
|
|
167
|
-
} : s(e) ? e : {
|
|
168
|
-
[p]: e
|
|
169
|
-
}) : U(l, n, r, u(e) ? {
|
|
170
|
-
[v]: Array.from(e)
|
|
171
|
-
} : s(r) ? e : {
|
|
172
|
-
[p]: e
|
|
173
|
-
}), e) : void U(l, n, r, g);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function U(r, e, n, l) {
|
|
177
|
-
r.oldValue = y(r.oldValue, e, n), r.newValue = y(r.newValue, e, l);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function b(r) {
|
|
181
|
-
if (null != r && r != g) {
|
|
182
|
-
for (;null != r[p]; ) if ((r = r[p]) == g) return;
|
|
183
|
-
return r;
|
|
184
|
-
}
|
|
135
|
+
function w(l, e, r, n) {
|
|
136
|
+
t(l.oldValue, e, r), t(l.newValue, e, n);
|
|
185
137
|
}
|
|
186
138
|
|
|
187
139
|
export {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
A as cleanContent,
|
|
194
|
-
l as objToDelMarks
|
|
140
|
+
l as mergeContentAndGenDelta,
|
|
141
|
+
t as setValByNamePath,
|
|
142
|
+
e as getValByNamePath,
|
|
143
|
+
v as delValByNamePath,
|
|
144
|
+
d as cleanContent
|
|
195
145
|
};
|
package/src/QySnapshots.js
CHANGED
package/src/QyUtils.js
CHANGED