@php-wasm/fs-journal
Advanced tools
Comparing version 0.6.15 to 0.6.16
108
index.js
@@ -9,3 +9,3 @@ var Y = (e, t, r) => { | ||
t instanceof WeakSet ? t.add(e) : t.set(e, r); | ||
}, h = (e, t, r, s) => (Y(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r); | ||
}, p = (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); | ||
@@ -426,3 +426,3 @@ const currentJsRuntime = function() { | ||
u(this, T, void 0); | ||
this.requestHandler = t, h(this, v, {}), h(this, T, { | ||
this.requestHandler = t, p(this, v, {}), p(this, T, { | ||
handleRedirects: !1, | ||
@@ -584,3 +584,3 @@ maxRedirects: 4, | ||
u(this, b, void 0); | ||
h(this, b, new Semaphore({ concurrency: 1 })); | ||
p(this, b, new Semaphore({ concurrency: 1 })); | ||
const { | ||
@@ -591,10 +591,10 @@ documentRoot: s = "/www/", | ||
} = r; | ||
this.php = t, h(this, m, s); | ||
this.php = t, p(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(":", "")); | ||
p(this, N, o.hostname), p(this, R, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), p(this, F, (o.protocol || "").replace(":", "")); | ||
const a = l(this, R) !== 443 && l(this, R) !== 80; | ||
h(this, x, [ | ||
p(this, x, [ | ||
l(this, N), | ||
a ? `:${l(this, R)}` : "" | ||
].join("")), h(this, _, o.pathname.replace(/\/+$/, "")), h(this, C, [ | ||
].join("")), p(this, _, o.pathname.replace(/\/+$/, "")), p(this, C, [ | ||
`${l(this, F)}://`, | ||
@@ -690,4 +690,4 @@ l(this, x), | ||
i = "POST"; | ||
const { bytes: d, contentType: p } = await encodeAsMultipart(a); | ||
a = d, o["content-type"] = p; | ||
const { bytes: d, contentType: h } = await encodeAsMultipart(a); | ||
a = d, o["content-type"] = h; | ||
} | ||
@@ -704,13 +704,20 @@ let c; | ||
} | ||
return await this.php.run({ | ||
relativeUri: ensurePathPrefix( | ||
toRelativeUrl(r), | ||
l(this, _) | ||
), | ||
protocol: l(this, F), | ||
method: t.method || i, | ||
body: a, | ||
scriptPath: c, | ||
headers: o | ||
}); | ||
try { | ||
return await this.php.run({ | ||
relativeUri: ensurePathPrefix( | ||
toRelativeUrl(r), | ||
l(this, _) | ||
), | ||
protocol: l(this, F), | ||
method: t.method || i, | ||
body: a, | ||
scriptPath: c, | ||
headers: o | ||
}); | ||
} catch (d) { | ||
const h = d; | ||
if (h != null && h.response) | ||
return h.response; | ||
throw d; | ||
} | ||
} finally { | ||
@@ -875,3 +882,3 @@ s(); | ||
if (c in FileErrorCodes) { | ||
const d = FileErrorCodes[c], p = typeof o[0] == "string" ? o[0] : null, P = p !== null ? e.replaceAll("{path}", p) : e; | ||
const d = FileErrorCodes[c], h = typeof o[0] == "string" ? o[0] : null, P = h !== null ? e.replaceAll("{path}", h) : e; | ||
throw new Error(`${P}: ${d}`, { | ||
@@ -900,2 +907,7 @@ cause: a | ||
const STRING = "string", NUMBER = "number", __private__dont__use = Symbol("__private__dont__use"); | ||
class PHPExecutionFailureError extends Error { | ||
constructor(t, r, s) { | ||
super(t), this.response = r, this.source = s; | ||
} | ||
} | ||
var S, k, A, y, w, g, E, H, M, ee, B, te, L, re, D, se, q, ne, $, ie, W, oe, j, ae, z, le, G, ce, J, ue, Q, de; | ||
@@ -931,3 +943,3 @@ class BasePHP { | ||
u(this, H, void 0); | ||
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( | ||
p(this, S, []), p(this, y, !1), p(this, w, null), p(this, g, {}), p(this, E, /* @__PURE__ */ new Map()), p(this, H, []), this.semaphore = new Semaphore({ concurrency: 1 }), e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new PHPBrowser( | ||
new PHPRequestHandler(this, t) | ||
@@ -988,3 +1000,3 @@ )); | ||
return ""; | ||
}, h(this, w, improveWASMErrorReporting(t)), this.dispatchEvent({ | ||
}, p(this, w, improveWASMErrorReporting(t)), this.dispatchEvent({ | ||
type: "runtime.initialized" | ||
@@ -1004,3 +1016,3 @@ }); | ||
); | ||
h(this, A, e); | ||
p(this, A, e); | ||
} | ||
@@ -1011,3 +1023,3 @@ /** @inheritDoc */ | ||
throw new Error("Cannot set PHP ini path after calling run()."); | ||
h(this, k, e), this[__private__dont__use].ccall( | ||
p(this, k, e), this[__private__dont__use].ccall( | ||
"wasm_set_phpini_path", | ||
@@ -1040,3 +1052,3 @@ null, | ||
try { | ||
if (l(this, y) || (f(this, M, ee).call(this), h(this, y, !0)), e.scriptPath && !this.fileExists(e.scriptPath)) | ||
if (l(this, y) || (f(this, M, ee).call(this), p(this, y, !0)), e.scriptPath && !this.fileExists(e.scriptPath)) | ||
throw new Error( | ||
@@ -1054,6 +1066,8 @@ `The script path "${e.scriptPath}" does not exist.` | ||
console.warn("PHP.run() output was:", o.text); | ||
const a = new Error( | ||
`PHP.run() failed with exit code ${o.exitCode} and the following output: ` + o.errors | ||
const a = new PHPExecutionFailureError( | ||
`PHP.run() failed with exit code ${o.exitCode} and the following output: ` + o.errors, | ||
o, | ||
"request" | ||
); | ||
throw a.response = o, a.source = "request", console.error(a), a; | ||
throw console.error(a), a; | ||
} | ||
@@ -1188,3 +1202,3 @@ return o; | ||
} | ||
h(this, y, !1), h(this, w, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use]; | ||
p(this, y, !1), p(this, w, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use]; | ||
} | ||
@@ -1358,4 +1372,4 @@ } | ||
console.error(d), console.error(d.error); | ||
const p = new Error("Rethrown"); | ||
p.cause = d.error, p.betterMessage = d.message, o(p); | ||
const h = new Error("Rethrown"); | ||
h.cause = d.error, h.betterMessage = d.message, o(h); | ||
}, (c = l(this, w)) == null || c.addEventListener( | ||
@@ -1385,7 +1399,7 @@ "error", | ||
} finally { | ||
(n = l(this, w)) == null || n.removeEventListener("error", t), h(this, g, {}); | ||
(n = l(this, w)) == null || n.removeEventListener("error", t), p(this, g, {}); | ||
} | ||
const { headers: r, httpStatusCode: s } = f(this, B, te).call(this); | ||
return new PHPResponse( | ||
s, | ||
e === 0 ? s : 500, | ||
r, | ||
@@ -1455,24 +1469,24 @@ this.readFileAsBuffer("/internal/stdout"), | ||
t = normalizePath(t); | ||
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)) | ||
const i = e[__private__dont__use].FS, o = createFSHooks(i, (h) => { | ||
if (h.path.startsWith(t)) | ||
r(h); | ||
else if (h.operation === "RENAME" && h.toPath.startsWith(t)) | ||
for (const P of recordExistingPath( | ||
e, | ||
p.path, | ||
p.toPath | ||
h.path, | ||
h.toPath | ||
)) | ||
r(P); | ||
}), a = {}; | ||
for (const [p] of Object.entries(o)) | ||
a[p] = i[p]; | ||
for (const [h] of Object.entries(o)) | ||
a[h] = i[h]; | ||
function c() { | ||
for (const [p, P] of Object.entries(o)) | ||
i[p] = function(...V) { | ||
return P(...V), a[p].apply(this, V); | ||
for (const [h, P] of Object.entries(o)) | ||
i[h] = function(...V) { | ||
return P(...V), a[h].apply(this, V); | ||
}; | ||
} | ||
function d() { | ||
for (const [p, P] of Object.entries(a)) | ||
e[__private__dont__use].FS[p] = P; | ||
for (const [h, P] of Object.entries(a)) | ||
e[__private__dont__use].FS[h] = P; | ||
} | ||
@@ -1479,0 +1493,0 @@ e[__private__dont__use].journal = { |
{ | ||
"name": "@php-wasm/fs-journal", | ||
"version": "0.6.15", | ||
"version": "0.6.16", | ||
"description": "Bindings to journal the PHP filesystem", | ||
@@ -39,3 +39,3 @@ "repository": { | ||
"license": "GPL-2.0-or-later", | ||
"gitHead": "e05126da329a26535905b0ab65415d20118f0197", | ||
"gitHead": "1981567e7eacecbc4a18c870267c20bf489afd8f", | ||
"engines": { | ||
@@ -42,0 +42,0 @@ "node": ">=18.18.0", |
Sorry, the diff of this file is not supported yet
90558
1943