@vope/utils 1.6.0-bate.2 → 1.6.0-bate.3
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/dist/clamp.d.ts +4 -0
- package/dist/clamp.mjs +11 -0
- package/dist/classnames.d.ts +7 -0
- package/dist/classnames.mjs +17 -0
- package/dist/compare/version.d.ts +5 -0
- package/dist/compare/version.mjs +15 -0
- package/dist/compare/weak-equal.d.ts +4 -0
- package/dist/compare/weak-equal.mjs +33 -0
- package/dist/convert/json.d.ts +12 -0
- package/dist/convert/json.mjs +7 -0
- package/dist/convert/object.d.ts +12 -0
- package/dist/convert/object.mjs +7 -0
- package/dist/convert/strings.d.ts +6 -0
- package/dist/convert/strings.mjs +7 -0
- package/dist/desens.d.ts +40 -0
- package/dist/desens.mjs +51 -0
- package/dist/encoding.d.ts +9 -0
- package/dist/encoding.mjs +56 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1361 -0
- package/dist/index.mjs +73 -0
- package/dist/input-regex.d.ts +12 -0
- package/dist/input-regex.mjs +8 -0
- package/dist/is/class.d.ts +4 -0
- package/dist/is/class.mjs +22 -0
- package/dist/is/empty.d.ts +4 -0
- package/dist/is/empty.mjs +5 -0
- package/dist/is/key.d.ts +4 -0
- package/dist/is/key.mjs +4 -0
- package/dist/is/null.d.ts +4 -0
- package/dist/is/null.mjs +4 -0
- package/dist/load/image.d.ts +5 -0
- package/dist/load/image.mjs +11 -0
- package/dist/memory/basic.d.ts +79 -0
- package/dist/memory/basic.mjs +167 -0
- package/dist/memory/list.d.ts +8 -0
- package/dist/memory/list.mjs +12 -0
- package/dist/memory/power.d.ts +8 -0
- package/dist/memory/power.mjs +13 -0
- package/dist/memory/simple.d.ts +60 -0
- package/dist/memory/simple.mjs +94 -0
- package/dist/neo4j-anchors.d.ts +50 -0
- package/dist/neo4j-anchors.mjs +169 -0
- package/dist/neo4j.d.ts +82 -0
- package/dist/neo4j.mjs +161 -0
- package/dist/once.d.ts +6 -0
- package/dist/once.mjs +8 -0
- package/dist/parse/num.d.ts +8 -0
- package/dist/parse/num.mjs +31 -0
- package/dist/power/decon.d.ts +9 -0
- package/dist/power/decon.mjs +22 -0
- package/dist/rotate/angle.d.ts +8 -0
- package/dist/rotate/angle.mjs +5 -0
- package/dist/rotate/rad.d.ts +8 -0
- package/dist/rotate/rad.mjs +11 -0
- package/dist/serialize/url-params.d.ts +43 -0
- package/dist/serialize/url-params.mjs +53 -0
- package/dist/storage/offline.d.ts +51 -0
- package/dist/style/css.d.ts +9 -0
- package/dist/style/css.mjs +25 -0
- package/dist/subscriber.d.ts +11 -0
- package/dist/subscriber.mjs +64 -0
- package/dist/table/flex.d.ts +43 -0
- package/dist/table/flex.mjs +96 -0
- package/dist/union.d.ts +34 -0
- package/dist/union.mjs +47 -0
- package/dist/url/join.d.ts +4 -0
- package/dist/url/join.mjs +9 -0
- package/dist/url/params.d.ts +8 -0
- package/dist/url/params.mjs +8 -0
- package/dist/wait.d.ts +4 -0
- package/dist/wait.mjs +4 -0
- package/package.json +3 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FlexTable: () => FlexTable,
|
|
24
|
+
MemoryBasic: () => MemoryBasic,
|
|
25
|
+
MemoryList: () => MemoryList,
|
|
26
|
+
MemoryPower: () => MemoryPower,
|
|
27
|
+
MemorySimple: () => MemorySimple,
|
|
28
|
+
Neo4j: () => Neo4j,
|
|
29
|
+
Neo4jAhchors: () => Neo4jAhchors,
|
|
30
|
+
Subscriber: () => Subscriber,
|
|
31
|
+
Union: () => Union,
|
|
32
|
+
clamp: () => clamp,
|
|
33
|
+
classnames: () => classnames,
|
|
34
|
+
compareVersion: () => compareVersion,
|
|
35
|
+
connectURLParams: () => connectURLParams,
|
|
36
|
+
css: () => css,
|
|
37
|
+
cubeURLParams: () => cubeURLParams,
|
|
38
|
+
deconPowersSum: () => deconPowersSum,
|
|
39
|
+
deepWeakEqual: () => deepWeakEqual,
|
|
40
|
+
desensDecrypt: () => desensDecrypt,
|
|
41
|
+
desensEncrypt: () => desensEncrypt,
|
|
42
|
+
desensReplace: () => desensReplace,
|
|
43
|
+
flatURLParams: () => flatURLParams,
|
|
44
|
+
getEncoding: () => getEncoding,
|
|
45
|
+
hash8json: () => hash8json,
|
|
46
|
+
hash8object: () => hash8object,
|
|
47
|
+
hash8strings: () => hash8strings,
|
|
48
|
+
inputRegex: () => inputRegex,
|
|
49
|
+
isClass: () => isClass,
|
|
50
|
+
isEmpty: () => isEmpty,
|
|
51
|
+
isKey: () => isKey,
|
|
52
|
+
isNull: () => isNull,
|
|
53
|
+
joinPaths: () => joinPaths,
|
|
54
|
+
loadImage: () => loadImage,
|
|
55
|
+
once: () => once,
|
|
56
|
+
parseNum: () => parseNum,
|
|
57
|
+
rotateAngle: () => rotateAngle,
|
|
58
|
+
rotateRad: () => rotateRad,
|
|
59
|
+
wait: () => wait
|
|
60
|
+
});
|
|
61
|
+
module.exports = __toCommonJS(index_exports);
|
|
62
|
+
|
|
63
|
+
// src/clamp.ts
|
|
64
|
+
var clamp = (value, min, max) => {
|
|
65
|
+
if (min > max) {
|
|
66
|
+
const swap = max;
|
|
67
|
+
max = min;
|
|
68
|
+
min = swap;
|
|
69
|
+
}
|
|
70
|
+
return Math.min(max, Math.max(min, value));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
|
|
74
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
75
|
+
var freeGlobal_default = freeGlobal;
|
|
76
|
+
|
|
77
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js
|
|
78
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
79
|
+
var root = freeGlobal_default || freeSelf || Function("return this")();
|
|
80
|
+
var root_default = root;
|
|
81
|
+
|
|
82
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
|
|
83
|
+
var Symbol2 = root_default.Symbol;
|
|
84
|
+
var Symbol_default = Symbol2;
|
|
85
|
+
|
|
86
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
|
|
87
|
+
var objectProto = Object.prototype;
|
|
88
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
89
|
+
var nativeObjectToString = objectProto.toString;
|
|
90
|
+
var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
91
|
+
function getRawTag(value) {
|
|
92
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
93
|
+
try {
|
|
94
|
+
value[symToStringTag] = void 0;
|
|
95
|
+
var unmasked = true;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
}
|
|
98
|
+
var result = nativeObjectToString.call(value);
|
|
99
|
+
if (unmasked) {
|
|
100
|
+
if (isOwn) {
|
|
101
|
+
value[symToStringTag] = tag;
|
|
102
|
+
} else {
|
|
103
|
+
delete value[symToStringTag];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
var getRawTag_default = getRawTag;
|
|
109
|
+
|
|
110
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js
|
|
111
|
+
var objectProto2 = Object.prototype;
|
|
112
|
+
var nativeObjectToString2 = objectProto2.toString;
|
|
113
|
+
function objectToString(value) {
|
|
114
|
+
return nativeObjectToString2.call(value);
|
|
115
|
+
}
|
|
116
|
+
var objectToString_default = objectToString;
|
|
117
|
+
|
|
118
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
|
|
119
|
+
var nullTag = "[object Null]";
|
|
120
|
+
var undefinedTag = "[object Undefined]";
|
|
121
|
+
var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
|
|
122
|
+
function baseGetTag(value) {
|
|
123
|
+
if (value == null) {
|
|
124
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
125
|
+
}
|
|
126
|
+
return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
|
|
127
|
+
}
|
|
128
|
+
var baseGetTag_default = baseGetTag;
|
|
129
|
+
|
|
130
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js
|
|
131
|
+
function isObjectLike(value) {
|
|
132
|
+
return value != null && typeof value == "object";
|
|
133
|
+
}
|
|
134
|
+
var isObjectLike_default = isObjectLike;
|
|
135
|
+
|
|
136
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArray.js
|
|
137
|
+
var isArray = Array.isArray;
|
|
138
|
+
var isArray_default = isArray;
|
|
139
|
+
|
|
140
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
|
|
141
|
+
var stringTag = "[object String]";
|
|
142
|
+
function isString(value) {
|
|
143
|
+
return typeof value == "string" || !isArray_default(value) && isObjectLike_default(value) && baseGetTag_default(value) == stringTag;
|
|
144
|
+
}
|
|
145
|
+
var isString_default = isString;
|
|
146
|
+
|
|
147
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isBoolean.js
|
|
148
|
+
var boolTag = "[object Boolean]";
|
|
149
|
+
function isBoolean(value) {
|
|
150
|
+
return value === true || value === false || isObjectLike_default(value) && baseGetTag_default(value) == boolTag;
|
|
151
|
+
}
|
|
152
|
+
var isBoolean_default = isBoolean;
|
|
153
|
+
|
|
154
|
+
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNumber.js
|
|
155
|
+
var numberTag = "[object Number]";
|
|
156
|
+
function isNumber(value) {
|
|
157
|
+
return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag;
|
|
158
|
+
}
|
|
159
|
+
var isNumber_default = isNumber;
|
|
160
|
+
|
|
161
|
+
// src/classnames.ts
|
|
162
|
+
var add = (a, b) => a ? a + " " + b : b;
|
|
163
|
+
var classnames = (...list) => list.reduce((caches, data) => {
|
|
164
|
+
if (isString_default(data)) {
|
|
165
|
+
data && (caches = add(caches, data));
|
|
166
|
+
} else if (Array.isArray(data)) {
|
|
167
|
+
data.forEach((value) => value && isString_default(value) && (caches = add(caches, value)));
|
|
168
|
+
} else if (!isBoolean_default(data)) {
|
|
169
|
+
for (const key in data) {
|
|
170
|
+
key && data[key] && (caches = add(caches, key));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return caches;
|
|
174
|
+
}, "");
|
|
175
|
+
|
|
176
|
+
// src/compare/version.ts
|
|
177
|
+
var CHAR = ".";
|
|
178
|
+
var compareVersion = (from, to) => {
|
|
179
|
+
const froms = from.split(CHAR);
|
|
180
|
+
const tos = to.split(CHAR);
|
|
181
|
+
for (let i = 0, max = Math.max(froms.length, tos.length); i < max; i++) {
|
|
182
|
+
const fromV = +froms[i] || 0;
|
|
183
|
+
const toV = +tos[i] || 0;
|
|
184
|
+
if (fromV > toV) return -1;
|
|
185
|
+
if (fromV < toV) return 1;
|
|
186
|
+
}
|
|
187
|
+
return 0;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/convert/strings.ts
|
|
191
|
+
var hash8strings = (list) => list.reduce((caches, data, index) => {
|
|
192
|
+
caches[data] = index;
|
|
193
|
+
return caches;
|
|
194
|
+
}, {});
|
|
195
|
+
|
|
196
|
+
// src/compare/weak-equal.ts
|
|
197
|
+
var deepWeakEqual = (from, to, exclude) => {
|
|
198
|
+
if (typeof from !== "object" || from === null || typeof to !== "object" || to === null) return from === to;
|
|
199
|
+
if (Array.isArray(from) && Array.isArray(to)) {
|
|
200
|
+
if (from.length !== to.length) return false;
|
|
201
|
+
return !from.some((t1, index) => {
|
|
202
|
+
if (!deepWeakEqual(t1, to[index])) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
const caches = {};
|
|
208
|
+
const excludeCaches = exclude && hash8strings(exclude);
|
|
209
|
+
for (const key in from) {
|
|
210
|
+
if (excludeCaches && key in excludeCaches) continue;
|
|
211
|
+
if (!deepWeakEqual(from[key], to[key])) {
|
|
212
|
+
return false;
|
|
213
|
+
} else {
|
|
214
|
+
caches[key] = key;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
for (const key in to) {
|
|
218
|
+
if (excludeCaches && key in excludeCaches || key in caches) continue;
|
|
219
|
+
if (!deepWeakEqual(from[key], to[key])) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/convert/json.ts
|
|
228
|
+
var hash8json = (list, key) => list.reduce((caches, data) => {
|
|
229
|
+
caches[data[key]] = data;
|
|
230
|
+
return caches;
|
|
231
|
+
}, {});
|
|
232
|
+
|
|
233
|
+
// src/convert/object.ts
|
|
234
|
+
var hash8object = (list, key) => list.reduce((caches, data) => {
|
|
235
|
+
caches.set(data[key], data);
|
|
236
|
+
return caches;
|
|
237
|
+
}, /* @__PURE__ */ new Map());
|
|
238
|
+
|
|
239
|
+
// src/desens.ts
|
|
240
|
+
var desensEncrypt = (plaintext, encrypt) => {
|
|
241
|
+
const rules = [];
|
|
242
|
+
let point = -1;
|
|
243
|
+
let ciphertext = encrypt(plaintext).reduce((cache, { range, ciphertext: ciphertext2 }) => {
|
|
244
|
+
cache += plaintext.slice(point + 1, range[0]) + ciphertext2;
|
|
245
|
+
point = range[1];
|
|
246
|
+
rules.push({
|
|
247
|
+
range,
|
|
248
|
+
modify: ciphertext2.length
|
|
249
|
+
});
|
|
250
|
+
return cache;
|
|
251
|
+
}, "");
|
|
252
|
+
if (point !== -1) {
|
|
253
|
+
ciphertext += plaintext.slice(point + 1);
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
ciphertext,
|
|
257
|
+
rules
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
var desensDecrypt = (ciphertext, rules, decrypt) => {
|
|
261
|
+
Array.isArray(rules) || (rules = [rules]);
|
|
262
|
+
let offset = 0;
|
|
263
|
+
let from = 0;
|
|
264
|
+
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
265
|
+
cache += ciphertext.slice(from, start + offset) + decrypt(ciphertext.slice(start + offset, start + offset + modify));
|
|
266
|
+
from = start + offset + modify;
|
|
267
|
+
offset += modify - (stop + 1 - start);
|
|
268
|
+
return cache;
|
|
269
|
+
}, "") + ciphertext.slice(from);
|
|
270
|
+
};
|
|
271
|
+
var desensReplace = (ciphertext, rules, replacer = "*") => {
|
|
272
|
+
Array.isArray(rules) || (rules = [rules]);
|
|
273
|
+
let offset = 0;
|
|
274
|
+
let from = 0;
|
|
275
|
+
return rules.reduce((cache, { range: [start, stop], modify }) => {
|
|
276
|
+
const part = ciphertext.slice(start + offset, start + offset + modify);
|
|
277
|
+
const size = stop + 1 - start;
|
|
278
|
+
const replaceValue = isString_default(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
|
|
279
|
+
cache += ciphertext.slice(from, start + offset) + replaceValue;
|
|
280
|
+
from = start + offset + modify;
|
|
281
|
+
offset += modify - size;
|
|
282
|
+
return cache;
|
|
283
|
+
}, "") + ciphertext.slice(from);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/encoding.ts
|
|
287
|
+
var utf8_first_prefix = /^1{2,}/g;
|
|
288
|
+
var utf8_other_prefix = /^10/;
|
|
289
|
+
var Encodes = {
|
|
290
|
+
UTF_8: "utf-8",
|
|
291
|
+
UTF_16LE: "utf-16le",
|
|
292
|
+
UTF_16BE: "utf-16be",
|
|
293
|
+
GBK: "gbk"
|
|
294
|
+
};
|
|
295
|
+
var BOM = {
|
|
296
|
+
UTF_8: [239, 187, 191],
|
|
297
|
+
UTF_16LE: [255, 254],
|
|
298
|
+
UTF_16BE: [254, 255]
|
|
299
|
+
};
|
|
300
|
+
var equal = (uint, list) => {
|
|
301
|
+
return uint.length === list.length ? !uint.some((value, index) => value !== list[index]) : false;
|
|
302
|
+
};
|
|
303
|
+
var getEncoding = (uint, limit = 1024) => {
|
|
304
|
+
let encoding;
|
|
305
|
+
let offset = 0;
|
|
306
|
+
for (const key in BOM) {
|
|
307
|
+
const head = BOM[key];
|
|
308
|
+
if (equal(uint.slice(0, head.length), head)) {
|
|
309
|
+
offset = head.length;
|
|
310
|
+
encoding = Encodes[key];
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (!encoding) {
|
|
315
|
+
let isBreak = false;
|
|
316
|
+
top:
|
|
317
|
+
for (let i = 0, max = Math.min(uint.length, limit); i < max; i++) {
|
|
318
|
+
const data = uint[i];
|
|
319
|
+
if (data < 128) continue;
|
|
320
|
+
const match = data.toString(2).match(utf8_first_prefix);
|
|
321
|
+
if (match) {
|
|
322
|
+
for (let m = 0; m < match[0].length - 1; m++) {
|
|
323
|
+
const target = uint[++i];
|
|
324
|
+
if (target == void 0 || !utf8_other_prefix.test(target.toString(2))) {
|
|
325
|
+
encoding = Encodes.GBK;
|
|
326
|
+
isBreak = true;
|
|
327
|
+
break top;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
encoding = Encodes.GBK;
|
|
332
|
+
isBreak = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
isBreak || (encoding = Encodes.UTF_8);
|
|
337
|
+
}
|
|
338
|
+
return { encoding, offset };
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/input-regex.ts
|
|
342
|
+
var RE_REGEX = /[$()*+.[?\\^{|]/g;
|
|
343
|
+
var RE_STRING = /[$()*+.[?\\^{|-]/g;
|
|
344
|
+
function inputRegex(text, flags) {
|
|
345
|
+
return flags === false ? text.replace(RE_STRING, ($0) => "\\" + $0) : new RegExp(text.replace(RE_REGEX, ($0) => "\\" + $0), flags);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/is/class.ts
|
|
349
|
+
var re_anonymous = /^function\s+\(|^function\s+anonymous\(/;
|
|
350
|
+
var re_function = /^function\s+[A-Z]/;
|
|
351
|
+
var re_this = /\b\(this\b|\bthis[\.\[]\b/;
|
|
352
|
+
var re_check = /classCallCheck\(this/;
|
|
353
|
+
var re_default = /^function\sdefault_\d+\s*\(/;
|
|
354
|
+
var isClass = (value, strict = true) => {
|
|
355
|
+
if (typeof value !== "function") return false;
|
|
356
|
+
const proto = value.prototype;
|
|
357
|
+
if (!proto || proto.constructor !== value) return false;
|
|
358
|
+
const str = value.toString();
|
|
359
|
+
if (str.slice(0, 5) === "class" || Object.getOwnPropertyNames(proto).length >= 2) return true;
|
|
360
|
+
if (re_anonymous.test(str)) return false;
|
|
361
|
+
if (strict && re_function.test(str)) return true;
|
|
362
|
+
if (re_this.test(str)) {
|
|
363
|
+
if (!strict || re_check.test(str)) return true;
|
|
364
|
+
return re_default.test(str);
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// src/is/null.ts
|
|
370
|
+
var isNull = (value) => value === void 0 || value === null;
|
|
371
|
+
|
|
372
|
+
// src/is/empty.ts
|
|
373
|
+
var isEmpty = (value) => isNull(value) || value === "";
|
|
374
|
+
|
|
375
|
+
// src/is/key.ts
|
|
376
|
+
var isKey = (key, data) => key in data;
|
|
377
|
+
|
|
378
|
+
// src/load/image.ts
|
|
379
|
+
var loadImage = (src) => {
|
|
380
|
+
return new Promise((resolve) => {
|
|
381
|
+
const img = new Image();
|
|
382
|
+
img.onload = () => resolve(img);
|
|
383
|
+
img.onerror = () => resolve(null);
|
|
384
|
+
img.src = src;
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/memory/basic.ts
|
|
389
|
+
var MemoryBasic = class {
|
|
390
|
+
/**
|
|
391
|
+
* @param key 用于对数据进行分类的key
|
|
392
|
+
* @param config
|
|
393
|
+
*/
|
|
394
|
+
constructor(key, config) {
|
|
395
|
+
this.key = key;
|
|
396
|
+
this.#mount = config.mount;
|
|
397
|
+
this.#reflex = config.reflex;
|
|
398
|
+
}
|
|
399
|
+
#mount;
|
|
400
|
+
#reflex;
|
|
401
|
+
list = [];
|
|
402
|
+
memorys = /* @__PURE__ */ new Map();
|
|
403
|
+
/**
|
|
404
|
+
* 返回存储长度
|
|
405
|
+
*/
|
|
406
|
+
get size() {
|
|
407
|
+
return this.list.length;
|
|
408
|
+
}
|
|
409
|
+
getType(data) {
|
|
410
|
+
const { key } = this;
|
|
411
|
+
return typeof key === "function" ? key(data) : data[key];
|
|
412
|
+
}
|
|
413
|
+
push(...list) {
|
|
414
|
+
const { memorys } = this;
|
|
415
|
+
list.forEach((data) => {
|
|
416
|
+
const type = this.getType(data);
|
|
417
|
+
const memory = memorys.get(type);
|
|
418
|
+
const index = this.list.push(data) - 1;
|
|
419
|
+
const result = this.#mount(index, memory);
|
|
420
|
+
memory === result || memorys.set(type, result);
|
|
421
|
+
});
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* 返回位于指定索引处的项
|
|
426
|
+
*/
|
|
427
|
+
at(index) {
|
|
428
|
+
const { list } = this;
|
|
429
|
+
if (index < 0) {
|
|
430
|
+
index += list.length;
|
|
431
|
+
}
|
|
432
|
+
return this.list.at(index);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* 遍历所有存储数据(按入栈顺序)
|
|
436
|
+
*/
|
|
437
|
+
forEach(callback) {
|
|
438
|
+
this.list.forEach(callback);
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* 遍历所有存储类型
|
|
443
|
+
*/
|
|
444
|
+
forType(callback) {
|
|
445
|
+
const { memorys, list } = this;
|
|
446
|
+
for (const [type, memory] of memorys) {
|
|
447
|
+
const caches = this.#reflex(memory).map((index) => list[index]);
|
|
448
|
+
callback(caches, type);
|
|
449
|
+
}
|
|
450
|
+
return this;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* some(按入栈顺序)
|
|
454
|
+
*/
|
|
455
|
+
some(callback) {
|
|
456
|
+
return this.list.some(callback);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* map(按入栈顺序)
|
|
460
|
+
*/
|
|
461
|
+
map(callback) {
|
|
462
|
+
return this.list.map(callback);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* reduce(按入栈顺序)
|
|
466
|
+
*/
|
|
467
|
+
reduce(callback, initialValue) {
|
|
468
|
+
return this.list.reduce(callback, initialValue);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* 判断存储是否包含指定类型
|
|
472
|
+
*/
|
|
473
|
+
includes(type) {
|
|
474
|
+
return this.memorys.has(type);
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* 获取指定类型存储数据
|
|
478
|
+
*/
|
|
479
|
+
get(type) {
|
|
480
|
+
const memory = this.memorys.get(type);
|
|
481
|
+
return memory === void 0 ? null : this.#reflex(memory).map((count) => this.list[count]);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* 删除指定存储数据
|
|
485
|
+
*/
|
|
486
|
+
delete(data) {
|
|
487
|
+
const { memorys, list } = this;
|
|
488
|
+
let index = -1;
|
|
489
|
+
if (!list.some((value, i) => {
|
|
490
|
+
if (data === value) {
|
|
491
|
+
index = i;
|
|
492
|
+
list.splice(index, 1);
|
|
493
|
+
const type = this.getType(value);
|
|
494
|
+
const memory = this.#reflex(memorys.get(type));
|
|
495
|
+
if (memory.length === 1) {
|
|
496
|
+
memorys.delete(type);
|
|
497
|
+
} else {
|
|
498
|
+
memory.some((count, j) => {
|
|
499
|
+
if (count === i) {
|
|
500
|
+
memory.splice(j, 1);
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
})) return this;
|
|
508
|
+
for (const [type, target] of memorys) {
|
|
509
|
+
const memory = this.#reflex(target);
|
|
510
|
+
memory.forEach((value, i) => {
|
|
511
|
+
if (value >= index) {
|
|
512
|
+
memory[i] = value - 1;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
if (memory !== target) {
|
|
516
|
+
let reactor;
|
|
517
|
+
memory.forEach((count) => {
|
|
518
|
+
reactor = this.#mount(count, reactor);
|
|
519
|
+
});
|
|
520
|
+
memorys.set(type, reactor);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* 删除指定类型存储数据
|
|
527
|
+
*/
|
|
528
|
+
deleteType(type) {
|
|
529
|
+
const { memorys, list } = this;
|
|
530
|
+
if (!memorys.has(type)) return this;
|
|
531
|
+
const local = hash8strings(this.#reflex(memorys.get(type)));
|
|
532
|
+
const Memory = this.constructor;
|
|
533
|
+
const imitator = new Memory(this.key, {
|
|
534
|
+
mount: this.#mount,
|
|
535
|
+
reflex: this.#reflex
|
|
536
|
+
});
|
|
537
|
+
list.forEach((data, index) => {
|
|
538
|
+
index in local || imitator.push(data);
|
|
539
|
+
});
|
|
540
|
+
this.list = imitator.list;
|
|
541
|
+
this.memorys = imitator.memorys;
|
|
542
|
+
return this;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* 清理存储
|
|
546
|
+
*/
|
|
547
|
+
clear() {
|
|
548
|
+
this.list = [];
|
|
549
|
+
this.memorys.clear();
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
// src/memory/list.ts
|
|
554
|
+
var MemoryList = class extends MemoryBasic {
|
|
555
|
+
constructor(key) {
|
|
556
|
+
super(key, {
|
|
557
|
+
mount: (index, reactor) => reactor ? (reactor.push(index), reactor) : [index],
|
|
558
|
+
reflex: (reactor) => reactor
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// src/power/decon.ts
|
|
564
|
+
var ERROR_MESSAGE = {
|
|
565
|
+
INT: "\u53C2\u6570\u5FC5\u987B\u662F\u6574\u6570",
|
|
566
|
+
MIN: "\u591A\u4E2A2\u7684\u6B63\u6574\u6570\u5E42(\u4E24\u4E24\u4E0D\u76F8\u7B49)\u4E4B\u548C\u5FC5\u5B9A\u5927\u4E8E\u7B49\u4E8E1"
|
|
567
|
+
};
|
|
568
|
+
var deconPowersSum = (sum, sort) => {
|
|
569
|
+
if (sum < 1) {
|
|
570
|
+
throw new Error(ERROR_MESSAGE.MIN);
|
|
571
|
+
} else if (sum !== Math.floor(sum)) {
|
|
572
|
+
throw new Error(ERROR_MESSAGE.INT);
|
|
573
|
+
}
|
|
574
|
+
const list = [];
|
|
575
|
+
let cache = sum;
|
|
576
|
+
while (cache) {
|
|
577
|
+
const power = Math.log2(cache) ^ 0;
|
|
578
|
+
list.push(power);
|
|
579
|
+
cache -= Math.pow(2, power);
|
|
580
|
+
}
|
|
581
|
+
return sort === "asc" ? list.reverse() : list;
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// src/memory/power.ts
|
|
585
|
+
var MemoryPower = class extends MemoryBasic {
|
|
586
|
+
constructor(key) {
|
|
587
|
+
super(key, {
|
|
588
|
+
mount: (index, reactor) => (reactor || 0) + 2 ** index,
|
|
589
|
+
reflex: (reactor) => deconPowersSum(reactor, "asc")
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
// src/memory/simple.ts
|
|
595
|
+
var MemorySimple = class {
|
|
596
|
+
#memory;
|
|
597
|
+
#key;
|
|
598
|
+
get size() {
|
|
599
|
+
return this.#memory.size;
|
|
600
|
+
}
|
|
601
|
+
constructor(key) {
|
|
602
|
+
this.#key = key;
|
|
603
|
+
this.#memory = new MemoryBasic(key, {
|
|
604
|
+
mount: (index) => index,
|
|
605
|
+
reflex: (reactor) => [reactor]
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
#getType(data) {
|
|
609
|
+
const key = this.#key;
|
|
610
|
+
return typeof key === "function" ? key(data) : data[key];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* 返回位于指定索引处的项
|
|
614
|
+
*/
|
|
615
|
+
at(index) {
|
|
616
|
+
return this.#memory.at(index);
|
|
617
|
+
}
|
|
618
|
+
push(...list) {
|
|
619
|
+
const memory = this.#memory;
|
|
620
|
+
list.forEach((data) => {
|
|
621
|
+
memory.includes(this.#getType(data)) || memory.push(data);
|
|
622
|
+
});
|
|
623
|
+
return this;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* 获取指定类型存储数据
|
|
627
|
+
*/
|
|
628
|
+
get(type) {
|
|
629
|
+
const value = this.#memory.get(type);
|
|
630
|
+
if (value === null) return value;
|
|
631
|
+
return value.length ? value[0] : null;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* 遍历所有存储数据(按入栈顺序)
|
|
635
|
+
*/
|
|
636
|
+
forEach(callback) {
|
|
637
|
+
this.#memory.forEach(callback);
|
|
638
|
+
return this;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* some(按入栈顺序)
|
|
642
|
+
*/
|
|
643
|
+
some(callback) {
|
|
644
|
+
return this.#memory.some(callback);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* map(按入栈顺序)
|
|
648
|
+
*/
|
|
649
|
+
map(callback) {
|
|
650
|
+
return this.#memory.map(callback);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* reduce(按入栈顺序)
|
|
654
|
+
*/
|
|
655
|
+
reduce(callback, initialValue) {
|
|
656
|
+
return this.#memory.reduce(callback, initialValue);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* 判断是否包含指定类型
|
|
660
|
+
*/
|
|
661
|
+
includes(type) {
|
|
662
|
+
return this.#memory.includes(type);
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* 删除指定存储数据
|
|
666
|
+
*/
|
|
667
|
+
delete(data) {
|
|
668
|
+
this.#memory.delete(data);
|
|
669
|
+
return this;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* 删除指定类型存储数据
|
|
673
|
+
*/
|
|
674
|
+
deleteType(type) {
|
|
675
|
+
this.#memory.deleteType(type);
|
|
676
|
+
return this;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* 清理存储
|
|
680
|
+
*/
|
|
681
|
+
clear() {
|
|
682
|
+
this.#memory.clear();
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
// src/rotate/rad.ts
|
|
687
|
+
var rotateRad = (from, rad, visit = [0, 0]) => {
|
|
688
|
+
const x = from[0] - visit[0];
|
|
689
|
+
const y = from[1] - visit[1];
|
|
690
|
+
return [
|
|
691
|
+
x * Math.cos(rad) + y * Math.sin(rad) + visit[0],
|
|
692
|
+
y * Math.cos(rad) - x * Math.sin(rad) + visit[1]
|
|
693
|
+
];
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// src/neo4j-anchors.ts
|
|
697
|
+
var Neo4jAhchors = class {
|
|
698
|
+
constructor(neo4j, config) {
|
|
699
|
+
this.neo4j = neo4j;
|
|
700
|
+
this.config = Object.assign({}, config);
|
|
701
|
+
}
|
|
702
|
+
config;
|
|
703
|
+
#anchors = {};
|
|
704
|
+
getDir(start, end) {
|
|
705
|
+
const { neo4j } = this;
|
|
706
|
+
return neo4j.dirKey({
|
|
707
|
+
[neo4j.sourceField]: start,
|
|
708
|
+
[neo4j.targetField]: end
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* 设置多边间隔弧长
|
|
713
|
+
*/
|
|
714
|
+
setRaidx(value) {
|
|
715
|
+
this.config.radOffsetRaidx = value;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* 当图数据准备好后调用
|
|
719
|
+
*/
|
|
720
|
+
read() {
|
|
721
|
+
const { neo4j } = this;
|
|
722
|
+
const { nodeField, edgeField, sourceField, targetField } = neo4j;
|
|
723
|
+
const anchors = {};
|
|
724
|
+
neo4j.nodes.forEach((node) => {
|
|
725
|
+
const nodeId = node[nodeField];
|
|
726
|
+
let count = 0;
|
|
727
|
+
[
|
|
728
|
+
neo4j.sources.get(nodeId),
|
|
729
|
+
neo4j.targets.get(nodeId)
|
|
730
|
+
].forEach((list, i) => {
|
|
731
|
+
if (!list) return;
|
|
732
|
+
let diffCount = 0;
|
|
733
|
+
let sameCount = 0;
|
|
734
|
+
list.forEach((edge) => {
|
|
735
|
+
const edgeId = edge[edgeField];
|
|
736
|
+
if (edge[sourceField] !== edge[targetField]) {
|
|
737
|
+
const anchor = anchors[edgeId] || (anchors[edgeId] = {});
|
|
738
|
+
anchor[i ? "target" : "source"] = count + diffCount++;
|
|
739
|
+
} else if (edgeId in anchors === false) {
|
|
740
|
+
anchors[edgeId] = {
|
|
741
|
+
source: sameCount,
|
|
742
|
+
target: sameCount++
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
count += diffCount;
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
this.#anchors = anchors;
|
|
750
|
+
}
|
|
751
|
+
calcPoints(edge, index, total, type) {
|
|
752
|
+
const { neo4j, config: { getBox, radOffsetRaidx = 0.3125 } } = this;
|
|
753
|
+
const source = getBox(edge[neo4j.sourceField]);
|
|
754
|
+
const target = getBox(edge[neo4j.targetField]);
|
|
755
|
+
const rad = Math.atan2(
|
|
756
|
+
(source.centerY - target.centerY) * type,
|
|
757
|
+
(source.centerX - target.centerX) * type
|
|
758
|
+
);
|
|
759
|
+
let point = rotateRad([0.5, 0], rad);
|
|
760
|
+
if (total !== 1) {
|
|
761
|
+
point = rotateRad(point, radOffsetRaidx * (total / 2 - 0.5 - index));
|
|
762
|
+
}
|
|
763
|
+
const [x, y] = point;
|
|
764
|
+
return [x + 0.5, 0.5 - y];
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* 获取指定节点上出入边连接点的坐标
|
|
768
|
+
*/
|
|
769
|
+
getPoints(id) {
|
|
770
|
+
const { neo4j } = this;
|
|
771
|
+
const { dirs, edgeField, sourceField, targetField } = neo4j;
|
|
772
|
+
const anchors = this.#anchors;
|
|
773
|
+
const points = [];
|
|
774
|
+
const caches = {};
|
|
775
|
+
neo4j.sources.get(id)?.forEach((edge) => {
|
|
776
|
+
const source = edge[sourceField];
|
|
777
|
+
const target = edge[targetField];
|
|
778
|
+
const direct = this.getDir(source, target);
|
|
779
|
+
const invert = this.getDir(target, source);
|
|
780
|
+
if (direct in caches) return;
|
|
781
|
+
const directs = dirs.get(direct) || [];
|
|
782
|
+
const inverts = dirs.get(invert) || [];
|
|
783
|
+
const directsLength = directs.length;
|
|
784
|
+
const invertsLength = inverts.length;
|
|
785
|
+
const total = directsLength + invertsLength;
|
|
786
|
+
directs.forEach((data, index) => {
|
|
787
|
+
points[anchors[data[edgeField]].source] = this.calcPoints(data, directsLength - 1 - index, total, -1);
|
|
788
|
+
});
|
|
789
|
+
caches[direct] = direct;
|
|
790
|
+
});
|
|
791
|
+
neo4j.targets.get(id)?.forEach((edge) => {
|
|
792
|
+
const source = edge[sourceField];
|
|
793
|
+
const target = edge[targetField];
|
|
794
|
+
const direct = this.getDir(source, target);
|
|
795
|
+
const invert = this.getDir(target, source);
|
|
796
|
+
if (direct in caches) return;
|
|
797
|
+
const directs = neo4j.dirs.get(direct) || [];
|
|
798
|
+
const inverts = neo4j.dirs.get(invert) || [];
|
|
799
|
+
const directsLength = directs.length;
|
|
800
|
+
const invertsLength = inverts.length;
|
|
801
|
+
const total = directsLength + invertsLength;
|
|
802
|
+
directs.forEach((data, index) => {
|
|
803
|
+
points[anchors[data[edgeField]].target] = this.calcPoints(data, invertsLength + index, total, 1);
|
|
804
|
+
});
|
|
805
|
+
caches[direct] = direct;
|
|
806
|
+
});
|
|
807
|
+
return points;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* 查找边连接点的位置
|
|
811
|
+
*/
|
|
812
|
+
findAnchor(id) {
|
|
813
|
+
const anchor = this.#anchors[id];
|
|
814
|
+
if (!anchor) return null;
|
|
815
|
+
return {
|
|
816
|
+
source: anchor.source || 0,
|
|
817
|
+
target: anchor.target || 0
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* 获取指定边控制点距离两端点连线的距离(可理解为控制边的弯曲程度)
|
|
822
|
+
* @description 返回值是一个相对值,需要乘以一个基数值(基数值应为负值,如-30)
|
|
823
|
+
*/
|
|
824
|
+
getOffset(id) {
|
|
825
|
+
const { neo4j } = this;
|
|
826
|
+
const edge = neo4j.edges.get(id);
|
|
827
|
+
if (!edge) return -1;
|
|
828
|
+
const { dirs, edgeField, sourceField, targetField } = neo4j;
|
|
829
|
+
const source = edge[sourceField];
|
|
830
|
+
const target = edge[targetField];
|
|
831
|
+
const directs = dirs.get(this.getDir(source, target)) || [];
|
|
832
|
+
const inverts = dirs.get(this.getDir(target, source)) || [];
|
|
833
|
+
let count = 0;
|
|
834
|
+
let index = 0;
|
|
835
|
+
[directs, inverts].some((list) => {
|
|
836
|
+
const result = list.some((data, i) => {
|
|
837
|
+
if (data[edgeField] === id) {
|
|
838
|
+
index = i + count;
|
|
839
|
+
return true;
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
count += list.length;
|
|
843
|
+
return result;
|
|
844
|
+
});
|
|
845
|
+
const directsSize = directs.length;
|
|
846
|
+
const invertsSize = inverts.length;
|
|
847
|
+
const total = directsSize + invertsSize;
|
|
848
|
+
if (total === 1) return -1;
|
|
849
|
+
if (directsSize === 0 || invertsSize === 0) {
|
|
850
|
+
return total / 2 - index - 0.5;
|
|
851
|
+
} else {
|
|
852
|
+
return Math.abs(directsSize - invertsSize) * (directsSize >= invertsSize ? 1 : -1) / 2 - index - 0.5;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* 清理数据
|
|
857
|
+
*/
|
|
858
|
+
clear() {
|
|
859
|
+
this.#anchors = {};
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
// src/neo4j.ts
|
|
864
|
+
var Neo4j = class {
|
|
865
|
+
#nPrimaryKey;
|
|
866
|
+
#ePrimaryKey;
|
|
867
|
+
#sourceKey;
|
|
868
|
+
#targetKey;
|
|
869
|
+
#dirKey;
|
|
870
|
+
#nodes;
|
|
871
|
+
#edges;
|
|
872
|
+
#sources;
|
|
873
|
+
#targets;
|
|
874
|
+
#dirs;
|
|
875
|
+
get nodeField() {
|
|
876
|
+
return this.#nPrimaryKey;
|
|
877
|
+
}
|
|
878
|
+
get edgeField() {
|
|
879
|
+
return this.#ePrimaryKey;
|
|
880
|
+
}
|
|
881
|
+
get sourceField() {
|
|
882
|
+
return this.#sourceKey;
|
|
883
|
+
}
|
|
884
|
+
get targetField() {
|
|
885
|
+
return this.#targetKey;
|
|
886
|
+
}
|
|
887
|
+
get dirKey() {
|
|
888
|
+
return this.#dirKey;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* 点视图
|
|
892
|
+
*/
|
|
893
|
+
nodes;
|
|
894
|
+
/**
|
|
895
|
+
* 边视图
|
|
896
|
+
*/
|
|
897
|
+
edges;
|
|
898
|
+
/**
|
|
899
|
+
* (边)出点视图
|
|
900
|
+
*/
|
|
901
|
+
sources;
|
|
902
|
+
/**
|
|
903
|
+
* (边)入点视图
|
|
904
|
+
*/
|
|
905
|
+
targets;
|
|
906
|
+
/**
|
|
907
|
+
* (边)方向视图
|
|
908
|
+
*/
|
|
909
|
+
dirs;
|
|
910
|
+
constructor(nodeList, edgeList, {
|
|
911
|
+
nid,
|
|
912
|
+
eid,
|
|
913
|
+
sourceKey,
|
|
914
|
+
targetKey,
|
|
915
|
+
dir = (edge) => edge[sourceKey] + "|" + edge[targetKey]
|
|
916
|
+
}) {
|
|
917
|
+
shield(this, "nodes", this.#nodes = new MemorySimple(this.#nPrimaryKey = nid));
|
|
918
|
+
shield(this, "edges", this.#edges = new MemorySimple(this.#ePrimaryKey = eid));
|
|
919
|
+
shield(this, "sources", this.#sources = new MemoryList(this.#sourceKey = sourceKey));
|
|
920
|
+
shield(this, "targets", this.#targets = new MemoryList(this.#targetKey = targetKey));
|
|
921
|
+
shield(this, "dirs", this.#dirs = new MemoryList(this.#dirKey = dir));
|
|
922
|
+
nodeList.forEach((node) => this.node("add", node));
|
|
923
|
+
edgeList.forEach((edge) => this.edge("add", edge));
|
|
924
|
+
}
|
|
925
|
+
node(type, value) {
|
|
926
|
+
const nodes = this.#nodes;
|
|
927
|
+
if (type === "add") {
|
|
928
|
+
nodes.push(value);
|
|
929
|
+
} else if (type === "delete") {
|
|
930
|
+
const node = nodes.get(value);
|
|
931
|
+
if (!node) return [];
|
|
932
|
+
nodes.delete(node);
|
|
933
|
+
const id = node[this.#nPrimaryKey];
|
|
934
|
+
const sourceKey = this.#sourceKey;
|
|
935
|
+
const targetKey = this.#targetKey;
|
|
936
|
+
const edges = this.#edges;
|
|
937
|
+
const sources = this.#sources;
|
|
938
|
+
const targets = this.#targets;
|
|
939
|
+
const dirs = this.#dirs;
|
|
940
|
+
const list = [];
|
|
941
|
+
sources.get(id)?.reduce((_, edge) => {
|
|
942
|
+
edges.delete(edge);
|
|
943
|
+
targets.delete(edge);
|
|
944
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
945
|
+
list.push(edge);
|
|
946
|
+
return true;
|
|
947
|
+
}, false) && sources.deleteType(id);
|
|
948
|
+
targets.get(id)?.reduce((_, edge) => {
|
|
949
|
+
edges.delete(edge);
|
|
950
|
+
sources.delete(edge);
|
|
951
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
952
|
+
list.push(edge);
|
|
953
|
+
return true;
|
|
954
|
+
}, false) && targets.deleteType(id);
|
|
955
|
+
return list;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
edge(type, value) {
|
|
959
|
+
const sourceKey = this.#sourceKey;
|
|
960
|
+
const targetKey = this.#targetKey;
|
|
961
|
+
const edges = this.#edges;
|
|
962
|
+
const sources = this.#sources;
|
|
963
|
+
const targets = this.#targets;
|
|
964
|
+
const dirs = this.#dirs;
|
|
965
|
+
if (type === "add") {
|
|
966
|
+
const edge = value;
|
|
967
|
+
edges.push(edge);
|
|
968
|
+
sources.push(edge);
|
|
969
|
+
targets.push(edge);
|
|
970
|
+
edge[sourceKey] === edge[targetKey] || dirs.push(edge);
|
|
971
|
+
} else if (type === "delete") {
|
|
972
|
+
const edge = edges.get(value);
|
|
973
|
+
if (!edge) return false;
|
|
974
|
+
edges.delete(edge);
|
|
975
|
+
sources.delete(edge);
|
|
976
|
+
targets.delete(edge);
|
|
977
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
978
|
+
return true;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* 清理图管理数据
|
|
983
|
+
*/
|
|
984
|
+
clear() {
|
|
985
|
+
this.#nodes.clear();
|
|
986
|
+
this.#edges.clear();
|
|
987
|
+
this.#sources.clear();
|
|
988
|
+
this.#targets.clear();
|
|
989
|
+
this.#dirs.clear();
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
var shield_keys = hash8strings([
|
|
993
|
+
"push",
|
|
994
|
+
"delete",
|
|
995
|
+
"deleteType",
|
|
996
|
+
"clear"
|
|
997
|
+
]);
|
|
998
|
+
var shield = (obj, key, origin) => {
|
|
999
|
+
const proxy = new Proxy({}, {
|
|
1000
|
+
get(target, p) {
|
|
1001
|
+
if (p in shield_keys) return;
|
|
1002
|
+
const value = origin[p];
|
|
1003
|
+
if (typeof value === "function") {
|
|
1004
|
+
return function(...args) {
|
|
1005
|
+
const result = origin[p](...args);
|
|
1006
|
+
return result === origin ? proxy : result;
|
|
1007
|
+
};
|
|
1008
|
+
} else {
|
|
1009
|
+
return value;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
Object.defineProperty(obj, key, {
|
|
1014
|
+
get() {
|
|
1015
|
+
return proxy;
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
// src/once.ts
|
|
1021
|
+
var once = (func, thisArg) => {
|
|
1022
|
+
let local;
|
|
1023
|
+
let inited = false;
|
|
1024
|
+
return (...list) => inited ? local : (inited = true, local = func.apply(thisArg, list));
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
// src/parse/num.ts
|
|
1028
|
+
var pow = Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
|
|
1029
|
+
var re_num = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
|
|
1030
|
+
var parseNum = (num) => {
|
|
1031
|
+
if (isNumber_default(num) || typeof num === "bigint") return num;
|
|
1032
|
+
const match = num.match(re_num);
|
|
1033
|
+
if (!match) return Number.NaN;
|
|
1034
|
+
const [, valueSymbol, integer, bigint, decimal, powSymbol, powValue] = match;
|
|
1035
|
+
if (bigint === "n") return BigInt(valueSymbol + integer);
|
|
1036
|
+
const powSize = integer.length - 1 + (powValue ? powSymbol === "-" ? -powValue : +powValue : 0);
|
|
1037
|
+
if (powSize < pow || powSize === pow && +integer.slice(0, -1) < Number.MAX_SAFE_INTEGER / 10) return +num;
|
|
1038
|
+
try {
|
|
1039
|
+
const bigValue = BigInt(integer.slice(0, powSize + 1).padEnd(powSize + 1, "0"));
|
|
1040
|
+
let smallValue;
|
|
1041
|
+
if (decimal && powValue && powSymbol !== "-") {
|
|
1042
|
+
const powNum = +powValue;
|
|
1043
|
+
const effectDecimal = decimal.slice(0, Math.min(pow, powNum));
|
|
1044
|
+
const tinyValue = decimal.length > pow && powNum > pow ? BigInt(+decimal.slice(pow, powNum)) * BigInt(10 ** Math.max(powNum - decimal.length, 0)) : BigInt(0);
|
|
1045
|
+
smallValue = BigInt(effectDecimal) * BigInt(10 ** (powNum - effectDecimal.length)) + tinyValue;
|
|
1046
|
+
} else {
|
|
1047
|
+
smallValue = BigInt(0);
|
|
1048
|
+
}
|
|
1049
|
+
const value = bigValue + smallValue;
|
|
1050
|
+
return valueSymbol === "-" ? value * BigInt(-1) : value;
|
|
1051
|
+
} catch {
|
|
1052
|
+
return Number.NaN;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/rotate/angle.ts
|
|
1057
|
+
var rotateAngle = (from, angle, visit) => rotateRad(from, angle / 180 * Math.PI, visit);
|
|
1058
|
+
|
|
1059
|
+
// src/serialize/url-params.ts
|
|
1060
|
+
var cubes = {
|
|
1061
|
+
string: (text) => text,
|
|
1062
|
+
boolean: (text) => text === "true",
|
|
1063
|
+
number: (text) => Number(text),
|
|
1064
|
+
bigint: (text) => BigInt(text),
|
|
1065
|
+
date: (text) => new Date(text),
|
|
1066
|
+
regexp: (text) => new RegExp(text),
|
|
1067
|
+
null: () => null
|
|
1068
|
+
};
|
|
1069
|
+
var flats = {
|
|
1070
|
+
string: (data) => flatEncode(data),
|
|
1071
|
+
boolean: (data) => `${data}`,
|
|
1072
|
+
number: (data) => `${data}`,
|
|
1073
|
+
bigint: (data) => `${data}`,
|
|
1074
|
+
date: (data) => data.toJSON(),
|
|
1075
|
+
regexp: (data) => flatEncode(data.source),
|
|
1076
|
+
null: () => "null"
|
|
1077
|
+
};
|
|
1078
|
+
var cubeURLParams = (text, serializes) => {
|
|
1079
|
+
const params = new URLSearchParams(text);
|
|
1080
|
+
const result = {};
|
|
1081
|
+
for (const [key, value] of params) {
|
|
1082
|
+
const serialize = serializes[key];
|
|
1083
|
+
if (!serialize) continue;
|
|
1084
|
+
if (isString_default(serialize) && isKey(serialize, cubes)) {
|
|
1085
|
+
result[key] = cubes[serialize](value);
|
|
1086
|
+
} else {
|
|
1087
|
+
result[key] = serialize.cube(value);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return result;
|
|
1091
|
+
};
|
|
1092
|
+
var re_flat = /\+/g;
|
|
1093
|
+
var flatEncode = (text) => text.replace(re_flat, () => "%2B");
|
|
1094
|
+
var flatURLParams = (data, serializes) => {
|
|
1095
|
+
const params = new URLSearchParams();
|
|
1096
|
+
for (const key in data) {
|
|
1097
|
+
const value = data[key];
|
|
1098
|
+
const serialize = serializes[key];
|
|
1099
|
+
if (!serialize) continue;
|
|
1100
|
+
params.append(
|
|
1101
|
+
key,
|
|
1102
|
+
isString_default(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
return params.toString();
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
// src/style/css.ts
|
|
1109
|
+
var hump = /[A-Z]/g;
|
|
1110
|
+
var css = (...args) => {
|
|
1111
|
+
const list = [];
|
|
1112
|
+
for (let i = 0; i < args.length; i++) {
|
|
1113
|
+
const data = args[i];
|
|
1114
|
+
if (!data) continue;
|
|
1115
|
+
if (isString_default(data)) {
|
|
1116
|
+
list.push(data);
|
|
1117
|
+
} else if (Array.isArray(data)) {
|
|
1118
|
+
const result = css(...data);
|
|
1119
|
+
result && list.push(result);
|
|
1120
|
+
} else {
|
|
1121
|
+
for (const key in data) {
|
|
1122
|
+
const value = data[key];
|
|
1123
|
+
isNull(value) || list.push(`${key.replace(hump, ($0) => "-" + $0.toLocaleLowerCase())}: ${value}`);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
return list.join(";");
|
|
1128
|
+
};
|
|
1129
|
+
|
|
1130
|
+
// src/subscriber.ts
|
|
1131
|
+
var Subscriber = class {
|
|
1132
|
+
#listeners = {};
|
|
1133
|
+
#once = {};
|
|
1134
|
+
$on(name, listener) {
|
|
1135
|
+
const listeners = this.#listeners;
|
|
1136
|
+
if (name in listeners) {
|
|
1137
|
+
listeners[name].push(listener);
|
|
1138
|
+
} else {
|
|
1139
|
+
listeners[name] = [listener];
|
|
1140
|
+
}
|
|
1141
|
+
return this;
|
|
1142
|
+
}
|
|
1143
|
+
$once(name, listener) {
|
|
1144
|
+
this.$on(name, listener);
|
|
1145
|
+
const index = this.#listeners[name].length - 1;
|
|
1146
|
+
const once2 = this.#once;
|
|
1147
|
+
if (name in once2) {
|
|
1148
|
+
once2[name].push(index);
|
|
1149
|
+
} else {
|
|
1150
|
+
once2[name] = [index];
|
|
1151
|
+
}
|
|
1152
|
+
return this;
|
|
1153
|
+
}
|
|
1154
|
+
$emit(name, ...args) {
|
|
1155
|
+
const listeners = this.#listeners[name];
|
|
1156
|
+
if (!listeners) return this;
|
|
1157
|
+
const once2 = hash8strings(this.#once[name] || []);
|
|
1158
|
+
this.#listeners[name] = listeners.reduce((list, listener, index) => {
|
|
1159
|
+
listener(...args);
|
|
1160
|
+
index in once2 || list.push(listener);
|
|
1161
|
+
return list;
|
|
1162
|
+
}, []);
|
|
1163
|
+
delete this.#once[name];
|
|
1164
|
+
return this;
|
|
1165
|
+
}
|
|
1166
|
+
$off(name, listener) {
|
|
1167
|
+
const listeners = this.#listeners;
|
|
1168
|
+
const once2 = this.#once;
|
|
1169
|
+
if (name in listeners === false) return this;
|
|
1170
|
+
if (listener) {
|
|
1171
|
+
let count;
|
|
1172
|
+
listeners[name].some((value, index) => {
|
|
1173
|
+
if (value === listener) {
|
|
1174
|
+
count = index;
|
|
1175
|
+
listeners[name].splice(index, 1);
|
|
1176
|
+
return true;
|
|
1177
|
+
}
|
|
1178
|
+
}) && once2[name].some((value, index) => {
|
|
1179
|
+
if (value === count) {
|
|
1180
|
+
listeners[name].splice(index, 1);
|
|
1181
|
+
return true;
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
} else {
|
|
1185
|
+
delete listeners[name];
|
|
1186
|
+
delete this.#once[name];
|
|
1187
|
+
}
|
|
1188
|
+
return this;
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/table/flex.ts
|
|
1193
|
+
var FlexTable = class {
|
|
1194
|
+
#data = [];
|
|
1195
|
+
/**
|
|
1196
|
+
* 行数
|
|
1197
|
+
*/
|
|
1198
|
+
get rowspan() {
|
|
1199
|
+
return this.#data.length;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* 总数据长度
|
|
1203
|
+
*/
|
|
1204
|
+
get length() {
|
|
1205
|
+
return this.#data.reduce((length, list) => length + list.length, 0);
|
|
1206
|
+
}
|
|
1207
|
+
constructor() {
|
|
1208
|
+
this.newline();
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* 创建新行
|
|
1212
|
+
*/
|
|
1213
|
+
newline() {
|
|
1214
|
+
this.#data.push([]);
|
|
1215
|
+
return this;
|
|
1216
|
+
}
|
|
1217
|
+
push(value) {
|
|
1218
|
+
const rowspan = this.#data.length;
|
|
1219
|
+
rowspan || this.newline();
|
|
1220
|
+
this.#data[rowspan - 1].push(value);
|
|
1221
|
+
return this;
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* 替换指定位置的数据
|
|
1225
|
+
* @description 指定位置必需为有效位置
|
|
1226
|
+
*/
|
|
1227
|
+
replace(rowspan, colspan, value) {
|
|
1228
|
+
const list = this.#data[rowspan];
|
|
1229
|
+
list && colspan in list && (list[colspan] = value);
|
|
1230
|
+
return this;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* 从指定位置开始移除或者替换/添加元素
|
|
1234
|
+
* @description 指定位置必需为有效位置
|
|
1235
|
+
*/
|
|
1236
|
+
splice(rowspan, colspan, deleteCount, ...values) {
|
|
1237
|
+
const list = this.#data[rowspan];
|
|
1238
|
+
list && colspan in list && list.splice(colspan, deleteCount, ...values);
|
|
1239
|
+
return this;
|
|
1240
|
+
}
|
|
1241
|
+
pop() {
|
|
1242
|
+
const data = this.#data;
|
|
1243
|
+
const rowspan = data.length;
|
|
1244
|
+
if (!rowspan) return null;
|
|
1245
|
+
const list = data[rowspan - 1];
|
|
1246
|
+
if (list.length) {
|
|
1247
|
+
return list.pop();
|
|
1248
|
+
} else {
|
|
1249
|
+
data.pop();
|
|
1250
|
+
return this.pop();
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* 遍历数据
|
|
1255
|
+
*/
|
|
1256
|
+
each(callback) {
|
|
1257
|
+
const data = this.#data;
|
|
1258
|
+
outloop: for (let i = 0; i < data.length; i++) {
|
|
1259
|
+
const list = data[i];
|
|
1260
|
+
for (let j = 0; j < list.length; j++) {
|
|
1261
|
+
if (callback(list[j], i, j) === false) break outloop;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* 反序遍历数据
|
|
1267
|
+
*/
|
|
1268
|
+
reverseEach(callback) {
|
|
1269
|
+
const data = this.#data;
|
|
1270
|
+
outloop: for (let i = data.length; i; ) {
|
|
1271
|
+
const list = data[--i];
|
|
1272
|
+
for (let j = list.length; j; ) {
|
|
1273
|
+
if (callback(list[--j], i, j) === false) break outloop;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* 清空数据
|
|
1279
|
+
*/
|
|
1280
|
+
clear() {
|
|
1281
|
+
if (this.#data.length) {
|
|
1282
|
+
this.#data = [];
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
// src/union.ts
|
|
1288
|
+
var Union = class {
|
|
1289
|
+
constructor(key, formatter) {
|
|
1290
|
+
this.key = key;
|
|
1291
|
+
this.formatter = formatter;
|
|
1292
|
+
}
|
|
1293
|
+
#data = {};
|
|
1294
|
+
#options = {};
|
|
1295
|
+
#raws = {};
|
|
1296
|
+
get data() {
|
|
1297
|
+
return this.#data;
|
|
1298
|
+
}
|
|
1299
|
+
get options() {
|
|
1300
|
+
return this.#options;
|
|
1301
|
+
}
|
|
1302
|
+
add(data) {
|
|
1303
|
+
const key = data[this.key];
|
|
1304
|
+
const result = this.formatter(data);
|
|
1305
|
+
this.#raws[key] = data;
|
|
1306
|
+
this.#data[key] = result.data;
|
|
1307
|
+
this.#options[key] = result.option;
|
|
1308
|
+
return this;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* 获取原始数据
|
|
1312
|
+
*/
|
|
1313
|
+
getRaw(key) {
|
|
1314
|
+
return this.#raws[key];
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* 从已有的联合中拷贝数据
|
|
1318
|
+
*/
|
|
1319
|
+
clone(target, key) {
|
|
1320
|
+
const { data, options } = target;
|
|
1321
|
+
const keys = Array.isArray(key) ? key : [key];
|
|
1322
|
+
keys.forEach((key2) => {
|
|
1323
|
+
if (key2 in data) {
|
|
1324
|
+
this.#raws[key2] = target.getRaw(key2);
|
|
1325
|
+
this.#data[key2] = data[key2];
|
|
1326
|
+
this.#options[key2] = options[key2];
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
return this;
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// src/url/join.ts
|
|
1334
|
+
var re = /([^:])\/{2,}/g;
|
|
1335
|
+
var joinPaths = (...list) => {
|
|
1336
|
+
const { length } = list;
|
|
1337
|
+
if (length === 0) return "";
|
|
1338
|
+
return length === 1 ? list[0] : list.join("/").replace(re, ($0, $1) => `${$1}/`);
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
// src/url/params.ts
|
|
1342
|
+
var connectURLParams = (url, params, serializes) => {
|
|
1343
|
+
const query = flatURLParams(params, serializes);
|
|
1344
|
+
return query ? url.includes("?") ? url + "&" + query : url + "?" + query : url;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1347
|
+
// src/wait.ts
|
|
1348
|
+
var wait = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay));
|
|
1349
|
+
/*! Bundled license information:
|
|
1350
|
+
|
|
1351
|
+
lodash-es/lodash.js:
|
|
1352
|
+
(**
|
|
1353
|
+
* @license
|
|
1354
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
1355
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
1356
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
1357
|
+
* Released under MIT license <https://lodash.com/license>
|
|
1358
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
1359
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
1360
|
+
*)
|
|
1361
|
+
*/
|