@sveltejs/kit 1.0.0-next.21 → 1.0.0-next.210

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 (81) hide show
  1. package/README.md +12 -9
  2. package/assets/components/error.svelte +19 -3
  3. package/assets/kit.js +1912 -0
  4. package/assets/runtime/app/env.js +20 -0
  5. package/assets/runtime/app/navigation.js +45 -13
  6. package/assets/runtime/app/paths.js +1 -2
  7. package/assets/runtime/app/stores.js +15 -9
  8. package/assets/runtime/chunks/utils.js +13 -0
  9. package/assets/runtime/env.js +8 -0
  10. package/assets/runtime/internal/singletons.js +5 -11
  11. package/assets/runtime/internal/start.js +979 -355
  12. package/assets/runtime/paths.js +13 -0
  13. package/dist/chunks/cert.js +29255 -0
  14. package/dist/chunks/constants.js +8 -0
  15. package/dist/chunks/error.js +21 -0
  16. package/dist/chunks/index.js +4732 -0
  17. package/dist/chunks/index2.js +812 -0
  18. package/dist/chunks/index3.js +624 -0
  19. package/dist/chunks/index4.js +109 -0
  20. package/dist/chunks/index5.js +628 -0
  21. package/dist/chunks/index6.js +827 -0
  22. package/dist/chunks/index7.js +15575 -0
  23. package/dist/chunks/misc.js +3 -0
  24. package/dist/chunks/multipart-parser.js +449 -0
  25. package/dist/chunks/url.js +62 -0
  26. package/dist/cli.js +1012 -67
  27. package/dist/hooks.js +28 -0
  28. package/dist/install-fetch.js +6514 -0
  29. package/dist/node.js +51 -0
  30. package/dist/ssr.js +1842 -0
  31. package/package.json +90 -54
  32. package/svelte-kit.js +2 -0
  33. package/types/ambient-modules.d.ts +181 -0
  34. package/types/app.d.ts +45 -0
  35. package/types/config.d.ts +163 -0
  36. package/types/endpoint.d.ts +18 -0
  37. package/types/helper.d.ts +41 -0
  38. package/types/hooks.d.ts +48 -0
  39. package/types/index.d.ts +17 -0
  40. package/types/internal.d.ts +231 -0
  41. package/types/page.d.ts +71 -0
  42. package/CHANGELOG.md +0 -282
  43. package/assets/runtime/app/navigation.js.map +0 -1
  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.map +0 -1
  47. package/assets/runtime/internal/start.js.map +0 -1
  48. package/assets/runtime/utils-85ebcc60.js +0 -18
  49. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  50. package/dist/api.js +0 -44
  51. package/dist/api.js.map +0 -1
  52. package/dist/build.js +0 -246
  53. package/dist/build.js.map +0 -1
  54. package/dist/cli.js.map +0 -1
  55. package/dist/colors.js +0 -37
  56. package/dist/colors.js.map +0 -1
  57. package/dist/create_app.js +0 -578
  58. package/dist/create_app.js.map +0 -1
  59. package/dist/index.js +0 -12042
  60. package/dist/index.js.map +0 -1
  61. package/dist/index2.js +0 -544
  62. package/dist/index2.js.map +0 -1
  63. package/dist/index3.js +0 -71
  64. package/dist/index3.js.map +0 -1
  65. package/dist/index4.js +0 -466
  66. package/dist/index4.js.map +0 -1
  67. package/dist/index5.js +0 -729
  68. package/dist/index5.js.map +0 -1
  69. package/dist/index6.js +0 -713
  70. package/dist/index6.js.map +0 -1
  71. package/dist/logging.js +0 -43
  72. package/dist/logging.js.map +0 -1
  73. package/dist/package.js +0 -432
  74. package/dist/package.js.map +0 -1
  75. package/dist/renderer.js +0 -2391
  76. package/dist/renderer.js.map +0 -1
  77. package/dist/standard.js +0 -101
  78. package/dist/standard.js.map +0 -1
  79. package/dist/utils.js +0 -54
  80. package/dist/utils.js.map +0 -1
  81. package/svelte-kit +0 -3
@@ -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 };
@@ -1,23 +1,55 @@
1
- import { g as get_base_uri } from '../utils-85ebcc60.js';
2
- import { router, renderer } from '../internal/singletons.js';
1
+ import { router as router$1 } from '../internal/singletons.js';
2
+ import { g as get_base_uri } from '../chunks/utils.js';
3
3
 
