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