@php-wasm/node 3.0.54 → 3.1.0

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.
@@ -0,0 +1,14 @@
1
+ import type { FileLockManager, WholeFileLockOp, RequestedRangeLock, Path } from '@php-wasm/universal';
2
+ type StoredWholeFileLock = WholeFileLockOp & {
3
+ path: Path;
4
+ };
5
+ export declare class FileLockManagerForPosix implements FileLockManager {
6
+ wholeFileLockMap: Map<number, Map<number, StoredWholeFileLock>>;
7
+ rangeLockedFds: Map<number, Map<string, Set<number>>>;
8
+ lockWholeFile(path: string, op: WholeFileLockOp): boolean;
9
+ lockFileByteRange(path: string, op: RequestedRangeLock, waitForLock: boolean): boolean;
10
+ findFirstConflictingByteRangeLock(path: string, op: RequestedRangeLock): ReturnType<FileLockManager['findFirstConflictingByteRangeLock']>;
11
+ releaseLocksForProcess(targetPid: number): void;
12
+ releaseLocksOnFdClose(targetPid: number, targetFd: number, targetPath: string): void;
13
+ }
14
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { FileLockManager, WholeFileLockOp, RequestedRangeLock, Path } from '@php-wasm/universal';
2
+ import { FileLockIntervalTree } from '@php-wasm/universal';
3
+ type StoredWholeFileLock = WholeFileLockOp & {
4
+ path: Path;
5
+ };
6
+ export declare class FileLockManagerForWindows implements FileLockManager {
7
+ wholeFileLockMap: Map<number, Map<number, StoredWholeFileLock>>;
8
+ rangeLockedFds: Map<string, FileLockIntervalTree>;
9
+ lockWholeFile(path: string, op: WholeFileLockOp): boolean;
10
+ lockFileByteRange(path: string, op: RequestedRangeLock, waitForLock: boolean): boolean;
11
+ findFirstConflictingByteRangeLock(path: string, op: RequestedRangeLock): ReturnType<FileLockManager['findFirstConflictingByteRangeLock']>;
12
+ releaseLocksForProcess(targetPid: number): void;
13
+ releaseLocksOnFdClose(targetPid: number, targetFd: number, targetPath: string): void;
14
+ }
15
+ export {};
package/lib/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export * from './networking/with-networking';
3
3
  export * from './load-runtime';
4
4
  export * from './use-host-filesystem';
5
5
  export * from './node-fs-mount';
6
- export * from './file-lock-manager';
7
- export * from './file-lock-manager-for-node';
6
+ export * from './file-lock-manager-for-posix';
7
+ export * from './file-lock-manager-for-windows';
8
8
  export * from './extensions/xdebug/with-xdebug';
9
+ export * from './wasm-user-space';
10
+ export * from './wasm-kernel-space';
@@ -1,9 +1,7 @@
1
- import type { SupportedPHPVersion, EmscriptenOptions, RemoteAPI } from '@php-wasm/universal';
2
- import type { FileLockManager } from './file-lock-manager';
1
+ import { type SupportedPHPVersion, type EmscriptenOptions, type FileLockManager } from '@php-wasm/universal';
2
+ import type { WasmUserSpaceAPI, WasmUserSpaceContext } from './wasm-user-space';
3
3
  import { type XdebugOptions } from './extensions/xdebug/with-xdebug';
