New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wp-playground/wordpress

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wp-playground/wordpress - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

24

index.d.ts

@@ -34,1 +34,25 @@ import { PHP, UniversalPHP } from '@php-wasm/universal';

export declare function unzipWordPress(php: PHP, wpZip: File): Promise<void>;
/**
* Resolves a specific WordPress release URL and version string based on
* a version query string such as "latest", "beta", or "6.6".
*
* Examples:
* ```js
* const { releaseUrl, version } = await resolveWordPressRelease('latest')
* // becomes https://wordpress.org/wordpress-6.6.2.zip and '6.6.2'
*
* const { releaseUrl, version } = await resolveWordPressRelease('beta')
* // becomes https://wordpress.org/wordpress-6.6.2-RC1.zip and '6.6.2-RC1'
*
* const { releaseUrl, version } = await resolveWordPressRelease('6.6')
* // becomes https://wordpress.org/wordpress-6.6.2.zip and '6.6.2'
* ```
*
* @param versionQuery - The WordPress version query string to resolve.
* @returns The resolved WordPress release URL and version string.
*/
export declare function resolveWordPressRelease(versionQuery?: string): Promise<{
releaseUrl: any;
version: any;
source: string;
}>;

22

index.js

@@ -1,2 +0,2 @@

import{joinPaths as a,phpVar as d}from"@php-wasm/util";import{unzipFile as l}from"@wp-playground/common";import{PHPRequestHandler as _,withPHPIniValues as f,PHP as g,setPhpIniEntries as w,writeFiles as m,proxyFileSystem as h,rotatePHPRuntime as $}from"@php-wasm/universal";import{logger as y}from"@php-wasm/logger";async function x(e){async function r(n,s){const o=new g(await e.createPhpRuntime());return e.sapiName&&o.setSapiName(e.sapiName),n&&(o.requestHandler=n),e.phpIniEntries&&w(o,e.phpIniEntries),s?(await L(o),await m(o,"/",e.createFiles||{}),await S(o,a(new URL(e.siteUrl).pathname,"phpinfo.php"))):h(await n.getPrimaryPhp(),o,["/tmp",n.documentRoot,"/internal/shared"]),e.spawnHandler&&await o.setSpawnHandler(e.spawnHandler(n.processManager)),$({php:o,cwd:n.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),o}const t=new _({phpFactory:async({isPrimary:n})=>r(t,n),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:R,getFileNotFoundAction:e.getFileNotFoundAction??b}),i=await t.getPrimaryPhp();if(e.hooks?.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(i),e.wordPressZip&&await I(i,await e.wordPressZip),e.constants)for(const n in e.constants)i.defineConstant(n,e.constants[n]);if(i.defineConstant("WP_HOME",e.siteUrl),i.defineConstant("WP_SITEURL",e.siteUrl),e.hooks?.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(i),e.sqliteIntegrationPluginZip&&await T(i,await e.sqliteIntegrationPluginZip),await c(i)||await P(i),!await c(i))throw new Error("WordPress installation has failed.");return t}async function c(e){return(await e.run({code:`<?php
import{joinPaths as a,phpVar as l}from"@php-wasm/util";import{createMemoizedFetch as _,unzipFile as d}from"@wp-playground/common";import{PHPRequestHandler as f,withPHPIniValues as g,PHP as w,setPhpIniEntries as h,writeFiles as m,proxyFileSystem as $,rotatePHPRuntime as P}from"@php-wasm/universal";import{logger as b}from"@php-wasm/logger";async function q(e){async function n(r,o){const s=new w(await e.createPhpRuntime());return e.sapiName&&s.setSapiName(e.sapiName),r&&(s.requestHandler=r),e.phpIniEntries&&h(s,e.phpIniEntries),o?(await L(s),await m(s,"/",e.createFiles||{}),await T(s,a(new URL(e.siteUrl).pathname,"phpinfo.php"))):$(await r.getPrimaryPhp(),s,["/tmp",r.documentRoot,"/internal/shared"]),e.spawnHandler&&await s.setSpawnHandler(e.spawnHandler(r.processManager)),P({php:s,cwd:r.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),s}const i=new f({phpFactory:async({isPrimary:r})=>n(i,r),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:S,getFileNotFoundAction:e.getFileNotFoundAction??E}),t=await i.getPrimaryPhp();if(e.hooks?.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(t),e.wordPressZip&&await U(t,await e.wordPressZip),e.constants)for(const r in e.constants)t.defineConstant(r,e.constants[r]);if(t.defineConstant("WP_HOME",e.siteUrl),t.defineConstant("WP_SITEURL",e.siteUrl),e.hooks?.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(t),e.sqliteIntegrationPluginZip&&await I(t,await e.sqliteIntegrationPluginZip),await c(t)||await y(t),!await c(t))throw new Error("WordPress installation has failed.");return i}async function c(e){return(await e.run({code:`<?php
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';

@@ -9,3 +9,3 @@ if (!file_exists($wp_load)) {

echo is_blog_installed() ? '1' : '0';
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function P(e){await f(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
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text==="1"}async function y(e){await g(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
$wp_load = getenv('DOCUMENT_ROOT') . '/wp-load.php';

@@ -22,6 +22,6 @@ if (!file_exists($wp_load)) {

echo $option_result ? '1' : '0';
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&y.warn("Failed to default to pretty permalinks after WP install.")}function b(e){return{type:"internal-redirect",uri:"/index.php"}}async function q(e){const i=(await(await e.getPrimaryPhp()).run({code:`<?php
`,env:{DOCUMENT_ROOT:e.documentRoot}})).text!=="1"&&b.warn("Failed to default to pretty permalinks after WP install.")}function E(e){return{type:"internal-redirect",uri:"/index.php"}}async function A(e){const t=(await(await e.getPrimaryPhp()).run({code:`<?php
require '${e.documentRoot}/wp-includes/version.php';
echo $wp_version;
`})).text;if(!i)throw new Error("Unable to read loaded WordPress version.");return E(i)}function E(e){if(/-(alpha|beta|RC)\d*-\d+$/.test(e))return"nightly";if(/-(beta|RC)\d*$/.test(e))return"beta";const i=e.match(/^(\d+\.\d+)(?:\.\d+)?$/);return i!==null?i[1]:e}const R=[{match:/^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,replacement:"$2"}];async function L(e){await e.mkdir("/internal/shared/mu-plugins"),await e.writeFile("/internal/shared/preload/env.php",`<?php
`})).text;if(!t)throw new Error("Unable to read loaded WordPress version.");return R(t)}function R(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 S=[{match:/^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,replacement:"$2"}];async function L(e){await e.mkdir("/internal/shared/mu-plugins"),await e.writeFile("/internal/shared/preload/env.php",`<?php

@@ -235,14 +235,14 @@ // Allow adding filters/actions prior to loading WordPress.

});
})();`)}async function S(e,r="/phpinfo.php"){await e.writeFile("/internal/shared/preload/phpinfo.php",`<?php
})();`)}async function T(e,n="/phpinfo.php"){await e.writeFile("/internal/shared/preload/phpinfo.php",`<?php
// Render PHPInfo if the requested page is /phpinfo.php
if ( ${d(r)} === $_SERVER['REQUEST_URI'] ) {
if ( ${l(n)} === $_SERVER['REQUEST_URI'] ) {
phpinfo();
exit;
}
`)}async function T(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 l(e,r,"/tmp/sqlite-database-integration");const t="/internal/shared/sqlite-database-integration",i=await e.isDir("/tmp/sqlite-database-integration/sqlite-database-integration-main")?"/tmp/sqlite-database-integration/sqlite-database-integration-main":"/tmp/sqlite-database-integration/sqlite-database-integration-develop";await e.mv(i,t),await e.defineConstant("SQLITE_MAIN_FILE","1");const s=(await e.readFileAsText(a(t,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",d(t)).replace("'{SQLITE_PLUGIN}'",d(a(t,"load.php"))),o=a(await e.documentRoot,"wp-content/db.php"),u=`<?php
`)}async function I(e,n){await e.isDir("/tmp/sqlite-database-integration")&&await e.rmdir("/tmp/sqlite-database-integration",{recursive:!0}),await e.mkdir("/tmp/sqlite-database-integration"),await d(e,n,"/tmp/sqlite-database-integration");const i="/internal/shared/sqlite-database-integration",t=await e.isDir("/tmp/sqlite-database-integration/sqlite-database-integration-main")?"/tmp/sqlite-database-integration/sqlite-database-integration-main":"/tmp/sqlite-database-integration/sqlite-database-integration-develop";await e.mv(t,i),await e.defineConstant("SQLITE_MAIN_FILE","1");const o=(await e.readFileAsText(a(i,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",l(i)).replace("'{SQLITE_PLUGIN}'",l(a(i,"load.php"))),s=a(await e.documentRoot,"wp-content/db.php"),u=`<?php
// Do not preload this if WordPress comes with a custom db.php file.
if(file_exists(${d(o)})) {
if(file_exists(${l(s)})) {
return;
}
?>`,p="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(p,u+s),await e.writeFile("/internal/shared/preload/0-sqlite.php",u+`<?php
?>`,p="/internal/shared/mu-plugins/sqlite-database-integration.php";await e.writeFile(p,u+o),await e.writeFile("/internal/shared/preload/0-sqlite.php",u+`<?php

@@ -297,3 +297,3 @@ /**

protected function load_sqlite_integration() {
require_once ${d(p)};
require_once ${l(p)};
}

@@ -320,2 +320,2 @@ }

}
`)}async function I(e,r){e.mkdir("/tmp/unzipped-wordpress"),await l(e,r,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await l(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let t=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(a(t,"wp-config-sample.php"))){const i=e.listFiles(t);if(i.length){const n=i[0];e.fileExists(a(t,n,"wp-config-sample.php"))&&(t=a(t,n))}}if(e.isDir(e.documentRoot)&&v(e.documentRoot,e)){for(const i of e.listFiles(t)){const n=a(t,i),s=a(e.documentRoot,i);e.mv(n,s)}e.rmdir(t,{recursive:!0})}else e.mv(t,e.documentRoot);!e.fileExists(a(e.documentRoot,"wp-config.php"))&&e.fileExists(a(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(a(e.documentRoot,"wp-config.php"),e.readFileAsText(a(e.documentRoot,"/wp-config-sample.php")))}function v(e,r){const t=r.listFiles(e);return t.length===0||t.length===1&&t[0]==="playground-site-metadata.json"}export{x as bootWordPress,b as getFileNotFoundActionForWordPress,q as getLoadedWordPressVersion,S as preloadPhpInfoRoute,T as preloadSqliteIntegration,L as setupPlatformLevelMuPlugins,I as unzipWordPress,E as versionStringToLoadedWordPressVersion,R as wordPressRewriteRules};
`)}async function U(e,n){e.mkdir("/tmp/unzipped-wordpress"),await d(e,n,"/tmp/unzipped-wordpress"),e.fileExists("/tmp/unzipped-wordpress/wordpress.zip")&&await d(e,"/tmp/unzipped-wordpress/wordpress.zip","/tmp/unzipped-wordpress");let i=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(a(i,"wp-config-sample.php"))){const t=e.listFiles(i);if(t.length){const r=t[0];e.fileExists(a(i,r,"wp-config-sample.php"))&&(i=a(i,r))}}if(e.isDir(e.documentRoot)&&v(e.documentRoot,e)){for(const t of e.listFiles(i)){const r=a(i,t),o=a(e.documentRoot,t);e.mv(r,o)}e.rmdir(i,{recursive:!0})}else e.mv(i,e.documentRoot);!e.fileExists(a(e.documentRoot,"wp-config.php"))&&e.fileExists(a(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(a(e.documentRoot,"wp-config.php"),e.readFileAsText(a(e.documentRoot,"/wp-config-sample.php")))}function v(e,n){const i=n.listFiles(e);return i.length===0||i.length===1&&i[0]==="playground-site-metadata.json"}const O=_(fetch);async function N(e="latest"){if(e.startsWith("https://")||e.startsWith("http://")){const t=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(e)),r=Array.from(new Uint8Array(t)).map(o=>o.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 i=await(await O("https://api.wordpress.org/core/version-check/1.7/?channel=beta")).json();i=i.offers.filter(t=>t.response==="autoupdate");for(const t of i){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"}}export{q as bootWordPress,E as getFileNotFoundActionForWordPress,A as getLoadedWordPressVersion,T as preloadPhpInfoRoute,I as preloadSqliteIntegration,N as resolveWordPressRelease,L as setupPlatformLevelMuPlugins,U as unzipWordPress,R as versionStringToLoadedWordPressVersion,S as wordPressRewriteRules};
{
"name": "@wp-playground/wordpress",
"version": "1.0.13",
"version": "1.0.14",
"description": "WordPress-related plumbing for WordPress Playground",

@@ -31,3 +31,3 @@ "repository": {

},
"gitHead": "22888c009b54e0b1e5a5c9961b9d97c08b39f672",
"gitHead": "4d191fdd33db1949e51d54e2b03decbb103db4ac",
"dependencies": {

@@ -41,8 +41,8 @@ "comlink": "^4.4.1",

"yargs": "17.7.2",
"@php-wasm/universal": "1.0.13",
"@php-wasm/util": "1.0.13",
"@php-wasm/logger": "1.0.13",
"@wp-playground/common": "1.0.13",
"@php-wasm/node": "1.0.13"
"@php-wasm/universal": "1.0.14",
"@php-wasm/util": "1.0.14",
"@php-wasm/logger": "1.0.14",
"@wp-playground/common": "1.0.14",
"@php-wasm/node": "1.0.14"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc