@wp-playground/client 0.1.33 → 0.1.34
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 +1 -1
- package/index.d.ts +11 -8
- package/index.js +22 -22
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -100,4 +100,4 @@ function delTree($dir)
|
|
|
100
100
|
* @license
|
|
101
101
|
* Copyright 2019 Google LLC
|
|
102
102
|
* SPDX-License-Identifier: Apache-2.0
|
|
103
|
-
*/const Ue=Symbol("Comlink.proxy"),_t=Symbol("Comlink.endpoint"),St=Symbol("Comlink.releaseProxy"),N=Symbol("Comlink.finalizer"),F=Symbol("Comlink.thrown"),Le=t=>typeof t=="object"&&t!==null||typeof t=="function",$t={canHandle:t=>Le(t)&&t[Ue],serialize(t){const{port1:e,port2:r}=new MessageChannel;return M(t,e),[r,[r]]},deserialize(t){return t.start(),j(t)}},vt={canHandle:t=>Le(t)&&F in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},R=new Map([["proxy",$t],["throw",vt]]);function Et(t,e){for(const r of t)if(e===r||r==="*"||r instanceof RegExp&&r.test(e))return!0;return!1}function M(t,e=globalThis,r=["*"]){e.addEventListener("message",function s(n){if(!n||!n.data)return;if(!Et(r,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},n.data),l=(n.data.argumentList||[]).map(P);let c;try{const u=a.slice(0,-1).reduce((p,y)=>p[y],t),d=a.reduce((p,y)=>p[y],t);switch(o){case"GET":c=d;break;case"SET":u[a.slice(-1)[0]]=P(n.data.value),c=!0;break;case"APPLY":c=d.apply(u,l);break;case"CONSTRUCT":{const p=new d(...l);c=kt(p)}break;case"ENDPOINT":{const{port1:p,port2:y}=new MessageChannel;M(t,y),c=Ct(p,[p])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[F]:0}}Promise.resolve(c).catch(u=>({value:u,[F]:0})).then(u=>{const[d,p]=U(u);e.postMessage(Object.assign(Object.assign({},d),{id:i}),p),o==="RELEASE"&&(e.removeEventListener("message",s),Ae(e),N in t&&typeof t[N]=="function"&&t[N]())}).catch(u=>{const[d,p]=U({value:new TypeError("Unserializable return value"),[F]:0});e.postMessage(Object.assign(Object.assign({},d),{id:i}),p)})}),e.start&&e.start()}function Rt(t){return t.constructor.name==="MessagePort"}function Ae(t){Rt(t)&&t.close()}function j(t,e){return W(t,[],e)}function x(t){if(t)throw new Error("Proxy has been released and is not useable")}function He(t){return $(t,{type:"RELEASE"}).then(()=>{Ae(t)})}const k=new WeakMap,O="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(k.get(t)||0)-1;k.set(t,e),e===0&&He(t)});function Tt(t,e){const r=(k.get(e)||0)+1;k.set(e,r),O&&O.register(t,e,t)}function xt(t){O&&O.unregister(t)}function W(t,e=[],r=function(){}){let s=!1;const n=new Proxy(r,{get(i,o){if(x(s),o===St)return()=>{xt(n),He(t),s=!0};if(o==="then"){if(e.length===0)return{then:()=>n};const a=$(t,{type:"GET",path:e.map(l=>l.toString())}).then(P);return a.then.bind(a)}return W(t,[...e,o])},set(i,o,a){x(s);const[l,c]=U(a);return $(t,{type:"SET",path:[...e,o].map(u=>u.toString()),value:l},c).then(P)},apply(i,o,a){x(s);const l=e[e.length-1];if(l===_t)return $(t,{type:"ENDPOINT"}).then(P);if(l==="bind")return W(t,e.slice(0,-1));const[c,u]=Z(a);return $(t,{type:"APPLY",path:e.map(d=>d.toString()),argumentList:c},u).then(P)},construct(i,o){x(s);const[a,l]=Z(o);return $(t,{type:"CONSTRUCT",path:e.map(c=>c.toString()),argumentList:a},l).then(P)}});return Tt(n,t),n}function Ft(t){return Array.prototype.concat.apply([],t)}function Z(t){const e=t.map(U);return[e.map(r=>r[0]),Ft(e.map(r=>r[1]))]}const Ie=new WeakMap;function Ct(t,e){return Ie.set(t,e),t}function kt(t){return Object.assign(t,{[Ue]:!0})}function Ot(t,e=globalThis,r="*"){return{postMessage:(s,n)=>t.postMessage(s,r,n),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function U(t){for(const[e,r]of R)if(r.canHandle(t)){const[s,n]=r.serialize(t);return[{type:"HANDLER",name:e,value:s},n]}return[{type:"RAW",value:t},Ie.get(t)||[]]}function P(t){switch(t.type){case"HANDLER":return R.get(t.name).deserialize(t.value);case"RAW":return t.value}}function $(t,e,r){return new Promise(s=>{const n=Ut();t.addEventListener("message",function i(o){!o.data||!o.data.id||o.data.id!==n||(t.removeEventListener("message",i),s(o.data))}),t.start&&t.start(),t.postMessage(Object.assign({id:n},e),r)})}function Ut(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function ze(t){Lt();const e=t instanceof Worker?t:Ot(t);return j(e)}function Lt(){R.set("EVENT",{canHandle:t=>t instanceof CustomEvent,serialize:t=>[{detail:t.detail},[]],deserialize:t=>t}),R.set("FUNCTION",{canHandle:t=>typeof t=="function",serialize(t){console.debug("[Comlink][Performance] Proxying a function");const{port1:e,port2:r}=new MessageChannel;return M(t,e),[r,[r]]},deserialize(t){return t.start(),j(t)}}),R.set("PHPResponse",{canHandle:t=>typeof t=="object"&&t!==null&&"headers"in t&&"bytes"in t&&"errors"in t&&"exitCode"in t&&"httpStatusCode"in t,serialize(t){return[t.toRawData(),[]]},deserialize(t){return v.fromRawData(t)}})}(function(){return typeof navigator<"u"&&navigator?.userAgent?.toLowerCase().indexOf("firefox")>-1?"iframe":"webworker"})();async function Ne({iframe:t,blueprint:e,remoteUrl:r,progressTracker:s=new H,disableProgressBar:n,onBlueprintStepCompleted:i}){if(At(r),r=te(r,{progressbar:!n}),s.setCaption("Preparing WordPress"),!e)return ee(t,r,s);const o=ke(e,{progress:s.stage(.5),onStepCompleted:i}),a=await ee(t,te(r,{php:o.versions.php,wp:o.versions.wp}),s);return await Oe(o,a),a}async function ee(t,e,r){await new Promise(n=>{t.src=e,t.addEventListener("load",n,!1)});const s=ze(t.contentWindow);return await s.
|
|
103
|
+
*/const Ue=Symbol("Comlink.proxy"),_t=Symbol("Comlink.endpoint"),St=Symbol("Comlink.releaseProxy"),N=Symbol("Comlink.finalizer"),F=Symbol("Comlink.thrown"),Le=t=>typeof t=="object"&&t!==null||typeof t=="function",$t={canHandle:t=>Le(t)&&t[Ue],serialize(t){const{port1:e,port2:r}=new MessageChannel;return M(t,e),[r,[r]]},deserialize(t){return t.start(),j(t)}},vt={canHandle:t=>Le(t)&&F in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},R=new Map([["proxy",$t],["throw",vt]]);function Et(t,e){for(const r of t)if(e===r||r==="*"||r instanceof RegExp&&r.test(e))return!0;return!1}function M(t,e=globalThis,r=["*"]){e.addEventListener("message",function s(n){if(!n||!n.data)return;if(!Et(r,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},n.data),l=(n.data.argumentList||[]).map(P);let c;try{const u=a.slice(0,-1).reduce((p,y)=>p[y],t),d=a.reduce((p,y)=>p[y],t);switch(o){case"GET":c=d;break;case"SET":u[a.slice(-1)[0]]=P(n.data.value),c=!0;break;case"APPLY":c=d.apply(u,l);break;case"CONSTRUCT":{const p=new d(...l);c=kt(p)}break;case"ENDPOINT":{const{port1:p,port2:y}=new MessageChannel;M(t,y),c=Ct(p,[p])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[F]:0}}Promise.resolve(c).catch(u=>({value:u,[F]:0})).then(u=>{const[d,p]=U(u);e.postMessage(Object.assign(Object.assign({},d),{id:i}),p),o==="RELEASE"&&(e.removeEventListener("message",s),Ae(e),N in t&&typeof t[N]=="function"&&t[N]())}).catch(u=>{const[d,p]=U({value:new TypeError("Unserializable return value"),[F]:0});e.postMessage(Object.assign(Object.assign({},d),{id:i}),p)})}),e.start&&e.start()}function Rt(t){return t.constructor.name==="MessagePort"}function Ae(t){Rt(t)&&t.close()}function j(t,e){return W(t,[],e)}function x(t){if(t)throw new Error("Proxy has been released and is not useable")}function He(t){return $(t,{type:"RELEASE"}).then(()=>{Ae(t)})}const k=new WeakMap,O="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(k.get(t)||0)-1;k.set(t,e),e===0&&He(t)});function Tt(t,e){const r=(k.get(e)||0)+1;k.set(e,r),O&&O.register(t,e,t)}function xt(t){O&&O.unregister(t)}function W(t,e=[],r=function(){}){let s=!1;const n=new Proxy(r,{get(i,o){if(x(s),o===St)return()=>{xt(n),He(t),s=!0};if(o==="then"){if(e.length===0)return{then:()=>n};const a=$(t,{type:"GET",path:e.map(l=>l.toString())}).then(P);return a.then.bind(a)}return W(t,[...e,o])},set(i,o,a){x(s);const[l,c]=U(a);return $(t,{type:"SET",path:[...e,o].map(u=>u.toString()),value:l},c).then(P)},apply(i,o,a){x(s);const l=e[e.length-1];if(l===_t)return $(t,{type:"ENDPOINT"}).then(P);if(l==="bind")return W(t,e.slice(0,-1));const[c,u]=Z(a);return $(t,{type:"APPLY",path:e.map(d=>d.toString()),argumentList:c},u).then(P)},construct(i,o){x(s);const[a,l]=Z(o);return $(t,{type:"CONSTRUCT",path:e.map(c=>c.toString()),argumentList:a},l).then(P)}});return Tt(n,t),n}function Ft(t){return Array.prototype.concat.apply([],t)}function Z(t){const e=t.map(U);return[e.map(r=>r[0]),Ft(e.map(r=>r[1]))]}const Ie=new WeakMap;function Ct(t,e){return Ie.set(t,e),t}function kt(t){return Object.assign(t,{[Ue]:!0})}function Ot(t,e=globalThis,r="*"){return{postMessage:(s,n)=>t.postMessage(s,r,n),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function U(t){for(const[e,r]of R)if(r.canHandle(t)){const[s,n]=r.serialize(t);return[{type:"HANDLER",name:e,value:s},n]}return[{type:"RAW",value:t},Ie.get(t)||[]]}function P(t){switch(t.type){case"HANDLER":return R.get(t.name).deserialize(t.value);case"RAW":return t.value}}function $(t,e,r){return new Promise(s=>{const n=Ut();t.addEventListener("message",function i(o){!o.data||!o.data.id||o.data.id!==n||(t.removeEventListener("message",i),s(o.data))}),t.start&&t.start(),t.postMessage(Object.assign({id:n},e),r)})}function Ut(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function ze(t){Lt();const e=t instanceof Worker?t:Ot(t);return j(e)}function Lt(){R.set("EVENT",{canHandle:t=>t instanceof CustomEvent,serialize:t=>[{detail:t.detail},[]],deserialize:t=>t}),R.set("FUNCTION",{canHandle:t=>typeof t=="function",serialize(t){console.debug("[Comlink][Performance] Proxying a function");const{port1:e,port2:r}=new MessageChannel;return M(t,e),[r,[r]]},deserialize(t){return t.start(),j(t)}}),R.set("PHPResponse",{canHandle:t=>typeof t=="object"&&t!==null&&"headers"in t&&"bytes"in t&&"errors"in t&&"exitCode"in t&&"httpStatusCode"in t,serialize(t){return[t.toRawData(),[]]},deserialize(t){return v.fromRawData(t)}})}(function(){return typeof navigator<"u"&&navigator?.userAgent?.toLowerCase().indexOf("firefox")>-1?"iframe":"webworker"})();async function Ne({iframe:t,blueprint:e,remoteUrl:r,progressTracker:s=new H,disableProgressBar:n,onBlueprintStepCompleted:i}){if(At(r),r=te(r,{progressbar:!n}),s.setCaption("Preparing WordPress"),!e)return ee(t,r,s);const o=ke(e,{progress:s.stage(.5),onStepCompleted:i}),a=await ee(t,te(r,{php:o.versions.php,wp:o.versions.wp}),s);return await Oe(o,a),a}async function ee(t,e,r){await new Promise(n=>{t.src=e,t.addEventListener("load",n,!1)});const s=ze(t.contentWindow);return await s.isConnected(),r.pipe(s),await s.onDownloadProgress(r.stage().loadingListener),await s.isReady(),s}const C="https://playground.wordpress.net";function At(t){const e=new URL(t,C);if((e.origin===C||e.hostname==="localhost")&&e.pathname!=="/remote.html")throw new Error(`Invalid remote URL: ${e}. Expected origin to be ${C}/remote.html.`)}function te(t,e){const r=new URL(t,C),s=new URLSearchParams(r.search);for(const[n,i]of Object.entries(e))i!=null&&i!==!1&&s.set(n,i.toString());return r.search=s.toString(),r.toString()}async function Ht(t,e){if(console.warn("`connectPlayground` is deprecated and will be removed. Use `startPlayground` instead."),e?.loadRemote)return Ne({iframe:t,remoteUrl:e.loadRemote});const r=ze(t.contentWindow);return await r.isConnected(),r}exports.LatestSupportedPHPVersion=Te;exports.SupportedPHPVersions=I;exports.SupportedPHPVersionsList=Ye;exports.activatePlugin=re;exports.applyWordPressPatches=se;exports.compileBlueprint=ke;exports.connectPlayground=Ht;exports.cp=ce;exports.defineSiteUrl=fe;exports.importFile=ye;exports.installPlugin=be;exports.installTheme=_e;exports.login=Se;exports.mkdir=ue;exports.mv=le;exports.phpVar=b;exports.phpVars=A;exports.replaceSite=ge;exports.request=ae;exports.rm=he;exports.rmdir=de;exports.runBlueprintSteps=Oe;exports.runPHP=ne;exports.runPHPWithOptions=ie;exports.runWpInstallationWizard=$e;exports.setPhpIniEntry=oe;exports.setSiteOptions=ve;exports.startPlaygroundWeb=Ne;exports.unzip=q;exports.updateUserMeta=Ee;exports.writeFile=pe;exports.zipEntireSite=we;
|
package/index.d.ts
CHANGED
|
@@ -1205,11 +1205,19 @@ export interface CompileBlueprintOptions {
|
|
|
1205
1205
|
*/
|
|
1206
1206
|
export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, }?: CompileBlueprintOptions): CompiledBlueprint;
|
|
1207
1207
|
export declare function runBlueprintSteps(compiledBlueprint: CompiledBlueprint, playground: UniversalPHP): Promise<void>;
|
|
1208
|
-
export type
|
|
1209
|
-
/**
|
|
1208
|
+
export type WithAPIState = {
|
|
1209
|
+
/**
|
|
1210
|
+
* Resolves to true when the remote API is ready for
|
|
1211
|
+
* Comlink communication, but not necessarily fully initialized yet.
|
|
1212
|
+
*/
|
|
1213
|
+
isConnected: () => Promise<void>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Resolves to true when the remote API is declares it's
|
|
1216
|
+
* fully loaded and ready to be used.
|
|
1217
|
+
*/
|
|
1210
1218
|
isReady: () => Promise<void>;
|
|
1211
1219
|
};
|
|
1212
|
-
export type RemoteAPI<T> = Comlink.Remote<T &
|
|
1220
|
+
export type RemoteAPI<T> = Comlink.Remote<T & WithAPIState>;
|
|
1213
1221
|
export interface PHPWebLoaderOptions {
|
|
1214
1222
|
emscriptenOptions?: EmscriptenOptions;
|
|
1215
1223
|
downloadMonitor?: EmscriptenDownloadMonitor;
|
|
@@ -1244,11 +1252,6 @@ declare class WebPHP extends BasePHP {
|
|
|
1244
1252
|
};
|
|
1245
1253
|
}
|
|
1246
1254
|
declare class WebPHPEndpoint implements IsomorphicLocalPHP {
|
|
1247
|
-
/**
|
|
1248
|
-
* A dummy promise that resolves immediately.
|
|
1249
|
-
* Used to assert that the PHPClient is ready for communication.
|
|
1250
|
-
*/
|
|
1251
|
-
connected: Promise<void>;
|
|
1252
1255
|
/** @inheritDoc */
|
|
1253
1256
|
absoluteUrl: string;
|
|
1254
1257
|
/** @inheritDoc */
|
package/index.js
CHANGED
|
@@ -97,9 +97,9 @@ const be = async (t, { code: e }) => await t.run({ code: e }), _e = async (t, {
|
|
|
97
97
|
await t.unlink(e);
|
|
98
98
|
}, xe = async (t, { path: e }) => {
|
|
99
99
|
await t.rmdir(e);
|
|
100
|
-
},
|
|
100
|
+
}, Ce = async (t, { path: e, data: r }) => {
|
|
101
101
|
r instanceof File && (r = await we(r)), await t.writeFile(e, r);
|
|
102
|
-
},
|
|
102
|
+
}, Fe = async (t, { siteUrl: e }) => {
|
|
103
103
|
await E(
|
|
104
104
|
t,
|
|
105
105
|
"/wordpress/wp-config.php",
|
|
@@ -475,7 +475,7 @@ const Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
475
475
|
activatePlugin: ge,
|
|
476
476
|
applyWordPressPatches: ye,
|
|
477
477
|
cp: ve,
|
|
478
|
-
defineSiteUrl:
|
|
478
|
+
defineSiteUrl: Fe,
|
|
479
479
|
importFile: Ae,
|
|
480
480
|
installPlugin: Ie,
|
|
481
481
|
installTheme: Ne,
|
|
@@ -493,7 +493,7 @@ const Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
493
493
|
setSiteOptions: qe,
|
|
494
494
|
unzip: re,
|
|
495
495
|
updateUserMeta: We,
|
|
496
|
-
writeFile:
|
|
496
|
+
writeFile: Ce,
|
|
497
497
|
zipEntireSite: Oe
|
|
498
498
|
}, Symbol.toStringTag, { value: "Module" })), je = 5 * 1024 * 1024;
|
|
499
499
|
function Be(t, e) {
|
|
@@ -1842,7 +1842,7 @@ async function yt(t, e) {
|
|
|
1842
1842
|
* Copyright 2019 Google LLC
|
|
1843
1843
|
* SPDX-License-Identifier: Apache-2.0
|
|
1844
1844
|
*/
|
|
1845
|
-
const ce = Symbol("Comlink.proxy"), Pt = Symbol("Comlink.endpoint"), bt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"),
|
|
1845
|
+
const ce = Symbol("Comlink.proxy"), Pt = Symbol("Comlink.endpoint"), bt = Symbol("Comlink.releaseProxy"), I = Symbol("Comlink.finalizer"), C = Symbol("Comlink.thrown"), le = (t) => typeof t == "object" && t !== null || typeof t == "function", _t = {
|
|
1846
1846
|
canHandle: (t) => le(t) && t[ce],
|
|
1847
1847
|
serialize(t) {
|
|
1848
1848
|
const { port1: e, port2: r } = new MessageChannel();
|
|
@@ -1852,7 +1852,7 @@ const ce = Symbol("Comlink.proxy"), Pt = Symbol("Comlink.endpoint"), bt = Symbol
|
|
|
1852
1852
|
return t.start(), M(t);
|
|
1853
1853
|
}
|
|
1854
1854
|
}, $t = {
|
|
1855
|
-
canHandle: (t) => le(t) &&
|
|
1855
|
+
canHandle: (t) => le(t) && C in t,
|
|
1856
1856
|
serialize({ value: t }) {
|
|
1857
1857
|
let e;
|
|
1858
1858
|
return t instanceof Error ? e = {
|
|
@@ -1902,7 +1902,7 @@ function W(t, e = globalThis, r = ["*"]) {
|
|
|
1902
1902
|
case "CONSTRUCT":
|
|
1903
1903
|
{
|
|
1904
1904
|
const p = new d(...l);
|
|
1905
|
-
c =
|
|
1905
|
+
c = Ct(p);
|
|
1906
1906
|
}
|
|
1907
1907
|
break;
|
|
1908
1908
|
case "ENDPOINT":
|
|
@@ -1918,15 +1918,15 @@ function W(t, e = globalThis, r = ["*"]) {
|
|
|
1918
1918
|
return;
|
|
1919
1919
|
}
|
|
1920
1920
|
} catch (u) {
|
|
1921
|
-
c = { value: u, [
|
|
1921
|
+
c = { value: u, [C]: 0 };
|
|
1922
1922
|
}
|
|
1923
|
-
Promise.resolve(c).catch((u) => ({ value: u, [
|
|
1923
|
+
Promise.resolve(c).catch((u) => ({ value: u, [C]: 0 })).then((u) => {
|
|
1924
1924
|
const [d, p] = U(u);
|
|
1925
1925
|
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p), o === "RELEASE" && (e.removeEventListener("message", s), ue(e), I in t && typeof t[I] == "function" && t[I]());
|
|
1926
1926
|
}).catch((u) => {
|
|
1927
1927
|
const [d, p] = U({
|
|
1928
1928
|
value: new TypeError("Unserializable return value"),
|
|
1929
|
-
[
|
|
1929
|
+
[C]: 0
|
|
1930
1930
|
});
|
|
1931
1931
|
e.postMessage(Object.assign(Object.assign({}, d), { id: i }), p);
|
|
1932
1932
|
});
|
|
@@ -2031,10 +2031,10 @@ const de = /* @__PURE__ */ new WeakMap();
|
|
|
2031
2031
|
function xt(t, e) {
|
|
2032
2032
|
return de.set(t, e), t;
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function Ct(t) {
|
|
2035
2035
|
return Object.assign(t, { [ce]: !0 });
|
|
2036
2036
|
}
|
|
2037
|
-
function
|
|
2037
|
+
function Ft(t, e = globalThis, r = "*") {
|
|
2038
2038
|
return {
|
|
2039
2039
|
postMessage: (s, n) => t.postMessage(s, r, n),
|
|
2040
2040
|
addEventListener: e.addEventListener.bind(e),
|
|
@@ -2083,7 +2083,7 @@ function kt() {
|
|
|
2083
2083
|
}
|
|
2084
2084
|
function pe(t) {
|
|
2085
2085
|
Ot();
|
|
2086
|
-
const e = t instanceof Worker ? t :
|
|
2086
|
+
const e = t instanceof Worker ? t : Ft(t);
|
|
2087
2087
|
return M(e);
|
|
2088
2088
|
}
|
|
2089
2089
|
function Ot() {
|
|
@@ -2151,20 +2151,20 @@ async function Z(t, e, r) {
|
|
|
2151
2151
|
const s = pe(
|
|
2152
2152
|
t.contentWindow
|
|
2153
2153
|
);
|
|
2154
|
-
return await s.
|
|
2154
|
+
return await s.isConnected(), r.pipe(s), await s.onDownloadProgress(
|
|
2155
2155
|
r.stage().loadingListener
|
|
2156
2156
|
), await s.isReady(), s;
|
|
2157
2157
|
}
|
|
2158
|
-
const
|
|
2158
|
+
const F = "https://playground.wordpress.net";
|
|
2159
2159
|
function At(t) {
|
|
2160
|
-
const e = new URL(t,
|
|
2161
|
-
if ((e.origin ===
|
|
2160
|
+
const e = new URL(t, F);
|
|
2161
|
+
if ((e.origin === F || e.hostname === "localhost") && e.pathname !== "/remote.html")
|
|
2162
2162
|
throw new Error(
|
|
2163
|
-
`Invalid remote URL: ${e}. Expected origin to be ${
|
|
2163
|
+
`Invalid remote URL: ${e}. Expected origin to be ${F}/remote.html.`
|
|
2164
2164
|
);
|
|
2165
2165
|
}
|
|
2166
2166
|
function ee(t, e) {
|
|
2167
|
-
const r = new URL(t,
|
|
2167
|
+
const r = new URL(t, F), s = new URLSearchParams(r.search);
|
|
2168
2168
|
for (const [n, i] of Object.entries(e))
|
|
2169
2169
|
i != null && i !== !1 && s.set(n, i.toString());
|
|
2170
2170
|
return r.search = s.toString(), r.toString();
|
|
@@ -2180,7 +2180,7 @@ async function Ht(t, e) {
|
|
|
2180
2180
|
const r = pe(
|
|
2181
2181
|
t.contentWindow
|
|
2182
2182
|
);
|
|
2183
|
-
return await r.
|
|
2183
|
+
return await r.isConnected(), r;
|
|
2184
2184
|
}
|
|
2185
2185
|
export {
|
|
2186
2186
|
Ve as LatestSupportedPHPVersion,
|
|
@@ -2191,7 +2191,7 @@ export {
|
|
|
2191
2191
|
ft as compileBlueprint,
|
|
2192
2192
|
Ht as connectPlayground,
|
|
2193
2193
|
ve as cp,
|
|
2194
|
-
|
|
2194
|
+
Fe as defineSiteUrl,
|
|
2195
2195
|
Ae as importFile,
|
|
2196
2196
|
Ie as installPlugin,
|
|
2197
2197
|
Ne as installTheme,
|
|
@@ -2213,6 +2213,6 @@ export {
|
|
|
2213
2213
|
Ut as startPlaygroundWeb,
|
|
2214
2214
|
re as unzip,
|
|
2215
2215
|
We as updateUserMeta,
|
|
2216
|
-
|
|
2216
|
+
Ce as writeFile,
|
|
2217
2217
|
Oe as zipEntireSite
|
|
2218
2218
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "WordPress Playground client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"main": "./index.cjs",
|
|
38
38
|
"module": "./index.js",
|
|
39
39
|
"types": "index.d.ts",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "8c0a6a74f00bbf4bead78d49845dcdd79b02edd6"
|
|
41
41
|
}
|