@php-wasm/node 3.1.22 → 3.1.26

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/README.md CHANGED
@@ -41,7 +41,7 @@ const php = new PHP(
41
41
  ```
42
42
 
43
43
  `@php-wasm/node` ships `intl`, `xdebug`, `redis`, and `memcached`. It can also
44
- load external `.so` artifacts from a manifest:
44
+ load external JSPI `.so` artifacts from a manifest:
45
45
 
46
46
  ```js
47
47
  const php = new PHP(
@@ -63,6 +63,10 @@ URL. Relative local paths are resolved from the current working directory.
63
63
  Relative artifact files in the manifest are resolved against the manifest
64
64
  location.
65
65
 
66
+ External extensions are only supported when the Node.js runtime has JSPI
67
+ available. Asyncify support is limited to the bundled extensions shipped with
68
+ this package.
69
+
66
70
  The older `withIntl`, `withXdebug`, `withRedis`, and `withMemcached` loader
67
71
  options still work, but new code should use `extensions`.
68
72
 
package/index.cjs CHANGED
@@ -1730,11 +1730,15 @@ async function withPHPExtensions(version, asyncMode, options, extensions = []) {
1730
1730
  }
1731
1731
  async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1732
1732
  if (typeof extension === "object" && "source" in extension) {
1733
+ if (asyncMode === "asyncify") {
1734
+ throw new Error(
1735
+ "External PHP extensions require JSPI. Asyncify is only supported for PHP.wasm bundled extensions."
1736
+ );
1737
+ }
1733
1738
  return await (0, import_universal8.resolvePHPExtension)({
1734
1739
  ...extension,
1735
1740
  source: normalizeNodeExtensionSource(extension.source),
1736
1741
  phpVersion: version,
1737
- asyncMode,
1738
1742
  fetch: extension.fetch ?? fetchNodeExtensionResource
1739
1743
  });
1740
1744
  }
@@ -1755,15 +1759,15 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1755
1759
  bytes: soBytes
1756
1760
  },
1757
1761
  phpVersion: version,
1758
- asyncMode,
1759
1762
  env: {
1760
1763
  ICU_DATA: "/internal/shared"
1761
1764
  },
1762
1765
  extraFiles: {
1763
- targetPath: "/internal/shared",
1764
1766
  files: {
1765
1767
  // The Intl extension looks for the hard-coded ICU data name.
1766
- "icudt74l.dat": new Uint8Array(ICUData)
1768
+ "/internal/shared/icudt74l.dat": new Uint8Array(
1769
+ ICUData
1770
+ )
1767
1771
  }
1768
1772
  }
1769
1773
  });
@@ -1776,8 +1780,7 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1776
1780
  name: "redis",
1777
1781
  bytes: new Uint8Array(import_fs.default.readFileSync(extensionPath))
1778
1782
  },
1779
- phpVersion: version,
1780
- asyncMode
1783
+ phpVersion: version
1781
1784
  });
1782
1785
  }
1783
1786
  case "memcached": {
@@ -1788,8 +1791,7 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1788
1791
  name: "memcached",
1789
1792
  bytes: new Uint8Array(import_fs.default.readFileSync(extensionPath))
1790
1793
  },
1791
- phpVersion: version,
1792
- asyncMode
1794
+ phpVersion: version
1793
1795
  });
1794
1796
  }
1795
1797
  case "xdebug": {
@@ -1803,7 +1805,6 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1803
1805
  bytes: new Uint8Array(import_fs.default.readFileSync(filePath))
1804
1806
  },
1805
1807
  phpVersion: version,
1806
- asyncMode,
1807
1808
  loadWithIniDirective: "zend_extension",
1808
1809
  iniEntries: {
1809
1810
  "xdebug.mode": "debug,develop",
@@ -1850,15 +1851,12 @@ function resolveXdebugExtraFiles(version, xdebugOptions) {
1850
1851
  }
1851
1852
  const files = {};
1852
1853
  if (pathMappings) {
1853
- files["path.map"] = pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n");
1854
+ files["/.xdebug/path.map"] = pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n");
1854
1855
  }
1855
1856
  if (pathSkippings) {
1856
- files["skip.map"] = pathSkippings.map((path3) => `${path3} = SKIP`).join("\n");
1857
+ files["/.xdebug/skip.map"] = pathSkippings.map((path3) => `${path3} = SKIP`).join("\n");
1857
1858
  }
1858
- return {
1859
- targetPath: "/.xdebug",
1860
- files
1861
- };
1859
+ return { files };
1862
1860
  }
