@php-wasm/node 0.9.33 → 0.9.35
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 +4 -1
- package/index.d.ts +2 -0
- package/index.js +4 -1
- package/lib/get-php-loader-module.d.ts +2 -0
- package/lib/index.d.ts +5 -0
- package/lib/load-runtime.d.ts +12 -0
- package/lib/networking/inbound-tcp-to-ws-proxy.d.ts +8 -0
- package/lib/networking/outbound-ws-to-tcp-proxy.d.ts +58 -0
- package/lib/networking/utils.d.ts +2 -0
- package/lib/networking/with-networking.d.ts +2 -0
- package/lib/node-fs-mount.d.ts +2 -0
- package/lib/use-host-filesystem.d.ts +9 -0
- package/noop.d.ts +4 -0
- package/package.json +8 -8
package/index.cjs
CHANGED
|
@@ -67167,9 +67167,12 @@ function listenTCPToWSProxy(options) {
|
|
|
67167
67167
|
// packages/php-wasm/node/src/lib/networking/with-networking.ts
|
|
67168
67168
|
async function withNetworking(phpModuleArgs = {}) {
|
|
67169
67169
|
const [inboundProxyWsServerPort, outboundProxyWsServerPort] = await findFreePorts(2);
|
|
67170
|
-
await initOutboundWebsocketProxyServer(
|
|
67170
|
+
const outboundNetworkProxyServer = await initOutboundWebsocketProxyServer(
|
|
67171
|
+
outboundProxyWsServerPort
|
|
67172
|
+
);
|
|
67171
67173
|
return {
|
|
67172
67174
|
...phpModuleArgs,
|
|
67175
|
+
outboundNetworkProxyServer,
|
|
67173
67176
|
websocket: {
|
|
67174
67177
|
...phpModuleArgs["websocket"] || {},
|
|
67175
67178
|
url: (_, host, port) => {
|
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -67148,9 +67148,12 @@ function listenTCPToWSProxy(options) {
|
|
|
67148
67148
|
// packages/php-wasm/node/src/lib/networking/with-networking.ts
|
|
67149
67149
|
async function withNetworking(phpModuleArgs = {}) {
|
|
67150
67150
|
const [inboundProxyWsServerPort, outboundProxyWsServerPort] = await findFreePorts(2);
|
|
67151
|
-
await initOutboundWebsocketProxyServer(
|
|
67151
|
+
const outboundNetworkProxyServer = await initOutboundWebsocketProxyServer(
|
|
67152
|
+
outboundProxyWsServerPort
|
|
67153
|
+
);
|
|
67152
67154
|
return {
|
|
67153
67155
|
...phpModuleArgs,
|
|
67156
|
+
outboundNetworkProxyServer,
|
|
67154
67157
|
websocket: {
|
|
67155
67158
|
...phpModuleArgs["websocket"] || {},
|
|
67156
67159
|
url: (_, host, port) => {
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SupportedPHPVersion, EmscriptenOptions } from '@php-wasm/universal';
|
|
2
|
+
export interface PHPLoaderOptions {
|
|
3
|
+
emscriptenOptions?: EmscriptenOptions;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Does what load() does, but synchronously returns
|
|
7
|
+
* an object with the PHP instance and a promise that
|
|
8
|
+
* resolves when the PHP instance is ready.
|
|
9
|
+
*
|
|
10
|
+
* @see load
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadNodeRuntime(phpVersion: SupportedPHPVersion, options?: PHPLoaderOptions): Promise<number>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebSocketServer } from 'ws';
|
|
2
|
+
export declare function addTCPServerToWebSocketServerClass(wsListenPort: number, WSServer: typeof WebSocketServer): any;
|
|
3
|
+
export interface InboundTcpToWsProxyOptions {
|
|
4
|
+
tcpListenPort: number;
|
|
5
|
+
wsConnectHost?: string;
|
|
6
|
+
wsConnectPort: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function listenTCPToWSProxy(options: InboundTcpToWsProxyOptions): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
/**
|
|
3
|
+
* Send a chunk of data to the remote server.
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMMAND_CHUNK = 1;
|
|
6
|
+
/**
|
|
7
|
+
* Set a TCP socket option.
|
|
8
|
+
*/
|
|
9
|
+
export declare const COMMAND_SET_SOCKETOPT = 2;
|
|
10
|
+
/**
|
|
11
|
+
* Adds support for TCP socket options to WebSocket class.
|
|
12
|
+
*
|
|
13
|
+
* Socket options are implemented by adopting a specific data transmission
|
|
14
|
+
* protocol between WS client and WS server The first byte
|
|
15
|
+
* of every message is a command type, and the remaining bytes
|
|
16
|
+
* are the actual data.
|
|
17
|
+
*
|
|
18
|
+
* @param WebSocketConstructor
|
|
19
|
+
* @returns Decorated constructor
|
|
20
|
+
*/
|
|
21
|
+
export declare function addSocketOptionsSupportToWebSocketClass(WebSocketConstructor: typeof WebSocket): {
|
|
22
|
+
new (url: string | URL, protocols?: string | string[]): {
|
|
23
|
+
send(chunk: any, callback: any): any;
|
|
24
|
+
setSocketOpt(optionClass: number, optionName: number, optionValue: number): any;
|
|
25
|
+
sendCommand(commandType: number, chunk: string | ArrayBuffer | ArrayLike<number>, callback: any): any;
|
|
26
|
+
binaryType: BinaryType;
|
|
27
|
+
readonly bufferedAmount: number;
|
|
28
|
+
readonly extensions: string;
|
|
29
|
+
onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
|
|
30
|
+
onerror: ((this: WebSocket, ev: Event) => any) | null;
|
|
31
|
+
onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null;
|
|
32
|
+
onopen: ((this: WebSocket, ev: Event) => any) | null;
|
|
33
|
+
readonly protocol: string;
|
|
34
|
+
readonly readyState: number;
|
|
35
|
+
readonly url: string;
|
|
36
|
+
close(code?: number, reason?: string): void;
|
|
37
|
+
close(code?: number, reason?: string): void;
|
|
38
|
+
readonly CONNECTING: 0;
|
|
39
|
+
readonly OPEN: 1;
|
|
40
|
+
readonly CLOSING: 2;
|
|
41
|
+
readonly CLOSED: 3;
|
|
42
|
+
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
43
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
44
|
+
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
45
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
46
|
+
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
47
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
48
|
+
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
49
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
50
|
+
dispatchEvent(event: Event): boolean;
|
|
51
|
+
dispatchEvent(event: Event): boolean;
|
|
52
|
+
};
|
|
53
|
+
readonly CONNECTING: 0;
|
|
54
|
+
readonly OPEN: 1;
|
|
55
|
+
readonly CLOSING: 2;
|
|
56
|
+
readonly CLOSED: 3;
|
|
57
|
+
};
|
|
58
|
+
export declare function initOutboundWebsocketProxyServer(listenPort: number, listenHost?: string): Promise<http.Server>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PHP } from '@php-wasm/universal';
|
|
2
|
+
/**
|
|
3
|
+
* Enables host filesystem usage by mounting root
|
|
4
|
+
* directories (e.g. /, /home, /var) into the in-memory
|
|
5
|
+
* virtual filesystem used by this PHP instance, and
|
|
6
|
+
* setting the current working directory to one used by
|
|
7
|
+
* the current node.js process.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useHostFilesystem(php: PHP): void;
|
package/noop.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/node",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"description": "PHP.wasm for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "GPL-2.0-or-later",
|
|
40
40
|
"types": "index.d.ts",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "2975b41ced95054ab3332cad41f27af557309b08",
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18.18.0",
|
|
44
44
|
"npm": ">=8.11.0"
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"ini": "4.1.2",
|
|
50
50
|
"ws": "8.18.0",
|
|
51
51
|
"yargs": "17.7.2",
|
|
52
|
-
"@php-wasm/node-polyfills": "0.9.
|
|
53
|
-
"@php-wasm/universal": "0.9.
|
|
54
|
-
"@php-wasm/logger": "0.9.
|
|
55
|
-
"@php-wasm/util": "0.9.
|
|
56
|
-
"@wp-playground/common": "0.9.
|
|
57
|
-
"@wp-playground/wordpress": "0.9.
|
|
52
|
+
"@php-wasm/node-polyfills": "0.9.35",
|
|
53
|
+
"@php-wasm/universal": "0.9.35",
|
|
54
|
+
"@php-wasm/logger": "0.9.35",
|
|
55
|
+
"@php-wasm/util": "0.9.35",
|
|
56
|
+
"@wp-playground/common": "0.9.35",
|
|
57
|
+
"@wp-playground/wordpress": "0.9.35"
|
|
58
58
|
}
|
|
59
59
|
}
|