@sveltejs/kit 1.0.0-next.23 → 1.0.0-next.230

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.
Files changed (83) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +81 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/{runtime/app → app}/stores.js +19 -15
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +18 -0
  8. package/assets/client/start.js +1382 -0
  9. package/assets/components/error.svelte +19 -3
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +1998 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/index.js +2391 -0
  15. package/dist/chunks/index2.js +807 -0
  16. package/dist/chunks/index3.js +648 -0
  17. package/dist/chunks/index4.js +109 -0
  18. package/dist/chunks/index5.js +754 -0
  19. package/dist/chunks/index6.js +830 -0
  20. package/dist/chunks/index7.js +15574 -0
  21. package/dist/chunks/index8.js +4207 -0
  22. package/dist/chunks/misc.js +3 -0
  23. package/dist/chunks/multipart-parser.js +449 -0
  24. package/dist/chunks/url.js +62 -0
  25. package/dist/cli.js +1039 -84
  26. package/dist/hooks.js +28 -0
  27. package/dist/install-fetch.js +6514 -0
  28. package/dist/node.js +51 -0
  29. package/package.json +93 -54
  30. package/svelte-kit.js +2 -0
  31. package/types/ambient-modules.d.ts +204 -0
  32. package/types/app.d.ts +45 -0
  33. package/types/config.d.ts +169 -0
  34. package/types/endpoint.d.ts +20 -0
  35. package/types/helper.d.ts +53 -0
  36. package/types/hooks.d.ts +55 -0
  37. package/types/index.d.ts +18 -0
  38. package/types/internal.d.ts +237 -0
  39. package/types/page.d.ts +73 -0
  40. package/CHANGELOG.md +0 -294
  41. package/assets/runtime/app/navigation.js +0 -23
  42. package/assets/runtime/app/navigation.js.map +0 -1
  43. package/assets/runtime/app/paths.js +0 -2
  44. package/assets/runtime/app/paths.js.map +0 -1
  45. package/assets/runtime/app/stores.js.map +0 -1
  46. package/assets/runtime/internal/singletons.js +0 -15
  47. package/assets/runtime/internal/singletons.js.map +0 -1
  48. package/assets/runtime/internal/start.js +0 -591
  49. package/assets/runtime/internal/start.js.map +0 -1
  50. package/assets/runtime/utils-85ebcc60.js +0 -18
  51. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  52. package/dist/api.js +0 -44
  53. package/dist/api.js.map +0 -1
  54. package/dist/build.js +0 -246
  55. package/dist/build.js.map +0 -1
  56. package/dist/cli.js.map +0 -1
  57. package/dist/colors.js +0 -37
  58. package/dist/colors.js.map +0 -1
  59. package/dist/create_app.js +0 -578
  60. package/dist/create_app.js.map +0 -1
  61. package/dist/index.js +0 -367
  62. package/dist/index.js.map +0 -1
  63. package/dist/index2.js +0 -12044
  64. package/dist/index2.js.map +0 -1
  65. package/dist/index3.js +0 -547
  66. package/dist/index3.js.map +0 -1
  67. package/dist/index4.js +0 -73
  68. package/dist/index4.js.map +0 -1
  69. package/dist/index5.js +0 -464
  70. package/dist/index5.js.map +0 -1
  71. package/dist/index6.js +0 -729
  72. package/dist/index6.js.map +0 -1
  73. package/dist/logging.js +0 -43
  74. package/dist/logging.js.map +0 -1
  75. package/dist/package.js +0 -432
  76. package/dist/package.js.map +0 -1
  77. package/dist/renderer.js +0 -2391
  78. package/dist/renderer.js.map +0 -1
  79. package/dist/standard.js +0 -101
  80. package/dist/standard.js.map +0 -1
  81. package/dist/utils.js +0 -54
  82. package/dist/utils.js.map +0 -1
  83. package/svelte-kit +0 -3
package/README.md CHANGED
@@ -1,15 +1,18 @@
1
- # @sveltejs/kit
1
+ # The fastest way to build Svelte apps
2
2
 
3
- Here be dragons, etc etc.
3
+ This is the [SvelteKit](https://kit.svelte.dev) framework and CLI.
4
4
 
5
- This project aims to replicate Sapper's functionality in its entirety, minus building for deployment (which can be handled by 'adapters' that do various opinionated things with the output of `snowpack build`).
5
+ The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) package:
6
6
 