1863
1861
 
1864
1862
  // packages/php-wasm/node/src/lib/load-runtime.ts
package/index.js CHANGED
@@ -1712,11 +1712,15 @@ async function withPHPExtensions(version, asyncMode, options, extensions = []) {
1712
1712
  }
1713
1713
  async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1714
1714
  if (typeof extension === "object" && "source" in extension) {
1715
+ if (asyncMode === "asyncify") {
1716
+ throw new Error(
1717
+ "External PHP extensions require JSPI. Asyncify is only supported for PHP.wasm bundled extensions."
1718
+ );
1719
+ }
1715
1720
  return await resolvePHPExtension({
1716
1721
  ...extension,
1717
1722
  source: normalizeNodeExtensionSource(extension.source),
1718
1723
  phpVersion: version,
1719
- asyncMode,
1720
1724
  fetch: extension.fetch ?? fetchNodeExtensionResource
1721
1725
  });
1722
1726
  }
@@ -1737,15 +1741,15 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1737
1741
  bytes: soBytes
1738
1742
  },
1739
1743
  phpVersion: version,
1740
- asyncMode,
1741
1744
  env: {
1742
1745
  ICU_DATA: "/internal/shared"
1743
1746
  },
1744
1747
  extraFiles: {
1745
- targetPath: "/internal/shared",
1746
1748
  files: {
1747
1749
  // The Intl extension looks for the hard-coded ICU data name.
1748
- "icudt74l.dat": new Uint8Array(ICUData)
1750
+ "/internal/shared/icudt74l.dat": new Uint8Array(
1751
+ ICUData
1752
+ )
1749
1753
  }
1750
1754
  }
1751
1755
  });
@@ -1758,8 +1762,7 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1758
1762
  name: "redis",
1759
1763
  bytes: new Uint8Array(fs.readFileSync(extensionPath))
1760
1764
  },
1761
- phpVersion: version,
1762
- asyncMode
1765
+ phpVersion: version
1763
1766
  });
1764
1767
  }
1765
1768
  case "memcached": {
@@ -1770,8 +1773,7 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1770
1773
  name: "memcached",
1771
1774
  bytes: new Uint8Array(fs.readFileSync(extensionPath))
1772
1775
  },
1773
- phpVersion: version,
1774
- asyncMode
1776
+ phpVersion: version
1775
1777
  });
1776
1778
  }
