@wp-playground/wordpress 1.1.3 → 1.1.4

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/boot.d.ts CHANGED
@@ -9,6 +9,7 @@ export interface Hooks {
9
9
  export type DatabaseType = 'sqlite' | 'mysql' | 'custom';
10
10
  export interface BootOptions {
11
11
  createPhpRuntime: () => Promise<number>;
12
+ onPHPInstanceCreated?: (php: PHP) => Promise<void>;
12
13
  /**
13
14
  * Mounting and Copying is handled via hooks for starters.
14
15
  *
package/index.cjs CHANGED
@@ -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 _(e,i){const n=r.joinPaths(i,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(r.joinPaths(i,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(r.joinPaths(i,"wp-config-sample.php"))),await f(e,n,t,"skip")}async function T(e){var t,a;const i=await c(e),n=await i.getPrimaryPhp();if((t=e.hooks)!=null&&t.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await y(n,await e.wordPressZip),e.constants)for(const o in e.constants)n.defineConstant(o,e.constants[o]);if(n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await _(n,i.documentRoot),(a=e.hooks)!=null&&a.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n),e.sqliteIntegrationPluginZip&&await b(n,await e.sqliteIntegrationPluginZip),await p(n)||await R(n),!await p(n))throw new Error("WordPress installation has failed.");return i}async function c(e){async function i(t,a){const o=new s.PHP(await e.createPhpRuntime());return e.sapiName&&o.setSapiName(e.sapiName),t&&(o.requestHandler=t),e.phpIniEntries&&s.setPhpIniEntries(o,e.phpIniEntries),a?(await w(o),await s.writeFiles(o,"/",e.createFiles||{}),await m(o,r.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):s.proxyFileSystem(await t.getPrimaryPhp(),o,["/tmp",t.documentRoot,"/internal/shared"]),e.spawnHandler&&await o.setSpawnHandler(e.spawnHandler(t.processManager)),s.rotatePHPRuntime({php:o,cwd:t.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),o}const n=new s.PHPRequestHandler({phpFactory:async({isPrimary:t})=>i(n,t),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:$,getFileNotFoundAction:e.getFileNotFoundAction??h,cookieStore:e.cookieStore});return n}async function p(e){return(await e.run({code:`<?php
355
+ `})).text!=="1")throw new Error("Failed to rewrite constants in wp-config.php.")}async function _(e,i){const n=r.joinPaths(i,"wp-config.php"),t={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(r.joinPaths(i,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(r.joinPaths(i,"wp-config-sample.php"))),await f(e,n,t,"skip")}async function R(e){var t,a;const i=await c(e),n=await i.getPrimaryPhp();if((t=e.hooks)!=null&&t.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(n),e.wordPressZip&&await y(n,await e.wordPressZip),e.constants)for(const o in e.constants)n.defineConstant(o,e.constants[o]);if(e.dataSqlPath&&(n.defineConstant("DB_DIR",r.dirname(e.dataSqlPath)),n.defineConstant("DB_FILE",r.basename(e.dataSqlPath))),n.defineConstant("WP_HOME",e.siteUrl),n.defineConstant("WP_SITEURL",e.siteUrl),await _(n,i.documentRoot),(a=e.hooks)!=null&&a.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(n),e.sqliteIntegrationPluginZip&&await b(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await p(n)||await T(n),!await p(n)))throw new Error("WordPress installation has failed.");return i}async function c(e){async function i(t,a){const o=new s.PHP(await e.createPhpRuntime());return e.sapiName&&o.setSapiName(e.sapiName),t&&(o.requestHandler=t),e.phpIniEntries&&s.setPhpIniEntries(o,e.phpIniEntries),a?(await w(o),await s.writeFiles(o,"/",e.createFiles||{}),await m(o,r.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):s.proxyFileSystem(await t.getPrimaryPhp(),o,["/tmp",t.documentRoot,"/internal/shared"]),e.spawnHandler&&await o.setSpawnHandler(e.spawnHandler(t.processManager)),s.rotatePHPRuntime({php:o,cwd:t.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(o),o}const n=new s.PHPRequestHandler({phpFactory:async({isPrimary:t})=>i(n,t),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:$,getFileNotFoundAction:e.getFileNotFoundAction??h,cookieStore:e.cookieStore});return n}async function p(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)) {
@@ -363,7 +363,7 @@ function skip_whitespace($tokens) {
363
363
  ob_clean();
364
364
  echo is_blog_installed() ? '1' : '0';
365
365
  ob_end_flush();
366
- `,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function R(e){await s.withPHPIniValues(e,{disable_functions:"fsockopen",allow_url_fopen:"0"},async()=>await e.request({url:"/wp-admin/install.php?step=2",method:"POST",body:{language:"en",prefix:"wp_",weblog_title:"My WordPress Website",user_name:"admin",admin_password:"password",admin_password2:"password",Submit:"Install WordPress",pw_weak:"1",admin_email:"admin@localhost.com"}})),(await e.run({code:`<?php
366
+ `,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function T(e){await s.withPHPIniValues(e,{disable_functions:"fsockopen",allow_url_fopen:"0"},async()=>await e.request({url:"/wp-admin/install.php?step=2",method:"POST",body:{language:"en",prefix:"wp_",weblog_title:"My WordPress Website",user_name:"admin",admin_password:"password",admin_password2:"password",Submit:"Install WordPress",pw_weak:"1",admin_email:"admin@localhost.com"}})),(await e.run({code:`<?php
367
367
  ob_start();
368
368
  $wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';
369
369
  if (!file_exists($wp_load)) {
@@ -692,5 +692,5 @@ if(!function_exists('mysqli_connect')) {
692
692
  var_dump(isset($wpdb));
693
693
  die("SQLite integration not loaded " . get_class($wpdb));
694
694
  }
695
- `)}async function y(e,i){e.mkdir("/tmp/unzipped-wordpress"),await d.unzipFile(e,i,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await d.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(r.joinPaths(n,"wp-config-sample.php"))){const t=e.listFiles(n);if(t.length){const a=t[0];e.fileExists(r.joinPaths(n,a,"wp-config-sample.php"))&&(n=r.joinPaths(n,a))}}if(e.isDir(e.documentRoot)&&v(e.documentRoot,e)){for(const t of e.listFiles(n)){const a=r.joinPaths(n,t),o=r.joinPaths(e.documentRoot,t);e.mv(a,o)}e.rmdir(n,{recursive:!0})}else e.mv(n,e.documentRoot);!e.fileExists(r.joinPaths(e.documentRoot,"wp-config.php"))&&e.fileExists(r.joinPaths(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(r.joinPaths(e.documentRoot,"wp-config.php"),e.readFileAsText(r.joinPaths(e.documentRoot,"/wp-config-sample.php")))}function v(e,i){const n=i.listFiles(e);return n.length===0||n.length===1&&n[0]==="playground-site-metadata.json"}const L=d.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)),a=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+a.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=c;exports.bootWordPress=T;exports.defineWpConfigConstants=f;exports.ensureWpConfig=_;exports.getFileNotFoundActionForWordPress=h;exports.getLoadedWordPressVersion=S;exports.preloadPhpInfoRoute=m;exports.preloadSqliteIntegration=b;exports.resolveWordPressRelease=x;exports.setupPlatformLevelMuPlugins=w;exports.unzipWordPress=y;exports.versionStringToLoadedWordPressVersion=g;exports.wordPressRewriteRules=$;
695
+ `)}async function y(e,i){e.mkdir("/tmp/unzipped-wordpress"),await d.unzipFile(e,i,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await d.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(r.joinPaths(n,"wp-config-sample.php"))){const t=e.listFiles(n);if(t.length){const a=t[0];e.fileExists(r.joinPaths(n,a,"wp-config-sample.php"))&&(n=r.joinPaths(n,a))}}if(e.isDir(e.documentRoot)&&v(e.documentRoot,e)){for(const t of e.listFiles(n)){const a=r.joinPaths(n,t),o=r.joinPaths(e.documentRoot,t);e.mv(a,o)}e.rmdir(n,{recursive:!0})}else e.mv(n,e.documentRoot);!e.fileExists(r.joinPaths(e.documentRoot,"wp-config.php"))&&e.fileExists(r.joinPaths(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(r.joinPaths(e.documentRoot,"wp-config.php"),e.readFileAsText(r.joinPaths(e.documentRoot,"/wp-config-sample.php")))}function v(e,i){const n=i.listFiles(e);return n.length===0||n.length===1&&n[0]==="playground-site-metadata.json"}const L=d.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)),a=Array.from(new Uint8Array(t)).map(o=>o.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+a.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=c;exports.bootWordPress=R;exports.defineWpConfigConstants=f;exports.ensureWpConfig=_;exports.getFileNotFoundActionForWordPress=h;exports.getLoadedWordPressVersion=S;exports.preloadPhpInfoRoute=m;exports.preloadSqliteIntegration=b;exports.resolveWordPressRelease=x;exports.setupPlatformLevelMuPlugins=w;exports.unzipWordPress=y;exports.versionStringToLoadedWordPressVersion=g;exports.wordPressRewriteRules=$;
696
696
  //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { phpVars as _, joinPaths as a, phpVar as s } from "@php-wasm/util";
2
- import { createMemoizedFetch as c, unzipFile as d } from "@wp-playground/common";
3
- import { PHPRequestHandler as h, withPHPIniValues as g, PHP as $, setPhpIniEntries as w, writeFiles as m, proxyFileSystem as b, rotatePHPRuntime as y } from "@php-wasm/universal";
4
- import { logger as k } from "@php-wasm/logger";
5
- const P = `<?php
1
+ import { phpVars as _, joinPaths as o, dirname as c, basename as h, phpVar as s } from "@php-wasm/util";
2
+ import { createMemoizedFetch as g, unzipFile as d } from "@wp-playground/common";
3
+ import { PHPRequestHandler as $, withPHPIniValues as w, PHP as m, setPhpIniEntries as b, writeFiles as y, proxyFileSystem as k, rotatePHPRuntime as P } from "@php-wasm/universal";
4
+ import { logger as E } from "@php-wasm/logger";
5
+ const T = `<?php
6
6
 
7
7
  /**
8
8
  * Rewrites the wp-config.php file to ensure specific constants are defined
@@ -348,14 +348,14 @@ function skip_whitespace($tokens) {
348
348
  return $output;
349
349
  }
350
350
  `;
351
- async function E(e, i, n, t = "rewrite") {
352
- const o = _({ wpConfigPath: i, constants: n, whenAlreadyDefined: t });
351
+ async function R(e, i, n, t = "rewrite") {
352
+ const a = _({ wpConfigPath: i, constants: n, whenAlreadyDefined: t });
353
353
  if ((await e.run({
354
354
  code: `<?php ob_start(); ?>
355
- ${P}
356
- $wp_config_path = ${o.wpConfigPath};
355
+ ${T}
356
+ $wp_config_path = ${a.wpConfigPath};
357
357
  $wp_config = file_get_contents($wp_config_path);
358
- $new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${o.constants}, ${o.whenAlreadyDefined});
358
+ $new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${a.constants}, ${a.whenAlreadyDefined});
359
359
  $return_value = file_put_contents($wp_config_path, $new_wp_config);
360
360
  ob_clean();
361
361
  echo false === $return_value ? '0' : '1';
@@ -364,55 +364,55 @@ async function E(e, i, n, t = "rewrite") {
364
364
  })).text !== "1")
365
365
  throw new Error("Failed to rewrite constants in wp-config.php.");
366
366
  }
367
- async function T(e, i) {
368
- const n = a(i, "wp-config.php"), t = {
367
+ async function S(e, i) {
368
+ const n = o(i, "wp-config.php"), t = {
369
369
  DB_NAME: "wordpress"
370
370
  };
371
- !e.fileExists(n) && e.fileExists(a(i, "wp-config-sample.php")) && await e.writeFile(
371
+ !e.fileExists(n) && e.fileExists(o(i, "wp-config-sample.php")) && await e.writeFile(
372
372
  n,
373
373
  await e.readFileAsBuffer(
374
- a(i, "wp-config-sample.php")
374
+ o(i, "wp-config-sample.php")
375
375
  )
376
- ), await E(e, n, t, "skip");
376
+ ), await R(e, n, t, "skip");
377
377
  }
378
- async function q(e) {
379
- var t, o;
380
- const i = await R(e), n = await i.getPrimaryPhp();
381
- if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await O(n, await e.wordPressZip), e.constants)
378
+ async function M(e) {
379
+ var t, a;
380
+ const i = await v(e), n = await i.getPrimaryPhp();
381
+ if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await D(n, await e.wordPressZip), e.constants)
382
382
  for (const r in e.constants)
383
383
  n.defineConstant(r, e.constants[r]);
384
- if (n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await T(n, i.documentRoot), (o = e.hooks) != null && o.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await W(
384
+ if (e.dataSqlPath && (n.defineConstant("DB_DIR", c(e.dataSqlPath)), n.defineConstant("DB_FILE", h(e.dataSqlPath))), n.defineConstant("WP_HOME", e.siteUrl), n.defineConstant("WP_SITEURL", e.siteUrl), await S(n, i.documentRoot), (a = e.hooks) != null && a.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await C(
385
385
  n,
386
386
  await e.sqliteIntegrationPluginZip
387
- ), await p(n) || await S(n), !await p(n))
387
+ ), !e.dataSqlPath && (await p(n) || await L(n), !await p(n)))
388
388
  throw new Error("WordPress installation has failed.");
389
389
  return i;
390
390
  }
391
- async function R(e) {
392
- async function i(t, o) {
393
- const r = new $(await e.createPhpRuntime());
394
- return e.sapiName && r.setSapiName(e.sapiName), t && (r.requestHandler = t), e.phpIniEntries && w(r, e.phpIniEntries), o ? (await I(r), await m(r, "/", e.createFiles || {}), await U(
391
+ async function v(e) {
392
+ async function i(t, a) {
393
+ const r = new m(await e.createPhpRuntime());
394
+ return e.sapiName && r.setSapiName(e.sapiName), t && (r.requestHandler = t), e.phpIniEntries && b(r, e.phpIniEntries), a ? (await W(r), await y(r, "/", e.createFiles || {}), await O(
395
395
  r,
396
- a(new URL(e.siteUrl).pathname, "phpinfo.php")
397
- )) : b(await t.getPrimaryPhp(), r, [
396
+ o(new URL(e.siteUrl).pathname, "phpinfo.php")
397
+ )) : k(await t.getPrimaryPhp(), r, [
398
398
  "/tmp",
399
399
  t.documentRoot,
400
400
  "/internal/shared"
401
401
  ]), e.spawnHandler && await r.setSpawnHandler(
402
402
  e.spawnHandler(t.processManager)
403
- ), y({
403
+ ), P({
404
404
  php: r,
405
405
  cwd: t.documentRoot,
406
406
  recreateRuntime: e.createPhpRuntime,
407
407
  maxRequests: 400
408
- }), r;
408
+ }), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(r), r;
409
409
  }
410
- const n = new h({
410
+ const n = new $({
411
411
  phpFactory: async ({ isPrimary: t }) => i(n, t),
412
412
  documentRoot: e.documentRoot || "/wordpress",
413
413
  absoluteUrl: e.siteUrl,
414
- rewriteRules: L,
415
- getFileNotFoundAction: e.getFileNotFoundAction ?? v,
414
+ rewriteRules: U,
415
+ getFileNotFoundAction: e.getFileNotFoundAction ?? x,
416
416
  cookieStore: e.cookieStore
417
417
  });
418
418
  return n;
@@ -436,8 +436,8 @@ async function p(e) {
436
436
  }
437
437
  })).text === "1";
438
438
  }
439
- async function S(e) {
440
- await g(
439
+ async function L(e) {
440
+ await w(
441
441
  e,
442
442
  {
443
443
  disable_functions: "fsockopen",
@@ -479,33 +479,33 @@ async function S(e) {
479
479
  env: {
480
480
  DOCUMENT_ROOT: e.documentRoot
481
481
  }
482
- })).text !== "1" && k.warn("Failed to default to pretty permalinks after WP install.");
482
+ })).text !== "1" && E.warn("Failed to default to pretty permalinks after WP install.");
483
483
  }
484
- function v(e) {
484
+ function x(e) {
485
485
  return {
486
486
  type: "internal-redirect",
487
487
  uri: "/index.php"
488
488
  };
489
489
  }
490
- async function M(e) {
490
+ async function H(e) {
491
491
  const { php: i, reap: n } = await e.processManager.acquirePHPInstance({
492
492
  considerPrimary: !0
493
493
  });
494
494
  try {
495
- const o = (await i.run({
495
+ const a = (await i.run({
496
496
  code: `<?php
497
497
  require '${e.documentRoot}/wp-includes/version.php';
498
498
  echo $wp_version;
499
499
  `
500
500
  })).text;
501
- if (!o)
501
+ if (!a)
502
502
  throw new Error("Unable to read loaded WordPress version.");
503
- return x(o);
503
+ return I(a);
504
504
  } finally {
505
505
  n();
506
506
  }
507
507
  }
508
- function x(e) {
508
+ function I(e) {
509
509
  if (/-(alpha|beta|RC)\d*-\d+$/.test(e))
510
510
  return "nightly";
511
511
  if (/-(beta|RC)\d*$/.test(e))
@@ -513,13 +513,13 @@ function x(e) {
513
513
  const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
514
514
  return t !== null ? t[1] : e;
515
515
  }
516
- const L = [
516
+ const U = [
517
517
  {
518
518
  match: /^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,
519
519
  replacement: "$2"
520
520
  }
521
521
  ];
522
- async function I(e) {
522
+ async function W(e) {
523
523
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
524
524
  "/internal/shared/preload/env.php",
525
525
  `<?php
@@ -762,33 +762,35 @@ async function I(e) {
762
762
  })();`
763
763
  );
764
764
  }
765
- async function U(e, i = "/phpinfo.php") {
765
+ async function O(e, i = "/phpinfo.php") {
766
766
  await e.writeFile(
767
767
  "/internal/shared/preload/phpinfo.php",
768
768
  `<?php
769
769
  // Render PHPInfo if the requested page is /phpinfo.php
770
- if ( isset($_SERVER['REQUEST_URI']) && ${s(i)} === $_SERVER['REQUEST_URI'] ) {
770
+ if ( isset($_SERVER['REQUEST_URI']) && ${s(
771
+ i
772
+ )} === $_SERVER['REQUEST_URI'] ) {
771
773
  phpinfo();
772
774
  exit;
773
775
  }
774
776
  `
775
777
  );
776
778
  }
777
- async function W(e, i) {
779
+ async function C(e, i) {
778
780
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
779
781
  recursive: !0
780
782
  }), await e.mkdir("/tmp/sqlite-database-integration"), await d(e, i, "/tmp/sqlite-database-integration");
781
783
  const n = "/internal/shared/sqlite-database-integration", t = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
782
784
  await e.mv(t, n), e.defineConstant("WP_SQLITE_AST_DRIVER", !0), await e.defineConstant("SQLITE_MAIN_FILE", "1");
783
785
  const r = (await e.readFileAsText(
784
- a(n, "db.copy")
786
+ o(n, "db.copy")
785
787
  )).replace(
786
788
  "'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
787
789
  s(n)
788
790
  ).replace(
789
791
  "'{SQLITE_PLUGIN}'",
790
- s(a(n, "load.php"))
791
- ), f = a(await e.documentRoot, "wp-content/db.php"), l = `<?php
792
+ s(o(n, "load.php"))
793
+ ), f = o(await e.documentRoot, "wp-content/db.php"), l = `<?php
792
794
  // Do not preload this if WordPress comes with a custom db.php file.
793
795
  if(file_exists(${s(f)})) {
794
796
  return;
@@ -874,52 +876,52 @@ if(!function_exists('mysqli_connect')) {
874
876
  `
875
877
  );
876
878
  }
877
- async function O(e, i) {
879
+ async function D(e, i) {
878
880
  e.mkdir("/tmp/unzipped-wordpress"), await d(e, i, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await d(
879
881
  e,
880
882
  "/tmp/unzipped-wordpress/wordpress.zip",
881
883
  "/tmp/unzipped-wordpress"
882
884
  );
883
885
  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";
884
- if (!e.fileExists(a(n, "wp-config-sample.php"))) {
886
+ if (!e.fileExists(o(n, "wp-config-sample.php"))) {
885
887
  const t = e.listFiles(n);
886
888
  if (t.length) {
887
- const o = t[0];
889
+ const a = t[0];
888
890
  e.fileExists(
889
- a(n, o, "wp-config-sample.php")
890
- ) && (n = a(n, o));
891
+ o(n, a, "wp-config-sample.php")
892
+ ) && (n = o(n, a));
891
893
  }
892
894
  }
893
- if (e.isDir(e.documentRoot) && C(e.documentRoot, e)) {
895
+ if (e.isDir(e.documentRoot) && A(e.documentRoot, e)) {
894
896
  for (const t of e.listFiles(n)) {
895
- const o = a(n, t), r = a(e.documentRoot, t);
896
- e.mv(o, r);
897
+ const a = o(n, t), r = o(e.documentRoot, t);
898
+ e.mv(a, r);
897
899
  }
898
900
  e.rmdir(n, { recursive: !0 });
899
901
  } else
900
902
  e.mv(n, e.documentRoot);
901
- !e.fileExists(a(e.documentRoot, "wp-config.php")) && e.fileExists(a(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
902
- a(e.documentRoot, "wp-config.php"),
903
+ !e.fileExists(o(e.documentRoot, "wp-config.php")) && e.fileExists(o(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
904
+ o(e.documentRoot, "wp-config.php"),
903
905
  e.readFileAsText(
904
- a(e.documentRoot, "/wp-config-sample.php")
906
+ o(e.documentRoot, "/wp-config-sample.php")
905
907
  )
906
908
  );
907
909
  }
908
- function C(e, i) {
910
+ function A(e, i) {
909
911
  const n = i.listFiles(e);
910
912
  return n.length === 0 || n.length === 1 && // TODO: use a constant from a site storage package
911
913
  n[0] === "playground-site-metadata.json";
912
914
  }
913
- const A = c(fetch);
914
- async function B(e = "latest") {
915
+ const F = g(fetch);
916
+ async function z(e = "latest") {
915
917
  if (e.startsWith("https://") || e.startsWith("http://")) {
916
918
  const t = await crypto.subtle.digest(
917
919
  "SHA-1",
918
920
  new TextEncoder().encode(e)
919
- ), o = Array.from(new Uint8Array(t)).map((r) => r.toString(16).padStart(2, "0")).join("");
921
+ ), a = Array.from(new Uint8Array(t)).map((r) => r.toString(16).padStart(2, "0")).join("");
920
922
  return {
921
923
  releaseUrl: e,
922
- version: "custom-" + o.substring(0, 8),
924
+ version: "custom-" + a.substring(0, 8),
923
925
  source: "inferred"
924
926
  };
925
927
  } else if (e === "trunk" || e === "nightly")
@@ -928,7 +930,7 @@ async function B(e = "latest") {
928
930
  version: "nightly-" + (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
929
931
  source: "inferred"
930
932
  };
931
- let n = await (await A(
933
+ let n = await (await F(
932
934
  "https://api.wordpress.org/core/version-check/1.7/?channel=beta"
933
935
  )).json();
934
936
  n = n.offers.filter(
@@ -961,18 +963,18 @@ async function B(e = "latest") {
961
963
  };
962
964
  }
963
965
  export {
964
- R as bootRequestHandler,
965
- q as bootWordPress,
966
- E as defineWpConfigConstants,
967
- T as ensureWpConfig,
968
- v as getFileNotFoundActionForWordPress,
969
- M as getLoadedWordPressVersion,
970
- U as preloadPhpInfoRoute,
971
- W as preloadSqliteIntegration,
972
- B as resolveWordPressRelease,
973
- I as setupPlatformLevelMuPlugins,
974
- O as unzipWordPress,
975
- x as versionStringToLoadedWordPressVersion,
976
- L as wordPressRewriteRules
966
+ v as bootRequestHandler,
967
+ M as bootWordPress,
968
+ R as defineWpConfigConstants,
969
+ S as ensureWpConfig,
970
+ x as getFileNotFoundActionForWordPress,
971
+ H as getLoadedWordPressVersion,
972
+ O as preloadPhpInfoRoute,
973
+ C as preloadSqliteIntegration,
974
+ z as resolveWordPressRelease,
975
+ W as setupPlatformLevelMuPlugins,
976
+ D as unzipWordPress,
977
+ I as versionStringToLoadedWordPressVersion,
978
+ U as word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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/wordpress",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "WordPress-related plumbing for WordPress Playground",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,19 +35,20 @@
35
35
  "access": "public",
36
36
  "directory": "../../../dist/packages/playground/wordpress"
37
37
  },
38
- "gitHead": "977f8e90eabb2c8d4eed75677ddd9fb6c13274ae",
38
+ "gitHead": "ed646326d99ba84bad911d65b6634265f508f073",
39
39
  "dependencies": {
40
- "comlink": "^4.4.1",
40
+ "comlink": "^4.4.2",
41
41
  "express": "4.21.2",
42
+ "fs-ext": "2.1.1",
42
43
  "ini": "4.1.2",
43
44
  "wasm-feature-detect": "1.8.0",
44
45
  "ws": "8.18.1",
45
46
  "yargs": "17.7.2",
46
- "@php-wasm/universal": "1.1.3",
47
- "@php-wasm/util": "1.1.3",
48
- "@php-wasm/logger": "1.1.3",
49
- "@wp-playground/common": "1.1.3",
50
- "@php-wasm/node": "1.1.3"
47
+ "@php-wasm/universal": "1.1.4",
48
+ "@php-wasm/util": "1.1.4",
49
+ "@php-wasm/logger": "1.1.4",
50
+ "@wp-playground/common": "1.1.4",
51
+ "@php-wasm/node": "1.1.4"
51
52
  },
52
53
  "overrides": {
53
54
  "rollup": "^4.34.6",