@php-wasm/progress
Advanced tools
Comparing version 0.1.34 to 0.1.35
23
index.js
@@ -35,3 +35,3 @@ class f extends EventTarget { | ||
new URL(i.url).origin.length + 1 | ||
), n = u( | ||
), n = c( | ||
i, | ||
@@ -84,3 +84,3 @@ ({ detail: { loaded: a, total: l } }) => this.#i(r, a, l) | ||
} | ||
function u(o, e) { | ||
function c(o, e) { | ||
const t = o.headers.get("content-length") || "", s = parseInt(t, 10) || 5242880; | ||
@@ -163,3 +163,3 @@ function i(r, n) { | ||
const d = 1e-5; | ||
class c extends EventTarget { | ||
class u extends EventTarget { | ||
constructor({ | ||
@@ -170,3 +170,3 @@ weight: e = 1, | ||
} = {}) { | ||
super(), this._selfWeight = 1, this._selfProgress = 0, this._selfCaption = "", this._isFilling = !1, this._subTrackers = [], this._weight = e, this._selfCaption = t, this._fillTime = s; | ||
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 = s; | ||
} | ||
@@ -214,3 +214,3 @@ /** | ||
this._selfWeight -= e; | ||
const s = new c({ | ||
const s = new u({ | ||
caption: t, | ||
@@ -255,3 +255,3 @@ weight: e, | ||
finish() { | ||
this._fillInterval && clearInterval(this._fillInterval), this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone(); | ||
this._fillInterval && clearInterval(this._fillInterval), this._selfDone = !0, this._selfProgress = 100, this._isFilling = !1, this._fillInterval = void 0, this.notifyProgress(), this.notifyDone(); | ||
} | ||
@@ -274,2 +274,4 @@ get caption() { | ||
get progress() { | ||
if (this._selfDone) | ||
return 100; | ||
const e = this._subTrackers.reduce( | ||
@@ -295,3 +297,6 @@ (t, s) => t + s.progress * s.weight, | ||
pipe(e) { | ||
this.addEventListener("progress", (t) => { | ||
e.setProgress({ | ||
progress: this.progress, | ||
caption: this.caption | ||
}), this.addEventListener("progress", (t) => { | ||
e.setProgress({ | ||
@@ -333,4 +338,4 @@ progress: t.detail.progress, | ||
p as ProgressObserver, | ||
c as ProgressTracker, | ||
u as cloneResponseMonitorProgress | ||
u as ProgressTracker, | ||
c as cloneResponseMonitorProgress | ||
}; |
@@ -88,2 +88,3 @@ /** | ||
private _selfWeight; | ||
private _selfDone; | ||
private _selfProgress; | ||
@@ -90,0 +91,0 @@ private _selfCaption; |
{ | ||
"name": "@php-wasm/progress", | ||
"version": "0.1.34", | ||
"version": "0.1.35", | ||
"description": "PHP.wasm – loading progress monitoring", | ||
@@ -32,4 +32,4 @@ "repository": { | ||
"types": "index.d.ts", | ||
"gitHead": "8c0a6a74f00bbf4bead78d49845dcdd79b02edd6", | ||
"gitHead": "0962f89a2b1a438997960a25c26f5341db063a3e", | ||
"dependencies": {} | ||
} |
Sorry, the diff of this file is not supported yet
24655
604