@php-wasm/logger
Advanced tools
Comparing version 0.6.8 to 0.6.9
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=function(){var o;return typeof process<"u"&&((o=process.release)==null?void 0:o.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(u==="NODE"){let o=function(e){return new Promise(function(r,n){e.onload=e.onerror=function(s){e.onload=e.onerror=null,s.type==="load"?r(e.result):n(new Error("Failed to read the blob/file"))}})},t=function(){const e=new Uint8Array([1,2,3,4]),n=new File([e],"test").stream();try{return n.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class e extends Blob{constructor(n,s,a){super(n);let i;a!=null&&a.lastModified&&(i=new Date),(!i||isNaN(i.getFullYear()))&&(i=new Date),this.lastModifiedDate=i,this.lastModified=i.getMilliseconds(),this.name=s||""}}global.File=e}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const r=new FileReader;return r.readAsArrayBuffer(this),o(r)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const r=new FileReader;return r.readAsText(this),o(r)}),(typeof Blob.prototype.stream>"u"||!t())&&(Blob.prototype.stream=function(){let e=0;const r=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(n){const s=n.byobRequest.view,i=await r.slice(e,e+s.byteLength).arrayBuffer(),d=new Uint8Array(i);new Uint8Array(s.buffer).set(d);const l=d.byteLength;n.byobRequest.respond(l),e+=l,e>=r.size&&n.close()}})})}if(u==="NODE"&&typeof CustomEvent>"u"){class o extends Event{constructor(e,r={}){super(e,r),this.detail=r.detail}initCustomEvent(){}}globalThis.CustomEvent=o}class f extends EventTarget{constructor(t){super(),this.fatalErrorEvent="playground-fatal-error",this.logs=[],this.windowConnected=!1,this.lastPHPLogLength=0,this.errorLogPath="/wordpress/wp-content/debug.log",t&&(this.errorLogPath=t)}async getRequestPhpErrorLog(t){return await t.fileExists(this.errorLogPath)?await t.readFileAsText(this.errorLogPath):""}logWindowError(t){this.log(`${t.message} in ${t.filename} on line ${t.lineno}:${t.colno}`,"Error")}logUnhandledRejection(t){this.log(`${t.reason.stack}`,"Error")}addWindowErrorListener(){this.windowConnected||typeof window>"u"||(window.addEventListener("error",this.logWindowError.bind(this)),window.addEventListener("unhandledrejection",this.logUnhandledRejection.bind(this)),window.addEventListener("rejectionhandled",this.logUnhandledRejection.bind(this)),this.windowConnected=!0)}addPlaygroundRequestEndListener(t){t.addEventListener("request.end",async()=>{const e=await this.getRequestPhpErrorLog(t);e.length>this.lastPHPLogLength&&(this.logRaw(e.substring(this.lastPHPLogLength)),this.lastPHPLogLength=e.length)}),t.addEventListener("request.error",e=>{e=e,e.error&&(this.log(`${e.error.message} ${e.error.stack}`,"Fatal","PHP-WASM"),this.dispatchEvent(new CustomEvent(this.fatalErrorEvent,{detail:{logs:this.getLogs()}})))})}formatLogDate(t){const e=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(t).replace(/ /g,"-"),r=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(t);return e+" "+r}formatMessage(t,e,r){return`[${this.formatLogDate(new Date)}] ${r} ${e}: ${t}`}log(t,e,r){e===void 0&&(e="Info");const n=this.formatMessage(t,e,r??"Playground");this.logRaw(n)}logRaw(t){this.logs.push(t),console.debug(t)}getLogs(){return this.logs}}const c=new f;function g(o){o.addWindowErrorListener()}function h(o,t){o.addPlaygroundRequestEndListener(t)}function w(o,t){o.addEventListener(o.fatalErrorEvent,t)}exports.Logger=f;exports.addFatalErrorListener=w;exports.collectPhpLogs=h;exports.collectWindowErrors=g;exports.logger=c; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=function(){var o;return typeof process<"u"&&((o=process.release)==null?void 0:o.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(u==="NODE"){let o=function(t){return new Promise(function(r,n){t.onload=t.onerror=function(s){t.onload=t.onerror=null,s.type==="load"?r(t.result):n(new Error("Failed to read the blob/file"))}})},e=function(){const t=new Uint8Array([1,2,3,4]),n=new File([t],"test").stream();try{return n.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class t extends Blob{constructor(n,s,a){super(n);let i;a!=null&&a.lastModified&&(i=new Date),(!i||isNaN(i.getFullYear()))&&(i=new Date),this.lastModifiedDate=i,this.lastModified=i.getMilliseconds(),this.name=s||""}}global.File=t}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const r=new FileReader;return r.readAsArrayBuffer(this),o(r)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const r=new FileReader;return r.readAsText(this),o(r)}),(typeof Blob.prototype.stream>"u"||!e())&&(Blob.prototype.stream=function(){let t=0;const r=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(n){const s=n.byobRequest.view,i=await r.slice(t,t+s.byteLength).arrayBuffer(),d=new Uint8Array(i);new Uint8Array(s.buffer).set(d);const l=d.byteLength;n.byobRequest.respond(l),t+=l,t>=r.size&&n.close()}})})}if(u==="NODE"&&typeof CustomEvent>"u"){class o extends Event{constructor(t,r={}){super(t,r),this.detail=r.detail}initCustomEvent(){}}globalThis.CustomEvent=o}class f extends EventTarget{constructor(e){super(),this.fatalErrorEvent="playground-fatal-error",this.logs=[],this.windowConnected=!1,this.lastPHPLogLength=0,this.errorLogPath="/wordpress/wp-content/debug.log",e&&(this.errorLogPath=e)}async getRequestPhpErrorLog(e){return await e.fileExists(this.errorLogPath)?await e.readFileAsText(this.errorLogPath):""}logWindowError(e){this.log(`${e.message} in ${e.filename} on line ${e.lineno}:${e.colno}`,"Error")}logUnhandledRejection(e){if(!(e!=null&&e.reason))return;const t=(e==null?void 0:e.reason.stack)??e.reason;this.log(t,"Error")}addWindowErrorListener(){this.windowConnected||typeof window>"u"||(window.addEventListener("error",this.logWindowError.bind(this)),window.addEventListener("unhandledrejection",this.logUnhandledRejection.bind(this)),window.addEventListener("rejectionhandled",this.logUnhandledRejection.bind(this)),this.windowConnected=!0)}addPlaygroundRequestEndListener(e){e.addEventListener("request.end",async()=>{const t=await this.getRequestPhpErrorLog(e);t.length>this.lastPHPLogLength&&(this.logRaw(t.substring(this.lastPHPLogLength)),this.lastPHPLogLength=t.length)}),e.addEventListener("request.error",t=>{t=t,t.error&&(this.log(`${t.error.message} ${t.error.stack}`,"Fatal","PHP-WASM"),this.dispatchEvent(new CustomEvent(this.fatalErrorEvent,{detail:{logs:this.getLogs(),source:t.source}})))})}formatLogDate(e){const t=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(e).replace(/ /g,"-"),r=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(e);return t+" "+r}formatMessage(e,t,r){return`[${this.formatLogDate(new Date)}] ${r} ${t}: ${e}`}log(e,t,r){t===void 0&&(t="Info");const n=this.formatMessage(e,t,r??"Playground");this.logRaw(n)}logRaw(e){this.logs.push(e),console.debug(e)}getLogs(){return this.logs}}const c=new f;function g(o){o.addWindowErrorListener()}function h(o,e){o.addPlaygroundRequestEndListener(e)}function w(o,e){o.addEventListener(o.fatalErrorEvent,e)}exports.Logger=f;exports.addFatalErrorListener=w;exports.collectPhpLogs=h;exports.collectWindowErrors=g;exports.logger=c; |
{ | ||
"name": "@php-wasm/logger", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "A logger for PHP-wasm clients like Playground and WP-now.", | ||
@@ -28,3 +28,3 @@ "repository": { | ||
}, | ||
"gitHead": "cb7b1af260489022238495a2fc0d96f767a1294a" | ||
"gitHead": "f6b98ad6d05617ee8cb1234c21318fdde17a6e56" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14450
348
0