Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@php-wasm/universal

Package Overview
Dependencies
Maintainers
3
Versions
123
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.2.0 to 0.3.0

lib/supported-php-extensions.d.ts

213

index.js

@@ -1,2 +0,2 @@

const v = Symbol("error"), _ = Symbol("message");
const v = Symbol("error"), E = Symbol("message");
class b extends Event {

@@ -11,3 +11,3 @@ /**

constructor(e, t = {}) {
super(e), this[v] = t.error === void 0 ? null : t.error, this[_] = t.message === void 0 ? "" : t.message;
super(e), this[v] = t.error === void 0 ? null : t.error, this[E] = t.message === void 0 ? "" : t.message;
}

@@ -18,3 +18,3 @@ get error() {

get message() {
return this[_];
return this[E];
}

@@ -24,7 +24,7 @@ }

Object.defineProperty(b.prototype, "message", { enumerable: !0 });
const A = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : b;
const U = typeof globalThis.ErrorEvent == "function" ? globalThis.ErrorEvent : b;
function I(s) {
return s instanceof Error ? "exitCode" in s && s?.exitCode === 0 || s?.name === "ExitStatus" && "status" in s && s.status === 0 : !1;
}
class N extends EventTarget {
class L extends EventTarget {
constructor() {

@@ -43,7 +43,7 @@ super(...arguments), this.listenersCount = 0;

}
function $(s) {
function N(s) {
s.asm = {
...s.asm
};
const e = new N();
const e = new L();
for (const t in s.asm)

@@ -64,3 +64,3 @@ if (typeof s.asm[t] == "function") {

e.dispatchEvent(
new A("error", {
new U("error", {
error: o,

@@ -72,3 +72,3 @@ message: i

}
throw I(o) || q(i), o;
throw I(o) || D(i), o;
}

@@ -80,3 +80,3 @@ };

let w = [];
function L() {
function $() {
return w;

@@ -86,3 +86,3 @@ }

if (s.message === "unreachable") {
let t = B;
let t = q;
e || (t += `

@@ -103,3 +103,3 @@

}
const B = `
const q = `
"unreachable" WASM instruction executed.

@@ -128,12 +128,12 @@

`, E = "\x1B[41m", D = "\x1B[1m", R = "\x1B[0m", S = "\x1B[K";
let x = !1;
function q(s) {
if (!x) {
x = !0, console.log(`${E}
${S}
${D} WASM ERROR${R}${E}`);
`, _ = "\x1B[41m", B = "\x1B[1m", R = "\x1B[0m", x = "\x1B[K";
let S = !1;
function D(s) {
if (!S) {
S = !0, console.log(`${_}
${x}
${B} WASM ERROR${R}${_}`);
for (const e of s.split(`
`))
console.log(`${S} ${e} `);
console.log(`${x} ${e} `);
console.log(`${R}`);

@@ -194,3 +194,3 @@ }

}
const H = [
const F = [
"8.2",

@@ -205,4 +205,11 @@ "8.1",

"5.6"
], re = H[0], se = H;
class j {
], ie = F[0], ae = F, j = [
"iconv",
"mbstring",
"xml-bundle",
"gd"
], le = {
"kitchen-sink": j
};
class z {
#e;

@@ -293,3 +300,3 @@ #t;

}
class z {
class G {
constructor({ concurrency: e }) {

@@ -322,13 +329,13 @@ this._running = 0, this.concurrency = e, this.queue = [];

}
const G = "http://example.com";
function T(s) {
const V = "http://example.com";
function k(s) {
return s.toString().substring(s.origin.length);
}
function k(s, e) {
function H(s, e) {
return !e || !s.startsWith(e) ? s : s.substring(e.length);
}
function V(s, e) {
function Y(s, e) {
return !e || s.startsWith(e) ? s : e + s;
}
class Y {
class J {
#e;

@@ -342,3 +349,2 @@ #t;

#a;
#l;
/**

@@ -349,16 +355,15 @@ * @param php - The PHP instance.

constructor(e, t = {}) {
this.#a = new z({ concurrency: 1 });
this.#a = new G({ concurrency: 1 });
const {
documentRoot: r = "/www/",
absoluteUrl: n = typeof location == "object" ? location?.href : "",
isStaticFilePath: o = () => !1
absoluteUrl: n = typeof location == "object" ? location?.href : ""
} = t;
this.php = e, this.#e = r, this.#l = o;
const i = new URL(n);
this.#s = i.hostname, this.#r = i.port ? Number(i.port) : i.protocol === "https:" ? 443 : 80, this.#t = (i.protocol || "").replace(":", "");
const l = this.#r !== 443 && this.#r !== 80;
this.php = e, this.#e = r;
const o = new URL(n);
this.#s = o.hostname, this.#r = o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80, this.#t = (o.protocol || "").replace(":", "");
const i = this.#r !== 443 && this.#r !== 80;
this.#o = [
this.#s,
l ? `:${this.#r}` : ""
].join(""), this.#n = i.pathname.replace(/\/+$/, ""), this.#i = [
i ? `:${this.#r}` : ""
].join(""), this.#n = o.pathname.replace(/\/+$/, ""), this.#i = [
`${this.#t}://`,

@@ -376,3 +381,3 @@ this.#o,

const t = new URL(e);
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)), T(t);
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)), k(t);
}

@@ -394,8 +399,8 @@ get isRequestRunning() {

e.url,
t ? void 0 : G
), n = k(
t ? void 0 : V
), n = H(
r.pathname,
this.#n
);
return this.#l(n) ? this.#c(n) : await this.#h(e, r);
), o = `${this.#e}${n}`;
return Q(o) ? await this.#c(e, r) : this.#l(o);
}

@@ -405,26 +410,29 @@ /**

*
* @param path - The requested static file path.
* @param fsPath - Absolute path of the static file to serve.
* @returns The response.
*/
#c(e) {
const t = `${this.#e}${e}`;
if (!this.php.fileExists(t))
#l(e) {
if (!this.php.fileExists(e))
return new g(
404,
{},
// Let the service worker know that no static file was found
// and that it's okay to issue a real fetch() to the server.
{
"x-file-type": ["static"]
},
new TextEncoder().encode("404 File not found")
);
const r = this.php.readFileAsBuffer(t);
const t = this.php.readFileAsBuffer(e);
return new g(
200,
{
"content-length": [`${r.byteLength}`],
"content-length": [`${t.byteLength}`],
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
// The code below won't return the correct mime-type if the extension
// was tampered with.
"content-type": [K(t)],
"content-type": [Z(e)],
"accept-ranges": ["bytes"],
"cache-control": ["public, max-age=0"]
},
r
t
);

@@ -439,3 +447,3 @@ }

