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

@php-wasm/universal

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@php-wasm/universal - npm Package Compare versions

Comparing version 0.6.7 to 0.6.8

309

index.js

@@ -1,11 +0,11 @@

var Q = (e, t, r) => {
var J = (e, t, r) => {
if (!t.has(e))
throw TypeError("Cannot " + r);
};
var l = (e, t, r) => (Q(e, t, "read from private field"), r ? r.call(e) : t.get(e)), u = (e, t, r) => {
var l = (e, t, r) => (J(e, t, "read from private field"), r ? r.call(e) : t.get(e)), u = (e, t, r) => {
if (t.has(e))
throw TypeError("Cannot add the same private member more than once");
t instanceof WeakSet ? t.add(e) : t.set(e, r);
}, h = (e, t, r, s) => (Q(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r);
var f = (e, t, r) => (Q(e, t, "access private method"), r);
}, h = (e, t, r, s) => (J(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r);
var f = (e, t, r) => (J(e, t, "access private method"), r);
const currentJsRuntime$1 = function() {

@@ -22,4 +22,4 @@ var e;

return new Promise(function(s, n) {
r.onload = r.onerror = function(i) {
r.onload = r.onerror = null, i.type === "load" ? s(r.result) : n(new Error("Failed to read the blob/file"));
r.onload = r.onerror = function(o) {
r.onload = r.onerror = null, o.type === "load" ? s(r.result) : n(new Error("Failed to read the blob/file"));
};

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

class r extends Blob {
constructor(n, i, o) {
constructor(n, o, i) {
super(n);
let a;
o != null && o.lastModified && (a = /* @__PURE__ */ new Date()), (!a || isNaN(a.getFullYear())) && (a = /* @__PURE__ */ new Date()), this.lastModifiedDate = a, this.lastModified = a.getMilliseconds(), this.name = i || "";
i != null && i.lastModified && (a = /* @__PURE__ */ new Date()), (!a || isNaN(a.getFullYear())) && (a = /* @__PURE__ */ new Date()), this.lastModifiedDate = a, this.lastModified = a.getMilliseconds(), this.name = o || "";
}

@@ -61,7 +61,7 @@ }

async pull(n) {
const i = n.byobRequest.view, a = await s.slice(
const o = n.byobRequest.view, a = await s.slice(
r,
r + i.byteLength
r + o.byteLength
).arrayBuffer(), c = new Uint8Array(a);
new Uint8Array(i.buffer).set(c);
new Uint8Array(o.buffer).set(c);
const d = c.byteLength;

@@ -131,16 +131,16 @@ n.byobRequest.respond(d), r += d, r >= s.size && n.close();

e.asm[r] = function(...n) {
var i;
var o;
try {
return s(...n);
} catch (o) {
if (!(o instanceof Error))
throw o;
} catch (i) {
if (!(i instanceof Error))
throw i;
const a = clarifyErrorMessage(
o,
(i = e.lastAsyncifyStackSource) == null ? void 0 : i.stack
i,
(o = e.lastAsyncifyStackSource) == null ? void 0 : o.stack
);
if (e.lastAsyncifyStackSource && (o.cause = e.lastAsyncifyStackSource), t.hasListeners()) {
if (e.lastAsyncifyStackSource && (i.cause = e.lastAsyncifyStackSource), t.hasListeners()) {
t.dispatchEvent(
new ErrorEvent("error", {
error: o,
error: i,
message: a

@@ -151,3 +151,3 @@ })

}
throw isExitCodeZero(o) || showCriticalErrorBox(a), o;
throw isExitCodeZero(i) || showCriticalErrorBox(a), i;
}

@@ -294,24 +294,24 @@ };

let s = 0, n = "";
const i = [];
let o = "";
const o = [];
let i = "";
for (let a = 0; a < e.length; a++) {
const c = e[a];
c === "\\" ? ((e[a + 1] === '"' || e[a + 1] === "'") && a++, o += e[a]) : s === 0 ? c === '"' || c === "'" ? (s = 1, n = c) : c.match(/\s/) ? (o.trim().length && i.push(o.trim()), o = c) : i.length && !o ? o = i.pop() + c : o += c : s === 1 && (c === n ? (s = 0, n = "") : o += c);
c === "\\" ? ((e[a + 1] === '"' || e[a + 1] === "'") && a++, i += e[a]) : s === 0 ? c === '"' || c === "'" ? (s = 1, n = c) : c.match(/\s/) ? (i.trim().length && o.push(i.trim()), i = c) : o.length && !i ? i = o.pop() + c : i += c : s === 1 && (c === n ? (s = 0, n = "") : i += c);
}
return o && i.push(o.trim()), i;
return i && o.push(i.trim()), o;
}
function createSpawnHandler(e) {
return function(t, r = [], s = {}) {
const n = new ChildProcess(), i = new ProcessApi(n);
const n = new ChildProcess(), o = new ProcessApi(n);
return setTimeout(async () => {
let o = [];
let i = [];
if (r.length)
o = [t, ...r];
i = [t, ...r];
else if (typeof t == "string")
o = splitShellCommand(t);
i = splitShellCommand(t);
else if (Array.isArray(t))
o = t;
i = t;
else
throw new Error("Invalid command ", t);
await e(o, i, s), n.emit("spawn", !0);
await e(i, o, s), n.emit("spawn", !0);
}), n;

@@ -417,10 +417,10 @@ };

async pull(n) {
const { value: i, done: o } = await r.read(
const { value: o, done: i } = await r.read(
new Uint8Array(t - s)
);
if (o) {
if (i) {
r.releaseLock(), n.close();
return;
}
s += i.length, n.enqueue(i), s >= t && (r.releaseLock(), n.close());
s += o.length, n.enqueue(o), s >= t && (r.releaseLock(), n.close());
},

@@ -507,13 +507,13 @@ cancel() {

t = normalizePath(t);
const i = [t];
for (; i.length; ) {
const o = i.pop();
if (!o)
const o = [t];
for (; o.length; ) {
const i = o.pop();
if (!i)
return;
const a = await e.listFiles(o);
const a = await e.listFiles(i);
for (const c of a) {
const d = `${o}/${c}`;
const d = `${i}/${c}`;
if (n.includes(d.substring(t.length + 1)))
continue;
await e.isDir(d) ? i.push(d) : yield new StreamedFile(
await e.isDir(d) ? o.push(d) : yield new StreamedFile(
streamReadFileFromPHP(e, d),

@@ -540,4 +540,4 @@ r ? joinPaths(

class PHPResponse {
constructor(t, r, s, n = "", i = 0) {
this.httpStatusCode = t, this.headers = r, this.bytes = s, this.exitCode = i, this.errors = n;
constructor(t, r, s, n = "", o = 0) {
this.httpStatusCode = t, this.headers = r, this.bytes = s, this.exitCode = o, this.errors = n;
}

@@ -667,4 +667,4 @@ static fromRawData(t) {

continue;
const s = r.indexOf("="), n = r.substring(0, s), i = r.substring(s + 1).split(";")[0];
l(this, E)[n] = i;
const s = r.indexOf("="), n = r.substring(0, s), o = r.substring(s + 1).split(";")[0];
l(this, E)[n] = o;
} catch (s) {

@@ -703,10 +703,10 @@ console.error(s);

`);
const i = n.reduce((c, d) => c + d.length, 0), o = new Uint8Array(i);
const o = n.reduce((c, d) => c + d.length, 0), i = new Uint8Array(o);
let a = 0;
for (const c of n)
o.set(
i.set(
typeof c == "string" ? s.encode(c) : c,
a
), a += c.length;
return { bytes: o, contentType: r };
return { bytes: i, contentType: r };
}

@@ -721,3 +721,3 @@ function fileToUint8Array(e) {

}
var m, H, k, v, x, _, F, R, B, Y, I, K, N, Z;
var m, H, k, v, F, p, x, R, U, Q, B, Y, I, K;
class PHPRequestHandler {

@@ -735,3 +735,3 @@ /**

*/
u(this, B);
u(this, U);
/**

@@ -744,3 +744,3 @@ * Runs the requested PHP file with all the request and $_SERVER

*/
u(this, I);
u(this, B);
/**

@@ -755,3 +755,3 @@ * Resolve the requested path to the filesystem path of the requested PHP file.

*/
u(this, N);
u(this, I);
u(this, m, void 0);

@@ -761,5 +761,5 @@ u(this, H, void 0);

u(this, v, void 0);
u(this, F, void 0);
u(this, p, void 0);
u(this, x, void 0);
u(this, _, void 0);
u(this, F, void 0);
u(this, R, void 0);

@@ -769,3 +769,4 @@ h(this, R, new Semaphore({ concurrency: 1 }));

documentRoot: s = "/www/",
absoluteUrl: n = typeof location == "object" ? location == null ? void 0 : location.href : ""
absoluteUrl: n = typeof location == "object" ? location == null ? void 0 : location.href : "",
rewriteRules: o = []
} = r;

@@ -775,11 +776,11 @@ this.php = t, h(this, m, s);

h(this, k, i.hostname), h(this, v, i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80), h(this, H, (i.protocol || "").replace(":", ""));
const o = l(this, v) !== 443 && l(this, v) !== 80;
h(this, x, [
const a = l(this, v) !== 443 && l(this, v) !== 80;
h(this, F, [
l(this, k),
o ? `:${l(this, v)}` : ""
].join("")), h(this, _, i.pathname.replace(/\/+$/, "")), h(this, F, [
a ? `:${l(this, v)}` : ""
].join("")), h(this, p, i.pathname.replace(/\/+$/, "")), h(this, x, [
`${l(this, H)}://`,
l(this, x),
l(this, _)
].join(""));
l(this, F),
l(this, p)
].join("")), this.rewriteRules = o;
}

@@ -793,3 +794,3 @@ /** @inheritDoc */

const r = new URL(t);
return r.pathname.startsWith(l(this, _)) && (r.pathname = r.pathname.slice(l(this, _).length)), toRelativeUrl(r);
return r.pathname.startsWith(l(this, p)) && (r.pathname = r.pathname.slice(l(this, p).length)), toRelativeUrl(r);
}

@@ -801,3 +802,3 @@ get isRequestRunning() {

get absoluteUrl() {
return l(this, F);
return l(this, x);
}

@@ -813,10 +814,10 @@ /** @inheritDoc */

r ? void 0 : DEFAULT_BASE_URL
), n = removePathPrefix(
s.pathname,
l(this, _)
), i = `${l(this, m)}${n}`;
return seemsLikeAPHPRequestHandlerPath(i) ? await f(this, I, K).call(this, t, s) : f(this, B, Y).call(this, i);
), n = applyRewriteRules(
removePathPrefix(s.pathname, l(this, p)),
this.rewriteRules
), o = `${l(this, m)}${n}`;
return seemsLikeAPHPRequestHandlerPath(o) ? await f(this, B, Y).call(this, t, s) : f(this, U, Q).call(this, o);
}
}
m = new WeakMap(), H = new WeakMap(), k = new WeakMap(), v = new WeakMap(), x = new WeakMap(), _ = new WeakMap(), F = new WeakMap(), R = new WeakMap(), B = new WeakSet(), Y = function(t) {
m = new WeakMap(), H = new WeakMap(), k = new WeakMap(), v = new WeakMap(), F = new WeakMap(), p = new WeakMap(), x = new WeakMap(), R = new WeakMap(), U = new WeakSet(), Q = function(t) {
if (!this.php.fileExists(t))

@@ -846,4 +847,4 @@ return new PHPResponse(

);
}, I = new WeakSet(), K = async function(t, r) {
var n, i;
}, B = new WeakSet(), Y = async function(t, r) {
var n;
if (l(this, R).running > 0 && ((n = t.headers) == null ? void 0 : n["x-request-issuer"]) === "php")

@@ -861,26 +862,18 @@ return console.warn(

"HTTPS",
l(this, F).startsWith("https://") ? "on" : ""
l(this, x).startsWith("https://") ? "on" : ""
);
let o = "GET";
const a = {
host: l(this, x),
const i = {
host: l(this, F),
...normalizeHeaders(t.headers || {})
};
let c = t.body;
if (typeof c == "object" && !(c instanceof Uint8Array)) {
let a = t.body;
if (typeof a == "object" && !(a instanceof Uint8Array)) {
o = "POST";
const { bytes: p, contentType: U } = await encodeAsMultipart(c);
c = p, a["content-type"] = U;
const { bytes: d, contentType: _ } = await encodeAsMultipart(a);
a = d, i["content-type"] = _;
}
let d;
let c;
try {
let p = r.pathname;
if ((i = t.headers) != null && i["x-rewrite-url"])
try {
p = new URL(
t.headers["x-rewrite-url"]
).pathname;
} catch {
}
d = f(this, N, Z).call(this, p);
c = f(this, I, K).call(this, r.pathname);
} catch {

@@ -896,9 +889,9 @@ return new PHPResponse(

toRelativeUrl(r),
l(this, _)
l(this, p)
),
protocol: l(this, H),
method: t.method || o,
body: c,
scriptPath: d,
headers: a
body: a,
scriptPath: c,
headers: i
});

@@ -908,5 +901,5 @@ } finally {

}
}, N = new WeakSet(), Z = function(t) {
let r = removePathPrefix(t, l(this, _));
r.includes(".php") ? r = r.split(".php")[0] + ".php" : this.php.isDir(`${l(this, m)}${r}`) ? (r.endsWith("/") || (r = `${r}/`), r = `${r}index.php`) : r = "/index.php";
}, I = new WeakSet(), K = function(t) {
let r = removePathPrefix(t, l(this, p));
r = applyRewriteRules(r, this.rewriteRules), r.includes(".php") ? r = r.split(".php")[0] + ".php" : this.php.isDir(`${l(this, m)}${r}`) ? (r.endsWith("/") || (r = `${r}/`), r = `${r}index.php`) : r = "/index.php";
const s = `${l(this, m)}${r}`;

@@ -966,2 +959,8 @@ if (this.php.fileExists(s))

}
function applyRewriteRules(e, t) {
for (const r of t)
if (new RegExp(r.match).test(e))
return e.replace(r.match, r.replacement);
return e;
}
const FileErrorCodes = {

@@ -1053,11 +1052,11 @@ 0: "No error occurred. System call completed successfully.",

return function(r, s, n) {
const i = n.value;
n.value = function(...o) {
const o = n.value;
n.value = function(...i) {
try {
return i.apply(this, o);
return o.apply(this, i);
} catch (a) {
const c = typeof a == "object" ? a == null ? void 0 : a.errno : null;
if (c in FileErrorCodes) {
const d = FileErrorCodes[c], p = typeof o[0] == "string" ? o[0] : null, U = p !== null ? e.replaceAll("{path}", p) : e;
throw new Error(`${U}: ${d}`, {
const d = FileErrorCodes[c], _ = typeof i[0] == "string" ? i[0] : null, ue = _ !== null ? e.replaceAll("{path}", _) : e;
throw new Error(`${ue}: ${d}`, {
cause: a

@@ -1074,3 +1073,3 @@ });

async function loadPHPRuntime(e, t = {}) {
const [r, s, n] = makePromise(), i = e.init(currentJsRuntime, {
const [r, s, n] = makePromise(), o = e.init(currentJsRuntime, {
onAbort(a) {

@@ -1091,6 +1090,6 @@ n(a), console.error(a);

await r;
const o = ++lastRuntimeId;
return i.id = o, i.originalExit = i._exit, i._exit = function(a) {
return loadedRuntimes.delete(o), i.originalExit(a);
}, i[RuntimeId] = o, loadedRuntimes.set(o, i), o;
const i = ++lastRuntimeId;
return o.id = i, o.originalExit = o._exit, o._exit = function(a) {
return loadedRuntimes.delete(i), o.originalExit(a);
}, o[RuntimeId] = i, loadedRuntimes.set(i, o), i;
}

@@ -1110,8 +1109,8 @@ function getLoadedRuntime(e) {

var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = (e, t, r, s) => {
for (var n = s > 1 ? void 0 : s ? __getOwnPropDesc(t, r) : t, i = e.length - 1, o; i >= 0; i--)
(o = e[i]) && (n = (s ? o(t, r, n) : o(n)) || n);
for (var n = s > 1 ? void 0 : s ? __getOwnPropDesc(t, r) : t, o = e.length - 1, i; o >= 0; o--)
(i = e[o]) && (n = (s ? i(t, r, n) : i(n)) || n);
return s && n && __defProp(t, r, n), n;
};
const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use");
var S, T, A, y, w, g, P, C, L, X, O, ee, M, te, q, re, D, se, $, ne, j, ie, W, oe, z, ae, G, le, V, ce, J, ue;
var S, T, A, y, w, g, P, C, N, Z, L, X, O, ee, q, te, M, re, D, se, $, ne, j, ie, W, oe, z, ae, G, le, V, ce;
class BasePHP {

@@ -1126,6 +1125,7 @@ /**

constructor(e, t) {
u(this, N);
u(this, L);
u(this, O);
u(this, q);
u(this, M);
u(this, q);
u(this, D);

@@ -1138,3 +1138,2 @@ u(this, $);

u(this, V);
u(this, J);
u(this, S, void 0);

@@ -1253,25 +1252,30 @@ u(this, T, void 0);

try {
if (l(this, y) || (f(this, L, X).call(this), h(this, y, !0)), e.scriptPath && !this.fileExists(e.scriptPath))
if (l(this, y) || (f(this, N, Z).call(this), h(this, y, !0)), e.scriptPath && !this.fileExists(e.scriptPath))
throw new Error(
`The script path "${e.scriptPath}" does not exist.`
);
f(this, W, oe).call(this, e.scriptPath || ""), f(this, M, te).call(this, e.relativeUri || ""), f(this, D, se).call(this, e.method || "GET");
f(this, j, ie).call(this, e.scriptPath || ""), f(this, O, ee).call(this, e.relativeUri || ""), f(this, M, re).call(this, e.method || "GET");
const s = normalizeHeaders(e.headers || {}), n = s.host || "example.com:443";
f(this, q, re).call(this, n, e.protocol || "http"), f(this, $, ne).call(this, s), e.body && (r = f(this, j, ie).call(this, e.body)), typeof e.code == "string" && f(this, V, ce).call(this, " ?>" + e.code), f(this, z, ae).call(this);
const i = e.env || {};
for (const a in i)
f(this, G, le).call(this, a, i[a]);
const o = await f(this, J, ue).call(this);
if (e.throwOnError && o.exitCode !== 0) {
f(this, q, te).call(this, n, e.protocol || "http"), f(this, D, se).call(this, s), e.body && (r = f(this, $, ne).call(this, e.body)), typeof e.code == "string" && f(this, G, le).call(this, " ?>" + e.code), f(this, W, oe).call(this);
const o = e.env || {};
for (const a in o)
f(this, z, ae).call(this, a, o[a]);
const i = await f(this, V, ce).call(this);
if (e.throwOnError && i.exitCode !== 0) {
const a = {
stdout: o.text,
stderr: o.errors
stdout: i.text,
stderr: i.errors
};
console.warn("PHP.run() output was:", a);
const c = new Error(
`PHP.run() failed with exit code ${o.exitCode} and the following output: ` + o.errors
`PHP.run() failed with exit code ${i.exitCode} and the following output: ` + i.errors
);
throw c.output = a, console.error(c), c;
}
return o;
return i;
} catch (s) {
throw this.dispatchEvent({
type: "request.error",
error: s
}), s;
} finally {

@@ -1400,3 +1404,3 @@ try {

}
S = new WeakMap(), T = new WeakMap(), A = new WeakMap(), y = new WeakMap(), w = new WeakMap(), g = new WeakMap(), P = new WeakMap(), C = new WeakMap(), L = new WeakSet(), X = function() {
S = new WeakMap(), T = new WeakMap(), A = new WeakMap(), y = new WeakMap(), w = new WeakMap(), g = new WeakMap(), P = new WeakMap(), C = new WeakMap(), N = new WeakSet(), Z = function() {
if (this.setPhpIniEntry("auto_prepend_file", "/internal/consts.php"), this.fileExists("/internal/consts.php") || this.writeFile(

@@ -1426,3 +1430,3 @@ "/internal/consts.php",

this[__private__dont__use].ccall("php_wasm_init", null, [], []);
}, O = new WeakSet(), ee = function() {
}, L = new WeakSet(), X = function() {
const e = "/internal/headers.json";

@@ -1437,4 +1441,4 @@ if (!this.fileExists(e))

continue;
const n = s.indexOf(": "), i = s.substring(0, n).toLowerCase(), o = s.substring(n + 2);
i in r || (r[i] = []), r[i].push(o);
const n = s.indexOf(": "), o = s.substring(0, n).toLowerCase(), i = s.substring(n + 2);
o in r || (r[o] = []), r[o].push(i);
}

@@ -1445,3 +1449,3 @@ return {

};
}, M = new WeakSet(), te = function(e) {
}, O = new WeakSet(), ee = function(e) {
if (this[__private__dont__use].ccall(

@@ -1461,3 +1465,3 @@ "wasm_set_request_uri",

}
}, q = new WeakSet(), re = function(e, t) {
}, q = new WeakSet(), te = function(e, t) {
this[__private__dont__use].ccall(

@@ -1480,3 +1484,3 @@ "wasm_set_request_host",

), (t === "https" || !t && r === 443) && this.addServerGlobalEntry("HTTPS", "on");
}, D = new WeakSet(), se = function(e) {
}, M = new WeakSet(), re = function(e) {
this[__private__dont__use].ccall(

@@ -1488,3 +1492,3 @@ "wasm_set_request_method",

);
}, $ = new WeakSet(), ne = function(e) {
}, D = new WeakSet(), se = function(e) {
e.cookie && this[__private__dont__use].ccall(

@@ -1513,3 +1517,3 @@ "wasm_set_cookies",

}
}, j = new WeakSet(), ie = function(e) {
}, $ = new WeakSet(), ne = function(e) {
let t, r;

@@ -1537,3 +1541,3 @@ typeof e == "string" ? (console.warn(

), s;
}, W = new WeakSet(), oe = function(e) {
}, j = new WeakSet(), ie = function(e) {
this[__private__dont__use].ccall(

@@ -1545,3 +1549,3 @@ "wasm_set_path_translated",

);
}, z = new WeakSet(), ae = function() {
}, W = new WeakSet(), oe = function() {
for (const e in l(this, g))

@@ -1554,3 +1558,3 @@ this[__private__dont__use].ccall(

);
}, G = new WeakSet(), le = function(e, t) {
}, z = new WeakSet(), ae = function(e, t) {
this[__private__dont__use].ccall(

@@ -1562,3 +1566,3 @@ "wasm_add_ENV_entry",

);
}, V = new WeakSet(), ce = function(e) {
}, G = new WeakSet(), le = function(e) {
this[__private__dont__use].ccall(

@@ -1570,12 +1574,12 @@ "wasm_set_php_code",

);
}, J = new WeakSet(), ue = async function() {
}, V = new WeakSet(), ce = async function() {
var n;
let e, t;
try {
e = await new Promise((i, o) => {
e = await new Promise((o, i) => {
var c;
t = (d) => {
console.error(d), console.error(d.error);
const p = new Error("Rethrown");
p.cause = d.error, p.betterMessage = d.message, o(p);
const _ = new Error("Rethrown");
_.cause = d.error, _.betterMessage = d.message, i(_);
}, (c = l(this, w)) == null || c.addEventListener(

@@ -1592,5 +1596,5 @@ "error",

);
return a instanceof Promise ? a.then(i, o) : i(a);
return a instanceof Promise ? a.then(o, i) : o(a);
});
} catch (i) {
} catch (o) {
for (const d in this)

@@ -1603,8 +1607,8 @@ typeof this[d] == "function" && (this[d] = () => {

this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify();
const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(a);
throw c.cause = o, console.error(c), c;
const i = o, a = "betterMessage" in i ? i.betterMessage : i.message, c = new Error(a);
throw c.cause = i, console.error(c), c;
} finally {
(n = l(this, w)) == null || n.removeEventListener("error", t), h(this, g, {});
}
const { headers: r, httpStatusCode: s } = f(this, O, ee).call(this);
const { headers: r, httpStatusCode: s } = f(this, L, X).call(this);
return new PHPResponse(

@@ -1668,5 +1672,5 @@ s,

t.mkdirTree(r);
const n = e.readdir(r).filter((i) => i !== "." && i !== "..");
for (const i of n)
copyFS(e, t, joinPaths(r, i));
const n = e.readdir(r).filter((o) => o !== "." && o !== "..");
for (const o of n)
copyFS(e, t, joinPaths(r, o));
}

@@ -1689,7 +1693,7 @@ function isLocalPHP(e) {

s = 0;
const i = await e.semaphore.acquire();
const o = await e.semaphore.acquire();
try {
e.hotSwapPHPRuntime(await t());
} finally {
i();
o();
}

@@ -1703,5 +1707,5 @@ }

s && await e.isDir(t) && await e.rmdir(t, { recursive: !0 });
for (const [n, i] of Object.entries(r)) {
const o = joinPaths(t, n);
await e.fileExists(dirname(o)) || await e.mkdir(dirname(o)), await e.writeFile(o, i);
for (const [n, o] of Object.entries(r)) {
const i = joinPaths(t, n);
await e.fileExists(dirname(i)) || await e.mkdir(dirname(i)), await e.writeFile(i, o);
}

@@ -1722,2 +1726,3 @@ }

__private__dont__use,
applyRewriteRules,
ensurePathPrefix,

@@ -1724,0 +1729,0 @@ isExitCodeZero,

@@ -19,4 +19,4 @@ export type { IsomorphicLocalPHP, IsomorphicRemotePHP, MessageListener, PHPOutput, PHPRunOptions, UniversalPHP, ListFilesOptions, RmDirOptions, PHPEvent, PHPEventListener, HTTPMethod, PHPRequest, PHPRequestHeaders, RequestHandler, SpawnHandler, } from './universal-php';

export { isRemotePHP } from './is-remote-php';
export type { PHPRequestHandlerConfiguration } from './php-request-handler';
export { PHPRequestHandler } from './php-request-handler';
export type { PHPRequestHandlerConfiguration, RewriteRule, } from './php-request-handler';
export { PHPRequestHandler, applyRewriteRules } from './php-request-handler';
export type { PHPBrowserConfiguration } from './php-browser';

@@ -23,0 +23,0 @@ export { PHPBrowser } from './php-browser';

import { BasePHP } from './base-php';
import { PHPResponse } from './php-response';
import { PHPRequest, RequestHandler } from './universal-php';
export type RewriteRule = {
match: RegExp;
replacement: string;
};
export interface PHPRequestHandlerConfiguration {

@@ -14,2 +18,6 @@ /**

absoluteUrl?: string;
/**
* Rewrite rules
*/
rewriteRules?: RewriteRule[];
}

@@ -19,2 +27,3 @@ /** @inheritDoc */

#private;
rewriteRules: RewriteRule[];
/**

@@ -58,1 +67,9 @@ * The PHP instance

export declare function seemsLikeAPHPRequestHandlerPath(path: string): boolean;
/**
* Applies the given rewrite rules to the given path.
*
* @param path The path to apply the rules to.
* @param rules The rules to apply.
* @returns The path with the rules applied.
*/
export declare function applyRewriteRules(path: string, rules: RewriteRule[]): string;

@@ -10,2 +10,9 @@ import { Remote } from 'comlink';

/**
* Represents an error event related to the PHP request.
*/
export interface PHPRequestErrorEvent {
type: 'request.error';
error: Error;
}
/**
* Represents a PHP runtime initialization event.

@@ -27,3 +34,3 @@ */

*/
export type PHPEvent = PHPRequestEndEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
export type PHPEvent = PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
/**

@@ -30,0 +37,0 @@ * A callback function that handles PHP events.

{
"name": "@php-wasm/universal",
"version": "0.6.7",
"version": "0.6.8",
"description": "PHP.wasm – emscripten bindings for PHP",

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

"license": "GPL-2.0-or-later",
"gitHead": "c4c52563eee8997b94cd4a0875e10fb5d8ccda42",
"gitHead": "cb7b1af260489022238495a2fc0d96f767a1294a",
"engines": {

@@ -42,0 +42,0 @@ "node": ">=18.18.2",

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