@@ -8,12 +8,12 @@ import {
8
8
useMemo ,
9
9
useCallback
10
10
} from 'preact/hooks' ;
11
- import { useLocation } from 'preact-iso' ;
11
+ import { ErrorBoundary , useLocation } from 'preact-iso' ;
12
12
import { TutorialContext , SolutionContext } from './contexts' ;
13
13
import { ErrorOverlay } from '../repl/error-overlay' ;
14
14
import { parseStackTrace } from '../repl/errors' ;
15
15
import cx from '../../../lib/cx' ;
16
- import { useRepl } from '../../../lib/use- repl' ;
16
+ import { Repl } from '../../../lib/repl' ;
17
17
import { useLanguage } from '../../../lib/i18n' ;
18
18
import { Splitter } from '../../splitter' ;
19
19
import config from '../../../config.json' ;
@@ -61,8 +61,6 @@ export function Tutorial({ html, meta }) {
61
61
// TODO: Needs some work for prerendering to not cause pop-in
62
62
if ( typeof window === 'undefined' ) return null ;
63
63
64
- const { CodeEditor, Runner } = useRepl ( ) ;
65
-
66
64
useEffect ( ( ) => {
67
65
if ( meta . tutorial ?. initial && editorCode !== meta . tutorial . initial ) {
68
66
setEditorCode ( meta . tutorial . initial ) ;
@@ -145,74 +143,76 @@ export function Tutorial({ html, meta }) {
145
143
showCode && style . showCode
146
144
) }
147
145
>
148
- < Splitter
149
- orientation = "horizontal"
150
- force = { ! showCode ? '100%' : undefined }
151
- other = {
152
- < Splitter
153
- orientation = "vertical"
154
- other = {
155
- < >
156
- < div class = { style . output } >
157
- { error && (
158
- < ErrorOverlay
159
- name = { error . name }
160
- message = { error . message }
161
- stack = { parseStackTrace ( error ) }
146
+ < ErrorBoundary >
147
+ < Splitter
148
+ orientation = "horizontal"
149
+ force = { ! showCode ? '100%' : undefined }
150
+ other = {
151
+ < Splitter
152
+ orientation = "vertical"
153
+ other = {
154
+ < >
155
+ < div class = { style . output } >
156
+ { error && (
157
+ < ErrorOverlay
158
+ name = { error . name }
159
+ message = { error . message }
160
+ stack = { parseStackTrace ( error ) }
161
+ />
162
+ ) }
163
+ < Repl . Runner
164
+ ref = { runner }
165
+ onSuccess = { onSuccess }
166
+ onRealm = { onRealm }
167
+ onError = { onError }
168
+ code = { runnerCode }
162
169
/>
170
+ </ div >
171
+ { hasCode && (
172
+ < button
173
+ class = { style . toggleCode }
174
+ title = "Toggle Code"
175
+ onClick = { toggleCode }
176
+ >
177
+ < span > Toggle Code</ span >
178
+ </ button >
163
179
) }
164
- < Runner
165
- ref = { runner }
166
- onSuccess = { onSuccess }
167
- onRealm = { onRealm }
168
- onError = { onError }
169
- code = { runnerCode }
170
- />
171
- </ div >
172
- { hasCode && (
173
- < button
174
- class = { style . toggleCode }
175
- title = "Toggle Code"
176
- onClick = { toggleCode }
177
- >
178
- < span > Toggle Code</ span >
179
- </ button >
180
- ) }
181
- </ >
182
- }
183
- >
184
- < div class = { style . codeWindow } >
185
- < CodeEditor
186
- class = { style . code }
187
- value = { editorCode }
188
- error = { error }
189
- slug = { url }
190
- onInput = { setEditorCode }
191
- />
192
- </ div >
193
- </ Splitter >
194
- }
195
- >
196
- < div class = { style . tutorialWindow } ref = { content } >
197
- < MarkdownRegion
198
- html = { html }
199
- meta = { meta }
200
- components = { TUTORIAL_COMPONENTS }
201
- />
202
-
203
- { meta . tutorial ?. setup &&
204
- < TutorialSetupBlock
205
- code = { meta . tutorial . setup }
206
- runner = { runner }
207
- useResult = { useResult }
208
- useRealm = { useRealm }
209
- useError = { useError }
210
- />
180
+ </ >
181
+ }
182
+ >
183
+ < div class = { style . codeWindow } >
184
+ < Repl . CodeEditor
185
+ class = { style . code }
186
+ value = { editorCode }
187
+ error = { error }
188
+ slug = { url }
189
+ onInput = { setEditorCode }
190
+ />
191
+ </ div >
192
+ </ Splitter >
211
193
}
194
+ >
195
+ < div class = { style . tutorialWindow } ref = { content } >
196
+ < MarkdownRegion
197
+ html = { html }
198
+ meta = { meta }
199
+ components = { TUTORIAL_COMPONENTS }
200
+ />
201
+
202
+ { meta . tutorial ?. setup &&
203
+ < TutorialSetupBlock
204
+ code = { meta . tutorial . setup }
205
+ runner = { runner }
206
+ useResult = { useResult }
207
+ useRealm = { useRealm }
208
+ useError = { useError }
209
+ />
210
+ }
212
211
213
- < ButtonContainer meta = { meta } showCode = { showCode } help = { help } />
214
- </ div >
215
- </ Splitter >
212
+ < ButtonContainer meta = { meta } showCode = { showCode } help = { help } />
213
+ </ div >
214
+ </ Splitter >
215
+ </ ErrorBoundary >
216
216
</ div >
217
217
</ TutorialContext . Provider >
218
218
) ;
0 commit comments