@sveltejs/kit 1.0.0-next.23 → 1.0.0-next.230

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 (83) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -0
  3. package/assets/app/navigation.js +81 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/{runtime/app → app}/stores.js +19 -15
  6. package/assets/chunks/utils.js +13 -0
  7. package/assets/client/singletons.js +18 -0
  8. package/assets/client/start.js +1382 -0
  9. package/assets/components/error.svelte +19 -3
  10. package/assets/env.js +8 -0
  11. package/assets/paths.js +13 -0
  12. package/assets/server/index.js +1998 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/index.js +2391 -0
  15. package/dist/chunks/index2.js +807 -0
  16. package/dist/chunks/index3.js +648 -0
  17. package/dist/chunks/index4.js +109 -0
  18. package/dist/chunks/index5.js +754 -0
  19. package/dist/chunks/index6.js +830 -0
  20. package/dist/chunks/index7.js +15574 -0
  21. package/dist/chunks/index8.js +4207 -0
  22. package/dist/chunks/misc.js +3 -0
  23. package/dist/chunks/multipart-parser.js +449 -0
  24. package/dist/chunks/url.js +62 -0
  25. package/dist/cli.js +1039 -84
  26. package/dist/hooks.js +28 -0
  27. package/dist/install-fetch.js +6514 -0
  28. package/dist/node.js +51 -0
  29. package/package.json +93 -54
  30. package/svelte-kit.js +2 -0
  31. package/types/ambient-modules.d.ts +204 -0
  32. package/types/app.d.ts +45 -0
  33. package/types/config.d.ts +169 -0
  34. package/types/endpoint.d.ts +20 -0
  35. package/types/helper.d.ts +53 -0
  36. package/types/hooks.d.ts +55 -0
  37. package/types/index.d.ts +18 -0
  38. package/types/internal.d.ts +237 -0
  39. package/types/page.d.ts +73 -0
  40. package/CHANGELOG.md +0 -294
  41. package/assets/runtime/app/navigation.js +0 -23
  42. package/assets/runtime/app/navigation.js.map +0 -1
  43. package/assets/runtime/app/paths.js +0 -2
  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 +0 -15
  47. package/assets/runtime/internal/singletons.js.map +0 -1
  48. package/assets/runtime/internal/start.js +0 -591
  49. package/assets/runtime/internal/start.js.map +0 -1
  50. package/assets/runtime/utils-85ebcc60.js +0 -18
  51. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  52. package/dist/api.js +0 -44
  53. package/dist/api.js.map +0 -1
  54. package/dist/build.js +0 -246
  55. package/dist/build.js.map +0 -1
  56. package/dist/cli.js.map +0 -1
  57. package/dist/colors.js +0 -37
  58. package/dist/colors.js.map +0 -1
  59. package/dist/create_app.js +0 -578
  60. package/dist/create_app.js.map +0 -1
  61. package/dist/index.js +0 -367
  62. package/dist/index.js.map +0 -1
  63. package/dist/index2.js +0 -12044
  64. package/dist/index2.js.map +0 -1
  65. package/dist/index3.js +0 -547
  66. package/dist/index3.js.map +0 -1
  67. package/dist/index4.js +0 -73
  68. package/dist/index4.js.map +0 -1
  69. package/dist/index5.js +0 -464
  70. package/dist/index5.js.map +0 -1
  71. package/dist/index6.js +0 -729
  72. package/dist/index6.js.map +0 -1
  73. package/dist/logging.js +0 -43
  74. package/dist/logging.js.map +0 -1
  75. package/dist/package.js +0 -432
  76. package/dist/package.js.map +0 -1
  77. package/dist/renderer.js +0 -2391
  78. package/dist/renderer.js.map +0 -1
  79. package/dist/standard.js +0 -101
  80. package/dist/standard.js.map +0 -1
  81. package/dist/utils.js +0 -54
  82. package/dist/utils.js.map +0 -1
  83. package/svelte-kit +0 -3
