@gjsify/console 0.3.20 → 0.4.0

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.
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
package/lib/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- const e=typeof print==`function`&&typeof printerr==`function`;function t(...e){let t=e[0],n=e.slice(1);if(typeof t!=`string`||!/%(s|d|i|f|o|O|c)/.test(t))return e.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `);let r=0,i=t.replace(/%([sdifOoc])/g,(e,t)=>{if(r>=n.length)return e;let i=n[r++];switch(t){case`s`:return String(i);case`d`:case`i`:return String(parseInt(String(i),10));case`f`:return String(parseFloat(String(i)));case`o`:case`O`:return JSON.stringify(i);case`c`:return``;default:return e}}),a=n.slice(r);return a.length===0?i:i+` `+a.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `)}var n=class{_stdout;_stderr;_groupDepth=0;_groupIndentation;_timers=new Map;_counters=new Map;constructor(e,t){if(e&&typeof e.write==`function`)this._stdout=e,this._stderr=t||this._stdout;else if(e&&typeof e==`object`){let t=e;this._stdout=t.stdout,this._stderr=t.stderr||t.stdout}this._groupIndentation=2}_write(n,...r){let i=n===`stderr`&&this._stderr||this._stdout;if(i){let e=` `.repeat(this._groupDepth*this._groupIndentation),n=t(...r);i.write(e+n+`
2
- `)}else if(e){let e=` `.repeat(this._groupDepth*this._groupIndentation)+t(...r);n===`stderr`?printerr(e):print(e)}else{let e=globalThis.console;n===`stderr`?e.error(...r):e.log(...r)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):e?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(t,n){this._stdout?this._write(`stdout`,t):e?print(JSON.stringify(t,null,2)):globalThis.console.table(t,n)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
1
+ import"./_virtual/_rolldown/runtime.js";const e=typeof print==`function`&&typeof printerr==`function`;function _formatArgs(...e){let t=e[0],n=e.slice(1);if(typeof t!=`string`||!/%(s|d|i|f|o|O|c)/.test(t))return e.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `);let r=0,i=t.replace(/%([sdifOoc])/g,(e,t)=>{if(r>=n.length)return e;let i=n[r++];switch(t){case`s`:return String(i);case`d`:case`i`:return String(parseInt(String(i),10));case`f`:return String(parseFloat(String(i)));case`o`:case`O`:return JSON.stringify(i);case`c`:return``;default:return e}}),a=n.slice(r);return a.length===0?i:i+` `+a.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `)}var Console=class{_stdout;_stderr;_groupDepth=0;_groupIndentation;_timers=new Map;_counters=new Map;constructor(e,t){if(e&&typeof e.write==`function`)this._stdout=e,this._stderr=t||this._stdout;else if(e&&typeof e==`object`){let t=e;this._stdout=t.stdout,this._stderr=t.stderr||t.stdout}this._groupIndentation=2}_write(t,...n){let r=t===`stderr`&&this._stderr||this._stdout;if(r){let e=` `.repeat(this._groupDepth*this._groupIndentation),t=_formatArgs(...n);r.write(e+t+`
2
+ `)}else if(e){let e=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...n);t===`stderr`?printerr(e):print(e)}else{let e=globalThis.console;t===`stderr`?e.error(...n):e.log(...n)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):e?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(t,n){this._stdout?this._write(`stdout`,t):e?print(JSON.stringify(t,null,2)):globalThis.console.table(t,n)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
3
3
  `).slice(1).join(`
4
4
  `)||``;this._write(`stderr`,`Trace:`,...e,`
5
- `+t)}profile(e){}profileEnd(e){}timeStamp(e){}};const r=new n,i=(...e)=>r.log(...e),a=(...e)=>r.info(...e),o=(...e)=>r.debug(...e),s=(...e)=>r.warn(...e),c=(...e)=>r.error(...e),l=(e,t)=>r.dir(e,t),u=(...e)=>r.dirxml(...e),d=(e,t)=>r.table(e,t),f=()=>r.clear(),p=(e,...t)=>r.assert(e,...t),m=(...e)=>r.trace(...e),h=e=>r.time(e),g=e=>r.timeEnd(e),_=(e,...t)=>r.timeLog(e,...t),v=e=>r.count(e),y=e=>r.countReset(e),b=(...e)=>r.group(...e),x=(...e)=>r.groupCollapsed(...e),S=()=>r.groupEnd(),C=e=>{},w=e=>{},T=e=>{},E={Console:n,log:i,info:a,debug:o,warn:s,error:c,dir:l,dirxml:u,table:d,time:h,timeEnd:g,timeLog:_,trace:m,assert:p,clear:f,count:v,countReset:y,group:b,groupCollapsed:x,groupEnd:S,profile:C,profileEnd:w,timeStamp:T};export{n as Console,p as assert,f as clear,v as count,y as countReset,o as debug,E as default,l as dir,u as dirxml,c as error,b as group,x as groupCollapsed,S as groupEnd,a as info,i as log,C as profile,w as profileEnd,d as table,h as time,g as timeEnd,_ as timeLog,T as timeStamp,m as trace,s as warn};
5
+ `+t)}profile(e){}profileEnd(e){}timeStamp(e){}};const t=new Console,log=(...e)=>t.log(...e),info=(...e)=>t.info(...e),debug=(...e)=>t.debug(...e),warn=(...e)=>t.warn(...e),error=(...e)=>t.error(...e),dir=(e,n)=>t.dir(e,n),dirxml=(...e)=>t.dirxml(...e),table=(e,n)=>t.table(e,n),clear=()=>t.clear(),assert=(e,...n)=>t.assert(e,...n),trace=(...e)=>t.trace(...e),time=e=>t.time(e),timeEnd=e=>t.timeEnd(e),timeLog=(e,...n)=>t.timeLog(e,...n),count=e=>t.count(e),countReset=e=>t.countReset(e),group=(...e)=>t.group(...e),groupCollapsed=(...e)=>t.groupCollapsed(...e),groupEnd=()=>t.groupEnd(),profile=e=>{},profileEnd=e=>{},timeStamp=e=>{},n={Console,log,info,debug,warn,error,dir,dirxml,table,time,timeEnd,timeLog,trace,assert,clear,count,countReset,group,groupCollapsed,groupEnd,profile,profileEnd,timeStamp};export{Console,assert,clear,count,countReset,debug,n as default,dir,dirxml,error,group,groupCollapsed,groupEnd,info,log,profile,profileEnd,table,time,timeEnd,timeLog,timeStamp,trace,warn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/console",
3
- "version": "0.3.20",
3
+ "version": "0.4.0",
4
4
  "description": "Node.js console module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -30,8 +30,8 @@
30
30
  "console"
31
31
  ],
32
32
  "devDependencies": {
33
- "@gjsify/cli": "^0.3.20",
34
- "@gjsify/unit": "^0.3.20",
33
+ "@gjsify/cli": "^0.4.0",
34
+ "@gjsify/unit": "^0.4.0",
35
35
  "@types/node": "^25.6.2",
36
36
  "typescript": "^6.0.3"
37
37
  }