@php-wasm/node 0.1.60 → 0.1.61
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 +1268 -1190
- package/index.d.ts +45 -0
- package/package.json +4 -4
- package/php_5_6.wasm +0 -0
- package/php_7_0.wasm +0 -0
- package/php_7_1.wasm +0 -0
- package/php_7_2.wasm +0 -0
- package/php_7_3.wasm +0 -0
- package/php_7_4.wasm +0 -0
- package/php_8_0.wasm +0 -0
- package/php_8_1.wasm +0 -0
- package/php_8_2.wasm +0 -0
package/index.d.ts
CHANGED
|
@@ -350,7 +350,48 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
350
350
|
* @param options - PHP runtime options.
|
|
351
351
|
*/
|
|
352
352
|
run(options: PHPRunOptions): Promise<PHPResponse>;
|
|
353
|
+
/**
|
|
354
|
+
* Listens to message sent by the PHP code.
|
|
355
|
+
*
|
|
356
|
+
* To dispatch messages, call:
|
|
357
|
+
*
|
|
358
|
+
* post_message_to_js(string $data)
|
|
359
|
+
*
|
|
360
|
+
* Arguments:
|
|
361
|
+
* $data – any extra information as a string
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
*
|
|
365
|
+
* ```ts
|
|
366
|
+
* const php = await PHP.load('8.0');
|
|
367
|
+
*
|
|
368
|
+
* php.onMessage(
|
|
369
|
+
* // The data is always passed as a string
|
|
370
|
+
* function (data: string) {
|
|
371
|
+
* // Let's decode and log the data:
|
|
372
|
+
* console.log(JSON.parse(data));
|
|
373
|
+
* }
|
|
374
|
+
* );
|
|
375
|
+
*
|
|
376
|
+
* // Now that we have a listener in place, let's
|
|
377
|
+
* // dispatch a message:
|
|
378
|
+
* await php.run({
|
|
379
|
+
* code: `<?php
|
|
380
|
+
* post_message_to_js(
|
|
381
|
+
* json_encode([
|
|
382
|
+
* 'post_id' => '15',
|
|
383
|
+
* 'post_title' => 'This is a blog post!'
|
|
384
|
+
* ])
|
|
385
|
+
* ));
|
|
386
|
+
* `,
|
|
387
|
+
* });
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @param listener Callback function to handle the message.
|
|
391
|
+
*/
|
|
392
|
+
onMessage(listener: MessageListener): void;
|
|
353
393
|
}
|
|
394
|
+
export type MessageListener = (data: string) => void;
|
|
354
395
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
355
396
|
export type PHPRequestHeaders = Record<string, string>;
|
|
356
397
|
export interface PHPRequest {
|
|
@@ -550,7 +591,9 @@ export type EmscriptenOptions = {
|
|
|
550
591
|
quit?: (status: number, toThrow: any) => void;
|
|
551
592
|
onRuntimeInitialized?: () => void;
|
|
552
593
|
monitorRunDependencies?: (left: number) => void;
|
|
594
|
+
onMessage?: (listener: EmscriptenMessageListener) => void;
|
|
553
595
|
} & Record<string, any>;
|
|
596
|
+
export type EmscriptenMessageListener = (type: string, data: string) => void;
|
|
554
597
|
declare const __private__dont__use: unique symbol;
|
|
555
598
|
declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
556
599
|
#private;
|
|
@@ -565,6 +608,8 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
565
608
|
*/
|
|
566
609
|
constructor(PHPRuntimeId?: PHPRuntimeId, serverOptions?: PHPRequestHandlerConfiguration);
|
|
567
610
|
/** @inheritDoc */
|
|
611
|
+
onMessage(listener: MessageListener): Promise<void>;
|
|
612
|
+
/** @inheritDoc */
|
|
568
613
|
get absoluteUrl(): string;
|
|
569
614
|
/** @inheritDoc */
|
|
570
615
|
get documentRoot(): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
4
4
|
"description": "PHP.wasm for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"license": "GPL-2.0-or-later",
|
|
29
29
|
"main": "index.cjs",
|
|
30
30
|
"types": "index.d.ts",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f2cd7382004f7b003904b5db1d33d37fd2b1bfab",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"comlink": "^4.4.1",
|
|
34
34
|
"express": "4.18.2",
|
|
35
35
|
"ws": "8.13.0",
|
|
36
36
|
"yargs": "17.7.2",
|
|
37
|
-
"@php-wasm/universal": "0.1.
|
|
38
|
-
"@php-wasm/util": "0.1.
|
|
37
|
+
"@php-wasm/universal": "0.1.61",
|
|
38
|
+
"@php-wasm/util": "0.1.61"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/php_5_6.wasm
CHANGED
|
Binary file
|
package/php_7_0.wasm
CHANGED
|
Binary file
|
package/php_7_1.wasm
CHANGED
|
Binary file
|
package/php_7_2.wasm
CHANGED
|
Binary file
|
package/php_7_3.wasm
CHANGED
|
Binary file
|
package/php_7_4.wasm
CHANGED
|
Binary file
|
package/php_8_0.wasm
CHANGED
|
Binary file
|
package/php_8_1.wasm
CHANGED
|
Binary file
|
package/php_8_2.wasm
CHANGED
|
Binary file
|