@sveltejs/kit 1.0.0-next.28 → 1.0.0-next.282

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 (79) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +79 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +21 -0
  8. package/assets/client/start.js +1561 -0
  9. package/assets/components/error.svelte +18 -2
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +2759 -0
  13. package/dist/chunks/amp_hook.js +56 -0
  14. package/dist/chunks/build.js +658 -0
  15. package/dist/chunks/cert.js +28154 -0
  16. package/dist/chunks/index.js +473 -0
  17. package/dist/chunks/index2.js +836 -0
  18. package/dist/chunks/index3.js +643 -0
  19. package/dist/chunks/index4.js +120 -0
  20. package/dist/chunks/index5.js +881 -0
  21. package/dist/chunks/index6.js +170 -0
  22. package/dist/chunks/index7.js +15584 -0
  23. package/dist/chunks/index8.js +4207 -0
  24. package/dist/chunks/misc.js +3 -0
  25. package/dist/chunks/multipart-parser.js +449 -0
  26. package/dist/cli.js +1132 -86
  27. package/dist/hooks.js +28 -0
  28. package/dist/install-fetch.js +6518 -0
  29. package/dist/node.js +95 -0
  30. package/package.json +97 -54
  31. package/svelte-kit.js +2 -0
  32. package/types/ambient.d.ts +208 -0
  33. package/types/index.d.ts +391 -0
  34. package/types/internal.d.ts +372 -0
  35. package/CHANGELOG.md +0 -326
  36. package/assets/runtime/app/navigation.js +0 -23
  37. package/assets/runtime/app/navigation.js.map +0 -1
  38. package/assets/runtime/app/paths.js +0 -2
  39. package/assets/runtime/app/paths.js.map +0 -1
  40. package/assets/runtime/app/stores.js +0 -78
  41. package/assets/runtime/app/stores.js.map +0 -1
  42. package/assets/runtime/internal/singletons.js +0 -15
  43. package/assets/runtime/internal/singletons.js.map +0 -1
  44. package/assets/runtime/internal/start.js +0 -591
  45. package/assets/runtime/internal/start.js.map +0 -1
  46. package/assets/runtime/utils-85ebcc60.js +0 -18
  47. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  48. package/dist/api.js +0 -44
  49. package/dist/api.js.map +0 -1
  50. package/dist/build.js +0 -246
  51. package/dist/build.js.map +0 -1
  52. package/dist/cli.js.map +0 -1
  53. package/dist/colors.js +0 -37
  54. package/dist/colors.js.map +0 -1
  55. package/dist/create_app.js +0 -580
  56. package/dist/create_app.js.map +0 -1
  57. package/dist/index.js +0 -368
  58. package/dist/index.js.map +0 -1
  59. package/dist/index2.js +0 -12035
  60. package/dist/index2.js.map +0 -1
  61. package/dist/index3.js +0 -549
  62. package/dist/index3.js.map +0 -1
  63. package/dist/index4.js +0 -74
  64. package/dist/index4.js.map +0 -1
  65. package/dist/index5.js +0 -464
  66. package/dist/index5.js.map +0 -1
  67. package/dist/index6.js +0 -735
  68. package/dist/index6.js.map +0 -1
  69. package/dist/logging.js +0 -43
  70. package/dist/logging.js.map +0 -1
  71. package/dist/package.js +0 -432
  72. package/dist/package.js.map +0 -1
  73. package/dist/renderer.js +0 -2425
  74. package/dist/renderer.js.map +0 -1
  75. package/dist/standard.js +0 -101
  76. package/dist/standard.js.map +0 -1
  77. package/dist/utils.js +0 -58
  78. package/dist/utils.js.map +0 -1
  79. 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,79 @@
