pict 1.0.78 → 1.0.80

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.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";function _defineProperty2(obj,key,value){key=_toPropertyKey2(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toPropertyKey2(arg){var key=_toPrimitive2(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive2(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o;}return r;})()({1:[function(require,module,exports){'use strict';var eachOfLimit=require('async.util.eachoflimit');var withoutIndex=require('async.util.withoutindex');module.exports=function eachLimit(arr,limit,iterator,cb){return eachOfLimit(limit)(arr,withoutIndex(iterator),cb);};},{"async.util.eachoflimit":3,"async.util.withoutindex":14}],2:[function(require,module,exports){'use strict';module.exports=function(tasks){function makeCallback(index){function fn(){if(tasks.length){tasks[index].apply(null,arguments);}return fn.next();}fn.next=function(){return index<tasks.length-1?makeCallback(index+1):null;};return fn;}return makeCallback(0);};},{}],3:[function(require,module,exports){var once=require('async.util.once');var noop=require('async.util.noop');var onlyOnce=require('async.util.onlyonce');var keyIterator=require('async.util.keyiterator');module.exports=function eachOfLimit(limit){return function(obj,iterator,cb){cb=once(cb||noop);obj=obj||[];var nextKey=keyIterator(obj);if(limit<=0){return cb(null);}var done=false;var running=0;var errored=false;(function replenish(){if(done&&running<=0){return cb(null);}while(running<limit&&!errored){var key=nextKey();if(key===null){done=true;if(running<=0){cb(null);}return;}running+=1;iterator(obj[key],key,onlyOnce(function(err){running-=1;if(err){cb(err);errored=true;}else{replenish();}}));}})();};};},{"async.util.keyiterator":7,"async.util.noop":9,"async.util.once":10,"async.util.onlyonce":11}],4:[function(require,module,exports){'use strict';var setImmediate=require('async.util.setimmediate');var restParam=require('async.util.restparam');module.exports=function(fn){return restParam(function(args){var callback=args.pop();args.push(function(){var innerArgs=arguments;if(sync){setImmediate(function(){callback.apply(null,innerArgs);});}else{callback.apply(null,innerArgs);}});var sync=true;fn.apply(this,args);sync=false;});};},{"async.util.restparam":12,"async.util.setimmediate":13}],5:[function(require,module,exports){'use strict';module.exports=Array.isArray||function isArray(obj){return Object.prototype.toString.call(obj)==='[object Array]';};},{}],6:[function(require,module,exports){'use strict';var isArray=require('async.util.isarray');module.exports=function isArrayLike(arr){return isArray(arr)||// has a positive integer length property
1
+ "use strict";function _defineProperty2(obj,key,value){key=_toPropertyKey2(key);if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toPropertyKey2(arg){var key=_toPrimitive2(arg,"string");return typeof key==="symbol"?key:String(key);}function _toPrimitive2(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return(hint==="string"?String:Number)(input);}(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else{var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else{g=this;}g.Pict=f();}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o;}return r;}()({1:[function(require,module,exports){'use strict';var eachOfLimit=require('async.util.eachoflimit');var withoutIndex=require('async.util.withoutindex');module.exports=function eachLimit(arr,limit,iterator,cb){return eachOfLimit(limit)(arr,withoutIndex(iterator),cb);};},{"async.util.eachoflimit":3,"async.util.withoutindex":14}],2:[function(require,module,exports){'use strict';module.exports=function(tasks){function makeCallback(index){function fn(){if(tasks.length){tasks[index].apply(null,arguments);}return fn.next();}fn.next=function(){return index<tasks.length-1?makeCallback(index+1):null;};return fn;}return makeCallback(0);};},{}],3:[function(require,module,exports){var once=require('async.util.once');var noop=require('async.util.noop');var onlyOnce=require('async.util.onlyonce');var keyIterator=require('async.util.keyiterator');module.exports=function eachOfLimit(limit){return function(obj,iterator,cb){cb=once(cb||noop);obj=obj||[];var nextKey=keyIterator(obj);if(limit<=0){return cb(null);}var done=false;var running=0;var errored=false;(function replenish(){if(done&&running<=0){return cb(null);}while(running<limit&&!errored){var key=nextKey();if(key===null){done=true;if(running<=0){cb(null);}return;}running+=1;iterator(obj[key],key,onlyOnce(function(err){running-=1;if(err){cb(err);errored=true;}else{replenish();}}));}})();};};},{"async.util.keyiterator":7,"async.util.noop":9,"async.util.once":10,"async.util.onlyonce":11}],4:[function(require,module,exports){'use strict';var setImmediate=require('async.util.setimmediate');var restParam=require('async.util.restparam');module.exports=function(fn){return restParam(function(args){var callback=args.pop();args.push(function(){var innerArgs=arguments;if(sync){setImmediate(function(){callback.apply(null,innerArgs);});}else{callback.apply(null,innerArgs);}});var sync=true;fn.apply(this,args);sync=false;});};},{"async.util.restparam":12,"async.util.setimmediate":13}],5:[function(require,module,exports){'use strict';module.exports=Array.isArray||function isArray(obj){return Object.prototype.toString.call(obj)==='[object Array]';};},{}],6:[function(require,module,exports){'use strict';var isArray=require('async.util.isarray');module.exports=function isArrayLike(arr){return isArray(arr)||// has a positive integer length property
2
2
  typeof arr.length==='number'&&arr.length>=0&&arr.length%1===0;};},{"async.util.isarray":5}],7:[function(require,module,exports){'use strict';var _keys=require('async.util.keys');var isArrayLike=require('async.util.isarraylike');module.exports=function keyIterator(coll){var i=-1;var len;var keys;if(isArrayLike(coll)){len=coll.length;return function next(){i++;return i<len?i:null;};}else{keys=_keys(coll);len=keys.length;return function next(){i++;return i<len?keys[i]:null;};}};},{"async.util.isarraylike":6,"async.util.keys":8}],8:[function(require,module,exports){'use strict';module.exports=Object.keys||function keys(obj){var _keys=[];for(var k in obj){if(obj.hasOwnProperty(k)){_keys.push(k);}}return _keys;};},{}],9:[function(require,module,exports){'use strict';module.exports=function noop(){};},{}],10:[function(require,module,exports){'use strict';module.exports=function once(fn){return function(){if(fn===null)return;fn.apply(this,arguments);fn=null;};};},{}],11:[function(require,module,exports){'use strict';module.exports=function only_once(fn){return function(){if(fn===null)throw new Error('Callback was already called.');fn.apply(this,arguments);fn=null;};};},{}],12:[function(require,module,exports){'use strict';module.exports=function restParam(func,startIndex){startIndex=startIndex==null?func.length-1:+startIndex;return function(){var length=Math.max(arguments.length-startIndex,0);var rest=new Array(length);for(var index=0;index<length;index++){rest[index]=arguments[index+startIndex];}switch(startIndex){case 0:return func.call(this,rest);case 1:return func.call(this,arguments[0],rest);}};};},{}],13:[function(require,module,exports){(function(setImmediate){(function(){'use strict';var _setImmediate=typeof setImmediate==='function'&&setImmediate;var fallback=function fallback(fn){setTimeout(fn,0);};module.exports=function setImmediate(fn){// not a direct alias for IE10 compatibility
3
3
  return(_setImmediate||fallback)(fn);};}).call(this);}).call(this,require("timers").setImmediate);},{"timers":102}],14:[function(require,module,exports){'use strict';module.exports=function withoutIndex(iterator){return function(value,index,callback){return iterator(value,callback);};};},{}],15:[function(require,module,exports){'use strict';var once=require('async.util.once');var noop=require('async.util.noop');var isArray=require('async.util.isarray');var restParam=require('async.util.restparam');var ensureAsync=require('async.util.ensureasync');var iterator=require('async.iterator');module.exports=function(tasks,cb){cb=once(cb||noop);if(!isArray(tasks))return cb(new Error('First argument to waterfall must be an array of functions'));if(!tasks.length)return cb();function wrapIterator(iterator){return restParam(function(err,args){if(err){cb.apply(null,[err].concat(args));}else{var next=iterator.next();if(next){args.push(wrapIterator(next));}else{args.push(cb);}ensureAsync(iterator).apply(null,args);}});}wrapIterator(iterator(tasks))();};},{"async.iterator":2,"async.util.ensureasync":4,"async.util.isarray":5,"async.util.noop":9,"async.util.once":10,"async.util.restparam":12}],16:[function(require,module,exports){'use strict';exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=='undefined'?Uint8Array:Array;var code='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i;}// Support decoding URL-safe base64 strings, as Node.js does.
4
4
  // See: https://en.wikipedia.org/wiki/Base64#URL_applications
@@ -445,22 +445,23 @@ function autoConstruct(pSettings){return new FableUUID(pSettings);}module.export
445
445
  */const libFableServiceBase=require('fable-serviceproviderbase');class FableService extends libFableServiceBase.CoreServiceProviderBase{constructor(pSettings,pServiceHash){super(pSettings,pServiceHash);this.serviceType='ServiceManager';this.serviceTypes=[];// A map of instantiated services
446
446
  this.services={};// A map of the default instantiated service by type
447
447
  this.defaultServices={};// A map of class constructors for services
448
- this.serviceClasses={};}addServiceType(pServiceType,pServiceClass){// Add the type to the list of types
448
+ this.serviceClasses={};// If we need extra service initialization capabilities
449
+ this.extraServiceInitialization=false;}addServiceType(pServiceType,pServiceClass){// Add the type to the list of types
449
450
  this.serviceTypes.push(pServiceType);// Add the container for instantiated services to go in
450
451
  this.services[pServiceType]={};// Using the static member of the class is a much more reliable way to check if it is a service class than instanceof
451
452
  if(typeof pServiceClass=='function'&&pServiceClass.isFableService){// Add the class to the list of classes
452
453
  this.serviceClasses[pServiceType]=pServiceClass;}else{// Add the base class to the list of classes
453
454
  this.fable.log.error("Attempted to add service type [".concat(pServiceType,"] with an invalid class. Using base service class, which will not crash but won't provide meaningful services."));this.serviceClasses[pServiceType]=libFableServiceBase;}}// This is for the services that are meant to run mostly single-instance so need a default at initialization
454
- addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}// Some servicds expect to be overloaded / customized class.
455
+ addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}// Some services expect to be overloaded / customized class.
455
456
  instantiateServiceProviderFromPrototype(pServiceType,pOptions,pCustomServiceHash,pServicePrototype){// Instantiate the service
456
- let tmpService=new pServicePrototype(this.fable,pOptions,pCustomServiceHash);// Add the service to the service map
457
+ let tmpService=new pServicePrototype(this.fable,pOptions,pCustomServiceHash);if(this.extraServiceInitialization){tmpService=this.extraServiceInitialization(tmpService);}// Add the service to the service map
457
458
  this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
458
459
  if(!this.defaultServices.hasOwnProperty(pServiceType)){this.setDefaultServiceInstantiation(pServiceType,tmpService.Hash);}return tmpService;}instantiateServiceProvider(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
459
460
  let tmpService=this.instantiateServiceProviderWithoutRegistration(pServiceType,pOptions,pCustomServiceHash);// Add the service to the service map
460
461
  this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
461
462
  if(!this.defaultServices.hasOwnProperty(pServiceType)){this.setDefaultServiceInstantiation(pServiceType,tmpService.Hash);}return tmpService;}// Create a service provider but don't register it to live forever in fable.services
462
463
  instantiateServiceProviderWithoutRegistration(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
463
- let tmpService=new this.serviceClasses[pServiceType](this.fable,pOptions,pCustomServiceHash);return tmpService;}// Connect an initialized service provider that came before Fable was initialized
464
+ let tmpService=new this.serviceClasses[pServiceType](this.fable,pOptions,pCustomServiceHash);if(this.extraServiceInitialization){tmpService=this.extraServiceInitialization(tmpService);}return tmpService;}// Connect an initialized service provider that came before Fable was initialized
464
465
  connectPreinitServiceProviderInstance(pServiceInstance){let tmpServiceType=pServiceInstance.serviceType;let tmpServiceHash=pServiceInstance.Hash;// The service should already be instantiated, so just connect it to fable
465
466
  pServiceInstance.connectFable(this.fable);if(!this.services.hasOwnProperty(tmpServiceType)){// If the core service hasn't registered itself yet, create the service container for it.
466
467
  // This means you couldn't register another with this type unless it was later registered with a constructor class.
@@ -2884,7 +2885,7 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
2884
2885
  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;}}},{}],107:[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;}},{}],108:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;const defaultPictSettings={Name:'DefaultPictApplication',InitializeOnLoad:true,// The main "viewport" is the view that is used to host our application
2885
2886
  MainViewportView:'Default-View',MainViewportRenderable:'Application-Default-View-Renderable',MainViewportDestinationAddress:'Application-Destination-Address',MainViewportDefaultDataAddress:'',// Whether or not we should automatically render the main viewport when appropriate
2886
2887
  AutoRenderMainViewportView:false,Manifests:{},// The prefix to prepend on all template destination hashes
2887
- IdentifierAddressPrefix:'PICT-'};class PictApplication extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.options=this.fable.Utility.extend(JSON.parse(JSON.stringify(defaultPictSettings)),this.options);this.serviceType='PictApplication';this.AppData=this.fable.AppData;this.initializationFunctionSet=[];let tmpManifestKeys=Object.keys(this.options.Manifests);if(tmpManifestKeys.length>0){for(let i=0;i<tmpManifestKeys.length;i++){// Load each manifest
2888
+ IdentifierAddressPrefix:'PICT-'};class PictApplication extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){let tmpOptions=Object.assign({},defaultPictSettings,pOptions);super(pFable,tmpOptions,pServiceHash);this.serviceType='PictApplication';this.AppData=this.fable.AppData;this.initializationFunctionSet=[];let tmpManifestKeys=Object.keys(this.options.Manifests);if(tmpManifestKeys.length>0){for(let i=0;i<tmpManifestKeys.length;i++){// Load each manifest
2888
2889
  let tmpManifestKey=tmpManifestKeys[i];this.fable.serviceManager.instantiateServiceProvider('Manifest',this.options.Manifests[tmpManifestKey],tmpManifestKey);}}if(this.options.InitializeOnLoad){return this.initialize();}if(this.options.AutoRenderMainViewportView){this.log.info("Pict Application ".concat(this.options.Name,"[").concat(this.UUID,"]::[").concat(this.Hash,"] beginning auto render of [").concat(this.options.MainViewportView,"::").concat(this.options.MainViewportRenderable,"]."));this.renderAsync(this.options.MainViewportView,this.options.MainViewportRenderable,this.options.MainViewportDestinationAddress,this.options.MainViewportDefaultDataAddress,()=>{});}}// TODO: do we need an asynchronous version of this?
