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/.browserslistrc +1 -1
- package/dist/fable.compatible.js +66 -53
- package/dist/fable.compatible.min.js +5 -5
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +66 -53
- package/dist/fable.min.js +4 -4
- package/dist/fable.min.js.map +1 -1
- package/gulpfile-config.json +2 -2
- package/gulpfile.js +2 -2
- package/package.json +1 -1
- package/source/Fable-ServiceManager.js +19 -0
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-StringParser.js +222 -128
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-WordTree.js +62 -39
- package/test/FableServiceManager_tests.js +3 -0
- package/test/MetaTemplating_tests.js +0 -3
package/.browserslistrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
since 2018
|
package/dist/fable.compatible.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
|
-
},{key:"addAndInstantiateServiceType",value:function addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}
|
|
2399
|
+
},{key:"addAndInstantiateServiceType",value:function addAndInstantiateServiceType(pServiceType,pServiceClass){this.addServiceType(pServiceType,pServiceClass);this.instantiateServiceProvider(pServiceType,{},"".concat(pServiceType,"-Default"));}// Some servicds expect to be overloaded / customized class.
|
|
2400
|
+
},{key:"instantiateServiceProviderFromPrototype",value:function instantiateServiceProviderFromPrototype(pServiceType,pOptions,pCustomServiceHash,pServicePrototype){// Instantiate the service
|
|
2401
|
+
var 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;}},{key:"instantiateServiceProvider",value:function instantiateServiceProvider(pServiceType,pOptions,pCustomServiceHash){// Instantiate the service
|
|
2400
2404
|
var 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 @@ _this20.StringParser=new libStringParser(_this20.fable.defaultServices.Utility.e
|
|
|
2662
2666
|
* @param {object} pData - Data to pass in as the second argument
|
|
2663
2667
|
* @return {string} The result from the parser
|
|
2664
2668
|
*/},{key:"parseString",value:function parseString(pString,pData,fCallback){return this.StringParser.parseString(pString,this.ParseTree,pData,fCallback);}}]);return FableServiceMetaTemplate;}(libFableServiceBase);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
|
-
*
|
|
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
|
*/var StringParser=/*#__PURE__*/function(){/**
|
|
@@ -2673,16 +2677,7 @@ _this20.StringParser=new libStringParser(_this20.fable.defaultServices.Utility.e
|
|
|
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
|
-
*/_createClass2(StringParser,[{key:"newParserState",value:function newParserState(pParseTree){return{ParseTree:pParseTree,Asynchronous:false,Output:'',OutputBuffer:'',Pattern:
|
|
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
|
-
*/},{key:"assignNode",value:function 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
|
+
*/_createClass2(StringParser,[{key:"newParserState",value:function 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
|
-
*/},{key:"flushOutputBuffer",value:function flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}
|
|
2698
|
-
|
|
2699
|
-
|
|
2692
|
+
*/},{key:"flushOutputBuffer",value:function flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}},{key:"resetOutputBuffer",value:function 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
|
-
*/},{key:"
|
|
2703
|
-
//
|
|
2704
|
-
if(pParserState.Pattern.
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
pParserState.
|
|
2709
|
-
//
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
pParserState.Pattern
|
|
2713
|
-
this.
|
|
2714
|
-
|
|
2700
|
+
*/},{key:"parseCharacter",value:function 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
|
-
*/},{key:"
|
|
2721
|
-
if(
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
else if(pParserState.
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2721
|
+
*/},{key:"parseCharacterAsync",value:function parseCharacterAsync(pCharacter,pParserState,pData,fCallback){var _this21=this;// 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,function(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;_this21.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,function(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;_this21.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
|
*/},{key:"parseString",value:function parseString(pString,pParseTree,pData,fCallback){var _this22=this;if(typeof fCallback!=='function'){var 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
|
-
var _tmpParserState=this.newParserState(pParseTree);this.eachLimit(pString,1,function(pCharacter,fCharacterCallback){_this22.parseCharacterAsync(pCharacter,_tmpParserState,pData,fCharacterCallback);},function(pError){// Flush the remaining data
|
|
2751
|
+
var _tmpParserState=this.newParserState(pParseTree);_tmpParserState.Asynchronous=true;this.eachLimit(pString,1,function(pCharacter,fCharacterCallback){_this22.parseCharacterAsync(pCharacter,_tmpParserState,pData,fCharacterCallback);},function(pError){// Flush the remaining data
|
|
2744
2752
|
_this22.flushOutputBuffer(_tmpParserState);fCallback(pError,_tmpParserState.Output);});}}}]);return StringParser;}();module.exports=StringParser;},{}],99:[function(require,module,exports){/**
|
|
2745
|
-
*
|
|
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
|
*/var WordTree=/*#__PURE__*/function(){/**
|
|
@@ -2752,24 +2760,29 @@ _this22.flushOutputBuffer(_tmpParserState);fCallback(pError,_tmpParserState.Outp
|
|
|
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
|
-
*/_createClass2(WordTree,[{key:"addChild",value:function addChild(pTree,pPattern
|
|
2765
|
+
*/_createClass2(WordTree,[{key:"addChild",value:function 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
|
+
*/},{key:"addEndChild",value:function 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 {
|
|
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
|
-
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,
|
|
2765
|
-
for(var i=0;i<pPatternStart.length;i++)tmpLeaf=this.addChild(tmpLeaf,pPatternStart,i);tmpLeaf.
|
|
2778
|
+
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,fParser){if(pPatternStart.length<1){return false;}if(typeof pPatternEnd==='string'&&pPatternEnd.length<1){return false;}var 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={};}var tmpPatternEnd=typeof pPatternEnd==='string'?pPatternEnd:pPatternStart;for(var _i10=0;_i10<tmpPatternEnd.length;_i10++){tmpLeaf=this.addEndChild(tmpLeaf,tmpPatternEnd[_i10],_i10);}tmpLeaf.PatternStartString=pPatternStart;tmpLeaf.PatternEndString=tmpPatternEnd;tmpLeaf.Parse=typeof fParser==='function'?fParser:typeof fParser==='string'?function(){return fParser;}:function(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 {
|
|
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
|
-
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,
|
|
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'?function(pHash,pData,fCallback){fCallback(pParserPromise);}:function(pHash,pData,fCallback){return fCallback(pHash);};tmpLeaf.isAsync=true;return true;}}]);return WordTree;}();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){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase3){_inherits(FableOperation,_libFableServiceBase3);var _super13=_createSuper(FableOperation);function FableOperation(pFable,pOptions,pServiceHash){var _this23;_classCallCheck2(this,FableOperation);_this23=_super13.call(this,pFable,pOptions,pServiceHash);_this23.serviceType='PhasedOperation';_this23.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
|
|
2785
|
+
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,fParser){var tmpLeaf=this.addPattern(pPatternStart,pPatternEnd,fParser);if(tmpLeaf){tmpLeaf.isAsync=true;}}}]);return WordTree;}();module.exports=WordTree;},{}],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){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var _OperationStatePrototypeString=JSON.stringify(require('./Fable-Service-Operation-DefaultSettings.js'));var FableOperation=/*#__PURE__*/function(_libFableServiceBase3){_inherits(FableOperation,_libFableServiceBase3);var _super13=_createSuper(FableOperation);function FableOperation(pFable,pOptions,pServiceHash){var _this23;_classCallCheck2(this,FableOperation);_this23=_super13.call(this,pFable,pOptions,pServiceHash);_this23.serviceType='PhasedOperation';_this23.state=JSON.parse(_OperationStatePrototypeString);// Match the service instantiation to the operation.
|
|
2773
2786
|
_this23.state.Metadata.Hash=_this23.Hash;_this23.state.Metadata.UUID=_this23.UUID;_this23.name=typeof _this23.options.Name=='string'?_this23.options.Name:"Unnamed Operation ".concat(_this23.state.Metadata.UUID);_this23.log=_assertThisInitialized(_this23);return _this23;}_createClass2(FableOperation,[{key:"writeOperationLog",value:function writeOperationLog(pLogLevel,pLogText,pLogObject){this.state.Log.push("".concat(new Date().toUTCString()," [").concat(pLogLevel,"]: ").concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Log.push(JSON.stringify(pLogObject));}}},{key:"writeOperationErrors",value:function writeOperationErrors(pLogText,pLogObject){this.state.Errors.push("".concat(pLogText));if(_typeof(pLogObject)=='object'){this.state.Errors.push(JSON.stringify(pLogObject));}}},{key:"trace",value:function trace(pLogText,pLogObject){this.writeOperationLog('TRACE',pLogText,pLogObject);this.fable.log.trace(pLogText,pLogObject);}},{key:"debug",value:function debug(pLogText,pLogObject){this.writeOperationLog('DEBUG',pLogText,pLogObject);this.fable.log.debug(pLogText,pLogObject);}},{key:"info",value:function info(pLogText,pLogObject){this.writeOperationLog('INFO',pLogText,pLogObject);this.fable.log.info(pLogText,pLogObject);}},{key:"warn",value:function warn(pLogText,pLogObject){this.writeOperationLog('WARN',pLogText,pLogObject);this.fable.log.warn(pLogText,pLogObject);}},{key:"error",value:function error(pLogText,pLogObject){this.writeOperationLog('ERROR',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.error(pLogText,pLogObject);}},{key:"fatal",value:function fatal(pLogText,pLogObject){this.writeOperationLog('FATAL',pLogText,pLogObject);this.writeOperationErrors(pLogText,pLogObject);this.fable.log.fatal(pLogText,pLogObject);}}]);return FableOperation;}(libFableServiceBase);module.exports=FableOperation;},{"../Fable-ServiceManager.js":92,"./Fable-Service-Operation-DefaultSettings.js":100}],102:[function(require,module,exports){var libFableServiceBase=require('../Fable-ServiceManager.js').ServiceProviderBase;var libSimpleGet=require('simple-get');var FableServiceRestClient=/*#__PURE__*/function(_libFableServiceBase4){_inherits(FableServiceRestClient,_libFableServiceBase4);var _super14=_createSuper(FableServiceRestClient);function FableServiceRestClient(pFable,pOptions,pServiceHash){var _this24;_classCallCheck2(this,FableServiceRestClient);_this24=_super14.call(this,pFable,pOptions,pServiceHash);_this24.TraceLog=false;if(_this24.options.TraceLog||_this24.fable.TraceLog){_this24.TraceLog=true;}_this24.dataFormat=_this24.fable.defaultServices.DataFormat;_this24.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
|
_this24.prepareRequestOptions=function(pOptions){return pOptions;};return _this24;}_createClass2(FableServiceRestClient,[{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|