@sveltejs/kit 1.0.0-next.98 → 1.0.0

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 (141) hide show
  1. package/README.md +5 -1
  2. package/package.json +91 -77
  3. package/postinstall.js +47 -0
  4. package/src/cli.js +44 -0
  5. package/src/constants.js +5 -0
  6. package/src/core/adapt/builder.js +221 -0
  7. package/src/core/adapt/index.js +31 -0
  8. package/src/core/config/default-error.html +56 -0
  9. package/src/core/config/index.js +100 -0
  10. package/src/core/config/options.js +387 -0
  11. package/src/core/config/types.d.ts +1 -0
  12. package/src/core/env.js +138 -0
  13. package/src/core/generate_manifest/index.js +116 -0
  14. package/src/core/prerender/crawl.js +207 -0
  15. package/src/core/prerender/entities.js +2252 -0
  16. package/src/core/prerender/fallback.js +43 -0
  17. package/src/core/prerender/prerender.js +459 -0
  18. package/src/core/prerender/queue.js +80 -0
  19. package/src/core/sync/create_manifest_data/conflict.js +0 -0
  20. package/src/core/sync/create_manifest_data/index.js +523 -0
  21. package/src/core/sync/create_manifest_data/sort.js +161 -0
  22. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  23. package/src/core/sync/sync.js +59 -0
  24. package/src/core/sync/utils.js +33 -0
  25. package/src/core/sync/write_ambient.js +58 -0
  26. package/src/core/sync/write_client_manifest.js +107 -0
  27. package/src/core/sync/write_matchers.js +25 -0
  28. package/src/core/sync/write_root.js +91 -0
  29. package/src/core/sync/write_tsconfig.js +195 -0
  30. package/src/core/sync/write_types/index.js +809 -0
  31. package/src/core/utils.js +67 -0
  32. package/src/exports/hooks/index.js +1 -0
  33. package/src/exports/hooks/sequence.js +44 -0
  34. package/src/exports/index.js +55 -0
  35. package/src/exports/node/index.js +172 -0
  36. package/src/exports/node/polyfills.js +28 -0
  37. package/src/exports/vite/build/build_server.js +359 -0
  38. package/src/exports/vite/build/build_service_worker.js +85 -0
  39. package/src/exports/vite/build/utils.js +230 -0
  40. package/src/exports/vite/dev/index.js +597 -0
  41. package/src/exports/vite/graph_analysis/index.js +99 -0
  42. package/src/exports/vite/graph_analysis/types.d.ts +5 -0
  43. package/src/exports/vite/graph_analysis/utils.js +6 -0
  44. package/src/exports/vite/index.js +708 -0
  45. package/src/exports/vite/preview/index.js +194 -0
  46. package/src/exports/vite/types.d.ts +3 -0
  47. package/src/exports/vite/utils.js +184 -0
  48. package/src/runtime/app/env.js +1 -0
  49. package/src/runtime/app/environment.js +13 -0
  50. package/src/runtime/app/forms.js +135 -0
  51. package/src/runtime/app/navigation.js +22 -0
  52. package/src/runtime/app/paths.js +1 -0
  53. package/src/runtime/app/stores.js +57 -0
  54. package/src/runtime/client/ambient.d.ts +30 -0
  55. package/src/runtime/client/client.js +1725 -0
  56. package/src/runtime/client/constants.js +10 -0
  57. package/src/runtime/client/fetcher.js +127 -0
  58. package/src/runtime/client/parse.js +60 -0
  59. package/src/runtime/client/singletons.js +21 -0
  60. package/src/runtime/client/start.js +45 -0
  61. package/src/runtime/client/types.d.ts +86 -0
  62. package/src/runtime/client/utils.js +257 -0
  63. package/src/runtime/components/error.svelte +6 -0
  64. package/{assets → src/runtime}/components/layout.svelte +0 -0
  65. package/src/runtime/control.js +45 -0
  66. package/src/runtime/env/dynamic/private.js +1 -0
  67. package/src/runtime/env/dynamic/public.js +1 -0
  68. package/src/runtime/env-private.js +6 -0
  69. package/src/runtime/env-public.js +6 -0
  70. package/src/runtime/env.js +12 -0
  71. package/src/runtime/hash.js +20 -0
  72. package/src/runtime/paths.js +11 -0
  73. package/src/runtime/server/cookie.js +228 -0
  74. package/src/runtime/server/data/index.js +158 -0
  75. package/src/runtime/server/endpoint.js +86 -0
  76. package/src/runtime/server/fetch.js +175 -0
  77. package/src/runtime/server/index.js +405 -0
  78. package/src/runtime/server/page/actions.js +267 -0
  79. package/src/runtime/server/page/crypto.js +239 -0
  80. package/src/runtime/server/page/csp.js +250 -0
  81. package/src/runtime/server/page/index.js +326 -0
  82. package/src/runtime/server/page/load_data.js +270 -0
  83. package/src/runtime/server/page/render.js +393 -0
  84. package/src/runtime/server/page/respond_with_error.js +103 -0
  85. package/src/runtime/server/page/serialize_data.js +87 -0
  86. package/src/runtime/server/page/types.d.ts +35 -0
  87. package/src/runtime/server/utils.js +179 -0
  88. package/src/utils/array.js +9 -0
  89. package/src/utils/error.js +22 -0
  90. package/src/utils/escape.js +46 -0
  91. package/src/utils/exports.js +54 -0
  92. package/src/utils/filesystem.js +178 -0
  93. package/src/utils/functions.js +16 -0
  94. package/src/utils/http.js +72 -0
  95. package/src/utils/misc.js +1 -0
  96. package/src/utils/promises.js +17 -0
  97. package/src/utils/routing.js +201 -0
  98. package/src/utils/unit_test.js +11 -0
  99. package/src/utils/url.js +161 -0
  100. package/svelte-kit.js +1 -1
  101. package/types/ambient.d.ts +451 -0
  102. package/types/index.d.ts +1168 -5
  103. package/types/internal.d.ts +348 -160
  104. package/types/private.d.ts +237 -0
  105. package/types/synthetic/$env+dynamic+private.md +10 -0
  106. package/types/synthetic/$env+dynamic+public.md +8 -0
  107. package/types/synthetic/$env+static+private.md +19 -0
  108. package/types/synthetic/$env+static+public.md +7 -0
  109. package/types/synthetic/$lib.md +5 -0
  110. package/CHANGELOG.md +0 -819
  111. package/assets/components/error.svelte +0 -21
  112. package/assets/runtime/app/env.js +0 -16
  113. package/assets/runtime/app/navigation.js +0 -53
  114. package/assets/runtime/app/paths.js +0 -1
  115. package/assets/runtime/app/stores.js +0 -87
  116. package/assets/runtime/chunks/utils.js +0 -13
  117. package/assets/runtime/env.js +0 -8
  118. package/assets/runtime/internal/singletons.js +0 -20
  119. package/assets/runtime/internal/start.js +0 -1061
  120. package/assets/runtime/paths.js +0 -12
  121. package/dist/chunks/_commonjsHelpers.js +0 -8
  122. package/dist/chunks/cert.js +0 -29079
  123. package/dist/chunks/constants.js +0 -3
  124. package/dist/chunks/index.js +0 -3526
  125. package/dist/chunks/index2.js +0 -583
  126. package/dist/chunks/index3.js +0 -31
  127. package/dist/chunks/index4.js +0 -1005
  128. package/dist/chunks/index5.js +0 -327
  129. package/dist/chunks/index6.js +0 -325
  130. package/dist/chunks/standard.js +0 -99
  131. package/dist/chunks/utils.js +0 -149
  132. package/dist/cli.js +0 -711
  133. package/dist/http.js +0 -66
  134. package/dist/install-fetch.js +0 -1699
  135. package/dist/ssr.js +0 -1529
  136. package/types/ambient-modules.d.ts +0 -115
  137. package/types/config.d.ts +0 -101
  138. package/types/endpoint.d.ts +0 -23
  139. package/types/helper.d.ts +0 -19
  140. package/types/hooks.d.ts +0 -23
  141. package/types/page.d.ts +0 -30
