@@ -18,7 +18,8 @@ export class BlueprintsV2Handler {
1818sapiName,
1919scope,
2020} = this . options ;
21- const downloadProgress = progressTracker ! . stage ( ) ;
21+ const downloadProgress = progressTracker ! . stage ( 0.25 ) ;
22+ const executionProgress = progressTracker ! . stage ( 0.75 ) ;
2223
2324// Connect the Comlink API client to the remote worker,
2425// boot the playground, and run the blueprint steps.
@@ -31,6 +32,56 @@ export class BlueprintsV2Handler {
3132
3233// Connect the Comlink API client to the remote worker download monitor
3334await playground . onDownloadProgress ( downloadProgress . loadingListener ) ;
35+ await playground . addEventListener (
36+ 'blueprint.message' ,
37+ ( { message } : any ) => {
38+ switch ( message . type ) {
39+ case 'blueprint.target_resolved' : {
40+ // @TODO : Evaluate consistenty with the CLI worker
41+ // if (!this.blueprintTargetResolved) {
42+ // this.blueprintTargetResolved = true;
43+ // for (const php of this
44+ // .phpInstancesThatNeedMountsAfterTargetResolved) {
45+ // // console.log('mounting resources for php', php);
46+ // this.phpInstancesThatNeedMountsAfterTargetResolved.delete(
47+ // php
48+ // );
49+ // await mountResources(php, args.mount || []);
50+ // }
51+ // }
52+ break ;
53+ }
54+ case 'blueprint.progress' : {
55+ executionProgress . set ( message . progress ) ;
56+ executionProgress . setCaption ( message . caption ) ;
57+ break ;
58+ }
59+ case 'blueprint.error' : {
60+ // @TODO : Error reporting.
61+ const red = '\x1b[31m' ;
62+ const bold = '\x1b[1m' ;
63+ const reset = '\x1b[0m' ;
64+ if ( message . details ) {
65+ logger . error (
66+ `${ red } ${ bold } Fatal error:${ reset } Uncaught ${ message . details . exception } : ${ message . details . message } \n` +
67+ ` at ${ message . details . file } :${ message . details . line } \n` +
68+ ( message . details . trace
69+ ? message . details . trace + '\n'
70+ : '' )
71+ ) ;
72+ } else {
73+ logger . error (
74+ `${ red } ${ bold } Error:${ reset } ${ message . message } \n`
75+ ) ;
76+ }
77+
78+ // TODO: Should we report the error like that?
79+ throw new Error ( message . message ) ;
80+ break ;
81+ }
82+ }
83+ }
84+ ) ;
3485
3586await playground . boot ( {
3687mounts,
@@ -48,12 +99,16 @@ export class BlueprintsV2Handler {
4899collectPhpLogs ( logger , playground ) ;
49100onClientConnected ?.( playground ) ;
50101
102+ // @TODO : Get the landing page from the Blueprint.
103+ playground . goTo ( '/' ) ;
104+
51105/**
52106 * Pre-fetch WordPress update checks to speed up the initial wp-admin load.
53107 *
54108 * @see https://github.com/WordPress/wordpress-playground/pull/2295
55109 */
56- // @TODO
110+ // @TODO get the enabled features somehow – probably using the same
111+ // resolveRuntimeConfiguration() logic as the redux site-slice.ts
57112// if (compiled.features.networking) {
58113// await playground.prefetchUpdateChecks();
59114// }
0 commit comments