@sveltejs/kit 1.0.0-next.38 → 1.0.0-next.382

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 (42) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +28 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/{runtime/app → app}/stores.js +33 -29
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1803 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/{runtime/chunks/paths.js → paths.js} +4 -3
  11. package/assets/server/index.js +3563 -0
  12. package/dist/chunks/_commonjsHelpers.js +3 -0
  13. package/dist/chunks/error.js +664 -0
  14. package/dist/chunks/index.js +15292 -3067
  15. package/dist/chunks/index2.js +186 -555
  16. package/dist/chunks/multipart-parser.js +445 -0
  17. package/dist/chunks/sync.js +1007 -0
  18. package/dist/chunks/write_tsconfig.js +274 -0
  19. package/dist/cli.js +66 -514
  20. package/dist/hooks.js +28 -0
  21. package/dist/node/polyfills.js +12240 -0
  22. package/dist/node.js +5893 -0
  23. package/dist/vite.js +3243 -0
  24. package/package.json +97 -64
  25. package/types/ambient.d.ts +345 -0
  26. package/types/index.d.ts +289 -0
  27. package/types/internal.d.ts +326 -0
  28. package/types/private.d.ts +235 -0
  29. package/CHANGELOG.md +0 -399
  30. package/assets/runtime/app/env.js +0 -5
  31. package/assets/runtime/app/navigation.js +0 -41
  32. package/assets/runtime/app/paths.js +0 -1
  33. package/assets/runtime/chunks/utils.js +0 -19
  34. package/assets/runtime/internal/singletons.js +0 -23
  35. package/assets/runtime/internal/start.js +0 -770
  36. package/dist/chunks/index3.js +0 -246
  37. package/dist/chunks/index4.js +0 -511
  38. package/dist/chunks/index5.js +0 -761
  39. package/dist/chunks/index6.js +0 -322
  40. package/dist/chunks/standard.js +0 -99
  41. package/dist/chunks/utils.js +0 -83
  42. package/dist/ssr.js +0 -2523
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 create svelte@latest 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,28 @@
1
+ export { prerendering } from '../env.js';
2
+
3
+ /**
4
+ * @type {import('$app/env').browser}
5
+ */
6
+ const browser = !import.meta.env.SSR;
7
+
8
+ /**
9
+ * @type {import('$app/env').server}
10
+ */
11
+ const server = !!import.meta.env.SSR;
12
+
13
+ /**
14
+ * @type {import('$app/env').dev}
15
+ */
16
+ const dev = !!import.meta.env.DEV;
17
+
18
+ /**
19
+ * @type {import('$app/env').prod}
20
+ */
21
+ const prod = !import.meta.env.DEV;
22
+
23
+ /**
24
+ * @type {import('$app/env').mode}
25
+ */
26
+ const mode = import.meta.env.MODE;
27
+
28
+ export { browser, dev, mode, prod, server };
@@ -0,0 +1,24 @@
1
+ import { client } from '../client/singletons.js';
2
+
3
+ /**
4
+ * @param {string} name
5
+ */
6
+ function guard(name) {
7
+ return () => {
8
+ throw new Error(`Cannot call ${name}(...) on the server`);
9
+ };
10
+ }
11
+
12
+ const ssr = import.meta.env.SSR;
13
+
14
+ const disableScrollHandling = ssr
15
+ ? guard('disableScrollHandling')
16
+ : client.disable_scroll_handling;
17
+ const goto = ssr ? guard('goto') : client.goto;
18
+ const invalidate = ssr ? guard('invalidate') : client.invalidate;
19
+ const prefetch = ssr ? guard('prefetch') : client.prefetch;
20
+ const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
21
+ const beforeNavigate = ssr ? () => {} : client.before_navigate;
22
+ const afterNavigate = ssr ? () => {} : client.after_navigate;
23
+
24
+ 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,37 +12,33 @@ function stores() {
13
12
  return getStores();
14
13
  }
15
14
 
16
- /** @typedef {import('svelte/store').Readable<{
17
- * host: string;
18
- * path: string;
19
- * query: URLSearchParams;
20
- * params: Record<string, string | string[]>
21
- * }>} PageStore */
22
-
15
+ /**
16
+ * @type {import('$app/stores').getStores}
17
+ */
23
18
  const getStores = () => {
24
19
  const stores = getContext('__svelte__');
25
20
 
26
21
  return {
27
- /** @type {PageStore} */
28
22
  page: {
29
23
  subscribe: stores.page.subscribe
30
24
  },
31
- /** @type {import('svelte/store').Readable<boolean>} */
32
25
  navigating: {
33
26
  subscribe: stores.navigating.subscribe
34
27
  },
28
+ // TODO remove this (for 1.0? after 1.0?)
29
+ // @ts-expect-error - deprecated, not part of type definitions, but still callable
35
30
  get preloading() {
36
31
  console.error('stores.preloading is deprecated; use stores.navigating instead');
37
32
  return {
38
33
  subscribe: stores.navigating.subscribe
39
34
  };
40
35
  },
41
- /** @type {import('svelte/store').Writable<any>} */
42
- session: stores.session
36
+ session: stores.session,
37
+ updated: stores.updated
43
38
  };
44
39
  };
45
40
 
46
- /** @type {PageStore} */
41
+ /** @type {typeof import('$app/stores').page} */
47
42
  const page = {
48
43
  /** @param {(value: any) => void} fn */
49
44
  subscribe(fn) {
@@ -52,9 +47,8 @@ const page = {
52
47
  }
53
48
  };
54
49
 
55
- /** @type {import('svelte/store').Readable<boolean>} */
50
+ /** @type {typeof import('$app/stores').navigating} */
56
51
  const navigating = {
57
- /** @param {(value: any) => void} fn */
58
52
  subscribe(fn) {
59
53
  const store = getStores().navigating;
60
54
  return store.subscribe(fn);
@@ -62,32 +56,42 @@ const navigating = {
62
56
  };
63
57
 
64
58
  /** @param {string} verb */
65
- const error = (verb) => {
59
+ const throw_error = (verb) => {
66
60
  throw new Error(
67
- ssr
68
- ? `Can only ${verb} session store in browser`
69
- : `Cannot ${verb} session store before subscribing`
61
+ browser
62
+ ? `Cannot ${verb} session store before subscribing`
63
+ : `Can only ${verb} session store in browser`
70
64
  );
71
65
  };
72
66
 
73
- /** @type {import('svelte/store').Writable<any>} */
67
+ /** @type {typeof import('$app/stores').session} */
74
68
  const session = {
75
69
  subscribe(fn) {
76
70
  const store = getStores().session;
77
71
 
78
- if (!ssr) {
72
+ if (browser) {
79
73
  session.set = store.set;
80
74
  session.update = store.update;
81
75
  }
82
76
 
83
77
  return store.subscribe(fn);
84
78
  },
85
- set: (value) => {
86
- error('set');
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);
87
93
  },
88
- update: (updater) => {
89
- error('update');
90
- }
94
+ check: () => throw_error('check')
91
95
  };
92
96
 
93
- export { getStores, navigating, page, session, stores };
97
+ export { getStores, navigating, page, session, stores, updated };
@@ -0,0 +1,13 @@
1
+ /** @type {import('./types').Client} */
2
+ let client;
3
+
4
+ /**
5
+ * @param {{
6
+ * client: import('./types').Client;
7
+ * }} opts
8
+ */
9
+ function init(opts) {
10
+ client = opts.client;
11
+ }
12
+
13
+ export { client, init };