1777
1779
  case "xdebug": {
@@ -1785,7 +1787,6 @@ async function resolveRuntimePHPExtension(version, asyncMode, extension) {
1785
1787
  bytes: new Uint8Array(fs.readFileSync(filePath))
1786
1788
  },
1787
1789
  phpVersion: version,
1788
- asyncMode,
1789
1790
  loadWithIniDirective: "zend_extension",
1790
1791
  iniEntries: {
1791
1792
  "xdebug.mode": "debug,develop",
@@ -1832,15 +1833,12 @@ function resolveXdebugExtraFiles(version, xdebugOptions) {
1832
1833
  }
1833
1834
  const files = {};
1834
1835
  if (pathMappings) {
1835
- files["path.map"] = pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n");
1836
+ files["/.xdebug/path.map"] = pathMappings.map((map) => `${map.vfsPath} = ${map.hostPath}`).join("\n");
1836
1837
  }
1837
1838
  if (pathSkippings) {
1838
- files["skip.map"] = pathSkippings.map((path3) => `${path3} = SKIP`).join("\n");
1839
+ files["/.xdebug/skip.map"] = pathSkippings.map((path3) => `${path3} = SKIP`).join("\n");
1839
1840
  }
1840
- return {
1841
- targetPath: "/.xdebug",
1842
- files
1843
- };
1841
+ return { files };
1844
1842
  }
1845
1843
 
1846
1844
  // packages/php-wasm/node/src/lib/load-runtime.ts
@@ -1,4 +1,5 @@
1
- import type { EmscriptenOptions, PHPExtensionInstallOptions, PHPWasmAsyncMode, SupportedPHPVersion } from '@php-wasm/universal';
1
+ import type { EmscriptenOptions, ResolvedInstallOptions, SupportedPHPVersion } from '@php-wasm/universal';
2
+ type PHPWasmAsyncMode = 'jspi' | 'asyncify';
2
3
  export interface PathMapping {
3
4
  hostPath: string;
4
5
  vfsPath: string;
@@ -15,10 +16,10 @@ export type BuiltInPHPExtensionName = 'intl' | 'xdebug' | 'redis' | 'memcached';
15
16
  /**
16
17
  * External PHP extension source that can be installed before PHP starts.
17
18
  *
18
- * The runtime supplies the active PHP version and async mode before resolving
19
- * the source, so callers only provide the artifact source and install options.
19
+ * External sources are supported in JSPI runtimes only. Asyncify support is
20
+ * limited to bundled extensions shipped with this package.
20
21
  */
21
- export type RuntimePHPExtensionSource = PHPExtensionInstallOptions;
22
+ export type RuntimePHPExtensionSource = Omit<ResolvedInstallOptions, 'phpVersion'>;
22
23
  /**
23
24
  * Built-in PHP extension request accepted by `loadNodeRuntime()`.
24
25
  *
@@ -57,3 +58,4 @@ export type PHPExtension = BuiltInPHPExtension | RuntimePHPExtensionSource;
57
58
  * downloads do not block each other.
58
59
  */
59
60
  export declare function withPHPExtensions(version: SupportedPHPVersion, asyncMode: PHPWasmAsyncMode, options: EmscriptenOptions, extensions?: PHPExtension[]): Promise<EmscriptenOptions>;
61
+ export {};
@@ -7,7 +7,7 @@ export interface PHPLoaderOptions {
7
7
  * PHP extensions to install before the runtime starts.
8
8
  *
9
9
  * Use built-in names such as `intl`, `xdebug`, `redis`, and `memcached`,
10
- * or pass an external extension source such as a manifest.
10
+ * or pass an external JSPI extension source such as a manifest.
11
11
  */
12
12
  extensions?: PHPExtension[];
13
13
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "3.1.22",
3
+ "version": "3.1.26",
4
4
  "description": "PHP.wasm for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,6 +39,7 @@
39
39
  "license": "GPL-2.0-or-later",
40
40
  "types": "index.d.ts",
41
41
  "dependencies": {
42
+ "ajv": "8.12.0",
42
43
  "express": "4.22.0",
43
44
  "fast-xml-parser": "^5.5.1",
44
45
  "fs-ext-extra-prebuilt": "2.2.7",
@@ -47,21 +48,21 @@
47
48
  "wasm-feature-detect": "1.8.0",
48
49
  "ws": "8.18.0",
49
50
  "yargs": "17.7.2",
50
- "@php-wasm/universal": "3.1.22",
51
- "@php-wasm/node-8-5": "3.1.22",
52
- "@php-wasm/node-8-4": "3.1.22",
53
- "@php-wasm/node-8-3": "3.1.22",
54
- "@php-wasm/node-8-2": "3.1.22",
55
- "@php-wasm/node-8-1": "3.1.22",
56
- "@php-wasm/node-8-0": "3.1.22",
57
- "@php-wasm/node-7-4": "3.1.22",
58
- "@php-wasm/cli-util": "3.1.22",
59
- "@php-wasm/logger": "3.1.22",
60
- "@php-wasm/node-5-2": "3.1.22",
61
- "@php-wasm/util": "3.1.22",
62
- "@wp-playground/common": "3.1.22"
51
+ "@php-wasm/universal": "3.1.26",
52
+ "@php-wasm/node-8-5": "3.1.26",
53
+ "@php-wasm/node-8-4": "3.1.26",
54
+ "@php-wasm/node-8-3": "3.1.26",
55
+ "@php-wasm/node-8-2": "3.1.26",
56
+ "@php-wasm/node-8-1": "3.1.26",
57
+ "@php-wasm/node-8-0": "3.1.26",
58
+ "@php-wasm/node-7-4": "3.1.26",
59
+ "@php-wasm/cli-util": "3.1.26",
60
+ "@php-wasm/logger": "3.1.26",
61
+ "@php-wasm/node-5-2": "3.1.26",
62
+ "@php-wasm/util": "3.1.26",
63
+ "@wp-playground/common": "3.1.26"
63
64
  },
64
- "gitHead": "04c986b63dd56fe74e4ed0cf04d00cae7ac050bf",
65
+ "gitHead": "6acfccb8e79f4e664429e3f729f04dbf2ff55303",
65
66
  "engines": {
66
67
  "node": ">=20.10.0",
67
68
  "npm": ">=10.2.3"