New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@php-wasm/progress

Package Overview
Dependencies
Maintainers
3
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@php-wasm/progress - npm Package Compare versions

Comparing version 0.5.6 to 0.6.0

260

index.js

@@ -1,32 +0,32 @@

var L = (r, e, t) => {
if (!e.has(r))
var w = (s, e, t) => {
if (!e.has(s))
throw TypeError("Cannot " + t);
};
var l = (r, e, t) => (L(r, e, "read from private field"), t ? t.call(r) : e.get(r)), d = (r, e, t) => {
if (e.has(r))
var a = (s, e, t) => (w(s, e, "read from private field"), t ? t.call(s) : e.get(s)), h = (s, e, t) => {
if (e.has(s))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(r) : e.set(r, t);
}, y = (r, e, t, s) => (L(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t);
var P = (r, e, t, s) => ({
e instanceof WeakSet ? e.add(s) : e.set(s, t);
}, _ = (s, e, t, i) => (w(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t);
var E = (s, e, t, i) => ({
set _(n) {
y(r, e, n, t);
_(s, e, n, t);
},
get _() {
return l(r, e, s);
return a(s, e, i);
}
}), u = (r, e, t) => (L(r, e, "access private method"), t);
}), g = (s, e, t) => (w(s, e, "access private method"), t);
if (typeof File > "u") {
class r extends Blob {
constructor(t, s, n) {
class s extends Blob {
constructor(t, i, n) {
super(t);
let i;
n != null && n.lastModified && (i = /* @__PURE__ */ new Date()), (!i || isNaN(i.getFullYear())) && (i = /* @__PURE__ */ new Date()), this.lastModifiedDate = i, this.lastModified = i.getMilliseconds(), this.name = s || "";
let r;
n != null && n.lastModified && (r = /* @__PURE__ */ new Date()), (!r || isNaN(r.getFullYear())) && (r = /* @__PURE__ */ new Date()), this.lastModifiedDate = r, this.lastModified = r.getMilliseconds(), this.name = i || "";
}
}
global.File = r;
global.File = s;
}
function F(r) {
function B(s) {
return new Promise(function(e, t) {
r.onload = r.onerror = function(s) {
r.onload = r.onerror = null, s.type === "load" ? e(r.result) : t(new Error("Failed to read the blob/file"));
s.onload = s.onerror = function(i) {
s.onload = s.onerror = null, i.type === "load" ? e(s.result) : t(new Error("Failed to read the blob/file"));
};

@@ -37,10 +37,10 @@ });

const e = new FileReader();
return e.readAsArrayBuffer(this), F(e);
return e.readAsArrayBuffer(this), B(e);
});
typeof Blob.prototype.text > "u" && (Blob.prototype.text = function() {
const e = new FileReader();
return e.readAsText(this), F(e);
return e.readAsText(this), B(e);
});
function A() {
const r = new Uint8Array([1, 2, 3, 4]), t = new File([r], "test").stream();
const s = new Uint8Array([1, 2, 3, 4]), t = new File([s], "test").stream();
try {

@@ -53,3 +53,3 @@ return t.getReader({ mode: "byob" }), !0;

(typeof Blob.prototype.stream > "u" || !A()) && (Blob.prototype.stream = function() {
let r = 0;
let s = 0;
const e = this;

@@ -62,6 +62,6 @@ return new ReadableStream({

async pull(t) {
const s = t.byobRequest.view, i = await e.slice(r, r + s.byteLength).arrayBuffer(), a = new Uint8Array(i);
new Uint8Array(s.buffer).set(a);
const o = a.byteLength;
t.byobRequest.respond(o), r += o, r >= e.size && t.close();
const i = t.byobRequest.view, r = await e.slice(s, s + i.byteLength).arrayBuffer(), l = new Uint8Array(r);
new Uint8Array(i.buffer).set(l);
const o = l.byteLength;
t.byobRequest.respond(o), s += o, s >= e.size && t.close();
}

@@ -71,5 +71,5 @@ });

if (typeof CustomEvent > "u") {
class r extends Event {
constructor(t, s = {}) {
super(t, s), this.detail = s.detail;
class s extends Event {
constructor(t, i = {}) {
super(t, i), this.detail = i.detail;
}

@@ -79,8 +79,8 @@ initCustomEvent() {

}
globalThis.CustomEvent = r;
globalThis.CustomEvent = s;
}
const D = 5 * 1024 * 1024;
var g, p, w, S, E, B, b, v;
class W extends EventTarget {
constructor(t = []) {
const F = 5 * 1024 * 1024;
var u, d, v, I, b, P;
class k extends EventTarget {
constructor() {
super();

@@ -91,10 +91,4 @@ /**

*/
d(this, w);
h(this, v);
/**
* Creates a `dataFileDownloads` Proxy object that can be passed
* to `startPHP` to monitor the download #progress of the data
* dependencies.
*/
d(this, E);
/**
* Notifies about the download #progress of a file.

@@ -106,60 +100,40 @@ *

*/
d(this, b);
d(this, g, {});
d(this, p, {});
this.setModules(t), u(this, w, S).call(this);
h(this, b);
h(this, u, {});
h(this, d, {});
g(this, v, I).call(this);
}
getEmscriptenOptions() {
return {
dataFileDownloads: u(this, E, B).call(this)
};
expectAssets(t) {
for (const [i, n] of Object.entries(t)) {
const r = "http://example.com/", o = new URL(i, r).pathname.split("/").pop();
o in a(this, u) || (a(this, u)[o] = n), o in a(this, d) || (a(this, d)[o] = 0);
}
}
setModules(t) {
y(this, g, t.reduce((s, n) => {
if (n.dependenciesTotalSize > 0) {
const i = "http://example.com/", o = new URL(n.dependencyFilename, i).pathname.split("/").pop();
s[o] = Math.max(
o in s ? s[o] : 0,
n.dependenciesTotalSize
);
}
return s;
}, {})), y(this, p, Object.fromEntries(
Object.entries(l(this, g)).map(([s]) => [s, 0])
));
async monitorFetch(t) {
const i = await t;
return C(i, (r) => {
g(this, b, P).call(this, i.url, r.detail.loaded, r.detail.total);
});
}
}
g = new WeakMap(), p = new WeakMap(), w = new WeakSet(), S = function() {
u = new WeakMap(), d = new WeakMap(), v = new WeakSet(), I = function() {
const t = WebAssembly.instantiateStreaming;
WebAssembly.instantiateStreaming = async (s, ...n) => {
const i = await s, a = i.url.substring(
new URL(i.url).origin.length + 1
), o = O(
i,
({ detail: { loaded: h, total: c } }) => u(this, b, v).call(this, a, h, c)
WebAssembly.instantiateStreaming = async (i, ...n) => {
const r = await i, l = r.url.substring(
new URL(r.url).origin.length + 1
), o = C(
r,
({ detail: { loaded: c, total: y } }) => g(this, b, P).call(this, l, c, y)
);
return t(o, ...n);
};
}, E = new WeakSet(), B = function() {
const t = this, s = {};
return new Proxy(s, {
set(n, i, a) {
var o;
return u(o = t, b, v).call(o, i, a.loaded, a.total), n[i] = new Proxy(JSON.parse(JSON.stringify(a)), {
set(h, c, M) {
var x;
return h[c] = M, u(x = t, b, v).call(x, i, h.loaded, h.total), !0;
}
}), !0;
}
});
}, b = new WeakSet(), v = function(t, s, n) {
const i = new URL(t, "http://example.com").pathname.split("/").pop();
n || (n = l(this, g)[i]), i in l(this, p) || console.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.`
), l(this, p)[i] = s, this.dispatchEvent(
}, b = new WeakSet(), P = function(t, i, n) {
const r = new URL(t, "http://example.com").pathname.split("/").pop();
n || (n = a(this, u)[r]), r in a(this, d) || console.warn(
`Registered a download #progress of an unregistered file "${r}". This may cause a sudden **decrease** in the #progress percentage as the total number of bytes increases during the download.`
), a(this, d)[r] = i, this.dispatchEvent(
new CustomEvent("progress", {
detail: {
loaded: C(l(this, p)),
total: C(l(this, g))
loaded: R(a(this, d)),
total: R(a(this, u))
}

@@ -169,13 +143,13 @@ })

};
function C(r) {
return Object.values(r).reduce((e, t) => e + t, 0);
function R(s) {
return Object.values(s).reduce((e, t) => e + t, 0);
}
function O(r, e) {
const t = r.headers.get("content-length") || "", s = parseInt(t, 10) || D;
function n(i, a) {
function C(s, e) {
const t = s.headers.get("content-length") || "", i = parseInt(t, 10) || F;
function n(r, l) {
e(
new CustomEvent("progress", {
detail: {
loaded: i,
total: a
loaded: r,
total: l
}

@@ -187,19 +161,19 @@ })

new ReadableStream({
async start(i) {
if (!r.body) {
i.close();
async start(r) {
if (!s.body) {
r.close();
return;
}
const a = r.body.getReader();
const l = s.body.getReader();
let o = 0;
for (; ; )
try {
const { done: h, value: c } = await a.read();
if (c && (o += c.byteLength), h) {
n(o, o), i.close();
const { done: c, value: y } = await l.read();
if (y && (o += y.byteLength), c) {
n(o, o), r.close();
break;
} else
n(o, s), i.enqueue(c);
} catch (h) {
console.error({ e: h }), i.error(h);
n(o, i), r.enqueue(y);
} catch (c) {
console.error({ e: c }), r.error(c);
break;

@@ -210,31 +184,31 @@ }

{
status: r.status,
statusText: r.statusText,
headers: r.headers
status: s.status,
statusText: s.statusText,
headers: s.headers
}
);
}
var f, m, _, R;
class N extends EventTarget {
var f, p, m, T;
class M extends EventTarget {
constructor() {
super(...arguments);
d(this, _);
d(this, f, void 0);
d(this, m, void 0);
y(this, f, {}), y(this, m, 0), this.progress = 0, this.mode = "REAL_TIME", this.caption = "";
h(this, m);
h(this, f, void 0);
h(this, p, void 0);
_(this, f, {}), _(this, p, 0), this.progress = 0, this.mode = "REAL_TIME", this.caption = "";
}
partialObserver(t, s = "") {
const n = ++P(this, m)._;
return l(this, f)[n] = 0, (i) => {
const { loaded: a, total: o } = (i == null ? void 0 : i.detail) || {};
l(this, f)[n] = a / o * t, u(this, _, R).call(this, this.totalProgress, "REAL_TIME", s);
partialObserver(t, i = "") {
const n = ++E(this, p)._;
return a(this, f)[n] = 0, (r) => {
const { loaded: l, total: o } = (r == null ? void 0 : r.detail) || {};
a(this, f)[n] = l / o * t, g(this, m, T).call(this, this.totalProgress, "REAL_TIME", i);
};
}
slowlyIncrementBy(t) {
const s = ++P(this, m)._;
l(this, f)[s] = t, u(this, _, R).call(this, this.totalProgress, "SLOWLY_INCREMENT");
const i = ++E(this, p)._;
a(this, f)[i] = t, g(this, m, T).call(this, this.totalProgress, "SLOWLY_INCREMENT");
}
get totalProgress() {
return Object.values(l(this, f)).reduce(
(t, s) => t + s,
return Object.values(a(this, f)).reduce(
(t, i) => t + i,
0

@@ -244,3 +218,3 @@ );

}
f = new WeakMap(), m = new WeakMap(), _ = new WeakSet(), R = function(t, s, n) {
f = new WeakMap(), p = new WeakMap(), m = new WeakSet(), T = function(t, i, n) {
this.dispatchEvent(

@@ -250,3 +224,3 @@ new CustomEvent("progress", {

progress: t,
mode: s,
mode: i,
caption: n

@@ -257,10 +231,10 @@ }

};
const T = 1e-5;
class I extends EventTarget {
const L = 1e-5;
class x extends EventTarget {
constructor({
weight: e = 1,
caption: t = "",
fillTime: s = 4
fillTime: i = 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 = 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 = i;
}

@@ -303,3 +277,3 @@ /**

stage(e, t = "") {
if (e || (e = this._selfWeight), this._selfWeight - e < -T)
if (e || (e = this._selfWeight), this._selfWeight - e < -L)
throw new Error(

@@ -309,3 +283,3 @@ `Cannot add a stage with weight ${e} as the total weight of registered stages would exceed 1.`

this._selfWeight -= e;
const s = new I({
const i = new x({
caption: t,

@@ -315,5 +289,5 @@ weight: e,

});
return this._subTrackers.push(s), s.addEventListener("progress", () => this.notifyProgress()), s.addEventListener("done", () => {
return this._subTrackers.push(i), i.addEventListener("progress", () => this.notifyProgress()), i.addEventListener("done", () => {
this.done && this.notifyDone();
}), s;
}), i;
}

@@ -342,9 +316,9 @@ /**

this._isFilling = !0;
const t = 100, s = this._fillTime / t;
const t = 100, i = this._fillTime / t;
this._fillInterval = setInterval(() => {
this.set(this._selfProgress + 1), e && this._selfProgress >= 99 && clearInterval(this._fillInterval);
}, s);
}, i);
}
set(e) {
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + T >= 100 && this.finish();
this._selfProgress = Math.min(e, 100), this.notifyProgress(), this._selfProgress + L >= 100 && this.finish();
}

@@ -367,3 +341,3 @@ finish() {

get done() {
return this.progress + T >= 100;
return this.progress + L >= 100;
}

@@ -374,3 +348,3 @@ get progress() {

const e = this._subTrackers.reduce(
(t, s) => t + s.progress * s.weight,
(t, i) => t + i.progress * i.weight,
this._selfProgress * this._selfWeight

@@ -432,6 +406,6 @@ );

export {
W as EmscriptenDownloadMonitor,
N as ProgressObserver,
I as ProgressTracker,
O as cloneResponseMonitorProgress
k as EmscriptenDownloadMonitor,
M as ProgressObserver,
x as ProgressTracker,
C as cloneResponseMonitorProgress
};

@@ -1,5 +0,1 @@

export interface MonitoredModule {
dependencyFilename: string;
dependenciesTotalSize: number;
}
/**

@@ -24,7 +20,5 @@ * Monitors the download #progress of Emscripten modules

#private;
constructor(modules?: MonitoredModule[]);
getEmscriptenOptions(): {
dataFileDownloads: Record<string, any>;
};
setModules(modules: MonitoredModule[]): void;
constructor();
expectAssets(assets: Record<string, number>): void;
monitorFetch(fetchPromise: Promise<Response>): Promise<Response>;
}

@@ -31,0 +25,0 @@ export default EmscriptenDownloadMonitor;

{
"name": "@php-wasm/progress",
"version": "0.5.6",
"version": "0.6.0",
"description": "PHP.wasm – loading progress monitoring",

@@ -32,3 +32,3 @@ "repository": {

"types": "index.d.ts",
"gitHead": "72e190ebb407051ccb5ef544e2a62018395395a0",
"gitHead": "3f137306ec8e3b10ec0674a1fe69ee43349edb4a",
"engines": {

@@ -39,4 +39,4 @@ "node": ">=18.18.2",

"dependencies": {
"@php-wasm/node-polyfills": "0.5.6"
"@php-wasm/node-polyfills": "0.6.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc