@php-wasm/node 0.6.1 → 0.6.3

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/index.cjs CHANGED
@@ -9148,7 +9148,10 @@ function init(RuntimeName, PHPLoader) {
9148
9148
  return Asyncify.handleSleep(async (wakeUp) => {
9149
9149
  let cp;
9150
9150
  try {
9151
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
9151
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
9152
+ if (cp instanceof Promise) {
9153
+ cp = await cp;
9154
+ }
9152
9155
  } catch (e) {
9153
9156
  if (e.code === "SPAWN_UNSUPPORTED") {
9154
9157
  wakeUp(1);
@@ -9267,7 +9270,10 @@ function init(RuntimeName, PHPLoader) {
9267
9270
  return Asyncify.handleSleep(async (wakeUp) => {
9268
9271
  let cp;
9269
9272
  try {
9270
- cp = await PHPWASM.spawnProcess(cmdstr, []);
9273
+ cp = PHPWASM.spawnProcess(cmdstr, []);
9274
+ if (cp instanceof Promise) {
9275
+ cp = await cp;
9276
+ }
9271
9277
  } catch (e) {
9272
9278
  console.error(e);
9273
9279
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -10908,7 +10914,7 @@ var init_php_8_3 = __esm({
10908
10914
  "packages/php-wasm/node/public/php_8_3.js"() {
10909
10915
  "use strict";
10910
10916
  dependencyFilename = __dirname + "/8_3_0/php_8_3.wasm";
10911
- dependenciesTotalSize = 11370166;
10917
+ dependenciesTotalSize = 11370174;
10912
10918
  }
10913
10919
  });
10914
10920
 
@@ -16517,7 +16523,10 @@ function init2(RuntimeName, PHPLoader) {
16517
16523
  return Asyncify.handleSleep(async (wakeUp) => {
16518
16524
  let cp;
16519
16525
  try {
16520
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
16526
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
16527
+ if (cp instanceof Promise) {
16528
+ cp = await cp;
16529
+ }
16521
16530
  } catch (e) {
16522
16531
  if (e.code === "SPAWN_UNSUPPORTED") {
16523
16532
  wakeUp(1);
@@ -16636,7 +16645,10 @@ function init2(RuntimeName, PHPLoader) {
16636
16645
  return Asyncify.handleSleep(async (wakeUp) => {
16637
16646
  let cp;
16638
16647
  try {
16639
- cp = await PHPWASM.spawnProcess(cmdstr, []);
16648
+ cp = PHPWASM.spawnProcess(cmdstr, []);
16649
+ if (cp instanceof Promise) {
16650
+ cp = await cp;
16651
+ }
16640
16652
  } catch (e) {
16641
16653
  console.error(e);
16642
16654
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -18277,7 +18289,7 @@ var init_php_8_2 = __esm({
18277
18289
  "packages/php-wasm/node/public/php_8_2.js"() {
18278
18290
  "use strict";
18279
18291
  dependencyFilename2 = __dirname + "/8_2_10/php_8_2.wasm";
18280
- dependenciesTotalSize2 = 11251647;
18292
+ dependenciesTotalSize2 = 11251648;
18281
18293
  }
18282
18294
  });
18283
18295
 
@@ -23882,7 +23894,10 @@ function init3(RuntimeName, PHPLoader) {
23882
23894
  return Asyncify.handleSleep(async (wakeUp) => {
23883
23895
  let cp;
23884
23896
  try {
23885
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
23897
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
23898
+ if (cp instanceof Promise) {
23899
+ cp = await cp;
23900
+ }
23886
23901
  } catch (e) {
23887
23902
  if (e.code === "SPAWN_UNSUPPORTED") {
23888
23903
  wakeUp(1);
@@ -24001,7 +24016,10 @@ function init3(RuntimeName, PHPLoader) {
24001
24016
  return Asyncify.handleSleep(async (wakeUp) => {
24002
24017
  let cp;
24003
24018
  try {
24004
- cp = await PHPWASM.spawnProcess(cmdstr, []);
24019
+ cp = PHPWASM.spawnProcess(cmdstr, []);
24020
+ if (cp instanceof Promise) {
24021
+ cp = await cp;
24022
+ }
24005
24023
  } catch (e) {
24006
24024
  console.error(e);
24007
24025
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -25641,7 +25659,7 @@ var init_php_8_1 = __esm({
25641
25659
  "packages/php-wasm/node/public/php_8_1.js"() {
25642
25660
  "use strict";
25643
25661
  dependencyFilename3 = __dirname + "/8_1_23/php_8_1.wasm";
25644
- dependenciesTotalSize3 = 10994169;
25662
+ dependenciesTotalSize3 = 10994159;
25645
25663
  }
25646
25664
  });
25647
25665
 
@@ -31230,7 +31248,10 @@ function init4(RuntimeName, PHPLoader) {
31230
31248
  return Asyncify.handleSleep(async (wakeUp) => {
31231
31249
  let cp;
31232
31250
  try {
31233
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
31251
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
31252
+ if (cp instanceof Promise) {
31253
+ cp = await cp;
31254
+ }
31234
31255
  } catch (e) {
31235
31256
  if (e.code === "SPAWN_UNSUPPORTED") {
31236
31257
  wakeUp(1);
@@ -31349,7 +31370,10 @@ function init4(RuntimeName, PHPLoader) {
31349
31370
  return Asyncify.handleSleep(async (wakeUp) => {
31350
31371
  let cp;
31351
31372
  try {
31352
- cp = await PHPWASM.spawnProcess(cmdstr, []);
31373
+ cp = PHPWASM.spawnProcess(cmdstr, []);
31374
+ if (cp instanceof Promise) {
31375
+ cp = await cp;
31376
+ }
31353
31377
  } catch (e) {
31354
31378
  console.error(e);
31355
31379
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -32978,7 +33002,7 @@ var init_php_8_0 = __esm({
32978
33002
  "packages/php-wasm/node/public/php_8_0.js"() {
32979
33003
  "use strict";
32980
33004
  dependencyFilename4 = __dirname + "/8_0_30/php_8_0.wasm";
32981
- dependenciesTotalSize4 = 11122204;
33005
+ dependenciesTotalSize4 = 11122216;
32982
33006
  }
32983
33007
  });
32984
33008
 
@@ -38567,7 +38591,10 @@ function init5(RuntimeName, PHPLoader) {
38567
38591
  return Asyncify.handleSleep(async (wakeUp) => {
38568
38592
  let cp;
38569
38593
  try {
38570
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
38594
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
38595
+ if (cp instanceof Promise) {
38596
+ cp = await cp;
38597
+ }
38571
38598
  } catch (e) {
38572
38599
  if (e.code === "SPAWN_UNSUPPORTED") {
38573
38600
  wakeUp(1);
@@ -38686,7 +38713,10 @@ function init5(RuntimeName, PHPLoader) {
38686
38713
  return Asyncify.handleSleep(async (wakeUp) => {
38687
38714
  let cp;
38688
38715
  try {
38689
- cp = await PHPWASM.spawnProcess(cmdstr, []);
38716
+ cp = PHPWASM.spawnProcess(cmdstr, []);
38717
+ if (cp instanceof Promise) {
38718
+ cp = await cp;
38719
+ }
38690
38720
  } catch (e) {
38691
38721
  console.error(e);
38692
38722
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -40300,7 +40330,7 @@ var init_php_7_4 = __esm({
40300
40330
  "packages/php-wasm/node/public/php_7_4.js"() {
40301
40331
  "use strict";
40302
40332
  dependencyFilename5 = __dirname + "/7_4_33/php_7_4.wasm";
40303
- dependenciesTotalSize5 = 11983432;
40333
+ dependenciesTotalSize5 = 11983410;
40304
40334
  }
40305
40335
  });
40306
40336
 
@@ -45889,7 +45919,10 @@ function init6(RuntimeName, PHPLoader) {
45889
45919
  return Asyncify.handleSleep(async (wakeUp) => {
45890
45920
  let cp;
45891
45921
  try {
45892
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
45922
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
45923
+ if (cp instanceof Promise) {
45924
+ cp = await cp;
45925
+ }
45893
45926
  } catch (e) {
45894
45927
  if (e.code === "SPAWN_UNSUPPORTED") {
45895
45928
  wakeUp(1);
@@ -46008,7 +46041,10 @@ function init6(RuntimeName, PHPLoader) {
46008
46041
  return Asyncify.handleSleep(async (wakeUp) => {
46009
46042
  let cp;
46010
46043
  try {
46011
- cp = await PHPWASM.spawnProcess(cmdstr, []);
46044
+ cp = PHPWASM.spawnProcess(cmdstr, []);
46045
+ if (cp instanceof Promise) {
46046
+ cp = await cp;
46047
+ }
46012
46048
  } catch (e) {
46013
46049
  console.error(e);
46014
46050
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -47617,7 +47653,7 @@ var init_php_7_3 = __esm({
47617
47653
  "packages/php-wasm/node/public/php_7_3.js"() {
47618
47654
  "use strict";
47619
47655
  dependencyFilename6 = __dirname + "/7_3_33/php_7_3.wasm";
47620
- dependenciesTotalSize6 = 11900257;
47656
+ dependenciesTotalSize6 = 11900300;
47621
47657
  }
47622
47658
  });
47623
47659
 
@@ -53075,7 +53111,10 @@ function init7(RuntimeName, PHPLoader) {
53075
53111
  return Asyncify.handleSleep(async (wakeUp) => {
53076
53112
  let cp;
53077
53113
  try {
53078
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
53114
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
53115
+ if (cp instanceof Promise) {
53116
+ cp = await cp;
53117
+ }
53079
53118
  } catch (e) {
53080
53119
  if (e.code === "SPAWN_UNSUPPORTED") {
53081
53120
  wakeUp(1);
@@ -53194,7 +53233,10 @@ function init7(RuntimeName, PHPLoader) {
53194
53233
  return Asyncify.handleSleep(async (wakeUp) => {
53195
53234
  let cp;
53196
53235
  try {
53197
- cp = await PHPWASM.spawnProcess(cmdstr, []);
53236
+ cp = PHPWASM.spawnProcess(cmdstr, []);
53237
+ if (cp instanceof Promise) {
53238
+ cp = await cp;
53239
+ }
53198
53240
  } catch (e) {
53199
53241
  console.error(e);
53200
53242
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -54802,7 +54844,7 @@ var init_php_7_2 = __esm({
54802
54844
  "packages/php-wasm/node/public/php_7_2.js"() {
54803
54845
  "use strict";
54804
54846
  dependencyFilename7 = __dirname + "/7_2_34/php_7_2.wasm";
54805
- dependenciesTotalSize7 = 11976463;
54847
+ dependenciesTotalSize7 = 11976453;
54806
54848
  }
54807
54849
  });
54808
54850
 
@@ -60260,7 +60302,10 @@ function init8(RuntimeName, PHPLoader) {
60260
60302
  return Asyncify.handleSleep(async (wakeUp) => {
60261
60303
  let cp;
60262
60304
  try {
60263
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
60305
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
60306
+ if (cp instanceof Promise) {
60307
+ cp = await cp;
60308
+ }
60264
60309
  } catch (e) {
60265
60310
  if (e.code === "SPAWN_UNSUPPORTED") {
60266
60311
  wakeUp(1);
@@ -60379,7 +60424,10 @@ function init8(RuntimeName, PHPLoader) {
60379
60424
  return Asyncify.handleSleep(async (wakeUp) => {
60380
60425
  let cp;
60381
60426
  try {
60382
- cp = await PHPWASM.spawnProcess(cmdstr, []);
60427
+ cp = PHPWASM.spawnProcess(cmdstr, []);
60428
+ if (cp instanceof Promise) {
60429
+ cp = await cp;
60430
+ }
60383
60431
  } catch (e) {
60384
60432
  console.error(e);
60385
60433
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -61972,7 +62020,7 @@ var init_php_7_1 = __esm({
61972
62020
  "packages/php-wasm/node/public/php_7_1.js"() {
61973
62021
  "use strict";
61974
62022
  dependencyFilename8 = __dirname + "/7_1_30/php_7_1.wasm";
61975
- dependenciesTotalSize8 = 11592748;
62023
+ dependenciesTotalSize8 = 11592810;
61976
62024
  }
61977
62025
  });
61978
62026
 
@@ -67430,7 +67478,10 @@ function init9(RuntimeName, PHPLoader) {
67430
67478
  return Asyncify.handleSleep(async (wakeUp) => {
67431
67479
  let cp;
67432
67480
  try {
67433
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
67481
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
67482
+ if (cp instanceof Promise) {
67483
+ cp = await cp;
67484
+ }
67434
67485
  } catch (e) {
67435
67486
  if (e.code === "SPAWN_UNSUPPORTED") {
67436
67487
  wakeUp(1);
@@ -67549,7 +67600,10 @@ function init9(RuntimeName, PHPLoader) {
67549
67600
  return Asyncify.handleSleep(async (wakeUp) => {
67550
67601
  let cp;
67551
67602
  try {
67552
- cp = await PHPWASM.spawnProcess(cmdstr, []);
67603
+ cp = PHPWASM.spawnProcess(cmdstr, []);
67604
+ if (cp instanceof Promise) {
67605
+ cp = await cp;
67606
+ }
67553
67607
  } catch (e) {
67554
67608
  console.error(e);
67555
67609
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -69156,7 +69210,7 @@ var init_php_7_0 = __esm({
69156
69210
  "packages/php-wasm/node/public/php_7_0.js"() {
69157
69211
  "use strict";
69158
69212
  dependencyFilename9 = __dirname + "/7_0_33/php_7_0.wasm";
69159
- dependenciesTotalSize9 = 11391831;
69213
+ dependenciesTotalSize9 = 11391597;
69160
69214
  }
69161
69215
  });
69162
69216
 
@@ -69264,13 +69318,6 @@ if (typeof CustomEvent === "undefined") {
69264
69318
  globalThis.CustomEvent = CustomEvent2;
69265
69319
  }
69266
69320
 
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
-
69274
69321
  // packages/php-wasm/universal/src/lib/error-event-polyfill.ts
69275
69322
  var kError = Symbol("error");
69276
69323
  var kMessage = Symbol("message");
@@ -69825,6 +69872,59 @@ function ensurePathPrefix(path, prefix) {
69825
69872
  return prefix + path;
69826
69873
  }
69827
69874
 
69875
+ // packages/php-wasm/universal/src/lib/encode-as-multipart.ts
69876
+ async function encodeAsMultipart(data) {
69877
+ const boundary = `----${Math.random().toString(36).slice(2)}`;
69878
+ const contentType = `multipart/form-data; boundary=${boundary}`;
69879
+ const textEncoder = new TextEncoder();
69880
+ const parts = [];
69881
+ for (const [name, value] of Object.entries(data)) {
69882
+ parts.push(`--${boundary}\r
69883
+ `);
69884
+ parts.push(`Content-Disposition: form-data; name="${name}"`);
69885
+ if (value instanceof File) {
69886
+ parts.push(`; filename="${value.name}"`);
69887
+ }
69888
+ parts.push(`\r
69889
+ `);
69890
+ if (value instanceof File) {
69891
+ parts.push(`Content-Type: application/octet-stream`);
69892
+ }
69893
+ parts.push(`\r
69894
+ \r
69895
+ `);
69896
+ if (value instanceof File) {
69897
+ parts.push(await fileToUint8Array(value));
69898
+ } else {
69899
+ parts.push(value);
69900
+ }
69901
+ parts.push(`\r
69902
+ `);
69903
+ }
69904
+ parts.push(`--${boundary}--\r
69905
+ `);
69906
+ const length = parts.reduce((acc, part) => acc + part.length, 0);
69907
+ const bytes = new Uint8Array(length);
69908
+ let offset = 0;
69909
+ for (const part of parts) {
69910
+ bytes.set(
69911
+ typeof part === "string" ? textEncoder.encode(part) : part,
69912
+ offset
69913
+ );
69914
+ offset += part.length;
69915
+ }
69916
+ return { bytes, contentType };
69917
+ }
69918
+ function fileToUint8Array(file) {
69919
+ return new Promise((resolve) => {
69920
+ const reader = new FileReader();
69921
+ reader.onload = () => {
69922
+ resolve(new Uint8Array(reader.result));
69923
+ };
69924
+ reader.readAsArrayBuffer(file);
69925
+ });
69926
+ }
69927
+
69828
69928
  // packages/php-wasm/universal/src/lib/php-request-handler.ts
69829
69929
  var PHPRequestHandler = class {
69830
69930
  #DOCROOT;
@@ -69967,35 +70067,12 @@ var PHPRequestHandler = class {
69967
70067
  host: this.#HOST,
69968
70068
  ...normalizeHeaders(request.headers || {})
69969
70069
  };
69970
- const fileInfos = [];
69971
- if (request.files && Object.keys(request.files).length) {
69972
- preferredMethod = "POST";
69973
- for (const key in request.files) {
69974
- const file = request.files[key];
69975
- fileInfos.push({
69976
- key,
69977
- name: file.name,
69978
- type: file.type,
69979
- data: new Uint8Array(await file.arrayBuffer())
69980
- });
69981
- }
69982
- if (headers["content-type"]?.startsWith("multipart/form-data")) {
69983
- request.formData = parseMultipartFormDataString(
69984
- request.body || ""
69985
- );
69986
- headers["content-type"] = "application/x-www-form-urlencoded";
69987
- delete request.body;
69988
- }
69989
- }
69990
- let body;
69991
- if (request.formData !== void 0) {
70070
+ let body = request.body;
70071
+ if (typeof body === "object" && !(body instanceof Uint8Array)) {
69992
70072
  preferredMethod = "POST";
69993
- headers["content-type"] = headers["content-type"] || "application/x-www-form-urlencoded";
69994
- body = new URLSearchParams(
69995
- request.formData
69996
- ).toString();
69997
- } else {
69998
- body = request.body;
70073
+ const { bytes, contentType } = await encodeAsMultipart(body);
70074
+ body = bytes;
70075
+ headers["content-type"] = contentType;
69999
70076
  }
70000
70077
  let scriptPath;
70001
70078
  try {
@@ -70024,7 +70101,6 @@ var PHPRequestHandler = class {
70024
70101
  protocol: this.#PROTOCOL,
70025
70102
  method: request.method || preferredMethod,
70026
70103
  body,
70027
- fileInfos,
70028
70104
  scriptPath,
70029
70105
  headers
70030
70106
  });
@@ -70060,28 +70136,6 @@ var PHPRequestHandler = class {
70060
70136
  throw new Error(`File not found: ${resolvedFsPath}`);
70061
70137
  }
70062
70138
  };
70063
- function parseMultipartFormDataString(multipartString) {
70064
- const parsedData = {};
70065
- const boundaryMatch = multipartString.match(/--(.*)\r\n/);
70066
- if (!boundaryMatch) {
70067
- return parsedData;
70068
- }
70069
- const boundary = boundaryMatch[1];
70070
- const parts = multipartString.split(`--${boundary}`);
70071
- parts.shift();
70072
- parts.pop();
70073
- parts.forEach((part) => {
70074
- const headerBodySplit = part.indexOf("\r\n\r\n");
70075
- const headers = part.substring(0, headerBodySplit).trim();
70076
- const body = part.substring(headerBodySplit + 4).trim();
70077
- const nameMatch = headers.match(/name="([^"]+)"/);
70078
- if (nameMatch) {
70079
- const name = nameMatch[1];
70080
- parsedData[name] = body;
70081
- }
70082
- });
70083
- return parsedData;
70084
- }
70085
70139
  function inferMimeType(path) {
70086
70140
  const extension = path.split(".").pop();
70087
70141
  switch (extension) {
@@ -70477,11 +70531,6 @@ var BasePHP2 = class {
70477
70531
  if (request.body) {
70478
70532
  heapBodyPointer = this.#setRequestBody(request.body);
70479
70533
  }
70480
- if (request.fileInfos) {
70481
- for (const file of request.fileInfos) {
70482
- this.#addUploadedFile(file);
70483
- }
70484
- }
70485
70534
  if (typeof request.code === "string") {
70486
70535
  this.#setPHPCode(" ?>" + request.code);
70487
70536
  }
@@ -70653,16 +70702,30 @@ var BasePHP2 = class {
70653
70702
  }
70654
70703
  }
70655
70704
  #setRequestBody(body) {
70656
- const size = this[__private__dont__use].lengthBytesUTF8(body);
70657
- const heapBodyPointer = this[__private__dont__use].malloc(size + 1);
70705
+ let size, contentLength;
70706
+ if (typeof body === "string") {
70707
+ console.warn(
70708
+ "Passing a string as the request body is deprecated. Please use a Uint8Array instead. See https://github.com/WordPress/wordpress-playground/issues/997 for more details"
70709
+ );
70710
+ contentLength = this[__private__dont__use].lengthBytesUTF8(body);
70711
+ size = contentLength + 1;
70712
+ } else {
70713
+ contentLength = body.byteLength;
70714
+ size = body.byteLength;
70715
+ }
70716
+ const heapBodyPointer = this[__private__dont__use].malloc(size);
70658
70717
  if (!heapBodyPointer) {
70659
70718
  throw new Error("Could not allocate memory for the request body.");
70660
70719
  }
70661
- this[__private__dont__use].stringToUTF8(
70662
- body,
70663
- heapBodyPointer,
70664
- size + 1
70665
- );
70720
+ if (typeof body === "string") {
70721
+ this[__private__dont__use].stringToUTF8(
70722
+ body,
70723
+ heapBodyPointer,
70724
+ size + 1
70725
+ );
70726
+ } else {
70727
+ this[__private__dont__use].HEAPU8.set(body, heapBodyPointer);
70728
+ }
70666
70729
  this[__private__dont__use].ccall(
70667
70730
  "wasm_set_request_body",
70668
70731
  null,
@@ -70673,7 +70736,7 @@ var BasePHP2 = class {
70673
70736
  "wasm_set_content_length",
70674
70737
  null,
70675
70738
  [NUMBER],
70676
- [new TextEncoder().encode(body).length]
70739
+ [contentLength]
70677
70740
  );
70678
70741
  return heapBodyPointer;
70679
70742
  }
@@ -70714,27 +70777,6 @@ var BasePHP2 = class {
70714
70777
  })
70715
70778
  );
70716
70779
  }
70717
- /**
70718
- * Adds file information to $_FILES superglobal in PHP.
70719
- *
70720
- * In particular:
70721
- * * Creates the file data in the filesystem
70722
- * * Registers the file details in PHP
70723
- *
70724
- * @param fileInfo - File details
70725
- */
70726
- #addUploadedFile(fileInfo) {
70727
- const { key, name, type, data } = fileInfo;
70728
- const tmpPath = `/tmp/${Math.random().toFixed(20)}`;
70729
- this.writeFile(tmpPath, data);
70730
- const error = 0;
70731
- this[__private__dont__use].ccall(
70732
- "wasm_add_uploaded_file",
70733
- null,
70734
- [STRING, STRING, STRING, STRING, NUMBER, NUMBER],
70735
- [key, name, type, tmpPath, error, data.byteLength]
70736
- );
70737
- }
70738
70780
  #setPHPCode(code) {
70739
70781
  this[__private__dont__use].ccall(
70740
70782
  "wasm_set_php_code",
package/index.d.ts CHANGED
@@ -169,7 +169,7 @@ export interface RequestHandler {
169
169
  * headers: {
170
170
  * 'X-foo': 'bar',
171
171
  * },
172
- * formData: {
172
+ * body: {
173
173
  * foo: 'bar',
174
174
  * },
175
175
  * });
@@ -476,18 +476,11 @@ export interface PHPRequest {
476
476
  */
477
477
  headers?: PHPRequestHeaders;
478
478
  /**
479
- * Uploaded files
479
+ * Request body.
480
+ * If an object is given, the request will be encoded as multipart
481
+ * and sent with a `multipart/form-data` header.
480
482
  */
481
- files?: Record<string, File>;
482
- /**
483
- * Request body without the files.
484
- */
485
- body?: string;
486
- /**
487
- * Form data. If set, the request body will be ignored and
488
- * the content-type header will be set to `application/x-www-form-urlencoded`.
489
- */
490
- formData?: Record<string, unknown>;
483
+ body?: string | Uint8Array | Record<string, string | Uint8Array | File>;
491
484
  }
492
485
  export interface PHPRunOptions {
493
486
  /**
@@ -511,13 +504,9 @@ export interface PHPRunOptions {
511
504
  */
512
505
  headers?: PHPRequestHeaders;
513
506
  /**
514
- * Request body without the files.
507
+ * Request body.
515
508
  */
516
- body?: string;
517
- /**
518
- * Uploaded files.
519
- */
520
- fileInfos?: FileInfo[];
509
+ body?: string | Uint8Array;
521
510
  /**
522
511
  * The code snippet to eval instead of a php file.
523
512
  */
@@ -528,12 +517,6 @@ export interface PHPRunOptions {
528
517
  */
529
518
  throwOnError?: boolean;
530
519
  }
531
- export interface FileInfo {
532
- key: string;
533
- name: string;
534
- type: string;
535
- data: Uint8Array;
536
- }
537
520
  export interface RmDirOptions {
538
521
  /**
539
522
  * If true, recursively removes the directory and all its contents.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@php-wasm/node",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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": "171b22b853786b8912d9624ea064eaa1e985e96b",
31
+ "gitHead": "0a8916ec08aa5f02de5fea308b287171e7948e4b",
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.1",
42
- "@php-wasm/universal": "0.6.1",
43
- "@php-wasm/util": "0.6.1"
41
+ "@php-wasm/node-polyfills": "0.6.3",
42
+ "@php-wasm/universal": "0.6.3",
43
+ "@php-wasm/util": "0.6.3"
44
44
  }
45
45
  }
package/php_7_0.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/7_0_33/php_7_0.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11391831;
3
+ export const dependenciesTotalSize = 11391597;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5549,7 +5549,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5549
5549
  return Asyncify.handleSleep((async wakeUp => {
5550
5550
  let cp;
5551
5551
  try {
5552
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5552
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5553
+ if (cp instanceof Promise) {
5554
+ cp = await cp;
5555
+ }
5553
5556
  } catch (e) {
5554
5557
  if (e.code === "SPAWN_UNSUPPORTED") {
5555
5558
  wakeUp(1);
@@ -5661,7 +5664,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5661
5664
  return Asyncify.handleSleep((async wakeUp => {
5662
5665
  let cp;
5663
5666
  try {
5664
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5667
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5668
+ if (cp instanceof Promise) {
5669
+ cp = await cp;
5670
+ }
5665
5671
  } catch (e) {
5666
5672
  console.error(e);
5667
5673
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7387,6 +7393,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7387
7393
  }
7388
7394
  }
7389
7395
 
7396
+ /**
7397
+ * Other exports live in the Dockerfile in:
7398
+ *
7399
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7400
+ * * EXPORTED_FUNCTIONS
7401
+ *
7402
+ * These exports, however, live in here because:
7403
+ *
7404
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7405
+ * export them. This could be a bug in Emscripten or a consequence of
7406
+ * that option being deprecated.
7407
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7408
+ * on every `BasePHP.run()` call. This is a problem because we want to
7409
+ * spy on these calls in some unit tests.
7410
+ *
7411
+ * Therefore, we export them here.
7412
+ */
7390
7413
  PHPLoader['malloc'] = _malloc;
7391
7414
  PHPLoader['free'] = _free;
7392
7415
 
package/php_7_1.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/7_1_30/php_7_1.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11592748;
3
+ export const dependenciesTotalSize = 11592810;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5549,7 +5549,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5549
5549
  return Asyncify.handleSleep((async wakeUp => {
5550
5550
  let cp;
5551
5551
  try {
5552
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5552
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5553
+ if (cp instanceof Promise) {
5554
+ cp = await cp;
5555
+ }
5553
5556
  } catch (e) {
5554
5557
  if (e.code === "SPAWN_UNSUPPORTED") {
5555
5558
  wakeUp(1);
@@ -5661,7 +5664,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5661
5664
  return Asyncify.handleSleep((async wakeUp => {
5662
5665
  let cp;
5663
5666
  try {
5664
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5667
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5668
+ if (cp instanceof Promise) {
5669
+ cp = await cp;
5670
+ }
5665
5671
  } catch (e) {
5666
5672
  console.error(e);
5667
5673
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7372,6 +7378,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7372
7378
  }
7373
7379
  }
7374
7380
 
7381
+ /**
7382
+ * Other exports live in the Dockerfile in:
7383
+ *
7384
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7385
+ * * EXPORTED_FUNCTIONS
7386
+ *
7387
+ * These exports, however, live in here because:
7388
+ *
7389
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7390
+ * export them. This could be a bug in Emscripten or a consequence of
7391
+ * that option being deprecated.
7392
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7393
+ * on every `BasePHP.run()` call. This is a problem because we want to
7394
+ * spy on these calls in some unit tests.
7395
+ *
7396
+ * Therefore, we export them here.
7397
+ */
7375
7398
  PHPLoader['malloc'] = _malloc;
7376
7399
  PHPLoader['free'] = _free;
7377
7400
 
package/php_7_2.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/7_2_34/php_7_2.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11976463;
3
+ export const dependenciesTotalSize = 11976453;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5549,7 +5549,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5549
5549
  return Asyncify.handleSleep((async wakeUp => {
5550
5550
  let cp;
5551
5551
  try {
5552
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5552
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5553
+ if (cp instanceof Promise) {
5554
+ cp = await cp;
5555
+ }
5553
5556
  } catch (e) {
5554
5557
  if (e.code === "SPAWN_UNSUPPORTED") {
5555
5558
  wakeUp(1);
@@ -5661,7 +5664,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5661
5664
  return Asyncify.handleSleep((async wakeUp => {
5662
5665
  let cp;
5663
5666
  try {
5664
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5667
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5668
+ if (cp instanceof Promise) {
5669
+ cp = await cp;
5670
+ }
5665
5671
  } catch (e) {
5666
5672
  console.error(e);
5667
5673
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7388,6 +7394,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7388
7394
  }
7389
7395
  }
7390
7396
 
7397
+ /**
7398
+ * Other exports live in the Dockerfile in:
7399
+ *
7400
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7401
+ * * EXPORTED_FUNCTIONS
7402
+ *
7403
+ * These exports, however, live in here because:
7404
+ *
7405
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7406
+ * export them. This could be a bug in Emscripten or a consequence of
7407
+ * that option being deprecated.
7408
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7409
+ * on every `BasePHP.run()` call. This is a problem because we want to
7410
+ * spy on these calls in some unit tests.
7411
+ *
7412
+ * Therefore, we export them here.
7413
+ */
7391
7414
  PHPLoader['malloc'] = _malloc;
7392
7415
  PHPLoader['free'] = _free;
7393
7416
 
package/php_7_3.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/7_3_33/php_7_3.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11900257;
3
+ export const dependenciesTotalSize = 11900300;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5681,7 +5681,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5681
5681
  return Asyncify.handleSleep((async wakeUp => {
5682
5682
  let cp;
5683
5683
  try {
5684
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5684
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5685
+ if (cp instanceof Promise) {
5686
+ cp = await cp;
5687
+ }
5685
5688
  } catch (e) {
5686
5689
  if (e.code === "SPAWN_UNSUPPORTED") {
5687
5690
  wakeUp(1);
@@ -5793,7 +5796,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5793
5796
  return Asyncify.handleSleep((async wakeUp => {
5794
5797
  let cp;
5795
5798
  try {
5796
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5799
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5800
+ if (cp instanceof Promise) {
5801
+ cp = await cp;
5802
+ }
5797
5803
  } catch (e) {
5798
5804
  console.error(e);
5799
5805
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7521,6 +7527,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7521
7527
  }
7522
7528
  }
7523
7529
 
7530
+ /**
7531
+ * Other exports live in the Dockerfile in:
7532
+ *
7533
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7534
+ * * EXPORTED_FUNCTIONS
7535
+ *
7536
+ * These exports, however, live in here because:
7537
+ *
7538
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7539
+ * export them. This could be a bug in Emscripten or a consequence of
7540
+ * that option being deprecated.
7541
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7542
+ * on every `BasePHP.run()` call. This is a problem because we want to
7543
+ * spy on these calls in some unit tests.
7544
+ *
7545
+ * Therefore, we export them here.
7546
+ */
7524
7547
  PHPLoader['malloc'] = _malloc;
7525
7548
  PHPLoader['free'] = _free;
7526
7549
 
package/php_7_4.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/7_4_33/php_7_4.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11983432;
3
+ export const dependenciesTotalSize = 11983410;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5680,7 +5680,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5680
5680
  return Asyncify.handleSleep((async wakeUp => {
5681
5681
  let cp;
5682
5682
  try {
5683
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5683
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5684
+ if (cp instanceof Promise) {
5685
+ cp = await cp;
5686
+ }
5684
5687
  } catch (e) {
5685
5688
  if (e.code === "SPAWN_UNSUPPORTED") {
5686
5689
  wakeUp(1);
@@ -5792,7 +5795,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5792
5795
  return Asyncify.handleSleep((async wakeUp => {
5793
5796
  let cp;
5794
5797
  try {
5795
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5798
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5799
+ if (cp instanceof Promise) {
5800
+ cp = await cp;
5801
+ }
5796
5802
  } catch (e) {
5797
5803
  console.error(e);
5798
5804
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7526,6 +7532,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7526
7532
  }
7527
7533
  }
7528
7534
 
7535
+ /**
7536
+ * Other exports live in the Dockerfile in:
7537
+ *
7538
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7539
+ * * EXPORTED_FUNCTIONS
7540
+ *
7541
+ * These exports, however, live in here because:
7542
+ *
7543
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7544
+ * export them. This could be a bug in Emscripten or a consequence of
7545
+ * that option being deprecated.
7546
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7547
+ * on every `BasePHP.run()` call. This is a problem because we want to
7548
+ * spy on these calls in some unit tests.
7549
+ *
7550
+ * Therefore, we export them here.
7551
+ */
7529
7552
  PHPLoader['malloc'] = _malloc;
7530
7553
  PHPLoader['free'] = _free;
7531
7554
 
package/php_8_0.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/8_0_30/php_8_0.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11122204;
3
+ export const dependenciesTotalSize = 11122216;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5680,7 +5680,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5680
5680
  return Asyncify.handleSleep((async wakeUp => {
5681
5681
  let cp;
5682
5682
  try {
5683
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5683
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5684
+ if (cp instanceof Promise) {
5685
+ cp = await cp;
5686
+ }
5684
5687
  } catch (e) {
5685
5688
  if (e.code === "SPAWN_UNSUPPORTED") {
5686
5689
  wakeUp(1);
@@ -5792,7 +5795,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5792
5795
  return Asyncify.handleSleep((async wakeUp => {
5793
5796
  let cp;
5794
5797
  try {
5795
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5798
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5799
+ if (cp instanceof Promise) {
5800
+ cp = await cp;
5801
+ }
5796
5802
  } catch (e) {
5797
5803
  console.error(e);
5798
5804
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7542,6 +7548,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7542
7548
  }
7543
7549
  }
7544
7550
 
7551
+ /**
7552
+ * Other exports live in the Dockerfile in:
7553
+ *
7554
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7555
+ * * EXPORTED_FUNCTIONS
7556
+ *
7557
+ * These exports, however, live in here because:
7558
+ *
7559
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7560
+ * export them. This could be a bug in Emscripten or a consequence of
7561
+ * that option being deprecated.
7562
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7563
+ * on every `BasePHP.run()` call. This is a problem because we want to
7564
+ * spy on these calls in some unit tests.
7565
+ *
7566
+ * Therefore, we export them here.
7567
+ */
7545
7568
  PHPLoader['malloc'] = _malloc;
7546
7569
  PHPLoader['free'] = _free;
7547
7570
 
package/php_8_1.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/8_1_23/php_8_1.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 10994169;
3
+ export const dependenciesTotalSize = 10994159;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5696,7 +5696,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5696
5696
  return Asyncify.handleSleep((async wakeUp => {
5697
5697
  let cp;
5698
5698
  try {
5699
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5699
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5700
+ if (cp instanceof Promise) {
5701
+ cp = await cp;
5702
+ }
5700
5703
  } catch (e) {
5701
5704
  if (e.code === "SPAWN_UNSUPPORTED") {
5702
5705
  wakeUp(1);
@@ -5808,7 +5811,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5808
5811
  return Asyncify.handleSleep((async wakeUp => {
5809
5812
  let cp;
5810
5813
  try {
5811
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5814
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5815
+ if (cp instanceof Promise) {
5816
+ cp = await cp;
5817
+ }
5812
5818
  } catch (e) {
5813
5819
  console.error(e);
5814
5820
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7571,6 +7577,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7571
7577
  }
7572
7578
  }
7573
7579
 
7580
+ /**
7581
+ * Other exports live in the Dockerfile in:
7582
+ *
7583
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7584
+ * * EXPORTED_FUNCTIONS
7585
+ *
7586
+ * These exports, however, live in here because:
7587
+ *
7588
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7589
+ * export them. This could be a bug in Emscripten or a consequence of
7590
+ * that option being deprecated.
7591
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7592
+ * on every `BasePHP.run()` call. This is a problem because we want to
7593
+ * spy on these calls in some unit tests.
7594
+ *
7595
+ * Therefore, we export them here.
7596
+ */
7574
7597
  PHPLoader['malloc'] = _malloc;
7575
7598
  PHPLoader['free'] = _free;
7576
7599
 
package/php_8_2.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/8_2_10/php_8_2.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11251647;
3
+ export const dependenciesTotalSize = 11251648;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5701,7 +5701,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5701
5701
  return Asyncify.handleSleep((async wakeUp => {
5702
5702
  let cp;
5703
5703
  try {
5704
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5704
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5705
+ if (cp instanceof Promise) {
5706
+ cp = await cp;
5707
+ }
5705
5708
  } catch (e) {
5706
5709
  if (e.code === "SPAWN_UNSUPPORTED") {
5707
5710
  wakeUp(1);
@@ -5813,7 +5816,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5813
5816
  return Asyncify.handleSleep((async wakeUp => {
5814
5817
  let cp;
5815
5818
  try {
5816
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5819
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5820
+ if (cp instanceof Promise) {
5821
+ cp = await cp;
5822
+ }
5817
5823
  } catch (e) {
5818
5824
  console.error(e);
5819
5825
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7577,6 +7583,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7577
7583
  }
7578
7584
  }
7579
7585
 
7586
+ /**
7587
+ * Other exports live in the Dockerfile in:
7588
+ *
7589
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7590
+ * * EXPORTED_FUNCTIONS
7591
+ *
7592
+ * These exports, however, live in here because:
7593
+ *
7594
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7595
+ * export them. This could be a bug in Emscripten or a consequence of
7596
+ * that option being deprecated.
7597
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7598
+ * on every `BasePHP.run()` call. This is a problem because we want to
7599
+ * spy on these calls in some unit tests.
7600
+ *
7601
+ * Therefore, we export them here.
7602
+ */
7580
7603
  PHPLoader['malloc'] = _malloc;
7581
7604
  PHPLoader['free'] = _free;
7582
7605
 
package/php_8_3.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const dependencyFilename = __dirname + '/8_3_0/php_8_3.wasm';
2
2
  export { dependencyFilename };
3
- export const dependenciesTotalSize = 11370166;
3
+ export const dependenciesTotalSize = 11370174;
4
4
  export function init(RuntimeName, PHPLoader) {
5
5
  /**
6
6
  * Overrides Emscripten's default ExitStatus object which gets
@@ -5701,7 +5701,10 @@ function _js_open_process(command, argsPtr, argsLength, descriptorsPtr, descript
5701
5701
  return Asyncify.handleSleep((async wakeUp => {
5702
5702
  let cp;
5703
5703
  try {
5704
- cp = await PHPWASM.spawnProcess(cmdstr, argsArray);
5704
+ cp = PHPWASM.spawnProcess(cmdstr, argsArray);
5705
+ if (cp instanceof Promise) {
5706
+ cp = await cp;
5707
+ }
5705
5708
  } catch (e) {
5706
5709
  if (e.code === "SPAWN_UNSUPPORTED") {
5707
5710
  wakeUp(1);
@@ -5813,7 +5816,10 @@ function _js_popen_to_file(command, mode, exitCodePtr) {
5813
5816
  return Asyncify.handleSleep((async wakeUp => {
5814
5817
  let cp;
5815
5818
  try {
5816
- cp = await PHPWASM.spawnProcess(cmdstr, []);
5819
+ cp = PHPWASM.spawnProcess(cmdstr, []);
5820
+ if (cp instanceof Promise) {
5821
+ cp = await cp;
5822
+ }
5817
5823
  } catch (e) {
5818
5824
  console.error(e);
5819
5825
  if (e.code === "SPAWN_UNSUPPORTED") {
@@ -7577,6 +7583,23 @@ PHPLoader['removeRunDependency'] = function (...args) {
7577
7583
  }
7578
7584
  }
7579
7585
 
7586
+ /**
7587
+ * Other exports live in the Dockerfile in:
7588
+ *
7589
+ * * EXTRA_EXPORTED_RUNTIME_METHODS
7590
+ * * EXPORTED_FUNCTIONS
7591
+ *
7592
+ * These exports, however, live in here because:
7593
+ *
7594
+ * * Listing them in EXTRA_EXPORTED_RUNTIME_METHODS doesn't actually
7595
+ * export them. This could be a bug in Emscripten or a consequence of
7596
+ * that option being deprecated.
7597
+ * * Listing them in EXPORTED_FUNCTIONS works, but they are overridden
7598
+ * on every `BasePHP.run()` call. This is a problem because we want to
7599
+ * spy on these calls in some unit tests.
7600
+ *
7601
+ * Therefore, we export them here.
7602
+ */
7580
7603
  PHPLoader['malloc'] = _malloc;
7581
7604
  PHPLoader['free'] = _free;
7582
7605