fable 3.0.47 → 3.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fable.js CHANGED
@@ -2396,7 +2396,11 @@ this.services[pServiceType]={};// Using the static member of the class is a much
2396
2396
  if(typeof pServiceClass=='function'&&pServiceClass.isFableService){// Add the class to the list of classes
2397
2397
  this.serviceClasses[pServiceType]=pServiceClass;}else{// Add the base class to the list of classes
2398
2398
  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
2399
- addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}instantiateServiceProvider(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
2399
+ addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}// Some servicds expect to be overloaded / customized class.
2400
+ instantiateServiceProviderFromPrototype(pServiceType,pOptions,pCustomServiceHash,pServicePrototype){// Instantiate the service
2401
+ let tmpService=new pServicePrototype(this.fable,pOptions,pCustomServiceHash);// Add the service to the service map
2402
+ this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
2403
+ if(!this.defaultServices.hasOwnProperty(pServiceType)){this.setDefaultServiceInstantiation(pServiceType,tmpService.Hash);}return tmpService;}instantiateServiceProvider(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
2400
2404
  let tmpService=this.instantiateServiceProviderWithoutRegistration(pServiceType,pOptions,pCustomServiceHash);// Add the service to the service map
2401
2405
  this.services[pServiceType][tmpService.Hash]=tmpService;// If this is the first service of this type, make it the default
2402
2406
  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
@@ -2662,7 +2666,7 @@ this.StringParser=new libStringParser(this.fable.defaultServices.Utility.eachLim
2662
2666
  * @param {object} pData - Data to pass in as the second argument
2663
2667
  * @return {string} The result from the parser
2664
2668
  */parseString(pString,pData,fCallback){return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback);}}module.exports=FableServiceMetaTemplate;},{"../Fable-ServiceManager.js":92,"./Fable-Service-MetaTemplate/MetaTemplate-StringParser.js":98,"./Fable-Service-MetaTemplate/MetaTemplate-WordTree.js":99}],98:[function(require,module,exports){/**
2665
- * MetaTemplate String Parser
2669
+ * String Parser
2666
2670
  * @author Steven Velozo <steven@velozo.com>
2667
2671
  * @description Parse a string, properly processing each matched token in the word tree.
2668
2672
  */class StringParser{/**
@@ -2673,16 +2677,7 @@ this.StringParser=new libStringParser(this.fable.defaultServices.Utility.eachLim
2673
2677
  * @param {Object} pParseTree - A node on the parse tree to begin parsing from (usually root)
2674
2678
  * @return {Object} A new parser state object for running a character parser on
2675
2679
  * @private
2676
- */newParserState(pParseTree){return{ParseTree:pParseTree,Asynchronous:false,Output:'',OutputBuffer:'',Pattern:false,PatternMatch:false,PatternMatchOutputBuffer:''};}/**
2677
- * Assign a node of the parser tree to be the next potential match.
2678
- * If the node has a PatternEnd property, it is a valid match and supercedes the last valid match (or becomes the initial match).
2679
- * @method assignNode
2680
- * @param {Object} pNode - A node on the parse tree to assign
2681
- * @param {Object} pParserState - The state object for the current parsing task
2682
- * @private
2683
- */assignNode(pNode,pParserState){pParserState.PatternMatch=pNode;// If the pattern has a END we can assume it has a parse function...
2684
- if(pParserState.PatternMatch.hasOwnProperty('PatternEnd')){// ... this is the legitimate start of a pattern.
2685
- pParserState.Pattern=pParserState.PatternMatch;}}/**
2680
+ */newParserState(pParseTree){return{ParseTree:pParseTree,Asynchronous:false,Output:'',OutputBuffer:'',Pattern:{},PatternMatch:false,PatternMatchEnd:false};}/**
2686
2681
  * Append a character to the output buffer in the parser state.
2687
2682
  * This output buffer is used when a potential match is being explored, or a match is being explored.
2688
2683
  * @method appendOutputBuffer
@@ -2694,44 +2689,57 @@ pParserState.Pattern=pParserState.PatternMatch;}}/**
2694
2689
  * @method flushOutputBuffer
2695
2690
  * @param {Object} pParserState - The state object for the current parsing task
2696
2691
  * @private
2697
- */flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}/**
2698
- * Check if the pattern has ended. If it has, properly flush the buffer and start looking for new patterns.
2699
- * @method checkPatternEnd
2692
+ */flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}resetOutputBuffer(pParserState){// Flush the output buffer.
2693
+ this.flushOutputBuffer(pParserState);// End pattern mode
2694
+ pParserState.Pattern=false;pParserState.PatternStartNode=false;pParserState.StartPatternMatchComplete=false;pParserState.EndPatternMatchBegan=false;pParserState.PatternMatch=false;return true;}/**
2695
+ * Parse a character in the buffer.
2696
+ * @method parseCharacter
2697
+ * @param {string} pCharacter - The character to append
2700
2698
  * @param {Object} pParserState - The state object for the current parsing task
2701
2699
  * @private
2702
- */checkPatternEnd(pParserState,pData){if(pParserState.OutputBuffer.length>=pParserState.Pattern.PatternEnd.length+pParserState.Pattern.PatternStart.length&&pParserState.OutputBuffer.substr(-pParserState.Pattern.PatternEnd.length)===pParserState.Pattern.PatternEnd){// ... this is the end of a pattern, cut off the end tag and parse it.
2703
- // Trim the start and end tags off the output buffer now
2704
- if(pParserState.Pattern.isAsync){console.log("Precedent ERROR: Async template detected for pattern ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd," but the template engine is being run in non-async mode."));this.OutputBuffer='';// Flush the output buffer.
2705
- this.flushOutputBuffer(pParserState);// End pattern mode
2706
- pParserState.Pattern=false;pParserState.PatternMatch=false;}else{pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStart.length+pParserState.Pattern.PatternEnd.length)),pData);// Flush the output buffer.
2707
- this.flushOutputBuffer(pParserState);// End pattern mode
2708
- pParserState.Pattern=false;pParserState.PatternMatch=false;}}}checkPatternEndAsync(pParserState,pData,fCallback){if(pParserState.OutputBuffer.length>=pParserState.Pattern.PatternEnd.length+pParserState.Pattern.PatternStart.length&&pParserState.OutputBuffer.substr(-pParserState.Pattern.PatternEnd.length)===pParserState.Pattern.PatternEnd){// ... this is the end of a pattern, cut off the end tag and parse it.
2709
- // Trim the start and end tags off the output buffer now
2710
- if(pParserState.Pattern.isAsync){return pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStart.length+pParserState.Pattern.PatternEnd.length)),pData,(pError,pAsyncOutput)=>{if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;// Flush the output buffer.
2711
- this.flushOutputBuffer(pParserState);// End pattern mode
2712
- pParserState.Pattern=false;pParserState.PatternMatch=false;return fCallback();});}else{pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStart.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStart.length+pParserState.Pattern.PatternEnd.length)),pData);// Flush the output buffer.
2713
- this.flushOutputBuffer(pParserState);// End pattern mode
2714
- pParserState.Pattern=false;pParserState.PatternMatch=false;}}return fCallback();}/**
2700
+ */parseCharacter(pCharacter,pParserState,pData){// If we are already in a pattern match traversal
2701
+ if(pParserState.PatternMatch){// If the pattern is still matching the start and we haven't passed the buffer
2702
+ if(!pParserState.StartPatternMatchComplete&&pParserState.Pattern.hasOwnProperty(pCharacter)){pParserState.Pattern=pParserState.Pattern[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else if(pParserState.EndPatternMatchBegan){if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This leaf has a PatternEnd tree, so we will wait until that end is met.
2703
+ pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the output buffer.
2704
+ this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
2705
+ if(pParserState.Pattern.hasOwnProperty('Parse')){// Run the function
2706
+ pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);return this.resetOutputBuffer(pParserState);}}else if(pParserState.PatternStartNode.PatternEnd.hasOwnProperty(pCharacter)){// We broke out of the end -- see if this is a new start of the end.
2707
+ pParserState.Pattern=pParserState.PatternStartNode.PatternEnd[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else{pParserState.EndPatternMatchBegan=false;this.appendOutputBuffer(pCharacter,pParserState);}}else if(pParserState.Pattern.hasOwnProperty('PatternEnd')){if(!pParserState.StartPatternMatchComplete){pParserState.StartPatternMatchComplete=true;pParserState.PatternStartNode=pParserState.Pattern;}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This is the first character of the end pattern.
2708
+ pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
2709
+ pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// If this last character is the end of the pattern, parse it.
2710
+ if(pParserState.Pattern.hasOwnProperty('Parse')){if(pParserState.Pattern.isAsync){this.log.error("MetaTemplate: The pattern ".concat(pParserState.Pattern.PatternStartString," is asynchronous and cannot be used in a synchronous parser."));this.resetOutputBuffer(pParserState);}else{// Run the t*mplate function
2711
+ pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);return this.resetOutputBuffer(pParserState);}}}}else{// We are in a pattern start but didn't match one; reset and start trying again from this character.
2712
+ this.resetOutputBuffer(pParserState);}}// If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
2713
+ if(!pParserState.PatternMatch){// This may be the start of a new pattern....
2714
+ if(pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the root node as the matched node.
2715
+ this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;return true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return false;}/**
2715
2716
  * Parse a character in the buffer.
2716
2717
  * @method parseCharacter
2717
2718
  * @param {string} pCharacter - The character to append
2718
2719
  * @param {Object} pParserState - The state object for the current parsing task
2719
2720
  * @private
2720
- */parseCharacter(pCharacter,pParserState,pData){// (1) If we aren't in a pattern match, and we aren't potentially matching, and this may be the start of a new pattern....
2721
- if(!pParserState.PatternMatch&&pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the node as the matched node.
2722
- this.assignNode(pParserState.ParseTree[pCharacter],pParserState);this.appendOutputBuffer(pCharacter,pParserState);}// (2) If we are in a pattern match (actively seeing if this is part of a new pattern token)
2723
- else if(pParserState.PatternMatch){// If the pattern has a subpattern with this key
2724
- if(pParserState.PatternMatch.hasOwnProperty(pCharacter)){// Continue matching patterns.
2725
- this.assignNode(pParserState.PatternMatch[pCharacter],pParserState);}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern){// ... Check if this is the end of the pattern (if we are matching a valid pattern)...
2726
- this.checkPatternEnd(pParserState,pData);}}// (3) If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
2727
- else{pParserState.Output+=pCharacter;}}parseCharacterAsync(pCharacter,pParserState,pData,fCallback){// (1) If we aren't in a pattern match, and we aren't potentially matching, and this may be the start of a new pattern....
2728
- if(!pParserState.PatternMatch&&pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the node as the matched node.
2729
- this.assignNode(pParserState.ParseTree[pCharacter],pParserState);this.appendOutputBuffer(pCharacter,pParserState);}// (2) If we are in a pattern match (actively seeing if this is part of a new pattern token)
2730
- else if(pParserState.PatternMatch){// If the pattern has a subpattern with this key
2731
- if(pParserState.PatternMatch.hasOwnProperty(pCharacter)){// Continue matching patterns.
2732
- this.assignNode(pParserState.PatternMatch[pCharacter],pParserState);}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern){// ... Check if this is the end of the pattern (if we are matching a valid pattern)...
2733
- return this.checkPatternEndAsync(pParserState,pData,fCallback);}}// (3) If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
2734
- else{pParserState.Output+=pCharacter;}return fCallback(null);}/**
2721
+ */parseCharacterAsync(pCharacter,pParserState,pData,fCallback){// If we are already in a pattern match traversal
2722
+ if(pParserState.PatternMatch){// If the pattern is still matching the start and we haven't passed the buffer
2723
+ if(!pParserState.StartPatternMatchComplete&&pParserState.Pattern.hasOwnProperty(pCharacter)){pParserState.Pattern=pParserState.Pattern[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else if(pParserState.EndPatternMatchBegan){if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This leaf has a PatternEnd tree, so we will wait until that end is met.
2724
+ pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the output buffer.
2725
+ this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
2726
+ if(pParserState.Pattern.hasOwnProperty('Parse')){// ... this is the end of a pattern, cut off the end tag and parse it.
2727
+ // Trim the start and end tags off the output buffer now
2728
+ if(pParserState.Pattern.isAsync){// Run the function
2729
+ return pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,(pError,pAsyncOutput)=>{if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;this.resetOutputBuffer(pParserState);return fCallback();});}else{// Run the t*mplate function
2730
+ pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);this.resetOutputBuffer(pParserState);return fCallback();}}}else if(pParserState.PatternStartNode.PatternEnd.hasOwnProperty(pCharacter)){// We broke out of the end -- see if this is a new start of the end.
2731
+ pParserState.Pattern=pParserState.PatternStartNode.PatternEnd[pCharacter];this.appendOutputBuffer(pCharacter,pParserState);}else{pParserState.EndPatternMatchBegan=false;this.appendOutputBuffer(pCharacter,pParserState);}}else if(pParserState.Pattern.hasOwnProperty('PatternEnd')){if(!pParserState.StartPatternMatchComplete){pParserState.StartPatternMatchComplete=true;pParserState.PatternStartNode=pParserState.Pattern;}this.appendOutputBuffer(pCharacter,pParserState);if(pParserState.Pattern.PatternEnd.hasOwnProperty(pCharacter)){// This is the first character of the end pattern.
2732
+ pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
2733
+ pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// If this last character is the end of the pattern, parse it.
2734
+ if(pParserState.Pattern.hasOwnProperty('Parse')){// ... this is the end of a pattern, cut off the end tag and parse it.
2735
+ // Trim the start and end tags off the output buffer now
2736
+ if(pParserState.Pattern.isAsync){// Run the function
2737
+ return pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData,(pError,pAsyncOutput)=>{if(pError){console.log("Precedent ERROR: Async template error happened parsing ".concat(pParserState.Pattern.PatternStart," ... ").concat(pParserState.Pattern.PatternEnd,": ").concat(pError));}pParserState.OutputBuffer=pAsyncOutput;this.resetOutputBuffer(pParserState);return fCallback();});}else{// Run the t*mplate function
2738
+ pParserState.OutputBuffer=pParserState.Pattern.Parse(pParserState.OutputBuffer.substr(pParserState.Pattern.PatternStartString.length,pParserState.OutputBuffer.length-(pParserState.Pattern.PatternStartString.length+pParserState.Pattern.PatternEndString.length)),pData);this.resetOutputBuffer(pParserState);return fCallback();}}}}else{// We are in a pattern start but didn't match one; reset and start trying again from this character.
2739
+ this.resetOutputBuffer(pParserState);return fCallback();}}// If we aren't in a pattern match or pattern, and this isn't the start of a new pattern (RAW mode)....
2740
+ if(!pParserState.PatternMatch){// This may be the start of a new pattern....
2741
+ if(pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the root node as the matched node.
2742
+ this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return fCallback();}/**
2735
2743
  * Parse a string for matches, and process any template segments that occur.
2736
2744
  * @method parseString
2737
2745
  * @param {string} pString - The string to parse.
@@ -2740,9 +2748,9 @@ else{pParserState.Output+=pCharacter;}return fCallback(null);}/**
2740
2748
  * @param {function} fCallback - The callback function to call when the parse is complete
2741
2749
  */parseString(pString,pParseTree,pData,fCallback){if(typeof fCallback!=='function'){let tmpParserState=this.newParserState(pParseTree);for(var i=0;i<pString.length;i++){// TODO: This is not fast.
2742
2750
  this.parseCharacter(pString[i],tmpParserState,pData,fCallback);}this.flushOutputBuffer(tmpParserState);return tmpParserState.Output;}else{// This is the async mode
2743
- let tmpParserState=this.newParserState(pParseTree);this.eachLimit(pString,1,(pCharacter,fCharacterCallback)=>{this.parseCharacterAsync(pCharacter,tmpParserState,pData,fCharacterCallback);},pError=>{// Flush the remaining data
2751
+ let tmpParserState=this.newParserState(pParseTree);tmpParserState.Asynchronous=true;this.eachLimit(pString,1,(pCharacter,fCharacterCallback)=>{this.parseCharacterAsync(pCharacter,tmpParserState,pData,fCharacterCallback);},pError=>{// Flush the remaining data
2744
2752
  this.flushOutputBuffer(tmpParserState);fCallback(pError,tmpParserState.Output);});}}}module.exports=StringParser;},{}],99:[function(require,module,exports){/**
2745
- * MetaTemplate Word Tree
2753
+ * Word Tree
2746
2754
  * @author Steven Velozo <steven@velozo.com>
2747
2755
  * @description Create a tree (directed graph) of Javascript objects, one character per object.
2748
2756
  */class WordTree{/**
@@ -2752,24 +2760,29 @@ this.flushOutputBuffer(tmpParserState);fCallback(pError,tmpParserState.Output);}
2752
2760
  * @method addChild
2753
2761
  * @param {Object} pTree - A parse tree to push the characters into
2754
2762
  * @param {string} pPattern - The string to add to the tree
2755
- * @param {number} pIndex - The index of the character in the pattern
2756
2763
  * @returns {Object} The resulting leaf node that was added (or found)
2757
2764
  * @private
2758
- */addChild(pTree,pPattern,pIndex){if(!pTree.hasOwnProperty(pPattern[pIndex]))pTree[pPattern[pIndex]]={};return pTree[pPattern[pIndex]];}/** Add a Pattern to the Parse Tree
2765
+ */addChild(pTree,pPattern){if(!pTree.hasOwnProperty(pPattern)){pTree[pPattern]={};}return pTree[pPattern];}/**
2766
+ * Add a child character to a Parse Tree PatternEnd subtree
2767
+ * @method addChild
2768
+ * @param {Object} pTree - A parse tree to push the characters into
2769
+ * @param {string} pPattern - The string to add to the tree
2770
+ * @returns {Object} The resulting leaf node that was added (or found)
2771
+ * @private
2772
+ */addEndChild(pTree,pPattern){if(!pTree.hasOwnProperty('PatternEnd')){pTree.PatternEnd={};}pTree.PatternEnd[pPattern]={};return pTree.PatternEnd[pPattern];}/** Add a Pattern to the Parse Tree
2759
2773
  * @method addPattern
2760
2774
  * @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
2761
2775
  * @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
2762
- * @param {number} pParser - 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.
2776
+ * @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.
2763
2777
  * @return {bool} True if adding the pattern was successful
2764
- */addPattern(pPatternStart,pPatternEnd,pParser){if(pPatternStart.length<1)return false;if(typeof pPatternEnd==='string'&&pPatternEnd.length<1)return false;let tmpLeaf=this.ParseTree;// Add the tree of leaves iteratively
2765
- for(var i=0;i<pPatternStart.length;i++)tmpLeaf=this.addChild(tmpLeaf,pPatternStart,i);tmpLeaf.PatternStart=pPatternStart;tmpLeaf.PatternEnd=typeof pPatternEnd==='string'&&pPatternEnd.length>0?pPatternEnd:pPatternStart;tmpLeaf.Parse=typeof pParser==='function'?pParser:typeof pParser==='string'?()=>{return pParser;}:pData=>{return pData;};tmpLeaf.isPromise=false;return true;}/** Add a Pattern to the Parse Tree (asynchronous)
2778
+ */addPattern(pPatternStart,pPatternEnd,fParser){if(pPatternStart.length<1){return false;}if(typeof pPatternEnd==='string'&&pPatternEnd.length<1){return false;}let tmpLeaf=this.ParseTree;// Add the tree of leaves iteratively
2779
+ for(var i=0;i<pPatternStart.length;i++){tmpLeaf=this.addChild(tmpLeaf,pPatternStart[i],i);}if(!tmpLeaf.hasOwnProperty('PatternEnd')){tmpLeaf.PatternEnd={};}let tmpPatternEnd=typeof pPatternEnd==='string'?pPatternEnd:pPatternStart;for(let i=0;i<tmpPatternEnd.length;i++){tmpLeaf=this.addEndChild(tmpLeaf,tmpPatternEnd[i],i);}tmpLeaf.PatternStartString=pPatternStart;tmpLeaf.PatternEndString=tmpPatternEnd;tmpLeaf.Parse=typeof fParser==='function'?fParser:typeof fParser==='string'?()=>{return fParser;}:pData=>{return pData;};return tmpLeaf;}/** Add a Pattern to the Parse Tree
2766
2780
  * @method addPattern
2767
2781
  * @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
2768
2782
  * @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
2769
- * @param {number} pParserAsync - The function (with an asynchronous callback) to parse if this is the matched pattern, once the Pattern End is met. If this is a string, a simple replacement occurs.
2783
+ * @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.
2770
2784
  * @return {bool} True if adding the pattern was successful
2771
- */addPatternAsync(pPatternStart,pPatternEnd,pParserAsync){if(pPatternStart.length<1)return false;if(typeof pPatternEnd==='string'&&pPatternEnd.length<1)return false;let tmpLeaf=this.ParseTree;// Add the tree of leaves iteratively
2772
- for(var i=0;i<pPatternStart.length;i++)tmpLeaf=this.addChild(tmpLeaf,pPatternStart,i);tmpLeaf.PatternStart=pPatternStart;tmpLeaf.PatternEnd=typeof pPatternEnd==='string'&&pPatternEnd.length>0?pPatternEnd:pPatternStart;tmpLeaf.Parse=typeof pParserAsync==='function'?pParserAsync:typeof pParserAsync==='string'?(pHash,pData,fCallback)=>{fCallback(pParserPromise);}:(pHash,pData,fCallback)=>{return fCallback(pHash);};tmpLeaf.isAsync=true;return true;}}module.exports=WordTree;},{}],100:[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":[]};},{}],101:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));class FableOperation extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='PhasedOperation';this.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
2785
+ */addPatternAsync(pPatternStart,pPatternEnd,fParser){let tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;}}}module.exports=WordTree;},{}],100:[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":[]};},{}],101:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));class FableOperation extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.serviceType='PhasedOperation';this.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
2773
2786
  this.state.Metadata.Hash=this.Hash;this.state.Metadata.UUID=this.UUID;this.name=typeof this.options.Name=='string'?this.options.Name:"Unnamed Operation ".concat(this.state.Metadata.UUID);this.log=this;}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));}}writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(typeof pLogObject=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}}module.exports=FableOperation;},{"../Fable-ServiceManager.js":92,"./Fable-Service-Operation-DefaultSettings.js":100}],102:[function(require,module,exports){const libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;const libSimpleGet=require('simple-get');class FableServiceRestClient extends libFableServiceBase{constructor(pFable,pOptions,pServiceHash){super(pFable,pOptions,pServiceHash);this.TraceLog=false;if(this.options.TraceLog||this.fable.TraceLog){this.TraceLog=true;}this.dataFormat=this.fable.defaultServices.DataFormat;this.serviceType='RestClient';// This is a function that can be overridden, to allow the management
2774
2787
  // of the request options before they are passed to the request library.
2775
2788
  this.prepareRequestOptions=pOptions=>{return pOptions;};}preRequest(pOptions){// Validate the options object