File tree 2 files changed +0
-37
lines changed
content/tutorial/common/src
src/routes/tutorial/[slug] 2 files changed +0
-37
lines changed Original file line number Diff line number Diff line change 1
- // Hack into the alert that's used in some tutorials and send a message prior to the alert,
2
- // else the parent thinks we lost contact and wrongfully reloads the page.
3
- // The drawback is that alert is no longer blocking, but no tutorial relies on this.
4
- const alert = window . alert ;
5
- window . alert = ( message ) => {
6
- parent . postMessage (
7
- {
8
- type : 'ping-pause'
9
- } ,
10
- '*'
11
- ) ;
12
- setTimeout ( ( ) => {
13
- alert ( message ) ;
14
- } ) ;
15
- } ;
16
-
17
1
window . addEventListener ( 'message' , async ( e ) => {
18
2
if ( e . data . type === 'fetch' ) {
19
3
const names = e . data . names ;
@@ -121,7 +105,6 @@ function ping() {
121
105
) ;
122
106
}
123
107
124
- setInterval ( ping , 100 ) ;
125
108
ping ( ) ;
126
109
127
110
if ( import . meta. hot ) {
Original file line number Diff line number Diff line change 34
34
};
35
35
});
36
36
37
- afterNavigate (() => {
38
- clearTimeout (timeout);
39
- });
40
-
41
- /** @type {any} */
42
- let timeout;
43
-
44
37
/** @param {MessageEvent} e */
45
38
async function handle_message (e ) {
46
39
if (e .origin !== $base) return ;
47
40
48
41
if (paused) return ;
49
42
50
43
if (e .data .type === ' ping' ) {
51
- path = e .data .data .path ?? path;
52
44
loading = false ;
53
-
54
- clearTimeout (timeout);
55
- timeout = setTimeout (() => {
56
- if (dev && ! iframe) return ;
57
-
58
- // we lost contact, refresh the page
59
- loading = true ;
60
- set_iframe_src ($base + path);
61
- loading = false ;
62
- }, 1000 );
63
- } else if (e .data .type === ' ping-pause' ) {
64
- clearTimeout (timeout);
65
45
} else if (e .data .type === ' warnings' ) {
66
46
warnings .update (($warnings ) => ({
67
47
... $warnings,
You can’t perform that action at this time.
0 commit comments