2889
2890
  solve(){this.log.info("Pict Application ".concat(this.options.Name,"[").concat(this.UUID,"]::[").concat(this.Hash,"] executing solve() function..."));return true;}internalInitialize(){return true;}initialize(){this.log.info("Pict Application ".concat(this.options.Name,"[").concat(this.UUID,"]::[").concat(this.Hash,"] beginning initialization..."));this.internalInitialize();this.log.info("Pict Application ".concat(this.options.Name,"[").concat(this.UUID,"]::[").concat(this.Hash,"] initialization complete."));}render(pViewHash,pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress){let tmpView=typeof pViewHash==='string'?this.services.PictView[pViewHash]:false;if(!tmpView){this.log.error("PictApplication [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," could not render from View ").concat(pViewHash," because it is not a valid view."));return false;}return tmpView.render(pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress);}renderAsync(pViewHash,pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress,fCallback){let tmpView=typeof pViewHash==='string'?this.services.PictView[pViewHash]:false;if(!tmpView){this.log.error("PictApplication [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.Name," could not render from View ").concat(pViewHash," because it is not a valid view."));return false;}return tmpView.renderAsync(pRenderableHash,pRenderDestinationAddress,pTemplateDataAddress,fCallback);}}module.exports=PictApplication;},{"fable":39}],109:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;class PictContentAssignment extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='PictContentAssignment';// Check to see if we are running in a browser
