@wp-playground/wordpress 3.0.5 → 3.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"),l=require("@php-wasm/universal"),R=`<?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"),v=`<?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,t,n,i="rewrite"){const r=o.phpVars({wpConfigPath:t,constants:n,whenAlreadyDefined:i});if((await e.run({code:`<?php ob_start(); ?>
347
- ${R}
347
+ ${v}
348
348
  $wp_config_path = ${r.wpConfigPath};
349
349
  $wp_config = file_get_contents($wp_config_path);
350
350
  $new_wp_config = rewrite_wp_config_to_define_constants($wp_config, ${r.constants}, ${r.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,t){const n=o.joinPaths(t,"wp-config.php"),i={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(t,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(t,"wp-config-sample.php"))),await _(e,n,i,"skip")}async function v(e){const t=await w(e);return await g(t,e),t}async function g(e,t){var i,r;const n=await e.getPrimaryPhp();if((i=t.hooks)!=null&&i.beforeWordPressFiles&&await t.hooks.beforeWordPressFiles(n),t.wordPressZip&&await E(n,await t.wordPressZip),t.constants)for(const s in t.constants)n.defineConstant(s,t.constants[s]);if(t.dataSqlPath&&(n.defineConstant("DB_DIR",o.dirname(t.dataSqlPath)),n.defineConstant("DB_FILE",o.basename(t.dataSqlPath))),n.defineConstant("WP_HOME",t.siteUrl),n.defineConstant("WP_SITEURL",t.siteUrl),await h(n,e.documentRoot),(r=t.hooks)!=null&&r.beforeDatabaseSetup&&await t.hooks.beforeDatabaseSetup(n),t.sqliteIntegrationPluginZip&&await k(n,await t.sqliteIntegrationPluginZip),t.wordPressZip&&!t.dataSqlPath&&(await f(n)||await S(n),!await f(n))){if(await L(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(!t.sqliteIntegrationPluginZip){const d=o.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(n.isDir(d))throw new Error("Error connecting to the SQLite database.")}throw new Error("Error connecting to the MySQL database.")}return e}async function w(e){const t=e.spawnHandler??l.sandboxedSpawnHandlerFactory;async function n(r,s){const d=await e.createPhpRuntime(s),a=new l.PHP(d);return e.sapiName&&a.setSapiName(e.sapiName),r&&(a.requestHandler=r),e.phpIniEntries&&l.setPhpIniEntries(a,e.phpIniEntries),a.defineConstant("WP_SQLITE_AST_DRIVER",!0),s&&!a.isFile("/internal/.boot-files-written")&&(await y(a),await l.writeFiles(a,"/",e.createFiles||{}),await P(a,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php")),await l.writeFiles(a,"/internal",{".boot-files-written":""})),t&&await a.setSpawnHandler(t(r.processManager)),a.enableRuntimeRotation({cwd:r.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(a,{isPrimary:s}),a}const i=new l.PHPRequestHandler({phpFactory:async({isPrimary:r})=>n(i,r),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:b,getFileNotFoundAction:e.getFileNotFoundAction??$,cookieStore:e.cookieStore});return i}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,t){const n=o.joinPaths(t,"wp-config.php"),i={DB_NAME:"wordpress"};!e.fileExists(n)&&e.fileExists(o.joinPaths(t,"wp-config-sample.php"))&&await e.writeFile(n,await e.readFileAsBuffer(o.joinPaths(t,"wp-config-sample.php"))),await _(e,n,i,"skip")}async function R(e){const t=await w(e);return await g(t,e),t}async function g(e,t){var i,r;const n=await e.getPrimaryPhp();if((i=t.hooks)!=null&&i.beforeWordPressFiles&&await t.hooks.beforeWordPressFiles(n),t.wordPressZip&&await E(n,await t.wordPressZip),t.constants)for(const a in t.constants)n.defineConstant(a,t.constants[a]);if(t.dataSqlPath&&(n.defineConstant("DB_DIR",o.dirname(t.dataSqlPath)),n.defineConstant("DB_FILE",o.basename(t.dataSqlPath))),n.defineConstant("WP_HOME",t.siteUrl),n.defineConstant("WP_SITEURL",t.siteUrl),await h(n,e.documentRoot),(r=t.hooks)!=null&&r.beforeDatabaseSetup&&await t.hooks.beforeDatabaseSetup(n),t.sqliteIntegrationPluginZip&&await k(n,await t.sqliteIntegrationPluginZip),t.wordPressZip&&!t.dataSqlPath&&(await f(n)||await S(n),!await f(n))){if(await L(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(!t.sqliteIntegrationPluginZip){const l=o.joinPaths(e.documentRoot,"wp-content/mu-plugins/sqlite-database-integration");if(n.isDir(l))throw new Error("Error connecting to the SQLite database.")}throw new Error("Error connecting to the MySQL database.")}return e}async function w(e){const t=e.spawnHandler??d.sandboxedSpawnHandlerFactory;async function n(r,a){const l=await e.createPhpRuntime(a),s=new d.PHP(l);return e.sapiName&&s.setSapiName(e.sapiName),r&&(s.requestHandler=r),e.phpIniEntries&&d.setPhpIniEntries(s,e.phpIniEntries),s.defineConstant("WP_SQLITE_AST_DRIVER",!0),a&&!s.isFile("/internal/.boot-files-written")&&(await y(s),await d.writeFiles(s,"/",e.createFiles||{}),await P(s,o.joinPaths(new URL(e.siteUrl).pathname,"phpinfo.php")),await d.writeFiles(s,"/internal",{".boot-files-written":""})),t&&await s.setSpawnHandler(t(r.processManager)),s.enableRuntimeRotation({recreateRuntime:e.createPhpRuntime,maxRequests:400}),e.onPHPInstanceCreated&&await e.onPHPInstanceCreated(s,{isPrimary:a}),s}const i=new d.PHPRequestHandler({phpFactory:async({isPrimary:r})=>n(i,r),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:b,getFileNotFoundAction:e.getFileNotFoundAction??$,cookieStore:e.cookieStore});return i}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 S(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 S(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 k(e,t){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,t,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",i=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(i,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"))),d=o.joinPaths(await e.documentRoot,"wp-content/db.php"),a=`<?php
672
+ `)}async function k(e,t){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,t,"/tmp/sqlite-database-integration");const n="/internal/shared/sqlite-database-integration",i=`/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;await e.mv(i,n),await e.defineConstant("SQLITE_MAIN_FILE","1");const a=(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"))),l=o.joinPaths(await e.documentRoot,"wp-content/db.php"),s=`<?php
673
673
  // Do not preload this if WordPress comes with a custom db.php file.
674
- if(file_exists(${o.phpVar(d)})) {
674
+ if(file_exists(${o.phpVar(l)})) {
675
675
  return;
676
676
  }
677
- ?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,a+s),await e.writeFile("/internal/shared/preload/0-sqlite.php",a+`<?php
677
+ ?>`,u="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(u,s+a),await e.writeFile("/internal/shared/preload/0-sqlite.php",s+`<?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 E(e,t){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,t,"/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 r=e.listFiles(n);if(r.length){const s=r[0];e.fileExists(o.joinPaths(n,s,"wp-config-sample.php"))&&(n=o.joinPaths(n,s))}}const i=(r,s,d)=>{if(d.isDir(r)&&d.isDir(s))for(const a of d.listFiles(r)){const u=o.joinPaths(r,a),T=o.joinPaths(s,a);i(u,T,d)}else{if(d.fileExists(s)){const a=r.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Skipping ${a} because something exists at the target path.`);return}d.mv(r,s)}};i(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 I=p.createMemoizedFetch(fetch);async function W(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const i=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),r=Array.from(new Uint8Array(i)).map(s=>s.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+r.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 I("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(i=>i.response==="autoupdate");for(const i of n){if(e==="beta"&&i.version.includes("beta"))return{releaseUrl:i.download,version:i.version,source:"api"};if(e==="latest"&&!i.version.includes("beta"))return{releaseUrl:i.download,version:i.version,source:"api"};if(i.version.substring(0,e.length)===e)return{releaseUrl:i.download,version:i.version,source:"api"}}return{releaseUrl:`https://wordpress.org/wordpress-${e}.zip`,version:e,source:"inferred"}}exports.bootRequestHandler=w;exports.bootWordPress=g;exports.bootWordPressAndRequestHandler=v;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=x;exports.preloadPhpInfoRoute=P;exports.preloadSqliteIntegration=k;exports.resolveWordPressRelease=W;exports.setupPlatformLevelMuPlugins=y;exports.unzipWordPress=E;exports.versionStringToLoadedWordPressVersion=m;exports.wordPressRewriteRules=b;
758
+ `)}async function E(e,t){e.mkdir("/tmp/unzipped-wordpress"),await p.unzipFile(e,t,"/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 r=e.listFiles(n);if(r.length){const a=r[0];e.fileExists(o.joinPaths(n,a,"wp-config-sample.php"))&&(n=o.joinPaths(n,a))}}const i=(r,a,l)=>{if(l.isDir(r)&&l.isDir(a))for(const s of l.listFiles(r)){const u=o.joinPaths(r,s),T=o.joinPaths(a,s);i(u,T,l)}else{if(l.fileExists(a)){const s=r.replace(/^\/tmp\/unzipped-wordpress\//,"/");c.logger.warn(`Cannot unzip WordPress files at ${a}: ${s} already exists.`);return}l.mv(r,a)}};i(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 I=p.createMemoizedFetch(fetch);async function W(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const i=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),r=Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("");return{releaseUrl:e,version:"custom-"+r.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 I("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();n=n.offers.filter(i=>i.response==="autoupdate");for(const i of n){if(e==="beta"&&i.version.includes("beta"))return{releaseUrl:i.download,version:i.version,source:"api"};if(e==="latest"&&!i.version.includes("beta"))return{releaseUrl:i.download,version:i.version,source:"api"};if(i.version.substring(0,e.length)===e)return{releaseUrl:i.download,version:i.version,source:"api"}}return{releaseUrl:`https://wordpress.org/wordpress-${e}.zip`,version:e,source:"inferred"}}exports.bootRequestHandler=w;exports.bootWordPress=g;exports.bootWordPressAndRequestHandler=R;exports.defineWpConfigConstants=_;exports.ensureWpConfig=h;exports.getFileNotFoundActionForWordPress=$;exports.getLoadedWordPressVersion=x;exports.preloadPhpInfoRoute=P;exports.preloadSqliteIntegration=k;exports.resolveWordPressRelease=W;exports.setupPlatformLevelMuPlugins=y;exports.unzipWordPress=E;exports.versionStringToLoadedWordPressVersion=m;exports.wordPressRewriteRules=b;
759
759
  //# sourceMappingURL=index.cjs.map
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { phpVars as g, joinPaths as s, dirname as w, basename as $, phpVar as l } from "@php-wasm/util";
1
+ import { phpVars as g, joinPaths as s, dirname as $, basename as w, phpVar as l } from "@php-wasm/util";
2
2
  import { createMemoizedFetch as m, unzipFile as p } from "@wp-playground/common";
3
3
  import { logger as _ } from "@php-wasm/logger";
4
4
  import { sandboxedSpawnHandlerFactory as b, PHPRequestHandler as y, withPHPIniValues as k, PHP as P, setPhpIniEntries as E, writeFiles as f } from "@php-wasm/universal";
@@ -383,9 +383,9 @@ async function S(e, t) {
383
383
  var i, r;
384
384
  const n = await e.getPrimaryPhp();
385
385
  if ((i = t.hooks) != null && i.beforeWordPressFiles && await t.hooks.beforeWordPressFiles(n), t.wordPressZip && await q(n, await t.wordPressZip), t.constants)
386
- for (const o in t.constants)
387
- n.defineConstant(o, t.constants[o]);
388
- if (t.dataSqlPath && (n.defineConstant("DB_DIR", w(t.dataSqlPath)), n.defineConstant("DB_FILE", $(t.dataSqlPath))), n.defineConstant("WP_HOME", t.siteUrl), n.defineConstant("WP_SITEURL", t.siteUrl), await R(n, e.documentRoot), (r = t.hooks) != null && r.beforeDatabaseSetup && await t.hooks.beforeDatabaseSetup(n), t.sqliteIntegrationPluginZip && await A(
386
+ for (const a in t.constants)
387
+ n.defineConstant(a, t.constants[a]);
388
+ if (t.dataSqlPath && (n.defineConstant("DB_DIR", $(t.dataSqlPath)), n.defineConstant("DB_FILE", w(t.dataSqlPath))), n.defineConstant("WP_HOME", t.siteUrl), n.defineConstant("WP_SITEURL", t.siteUrl), await R(n, e.documentRoot), (r = t.hooks) != null && r.beforeDatabaseSetup && await t.hooks.beforeDatabaseSetup(n), t.sqliteIntegrationPluginZip && await A(
389
389
  n,
390
390
  await t.sqliteIntegrationPluginZip
391
391
  ), t.wordPressZip && !t.dataSqlPath && (await c(n) || await L(n), !await c(n))) {
@@ -409,9 +409,9 @@ async function S(e, t) {
409
409
  }
410
410
  async function x(e) {
411
411
  const t = e.spawnHandler ?? b;
412
- async function n(r, o) {
413
- const d = await e.createPhpRuntime(o), a = new P(d);
414
- return e.sapiName && a.setSapiName(e.sapiName), r && (a.requestHandler = r), e.phpIniEntries && E(a, e.phpIniEntries), a.defineConstant("WP_SQLITE_AST_DRIVER", !0), o && /**
412
+ async function n(r, a) {
413
+ const d = await e.createPhpRuntime(a), o = new P(d);
414
+ return e.sapiName && o.setSapiName(e.sapiName), r && (o.requestHandler = r), e.phpIniEntries && E(o, e.phpIniEntries), o.defineConstant("WP_SQLITE_AST_DRIVER", !0), a && /**
415
415
  * Only the first PHP instance of the first worker created
416
416
  * during WordPress boot writes these files – otherwise we'll keep
417
417
  * overwriting them with concurrent writers living in other worker
@@ -421,18 +421,17 @@ async function x(e) {
421
421
  * mechanism. It works, because secondary workers are only booted
422
422
  * once the primary worker has fully booted.
423
423
  */
424
- !a.isFile("/internal/.boot-files-written") && (await C(a), await f(a, "/", e.createFiles || {}), await D(
425
- a,
424
+ !o.isFile("/internal/.boot-files-written") && (await C(o), await f(o, "/", e.createFiles || {}), await D(
425
+ o,
426
426
  s(new URL(e.siteUrl).pathname, "phpinfo.php")
427
- ), await f(a, "/internal", {
427
+ ), await f(o, "/internal", {
428
428
  ".boot-files-written": ""
429
- })), t && await a.setSpawnHandler(
429
+ })), t && await o.setSpawnHandler(
430
430
  t(r.processManager)
431
- ), a.enableRuntimeRotation({
432
- cwd: r.documentRoot,
431
+ ), o.enableRuntimeRotation({
433
432
  recreateRuntime: e.createPhpRuntime,
434
433
  maxRequests: 400
435
- }), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(a, { isPrimary: o }), a;
434
+ }), e.onPHPInstanceCreated && await e.onPHPInstanceCreated(o, { isPrimary: a }), o;
436
435
  }
437
436
  const i = new y({
438
437
  phpFactory: async ({ isPrimary: r }) => n(i, r),
@@ -533,7 +532,7 @@ async function U(e) {
533
532
  }
534
533
  })).text === "1";
535
534
  }
536
- async function Q(e) {
535
+ async function z(e) {
537
536
  const { php: t, reap: n } = await e.processManager.acquirePHPInstance({
538
537
  considerPrimary: !0
539
538
  });
@@ -871,7 +870,7 @@ async function A(e, t) {
871
870
  }), await e.mkdir("/tmp/sqlite-database-integration"), await p(e, t, "/tmp/sqlite-database-integration");
872
871
  const n = "/internal/shared/sqlite-database-integration", i = `/tmp/sqlite-database-integration/${(await e.listFiles("/tmp/sqlite-database-integration"))[0]}`;
873
872
  await e.mv(i, n), await e.defineConstant("SQLITE_MAIN_FILE", "1");
874
- const o = (await e.readFileAsText(
873
+ const a = (await e.readFileAsText(
875
874
  s(n, "db.copy")
876
875
  )).replace(
877
876
  "'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",
@@ -879,15 +878,15 @@ async function A(e, t) {
879
878
  ).replace(
880
879
  "'{SQLITE_PLUGIN}'",
881
880
  l(s(n, "load.php"))
882
- ), d = s(await e.documentRoot, "wp-content/db.php"), a = `<?php
881
+ ), d = s(await e.documentRoot, "wp-content/db.php"), o = `<?php
883
882
  // Do not preload this if WordPress comes with a custom db.php file.
884
883
  if(file_exists(${l(d)})) {
885
884
  return;
886
885
  }
887
886
  ?>`, u = "/internal/shared/mu-plugins/sqlite-database-integration.php";
888
- await e.writeFile(u, a + o), await e.writeFile(
887
+ await e.writeFile(u, o + a), await e.writeFile(
889
888
  "/internal/shared/preload/0-sqlite.php",
890
- a + `<?php
889
+ o + `<?php
891
890
 
892
891
  /**
893
892
  * Loads the SQLite integration plugin before WordPress is loaded
@@ -984,30 +983,30 @@ async function q(e, t) {
984
983
  if (!e.fileExists(s(n, "wp-config-sample.php"))) {
985
984
  const r = e.listFiles(n);
986
985
  if (r.length) {
987
- const o = r[0];
986
+ const a = r[0];
988
987
  e.fileExists(
989
- s(n, o, "wp-config-sample.php")
990
- ) && (n = s(n, o));
988
+ s(n, a, "wp-config-sample.php")
989
+ ) && (n = s(n, a));
991
990
  }
992
991
  }
993
- const i = (r, o, d) => {
994
- if (d.isDir(r) && d.isDir(o))
995
- for (const a of d.listFiles(r)) {
996
- const u = s(r, a), h = s(o, a);
992
+ const i = (r, a, d) => {
993
+ if (d.isDir(r) && d.isDir(a))
994
+ for (const o of d.listFiles(r)) {
995
+ const u = s(r, o), h = s(a, o);
997
996
  i(u, h, d);
998
997
  }
999
998
  else {
1000
- if (d.fileExists(o)) {
1001
- const a = r.replace(
999
+ if (d.fileExists(a)) {
1000
+ const o = r.replace(
1002
1001
  /^\/tmp\/unzipped-wordpress\//,
1003
1002
  "/"
1004
1003
  );
1005
1004
  _.warn(
1006
- `Skipping ${a} because something exists at the target path.`
1005
+ `Cannot unzip WordPress files at ${a}: ${o} already exists.`
1007
1006
  );
1008
1007
  return;
1009
1008
  }
1010
- d.mv(r, o);
1009
+ d.mv(r, a);
1011
1010
  }
1012
1011
  };
1013
1012
  i(n, e.documentRoot, e), e.fileExists(n) && e.rmdir(n, { recursive: !0 }), !e.fileExists(s(e.documentRoot, "wp-config.php")) && e.fileExists(s(e.documentRoot, "wp-config-sample.php")) && e.writeFile(
@@ -1018,12 +1017,12 @@ async function q(e, t) {
1018
1017
  );
1019
1018
  }
1020
1019
  const F = m(fetch);
1021
- async function z(e = "latest") {
1020
+ async function Q(e = "latest") {
1022
1021
  if (e.startsWith("https://") || e.startsWith("http://")) {
1023
1022
  const i = await crypto.subtle.digest(
1024
1023
  "SHA-1",
1025
1024
  new TextEncoder().encode(e)
1026
- ), r = Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1025
+ ), r = Array.from(new Uint8Array(i)).map((a) => a.toString(16).padStart(2, "0")).join("");
1027
1026
  return {
1028
1027
  releaseUrl: e,
1029
1028
  version: "custom-" + r.substring(0, 8),
@@ -1074,10 +1073,10 @@ export {
1074
1073
  v as defineWpConfigConstants,
1075
1074
  R as ensureWpConfig,
1076
1075
  I as getFileNotFoundActionForWordPress,
1077
- Q as getLoadedWordPressVersion,
1076
+ z as getLoadedWordPressVersion,
1078
1077
  D as preloadPhpInfoRoute,
1079
1078
  A as preloadSqliteIntegration,
1080
- z as resolveWordPressRelease,
1079
+ Q as resolveWordPressRelease,
1081
1080
  C as setupPlatformLevelMuPlugins,
1082
1081
  q as unzipWordPress,
1083
1082
  W as versionStringToLoadedWordPressVersion,
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": "3.0.5",
3
+ "version": "3.0.8",
4
4
  "description": "WordPress-related plumbing for WordPress Playground",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,24 +35,25 @@
35
35
  "access": "public",
36
36
  "directory": "../../../dist/packages/playground/wordpress"
37
37
  },
38
- "gitHead": "25f366144172f93d8500031c612bf197638fe78c",
38
+ "gitHead": "a1128d0626073076640e7acd088cd3c9c70916c2",
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": "3.0.5",
46
- "@php-wasm/util": "3.0.5",
47
- "@php-wasm/logger": "3.0.5",
48
- "@wp-playground/common": "3.0.5",
49
- "@php-wasm/node": "3.0.5"
45
+ "@php-wasm/universal": "3.0.8",
46
+ "@php-wasm/util": "3.0.8",
47
+ "@php-wasm/logger": "3.0.8",
48
+ "@wp-playground/common": "3.0.8",
49
+ "@php-wasm/node": "3.0.8"
50
50
  },
51
51
  "overrides": {
52
52
  "rollup": "^4.34.6",
53
53
  "react": "18.3.1",
54
54
  "react-dom": "18.3.1",
55
55
  "typescript": "5.4.5",
56
+ "@playwright/test": "1.47.1",
56
57
  "ws": "^8.18.0"
57
58
  },
58
59
  "optionalDependencies": {