@wp-playground/wordpress 2.0.5 → 2.0.8

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","/internal/symlinks"]),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,30 +375,46 @@ 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, [
399
414
  "/tmp",
400
415
  i.documentRoot,
401
- "/internal/shared"
416
+ "/internal/shared",
417
+ "/internal/symlinks"
402
418
  ]), r && await a.setSpawnHandler(
403
419
  r(i.processManager)
404
420
  ), S({
@@ -412,7 +428,7 @@ async function L(e) {
412
428
  phpFactory: async ({ isPrimary: i }) => n(t, i),
413
429
  documentRoot: e.documentRoot || "/wordpress",
414
430
  absoluteUrl: e.siteUrl,
415
- rewriteRules: O,
431
+ rewriteRules: C,
416
432
  getFileNotFoundAction: e.getFileNotFoundAction ?? U,
417
433
  cookieStore: e.cookieStore
418
434
  });
@@ -480,7 +496,7 @@ async function I(e) {
480
496
  env: {
481
497
  DOCUMENT_ROOT: e.documentRoot
482
498
  }
483
- })).text !== "1" && _.warn("Failed to default to pretty permalinks after WP install.");
499
+ })).text !== "1" && c.warn("Failed to default to pretty permalinks after WP install.");
484
500
  }
485
501
  function U(e) {
486
502
  return {
@@ -488,6 +504,25 @@ function U(e) {
488
504
  uri: "/index.php"
489
505
  };
490
506
  }
507
+ async function O(e) {
508
+ return (await e.run({
509
+ code: `<?php
510
+ ob_start();
511
+ $wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
512
+ if (!file_exists($wp_load)) {
513
+ echo '-1';
514
+ exit;
515
+ }
516
+ require $wp_load;
517
+ ob_clean();
518
+ echo $wpdb->check_connection( false) ? '1' : '0';
519
+ ob_end_flush();
520
+ `,
521
+ env: {
522
+ DOCUMENT_ROOT: e.documentRoot
523
+ }
524
+ })).text === "1";
525
+ }
491
526
  async function z(e) {
492
527
  const { php: r, reap: n } = await e.processManager.acquirePHPInstance({
493
528
  considerPrimary: !0
@@ -514,13 +549,13 @@ function W(e) {
514
549
  const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
515
550
  return t !== null ? t[1] : e;
516
551
  }
517
- const O = [
552
+ const C = [
518
553
  {
519
554
  match: /^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,
520
555
  replacement: "$2"
521
556
  }
522
557
  ];
523
- async function C(e) {
558
+ async function D(e) {
524
559
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
525
560
  "/internal/shared/preload/env.php",
526
561
  `<?php
@@ -777,7 +812,7 @@ async function A(e, r = "/phpinfo.php") {
777
812
  `
778
813
  );
779
814
  }
780
- async function D(e, r) {
815
+ async function F(e, r) {
781
816
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
782
817
  recursive: !0
783
818
  }), await e.mkdir("/tmp/sqlite-database-integration"), await p(e, r, "/tmp/sqlite-database-integration");
@@ -886,7 +921,7 @@ if(!function_exists('mysqli_connect')) {
886
921
  `
887
922
  );
888
923
  }
889
- async function F(e, r) {
924
+ async function N(e, r) {
890
925
  e.mkdir("/tmp/unzipped-wordpress"), await p(e, r, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await p(
891
926
  e,
892
927
  "/tmp/unzipped-wordpress/wordpress.zip",
@@ -905,8 +940,8 @@ async function F(e, r) {
905
940
  const t = (i, o, a) => {
906
941
  if (a.isDir(i) && a.isDir(o))
907
942
  for (const d of a.listFiles(i)) {
908
- const u = s(i, d), c = s(o, d);
909
- t(u, c, a);
943
+ const u = s(i, d), _ = s(o, d);
944
+ t(u, _, a);
910
945
  }
911
946
  else {
912
947
  if (a.fileExists(o)) {
@@ -914,7 +949,7 @@ async function F(e, r) {
914
949
  /^\/tmp\/unzipped-wordpress\//,
915
950
  "/"
916
951
  );
917
- _.warn(
952
+ c.warn(
918
953
  `Skipping ${d} because something exists at the target path.`
919
954
  );
920
955
  return;
@@ -929,8 +964,8 @@ async function F(e, r) {
929
964
  )
930
965
  );
931
966
  }
932
- const G = w(fetch);
933
- async function Q(e = "latest") {
967
+ const q = w(fetch);
968
+ async function V(e = "latest") {
934
969
  if (e.startsWith("https://") || e.startsWith("http://")) {
935
970
  const t = await crypto.subtle.digest(
936
971
  "SHA-1",
@@ -947,7 +982,7 @@ async function Q(e = "latest") {
947
982
  version: "nightly-" + (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
948
983
  source: "inferred"
949
984
  };
950
- let n = await (await G(
985
+ let n = await (await q(
951
986
  "https://api.wordpress.org/core/version-check/1.7/?channel=beta"
952
987
  )).json();
953
988
  n = n.offers.filter(
@@ -981,17 +1016,17 @@ async function Q(e = "latest") {
981
1016
  }
982
1017
  export {
983
1018
  L as bootRequestHandler,
984
- H as bootWordPress,
1019
+ Q as bootWordPress,
985
1020
  v as defineWpConfigConstants,
986
1021
  x as ensureWpConfig,
987
1022
  U as getFileNotFoundActionForWordPress,
988
1023
  z as getLoadedWordPressVersion,
989
1024
  A as preloadPhpInfoRoute,
990
- D as preloadSqliteIntegration,
991
- Q as resolveWordPressRelease,
992
- C as setupPlatformLevelMuPlugins,
993
- F as unzipWordPress,
1025
+ F as preloadSqliteIntegration,
1026
+ V as resolveWordPressRelease,
1027
+ D as setupPlatformLevelMuPlugins,
1028
+ N as unzipWordPress,
994
1029
  W as versionStringToLoadedWordPressVersion,
995
- O as wordPressRewriteRules
1030
+ C as wordPressRewriteRules
996
1031
  };
997
1032
  //# 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.5",
3
+ "version": "2.0.8",
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": "9d14cae73a85996c749bdca82b8266572d4c1e31",
38
+ "gitHead": "886a4a87ea86fed4f76ef1d71fc53601fc90c724",
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.5",
46
- "@php-wasm/util": "2.0.5",
47
- "@php-wasm/logger": "2.0.5",
48
- "@wp-playground/common": "2.0.5",
49
- "@php-wasm/node": "2.0.5"
45
+ "@php-wasm/universal": "2.0.8",
46
+ "@php-wasm/util": "2.0.8",
47
+ "@php-wasm/logger": "2.0.8",
48
+ "@wp-playground/common": "2.0.8",
49
+ "@php-wasm/node": "2.0.8"
50
50
  },
51
51
  "overrides": {
52
52
  "rollup": "^4.34.6",