2890
2891
  this.inBrowser=false;this.hasDocument=false;if(typeof window=='object'){this.inBrowser=true;// Now check that the browser has a document object
@@ -2930,7 +2931,7 @@ this.loadTemplateFunction=pTemplateHash=>{return false;};}addTemplate(pTemplateH
2930
2931
  */for(let 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;}getTemplate(pTemplateHash){// TODO: Optimize this.
2931
2932
  // If the template doesn't exist, try to load it with the loading function
2932
2933
  if(!this.templates.hasOwnProperty(pTemplateHash)){this.loadTemplate(pTemplateHash);}// If the loading function fails, try to load it from the default templates
2933
- if(!this.templates.hasOwnProperty(pTemplateHash)){this.checkDefaultTemplateHash(pTemplateHash);}if(this.templates.hasOwnProperty(pTemplateHash)){return this.templates[pTemplateHash];}else{return false;}}loadTemplate(pTemplateHash){let 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;}}module.exports=PictTemplateProvider;},{"fable":39}],113:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;const defaultPictViewSettings={DefaultRenderable:false,DefaultDestinationAddress:false,DefaultTemplateRecordAddress:false,ViewIdentifier:'DEFAULT',InitializeOnLoad:true,RenderOnLoad:false,Templates:[],DefaultTemplates:[],Renderables:[],Manifests:{}};class PictView extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.options=this.fable.Utility.extend(JSON.parse(JSON.stringify(defaultPictViewSettings)),this.options);this.serviceType='PictView';// Wire in the essential Pict service
2934
+ if(!this.templates.hasOwnProperty(pTemplateHash)){this.checkDefaultTemplateHash(pTemplateHash);}if(this.templates.hasOwnProperty(pTemplateHash)){return this.templates[pTemplateHash];}else{return false;}}loadTemplate(pTemplateHash){let 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;}}module.exports=PictTemplateProvider;},{"fable":39}],113:[function(require,module,exports){const libFableServiceBase=require('fable').ServiceProviderBase;const defaultPictViewSettings={DefaultRenderable:false,DefaultDestinationAddress:false,DefaultTemplateRecordAddress:false,ViewIdentifier:'DEFAULT',InitializeOnLoad:true,RenderOnLoad:false,Templates:[],DefaultTemplates:[],Renderables:[],Manifests:{}};class PictView extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){let tmpOptions=Object.assign({},defaultPictViewSettings,pOptions);super(pFable,tmpOptions,pServiceHash);this.serviceType='PictView';// Wire in the essential Pict service
2934
2935
  this.AppData=this.fable.AppData;// Load all templates from the array in the options
2935
2936
  // Templates are in the form of {Hash:'Some-Template-Hash',Template:'Template content',Source:'TemplateSource'}
2936
2937
  for(let i=0;i<this.options.Templates.length;i++){let tmpTemplate=this.options.Templates[i];if(!tmpTemplate.hasOwnProperty('Hash')||!tmpTemplate.hasOwnProperty('Template')){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not load Template ").concat(i," in the options array."),tmpTemplate);}else{if(!tmpTemplate.Source){tmpTemplate.Source="PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," options object.");}this.fable.TemplateProvider.addTemplate(tmpTemplate.Hash,tmpTemplate.Template,tmpTemplate.Source);}}// Load all default templates from the array in the options
