File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
sites/svelte-5-preview/src/routes Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 3
3
import ' @sveltejs/site-kit/styles/index.css' ;
4
4
5
5
import Repl from ' $lib/Repl.svelte' ;
6
- import { onMount } from ' svelte' ;
7
6
import { default_files } from ' ./defaults.js' ;
8
7
import { compress_and_encode_text , decode_and_decompress_text } from ' ./gzip.js' ;
8
+ import { afterNavigate } from ' $app/navigation' ;
9
9
10
10
/** @type {Repl} */
11
11
let repl;
12
12
13
13
let setting_hash = false ;
14
- let started = false ;
14
+ let navigating = false ;
15
15
16
- onMount (change_from_hash);
16
+ afterNavigate (change_from_hash);
17
17
18
18
async function change_from_hash () {
19
+ navigating = true ;
20
+
19
21
const hash = location .hash .slice (1 );
20
22
21
23
if (! hash) {
22
24
repl .set ({
23
- files: default_files
25
+ files: default_files ()
24
26
});
25
27
26
28
return ;
56
58
57
59
/** @param {CustomEvent<any>} e */
58
60
async function change_from_editor (e ) {
59
- if (! started ) {
60
- started = true ; // ignore initial change caused by the repl.set in change_from_hash
61
+ if (navigating ) {
62
+ navigating = false ;
61
63
return ;
62
64
}
63
65
76
78
</script >
77
79
78
80
<svelte:window
79
- on:hashchange ={(e ) => {
81
+ on:hashchange ={() => {
80
82
if (! setting_hash ) {
81
83
change_from_hash ();
82
84
}
Original file line number Diff line number Diff line change 1
- export const default_files = [
1
+ export const default_files = ( ) => [
2
2
{
3
3
name : 'App' ,
4
4
type : 'svelte' ,
You can’t perform that action at this time.
0 commit comments