@php-wasm/fs-journal
Advanced tools
Comparing version 0.6.7 to 0.6.8
314
index.js
@@ -5,7 +5,7 @@ var Y = (e, t, r) => { | ||
}; | ||
var a = (e, t, r) => (Y(e, t, "read from private field"), r ? r.call(e) : t.get(e)), u = (e, t, r) => { | ||
var l = (e, t, r) => (Y(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); | ||
}, p = (e, t, r, s) => (Y(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r); | ||
}, h = (e, t, r, s) => (Y(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r); | ||
var f = (e, t, r) => (Y(e, t, "access private method"), r); | ||
@@ -39,4 +39,4 @@ const currentJsRuntime = function() { | ||
super(n); | ||
let l; | ||
o != null && o.lastModified && (l = /* @__PURE__ */ new Date()), (!l || isNaN(l.getFullYear())) && (l = /* @__PURE__ */ new Date()), this.lastModifiedDate = l, this.lastModified = l.getMilliseconds(), this.name = i || ""; | ||
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 || ""; | ||
} | ||
@@ -61,9 +61,9 @@ } | ||
async pull(n) { | ||
const i = n.byobRequest.view, l = await s.slice( | ||
const i = n.byobRequest.view, a = await s.slice( | ||
r, | ||
r + i.byteLength | ||
).arrayBuffer(), c = new Uint8Array(l); | ||
).arrayBuffer(), c = new Uint8Array(a); | ||
new Uint8Array(i.buffer).set(c); | ||
const h = c.byteLength; | ||
n.byobRequest.respond(h), r += h, r >= s.size && n.close(); | ||
const d = c.byteLength; | ||
n.byobRequest.respond(d), r += d, r >= s.size && n.close(); | ||
} | ||
@@ -137,3 +137,3 @@ }); | ||
throw o; | ||
const l = clarifyErrorMessage( | ||
const a = clarifyErrorMessage( | ||
o, | ||
@@ -146,3 +146,3 @@ (i = e.lastAsyncifyStackSource) == null ? void 0 : i.stack | ||
error: o, | ||
message: l | ||
message: a | ||
}) | ||
@@ -152,3 +152,3 @@ ); | ||
} | ||
throw isExitCodeZero(o) || showCriticalErrorBox(l), o; | ||
throw isExitCodeZero(o) || showCriticalErrorBox(a), o; | ||
} | ||
@@ -297,5 +297,5 @@ }; | ||
let o = ""; | ||
for (let l = 0; l < e.length; l++) { | ||
const c = e[l]; | ||
c === "\\" ? ((e[l + 1] === '"' || e[l + 1] === "'") && l++, o += e[l]) : 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); | ||
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); | ||
} | ||
@@ -432,3 +432,3 @@ return o && i.push(o.trim()), i; | ||
u(this, T, void 0); | ||
this.requestHandler = t, p(this, v, {}), p(this, T, { | ||
this.requestHandler = t, h(this, v, {}), h(this, T, { | ||
handleRedirects: !1, | ||
@@ -461,3 +461,3 @@ maxRedirects: 4, | ||
}); | ||
if (s.headers["set-cookie"] && this.setCookies(s.headers["set-cookie"]), a(this, T).handleRedirects && s.headers.location && r < a(this, T).maxRedirects) { | ||
if (s.headers["set-cookie"] && this.setCookies(s.headers["set-cookie"]), l(this, T).handleRedirects && s.headers.location && r < l(this, T).maxRedirects) { | ||
const n = new URL( | ||
@@ -500,3 +500,3 @@ s.headers.location[0], | ||
const s = r.indexOf("="), n = r.substring(0, s), i = r.substring(s + 1).split(";")[0]; | ||
a(this, v)[n] = i; | ||
l(this, v)[n] = i; | ||
} catch (s) { | ||
@@ -508,4 +508,4 @@ console.error(s); | ||
const t = []; | ||
for (const r in a(this, v)) | ||
t.push(`${r}=${a(this, v)[r]}`); | ||
for (const r in l(this, v)) | ||
t.push(`${r}=${l(this, v)[r]}`); | ||
return t.join("; "); | ||
@@ -527,18 +527,18 @@ } | ||
const t = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${t}`, s = new TextEncoder(), n = []; | ||
for (const [c, h] of Object.entries(e)) | ||
for (const [c, d] of Object.entries(e)) | ||
n.push(`--${t}\r | ||
`), n.push(`Content-Disposition: form-data; name="${c}"`), h instanceof File && n.push(`; filename="${h.name}"`), n.push(`\r | ||
`), h instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r | ||
`), n.push(`Content-Disposition: form-data; name="${c}"`), d instanceof File && n.push(`; filename="${d.name}"`), n.push(`\r | ||
`), d instanceof File && (n.push("Content-Type: application/octet-stream"), n.push(`\r | ||
`)), n.push(`\r | ||
`), h instanceof File ? n.push(await fileToUint8Array(h)) : n.push(h), n.push(`\r | ||
`), d instanceof File ? n.push(await fileToUint8Array(d)) : n.push(d), n.push(`\r | ||
`); | ||
n.push(`--${t}--\r | ||
`); | ||
const i = n.reduce((c, h) => c + h.length, 0), o = new Uint8Array(i); | ||
let l = 0; | ||
const i = n.reduce((c, d) => c + d.length, 0), o = new Uint8Array(i); | ||
let a = 0; | ||
for (const c of n) | ||
o.set( | ||
typeof c == "string" ? s.encode(c) : c, | ||
l | ||
), l += c.length; | ||
a | ||
), a += c.length; | ||
return { bytes: o, contentType: r }; | ||
@@ -554,3 +554,3 @@ } | ||
} | ||
var y, F, N, b, x, m, C, R, I, K, O, Z, U, X; | ||
var m, F, N, R, x, _, C, b, I, K, O, Z, M, X; | ||
class PHPRequestHandler { | ||
@@ -586,28 +586,29 @@ /** | ||
*/ | ||
u(this, U); | ||
u(this, y, void 0); | ||
u(this, M); | ||
u(this, m, void 0); | ||
u(this, F, void 0); | ||
u(this, N, void 0); | ||
u(this, b, void 0); | ||
u(this, R, void 0); | ||
u(this, x, void 0); | ||
u(this, m, void 0); | ||
u(this, _, void 0); | ||
u(this, C, void 0); | ||
u(this, R, void 0); | ||
p(this, R, new Semaphore({ concurrency: 1 })); | ||
u(this, b, void 0); | ||
h(this, b, new Semaphore({ concurrency: 1 })); | ||
const { | ||
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: i = [] | ||
} = r; | ||
this.php = t, p(this, y, s); | ||
const i = new URL(n); | ||
p(this, N, i.hostname), p(this, b, i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80), p(this, F, (i.protocol || "").replace(":", "")); | ||
const o = a(this, b) !== 443 && a(this, b) !== 80; | ||
p(this, x, [ | ||
a(this, N), | ||
o ? `:${a(this, b)}` : "" | ||
].join("")), p(this, m, i.pathname.replace(/\/+$/, "")), p(this, C, [ | ||
`${a(this, F)}://`, | ||
a(this, x), | ||
a(this, m) | ||
].join("")); | ||
this.php = t, h(this, m, s); | ||
const o = new URL(n); | ||
h(this, N, o.hostname), h(this, R, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), h(this, F, (o.protocol || "").replace(":", "")); | ||
const a = l(this, R) !== 443 && l(this, R) !== 80; | ||
h(this, x, [ | ||
l(this, N), | ||
a ? `:${l(this, R)}` : "" | ||
].join("")), h(this, _, o.pathname.replace(/\/+$/, "")), h(this, C, [ | ||
`${l(this, F)}://`, | ||
l(this, x), | ||
l(this, _) | ||
].join("")), this.rewriteRules = i; | ||
} | ||
@@ -621,14 +622,14 @@ /** @inheritDoc */ | ||
const r = new URL(t); | ||
return r.pathname.startsWith(a(this, m)) && (r.pathname = r.pathname.slice(a(this, m).length)), toRelativeUrl(r); | ||
return r.pathname.startsWith(l(this, _)) && (r.pathname = r.pathname.slice(l(this, _).length)), toRelativeUrl(r); | ||
} | ||
get isRequestRunning() { | ||
return a(this, R).running > 0; | ||
return l(this, b).running > 0; | ||
} | ||
/** @inheritDoc */ | ||
get absoluteUrl() { | ||
return a(this, C); | ||
return l(this, C); | ||
} | ||
/** @inheritDoc */ | ||
get documentRoot() { | ||
return a(this, y); | ||
return l(this, m); | ||
} | ||
@@ -640,10 +641,10 @@ /** @inheritDoc */ | ||
r ? void 0 : DEFAULT_BASE_URL | ||
), n = removePathPrefix( | ||
s.pathname, | ||
a(this, m) | ||
), i = `${a(this, y)}${n}`; | ||
), n = applyRewriteRules( | ||
removePathPrefix(s.pathname, l(this, _)), | ||
this.rewriteRules | ||
), i = `${l(this, m)}${n}`; | ||
return seemsLikeAPHPRequestHandlerPath(i) ? await f(this, O, Z).call(this, t, s) : f(this, I, K).call(this, i); | ||
} | ||
} | ||
y = new WeakMap(), F = new WeakMap(), N = new WeakMap(), b = new WeakMap(), x = new WeakMap(), m = new WeakMap(), C = new WeakMap(), R = new WeakMap(), I = new WeakSet(), K = function(t) { | ||
m = new WeakMap(), F = new WeakMap(), N = new WeakMap(), R = new WeakMap(), x = new WeakMap(), _ = new WeakMap(), C = new WeakMap(), b = new WeakMap(), I = new WeakSet(), K = function(t) { | ||
if (!this.php.fileExists(t)) | ||
@@ -674,4 +675,4 @@ return new PHPResponse( | ||
}, O = new WeakSet(), Z = async function(t, r) { | ||
var n, i; | ||
if (a(this, R).running > 0 && ((n = t.headers) == null ? void 0 : n["x-request-issuer"]) === "php") | ||
var n; | ||
if (l(this, b).running > 0 && ((n = t.headers) == null ? void 0 : n["x-request-issuer"]) === "php") | ||
return console.warn( | ||
@@ -684,30 +685,22 @@ "Possible deadlock: Called request() before the previous request() have finished. PHP likely issued an HTTP call to itself. Normally this would lead to infinite waiting as Request 1 holds the lock that the Request 2 is waiting to acquire. That's not useful, so PHPRequestHandler will return error 502 instead." | ||
); | ||
const s = await a(this, R).acquire(); | ||
const s = await l(this, b).acquire(); | ||
try { | ||
this.php.addServerGlobalEntry("REMOTE_ADDR", "127.0.0.1"), this.php.addServerGlobalEntry("DOCUMENT_ROOT", a(this, y)), this.php.addServerGlobalEntry( | ||
this.php.addServerGlobalEntry("REMOTE_ADDR", "127.0.0.1"), this.php.addServerGlobalEntry("DOCUMENT_ROOT", l(this, m)), this.php.addServerGlobalEntry( | ||
"HTTPS", | ||
a(this, C).startsWith("https://") ? "on" : "" | ||
l(this, C).startsWith("https://") ? "on" : "" | ||
); | ||
let o = "GET"; | ||
const l = { | ||
host: a(this, x), | ||
let i = "GET"; | ||
const o = { | ||
host: l(this, x), | ||
...normalizeHeaders(t.headers || {}) | ||
}; | ||
let c = t.body; | ||
if (typeof c == "object" && !(c instanceof Uint8Array)) { | ||
o = "POST"; | ||
const { bytes: d, contentType: _ } = await encodeAsMultipart(c); | ||
c = d, l["content-type"] = _; | ||
let a = t.body; | ||
if (typeof a == "object" && !(a instanceof Uint8Array)) { | ||
i = "POST"; | ||
const { bytes: d, contentType: p } = await encodeAsMultipart(a); | ||
a = d, o["content-type"] = p; | ||
} | ||
let h; | ||
let c; | ||
try { | ||
let d = r.pathname; | ||
if ((i = t.headers) != null && i["x-rewrite-url"]) | ||
try { | ||
d = new URL( | ||
t.headers["x-rewrite-url"] | ||
).pathname; | ||
} catch { | ||
} | ||
h = f(this, U, X).call(this, d); | ||
c = f(this, M, X).call(this, r.pathname); | ||
} catch { | ||
@@ -723,9 +716,9 @@ return new PHPResponse( | ||
toRelativeUrl(r), | ||
a(this, m) | ||
l(this, _) | ||
), | ||
protocol: a(this, F), | ||
method: t.method || o, | ||
body: c, | ||
scriptPath: h, | ||
headers: l | ||
protocol: l(this, F), | ||
method: t.method || i, | ||
body: a, | ||
scriptPath: c, | ||
headers: o | ||
}); | ||
@@ -735,6 +728,6 @@ } finally { | ||
} | ||
}, U = new WeakSet(), X = function(t) { | ||
let r = removePathPrefix(t, a(this, m)); | ||
r.includes(".php") ? r = r.split(".php")[0] + ".php" : this.php.isDir(`${a(this, y)}${r}`) ? (r.endsWith("/") || (r = `${r}/`), r = `${r}index.php`) : r = "/index.php"; | ||
const s = `${a(this, y)}${r}`; | ||
}, M = new WeakSet(), X = function(t) { | ||
let r = removePathPrefix(t, l(this, _)); | ||
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}`; | ||
if (this.php.fileExists(s)) | ||
@@ -793,2 +786,8 @@ return 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 = { | ||
@@ -884,11 +883,11 @@ 0: "No error occurred. System call completed successfully.", | ||
return i.apply(this, o); | ||
} catch (l) { | ||
const c = typeof l == "object" ? l == null ? void 0 : l.errno : null; | ||
} catch (a) { | ||
const c = typeof a == "object" ? a == null ? void 0 : a.errno : null; | ||
if (c in FileErrorCodes) { | ||
const h = FileErrorCodes[c], d = typeof o[0] == "string" ? o[0] : null, _ = d !== null ? e.replaceAll("{path}", d) : e; | ||
throw new Error(`${_}: ${h}`, { | ||
cause: l | ||
const d = FileErrorCodes[c], p = typeof o[0] == "string" ? o[0] : null, P = p !== null ? e.replaceAll("{path}", p) : e; | ||
throw new Error(`${P}: ${d}`, { | ||
cause: a | ||
}); | ||
} | ||
throw l; | ||
throw a; | ||
} | ||
@@ -912,3 +911,3 @@ }; | ||
const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use"); | ||
var S, k, A, E, g, P, w, H, M, ee, B, te, L, re, D, se, $, ne, q, ie, W, oe, j, ae, z, le, G, ce, J, ue, Q, de; | ||
var S, k, A, y, w, g, E, H, U, ee, B, te, L, re, D, se, $, ne, q, ie, W, oe, j, ae, z, le, G, ce, J, ue, Q, de; | ||
class BasePHP { | ||
@@ -923,3 +922,3 @@ /** | ||
constructor(e, t) { | ||
u(this, M); | ||
u(this, U); | ||
u(this, B); | ||
@@ -939,8 +938,8 @@ u(this, L); | ||
u(this, A, void 0); | ||
u(this, y, void 0); | ||
u(this, w, void 0); | ||
u(this, g, void 0); | ||
u(this, E, void 0); | ||
u(this, g, void 0); | ||
u(this, P, void 0); | ||
u(this, w, void 0); | ||
u(this, H, void 0); | ||
p(this, S, []), p(this, E, !1), p(this, g, null), p(this, P, {}), p(this, w, /* @__PURE__ */ new Map()), p(this, H, []), this.semaphore = new Semaphore({ concurrency: 1 }), e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new PHPBrowser( | ||
h(this, S, []), h(this, y, !1), h(this, w, null), h(this, g, {}), h(this, E, /* @__PURE__ */ new Map()), h(this, H, []), this.semaphore = new Semaphore({ concurrency: 1 }), e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new PHPBrowser( | ||
new PHPRequestHandler(this, t) | ||
@@ -950,10 +949,10 @@ )); | ||
addEventListener(e, t) { | ||
a(this, w).has(e) || a(this, w).set(e, /* @__PURE__ */ new Set()), a(this, w).get(e).add(t); | ||
l(this, E).has(e) || l(this, E).set(e, /* @__PURE__ */ new Set()), l(this, E).get(e).add(t); | ||
} | ||
removeEventListener(e, t) { | ||
var r; | ||
(r = a(this, w).get(e)) == null || r.delete(t); | ||
(r = l(this, E).get(e)) == null || r.delete(t); | ||
} | ||
dispatchEvent(e) { | ||
const t = a(this, w).get(e.type); | ||
const t = l(this, E).get(e.type); | ||
if (t) | ||
@@ -965,3 +964,3 @@ for (const r of t) | ||
async onMessage(e) { | ||
a(this, H).push(e); | ||
l(this, H).push(e); | ||
} | ||
@@ -997,3 +996,3 @@ /** @inheritDoc */ | ||
this[__private__dont__use] = t, t.onMessage = async (r) => { | ||
for (const s of a(this, H)) { | ||
for (const s of l(this, H)) { | ||
const n = await s(r); | ||
@@ -1004,3 +1003,3 @@ if (n) | ||
return ""; | ||
}, p(this, g, improveWASMErrorReporting(t)), this.dispatchEvent({ | ||
}, h(this, w, improveWASMErrorReporting(t)), this.dispatchEvent({ | ||
type: "runtime.initialized" | ||
@@ -1020,9 +1019,9 @@ }); | ||
); | ||
p(this, A, e); | ||
h(this, A, e); | ||
} | ||
/** @inheritDoc */ | ||
setPhpIniPath(e) { | ||
if (a(this, E)) | ||
if (l(this, y)) | ||
throw new Error("Cannot set PHP ini path after calling run()."); | ||
p(this, k, e), this[__private__dont__use].ccall( | ||
h(this, k, e), this[__private__dont__use].ccall( | ||
"wasm_set_phpini_path", | ||
@@ -1036,5 +1035,5 @@ null, | ||
setPhpIniEntry(e, t) { | ||
if (a(this, E)) | ||
if (l(this, y)) | ||
throw new Error("Cannot set PHP ini entries after calling run()."); | ||
a(this, S).push([e, t]); | ||
l(this, S).push([e, t]); | ||
} | ||
@@ -1056,3 +1055,3 @@ /** @inheritDoc */ | ||
try { | ||
if (a(this, E) || (f(this, M, ee).call(this), p(this, E, !0)), e.scriptPath && !this.fileExists(e.scriptPath)) | ||
if (l(this, y) || (f(this, U, ee).call(this), h(this, y, !0)), e.scriptPath && !this.fileExists(e.scriptPath)) | ||
throw new Error( | ||
@@ -1065,17 +1064,22 @@ `The script path "${e.scriptPath}" does not exist.` | ||
const i = e.env || {}; | ||
for (const l in i) | ||
f(this, G, ce).call(this, l, i[l]); | ||
for (const a in i) | ||
f(this, G, ce).call(this, a, i[a]); | ||
const o = await f(this, Q, de).call(this); | ||
if (e.throwOnError && o.exitCode !== 0) { | ||
const l = { | ||
const a = { | ||
stdout: o.text, | ||
stderr: o.errors | ||
}; | ||
console.warn("PHP.run() output was:", l); | ||
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 | ||
); | ||
throw c.output = l, console.error(c), c; | ||
throw c.output = a, console.error(c), c; | ||
} | ||
return o; | ||
} catch (s) { | ||
throw this.dispatchEvent({ | ||
type: "request.error", | ||
error: s | ||
}), s; | ||
} finally { | ||
@@ -1092,3 +1096,3 @@ try { | ||
addServerGlobalEntry(e, t) { | ||
a(this, P)[e] = t; | ||
l(this, g)[e] = t; | ||
} | ||
@@ -1189,3 +1193,3 @@ defineConstant(e, t) { | ||
} | ||
if (this.initializeRuntime(e), a(this, k) && this.setPhpIniPath(a(this, k)), a(this, A) && this.setSapiName(a(this, A)), this.requestHandler) { | ||
if (this.initializeRuntime(e), l(this, k) && this.setPhpIniPath(l(this, k)), l(this, A) && this.setSapiName(l(this, A)), this.requestHandler) { | ||
const r = this.documentRoot; | ||
@@ -1203,6 +1207,6 @@ copyFS(t, this[__private__dont__use].FS, r); | ||
} | ||
p(this, E, !1), p(this, g, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use]; | ||
h(this, y, !1), h(this, w, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use]; | ||
} | ||
} | ||
S = new WeakMap(), k = new WeakMap(), A = new WeakMap(), E = new WeakMap(), g = new WeakMap(), P = new WeakMap(), w = new WeakMap(), H = new WeakMap(), M = new WeakSet(), ee = function() { | ||
S = new WeakMap(), k = new WeakMap(), A = new WeakMap(), y = new WeakMap(), w = new WeakMap(), g = new WeakMap(), E = new WeakMap(), H = new WeakMap(), U = new WeakSet(), ee = function() { | ||
if (this.setPhpIniEntry("auto_prepend_file", "/internal/consts.php"), this.fileExists("/internal/consts.php") || this.writeFile( | ||
@@ -1219,4 +1223,4 @@ "/internal/consts.php", | ||
}` | ||
), a(this, S).length > 0) { | ||
const e = a(this, S).map(([t, r]) => `${t}=${r}`).join(` | ||
), l(this, S).length > 0) { | ||
const e = l(this, S).map(([t, r]) => `${t}=${r}`).join(` | ||
`) + ` | ||
@@ -1345,3 +1349,3 @@ | ||
}, z = new WeakSet(), le = function() { | ||
for (const e in a(this, P)) | ||
for (const e in l(this, g)) | ||
this[__private__dont__use].ccall( | ||
@@ -1351,3 +1355,3 @@ "wasm_add_SERVER_entry", | ||
[STRING, STRING], | ||
[e, a(this, P)[e]] | ||
[e, l(this, g)[e]] | ||
); | ||
@@ -1374,11 +1378,11 @@ }, G = new WeakSet(), ce = function(e, t) { | ||
var c; | ||
t = (h) => { | ||
console.error(h), console.error(h.error); | ||
const d = new Error("Rethrown"); | ||
d.cause = h.error, d.betterMessage = h.message, o(d); | ||
}, (c = a(this, g)) == null || c.addEventListener( | ||
t = (d) => { | ||
console.error(d), console.error(d.error); | ||
const p = new Error("Rethrown"); | ||
p.cause = d.error, p.betterMessage = d.message, o(p); | ||
}, (c = l(this, w)) == null || c.addEventListener( | ||
"error", | ||
t | ||
); | ||
const l = this[__private__dont__use].ccall( | ||
const a = this[__private__dont__use].ccall( | ||
"wasm_sapi_handle_request", | ||
@@ -1390,7 +1394,7 @@ NUMBER, | ||
); | ||
return l instanceof Promise ? l.then(i, o) : i(l); | ||
return a instanceof Promise ? a.then(i, o) : i(a); | ||
}); | ||
} catch (i) { | ||
for (const h in this) | ||
typeof this[h] == "function" && (this[h] = () => { | ||
for (const d in this) | ||
typeof this[d] == "function" && (this[d] = () => { | ||
throw new Error( | ||
@@ -1401,6 +1405,6 @@ "PHP runtime has crashed – see the earlier error for details." | ||
this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify(); | ||
const o = i, l = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(l); | ||
const o = i, a = "betterMessage" in o ? o.betterMessage : o.message, c = new Error(a); | ||
throw c.cause = o, console.error(c), c; | ||
} finally { | ||
(n = a(this, g)) == null || n.removeEventListener("error", t), p(this, P, {}); | ||
(n = l(this, w)) == null || n.removeEventListener("error", t), h(this, g, {}); | ||
} | ||
@@ -1474,28 +1478,28 @@ const { headers: r, httpStatusCode: s } = f(this, B, te).call(this); | ||
t = normalizePath(t); | ||
const i = e[__private__dont__use].FS, o = createFSHooks(i, (d) => { | ||
if (d.path.startsWith(t)) | ||
r(d); | ||
else if (d.operation === "RENAME" && d.toPath.startsWith(t)) | ||
for (const _ of recordExistingPath( | ||
const i = e[__private__dont__use].FS, o = createFSHooks(i, (p) => { | ||
if (p.path.startsWith(t)) | ||
r(p); | ||
else if (p.operation === "RENAME" && p.toPath.startsWith(t)) | ||
for (const P of recordExistingPath( | ||
e, | ||
d.path, | ||
d.toPath | ||
p.path, | ||
p.toPath | ||
)) | ||
r(_); | ||
}), l = {}; | ||
for (const [d] of Object.entries(o)) | ||
l[d] = i[d]; | ||
r(P); | ||
}), a = {}; | ||
for (const [p] of Object.entries(o)) | ||
a[p] = i[p]; | ||
function c() { | ||
for (const [d, _] of Object.entries(o)) | ||
i[d] = function(...V) { | ||
return _(...V), l[d].apply(this, V); | ||
for (const [p, P] of Object.entries(o)) | ||
i[p] = function(...V) { | ||
return P(...V), a[p].apply(this, V); | ||
}; | ||
} | ||
function h() { | ||
for (const [d, _] of Object.entries(l)) | ||
e[__private__dont__use].FS[d] = _; | ||
function d() { | ||
for (const [p, P] of Object.entries(a)) | ||
e[__private__dont__use].FS[p] = P; | ||
} | ||
e[__private__dont__use].journal = { | ||
bind: c, | ||
unbind: h | ||
unbind: d | ||
}, c(); | ||
@@ -1502,0 +1506,0 @@ } |
{ | ||
"name": "@php-wasm/fs-journal", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "Bindings to journal the PHP filesystem", | ||
@@ -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
89816
1926