fable 3.0.48 → 3.0.50
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.compatible.js +66 -56
- package/dist/fable.compatible.min.js +5 -5
- package/dist/fable.compatible.min.js.map +1 -1
- package/dist/fable.js +66 -56
- package/dist/fable.min.js +4 -4
- package/dist/fable.min.js.map +1 -1
- package/gulpfile.js +2 -2
- package/package.json +1 -1
- package/source/services/Fable-Service-DataFormat.js +16 -3
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-StringParser.js +222 -128
- package/source/services/Fable-Service-MetaTemplate/MetaTemplate-WordTree.js +62 -39
- package/test/DataFormat-StringManipulation_tests.js +35 -4
- package/test/MetaTemplating_tests.js +0 -3
package/dist/fable.compatible.js
CHANGED
|
@@ -2473,9 +2473,9 @@ if(this.EmitHeader){return this.Header;}else{return false;}}else{return this.emi
|
|
|
2473
2473
|
_this18._Regex_formatterInsertCommas=/.{1,3}/g;// Match Function:
|
|
2474
2474
|
// function(pMatch, pSign, pZeros, pBefore, pDecimal, pAfter)
|
|
2475
2475
|
// Thoughts about below: /^([+-]?)(0*)(\d+)(\.(\d+))?$/;
|
|
2476
|
-
_this18._Regex_formatterAddCommasToNumber=/^([-+]?)(0?)(\d+)(.?)(\d+)$/g;_this18._Regex_formatterDollarsRemoveCommas=/,/gi;_this18.
|
|
2476
|
+
_this18._Regex_formatterAddCommasToNumber=/^([-+]?)(0?)(\d+)(.?)(\d+)$/g;_this18._Regex_formatterDollarsRemoveCommas=/,/gi;_this18._Regex_formatterCleanNonAlphaChar=/[^a-zA-Z]/gi;_this18._Regex_formatterCapitalizeEachWord=/([a-zA-Z]+)/g;// TODO: Potentially pull these in from a configuration.
|
|
2477
2477
|
// TODO: Use locale data for this if it's defaults all the way down.
|
|
2478
|
-
_this18._Value_MoneySign_Currency='$';_this18._Value_NaN_Currency='--';_this18._Value_GroupSeparator_Number=',';_this18._Value_Prefix_StringHash='HSH';_this18._Value_Clean_formatterCleanNonAlpha='
|
|
2478
|
+
_this18._Value_MoneySign_Currency='$';_this18._Value_NaN_Currency='--';_this18._Value_GroupSeparator_Number=',';_this18._Value_Prefix_StringHash='HSH';_this18._Value_Clean_formatterCleanNonAlpha='';_this18._UseEngineStringStartsWith=typeof String.prototype.startsWith==='function';_this18._UseEngineStringEndsWith=typeof String.prototype.endsWith==='function';return _this18;}/*************************************************************************
|
|
2479
2479
|
* String Manipulation and Comparison Functions
|
|
2480
2480
|
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
2481
2481
|
* Reverse a string
|
|
@@ -2518,7 +2518,7 @@ if(!(pEndIndex<this.length)){pEndIndex=this.length;}else{pEndIndex|=0;// round p
|
|
|
2518
2518
|
*
|
|
2519
2519
|
* @param {string} pString
|
|
2520
2520
|
* @returns {string}
|
|
2521
|
-
*/},{key:"insecureStringHash",value:function insecureStringHash(pString){var tmpHash=0;var tmpStringLength=pString.length;var tmpCharacterIndex=0;while(tmpCharacterIndex<tmpStringLength){tmpHash=(tmpHash<<5)-tmpHash+pString.charCodeAt(tmpCharacterIndex++)|0;}return"".concat(this._Value_Prefix_StringHash).concat(tmpHash);}/**
|
|
2521
|
+
*/},{key:"insecureStringHash",value:function insecureStringHash(pString){var tmpHash=0;var tmpStringLength=pString.length;var tmpCharacterIndex=0;while(tmpCharacterIndex<tmpStringLength){tmpHash=(tmpHash<<5)-tmpHash+pString.charCodeAt(tmpCharacterIndex++)|0;}return"".concat(this._Value_Prefix_StringHash).concat(tmpHash);}},{key:"capitalizeEachWord",value:function capitalizeEachWord(pString){return pString.replace(this._Regex_formatterCapitalizeEachWord,function(pMatch){return pMatch.charAt(0).toUpperCase()+pMatch.substr(1);});}/**
|
|
2522
2522
|
* Clean wrapping characters if they exist consistently around the string. If they do not, the string is returned unchanged.
|
|
2523
2523
|
*
|
|
2524
2524
|
* @param {string} pWrapCharacter - The character expected as the wrapping character
|
|
@@ -2537,10 +2537,11 @@ if(!(pEndIndex<this.length)){pEndIndex=this.length;}else{pEndIndex|=0;// round p
|
|
|
2537
2537
|
// This function is necessary to remove the wrapping quotes before object
|
|
2538
2538
|
// resolution can occur.
|
|
2539
2539
|
if(pString.startsWith(pWrapCharacter)&&pString.endsWith(pWrapCharacter)){return pString.substring(1,pString.length-1);}else{return pString;}}/**
|
|
2540
|
+
* Clean a string of any non-alpha characters (including numbers)
|
|
2540
2541
|
*
|
|
2541
2542
|
* @param {*} pString
|
|
2542
2543
|
* @returns
|
|
2543
|
-
*/},{key:"cleanNonAlphaCharacters",value:function cleanNonAlphaCharacters(pString){if(typeof pString=='string'&&pString!=''){return pString.replace(this.
|
|
2544
|
+
*/},{key:"cleanNonAlphaCharacters",value:function cleanNonAlphaCharacters(pString){if(typeof pString=='string'&&pString!=''){return pString.replace(this._Regex_formatterCleanNonAlphaChar,this._Value_Clean_formatterCleanNonAlpha);}return'';}/*************************************************************************
|
|
2544
2545
|
* Number Formatting Functions
|
|
2545
2546
|
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ /**
|
|
2546
2547
|
* Insert commas every 3 characters from the right. Used by formatterAddCommasToNumber().
|
|
@@ -2666,7 +2667,7 @@ _this20.StringParser=new libStringParser(_this20.fable.defaultServices.Utility.e
|
|
|
2666
2667
|
* @param {object} pData - Data to pass in as the second argument
|
|
2667
2668
|
* @return {string} The result from the parser
|
|
2668
2669
|
*/},{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){/**
|
|
2669
|
-
*
|
|
2670
|
+
* String Parser
|
|
2670
2671
|
* @author Steven Velozo <steven@velozo.com>
|
|
2671
2672
|
* @description Parse a string, properly processing each matched token in the word tree.
|
|
2672
2673
|
*/var StringParser=/*#__PURE__*/function(){/**
|
|
@@ -2677,16 +2678,7 @@ _this20.StringParser=new libStringParser(_this20.fable.defaultServices.Utility.e
|
|
|
2677
2678
|
* @param {Object} pParseTree - A node on the parse tree to begin parsing from (usually root)
|
|
2678
2679
|
* @return {Object} A new parser state object for running a character parser on
|
|
2679
2680
|
* @private
|
|
2680
|
-
*/_createClass2(StringParser,[{key:"newParserState",value:function newParserState(pParseTree){return{ParseTree:pParseTree,Asynchronous:false,Output:'',OutputBuffer:'',Pattern:
|
|
2681
|
-
* Assign a node of the parser tree to be the next potential match.
|
|
2682
|
-
* If the node has a PatternEnd property, it is a valid match and supercedes the last valid match (or becomes the initial match).
|
|
2683
|
-
* @method assignNode
|
|
2684
|
-
* @param {Object} pNode - A node on the parse tree to assign
|
|
2685
|
-
* @param {Object} pParserState - The state object for the current parsing task
|
|
2686
|
-
* @private
|
|
2687
|
-
*/},{key:"assignNode",value:function assignNode(pNode,pParserState){pParserState.PatternMatch=pNode;// If the pattern has a END we can assume it has a parse function...
|
|
2688
|
-
if(pParserState.PatternMatch.hasOwnProperty('PatternEnd')){// ... this is the legitimate start of a pattern.
|
|
2689
|
-
pParserState.Pattern=pParserState.PatternMatch;}}/**
|
|
2681
|
+
*/_createClass2(StringParser,[{key:"newParserState",value:function newParserState(pParseTree){return{ParseTree:pParseTree,Asynchronous:false,Output:'',OutputBuffer:'',Pattern:{},PatternMatch:false,PatternMatchEnd:false};}/**
|
|
2690
2682
|
* Append a character to the output buffer in the parser state.
|
|
2691
2683
|
* This output buffer is used when a potential match is being explored, or a match is being explored.
|
|
2692
2684
|
* @method appendOutputBuffer
|
|
@@ -2698,44 +2690,57 @@ pParserState.Pattern=pParserState.PatternMatch;}}/**
|
|
|
2698
2690
|
* @method flushOutputBuffer
|
|
2699
2691
|
* @param {Object} pParserState - The state object for the current parsing task
|
|
2700
2692
|
* @private
|
|
2701
|
-
*/},{key:"flushOutputBuffer",value:function flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}
|
|
2702
|
-
|
|
2703
|
-
|
|
2693
|
+
*/},{key:"flushOutputBuffer",value:function flushOutputBuffer(pParserState){pParserState.Output+=pParserState.OutputBuffer;pParserState.OutputBuffer='';}},{key:"resetOutputBuffer",value:function resetOutputBuffer(pParserState){// Flush the output buffer.
|
|
2694
|
+
this.flushOutputBuffer(pParserState);// End pattern mode
|
|
2695
|
+
pParserState.Pattern=false;pParserState.PatternStartNode=false;pParserState.StartPatternMatchComplete=false;pParserState.EndPatternMatchBegan=false;pParserState.PatternMatch=false;return true;}/**
|
|
2696
|
+
* Parse a character in the buffer.
|
|
2697
|
+
* @method parseCharacter
|
|
2698
|
+
* @param {string} pCharacter - The character to append
|
|
2704
2699
|
* @param {Object} pParserState - The state object for the current parsing task
|
|
2705
2700
|
* @private
|
|
2706
|
-
*/},{key:"
|
|
2707
|
-
//
|
|
2708
|
-
if(pParserState.Pattern.
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
pParserState.
|
|
2713
|
-
//
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
pParserState.Pattern
|
|
2717
|
-
this.
|
|
2718
|
-
|
|
2701
|
+
*/},{key:"parseCharacter",value:function parseCharacter(pCharacter,pParserState,pData){// If we are already in a pattern match traversal
|
|
2702
|
+
if(pParserState.PatternMatch){// If the pattern is still matching the start and we haven't passed the buffer
|
|
2703
|
+
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.
|
|
2704
|
+
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the output buffer.
|
|
2705
|
+
this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
|
|
2706
|
+
if(pParserState.Pattern.hasOwnProperty('Parse')){// Run the function
|
|
2707
|
+
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.
|
|
2708
|
+
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.
|
|
2709
|
+
pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
|
|
2710
|
+
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// If this last character is the end of the pattern, parse it.
|
|
2711
|
+
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
|
|
2712
|
+
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.
|
|
2713
|
+
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)....
|
|
2714
|
+
if(!pParserState.PatternMatch){// This may be the start of a new pattern....
|
|
2715
|
+
if(pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the root node as the matched node.
|
|
2716
|
+
this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;return true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return false;}/**
|
|
2719
2717
|
* Parse a character in the buffer.
|
|
2720
2718
|
* @method parseCharacter
|
|
2721
2719
|
* @param {string} pCharacter - The character to append
|
|
2722
2720
|
* @param {Object} pParserState - The state object for the current parsing task
|
|
2723
2721
|
* @private
|
|
2724
|
-
*/},{key:"
|
|
2725
|
-
if(
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
else if(pParserState.
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2722
|
+
*/},{key:"parseCharacterAsync",value:function parseCharacterAsync(pCharacter,pParserState,pData,fCallback){var _this21=this;// If we are already in a pattern match traversal
|
|
2723
|
+
if(pParserState.PatternMatch){// If the pattern is still matching the start and we haven't passed the buffer
|
|
2724
|
+
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.
|
|
2725
|
+
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// Flush the output buffer.
|
|
2726
|
+
this.appendOutputBuffer(pCharacter,pParserState);// If this last character is the end of the pattern, parse it.
|
|
2727
|
+
if(pParserState.Pattern.hasOwnProperty('Parse')){// ... this is the end of a pattern, cut off the end tag and parse it.
|
|
2728
|
+
// Trim the start and end tags off the output buffer now
|
|
2729
|
+
if(pParserState.Pattern.isAsync){// Run the function
|
|
2730
|
+
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
|
|
2731
|
+
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.
|
|
2732
|
+
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.
|
|
2733
|
+
pParserState.EndPatternMatchBegan=true;// This leaf has a PatternEnd tree, so we will wait until that end is met.
|
|
2734
|
+
pParserState.Pattern=pParserState.Pattern.PatternEnd[pCharacter];// If this last character is the end of the pattern, parse it.
|
|
2735
|
+
if(pParserState.Pattern.hasOwnProperty('Parse')){// ... this is the end of a pattern, cut off the end tag and parse it.
|
|
2736
|
+
// Trim the start and end tags off the output buffer now
|
|
2737
|
+
if(pParserState.Pattern.isAsync){// Run the function
|
|
2738
|
+
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
|
|
2739
|
+
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.
|
|
2740
|
+
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)....
|
|
2741
|
+
if(!pParserState.PatternMatch){// This may be the start of a new pattern....
|
|
2742
|
+
if(pParserState.ParseTree.hasOwnProperty(pCharacter)){// ... assign the root node as the matched node.
|
|
2743
|
+
this.resetOutputBuffer(pParserState);this.appendOutputBuffer(pCharacter,pParserState);pParserState.Pattern=pParserState.ParseTree[pCharacter];pParserState.PatternMatch=true;}else{this.appendOutputBuffer(pCharacter,pParserState);}}return fCallback();}/**
|
|
2739
2744
|
* Parse a string for matches, and process any template segments that occur.
|
|
2740
2745
|
* @method parseString
|
|
2741
2746
|
* @param {string} pString - The string to parse.
|
|
@@ -2744,9 +2749,9 @@ else{pParserState.Output+=pCharacter;}return fCallback(null);}/**
|
|
|
2744
2749
|
* @param {function} fCallback - The callback function to call when the parse is complete
|
|
2745
2750
|
*/},{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.
|
|
2746
2751
|
this.parseCharacter(pString[i],tmpParserState,pData,fCallback);}this.flushOutputBuffer(tmpParserState);return tmpParserState.Output;}else{// This is the async mode
|
|
2747
|
-
var _tmpParserState=this.newParserState(pParseTree);this.eachLimit(pString,1,function(pCharacter,fCharacterCallback){_this22.parseCharacterAsync(pCharacter,_tmpParserState,pData,fCharacterCallback);},function(pError){// Flush the remaining data
|
|
2752
|
+
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
|
|
2748
2753
|
_this22.flushOutputBuffer(_tmpParserState);fCallback(pError,_tmpParserState.Output);});}}}]);return StringParser;}();module.exports=StringParser;},{}],99:[function(require,module,exports){/**
|
|
2749
|
-
*
|
|
2754
|
+
* Word Tree
|
|
2750
2755
|
* @author Steven Velozo <steven@velozo.com>
|
|
2751
2756
|
* @description Create a tree (directed graph) of Javascript objects, one character per object.
|
|
2752
2757
|
*/var WordTree=/*#__PURE__*/function(){/**
|
|
@@ -2756,24 +2761,29 @@ _this22.flushOutputBuffer(_tmpParserState);fCallback(pError,_tmpParserState.Outp
|
|
|
2756
2761
|
* @method addChild
|
|
2757
2762
|
* @param {Object} pTree - A parse tree to push the characters into
|
|
2758
2763
|
* @param {string} pPattern - The string to add to the tree
|
|
2759
|
-
* @param {number} pIndex - The index of the character in the pattern
|
|
2760
2764
|
* @returns {Object} The resulting leaf node that was added (or found)
|
|
2761
2765
|
* @private
|
|
2762
|
-
*/_createClass2(WordTree,[{key:"addChild",value:function addChild(pTree,pPattern
|
|
2766
|
+
*/_createClass2(WordTree,[{key:"addChild",value:function addChild(pTree,pPattern){if(!pTree.hasOwnProperty(pPattern)){pTree[pPattern]={};}return pTree[pPattern];}/**
|
|
2767
|
+
* Add a child character to a Parse Tree PatternEnd subtree
|
|
2768
|
+
* @method addChild
|
|
2769
|
+
* @param {Object} pTree - A parse tree to push the characters into
|
|
2770
|
+
* @param {string} pPattern - The string to add to the tree
|
|
2771
|
+
* @returns {Object} The resulting leaf node that was added (or found)
|
|
2772
|
+
* @private
|
|
2773
|
+
*/},{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
|
|
2763
2774
|
* @method addPattern
|
|
2764
2775
|
* @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
|
|
2765
2776
|
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
2766
|
-
* @param {
|
|
2777
|
+
* @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.
|
|
2767
2778
|
* @return {bool} True if adding the pattern was successful
|
|
2768
|
-
*/},{key:"addPattern",value:function addPattern(pPatternStart,pPatternEnd,
|
|
2769
|
-
for(var i=0;i<pPatternStart.length;i++)tmpLeaf=this.addChild(tmpLeaf,pPatternStart,i);tmpLeaf.
|
|
2779
|
+
*/},{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
|
|
2780
|
+
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
|
|
2770
2781
|
* @method addPattern
|
|
2771
2782
|
* @param {Object} pPatternStart - The starting string for the pattern (e.g. "${")
|
|
2772
2783
|
* @param {string} pPatternEnd - The ending string for the pattern (e.g. "}")
|
|
2773
|
-
* @param {
|
|
2784
|
+
* @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.
|
|
2774
2785
|
* @return {bool} True if adding the pattern was successful
|
|
2775
|
-
*/},{key:"addPatternAsync",value:function addPatternAsync(pPatternStart,pPatternEnd,
|
|
2776
|
-
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.
|
|
2786
|
+
*/},{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.
|
|
2777
2787
|
_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
|
|
2778
2788
|
// of the request options before they are passed to the request library.
|
|
2779
2789
|
_this24.prepareRequestOptions=function(pOptions){return pOptions;};return _this24;}_createClass2(FableServiceRestClient,[{key:"preRequest",value:function preRequest(pOptions){// Validate the options object
|