@sveltejs/kit 1.0.0-next.99 → 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 -159
  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 -825
  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 -3532
  125. package/dist/chunks/index2.js +0 -583
  126. package/dist/chunks/index3.js +0 -31
  127. package/dist/chunks/index4.js +0 -1004
  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 -1523
  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 -21
  141. package/types/page.d.ts +0 -30
package/README.md CHANGED
@@ -5,10 +5,14 @@ This is the [SvelteKit](https://kit.svelte.dev) framework and CLI.
5
5
  The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) package:
6
6
 
7
7
  ```bash
8
- npm init svelte@next my-app
8
+ npm create svelte@latest my-app
9
9
  cd my-app
10
10
  npm install
11
11
  npm run dev
12
12
  ```
13
13
 
14
14
  See the [documentation](https://kit.svelte.dev/docs) to learn more.
15
+
16
+ ## Changelog
17
+
18
+ [The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md).
package/package.json CHANGED
@@ -1,78 +1,92 @@
1
1
  {
2
- "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.99",
4
- "type": "module",
5
- "dependencies": {
6
- "@sveltejs/vite-plugin-svelte": "^1.0.0-next.9",
7
- "cheap-watch": "^1.0.3",
8
- "sade": "^1.7.4"
9
- },
10
- "devDependencies": {
11
- "@rollup/plugin-replace": "^2.4.2",
12
- "@sveltejs/kit": "1.0.0-next.99",
13
- "@types/amphtml-validator": "^1.0.1",
14
- "@types/cookie": "^0.4.0",
15
- "@types/mime": "^2.0.3",
16
- "@types/node": "^14.14.43",
17
- "@types/rimraf": "^3.0.0",
18
- "@types/sade": "^1.7.2",
19
- "amphtml-validator": "^1.0.34",
20
- "cookie": "^0.4.1",
21
- "devalue": "^2.0.1",
22
- "eslint": "^7.25.0",
23
- "kleur": "^4.1.4",
24
- "marked": "^2.0.3",
25
- "node-fetch": "^3.0.0-beta.9",
26
- "port-authority": "^1.1.2",
27
- "rimraf": "^3.0.2",
28
- "rollup": "^2.46.0",
29
- "selfsigned": "^1.10.8",
30
- "sirv": "^1.0.11",
31
- "svelte": "^3.35.0",
32
- "tiny-glob": "^0.2.8",
33
- "typescript": "^4.2.4",
34
- "uvu": "^0.5.1",
35
- "vite": "^2.2.3"
36
- },
37
- "peerDependencies": {
38
- "svelte": "^3.34.0",
39
- "vite": "^2.2.3"
40
- },
41
- "bin": {
42
- "svelte-kit": "svelte-kit.js"
43
- },
44
- "files": [
45
- "assets",
46
- "dist",
47
- "types",
48
- "svelte-kit.js"
49
- ],
50
- "exports": {
51
- "./package.json": "./package.json",
52
- "./ssr": {
53
- "import": "./dist/ssr.js"
54
- },
55
- "./http": {
56
- "import": "./dist/http.js"
57
- },
58
- "./install-fetch": {
59
- "import": "./dist/install-fetch.js"
60
- },
61
- "./types": "./types/index.d.ts"
62
- },
63
- "types": "types/index.d.ts",
64
- "engines": {
65
- "node": ">= 12.17.0"
66
- },
67
- "scripts": {
68
- "dev": "rm -rf assets/runtime && rollup -cw",
69
- "build": "rm -rf assets/runtime && rollup -c",
70
- "lint": "eslint --ignore-path .gitignore \"src/**/*.{ts,mjs,js,svelte}\" && npm run check-format",
71
- "check": "npx tsc",
72
- "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
73
- "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
74
- "test": "npm run test:unit && npm run test:integration",
75
- "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
76
- "test:integration": "uvu test test.js"
77
- }
78
- }
2
+ "name": "@sveltejs/kit",
3
+ "version": "1.0.0",
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": "^2.0.0",
14
+ "@types/cookie": "^0.5.1",
15
+ "cookie": "^0.5.0",
16
+ "devalue": "^4.2.0",
17
+ "esm-env": "^1.0.0",
18
+ "kleur": "^4.1.5",
19
+ "magic-string": "^0.27.0",
20
+ "mime": "^3.0.0",
21
+ "sade": "^1.8.1",
22
+ "set-cookie-parser": "^2.5.1",
23
+ "sirv": "^2.0.2",
24
+ "tiny-glob": "^0.2.9",
25
+ "undici": "5.14.0"
26
+ },
27
+ "devDependencies": {
28
+ "@playwright/test": "^1.28.1",
29
+ "@types/connect": "^3.4.35",
30
+ "@types/marked": "^4.0.7",
31
+ "@types/mime": "^3.0.1",
32
+ "@types/node": "^16.18.6",
33
+ "@types/sade": "^1.7.4",
34
+ "@types/set-cookie-parser": "^2.4.2",
35
+ "marked": "^4.2.3",
36
+ "rollup": "^3.7.0",
37
+ "svelte": "^3.54.0",
38
+ "svelte-preprocess": "^5.0.0",
39
+ "typescript": "^4.9.3",
40
+ "uvu": "^0.5.6",
41
+ "vite": "^4.0.0"
42
+ },
43
+ "peerDependencies": {
44
+ "svelte": "^3.54.0",
45
+ "vite": "^4.0.0"
46
+ },
47
+ "bin": {
48
+ "svelte-kit": "svelte-kit.js"
49
+ },
50
+ "files": [
51
+ "src",
52
+ "!src/**/*.spec.js",
53
+ "!src/core/**/fixtures",
54
+ "!src/core/**/test",
55
+ "types",
56
+ "svelte-kit.js",
57
+ "postinstall.js"
58
+ ],
59
+ "exports": {
60
+ "./package.json": "./package.json",
61
+ ".": {
62
+ "types": "./types/index.d.ts",
63
+ "import": "./src/exports/index.js"
64
+ },
65
+ "./node": {
66
+ "import": "./src/exports/node/index.js"
67
+ },
68
+ "./node/polyfills": {
69
+ "import": "./src/exports/node/polyfills.js"
70
+ },
71
+ "./hooks": {
72
+ "import": "./src/exports/hooks/index.js"
73
+ },
74
+ "./vite": {
75
+ "import": "./src/exports/vite/index.js"
76
+ }
77
+ },
78
+ "types": "types/index.d.ts",
79
+ "engines": {
80
+ "node": ">=16.14"
81
+ },
82
+ "scripts": {
83
+ "lint": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
84
+ "check": "tsc",
85
+ "check:all": "tsc && pnpm -r --filter=\"./**\" check",
86
+ "format": "pnpm lint --write",
87
+ "test": "pnpm test:unit && pnpm test:integration",
88
+ "test:integration": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test",
89
+ "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
90
+ "postinstall": "node postinstall.js"
91
+ }
92
+ }
package/postinstall.js ADDED
@@ -0,0 +1,47 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import glob from 'tiny-glob/sync.js';
4
+ import { load_config } from './src/core/config/index.js';
5
+ import * as sync from './src/core/sync/sync.js';
6
+
7
+ try {
8
+ const cwd = process.env.INIT_CWD ?? process.cwd();
9
+ process.chdir(cwd);
10
+
11
+ if (fs.existsSync('package.json')) {
12
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
13
+
14
+ const directories = [];
15
+
16
+ if (pkg.workspaces) {
17
+ // we have to do this because of https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
18
+ const packages = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages;
19
+
20
+ for (const directory of packages) {
21
+ directories.push(...glob(directory, { cwd }).map((dir) => path.resolve(cwd, dir)));
22
+ }
23
+ } else {
24
+ directories.push(cwd);
25
+ }
26
+
27
+ for (const cwd of directories) {
28
+ process.chdir(cwd);
29
+
30
+ if (!fs.existsSync('package.json')) continue;
31
+ if (!fs.existsSync('svelte.config.js')) continue;
32
+
33
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
34
+ if (!pkg.dependencies?.['@sveltejs/kit'] && !pkg.devDependencies?.['@sveltejs/kit']) continue;
35
+
36
+ try {
37
+ const config = await load_config();
38
+ await sync.all(config, 'development');
39
+ } catch (error) {
40
+ console.log('Error while trying to sync SvelteKit config');
41
+ console.log(error.stack);
42
+ }
43
+ }
44
+ }
45
+ } catch (error) {
46
+ console.error(error.stack);
47
+ }
package/src/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import colors from 'kleur';
4
+ import sade from 'sade';
5
+ import { load_config } from './core/config/index.js';
6
+ import { coalesce_to_error } from './utils/error.js';
7
+
8
+ /** @param {unknown} e */
9
+ function handle_error(e) {
10
+ const error = coalesce_to_error(e);
11
+
12
+ if (error.name === 'SyntaxError') throw error;
13
+
14
+ console.error(colors.bold().red(`> ${error.message}`));
15
+ if (error.stack) {
16
+ console.error(colors.gray(error.stack.split('\n').slice(1).join('\n')));
17
+ }
18
+
19
+ process.exit(1);
20
+ }
21
+
22
+ const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
23
+ const prog = sade('svelte-kit').version(pkg.version);
24
+
25
+ prog
26
+ .command('sync')
27
+ .describe('Synchronise generated files')
28
+ .option('--mode', 'Specify a mode for loading environment variables', 'development')
29
+ .action(async ({ mode }) => {
30
+ if (!fs.existsSync('svelte.config.js')) {
31
+ console.warn(`Missing ${path.resolve('svelte.config.js')} — skipping`);
32
+ return;
33
+ }
34
+
35
+ try {
36
+ const config = await load_config();
37
+ const sync = await import('./core/sync/sync.js');
38
+ await sync.all(config, mode);
39
+ } catch (error) {
40
+ handle_error(error);
41
+ }
42
+ });
43
+
44
+ prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
@@ -0,0 +1,5 @@
1
+ // in `vite dev` and `vite preview`, we use a fake asset path so that we can
2
+ // serve local assets while verifying that requests are correctly prefixed
3
+ export const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
4
+
5
+ export const GENERATED_COMMENT = '// this file is generated — do not edit it\n';
@@ -0,0 +1,221 @@
1
+ import { existsSync, statSync, createReadStream, createWriteStream } from 'node:fs';
2
+ import { pipeline } from 'node:stream';
3
+ import { promisify } from 'node:util';
4
+ import { fork } from 'node:child_process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import glob from 'tiny-glob';
7
+ import zlib from 'zlib';
8
+ import { copy, rimraf, mkdirp } from '../../utils/filesystem.js';
9
+ import { generate_manifest } from '../generate_manifest/index.js';
10
+ import { get_route_segments } from '../../utils/routing.js';
11
+ import { get_env } from '../../exports/vite/utils.js';
12
+
13
+ const pipe = promisify(pipeline);
14
+
15
+ /**
16
+ * Creates the Builder which is passed to adapters for building the application.
17
+ * @param {{
18
+ * config: import('types').ValidatedConfig;
19
+ * build_data: import('types').BuildData;
20
+ * routes: import('types').RouteData[];
21
+ * prerendered: import('types').Prerendered;
22
+ * log: import('types').Logger;
23
+ * }} opts
24
+ * @returns {import('types').Builder}
25
+ */
26
+ export function create_builder({ config, build_data, routes, prerendered, log }) {
27
+ return {
28
+ log,
29
+ rimraf,
30
+ mkdirp,
31
+ copy,
32
+
33
+ config,
34
+ prerendered,
35
+
36
+ async compress(directory) {
37
+ if (!existsSync(directory)) {
38
+ return;
39
+ }
40
+
41
+ const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
42
+ cwd: directory,
43
+ dot: true,
44
+ absolute: true,
45
+ filesOnly: true
46
+ });
47
+
48
+ await Promise.all(
49
+ files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
50
+ );
51
+ },
52
+
53
+ async createEntries(fn) {
54
+ /** @type {import('types').RouteDefinition[]} */
55
+ const facades = routes.map((route) => {
56
+ /** @type {Set<import('types').HttpMethod>} */
57
+ const methods = new Set();
58
+
59
+ if (route.page) {
60
+ methods.add('GET');
61
+ }
62
+
63
+ if (route.endpoint) {
64
+ for (const method of build_data.server.methods[route.endpoint.file]) {
65
+ methods.add(method);
66
+ }
67
+ }
68
+
69
+ return {
70
+ id: route.id,
71
+ segments: get_route_segments(route.id).map((segment) => ({
72
+ dynamic: segment.includes('['),
73
+ rest: segment.includes('[...'),
74
+ content: segment
75
+ })),
76
+ pattern: route.pattern,
77
+ methods: Array.from(methods)
78
+ };
79
+ });
80
+
81
+ const seen = new Set();
82
+
83
+ for (let i = 0; i < routes.length; i += 1) {
84
+ const route = routes[i];
85
+ const { id, filter, complete } = fn(facades[i]);
86
+
87
+ if (seen.has(id)) continue;
88
+ seen.add(id);
89
+
90
+ const group = [route];
91
+
92
+ // figure out which lower priority routes should be considered fallbacks
93
+ for (let j = i + 1; j < routes.length; j += 1) {
94
+ if (filter(facades[j])) {
95
+ group.push(routes[j]);
96
+ }
97
+ }
98
+
99
+ const filtered = new Set(group);
100
+
101
+ // heuristic: if /foo/[bar] is included, /foo/[bar].json should
102
+ // also be included, since the page likely needs the endpoint
103
+ // TODO is this still necessary, given the new way of doing things?
104
+ filtered.forEach((route) => {
105
+ if (route.page) {
106
+ const endpoint = routes.find((candidate) => candidate.id === route.id + '.json');
107
+
108
+ if (endpoint) {
109
+ filtered.add(endpoint);
110
+ }
111
+ }
112
+ });
113
+
114
+ if (filtered.size > 0) {
115
+ await complete({
116
+ generateManifest: ({ relativePath }) =>
117
+ generate_manifest({
118
+ build_data,
119
+ relative_path: relativePath,
120
+ routes: Array.from(filtered)
121
+ })
122
+ });
123
+ }
124
+ }
125
+ },
126
+
127
+ generateFallback(dest) {
128
+ // do prerendering in a subprocess so any dangling stuff gets killed upon completion
129
+ const script = fileURLToPath(new URL('../prerender/fallback.js', import.meta.url));
130
+
131
+ const manifest_path = `${config.kit.outDir}/output/server/manifest-full.js`;
132
+
133
+ const env = get_env(config.kit.env, 'production');
134
+
135
+ return new Promise((fulfil, reject) => {
136
+ const child = fork(
137
+ script,
138
+ [dest, manifest_path, JSON.stringify({ ...env.private, ...env.public })],
139
+ {
140
+ stdio: 'inherit'
141
+ }
142
+ );
143
+
144
+ child.on('exit', (code) => {
145
+ if (code) {
146
+ reject(new Error(`Could not create a fallback page — failed with code ${code}`));
147
+ } else {
148
+ fulfil(undefined);
149
+ }
150
+ });
151
+ });
152
+ },
153
+
154
+ generateManifest: ({ relativePath }) => {
155
+ return generate_manifest({
156
+ build_data,
157
+ relative_path: relativePath,
158
+ routes
159
+ });
160
+ },
161
+
162
+ getBuildDirectory(name) {
163
+ return `${config.kit.outDir}/${name}`;
164
+ },
165
+
166
+ getClientDirectory() {
167
+ return `${config.kit.outDir}/output/client`;
168
+ },
169
+
170
+ getServerDirectory() {
171
+ return `${config.kit.outDir}/output/server`;
172
+ },
173
+
174
+ getAppPath() {
175
+ return build_data.app_path;
176
+ },
177
+
178
+ writeClient(dest) {
179
+ return [...copy(`${config.kit.outDir}/output/client`, dest)];
180
+ },
181
+
182
+ // @ts-expect-error
183
+ writePrerendered(dest, opts) {
184
+ // TODO remove for 1.0
185
+ if (opts?.fallback) {
186
+ throw new Error(
187
+ 'The fallback option no longer exists — use builder.generateFallback(fallback) instead'
188
+ );
189
+ }
190
+
191
+ const source = `${config.kit.outDir}/output/prerendered`;
192
+ return [...copy(`${source}/pages`, dest), ...copy(`${source}/dependencies`, dest)];
193
+ },
194
+
195
+ writeServer(dest) {
196
+ return copy(`${config.kit.outDir}/output/server`, dest);
197
+ }
198
+ };
199
+ }
200
+
201
+ /**
202
+ * @param {string} file
203
+ * @param {'gz' | 'br'} format
204
+ */
205
+ async function compress_file(file, format = 'gz') {
206
+ const compress =
207
+ format == 'br'
208
+ ? zlib.createBrotliCompress({
209
+ params: {
210
+ [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
211
+ [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
212
+ [zlib.constants.BROTLI_PARAM_SIZE_HINT]: statSync(file).size
213
+ }
214
+ })
215
+ : zlib.createGzip({ level: zlib.constants.Z_BEST_COMPRESSION });
216
+
217
+ const source = createReadStream(file);
218
+ const destination = createWriteStream(`${file}.${format}`);
219
+
220
+ await pipe(source, compress, destination);
221
+ }
@@ -0,0 +1,31 @@
1
+ import colors from 'kleur';
2
+ import { create_builder } from './builder.js';
3
+
4
+ /**
5
+ * @param {import('types').ValidatedConfig} config
6
+ * @param {import('types').BuildData} build_data
7
+ * @param {import('types').Prerendered} prerendered
8
+ * @param {import('types').PrerenderMap} prerender_map
9
+ * @param {{ log: import('types').Logger }} opts
10
+ */
11
+ export async function adapt(config, build_data, prerendered, prerender_map, { log }) {
12
+ const { name, adapt } = config.kit.adapter;
13
+
14
+ console.log(colors.bold().cyan(`\n> Using ${name}`));
15
+
16
+ const builder = create_builder({
17
+ config,
18
+ build_data,
19
+ routes: build_data.manifest_data.routes.filter((route) => {
20
+ if (!route.page && !route.endpoint) return false;
21
+
22
+ const prerender = prerender_map.get(route.id);
23
+ return prerender === false || prerender === undefined || prerender === 'auto';
24
+ }),
25
+ prerendered,
26
+ log
27
+ });
28
+ await adapt(builder);
29
+
30
+ log.success('done');
31
+ }
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>%sveltekit.error.message%</title>
6
+
7
+ <style>
8
+ body {
9
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
10
+ Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ height: 100vh;
15
+ }
16
+
17
+ .error {
18
+ display: flex;
19
+ align-items: center;
20
+ max-width: 32rem;
21
+ margin: 0 1rem;
22
+ }
23
+
24
+ .status {
25
+ font-weight: 200;
26
+ font-size: 3rem;
27
+ line-height: 1;
28
+ position: relative;
29
+ top: -0.05rem;
30
+ }
31
+
32
+ .message {
33
+ border-left: 1px solid #ccc;
34
+ padding: 0 0 0 1rem;
35
+ margin: 0 0 0 1rem;
36
+ min-height: 2.5rem;
37
+ display: flex;
38
+ align-items: center;
39
+ }
40
+
41
+ .message h1 {
42
+ font-weight: 400;
43
+ font-size: 1em;
44
+ margin: 0;
45
+ }
46
+ </style>
47
+ </head>
48
+ <body>
49
+ <div class="error">
50
+ <span class="status">%sveltekit.status%</span>
51
+ <div class="message">
52
+ <h1>%sveltekit.error.message%</h1>
53
+ </div>
54
+ </div>
55
+ </body>
56
+ </html>