@php-wasm/universal 1.0.28 → 1.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.
@@ -1,4 +1,4 @@
1
- import { Emscripten } from './emscripten-types';
1
+ import type { Emscripten } from './emscripten-types';
2
2
  export interface RmDirOptions {
3
3
  /**
4
4
  * If true, recursively removes the directory and all its contents.
@@ -1,7 +1,8 @@
1
+ import type { CookieStore } from './php-request-handler';
1
2
  /**
2
3
  * @public
3
4
  */
4
- export declare class HttpCookieStore {
5
+ export declare class HttpCookieStore implements CookieStore {
5
6
  cookies: Record<string, string>;
6
7
  rememberCookiesFromResponseHeaders(headers: Record<string, string[]>): void;
7
8
  getCookieRequestHeader(): string;
package/lib/index.d.ts CHANGED
@@ -18,11 +18,11 @@ export type { SupportedPHPVersion } from './supported-php-versions';
18
18
  export { PHP, __private__dont__use } from './php';
19
19
  export type { MountHandler, UnmountFunction } from './php';
20
20
  export { loadPHPRuntime, getLoadedRuntime } from './load-php-runtime';
21
- export type * from './emscripten-types';
21
+ export type { Emscripten } from './emscripten-types';
22
22
  export type { DataModule, EmscriptenOptions, PHPLoaderModule, PHPRuntime, PHPRuntimeId, RuntimeType, } from './load-php-runtime';
23
23
  export type { PHPRequestHandlerConfiguration, RewriteRule, } from './php-request-handler';
24
24
  export { PHPRequestHandler, applyRewriteRules } from './php-request-handler';
25
- export type { FileNotFoundGetActionCallback, FileNotFoundToInternalRedirect, FileNotFoundToResponse, FileNotFoundAction, } from './php-request-handler';
25
+ export type { FileNotFoundGetActionCallback, FileNotFoundToInternalRedirect, FileNotFoundToResponse, FileNotFoundAction, CookieStore, } from './php-request-handler';
26
26
  export { rotatePHPRuntime } from './rotate-php-runtime';
27
27
  export { writeFiles } from './write-files';
28
28
  export type { FileTree } from './write-files';
package/lib/ini.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UniversalPHP } from './universal-php';
1
+ import type { UniversalPHP } from './universal-php';
2
2
  /**
3
3
  * Reads the php.ini file and returns its entries.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { UniversalPHP } from './universal-php';
1
+ import type { UniversalPHP } from './universal-php';
2
2
  export type IteratePhpFilesOptions = {
3
3
  /**
4
4
  * Should yield paths relative to the root directory?
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { IncomingMessage, Server, ServerResponse } from 'http';
2
+ import type { IncomingMessage, Server, ServerResponse } from 'http';
3
3
  /**
4
4
  * Loads the PHP runtime with the given arguments and data dependencies.
5
5
  *
@@ -116,10 +116,10 @@ import { IncomingMessage, Server, ServerResponse } from 'http';
116
116
  *
117
117
  * @public
118
118
  * @param phpLoaderModule - The ESM-wrapped Emscripten module. Consult the Dockerfile for the build process.
119
- * @param phpModuleArgs - The Emscripten module arguments, see https://emscripten.org/docs/api_reference/module.html#affecting-execution.
119
+ * @param options - The Emscripten module arguments, see https://emscripten.org/docs/api_reference/module.html#affecting-execution.
120
120
  * @returns Loaded runtime id.
121
121
  */
122
- export declare function loadPHPRuntime(phpLoaderModule: PHPLoaderModule, phpModuleArgs?: EmscriptenOptions): Promise<number>;
122
+ export declare function loadPHPRuntime(phpLoaderModule: PHPLoaderModule, ...options: EmscriptenOptions[]): Promise<number>;
123
123
  export type RuntimeType = 'NODE' | 'WEB' | 'WORKER';
124
124
  export type PHPRuntimeId = number;
125
125
  export declare function getLoadedRuntime(id: PHPRuntimeId): PHPRuntime;
@@ -147,7 +147,7 @@ export type EmscriptenOptions = {
147
147
  print?: (message: string) => void;
148
148
  printErr?: (message: string) => void;
149
149
  quit?: (status: number, toThrow: any) => void;
150
- onRuntimeInitialized?: () => void;
150
+ onRuntimeInitialized?: (phpRuntime: PHPRuntime) => void;
151
151
  monitorRunDependencies?: (left: number) => void;
152
152
  onMessage?: (listener: EmscriptenMessageListener) => void;
153
153
  outboundNetworkProxyServer?: Server<typeof IncomingMessage, typeof ServerResponse>;
@@ -1,4 +1,4 @@
1
- import { PHP } from './php';
1
+ import type { PHP } from './php';
2
2
  export type PHPFactoryOptions = {
3
3
  isPrimary: boolean;
4
4
  };
@@ -1,7 +1,8 @@
1
- import { PHP } from './php';
1
+ import type { PHP } from './php';
2
2
  import { PHPResponse } from './php-response';
3
- import { PHPRequest } from './universal-php';
4
- import { PHPFactoryOptions, PHPProcessManager } from './php-process-manager';
3
+ import type { PHPRequest } from './universal-php';
4
+ import type { PHPFactoryOptions } from './php-process-manager';
5
+ import { PHPProcessManager } from './php-process-manager';
5
6
  export type RewriteRule = {
6
7
  match: RegExp;
7
8
  replacement: string;
@@ -19,6 +20,22 @@ export type FileNotFoundTo404 = {
19
20
  };
20
21
  export type FileNotFoundAction = FileNotFoundToResponse | FileNotFoundToInternalRedirect | FileNotFoundTo404;
21
22
  export type FileNotFoundGetActionCallback = (relativePath: string) => FileNotFoundAction;
23
+ /**
24
+ * Interface for cookie storage implementations.
25
+ * This allows different cookie handling strategies to be used with the PHP request handler.
26
+ */
27
+ export interface CookieStore {
28
+ /**
29
+ * Processes and stores cookies from response headers
30
+ * @param headers Response headers containing Set-Cookie directives
31
+ */
32
+ rememberCookiesFromResponseHeaders(headers: Record<string, string[]>): void;
33
+ /**
34
+ * Gets the cookie header string for the next request
35
+ * @returns Formatted cookie header string
36
+ */
37
+ getCookieRequestHeader(): string;
38
+ }
22
39
  interface BaseConfiguration {
23
40
  /**
24
41
  * The directory in the PHP filesystem where the server will look
@@ -62,7 +79,9 @@ export type PHPRequestHandlerConfiguration = BaseConfiguration & ({
62
79
  * the same time.
63
80
  */
64
81
  maxPhpInstances?: number;
65
- });
82
+ }) & {
83
+ cookieStore?: CookieStore | false;
84
+ };
66
85
  /**
67
86
  * Handles HTTP requests using PHP runtime as a backend.
68
87
  *
@@ -1,9 +1,9 @@
1
- import { EmscriptenDownloadMonitor } from '@php-wasm/progress';
2
- import { PHP } from './php';
3
- import { PHPRequestHandler } from './php-request-handler';
4
- import { PHPResponse } from './php-response';
5
- import { PHPRequest, PHPRunOptions, MessageListener, PHPEvent, PHPEventListener } from './universal-php';
6
- import { RmDirOptions, ListFilesOptions } from './fs-helpers';
1
+ import type { EmscriptenDownloadMonitor } from '@php-wasm/progress';
2
+ import type { PHP } from './php';
3
+ import type { PHPRequestHandler } from './php-request-handler';
4
+ import type { PHPResponse } from './php-response';
5
+ import type { PHPRequest, PHPRunOptions, MessageListener, PHPEvent, PHPEventListener } from './universal-php';
6
+ import type { RmDirOptions, ListFilesOptions } from './fs-helpers';
7
7
  export type LimitedPHPApi = Pick<PHP, 'request' | 'defineConstant' | 'addEventListener' | 'removeEventListener' | 'mkdir' | 'mkdirTree' | 'readFileAsText' | 'readFileAsBuffer' | 'writeFile' | 'unlink' | 'mv' | 'rmdir' | 'listFiles' | 'isDir' | 'fileExists' | 'chdir' | 'run' | 'onMessage'> & {
8
8
  documentRoot: PHP['documentRoot'];
9
9
  absoluteUrl: PHP['absoluteUrl'];
package/lib/php.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { PHPResponse } from './php-response';
2
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';
3
+ import type { MessageListener, PHPRequest, PHPRequestHeaders, PHPRunOptions, SpawnHandler, PHPEventListener, PHPEvent } from './universal-php';
4
+ import type { RmDirOptions, ListFilesOptions } from './fs-helpers';
5
5
  import { Semaphore } from '@php-wasm/util';
6
- import { PHPRequestHandler } from './php-request-handler';
7
- import { Emscripten } from './emscripten-types';
6
+ import type { PHPRequestHandler } from './php-request-handler';
7
+ import type { Emscripten } from './emscripten-types';
8
8
  export declare const __private__dont__use: unique symbol;
9
+ type ErrorSource = 'request' | 'php-wasm';
9
10
  export declare class PHPExecutionFailureError extends Error {
10
11
  response: PHPResponse;
11
- source: 'request' | 'php-wasm';
12
- constructor(message: string, response: PHPResponse, source: 'request' | 'php-wasm');
12
+ source: ErrorSource;
13
+ constructor(message: string, response: PHPResponse, source: ErrorSource);
13
14
  }
14
15
  export type UnmountFunction = (() => Promise<any>) | (() => any);
15
16
  export type MountHandler = (php: PHP, FS: Emscripten.RootFS, vfsMountPoint: string) => UnmountFunction | Promise<UnmountFunction>;
@@ -345,3 +346,4 @@ export declare class PHP implements Disposable {
345
346
  [Symbol.dispose](): void;
346
347
  }
347
348
  export declare function normalizeHeaders(headers: PHPRequestHeaders): PHPRequestHeaders;
349
+ export {};
@@ -1,4 +1,4 @@
1
- import { PHP } from './php';
1
+ import type { PHP } from './php';
2
2
  /**
3
3
  * Proxy specific paths to the parent's MEMFS instance.
4
4
  * This is useful for sharing the WordPress installation
@@ -15,4 +15,4 @@ export interface ErrnoError extends Error {
15
15
  */
16
16
  export declare const FileErrorCodes: any;
17
17
  export declare function getEmscriptenFsError(e: any): any;
18
- export declare function rethrowFileSystemError(messagePrefix?: string): (target: any, methodName: string, descriptor: PropertyDescriptor) => void;
18
+ export declare function rethrowFileSystemError(messagePrefix?: string): (value: (...args: any[]) => any) => (...args: any[]) => any;
@@ -1,4 +1,4 @@
1
- import { PHP } from './php';
1
+ import type { PHP } from './php';
2
2
  export interface RotateOptions {
3
3
  php: PHP;
4
4
  cwd: string;
@@ -1,4 +1,4 @@
1
- import { UniversalPHP } from './universal-php';
1
+ import type { UniversalPHP } from './universal-php';
2
2
  /**
3
3
  * Reads a file from PHP filesystem using a stream.
4
4
  */
@@ -1,4 +1,4 @@
1
- export declare const SupportedPHPVersions: readonly ["8.4", "8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2", "7.1", "7.0"];
1
+ export declare const SupportedPHPVersions: readonly ["8.4", "8.3", "8.2", "8.1", "8.0", "7.4", "7.3", "7.2"];
2
2
  export declare const LatestSupportedPHPVersion: "8.4";
3
3
  export declare const SupportedPHPVersionsList: string[];
4
4
  export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
@@ -1,5 +1,5 @@
1
- import { Remote } from 'comlink';
2
- import { LimitedPHPApi } from './php-worker';
1
+ import type { Remote } from 'comlink';
2
+ import type { LimitedPHPApi } from './php-worker';
3
3
  /**
4
4
  * Represents an event related to the PHP request.
5
5
  */
@@ -1,4 +1,4 @@
1
- import { UniversalPHP } from './universal-php';
1
+ import type { UniversalPHP } from './universal-php';
2
2
  /**
3
3
  * Writes streamed files to PHP filesystem.
4
4
  */
@@ -1,4 +1,6 @@
1
- import { UniversalPHP } from './universal-php';
1
+ import type { UniversalPHP } from './universal-php';
2
+ export interface FileTree extends Record<string, Uint8Array | string | FileTree> {
3
+ }
2
4
  export interface WriteFilesOptions {
3
5
  /**
4
6
  * Whether to wipe out the contents of the
@@ -6,8 +8,6 @@ export interface WriteFilesOptions {
6
8
  */
7
9
  rmRoot?: boolean;
8
10
  }
9
- export interface FileTree extends Record<string, Uint8Array | string | FileTree> {
10
- }
11
11
  /**
12
12
  * Writes multiple files to a specified directory in the Playground
13
13
  * filesystem.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/universal",
3
- "version": "1.0.28",
3
+ "version": "1.1.0",
4
4
  "description": "PHP.wasm – emscripten bindings for PHP",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,18 +37,25 @@
37
37
  "module": "./index.js",
38
38
  "types": "index.d.ts",
39
39
  "license": "GPL-2.0-or-later",
40
- "gitHead": "ed7171a91717c70dd7162e3d93283f66d21c001d",
40
+ "gitHead": "9dbbe2b22ccbacda9c0da4444c51d5739e784302",
41
41
  "engines": {
42
- "node": ">=18.18.0",
43
- "npm": ">=8.11.0"
42
+ "node": ">=20.18.3",
43
+ "npm": ">=10.1.0"
44
44
  },
45
45
  "dependencies": {
46
46
  "comlink": "^4.4.1",
47
47
  "ini": "4.1.2",
48
- "@php-wasm/node-polyfills": "1.0.28",
49
- "@php-wasm/logger": "1.0.28",
50
- "@php-wasm/util": "1.0.28",
51
- "@php-wasm/stream-compression": "1.0.28",
52
- "@php-wasm/progress": "1.0.28"
48
+ "@php-wasm/node-polyfills": "1.1.0",
49
+ "@php-wasm/logger": "1.1.0",
50
+ "@php-wasm/util": "1.1.0",
51
+ "@php-wasm/stream-compression": "1.1.0",
52
+ "@php-wasm/progress": "1.1.0"
53
+ },
54
+ "overrides": {
55
+ "rollup": "^4.34.6",
56
+ "react": "18.3.1",
57
+ "react-dom": "18.3.1",
58
+ "typescript": "5.4.5",
59
+ "ws": "^8.18.0"
53
60
  }
54
- }
61
+ }