@wp-playground/blueprints 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 +1 -1
- package/index.cjs.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +13 -13
package/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
https://raw.githubusercontent.com/username/repository/branch/filename
|
|
23
23
|
|
|
24
24
|
Error:
|
|
25
|
-
${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 ht(r){if(!r)return null;const t=r.match(/filename\*?=([^;]+)/i);if(!t)return null;let n=t[1].trim();if((n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),t[0].includes("filename*")){const d=n.match(/^[^']*'[^']*'(.+)$/);if(d)try{n=decodeURIComponent(d[1])}catch{}}return n}const gt=()=>{};class bt extends mr{constructor(t,n,d){if(super(n,d==null?void 0:d.corsProxy),this.resource=t,this.options=d,this.resource.url.startsWith("https://github.com/")){const u=this.resource.url.match(/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/blob\/(?<branch>[^/]+)\/(?<path>.+[^/])$/);u!=null&&u.groups&&(this.resource={...this.resource,url:`https://raw.githubusercontent.com/${u.groups.owner}/${u.groups.repo}/${u.groups.branch}/${u.groups.path}`})}}getURL(){return this.resource.url}get caption(){return this.resource.caption??super.caption}}class wt extends Te{constructor(t,n,d){super(),this.reference=t,this._progress=n,this.options=d}async resolve(){var c;const t=(c=this.options)!=null&&c.corsProxy?`${this.options.corsProxy}${this.reference.url}`:this.reference.url,n=await Ee.resolveCommitHash(t,{value:this.reference.ref,type:this.reference.refType??"infer"}),d=await Ee.listGitFiles(t,n),u=(this.reference.path??"").replace(/^\/+/,""),s=Ee.listDescendantFiles(d,u),e=await Ee.sparseCheckout(t,n,s,{withObjects:this.reference[".git"]});let l=e.files;return l=vt(l,_=>_.substring(u.length).replace(/^\/+/,"")),this.reference[".git"]&&(l={...await Ee.createDotGitDirectory({repoUrl:this.reference.url,commitHash:n,ref:this.reference.ref,refType:this.reference.refType,objects:e.objects??[],fileOids:e.fileOids??{},pathPrefix:u}),...l}),{name:this.filename,files:l}}get filename(){return this.name.replaceAll(/[^a-zA-Z0-9-.]/g,"-").replaceAll(/-+/g,"-").replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g,"")||U.randomFilename()}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(n=>n.length>0).join(" ")}}function vt(r,t){return Object.fromEntries(Object.entries(r).map(([n,d])=>[t(n),d]))}class Pt extends Te{constructor(t,n){super(),this.reference=t,this._progress=n}async resolve(){return this.reference}get name(){return this.reference.name}}class _t extends mr{constructor(t,n){super(n),this.resource=t}get name(){return ir(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/theme/${Lr(this.resource.slug)}`}}class kt extends mr{constructor(t,n){super(n),this.resource=t}get name(){return ir(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/plugin/${Lr(this.resource.slug)}`}}function Lr(r){return!r||r.endsWith(".zip")?r:r+".latest-stable.zip"}class Ot extends Fr{async resolve(){return this.promise||(this.promise=this.resource.resolve()),this.promise}}class Tt extends Fr{constructor(t,n){super(t),this.semaphore=n}async resolve(){return this.isAsync?this.semaphore.run(()=>this.resource.resolve()):this.resource.resolve()}}class jt extends Te{constructor(t,n,d){if(!n)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=n,this._progress=d}async resolve(){var t,n,d;(t=this.progress)==null||t.set(0);try{const u=await this.streamBundledFile(this.resource.path),s=u.filesize;if(!s)return(n=this.progress)==null||n.set(100),u;const e=ur.cloneStreamMonitorProgress(u.stream(),s,l=>{var c;(c=this.progress)==null||c.set(l.detail.loaded/l.detail.total*100)});return new ft.StreamedFile(e,this.name,{filesize:s})}catch(u){throw(d=this.progress)==null||d.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.
|
|
25
|
+
${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 ht(r){if(!r)return null;const t=r.match(/filename\*?=([^;]+)/i);if(!t)return null;let n=t[1].trim();if((n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))&&(n=n.slice(1,-1)),t[0].includes("filename*")){const d=n.match(/^[^']*'[^']*'(.+)$/);if(d)try{n=decodeURIComponent(d[1])}catch{}}return n}const gt=()=>{};class bt extends mr{constructor(t,n,d){if(super(n,d==null?void 0:d.corsProxy),this.resource=t,this.options=d,this.resource.url.startsWith("https://github.com/")){const u=this.resource.url.match(/^https:\/\/github\.com\/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?:blob|raw)\/(?<branch>[^/]+)\/(?<path>.+[^/])$/);u!=null&&u.groups&&(this.resource={...this.resource,url:`https://raw.githubusercontent.com/${u.groups.owner}/${u.groups.repo}/${u.groups.branch}/${u.groups.path}`})}}getURL(){return this.resource.url}get caption(){return this.resource.caption??super.caption}}class wt extends Te{constructor(t,n,d){super(),this.reference=t,this._progress=n,this.options=d}async resolve(){var c;const t=(c=this.options)!=null&&c.corsProxy?`${this.options.corsProxy}${this.reference.url}`:this.reference.url,n=await Ee.resolveCommitHash(t,{value:this.reference.ref,type:this.reference.refType??"infer"}),d=await Ee.listGitFiles(t,n),u=(this.reference.path??"").replace(/^\/+/,""),s=Ee.listDescendantFiles(d,u),e=await Ee.sparseCheckout(t,n,s,{withObjects:this.reference[".git"]});let l=e.files;return l=vt(l,_=>_.substring(u.length).replace(/^\/+/,"")),this.reference[".git"]&&(l={...await Ee.createDotGitDirectory({repoUrl:this.reference.url,commitHash:n,ref:this.reference.ref,refType:this.reference.refType,objects:e.objects??[],fileOids:e.fileOids??{},pathPrefix:u}),...l}),{name:this.filename,files:l}}get filename(){return this.name.replaceAll(/[^a-zA-Z0-9-.]/g,"-").replaceAll(/-+/g,"-").replace(/^[^a-zA-Z0-9]+|[^a-zA-Z0-9]+$/g,"")||U.randomFilename()}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(n=>n.length>0).join(" ")}}function vt(r,t){return Object.fromEntries(Object.entries(r).map(([n,d])=>[t(n),d]))}class Pt extends Te{constructor(t,n){super(),this.reference=t,this._progress=n}async resolve(){return this.reference}get name(){return this.reference.name}}class _t extends mr{constructor(t,n){super(n),this.resource=t}get name(){return ir(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/theme/${Lr(this.resource.slug)}`}}class kt extends mr{constructor(t,n){super(n),this.resource=t}get name(){return ir(this.resource.slug)}getURL(){return`https://downloads.wordpress.org/plugin/${Lr(this.resource.slug)}`}}function Lr(r){return!r||r.endsWith(".zip")?r:r+".latest-stable.zip"}class Ot extends Fr{async resolve(){return this.promise||(this.promise=this.resource.resolve()),this.promise}}class Tt extends Fr{constructor(t,n){super(t),this.semaphore=n}async resolve(){return this.isAsync?this.semaphore.run(()=>this.resource.resolve()):this.resource.resolve()}}class jt extends Te{constructor(t,n,d){if(!n)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=n,this._progress=d}async resolve(){var t,n,d;(t=this.progress)==null||t.set(0);try{const u=await this.streamBundledFile(this.resource.path),s=u.filesize;if(!s)return(n=this.progress)==null||n.set(100),u;const e=ur.cloneStreamMonitorProgress(u.stream(),s,l=>{var c;(c=this.progress)==null||c.set(l.detail.loaded/l.detail.total*100)});return new ft.StreamedFile(e,this.name,{filesize:s})}catch(u){throw(d=this.progress)==null||d.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.
|
|
26
26
|
|
|
27
27
|
Error details: ${u instanceof Error?u.message:String(u)}`,{cause:u})}}get name(){return this.resource.path.split("/").pop()||""}get isAsync(){return!0}}const yr=async(r,{pluginPath:t,pluginName:n},d)=>{d==null||d.tracker.setCaption(`Activating ${n||t}`);const u=await r.documentRoot,s=await r.run({code:`<?php
|
|
28
28
|
define( 'WP_ADMIN', true );
|