@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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/jspi/php_7_2.js CHANGED
@@ -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');
@@ -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_7_3.js CHANGED
@@ -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');
@@ -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_7_4.js CHANGED
@@ -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');
@@ -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_0.js CHANGED
@@ -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');
@@ -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_1.js CHANGED
@@ -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');
@@ -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_2.js CHANGED
@@ -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');
@@ -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.