@php-wasm/node 0.1.56 → 0.1.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +12 -3
  2. package/index.d.ts +10 -2
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -67703,8 +67703,12 @@ var BasePHP2 = class {
67703
67703
  );
67704
67704
  }
67705
67705
  for (const name in headers) {
67706
+ let HTTP_prefix = "HTTP_";
67707
+ if (["content-type", "content-length"].includes(name.toLowerCase())) {
67708
+ HTTP_prefix = "";
67709
+ }
67706
67710
  this.addServerGlobalEntry(
67707
- `HTTP_${name.toUpperCase().replace(/-/g, "_")}`,
67711
+ `${HTTP_prefix}${name.toUpperCase().replace(/-/g, "_")}`,
67708
67712
  headers[name]
67709
67713
  );
67710
67714
  }
@@ -67862,14 +67866,19 @@ var BasePHP2 = class {
67862
67866
  }
67863
67867
  this[__private__dont__use].FS.rmdir(path);
67864
67868
  }
67865
- listFiles(path) {
67869
+ listFiles(path, options = { prependPath: false }) {
67866
67870
  if (!this.fileExists(path)) {
67867
67871
  return [];
67868
67872
  }
67869
67873
  try {
67870
- return this[__private__dont__use].FS.readdir(path).filter(
67874
+ const files = this[__private__dont__use].FS.readdir(path).filter(
67871
67875
  (name) => name !== "." && name !== ".."
67872
67876
  );
67877
+ if (options.prependPath) {
67878
+ const prepend = path.replace(/\/$/, "");
67879
+ return files.map((name) => `${prepend}/${name}`);
67880
+ }
67881
+ return files;
67873
67882
  } catch (e) {
67874
67883
  console.error(e, { path });
67875
67884
  return [];
package/index.d.ts CHANGED
@@ -253,9 +253,10 @@ export interface IsomorphicLocalPHP extends RequestHandler {
253
253
  * Lists the files and directories in the given directory.
254
254
  *
255
255
  * @param path - The directory path to list.
256
+ * @param options - Options for the listing.
256
257
  * @returns The list of files and directories in the given directory.
257
258
  */
258
- listFiles(path: string): string[];
259
+ listFiles(path: string, options?: ListFilesOptions): string[];
259
260
  /**
260
261
  * Checks if a directory exists in the PHP filesystem.
261
262
  *
@@ -426,6 +427,13 @@ export interface RmDirOptions {
426
427
  */
427
428
  recursive?: boolean;
428
429
  }
430
+ export interface ListFilesOptions {
431
+ /**
432
+ * If true, prepend given folder path to all file names.
433
+ * Default: false.
434
+ */
435
+ prependPath: boolean;
436
+ }
429
437
  declare const SupportedPHPVersions: readonly [
430
438
  "8.2",
431
439
  "8.1",
@@ -593,7 +601,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
593
601
  /** @inheritDoc */
594
602
  rmdir(path: string, options?: RmDirOptions): void;
595
603
  /** @inheritDoc */
596
- listFiles(path: string): string[];
604
+ listFiles(path: string, options?: ListFilesOptions): string[];
597
605
  /** @inheritDoc */
598
606
  isDir(path: string): boolean;
599
607
  /** @inheritDoc */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "PHP.wasm for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,13 +28,13 @@
28
28
  "license": "GPL-2.0-or-later",
29
29
  "main": "index.cjs",
30
30
  "types": "index.d.ts",
31
- "gitHead": "af3583eb7c6644a9859ea4782702c6e2c3474821",
31
+ "gitHead": "dbc77ed4c0b0a2625cfbe08722fade036c69a425",
32
32
  "dependencies": {
33
33
  "comlink": "^4.4.1",
34
34
  "express": "4.18.2",
35
35
  "ws": "8.13.0",
36
36
  "yargs": "17.7.2",
37
- "@php-wasm/universal": "0.1.56",
38
- "@php-wasm/util": "0.1.56"
37
+ "@php-wasm/universal": "0.1.58",
38
+ "@php-wasm/util": "0.1.58"
39
39
  }
40
40
  }