1
+ import { renderer, router } from '../client/singletons.js';
2
+ import { g as get_base_uri } from '../chunks/utils.js';
3
+
4
+ /**
5
+ * @param {string} name
6
+ */
7
+ function guard(name) {
8
+ return () => {
9
+ throw new Error(`Cannot call ${name}(...) on the server`);
10
+ };
11
+ }
12
+
13
+ const disableScrollHandling = import.meta.env.SSR
14
+ ? guard('disableScrollHandling')
15
+ : disableScrollHandling_;
16
+ const goto = import.meta.env.SSR ? guard('goto') : goto_;
17
+ const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_;
18
+ const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
19
+ const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
20
+ const beforeNavigate = import.meta.env.SSR ? () => {} : beforeNavigate_;
21
+ const afterNavigate = import.meta.env.SSR ? () => {} : afterNavigate_;
22
+
23
+ /**
24
+ * @type {import('$app/navigation').goto}
25
+ */
26
+ async function disableScrollHandling_() {
27
+ renderer.disable_scroll_handling();
28
+ }
29
+
30
+ /**
31
+ * @type {import('$app/navigation').goto}
32
+ */
33
+ async function goto_(href, opts) {
34
+ return router.goto(href, opts, []);
35
+ }
36
+
37
+ /**
38
+ * @type {import('$app/navigation').invalidate}
39
+ */
40
+ async function invalidate_(resource) {
41
+ const { href } = new URL(resource, location.href);
42
+ return router.renderer.invalidate(href);
43
+ }
44
+
45
+ /**
46
+ * @type {import('$app/navigation').prefetch}
47
+ */
48
+ async function prefetch_(href) {
49
+ await router.prefetch(new URL(href, get_base_uri(document)));
50
+ }
51
+
52
+ /**
53
+ * @type {import('$app/navigation').prefetchRoutes}
54
+ */
55
+ async function prefetchRoutes_(pathnames) {
56
+ const matching = pathnames
57
+ ? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
58
+ : router.routes;
59
+
60
+ const promises = matching.map((r) => Promise.all(r[1].map((load) => load())));
61
+
62
+ await Promise.all(promises);
63
+ }
64
+
65
+ /**
66
+ * @type {import('$app/navigation').beforeNavigate}
67
+ */
68
+ function beforeNavigate_(fn) {
69
+ if (router) router.before_navigate(fn);
70
+ }
71
+
72
+ /**
73
+ * @type {import('$app/navigation').afterNavigate}
74
+ */
75
+ function afterNavigate_(fn) {
76
+ if (router) router.after_navigate(fn);
77
+ }
78
+
79
+ export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
@@ -0,0 +1 @@
1
+ export { assets, base } from '../paths.js';
@@ -0,0 +1,97 @@
1
+ import { getContext } from 'svelte';
2
+ import { browser } from './env.js';
3
+ import '../env.js';
4
+
5
+ // TODO remove this (for 1.0? after 1.0?)
6
+ let warned = false;
7
+ function stores() {
8
+ if (!warned) {
9
+ console.error('stores() is deprecated; use getStores() instead');
10
+ warned = true;
11
+ }
12
+ return getStores();
13
+ }
14
+
15
+ /**
16
+ * @type {import('$app/stores').getStores}
17
+ */
18
+ const getStores = () => {
19
+ const stores = getContext('__svelte__');
20
+
21
+ return {
22
+ page: {
23
+ subscribe: stores.page.subscribe
24
+ },
25
+ navigating: {
26
+ subscribe: stores.navigating.subscribe
27
+ },
28
+ // TODO remove this (for 1.0? after 1.0?)
29
+ // @ts-expect-error - deprecated, not part of type definitions, but still callable
30
+ get preloading() {
31
+ console.error('stores.preloading is deprecated; use stores.navigating instead');
32
+ return {
33
+ subscribe: stores.navigating.subscribe
34
+ };
35
+ },
36
+ session: stores.session,
37
+ updated: stores.updated
38
+ };
39
+ };
40
+
41
+ /** @type {typeof import('$app/stores').page} */
42
+ const page = {
43
+ /** @param {(value: any) => void} fn */
44
+ subscribe(fn) {
45
+ const store = getStores().page;
46
+ return store.subscribe(fn);
47
+ }
48
+ };
49
+
50
+ /** @type {typeof import('$app/stores').navigating} */
51
+ const navigating = {
52
+ subscribe(fn) {
53
+ const store = getStores().navigating;
54
+ return store.subscribe(fn);
55
+ }
56
+ };
57
+
58
+ /** @param {string} verb */
59
+ const throw_error = (verb) => {
60
+ throw new Error(
61
+ browser
62
+ ? `Cannot ${verb} session store before subscribing`
63
+ : `Can only ${verb} session store in browser`
64
+ );
65
+ };
66
+
67
+ /** @type {typeof import('$app/stores').session} */
68
+ const session = {
69
+ subscribe(fn) {
70
+ const store = getStores().session;
71
+
72
+ if (browser) {
73
+ session.set = store.set;
74
+ session.update = store.update;
75
+ }
76
+
77
+ return store.subscribe(fn);
78
+ },
79
+ set: () => throw_error('set'),
80
+ update: () => throw_error('update')
81
+ };
82
+
83
+ /** @type {typeof import('$app/stores').updated} */
84
+ const updated = {
85
+ subscribe(fn) {
86
+ const store = getStores().updated;
87
+
88
+ if (browser) {
89
+ updated.check = store.check;
90
+ }
91
+
92
+ return store.subscribe(fn);
93
+ },
94
+ check: () => throw_error('check')
95
+ };
96
+
97
+ export { getStores, navigating, page, session, stores, updated };
@@ -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,21 @@
1
+ /**
2
+ * The router is nullable, but not typed that way for ease-of-use
3
+ * @type {import('./router').Router}
4
+ */
5
+ let router;
6
+
7
+ /** @type {import('./renderer').Renderer} */
8
+ let renderer;
9
+
10
+ /**
11
+ * @param {{
12
+ * router: import('./router').Router?;
13
+ * renderer: import('./renderer').Renderer;
14
+ * }} opts
15
+ */
16
+ function init(opts) {
17
+ router = /** @type {import('../client/router').Router} */ (opts.router);
18
+ renderer = opts.renderer;
19
+ }
20
+
21
+ export { init, renderer, router };