4
- async function goto(href, opts) {
5
- return router.goto(href, opts);
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 goto = import.meta.env.SSR ? guard('goto') : goto_;
16
+ const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_;
17
+ const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
18
+ const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
19
+
20
+ /**
21
+ * @type {import('$app/navigation').goto}
22
+ */
23
+ async function goto_(href, opts) {
24
+ return router.goto(href, opts, []);
25
+ }
26
+
27
+ /**
28
+ * @type {import('$app/navigation').invalidate}
29
+ */
30
+ async function invalidate_(resource) {
31
+ const { href } = new URL(resource, location.href);
32
+ return router.renderer.invalidate(href);
6
33
  }
7
34
 
8
- function prefetch(href) {
9
- return renderer.prefetch(new URL(href, get_base_uri(document)));
35
+ /**
36
+ * @type {import('$app/navigation').prefetch}
37
+ */
38
+ function prefetch_(href) {
39
+ return router.prefetch(new URL(href, get_base_uri(document)));
10
40
  }
11
41
 
12
- async function prefetchRoutes(pathnames) {
13
- const path_routes = pathnames
14
- ? router.pages.filter((page) => pathnames.some((pathname) => page.pattern.test(pathname)))
15
- : router.pages;
42
+ /**
43
+ * @type {import('$app/navigation').prefetchRoutes}
44
+ */
45
+ async function prefetchRoutes_(pathnames) {
46
+ const matching = pathnames
47
+ ? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
48
+ : router.routes;
16
49
 
17
- const promises = path_routes.map((r) => Promise.all(r.parts.map((load) => load())));
50
+ const promises = matching.map((r) => Promise.all(r[1].map((load) => load())));
18
51
 
19
52
  await Promise.all(promises);
20
53
  }
21
54
 
22
- export { goto, prefetch, prefetchRoutes };
23
- //# sourceMappingURL=navigation.js.map
55
+ export { goto, invalidate, prefetch, prefetchRoutes };
@@ -1,2 +1 @@
1
- export { assets, base } from '../internal/singletons.js';
2
- //# sourceMappingURL=paths.js.map
1
+ export { assets, base } from '../paths.js';
@@ -1,7 +1,8 @@
1
1
  import { getContext } from 'svelte';
2
+ import { browser } from './env.js';
3
+ import '../env.js';
2
4
 
3
- // const ssr = (import.meta as any).env.SSR;
4
- const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build?
5
+ const ssr = !browser;
5
6
 
6
7
  // TODO remove this (for 1.0? after 1.0?)
7
8
  let warned = false;
@@ -13,6 +14,9 @@ function stores() {
13
14
  return getStores();
14
15
  }
15
16
 
17
+ /**
18
+ * @type {import('$app/stores').getStores}
19
+ */
16
20
  const getStores = () => {
17
21
  const stores = getContext('__svelte__');
18
22
 
@@ -23,6 +27,8 @@ const getStores = () => {
23
27
  navigating: {
24
28
  subscribe: stores.navigating.subscribe
25
29
  },
30
+ // TODO remove this (for 1.0? after 1.0?)
31
+ // @ts-expect-error - deprecated, not part of type definitions, but still callable
26
32
  get preloading() {
27
33
  console.error('stores.preloading is deprecated; use stores.navigating instead');
28
34
  return {
@@ -33,13 +39,16 @@ const getStores = () => {
33
39
  };
34
40
  };
35
41
 
42
+ /** @type {typeof import('$app/stores').page} */
36
43
  const page = {
44
+ /** @param {(value: any) => void} fn */
37
45
  subscribe(fn) {
38
46
  const store = getStores().page;
39
47
  return store.subscribe(fn);
40
48
  }
41
49
  };
42
50
 
51
+ /** @type {typeof import('$app/stores').navigating} */
43
52
  const navigating = {
44
53
  subscribe(fn) {
45
54
  const store = getStores().navigating;
@@ -47,6 +56,7 @@ const navigating = {
47
56
  }
48
57
  };
49
58
 
59
+ /** @param {string} verb */
50
60
  const error = (verb) => {
51
61
  throw new Error(
52
62
  ssr
@@ -55,6 +65,7 @@ const error = (verb) => {
55
65
  );
56
66
  };
57
67
 
68
+ /** @type {typeof import('$app/stores').session} */
58
69
  const session = {
59
70
  subscribe(fn) {
60
71
  const store = getStores().session;
@@ -66,13 +77,8 @@ const session = {
66
77
 
67
78
  return store.subscribe(fn);
68
79
  },
69
- set: (value) => {
70
- error('set');
71
- },
72
- update: (updater) => {
73
- error('update');
74
- }
80
+ set: () => error('set'),
81
+ update: () => error('update')
75
82
  };
76
83
 
77
84
  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,8 @@
1
+ let prerendering = false;
2
+
3
+ /** @param {boolean} value */
4
+ function set_prerendering(value) {
5
+ prerendering = value;
6
+ }
7
+
8
+ export { prerendering, set_prerendering };
@@ -1,15 +1,9 @@
1
+ /** @type {import('./router').Router?} */
1
2
  let router;
2
- let renderer;
3
- let base;
4
- let assets;
5
3
 
6
- function init(opts) {
7
- ({ router, renderer } = opts);
4
+ /** @param {import('./router').Router?} _ */
5
+ function init(_) {
6
+ router = _;
8
7
  }
9
8
 
10
- function set_paths(paths) {
11
- ({ base, assets } = paths);
12
- }
13
-
14
- export { assets, base, init, renderer, router, set_paths };
15
- //# sourceMappingURL=singletons.js.map
9
+ export { init, router };