lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
2 lines • 18.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxb=e():t.fxb=e()}(this,()=>(()=>{"use strict";var t={d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>b});class i{constructor(t,e={}){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let i=0,r="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(r.trim()&&(e.push(this._parseSegment(r.trim())),r=""),e.push({type:"deep-wildcard"}),i+=2):(r.trim()&&e.push(this._parseSegment(r.trim())),r="",i++):(r+=t[i],i++);return r.trim()&&e.push(this._parseSegment(r.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,r=t;const s=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(s&&(r=s[1]+s[3],s[2])){const t=s[2].slice(1,-1);t&&(i=t)}let n,o,a=r;if(r.includes("::")){const e=r.indexOf("::");if(n=r.substring(0,e).trim(),a=r.substring(e+2).trim(),!n)throw new Error(`Invalid namespace in pattern: ${t}`)}let h=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),i=a.substring(t+1).trim();["first","last","odd","even"].includes(i)||/^nth\(\d+\)$/.test(i)?(o=e,h=i):o=a}else o=a;if(!o)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=o,n&&(e.namespace=n),i)if(i.includes("=")){const t=i.indexOf("=");e.attrName=i.substring(0,t).trim(),e.attrValue=i.substring(t+1).trim()}else e.attrName=i.trim();if(h){const t=h.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=h}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class r{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[]}push(t,e=null,i=null){this.path.length>0&&(this.path[this.path.length-1].values=void 0);const r=this.path.length;this.siblingStacks[r]||(this.siblingStacks[r]=new Map);const s=this.siblingStacks[r],n=i?`${i}:${t}`:t,o=s.get(n)||0;let a=0;for(const t of s.values())a+=t;s.set(n,o+1);const h={tag:t,position:a,counter:o};null!=i&&(h.namespace=i),null!=e&&(h.values=e),this.path.push(h)}pop(){if(0===this.path.length)return;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0===this.path.length)return;const e=this.path[this.path.length-1];return e.values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++){const i=t[e],r=this.path[e],s=e===this.path.length-1;if(!this._matchSegment(i,r,s))return!1}return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const r=t[i];if("deep-wildcard"===r.type){if(i--,i<0)return!0;const r=t[i];let s=!1;for(let t=e;t>=0;t--){const n=t===this.path.length-1;if(this._matchSegment(r,this.path[t],n)){e=t-1,i--,s=!0;break}}if(!s)return!1}else{const t=e===this.path.length-1;if(!this._matchSegment(r,this.path[e],t))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!i)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue){const i=e.values[t.attrName];if(String(i)!==String(t.attrValue))return!1}}if(void 0!==t.position){if(!i)return!1;const r=e.counter??0;if("first"===t.position&&0!==r)return!1;if("odd"===t.position&&r%2!=1)return!1;if("even"===t.position&&r%2!=0)return!1;if("nth"===t.position&&r!==t.positionValue)return!1}return!0}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}}function s(t,e){var s="";e.format&&e.indentBy.length>0&&(s="\n");var o=[];if(e.stopNodes&&Array.isArray(e.stopNodes))for(var a=0;a<e.stopNodes.length;a++){var h=e.stopNodes[a];"string"==typeof h?o.push(new i(h)):h instanceof i&&o.push(h)}return n(t,e,s,new r,o)}function n(t,e,i,r,s){var h="",c=!1;if(e.maxNestedTags&&r.getDepth()>e.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(t)){if(null!=t){var f=t.toString();return d(f,e)}return""}for(var g=0;g<t.length;g++){var m=t[g],b=p(m);if(void 0!==b){var v=o(m[":@"],e);r.push(b,v);var N=l(r,s);if(b!==e.textNodeName)if(b!==e.cdataPropName)if(b!==e.commentPropName)if("?"!==b[0]){var y=i;""!==y&&(y+=e.indentBy);var x=i+"<"+b+u(m[":@"],e,N),A=void 0;A=N?a(m[b],e):n(m[b],e,y,r,s),-1!==e.unpairedTags.indexOf(b)?e.suppressUnpairedNode?h+=x+">":h+=x+"/>":A&&0!==A.length||!e.suppressEmptyNode?A&&A.endsWith(">")?h+=x+">"+A+i+"</"+b+">":(h+=x+">",A&&""!==i&&(A.includes("/>")||A.includes("</"))?h+=i+e.indentBy+A+i:h+=A,h+="</"+b+">"):h+=x+"/>",c=!0,r.pop()}else{var S=u(m[":@"],e,N),P="?xml"===b?"":i,O=m[b][0][e.textNodeName];h+=P+"<"+b+(O=0!==O.length?" "+O:"")+S+"?>",c=!0,r.pop()}else h+=i+"\x3c!--"+m[b][0][e.textNodeName]+"--\x3e",c=!0,r.pop();else c&&(h+=i),h+="<![CDATA["+m[b][0][e.textNodeName]+"]]>",c=!1,r.pop();else{var w=m[b];N||(w=d(w=e.tagValueProcessor(b,w),e)),c&&(h+=i),h+=w,c=!1,r.pop()}}}return h}function o(t,e){if(!t||e.ignoreAttributes)return null;var i={},r=!1;for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s.startsWith(e.attributeNamePrefix)?s.substr(e.attributeNamePrefix.length):s]=t[s],r=!0);return r?i:null}function a(t,e){if(!Array.isArray(t))return null!=t?t.toString():"";for(var i="",r=0;r<t.length;r++){var s=t[r],n=p(s);if(n===e.textNodeName)i+=s[n];else if(n===e.cdataPropName)i+=s[n][0][e.textNodeName];else if(n===e.commentPropName)i+=s[n][0][e.textNodeName];else{if(n&&"?"===n[0])continue;if(n){var o=h(s[":@"],e),u=a(s[n],e);u&&0!==u.length?i+="<"+n+o+">"+u+"</"+n+">":i+="<"+n+o+"/>"}}}return i}function h(t,e){var i="";if(t&&!e.ignoreAttributes)for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var s=t[r];!0===s&&e.suppressBooleanAttributes?i+=" "+r.substr(e.attributeNamePrefix.length):i+=" "+r.substr(e.attributeNamePrefix.length)+'="'+s+'"'}return i}function p(t){for(var e=Object.keys(t),i=0;i<e.length;i++){var r=e[i];if(Object.prototype.hasOwnProperty.call(t,r)&&":@"!==r)return r}}function u(t,e,i){var r="";if(t&&!e.ignoreAttributes)for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s)){var n=void 0;!0===(n=i?t[s]:d(n=e.attributeValueProcessor(s,t[s]),e))&&e.suppressBooleanAttributes?r+=" "+s.substr(e.attributeNamePrefix.length):r+=" "+s.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function l(t,e){if(!e||0===e.length)return!1;for(var i=0;i<e.length;i++)if(t.matches(e[i]))return!0;return!1}function d(t,e){if(t&&t.length>0&&e.processEntities)for(var i=0;i<e.entities.length;i++){var r=e.entities[i];t=t.replace(r.regex,r.val)}return t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}function f(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return g(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=Array(e);i<e;i++)r[i]=t[i];return r}var m={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function b(t){if(this.options=Object.assign({},m,t),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(function(t){return"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t})),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(var e=0;e<this.options.stopNodes.length;e++){var r=this.options.stopNodes[e];"string"==typeof r?this.stopNodeExpressions.push(new i(r)):r instanceof i&&this.stopNodeExpressions.push(r)}var s;!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn="function"==typeof(s=this.options.ignoreAttributes)?s:Array.isArray(s)?function(t){for(var e,i=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return c(t,e);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?c(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(s);!(e=i()).done;){var r=e.value;if("string"==typeof r&&t===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}}:function(){return!1},this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=y),this.processTextOrObjNode=v,this.options.format?(this.indentate=N,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function v(t,e,i,r){var s=this.extractAttributes(t);if(r.push(e,s),this.checkStopNode(r)){var n=this.buildRawContent(t),o=this.buildAttributesForStopNode(t);return r.pop(),this.buildObjectNode(n,e,o,i)}var a=this.j2x(t,i+1,r);return r.pop(),void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,a.attrStr,i,r):this.buildObjectNode(a.val,e,a.attrStr,i)}function N(t){return this.options.indentBy.repeat(t)}function y(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}return b.prototype.build=function(t){if(this.options.preserveOrder)return s(t,this.options);var e;Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e);var i=new r;return this.j2x(t,0,i).val},b.prototype.j2x=function(t,e,i){var r="",s="";if(this.options.maxNestedTags&&i.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");var n=this.options.jPath?i.toString():i,o=this.checkStopNode(i);for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(void 0===t[a])this.isAttribute(a)&&(s+="");else if(null===t[a])this.isAttribute(a)||a===this.options.cdataPropName?s+="":"?"===a[0]?s+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)s+=this.buildTextValNode(t[a],a,"",e,i);else if("object"!=typeof t[a]){var h=this.isAttribute(a);if(h&&!this.ignoreAttributesFn(h,n))r+=this.buildAttrPairStr(h,""+t[a],o);else if(!h)if(a===this.options.textNodeName){var p=this.options.tagValueProcessor(a,""+t[a]);s+=this.replaceEntitiesValue(p)}else{i.push(a);var u=this.checkStopNode(i);if(i.pop(),u){var l=""+t[a];s+=""===l?this.indentate(e)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(e)+"<"+a+">"+l+"</"+a+this.tagEndChar}else s+=this.buildTextValNode(t[a],a,"",e,i)}}else if(Array.isArray(t[a])){for(var d=t[a].length,c="",f="",g=0;g<d;g++){var m=t[a][g];if(void 0===m);else if(null===m)"?"===a[0]?s+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if("object"==typeof m)if(this.options.oneListGroup){i.push(a);var b=this.j2x(m,e+1,i);i.pop(),c+=b.val,this.options.attributesGroupName&&m.hasOwnProperty(this.options.attributesGroupName)&&(f+=b.attrStr)}else c+=this.processTextOrObjNode(m,a,e,i);else if(this.options.oneListGroup){var v=this.options.tagValueProcessor(a,m);c+=v=this.replaceEntitiesValue(v)}else{i.push(a);var N=this.checkStopNode(i);if(i.pop(),N){var y=""+m;c+=""===y?this.indentate(e)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(e)+"<"+a+">"+y+"</"+a+this.tagEndChar}else c+=this.buildTextValNode(m,a,"",e,i)}}this.options.oneListGroup&&(c=this.buildObjectNode(c,a,f,e)),s+=c}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName)for(var x=Object.keys(t[a]),A=x.length,S=0;S<A;S++)r+=this.buildAttrPairStr(x[S],""+t[a][x[S]],o);else s+=this.processTextOrObjNode(t[a],a,e,i);return{attrStr:r,val:s}},b.prototype.buildAttrPairStr=function(t,e,i){return i||(e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e)),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},b.prototype.extractAttributes=function(t){if(!t||"object"!=typeof t)return null;var e={},i=!1;if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){var r=t[this.options.attributesGroupName];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s.startsWith(this.options.attributeNamePrefix)?s.substring(this.options.attributeNamePrefix.length):s]=r[s],i=!0)}else for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var o=this.isAttribute(n);o&&(e[o]=t[n],i=!0)}return i?e:null},b.prototype.buildRawContent=function(t){if("string"==typeof t)return t;if("object"!=typeof t||null===t)return String(t);if(void 0!==t[this.options.textNodeName])return t[this.options.textNodeName];var e="";for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&!(this.isAttribute(i)||this.options.attributesGroupName&&i===this.options.attributesGroupName)){var r=t[i];if(i===this.options.textNodeName)e+=r;else if(Array.isArray(r))for(var s,n=f(r);!(s=n()).done;){var o=s.value;if("string"==typeof o||"number"==typeof o)e+="<"+i+">"+o+"</"+i+">";else if("object"==typeof o&&null!==o){var a=this.buildRawContent(o),h=this.buildAttributesForStopNode(o);e+=""===a?"<"+i+h+"/>":"<"+i+h+">"+a+"</"+i+">"}}else if("object"==typeof r&&null!==r){var p=this.buildRawContent(r),u=this.buildAttributesForStopNode(r);e+=""===p?"<"+i+u+"/>":"<"+i+u+">"+p+"</"+i+">"}else e+="<"+i+">"+r+"</"+i+">"}return e},b.prototype.buildAttributesForStopNode=function(t){if(!t||"object"!=typeof t)return"";var e="";if(this.options.attributesGroupName&&t[this.options.attributesGroupName]){var i=t[this.options.attributesGroupName];for(var r in i)if(Object.prototype.hasOwnProperty.call(i,r)){var s=r.startsWith(this.options.attributeNamePrefix)?r.substring(this.options.attributeNamePrefix.length):r,n=i[r];!0===n&&this.options.suppressBooleanAttributes?e+=" "+s:e+=" "+s+'="'+n+'"'}}else for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var a=this.isAttribute(o);if(a){var h=t[o];!0===h&&this.options.suppressBooleanAttributes?e+=" "+a:e+=" "+a+'="'+h+'"'}}return e},b.prototype.buildObjectNode=function(t,e,i,r){if(""===t)return"?"===e[0]?this.indentate(r)+"<"+e+i+"?"+this.tagEndChar:this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar;var s="</"+e+this.tagEndChar,n="";return"?"===e[0]&&(n="?",s=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===n.length?this.indentate(r)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(r)+"<"+e+i+n+this.tagEndChar+t+this.indentate(r)+s:this.indentate(r)+"<"+e+i+n+">"+t+s},b.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},b.prototype.checkStopNode=function(t){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(var e=0;e<this.stopNodeExpressions.length;e++)if(t.matches(this.stopNodeExpressions[e]))return!0;return!1},b.prototype.buildTextValNode=function(t,e,i,r,s){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(r)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(r)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(r)+"<"+e+i+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(r)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+i+">"+n+"</"+e+this.tagEndChar},b.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t},e})());
//# sourceMappingURL=fxb.min.js.map