@wp-playground/client 3.1.28 → 3.1.30
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 +5 -1
- package/index.js +20 -17
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1472,7 +1472,7 @@ function playground_progress_reporter() {
|
|
|
1472
1472
|
}
|
|
1473
1473
|
playground_add_filter('blueprint.progress_reporter', 'playground_progress_reporter');
|
|
1474
1474
|
require( "/tmp/blueprints.phar" );
|
|
1475
|
-
`));const p=await i.cli(["/internal/shared/bin/php","/tmp/run-blueprints.php","exec",o,...t]);return p.finished.finally(l),p}class Kd extends Error{constructor(t,r,i){super(t,i),this.name="BlueprintFetchError",this.url=r}}async function Dv(e){let
|
|
1475
|
+
`));const p=await i.cli(["/internal/shared/bin/php","/tmp/run-blueprints.php","exec",o,...t]);return p.finished.finally(l),p}class Kd extends Error{constructor(t,r,i){super(t,i),this.name="BlueprintFetchError",this.url=r}}async function Dv(e,t={}){let r;try{const a=await(t.fetch||fetch)(e,{credentials:"omit"});if(!a.ok)throw new Error(`Failed to fetch blueprint from ${e}`);r=await a.arrayBuffer()}catch(i){throw new Kd(`Blueprint file could not be resolved from ${e}: ${i instanceof Error?i.message:String(i)}`,e,{cause:i})}try{const i=new TextDecoder().decode(r);return JSON.parse(i),new R_([new A_({"blueprint.json":i}),new F_({baseUrl:e,corsProxy:t.corsProxy})])}catch(i){if(await qv(r))return Bv(r);throw new Error(`Blueprint file at ${e} is neither a valid JSON nor a ZIP file.`,{cause:i})}}function Uv(e){const t=e.map(i=>Mr(i));if(t.some(i=>fl(i)==="blueprint.json"&&Bn(i)===""))return"blueprint.json";const r=new Set;for(const i of t){const a=i.split("/")[0];a&&a!==fl(i)&&a!=="__MACOSX"&&r.add(a)}if(r.size>1)throw new Error("ZIP contains multiple top-level directories. Bundle ZIPs must contain blueprint.json at the root or inside a single top-level directory.");if(r.size===1){const a=`${[...r][0]}/blueprint.json`;if(t.includes(a))return a}throw new Error("ZIP does not contain a blueprint.json. Place blueprint.json at the ZIP root or inside a single top-level directory.")}async function Bv(e){const t=di.fromArrayBuffer(e),r=await t.getAllFilePaths(),i=Uv(r),a=Bn(i);return a===""?t:new $_(a,t)}async function qv(e){if(e.byteLength<4)return!1;const t=new Uint8Array(e,0,4);return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4}async function Xd(e){if((await dn.create(e)).getVersion()===1){const r=await Li(e);return{wpVersion:r.versions.wp,phpVersion:r.versions.php,intl:r.features.intl,networking:r.features.networking,extraLibraries:r.extraLibraries,constants:{}}}else return{phpVersion:sv,wpVersion:"latest",intl:!1,networking:!0,constants:{},extraLibraries:[]}}function Mv(){}const Wv=[],Hv="127.0.0.1",zv=4400;class Vv{constructor(t){this.options=t}async bootPlayground(t,r){var S;const{onBlueprintValidated:i,onBlueprintStepCompleted:a,corsProxy:s,gitAdditionalHeadersCallback:n,mounts:o,sapiName:l,scope:p,shouldInstallWordPress:c,shouldBootWordPress:d,sqliteDriverVersion:m,wordpressInstallMode:y,onClientConnected:T,pathAliases:g}=this.options,w=r.stage(.5),_=r.stage(),O=this.options.blueprint||{},E=lc(t.contentWindow,t.ownerDocument.defaultView);await E.isConnected(),r.pipe(E);const I=await Xd(O);await E.onDownloadProgress(_.loadingListener);const $=!Ii(O)&&((S=O.preferredVersions)==null?void 0:S.wp)===!1;if((c===!0||d===!0)&&$)throw new Error("Conflicting options: WordPress install or boot was requested, but the Blueprint sets `preferredVersions.wp: false`. Pick one.");const L=d??!$,C=c??L;if(C&&!L)throw new Error("Conflicting options: WordPress installation was requested, but WordPress boot was disabled. Pick one.");if(await E.boot({mounts:o,sapiName:l,scope:p??Math.random().toFixed(16),shouldInstallWordPress:C,shouldBootWordPress:L,wordpressInstallMode:y,phpVersion:I.phpVersion,wpVersion:I.wpVersion,extensions:I.intl?["intl"]:[],withNetworking:I.networking,corsProxyUrl:s,sqliteDriverVersion:m,pathAliases:g}),await E.isReady(),_.finish(),Vp(Te,E),T==null||T(E),(await dn.create(O)).getVersion()===1){const j=await Li(O,{progress:w,onStepCompleted:a,onBlueprintValidated:i,corsProxy:s,gitAdditionalHeadersCallback:n});await nl(j,E)}const F=parseFloat(I.wpVersion),P=Number.isFinite(F)&&F<5.1;return I.networking&&!P&&C&&await E.prefetchUpdateChecks(),E}}class Zv{constructor(t){this.options=t}async bootPlayground(t,r){const{blueprint:i,onClientConnected:a,corsProxy:s,mounts:n,sapiName:o,scope:l,pathAliases:p}=this.options,c=r.stage(.25),d=r.stage(.75),m=lc(t.contentWindow,t.ownerDocument.defaultView);return await m.isConnected(),r.pipe(m),await m.onDownloadProgress(c.loadingListener),await m.addEventListener("blueprint.message",({message:y})=>{switch(y.type){case"blueprint.target_resolved":break;case"blueprint.progress":{d.set(y.progress),d.setCaption(y.caption);break}case"blueprint.error":{const T="\x1B[31m",g="\x1B[1m",w="\x1B[0m";throw y.details?Te.error(`${T}${g}Fatal error:${w} Uncaught ${y.details.exception}: ${y.details.message}
|
|
1476
1476
|
at ${y.details.file}:${y.details.line}
|
|
1477
1477
|
`+(y.details.trace?y.details.trace+`
|
|
1478
1478
|
`:"")):Te.error(`${T}${g}Error:${w} ${y.message}
|
package/index.d.ts
CHANGED
|
@@ -5156,13 +5156,17 @@ export declare class BlueprintFetchError extends Error {
|
|
|
5156
5156
|
readonly url: string;
|
|
5157
5157
|
constructor(message: string, url: string, options?: ErrorOptions);
|
|
5158
5158
|
}
|
|
5159
|
+
export interface ResolveRemoteBlueprintOptions {
|
|
5160
|
+
fetch?: typeof fetch;
|
|
5161
|
+
corsProxy?: string;
|
|
5162
|
+
}
|
|
5159
5163
|
/**
|
|
5160
5164
|
* Resolves a remote blueprint from a URL.
|
|
5161
5165
|
*
|
|
5162
5166
|
* @param url - The URL of the blueprint to resolve.
|
|
5163
5167
|
* @returns A promise that resolves to the resolved blueprint.
|
|
5164
5168
|
*/
|
|
5165
|
-
export declare function resolveRemoteBlueprint(url: string): Promise<BlueprintBundle>;
|
|
5169
|
+
export declare function resolveRemoteBlueprint(url: string, options?: ResolveRemoteBlueprintOptions): Promise<BlueprintBundle>;
|
|
5166
5170
|
export declare function resolveRuntimeConfiguration(blueprint: Blueprint): Promise<RuntimeConfiguration>;
|
|
5167
5171
|
/**
|
|
5168
5172
|
* @deprecated This function is a no-op. Playground no longer uses a proxy to download plugins and themes.
|
package/index.js
CHANGED
|
@@ -28420,44 +28420,47 @@ class Fv extends Error {
|
|
|
28420
28420
|
super(t, i), this.name = "BlueprintFetchError", this.url = r;
|
|
28421
28421
|
}
|
|
28422
28422
|
}
|
|
28423
|
-
async function Kv(e) {
|
|
28424
|
-
let
|
|
28423
|
+
async function Kv(e, t = {}) {
|
|
28424
|
+
let r;
|
|
28425
28425
|
try {
|
|
28426
|
-
const
|
|
28426
|
+
const a = await (t.fetch || fetch)(e, {
|
|
28427
28427
|
credentials: "omit"
|
|
28428
28428
|
});
|
|
28429
|
-
if (!
|
|
28429
|
+
if (!a.ok)
|
|
28430
28430
|
throw new Error(`Failed to fetch blueprint from ${e}`);
|
|
28431
|
-
|
|
28432
|
-
} catch (
|
|
28431
|
+
r = await a.arrayBuffer();
|
|
28432
|
+
} catch (i) {
|
|
28433
28433
|
throw new Fv(
|
|
28434
|
-
`Blueprint file could not be resolved from ${e}: ${
|
|
28434
|
+
`Blueprint file could not be resolved from ${e}: ${i instanceof Error ? i.message : String(i)}`,
|
|
28435
28435
|
e,
|
|
28436
|
-
{ cause:
|
|
28436
|
+
{ cause: i }
|
|
28437
28437
|
);
|
|
28438
28438
|
}
|
|
28439
28439
|
try {
|
|
28440
|
-
const
|
|
28441
|
-
return JSON.parse(
|
|
28440
|
+
const i = new TextDecoder().decode(r);
|
|
28441
|
+
return JSON.parse(i), new Jb([
|
|
28442
28442
|
new Kb({
|
|
28443
|
-
"blueprint.json":
|
|
28443
|
+
"blueprint.json": i
|
|
28444
28444
|
}),
|
|
28445
28445
|
new Qb({
|
|
28446
|
-
baseUrl: e
|
|
28446
|
+
baseUrl: e,
|
|
28447
|
+
corsProxy: t.corsProxy
|
|
28447
28448
|
})
|
|
28448
28449
|
]);
|
|
28449
|
-
} catch (
|
|
28450
|
-
if (await Cv(
|
|
28451
|
-
return Iv(
|
|
28450
|
+
} catch (i) {
|
|
28451
|
+
if (await Cv(r))
|
|
28452
|
+
return Iv(r);
|
|
28452
28453
|
throw new Error(
|
|
28453
28454
|
`Blueprint file at ${e} is neither a valid JSON nor a ZIP file.`,
|
|
28454
|
-
{ cause:
|
|
28455
|
+
{ cause: i }
|
|
28455
28456
|
);
|
|
28456
28457
|
}
|
|
28457
28458
|
}
|
|
28458
28459
|
function Lv(e) {
|
|
28459
28460
|
const t = e.map((i) => qr(i));
|
|
28460
|
-
if (t.some(
|
|
28461
|
+
if (t.some(
|
|
28462
|
+
(i) => Jo(i) === "blueprint.json" && Un(i) === ""
|
|
28463
|
+
))
|
|
28461
28464
|
return "blueprint.json";
|
|
28462
28465
|
const r = /* @__PURE__ */ new Set();
|
|
28463
28466
|
for (const i of t) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/client",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.30",
|
|
4
4
|
"description": "WordPress Playground client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"main": "./index.cjs",
|
|
39
39
|
"module": "./index.js",
|
|
40
40
|
"types": "index.d.ts",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "1034030cf2893113dfc0d3a3ff79b1c60906cabe",
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=20.10.0",
|
|
44
44
|
"npm": ">=10.2.3"
|