@php-wasm/universal 0.9.18 → 0.9.20

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/lib/php.d.ts ADDED
@@ -0,0 +1,314 @@
1
+ import { PHPResponse } from './php-response';
2
+ import type { PHPRuntimeId } from './load-php-runtime';
3
+ import { MessageListener, PHPRequest, PHPRequestHeaders, PHPRunOptions, SpawnHandler, PHPEventListener, PHPEvent } from './universal-php';
4
+ import { RmDirOptions, ListFilesOptions } from './fs-helpers';
5
+ import { Semaphore } from '../../../util/src/index.ts';
6
+ import { PHPRequestHandler } from './php-request-handler';
7
+ import { Emscripten } from './emscripten-types';
8
+ export declare const __private__dont__use: unique symbol;
9
+ export declare class PHPExecutionFailureError extends Error {
10
+ response: PHPResponse;
11
+ source: 'request' | 'php-wasm';
12
+ constructor(message: string, response: PHPResponse, source: 'request' | 'php-wasm');
13
+ }
14
+ export type UnmountFunction = (() => Promise<any>) | (() => any);
15
+ export type MountHandler = (php: PHP, FS: Emscripten.RootFS, vfsMountPoint: string) => UnmountFunction | Promise<UnmountFunction>;
16
+ export declare const PHP_INI_PATH = "/internal/shared/php.ini";
17
+ /**
18
+ * An environment-agnostic wrapper around the Emscripten PHP runtime
19
+ * that universals the super low-level API and provides a more convenient
20
+ * higher-level API.
21
+ *
22
+ * It exposes a minimal set of methods to run PHP scripts and to
23
+ * interact with the PHP filesystem.
24
+ */
25
+ export declare class PHP implements Disposable {
26
+ #private;
27
+ protected [__private__dont__use]: any;
28
+ requestHandler?: PHPRequestHandler;
29
+ /**
30
+ * An exclusive lock that prevent multiple requests from running at
31
+ * the same time.
32
+ */
33
+ semaphore: Semaphore;
34
+ /**
35
+ * Initializes a PHP runtime.
36
+ *
37
+ * @internal
38
+ * @param PHPRuntime - Optional. PHP Runtime ID as initialized by loadPHPRuntime.
39
+ * @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
40
+ */
41
+ constructor(PHPRuntimeId?: PHPRuntimeId);
42
+ /**
43
+ * Adds an event listener for a PHP event.
44
+ * @param eventType - The type of event to listen for.
45
+ * @param listener - The listener function to be called when the event is triggered.
46
+ */
47
+ addEventListener(eventType: PHPEvent['type'], listener: PHPEventListener): void;
48
+ /**
49
+ * Removes an event listener for a PHP event.
50
+ * @param eventType - The type of event to remove the listener from.
51
+ * @param listener - The listener function to be removed.
52
+ */
53
+ removeEventListener(eventType: PHPEvent['type'], listener: PHPEventListener): void;
54
+ dispatchEvent<Event extends PHPEvent>(event: Event): void;
55
+ /**
56
+ * Listens to message sent by the PHP code.
57
+ *
58
+ * To dispatch messages, call:
59
+ *
60
+ * post_message_to_js(string $data)
61
+ *
62
+ * Arguments:
63
+ * $data (string) – Data to pass to JavaScript.
64
+ *
65
+ * @example
66
+ *
67
+ * ```ts
68
+ * const php = await PHP.load('8.0');
69
+ *
70
+ * php.onMessage(
71
+ * // The data is always passed as a string
72
+ * function (data: string) {
73
+ * // Let's decode and log the data:
74
+ * console.log(JSON.parse(data));
75
+ * }
76
+ * );
77
+ *
78
+ * // Now that we have a listener in place, let's
79
+ * // dispatch a message:
80
+ * await php.run({
81
+ * code: `<?php
82
+ * post_message_to_js(
83
+ * json_encode([
84
+ * 'post_id' => '15',
85
+ * 'post_title' => 'This is a blog post!'
86
+ * ])
87
+ * ));
88
+ * `,
89
+ * });
90
+ * ```
91
+ *
92
+ * @param listener Callback function to handle the message.
93
+ */
94
+ onMessage(listener: MessageListener): void;
95
+ setSpawnHandler(handler: SpawnHandler | string): Promise<void>;
96
+ /** @deprecated Use PHPRequestHandler instead. */
97
+ get absoluteUrl(): string;
98
+ /** @deprecated Use PHPRequestHandler instead. */
99
+ get documentRoot(): string;
100
+ /** @deprecated Use PHPRequestHandler instead. */
101
+ pathToInternalUrl(path: string): string;
102
+ /** @deprecated Use PHPRequestHandler instead. */
103
+ internalUrlToPath(internalUrl: string): string;
104
+ initializeRuntime(runtimeId: PHPRuntimeId): void;
105
+ /** @inheritDoc */
106
+ setSapiName(newName: string): Promise<void>;
107
+ /**
108
+ * Changes the current working directory in the PHP filesystem.
109
+ * This is the directory that will be used as the base for relative paths.
110
+ * For example, if the current working directory is `/root/php`, and the
111
+ * path is `data`, the absolute path will be `/root/php/data`.
112
+ *
113
+ * @param path - The new working directory.
114
+ */
115
+ chdir(path: string): void;
116
+ /**
117
+ * Do not use. Use new PHPRequestHandler() instead.
118
+ * @deprecated
119
+ */
120
+ request(request: PHPRequest): Promise<PHPResponse>;
121
+ /**
122
+ * Runs PHP code.
123
+ *
124
+ * This low-level method directly interacts with the WebAssembly
125
+ * PHP interpreter.
126
+ *
127
+ * Every time you call run(), it prepares the PHP
128
+ * environment and:
129
+ *
130
+ * * Resets the internal PHP state
131
+ * * Populates superglobals ($_SERVER, $_GET, etc.)
132
+ * * Handles file uploads
133
+ * * Populates input streams (stdin, argv, etc.)
134
+ * * Sets the current working directory
135
+ *
136
+ * You can use run() in two primary modes:
137
+ *
138
+ * ### Code snippet mode
139
+ *
140
+ * In this mode, you pass a string containing PHP code to run.
141
+ *
142
+ * ```ts
143
+ * const result = await php.run({
144
+ * code: `<?php echo "Hello world!";`
145
+ * });
146
+ * // result.text === "Hello world!"
147
+ * ```
148
+ *
149
+ * In this mode, information like __DIR__ or __FILE__ isn't very
150
+ * useful because the code is not associated with any file.
151
+ *
152
+ * Under the hood, the PHP snippet is passed to the `zend_eval_string`
153
+ * C function.
154
+ *
155
+ * ### File mode
156
+ *
157
+ * In the file mode, you pass a scriptPath and PHP executes a file
158
+ * found at a that path:
159
+ *
160
+ * ```ts
161
+ * php.writeFile(
162
+ * "/www/index.php",
163
+ * `<?php echo "Hello world!";"`
164
+ * );
165
+ * const result = await php.run({
166
+ * scriptPath: "/www/index.php"
167
+ * });
168
+ * // result.text === "Hello world!"
169
+ * ```
170
+ *
171
+ * In this mode, you can rely on path-related information like __DIR__
172
+ * or __FILE__.
173
+ *
174
+ * Under the hood, the PHP file is executed with the `php_execute_script`
175
+ * C function.
176
+ *
177
+ * The `run()` method cannot be used in conjunction with `cli()`.
178
+ *
179
+ * @example
180
+ * ```js
181
+ * const result = await php.run(`<?php
182
+ * $fp = fopen('php://stderr', 'w');
183
+ * fwrite($fp, "Hello, world!");
184
+ * `);
185
+ * // result.errors === "Hello, world!"
186
+ * ```
187
+ *
188
+ * @param options - PHP runtime options.
189
+ */
190
+ run(request: PHPRunOptions): Promise<PHPResponse>;
191
+ /**
192
+ * Defines a constant in the PHP runtime.
193
+ * @param key - The name of the constant.
194
+ * @param value - The value of the constant.
195
+ */
196
+ defineConstant(key: string, value: string | boolean | number | null): void;
197
+ /**
198
+ * Recursively creates a directory with the given path in the PHP filesystem.
199
+ * For example, if the path is `/root/php/data`, and `/root` already exists,
200
+ * it will create the directories `/root/php` and `/root/php/data`.
201
+ *
202
+ * @param path - The directory path to create.
203
+ */
204
+ mkdir(path: string): void;
205
+ /**
206
+ * @deprecated Use mkdir instead.
207
+ */
208
+ mkdirTree(path: string): void;
209
+ /**
210
+ * Reads a file from the PHP filesystem and returns it as a string.
211
+ *
212
+ * @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
213
+ * @param path - The file path to read.
214
+ * @returns The file contents.
215
+ */
216
+ readFileAsText(path: string): string;
217
+ /**
218
+ * Reads a file from the PHP filesystem and returns it as an array buffer.
219
+ *
220
+ * @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
221
+ * @param path - The file path to read.
222
+ * @returns The file contents.
223
+ */
224
+ readFileAsBuffer(path: string): Uint8Array;
225
+ /**
226
+ * Overwrites data in a file in the PHP filesystem.
227
+ * Creates a new file if one doesn't exist yet.
228
+ *
229
+ * @param path - The file path to write to.
230
+ * @param data - The data to write to the file.
231
+ */
232
+ writeFile(path: string, data: string | Uint8Array): void;
233
+ /**
234
+ * Removes a file from the PHP filesystem.
235
+ *
236
+ * @throws {@link @php-wasm/universal:ErrnoError} – If the file doesn't exist.
237
+ * @param path - The file path to remove.
238
+ */
239
+ unlink(path: string): void;
240
+ /**
241
+ * Moves a file or directory in the PHP filesystem to a
242
+ * new location.
243
+ *
244
+ * @param oldPath The path to rename.
245
+ * @param newPath The new path.
246
+ */
247
+ mv(fromPath: string, toPath: string): void;
248
+ /**
249
+ * Removes a directory from the PHP filesystem.
250
+ *
251
+ * @param path The directory path to remove.
252
+ * @param options Options for the removal.
253
+ */
254
+ rmdir(path: string, options?: RmDirOptions): void;
255
+ /**
256
+ * Lists the files and directories in the given directory.
257
+ *
258
+ * @param path - The directory path to list.
259
+ * @param options - Options for the listing.
260
+ * @returns The list of files and directories in the given directory.
261
+ */
262
+ listFiles(path: string, options?: ListFilesOptions): string[];
263
+ /**
264
+ * Checks if a directory exists in the PHP filesystem.
265
+ *
266
+ * @param path – The path to check.
267
+ * @returns True if the path is a directory, false otherwise.
268
+ */
269
+ isDir(path: string): boolean;
270
+ /**
271
+ * Checks if a file (or a directory) exists in the PHP filesystem.
272
+ *
273
+ * @param path - The file path to check.
274
+ * @returns True if the file exists, false otherwise.
275
+ */
276
+ fileExists(path: string): boolean;
277
+ /**
278
+ * Hot-swaps the PHP runtime for a new one without
279
+ * interrupting the operations of this PHP instance.
280
+ *
281
+ * @param runtime
282
+ * @param cwd. Internal, the VFS path to recreate in the new runtime.
283
+ * This arg is temporary and will be removed once BasePHP
284
+ * is fully decoupled from the request handler and
285
+ * accepts a constructor-level cwd argument.
286
+ */
287
+ hotSwapPHPRuntime(runtime: number, cwd?: string): void;
288
+ /**
289
+ * Mounts a filesystem to a given path in the PHP filesystem.
290
+ *
291
+ * @param virtualFSPath - Where to mount it in the PHP virtual filesystem.
292
+ * @param mountHandler - The mount handler to use.
293
+ * @return Unmount function to unmount the filesystem.
294
+ */
295
+ mount(virtualFSPath: string, mountHandler: MountHandler): Promise<UnmountFunction>;
296
+ /**
297
+ * Starts a PHP CLI session with given arguments.
298
+ *
299
+ * This method can only be used when PHP was compiled with the CLI SAPI
300
+ * and it cannot be used in conjunction with `run()`.
301
+ *
302
+ * Once this method finishes running, the PHP instance is no
303
+ * longer usable and should be discarded. This is because PHP
304
+ * internally cleans up all the resources and calls exit().
305
+ *
306
+ * @param argv - The arguments to pass to the CLI.
307
+ * @returns The exit code of the CLI session.
308
+ */
309
+ cli(argv: string[]): Promise<number>;
310
+ setSkipShebang(shouldSkip: boolean): void;
311
+ exit(code?: number): void;
312
+ [Symbol.dispose](): void;
313
+ }
314
+ export declare function normalizeHeaders(headers: PHPRequestHeaders): PHPRequestHeaders;
@@ -0,0 +1,7 @@
1
+ import { PHP } from './php';
2
+ /**
3
+ * Proxy specific paths to the parent's MEMFS instance.
4
+ * This is useful for sharing the WordPress installation
5
+ * between the parent and child processes.
6
+ */
7
+ export declare function proxyFileSystem(sourceOfTruth: PHP, replica: PHP, paths: string[]): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Emscripten's filesystem-related Exception.
3
+ *
4
+ * @see https://emscripten.org/docs/api_reference/Filesystem-API.html
5
+ * @see https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/arch/emscripten/bits/errno.h
6
+ * @see https://github.com/emscripten-core/emscripten/blob/38eedc630f17094b3202fd48ac0c2c585dbea31e/system/include/wasi/api.h#L336
7
+ */
8
+ export interface ErrnoError extends Error {
9
+ node?: any;
10
+ errno: number;
11
+ message: string;
12
+ }
13
+ /**
14
+ * @see https://github.com/emscripten-core/emscripten/blob/38eedc630f17094b3202fd48ac0c2c585dbea31e/system/include/wasi/api.h#L336
15
+ */
16
+ export declare const FileErrorCodes: any;
17
+ export declare function getEmscriptenFsError(e: any): any;
18
+ export declare function rethrowFileSystemError(messagePrefix?: string): (target: any, methodName: string, descriptor: PropertyDescriptor) => void;
@@ -0,0 +1,24 @@
1
+ import { PHP } from './php';
2
+ export interface RotateOptions {
3
+ php: PHP;
4
+ cwd: string;
5
+ recreateRuntime: () => Promise<number> | number;
6
+ maxRequests: number;
7
+ }
8
+ /**
9
+ * Listens to PHP events and swaps the internal PHP Runtime for a fresh one
10
+ * after a certain number of run() calls (which are responsible for handling
11
+ * HTTP requests).
12
+ *
13
+ * Why? Because PHP and PHP extension have a memory leak. Each request leaves
14
+ * the memory a bit more fragmented and with a bit less available space than
15
+ * before. Eventually, new allocations start failing.
16
+ *
17
+ * Rotating the PHP instance may seem like a workaround, but it's actually
18
+ * what PHP-FPM does natively:
19
+ *
20
+ * https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-tasks
21
+ *
22
+ * @return cleanup function to restore
23
+ */
24
+ export declare function rotatePHPRuntime({ php, cwd, recreateRuntime, maxRequests, }: RotateOptions): () => void;
@@ -0,0 +1,5 @@
1
+ import { UniversalPHP } from './universal-php';
2
+ /**
3
+ * Reads a file from PHP filesystem using a stream.
4
+ */
5
+ export declare function streamReadFileFromPHP(php: UniversalPHP, path: string): ReadableStream<any>;
@@ -0,0 +1,7 @@
1
+ export type SupportedPHPExtension = 'iconv' | 'mbstring' | 'xml-bundle' | 'gd';
2
+ export declare const SupportedPHPExtensionsList: string[];
3
+ export declare const SupportedPHPExtensionBundles: {
4
+ 'kitchen-sink': string[];
5
+ light: never[];
6
+ };
7
+ export type SupportedPHPExtensionBundle = 'kitchen-sink' | 'light';
@@ -0,0 +1,4 @@
1
+ export declare const SupportedPHPVersions: readonly ["8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2", "7.1", "7.0"];
2
+ export declare const LatestSupportedPHPVersion: "8.3";
3
+ export declare const SupportedPHPVersionsList: string[];
4
+ export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
@@ -0,0 +1,121 @@
1
+ import { Remote } from 'comlink';
2
+ import { LimitedPHPApi } from './php-worker';
3
+ /**
4
+ * Represents an event related to the PHP request.
5
+ */
6
+ export interface PHPRequestEndEvent {
7
+ type: 'request.end';
8
+ }
9
+ /**
10
+ * Represents an error event related to the PHP request.
11
+ */
12
+ export interface PHPRequestErrorEvent {
13
+ type: 'request.error';
14
+ error: Error;
15
+ source?: 'request' | 'php-wasm';
16
+ }
17
+ /**
18
+ * Represents a PHP runtime initialization event.
19
+ */
20
+ export interface PHPRuntimeInitializedEvent {
21
+ type: 'runtime.initialized';
22
+ }
23
+ /**
24
+ * Represents a PHP runtime destruction event.
25
+ */
26
+ export interface PHPRuntimeBeforeDestroyEvent {
27
+ type: 'runtime.beforedestroy';
28
+ }
29
+ /**
30
+ * Represents an event related to the PHP instance.
31
+ * This is intentionally not an extension of CustomEvent
32
+ * to make it isomorphic between different JavaScript runtimes.
33
+ */
34
+ export type PHPEvent = PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
35
+ /**
36
+ * A callback function that handles PHP events.
37
+ */
38
+ export type PHPEventListener = (event: PHPEvent) => void;
39
+ export type UniversalPHP = LimitedPHPApi | Remote<LimitedPHPApi>;
40
+ export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
41
+ interface EventEmitter {
42
+ on(event: string, listener: (...args: any[]) => void): this;
43
+ emit(event: string, ...args: any[]): boolean;
44
+ }
45
+ type ChildProcess = EventEmitter & {
46
+ stdout: EventEmitter;
47
+ stderr: EventEmitter;
48
+ };
49
+ export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
50
+ export type HTTPMethod = 'GET' | 'POST' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'PUT' | 'DELETE';
51
+ export type PHPRequestHeaders = Record<string, string>;
52
+ export interface PHPRequest {
53
+ /**
54
+ * Request method. Default: `GET`.
55
+ */
56
+ method?: HTTPMethod;
57
+ /**
58
+ * Request path or absolute URL.
59
+ */
60
+ url: string;
61
+ /**
62
+ * Request headers.
63
+ */
64
+ headers?: PHPRequestHeaders;
65
+ /**
66
+ * Request body.
67
+ * If an object is given, the request will be encoded as multipart
68
+ * and sent with a `multipart/form-data` header.
69
+ */
70
+ body?: string | Uint8Array | Record<string, string | Uint8Array | File>;
71
+ }
72
+ export interface PHPRunOptions {
73
+ /**
74
+ * Request path following the domain:port part.
75
+ */
76
+ relativeUri?: string;
77
+ /**
78
+ * Path of the .php file to execute.
79
+ */
80
+ scriptPath?: string;
81
+ /**
82
+ * Request protocol.
83
+ */
84
+ protocol?: string;
85
+ /**
86
+ * Request method. Default: `GET`.
87
+ */
88
+ method?: HTTPMethod;
89
+ /**
90
+ * Request headers.
91
+ */
92
+ headers?: PHPRequestHeaders;
93
+ /**
94
+ * Request body.
95
+ */
96
+ body?: string | Uint8Array;
97
+ /**
98
+ * Environment variables to set for this run.
99
+ */
100
+ env?: Record<string, string>;
101
+ /**
102
+ * $_SERVER entries to set for this run.
103
+ */
104
+ $_SERVER?: Record<string, string>;
105
+ /**
106
+ * The code snippet to eval instead of a php file.
107
+ */
108
+ code?: string;
109
+ }
110
+ /**
111
+ * Output of the PHP.wasm runtime.
112
+ */
113
+ export interface PHPOutput {
114
+ /** Exit code of the PHP process. 0 means success, 1 and 2 mean error. */
115
+ exitCode: number;
116
+ /** Stdout data */
117
+ stdout: ArrayBuffer;
118
+ /** Stderr lines */
119
+ stderr: string[];
120
+ }
121
+ export {};
package/lib/urls.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The default base used to convert a path into the URL object.
3
+ */
4
+ export declare const DEFAULT_BASE_URL = "http://example.com";
5
+ /**
6
+ * Returns a string representing the path, query, and
7
+ * fragment of the given URL.
8
+ *
9
+ * @example
10
+ * ```js
11
+ * const url = new URL('http://example.com/foo/bar?baz=qux#quux');
12
+ * toRelativeUrl(url); // '/foo/bar?baz=qux#quux'
13
+ * ```
14
+ *
15
+ * @param url The URL.
16
+ * @returns The path, query, and fragment.
17
+ */
18
+ export declare function toRelativeUrl(url: URL): string;
19
+ /**
20
+ * Removes the given prefix from the given path.
21
+ *
22
+ * @example
23
+ * ```js
24
+ * removePathPrefix('/foo/bar', '/foo'); // '/bar'
25
+ * removePathPrefix('/bar', '/foo'); // '/bar'
26
+ * ```
27
+ *
28
+ * @param path The path to remove the prefix from.
29
+ * @param prefix The prefix to remove.
30
+ * @returns Path with the prefix removed.
31
+ */
32
+ export declare function removePathPrefix(path: string, prefix: string): string;
33
+ /**
34
+ * Ensures the given path has the given prefix.
35
+ *
36
+ * @example
37
+ * ```js
38
+ * ensurePathPrefix('/bar', '/foo'); // '/foo/bar'
39
+ * ensurePathPrefix('/foo/bar', '/foo'); // '/foo/bar'
40
+ * ```
41
+ *
42
+ * @param path
43
+ * @param prefix
44
+ * @returns Path with the prefix added.
45
+ */
46
+ export declare function ensurePathPrefix(path: string, prefix: string): string;
@@ -0,0 +1,26 @@
1
+ type Runtime = {
2
+ wasmExports: Record<string, unknown>;
3
+ lastAsyncifyStackSource?: Error;
4
+ };
5
+ export declare class UnhandledRejectionsTarget extends EventTarget {
6
+ listenersCount: number;
7
+ addEventListener(type: unknown, callback: unknown): void;
8
+ removeEventListener(type: unknown, callback: unknown): void;
9
+ hasListeners(): boolean;
10
+ }
11
+ /**
12
+ * Creates Asyncify errors listener.
13
+ *
14
+ * Emscripten turns Asyncify errors into unhandled rejections by
15
+ * throwing them outside of the context of the original function call.
16
+ *
17
+ * With this listener, we can catch and rethrow them in a proper context,
18
+ * or at least log them in a more readable way.
19
+ *
20
+ * @param runtime
21
+ */
22
+ export declare function improveWASMErrorReporting(runtime: Runtime): UnhandledRejectionsTarget;
23
+ export declare function getFunctionsMaybeMissingFromAsyncify(): string[];
24
+ export declare function clarifyErrorMessage(crypticError: Error, asyncifyStack?: string): string;
25
+ export declare function showCriticalErrorBox(message: string): void;
26
+ export {};
@@ -0,0 +1,5 @@
1
+ import { UniversalPHP } from './universal-php';
2
+ /**
3
+ * Writes streamed files to PHP filesystem.
4
+ */
5
+ export declare function writeFilesStreamToPhp(php: UniversalPHP, root: string): WritableStream<File>;
@@ -0,0 +1,28 @@
1
+ import { UniversalPHP } from './universal-php';
2
+ export interface WriteFilesOptions {
3
+ /**
4
+ * Whether to wipe out the contents of the
5
+ * root directory before writing the new files.
6
+ */
7
+ rmRoot?: boolean;
8
+ }
9
+ export interface FileTree extends Record<string, Uint8Array | string | FileTree> {
10
+ }
11
+ /**
12
+ * Writes multiple files to a specified directory in the Playground
13
+ * filesystem.
14
+ *
15
+ * @example ```ts
16
+ * await writeFiles(php, '/test', {
17
+ * 'file.txt': 'file',
18
+ * 'sub/file.txt': 'file',
19
+ * 'sub1/sub2/file.txt': 'file',
20
+ * });
21
+ * ```
22
+ *
23
+ * @param php
24
+ * @param root
25
+ * @param newFiles
26
+ * @param options
27
+ */
28
+ export declare function writeFiles(php: UniversalPHP, root: string, newFiles: FileTree, { rmRoot }?: WriteFilesOptions): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/universal",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "description": "PHP.wasm – emscripten bindings for PHP",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "module": "./index.js",
38
38
  "types": "index.d.ts",
39
39
  "license": "GPL-2.0-or-later",
40
- "gitHead": "13942923e970013ae9448c658e7c9ba8d4d85619",
40
+ "gitHead": "f619fcb719128d247bec296b9339aff52101e948",
41
41
  "engines": {
42
42
  "node": ">=18.18.0",
43
43
  "npm": ">=8.11.0"
@@ -45,10 +45,10 @@
45
45
  "dependencies": {
46
46
  "comlink": "^4.4.1",
47
47
  "ini": "4.1.2",
48
- "@php-wasm/node-polyfills": "0.9.18",
49
- "@php-wasm/logger": "0.9.18",
50
- "@php-wasm/util": "0.9.18",
51
- "@php-wasm/stream-compression": "0.9.18",
52
- "@php-wasm/progress": "0.9.18"
48
+ "@php-wasm/node-polyfills": "0.9.20",
49
+ "@php-wasm/logger": "0.9.20",
50
+ "@php-wasm/util": "0.9.20",
51
+ "@php-wasm/stream-compression": "0.9.20",
52
+ "@php-wasm/progress": "0.9.20"
53
53
  }
54
54
  }