@@ -2943,9 +2944,12 @@ for(let i=0;i<this.options.DefaultTemplates.length;i++){let tmpDefaultTemplate=t
2943
2944
  this.renderables={};for(let i=0;i<this.options.Renderables.length;i++){let tmpRenderable=this.options.Renderables[i];if(!tmpRenderable.hasOwnProperty('RenderableHash')||!tmpRenderable.hasOwnProperty('TemplateHash')){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not load Renderable ").concat(i," in the options array."),tmpRenderable);}else{this.renderables[tmpRenderable.RenderableHash]=tmpRenderable;}}if(this.options.InitializeOnLoad){this.initialize();}if(this.options.RenderOnLoad){this.render(this.options.DefaultRenderable,this.options.DefaultDestinationAddress,this.options.DefaultTemplateRecordAddress);this.postInitialRenderInitialize();}}internalInitialize(){return true;}postInitialRenderInitialize(){return true;}initialize(){this.log.info("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," beginning initialization..."));this.internalInitialize();this.log.info("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," initialization complete."));}render(pRenderable,pRenderDestinationAddress,pTemplateDataAddress){let 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;}let 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;}let 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;}let tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.RecordAddress==='string'?tmpRenderable.RecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;let tmpData=typeof tmpDataAddress==='string'?this.fable.DataProvider.getDataByAddress(tmpDataAddress):undefined;let tmpContent=this.fable.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData);return this.fable.ContentAssignment.assignContent(tmpRenderDestinationAddress,tmpContent);}renderAsync(pRenderable,pRenderDestinationAddress,pTemplateDataAddress,fCallback){let tmpRenderableHash=typeof pRenderable==='string'?pRenderable: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.")));}let 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.")));}let 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)));}let tmpDataAddress=typeof pTemplateDataAddress==='string'?pTemplateDataAddress:typeof tmpRenderable.RecordAddress==='string'?tmpRenderable.RecordAddress:typeof this.options.DefaultTemplateRecordAddress==='string'?this.options.DefaultTemplateRecordAddress:false;let tmpData=typeof tmpDataAddress==='string'?this.fable.DataProvider.getDataByAddress(tmpDataAddress):undefined;this.fable.parseTemplateByHash(tmpRenderable.TemplateHash,tmpData,(pError,pContent)=>{if(pError){this.log.error("PictView [".concat(this.UUID,"]::[").concat(this.Hash,"] ").concat(this.options.ViewIdentifier," could not render (asynchronously) ").concat(tmpRenderableHash," (param ").concat(pRenderable,") because it did not parse the template."),pError);return fCallback(pError);}this.fable.ContentAssignment.assignContent(tmpRenderDestinationAddress,pContent);return fCallback(null,pContent);});}}module.exports=PictView;},{"fable":39}],114:[function(require,module,exports){/**
