Skip to content

Commit 38cdd83

Browse files
committed
Make an injectable user-space interface for php-wasm instances
1 parent 517a4a8 commit 38cdd83

File tree

9 files changed

+897
-5
lines changed

9 files changed

+897
-5
lines changed

packages/php-wasm/node/src/lib/file-lock-manager-for-node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
WholeFileLockOp,
1414
Pid,
1515
Fd,
16-
} from './file-lock-manager';
16+
} from '@php-wasm/universal';
1717

1818
type LockMode = 'exclusive' | 'shared' | 'unlock';
1919

packages/php-wasm/node/src/lib/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ export * from './networking/with-networking';
33
export * from './load-runtime';
44
export * from './use-host-filesystem';
55
export * from './node-fs-mount';
6-
export * from './file-lock-manager';
76
export * from './file-lock-manager-for-node';
87
export * from './xdebug/with-xdebug';

packages/php-wasm/node/src/lib/load-runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import type {
33
EmscriptenOptions,
44
PHPRuntime,
55
RemoteAPI,
6+
FileLockManager,
67
} from '@php-wasm/universal';
78
import { loadPHPRuntime, FSHelpers } from '@php-wasm/universal';
89
import fs from 'fs';
910
import { getPHPLoaderModule } from '.';
1011
import { withNetworking } from './networking/with-networking';
11-
import type { FileLockManager } from './file-lock-manager';
1212
import { withXdebug, type XdebugOptions } from './xdebug/with-xdebug';
1313
import { withIntl } from './extensions/intl/with-intl';
1414
import { joinPaths } from '@php-wasm/util';

packages/php-wasm/universal/src/lib/emscripten-types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export namespace Emscripten {
149149

150150
export interface Mount {
151151
type: Emscripten.FileSystemType;
152-
opts: object;
152+
opts: Record<string, any>;
153153
mountpoint: string;
154154
mounts: Mount[];
155155
root: FSNode;
@@ -185,6 +185,10 @@ export namespace Emscripten {
185185
write: boolean;
186186
readonly isFolder: boolean;
187187
readonly isDevice: boolean;
188+
189+
// NOTE: As of 2025-11-11, this property is added by a php-wasm patch
190+
// for NODEFS.createNode(). It is not part of the Emscripten FSNode interface.
191+
readonly isSharedFS?: boolean;
188192
}
189193

190194
export interface ErrnoError extends Error {
@@ -394,6 +398,7 @@ export namespace Emscripten {
394398
export declare const MEMFS: Emscripten.FileSystemType;
395399
export declare const NODEFS: Emscripten.FileSystemType;
396400
export declare const IDBFS: Emscripten.FileSystemType;
401+
export declare const PROXYFS: Emscripten.FileSystemType;
397402

398403
// https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
399404
type StringToType<R> = R extends Emscripten.JSType

packages/php-wasm/node/src/lib/file-lock-manager.ts renamed to packages/php-wasm/universal/src/lib/file-lock-manager.ts

File renamed without changes.

packages/php-wasm/universal/src/lib/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ export { sandboxedSpawnHandlerFactory } from './sandboxed-spawn-handler-factory'
8888

8989
export * from './api';
9090
export type { WithAPIState as WithIsReady } from './api';
91+
92+
export type * from './file-lock-manager';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// TODO: Consider merging FileLockManager file with os-kernel-space.
2+
import type { FileLockManager } from './file-lock-manager';
3+
4+
// TODO: Consider merging FileLockManager into this type.
5+
export class OSKernelSpace {
6+
readonly fileLockManager: FileLockManager;
7+
8+
constructor(fileLockManager: FileLockManager) {
9+
this.fileLockManager = fileLockManager;
10+
}
11+
}

0 commit comments

Comments
 (0)