@php-wasm/logger 0.7.19 → 0.9.2
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/index.cjs +3 -2
- package/index.js +117 -101
- package/lib/handlers/log-event.d.ts +3 -0
- package/lib/logger.d.ts +2 -0
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=function(){var e;return typeof process<"u"&&((e=process.release)==null?void 0:e.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(w==="NODE"){let e=function(t){return new Promise(function(s,o){t.onload=t.onerror=function(n){t.onload=t.onerror=null,n.type==="load"?s(t.result):o(new Error("Failed to read the blob/file"))}})},r=function(){const t=new Uint8Array([1,2,3,4]),o=new File([t],"test").stream();try{return o.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class t extends Blob{constructor(o,n,i){super(o);let a;i!=null&&i.lastModified&&(a=new Date),(!a||isNaN(a.getFullYear()))&&(a=new Date),this.lastModifiedDate=a,this.lastModified=a.getMilliseconds(),this.name=n||""}}global.File=t}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const s=new FileReader;return s.readAsArrayBuffer(this),e(s)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const s=new FileReader;return s.readAsText(this),e(s)}),(typeof Blob.prototype.stream>"u"||!r())&&(Blob.prototype.stream=function(){let t=0;const s=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(o){const n=o.byobRequest.view,a=await s.slice(t,t+n.byteLength).arrayBuffer(),u=new Uint8Array(a);new Uint8Array(n.buffer).set(u);const g=u.byteLength;o.byobRequest.respond(g),t+=g,t>=s.size&&o.close()}})})}if(w==="NODE"&&typeof CustomEvent>"u"){class e extends Event{constructor(t,s={}){super(t,s),this.detail=s.detail}initCustomEvent(){}}globalThis.CustomEvent=e}const E="playground-log",m=(e,...r)=>{M.dispatchEvent(new CustomEvent(E,{detail:{log:e,args:r}}))},O=(e,...r)=>{switch(typeof e.message=="string"?e.message=l(e.message):e.message.message&&typeof e.message.message=="string"&&(e.message.message=l(e.message.message)),e.severity){case"Debug":console.debug(e.message,...r);break;case"Info":console.info(e.message,...r);break;case"Warn":console.warn(e.message,...r);break;case"Error":console.error(e.message,...r);break;case"Fatal":console.error(e.message,...r);break;default:console.log(e.message,...r)}},P=e=>e instanceof Error?[e.message,e.stack].join(`
|
|
2
|
+
`):JSON.stringify(e,null,2),v=[],p=e=>{v.push(e)},f=e=>{if(e.raw===!0)p(e.message);else{const r=T(typeof e.message=="object"?P(e.message):e.message,e.severity??"Info",e.prefix??"JavaScript");p(r)}};class L extends EventTarget{constructor(r=[]){super(),this.handlers=r,this.fatalErrorEvent="playground-fatal-error"}getLogs(){return this.handlers.includes(f)?[...v]:(this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
2
3
|
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
3
|
-
`),[])}logMessage(
|
|
4
|
+
`),[])}logMessage(r,...t){for(const s of this.handlers)s(r,...t)}log(r,...t){this.logMessage({message:r,severity:void 0,prefix:"JavaScript",raw:!1},...t)}debug(r,...t){this.logMessage({message:r,severity:"Debug",prefix:"JavaScript",raw:!1},...t)}info(r,...t){this.logMessage({message:r,severity:"Info",prefix:"JavaScript",raw:!1},...t)}warn(r,...t){this.logMessage({message:r,severity:"Warn",prefix:"JavaScript",raw:!1},...t)}error(r,...t){this.logMessage({message:r,severity:"Error",prefix:"JavaScript",raw:!1},...t)}}const S=()=>{try{if(process.env.NODE_ENV==="test")return[f,m]}catch{}return[f,O,m]},M=new L(S()),l=e=>e.replace(/\t/g,""),T=(e,r,t)=>{const s=new Date,o=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(s).replace(/ /g,"-"),n=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(s),i=o+" "+n;return e=l(e),`[${i}] ${t} ${r}: ${e}`},k=(e,r)=>{e.addEventListener(e.fatalErrorEvent,r)};let c=0;const y="/wordpress/wp-content/debug.log",B=async e=>await e.fileExists(y)?await e.readFileAsText(y):"",x=(e,r)=>{r.addEventListener("request.end",async()=>{const t=await B(r);if(t.length>c){const s=t.substring(c);e.logMessage({message:s,raw:!0}),c=t.length}}),r.addEventListener("request.error",t=>{t=t,t.error&&(e.logMessage({message:`${t.error.message} ${t.error.stack}`,severity:"Fatal",prefix:t.source==="request"?"PHP":"WASM Crash"}),e.dispatchEvent(new CustomEvent(e.fatalErrorEvent,{detail:{logs:e.getLogs(),source:t.source}})))})},D=(e,r)=>{e.logMessage({message:`${r.message} in ${r.filename} on line ${r.lineno}:${r.colno}`,severity:"Error"})},h=(e,r)=>{if(!(r!=null&&r.reason))return;const t=(r==null?void 0:r.reason.stack)??r.reason;e.logMessage({message:t,severity:"Error"})};let d=0;const C=e=>{navigator.serviceWorker.addEventListener("message",r=>{var t,s,o;((t=r.data)==null?void 0:t.numberOfOpenPlaygroundTabs)!==void 0&&d!==((s=r.data)==null?void 0:s.numberOfOpenPlaygroundTabs)&&(d=(o=r.data)==null?void 0:o.numberOfOpenPlaygroundTabs,e.debug(`Number of open Playground tabs is: ${d}`))})};let b=!1;const W=e=>{b||(C(e),!(typeof window>"u")&&(window.addEventListener("error",r=>D(e,r)),window.addEventListener("unhandledrejection",r=>h(e,r)),window.addEventListener("rejectionhandled",r=>h(e,r)),b=!0))},F=e=>{e.addEventListener("activate",()=>{e.clients.matchAll().then(r=>{const t={numberOfOpenPlaygroundTabs:r.filter(s=>s.frameType==="top-level").length};for(const s of r)s.postMessage(t)})})};exports.Logger=L;exports.addCrashListener=k;exports.collectPhpLogs=x;exports.collectWindowErrors=W;exports.formatLogEntry=T;exports.logEventType=E;exports.logger=M;exports.prepareLogMessage=l;exports.reportServiceWorkerMetrics=F;
|
package/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const
|
|
2
|
-
var
|
|
3
|
-
return typeof process < "u" && ((
|
|
1
|
+
const w = function() {
|
|
2
|
+
var e;
|
|
3
|
+
return typeof process < "u" && ((e = process.release) == null ? void 0 : e.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
typeof WorkerGlobalScope < "u" && // @ts-ignore
|
|
6
6
|
self instanceof WorkerGlobalScope ? "WORKER" : "NODE"
|
|
7
7
|
);
|
|
8
8
|
}();
|
|
9
|
-
if (
|
|
10
|
-
let
|
|
9
|
+
if (w === "NODE") {
|
|
10
|
+
let e = function(t) {
|
|
11
11
|
return new Promise(function(s, o) {
|
|
12
12
|
t.onload = t.onerror = function(n) {
|
|
13
13
|
t.onload = t.onerror = null, n.type === "load" ? s(t.result) : o(new Error("Failed to read the blob/file"));
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
|
-
},
|
|
16
|
+
}, r = function() {
|
|
17
17
|
const t = new Uint8Array([1, 2, 3, 4]), o = new File([t], "test").stream();
|
|
18
18
|
try {
|
|
19
19
|
return o.getReader({ mode: "byob" }), !0;
|
|
@@ -33,11 +33,11 @@ if (p === "NODE") {
|
|
|
33
33
|
}
|
|
34
34
|
typeof Blob.prototype.arrayBuffer > "u" && (Blob.prototype.arrayBuffer = function() {
|
|
35
35
|
const s = new FileReader();
|
|
36
|
-
return s.readAsArrayBuffer(this),
|
|
36
|
+
return s.readAsArrayBuffer(this), e(s);
|
|
37
37
|
}), typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
|
|
38
38
|
const s = new FileReader();
|
|
39
|
-
return s.readAsText(this),
|
|
40
|
-
}), (typeof Blob.prototype.stream > "u" || !
|
|
39
|
+
return s.readAsText(this), e(s);
|
|
40
|
+
}), (typeof Blob.prototype.stream > "u" || !r()) && (Blob.prototype.stream = function() {
|
|
41
41
|
let t = 0;
|
|
42
42
|
const s = this;
|
|
43
43
|
return new ReadableStream({
|
|
@@ -49,72 +49,79 @@ if (p === "NODE") {
|
|
|
49
49
|
const n = o.byobRequest.view, a = await s.slice(
|
|
50
50
|
t,
|
|
51
51
|
t + n.byteLength
|
|
52
|
-
).arrayBuffer(),
|
|
53
|
-
new Uint8Array(n.buffer).set(
|
|
54
|
-
const
|
|
55
|
-
o.byobRequest.respond(
|
|
52
|
+
).arrayBuffer(), u = new Uint8Array(a);
|
|
53
|
+
new Uint8Array(n.buffer).set(u);
|
|
54
|
+
const g = u.byteLength;
|
|
55
|
+
o.byobRequest.respond(g), t += g, t >= s.size && o.close();
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
if (
|
|
61
|
-
class
|
|
60
|
+
if (w === "NODE" && typeof CustomEvent > "u") {
|
|
61
|
+
class e extends Event {
|
|
62
62
|
constructor(t, s = {}) {
|
|
63
63
|
super(t, s), this.detail = s.detail;
|
|
64
64
|
}
|
|
65
65
|
initCustomEvent() {
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
globalThis.CustomEvent =
|
|
68
|
+
globalThis.CustomEvent = e;
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const v = "playground-log", m = (e, ...r) => {
|
|
71
|
+
B.dispatchEvent(
|
|
72
|
+
new CustomEvent(v, {
|
|
73
|
+
detail: {
|
|
74
|
+
log: e,
|
|
75
|
+
args: r
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
}, L = (e, ...r) => {
|
|
80
|
+
switch (typeof e.message == "string" ? e.message = l(e.message) : e.message.message && typeof e.message.message == "string" && (e.message.message = l(e.message.message)), e.severity) {
|
|
72
81
|
case "Debug":
|
|
73
|
-
console.debug(
|
|
82
|
+
console.debug(e.message, ...r);
|
|
74
83
|
break;
|
|
75
84
|
case "Info":
|
|
76
|
-
console.info(
|
|
85
|
+
console.info(e.message, ...r);
|
|
77
86
|
break;
|
|
78
87
|
case "Warn":
|
|
79
|
-
console.warn(
|
|
88
|
+
console.warn(e.message, ...r);
|
|
80
89
|
break;
|
|
81
90
|
case "Error":
|
|
82
|
-
console.error(
|
|
91
|
+
console.error(e.message, ...r);
|
|
83
92
|
break;
|
|
84
93
|
case "Fatal":
|
|
85
|
-
console.error(
|
|
94
|
+
console.error(e.message, ...r);
|
|
86
95
|
break;
|
|
87
96
|
default:
|
|
88
|
-
console.log(
|
|
97
|
+
console.log(e.message, ...r);
|
|
89
98
|
}
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (r.raw === !0)
|
|
97
|
-
u(r.message);
|
|
99
|
+
}, T = (e) => e instanceof Error ? [e.message, e.stack].join(`
|
|
100
|
+
`) : JSON.stringify(e, null, 2), E = [], p = (e) => {
|
|
101
|
+
E.push(e);
|
|
102
|
+
}, d = (e) => {
|
|
103
|
+
if (e.raw === !0)
|
|
104
|
+
p(e.message);
|
|
98
105
|
else {
|
|
99
|
-
const
|
|
100
|
-
typeof
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
const r = O(
|
|
107
|
+
typeof e.message == "object" ? T(e.message) : e.message,
|
|
108
|
+
e.severity ?? "Info",
|
|
109
|
+
e.prefix ?? "JavaScript"
|
|
103
110
|
);
|
|
104
|
-
|
|
111
|
+
p(r);
|
|
105
112
|
}
|
|
106
113
|
};
|
|
107
|
-
class
|
|
114
|
+
class M extends EventTarget {
|
|
108
115
|
// constructor
|
|
109
|
-
constructor(
|
|
110
|
-
super(), this.handlers =
|
|
116
|
+
constructor(r = []) {
|
|
117
|
+
super(), this.handlers = r, this.fatalErrorEvent = "playground-fatal-error";
|
|
111
118
|
}
|
|
112
119
|
/**
|
|
113
120
|
* Get all logs.
|
|
114
121
|
* @returns string[]
|
|
115
122
|
*/
|
|
116
123
|
getLogs() {
|
|
117
|
-
return this.handlers.includes(
|
|
124
|
+
return this.handlers.includes(d) ? [...E] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
118
125
|
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
119
126
|
`), []);
|
|
120
127
|
}
|
|
@@ -126,9 +133,9 @@ class v extends EventTarget {
|
|
|
126
133
|
* @param raw boolean
|
|
127
134
|
* @param args any
|
|
128
135
|
*/
|
|
129
|
-
logMessage(
|
|
136
|
+
logMessage(r, ...t) {
|
|
130
137
|
for (const s of this.handlers)
|
|
131
|
-
s(
|
|
138
|
+
s(r, ...t);
|
|
132
139
|
}
|
|
133
140
|
/**
|
|
134
141
|
* Log message
|
|
@@ -136,10 +143,10 @@ class v extends EventTarget {
|
|
|
136
143
|
* @param message any
|
|
137
144
|
* @param args any
|
|
138
145
|
*/
|
|
139
|
-
log(
|
|
146
|
+
log(r, ...t) {
|
|
140
147
|
this.logMessage(
|
|
141
148
|
{
|
|
142
|
-
message:
|
|
149
|
+
message: r,
|
|
143
150
|
severity: void 0,
|
|
144
151
|
prefix: "JavaScript",
|
|
145
152
|
raw: !1
|
|
@@ -153,10 +160,10 @@ class v extends EventTarget {
|
|
|
153
160
|
* @param message any
|
|
154
161
|
* @param args any
|
|
155
162
|
*/
|
|
156
|
-
debug(
|
|
163
|
+
debug(r, ...t) {
|
|
157
164
|
this.logMessage(
|
|
158
165
|
{
|
|
159
|
-
message:
|
|
166
|
+
message: r,
|
|
160
167
|
severity: "Debug",
|
|
161
168
|
prefix: "JavaScript",
|
|
162
169
|
raw: !1
|
|
@@ -170,10 +177,10 @@ class v extends EventTarget {
|
|
|
170
177
|
* @param message any
|
|
171
178
|
* @param args any
|
|
172
179
|
*/
|
|
173
|
-
info(
|
|
180
|
+
info(r, ...t) {
|
|
174
181
|
this.logMessage(
|
|
175
182
|
{
|
|
176
|
-
message:
|
|
183
|
+
message: r,
|
|
177
184
|
severity: "Info",
|
|
178
185
|
prefix: "JavaScript",
|
|
179
186
|
raw: !1
|
|
@@ -187,10 +194,10 @@ class v extends EventTarget {
|
|
|
187
194
|
* @param message any
|
|
188
195
|
* @param args any
|
|
189
196
|
*/
|
|
190
|
-
warn(
|
|
197
|
+
warn(r, ...t) {
|
|
191
198
|
this.logMessage(
|
|
192
199
|
{
|
|
193
|
-
message:
|
|
200
|
+
message: r,
|
|
194
201
|
severity: "Warn",
|
|
195
202
|
prefix: "JavaScript",
|
|
196
203
|
raw: !1
|
|
@@ -204,10 +211,10 @@ class v extends EventTarget {
|
|
|
204
211
|
* @param message any
|
|
205
212
|
* @param args any
|
|
206
213
|
*/
|
|
207
|
-
error(
|
|
214
|
+
error(r, ...t) {
|
|
208
215
|
this.logMessage(
|
|
209
216
|
{
|
|
210
|
-
message:
|
|
217
|
+
message: r,
|
|
211
218
|
severity: "Error",
|
|
212
219
|
prefix: "JavaScript",
|
|
213
220
|
raw: !1
|
|
@@ -216,7 +223,14 @@ class v extends EventTarget {
|
|
|
216
223
|
);
|
|
217
224
|
}
|
|
218
225
|
}
|
|
219
|
-
const
|
|
226
|
+
const x = () => {
|
|
227
|
+
try {
|
|
228
|
+
if (process.env.NODE_ENV === "test")
|
|
229
|
+
return [d, m];
|
|
230
|
+
} catch {
|
|
231
|
+
}
|
|
232
|
+
return [d, L, m];
|
|
233
|
+
}, B = new M(x()), l = (e) => e.replace(/\t/g, ""), O = (e, r, t) => {
|
|
220
234
|
const s = /* @__PURE__ */ new Date(), o = new Intl.DateTimeFormat("en-GB", {
|
|
221
235
|
year: "numeric",
|
|
222
236
|
month: "short",
|
|
@@ -229,91 +243,93 @@ const B = new v([b, w]), L = (r, e, t) => {
|
|
|
229
243
|
hour12: !1,
|
|
230
244
|
timeZone: "UTC",
|
|
231
245
|
timeZoneName: "short"
|
|
232
|
-
}).format(s);
|
|
233
|
-
return `[${
|
|
234
|
-
},
|
|
235
|
-
|
|
246
|
+
}).format(s), i = o + " " + n;
|
|
247
|
+
return e = l(e), `[${i}] ${t} ${r}: ${e}`;
|
|
248
|
+
}, S = (e, r) => {
|
|
249
|
+
e.addEventListener(e.fatalErrorEvent, r);
|
|
236
250
|
};
|
|
237
|
-
let
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
const t = await
|
|
241
|
-
if (t.length >
|
|
242
|
-
const s = t.substring(
|
|
243
|
-
|
|
251
|
+
let f = 0;
|
|
252
|
+
const y = "/wordpress/wp-content/debug.log", k = async (e) => await e.fileExists(y) ? await e.readFileAsText(y) : "", C = (e, r) => {
|
|
253
|
+
r.addEventListener("request.end", async () => {
|
|
254
|
+
const t = await k(r);
|
|
255
|
+
if (t.length > f) {
|
|
256
|
+
const s = t.substring(f);
|
|
257
|
+
e.logMessage({
|
|
244
258
|
message: s,
|
|
245
259
|
raw: !0
|
|
246
|
-
}),
|
|
260
|
+
}), f = t.length;
|
|
247
261
|
}
|
|
248
|
-
}),
|
|
249
|
-
t = t, t.error && (
|
|
262
|
+
}), r.addEventListener("request.error", (t) => {
|
|
263
|
+
t = t, t.error && (e.logMessage({
|
|
250
264
|
message: `${t.error.message} ${t.error.stack}`,
|
|
251
265
|
severity: "Fatal",
|
|
252
266
|
prefix: t.source === "request" ? "PHP" : "WASM Crash"
|
|
253
|
-
}),
|
|
254
|
-
new CustomEvent(
|
|
267
|
+
}), e.dispatchEvent(
|
|
268
|
+
new CustomEvent(e.fatalErrorEvent, {
|
|
255
269
|
detail: {
|
|
256
|
-
logs:
|
|
270
|
+
logs: e.getLogs(),
|
|
257
271
|
source: t.source
|
|
258
272
|
}
|
|
259
273
|
})
|
|
260
274
|
));
|
|
261
275
|
});
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
message: `${
|
|
276
|
+
}, P = (e, r) => {
|
|
277
|
+
e.logMessage({
|
|
278
|
+
message: `${r.message} in ${r.filename} on line ${r.lineno}:${r.colno}`,
|
|
265
279
|
severity: "Error"
|
|
266
280
|
});
|
|
267
|
-
},
|
|
268
|
-
if (!(
|
|
281
|
+
}, h = (e, r) => {
|
|
282
|
+
if (!(r != null && r.reason))
|
|
269
283
|
return;
|
|
270
|
-
const t = (
|
|
271
|
-
|
|
284
|
+
const t = (r == null ? void 0 : r.reason.stack) ?? r.reason;
|
|
285
|
+
e.logMessage({
|
|
272
286
|
message: t,
|
|
273
287
|
severity: "Error"
|
|
274
288
|
});
|
|
275
289
|
};
|
|
276
|
-
let
|
|
277
|
-
const
|
|
278
|
-
navigator.serviceWorker.addEventListener("message", (
|
|
290
|
+
let c = 0;
|
|
291
|
+
const D = (e) => {
|
|
292
|
+
navigator.serviceWorker.addEventListener("message", (r) => {
|
|
279
293
|
var t, s, o;
|
|
280
|
-
((t =
|
|
281
|
-
`Number of open Playground tabs is: ${
|
|
294
|
+
((t = r.data) == null ? void 0 : t.numberOfOpenPlaygroundTabs) !== void 0 && c !== ((s = r.data) == null ? void 0 : s.numberOfOpenPlaygroundTabs) && (c = (o = r.data) == null ? void 0 : o.numberOfOpenPlaygroundTabs, e.debug(
|
|
295
|
+
`Number of open Playground tabs is: ${c}`
|
|
282
296
|
));
|
|
283
297
|
});
|
|
284
298
|
};
|
|
285
|
-
let
|
|
286
|
-
const
|
|
287
|
-
|
|
299
|
+
let b = !1;
|
|
300
|
+
const F = (e) => {
|
|
301
|
+
b || (D(e), !(typeof window > "u") && (window.addEventListener(
|
|
288
302
|
"error",
|
|
289
|
-
(
|
|
303
|
+
(r) => P(e, r)
|
|
290
304
|
), window.addEventListener(
|
|
291
305
|
"unhandledrejection",
|
|
292
|
-
(
|
|
306
|
+
(r) => h(e, r)
|
|
293
307
|
), window.addEventListener(
|
|
294
308
|
"rejectionhandled",
|
|
295
|
-
(
|
|
296
|
-
),
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
|
|
309
|
+
(r) => h(e, r)
|
|
310
|
+
), b = !0));
|
|
311
|
+
}, R = (e) => {
|
|
312
|
+
e.addEventListener("activate", () => {
|
|
313
|
+
e.clients.matchAll().then((r) => {
|
|
300
314
|
const t = {
|
|
301
|
-
numberOfOpenPlaygroundTabs:
|
|
315
|
+
numberOfOpenPlaygroundTabs: r.filter(
|
|
302
316
|
// Only count top-level frames to get the number of tabs.
|
|
303
317
|
(s) => s.frameType === "top-level"
|
|
304
318
|
).length
|
|
305
319
|
};
|
|
306
|
-
for (const s of
|
|
320
|
+
for (const s of r)
|
|
307
321
|
s.postMessage(t);
|
|
308
322
|
});
|
|
309
323
|
});
|
|
310
324
|
};
|
|
311
325
|
export {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
326
|
+
M as Logger,
|
|
327
|
+
S as addCrashListener,
|
|
328
|
+
C as collectPhpLogs,
|
|
329
|
+
F as collectWindowErrors,
|
|
330
|
+
O as formatLogEntry,
|
|
331
|
+
v as logEventType,
|
|
317
332
|
B as logger,
|
|
318
|
-
|
|
333
|
+
l as prepareLogMessage,
|
|
334
|
+
R as reportServiceWorkerMetrics
|
|
319
335
|
};
|
package/lib/logger.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { logEventType } from './handlers/log-event';
|
|
1
2
|
export type Log = {
|
|
2
3
|
message: any;
|
|
3
4
|
severity?: LogSeverity;
|
|
@@ -73,6 +74,7 @@ export declare class Logger extends EventTarget {
|
|
|
73
74
|
* The logger instance.
|
|
74
75
|
*/
|
|
75
76
|
export declare const logger: Logger;
|
|
77
|
+
export declare const prepareLogMessage: (message: string) => string;
|
|
76
78
|
export declare const formatLogEntry: (message: string, severity: LogSeverity, prefix: string) => string;
|
|
77
79
|
/**
|
|
78
80
|
* Add a listener for the Playground crashes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/logger",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "A logger for PHP-wasm clients like Playground and WP-now.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"node": ">=18.18.0",
|
|
28
28
|
"npm": ">=8.11.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "40dca15bf2d5c21c2ee57a878940cb6f7f7851f0"
|
|
31
31
|
}
|