@wp-playground/wordpress 2.0.15 → 2.0.18

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"),l=require("@php-wasm/universal"),T=`<?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
@@ -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 v(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 P(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await f(n)||await R(n),!await f(n))){if(await S(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??l.sandboxedSpawnHandlerFactory;async function n(i,s){const a=new l.PHP(await e.createPhpRuntime());return e.sapiName&&a.setSapiName(e.sapiName),i&&(a.requestHandler=i),e.phpIniEntries&&l.setPhpIniEntries(a,e.phpIniEntries),a.defineConstant("WP_SQLITE_AST_DRIVER",!0),s?(await b(a),await l.writeFiles(a,"/",e.createFiles||{}),await y(a,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php"))):l.proxyFileSystem(await i.getPrimaryPhp(),a,["/tmp",i.documentRoot,"/internal/shared","/internal/symlinks"]),r&&await a.setSpawnHandler(r(i.processManager)),l.rotatePHPRuntime({php:a,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(a),a}const t=new l.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 v(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 P(n,await e.sqliteIntegrationPluginZip),!e.dataSqlPath&&(await f(n)||await R(n),!await f(n))){if(await S(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),a.defineConstant("WP_SQLITE_AST_DRIVER",!0),s?(await b(a),await d.writeFiles(a,"/",e.createFiles||{}),await y(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)),a.enableRuntimeRotation({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)) {
@@ -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 l.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 R(e){await d.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)) {
@@ -669,12 +669,12 @@ function skip_whitespace($tokens) {
669
669
  phpinfo();
670
670
  exit;
671
671
  }
672
- `)}async function P(e,r){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await p.unzipFile(e,r,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",t=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(t,n),await e.defineConstant("SQLITE_MAIN_FILE","1");const s=(await e.readFileAsText(o.joinPaths(n,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",o.phpVar(n)).replace("'{SQLITE_PLUGIN}'",o.phpVar(o.joinPaths(n,"load.php"))),a=o.joinPaths(await e.documentRoot,"wp-content/db.php"),d=`<?php
672
+ `)}async function P(e,r){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await p.unzipFile(e,r,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",t=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(t,n),await e.defineConstant("SQLITE_MAIN_FILE","1");const s=(await e.readFileAsText(o.joinPaths(n,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",o.phpVar(n)).replace("'{SQLITE_PLUGIN}'",o.phpVar(o.joinPaths(n,"load.php"))),a=o.joinPaths(await e.documentRoot,"wp-content/db.php"),l=`<?php
673
673
  // Do not preload this if WordPress comes with a custom db.php file.
674
674
  if(file_exists(${o.phpVar(a)})) {
675
675
  return;
676
676
  }
677
- ?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,d+s),await e.writeFile("/internal/shared/preload/0-sqlite.php",d+`<?php
677
+ ?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,l+s),await e.writeFile("/internal/shared/preload/0-sqlite.php",l+`<?php
678
678
 
679
679
  /**
680
680
  * Loads the SQLite integration plugin before WordPress is loaded
@@ -755,5 +755,5 @@ if(!function_exists('mysqli_connect')) {
755
755
  var_dump(isset($wpdb));
756
756
  die("SQLite integration not loaded " . get_class($wpdb));
757
757
  }
758
- `)}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 d of a.listFiles(i)){const u=o.joinPaths(i,d),E=o.joinPaths(s,d);t(u,E,a)}else{if(a.fileExists(s)){const d=i.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Skipping ${d} 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 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 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=v;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=x;exports.preloadPhpInfoRoute=y;exports.preloadSqliteIntegration=P;exports.resolveWordPressRelease=I;exports.setupPlatformLevelMuPlugins=b;exports.unzipWordPress=k;exports.versionStringToLoadedWordPressVersion=w;exports.wordPressRewriteRules=m;
758
+ `)}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 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 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=v;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=x;exports.preloadPhpInfoRoute=y;exports.preloadSqliteIntegration=P;exports.resolveWordPressRelease=I;exports.setupPlatformLevelMuPlugins=b;exports.unzipWordPress=k;exports.versionStringToLoadedWordPressVersion=w;exports.wordPressRewriteRules=m;
759
759
  //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -1,8 +1,8 @@
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
3
  import { logger as c } from "@php-wasm/logger";
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 v } from "@php-wasm/universal";
5
- const R = `<?php
4
+ import { sandboxedSpawnHandlerFactory as m, PHPRequestHandler as b, withPHPIniValues as y, PHP as k, setPhpIniEntries as P, writeFiles as E, proxyFileSystem as T } from "@php-wasm/universal";
5
+ const v = `<?php
6
6
 
7
7
  /**
8
8
  * Rewrites the wp-config.php file to ensure specific constants are defined
@@ -348,11 +348,11 @@ function skip_whitespace($tokens) {
348
348
  return $output;
349
349
  }
350
350
  `;
351
- async function S(e, r, n, t = "rewrite") {
351
+ async function R(e, r, n, t = "rewrite") {
352
352
  const i = h({ wpConfigPath: r, constants: n, whenAlreadyDefined: t });
353
353
  if ((await e.run({
354
354
  code: `<?php ob_start(); ?>
355
- ${R}
355
+ ${v}
356
356
  $wp_config_path = ${i.wpConfigPath};
357
357
  $wp_config = file_get_contents($wp_config_path);
358
358
  $new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${i.constants}, ${i.whenAlreadyDefined});
@@ -364,7 +364,7 @@ async function S(e, r, 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 x(e, r) {
367
+ async function S(e, r) {
368
368
  const n = s(r, "wp-config.php"), t = {
369
369
  DB_NAME: "wordpress"
370
370
  };
@@ -373,19 +373,19 @@ async function x(e, r) {
373
373
  await e.readFileAsBuffer(
374
374
  s(r, "wp-config-sample.php")
375
375
  )
376
- ), await S(e, n, t, "skip");
376
+ ), await R(e, n, t, "skip");
377
377
  }
378
- async function Q(e) {
378
+ async function H(e) {
379
379
  var t, i;
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)
380
+ const r = await x(e), n = await r.getPrimaryPhp();
381
+ if ((t = e.hooks) != null && t.beforeWordPressFiles && await e.hooks.beforeWordPressFiles(n), e.wordPressZip && await q(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 q(
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 S(n, r.documentRoot), (i = e.hooks) != null && i.beforeDatabaseSetup && await e.hooks.beforeDatabaseSetup(n), e.sqliteIntegrationPluginZip && await A(
385
385
  n,
386
386
  await e.sqliteIntegrationPluginZip
387
- ), !e.dataSqlPath && (await f(n) || await I(n), !await f(n))) {
388
- if (await O(n))
387
+ ), !e.dataSqlPath && (await f(n) || await L(n), !await f(n))) {
388
+ if (await U(n))
389
389
  throw new Error("WordPress installation has failed.");
390
390
  if (n.isFile("/internal/shared/preload/0-sqlite.php"))
391
391
  throw new Error("Error connecting to the SQLite database.");
@@ -403,11 +403,11 @@ async function Q(e) {
403
403
  }
404
404
  return r;
405
405
  }
406
- async function L(e) {
406
+ async function x(e) {
407
407
  const r = e.spawnHandler ?? m;
408
408
  async function n(i, o) {
409
409
  const a = new k(await e.createPhpRuntime());
410
- return e.sapiName && a.setSapiName(e.sapiName), i && (a.requestHandler = i), e.phpIniEntries && P(a, e.phpIniEntries), a.defineConstant("WP_SQLITE_AST_DRIVER", !0), o ? (await D(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), a.defineConstant("WP_SQLITE_AST_DRIVER", !0), o ? (await C(a), await E(a, "/", e.createFiles || {}), await D(
411
411
  a,
412
412
  s(new URL(e.siteUrl).pathname, "phpinfo.php")
413
413
  )) : T(await i.getPrimaryPhp(), a, [
@@ -417,8 +417,7 @@ async function L(e) {
417
417
  "/internal/symlinks"
418
418
  ]), r && await a.setSpawnHandler(
419
419
  r(i.processManager)
420
- ), v({
421
- php: a,
420
+ ), a.enableRuntimeRotation({
422
421
  cwd: i.documentRoot,
423
422
  recreateRuntime: e.createPhpRuntime,
424
423
  maxRequests: 400
@@ -428,8 +427,8 @@ async function L(e) {
428
427
  phpFactory: async ({ isPrimary: i }) => n(t, i),
429
428
  documentRoot: e.documentRoot || "/wordpress",
430
429
  absoluteUrl: e.siteUrl,
431
- rewriteRules: C,
432
- getFileNotFoundAction: e.getFileNotFoundAction ?? U,
430
+ rewriteRules: W,
431
+ getFileNotFoundAction: e.getFileNotFoundAction ?? I,
433
432
  cookieStore: e.cookieStore
434
433
  });
435
434
  return t;
@@ -453,7 +452,7 @@ async function f(e) {
453
452
  }
454
453
  })).text === "1";
455
454
  }
456
- async function I(e) {
455
+ async function L(e) {
457
456
  await y(
458
457
  e,
459
458
  {
@@ -498,13 +497,13 @@ async function I(e) {
498
497
  }
499
498
  })).text !== "1" && c.warn("Failed to default to pretty permalinks after WP install.");
500
499
  }
501
- function U(e) {
500
+ function I(e) {
502
501
  return {
503
502
  type: "internal-redirect",
504
503
  uri: "/index.php"
505
504
  };
506
505
  }
507
- async function O(e) {
506
+ async function U(e) {
508
507
  return (await e.run({
509
508
  code: `<?php
510
509
  ob_start();
@@ -523,7 +522,7 @@ async function O(e) {
523
522
  }
524
523
  })).text === "1";
525
524
  }
526
- async function z(e) {
525
+ async function Q(e) {
527
526
  const { php: r, reap: n } = await e.processManager.acquirePHPInstance({
528
527
  considerPrimary: !0
529
528
  });
@@ -536,12 +535,12 @@ async function z(e) {
536
535
  })).text;
537
536
  if (!i)
538
537
  throw new Error("Unable to read loaded WordPress version.");
539
- return W(i);
538
+ return O(i);
540
539
  } finally {
541
540
  n();
542
541
  }
543
542
  }
544
- function W(e) {
543
+ function O(e) {
545
544
  if (/-(alpha|beta|RC)\d*-\d+$/.test(e))
546
545
  return "nightly";
547
546
  if (/-(beta|RC)\d*$/.test(e))
@@ -549,13 +548,13 @@ function W(e) {
549
548
  const t = e.match(/^(\d+\.\d+)(?:\.\d+)?$/);
550
549
  return t !== null ? t[1] : e;
551
550
  }
552
- const C = [
551
+ const W = [
553
552
  {
554
553
  match: /^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,
555
554
  replacement: "$2"
556
555
  }
557
556
  ];
558
- async function D(e) {
557
+ async function C(e) {
559
558
  await e.mkdir("/internal/shared/mu-plugins"), await e.writeFile(
560
559
  "/internal/shared/preload/env.php",
561
560
  `<?php
@@ -841,7 +840,7 @@ async function D(e) {
841
840
  })();`
842
841
  );
843
842
  }
844
- async function A(e, r = "/phpinfo.php") {
843
+ async function D(e, r = "/phpinfo.php") {
845
844
  await e.writeFile(
846
845
  "/internal/shared/preload/phpinfo.php",
847
846
  `<?php
@@ -855,7 +854,7 @@ async function A(e, r = "/phpinfo.php") {
855
854
  `
856
855
  );
857
856
  }
858
- async function q(e, r) {
857
+ async function A(e, r) {
859
858
  await e.isDir("/tmp/sqlite-database-integration") && await e.rmdir("/tmp/sqlite-database-integration", {
860
859
  recursive: !0
861
860
  }), await e.mkdir("/tmp/sqlite-database-integration"), await p(e, r, "/tmp/sqlite-database-integration");
@@ -964,7 +963,7 @@ if(!function_exists('mysqli_connect')) {
964
963
  `
965
964
  );
966
965
  }
967
- async function F(e, r) {
966
+ async function q(e, r) {
968
967
  e.mkdir("/tmp/unzipped-wordpress"), await p(e, r, "/tmp/unzipped-wordpress"), e.fileExists("/tmp/unzipped-wordpress/wordpress.zip") && await p(
969
968
  e,
970
969
  "/tmp/unzipped-wordpress/wordpress.zip",
@@ -1007,8 +1006,8 @@ async function F(e, r) {
1007
1006
  )
1008
1007
  );
1009
1008
  }
1010
- const N = w(fetch);
1011
- async function V(e = "latest") {
1009
+ const F = w(fetch);
1010
+ async function z(e = "latest") {
1012
1011
  if (e.startsWith("https://") || e.startsWith("http://")) {
1013
1012
  const t = await crypto.subtle.digest(
1014
1013
  "SHA-1",
@@ -1025,7 +1024,7 @@ async function V(e = "latest") {
1025
1024
  version: "nightly-" + (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
1026
1025
  source: "inferred"
1027
1026
  };
1028
- let n = await (await N(
1027
+ let n = await (await F(
1029
1028
  "https://api.wordpress.org/core/version-check/1.7/?channel=beta"
1030
1029
  )).json();
1031
1030
  n = n.offers.filter(
@@ -1058,18 +1057,18 @@ async function V(e = "latest") {
1058
1057
  };
1059
1058
  }
1060
1059
  export {
1061
- L as bootRequestHandler,
1062
- Q as bootWordPress,
1063
- S as defineWpConfigConstants,
1064
- x as ensureWpConfig,
1065
- U as getFileNotFoundActionForWordPress,
1066
- z as getLoadedWordPressVersion,
1067
- A as preloadPhpInfoRoute,
1068
- q as preloadSqliteIntegration,
1069
- V as resolveWordPressRelease,
1070
- D as setupPlatformLevelMuPlugins,
1071
- F as unzipWordPress,
1072
- W as versionStringToLoadedWordPressVersion,
1073
- C as wordPressRewriteRules
1060
+ x as bootRequestHandler,
1061
+ H as bootWordPress,
1062
+ R as defineWpConfigConstants,
1063
+ S as ensureWpConfig,
1064
+ I as getFileNotFoundActionForWordPress,
1065
+ Q as getLoadedWordPressVersion,
1066
+ D as preloadPhpInfoRoute,
1067
+ A as preloadSqliteIntegration,
1068
+ z as resolveWordPressRelease,
1069
+ C as setupPlatformLevelMuPlugins,
1070
+ q as unzipWordPress,
1071
+ O as versionStringToLoadedWordPressVersion,
1072
+ W as wordPressRewriteRules
1074
1073
  };
1075
1074
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wp-playground/wordpress",
3
- "version": "2.0.15",
3
+ "version": "2.0.18",
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": "f3f73a4fc48bbe3ae099da4c1418d2f125d16d0a",
38
+ "gitHead": "1b63e0be1a05bdd244a5c29beff2ae2c228a003e",
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.15",
46
- "@php-wasm/util": "2.0.15",
47
- "@php-wasm/logger": "2.0.15",
48
- "@wp-playground/common": "2.0.15",
49
- "@php-wasm/node": "2.0.15"
45
+ "@php-wasm/universal": "2.0.18",
46
+ "@php-wasm/util": "2.0.18",
47
+ "@php-wasm/logger": "2.0.18",
48
+ "@wp-playground/common": "2.0.18",
49
+ "@php-wasm/node": "2.0.18"
50
50
  },
51
51
  "overrides": {
52
52
  "rollup": "^4.34.6",