@php-wasm/node 3.1.1 → 3.1.3
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 +33 -13
- package/index.js +41 -15
- package/lib/extensions/xdebug/with-xdebug.d.ts +8 -2
- package/lib/load-runtime.d.ts +1 -2
- package/package.json +17 -14
package/index.cjs
CHANGED
|
@@ -1564,6 +1564,7 @@ var FileLockManagerForWindows = class {
|
|
|
1564
1564
|
};
|
|
1565
1565
|
|
|
1566
1566
|
// packages/php-wasm/node/src/lib/extensions/xdebug/with-xdebug.ts
|
|
1567
|
+
var import_cli_util = require("@php-wasm/cli-util");
|
|
1567
1568
|
var import_universal5 = require("@php-wasm/universal");
|
|
1568
1569
|
var import_fs = __toESM(require("fs"), 1);
|
|
1569
1570
|
|
|
@@ -1623,26 +1624,39 @@ async function withXdebug(version = import_universal5.LatestSupportedPHPVersion,
|
|
|
1623
1624
|
phpRuntime.FS,
|
|
1624
1625
|
"/internal/shared/extensions/xdebug.ini"
|
|
1625
1626
|
)) {
|
|
1626
|
-
const ideKey = xdebugOptions
|
|
1627
|
+
const ideKey = xdebugOptions.ideKey || import_cli_util.DEFAULT_IDE_KEY;
|
|
1627
1628
|
phpRuntime.FS.writeFile(
|
|
1628
1629
|
"/internal/shared/extensions/xdebug.ini",
|
|
1629
1630
|
[
|
|
1630
1631
|
"zend_extension=/internal/shared/extensions/xdebug.so",
|
|
1631
1632
|
"xdebug.mode=debug,develop",
|
|
1632
1633
|
"xdebug.start_with_request=yes",
|
|
1633
|
-
`xdebug.idekey="${ideKey}"
|
|
1634
|
+
`xdebug.idekey="${ideKey}"`,
|
|
1635
|
+
// Path mapping is only available starting
|
|
1636
|
+
// from Xdebug 3.5, which is used by PHP 8.5+
|
|
1637
|
+
// Previous versions will ignore this entry.
|
|
1638
|
+
"xdebug.path_mapping=yes"
|
|
1634
1639
|
].join("\n")
|
|
1635
1640
|
);
|
|
1636
1641
|
}
|
|
1637
|
-
const
|
|
1638
|
-
if (
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1642
|
+
const isPHP85orHigher = import_universal5.SupportedPHPVersionsList.indexOf(version) <= import_universal5.SupportedPHPVersions.indexOf("8.5");
|
|
1643
|
+
if (isPHP85orHigher) {
|
|
1644
|
+
const { pathMappings, pathSkippings } = xdebugOptions;
|
|
1645
|
+
if (!pathMappings && !pathSkippings)
|
|
1646
|
+
return;
|
|
1647
|
+
phpRuntime.FS.mkdir("/.xdebug");
|
|
1648
|
+
if (pathMappings) {
|
|
1649
|
+
phpRuntime.FS.writeFile(
|
|
1650
|
+
"/.xdebug/path.map",
|
|
1651
|
+
pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n")
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1654
|
+
if (pathSkippings) {
|
|
1655
|
+
phpRuntime.FS.writeFile(
|
|
1656
|
+
"/.xdebug/skip.map",
|
|
1657
|
+
pathSkippings.map((path2) => `${path2} = SKIP`).join("\n")
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1646
1660
|
}
|
|
1647
1661
|
}
|
|
1648
1662
|
};
|
|
@@ -1881,7 +1895,12 @@ async function withMemcached(version = import_universal11.LatestSupportedPHPVers
|
|
|
1881
1895
|
// packages/php-wasm/node/src/lib/load-runtime.ts
|
|
1882
1896
|
var import_util = require("@php-wasm/util");
|
|
1883
1897
|
var import_os = require("os");
|
|
1898
|
+
var dangerousDefaultProcessIdAllocator = process.env.VITEST ? new import_universal12.ProcessIdAllocator() : void 0;
|
|
1884
1899
|
async function loadNodeRuntime(phpVersion, options = {}) {
|
|
1900
|
+
const processId = options.emscriptenOptions?.processId ?? // !! Only assign a default process ID during test.
|
|
1901
|
+
// Otherwise, multiple workers with duplicate process IDs
|
|
1902
|
+
// could break file locking and lead to database corruption.
|
|
1903
|
+
(process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
|
|
1885
1904
|
let emscriptenOptions = {
|
|
1886
1905
|
/**
|
|
1887
1906
|
* Emscripten default behavior is to kill the process when
|
|
@@ -1900,6 +1919,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1900
1919
|
return bindUserSpace({ fileLockManager }, userSpaceContext);
|
|
1901
1920
|
},
|
|
1902
1921
|
...options.emscriptenOptions || {},
|
|
1922
|
+
processId,
|
|
1903
1923
|
onRuntimeInitialized: (phpRuntime) => {
|
|
1904
1924
|
if (options?.followSymlinks === true) {
|
|
1905
1925
|
phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
|
|
@@ -1952,11 +1972,11 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1952
1972
|
phpRuntime.FS.root.mount.opts.root = ".";
|
|
1953
1973
|
}
|
|
1954
1974
|
};
|
|
1955
|
-
if (options?.withXdebug
|
|
1975
|
+
if (options?.withXdebug) {
|
|
1956
1976
|
emscriptenOptions = await withXdebug(
|
|
1957
1977
|
phpVersion,
|
|
1958
1978
|
emscriptenOptions,
|
|
1959
|
-
options.
|
|
1979
|
+
typeof options.withXdebug === "object" ? options.withXdebug : {}
|
|
1960
1980
|
);
|
|
1961
1981
|
}
|
|
1962
1982
|
if (options?.withIntl === true) {
|
package/index.js
CHANGED
|
@@ -393,7 +393,8 @@ async function withNetworking(phpModuleArgs = {}) {
|
|
|
393
393
|
import {
|
|
394
394
|
loadPHPRuntime,
|
|
395
395
|
FSHelpers as FSHelpers5,
|
|
396
|
-
FileLockManagerComposite
|
|
396
|
+
FileLockManagerComposite,
|
|
397
|
+
ProcessIdAllocator
|
|
397
398
|
} from "@php-wasm/universal";
|
|
398
399
|
|
|
399
400
|
// packages/php-wasm/node/src/lib/wasm-user-space.ts
|
|
@@ -1541,7 +1542,13 @@ var FileLockManagerForWindows = class {
|
|
|
1541
1542
|
};
|
|
1542
1543
|
|
|
1543
1544
|
// packages/php-wasm/node/src/lib/extensions/xdebug/with-xdebug.ts
|
|
1544
|
-
import {
|
|
1545
|
+
import { DEFAULT_IDE_KEY } from "@php-wasm/cli-util";
|
|
1546
|
+
import {
|
|
1547
|
+
FSHelpers,
|
|
1548
|
+
LatestSupportedPHPVersion as LatestSupportedPHPVersion3,
|
|
1549
|
+
SupportedPHPVersions,
|
|
1550
|
+
SupportedPHPVersionsList
|
|
1551
|
+
} from "@php-wasm/universal";
|
|
1545
1552
|
import fs from "fs";
|
|
1546
1553
|
|
|
1547
1554
|
// packages/php-wasm/node/src/lib/extensions/xdebug/get-xdebug-extension-module.ts
|
|
@@ -1600,26 +1607,39 @@ async function withXdebug(version = LatestSupportedPHPVersion3, options, xdebugO
|
|
|
1600
1607
|
phpRuntime.FS,
|
|
1601
1608
|
"/internal/shared/extensions/xdebug.ini"
|
|
1602
1609
|
)) {
|
|
1603
|
-
const ideKey = xdebugOptions
|
|
1610
|
+
const ideKey = xdebugOptions.ideKey || DEFAULT_IDE_KEY;
|
|
1604
1611
|
phpRuntime.FS.writeFile(
|
|
1605
1612
|
"/internal/shared/extensions/xdebug.ini",
|
|
1606
1613
|
[
|
|
1607
1614
|
"zend_extension=/internal/shared/extensions/xdebug.so",
|
|
1608
1615
|
"xdebug.mode=debug,develop",
|
|
1609
1616
|
"xdebug.start_with_request=yes",
|
|
1610
|
-
`xdebug.idekey="${ideKey}"
|
|
1617
|
+
`xdebug.idekey="${ideKey}"`,
|
|
1618
|
+
// Path mapping is only available starting
|
|
1619
|
+
// from Xdebug 3.5, which is used by PHP 8.5+
|
|
1620
|
+
// Previous versions will ignore this entry.
|
|
1621
|
+
"xdebug.path_mapping=yes"
|
|
1611
1622
|
].join("\n")
|
|
1612
1623
|
);
|
|
1613
1624
|
}
|
|
1614
|
-
const
|
|
1615
|
-
if (
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1625
|
+
const isPHP85orHigher = SupportedPHPVersionsList.indexOf(version) <= SupportedPHPVersions.indexOf("8.5");
|
|
1626
|
+
if (isPHP85orHigher) {
|
|
1627
|
+
const { pathMappings, pathSkippings } = xdebugOptions;
|
|
1628
|
+
if (!pathMappings && !pathSkippings)
|
|
1629
|
+
return;
|
|
1630
|
+
phpRuntime.FS.mkdir("/.xdebug");
|
|
1631
|
+
if (pathMappings) {
|
|
1632
|
+
phpRuntime.FS.writeFile(
|
|
1633
|
+
"/.xdebug/path.map",
|
|
1634
|
+
pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n")
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
if (pathSkippings) {
|
|
1638
|
+
phpRuntime.FS.writeFile(
|
|
1639
|
+
"/.xdebug/skip.map",
|
|
1640
|
+
pathSkippings.map((path2) => `${path2} = SKIP`).join("\n")
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1623
1643
|
}
|
|
1624
1644
|
}
|
|
1625
1645
|
};
|
|
@@ -1857,7 +1877,12 @@ async function withMemcached(version = LatestSupportedPHPVersion9, options) {
|
|
|
1857
1877
|
// packages/php-wasm/node/src/lib/load-runtime.ts
|
|
1858
1878
|
import { dirname, joinPaths, toPosixPath } from "@php-wasm/util";
|
|
1859
1879
|
import { platform } from "os";
|
|
1880
|
+
var dangerousDefaultProcessIdAllocator = process.env.VITEST ? new ProcessIdAllocator() : void 0;
|
|
1860
1881
|
async function loadNodeRuntime(phpVersion, options = {}) {
|
|
1882
|
+
const processId = options.emscriptenOptions?.processId ?? // !! Only assign a default process ID during test.
|
|
1883
|
+
// Otherwise, multiple workers with duplicate process IDs
|
|
1884
|
+
// could break file locking and lead to database corruption.
|
|
1885
|
+
(process.env.VITEST ? dangerousDefaultProcessIdAllocator.claim() : void 0);
|
|
1861
1886
|
let emscriptenOptions = {
|
|
1862
1887
|
/**
|
|
1863
1888
|
* Emscripten default behavior is to kill the process when
|
|
@@ -1876,6 +1901,7 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1876
1901
|
return bindUserSpace({ fileLockManager }, userSpaceContext);
|
|
1877
1902
|
},
|
|
1878
1903
|
...options.emscriptenOptions || {},
|
|
1904
|
+
processId,
|
|
1879
1905
|
onRuntimeInitialized: (phpRuntime) => {
|
|
1880
1906
|
if (options?.followSymlinks === true) {
|
|
1881
1907
|
phpRuntime.FS.filesystems.NODEFS.node_ops.readlink = (node) => {
|
|
@@ -1928,11 +1954,11 @@ async function loadNodeRuntime(phpVersion, options = {}) {
|
|
|
1928
1954
|
phpRuntime.FS.root.mount.opts.root = ".";
|
|
1929
1955
|
}
|
|
1930
1956
|
};
|
|
1931
|
-
if (options?.withXdebug
|
|
1957
|
+
if (options?.withXdebug) {
|
|
1932
1958
|
emscriptenOptions = await withXdebug(
|
|
1933
1959
|
phpVersion,
|
|
1934
1960
|
emscriptenOptions,
|
|
1935
|
-
options.
|
|
1961
|
+
typeof options.withXdebug === "object" ? options.withXdebug : {}
|
|
1936
1962
|
);
|
|
1937
1963
|
}
|
|
1938
1964
|
if (options?.withIntl === true) {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EmscriptenOptions } from '@php-wasm/universal';
|
|
2
|
+
export interface PathMapping {
|
|
3
|
+
hostPath: string;
|
|
4
|
+
vfsPath: string;
|
|
5
|
+
}
|
|
2
6
|
export interface XdebugOptions {
|
|
3
7
|
ideKey?: string;
|
|
8
|
+
pathMappings?: PathMapping[];
|
|
9
|
+
pathSkippings?: string[];
|
|
4
10
|
}
|
|
5
|
-
export declare function withXdebug(version: "8.5" | "8.4" | "8.3" | "8.2" | "8.1" | "8.0" | "7.4" | undefined, options: EmscriptenOptions, xdebugOptions
|
|
11
|
+
export declare function withXdebug(version: "8.5" | "8.4" | "8.3" | "8.2" | "8.1" | "8.0" | "7.4" | undefined, options: EmscriptenOptions, xdebugOptions: XdebugOptions): Promise<EmscriptenOptions>;
|
package/lib/load-runtime.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import type { WasmUserSpaceAPI, WasmUserSpaceContext } from './wasm-user-space';
|
|
|
3
3
|
import { type XdebugOptions } from './extensions/xdebug/with-xdebug';
|
|
4
4
|
export interface PHPLoaderOptions {
|
|
5
5
|
followSymlinks?: boolean;
|
|
6
|
-
withXdebug?: boolean;
|
|
7
|
-
xdebug?: XdebugOptions;
|
|
6
|
+
withXdebug?: boolean | XdebugOptions;
|
|
8
7
|
withIntl?: boolean;
|
|
9
8
|
withRedis?: boolean;
|
|
10
9
|
withMemcached?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/node",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "PHP.wasm for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,30 +38,33 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "GPL-2.0-or-later",
|
|
40
40
|
"types": "index.d.ts",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "54bb87ba4c9624ec02f60194a2f1938b3f42477b",
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=20.10.0",
|
|
44
44
|
"npm": ">=10.2.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"express": "4.22.0",
|
|
48
|
+
"fast-xml-parser": "^5.3.4",
|
|
48
49
|
"fs-ext-extra-prebuilt": "2.2.7",
|
|
49
50
|
"ini": "4.1.2",
|
|
51
|
+
"jsonc-parser": "3.3.1",
|
|
50
52
|
"wasm-feature-detect": "1.8.0",
|
|
51
53
|
"ws": "8.18.3",
|
|
52
54
|
"yargs": "17.7.2",
|
|
53
|
-
"@php-wasm/node-polyfills": "3.1.
|
|
54
|
-
"@php-wasm/universal": "3.1.
|
|
55
|
-
"@php-wasm/node-8-5": "3.1.
|
|
56
|
-
"@php-wasm/node-8-4": "3.1.
|
|
57
|
-
"@php-wasm/node-8-3": "3.1.
|
|
58
|
-
"@php-wasm/node-8-2": "3.1.
|
|
59
|
-
"@php-wasm/node-8-1": "3.1.
|
|
60
|
-
"@php-wasm/node-8-0": "3.1.
|
|
61
|
-
"@php-wasm/node-7-4": "3.1.
|
|
62
|
-
"@php-wasm/
|
|
63
|
-
"@php-wasm/
|
|
64
|
-
"@
|
|
55
|
+
"@php-wasm/node-polyfills": "3.1.3",
|
|
56
|
+
"@php-wasm/universal": "3.1.3",
|
|
57
|
+
"@php-wasm/node-8-5": "3.1.3",
|
|
58
|
+
"@php-wasm/node-8-4": "3.1.3",
|
|
59
|
+
"@php-wasm/node-8-3": "3.1.3",
|
|
60
|
+
"@php-wasm/node-8-2": "3.1.3",
|
|
61
|
+
"@php-wasm/node-8-1": "3.1.3",
|
|
62
|
+
"@php-wasm/node-8-0": "3.1.3",
|
|
63
|
+
"@php-wasm/node-7-4": "3.1.3",
|
|
64
|
+
"@php-wasm/cli-util": "3.1.3",
|
|
65
|
+
"@php-wasm/logger": "3.1.3",
|
|
66
|
+
"@php-wasm/util": "3.1.3",
|
|
67
|
+
"@wp-playground/common": "3.1.3"
|
|
65
68
|
},
|
|
66
69
|
"packageManager": "npm@10.9.2",
|
|
67
70
|
"overrides": {
|