@wp-playground/client 3.0.21 → 3.0.22
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 +3 -2
- package/index.js +3 -2
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -111,7 +111,7 @@ gpgsig`+Oi(n)+`
|
|
|
111
111
|
https://raw.githubusercontent.com/username/repository/branch/filename
|
|
112
112
|
|
|
113
113
|
Error:
|
|
114
|
-
${s}`)}}get caption(){return`Downloading ${this.name}`}get name(){try{return new URL(this.getURL(),"http://example.com").pathname.split("/").pop()}catch{return this.getURL()}}get isAsync(){return!0}}function lb(e){if(!e)return null;const t=e.match(/filename\*?=([^;]+)/i);if(!t)return null;let r=t[1].trim();if((r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),t[0].includes("filename*")){const i=r.match(/^[^']*'[^']*'(.+)$/);if(i)try{r=decodeURIComponent(i[1])}catch{}}return r}const fb=()=>{};class pb extends Ro{constructor(t,r,i){if(super(r,i==null?void 0:i.corsProxy),this.resource=t,this.options=i,this.resource.url.startsWith("https://github.com/")){const a=this.resource.url.match(/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/blob\/(?<branch>[^/]+)\/(?<path>.+[^/])$/);a!=null&&a.groups&&(this.resource={...this.resource,url:`https://raw.githubusercontent.com/${a.groups.owner}/${a.groups.repo}/${a.groups.branch}/${a.groups.path}`})}}getURL(){return this.resource.url}get caption(){return this.resource.caption??super.caption}}class cb extends Jt{constructor(t,r,i){super(),this.reference=t,this._progress=r,this.options=i}async resolve(){var f;const t=(f=this.options)!=null&&f.corsProxy?`${this.options.corsProxy}${this.reference.url}`:this.reference.url,r=await Qg(t,{value:this.reference.ref,type:this.reference.refType??"infer"}),i=await Jg(t,r),a=(this.reference.path??"").replace(/^\/+/,""),s=u_(i,a),n=await Yg(t,r,s,{withObjects:this.reference[".git"]});let o=n.files;return o=ub(o,p=>p.substring(a.length).replace(/^\/+/,"")),this.reference[".git"]&&(o={...await c_({repoUrl:this.reference.url,commitHash:r,ref:this.reference.ref,refType:this.reference.refType,objects:n.objects??[],fileOids:n.fileOids??{},pathPrefix:a}),...o}),{name:this.filename,files:o}}get filename(){return this.name.replaceAll(/[^a-zA-Z0-9-.]/g,"-").replaceAll(/-+/g,"-").replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g,"")||so()}get name(){var t;return[this.reference.url,this.reference.ref?`(${this.reference.ref})`:"",(t=this.reference.path)!=null&&t.replace(/^\/+/,"")?`at ${this.reference.path}`:""].filter(r=>r.length>0).join(" ")}}function ub(e,t){return Object.fromEntries(Object.entries(e).map(([r,i])=>[t(r),i]))}class db extends Jt{constructor(t,r){super(),this.reference=t,this._progress=r}async resolve(){return this.reference}get name(){return this.reference.name}}class hb extends Ro{constructor(t,r){super(r),this.resource=t}get name(){return gi(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/theme/${Ju(this.resource.slug)}`}}class mb extends Ro{constructor(t,r){super(r),this.resource=t}get name(){return gi(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/plugin/${Ju(this.resource.slug)}`}}function Ju(e){return!e||e.endsWith(".zip")?e:e+".latest-stable.zip"}class yb extends Xu{async resolve(){return this.promise||(this.promise=this.resource.resolve()),this.promise}}class gb extends Xu{constructor(t,r){super(t),this.semaphore=r}async resolve(){return this.isAsync?this.semaphore.run(()=>this.resource.resolve()):this.resource.resolve()}}class _b extends Jt{constructor(t,r,i){if(!r)throw new Error(`You are trying to run a Blueprint that refers to a bundled file ("blueprint" resource type), but you did not provide the rest of the bundle. This Blueprint won't work as a standalone JSON file. You'll need to load the entire bundle, e.g. a blueprint.zip file. Alternatively, you may try loading it directly from a URL or a local directory and Playground will try (with your permission) to source the missing files from paths relative to the blueprint file.`);super(),this.resource=t,this.streamBundledFile=r,this._progress=i}async resolve(){var t,r,i;(t=this.progress)==null||t.set(0);try{const a=await this.streamBundledFile(this.resource.path),s=a.filesize;if(!s)return(r=this.progress)==null||r.set(100),a;const n=Op(a.stream(),s,o=>{var f;(f=this.progress)==null||f.set(o.detail.loaded/o.detail.total*100)});return new In(n,this.name,{filesize:s})}catch(a){throw(i=this.progress)==null||i.set(100),new Error(`Failed to read file from blueprint. This Blueprint refers to a resource of type "bundled" with path "${this.resource.path}" that was not available. Please ensure that the entire bundle, such as a blueprint.zip file, is loaded. If you are trying to load the Blueprint directly from a URL or a local directory, make sure that all the necessary files are accessible and located relative to the blueprint file.
|
|
114
|
+
${s}`)}}get caption(){return`Downloading ${this.name}`}get name(){try{return new URL(this.getURL(),"http://example.com").pathname.split("/").pop()}catch{return this.getURL()}}get isAsync(){return!0}}function lb(e){if(!e)return null;const t=e.match(/filename\*?=([^;]+)/i);if(!t)return null;let r=t[1].trim();if((r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1)),t[0].includes("filename*")){const i=r.match(/^[^']*'[^']*'(.+)$/);if(i)try{r=decodeURIComponent(i[1])}catch{}}return r}const fb=()=>{};class pb extends Ro{constructor(t,r,i){if(super(r,i==null?void 0:i.corsProxy),this.resource=t,this.options=i,this.resource.url.startsWith("https://github.com/")){const a=this.resource.url.match(/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?:blob|raw)\/(?<branch>[^/]+)\/(?<path>.+[^/])$/);a!=null&&a.groups&&(this.resource={...this.resource,url:`https://raw.githubusercontent.com/${a.groups.owner}/${a.groups.repo}/${a.groups.branch}/${a.groups.path}`})}}getURL(){return this.resource.url}get caption(){return this.resource.caption??super.caption}}class cb extends Jt{constructor(t,r,i){super(),this.reference=t,this._progress=r,this.options=i}async resolve(){var f;const t=(f=this.options)!=null&&f.corsProxy?`${this.options.corsProxy}${this.reference.url}`:this.reference.url,r=await Qg(t,{value:this.reference.ref,type:this.reference.refType??"infer"}),i=await Jg(t,r),a=(this.reference.path??"").replace(/^\/+/,""),s=u_(i,a),n=await Yg(t,r,s,{withObjects:this.reference[".git"]});let o=n.files;return o=ub(o,p=>p.substring(a.length).replace(/^\/+/,"")),this.reference[".git"]&&(o={...await c_({repoUrl:this.reference.url,commitHash:r,ref:this.reference.ref,refType:this.reference.refType,objects:n.objects??[],fileOids:n.fileOids??{},pathPrefix:a}),...o}),{name:this.filename,files:o}}get filename(){return this.name.replaceAll(/[^a-zA-Z0-9-.]/g,"-").replaceAll(/-+/g,"-").replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g,"")||so()}get name(){var t;return[this.reference.url,this.reference.ref?`(${this.reference.ref})`:"",(t=this.reference.path)!=null&&t.replace(/^\/+/,"")?`at ${this.reference.path}`:""].filter(r=>r.length>0).join(" ")}}function ub(e,t){return Object.fromEntries(Object.entries(e).map(([r,i])=>[t(r),i]))}class db extends Jt{constructor(t,r){super(),this.reference=t,this._progress=r}async resolve(){return this.reference}get name(){return this.reference.name}}class hb extends Ro{constructor(t,r){super(r),this.resource=t}get name(){return gi(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/theme/${Ju(this.resource.slug)}`}}class mb extends Ro{constructor(t,r){super(r),this.resource=t}get name(){return gi(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/plugin/${Ju(this.resource.slug)}`}}function Ju(e){return!e||e.endsWith(".zip")?e:e+".latest-stable.zip"}class yb extends Xu{async resolve(){return this.promise||(this.promise=this.resource.resolve()),this.promise}}class gb extends Xu{constructor(t,r){super(t),this.semaphore=r}async resolve(){return this.isAsync?this.semaphore.run(()=>this.resource.resolve()):this.resource.resolve()}}class _b extends Jt{constructor(t,r,i){if(!r)throw new Error(`You are trying to run a Blueprint that refers to a bundled file ("blueprint" resource type), but you did not provide the rest of the bundle. This Blueprint won't work as a standalone JSON file. You'll need to load the entire bundle, e.g. a blueprint.zip file. Alternatively, you may try loading it directly from a URL or a local directory and Playground will try (with your permission) to source the missing files from paths relative to the blueprint file.`);super(),this.resource=t,this.streamBundledFile=r,this._progress=i}async resolve(){var t,r,i;(t=this.progress)==null||t.set(0);try{const a=await this.streamBundledFile(this.resource.path),s=a.filesize;if(!s)return(r=this.progress)==null||r.set(100),a;const n=Op(a.stream(),s,o=>{var f;(f=this.progress)==null||f.set(o.detail.loaded/o.detail.total*100)});return new In(n,this.name,{filesize:s})}catch(a){throw(i=this.progress)==null||i.set(100),new Error(`Failed to read file from blueprint. This Blueprint refers to a resource of type "bundled" with path "${this.resource.path}" that was not available. Please ensure that the entire bundle, such as a blueprint.zip file, is loaded. If you are trying to load the Blueprint directly from a URL or a local directory, make sure that all the necessary files are accessible and located relative to the blueprint file.
|
|
115
115
|
|
|
116
116
|
Error details: ${a instanceof Error?a.message:String(a)}`,{cause:a})}}get name(){return this.resource.path.split("/").pop()||""}get isAsync(){return!0}}const Io=async(e,{pluginPath:t,pluginName:r},i)=>{i==null||i.tracker.setCaption(`Activating ${r||t}`);const a=await e.documentRoot,s=await e.run({code:`<?php
|
|
117
117
|
define( 'WP_ADMIN', true );
|
|
@@ -265,7 +265,8 @@ This will ensure your code works reliably regardless of the current working dire
|
|
|
265
265
|
$zip->close();
|
|
266
266
|
chmod($extractTo, 0777);
|
|
267
267
|
} else {
|
|
268
|
-
|
|
268
|
+
$fileSize = file_exists($zipPath) ? filesize($zipPath) : 'unknown';
|
|
269
|
+
throw new Exception("Could not unzip file. Error code: " . $res . ". File size: " . $fileSize . " bytes.");
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
272
|
unzip(${s.zipPath}, ${s.extractToPath}, ${s.overwriteFiles});
|
package/index.js
CHANGED
|
@@ -14448,7 +14448,7 @@ class Hw extends Ao {
|
|
|
14448
14448
|
constructor(t, r, i) {
|
|
14449
14449
|
if (super(r, i == null ? void 0 : i.corsProxy), this.resource = t, this.options = i, this.resource.url.startsWith("https://github.com/")) {
|
|
14450
14450
|
const a = this.resource.url.match(
|
|
14451
|
-
/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/blob\/(?<branch>[^/]+)\/(?<path>.+[^/])$/
|
|
14451
|
+
/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?:blob|raw)\/(?<branch>[^/]+)\/(?<path>.+[^/])$/
|
|
14452
14452
|
);
|
|
14453
14453
|
a != null && a.groups && (this.resource = {
|
|
14454
14454
|
...this.resource,
|
|
@@ -14872,7 +14872,8 @@ This will ensure your code works reliably regardless of the current working dire
|
|
|
14872
14872
|
$zip->close();
|
|
14873
14873
|
chmod($extractTo, 0777);
|
|
14874
14874
|
} else {
|
|
14875
|
-
|
|
14875
|
+
$fileSize = file_exists($zipPath) ? filesize($zipPath) : 'unknown';
|
|
14876
|
+
throw new Exception("Could not unzip file. Error code: " . $res . ". File size: " . $fileSize . " bytes.");
|
|
14876
14877
|
}
|
|
14877
14878
|
}
|
|
14878
14879
|
unzip(${s.zipPath}, ${s.extractToPath}, ${s.overwriteFiles});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.22",
|
|
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": "a624d1a97dc639e152d335e6a801b2fad7f6b594",
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=20.18.3",
|
|
43
43
|
"npm": ">=10.1.0"
|