@php-wasm/progress 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 +76 -62
- package/package.json +4 -4
package/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var E=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var a=(s,e,t)=>(E(s,e,"read from private field"),t?t.call(s):e.get(s)),u=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},y=(s,e,t,r)=>(E(s,e,"write to private field"),r?r.call(s,t):e.set(s,t),t);var w=(s,e,t,r)=>({set _(n){y(s,e,n,t)},get _(){return a(s,e,r)}}),v=(s,e,t)=>(E(s,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=function(){var s;return typeof process<"u"&&((s=process.release)==null?void 0:s.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(x==="NODE"){let s=function(t){return new Promise(function(r,n){t.onload=t.onerror=function(i){t.onload=t.onerror=null,i.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,i,l){super(n);let o;l!=null&&l.lastModified&&(o=new Date),(!o||isNaN(o.getFullYear()))&&(o=new Date),this.lastModifiedDate=o,this.lastModified=o.getMilliseconds(),this.name=i||""}}global.File=t}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const r=new FileReader;return r.readAsArrayBuffer(this),s(r)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const r=new FileReader;return r.readAsText(this),s(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 i=n.byobRequest.view,o=await r.slice(t,t+i.byteLength).arrayBuffer(),d=new Uint8Array(o);new Uint8Array(i.buffer).set(d);const g=d.byteLength;n.byobRequest.respond(g),t+=g,t>=r.size&&n.close()}})})}if(x==="NODE"&&typeof CustomEvent>"u"){class s extends Event{constructor(t,r={}){super(t,r),this.detail=r.detail}initCustomEvent(){}}globalThis.CustomEvent=s}const S="playground-log",M=(s,...e)=>{D.dispatchEvent(new CustomEvent(S,{detail:{log:s,args:e}}))},F=(s,...e)=>{switch(typeof s.message=="string"?s.message=L(s.message):s.message.message&&typeof s.message.message=="string"&&(s.message.message=L(s.message.message)),s.severity){case"Debug":console.debug(s.message,...e);break;case"Info":console.info(s.message,...e);break;case"Warn":console.warn(s.message,...e);break;case"Error":console.error(s.message,...e);break;case"Fatal":console.error(s.message,...e);break;default:console.log(s.message,...e)}},N=s=>s instanceof Error?[s.message,s.stack].join(`
|
|
2
|
+
`):JSON.stringify(s,null,2),C=[],R=s=>{C.push(s)},T=s=>{if(s.raw===!0)R(s.message);else{const e=J(typeof s.message=="object"?N(s.message):s.message,s.severity??"Info",s.prefix??"JavaScript");R(e)}};class A extends EventTarget{constructor(e=[]){super(),this.handlers=e,this.fatalErrorEvent="playground-fatal-error"}getLogs(){return this.handlers.includes(T)?[...C]:(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(e,...t){for(const r of this.handlers)r(e,...t)}log(e,...t){this.logMessage({message:e,severity:void 0,prefix:"JavaScript",raw:!1},...t)}debug(e,...t){this.logMessage({message:e,severity:"Debug",prefix:"JavaScript",raw:!1},...t)}info(e,...t){this.logMessage({message:e,severity:"Info",prefix:"JavaScript",raw:!1},...t)}warn(e,...t){this.logMessage({message:e,severity:"Warn",prefix:"JavaScript",raw:!1},...t)}error(e,...t){this.logMessage({message:e,severity:"Error",prefix:"JavaScript",raw:!1},...t)}}const
|
|
4
|
+
`),[])}logMessage(e,...t){for(const r of this.handlers)r(e,...t)}log(e,...t){this.logMessage({message:e,severity:void 0,prefix:"JavaScript",raw:!1},...t)}debug(e,...t){this.logMessage({message:e,severity:"Debug",prefix:"JavaScript",raw:!1},...t)}info(e,...t){this.logMessage({message:e,severity:"Info",prefix:"JavaScript",raw:!1},...t)}warn(e,...t){this.logMessage({message:e,severity:"Warn",prefix:"JavaScript",raw:!1},...t)}error(e,...t){this.logMessage({message:e,severity:"Error",prefix:"JavaScript",raw:!1},...t)}}const W=()=>{try{if(process.env.NODE_ENV==="test")return[T,M]}catch{}return[T,F,M]},D=new A(W()),L=s=>s.replace(/\t/g,""),J=(s,e,t)=>{const r=new Date,n=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(r).replace(/ /g,"-"),i=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(r),l=n+" "+i;return s=L(s),`[${l}] ${t} ${e}: ${s}`},U=5*1024*1024;var f,c,b,O;class $ extends EventTarget{constructor(){super(...arguments);u(this,b);u(this,f,{});u(this,c,{})}expectAssets(t){for(const[r,n]of Object.entries(t)){const i="http://example.com/",o=new URL(r,i).pathname.split("/").pop();o in a(this,f)||(a(this,f)[o]=n),o in a(this,c)||(a(this,c)[o]=0)}}async monitorFetch(t){const r=await t;return B(r,i=>{v(this,b,O).call(this,r.url,i.detail.loaded,i.detail.total)})}}f=new WeakMap,c=new WeakMap,b=new WeakSet,O=function(t,r,n){const i=new URL(t,"http://example.com").pathname.split("/").pop();n?i in a(this,f)||(a(this,f)[i]=n,a(this,c)[i]=r):n=a(this,f)[i],i in a(this,c)||D.warn(`Registered a download #progress of an unregistered file "${i}". This may cause a sudden **decrease** in the #progress percentage as the total number of bytes increases during the download.`),a(this,c)[i]=r,this.dispatchEvent(new CustomEvent("progress",{detail:{loaded:k(a(this,c)),total:k(a(this,f))}}))};function k(s){return Object.values(s).reduce((e,t)=>e+t,0)}function B(s,e){const t=s.headers.get("content-length")||"",r=parseInt(t,10)||U;function n(i,l){e(new CustomEvent("progress",{detail:{loaded:i,total:l}}))}return new Response(new ReadableStream({async start(i){if(!s.body){i.close();return}const l=s.body.getReader();let o=0;for(;;)try{const{done:d,value:g}=await l.read();if(g&&(o+=g.byteLength),d){n(o,o),i.close();break}else n(o,r),i.enqueue(g)}catch(d){D.error({e:d}),i.error(d);break}}}),{status:s.status,statusText:s.statusText,headers:s.headers})}var h,p,m,P;class G extends EventTarget{constructor(){super(...arguments);u(this,m);u(this,h,void 0);u(this,p,void 0);y(this,h,{}),y(this,p,0),this.progress=0,this.mode="REAL_TIME",this.caption=""}partialObserver(t,r=""){const n=++w(this,p)._;return a(this,h)[n]=0,i=>{const{loaded:l,total:o}=(i==null?void 0:i.detail)||{};a(this,h)[n]=l/o*t,v(this,m,P).call(this,this.totalProgress,"REAL_TIME",r)}}slowlyIncrementBy(t){const r=++w(this,p)._;a(this,h)[r]=t,v(this,m,P).call(this,this.totalProgress,"SLOWLY_INCREMENT")}get totalProgress(){return Object.values(a(this,h)).reduce((t,r)=>t+r,0)}}h=new WeakMap,p=new WeakMap,m=new WeakSet,P=function(t,r,n){this.dispatchEvent(new CustomEvent("progress",{detail:{progress:t,mode:r,caption:n}}))};const _=1e-5;class I extends EventTarget{constructor({weight:e=1,caption:t="",fillTime:r=4}={}){super(),this._selfWeight=1,this._selfDone=!1,this._selfProgress=0,this._selfCaption="",this._isFilling=!1,this._subTrackers=[],this._weight=e,this._selfCaption=t,this._fillTime=r}stage(e,t=""){if(e||(e=this._selfWeight),this._selfWeight-e<-_)throw new Error(`Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`);this._selfWeight-=e;const r=new I({caption:t,weight:e,fillTime:this._fillTime});return this._subTrackers.push(r),r.addEventListener("progress",()=>this.notifyProgress()),r.addEventListener("done",()=>{this.done&&this.notifyDone()}),r}fillSlowly({stopBeforeFinishing:e=!0}={}){if(this._isFilling)return;this._isFilling=!0;const t=100,r=this._fillTime/t;this._fillInterval=setInterval(()=>{this.set(this._selfProgress+1),e&&this._selfProgress>=99&&clearInterval(this._fillInterval)},r)}set(e){this._selfProgress=Math.min(e,100),this.notifyProgress(),this._selfProgress+_>=100&&this.finish()}finish(){this._fillInterval&&clearInterval(this._fillInterval),this._selfDone=!0,this._selfProgress=100,this._isFilling=!1,this._fillInterval=void 0,this.notifyProgress(),this.notifyDone()}get caption(){for(let e=this._subTrackers.length-1;e>=0;e--)if(!this._subTrackers[e].done){const t=this._subTrackers[e].caption;if(t)return t}return this._selfCaption}setCaption(e){this._selfCaption=e,this.notifyProgress()}get done(){return this.progress+_>=100}get progress(){if(this._selfDone)return 100;const e=this._subTrackers.reduce((t,r)=>t+r.progress*r.weight,this._selfProgress*this._selfWeight);return Math.round(e*1e4)/1e4}get weight(){return this._weight}get observer(){return this._progressObserver||(this._progressObserver=e=>{this.set(e)}),this._progressObserver}get loadingListener(){return this._loadingListener||(this._loadingListener=e=>{this.set(e.detail.loaded/e.detail.total*100)}),this._loadingListener}pipe(e){e.setProgress({progress:this.progress,caption:this.caption}),this.addEventListener("progress",t=>{e.setProgress({progress:t.detail.progress,caption:t.detail.caption})}),this.addEventListener("done",()=>{e.setLoaded()})}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}notifyProgress(){const e=this;this.dispatchEvent(new CustomEvent("progress",{detail:{get progress(){return e.progress},get caption(){return e.caption}}}))}notifyDone(){this.dispatchEvent(new CustomEvent("done"))}}exports.EmscriptenDownloadMonitor=$;exports.ProgressObserver=G;exports.ProgressTracker=I;exports.cloneResponseMonitorProgress=B;
|
package/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
1
|
+
var E = (s, e, t) => {
|
|
2
2
|
if (!e.has(s))
|
|
3
3
|
throw TypeError("Cannot " + t);
|
|
4
4
|
};
|
|
5
|
-
var a = (s, e, t) => (
|
|
5
|
+
var a = (s, e, t) => (E(s, e, "read from private field"), t ? t.call(s) : e.get(s)), u = (s, e, t) => {
|
|
6
6
|
if (e.has(s))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
8
|
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
9
|
-
}, y = (s, e, t, r) => (
|
|
10
|
-
var
|
|
9
|
+
}, y = (s, e, t, r) => (E(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
10
|
+
var w = (s, e, t, r) => ({
|
|
11
11
|
set _(n) {
|
|
12
12
|
y(s, e, n, t);
|
|
13
13
|
},
|
|
14
14
|
get _() {
|
|
15
15
|
return a(s, e, r);
|
|
16
16
|
}
|
|
17
|
-
}),
|
|
18
|
-
const
|
|
17
|
+
}), v = (s, e, t) => (E(s, e, "access private method"), t);
|
|
18
|
+
const R = function() {
|
|
19
19
|
var s;
|
|
20
20
|
return typeof process < "u" && ((s = process.release) == null ? void 0 : s.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
|
|
21
21
|
// @ts-ignore
|
|
@@ -23,7 +23,7 @@ const x = function() {
|
|
|
23
23
|
self instanceof WorkerGlobalScope ? "WORKER" : "NODE"
|
|
24
24
|
);
|
|
25
25
|
}();
|
|
26
|
-
if (
|
|
26
|
+
if (R === "NODE") {
|
|
27
27
|
let s = function(t) {
|
|
28
28
|
return new Promise(function(r, n) {
|
|
29
29
|
t.onload = t.onerror = function(i) {
|
|
@@ -66,15 +66,15 @@ if (x === "NODE") {
|
|
|
66
66
|
const i = n.byobRequest.view, o = await r.slice(
|
|
67
67
|
t,
|
|
68
68
|
t + i.byteLength
|
|
69
|
-
).arrayBuffer(),
|
|
70
|
-
new Uint8Array(i.buffer).set(
|
|
71
|
-
const g =
|
|
69
|
+
).arrayBuffer(), d = new Uint8Array(o);
|
|
70
|
+
new Uint8Array(i.buffer).set(d);
|
|
71
|
+
const g = d.byteLength;
|
|
72
72
|
n.byobRequest.respond(g), t += g, t >= r.size && n.close();
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
77
|
+
if (R === "NODE" && typeof CustomEvent > "u") {
|
|
78
78
|
class s extends Event {
|
|
79
79
|
constructor(t, r = {}) {
|
|
80
80
|
super(t, r), this.detail = r.detail;
|
|
@@ -84,8 +84,17 @@ if (x === "NODE" && typeof CustomEvent > "u") {
|
|
|
84
84
|
}
|
|
85
85
|
globalThis.CustomEvent = s;
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const O = "playground-log", I = (s, ...e) => {
|
|
88
|
+
x.dispatchEvent(
|
|
89
|
+
new CustomEvent(O, {
|
|
90
|
+
detail: {
|
|
91
|
+
log: s,
|
|
92
|
+
args: e
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}, F = (s, ...e) => {
|
|
97
|
+
switch (typeof s.message == "string" ? s.message = T(s.message) : s.message.message && typeof s.message.message == "string" && (s.message.message = T(s.message.message)), s.severity) {
|
|
89
98
|
case "Debug":
|
|
90
99
|
console.debug(s.message, ...e);
|
|
91
100
|
break;
|
|
@@ -104,24 +113,22 @@ const B = (s, ...e) => {
|
|
|
104
113
|
default:
|
|
105
114
|
console.log(s.message, ...e);
|
|
106
115
|
}
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
I.push(s);
|
|
112
|
-
}, M = (s) => {
|
|
116
|
+
}, S = (s) => s instanceof Error ? [s.message, s.stack].join(`
|
|
117
|
+
`) : JSON.stringify(s, null, 2), k = [], C = (s) => {
|
|
118
|
+
k.push(s);
|
|
119
|
+
}, L = (s) => {
|
|
113
120
|
if (s.raw === !0)
|
|
114
|
-
|
|
121
|
+
C(s.message);
|
|
115
122
|
else {
|
|
116
|
-
const e =
|
|
117
|
-
typeof s.message == "object" ?
|
|
123
|
+
const e = W(
|
|
124
|
+
typeof s.message == "object" ? S(s.message) : s.message,
|
|
118
125
|
s.severity ?? "Info",
|
|
119
126
|
s.prefix ?? "JavaScript"
|
|
120
127
|
);
|
|
121
|
-
|
|
128
|
+
C(e);
|
|
122
129
|
}
|
|
123
130
|
};
|
|
124
|
-
class
|
|
131
|
+
class N extends EventTarget {
|
|
125
132
|
// constructor
|
|
126
133
|
constructor(e = []) {
|
|
127
134
|
super(), this.handlers = e, this.fatalErrorEvent = "playground-fatal-error";
|
|
@@ -131,7 +138,7 @@ class O extends EventTarget {
|
|
|
131
138
|
* @returns string[]
|
|
132
139
|
*/
|
|
133
140
|
getLogs() {
|
|
134
|
-
return this.handlers.includes(
|
|
141
|
+
return this.handlers.includes(L) ? [...k] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
135
142
|
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
136
143
|
`), []);
|
|
137
144
|
}
|
|
@@ -233,7 +240,14 @@ class O extends EventTarget {
|
|
|
233
240
|
);
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
|
-
const
|
|
243
|
+
const A = () => {
|
|
244
|
+
try {
|
|
245
|
+
if (process.env.NODE_ENV === "test")
|
|
246
|
+
return [L, I];
|
|
247
|
+
} catch {
|
|
248
|
+
}
|
|
249
|
+
return [L, F, I];
|
|
250
|
+
}, x = new N(A()), T = (s) => s.replace(/\t/g, ""), W = (s, e, t) => {
|
|
237
251
|
const r = /* @__PURE__ */ new Date(), n = new Intl.DateTimeFormat("en-GB", {
|
|
238
252
|
year: "numeric",
|
|
239
253
|
month: "short",
|
|
@@ -246,11 +260,11 @@ const R = new O([M, B]), S = (s, e, t) => {
|
|
|
246
260
|
hour12: !1,
|
|
247
261
|
timeZone: "UTC",
|
|
248
262
|
timeZoneName: "short"
|
|
249
|
-
}).format(r);
|
|
250
|
-
return `[${
|
|
251
|
-
},
|
|
252
|
-
var f, h,
|
|
253
|
-
class
|
|
263
|
+
}).format(r), l = n + " " + i;
|
|
264
|
+
return s = T(s), `[${l}] ${t} ${e}: ${s}`;
|
|
265
|
+
}, J = 5 * 1024 * 1024;
|
|
266
|
+
var f, h, b, B;
|
|
267
|
+
class G extends EventTarget {
|
|
254
268
|
constructor() {
|
|
255
269
|
super(...arguments);
|
|
256
270
|
/**
|
|
@@ -260,7 +274,7 @@ class W extends EventTarget {
|
|
|
260
274
|
* @param loaded The number of bytes of that file loaded so far.
|
|
261
275
|
* @param fileSize The total number of bytes in the loaded file.
|
|
262
276
|
*/
|
|
263
|
-
u(this,
|
|
277
|
+
u(this, b);
|
|
264
278
|
u(this, f, {});
|
|
265
279
|
u(this, h, {});
|
|
266
280
|
}
|
|
@@ -272,29 +286,29 @@ class W extends EventTarget {
|
|
|
272
286
|
}
|
|
273
287
|
async monitorFetch(t) {
|
|
274
288
|
const r = await t;
|
|
275
|
-
return
|
|
276
|
-
|
|
289
|
+
return U(r, (i) => {
|
|
290
|
+
v(this, b, B).call(this, r.url, i.detail.loaded, i.detail.total);
|
|
277
291
|
});
|
|
278
292
|
}
|
|
279
293
|
}
|
|
280
|
-
f = new WeakMap(), h = new WeakMap(),
|
|
294
|
+
f = new WeakMap(), h = new WeakMap(), b = new WeakSet(), B = function(t, r, n) {
|
|
281
295
|
const i = new URL(t, "http://example.com").pathname.split("/").pop();
|
|
282
|
-
n ? i in a(this, f) || (a(this, f)[i] = n, a(this, h)[i] = r) : n = a(this, f)[i], i in a(this, h) ||
|
|
296
|
+
n ? i in a(this, f) || (a(this, f)[i] = n, a(this, h)[i] = r) : n = a(this, f)[i], i in a(this, h) || x.warn(
|
|
283
297
|
`Registered a download #progress of an unregistered file "${i}". This may cause a sudden **decrease** in the #progress percentage as the total number of bytes increases during the download.`
|
|
284
298
|
), a(this, h)[i] = r, this.dispatchEvent(
|
|
285
299
|
new CustomEvent("progress", {
|
|
286
300
|
detail: {
|
|
287
|
-
loaded:
|
|
288
|
-
total:
|
|
301
|
+
loaded: D(a(this, h)),
|
|
302
|
+
total: D(a(this, f))
|
|
289
303
|
}
|
|
290
304
|
})
|
|
291
305
|
);
|
|
292
306
|
};
|
|
293
|
-
function
|
|
307
|
+
function D(s) {
|
|
294
308
|
return Object.values(s).reduce((e, t) => e + t, 0);
|
|
295
309
|
}
|
|
296
|
-
function
|
|
297
|
-
const t = s.headers.get("content-length") || "", r = parseInt(t, 10) ||
|
|
310
|
+
function U(s, e) {
|
|
311
|
+
const t = s.headers.get("content-length") || "", r = parseInt(t, 10) || J;
|
|
298
312
|
function n(i, l) {
|
|
299
313
|
e(
|
|
300
314
|
new CustomEvent("progress", {
|
|
@@ -316,14 +330,14 @@ function A(s, e) {
|
|
|
316
330
|
let o = 0;
|
|
317
331
|
for (; ; )
|
|
318
332
|
try {
|
|
319
|
-
const { done:
|
|
320
|
-
if (g && (o += g.byteLength),
|
|
333
|
+
const { done: d, value: g } = await l.read();
|
|
334
|
+
if (g && (o += g.byteLength), d) {
|
|
321
335
|
n(o, o), i.close();
|
|
322
336
|
break;
|
|
323
337
|
} else
|
|
324
338
|
n(o, r), i.enqueue(g);
|
|
325
|
-
} catch (
|
|
326
|
-
|
|
339
|
+
} catch (d) {
|
|
340
|
+
x.error({ e: d }), i.error(d);
|
|
327
341
|
break;
|
|
328
342
|
}
|
|
329
343
|
}
|
|
@@ -335,34 +349,34 @@ function A(s, e) {
|
|
|
335
349
|
}
|
|
336
350
|
);
|
|
337
351
|
}
|
|
338
|
-
var
|
|
339
|
-
class
|
|
352
|
+
var c, p, m, P;
|
|
353
|
+
class Z extends EventTarget {
|
|
340
354
|
constructor() {
|
|
341
355
|
super(...arguments);
|
|
342
356
|
u(this, m);
|
|
343
|
-
u(this,
|
|
357
|
+
u(this, c, void 0);
|
|
344
358
|
u(this, p, void 0);
|
|
345
|
-
y(this,
|
|
359
|
+
y(this, c, {}), y(this, p, 0), this.progress = 0, this.mode = "REAL_TIME", this.caption = "";
|
|
346
360
|
}
|
|
347
361
|
partialObserver(t, r = "") {
|
|
348
|
-
const n = ++
|
|
349
|
-
return a(this,
|
|
362
|
+
const n = ++w(this, p)._;
|
|
363
|
+
return a(this, c)[n] = 0, (i) => {
|
|
350
364
|
const { loaded: l, total: o } = (i == null ? void 0 : i.detail) || {};
|
|
351
|
-
a(this,
|
|
365
|
+
a(this, c)[n] = l / o * t, v(this, m, P).call(this, this.totalProgress, "REAL_TIME", r);
|
|
352
366
|
};
|
|
353
367
|
}
|
|
354
368
|
slowlyIncrementBy(t) {
|
|
355
|
-
const r = ++
|
|
356
|
-
a(this,
|
|
369
|
+
const r = ++w(this, p)._;
|
|
370
|
+
a(this, c)[r] = t, v(this, m, P).call(this, this.totalProgress, "SLOWLY_INCREMENT");
|
|
357
371
|
}
|
|
358
372
|
get totalProgress() {
|
|
359
|
-
return Object.values(a(this,
|
|
373
|
+
return Object.values(a(this, c)).reduce(
|
|
360
374
|
(t, r) => t + r,
|
|
361
375
|
0
|
|
362
376
|
);
|
|
363
377
|
}
|
|
364
378
|
}
|
|
365
|
-
|
|
379
|
+
c = new WeakMap(), p = new WeakMap(), m = new WeakSet(), P = function(t, r, n) {
|
|
366
380
|
this.dispatchEvent(
|
|
367
381
|
new CustomEvent("progress", {
|
|
368
382
|
detail: {
|
|
@@ -374,7 +388,7 @@ d = new WeakMap(), p = new WeakMap(), m = new WeakSet(), L = function(t, r, n) {
|
|
|
374
388
|
);
|
|
375
389
|
};
|
|
376
390
|
const _ = 1e-5;
|
|
377
|
-
class
|
|
391
|
+
class M extends EventTarget {
|
|
378
392
|
constructor({
|
|
379
393
|
weight: e = 1,
|
|
380
394
|
caption: t = "",
|
|
@@ -423,7 +437,7 @@ class k extends EventTarget {
|
|
|
423
437
|
`Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`
|
|
424
438
|
);
|
|
425
439
|
this._selfWeight -= e;
|
|
426
|
-
const r = new
|
|
440
|
+
const r = new M({
|
|
427
441
|
caption: t,
|
|
428
442
|
weight: e,
|
|
429
443
|
fillTime: this._fillTime
|
|
@@ -541,8 +555,8 @@ class k extends EventTarget {
|
|
|
541
555
|
}
|
|
542
556
|
}
|
|
543
557
|
export {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
558
|
+
G as EmscriptenDownloadMonitor,
|
|
559
|
+
Z as ProgressObserver,
|
|
560
|
+
M as ProgressTracker,
|
|
561
|
+
U as cloneResponseMonitorProgress
|
|
548
562
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/progress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "PHP.wasm – loading progress monitoring",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "index.js",
|
|
31
31
|
"types": "index.d.ts",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "40dca15bf2d5c21c2ee57a878940cb6f7f7851f0",
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18.18.0",
|
|
35
35
|
"npm": ">=8.11.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@php-wasm/node-polyfills": "0.
|
|
39
|
-
"@php-wasm/logger": "0.
|
|
38
|
+
"@php-wasm/node-polyfills": "0.9.2",
|
|
39
|
+
"@php-wasm/logger": "0.9.2"
|
|
40
40
|
}
|
|
41
41
|
}
|