*/
async #h(e, t) {
async #c(e, t) {
const r = await this.#a.acquire();

@@ -450,3 +458,3 @@ try {

host: this.#o,
...U(e.headers || {})
...A(e.headers || {})
}, i = [];

@@ -464,3 +472,3 @@ if (e.files && Object.keys(e.files).length) {

}
o["content-type"]?.startsWith("multipart/form-data") && (e.formData = J(
o["content-type"]?.startsWith("multipart/form-data") && (e.formData = K(
e.body || ""

@@ -475,3 +483,3 @@ ), o["content-type"] = "application/x-www-form-urlencoded", delete e.body);

try {
h = this.#u(t.pathname);
h = this.#h(t.pathname);
} catch {

@@ -485,4 +493,4 @@ return new g(

return await this.php.run({
relativeUri: V(
T(t),
relativeUri: Y(
k(t),
this.#n

@@ -510,4 +518,4 @@ ),

*/
#u(e) {
let t = k(e, this.#n);
#h(e) {
let t = H(e, this.#n);
t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php"));

@@ -522,3 +530,3 @@ const r = `${this.#e}${t}`;

}
function J(s) {
function K(s) {
const e = {}, t = s.match(/--(.*)\r\n/);

@@ -538,3 +546,3 @@ if (!t)

}
function K(s) {
function Z(s) {
switch (s.split(".").pop()) {

@@ -579,3 +587,12 @@ case "css":

}
const C = {
function Q(s) {
return X(s) || ee(s);
}
function X(s) {
return s.endsWith(".php") || s.includes(".php/");
}
function ee(s) {
return !s.split("/").pop().includes(".");
}
const T = {
0: "No error occurred. System call completed successfully.",

@@ -667,4 +684,4 @@ 1: "Argument list too long.",

const h = typeof l == "object" ? l?.errno : null;
if (h in C) {
const c = C[h], m = typeof i[0] == "string" ? i[0] : null, O = m !== null ? s.replaceAll("{path}", m) : s;
if (h in T) {
const c = T[h], m = typeof i[0] == "string" ? i[0] : null, O = m !== null ? s.replaceAll("{path}", m) : s;
throw new Error(`${O}: ${c}`, {

@@ -679,4 +696,4 @@ cause: l

}
async function ne(s, e = {}, t = []) {
const [r, n, o] = F(), [i, l] = F(), h = s.init(Q, {
async function ce(s, e = {}, t = []) {
const [r, n, o] = C(), [i, l] = C(), h = s.init(re, {
onAbort(c) {

@@ -706,8 +723,8 @@ o(c), l(), console.error(c);

const P = [];
function Z(s) {
function te(s) {
return P[s];
}
const Q = function() {
const re = function() {
return typeof process < "u" && process.release?.name === "node" ? "NODE" : typeof window < "u" ? "WEB" : typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope ? "WORKER" : "NODE";
}(), F = () => {
}(), C = () => {
const s = [], e = new Promise((t, r) => {

@@ -718,6 +735,6 @@ s.push(t, r);

};
var X = Object.defineProperty, ee = Object.getOwnPropertyDescriptor, f = (s, e, t, r) => {
for (var n = r > 1 ? void 0 : r ? ee(e, t) : e, o = s.length - 1, i; o >= 0; o--)
var se = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, f = (s, e, t, r) => {
for (var n = r > 1 ? void 0 : r ? ne(e, t) : e, o = s.length - 1, i; o >= 0; o--)
(i = s[o]) && (n = (r ? i(e, t, n) : i(n)) || n);
return r && n && X(e, t, n), n;
return r && n && se(e, t, n), n;
};

@@ -734,4 +751,4 @@ const u = "string", y = "number", a = Symbol("__private__dont__use");

constructor(e, t) {
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, this.#o = [], e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new j(
new Y(this, t)
this.#e = [], this.#t = !1, this.#s = null, this.#r = {}, this.#o = [], e !== void 0 && this.initializeRuntime(e), t && (this.requestHandler = new z(
new J(this, t)
));

@@ -769,3 +786,3 @@ }

throw new Error("PHP runtime already initialized.");
const t = Z(e);
const t = te(e);
if (!t)

@@ -776,3 +793,3 @@ throw new Error("Invalid PHP runtime id.");

n(r);
}, this.#s = $(t);
}, this.#s = N(t);
}

@@ -811,3 +828,3 @@ /** @inheritDoc */

host: "example.com:443",
...U(e.headers || {})
...A(e.headers || {})
};

@@ -1007,3 +1024,3 @@ if (this.#l(t, e.protocol || "http"), this.#h(r), e.body && this.#u(e.body), e.fileInfos)

});
this.functionsMaybeMissingFromAsyncify = L();
this.functionsMaybeMissingFromAsyncify = $();
const i = o, l = "betterMessage" in i ? i.betterMessage : i.message, h = new Error(l);

@@ -1112,3 +1129,3 @@ throw h.cause = i, h;

], d.prototype, "fileExists", 1);
function U(s) {
function A(s) {
const e = {};

@@ -1119,27 +1136,29 @@ for (const t in s)

}
function te(s) {
function oe(s) {
return !(s instanceof d);
}
function oe(s) {
return !te(s);
function he(s) {
return !oe(s);
}
export {
d as BasePHP,
G as DEFAULT_BASE_URL,
re as LatestSupportedPHPVersion,
j as PHPBrowser,
Y as PHPRequestHandler,
V as DEFAULT_BASE_URL,
ie as LatestSupportedPHPVersion,
z as PHPBrowser,
J as PHPRequestHandler,
g as PHPResponse,
H as SupportedPHPVersions,
se as SupportedPHPVersionsList,
N as UnhandledRejectionsTarget,
le as SupportedPHPExtensionBundles,
j as SupportedPHPExtensionsList,
F as SupportedPHPVersions,
ae as SupportedPHPVersionsList,
L as UnhandledRejectionsTarget,
a as __private__dont__use,
V as ensurePathPrefix,
Y as ensurePathPrefix,
I as isExitCodeZero,
te as isLocalPHP,
oe as isRemotePHP,
ne as loadPHPRuntime,
k as removePathPrefix,
oe as isLocalPHP,
he as isRemotePHP,
ce as loadPHPRuntime,
H as removePathPrefix,
p as rethrowFileSystemError,
T as toRelativeUrl
k as toRelativeUrl
};

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

export type { SupportedPHPVersion } from './supported-php-versions';
export { SupportedPHPExtensionsList, SupportedPHPExtensionBundles, } from './supported-php-extensions';
export type { SupportedPHPExtension, SupportedPHPExtensionBundle, } from './supported-php-extensions';
export { BasePHP, __private__dont__use } from './base-php';

@@ -10,0 +12,0 @@ export { loadPHPRuntime } from './load-php-runtime';

@@ -14,7 +14,2 @@ import { BasePHP } from './base-php';

absoluteUrl?: string;
/**
* Callback used by the PHPRequestHandler to decide whether
* the requested path refers to a PHP file or a static file.
*/
isStaticFilePath?: (path: string) => boolean;
}

@@ -45,1 +40,18 @@ /** @inheritDoc */

}
/**
* Guesses whether the given path looks like a PHP file.
*
* @example
* ```js
* seemsLikeAPHPRequestHandlerPath('/index.php') // true
* seemsLikeAPHPRequestHandlerPath('/index.php') // true
* seemsLikeAPHPRequestHandlerPath('/index.php/foo/bar') // true
* seemsLikeAPHPRequestHandlerPath('/index.html') // false
* seemsLikeAPHPRequestHandlerPath('/index.html/foo/bar') // false
* seemsLikeAPHPRequestHandlerPath('/') // true
* ```
*
* @param path The path to check.
* @returns Whether the path seems like a PHP server path.
*/
export declare function seemsLikeAPHPRequestHandlerPath(path: string): boolean;
{
"name": "@php-wasm/universal",
"version": "0.2.0",
"version": "0.3.0",
"description": "PHP.wasm – emscripten bindings for PHP",

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

"license": "GPL-2.0-or-later",
"gitHead": "cd4062de74f7f18058d3f962e124d0fdff78b5a7",
"gitHead": "6890ff9243f9a10f0b86755fead101647a8c8535",
"engines": {

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

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