fable 3.0.17 → 3.0.20
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 +2714 -0
- package/dist/fable.compatible.min.js +112 -0
- package/dist/fable.compatible.min.js.map +1 -0
- package/dist/fable.js +137 -122
- package/dist/fable.min.js +8 -8
- 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 +5 -1
package/dist/fable.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
(function (f) {
|
|
2
4
|
if (typeof exports === "object" && typeof module !== "undefined") {
|
|
3
5
|
module.exports = f();
|
|
@@ -264,7 +266,7 @@
|
|
|
264
266
|
'use strict';
|
|
265
267
|
|
|
266
268
|
var _setImmediate = typeof setImmediate === 'function' && setImmediate;
|
|
267
|
-
var fallback = function (fn) {
|
|
269
|
+
var fallback = function fallback(fn) {
|
|
268
270
|
setTimeout(fn, 0);
|
|
269
271
|
};
|
|
270
272
|
module.exports = function setImmediate(fn) {
|
|
@@ -422,7 +424,7 @@
|
|
|
422
424
|
super(pLogStreamSettings);
|
|
423
425
|
this._ShowTimeStamps = this._Settings.hasOwnProperty('showtimestamps') ? this._Settings.showtimestamps == true : true;
|
|
424
426
|
this._FormattedTimeStamps = this._Settings.hasOwnProperty('formattedtimestamps') ? this._Settings.formattedtimestamps == true : true;
|
|
425
|
-
this._ContextMessage = this._Settings.hasOwnProperty('Context') ?
|
|
427
|
+
this._ContextMessage = this._Settings.hasOwnProperty('Context') ? "(".concat(this._Settings.Context, ")") : pFableLog._Settings.hasOwnProperty('Product') ? "(".concat(pFableLog._Settings.Product, ")") : 'Unnamed_Log_Context';
|
|
426
428
|
|
|
427
429
|
// Allow the user to decide what gets output to the console
|
|
428
430
|
this._OutputLogLinesToConsole = this._Settings.hasOwnProperty('outputloglinestoconsole') ? this._Settings.outputloglinestoconsole : true;
|
|
@@ -431,7 +433,7 @@
|
|
|
431
433
|
// Precompute the prefix for each level
|
|
432
434
|
this.prefixCache = {};
|
|
433
435
|
for (let i = 0; i <= this.levels.length; i++) {
|
|
434
|
-
this.prefixCache[this.levels[i]] =
|
|
436
|
+
this.prefixCache[this.levels[i]] = "[".concat(this.levels[i], "] ").concat(this._ContextMessage, ": ");
|
|
435
437
|
if (this._ShowTimeStamps) {
|
|
436
438
|
// If there is a timestamp we need a to prepend space before the prefixcache string, since the timestamp comes first
|
|
437
439
|
this.prefixCache[this.levels[i]] = ' ' + this.prefixCache[this.levels[i]];
|
|
@@ -445,7 +447,7 @@
|
|
|
445
447
|
} else if (this._ShowTimeStamps) {
|
|
446
448
|
tmpTimeStamp = +new Date();
|
|
447
449
|
}
|
|
448
|
-
let tmpLogLine =
|
|
450
|
+
let tmpLogLine = "".concat(tmpTimeStamp).concat(this.prefixCache[pLevel]).concat(pLogText);
|
|
449
451
|
if (this._OutputLogLinesToConsole) {
|
|
450
452
|
console.log(tmpLogLine);
|
|
451
453
|
}
|
|
@@ -472,7 +474,7 @@
|
|
|
472
474
|
super(pLogStreamSettings, pFableLog);
|
|
473
475
|
|
|
474
476
|
// If a path isn't provided for the logfile, it tries to use the ProductName or Context
|
|
475
|
-
this.logFileRawPath = this._Settings.hasOwnProperty('path') ? this._Settings.path :
|
|
477
|
+
this.logFileRawPath = this._Settings.hasOwnProperty('path') ? this._Settings.path : "./".concat(this._ContextMessage, ".log");
|
|
476
478
|
this.logFilePath = libPath.normalize(this.logFileRawPath);
|
|
477
479
|
this.logFileStreamOptions = this._Settings.hasOwnProperty('fileStreamoptions') ? this._Settings.fileStreamOptions : {
|
|
478
480
|
"flags": "a",
|
|
@@ -519,9 +521,9 @@
|
|
|
519
521
|
let tmpConstructedBufferOutputString = '';
|
|
520
522
|
for (let i = 0; i < tmpLineStrings.length; i++) {
|
|
521
523
|
// TODO: Windows Newline? ....... yo no se!
|
|
522
|
-
tmpConstructedBufferOutputString +=
|
|
524
|
+
tmpConstructedBufferOutputString += "".concat(tmpLineStrings[i], "\n");
|
|
523
525
|
if (tmpObjectStrings[i] !== false) {
|
|
524
|
-
tmpConstructedBufferOutputString +=
|
|
526
|
+
tmpConstructedBufferOutputString += "".concat(tmpObjectStrings[i], "\n");
|
|
525
527
|
}
|
|
526
528
|
}
|
|
527
529
|
if (!this.fileWriter.write(tmpConstructedBufferOutputString, 'utf8')) {
|
|
@@ -672,7 +674,7 @@
|
|
|
672
674
|
level: 'info'
|
|
673
675
|
}, this._StreamDefinitions[i]);
|
|
674
676
|
if (!this._Providers.hasOwnProperty(tmpStreamDefinition.loggertype)) {
|
|
675
|
-
console.log(
|
|
677
|
+
console.log("Error initializing log stream: bad loggertype in stream definition ".concat(JSON.stringify(tmpStreamDefinition)));
|
|
676
678
|
} else {
|
|
677
679
|
this.addLogger(new this._Providers[tmpStreamDefinition.loggertype](tmpStreamDefinition, this), tmpStreamDefinition.level);
|
|
678
680
|
}
|
|
@@ -686,7 +688,7 @@
|
|
|
686
688
|
logTime(pMessage, pDatum) {
|
|
687
689
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time';
|
|
688
690
|
let tmpTime = new Date();
|
|
689
|
-
this.info(
|
|
691
|
+
this.info("".concat(tmpMessage, " ").concat(tmpTime, " (epoch ").concat(+tmpTime, ")"), pDatum);
|
|
690
692
|
}
|
|
691
693
|
|
|
692
694
|
// Get a timestamp
|
|
@@ -703,7 +705,7 @@
|
|
|
703
705
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
704
706
|
let tmpDatum = typeof pDatum === 'object' ? pDatum : {};
|
|
705
707
|
let tmpEndTime = +new Date();
|
|
706
|
-
this.info(
|
|
708
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms)"), pDatum);
|
|
707
709
|
}
|
|
708
710
|
logTimeDeltaHuman(pTimeDelta, pMessage, pDatum) {
|
|
709
711
|
let tmpMessage = typeof pMessage !== 'undefined' ? pMessage : 'Time Measurement';
|
|
@@ -716,7 +718,7 @@
|
|
|
716
718
|
tmpSeconds = tmpSeconds < 10 ? "0" + tmpSeconds : tmpSeconds;
|
|
717
719
|
tmpMinutes = tmpMinutes < 10 ? "0" + tmpMinutes : tmpMinutes;
|
|
718
720
|
tmpHours = tmpHours < 10 ? "0" + tmpHours : tmpHours;
|
|
719
|
-
this.info(
|
|
721
|
+
this.info("".concat(tmpMessage, " logged at (epoch ").concat(+tmpEndTime, ") took (").concat(pTimeDelta, "ms) or (").concat(tmpHours, ":").concat(tmpMinutes, ":").concat(tmpSeconds, ".").concat(tmpMs, ")"), pDatum);
|
|
720
722
|
}
|
|
721
723
|
logTimeDeltaRelative(pStartTime, pMessage, pDatum) {
|
|
722
724
|
this.logTimeDelta(this.getTimeDelta(pStartTime), pMessage, pDatum);
|
|
@@ -1563,8 +1565,8 @@
|
|
|
1563
1565
|
*
|
|
1564
1566
|
* @description Process text streams, parsing out meta-template expressions.
|
|
1565
1567
|
*/
|
|
1566
|
-
var libWordTree = require(
|
|
1567
|
-
var libStringParser = require(
|
|
1568
|
+
var libWordTree = require("./WordTree.js");
|
|
1569
|
+
var libStringParser = require("./StringParser.js");
|
|
1568
1570
|
class Precedent {
|
|
1569
1571
|
/**
|
|
1570
1572
|
* Precedent Constructor
|
|
@@ -2094,6 +2096,7 @@
|
|
|
2094
2096
|
class FableOperation {
|
|
2095
2097
|
constructor(pFable, pOperationName, pOperationHash) {
|
|
2096
2098
|
this.fable = pFable;
|
|
2099
|
+
this.name = pOperationName;
|
|
2097
2100
|
this.state = JSON.parse(_OperationStatePrototype);
|
|
2098
2101
|
this.state.Metadata.GUID = this.fable.getUUID();
|
|
2099
2102
|
this.state.Metadata.Hash = this.state.GUID;
|
|
@@ -2111,13 +2114,13 @@
|
|
|
2111
2114
|
return this;
|
|
2112
2115
|
}
|
|
2113
2116
|
writeOperationLog(pLogLevel, pLogText, pLogObject) {
|
|
2114
|
-
this.state.Log.push(
|
|
2117
|
+
this.state.Log.push("".concat(new Date().toUTCString(), " [").concat(pLogLevel, "]: ").concat(pLogText));
|
|
2115
2118
|
if (typeof pLogObject == 'object') {
|
|
2116
2119
|
this.state.Log.push(JSON.stringify(pLogObject));
|
|
2117
2120
|
}
|
|
2118
2121
|
}
|
|
2119
2122
|
writeOperationErrors(pLogText, pLogObject) {
|
|
2120
|
-
this.state.Errors.push(
|
|
2123
|
+
this.state.Errors.push("".concat(pLogText));
|
|
2121
2124
|
if (typeof pLogObject == 'object') {
|
|
2122
2125
|
this.state.Errors.push(JSON.stringify(pLogObject));
|
|
2123
2126
|
}
|
|
@@ -2152,6 +2155,89 @@
|
|
|
2152
2155
|
module.exports = FableOperation;
|
|
2153
2156
|
}, {}],
|
|
2154
2157
|
36: [function (require, module, exports) {
|
|
2158
|
+
const libFableServiceBase = require('./Fable-ServiceProviderBase.js');
|
|
2159
|
+
class FableServiceTemplate extends libFableServiceBase {
|
|
2160
|
+
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2161
|
+
// string-based template with code snippets into simple executable pieces,
|
|
2162
|
+
// with the added twist of returning a precompiled function ready to go.
|
|
2163
|
+
//
|
|
2164
|
+
// NOTE: This does not implement underscore escape expressions
|
|
2165
|
+
// NOTE: This does not implement underscore magic browser variable assignment
|
|
2166
|
+
//
|
|
2167
|
+
// This is an implementation of that.
|
|
2168
|
+
// TODO: Make this use precedent, add configuration, add debugging.
|
|
2169
|
+
constructor(pFable, pOptions, pServiceHash) {
|
|
2170
|
+
super(pFable, pOptions, pServiceHash);
|
|
2171
|
+
this.serviceType = 'Template';
|
|
2172
|
+
|
|
2173
|
+
// These are the exact regex's used in lodash/underscore
|
|
2174
|
+
// TODO: Switch this to precedent
|
|
2175
|
+
this.Matchers = {
|
|
2176
|
+
Evaluate: /<%([\s\S]+?)%>/g,
|
|
2177
|
+
Interpolate: /<%=([\s\S]+?)%>/g,
|
|
2178
|
+
Escaper: /\\|'|\r|\n|\t|\u2028|\u2029/g,
|
|
2179
|
+
Unescaper: /\\(\\|'|r|n|t|u2028|u2029)/g,
|
|
2180
|
+
// This is how underscore does it, so we are keeping it for now.
|
|
2181
|
+
GuaranteedNonMatch: /.^/
|
|
2182
|
+
};
|
|
2183
|
+
|
|
2184
|
+
// This is a helper for the escaper and unescaper functions.
|
|
2185
|
+
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
2186
|
+
this.templateEscapes = {
|
|
2187
|
+
'\\': '\\',
|
|
2188
|
+
"'": "'",
|
|
2189
|
+
'r': '\r',
|
|
2190
|
+
'\r': 'r',
|
|
2191
|
+
'n': '\n',
|
|
2192
|
+
'\n': 'n',
|
|
2193
|
+
't': '\t',
|
|
2194
|
+
'\t': 't',
|
|
2195
|
+
'u2028': '\u2028',
|
|
2196
|
+
'\u2028': 'u2028',
|
|
2197
|
+
'u2029': '\u2029',
|
|
2198
|
+
'\u2029': 'u2029'
|
|
2199
|
+
};
|
|
2200
|
+
|
|
2201
|
+
// This is defined as such to underscore that it is a dynamic programming
|
|
2202
|
+
// function on this class.
|
|
2203
|
+
this.renderFunction = false;
|
|
2204
|
+
this.templateString = false;
|
|
2205
|
+
}
|
|
2206
|
+
renderTemplate(pData) {
|
|
2207
|
+
return this.renderFunction(pData);
|
|
2208
|
+
}
|
|
2209
|
+
templateFunction(pData) {
|
|
2210
|
+
let fRenderTemplateBound = this.renderTemplate.bind(this);
|
|
2211
|
+
return fRenderTemplateBound;
|
|
2212
|
+
}
|
|
2213
|
+
buildTemplateFunction(pTemplateText, pData) {
|
|
2214
|
+
// For now this is being kept in a weird form ... this is to mimic the old
|
|
2215
|
+
// underscore code until this is rewritten using precedent.
|
|
2216
|
+
this.TemplateSource = "__p+='" + pTemplateText.replace(this.Matchers.Escaper, pMatch => {
|
|
2217
|
+
return "\\".concat(this.templateEscapes[pMatch]);
|
|
2218
|
+
}).replace(this.Matchers.Interpolate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2219
|
+
return "'+\n(".concat(decodeURIComponent(pCode), ")+\n'");
|
|
2220
|
+
}).replace(this.Matchers.Evaluate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2221
|
+
return "';\n".concat(decodeURIComponent(pCode), "\n;__p+='");
|
|
2222
|
+
}) + "';\n";
|
|
2223
|
+
this.TemplateSource = "with(pTemplateDataObject||{}){\n".concat(this.TemplateSource, "}\n");
|
|
2224
|
+
this.TemplateSource = "var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n".concat(this.TemplateSource, "return __p;\n");
|
|
2225
|
+
this.renderFunction = new Function('pTemplateDataObject', this.TemplateSource);
|
|
2226
|
+
if (typeof pData != 'undefined') {
|
|
2227
|
+
return this.renderFunction(pData);
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
// Provide the compiled function source as a convenience for build time
|
|
2231
|
+
// precompilation.
|
|
2232
|
+
this.TemplateSourceCompiled = 'function(obj){\n' + this.TemplateSource + '}';
|
|
2233
|
+
return this.templateFunction();
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
module.exports = FableServiceTemplate;
|
|
2237
|
+
}, {
|
|
2238
|
+
"./Fable-ServiceProviderBase.js": 38
|
|
2239
|
+
}],
|
|
2240
|
+
37: [function (require, module, exports) {
|
|
2155
2241
|
/**
|
|
2156
2242
|
* Fable Application Services Management
|
|
2157
2243
|
* @license MIT
|
|
@@ -2179,7 +2265,7 @@
|
|
|
2179
2265
|
|
|
2180
2266
|
// Add the container for instantiated services to go in
|
|
2181
2267
|
this.services[pServiceType] = {};
|
|
2182
|
-
if (typeof pServiceClass == '
|
|
2268
|
+
if (typeof pServiceClass == 'function' && pServiceClass.prototype instanceof libFableServiceBase) {
|
|
2183
2269
|
// Add the class to the list of classes
|
|
2184
2270
|
this.serviceClasses[pServiceType] = pServiceClass;
|
|
2185
2271
|
} else {
|
|
@@ -2189,7 +2275,7 @@
|
|
|
2189
2275
|
}
|
|
2190
2276
|
instantiateServiceProvider(pServiceType, pOptions, pCustomServiceHash) {
|
|
2191
2277
|
// Instantiate the service
|
|
2192
|
-
let tmpService =
|
|
2278
|
+
let tmpService = this.instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash);
|
|
2193
2279
|
|
|
2194
2280
|
// Add the service to the service map
|
|
2195
2281
|
this.services[pServiceType][tmpService.Hash] = tmpService;
|
|
@@ -2200,6 +2286,13 @@
|
|
|
2200
2286
|
}
|
|
2201
2287
|
return tmpService;
|
|
2202
2288
|
}
|
|
2289
|
+
|
|
2290
|
+
// Create a service provider but don't register it to live forever in fable.services
|
|
2291
|
+
instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash) {
|
|
2292
|
+
// Instantiate the service
|
|
2293
|
+
let tmpService = new this.serviceClasses[pServiceType](this.fable, pOptions, pCustomServiceHash);
|
|
2294
|
+
return tmpService;
|
|
2295
|
+
}
|
|
2203
2296
|
setDefaultServiceInstantiation(pServiceType, pServiceHash) {
|
|
2204
2297
|
if (this.services[pServiceType].hasOwnProperty(pServiceHash)) {
|
|
2205
2298
|
this.defaultServices[pServiceType] = this.services[pServiceType][pServiceHash];
|
|
@@ -2207,19 +2300,13 @@
|
|
|
2207
2300
|
}
|
|
2208
2301
|
return false;
|
|
2209
2302
|
}
|
|
2210
|
-
getServiceByHash(pServiceHash) {
|
|
2211
|
-
if (this.services.hasOwnProperty(pServiceHash)) {
|
|
2212
|
-
return this.services[pServiceHash];
|
|
2213
|
-
}
|
|
2214
|
-
return false;
|
|
2215
|
-
}
|
|
2216
2303
|
}
|
|
2217
2304
|
module.exports = FableService;
|
|
2218
|
-
module.exports.
|
|
2305
|
+
module.exports.ServiceProviderBase = libFableServiceBase;
|
|
2219
2306
|
}, {
|
|
2220
|
-
"./Fable-ServiceProviderBase.js":
|
|
2307
|
+
"./Fable-ServiceProviderBase.js": 38
|
|
2221
2308
|
}],
|
|
2222
|
-
|
|
2309
|
+
38: [function (require, module, exports) {
|
|
2223
2310
|
/**
|
|
2224
2311
|
* Fable Service Base
|
|
2225
2312
|
* @license MIT
|
|
@@ -2229,108 +2316,22 @@
|
|
|
2229
2316
|
class FableServiceProviderBase {
|
|
2230
2317
|
constructor(pFable, pOptions, pServiceHash) {
|
|
2231
2318
|
this.fable = pFable;
|
|
2232
|
-
this.options = pOptions;
|
|
2319
|
+
this.options = typeof pOptions === 'object' ? pOptions : {};
|
|
2233
2320
|
this.serviceType = 'Unknown';
|
|
2234
2321
|
this.UUID = pFable.getUUID();
|
|
2235
|
-
this.Hash = typeof pServiceHash === 'string' ? pServiceHash :
|
|
2322
|
+
this.Hash = typeof pServiceHash === 'string' ? pServiceHash : "".concat(this.UUID);
|
|
2236
2323
|
}
|
|
2237
2324
|
}
|
|
2238
2325
|
module.exports = FableServiceProviderBase;
|
|
2239
2326
|
}, {}],
|
|
2240
|
-
38: [function (require, module, exports) {
|
|
2241
|
-
class FableUtility {
|
|
2242
|
-
// Underscore and lodash have a behavior, _.template, which compiles a
|
|
2243
|
-
// string-based template with code snippets into simple executable pieces,
|
|
2244
|
-
// with the added twist of returning a precompiled function ready to go.
|
|
2245
|
-
//
|
|
2246
|
-
// NOTE: This does not implement underscore escape expressions
|
|
2247
|
-
// NOTE: This does not implement underscore magic browser variable assignment
|
|
2248
|
-
//
|
|
2249
|
-
// This is an implementation of that.
|
|
2250
|
-
// TODO: Make this use precedent, add configuration, add debugging.
|
|
2251
|
-
constructor(pFable, pTemplateText) {
|
|
2252
|
-
this.fable = pFable;
|
|
2253
|
-
|
|
2254
|
-
// These are the exact regex's used in lodash/underscore
|
|
2255
|
-
// TODO: Switch this to precedent
|
|
2256
|
-
this.Matchers = {
|
|
2257
|
-
Evaluate: /<%([\s\S]+?)%>/g,
|
|
2258
|
-
Interpolate: /<%=([\s\S]+?)%>/g,
|
|
2259
|
-
Escaper: /\\|'|\r|\n|\t|\u2028|\u2029/g,
|
|
2260
|
-
Unescaper: /\\(\\|'|r|n|t|u2028|u2029)/g,
|
|
2261
|
-
// This is how underscore does it, so we are keeping it for now.
|
|
2262
|
-
GuaranteedNonMatch: /.^/
|
|
2263
|
-
};
|
|
2264
|
-
|
|
2265
|
-
// This is a helper for the escaper and unescaper functions.
|
|
2266
|
-
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
2267
|
-
this.templateEscapes = {
|
|
2268
|
-
'\\': '\\',
|
|
2269
|
-
"'": "'",
|
|
2270
|
-
'r': '\r',
|
|
2271
|
-
'\r': 'r',
|
|
2272
|
-
'n': '\n',
|
|
2273
|
-
'\n': 'n',
|
|
2274
|
-
't': '\t',
|
|
2275
|
-
'\t': 't',
|
|
2276
|
-
'u2028': '\u2028',
|
|
2277
|
-
'\u2028': 'u2028',
|
|
2278
|
-
'u2029': '\u2029',
|
|
2279
|
-
'\u2029': 'u2029'
|
|
2280
|
-
};
|
|
2281
|
-
|
|
2282
|
-
// This is defined as such to underscore that it is a dynamic programming
|
|
2283
|
-
// function on this class.
|
|
2284
|
-
this.renderFunction = () => {
|
|
2285
|
-
return ``;
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
|
|
2289
|
-
// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
2290
|
-
// Now that es6 gives us this, use the native thingy.
|
|
2291
|
-
extend(pDestinationObject, ...pSourceObjects) {
|
|
2292
|
-
return Object.assign(pDestinationObject, ...pSourceObjects);
|
|
2293
|
-
}
|
|
2294
|
-
renderTemplate(pData) {
|
|
2295
|
-
return this.renderFunction(pData);
|
|
2296
|
-
}
|
|
2297
|
-
templateFunction(pData) {
|
|
2298
|
-
let fRenderTemplateBound = this.renderTemplate.bind(this);
|
|
2299
|
-
return fRenderTemplateBound;
|
|
2300
|
-
}
|
|
2301
|
-
buildTemplateFunction(pTemplateText, pData) {
|
|
2302
|
-
// For now this is being kept in a weird form ... this is to mimic the old
|
|
2303
|
-
// underscore code until this is rewritten using precedent.
|
|
2304
|
-
this.TemplateSource = "__p+='" + pTemplateText.replace(this.Matchers.Escaper, pMatch => {
|
|
2305
|
-
return `\\${this.templateEscapes[pMatch]}`;
|
|
2306
|
-
}).replace(this.Matchers.Interpolate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2307
|
-
return `'+\n(${decodeURIComponent(pCode)})+\n'`;
|
|
2308
|
-
}).replace(this.Matchers.Evaluate || this.Matchers.GuaranteedNonMatch, (pMatch, pCode) => {
|
|
2309
|
-
return `';\n${decodeURIComponent(pCode)}\n;__p+='`;
|
|
2310
|
-
}) + `';\n`;
|
|
2311
|
-
this.TemplateSource = `with(pTemplateDataObject||{}){\n${this.TemplateSource}}\n`;
|
|
2312
|
-
this.TemplateSource = `var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n${this.TemplateSource}return __p;\n`;
|
|
2313
|
-
this.renderFunction = new Function('pTemplateDataObject', this.TemplateSource);
|
|
2314
|
-
if (typeof pData != 'undefined') {
|
|
2315
|
-
return this.renderFunction(pData);
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
// Provide the compiled function source as a convenience for build time
|
|
2319
|
-
// precompilation.
|
|
2320
|
-
this.TemplateSourceCompiled = 'function(obj){\n' + this.TemplateSource + '}';
|
|
2321
|
-
return this.templateFunction();
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
module.exports = FableUtility;
|
|
2325
|
-
}, {}],
|
|
2326
2327
|
39: [function (require, module, exports) {
|
|
2327
|
-
const libFableUtilityTemplate = require('./Fable-Utility-Template.js');
|
|
2328
2328
|
// TODO: These are still pretty big -- consider the smaller polyfills
|
|
2329
2329
|
const libAsyncWaterfall = require('async.waterfall');
|
|
2330
|
-
const libAsyncEachLimit = require('async.
|
|
2330
|
+
const libAsyncEachLimit = require('async.eachlimit');
|
|
2331
2331
|
class FableUtility {
|
|
2332
2332
|
constructor(pFable) {
|
|
2333
2333
|
this.fable = pFable;
|
|
2334
|
+
this.templates = {};
|
|
2334
2335
|
|
|
2335
2336
|
// These two functions are used extensively throughout
|
|
2336
2337
|
this.waterfall = libAsyncWaterfall;
|
|
@@ -2339,7 +2340,10 @@
|
|
|
2339
2340
|
|
|
2340
2341
|
// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
2341
2342
|
// Now that es6 gives us this, use the native thingy.
|
|
2342
|
-
extend(pDestinationObject
|
|
2343
|
+
extend(pDestinationObject) {
|
|
2344
|
+
for (var _len = arguments.length, pSourceObjects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2345
|
+
pSourceObjects[_key - 1] = arguments[_key];
|
|
2346
|
+
}
|
|
2343
2347
|
return Object.assign(pDestinationObject, ...pSourceObjects);
|
|
2344
2348
|
}
|
|
2345
2349
|
|
|
@@ -2347,10 +2351,17 @@
|
|
|
2347
2351
|
// string-based template with code snippets into simple executable pieces,
|
|
2348
2352
|
// with the added twist of returning a precompiled function ready to go.
|
|
2349
2353
|
template(pTemplateText, pData) {
|
|
2350
|
-
let tmpTemplate =
|
|
2354
|
+
let tmpTemplate = this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Template');
|
|
2351
2355
|
return tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2352
2356
|
}
|
|
2353
2357
|
|
|
2358
|
+
// Build a template function from a template hash, and, register it with the service provider
|
|
2359
|
+
buildHashedTemplate(pTemplateHash, pTemplateText, pData) {
|
|
2360
|
+
let tmpTemplate = this.fable.serviceManager.instantiateServiceProvider('Template', {}, pTemplateHash);
|
|
2361
|
+
this.templates[pTemplateHash] = tmpTemplate.buildTemplateFunction(pTemplateText, pData);
|
|
2362
|
+
return this.templates[pTemplateHash];
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2354
2365
|
// This is a safe, modern version of chunk from underscore
|
|
2355
2366
|
// Algorithm pulled from a mix of these two polyfills:
|
|
2356
2367
|
// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_chunk
|
|
@@ -2372,8 +2383,7 @@
|
|
|
2372
2383
|
}
|
|
2373
2384
|
module.exports = FableUtility;
|
|
2374
2385
|
}, {
|
|
2375
|
-
"
|
|
2376
|
-
"async.eachLimit": 1,
|
|
2386
|
+
"async.eachlimit": 1,
|
|
2377
2387
|
"async.waterfall": 15
|
|
2378
2388
|
}],
|
|
2379
2389
|
40: [function (require, module, exports) {
|
|
@@ -2387,6 +2397,7 @@
|
|
|
2387
2397
|
const libFableLog = require('fable-log');
|
|
2388
2398
|
const libFableUtility = require('./Fable-Utility.js');
|
|
2389
2399
|
const libFableServiceManager = require('./Fable-ServiceManager.js');
|
|
2400
|
+
const libFableServiceTemplate = require('./Fable-Service-Template.js');
|
|
2390
2401
|
const libFableOperation = require('./Fable-Operation.js');
|
|
2391
2402
|
class Fable {
|
|
2392
2403
|
constructor(pSettings) {
|
|
@@ -2409,6 +2420,9 @@
|
|
|
2409
2420
|
// Location for Operation state
|
|
2410
2421
|
this.Operations = {};
|
|
2411
2422
|
this.serviceManager = new libFableServiceManager(this);
|
|
2423
|
+
this.serviceManager.addServiceType('Template', libFableServiceTemplate);
|
|
2424
|
+
this.services = this.serviceManager.services;
|
|
2425
|
+
this.defaultServices = this.serviceManager.defaultServices;
|
|
2412
2426
|
}
|
|
2413
2427
|
get settings() {
|
|
2414
2428
|
return this.settingsManager.settings;
|
|
@@ -2433,7 +2447,7 @@
|
|
|
2433
2447
|
if (!this.Operations.hasOwnProperty(pOperationHash)) {
|
|
2434
2448
|
return false;
|
|
2435
2449
|
} else {
|
|
2436
|
-
return this.
|
|
2450
|
+
return this.Operations[pOperationHash];
|
|
2437
2451
|
}
|
|
2438
2452
|
}
|
|
2439
2453
|
}
|
|
@@ -2449,7 +2463,8 @@
|
|
|
2449
2463
|
module.exports.precedent = libFableSettings.precedent;
|
|
2450
2464
|
}, {
|
|
2451
2465
|
"./Fable-Operation.js": 35,
|
|
2452
|
-
"./Fable-
|
|
2466
|
+
"./Fable-Service-Template.js": 36,
|
|
2467
|
+
"./Fable-ServiceManager.js": 37,
|
|
2453
2468
|
"./Fable-Utility.js": 39,
|
|
2454
2469
|
"fable-log": 22,
|
|
2455
2470
|
"fable-settings": 25,
|