@wp-playground/client 0.9.34 → 0.9.36
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 +5 -1
- package/package.json +8 -8
package/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Kr=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"}();if(Kr==="NODE"){let r=function(n){return new Promise(function(p,l){n.onload=n.onerror=function(i){n.onload=n.onerror=null,i.type==="load"?p(n.result):l(new Error("Failed to read the blob/file"))}})},t=function(){const n=new Uint8Array([1,2,3,4]),l=new File([n],"test").stream();try{return l.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class n extends Blob{constructor(l,i,e){super(l);let f;e!=null&&e.lastModified&&(f=new Date),(!f||isNaN(f.getFullYear()))&&(f=new Date),this.lastModifiedDate=f,this.lastModified=f.getMilliseconds(),this.name=i||""}}global.File=n}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const p=new FileReader;return p.readAsArrayBuffer(this),r(p)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const p=new FileReader;return p.readAsText(this),r(p)}),(typeof Blob.prototype.stream>"u"||!t())&&(Blob.prototype.stream=function(){let n=0;const p=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(l){const i=l.byobRequest.view,f=await p.slice(n,n+i.byteLength).arrayBuffer(),h=new Uint8Array(f);new Uint8Array(i.buffer).set(h);const b=h.byteLength;l.byobRequest.respond(b),n+=b,n>=p.size&&l.close()}})})}if(Kr==="NODE"&&typeof CustomEvent>"u"){class r extends Event{constructor(n,p={}){super(n,p),this.detail=p.detail}initCustomEvent(){}}globalThis.CustomEvent=r}const Ar=["db.php","plugins/akismet","plugins/hello.php","plugins/wordpress-importer","mu-plugins/sqlite-database-integration","mu-plugins/playground-includes","mu-plugins/0-playground.php","mu-plugins/0-sqlite.php","themes/twentytwenty","themes/twentytwentyone","themes/twentytwentytwo","themes/twentytwentythree","themes/twentytwentyfour","themes/twentytwentyfive","themes/twentytwentysix"],Xr=Symbol("SleepFinished");function zt(r){return new Promise(t=>{setTimeout(()=>t(Xr),r)})}class Vt extends Error{constructor(){super("Acquiring lock timed out")}}class Ht{constructor({concurrency:t,timeout:n}){this._running=0,this.concurrency=t,this.timeout=n,this.queue=[]}get remaining(){return this.concurrency-this.running}get running(){return this._running}async acquire(){for(;;)if(this._running>=this.concurrency){const t=new Promise(n=>{this.queue.push(n)});this.timeout!==void 0?await Promise.race([t,zt(this.timeout)]).then(n=>{if(n===Xr)throw new Vt}):await t}else{this._running++;let t=!1;return()=>{t||(t=!0,this._running--,this.queue.length>0&&this.queue.shift()())}}}async run(t){const n=await this.acquire();try{return await t()}finally{n()}}}function ie(...r){function t(i){return i.substring(i.length-1)==="/"}let n=r.join("/");const p=n[0]==="/",l=t(n);return n=rt(n),!n&&!p&&(n="."),n&&l&&!t(n)&&(n+="/"),n}function et(r){if(r==="/")return"/";r=rt(r);const t=r.lastIndexOf("/");return t===-1?"":t===0?"/":r.substr(0,t)}function rt(r){const t=r[0]==="/";return r=Gt(r.split("/").filter(n=>!!n),!t).join("/"),(t?"/":"")+r.replace(/\/$/,"")}function Gt(r,t){let n=0;for(let p=r.length-1;p>=0;p--){const l=r[p];l==="."?r.splice(p,1):l===".."?(r.splice(p,1),n++):n&&(r.splice(p,1),n--)}if(t)for(;n;n--)r.unshift("..");return r}function tt(r=36,t="!@#$%^&*()_+=-[]/.,<>?"){const n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+t;let p="";for(let l=r;l>0;--l)p+=n[Math.floor(Math.random()*n.length)];return p}function Yt(){return tt(36,"-_")}function se(r){return`json_decode(base64_decode('${Zt(JSON.stringify(r))}'), true)`}function We(r){const t={};for(const n in r)t[n]=se(r[n]);return t}function Zt(r){return Qt(new TextEncoder().encode(r))}function Qt(r){const t=String.fromCodePoint(...r);return btoa(t)}const Jt="playground-log",Dr=(r,...t)=>{ae.dispatchEvent(new CustomEvent(Jt,{detail:{log:r,args:t}}))},Kt=(r,...t)=>{switch(typeof r.message=="string"?r
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Kr=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"}();if(Kr==="NODE"){let r=function(n){return new Promise(function(p,l){n.onload=n.onerror=function(i){n.onload=n.onerror=null,i.type==="load"?p(n.result):l(new Error("Failed to read the blob/file"))}})},t=function(){const n=new Uint8Array([1,2,3,4]),l=new File([n],"test").stream();try{return l.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class n extends Blob{constructor(l,i,e){super(l);let f;e!=null&&e.lastModified&&(f=new Date),(!f||isNaN(f.getFullYear()))&&(f=new Date),this.lastModifiedDate=f,this.lastModified=f.getMilliseconds(),this.name=i||""}}global.File=n}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const p=new FileReader;return p.readAsArrayBuffer(this),r(p)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const p=new FileReader;return p.readAsText(this),r(p)}),(typeof Blob.prototype.stream>"u"||!t())&&(Blob.prototype.stream=function(){let n=0;const p=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(l){const i=l.byobRequest.view,f=await p.slice(n,n+i.byteLength).arrayBuffer(),h=new Uint8Array(f);new Uint8Array(i.buffer).set(h);const b=h.byteLength;l.byobRequest.respond(b),n+=b,n>=p.size&&l.close()}})})}if(Kr==="NODE"&&typeof CustomEvent>"u"){class r extends Event{constructor(n,p={}){super(n,p),this.detail=p.detail}initCustomEvent(){}}globalThis.CustomEvent=r}const Ar=["db.php","plugins/akismet","plugins/hello.php","plugins/wordpress-importer","mu-plugins/sqlite-database-integration","mu-plugins/playground-includes","mu-plugins/0-playground.php","mu-plugins/0-sqlite.php","themes/twentytwenty","themes/twentytwentyone","themes/twentytwentytwo","themes/twentytwentythree","themes/twentytwentyfour","themes/twentytwentyfive","themes/twentytwentysix"],Xr=Symbol("SleepFinished");function zt(r){return new Promise(t=>{setTimeout(()=>t(Xr),r)})}class Vt extends Error{constructor(){super("Acquiring lock timed out")}}class Ht{constructor({concurrency:t,timeout:n}){this._running=0,this.concurrency=t,this.timeout=n,this.queue=[]}get remaining(){return this.concurrency-this.running}get running(){return this._running}async acquire(){for(;;)if(this._running>=this.concurrency){const t=new Promise(n=>{this.queue.push(n)});this.timeout!==void 0?await Promise.race([t,zt(this.timeout)]).then(n=>{if(n===Xr)throw new Vt}):await t}else{this._running++;let t=!1;return()=>{t||(t=!0,this._running--,this.queue.length>0&&this.queue.shift()())}}}async run(t){const n=await this.acquire();try{return await t()}finally{n()}}}function ie(...r){function t(i){return i.substring(i.length-1)==="/"}let n=r.join("/");const p=n[0]==="/",l=t(n);return n=rt(n),!n&&!p&&(n="."),n&&l&&!t(n)&&(n+="/"),n}function et(r){if(r==="/")return"/";r=rt(r);const t=r.lastIndexOf("/");return t===-1?"":t===0?"/":r.substr(0,t)}function rt(r){const t=r[0]==="/";return r=Gt(r.split("/").filter(n=>!!n),!t).join("/"),(t?"/":"")+r.replace(/\/$/,"")}function Gt(r,t){let n=0;for(let p=r.length-1;p>=0;p--){const l=r[p];l==="."?r.splice(p,1):l===".."?(r.splice(p,1),n++):n&&(r.splice(p,1),n--)}if(t)for(;n;n--)r.unshift("..");return r}function tt(r=36,t="!@#$%^&*()_+=-[]/.,<>?"){const n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+t;let p="";for(let l=r;l>0;--l)p+=n[Math.floor(Math.random()*n.length)];return p}function Yt(){return tt(36,"-_")}function se(r){return`json_decode(base64_decode('${Zt(JSON.stringify(r))}'), true)`}function We(r){const t={};for(const n in r)t[n]=se(r[n]);return t}function Zt(r){return Qt(new TextEncoder().encode(r))}function Qt(r){const t=String.fromCodePoint(...r);return btoa(t)}const Jt="playground-log",Dr=(r,...t)=>{ae.dispatchEvent(new CustomEvent(Jt,{detail:{log:r,args:t}}))},Kt=(r,...t)=>{switch(typeof r.message=="string"?Reflect.set(r,"message",$r(r.message)):r.message.message&&typeof r.message.message=="string"&&Reflect.set(r.message,"message",$r(r.message.message)),r.severity){case"Debug":console.debug(r.message,...t);break;case"Info":console.info(r.message,...t);break;case"Warn":console.warn(r.message,...t);break;case"Error":console.error(r.message,...t);break;case"Fatal":console.error(r.message,...t);break;default:console.log(r.message,...t)}},Xt=r=>r instanceof Error?[r.message,r.stack].join(`
|
|
2
2
|
`):JSON.stringify(r,null,2),st=[],Mr=r=>{st.push(r)},Er=r=>{if(r.raw===!0)Mr(r.message);else{const t=ts(typeof r.message=="object"?Xt(r.message):r.message,r.severity??"Info",r.prefix??"JavaScript");Mr(t)}};class es extends EventTarget{constructor(t=[]){super(),this.handlers=t,this.fatalErrorEvent="playground-fatal-error"}getLogs(){return this.handlers.includes(Er)?[...st]:(this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
3
3
|
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
4
4
|
`),[])}logMessage(t,...n){for(const p of this.handlers)p(t,...n)}log(t,...n){this.logMessage({message:t,severity:void 0,prefix:"JavaScript",raw:!1},...n)}debug(t,...n){this.logMessage({message:t,severity:"Debug",prefix:"JavaScript",raw:!1},...n)}info(t,...n){this.logMessage({message:t,severity:"Info",prefix:"JavaScript",raw:!1},...n)}warn(t,...n){this.logMessage({message:t,severity:"Warn",prefix:"JavaScript",raw:!1},...n)}error(t,...n){this.logMessage({message:t,severity:"Error",prefix:"JavaScript",raw:!1},...n)}}const rs=()=>{try{if(process.env.NODE_ENV==="test")return[Er,Dr]}catch{}return[Er,Kt,Dr]},ae=new es(rs()),$r=r=>r.replace(/\t/g,""),ts=(r,t,n)=>{const p=new Date,l=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(p).replace(/ /g,"-"),i=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(p),e=l+" "+i;return r=$r(r),`[${e}] ${n} ${t}: ${r}`};let wr=0;const Br="/wordpress/wp-content/debug.log",ss=async r=>await r.fileExists(Br)?await r.readFileAsText(Br):"",is=(r,t)=>{t.addEventListener("request.end",async()=>{const n=await ss(t);if(n.length>wr){const p=n.substring(wr);r.logMessage({message:p,raw:!0}),wr=n.length}}),t.addEventListener("request.error",n=>{n=n,n.error&&(r.logMessage({message:`${n.error.message} ${n.error.stack}`,severity:"Fatal",prefix:n.source==="request"?"PHP":"WASM Crash"}),r.dispatchEvent(new CustomEvent(r.fatalErrorEvent,{detail:{logs:r.getLogs(),source:n.source}})))})},dr=async(r,{pluginPath:t,pluginName:n},p)=>{p==null||p.tracker.setCaption(`Activating ${n||t}`);const l=await r.documentRoot,i=await r.run({code:`<?php
|
package/index.js
CHANGED
|
@@ -209,7 +209,11 @@ const At = "playground-log", Sr = (r, ...t) => {
|
|
|
209
209
|
})
|
|
210
210
|
);
|
|
211
211
|
}, qt = (r, ...t) => {
|
|
212
|
-
switch (typeof r.message == "string" ? r
|
|
212
|
+
switch (typeof r.message == "string" ? Reflect.set(r, "message", Pr(r.message)) : r.message.message && typeof r.message.message == "string" && Reflect.set(
|
|
213
|
+
r.message,
|
|
214
|
+
"message",
|
|
215
|
+
Pr(r.message.message)
|
|
216
|
+
), r.severity) {
|
|
213
217
|
case "Debug":
|
|
214
218
|
console.debug(r.message, ...t);
|
|
215
219
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.36",
|
|
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": "7e69767d7998d57224cbbc5a1de986cef93cee0f",
|
|
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.36",
|
|
51
|
+
"@php-wasm/universal": "0.9.36",
|
|
52
|
+
"@php-wasm/util": "0.9.36",
|
|
53
|
+
"@php-wasm/web": "0.9.36",
|
|
54
|
+
"@php-wasm/progress": "0.9.36",
|
|
55
|
+
"@php-wasm/logger": "0.9.36"
|
|
56
56
|
}
|
|
57
57
|
}
|