@php-wasm/universal 3.1.1 → 3.1.3

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/index.d.ts CHANGED
@@ -48,3 +48,4 @@ export * from './file-lock-interval-tree';
48
48
  export type { Remote } from './comlink-sync';
49
49
  export { createObjectPoolProxy } from './object-pool-proxy';
50
50
  export type { Pooled } from './object-pool-proxy';
51
+ export * from './process-id-allocator';
@@ -1,5 +1,5 @@
1
1
  import type { PHP } from './php';
2
- import { PHPResponse } from './php-response';
2
+ import { PHPResponse, StreamedPHPResponse } from './php-response';
3
3
  import type { PHPRequest } from './universal-php';
4
4
  import type { PHPFactoryOptions } from './php-process-manager';
5
5
  import type { PHPInstanceManager } from './php-instance-manager';
@@ -261,6 +261,18 @@ export declare class PHPRequestHandler implements AsyncDisposable {
261
261
  * @param request - PHP Request data.
262
262
  */
263
263
  request(request: PHPRequest): Promise<PHPResponse>;
264
+ /**
265
+ * Serves the request with streaming support – returns a StreamedPHPResponse
266
+ * that allows processing the response body incrementally without buffering
267
+ * the entire response in memory.
268
+ *
269
+ * This is useful for large file downloads (>2GB) that would otherwise
270
+ * exceed JavaScript's Uint8Array size limits.
271
+ *
272
+ * @param request - PHP Request data.
273
+ * @returns A StreamedPHPResponse.
274
+ */
275
+ requestStreamed(request: PHPRequest): Promise<StreamedPHPResponse>;
264
276
  /**
265
277
  * Computes the essential $_SERVER entries for a request.
266
278
  *
@@ -23,10 +23,7 @@ export interface PHPResponseData {
23
23
  readonly httpStatusCode: number;
24
24
  }
25
25
  export declare class StreamedPHPResponse {
26
- /**
27
- * Response headers.
28
- */
29
- private readonly headersStream;
26
+ #private;
30
27
  /**
31
28
  * Response body. Contains the output from `echo`,
32
29
  * `print`, inline HTML etc.
@@ -45,6 +42,21 @@ export declare class StreamedPHPResponse {
45
42
  private cachedStdoutBytes;
46
43
  private cachedStderrText;
47
44
  constructor(headers: ReadableStream<Uint8Array>, stdout: ReadableStream<Uint8Array>, stderr: ReadableStream<Uint8Array>, exitCode: Promise<number>);
45
+ /**
46
+ * Creates a StreamedPHPResponse from a buffered PHPResponse.
47
+ * Useful for unifying response handling when both types may be returned.
48
+ */
49
+ static fromPHPResponse(response: PHPResponse): StreamedPHPResponse;
50
+ /**
51
+ * Creates a StreamedPHPResponse for a given HTTP status code.
52
+ * Shorthand for `StreamedPHPResponse.fromPHPResponse(PHPResponse.forHttpCode(...))`.
53
+ */
54
+ static forHttpCode(httpStatusCode: number, text?: string): StreamedPHPResponse;
55
+ /**
56
+ * Returns the raw headers stream for serialization purposes.
57
+ * For parsed headers, use the `headers` property instead.
58
+ */
59
+ getHeadersStream(): ReadableStream<Uint8Array>;
48
60
  /**
49
61
  * True if the response is successful (HTTP status code 200-399),
50
62
  * false otherwise.
@@ -59,6 +59,17 @@ export declare class PHPWorker implements LimitedPHPApi, AsyncDisposable {
59
59
  rmdir(path: string, options?: RmDirOptions): Promise<void>;
60
60
  /** @inheritDoc @php-wasm/universal!PHPRequestHandler.request */
61
61
  request(request: PHPRequest): Promise<PHPResponse>;
62
+ /**
63
+ * Handles a request with streaming support for large responses.
64
+ * Returns a StreamedPHPResponse that allows processing the response
65
+ * body incrementally without buffering the entire response in memory.
66
+ *
67
+ * This is useful for large file downloads (>2GB) that would otherwise
68
+ * exceed JavaScript's Uint8Array size limits.
69
+ *
70
+ * @param request - PHP Request data.
71
+ */
72
+ requestStreamed(request: PHPRequest): Promise<StreamedPHPResponse>;
62
73
  /** @inheritDoc @php-wasm/universal!/PHP.run */
63
74
  run(request: PHPRunOptions): Promise<PHPResponse>;
64
75
  /** @inheritDoc @php-wasm/universal!/PHP.cli */
package/lib/php.d.ts CHANGED
@@ -351,10 +351,18 @@ export declare class PHP implements Disposable {
351
351
  * Moves a file or directory in the PHP filesystem to a
352
352
  * new location.
353
353
  *
354
- * @param oldPath The path to rename.
355
- * @param newPath The new path.
354
+ * @param fromPath The path to rename.
355
+ * @param toPath The new path.
356
356
  */
357
357
  mv(fromPath: string, toPath: string): void;
358
+ /**
359
+ * Copies a file or directory in the PHP filesystem to a
360
+ * new location.
361
+ *
362
+ * @param fromPath The source path.
363
+ * @param toPath The target path.
364
+ */
365
+ cp(fromPath: string, toPath: string): void;
358
366
  /**
359
367
  * Removes a directory from the PHP filesystem.
360
368
  *
@@ -0,0 +1,9 @@
1
+ export declare class ProcessIdAllocator {
2
+ private initialId;
3
+ private maxId;
4
+ private nextId;
5
+ private claimed;
6
+ constructor(initialId?: number, maxId?: number);
7
+ claim(): number;
8
+ release(id: number): boolean;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/universal",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "PHP.wasm – emscripten bindings for PHP",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,18 +37,18 @@
37
37
  "module": "./index.js",
38
38
  "types": "index.d.ts",
39
39
  "license": "GPL-2.0-or-later",
40
- "gitHead": "71560d81fcde96435d5730a0430abcafaa6f92b8",
40
+ "gitHead": "54bb87ba4c9624ec02f60194a2f1938b3f42477b",
41
41
  "engines": {
42
42
  "node": ">=20.10.0",
43
43
  "npm": ">=10.2.3"
44
44
  },
45
45
  "dependencies": {
46
46
  "ini": "4.1.2",
47
- "@php-wasm/node-polyfills": "3.1.1",
48
- "@php-wasm/logger": "3.1.1",
49
- "@php-wasm/util": "3.1.1",
50
- "@php-wasm/stream-compression": "3.1.1",
51
- "@php-wasm/progress": "3.1.1"
47
+ "@php-wasm/node-polyfills": "3.1.3",
48
+ "@php-wasm/logger": "3.1.3",
49
+ "@php-wasm/util": "3.1.3",
50
+ "@php-wasm/stream-compression": "3.1.3",
51
+ "@php-wasm/progress": "3.1.3"
52
52
  },
53
53
  "packageManager": "npm@10.9.2",
54
54
  "overrides": {