@sveltejs/kit 1.0.0-next.194 → 1.0.0-next.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/runtime/internal/start.js +37 -27
- package/dist/chunks/http.js +1 -0
- package/dist/chunks/index3.js +1 -6
- package/dist/cli.js +2 -2
- package/dist/ssr.js +6 -1
- package/package.json +1 -3
|
@@ -93,7 +93,8 @@ class Router {
|
|
|
93
93
|
'sveltekit:scroll': scroll_state()
|
|
94
94
|
};
|
|
95
95
|
history.replaceState(new_state, document.title, window.location.href);
|
|
96
|
-
|
|
96
|
+
// iOS scroll event intervals happen between 30-150ms, sometimes around 200ms
|
|
97
|
+
}, 200);
|
|
97
98
|
});
|
|
98
99
|
|
|
99
100
|
/** @param {MouseEvent|TouchEvent} event */
|
|
@@ -655,34 +656,43 @@ class Renderer {
|
|
|
655
656
|
this._init(navigation_result);
|
|
656
657
|
}
|
|
657
658
|
|
|
658
|
-
|
|
659
|
-
await 0;
|
|
660
|
-
} else {
|
|
661
|
-
const { hash, scroll, keepfocus } = opts;
|
|
659
|
+
const { hash, scroll, keepfocus } = opts || {};
|
|
662
660
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
661
|
+
if (!keepfocus) {
|
|
662
|
+
getSelection()?.removeAllRanges();
|
|
663
|
+
document.body.focus();
|
|
664
|
+
}
|
|
666
665
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
666
|
+
const old_page_y_offset = Math.round(pageYOffset);
|
|
667
|
+
const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
668
|
+
|
|
669
|
+
await 0;
|
|
670
|
+
|
|
671
|
+
const new_page_y_offset = Math.round(pageYOffset);
|
|
672
|
+
const new_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
|
|
673
|
+
|
|
674
|
+
// After `await 0`, the `onMount()` function in the component executed.
|
|
675
|
+
// Check if no scrolling happened on mount.
|
|
676
|
+
const no_scroll_happened =
|
|
677
|
+
// In most cases, we can compare whether `pageYOffset` changed between navigation
|
|
678
|
+
new_page_y_offset === Math.min(old_page_y_offset, new_max_page_y_offset) ||
|
|
679
|
+
// But if the page is scrolled to/near the bottom, the browser would also scroll
|
|
680
|
+
// to/near the bottom of the new page on navigation. Since we can't detect when this
|
|
681
|
+
// behaviour happens, we naively compare by the y offset from the bottom of the page.
|
|
682
|
+
old_max_page_y_offset - old_page_y_offset === new_max_page_y_offset - new_page_y_offset;
|
|
683
|
+
|
|
684
|
+
// If there was no scrolling, we run on our custom scroll handling
|
|
685
|
+
if (no_scroll_happened) {
|
|
686
|
+
const deep_linked = hash && document.getElementById(hash.slice(1));
|
|
687
|
+
if (scroll) {
|
|
688
|
+
scrollTo(scroll.x, scroll.y);
|
|
689
|
+
} else if (deep_linked) {
|
|
690
|
+
// Here we use `scrollIntoView` on the element instead of `scrollTo`
|
|
691
|
+
// because it natively supports the `scroll-margin` and `scroll-behavior`
|
|
692
|
+
// CSS properties.
|
|
693
|
+
deep_linked.scrollIntoView();
|
|
694
|
+
} else {
|
|
695
|
+
scrollTo(0, 0);
|
|
686
696
|
}
|
|
687
697
|
}
|
|
688
698
|
|
package/dist/chunks/http.js
CHANGED
package/dist/chunks/index3.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -817,7 +817,7 @@ async function launch(port, https) {
|
|
|
817
817
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
820
|
+
const prog = sade('svelte-kit').version('1.0.0-next.198');
|
|
821
821
|
|
|
822
822
|
prog
|
|
823
823
|
.command('dev')
|
|
@@ -982,7 +982,7 @@ async function check_port(port) {
|
|
|
982
982
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
983
983
|
if (open) launch(port, https);
|
|
984
984
|
|
|
985
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
985
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.198'}\n`));
|
|
986
986
|
|
|
987
987
|
const protocol = https ? 'https:' : 'http:';
|
|
988
988
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/dist/ssr.js
CHANGED
|
@@ -587,6 +587,9 @@ async function render_response({
|
|
|
587
587
|
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style>
|
|
588
588
|
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
|
|
589
589
|
<script async src="https://cdn.ampproject.org/v0.js"></script>`;
|
|
590
|
+
init += options.service_worker
|
|
591
|
+
? '<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"></script>'
|
|
592
|
+
: '';
|
|
590
593
|
} else if (include_js) {
|
|
591
594
|
// prettier-ignore
|
|
592
595
|
init = `<script type="module">
|
|
@@ -625,7 +628,9 @@ async function render_response({
|
|
|
625
628
|
}
|
|
626
629
|
|
|
627
630
|
if (options.service_worker) {
|
|
628
|
-
init +=
|
|
631
|
+
init += options.amp
|
|
632
|
+
? `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`
|
|
633
|
+
: `<script>
|
|
629
634
|
if ('serviceWorker' in navigator) {
|
|
630
635
|
navigator.serviceWorker.register('${options.service_worker}');
|
|
631
636
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.198",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"@types/marked": "^3.0.1",
|
|
22
22
|
"@types/mime": "^2.0.3",
|
|
23
23
|
"@types/node": "^16.10.3",
|
|
24
|
-
"@types/rimraf": "^3.0.2",
|
|
25
24
|
"@types/sade": "^1.7.3",
|
|
26
25
|
"amphtml-validator": "^1.0.35",
|
|
27
26
|
"cookie": "^0.4.1",
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
"mime": "^2.5.2",
|
|
34
33
|
"node-fetch": "^3.0.0",
|
|
35
34
|
"port-authority": "^1.1.2",
|
|
36
|
-
"rimraf": "^3.0.2",
|
|
37
35
|
"rollup": "^2.58.0",
|
|
38
36
|
"selfsigned": "^1.10.11",
|
|
39
37
|
"sirv": "^1.0.17",
|