@php-wasm/node 0.5.5 → 0.6.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.
- package/7_0_33/php_7_0.wasm +0 -0
- package/7_1_30/php_7_1.wasm +0 -0
- package/7_2_34/php_7_2.wasm +0 -0
- package/7_3_33/php_7_3.wasm +0 -0
- package/7_4_33/php_7_4.wasm +0 -0
- package/8_0_30/php_8_0.wasm +0 -0
- package/8_1_23/php_8_1.wasm +0 -0
- package/8_2_10/php_8_2.wasm +0 -0
- package/8_3_0/php_8_3.wasm +0 -0
- package/index.cjs +3312 -2314
- package/index.d.ts +56 -18
- package/package.json +5 -5
- package/php_7_0.js +335 -241
- package/php_7_1.js +334 -240
- package/php_7_2.js +335 -241
- package/php_7_3.js +336 -242
- package/php_7_4.js +336 -242
- package/php_8_0.js +338 -244
- package/php_8_1.js +340 -246
- package/php_8_2.js +341 -247
- package/php_8_3.js +341 -247
package/index.d.ts
CHANGED
|
@@ -48,17 +48,29 @@ declare class PHPResponse implements PHPResponseData {
|
|
|
48
48
|
get text(): string;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Represents an event related to the PHP
|
|
51
|
+
* Represents an event related to the PHP request.
|
|
52
52
|
*/
|
|
53
53
|
export interface PHPRequestEndEvent {
|
|
54
54
|
type: "request.end";
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Represents a PHP runtime initialization event.
|
|
58
|
+
*/
|
|
59
|
+
export interface PHPRuntimeInitializedEvent {
|
|
60
|
+
type: "runtime.initialized";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Represents a PHP runtime destruction event.
|
|
64
|
+
*/
|
|
65
|
+
export interface PHPRuntimeBeforeDestroyEvent {
|
|
66
|
+
type: "runtime.beforedestroy";
|
|
67
|
+
}
|
|
56
68
|
/**
|
|
57
69
|
* Represents an event related to the PHP instance.
|
|
58
70
|
* This is intentionally not an extension of CustomEvent
|
|
59
71
|
* to make it isomorphic between different JavaScript runtimes.
|
|
60
72
|
*/
|
|
61
|
-
export type PHPEvent = PHPRequestEndEvent;
|
|
73
|
+
export type PHPEvent = PHPRequestEndEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
|
|
62
74
|
/**
|
|
63
75
|
* A callback function that handles PHP events.
|
|
64
76
|
*/
|
|
@@ -194,6 +206,11 @@ export interface RequestHandler {
|
|
|
194
206
|
documentRoot: string;
|
|
195
207
|
}
|
|
196
208
|
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
209
|
+
/**
|
|
210
|
+
* Sets the SAPI name exposed by the PHP module.
|
|
211
|
+
* @param newName - The new SAPI name.
|
|
212
|
+
*/
|
|
213
|
+
setSapiName(newName: string): void;
|
|
197
214
|
/**
|
|
198
215
|
* Defines a constant in the PHP runtime.
|
|
199
216
|
* @param key - The name of the constant.
|
|
@@ -431,7 +448,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
431
448
|
*
|
|
432
449
|
* @param handler Callback function to spawn a process.
|
|
433
450
|
*/
|
|
434
|
-
setSpawnHandler(handler: SpawnHandler): void;
|
|
451
|
+
setSpawnHandler(handler: SpawnHandler | string): void;
|
|
435
452
|
}
|
|
436
453
|
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
437
454
|
export interface EventEmitter {
|
|
@@ -442,7 +459,7 @@ export type ChildProcess = EventEmitter & {
|
|
|
442
459
|
stdout: EventEmitter;
|
|
443
460
|
stderr: EventEmitter;
|
|
444
461
|
};
|
|
445
|
-
export type SpawnHandler = (command: string) => ChildProcess;
|
|
462
|
+
export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
446
463
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
447
464
|
export type PHPRequestHeaders = Record<string, string>;
|
|
448
465
|
export interface PHPRequest {
|
|
@@ -505,6 +522,11 @@ export interface PHPRunOptions {
|
|
|
505
522
|
* The code snippet to eval instead of a php file.
|
|
506
523
|
*/
|
|
507
524
|
code?: string;
|
|
525
|
+
/**
|
|
526
|
+
* Whether to throw an error if the PHP process exits with a non-zero code
|
|
527
|
+
* or outputs to stderr.
|
|
528
|
+
*/
|
|
529
|
+
throwOnError?: boolean;
|
|
508
530
|
}
|
|
509
531
|
export interface FileInfo {
|
|
510
532
|
key: string;
|
|
@@ -624,11 +646,6 @@ export type PHPLoaderModule = {
|
|
|
624
646
|
dependenciesTotalSize: number;
|
|
625
647
|
init: (jsRuntime: string, options: EmscriptenOptions) => PHPRuntime;
|
|
626
648
|
};
|
|
627
|
-
export type DataModule = {
|
|
628
|
-
dependencyFilename: string;
|
|
629
|
-
dependenciesTotalSize: number;
|
|
630
|
-
default: (phpRuntime: PHPRuntime) => void;
|
|
631
|
-
};
|
|
632
649
|
export type EmscriptenOptions = {
|
|
633
650
|
onAbort?: (message: string) => void;
|
|
634
651
|
/**
|
|
@@ -638,7 +655,6 @@ export type EmscriptenOptions = {
|
|
|
638
655
|
ENV?: Record<string, string>;
|
|
639
656
|
locateFile?: (path: string) => string;
|
|
640
657
|
noInitialRun?: boolean;
|
|
641
|
-
dataFileDownloads?: Record<string, number>;
|
|
642
658
|
print?: (message: string) => void;
|
|
643
659
|
printErr?: (message: string) => void;
|
|
644
660
|
quit?: (status: number, toThrow: any) => void;
|
|
@@ -647,11 +663,28 @@ export type EmscriptenOptions = {
|
|
|
647
663
|
onMessage?: (listener: EmscriptenMessageListener) => void;
|
|
648
664
|
} & Record<string, any>;
|
|
649
665
|
export type EmscriptenMessageListener = (type: string, data: string) => void;
|
|
666
|
+
export interface SemaphoreOptions {
|
|
667
|
+
concurrency: number;
|
|
668
|
+
}
|
|
669
|
+
declare class Semaphore {
|
|
670
|
+
private _running;
|
|
671
|
+
private concurrency;
|
|
672
|
+
private queue;
|
|
673
|
+
constructor({ concurrency }: SemaphoreOptions);
|
|
674
|
+
get running(): number;
|
|
675
|
+
acquire(): Promise<() => void>;
|
|
676
|
+
run<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
677
|
+
}
|
|
650
678
|
declare const __private__dont__use: unique symbol;
|
|
651
679
|
declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
652
680
|
#private;
|
|
653
681
|
protected [__private__dont__use]: any;
|
|
654
682
|
requestHandler?: PHPBrowser;
|
|
683
|
+
/**
|
|
684
|
+
* An exclusive lock that prevent multiple requests from running at
|
|
685
|
+
* the same time.
|
|
686
|
+
*/
|
|
687
|
+
semaphore: Semaphore;
|
|
655
688
|
/**
|
|
656
689
|
* Initializes a PHP runtime.
|
|
657
690
|
*
|
|
@@ -666,7 +699,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
666
699
|
/** @inheritDoc */
|
|
667
700
|
onMessage(listener: MessageListener): Promise<void>;
|
|
668
701
|
/** @inheritDoc */
|
|
669
|
-
setSpawnHandler(handler: SpawnHandler): Promise<void>;
|
|
702
|
+
setSpawnHandler(handler: SpawnHandler | string): Promise<void>;
|
|
670
703
|
/** @inheritDoc */
|
|
671
704
|
get absoluteUrl(): string;
|
|
672
705
|
/** @inheritDoc */
|
|
@@ -677,6 +710,8 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
677
710
|
internalUrlToPath(internalUrl: string): string;
|
|
678
711
|
initializeRuntime(runtimeId: PHPRuntimeId): void;
|
|
679
712
|
/** @inheritDoc */
|
|
713
|
+
setSapiName(newName: string): Promise<void>;
|
|
714
|
+
/** @inheritDoc */
|
|
680
715
|
setPhpIniPath(path: string): void;
|
|
681
716
|
/** @inheritDoc */
|
|
682
717
|
setPhpIniEntry(key: string, value: string): void;
|
|
@@ -687,7 +722,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
687
722
|
/** @inheritDoc */
|
|
688
723
|
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
689
724
|
addServerGlobalEntry(key: string, value: string): void;
|
|
690
|
-
defineConstant(key: string, value: string | number | null): void;
|
|
725
|
+
defineConstant(key: string, value: string | boolean | number | null): void;
|
|
691
726
|
/** @inheritDoc */
|
|
692
727
|
mkdir(path: string): void;
|
|
693
728
|
/** @inheritDoc */
|
|
@@ -710,14 +745,20 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
710
745
|
isDir(path: string): boolean;
|
|
711
746
|
/** @inheritDoc */
|
|
712
747
|
fileExists(path: string): boolean;
|
|
713
|
-
|
|
748
|
+
/**
|
|
749
|
+
* Hot-swaps the PHP runtime for a new one without
|
|
750
|
+
* interrupting the operations of this PHP instance.
|
|
751
|
+
*
|
|
752
|
+
* @param runtime
|
|
753
|
+
*/
|
|
754
|
+
hotSwapPHPRuntime(runtime: number): void;
|
|
755
|
+
exit(code?: number): void;
|
|
714
756
|
}
|
|
715
757
|
export declare function getPHPLoaderModule(version?: SupportedPHPVersion): Promise<PHPLoaderModule>;
|
|
716
758
|
export declare function withNetworking(phpModuleArgs?: EmscriptenOptions): Promise<EmscriptenOptions>;
|
|
717
759
|
export interface PHPLoaderOptions {
|
|
718
760
|
emscriptenOptions?: EmscriptenOptions;
|
|
719
761
|
requestHandler?: PHPRequestHandlerConfiguration;
|
|
720
|
-
dataModules?: Array<DataModule | Promise<DataModule>>;
|
|
721
762
|
}
|
|
722
763
|
export type MountSettings = {
|
|
723
764
|
root: string;
|
|
@@ -743,10 +784,7 @@ export declare class NodePHP extends BasePHP {
|
|
|
743
784
|
*
|
|
744
785
|
* @see load
|
|
745
786
|
*/
|
|
746
|
-
static
|
|
747
|
-
php: NodePHP;
|
|
748
|
-
phpReady: Promise<NodePHP>;
|
|
749
|
-
};
|
|
787
|
+
static loadRuntime(phpVersion: SupportedPHPVersion, options?: PHPLoaderOptions): Promise<number>;
|
|
750
788
|
/**
|
|
751
789
|
* Enables host filesystem usage by mounting root
|
|
752
790
|
* directories (e.g. /, /home, /var) into the in-memory
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "PHP.wasm for Node.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "GPL-2.0-or-later",
|
|
29
29
|
"main": "index.cjs",
|
|
30
30
|
"types": "index.d.ts",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "3f137306ec8e3b10ec0674a1fe69ee43349edb4a",
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=18.18.2",
|
|
34
34
|
"npm": ">=8.11.0"
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"express": "4.18.2",
|
|
39
39
|
"ws": "8.13.0",
|
|
40
40
|
"yargs": "17.7.2",
|
|
41
|
-
"@php-wasm/node-polyfills": "0.
|
|
42
|
-
"@php-wasm/universal": "0.
|
|
43
|
-
"@php-wasm/util": "0.
|
|
41
|
+
"@php-wasm/node-polyfills": "0.6.0",
|
|
42
|
+
"@php-wasm/universal": "0.6.0",
|
|
43
|
+
"@php-wasm/util": "0.6.0"
|
|
44
44
|
}
|
|
45
45
|
}
|