2944
2945
  * @author <steven@velozo.com>
2945
2946
  */const libFable=require('fable');class Pict extends libFable{constructor(pSettings){super(pSettings);this.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");// The templateProvider provides a basic key->template mapping with default fallback capabilities
2946
- this.serviceManager.addAndInstantiateServiceType('TemplateProvider',require('./Pict-Template-Provider.js'));this.serviceManager.addAndInstantiateServiceType('EntityProvider',require('./Pict-Meadow-EntityProvider.js'));this.serviceManager.addAndInstantiateServiceType('DataProvider',require('./Pict-DataProvider.js'));this.serviceManager.addAndInstantiateServiceType('ContentAssignment',require('./Pict-Content-Assignment.js'));this.serviceManager.instantiateServiceProvider('MetaTemplate');this.serviceManager.instantiateServiceProvider('DataGeneration');this.manifest=this.serviceManager.instantiateServiceProvider('Manifest');this.AppData={};this.Bundle={};// Log noisness goes from 0 - 5, where 5 is show me everything.
2947
- this.LogNoisiness=0;if(typeof this.settings.Manifests=='object'){let tmpManifestKeys=Object.keys(this.settings.Manifests);if(tmpManifestKeys.length>0){for(let i=0;i<tmpManifestKeys.length;i++){// Load each manifest
2948
- let tmpManifestKey=tmpManifestKeys[i];this.serviceManager.instantiateServiceProvider('Manifest',this.settings.Manifests[tmpManifestKey],tmpManifestKey);}}}this._DefaultPictTemplatesInitialized=false;this.initializePictTemplates();this.serviceManager.addServiceType('PictView',require('./Pict-View.js'));this.serviceManager.addServiceType('PictApplication',require('./Pict-Application.js'));}// Just passing an options will construct one for us.
2947
+ this.serviceManager.addAndInstantiateServiceType('TemplateProvider',require('./Pict-Template-Provider.js'));this.serviceManager.addAndInstantiateServiceType('EntityProvider',require('./Pict-Meadow-EntityProvider.js'));this.serviceManager.addAndInstantiateServiceType('DataProvider',require('./Pict-DataProvider.js'));this.serviceManager.addAndInstantiateServiceType('ContentAssignment',require('./Pict-Content-Assignment.js'));this.serviceManager.instantiateServiceProvider('MetaTemplate');this.serviceManager.instantiateServiceProvider('DataGeneration');this.manifest=this.serviceManager.instantiateServiceProvider('Manifest');this.AppData={};this.Bundle={};this.serviceManager.extraServiceInitialization=pService=>{// Decorate services with pict so we can use that instead of fable to eliminate confusion
2948
+ pService.pict=this;return pService;};// Log noisness goes from 0 - 5, where 5 is show me everything.
2949
+ this.LogNoisiness=0;// Load manifest sets
2950
+ if(this.settings.Manifests){this.loadManifestSet(this.settings.Manifests);}this._DefaultPictTemplatesInitialized=false;this.initializePictTemplates();this.serviceManager.addServiceType('PictView',require('./Pict-View.js'));this.serviceManager.addServiceType('PictApplication',require('./Pict-Application.js'));}// Load manifests in as Hashed services
2951
+ 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;}let tmpManifestKeys=Object.keys(pManifestSet.Manifests);if(tmpManifestKeys.length>0){for(let i=0;i<tmpManifestKeys.length;i++){// Load each manifest
2952
+ let tmpManifestKey=tmpManifestKeys[i];this.serviceManager.instantiateServiceProvider('Manifest',pManifestSet[tmpManifestKey],tmpManifestKey);}}}// Just passing an options will construct one for us.
2949
2953
  // Passing a hash will set the hash.
