analogger 1.18.2 → 1.18.3
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/CHANGELOG.md +3 -1
- package/browser/src/ana-logger.mjs +5 -10
- package/dist/analogger-browser.min.mjs +3 -3
- package/esm/src/ana-logger.mjs +10 -10
- package/package.json +6 -5
- package/src/ana-logger.cjs +12 -13
- package/esm/node_modules/define-property/index.mjs +0 -37
- package/esm/node_modules/is-accessor-descriptor/index.mjs +0 -74
- package/esm/node_modules/is-data-descriptor/index.mjs +0 -55
- package/esm/node_modules/is-descriptor/index.mjs +0 -30
- package/esm/node_modules/is-number/index.mjs +0 -24
- package/esm/node_modules/kind-of/index.mjs +0 -135
- package/esm/node_modules/window-size/index.mjs +0 -38
- package/esm/node_modules/window-size/utils.mjs +0 -132
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
## [1.18.
|
|
1
|
+
## [1.18.3](https://github.com/thimpat/analogger/compare/v1.18.2...v1.18.3) (2022-08-31)
|
|
2
2
|
|
|
3
|
+
## [1.18.2](https://github.com/thimpat/analogger/compare/v1.18.1...v1.18.2) (2022-08-13)
|
|
4
|
+
|
|
3
5
|
## [1.18.1](https://github.com/thimpat/analogger/compare/v1.18.0...v1.18.1) (2022-08-13)
|
|
4
6
|
|
|
5
7
|
# [1.18.0](https://github.com/thimpat/analogger/compare/v1.17.0...v1.18.0) (2022-08-13)
|
|
@@ -9,13 +9,10 @@ import {COLOR_TABLE, SYSTEM, MAX_CHILDREN_DOM_ANALOGGER, CLASS_REMOVED_NOTIF, AD
|
|
|
9
9
|
PREDEFINED_FORMATS, ANALOGGER_NAME, LINE_CLASSNAME
|
|
10
10
|
} from "./constants.mjs";
|
|
11
11
|
import {stringify} from "../../node_modules/flatted/esm/index.js";
|
|
12
|
-
let
|
|
12
|
+
let getTerminalWidth = () => null;
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
_terminalSize = {}
|
|
17
|
-
|
|
18
|
-
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
const PREDEFINED_CONTEXT_NAMES = {
|
|
@@ -466,11 +463,9 @@ class ____AnaLogger
|
|
|
466
463
|
|
|
467
464
|
if (!this.isBrowser0)
|
|
468
465
|
{
|
|
469
|
-
_terminalSize = _terminalSize || {};
|
|
470
|
-
|
|
471
466
|
if (!availableLength)
|
|
472
467
|
{
|
|
473
|
-
availableLength =
|
|
468
|
+
availableLength = getTerminalWidth() || process.stdout.columns || 120 - verticalSeparator.length - 1 - 5;
|
|
474
469
|
}
|
|
475
470
|
}
|
|
476
471
|
|
|
@@ -655,7 +650,7 @@ class ____AnaLogger
|
|
|
655
650
|
{
|
|
656
651
|
try
|
|
657
652
|
{
|
|
658
|
-
let mainIndex = -1
|
|
653
|
+
let mainIndex = -1;
|
|
659
654
|
let extracted = null;
|
|
660
655
|
for (let i = 0; i < args.length; ++i)
|
|
661
656
|
{
|
|
@@ -665,7 +660,7 @@ class ____AnaLogger
|
|
|
665
660
|
if (arg.stack)
|
|
666
661
|
{
|
|
667
662
|
mainIndex = i;
|
|
668
|
-
extracted = this.assistStask(arg) || []
|
|
663
|
+
extracted = this.assistStask(arg) || [];
|
|
669
664
|
break;
|
|
670
665
|
}
|
|
671
666
|
}
|
|
@@ -674,7 +669,7 @@ class ____AnaLogger
|
|
|
674
669
|
if (!extracted)
|
|
675
670
|
{
|
|
676
671
|
this.error(...args);
|
|
677
|
-
return
|
|
672
|
+
return;
|
|
678
673
|
}
|
|
679
674
|
|
|
680
675
|
for (let i = 0; i < extracted.length; ++i)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,
|
|
3
|
-
`),r=[];for(let s=0;s<t.length;++s){let n=t[s];r.push(n)}return r}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,r=null;for(let s=0;s<e.length;++s){let n=e[s];if(n instanceof Error&&n.stack){t=s,r=this.assistStask(n)||[];break}}if(!r){this.error(...e);return}for(let s=0;s<r.length;++s)e[t]=r[s],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setContext(e,t){this.contexts[e]=t}setDefaultContext(e){this.setContext(y.DEFAULT,e)}generateDefaultContext(){let e=this.contexts[y.DEFAULT]||{};return e=Object.assign({},{name:y.DEFAULT,contextName:y.DEFAULT,target:"ALL",symbol:"\u26A1",color:B[1]},e),e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=B[this.indexColor++%(B.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.name=y.ERROR,e.contextName=y.ERROR,e.color=B[0],e.symbol="\u274C",e.error=!0,e}setContexts(e){let t=Object.keys(e);e[y.DEFAULT]=this.contexts[y.DEFAULT]=this.generateDefaultContext(),e[y.ERROR]=this.contexts[y.ERROR]=this.generateErrorContext(),t.forEach(r=>{let s=e[r]||{};s.contextName=r,s.name=r,this.contexts[r]=
|
|
1
|
+
var Te=Object.defineProperty;var Le=(o,e,t)=>e in o?Te(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var f=(o,e,t)=>(Le(o,typeof e!="symbol"?e+"":e,t),t),te=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var u=(o,e,t)=>(te(o,e,"read from private field"),t?t.call(o):e.get(o)),M=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)};var re=(o,e,t)=>(te(o,e,"access private method"),t);var se={Foreground:38,Background:48},_="\x1B[1D",oe="\x1B[0m"+_,v={Bold:"\x1B[1m"+_,Underline:"\x1B[4m"+_,Reversed:"\x1B[7m"+_},Oe={Bold:"\x1B[1m"+_,Underline:"\x1B[4m"+_,Reversed:"\x1B[7m"+_},J={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function ye(o){return!!J[o]}var ne=(o,e,t)=>o===e&&e===t?o<8?16:o>248?231:Math.round((o-8)/247*24)+232:16+36*Math.round(o/255*5)+6*Math.round(e/255*5)+Math.round(t/255*5),ie=o=>{let e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;o=o.replace(e,function(r,s,n,i){return s+s+n+n+i+i});let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(o);return t?{red:parseInt(t[1],16),blue:parseInt(t[2],16),green:parseInt(t[3],16)}:{}},ae=function({red:o,green:e,blue:t}){let r=o<<16|e<<8|t<<0;return"#"+(16777216+r).toString(16).slice(1)},le=function(o){let e=o.matchAll(/\d+/g),t=[];for(let r of e){let s=parseInt(r[0]);if(s>255)return null;t.push(s)}return t.length!==3?null:{red:t[0],green:t[1],blue:t[2]}},xe=function(o){let e=le(o);return e&&ae(e)},U=function(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},fe=({hue:o,saturation:e,lightness:t})=>{let r,s,n;if(e===0)r=s=n=t;else{let i=t<.5?t*(1+e):t+e-t*e,a=2*t-i;r=U(a,i,o+1/3),s=U(a,i,o),n=U(a,i,o-1/3)}return{red:Math.round(r*255),blue:Math.round(n*255),green:Math.round(s*255)}},ce=o=>{let e=o.toLowerCase();return typeof J[e]<"u"?J[e]:""};function S({red:o,blue:e,green:t},r=!0){if(o===void 0||e===void 0||t===void 0)return"";let s=ne(o,e,t);return`\x1B[${r?se.Foreground:se.Background};5;`+s+"m "+_}function F(o,e=!0){let{red:t,green:r,blue:s}=ie(o);return S({red:t,green:r,blue:s},e)}function P({hue:o,saturation:e,lightness:t},r){let{red:s,green:n,blue:i}=fe({hue:o,saturation:e,lightness:t});return S({red:s,green:n,blue:i},r)}function X(o,e=!0){try{let t;return o=o||"",o?((typeof o=="string"||o instanceof String)&&(o=o.trim()),ye(o)?(t=ce(o),F(t,e)):typeof o=="object"&&!!o.red&&!!o.blue&&!!o.green?S(o,e):typeof o=="object"&&!!o.hue&&!!o.saturation&&!!o.lightness?P(o,e):o.startsWith("#")?F(o,e):(o=o.toString(),/^[\da-fA-F]+$/.test(o)?F("#"+o,e):"")):""}catch(t){console.error("TO_ANSI_INVALID_ARGUMENT_ERROR",t.message)}}function G(o,{fg:e,bg:t,isUnderline:r=!1,isBold:s=!1,isReversed:n=!1}){let i=!1,a="";return e&&(i=!0,a=a+e),t&&(i=!0,a=a+t),r&&(i=!0,a=a+v.Underline),s&&(i=!0,a=a+v.Bold),n&&(i=!0,a=a+v.Reversed),i?a+o+oe:o}function we(o,{fg:e={},bg:t={},isUnderline:r=!1,isBold:s=!1,isReversed:n=!1}){return e&&(e=S({...e})),t&&(t=S({...t},!1)),G(o,{fg:e,bg:t,isUnderline:r,isBold:s,isReversed:n})}function Ae(o,{fg:e="",bg:t="",isUnderline:r=!1,isBold:s=!1,isReversed:n=!1}){return e&&(e=P({...e})),t&&(t=P({...t},!1)),G(o,{fg:e,bg:t,isUnderline:r,isBold:s,isReversed:n})}function _e(o,{fg:e="",bg:t="",isUnderline:r=!1,isBold:s=!1,isReversed:n=!1}){return e&&(e=F(e)),t&&(t=F(t,!1)),G(o,{fg:e,bg:t,isUnderline:r,isBold:s,isReversed:n})}function Ne(o,e=null){if(!e)return o;let{fg:t="",bg:r="",isUnderline:s=!1,isBold:n=!1,isReversed:i=!1}=e;return t&&(t=X(t)),r&&(r=X(r,!1)),G(o,{fg:t,bg:r,isUnderline:s,isBold:n,isReversed:i})}var j={fromRgb:S,fromHexa:F,fromHsl:P,fromColor:X,getTextFromRgb:we,getTextFromHsl:Ae,getTextFromHex:_e,getTextFromColor:Ne,colorNameToHex:ce,hslToRgb:fe,hexToRgb:ie,rgbToHex:ae,rgbToAnsi256:ne,rgbStringToRgb:le,rgbStringToHex:xe,hue2rgb:U,RESET:oe,FONT_STYLE:v,STYLE:Oe};var de={COLOR_TABLE:["#d2466e","#FFA07A","#FF7F50","#FF6347","#FFE4B5","#ADFF2F","#808000","#40E0D0","#1E90FF","#EE82EE","#708090","#DEB887","#FE642E","#210B61","#088A4B","#5E610B","#FA8258","#088A68","#B40431"],SYSTEM:{BROWSER:"BROWSER",NODE:"NODE"}},B=de.COLOR_TABLE,I=de.SYSTEM,z=2e3,K="analogger-removed-notif",Q="analogger-view",he="to-esm-line",q={TOP:"TOP",BOTTOM:"BOTTOM"},ue="ANALOGGER",Z={DEFAULT_FORMAT:"FORMAT1"};var{parse:ve,stringify:Re}=JSON,{keys:Ue}=Object,De=String,Me="string";var ge="object",Fe=(o,e)=>e;var me=(o,e,t)=>{let r=De(e.push(t)-1);return o.set(t,r),r};var pe=(o,e,t)=>{let r=e&&typeof e===ge?(p,h)=>p===""||-1<e.indexOf(p)?h:void 0:e||Fe,s=new Map,n=[],i=[],a=+me(s,n,r.call({"":o},"",o)),l=!a;for(;a<n.length;)l=!0,i[a]=Re(n[a++],x,t);return"["+i.join(",")+"]";function x(p,h){if(l)return l=!l,h;let E=r.call(this,p,h);switch(typeof E){case ge:if(E===null)return E;case Me:return s.get(E)||me(s,n,E)}return E}};var Se=()=>null,y={DEFAULT:"DEFAULT",ERROR:"ERROR"},V=`
|
|
2
|
+
`,W={airplane:"\u2708",anchor:"\u2693",arrow_backward:"\u25C0",arrow_double_up:"\u23EB",arrow_double_down:"\u23EC",arrow_forward:"\u25B6",arrow_lower_right:"\u2198",arrow_lower_left:"\u2199",arrow_right_hook:"\u21AA",arrow_up_down:"\u2195",arrow_upper_left:"\u2196",arrow_upper_right:"\u2197",ballot_box_with_check:"\u2611",biohazard:"\u2623",black_circle:"\u23FA",black_medium_small_square:"\u25FE",black_medium_square:"\u25FC",black_nib:"\u2712",black_small_square:"\u25AA",black_square:"\u23F9",chains:"\u26D3",check:"\u2714",chess_pawn:"\u265F",cloud_and_rain:"\u26C8",clubs:"\u2663",coffee:"\u2615",copyright:"\xA9",cross:"\u274C",diamonds:"\u2666",divisions_ign:"\u2797",double_triangle_right:"\u23ED",double_triangle_left:"\u23EE",email:"\u2709",eject:"\u23CF",exclamation_mark:"\u2757",fast_forward:"\u23E9",female_sign:"\u2640",fist:"\u270A",fuel_pump:"\u26FD",gear:"\u2699",hammer_and_pick:"\u2692",hand:"\u270B",hearts:"\u2665",infinity:"\u267E",information:"\u2139",left_right_arrow:"\u2194",leftwards_arrow_with_hook:"\u21A9",male_sign:"\u2642",minus_sign:"\u2796",no_entry:"\u26D4",partly_sunny:"\u26C5",pencil:"\u270F",phone:"\u260E",plus_sign:"\u2795",question:"\u2754",radioactive:"\u2622",raised_hand:"\u270B",recycle:"\u267B",registered:"\xAE",relaxed:"\u263A",rewind:"\u23EA",scissors:"\u2702",snowman:"\u2603",spades:"\u2660",sparkles:"\u2728",star:"\u2B50",sunny:"\u2600",tent:"\u26FA",trademark:"\u2122",triangle_with_vertical_bar:"\u23EF",umbrella:"\u2614",vertical_bars:"\u23F8",watch:"\u231A",white_frowning_face:"\u2639",white_medium_square:"\u25FB",white_medium_small_square:"\u25FD",white_small_square:"\u25AB",wheelchair:"\u267F",white_circle:"\u26AA",writing_hand:"\u270D"},b,C,H,k,Y,Ee,O=class{constructor({name:e="default"}={}){M(this,Y);f(this,"system","");f(this,"instanceId","");f(this,"instanceName","");f(this,"logIndex",0);f(this,"logCounter",0);f(this,"contexts",[]);f(this,"targets",{});f(this,"activeTarget",null);f(this,"indexColor",0);f(this,"format","");f(this,"keepLog",!1);f(this,"logHistory",[]);f(this,"$containers",null);f(this,"options",{hideHookMessage:!1});M(this,b,console.log);M(this,C,console.info);M(this,H,console.warn);M(this,k,console.error);f(this,"isBrowser0",null);f(this,"originalFormatFunction");f(this,"removeDomOldEntries",e=>{if(e.childElementCount>z){let r=Math.ceil(z/10);for(let s=0;s<r;++s)e.removeChild(e.firstChild);return r}return 0});f(this,"scrollDivToBottom",e=>{let t=e.scrollHeight-(e.clientHeight+e.scrollTop),r=e.clientHeight||e.offsetHeight;t>r/2||(e.scrollTop=e.scrollHeight)});this.system=typeof process=="object"?I.NODE:I.BROWSER,this.format=this.onBuildLog.bind(this),this.originalFormatFunction=this.format,this.instanceName=e,++O.instanceCount,this.instanceId=O.instanceCount+"-"+Date.now(),this.errorTargetHandler=this.onError.bind(this),this.errorUserTargetHandler=this.onErrorForUserTarget.bind(this),this.setOptions(this.options),this.rawLog=u(this,b),this.rawInfo=u(this,C),this.rawWarn=u(this,H),this.rawError=u(this,k),console.rawLog=u(this,b),console.raw=u(this,b),console.rawInfo=u(this,C),console.rawWarn=u(this,H),console.rawError=u(this,k),console.keepLogHistory=this.keepLogHistory,console.getLogHistory=this.getLogHistory,console.table=this.table,console.buildTable=this.buildTable,console.isNode=this.isNode,console.isBrowser=this.isBrowser,console.truncateMessage=this.truncateMessage,console.rawLog=this.rawLog,console.rawInfo=this.rawInfo,console.rawWarn=this.rawWarn,console.rawError=this.rawError,console.isBrowser0=this.system===I.BROWSER,this.ALIGN=O.ALIGN,this.ENVIRONMENT_TYPE=O.ENVIRONMENT_TYPE,this.resetLogHistory()}getName(){return this.instanceName}getId(){return this.instanceId}keepLogHistory(){this.keepLog=!0}releaseLogHistory(){this.keepLog=!1}resetLogHistory(){this.logHistory=[]}getLogHistory(e=!0,t=V){if(!this.logHistory)return"";let s=this.logHistory.slice(0),n=JSON.parse(JSON.stringify(s));return e?n.join(t):n}isNode(){return this.system===I.NODE}isBrowser(){return!this.isNode()}resetLogger(){this.options={},this.options.timeLenMax=10,this.options.contextLenMax=10,this.options.idLenMax=5,this.options.lidLenMax=6,this.options.messageLenMax=void 0,this.options.symbolLenMax=60,this.options.hideHookMessage=void 0,this.options.hidePassingTests=void 0,this.options.hideLog=void 0,this.options.hideError=void 0,this.options.oneConsolePerContext=!0,this.options.logToDom=void 0,this.options.logToFile=void 0,this.options.logToDomlogToFile=void 0}resetOptions(){this.resetLogger()}setOptions({contextLenMax:e=10,idLenMax:t=5,lidLenMax:r=6,symbolLenMax:s=2,messageLenMax:n=void 0,hideLog:i=void 0,hideError:a=void 0,hideHookMessage:l=void 0,hidePassingTests:x=void 0,logToDom:p=void 0,logToFile:h=void 0,oneConsolePerContext:E=void 0,silent:w=void 0}=null){this.options.contextLenMax=e,this.options.idLenMax=t,this.options.lidLenMax=r,this.options.messageLenMax=n,this.options.symbolLenMax=s,x!==void 0&&(this.options.hidePassingTests=!!x),l!==void 0&&(this.options.hideHookMessage=!!l);let R;w!==void 0?R=!!w:i!==void 0&&(R=!!i),R&&(this.options.hideLog=!!R),a!==void 0&&(this.options.hideError=!!a),E!==void 0&&(this.options.oneConsolePerContext=!!E),p!==void 0&&(this.options.logToDom=p||"#analogger"),h===!1?this.options.logToFile=!1:h!==void 0&&(this.isBrowser()||(this.options.logToFile=h||"./analogger.log"),u(this,b).call(this,"LogToFile is not supported in this environment. "))}getOptions(){return this.options}truncateMessage(e="",{fit:t=0,align:r=O.ALIGN.LEFT,ellipsis:s="..."}={}){return e=""+e,t&&e.length>t&&(e=e.substring(0,t-s.length)+s),e=r===O.ALIGN.LEFT?e.padEnd(t," "):e.padStart(t," "),e}buildTable(e,{ellipsis:t="...",ColumnMinChars:r=6,columnMaxChars:s=0,verticalSeparator:n=" \u2502 ",horizontalSeparator:i="\u2500",availableLength:a=0,onCompleteHeaders:l=null,onCompleteSeparators:x=null,onCompleteLines:p=null}={}){let h="";if(Array.isArray(e)||(e=Object.values(Object.values(e))),!e||!e.length)return"";let w=e.map(c=>Object.assign({},c)),R=w[0],T=Object.keys(R);w.unshift(T),i=i.repeat(100);let m={};for(let c=1;c<w.length;++c){let d=w[c];for(let L=0;L<T.length;++L){let A=T[L],$=d[A];m[A]=m[A]||0;let D;try{D=JSON.stringify($).length}catch{}D=D||r,m[A]=Math.max(m[A],D,A.length)}}this.isBrowser0||a||(a=Se()||process.stdout.columns||120-n.length-1-5),a=a-4;let ee=Object.values(m).reduce((c,d)=>c+d,0);if(a<ee){let c=a/ee;for(let d in m)m[d]=Math.floor(m[d]*c)-1,r&&m[d]<r&&(m[d]=r),s&&m[d]>s&&(m[d]=s),m[d]=m[d]}let g;g="";for(let c=0;c<T.length;++c){let d=T[c],L=m[d];g+=this.truncateMessage(d,{fit:L,ellipsis:t}),g+=n}l&&(g=l(g,T)),h+=this.truncateMessage(g,{fit:a}),h+=V,g="";let be=i;for(let c=0;c<T.length;++c){let d=T[c],L=m[d];g+=this.truncateMessage(be,{fit:L,ellipsis:""}),g+=n}x&&(g=x(g,T)),h+=this.truncateMessage(g,{fit:a}),h+=V;for(let c=1;c<w.length;++c){g="";let d=w[c];for(let L=0;L<T.length;++L){let A=T[L],$=d[A],D=m[A];g+=this.truncateMessage($,{fit:D,ellipsis:t}),g+=n}p&&(g=p(g,d)),h+=this.truncateMessage(g,{fit:a}),h+=V}return this.rawLog(h),h}onBuildLog({contextName:e,message:t="",lid:r="",symbol:s=""}={}){let n=new Date,i=("0"+n.getHours()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2);return i=this.truncateMessage(i,{fit:this.options.timeLenMax}),e=this.truncateMessage(e,{fit:this.options.contextLenMax,align:O.ALIGN.RIGHT}),r=this.truncateMessage(r,{fit:this.options.lidLenMax}),this.options.messageLenMax!==void 0&&(t=this.truncateMessage(t,{fit:this.options.messageLenMax})),s=this.truncateMessage(s,{fit:this.options.symbolLenMax}),`[${i}] ${e}: (${r}) ${s} ${t}`}onErrorForUserTarget(e,...t){this.errorUserTargetHandler(e,...t)}onError(e,...t){e.target===this.targets.USER&&this.onErrorForUserTarget(e,...t)}onDisplayLog(...e){this.log(...e)}assistStask(e){try{let t=e.stack.split(`
|
|
3
|
+
`),r=[];for(let s=0;s<t.length;++s){let n=t[s];r.push(n)}return r}catch(t){console.rawError(t.message)}return e.message}onDisplayError(...e){try{let t=-1,r=null;for(let s=0;s<e.length;++s){let n=e[s];if(n instanceof Error&&n.stack){t=s,r=this.assistStask(n)||[];break}}if(!r){this.error(...e);return}for(let s=0;s<r.length;++s)e[t]=r[s],this.error(...e)}catch(t){console.rawError(t)}}setLogFormat(e){if(typeof e!="function")return console.error("Invalid parameter for setFormat. It is expecting a function or method."),!1;this.format=e.bind(this)}resetLogFormatter(){this.format=this.originalFormatFunction}setErrorHandler(e){this.errorTargetHandler=e.bind(this)}setErrorHandlerForUserTarget(e){this.errorUserTargetHandler=e.bind(this)}isContextValid(e){return typeof e=="object"&&!Array.isArray(e)&&e!==null?e.hasOwnProperty("contextName")&&e.hasOwnProperty("target"):!1}setContext(e,t){this.contexts[e]=t}setDefaultContext(e){this.setContext(y.DEFAULT,e)}generateDefaultContext(){let e=this.contexts[y.DEFAULT]||{};return e=Object.assign({},{name:y.DEFAULT,contextName:y.DEFAULT,target:"ALL",symbol:"\u26A1",color:B[1]},e),e.id=this.logIndex++,e}generateNewContext(){let e=this.generateDefaultContext();return e.color=B[this.indexColor++%(B.length-3)+2],e.symbol="",e}generateErrorContext(){let e=this.generateDefaultContext();return e.name=y.ERROR,e.contextName=y.ERROR,e.color=B[0],e.symbol="\u274C",e.error=!0,e}setContexts(e){let t=Object.keys(e);e[y.DEFAULT]=this.contexts[y.DEFAULT]=this.generateDefaultContext(),e[y.ERROR]=this.contexts[y.ERROR]=this.generateErrorContext(),t.forEach(r=>{let s=e[r]||{};s.contextName=r,s.name=r,this.contexts[r]=re(this,Y,Ee).call(this,s),e[r]=this.contexts[r]})}setTargets(e={}){this.targets=Object.assign({},e,{ALL:"ALL",USER:"USER"})}setActiveTarget(e){this.activeTarget=e}isTargetAllowed(e){return!e||!this.activeTarget||e===this.targets.ALL?!0:this.activeTarget===e}setColumns(e,t,r){let s=0;for(let i in t){if(!["contextName","symbol","lid","text"].includes(i))continue;let a=t[i],l=document.createElement("span");l.classList.add("analogger-col",`analogger-col-${i}`,`analogger-col-${s}`),++s,l.textContent=a,e.append(l)}let n=document.createElement("span");n.classList.add("analogger-col","analogger-col-text",`analogger-col-${s}`),n.textContent=r,e.append(n)}addLineToDom(e,t,{context:r,addType:s}){if(s===q.BOTTOM?e.append(t):e.insertBefore(t,e.firstChild),this.removeDomOldEntries(e)){if(e.getElementsByClassName(K).length)return;r.contextName=ue,r.symbol="\u{1F5D1}",r.color="orange",r.className=K,clearTimeout(this.timerAddLineToDomID),this.timerAddLineToDomID=setTimeout(()=>{this.timerAddLineToDomID=null,this.writeLogToDom(r,"",{addType:q.TOP,message:"Oldest entries removed"})},500);return}this.scrollDivToBottom(e)}writeLogToDom(e,t,{addType:r=q.BOTTOM,message:s=""}={}){this.$containers=this.$containers||document.querySelectorAll(this.options.logToDom),t=s||t;for(let n=0;n<this.$containers.length;++n){let i=this.$containers[n],a=i.querySelector("."+Q);a||(a=document.createElement("div"),a.classList.add(Q),i.append(a));let l=document.createElement("div");l.classList.add(he),e.className&&l.classList.add(e.className),l.style.color=e.color,this.setColumns(l,e,t),setTimeout(function(x,p,{addType:h,context:E}){this.addLineToDom(x,p,{addType:h,context:E})}.bind(this,a,l,{addType:r,context:e}),0)}}writeLogToFile(e){try{fs.appendFileSync(this.options.logToFilePath,e+this.EOL)}catch(t){console.rawError("LOG_TO_FILE_FAILURE: ",t.message)}}convertArgumentsToText(e){let t=[],r,s=e.length;for(let n=0;n<s;++n){let i,a=e[n];try{i=JSON.stringify(a)}catch{}if(!i)try{i=pe(a)}catch{}t.push(i)}return r=t.join("\u2022"),r}processOutput(e={}){try{let t="";if(!this.isTargetAllowed(e.target))return;let r=Array.prototype.slice.call(arguments);r.shift(),t=this.convertArgumentsToText(r);let s="",n="";if(n=this.format({...e,message:t}),++this.logCounter,this.isBrowser()?(e.environnment=O.ENVIRONMENT_TYPE.BROWSER,this.options.logToDom&&this.writeLogToDom(e,n,{message:t}),s=`%c${n}`):(e.environnment=O.ENVIRONMENT_TYPE.NODE,s=j.getTextFromColor(n,{fg:e.color,bg:e.bgColor,isBold:e.bold,isUnderline:e.underline,isReversed:e.reversed}),this.options.logToFile&&this.writeLogToFile(n)),this.keepLog&&this.logHistory.push(s),this.options.hideLog)return;this.isBrowser()?u(this,b).call(this,s,`color: ${e.color}`):u(this,b).call(this,s),this.errorTargetHandler(e,r)}catch(t){console.rawError("AnaLogger:",t.message)}}isExtendedOptionsPassed(e){return typeof e!="object"?!1:e.hasOwnProperty("context")||e.hasOwnProperty("target")||e.hasOwnProperty("color")||e.hasOwnProperty("contextName")||e.hasOwnProperty("lid")}listSymbols(){for(let e in W)console.rawLog(W[e]+` ${e} `)}applySymbolByName(e){try{e.symbol&&W[e.symbol]&&(e.symbol=W[e.symbol])}catch{}}convertToContext(e,t){t=t||this.generateDefaultContext(),e=e||t;let r=e;if(e.context&&typeof e.context=="object"){let s=Object.assign({},e);delete s.context,r=Object.assign({},e.context,s)}return r=Object.assign({},t,r),delete r.context,this.applySymbolByName(r),r}log(e,...t){if(!this.isExtendedOptionsPassed(e)){let s=this.generateDefaultContext();this.processOutput.apply(this,[s,e,...t]);return}let r=this.convertToContext(e);this.processOutput.apply(this,[r,...t])}error(e,...t){if(this.options.hideError)return;if(!this.isExtendedOptionsPassed(e)){let i=this.generateErrorContext();this.processOutput.apply(this,[i,e,...t]);return}let r=this.generateErrorContext(),s=this.convertToContext(e,r),n=Array.prototype.slice.call(arguments,1);this.log(s,...n)}overrideError(){this.options.hideHookMessage||u(this,b).call(this,"AnaLogger: Hook placed on console.error"),console.error=this.onDisplayError.bind(this)}overrideConsole({log:e=!0,info:t=!0,warn:r=!0,error:s=!1}={}){this.options.hideHookMessage||u(this,b).call(this,"AnaLogger: Hook placed on console.log"),e&&(console.log=this.onDisplayLog.bind(this)),t&&(console.info=this.onDisplayLog.bind(this)),r&&(console.warn=this.onDisplayLog.bind(this)),s&&this.overrideError()}removeOverrideError(){console.warn=u(this,k)}removeOverride({log:e=!0,info:t=!0,warn:r=!0,error:s=!1}={}){e&&(console.log=u(this,b)),t&&(console.info=u(this,C)),r&&(console.warn=u(this,H)),s&&this.removeOverrideError()}info(...e){return this.log(...e)}warn(...e){return this.log(...e)}table(...e){return this.buildTable(...e)}alert(...e){if(this.isNode())return this.log(...e);let t=e.join(" | ");alert(t)}assert(e,t=!0,...r){let s;try{return typeof e=="function"?(s=e(...r),s!==t?(this.error("Asset failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)):e!==t?(this.error("Assert failed"),!1):(this.options.hidePassingTests||this.log("SUCCESS: Assert passed"),!0)}catch{this.error("Unexpected error in assert")}return!1}applyAnalogFormatting({activeTarget:e="",override:t=!1}={}){try{let s={STANDARD:null,TEST:{color:"#B18904",symbol:"diamonds"},C1:null,C2:null,C3:null,DEFAULT:{}},n=typeof process=="object"?process.env.DEVELOPER:"DEV",i=typeof process=="object"?process.env.DEVELOPER:"DEV1",a={ALL:"ALL",DEBUG:"DEBUG",DEV:n,DEV1:i,USER:"USER"};return this.setDefaultContext(s.DEFAULT),this.setTargets(a),e&&this.setActiveTarget(e),this.setOptions({silent:!1,hideError:!1,hideHookMessage:!0,lidLenMax:4}),t&&(this.overrideConsole(),this.overrideError()),!0}catch(r){console.error({lid:3249},r.message)}return!1}applyPredefinedFormat(e=Z.DEFAULT_FORMAT,{activeTarget:t="",override:r=!1}={}){if(e===Z.DEFAULT_FORMAT)return this.applyAnalogFormatting({activeTarget:t,override:r})}},N=O;b=new WeakMap,C=new WeakMap,H=new WeakMap,k=new WeakMap,Y=new WeakSet,Ee=function(e){let t=e,r=this.generateNewContext();return t=Object.assign({},r,t),t.color.toLowerCase().indexOf("rgb")>-1?t.color=j.rgbStringToHex(t.color):t.color.indexOf("#")===-1&&(t.color=j.colorNameToHex(t.color)),t},f(N,"ALIGN",{LEFT:"LEFT",RIGHT:"RIGHT"}),f(N,"ENVIRONMENT_TYPE",{BROWSER:"BROWSER",NODE:"NODE",OTHER:"OTHER"}),f(N,"instanceCount",0);var Ve=N,Ce=N,We=Ce,Ye=new N;export{Ve as AnaLogger,Ye as anaLogger,We as default};
|
|
4
4
|
|
package/esm/src/ana-logger.mjs
CHANGED
|
@@ -7,21 +7,23 @@
|
|
|
7
7
|
import path from "path";
|
|
8
8
|
import fs from "fs";
|
|
9
9
|
import os from "os";
|
|
10
|
-
import terminalSize from "
|
|
10
|
+
import terminalSize from "term-size-cjs";
|
|
11
11
|
import toAnsi from "to-ansi";
|
|
12
12
|
import {COLOR_TABLE, SYSTEM, MAX_CHILDREN_DOM_ANALOGGER, CLASS_REMOVED_NOTIF, ADD_TYPE, CONSOLE_AREA_CLASSNAME,
|
|
13
13
|
PREDEFINED_FORMATS, ANALOGGER_NAME, LINE_CLASSNAME
|
|
14
14
|
} from "./constants.mjs";
|
|
15
15
|
import {stringify} from "flatted";
|
|
16
|
-
let
|
|
16
|
+
let getTerminalWidth = () => null;
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
getTerminalWidth = () =>
|
|
24
|
+
{
|
|
25
|
+
return terminalSize().cols;
|
|
26
|
+
};
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
|
|
@@ -478,11 +480,9 @@ class ____AnaLogger
|
|
|
478
480
|
|
|
479
481
|
if (!this.isBrowser0)
|
|
480
482
|
{
|
|
481
|
-
_terminalSize = _terminalSize || {};
|
|
482
|
-
|
|
483
483
|
if (!availableLength)
|
|
484
484
|
{
|
|
485
|
-
availableLength =
|
|
485
|
+
availableLength = getTerminalWidth() || process.stdout.columns || 120 - verticalSeparator.length - 1 - 5;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
@@ -667,7 +667,7 @@ class ____AnaLogger
|
|
|
667
667
|
{
|
|
668
668
|
try
|
|
669
669
|
{
|
|
670
|
-
let mainIndex = -1
|
|
670
|
+
let mainIndex = -1;
|
|
671
671
|
let extracted = null;
|
|
672
672
|
for (let i = 0; i < args.length; ++i)
|
|
673
673
|
{
|
|
@@ -677,7 +677,7 @@ class ____AnaLogger
|
|
|
677
677
|
if (arg.stack)
|
|
678
678
|
{
|
|
679
679
|
mainIndex = i;
|
|
680
|
-
extracted = this.assistStask(arg) || []
|
|
680
|
+
extracted = this.assistStask(arg) || [];
|
|
681
681
|
break;
|
|
682
682
|
}
|
|
683
683
|
}
|
|
@@ -686,7 +686,7 @@ class ____AnaLogger
|
|
|
686
686
|
if (!extracted)
|
|
687
687
|
{
|
|
688
688
|
this.error(...args);
|
|
689
|
-
return
|
|
689
|
+
return;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
for (let i = 0; i < extracted.length; ++i)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "analogger",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.3",
|
|
4
4
|
"description": "Js Logger",
|
|
5
5
|
"main": "./src/ana-logger.cjs",
|
|
6
6
|
"module": "./esm/src/ana-logger.mjs",
|
|
@@ -92,9 +92,10 @@
|
|
|
92
92
|
"to-esm": "^2.19.0"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@thimpat/libutils": "
|
|
96
|
-
"flatted": "
|
|
97
|
-
"
|
|
98
|
-
"
|
|
95
|
+
"@thimpat/libutils": "1.5.1",
|
|
96
|
+
"flatted": "3.2.7",
|
|
97
|
+
"term-size": "3.0.2",
|
|
98
|
+
"term-size-cjs": "npm:term-size@2.2.1",
|
|
99
|
+
"to-ansi": "1.4.3"
|
|
99
100
|
}
|
|
100
101
|
}
|
package/src/ana-logger.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
let
|
|
1
|
+
let getTerminalWidth = () => null;
|
|
2
2
|
|
|
3
3
|
/** to-esm-browser: remove **/
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const os = require("os");
|
|
7
|
-
let terminalSize = require("window-size");
|
|
8
|
-
_terminalSize = terminalSize;
|
|
9
|
-
/** to-esm-browser: end-remove **/
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
let terminalSize = require("term-size-cjs");
|
|
9
|
+
getTerminalWidth = () =>
|
|
10
|
+
{
|
|
11
|
+
return terminalSize().cols;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** to-esm-browser: end-remove **/
|
|
14
15
|
|
|
15
16
|
const toAnsi = require("to-ansi");
|
|
16
17
|
|
|
@@ -471,11 +472,9 @@ class ____AnaLogger
|
|
|
471
472
|
|
|
472
473
|
if (!this.isBrowser0)
|
|
473
474
|
{
|
|
474
|
-
_terminalSize = _terminalSize || {};
|
|
475
|
-
|
|
476
475
|
if (!availableLength)
|
|
477
476
|
{
|
|
478
|
-
availableLength =
|
|
477
|
+
availableLength = getTerminalWidth() || process.stdout.columns || 120 - verticalSeparator.length - 1 - 5;
|
|
479
478
|
}
|
|
480
479
|
}
|
|
481
480
|
|
|
@@ -660,7 +659,7 @@ class ____AnaLogger
|
|
|
660
659
|
{
|
|
661
660
|
try
|
|
662
661
|
{
|
|
663
|
-
let mainIndex = -1
|
|
662
|
+
let mainIndex = -1;
|
|
664
663
|
let extracted = null;
|
|
665
664
|
for (let i = 0; i < args.length; ++i)
|
|
666
665
|
{
|
|
@@ -670,7 +669,7 @@ class ____AnaLogger
|
|
|
670
669
|
if (arg.stack)
|
|
671
670
|
{
|
|
672
671
|
mainIndex = i;
|
|
673
|
-
extracted = this.assistStask(arg) || []
|
|
672
|
+
extracted = this.assistStask(arg) || [];
|
|
674
673
|
break;
|
|
675
674
|
}
|
|
676
675
|
}
|
|
@@ -679,7 +678,7 @@ class ____AnaLogger
|
|
|
679
678
|
if (!extracted)
|
|
680
679
|
{
|
|
681
680
|
this.error(...args);
|
|
682
|
-
return
|
|
681
|
+
return;
|
|
683
682
|
}
|
|
684
683
|
|
|
685
684
|
for (let i = 0; i < extracted.length; ++i)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/define-property/index.js]{@link ./node_modules/define-property/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import isDescriptor from "../is-descriptor/index.mjs";
|
|
8
|
-
/*!
|
|
9
|
-
* define-property <https://github.com/jonschlinkert/define-property>
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
|
12
|
-
* Released under the MIT License.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
'use strict';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default function defineProperty(obj, prop, val) {
|
|
19
|
-
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
|
20
|
-
throw new TypeError('expected an object or function.');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (typeof prop !== 'string') {
|
|
24
|
-
throw new TypeError('expected `prop` to be a string.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isDescriptor(val) && ('set' in val || 'get' in val)) {
|
|
28
|
-
return Object.defineProperty(obj, prop, val);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return Object.defineProperty(obj, prop, {
|
|
32
|
-
configurable: true,
|
|
33
|
-
enumerable: false,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: val
|
|
36
|
-
});
|
|
37
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/is-accessor-descriptor/index.js]{@link ./node_modules/is-accessor-descriptor/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import typeOf from "../kind-of/index.mjs";
|
|
8
|
-
/*!
|
|
9
|
-
* is-accessor-descriptor <https://github.com/jonschlinkert/is-accessor-descriptor>
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015-2017, Jon Schlinkert.
|
|
12
|
-
* Released under the MIT License.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
'use strict';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var accessor = {
|
|
19
|
-
get: 'function',
|
|
20
|
-
set: 'function',
|
|
21
|
-
configurable: 'boolean',
|
|
22
|
-
enumerable: 'boolean'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
function isAccessorDescriptor(obj, prop) {
|
|
26
|
-
if (typeof prop === 'string') {
|
|
27
|
-
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
|
28
|
-
return typeof val !== 'undefined';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeOf(obj) !== 'object') {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (has(obj, 'value') || has(obj, 'writable')) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!has(obj, 'get') || typeof obj.get !== 'function') {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// tldr: it's valid to have "set" be undefined
|
|
44
|
-
// "set" might be undefined if `Object.getOwnPropertyDescriptor`
|
|
45
|
-
// was used to get the value, and only `get` was defined by the user
|
|
46
|
-
if (has(obj, 'set') && typeof obj[key] !== 'function' && typeof obj[key] !== 'undefined') {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (var key in obj) {
|
|
51
|
-
if (!accessor.hasOwnProperty(key)) {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (typeOf(obj[key]) === accessor[key]) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (typeof obj[key] !== 'undefined') {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function has(obj, key) {
|
|
67
|
-
return {}.hasOwnProperty.call(obj, key);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Expose `isAccessorDescriptor`
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
export default isAccessorDescriptor;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/is-data-descriptor/index.js]{@link ./node_modules/is-data-descriptor/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import typeOf from "../kind-of/index.mjs";
|
|
8
|
-
/*!
|
|
9
|
-
* is-data-descriptor <https://github.com/jonschlinkert/is-data-descriptor>
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015-2017, Jon Schlinkert.
|
|
12
|
-
* Released under the MIT License.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
'use strict';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export default function isDataDescriptor(obj, prop) {
|
|
19
|
-
// data descriptor properties
|
|
20
|
-
var data = {
|
|
21
|
-
configurable: 'boolean',
|
|
22
|
-
enumerable: 'boolean',
|
|
23
|
-
writable: 'boolean'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (typeOf(obj) !== 'object') {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (typeof prop === 'string') {
|
|
31
|
-
var val = Object.getOwnPropertyDescriptor(obj, prop);
|
|
32
|
-
return typeof val !== 'undefined';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!('value' in obj) && !('writable' in obj)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (var key in obj) {
|
|
40
|
-
if (key === 'value') continue;
|
|
41
|
-
|
|
42
|
-
if (!data.hasOwnProperty(key)) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (typeOf(obj[key]) === data[key]) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof obj[key] !== 'undefined') {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/is-descriptor/index.js]{@link ./node_modules/is-descriptor/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import typeOf from "../kind-of/index.mjs";
|
|
8
|
-
import isAccessor from "../is-accessor-descriptor/index.mjs";
|
|
9
|
-
import isData from "../is-data-descriptor/index.mjs";
|
|
10
|
-
/*!
|
|
11
|
-
* is-descriptor <https://github.com/jonschlinkert/is-descriptor>
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) 2015-2017, Jon Schlinkert.
|
|
14
|
-
* Released under the MIT License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
'use strict';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export default function isDescriptor(obj, key) {
|
|
23
|
-
if (typeOf(obj) !== 'object') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if ('get' in obj) {
|
|
27
|
-
return isAccessor(obj, key);
|
|
28
|
-
}
|
|
29
|
-
return isData(obj, key);
|
|
30
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/is-number/index.js]{@link ./node_modules/is-number/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
/*!
|
|
8
|
-
* is-number <https://github.com/jonschlinkert/is-number>
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
11
|
-
* Released under the MIT License.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
'use strict';
|
|
15
|
-
|
|
16
|
-
export default function(num) {
|
|
17
|
-
if (typeof num === 'number') {
|
|
18
|
-
return num - num === 0;
|
|
19
|
-
}
|
|
20
|
-
if (typeof num === 'string' && num.trim() !== '') {
|
|
21
|
-
return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/kind-of/index.js]{@link ./node_modules/kind-of/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
var toString = Object.prototype.toString;
|
|
8
|
-
|
|
9
|
-
export default function kindOf(val) {
|
|
10
|
-
if (val === void 0) return 'undefined';
|
|
11
|
-
if (val === null) return 'null';
|
|
12
|
-
|
|
13
|
-
var type = typeof val;
|
|
14
|
-
if (type === 'boolean') return 'boolean';
|
|
15
|
-
if (type === 'string') return 'string';
|
|
16
|
-
if (type === 'number') return 'number';
|
|
17
|
-
if (type === 'symbol') return 'symbol';
|
|
18
|
-
if (type === 'function') {
|
|
19
|
-
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (isArray(val)) return 'array';
|
|
23
|
-
if (isBuffer(val)) return 'buffer';
|
|
24
|
-
if (isArguments(val)) return 'arguments';
|
|
25
|
-
if (isDate(val)) return 'date';
|
|
26
|
-
if (isError(val)) return 'error';
|
|
27
|
-
if (isRegexp(val)) return 'regexp';
|
|
28
|
-
|
|
29
|
-
switch (ctorName(val)) {
|
|
30
|
-
case 'Symbol': return 'symbol';
|
|
31
|
-
case 'Promise': return 'promise';
|
|
32
|
-
|
|
33
|
-
// Set, Map, WeakSet, WeakMap
|
|
34
|
-
case 'WeakMap': return 'weakmap';
|
|
35
|
-
case 'WeakSet': return 'weakset';
|
|
36
|
-
case 'Map': return 'map';
|
|
37
|
-
case 'Set': return 'set';
|
|
38
|
-
|
|
39
|
-
// 8-bit typed arrays
|
|
40
|
-
case 'Int8Array': return 'int8array';
|
|
41
|
-
case 'Uint8Array': return 'uint8array';
|
|
42
|
-
case 'Uint8ClampedArray': return 'uint8clampedarray';
|
|
43
|
-
|
|
44
|
-
// 16-bit typed arrays
|
|
45
|
-
case 'Int16Array': return 'int16array';
|
|
46
|
-
case 'Uint16Array': return 'uint16array';
|
|
47
|
-
|
|
48
|
-
// 32-bit typed arrays
|
|
49
|
-
case 'Int32Array': return 'int32array';
|
|
50
|
-
case 'Uint32Array': return 'uint32array';
|
|
51
|
-
case 'Float32Array': return 'float32array';
|
|
52
|
-
case 'Float64Array': return 'float64array';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (isGeneratorObj(val)) {
|
|
56
|
-
return 'generator';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Non-plain objects
|
|
60
|
-
type = toString.call(val);
|
|
61
|
-
switch (type) {
|
|
62
|
-
case '[object Object]': return 'object';
|
|
63
|
-
// iterators
|
|
64
|
-
case '[object Map Iterator]': return 'mapiterator';
|
|
65
|
-
case '[object Set Iterator]': return 'setiterator';
|
|
66
|
-
case '[object String Iterator]': return 'stringiterator';
|
|
67
|
-
case '[object Array Iterator]': return 'arrayiterator';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// other
|
|
71
|
-
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
function ctorName(val) {
|
|
75
|
-
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function isArray(val) {
|
|
79
|
-
if (Array.isArray) return Array.isArray(val);
|
|
80
|
-
return val instanceof Array;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function isError(val) {
|
|
84
|
-
return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function isDate(val) {
|
|
88
|
-
if (val instanceof Date) return true;
|
|
89
|
-
return typeof val.toDateString === 'function'
|
|
90
|
-
&& typeof val.getDate === 'function'
|
|
91
|
-
&& typeof val.setDate === 'function';
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function isRegexp(val) {
|
|
95
|
-
if (val instanceof RegExp) return true;
|
|
96
|
-
return typeof val.flags === 'string'
|
|
97
|
-
&& typeof val.ignoreCase === 'boolean'
|
|
98
|
-
&& typeof val.multiline === 'boolean'
|
|
99
|
-
&& typeof val.global === 'boolean';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function isGeneratorFn(name, val) {
|
|
103
|
-
return ctorName(name) === 'GeneratorFunction';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function isGeneratorObj(val) {
|
|
107
|
-
return typeof val.throw === 'function'
|
|
108
|
-
&& typeof val.return === 'function'
|
|
109
|
-
&& typeof val.next === 'function';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function isArguments(val) {
|
|
113
|
-
try {
|
|
114
|
-
if (typeof val.length === 'number' && typeof val.callee === 'function') {
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
} catch (err) {
|
|
118
|
-
if (err.message.indexOf('callee') !== -1) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* If you need to support Safari 5-7 (8-10 yr-old browser),
|
|
127
|
-
* take a look at https://github.com/feross/is-buffer
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
function isBuffer(val) {
|
|
131
|
-
if (val.constructor && typeof val.constructor.isBuffer === 'function') {
|
|
132
|
-
return val.constructor.isBuffer(val);
|
|
133
|
-
}
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/window-size/index.js]{@link ./node_modules/window-size/index.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import define from "../define-property/index.mjs";
|
|
8
|
-
import utils from "./utils.mjs";
|
|
9
|
-
/*!
|
|
10
|
-
* window-size <https://github.com/jonschlinkert/window-size>
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
13
|
-
* Released under the MIT License.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
'use strict';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export default utils.get();
|
|
21
|
-
|
|
22
|
-
if (module.exports) {
|
|
23
|
-
/**
|
|
24
|
-
* Expose `windowSize.get` method
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
define(module.exports, 'get', utils.get);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Expose methods for unit tests
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
define(module.exports, 'env', utils.env);
|
|
34
|
-
define(module.exports, 'tty', utils.tty);
|
|
35
|
-
define(module.exports, 'tput', utils.tput);
|
|
36
|
-
define(module.exports, 'win', utils.win);
|
|
37
|
-
}
|
|
38
|
-
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DO NOT EDIT THIS FILE DIRECTLY.
|
|
3
|
-
* This file is generated following the conversion of
|
|
4
|
-
* @see [./node_modules/window-size/utils.js]{@link ./node_modules/window-size/utils.js}
|
|
5
|
-
*
|
|
6
|
-
**/
|
|
7
|
-
import os from "os";
|
|
8
|
-
import isNumber from "../is-number/index.mjs";
|
|
9
|
-
import cp from "child_process";
|
|
10
|
-
var tty = options.tty || require('tty');
|
|
11
|
-
/*!
|
|
12
|
-
* window-size <https://github.com/jonschlinkert/window-size>
|
|
13
|
-
*
|
|
14
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
15
|
-
* Released under the MIT License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function windowSize(options) {
|
|
24
|
-
options = options || {};
|
|
25
|
-
return streamSize(options, 'stdout') ||
|
|
26
|
-
streamSize(options, 'stderr') ||
|
|
27
|
-
envSize() ||
|
|
28
|
-
ttySize(options);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function streamSize(options, name) {
|
|
32
|
-
var stream = (process && process[name]) || options[name];
|
|
33
|
-
var size;
|
|
34
|
-
|
|
35
|
-
if (!stream) return;
|
|
36
|
-
if (typeof stream.getWindowSize === 'function') {
|
|
37
|
-
size = stream.getWindowSize();
|
|
38
|
-
if (isSize(size)) {
|
|
39
|
-
return {
|
|
40
|
-
width: size[0],
|
|
41
|
-
height: size[1],
|
|
42
|
-
type: name
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
size = [stream.columns, stream.rows];
|
|
48
|
-
if (isSize(size)) {
|
|
49
|
-
return {
|
|
50
|
-
width: Number(size[0]),
|
|
51
|
-
height: Number(size[1]),
|
|
52
|
-
type: name
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function envSize() {
|
|
58
|
-
if (process && process.env) {
|
|
59
|
-
var size = [process.env.COLUMNS, process.env.ROWS];
|
|
60
|
-
if (isSize(size)) {
|
|
61
|
-
return {
|
|
62
|
-
width: Number(size[0]),
|
|
63
|
-
height: Number(size[1]),
|
|
64
|
-
type: 'process.env'
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function ttySize(options, stdout) {
|
|
71
|
-
if (tty && typeof tty.getWindowSize === 'function') {
|
|
72
|
-
var size = tty.getWindowSize(stdout);
|
|
73
|
-
if (isSize(size)) {
|
|
74
|
-
return {
|
|
75
|
-
width: Number(size[1]),
|
|
76
|
-
height: Number(size[0]),
|
|
77
|
-
type: 'tty'
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function winSize() {
|
|
84
|
-
if (os.release().startsWith('10')) {
|
|
85
|
-
var cmd = 'wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution';
|
|
86
|
-
var numberPattern = /\d+/g;
|
|
87
|
-
var code = cp.execSync(cmd).toString();
|
|
88
|
-
var size = code.match(numberPattern);
|
|
89
|
-
if (isSize(size)) {
|
|
90
|
-
return {
|
|
91
|
-
width: Number(size[0]),
|
|
92
|
-
height: Number(size[1]),
|
|
93
|
-
type: 'windows'
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function tputSize() {
|
|
100
|
-
try {
|
|
101
|
-
var buf = cp.execSync('tput cols && tput lines', {stdio: ['ignore', 'pipe', process.stderr]});
|
|
102
|
-
var size = buf.toString().trim().split('\n');
|
|
103
|
-
if (isSize(size)) {
|
|
104
|
-
return {
|
|
105
|
-
width: Number(size[0]),
|
|
106
|
-
height: Number(size[1]),
|
|
107
|
-
type: 'tput'
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
} catch (err) {}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Returns true if the given size array has
|
|
115
|
-
* valid height and width values.
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
function isSize(size) {
|
|
119
|
-
return Array.isArray(size) && isNumber(size[0]) && isNumber(size[1]);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Expose `windowSize`
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
export default {
|
|
127
|
-
get: windowSize,
|
|
128
|
-
env: envSize,
|
|
129
|
-
tty: ttySize,
|
|
130
|
-
tput: tputSize,
|
|
131
|
-
win: winSize
|
|
132
|
-
};
|