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