2950
2954
  // Passing a prototype will use that!
2951
2955
  addView(pOptions,pViewHash,pViewPrototype){let tmpOptions=typeof pOptions=='object'?pOptions:{};let tmpViewHash=typeof pViewHash=='string'?pViewHash:this.fable.getUUID();if(typeof pViewPrototype!='undefined'){return this.serviceManager.instantiateServiceProviderFromPrototype('PictView',tmpOptions,tmpViewHash,pViewPrototype);}else{return this.serviceManager.instantiateServiceProvider('PictView',tmpOptions,tmpViewHash);}}// Just passing an options will construct one for us.
@@ -2963,7 +2967,7 @@ addApplication(pOptions,pApplicationHash,pApplicationPrototype){let tmpOptions=t
2963
2967
  // ...meaning GET BOOK with IDBook FROM AppData.Some.Address.IDBook
2964
2968
  // {~E:Book:AppData.Some.Address.IDBook:Render-Book-Template~}
2965
2969
  // ...meaning GET BOOK with IDBook FROM AppData.Some.Address.IDBook and render it to Render-Book-Template
2966
- let fEntityRender=(pHash,pData,fCallback)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpEntity=false;let tmpEntityID=false;let tmpEntityTemplate=false;// This expression requires 2 parts -- a third is optional, and, if present, is the template to render to.
2970
+ let fEntityRender=(pHash,pData,fCallback)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fEntityRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>0){this.log.trace("PICT Template [fEntityRender]::[".concat(tmpHash,"]"));}let tmpEntity=false;let tmpEntityID=false;let tmpEntityTemplate=false;// This expression requires 2 parts -- a third is optional, and, if present, is the template to render to.
2967
2971
  let tmpHashSeparator=tmpHash.indexOf('|');if(tmpHashSeparator<0){// This is just a simple 2 part hash (the entity and the ID)
2968
2972
  let 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)
2969
2973
  let tmpHashEntitySeparator=tmpHash.indexOf(':');tmpEntity=tmpHash.substring(0,tmpHashEntitySeparator);let 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
@@ -2971,19 +2975,19 @@ tmpEntityID=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundl
2971
2975
  if(!tmpEntity||!tmpEntityID){this.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
2972
2976
  this.EntityProvider.getEntity(tmpEntity,tmpEntityID,(pError,pRecord)=>{if(pError){this.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
2973
2977
  if(tmpEntityTemplate){return fCallback(null,this.parseTemplateByHash(tmpEntityTemplate,pRecord));}else{return fCallback(null,'');}});};this.defaultServices.MetaTemplate.addPatternAsync('{~E:','~}',fEntityRender);this.defaultServices.MetaTemplate.addPatternAsync('{~Entity:','~}',fEntityRender);// {NE~Some.Address|If the left value is truthy, render this value.~}
2974
- let fNotEmptyRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};// Should switch this to indexOf so pipes can be in the content.
2978
+ let fNotEmptyRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>2){this.log.trace("PICT Template [fNotEmptyRender]::[".concat(tmpHash,"]"));}// Should switch this to indexOf so pipes can be in the content.
2975
2979
  let tmpHashParts=tmpHash.split('|');// For now just check truthiness
2976
2980
  if(this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHashParts[0])){return tmpHashParts[1];}else{return'';}};this.defaultServices.MetaTemplate.addPattern('{~NotEmpty:','~}',fNotEmptyRender);this.defaultServices.MetaTemplate.addPattern('{~NE:','~}',fNotEmptyRender);// {~T:Template:AddressOfData~}
2977
- let fTemplateRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpTemplateHash=false;let tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
2981
+ let fTemplateRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>0){this.log.trace("PICT Template [fTemplateRender]::[".concat(tmpHash,"]"));}let tmpTemplateHash=false;let tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
2978
2982
  let tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
2979
2983
  if(!tmpTemplateHash){this.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.
2980
2984
  return this.parseTemplateByHash(tmpTemplateHash,pData);}else{return this.parseTemplateByHash(tmpTemplateHash,this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpAddressOfData));}};this.defaultServices.MetaTemplate.addPattern('{~T:','~}',fTemplateRender);this.defaultServices.MetaTemplate.addPattern('{~Template:','~}',fTemplateRender);// {~TS:Template:AddressOfDataSet~}
