@php-wasm/node 3.1.19 → 3.1.21

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.
package/index.cjs CHANGED
@@ -41,7 +41,6 @@ __export(src_exports, {
41
41
  withXdebug: () => withXdebug
42
42
  });
43
43
  module.exports = __toCommonJS(src_exports);
44
- var import_node_polyfills = require("@php-wasm/node-polyfills");
45
44
 
46
45
  // packages/php-wasm/node/src/lib/get-php-loader-module.ts
47
46
  var import_universal = require("@php-wasm/universal");
@@ -62,6 +61,8 @@ async function getPHPLoaderModule(version = import_universal.LatestSupportedPHPV
62
61
  return (await import("@php-wasm/node-8-0")).getPHPLoaderModule();
63
62
  case "7.4":
64
63
  return (await import("@php-wasm/node-7-4")).getPHPLoaderModule();
64
+ case "5.2":
65
+ return (await import("@php-wasm/node-5-2")).getPHPLoaderModule();
65
66
  }
66
67
  throw new Error(`Unsupported PHP version ${version}`);
67
68
  } catch (errorCandidate) {
@@ -1906,6 +1907,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1906
1907
  // Otherwise, multiple workers with duplicate process IDs
1907
1908
  // could break file locking and lead to database corruption.
1908
1909
  (process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
1910
+ const isLegacy = (0, import_universal12.isLegacyPHPVersion)(phpVersion);
1909
1911
  let emscriptenOptions = {
1910
1912
  /**
1911
1913
  * Emscripten default behavior is to kill the process when
@@ -1925,6 +1927,16 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1925
1927
  },
1926
1928
  ...options.emscriptenOptions || {},
1927
1929
  processId,
1930
+ // For legacy PHP: pre-create php.ini via a preRun step. See
1931
+ // createLegacyPhpIniPreRunStep for why this must run before
1932
+ // the PHP SAPI starts. Merge with any caller-provided preRun
1933
+ // hooks (the spread above may have set them).
1934
+ ...isLegacy ? {
1935
+ preRun: [
1936
+ (0, import_universal12.createLegacyPhpIniPreRunStep)(),
1937
+ ...options.emscriptenOptions?.preRun ?? []
1938
+ ]
1939
+ } : {},
1928
1940
  onRuntimeInitialized: (phpRuntime) => {
1929
1941
  if (options?.followSymlinks === true) {
1930
1942
  phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
@@ -1979,21 +1991,38 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1979
1991
  phpRuntime.FS.root.mount.opts.root = ".";
1980
1992
  }
1981
1993
  };
1982
- if (options?.withXdebug) {
1983
- emscriptenOptions = await withXdebug(
1984
- phpVersion,
1985
- emscriptenOptions,
1986
- typeof options.withXdebug === "object" ? options.withXdebug : {}
1994
+ if (isLegacy && (options?.withXdebug || options?.withIntl || options?.withRedis || options?.withMemcached)) {
1995
+ throw new Error(
1996
+ `Extensions (xdebug, intl, redis, memcached) are not available for legacy PHP ${phpVersion}.`
1987
1997
  );
1988
1998
  }
1989
- if (options?.withIntl === true) {
1990
- emscriptenOptions = await withIntl(phpVersion, emscriptenOptions);
1991
- }
1992
- if (options?.withRedis === true) {
1993
- emscriptenOptions = await withRedis(phpVersion, emscriptenOptions);
1994
- }
1995
- if (options?.withMemcached === true) {
1996
- emscriptenOptions = await withMemcached(phpVersion, emscriptenOptions);
1999
+ if (!isLegacy) {
2000
+ const modernVersion = phpVersion;
2001
+ if (options?.withXdebug) {
2002
+ emscriptenOptions = await withXdebug(
2003
+ modernVersion,
2004
+ emscriptenOptions,
2005
+ typeof options.withXdebug === "object" ? options.withXdebug : {}
2006
+ );
2007
+ }
2008
+ if (options?.withIntl === true) {
2009
+ emscriptenOptions = await withIntl(
2010
+ modernVersion,
2011
+ emscriptenOptions
2012
+ );
2013
+ }
2014
+ if (options?.withRedis === true) {
2015
+ emscriptenOptions = await withRedis(
2016
+ modernVersion,
2017
+ emscriptenOptions
2018
+ );
2019
+ }
2020
+ if (options?.withMemcached === true) {
2021
+ emscriptenOptions = await withMemcached(
2022
+ modernVersion,
2023
+ emscriptenOptions
2024
+ );
2025
+ }
1997
2026
  }
1998
2027
  emscriptenOptions = await withNetworking(emscriptenOptions);
1999
2028
  const phpLoaderModule = await getPHPLoaderModule(phpVersion);
package/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import '@php-wasm/node-polyfills';
2
1
  export * from './lib';
package/index.js CHANGED
@@ -6,9 +6,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // packages/php-wasm/node/src/index.ts
10
- import "@php-wasm/node-polyfills";
11
-
12
9
  // packages/php-wasm/node/src/lib/get-php-loader-module.ts
13
10
  import { LatestSupportedPHPVersion } from "@php-wasm/universal";
14
11
  async function getPHPLoaderModule(version = LatestSupportedPHPVersion) {
@@ -28,6 +25,8 @@ async function getPHPLoaderModule(version = LatestSupportedPHPVersion) {
28
25
  return (await import("@php-wasm/node-8-0")).getPHPLoaderModule();
29
26
  case "7.4":
30
27
  return (await import("@php-wasm/node-7-4")).getPHPLoaderModule();
28
+ case "5.2":
29
+ return (await import("@php-wasm/node-5-2")).getPHPLoaderModule();
31
30
  }
32
31
  throw new Error(`Unsupported PHP version ${version}`);
33
32
  } catch (errorCandidate) {
@@ -394,6 +393,8 @@ import {
394
393
  loadPHPRuntime,
395
394
  FSHelpers as FSHelpers5,
396
395
  FileLockManagerComposite,
396
+ createLegacyPhpIniPreRunStep,
397
+ isLegacyPHPVersion,
397
398
  ProcessIdAllocator
398
399
  } from "@php-wasm/universal";
399
400
 
@@ -1888,6 +1889,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1888
1889
  // Otherwise, multiple workers with duplicate process IDs
1889
1890
  // could break file locking and lead to database corruption.
1890
1891
  (process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
1892
+ const isLegacy = isLegacyPHPVersion(phpVersion);
1891
1893
  let emscriptenOptions = {
1892
1894
  /**
1893
1895
  * Emscripten default behavior is to kill the process when
@@ -1907,6 +1909,16 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1907
1909
  },
1908
1910
  ...options.emscriptenOptions || {},
1909
1911
  processId,
1912
+ // For legacy PHP: pre-create php.ini via a preRun step. See
1913
+ // createLegacyPhpIniPreRunStep for why this must run before
1914
+ // the PHP SAPI starts. Merge with any caller-provided preRun
1915
+ // hooks (the spread above may have set them).
1916
+ ...isLegacy ? {
1917
+ preRun: [
1918
+ createLegacyPhpIniPreRunStep(),
1919
+ ...options.emscriptenOptions?.preRun ?? []
1920
+ ]
1921
+ } : {},
1910
1922
  onRuntimeInitialized: (phpRuntime) => {
1911
1923
  if (options?.followSymlinks === true) {
1912
1924
  phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
@@ -1961,21 +1973,38 @@ async function loadNodeRuntime(phpVersion, options = {}) {
1961
1973
  phpRuntime.FS.root.mount.opts.root = ".";
1962
1974
  }
1963
1975
  };
1964
- if (options?.withXdebug) {
1965
- emscriptenOptions = await withXdebug(
1966
- phpVersion,
1967
- emscriptenOptions,
1968
- typeof options.withXdebug === "object" ? options.withXdebug : {}
1976
+ if (isLegacy && (options?.withXdebug || options?.withIntl || options?.withRedis || options?.withMemcached)) {
1977
+ throw new Error(
1978
+ `Extensions (xdebug, intl, redis, memcached) are not available for legacy PHP ${phpVersion}.`
1969
1979
  );
1970
1980
  }
1971
- if (options?.withIntl === true) {
1972
- emscriptenOptions = await withIntl(phpVersion, emscriptenOptions);
1973
- }
1974
- if (options?.withRedis === true) {
1975
- emscriptenOptions = await withRedis(phpVersion, emscriptenOptions);
1976
- }
1977
- if (options?.withMemcached === true) {
1978
- emscriptenOptions = await withMemcached(phpVersion, emscriptenOptions);
1981
+ if (!isLegacy) {
1982
+ const modernVersion = phpVersion;
1983
+ if (options?.withXdebug) {
1984
+ emscriptenOptions = await withXdebug(
1985
+ modernVersion,
1986
+ emscriptenOptions,
1987
+ typeof options.withXdebug === "object" ? options.withXdebug : {}
1988
+ );
1989
+ }
1990
+ if (options?.withIntl === true) {
1991
+ emscriptenOptions = await withIntl(
1992
+ modernVersion,
1993
+ emscriptenOptions
1994
+ );
1995
+ }
1996
+ if (options?.withRedis === true) {
1997
+ emscriptenOptions = await withRedis(
1998
+ modernVersion,
1999
+ emscriptenOptions
2000
+ );
2001
+ }
2002
+ if (options?.withMemcached === true) {
2003
+ emscriptenOptions = await withMemcached(
2004
+ modernVersion,
2005
+ emscriptenOptions
2006
+ );
2007
+ }
1979
2008
  }
1980
2009
  emscriptenOptions = await withNetworking(emscriptenOptions);
1981
2010
  const phpLoaderModule = await getPHPLoaderModule(phpVersion);
@@ -1,4 +1,4 @@
1
- import type { PHPLoaderModule, SupportedPHPVersion } from '@php-wasm/universal';
1
+ import type { AllPHPVersion, PHPLoaderModule } from '@php-wasm/universal';
2
2
  /**
3
3
  * Loads the PHP loader module for the given PHP version.
4
4
  *
@@ -11,4 +11,4 @@ import type { PHPLoaderModule, SupportedPHPVersion } from '@php-wasm/universal';
11
11
  * @param version The PHP version to load.
12
12
  * @returns The PHP loader module.
13
13
  */
14
- export declare function getPHPLoaderModule(version?: SupportedPHPVersion | string): Promise<PHPLoaderModule>;
14
+ export declare function getPHPLoaderModule(version?: AllPHPVersion): Promise<PHPLoaderModule>;
@@ -1,4 +1,4 @@
1
- import { type SupportedPHPVersion, type EmscriptenOptions, type FileLockManager } from '@php-wasm/universal';
1
+ import { type AllPHPVersion, type EmscriptenOptions, type FileLockManager } from '@php-wasm/universal';
2
2
  import type { WasmUserSpaceAPI, WasmUserSpaceContext } from './wasm-user-space';
3
3
  import { type XdebugOptions } from './extensions/xdebug/with-xdebug';
4
4
  export interface PHPLoaderOptions {
@@ -54,4 +54,4 @@ export type PHPLoaderOptionsForNode = PHPLoaderOptions & {
54
54
  *
55
55
  * @see load
56
56
  */
57
- export declare function loadNodeRuntime(phpVersion: SupportedPHPVersion, options?: PHPLoaderOptionsForNode): Promise<number>;
57
+ export declare function loadNodeRuntime(phpVersion: AllPHPVersion, options?: PHPLoaderOptionsForNode): Promise<number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "3.1.19",
3
+ "version": "3.1.21",
4
4
  "description": "PHP.wasm for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "license": "GPL-2.0-or-later",
40
40
  "types": "index.d.ts",
41
- "gitHead": "be542ee28a5966eeb28154cd8e3723db5ff9df07",
41
+ "gitHead": "5864051cbf4c2a55656112d99a3f1b076bcd67cd",
42
42
  "engines": {
43
43
  "node": ">=20.10.0",
44
44
  "npm": ">=10.2.3"
@@ -50,21 +50,21 @@
50
50
  "ini": "4.1.2",
51
51
  "jsonc-parser": "3.3.1",
52
52
  "wasm-feature-detect": "1.8.0",
53
- "ws": "8.18.3",
53
+ "ws": "8.18.0",
54
54
  "yargs": "17.7.2",
55
- "@php-wasm/node-polyfills": "3.1.19",
56
- "@php-wasm/universal": "3.1.19",
57
- "@php-wasm/node-8-5": "3.1.19",
58
- "@php-wasm/node-8-4": "3.1.19",
59
- "@php-wasm/node-8-3": "3.1.19",
60
- "@php-wasm/node-8-2": "3.1.19",
61
- "@php-wasm/node-8-1": "3.1.19",
62
- "@php-wasm/node-8-0": "3.1.19",
63
- "@php-wasm/node-7-4": "3.1.19",
64
- "@php-wasm/cli-util": "3.1.19",
65
- "@php-wasm/logger": "3.1.19",
66
- "@php-wasm/util": "3.1.19",
67
- "@wp-playground/common": "3.1.19"
55
+ "@php-wasm/universal": "3.1.21",
56
+ "@php-wasm/node-8-5": "3.1.21",
57
+ "@php-wasm/node-8-4": "3.1.21",
58
+ "@php-wasm/node-8-3": "3.1.21",
59
+ "@php-wasm/node-8-2": "3.1.21",
60
+ "@php-wasm/node-8-1": "3.1.21",
61
+ "@php-wasm/node-8-0": "3.1.21",
62
+ "@php-wasm/node-7-4": "3.1.21",
63
+ "@php-wasm/cli-util": "3.1.21",
64
+ "@php-wasm/logger": "3.1.21",
65
+ "@php-wasm/node-5-2": "3.1.21",
66
+ "@php-wasm/util": "3.1.21",
67
+ "@wp-playground/common": "3.1.21"
68
68
  },
69
69
  "packageManager": "npm@10.9.2",
70
70
  "overrides": {
@@ -76,6 +76,7 @@
76
76
  "tmp": "0.2.5",
77
77
  "form-data": "^4.0.4",
78
78
  "lodash": "^4.17.23",
79
- "glob": "^9.3.0"
79
+ "glob": "^9.3.0",
80
+ "webpackbar": "^7.0.0"
80
81
  }
81
82
  }