4
- import type { Promised } from '@php-wasm/util';
5
4
  export interface PHPLoaderOptions {
6
- emscriptenOptions?: EmscriptenOptions;
7
5
  followSymlinks?: boolean;
8
6
  withXdebug?: boolean;
9
7
  xdebug?: XdebugOptions;
@@ -12,6 +10,11 @@ export interface PHPLoaderOptions {
12
10
  withMemcached?: boolean;
13
11
  }
14
12
  export type PHPLoaderOptionsForNode = PHPLoaderOptions & {
13
+ /**
14
+ * A file lock manager to coordinate file locks between
15
+ * multiple php-wasm instances and other OS processes.
16
+ */
17
+ fileLockManager?: FileLockManager;
15
18
  emscriptenOptions?: EmscriptenOptions & {
16
19
  /**
17
20
  * The process ID for the PHP runtime.
@@ -23,15 +26,13 @@ export type PHPLoaderOptionsForNode = PHPLoaderOptions & {
23
26
  */
24
27
  processId?: number;
25
28
  /**
26
- * An optional file lock manager to use for the PHP runtime.
27
- *
28
- * The lock manager is optional when running a single php-wasm process.
29
- *
30
- * When running with JSPI, both synchronous and asynchronous
31
- * file lock managers are supported.
32
- * When running with Asyncify, the file lock manager must be synchronous.
29
+ * Factory called during WASM initialization to create
30
+ * user-space syscall implementations (flock, fcntl, etc.)
31
+ * for a PHP process. Receives process context (PID,
32
+ * constants, errno codes) and returns the bound syscall
33
+ * functions.
33
34
  */
34
- fileLockManager?: RemoteAPI<FileLockManager> | Promised<FileLockManager> | FileLockManager;
35
+ bindUserSpace?: (userSpaceContext: WasmUserSpaceContext) => WasmUserSpaceAPI;
35
36
  /**
36
37
  * An optional function to collect trace messages.
37
38
  *
@@ -41,16 +42,10 @@ export type PHPLoaderOptionsForNode = PHPLoaderOptions & {
41
42
  */
42
43
  trace?: (processId: number, format: string, ...args: any[]) => void;
43
44
  /**
44
- * An optional object to pass to the PHP-WASM library's `init` function.
45
- *
46
- * phpWasmInitOptions.nativeInternalDirPath is used to mount a
47
- * real, native directory as the php-wasm /internal directory.
48
- *
49
- * @see https://github.com/php-wasm/php-wasm/blob/main/compile/php/phpwasm-emscripten-library.js#L100
45
+ * An optional path used to a real, native directory
46
+ * to be mounted as the php-wasm /internal directory.
50
47
  */
51
- phpWasmInitOptions?: {
52
- nativeInternalDirPath?: string;
53
- };
48
+ nativeInternalDirPath?: string;
54
49
  };
55
50
  };
56
51
  /**
@@ -0,0 +1,9 @@
1
+ import type { FileLockManager } from '@php-wasm/universal';
2
+ /**
3
+ * Shared state that persists across all PHP-WASM processes, analogous
4
+ * to OS kernel space. Currently holds the file lock manager that
5
+ * coordinates locks across PHP-WASM instances.
6
+ */
7
+ export type WasmKernelSpace = {
8
+ readonly fileLockManager: FileLockManager | undefined;
9
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Per-process syscall implementations (flock, fcntl, etc.) that run
3
+ * in the context of a single WASM PHP process. Analogous to OS
4
+ * user space: each process gets its own instance bound to its PID,
5
+ * constants, and file descriptor table.
6
+ */
7
+ import type { Emscripten } from '@php-wasm/universal';
8
+ import type { WasmKernelSpace } from './wasm-kernel-space';
9
+ type FSNode = Emscripten.FS.FSNode;
10
+ type NonZeroNumber = Exclude<number, 0>;
11
+ export type WasmUserSpaceContext = {
12
+ pid: number;
13
+ constants: {
14
+ F_RDLCK: number;
15
+ F_WRLCK: number;
16
+ F_UNLCK: number;
17
+ F_GETFL: number;
18
+ O_ACCMODE: number;
19
+ O_RDONLY: number;
20
+ O_WRONLY: number;
21
+ O_APPEND: number;
22
+ O_NONBLOCK: number;
23
+ F_SETFL: number;
24
+ F_GETLK: number;
25
+ F_SETLK: number;
26
+ F_SETLKW: number;
27
+ SEEK_SET: number;
28
+ SEEK_CUR: number;
29
+ SEEK_END: number;
30
+ LOCK_SH: 1;
31
+ LOCK_EX: 2;
32
+ LOCK_NB: 4;
33
+ LOCK_UN: 8;
34
+ };
35
+ errnoCodes: {
36
+ EBADF: NonZeroNumber;
37
+ EINVAL: NonZeroNumber;
38
+ EAGAIN: NonZeroNumber;
39
+ EDEADLK: NonZeroNumber;
40
+ EWOULDBLOCK: NonZeroNumber;
41
+ };
42
+ memory: {
43
+ HEAP8: Int8Array;
44
+ HEAPU8: Uint8Array;
45
+ HEAP16: Int16Array;
46
+ HEAPU16: Uint16Array;
47
+ HEAP32: Int32Array;
48
+ HEAPU32: Uint32Array;
49
+ HEAPF32: Float32Array;
50
+ HEAP64: BigInt64Array;
51
+ HEAPU64: BigUint64Array;
52
+ HEAPF64: Float64Array;
53
+ };
54
+ wasmImports: {
55
+ builtin_fcntl64: (fd: number, cmd: number, varargs?: any) => number;
56
+ builtin_fd_close: (fd: number) => number;
57
+ js_wasm_trace: (...args: any[]) => void;
58
+ };
59
+ wasmExports: {
60
+ wasm_get_end_offset: (fd: number) => bigint;
61
+ };
62
+ syscalls: {
63
+ getStreamFromFD: (fd: number) => Emscripten.FS.FSStream;
64
+ };
65
+ FS: typeof Emscripten.FS;
66
+ PROXYFS: typeof Emscripten.PROXYFS & {
67
+ realPath(node: FSNode): string;
68
+ };
69
+ NODEFS: typeof Emscripten.NODEFS & {
70
+ realPath(node: FSNode): string;
71
+ };
72
+ };
73
+ export type WasmUserSpaceAPI = {
74
+ fcntl64: (fd: number, cmd: number, varargs?: number) => number;
75
+ flock: (fd: number, op: number) => number;
76
+ fd_close: (fd: number) => number;
77
+ js_release_file_locks: () => void;
78
+ gethostbyname: (hostname: string) => Promise<string>;
79
+ };
80
+ export declare function bindUserSpace({ fileLockManager }: WasmKernelSpace, { pid, memory: { HEAP16, HEAP64, HEAP32 }, constants: { F_RDLCK, F_WRLCK, F_UNLCK, F_GETFL, O_ACCMODE, O_RDONLY, O_WRONLY, O_APPEND, O_NONBLOCK, F_SETFL, F_GETLK, F_SETLK, F_SETLKW, SEEK_SET, SEEK_CUR, SEEK_END, LOCK_SH, LOCK_EX, LOCK_NB, LOCK_UN, }, errnoCodes: { EBADF, EINVAL, EAGAIN, EWOULDBLOCK }, wasmImports: { builtin_fcntl64, builtin_fd_close, js_wasm_trace }, wasmExports: { wasm_get_end_offset }, syscalls: { getStreamFromFD }, FS, PROXYFS, NODEFS, }: WasmUserSpaceContext): WasmUserSpaceAPI;
81
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "3.0.54",
3
+ "version": "3.1.0",
4
4
  "description": "PHP.wasm for Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,29 +38,30 @@
38
38
  },
39
39
  "license": "GPL-2.0-or-later",
40
40
  "types": "index.d.ts",
41
- "gitHead": "e449793042bf2c66f8fdd4212ef266801ae3f605",
41
+ "gitHead": "be66d7e27ea9a8f09c2cc15e4470a6e28def5c58",
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
+ "fs-ext-extra-prebuilt": "2.2.7",
48
49
  "ini": "4.1.2",
49
50
  "wasm-feature-detect": "1.8.0",
50
51
  "ws": "8.18.3",
51
52
  "yargs": "17.7.2",
52
- "@php-wasm/node-polyfills": "3.0.54",
53
- "@php-wasm/universal": "3.0.54",
54
- "@php-wasm/node-8-5": "3.0.54",
55
- "@php-wasm/node-8-4": "3.0.54",
56
- "@php-wasm/node-8-3": "3.0.54",
57
- "@php-wasm/node-8-2": "3.0.54",
58
- "@php-wasm/node-8-1": "3.0.54",
59
- "@php-wasm/node-8-0": "3.0.54",
60
- "@php-wasm/node-7-4": "3.0.54",
61
- "@php-wasm/logger": "3.0.54",
62
- "@php-wasm/util": "3.0.54",
63
- "@wp-playground/common": "3.0.54"
53
+ "@php-wasm/node-polyfills": "3.1.0",
54
+ "@php-wasm/universal": "3.1.0",
55
+ "@php-wasm/node-8-5": "3.1.0",
56
+ "@php-wasm/node-8-4": "3.1.0",
57
+ "@php-wasm/node-8-3": "3.1.0",
58
+ "@php-wasm/node-8-2": "3.1.0",
59
+ "@php-wasm/node-8-1": "3.1.0",
60
+ "@php-wasm/node-8-0": "3.1.0",
61
+ "@php-wasm/node-7-4": "3.1.0",
62
+ "@php-wasm/logger": "3.1.0",
63
+ "@php-wasm/util": "3.1.0",
64
+ "@wp-playground/common": "3.1.0"
64
65
  },