2981
- let fTemplateSetRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpTemplateHash=false;let tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
2985
+ let fTemplateSetRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>0){this.log.trace("PICT Template [fTemplateSetRender]::[".concat(tmpHash,"]"));}let tmpTemplateHash=false;let tmpAddressOfData=false;// This is just a simple 2 part hash (the entity and the ID)
2982
2986
  let tmpHashTemplateSeparator=tmpHash.indexOf(':');tmpTemplateHash=tmpHash.substring(0,tmpHashTemplateSeparator);if(tmpHashTemplateSeparator>-1){tmpAddressOfData=tmpHash.substring(tmpHashTemplateSeparator+1);}else{tmpTemplateHash=tmpHash;}// No template hash
2983
2987
  if(!tmpTemplateHash){this.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.
2984
2988
  return this.parseTemplateSetByHash(tmpTemplateHash,pData);}else{return this.parseTemplateSetByHash(tmpTemplateHash,this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpAddressOfData));}};this.defaultServices.MetaTemplate.addPattern('{~TS:','~}',fTemplateSetRender);this.defaultServices.MetaTemplate.addPattern('{~TemplateSet:','~}',fTemplateSetRender);//{~Data:AppData.Some.Value.to.Render~}
2985
- let fDataRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpValue=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return tmpValue;};this.defaultServices.MetaTemplate.addPattern('{~D:','~}',fDataRender);this.defaultServices.MetaTemplate.addPattern('{~Data:','~}',fDataRender);this.defaultServices.MetaTemplate.addPattern('{~Dollars:','~}',(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpColumnData=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);return this.defaultServices.DataFormat.formatterDollars(tmpColumnData);});this.defaultServices.MetaTemplate.addPattern('{~Digits:','~}',(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpColumnData=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);return this.defaultServices.DataFormat.formatterAddCommasToNumber(this.defaultServices.DataFormat.formatterRoundNumber(tmpColumnData,2));});let fRandomNumberString=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpStringLength=4;let tmpMaxNumber=9999;if(tmpHash.length>0){let tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpStringLength=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return this.defaultServices.DataGeneration.randomNumericString(tmpStringLength,tmpMaxNumber);};this.defaultServices.MetaTemplate.addPattern('{~RandomNumberString:','~}',fRandomNumberString);this.defaultServices.MetaTemplate.addPattern('{~RNS:','~}',fRandomNumberString);let fPascalCaseIdentifier=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpValue=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return this.defaultServices.DataFormat.cleanNonAlphaCharacters(this.defaultServices.DataFormat.capitalizeEachWord(tmpValue));};this.defaultServices.MetaTemplate.addPattern('{~PascalCaseIdentifier:','~}',fPascalCaseIdentifier);this._DefaultPictTemplatesInitialized=true;}}parseTemplate(pTemplateString,pData,fCallback){let tmpData=typeof pData==='object'?pData:{};return this.defaultServices.MetaTemplate.parseString(pTemplateString,tmpData,fCallback);}parseTemplateByHash(pTemplateHash,pData,fCallback){let tmpTemplateString=this.defaultServices.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
2989
+ let fDataRender=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>3){this.log.trace("PICT Template [fDataRender]::[".concat(tmpHash,"]"));}let tmpValue=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return tmpValue;};this.defaultServices.MetaTemplate.addPattern('{~D:','~}',fDataRender);this.defaultServices.MetaTemplate.addPattern('{~Data:','~}',fDataRender);this.defaultServices.MetaTemplate.addPattern('{~Dollars:','~}',(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>3){this.log.trace("PICT Template [fDollars]::[".concat(tmpHash,"]"));}let tmpColumnData=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);return this.defaultServices.DataFormat.formatterDollars(tmpColumnData);});this.defaultServices.MetaTemplate.addPattern('{~Digits:','~}',(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>3){this.log.trace("PICT Template [fDigits]::[".concat(tmpHash,"]"));}let tmpColumnData=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);return this.defaultServices.DataFormat.formatterAddCommasToNumber(this.defaultServices.DataFormat.formatterRoundNumber(tmpColumnData,2));});let fRandomNumberString=(pHash,pData)=>{let tmpHash=pHash.trim();if(this.LogNoisiness>3){this.log.trace("PICT Template [fRandomNumberString]::[".concat(tmpHash,"]"));}let tmpStringLength=4;let tmpMaxNumber=9999;if(tmpHash.length>0){let tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpStringLength=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return this.defaultServices.DataGeneration.randomNumericString(tmpStringLength,tmpMaxNumber);};this.defaultServices.MetaTemplate.addPattern('{~RandomNumberString:','~}',fRandomNumberString);this.defaultServices.MetaTemplate.addPattern('{~RNS:','~}',fRandomNumberString);let fRandomNumber=(pHash,pData)=>{let tmpHash=pHash.trim();if(this.LogNoisiness>3){this.log.trace("PICT Template [fRandomNumber]::[".concat(tmpHash,"]"));}let tmpMinimumNumber=0;let tmpMaxNumber=9999999;if(tmpHash.length>0){let tmpHashParts=tmpHash.split(',');if(tmpHashParts.length>0){tmpMinimumNumber=parseInt(tmpHashParts[0]);}if(tmpHashParts.length>1){tmpMaxNumber=parseInt(tmpHashParts[1]);}}return this.defaultServices.DataGeneration.randomIntegerBetween(tmpMinimumNumber,tmpMaxNumber);};this.defaultServices.MetaTemplate.addPattern('{~RandomNumber:','~}',fRandomNumber);this.defaultServices.MetaTemplate.addPattern('{~RN:','~}',fRandomNumber);let fPascalCaseIdentifier=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};if(this.LogNoisiness>4){this.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"] with tmpData:"),tmpData);}else if(this.LogNoisiness>3){this.log.trace("PICT Template [fPascalCaseIdentifier]::[".concat(tmpHash,"]"));}let tmpValue=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);if(tmpValue==null||tmpValue=='undefined'||typeof tmpValue=='undefined'){return'';}return this.defaultServices.DataFormat.cleanNonAlphaCharacters(this.defaultServices.DataFormat.capitalizeEachWord(tmpValue));};this.defaultServices.MetaTemplate.addPattern('{~PascalCaseIdentifier:','~}',fPascalCaseIdentifier);let fLogValue=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpData=typeof pData==='object'?pData:{};let tmpValue=this.manifest.getValueByHash({AppData:this.AppData,Bundle:this.Bundle,Record:tmpData},tmpHash);let tmpValueType=typeof tmpValue;if(tmpValue==null||tmpValueType=='undefined'){this.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is ").concat(tmpValueType,"."));}else if(tmpValueType=='object'){this.log.trace("PICT Template Log Value: [".concat(tmpHash,"] is an obect."),tmpValue);}else{this.log.trace("PICT Template Log Value: [".concat(tmpHash,"] if a ").concat(tmpValueType," = [").concat(tmpValue,"]"));}return'';};this.defaultServices.MetaTemplate.addPattern('{~LogValue:','~}',fLogValue);this.defaultServices.MetaTemplate.addPattern('{~LV:','~}',fLogValue);let fLogStatement=(pHash,pData)=>{let tmpHash=pHash.trim();this.log.trace("PICT Template Log Message: ".concat(tmpHash));return'';};this.defaultServices.MetaTemplate.addPattern('{~LogStatement:','~}',fLogStatement);this.defaultServices.MetaTemplate.addPattern('{~LS:','~}',fLogStatement);let fBreakpoint=(pHash,pData)=>{let tmpHash=pHash.trim();let tmpError=new Error("PICT Template Breakpoint: ".concat(tmpHash));this.log.trace("PICT Template Breakpoint: ".concat(tmpHash),tmpError.stack);debugger;return'';};this.defaultServices.MetaTemplate.addPattern('{~Breakpoint','~}',fBreakpoint);this._DefaultPictTemplatesInitialized=true;}}parseTemplate(pTemplateString,pData,fCallback){let tmpData=typeof pData==='object'?pData:{};return this.defaultServices.MetaTemplate.parseString(pTemplateString,tmpData,fCallback);}parseTemplateByHash(pTemplateHash,pData,fCallback){let tmpTemplateString=this.defaultServices.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
2986
2990
  if(!tmpTemplateString){return'';}return this.parseTemplate(tmpTemplateString,pData,fCallback);}parseTemplateSet(pTemplateString,pDataSet,fCallback){// TODO: This will need streaming -- for now janky old string append does the trick
2987
2991
  let tmpValue='';if(typeof fCallback=='function'){if(Array.isArray(pDataSet)||typeof pDataSet=='object'){this.defaultServices.Utility.eachLimit(pDataSet,1,(pRecord,fRecordTemplateCallback)=>{return this.parseTemplate(pTemplateString,pRecord,(pError,pTemplateResult)=>{tmpValue+=pTemplateResult;return fRecordTemplateCallback();});},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(let i=0;i<pDataSet.length;i++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[i]);}}else{let tmpKeys=Object.keys(pDataSet);for(let i=0;i<tmpKeys.length;i++){tmpValue+=this.parseTemplate(pTemplateString,pDataSet[tmpKeys[i]]);}}return tmpValue;}else{return'';}}}parseTemplateSetByHash(pTemplateHash,pDataSet,fCallback){let tmpTemplateString=this.defaultServices.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
2988
2992
  if(!tmpTemplateString){return'';}return this.parseTemplateSet(tmpTemplateString,pDataSet,fCallback);}};module.exports=Pict;module.exports.PictApplicationClass=require('./Pict-Application.js');module.exports.PictViewClass=require('./Pict-View.js');// This is to help understand the type of enivironement we're executing in
2989
- module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-Application.js":108,"./Pict-Content-Assignment.js":109,"./Pict-DataProvider.js":110,"./Pict-Meadow-EntityProvider.js":111,"./Pict-Template-Provider.js":112,"./Pict-View.js":113,"fable":39}]},{},[114]);
2993
+ module.exports.isBrowser=new Function("try {return (this===window);} catch(pError) {return false;}");},{"./Pict-Application.js":108,"./Pict-Content-Assignment.js":109,"./Pict-DataProvider.js":110,"./Pict-Meadow-EntityProvider.js":111,"./Pict-Template-Provider.js":112,"./Pict-View.js":113,"fable":39}]},{},[114])(114);});