@@ -76,44 +76,68 @@ export function Editor() {
7676
7777 useEffect ( ( ) => {
7878 if ( focused && framework_config ) {
79- console . log ( "Editor: useEffect: focused" ) ;
80- designToCode ( {
81- input : {
82- id : focused . id ,
83- name : focused . name ,
84- entry : focused ,
85- repository : design . repository ,
86- } ,
87- framework : framework_config ,
88- asset_config : { asset_repository : MainImageRepository . instance } ,
89- build_config : {
90- ...config . default_build_configuration ,
91- disable_components : ! enable_components ,
92- } ,
93- } ) . then ( ( result ) => {
79+ const input = {
80+ id : focused . id ,
81+ name : focused . name ,
82+ entry : focused ,
83+ repository : design . repository ,
84+ } ;
85+ const build_config = {
86+ ...config . default_build_configuration ,
87+ disable_components : ! enable_components ,
88+ } ;
89+
90+ const on_result = ( result : Result ) => {
9491 setResult ( result ) ;
9592 if ( framework_config . framework == preview_runner_framework . framework ) {
9693 setPreview ( result ) ;
9794 }
98- } ) ;
95+ } ;
96+
97+ // build code without assets fetch
98+ designToCode ( {
99+ input : input ,
100+ framework : framework_config ,
101+ asset_config : { skip_asset_replacement : true } ,
102+ build_config : build_config ,
103+ } ) . then ( on_result ) ;
104+
105+ // build final code with asset fetch
106+ designToCode ( {
107+ input : input ,
108+ framework : framework_config ,
109+ asset_config : { asset_repository : MainImageRepository . instance } ,
110+ build_config : build_config ,
111+ } ) . then ( on_result ) ;
99112 }
100113 } , [ focused ?. id , framework_config ?. framework ] ) ;
101114
102115 useEffect ( ( ) => {
103116 if ( design ) {
104117 const { id, name } = design . entry ;
118+ const input = {
119+ id : id ,
120+ name : name ,
121+ entry : design . entry ,
122+ } ;
123+ const build_config = {
124+ ...config . default_build_configuration ,
125+ disable_components : true ,
126+ } ;
105127 // ----- for preview -----
106128 if ( framework_config ?. framework !== preview_runner_framework . framework ) {
107129 designToCode ( {
108- input : {
109- id : id ,
110- name : name ,
111- entry : design . entry ,
112- } ,
113- build_config : {
114- ...config . default_build_configuration ,
115- disable_components : true ,
116- } ,
130+ input : input ,
131+ build_config : build_config ,
132+ framework : preview_runner_framework ,
133+ asset_config : { skip_asset_replacement : true } ,
134+ } ) . then ( ( result ) => {
135+ setPreview ( result ) ;
136+ } ) ;
137+
138+ designToCode ( {
139+ input : input ,
140+ build_config : build_config ,
117141 framework : preview_runner_framework ,
118142 asset_config : { asset_repository : MainImageRepository . instance } ,
119143 } ) . then ( ( result ) => {
@@ -124,7 +148,6 @@ export function Editor() {
124148 } , [ design ?. id ] ) ;
125149
126150 const { code, scaffold, name : componentName } = result ?? { } ;
127- const _key_for_preview = design ?. id ;
128151
129152 return (
130153 < DefaultEditorWorkspaceLayout
0 commit comments