@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,115 +0,0 @@
1
- declare module '$app/env' {
2
- /**
3
- * Whether or not app is in AMP mode.
4
- */
5
- export const amp: boolean;
6
- /**
7
- * Whether the app is running in the browser or on the server.
8
- */
9
- export const browser: boolean;
10
- /**
11
- * `true` in development mode, `false` in production.
12
- */
13
- export const dev: boolean;
14
- /**
15
- * `true` when prerendering, `false` otherwise.
16
- */
17
- export const prerendering: boolean;
18
- }
19
-
20
- declare module '$app/navigation' {
21
- /**
22
- * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified href.
23
- *
24
- * @param href Where to navigate to
25
- * @param opts Optional. If `replaceState` is `true`, a new history entry won't be created. If `noscroll` is `true`, the browser won't scroll to the top of the page after navigation.
26
- */
27
- export function goto(
28
- href: string,
29
- opts?: { replaceState?: boolean; noscroll?: boolean }
30
- ): Promise<any>;
31
- /**
32
- * Returns a Promise that resolves when SvelteKit re-runs any current `load` functions that depend on `href`
33
- * @param href The invalidated resource
34
- */
35
- export function invalidate(href: string): Promise<any>;
36
- /**
37
- * Programmatically prefetches the given page, which means a) ensuring that the code for the page is loaded, and b) calling the page's load function with the appropriate options.
38
- * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `sveltekit:prefetch`.
39
- * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
40
- * Returns a Promise that resolves when the prefetch is complete.
41
- *
42
- * @param href Page to prefetch
43
- */
44
- export function prefetch(href: string): Promise<any>;
45
- /**
46
- * Programmatically prefetches the code for routes that haven't yet been fetched.
47
- * Typically, you might call this to speed up subsequent navigation.
48
- * If no argument is given, all routes will be fetched, otherwise you can specify routes by any matching pathname such as `/about` (to match `src/routes/about.svelte`)
49
- * or `/blog/*` (to match `src/routes/blog/[slug].svelte`). Unlike prefetch, this won't call preload for individual pages.
50
- * Returns a Promise that resolves when the routes have been prefetched.
51
- */
52
- export function prefetchRoutes(routes?: string[]): Promise<any>;
53
- }
54
-
55
- declare module '$app/paths' {
56
- /**
57
- * A root-relative (i.e. begins with a `/`) string that matches `config.kit.files.base` in your project configuration.
58
- */
59
- export const base: string;
60
- /**
61
- * A root-relative or absolute path that matches `config.kit.files.assets` (after it has been resolved against base).
62
- */
63
- export const assets: string;
64
- }
65
-
66
- declare module '$app/stores' {
67
- import { Readable, Writable } from 'svelte/store';
68
- import { Page } from '@sveltejs/kit';
69
-
70
- /**
71
- * A convenience function around `getContext` that returns `{ navigating, page, session }`.
72
- * Most of the time, you won't need to use it.
73
- */
74
- export function getStores(): {
75
- navigating: Readable<{ from: Page; to: Page } | null>;
76
- page: Readable<Page>;
77
- session: Writable<any>;
78
- };
79
- /**
80
- * A readable store whose value reflects the object passed to load functions.
81
- */
82
- export const page: Readable<Page>;
83
- /**
84
- * A readable store.
85
- * When navigating starts, its value is `{ from, to }`, where from and to both mirror the page store value.
86
- * When navigating finishes, its value reverts to `null`.
87
- */
88
- export const navigating: Readable<{ from: Page; to: Page } | null>;
89
- /**
90
- * A writable store whose initial value is whatever was returned from `getSession`.
91
- * It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
92
- */
93
- export const session: Writable<any>;
94
- }
95
-
96
- declare module '$service-worker' {
97
- /**
98
- * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
99
- * This is only available to service workers.
100
- */
101
- export const build: string[];
102
- /**
103
- * An array of URL strings representing the files in your static directory,
104
- * or whatever directory is specified by `config.kit.files.assets`.
105
- * This is only available to service workers.
106
- */
107
- export const files: string[];
108
- /**
109
- * The result of calling `Date.now()` at build time.
110
- * It's useful for generating unique cache names inside your service worker,
111
- * so that a later deployment of your app can invalidate old caches.
112
- * This is only available to service workers.
113
- */
114
- export const timestamp: number;
115
- }
package/types/config.d.ts DELETED
@@ -1,101 +0,0 @@
1
- import { Logger } from './internal';
2
- import { UserConfig as ViteConfig } from 'vite';
3
-
4
- export type AdapterUtils = {
5
- log: Logger;
6
- rimraf: (dir: string) => void;
7
- mkdirp: (dir: string) => void;
8
- copy_client_files: (dest: string) => void;
9
- copy_server_files: (dest: string) => void;
10
- copy_static_files: (dest: string) => void;
11
- copy: (from: string, to: string, filter?: (basename: string) => boolean) => void;
12
- prerender: ({
13
- all,
14
- dest,
15
- fallback
16
- }: {
17
- all?: boolean;
18
- dest: string;
19
- fallback?: string;
20
- }) => Promise<void>;
21
- };
22
-
23
- export type Adapter = {
24
- name: string;
25
- adapt: (utils: AdapterUtils) => Promise<void>;
26
- };
27
-
28
- export type Config = {
29
- compilerOptions?: any;
30
- extensions?: string[];
31
- kit?: {
32
- adapter?: Adapter;
33
- amp?: boolean;
34
- appDir?: string;
35
- files?: {
36
- assets?: string;
37
- hooks?: string;
38
- lib?: string;
39
- routes?: string;
40
- serviceWorker?: string;
41
- template?: string;
42
- };
43
- floc?: boolean;
44
- host?: string;
45
- hostHeader?: string;
46
- hydrate?: boolean;
47
- paths?: {
48
- base?: string;
49
- assets?: string;
50
- };
51
- prerender?: {
52
- crawl?: boolean;
53
- enabled?: boolean;
54
- force?: boolean;
55
- pages?: string[];
56
- };
57
- router?: boolean;
58
- ssr?: boolean;
59
- target?: string;
60
- vite?: ViteConfig | (() => ViteConfig);
61
- };
62
- preprocess?: any;
63
- };
64
-
65
- export type ValidatedConfig = {
66
- compilerOptions: any;
67
- extensions: string[];
68
- kit: {
69
- adapter: Adapter;
70
- amp: boolean;
71
- appDir: string;
72
- files: {
73
- assets: string;
74
- hooks: string;
75
- lib: string;
76
- routes: string;
77
- serviceWorker: string;
78
- setup: string;
79
- template: string;
80
- };
81
- floc: boolean;
82
- host: string;
83
- hostHeader: string;
84
- hydrate: boolean;
85
- paths: {
86
- base: string;
87
- assets: string;
88
- };
89
- prerender: {
90
- crawl: boolean;
91
- enabled: boolean;
92
- force: boolean;
93
- pages: string[];
94
- };
95
- router: boolean;
96
- ssr: boolean;
97
- target: string;
98
- vite: () => ViteConfig;
99
- };
100
- preprocess: any;
101
- };
@@ -1,23 +0,0 @@
1
- import { Headers, ParameterizedBody } from './helper';
2
-
3
- export type ServerRequest<Context = any, Body = unknown> = {
4
- method: string;
5
- host: string;
6
- headers: Headers;
7
- path: string;
8
- params: Record<string, string>;
9
- query: URLSearchParams;
10
- rawBody: string | ArrayBuffer;
11
- body: ParameterizedBody<Body>;
12
- context: Context;
13
- };
14
-
15
- export type ServerResponse = {
16
- status?: number;
17
- headers?: Headers;
18
- body?: any;
19
- };
20
-
21
- export type RequestHandler<Context = any, Body = unknown> = (
22
- request: ServerRequest<Context, Body>
23
- ) => void | ServerResponse | Promise<ServerResponse>;
package/types/helper.d.ts DELETED
@@ -1,19 +0,0 @@
1
- interface ReadOnlyFormData extends Iterator<[string, string]> {
2
- get: (key: string) => string;
3
- getAll: (key: string) => string[];
4
- has: (key: string) => boolean;
5
- entries: () => Iterator<[string, string]>;
6
- keys: () => Iterator<string>;
7
- values: () => Iterator<string>;
8
- }
9
-
10
- export type BaseBody = string | Buffer | ReadOnlyFormData;
11
- export type ParameterizedBody<Body = unknown> = Body extends FormData
12
- ? ReadOnlyFormData
13
- : BaseBody & Body;
14
-
15
- // TODO we want to differentiate between request headers, which
16
- // always follow this type, and response headers, in which
17
- // 'set-cookie' is a `string[]` (or at least `string | string[]`)
18
- // but this can't happen until TypeScript 4.3
19
- export type Headers = Record<string, string>;
package/types/hooks.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { BaseBody, Headers } from './helper';
2
- import { ServerRequest, ServerResponse } from './endpoint';
3
-
4
- export type Incoming = {
5
- method: string;
6
- host: string;
7
- headers: Headers;
8
- path: string;
9
- query: URLSearchParams;
10
- rawBody: string | ArrayBuffer;
11
- body?: BaseBody;
12
- };
13
-
14
- export type GetContext<Context = any> = (incoming: Incoming) => Context;
15
-
16
- export type GetSession<Context = any, Session = any> = {
17
- ({ context }: { context: Context }): Session | Promise<Session>;
18
- };
19
-
20
- export type Handle<Context = any> = (input: {
21
- request: ServerRequest<Context>;
22
- render: (request: ServerRequest<Context>) => ServerResponse | Promise<ServerResponse>;
23
- }) => ServerResponse | Promise<ServerResponse>;
package/types/page.d.ts DELETED
@@ -1,30 +0,0 @@
1
- export type LoadInput = {
2
- page: Page;
3
- fetch: (info: RequestInfo, init?: RequestInit) => Promise<Response>;
4
- session: any;
5
- context: Record<string, any>;
6
- };
7
-
8
- export type ErrorLoadInput = LoadInput & {
9
- status: number;
10
- error: Error;
11
- };
12
-
13
- export type LoadOutput = {
14
- status?: number;
15
- error?: Error;
16
- redirect?: string;
17
- props?: Record<string, any> | Promise<Record<string, any>>;
18
- context?: Record<string, any>;
19
- maxage?: number;
20
- };
21
-
22
- /* Publicized Types */
23
- export type Load = (input: LoadInput) => LoadOutput | Promise<LoadOutput>;
24
- export type ErrorLoad = (input: ErrorLoadInput) => LoadOutput | Promise<LoadOutput>;
25
- export type Page = {
26
- host: string;
27
- path: string;
28
- params: Record<string, string>;
29
- query: URLSearchParams;
30
- };