@sveltejs/kit 1.0.0-next.26 → 1.0.0-next.263

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 (86) 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 +1499 -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 +2709 -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 +467 -0
  17. package/dist/chunks/index2.js +836 -0
  18. package/dist/chunks/index3.js +638 -0
  19. package/dist/chunks/index4.js +115 -0
  20. package/dist/chunks/index5.js +859 -0
  21. package/dist/chunks/index6.js +170 -0
  22. package/dist/chunks/index7.js +15582 -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 +1128 -84
  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 +95 -54
  31. package/svelte-kit.js +2 -0
  32. package/types/ambient-modules.d.ts +208 -0
  33. package/types/app.d.ts +35 -0
  34. package/types/config.d.ts +176 -0
  35. package/types/csp.d.ts +115 -0
  36. package/types/endpoint.d.ts +39 -0
  37. package/types/helper.d.ts +23 -0
  38. package/types/hooks.d.ts +34 -0
  39. package/types/index.d.ts +10 -0
  40. package/types/internal.d.ts +260 -0
  41. package/types/page.d.ts +33 -0
  42. package/CHANGELOG.md +0 -312
  43. package/assets/runtime/app/navigation.js +0 -23
  44. package/assets/runtime/app/navigation.js.map +0 -1
  45. package/assets/runtime/app/paths.js +0 -2
  46. package/assets/runtime/app/paths.js.map +0 -1
  47. package/assets/runtime/app/stores.js +0 -78
  48. package/assets/runtime/app/stores.js.map +0 -1
  49. package/assets/runtime/internal/singletons.js +0 -15
  50. package/assets/runtime/internal/singletons.js.map +0 -1
  51. package/assets/runtime/internal/start.js +0 -591
  52. package/assets/runtime/internal/start.js.map +0 -1
  53. package/assets/runtime/utils-85ebcc60.js +0 -18
  54. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  55. package/dist/api.js +0 -44
  56. package/dist/api.js.map +0 -1
  57. package/dist/build.js +0 -246
  58. package/dist/build.js.map +0 -1
  59. package/dist/cli.js.map +0 -1
  60. package/dist/colors.js +0 -37
  61. package/dist/colors.js.map +0 -1
  62. package/dist/create_app.js +0 -580
  63. package/dist/create_app.js.map +0 -1
  64. package/dist/index.js +0 -367
  65. package/dist/index.js.map +0 -1
  66. package/dist/index2.js +0 -12035
  67. package/dist/index2.js.map +0 -1
  68. package/dist/index3.js +0 -547
  69. package/dist/index3.js.map +0 -1
  70. package/dist/index4.js +0 -74
  71. package/dist/index4.js.map +0 -1
  72. package/dist/index5.js +0 -464
  73. package/dist/index5.js.map +0 -1
  74. package/dist/index6.js +0 -727
  75. package/dist/index6.js.map +0 -1
  76. package/dist/logging.js +0 -43
  77. package/dist/logging.js.map +0 -1
  78. package/dist/package.js +0 -432
  79. package/dist/package.js.map +0 -1
  80. package/dist/renderer.js +0 -2403
  81. package/dist/renderer.js.map +0 -1
  82. package/dist/standard.js +0 -101
  83. package/dist/standard.js.map +0 -1
  84. package/dist/utils.js +0 -54
  85. package/dist/utils.js.map +0 -1
  86. package/svelte-kit +0 -3
