@php-wasm/universal 0.6.16 → 0.7.1
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/index.cjs +8 -8
- package/index.js +373 -294
- package/lib/base-php.d.ts +8 -6
- package/lib/http-cookie-store.d.ts +8 -0
- package/lib/index.d.ts +1 -3
- package/lib/load-php-runtime.d.ts +1 -0
- package/lib/php-request-handler.d.ts +125 -8
- package/lib/rotate-php-runtime.d.ts +2 -1
- package/lib/universal-php.d.ts +11 -135
- package/package.json +2 -2
- package/lib/php-browser.d.ts +0 -54
package/lib/base-php.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PHPRequestHandlerConfiguration } from './php-request-handler';
|
|
1
|
+
import { PHPRequestHandler, PHPRequestHandlerConfiguration } from './php-request-handler';
|
|
3
2
|
import { PHPResponse } from './php-response';
|
|
4
3
|
import type { PHPRuntimeId } from './load-php-runtime';
|
|
5
4
|
import { IsomorphicLocalPHP, MessageListener, PHPRequest, PHPRequestHeaders, PHPRunOptions, RmDirOptions, ListFilesOptions, SpawnHandler, PHPEventListener, PHPEvent } from './universal-php';
|
|
@@ -21,7 +20,7 @@ export declare class PHPExecutionFailureError extends Error {
|
|
|
21
20
|
export declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
22
21
|
#private;
|
|
23
22
|
protected [__private__dont__use]: any;
|
|
24
|
-
requestHandler?:
|
|
23
|
+
requestHandler?: PHPRequestHandler;
|
|
25
24
|
/**
|
|
26
25
|
* An exclusive lock that prevent multiple requests from running at
|
|
27
26
|
* the same time.
|
|
@@ -60,10 +59,9 @@ export declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
60
59
|
/** @inheritDoc */
|
|
61
60
|
chdir(path: string): void;
|
|
62
61
|
/** @inheritDoc */
|
|
63
|
-
request(request: PHPRequest
|
|
62
|
+
request(request: PHPRequest): Promise<PHPResponse>;
|
|
64
63
|
/** @inheritDoc */
|
|
65
64
|
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
66
|
-
addServerGlobalEntry(key: string, value: string): void;
|
|
67
65
|
defineConstant(key: string, value: string | boolean | number | null): void;
|
|
68
66
|
/** @inheritDoc */
|
|
69
67
|
mkdir(path: string): void;
|
|
@@ -92,8 +90,12 @@ export declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
92
90
|
* interrupting the operations of this PHP instance.
|
|
93
91
|
*
|
|
94
92
|
* @param runtime
|
|
93
|
+
* @param cwd. Internal, the VFS path to recreate in the new runtime.
|
|
94
|
+
* This arg is temporary and will be removed once BasePHP
|
|
95
|
+
* is fully decoupled from the request handler and
|
|
96
|
+
* accepts a constructor-level cwd argument.
|
|
95
97
|
*/
|
|
96
|
-
hotSwapPHPRuntime(runtime: number): void;
|
|
98
|
+
hotSwapPHPRuntime(runtime: number, cwd?: string): void;
|
|
97
99
|
exit(code?: number): void;
|
|
98
100
|
}
|
|
99
101
|
export declare function normalizeHeaders(headers: PHPRequestHeaders): PHPRequestHeaders;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { IsomorphicLocalPHP, IsomorphicRemotePHP, MessageListener, PHPOutput, PHPRunOptions, UniversalPHP, ListFilesOptions, RmDirOptions, PHPEvent, PHPEventListener, HTTPMethod, PHPRequest, PHPRequestHeaders,
|
|
1
|
+
export type { IsomorphicLocalPHP, IsomorphicRemotePHP, MessageListener, PHPOutput, PHPRunOptions, UniversalPHP, ListFilesOptions, RmDirOptions, PHPEvent, PHPEventListener, HTTPMethod, PHPRequest, PHPRequestHeaders, SpawnHandler, } from './universal-php';
|
|
2
2
|
export { UnhandledRejectionsTarget } from './wasm-error-reporting';
|
|
3
3
|
export type { IteratePhpFilesOptions as IterateFilesOptions } from './iterate-files';
|
|
4
4
|
export { iteratePhpFiles as iterateFiles } from './iterate-files';
|
|
@@ -18,8 +18,6 @@ export { isLocalPHP } from './is-local-php';
|
|
|
18
18
|
export { isRemotePHP } from './is-remote-php';
|
|
19
19
|
export type { PHPRequestHandlerConfiguration, RewriteRule, } from './php-request-handler';
|
|
20
20
|
export { PHPRequestHandler, applyRewriteRules } from './php-request-handler';
|
|
21
|
-
export type { PHPBrowserConfiguration } from './php-browser';
|
|
22
|
-
export { PHPBrowser } from './php-browser';
|
|
23
21
|
export { rotatePHPRuntime } from './rotate-php-runtime';
|
|
24
22
|
export { writeFiles } from './write-files';
|
|
25
23
|
export { DEFAULT_BASE_URL, ensurePathPrefix, removePathPrefix, toRelativeUrl, } from './urls';
|
|
@@ -145,5 +145,6 @@ export type EmscriptenOptions = {
|
|
|
145
145
|
onRuntimeInitialized?: () => void;
|
|
146
146
|
monitorRunDependencies?: (left: number) => void;
|
|
147
147
|
onMessage?: (listener: EmscriptenMessageListener) => void;
|
|
148
|
+
instantiateWasm?: (info: WebAssembly.Imports, receiveInstance: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void) => void;
|
|
148
149
|
} & Record<string, any>;
|
|
149
150
|
export type EmscriptenMessageListener = (type: string, data: string) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BasePHP } from './base-php';
|
|
2
2
|
import { PHPResponse } from './php-response';
|
|
3
|
-
import { PHPRequest
|
|
3
|
+
import { PHPRequest } from './universal-php';
|
|
4
4
|
export type RewriteRule = {
|
|
5
5
|
match: RegExp;
|
|
6
6
|
replacement: string;
|
|
@@ -20,8 +20,61 @@ export interface PHPRequestHandlerConfiguration {
|
|
|
20
20
|
*/
|
|
21
21
|
rewriteRules?: RewriteRule[];
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Handles HTTP requests using PHP runtime as a backend.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @example Use PHPRequestHandler implicitly with a new PHP instance:
|
|
28
|
+
* ```js
|
|
29
|
+
* import { PHP } from '../../../web/src/index.ts';
|
|
30
|
+
*
|
|
31
|
+
* const php = await PHP.load( '7.4', {
|
|
32
|
+
* requestHandler: {
|
|
33
|
+
* // PHP FS path to serve the files from:
|
|
34
|
+
* documentRoot: '/www',
|
|
35
|
+
*
|
|
36
|
+
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
37
|
+
* absoluteUrl: 'http://127.0.0.1'
|
|
38
|
+
* }
|
|
39
|
+
* } );
|
|
40
|
+
*
|
|
41
|
+
* php.mkdirTree('/www');
|
|
42
|
+
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
43
|
+
*
|
|
44
|
+
* const response = await php.request({ path: '/index.php' });
|
|
45
|
+
* console.log(response.text);
|
|
46
|
+
* // "Hi from PHP!"
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Explicitly create a PHPRequestHandler instance and run a PHP script:
|
|
50
|
+
* ```js
|
|
51
|
+
* import {
|
|
52
|
+
* loadPHPRuntime,
|
|
53
|
+
* PHP,
|
|
54
|
+
* PHPRequestHandler,
|
|
55
|
+
* getPHPLoaderModule,
|
|
56
|
+
* } from '@php-wasm/web';
|
|
57
|
+
*
|
|
58
|
+
* const runtime = await loadPHPRuntime( await getPHPLoaderModule('7.4') );
|
|
59
|
+
* const php = new PHP( runtime );
|
|
60
|
+
*
|
|
61
|
+
* php.mkdirTree('/www');
|
|
62
|
+
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
63
|
+
*
|
|
64
|
+
* const server = new PHPRequestHandler(php, {
|
|
65
|
+
* // PHP FS path to serve the files from:
|
|
66
|
+
* documentRoot: '/www',
|
|
67
|
+
*
|
|
68
|
+
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
69
|
+
* absoluteUrl: 'http://127.0.0.1'
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* const response = server.request({ path: '/index.php' });
|
|
73
|
+
* console.log(response.text);
|
|
74
|
+
* // "Hi from PHP!"
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare class PHPRequestHandler {
|
|
25
78
|
#private;
|
|
26
79
|
rewriteRules: RewriteRule[];
|
|
27
80
|
/**
|
|
@@ -33,16 +86,80 @@ export declare class PHPRequestHandler implements RequestHandler {
|
|
|
33
86
|
* @param config - Request Handler configuration.
|
|
34
87
|
*/
|
|
35
88
|
constructor(php: BasePHP, config?: PHPRequestHandlerConfiguration);
|
|
36
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
91
|
+
* root.
|
|
92
|
+
*
|
|
93
|
+
* @param path The server path to convert to an absolute URL.
|
|
94
|
+
* @returns The absolute URL.
|
|
95
|
+
*/
|
|
37
96
|
pathToInternalUrl(path: string): string;
|
|
38
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Converts an absolute URL based at the PHPRequestHandler to a relative path
|
|
99
|
+
* without the server pathname and scope.
|
|
100
|
+
*
|
|
101
|
+
* @param internalUrl An absolute URL based at the PHPRequestHandler root.
|
|
102
|
+
* @returns The relative path.
|
|
103
|
+
*/
|
|
39
104
|
internalUrlToPath(internalUrl: string): string;
|
|
40
105
|
get isRequestRunning(): boolean;
|
|
41
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* The absolute URL of this PHPRequestHandler instance.
|
|
108
|
+
*/
|
|
42
109
|
get absoluteUrl(): string;
|
|
43
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* The directory in the PHP filesystem where the server will look
|
|
112
|
+
* for the files to serve. Default: `/var/www`.
|
|
113
|
+
*/
|
|
44
114
|
get documentRoot(): string;
|
|
45
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Serves the request – either by serving a static file, or by
|
|
117
|
+
* dispatching it to the PHP runtime.
|
|
118
|
+
*
|
|
119
|
+
* The request() method mode behaves like a web server and only works if
|
|
120
|
+
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
121
|
+
* of WordPress Playground does by default).
|
|
122
|
+
*
|
|
123
|
+
* In the request mode, you pass an object containing the request information
|
|
124
|
+
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* const php = PHP.load('7.4', {
|
|
128
|
+
* requestHandler: {
|
|
129
|
+
* documentRoot: "/www"
|
|
130
|
+
* }
|
|
131
|
+
* })
|
|
132
|
+
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
133
|
+
* const result = await php.request({
|
|
134
|
+
* method: "GET",
|
|
135
|
+
* headers: {
|
|
136
|
+
* "Content-Type": "text/plain"
|
|
137
|
+
* },
|
|
138
|
+
* body: "Hello world!",
|
|
139
|
+
* path: "/www/index.php"
|
|
140
|
+
* });
|
|
141
|
+
* // result.text === "Hello world!"
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```js
|
|
148
|
+
* const output = await php.request({
|
|
149
|
+
* method: 'GET',
|
|
150
|
+
* url: '/index.php',
|
|
151
|
+
* headers: {
|
|
152
|
+
* 'X-foo': 'bar',
|
|
153
|
+
* },
|
|
154
|
+
* body: {
|
|
155
|
+
* foo: 'bar',
|
|
156
|
+
* },
|
|
157
|
+
* });
|
|
158
|
+
* console.log(output.stdout); // "Hello world!"
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @param request - PHP Request data.
|
|
162
|
+
*/
|
|
46
163
|
request(request: PHPRequest): Promise<PHPResponse>;
|
|
47
164
|
}
|
|
48
165
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BasePHP } from './base-php';
|
|
2
2
|
export interface RotateOptions<T extends BasePHP> {
|
|
3
3
|
php: T;
|
|
4
|
+
cwd: string;
|
|
4
5
|
recreateRuntime: () => Promise<number> | number;
|
|
5
6
|
maxRequests: number;
|
|
6
7
|
}
|
|
@@ -20,4 +21,4 @@ export interface RotateOptions<T extends BasePHP> {
|
|
|
20
21
|
*
|
|
21
22
|
* @return cleanup function to restore
|
|
22
23
|
*/
|
|
23
|
-
export declare function rotatePHPRuntime<T extends BasePHP>({ php, recreateRuntime, maxRequests, }: RotateOptions<T>): () => void;
|
|
24
|
+
export declare function rotatePHPRuntime<T extends BasePHP>({ php, cwd, recreateRuntime, maxRequests, }: RotateOptions<T>): () => void;
|
package/lib/universal-php.d.ts
CHANGED
|
@@ -36,137 +36,17 @@ export type PHPEvent = PHPRequestEndEvent | PHPRequestErrorEvent | PHPRuntimeIni
|
|
|
36
36
|
* A callback function that handles PHP events.
|
|
37
37
|
*/
|
|
38
38
|
export type PHPEventListener = (event: PHPEvent) => void;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @example Use PHPRequestHandler implicitly with a new PHP instance:
|
|
44
|
-
* ```js
|
|
45
|
-
* import { PHP } from '../../../web/src/index.ts';
|
|
46
|
-
*
|
|
47
|
-
* const php = await PHP.load( '7.4', {
|
|
48
|
-
* requestHandler: {
|
|
49
|
-
* // PHP FS path to serve the files from:
|
|
50
|
-
* documentRoot: '/www',
|
|
51
|
-
*
|
|
52
|
-
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
53
|
-
* absoluteUrl: 'http://127.0.0.1'
|
|
54
|
-
* }
|
|
55
|
-
* } );
|
|
56
|
-
*
|
|
57
|
-
* php.mkdirTree('/www');
|
|
58
|
-
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
59
|
-
*
|
|
60
|
-
* const response = await php.request({ path: '/index.php' });
|
|
61
|
-
* console.log(response.text);
|
|
62
|
-
* // "Hi from PHP!"
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example Explicitly create a PHPRequestHandler instance and run a PHP script:
|
|
66
|
-
* ```js
|
|
67
|
-
* import {
|
|
68
|
-
* loadPHPRuntime,
|
|
69
|
-
* PHP,
|
|
70
|
-
* PHPRequestHandler,
|
|
71
|
-
* getPHPLoaderModule,
|
|
72
|
-
* } from '@php-wasm/web';
|
|
73
|
-
*
|
|
74
|
-
* const runtime = await loadPHPRuntime( await getPHPLoaderModule('7.4') );
|
|
75
|
-
* const php = new PHP( runtime );
|
|
76
|
-
*
|
|
77
|
-
* php.mkdirTree('/www');
|
|
78
|
-
* php.writeFile('/www/index.php', '<?php echo "Hi from PHP!"; ');
|
|
79
|
-
*
|
|
80
|
-
* const server = new PHPRequestHandler(php, {
|
|
81
|
-
* // PHP FS path to serve the files from:
|
|
82
|
-
* documentRoot: '/www',
|
|
83
|
-
*
|
|
84
|
-
* // Used to populate $_SERVER['SERVER_NAME'] etc.:
|
|
85
|
-
* absoluteUrl: 'http://127.0.0.1'
|
|
86
|
-
* });
|
|
87
|
-
*
|
|
88
|
-
* const response = server.request({ path: '/index.php' });
|
|
89
|
-
* console.log(response.text);
|
|
90
|
-
* // "Hi from PHP!"
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export interface RequestHandler {
|
|
94
|
-
/**
|
|
95
|
-
* Serves the request – either by serving a static file, or by
|
|
96
|
-
* dispatching it to the PHP runtime.
|
|
97
|
-
*
|
|
98
|
-
* The request() method mode behaves like a web server and only works if
|
|
99
|
-
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
100
|
-
* of WordPress Playground does by default).
|
|
101
|
-
*
|
|
102
|
-
* In the request mode, you pass an object containing the request information
|
|
103
|
-
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
104
|
-
*
|
|
105
|
-
* ```ts
|
|
106
|
-
* const php = PHP.load('7.4', {
|
|
107
|
-
* requestHandler: {
|
|
108
|
-
* documentRoot: "/www"
|
|
109
|
-
* }
|
|
110
|
-
* })
|
|
111
|
-
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
112
|
-
* const result = await php.request({
|
|
113
|
-
* method: "GET",
|
|
114
|
-
* headers: {
|
|
115
|
-
* "Content-Type": "text/plain"
|
|
116
|
-
* },
|
|
117
|
-
* body: "Hello world!",
|
|
118
|
-
* path: "/www/index.php"
|
|
119
|
-
* });
|
|
120
|
-
* // result.text === "Hello world!"
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```js
|
|
127
|
-
* const output = await php.request({
|
|
128
|
-
* method: 'GET',
|
|
129
|
-
* url: '/index.php',
|
|
130
|
-
* headers: {
|
|
131
|
-
* 'X-foo': 'bar',
|
|
132
|
-
* },
|
|
133
|
-
* body: {
|
|
134
|
-
* foo: 'bar',
|
|
135
|
-
* },
|
|
136
|
-
* });
|
|
137
|
-
* console.log(output.stdout); // "Hello world!"
|
|
138
|
-
* ```
|
|
139
|
-
*
|
|
140
|
-
* @param request - PHP Request data.
|
|
141
|
-
*/
|
|
142
|
-
request(request: PHPRequest, maxRedirects?: number): Promise<PHPResponse>;
|
|
143
|
-
/**
|
|
144
|
-
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
145
|
-
* root.
|
|
146
|
-
*
|
|
147
|
-
* @param path The server path to convert to an absolute URL.
|
|
148
|
-
* @returns The absolute URL.
|
|
149
|
-
*/
|
|
39
|
+
export interface IsomorphicLocalPHP {
|
|
40
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
41
|
+
request(request: PHPRequest): Promise<PHPResponse>;
|
|
42
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
150
43
|
pathToInternalUrl(path: string): string;
|
|
151
|
-
/**
|
|
152
|
-
* Converts an absolute URL based at the PHPRequestHandler to a relative path
|
|
153
|
-
* without the server pathname and scope.
|
|
154
|
-
*
|
|
155
|
-
* @param internalUrl An absolute URL based at the PHPRequestHandler root.
|
|
156
|
-
* @returns The relative path.
|
|
157
|
-
*/
|
|
44
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
158
45
|
internalUrlToPath(internalUrl: string): string;
|
|
159
|
-
/**
|
|
160
|
-
* The absolute URL of this PHPRequestHandler instance.
|
|
161
|
-
*/
|
|
46
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
162
47
|
absoluteUrl: string;
|
|
163
|
-
/**
|
|
164
|
-
* The directory in the PHP filesystem where the server will look
|
|
165
|
-
* for the files to serve. Default: `/var/www`.
|
|
166
|
-
*/
|
|
48
|
+
/** @deprecated Use PHPRequestHandler instead. */
|
|
167
49
|
documentRoot: string;
|
|
168
|
-
}
|
|
169
|
-
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
170
50
|
/**
|
|
171
51
|
* Sets the SAPI name exposed by the PHP module.
|
|
172
52
|
* @param newName - The new SAPI name.
|
|
@@ -402,14 +282,6 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
402
282
|
* @param listener Callback function to handle the message.
|
|
403
283
|
*/
|
|
404
284
|
onMessage(listener: MessageListener): void;
|
|
405
|
-
/**
|
|
406
|
-
* Registers a handler to spawns a child process when
|
|
407
|
-
* `proc_open()`, `popen()`, `exec()`, `system()`, or `passthru()`
|
|
408
|
-
* is called.
|
|
409
|
-
*
|
|
410
|
-
* @param handler Callback function to spawn a process.
|
|
411
|
-
*/
|
|
412
|
-
setSpawnHandler(handler: SpawnHandler | string): void;
|
|
413
285
|
}
|
|
414
286
|
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
415
287
|
interface EventEmitter {
|
|
@@ -474,6 +346,10 @@ export interface PHPRunOptions {
|
|
|
474
346
|
* Environment variables to set for this run.
|
|
475
347
|
*/
|
|
476
348
|
env?: Record<string, string>;
|
|
349
|
+
/**
|
|
350
|
+
* $_SERVER entries to set for this run.
|
|
351
|
+
*/
|
|
352
|
+
$_SERVER?: Record<string, string>;
|
|
477
353
|
/**
|
|
478
354
|
* The code snippet to eval instead of a php file.
|
|
479
355
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/universal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "PHP.wasm – emscripten bindings for PHP",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"main": "./index.cjs",
|
|
37
37
|
"module": "./index.js",
|
|
38
38
|
"license": "GPL-2.0-or-later",
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ed0ec39040ab4cd69dc48a8eac157436b30f9d55",
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=18.18.0",
|
|
42
42
|
"npm": ">=8.11.0"
|
package/lib/php-browser.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { PHPRequestHandler } from './php-request-handler';
|
|
2
|
-
import type { PHPResponse } from './php-response';
|
|
3
|
-
import { PHPRequest, RequestHandler } from './universal-php';
|
|
4
|
-
export interface PHPBrowserConfiguration {
|
|
5
|
-
/**
|
|
6
|
-
* Should handle redirects internally?
|
|
7
|
-
*/
|
|
8
|
-
handleRedirects?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* The maximum number of redirects to follow internally. Once
|
|
11
|
-
* exceeded, request() will return the redirecting response.
|
|
12
|
-
*/
|
|
13
|
-
maxRedirects?: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A fake web browser that handles PHPRequestHandler's cookies and redirects
|
|
17
|
-
* internally without exposing them to the consumer.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export declare class PHPBrowser implements RequestHandler {
|
|
22
|
-
#private;
|
|
23
|
-
requestHandler: PHPRequestHandler;
|
|
24
|
-
/**
|
|
25
|
-
* @param server - The PHP server to browse.
|
|
26
|
-
* @param config - The browser configuration.
|
|
27
|
-
*/
|
|
28
|
-
constructor(requestHandler: PHPRequestHandler, config?: PHPBrowserConfiguration);
|
|
29
|
-
/**
|
|
30
|
-
* Sends the request to the server.
|
|
31
|
-
*
|
|
32
|
-
* When cookies are present in the response, this method stores
|
|
33
|
-
* them and sends them with any subsequent requests.
|
|
34
|
-
*
|
|
35
|
-
* When a redirection is present in the response, this method
|
|
36
|
-
* follows it by discarding a response and sending a subsequent
|
|
37
|
-
* request.
|
|
38
|
-
*
|
|
39
|
-
* @param request - The request.
|
|
40
|
-
* @param redirects - Internal. The number of redirects handled so far.
|
|
41
|
-
* @returns PHPRequestHandler response.
|
|
42
|
-
*/
|
|
43
|
-
request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
|
|
44
|
-
/** @inheritDoc */
|
|
45
|
-
pathToInternalUrl(path: string): string;
|
|
46
|
-
/** @inheritDoc */
|
|
47
|
-
internalUrlToPath(internalUrl: string): string;
|
|
48
|
-
/** @inheritDoc */
|
|
49
|
-
get absoluteUrl(): string;
|
|
50
|
-
/** @inheritDoc */
|
|
51
|
-
get documentRoot(): string;
|
|
52
|
-
setCookies(cookies: string[]): void;
|
|
53
|
-
serializeCookies(): string;
|
|
54
|
-
}
|