@wp-playground/client 0.9.41 → 0.9.44
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.js +1 -1
- package/package.json +8 -8
package/index.cjs
CHANGED
|
@@ -702,7 +702,7 @@ function join_paths()
|
|
|
702
702
|
wp_get_themes()
|
|
703
703
|
)
|
|
704
704
|
)
|
|
705
|
-
);`})).json;for(const{slug:k,version:m}of b)i.push({url:`https://downloads.wordpress.org/translation/theme/${k}/${m}/${t}.zip`,type:"theme"});await r.isDir(`${p}/wp-content/languages/plugins`)||await r.mkdir(`${p}/wp-content/languages/plugins`),await r.isDir(`${p}/wp-content/languages/themes`)||await r.mkdir(`${p}/wp-content/languages/themes`);for(const{url:k,type:m}of i)try{const w=await fetch(k);if(!w.ok)throw new Error(`Failed to download translations for ${m}: ${w.statusText}`);let S=`${p}/wp-content/languages`;m==="plugin"?S+="/plugins":m==="theme"&&(S+="/themes"),await yt(r,new File([await w.blob()],`${t}-${m}.zip`),S)}catch(w){if(m==="core")throw new Error(`Failed to download translations for WordPress. Please check if the language code ${t} is correct. You can find all available languages and translations on https://translate.wordpress.org/.`);ae.warn(`Error downloading translations for ${m}: ${w}`)}},cs=Object.freeze(Object.defineProperty({__proto__:null,activatePlugin:dr,activateTheme:qr,cp:ft,defineSiteUrl:xr,defineWpConfigConsts:Ie,enableMultisite:lt,exportWXR:gt,importThemeStarterContent:Nr,importWordPressFiles:ht,importWxr:mt,installPlugin:wt,installTheme:vt,login:or,mkdir:dt,mv:ut,request:nr,resetData:Pt,rm:Rr,rmdir:ct,runPHP:it,runPHPWithOptions:nt,runSql:ot,runWpInstallationWizard:_t,setSiteLanguage:Et,setSiteOptions:Lr,unzip:cr,updateUserMeta:at,wpCLI:Ot,writeFile:Sr,zipWpContent:kt},Symbol.toStringTag,{value:"Module"})),ms=5*1024*1024;function ys(r,t){const n=r.headers.get("content-length")||"",p=parseInt(n,10)||ms;function l(i,e){t(new CustomEvent("progress",{detail:{loaded:i,total:e}}))}return new Response(new ReadableStream({async start(i){if(!r.body){i.close();return}const e=r.body.getReader();let f=0;for(;;)try{const{done:h,value:b}=await e.read();if(b&&(f+=b.byteLength),h){l(f,f),i.close();break}else l(f,p),i.enqueue(b)}catch(h){ae.error({e:h}),i.error(h);break}}}),{status:r.status,statusText:r.statusText,headers:r.headers})}const Pr=1e-5;class yr extends EventTarget{constructor({weight:t=1,caption:n="",fillTime:p=4}={}){super(),this._selfWeight=1,this._selfDone=!1,this._selfProgress=0,this._selfCaption="",this._isFilling=!1,this._subTrackers=[],this._weight=t,this._selfCaption=n,this._fillTime=p}stage(t,n=""){if(t||(t=this._selfWeight),this._selfWeight-t<-Pr)throw new Error(`Cannot add a stage with weight ${t} as the total weight of registered stages would exceed 1.`);this._selfWeight-=t;const p=new yr({caption:n,weight:t,fillTime:this._fillTime});return this._subTrackers.push(p),p.addEventListener("progress",()=>this.notifyProgress()),p.addEventListener("done",()=>{this.done&&this.notifyDone()}),p}fillSlowly({stopBeforeFinishing:t=!0}={}){if(this._isFilling)return;this._isFilling=!0;const n=100,p=this._fillTime/n;this._fillInterval=setInterval(()=>{this.set(this._selfProgress+1),t&&this._selfProgress>=99&&clearInterval(this._fillInterval)},p)}set(t){this._selfProgress=Math.min(t,100),this.notifyProgress(),this._selfProgress+Pr>=100&&this.finish()}finish(){this._fillInterval&&clearInterval(this._fillInterval),this._selfDone=!0,this._selfProgress=100,this._isFilling=!1,this._fillInterval=void 0,this.notifyProgress(),this.notifyDone()}get caption(){for(let t=this._subTrackers.length-1;t>=0;t--)if(!this._subTrackers[t].done){const n=this._subTrackers[t].caption;if(n)return n}return this._selfCaption}setCaption(t){this._selfCaption=t,this.notifyProgress()}get done(){return this.progress+Pr>=100}get progress(){if(this._selfDone)return 100;const t=this._subTrackers.reduce((n,p)=>n+p.progress*p.weight,this._selfProgress*this._selfWeight);return Math.round(t*1e4)/1e4}get weight(){return this._weight}get observer(){return this._progressObserver||(this._progressObserver=t=>{this.set(t)}),this._progressObserver}get loadingListener(){return this._loadingListener||(this._loadingListener=t=>{this.set(t.detail.loaded/t.detail.total*100)}),this._loadingListener}pipe(t){t.setProgress({progress:this.progress,caption:this.caption}),this.addEventListener("progress",n=>{t.setProgress({progress:n.detail.progress,caption:n.detail.caption})}),this.addEventListener("done",()=>{t.setLoaded()})}addEventListener(t,n){super.addEventListener(t,n)}removeEventListener(t,n){super.removeEventListener(t,n)}notifyProgress(){const t=this;this.dispatchEvent(new CustomEvent("progress",{detail:{get progress(){return t.progress},get caption(){return t.caption}}}))}notifyDone(){this.dispatchEvent(new CustomEvent("done"))}}const ar={0:"No error occurred. System call completed successfully.",1:"Argument list too long.",2:"Permission denied.",3:"Address in use.",4:"Address not available.",5:"Address family not supported.",6:"Resource unavailable, or operation would block.",7:"Connection already in progress.",8:"Bad file descriptor.",9:"Bad message.",10:"Device or resource busy.",11:"Operation canceled.",12:"No child processes.",13:"Connection aborted.",14:"Connection refused.",15:"Connection reset.",16:"Resource deadlock would occur.",17:"Destination address required.",18:"Mathematics argument out of domain of function.",19:"Reserved.",20:"File exists.",21:"Bad address.",22:"File too large.",23:"Host is unreachable.",24:"Identifier removed.",25:"Illegal byte sequence.",26:"Operation in progress.",27:"Interrupted function.",28:"Invalid argument.",29:"I/O error.",30:"Socket is connected.",31:"There is a directory under that path.",32:"Too many levels of symbolic links.",33:"File descriptor value too large.",34:"Too many links.",35:"Message too large.",36:"Reserved.",37:"Filename too long.",38:"Network is down.",39:"Connection aborted by network.",40:"Network unreachable.",41:"Too many files open in system.",42:"No buffer space available.",43:"No such device.",44:"There is no such file or directory OR the parent directory does not exist.",45:"Executable file format error.",46:"No locks available.",47:"Reserved.",48:"Not enough space.",49:"No message of the desired type.",50:"Protocol not available.",51:"No space left on device.",52:"Function not supported.",53:"The socket is not connected.",54:"Not a directory or a symbolic link to a directory.",55:"Directory not empty.",56:"State not recoverable.",57:"Not a socket.",58:"Not supported, or operation not supported on socket.",59:"Inappropriate I/O control operation.",60:"No such device or address.",61:"Value too large to be stored in data type.",62:"Previous owner died.",63:"Operation not permitted.",64:"Broken pipe.",65:"Protocol error.",66:"Protocol not supported.",67:"Protocol wrong type for socket.",68:"Result too large.",69:"Read-only file system.",70:"Invalid seek.",71:"No such process.",72:"Reserved.",73:"Connection timed out.",74:"Text file busy.",75:"Cross-device link.",76:"Extension: Capabilities insufficient."};function hs(r){const t=typeof r=="object"?r==null?void 0:r.errno:null;if(t in ar)return ar[t]}function ge(r=""){return function(n,p,l){const i=l.value;l.value=function(...e){try{return i.apply(this,e)}catch(f){const h=typeof f=="object"?f==null?void 0:f.errno:null;if(h in ar){const b=ar[h],k=typeof e[1]=="string"?e[1]:null,m=k!==null?r.replaceAll("{path}",k):r;throw new Error(`${m}: ${b}`,{cause:f})}throw f}}}}var gs=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,be=(r,t,n,p)=>{for(var l=p>1?void 0:p?bs(t,n):t,i=r.length-1,e;i>=0;i--)(e=r[i])&&(l=(p?e(t,n,l):e(l))||l);return p&&l&&gs(t,n,l),l};const we=class pe{static readFileAsText(t,n){return new TextDecoder().decode(pe.readFileAsBuffer(t,n))}static readFileAsBuffer(t,n){return t.readFile(n)}static writeFile(t,n,p){t.writeFile(n,p)}static unlink(t,n){t.unlink(n)}static mv(t,n,p){try{const l=t.lookupPath(n).node.mount,i=pe.fileExists(t,p)?t.lookupPath(p).node.mount:t.lookupPath(et(p)).node.mount;l.mountpoint!==i.mountpoint?(pe.copyRecursive(t,n,p),pe.rmdir(t,n,{recursive:!0})):t.rename(n,p)}catch(l){const i=hs(l);throw i?new Error(`Could not move ${n} to ${p}: ${i}`,{cause:l}):l}}static rmdir(t,n,p={recursive:!0}){p!=null&&p.recursive&&pe.listFiles(t,n).forEach(l=>{const i=`${n}/${l}`;pe.isDir(t,i)?pe.rmdir(t,i,p):pe.unlink(t,i)}),t.rmdir(n)}static listFiles(t,n,p={prependPath:!1}){if(!pe.fileExists(t,n))return[];try{const l=t.readdir(n).filter(i=>i!=="."&&i!=="..");if(p.prependPath){const i=n.replace(/\/$/,"");return l.map(e=>`${i}/${e}`)}return l}catch(l){return ae.error(l,{path:n}),[]}}static isDir(t,n){return pe.fileExists(t,n)?t.isDir(t.lookupPath(n,{follow:!0}).node.mode):!1}static isFile(t,n){return pe.fileExists(t,n)?t.isFile(t.lookupPath(n,{follow:!0}).node.mode):!1}static symlink(t,n,p){return t.symlink(n,p)}static isSymlink(t,n){return pe.fileExists(t,n)?t.isLink(t.lookupPath(n).node.mode):!1}static readlink(t,n){return t.readlink(n)}static realpath(t,n){return t.lookupPath(n,{follow:!0}).path}static fileExists(t,n){try{return t.lookupPath(n),!0}catch{return!1}}static mkdir(t,n){t.mkdirTree(n)}static copyRecursive(t,n,p){const l=t.lookupPath(n).node;if(t.isDir(l.mode)){t.mkdirTree(p);const i=t.readdir(n).filter(e=>e!=="."&&e!=="..");for(const e of i)pe.copyRecursive(t,ie(n,e),ie(p,e))}else t.writeFile(p,t.readFile(n))}};be([ge('Could not read "{path}"')],we,"readFileAsText",1);be([ge('Could not read "{path}"')],we,"readFileAsBuffer",1);be([ge('Could not write to "{path}"')],we,"writeFile",1);be([ge('Could not unlink "{path}"')],we,"unlink",1);be([ge('Could not remove directory "{path}"')],we,"rmdir",1);be([ge('Could not list files in "{path}"')],we,"listFiles",1);be([ge('Could not stat "{path}"')],we,"isDir",1);be([ge('Could not stat "{path}"')],we,"isFile",1);be([ge('Could not stat "{path}"')],we,"realpath",1);be([ge('Could not stat "{path}"')],we,"fileExists",1);be([ge('Could not create directory "{path}"')],we,"mkdir",1);be([ge('Could not copy files from "{path}"')],we,"copyRecursive",1);const ws={500:"Internal Server Error",502:"Bad Gateway",404:"Not Found",403:"Forbidden",401:"Unauthorized",400:"Bad Request",301:"Moved Permanently",302:"Found",307:"Temporary Redirect",308:"Permanent Redirect",204:"No Content",201:"Created",200:"OK"};class pr{constructor(t,n,p,l="",i=0){this.httpStatusCode=t,this.headers=n,this.bytes=p,this.exitCode=i,this.errors=l}static forHttpCode(t,n=""){return new pr(t,{},new TextEncoder().encode(n||ws[t]||""))}static fromRawData(t){return new pr(t.httpStatusCode,t.headers,t.bytes,t.errors,t.exitCode)}toRawData(){return{headers:this.headers,bytes:this.bytes,errors:this.errors,exitCode:this.exitCode,httpStatusCode:this.httpStatusCode}}get json(){return JSON.parse(this.text)}get text(){return new TextDecoder().decode(this.bytes)}}(function(){var r;return typeof process<"u"&&((r=process.release)==null?void 0:r.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"})();const zr="/internal/shared/php.ini",{hasOwnProperty:_r}=Object.prototype,Tr=(r,t={})=>{typeof t=="string"&&(t={section:t}),t.align=t.align===!0,t.newline=t.newline===!0,t.sort=t.sort===!0,t.whitespace=t.whitespace===!0||t.align===!0,t.platform=t.platform||typeof process<"u"&&process.platform,t.bracketedArray=t.bracketedArray!==!1;const n=t.platform==="win32"?`\r
|
|
705
|
+
);`})).json;for(const{slug:k,version:m}of b)i.push({url:`https://downloads.wordpress.org/translation/theme/${k}/${m}/${t}.zip`,type:"theme"});await r.isDir(`${p}/wp-content/languages/plugins`)||await r.mkdir(`${p}/wp-content/languages/plugins`),await r.isDir(`${p}/wp-content/languages/themes`)||await r.mkdir(`${p}/wp-content/languages/themes`);for(const{url:k,type:m}of i)try{const w=await fetch(k);if(!w.ok)throw new Error(`Failed to download translations for ${m}: ${w.statusText}`);let S=`${p}/wp-content/languages`;m==="plugin"?S+="/plugins":m==="theme"&&(S+="/themes"),await yt(r,new File([await w.blob()],`${t}-${m}.zip`),S)}catch(w){if(m==="core")throw new Error(`Failed to download translations for WordPress. Please check if the language code ${t} is correct. You can find all available languages and translations on https://translate.wordpress.org/.`);ae.warn(`Error downloading translations for ${m}: ${w}`)}},cs=Object.freeze(Object.defineProperty({__proto__:null,activatePlugin:dr,activateTheme:qr,cp:ft,defineSiteUrl:xr,defineWpConfigConsts:Ie,enableMultisite:lt,exportWXR:gt,importThemeStarterContent:Nr,importWordPressFiles:ht,importWxr:mt,installPlugin:wt,installTheme:vt,login:or,mkdir:dt,mv:ut,request:nr,resetData:Pt,rm:Rr,rmdir:ct,runPHP:it,runPHPWithOptions:nt,runSql:ot,runWpInstallationWizard:_t,setSiteLanguage:Et,setSiteOptions:Lr,unzip:cr,updateUserMeta:at,wpCLI:Ot,writeFile:Sr,zipWpContent:kt},Symbol.toStringTag,{value:"Module"})),ms=5*1024*1024;function ys(r,t){const n=r.headers.get("content-length")||"",p=parseInt(n,10)||ms;function l(i,e){t(new CustomEvent("progress",{detail:{loaded:i,total:e}}))}return new Response(new ReadableStream({async start(i){if(!r.body){i.close();return}const e=r.body.getReader();let f=0;for(;;)try{const{done:h,value:b}=await e.read();if(b&&(f+=b.byteLength),h){l(f,f),i.close();break}else l(f,p),i.enqueue(b)}catch(h){ae.error({e:h}),i.error(h);break}}}),{status:r.status,statusText:r.statusText,headers:r.headers})}const Pr=1e-5;class yr extends EventTarget{constructor({weight:t=1,caption:n="",fillTime:p=4}={}){super(),this._selfWeight=1,this._selfDone=!1,this._selfProgress=0,this._selfCaption="",this._isFilling=!1,this._subTrackers=[],this._weight=t,this._selfCaption=n,this._fillTime=p}stage(t,n=""){if(t||(t=this._selfWeight),this._selfWeight-t<-Pr)throw new Error(`Cannot add a stage with weight ${t} as the total weight of registered stages would exceed 1.`);this._selfWeight-=t;const p=new yr({caption:n,weight:t,fillTime:this._fillTime});return this._subTrackers.push(p),p.addEventListener("progress",()=>this.notifyProgress()),p.addEventListener("done",()=>{this.done&&this.notifyDone()}),p}fillSlowly({stopBeforeFinishing:t=!0}={}){if(this._isFilling)return;this._isFilling=!0;const n=100,p=this._fillTime/n;this._fillInterval=setInterval(()=>{this.set(this._selfProgress+1),t&&this._selfProgress>=99&&clearInterval(this._fillInterval)},p)}set(t){this._selfProgress=Math.min(t,100),this.notifyProgress(),this._selfProgress+Pr>=100&&this.finish()}finish(){this._fillInterval&&clearInterval(this._fillInterval),this._selfDone=!0,this._selfProgress=100,this._isFilling=!1,this._fillInterval=void 0,this.notifyProgress(),this.notifyDone()}get caption(){for(let t=this._subTrackers.length-1;t>=0;t--)if(!this._subTrackers[t].done){const n=this._subTrackers[t].caption;if(n)return n}return this._selfCaption}setCaption(t){this._selfCaption=t,this.notifyProgress()}get done(){return this.progress+Pr>=100}get progress(){if(this._selfDone)return 100;const t=this._subTrackers.reduce((n,p)=>n+p.progress*p.weight,this._selfProgress*this._selfWeight);return Math.round(t*1e4)/1e4}get weight(){return this._weight}get observer(){return this._progressObserver||(this._progressObserver=t=>{this.set(t)}),this._progressObserver}get loadingListener(){return this._loadingListener||(this._loadingListener=t=>{this.set(t.detail.loaded/t.detail.total*100)}),this._loadingListener}pipe(t){t.setProgress({progress:this.progress,caption:this.caption}),this.addEventListener("progress",n=>{t.setProgress({progress:n.detail.progress,caption:n.detail.caption})}),this.addEventListener("done",()=>{t.setLoaded()})}addEventListener(t,n){super.addEventListener(t,n)}removeEventListener(t,n){super.removeEventListener(t,n)}notifyProgress(){const t=this;this.dispatchEvent(new CustomEvent("progress",{detail:{get progress(){return t.progress},get caption(){return t.caption}}}))}notifyDone(){this.dispatchEvent(new CustomEvent("done"))}}const ar={0:"No error occurred. System call completed successfully.",1:"Argument list too long.",2:"Permission denied.",3:"Address in use.",4:"Address not available.",5:"Address family not supported.",6:"Resource unavailable, or operation would block.",7:"Connection already in progress.",8:"Bad file descriptor.",9:"Bad message.",10:"Device or resource busy.",11:"Operation canceled.",12:"No child processes.",13:"Connection aborted.",14:"Connection refused.",15:"Connection reset.",16:"Resource deadlock would occur.",17:"Destination address required.",18:"Mathematics argument out of domain of function.",19:"Reserved.",20:"File exists.",21:"Bad address.",22:"File too large.",23:"Host is unreachable.",24:"Identifier removed.",25:"Illegal byte sequence.",26:"Operation in progress.",27:"Interrupted function.",28:"Invalid argument.",29:"I/O error.",30:"Socket is connected.",31:"There is a directory under that path.",32:"Too many levels of symbolic links.",33:"File descriptor value too large.",34:"Too many links.",35:"Message too large.",36:"Reserved.",37:"Filename too long.",38:"Network is down.",39:"Connection aborted by network.",40:"Network unreachable.",41:"Too many files open in system.",42:"No buffer space available.",43:"No such device.",44:"There is no such file or directory OR the parent directory does not exist.",45:"Executable file format error.",46:"No locks available.",47:"Reserved.",48:"Not enough space.",49:"No message of the desired type.",50:"Protocol not available.",51:"No space left on device.",52:"Function not supported.",53:"The socket is not connected.",54:"Not a directory or a symbolic link to a directory.",55:"Directory not empty.",56:"State not recoverable.",57:"Not a socket.",58:"Not supported, or operation not supported on socket.",59:"Inappropriate I/O control operation.",60:"No such device or address.",61:"Value too large to be stored in data type.",62:"Previous owner died.",63:"Operation not permitted.",64:"Broken pipe.",65:"Protocol error.",66:"Protocol not supported.",67:"Protocol wrong type for socket.",68:"Result too large.",69:"Read-only file system.",70:"Invalid seek.",71:"No such process.",72:"Reserved.",73:"Connection timed out.",74:"Text file busy.",75:"Cross-device link.",76:"Extension: Capabilities insufficient."};function hs(r){const t=typeof r=="object"?r==null?void 0:r.errno:null;if(t in ar)return ar[t]}function ge(r=""){return function(n,p,l){const i=l.value;l.value=function(...e){try{return i.apply(this,e)}catch(f){const h=typeof f=="object"?f==null?void 0:f.errno:null;if(h in ar){const b=ar[h],k=typeof e[1]=="string"?e[1]:null,m=k!==null?r.replaceAll("{path}",k):r;throw new Error(`${m}: ${b}`,{cause:f})}throw f}}}}var gs=Object.defineProperty,bs=Object.getOwnPropertyDescriptor,be=(r,t,n,p)=>{for(var l=p>1?void 0:p?bs(t,n):t,i=r.length-1,e;i>=0;i--)(e=r[i])&&(l=(p?e(t,n,l):e(l))||l);return p&&l&&gs(t,n,l),l};const we=class pe{static readFileAsText(t,n){return new TextDecoder().decode(pe.readFileAsBuffer(t,n))}static readFileAsBuffer(t,n){return t.readFile(n)}static writeFile(t,n,p){t.writeFile(n,p)}static unlink(t,n){t.unlink(n)}static mv(t,n,p){try{const l=t.lookupPath(n).node.mount,i=pe.fileExists(t,p)?t.lookupPath(p).node.mount:t.lookupPath(et(p)).node.mount;l.mountpoint!==i.mountpoint?(pe.copyRecursive(t,n,p),pe.isDir(t,n)?pe.rmdir(t,n,{recursive:!0}):t.unlink(n)):t.rename(n,p)}catch(l){const i=hs(l);throw i?new Error(`Could not move ${n} to ${p}: ${i}`,{cause:l}):l}}static rmdir(t,n,p={recursive:!0}){p!=null&&p.recursive&&pe.listFiles(t,n).forEach(l=>{const i=`${n}/${l}`;pe.isDir(t,i)?pe.rmdir(t,i,p):pe.unlink(t,i)}),t.rmdir(n)}static listFiles(t,n,p={prependPath:!1}){if(!pe.fileExists(t,n))return[];try{const l=t.readdir(n).filter(i=>i!=="."&&i!=="..");if(p.prependPath){const i=n.replace(/\/$/,"");return l.map(e=>`${i}/${e}`)}return l}catch(l){return ae.error(l,{path:n}),[]}}static isDir(t,n){return pe.fileExists(t,n)?t.isDir(t.lookupPath(n,{follow:!0}).node.mode):!1}static isFile(t,n){return pe.fileExists(t,n)?t.isFile(t.lookupPath(n,{follow:!0}).node.mode):!1}static symlink(t,n,p){return t.symlink(n,p)}static isSymlink(t,n){return pe.fileExists(t,n)?t.isLink(t.lookupPath(n).node.mode):!1}static readlink(t,n){return t.readlink(n)}static realpath(t,n){return t.lookupPath(n,{follow:!0}).path}static fileExists(t,n){try{return t.lookupPath(n),!0}catch{return!1}}static mkdir(t,n){t.mkdirTree(n)}static copyRecursive(t,n,p){const l=t.lookupPath(n).node;if(t.isDir(l.mode)){t.mkdirTree(p);const i=t.readdir(n).filter(e=>e!=="."&&e!=="..");for(const e of i)pe.copyRecursive(t,ie(n,e),ie(p,e))}else t.writeFile(p,t.readFile(n))}};be([ge('Could not read "{path}"')],we,"readFileAsText",1);be([ge('Could not read "{path}"')],we,"readFileAsBuffer",1);be([ge('Could not write to "{path}"')],we,"writeFile",1);be([ge('Could not unlink "{path}"')],we,"unlink",1);be([ge('Could not remove directory "{path}"')],we,"rmdir",1);be([ge('Could not list files in "{path}"')],we,"listFiles",1);be([ge('Could not stat "{path}"')],we,"isDir",1);be([ge('Could not stat "{path}"')],we,"isFile",1);be([ge('Could not stat "{path}"')],we,"realpath",1);be([ge('Could not stat "{path}"')],we,"fileExists",1);be([ge('Could not create directory "{path}"')],we,"mkdir",1);be([ge('Could not copy files from "{path}"')],we,"copyRecursive",1);const ws={500:"Internal Server Error",502:"Bad Gateway",404:"Not Found",403:"Forbidden",401:"Unauthorized",400:"Bad Request",301:"Moved Permanently",302:"Found",307:"Temporary Redirect",308:"Permanent Redirect",204:"No Content",201:"Created",200:"OK"};class pr{constructor(t,n,p,l="",i=0){this.httpStatusCode=t,this.headers=n,this.bytes=p,this.exitCode=i,this.errors=l}static forHttpCode(t,n=""){return new pr(t,{},new TextEncoder().encode(n||ws[t]||""))}static fromRawData(t){return new pr(t.httpStatusCode,t.headers,t.bytes,t.errors,t.exitCode)}toRawData(){return{headers:this.headers,bytes:this.bytes,errors:this.errors,exitCode:this.exitCode,httpStatusCode:this.httpStatusCode}}get json(){return JSON.parse(this.text)}get text(){return new TextDecoder().decode(this.bytes)}}(function(){var r;return typeof process<"u"&&((r=process.release)==null?void 0:r.name)==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"})();const zr="/internal/shared/php.ini",{hasOwnProperty:_r}=Object.prototype,Tr=(r,t={})=>{typeof t=="string"&&(t={section:t}),t.align=t.align===!0,t.newline=t.newline===!0,t.sort=t.sort===!0,t.whitespace=t.whitespace===!0||t.align===!0,t.platform=t.platform||typeof process<"u"&&process.platform,t.bracketedArray=t.bracketedArray!==!1;const n=t.platform==="win32"?`\r
|
|
706
706
|
`:`
|
|
707
707
|
`,p=t.whitespace?" = ":"=",l=[],i=t.sort?Object.keys(r).sort():Object.keys(r);let e=0;t.align&&(e=Ee(i.filter(b=>r[b]===null||Array.isArray(r[b])||typeof r[b]!="object").map(b=>Array.isArray(r[b])?`${b}[]`:b).concat([""]).reduce((b,k)=>Ee(b).length>=Ee(k).length?b:k)).length);let f="";const h=t.bracketedArray?"[]":"";for(const b of i){const k=r[b];if(k&&Array.isArray(k))for(const m of k)f+=Ee(`${b}${h}`).padEnd(e," ")+p+Ee(m)+n;else k&&typeof k=="object"?l.push(b):f+=Ee(b).padEnd(e," ")+p+Ee(k)+n}t.section&&f.length&&(f="["+Ee(t.section)+"]"+(t.newline?n+n:n)+f);for(const b of l){const k=$t(b,".").join("\\."),m=(t.section?t.section+".":"")+k,w=Tr(r[b],{...t,section:m});f.length&&w.length&&(f+=n),f+=w}return f};function $t(r,t){var n=0,p=0,l=0,i=[];do if(l=r.indexOf(t,n),l!==-1){if(n=l+t.length,l>0&&r[l-1]==="\\")continue;i.push(r.slice(p,l)),p=l+t.length}while(l!==-1);return i.push(r.slice(p)),i}const Vr=(r,t={})=>{t.bracketedArray=t.bracketedArray!==!1;const n=Object.create(null);let p=n,l=null;const i=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,e=r.split(/[\r\n]+/g),f={};for(const b of e){if(!b||b.match(/^\s*[;#]/)||b.match(/^\s*$/))continue;const k=b.match(i);if(!k)continue;if(k[1]!==void 0){if(l=rr(k[1]),l==="__proto__"){p=Object.create(null);continue}p=n[l]=n[l]||Object.create(null);continue}const m=rr(k[2]);let w;t.bracketedArray?w=m.length>2&&m.slice(-2)==="[]":(f[m]=((f==null?void 0:f[m])||0)+1,w=f[m]>1);const S=w?m.slice(0,-2):m;if(S==="__proto__")continue;const W=k[3]?rr(k[4]):!0,P=W==="true"||W==="false"||W==="null"?JSON.parse(W):W;w&&(_r.call(p,S)?Array.isArray(p[S])||(p[S]=[p[S]]):p[S]=[]),Array.isArray(p[S])?p[S].push(P):p[S]=P}const h=[];for(const b of Object.keys(n)){if(!_r.call(n,b)||typeof n[b]!="object"||Array.isArray(n[b]))continue;const k=$t(b,".");p=n;const m=k.pop(),w=m.replace(/\\\./g,".");for(const S of k)S!=="__proto__"&&((!_r.call(p,S)||typeof p[S]!="object")&&(p[S]=Object.create(null)),p=p[S]);p===n&&w===m||(p[w]=n[b],h.push(b))}for(const b of h)delete n[b];return n},Tt=r=>r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"),Ee=r=>typeof r!="string"||r.match(/[=\r\n]/)||r.match(/^\[/)||r.length>1&&Tt(r)||r!==r.trim()?JSON.stringify(r):r.split(";").join("\\;").split("#").join("\\#"),rr=r=>{if(r=(r||"").trim(),Tt(r)){r.charAt(0)==="'"&&(r=r.slice(1,-1));try{r=JSON.parse(r)}catch{}}else{let t=!1,n="";for(let p=0,l=r.length;p<l;p++){const i=r.charAt(p);if(t)"\\;#".indexOf(i)!==-1?n+=i:n+="\\"+i,t=!1;else{if(";#".indexOf(i)!==-1)break;i==="\\"?t=!0:n+=i}}return t&&(n+="\\"),n.trim()}return r};var Hr={parse:Vr,decode:Vr,stringify:Tr,encode:Tr,safe:Ee,unsafe:rr};async function vs(r,t){const n=Hr.parse(await r.readFileAsText(zr));for(const[p,l]of Object.entries(t))l==null?delete n[p]:n[p]=l;await r.writeFile(zr,Hr.stringify(n))}ReadableStream.prototype[Symbol.asyncIterator]||(ReadableStream.prototype[Symbol.asyncIterator]=async function*(){const r=this.getReader();try{for(;;){const{done:t,value:n}=await r.read();if(t)return;yield n}}finally{r.releaseLock()}},ReadableStream.prototype.iterate=ReadableStream.prototype[Symbol.asyncIterator]);const hr=["8.3","8.2","8.1","8.0","7.4","7.3","7.2","7.1","7.0"],jt=hr[0],Ps=hr,At=["iconv","mbstring","xml-bundle","gd"],Gr={"kitchen-sink":At,light:[]},_s=["vfs","literal","wordpress.org/themes","wordpress.org/plugins","url"];function ks(r){return r&&typeof r=="object"&&typeof r.resource=="string"&&_s.includes(r.resource)}class Le{static create(t,{semaphore:n,progress:p}){let l;switch(t.resource){case"vfs":l=new Os(t,p);break;case"literal":l=new Es(t,p);break;case"wordpress.org/themes":l=new js(t,p);break;case"wordpress.org/plugins":l=new As(t,p);break;case"url":l=new Ts(t,p);break;default:throw new Error(`Invalid resource: ${t}`)}return l=new qs(l),n&&(l=new Rs(l,n)),l}setPlayground(t){this.playground=t}get isAsync(){return!1}}class Os extends Le{constructor(t,n){super(),this.resource=t,this.progress=n}async resolve(){var n;const t=await this.playground.readFileAsBuffer(this.resource.path);return(n=this.progress)==null||n.set(100),new File([t],this.name)}get name(){return this.resource.path.split("/").pop()||""}}class Es extends Le{constructor(t,n){super(),this.resource=t,this.progress=n}async resolve(){var t;return(t=this.progress)==null||t.set(100),new File([this.resource.contents],this.resource.name)}get name(){return this.resource.name}}class Fr extends Le{constructor(t){super(),this.progress=t}async resolve(){var n,p;(n=this.progress)==null||n.setCaption(this.caption);const t=this.getURL();try{let l=await fetch(t);if(!l.ok)throw new Error(`Could not download "${t}"`);if(l=await ys(l,((p=this.progress)==null?void 0:p.loadingListener)??$s),l.status!==200)throw new Error(`Could not download "${t}"`);return new File([await l.blob()],this.name)}catch(l){throw new Error(`Could not download "${t}".
|
|
708
708
|
Check if the URL is correct and the server is reachable.
|
package/index.js
CHANGED
|
@@ -2012,7 +2012,7 @@ const we = class pe {
|
|
|
2012
2012
|
static mv(t, o, p) {
|
|
2013
2013
|
try {
|
|
2014
2014
|
const l = t.lookupPath(o).node.mount, i = pe.fileExists(t, p) ? t.lookupPath(p).node.mount : t.lookupPath(Yr(p)).node.mount;
|
|
2015
|
-
l.mountpoint !== i.mountpoint ? (pe.copyRecursive(t, o, p), pe.rmdir(t, o, { recursive: !0 })) : t.rename(o, p);
|
|
2015
|
+
l.mountpoint !== i.mountpoint ? (pe.copyRecursive(t, o, p), pe.isDir(t, o) ? pe.rmdir(t, o, { recursive: !0 }) : t.unlink(o)) : t.rename(o, p);
|
|
2016
2016
|
} catch (l) {
|
|
2017
2017
|
const i = cs(l);
|
|
2018
2018
|
throw i ? new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.44",
|
|
4
4
|
"description": "WordPress Playground client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"main": "./index.cjs",
|
|
38
38
|
"module": "./index.js",
|
|
39
39
|
"types": "index.d.ts",
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "9e9943cca00e850e6ce60f1aac4313831fc4a65c",
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18.18.0",
|
|
43
43
|
"npm": ">=8.11.0"
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"comlink": "^4.4.1",
|
|
48
48
|
"ini": "4.1.2",
|
|
49
49
|
"octokit": "3.1.1",
|
|
50
|
-
"@wp-playground/blueprints": "0.9.
|
|
51
|
-
"@php-wasm/universal": "0.9.
|
|
52
|
-
"@php-wasm/util": "0.9.
|
|
53
|
-
"@php-wasm/web": "0.9.
|
|
54
|
-
"@php-wasm/progress": "0.9.
|
|
55
|
-
"@php-wasm/logger": "0.9.
|
|
50
|
+
"@wp-playground/blueprints": "0.9.44",
|
|
51
|
+
"@php-wasm/universal": "0.9.44",
|
|
52
|
+
"@php-wasm/util": "0.9.44",
|
|
53
|
+
"@php-wasm/web": "0.9.44",
|
|
54
|
+
"@php-wasm/progress": "0.9.44",
|
|
55
|
+
"@php-wasm/logger": "0.9.44"
|
|
56
56
|
}
|
|
57
57
|
}
|