package/dist/node.js ADDED
@@ -0,0 +1,95 @@
1
+ import { Readable } from 'stream';
2
+
3
+ /** @type {import('@sveltejs/kit/node').GetRawBody} */
4
+ function get_raw_body(req) {
5
+ return new Promise((fulfil, reject) => {
6
+ const h = req.headers;
7
+
8
+ if (!h['content-type']) {
9
+ return fulfil(null);
10
+ }
11
+
12
+ req.on('error', reject);
13
+
14
+ const length = Number(h['content-length']);
15
+
16
+ // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95
17
+ if (isNaN(length) && h['transfer-encoding'] == null) {
18
+ return fulfil(null);
19
+ }
20
+
21
+ let data = new Uint8Array(length || 0);
22
+
23
+ if (length > 0) {
24
+ let offset = 0;
25
+ req.on('data', (chunk) => {
26
+ const new_len = offset + Buffer.byteLength(chunk);
27
+
28
+ if (new_len > length) {
29
+ return reject({
30
+ status: 413,
31
+ reason: 'Exceeded "Content-Length" limit'
32
+ });
33
+ }
34
+
35
+ data.set(chunk, offset);
36
+ offset = new_len;
37
+ });
38
+ } else {
39
+ req.on('data', (chunk) => {
40
+ const new_data = new Uint8Array(data.length + chunk.length);
41
+ new_data.set(data, 0);
42
+ new_data.set(chunk, data.length);
43
+ data = new_data;
44
+ });
45
+ }
46
+
47
+ req.on('end', () => {
48
+ fulfil(data);
49
+ });
50
+ });
51
+ }
52
+
53
+ /** @type {import('@sveltejs/kit/node').GetRequest} */
54
+ async function getRequest(base, req) {
55
+ let headers = /** @type {Record<string, string>} */ (req.headers);
56
+ if (req.httpVersionMajor === 2) {
57
+ // we need to strip out the HTTP/2 pseudo-headers because node-fetch's
58
+ // Request implementation doesn't like them
59
+ headers = Object.assign({}, headers);
60
+ delete headers[':method'];
61
+ delete headers[':path'];
62
+ delete headers[':authority'];
63
+ delete headers[':scheme'];
64
+ }
65
+ return new Request(base + req.url, {
66
+ method: req.method,
67
+ headers,
68
+ body: await get_raw_body(req) // TODO stream rather than buffer
69
+ });
70
+ }
71
+
72
+ /** @type {import('@sveltejs/kit/node').SetResponse} */
73
+ async function setResponse(res, response) {
74
+ /** @type {import('../types/helper').ResponseHeaders} */
75
+ const headers = Object.fromEntries(response.headers);
76
+
77
+ if (response.headers.has('set-cookie')) {
78
+ // @ts-expect-error (headers.raw() is non-standard)
79
+ headers['set-cookie'] = response.headers.raw()['set-cookie'];
80
+ }
81
+
82
+ res.writeHead(response.status, headers);
83
+
84
+ if (response.body instanceof Readable) {
85
+ response.body.pipe(res);
86
+ } else {
87
+ if (response.body) {
88
+ res.write(await response.arrayBuffer());
89
+ }
90
+
91
+ res.end();
92
+ }
93
+ }
94
+
95
+ export { getRequest, setResponse };
package/package.json CHANGED
@@ -1,55 +1,96 @@
1
1
  {
2
- "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.26",
4
- "dependencies": {
5
- "cheap-watch": "^1.0.2",
6
- "http-proxy": "^1.18.1",
7
- "rollup": "^2.32.0",
8
- "rollup-plugin-css-chunks": "^2.0.2",
9
- "rollup-plugin-terser": "^7.0.2",
10
- "sade": "^1.7.4",
11
- "scorta": "^1.0.0",
12
- "snowpack": "^3.0.10",
13
- "source-map": "^0.7.3"
14
- },
15
- "devDependencies": {
16
- "@sveltejs/app-utils": "*",
17
- "@types/node": "^14.11.10",
18
- "@types/rimraf": "^3.0.0",
19
- "@types/sade": "^1.7.2",
20
- "amphtml-validator": "^1.0.34",
21
- "eslint": "^7.14.0",
22
- "esm": "^3.2.25",
23
- "estree-walker": "^2.0.1",
24
- "is-reference": "^1.2.1",
25
- "kleur": "^4.1.3",
26
- "magic-string": "^0.25.7",
27
- "meriyah": "^3.0.3",
28
- "node-fetch": "^2.6.1",
29
- "periscopic": "^2.0.2",
30
- "port-authority": "^1.1.1",
31
- "require-relative": "^0.8.7",
32
- "rimraf": "^3.0.2",
33
- "sirv": "^1.0.7",
34
- "source-map-support": "^0.5.19",
35
- "svelte": "^3.29.0",
36
- "tiny-glob": "^0.2.8"
37
- },
38
- "bin": {
39
- "svelte-kit": "svelte-kit"
40
- },
41
- "files": [
42
- "assets",
43
- "dist",
44
- "client"
45
- ],
46
- "scripts": {
47
- "dev": "rollup -cw",
48
- "build": "rollup -c",
49
- "lint": "eslint --ignore-path .gitignore \"**/*.{ts,mjs,js,svelte}\" && npm run check-format",
50
- "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
51
- "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
52
- "prepublishOnly": "npm run build",
53
- "test": "uvu src \"(spec.js|test/index.js)\" -r esm"
54
- }
55
- }
2
+ "name": "@sveltejs/kit",
3
+ "version": "1.0.0-next.263",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/sveltejs/kit",
7
+ "directory": "packages/kit"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://kit.svelte.dev",
11
+ "type": "module",
12
+ "dependencies": {
13
+ "@sveltejs/vite-plugin-svelte": "^1.0.0-next.32",
14
+ "sade": "^1.7.4",
15
+ "vite": "^2.8.0"
16
+ },
17
+ "devDependencies": {
18
+ "@playwright/test": "^1.17.1",
19
+ "@rollup/plugin-replace": "^3.0.0",
20
+ "@types/amphtml-validator": "^1.0.1",
21
+ "@types/cookie": "^0.4.1",
22
+ "@types/marked": "^4.0.1",
23
+ "@types/mime": "^2.0.3",
24
+ "@types/node": "^16.11.11",
25
+ "@types/sade": "^1.7.3",
26
+ "amphtml-validator": "^1.0.35",
27
+ "cookie": "^0.4.1",
28
+ "cross-env": "^7.0.3",
29
+ "devalue": "^2.0.1",
30
+ "eslint": "^8.3.0",
31
+ "kleur": "^4.1.4",
32
+ "locate-character": "^2.0.5",
33
+ "marked": "^4.0.5",
34
+ "mime": "^3.0.0",
35
+ "node-fetch": "^3.1.0",
36
+ "port-authority": "^1.1.2",
37
+ "rollup": "^2.60.2",
38
+ "selfsigned": "^2.0.0",
39
+ "sirv": "^2.0.0",
40
+ "svelte": "^3.44.2",
41
+ "svelte-check": "^2.2.10",
42
+ "svelte-preprocess": "^4.9.8",
43
+ "svelte2tsx": "~0.5.0",
44
+ "tiny-glob": "^0.2.9",
45
+ "uvu": "^0.5.2"
46
+ },
47
+ "peerDependencies": {
48
+ "svelte": "^3.44.0"
49
+ },
50
+ "bin": {
51
+ "svelte-kit": "svelte-kit.js"
52
+ },
53
+ "files": [
54
+ "assets",
55
+ "dist",
56
+ "types",
57
+ "svelte-kit.js"
58
+ ],
59
+ "exports": {
60
+ "./package.json": "./package.json",
61
+ ".": {
62
+ "types": "./types/index.d.ts"
63
+ },
64
+ "./node": {
65
+ "import": "./dist/node.js"
66
+ },
67
+ "./hooks": {
68
+ "import": "./dist/hooks.js"
69
+ },
70
+ "./install-fetch": {
71
+ "import": "./dist/install-fetch.js"
72
+ }
73
+ },
74
+ "types": "types/index.d.ts",
75
+ "engines": {
76
+ "node": ">=14.13"
77
+ },
78
+ "scripts": {
79
+ "build": "rollup -c && node scripts/cp.js src/runtime/components assets/components",
80
+ "dev": "rollup -cw",
81
+ "lint": "eslint --ignore-path .gitignore --ignore-pattern \"src/packaging/test/**\" \"{src,test}/**/*.{ts,mjs,js,svelte}\" && npm run check-format",
82
+ "check": "tsc && svelte-check --ignore test/prerendering,src/packaging/test",
83
+ "format": "npm run check-format -- --write",
84
+ "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
85
+ "test": "npm run test:unit && npm run test:packaging && npm run test:prerendering && npm run test:integration",
86
+ "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
87
+ "test:prerendering": "pnpm test:prerendering:basics",
88
+ "test:prerendering:basics": "cd test/prerendering/basics && pnpm test",
89
+ "test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
90
+ "test:integration": "pnpm test:integration:amp && pnpm test:integration:basics && pnpm test:integration:options && pnpm test:integration:options-2",
91
+ "test:integration:amp": "cd test/apps/amp && pnpm test",
92
+ "test:integration:basics": "cd test/apps/basics && pnpm test",
93
+ "test:integration:options": "cd test/apps/options && pnpm test",
94
+ "test:integration:options-2": "cd test/apps/options-2 && pnpm test"
95
+ }
96
+ }
package/svelte-kit.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './dist/cli.js';
@@ -0,0 +1,208 @@
1
+ /* eslint-disable import/no-duplicates */
2
+
3
+ declare namespace App {
4
+ interface Locals {}
5
+ interface Platform {}
6
+ interface Session {}
7
+ interface Stuff {}
8
+ }
9
+
10
+ declare module '$app/env' {
11
+ /**
12
+ * Whether or not app is in AMP mode.
13
+ */
14
+ export const amp: boolean;
15
+ /**
16
+ * Whether the app is running in the browser or on the server.
17
+ */
18
+ export const browser: boolean;
19
+ /**
20
+ * `true` in development mode, `false` in production.
21
+ */
22
+ export const dev: boolean;
23
+ /**
24
+ * `true` when prerendering, `false` otherwise.
25
+ */
26
+ export const prerendering: boolean;
27
+ /**
28
+ * The Vite.js mode the app is running in. Configure in `config.kit.vite.mode`.
29
+ * Vite.js loads the dotenv file associated with the provided mode, `.env.[mode]` or `.env.[mode].local`.
30
+ * By default, `svelte-kit dev` runs with `mode=development` and `svelte-kit build` runs with `mode=production`.
31
+ */
32
+ export const mode: string;
33
+ }
34
+
35
+ declare module '$app/navigation' {
36
+ /**
37
+ * Disable SvelteKit's built-in scroll handling for the current navigation, in case you need to manually control the scroll position.
38
+ * This is generally discouraged, since it breaks user expectations.
39
+ */
40
+ export function disableScrollHandling(): void;
41
+ /**
42
+ * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified href.
43
+ *
44
+ * @param href Where to navigate to
45
+ * @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
46
+ * @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
47
+ * @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
48
+ * @param opts.state The state of the new/updated history entry
49
+ */
50
+ export function goto(
51
+ href: string,
52
+ opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
53
+ ): Promise<any>;
54
+ /**
55
+ * Returns a Promise that resolves when SvelteKit re-runs any current `load` functions that depend on `href`
56
+ * @param href The invalidated resource
57
+ */
58
+ export function invalidate(href: string): Promise<any>;
59
+ /**
60
+ * Programmatically prefetches the given page, which means
61
+ * 1. ensuring that the code for the page is loaded, and
62
+ * 2. calling the page's load function with the appropriate options.
63
+ *
64
+ * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `sveltekit:prefetch`.
65
+ * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
66
+ * Returns a Promise that resolves when the prefetch is complete.
67
+ *
68
+ * @param href Page to prefetch
69
+ */
70
+ export function prefetch(href: string): Promise<any>;
71
+ /**
72
+ * Programmatically prefetches the code for routes that haven't yet been fetched.
73
+ * Typically, you might call this to speed up subsequent navigation.
74
+ *
75
+ * If no argument is given, all routes will be fetched, otherwise you can specify routes by any matching pathname
76
+ * such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`).
77
+ *
78
+ * Unlike prefetch, this won't call preload for individual pages.
79
+ * Returns a Promise that resolves when the routes have been prefetched.
80
+ */
81
+ export function prefetchRoutes(routes?: string[]): Promise<any>;
82
+
83
+ /**
84
+ * A navigation interceptor that triggers before we navigate to a new route.
85
+ * This is helpful if we want to conditionally prevent a navigation from completing or lookup the upcoming url.
86
+ */
87
+ export function beforeNavigate(
88
+ fn: ({ from, to, cancel }: { from: URL; to: URL | null; cancel: () => void }) => void
89
+ ): any;
90
+
91
+ /**
92
+ * A lifecycle function that runs when the page mounts, and also whenever SvelteKit navigates to a new URL but stays on this component.
93
+ */
94
+ export function afterNavigate(fn: ({ from, to }: { from: URL | null; to: URL }) => void): any;
95
+ }
96
+
97
+ declare module '$app/paths' {
98
+ /**
99
+ * A root-relative (i.e. begins with a `/`) string that matches `config.kit.paths.base` in your project configuration.
100
+ */
101
+ export const base: string;
102
+ /**
103
+ * A root-relative or absolute path that matches `config.kit.paths.assets` (after it has been resolved against base).
104
+ */
105
+ export const assets: string;
106
+ }
107
+
108
+ declare module '$app/stores' {
109
+ import { Readable, Writable } from 'svelte/store';
110
+ type Navigating = { from: URL; to: URL };
111
+
112
+ /**
113
+ * A convenience function around `getContext` that returns `{ navigating, page, session }`.
114
+ * Most of the time, you won't need to use it.
115
+ */
116
+ export function getStores(): {
117
+ navigating: typeof navigating;
118
+ page: typeof page;
119
+ session: Writable<App.Session>;
120
+ updated: typeof updated;
121
+ };
122
+ /**
123
+ * A readable store whose value contains page data.
124
+ */
125
+ export const page: Readable<{
126
+ url: URL;
127
+ params: Record<string, string>;
128
+ stuff: App.Stuff;
129
+ status: number;
130
+ error: Error | null;
131
+ }>;
132
+ /**
133
+ * A readable store.
134
+ * When navigating starts, its value is `{ from: URL, to: URL }`
135
+ * When navigating finishes, its value reverts to `null`.
136
+ */
137
+ export const navigating: Readable<Navigating | null>;
138
+ /**
139
+ * A writable store whose initial value is whatever was returned from `getSession`.
140
+ * It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
141
+ */
142
+ export const session: Writable<App.Session>;
143
+ /**
144
+ * A writable store indicating if the site was updated since the store was created.
145
+ * It can be written to when custom logic is required to detect updates.
146
+ */
147
+ export const updated: Readable<boolean> & { check: () => boolean };
148
+ }
149
+
150
+ declare module '$service-worker' {
151
+ /**
152
+ * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
153
+ * This is only available to service workers.
154
+ */
155
+ export const build: string[];
156
+ /**
157
+ * An array of URL strings representing the files in your static directory,
158
+ * or whatever directory is specified by `config.kit.files.assets`.
159
+ * This is only available to service workers.
160
+ */
161
+ export const files: string[];
162
+ /**
163
+ * The result of calling `Date.now()` at build time.
164
+ * It's useful for generating unique cache names inside your service worker,
165
+ * so that a later deployment of your app can invalidate old caches.
166
+ * This is only available to service workers.
167
+ */
168
+ export const timestamp: number;
169
+ }
170
+
171
+ declare module '@sveltejs/kit/hooks' {
172
+ import { Handle } from '@sveltejs/kit';
173
+
174
+ /**
175
+ * Utility function that allows chaining `handle` functions in a
176
+ * middleware-like manner.
177
+ *
178
+ * @param handlers The chain of `handle` functions
179
+ */
180
+ export function sequence(...handlers: Handle[]): Handle;
181
+ }
182
+
183
+ declare module '@sveltejs/kit/node' {
184
+ import { IncomingMessage, ServerResponse } from 'http';
185
+
186
+ export interface GetRawBody {
187
+ (request: IncomingMessage): Promise<Uint8Array | null>;
188
+ }
189
+ export const getRawBody: GetRawBody;
190
+
191
+ export interface GetRequest {
192
+ (base: string, request: IncomingMessage): Promise<Request>;
193
+ }
194
+ export const getRequest: GetRequest;
195
+
196
+ export interface SetResponse {
197
+ (res: ServerResponse, response: Response): void;
198
+ }
199
+ export const setResponse: SetResponse;
200
+ }
201
+
202
+ declare module '@sveltejs/kit/install-fetch' {
203
+ import fetch, { Headers, Request, Response } from 'node-fetch';
204
+
205
+ export function __fetch_polyfill(): void;
206
+
207
+ export { fetch, Headers, Request, Response };
208
+ }
package/types/app.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { PrerenderOptions, SSRNodeLoader, SSRRoute } from './internal';
2
+
3
+ export interface RequestOptions<Platform = Record<string, any>> {
4
+ platform?: Platform;
5
+ }
6
+
7
+ export class App {
8
+ constructor(manifest: SSRManifest);
9
+ render(request: Request, options?: RequestOptions): Promise<Response>;
10
+ }
11
+
12
+ export class InternalApp extends App {
13
+ render(
14
+ request: Request,
15
+ options?: RequestOptions & {
16
+ prerender?: PrerenderOptions;
17
+ }
18
+ ): Promise<Response>;
19
+ }
20
+
21
+ export interface SSRManifest {
22
+ appDir: string;
23
+ assets: Set<string>;
24
+ /** private fields */
25
+ _: {
26
+ mime: Record<string, string>;
27
+ entry: {
28
+ file: string;
29
+ js: string[];
30
+ css: string[];
31
+ };
32
+ nodes: SSRNodeLoader[];
33
+ routes: SSRRoute[];
34
+ };
35
+ }
@@ -0,0 +1,176 @@
1
+ import { CompileOptions } from 'svelte/types/compiler/interfaces';
2
+ import { UserConfig as ViteConfig } from 'vite';
3
+ import { CspDirectives } from './csp';
4
+ import { MaybePromise, RecursiveRequired } from './helper';
5
+ import { HttpMethod, Logger, RouteSegment, TrailingSlash } from './internal';
6
+
7
+ export interface RouteDefinition {
8
+ type: 'page' | 'endpoint';
9
+ pattern: RegExp;
10
+ segments: RouteSegment[];
11
+ methods: HttpMethod[];
12
+ }
13
+
14
+ export interface AdapterEntry {
15
+ /**
16
+ * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
17
+ * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
18
+ * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
19
+ */
20
+ id: string;
21
+
22
+ /**
23
+ * A function that compares the candidate route with the current route to determine
24
+ * if it should be treated as a fallback for the current route. For example, `/foo/[c]`
25
+ * is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
26
+ */
27
+ filter: (route: RouteDefinition) => boolean;
28
+
29
+ /**
30
+ * A function that is invoked once the entry has been created. This is where you
31
+ * should write the function to the filesystem and generate redirect manifests.
32
+ */
33
+ complete: (entry: {
34
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
35
+ }) => void;
36
+ }
37
+
38
+ export interface Builder {
39
+ log: Logger;
40
+ rimraf(dir: string): void;
41
+ mkdirp(dir: string): void;
42
+
43
+ appDir: string;
44
+
45
+ /**
46
+ * Create entry points that map to individual functions
47
+ * @param fn A function that groups a set of routes into an entry point
48
+ */
49
+ createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
50
+
51
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
52
+
53
+ getBuildDirectory(name: string): string;
54
+ getClientDirectory(): string;
55
+ getServerDirectory(): string;
56
+ getStaticDirectory(): string;
57
+
58
+ /**
59
+ * @param dest the destination folder to which files should be copied
60
+ * @returns an array of paths corresponding to the files that have been created by the copy
61
+ */
62
+ writeClient(dest: string): string[];
63
+ /**
64
+ * @param dest the destination folder to which files should be copied
65
+ * @returns an array of paths corresponding to the files that have been created by the copy
66
+ */
67
+ writeServer(dest: string): string[];
68
+ /**
69
+ * @param dest the destination folder to which files should be copied
70
+ * @returns an array of paths corresponding to the files that have been created by the copy
71
+ */
72
+ writeStatic(dest: string): string[];
73
+ /**
74
+ * @param from the source file or folder
75
+ * @param to the destination file or folder
76
+ * @param opts.filter a function to determine whether a file or folder should be copied
77
+ * @param opts.replace a map of strings to replace
78
+ * @returns an array of paths corresponding to the files that have been created by the copy
79
+ */
80
+ copy(
81
+ from: string,
82
+ to: string,
83
+ opts?: {
84
+ filter?: (basename: string) => boolean;
85
+ replace?: Record<string, string>;
86
+ }
87
+ ): string[];
88
+
89
+ prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<{
90
+ paths: string[];
91
+ }>;
92
+ }
93
+
94
+ export interface Adapter {
95
+ name: string;
96
+ headers?: {
97
+ host?: string;
98
+ protocol?: string;
99
+ };
100
+ adapt(builder: Builder): Promise<void>;
101
+ }
102
+
103
+ export interface PrerenderErrorHandler {
104
+ (details: {
105
+ status: number;
106
+ path: string;
107
+ referrer: string | null;
108
+ referenceType: 'linked' | 'fetched';
109
+ }): void;
110
+ }
111
+
112
+ export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
113
+
114
+ export interface Config {
115
+ compilerOptions?: CompileOptions;
116
+ extensions?: string[];
117
+ kit?: {
118
+ adapter?: Adapter;
119
+ amp?: boolean;
120
+ appDir?: string;
121
+ browser?: {
122
+ hydrate?: boolean;
123
+ router?: boolean;
124
+ };
125
+ csp?: {
126
+ mode?: 'hash' | 'nonce' | 'auto';
127
+ directives?: CspDirectives;
128
+ };
129
+ files?: {
130
+ assets?: string;
131
+ hooks?: string;
132
+ lib?: string;
133
+ routes?: string;
134
+ serviceWorker?: string;
135
+ template?: string;
136
+ };
137
+ floc?: boolean;
138
+ inlineStyleThreshold?: number;
139
+ methodOverride?: {
140
+ parameter?: string;
141
+ allowed?: string[];
142
+ };
143
+ package?: {
144
+ dir?: string;
145
+ emitTypes?: boolean;
146
+ exports?(filepath: string): boolean;
147
+ files?(filepath: string): boolean;
148
+ };
149
+ paths?: {
150
+ assets?: string;
151
+ base?: string;
152
+ };
153
+ prerender?: {
154
+ concurrency?: number;
155
+ crawl?: boolean;
156
+ createIndexFiles?: boolean;
157
+ enabled?: boolean;
158
+ entries?: string[];
159
+ onError?: PrerenderOnErrorValue;
160
+ };
161
+ routes?: (filepath: string) => boolean;
162
+ serviceWorker?: {
163
+ register?: boolean;
164
+ files?: (filepath: string) => boolean;
165
+ };
166
+ trailingSlash?: TrailingSlash;
167
+ version?: {
168
+ name?: string;
169
+ pollInterval?: number;
170
+ };
171
+ vite?: ViteConfig | (() => MaybePromise<ViteConfig>);
172
+ };
173
+ preprocess?: any;
174
+ }
175
+
176
+ export type ValidatedConfig = RecursiveRequired<Config>;