@vope/utils 1.5.0 → 1.6.0-bate.10

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