7
- It's currently missing a ton of stuff but I figured I'd throw it up on GitHub anyway partly for the sake of 'working in the open' but mostly because I need an issue tracker to organise my thoughts.
7
+ ```bash
8
+ npm init svelte@next my-app
9
+ cd my-app
10
+ npm install
11
+ npm run dev
12
+ ```
8
13
 
9
- There are no tests yet or anything like that. Some of the code has just been straight copied over from the existing Sapper repo, but a pleasing amount of it can safely be left behind.
14
+ See the [documentation](https://kit.svelte.dev/docs) to learn more.
10
15
 
11
- ## Trying it out
16
+ ## Changelog
12
17
 
13
- Clone this repo, `npm install`, and `npm link`. That will create a global link to the `svelte` bin. You can then either `npm run build` or `npm run dev`, if you intend to make changes and see them immediately reflected.
14
-
15
- Then, clone the corresponding [svelte-app-demo](https://github.com/sveltejs/svelte-app-demo) repo and follow the instructions therein.
18
+ [The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
@@ -0,0 +1,20 @@
1
+ export { prerendering } from '../env.js';
2
+
3
+ /**
4
+ * @type {import('$app/env').browser}
5
+ */
6
+ const browser = !import.meta.env.SSR;
7
+ /**
8
+ * @type {import('$app/env').dev}
9
+ */
10
+ const dev = !!import.meta.env.DEV;
11
+ /**
12
+ * @type {import('$app/env').mode}
13
+ */
14
+ const mode = import.meta.env.MODE;
15
+ /**
16
+ * @type {import('$app/env').amp}
17
+ */
18
+ const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
19
+
20
+ export { amp, browser, dev, mode };
@@ -0,0 +1,81 @@
1
+ import { renderer, router as router$1 } from '../client/singletons.js';
2
+ import { g as get_base_uri } from '../chunks/utils.js';
3
+
4
+ const router = /** @type {import('../client/router').Router} */ (router$1);
5
+
6
+ /**
7
+ * @param {string} name
8
+ */
9
+ function guard(name) {
10
+ return () => {
11
+ throw new Error(`Cannot call ${name}(...) on the server`);
12
+ };
13
+ }
14
+
15
+ const disableScrollHandling = import.meta.env.SSR
16
+ ? guard('disableScrollHandling')
17
+ : disableScrollHandling_;
18
+ const goto = import.meta.env.SSR ? guard('goto') : goto_;
19
+ const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_;
20
+ const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
21
+ const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
22
+ const beforeNavigate = import.meta.env.SSR ? () => {} : beforeNavigate_;
23
+ const afterNavigate = import.meta.env.SSR ? () => {} : afterNavigate_;
24
+
25
+ /**
26
+ * @type {import('$app/navigation').goto}
27
+ */
28
+ async function disableScrollHandling_() {
29
+ renderer.disable_scroll_handling();
30
+ }
31
+
32
+ /**
33
+ * @type {import('$app/navigation').goto}
34
+ */
35
+ async function goto_(href, opts) {
36
+ return router.goto(href, opts, []);
37
+ }
38
+
39
+ /**
40
+ * @type {import('$app/navigation').invalidate}
41
+ */
42
+ async function invalidate_(resource) {
43
+ const { href } = new URL(resource, location.href);
44
+ return router.renderer.invalidate(href);
45
+ }
46
+
47
+ /**
48
+ * @type {import('$app/navigation').prefetch}
49
+ */
50
+ function prefetch_(href) {
51
+ return router.prefetch(new URL(href, get_base_uri(document)));
52
+ }
53
+
54
+ /**
55
+ * @type {import('$app/navigation').prefetchRoutes}
56
+ */
57
+ async function prefetchRoutes_(pathnames) {
58
+ const matching = pathnames
59
+ ? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
60
+ : router.routes;
61
+
62
+ const promises = matching.map((r) => Promise.all(r[1].map((load) => load())));
63
+
64
+ await Promise.all(promises);
65
+ }
66
+
67
+ /**
68
+ * @type {import('$app/navigation').beforeNavigate}
69
+ */
70
+ function beforeNavigate_(fn) {
71
+ if (router) router.before_navigate(fn);
72
+ }
73
+
74
+ /**
75
+ * @type {import('$app/navigation').afterNavigate}
76
+ */
77
+ function afterNavigate_(fn) {
78
+ if (router) router.after_navigate(fn);
79
+ }
80
+
81
+ export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
@@ -0,0 +1 @@
1
+ export { assets, base } from '../paths.js';
@@ -1,7 +1,6 @@
1
1
  import { getContext } from 'svelte';
2
-
3
- // const ssr = (import.meta as any).env.SSR;
4
- const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build?
2
+ import { browser } from './env.js';
3
+ import '../env.js';
5
4
 
6
5
  // TODO remove this (for 1.0? after 1.0?)
7
6
  let warned = false;
@@ -13,6 +12,9 @@ function stores() {
13
12
  return getStores();
14
13
  }
15
14
 
15
+ /**
16
+ * @type {import('$app/stores').getStores}
17
+ */
16
18
  const getStores = () => {
17
19
  const stores = getContext('__svelte__');
18
20
 
@@ -23,6 +25,8 @@ const getStores = () => {
23
25
  navigating: {
24
26
  subscribe: stores.navigating.subscribe
25
27
  },
28
+ // TODO remove this (for 1.0? after 1.0?)
29
+ // @ts-expect-error - deprecated, not part of type definitions, but still callable
26
30
  get preloading() {
27
31
  console.error('stores.preloading is deprecated; use stores.navigating instead');
28
32
  return {
@@ -33,13 +37,16 @@ const getStores = () => {
33
37
  };
34
38
  };
35
39
 
40
+ /** @type {typeof import('$app/stores').page} */
36
41
  const page = {
42
+ /** @param {(value: any) => void} fn */
37
43
  subscribe(fn) {
38
44
  const store = getStores().page;
39
45
  return store.subscribe(fn);
40
46
  }
41
47
  };
42
48
 
49
+ /** @type {typeof import('$app/stores').navigating} */
43
50
  const navigating = {
44
51
  subscribe(fn) {
45
52
  const store = getStores().navigating;
@@ -47,32 +54,29 @@ const navigating = {
47
54
  }
48
55
  };
49
56
 
50
- const error = (verb) => {
57
+ /** @param {string} verb */
58
+ const throw_error = (verb) => {
51
59
  throw new Error(
52
- ssr
53
- ? `Can only ${verb} session store in browser`
54
- : `Cannot ${verb} session store before subscribing`
60
+ browser
61
+ ? `Cannot ${verb} session store before subscribing`
62
+ : `Can only ${verb} session store in browser`
55
63
  );
56
64
  };
57
65
 
66
+ /** @type {typeof import('$app/stores').session} */
58
67
  const session = {
59
68
  subscribe(fn) {
60
69
  const store = getStores().session;
61
70
 
62
- if (!ssr) {
71
+ if (browser) {
63
72
  session.set = store.set;
64
73
  session.update = store.update;
65
74
  }
66
75
 
67
76
  return store.subscribe(fn);
68
77
  },
69
- set: (value) => {
70
- error('set');
71
- },
72
- update: (updater) => {
73
- error('update');
74
- }
78
+ set: () => throw_error('set'),
79
+ update: () => throw_error('update')
75
80
  };
76
81
 
77
82
  export { getStores, navigating, page, session, stores };
78
- //# sourceMappingURL=stores.js.map
@@ -0,0 +1,13 @@
1
+ /** @param {HTMLDocument} doc */
2
+ function get_base_uri(doc) {
3
+ let baseURI = doc.baseURI;
4
+
5
+ if (!baseURI) {
6
+ const baseTags = doc.getElementsByTagName('base');
7
+ baseURI = baseTags.length ? baseTags[0].href : doc.URL;
8
+ }
9
+
10
+ return baseURI;
11
+ }
12
+
13
+ export { get_base_uri as g };
@@ -0,0 +1,18 @@
1
+ /** @type {import('./router').Router?} */
2
+ let router;
3
+
4
+ /** @type {import('./renderer').Renderer} */
5
+ let renderer;
6
+
7
+ /**
8
+ * @param {{
9
+ * router: import('./router').Router?;
10
+ * renderer: import('./renderer').Renderer;
11
+ * }} opts
12
+ */
13
+ function init(opts) {
14
+ router = opts.router;
15
+ renderer = opts.renderer;
16
+ }
17
+
18
+ export { init, renderer, router };