@sveltejs/kit 1.0.0-next.193 → 1.0.0-next.197

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.
@@ -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
- }, 50);
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,18 +656,33 @@ class Renderer {
655
656
  this._init(navigation_result);
656
657
  }
657
658
 
658
- if (!opts?.keepfocus) {
659
+ const { hash, scroll, keepfocus } = opts || {};
660
+
661
+ if (!keepfocus) {
662
+ getSelection()?.removeAllRanges();
659
663
  document.body.focus();
660
664
  }
661
665
 
662
- await 0;
666
+ const old_page_y_offset = Math.round(pageYOffset);
667
+ const old_max_page_y_offset = document.documentElement.scrollHeight - innerHeight;
663
668
 
664
- // After `await 0`, the onMount() function in the component executed.
665
- // If there was no scrolling happening (checked via pageYOffset),
666
- // continue on our custom scroll handling
667
- if (pageYOffset === 0 && opts) {
668
- const { hash, scroll } = opts;
669
+ await 0;
669
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) {
670
686
  const deep_linked = hash && document.getElementById(hash.slice(1));
671
687
  if (scroll) {
672
688
  scrollTo(scroll.x, scroll.y);
@@ -2,6 +2,7 @@
2
2
  * @param {Record<string, string | string[]>} headers
3
3
  * @param {string} key
4
4
  * @returns {string | undefined}
5
+ * @throws {Error}
5
6
  */
6
7
  function get_single_valued_header(headers, key) {
7
8
  const value = headers[key];
@@ -888,12 +888,7 @@ async function build_server(
888
888
 
889
889
  const default_config = {
890
890
  build: {
891
- target: 'es2020',
892
- rollupOptions: {
893
- output: {
894
- inlineDynamicImports: true
895
- }
896
- }
891
+ target: 'es2020'
897
892
  },
898
893
  server: {
899
894
  fs: {
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.193');
820
+ const prog = sade('svelte-kit').version('1.0.0-next.197');
821
821
 
822
822
  prog
823
823
  .command('dev')
@@ -851,14 +851,17 @@ prog
851
851
  watcher.vite.httpServer.address()
852
852
  );
853
853
 
854
- https = https || !!config.kit.vite().server?.https;
855
- open = open || !!config.kit.vite().server?.open;
854
+ const vite_config = config.kit.vite();
855
+
856
+ https = https || !!vite_config.server?.https;
857
+ open = open || !!vite_config.server?.open;
856
858
 
857
859
  welcome({
858
860
  port: address_info.port,
859
861
  host: address_info.address,
860
862
  https,
861
863
  open,
864
+ loose: vite_config.server?.fs?.strict === false,
862
865
  allow: watcher.allowed_directories(),
863
866
  cwd: watcher.cwd
864
867
  });
@@ -971,14 +974,15 @@ async function check_port(port) {
971
974
  * host: string;
972
975
  * https: boolean;
973
976
  * port: number;
977
+ * loose?: boolean;
974
978
  * allow?: string[];
975
979
  * cwd?: string;
976
980
  * }} param0
977
981
  */
978
- function welcome({ port, host, https, open, allow, cwd }) {
982
+ function welcome({ port, host, https, open, loose, allow, cwd }) {
979
983
  if (open) launch(port, https);
980
984
 
981
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.193'}\n`));
985
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.197'}\n`));
982
986
 
983
987
  const protocol = https ? 'https:' : 'http:';
984
988
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -996,7 +1000,9 @@ function welcome({ port, host, https, open, allow, cwd }) {
996
1000
 
997
1001
  if (exposed) {
998
1002
  console.log(` ${$.gray('network:')} ${protocol}//${$.bold(`${details.address}:${port}`)}`);
999
- if (allow?.length && cwd) {
1003
+ if (loose) {
1004
+ console.log(`\n ${$.yellow('Serving with vite.server.fs.strict: false. Note that all files on your machine will be accessible to anyone on your network.')}`);
1005
+ } else if (allow?.length && cwd) {
1000
1006
  console.log(`\n ${$.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => relative(cwd, a)).join(', '))}`);
1001
1007
  }
1002
1008
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.193",
3
+ "version": "1.0.0-next.197",
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",