|
164 | 164 | { |
165 | 165 | const { mount, unmount, App } = __repl_exports; |
166 | 166 |
|
| 167 | + const render_app = () => { |
| 168 | + const component = mount(App, { target: document.body }); |
167 | 169 |
|
168 | | - window.initialize = () => { |
169 | | - var script = document.createElement('script'); |
170 | | - script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/public/target.js'; |
171 | | - script.setAttribute('embedded', 'true'); |
172 | | - script.setAttribute('cdn', 'https://cdn.jsdelivr.net/npm/chii/public'); |
173 | | - document.head.appendChild(script); |
| 170 | + window.__unmount_previous = () => { |
| 171 | + unmount(component); |
| 172 | + } |
| 173 | + }; |
174 | 174 |
|
175 | | - script.onload = () => { |
176 | | - const component = mount(App, { target: document.body }); |
| 175 | + if (!window.initialize) { |
| 176 | + window.initialize = () => { |
| 177 | + var script = document.createElement('script'); |
| 178 | + script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/public/target.js'; |
| 179 | + script.setAttribute('embedded', 'true'); |
| 180 | + script.setAttribute('cdn', 'https://cdn.jsdelivr.net/npm/chii/public'); |
| 181 | + document.head.appendChild(script); |
177 | 182 |
|
178 | | - window.__unmount_previous = () => { |
179 | | - unmount(component); |
180 | | - } |
| 183 | + script.onload = render_app; |
181 | 184 | }; |
182 | | - }; |
183 | 185 |
|
184 | | - setTimeout(() => { |
185 | | - window.dispatchEvent(new Event('preview_ready')); |
186 | | - }, 0); |
| 186 | + setTimeout(() => { |
| 187 | + window.dispatchEvent(new Event('preview_ready')); |
| 188 | + }, 0); |
| 189 | + } else { |
| 190 | + render_app(); |
| 191 | + } |
| 192 | +
|
187 | 193 | } |
188 | 194 | //# sourceURL=playground:output |
189 | 195 | `); |
|
0 commit comments