@php-wasm/node 2.0.5 → 2.0.8

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/jspi/php_8_3.js CHANGED
@@ -6,10 +6,10 @@ const require = createRequire(import.meta.url);
6
6
  // Note: The path module is currently needed by code injected by the php-wasm Dockerfile.
7
7
  import path from 'path';
8
8
 
9
- const dependencyFilename = path.join(__dirname, '8_3_23', 'php_8_3.wasm');
9
+ const dependencyFilename = path.join(__dirname, '8_3_24', 'php_8_3.wasm');
10
10
  export { dependencyFilename };
11
- export const dependenciesTotalSize = 32571921;
12
- const phpVersionString = '8.3.23';
11
+ export const dependenciesTotalSize = 32572592;
12
+ const phpVersionString = '8.3.24';
13
13
  export function init(RuntimeName, PHPLoader) {
14
14
  // The rest of the code comes from the built php.js file and esm-suffix.js
15
15
  // include: shell.js
@@ -1012,7 +1012,7 @@ export function init(RuntimeName, PHPLoader) {
1012
1012
 
1013
1013
  /** @type {WebAssembly.Table} */
1014
1014
  var wasmTable = new WebAssembly.Table({
1015
- initial: 15738,
1015
+ initial: 15739,
1016
1016
  element: 'anyfunc',
1017
1017
  });
1018
1018
  var getWasmTableEntry = (funcPtr) => {
@@ -6994,35 +6994,25 @@ export function init(RuntimeName, PHPLoader) {
6994
6994
  1: 'exclusive',
6995
6995
  2: 'unlocked',
6996
6996
  },
6997
- is_shared_fs_node(node) {
6998
- if (node?.isSharedFS) {
6999
- return true;
7000
- }
7001
-
7002
- // Handle PROXYFS nodes which wrap other nodes.
7003
- if (
7004
- !node?.mount?.opts?.fs?.lookupPath ||
7005
- !node?.mount?.type?.realPath
7006
- ) {
7007
- return false;
6997
+ is_path_to_shared_fs(path) {
6998
+ _js_wasm_trace('is_path_to_shared_fs(%s)', path);
6999
+ const { node } = FS.lookupPath(path, { noent_okay: true });
7000
+ if (node.mount.type !== PROXYFS) {
7001
+ return !!node.isSharedFS;
7002
+ }
7003
+
7004
+ // This looks like a PROXYFS node. Let's try a lookup.
7005
+ const nodePath = PROXYFS.realPath(node);
7006
+ const backingFs = node?.mount?.opts?.fs;
7007
+ if (backingFs) {
7008
+ // Tolerate ENOENT because looking up a MEMFS node by path always fails.
7009
+ const { node: backingNode } = backingFs.lookupPath(nodePath, {
7010
+ noent_okay: true,
7011
+ });
7012
+ return !!backingNode?.isSharedFS;
7008
7013
  }
7009
7014
 
7010
- // Only NODEFS can be shared between workers at the moment.
7011
- if (node.mount.type !== NODEFS) {
7012
- return false;
7013
- }
7014
- const vfsPath = node.mount.type.realPath(node);
7015
- try {
7016
- const underlyingNode =
7017
- node.mount.opts.fs.lookupPath(vfsPath)?.node;
7018
- return !!underlyingNode?.isSharedFS;
7019
- } catch (e) {
7020
- return false;
7021
- }
7022
- },
7023
- is_path_to_shared_fs(path) {
7024
- const { node } = FS.lookupPath(path);
7025
- return locking.is_shared_fs_node(node);
7015
+ return false;
7026
7016
  },
7027
7017
  get_fd_access_mode(fd) {
7028
7018
  const emscripten_F_GETFL = Number('3');
@@ -7040,8 +7030,26 @@ export function init(RuntimeName, PHPLoader) {
7040
7030
  }
7041
7031
  },
7042
7032
  get_native_path_from_vfs_path(vfsPath) {
7043
- const { node } = FS.lookupPath(vfsPath);
7044
- return NODEFS.realPath(node);
7033
+ // TODO: Should there be a try/catch here?
7034
+ const { node } = FS.lookupPath(vfsPath, {});
7035
+ if (node.mount.type === NODEFS) {
7036
+ return NODEFS.realPath(node);
7037
+ } else if (node.mount.type === PROXYFS) {
7038
+ // TODO: Tolerate ENOENT here?
7039
+ const { node: backingNode, path: backingPath } =
7040
+ node.mount.opts.fs.lookupPath(vfsPath);
7041
+ _js_wasm_trace(
7042
+ 'backingNode for %s: %s',
7043
+ vfsPath,
7044
+ backingPath,
7045
+ backingNode
7046
+ );
7047
+ return backingNode.mount.type.realPath(backingNode);
7048
+ } else {
7049
+ throw new Error(
7050
+ `Unsupported filesystem type for path ${vfsPath}`
7051
+ );
7052
+ }
7045
7053
  },
7046
7054
  check_lock_params(fd, l_type) {
7047
7055
  const emscripten_O_RDONLY = Number('0');
@@ -31254,13 +31262,13 @@ export function init(RuntimeName, PHPLoader) {
31254
31262
  // End JS library code
31255
31263
 
31256
31264
  var ASM_CONSTS = {
31257
- 13232622: ($0) => {
31265
+ 13232510: ($0) => {
31258
31266
  if (!$0) {
31259
31267
  AL.alcErr = 0xa004;
31260
31268
  return 1;
31261
31269
  }
31262
31270
  },
31263
- 13232670: ($0) => {
31271
+ 13232558: ($0) => {
31264
31272
  if (!AL.currentCtx) {
31265
31273
  err('alGetProcAddress() called without a valid context');
31266
31274
  return 1;
@@ -34409,19 +34417,16 @@ export function init(RuntimeName, PHPLoader) {
34409
34417
  // We override NODEFS.createNode() to add an `isSharedFS` flag to all NODEFS
34410
34418
  // nodes. This way we can tell whether file-locking is needed and possible
34411
34419
  // for an FS node, even if wrapped with PROXYFS.
34412
- const originalCreateNode = NODEFS.createNode;
34420
+ const originalNodeFsCreateNode = NODEFS.createNode;
34413
34421
  NODEFS.createNode = function createNodeWithSharedFlag() {
34414
- const node = originalCreateNode.apply(NODEFS, arguments);
34422
+ const node = originalNodeFsCreateNode.apply(NODEFS, arguments);
34415
34423
  node.isSharedFS = true;
34416
34424
  return node;
34417
34425
  };
34418
34426
 
34419
34427
  var originalHashAddNode = FS.hashAddNode;
34420
34428
  FS.hashAddNode = function hashAddNodeIfNotSharedFS(node) {
34421
- if (
34422
- typeof locking === 'object' &&
34423
- locking?.is_shared_fs_node(node)
34424
- ) {
34429
+ if (node?.isSharedFS) {
34425
34430
  // Avoid caching shared VFS nodes so multiple instances
34426
34431
  // can access the same underlying filesystem without
34427
34432
  // conflicting caches.
package/jspi/php_8_4.js CHANGED
@@ -6,10 +6,10 @@ const require = createRequire(import.meta.url);
6
6
  // Note: The path module is currently needed by code injected by the php-wasm Dockerfile.
7
7
  import path from 'path';
8
8
 
9
- const dependencyFilename = path.join(__dirname, '8_4_10', 'php_8_4.wasm');
9
+ const dependencyFilename = path.join(__dirname, '8_4_11', 'php_8_4.wasm');
10
10
  export { dependencyFilename };
11
- export const dependenciesTotalSize = 36372438;
12
- const phpVersionString = '8.4.10';
11
+ export const dependenciesTotalSize = 36373389;
12
+ const phpVersionString = '8.4.11';
13
13
  export function init(RuntimeName, PHPLoader) {
14
14
  // The rest of the code comes from the built php.js file and esm-suffix.js
15
15
  // include: shell.js
@@ -1012,7 +1012,7 @@ export function init(RuntimeName, PHPLoader) {
1012
1012
 
1013
1013
  /** @type {WebAssembly.Table} */
1014
1014
  var wasmTable = new WebAssembly.Table({
1015
- initial: 16555,
1015
+ initial: 16556,
1016
1016
  element: 'anyfunc',
1017
1017
  });
1018
1018
  var getWasmTableEntry = (funcPtr) => {
@@ -6994,35 +6994,25 @@ export function init(RuntimeName, PHPLoader) {
6994
6994
  1: 'exclusive',
6995
6995
  2: 'unlocked',
6996
6996
  },
6997
- is_shared_fs_node(node) {
6998
- if (node?.isSharedFS) {
6999
- return true;
7000
- }
7001
-
7002
- // Handle PROXYFS nodes which wrap other nodes.
7003
- if (
7004
- !node?.mount?.opts?.fs?.lookupPath ||
7005
- !node?.mount?.type?.realPath
7006
- ) {
7007
- return false;
6997
+ is_path_to_shared_fs(path) {
6998
+ _js_wasm_trace('is_path_to_shared_fs(%s)', path);
6999
+ const { node } = FS.lookupPath(path, { noent_okay: true });
7000
+ if (node.mount.type !== PROXYFS) {
7001
+ return !!node.isSharedFS;
7002
+ }
7003
+
7004
+ // This looks like a PROXYFS node. Let's try a lookup.
7005
+ const nodePath = PROXYFS.realPath(node);
7006
+ const backingFs = node?.mount?.opts?.fs;
7007
+ if (backingFs) {
7008
+ // Tolerate ENOENT because looking up a MEMFS node by path always fails.
7009
+ const { node: backingNode } = backingFs.lookupPath(nodePath, {
7010
+ noent_okay: true,
7011
+ });
7012
+ return !!backingNode?.isSharedFS;
7008
7013
  }
7009
7014
 
7010
- // Only NODEFS can be shared between workers at the moment.
7011
- if (node.mount.type !== NODEFS) {
7012
- return false;
7013
- }
7014
- const vfsPath = node.mount.type.realPath(node);
7015
- try {
7016
- const underlyingNode =
7017
- node.mount.opts.fs.lookupPath(vfsPath)?.node;
7018
- return !!underlyingNode?.isSharedFS;
7019
- } catch (e) {
7020
- return false;
7021
- }
7022
- },
7023
- is_path_to_shared_fs(path) {
7024
- const { node } = FS.lookupPath(path);
7025
- return locking.is_shared_fs_node(node);
7015
+ return false;
7026
7016
  },
7027
7017
  get_fd_access_mode(fd) {
7028
7018
  const emscripten_F_GETFL = Number('3');
@@ -7040,8 +7030,26 @@ export function init(RuntimeName, PHPLoader) {
7040
7030
  }
7041
7031
  },
7042
7032
  get_native_path_from_vfs_path(vfsPath) {
7043
- const { node } = FS.lookupPath(vfsPath);
7044
- return NODEFS.realPath(node);
7033
+ // TODO: Should there be a try/catch here?
7034
+ const { node } = FS.lookupPath(vfsPath, {});
7035
+ if (node.mount.type === NODEFS) {
7036
+ return NODEFS.realPath(node);
7037
+ } else if (node.mount.type === PROXYFS) {
7038
+ // TODO: Tolerate ENOENT here?
7039
+ const { node: backingNode, path: backingPath } =
7040
+ node.mount.opts.fs.lookupPath(vfsPath);
7041
+ _js_wasm_trace(
7042
+ 'backingNode for %s: %s',
7043
+ vfsPath,
7044
+ backingPath,
7045
+ backingNode
7046
+ );
7047
+ return backingNode.mount.type.realPath(backingNode);
7048
+ } else {
7049
+ throw new Error(
7050
+ `Unsupported filesystem type for path ${vfsPath}`
7051
+ );
7052
+ }
7045
7053
  },
7046
7054
  check_lock_params(fd, l_type) {
7047
7055
  const emscripten_O_RDONLY = Number('0');
@@ -31254,13 +31262,13 @@ export function init(RuntimeName, PHPLoader) {
31254
31262
  // End JS library code
31255
31263
 
31256
31264
  var ASM_CONSTS = {
31257
- 16328094: ($0) => {
31265
+ 16328046: ($0) => {
31258
31266
  if (!$0) {
31259
31267
  AL.alcErr = 0xa004;
31260
31268
  return 1;
31261
31269
  }
31262
31270
  },
31263
- 16328142: ($0) => {
31271
+ 16328094: ($0) => {
31264
31272
  if (!AL.currentCtx) {
31265
31273
  err('alGetProcAddress() called without a valid context');
31266
31274
  return 1;
@@ -34409,19 +34417,16 @@ export function init(RuntimeName, PHPLoader) {
34409
34417
  // We override NODEFS.createNode() to add an `isSharedFS` flag to all NODEFS
34410
34418
  // nodes. This way we can tell whether file-locking is needed and possible
34411
34419
  // for an FS node, even if wrapped with PROXYFS.
34412
- const originalCreateNode = NODEFS.createNode;
34420
+ const originalNodeFsCreateNode = NODEFS.createNode;
34413
34421
  NODEFS.createNode = function createNodeWithSharedFlag() {
34414
- const node = originalCreateNode.apply(NODEFS, arguments);
34422
+ const node = originalNodeFsCreateNode.apply(NODEFS, arguments);
34415
34423
  node.isSharedFS = true;
34416
34424
  return node;
34417
34425
  };
34418
34426
 
34419
34427
  var originalHashAddNode = FS.hashAddNode;
34420
34428
  FS.hashAddNode = function hashAddNodeIfNotSharedFS(node) {
34421
- if (
34422
- typeof locking === 'object' &&
34423
- locking?.is_shared_fs_node(node)
34424
- ) {
34429
+ if (node?.isSharedFS) {
34425
34430
  // Avoid caching shared VFS nodes so multiple instances
34426
34431
  // can access the same underlying filesystem without
34427
34432
  // conflicting caches.
@@ -147,11 +147,18 @@ export declare class FileLock {
147
147
  */
148
148
  private ensureCompatibleNativeLock;
149
149
  /**
150
- * Check if a conflicting lock exists.
150
+ * Check if a lock exists that conflicts with the requested range lock.
151
151
  *
152
152
  * @param requestedLock The desired byte range lock.
153
153
  * @returns True if a conflicting lock exists, false otherwise.
154
154
  */
155
- private doesAConflictingLockExist;
155
+ private isThereAConflictWithRequestedRangeLock;
156
+ /**
157
+ * Check if a lock exists that conflicts with the requested whole-file lock.
158
+ *
159
+ * @param requestedLock The desired whole-file lock.
160
+ * @returns True if a conflicting lock exists, false otherwise.
161
+ */
162
+ private isThereAConflictWithRequestedWholeFileLock;
156
163
  }
157
164
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { SupportedPHPVersion, EmscriptenOptions, RemoteAPI } from '@php-wasm/universal';
2
2
  import type { FileLockManager } from './file-lock-manager';
3
+ import type { Promised } from '@php-wasm/util';
3
4
  export interface PHPLoaderOptions {
4
5
  emscriptenOptions?: EmscriptenOptions;
5
6
  followSymlinks?: boolean;
@@ -25,7 +26,7 @@ type PHPLoaderOptionsForNode = PHPLoaderOptions & {
25
26
  * file lock managers are supported.
26
27
  * When running with Asyncify, the file lock manager must be synchronous.
27
28
  */
28
- fileLockManager?: RemoteAPI<FileLockManager> | FileLockManager;
29
+ fileLockManager?: RemoteAPI<FileLockManager> | Promised<FileLockManager> | FileLockManager;
29
30
  /**
30
31
  * An optional function to collect trace messages.
31
32
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "2.0.5",
3
+ "version": "2.0.8",
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": "9d14cae73a85996c749bdca82b8266572d4c1e31",
41
+ "gitHead": "886a4a87ea86fed4f76ef1d71fc53601fc90c724",
42
42
  "engines": {
43
43
  "node": ">=20.18.3",
44
44
  "npm": ">=10.1.0"
@@ -49,11 +49,11 @@
49
49
  "wasm-feature-detect": "1.8.0",
50
50
  "ws": "8.18.1",
51
51
  "yargs": "17.7.2",
52
- "@php-wasm/node-polyfills": "2.0.5",
53
- "@php-wasm/universal": "2.0.5",
54
- "@php-wasm/logger": "2.0.5",
55
- "@php-wasm/util": "2.0.5",
56
- "@wp-playground/common": "2.0.5"
52
+ "@php-wasm/node-polyfills": "2.0.8",
53
+ "@php-wasm/universal": "2.0.8",
54
+ "@php-wasm/logger": "2.0.8",
55
+ "@php-wasm/util": "2.0.8",
56
+ "@wp-playground/common": "2.0.8"
57
57
  },
58
58
  "overrides": {
59
59
  "rollup": "^4.34.6",