@php-wasm/web 0.5.6 → 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/index.d.ts +63 -30
- package/index.js +1033 -877
- package/kitchen-sink/7_0_33/php_7_0.wasm +0 -0
- package/kitchen-sink/7_1_30/php_7_1.wasm +0 -0
- package/kitchen-sink/7_2_34/php_7_2.wasm +0 -0
- package/kitchen-sink/7_3_33/php_7_3.wasm +0 -0
- package/kitchen-sink/7_4_33/php_7_4.wasm +0 -0
- package/kitchen-sink/8_0_30/php_8_0.wasm +0 -0
- package/kitchen-sink/8_1_23/php_8_1.wasm +0 -0
- package/kitchen-sink/8_2_10/php_8_2.wasm +0 -0
- package/kitchen-sink/8_3_0/php_8_3.wasm +0 -0
- package/kitchen-sink/php_7_0.js +6 -3
- package/kitchen-sink/php_7_1.js +6 -3
- package/kitchen-sink/php_7_2.js +6 -3
- package/kitchen-sink/php_7_3.js +6 -3
- package/kitchen-sink/php_7_4.js +6 -3
- package/kitchen-sink/php_8_0.js +6 -3
- package/kitchen-sink/php_8_1.js +6 -3
- package/kitchen-sink/php_8_2.js +6 -3
- package/kitchen-sink/php_8_3.js +6 -3
- package/light/7_0_33/php_7_0.wasm +0 -0
- package/light/7_1_30/php_7_1.wasm +0 -0
- package/light/7_2_34/php_7_2.wasm +0 -0
- package/light/7_3_33/php_7_3.wasm +0 -0
- package/light/7_4_33/php_7_4.wasm +0 -0
- package/light/8_0_30/php_8_0.wasm +0 -0
- package/light/8_1_23/php_8_1.wasm +0 -0
- package/light/8_2_10/php_8_2.wasm +0 -0
- package/light/8_3_0/php_8_3.wasm +0 -0
- package/light/php_7_0.js +6 -3
- package/light/php_7_1.js +6 -3
- package/light/php_7_2.js +6 -3
- package/light/php_7_3.js +6 -3
- package/light/php_7_4.js +6 -3
- package/light/php_8_0.js +6 -3
- package/light/php_8_1.js +6 -3
- package/light/php_8_2.js +6 -3
- package/light/php_8_3.js +6 -3
- package/package.json +5 -5
package/index.d.ts
CHANGED
|
@@ -71,17 +71,29 @@ declare class PHPResponse implements PHPResponseData {
|
|
|
71
71
|
get text(): string;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
* Represents an event related to the PHP
|
|
74
|
+
* Represents an event related to the PHP request.
|
|
75
75
|
*/
|
|
76
76
|
export interface PHPRequestEndEvent {
|
|
77
77
|
type: "request.end";
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Represents a PHP runtime initialization event.
|
|
81
|
+
*/
|
|
82
|
+
export interface PHPRuntimeInitializedEvent {
|
|
83
|
+
type: "runtime.initialized";
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Represents a PHP runtime destruction event.
|
|
87
|
+
*/
|
|
88
|
+
export interface PHPRuntimeBeforeDestroyEvent {
|
|
89
|
+
type: "runtime.beforedestroy";
|
|
90
|
+
}
|
|
79
91
|
/**
|
|
80
92
|
* Represents an event related to the PHP instance.
|
|
81
93
|
* This is intentionally not an extension of CustomEvent
|
|
82
94
|
* to make it isomorphic between different JavaScript runtimes.
|
|
83
95
|
*/
|
|
84
|
-
export type PHPEvent = PHPRequestEndEvent;
|
|
96
|
+
export type PHPEvent = PHPRequestEndEvent | PHPRuntimeInitializedEvent | PHPRuntimeBeforeDestroyEvent;
|
|
85
97
|
/**
|
|
86
98
|
* A callback function that handles PHP events.
|
|
87
99
|
*/
|
|
@@ -217,6 +229,11 @@ export interface RequestHandler {
|
|
|
217
229
|
documentRoot: string;
|
|
218
230
|
}
|
|
219
231
|
export interface IsomorphicLocalPHP extends RequestHandler {
|
|
232
|
+
/**
|
|
233
|
+
* Sets the SAPI name exposed by the PHP module.
|
|
234
|
+
* @param newName - The new SAPI name.
|
|
235
|
+
*/
|
|
236
|
+
setSapiName(newName: string): void;
|
|
220
237
|
/**
|
|
221
238
|
* Defines a constant in the PHP runtime.
|
|
222
239
|
* @param key - The name of the constant.
|
|
@@ -454,7 +471,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {
|
|
|
454
471
|
*
|
|
455
472
|
* @param handler Callback function to spawn a process.
|
|
456
473
|
*/
|
|
457
|
-
setSpawnHandler(handler: SpawnHandler): void;
|
|
474
|
+
setSpawnHandler(handler: SpawnHandler | string): void;
|
|
458
475
|
}
|
|
459
476
|
export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
|
|
460
477
|
export interface EventEmitter {
|
|
@@ -465,7 +482,7 @@ export type ChildProcess = EventEmitter & {
|
|
|
465
482
|
stdout: EventEmitter;
|
|
466
483
|
stderr: EventEmitter;
|
|
467
484
|
};
|
|
468
|
-
export type SpawnHandler = (command: string) => ChildProcess;
|
|
485
|
+
export type SpawnHandler = (command: string, args: string[]) => ChildProcess;
|
|
469
486
|
export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
|
|
470
487
|
export type PHPRequestHeaders = Record<string, string>;
|
|
471
488
|
export interface PHPRequest {
|
|
@@ -528,6 +545,11 @@ export interface PHPRunOptions {
|
|
|
528
545
|
* The code snippet to eval instead of a php file.
|
|
529
546
|
*/
|
|
530
547
|
code?: string;
|
|
548
|
+
/**
|
|
549
|
+
* Whether to throw an error if the PHP process exits with a non-zero code
|
|
550
|
+
* or outputs to stderr.
|
|
551
|
+
*/
|
|
552
|
+
throwOnError?: boolean;
|
|
531
553
|
}
|
|
532
554
|
export interface FileInfo {
|
|
533
555
|
key: string;
|
|
@@ -661,7 +683,6 @@ export type EmscriptenOptions = {
|
|
|
661
683
|
ENV?: Record<string, string>;
|
|
662
684
|
locateFile?: (path: string) => string;
|
|
663
685
|
noInitialRun?: boolean;
|
|
664
|
-
dataFileDownloads?: Record<string, number>;
|
|
665
686
|
print?: (message: string) => void;
|
|
666
687
|
printErr?: (message: string) => void;
|
|
667
688
|
quit?: (status: number, toThrow: any) => void;
|
|
@@ -670,11 +691,28 @@ export type EmscriptenOptions = {
|
|
|
670
691
|
onMessage?: (listener: EmscriptenMessageListener) => void;
|
|
671
692
|
} & Record<string, any>;
|
|
672
693
|
export type EmscriptenMessageListener = (type: string, data: string) => void;
|
|
694
|
+
export interface SemaphoreOptions {
|
|
695
|
+
concurrency: number;
|
|
696
|
+
}
|
|
697
|
+
declare class Semaphore {
|
|
698
|
+
private _running;
|
|
699
|
+
private concurrency;
|
|
700
|
+
private queue;
|
|
701
|
+
constructor({ concurrency }: SemaphoreOptions);
|
|
702
|
+
get running(): number;
|
|
703
|
+
acquire(): Promise<() => void>;
|
|
704
|
+
run<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
705
|
+
}
|
|
673
706
|
declare const __private__dont__use: unique symbol;
|
|
674
707
|
declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
675
708
|
#private;
|
|
676
709
|
protected [__private__dont__use]: any;
|
|
677
710
|
requestHandler?: PHPBrowser;
|
|
711
|
+
/**
|
|
712
|
+
* An exclusive lock that prevent multiple requests from running at
|
|
713
|
+
* the same time.
|
|
714
|
+
*/
|
|
715
|
+
semaphore: Semaphore;
|
|
678
716
|
/**
|
|
679
717
|
* Initializes a PHP runtime.
|
|
680
718
|
*
|
|
@@ -689,7 +727,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
689
727
|
/** @inheritDoc */
|
|
690
728
|
onMessage(listener: MessageListener): Promise<void>;
|
|
691
729
|
/** @inheritDoc */
|
|
692
|
-
setSpawnHandler(handler: SpawnHandler): Promise<void>;
|
|
730
|
+
setSpawnHandler(handler: SpawnHandler | string): Promise<void>;
|
|
693
731
|
/** @inheritDoc */
|
|
694
732
|
get absoluteUrl(): string;
|
|
695
733
|
/** @inheritDoc */
|
|
@@ -700,6 +738,8 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
700
738
|
internalUrlToPath(internalUrl: string): string;
|
|
701
739
|
initializeRuntime(runtimeId: PHPRuntimeId): void;
|
|
702
740
|
/** @inheritDoc */
|
|
741
|
+
setSapiName(newName: string): Promise<void>;
|
|
742
|
+
/** @inheritDoc */
|
|
703
743
|
setPhpIniPath(path: string): void;
|
|
704
744
|
/** @inheritDoc */
|
|
705
745
|
setPhpIniEntry(key: string, value: string): void;
|
|
@@ -710,7 +750,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
710
750
|
/** @inheritDoc */
|
|
711
751
|
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
712
752
|
addServerGlobalEntry(key: string, value: string): void;
|
|
713
|
-
defineConstant(key: string, value: string | number | null): void;
|
|
753
|
+
defineConstant(key: string, value: string | boolean | number | null): void;
|
|
714
754
|
/** @inheritDoc */
|
|
715
755
|
mkdir(path: string): void;
|
|
716
756
|
/** @inheritDoc */
|
|
@@ -733,19 +773,20 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
|
|
|
733
773
|
isDir(path: string): boolean;
|
|
734
774
|
/** @inheritDoc */
|
|
735
775
|
fileExists(path: string): boolean;
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
776
|
+
/**
|
|
777
|
+
* Hot-swaps the PHP runtime for a new one without
|
|
778
|
+
* interrupting the operations of this PHP instance.
|
|
779
|
+
*
|
|
780
|
+
* @param runtime
|
|
781
|
+
*/
|
|
782
|
+
hotSwapPHPRuntime(runtime: number): void;
|
|
783
|
+
exit(code?: number): void;
|
|
741
784
|
}
|
|
742
785
|
declare class EmscriptenDownloadMonitor extends EventTarget {
|
|
743
786
|
#private;
|
|
744
|
-
constructor(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
};
|
|
748
|
-
setModules(modules: MonitoredModule[]): void;
|
|
787
|
+
constructor();
|
|
788
|
+
expectAssets(assets: Record<string, number>): void;
|
|
789
|
+
monitorFetch(fetchPromise: Promise<Response>): Promise<Response>;
|
|
749
790
|
}
|
|
750
791
|
export interface PHPWebLoaderOptions {
|
|
751
792
|
emscriptenOptions?: EmscriptenOptions;
|
|
@@ -769,17 +810,7 @@ export declare class WebPHP extends BasePHP {
|
|
|
769
810
|
* @returns A new PHP instance
|
|
770
811
|
*/
|
|
771
812
|
static load(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<WebPHP>;
|
|
772
|
-
|
|
773
|
-
* Does what load() does, but synchronously returns
|
|
774
|
-
* an object with the PHP instance and a promise that
|
|
775
|
-
* resolves when the PHP instance is ready.
|
|
776
|
-
*
|
|
777
|
-
* @see load
|
|
778
|
-
*/
|
|
779
|
-
static loadSync(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): {
|
|
780
|
-
php: WebPHP;
|
|
781
|
-
phpReady: Promise<WebPHP>;
|
|
782
|
-
};
|
|
813
|
+
static loadRuntime(phpVersion: SupportedPHPVersion, options?: PHPWebLoaderOptions): Promise<number>;
|
|
783
814
|
}
|
|
784
815
|
/**
|
|
785
816
|
* A PHP client that can be used to run PHP code in the browser.
|
|
@@ -808,9 +839,11 @@ export declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
|
808
839
|
/** @inheritDoc @php-wasm/web!WebPHP.run */
|
|
809
840
|
run(request: PHPRunOptions): Promise<PHPResponse>;
|
|
810
841
|
/** @inheritDoc @php-wasm/web!WebPHP.setSpawnHandler */
|
|
811
|
-
setSpawnHandler(listener: SpawnHandler): void;
|
|
842
|
+
setSpawnHandler(listener: string | SpawnHandler): void;
|
|
812
843
|
/** @inheritDoc @php-wasm/web!WebPHP.chdir */
|
|
813
844
|
chdir(path: string): void;
|
|
845
|
+
/** @inheritDoc @php-wasm/web!WebPHP.setSapiName */
|
|
846
|
+
setSapiName(newName: string): void;
|
|
814
847
|
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniPath */
|
|
815
848
|
setPhpIniPath(path: string): void;
|
|
816
849
|
/** @inheritDoc @php-wasm/web!WebPHP.setPhpIniEntry */
|
|
@@ -836,7 +869,7 @@ export declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
|
836
869
|
/** @inheritDoc @php-wasm/web!WebPHP.onMessage */
|
|
837
870
|
onMessage(listener: MessageListener): void;
|
|
838
871
|
/** @inheritDoc @php-wasm/web!WebPHP.defineConstant */
|
|
839
|
-
defineConstant(key: string, value: string | number | null): void;
|
|
872
|
+
defineConstant(key: string, value: string | boolean | number | null): void;
|
|
840
873
|
/** @inheritDoc @php-wasm/web!WebPHP.addEventListener */
|
|
841
874
|
addEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
|
|
842
875
|
/** @inheritDoc @php-wasm/web!WebPHP.removeEventListener */
|