@sveltejs/kit 1.0.0-next.202 → 1.0.0-next.203

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.
@@ -99,7 +99,7 @@ class Router {
99
99
  }, 200);
100
100
  });
101
101
 
102
- /** @param {MouseEvent|TouchEvent} event */
102
+ /** @param {Event} event */
103
103
  const trigger_prefetch = (event) => {
104
104
  const a = find_anchor(event);
105
105
  if (a && a.href && a.hasAttribute('sveltekit:prefetch')) {
@@ -114,12 +114,17 @@ class Router {
114
114
  const handle_mousemove = (event) => {
115
115
  clearTimeout(mousemove_timeout);
116
116
  mousemove_timeout = setTimeout(() => {
117
- trigger_prefetch(event);
117
+ // event.composedPath(), which is used in find_anchor, will be empty if the event is read in a timeout
118
+ // add a layer of indirection to address that
119
+ event.target?.dispatchEvent(
120
+ new CustomEvent('sveltekit:trigger_prefetch', { bubbles: true })
121
+ );
118
122
  }, 20);
119
123
  };
120
124
 
121
125
  addEventListener('touchstart', trigger_prefetch);
122
126
  addEventListener('mousemove', handle_mousemove);
127
+ addEventListener('sveltekit:trigger_prefetch', trigger_prefetch);
123
128
 
124
129
  /** @param {MouseEvent} event */
125
130
  addEventListener('click', (event) => {
@@ -498,7 +498,7 @@ function create_manifest_data({ config, output, cwd = process.cwd() }) {
498
498
  basename,
499
499
  ext,
500
500
  parts,
501
- file: posixify(file),
501
+ file,
502
502
  is_dir,
503
503
  is_index,
504
504
  is_page,
@@ -670,9 +670,10 @@ function comparator(a, b) {
670
670
  if (!a_sub_part) return 1; // b is more specific, so goes first
671
671
  if (!b_sub_part) return -1;
672
672
 
673
- // if spread && index, order later
673
+ // if spread, order later
674
674
  if (a_sub_part.spread && b_sub_part.spread) {
675
- return a.is_index ? 1 : -1;
675
+ // sort alphabetically
676
+ return a_sub_part.content < b_sub_part.content ? -1 : 1;
676
677
  }
677
678
 
678
679
  // If one is ...spread order it later
package/dist/cli.js CHANGED
@@ -822,7 +822,7 @@ async function launch(port, https) {
822
822
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
823
823
  }
824
824
 
825
- const prog = sade('svelte-kit').version('1.0.0-next.202');
825
+ const prog = sade('svelte-kit').version('1.0.0-next.203');
826
826
 
827
827
  prog
828
828
  .command('dev')
@@ -987,7 +987,7 @@ async function check_port(port) {
987
987
  function welcome({ port, host, https, open, loose, allow, cwd }) {
988
988
  if (open) launch(port, https);
989
989
 
990
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.202'}\n`));
990
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.203'}\n`));
991
991
 
992
992
  const protocol = https ? 'https:' : 'http:';
993
993
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/dist/ssr.js CHANGED
@@ -627,10 +627,8 @@ async function render_response({
627
627
  </script>`;
628
628
  }
629
629
 
630
- if (options.service_worker) {
631
- init += options.amp
632
- ? `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`
633
- : `<script>
630
+ if (options.service_worker && !options.amp) {
631
+ init += `<script>
634
632
  if ('serviceWorker' in navigator) {
635
633
  navigator.serviceWorker.register('${options.service_worker}');
636
634
  }
@@ -646,21 +644,23 @@ async function render_response({
646
644
  init
647
645
  ].join('\n\n\t\t');
648
646
 
649
- const body = options.amp
650
- ? rendered.html
651
- : `${rendered.html}
652
-
653
- ${serialized_data
654
- .map(({ url, body, json }) => {
655
- let attributes = `type="application/json" data-type="svelte-data" data-url=${escape_html_attr(
656
- url
657
- )}`;
658
- if (body) attributes += ` data-body="${hash(body)}"`;
659
-
660
- return `<script ${attributes}>${json}</script>`;
661
- })
662
- .join('\n\n\t')}
663
- `;
647
+ let body = rendered.html;
648
+ if (options.amp) {
649
+ if (options.service_worker) {
650
+ body += `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`;
651
+ }
652
+ } else {
653
+ body += serialized_data
654
+ .map(({ url, body, json }) => {
655
+ let attributes = `type="application/json" data-type="svelte-data" data-url=${escape_html_attr(
656
+ url
657
+ )}`;
658
+ if (body) attributes += ` data-body="${hash(body)}"`;
659
+
660
+ return `<script ${attributes}>${json}</script>`;
661
+ })
662
+ .join('\n\n\t');
663
+ }
664
664
 
665
665
  /** @type {import('types/helper').ResponseHeaders} */
666
666
  const headers = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.202",
3
+ "version": "1.0.0-next.203",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -10,7 +10,7 @@
10
10
  "homepage": "https://kit.svelte.dev",
11
11
  "type": "module",
12
12
  "dependencies": {
13
- "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
13
+ "@sveltejs/vite-plugin-svelte": "^1.0.0-next.32",
14
14
  "cheap-watch": "^1.0.4",
15
15
  "sade": "^1.7.4",
16
16
  "vite": "^2.7.2"
@@ -87,5 +87,6 @@
87
87
  "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
88
88
  "test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
89
89
  "test:integration": "uvu test test.js"
90
- }
90
+ },
91
+ "readme": "# The fastest way to build Svelte apps\n\nThis is the [SvelteKit](https://kit.svelte.dev) framework and CLI.\n\nThe quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) package:\n\n```bash\nnpm init svelte@next my-app\ncd my-app\nnpm install\nnpm run dev\n```\n\nSee the [documentation](https://kit.svelte.dev/docs) to learn more.\n\n## Changelog\n\n[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).\n"
91
92
  }