pict 1.0.99 → 1.0.100
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 +37 -11
- package/dist/pict.compatible.min.js +2 -2
- package/dist/pict.compatible.min.js.map +1 -1
- package/dist/pict.js +37 -11
- package/dist/pict.min.js +2 -2
- package/dist/pict.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Pict-Content-Assignment.js +7 -10
- package/source/Pict.js +6 -4
- package/source/environments/Pict-Environment-Log.js +124 -0
- package/test/Pict_view_tests.js +4 -26
- package/test/configurations/Pict-View-BasicConfigurationOnly.json +23 -0
- package/source/Pict-Application.js +0 -1
- package/source/Pict-View.js +0 -1
package/dist/pict.compatible.js
CHANGED
|
@@ -2975,11 +2975,12 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
2975
2975
|
// presumably different callback function.
|
|
2976
2976
|
// This makes sure that own properties are retained, so that
|
|
2977
2977
|
// decorations and such are not lost along the way.
|
|
2978
|
-
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){
|
|
2978
|
+
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 PictContentAssignment=/*#__PURE__*/function(_libFableServiceBase12){_inherits(PictContentAssignment,_libFableServiceBase12);var _super22=_createSuper(PictContentAssignment);function PictContentAssignment(pFable,pOptions,pServiceHash){var _this37;_classCallCheck2(this,PictContentAssignment);_this37=_super22.call(this,pFable,pOptions,pServiceHash);_this37.serviceType='PictContentAssignment';// Check to see if we are running in a browser
|
|
2979
2979
|
_this37.inBrowser=false;_this37.hasDocument=false;if((typeof window==="undefined"?"undefined":_typeof(window))=='object'){_this37.inBrowser=true;// Now check that the browser has a document object
|
|
2980
2980
|
if(typeof window.document!='undefined'&&typeof window.document.querySelectorAll=='function'){_this37.hasDocument=true;}}// If we're in a browser, check to see if jQuery is available.
|
|
2981
|
-
_this37.hasJquery=false;_this37.jQuery=false;if(_this37.inBrowser&&typeof window.jQuery!=='undefined'){_this37.hasJquery=true;}// API Consumers can
|
|
2982
|
-
_this37.customAssignFunction=false;// API Consumers can also craft their own
|
|
2981
|
+
_this37.hasJquery=false;_this37.jQuery=false;if(_this37.inBrowser&&typeof window.jQuery!=='undefined'){_this37.hasJquery=true;}// API Consumers can craft their own assign function
|
|
2982
|
+
_this37.customAssignFunction=false;// API Consumers can also craft their own prepend function
|
|
2983
|
+
_this37.customPrependFunction=false;// API Consumers can also craft their own append function
|
|
2983
2984
|
_this37.customAppendFunction=false;// API Consumers can also craft their own read function
|
|
2984
2985
|
_this37.customReadFunction=false;// API Consumers can even craft their own get element function.
|
|
2985
2986
|
_this37.customGetElementFunction=false;return _this37;}_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.
|
|
@@ -2992,9 +2993,9 @@ var tmpTargetElement=window.jQuery(pAddress);// Should we ensure we matched 1 an
|
|
|
2992
2993
|
tmpTargetElement.html(pContent);//}
|
|
2993
2994
|
}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);for(var i=0;i<tmpTargetElementSet.length;i++){tmpTargetElementSet[i].innerHTML=pContent;}}else{// Just log it out for now
|
|
2994
2995
|
this.log.trace("PICT Content ASSIGN to [".concat(pAddress,"]:"),pContent);}}},{key:"appendContent",value:function appendContent(pAddress,pContent){if(this.customAppendFunction){return this.customAppendFunction(pAddress,pContent);}else if(this.hasJquery){var tmpTargetElement=window.jQuery(pAddress);tmpTargetElement.append(pContent);}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);for(var i=0;i<tmpTargetElementSet.length;i++){tmpTargetElementSet[i].insertAdjacentHTML("beforeend",pContent);}}else{// Just log it out for now -- nothing browser in our mix.
|
|
2995
|
-
this.log.trace("PICT Content APPEND to [".concat(pAddress,"]:"),pContent);}}},{key:"prependContent",value:function prependContent(pAddress,pContent){if(this.customAppendFunction){return this.
|
|
2996
|
-
this.log.trace("PICT Content PREPEND in [".concat(pAddress,"]:"),pContent);}}},{key:"readContent",value:function readContent(pAddress
|
|
2997
|
-
this.log.trace("PICT Content READ from [".concat(pAddress,"]
|
|
2996
|
+
this.log.trace("PICT Content APPEND to [".concat(pAddress,"]:"),pContent);}}},{key:"prependContent",value:function prependContent(pAddress,pContent){if(this.customAppendFunction){return this.customPrependFunction(pAddress,pContent);}else if(this.hasJquery){var tmpTargetElement=window.jQuery(pAddress);tmpTargetElement.prepend(pContent);}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);for(var i=0;i<tmpTargetElementSet.length;i++){tmpTargetElementSet[i].insertAdjacentHTML("afterbegin",pContent);}}else{// Just log it out for now -- nothing browser in our mix.
|
|
2997
|
+
this.log.trace("PICT Content PREPEND in [".concat(pAddress,"]:"),pContent);}}},{key:"readContent",value:function readContent(pAddress){if(this.customReadFunction){return this.customReadFunction(pAddress);}else if(this.hasJquery){var tmpTargetElement=window.jQuery(pAddress);return tmpTargetElement.html();}else if(this.inBrowser&&this.hasDocument){var tmpTargetElementSet=window.document.querySelectorAll(pAddress);if(tmpTargetElementSet.length<1){return'';}else if(tmpTargetElementSet.length==1){return tmpTargetElementSet[0].innerHTML;}}else{// Just log it out for now -- nothing browser in our mix.
|
|
2998
|
+
this.log.trace("PICT Content READ from [".concat(pAddress,"]..."));return'';}}}]);return PictContentAssignment;}(libFableServiceBase);module.exports=PictContentAssignment;},{"fable":40}],112:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictDataProvider=/*#__PURE__*/function(_libFableServiceBase13){_inherits(PictDataProvider,_libFableServiceBase13);var _super23=_createSuper(PictDataProvider);function PictDataProvider(pFable,pOptions,pServiceHash){var _this38;_classCallCheck2(this,PictDataProvider);_this38=_super23.call(this,pFable,pOptions,pServiceHash);_this38.serviceType='PictDataProvider';return _this38;}_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}],113:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictMeadowEntityProvider=/*#__PURE__*/function(_libFableServiceBase14){_inherits(PictMeadowEntityProvider,_libFableServiceBase14);var _super24=_createSuper(PictMeadowEntityProvider);function PictMeadowEntityProvider(pFable,pOptions,pServiceHash){var _this39;_classCallCheck2(this,PictMeadowEntityProvider);_this39=_super24.call(this,pFable,pOptions,pServiceHash);_defineProperty2(_assertThisInitialized(_this39),"getEntitySet",function(pEntity,pMeadowFilterExpression,fCallback){var _this40=this;this.initializeCache(pEntity);// TODO: Should we test for too many record IDs here by string length?
|
|
2998
2999
|
// FBL~ID${pDestinationEntity}~INN~${tmpIDRecordsCommaSeparated}
|
|
2999
3000
|
// Discard anything from the cache that has expired or is over size.
|
|
3000
3001
|
this.cache[pEntity].prune(function(){var tmpCountOptions={url:"".concat(_this40.options.urlPrefix).concat(pEntity,"s/Count/FilteredTo/").concat(pMeadowFilterExpression)};tmpCountOptions=_this40.prepareRequestOptions(tmpCountOptions);return _this40.restClient.getJSON(tmpCountOptions,function(pError,pResponse,pBody){if(pError){_this40.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=_this40.options.downloadBatchSize;for(var i=0;i<tmpRecordCount/tmpDownloadBatchSize;i++){// Generate each of the URI fragments to download
|
|
@@ -3004,7 +3005,7 @@ return fDownloadCallback(pDownloadError);});},function(pFullDownloadError){retur
|
|
|
3004
3005
|
if(!this.cache.hasOwnProperty(pEntity)){this.cache[pEntity]=this.fable.serviceManager.instantiateServiceProviderWithoutRegistration('ObjectCache');// TODO: Make this a configuration?
|
|
3005
3006
|
// For now cache for 30 seconds.
|
|
3006
3007
|
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 _this41=this;this.initializeCache(pEntity);// Discard anything from the cache that has expired or is over size.
|
|
3007
|
-
this.cache[pEntity].prune(function(){var tmpPossibleRecord=_this41.cache[pEntity].read(pIDRecord);if(tmpPossibleRecord){return tmpPossibleRecord;}var tmpOptions={url:"".concat(_this41.options.urlPrefix).concat(pEntity,"/").concat(pIDRecord)};tmpOptions=_this41.prepareRequestOptions(tmpOptions);return _this41.restClient.getJSON(tmpOptions,function(pError,pResponse,pBody){if(pBody){_this41.cache[pEntity].put(pBody,pIDRecord);}return fCallback(pError,pBody);});});}}]);return PictMeadowEntityProvider;}(libFableServiceBase);module.exports=PictMeadowEntityProvider;},{"fable":40}],
|
|
3008
|
+
this.cache[pEntity].prune(function(){var tmpPossibleRecord=_this41.cache[pEntity].read(pIDRecord);if(tmpPossibleRecord){return tmpPossibleRecord;}var tmpOptions={url:"".concat(_this41.options.urlPrefix).concat(pEntity,"/").concat(pIDRecord)};tmpOptions=_this41.prepareRequestOptions(tmpOptions);return _this41.restClient.getJSON(tmpOptions,function(pError,pResponse,pBody){if(pBody){_this41.cache[pEntity].put(pBody,pIDRecord);}return fCallback(pError,pBody);});});}}]);return PictMeadowEntityProvider;}(libFableServiceBase);module.exports=PictMeadowEntityProvider;},{"fable":40}],114:[function(require,module,exports){var libFableServiceBase=require('fable').ServiceProviderBase;var PictTemplateProvider=/*#__PURE__*/function(_libFableServiceBase15){_inherits(PictTemplateProvider,_libFableServiceBase15);var _super25=_createSuper(PictTemplateProvider);function PictTemplateProvider(pFable,pOptions,pServiceHash){var _this42;_classCallCheck2(this,PictTemplateProvider);_this42=_super25.call(this,pFable,pOptions,pServiceHash);_this42.serviceType='PictTemplateProvider';_this42.templates={};_this42.templateSources={};// Default templates are stored by prefix.
|
|
3008
3009
|
// The longest prefix match is used.
|
|
3009
3010
|
// Case sensitive.
|
|
3010
3011
|
_this42.defaultTemplates=[];// This function can be overloaded to load templates from a database, in a page or other source.
|
|
@@ -3020,12 +3021,12 @@ _this42.loadTemplateFunction=function(pTemplateHash){return false;};return _this
|
|
|
3020
3021
|
*/for(var i=0;i<this.defaultTemplates.length;i++){if(pTemplateHash.indexOf(this.defaultTemplates[i].postfix)==pTemplateHash.length-this.defaultTemplates[i].postfix.length&&pTemplateHash.indexOf(this.defaultTemplates[i].prefix)==0){this.templates[pTemplateHash]=this.defaultTemplates[i].template;this.templateSources[pTemplateHash]="Auto created in checkDefaultTemplateHash('".concat(pTemplateHash,"') function by PictTemplateProvider [").concat(this.UUID,"]::[").concat(this.Hash,"] from [").concat(this.defaultTemplates[i].prefix,"]...[").concat(this.defaultTemplates[i].postfix,"]");return this.templates[pTemplateHash];}}return false;}},{key:"getTemplate",value:function getTemplate(pTemplateHash){// TODO: Optimize this.
|
|
3021
3022
|
// If the template doesn't exist, try to load it with the loading function
|
|
3022
3023
|
if(!this.templates.hasOwnProperty(pTemplateHash)){this.loadTemplate(pTemplateHash);}// If the loading function fails, try to load it from the default templates
|
|
3023
|
-
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}],
|
|
3024
|
+
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}],115:[function(require,module,exports){/**
|
|
3024
3025
|
* @author <steven@velozo.com>
|
|
3025
3026
|
*/var libFable=require('fable');var Pict=/*#__PURE__*/function(_libFable){_inherits(Pict,_libFable);var _super26=_createSuper(Pict);function Pict(pSettings){var _this43;_classCallCheck2(this,Pict);_this43=_super26.call(this,pSettings);_this43.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");// The templateProvider provides a basic key->template mapping with default fallback capabilities
|
|
3026
3027
|
_this43.serviceManager.addAndInstantiateServiceType('TemplateProvider',require('./Pict-Template-Provider.js'));_this43.serviceManager.addAndInstantiateServiceType('EntityProvider',require('./Pict-Meadow-EntityProvider.js'));_this43.serviceManager.addAndInstantiateServiceType('DataProvider',require('./Pict-DataProvider.js'));_this43.serviceManager.addAndInstantiateServiceType('ContentAssignment',require('./Pict-Content-Assignment.js'));_this43.serviceManager.instantiateServiceProvider('MetaTemplate');_this43.serviceManager.instantiateServiceProvider('DataGeneration');_this43.manifest=_this43.serviceManager.instantiateServiceProvider('Manifest');_this43.AppData={};_this43.Bundle={};// Log noisness goes from 0 - 5, where 5 is show me everything.
|
|
3027
3028
|
_this43.LogNoisiness=0;// Load manifest sets
|
|
3028
|
-
if(_this43.settings.Manifests){_this43.loadManifestSet(_this43.settings.Manifests);}_this43._DefaultPictTemplatesInitialized=false;_this43.initializePictTemplateEngine();_this43.serviceManager.addServiceType('PictView',require('
|
|
3029
|
+
if(_this43.settings.Manifests){_this43.loadManifestSet(_this43.settings.Manifests);}_this43._DefaultPictTemplatesInitialized=false;_this43.initializePictTemplateEngine();_this43.serviceManager.addServiceType('PictView',require('pict-view'));_this43.serviceManager.addServiceType('PictApplication',require('pict-application'));// Expose the named views directly, through a convenience accessor
|
|
3029
3030
|
_this43.views=_this43.serviceManager.servicesMap.PictView;return _this43;}// Load manifests in as Hashed services
|
|
3030
3031
|
_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
|
|
3031
3032
|
var tmpManifestKey=tmpManifestKeys[i];this.serviceManager.instantiateServiceProvider('Manifest',pManifestSet[tmpManifestKey],tmpManifestKey);}}}// Just passing an options will construct one for us.
|
|
@@ -3068,5 +3069,30 @@ return _this44.parseTemplateSetByHash(tmpTemplateHash,pData);}else{return _this4
|
|
|
3068
3069
|
var fDataRender=function fDataRender(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this44.LogNoisiness>4){_this44.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this44.LogNoisiness>3){_this44.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"]"));}var tmpValue=_this44.manifest.getValueByHash({AppData:_this44.AppData,Bundle:_this44.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(_this44.LogNoisiness>4){_this44.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this44.LogNoisiness>3){_this44.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"]"));}var tmpColumnData=_this44.manifest.getValueByHash({AppData:_this44.AppData,Bundle:_this44.Bundle,Record:tmpData},tmpHash);return _this44.DataFormat.formatterDollars(tmpColumnData);});this.MetaTemplate.addPattern('{~Digits:','~}',function(pHash,pData){var tmpHash=pHash.trim();var tmpData=_typeof(pData)==='object'?pData:{};if(_this44.LogNoisiness>4){_this44.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this44.LogNoisiness>3){_this44.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"]"));}var tmpColumnData=_this44.manifest.getValueByHash({AppData:_this44.AppData,Bundle:_this44.Bundle,Record:tmpData},tmpHash);return _this44.DataFormat.formatterAddCommasToNumber(_this44.DataFormat.formatterRoundNumber(tmpColumnData,2));});var fRandomNumberString=function fRandomNumberString(pHash,pData){var tmpHash=pHash.trim();if(_this44.LogNoisiness>3){_this44.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 _this44.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(_this44.LogNoisiness>3){_this44.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 _this44.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(_this44.LogNoisiness>4){_this44.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(_this44.LogNoisiness>3){_this44.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"]"));}var tmpValue=_this44.manifest.getValueByHash({AppData:_this44.AppData,Bundle:_this44.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return _this44.DataFormat.cleanNonAlphaCharacters(_this44.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=_this44.manifest.getValueByHash({AppData:_this44.AppData,Bundle:_this44.Bundle,Record:tmpData},tmpHash);var tmpValueType=_typeof(tmpValue);if(tmpValue==null||tmpValueType=='undefined'){_this44.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is ").concat(tmpValueType,"."));}else if(tmpValueType=='object'){_this44.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is an obect."),tmpValue);}else{_this44.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();_this44.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));_this44.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
|
|
3069
3070
|
if(!tmpTemplateString){return'';}return this.parseTemplate(tmpTemplateString,pData,fCallback);}},{key:"parseTemplateSet",value:function parseTemplateSet(pTemplateString,pDataSet,fCallback){var _this45=this;// TODO: This will need streaming -- for now janky old string append does the trick
|
|
3070
3071
|
var tmpValue='';if(typeof fCallback=='function'){if(Array.isArray(pDataSet)||_typeof(pDataSet)=='object'){this.Utility.eachLimit(pDataSet,1,function(pRecord,fRecordTemplateCallback){return _this45.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 _i14=0;_i14<tmpKeys.length;_i14++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[tmpKeys[_i14]]);}}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
|
|
3071
|
-
if(!tmpTemplateString){return'';}return this.parseTemplateSet(tmpTemplateString,pDataSet,fCallback);}}]);return Pict;}(libFable);;module.exports=Pict;module.exports.PictApplicationClass=require('
|
|
3072
|
-
module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-
|
|
3072
|
+
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
|
|
3073
|
+
module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-Content-Assignment.js":111,"./Pict-DataProvider.js":112,"./Pict-Meadow-EntityProvider.js":113,"./Pict-Template-Provider.js":114,"./environments/Pict-Environment-Log.js":116,"fable":40,"pict-application":72,"pict-view":73}],116:[function(require,module,exports){/**
|
|
3074
|
+
* Pict browser shim loader
|
|
3075
|
+
* @author <steven@velozo.com>
|
|
3076
|
+
*
|
|
3077
|
+
* This was born after writing about 10 views and copying basically the same
|
|
3078
|
+
* mock environment read/write functions into the test harnesses. It allows
|
|
3079
|
+
* mocks or other types of communications back-and-forth to be configured
|
|
3080
|
+
* as an environment for views and applications.
|
|
3081
|
+
*
|
|
3082
|
+
* To use this:
|
|
3083
|
+
*
|
|
3084
|
+
* 1. Construct a pict object in your favorite fashion:
|
|
3085
|
+
* let _Pict = new libPict({...Environment})
|
|
3086
|
+
* 2. Require this; it's exported as a static subobject of the pict library,
|
|
3087
|
+
* so you can do:
|
|
3088
|
+
* const libPictEnvironmentLog = require('pict').EnvironmentLog;
|
|
3089
|
+
* 3. Create an object that is your custom read data. Any key that is requested
|
|
3090
|
+
* but missing will return empty.
|
|
3091
|
+
* const tmpContentMap = { '#SomeElement': 'SomeValue' };
|
|
3092
|
+
* 4. Pass your pict through this to get the custom functions mapped into the ContentAssignment service:
|
|
3093
|
+
* let tmpMockEnvironment = new libPictEnvironmentLog(_Pict, tmpContentMap);
|
|
3094
|
+
* 5. Now you can use your pict as normal, and it will log all of the read/write events out and keep a log of when they occurred.
|
|
3095
|
+
*/var PictEnvironmentLog=/*#__PURE__*/function(){function PictEnvironmentLog(pPict,pContentMap){_classCallCheck2(this,PictEnvironmentLog);this.contentMap=_typeof(pContentMap)=='object'?pContentMap:{};this.pict=pPict;// If this is set to false, we won't keep an array-based log of every read, assignment, append or get.
|
|
3096
|
+
this.truncateContentLength=256;this.storeEventLog=true;// Where to store each event type
|
|
3097
|
+
this.eventLog={};this.eventLog.GetElement=[];this.eventLog.Read=[];this.eventLog.Prepend=[];this.eventLog.Append=[];this.eventLog.Assign=[];this.pict.ContentAssignment.customGetElementFunction=this.customGetElementFunction.bind(this);this.pict.ContentAssignment.customReadFunction=this.customGetElementFunction.bind(this);this.pict.ContentAssignment.customAppendFunction=this.customAppendFunction.bind(this);this.pict.ContentAssignment.customPrependFunction=this.customPrependFunction.bind(this);this.pict.ContentAssignment.customAssignFunction=this.customAssignFunction.bind(this);}_createClass2(PictEnvironmentLog,[{key:"createEventLogEntry",value:function createEventLogEntry(pAddress,pContent){var tmpContent=typeof pContent=='undefined'?'':pContent;return{TimeStamp:this.pict.log.getTimeStamp(),Hash:pAddress,Content:tmpContent};}},{key:"customGetElementFunction",value:function customGetElementFunction(pAddress){if(this.storeEventLog)this.eventLog.GetElement.push(this.createEventLogEntry(pAddress));this.pict.log.info("Mocking an GET of Address -> [".concat(pAddress,"]"));return'';}},{key:"customReadFunction",value:function customReadFunction(pAddress){if(this.storeEventLog)this.eventLog.Read.push(this.createEventLogEntry(pAddress));this.pict.log.info("Mocking an READ from Address -> [".concat(pAddress,"]"));if(this.contentMap.hasOwnProperty(pAddress)){// The data is in the content map!
|
|
3098
|
+
return this.contentMap[pAddress];}this.pict.log.warn("Mock read from Address ".concat(pAddress," did not find a value in the content map."));return'';}},{key:"customAppendFunction",value:function customAppendFunction(pAddress,pContent){if(this.storeEventLog)this.eventLog.Append.push(this.createEventLogEntry(pAddress,pContent));if(pContent.length>this.truncateContentLength){this.pict.log.info("Mocking an APPEND to Address -> [".concat(pAddress,"] (log truncated to first ").concat(this.truncateContentLength," characters)"),{Content:pContent.substring(0,this.truncateContentLength)});}else{this.pict.log.info("Mocking an APPEND to Address -> [".concat(pAddress,"]"),{Content:pContent});}return'';}},{key:"customPrependFunction",value:function customPrependFunction(pAddress,pContent){if(this.storeEventLog)this.eventLog.Prepend.push(this.createEventLogEntry(pAddress,pContent));if(pContent.length>this.truncateContentLength){this.pict.log.info("Mocking an PREPEND to Address -> [".concat(pAddress,"] (log truncated to first ").concat(this.truncateContentLength," characters)"),{Content:pContent.substring(0,this.truncateContentLength)});}else{this.pict.log.info("Mocking an PREPEND to Address -> [".concat(pAddress,"]"),{Content:pContent});}return'';}},{key:"customAssignFunction",value:function customAssignFunction(pAddress,pContent){if(this.storeEventLog)this.eventLog.Assign.push(this.createEventLogEntry(pAddress,pContent));if(pContent.length>this.truncateContentLength){this.pict.log.info("Mocking an ASSIGN to Address -> [".concat(pAddress,"] (log truncated to first ").concat(this.truncateContentLength," characters)"),{Content:pContent.substring(0,this.truncateContentLength)});}else{this.pict.log.info("Mocking an ASSIGN to Address -> [".concat(pAddress,"]"),{Content:pContent});}return'';}}]);return PictEnvironmentLog;}();module.exports=PictEnvironmentLog;},{}]},{},[115])(115);});
|