fable 3.0.10 → 3.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fable.js +112 -6
- package/dist/fable.min.js +6 -6
- package/dist/fable.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Fable-Operation.js +119 -0
- package/source/Fable-Utility.js +1 -0
- package/source/Fable.js +36 -1
- package/test/FableOperations_tests.js +66 -0
- package/test/FableUtility_tests.js +3 -2
- package/test/Fable_tests.js +3 -3
package/dist/fable.js
CHANGED
|
@@ -1921,9 +1921,90 @@
|
|
|
1921
1921
|
}
|
|
1922
1922
|
module.exports = libNPMModuleWrapper;
|
|
1923
1923
|
}, {
|
|
1924
|
-
"./Fable.js":
|
|
1924
|
+
"./Fable.js": 36
|
|
1925
1925
|
}],
|
|
1926
1926
|
33: [function (require, module, exports) {
|
|
1927
|
+
const _OperationStatePrototype = JSON.stringify({
|
|
1928
|
+
"Metadata": {
|
|
1929
|
+
"GUID": false,
|
|
1930
|
+
"Hash": false,
|
|
1931
|
+
"Title": "",
|
|
1932
|
+
"Summary": "",
|
|
1933
|
+
"Version": 0
|
|
1934
|
+
},
|
|
1935
|
+
"Status": {
|
|
1936
|
+
"Completed": false,
|
|
1937
|
+
"CompletionProgress": 0,
|
|
1938
|
+
"CompletionTimeElapsed": 0,
|
|
1939
|
+
"Steps": 1,
|
|
1940
|
+
"StepsCompleted": 0,
|
|
1941
|
+
"StartTime": 0,
|
|
1942
|
+
"EndTime": 0
|
|
1943
|
+
},
|
|
1944
|
+
"Errors": [],
|
|
1945
|
+
"Log": []
|
|
1946
|
+
});
|
|
1947
|
+
class FableOperation {
|
|
1948
|
+
constructor(pFable, pOperationName, pOperationHash) {
|
|
1949
|
+
this.fable = pFable;
|
|
1950
|
+
this.state = JSON.parse(_OperationStatePrototype);
|
|
1951
|
+
this.state.Metadata.GUID = this.fable.getUUID();
|
|
1952
|
+
this.state.Metadata.Hash = this.state.GUID;
|
|
1953
|
+
if (typeof pOperationHash == 'string') {
|
|
1954
|
+
this.state.Metadata.Hash = pOperationHash;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
get GUID() {
|
|
1958
|
+
return this.state.Metadata.GUID;
|
|
1959
|
+
}
|
|
1960
|
+
get Hash() {
|
|
1961
|
+
return this.state.Metadata.Hash;
|
|
1962
|
+
}
|
|
1963
|
+
get log() {
|
|
1964
|
+
return this;
|
|
1965
|
+
}
|
|
1966
|
+
writeOperationLog(pLogLevel, pLogText, pLogObject) {
|
|
1967
|
+
this.state.Log.push(`${new Date().toUTCString()} [${pLogLevel}]: ${pLogText}`);
|
|
1968
|
+
if (typeof pLogObject == 'object') {
|
|
1969
|
+
this.state.Log.push(JSON.stringify(pLogObject));
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
writeOperationErrors(pLogText, pLogObject) {
|
|
1973
|
+
this.state.Errors.push(`${pLogText}`);
|
|
1974
|
+
if (typeof pLogObject == 'object') {
|
|
1975
|
+
this.state.Errors.push(JSON.stringify(pLogObject));
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
trace(pLogText, pLogObject) {
|
|
1979
|
+
this.writeOperationLog('TRACE', pLogText, pLogObject);
|
|
1980
|
+
this.fable.log.trace(pLogText, pLogObject);
|
|
1981
|
+
}
|
|
1982
|
+
debug(pLogText, pLogObject) {
|
|
1983
|
+
this.writeOperationLog('DEBUG', pLogText, pLogObject);
|
|
1984
|
+
this.fable.log.debug(pLogText, pLogObject);
|
|
1985
|
+
}
|
|
1986
|
+
info(pLogText, pLogObject) {
|
|
1987
|
+
this.writeOperationLog('INFO', pLogText, pLogObject);
|
|
1988
|
+
this.fable.log.info(pLogText, pLogObject);
|
|
1989
|
+
}
|
|
1990
|
+
warn(pLogText, pLogObject) {
|
|
1991
|
+
this.writeOperationLog('WARN', pLogText, pLogObject);
|
|
1992
|
+
this.fable.log.warn(pLogText, pLogObject);
|
|
1993
|
+
}
|
|
1994
|
+
error(pLogText, pLogObject) {
|
|
1995
|
+
this.writeOperationLog('ERROR', pLogText, pLogObject);
|
|
1996
|
+
this.writeOperationErrors(pLogText, pLogObject);
|
|
1997
|
+
this.fable.log.error(pLogText, pLogObject);
|
|
1998
|
+
}
|
|
1999
|
+
fatal(pLogText, pLogObject) {
|
|
2000
|
+
this.writeOperationLog('FATAL', pLogText, pLogObject);
|
|
2001
|
+
this.writeOperationErrors(pLogText, pLogObject);
|
|
2002
|
+
this.fable.log.fatal(pLogText, pLogObject);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
module.exports = FableOperation;
|
|
2006
|
+
}, {}],
|
|
2007
|
+
34: [function (require, module, exports) {
|
|
1927
2008
|
class FableUtility {
|
|
1928
2009
|
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
1929
2010
|
// string-based template with code snippets into simple executable pieces,
|
|
@@ -2009,8 +2090,9 @@
|
|
|
2009
2090
|
}
|
|
2010
2091
|
module.exports = FableUtility;
|
|
2011
2092
|
}, {}],
|
|
2012
|
-
|
|
2093
|
+
35: [function (require, module, exports) {
|
|
2013
2094
|
const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
|
|
2095
|
+
// TODO: These are still pretty big -- consider the smaller polyfills
|
|
2014
2096
|
const libAsyncWaterfall = require('async/waterfall');
|
|
2015
2097
|
const libAsyncEachLimit = require('async/eachLimit');
|
|
2016
2098
|
class FableUtility {
|
|
@@ -2057,11 +2139,11 @@
|
|
|
2057
2139
|
}
|
|
2058
2140
|
module.exports = FableUtility;
|
|
2059
2141
|
}, {
|
|
2060
|
-
"./Fable-Utility-Template.js":
|
|
2142
|
+
"./Fable-Utility-Template.js": 34,
|
|
2061
2143
|
"async/eachLimit": 2,
|
|
2062
2144
|
"async/waterfall": 16
|
|
2063
2145
|
}],
|
|
2064
|
-
|
|
2146
|
+
36: [function (require, module, exports) {
|
|
2065
2147
|
/**
|
|
2066
2148
|
* Fable Application Services Support Library
|
|
2067
2149
|
* @license MIT
|
|
@@ -2071,6 +2153,7 @@
|
|
|
2071
2153
|
const libFableUUID = require('fable-uuid');
|
|
2072
2154
|
const libFableLog = require('fable-log');
|
|
2073
2155
|
const libFableUtility = require('./Fable-Utility.js');
|
|
2156
|
+
const libFableOperation = require('./Fable-Operation.js');
|
|
2074
2157
|
class Fable {
|
|
2075
2158
|
constructor(pSettings) {
|
|
2076
2159
|
let tmpSettings = new libFableSettings(pSettings);
|
|
@@ -2080,12 +2163,17 @@
|
|
|
2080
2163
|
this.libUUID = new libFableUUID(this.settingsManager.settings);
|
|
2081
2164
|
this.log = new libFableLog(this.settingsManager.settings);
|
|
2082
2165
|
this.log.initialize();
|
|
2166
|
+
|
|
2167
|
+
// Built-in utility belt functions
|
|
2083
2168
|
this.Utility = new libFableUtility(this);
|
|
2084
2169
|
|
|
2085
|
-
// Built-in dependencies
|
|
2170
|
+
// Built-in dependencies
|
|
2086
2171
|
this.Dependencies = {
|
|
2087
2172
|
precedent: libFableSettings.precedent
|
|
2088
2173
|
};
|
|
2174
|
+
|
|
2175
|
+
// Location for Operation state
|
|
2176
|
+
this.Operations = {};
|
|
2089
2177
|
}
|
|
2090
2178
|
get settings() {
|
|
2091
2179
|
return this.settingsManager.settings;
|
|
@@ -2096,6 +2184,23 @@
|
|
|
2096
2184
|
getUUID() {
|
|
2097
2185
|
return this.libUUID.getUUID();
|
|
2098
2186
|
}
|
|
2187
|
+
createOperation(pOperationName, pOperationHash) {
|
|
2188
|
+
let tmpOperation = new libFableOperation(this, pOperationName, pOperationHash);
|
|
2189
|
+
if (this.Operations.hasOwnProperty(tmpOperation.Hash)) {
|
|
2190
|
+
// Uh Oh ...... Operation Hash Collision!
|
|
2191
|
+
// TODO: What to do?!
|
|
2192
|
+
} else {
|
|
2193
|
+
this.Operations[tmpOperation.Hash] = tmpOperation;
|
|
2194
|
+
}
|
|
2195
|
+
return tmpOperation;
|
|
2196
|
+
}
|
|
2197
|
+
getOperation(pOperationHash) {
|
|
2198
|
+
if (!this.Operations.hasOwnProperty(pOperationHash)) {
|
|
2199
|
+
return false;
|
|
2200
|
+
} else {
|
|
2201
|
+
return this.pOperations[pOperationHash];
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2099
2204
|
}
|
|
2100
2205
|
|
|
2101
2206
|
// This is for backwards compatibility
|
|
@@ -2107,7 +2212,8 @@
|
|
|
2107
2212
|
module.exports.LogProviderBase = libFableLog.LogProviderBase;
|
|
2108
2213
|
module.exports.precedent = libFableSettings.precedent;
|
|
2109
2214
|
}, {
|
|
2110
|
-
"./Fable-
|
|
2215
|
+
"./Fable-Operation.js": 33,
|
|
2216
|
+
"./Fable-Utility.js": 35,
|
|
2111
2217
|
"fable-log": 21,
|
|
2112
2218
|
"fable-settings": 24,
|
|
2113
2219
|
"fable-uuid": 26
|
package/dist/fable.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Fable=t()}}((function(){return function t(e,r,n){function i(
|
|
1
|
+
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Fable=t()}}((function(){return function t(e,r,n){function i(o,a){if(!r[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};e[o][0].call(c.exports,(function(t){return i(e[o][1][t]||t)}),c,c.exports,t,e,r,n)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){if((0,s.isAsync)(t))return function(...e){const r=e.pop();return a(t.apply(this,e),r)};return(0,n.default)((function(e,r){var n;try{n=t.apply(this,e)}catch(t){return r(t)}if(n&&"function"==typeof n.then)return a(n,r);r(null,n)}))};var n=o(t("./internal/initialParams.js")),i=o(t("./internal/setImmediate.js")),s=t("./internal/wrapAsync.js");function o(t){return t&&t.__esModule?t:{default:t}}function a(t,e){return t.then((t=>{u(e,null,t)}),(t=>{u(e,t&&t.message?t:new Error(t))}))}function u(t,e,r){try{t(e,r)}catch(t){(0,i.default)((t=>{throw t}),t)}}e.exports=r.default},{"./internal/initialParams.js":8,"./internal/setImmediate.js":13,"./internal/wrapAsync.js":15}],2:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=a(t("./internal/eachOfLimit.js")),i=a(t("./internal/withoutIndex.js")),s=a(t("./internal/wrapAsync.js")),o=a(t("./internal/awaitify.js"));function a(t){return t&&t.__esModule?t:{default:t}}r.default=(0,o.default)((function(t,e,r,o){return(0,n.default)(e)(t,(0,i.default)((0,s.default)(r)),o)}),4),e.exports=r.default},{"./internal/awaitify.js":4,"./internal/eachOfLimit.js":6,"./internal/withoutIndex.js":14,"./internal/wrapAsync.js":15}],3:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e,r,n){let i=!1,o=!1,a=!1,u=0,l=0;function c(){u>=e||a||i||(a=!0,t.next().then((({value:t,done:e})=>{if(!o&&!i){if(a=!1,e)return i=!0,void(u<=0&&n(null));u++,r(t,l,f),l++,c()}})).catch(h))}function f(t,e){if(u-=1,!o)return t?h(t):!1===t?(i=!0,void(o=!0)):e===s.default||i&&u<=0?(i=!0,n(null)):void c()}function h(t){o||(a=!1,i=!0,n(t))}c()};var n,i=t("./breakLoop.js"),s=(n=i)&&n.__esModule?n:{default:n};e.exports=r.default},{"./breakLoop.js":5}],4:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t,e=t.length){if(!e)throw new Error("arity is undefined");return function(...r){return"function"==typeof r[e-1]?t.apply(this,r):new Promise(((n,i)=>{r[e-1]=(t,...e)=>{if(t)return i(t);n(e.length>1?e:e[0])},t.apply(this,r)}))}},e.exports=r.default},{}],5:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.default={},e.exports=r.default},{}],6:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=l(t("./once.js")),i=l(t("./iterator.js")),s=l(t("./onlyOnce.js")),o=t("./wrapAsync.js"),a=l(t("./asyncEachOfLimit.js")),u=l(t("./breakLoop.js"));function l(t){return t&&t.__esModule?t:{default:t}}r.default=t=>(e,r,l)=>{if(l=(0,n.default)(l),t<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!e)return l(null);if((0,o.isAsyncGenerator)(e))return(0,a.default)(e,t,r,l);if((0,o.isAsyncIterable)(e))return(0,a.default)(e[Symbol.asyncIterator](),t,r,l);var c=(0,i.default)(e),f=!1,h=!1,p=0,d=!1;function g(t,e){if(!h)if(p-=1,t)f=!0,l(t);else if(!1===t)f=!0,h=!0;else{if(e===u.default||f&&p<=0)return f=!0,l(null);d||m()}}function m(){for(d=!0;p<t&&!f;){var e=c();if(null===e)return f=!0,void(p<=0&&l(null));p+=1,r(e.value,e.key,(0,s.default)(g))}d=!1}m()},e.exports=r.default},{"./asyncEachOfLimit.js":3,"./breakLoop.js":5,"./iterator.js":10,"./once.js":11,"./onlyOnce.js":12,"./wrapAsync.js":15}],7:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return t[Symbol.iterator]&&t[Symbol.iterator]()},e.exports=r.default},{}],8:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return function(...e){var r=e.pop();return t.call(this,e,r)}},e.exports=r.default},{}],9:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return t&&"number"==typeof t.length&&t.length>=0&&t.length%1==0},e.exports=r.default},{}],10:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){if((0,n.default)(t))return function(t){var e=-1,r=t.length;return function(){return++e<r?{value:t[e],key:e}:null}}(t);var e=(0,i.default)(t);return e?function(t){var e=-1;return function(){var r=t.next();return r.done?null:(e++,{value:r.value,key:e})}}(e):(r=t,s=r?Object.keys(r):[],o=-1,a=s.length,function t(){var e=s[++o];return"__proto__"===e?t():o<a?{value:r[e],key:e}:null});var r,s,o,a};var n=s(t("./isArrayLike.js")),i=s(t("./getIterator.js"));function s(t){return t&&t.__esModule?t:{default:t}}e.exports=r.default},{"./getIterator.js":7,"./isArrayLike.js":9}],11:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){function e(...e){if(null!==t){var r=t;t=null,r.apply(this,e)}}return Object.assign(e,t),e},e.exports=r.default},{}],12:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return function(...e){if(null===t)throw new Error("Callback was already called.");var r=t;t=null,r.apply(this,e)}},e.exports=r.default},{}],13:[function(t,e,r){(function(t,e){(function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.fallback=a,r.wrap=u;var n,i=r.hasQueueMicrotask="function"==typeof queueMicrotask&&queueMicrotask,s=r.hasSetImmediate="function"==typeof e&&e,o=r.hasNextTick="object"==typeof t&&"function"==typeof t.nextTick;function a(t){setTimeout(t,0)}function u(t){return(e,...r)=>t((()=>e(...r)))}n=i?queueMicrotask:s?e:o?t.nextTick:a,r.default=u(n)}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:30,timers:31}],14:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(t){return(e,r,n)=>t(e,n)},e.exports=r.default},{}],15:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isAsyncIterable=r.isAsyncGenerator=r.isAsync=void 0;var n,i=t("../asyncify.js"),s=(n=i)&&n.__esModule?n:{default:n};function o(t){return"AsyncFunction"===t[Symbol.toStringTag]}r.default=function(t){if("function"!=typeof t)throw new Error("expected a function");return o(t)?(0,s.default)(t):t},r.isAsync=o,r.isAsyncGenerator=function(t){return"AsyncGenerator"===t[Symbol.toStringTag]},r.isAsyncIterable=function(t){return"function"==typeof t[Symbol.asyncIterator]}},{"../asyncify.js":1}],16:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=a(t("./internal/once.js")),i=a(t("./internal/onlyOnce.js")),s=a(t("./internal/wrapAsync.js")),o=a(t("./internal/awaitify.js"));function a(t){return t&&t.__esModule?t:{default:t}}r.default=(0,o.default)((function(t,e){if(e=(0,n.default)(e),!Array.isArray(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var r=0;function o(e){(0,s.default)(t[r++])(...e,(0,i.default)(a))}function a(n,...i){if(!1!==n)return n||r===t.length?e(n,...i):void o(i)}o([])})),e.exports=r.default},{"./internal/awaitify.js":4,"./internal/once.js":11,"./internal/onlyOnce.js":12,"./internal/wrapAsync.js":15}],17:[function(t,e,r){e.exports=
|
|
2
2
|
/**
|
|
3
3
|
* Base Logger Class
|
|
4
4
|
*
|
|
@@ -23,7 +23,7 @@ getDefaultProviders=()=>{let e={};return e.console=t("./Fable-Log-Logger-Console
|
|
|
23
23
|
* @author Steven Velozo <steven@velozo.com>
|
|
24
24
|
* @module Fable Logger
|
|
25
25
|
*/
|
|
26
|
-
class n{constructor(e,r){let n="object"==typeof e?e:{};this._Settings=n,this._Providers=t("./Fable-Log-DefaultProviders-Node.js"),this._StreamDefinitions=n.hasOwnProperty("LogStreams")?n.LogStreams:t("./Fable-Log-DefaultStreams.json"),this.logStreams=[],this.logProviders={},this.activeLogStreams={},this.logStreamsTrace=[],this.logStreamsDebug=[],this.logStreamsInfo=[],this.logStreamsWarn=[],this.logStreamsError=[],this.logStreamsFatal=[],this.datumDecorator=t=>t,this.uuid="string"==typeof n.Product?n.Product:"Default"}addLogger(t,e){if(this.activeLogStreams.hasOwnProperty(t.loggerUUID))return!1;switch(this.logStreams.push(t),this.activeLogStreams[t.loggerUUID]=!0,e){case"trace":this.logStreamsTrace.push(t);case"debug":this.logStreamsDebug.push(t);case"info":this.logStreamsInfo.push(t);case"warn":this.logStreamsWarn.push(t);case"error":this.logStreamsError.push(t);case"fatal":this.logStreamsFatal.push(t)}return!0}setDatumDecorator(t){this.datumDecorator="function"==typeof t?t:t=>t}trace(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsTrace.length;e++)this.logStreamsTrace[e].trace(t,r)}debug(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsDebug.length;e++)this.logStreamsDebug[e].debug(t,r)}info(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsInfo.length;e++)this.logStreamsInfo[e].info(t,r)}warn(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsWarn.length;e++)this.logStreamsWarn[e].warn(t,r)}error(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsError.length;e++)this.logStreamsError[e].error(t,r)}fatal(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsFatal.length;e++)this.logStreamsFatal[e].fatal(t,r)}initialize(){for(let t=0;t<this._StreamDefinitions.length;t++){let e=Object.assign({loggertype:"default",streamtype:"console",level:"info"},this._StreamDefinitions[t]);this._Providers.hasOwnProperty(e.loggertype)?this.addLogger(new this._Providers[e.loggertype](e,this),e.level):console.log(`Error initializing log stream: bad loggertype in stream definition ${JSON.stringify(e)}`)}for(let t=0;t<this.logStreams.length;t++)this.logStreams[t].initialize()}logTime(t,e){let r=void 0!==t?t:"Time",n=new Date;this.info(`${r} ${n} (epoch ${+n})`,e)}getTimeStamp(){return+new Date}getTimeDelta(t){return+new Date-t}logTimeDelta(t,e,r){let n=void 0!==e?e:"Time Measurement",i=+new Date;this.info(`${n} logged at (epoch ${+i}) took (${t}ms)`,r)}logTimeDeltaHuman(t,e,r){let n=void 0!==e?e:"Time Measurement",i=+new Date,
|
|
26
|
+
class n{constructor(e,r){let n="object"==typeof e?e:{};this._Settings=n,this._Providers=t("./Fable-Log-DefaultProviders-Node.js"),this._StreamDefinitions=n.hasOwnProperty("LogStreams")?n.LogStreams:t("./Fable-Log-DefaultStreams.json"),this.logStreams=[],this.logProviders={},this.activeLogStreams={},this.logStreamsTrace=[],this.logStreamsDebug=[],this.logStreamsInfo=[],this.logStreamsWarn=[],this.logStreamsError=[],this.logStreamsFatal=[],this.datumDecorator=t=>t,this.uuid="string"==typeof n.Product?n.Product:"Default"}addLogger(t,e){if(this.activeLogStreams.hasOwnProperty(t.loggerUUID))return!1;switch(this.logStreams.push(t),this.activeLogStreams[t.loggerUUID]=!0,e){case"trace":this.logStreamsTrace.push(t);case"debug":this.logStreamsDebug.push(t);case"info":this.logStreamsInfo.push(t);case"warn":this.logStreamsWarn.push(t);case"error":this.logStreamsError.push(t);case"fatal":this.logStreamsFatal.push(t)}return!0}setDatumDecorator(t){this.datumDecorator="function"==typeof t?t:t=>t}trace(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsTrace.length;e++)this.logStreamsTrace[e].trace(t,r)}debug(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsDebug.length;e++)this.logStreamsDebug[e].debug(t,r)}info(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsInfo.length;e++)this.logStreamsInfo[e].info(t,r)}warn(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsWarn.length;e++)this.logStreamsWarn[e].warn(t,r)}error(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsError.length;e++)this.logStreamsError[e].error(t,r)}fatal(t,e){const r=this.datumDecorator(e);for(let e=0;e<this.logStreamsFatal.length;e++)this.logStreamsFatal[e].fatal(t,r)}initialize(){for(let t=0;t<this._StreamDefinitions.length;t++){let e=Object.assign({loggertype:"default",streamtype:"console",level:"info"},this._StreamDefinitions[t]);this._Providers.hasOwnProperty(e.loggertype)?this.addLogger(new this._Providers[e.loggertype](e,this),e.level):console.log(`Error initializing log stream: bad loggertype in stream definition ${JSON.stringify(e)}`)}for(let t=0;t<this.logStreams.length;t++)this.logStreams[t].initialize()}logTime(t,e){let r=void 0!==t?t:"Time",n=new Date;this.info(`${r} ${n} (epoch ${+n})`,e)}getTimeStamp(){return+new Date}getTimeDelta(t){return+new Date-t}logTimeDelta(t,e,r){let n=void 0!==e?e:"Time Measurement",i=+new Date;this.info(`${n} logged at (epoch ${+i}) took (${t}ms)`,r)}logTimeDeltaHuman(t,e,r){let n=void 0!==e?e:"Time Measurement",i=+new Date,s=parseInt(t%1e3),o=parseInt(t/1e3%60),a=parseInt(t/6e4%60),u=parseInt(t/36e5);s=s<10?"00"+s:s<100?"0"+s:s,o=o<10?"0"+o:o,a=a<10?"0"+a:a,u=u<10?"0"+u:u,this.info(`${n} logged at (epoch ${+i}) took (${t}ms) or (${u}:${a}:${o}.${s})`,r)}logTimeDeltaRelative(t,e,r){this.logTimeDelta(this.getTimeDelta(t),e,r)}logTimeDeltaRelativeHuman(t,e,r){this.logTimeDeltaHuman(this.getTimeDelta(t),e,r)}}e.exports=n,e.exports.new=function(t){return new n(t)},e.exports.LogProviderBase=t("./Fable-Log-BaseLogger.js")},{"./Fable-Log-BaseLogger.js":17,"./Fable-Log-DefaultProviders-Node.js":18,"./Fable-Log-DefaultStreams.json":19}],22:[function(t,e,r){e.exports={Product:"ApplicationNameHere",ProductVersion:"0.0.0",ConfigFile:!1,LogStreams:[{level:"trace"}]}},{}],23:[function(t,e,r){(function(t){(function(){e.exports=
|
|
27
27
|
/**
|
|
28
28
|
* Fable Settings Template Processor
|
|
29
29
|
*
|
|
@@ -34,7 +34,7 @@ class n{constructor(e,r){let n="object"==typeof e?e:{};this._Settings=n,this._Pr
|
|
|
34
34
|
* @author Steven Velozo <steven@velozo.com>
|
|
35
35
|
* @module Fable Settings
|
|
36
36
|
*/
|
|
37
|
-
class{constructor(e){this.templateProcessor=new e.precedent,this.templateProcessor.addPattern("${","}",(e=>{let r=e.trim(),n=r.indexOf("|"),i=r.substring(n+1),
|
|
37
|
+
class{constructor(e){this.templateProcessor=new e.precedent,this.templateProcessor.addPattern("${","}",(e=>{let r=e.trim(),n=r.indexOf("|"),i=r.substring(n+1),s=n>-1?r.substring(0,n):r;return t.env.hasOwnProperty(s)?t.env[s]:i}))}parseSetting(t){return this.templateProcessor.parseString(t)}}}).call(this)}).call(this,t("_process"))},{_process:30}],24:[function(t,e,r){
|
|
38
38
|
/**
|
|
39
39
|
* Fable Settings Add-on
|
|
40
40
|
*
|
|
@@ -43,7 +43,7 @@ class{constructor(e){this.templateProcessor=new e.precedent,this.templateProcess
|
|
|
43
43
|
* @author Steven Velozo <steven@velozo.com>
|
|
44
44
|
* @module Fable Settings
|
|
45
45
|
*/
|
|
46
|
-
const n=t("precedent"),i=t("./Fable-Settings-TemplateProcessor.js");class
|
|
46
|
+
const n=t("precedent"),i=t("./Fable-Settings-TemplateProcessor.js");class s{constructor(e){this.dependencies={precedent:n},this.settingsTemplateProcessor=new i(this.dependencies),this._configureEnvTemplating(e),this.default=this.buildDefaultSettings();let r=this.merge(e,this.buildDefaultSettings());if(this.base=JSON.parse(JSON.stringify(r)),r.DefaultConfigFile)try{r=this.merge(t(r.DefaultConfigFile),r)}catch(t){console.log("Fable-Settings Warning: Default configuration file specified but there was a problem loading it. Falling back to base."),console.log(" Loading Exception: "+t)}if(r.ConfigFile)try{r=this.merge(t(r.ConfigFile),r)}catch(t){console.log("Fable-Settings Warning: Configuration file specified but there was a problem loading it. Falling back to base."),console.log(" Loading Exception: "+t)}this.settings=r}buildDefaultSettings(){return JSON.parse(JSON.stringify(t("./Fable-Settings-Default")))}_configureEnvTemplating(t){this._PerformEnvTemplating=!t||!0!==t.NoEnvReplacement}_resolveEnv(t){for(const e in t)"object"==typeof t[e]?this._resolveEnv(t[e]):"string"==typeof t[e]&&(t[e]=this.settingsTemplateProcessor.parseSetting(t[e]))}_isObject(t){return"object"==typeof t&&!Array.isArray(t)}_deepMergeObjects(t,e){if(e&&this._isObject(e))return Object.keys(e).forEach((r=>{const n=e[r];if(this._isObject(n)){const e=t[r];if(e&&this._isObject(e))return void this._deepMergeObjects(e,n)}t[r]=n})),t}merge(t,e){let r="object"==typeof t?t:{},n="object"==typeof e?e:this.settings,i=JSON.parse(JSON.stringify(r));return n=this._deepMergeObjects(n,i),this._PerformEnvTemplating&&this._resolveEnv(n),this._configureEnvTemplating(n),n}fill(t){let e="object"==typeof t?t:{},r=JSON.parse(JSON.stringify(e));return this.settings=this._deepMergeObjects(r,this.settings),this.settings}}e.exports=s,e.exports.new=function(t){return new s(t)},e.exports.precedent=n},{"./Fable-Settings-Default":22,"./Fable-Settings-TemplateProcessor.js":23,precedent:27}],25:[function(t,e,r){e.exports=
|
|
47
47
|
/**
|
|
48
48
|
* Random Byte Generator - Browser version
|
|
49
49
|
*
|
|
@@ -90,11 +90,11 @@ class{constructor(){}newParserState(t){return{ParseTree:t,Output:"",OutputBuffer
|
|
|
90
90
|
*
|
|
91
91
|
* @description Create a tree (directed graph) of Javascript objects, one character per object.
|
|
92
92
|
*/
|
|
93
|
-
class{constructor(){this.ParseTree={}}addChild(t,e,r){return t.hasOwnProperty(e[r])||(t[e[r]]={}),t[e[r]]}addPattern(t,e,r){if(t.length<1)return!1;if("string"==typeof e&&e.length<1)return!1;let n=this.ParseTree;for(var i=0;i<t.length;i++)n=this.addChild(n,t,i);return n.PatternStart=t,n.PatternEnd="string"==typeof e&&e.length>0?e:t,n.Parse="function"==typeof r?r:"string"==typeof r?()=>r:t=>t,!0}}},{}],30:[function(t,e,r){var n,i,
|
|
93
|
+
class{constructor(){this.ParseTree={}}addChild(t,e,r){return t.hasOwnProperty(e[r])||(t[e[r]]={}),t[e[r]]}addPattern(t,e,r){if(t.length<1)return!1;if("string"==typeof e&&e.length<1)return!1;let n=this.ParseTree;for(var i=0;i<t.length;i++)n=this.addChild(n,t,i);return n.PatternStart=t,n.PatternEnd="string"==typeof e&&e.length>0?e:t,n.Parse="function"==typeof r?r:"string"==typeof r?()=>r:t=>t,!0}}},{}],30:[function(t,e,r){var n,i,s=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{i="function"==typeof clearTimeout?clearTimeout:a}catch(t){i=a}}();var l,c=[],f=!1,h=-1;function p(){f&&l&&(f=!1,l.length?c=l.concat(c):h=-1,c.length&&d())}function d(){if(!f){var t=u(p);f=!0;for(var e=c.length;e;){for(l=c,c=[];++h<e;)l&&l[h].run();h=-1,e=c.length}l=null,f=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{return i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function g(t,e){this.fun=t,this.array=e}function m(){}s.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new g(t,e)),1!==c.length||f||u(d)},g.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],31:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,s=Function.prototype.apply,o=Array.prototype.slice,a={},u=0;function l(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new l(s.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new l(s.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&o.call(arguments,1);return a[e]=!0,i((function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))})),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":30,timers:31}],32:[function(t,e,r){var n=t("./Fable.js");"object"!=typeof window||window.hasOwnProperty("Fable")||(window.Fable=n),e.exports=n},{"./Fable.js":36}],33:[function(t,e,r){const n=JSON.stringify({Metadata:{GUID:!1,Hash:!1,Title:"",Summary:"",Version:0},Status:{Completed:!1,CompletionProgress:0,CompletionTimeElapsed:0,Steps:1,StepsCompleted:0,StartTime:0,EndTime:0},Errors:[],Log:[]});e.exports=class{constructor(t,e,r){this.fable=t,this.state=JSON.parse(n),this.state.Metadata.GUID=this.fable.getUUID(),this.state.Metadata.Hash=this.state.GUID,"string"==typeof r&&(this.state.Metadata.Hash=r)}get GUID(){return this.state.Metadata.GUID}get Hash(){return this.state.Metadata.Hash}get log(){return this}writeOperationLog(t,e,r){this.state.Log.push(`${(new Date).toUTCString()} [${t}]: ${e}`),"object"==typeof r&&this.state.Log.push(JSON.stringify(r))}writeOperationErrors(t,e){this.state.Errors.push(`${t}`),"object"==typeof e&&this.state.Errors.push(JSON.stringify(e))}trace(t,e){this.writeOperationLog("TRACE",t,e),this.fable.log.trace(t,e)}debug(t,e){this.writeOperationLog("DEBUG",t,e),this.fable.log.debug(t,e)}info(t,e){this.writeOperationLog("INFO",t,e),this.fable.log.info(t,e)}warn(t,e){this.writeOperationLog("WARN",t,e),this.fable.log.warn(t,e)}error(t,e){this.writeOperationLog("ERROR",t,e),this.writeOperationErrors(t,e),this.fable.log.error(t,e)}fatal(t,e){this.writeOperationLog("FATAL",t,e),this.writeOperationErrors(t,e),this.fable.log.fatal(t,e)}}},{}],34:[function(t,e,r){e.exports=class{constructor(t,e){this.fable=t,this.Matchers={Evaluate:/<%([\s\S]+?)%>/g,Interpolate:/<%=([\s\S]+?)%>/g,Escaper:/\\|'|\r|\n|\t|\u2028|\u2029/g,Unescaper:/\\(\\|'|r|n|t|u2028|u2029)/g,GuaranteedNonMatch:/.^/},this.templateEscapes={"\\":"\\","'":"'",r:"\r","\r":"r",n:"\n","\n":"n",t:"\t","\t":"t",u2028:"\u2028","\u2028":"u2028",u2029:"\u2029","\u2029":"u2029"},this.renderFunction=()=>""}extend(t,...e){return Object.assign(t,...e)}renderTemplate(t){return this.renderFunction(t)}templateFunction(t){return this.renderTemplate.bind(this)}buildTemplateFunction(t,e){return this.TemplateSource="__p+='"+t.replace(this.Matchers.Escaper,(t=>`\\${this.templateEscapes[t]}`)).replace(this.Matchers.Interpolate||this.Matchers.GuaranteedNonMatch,((t,e)=>`'+\n(${decodeURIComponent(e)})+\n'`)).replace(this.Matchers.Evaluate||this.Matchers.GuaranteedNonMatch,((t,e)=>`';\n${decodeURIComponent(e)}\n;__p+='`))+"';\n",this.TemplateSource=`with(pTemplateDataObject||{}){\n${this.TemplateSource}}\n`,this.TemplateSource=`var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n${this.TemplateSource}return __p;\n`,this.renderFunction=new Function("pTemplateDataObject",this.TemplateSource),void 0!==e?this.renderFunction(e):(this.TemplateSourceCompiled="function(obj){\n"+this.TemplateSource+"}",this.templateFunction())}}},{}],35:[function(t,e,r){const n=t("./Fable-Utility-Template.js"),i=t("async/waterfall"),s=t("async/eachLimit");e.exports=class{constructor(t){this.fable=t,this.waterfall=i,this.eachLimit=s}extend(t,...e){return Object.assign(t,...e)}template(t,e){return new n(this.fable,t).buildTemplateFunction(t,e)}chunk(t,e,r){let n=[...t],i="number"==typeof e?e:0,s=void 0!==r?r:[];if(i<=0)return s;for(;n.length;)s.push(n.splice(0,i));return s}}},{"./Fable-Utility-Template.js":34,"async/eachLimit":2,"async/waterfall":16}],36:[function(t,e,r){
|
|
94
94
|
/**
|
|
95
95
|
* Fable Application Services Support Library
|
|
96
96
|
* @license MIT
|
|
97
97
|
* @author <steven@velozo.com>
|
|
98
98
|
*/
|
|
99
|
-
const n=t("fable-settings"),i=t("fable-uuid"),
|
|
99
|
+
const n=t("fable-settings"),i=t("fable-uuid"),s=t("fable-log"),o=t("./Fable-Utility.js"),a=t("./Fable-Operation.js");class u{constructor(t){let e=new n(t);this.settingsManager=e,this.libUUID=new i(this.settingsManager.settings),this.log=new s(this.settingsManager.settings),this.log.initialize(),this.Utility=new o(this),this.Dependencies={precedent:n.precedent},this.Operations={}}get settings(){return this.settingsManager.settings}get fable(){return this}getUUID(){return this.libUUID.getUUID()}createOperation(t,e){let r=new a(this,t,e);return this.Operations.hasOwnProperty(r.Hash)||(this.Operations[r.Hash]=r),r}getOperation(t){return!!this.Operations.hasOwnProperty(t)&&this.pOperations[t]}}e.exports=u,e.exports.new=function(t){return new u(t)},e.exports.LogProviderBase=s.LogProviderBase,e.exports.precedent=n.precedent},{"./Fable-Operation.js":33,"./Fable-Utility.js":35,"fable-log":21,"fable-settings":24,"fable-uuid":26}]},{},[32])(32)}));
|
|
100
100
|
//# sourceMappingURL=fable.min.js.map
|