@php-wasm/universal
Advanced tools
Comparing version 0.1.56 to 0.1.58
39
index.js
@@ -304,6 +304,6 @@ const v = Symbol("error"), _ = Symbol("message"); | ||
const j = "http://example.com"; | ||
function k(s) { | ||
function T(s) { | ||
return s.toString().substring(s.origin.length); | ||
} | ||
function T(s, e) { | ||
function k(s, e) { | ||
return !e || !s.startsWith(e) ? s : s.substring(e.length); | ||
@@ -355,3 +355,3 @@ } | ||
const t = new URL(e); | ||
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)), k(t); | ||
return t.pathname.startsWith(this.#n) && (t.pathname = t.pathname.slice(this.#n.length)), T(t); | ||
} | ||
@@ -374,3 +374,3 @@ get isRequestRunning() { | ||
t ? void 0 : j | ||
), n = T( | ||
), n = k( | ||
r.pathname, | ||
@@ -460,3 +460,3 @@ this.#n | ||
relativeUri: z( | ||
k(t), | ||
T(t), | ||
this.#n | ||
@@ -485,3 +485,3 @@ ), | ||
#u(e) { | ||
let t = T(e, this.#n); | ||
let t = k(e, this.#n); | ||
t.includes(".php") ? t = t.split(".php")[0] + ".php" : (t.endsWith("/") || (t += "/"), t.endsWith("index.php") || (t += "index.php")); | ||
@@ -865,7 +865,9 @@ const r = `${this.#e}${t}`; | ||
); | ||
for (const t in e) | ||
this.addServerGlobalEntry( | ||
`HTTP_${t.toUpperCase().replace(/-/g, "_")}`, | ||
for (const t in e) { | ||
let r = "HTTP_"; | ||
["content-type", "content-length"].includes(t.toLowerCase()) && (r = ""), this.addServerGlobalEntry( | ||
`${r}${t.toUpperCase().replace(/-/g, "_")}`, | ||
e[t] | ||
); | ||
} | ||
} | ||
@@ -1001,11 +1003,16 @@ #h(e) { | ||
} | ||
listFiles(e) { | ||
listFiles(e, t = { prependPath: !1 }) { | ||
if (!this.fileExists(e)) | ||
return []; | ||
try { | ||
return this[a].FS.readdir(e).filter( | ||
(t) => t !== "." && t !== ".." | ||
const r = this[a].FS.readdir(e).filter( | ||
(n) => n !== "." && n !== ".." | ||
); | ||
} catch (t) { | ||
return console.error(t, { path: e }), []; | ||
if (t.prependPath) { | ||
const n = e.replace(/\/$/, ""); | ||
return r.map((o) => `${n}/${o}`); | ||
} | ||
return r; | ||
} catch (r) { | ||
return console.error(r, { path: e }), []; | ||
} | ||
@@ -1086,5 +1093,5 @@ } | ||
re as loadPHPRuntime, | ||
T as removePathPrefix, | ||
k as removePathPrefix, | ||
p as rethrowFileSystemError, | ||
k as toRelativeUrl | ||
T as toRelativeUrl | ||
}; |
@@ -5,3 +5,3 @@ import { PHPBrowser } from './php-browser'; | ||
import type { PHPRuntimeId } from './load-php-runtime'; | ||
import { IsomorphicLocalPHP, PHPRequest, PHPRunOptions, RmDirOptions } from './universal-php'; | ||
import { IsomorphicLocalPHP, PHPRequest, PHPRunOptions, RmDirOptions, ListFilesOptions } from './universal-php'; | ||
export declare const __private__dont__use: unique symbol; | ||
@@ -65,3 +65,3 @@ /** | ||
/** @inheritDoc */ | ||
listFiles(path: string): string[]; | ||
listFiles(path: string, options?: ListFilesOptions): string[]; | ||
/** @inheritDoc */ | ||
@@ -68,0 +68,0 @@ isDir(path: string): boolean; |
@@ -1,2 +0,2 @@ | ||
export type { FileInfo, IsomorphicLocalPHP, IsomorphicRemotePHP, PHPOutput, PHPRunOptions, UniversalPHP, RmDirOptions, HTTPMethod, PHPRequest, PHPRequestHeaders, RequestHandler, } from './universal-php'; | ||
export type { FileInfo, IsomorphicLocalPHP, IsomorphicRemotePHP, PHPOutput, PHPRunOptions, UniversalPHP, ListFilesOptions, RmDirOptions, HTTPMethod, PHPRequest, PHPRequestHeaders, RequestHandler, } from './universal-php'; | ||
export { UnhandledRejectionsTarget } from './wasm-error-reporting'; | ||
@@ -3,0 +3,0 @@ export { PHPResponse } from './php-response'; |
@@ -209,5 +209,6 @@ import { Remote } from 'comlink'; | ||
* @param path - The directory path to list. | ||
* @param options - Options for the listing. | ||
* @returns The list of files and directories in the given directory. | ||
*/ | ||
listFiles(path: string): string[]; | ||
listFiles(path: string, options?: ListFilesOptions): string[]; | ||
/** | ||
@@ -396,1 +397,8 @@ * Checks if a directory exists in the PHP filesystem. | ||
} | ||
export interface ListFilesOptions { | ||
/** | ||
* If true, prepend given folder path to all file names. | ||
* Default: false. | ||
*/ | ||
prependPath: boolean; | ||
} |
{ | ||
"name": "@php-wasm/universal", | ||
"version": "0.1.56", | ||
"version": "0.1.58", | ||
"description": "PHP.wasm – emscripten bindings for PHP", | ||
@@ -39,3 +39,3 @@ "repository": { | ||
"license": "GPL-2.0-or-later", | ||
"gitHead": "af3583eb7c6644a9859ea4782702c6e2c3474821" | ||
"gitHead": "dbc77ed4c0b0a2625cfbe08722fade036c69a425" | ||
} |
Sorry, the diff of this file is not supported yet
78130
2084