@php-wasm/node 0.6.0 → 0.6.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.
Files changed (3) hide show
  1. package/index.cjs +17 -0
  2. package/index.d.ts +1 -1
  3. package/package.json +5 -5
package/index.cjs CHANGED
@@ -69264,6 +69264,13 @@ if (typeof CustomEvent === "undefined") {
69264
69264
  globalThis.CustomEvent = CustomEvent2;
69265
69265
  }
69266
69266
 
69267
+ // packages/php-wasm/node-polyfills/src/lib/crypto.ts
69268
+ if (typeof crypto === "undefined") {
69269
+ Promise.resolve().then(() => __toESM(require("crypto"), 1)).then((module2) => {
69270
+ global.crypto = module2;
69271
+ });
69272
+ }
69273
+
69267
69274
  // packages/php-wasm/universal/src/lib/error-event-polyfill.ts
69268
69275
  var kError = Symbol("error");
69269
69276
  var kMessage = Symbol("message");
@@ -69937,6 +69944,16 @@ var PHPRequestHandler = class {
69937
69944
  * @returns The response.
69938
69945
  */
69939
69946
  async #dispatchToPHP(request, requestedUrl) {
69947
+ if (this.#semaphore.running > 0 && request.headers?.["x-request-issuer"] === "php") {
69948
+ console.warn(
69949
+ `Possible deadlock: Called request() before the previous request() have finished. PHP likely issued an HTTP call to itself. Normally this would lead to infinite waiting as Request 1 holds the lock that the Request 2 is waiting to acquire. That's not useful, so PHPRequestHandler will return error 502 instead.`
69950
+ );
69951
+ return new PHPResponse(
69952
+ 502,
69953
+ {},
69954
+ new TextEncoder().encode("502 Bad Gateway")
69955
+ );
69956
+ }
69940
69957
  const release = await this.#semaphore.acquire();
69941
69958
  try {
69942
69959
  this.php.addServerGlobalEntry("REMOTE_ADDR", "127.0.0.1");
package/index.d.ts CHANGED
@@ -216,7 +216,7 @@ export interface IsomorphicLocalPHP extends RequestHandler {
216
216
  * @param key - The name of the constant.
217
217
  * @param value - The value of the constant.
218
218
  */
219
- defineConstant(key: string, value: string | number | null): void;
219
+ defineConstant(key: string, value: boolean | string | number | null): void;
220
220
  /**
221
221
  * Adds an event listener for a PHP event.
222
222
  * @param eventType - The type of event to listen for.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
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": "3f137306ec8e3b10ec0674a1fe69ee43349edb4a",
31
+ "gitHead": "171b22b853786b8912d9624ea064eaa1e985e96b",
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.6.0",
42
- "@php-wasm/universal": "0.6.0",
43
- "@php-wasm/util": "0.6.0"
41
+ "@php-wasm/node-polyfills": "0.6.1",
42
+ "@php-wasm/universal": "0.6.1",
43
+ "@php-wasm/util": "0.6.1"
44
44
  }
45
45
  }