@wp-playground/wordpress 2.0.4 → 2.0.7

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@php-wasm/util"),p=require("@wp-playground/common"),c=require("@php-wasm/logger"),d=require("@php-wasm/universal"),S=`<?php
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@php-wasm/util"),p=require("@wp-playground/common"),c=require("@php-wasm/logger"),d=require("@php-wasm/universal"),T=`<?php
2
2
 
3
3
  /**
4
4
  * Rewrites the wp-config.php file to ensure specific constants are defined
@@ -344,7 +344,7 @@ function skip_whitespace($tokens) {
344
344
  return $output;
345
345
  }
346
346
  `;async function _(e,r,n,t="rewrite"){const i=o.phpVars({wpConfigPath:r,constants:n,whenAlreadyDefined:t});if((await e.run({code:`<?php ob_start(); ?>
347
- ${S}
347
+ ${T}
348
348
  $wp_config_path = ${i.wpConfigPath};
349
349
  $wp_config = file_get_contents($wp_config_path);
350
350
  $new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${i.constants}, ${i.whenAlreadyDefined});
@@ -352,7 +352,7 @@ function skip_whitespace($tokens) {
352
352
  ob_clean();
353
353
  echo false === $return_value ? '0' : '1';
354
354
  ob_end_flush();
355
- `})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function h(e,r){const n=o.joinPaths(r,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(r,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(r,"wp-config-sample.php"))),await _(e,n,t,"skip")}async function T(e){var t,i;const r=await g(e),n=await r.getPrimaryPhp();if((t=e.hooks)!=null&&t.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await k(n,await e.wordPressZip),e.constants)for(const s in e.constants)n.defineConstant(s,e.constants[s]);if(e.dataSqlPath&&(n.defineConstant("DB_DIR",o.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",o.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await h(n,r.documentRoot),(i=e.hooks)!=null&&i.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n),e.sqliteIntegrationPluginZip&&await y(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await f(n)||await R(n),!await f(n)))throw new Error("WordPress installation has failed.");return r}async function g(e){const r=e.spawnHandler??d.sandboxedSpawnHandlerFactory;async function n(i,s){const a=new d.PHP(await e.createPhpRuntime());return e.sapiName&&a.setSapiName(e.sapiName),i&&(a.requestHandler=i),e.phpIniEntries&&d.setPhpIniEntries(a,e.phpIniEntries),s?(await b(a),await d.writeFiles(a,"/",e.createFiles||{}),await P(a,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):d.proxyFileSystem(await i.getPrimaryPhp(),a,["/tmp",i.documentRoot,"/internal/shared"]),r&&await a.setSpawnHandler(r(i.processManager)),d.rotatePHPRuntime({php:a,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(a),a}const t=new d.PHPRequestHandler({phpFactory:async({isPrimary:i})=>n(t,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:m,getFileNotFoundAction:e.getFileNotFoundAction??$,cookieStore:e.cookieStore});return t}async function f(e){return(await e.run({code:`<?php
355
+ `})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function h(e,r){const n=o.joinPaths(r,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(r,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(r,"wp-config-sample.php"))),await _(e,n,t,"skip")}async function S(e){var t,i;const r=await g(e),n=await r.getPrimaryPhp();if((t=e.hooks)!=null&&t.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await k(n,await e.wordPressZip),e.constants)for(const s in e.constants)n.defineConstant(s,e.constants[s]);if(e.dataSqlPath&&(n.defineConstant("DB_DIR",o.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",o.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await h(n,r.documentRoot),(i=e.hooks)!=null&&i.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n),e.sqliteIntegrationPluginZip&&await y(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await f(n)||await R(n),!await f(n))){if(await v(n))throw new Error("WordPress installation has failed.");if(n.isFile("/internal/shared/preload/0-sqlite.php"))throw new Error("Error connecting to the SQLite database.");if(!e.sqliteIntegrationPluginZip){const a=o.joinPaths(r.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(n.isDir(a))throw new Error("Error connecting to the SQLite database.")}throw new Error("Error connecting to the MySQL database.")}return r}async function g(e){const r=e.spawnHandler??d.sandboxedSpawnHandlerFactory;async function n(i,s){const a=new d.PHP(await e.createPhpRuntime());return e.sapiName&&a.setSapiName(e.sapiName),i&&(a.requestHandler=i),e.phpIniEntries&&d.setPhpIniEntries(a,e.phpIniEntries),s?(await b(a),await d.writeFiles(a,"/",e.createFiles||{}),await P(a,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):d.proxyFileSystem(await i.getPrimaryPhp(),a,["/tmp",i.documentRoot,"/internal/shared"]),r&&await a.setSpawnHandler(r(i.processManager)),d.rotatePHPRuntime({php:a,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(a),a}const t=new d.PHPRequestHandler({phpFactory:async({isPrimary:i})=>n(t,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:m,getFileNotFoundAction:e.getFileNotFoundAction??$,cookieStore:e.cookieStore});return t}async function f(e){return(await e.run({code:`<?php
356
356
  ob_start();
357
357
  $wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
358
358
  if (!file_exists($wp_load)) {
@@ -378,7 +378,18 @@ function skip_whitespace($tokens) {
378
378
  ob_clean();
379
379
  echo $option_result ? '1' : '0';
380
380
  ob_end_flush();
381
- `,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&c.logger.warn("Failed to default to pretty permalinks after WP install.")}function $(e){return{type:"internal-redirect",uri:"/index.php"}}async function v(e){const{php:r,reap:n}=await e.processManager.acquirePHPInstance({considerPrimary:!0});try{const i=(await r.run({code:`<?php
381
+ `,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&c.logger.warn("Failed to default to pretty permalinks after WP install.")}function $(e){return{type:"internal-redirect",uri:"/index.php"}}async function v(e){return(await e.run({code:`<?php
382
+ ob_start();
383
+ $wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
384
+ if (!file_exists($wp_load)) {
385
+ echo '-1';
386
+ exit;
387
+ }
388
+ require $wp_load;
389
+ ob_clean();
390
+ echo $wpdb->check_connection( false) ? '1' : '0';
391
+ ob_end_flush();
392
+ `,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function L(e){const{php:r,reap:n}=await e.processManager.acquirePHPInstance({considerPrimary:!0});try{const i=(await r.run({code:`<?php
382
393
  require '${e.documentRoot}/wp-includes/version.php';
383
394
  echo $wp_version;
384
395
  `})).text;if(!i)throw new Error("Unable to read loaded WordPress version.");return w(i)}finally{n()}}function w(e){if(/-(alpha|beta|RC)\d*-\d+$/.test(e))return"nightly";if(/-(beta|RC)\d*$/.test(e))return"beta";const t=e.match(/^(\d+\.\d+)(?:\.\d+)?$/);return t!==null?t[1]:e}const m=[{match:/^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,replacement:"$2"}];async function b(e){await e.mkdir("/internal/shared/mu-plugins"),await e.writeFile("/internal/shared/preload/env.php",`<?php
@@ -701,5 +712,5 @@ if(!function_exists('mysqli_connect')) {
701
712
  var_dump(isset($wpdb));
702
713
  die("SQLite integration not loaded " . get_class($wpdb));
703
714
  }
704
- `)}async function k(e,r){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!e.fileExists(o.joinPaths(n,"wp-config-sample.php"))){const i=e.listFiles(n);if(i.length){const s=i[0];e.fileExists(o.joinPaths(n,s,"wp-config-sample.php"))&&(n=o.joinPaths(n,s))}}const t=(i,s,a)=>{if(a.isDir(i)&&a.isDir(s))for(const l of a.listFiles(i)){const u=o.joinPaths(i,l),E=o.joinPaths(s,l);t(u,E,a)}else{if(a.fileExists(s)){const l=i.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Skipping ${l} because something exists at the target path.`);return}a.mv(i,s)}};t(n,e.documentRoot,e),e.fileExists(n)&&e.rmdir(n,{recursive:!0}),!e.fileExists(o.joinPaths(e.documentRoot,"wp-config.php"))&&e.fileExists(o.joinPaths(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(o.joinPaths(e.documentRoot,"wp-config.php"),e.readFileAsText(o.joinPaths(e.documentRoot,"/wp-config-sample.php")))}const L=p.createMemoizedFetch(fetch);async function x(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const t=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),i=Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+i.substring(0,8),source:"inferred"}}else if(e==="trunk"||e==="nightly")return{releaseUrl:"https://wordpress.org/nightly-builds/wordpress-latest.zip",version:"nightly-"+new Date().toISOString().split("T")[0],source:"inferred"};let n=await(await L("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(t=>t.response==="autoupdate");for(const t of n){if(e==="beta"&&t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(e==="latest"&&!t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(t.version.substring(0,e.length)===e)return{releaseUrl:t.download,version:t.version,source:"api"}}return{releaseUrl:`https://wordpress.org/wordpress-${e}.zip`,version:e,source:"inferred"}}exports.bootRequestHandler=g;exports.bootWordPress=T;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=v;exports.preloadPhpInfoRoute=P;exports.preloadSqliteIntegration=y;exports.resolveWordPressRelease=x;exports.setupPlatformLevelMuPlugins=b;exports.unzipWordPress=k;exports.versionStringToLoadedWordPressVersion=w;exports.wordPressRewriteRules=m;
715
+ `)}async function k(e,r){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await p.unzipFile(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let n=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";if(!e.fileExists(o.joinPaths(n,"wp-config-sample.php"))){const i=e.listFiles(n);if(i.length){const s=i[0];e.fileExists(o.joinPaths(n,s,"wp-config-sample.php"))&&(n=o.joinPaths(n,s))}}const t=(i,s,a)=>{if(a.isDir(i)&&a.isDir(s))for(const l of a.listFiles(i)){const u=o.joinPaths(i,l),E=o.joinPaths(s,l);t(u,E,a)}else{if(a.fileExists(s)){const l=i.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Skipping ${l} because something exists at the target path.`);return}a.mv(i,s)}};t(n,e.documentRoot,e),e.fileExists(n)&&e.rmdir(n,{recursive:!0}),!e.fileExists(o.joinPaths(e.documentRoot,"wp-config.php"))&&e.fileExists(o.joinPaths(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(o.joinPaths(e.documentRoot,"wp-config.php"),e.readFileAsText(o.joinPaths(e.documentRoot,"/wp-config-sample.php")))}const x=p.createMemoizedFetch(fetch);async function I(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const t=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),i=Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+i.substring(0,8),source:"inferred"}}else if(e==="trunk"||e==="nightly")return{releaseUrl:"https://wordpress.org/nightly-builds/wordpress-latest.zip",version:"nightly-"+new Date().toISOString().split("T")[0],source:"inferred"};let n=await(await x("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(t=>t.response==="autoupdate");for(const t of n){if(e==="beta"&&t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(e==="latest"&&!t.version.includes("beta"))return{releaseUrl:t.download,version:t.version,source:"api"};if(t.version.substring(0,e.length)===e)return{releaseUrl:t.download,version:t.version,source:"api"}}return{releaseUrl:`https://wordpress.org/wordpress-${e}.zip`,version:e,source:"inferred"}}exports.bootRequestHandler=g;exports.bootWordPress=S;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=L;exports.preloadPhpInfoRoute=P;exports.preloadSqliteIntegration=y;exports.resolveWordPressRelease=I;exports.setupPlatformLevelMuPlugins=b;exports.unzipWordPress=k;exports.versionStringToLoadedWordPressVersion=w;exports.wordPressRewriteRules=m;
705
716
  //# sourceMappingURL=index.cjs.map
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { phpVars as h, joinPaths as s, dirname as g, basename as $, phpVar as l } from "@php-wasm/util";
2
2
  import { createMemoizedFetch as w, unzipFile as p } from "@wp-playground/common";
3
- import { logger as _ } from "@php-wasm/logger";
3
+ import { logger as c } from "@php-wasm/logger";
4
4
  import { sandboxedSpawnHandlerFactory as m, PHPRequestHandler as b, withPHPIniValues as y, PHP as k, setPhpIniEntries as P, writeFiles as E, proxyFileSystem as T, rotatePHPRuntime as S } from "@php-wasm/universal";
5
5
  const R = `<?php
6
6
 
@@ -375,24 +375,39 @@ async function x(e, r) {
375
375
  )
376
376
  ), await v(e, n, t, "skip");
377
377
  }
378
- async function H(e) {
378
+ async function Q(e) {
379
379
  var t, i;
380
380
  const r = await L(e), n = await r.getPrimaryPhp();
381
- if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await F(n, await e.wordPressZip), e.constants)
381
+ if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await N(n, await e.wordPressZip), e.constants)
382
382
  for (const o in e.constants)
383
383
  n.defineConstant(o, e.constants[o]);
384
- if (e.dataSqlPath && (n.defineConstant("DB_DIR", g(e.dataSqlPath)), n.defineConstant("DB_FILE", $(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await x(n, r.documentRoot), (i = e.hooks) != null && i.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await D(
384
+ if (e.dataSqlPath && (n.defineConstant("DB_DIR", g(e.dataSqlPath)), n.defineConstant("DB_FILE", $(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await x(n, r.documentRoot), (i = e.hooks) != null && i.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await F(
385
385
  n,
386
386
  await e.sqliteIntegrationPluginZip
387
- ), !e.dataSqlPath && (await f(n) || await I(n), !await f(n)))
388
- throw new Error("WordPress installation has failed.");
387
+ ), !e.dataSqlPath && (await f(n) || await I(n), !await f(n))) {
388
+ if (await O(n))
389
+ throw new Error("WordPress installation has failed.");
390
+ if (n.isFile("/internal/shared/preload/0-sqlite.php"))
391
+ throw new Error("Error connecting to the SQLite database.");
392
+ if (!e.sqliteIntegrationPluginZip) {
393
+ const a = s(
394
+ r.documentRoot,
395
+ "wp-content/mu-plugins/sqlite-database-integration"
396
+ );
397
+ if (n.isDir(a))
398
+ throw new Error(
399
+ "Error connecting to the SQLite database."
400
+ );
401
+ }
402
+ throw new Error("Error connecting to the MySQL database.");
403
+ }
389
404
  return r;
390
405
  }
391
406
  async function L(e) {
392
407
  const r = e.spawnHandler ?? m;
393
408
  async function n(i, o) {
394
409
  const a = new k(await e.createPhpRuntime());
395
- return e.sapiName && a.setSapiName(e.sapiName), i && (a.requestHandler = i), e.phpIniEntries && P(a, e.phpIniEntries), o ? (await C(a), await E(a, "/", e.createFiles || {}), await A(
410
+ return e.sapiName && a.setSapiName(e.sapiName), i && (a.requestHandler = i), e.phpIniEntries && P(a, e.phpIniEntries), o ? (await D(a), await E(a, "/", e.createFiles || {}), await A(
396
411
  a,
397
412
  s(new URL(e.siteUrl).pathname, "phpinfo.php")
398
413
  )) : T(await i.getPrimaryPhp(), a, [
@@ -412,7 +427,7 @@ async function L(e) {
412
427
  phpFactory: async ({ isPrimary: i }) => n(t, i),
413
428
  documentRoot: e.documentRoot || "/wordpress",
414
429
  absoluteUrl: e.siteUrl,
415
- rewriteRules: O,
430
+ rewriteRules: C,
416
431
  getFileNotFoundAction: e.getFileNotFoundAction ?? U,
417
432
  cookieStore: e.cookieStore
418
433
  });
@@ -480,7 +495,7 @@ async function I(e) {
480
495
  env: {
481
496
  DOCUMENT_ROOT: e.documentRoot
482
497
  }
483
- })).text !== "1" && _.warn("Failed to default to pretty permalinks after WP install.");
498
+ })).text !== "1" && c.warn("Failed to default to pretty permalinks after WP install.");
484
499
  }
485
500
  function U(e) {
486
501
  return {
@@ -488,6 +503,25 @@ function U(e) {
488
503
  uri: "/index.php"
489
504
  };
490
505
  }
506
+ async function O(e) {
507
+ return (await e.run({
508
+ code: `<?php
509
+ ob_start();
510
+ $wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
511
+ if (!file_exists($wp_load)) {
512
+ echo '-1';
513
+ exit;
514
+ }
515
+ require $wp_load;
516
+ ob_clean();
517
+ echo $wpdb->check_connection( false) ? '1' : '0';
518
+ ob_end_flush();
519
+ `,
520
+ env: {
521
+ DOCUMENT_ROOT: e.documentRoot
522
+ }
523
+ })).text === "1";
524
+ }
491
525
  async function z(e) {
492
526
  const { php: r, reap: n } = await e.processManager.acquirePHPInstance({
493
527
  considerPrimary: !0
@@ -514,13 +548,13 @@ function W(e) {
514
548
  const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
515
549
  return t !== null ? t[1] : e;
516
550
  }
517
- const O = [
551
+ const C = [
518
552
  {
519
553
  match: /^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,
520
554
  replacement: "$2"
521
555
  }
522
556
  ];
523
- async function C(e) {
557
+ async function D(e) {
524
558
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
525
559
  "/internal/shared/preload/env.php",
526
560
  `<?php
@@ -777,7 +811,7 @@ async function A(e, r = "/phpinfo.php") {
777
811
  `
778
812
  );
779
813
  }
780
- async function D(e, r) {
814
+ async function F(e, r) {
781
815
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
782
816
  recursive: !0
783
817
  }), await e.mkdir("/tmp/sqlite-database-integration"), await p(e, r, "/tmp/sqlite-database-integration");
@@ -886,7 +920,7 @@ if(!function_exists('mysqli_connect')) {
886
920
  `
887
921
  );
888
922
  }
889
- async function F(e, r) {
923
+ async function N(e, r) {
890
924
  e.mkdir("/tmp/unzipped-wordpress"), await p(e, r, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await p(
891
925
  e,
892
926
  "/tmp/unzipped-wordpress/wordpress.zip",
@@ -905,8 +939,8 @@ async function F(e, r) {
905
939
  const t = (i, o, a) => {
906
940
  if (a.isDir(i) && a.isDir(o))
907
941
  for (const d of a.listFiles(i)) {
908
- const u = s(i, d), c = s(o, d);
909
- t(u, c, a);
942
+ const u = s(i, d), _ = s(o, d);
943
+ t(u, _, a);
910
944
  }
911
945
  else {
912
946
  if (a.fileExists(o)) {
@@ -914,7 +948,7 @@ async function F(e, r) {
914
948
  /^\/tmp\/unzipped-wordpress\//,
915
949
  "/"
916
950
  );
917
- _.warn(
951
+ c.warn(
918
952
  `Skipping ${d} because something exists at the target path.`
919
953
  );
920
954
  return;
@@ -929,8 +963,8 @@ async function F(e, r) {
929
963
  )
930
964
  );
931
965
  }
932
- const G = w(fetch);
933
- async function Q(e = "latest") {
966
+ const q = w(fetch);
967
+ async function V(e = "latest") {
934
968
  if (e.startsWith("https://") || e.startsWith("http://")) {
935
969
  const t = await crypto.subtle.digest(
936
970
  "SHA-1",
@@ -947,7 +981,7 @@ async function Q(e = "latest") {
947
981
  version: "nightly-" + (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
948
982
  source: "inferred"
949
983
  };
950
- let n = await (await G(
984
+ let n = await (await q(
951
985
  "https://api.wordpress.org/core/version-check/1.7/?channel=beta"
952
986
  )).json();
953
987
  n = n.offers.filter(
@@ -981,17 +1015,17 @@ async function Q(e = "latest") {
981
1015
  }
982
1016
  export {
983
1017
  L as bootRequestHandler,
984
- H as bootWordPress,
1018
+ Q as bootWordPress,
985
1019
  v as defineWpConfigConstants,
986
1020
  x as ensureWpConfig,
987
1021
  U as getFileNotFoundActionForWordPress,
988
1022
  z as getLoadedWordPressVersion,
989
1023
  A as preloadPhpInfoRoute,
990
- D as preloadSqliteIntegration,
991
- Q as resolveWordPressRelease,
992
- C as setupPlatformLevelMuPlugins,
993
- F as unzipWordPress,
1024
+ F as preloadSqliteIntegration,
1025
+ V as resolveWordPressRelease,
1026
+ D as setupPlatformLevelMuPlugins,
1027
+ N as unzipWordPress,
994
1028
  W as versionStringToLoadedWordPressVersion,
995
- O as wordPressRewriteRules
1029
+ C as wordPressRewriteRules
996
1030
  };
997
1031
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/wordpress",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "description": "WordPress-related plumbing for WordPress Playground",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,18 +35,18 @@
35
35
  "access": "public",
36
36
  "directory": "../../../dist/packages/playground/wordpress"
37
37
  },
38
- "gitHead": "8fc1b0f5379a854c9df792c14da17a2ba697e562",
38
+ "gitHead": "025d757fb86aaaae722819154a73fc8b6c728cc7",
39
39
  "dependencies": {
40
40
  "express": "4.21.2",
41
41
  "ini": "4.1.2",
42
42
  "wasm-feature-detect": "1.8.0",
43
43
  "ws": "8.18.1",
44
44
  "yargs": "17.7.2",
45
- "@php-wasm/universal": "2.0.4",
46
- "@php-wasm/util": "2.0.4",
47
- "@php-wasm/logger": "2.0.4",
48
- "@wp-playground/common": "2.0.4",
49
- "@php-wasm/node": "2.0.4"
45
+ "@php-wasm/universal": "2.0.7",
46
+ "@php-wasm/util": "2.0.7",
47
+ "@php-wasm/logger": "2.0.7",
48
+ "@wp-playground/common": "2.0.7",
49
+ "@php-wasm/node": "2.0.7"
50
50
  },
51
51
  "overrides": {
52
52
  "rollup": "^4.34.6",