fable 3.0.18 → 3.0.21
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/.babelrc +3 -0
- package/.browserslistrc +1 -0
- package/.browserslistrc_compatible +1 -0
- package/.browserslistrc_default +1 -0
- package/dist/fable.compatible.js +3219 -0
- package/dist/fable.compatible.min.js +117 -0
- package/dist/fable.compatible.min.js.map +1 -0
- package/dist/fable.js +600 -138
- package/dist/fable.min.js +19 -14
- package/dist/fable.min.js.map +1 -1
- package/gulpfile-config.json +11 -0
- package/gulpfile-config_compatible.json +11 -0
- package/gulpfile-config_default.json +11 -0
- package/gulpfile.js +97 -16
- package/package.json +6 -1
- package/source/Fable-Service-DataArithmatic.js +16 -0
- package/source/{Fable-Utility.js → Fable-Service-Utility.js} +16 -4
- package/source/Fable.js +14 -4
- package/test/FableDataArithmatic_tests.js +223 -0
- package/test/Fable_tests.js +0 -1
|
@@ -0,0 +1,3219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
10
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
11
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
15
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
21
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
23
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
24
|
+
(function (f) {
|
|
25
|
+
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") {
|
|
26
|
+
module.exports = f();
|
|
27
|
+
} else if (typeof define === "function" && define.amd) {
|
|
28
|
+
define([], f);
|
|
29
|
+
} else {
|
|
30
|
+
var g;
|
|
31
|
+
if (typeof window !== "undefined") {
|
|
32
|
+
g = window;
|
|
33
|
+
} else if (typeof global !== "undefined") {
|
|
34
|
+
g = global;
|
|
35
|
+
} else if (typeof self !== "undefined") {
|
|
36
|
+
g = self;
|
|
37
|
+
} else {
|
|
38
|
+
g = this;
|
|
39
|
+
}
|
|
40
|
+
g.Fable = f();
|
|
41
|
+
}
|
|
42
|
+
})(function () {
|
|
43
|
+
var define, module, exports;
|
|
44
|
+
return function () {
|
|
45
|
+
function r(e, n, t) {
|
|
46
|
+
function o(i, f) {
|
|
47
|
+
if (!n[i]) {
|
|
48
|
+
if (!e[i]) {
|
|
49
|
+
var c = "function" == typeof require && require;
|
|
50
|
+
if (!f && c) return c(i, !0);
|
|
51
|
+
if (u) return u(i, !0);
|
|
52
|
+
var a = new Error("Cannot find module '" + i + "'");
|
|
53
|
+
throw a.code = "MODULE_NOT_FOUND", a;
|
|
54
|
+
}
|
|
55
|
+
var p = n[i] = {
|
|
56
|
+
exports: {}
|
|
57
|
+
};
|
|
58
|
+
e[i][0].call(p.exports, function (r) {
|
|
59
|
+
var n = e[i][1][r];
|
|
60
|
+
return o(n || r);
|
|
61
|
+
}, p, p.exports, r, e, n, t);
|
|
62
|
+
}
|
|
63
|
+
return n[i].exports;
|
|
64
|
+
}
|
|
65
|
+
for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) o(t[i]);
|
|
66
|
+
return o;
|
|
67
|
+
}
|
|
68
|
+
return r;
|
|
69
|
+
}()({
|
|
70
|
+
1: [function (require, module, exports) {
|
|
71
|
+
'use strict';
|
|
72
|
+
|
|
73
|
+
var eachOfLimit = require('async.util.eachoflimit');
|
|
74
|
+
var withoutIndex = require('async.util.withoutindex');
|
|
75
|
+
module.exports = function eachLimit(arr, limit, iterator, cb) {
|
|
76
|
+
return eachOfLimit(limit)(arr, withoutIndex(iterator), cb);
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
"async.util.eachoflimit": 3,
|
|
80
|
+
"async.util.withoutindex": 14
|
|
81
|
+
}],
|
|
82
|
+
2: [function (require, module, exports) {
|
|
83
|
+
'use strict';
|
|
84
|
+
|
|
85
|
+
module.exports = function (tasks) {
|
|
86
|
+
function makeCallback(index) {
|
|
87
|
+
function fn() {
|
|
88
|
+
if (tasks.length) {
|
|
89
|
+
tasks[index].apply(null, arguments);
|
|
90
|
+
}
|
|
91
|
+
return fn.next();
|
|
92
|
+
}
|
|
93
|
+
fn.next = function () {
|
|
94
|
+
return index < tasks.length - 1 ? makeCallback(index + 1) : null;
|
|
95
|
+
};
|
|
96
|
+
return fn;
|
|
97
|
+
}
|
|
98
|
+
return makeCallback(0);
|
|
99
|
+
};
|
|
100
|
+
}, {}],
|
|
101
|
+
3: [function (require, module, exports) {
|
|
102
|
+
var once = require('async.util.once');
|
|
103
|
+
var noop = require('async.util.noop');
|
|
104
|
+
var onlyOnce = require('async.util.onlyonce');
|
|
105
|
+
var keyIterator = require('async.util.keyiterator');
|
|
106
|
+
module.exports = function eachOfLimit(limit) {
|
|
107
|
+
return function (obj, iterator, cb) {
|
|
108
|
+
cb = once(cb || noop);
|
|
109
|
+
obj = obj || [];
|
|
110
|
+
var nextKey = keyIterator(obj);
|
|
111
|
+
if (limit <= 0) {
|
|
112
|
+
return cb(null);
|
|
113
|
+
}
|
|
114
|
+
var done = false;
|
|
115
|
+
var running = 0;
|
|
116
|
+
var errored = false;
|
|
117
|
+
(function replenish() {
|
|
118
|
+
if (done && running <= 0) {
|
|
119
|
+
return cb(null);
|
|
120
|
+
}
|
|
121
|
+
while (running < limit && !errored) {
|
|
122
|
+
var key = nextKey();
|
|
123
|
+
if (key === null) {
|
|
124
|
+
done = true;
|
|
125
|
+
if (running <= 0) {
|
|
126
|
+
cb(null);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
running += 1;
|
|
131
|
+
iterator(obj[key], key, onlyOnce(function (err) {
|
|
132
|
+
running -= 1;
|
|
133
|
+
if (err) {
|
|
134
|
+
cb(err);
|
|
135
|
+
errored = true;
|
|
136
|
+
} else {
|
|
137
|
+
replenish();
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
}, {
|
|
145
|
+
"async.util.keyiterator": 7,
|
|
146
|
+
"async.util.noop": 9,
|
|
147
|
+
"async.util.once": 10,
|
|
148
|
+
"async.util.onlyonce": 11
|
|
149
|
+
}],
|
|
150
|
+
4: [function (require, module, exports) {
|
|
151
|
+
'use strict';
|
|
152
|
+
|
|
153
|
+
var setImmediate = require('async.util.setimmediate');
|
|
154
|
+
var restParam = require('async.util.restparam');
|
|
155
|
+
module.exports = function (fn) {
|
|
156
|
+
return restParam(function (args) {
|
|
157
|
+
var callback = args.pop();
|
|
158
|
+
args.push(function () {
|
|
159
|
+
var innerArgs = arguments;
|
|
160
|
+
if (sync) {
|
|
161
|
+
setImmediate(function () {
|
|
162
|
+
callback.apply(null, innerArgs);
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
callback.apply(null, innerArgs);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
var sync = true;
|
|
169
|
+
fn.apply(this, args);
|
|
170
|
+
sync = false;
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
}, {
|
|
174
|
+
"async.util.restparam": 12,
|
|
175
|
+
"async.util.setimmediate": 13
|
|
176
|
+
}],
|
|
177
|
+
5: [function (require, module, exports) {
|
|
178
|
+
'use strict';
|
|
179
|
+
|
|
180
|
+
module.exports = Array.isArray || function isArray(obj) {
|
|
181
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
182
|
+
};
|
|
183
|
+
}, {}],
|
|
184
|
+
6: [function (require, module, exports) {
|
|
185
|
+
'use strict';
|
|
186
|
+
|
|
187
|
+
var isArray = require('async.util.isarray');
|
|
188
|
+
module.exports = function isArrayLike(arr) {
|
|
189
|
+
return isArray(arr) ||
|
|
190
|
+
// has a positive integer length property
|
|
191
|
+
typeof arr.length === 'number' && arr.length >= 0 && arr.length % 1 === 0;
|
|
192
|
+
};
|
|
193
|
+
}, {
|
|
194
|
+
"async.util.isarray": 5
|
|
195
|
+
}],
|
|
196
|
+
7: [function (require, module, exports) {
|
|
197
|
+
'use strict';
|
|
198
|
+
|
|
199
|
+
var _keys = require('async.util.keys');
|
|
200
|
+
var isArrayLike = require('async.util.isarraylike');
|
|
201
|
+
module.exports = function keyIterator(coll) {
|
|
202
|
+
var i = -1;
|
|
203
|
+
var len;
|
|
204
|
+
var keys;
|
|
205
|
+
if (isArrayLike(coll)) {
|
|
206
|
+
len = coll.length;
|
|
207
|
+
return function next() {
|
|
208
|
+
i++;
|
|
209
|
+
return i < len ? i : null;
|
|
210
|
+
};
|
|
211
|
+
} else {
|
|
212
|
+
keys = _keys(coll);
|
|
213
|
+
len = keys.length;
|
|
214
|
+
return function next() {
|
|
215
|
+
i++;
|
|
216
|
+
return i < len ? keys[i] : null;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}, {
|
|
221
|
+
"async.util.isarraylike": 6,
|
|
222
|
+
"async.util.keys": 8
|
|
223
|
+
}],
|
|
224
|
+
8: [function (require, module, exports) {
|
|
225
|
+
'use strict';
|
|
226
|
+
|
|
227
|
+
module.exports = Object.keys || function keys(obj) {
|
|
228
|
+
var _keys = [];
|
|
229
|
+
for (var k in obj) {
|
|
230
|
+
if (obj.hasOwnProperty(k)) {
|
|
231
|
+
_keys.push(k);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return _keys;
|
|
235
|
+
};
|
|
236
|
+
}, {}],
|
|
237
|
+
9: [function (require, module, exports) {
|
|
238
|
+
'use strict';
|
|
239
|
+
|
|
240
|
+
module.exports = function noop() {};
|
|
241
|
+
}, {}],
|
|
242
|
+
10: [function (require, module, exports) {
|
|
243
|
+
'use strict';
|
|
244
|
+
|
|
245
|
+
module.exports = function once(fn) {
|
|
246
|
+
return function () {
|
|
247
|
+
if (fn === null) return;
|
|
248
|
+
fn.apply(this, arguments);
|
|
249
|
+
fn = null;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
}, {}],
|
|
253
|
+
11: [function (require, module, exports) {
|
|
254
|
+
'use strict';
|
|
255
|
+
|
|
256
|
+
module.exports = function only_once(fn) {
|
|
257
|
+
return function () {
|
|
258
|
+
if (fn === null) throw new Error('Callback was already called.');
|
|
259
|
+
fn.apply(this, arguments);
|
|
260
|
+
fn = null;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
}, {}],
|
|
264
|
+
12: [function (require, module, exports) {
|
|
265
|
+
'use strict';
|
|
266
|
+
|
|
267
|
+
module.exports = function restParam(func, startIndex) {
|
|
268
|
+
startIndex = startIndex == null ? func.length - 1 : +startIndex;
|
|
269
|
+
return function () {
|
|
270
|
+
var length = Math.max(arguments.length - startIndex, 0);
|
|
271
|
+
var rest = new Array(length);
|
|
272
|
+
for (var index = 0; index < length; index++) {
|
|
273
|
+
rest[index] = arguments[index + startIndex];
|
|
274
|
+
}
|
|
275
|
+
switch (startIndex) {
|
|
276
|
+
case 0:
|
|
277
|
+
return func.call(this, rest);
|
|
278
|
+
case 1:
|
|
279
|
+
return func.call(this, arguments[0], rest);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
}, {}],
|
|
284
|
+
13: [function (require, module, exports) {
|
|
285
|
+
(function (setImmediate) {
|
|
286
|
+
(function () {
|
|
287
|
+
'use strict';
|
|
288
|
+
|
|
289
|
+
var _setImmediate = typeof setImmediate === 'function' && setImmediate;
|
|
290
|
+
var fallback = function fallback(fn) {
|
|
291
|
+
setTimeout(fn, 0);
|
|
292
|
+
};
|
|
293
|
+
module.exports = function setImmediate(fn) {
|
|
294
|
+
// not a direct alias for IE10 compatibility
|
|
295
|
+
return (_setImmediate || fallback)(fn);
|
|
296
|
+
};
|
|
297
|
+
}).call(this);
|
|
298
|
+
}).call(this, require("timers").setImmediate);
|
|
299
|
+
}, {
|
|
300
|
+
"timers": 34
|
|
301
|
+
}],
|
|
302
|
+
14: [function (require, module, exports) {
|
|
303
|
+
'use strict';
|
|
304
|
+
|
|
305
|
+
module.exports = function withoutIndex(iterator) {
|
|
306
|
+
return function (value, index, callback) {
|
|
307
|
+
return iterator(value, callback);
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
}, {}],
|
|
311
|
+
15: [function (require, module, exports) {
|
|
312
|
+
'use strict';
|
|
313
|
+
|
|
314
|
+
var once = require('async.util.once');
|
|
315
|
+
var noop = require('async.util.noop');
|
|
316
|
+
var isArray = require('async.util.isarray');
|
|
317
|
+
var restParam = require('async.util.restparam');
|
|
318
|
+
var ensureAsync = require('async.util.ensureasync');
|
|
319
|
+
var iterator = require('async.iterator');
|
|
320
|
+
module.exports = function (tasks, cb) {
|
|
321
|
+
cb = once(cb || noop);
|
|
322
|
+
if (!isArray(tasks)) return cb(new Error('First argument to waterfall must be an array of functions'));
|
|
323
|
+
if (!tasks.length) return cb();
|
|
324
|
+
function wrapIterator(iterator) {
|
|
325
|
+
return restParam(function (err, args) {
|
|
326
|
+
if (err) {
|
|
327
|
+
cb.apply(null, [err].concat(args));
|
|
328
|
+
} else {
|
|
329
|
+
var next = iterator.next();
|
|
330
|
+
if (next) {
|
|
331
|
+
args.push(wrapIterator(next));
|
|
332
|
+
} else {
|
|
333
|
+
args.push(cb);
|
|
334
|
+
}
|
|
335
|
+
ensureAsync(iterator).apply(null, args);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
wrapIterator(iterator(tasks))();
|
|
340
|
+
};
|
|
341
|
+
}, {
|
|
342
|
+
"async.iterator": 2,
|
|
343
|
+
"async.util.ensureasync": 4,
|
|
344
|
+
"async.util.isarray": 5,
|
|
345
|
+
"async.util.noop": 9,
|
|
346
|
+
"async.util.once": 10,
|
|
347
|
+
"async.util.restparam": 12
|
|
348
|
+
}],
|
|
349
|
+
16: [function (require, module, exports) {}, {}],
|
|
350
|
+
17: [function (require, module, exports) {
|
|
351
|
+
/**
|
|
352
|
+
* @license MIT
|
|
353
|
+
* @author <steven@velozo.com>
|
|
354
|
+
*/
|
|
355
|
+
/**
|
|
356
|
+
* Data Arithmatic
|
|
357
|
+
*
|
|
358
|
+
* @class DataArithmatic
|
|
359
|
+
*/
|
|
360
|
+
var DataArithmatic = /*#__PURE__*/function () {
|
|
361
|
+
function DataArithmatic() {
|
|
362
|
+
_classCallCheck(this, DataArithmatic);
|
|
363
|
+
// Regular Expressions (so they don't have to be recompiled every time)
|
|
364
|
+
// These could be defined as static, but I'm not sure if that will work with browserify ... and specifically the QT browser.
|
|
365
|
+
this._Regex_formatterInsertCommas = /.{1,3}/g;
|
|
366
|
+
// Match Function:
|
|
367
|
+
// function(pMatch, pSign, pZeros, pBefore, pDecimal, pAfter)
|
|
368
|
+
// Thoughts about below: /^([+-]?)(0*)(\d+)(\.(\d+))?$/;
|
|
369
|
+
this._Regex_formatterAddCommasToNumber = /^([-+]?)(0?)(\d+)(.?)(\d+)$/g;
|
|
370
|
+
this._Regex_formatterDollarsRemoveCommas = /,/gi;
|
|
371
|
+
this._Regex_formatterCleanNonAlpha = /[^a-z0-9]/gi;
|
|
372
|
+
|
|
373
|
+
// TODO: Potentially pull these in from a configuration.
|
|
374
|
+
// TODO: Use locale data for this if it's defaults all the way down.
|
|
375
|
+
this._Value_MoneySign_Currency = '$';
|
|
376
|
+
this._Value_NaN_Currency = '--';
|
|
377
|
+
this._Value_GroupSeparator_Number = ',';
|
|
378
|
+
this._Value_Prefix_StringHash = 'HSH';
|
|
379
|
+
this._Value_Clean_formatterCleanNonAlpha = '_';
|
|
380
|
+
this._UseEngineStringStartsWith = typeof String.prototype.startsWith === 'function';
|
|
381
|
+
this._UseEngineStringEndsWith = typeof String.prototype.endsWith === 'function';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/*************************************************************************
|
|
385
|
+
* String Manipulation and Comparison Functions
|
|
386
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Reverse a string
|
|
390
|
+
*
|
|
391
|
+
* @param {string} pString - The string to reverse
|
|
392
|
+
* @returns {string}
|
|
393
|
+
*/
|
|
394
|
+
_createClass(DataArithmatic, [{
|
|
395
|
+
key: "stringReverse",
|
|
396
|
+
value: function stringReverse(pString) {
|
|
397
|
+
// TODO: Benchmark if there are faster ways we want to do this with all the newer JS stuff
|
|
398
|
+
// ... and if it will work with browserify in a clean way.
|
|
399
|
+
return pString.split('').reverse().join('');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Test if a string starts with a given substring.
|
|
404
|
+
*
|
|
405
|
+
* @param {*} pString
|
|
406
|
+
* @param {*} pSearchString
|
|
407
|
+
* @param {*} pStartIndex
|
|
408
|
+
* @returns {*}
|
|
409
|
+
*/
|
|
410
|
+
}, {
|
|
411
|
+
key: "stringStartsWith",
|
|
412
|
+
value: function stringStartsWith(pString, pSearchString, pStartIndex) {
|
|
413
|
+
if (this._UseEngineStringStartsWith) {
|
|
414
|
+
return pString.startsWith(pSearchString, pStartIndex);
|
|
415
|
+
} else {
|
|
416
|
+
return this.stringStartsWith_Polyfill.call(pString, pSearchString, pStartIndex);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Check if a string starts with a given substring. This is a safe polyfill for the ES6 string.startsWith() function.
|
|
422
|
+
*
|
|
423
|
+
* @param {*} pSearchString - The string to search for
|
|
424
|
+
* @param {*} pStartIndex - The index to start the search at
|
|
425
|
+
* @returns {boolean}
|
|
426
|
+
*/
|
|
427
|
+
}, {
|
|
428
|
+
key: "stringStartsWith_Polyfill",
|
|
429
|
+
value: function stringStartsWith_Polyfill(pSearchString, pStartIndex) {
|
|
430
|
+
return this.slice(pStartIndex || 0, pSearchString.length) === pSearchString;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Test if a string starts with a given substring.
|
|
435
|
+
*
|
|
436
|
+
* @param {*} pString
|
|
437
|
+
* @param {*} pSearchString
|
|
438
|
+
* @param {*} pEndIndex
|
|
439
|
+
* @returns {*}
|
|
440
|
+
*/
|
|
441
|
+
}, {
|
|
442
|
+
key: "stringEndsWith",
|
|
443
|
+
value: function stringEndsWith(pString, pSearchString, pEndIndex) {
|
|
444
|
+
if (this._UseEngineStringEndsWith) {
|
|
445
|
+
return pString.endsWith(pSearchString, pEndIndex);
|
|
446
|
+
} else {
|
|
447
|
+
return this.stringEndsWith_Polyfill.call(pString, pSearchString, pEndIndex);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Check if a string starts with a given substring. This is a safe polyfill for the ES6 string.startsWith() function.
|
|
453
|
+
*
|
|
454
|
+
* @param {*} pSearchString - The string to search for
|
|
455
|
+
* @param {*} pEndIndex - The index to end the search at
|
|
456
|
+
* @returns {boolean}
|
|
457
|
+
*/
|
|
458
|
+
}, {
|
|
459
|
+
key: "stringEndsWith_Polyfill",
|
|
460
|
+
value: function stringEndsWith_Polyfill(pSearchString, pEndIndex) {
|
|
461
|
+
// This works much better than >= because
|
|
462
|
+
// it compensates for NaN:
|
|
463
|
+
if (!(pEndIndex < this.length)) {
|
|
464
|
+
pEndIndex = this.length;
|
|
465
|
+
} else {
|
|
466
|
+
pEndIndex |= 0; // round position
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
return this.substr(pEndIndex - pSearchString.length, pSearchString.length) === pSearchString;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Generate an insecure string hash. Not meant to be secure, just a quick way to generate a hash for a string. This is not a cryptographic hash. Additional warranty and disclaimer ... this is not for passwords!
|
|
474
|
+
*
|
|
475
|
+
* @param {string} pString
|
|
476
|
+
* @returns {string}
|
|
477
|
+
*/
|
|
478
|
+
}, {
|
|
479
|
+
key: "insecureStringHash",
|
|
480
|
+
value: function insecureStringHash(pString) {
|
|
481
|
+
var tmpHash = 0;
|
|
482
|
+
var tmpStringLength = pString.length;
|
|
483
|
+
var tmpCharacterIndex = 0;
|
|
484
|
+
while (tmpCharacterIndex < tmpStringLength) {
|
|
485
|
+
tmpHash = (tmpHash << 5) - tmpHash + pString.charCodeAt(tmpCharacterIndex++) | 0;
|
|
486
|
+
}
|
|
487
|
+
return "".concat(this._Value_Prefix_StringHash).concat(tmpHash);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Clean wrapping characters if they exist consistently around the string. If they do not, the string is returned unchanged.
|
|
492
|
+
*
|
|
493
|
+
* @param {string} pWrapCharacter - The character expected as the wrapping character
|
|
494
|
+
* @param {string} pString - the string to clean
|
|
495
|
+
* @returns {string}
|
|
496
|
+
*/
|
|
497
|
+
}, {
|
|
498
|
+
key: "cleanEnclosureWrapCharacters",
|
|
499
|
+
value: function cleanEnclosureWrapCharacters(pWrapCharacter, pString) {
|
|
500
|
+
// # Use case from ManyFest DSL:
|
|
501
|
+
//
|
|
502
|
+
// When a boxed property is passed in, it should have quotes of some
|
|
503
|
+
// kind around it.
|
|
504
|
+
//
|
|
505
|
+
// For instance:
|
|
506
|
+
// MyValues['Name']
|
|
507
|
+
// MyValues["Age"]
|
|
508
|
+
// MyValues[`Cost`]
|
|
509
|
+
//
|
|
510
|
+
// This function is necessary to remove the wrapping quotes before object
|
|
511
|
+
// resolution can occur.
|
|
512
|
+
if (pString.startsWith(pWrapCharacter) && pString.endsWith(pWrapCharacter)) {
|
|
513
|
+
return pString.substring(1, pString.length - 1);
|
|
514
|
+
} else {
|
|
515
|
+
return pString;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
*
|
|
521
|
+
* @param {*} pString
|
|
522
|
+
* @returns
|
|
523
|
+
*/
|
|
524
|
+
}, {
|
|
525
|
+
key: "cleanNonAlphaCharacters",
|
|
526
|
+
value: function cleanNonAlphaCharacters(pString) {
|
|
527
|
+
if (typeof pString == 'string' && pString != '') {
|
|
528
|
+
return pString.replace(this._Regex_formatterCleanNonAlpha, this._Value_Clean_formatterCleanNonAlpha);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/*************************************************************************
|
|
533
|
+
* Number Formatting Functions
|
|
534
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Insert commas every 3 characters from the right. Used by formatterAddCommasToNumber().
|
|
538
|
+
*
|
|
539
|
+
* @param {*} pString
|
|
540
|
+
* @returns {*}
|
|
541
|
+
*/
|
|
542
|
+
}, {
|
|
543
|
+
key: "formatterInsertCommas",
|
|
544
|
+
value: function formatterInsertCommas(pString) {
|
|
545
|
+
// Reverse, because it's easier to do things from the left, given arbitrary digit counts
|
|
546
|
+
var tmpReversed = this.stringReverse(pString);
|
|
547
|
+
// Add commas every three characters
|
|
548
|
+
var tmpReversedWithCommas = tmpReversed.match(this._Regex_formatterInsertCommas).join(',');
|
|
549
|
+
// Reverse again (back to normal direction)
|
|
550
|
+
return this.stringReverse(tmpReversedWithCommas);
|
|
551
|
+
}
|
|
552
|
+
}, {
|
|
553
|
+
key: "processAddCommasToNumberRegex",
|
|
554
|
+
value: function processAddCommasToNumberRegex(pMatch, pSign, pZeros, pBefore, pDecimal, pAfter) {
|
|
555
|
+
// If there was no decimal, the last capture grabs the final digit, so
|
|
556
|
+
// we have to put it back together with the 'before' substring
|
|
557
|
+
return pSign + (pDecimal ? this.formatterInsertCommas(pBefore) + pDecimal + pAfter : this.formatterInsertCommas(pBefore + pAfter));
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Add Commas to a Number for readability.
|
|
562
|
+
*
|
|
563
|
+
* @param {*} pNumber
|
|
564
|
+
* @returns {string}
|
|
565
|
+
*/
|
|
566
|
+
}, {
|
|
567
|
+
key: "formatterAddCommasToNumber",
|
|
568
|
+
value: function formatterAddCommasToNumber(pNumber) {
|
|
569
|
+
// If the regex doesn't match, `replace` returns the string unmodified
|
|
570
|
+
return pNumber.toString().replace(this._Regex_formatterAddCommasToNumber, this.processAddCommasToNumberRegex.bind(this));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* This will take a number and format it as a dollar string. It will also add commas to the number. If the number is not a number, it will return '--'.
|
|
575
|
+
*
|
|
576
|
+
* @param {*} pValue
|
|
577
|
+
* @returns {string}
|
|
578
|
+
*/
|
|
579
|
+
}, {
|
|
580
|
+
key: "formatterDollars",
|
|
581
|
+
value: function formatterDollars(pValue) {
|
|
582
|
+
var tmpDollarAmount = parseFloat(pValue).toFixed(2);
|
|
583
|
+
if (isNaN(tmpDollarAmount)) {
|
|
584
|
+
// Try again and see if what was passed in was a dollars string.
|
|
585
|
+
if (typeof pValue == 'string') {
|
|
586
|
+
// TODO: Better rounding function? This is a hack to get rid of the currency symbol and commas.
|
|
587
|
+
tmpDollarAmount = parseFloat(pValue.replace(this._Value_MoneySign_Currency, '').replace(this._Regex_formatterDollarsRemoveCommas, '')).toFixed(2);
|
|
588
|
+
}
|
|
589
|
+
// If we didn't get a number, return the "not a number" string.
|
|
590
|
+
if (isNaN(tmpDollarAmount)) {
|
|
591
|
+
return this._Value_NaN_Currency;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// TODO: Get locale data and use that for this stuff.
|
|
596
|
+
return "$".concat(this.formatterAddCommasToNumber(tmpDollarAmount));
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Round a number to a certain number of digits. If the number is not a number, it will return 0. If no digits are specified, it will default to 2 significant digits.
|
|
601
|
+
*
|
|
602
|
+
* @param {*} pValue
|
|
603
|
+
* @param {number} pDigits
|
|
604
|
+
* @returns {string}
|
|
605
|
+
*/
|
|
606
|
+
}, {
|
|
607
|
+
key: "formatterRoundNumber",
|
|
608
|
+
value: function formatterRoundNumber(pValue, pDigits) {
|
|
609
|
+
var tmpDigits = typeof pDigits == 'undefined' ? 2 : pDigits;
|
|
610
|
+
var tmpValue = Number.parseFloat(pValue).toFixed(tmpDigits);
|
|
611
|
+
if (isNaN(tmpValue)) {
|
|
612
|
+
var tmpZed = 0;
|
|
613
|
+
return tmpZed.toFixed(tmpDigits);
|
|
614
|
+
} else {
|
|
615
|
+
return tmpValue;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/*************************************************************************
|
|
620
|
+
* String Tokenization Functions
|
|
621
|
+
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Return the string before the matched substring.
|
|
625
|
+
*
|
|
626
|
+
* If the substring is not found, the entire string is returned. This only deals with the *first* match.
|
|
627
|
+
*
|
|
628
|
+
* @param {string} pString
|
|
629
|
+
* @param {string} pMatch
|
|
630
|
+
* @returns {string}
|
|
631
|
+
*/
|
|
632
|
+
}, {
|
|
633
|
+
key: "stringBeforeMatch",
|
|
634
|
+
value: function stringBeforeMatch(pString, pMatch) {
|
|
635
|
+
return pString.split(pMatch)[0];
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Return the string after the matched substring.
|
|
640
|
+
*
|
|
641
|
+
* If the substring is not found, an empty string is returned. This only deals with the *first* match.
|
|
642
|
+
*
|
|
643
|
+
* @param {string} pString
|
|
644
|
+
* @param {string} pMatch
|
|
645
|
+
* @returns {string}
|
|
646
|
+
*/
|
|
647
|
+
}, {
|
|
648
|
+
key: "stringAfterMatch",
|
|
649
|
+
value: function stringAfterMatch(pString, pMatch) {
|
|
650
|
+
var tmpStringSplitLocation = pString.indexOf(pMatch);
|
|
651
|
+
if (tmpStringSplitLocation < 0 || tmpStringSplitLocation + pMatch.length >= pString.length) {
|
|
652
|
+
return '';
|
|
653
|
+
}
|
|
654
|
+
return pString.substring(tmpStringSplitLocation + pMatch.length);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Count the number of enclosures in a string based on the start and end characters.
|
|
659
|
+
*
|
|
660
|
+
* If no start or end characters are specified, it will default to parentheses. If the string is not a string, it will return 0.
|
|
661
|
+
*
|
|
662
|
+
* @param {string} pString
|
|
663
|
+
* @param {string} pEnclosureStart
|
|
664
|
+
* @param {string} pEnclosureEnd
|
|
665
|
+
* @returns the count of full in the string
|
|
666
|
+
*/
|
|
667
|
+
}, {
|
|
668
|
+
key: "stringCountEnclosures",
|
|
669
|
+
value: function stringCountEnclosures(pString, pEnclosureStart, pEnclosureEnd) {
|
|
670
|
+
var tmpString = typeof pString == 'string' ? pString : '';
|
|
671
|
+
var tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
672
|
+
var tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
673
|
+
var tmpEnclosureCount = 0;
|
|
674
|
+
var tmpEnclosureDepth = 0;
|
|
675
|
+
for (var i = 0; i < tmpString.length; i++) {
|
|
676
|
+
// This is the start of an enclosure
|
|
677
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
678
|
+
if (tmpEnclosureDepth == 0) {
|
|
679
|
+
tmpEnclosureCount++;
|
|
680
|
+
}
|
|
681
|
+
tmpEnclosureDepth++;
|
|
682
|
+
} else if (tmpString[i] == tmpEnclosureEnd) {
|
|
683
|
+
tmpEnclosureDepth--;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return tmpEnclosureCount;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* Get the value of the enclosure at the specified index.
|
|
691
|
+
*
|
|
692
|
+
* If the index is not a number, it will default to 0. If the string is not a string, it will return an empty string. If the enclosure is not found, it will return an empty string. If the enclosure
|
|
693
|
+
*
|
|
694
|
+
* @param {string} pString
|
|
695
|
+
* @param {number} pEnclosureIndexToGet
|
|
696
|
+
* @param {string} pEnclosureStart
|
|
697
|
+
* @param {string}} pEnclosureEnd
|
|
698
|
+
* @returns {string}
|
|
699
|
+
*/
|
|
700
|
+
}, {
|
|
701
|
+
key: "stringGetEnclosureValueByIndex",
|
|
702
|
+
value: function stringGetEnclosureValueByIndex(pString, pEnclosureIndexToGet, pEnclosureStart, pEnclosureEnd) {
|
|
703
|
+
var tmpString = typeof pString == 'string' ? pString : '';
|
|
704
|
+
var tmpEnclosureIndexToGet = typeof pEnclosureIndexToGet == 'number' ? pEnclosureIndexToGet : 0;
|
|
705
|
+
var tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
706
|
+
var tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
707
|
+
var tmpEnclosureCount = 0;
|
|
708
|
+
var tmpEnclosureDepth = 0;
|
|
709
|
+
var tmpMatchedEnclosureIndex = false;
|
|
710
|
+
var tmpEnclosedValueStartIndex = 0;
|
|
711
|
+
var tmpEnclosedValueEndIndex = 0;
|
|
712
|
+
for (var i = 0; i < tmpString.length; i++) {
|
|
713
|
+
// This is the start of an enclosure
|
|
714
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
715
|
+
tmpEnclosureDepth++;
|
|
716
|
+
|
|
717
|
+
// Only count enclosures at depth 1, but still this parses both pairs of all of them.
|
|
718
|
+
if (tmpEnclosureDepth == 1) {
|
|
719
|
+
tmpEnclosureCount++;
|
|
720
|
+
if (tmpEnclosureIndexToGet == tmpEnclosureCount - 1) {
|
|
721
|
+
// This is the start of *the* enclosure
|
|
722
|
+
tmpMatchedEnclosureIndex = true;
|
|
723
|
+
tmpEnclosedValueStartIndex = i;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
// This is the end of an enclosure
|
|
728
|
+
else if (tmpString[i] == tmpEnclosureEnd) {
|
|
729
|
+
tmpEnclosureDepth--;
|
|
730
|
+
|
|
731
|
+
// Again, only count enclosures at depth 1, but still this parses both pairs of all of them.
|
|
732
|
+
if (tmpEnclosureDepth == 0 && tmpMatchedEnclosureIndex && tmpEnclosedValueEndIndex <= tmpEnclosedValueStartIndex) {
|
|
733
|
+
tmpEnclosedValueEndIndex = i;
|
|
734
|
+
tmpMatchedEnclosureIndex = false;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (tmpEnclosureCount <= tmpEnclosureIndexToGet) {
|
|
739
|
+
// Return an empty string if the enclosure is not found
|
|
740
|
+
return '';
|
|
741
|
+
}
|
|
742
|
+
if (tmpEnclosedValueEndIndex > 0 && tmpEnclosedValueEndIndex > tmpEnclosedValueStartIndex) {
|
|
743
|
+
return tmpString.substring(tmpEnclosedValueStartIndex + 1, tmpEnclosedValueEndIndex);
|
|
744
|
+
} else {
|
|
745
|
+
return tmpString.substring(tmpEnclosedValueStartIndex + 1);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Remove an enclosure from a string based on the index of the enclosure.
|
|
751
|
+
*
|
|
752
|
+
* @param {string} pString
|
|
753
|
+
* @param {number} pEnclosureIndexToRemove
|
|
754
|
+
* @param {number} pEnclosureStart
|
|
755
|
+
* @param {number} pEnclosureEnd
|
|
756
|
+
* @returns {string}
|
|
757
|
+
*/
|
|
758
|
+
}, {
|
|
759
|
+
key: "stringRemoveEnclosureByIndex",
|
|
760
|
+
value: function stringRemoveEnclosureByIndex(pString, pEnclosureIndexToRemove, pEnclosureStart, pEnclosureEnd) {
|
|
761
|
+
var tmpString = typeof pString == 'string' ? pString : '';
|
|
762
|
+
var tmpEnclosureIndexToRemove = typeof pEnclosureIndexToRemove == 'number' ? pEnclosureIndexToRemove : 0;
|
|
763
|
+
var tmpEnclosureStart = typeof pEnclosureStart == 'string' ? pEnclosureStart : '(';
|
|
764
|
+
var tmpEnclosureEnd = typeof pEnclosureEnd == 'string' ? pEnclosureEnd : ')';
|
|
765
|
+
var tmpEnclosureCount = 0;
|
|
766
|
+
var tmpEnclosureDepth = 0;
|
|
767
|
+
var tmpMatchedEnclosureIndex = false;
|
|
768
|
+
var tmpEnclosureStartIndex = 0;
|
|
769
|
+
var tmpEnclosureEndIndex = 0;
|
|
770
|
+
for (var i = 0; i < tmpString.length; i++) {
|
|
771
|
+
// This is the start of an enclosure
|
|
772
|
+
if (tmpString[i] == tmpEnclosureStart) {
|
|
773
|
+
tmpEnclosureDepth++;
|
|
774
|
+
if (tmpEnclosureDepth == 1) {
|
|
775
|
+
tmpEnclosureCount++;
|
|
776
|
+
if (tmpEnclosureIndexToRemove == tmpEnclosureCount - 1) {
|
|
777
|
+
tmpMatchedEnclosureIndex = true;
|
|
778
|
+
tmpEnclosureStartIndex = i;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
} else if (tmpString[i] == tmpEnclosureEnd) {
|
|
782
|
+
tmpEnclosureDepth--;
|
|
783
|
+
if (tmpEnclosureDepth == 0 && tmpMatchedEnclosureIndex && tmpEnclosureEndIndex <= tmpEnclosureStartIndex) {
|
|
784
|
+
tmpEnclosureEndIndex = i;
|
|
785
|
+
tmpMatchedEnclosureIndex = false;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (tmpEnclosureCount <= tmpEnclosureIndexToRemove) {
|
|
790
|
+
return tmpString;
|
|
791
|
+
}
|
|
792
|
+
var tmpReturnString = '';
|
|
793
|
+
if (tmpEnclosureStartIndex > 1) {
|
|
794
|
+
tmpReturnString = tmpString.substring(0, tmpEnclosureStartIndex);
|
|
795
|
+
}
|
|
796
|
+
if (tmpString.length > tmpEnclosureEndIndex + 1 && tmpEnclosureEndIndex > tmpEnclosureStartIndex) {
|
|
797
|
+
tmpReturnString += tmpString.substring(tmpEnclosureEndIndex + 1);
|
|
798
|
+
}
|
|
799
|
+
return tmpReturnString;
|
|
800
|
+
}
|
|
801
|
+
}]);
|
|
802
|
+
return DataArithmatic;
|
|
803
|
+
}();
|
|
804
|
+
module.exports = DataArithmatic;
|
|
805
|
+
}, {}],
|
|
806
|
+
18: [function (require, module, exports) {
|
|
807
|
+
/**
|
|
808
|
+
* Base Logger Class
|
|
809
|
+
*
|
|
810
|
+
* @license MIT
|
|
811
|
+
*
|
|
812
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
813
|
+
*/
|
|
814
|
+
var BaseLogger = /*#__PURE__*/function () {
|
|
815
|
+
function BaseLogger(pLogStreamSettings, pFableLog) {
|
|
816
|
+
_classCallCheck(this, BaseLogger);
|
|
817
|
+
// This should not possibly be able to be instantiated without a settings object
|
|
818
|
+
this._Settings = _typeof(pLogStreamSettings) == 'object' ? pLogStreamSettings : {};
|
|
819
|
+
|
|
820
|
+
// The base logger does nothing but associate a UUID with itself
|
|
821
|
+
// We added this as the mechanism for tracking loggers to allow multiple simultaneous streams
|
|
822
|
+
// to the same provider.
|
|
823
|
+
this.loggerUUID = this.generateInsecureUUID();
|
|
824
|
+
|
|
825
|
+
// Eventually we can use this array to ompute which levels the provider allows.
|
|
826
|
+
// For now it's just used to precompute some string concatenations.
|
|
827
|
+
this.levels = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// This is meant to generate programmatically insecure UUIDs to identify loggers
|
|
831
|
+
_createClass(BaseLogger, [{
|
|
832
|
+
key: "generateInsecureUUID",
|
|
833
|
+
value: function generateInsecureUUID() {
|
|
834
|
+
var tmpDate = new Date().getTime();
|
|
835
|
+
var tmpUUID = 'LOGSTREAM-xxxxxx-yxxxxx'.replace(/[xy]/g, function (pCharacter) {
|
|
836
|
+
// Funny algorithm from w3resource that is twister-ish without the deep math and security
|
|
837
|
+
// ..but good enough for unique log stream identifiers
|
|
838
|
+
var tmpRandomData = (tmpDate + Math.random() * 16) % 16 | 0;
|
|
839
|
+
tmpDate = Math.floor(tmpDate / 16);
|
|
840
|
+
return (pCharacter == 'x' ? tmpRandomData : tmpRandomData & 0x3 | 0x8).toString(16);
|
|
841
|
+
});
|
|
842
|
+
return tmpUUID;
|
|
843
|
+
}
|
|
844
|
+
}, {
|
|
845
|
+
key: "initialize",
|
|
846
|
+
value: function initialize() {
|
|
847
|
+
// No operation.
|
|
848
|
+
}
|
|
849
|
+
}, {
|
|
850
|
+
key: "trace",
|
|
851
|
+
value: function trace(pLogText, pLogObject) {
|
|
852
|
+
this.write("trace", pLogText, pLogObject);
|
|
853
|
+
}
|
|
854
|
+
}, {
|
|
855
|
+
key: "debug",
|
|
856
|
+
value: function debug(pLogText, pLogObject) {
|
|
857
|
+
this.write("debug", pLogText, pLogObject);
|
|
858
|
+
}
|
|
859
|
+
}, {
|
|
860
|
+
key: "info",
|
|
861
|
+
value: function info(pLogText, pLogObject) {
|
|
862
|
+
this.write("info", pLogText, pLogObject);
|
|
863
|
+
}
|
|
864
|
+
}, {
|
|
865
|
+
key: "warn",
|
|
866
|
+
value: function warn(pLogText, pLogObject) {
|
|
867
|
+
this.write("warn", pLogText, pLogObject);
|
|
868
|
+
}
|
|
869
|
+
}, {
|
|
870
|
+
key: "error",
|
|
871
|
+
value: function error(pLogText, pLogObject) {
|
|
872
|
+
this.write("error", pLogText, pLogObject);
|
|
873
|
+
}
|
|
874
|
+
}, {
|
|
875
|
+
key: "fatal",
|
|
876
|
+
value: function fatal(pLogText, pLogObject) {
|
|
877
|
+
this.write("fatal", pLogText, pLogObject);
|
|
878
|
+
}
|
|
879
|
+
}, {
|
|
880
|
+
key: "write",
|
|
881
|
+
value: function write(pLogLevel, pLogText, pLogObject) {
|
|
882
|
+
// The base logger does nothing.
|
|
883
|
+
return true;
|
|
884
|
+
}
|
|
885
|
+
}]);
|
|
886
|
+
return BaseLogger;
|
|
887
|
+
}();
|
|
888
|
+
module.exports = BaseLogger;
|
|
889
|
+
}, {}],
|
|
890
|
+
19: [function (require, module, exports) {
|
|
891
|
+
/**
|
|
892
|
+
* Default Logger Provider Function
|
|
893
|
+
*
|
|
894
|
+
* @license MIT
|
|
895
|
+
*
|
|
896
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
897
|
+
*/
|
|
898
|
+
|
|
899
|
+
// Return the providers that are available without extensions loaded
|
|
900
|
+
getDefaultProviders = function getDefaultProviders() {
|
|
901
|
+
var tmpDefaultProviders = {};
|
|
902
|
+
tmpDefaultProviders.console = require('./Fable-Log-Logger-Console.js');
|
|
903
|
+
tmpDefaultProviders["default"] = tmpDefaultProviders.console;
|
|
904
|
+
return tmpDefaultProviders;
|
|
905
|
+
};
|
|
906
|
+
module.exports = getDefaultProviders();
|
|
907
|
+
}, {
|
|
908
|
+
"./Fable-Log-Logger-Console.js": 21
|
|
909
|
+
}],
|
|
910
|
+
20: [function (require, module, exports) {
|
|
911
|
+
module.exports = [{
|
|
912
|
+
"loggertype": "console",
|
|
913
|
+
"streamtype": "console",
|
|
914
|
+
"level": "trace"
|
|
915
|
+
}];
|
|
916
|
+
}, {}],
|
|
917
|
+
21: [function (require, module, exports) {
|
|
918
|
+
var libBaseLogger = require('./Fable-Log-BaseLogger.js');
|
|
919
|
+
var ConsoleLogger = /*#__PURE__*/function (_libBaseLogger) {
|
|
920
|
+
_inherits(ConsoleLogger, _libBaseLogger);
|
|
921
|
+
var _super = _createSuper(ConsoleLogger);
|
|
922
|
+
function ConsoleLogger(pLogStreamSettings, pFableLog) {
|
|
923
|
+
var _this;
|
|
924
|
+
_classCallCheck(this, ConsoleLogger);
|
|
925
|
+
_this = _super.call(this, pLogStreamSettings);
|
|
926
|
+
_this._ShowTimeStamps = _this._Settings.hasOwnProperty('showtimestamps') ? _this._Settings.showtimestamps == true : true;
|
|
927
|
+
_this._FormattedTimeStamps = _this._Settings.hasOwnProperty('formattedtimestamps') ? _this._Settings.formattedtimestamps == true : true;
|
|
928
|
+
_this._ContextMessage = _this._Settings.hasOwnProperty('Context') ? "(".concat(_this._Settings.Context, ")") : pFableLog._Settings.hasOwnProperty('Product') ? "(".concat(pFableLog._Settings.Product, ")") : 'Unnamed_Log_Context';
|
|
929
|
+
|
|
930
|
+
// Allow the user to decide what gets output to the console
|
|
931
|
+
_this._OutputLogLinesToConsole = _this._Settings.hasOwnProperty('outputloglinestoconsole') ? _this._Settings.outputloglinestoconsole : true;
|
|
932
|
+
_this._OutputObjectsToConsole = _this._Settings.hasOwnProperty('outputobjectstoconsole') ? _this._Settings.outputobjectstoconsole : true;
|
|
933
|
+
|
|
934
|
+
// Precompute the prefix for each level
|
|
935
|
+
_this.prefixCache = {};
|
|
936
|
+
for (var i = 0; i <= _this.levels.length; i++) {
|
|
937
|
+
_this.prefixCache[_this.levels[i]] = "[".concat(_this.levels[i], "] ").concat(_this._ContextMessage, ": ");
|
|
938
|
+
if (_this._ShowTimeStamps) {
|
|
939
|
+
// If there is a timestamp we need a to prepend space before the prefixcache string, since the timestamp comes first
|
|
940
|
+
_this.prefixCache[_this.levels[i]] = ' ' + _this.prefixCache[_this.levels[i]];
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return _this;
|
|
944
|
+
}
|
|
945
|
+
_createClass(ConsoleLogger, [{
|
|
946
|
+
key: "write",
|
|
947
|
+
value: function write(pLevel, pLogText, pObject) {
|
|
948
|
+
var tmpTimeStamp = '';
|
|
949
|
+
if (this._ShowTimeStamps && this._FormattedTimeStamps) {
|
|
950
|
+
tmpTimeStamp = new Date().toISOString();
|
|
951
|
+
} else if (this._ShowTimeStamps) {
|
|
952
|
+
tmpTimeStamp = +new Date();
|
|
953
|
+
}
|
|
954
|
+
var tmpLogLine = "".concat(tmpTimeStamp).concat(this.prefixCache[pLevel]).concat(pLogText);
|
|
955
|
+
if (this._OutputLogLinesToConsole) {
|
|
956
|
+
console.log(tmpLogLine);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// Write out the object on a separate line if it is passed in
|
|
960
|
+
if (this._OutputObjectsToConsole && typeof pObject !== 'undefined') {
|
|
961
|
+
console.log(JSON.stringify(pObject, null, 2));
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// Provide an easy way to be overridden and be consistent
|
|
965
|
+
return tmpLogLine;
|
|
966
|
+
}
|
|
967
|
+
}]);
|
|
968
|
+
return ConsoleLogger;
|
|
969
|
+
}(libBaseLogger);
|
|
970
|
+
module.exports = ConsoleLogger;
|
|
971
|
+
}, {
|
|
972
|
+
"./Fable-Log-BaseLogger.js": 18
|
|
973
|
+
}],
|
|
974
|
+
22: [function (require, module, exports) {
|
|
975
|
+
var libConsoleLog = require('./Fable-Log-Logger-Console.js');
|
|
976
|
+
var libFS = require('fs');
|
|
977
|
+
var libPath = require('path');
|
|
978
|
+
var SimpleFlatFileLogger = /*#__PURE__*/function (_libConsoleLog) {
|
|
979
|
+
_inherits(SimpleFlatFileLogger, _libConsoleLog);
|
|
980
|
+
var _super2 = _createSuper(SimpleFlatFileLogger);
|
|
981
|
+
function SimpleFlatFileLogger(pLogStreamSettings, pFableLog) {
|
|
982
|
+
var _this2;
|
|
983
|
+
_classCallCheck(this, SimpleFlatFileLogger);
|
|
984
|
+
_this2 = _super2.call(this, pLogStreamSettings, pFableLog);
|
|
985
|
+
|
|
986
|
+
// If a path isn't provided for the logfile, it tries to use the ProductName or Context
|
|
987
|
+
_this2.logFileRawPath = _this2._Settings.hasOwnProperty('path') ? _this2._Settings.path : "./".concat(_this2._ContextMessage, ".log");
|
|
988
|
+
_this2.logFilePath = libPath.normalize(_this2.logFileRawPath);
|
|
989
|
+
_this2.logFileStreamOptions = _this2._Settings.hasOwnProperty('fileStreamoptions') ? _this2._Settings.fileStreamOptions : {
|
|
990
|
+
"flags": "a",
|
|
991
|
+
"encoding": "utf8"
|
|
992
|
+
};
|
|
993
|
+
_this2.fileWriter = libFS.createWriteStream(_this2.logFilePath, _this2.logFileStreamOptions);
|
|
994
|
+
_this2.activelyWriting = false;
|
|
995
|
+
_this2.logLineStrings = [];
|
|
996
|
+
_this2.logObjectStrings = [];
|
|
997
|
+
_this2.defaultWriteCompleteCallback = function () {};
|
|
998
|
+
_this2.defaultBufferFlushCallback = function () {};
|
|
999
|
+
return _this2;
|
|
1000
|
+
}
|
|
1001
|
+
_createClass(SimpleFlatFileLogger, [{
|
|
1002
|
+
key: "closeWriter",
|
|
1003
|
+
value: function closeWriter(fCloseComplete) {
|
|
1004
|
+
var tmpCloseComplete = typeof fCloseComplete == 'function' ? fCloseComplete : function () {};
|
|
1005
|
+
if (this.fileWriter) {
|
|
1006
|
+
this.fileWriter.end('\n');
|
|
1007
|
+
return this.fileWriter.once('finish', tmpCloseComplete.bind(this));
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}, {
|
|
1011
|
+
key: "completeBufferFlushToLogFile",
|
|
1012
|
+
value: function completeBufferFlushToLogFile(fFlushComplete) {
|
|
1013
|
+
this.activelyWriting = false;
|
|
1014
|
+
var tmpFlushComplete = typeof fFlushComplete == 'function' ? fFlushComplete : this.defaultBufferFlushCallback;
|
|
1015
|
+
if (this.logLineStrings.length > 0) {
|
|
1016
|
+
this.flushBufferToLogFile(tmpFlushComplete);
|
|
1017
|
+
} else {
|
|
1018
|
+
return tmpFlushComplete();
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}, {
|
|
1022
|
+
key: "flushBufferToLogFile",
|
|
1023
|
+
value: function flushBufferToLogFile(fFlushComplete) {
|
|
1024
|
+
if (!this.activelyWriting) {
|
|
1025
|
+
// Only want to be writing one thing at a time....
|
|
1026
|
+
this.activelyWriting = true;
|
|
1027
|
+
var tmpFlushComplete = typeof fFlushComplete == 'function' ? fFlushComplete : this.defaultBufferFlushCallback;
|
|
1028
|
+
|
|
1029
|
+
// Get the current buffer arrays. These should always have matching number of elements.
|
|
1030
|
+
var tmpLineStrings = this.logLineStrings;
|
|
1031
|
+
var tmpObjectStrings = this.logObjectStrings;
|
|
1032
|
+
|
|
1033
|
+
// Reset these to be filled while we process this queue...
|
|
1034
|
+
this.logLineStrings = [];
|
|
1035
|
+
this.logObjectStrings = [];
|
|
1036
|
+
|
|
1037
|
+
// This is where we will put each line before writing it to the file...
|
|
1038
|
+
var tmpConstructedBufferOutputString = '';
|
|
1039
|
+
for (var i = 0; i < tmpLineStrings.length; i++) {
|
|
1040
|
+
// TODO: Windows Newline? ....... yo no se!
|
|
1041
|
+
tmpConstructedBufferOutputString += "".concat(tmpLineStrings[i], "\n");
|
|
1042
|
+
if (tmpObjectStrings[i] !== false) {
|
|
1043
|
+
tmpConstructedBufferOutputString += "".concat(tmpObjectStrings[i], "\n");
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (!this.fileWriter.write(tmpConstructedBufferOutputString, 'utf8')) {
|
|
1047
|
+
// If the streamwriter returns false, we need to wait for it to drain.
|
|
1048
|
+
this.fileWriter.once('drain', this.completeBufferFlushToLogFile.bind(this, tmpFlushComplete));
|
|
1049
|
+
} else {
|
|
1050
|
+
return this.completeBufferFlushToLogFile(tmpFlushComplete);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}, {
|
|
1055
|
+
key: "write",
|
|
1056
|
+
value: function write(pLevel, pLogText, pObject) {
|
|
1057
|
+
var tmpLogLine = _get(_getPrototypeOf(SimpleFlatFileLogger.prototype), "write", this).call(this, pLevel, pLogText, pObject);
|
|
1058
|
+
|
|
1059
|
+
// Use a very simple array as the write buffer
|
|
1060
|
+
this.logLineStrings.push(tmpLogLine);
|
|
1061
|
+
|
|
1062
|
+
// Write out the object on a separate line if it is passed in
|
|
1063
|
+
if (typeof pObject !== 'undefined') {
|
|
1064
|
+
this.logObjectStrings.push(JSON.stringify(pObject, null, 4));
|
|
1065
|
+
} else {
|
|
1066
|
+
this.logObjectStrings.push(false);
|
|
1067
|
+
}
|
|
1068
|
+
this.flushBufferToLogFile();
|
|
1069
|
+
}
|
|
1070
|
+
}]);
|
|
1071
|
+
return SimpleFlatFileLogger;
|
|
1072
|
+
}(libConsoleLog);
|
|
1073
|
+
module.exports = SimpleFlatFileLogger;
|
|
1074
|
+
}, {
|
|
1075
|
+
"./Fable-Log-Logger-Console.js": 21,
|
|
1076
|
+
"fs": 16,
|
|
1077
|
+
"path": 29
|
|
1078
|
+
}],
|
|
1079
|
+
23: [function (require, module, exports) {
|
|
1080
|
+
/**
|
|
1081
|
+
* Fable Logging Add-on
|
|
1082
|
+
*
|
|
1083
|
+
* @license MIT
|
|
1084
|
+
*
|
|
1085
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
1086
|
+
* @module Fable Logger
|
|
1087
|
+
*/
|
|
1088
|
+
/**
|
|
1089
|
+
* Fable Solution Log Wrapper Main Class
|
|
1090
|
+
*
|
|
1091
|
+
* @class FableLog
|
|
1092
|
+
* @constructor
|
|
1093
|
+
*/
|
|
1094
|
+
var FableLog = /*#__PURE__*/function () {
|
|
1095
|
+
function FableLog(pFableSettings, pFable) {
|
|
1096
|
+
_classCallCheck(this, FableLog);
|
|
1097
|
+
var tmpSettings = _typeof(pFableSettings) === 'object' ? pFableSettings : {};
|
|
1098
|
+
this._Settings = tmpSettings;
|
|
1099
|
+
this._Providers = require('./Fable-Log-DefaultProviders-Node.js');
|
|
1100
|
+
this._StreamDefinitions = tmpSettings.hasOwnProperty('LogStreams') ? tmpSettings.LogStreams : require('./Fable-Log-DefaultStreams.json');
|
|
1101
|
+
this.logStreams = [];
|
|
1102
|
+
|
|
1103
|
+
// This object gets decorated for one-time instantiated providers that
|
|
1104
|
+
// have multiple outputs, such as bunyan.
|
|
1105
|
+
this.logProviders = {};
|
|
1106
|
+
|
|
1107
|
+
// A hash list of the GUIDs for each log stream, so they can't be added to the set more than one time
|
|
1108
|
+
this.activeLogStreams = {};
|
|
1109
|
+
this.logStreamsTrace = [];
|
|
1110
|
+
this.logStreamsDebug = [];
|
|
1111
|
+
this.logStreamsInfo = [];
|
|
1112
|
+
this.logStreamsWarn = [];
|
|
1113
|
+
this.logStreamsError = [];
|
|
1114
|
+
this.logStreamsFatal = [];
|
|
1115
|
+
this.datumDecorator = function (pDatum) {
|
|
1116
|
+
return pDatum;
|
|
1117
|
+
};
|
|
1118
|
+
this.uuid = typeof tmpSettings.Product === 'string' ? tmpSettings.Product : 'Default';
|
|
1119
|
+
}
|
|
1120
|
+
_createClass(FableLog, [{
|
|
1121
|
+
key: "addLogger",
|
|
1122
|
+
value: function addLogger(pLogger, pLevel) {
|
|
1123
|
+
// Bail out if we've already created one.
|
|
1124
|
+
if (this.activeLogStreams.hasOwnProperty(pLogger.loggerUUID)) {
|
|
1125
|
+
return false;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// Add it to the streams and to the mutex
|
|
1129
|
+
this.logStreams.push(pLogger);
|
|
1130
|
+
this.activeLogStreams[pLogger.loggerUUID] = true;
|
|
1131
|
+
|
|
1132
|
+
// Make sure a kosher level was passed in
|
|
1133
|
+
switch (pLevel) {
|
|
1134
|
+
case 'trace':
|
|
1135
|
+
this.logStreamsTrace.push(pLogger);
|
|
1136
|
+
case 'debug':
|
|
1137
|
+
this.logStreamsDebug.push(pLogger);
|
|
1138
|
+
case 'info':
|
|
1139
|
+
this.logStreamsInfo.push(pLogger);
|
|
1140
|
+
case 'warn':
|
|
1141
|
+
this.logStreamsWarn.push(pLogger);
|
|
1142
|
+
case 'error':
|
|
1143
|
+
this.logStreamsError.push(pLogger);
|
|
1144
|
+
case 'fatal':
|
|
1145
|
+
this.logStreamsFatal.push(pLogger);
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1150
|
+
}, {
|
|
1151
|
+
key: "setDatumDecorator",
|
|
1152
|
+
value: function setDatumDecorator(fDatumDecorator) {
|
|
1153
|
+
if (typeof fDatumDecorator === 'function') {
|
|
1154
|
+
this.datumDecorator = fDatumDecorator;
|
|
1155
|
+
} else {
|
|
1156
|
+
this.datumDecorator = function (pDatum) {
|
|
1157
|
+
return pDatum;
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
}, {
|
|
1162
|
+
key: "trace",
|
|
1163
|
+
value: function trace(pMessage, pDatum) {
|
|
1164
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1165
|
+
for (var i = 0; i < this.logStreamsTrace.length; i++) {
|
|
1166
|
+
this.logStreamsTrace[i].trace(pMessage, tmpDecoratedDatum);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}, {
|
|
1170
|
+
key: "debug",
|
|
1171
|
+
value: function debug(pMessage, pDatum) {
|
|
1172
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1173
|
+
for (var i = 0; i < this.logStreamsDebug.length; i++) {
|
|
1174
|
+
this.logStreamsDebug[i].debug(pMessage, tmpDecoratedDatum);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}, {
|
|
1178
|
+
key: "info",
|
|
1179
|
+
value: function info(pMessage, pDatum) {
|
|
1180
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1181
|
+
for (var i = 0; i < this.logStreamsInfo.length; i++) {
|
|
1182
|
+
this.logStreamsInfo[i].info(pMessage, tmpDecoratedDatum);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}, {
|
|
1186
|
+
key: "warn",
|
|
1187
|
+
value: function warn(pMessage, pDatum) {
|
|
1188
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1189
|
+
for (var i = 0; i < this.logStreamsWarn.length; i++) {
|
|
1190
|
+
this.logStreamsWarn[i].warn(pMessage, tmpDecoratedDatum);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}, {
|
|
1194
|
+
key: "error",
|
|
1195
|
+
value: function error(pMessage, pDatum) {
|
|
1196
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1197
|
+
for (var i = 0; i < this.logStreamsError.length; i++) {
|
|
1198
|
+
this.logStreamsError[i].error(pMessage, tmpDecoratedDatum);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
}, {
|
|
1202
|
+
key: "fatal",
|
|
1203
|
+
value: function fatal(pMessage, pDatum) {
|
|
1204
|
+
var tmpDecoratedDatum = this.datumDecorator(pDatum);
|
|
1205
|
+
for (var i = 0; i < this.logStreamsFatal.length; i++) {
|
|
1206
|
+
this.logStreamsFatal[i].fatal(pMessage, tmpDecoratedDatum);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}, {
|
|
1210
|
+
key: "initialize",
|
|
1211
|
+
value: function initialize() {
|
|
1212
|
+
// "initialize" each logger as defined in the logging parameters
|
|
1213
|
+
for (var i = 0; i < this._StreamDefinitions.length; i++) {
|
|
1214
|
+
var tmpStreamDefinition = Object.assign({
|
|
1215
|
+
loggertype: 'default',
|
|
1216
|
+
streamtype: 'console',
|
|
1217
|
+
level: 'info'
|
|
1218
|
+
}, this._StreamDefinitions[i]);
|
|
1219
|
+
if (!this._Providers.hasOwnProperty(tmpStreamDefinition.loggertype)) {
|
|
1220
|
+
console.log("Error initializing log stream: bad loggertype in stream definition ".concat(JSON.stringify(tmpStreamDefinition)));
|
|
1221
|
+
} else {
|
|
1222
|
+
this.addLogger(new this._Providers[tmpStreamDefinition.loggertype](tmpStreamDefinition, this), tmpStreamDefinition.level);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// Now initialize each one.
|
|
1227
|
+
for (var _i = 0; _i < this.logStreams.length; _i++) {
|
|
1228
|
+
this.logStreams[_i].initialize();
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}, {
|
|
1232
|
+
key: "logTime",
|
|
1233
|
+
value: function logTime(pMessage, pDatum) {
|
|
1234
|
+
var tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time';
|
|
1235
|
+
var tmpTime = new Date();
|
|
1236
|
+
this.info("".concat(tmpMessage, " ").concat(tmpTime, " (epoch ").concat(+tmpTime, ")"), pDatum);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// Get a timestamp
|
|
1240
|
+
}, {
|
|
1241
|
+
key: "getTimeStamp",
|
|
1242
|
+
value: function getTimeStamp() {
|
|
1243
|
+
return +new Date();
|
|
1244
|
+
}
|
|
1245
|
+
}, {
|
|
1246
|
+
key: "getTimeDelta",
|
|
1247
|
+
value: function getTimeDelta(pTimeStamp) {
|
|
1248
|
+
var tmpEndTime = +new Date();
|
|
1249
|
+
return tmpEndTime - pTimeStamp;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// Log the delta between a timestamp, and now with a message
|
|
1253
|
+
}, {
|
|
1254
|
+
key: "logTimeDelta",
|
|
1255
|
+
value: function logTimeDelta(pTimeDelta, pMessage, pDatum) {
|
|
1256
|
+
var tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
1257
|
+
var tmpDatum = _typeof(pDatum) === 'object' ? pDatum : {};
|
|
1258
|
+
var tmpEndTime = +new Date();
|
|
1259
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms)"), pDatum);
|
|
1260
|
+
}
|
|
1261
|
+
}, {
|
|
1262
|
+
key: "logTimeDeltaHuman",
|
|
1263
|
+
value: function logTimeDeltaHuman(pTimeDelta, pMessage, pDatum) {
|
|
1264
|
+
var tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
1265
|
+
var tmpEndTime = +new Date();
|
|
1266
|
+
var tmpMs = parseInt(pTimeDelta % 1000);
|
|
1267
|
+
var tmpSeconds = parseInt(pTimeDelta / 1000 % 60);
|
|
1268
|
+
var tmpMinutes = parseInt(pTimeDelta / (1000 * 60) % 60);
|
|
1269
|
+
var tmpHours = parseInt(pTimeDelta / (1000 * 60 * 60));
|
|
1270
|
+
tmpMs = tmpMs < 10 ? "00" + tmpMs : tmpMs < 100 ? "0" + tmpMs : tmpMs;
|
|
1271
|
+
tmpSeconds = tmpSeconds < 10 ? "0" + tmpSeconds : tmpSeconds;
|
|
1272
|
+
tmpMinutes = tmpMinutes < 10 ? "0" + tmpMinutes : tmpMinutes;
|
|
1273
|
+
tmpHours = tmpHours < 10 ? "0" + tmpHours : tmpHours;
|
|
1274
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms) or (").concat(tmpHours, ":").concat(tmpMinutes, ":").concat(tmpSeconds, ".").concat(tmpMs, ")"), pDatum);
|
|
1275
|
+
}
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "logTimeDeltaRelative",
|
|
1278
|
+
value: function logTimeDeltaRelative(pStartTime, pMessage, pDatum) {
|
|
1279
|
+
this.logTimeDelta(this.getTimeDelta(pStartTime), pMessage, pDatum);
|
|
1280
|
+
}
|
|
1281
|
+
}, {
|
|
1282
|
+
key: "logTimeDeltaRelativeHuman",
|
|
1283
|
+
value: function logTimeDeltaRelativeHuman(pStartTime, pMessage, pDatum) {
|
|
1284
|
+
this.logTimeDeltaHuman(this.getTimeDelta(pStartTime), pMessage, pDatum);
|
|
1285
|
+
}
|
|
1286
|
+
}]);
|
|
1287
|
+
return FableLog;
|
|
1288
|
+
}(); // This is for backwards compatibility
|
|
1289
|
+
function autoConstruct(pSettings) {
|
|
1290
|
+
return new FableLog(pSettings);
|
|
1291
|
+
}
|
|
1292
|
+
module.exports = FableLog;
|
|
1293
|
+
module.exports["new"] = autoConstruct;
|
|
1294
|
+
module.exports.LogProviderBase = require('./Fable-Log-BaseLogger.js');
|
|
1295
|
+
module.exports.LogProviderConsole = require('./Fable-Log-Logger-Console.js');
|
|
1296
|
+
module.exports.LogProviderConsole = require('./Fable-Log-Logger-SimpleFlatFile.js');
|
|
1297
|
+
}, {
|
|
1298
|
+
"./Fable-Log-BaseLogger.js": 18,
|
|
1299
|
+
"./Fable-Log-DefaultProviders-Node.js": 19,
|
|
1300
|
+
"./Fable-Log-DefaultStreams.json": 20,
|
|
1301
|
+
"./Fable-Log-Logger-Console.js": 21,
|
|
1302
|
+
"./Fable-Log-Logger-SimpleFlatFile.js": 22
|
|
1303
|
+
}],
|
|
1304
|
+
24: [function (require, module, exports) {
|
|
1305
|
+
module.exports = {
|
|
1306
|
+
"Product": "ApplicationNameHere",
|
|
1307
|
+
"ProductVersion": "0.0.0",
|
|
1308
|
+
"ConfigFile": false,
|
|
1309
|
+
"LogStreams": [{
|
|
1310
|
+
"level": "trace"
|
|
1311
|
+
}]
|
|
1312
|
+
};
|
|
1313
|
+
}, {}],
|
|
1314
|
+
25: [function (require, module, exports) {
|
|
1315
|
+
(function (process) {
|
|
1316
|
+
(function () {
|
|
1317
|
+
/**
|
|
1318
|
+
* Fable Settings Template Processor
|
|
1319
|
+
*
|
|
1320
|
+
* This class allows environment variables to come in via templated expressions, and defaults to be set.
|
|
1321
|
+
*
|
|
1322
|
+
* @license MIT
|
|
1323
|
+
*
|
|
1324
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
1325
|
+
* @module Fable Settings
|
|
1326
|
+
*/
|
|
1327
|
+
var FableSettingsTemplateProcessor = /*#__PURE__*/function () {
|
|
1328
|
+
function FableSettingsTemplateProcessor(pDependencies) {
|
|
1329
|
+
_classCallCheck(this, FableSettingsTemplateProcessor);
|
|
1330
|
+
// Use a no-dependencies templating engine to parse out environment variables
|
|
1331
|
+
this.templateProcessor = new pDependencies.precedent();
|
|
1332
|
+
|
|
1333
|
+
// TODO: Make the environment variable wrap expression demarcation characters configurable?
|
|
1334
|
+
this.templateProcessor.addPattern('${', '}', function (pTemplateValue) {
|
|
1335
|
+
var tmpTemplateValue = pTemplateValue.trim();
|
|
1336
|
+
var tmpSeparatorIndex = tmpTemplateValue.indexOf('|');
|
|
1337
|
+
|
|
1338
|
+
// If there is no pipe, the default value will end up being whatever the variable name is.
|
|
1339
|
+
var tmpDefaultValue = tmpTemplateValue.substring(tmpSeparatorIndex + 1);
|
|
1340
|
+
var tmpEnvironmentVariableName = tmpSeparatorIndex > -1 ? tmpTemplateValue.substring(0, tmpSeparatorIndex) : tmpTemplateValue;
|
|
1341
|
+
if (process.env.hasOwnProperty(tmpEnvironmentVariableName)) {
|
|
1342
|
+
return process.env[tmpEnvironmentVariableName];
|
|
1343
|
+
} else {
|
|
1344
|
+
return tmpDefaultValue;
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
_createClass(FableSettingsTemplateProcessor, [{
|
|
1349
|
+
key: "parseSetting",
|
|
1350
|
+
value: function parseSetting(pString) {
|
|
1351
|
+
return this.templateProcessor.parseString(pString);
|
|
1352
|
+
}
|
|
1353
|
+
}]);
|
|
1354
|
+
return FableSettingsTemplateProcessor;
|
|
1355
|
+
}();
|
|
1356
|
+
module.exports = FableSettingsTemplateProcessor;
|
|
1357
|
+
}).call(this);
|
|
1358
|
+
}).call(this, require('_process'));
|
|
1359
|
+
}, {
|
|
1360
|
+
"_process": 33
|
|
1361
|
+
}],
|
|
1362
|
+
26: [function (require, module, exports) {
|
|
1363
|
+
/**
|
|
1364
|
+
* Fable Settings Add-on
|
|
1365
|
+
*
|
|
1366
|
+
* @license MIT
|
|
1367
|
+
*
|
|
1368
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
1369
|
+
* @module Fable Settings
|
|
1370
|
+
*/
|
|
1371
|
+
|
|
1372
|
+
var libPrecedent = require('precedent');
|
|
1373
|
+
var libFableSettingsTemplateProcessor = require('./Fable-Settings-TemplateProcessor.js');
|
|
1374
|
+
var FableSettings = /*#__PURE__*/function () {
|
|
1375
|
+
function FableSettings(pFableSettings) {
|
|
1376
|
+
_classCallCheck(this, FableSettings);
|
|
1377
|
+
// Expose the dependencies for downstream re-use
|
|
1378
|
+
this.dependencies = {
|
|
1379
|
+
precedent: libPrecedent
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// Initialize the settings value template processor
|
|
1383
|
+
this.settingsTemplateProcessor = new libFableSettingsTemplateProcessor(this.dependencies);
|
|
1384
|
+
|
|
1385
|
+
// set straight away so anything that uses it respects the initial setting
|
|
1386
|
+
this._configureEnvTemplating(pFableSettings);
|
|
1387
|
+
this["default"] = this.buildDefaultSettings();
|
|
1388
|
+
|
|
1389
|
+
// Construct a new settings object
|
|
1390
|
+
var tmpSettings = this.merge(pFableSettings, this.buildDefaultSettings());
|
|
1391
|
+
|
|
1392
|
+
// The base settings object (what they were on initialization, before other actors have altered them)
|
|
1393
|
+
this.base = JSON.parse(JSON.stringify(tmpSettings));
|
|
1394
|
+
if (tmpSettings.DefaultConfigFile) {
|
|
1395
|
+
try {
|
|
1396
|
+
// If there is a DEFAULT configuration file, try to load and merge it.
|
|
1397
|
+
tmpSettings = this.merge(require(tmpSettings.DefaultConfigFile), tmpSettings);
|
|
1398
|
+
} catch (pException) {
|
|
1399
|
+
// Why this? Often for an app we want settings to work out of the box, but
|
|
1400
|
+
// would potentially want to have a config file for complex settings.
|
|
1401
|
+
console.log('Fable-Settings Warning: Default configuration file specified but there was a problem loading it. Falling back to base.');
|
|
1402
|
+
console.log(' Loading Exception: ' + pException);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
if (tmpSettings.ConfigFile) {
|
|
1406
|
+
try {
|
|
1407
|
+
// If there is a configuration file, try to load and merge it.
|
|
1408
|
+
tmpSettings = this.merge(require(tmpSettings.ConfigFile), tmpSettings);
|
|
1409
|
+
} catch (pException) {
|
|
1410
|
+
// Why this? Often for an app we want settings to work out of the box, but
|
|
1411
|
+
// would potentially want to have a config file for complex settings.
|
|
1412
|
+
console.log('Fable-Settings Warning: Configuration file specified but there was a problem loading it. Falling back to base.');
|
|
1413
|
+
console.log(' Loading Exception: ' + pException);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
this.settings = tmpSettings;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// Build a default settings object. Use the JSON jimmy to ensure it is always a new object.
|
|
1420
|
+
_createClass(FableSettings, [{
|
|
1421
|
+
key: "buildDefaultSettings",
|
|
1422
|
+
value: function buildDefaultSettings() {
|
|
1423
|
+
return JSON.parse(JSON.stringify(require('./Fable-Settings-Default')));
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// Update the configuration for environment variable templating based on the current settings object
|
|
1427
|
+
}, {
|
|
1428
|
+
key: "_configureEnvTemplating",
|
|
1429
|
+
value: function _configureEnvTemplating(pSettings) {
|
|
1430
|
+
// default environment variable templating to on
|
|
1431
|
+
this._PerformEnvTemplating = !pSettings || pSettings.NoEnvReplacement !== true;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
// Resolve (recursive) any environment variables found in settings object.
|
|
1435
|
+
}, {
|
|
1436
|
+
key: "_resolveEnv",
|
|
1437
|
+
value: function _resolveEnv(pSettings) {
|
|
1438
|
+
for (var tmpKey in pSettings) {
|
|
1439
|
+
if (_typeof(pSettings[tmpKey]) === 'object') {
|
|
1440
|
+
this._resolveEnv(pSettings[tmpKey]);
|
|
1441
|
+
} else if (typeof pSettings[tmpKey] === 'string') {
|
|
1442
|
+
pSettings[tmpKey] = this.settingsTemplateProcessor.parseSetting(pSettings[tmpKey]);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Check to see if a value is an object (but not an array).
|
|
1449
|
+
*/
|
|
1450
|
+
}, {
|
|
1451
|
+
key: "_isObject",
|
|
1452
|
+
value: function _isObject(value) {
|
|
1453
|
+
return _typeof(value) === 'object' && !Array.isArray(value);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Merge two plain objects. Keys that are objects in both will be merged property-wise.
|
|
1458
|
+
*/
|
|
1459
|
+
}, {
|
|
1460
|
+
key: "_deepMergeObjects",
|
|
1461
|
+
value: function _deepMergeObjects(toObject, fromObject) {
|
|
1462
|
+
var _this3 = this;
|
|
1463
|
+
if (!fromObject || !this._isObject(fromObject)) {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
Object.keys(fromObject).forEach(function (key) {
|
|
1467
|
+
var fromValue = fromObject[key];
|
|
1468
|
+
if (_this3._isObject(fromValue)) {
|
|
1469
|
+
var toValue = toObject[key];
|
|
1470
|
+
if (toValue && _this3._isObject(toValue)) {
|
|
1471
|
+
// both are objects, so do a recursive merge
|
|
1472
|
+
_this3._deepMergeObjects(toValue, fromValue);
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
toObject[key] = fromValue;
|
|
1477
|
+
});
|
|
1478
|
+
return toObject;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// Merge some new object into the existing settings.
|
|
1482
|
+
}, {
|
|
1483
|
+
key: "merge",
|
|
1484
|
+
value: function merge(pSettingsFrom, pSettingsTo) {
|
|
1485
|
+
// If an invalid settings from object is passed in (e.g. object constructor without passing in anything) this should still work
|
|
1486
|
+
var tmpSettingsFrom = _typeof(pSettingsFrom) === 'object' ? pSettingsFrom : {};
|
|
1487
|
+
// Default to the settings object if none is passed in for the merge.
|
|
1488
|
+
var tmpSettingsTo = _typeof(pSettingsTo) === 'object' ? pSettingsTo : this.settings;
|
|
1489
|
+
|
|
1490
|
+
// do not mutate the From object property values
|
|
1491
|
+
var tmpSettingsFromCopy = JSON.parse(JSON.stringify(tmpSettingsFrom));
|
|
1492
|
+
tmpSettingsTo = this._deepMergeObjects(tmpSettingsTo, tmpSettingsFromCopy);
|
|
1493
|
+
if (this._PerformEnvTemplating) {
|
|
1494
|
+
this._resolveEnv(tmpSettingsTo);
|
|
1495
|
+
}
|
|
1496
|
+
// Update env tempating config, since we just updated the config object, and it may have changed
|
|
1497
|
+
this._configureEnvTemplating(tmpSettingsTo);
|
|
1498
|
+
return tmpSettingsTo;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// Fill in settings gaps without overwriting settings that are already there
|
|
1502
|
+
}, {
|
|
1503
|
+
key: "fill",
|
|
1504
|
+
value: function fill(pSettingsFrom) {
|
|
1505
|
+
// If an invalid settings from object is passed in (e.g. object constructor without passing in anything) this should still work
|
|
1506
|
+
var tmpSettingsFrom = _typeof(pSettingsFrom) === 'object' ? pSettingsFrom : {};
|
|
1507
|
+
|
|
1508
|
+
// do not mutate the From object property values
|
|
1509
|
+
var tmpSettingsFromCopy = JSON.parse(JSON.stringify(tmpSettingsFrom));
|
|
1510
|
+
this.settings = this._deepMergeObjects(tmpSettingsFromCopy, this.settings);
|
|
1511
|
+
return this.settings;
|
|
1512
|
+
}
|
|
1513
|
+
}]);
|
|
1514
|
+
return FableSettings;
|
|
1515
|
+
}();
|
|
1516
|
+
;
|
|
1517
|
+
|
|
1518
|
+
// This is for backwards compatibility
|
|
1519
|
+
function autoConstruct(pSettings) {
|
|
1520
|
+
return new FableSettings(pSettings);
|
|
1521
|
+
}
|
|
1522
|
+
module.exports = FableSettings;
|
|
1523
|
+
module.exports["new"] = autoConstruct;
|
|
1524
|
+
module.exports.precedent = libPrecedent;
|
|
1525
|
+
}, {
|
|
1526
|
+
"./Fable-Settings-Default": 24,
|
|
1527
|
+
"./Fable-Settings-TemplateProcessor.js": 25,
|
|
1528
|
+
"precedent": 30
|
|
1529
|
+
}],
|
|
1530
|
+
27: [function (require, module, exports) {
|
|
1531
|
+
/**
|
|
1532
|
+
* Random Byte Generator - Browser version
|
|
1533
|
+
*
|
|
1534
|
+
* @license MIT
|
|
1535
|
+
*
|
|
1536
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
1537
|
+
*/
|
|
1538
|
+
// Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
1539
|
+
// Unique ID creation requires a high quality random # generator. In the
|
|
1540
|
+
// browser this is a little complicated due to unknown quality of Math.random()
|
|
1541
|
+
// and inconsistent support for the `crypto` API. We do the best we can via
|
|
1542
|
+
// feature-detection
|
|
1543
|
+
var RandomBytes = /*#__PURE__*/function () {
|
|
1544
|
+
function RandomBytes() {
|
|
1545
|
+
_classCallCheck(this, RandomBytes);
|
|
1546
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto
|
|
1547
|
+
// implementation. Also, find the complete implementation of crypto on IE11.
|
|
1548
|
+
this.getRandomValues = typeof crypto != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
// WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
|
|
1552
|
+
_createClass(RandomBytes, [{
|
|
1553
|
+
key: "generateWhatWGBytes",
|
|
1554
|
+
value: function generateWhatWGBytes() {
|
|
1555
|
+
var tmpBuffer = new Uint8Array(16); // eslint-disable-line no-undef
|
|
1556
|
+
|
|
1557
|
+
this.getRandomValues(tmpBuffer);
|
|
1558
|
+
return tmpBuffer;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
// Math.random()-based (RNG)
|
|
1562
|
+
}, {
|
|
1563
|
+
key: "generateRandomBytes",
|
|
1564
|
+
value: function generateRandomBytes() {
|
|
1565
|
+
// If all else fails, use Math.random(). It's fast, but is of unspecified
|
|
1566
|
+
// quality.
|
|
1567
|
+
var tmpBuffer = new Uint8Array(16); // eslint-disable-line no-undef
|
|
1568
|
+
|
|
1569
|
+
for (var i = 0, tmpValue; i < 16; i++) {
|
|
1570
|
+
if ((i & 0x03) === 0) {
|
|
1571
|
+
tmpValue = Math.random() * 0x100000000;
|
|
1572
|
+
}
|
|
1573
|
+
tmpBuffer[i] = tmpValue >>> ((i & 0x03) << 3) & 0xff;
|
|
1574
|
+
}
|
|
1575
|
+
return tmpBuffer;
|
|
1576
|
+
}
|
|
1577
|
+
}, {
|
|
1578
|
+
key: "generate",
|
|
1579
|
+
value: function generate() {
|
|
1580
|
+
if (this.getRandomValues) {
|
|
1581
|
+
return this.generateWhatWGBytes();
|
|
1582
|
+
} else {
|
|
1583
|
+
return this.generateRandomBytes();
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}]);
|
|
1587
|
+
return RandomBytes;
|
|
1588
|
+
}();
|
|
1589
|
+
module.exports = RandomBytes;
|
|
1590
|
+
}, {}],
|
|
1591
|
+
28: [function (require, module, exports) {
|
|
1592
|
+
/**
|
|
1593
|
+
* Fable UUID Generator
|
|
1594
|
+
*
|
|
1595
|
+
* @license MIT
|
|
1596
|
+
*
|
|
1597
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
1598
|
+
* @module Fable UUID
|
|
1599
|
+
*/
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* Fable Solution UUID Generation Main Class
|
|
1603
|
+
*
|
|
1604
|
+
* @class FableUUID
|
|
1605
|
+
* @constructor
|
|
1606
|
+
*/
|
|
1607
|
+
|
|
1608
|
+
var libRandomByteGenerator = require('./Fable-UUID-Random.js');
|
|
1609
|
+
var FableUUID = /*#__PURE__*/function () {
|
|
1610
|
+
function FableUUID(pSettings) {
|
|
1611
|
+
_classCallCheck(this, FableUUID);
|
|
1612
|
+
// Determine if the module is in "Random UUID Mode" which means just use the random character function rather than the v4 random UUID spec.
|
|
1613
|
+
// Note this allows UUIDs of various lengths (including very short ones) although guaranteed uniqueness goes downhill fast.
|
|
1614
|
+
this._UUIDModeRandom = _typeof(pSettings) === 'object' && pSettings.hasOwnProperty('UUIDModeRandom') ? pSettings.UUIDModeRandom == true : false;
|
|
1615
|
+
// These two properties are only useful if we are in Random mode. Otherwise it generates a v4 spec
|
|
1616
|
+
// Length for "Random UUID Mode" is set -- if not set it to 8
|
|
1617
|
+
this._UUIDLength = _typeof(pSettings) === 'object' && pSettings.hasOwnProperty('UUIDLength') ? pSettings.UUIDLength + 0 : 8;
|
|
1618
|
+
// Dictionary for "Random UUID Mode"
|
|
1619
|
+
this._UUIDRandomDictionary = _typeof(pSettings) === 'object' && pSettings.hasOwnProperty('UUIDDictionary') ? pSettings.UUIDDictionary + 0 : '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
1620
|
+
this.randomByteGenerator = new libRandomByteGenerator();
|
|
1621
|
+
|
|
1622
|
+
// Lookup table for hex codes
|
|
1623
|
+
this._HexLookup = [];
|
|
1624
|
+
for (var i = 0; i < 256; ++i) {
|
|
1625
|
+
this._HexLookup[i] = (i + 0x100).toString(16).substr(1);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
1630
|
+
_createClass(FableUUID, [{
|
|
1631
|
+
key: "bytesToUUID",
|
|
1632
|
+
value: function bytesToUUID(pBuffer) {
|
|
1633
|
+
var i = 0;
|
|
1634
|
+
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
|
1635
|
+
return [this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], '-', this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], '-', this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], '-', this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], '-', this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]], this._HexLookup[pBuffer[i++]]].join('');
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
1639
|
+
}, {
|
|
1640
|
+
key: "generateUUIDv4",
|
|
1641
|
+
value: function generateUUIDv4() {
|
|
1642
|
+
var tmpBuffer = new Array(16);
|
|
1643
|
+
var tmpRandomBytes = this.randomByteGenerator.generate();
|
|
1644
|
+
|
|
1645
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
1646
|
+
tmpRandomBytes[6] = tmpRandomBytes[6] & 0x0f | 0x40;
|
|
1647
|
+
tmpRandomBytes[8] = tmpRandomBytes[8] & 0x3f | 0x80;
|
|
1648
|
+
return this.bytesToUUID(tmpRandomBytes);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// Simple random UUID generation
|
|
1652
|
+
}, {
|
|
1653
|
+
key: "generateRandom",
|
|
1654
|
+
value: function generateRandom() {
|
|
1655
|
+
var tmpUUID = '';
|
|
1656
|
+
for (var i = 0; i < this._UUIDLength; i++) {
|
|
1657
|
+
tmpUUID += this._UUIDRandomDictionary.charAt(Math.floor(Math.random() * (this._UUIDRandomDictionary.length - 1)));
|
|
1658
|
+
}
|
|
1659
|
+
return tmpUUID;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
// Adapted from node-uuid (https://github.com/kelektiv/node-uuid)
|
|
1663
|
+
}, {
|
|
1664
|
+
key: "getUUID",
|
|
1665
|
+
value: function getUUID() {
|
|
1666
|
+
if (this._UUIDModeRandom) {
|
|
1667
|
+
return this.generateRandom();
|
|
1668
|
+
} else {
|
|
1669
|
+
return this.generateUUIDv4();
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}]);
|
|
1673
|
+
return FableUUID;
|
|
1674
|
+
}(); // This is for backwards compatibility
|
|
1675
|
+
function autoConstruct(pSettings) {
|
|
1676
|
+
return new FableUUID(pSettings);
|
|
1677
|
+
}
|
|
1678
|
+
module.exports = FableUUID;
|
|
1679
|
+
module.exports["new"] = autoConstruct;
|
|
1680
|
+
}, {
|
|
1681
|
+
"./Fable-UUID-Random.js": 27
|
|
1682
|
+
}],
|
|
1683
|
+
29: [function (require, module, exports) {
|
|
1684
|
+
(function (process) {
|
|
1685
|
+
(function () {
|
|
1686
|
+
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
|
1687
|
+
// transplited with Babel
|
|
1688
|
+
|
|
1689
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
1690
|
+
//
|
|
1691
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
1692
|
+
// copy of this software and associated documentation files (the
|
|
1693
|
+
// "Software"), to deal in the Software without restriction, including
|
|
1694
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
1695
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
1696
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
1697
|
+
// following conditions:
|
|
1698
|
+
//
|
|
1699
|
+
// The above copyright notice and this permission notice shall be included
|
|
1700
|
+
// in all copies or substantial portions of the Software.
|
|
1701
|
+
//
|
|
1702
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
1703
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
1704
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
1705
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
1706
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
1707
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
1708
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1709
|
+
|
|
1710
|
+
'use strict';
|
|
1711
|
+
|
|
1712
|
+
function assertPath(path) {
|
|
1713
|
+
if (typeof path !== 'string') {
|
|
1714
|
+
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
// Resolves . and .. elements in a path with directory names
|
|
1719
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1720
|
+
var res = '';
|
|
1721
|
+
var lastSegmentLength = 0;
|
|
1722
|
+
var lastSlash = -1;
|
|
1723
|
+
var dots = 0;
|
|
1724
|
+
var code;
|
|
1725
|
+
for (var i = 0; i <= path.length; ++i) {
|
|
1726
|
+
if (i < path.length) code = path.charCodeAt(i);else if (code === 47 /*/*/) break;else code = 47 /*/*/;
|
|
1727
|
+
if (code === 47 /*/*/) {
|
|
1728
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
1729
|
+
// NOOP
|
|
1730
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1731
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
|
|
1732
|
+
if (res.length > 2) {
|
|
1733
|
+
var lastSlashIndex = res.lastIndexOf('/');
|
|
1734
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
1735
|
+
if (lastSlashIndex === -1) {
|
|
1736
|
+
res = '';
|
|
1737
|
+
lastSegmentLength = 0;
|
|
1738
|
+
} else {
|
|
1739
|
+
res = res.slice(0, lastSlashIndex);
|
|
1740
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
1741
|
+
}
|
|
1742
|
+
lastSlash = i;
|
|
1743
|
+
dots = 0;
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1746
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1747
|
+
res = '';
|
|
1748
|
+
lastSegmentLength = 0;
|
|
1749
|
+
lastSlash = i;
|
|
1750
|
+
dots = 0;
|
|
1751
|
+
continue;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (allowAboveRoot) {
|
|
1755
|
+
if (res.length > 0) res += '/..';else res = '..';
|
|
1756
|
+
lastSegmentLength = 2;
|
|
1757
|
+
}
|
|
1758
|
+
} else {
|
|
1759
|
+
if (res.length > 0) res += '/' + path.slice(lastSlash + 1, i);else res = path.slice(lastSlash + 1, i);
|
|
1760
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
1761
|
+
}
|
|
1762
|
+
lastSlash = i;
|
|
1763
|
+
dots = 0;
|
|
1764
|
+
} else if (code === 46 /*.*/ && dots !== -1) {
|
|
1765
|
+
++dots;
|
|
1766
|
+
} else {
|
|
1767
|
+
dots = -1;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return res;
|
|
1771
|
+
}
|
|
1772
|
+
function _format(sep, pathObject) {
|
|
1773
|
+
var dir = pathObject.dir || pathObject.root;
|
|
1774
|
+
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
|
|
1775
|
+
if (!dir) {
|
|
1776
|
+
return base;
|
|
1777
|
+
}
|
|
1778
|
+
if (dir === pathObject.root) {
|
|
1779
|
+
return dir + base;
|
|
1780
|
+
}
|
|
1781
|
+
return dir + sep + base;
|
|
1782
|
+
}
|
|
1783
|
+
var posix = {
|
|
1784
|
+
// path.resolve([from ...], to)
|
|
1785
|
+
resolve: function resolve() {
|
|
1786
|
+
var resolvedPath = '';
|
|
1787
|
+
var resolvedAbsolute = false;
|
|
1788
|
+
var cwd;
|
|
1789
|
+
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
1790
|
+
var path;
|
|
1791
|
+
if (i >= 0) path = arguments[i];else {
|
|
1792
|
+
if (cwd === undefined) cwd = process.cwd();
|
|
1793
|
+
path = cwd;
|
|
1794
|
+
}
|
|
1795
|
+
assertPath(path);
|
|
1796
|
+
|
|
1797
|
+
// Skip empty entries
|
|
1798
|
+
if (path.length === 0) {
|
|
1799
|
+
continue;
|
|
1800
|
+
}
|
|
1801
|
+
resolvedPath = path + '/' + resolvedPath;
|
|
1802
|
+
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
1806
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
1807
|
+
|
|
1808
|
+
// Normalize the path
|
|
1809
|
+
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
1810
|
+
if (resolvedAbsolute) {
|
|
1811
|
+
if (resolvedPath.length > 0) return '/' + resolvedPath;else return '/';
|
|
1812
|
+
} else if (resolvedPath.length > 0) {
|
|
1813
|
+
return resolvedPath;
|
|
1814
|
+
} else {
|
|
1815
|
+
return '.';
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
normalize: function normalize(path) {
|
|
1819
|
+
assertPath(path);
|
|
1820
|
+
if (path.length === 0) return '.';
|
|
1821
|
+
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
1822
|
+
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
|
|
1823
|
+
|
|
1824
|
+
// Normalize the path
|
|
1825
|
+
path = normalizeStringPosix(path, !isAbsolute);
|
|
1826
|
+
if (path.length === 0 && !isAbsolute) path = '.';
|
|
1827
|
+
if (path.length > 0 && trailingSeparator) path += '/';
|
|
1828
|
+
if (isAbsolute) return '/' + path;
|
|
1829
|
+
return path;
|
|
1830
|
+
},
|
|
1831
|
+
isAbsolute: function isAbsolute(path) {
|
|
1832
|
+
assertPath(path);
|
|
1833
|
+
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
|
|
1834
|
+
},
|
|
1835
|
+
|
|
1836
|
+
join: function join() {
|
|
1837
|
+
if (arguments.length === 0) return '.';
|
|
1838
|
+
var joined;
|
|
1839
|
+
for (var i = 0; i < arguments.length; ++i) {
|
|
1840
|
+
var arg = arguments[i];
|
|
1841
|
+
assertPath(arg);
|
|
1842
|
+
if (arg.length > 0) {
|
|
1843
|
+
if (joined === undefined) joined = arg;else joined += '/' + arg;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (joined === undefined) return '.';
|
|
1847
|
+
return posix.normalize(joined);
|
|
1848
|
+
},
|
|
1849
|
+
relative: function relative(from, to) {
|
|
1850
|
+
assertPath(from);
|
|
1851
|
+
assertPath(to);
|
|
1852
|
+
if (from === to) return '';
|
|
1853
|
+
from = posix.resolve(from);
|
|
1854
|
+
to = posix.resolve(to);
|
|
1855
|
+
if (from === to) return '';
|
|
1856
|
+
|
|
1857
|
+
// Trim any leading backslashes
|
|
1858
|
+
var fromStart = 1;
|
|
1859
|
+
for (; fromStart < from.length; ++fromStart) {
|
|
1860
|
+
if (from.charCodeAt(fromStart) !== 47 /*/*/) break;
|
|
1861
|
+
}
|
|
1862
|
+
var fromEnd = from.length;
|
|
1863
|
+
var fromLen = fromEnd - fromStart;
|
|
1864
|
+
|
|
1865
|
+
// Trim any leading backslashes
|
|
1866
|
+
var toStart = 1;
|
|
1867
|
+
for (; toStart < to.length; ++toStart) {
|
|
1868
|
+
if (to.charCodeAt(toStart) !== 47 /*/*/) break;
|
|
1869
|
+
}
|
|
1870
|
+
var toEnd = to.length;
|
|
1871
|
+
var toLen = toEnd - toStart;
|
|
1872
|
+
|
|
1873
|
+
// Compare paths to find the longest common path from root
|
|
1874
|
+
var length = fromLen < toLen ? fromLen : toLen;
|
|
1875
|
+
var lastCommonSep = -1;
|
|
1876
|
+
var i = 0;
|
|
1877
|
+
for (; i <= length; ++i) {
|
|
1878
|
+
if (i === length) {
|
|
1879
|
+
if (toLen > length) {
|
|
1880
|
+
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
|
|
1881
|
+
// We get here if `from` is the exact base path for `to`.
|
|
1882
|
+
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
1883
|
+
return to.slice(toStart + i + 1);
|
|
1884
|
+
} else if (i === 0) {
|
|
1885
|
+
// We get here if `from` is the root
|
|
1886
|
+
// For example: from='/'; to='/foo'
|
|
1887
|
+
return to.slice(toStart + i);
|
|
1888
|
+
}
|
|
1889
|
+
} else if (fromLen > length) {
|
|
1890
|
+
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
|
|
1891
|
+
// We get here if `to` is the exact base path for `from`.
|
|
1892
|
+
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
1893
|
+
lastCommonSep = i;
|
|
1894
|
+
} else if (i === 0) {
|
|
1895
|
+
// We get here if `to` is the root.
|
|
1896
|
+
// For example: from='/foo'; to='/'
|
|
1897
|
+
lastCommonSep = 0;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
break;
|
|
1901
|
+
}
|
|
1902
|
+
var fromCode = from.charCodeAt(fromStart + i);
|
|
1903
|
+
var toCode = to.charCodeAt(toStart + i);
|
|
1904
|
+
if (fromCode !== toCode) break;else if (fromCode === 47 /*/*/) lastCommonSep = i;
|
|
1905
|
+
}
|
|
1906
|
+
var out = '';
|
|
1907
|
+
// Generate the relative path based on the path difference between `to`
|
|
1908
|
+
// and `from`
|
|
1909
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
1910
|
+
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
|
|
1911
|
+
if (out.length === 0) out += '..';else out += '/..';
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
1916
|
+
// the common path parts
|
|
1917
|
+
if (out.length > 0) return out + to.slice(toStart + lastCommonSep);else {
|
|
1918
|
+
toStart += lastCommonSep;
|
|
1919
|
+
if (to.charCodeAt(toStart) === 47 /*/*/) ++toStart;
|
|
1920
|
+
return to.slice(toStart);
|
|
1921
|
+
}
|
|
1922
|
+
},
|
|
1923
|
+
_makeLong: function _makeLong(path) {
|
|
1924
|
+
return path;
|
|
1925
|
+
},
|
|
1926
|
+
dirname: function dirname(path) {
|
|
1927
|
+
assertPath(path);
|
|
1928
|
+
if (path.length === 0) return '.';
|
|
1929
|
+
var code = path.charCodeAt(0);
|
|
1930
|
+
var hasRoot = code === 47 /*/*/;
|
|
1931
|
+
var end = -1;
|
|
1932
|
+
var matchedSlash = true;
|
|
1933
|
+
for (var i = path.length - 1; i >= 1; --i) {
|
|
1934
|
+
code = path.charCodeAt(i);
|
|
1935
|
+
if (code === 47 /*/*/) {
|
|
1936
|
+
if (!matchedSlash) {
|
|
1937
|
+
end = i;
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1940
|
+
} else {
|
|
1941
|
+
// We saw the first non-path separator
|
|
1942
|
+
matchedSlash = false;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
if (end === -1) return hasRoot ? '/' : '.';
|
|
1946
|
+
if (hasRoot && end === 1) return '//';
|
|
1947
|
+
return path.slice(0, end);
|
|
1948
|
+
},
|
|
1949
|
+
basename: function basename(path, ext) {
|
|
1950
|
+
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
|
|
1951
|
+
assertPath(path);
|
|
1952
|
+
var start = 0;
|
|
1953
|
+
var end = -1;
|
|
1954
|
+
var matchedSlash = true;
|
|
1955
|
+
var i;
|
|
1956
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
1957
|
+
if (ext.length === path.length && ext === path) return '';
|
|
1958
|
+
var extIdx = ext.length - 1;
|
|
1959
|
+
var firstNonSlashEnd = -1;
|
|
1960
|
+
for (i = path.length - 1; i >= 0; --i) {
|
|
1961
|
+
var code = path.charCodeAt(i);
|
|
1962
|
+
if (code === 47 /*/*/) {
|
|
1963
|
+
// If we reached a path separator that was not part of a set of path
|
|
1964
|
+
// separators at the end of the string, stop now
|
|
1965
|
+
if (!matchedSlash) {
|
|
1966
|
+
start = i + 1;
|
|
1967
|
+
break;
|
|
1968
|
+
}
|
|
1969
|
+
} else {
|
|
1970
|
+
if (firstNonSlashEnd === -1) {
|
|
1971
|
+
// We saw the first non-path separator, remember this index in case
|
|
1972
|
+
// we need it if the extension ends up not matching
|
|
1973
|
+
matchedSlash = false;
|
|
1974
|
+
firstNonSlashEnd = i + 1;
|
|
1975
|
+
}
|
|
1976
|
+
if (extIdx >= 0) {
|
|
1977
|
+
// Try to match the explicit extension
|
|
1978
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
1979
|
+
if (--extIdx === -1) {
|
|
1980
|
+
// We matched the extension, so mark this as the end of our path
|
|
1981
|
+
// component
|
|
1982
|
+
end = i;
|
|
1983
|
+
}
|
|
1984
|
+
} else {
|
|
1985
|
+
// Extension does not match, so our result is the entire path
|
|
1986
|
+
// component
|
|
1987
|
+
extIdx = -1;
|
|
1988
|
+
end = firstNonSlashEnd;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
|
|
1994
|
+
return path.slice(start, end);
|
|
1995
|
+
} else {
|
|
1996
|
+
for (i = path.length - 1; i >= 0; --i) {
|
|
1997
|
+
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
1998
|
+
// If we reached a path separator that was not part of a set of path
|
|
1999
|
+
// separators at the end of the string, stop now
|
|
2000
|
+
if (!matchedSlash) {
|
|
2001
|
+
start = i + 1;
|
|
2002
|
+
break;
|
|
2003
|
+
}
|
|
2004
|
+
} else if (end === -1) {
|
|
2005
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
2006
|
+
// path component
|
|
2007
|
+
matchedSlash = false;
|
|
2008
|
+
end = i + 1;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
if (end === -1) return '';
|
|
2012
|
+
return path.slice(start, end);
|
|
2013
|
+
}
|
|
2014
|
+
},
|
|
2015
|
+
extname: function extname(path) {
|
|
2016
|
+
assertPath(path);
|
|
2017
|
+
var startDot = -1;
|
|
2018
|
+
var startPart = 0;
|
|
2019
|
+
var end = -1;
|
|
2020
|
+
var matchedSlash = true;
|
|
2021
|
+
// Track the state of characters (if any) we see before our first dot and
|
|
2022
|
+
// after any path separator we find
|
|
2023
|
+
var preDotState = 0;
|
|
2024
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
2025
|
+
var code = path.charCodeAt(i);
|
|
2026
|
+
if (code === 47 /*/*/) {
|
|
2027
|
+
// If we reached a path separator that was not part of a set of path
|
|
2028
|
+
// separators at the end of the string, stop now
|
|
2029
|
+
if (!matchedSlash) {
|
|
2030
|
+
startPart = i + 1;
|
|
2031
|
+
break;
|
|
2032
|
+
}
|
|
2033
|
+
continue;
|
|
2034
|
+
}
|
|
2035
|
+
if (end === -1) {
|
|
2036
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
2037
|
+
// extension
|
|
2038
|
+
matchedSlash = false;
|
|
2039
|
+
end = i + 1;
|
|
2040
|
+
}
|
|
2041
|
+
if (code === 46 /*.*/) {
|
|
2042
|
+
// If this is our first dot, mark it as the start of our extension
|
|
2043
|
+
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
|
|
2044
|
+
} else if (startDot !== -1) {
|
|
2045
|
+
// We saw a non-dot and non-path separator before our dot, so we should
|
|
2046
|
+
// have a good chance at having a non-empty extension
|
|
2047
|
+
preDotState = -1;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
if (startDot === -1 || end === -1 ||
|
|
2051
|
+
// We saw a non-dot character immediately before the dot
|
|
2052
|
+
preDotState === 0 ||
|
|
2053
|
+
// The (right-most) trimmed path component is exactly '..'
|
|
2054
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2055
|
+
return '';
|
|
2056
|
+
}
|
|
2057
|
+
return path.slice(startDot, end);
|
|
2058
|
+
},
|
|
2059
|
+
format: function format(pathObject) {
|
|
2060
|
+
if (pathObject === null || _typeof(pathObject) !== 'object') {
|
|
2061
|
+
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + _typeof(pathObject));
|
|
2062
|
+
}
|
|
2063
|
+
return _format('/', pathObject);
|
|
2064
|
+
},
|
|
2065
|
+
parse: function parse(path) {
|
|
2066
|
+
assertPath(path);
|
|
2067
|
+
var ret = {
|
|
2068
|
+
root: '',
|
|
2069
|
+
dir: '',
|
|
2070
|
+
base: '',
|
|
2071
|
+
ext: '',
|
|
2072
|
+
name: ''
|
|
2073
|
+
};
|
|
2074
|
+
if (path.length === 0) return ret;
|
|
2075
|
+
var code = path.charCodeAt(0);
|
|
2076
|
+
var isAbsolute = code === 47 /*/*/;
|
|
2077
|
+
var start;
|
|
2078
|
+
if (isAbsolute) {
|
|
2079
|
+
ret.root = '/';
|
|
2080
|
+
start = 1;
|
|
2081
|
+
} else {
|
|
2082
|
+
start = 0;
|
|
2083
|
+
}
|
|
2084
|
+
var startDot = -1;
|
|
2085
|
+
var startPart = 0;
|
|
2086
|
+
var end = -1;
|
|
2087
|
+
var matchedSlash = true;
|
|
2088
|
+
var i = path.length - 1;
|
|
2089
|
+
|
|
2090
|
+
// Track the state of characters (if any) we see before our first dot and
|
|
2091
|
+
// after any path separator we find
|
|
2092
|
+
var preDotState = 0;
|
|
2093
|
+
|
|
2094
|
+
// Get non-dir info
|
|
2095
|
+
for (; i >= start; --i) {
|
|
2096
|
+
code = path.charCodeAt(i);
|
|
2097
|
+
if (code === 47 /*/*/) {
|
|
2098
|
+
// If we reached a path separator that was not part of a set of path
|
|
2099
|
+
// separators at the end of the string, stop now
|
|
2100
|
+
if (!matchedSlash) {
|
|
2101
|
+
startPart = i + 1;
|
|
2102
|
+
break;
|
|
2103
|
+
}
|
|
2104
|
+
continue;
|
|
2105
|
+
}
|
|
2106
|
+
if (end === -1) {
|
|
2107
|
+
// We saw the first non-path separator, mark this as the end of our
|
|
2108
|
+
// extension
|
|
2109
|
+
matchedSlash = false;
|
|
2110
|
+
end = i + 1;
|
|
2111
|
+
}
|
|
2112
|
+
if (code === 46 /*.*/) {
|
|
2113
|
+
// If this is our first dot, mark it as the start of our extension
|
|
2114
|
+
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
|
|
2115
|
+
} else if (startDot !== -1) {
|
|
2116
|
+
// We saw a non-dot and non-path separator before our dot, so we should
|
|
2117
|
+
// have a good chance at having a non-empty extension
|
|
2118
|
+
preDotState = -1;
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
if (startDot === -1 || end === -1 ||
|
|
2122
|
+
// We saw a non-dot character immediately before the dot
|
|
2123
|
+
preDotState === 0 ||
|
|
2124
|
+
// The (right-most) trimmed path component is exactly '..'
|
|
2125
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
2126
|
+
if (end !== -1) {
|
|
2127
|
+
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
|
|
2128
|
+
}
|
|
2129
|
+
} else {
|
|
2130
|
+
if (startPart === 0 && isAbsolute) {
|
|
2131
|
+
ret.name = path.slice(1, startDot);
|
|
2132
|
+
ret.base = path.slice(1, end);
|
|
2133
|
+
} else {
|
|
2134
|
+
ret.name = path.slice(startPart, startDot);
|
|
2135
|
+
ret.base = path.slice(startPart, end);
|
|
2136
|
+
}
|
|
2137
|
+
ret.ext = path.slice(startDot, end);
|
|
2138
|
+
}
|
|
2139
|
+
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
|
|
2140
|
+
return ret;
|
|
2141
|
+
},
|
|
2142
|
+
sep: '/',
|
|
2143
|
+
delimiter: ':',
|
|
2144
|
+
win32: null,
|
|
2145
|
+
posix: null
|
|
2146
|
+
};
|
|
2147
|
+
posix.posix = posix;
|
|
2148
|
+
module.exports = posix;
|
|
2149
|
+
}).call(this);
|
|
2150
|
+
}).call(this, require('_process'));
|
|
2151
|
+
}, {
|
|
2152
|
+
"_process": 33
|
|
2153
|
+
}],
|
|
2154
|
+
30: [function (require, module, exports) {
|
|
2155
|
+
/**
|
|
2156
|
+
* Precedent Meta-Templating
|
|
2157
|
+
*
|
|
2158
|
+
* @license MIT
|
|
2159
|
+
*
|
|
2160
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
2161
|
+
*
|
|
2162
|
+
* @description Process text streams, parsing out meta-template expressions.
|
|
2163
|
+
*/
|
|
2164
|
+
var libWordTree = require("./WordTree.js");
|
|
2165
|
+
var libStringParser = require("./StringParser.js");
|
|
2166
|
+
var Precedent = /*#__PURE__*/function () {
|
|
2167
|
+
/**
|
|
2168
|
+
* Precedent Constructor
|
|
2169
|
+
*/
|
|
2170
|
+
function Precedent() {
|
|
2171
|
+
_classCallCheck(this, Precedent);
|
|
2172
|
+
this.WordTree = new libWordTree();
|
|
2173
|
+
this.StringParser = new libStringParser();
|
|
2174
|
+
this.ParseTree = this.WordTree.ParseTree;
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* Add a Pattern to the Parse Tree
|
|
2179
|
+
* @method addPattern
|
|
2180
|
+
* @param {Object} pTree - A node on the parse tree to push the characters into
|
|
2181
|
+
* @param {string} pPattern - The string to add to the tree
|
|
2182
|
+
* @param {number} pIndex - callback function
|
|
2183
|
+
* @return {bool} True if adding the pattern was successful
|
|
2184
|
+
*/
|
|
2185
|
+
_createClass(Precedent, [{
|
|
2186
|
+
key: "addPattern",
|
|
2187
|
+
value: function addPattern(pPatternStart, pPatternEnd, pParser) {
|
|
2188
|
+
return this.WordTree.addPattern(pPatternStart, pPatternEnd, pParser);
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
/**
|
|
2192
|
+
* Parse a string with the existing parse tree
|
|
2193
|
+
* @method parseString
|
|
2194
|
+
* @param {string} pString - The string to parse
|
|
2195
|
+
* @return {string} The result from the parser
|
|
2196
|
+
*/
|
|
2197
|
+
}, {
|
|
2198
|
+
key: "parseString",
|
|
2199
|
+
value: function parseString(pString) {
|
|
2200
|
+
return this.StringParser.parseString(pString, this.ParseTree);
|
|
2201
|
+
}
|
|
2202
|
+
}]);
|
|
2203
|
+
return Precedent;
|
|
2204
|
+
}();
|
|
2205
|
+
module.exports = Precedent;
|
|
2206
|
+
}, {
|
|
2207
|
+
"./StringParser.js": 31,
|
|
2208
|
+
"./WordTree.js": 32
|
|
2209
|
+
}],
|
|
2210
|
+
31: [function (require, module, exports) {
|
|
2211
|
+
/**
|
|
2212
|
+
* String Parser
|
|
2213
|
+
*
|
|
2214
|
+
* @license MIT
|
|
2215
|
+
*
|
|
2216
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
2217
|
+
*
|
|
2218
|
+
* @description Parse a string, properly processing each matched token in the word tree.
|
|
2219
|
+
*/
|
|
2220
|
+
var StringParser = /*#__PURE__*/function () {
|
|
2221
|
+
/**
|
|
2222
|
+
* StringParser Constructor
|
|
2223
|
+
*/
|
|
2224
|
+
function StringParser() {
|
|
2225
|
+
_classCallCheck(this, StringParser);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
/**
|
|
2229
|
+
* Create a fresh parsing state object to work with.
|
|
2230
|
+
* @method newParserState
|
|
2231
|
+
* @param {Object} pParseTree - A node on the parse tree to begin parsing from (usually root)
|
|
2232
|
+
* @return {Object} A new parser state object for running a character parser on
|
|
2233
|
+
* @private
|
|
2234
|
+
*/
|
|
2235
|
+
_createClass(StringParser, [{
|
|
2236
|
+
key: "newParserState",
|
|
2237
|
+
value: function newParserState(pParseTree) {
|
|
2238
|
+
return {
|
|
2239
|
+
ParseTree: pParseTree,
|
|
2240
|
+
Output: '',
|
|
2241
|
+
OutputBuffer: '',
|
|
2242
|
+
Pattern: false,
|
|
2243
|
+
PatternMatch: false,
|
|
2244
|
+
PatternMatchOutputBuffer: ''
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Assign a node of the parser tree to be the next potential match.
|
|
2250
|
+
* If the node has a PatternEnd property, it is a valid match and supercedes the last valid match (or becomes the initial match).
|
|
2251
|
+
* @method assignNode
|
|
2252
|
+
* @param {Object} pNode - A node on the parse tree to assign
|
|
2253
|
+
* @param {Object} pParserState - The state object for the current parsing task
|
|
2254
|
+
* @private
|
|
2255
|
+
*/
|
|
2256
|
+
}, {
|
|
2257
|
+
key: "assignNode",
|
|
2258
|
+
value: function assignNode(pNode, pParserState) {
|
|
2259
|
+
pParserState.PatternMatch = pNode;
|
|
2260
|
+
|
|
2261
|
+
// If the pattern has a END we can assume it has a parse function...
|
|
2262
|
+
if (pParserState.PatternMatch.hasOwnProperty('PatternEnd')) {
|
|
2263
|
+
// ... this is the legitimate start of a pattern.
|
|
2264
|
+
pParserState.Pattern = pParserState.PatternMatch;
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
/**
|
|
2269
|
+
* Append a character to the output buffer in the parser state.
|
|
2270
|
+
* This output buffer is used when a potential match is being explored, or a match is being explored.
|
|
2271
|
+
* @method appendOutputBuffer
|
|
2272
|
+
* @param {string} pCharacter - The character to append
|
|
2273
|
+
* @param {Object} pParserState - The state object for the current parsing task
|
|
2274
|
+
* @private
|
|
2275
|
+
*/
|
|
2276
|
+
}, {
|
|
2277
|
+
key: "appendOutputBuffer",
|
|
2278
|
+
value: function appendOutputBuffer(pCharacter, pParserState) {
|
|
2279
|
+
pParserState.OutputBuffer += pCharacter;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
/**
|
|
2283
|
+
* Flush the output buffer to the output and clear it.
|
|
2284
|
+
* @method flushOutputBuffer
|
|
2285
|
+
* @param {Object} pParserState - The state object for the current parsing task
|
|
2286
|
+
* @private
|
|
2287
|
+
*/
|
|
2288
|
+
}, {
|
|
2289
|
+
key: "flushOutputBuffer",
|
|
2290
|
+
value: function flushOutputBuffer(pParserState) {
|
|
2291
|
+
pParserState.Output += pParserState.OutputBuffer;
|
|
2292
|
+
pParserState.OutputBuffer = '';
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
/**
|
|
2296
|
+
* Check if the pattern has ended. If it has, properly flush the buffer and start looking for new patterns.
|
|
2297
|
+
* @method checkPatternEnd
|
|
2298
|
+
* @param {Object} pParserState - The state object for the current parsing task
|
|
2299
|
+
* @private
|
|
2300
|
+
*/
|
|
2301
|
+
}, {
|
|
2302
|
+
key: "checkPatternEnd",
|
|
2303
|
+
value: function checkPatternEnd(pParserState) {
|
|
2304
|
+
if (pParserState.OutputBuffer.length >= pParserState.Pattern.PatternEnd.length + pParserState.Pattern.PatternStart.length && pParserState.OutputBuffer.substr(-pParserState.Pattern.PatternEnd.length) === pParserState.Pattern.PatternEnd) {
|
|
2305
|
+
// ... this is the end of a pattern, cut off the end tag and parse it.
|
|
2306
|
+
// Trim the start and end tags off the output buffer now
|
|
2307
|
+
pParserState.OutputBuffer = pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length, pParserState.OutputBuffer.length - (pParserState.Pattern.PatternStart.length + pParserState.Pattern.PatternEnd.length)));
|
|
2308
|
+
// Flush the output buffer.
|
|
2309
|
+
this.flushOutputBuffer(pParserState);
|
|
2310
|
+
// End pattern mode
|
|
2311
|
+
pParserState.Pattern = false;
|
|
2312
|
+
pParserState.PatternMatch = false;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* Parse a character in the buffer.
|
|
2318
|
+
* @method parseCharacter
|
|
2319
|
+
* @param {string} pCharacter - The character to append
|
|
2320
|
+
* @param {Object} pParserState - The state object for the current parsing task
|
|
2321
|
+
* @private
|
|
2322
|
+
*/
|
|
2323
|
+
}, {
|
|
2324
|
+
key: "parseCharacter",
|
|
2325
|
+
value: function parseCharacter(pCharacter, pParserState) {
|
|
2326
|
+
// (1) If we aren't in a pattern match, and we aren't potentially matching, and this may be the start of a new pattern....
|
|
2327
|
+
if (!pParserState.PatternMatch && pParserState.ParseTree.hasOwnProperty(pCharacter)) {
|
|
2328
|
+
// ... assign the node as the matched node.
|
|
2329
|
+
this.assignNode(pParserState.ParseTree[pCharacter], pParserState);
|
|
2330
|
+
this.appendOutputBuffer(pCharacter, pParserState);
|
|
2331
|
+
}
|
|
2332
|
+
// (2) If we are in a pattern match (actively seeing if this is part of a new pattern token)
|
|
2333
|
+
else if (pParserState.PatternMatch) {
|
|
2334
|
+
// If the pattern has a subpattern with this key
|
|
2335
|
+
if (pParserState.PatternMatch.hasOwnProperty(pCharacter)) {
|
|
2336
|
+
// Continue matching patterns.
|
|
2337
|
+
this.assignNode(pParserState.PatternMatch[pCharacter], pParserState);
|
|
2338
|
+
}
|
|
2339
|
+
this.appendOutputBuffer(pCharacter, pParserState);
|
|
2340
|
+
if (pParserState.Pattern) {
|
|
2341
|
+
// ... Check if this is the end of the pattern (if we are matching a valid pattern)...
|
|
2342
|
+
this.checkPatternEnd(pParserState);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
// (3) If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
|
|
2346
|
+
else {
|
|
2347
|
+
pParserState.Output += pCharacter;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
/**
|
|
2352
|
+
* Parse a string for matches, and process any template segments that occur.
|
|
2353
|
+
* @method parseString
|
|
2354
|
+
* @param {string} pString - The string to parse.
|
|
2355
|
+
* @param {Object} pParseTree - The parse tree to begin parsing from (usually root)
|
|
2356
|
+
*/
|
|
2357
|
+
}, {
|
|
2358
|
+
key: "parseString",
|
|
2359
|
+
value: function parseString(pString, pParseTree) {
|
|
2360
|
+
var tmpParserState = this.newParserState(pParseTree);
|
|
2361
|
+
for (var i = 0; i < pString.length; i++) {
|
|
2362
|
+
// TODO: This is not fast.
|
|
2363
|
+
this.parseCharacter(pString[i], tmpParserState);
|
|
2364
|
+
}
|
|
2365
|
+
this.flushOutputBuffer(tmpParserState);
|
|
2366
|
+
return tmpParserState.Output;
|
|
2367
|
+
}
|
|
2368
|
+
}]);
|
|
2369
|
+
return StringParser;
|
|
2370
|
+
}();
|
|
2371
|
+
module.exports = StringParser;
|
|
2372
|
+
}, {}],
|
|
2373
|
+
32: [function (require, module, exports) {
|
|
2374
|
+
/**
|
|
2375
|
+
* Word Tree
|
|
2376
|
+
*
|
|
2377
|
+
* @license MIT
|
|
2378
|
+
*
|
|
2379
|
+
* @author Steven Velozo <steven@velozo.com>
|
|
2380
|
+
*
|
|
2381
|
+
* @description Create a tree (directed graph) of Javascript objects, one character per object.
|
|
2382
|
+
*/
|
|
2383
|
+
var WordTree = /*#__PURE__*/function () {
|
|
2384
|
+
/**
|
|
2385
|
+
* WordTree Constructor
|
|
2386
|
+
*/
|
|
2387
|
+
function WordTree() {
|
|
2388
|
+
_classCallCheck(this, WordTree);
|
|
2389
|
+
this.ParseTree = {};
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* Add a child character to a Parse Tree node
|
|
2394
|
+
* @method addChild
|
|
2395
|
+
* @param {Object} pTree - A parse tree to push the characters into
|
|
2396
|
+
* @param {string} pPattern - The string to add to the tree
|
|
2397
|
+
* @param {number} pIndex - The index of the character in the pattern
|
|
2398
|
+
* @returns {Object} The resulting leaf node that was added (or found)
|
|
2399
|
+
* @private
|
|
2400
|
+
*/
|
|
2401
|
+
_createClass(WordTree, [{
|
|
2402
|
+
key: "addChild",
|
|
2403
|
+
value: function addChild(pTree, pPattern, pIndex) {
|
|
2404
|
+
if (!pTree.hasOwnProperty(pPattern[pIndex])) pTree[pPattern[pIndex]] = {};
|
|
2405
|
+
return pTree[pPattern[pIndex]];
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
/** Add a Pattern to the Parse Tree
|
|
2409
|
+
* @method addPattern
|
|
2410
|
+
* @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
|
|
2411
|
+
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
2412
|
+
* @param {number} pParser - The function to parse if this is the matched pattern, once the Pattern End is met. If this is a string, a simple replacement occurs.
|
|
2413
|
+
* @return {bool} True if adding the pattern was successful
|
|
2414
|
+
*/
|
|
2415
|
+
}, {
|
|
2416
|
+
key: "addPattern",
|
|
2417
|
+
value: function addPattern(pPatternStart, pPatternEnd, pParser) {
|
|
2418
|
+
if (pPatternStart.length < 1) return false;
|
|
2419
|
+
if (typeof pPatternEnd === 'string' && pPatternEnd.length < 1) return false;
|
|
2420
|
+
var tmpLeaf = this.ParseTree;
|
|
2421
|
+
|
|
2422
|
+
// Add the tree of leaves iteratively
|
|
2423
|
+
for (var i = 0; i < pPatternStart.length; i++) tmpLeaf = this.addChild(tmpLeaf, pPatternStart, i);
|
|
2424
|
+
tmpLeaf.PatternStart = pPatternStart;
|
|
2425
|
+
tmpLeaf.PatternEnd = typeof pPatternEnd === 'string' && pPatternEnd.length > 0 ? pPatternEnd : pPatternStart;
|
|
2426
|
+
tmpLeaf.Parse = typeof pParser === 'function' ? pParser : typeof pParser === 'string' ? function () {
|
|
2427
|
+
return pParser;
|
|
2428
|
+
} : function (pData) {
|
|
2429
|
+
return pData;
|
|
2430
|
+
};
|
|
2431
|
+
return true;
|
|
2432
|
+
}
|
|
2433
|
+
}]);
|
|
2434
|
+
return WordTree;
|
|
2435
|
+
}();
|
|
2436
|
+
module.exports = WordTree;
|
|
2437
|
+
}, {}],
|
|
2438
|
+
33: [function (require, module, exports) {
|
|
2439
|
+
// shim for using process in browser
|
|
2440
|
+
var process = module.exports = {};
|
|
2441
|
+
|
|
2442
|
+
// cached from whatever global is present so that test runners that stub it
|
|
2443
|
+
// don't break things. But we need to wrap it in a try catch in case it is
|
|
2444
|
+
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
2445
|
+
// function because try/catches deoptimize in certain engines.
|
|
2446
|
+
|
|
2447
|
+
var cachedSetTimeout;
|
|
2448
|
+
var cachedClearTimeout;
|
|
2449
|
+
function defaultSetTimout() {
|
|
2450
|
+
throw new Error('setTimeout has not been defined');
|
|
2451
|
+
}
|
|
2452
|
+
function defaultClearTimeout() {
|
|
2453
|
+
throw new Error('clearTimeout has not been defined');
|
|
2454
|
+
}
|
|
2455
|
+
(function () {
|
|
2456
|
+
try {
|
|
2457
|
+
if (typeof setTimeout === 'function') {
|
|
2458
|
+
cachedSetTimeout = setTimeout;
|
|
2459
|
+
} else {
|
|
2460
|
+
cachedSetTimeout = defaultSetTimout;
|
|
2461
|
+
}
|
|
2462
|
+
} catch (e) {
|
|
2463
|
+
cachedSetTimeout = defaultSetTimout;
|
|
2464
|
+
}
|
|
2465
|
+
try {
|
|
2466
|
+
if (typeof clearTimeout === 'function') {
|
|
2467
|
+
cachedClearTimeout = clearTimeout;
|
|
2468
|
+
} else {
|
|
2469
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
2470
|
+
}
|
|
2471
|
+
} catch (e) {
|
|
2472
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
2473
|
+
}
|
|
2474
|
+
})();
|
|
2475
|
+
function runTimeout(fun) {
|
|
2476
|
+
if (cachedSetTimeout === setTimeout) {
|
|
2477
|
+
//normal enviroments in sane situations
|
|
2478
|
+
return setTimeout(fun, 0);
|
|
2479
|
+
}
|
|
2480
|
+
// if setTimeout wasn't available but was latter defined
|
|
2481
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
2482
|
+
cachedSetTimeout = setTimeout;
|
|
2483
|
+
return setTimeout(fun, 0);
|
|
2484
|
+
}
|
|
2485
|
+
try {
|
|
2486
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
2487
|
+
return cachedSetTimeout(fun, 0);
|
|
2488
|
+
} catch (e) {
|
|
2489
|
+
try {
|
|
2490
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
2491
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
2492
|
+
} catch (e) {
|
|
2493
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
2494
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
function runClearTimeout(marker) {
|
|
2499
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
2500
|
+
//normal enviroments in sane situations
|
|
2501
|
+
return clearTimeout(marker);
|
|
2502
|
+
}
|
|
2503
|
+
// if clearTimeout wasn't available but was latter defined
|
|
2504
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
2505
|
+
cachedClearTimeout = clearTimeout;
|
|
2506
|
+
return clearTimeout(marker);
|
|
2507
|
+
}
|
|
2508
|
+
try {
|
|
2509
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
2510
|
+
return cachedClearTimeout(marker);
|
|
2511
|
+
} catch (e) {
|
|
2512
|
+
try {
|
|
2513
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
2514
|
+
return cachedClearTimeout.call(null, marker);
|
|
2515
|
+
} catch (e) {
|
|
2516
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
2517
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
2518
|
+
return cachedClearTimeout.call(this, marker);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
var queue = [];
|
|
2523
|
+
var draining = false;
|
|
2524
|
+
var currentQueue;
|
|
2525
|
+
var queueIndex = -1;
|
|
2526
|
+
function cleanUpNextTick() {
|
|
2527
|
+
if (!draining || !currentQueue) {
|
|
2528
|
+
return;
|
|
2529
|
+
}
|
|
2530
|
+
draining = false;
|
|
2531
|
+
if (currentQueue.length) {
|
|
2532
|
+
queue = currentQueue.concat(queue);
|
|
2533
|
+
} else {
|
|
2534
|
+
queueIndex = -1;
|
|
2535
|
+
}
|
|
2536
|
+
if (queue.length) {
|
|
2537
|
+
drainQueue();
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
function drainQueue() {
|
|
2541
|
+
if (draining) {
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
2545
|
+
draining = true;
|
|
2546
|
+
var len = queue.length;
|
|
2547
|
+
while (len) {
|
|
2548
|
+
currentQueue = queue;
|
|
2549
|
+
queue = [];
|
|
2550
|
+
while (++queueIndex < len) {
|
|
2551
|
+
if (currentQueue) {
|
|
2552
|
+
currentQueue[queueIndex].run();
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
queueIndex = -1;
|
|
2556
|
+
len = queue.length;
|
|
2557
|
+
}
|
|
2558
|
+
currentQueue = null;
|
|
2559
|
+
draining = false;
|
|
2560
|
+
runClearTimeout(timeout);
|
|
2561
|
+
}
|
|
2562
|
+
process.nextTick = function (fun) {
|
|
2563
|
+
var args = new Array(arguments.length - 1);
|
|
2564
|
+
if (arguments.length > 1) {
|
|
2565
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2566
|
+
args[i - 1] = arguments[i];
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
queue.push(new Item(fun, args));
|
|
2570
|
+
if (queue.length === 1 && !draining) {
|
|
2571
|
+
runTimeout(drainQueue);
|
|
2572
|
+
}
|
|
2573
|
+
};
|
|
2574
|
+
|
|
2575
|
+
// v8 likes predictible objects
|
|
2576
|
+
function Item(fun, array) {
|
|
2577
|
+
this.fun = fun;
|
|
2578
|
+
this.array = array;
|
|
2579
|
+
}
|
|
2580
|
+
Item.prototype.run = function () {
|
|
2581
|
+
this.fun.apply(null, this.array);
|
|
2582
|
+
};
|
|
2583
|
+
process.title = 'browser';
|
|
2584
|
+
process.browser = true;
|
|
2585
|
+
process.env = {};
|
|
2586
|
+
process.argv = [];
|
|
2587
|
+
process.version = ''; // empty string to avoid regexp issues
|
|
2588
|
+
process.versions = {};
|
|
2589
|
+
function noop() {}
|
|
2590
|
+
process.on = noop;
|
|
2591
|
+
process.addListener = noop;
|
|
2592
|
+
process.once = noop;
|
|
2593
|
+
process.off = noop;
|
|
2594
|
+
process.removeListener = noop;
|
|
2595
|
+
process.removeAllListeners = noop;
|
|
2596
|
+
process.emit = noop;
|
|
2597
|
+
process.prependListener = noop;
|
|
2598
|
+
process.prependOnceListener = noop;
|
|
2599
|
+
process.listeners = function (name) {
|
|
2600
|
+
return [];
|
|
2601
|
+
};
|
|
2602
|
+
process.binding = function (name) {
|
|
2603
|
+
throw new Error('process.binding is not supported');
|
|
2604
|
+
};
|
|
2605
|
+
process.cwd = function () {
|
|
2606
|
+
return '/';
|
|
2607
|
+
};
|
|
2608
|
+
process.chdir = function (dir) {
|
|
2609
|
+
throw new Error('process.chdir is not supported');
|
|
2610
|
+
};
|
|
2611
|
+
process.umask = function () {
|
|
2612
|
+
return 0;
|
|
2613
|
+
};
|
|
2614
|
+
}, {}],
|
|
2615
|
+
34: [function (require, module, exports) {
|
|
2616
|
+
(function (setImmediate, clearImmediate) {
|
|
2617
|
+
(function () {
|
|
2618
|
+
var nextTick = require('process/browser.js').nextTick;
|
|
2619
|
+
var apply = Function.prototype.apply;
|
|
2620
|
+
var slice = Array.prototype.slice;
|
|
2621
|
+
var immediateIds = {};
|
|
2622
|
+
var nextImmediateId = 0;
|
|
2623
|
+
|
|
2624
|
+
// DOM APIs, for completeness
|
|
2625
|
+
|
|
2626
|
+
exports.setTimeout = function () {
|
|
2627
|
+
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
|
|
2628
|
+
};
|
|
2629
|
+
exports.setInterval = function () {
|
|
2630
|
+
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
|
|
2631
|
+
};
|
|
2632
|
+
exports.clearTimeout = exports.clearInterval = function (timeout) {
|
|
2633
|
+
timeout.close();
|
|
2634
|
+
};
|
|
2635
|
+
function Timeout(id, clearFn) {
|
|
2636
|
+
this._id = id;
|
|
2637
|
+
this._clearFn = clearFn;
|
|
2638
|
+
}
|
|
2639
|
+
Timeout.prototype.unref = Timeout.prototype.ref = function () {};
|
|
2640
|
+
Timeout.prototype.close = function () {
|
|
2641
|
+
this._clearFn.call(window, this._id);
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
// Does not start the time, just sets up the members needed.
|
|
2645
|
+
exports.enroll = function (item, msecs) {
|
|
2646
|
+
clearTimeout(item._idleTimeoutId);
|
|
2647
|
+
item._idleTimeout = msecs;
|
|
2648
|
+
};
|
|
2649
|
+
exports.unenroll = function (item) {
|
|
2650
|
+
clearTimeout(item._idleTimeoutId);
|
|
2651
|
+
item._idleTimeout = -1;
|
|
2652
|
+
};
|
|
2653
|
+
exports._unrefActive = exports.active = function (item) {
|
|
2654
|
+
clearTimeout(item._idleTimeoutId);
|
|
2655
|
+
var msecs = item._idleTimeout;
|
|
2656
|
+
if (msecs >= 0) {
|
|
2657
|
+
item._idleTimeoutId = setTimeout(function onTimeout() {
|
|
2658
|
+
if (item._onTimeout) item._onTimeout();
|
|
2659
|
+
}, msecs);
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
|
|
2663
|
+
// That's not how node.js implements it but the exposed api is the same.
|
|
2664
|
+
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function (fn) {
|
|
2665
|
+
var id = nextImmediateId++;
|
|
2666
|
+
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
|
|
2667
|
+
immediateIds[id] = true;
|
|
2668
|
+
nextTick(function onNextTick() {
|
|
2669
|
+
if (immediateIds[id]) {
|
|
2670
|
+
// fn.call() is faster so we optimize for the common use-case
|
|
2671
|
+
// @see http://jsperf.com/call-apply-segu
|
|
2672
|
+
if (args) {
|
|
2673
|
+
fn.apply(null, args);
|
|
2674
|
+
} else {
|
|
2675
|
+
fn.call(null);
|
|
2676
|
+
}
|
|
2677
|
+
// Prevent ids from leaking
|
|
2678
|
+
exports.clearImmediate(id);
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
return id;
|
|
2682
|
+
};
|
|
2683
|
+
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function (id) {
|
|
2684
|
+
delete immediateIds[id];
|
|
2685
|
+
};
|
|
2686
|
+
}).call(this);
|
|
2687
|
+
}).call(this, require("timers").setImmediate, require("timers").clearImmediate);
|
|
2688
|
+
}, {
|
|
2689
|
+
"process/browser.js": 33,
|
|
2690
|
+
"timers": 34
|
|
2691
|
+
}],
|
|
2692
|
+
35: [function (require, module, exports) {
|
|
2693
|
+
var libNPMModuleWrapper = require('./Fable.js');
|
|
2694
|
+
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.hasOwnProperty('Fable')) {
|
|
2695
|
+
window.Fable = libNPMModuleWrapper;
|
|
2696
|
+
}
|
|
2697
|
+
module.exports = libNPMModuleWrapper;
|
|
2698
|
+
}, {
|
|
2699
|
+
"./Fable.js": 42
|
|
2700
|
+
}],
|
|
2701
|
+
36: [function (require, module, exports) {
|
|
2702
|
+
var _OperationStatePrototype = JSON.stringify({
|
|
2703
|
+
"Metadata": {
|
|
2704
|
+
"GUID": false,
|
|
2705
|
+
"Hash": false,
|
|
2706
|
+
"Title": "",
|
|
2707
|
+
"Summary": "",
|
|
2708
|
+
"Version": 0
|
|
2709
|
+
},
|
|
2710
|
+
"Status": {
|
|
2711
|
+
"Completed": false,
|
|
2712
|
+
"CompletionProgress": 0,
|
|
2713
|
+
"CompletionTimeElapsed": 0,
|
|
2714
|
+
"Steps": 1,
|
|
2715
|
+
"StepsCompleted": 0,
|
|
2716
|
+
"StartTime": 0,
|
|
2717
|
+
"EndTime": 0
|
|
2718
|
+
},
|
|
2719
|
+
"Errors": [],
|
|
2720
|
+
"Log": []
|
|
2721
|
+
});
|
|
2722
|
+
var FableOperation = /*#__PURE__*/function () {
|
|
2723
|
+
function FableOperation(pFable, pOperationName, pOperationHash) {
|
|
2724
|
+
_classCallCheck(this, FableOperation);
|
|
2725
|
+
this.fable = pFable;
|
|
2726
|
+
this.name = pOperationName;
|
|
2727
|
+
this.state = JSON.parse(_OperationStatePrototype);
|
|
2728
|
+
this.state.Metadata.GUID = this.fable.getUUID();
|
|
2729
|
+
this.state.Metadata.Hash = this.state.GUID;
|
|
2730
|
+
if (typeof pOperationHash == 'string') {
|
|
2731
|
+
this.state.Metadata.Hash = pOperationHash;
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
_createClass(FableOperation, [{
|
|
2735
|
+
key: "GUID",
|
|
2736
|
+
get: function get() {
|
|
2737
|
+
return this.state.Metadata.GUID;
|
|
2738
|
+
}
|
|
2739
|
+
}, {
|
|
2740
|
+
key: "Hash",
|
|
2741
|
+
get: function get() {
|
|
2742
|
+
return this.state.Metadata.Hash;
|
|
2743
|
+
}
|
|
2744
|
+
}, {
|
|
2745
|
+
key: "log",
|
|
2746
|
+
get: function get() {
|
|
2747
|
+
return this;
|
|
2748
|
+
}
|
|
2749
|
+
}, {
|
|
2750
|
+
key: "writeOperationLog",
|
|
2751
|
+
value: function writeOperationLog(pLogLevel, pLogText, pLogObject) {
|
|
2752
|
+
this.state.Log.push("".concat(new Date().toUTCString(), " [").concat(pLogLevel, "]: ").concat(pLogText));
|
|
2753
|
+
if (_typeof(pLogObject) == 'object') {
|
|
2754
|
+
this.state.Log.push(JSON.stringify(pLogObject));
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
}, {
|
|
2758
|
+
key: "writeOperationErrors",
|
|
2759
|
+
value: function writeOperationErrors(pLogText, pLogObject) {
|
|
2760
|
+
this.state.Errors.push("".concat(pLogText));
|
|
2761
|
+
if (_typeof(pLogObject) == 'object') {
|
|
2762
|
+
this.state.Errors.push(JSON.stringify(pLogObject));
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
}, {
|
|
2766
|
+
key: "trace",
|
|
2767
|
+
value: function trace(pLogText, pLogObject) {
|
|
2768
|
+
this.writeOperationLog('TRACE', pLogText, pLogObject);
|
|
2769
|
+
this.fable.log.trace(pLogText, pLogObject);
|
|
2770
|
+
}
|
|
2771
|
+
}, {
|
|
2772
|
+
key: "debug",
|
|
2773
|
+
value: function debug(pLogText, pLogObject) {
|
|
2774
|
+
this.writeOperationLog('DEBUG', pLogText, pLogObject);
|
|
2775
|
+
this.fable.log.debug(pLogText, pLogObject);
|
|
2776
|
+
}
|
|
2777
|
+
}, {
|
|
2778
|
+
key: "info",
|
|
2779
|
+
value: function info(pLogText, pLogObject) {
|
|
2780
|
+
this.writeOperationLog('INFO', pLogText, pLogObject);
|
|
2781
|
+
this.fable.log.info(pLogText, pLogObject);
|
|
2782
|
+
}
|
|
2783
|
+
}, {
|
|
2784
|
+
key: "warn",
|
|
2785
|
+
value: function warn(pLogText, pLogObject) {
|
|
2786
|
+
this.writeOperationLog('WARN', pLogText, pLogObject);
|
|
2787
|
+
this.fable.log.warn(pLogText, pLogObject);
|
|
2788
|
+
}
|
|
2789
|
+
}, {
|
|
2790
|
+
key: "error",
|
|
2791
|
+
value: function error(pLogText, pLogObject) {
|
|
2792
|
+
this.writeOperationLog('ERROR', pLogText, pLogObject);
|
|
2793
|
+
this.writeOperationErrors(pLogText, pLogObject);
|
|
2794
|
+
this.fable.log.error(pLogText, pLogObject);
|
|
2795
|
+
}
|
|
2796
|
+
}, {
|
|
2797
|
+
key: "fatal",
|
|
2798
|
+
value: function fatal(pLogText, pLogObject) {
|
|
2799
|
+
this.writeOperationLog('FATAL', pLogText, pLogObject);
|
|
2800
|
+
this.writeOperationErrors(pLogText, pLogObject);
|
|
2801
|
+
this.fable.log.fatal(pLogText, pLogObject);
|
|
2802
|
+
}
|
|
2803
|
+
}]);
|
|
2804
|
+
return FableOperation;
|
|
2805
|
+
}();
|
|
2806
|
+
module.exports = FableOperation;
|
|
2807
|
+
}, {}],
|
|
2808
|
+
37: [function (require, module, exports) {
|
|
2809
|
+
var libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2810
|
+
var libDataArithmatic = require('data-arithmatic');
|
|
2811
|
+
var FableServiceDataArithmatic = /*#__PURE__*/function (_libFableServiceBase) {
|
|
2812
|
+
_inherits(FableServiceDataArithmatic, _libFableServiceBase);
|
|
2813
|
+
var _super3 = _createSuper(FableServiceDataArithmatic);
|
|
2814
|
+
function FableServiceDataArithmatic(pFable, pOptions, pServiceHash) {
|
|
2815
|
+
var _this4;
|
|
2816
|
+
_classCallCheck(this, FableServiceDataArithmatic);
|
|
2817
|
+
_this4 = _super3.call(this, pFable, pOptions, pServiceHash);
|
|
2818
|
+
_this4.serviceType = 'DataArithmatic';
|
|
2819
|
+
_this4._DataArithmaticLibrary = new libDataArithmatic();
|
|
2820
|
+
return _this4;
|
|
2821
|
+
}
|
|
2822
|
+
return _createClass(FableServiceDataArithmatic);
|
|
2823
|
+
}(libFableServiceBase);
|
|
2824
|
+
module.exports = FableServiceDataArithmatic;
|
|
2825
|
+
}, {
|
|
2826
|
+
"./Fable-ServiceProviderBase.js": 41,
|
|
2827
|
+
"data-arithmatic": 17
|
|
2828
|
+
}],
|
|
2829
|
+
38: [function (require, module, exports) {
|
|
2830
|
+
var libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2831
|
+
var FableServiceTemplate = /*#__PURE__*/function (_libFableServiceBase2) {
|
|
2832
|
+
_inherits(FableServiceTemplate, _libFableServiceBase2);
|
|
2833
|
+
var _super4 = _createSuper(FableServiceTemplate);
|
|
2834
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2835
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2836
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2837
|
+
//
|
|
2838
|
+
// NOTE: This does not implement underscore escape expressions
|
|
2839
|
+
// NOTE: This does not implement underscore magic browser variable assignment
|
|
2840
|
+
//
|
|
2841
|
+
// This is an implementation of that.
|
|
2842
|
+
// TODO: Make this use precedent, add configuration, add debugging.
|
|
2843
|
+
function FableServiceTemplate(pFable, pOptions, pServiceHash) {
|
|
2844
|
+
var _this5;
|
|
2845
|
+
_classCallCheck(this, FableServiceTemplate);
|
|
2846
|
+
_this5 = _super4.call(this, pFable, pOptions, pServiceHash);
|
|
2847
|
+
_this5.serviceType = 'Template';
|
|
2848
|
+
|
|
2849
|
+
// These are the exact regex's used in lodash/underscore
|
|
2850
|
+
// TODO: Switch this to precedent
|
|
2851
|
+
_this5.Matchers = {
|
|
2852
|
+
Evaluate: /<%([\s\S]+?)%>/g,
|
|
2853
|
+
Interpolate: /<%=([\s\S]+?)%>/g,
|
|
2854
|
+
Escaper: /\\|'|\r|\n|\t|\u2028|\u2029/g,
|
|
2855
|
+
Unescaper: /\\(\\|'|r|n|t|u2028|u2029)/g,
|
|
2856
|
+
// This is how underscore does it, so we are keeping it for now.
|
|
2857
|
+
GuaranteedNonMatch: /.^/
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
// This is a helper for the escaper and unescaper functions.
|
|
2861
|
+
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
2862
|
+
_this5.templateEscapes = {
|
|
2863
|
+
'\\': '\\',
|
|
2864
|
+
"'": "'",
|
|
2865
|
+
'r': '\r',
|
|
2866
|
+
'\r': 'r',
|
|
2867
|
+
'n': '\n',
|
|
2868
|
+
'\n': 'n',
|
|
2869
|
+
't': '\t',
|
|
2870
|
+
'\t': 't',
|
|
2871
|
+
'u2028': "\u2028",
|
|
2872
|
+
"\u2028": 'u2028',
|
|
2873
|
+
'u2029': "\u2029",
|
|
2874
|
+
"\u2029": 'u2029'
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2877
|
+
// This is defined as such to underscore that it is a dynamic programming
|
|
2878
|
+
// function on this class.
|
|
2879
|
+
_this5.renderFunction = false;
|
|
2880
|
+
_this5.templateString = false;
|
|
2881
|
+
return _this5;
|
|
2882
|
+
}
|
|
2883
|
+
_createClass(FableServiceTemplate, [{
|
|
2884
|
+
key: "renderTemplate",
|
|
2885
|
+
value: function renderTemplate(pData) {
|
|
2886
|
+
return this.renderFunction(pData);
|
|
2887
|
+
}
|
|
2888
|
+
}, {
|
|
2889
|
+
key: "templateFunction",
|
|
2890
|
+
value: function templateFunction(pData) {
|
|
2891
|
+
var fRenderTemplateBound = this.renderTemplate.bind(this);
|
|
2892
|
+
return fRenderTemplateBound;
|
|
2893
|
+
}
|
|
2894
|
+
}, {
|
|
2895
|
+
key: "buildTemplateFunction",
|
|
2896
|
+
value: function buildTemplateFunction(pTemplateText, pData) {
|
|
2897
|
+
var _this6 = this;
|
|
2898
|
+
// For now this is being kept in a weird form ... this is to mimic the old
|
|
2899
|
+
// underscore code until this is rewritten using precedent.
|
|
2900
|
+
this.TemplateSource = "__p+='" + pTemplateText.replace(this.Matchers.Escaper, function (pMatch) {
|
|
2901
|
+
return "\\".concat(_this6.templateEscapes[pMatch]);
|
|
2902
|
+
}).replace(this.Matchers.Interpolate || this.Matchers.GuaranteedNonMatch, function (pMatch, pCode) {
|
|
2903
|
+
return "'+\n(".concat(decodeURIComponent(pCode), ")+\n'");
|
|
2904
|
+
}).replace(this.Matchers.Evaluate || this.Matchers.GuaranteedNonMatch, function (pMatch, pCode) {
|
|
2905
|
+
return "';\n".concat(decodeURIComponent(pCode), "\n;__p+='");
|
|
2906
|
+
}) + "';\n";
|
|
2907
|
+
this.TemplateSource = "with(pTemplateDataObject||{}){\n".concat(this.TemplateSource, "}\n");
|
|
2908
|
+
this.TemplateSource = "var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n".concat(this.TemplateSource, "return __p;\n");
|
|
2909
|
+
this.renderFunction = new Function('pTemplateDataObject', this.TemplateSource);
|
|
2910
|
+
if (typeof pData != 'undefined') {
|
|
2911
|
+
return this.renderFunction(pData);
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
// Provide the compiled function source as a convenience for build time
|
|
2915
|
+
// precompilation.
|
|
2916
|
+
this.TemplateSourceCompiled = 'function(obj){\n' + this.TemplateSource + '}';
|
|
2917
|
+
return this.templateFunction();
|
|
2918
|
+
}
|
|
2919
|
+
}]);
|
|
2920
|
+
return FableServiceTemplate;
|
|
2921
|
+
}(libFableServiceBase);
|
|
2922
|
+
module.exports = FableServiceTemplate;
|
|
2923
|
+
}, {
|
|
2924
|
+
"./Fable-ServiceProviderBase.js": 41
|
|
2925
|
+
}],
|
|
2926
|
+
39: [function (require, module, exports) {
|
|
2927
|
+
var libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2928
|
+
|
|
2929
|
+
// TODO: These are still pretty big -- consider the smaller polyfills
|
|
2930
|
+
var libAsyncWaterfall = require('async.waterfall');
|
|
2931
|
+
var libAsyncEachLimit = require('async.eachlimit');
|
|
2932
|
+
var FableServiceUtility = /*#__PURE__*/function (_libFableServiceBase3) {
|
|
2933
|
+
_inherits(FableServiceUtility, _libFableServiceBase3);
|
|
2934
|
+
var _super5 = _createSuper(FableServiceUtility);
|
|
2935
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2936
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2937
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2938
|
+
//
|
|
2939
|
+
// NOTE: This does not implement underscore escape expressions
|
|
2940
|
+
// NOTE: This does not implement underscore magic browser variable assignment
|
|
2941
|
+
//
|
|
2942
|
+
// This is an implementation of that.
|
|
2943
|
+
// TODO: Make this use precedent, add configuration, add debugging.
|
|
2944
|
+
function FableServiceUtility(pFable, pOptions, pServiceHash) {
|
|
2945
|
+
var _this7;
|
|
2946
|
+
_classCallCheck(this, FableServiceUtility);
|
|
2947
|
+
_this7 = _super5.call(this, pFable, pOptions, pServiceHash);
|
|
2948
|
+
_this7.templates = {};
|
|
2949
|
+
|
|
2950
|
+
// These two functions are used extensively throughout
|
|
2951
|
+
_this7.waterfall = libAsyncWaterfall;
|
|
2952
|
+
_this7.eachLimit = libAsyncEachLimit;
|
|
2953
|
+
return _this7;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
2957
|
+
// Now that es6 gives us this, use the native thingy.
|
|
2958
|
+
_createClass(FableServiceUtility, [{
|
|
2959
|
+
key: "extend",
|
|
2960
|
+
value: function extend(pDestinationObject) {
|
|
2961
|
+
for (var _len = arguments.length, pSourceObjects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2962
|
+
pSourceObjects[_key - 1] = arguments[_key];
|
|
2963
|
+
}
|
|
2964
|
+
return Object.assign.apply(Object, [pDestinationObject].concat(pSourceObjects));
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2968
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2969
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2970
|
+
}, {
|
|
2971
|
+
key: "template",
|
|
2972
|
+
value: function template(pTemplateText, pData) {
|
|
2973
|
+
var tmpTemplate = this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Template');
|
|
2974
|
+
return tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
// Build a template function from a template hash, and, register it with the service provider
|
|
2978
|
+
}, {
|
|
2979
|
+
key: "buildHashedTemplate",
|
|
2980
|
+
value: function buildHashedTemplate(pTemplateHash, pTemplateText, pData) {
|
|
2981
|
+
var tmpTemplate = this.fable.serviceManager.instantiateServiceProvider('Template', {}, pTemplateHash);
|
|
2982
|
+
this.templates[pTemplateHash] = tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2983
|
+
return this.templates[pTemplateHash];
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
// This is a safe, modern version of chunk from underscore
|
|
2987
|
+
// Algorithm pulled from a mix of these two polyfills:
|
|
2988
|
+
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk
|
|
2989
|
+
// https://youmightnotneed.com/lodash
|
|
2990
|
+
// This implementation was most tolerant in browsers. Uglify can fix the rest.
|
|
2991
|
+
}, {
|
|
2992
|
+
key: "chunk",
|
|
2993
|
+
value: function chunk(pInput, pChunkSize, pChunkCache) {
|
|
2994
|
+
var tmpInputArray = _toConsumableArray(pInput);
|
|
2995
|
+
// Note lodash defaults to 1, underscore defaults to 0
|
|
2996
|
+
var tmpChunkSize = typeof pChunkSize == 'number' ? pChunkSize : 0;
|
|
2997
|
+
var tmpChunkCache = typeof pChunkCache != 'undefined' ? pChunkCache : [];
|
|
2998
|
+
if (tmpChunkSize <= 0) {
|
|
2999
|
+
return tmpChunkCache;
|
|
3000
|
+
}
|
|
3001
|
+
while (tmpInputArray.length) {
|
|
3002
|
+
tmpChunkCache.push(tmpInputArray.splice(0, tmpChunkSize));
|
|
3003
|
+
}
|
|
3004
|
+
return tmpChunkCache;
|
|
3005
|
+
}
|
|
3006
|
+
}]);
|
|
3007
|
+
return FableServiceUtility;
|
|
3008
|
+
}(libFableServiceBase);
|
|
3009
|
+
module.exports = FableServiceUtility;
|
|
3010
|
+
}, {
|
|
3011
|
+
"./Fable-ServiceProviderBase.js": 41,
|
|
3012
|
+
"async.eachlimit": 1,
|
|
3013
|
+
"async.waterfall": 15
|
|
3014
|
+
}],
|
|
3015
|
+
40: [function (require, module, exports) {
|
|
3016
|
+
/**
|
|
3017
|
+
* Fable Application Services Management
|
|
3018
|
+
* @license MIT
|
|
3019
|
+
* @author <steven@velozo.com>
|
|
3020
|
+
*/
|
|
3021
|
+
|
|
3022
|
+
var libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
3023
|
+
var FableService = /*#__PURE__*/function () {
|
|
3024
|
+
function FableService(pFable) {
|
|
3025
|
+
_classCallCheck(this, FableService);
|
|
3026
|
+
this.fable = pFable;
|
|
3027
|
+
this.serviceTypes = [];
|
|
3028
|
+
|
|
3029
|
+
// A map of instantiated services
|
|
3030
|
+
this.services = {};
|
|
3031
|
+
|
|
3032
|
+
// A map of the default instantiated service by type
|
|
3033
|
+
this.defaultServices = {};
|
|
3034
|
+
|
|
3035
|
+
// A map of class constructors for services
|
|
3036
|
+
this.serviceClasses = {};
|
|
3037
|
+
}
|
|
3038
|
+
_createClass(FableService, [{
|
|
3039
|
+
key: "addServiceType",
|
|
3040
|
+
value: function addServiceType(pServiceType, pServiceClass) {
|
|
3041
|
+
// Add the type to the list of types
|
|
3042
|
+
this.serviceTypes.push(pServiceType);
|
|
3043
|
+
|
|
3044
|
+
// Add the container for instantiated services to go in
|
|
3045
|
+
this.services[pServiceType] = {};
|
|
3046
|
+
if (typeof pServiceClass == 'function' && pServiceClass.prototype instanceof libFableServiceBase) {
|
|
3047
|
+
// Add the class to the list of classes
|
|
3048
|
+
this.serviceClasses[pServiceType] = pServiceClass;
|
|
3049
|
+
} else {
|
|
3050
|
+
// Add the base class to the list of classes
|
|
3051
|
+
this.serviceClasses[pServiceType] = libFableServiceBase;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
}, {
|
|
3055
|
+
key: "instantiateServiceProvider",
|
|
3056
|
+
value: function instantiateServiceProvider(pServiceType, pOptions, pCustomServiceHash) {
|
|
3057
|
+
// Instantiate the service
|
|
3058
|
+
var tmpService = this.instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash);
|
|
3059
|
+
|
|
3060
|
+
// Add the service to the service map
|
|
3061
|
+
this.services[pServiceType][tmpService.Hash] = tmpService;
|
|
3062
|
+
|
|
3063
|
+
// If this is the first service of this type, make it the default
|
|
3064
|
+
if (!this.defaultServices.hasOwnProperty(pServiceType)) {
|
|
3065
|
+
this.defaultServices[pServiceType] = tmpService;
|
|
3066
|
+
}
|
|
3067
|
+
return tmpService;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// Create a service provider but don't register it to live forever in fable.services
|
|
3071
|
+
}, {
|
|
3072
|
+
key: "instantiateServiceProviderWithoutRegistration",
|
|
3073
|
+
value: function instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash) {
|
|
3074
|
+
// Instantiate the service
|
|
3075
|
+
var tmpService = new this.serviceClasses[pServiceType](this.fable, pOptions, pCustomServiceHash);
|
|
3076
|
+
return tmpService;
|
|
3077
|
+
}
|
|
3078
|
+
}, {
|
|
3079
|
+
key: "setDefaultServiceInstantiation",
|
|
3080
|
+
value: function setDefaultServiceInstantiation(pServiceType, pServiceHash) {
|
|
3081
|
+
if (this.services[pServiceType].hasOwnProperty(pServiceHash)) {
|
|
3082
|
+
this.defaultServices[pServiceType] = this.services[pServiceType][pServiceHash];
|
|
3083
|
+
return true;
|
|
3084
|
+
}
|
|
3085
|
+
return false;
|
|
3086
|
+
}
|
|
3087
|
+
}]);
|
|
3088
|
+
return FableService;
|
|
3089
|
+
}();
|
|
3090
|
+
module.exports = FableService;
|
|
3091
|
+
module.exports.ServiceProviderBase = libFableServiceBase;
|
|
3092
|
+
}, {
|
|
3093
|
+
"./Fable-ServiceProviderBase.js": 41
|
|
3094
|
+
}],
|
|
3095
|
+
41: [function (require, module, exports) {
|
|
3096
|
+
/**
|
|
3097
|
+
* Fable Service Base
|
|
3098
|
+
* @license MIT
|
|
3099
|
+
* @author <steven@velozo.com>
|
|
3100
|
+
*/
|
|
3101
|
+
var FableServiceProviderBase = /*#__PURE__*/_createClass(function FableServiceProviderBase(pFable, pOptions, pServiceHash) {
|
|
3102
|
+
_classCallCheck(this, FableServiceProviderBase);
|
|
3103
|
+
this.fable = pFable;
|
|
3104
|
+
this.options = _typeof(pOptions) === 'object' ? pOptions : {};
|
|
3105
|
+
this.serviceType = 'Unknown';
|
|
3106
|
+
this.UUID = pFable.getUUID();
|
|
3107
|
+
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID);
|
|
3108
|
+
});
|
|
3109
|
+
module.exports = FableServiceProviderBase;
|
|
3110
|
+
}, {}],
|
|
3111
|
+
42: [function (require, module, exports) {
|
|
3112
|
+
/**
|
|
3113
|
+
* Fable Application Services Support Library
|
|
3114
|
+
* @license MIT
|
|
3115
|
+
* @author <steven@velozo.com>
|
|
3116
|
+
*/
|
|
3117
|
+
var libFableSettings = require('fable-settings');
|
|
3118
|
+
var libFableUUID = require('fable-uuid');
|
|
3119
|
+
var libFableLog = require('fable-log');
|
|
3120
|
+
var libFableServiceManager = require('./Fable-ServiceManager.js');
|
|
3121
|
+
var libFableServiceDataArithmatic = require('./Fable-Service-DataArithmatic.js');
|
|
3122
|
+
var libFableServiceTemplate = require('./Fable-Service-Template.js');
|
|
3123
|
+
var libFableServiceUtility = require('./Fable-Service-Utility.js');
|
|
3124
|
+
var libFableOperation = require('./Fable-Operation.js');
|
|
3125
|
+
var Fable = /*#__PURE__*/function () {
|
|
3126
|
+
function Fable(pSettings) {
|
|
3127
|
+
_classCallCheck(this, Fable);
|
|
3128
|
+
var tmpSettings = new libFableSettings(pSettings);
|
|
3129
|
+
this.settingsManager = tmpSettings;
|
|
3130
|
+
|
|
3131
|
+
// Instantiate the UUID generator
|
|
3132
|
+
this.libUUID = new libFableUUID(this.settingsManager.settings);
|
|
3133
|
+
this.log = new libFableLog(this.settingsManager.settings);
|
|
3134
|
+
this.log.initialize();
|
|
3135
|
+
|
|
3136
|
+
// Built-in dependencies
|
|
3137
|
+
this.Dependencies = {
|
|
3138
|
+
precedent: libFableSettings.precedent
|
|
3139
|
+
};
|
|
3140
|
+
|
|
3141
|
+
// Location for Operation state
|
|
3142
|
+
this.Operations = {};
|
|
3143
|
+
this.serviceManager = new libFableServiceManager(this);
|
|
3144
|
+
|
|
3145
|
+
// Initialize and instantiate the default baked-in Data Arithmatic service
|
|
3146
|
+
this.serviceManager.addServiceType('DataArithmatic', libFableServiceDataArithmatic);
|
|
3147
|
+
this.fable.serviceManager.instantiateServiceProvider('DataArithmatic', {}, 'Default-Service-DataArithmatic');
|
|
3148
|
+
// This service is passing through the data arithmatic library
|
|
3149
|
+
this.DataArithmatic = this.serviceManager.defaultServices.DataArithmatic._DataArithmaticLibrary;
|
|
3150
|
+
|
|
3151
|
+
// Initialize the template service
|
|
3152
|
+
this.serviceManager.addServiceType('Template', libFableServiceTemplate);
|
|
3153
|
+
|
|
3154
|
+
// Initialize and instantiate the default baked-in Utility service
|
|
3155
|
+
this.serviceManager.addServiceType('Utility', libFableServiceUtility);
|
|
3156
|
+
this.fable.serviceManager.instantiateServiceProvider('Utility', {}, 'Default-Service-Utility');
|
|
3157
|
+
this.Utility = this.serviceManager.defaultServices.Utility;
|
|
3158
|
+
this.services = this.serviceManager.services;
|
|
3159
|
+
this.defaultServices = this.serviceManager.defaultServices;
|
|
3160
|
+
}
|
|
3161
|
+
_createClass(Fable, [{
|
|
3162
|
+
key: "settings",
|
|
3163
|
+
get: function get() {
|
|
3164
|
+
return this.settingsManager.settings;
|
|
3165
|
+
}
|
|
3166
|
+
}, {
|
|
3167
|
+
key: "fable",
|
|
3168
|
+
get: function get() {
|
|
3169
|
+
return this;
|
|
3170
|
+
}
|
|
3171
|
+
}, {
|
|
3172
|
+
key: "getUUID",
|
|
3173
|
+
value: function getUUID() {
|
|
3174
|
+
return this.libUUID.getUUID();
|
|
3175
|
+
}
|
|
3176
|
+
}, {
|
|
3177
|
+
key: "createOperation",
|
|
3178
|
+
value: function createOperation(pOperationName, pOperationHash) {
|
|
3179
|
+
var tmpOperation = new libFableOperation(this, pOperationName, pOperationHash);
|
|
3180
|
+
if (this.Operations.hasOwnProperty(tmpOperation.Hash)) {
|
|
3181
|
+
// Uh Oh ...... Operation Hash Collision!
|
|
3182
|
+
// TODO: What to do?!
|
|
3183
|
+
} else {
|
|
3184
|
+
this.Operations[tmpOperation.Hash] = tmpOperation;
|
|
3185
|
+
}
|
|
3186
|
+
return tmpOperation;
|
|
3187
|
+
}
|
|
3188
|
+
}, {
|
|
3189
|
+
key: "getOperation",
|
|
3190
|
+
value: function getOperation(pOperationHash) {
|
|
3191
|
+
if (!this.Operations.hasOwnProperty(pOperationHash)) {
|
|
3192
|
+
return false;
|
|
3193
|
+
} else {
|
|
3194
|
+
return this.Operations[pOperationHash];
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
}]);
|
|
3198
|
+
return Fable;
|
|
3199
|
+
}(); // This is for backwards compatibility
|
|
3200
|
+
function autoConstruct(pSettings) {
|
|
3201
|
+
return new Fable(pSettings);
|
|
3202
|
+
}
|
|
3203
|
+
module.exports = Fable;
|
|
3204
|
+
module.exports["new"] = autoConstruct;
|
|
3205
|
+
module.exports.LogProviderBase = libFableLog.LogProviderBase;
|
|
3206
|
+
module.exports.ServiceProviderBase = libFableServiceManager.ServiceProviderBase;
|
|
3207
|
+
module.exports.precedent = libFableSettings.precedent;
|
|
3208
|
+
}, {
|
|
3209
|
+
"./Fable-Operation.js": 36,
|
|
3210
|
+
"./Fable-Service-DataArithmatic.js": 37,
|
|
3211
|
+
"./Fable-Service-Template.js": 38,
|
|
3212
|
+
"./Fable-Service-Utility.js": 39,
|
|
3213
|
+
"./Fable-ServiceManager.js": 40,
|
|
3214
|
+
"fable-log": 23,
|
|
3215
|
+
"fable-settings": 26,
|
|
3216
|
+
"fable-uuid": 28
|
|
3217
|
+
}]
|
|
3218
|
+
}, {}, [35])(35);
|
|
3219
|
+
});
|