65
66
  "packageManager": "npm@10.9.2",
66
67
  "overrides": {
@@ -74,8 +75,5 @@
74
75
  "form-data": "^4.0.4",
75
76
  "lodash": "^4.17.23",
76
77
  "glob": "^9.3.0"
77
- },
78
- "optionalDependencies": {
79
- "fs-ext": "2.1.1"
80
78
  }
81
79
  }
@@ -0,0 +1,20 @@
1
+ /// <reference types="node" />
2
+ import { closeSync, openSync } from 'fs';
3
+ import { type FileLockManager, type RequestedRangeLock } from '@php-wasm/universal';
4
+ export type RequestedRangeLockWithNonBigIntAddresses = Omit<RequestedRangeLock, 'start' | 'end'> & {
5
+ start: number;
6
+ end: number;
7
+ };
8
+ export type TestWorkerAPI = Omit<FileLockManager, 'lockFileByteRange' | 'findFirstConflictingByteRangeLock'> & {
9
+ lockFileByteRange: (path: string, requestedLock: RequestedRangeLockWithNonBigIntAddresses, waitForLock: boolean) => boolean;
10
+ findFirstConflictingByteRangeLock: (path: string, requestedLock: RequestedRangeLockWithNonBigIntAddresses) => Omit<RequestedRangeLockWithNonBigIntAddresses, 'fd'> | undefined;
11
+ openSync: typeof openSync;
12
+ closeSync: typeof closeSync;
13
+ };
14
+ /**
15
+ * Create a remote process API for a file lock manager.
16
+ *
17
+ * @param fileLockManager - The file lock manager to create a remote process API for.
18
+ * @returns An API for the remote test process to expose.
19
+ */
20
+ export declare function createRemoteProcessAPIFromFileLockManager(fileLockManager: FileLockManager): TestWorkerAPI;
@@ -0,0 +1,6 @@
1
+ export declare function declareFileLockManagerTests({ name, testWorkerUrl, shouldSkip, workerType, }: {
2
+ name: string;
3
+ testWorkerUrl: URL;
4
+ shouldSkip?: boolean;
5
+ workerType: 'childProcess' | 'workerThread';
6
+ }): import("vitest").SuiteCollector<object>;
@@ -1,164 +0,0 @@
1
- type NativeFlockSync = (fd: number, flags: 'sh' | 'ex' | 'shnb' | 'exnb' | 'un') => void;
2
- import type { FileLockManager, RequestedRangeLock, WholeFileLock, WholeFileLockOp, Pid, Fd } from './file-lock-manager';
3
- /**
4
- * This is the file lock manager for use within JS runtimes like Node.js.
5
- *
6
- * A FileLockManagerForNode is a wrapper around a Map of FileLock instances.
7
- * It provides methods for locking and unlocking files, as well as finding conflicting locks.
8
- */
9
- export declare class FileLockManagerForNode implements FileLockManager {
10
- nativeFlockSync: NativeFlockSync;
11
- locks: Map<string, FileLock>;
12
- /**
13
- * Create a new FileLockManagerForNode instance.
14
- *
15
- * @param nativeFlockSync A synchronous flock() function to lock files via the host OS.
16
- */
17
- constructor(nativeFlockSync?: NativeFlockSync);
18
- /**
19
- * Lock the whole file.
20
- *
21
- * @param path The path to the file to lock. This should be the path
22
- * of the file in the native filesystem.
23
- * @param op The whole file lock operation to perform.
24
- * @returns True if the lock was granted, false otherwise.
25
- */
26
- lockWholeFile(path: string, op: WholeFileLockOp): boolean;
27
- /**
28
- * Lock a byte range.
29
- *
30
- * @param path The path to the file to lock. This should be the path
31
- * of the file in the native filesystem.
32
- * @param requestedLock The byte range lock to perform.
33
- * @returns True if the lock was granted, false otherwise.
34
- */
35
- lockFileByteRange(path: string, requestedLock: RequestedRangeLock): boolean;
36
- /**
37
- * Find the first conflicting byte range lock.
38
- *
39
- * @param path The path to the file to find the conflicting lock for.
40
- * @param desiredLock The desired byte range lock.
41
- * @returns The first conflicting byte range lock, or undefined if no conflicting lock exists.
42
- */
43
- findFirstConflictingByteRangeLock(path: string, desiredLock: RequestedRangeLock): Omit<RequestedRangeLock, 'fd'> | undefined;
44
- /**
45
- * Release all locks for the given process.
46
- *
47
- * @param pid The process ID to release locks for.
48
- */
49
- releaseLocksForProcess(pid: number): void;
50
- /**
51
- * Release all locks for the given process and file descriptor.
52
- *
53
- * @param pid The process ID to release locks for.
54
- * @param fd The file descriptor to release locks for.
55
- * @param path The path to the file to release locks for.
56
- */
57
- releaseLocksForProcessFd(pid: number, fd: number, nativePath: string): void;
58
- /**
59
- * Forget the path if it is unlocked.
60
- *
61
- * @param path The path to the file to forget.
62
- */
63
- private forgetPathIfUnlocked;
64
- }
65
- /**
66
- * A FileLock instance encapsulates a native whole-file lock and file locking between
67
- * php-wasm processes.
68
- *
69
- * A FileLock supports php-wasm whole-file locks and byte range locks.
70
- * Before granting a php-wasm lock, a FileLock ensures that it first holds a compatible
71
- * native lock. If a compatible native lock cannot be acquired, the php-wasm lock is
72
- * not granted.
73
- */
74
- export declare class FileLock {
75
- /**
76
- * Create a new FileLock instance for the given file and mode.
77
- * Fail if the underlying native file lock cannot be acquired.
78
- *
79
- * @param path The path to the file to lock
80
- * @param mode The type of lock to acquire
81
- * @returns A FileLock instance if the lock was acquired, undefined otherwise
82
- */
83
- static maybeCreate(path: string, mode: Exclude<WholeFileLock['type'], 'unlocked'>, nativeFlockSync: NativeFlockSync): FileLock | undefined;
84
- private nativeLock;
85
- private wholeFileLock;
86
- private rangeLocks;
87
- private constructor();
88
- /**
89
- * Close the file descriptor and release the native lock.
90
- *
91
- * @TODO Replace this with a Symbol.dispose property once supported by all JS runtimes.
92
- */
93
- dispose(): void;
94
- /**
95
- * Lock the whole file.
96
- *
97
- * This method corresponds to the flock() function.
98
- *
99
- * @param op The whole file lock operation to perform.
100
- * @returns True if the lock was granted, false otherwise.
101
- */
102
- lockWholeFile(op: WholeFileLockOp): boolean;
103
- /**
104
- * Lock a byte range.
105
- *
106
- * This method corresponds to the fcntl() F_SETLK command.
107
- *
108
- * @param requestedLock The byte range lock to perform.
109
- * @returns True if the lock was granted, false otherwise.
110
- */
111
- lockFileByteRange(requestedLock: RequestedRangeLock): boolean;
112
- /**
113
- * Find the first conflicting byte range lock.
114
- *
115
- * This method corresponds to the fcntl() F_GETLK command.
116
- *
117
- * @param desiredLock The desired byte range lock.
118
- * @returns The first conflicting byte range lock, or undefined if no conflicting lock exists.
119
- */
120
- findFirstConflictingByteRangeLock(desiredLock: RequestedRangeLock): RequestedRangeLock | undefined;
121
- /**
122
- * Release all locks for the given process.
123
- *
124
- * @param pid The process ID to release locks for.
125
- */
126
- releaseLocksForProcess(pid: Pid): void;
127
- /**
128
- * Release all locks for the given process and file descriptor.
129
- *
130
- * @param pid The process ID to release locks for.
131
- * @param fd The file descriptor to release locks for.
132
- */
133
- releaseLocksForProcessFd(pid: Pid, fd: Fd): void;
134
- /**
135
- * Check if the file lock is unlocked.
136
- *
137
- * @returns True if the file lock is unlocked, false otherwise.
138
- */
139
- isUnlocked(): boolean;
140
- /**
141
- * Ensure that the native lock is compatible with the php-wasm lock,
142
- * upgrading or downgrading as needed.
143
- *
144
- * @param overrideWholeFileLockType If provided, use this type for the whole file lock.
145
- * @param overrideRangeLockType If provided, use this type for the range lock.
146
- * @returns True if the native lock was upgraded or downgraded, false otherwise.
147
- */
148
- private ensureCompatibleNativeLock;
149
- /**
150
- * Check if a lock exists that conflicts with the requested range lock.
151
- *
152
- * @param requestedLock The desired byte range lock.
153
- * @returns True if a conflicting lock exists, false otherwise.
154
- */
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;
163
- }
164
- export {};
@@ -1,96 +0,0 @@
1
- /**
2
- * This is an interface used to abstract byte range locking like fcntl()
3
- * and whole-file locking like flock().
4
- */
5
- export type FileLockManager = {
6
- /**
7
- * Update the lock on the whole file.
8
- *
9
- * This method is for updating the lock on the whole file with the F_SETLKW fcntl() command.
10
- * https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLKW-1
11
- *
12
- * @param path - The path of the file to lock. This should be the path of the file in the
13
- * underlying filesystem.
14
- * @param op - The operation to perform, including 'shared', 'exclusive', or 'unlock'.
15
- * @returns A promise for a boolean value.
16
- */
17
- lockWholeFile: (path: string, op: WholeFileLockOp) => boolean;
18
- /**
19
- * Update the lock on a byte range of a file.
20
- *
21
- * This method is for locking with the F_SETLK fcntl() command.
22
- * https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fSETLK-1
23
- *
24
- * @param path - The path of the file to lock. This should be the path of the file in the
25
- * underlying filesystem.
26
- * @param requestedLock - The lock to request, including start, end, type, and pid.
27
- * @returns A promise for a boolean value.
28
- * When locking: True if the lock was acquired, false if it was not.
29
- * When unlocking: Always true.
30
- */
31
- lockFileByteRange: (path: string, requestedLock: RequestedRangeLock) => boolean;
32
- /**
33
- * Get the first lock that would conflict with the specified lock.
34
- *
35
- * This method is meant to satisfy the needs of the F_GETLK fcntl() command.
36
- * https://sourceware.org/glibc/manual/2.41/html_node/File-Locks.html#index-F_005fGETLK-1
37
- *
38
- * @param path - The path of the file to check for conflicts. This should be the path
39
- * of the file in the underlying filesystem.
40
- * @param desiredLock - The lock to check for conflicts.
41
- * @returns A promise for the first conflicting lock,
42
- * or undefined if there is no conflict.
43
- */
44
- findFirstConflictingByteRangeLock: (path: string, desiredLock: RequestedRangeLock) => Omit<RequestedRangeLock, 'fd'> | undefined;
45
- /**
46
- * Release all locks for a given process.
47
- *
48
- * Used when a process exits or is otherwise terminated.
49
- *
50
- * @param pid - The PID of the process that wants to release the locks.
51
- */
52
- releaseLocksForProcess: (pid: number) => void;
53
- /**
54
- * Release all locks for the given process and file descriptor.
55
- *
56
- * @param pid The process ID to release locks for.
57
- * @param fd The file descriptor to release locks for.
58
- * @param path The path to the file to release locks for. This should be the path
59
- * of the file in the underlying filesystem.
60
- */
61
- releaseLocksForProcessFd: (pid: number, fd: number, path: string) => void;
62
- };
63
- export type RequestedRangeLock = Readonly<{
64
- /** The type of lock request */
65
- type: 'shared' | 'exclusive' | 'unlocked';
66
- /** The start offset of the lock range */
67
- start: bigint;
68
- /** The end of the lock range */
69
- end: bigint;
70
- /** The process ID that owns this lock */
71
- pid: Pid;
72
- }>;
73
- export type WholeFileLock = Readonly<WholeFileLock_Exclusive | WholeFileLock_Shared | WholeFileLock_Unlocked>;
74
- export type Pid = number;
75
- export type Fd = number;
76
- export type WholeFileLock_Exclusive = {
77
- type: 'exclusive';
78
- pid: Pid;
79
- fd: Fd;
80
- };
81
- export type WholeFileLock_Shared = {
82
- type: 'shared';
83
- /**
84
- * NOTE: flock() locks are associated with open file descriptors and duplicated file descriptors.
85
- * We do not currently recognize duplicate file descriptors.
86
- */
87
- pidFds: Map<Pid, Set<Fd>>;
88
- };
89
- export type WholeFileLock_Unlocked = {
90
- type: 'unlocked';
91
- };
92
- export type WholeFileLockOp = {
93
- pid: number;
94
- fd: number;
95
- type: 'shared' | 'exclusive' | 'unlock';
96
- };
@@ -1,9 +0,0 @@
1
- export declare class SyscallsForNode {
2
- /**
3
- * Resolve a hostname to an IP address.
4
- *
5
- * @param hostname The hostname to resolve.
6
- * @returns The IP address of the hostname as a string.
7
- */
8
- gethostbyname(hostname: string): Promise<string>;
9
- }