@lowlighter/run 3.0.0 → 3.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.
package/mod.mjs DELETED
@@ -1 +0,0 @@
1
- var e=class e{constructor({level:t,format:r,output:n,tags:o,...s}={}){"granted"===globalThis.Deno?.permissions.querySync?.({name:"env",variable:"LOG_LEVEL"}).state&&(t??=globalThis.Deno?.env.get("LOG_LEVEL")),this.#e=n||null===n?n:console,this.#t=e.level.log,this.#r=e.format.text,this.#n={date:!1,time:!1,delta:!0,caller:{file:!1,name:!1,line:!1,fileformat:null}},this.level(t).format(r).options(s),this.tags=o??{}}#e;#n;options(e){if(!e)return structuredClone(this.#n);if("date"in e&&(this.#n.date=e.date),"time"in e&&(this.#n.time=e.time),"delta"in e&&(this.#n.delta=e.delta),"caller"in e)switch(!0){case!0===e.caller:this.#n.caller={file:!0,name:!0,line:!0,fileformat:this.#n.caller.fileformat};break;case!1===e.caller:this.#n.caller={file:!1,name:!1,line:!1,fileformat:this.#n.caller.fileformat};break;case"object"==typeof e.caller:"file"in e.caller&&(this.#n.caller.file=e.caller.file),"name"in e.caller&&(this.#n.caller.name=e.caller.name),"line"in e.caller&&(this.#n.caller.line=e.caller.line),"fileformat"in e.caller&&void 0!==e.caller.fileformat&&(this.#n.caller.fileformat=e.caller.fileformat)}return this}#t;level(t){return arguments.length?(Number.isNaN(Number.parseInt(`${t}`))||(t=Number.parseInt(`${t}`)),"string"==typeof t&&t in e.level&&(t=e.level[t]),"number"==typeof t&&(this.#t=!Number.isNaN(t)&&t>=0?t:-1),this):this.#t>=0?this.#t:NaN}#o=new Map;#s=new Map;censor({values:e=[],keys:t=[],replace:r="[[redacted]]"}){return e.forEach((e=>this.#o.set(e,r))),t.forEach((e=>this.#s.set(e,r))),this}#i(e){return"string"==typeof e?this.#l(e):"object"==typeof e&&e?this.#a(e):e}#l(e){for(const[t,r]of this.#o)e=e.replaceAll(t instanceof RegExp&&!t.flags.includes("g")?new RegExp(t.source,"g"):t,r);return e}#a(e,t={}){for(const[r,n]of Object.entries(e))if(t[r]=n,"object"==typeof n&&n)t[r]=this.#a(n);else if("string"==typeof n){t[r]=this.#l(n);for(const[e,n]of this.#s)r===e&&(t[r]=n),e.test?.(r)&&(t[r]=n)}return t}static level=Object.freeze({disabled:NaN,error:0,warn:1,info:2,ok:2,log:3,debug:4,wdebug:4,trace:5,probe:NaN,always:1/0});error(...t){return this.#t>=e.level.error&&this.#e?.error(...this.#r(this,{level:"error",content:t,options:this.#n})),this}warn(...t){return this.#t>=e.level.warn&&this.#e?.warn(...this.#r(this,{level:"warn",content:t,options:this.#n})),this}info(...t){return this.#t>=e.level.info&&this.#e?.info(...this.#r(this,{level:"info",content:t,options:this.#n})),this}ok(...t){return this.#t>=e.level.info&&this.#e?.info(...this.#r(this,{level:"ok",content:t,options:this.#n})),this}log(...t){return this.#t>=e.level.log&&this.#e?.log(...this.#r(this,{level:"log",content:t,options:this.#n})),this}debug(...t){return this.#t>=e.level.debug&&this.#e?.debug(...this.#r(this,{level:"debug",content:t,options:this.#n})),this}wdebug(...t){return this.#t>=e.level.debug&&this.#e?.debug(...this.#r(this,{level:"wdebug",content:t,options:this.#n})),this}trace(...t){return this.#t>=e.level.trace&&this.#e?.debug(...this.#r(this,{level:"trace",content:t,options:this.#n})),this}probe(...e){return this.#e?.debug(...this.#r(this,{level:"probe",content:e,options:this.#n})),this}tags;with(t={}){const r=new e({level:this.#t,format:this.#r,output:this.#e,...this.#n,tags:{...this.tags,...t}});return this.#o.forEach(((e,t)=>r.#o.set(t,e))),this.#s.forEach(((e,t)=>r.#s.set(t,e))),r}#c(e=3){const t=Error,r=t.prepareStackTrace;t.prepareStackTrace=(e,t)=>t;const{stack:n}=new Error;t.prepareStackTrace=r;return n.map((e=>({file:e.getFileName(),name:e.getFunctionName(),line:e.getLineNumber(),column:e.getColumnNumber()})))[e]}#u(e){return e=this.#i(e),globalThis.Deno?.inspect(e,{colors:!0,depth:1/0,strAbbreviateSize:1/0})??e}#r;format(t){return this.#r=("string"==typeof t?e.format[t]:t)??e.format.text,this}static format={text(e,{level:t,content:r,options:n}){const o={error:"red",warn:"orange",info:"cyan",ok:"green",log:"white",debug:"gray",wdebug:"yellow",trace:"gray",probe:"magenta"}[t],s=[`%c ${t.replace("wdebug","debug").toLocaleUpperCase().padEnd(5)} │%c`],i=[`color: black; background-color: ${o}`,""];if(n.date||n.time||n.delta){const e=(new Date).toISOString(),t=[];if(n.delta){const e=performance.now()/1e3;let r=e.toPrecision(4);e<1&&(r=e.toPrecision(2)),t.push(`+${r}`)}n.date&&n.time?t.push(e):n.date?t.push(e.slice(0,e.indexOf("T"))):n.time&&t.push(e.slice(e.indexOf("T")+1,-1)),s.push(`%c ${t.join(" ¦ ").trim()} %c`),i.push(`color: black; background-color: ${o}`,"")}if(n.caller.file||n.caller.name||n.caller.line){const t=e.#c();if(t){const e=[];if(n.caller.file){let r=`${t.file}`;Array.isArray(n.caller.fileformat)&&(r=r.replace(n.caller.fileformat[0],n.caller.fileformat[1])),e.push(r)}n.caller.name&&t.name&&e.push(t.name),n.caller.line&&e.push(t.line,t.column),s.push(`%c ${e.join(":").trim()} %c`),i.push("color: black; background-color: gray","")}}const l=[];for(const[t,r]of Object.entries(e.tags))l.push(`${t}:${e.#u(r)}`);return s.push(`%c ${l.join(" ").trim()} %c`),i.push("background-color: black",""),[s.join(""),...i,...r.map((t=>e.#u(t)))]},json(e,{level:t,content:r,options:n}){const o={level:t,timestamp:Date.now(),tags:Object.fromEntries(Object.entries(e.tags).map((([t,r])=>[t,e.#i(r)]))),content:r.map((t=>e.#i(t)))},s={};if(n.date||n.time){const e=new Date(o.timestamp).toISOString();n.date&&(s.date=e.slice(0,e.indexOf("T"))),n.time&&(s.time=e.slice(e.indexOf("T")+1,-1))}if(n.delta&&(s.delta=performance.now()/1e3),n.caller.file||n.caller.name||n.caller.line){const t=e.#c();if(t){if(s.caller={},n.caller.file){let e=`${t.file}`;Array.isArray(n.caller.fileformat)&&(e=e.replace(n.caller.fileformat[0],n.caller.fileformat[1])),s.caller.file=e}n.caller.name&&t.name&&(s.caller.name=t.name),n.caller.line&&(s.caller.line=[t.line,t.column])}}return[JSON.stringify({...o,...s})]}}};TransformStream;function t(e){let t=0;for(const r of e)t+=r.length;const r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function r(e){const t=e.length,r=new Uint8Array(t);r[0]=0;let n=0,o=1;for(;o<t;)e[o]===e[n]?(n++,r[o]=n,o++):0===n?(r[o]=0,o++):n=r[n-1];return r}TransformStream,TransformStream,TransformStream,TransformStream;var n=class extends TransformStream{#d="";constructor(e={allowCR:!1}){super({transform:(t,r)=>{for(t=this.#d+t;;){const n=t.indexOf("\n"),o=e.allowCR?t.indexOf("\r"):-1;if(-1!==o&&o!==t.length-1&&(-1===n||n-1>o)){r.enqueue(t.slice(0,o)),t=t.slice(o+1);continue}if(-1===n)break;const s="\r"===t[n-1]?n-1:n;r.enqueue(t.slice(0,s)),t=t.slice(n+1)}this.#d=t},flush:t=>{if(""===this.#d)return;const r=e.allowCR&&this.#d.endsWith("\r")?this.#d.slice(0,-1):this.#d;t.enqueue(r)}})}};var o=new TextEncoder,s=new TextDecoder;function i(t,r,{logger:i=new e,stdin:a=null,stdout:c="debug",stderr:u="error",env:d,cwd:h,raw:f,callback:p,buffering:m,sync:g,throw:w,dryrun:b,winext:v="",os:y=Deno.build.os}={}){"windows"===y&&(t=`${t}${v}`),i=i.with({bin:t}),p&&"piped"!==l(a)&&(a="piped");const k=new Deno.Command(t,{args:r,stdin:g?"null":l(a),stdout:l(c),stderr:l(u),env:d,cwd:h,windowsRawArguments:f});if(b){i.wdebug(`dryrun: ${t} not executed`);const e={success:!0,code:0,stdio:[],stdin:"",stdout:"",stderr:""};return g?e:Promise.resolve(e)}return g?function(e,{bin:t,log:r,throw:n,stdout:o,stderr:i}){const a=Date.now(),c=e.outputSync(),{success:u,code:d}=c,h=Date.now()-a,f={get stdio(){return[[h,1,this.stdout],[h,2,this.stderr]]},stdin:"",stdout:"piped"===l(o)?s.decode(c.stdout):"",stderr:"piped"===l(i)?s.decode(c.stderr):""};for(const{channel:e,mode:t}of[{channel:"stdout",mode:o},{channel:"stderr",mode:i}])"piped"===l(t)&&f[e]&&r.with({t:h,channel:e})[t]?.(f[e]);if(!u&&n)throw new EvalError(`${t} exited with non-zero code ${d}:\n${f.stdout}\n${f.stderr}`);return{success:u,code:d,...f}}(k,{bin:t,log:i,throw:w,stdout:c,stderr:u}):async function(e,{bin:t,log:r,callback:s=({close:e})=>e?.(),buffering:i=250,throw:a,...c}){const u=e.spawn(),d=Date.now(),h={stdio:[],get stdin(){return this.stdio.filter((([e,t])=>0===t)).map((([e,t,r])=>r)).join("\n")},get stdout(){return this.stdio.filter((([e,t])=>1===t)).map((([e,t,r])=>r)).join("\n")},get stderr(){return this.stdio.filter((([e,t])=>2===t)).map((([e,t,r])=>r)).join("\n")}},f={};let p="";const m=function(e,t){let r=null,n=null;const o=(...s)=>{o.clear(),n=()=>{o.clear(),e.call(o,...s)},r=Number(setTimeout(n,t))};return o.clear=()=>{"number"==typeof r&&(clearTimeout(r),r=null,n=null)},o.flush=()=>{n?.()},Object.defineProperty(o,"pending",{get:()=>"number"==typeof r}),o}((async e=>{r.with({t:e}).trace("debounced"),p="",await s({stdio:h,i:h.stdin.length,...f})}),i);if("piped"===l(c.stdin)){const e=u.stdin.getWriter();Object.assign(f,{async write(t,n=!0){const s=Date.now()-d;c.stdin&&r.with({t:s,channel:"stdin"})[c.stdin]?.(t),h.stdio.push([s,0,t]),n&&!t.endsWith("\n")&&(t+="\n"),await e.write(o.encode(t)),p="stdin",e.releaseLock()},async close(){try{e.releaseLock(),await u.stdin.close(),r.with({t:Date.now()-d,closed:"stdin"}).trace()}catch{}},async wait(e=1e3){const t=Date.now()-d;r.with({t:t,waiting:e}).trace(),await function(e,t={}){const{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise(((t,o)=>{const s=()=>{clearTimeout(i),o(r?.reason)},i=setTimeout((()=>{r?.removeEventListener("abort",s),t()}),e);if(r?.addEventListener("abort",s,{once:!0}),!1===n)try{Deno.unrefTimer(i)}catch(e){if(!(e instanceof ReferenceError))throw e;console.error("`persistent` option is only available in Deno")}}))}(e),m(t)}}),m(Date.now()-d)}await Promise.all(["stdout","stderr"].filter((e=>"piped"===l(c[e]))).map((async e=>{for await(const t of u[e].pipeThrough(new TextDecoderStream).pipeThrough(new n)){const n=Date.now()-d,o={stdout:1,stderr:2}[e];if(c[e]&&r.with({t:n,channel:e})[c[e]]?.(t),h.stdio.length&&p===e){const e=h.stdio.at(-1);e[1]===o&&(e[2]+=`\n${t}`)}else h.stdio.push([n,o,t]);p=e,m(n)}}))),m.flush();const{success:g,code:w}=await u.status;if(!g&&a)throw new EvalError(`${t} exited with non-zero code ${w}:\n${h.stdout}\n${h.stderr}`);return{success:g,code:w,...h}}(k,{bin:t,log:i,callback:p,buffering:m,throw:w,stdin:"piped"===l(a)?a:null,stdout:"piped"===l(c)?c:null,stderr:"piped"===l(u)?u:null})}function l(e){return["inherit","null"].includes(`${e}`)?`${e}`:"piped"}export{i as command};
package/mod.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./command.ts"
package/mod_test.ts DELETED
@@ -1 +0,0 @@
1
- import "./mod.ts"