@php-wasm/universal 3.1.1 → 3.1.2

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.
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/universal",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
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": "4a2f8903e9d4a58e33382f8f888ef94d42d913dc",
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.2",
48
+ "@php-wasm/logger": "3.1.2",
49
+ "@php-wasm/util": "3.1.2",
50
+ "@php-wasm/stream-compression": "3.1.2",
51
+ "@php-wasm/progress": "3.1.2"
52
52
  },
53
53
  "packageManager": "npm@10.9.2",
54
54
  "overrides": {