pict 1.0.113 → 1.0.114
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/pict.compatible.js +91 -89
- package/dist/pict.compatible.min.js +1 -1
- package/dist/pict.compatible.min.js.map +1 -1
- package/dist/pict.js +8 -6
- package/dist/pict.min.js +2 -2
- package/dist/pict.min.js.map +1 -1
- package/package.json +3 -3
package/dist/pict.compatible.js
CHANGED
|
@@ -789,10 +789,10 @@ tmpParameters.ActualPath=libPath.normalize(tmpParameters.Path);tmpParameters.Act
|
|
|
789
789
|
// Build the new base path
|
|
790
790
|
if(tmpParameters.CurrentPath==libPath.sep){tmpParameters.CurrentPath=tmpParameters.CurrentPath+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex];}else{tmpParameters.CurrentPath=tmpParameters.CurrentPath+libPath.sep+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex];}// Increment the path index
|
|
791
791
|
tmpParameters.CurrentPathIndex++;}// Check if the path is fully complete
|
|
792
|
-
if(tmpParameters.CurrentPathIndex>=tmpParameters.ActualPathParts.length){fCallback(null);
|
|
792
|
+
if(tmpParameters.CurrentPathIndex>=tmpParameters.ActualPathParts.length){return fCallback(null);}// Check if the path exists (and is a folder)
|
|
793
793
|
libFS.open(tmpParameters.CurrentPath+libPath.sep+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex],'r',function(pError,pFileDescriptor){if(pFileDescriptor){libFS.closeSync(pFileDescriptor);}if(pError&&pError.code=='ENOENT'){/* Path doesn't exist, create it */libFS.mkdir(tmpParameters.CurrentPath+libPath.sep+tmpParameters.ActualPathParts[tmpParameters.CurrentPathIndex],tmpParameters.Mode,function(pCreateError){if(!pCreateError){// We have now created our folder and there was no error -- continue.
|
|
794
794
|
return _this19.makeFolderRecursive(tmpParameters,fCallback);}else if(pCreateError.code=='EEXIST'){// The folder exists -- our dev might be running this in parallel/async/whatnot.
|
|
795
|
-
return _this19.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pCreateError.code);fCallback(pCreateError);
|
|
795
|
+
return _this19.makeFolderRecursive(tmpParameters,fCallback);}else{console.log(pCreateError.code);return fCallback(pCreateError);}});}else{return _this19.makeFolderRecursive(tmpParameters,fCallback);}});}}]);return FableServiceFilePersistence;}(libFableServiceBase);module.exports=FableServiceFilePersistence;}).call(this);}).call(this,require('_process'));},{"../Fable-ServiceManager.js":39,"_process":77,"fs":18,"path":71}],48:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;/**
|
|
796
796
|
* Precedent Meta-Templating
|
|
797
797
|
* @author Steven Velozo <steven@velozo.com>
|
|
798
798
|
* @description Process text stream trie and postfix tree, parsing out meta-template expression functions.
|
|
@@ -928,17 +928,19 @@ for(var i=0;i<pPatternStart.length;i++){tmpLeaf=this.addChild(tmpLeaf,pPatternSt
|
|
|
928
928
|
* @param {function} fParser - 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.
|
|
929
929
|
* @return {bool} True if adding the pattern was successful
|
|
930
930
|
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,fParser){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;}}}]);return WordTree;}();module.exports=WordTree;},{}],51:[function(require,module,exports){module.exports={"Metadata":{"UUID":false,"Hash":false,"Title":"","Summary":"","Version":0},"Status":{"Completed":false,"CompletionProgress":0,"CompletionTimeElapsed":0,"Steps":1,"StepsCompleted":0,"StartTime":0,"EndTime":0},"Errors":[],"Log":[]};},{}],52:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase6){_inherits(FableOperation,_libFableServiceBase6);var _super15=_createSuper(FableOperation);function FableOperation(pFable,pOptions,pServiceHash){var _this23;_classCallCheck2(this,FableOperation);_this23=_super15.call(this,pFable,pOptions,pServiceHash);_this23.serviceType='PhasedOperation';_this23.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
|
|
931
|
-
_this23.state.Metadata.Hash=_this23.Hash;_this23.state.Metadata.UUID=_this23.UUID;_this23.name=typeof _this23.options.Name=='string'?_this23.options.Name:"Unnamed Operation ".concat(_this23.state.Metadata.UUID);_this23.log=_assertThisInitialized(_this23);return _this23;}_createClass2(FableOperation,[{key:"writeOperationLog",value:function writeOperationLog(pLogLevel,pLogText,pLogObject){this.state.Log.push("".concat(new Date().toUTCString()," [").concat(pLogLevel,"]: ").concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Log.push(JSON.stringify(pLogObject));}}},{key:"writeOperationErrors",value:function writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}},{key:"trace",value:function trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}},{key:"debug",value:function debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}},{key:"info",value:function info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}},{key:"warn",value:function warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}},{key:"error",value:function error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}},{key:"fatal",value:function fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}}]);return FableOperation;}(libFableServiceBase);module.exports=FableOperation;},{"../Fable-ServiceManager.js":39,"./Fable-Service-Operation-DefaultSettings.js":51}],53:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var libSimpleGet=require('simple-get');var libCookie=require('cookie');var FableServiceRestClient=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableServiceRestClient,_libFableServiceBase7);var _super16=_createSuper(FableServiceRestClient);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this24;_classCallCheck2(this,FableServiceRestClient);_this24=_super16.call(this,pFable,pOptions,pServiceHash);_this24.TraceLog=false;if(_this24.options.TraceLog||_this24.fable.TraceLog){_this24.TraceLog=true;}_this24.dataFormat=_this24.fable.services.DataFormat;_this24.serviceType='RestClient';_this24.cookie=false;// This is a function that can be overridden, to allow the management
|
|
931
|
+
_this23.state.Metadata.Hash=_this23.Hash;_this23.state.Metadata.UUID=_this23.UUID;_this23.name=typeof _this23.options.Name=='string'?_this23.options.Name:"Unnamed Operation ".concat(_this23.state.Metadata.UUID);_this23.log=_assertThisInitialized(_this23);return _this23;}_createClass2(FableOperation,[{key:"writeOperationLog",value:function writeOperationLog(pLogLevel,pLogText,pLogObject){this.state.Log.push("".concat(new Date().toUTCString()," [").concat(pLogLevel,"]: ").concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Log.push(JSON.stringify(pLogObject));}}},{key:"writeOperationErrors",value:function writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}},{key:"trace",value:function trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}},{key:"debug",value:function debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}},{key:"info",value:function info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}},{key:"warn",value:function warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}},{key:"error",value:function error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}},{key:"fatal",value:function fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}}]);return FableOperation;}(libFableServiceBase);module.exports=FableOperation;},{"../Fable-ServiceManager.js":39,"./Fable-Service-Operation-DefaultSettings.js":51}],53:[function(require,module,exports){(function(Buffer){(function(){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var libSimpleGet=require('simple-get');var libCookie=require('cookie');var FableServiceRestClient=/*#__PURE__*/function(_libFableServiceBase7){_inherits(FableServiceRestClient,_libFableServiceBase7);var _super16=_createSuper(FableServiceRestClient);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this24;_classCallCheck2(this,FableServiceRestClient);_this24=_super16.call(this,pFable,pOptions,pServiceHash);_this24.TraceLog=false;if(_this24.options.TraceLog||_this24.fable.TraceLog){_this24.TraceLog=true;}_this24.dataFormat=_this24.fable.services.DataFormat;_this24.serviceType='RestClient';_this24.cookie=false;// This is a function that can be overridden, to allow the management
|
|
932
932
|
// of the request options before they are passed to the request library.
|
|
933
|
-
_this24.prepareRequestOptions=function(pOptions){return pOptions;};return _this24;}_createClass2(FableServiceRestClient,[{key:"prepareCookies",value:function prepareCookies(pRequestOptions){if(this.cookie){var tmpCookieObject=this.cookie;if(!pRequestOptions.hasOwnProperty('headers')){pRequestOptions.headers={};}var tmpCookieKeys=Object.keys(tmpCookieObject);if(tmpCookieKeys.length>0){// Only grab the first for now.
|
|
933
|
+
_this24.prepareRequestOptions=function(pOptions){return pOptions;};return _this24;}_createClass2(FableServiceRestClient,[{key:"simpleGet",get:function get(){return libSimpleGet;}},{key:"prepareCookies",value:function prepareCookies(pRequestOptions){if(this.cookie){var tmpCookieObject=this.cookie;if(!pRequestOptions.hasOwnProperty('headers')){pRequestOptions.headers={};}var tmpCookieKeys=Object.keys(tmpCookieObject);if(tmpCookieKeys.length>0){// Only grab the first for now.
|
|
934
934
|
pRequestOptions.headers.cookie=libCookie.serialize(tmpCookieKeys[0],tmpCookieObject[tmpCookieKeys[0]]);}}return pRequestOptions;}},{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|
|
935
935
|
var tmpOptions=this.prepareCookies(pOptions);return this.prepareRequestOptions(tmpOptions);}},{key:"executeChunkedRequest",value:function executeChunkedRequest(pOptions,fCallback){var _this25=this;var tmpOptions=this.preRequest(pOptions);tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this25.TraceLog){var tmpConnectTime=_this25.fable.log.getTimeStamp();_this25.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this25.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpData='';pResponse.on('data',function(pChunk){// For JSON, the chunk is the serialized object.
|
|
936
|
-
if(_this25.TraceLog){var tmpChunkTime=_this25.fable.log.getTimeStamp();_this25.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this25.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpData+=pChunk;});pResponse.on('end',function(){if(_this25.TraceLog){var tmpCompletionTime=_this25.fable.log.getTimeStamp();_this25.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpData.length,"b received in ").concat(_this25.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpData);});});}},{key:"
|
|
936
|
+
if(_this25.TraceLog){var tmpChunkTime=_this25.fable.log.getTimeStamp();_this25.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this25.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpData+=pChunk;});pResponse.on('end',function(){if(_this25.TraceLog){var tmpCompletionTime=_this25.fable.log.getTimeStamp();_this25.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpData.length,"b received in ").concat(_this25.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpData);});});}},{key:"executeChunkedRequestBinary",value:function executeChunkedRequestBinary(pOptions,fCallback){var _this26=this;var tmpOptions=this.preRequest(pOptions);tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}tmpOptions.json=false;tmpOptions.encoding=null;return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this26.TraceLog){var tmpConnectTime=_this26.fable.log.getTimeStamp();_this26.fable.log.debug("--> ".concat(tmpOptions.method," connected in ").concat(_this26.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpDataBuffer=false;pResponse.on('data',function(pChunk){// For JSON, the chunk is the serialized object.
|
|
937
|
+
if(_this26.TraceLog){var tmpChunkTime=_this26.fable.log.getTimeStamp();_this26.fable.log.debug("--> ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this26.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}// TODO: Potentially create a third option that streams this to a file? So it doesn't have to hold it all in memory.
|
|
938
|
+
if(!tmpDataBuffer){tmpDataBuffer=Buffer.from(pChunk);}else{tmpDataBuffer=Buffer.concat([tmpDataBuffer,pChunk]);}});pResponse.on('end',function(){if(_this26.TraceLog){var tmpCompletionTime=_this26.fable.log.getTimeStamp();_this26.fable.log.debug("==> ".concat(tmpOptions.method," completed data size ").concat(tmpDataBuffer.length,"b received in ").concat(_this26.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,tmpDataBuffer);});});}},{key:"executeJSONRequest",value:function executeJSONRequest(pOptions,fCallback){var _this27=this;pOptions.json=true;var tmpOptions=this.preRequest(pOptions);if(!tmpOptions.hasOwnProperty('headers')){tmpOptions.headers={};}/* Automated headers break some APIs
|
|
937
939
|
if (!tmpOptions.headers.hasOwnProperty('Content-Type'))
|
|
938
940
|
{
|
|
939
941
|
tmpOptions.headers['Content-Type'] = 'application/json';
|
|
940
942
|
}
|
|
941
|
-
*/tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," JSON request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(
|
|
943
|
+
*/tmpOptions.RequestStartTime=this.fable.log.getTimeStamp();if(this.TraceLog){this.fable.log.debug("Beginning ".concat(tmpOptions.method," JSON request to ").concat(tmpOptions.url," at ").concat(tmpOptions.RequestStartTime));}return libSimpleGet(tmpOptions,function(pError,pResponse){if(pError){return fCallback(pError,pResponse);}if(_this27.TraceLog){var tmpConnectTime=_this27.fable.log.getTimeStamp();_this27.fable.log.debug("--> JSON ".concat(tmpOptions.method," connected in ").concat(_this27.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpConnectTime),"ms code ").concat(pResponse.statusCode));}var tmpJSONData='';pResponse.on('data',function(pChunk){if(_this27.TraceLog){var tmpChunkTime=_this27.fable.log.getTimeStamp();_this27.fable.log.debug("--> JSON ".concat(tmpOptions.method," data chunk size ").concat(pChunk.length,"b received in ").concat(_this27.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpChunkTime),"ms"));}tmpJSONData+=pChunk;});pResponse.on('end',function(){if(_this27.TraceLog){var tmpCompletionTime=_this27.fable.log.getTimeStamp();_this27.fable.log.debug("==> JSON ".concat(tmpOptions.method," completed - received in ").concat(_this27.dataFormat.formatTimeDelta(tmpOptions.RequestStartTime,tmpCompletionTime),"ms"));}return fCallback(pError,pResponse,JSON.parse(tmpJSONData));});});}},{key:"getJSON",value:function getJSON(pOptionsOrURL,fCallback){var tmpRequestOptions=_typeof(pOptionsOrURL)=='object'?pOptionsOrURL:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeJSONRequest(tmpRequestOptions,fCallback);}},{key:"putJSON",value:function putJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("PUT JSON Error Invalid options object"));}pOptions.method='PUT';return this.executeJSONRequest(pOptions,fCallback);}},{key:"postJSON",value:function postJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("POST JSON Error Invalid options object"));}pOptions.method='POST';return this.executeJSONRequest(pOptions,fCallback);}},{key:"patchJSON",value:function patchJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("PATCH JSON Error Invalid options object"));}pOptions.method='PATCH';return this.executeJSONRequest(pOptions,fCallback);}},{key:"headJSON",value:function headJSON(pOptions,fCallback){if(_typeof(pOptions.body)!='object'){return fCallback(new Error("HEAD JSON Error Invalid options object"));}pOptions.method='HEAD';return this.executeJSONRequest(pOptions,fCallback);}},{key:"delJSON",value:function delJSON(pOptions,fCallback){pOptions.method='DELETE';return this.executeJSONRequest(pOptions,fCallback);}},{key:"getRawText",value:function getRawText(pOptionsOrURL,fCallback){var tmpRequestOptions=_typeof(pOptionsOrURL)=='object'?pOptionsOrURL:{};if(typeof pOptionsOrURL=='string'){tmpRequestOptions.url=pOptionsOrURL;}tmpRequestOptions.method='GET';return this.executeChunkedRequest(tmpRequestOptions,fCallback);}}]);return FableServiceRestClient;}(libFableServiceBase);module.exports=FableServiceRestClient;}).call(this);}).call(this,require("buffer").Buffer);},{"../Fable-ServiceManager.js":39,"buffer":19,"cookie":24,"simple-get":84}],54:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var FableServiceTemplate=/*#__PURE__*/function(_libFableServiceBase8){_inherits(FableServiceTemplate,_libFableServiceBase8);var _super17=_createSuper(FableServiceTemplate);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
942
944
|
// string-based template with code snippets into simple executable pieces,
|
|
943
945
|
// with the added twist of returning a precompiled function ready to go.
|
|
944
946
|
//
|
|
@@ -947,16 +949,16 @@ if(_this25.TraceLog){var tmpChunkTime=_this25.fable.log.getTimeStamp();_this25.f
|
|
|
947
949
|
//
|
|
948
950
|
// This is an implementation of that.
|
|
949
951
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
950
|
-
function FableServiceTemplate(pFable,pOptions,pServiceHash){var
|
|
952
|
+
function FableServiceTemplate(pFable,pOptions,pServiceHash){var _this28;_classCallCheck2(this,FableServiceTemplate);_this28=_super17.call(this,pFable,pOptions,pServiceHash);_this28.serviceType='Template';// These are the exact regex's used in lodash/underscore
|
|
951
953
|
// TODO: Switch this to precedent
|
|
952
|
-
|
|
954
|
+
_this28.Matchers={Evaluate:/<%([\s\S]+?)%>/g,Interpolate:/<%=([\s\S]+?)%>/g,Escaper:/\\|'|\r|\n|\t|\u2028|\u2029/g,Unescaper:/\\(\\|'|r|n|t|u2028|u2029)/g,// This is how underscore does it, so we are keeping it for now.
|
|
953
955
|
GuaranteedNonMatch:/.^/};// This is a helper for the escaper and unescaper functions.
|
|
954
956
|
// Right now we are going to keep what underscore is doing, but, not forever.
|
|
955
|
-
|
|
957
|
+
_this28.templateEscapes={'\\':'\\',"'":"'",'r':'\r','\r':'r','n':'\n','\n':'n','t':'\t','\t':'t','u2028':"\u2028","\u2028":'u2028','u2029':"\u2029","\u2029":'u2029'};// This is defined as such to underscore that it is a dynamic programming
|
|
956
958
|
// function on this class.
|
|
957
|
-
|
|
959
|
+
_this28.renderFunction=false;_this28.templateString=false;return _this28;}_createClass2(FableServiceTemplate,[{key:"renderTemplate",value:function renderTemplate(pData){return this.renderFunction(pData);}},{key:"templateFunction",value:function templateFunction(pData){var fRenderTemplateBound=this.renderTemplate.bind(this);return fRenderTemplateBound;}},{key:"buildTemplateFunction",value:function buildTemplateFunction(pTemplateText,pData){var _this29=this;// For now this is being kept in a weird form ... this is to mimic the old
|
|
958
960
|
// underscore code until this is rewritten using precedent.
|
|
959
|
-
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(
|
|
961
|
+
this.TemplateSource="__p+='"+pTemplateText.replace(this.Matchers.Escaper,function(pMatch){return"\\".concat(_this29.templateEscapes[pMatch]);}).replace(this.Matchers.Interpolate||this.Matchers.GuaranteedNonMatch,function(pMatch,pCode){return"'+\n(".concat(decodeURIComponent(pCode),")+\n'");}).replace(this.Matchers.Evaluate||this.Matchers.GuaranteedNonMatch,function(pMatch,pCode){return"';\n".concat(decodeURIComponent(pCode),"\n;__p+='");})+"';\n";this.TemplateSource="with(pTemplateDataObject||{}){\n".concat(this.TemplateSource,"}\n");this.TemplateSource="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n".concat(this.TemplateSource,"return __p;\n");this.renderFunction=new Function('pTemplateDataObject',this.TemplateSource);if(typeof pData!='undefined'){return this.renderFunction(pData);}// Provide the compiled function source as a convenience for build time
|
|
960
962
|
// precompilation.
|
|
961
963
|
this.TemplateSourceCompiled='function(obj){\n'+this.TemplateSource+'}';return this.templateFunction();}}]);return FableServiceTemplate;}(libFableServiceBase);module.exports=FableServiceTemplate;},{"../Fable-ServiceManager.js":39}],55:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;// TODO: These are still pretty big -- consider the smaller polyfills
|
|
962
964
|
var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('async.eachlimit');var FableServiceUtility=/*#__PURE__*/function(_libFableServiceBase9){_inherits(FableServiceUtility,_libFableServiceBase9);var _super18=_createSuper(FableServiceUtility);// Underscore and lodash have a behavior, _.template, which compiles a
|
|
@@ -968,8 +970,8 @@ var libAsyncWaterfall=require('async.waterfall');var libAsyncEachLimit=require('
|
|
|
968
970
|
//
|
|
969
971
|
// This is an implementation of that.
|
|
970
972
|
// TODO: Make this use precedent, add configuration, add debugging.
|
|
971
|
-
function FableServiceUtility(pFable,pOptions,pServiceHash){var
|
|
972
|
-
|
|
973
|
+
function FableServiceUtility(pFable,pOptions,pServiceHash){var _this30;_classCallCheck2(this,FableServiceUtility);_this30=_super18.call(this,pFable,pOptions,pServiceHash);_this30.templates={};// These two functions are used extensively throughout
|
|
974
|
+
_this30.waterfall=libAsyncWaterfall;_this30.eachLimit=libAsyncEachLimit;return _this30;}// Underscore and lodash have a behavior, _.extend, which merges objects.
|
|
973
975
|
// Now that es6 gives us this, use the native thingy.
|
|
974
976
|
// Nevermind, the native thing is not stable enough across environments
|
|
975
977
|
// Basic shallow copy
|
|
@@ -1046,12 +1048,12 @@ var cleanWrapCharacters=function cleanWrapCharacters(pCharacter,pString){if(pStr
|
|
|
1046
1048
|
*
|
|
1047
1049
|
* @class ManyfestHashTranslation
|
|
1048
1050
|
*/var ManyfestHashTranslation=/*#__PURE__*/function(){function ManyfestHashTranslation(pInfoLog,pErrorLog){_classCallCheck2(this,ManyfestHashTranslation);// Wire in logging
|
|
1049
|
-
this.logInfo=typeof pInfoLog==='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog==='function'?pErrorLog:libSimpleLog;this.translationTable={};}_createClass2(ManyfestHashTranslation,[{key:"translationCount",value:function translationCount(){return Object.keys(this.translationTable).length;}},{key:"addTranslation",value:function addTranslation(pTranslation){var
|
|
1051
|
+
this.logInfo=typeof pInfoLog==='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog==='function'?pErrorLog:libSimpleLog;this.translationTable={};}_createClass2(ManyfestHashTranslation,[{key:"translationCount",value:function translationCount(){return Object.keys(this.translationTable).length;}},{key:"addTranslation",value:function addTranslation(pTranslation){var _this31=this;// This adds a translation in the form of:
|
|
1050
1052
|
// { "SourceHash": "DestinationHash", "SecondSourceHash":"SecondDestinationHash" }
|
|
1051
|
-
if(_typeof(pTranslation)!='object'){this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(_typeof(pTranslation)));return false;}var tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(function(pTranslationSource){if(typeof pTranslation[pTranslationSource]!='string'){
|
|
1053
|
+
if(_typeof(pTranslation)!='object'){this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(_typeof(pTranslation)));return false;}var tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(function(pTranslationSource){if(typeof pTranslation[pTranslationSource]!='string'){_this31.logError("Hash translation addTranslation expected a translation destination hash for [".concat(pTranslationSource,"] to be a string but the referrant was a ").concat(_typeof(pTranslation[pTranslationSource])));}else{_this31.translationTable[pTranslationSource]=pTranslation[pTranslationSource];}});}},{key:"removeTranslationHash",value:function removeTranslationHash(pTranslationHash){if(this.translationTable.hasOwnProperty(pTranslationHash)){delete this.translationTable[pTranslationHash];}}// This removes translations.
|
|
1052
1054
|
// If passed a string, just removes the single one.
|
|
1053
1055
|
// If passed an object, it does all the source keys.
|
|
1054
|
-
},{key:"removeTranslation",value:function removeTranslation(pTranslation){var
|
|
1056
|
+
},{key:"removeTranslation",value:function removeTranslation(pTranslation){var _this32=this;if(typeof pTranslation=='string'){this.removeTranslationHash(pTranslation);return true;}else if(_typeof(pTranslation)=='object'){var tmpTranslationSources=Object.keys(pTranslation);tmpTranslationSources.forEach(function(pTranslationSource){_this32.removeTranslation(pTranslationSource);});return true;}else{this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(_typeof(pTranslation)));return false;}}},{key:"clearTranslations",value:function clearTranslations(){this.translationTable={};}},{key:"translate",value:function translate(pTranslation){if(this.translationTable.hasOwnProperty(pTranslation)){return this.translationTable[pTranslation];}else{return pTranslation;}}}]);return ManyfestHashTranslation;}();module.exports=ManyfestHashTranslation;},{"./Manyfest-LogToConsole.js":61}],61:[function(require,module,exports){/**
|
|
1055
1057
|
* @author <steven@velozo.com>
|
|
1056
1058
|
*/ /**
|
|
1057
1059
|
* Manyfest simple logging shim (for browser and dependency-free running)
|
|
@@ -1599,9 +1601,9 @@ var tmpDescriptorAddresses=Object.keys(tmpSource);tmpDescriptorAddresses.forEach
|
|
|
1599
1601
|
* Manyfest object address-based descriptions and manipulations.
|
|
1600
1602
|
*
|
|
1601
1603
|
* @class Manyfest
|
|
1602
|
-
*/var Manyfest=/*#__PURE__*/function(_libFableServiceProvi7){_inherits(Manyfest,_libFableServiceProvi7);var _super19=_createSuper(Manyfest);function Manyfest(pFable,pManifest,pServiceHash){var
|
|
1603
|
-
|
|
1604
|
-
|
|
1604
|
+
*/var Manyfest=/*#__PURE__*/function(_libFableServiceProvi7){_inherits(Manyfest,_libFableServiceProvi7);var _super19=_createSuper(Manyfest);function Manyfest(pFable,pManifest,pServiceHash){var _this33;_classCallCheck2(this,Manyfest);if(pFable===undefined){_this33=_super19.call(this,{});}else{_this33=_super19.call(this,pFable,pManifest,pServiceHash);}_this33.serviceType='Manifest';// Wire in logging
|
|
1605
|
+
_this33.logInfo=libSimpleLog;_this33.logError=libSimpleLog;// Create an object address resolver and map in the functions
|
|
1606
|
+
_this33.objectAddressCheckAddressExists=new libObjectAddressCheckAddressExists(_this33.logInfo,_this33.logError);_this33.objectAddressGetValue=new libObjectAddressGetValue(_this33.logInfo,_this33.logError);_this33.objectAddressSetValue=new libObjectAddressSetValue(_this33.logInfo,_this33.logError);_this33.objectAddressDeleteValue=new libObjectAddressDeleteValue(_this33.logInfo,_this33.logError);if(!_this33.options.hasOwnProperty('defaultValues')){_this33.options.defaultValues={"String":"","Number":0,"Float":0.0,"Integer":0,"Boolean":false,"Binary":0,"DateTime":0,"Array":[],"Object":{},"Null":null};}if(!_this33.options.hasOwnProperty('strict')){_this33.options.strict=false;}_this33.scope=undefined;_this33.elementAddresses=undefined;_this33.elementHashes=undefined;_this33.elementDescriptors=undefined;_this33.reset();if(_typeof(_this33.options)==='object'){_this33.loadManifest(_this33.options);}_this33.schemaManipulations=new libSchemaManipulation(_this33.logInfo,_this33.logError);_this33.objectAddressGeneration=new libObjectAddressGeneration(_this33.logInfo,_this33.logError);_this33.hashTranslations=new libHashTranslation(_this33.logInfo,_this33.logError);return _possibleConstructorReturn(_this33);}/*************************************************************************
|
|
1605
1607
|
* Schema Manifest Loading, Reading, Manipulation and Serialization Functions
|
|
1606
1608
|
*/ // Reset critical manifest properties
|
|
1607
1609
|
_createClass2(Manyfest,[{key:"reset",value:function reset(){this.scope='DEFAULT';this.elementAddresses=[];this.elementHashes={};this.elementDescriptors={};}},{key:"clone",value:function clone(){// Make a copy of the options in-place
|
|
@@ -1652,13 +1654,13 @@ return null;}}}// Enumerate through the schema and populate default values if th
|
|
|
1652
1654
|
},{key:"populateDefaults",value:function populateDefaults(pObject,pOverwriteProperties){return this.populateObject(pObject,pOverwriteProperties,// This just sets up a simple filter to see if there is a default set.
|
|
1653
1655
|
function(pDescriptor){return pDescriptor.hasOwnProperty('Default');});}// Forcefully populate all values even if they don't have defaults.
|
|
1654
1656
|
// Based on type, this can do unexpected things.
|
|
1655
|
-
},{key:"populateObject",value:function populateObject(pObject,pOverwriteProperties,fFilter){var
|
|
1657
|
+
},{key:"populateObject",value:function populateObject(pObject,pOverwriteProperties,fFilter){var _this34=this;// Automatically create an object if one isn't passed in.
|
|
1656
1658
|
var tmpObject=_typeof(pObject)==='object'?pObject:{};// Default to *NOT OVERWRITING* properties
|
|
1657
1659
|
var tmpOverwriteProperties=typeof pOverwriteProperties=='undefined'?false:pOverwriteProperties;// This is a filter function, which is passed the schema and allows complex filtering of population
|
|
1658
1660
|
// The default filter function just returns true, populating everything.
|
|
1659
|
-
var tmpFilterFunction=typeof fFilter=='function'?fFilter:function(pDescriptor){return true;};this.elementAddresses.forEach(function(pAddress){var tmpDescriptor=
|
|
1661
|
+
var tmpFilterFunction=typeof fFilter=='function'?fFilter:function(pDescriptor){return true;};this.elementAddresses.forEach(function(pAddress){var tmpDescriptor=_this34.getDescriptor(pAddress);// Check the filter function to see if this is an address we want to set the value for.
|
|
1660
1662
|
if(tmpFilterFunction(tmpDescriptor)){// If we are overwriting properties OR the property does not exist
|
|
1661
|
-
if(tmpOverwriteProperties||!
|
|
1663
|
+
if(tmpOverwriteProperties||!_this34.checkAddressExists(tmpObject,pAddress)){_this34.setValueAtAddress(tmpObject,pAddress,_this34.getDefaultValue(tmpDescriptor));}}});return tmpObject;}}]);return Manyfest;}(libFableServiceProviderBase);;module.exports=Manyfest;},{"./Manyfest-HashTranslation.js":60,"./Manyfest-LogToConsole.js":61,"./Manyfest-ObjectAddress-CheckAddressExists.js":62,"./Manyfest-ObjectAddress-DeleteValue.js":63,"./Manyfest-ObjectAddress-GetValue.js":64,"./Manyfest-ObjectAddress-SetValue.js":65,"./Manyfest-ObjectAddressGeneration.js":66,"./Manyfest-SchemaManipulation.js":68,"fable-serviceproviderbase":33}],70:[function(require,module,exports){var wrappy=require('wrappy');module.exports=wrappy(once);module.exports.strict=wrappy(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,'once',{value:function value(){return once(this);},configurable:true});Object.defineProperty(Function.prototype,'onceStrict',{value:function value(){return onceStrict(this);},configurable:true});});function once(fn){var f=function f(){if(f.called)return f.value;f.called=true;return f.value=fn.apply(this,arguments);};f.called=false;return f;}function onceStrict(fn){var f=function f(){if(f.called)throw new Error(f.onceError);f.called=true;return f.value=fn.apply(this,arguments);};var name=fn.name||'Function wrapped with `once`';f.onceError=name+" shouldn't be called more than once";f.called=false;return f;}},{"wrappy":109}],71:[function(require,module,exports){(function(process){(function(){// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
|
1662
1664
|
// transplited with Babel
|
|
1663
1665
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
1664
1666
|
//
|
|
@@ -1743,57 +1745,57 @@ preDotState===0||// The (right-most) trimmed path component is exactly '..'
|
|
|
1743
1745
|
preDotState===1&&startDot===end-1&&startDot===startPart+1){if(end!==-1){if(startPart===0&&isAbsolute)ret.base=ret.name=path.slice(1,end);else ret.base=ret.name=path.slice(startPart,end);}}else{if(startPart===0&&isAbsolute){ret.name=path.slice(1,startDot);ret.base=path.slice(1,end);}else{ret.name=path.slice(startPart,startDot);ret.base=path.slice(startPart,end);}ret.ext=path.slice(startDot,end);}if(startPart>0)ret.dir=path.slice(0,startPart-1);else if(isAbsolute)ret.dir='/';return ret;},sep:'/',delimiter:':',win32:null,posix:null};posix.posix=posix;module.exports=posix;}).call(this);}).call(this,require('_process'));},{"_process":77}],72:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var defaultPictSettings={Name:'DefaultPictApplication',// The main "viewport" is the view that is used to host our application
|
|
1744
1746
|
MainViewportViewIdentifier:'Default-View',MainViewportRenderableHash:false,MainViewportDestinationAddress:false,MainViewportDefaultDataAddress:false,// Whether or not we should automatically render the main viewport after we initialize the pict application
|
|
1745
1747
|
AutoSolveAfterInitialize:true,AutoRenderMainViewportViewAfterInitialize:true,Manifests:{},// The prefix to prepend on all template destination hashes
|
|
1746
|
-
IdentifierAddressPrefix:'PICT-'};var PictApplication=/*#__PURE__*/function(_libFableServiceBase10){_inherits(PictApplication,_libFableServiceBase10);var _super20=_createSuper(PictApplication);function PictApplication(pFable,pOptions,pServiceHash){var
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
var tmpManifestKeys=Object.keys(
|
|
1750
|
-
var tmpManifestKey=tmpManifestKeys[i];
|
|
1748
|
+
IdentifierAddressPrefix:'PICT-'};var PictApplication=/*#__PURE__*/function(_libFableServiceBase10){_inherits(PictApplication,_libFableServiceBase10);var _super20=_createSuper(PictApplication);function PictApplication(pFable,pOptions,pServiceHash){var _this35;_classCallCheck2(this,PictApplication);var tmpOptions=Object.assign({},JSON.parse(JSON.stringify(defaultPictSettings)),pOptions);_this35=_super20.call(this,pFable,tmpOptions,pServiceHash);_this35.serviceType='PictApplication';// Convenience and consistency naming
|
|
1749
|
+
_this35.pict=_this35.fable;// Wire in the essential Pict state
|
|
1750
|
+
_this35.AppData=_this35.fable.AppData;_this35.initializeTimestamp=false;_this35.lastSolvedTimestamp=false;// Load all the manifests for the application
|
|
1751
|
+
var tmpManifestKeys=Object.keys(_this35.options.Manifests);if(tmpManifestKeys.length>0){for(var i=0;i<tmpManifestKeys.length;i++){// Load each manifest
|
|
1752
|
+
var tmpManifestKey=tmpManifestKeys[i];_this35.fable.serviceManager.instantiateServiceProvider('Manifest',_this35.options.Manifests[tmpManifestKey],tmpManifestKey);}}return _this35;}_createClass2(PictApplication,[{key:"onBeforeSolve",value:function onBeforeSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onBeforeSolve:"));}return true;}},{key:"onBeforeSolveAsync",value:function onBeforeSolveAsync(fCallback){this.onBeforeSolve();return fCallback();}},{key:"onSolve",value:function onSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onSolve:"));}return true;}},{key:"onSolveAsync",value:function onSolveAsync(fCallback){this.onSolve();return fCallback();}},{key:"solve",value:function solve(){if(this.pict.LogNoisiness>2){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," executing solve() function..."));}this.onBeforeSolve();// Now walk through any loaded views and initialize them as well.
|
|
1751
1753
|
var tmpLoadedViews=Object.keys(this.pict.views);var tmpViewsToSolve=[];for(var i=0;i<tmpLoadedViews.length;i++){var tmpView=this.pict.views[tmpLoadedViews[i]];if(tmpView.options.AutoInitialize){tmpViewsToSolve.push(tmpView);}}// Sort the views by their priority (if they are all priority 0, it will end up being add order due to JSON Object Property Key order stuff)
|
|
1752
|
-
tmpViewsToSolve.sort(function(a,b){return a.options.AutoInitializeOrdinal-b.options.AutoInitializeOrdinal;});for(var _i12=0;_i12<tmpViewsToSolve.length;_i12++){tmpViewsToSolve[_i12].solve();}this.onSolve();this.onAfterSolve();this.lastSolvedTimestamp=this.fable.log.getTimeStamp();return true;}},{key:"solveAsync",value:function solveAsync(fCallback){var
|
|
1754
|
+
tmpViewsToSolve.sort(function(a,b){return a.options.AutoInitializeOrdinal-b.options.AutoInitializeOrdinal;});for(var _i12=0;_i12<tmpViewsToSolve.length;_i12++){tmpViewsToSolve[_i12].solve();}this.onSolve();this.onAfterSolve();this.lastSolvedTimestamp=this.fable.log.getTimeStamp();return true;}},{key:"solveAsync",value:function solveAsync(fCallback){var _this36=this;var tmpAnticipate=this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Anticipate');tmpAnticipate.anticipate(this.onBeforeSolveAsync.bind(this));// Walk through any loaded views and solve them as well.
|
|
1753
1755
|
var tmpLoadedViews=Object.keys(this.pict.views);var tmpViewsToSolve=[];for(var i=0;i<tmpLoadedViews.length;i++){var tmpView=this.pict.views[tmpLoadedViews[i]];if(tmpView.options.AutoSolveWithApp){tmpViewsToSolve.push(tmpView);}}// Sort the views by their priority (if they are all priority 0, it will end up being add order due to JSON Object Property Key order stuff)
|
|
1754
|
-
tmpViewsToSolve.sort(function(a,b){return a.options.AutoSolveOrdinal-b.options.AutoSolveOrdinal;});for(var _i13=0;_i13<tmpViewsToSolve.length;_i13++){tmpAnticipate.anticipate(tmpViewsToSolve[_i13].solveAsync.bind(tmpViewsToSolve[_i13]));}tmpAnticipate.anticipate(this.onSolveAsync.bind(this));tmpAnticipate.anticipate(this.onAfterSolveAsync.bind(this));tmpAnticipate.wait(function(pError){if(
|
|
1756
|
+
tmpViewsToSolve.sort(function(a,b){return a.options.AutoSolveOrdinal-b.options.AutoSolveOrdinal;});for(var _i13=0;_i13<tmpViewsToSolve.length;_i13++){tmpAnticipate.anticipate(tmpViewsToSolve[_i13].solveAsync.bind(tmpViewsToSolve[_i13]));}tmpAnticipate.anticipate(this.onSolveAsync.bind(this));tmpAnticipate.anticipate(this.onAfterSolveAsync.bind(this));tmpAnticipate.wait(function(pError){if(_this36.pict.LogNoisiness>2){_this36.log.trace("PictApp [".concat(_this36.UUID,"]::[").concat(_this36.Hash,"] ").concat(_this36.options.Name," solveAsync() complete."));}_this36.lastSolvedTimestamp=_this36.fable.log.getTimeStamp();return fCallback(pError);});}},{key:"onAfterSolve",value:function onAfterSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onAfterSolve:"));}return true;}},{key:"onAfterSolveAsync",value:function onAfterSolveAsync(fCallback){this.onAfterSolve();return fCallback();}},{key:"onBeforeInitialize",value:function onBeforeInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onBeforeInitialize:"));}return true;}},{key:"onBeforeInitializeAsync",value:function onBeforeInitializeAsync(fCallback){this.onBeforeInitialize();return fCallback();}},{key:"onInitialize",value:function onInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onInitialize:"));}return true;}},{key:"onInitializeAsync",value:function onInitializeAsync(fCallback){this.onInitialize();return fCallback();}},{key:"initialize",value:function initialize(){if(!this.initializeTimestamp){this.onBeforeInitialize();this.onInitialize();// Now walk through any loaded views and initialize them as well.
|
|
1755
1757
|
var tmpLoadedViews=Object.keys(this.pict.views);var tmpViewsToInitialize=[];for(var i=0;i<tmpLoadedViews.length;i++){var tmpView=this.pict.views[tmpLoadedViews[i]];if(tmpView.options.AutoInitialize){tmpViewsToInitialize.push(tmpView);}}// Sort the views by their priority (if they are all priority 0, it will end up being add order due to JSON Object Property Key order stuff)
|
|
1756
1758
|
tmpViewsToInitialize.sort(function(a,b){return a.options.AutoInitializeOrdinal-b.options.AutoInitializeOrdinal;});for(var _i14=0;_i14<tmpViewsToInitialize.length;_i14++){tmpViewsToInitialize[_i14].initialize();}this.onAfterInitialize();if(this.options.AutoSolveAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto solving after initialization..."));}// Solve the template synchronously
|
|
1757
1759
|
this.solve();}// Now check and see if we should automatically render as well
|
|
1758
1760
|
if(this.options.AutoRenderMainViewportViewAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto rendering after initialization..."));}// Render the template synchronously
|
|
1759
|
-
this.render();}this.initializeTimestamp=this.fable.log.getTimeStamp();return true;}else{this.log.warn("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," initialize called but initialization is already completed. Aborting."));return false;}}},{key:"initializeAsync",value:function initializeAsync(fCallBack){var
|
|
1761
|
+
this.render();}this.initializeTimestamp=this.fable.log.getTimeStamp();return true;}else{this.log.warn("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," initialize called but initialization is already completed. Aborting."));return false;}}},{key:"initializeAsync",value:function initializeAsync(fCallBack){var _this37=this;if(!this.initializeTimestamp){var tmpAnticipate=this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('Anticipate');if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," beginning initialization..."));}tmpAnticipate.anticipate(this.onBeforeInitializeAsync.bind(this));tmpAnticipate.anticipate(this.onInitializeAsync.bind(this));// Now walk through any loaded views and initialize them as well.
|
|
1760
1762
|
// TODO: Some optimization cleverness could be gained by grouping them into a parallelized async operation, by ordinal.
|
|
1761
1763
|
var tmpLoadedViews=Object.keys(this.pict.views);var tmpViewsToInitialize=[];for(var i=0;i<tmpLoadedViews.length;i++){var tmpView=this.pict.views[tmpLoadedViews[i]];if(tmpView.options.AutoInitialize){tmpViewsToInitialize.push(tmpView);}}// Sort the views by their priority
|
|
1762
1764
|
// If they are all the default priority 0, it will end up being add order due to JSON Object Property Key order stuff
|
|
1763
|
-
tmpViewsToInitialize.sort(function(a,b){return a.options.AutoInitializeOrdinal-b.options.AutoInitializeOrdinal;});for(var _i15=0;_i15<tmpViewsToInitialize.length;_i15++){var _tmpView=tmpViewsToInitialize[_i15];tmpAnticipate.anticipate(_tmpView.initializeAsync.bind(_tmpView));}tmpAnticipate.anticipate(this.onAfterInitializeAsync.bind(this));if(this.options.AutoSolveAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto solving (asynchronously) after initialization..."));}tmpAnticipate.anticipate(this.solveAsync.bind(this));}if(this.options.AutoRenderMainViewportViewAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto rendering (asynchronously) after initialization..."));}tmpAnticipate.anticipate(this.renderMainViewportAsync.bind(this));}tmpAnticipate.wait(function(pError){
|
|
1765
|
+
tmpViewsToInitialize.sort(function(a,b){return a.options.AutoInitializeOrdinal-b.options.AutoInitializeOrdinal;});for(var _i15=0;_i15<tmpViewsToInitialize.length;_i15++){var _tmpView=tmpViewsToInitialize[_i15];tmpAnticipate.anticipate(_tmpView.initializeAsync.bind(_tmpView));}tmpAnticipate.anticipate(this.onAfterInitializeAsync.bind(this));if(this.options.AutoSolveAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto solving (asynchronously) after initialization..."));}tmpAnticipate.anticipate(this.solveAsync.bind(this));}if(this.options.AutoRenderMainViewportViewAfterInitialize){if(this.pict.LogNoisiness>1){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," auto rendering (asynchronously) after initialization..."));}tmpAnticipate.anticipate(this.renderMainViewportAsync.bind(this));}tmpAnticipate.wait(function(pError){_this37.initializeTimestamp=_this37.fable.log.getTimeStamp();if(_this37.pict.LogNoisiness>2){_this37.log.trace("PictApp [".concat(_this37.UUID,"]::[").concat(_this37.Hash,"] ").concat(_this37.options.Name," initialization complete."));}return fCallBack();});}else{this.log.warn("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," async initialize called but initialization is already completed. Aborting."));// TODO: Should this be an error?
|
|
1764
1766
|
return fCallback();}}},{key:"onAfterInitialize",value:function onAfterInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," onAfterInitialize:"));}return true;}},{key:"onAfterInitializeAsync",value:function onAfterInitializeAsync(fCallback){this.onAfterInitialize();return fCallback();}},{key:"render",value:function render(pViewIdentifier,pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress){var tmpViewIdentifier=typeof pViewIdentifier==='undefined'?this.options.MainViewportViewIdentifier:pViewIdentifier;var tmpRenderableHash=typeof pRenderableHash==='undefined'?this.options.MainViewportRenderableHash:pRenderableHash;var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='undefined'?this.options.MainViewportDestinationAddress:pRenderDestinationAddress;var tmpTemplateDataAddress=typeof pTemplateDataAddress==='undefined'?this.options.MainViewportDefaultDataAddress:pTemplateDataAddress;// Now get the view (by hash) from the loaded views
|
|
1765
1767
|
var tmpView=typeof tmpViewIdentifier==='string'?this.servicesMap.PictView[tmpViewIdentifier]:false;if(!tmpView){this.log.error("PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," could not render from View ").concat(tmpViewIdentifier," because it is not a valid view."));return false;}return tmpView.render(tmpRenderableHash,tmpRenderDestinationAddress,tmpTemplateDataAddress);}},{key:"renderMainViewport",value:function renderMainViewport(){return this.render(this.options.MainViewportViewIdentifier,this.options.MainViewportRenderableHash,this.options.MainViewportDestinationAddress,this.options.MainViewportDefaultDataAddress);}},{key:"renderAsync",value:function renderAsync(pViewIdentifier,pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress,fCallback){var tmpViewIdentifier=typeof pViewIdentifier==='undefined'?this.options.MainViewportViewIdentifier:pViewIdentifier;var tmpRenderableHash=typeof pRenderableHash==='undefined'?this.options.MainViewportRenderableHash:pRenderableHash;var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='undefined'?this.options.MainViewportDestinationAddress:pRenderDestinationAddress;var tmpTemplateDataAddress=typeof pTemplateDataAddress==='undefined'?this.options.MainViewportDefaultDataAddress:pTemplateDataAddress;var tmpView=typeof tmpViewIdentifier==='string'?this.servicesMap.PictView[tmpViewIdentifier]:false;if(!tmpView){var tmpErrorMessage="PictApp [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," could not asynchronously render from View ").concat(tmpViewIdentifier," because it is not a valid view.");if(this.pict.LogNoisiness>3){this.log.error(tmpErrorMessage);}return fCallback(new Error(tmpErrorMessage));}return tmpView.renderAsync(tmpRenderableHash,tmpRenderDestinationAddress,tmpTemplateDataAddress,fCallback);}},{key:"renderMainViewportAsync",value:function renderMainViewportAsync(fCallback){return this.renderAsync(this.options.MainViewportViewIdentifier,this.options.MainViewportRenderableHash,this.options.MainViewportDestinationAddress,this.options.MainViewportDefaultDataAddress,fCallback);}}]);return PictApplication;}(libFableServiceBase);module.exports=PictApplication;},{"fable-serviceproviderbase":33}],73:[function(require,module,exports){var libFableServiceBase=require('fable-serviceproviderbase');var defaultPictViewSettings={DefaultRenderable:false,DefaultDestinationAddress:false,DefaultTemplateRecordAddress:false,ViewIdentifier:false,// If this is set to true, when the App initializes this will.
|
|
1766
1768
|
// After the App initializes, initialize will be called as soon as it's added.
|
|
1767
1769
|
AutoInitialize:true,AutoInitializeOrdinal:0,// If this is set to true, when the App autorenders (on load) this will.
|
|
1768
1770
|
// After the App initializes, render will be called as soon as it's added.
|
|
1769
|
-
AutoRender:true,AutoRenderOrdinal:0,AutoSolveWithApp:true,AutoSolveOrdinal:0,CSSHash:false,CSS:false,CSSProvider:false,CSSPriority:500,Templates:[],DefaultTemplates:[],Renderables:[],Manifests:{}};var PictView=/*#__PURE__*/function(_libFableServiceBase11){_inherits(PictView,_libFableServiceBase11);var _super21=_createSuper(PictView);function PictView(pFable,pOptions,pServiceHash){var
|
|
1770
|
-
var tmpOptions=Object.assign({},JSON.parse(JSON.stringify(defaultPictViewSettings)),pOptions);
|
|
1771
|
-
|
|
1772
|
-
|
|
1771
|
+
AutoRender:true,AutoRenderOrdinal:0,AutoSolveWithApp:true,AutoSolveOrdinal:0,CSSHash:false,CSS:false,CSSProvider:false,CSSPriority:500,Templates:[],DefaultTemplates:[],Renderables:[],Manifests:{}};var PictView=/*#__PURE__*/function(_libFableServiceBase11){_inherits(PictView,_libFableServiceBase11);var _super21=_createSuper(PictView);function PictView(pFable,pOptions,pServiceHash){var _this38;_classCallCheck2(this,PictView);// Intersect default options, parent constructor, service information
|
|
1772
|
+
var tmpOptions=Object.assign({},JSON.parse(JSON.stringify(defaultPictViewSettings)),pOptions);_this38=_super21.call(this,pFable,tmpOptions,pServiceHash);if(!_this38.options.ViewIdentifier){_this38.options.ViewIdentifier="AutoViewID-".concat(_this38.fable.getUUID());}_this38.serviceType='PictView';// Convenience and consistency naming
|
|
1773
|
+
_this38.pict=_this38.fable;// Wire in the essential Pict application state
|
|
1774
|
+
_this38.AppData=_this38.pict.AppData;_this38.initializeTimestamp=false;_this38.lastSolvedTimestamp=false;_this38.lastRenderedTimestamp=false;// Load all templates from the array in the options
|
|
1773
1775
|
// Templates are in the form of {Hash:'Some-Template-Hash',Template:'Template content',Source:'TemplateSource'}
|
|
1774
|
-
for(var i=0;i<
|
|
1776
|
+
for(var i=0;i<_this38.options.Templates.length;i++){var tmpTemplate=_this38.options.Templates[i];if(!tmpTemplate.hasOwnProperty('Hash')||!tmpTemplate.hasOwnProperty('Template')){_this38.log.error("PictView [".concat(_this38.UUID,"]::[").concat(_this38.Hash,"] ").concat(_this38.options.ViewIdentifier," could not load Template ").concat(i," in the options array."),tmpTemplate);}else{if(!tmpTemplate.Source){tmpTemplate.Source="PictView [".concat(_this38.UUID,"]::[").concat(_this38.Hash,"] ").concat(_this38.options.ViewIdentifier," options object.");}_this38.pict.TemplateProvider.addTemplate(tmpTemplate.Hash,tmpTemplate.Template,tmpTemplate.Source);}}// Load all default templates from the array in the options
|
|
1775
1777
|
// Templates are in the form of {Prefix:'',Postfix:'-List-Row',Template:'Template content',Source:'TemplateSourceString'}
|
|
1776
|
-
for(var _i16=0;_i16<
|
|
1777
|
-
if(
|
|
1778
|
+
for(var _i16=0;_i16<_this38.options.DefaultTemplates.length;_i16++){var tmpDefaultTemplate=_this38.options.DefaultTemplates[_i16];if(!tmpDefaultTemplate.hasOwnProperty('Postfix')||!tmpDefaultTemplate.hasOwnProperty('Template')){_this38.log.error("PictView [".concat(_this38.UUID,"]::[").concat(_this38.Hash,"] ").concat(_this38.options.ViewIdentifier," could not load Default Template ").concat(_i16," in the options array."),tmpDefaultTemplate);}else{if(!tmpDefaultTemplate.Source){tmpDefaultTemplate.Source="PictView [".concat(_this38.UUID,"]::[").concat(_this38.Hash,"] ").concat(_this38.options.ViewIdentifier," options object.");}_this38.pict.TemplateProvider.addDefaultTemplate(tmpDefaultTemplate.Prefix,tmpDefaultTemplate.Postfix,tmpDefaultTemplate.Template,tmpDefaultTemplate.Source);}}// Load the CSS if it's available
|
|
1779
|
+
if(_this38.options.CSS){var tmpCSSHash=_this38.options.CSSHash?_this38.options.CSSHash:"View-".concat(_this38.options.ViewIdentifier);var tmpCSSProvider=_this38.options.CSSProvider?_this38.options.CSSProvider:tmpCSSHash;_this38.pict.CSSMap.addCSS(tmpCSSHash,_this38.options.CSS,tmpCSSProvider,_this38.options.CSSPriority);}// Load all renderables
|
|
1778
1780
|
// Renderables are launchable renderable instructions with templates
|
|
1779
1781
|
// They look as such: {Identifier:'ContentEntry', TemplateHash:'Content-Entry-Section-Main', ContentDestinationAddress:'#ContentSection', RecordAddress:'AppData.Content.DefaultText', ManifestTransformation:'ManyfestHash', ManifestDestinationAddress:'AppData.Content.DataToTransformContent'}
|
|
1780
1782
|
// The only parts that are necessary are Identifier and Template
|
|
1781
1783
|
// A developer can then do render('ContentEntry') and it just kinda works. Or they can override the ContentDestinationAddress
|
|
1782
|
-
|
|
1784
|
+
_this38.renderables={};for(var _i17=0;_i17<_this38.options.Renderables.length;_i17++){var tmpRenderable=_this38.options.Renderables[_i17];_this38.addRenderable(_this38.options.Renderables[_i17]);}return _this38;}_createClass2(PictView,[{key:"addRenderable",value:function addRenderable(pRenderableHash,pTemplateHash,pDefaultTemplateDataAddress,pDefaultDestinationAddress,pRenderMethod){var tmpRenderable=false;if(_typeof(pRenderableHash)=='object'){// The developer passed in the renderable as an object.
|
|
1783
1785
|
// Use theirs instead!
|
|
1784
|
-
tmpRenderable=pRenderableHash;}else{var tmpRenderMethod=typeof pRenderMethod!=='string'?pRenderMethod:'replace';tmpRenderable={RenderableHash:pRenderableHash,TemplateHash:pTemplateHash,DefaultTemplateDataAddress:pDefaultTemplateDataAddress,DefaultDestinationAddress:pDefaultDestinationAddress,RenderMethod:tmpRenderMethod};}if(typeof tmpRenderable.RenderableHash!='string'||typeof tmpRenderable.TemplateHash!='string'){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not load Renderable; RenderableHash or TemplateHash are invalid."),tmpRenderable);}else{if(this.pict.LogNoisiness>0){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," adding renderable [").concat(tmpRenderable.RenderableHash,"] pointed to template ").concat(tmpRenderable.TemplateHash,"."));}this.renderables[tmpRenderable.RenderableHash]=tmpRenderable;}}},{key:"onBeforeSolve",value:function onBeforeSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeSolve:"));}return true;}},{key:"onBeforeSolveAsync",value:function onBeforeSolveAsync(fCallback){this.onBeforeSolve();return fCallback();}},{key:"onSolve",value:function onSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onSolve:"));}return true;}},{key:"onSolveAsync",value:function onSolveAsync(fCallback){this.onSolve();return fCallback();}},{key:"solve",value:function solve(){if(this.pict.LogNoisiness>2){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," executing solve() function..."));}this.onBeforeSolve();this.onSolve();this.onAfterSolve();this.lastSolvedTimestamp=this.pict.log.getTimeStamp();return true;}},{key:"solveAsync",value:function solveAsync(fCallback){var
|
|
1786
|
+
tmpRenderable=pRenderableHash;}else{var tmpRenderMethod=typeof pRenderMethod!=='string'?pRenderMethod:'replace';tmpRenderable={RenderableHash:pRenderableHash,TemplateHash:pTemplateHash,DefaultTemplateDataAddress:pDefaultTemplateDataAddress,DefaultDestinationAddress:pDefaultDestinationAddress,RenderMethod:tmpRenderMethod};}if(typeof tmpRenderable.RenderableHash!='string'||typeof tmpRenderable.TemplateHash!='string'){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not load Renderable; RenderableHash or TemplateHash are invalid."),tmpRenderable);}else{if(this.pict.LogNoisiness>0){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," adding renderable [").concat(tmpRenderable.RenderableHash,"] pointed to template ").concat(tmpRenderable.TemplateHash,"."));}this.renderables[tmpRenderable.RenderableHash]=tmpRenderable;}}},{key:"onBeforeSolve",value:function onBeforeSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeSolve:"));}return true;}},{key:"onBeforeSolveAsync",value:function onBeforeSolveAsync(fCallback){this.onBeforeSolve();return fCallback();}},{key:"onSolve",value:function onSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onSolve:"));}return true;}},{key:"onSolveAsync",value:function onSolveAsync(fCallback){this.onSolve();return fCallback();}},{key:"solve",value:function solve(){if(this.pict.LogNoisiness>2){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," executing solve() function..."));}this.onBeforeSolve();this.onSolve();this.onAfterSolve();this.lastSolvedTimestamp=this.pict.log.getTimeStamp();return true;}},{key:"solveAsync",value:function solveAsync(fCallback){var _this39=this;var tmpAnticipate=this.pict.serviceManager.instantiateServiceProviderWithoutRegistration('Anticipate');tmpAnticipate.anticipate(this.onBeforeSolveAsync.bind(this));tmpAnticipate.anticipate(this.onSolveAsync.bind(this));tmpAnticipate.anticipate(this.onAfterSolveAsync.bind(this));tmpAnticipate.wait(function(pError){if(_this39.pict.LogNoisiness>2){_this39.log.trace("PictView [".concat(_this39.UUID,"]::[").concat(_this39.Hash,"] ").concat(_this39.options.ViewIdentifier," solveAsync() complete."));}_this39.lastSolvedTimestamp=_this39.pict.log.getTimeStamp();return fCallback(pError);});}},{key:"onAfterSolve",value:function onAfterSolve(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onAfterSolve:"));}return true;}},{key:"onAfterSolveAsync",value:function onAfterSolveAsync(fCallback){this.onAfterSolve();return fCallback();}},{key:"onBeforeInitialize",value:function onBeforeInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeInitialize:"));}return true;}},{key:"onBeforeInitializeAsync",value:function onBeforeInitializeAsync(fCallback){this.onBeforeInitialize();return fCallback();}},{key:"onInitialize",value:function onInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onInitialize:"));}return true;}},{key:"onInitializeAsync",value:function onInitializeAsync(fCallback){this.onInitialize();return fCallback();}},{key:"initialize",value:function initialize(){if(!this.initializeTimestamp){this.onBeforeInitialize();this.onInitialize();this.onAfterInitialize();this.initializeTimestamp=this.pict.log.getTimeStamp();return true;}else{this.log.warn("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," initialize called but initialization is already completed. Aborting."));return false;}}},{key:"initializeAsync",value:function initializeAsync(fCallback){var _this40=this;if(!this.initializeTimestamp){var tmpAnticipate=this.pict.serviceManager.instantiateServiceProviderWithoutRegistration('Anticipate');if(this.pict.LogNoisiness>0){this.log.info("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," beginning initialization..."));}tmpAnticipate.anticipate(this.onBeforeInitializeAsync.bind(this));tmpAnticipate.anticipate(this.onInitializeAsync.bind(this));tmpAnticipate.anticipate(this.onAfterInitializeAsync.bind(this));tmpAnticipate.wait(function(pError){_this40.initializeTimestamp=_this40.pict.log.getTimeStamp();if(_this40.pict.LogNoisiness>0){_this40.log.info("PictView [".concat(_this40.UUID,"]::[").concat(_this40.Hash,"] ").concat(_this40.options.ViewIdentifier," initialization complete."));}return fCallback();});}else{this.log.warn("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," async initialize called but initialization is already completed. Aborting."));// TODO: Should this be an error?
|
|
1785
1787
|
return fCallback();}}},{key:"onAfterInitialize",value:function onAfterInitialize(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onAfterInitialize:"));}return true;}},{key:"onAfterInitializeAsync",value:function onAfterInitializeAsync(fCallback){this.onAfterInitialize();return fCallback();}},{key:"onBeforeRender",value:function onBeforeRender(pRenderable,pRenderDestinationAddress,pData){// Overload this to mess with stuff before the content gets generated from the template
|
|
1786
1788
|
if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onBeforeRender:"));}return true;}},{key:"onBeforeRenderAsync",value:function onBeforeRenderAsync(pRenderable,pRenderDestinationAddress,pData,fCallback){this.onBeforeRender(pRenderable,pRenderDestinationAddress,pData);return fCallback();}},{key:"render",value:function render(pRenderable,pRenderDestinationAddress,pTemplateDataAddress){var tmpRenderableHash=typeof pRenderable==='string'?pRenderable:typeof this.options.DefaultRenderable=='string'?this.options.DefaultRenderable:false;if(!tmpRenderableHash){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it is not a valid renderable."));return false;}var tmpRenderable=this.renderables[tmpRenderableHash];if(!tmpRenderable){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist."));return false;}var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='string'?pRenderDestinationAddress:typeof tmpRenderable.ContentDestinationAddress==='string'?tmpRenderable.ContentDestinationAddress:typeof this.options.DefaultDestinationAddress==='string'?this.options.DefaultDestinationAddress:false;if(!tmpRenderDestinationAddress){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not have a valid destination address."));return false;}var tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.DefaultTemplateRecordAddress==='string'?tmpRenderable.DefaultTemplateRecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;var tmpData=typeof tmpDataAddress==='string'?this.pict.DataProvider.getDataByAddress(tmpDataAddress):undefined;// Execute the developer-overridable pre-render behavior
|
|
1787
1789
|
this.onBeforeRender(tmpRenderable,tmpRenderDestinationAddress,tmpData);// Generate the content output from the template and data
|
|
1788
1790
|
var tmpContent=this.pict.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData);// Assign the content to the destination address
|
|
1789
1791
|
switch(tmpRenderable.RenderMethod){case'append':this.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,tmpContent);break;case'prepend':this.pict.ContentAssignment.prependContent(tmpRenderDestinationAddress,tmpContent);break;case'append_once':// Try to find the content in the destination address
|
|
1790
1792
|
var tmpExistingContent=this.pict.ContentAssignment.getElement("#".concat(tmpRenderableHash));if(tmpExistingContent.length<1){this.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,tmpContent);}case'replace':default:this.pict.ContentAssignment.assignContent(tmpRenderDestinationAddress,tmpContent);break;}// Execute the developer-overridable post-render behavior
|
|
1791
|
-
this.onAfterRender(tmpRenderable,tmpRenderDestinationAddress,tmpData,tmpContent);this.lastRenderedTimestamp=this.pict.log.getTimeStamp();}},{key:"renderAsync",value:function renderAsync(pRenderable,pRenderDestinationAddress,pTemplateDataAddress,fCallback){var
|
|
1793
|
+
this.onAfterRender(tmpRenderable,tmpRenderDestinationAddress,tmpData,tmpContent);this.lastRenderedTimestamp=this.pict.log.getTimeStamp();}},{key:"renderAsync",value:function renderAsync(pRenderable,pRenderDestinationAddress,pTemplateDataAddress,fCallback){var _this41=this;var tmpRenderableHash=typeof pRenderable==='string'?pRenderable:typeof this.options.DefaultRenderable=='string'?this.options.DefaultRenderable:false;if(!tmpRenderableHash){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not asynchronously render ").concat(tmpRenderableHash," (param ").concat(pRenderable,"because it is not a valid renderable."));return fCallback(Error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not asynchronously render ").concat(tmpRenderableHash," (param ").concat(pRenderable,"because it is not a valid renderable.")));}var tmpRenderable=this.renderables[tmpRenderableHash];if(!tmpRenderable){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist."));return fCallback(Error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not exist.")));}var tmpRenderDestinationAddress=typeof pRenderDestinationAddress==='string'?pRenderDestinationAddress:typeof tmpRenderable.ContentDestinationAddress==='string'?tmpRenderable.ContentDestinationAddress:typeof this.options.DefaultDestinationAddress==='string'?this.options.DefaultDestinationAddress:false;if(!tmpRenderDestinationAddress){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it does not have a valid destination address."));return fCallback(Error("Could not render ".concat(tmpRenderableHash)));}var tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.DefaultTemplateRecordAddress==='string'?tmpRenderable.DefaultTemplateRecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;var tmpData=typeof tmpDataAddress==='string'?this.pict.DataProvider.getDataByAddress(tmpDataAddress):undefined;// Execute the developer-overridable pre-render behavior
|
|
1792
1794
|
this.onBeforeRender(tmpRenderable,tmpRenderDestinationAddress,tmpData);// Render the template (asynchronously)
|
|
1793
|
-
this.pict.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData,function(pError,pContent){if(pError){
|
|
1794
|
-
switch(tmpRenderable.RenderMethod){case'append':
|
|
1795
|
-
var tmpExistingContent=
|
|
1796
|
-
|
|
1795
|
+
this.pict.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData,function(pError,pContent){if(pError){_this41.log.error("PictView [".concat(_this41.UUID,"]::[").concat(_this41.Hash,"] ").concat(_this41.options.ViewIdentifier," could not render (asynchronously) ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it did not parse the template."),pError);return fCallback(pError);}// Assign the content to the destination address
|
|
1796
|
+
switch(tmpRenderable.RenderMethod){case'append':_this41.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,pContent);break;case'prepend':_this41.pict.ContentAssignment.prependContent(tmpRenderDestinationAddress,pContent);break;case'append_once':// Try to find the content in the destination address
|
|
1797
|
+
var tmpExistingContent=_this41.pict.ContentAssignment.getElement("#".concat(tmpRenderableHash));if(tmpExistingContent.length<1){_this41.pict.ContentAssignment.appendContent(tmpRenderDestinationAddress,pContent);}case'replace':default:_this41.pict.ContentAssignment.assignContent(tmpRenderDestinationAddress,pContent);break;}// Execute the developer-overridable post-render behavior
|
|
1798
|
+
_this41.onAfterRender(tmpRenderable,tmpRenderDestinationAddress,tmpData,pContent);_this41.lastRenderedTimestamp=_this41.pict.log.getTimeStamp();return fCallback(null,pContent);});}},{key:"onAfterRender",value:function onAfterRender(){if(this.pict.LogNoisiness>3){this.log.trace("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," onAfterRender:"));}return true;}},{key:"onAfterRenderAsync",value:function onAfterRenderAsync(fCallback){this.onAfterRender();return fCallback();}}]);return PictView;}(libFableServiceBase);module.exports=PictView;},{"fable-serviceproviderbase":33}],74:[function(require,module,exports){/**
|
|
1797
1799
|
* Precedent Meta-Templating
|
|
1798
1800
|
*
|
|
1799
1801
|
* @license MIT
|
|
@@ -3009,20 +3011,20 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
3009
3011
|
// This makes sure that own properties are retained, so that
|
|
3010
3012
|
// decorations and such are not lost along the way.
|
|
3011
3013
|
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],110:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],111:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var defaultConfiguration={// This is the address for the <script /> tag that contains the CSS.
|
|
3012
|
-
CSSElementAddress:'#PICT-CSS'};var PictCSS=/*#__PURE__*/function(_libFableServiceBase12){_inherits(PictCSS,_libFableServiceBase12);var _super22=_createSuper(PictCSS);function PictCSS(pFable,pOptions,pServiceHash){var
|
|
3013
|
-
if(typeof
|
|
3014
|
+
CSSElementAddress:'#PICT-CSS'};var PictCSS=/*#__PURE__*/function(_libFableServiceBase12){_inherits(PictCSS,_libFableServiceBase12);var _super22=_createSuper(PictCSS);function PictCSS(pFable,pOptions,pServiceHash){var _this42;_classCallCheck2(this,PictCSS);_this42=_super22.call(this,pFable,pOptions,pServiceHash);// No merging of options necessary
|
|
3015
|
+
if(typeof _this42.options.CSSElementAddress==='undefined'){_this42.options.CSSElementAddress=defaultConfiguration.CSSElementAddress;}_this42.inlineCSSMap={};return _this42;}// Add a CSS fragment to the CSS map (each view can have its own CSS fragment)
|
|
3014
3016
|
// Hash is shared across all views, so if 10 views all load the "My-Table-View" fragment, it will only be loaded once.
|
|
3015
|
-
_createClass2(PictCSS,[{key:"addCSS",value:function addCSS(pHash,pContent,pPriority,pProvider){var tmpPriority=typeof pPriority!=='undefined'?pPriority:1000;var tmpProvidor=typeof pProvider==='string'?pProvider:'Unknown';this.inlineCSSMap[pHash]={Hash:pHash,Content:pContent,Provider:tmpProvidor,Priority:tmpPriority};}},{key:"removeCSS",value:function removeCSS(pHash){delete this.inlineCSSMap[pHash];}},{key:"generateCSS",value:function generateCSS(){var
|
|
3016
|
-
tmpCSSHashes.sort(function(a,b){return
|
|
3017
|
-
},{key:"injectCSS",value:function injectCSS(){this.services.ContentAssignment.assignContent(this.options.CSSElementAddress,this.generateCSS());}}]);return PictCSS;}(libFableServiceBase);module.exports=PictCSS;},{"fable":40}],112:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictContentAssignment=/*#__PURE__*/function(_libFableServiceBase13){_inherits(PictContentAssignment,_libFableServiceBase13);var _super23=_createSuper(PictContentAssignment);function PictContentAssignment(pFable,pOptions,pServiceHash){var
|
|
3018
|
-
|
|
3019
|
-
if(typeof window.document!='undefined'&&typeof window.document.querySelectorAll=='function'){
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3017
|
+
_createClass2(PictCSS,[{key:"addCSS",value:function addCSS(pHash,pContent,pPriority,pProvider){var tmpPriority=typeof pPriority!=='undefined'?pPriority:1000;var tmpProvidor=typeof pProvider==='string'?pProvider:'Unknown';this.inlineCSSMap[pHash]={Hash:pHash,Content:pContent,Provider:tmpProvidor,Priority:tmpPriority};}},{key:"removeCSS",value:function removeCSS(pHash){delete this.inlineCSSMap[pHash];}},{key:"generateCSS",value:function generateCSS(){var _this43=this;var tmpCSS='';var tmpCSSHashes=Object.keys(this.inlineCSSMap);// Sort the hashes by Priority
|
|
3018
|
+
tmpCSSHashes.sort(function(a,b){return _this43.inlineCSSMap[a].Priority-_this43.inlineCSSMap[b].Priority;});for(var i=0;i<tmpCSSHashes.length;i++){var tmpCSSFragment=this.inlineCSSMap[tmpCSSHashes[i]];var tmpCSSComment=tmpCSSFragment.Hash;if(tmpCSSFragment.Hash!=tmpCSSFragment.Provider){tmpCSSComment="".concat(tmpCSSComment," from ").concat(tmpCSSFragment.Provider);}tmpCSS+="/* ".concat(tmpCSSComment," */\n").concat(tmpCSSFragment.Content,"\n");}return tmpCSS;}// Inject the CSS into the magic DOM element for it
|
|
3019
|
+
},{key:"injectCSS",value:function injectCSS(){this.services.ContentAssignment.assignContent(this.options.CSSElementAddress,this.generateCSS());}}]);return PictCSS;}(libFableServiceBase);module.exports=PictCSS;},{"fable":40}],112:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictContentAssignment=/*#__PURE__*/function(_libFableServiceBase13){_inherits(PictContentAssignment,_libFableServiceBase13);var _super23=_createSuper(PictContentAssignment);function PictContentAssignment(pFable,pOptions,pServiceHash){var _this44;_classCallCheck2(this,PictContentAssignment);_this44=_super23.call(this,pFable,pOptions,pServiceHash);_this44.serviceType='PictContentAssignment';// Check to see if we are running in a browser
|
|
3020
|
+
_this44.inBrowser=false;_this44.hasDocument=false;if((typeof window==="undefined"?"undefined":_typeof(window))=='object'){_this44.inBrowser=true;// Now check that the browser has a document object
|
|
3021
|
+
if(typeof window.document!='undefined'&&typeof window.document.querySelectorAll=='function'){_this44.hasDocument=true;}}// If we're in a browser, check to see if jQuery is available.
|
|
3022
|
+
_this44.hasJquery=false;_this44.jQuery=false;if(_this44.inBrowser&&typeof window.jQuery!=='undefined'){_this44.hasJquery=true;}// API Consumers can craft their own assign function
|
|
3023
|
+
_this44.customAssignFunction=false;// API Consumers can also craft their own prepend function
|
|
3024
|
+
_this44.customPrependFunction=false;// API Consumers can also craft their own append function
|
|
3025
|
+
_this44.customAppendFunction=false;// API Consumers can also craft their own read function
|
|
3026
|
+
_this44.customReadFunction=false;// API Consumers can even craft their own get element function.
|
|
3027
|
+
_this44.customGetElementFunction=false;return _this44;}_createClass2(PictContentAssignment,[{key:"getElement",value:function getElement(pAddress){if(this.customGetElementFunction){return this.customGetElementFunction(pAddress);}else if(this.hasJquery){var tmpElements=window.jQuery(pAddress);if(tmpElements.length==0){return[];}else{// TODO: This isn't the most efficient method, but it is the most compatible.
|
|
3026
3028
|
var tmpElementSet=[];for(var i=0;i<tmpElements.length;i++){tmpElementSet.push(tmpElements[0]);}return tmpElementSet;}}else if(this.inBrowser&&this.hasDocument){return window.document.querySelectorAll(pAddress);}else{// Just log it out for now
|
|
3027
3029
|
this.log.trace("PICT Content GET ELEMENT for [".concat(pAddress,"] will return empty because none of the browser methods are available"));return[];}}},{key:"assignContent",value:function assignContent(pAddress,pContent){if(this.customAssignFunction){return this.customAssignFunction(pAddress,pContent);}else if(this.hasJquery){// Get the element
|
|
3028
3030
|
var tmpTargetElement=window.jQuery(pAddress);// Should we ensure we matched 1 and exactly 1 element?
|
|
@@ -3038,21 +3040,21 @@ this.log.trace("PICT Content READ from [".concat(pAddress,"]..."));return'';}}},
|
|
|
3038
3040
|
var tmpTargetElement=window.jQuery(pAddress);tmpTargetElement.addClass(pClass);}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);for(var i=0;i<tmpTargetElementSet.length;i++){tmpTargetElementSet[i].classList.add(pClass);}}else{this.log.trace("PICT Content ADDCLASS to [".concat(pAddress,"]:"),pClass);}}},{key:"removeClass",value:function removeClass(pAddress,pClass){if(this.customRemoveClassFunction){return this.customRemoveClassFunction(pAddress,pClass);}else if(this.hasJquery){// Get the element
|
|
3039
3041
|
var tmpTargetElement=window.jQuery(pAddress);tmpTargetElement.removeClass(pClass);}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);for(var i=0;i<tmpTargetElementSet.length;i++){tmpTargetElementSet[i].classList.remove(pClass);}}else{this.log.trace("PICT Content REMOVECLASS from [".concat(pAddress,"]:"),pClass);}}},{key:"toggleClass",value:function toggleClass(pAddress,pClass){// STUB
|
|
3040
3042
|
}},{key:"hasClass",value:function hasClass(pAddress,pClass){// STUB
|
|
3041
|
-
}}]);return PictContentAssignment;}(libFableServiceBase);module.exports=PictContentAssignment;},{"fable":40}],113:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictDataProvider=/*#__PURE__*/function(_libFableServiceBase14){_inherits(PictDataProvider,_libFableServiceBase14);var _super24=_createSuper(PictDataProvider);function PictDataProvider(pFable,pOptions,pServiceHash){var
|
|
3043
|
+
}}]);return PictContentAssignment;}(libFableServiceBase);module.exports=PictContentAssignment;},{"fable":40}],113:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictDataProvider=/*#__PURE__*/function(_libFableServiceBase14){_inherits(PictDataProvider,_libFableServiceBase14);var _super24=_createSuper(PictDataProvider);function PictDataProvider(pFable,pOptions,pServiceHash){var _this45;_classCallCheck2(this,PictDataProvider);_this45=_super24.call(this,pFable,pOptions,pServiceHash);_this45.serviceType='PictDataProvider';return _this45;}_createClass2(PictDataProvider,[{key:"getDataByAddress",value:function getDataByAddress(pAddress,pData){var tmpData=typeof pData==='undefined'?{}:pData;return this.fable.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},pAddress);}}]);return PictDataProvider;}(libFableServiceBase);module.exports=PictDataProvider;},{"fable":40}],114:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictMeadowEntityProvider=/*#__PURE__*/function(_libFableServiceBase15){_inherits(PictMeadowEntityProvider,_libFableServiceBase15);var _super25=_createSuper(PictMeadowEntityProvider);function PictMeadowEntityProvider(pFable,pOptions,pServiceHash){var _this46;_classCallCheck2(this,PictMeadowEntityProvider);_this46=_super25.call(this,pFable,pOptions,pServiceHash);_defineProperty2(_assertThisInitialized(_this46),"getEntitySet",function(pEntity,pMeadowFilterExpression,fCallback){var _this47=this;this.initializeCache(pEntity);// TODO: Should we test for too many record IDs here by string length?
|
|
3042
3044
|
// FBL~ID${pDestinationEntity}~INN~${tmpIDRecordsCommaSeparated}
|
|
3043
3045
|
// Discard anything from the cache that has expired or is over size.
|
|
3044
|
-
this.cache[pEntity].prune(function(){var tmpCountOptions={url:"".concat(
|
|
3045
|
-
tmpDownloadURIFragments.push("".concat(
|
|
3046
|
-
|
|
3047
|
-
return fDownloadCallback(pDownloadError);});},function(pFullDownloadError){return fCallback(pFullDownloadError,tmpEntitySet);});});});});
|
|
3046
|
+
this.cache[pEntity].prune(function(){var tmpCountOptions={url:"".concat(_this47.options.urlPrefix).concat(pEntity,"s/Count/FilteredTo/").concat(pMeadowFilterExpression)};tmpCountOptions=_this47.prepareRequestOptions(tmpCountOptions);return _this47.restClient.getJSON(tmpCountOptions,function(pError,pResponse,pBody){if(pError){_this47.log.error("Error getting bulk entity count of [".concat(pEntity,"] filtered to [").concat(pMeadowFilterExpression,"] from server [").concat(tmpCountOptions.url,"]: ").concat(pError));return fCallback(pError);}var tmpRecordCount=0;if(pBody.Count){tmpRecordCount=pBody.Count;}var tmpDownloadURIFragments=[];var tmpDownloadBatchSize=_this47.options.downloadBatchSize;for(var i=0;i<tmpRecordCount/tmpDownloadBatchSize;i++){// Generate each of the URI fragments to download
|
|
3047
|
+
tmpDownloadURIFragments.push("".concat(_this47.options.urlPrefix).concat(pEntity,"s/FilteredTo/").concat(pMeadowFilterExpression,"/").concat(i*tmpDownloadBatchSize,"/").concat(tmpDownloadBatchSize));}var tmpEntitySet=[];// Now run these in series (it's possible to parallelize but no reason to)
|
|
3048
|
+
_this47.fable.Utility.eachLimit(tmpDownloadURIFragments,1,function(pURIFragment,fDownloadCallback){var tmpOptions={url:"".concat(_this47.options.urlPrefix).concat(pURIFragment)};tmpOptions=_this47.prepareRequestOptions(tmpOptions);_this47.restClient.getJSON(pURIFragment,function(pDownloadError,pDownloadResponse,pDownloadBody){tmpEntitySet=tmpEntitySet.concat(pDownloadBody);// Should we be caching each record?
|
|
3049
|
+
return fDownloadCallback(pDownloadError);});},function(pFullDownloadError){return fCallback(pFullDownloadError,tmpEntitySet);});});});});_this46.serviceType='PictMeadowProvider';if(_this46.fable.settings.PictDefaultURLPrefix){_this46.options.urlPrefix=_this46.fable.settings.PictDefaultURLPrefix;}else if(!_this46.options.urlPrefix){_this46.options.urlPrefix='/1.0/';}if(_this46.fable.settings.PictDefaultDownloadBatchSize){_this46.options.downloadBatchSize=_this46.fable.settings.PictDefaultDownloadBatchSize;}else if(!_this46.options.downloadBatchSize){_this46.options.downloadBatchSize=100;}_this46.restClient=_this46.fable.serviceManager.instantiateServiceProviderWithoutRegistration('RestClient');_this46.cache={};_this46.prepareRequestOptions=function(pOptions){return pOptions;};return _this46;}_createClass2(PictMeadowEntityProvider,[{key:"initializeCache",value:function initializeCache(pEntity){// This should not be happening as often as it's happening.
|
|
3048
3050
|
if(!this.cache.hasOwnProperty(pEntity)){this.cache[pEntity]=this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('ObjectCache');// TODO: Make this a configuration?
|
|
3049
3051
|
// For now cache for 30 seconds.
|
|
3050
|
-
this.cache[pEntity].maxAge=30000;this.cache[pEntity].maxLength=10000;this.fable.Bundle[pEntity]=this.cache[pEntity].RecordMap;}}},{key:"getEntity",value:function getEntity(pEntity,pIDRecord,fCallback){var
|
|
3051
|
-
this.cache[pEntity].prune(function(){var tmpPossibleRecord=
|
|
3052
|
+
this.cache[pEntity].maxAge=30000;this.cache[pEntity].maxLength=10000;this.fable.Bundle[pEntity]=this.cache[pEntity].RecordMap;}}},{key:"getEntity",value:function getEntity(pEntity,pIDRecord,fCallback){var _this48=this;this.initializeCache(pEntity);// Discard anything from the cache that has expired or is over size.
|
|
3053
|
+
this.cache[pEntity].prune(function(){var tmpPossibleRecord=_this48.cache[pEntity].read(pIDRecord);if(tmpPossibleRecord){return tmpPossibleRecord;}var tmpOptions={url:"".concat(_this48.options.urlPrefix).concat(pEntity,"/").concat(pIDRecord)};tmpOptions=_this48.prepareRequestOptions(tmpOptions);return _this48.restClient.getJSON(tmpOptions,function(pError,pResponse,pBody){if(pBody){_this48.cache[pEntity].put(pBody,pIDRecord);}return fCallback(pError,pBody);});});}}]);return PictMeadowEntityProvider;}(libFableServiceBase);module.exports=PictMeadowEntityProvider;},{"fable":40}],115:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictTemplateProvider=/*#__PURE__*/function(_libFableServiceBase16){_inherits(PictTemplateProvider,_libFableServiceBase16);var _super26=_createSuper(PictTemplateProvider);function PictTemplateProvider(pFable,pOptions,pServiceHash){var _this49;_classCallCheck2(this,PictTemplateProvider);_this49=_super26.call(this,pFable,pOptions,pServiceHash);_this49.serviceType='PictTemplateProvider';_this49.templates={};_this49.templateSources={};// Default templates are stored by prefix.
|
|
3052
3054
|
// The longest prefix match is used.
|
|
3053
3055
|
// Case sensitive.
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
+
_this49.defaultTemplates=[];// This function can be overloaded to load templates from a database, in a page or other source.
|
|
3057
|
+
_this49.loadTemplateFunction=function(pTemplateHash){return false;};return _this49;}_createClass2(PictTemplateProvider,[{key:"addTemplate",value:function addTemplate(pTemplateHash,pTemplate,pTemplateSource){this.templates[pTemplateHash]=pTemplate;if(typeof pTemplateSource=='string'){this.templateSources[pTemplateHash]=pTemplateSource;}else{this.templateSources[pTemplateHash]="Direct addTemplate('".concat(pTemplateHash,"') function load into PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"]");}}},{key:"addDefaultTemplate",value:function addDefaultTemplate(pPrefix,pPostfix,pTemplate,pSource){var tmpSource=typeof pSource=='string'?pSource:"Direct addDefaultTemplate('".concat(pPrefix,"','").concat(pPostfix,"',..) function load into PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"]");var tmpDefaultTemplate={prefix:pPrefix,postfix:pPostfix,template:pTemplate,source:tmpSource};if(typeof pTemplate!='string'){this.log.error('PictTemplateProvider.addDefaultTemplate: pTemplate is not a string.');}this.defaultTemplates.push(tmpDefaultTemplate);}},{key:"checkDefaultTemplateHash",value:function checkDefaultTemplateHash(pTemplateHash){/*
|
|
3056
3058
|
* Default templates are managed by postfix and prefix. The use case is things like titles, headers, list
|
|
3057
3059
|
* wrappers, rows, etc.
|
|
3058
3060
|
*
|
|
@@ -3066,11 +3068,11 @@ _this48.loadTemplateFunction=function(pTemplateHash){return false;};return _this
|
|
|
3066
3068
|
if(!this.templates.hasOwnProperty(pTemplateHash)){this.loadTemplate(pTemplateHash);}// If the loading function fails, try to load it from the default templates
|
|
3067
3069
|
if(!this.templates.hasOwnProperty(pTemplateHash)){this.checkDefaultTemplateHash(pTemplateHash);}if(this.templates.hasOwnProperty(pTemplateHash)){return this.templates[pTemplateHash];}else{return false;}}},{key:"loadTemplate",value:function loadTemplate(pTemplateHash){var tmpTemplate=this.loadTemplateFunction(pTemplateHash);if(tmpTemplate){this.templates[pTemplateHash]=tmpTemplate.template;this.templateSources[pTemplateHash]="Loaded in loadTemplate('".concat(pTemplateHash,"') function by PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"] from [").concat(tmpTemplate.source,"]");}return tmpTemplate;}}]);return PictTemplateProvider;}(libFableServiceBase);module.exports=PictTemplateProvider;},{"fable":40}],116:[function(require,module,exports){/**
|
|
3068
3070
|
* @author <steven@velozo.com>
|
|
3069
|
-
*/var libFable=require('fable');var Pict=/*#__PURE__*/function(_libFable){_inherits(Pict,_libFable);var _super27=_createSuper(Pict);function Pict(pSettings){var
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
if(
|
|
3073
|
-
|
|
3071
|
+
*/var libFable=require('fable');var Pict=/*#__PURE__*/function(_libFable){_inherits(Pict,_libFable);var _super27=_createSuper(Pict);function Pict(pSettings){var _this50;_classCallCheck2(this,Pict);_this50=_super27.call(this,pSettings);_this50.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");// The templateProvider provides a basic key->template mapping with default fallback capabilities
|
|
3072
|
+
_this50.serviceManager.addAndInstantiateServiceType('TemplateProvider',require('./Pict-Template-Provider.js'));_this50.serviceManager.addAndInstantiateServiceType('EntityProvider',require('./Pict-Meadow-EntityProvider.js'));_this50.serviceManager.addAndInstantiateServiceType('DataProvider',require('./Pict-DataProvider.js'));_this50.serviceManager.addAndInstantiateServiceType('ContentAssignment',require('./Pict-Content-Assignment.js'));_this50.serviceManager.addAndInstantiateServiceType('CSSMap',require('./Pict-CSS.js'));_this50.serviceManager.instantiateServiceProvider('MetaTemplate');_this50.serviceManager.instantiateServiceProvider('DataGeneration');_this50.manifest=_this50.serviceManager.instantiateServiceProvider('Manifest');_this50.AppData={};_this50.Bundle={};// Log noisness goes from 0 - 5, where 5 is show me everything.
|
|
3073
|
+
_this50.LogNoisiness=0;// Load manifest sets
|
|
3074
|
+
if(_this50.settings.Manifests){_this50.loadManifestSet(_this50.settings.Manifests);}_this50._DefaultPictTemplatesInitialized=false;_this50.initializePictTemplateEngine();_this50.serviceManager.addServiceType('PictView',require('pict-view'));_this50.serviceManager.addServiceType('PictApplication',require('pict-application'));// Expose the named views directly, through a convenience accessor
|
|
3075
|
+
_this50.views=_this50.serviceManager.servicesMap.PictView;return _this50;}// Load manifests in as Hashed services
|
|
3074
3076
|
_createClass2(Pict,[{key:"loadManifestSet",value:function loadManifestSet(pManifestSet){if(_typeof(pManifestSet)!='object'){this.log.warn("PICT [".concat(this.UUID,"] could not load Manifest Set; pManifestSet was not an object."));return false;}var tmpManifestKeys=Object.keys(pManifestSet);if(tmpManifestKeys.length>0){for(var i=0;i<tmpManifestKeys.length;i++){// Load each manifest
|
|
3075
3077
|
var tmpManifestKey=tmpManifestKeys[i];this.serviceManager.instantiateServiceProvider('Manifest',pManifestSet[tmpManifestKey],tmpManifestKey);}}}// Just passing an options will construct one for us.
|
|
3076
3078
|
// Passing a hash will set the hash.
|
|
@@ -3080,7 +3082,7 @@ if(pViewPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable
|
|
|
3080
3082
|
// Passing a hash will set the hash.
|
|
3081
3083
|
// Passing a prototype will use that!
|
|
3082
3084
|
},{key:"addApplication",value:function addApplication(pApplicationHash,pOptions,pApplicationPrototype){var tmpOptions=_typeof(pOptions)=='object'?pOptions:{};var tmpApplicationHash=typeof pApplicationHash=='string'?pApplicationHash:this.fable.getUUID();if(typeof pApplicationPrototype!='undefined'){// If the prototype has a default_configuration, it will be merged with options.
|
|
3083
|
-
if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable.Utility.extend({},pApplicationPrototype.default_configuration,tmpOptions);}return this.serviceManager.instantiateServiceProviderFromPrototype('PictApplication',tmpOptions,tmpApplicationHash,pApplicationPrototype);}else{return this.serviceManager.instantiateServiceProvider('PictApplication',tmpOptions,tmpApplicationHash);}}},{key:"initializePictTemplateEngine",value:function initializePictTemplateEngine(){var
|
|
3085
|
+
if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=this.fable.Utility.extend({},pApplicationPrototype.default_configuration,tmpOptions);}return this.serviceManager.instantiateServiceProviderFromPrototype('PictApplication',tmpOptions,tmpApplicationHash,pApplicationPrototype);}else{return this.serviceManager.instantiateServiceProvider('PictApplication',tmpOptions,tmpApplicationHash);}}},{key:"initializePictTemplateEngine",value:function initializePictTemplateEngine(){var _this51=this;/*
|
|
3084
3086
|
*
|
|
3085
3087
|
* To stave off madness, these are inefficient for now. The wkhtmltopdf renderer leaves much to be desired
|
|
3086
3088
|
* in the way of feedback with regards to javascript compatibility.
|
|
@@ -3092,28 +3094,28 @@ if(pApplicationPrototype.hasOwnProperty('default_configuration')){tmpOptions=thi
|
|
|
3092
3094
|
// ...meaning GET BOOK with IDBook FROM AppData.Some.Address.IDBook
|
|
3093
3095
|
// {~E:Book:AppData.Some.Address.IDBook:Render-Book-Template~}
|
|
3094
3096
|
// ...meaning GET BOOK with IDBook FROM AppData.Some.Address.IDBook and render it to Render-Book-Template
|
|
3095
|
-
var fEntityRender=function fEntityRender(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3097
|
+
var fEntityRender=function fEntityRender(pHash,pData,fCallback){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fEntityRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>0){_this51.log.trace("PICT Template [fEntityRender]::[".concat(tmpHash,"]"));}var tmpEntity=false;var tmpEntityID=false;var tmpEntityTemplate=false;// This expression requires 2 parts -- a third is optional, and, if present, is the template to render to.
|
|
3096
3098
|
var tmpHashSeparator=tmpHash.indexOf('|');if(tmpHashSeparator<0){// This is just a simple 2 part hash (the entity and the ID)
|
|
3097
3099
|
var tmpHashEntitySeparator=tmpHash.indexOf(':');tmpEntity=tmpHash.substring(0,tmpHashEntitySeparator);tmpEntityID=tmpHash.substring(tmpHashEntitySeparator+1);}else{// This is a 3 part hash (the entity, the ID, and the template)
|
|
3098
3100
|
var _tmpHashEntitySeparator=tmpHash.indexOf(':');tmpEntity=tmpHash.substring(0,_tmpHashEntitySeparator);var tmpHashTemplateSeparator=tmpHash.indexOf('|');tmpEntityID=tmpHash.substring(_tmpHashEntitySeparator+1,tmpHashTemplateSeparator);tmpEntityTemplate=tmpHash.substring(tmpHashTemplateSeparator+1);}if(!isNaN(tmpEntityID)){tmpEntityID=parseInt(tmpEntityID);}else{// This is an address, so we need to get the value at the address
|
|
3099
|
-
tmpEntityID=
|
|
3100
|
-
if(!tmpEntity||!tmpEntityID){
|
|
3101
|
-
|
|
3102
|
-
if(tmpEntityTemplate){return fCallback(null,
|
|
3103
|
-
var fNotEmptyRender=function fNotEmptyRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3101
|
+
tmpEntityID=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpEntityID);}// No Entity or EntityID
|
|
3102
|
+
if(!tmpEntity||!tmpEntityID){_this51.log.warn("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"]"));return fCallback(Error("Pict: Entity Render: Entity or entity ID not resolved for [".concat(tmpHash,"]")),'');}// Now try to get the entity
|
|
3103
|
+
_this51.EntityProvider.getEntity(tmpEntity,tmpEntityID,function(pError,pRecord){if(pError){_this51.log.error("Pict: Entity Render: Error getting entity [".concat(tmpEntity,"] with ID [").concat(tmpEntityID,"] for [").concat(tmpHash,"]: ").concat(pError),pError);return fCallback(pError,'');}// Now render the template
|
|
3104
|
+
if(tmpEntityTemplate){return fCallback(null,_this51.parseTemplateByHash(tmpEntityTemplate,pRecord));}else{return fCallback(null,'');}});};this.MetaTemplate.addPatternAsync('{~E:','~}',fEntityRender);this.MetaTemplate.addPatternAsync('{~Entity:','~}',fEntityRender);// {NE~Some.Address|If the left value is truthy, render this value.~}
|
|
3105
|
+
var fNotEmptyRender=function fNotEmptyRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>2){_this51.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"]"));}// Should switch this to indexOf so pipes can be in the content.
|
|
3104
3106
|
var tmpHashParts=tmpHash.split('|');// For now just check truthiness
|
|
3105
|
-
if(
|
|
3106
|
-
var fTemplateRender=function fTemplateRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3107
|
+
if(_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHashParts[0])){return tmpHashParts[1];}else{return'';}};this.MetaTemplate.addPattern('{~NotEmpty:','~}',fNotEmptyRender);this.MetaTemplate.addPattern('{~NE:','~}',fNotEmptyRender);// {~T:Template:AddressOfData~}
|
|
3108
|
+
var fTemplateRender=function fTemplateRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>0){_this51.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
|
|
3107
3109
|
var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
|
|
3108
|
-
if(!tmpTemplateHash){
|
|
3109
|
-
return
|
|
3110
|
-
var fTemplateSetRender=function fTemplateSetRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3110
|
+
if(!tmpTemplateHash){_this51.log.warn("Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]"));return"Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]");}if(!tmpAddressOfData){// No address was provided, just render the template with what this template has.
|
|
3111
|
+
return _this51.parseTemplateByHash(tmpTemplateHash,pData);}else{return _this51.parseTemplateByHash(tmpTemplateHash,_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpAddressOfData));}};this.MetaTemplate.addPattern('{~T:','~}',fTemplateRender);this.MetaTemplate.addPattern('{~Template:','~}',fTemplateRender);// {~TS:Template:AddressOfDataSet~}
|
|
3112
|
+
var fTemplateSetRender=function fTemplateSetRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>0){_this51.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"]"));}var tmpTemplateHash=false;var tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
|
|
3111
3113
|
var tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
|
|
3112
|
-
if(!tmpTemplateHash){
|
|
3113
|
-
return
|
|
3114
|
-
var fDataRender=function fDataRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(
|
|
3115
|
-
if(!tmpTemplateString){return'';}return this.parseTemplate(tmpTemplateString,pData,fCallback);}},{key:"parseTemplateSet",value:function parseTemplateSet(pTemplateString,pDataSet,fCallback){var
|
|
3116
|
-
var tmpValue='';if(typeof fCallback=='function'){if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){this.Utility.eachLimit(pDataSet,1,function(pRecord,fRecordTemplateCallback){return
|
|
3114
|
+
if(!tmpTemplateHash){_this51.log.warn("Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]"));return"Pict: Template Render: TemplateHash not resolved for [".concat(tmpHash,"]");}if(!tmpAddressOfData){// No address was provided, just render the template with what this template has.
|
|
3115
|
+
return _this51.parseTemplateSetByHash(tmpTemplateHash,pData);}else{return _this51.parseTemplateSetByHash(tmpTemplateHash,_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpAddressOfData));}};this.MetaTemplate.addPattern('{~TS:','~}',fTemplateSetRender);this.MetaTemplate.addPattern('{~TemplateSet:','~}',fTemplateSetRender);//{~Data:AppData.Some.Value.to.Render~}
|
|
3116
|
+
var fDataRender=function fDataRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"]"));}var tmpValue=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return tmpValue;};this.MetaTemplate.addPattern('{~D:','~}',fDataRender);this.MetaTemplate.addPattern('{~Data:','~}',fDataRender);this.MetaTemplate.addPattern('{~Dollars:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"]"));}var tmpColumnData=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHash);return _this51.DataFormat.formatterDollars(tmpColumnData);});this.MetaTemplate.addPattern('{~Digits:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"]"));}var tmpColumnData=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHash);return _this51.DataFormat.formatterAddCommasToNumber(_this51.DataFormat.formatterRoundNumber(tmpColumnData,2));});var fRandomNumberString=function fRandomNumberString(pHash,pData){var tmpHash=pHash.trim();if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fRandomNumberString]::[".concat(tmpHash,"]"));}var tmpStringLength=4;var tmpMaxNumber=9999;if(tmpHash.length>0){var tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpStringLength=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return _this51.DataGeneration.randomNumericString(tmpStringLength,tmpMaxNumber);};this.MetaTemplate.addPattern('{~RandomNumberString:','~}',fRandomNumberString);this.MetaTemplate.addPattern('{~RNS:','~}',fRandomNumberString);var fRandomNumber=function fRandomNumber(pHash,pData){var tmpHash=pHash.trim();if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fRandomNumber]::[".concat(tmpHash,"]"));}var tmpMinimumNumber=0;var tmpMaxNumber=9999999;if(tmpHash.length>0){var tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpMinimumNumber=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return _this51.DataGeneration.randomIntegerBetween(tmpMinimumNumber,tmpMaxNumber);};this.MetaTemplate.addPattern('{~RandomNumber:','~}',fRandomNumber);this.MetaTemplate.addPattern('{~RN:','~}',fRandomNumber);var fPascalCaseIdentifier=function fPascalCaseIdentifier(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this51.LogNoisiness>4){_this51.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this51.LogNoisiness>3){_this51.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"]"));}var tmpValue=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return _this51.DataFormat.cleanNonAlphaCharacters(_this51.DataFormat.capitalizeEachWord(tmpValue));};this.MetaTemplate.addPattern('{~PascalCaseIdentifier:','~}',fPascalCaseIdentifier);var fLogValue=function fLogValue(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};var tmpValue=_this51.manifest.getValueByHash({AppData:_this51.AppData,Bundle:_this51.Bundle,Record:tmpData},tmpHash);var tmpValueType=_typeof(tmpValue);if(tmpValue==null||tmpValueType=='undefined'){_this51.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is ").concat(tmpValueType,"."));}else if(tmpValueType=='object'){_this51.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is an obect."),tmpValue);}else{_this51.log.trace("PICT Template Log Value: [".concat(tmpHash,"] if a ").concat(tmpValueType," = [").concat(tmpValue,"]"));}return'';};this.MetaTemplate.addPattern('{~LogValue:','~}',fLogValue);this.MetaTemplate.addPattern('{~LV:','~}',fLogValue);var fLogStatement=function fLogStatement(pHash,pData){var tmpHash=pHash.trim();_this51.log.trace("PICT Template Log Message: ".concat(tmpHash));return'';};this.MetaTemplate.addPattern('{~LogStatement:','~}',fLogStatement);this.MetaTemplate.addPattern('{~LS:','~}',fLogStatement);var fBreakpoint=function fBreakpoint(pHash,pData){var tmpHash=pHash.trim();var tmpError=new Error("PICT Template Breakpoint: ".concat(tmpHash));_this51.log.trace("PICT Template Breakpoint: ".concat(tmpHash),tmpError.stack);debugger;return'';};this.MetaTemplate.addPattern('{~Breakpoint','~}',fBreakpoint);this._DefaultPictTemplatesInitialized=true;}}},{key:"parseTemplate",value:function parseTemplate(pTemplateString,pData,fCallback){var tmpData=_typeof(pData)==='object'?pData:{};return this.MetaTemplate.parseString(pTemplateString,tmpData,fCallback);}},{key:"parseTemplateByHash",value:function parseTemplateByHash(pTemplateHash,pData,fCallback){var tmpTemplateString=this.TemplateProvider.getTemplate(pTemplateHash);// TODO: Unsure if returning empty is always the right behavior -- if it isn't we will use config to set the behavior
|
|
3117
|
+
if(!tmpTemplateString){return'';}return this.parseTemplate(tmpTemplateString,pData,fCallback);}},{key:"parseTemplateSet",value:function parseTemplateSet(pTemplateString,pDataSet,fCallback){var _this52=this;// TODO: This will need streaming -- for now janky old string append does the trick
|
|
3118
|
+
var tmpValue='';if(typeof fCallback=='function'){if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){this.Utility.eachLimit(pDataSet,1,function(pRecord,fRecordTemplateCallback){return _this52.parseTemplate(pTemplateString,pRecord,function(pError,pTemplateResult){tmpValue+=pTemplateResult;return fRecordTemplateCallback();});},function(pError){return fCallback(pError,tmpValue);});}else{return fCallback(Error('Pict: Template Set: pDataSet is not an array or object.'),'');}}else{if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){if(Array.isArray(pDataSet)){for(var i=0;i<pDataSet.length;i++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[i]);}}else{var tmpKeys=Object.keys(pDataSet);for(var _i18=0;_i18<tmpKeys.length;_i18++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[tmpKeys[_i18]]);}}return tmpValue;}else{return'';}}}},{key:"parseTemplateSetByHash",value:function parseTemplateSetByHash(pTemplateHash,pDataSet,fCallback){var tmpTemplateString=this.TemplateProvider.getTemplate(pTemplateHash);// TODO: Unsure if returning empty is always the right behavior -- if it isn't we will use config to set the behavior
|
|
3117
3119
|
if(!tmpTemplateString){return'';}return this.parseTemplateSet(tmpTemplateString,pDataSet,fCallback);}}]);return Pict;}(libFable);;module.exports=Pict;module.exports.PictApplicationClass=require('pict-application');module.exports.PictViewClass=require('pict-view');module.exports.EnvironmentLog=require('./environments/Pict-Environment-Log.js');// This is to help understand the type of enivironement we're executing in
|
|
3118
3120
|
module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-CSS.js":111,"./Pict-Content-Assignment.js":112,"./Pict-DataProvider.js":113,"./Pict-Meadow-EntityProvider.js":114,"./Pict-Template-Provider.js":115,"./environments/Pict-Environment-Log.js":117,"fable":40,"pict-application":72,"pict-view":73}],117:[function(require,module,exports){/**
|
|
3119
3121
|
* Pict browser shim loader
|