@@ -1,21 +0,0 @@
1
- <script context="module">
2
- export function load({ error, status }) {
3
- return {
4
- props: { error, status }
5
- };
6
- }
7
- </script>
8
-
9
- <script>
10
- export let status;
11
- export let error;
12
- </script>
13
-
14
- <h1>{status}</h1>
15
-
16
- <p>{error.message}</p>
17
-
18
- <!-- TODO figure out what to do with stacktraces in prod -->
19
- {#if error.stack}
20
- <pre>{error.stack}</pre>
21
- {/if}
@@ -1,16 +0,0 @@
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').amp}
13
- */
14
- const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
15
-
16
- export { amp, browser, dev };
@@ -1,53 +0,0 @@
1
- import { router } from '../internal/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 goto = import.meta.env.SSR ? guard('goto') : goto_;
14
- const invalidate = import.meta.env.SSR ? guard('invalidate') : invalidate_;
15
- const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
16
- const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
17
-
18
- /**
19
- * @type {import('$app/navigation').goto}
20
- */
21
- async function goto_(href, opts) {
22
- return router.goto(href, opts, []);
23
- }
24
-
25
- /**
26
- * @type {import('$app/navigation').invalidate}
27
- */
28
- async function invalidate_(resource) {
29
- const { href } = new URL(resource, location.href);
30
- return router.renderer.invalidate(href);
31
- }
32
-
33
- /**
34
- * @type {import('$app/navigation').prefetch}
35
- */
36
- function prefetch_(href) {
37
- return router.prefetch(new URL(href, get_base_uri(document)));
38
- }
39
-
40
- /**
41
- * @type {import('$app/navigation').prefetchRoutes}
42
- */
43
- async function prefetchRoutes_(pathnames) {
44
- const matching = pathnames
45
- ? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
46
- : router.routes;
47
-
48
- const promises = matching.map((r) => r.length !== 1 && Promise.all(r[1].map((load) => load())));
49
-
50
- await Promise.all(promises);
51
- }
52
-
53
- export { goto, invalidate, prefetch, prefetchRoutes };
@@ -1 +0,0 @@
1
- export { assets, base } from '../paths.js';
@@ -1,87 +0,0 @@
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?
5
-
6
- // TODO remove this (for 1.0? after 1.0?)
7
- let warned = false;
8
- function stores() {
9
- if (!warned) {
10
- console.error('stores() is deprecated; use getStores() instead');
11
- warned = true;
12
- }
13
- return getStores();
14
- }
15
-
16
- /**
17
- * @type {import('$app/stores').getStores}
18
- */
19
- const getStores = () => {
20
- const stores = getContext('__svelte__');
21
-
22
- return {
23
- page: {
24
- subscribe: stores.page.subscribe
25
- },
26
- navigating: {
27
- subscribe: stores.navigating.subscribe
28
- },
29
- // @ts-ignore - 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
- };
38
- };
39
-
40
- /** @type {typeof import('$app/stores').page} */
41
- const page = {
42
- /** @param {(value: any) => void} fn */
43
- subscribe(fn) {
44
- const store = getStores().page;
45
- return store.subscribe(fn);
46
- }
47
- };
48
-
49
- /** @type {typeof import('$app/stores').navigating} */
50
- const navigating = {
51
- /** @param {(value: any) => void} fn */
52
- subscribe(fn) {
53
- const store = getStores().navigating;
54
- return store.subscribe(fn);
55
- }
56
- };
57
-
58
- /** @param {string} verb */
59
- const error = (verb) => {
60
- throw new Error(
61
- ssr
62
- ? `Can only ${verb} session store in browser`
63
- : `Cannot ${verb} session store before subscribing`
64
- );
65
- };
66
-
67
- /** @type {typeof import('$app/stores').session} */
68
- const session = {
69
- subscribe(fn) {
70
- const store = getStores().session;
71
-
72
- if (!ssr) {
73
- session.set = store.set;
74
- session.update = store.update;
75
- }
76
-
77
- return store.subscribe(fn);
78
- },
79
- set: (value) => {
80
- error('set');
81
- },
82
- update: (updater) => {
83
- error('update');
84
- }
85
- };
86
-
87
- export { getStores, navigating, page, session, stores };
@@ -1,13 +0,0 @@
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 };
@@ -1,8 +0,0 @@
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,20 +0,0 @@
1
- /** @type {import('./router').Router} */
2
- let router;
3
-
4
- /** @type {string} */
5
- let base = '';
6
-
7
- /** @type {string} */
8
- let assets = '/.';
9
-
10
- /** @param {import('./router').Router} _ */
11
- function init(_) {
12
- router = _;
13
- }
14
-
15
- /** @param {{ base: string, assets: string }} paths */
16
- function set_paths(paths) {
17
- ({ base, assets } = paths);
18
- }
19
-
20
- export { assets, base, init, router, set_paths };