@php-wasm/node 3.1.20 → 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 +43 -13
- package/index.js +45 -13
- package/lib/get-php-loader-module.d.ts +2 -2
- package/lib/load-runtime.d.ts +2 -2
- package/package.json +15 -14
package/index.cjs
CHANGED
|
@@ -61,6 +61,8 @@ async function getPHPLoaderModule(version = import_universal.LatestSupportedPHPV
|
|
|
61
61
|
return (await import("@php-wasm/node-8-0")).getPHPLoaderModule();
|
|
62
62
|
case "7.4":
|
|
63
63
|
return (await import("@php-wasm/node-7-4")).getPHPLoaderModule();
|
|
64
|
+
case "5.2":
|
|
65
|
+
return (await import("@php-wasm/node-5-2")).getPHPLoaderModule();
|
|
64
66
|
}
|
|
65
67
|
throw new Error(`Unsupported PHP version ${version}`);
|
|
66
68
|
} catch (errorCandidate) {
|
|
@@ -1905,6 +1907,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1905
1907
|
// Otherwise, multiple workers with duplicate process IDs
|
|
1906
1908
|
// could break file locking and lead to database corruption.
|
|
1907
1909
|
(process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
|
|
1910
|
+
const isLegacy = (0, import_universal12.isLegacyPHPVersion)(phpVersion);
|
|
1908
1911
|
let emscriptenOptions = {
|
|
1909
1912
|
/**
|
|
1910
1913
|
* Emscripten default behavior is to kill the process when
|
|
@@ -1924,6 +1927,16 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1924
1927
|
},
|
|
1925
1928
|
...options.emscriptenOptions || {},
|
|
1926
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
|
+
} : {},
|
|
1927
1940
|
onRuntimeInitialized: (phpRuntime) => {
|
|
1928
1941
|
if (options?.followSymlinks === true) {
|
|
1929
1942
|
phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
|
|
@@ -1978,21 +1991,38 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1978
1991
|
phpRuntime.FS.root.mount.opts.root = ".";
|
|
1979
1992
|
}
|
|
1980
1993
|
};
|
|
1981
|
-
if (options?.withXdebug) {
|
|
1982
|
-
|
|
1983
|
-
phpVersion
|
|
1984
|
-
emscriptenOptions,
|
|
1985
|
-
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}.`
|
|
1986
1997
|
);
|
|
1987
1998
|
}
|
|
1988
|
-
if (
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
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
|
+
}
|
|
1996
2026
|
}
|
|
1997
2027
|
emscriptenOptions = await withNetworking(emscriptenOptions);
|
|
1998
2028
|
const phpLoaderModule = await getPHPLoaderModule(phpVersion);
|
package/index.js
CHANGED
|
@@ -25,6 +25,8 @@ async function getPHPLoaderModule(version = LatestSupportedPHPVersion) {
|
|
|
25
25
|
return (await import("@php-wasm/node-8-0")).getPHPLoaderModule();
|
|
26
26
|
case "7.4":
|
|
27
27
|
return (await import("@php-wasm/node-7-4")).getPHPLoaderModule();
|
|
28
|
+
case "5.2":
|
|
29
|
+
return (await import("@php-wasm/node-5-2")).getPHPLoaderModule();
|
|
28
30
|
}
|
|
29
31
|
throw new Error(`Unsupported PHP version ${version}`);
|
|
30
32
|
} catch (errorCandidate) {
|
|
@@ -391,6 +393,8 @@ import {
|
|
|
391
393
|
loadPHPRuntime,
|
|
392
394
|
FSHelpers as FSHelpers5,
|
|
393
395
|
FileLockManagerComposite,
|
|
396
|
+
createLegacyPhpIniPreRunStep,
|
|
397
|
+
isLegacyPHPVersion,
|
|
394
398
|
ProcessIdAllocator
|
|
395
399
|
} from "@php-wasm/universal";
|
|
396
400
|
|
|
@@ -1885,6 +1889,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1885
1889
|
// Otherwise, multiple workers with duplicate process IDs
|
|
1886
1890
|
// could break file locking and lead to database corruption.
|
|
1887
1891
|
(process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
|
|
1892
|
+
const isLegacy = isLegacyPHPVersion(phpVersion);
|
|
1888
1893
|
let emscriptenOptions = {
|
|
1889
1894
|
/**
|
|
1890
1895
|
* Emscripten default behavior is to kill the process when
|
|
@@ -1904,6 +1909,16 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1904
1909
|
},
|
|
1905
1910
|
...options.emscriptenOptions || {},
|
|
1906
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
|
+
} : {},
|
|
1907
1922
|
onRuntimeInitialized: (phpRuntime) => {
|
|
1908
1923
|
if (options?.followSymlinks === true) {
|
|
1909
1924
|
phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
|
|
@@ -1958,21 +1973,38 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1958
1973
|
phpRuntime.FS.root.mount.opts.root = ".";
|
|
1959
1974
|
}
|
|
1960
1975
|
};
|
|
1961
|
-
if (options?.withXdebug) {
|
|
1962
|
-
|
|
1963
|
-
phpVersion
|
|
1964
|
-
emscriptenOptions,
|
|
1965
|
-
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}.`
|
|
1966
1979
|
);
|
|
1967
1980
|
}
|
|
1968
|
-
if (
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
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
|
+
}
|
|
1976
2008
|
}
|
|
1977
2009
|
emscriptenOptions = await withNetworking(emscriptenOptions);
|
|
1978
2010
|
const phpLoaderModule = await getPHPLoaderModule(phpVersion);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
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?:
|
|
14
|
+
export declare function getPHPLoaderModule(version?: AllPHPVersion): Promise<PHPLoaderModule>;
|
package/lib/load-runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
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:
|
|
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.
|
|
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": "
|
|
41
|
+
"gitHead": "5864051cbf4c2a55656112d99a3f1b076bcd67cd",
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=20.10.0",
|
|
44
44
|
"npm": ">=10.2.3"
|
|
@@ -52,18 +52,19 @@
|
|
|
52
52
|
"wasm-feature-detect": "1.8.0",
|
|
53
53
|
"ws": "8.18.0",
|
|
54
54
|
"yargs": "17.7.2",
|
|
55
|
-
"@php-wasm/universal": "3.1.
|
|
56
|
-
"@php-wasm/node-8-5": "3.1.
|
|
57
|
-
"@php-wasm/node-8-4": "3.1.
|
|
58
|
-
"@php-wasm/node-8-3": "3.1.
|
|
59
|
-
"@php-wasm/node-8-2": "3.1.
|
|
60
|
-
"@php-wasm/node-8-1": "3.1.
|
|
61
|
-
"@php-wasm/node-8-0": "3.1.
|
|
62
|
-
"@php-wasm/node-7-4": "3.1.
|
|
63
|
-
"@php-wasm/cli-util": "3.1.
|
|
64
|
-
"@php-wasm/logger": "3.1.
|
|
65
|
-
"@php-wasm/
|
|
66
|
-
"@
|
|
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"
|
|
67
68
|
},
|
|
68
69
|
"packageManager": "npm@10.9.2",
|
|
69
70
|
"overrides": {
|