Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More →
Socket
Sign inDemoInstall
Socket

@suitest/smst-to-text

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@suitest/smst-to-text - npm Package Compare versions

Comparing version 4.0.2 to 4.2.2

2

dist/toText.js

@@ -1,1 +0,1 @@

var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e}).apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,a,o=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return i},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},__spread=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(__read(arguments[r]));return e};!function(e){if("object"==typeof module&&"object"==typeof module.exports){var r=e(require,exports);void 0!==r&&(module.exports=r)}else"function"==typeof define&&define.amd&&define(["require","exports","@suitest/smst"],e)}((function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.toText=r.wrapTextNodes=r.escapeControlChars=void 0;var t=e("@suitest/smst"),n="\n",a=new RegExp([[0,8],[11,12],[14,31],[127,159]].map((function(e){var r=__read(e,2),t=r[0],n=r[1];return"["+String.fromCharCode(t)+"-"+String.fromCharCode(n)+"]"})).join("|"),"g"),o=function(e,r){return void 0===r&&(r=String),null==e?"[NOT DEFINED]":""===e?"[EMPTY STRING]":r(e)};r.escapeControlChars=function(e){return e.replace(a,"īŋŊ")};var i={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},s=function(e){return Object.values(i).reduce((function(e,r){return e.replace(r,"")}),e).length},u=function(e){return(null==e?void 0:e.value)?r.escapeControlChars(e.value):""},l=function(e){return(null==e?void 0:e.value)?(t=r.escapeControlChars(e.value),(n=e.type)in i?i[n]+t+i.cancel:t):"";var t,n},c=function(e){var r="";switch(e){case"success":r="✔ ";break;case"fail":case"fatal":r="✖ ";break;case"warning":r="â€ŧ ";break;case"excluded":case"exit":r="Âģ ";break;case"aborted":r="âĻģ "}return{type:e,value:r}};r.wrapTextNodes=function(e,r,t){var n,a;void 0===t&&(t=60);var o=[];try{for(var i=__values(e),s=i.next();!s.done;s=i.next()){var u=s.value,l=u.value.split(/\r\n|\r|\n/);if(1===l.length)o.push(u);else for(var c=0;c<l.length;c++)0!==c&&o.push({type:"newline"}),o.push({type:u.type,value:l[c]})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(a=i.return)&&a.call(i)}finally{if(n)throw n.error}}for(var v,f,p=[""],d=0,h=0,y=o.shift();y;){if("newline"===y.type)h=0,p.push("");else if(y.value.length<=t-h)h+=y.value.length,p[p.length-1]+=r(y),d=h>d?h:d;else{var _=(f=t-h,[__assign(__assign({},v=y),{value:v.value.slice(0,f)}),__assign(__assign({},v),{value:v.value.slice(f)})]);h=0,p[p.length-1]+=r(_[0]),p.push(""),o.splice(0,0,_[1]),d=t}y=o.shift()}return[d,p]};var v=function(e,a,i){var u=i.prefix,l=void 0===u?"":u,d=i.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return a(e);case"props":return function(e,t,a){var i,u,l,f,p,d,h,y=a.prefix,_=void 0===y?"":y,m=a.verbosity,b=[0,0,0],x=[];try{for(var g=__values(e.children),w=g.next();!w.done;w=g.next()){var j=w.value,T=[];x.push(T);var S=__spread(j.name);j.status&&S.splice(0,0,c(j.status));var C=__read(r.wrapTextNodes(S,t),2),N=C[0],E=C[1];T.push(E),N>b[0]&&(b[0]=N);var k=null!==(d=null===(p=j.comparator)||void 0===p?void 0:p.length)&&void 0!==d?d:0;if(T.push([null!==(h=j.comparator)&&void 0!==h?h:""]),k>b[1]&&(b[1]=k),"block"===j.contentType)T=[],x.push(T),T.push(v(j.expectedValue,t,{prefix:" ",verbosity:m}).split(n));else{var O=r.wrapTextNodes(j.expectedValue,t);0===O[0]?(T.push(["[EMPTY STRING]"]),O[0]="[EMPTY STRING]".length):T.push(O[1]),O[0]>b[2]&&(b[2]=O[0])}if("inline"===j.contentType&&void 0!==j.actualValue){T=[],x.push(T),T.push([],["→"]),0===b[1]&&(b[1]=1);var P=__read(r.wrapTextNodes([{type:"text",value:o(j.actualValue)}],t),2),I=P[0],M=P[1];T.push(M),I>b[2]&&(b[2]=I)}}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=g.return)&&u.call(g)}finally{if(i)throw i.error}}var R=[];try{for(var V=__values(x),B=V.next();!B.done;B=V.next())for(var G=B.value;G.some((function(e){return e.length}));)R.push(_+G.map((function(e,r){var t,n=null!==(t=e.shift())&&void 0!==t?t:"",a=s(n);return a<b[r]&&(n+=" ".repeat(b[r]-a)),n[1===r?"padStart":"padEnd"](b[r])})).join(" "))}catch(e){l={error:e}}finally{try{B&&!B.done&&(f=V.return)&&f.call(V)}finally{if(l)throw l.error}}return R.join(n)}(e,a,{prefix:l,verbosity:d});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return o(e.value,(function(e){return e.split(n).map((function(e){return l+"> "+e})).join(n)}));case"test-line":case"condition":return f(e,a,{prefix:l,verbosity:d});case"test-line-result":return p(e,a,{prefix:l,verbosity:d});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return t.assertUnknownSectionNode(e)}},f=function(e,r,t){var a=t.prefix,o=void 0===a?"":a,i=t.verbosity,s=e.status?r(c(e.status)):"",u=e.title.map(r).join(""),l=e.children.map((function(e){return v(e,r,{prefix:o+" ",verbosity:i})})).join(""),f=[o+s+u];return"normal"!==i&&"verbose"!==i||f.push(l),f.filter(Boolean).join(n)},p=function(e,r,t){var a,o=" "+r({type:e.status,value:e.status+": "}),i="";if("excluded"===e.status)i=o+"Test line was not executed";else{var u=null===(a=e.message)||void 0===a?void 0:a.map(r).join("");u&&(i=o+function(e,r,t){void 0===r&&(r=115),void 0===t&&(t=0);var a=0===t?"":" ".repeat(t);return e.length>r?e.split(/\s/).reduce((function(e,n){var o=1===e.length?r-t:r,i=e[e.length-1],u=s(i);if(u+s(n)+1>o+5){if(u>=o-5)return e.push(a+n),e;var l=n.slice(0,o-u),c=n.slice(o-u);return e[e.length-1]=i+" "+l,e.push(a+c),e}return e[e.length-1]=(i?i+" ":"")+n,e}),[""]).join(n):e}(u,void 0,s(o)))}var l=f(e.children[0],r,t),c=e.screenshot?"screenshot: "+e.screenshot:"";return[l,i,["verbose"===t.verbosity&&e.docs?"docs: "+e.docs:"",c].filter(Boolean).map((function(e){return e.split(n)})).reduce((function(e,r){return e.concat(r)}),[]).map((function(e){return" "+e})).join(n)].filter(Boolean).join(n)};r.toText=function(e,r){var t,n,a=null!==(t=null==r?void 0:r.format)&&void 0!==t&&t,o=null!==(n=null==r?void 0:r.verbosity)&&void 0!==n?n:"normal",i=a?l:u;return Array.isArray(e)||(e=[e]),e.map((function(e){return v(e,i,{verbosity:o})})).join("")}}));
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},__spread=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(__read(arguments[r]));return e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toText=exports.wrapTextNodes=exports.escapeControlChars=void 0;var smst_1=require("@suitest/smst"),nl="\n",tab=" ",emptyString="[EMPTY STRING]",notDefined="[NOT DEFINED]",controlChars=new RegExp([[0,8],[11,12],[14,31],[127,159]].map((function(e){var r=__read(e,2),t=r[0],n=r[1];return"["+String.fromCharCode(t)+"-"+String.fromCharCode(n)+"]"})).join("|"),"g"),formatNotDefined=function(e,r){return void 0===r&&(r=String),null==e?notDefined:""===e?emptyString:r(e)};exports.escapeControlChars=function(e){return e.replace(controlChars,"īŋŊ")};var format={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},formatString=function(e,r){return r in format?format[r]+e+format.cancel:e},calcPureLength=function(e){return Object.values(format).reduce((function(e,r){return e.replace(r,"")}),e).length},wrapText=function(e,r,t){void 0===r&&(r=115),void 0===t&&(t=0);var n=0===t?"":" ".repeat(t);return e.length>r?e.split(/\s/).reduce((function(e,o){var a=1===e.length?r-t:r,i=e[e.length-1],s=calcPureLength(i);if(s+calcPureLength(o)+1>a+5){if(s>=a-5)return e.push(n+o),e;var l=o.slice(0,a-s),u=o.slice(a-s);return e[e.length-1]=i+" "+l,e.push(n+u),e}return e[e.length-1]=(i?i+" ":"")+o,e}),[""]).join(nl):e},renderPlainTextNode=function(e){return(null==e?void 0:e.value)?exports.escapeControlChars(e.value):""},renderFormattedTextNode=function(e){return(null==e?void 0:e.value)?formatString(exports.escapeControlChars(e.value),e.type):""},renderStatus=function(e){var r="";switch(e){case"success":r="✔ ";break;case"fail":case"fatal":r="✖ ";break;case"warning":r="â€ŧ ";break;case"excluded":case"exit":r="Âģ ";break;case"aborted":r="âĻģ "}return{type:e,value:r}},splitNode=function(e,r){return[__assign(__assign({},e),{value:e.value.slice(0,r)}),__assign(__assign({},e),{value:e.value.slice(r)})]};exports.wrapTextNodes=function(e,r,t){var n,o;void 0===t&&(t=60);var a=[];try{for(var i=__values(e),s=i.next();!s.done;s=i.next()){var l=s.value,u=l.value.split(/\r\n|\r|\n/);if(1===u.length)a.push(l);else for(var c=0;c<u.length;c++)0!==c&&a.push({type:"newline"}),a.push({type:l.type,value:u[c]})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}for(var d=[""],p=0,f=0,v=a.shift();v;){if("newline"===v.type)f=0,d.push("");else if(v.value.length<=t-f)f+=v.value.length,d[d.length-1]+=r(v),p=f>p?f:p;else{var h=splitNode(v,t-f);f=0,d[d.length-1]+=r(h[0]),d.push(""),a.splice(0,0,h[1]),p=t}v=a.shift()}return[p,d]};var renderProps=function(e,r,t){var n,o,a,i,s,l,u,c=t.prefix,d=void 0===c?"":c,p=t.verbosity,f=[0,0,0],v=[];try{for(var h=__values(e.children),y=h.next();!y.done;y=h.next()){var m=y.value,x=[];v.push(x);var g=__spread(m.name);m.status&&g.splice(0,0,renderStatus(m.status));var _=__read(exports.wrapTextNodes(g,r),2),b=_[0],w=_[1];x.push(w),b>f[0]&&(f[0]=b);var T=null!==(l=null===(s=m.comparator)||void 0===s?void 0:s.length)&&void 0!==l?l:0;if(x.push([null!==(u=m.comparator)&&void 0!==u?u:""]),T>f[1]&&(f[1]=T),"block"===m.contentType)x=[],v.push(x),x.push(renderNode(m.expectedValue,r,{prefix:tab,verbosity:p}).split(nl));else{var N=exports.wrapTextNodes(m.expectedValue,r);0===N[0]?(x.push([emptyString]),N[0]=emptyString.length):x.push(N[1]),N[0]>f[2]&&(f[2]=N[0])}if("inline"===m.contentType&&void 0!==m.actualValue){x=[],v.push(x),x.push([],["→"]),0===f[1]&&(f[1]=1);var S=__read(exports.wrapTextNodes([{type:"text",value:formatNotDefined(m.actualValue)}],r),2),j=S[0],C=S[1];x.push(C),j>f[2]&&(f[2]=j)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}var P=[];try{for(var L=__values(v),O=L.next();!O.done;O=L.next())for(var k=O.value;k.some((function(e){return e.length}));)P.push(d+k.map((function(e,r){var t,n=null!==(t=e.shift())&&void 0!==t?t:"",o=calcPureLength(n);return o<f[r]&&(n+=" ".repeat(f[r]-o)),n[1===r?"padStart":"padEnd"](f[r])})).join(" "))}catch(e){a={error:e}}finally{try{O&&!O.done&&(i=L.return)&&i.call(L)}finally{if(a)throw a.error}}return P.join(nl)},renderNode=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return r(e);case"props":return renderProps(e,r,{prefix:o,verbosity:a});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return formatNotDefined(e.value,(function(e){return e.split(nl).map((function(e){return o+"> "+e})).join(nl)}));case"test-line":case"condition":return renderTestLineOrCondition(e,r,{prefix:o,verbosity:a});case"test-line-result":return renderTestLineResult(e,r,{prefix:o,verbosity:a});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return smst_1.assertUnknownSectionNode(e)}},renderTestLineOrCondition=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity,i=e.status?r(renderStatus(e.status)):"",s=e.title.map(r).join(""),l=e.children.map((function(e){return renderNode(e,r,{prefix:o+tab,verbosity:a})})).join(""),u=[o+i+s];return"normal"!==a&&"verbose"!==a||u.push(l),u.filter(Boolean).join(nl)},renderTestLineResult=function(e,r,t){var n,o=tab+r({type:e.status,value:e.status+": "}),a="";if("excluded"===e.status)a=o+"Test line was not executed";else{var i=null===(n=e.message)||void 0===n?void 0:n.map(r).join("");i&&(a=o+wrapText(i,void 0,calcPureLength(o)))}var s=renderTestLineOrCondition(e.children[0],r,t),l=e.screenshot?"screenshot: "+e.screenshot:"";return[s,a,["verbose"===t.verbosity&&e.docs?"docs: "+e.docs:"",l].filter(Boolean).map((function(e){return e.split(nl)})).reduce((function(e,r){return e.concat(r)}),[]).map((function(e){return tab+e})).join(nl)].filter(Boolean).join(nl)};exports.toText=function(e,r){var t,n,o=null!==(t=null==r?void 0:r.format)&&void 0!==t&&t,a=null!==(n=null==r?void 0:r.verbosity)&&void 0!==n?n:"normal",i=o?renderFormattedTextNode:renderPlainTextNode;return Array.isArray(e)||(e=[e]),e.map((function(e){return renderNode(e,i,{verbosity:a})})).join("")};
{
"name": "@suitest/smst-to-text",
"version": "4.0.2",
"version": "4.2.2",
"description": "Utility to convert SMST to plain text or ANSI-styled text",

@@ -33,4 +33,4 @@ "homepage": "https://suite.st/",

"dependencies": {
"@suitest/smst": "^4.0.2"
"@suitest/smst": "^4.2.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡ī¸ by Socket Inc