@hpcc-js/util 3.3.12 → 3.4.0
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/index.js +1837 -2112
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
- package/src/__package__.ts +3 -3
- package/types/__package__.d.ts +3 -3
package/dist/index.js
CHANGED
|
@@ -1,2224 +1,1949 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
var _a, _b, _c, _d;
|
|
1
|
+
//#region src/__package__.ts
|
|
6
2
|
const PKG_NAME = "@hpcc-js/util";
|
|
7
|
-
const PKG_VERSION = "3.
|
|
8
|
-
const BUILD_VERSION = "3.
|
|
3
|
+
const PKG_VERSION = "3.4.0";
|
|
4
|
+
const BUILD_VERSION = "3.15.0";
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/array.ts
|
|
9
8
|
function find(o, predicate) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const kValue = o[k];
|
|
21
|
-
if (predicate.call(thisArg, kValue, k)) {
|
|
22
|
-
return kValue;
|
|
23
|
-
}
|
|
24
|
-
k++;
|
|
25
|
-
}
|
|
26
|
-
return void 0;
|
|
9
|
+
if (o == null) throw new TypeError("\"o\" is null or not defined");
|
|
10
|
+
const len = o.length >>> 0;
|
|
11
|
+
if (typeof predicate !== "function") throw new TypeError("predicate must be a function");
|
|
12
|
+
const thisArg = arguments[1];
|
|
13
|
+
let k = 0;
|
|
14
|
+
while (k < len) {
|
|
15
|
+
const kValue = o[k];
|
|
16
|
+
if (predicate.call(thisArg, kValue, k)) return kValue;
|
|
17
|
+
k++;
|
|
18
|
+
}
|
|
27
19
|
}
|
|
28
|
-
__name(find, "find");
|
|
29
20
|
function compare(before, after) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
return retVal;
|
|
21
|
+
const retVal = {
|
|
22
|
+
update: [],
|
|
23
|
+
exit: [],
|
|
24
|
+
enter: [...after]
|
|
25
|
+
};
|
|
26
|
+
for (const row of before) {
|
|
27
|
+
const otherIdx = retVal.enter.indexOf(row);
|
|
28
|
+
if (otherIdx >= 0) {
|
|
29
|
+
retVal.update.push(row);
|
|
30
|
+
retVal.enter.splice(otherIdx, 1);
|
|
31
|
+
} else retVal.exit.push(row);
|
|
32
|
+
}
|
|
33
|
+
return retVal;
|
|
45
34
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
for (const key in unknownMap) {
|
|
72
|
-
retVal.enter.push(unknownMap[key]);
|
|
73
|
-
}
|
|
74
|
-
return retVal;
|
|
35
|
+
function compare2(before, after, idFunc, updateFunc = (before$1, after$1) => after$1) {
|
|
36
|
+
const retVal = {
|
|
37
|
+
update: [],
|
|
38
|
+
exit: [],
|
|
39
|
+
enter: []
|
|
40
|
+
};
|
|
41
|
+
if (before === after) {
|
|
42
|
+
retVal.update = before;
|
|
43
|
+
return retVal;
|
|
44
|
+
}
|
|
45
|
+
const unknownMap = {};
|
|
46
|
+
after.forEach((item) => {
|
|
47
|
+
unknownMap[idFunc(item)] = item;
|
|
48
|
+
});
|
|
49
|
+
for (const row of before) {
|
|
50
|
+
const id = idFunc(row);
|
|
51
|
+
const item = unknownMap[id];
|
|
52
|
+
if (item !== void 0) {
|
|
53
|
+
delete unknownMap[id];
|
|
54
|
+
retVal.update.push(updateFunc(row, item));
|
|
55
|
+
} else retVal.exit.push(row);
|
|
56
|
+
}
|
|
57
|
+
for (const key in unknownMap) retVal.enter.push(unknownMap[key]);
|
|
58
|
+
return retVal;
|
|
75
59
|
}
|
|
76
|
-
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/hashSum.ts
|
|
77
63
|
function pad(hash, len) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
return hash;
|
|
64
|
+
while (hash.length < len) hash = "0" + hash;
|
|
65
|
+
return hash;
|
|
82
66
|
}
|
|
83
|
-
__name(pad, "pad");
|
|
84
67
|
function fold(hash, text) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return hash < 0 ? hash * -2 : hash;
|
|
68
|
+
if (text.length === 0) return hash;
|
|
69
|
+
for (let i = 0; i < text.length; ++i) {
|
|
70
|
+
const chr = text.charCodeAt(i);
|
|
71
|
+
hash = (hash << 5) - hash + chr;
|
|
72
|
+
hash |= 0;
|
|
73
|
+
}
|
|
74
|
+
return hash < 0 ? hash * -2 : hash;
|
|
94
75
|
}
|
|
95
|
-
__name(fold, "fold");
|
|
96
76
|
function foldObject(hash, o, seen) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return foldValue(input, o[key], key, seen);
|
|
102
|
-
}, hash);
|
|
77
|
+
if (typeof o.hashSum === "function") return o.hashSum();
|
|
78
|
+
return Object.keys(o).sort().reduce((input, key) => {
|
|
79
|
+
return foldValue(input, o[key], key, seen);
|
|
80
|
+
}, hash);
|
|
103
81
|
}
|
|
104
|
-
__name(foldObject, "foldObject");
|
|
105
82
|
function foldValue(input, value, key, seen) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return fold(hash, "[Circular]" + key);
|
|
116
|
-
}
|
|
117
|
-
seen.push(value);
|
|
118
|
-
return foldObject(hash, value, seen);
|
|
119
|
-
}
|
|
120
|
-
return fold(hash, value.toString());
|
|
83
|
+
const hash = fold(fold(fold(input, key), toString(value)), typeof value);
|
|
84
|
+
if (value === null) return fold(hash, "null");
|
|
85
|
+
if (value === void 0) return fold(hash, "undefined");
|
|
86
|
+
if (typeof value === "object") {
|
|
87
|
+
if (seen.indexOf(value) !== -1) return fold(hash, "[Circular]" + key);
|
|
88
|
+
seen.push(value);
|
|
89
|
+
return foldObject(hash, value, seen);
|
|
90
|
+
}
|
|
91
|
+
return fold(hash, value.toString());
|
|
121
92
|
}
|
|
122
|
-
__name(foldValue, "foldValue");
|
|
123
93
|
function toString(o) {
|
|
124
|
-
|
|
94
|
+
return Object.prototype.toString.call(o);
|
|
125
95
|
}
|
|
126
|
-
__name(toString, "toString");
|
|
127
96
|
function hashSum(o) {
|
|
128
|
-
|
|
97
|
+
return pad(foldValue(0, o, "", []).toString(16), 8);
|
|
129
98
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/cache.ts
|
|
102
|
+
var Cache = class {
|
|
103
|
+
_cache = {};
|
|
104
|
+
_calcID;
|
|
105
|
+
static hash(...args) {
|
|
106
|
+
return hashSum({ ...args });
|
|
107
|
+
}
|
|
108
|
+
constructor(calcID) {
|
|
109
|
+
this._calcID = calcID;
|
|
110
|
+
}
|
|
111
|
+
has(espObj) {
|
|
112
|
+
return this._calcID(espObj) in this._cache;
|
|
113
|
+
}
|
|
114
|
+
set(obj) {
|
|
115
|
+
this._cache[this._calcID(obj)] = obj;
|
|
116
|
+
return obj;
|
|
117
|
+
}
|
|
118
|
+
get(espObj, factory) {
|
|
119
|
+
const retVal = this._cache[this._calcID(espObj)];
|
|
120
|
+
if (!retVal) return factory ? this.set(factory()) : null;
|
|
121
|
+
return retVal;
|
|
122
|
+
}
|
|
154
123
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return factory ? this.set(espObj, factory()) : Promise.resolve(null);
|
|
177
|
-
}
|
|
178
|
-
return retVal;
|
|
179
|
-
}
|
|
124
|
+
var AsyncCache = class {
|
|
125
|
+
_cache = {};
|
|
126
|
+
_calcID;
|
|
127
|
+
static hash(...args) {
|
|
128
|
+
return hashSum({ ...args });
|
|
129
|
+
}
|
|
130
|
+
constructor(calcID) {
|
|
131
|
+
this._calcID = calcID;
|
|
132
|
+
}
|
|
133
|
+
has(espObj) {
|
|
134
|
+
return this._calcID(espObj) in this._cache;
|
|
135
|
+
}
|
|
136
|
+
set(espObj, obj) {
|
|
137
|
+
this._cache[this._calcID(espObj)] = obj;
|
|
138
|
+
return obj;
|
|
139
|
+
}
|
|
140
|
+
get(espObj, factory) {
|
|
141
|
+
const retVal = this._cache[this._calcID(espObj)];
|
|
142
|
+
if (!retVal) return factory ? this.set(espObj, factory()) : Promise.resolve(null);
|
|
143
|
+
return retVal;
|
|
144
|
+
}
|
|
180
145
|
};
|
|
181
|
-
|
|
182
|
-
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/debounce.ts
|
|
183
149
|
function debounce(fn, timeout) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
})
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
return promises[hash].promise;
|
|
206
|
-
};
|
|
150
|
+
const promises = {};
|
|
151
|
+
return (...params) => {
|
|
152
|
+
const hash = hashSum(params);
|
|
153
|
+
if (!promises[hash]) promises[hash] = {
|
|
154
|
+
clockStart: Date.now(),
|
|
155
|
+
promise: fn(...params).then((response) => {
|
|
156
|
+
if (timeout === void 0) promises[hash] = null;
|
|
157
|
+
else setTimeout(() => {
|
|
158
|
+
promises[hash] = null;
|
|
159
|
+
}, Math.max(timeout - (Date.now() - promises[hash].clockStart), 0));
|
|
160
|
+
return response;
|
|
161
|
+
}).catch((e) => {
|
|
162
|
+
promises[hash] = null;
|
|
163
|
+
throw e;
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
return promises[hash].promise;
|
|
167
|
+
};
|
|
207
168
|
}
|
|
208
|
-
__name(debounce, "debounce");
|
|
209
169
|
function promiseTimeout(ms, promise) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
clearTimeout(id);
|
|
225
|
-
throw e;
|
|
226
|
-
});
|
|
170
|
+
let id;
|
|
171
|
+
const timeout = new Promise((resolve, reject) => {
|
|
172
|
+
id = setTimeout(() => {
|
|
173
|
+
clearTimeout(id);
|
|
174
|
+
reject("Timed out in " + ms + "ms.");
|
|
175
|
+
}, ms);
|
|
176
|
+
});
|
|
177
|
+
return Promise.race([promise, timeout]).then((response) => {
|
|
178
|
+
clearTimeout(id);
|
|
179
|
+
return response;
|
|
180
|
+
}).catch((e) => {
|
|
181
|
+
clearTimeout(id);
|
|
182
|
+
throw e;
|
|
183
|
+
});
|
|
227
184
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
185
|
+
var AsyncOrderedQueue = class {
|
|
186
|
+
_q = [];
|
|
187
|
+
isTop(p) {
|
|
188
|
+
return this._q[0] === p;
|
|
189
|
+
}
|
|
190
|
+
push(p) {
|
|
191
|
+
const retVal = p.then((response) => {
|
|
192
|
+
if (this.isTop(retVal)) {
|
|
193
|
+
this._q.shift();
|
|
194
|
+
return response;
|
|
195
|
+
}
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
const intervalHandler = setInterval(() => {
|
|
198
|
+
if (this.isTop(retVal)) {
|
|
199
|
+
clearInterval(intervalHandler);
|
|
200
|
+
this._q.shift();
|
|
201
|
+
resolve(response);
|
|
202
|
+
}
|
|
203
|
+
}, 20);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
this._q.push(retVal);
|
|
207
|
+
return retVal;
|
|
208
|
+
}
|
|
253
209
|
};
|
|
254
|
-
__name(_AsyncOrderedQueue, "AsyncOrderedQueue");
|
|
255
|
-
let AsyncOrderedQueue = _AsyncOrderedQueue;
|
|
256
210
|
function sleep(ms) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
211
|
+
return new Promise((resolve) => {
|
|
212
|
+
setTimeout(() => resolve(), ms);
|
|
213
|
+
});
|
|
260
214
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const retVal = [];
|
|
294
|
-
for (const key in this.store) {
|
|
295
|
-
retVal.push(this.store[key]);
|
|
296
|
-
}
|
|
297
|
-
return retVal;
|
|
298
|
-
}
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/dictionary.ts
|
|
218
|
+
var Dictionary = class {
|
|
219
|
+
store = {};
|
|
220
|
+
constructor(attrs) {
|
|
221
|
+
if (attrs) for (const key in attrs) this.set(key, attrs[key]);
|
|
222
|
+
}
|
|
223
|
+
set(key, value) {
|
|
224
|
+
const retVal = this.store[key];
|
|
225
|
+
this.store[key] = value;
|
|
226
|
+
return retVal;
|
|
227
|
+
}
|
|
228
|
+
get(key) {
|
|
229
|
+
return this.store[key];
|
|
230
|
+
}
|
|
231
|
+
has(key) {
|
|
232
|
+
return this.store[key] !== void 0;
|
|
233
|
+
}
|
|
234
|
+
remove(key) {
|
|
235
|
+
delete this.store[key];
|
|
236
|
+
}
|
|
237
|
+
keys() {
|
|
238
|
+
const retVal = [];
|
|
239
|
+
for (const key in this.store) retVal.push(key);
|
|
240
|
+
return retVal;
|
|
241
|
+
}
|
|
242
|
+
values() {
|
|
243
|
+
const retVal = [];
|
|
244
|
+
for (const key in this.store) retVal.push(this.store[key]);
|
|
245
|
+
return retVal;
|
|
246
|
+
}
|
|
299
247
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return super.remove(key.toLowerCase());
|
|
317
|
-
}
|
|
248
|
+
var DictionaryNoCase = class extends Dictionary {
|
|
249
|
+
constructor(attrs) {
|
|
250
|
+
super(attrs);
|
|
251
|
+
}
|
|
252
|
+
set(key, value) {
|
|
253
|
+
return super.set(key.toLowerCase(), value);
|
|
254
|
+
}
|
|
255
|
+
get(key) {
|
|
256
|
+
return super.get(key.toLowerCase());
|
|
257
|
+
}
|
|
258
|
+
has(key) {
|
|
259
|
+
return super.has(key.toLowerCase());
|
|
260
|
+
}
|
|
261
|
+
remove(key) {
|
|
262
|
+
return super.remove(key.toLowerCase());
|
|
263
|
+
}
|
|
318
264
|
};
|
|
319
|
-
|
|
320
|
-
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/esp.ts
|
|
321
268
|
function espTime2Seconds(duration) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const sIndex = duration.indexOf("s");
|
|
338
|
-
if (sIndex !== -1 && duration.indexOf("days") === -1) {
|
|
339
|
-
return parseFloat(duration.substr(0, sIndex));
|
|
340
|
-
}
|
|
341
|
-
const dayTimeParts = duration.split(" days ");
|
|
342
|
-
const days = dayTimeParts.length > 1 ? parseFloat(dayTimeParts[0]) : 0;
|
|
343
|
-
const time = dayTimeParts.length > 1 ? dayTimeParts[1] : dayTimeParts[0];
|
|
344
|
-
let secs = 0;
|
|
345
|
-
const timeParts = time.split(":").reverse();
|
|
346
|
-
for (let j = 0; j < timeParts.length; ++j) {
|
|
347
|
-
secs += parseFloat(timeParts[j]) * Math.pow(60, j);
|
|
348
|
-
}
|
|
349
|
-
return days * 24 * 60 * 60 + secs;
|
|
269
|
+
if (!duration) return 0;
|
|
270
|
+
else if (!isNaN(Number(duration))) return Number(duration);
|
|
271
|
+
const nsIndex = duration.indexOf("ns");
|
|
272
|
+
if (nsIndex !== -1) return parseFloat(duration.substr(0, nsIndex)) / 1e9;
|
|
273
|
+
const msIndex = duration.indexOf("ms");
|
|
274
|
+
if (msIndex !== -1) return parseFloat(duration.substr(0, msIndex)) / 1e3;
|
|
275
|
+
const sIndex = duration.indexOf("s");
|
|
276
|
+
if (sIndex !== -1 && duration.indexOf("days") === -1) return parseFloat(duration.substr(0, sIndex));
|
|
277
|
+
const dayTimeParts = duration.split(" days ");
|
|
278
|
+
const days = dayTimeParts.length > 1 ? parseFloat(dayTimeParts[0]) : 0;
|
|
279
|
+
const time = dayTimeParts.length > 1 ? dayTimeParts[1] : dayTimeParts[0];
|
|
280
|
+
let secs = 0;
|
|
281
|
+
const timeParts = time.split(":").reverse();
|
|
282
|
+
for (let j = 0; j < timeParts.length; ++j) secs += parseFloat(timeParts[j]) * Math.pow(60, j);
|
|
283
|
+
return days * 24 * 60 * 60 + secs;
|
|
350
284
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
this._allEdges.splice(idx, 1);
|
|
588
|
-
delete this._allEdgesMap[this.idOf(edge)];
|
|
589
|
-
if (edge.parent) {
|
|
590
|
-
edge.parent._removeEdge(edge);
|
|
591
|
-
}
|
|
592
|
-
edge.source.removeOutEdge(edge);
|
|
593
|
-
edge.target.removeInEdge(edge);
|
|
594
|
-
}
|
|
595
|
-
get edges() {
|
|
596
|
-
return this._allEdges;
|
|
597
|
-
}
|
|
598
|
-
edge(id) {
|
|
599
|
-
return this._allEdgesMap[id];
|
|
600
|
-
}
|
|
601
|
-
_walk(parent, visitor) {
|
|
602
|
-
for (const subgraph of parent.subgraphs) {
|
|
603
|
-
switch (visitor(subgraph)) {
|
|
604
|
-
case "abort":
|
|
605
|
-
return true;
|
|
606
|
-
case "stepover":
|
|
607
|
-
break;
|
|
608
|
-
default:
|
|
609
|
-
if (this._walk(subgraph, visitor)) return true;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
for (const vertex of parent.vertices) {
|
|
613
|
-
if (visitor(vertex) === "abort") return true;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
walk(visitor) {
|
|
617
|
-
this._walk(this.root, visitor);
|
|
618
|
-
for (const edge of this._allEdges) {
|
|
619
|
-
if (visitor(edge) === "abort") return true;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
clone() {
|
|
623
|
-
const ctor = this.constructor;
|
|
624
|
-
const retVal = new ctor(this.idOf, this.root._);
|
|
625
|
-
const map = ObjMap();
|
|
626
|
-
map.put(this.root, retVal.root);
|
|
627
|
-
this.walk((item) => {
|
|
628
|
-
const parent = map.get(item.parent);
|
|
629
|
-
if (item instanceof Subgraph$1) {
|
|
630
|
-
map.put(item, parent.createSubgraph(item._));
|
|
631
|
-
} else if (item instanceof Vertex$1) {
|
|
632
|
-
map.put(item, parent.createVertex(item._));
|
|
633
|
-
} else if (item instanceof Edge$1) {
|
|
634
|
-
const source = map.get(item.source);
|
|
635
|
-
const target = map.get(item.target);
|
|
636
|
-
parent.createEdge(source, target, item._);
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
return retVal;
|
|
640
|
-
}
|
|
285
|
+
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/graph.ts
|
|
288
|
+
var GraphItem = class {
|
|
289
|
+
_graph;
|
|
290
|
+
parent;
|
|
291
|
+
props = {};
|
|
292
|
+
constructor(graph, parent) {
|
|
293
|
+
this._graph = graph;
|
|
294
|
+
this.parent = parent;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var Subgraph = class Subgraph extends GraphItem {
|
|
298
|
+
subgraphs = [];
|
|
299
|
+
vertices = [];
|
|
300
|
+
edges = [];
|
|
301
|
+
_;
|
|
302
|
+
constructor(graph, parent, _) {
|
|
303
|
+
super(graph, parent);
|
|
304
|
+
if (parent) parent._addSubgraph(this);
|
|
305
|
+
this._ = _;
|
|
306
|
+
}
|
|
307
|
+
remove(full = true) {
|
|
308
|
+
this._graph.removeSubgraph(this, full);
|
|
309
|
+
}
|
|
310
|
+
createSubgraph(_) {
|
|
311
|
+
return this._graph.createSubgraph(this, _);
|
|
312
|
+
}
|
|
313
|
+
_addSubgraph(subgraph) {
|
|
314
|
+
if (this.subgraphs.indexOf(subgraph) >= 0) throw new Error("Subgraph already exists");
|
|
315
|
+
this.subgraphs.push(subgraph);
|
|
316
|
+
}
|
|
317
|
+
_removeSubgraph(subgraph) {
|
|
318
|
+
const idx = this.subgraphs.indexOf(subgraph);
|
|
319
|
+
if (idx < 0) throw new Error("Subgraph does not exist");
|
|
320
|
+
this.subgraphs.splice(idx, 1);
|
|
321
|
+
}
|
|
322
|
+
removeAllSubgraphs() {
|
|
323
|
+
for (let i = this.subgraphs.length - 1; i >= 0; --i) this._graph.removeSubgraph(this.subgraphs[i], true);
|
|
324
|
+
}
|
|
325
|
+
createVertex(_) {
|
|
326
|
+
return this._graph.createVertex(this, _);
|
|
327
|
+
}
|
|
328
|
+
_addVertex(vertex) {
|
|
329
|
+
if (this.vertices.indexOf(vertex) >= 0) throw new Error("Vertex already exists");
|
|
330
|
+
this.vertices.push(vertex);
|
|
331
|
+
}
|
|
332
|
+
_removeVertex(vertex) {
|
|
333
|
+
const idx = this.vertices.indexOf(vertex);
|
|
334
|
+
if (idx < 0) throw new Error("Vertex does not exist");
|
|
335
|
+
this.vertices.splice(idx, 1);
|
|
336
|
+
}
|
|
337
|
+
removeAllVertices() {
|
|
338
|
+
for (let i = this.vertices.length - 1; i >= 0; --i) this._graph.removeVertex(this.vertices[i], true);
|
|
339
|
+
}
|
|
340
|
+
createEdge(source, target, _) {
|
|
341
|
+
return this._graph.createEdge(this, source, target, _);
|
|
342
|
+
}
|
|
343
|
+
_addEdge(edge) {
|
|
344
|
+
if (this.edges.indexOf(edge) >= 0) throw new Error("Edge already exists");
|
|
345
|
+
this.edges.push(edge);
|
|
346
|
+
}
|
|
347
|
+
_removeEdge(edge) {
|
|
348
|
+
const idx = this.edges.indexOf(edge);
|
|
349
|
+
if (idx < 0) throw new Error("Edge does not exist");
|
|
350
|
+
this.edges.splice(idx, 1);
|
|
351
|
+
}
|
|
352
|
+
_add(item) {
|
|
353
|
+
if (item instanceof Subgraph) this._addSubgraph(item);
|
|
354
|
+
else if (item instanceof Vertex) this._addVertex(item);
|
|
355
|
+
else this._addEdge(item);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var Vertex = class extends GraphItem {
|
|
359
|
+
inEdges = [];
|
|
360
|
+
outEdges = [];
|
|
361
|
+
get edges() {
|
|
362
|
+
return [...this.inEdges, ...this.outEdges];
|
|
363
|
+
}
|
|
364
|
+
_;
|
|
365
|
+
constructor(graph, parent, _) {
|
|
366
|
+
super(graph, parent);
|
|
367
|
+
parent._addVertex(this);
|
|
368
|
+
this._ = _;
|
|
369
|
+
}
|
|
370
|
+
remove(full = true, _) {
|
|
371
|
+
return this._graph.removeVertex(this, full, _);
|
|
372
|
+
}
|
|
373
|
+
addInEdge(edge) {
|
|
374
|
+
this.inEdges.push(edge);
|
|
375
|
+
}
|
|
376
|
+
removeInEdge(edge) {
|
|
377
|
+
const idx = this.inEdges.indexOf(edge);
|
|
378
|
+
if (idx < 0) throw new Error("In edge does not exist");
|
|
379
|
+
this.inEdges.splice(idx, 1);
|
|
380
|
+
}
|
|
381
|
+
addOutEdge(edge) {
|
|
382
|
+
this.outEdges.push(edge);
|
|
383
|
+
}
|
|
384
|
+
removeOutEdge(edge) {
|
|
385
|
+
const idx = this.outEdges.indexOf(edge);
|
|
386
|
+
if (idx < 0) throw new Error("Out edge does not exist");
|
|
387
|
+
this.outEdges.splice(idx, 1);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
var Edge = class extends GraphItem {
|
|
391
|
+
source;
|
|
392
|
+
target;
|
|
393
|
+
_;
|
|
394
|
+
constructor(graph, parent, source, target, _) {
|
|
395
|
+
super(graph, parent);
|
|
396
|
+
if (!source) throw new Error("Missing source vertex");
|
|
397
|
+
if (!target) throw new Error("Missing target vertex");
|
|
398
|
+
parent._addEdge(this);
|
|
399
|
+
this.source = source;
|
|
400
|
+
this.source.addOutEdge(this);
|
|
401
|
+
this.target = target;
|
|
402
|
+
this.target.addInEdge(this);
|
|
403
|
+
this._ = _;
|
|
404
|
+
}
|
|
405
|
+
remove() {
|
|
406
|
+
this._graph.removeEdge(this);
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var Graph = class {
|
|
410
|
+
root;
|
|
411
|
+
_allSubgraphs = [];
|
|
412
|
+
_allSubgraphsMap = {};
|
|
413
|
+
_allVertices = [];
|
|
414
|
+
_allVerticesMap = {};
|
|
415
|
+
_allEdges = [];
|
|
416
|
+
_allEdgesMap = {};
|
|
417
|
+
idOf;
|
|
418
|
+
constructor(idOf = (item) => "" + item._, _) {
|
|
419
|
+
this.root = new Subgraph(this, null, _);
|
|
420
|
+
this.idOf = idOf;
|
|
421
|
+
}
|
|
422
|
+
createSubgraph(parent, _) {
|
|
423
|
+
const retVal = new Subgraph(this, parent || this.root, _);
|
|
424
|
+
this._allSubgraphs.push(retVal);
|
|
425
|
+
this._allSubgraphsMap[this.idOf(retVal)] = retVal;
|
|
426
|
+
return retVal;
|
|
427
|
+
}
|
|
428
|
+
removeSubgraph(subgraph, full = true) {
|
|
429
|
+
const idx = this._allSubgraphs.indexOf(subgraph);
|
|
430
|
+
if (idx < 0) throw new Error("Subgraph does not exist");
|
|
431
|
+
this._allSubgraphs.splice(idx, 1);
|
|
432
|
+
delete this._allSubgraphsMap[this.idOf(subgraph)];
|
|
433
|
+
if (subgraph.parent) subgraph.parent._removeSubgraph(subgraph);
|
|
434
|
+
subgraph.edges.forEach((edge) => full ? this.removeEdge(edge) : subgraph.parent._addEdge(edge));
|
|
435
|
+
subgraph.vertices.forEach((vertex) => full ? this.removeVertex(vertex, full) : subgraph.parent._addVertex(vertex));
|
|
436
|
+
subgraph.subgraphs.forEach((childSubgraph) => full ? this.removeSubgraph(childSubgraph, full) : subgraph.parent._addSubgraph(childSubgraph));
|
|
437
|
+
}
|
|
438
|
+
get subgraphs() {
|
|
439
|
+
return this._allSubgraphs;
|
|
440
|
+
}
|
|
441
|
+
subgraph(id) {
|
|
442
|
+
return this._allSubgraphsMap[id];
|
|
443
|
+
}
|
|
444
|
+
createVertex(parent, _) {
|
|
445
|
+
const retVal = new Vertex(this, parent, _);
|
|
446
|
+
this._allVertices.push(retVal);
|
|
447
|
+
this._allVerticesMap[this.idOf(retVal)] = retVal;
|
|
448
|
+
return retVal;
|
|
449
|
+
}
|
|
450
|
+
removeVertex(vertex, full = true, _) {
|
|
451
|
+
const idx = this._allVertices.indexOf(vertex);
|
|
452
|
+
if (idx < 0) throw new Error("Vertex does not exist");
|
|
453
|
+
this._allVertices.splice(idx, 1);
|
|
454
|
+
delete this._allVerticesMap[this.idOf(vertex)];
|
|
455
|
+
if (vertex.parent) vertex.parent._removeVertex(vertex);
|
|
456
|
+
if (!full) vertex.inEdges.forEach((inEdge) => {
|
|
457
|
+
vertex.outEdges.forEach((outEdge) => {
|
|
458
|
+
this.createEdge(this.root, inEdge.source, outEdge.target, _ ? _(inEdge.source._, outEdge.target._) : void 0);
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
vertex.inEdges.forEach((edge) => this.removeEdge(edge));
|
|
462
|
+
vertex.outEdges.forEach((edge) => this.removeEdge(edge));
|
|
463
|
+
}
|
|
464
|
+
get vertices() {
|
|
465
|
+
return this._allVertices;
|
|
466
|
+
}
|
|
467
|
+
vertex(id) {
|
|
468
|
+
return this._allVerticesMap[id];
|
|
469
|
+
}
|
|
470
|
+
createEdge(parent, source, target, _) {
|
|
471
|
+
const retVal = new Edge(this, parent, source, target, _);
|
|
472
|
+
this._allEdges.push(retVal);
|
|
473
|
+
this._allEdgesMap[this.idOf(retVal)] = retVal;
|
|
474
|
+
return retVal;
|
|
475
|
+
}
|
|
476
|
+
removeEdge(edge) {
|
|
477
|
+
const idx = this._allEdges.indexOf(edge);
|
|
478
|
+
if (idx < 0) throw new Error("Edge does not exist");
|
|
479
|
+
this._allEdges.splice(idx, 1);
|
|
480
|
+
delete this._allEdgesMap[this.idOf(edge)];
|
|
481
|
+
if (edge.parent) edge.parent._removeEdge(edge);
|
|
482
|
+
edge.source.removeOutEdge(edge);
|
|
483
|
+
edge.target.removeInEdge(edge);
|
|
484
|
+
}
|
|
485
|
+
get edges() {
|
|
486
|
+
return this._allEdges;
|
|
487
|
+
}
|
|
488
|
+
edge(id) {
|
|
489
|
+
return this._allEdgesMap[id];
|
|
490
|
+
}
|
|
491
|
+
_walk(parent, visitor) {
|
|
492
|
+
for (const subgraph of parent.subgraphs) switch (visitor(subgraph)) {
|
|
493
|
+
case "abort": return true;
|
|
494
|
+
case "stepover": break;
|
|
495
|
+
default: if (this._walk(subgraph, visitor)) return true;
|
|
496
|
+
}
|
|
497
|
+
for (const vertex of parent.vertices) if (visitor(vertex) === "abort") return true;
|
|
498
|
+
}
|
|
499
|
+
walk(visitor) {
|
|
500
|
+
this._walk(this.root, visitor);
|
|
501
|
+
for (const edge of this._allEdges) if (visitor(edge) === "abort") return true;
|
|
502
|
+
}
|
|
503
|
+
clone() {
|
|
504
|
+
const ctor = this.constructor;
|
|
505
|
+
const retVal = new ctor(this.idOf, this.root._);
|
|
506
|
+
const map = ObjMap();
|
|
507
|
+
map.put(this.root, retVal.root);
|
|
508
|
+
this.walk((item) => {
|
|
509
|
+
const parent = map.get(item.parent);
|
|
510
|
+
if (item instanceof Subgraph) map.put(item, parent.createSubgraph(item._));
|
|
511
|
+
else if (item instanceof Vertex) map.put(item, parent.createVertex(item._));
|
|
512
|
+
else if (item instanceof Edge) {
|
|
513
|
+
const source = map.get(item.source);
|
|
514
|
+
const target = map.get(item.target);
|
|
515
|
+
parent.createEdge(source, target, item._);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
return retVal;
|
|
519
|
+
}
|
|
641
520
|
};
|
|
642
|
-
__name(_Graph, "Graph");
|
|
643
|
-
let Graph = _Graph;
|
|
644
521
|
function ObjMap() {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
};
|
|
522
|
+
const keys = [];
|
|
523
|
+
const values = [];
|
|
524
|
+
return {
|
|
525
|
+
put(key, value) {
|
|
526
|
+
const index = keys.indexOf(key);
|
|
527
|
+
if (index === -1) {
|
|
528
|
+
keys.push(key);
|
|
529
|
+
values.push(value);
|
|
530
|
+
} else values[index] = value;
|
|
531
|
+
},
|
|
532
|
+
get(key) {
|
|
533
|
+
return values[keys.indexOf(key)];
|
|
534
|
+
}
|
|
535
|
+
};
|
|
661
536
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
537
|
+
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/graph2.ts
|
|
540
|
+
var GraphItem$1 = class {
|
|
541
|
+
_graph;
|
|
542
|
+
_;
|
|
543
|
+
id() {
|
|
544
|
+
return this._graph.id(this._);
|
|
545
|
+
}
|
|
546
|
+
constructor(g, _) {
|
|
547
|
+
this._graph = g;
|
|
548
|
+
this._ = _;
|
|
549
|
+
}
|
|
673
550
|
};
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
if (this._parent) {
|
|
696
|
-
this._parent.addChild(this);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return this;
|
|
700
|
-
}
|
|
551
|
+
var ChildGraphItem = class extends GraphItem$1 {
|
|
552
|
+
_parent;
|
|
553
|
+
constructor(g, _) {
|
|
554
|
+
super(g, _);
|
|
555
|
+
}
|
|
556
|
+
clearParent() {
|
|
557
|
+
if (this._parent) {
|
|
558
|
+
this._parent.removeChild(this);
|
|
559
|
+
delete this._parent;
|
|
560
|
+
}
|
|
561
|
+
return this;
|
|
562
|
+
}
|
|
563
|
+
parent(_) {
|
|
564
|
+
if (arguments.length === 0) return this._parent;
|
|
565
|
+
if (this._parent !== _) {
|
|
566
|
+
if (this._parent) this._parent.removeChild(this);
|
|
567
|
+
this._parent = _;
|
|
568
|
+
if (this._parent) this._parent.addChild(this);
|
|
569
|
+
}
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
701
572
|
};
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
this._children = this._children.filter((row) => row.id !== _.id);
|
|
717
|
-
}
|
|
573
|
+
var Subgraph$1 = class extends ChildGraphItem {
|
|
574
|
+
_children = [];
|
|
575
|
+
constructor(g, _) {
|
|
576
|
+
super(g, _);
|
|
577
|
+
}
|
|
578
|
+
children() {
|
|
579
|
+
return this._children;
|
|
580
|
+
}
|
|
581
|
+
addChild(_) {
|
|
582
|
+
this._children.push(_);
|
|
583
|
+
}
|
|
584
|
+
removeChild(_) {
|
|
585
|
+
this._children = this._children.filter((row) => row.id !== _.id);
|
|
586
|
+
}
|
|
718
587
|
};
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
this._outEdges = this._outEdges.filter((e) => e._.id !== id);
|
|
750
|
-
}
|
|
588
|
+
var Vertex$1 = class extends ChildGraphItem {
|
|
589
|
+
_inEdges = [];
|
|
590
|
+
_outEdges = [];
|
|
591
|
+
constructor(g, _) {
|
|
592
|
+
super(g, _);
|
|
593
|
+
}
|
|
594
|
+
edges() {
|
|
595
|
+
return [...this._inEdges, ...this._outEdges];
|
|
596
|
+
}
|
|
597
|
+
edgeCount() {
|
|
598
|
+
return this._outEdges.length + this._inEdges.length;
|
|
599
|
+
}
|
|
600
|
+
inEdges() {
|
|
601
|
+
return this._inEdges;
|
|
602
|
+
}
|
|
603
|
+
addInEdge(e) {
|
|
604
|
+
this._inEdges.push(e);
|
|
605
|
+
}
|
|
606
|
+
removeInEdge(id) {
|
|
607
|
+
this._inEdges = this._inEdges.filter((e) => e._.id !== id);
|
|
608
|
+
}
|
|
609
|
+
outEdges() {
|
|
610
|
+
return this._outEdges;
|
|
611
|
+
}
|
|
612
|
+
addOutEdge(e) {
|
|
613
|
+
this._outEdges.push(e);
|
|
614
|
+
}
|
|
615
|
+
removeOutEdge(id) {
|
|
616
|
+
this._outEdges = this._outEdges.filter((e) => e._.id !== id);
|
|
617
|
+
}
|
|
751
618
|
};
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
this._target = target;
|
|
761
|
-
}
|
|
619
|
+
var Edge$1 = class extends ChildGraphItem {
|
|
620
|
+
_source;
|
|
621
|
+
_target;
|
|
622
|
+
constructor(g, _, source, target) {
|
|
623
|
+
super(g, _);
|
|
624
|
+
this._source = source;
|
|
625
|
+
this._target = target;
|
|
626
|
+
}
|
|
762
627
|
};
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
for (const v of neighbors) {
|
|
1159
|
-
const alt = dist[u2] + adj[u2][v];
|
|
1160
|
-
if (alt < dist[v]) {
|
|
1161
|
-
dist[v] = alt;
|
|
1162
|
-
prev[v] = u2;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
let u = target;
|
|
1167
|
-
const ids = [u];
|
|
1168
|
-
let len = 0;
|
|
1169
|
-
while (prev[u] !== void 0) {
|
|
1170
|
-
ids.unshift(prev[u]);
|
|
1171
|
-
len += adj[u][prev[u]];
|
|
1172
|
-
u = prev[u];
|
|
1173
|
-
}
|
|
1174
|
-
return { ids, len };
|
|
1175
|
-
}
|
|
1176
|
-
sort(v_id) {
|
|
1177
|
-
const retVal = [];
|
|
1178
|
-
const visited = {};
|
|
1179
|
-
const visit = /* @__PURE__ */ __name((vertex, ancestors = []) => {
|
|
1180
|
-
const v_id2 = vertex.id();
|
|
1181
|
-
if (visited[v_id2]) return;
|
|
1182
|
-
visited[v_id2] = true;
|
|
1183
|
-
ancestors.push(vertex);
|
|
1184
|
-
vertex.outEdges().forEach((e) => {
|
|
1185
|
-
if (ancestors.indexOf(e._target) < 0) {
|
|
1186
|
-
visit(e._target, [...ancestors]);
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
retVal.unshift(vertex._);
|
|
1190
|
-
}, "visit");
|
|
1191
|
-
if (v_id) {
|
|
1192
|
-
visit(this._vertexMap[v_id]);
|
|
1193
|
-
} else {
|
|
1194
|
-
for (const key in this._vertexMap) {
|
|
1195
|
-
visit(this._vertexMap[key]);
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
return retVal;
|
|
1199
|
-
}
|
|
628
|
+
var Graph2 = class {
|
|
629
|
+
_directed;
|
|
630
|
+
_subgraphMap = {};
|
|
631
|
+
_vertexMap = {};
|
|
632
|
+
_edgeMap = {};
|
|
633
|
+
constructor(directed = true) {
|
|
634
|
+
this._directed = directed;
|
|
635
|
+
}
|
|
636
|
+
clear() {
|
|
637
|
+
this._subgraphMap = {};
|
|
638
|
+
this._vertexMap = {};
|
|
639
|
+
this._edgeMap = {};
|
|
640
|
+
return this;
|
|
641
|
+
}
|
|
642
|
+
clearParents() {
|
|
643
|
+
for (const key in this._subgraphMap) this._subgraphMap[key].clearParent();
|
|
644
|
+
for (const key in this._vertexMap) this._vertexMap[key].clearParent();
|
|
645
|
+
return this;
|
|
646
|
+
}
|
|
647
|
+
isDirected() {
|
|
648
|
+
return this._directed;
|
|
649
|
+
}
|
|
650
|
+
_idFunc = (_) => typeof _.id === "function" ? _.id() : _.id;
|
|
651
|
+
idFunc(_) {
|
|
652
|
+
this._idFunc = _;
|
|
653
|
+
return this;
|
|
654
|
+
}
|
|
655
|
+
_sourceFunc = (_) => typeof _.source === "function" ? _.source() : _.source;
|
|
656
|
+
sourceFunc(_) {
|
|
657
|
+
this._sourceFunc = _;
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
_targetFunc = (_) => typeof _.target === "function" ? _.target() : _.target;
|
|
661
|
+
targetFunc(_) {
|
|
662
|
+
this._targetFunc = _;
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
_updateFunc = (before, after) => after;
|
|
666
|
+
updateFunc(_) {
|
|
667
|
+
this._updateFunc = _;
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
id(_) {
|
|
671
|
+
return this._idFunc(_);
|
|
672
|
+
}
|
|
673
|
+
type(id) {
|
|
674
|
+
if (this.subgraphExists(id)) return "S";
|
|
675
|
+
if (this.vertexExists(id)) return "V";
|
|
676
|
+
if (this.edgeExists(id)) return "E";
|
|
677
|
+
return "";
|
|
678
|
+
}
|
|
679
|
+
isSubgraph(_) {
|
|
680
|
+
return this.subgraphExists(this.id(_));
|
|
681
|
+
}
|
|
682
|
+
isVertex(_) {
|
|
683
|
+
return this.vertexExists(this.id(_));
|
|
684
|
+
}
|
|
685
|
+
isEdge(_) {
|
|
686
|
+
return this.edgeExists(this.id(_));
|
|
687
|
+
}
|
|
688
|
+
allItems() {
|
|
689
|
+
return [
|
|
690
|
+
...this.allSubgraphs(),
|
|
691
|
+
...this.allVertices(),
|
|
692
|
+
...this.allEdges()
|
|
693
|
+
];
|
|
694
|
+
}
|
|
695
|
+
item(id) {
|
|
696
|
+
if (this.subgraphExists(id)) return this.subgraph(id);
|
|
697
|
+
if (this.vertexExists(id)) return this.vertex(id);
|
|
698
|
+
if (this.edgeExists(id)) return this.edge(id);
|
|
699
|
+
}
|
|
700
|
+
itemExists(id) {
|
|
701
|
+
return this.edgeExists(id) || this.vertexExists(id) || this.subgraphExists(id);
|
|
702
|
+
}
|
|
703
|
+
allSubgraphs() {
|
|
704
|
+
const retVal = [];
|
|
705
|
+
for (const key in this._subgraphMap) retVal.push(this._subgraphMap[key]._);
|
|
706
|
+
return retVal;
|
|
707
|
+
}
|
|
708
|
+
subgraphs() {
|
|
709
|
+
const retVal = [];
|
|
710
|
+
for (const key in this._subgraphMap) if (this._subgraphMap[key].parent() === void 0) retVal.push(this._subgraphMap[key]._);
|
|
711
|
+
return retVal;
|
|
712
|
+
}
|
|
713
|
+
subgraphExists(id) {
|
|
714
|
+
return !!this._subgraphMap[id];
|
|
715
|
+
}
|
|
716
|
+
subgraph(id) {
|
|
717
|
+
return this._subgraphMap[id]._;
|
|
718
|
+
}
|
|
719
|
+
subgraphSubgraphs(id) {
|
|
720
|
+
return this._subgraphMap[id].children().filter((child) => this.isSubgraph(child._)).map((child) => child._);
|
|
721
|
+
}
|
|
722
|
+
subgraphVertices(id) {
|
|
723
|
+
return this._subgraphMap[id].children().filter((child) => this.isVertex(child._)).map((child) => child._);
|
|
724
|
+
}
|
|
725
|
+
subgraphEdges(id) {
|
|
726
|
+
return this._subgraphMap[id].children().filter((child) => this.isEdge(child._)).map((child) => child._);
|
|
727
|
+
}
|
|
728
|
+
addSubgraph(s, parent) {
|
|
729
|
+
const s_id = this._idFunc(s);
|
|
730
|
+
if (this._subgraphMap[s_id]) throw new Error(`Subgraph '${s_id}' already exists.`);
|
|
731
|
+
const subgraph = new Subgraph$1(this, s);
|
|
732
|
+
if (parent) {
|
|
733
|
+
const p_id = this._idFunc(parent);
|
|
734
|
+
if (!this._subgraphMap[p_id]) throw new Error(`Subgraph '${p_id}' does not exist.`);
|
|
735
|
+
subgraph.parent(this._subgraphMap[p_id]);
|
|
736
|
+
}
|
|
737
|
+
this._subgraphMap[s_id] = subgraph;
|
|
738
|
+
return this;
|
|
739
|
+
}
|
|
740
|
+
mergeSubgraphs(_subgraphs = []) {
|
|
741
|
+
const sgDiff = compare2(this.allSubgraphs(), _subgraphs, (sg) => this._idFunc(sg), this._updateFunc);
|
|
742
|
+
sgDiff.exit.forEach((sg) => this.removeSubgraph(this._idFunc(sg)));
|
|
743
|
+
sgDiff.enter.forEach((sg) => this.addSubgraph(sg));
|
|
744
|
+
sgDiff.update.forEach((sg) => this.updateSubgraph(sg));
|
|
745
|
+
return this;
|
|
746
|
+
}
|
|
747
|
+
updateSubgraph(sg) {
|
|
748
|
+
const sg_id = this._idFunc(sg);
|
|
749
|
+
const subgraph = this._subgraphMap[sg_id];
|
|
750
|
+
if (!subgraph) throw new Error(`Subgraph '${sg_id}' does not exist.`);
|
|
751
|
+
subgraph._ = sg;
|
|
752
|
+
return this;
|
|
753
|
+
}
|
|
754
|
+
removeSubgraph(id, promoteChildren = true) {
|
|
755
|
+
const sg = this._subgraphMap[id];
|
|
756
|
+
if (!sg) throw new Error(`Subgraph '${id}' does not exist.`);
|
|
757
|
+
sg.children().forEach((child) => {
|
|
758
|
+
if (promoteChildren) child.parent(sg.parent());
|
|
759
|
+
else if (child instanceof Subgraph$1) this.removeSubgraph(child.id());
|
|
760
|
+
else this.removeVertex(child.id());
|
|
761
|
+
});
|
|
762
|
+
delete this._subgraphMap[id];
|
|
763
|
+
return this;
|
|
764
|
+
}
|
|
765
|
+
subgraphParent(id, parentID) {
|
|
766
|
+
const item = this._subgraphMap[id];
|
|
767
|
+
if (!item) throw new Error(`Subgraph '${id}' does not exist.`);
|
|
768
|
+
if (parentID === void 0) {
|
|
769
|
+
const parent$1 = item.parent();
|
|
770
|
+
return parent$1 ? parent$1._ : void 0;
|
|
771
|
+
}
|
|
772
|
+
const parent = this._subgraphMap[parentID];
|
|
773
|
+
if (!parent) throw new Error(`Vertex parent '${parent}' does not exist.`);
|
|
774
|
+
item.parent(parent);
|
|
775
|
+
return this;
|
|
776
|
+
}
|
|
777
|
+
allVertices() {
|
|
778
|
+
const retVal = [];
|
|
779
|
+
for (const key in this._vertexMap) retVal.push(this._vertexMap[key]._);
|
|
780
|
+
return retVal;
|
|
781
|
+
}
|
|
782
|
+
vertices() {
|
|
783
|
+
const retVal = [];
|
|
784
|
+
for (const key in this._vertexMap) if (this._vertexMap[key].parent() === void 0) retVal.push(this._vertexMap[key]._);
|
|
785
|
+
return retVal;
|
|
786
|
+
}
|
|
787
|
+
vertexExists(id) {
|
|
788
|
+
return !!this._vertexMap[id];
|
|
789
|
+
}
|
|
790
|
+
vertex(id) {
|
|
791
|
+
return this._vertexMap[id]._;
|
|
792
|
+
}
|
|
793
|
+
allEdges() {
|
|
794
|
+
const retVal = [];
|
|
795
|
+
for (const key in this._edgeMap) retVal.push(this._edgeMap[key]._);
|
|
796
|
+
return retVal;
|
|
797
|
+
}
|
|
798
|
+
edges() {
|
|
799
|
+
const retVal = [];
|
|
800
|
+
for (const key in this._edgeMap) if (this._edgeMap[key].parent() === void 0) retVal.push(this._edgeMap[key]._);
|
|
801
|
+
return retVal;
|
|
802
|
+
}
|
|
803
|
+
vertexEdges(vertexID) {
|
|
804
|
+
return this._vertexMap[vertexID].edges().map((e) => e._);
|
|
805
|
+
}
|
|
806
|
+
inEdges(vertexID) {
|
|
807
|
+
return this._vertexMap[vertexID].inEdges().map((e) => e._);
|
|
808
|
+
}
|
|
809
|
+
outEdges(vertexID) {
|
|
810
|
+
return this._vertexMap[vertexID].outEdges().map((e) => e._);
|
|
811
|
+
}
|
|
812
|
+
_neighbors(id) {
|
|
813
|
+
return [...this._vertexMap[id].outEdges().map((e) => e._target), ...this._vertexMap[id].inEdges().map((e) => e._source)];
|
|
814
|
+
}
|
|
815
|
+
neighbors(id) {
|
|
816
|
+
return this._neighbors(id).map((n) => n._);
|
|
817
|
+
}
|
|
818
|
+
singleNeighbors(id) {
|
|
819
|
+
return this._neighbors(id).filter((n) => n.edgeCount() === 1).map((n) => n._);
|
|
820
|
+
}
|
|
821
|
+
addVertex(v, parent) {
|
|
822
|
+
const v_id = this._idFunc(v);
|
|
823
|
+
if (this._vertexMap[v_id]) throw new Error(`Vertex '${v_id}' already exists.`);
|
|
824
|
+
const vertex = new Vertex$1(this, v);
|
|
825
|
+
if (parent) {
|
|
826
|
+
const p_id = this._idFunc(parent);
|
|
827
|
+
if (!this.subgraphExists(p_id)) throw new Error(`Subgraph '${p_id}' does not exist.`);
|
|
828
|
+
vertex.parent(this._subgraphMap[p_id]);
|
|
829
|
+
}
|
|
830
|
+
this._vertexMap[v_id] = vertex;
|
|
831
|
+
return this;
|
|
832
|
+
}
|
|
833
|
+
mergeVertices(_vertices) {
|
|
834
|
+
const vDiff = compare2(this.allVertices(), _vertices, (v) => this._idFunc(v), this._updateFunc);
|
|
835
|
+
vDiff.exit.forEach((v) => this.removeVertex(this._idFunc(v)));
|
|
836
|
+
vDiff.enter.forEach((v) => this.addVertex(v));
|
|
837
|
+
vDiff.update.forEach((v) => this.updateVertex(v));
|
|
838
|
+
return this;
|
|
839
|
+
}
|
|
840
|
+
updateVertex(v) {
|
|
841
|
+
const v_id = this._idFunc(v);
|
|
842
|
+
const vertex = this._vertexMap[v_id];
|
|
843
|
+
if (!vertex) throw new Error(`Vertex '${v_id}' does not exist.`);
|
|
844
|
+
vertex._ = v;
|
|
845
|
+
return this;
|
|
846
|
+
}
|
|
847
|
+
removeVertex(id) {
|
|
848
|
+
const v = this._vertexMap[id];
|
|
849
|
+
if (!v) throw new Error(`Vertex '${id}' does not exist.`);
|
|
850
|
+
v.edges().forEach((e) => {
|
|
851
|
+
this.removeEdge(e.id());
|
|
852
|
+
});
|
|
853
|
+
delete this._vertexMap[id];
|
|
854
|
+
return this;
|
|
855
|
+
}
|
|
856
|
+
vertexParent(id, parentID) {
|
|
857
|
+
const item = this._vertexMap[id];
|
|
858
|
+
if (!item) throw new Error(`Vertex '${id}' does not exist.`);
|
|
859
|
+
if (parentID === void 0) {
|
|
860
|
+
const parent$1 = item.parent();
|
|
861
|
+
return parent$1 ? parent$1._ : void 0;
|
|
862
|
+
}
|
|
863
|
+
const parent = this._subgraphMap[parentID];
|
|
864
|
+
if (!parent) throw new Error(`Vertex parent '${parent}' does not exist.`);
|
|
865
|
+
item.parent(parent);
|
|
866
|
+
return this;
|
|
867
|
+
}
|
|
868
|
+
edgeExists(id) {
|
|
869
|
+
return !!this._edgeMap[id];
|
|
870
|
+
}
|
|
871
|
+
edge(id) {
|
|
872
|
+
return this._edgeMap[id]._;
|
|
873
|
+
}
|
|
874
|
+
addEdge(e, parent) {
|
|
875
|
+
const e_id = this._idFunc(e);
|
|
876
|
+
const e_source = this._sourceFunc(e);
|
|
877
|
+
const e_target = this._targetFunc(e);
|
|
878
|
+
if (this._edgeMap[e_id]) throw new Error(`Edge '${e_id}' already exists.`);
|
|
879
|
+
if (!this.vertexExists(e_source)) throw new Error(`Edge Source '${e_source}' does not exist.`);
|
|
880
|
+
if (!this.vertexExists(e_target)) throw new Error(`Edge Target '${e_target}' does not exist.`);
|
|
881
|
+
const edge = new Edge$1(this, e, this._vertexMap[e_source], this._vertexMap[e_target]);
|
|
882
|
+
if (parent) {
|
|
883
|
+
const p_id = this._idFunc(parent);
|
|
884
|
+
if (!this.subgraphExists(p_id)) throw new Error(`Subgraph '${p_id}' does not exist.`);
|
|
885
|
+
edge.parent(this._subgraphMap[p_id]);
|
|
886
|
+
}
|
|
887
|
+
this._edgeMap[e_id] = edge;
|
|
888
|
+
this._vertexMap[e_source].addOutEdge(edge);
|
|
889
|
+
this._vertexMap[e_target].addInEdge(edge);
|
|
890
|
+
return this;
|
|
891
|
+
}
|
|
892
|
+
mergeEdges(_edges) {
|
|
893
|
+
const eDiff = compare2(this.allEdges(), _edges, (e) => this._idFunc(e), this._updateFunc);
|
|
894
|
+
eDiff.exit.forEach((e) => this.removeEdge(this._idFunc(e)));
|
|
895
|
+
eDiff.enter.forEach((e) => this.addEdge(e));
|
|
896
|
+
eDiff.update.forEach((e) => this.updateEdge(e));
|
|
897
|
+
return this;
|
|
898
|
+
}
|
|
899
|
+
updateEdge(e) {
|
|
900
|
+
const e_id = this._idFunc(e);
|
|
901
|
+
const edge = this._edgeMap[e_id];
|
|
902
|
+
if (!edge) throw new Error(`Edge '${e_id}' does not exist.`);
|
|
903
|
+
const old_source = edge._source.id();
|
|
904
|
+
const new_source = this._sourceFunc(e);
|
|
905
|
+
if (old_source !== new_source) {
|
|
906
|
+
this._vertexMap[old_source]?.removeOutEdge(e_id);
|
|
907
|
+
this._vertexMap[new_source]?.addOutEdge(edge);
|
|
908
|
+
}
|
|
909
|
+
const old_target = edge._target.id();
|
|
910
|
+
const new_target = this._targetFunc(e);
|
|
911
|
+
if (old_target !== new_target) {
|
|
912
|
+
this._vertexMap[old_target]?.removeInEdge(e_id);
|
|
913
|
+
this._vertexMap[new_target]?.addInEdge(edge);
|
|
914
|
+
}
|
|
915
|
+
edge._ = e;
|
|
916
|
+
edge._source = this._vertexMap[new_source];
|
|
917
|
+
edge._target = this._vertexMap[new_target];
|
|
918
|
+
return this;
|
|
919
|
+
}
|
|
920
|
+
removeEdge(id) {
|
|
921
|
+
const e = this._edgeMap[id];
|
|
922
|
+
if (!e) throw new Error(`Edge '${id}' does not exist.`);
|
|
923
|
+
const e_sourceID = this._idFunc(e._source._);
|
|
924
|
+
if (!this.vertexExists(e_sourceID)) throw new Error(`Edge Source'${e_sourceID}' does not exist.`);
|
|
925
|
+
this._vertexMap[e_sourceID].removeOutEdge(id);
|
|
926
|
+
const e_targetID = this._idFunc(e._target._);
|
|
927
|
+
if (!this.vertexExists(e_targetID)) throw new Error(`Edge Target'${e_targetID}' does not exist.`);
|
|
928
|
+
this._vertexMap[e_targetID].removeInEdge(id);
|
|
929
|
+
delete this._edgeMap[id];
|
|
930
|
+
return this;
|
|
931
|
+
}
|
|
932
|
+
_hwalk(item, formatter) {
|
|
933
|
+
if (item instanceof Subgraph$1) return formatter("subgraph", item._, item.children().map((child) => this._hwalk(child, formatter)));
|
|
934
|
+
else return formatter("vertex", item._);
|
|
935
|
+
}
|
|
936
|
+
hierarchy(formatter) {
|
|
937
|
+
const retVal = [];
|
|
938
|
+
for (const id in this._subgraphMap) {
|
|
939
|
+
const sg = this._subgraphMap[id];
|
|
940
|
+
if (sg.parent() === void 0) retVal.push(this._hwalk(sg, formatter));
|
|
941
|
+
}
|
|
942
|
+
for (const id in this._vertexMap) {
|
|
943
|
+
const v = this._vertexMap[id];
|
|
944
|
+
if (v.parent() === void 0) retVal.push(this._hwalk(v, formatter));
|
|
945
|
+
}
|
|
946
|
+
return retVal;
|
|
947
|
+
}
|
|
948
|
+
dijkstra(source, target) {
|
|
949
|
+
const edges = this.allEdges();
|
|
950
|
+
const Q = new Set();
|
|
951
|
+
const prev = {};
|
|
952
|
+
const dist = {};
|
|
953
|
+
const adj = {};
|
|
954
|
+
function vertex_with_min_dist(Q$1, dist$1) {
|
|
955
|
+
let min_distance = Infinity;
|
|
956
|
+
let u$1 = null;
|
|
957
|
+
Q$1.forEach((v) => {
|
|
958
|
+
if (dist$1[v] < min_distance) {
|
|
959
|
+
min_distance = dist$1[v];
|
|
960
|
+
u$1 = v;
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
return u$1;
|
|
964
|
+
}
|
|
965
|
+
for (let i = 0; i < edges.length; i++) {
|
|
966
|
+
const v1 = this._sourceFunc(edges[i]);
|
|
967
|
+
const v2 = this._targetFunc(edges[i]);
|
|
968
|
+
const len$1 = 1;
|
|
969
|
+
Q.add(v1);
|
|
970
|
+
Q.add(v2);
|
|
971
|
+
dist[v1] = Infinity;
|
|
972
|
+
dist[v2] = Infinity;
|
|
973
|
+
if (adj[v1] === void 0) adj[v1] = {};
|
|
974
|
+
if (adj[v2] === void 0) adj[v2] = {};
|
|
975
|
+
adj[v1][v2] = len$1;
|
|
976
|
+
adj[v2][v1] = len$1;
|
|
977
|
+
}
|
|
978
|
+
dist[source] = 0;
|
|
979
|
+
while (Q.size) {
|
|
980
|
+
const u$1 = vertex_with_min_dist(Q, dist);
|
|
981
|
+
if (u$1 === null) break;
|
|
982
|
+
const neighbors = Object.keys(adj[u$1]).filter((v) => Q.has(v));
|
|
983
|
+
Q.delete(u$1);
|
|
984
|
+
if (u$1 === target) break;
|
|
985
|
+
for (const v of neighbors) {
|
|
986
|
+
const alt = dist[u$1] + adj[u$1][v];
|
|
987
|
+
if (alt < dist[v]) {
|
|
988
|
+
dist[v] = alt;
|
|
989
|
+
prev[v] = u$1;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
let u = target;
|
|
994
|
+
const ids = [u];
|
|
995
|
+
let len = 0;
|
|
996
|
+
while (prev[u] !== void 0) {
|
|
997
|
+
ids.unshift(prev[u]);
|
|
998
|
+
len += adj[u][prev[u]];
|
|
999
|
+
u = prev[u];
|
|
1000
|
+
}
|
|
1001
|
+
return {
|
|
1002
|
+
ids,
|
|
1003
|
+
len
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
sort(v_id) {
|
|
1007
|
+
const retVal = [];
|
|
1008
|
+
const visited = {};
|
|
1009
|
+
const visit = (vertex, ancestors = []) => {
|
|
1010
|
+
const v_id$1 = vertex.id();
|
|
1011
|
+
if (visited[v_id$1]) return;
|
|
1012
|
+
visited[v_id$1] = true;
|
|
1013
|
+
ancestors.push(vertex);
|
|
1014
|
+
vertex.outEdges().forEach((e) => {
|
|
1015
|
+
if (ancestors.indexOf(e._target) < 0) visit(e._target, [...ancestors]);
|
|
1016
|
+
});
|
|
1017
|
+
retVal.unshift(vertex._);
|
|
1018
|
+
};
|
|
1019
|
+
if (v_id) visit(this._vertexMap[v_id]);
|
|
1020
|
+
else for (const key in this._vertexMap) visit(this._vertexMap[key]);
|
|
1021
|
+
return retVal;
|
|
1022
|
+
}
|
|
1200
1023
|
};
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
this._content.splice(idx, 1);
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
forEach(_) {
|
|
1223
|
-
this._content.forEach(_);
|
|
1224
|
-
}
|
|
1024
|
+
var Set = class {
|
|
1025
|
+
_content = [];
|
|
1026
|
+
get size() {
|
|
1027
|
+
return this._content.length;
|
|
1028
|
+
}
|
|
1029
|
+
has(_) {
|
|
1030
|
+
return this._content.indexOf(_) >= 0;
|
|
1031
|
+
}
|
|
1032
|
+
add(_) {
|
|
1033
|
+
if (!this.has(_)) this._content.push(_);
|
|
1034
|
+
}
|
|
1035
|
+
delete(_) {
|
|
1036
|
+
const idx = this._content.indexOf(_);
|
|
1037
|
+
if (idx >= 0) this._content.splice(idx, 1);
|
|
1038
|
+
}
|
|
1039
|
+
forEach(_) {
|
|
1040
|
+
this._content.forEach(_);
|
|
1041
|
+
}
|
|
1225
1042
|
};
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1043
|
+
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/immutable.ts
|
|
1046
|
+
var isArray$1 = Array.isArray;
|
|
1047
|
+
var keyList = Object.keys;
|
|
1048
|
+
var hasProp = Object.prototype.hasOwnProperty;
|
|
1231
1049
|
function verboseDeepEquals(a, b, functionRefCompare = false) {
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
return true;
|
|
1300
|
-
} else if (!functionRefCompare && typeof a === "function" && typeof b === "function") {
|
|
1301
|
-
const retVal2 = a.toString() === b.toString();
|
|
1302
|
-
if (!retVal2) {
|
|
1303
|
-
console.warn(`functions not equal: ${a.toString()} !== ${b.toString()}`);
|
|
1304
|
-
}
|
|
1305
|
-
return retVal2;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
const retVal = a !== a && b !== b;
|
|
1309
|
-
if (!retVal) {
|
|
1310
|
-
console.warn(`values not equal: ${a} !== ${b}`);
|
|
1311
|
-
}
|
|
1312
|
-
return retVal;
|
|
1050
|
+
if (a === b) return true;
|
|
1051
|
+
if (a && b) {
|
|
1052
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
1053
|
+
const arrA = isArray$1(a);
|
|
1054
|
+
const arrB = isArray$1(b);
|
|
1055
|
+
let i;
|
|
1056
|
+
let length;
|
|
1057
|
+
let key;
|
|
1058
|
+
if (arrA && arrB) {
|
|
1059
|
+
length = a.length;
|
|
1060
|
+
if (length !== b.length) {
|
|
1061
|
+
console.warn(`lengths not equal: ${length} !== ${b.length}`);
|
|
1062
|
+
return false;
|
|
1063
|
+
}
|
|
1064
|
+
for (i = length; i-- !== 0;) if (!verboseDeepEquals(a[i], b[i], functionRefCompare)) return false;
|
|
1065
|
+
return true;
|
|
1066
|
+
}
|
|
1067
|
+
if (arrA !== arrB) {
|
|
1068
|
+
console.warn(`arrays not equal: ${arrA} !== ${arrB}`);
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
const dateA = a instanceof Date;
|
|
1072
|
+
const dateB = b instanceof Date;
|
|
1073
|
+
if (dateA !== dateB) {
|
|
1074
|
+
console.warn(`dates not equal: ${dateA} !== ${dateB}`);
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
if (dateA && dateB) {
|
|
1078
|
+
const retVal$1 = a.getTime() === b.getTime();
|
|
1079
|
+
if (!retVal$1) console.warn(`dates not equal: ${a.getTime()} !== ${b.getTime()}`);
|
|
1080
|
+
return retVal$1;
|
|
1081
|
+
}
|
|
1082
|
+
const regexpA = a instanceof RegExp;
|
|
1083
|
+
const regexpB = b instanceof RegExp;
|
|
1084
|
+
if (regexpA !== regexpB) {
|
|
1085
|
+
console.warn(`regexps not equal: ${regexpA} !== ${regexpB}`);
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
if (regexpA && regexpB) {
|
|
1089
|
+
const retVal$1 = a.toString() === b.toString();
|
|
1090
|
+
if (!retVal$1) console.warn(`regexps not equal: ${a.toString()} !== ${b.toString()}`);
|
|
1091
|
+
return retVal$1;
|
|
1092
|
+
}
|
|
1093
|
+
const keys = keyList(a);
|
|
1094
|
+
length = keys.length;
|
|
1095
|
+
if (length !== keyList(b).length) {
|
|
1096
|
+
console.warn(`key lengths not equal: ${length} !== ${keyList(b).length}`);
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
for (i = length; i-- !== 0;) if (!hasProp.call(b, keys[i])) {
|
|
1100
|
+
console.warn(`${keys[i]} in a but not b`);
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
for (i = length; i-- !== 0;) {
|
|
1104
|
+
key = keys[i];
|
|
1105
|
+
if (!verboseDeepEquals(a[key], b[key], functionRefCompare)) return false;
|
|
1106
|
+
}
|
|
1107
|
+
return true;
|
|
1108
|
+
} else if (!functionRefCompare && typeof a === "function" && typeof b === "function") {
|
|
1109
|
+
const retVal$1 = a.toString() === b.toString();
|
|
1110
|
+
if (!retVal$1) console.warn(`functions not equal: ${a.toString()} !== ${b.toString()}`);
|
|
1111
|
+
return retVal$1;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
const retVal = a !== a && b !== b;
|
|
1115
|
+
if (!retVal) console.warn(`values not equal: ${a} !== ${b}`);
|
|
1116
|
+
return retVal;
|
|
1313
1117
|
}
|
|
1314
|
-
__name(verboseDeepEquals, "verboseDeepEquals");
|
|
1315
1118
|
function deepEquals(a, b, functionRefCompare = false) {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
} else if (!functionRefCompare && typeof a === "function" && typeof b === "function") {
|
|
1352
|
-
return a.toString() === b.toString();
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
return a !== a && b !== b;
|
|
1119
|
+
if (a === b) return true;
|
|
1120
|
+
if (a && b) {
|
|
1121
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
1122
|
+
const arrA = isArray$1(a);
|
|
1123
|
+
const arrB = isArray$1(b);
|
|
1124
|
+
let i;
|
|
1125
|
+
let length;
|
|
1126
|
+
let key;
|
|
1127
|
+
if (arrA && arrB) {
|
|
1128
|
+
length = a.length;
|
|
1129
|
+
if (length !== b.length) return false;
|
|
1130
|
+
for (i = length; i-- !== 0;) if (!deepEquals(a[i], b[i], functionRefCompare)) return false;
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
if (arrA !== arrB) return false;
|
|
1134
|
+
const dateA = a instanceof Date;
|
|
1135
|
+
const dateB = b instanceof Date;
|
|
1136
|
+
if (dateA !== dateB) return false;
|
|
1137
|
+
if (dateA && dateB) return a.getTime() === b.getTime();
|
|
1138
|
+
const regexpA = a instanceof RegExp;
|
|
1139
|
+
const regexpB = b instanceof RegExp;
|
|
1140
|
+
if (regexpA !== regexpB) return false;
|
|
1141
|
+
if (regexpA && regexpB) return a.toString() === b.toString();
|
|
1142
|
+
const keys = keyList(a);
|
|
1143
|
+
length = keys.length;
|
|
1144
|
+
if (length !== keyList(b).length) return false;
|
|
1145
|
+
for (i = length; i-- !== 0;) if (!hasProp.call(b, keys[i])) return false;
|
|
1146
|
+
for (i = length; i-- !== 0;) {
|
|
1147
|
+
key = keys[i];
|
|
1148
|
+
if (!deepEquals(a[key], b[key], functionRefCompare)) return false;
|
|
1149
|
+
}
|
|
1150
|
+
return true;
|
|
1151
|
+
} else if (!functionRefCompare && typeof a === "function" && typeof b === "function") return a.toString() === b.toString();
|
|
1152
|
+
}
|
|
1153
|
+
return a !== a && b !== b;
|
|
1356
1154
|
}
|
|
1357
|
-
__name(deepEquals, "deepEquals");
|
|
1358
1155
|
function update(origItem, newItem, functionRefCompare = false) {
|
|
1359
|
-
|
|
1156
|
+
return deepEquals(origItem, newItem, functionRefCompare) ? origItem : newItem;
|
|
1360
1157
|
}
|
|
1361
|
-
|
|
1158
|
+
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/platform.ts
|
|
1362
1161
|
const root = typeof globalThis !== "undefined" ? globalThis : window;
|
|
1363
1162
|
const isBrowser = typeof window !== "undefined" && root === window;
|
|
1364
1163
|
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1365
1164
|
const isCI = isNode && process.env != null && (process.env.TRAVIS != null || process.env.GITHUB_ACTIONS != null || process.env.CI != null);
|
|
1366
1165
|
function getScriptSrc(partial) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
}
|
|
1377
|
-
return "";
|
|
1166
|
+
const scripts = document.scripts || [];
|
|
1167
|
+
for (let i = document.scripts.length - 1; i >= 0; --i) {
|
|
1168
|
+
const script = scripts[i];
|
|
1169
|
+
if (script.src) {
|
|
1170
|
+
const idx = script.src.indexOf(partial);
|
|
1171
|
+
if (idx >= 0) return script.src.substring(0, idx);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
return "";
|
|
1378
1175
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1176
|
+
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/stack.ts
|
|
1179
|
+
/**
|
|
1180
|
+
* A generic Stack
|
|
1181
|
+
*/
|
|
1182
|
+
var Stack = class {
|
|
1183
|
+
stack = [];
|
|
1184
|
+
/**
|
|
1185
|
+
* Push element onto the stack
|
|
1186
|
+
*
|
|
1187
|
+
* @param e - element to push
|
|
1188
|
+
*/
|
|
1189
|
+
push(e) {
|
|
1190
|
+
this.stack.push(e);
|
|
1191
|
+
return e;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Pop element off the stack
|
|
1195
|
+
*/
|
|
1196
|
+
pop() {
|
|
1197
|
+
return this.stack.pop();
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Top item on the stack
|
|
1201
|
+
*
|
|
1202
|
+
* @returns Top element on the stack
|
|
1203
|
+
*/
|
|
1204
|
+
top() {
|
|
1205
|
+
return this.stack.length ? this.stack[this.stack.length - 1] : void 0;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Depth of stack
|
|
1209
|
+
*
|
|
1210
|
+
* @returns Depth
|
|
1211
|
+
*/
|
|
1212
|
+
depth() {
|
|
1213
|
+
return this.stack.length;
|
|
1214
|
+
}
|
|
1413
1215
|
};
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1216
|
+
|
|
1217
|
+
//#endregion
|
|
1218
|
+
//#region src/logging.ts
|
|
1219
|
+
let Level = /* @__PURE__ */ function(Level$1) {
|
|
1220
|
+
Level$1[Level$1["debug"] = 0] = "debug";
|
|
1221
|
+
Level$1[Level$1["info"] = 1] = "info";
|
|
1222
|
+
Level$1[Level$1["notice"] = 2] = "notice";
|
|
1223
|
+
Level$1[Level$1["warning"] = 3] = "warning";
|
|
1224
|
+
Level$1[Level$1["error"] = 4] = "error";
|
|
1225
|
+
Level$1[Level$1["critical"] = 5] = "critical";
|
|
1226
|
+
Level$1[Level$1["alert"] = 6] = "alert";
|
|
1227
|
+
Level$1[Level$1["emergency"] = 7] = "emergency";
|
|
1228
|
+
return Level$1;
|
|
1229
|
+
}({});
|
|
1230
|
+
var colours = {
|
|
1231
|
+
debug: "cyan",
|
|
1232
|
+
info: "green",
|
|
1233
|
+
notice: "grey",
|
|
1234
|
+
warning: "blue",
|
|
1235
|
+
error: "red",
|
|
1236
|
+
critical: "magenta",
|
|
1237
|
+
alert: "magenta",
|
|
1238
|
+
emergency: "magenta"
|
|
1436
1239
|
};
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
console.log(`[${dateTime}] %c${Level[level].toUpperCase()}%c ${id}: ${msg}`, `color:${colours[Level[level]]}`, "");
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1240
|
+
var ConsoleWriter = class {
|
|
1241
|
+
write(dateTime, level, id, msg) {
|
|
1242
|
+
if (isNode) console.log(`[${dateTime}] ${Level[level].toUpperCase()} ${id}: ${msg}`);
|
|
1243
|
+
else console.log(`[${dateTime}] %c${Level[level].toUpperCase()}%c ${id}: ${msg}`, `color:${colours[Level[level]]}`, "");
|
|
1244
|
+
}
|
|
1445
1245
|
};
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
popLevel() {
|
|
1525
|
-
this._level = this._levelStack.pop();
|
|
1526
|
-
return this;
|
|
1527
|
-
}
|
|
1528
|
-
filter(_) {
|
|
1529
|
-
if (_ === void 0) return this._filter;
|
|
1530
|
-
this._filter = _;
|
|
1531
|
-
return this;
|
|
1532
|
-
}
|
|
1246
|
+
var Logging = class {
|
|
1247
|
+
static _instance;
|
|
1248
|
+
_levelStack = new Stack();
|
|
1249
|
+
_level = Level.info;
|
|
1250
|
+
_filter = "";
|
|
1251
|
+
_writer = new ConsoleWriter();
|
|
1252
|
+
static Instance() {
|
|
1253
|
+
return this._instance || (this._instance = new this());
|
|
1254
|
+
}
|
|
1255
|
+
constructor() {}
|
|
1256
|
+
stringify(obj) {
|
|
1257
|
+
const cache = [];
|
|
1258
|
+
return JSON.stringify(obj, function(_key, value) {
|
|
1259
|
+
if (typeof value === "object" && value !== null) {
|
|
1260
|
+
if (cache.indexOf(value) !== -1) return;
|
|
1261
|
+
cache.push(value);
|
|
1262
|
+
}
|
|
1263
|
+
return value;
|
|
1264
|
+
}, 2);
|
|
1265
|
+
}
|
|
1266
|
+
writer(_) {
|
|
1267
|
+
if (_ === void 0) return this._writer;
|
|
1268
|
+
this._writer = _;
|
|
1269
|
+
return this;
|
|
1270
|
+
}
|
|
1271
|
+
log(level, id, msg) {
|
|
1272
|
+
if (level < this._level) return;
|
|
1273
|
+
if (this._filter && this._filter !== id) return;
|
|
1274
|
+
const dateTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
1275
|
+
if (this._writer.rawWrite) this._writer.rawWrite(dateTime, level, id, msg);
|
|
1276
|
+
else {
|
|
1277
|
+
if (typeof msg !== "string") msg = this.stringify(msg);
|
|
1278
|
+
if (this._writer.write) this._writer.write(dateTime, level, id, msg);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
debug(id, msg) {
|
|
1282
|
+
this.log(Level.debug, id, msg);
|
|
1283
|
+
}
|
|
1284
|
+
info(id, msg) {
|
|
1285
|
+
this.log(Level.info, id, msg);
|
|
1286
|
+
}
|
|
1287
|
+
notice(id, msg) {
|
|
1288
|
+
this.log(Level.notice, id, msg);
|
|
1289
|
+
}
|
|
1290
|
+
warning(id, msg) {
|
|
1291
|
+
this.log(Level.warning, id, msg);
|
|
1292
|
+
}
|
|
1293
|
+
error(id, msg) {
|
|
1294
|
+
this.log(Level.error, id, msg);
|
|
1295
|
+
}
|
|
1296
|
+
critical(id, msg) {
|
|
1297
|
+
this.log(Level.critical, id, msg);
|
|
1298
|
+
}
|
|
1299
|
+
alert(id, msg) {
|
|
1300
|
+
this.log(Level.alert, id, msg);
|
|
1301
|
+
}
|
|
1302
|
+
emergency(id, msg) {
|
|
1303
|
+
this.log(Level.emergency, id, msg);
|
|
1304
|
+
}
|
|
1305
|
+
level(_) {
|
|
1306
|
+
if (_ === void 0) return this._level;
|
|
1307
|
+
this._level = _;
|
|
1308
|
+
return this;
|
|
1309
|
+
}
|
|
1310
|
+
pushLevel(_) {
|
|
1311
|
+
this._levelStack.push(this._level);
|
|
1312
|
+
this._level = _;
|
|
1313
|
+
return this;
|
|
1314
|
+
}
|
|
1315
|
+
popLevel() {
|
|
1316
|
+
this._level = this._levelStack.pop();
|
|
1317
|
+
return this;
|
|
1318
|
+
}
|
|
1319
|
+
filter(_) {
|
|
1320
|
+
if (_ === void 0) return this._filter;
|
|
1321
|
+
this._filter = _;
|
|
1322
|
+
return this;
|
|
1323
|
+
}
|
|
1533
1324
|
};
|
|
1534
|
-
__name(_Logging, "Logging");
|
|
1535
|
-
__publicField(_Logging, "_instance");
|
|
1536
|
-
let Logging = _Logging;
|
|
1537
1325
|
const logger = Logging.Instance();
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1326
|
+
var ScopedLogging = class {
|
|
1327
|
+
_scopeID;
|
|
1328
|
+
constructor(scopeID) {
|
|
1329
|
+
this._scopeID = scopeID;
|
|
1330
|
+
}
|
|
1331
|
+
debug(msg) {
|
|
1332
|
+
logger.debug(this._scopeID, msg);
|
|
1333
|
+
}
|
|
1334
|
+
info(msg) {
|
|
1335
|
+
logger.info(this._scopeID, msg);
|
|
1336
|
+
}
|
|
1337
|
+
notice(msg) {
|
|
1338
|
+
logger.notice(this._scopeID, msg);
|
|
1339
|
+
}
|
|
1340
|
+
warning(msg) {
|
|
1341
|
+
logger.warning(this._scopeID, msg);
|
|
1342
|
+
}
|
|
1343
|
+
error(msg) {
|
|
1344
|
+
logger.error(this._scopeID, msg);
|
|
1345
|
+
}
|
|
1346
|
+
critical(msg) {
|
|
1347
|
+
logger.critical(this._scopeID, msg);
|
|
1348
|
+
}
|
|
1349
|
+
alert(msg) {
|
|
1350
|
+
logger.alert(this._scopeID, msg);
|
|
1351
|
+
}
|
|
1352
|
+
emergency(msg) {
|
|
1353
|
+
logger.emergency(this._scopeID, msg);
|
|
1354
|
+
}
|
|
1355
|
+
pushLevel(_) {
|
|
1356
|
+
logger.pushLevel(_);
|
|
1357
|
+
return this;
|
|
1358
|
+
}
|
|
1359
|
+
popLevel() {
|
|
1360
|
+
logger.popLevel();
|
|
1361
|
+
return this;
|
|
1362
|
+
}
|
|
1575
1363
|
};
|
|
1576
|
-
__name(_ScopedLogging, "ScopedLogging");
|
|
1577
|
-
let ScopedLogging = _ScopedLogging;
|
|
1578
1364
|
function scopedLogger(scopeID, filter = false) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
}
|
|
1582
|
-
return new ScopedLogging(scopeID);
|
|
1365
|
+
if (filter) logger.filter(scopeID);
|
|
1366
|
+
return new ScopedLogging(scopeID);
|
|
1583
1367
|
}
|
|
1584
|
-
|
|
1368
|
+
|
|
1369
|
+
//#endregion
|
|
1370
|
+
//#region src/math.ts
|
|
1371
|
+
/**
|
|
1372
|
+
* degreesToRadians - converts degrees to radians
|
|
1373
|
+
* Usage: degreesToRadians(1080);
|
|
1374
|
+
*
|
|
1375
|
+
* @param degrees
|
|
1376
|
+
* @returns Number radians
|
|
1377
|
+
*/
|
|
1585
1378
|
function degreesToRadians(degrees) {
|
|
1586
|
-
|
|
1379
|
+
return degrees * (Math.PI / 180);
|
|
1587
1380
|
}
|
|
1588
|
-
|
|
1381
|
+
/**
|
|
1382
|
+
* radiansToDegrees - converts radians to degrees
|
|
1383
|
+
* Usage: radiansToDegrees(7);
|
|
1384
|
+
*
|
|
1385
|
+
* @param radians
|
|
1386
|
+
* @returns Number degreees
|
|
1387
|
+
*/
|
|
1589
1388
|
function radiansToDegrees(radians) {
|
|
1590
|
-
|
|
1389
|
+
return radians * (180 / Math.PI);
|
|
1591
1390
|
}
|
|
1592
|
-
|
|
1391
|
+
/**
|
|
1392
|
+
* polarToCartesian - converts (r, theta) to {x, y}
|
|
1393
|
+
* Usage: polarToCartesian(5, Math.PI);
|
|
1394
|
+
*
|
|
1395
|
+
* @param r radius
|
|
1396
|
+
* @param theta angle in radians
|
|
1397
|
+
* @returns { x: number, y: number }
|
|
1398
|
+
*/
|
|
1593
1399
|
function polarToCartesian(r, theta) {
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1400
|
+
return {
|
|
1401
|
+
x: r * Math.cos(theta),
|
|
1402
|
+
y: r * Math.sin(theta)
|
|
1403
|
+
};
|
|
1598
1404
|
}
|
|
1599
|
-
|
|
1405
|
+
/**
|
|
1406
|
+
* cartesianToPolar - converts (x, y) to {r, theta}
|
|
1407
|
+
* Usage: cartesianToPolar(100, 200);
|
|
1408
|
+
*
|
|
1409
|
+
* @param x
|
|
1410
|
+
* @param y
|
|
1411
|
+
* @returns { r: number, theta: number }
|
|
1412
|
+
*/
|
|
1600
1413
|
function cartesianToPolar(x, y) {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1414
|
+
return {
|
|
1415
|
+
r: Math.sqrt(x * x + y * y),
|
|
1416
|
+
theta: Math.atan2(y, x)
|
|
1417
|
+
};
|
|
1605
1418
|
}
|
|
1606
|
-
|
|
1419
|
+
/**
|
|
1420
|
+
* normalizeRadians - normalizes a radian value to within the provided range
|
|
1421
|
+
* Usage: normalizeRadians(7);
|
|
1422
|
+
*
|
|
1423
|
+
* @param radians value to be normalized
|
|
1424
|
+
* @param min lower limit
|
|
1425
|
+
* @param max upper limit
|
|
1426
|
+
* @returns Number normalized to within the provided range
|
|
1427
|
+
*/
|
|
1607
1428
|
function normalizeRadians(radians, min = -Math.PI, max = Math.PI) {
|
|
1608
|
-
|
|
1429
|
+
return normalize(radians, min, max);
|
|
1609
1430
|
}
|
|
1610
|
-
|
|
1431
|
+
/**
|
|
1432
|
+
* normalizeDegrees - normalizes a degree value to within the provided range
|
|
1433
|
+
* Usage: normalizeDegrees(1080);
|
|
1434
|
+
*
|
|
1435
|
+
* @param degrees value to be normalized
|
|
1436
|
+
* @param min lower limit
|
|
1437
|
+
* @param max upper limit
|
|
1438
|
+
* @returns Number normalized to within the provided range
|
|
1439
|
+
*/
|
|
1611
1440
|
function normalizeDegrees(degrees, min = -180, max = 180) {
|
|
1612
|
-
|
|
1441
|
+
return normalize(degrees, min, max);
|
|
1613
1442
|
}
|
|
1614
|
-
|
|
1443
|
+
/**
|
|
1444
|
+
* normalize - normalizes a value to within the provided range
|
|
1445
|
+
* Usage: normalize(1000, 0, 365);
|
|
1446
|
+
*
|
|
1447
|
+
* @param value value to be normalized
|
|
1448
|
+
* @param min lower limit
|
|
1449
|
+
* @param max upper limit
|
|
1450
|
+
* @returns Number normalized to within the provided range
|
|
1451
|
+
*/
|
|
1615
1452
|
function normalize(value, min, max) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1453
|
+
const spread = max - min;
|
|
1454
|
+
const offsetValue = value - min;
|
|
1455
|
+
return offsetValue - Math.floor(offsetValue / spread) * spread + min;
|
|
1619
1456
|
}
|
|
1620
|
-
|
|
1457
|
+
|
|
1458
|
+
//#endregion
|
|
1459
|
+
//#region src/object.ts
|
|
1460
|
+
/**
|
|
1461
|
+
* inner - return inner property of Object
|
|
1462
|
+
* Usage: inner("some.prop.to.locate", obj);
|
|
1463
|
+
*
|
|
1464
|
+
* @param prop - property to locate
|
|
1465
|
+
* @param obj - object to locate property in
|
|
1466
|
+
*/
|
|
1621
1467
|
function inner(prop, obj) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
}
|
|
1629
|
-
return obj;
|
|
1468
|
+
if (prop === void 0 || obj === void 0) return void 0;
|
|
1469
|
+
for (const item of prop.split(".")) {
|
|
1470
|
+
if (!obj.hasOwnProperty(item)) return;
|
|
1471
|
+
obj = obj[item];
|
|
1472
|
+
}
|
|
1473
|
+
return obj;
|
|
1630
1474
|
}
|
|
1631
|
-
|
|
1475
|
+
/**
|
|
1476
|
+
* exists - return true if inner property of Object exists
|
|
1477
|
+
* Usage: exists("some.prop.to.locate", obj);
|
|
1478
|
+
*
|
|
1479
|
+
* @param prop - property to locate
|
|
1480
|
+
* @param obj - object to locate property in
|
|
1481
|
+
*/
|
|
1632
1482
|
function exists(prop, obj) {
|
|
1633
|
-
|
|
1483
|
+
return inner(prop, obj) !== void 0;
|
|
1634
1484
|
}
|
|
1635
|
-
__name(exists, "exists");
|
|
1636
1485
|
function _mixin(dest, source) {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
if (!(key in dest) || dest[key] !== s && (!(key in empty) || empty[key] !== s)) {
|
|
1647
|
-
dest[key] = s;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
return dest;
|
|
1486
|
+
const empty = {};
|
|
1487
|
+
for (const key in source) {
|
|
1488
|
+
if (!source.hasOwnProperty(key)) continue;
|
|
1489
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
1490
|
+
let s = source[key];
|
|
1491
|
+
if (s instanceof Array) {} else if (typeof s === "object") s = deepMixin(dest[key], s);
|
|
1492
|
+
if (!(key in dest) || dest[key] !== s && (!(key in empty) || empty[key] !== s)) dest[key] = s;
|
|
1493
|
+
}
|
|
1494
|
+
return dest;
|
|
1651
1495
|
}
|
|
1652
|
-
|
|
1496
|
+
/**
|
|
1497
|
+
* deepMixin - combine several objects from right to left
|
|
1498
|
+
* Usage: deepMixin({a: "a"}, {b: "b"});
|
|
1499
|
+
*
|
|
1500
|
+
* @param dest - target object to mix into.
|
|
1501
|
+
* @param sources - objects to mix in
|
|
1502
|
+
*/
|
|
1653
1503
|
function deepMixin(dest = {}, ...sources) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
}
|
|
1658
|
-
return dest;
|
|
1504
|
+
if (typeof dest !== "object") throw new Error(`Destination "${dest}" must be an object.`);
|
|
1505
|
+
for (const source of sources) _mixin(dest, source);
|
|
1506
|
+
return dest;
|
|
1659
1507
|
}
|
|
1660
|
-
|
|
1508
|
+
/**
|
|
1509
|
+
* deepMixinT - combine several objects of Partial<T> from right to left
|
|
1510
|
+
* Usage: deepMixinT<MyInterface>({a: "a"}, {b: "b"});
|
|
1511
|
+
*
|
|
1512
|
+
* Note: Only provided as a convenience, so user gets auto completion based on destination type.
|
|
1513
|
+
*
|
|
1514
|
+
* @param dest - target object to mix into.
|
|
1515
|
+
* @param sources - objects to mix in
|
|
1516
|
+
*/
|
|
1661
1517
|
function deepMixinT(dest = {}, ...sources) {
|
|
1662
|
-
|
|
1518
|
+
return deepMixin(dest, ...sources);
|
|
1663
1519
|
}
|
|
1664
|
-
|
|
1520
|
+
/**
|
|
1521
|
+
* safeStingify - JSONsimilar to .stringify, except ignores circular references.
|
|
1522
|
+
* Usage: safeStingify(object);
|
|
1523
|
+
*
|
|
1524
|
+
* @param obj - any object.
|
|
1525
|
+
*/
|
|
1665
1526
|
function safeStringify(obj) {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
return value;
|
|
1675
|
-
});
|
|
1527
|
+
const cache = [];
|
|
1528
|
+
return JSON.stringify(obj, function(key, value) {
|
|
1529
|
+
if (typeof value === "object" && value !== null) {
|
|
1530
|
+
if (cache.indexOf(value) !== -1) return;
|
|
1531
|
+
cache.push(value);
|
|
1532
|
+
}
|
|
1533
|
+
return value;
|
|
1534
|
+
});
|
|
1676
1535
|
}
|
|
1677
|
-
__name(safeStringify, "safeStringify");
|
|
1678
1536
|
function isArray(arg) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
}
|
|
1682
|
-
return Object.prototype.toString.call(arg) === "[object Array]";
|
|
1537
|
+
if (Array.isArray !== void 0) return Array.isArray(arg);
|
|
1538
|
+
return Object.prototype.toString.call(arg) === "[object Array]";
|
|
1683
1539
|
}
|
|
1684
|
-
__name(isArray, "isArray");
|
|
1685
1540
|
function classID2Meta(classID) {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1541
|
+
const info = classID.split("_");
|
|
1542
|
+
const classInfo = info[1].split(".");
|
|
1543
|
+
return {
|
|
1544
|
+
module: `@hpcc-js/${info[0]}`,
|
|
1545
|
+
file: classInfo[0],
|
|
1546
|
+
class: classInfo[1] || classInfo[0]
|
|
1547
|
+
};
|
|
1693
1548
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1549
|
+
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region src/observer.ts
|
|
1552
|
+
var ObserverHandle = class {
|
|
1553
|
+
eventTarget;
|
|
1554
|
+
eventID;
|
|
1555
|
+
callback;
|
|
1556
|
+
constructor(eventTarget, eventID, callback) {
|
|
1557
|
+
this.eventTarget = eventTarget;
|
|
1558
|
+
this.eventID = eventID;
|
|
1559
|
+
this.callback = callback;
|
|
1560
|
+
}
|
|
1561
|
+
release() {
|
|
1562
|
+
this.eventTarget.removeObserver(this.eventID, this.callback);
|
|
1563
|
+
}
|
|
1564
|
+
unwatch() {
|
|
1565
|
+
this.release();
|
|
1566
|
+
}
|
|
1710
1567
|
};
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
}
|
|
1746
|
-
_hasObserver(eventID) {
|
|
1747
|
-
const eventObservers = this._eventObservers[eventID];
|
|
1748
|
-
for (const observer in eventObservers) {
|
|
1749
|
-
if (eventObservers[observer]) {
|
|
1750
|
-
return true;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
return false;
|
|
1754
|
-
}
|
|
1755
|
-
hasObserver(_eventID) {
|
|
1756
|
-
if (_eventID !== void 0) {
|
|
1757
|
-
return this._hasObserver(_eventID);
|
|
1758
|
-
}
|
|
1759
|
-
for (const eventID in this._eventObservers) {
|
|
1760
|
-
if (this._hasObserver(eventID)) {
|
|
1761
|
-
return true;
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
return false;
|
|
1765
|
-
}
|
|
1568
|
+
var Observable = class {
|
|
1569
|
+
_eventObservers = {};
|
|
1570
|
+
constructor(...events) {}
|
|
1571
|
+
addObserver(eventID, callback) {
|
|
1572
|
+
let eventObservers = this._eventObservers[eventID];
|
|
1573
|
+
if (!eventObservers) {
|
|
1574
|
+
eventObservers = [];
|
|
1575
|
+
this._eventObservers[eventID] = eventObservers;
|
|
1576
|
+
}
|
|
1577
|
+
eventObservers.push(callback);
|
|
1578
|
+
return new ObserverHandle(this, eventID, callback);
|
|
1579
|
+
}
|
|
1580
|
+
removeObserver(eventID, callback) {
|
|
1581
|
+
const eventObservers = this._eventObservers[eventID];
|
|
1582
|
+
if (eventObservers) {
|
|
1583
|
+
for (let i = eventObservers.length - 1; i >= 0; --i) if (eventObservers[i] === callback) eventObservers.splice(i, 1);
|
|
1584
|
+
}
|
|
1585
|
+
return this;
|
|
1586
|
+
}
|
|
1587
|
+
dispatchEvent(eventID, ...args) {
|
|
1588
|
+
const eventObservers = this._eventObservers[eventID];
|
|
1589
|
+
if (eventObservers) for (const observer of eventObservers) observer(...args);
|
|
1590
|
+
return this;
|
|
1591
|
+
}
|
|
1592
|
+
_hasObserver(eventID) {
|
|
1593
|
+
const eventObservers = this._eventObservers[eventID];
|
|
1594
|
+
for (const observer in eventObservers) if (eventObservers[observer]) return true;
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
hasObserver(_eventID) {
|
|
1598
|
+
if (_eventID !== void 0) return this._hasObserver(_eventID);
|
|
1599
|
+
for (const eventID in this._eventObservers) if (this._hasObserver(eventID)) return true;
|
|
1600
|
+
return false;
|
|
1601
|
+
}
|
|
1766
1602
|
};
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1603
|
+
|
|
1604
|
+
//#endregion
|
|
1605
|
+
//#region src/dispatch.ts
|
|
1606
|
+
var requestAnimationFrame;
|
|
1770
1607
|
(function() {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
}
|
|
1608
|
+
if (root.requestAnimationFrame) requestAnimationFrame = root.requestAnimationFrame;
|
|
1609
|
+
else {
|
|
1610
|
+
let lastTime = 0;
|
|
1611
|
+
requestAnimationFrame = function(callback) {
|
|
1612
|
+
const currTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1613
|
+
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
1614
|
+
const id = setTimeout(() => callback(currTime + timeToCall), timeToCall);
|
|
1615
|
+
lastTime = currTime + timeToCall;
|
|
1616
|
+
return id;
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1783
1619
|
})();
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1620
|
+
var Message = class {
|
|
1621
|
+
get canConflate() {
|
|
1622
|
+
return false;
|
|
1623
|
+
}
|
|
1624
|
+
conflate(other) {
|
|
1625
|
+
return false;
|
|
1626
|
+
}
|
|
1627
|
+
void() {
|
|
1628
|
+
return false;
|
|
1629
|
+
}
|
|
1794
1630
|
};
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1631
|
+
var Dispatch = class {
|
|
1632
|
+
_observerID = 0;
|
|
1633
|
+
_observers = [];
|
|
1634
|
+
_messageBuffer = [];
|
|
1635
|
+
constructor() {}
|
|
1636
|
+
observers() {
|
|
1637
|
+
return this._observers;
|
|
1638
|
+
}
|
|
1639
|
+
messages() {
|
|
1640
|
+
const retVal = [];
|
|
1641
|
+
this._messageBuffer.forEach((msg) => {
|
|
1642
|
+
if (!retVal.some((msg2) => msg2.canConflate && msg2.conflate(msg))) retVal.push(msg);
|
|
1643
|
+
});
|
|
1644
|
+
return retVal;
|
|
1645
|
+
}
|
|
1646
|
+
dispatchAll() {
|
|
1647
|
+
this.dispatch(this.messages());
|
|
1648
|
+
this.flush();
|
|
1649
|
+
}
|
|
1650
|
+
dispatch(messages) {
|
|
1651
|
+
if (messages.length === 0) return;
|
|
1652
|
+
this.observers().forEach((o) => {
|
|
1653
|
+
const msgs = messages.filter((m) => !m.void() && (o.type === void 0 || m instanceof o.type));
|
|
1654
|
+
if (msgs.length) o.callback(msgs);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
hasObserver() {
|
|
1658
|
+
return this._observers.length > 0;
|
|
1659
|
+
}
|
|
1660
|
+
flush() {
|
|
1661
|
+
this._messageBuffer = [];
|
|
1662
|
+
}
|
|
1663
|
+
send(msg) {
|
|
1664
|
+
this.dispatch([msg]);
|
|
1665
|
+
}
|
|
1666
|
+
post(msg) {
|
|
1667
|
+
this._messageBuffer.push(msg);
|
|
1668
|
+
requestAnimationFrame(() => this.dispatchAll());
|
|
1669
|
+
}
|
|
1670
|
+
attach(callback, type) {
|
|
1671
|
+
const context = this;
|
|
1672
|
+
const id = ++this._observerID;
|
|
1673
|
+
this._observers.push({
|
|
1674
|
+
id,
|
|
1675
|
+
type,
|
|
1676
|
+
callback
|
|
1677
|
+
});
|
|
1678
|
+
return {
|
|
1679
|
+
release() {
|
|
1680
|
+
context._observers = context._observers.filter((o) => o.id !== id);
|
|
1681
|
+
},
|
|
1682
|
+
unwatch() {
|
|
1683
|
+
this.release();
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1854
1687
|
};
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
}
|
|
1688
|
+
|
|
1689
|
+
//#endregion
|
|
1690
|
+
//#region src/saxParser.ts
|
|
1691
|
+
var XMLNode = class {
|
|
1692
|
+
name = "";
|
|
1693
|
+
$ = {};
|
|
1694
|
+
_children = [];
|
|
1695
|
+
content = "";
|
|
1696
|
+
constructor(name) {
|
|
1697
|
+
this.name = name;
|
|
1698
|
+
}
|
|
1699
|
+
appendAttribute(key, val) {
|
|
1700
|
+
this.$[key] = val;
|
|
1701
|
+
}
|
|
1702
|
+
appendContent(content) {
|
|
1703
|
+
this.content += content;
|
|
1704
|
+
}
|
|
1705
|
+
appendChild(child) {
|
|
1706
|
+
this._children.push(child);
|
|
1707
|
+
}
|
|
1708
|
+
children(tag) {
|
|
1709
|
+
if (tag === void 0) return this._children;
|
|
1710
|
+
return this._children.filter((xmlNode) => {
|
|
1711
|
+
return xmlNode.name === tag;
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1882
1714
|
};
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
this.startDocument();
|
|
1924
|
-
this.walkDoc(doc);
|
|
1925
|
-
this.endDocument();
|
|
1926
|
-
}
|
|
1927
|
-
// Callbacks ---
|
|
1928
|
-
startDocument() {
|
|
1929
|
-
}
|
|
1930
|
-
endDocument() {
|
|
1931
|
-
}
|
|
1932
|
-
startXMLNode(node) {
|
|
1933
|
-
}
|
|
1934
|
-
endXMLNode(node) {
|
|
1935
|
-
}
|
|
1936
|
-
attributes(key, val) {
|
|
1937
|
-
this.stack.top().appendAttribute(key, val);
|
|
1938
|
-
}
|
|
1939
|
-
characters(text) {
|
|
1940
|
-
this.stack.top().appendContent(text);
|
|
1941
|
-
}
|
|
1715
|
+
var SAXStackParser = class {
|
|
1716
|
+
root;
|
|
1717
|
+
stack = new Stack();
|
|
1718
|
+
constructor() {}
|
|
1719
|
+
walkDoc(node) {
|
|
1720
|
+
const xmlNode = this._startXMLNode(node);
|
|
1721
|
+
if (node.attributes) for (let i = 0; i < node.attributes.length; ++i) {
|
|
1722
|
+
const attribute = node.attributes.item(i);
|
|
1723
|
+
this.attributes(attribute.nodeName, attribute.nodeValue);
|
|
1724
|
+
}
|
|
1725
|
+
this.startXMLNode(xmlNode);
|
|
1726
|
+
if (node.childNodes) for (let i = 0; i < node.childNodes.length; ++i) {
|
|
1727
|
+
const childNode = node.childNodes.item(i);
|
|
1728
|
+
if (childNode.nodeType === childNode.TEXT_NODE) this.characters(childNode.nodeValue);
|
|
1729
|
+
else this.walkDoc(childNode);
|
|
1730
|
+
}
|
|
1731
|
+
this.endXMLNode(this.stack.pop());
|
|
1732
|
+
}
|
|
1733
|
+
_startXMLNode(node) {
|
|
1734
|
+
const newNode = new XMLNode(node.nodeName);
|
|
1735
|
+
if (!this.stack.depth()) this.root = newNode;
|
|
1736
|
+
else this.stack.top().appendChild(newNode);
|
|
1737
|
+
return this.stack.push(newNode);
|
|
1738
|
+
}
|
|
1739
|
+
parse(xml) {
|
|
1740
|
+
const doc = new DOMParser().parseFromString(xml, "application/xml");
|
|
1741
|
+
this.startDocument();
|
|
1742
|
+
this.walkDoc(doc);
|
|
1743
|
+
this.endDocument();
|
|
1744
|
+
}
|
|
1745
|
+
startDocument() {}
|
|
1746
|
+
endDocument() {}
|
|
1747
|
+
startXMLNode(node) {}
|
|
1748
|
+
endXMLNode(node) {}
|
|
1749
|
+
attributes(key, val) {
|
|
1750
|
+
this.stack.top().appendAttribute(key, val);
|
|
1751
|
+
}
|
|
1752
|
+
characters(text) {
|
|
1753
|
+
this.stack.top().appendContent(text);
|
|
1754
|
+
}
|
|
1942
1755
|
};
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1756
|
+
var XML2JSONParser = class extends SAXStackParser {
|
|
1757
|
+
startXMLNode(node) {
|
|
1758
|
+
super.startXMLNode(node);
|
|
1759
|
+
switch (node.name) {
|
|
1760
|
+
case "xs:element": break;
|
|
1761
|
+
case "xs:simpleType": break;
|
|
1762
|
+
default: break;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
endXMLNode(node) {
|
|
1766
|
+
switch (node.name) {
|
|
1767
|
+
case "xs:element": break;
|
|
1768
|
+
case "xs:simpleType": break;
|
|
1769
|
+
default: break;
|
|
1770
|
+
}
|
|
1771
|
+
super.endXMLNode(node);
|
|
1772
|
+
}
|
|
1956
1773
|
};
|
|
1957
|
-
__name(_XML2JSONParser, "XML2JSONParser");
|
|
1958
|
-
let XML2JSONParser = _XML2JSONParser;
|
|
1959
1774
|
function xml2json(xml) {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1775
|
+
const saxParser = new XML2JSONParser();
|
|
1776
|
+
saxParser.parse(xml);
|
|
1777
|
+
return saxParser.root;
|
|
1963
1778
|
}
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1779
|
+
|
|
1780
|
+
//#endregion
|
|
1781
|
+
//#region src/stateful.ts
|
|
1782
|
+
var PropChangedMessage = class extends Message {
|
|
1783
|
+
constructor(property, newValue, oldValue) {
|
|
1784
|
+
super();
|
|
1785
|
+
this.property = property;
|
|
1786
|
+
this.newValue = newValue;
|
|
1787
|
+
this.oldValue = oldValue;
|
|
1788
|
+
}
|
|
1789
|
+
get canConflate() {
|
|
1790
|
+
return true;
|
|
1791
|
+
}
|
|
1792
|
+
conflate(other) {
|
|
1793
|
+
if (this.property === other.property) {
|
|
1794
|
+
this.newValue = other.newValue;
|
|
1795
|
+
return true;
|
|
1796
|
+
}
|
|
1797
|
+
return false;
|
|
1798
|
+
}
|
|
1799
|
+
void() {
|
|
1800
|
+
return deepEquals(this.newValue, this.oldValue);
|
|
1801
|
+
}
|
|
1985
1802
|
};
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
return 3e4;
|
|
2089
|
-
}
|
|
2090
|
-
watch(callback, triggerChange = true) {
|
|
2091
|
-
if (typeof callback !== "function") {
|
|
2092
|
-
throw new Error("Invalid Callback");
|
|
2093
|
-
}
|
|
2094
|
-
if (triggerChange) {
|
|
2095
|
-
setTimeout(() => {
|
|
2096
|
-
const props = this.get();
|
|
2097
|
-
const changes = [];
|
|
2098
|
-
for (const key in props) {
|
|
2099
|
-
if (props.hasOwnProperty(props)) {
|
|
2100
|
-
changes.push({ id: key, newValue: props[key], oldValue: void 0 });
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
callback(changes);
|
|
2104
|
-
}, 0);
|
|
2105
|
-
}
|
|
2106
|
-
const retVal = this.addObserver("changed", callback);
|
|
2107
|
-
this._monitor();
|
|
2108
|
-
return retVal;
|
|
2109
|
-
}
|
|
1803
|
+
var StateObject = class {
|
|
1804
|
+
_espState = {};
|
|
1805
|
+
_dispatch = new Dispatch();
|
|
1806
|
+
_monitorHandle;
|
|
1807
|
+
_monitorTickCount = 0;
|
|
1808
|
+
clear(newVals) {
|
|
1809
|
+
this._espState = {};
|
|
1810
|
+
if (newVals !== void 0) this.set(newVals);
|
|
1811
|
+
this._monitorTickCount = 0;
|
|
1812
|
+
}
|
|
1813
|
+
get(key, defValue) {
|
|
1814
|
+
if (key === void 0) return this._espState;
|
|
1815
|
+
return this.has(key) ? this._espState[key] : defValue;
|
|
1816
|
+
}
|
|
1817
|
+
set(keyOrNewVals, newVal) {
|
|
1818
|
+
if (typeof keyOrNewVals === "string") return this.setSingle(keyOrNewVals, newVal);
|
|
1819
|
+
this.setAll(keyOrNewVals);
|
|
1820
|
+
}
|
|
1821
|
+
setSingle(key, newVal) {
|
|
1822
|
+
const oldVal = this._espState[key];
|
|
1823
|
+
this._espState[key] = newVal;
|
|
1824
|
+
this._dispatch.post(new PropChangedMessage(key, newVal, oldVal));
|
|
1825
|
+
}
|
|
1826
|
+
setAll(_) {
|
|
1827
|
+
for (const key in _) if (_.hasOwnProperty(key)) this.setSingle(key, _[key]);
|
|
1828
|
+
}
|
|
1829
|
+
has(key) {
|
|
1830
|
+
return this._espState[key] !== void 0;
|
|
1831
|
+
}
|
|
1832
|
+
addObserver(eventID, propIDOrCallback, callback) {
|
|
1833
|
+
if (this.isCallback(propIDOrCallback)) {
|
|
1834
|
+
if (eventID !== "changed") throw new Error("Invalid eventID: " + eventID);
|
|
1835
|
+
return this._dispatch.attach((messages) => {
|
|
1836
|
+
propIDOrCallback(messages.map((m) => ({
|
|
1837
|
+
id: m.property,
|
|
1838
|
+
oldValue: m.oldValue,
|
|
1839
|
+
newValue: m.newValue
|
|
1840
|
+
})));
|
|
1841
|
+
});
|
|
1842
|
+
} else {
|
|
1843
|
+
if (eventID !== "propChanged") throw new Error("Invalid eventID: " + eventID);
|
|
1844
|
+
return this._dispatch.attach((messages) => {
|
|
1845
|
+
const filteredMessages = messages.filter((m) => m.property === propIDOrCallback);
|
|
1846
|
+
if (filteredMessages.length) {
|
|
1847
|
+
if (filteredMessages.length > 1) console.warn("Should only be 1 message?");
|
|
1848
|
+
const event = filteredMessages[filteredMessages.length - 1];
|
|
1849
|
+
callback({
|
|
1850
|
+
id: event.property,
|
|
1851
|
+
oldValue: event.oldValue,
|
|
1852
|
+
newValue: event.newValue
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
on(eventID, propIDOrCallback, callback) {
|
|
1859
|
+
this.addObserver(eventID, propIDOrCallback, callback);
|
|
1860
|
+
return this;
|
|
1861
|
+
}
|
|
1862
|
+
isCallback(propIDOrCallback) {
|
|
1863
|
+
return typeof propIDOrCallback === "function";
|
|
1864
|
+
}
|
|
1865
|
+
hasEventListener() {
|
|
1866
|
+
return this._dispatch.hasObserver();
|
|
1867
|
+
}
|
|
1868
|
+
async refresh(full = false) {
|
|
1869
|
+
await Promise.resolve();
|
|
1870
|
+
return this;
|
|
1871
|
+
}
|
|
1872
|
+
_monitor() {
|
|
1873
|
+
if (this._monitorHandle) {
|
|
1874
|
+
this._monitorTickCount = 0;
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
this._monitorHandle = setTimeout(() => {
|
|
1878
|
+
(this.hasEventListener() ? this.refresh() : Promise.resolve()).then(() => {
|
|
1879
|
+
this._monitor();
|
|
1880
|
+
});
|
|
1881
|
+
delete this._monitorHandle;
|
|
1882
|
+
}, this._monitorTimeoutDuration());
|
|
1883
|
+
}
|
|
1884
|
+
_monitorTimeoutDuration() {
|
|
1885
|
+
++this._monitorTickCount;
|
|
1886
|
+
if (this._monitorTickCount <= 1) return 0;
|
|
1887
|
+
return 3e4;
|
|
1888
|
+
}
|
|
1889
|
+
watch(callback, triggerChange = true) {
|
|
1890
|
+
if (typeof callback !== "function") throw new Error("Invalid Callback");
|
|
1891
|
+
if (triggerChange) setTimeout(() => {
|
|
1892
|
+
const props = this.get();
|
|
1893
|
+
const changes = [];
|
|
1894
|
+
for (const key in props) if (props.hasOwnProperty(props)) changes.push({
|
|
1895
|
+
id: key,
|
|
1896
|
+
newValue: props[key],
|
|
1897
|
+
oldValue: void 0
|
|
1898
|
+
});
|
|
1899
|
+
callback(changes);
|
|
1900
|
+
}, 0);
|
|
1901
|
+
const retVal = this.addObserver("changed", callback);
|
|
1902
|
+
this._monitor();
|
|
1903
|
+
return retVal;
|
|
1904
|
+
}
|
|
2110
1905
|
};
|
|
2111
|
-
|
|
2112
|
-
|
|
1906
|
+
|
|
1907
|
+
//#endregion
|
|
1908
|
+
//#region src/string.ts
|
|
2113
1909
|
function trim(str, char) {
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
while (endsWith(str, char)) {
|
|
2120
|
-
str = str.substring(0, str.length - 1);
|
|
2121
|
-
}
|
|
2122
|
-
return str;
|
|
1910
|
+
if (typeof char !== "string") return str;
|
|
1911
|
+
if (char.length === 0) return str;
|
|
1912
|
+
while (str.indexOf(char) === 0) str = str.substring(1);
|
|
1913
|
+
while (endsWith(str, char)) str = str.substring(0, str.length - 1);
|
|
1914
|
+
return str;
|
|
2123
1915
|
}
|
|
2124
|
-
__name(trim, "trim");
|
|
2125
1916
|
function endsWith(origString, searchString, position) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
const lastIndex = subjectString.lastIndexOf(searchString, position);
|
|
2132
|
-
return lastIndex !== -1 && lastIndex === position;
|
|
1917
|
+
const subjectString = origString.toString();
|
|
1918
|
+
if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) position = subjectString.length;
|
|
1919
|
+
position -= searchString.length;
|
|
1920
|
+
const lastIndex = subjectString.lastIndexOf(searchString, position);
|
|
1921
|
+
return lastIndex !== -1 && lastIndex === position;
|
|
2133
1922
|
}
|
|
2134
|
-
|
|
1923
|
+
|
|
1924
|
+
//#endregion
|
|
1925
|
+
//#region src/url.ts
|
|
2135
1926
|
function join(...segments) {
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
}
|
|
2152
|
-
resultParts.push(part);
|
|
2153
|
-
}
|
|
2154
|
-
return resultParts.join("/");
|
|
1927
|
+
const parts = segments.reduce((parts$1, segment) => {
|
|
1928
|
+
if (parts$1.length > 0) segment = segment.replace(/^\//, "");
|
|
1929
|
+
segment = segment.replace(/\/$/, "");
|
|
1930
|
+
return [...parts$1, ...segment.split("/")];
|
|
1931
|
+
}, []);
|
|
1932
|
+
const resultParts = [];
|
|
1933
|
+
for (const part of parts) {
|
|
1934
|
+
if (part === ".") continue;
|
|
1935
|
+
if (part === "..") {
|
|
1936
|
+
resultParts.pop();
|
|
1937
|
+
continue;
|
|
1938
|
+
}
|
|
1939
|
+
resultParts.push(part);
|
|
1940
|
+
}
|
|
1941
|
+
return resultParts.join("/");
|
|
2155
1942
|
}
|
|
2156
|
-
__name(join, "join");
|
|
2157
1943
|
function dirname(path) {
|
|
2158
|
-
|
|
1944
|
+
return join(path, "..");
|
|
2159
1945
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
BUILD_VERSION,
|
|
2165
|
-
Cache,
|
|
2166
|
-
Dictionary,
|
|
2167
|
-
DictionaryNoCase,
|
|
2168
|
-
Dispatch,
|
|
2169
|
-
Edge$1 as Edge,
|
|
2170
|
-
Graph,
|
|
2171
|
-
Graph2,
|
|
2172
|
-
GraphItem$1 as GraphItem,
|
|
2173
|
-
Level,
|
|
2174
|
-
Logging,
|
|
2175
|
-
Message,
|
|
2176
|
-
Observable,
|
|
2177
|
-
PKG_NAME,
|
|
2178
|
-
PKG_VERSION,
|
|
2179
|
-
SAXStackParser,
|
|
2180
|
-
ScopedLogging,
|
|
2181
|
-
Stack,
|
|
2182
|
-
StateObject,
|
|
2183
|
-
Subgraph$1 as Subgraph,
|
|
2184
|
-
Vertex$1 as Vertex,
|
|
2185
|
-
XMLNode,
|
|
2186
|
-
cartesianToPolar,
|
|
2187
|
-
classID2Meta,
|
|
2188
|
-
compare,
|
|
2189
|
-
compare2,
|
|
2190
|
-
debounce,
|
|
2191
|
-
deepEquals,
|
|
2192
|
-
deepMixin,
|
|
2193
|
-
deepMixinT,
|
|
2194
|
-
degreesToRadians,
|
|
2195
|
-
dirname,
|
|
2196
|
-
endsWith,
|
|
2197
|
-
espTime2Seconds,
|
|
2198
|
-
exists,
|
|
2199
|
-
find,
|
|
2200
|
-
getScriptSrc,
|
|
2201
|
-
hashSum,
|
|
2202
|
-
inner,
|
|
2203
|
-
isArray,
|
|
2204
|
-
isBrowser,
|
|
2205
|
-
isCI,
|
|
2206
|
-
isNode,
|
|
2207
|
-
join,
|
|
2208
|
-
logger,
|
|
2209
|
-
normalize,
|
|
2210
|
-
normalizeDegrees,
|
|
2211
|
-
normalizeRadians,
|
|
2212
|
-
polarToCartesian,
|
|
2213
|
-
promiseTimeout,
|
|
2214
|
-
radiansToDegrees,
|
|
2215
|
-
root,
|
|
2216
|
-
safeStringify,
|
|
2217
|
-
scopedLogger,
|
|
2218
|
-
sleep,
|
|
2219
|
-
trim,
|
|
2220
|
-
update,
|
|
2221
|
-
verboseDeepEquals,
|
|
2222
|
-
xml2json
|
|
2223
|
-
};
|
|
2224
|
-
//# sourceMappingURL=index.js.map
|
|
1946
|
+
|
|
1947
|
+
//#endregion
|
|
1948
|
+
export { AsyncCache, AsyncOrderedQueue, BUILD_VERSION, Cache, Dictionary, DictionaryNoCase, Dispatch, Edge, Graph, Graph2, GraphItem, Level, Logging, Message, Observable, PKG_NAME, PKG_VERSION, SAXStackParser, ScopedLogging, Stack, StateObject, Subgraph, Vertex, XMLNode, cartesianToPolar, classID2Meta, compare, compare2, debounce, deepEquals, deepMixin, deepMixinT, degreesToRadians, dirname, endsWith, espTime2Seconds, exists, find, getScriptSrc, hashSum, inner, isArray, isBrowser, isCI, isNode, join, logger, normalize, normalizeDegrees, normalizeRadians, polarToCartesian, promiseTimeout, radiansToDegrees, root, safeStringify, scopedLogger, sleep, trim, update, verboseDeepEquals, xml2json };
|
|
1949
|
+
//# sourceMappingURL=index.js.map
|