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.0 to 4.0.1

10

dist/toText.d.ts

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

import { InlineTextNode, TestLineResultStatus, SingleEntryStatus, Node, Verbosity } from '@suitest/smst/types/unistTestLine';
import { InlineTextNode, TestLineResultStatus, SingleEntryStatus, Node } from '@suitest/smst/types/unistTestLine';
declare type RenderTextFunc = (node: ExtendedInlineNodes) => string;

@@ -13,6 +13,6 @@ declare type ExtendedInlineNodes = InlineTextNode | {

export declare const wrapTextNodes: (inputNodes: ExtendedInlineNodes[], renderTextNode: RenderTextFunc, maxLineLength?: number) => [number, string[]];
export declare const toText: (node: Node, { format, verbosity }: {
format: boolean;
verbosity: Verbosity;
}) => string;
export declare const toText: (node: Node, options?: {
format?: boolean | undefined;
verbosity?: "quiet" | "normal" | "verbose" | undefined;
} | undefined) => string;
export {};

@@ -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),s=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)s.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 s},__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=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"),a=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(n,"�")};var o={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},s=function(e){return Object.values(o).reduce((function(e,r){return e.replace(r,"")}),e).length},i=function(e){return(null==e?void 0:e.value)?r.escapeControlChars(e.value):""},u=function(e){return(null==e?void 0:e.value)?(t=r.escapeControlChars(e.value),(n=e.type)in o?o[n]+t+o.cancel:t):"";var t,n},l=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 s=__values(e),i=s.next();!i.done;i=s.next()){var u=i.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{i&&!i.done&&(a=s.return)&&a.call(s)}finally{if(n)throw n.error}}for(var v,p,f=[""],d=0,h=0,y=o.shift();y;){if("newline"===y.type)h=0,f.push("");else if(y.value.length<=t-h)h+=y.value.length,f[f.length-1]+=r(y),d=h>d?h:d;else{var _=(p=t-h,[__assign(__assign({},v=y),{value:v.value.slice(0,p)}),__assign(__assign({},v),{value:v.value.slice(p)})]);h=0,f[f.length-1]+=r(_[0]),f.push(""),o.splice(0,0,_[1]),d=t}y=o.shift()}return[d,f]};var c=function(e,n,o){var i=o.prefix,u=void 0===i?"":i,f=o.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return n(e);case"props":return function(e,t,n){var o,i,u,v,p,f,d,h=n.prefix,y=void 0===h?"":h,_=n.verbosity,b=[0,0,0],m=[];try{for(var x=__values(e.children),g=x.next();!g.done;g=x.next()){var w=g.value,j=[];m.push(j);var T=__spread(w.name);w.status&&T.splice(0,0,l(w.status));var S=__read(r.wrapTextNodes(T,t),2),C=S[0],N=S[1];j.push(N),C>b[0]&&(b[0]=C);var k=null!==(f=null===(p=w.comparator)||void 0===p?void 0:p.length)&&void 0!==f?f:0;if(j.push([null!==(d=w.comparator)&&void 0!==d?d:""]),k>b[1]&&(b[1]=k),"block"===w.contentType)j=[],m.push(j),j.push(c(w.expectedValue,t,{prefix:" ",verbosity:_}).split("\n"));else{var E=r.wrapTextNodes(w.expectedValue,t);0===E[0]?(j.push(["[EMPTY STRING]"]),E[0]="[EMPTY STRING]".length):j.push(E[1]),E[0]>b[2]&&(b[2]=E[0])}if("inline"===w.contentType&&void 0!==w.actualValue){j=[],m.push(j),j.push([],["→"]),0===b[1]&&(b[1]=1);var O=__read(r.wrapTextNodes([{type:"text",value:a(w.actualValue)}],t),2),P=O[0],I=O[1];j.push(I),P>b[2]&&(b[2]=P)}}}catch(e){o={error:e}}finally{try{g&&!g.done&&(i=x.return)&&i.call(x)}finally{if(o)throw o.error}}var M=[];try{for(var R=__values(m),V=R.next();!V.done;V=R.next())for(var G=V.value;G.some((function(e){return e.length}));)M.push(y+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){u={error:e}}finally{try{V&&!V.done&&(v=R.return)&&v.call(R)}finally{if(u)throw u.error}}return M.join("\n")}(e,n,{prefix:u,verbosity:f});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return a(e.value,(function(e){return e.split("\n").map((function(e){return u+"> "+e})).join("\n")}));case"test-line":case"condition":return v(e,n,{prefix:u,verbosity:f});case"test-line-result":return p(e,n,{prefix:u,verbosity:f});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return t.assertUnknownSectionNode(e)}},v=function(e,r,t){var n=t.prefix,a=void 0===n?"":n,o=t.verbosity,s=e.status?r(l(e.status)):"",i=e.title.map(r).join(""),u=e.children.map((function(e){return c(e,r,{prefix:a+" ",verbosity:o})})).join(""),v="verbose"===o&&e.docs?" ".repeat(s.length)+"docs: "+c(e.docs,r,{verbosity:o}):"",p="excluded"===e.status?" "+r({type:e.status,value:e.status+": "})+"Test line was not executed":"",f=[a+s+i];switch(o){case"normal":f.push(u);break;case"verbose":f.push(u,v)}return f.push(p),f.filter(Boolean).join("\n")},p=function(e,r,t){var n,a=null===(n=e.message)||void 0===n?void 0:n.map(r).join(""),o="";if(a&&"excluded"!==e.status){var i=r({type:e.status,value:e.status+": "});o=" "+i+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,a){var o=1===e.length?r-t:r,i=e[e.length-1],u=s(i);if(u+s(a)+1>o+5){if(u>=o-5)return e.push(n+a),e;var l=a.slice(0,o-u),c=a.slice(o-u);return e[e.length-1]=i+" "+l,e.push(n+c),e}return e[e.length-1]=(i?i+" ":"")+a,e}),[""]).join("\n"):e}(a,void 0,2+s(i))}return[v(e.children[0],r,t),o,e.screenshot?" screenshot: "+e.screenshot:""].filter(Boolean).join("\n")};r.toText=function(e,r){var t=r.format,n=r.verbosity,a=t?u:i;return Array.isArray(e)||(e=[e]),e.map((function(e){return c(e,a,{verbosity:n})})).join("")}}));
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=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"),a=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(n,"�")};var o={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},i=function(e){return Object.values(o).reduce((function(e,r){return e.replace(r,"")}),e).length},s=function(e){return(null==e?void 0:e.value)?r.escapeControlChars(e.value):""},u=function(e){return(null==e?void 0:e.value)?(t=r.escapeControlChars(e.value),(n=e.type)in o?o[n]+t+o.cancel:t):"";var t,n},l=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,p,f=[""],d=0,h=0,y=o.shift();y;){if("newline"===y.type)h=0,f.push("");else if(y.value.length<=t-h)h+=y.value.length,f[f.length-1]+=r(y),d=h>d?h:d;else{var _=(p=t-h,[__assign(__assign({},v=y),{value:v.value.slice(0,p)}),__assign(__assign({},v),{value:v.value.slice(p)})]);h=0,f[f.length-1]+=r(_[0]),f.push(""),o.splice(0,0,_[1]),d=t}y=o.shift()}return[d,f]};var c=function(e,n,o){var s=o.prefix,u=void 0===s?"":s,f=o.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return n(e);case"props":return function(e,t,n){var o,s,u,v,p,f,d,h=n.prefix,y=void 0===h?"":h,_=n.verbosity,m=[0,0,0],b=[];try{for(var x=__values(e.children),g=x.next();!g.done;g=x.next()){var w=g.value,j=[];b.push(j);var T=__spread(w.name);w.status&&T.splice(0,0,l(w.status));var S=__read(r.wrapTextNodes(T,t),2),C=S[0],N=S[1];j.push(N),C>m[0]&&(m[0]=C);var k=null!==(f=null===(p=w.comparator)||void 0===p?void 0:p.length)&&void 0!==f?f:0;if(j.push([null!==(d=w.comparator)&&void 0!==d?d:""]),k>m[1]&&(m[1]=k),"block"===w.contentType)j=[],b.push(j),j.push(c(w.expectedValue,t,{prefix:" ",verbosity:_}).split("\n"));else{var E=r.wrapTextNodes(w.expectedValue,t);0===E[0]?(j.push(["[EMPTY STRING]"]),E[0]="[EMPTY STRING]".length):j.push(E[1]),E[0]>m[2]&&(m[2]=E[0])}if("inline"===w.contentType&&void 0!==w.actualValue){j=[],b.push(j),j.push([],["→"]),0===m[1]&&(m[1]=1);var O=__read(r.wrapTextNodes([{type:"text",value:a(w.actualValue)}],t),2),P=O[0],I=O[1];j.push(I),P>m[2]&&(m[2]=P)}}}catch(e){o={error:e}}finally{try{g&&!g.done&&(s=x.return)&&s.call(x)}finally{if(o)throw o.error}}var M=[];try{for(var R=__values(b),V=R.next();!V.done;V=R.next())for(var G=V.value;G.some((function(e){return e.length}));)M.push(y+G.map((function(e,r){var t,n=null!==(t=e.shift())&&void 0!==t?t:"",a=i(n);return a<m[r]&&(n+=" ".repeat(m[r]-a)),n[1===r?"padStart":"padEnd"](m[r])})).join(" "))}catch(e){u={error:e}}finally{try{V&&!V.done&&(v=R.return)&&v.call(R)}finally{if(u)throw u.error}}return M.join("\n")}(e,n,{prefix:u,verbosity:f});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return a(e.value,(function(e){return e.split("\n").map((function(e){return u+"> "+e})).join("\n")}));case"test-line":case"condition":return v(e,n,{prefix:u,verbosity:f});case"test-line-result":return p(e,n,{prefix:u,verbosity:f});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return t.assertUnknownSectionNode(e)}},v=function(e,r,t){var n=t.prefix,a=void 0===n?"":n,o=t.verbosity,i=e.status?r(l(e.status)):"",s=e.title.map(r).join(""),u=e.children.map((function(e){return c(e,r,{prefix:a+" ",verbosity:o})})).join(""),v="verbose"===o&&e.docs?" ".repeat(i.length)+"docs: "+c(e.docs,r,{verbosity:o}):"",p="excluded"===e.status?" "+r({type:e.status,value:e.status+": "})+"Test line was not executed":"",f=[a+i+s];switch(o){case"normal":f.push(u);break;case"verbose":f.push(u,v)}return f.push(p),f.filter(Boolean).join("\n")},p=function(e,r,t){var n,a=null===(n=e.message)||void 0===n?void 0:n.map(r).join(""),o="";if(a&&"excluded"!==e.status){var s=r({type:e.status,value:e.status+": "});o=" "+s+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,a){var o=1===e.length?r-t:r,s=e[e.length-1],u=i(s);if(u+i(a)+1>o+5){if(u>=o-5)return e.push(n+a),e;var l=a.slice(0,o-u),c=a.slice(o-u);return e[e.length-1]=s+" "+l,e.push(n+c),e}return e[e.length-1]=(s?s+" ":"")+a,e}),[""]).join("\n"):e}(a,void 0,2+i(s))}return[v(e.children[0],r,t),o,e.screenshot?" screenshot: "+e.screenshot:""].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?u:s;return Array.isArray(e)||(e=[e]),e.map((function(e){return c(e,i,{verbosity:o})})).join("")}}));
{
"name": "@suitest/smst-to-text",
"version": "4.0.0",
"version": "4.0.1",
"description": "Utility to convert SMST to plain text or ANSI-styled text",

@@ -5,0 +5,0 @@ "homepage": "https://suite.st/",

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