package/dist/node.js ADDED
@@ -0,0 +1,51 @@
1
+ /** @type {import('@sveltejs/kit/node').GetRawBody} */
2
+ function getRawBody(req) {
3
+ return new Promise((fulfil, reject) => {
4
+ const h = req.headers;
5
+
6
+ if (!h['content-type']) {
7
+ return fulfil(null);
8
+ }
9
+
10
+ req.on('error', reject);
11
+
12
+ const length = Number(h['content-length']);
13
+
14
+ // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95
15
+ if (isNaN(length) && h['transfer-encoding'] == null) {
16
+ return fulfil(null);
17
+ }
18
+
19
+ let data = new Uint8Array(length || 0);
20
+
21
+ if (length > 0) {
22
+ let offset = 0;
23
+ req.on('data', (chunk) => {
24
+ const new_len = offset + Buffer.byteLength(chunk);
25
+
26
+ if (new_len > length) {
27
+ return reject({
28
+ status: 413,
29
+ reason: 'Exceeded "Content-Length" limit'
30
+ });
31
+ }
32
+
33
+ data.set(chunk, offset);
34
+ offset = new_len;
35
+ });
36
+ } else {
37
+ req.on('data', (chunk) => {
38
+ const new_data = new Uint8Array(data.length + chunk.length);
39
+ new_data.set(data, 0);
40
+ new_data.set(chunk, data.length);
41
+ data = new_data;
42
+ });
43
+ }
44
+
45
+ req.on('end', () => {
46
+ fulfil(data);
47
+ });
48
+ });
49
+ }
50
+
51
+ export { getRawBody };
package/package.json CHANGED
@@ -1,55 +1,94 @@
1
1
  {
2
- "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.23",
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.4",
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.230",
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.7.2"
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.4.10",
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 \"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:integration",
86
+ "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
87
+ "test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
88
+ "test:integration": "pnpm test:integration:amp && pnpm test:integration:basics && pnpm test:integration:options && pnpm test:integration:options-2",
89
+ "test:integration:amp": "cd test/apps/amp && pnpm test",
90
+ "test:integration:basics": "cd test/apps/basics && pnpm test",
91
+ "test:integration:options": "cd test/apps/options && pnpm test",
92
+ "test:integration:options-2": "cd test/apps/options-2 && pnpm test"
93
+ }
94
+ }
package/svelte-kit.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import './dist/cli.js';
@@ -0,0 +1,204 @@
1
+ /* eslint-disable import/no-duplicates */
2
+
3
+ declare module '$app/env' {
4
+ /**
5
+ * Whether or not app is in AMP mode.
6
+ */
7
+ export const amp: boolean;
8
+ /**
9
+ * Whether the app is running in the browser or on the server.
10
+ */
11
+ export const browser: boolean;
12
+ /**
13
+ * `true` in development mode, `false` in production.
14
+ */
15
+ export const dev: boolean;
16
+ /**
17
+ * `true` when prerendering, `false` otherwise.
18
+ */
19
+ export const prerendering: boolean;
20
+ /**
21
+ * The Vite.js mode the app is running in. Configure in `config.kit.vite.mode`.
22
+ * Vite.js loads the dotenv file associated with the provided mode, `.env.[mode]` or `.env.[mode].local`.
23
+ * By default, `svelte-kit dev` runs with `mode=development` and `svelte-kit build` runs with `mode=production`.
24
+ */
25
+ export const mode: string;
26
+ }
27
+
28
+ declare module '$app/navigation' {
29
+ /**
30
+ * Disable SvelteKit's built-in scroll handling for the current navigation, in case you need to manually control the scroll position.
31
+ * This is generally discouraged, since it breaks user expectations.
32
+ */
33
+ export function disableScrollHandling(): void;
34
+ /**
35
+ * Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified href.
36
+ *
37
+ * @param href Where to navigate to
38
+ * @param opts.replaceState If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
39
+ * @param opts.noscroll If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
40
+ * @param opts.keepfocus If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
41
+ * @param opts.state The state of the new/updated history entry
42
+ */
43
+ export function goto(
44
+ href: string,
45
+ opts?: { replaceState?: boolean; noscroll?: boolean; keepfocus?: boolean; state?: any }
46
+ ): Promise<any>;
47
+ /**
48
+ * Returns a Promise that resolves when SvelteKit re-runs any current `load` functions that depend on `href`
49
+ * @param href The invalidated resource
50
+ */
51
+ export function invalidate(href: string): Promise<any>;
52
+ /**
53
+ * Programmatically prefetches the given page, which means
54
+ * 1. ensuring that the code for the page is loaded, and
55
+ * 2. calling the page's load function with the appropriate options.
56
+ *
57
+ * This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `sveltekit:prefetch`.
58
+ * If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
59
+ * Returns a Promise that resolves when the prefetch is complete.
60
+ *
61
+ * @param href Page to prefetch
62
+ */
63
+ export function prefetch(href: string): Promise<any>;
64
+ /**
65
+ * Programmatically prefetches the code for routes that haven't yet been fetched.
66
+ * Typically, you might call this to speed up subsequent navigation.
67
+ *
68
+ * If no argument is given, all routes will be fetched, otherwise you can specify routes by any matching pathname
69
+ * such as `/about` (to match `src/routes/about.svelte`) or `/blog/*` (to match `src/routes/blog/[slug].svelte`).
70
+ *
71
+ * Unlike prefetch, this won't call preload for individual pages.
72
+ * Returns a Promise that resolves when the routes have been prefetched.
73
+ */
74
+ export function prefetchRoutes(routes?: string[]): Promise<any>;
75
+
76
+ /**
77
+ * A navigation interceptor that triggers before we navigate to a new route.
78
+ * This is helpful if we want to conditionally prevent a navigation from completing or lookup the upcoming url.
79
+ */
80
+ export function beforeNavigate(
81
+ fn: ({ from, to, cancel }: { from: URL; to: URL | null; cancel: () => void }) => void
82
+ ): any;
83
+
84
+ /**
85
+ * A lifecycle function that runs when the page mounts, and also whenever SvelteKit navigates to a new URL but stays on this component.
86
+ */
87
+ export function afterNavigate(fn: ({ from, to }: { from: URL | null; to: URL }) => void): any;
88
+ }
89
+
90
+ declare module '$app/paths' {
91
+ /**
92
+ * A root-relative (i.e. begins with a `/`) string that matches `config.kit.paths.base` in your project configuration.
93
+ */
94
+ export const base: string;
95
+ /**
96
+ * A root-relative or absolute path that matches `config.kit.paths.assets` (after it has been resolved against base).
97
+ */
98
+ export const assets: string;
99
+ }
100
+
101
+ declare module '$app/stores' {
102
+ import { Readable, Writable } from 'svelte/store';
103
+ type Navigating = { from: URL; to: URL };
104
+
105
+ /**
106
+ * A convenience function around `getContext` that returns `{ navigating, page, session }`.
107
+ * Most of the time, you won't need to use it.
108
+ */
109
+ export function getStores<Session = any>(): {
110
+ navigating: Readable<Navigating | null>;
111
+ page: Readable<{
112
+ url: URL;
113
+ params: Record<string, string>;
114
+ status: number;
115
+ error: Error | null;
116
+ }>;
117
+ session: Writable<Session>;
118
+ };
119
+ export const url: Readable<URL>;
120
+ /**
121
+ * A readable store whose value contains page data.
122
+ */
123
+ export const page: Readable<{
124
+ url: URL;
125
+ params: Record<string, string>;
126
+ stuff: Record<string, any>;
127
+ status: number;
128
+ error: Error | null;
129
+ }>;
130
+ /**
131
+ * A readable store.
132
+ * When navigating starts, its value is `{ from: URL, to: URL }`
133
+ * When navigating finishes, its value reverts to `null`.
134
+ */
135
+ export const navigating: Readable<Navigating | null>;
136
+ /**
137
+ * A writable store whose initial value is whatever was returned from `getSession`.
138
+ * It can be written to, but this will not cause changes to persist on the server — this is something you must implement yourself.
139
+ */
140
+ export const session: Writable<any>;
141
+ }
142
+
143
+ declare module '$service-worker' {
144
+ /**
145
+ * An array of URL strings representing the files generated by Vite, suitable for caching with `cache.addAll(build)`.
146
+ * This is only available to service workers.
147
+ */
148
+ export const build: string[];
149
+ /**
150
+ * An array of URL strings representing the files in your static directory,
151
+ * or whatever directory is specified by `config.kit.files.assets`.
152
+ * This is only available to service workers.
153
+ */
154
+ export const files: string[];
155
+ /**
156
+ * The result of calling `Date.now()` at build time.
157
+ * It's useful for generating unique cache names inside your service worker,
158
+ * so that a later deployment of your app can invalidate old caches.
159
+ * This is only available to service workers.
160
+ */
161
+ export const timestamp: number;
162
+ }
163
+
164
+ declare module '@sveltejs/kit/hooks' {
165
+ import { Handle } from '@sveltejs/kit';
166
+
167
+ /**
168
+ * Utility function that allows chaining `handle` functions in a
169
+ * middleware-like manner.
170
+ *
171
+ * @param handlers The chain of `handle` functions
172
+ */
173
+ export function sequence(...handlers: Handle[]): Handle;
174
+ }
175
+
176
+ declare module '@sveltejs/kit/node' {
177
+ import { IncomingMessage } from 'http';
178
+ import { RawBody } from '@sveltejs/kit';
179
+
180
+ export interface GetRawBody {
181
+ (request: IncomingMessage): Promise<RawBody>;
182
+ }
183
+ export const getRawBody: GetRawBody;
184
+ }
185
+
186
+ declare module '@sveltejs/kit/ssr' {
187
+ import { IncomingRequest, Response } from '@sveltejs/kit';
188
+ // TODO import from public types, right now its heavily coupled with internal
189
+ type Options = import('@sveltejs/kit/types/internal').SSRRenderOptions;
190
+ type State = import('@sveltejs/kit/types/internal').SSRRenderState;
191
+
192
+ export interface Respond {
193
+ (incoming: IncomingRequest & { url: URL }, options: Options, state?: State): Promise<
194
+ Response | undefined
195
+ >;
196
+ }
197
+ export const respond: Respond;
198
+ }
199
+
200
+ declare module '@sveltejs/kit/install-fetch' {
201
+ import fetch, { Headers, Request, Response } from 'node-fetch';
202
+
203
+ export { fetch, Headers, Request, Response };
204
+ }
package/types/app.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { ReadOnlyFormData, RequestHeaders } from './helper';
2
+ import { ServerResponse } from './hooks';
3
+ import { PrerenderOptions, SSRNodeLoader, SSRRoute } from './internal';
4
+
5
+ export class App {
6
+ constructor(manifest: SSRManifest);
7
+ render(incoming: IncomingRequest): Promise<ServerResponse>;
8
+ }
9
+
10
+ export class InternalApp extends App {
11
+ render(
12
+ incoming: IncomingRequest,
13
+ options?: {
14
+ prerender: PrerenderOptions;
15
+ }
16
+ ): Promise<ServerResponse>;
17
+ }
18
+
19
+ export type RawBody = null | Uint8Array;
20
+ export type ParameterizedBody<Body = unknown> = Body extends FormData
21
+ ? ReadOnlyFormData
22
+ : (string | RawBody | ReadOnlyFormData) & Body;
23
+
24
+ export interface IncomingRequest {
25
+ url: string | URL;
26
+ method: string;
27
+ headers: RequestHeaders;
28
+ rawBody: RawBody;
29
+ }
30
+
31
+ export interface SSRManifest {
32
+ appDir: string;
33
+ assets: Set<string>;
34
+ /** private fields */
35
+ _: {
36
+ mime: Record<string, string>;
37
+ entry: {
38
+ file: string;
39
+ js: string[];
40
+ css: string[];
41
+ };
42
+ nodes: SSRNodeLoader[];
43
+ routes: SSRRoute[];
44
+ };
45
+ }
@@ -0,0 +1,169 @@
1
+ import { UserConfig as ViteConfig } from 'vite';
2
+ import { RecursiveRequired } from './helper';
3
+ import { HttpMethod, Logger, RouteSegment, TrailingSlash } from './internal';
4
+
5
+ export interface RouteDefinition {
6
+ type: 'page' | 'endpoint';
7
+ pattern: RegExp;
8
+ segments: RouteSegment[];
9
+ methods: HttpMethod[];
10
+ }
11
+
12
+ export interface AdapterEntry {
13
+ /**
14
+ * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
15
+ * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
16
+ * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
17
+ */
18
+ id: string;
19
+
20
+ /**
21
+ * A function that compares the candidate route with the current route to determine
22
+ * if it should be treated as a fallback for the current route. For example, `/foo/[c]`
23
+ * is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
24
+ */
25
+ filter: (route: RouteDefinition) => boolean;
26
+
27
+ /**
28
+ * A function that is invoked once the entry has been created. This is where you
29
+ * should write the function to the filesystem and generate redirect manifests.
30
+ */
31
+ complete: (entry: {
32
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
33
+ }) => void;
34
+ }
35
+
36
+ export interface Builder {
37
+ log: Logger;
38
+ rimraf(dir: string): void;
39
+ mkdirp(dir: string): void;
40
+
41
+ appDir: string;
42
+
43
+ /**
44
+ * Create entry points that map to individual functions
45
+ * @param fn A function that groups a set of routes into an entry point
46
+ */
47
+ createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
48
+
49
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
50
+
51
+ getBuildDirectory(name: string): string;
52
+ getClientDirectory(): string;
53
+ getServerDirectory(): string;
54
+ getStaticDirectory(): string;
55
+
56
+ /**
57
+ * @param dest the destination folder to which files should be copied
58
+ * @returns an array of paths corresponding to the files that have been created by the copy
59
+ */
60
+ writeClient(dest: string): string[];
61
+ /**
62
+ * @param dest the destination folder to which files should be copied
63
+ * @returns an array of paths corresponding to the files that have been created by the copy
64
+ */
65
+ writeServer(dest: string): string[];
66
+ /**
67
+ * @param dest the destination folder to which files should be copied
68
+ * @returns an array of paths corresponding to the files that have been created by the copy
69
+ */
70
+ writeStatic(dest: string): string[];
71
+ /**
72
+ * @param from the source file or folder
73
+ * @param to the destination file or folder
74
+ * @param opts.filter a function to determine whether a file or folder should be copied
75
+ * @param opts.replace a map of strings to replace
76
+ * @returns an array of paths corresponding to the files that have been created by the copy
77
+ */
78
+ copy(
79
+ from: string,
80
+ to: string,
81
+ opts?: {
82
+ filter?: (basename: string) => boolean;
83
+ replace?: Record<string, string>;
84
+ }
85
+ ): string[];
86
+
87
+ prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<{
88
+ paths: string[];
89
+ }>;
90
+ }
91
+
92
+ export interface Adapter {
93
+ name: string;
94
+ headers?: {
95
+ host?: string;
96
+ protocol?: string;
97
+ };
98
+ adapt(builder: Builder): Promise<void>;
99
+ }
100
+
101
+ export interface PrerenderErrorHandler {
102
+ (details: {
103
+ status: number;
104
+ path: string;
105
+ referrer: string | null;
106
+ referenceType: 'linked' | 'fetched';
107
+ }): void;
108
+ }
109
+
110
+ export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
111
+
112
+ export interface Config {
113
+ compilerOptions?: any;
114
+ extensions?: string[];
115
+ kit?: {
116
+ adapter?: Adapter;
117
+ amp?: boolean;
118
+ appDir?: string;
119
+ files?: {
120
+ assets?: string;
121
+ hooks?: string;
122
+ lib?: string;
123
+ routes?: string;
124
+ serviceWorker?: string;
125
+ template?: string;
126
+ };
127
+ floc?: boolean;
128
+ headers?: {
129
+ host?: string;
130
+ protocol?: string;
131
+ };
132
+ host?: string;
133
+ hydrate?: boolean;
134
+ inlineStyleThreshold?: number;
135
+ methodOverride?: {
136
+ parameter?: string;
137
+ allowed?: string[];
138
+ };
139
+ package?: {
140
+ dir?: string;
141
+ emitTypes?: boolean;
142
+ exports?(filepath: string): boolean;
143
+ files?(filepath: string): boolean;
144
+ };
145
+ paths?: {
146
+ assets?: string;
147
+ base?: string;
148
+ };
149
+ prerender?: {
150
+ concurrency?: number;
151
+ crawl?: boolean;
152
+ enabled?: boolean;
153
+ entries?: string[];
154
+ onError?: PrerenderOnErrorValue;
155
+ };
156
+ protocol?: string;
157
+ router?: boolean;
158
+ serviceWorker?: {
159
+ register?: boolean;
160
+ files?: (filepath: string) => boolean;
161
+ };
162
+ target?: string;
163
+ trailingSlash?: TrailingSlash;
164
+ vite?: ViteConfig | (() => ViteConfig);
165
+ };
166
+ preprocess?: any;
167
+ }
168
+
169
+ export type ValidatedConfig = RecursiveRequired<Config>;
@@ -0,0 +1,20 @@
1
+ import { ServerRequest } from './hooks';
2
+ import { JSONString, MaybePromise, ResponseHeaders, Either, Fallthrough } from './helper';
3
+
4
+ type DefaultBody = JSONString | Uint8Array;
5
+
6
+ export interface EndpointOutput<Body extends DefaultBody = DefaultBody> {
7
+ status?: number;
8
+ headers?: Partial<ResponseHeaders>;
9
+ body?: Body;
10
+ }
11
+
12
+ export interface RequestHandler<
13
+ Locals = Record<string, any>,
14
+ Input = unknown,
15
+ Output extends DefaultBody = DefaultBody
16
+ > {
17
+ (request: ServerRequest<Locals, Input>): MaybePromise<
18
+ Either<EndpointOutput<Output>, Fallthrough>
19
+ >;
20
+ }