@wp-playground/wordpress 0.9.17 → 0.9.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.d.ts +0 -1
- package/index.js +7 -7
- package/package.json +7 -7
package/index.d.ts
CHANGED
|
@@ -1050,7 +1050,6 @@ export interface BootOptions {
|
|
|
1050
1050
|
*/
|
|
1051
1051
|
export declare function bootWordPress(options: BootOptions): Promise<PHPRequestHandler>;
|
|
1052
1052
|
export declare function getLoadedWordPressVersion(requestHandler: PHPRequestHandler): Promise<string>;
|
|
1053
|
-
export declare function isSupportedWordPressVersion(wpVersion: string): boolean;
|
|
1054
1053
|
/**
|
|
1055
1054
|
* The default rewrite rules for WordPress.
|
|
1056
1055
|
*/
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{joinPaths as s,phpVar as o}from"@php-wasm/util";import{unzipFile as l}from"@wp-playground/common";import{PHPRequestHandler as c,withPHPIniValues as f,PHP as w,setPhpIniEntries as _,writeFiles as g,proxyFileSystem as m,rotatePHPRuntime as h}from"@php-wasm/universal";
|
|
1
|
+
import{joinPaths as s,phpVar as o}from"@php-wasm/util";import{unzipFile as l}from"@wp-playground/common";import{PHPRequestHandler as c,withPHPIniValues as f,PHP as w,setPhpIniEntries as _,writeFiles as g,proxyFileSystem as m,rotatePHPRuntime as h}from"@php-wasm/universal";async function T(e){async function r(i,d){const n=new w(await e.createPhpRuntime());return e.sapiName&&n.setSapiName(e.sapiName),i&&(n.requestHandler=i),e.phpIniEntries&&_(n,e.phpIniEntries),d?(await y(n),await g(n,"/",e.createFiles||{}),await L(n,s(new URL(e.siteUrl).pathname,"phpinfo.php"))):m(await i.getPrimaryPhp(),n,["/tmp",i.documentRoot,"/internal/shared"]),e.spawnHandler&&await n.setSpawnHandler(e.spawnHandler(i.processManager)),h({php:n,cwd:i.documentRoot,recreateRuntime:e.createPhpRuntime,maxRequests:400}),n}const a=new c({phpFactory:async({isPrimary:i})=>r(a,i),documentRoot:e.documentRoot||"/wordpress",absoluteUrl:e.siteUrl,rewriteRules:b}),t=await a.getPrimaryPhp();if(e.hooks?.beforeWordPressFiles&&await e.hooks.beforeWordPressFiles(t),e.wordPressZip&&await R(t,await e.wordPressZip),e.constants)for(const i in e.constants)t.defineConstant(i,e.constants[i]);if(t.defineConstant("WP_HOME",e.siteUrl),t.defineConstant("WP_SITEURL",e.siteUrl),e.hooks?.beforeDatabaseSetup&&await e.hooks.beforeDatabaseSetup(t),e.sqliteIntegrationPluginZip&&await E(t,await e.sqliteIntegrationPluginZip),await u(t)||await $(t),!await u(t))throw new Error("WordPress installation has failed.");return a}async function u(e){return(await e.run({code:`<?php
|
|
2
2
|
require '${e.documentRoot}/wp-load.php';
|
|
3
3
|
echo is_blog_installed() ? '1' : '0';
|
|
4
|
-
`})).text==="1"}async function
|
|
4
|
+
`})).text==="1"}async function $(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"}}))}async function x(e){const t=(await(await e.getPrimaryPhp()).run({code:`<?php
|
|
5
5
|
require '${e.documentRoot}/wp-includes/version.php';
|
|
6
6
|
echo $wp_version;
|
|
7
|
-
`})).text;if(!t)throw new Error("Unable to read loaded WordPress version.");return
|
|
7
|
+
`})).text;if(!t)throw new Error("Unable to read loaded WordPress version.");return P(t)}function P(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 b=[{match:/^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g,replacement:"$2"}];async function y(e){await e.mkdir("/internal/shared/mu-plugins"),await e.writeFile("/internal/shared/preload/env.php",`<?php
|
|
8
8
|
|
|
9
9
|
// Allow adding filters/actions prior to loading WordPress.
|
|
10
10
|
// $function_to_add MUST be a string.
|
|
@@ -108,13 +108,13 @@ import{joinPaths as s,phpVar as o}from"@php-wasm/util";import{unzipFile as l}fro
|
|
|
108
108
|
}
|
|
109
109
|
return false;
|
|
110
110
|
});
|
|
111
|
-
})();`)}async function
|
|
111
|
+
})();`)}async function L(e,r="/phpinfo.php"){await e.writeFile("/internal/shared/preload/phpinfo.php",`<?php
|
|
112
112
|
// Render PHPInfo if the requested page is /phpinfo.php
|
|
113
|
-
if ( ${o(
|
|
113
|
+
if ( ${o(r)} === $_SERVER['REQUEST_URI'] ) {
|
|
114
114
|
phpinfo();
|
|
115
115
|
exit;
|
|
116
116
|
}
|
|
117
|
-
`)}async function
|
|
117
|
+
`)}async function E(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 a="/internal/shared/sqlite-database-integration";await e.mv("/tmp/sqlite-database-integration/sqlite-database-integration-main",a),await e.defineConstant("SQLITE_MAIN_FILE","1");const i=(await e.readFileAsText(s(a,"db.copy"))).replace("'{SQLITE_IMPLEMENTATION_FOLDER_PATH}'",o(a)).replace("'{SQLITE_PLUGIN}'",o(s(a,"load.php"))),d=s(await e.documentRoot,"wp-content/db.php"),n=`<?php
|
|
118
118
|
// Do not preload this if WordPress comes with a custom db.php file.
|
|
119
119
|
if(file_exists(${o(d)})) {
|
|
120
120
|
return;
|
|
@@ -191,4 +191,4 @@ if(!function_exists('mysqli_connect')) {
|
|
|
191
191
|
var_dump(isset($wpdb));
|
|
192
192
|
die("SQLite integration not loaded " . get_class($wpdb));
|
|
193
193
|
}
|
|
194
|
-
`)}async function R(e,
|
|
194
|
+
`)}async function R(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");const a=e.fileExists("/tmp/unzipped-wordpress/wordpress")?"/tmp/unzipped-wordpress/wordpress":e.fileExists("/tmp/unzipped-wordpress/build")?"/tmp/unzipped-wordpress/build":"/tmp/unzipped-wordpress";e.mv(a,e.documentRoot),!e.fileExists(s(e.documentRoot,"wp-config.php"))&&e.fileExists(s(e.documentRoot,"wp-config-sample.php"))&&e.writeFile(s(e.documentRoot,"wp-config.php"),e.readFileAsText(s(e.documentRoot,"/wp-config-sample.php")))}export{T as bootWordPress,x as getLoadedWordPressVersion,L as preloadPhpInfoRoute,E as preloadSqliteIntegration,y as setupPlatformLevelMuPlugins,R as unzipWordPress,b as wordPressRewriteRules};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/wordpress",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.18",
|
|
4
4
|
"description": "WordPress-related plumbing for WordPress Playground",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"access": "public",
|
|
29
29
|
"directory": "../../../dist/packages/playground/wordpress"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "13942923e970013ae9448c658e7c9ba8d4d85619",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"comlink": "^4.4.1",
|
|
34
34
|
"express": "4.19.2",
|
|
35
35
|
"ini": "4.1.2",
|
|
36
36
|
"ws": "8.13.0",
|
|
37
37
|
"yargs": "17.7.2",
|
|
38
|
-
"@php-wasm/universal": "0.9.
|
|
39
|
-
"@php-wasm/util": "0.9.
|
|
40
|
-
"@wp-playground/common": "0.9.
|
|
41
|
-
"@wp-playground/wordpress-builds": "0.9.
|
|
42
|
-
"@php-wasm/node": "0.9.
|
|
38
|
+
"@php-wasm/universal": "0.9.18",
|
|
39
|
+
"@php-wasm/util": "0.9.18",
|
|
40
|
+
"@wp-playground/common": "0.9.18",
|
|
41
|
+
"@wp-playground/wordpress-builds": "0.9.18",
|
|
42
|
+
"@php-wasm/node": "0.9.18"
|
|
43
43
|
}
|
|
44
44
|
}
|