@sveltejs/kit 3.0.0-next.2 → 3.0.0-next.21
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.
- package/package.json +62 -36
- package/src/cli.js +15 -12
- package/src/constants.js +6 -1
- package/src/core/adapt/builder.js +66 -72
- package/src/core/adapt/index.js +17 -6
- package/src/core/config/index.js +134 -80
- package/src/core/config/options.js +295 -273
- package/src/core/config/types.d.ts +1 -1
- package/src/core/env.js +146 -16
- package/src/core/generate_manifest/index.js +18 -15
- package/src/core/postbuild/analyse.js +8 -20
- package/src/core/postbuild/crawl.js +22 -6
- package/src/core/postbuild/entities.js +8 -2
- package/src/core/postbuild/fallback.js +4 -2
- package/src/core/postbuild/prerender.js +222 -70
- package/src/core/postbuild/queue.js +2 -1
- package/src/core/sync/create_manifest_data/conflict.js +1 -1
- package/src/core/sync/create_manifest_data/index.js +82 -62
- package/src/core/sync/sync.js +40 -31
- package/src/core/sync/ts.js +1 -1
- package/src/core/sync/utils.js +22 -2
- package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
- package/src/core/sync/write_client_manifest.js +14 -29
- package/src/core/sync/write_env.js +7 -5
- package/src/core/sync/write_server.js +37 -45
- package/src/core/sync/write_tsconfig/index.js +274 -0
- package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
- package/src/core/sync/write_tsconfig/utils.js +77 -0
- package/src/core/sync/write_tsconfig/validate.js +128 -0
- package/src/core/sync/write_types/index.js +127 -123
- package/src/core/utils.js +30 -5
- package/src/exports/env/index.js +77 -0
- package/src/exports/env/public.d.ts +55 -0
- package/src/exports/hooks/index.js +3 -9
- package/src/exports/hooks/public.d.ts +195 -0
- package/src/exports/hooks/sequence.js +9 -6
- package/src/exports/index.js +52 -29
- package/src/exports/internal/client.js +5 -0
- package/src/exports/internal/env.js +8 -5
- package/src/exports/internal/index.js +1 -90
- package/src/exports/internal/{event.js → server/event.js} +2 -3
- package/src/exports/internal/server/index.js +37 -0
- package/src/exports/internal/server/telemetry.js +95 -0
- package/src/exports/internal/shared.js +90 -0
- package/src/exports/node/index.js +64 -22
- package/src/exports/params/index.js +70 -0
- package/src/exports/params/public.d.ts +63 -0
- package/src/exports/public.d.ts +50 -1733
- package/src/exports/remote/index.js +11 -0
- package/src/exports/remote/public.d.ts +519 -0
- package/src/exports/url.js +86 -0
- package/src/exports/vite/build/build_server.js +54 -65
- package/src/exports/vite/build/remote.js +24 -19
- package/src/exports/vite/build/utils.js +0 -8
- package/src/exports/vite/dev/index.js +218 -146
- package/src/exports/vite/index.js +1590 -858
- package/src/exports/vite/module_ids.js +2 -2
- package/src/exports/vite/preview/index.js +40 -32
- package/src/exports/vite/public.d.ts +588 -0
- package/src/exports/vite/utils.js +84 -46
- package/src/pathname.js +55 -0
- package/src/runner.js +15 -0
- package/src/runtime/app/env/internal.js +4 -4
- package/src/runtime/app/env/types.d.ts +1 -1
- package/src/runtime/app/environment/index.js +3 -3
- package/src/runtime/app/{forms.js → forms/index.js} +73 -42
- package/src/runtime/app/forms/public.d.ts +2 -0
- package/src/runtime/app/forms/types.d.ts +56 -0
- package/src/runtime/app/internal/transport.js +53 -0
- package/src/runtime/app/manifest/index.js +1 -0
- package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
- package/src/runtime/app/navigation/public.d.ts +237 -0
- package/src/runtime/app/paths/client.js +37 -37
- package/src/runtime/app/paths/index.js +1 -1
- package/src/runtime/app/paths/internal/client.js +34 -2
- package/src/runtime/app/paths/internal/server.js +6 -23
- package/src/runtime/app/paths/internal.d.ts +3 -0
- package/src/runtime/app/paths/public.d.ts +1 -29
- package/src/runtime/app/paths/server.js +36 -17
- package/src/runtime/app/paths/types.d.ts +11 -19
- package/src/runtime/app/server/index.js +2 -2
- package/src/runtime/app/server/public.d.ts +201 -0
- package/src/runtime/app/server/remote/command.js +13 -11
- package/src/runtime/app/server/remote/form.js +61 -39
- package/src/runtime/app/server/remote/prerender.js +45 -45
- package/src/runtime/app/server/remote/query.js +106 -108
- package/src/runtime/app/server/remote/requested.js +27 -19
- package/src/runtime/app/server/remote/shared.js +76 -76
- package/src/runtime/app/service-worker/index.js +24 -0
- package/src/runtime/app/state/client.js +4 -2
- package/src/runtime/app/state/index.js +7 -5
- package/src/runtime/app/state/public.d.ts +72 -0
- package/src/runtime/app/state/server.js +3 -0
- package/src/runtime/app/stores.js +15 -78
- package/src/runtime/client/bundle.js +1 -1
- package/src/runtime/client/client-entry.js +3 -0
- package/src/runtime/client/client.js +1336 -648
- package/src/runtime/client/constants.js +3 -6
- package/src/runtime/client/entry.js +24 -3
- package/src/runtime/client/fetcher.js +25 -25
- package/src/runtime/client/ndjson.js +1 -1
- package/src/runtime/client/parse.js +1 -1
- package/src/runtime/client/payload.js +17 -0
- package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
- package/src/runtime/client/remote-functions/command.svelte.js +37 -61
- package/src/runtime/client/remote-functions/form.svelte.js +267 -178
- package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
- package/src/runtime/client/remote-functions/query/index.js +10 -17
- package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
- package/src/runtime/client/remote-functions/query/proxy.js +5 -5
- package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
- package/src/runtime/client/remote-functions/query-live/index.js +1 -1
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
- package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
- package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
- package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
- package/src/runtime/client/snapshots.js +147 -0
- package/src/runtime/client/state.svelte.js +94 -55
- package/src/runtime/client/stream.js +3 -2
- package/src/runtime/client/types.d.ts +13 -9
- package/src/runtime/client/utils.js +22 -110
- package/src/runtime/components/root.svelte +56 -0
- package/src/runtime/env/dynamic/private.js +7 -0
- package/src/runtime/env/dynamic/public.js +7 -0
- package/src/runtime/env/static/private.js +6 -0
- package/src/runtime/env/static/public.js +6 -0
- package/src/runtime/form-utils.js +172 -61
- package/src/runtime/pathname.js +20 -32
- package/src/runtime/props.svelte.js +72 -0
- package/src/runtime/server/constants.js +0 -3
- package/src/runtime/server/cookie.js +72 -55
- package/src/runtime/server/csrf.js +65 -0
- package/src/runtime/server/data/index.js +49 -53
- package/src/runtime/server/dev.js +22 -0
- package/src/runtime/server/endpoint.js +6 -7
- package/src/runtime/server/env_module.js +0 -5
- package/src/runtime/server/errors.js +160 -0
- package/src/runtime/server/fetch.js +32 -39
- package/src/runtime/server/index.js +90 -64
- package/src/runtime/server/internal.js +71 -0
- package/src/runtime/server/page/actions.js +85 -64
- package/src/runtime/server/page/crypto.js +2 -2
- package/src/runtime/server/page/csp.js +88 -104
- package/src/runtime/server/page/data_serializer.js +24 -25
- package/src/runtime/server/page/index.js +36 -53
- package/src/runtime/server/page/load_data.js +50 -57
- package/src/runtime/server/page/render.js +173 -239
- package/src/runtime/server/page/respond_with_error.js +17 -31
- package/src/runtime/server/page/serialize_data.js +2 -13
- package/src/runtime/server/page/server_routing.js +85 -26
- package/src/runtime/server/remote-functions.js +640 -0
- package/src/runtime/server/respond.js +190 -131
- package/src/runtime/server/sourcemaps.js +183 -0
- package/src/runtime/server/state.js +53 -0
- package/src/runtime/server/utils.js +13 -155
- package/src/runtime/shared.js +20 -40
- package/src/runtime/utils.js +3 -0
- package/src/types/ambient-private.d.ts +11 -1
- package/src/types/ambient.d.ts +87 -36
- package/src/types/global-private.d.ts +25 -25
- package/src/types/internal.d.ts +163 -157
- package/src/types/private.d.ts +41 -1
- package/src/utils/error.js +28 -4
- package/src/utils/escape.js +9 -25
- package/src/utils/features.js +1 -1
- package/src/utils/filesystem.js +1 -23
- package/src/utils/fork.js +7 -2
- package/src/utils/hash.js +21 -0
- package/src/utils/http.js +8 -7
- package/src/utils/import.js +9 -2
- package/src/utils/imports.js +83 -0
- package/src/utils/mime.js +9 -0
- package/src/utils/page_nodes.js +6 -7
- package/src/utils/params.js +67 -0
- package/src/utils/regex.js +9 -0
- package/src/utils/routing.js +145 -73
- package/src/utils/shared-iterator.js +5 -0
- package/src/utils/streaming.js +14 -4
- package/src/utils/url.js +33 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +2616 -2433
- package/types/index.d.ts.map +120 -106
- package/src/core/sync/write_ambient.js +0 -18
- package/src/core/sync/write_root.js +0 -148
- package/src/core/sync/write_tsconfig.js +0 -250
- package/src/exports/internal/server.js +0 -22
- package/src/exports/node/polyfills.js +0 -30
- package/src/runtime/server/app.js +0 -9
- package/src/runtime/server/remote.js +0 -457
- package/src/runtime/shared-server.js +0 -7
- package/src/runtime/telemetry/otel.js +0 -21
- package/src/runtime/telemetry/record_span.js +0 -65
- package/src/types/synthetic/$lib.md +0 -5
- /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
- /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
package/src/core/config/index.js
CHANGED
|
@@ -1,13 +1,70 @@
|
|
|
1
|
-
/** @import { Config } from '@sveltejs/kit' */
|
|
1
|
+
/** @import { Config } from '@sveltejs/kit/vite' */
|
|
2
2
|
/** @import { ValidatedConfig } from 'types' */
|
|
3
3
|
/** @import { ResolvedConfig } from 'vite' */
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import * as url from 'node:url';
|
|
8
|
-
import
|
|
8
|
+
import { styleText } from 'node:util';
|
|
9
|
+
import { validate_options, kit_options, kit_experimental_options } from './options.js';
|
|
9
10
|
import { resolve_entry } from '../../utils/filesystem.js';
|
|
10
11
|
import { import_peer } from '../../utils/import.js';
|
|
12
|
+
import { stackless } from '../../utils/error.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Splits the config passed to the `sveltekit` Vite plugin into the options that
|
|
16
|
+
* SvelteKit processes itself and the options that are forwarded to
|
|
17
|
+
* `vite-plugin-svelte`. SvelteKit makes no assumptions about which options
|
|
18
|
+
* `vite-plugin-svelte` accepts — it plucks out its own options and passes
|
|
19
|
+
* everything else along (`vite-plugin-svelte` does its own validation).
|
|
20
|
+
* @param {Config} config
|
|
21
|
+
* @returns {{ svelte_config: Config, vite_plugin_svelte_config: Record<string, any> }}
|
|
22
|
+
*/
|
|
23
|
+
export function split_config(config) {
|
|
24
|
+
/** @type {Config} */
|
|
25
|
+
const svelte_config = {};
|
|
26
|
+
|
|
27
|
+
/** @type {Record<string, any>} */
|
|
28
|
+
const vite_plugin_svelte_config = {};
|
|
29
|
+
|
|
30
|
+
for (const key in config) {
|
|
31
|
+
if (key === 'experimental') {
|
|
32
|
+
// `experimental` is a namespace that both SvelteKit and vite-plugin-svelte
|
|
33
|
+
// use, so pluck out the flags SvelteKit recognises and pass the rest along
|
|
34
|
+
const experimental = /** @type {Record<string, any>} */ (config[key]) ?? {};
|
|
35
|
+
|
|
36
|
+
/** @type {Record<string, any>} */
|
|
37
|
+
const kit_experimental = {};
|
|
38
|
+
/** @type {Record<string, any>} */
|
|
39
|
+
const vps_experimental = {};
|
|
40
|
+
|
|
41
|
+
for (const flag in experimental) {
|
|
42
|
+
if (kit_experimental_options.includes(flag)) {
|
|
43
|
+
kit_experimental[flag] = experimental[flag];
|
|
44
|
+
} else {
|
|
45
|
+
vps_experimental[flag] = experimental[flag];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (Object.keys(kit_experimental).length > 0) {
|
|
50
|
+
svelte_config.experimental = kit_experimental;
|
|
51
|
+
}
|
|
52
|
+
if (Object.keys(vps_experimental).length > 0) {
|
|
53
|
+
vite_plugin_svelte_config.experimental = vps_experimental;
|
|
54
|
+
}
|
|
55
|
+
} else if (kit_options.includes(key)) {
|
|
56
|
+
// @ts-expect-error - we've verified this is one of SvelteKit's own options
|
|
57
|
+
svelte_config[key] = config[key];
|
|
58
|
+
} else {
|
|
59
|
+
vite_plugin_svelte_config[key] = /** @type {Record<string, any>} */ (config)[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
svelte_config,
|
|
65
|
+
vite_plugin_svelte_config
|
|
66
|
+
};
|
|
67
|
+
}
|
|
11
68
|
|
|
12
69
|
/**
|
|
13
70
|
* Loads the template (src/app.html by default) and validates that it has the
|
|
@@ -15,8 +72,8 @@ import { import_peer } from '../../utils/import.js';
|
|
|
15
72
|
* @param {string} cwd
|
|
16
73
|
* @param {ValidatedConfig} config
|
|
17
74
|
*/
|
|
18
|
-
export function load_template(cwd,
|
|
19
|
-
const { files } =
|
|
75
|
+
export function load_template(cwd, config) {
|
|
76
|
+
const { files } = config;
|
|
20
77
|
|
|
21
78
|
const relative = path.relative(cwd, files.appTemplate);
|
|
22
79
|
|
|
@@ -42,11 +99,11 @@ export function load_template(cwd, { kit }) {
|
|
|
42
99
|
* @param {ValidatedConfig} config
|
|
43
100
|
*/
|
|
44
101
|
export function load_error_page(config) {
|
|
45
|
-
let { errorTemplate } = config.
|
|
102
|
+
let { errorTemplate } = config.files;
|
|
46
103
|
|
|
47
104
|
// Don't do this inside resolving the config, because that would mean
|
|
48
105
|
// adding/removing error.html isn't detected and would require a restart.
|
|
49
|
-
if (!fs.existsSync(config.
|
|
106
|
+
if (!fs.existsSync(config.files.errorTemplate)) {
|
|
50
107
|
errorTemplate = url.fileURLToPath(new URL('./default-error.html', import.meta.url));
|
|
51
108
|
}
|
|
52
109
|
|
|
@@ -55,13 +112,12 @@ export function load_error_page(config) {
|
|
|
55
112
|
|
|
56
113
|
/**
|
|
57
114
|
* @param {string} [config]
|
|
115
|
+
* @param {typeof import('vite')} [vite]
|
|
58
116
|
*/
|
|
59
|
-
export async function load_vite_config(config) {
|
|
60
|
-
|
|
61
|
-
await import_peer('vite', process.cwd())
|
|
62
|
-
);
|
|
117
|
+
export async function load_vite_config(config, vite) {
|
|
118
|
+
vite ??= /** @type {typeof import('vite')} */ (await import_peer('vite', process.cwd()));
|
|
63
119
|
|
|
64
|
-
return resolveConfig({ configFile: config }, 'build', process.env.MODE ?? 'production');
|
|
120
|
+
return vite.resolveConfig({ configFile: config }, 'build', process.env.MODE ?? 'production');
|
|
65
121
|
}
|
|
66
122
|
|
|
67
123
|
/**
|
|
@@ -70,98 +126,96 @@ export async function load_vite_config(config) {
|
|
|
70
126
|
*/
|
|
71
127
|
export function extract_svelte_config(vite_config) {
|
|
72
128
|
const plugin = vite_config.plugins.find((p) => p.name === 'vite-plugin-sveltekit-setup');
|
|
73
|
-
return plugin?.api.options ?? process_config({});
|
|
129
|
+
return plugin?.api.options ?? process_config(validate_config({}), vite_config.root);
|
|
74
130
|
}
|
|
75
131
|
|
|
76
132
|
/**
|
|
77
|
-
* @param {
|
|
133
|
+
* @param {ValidatedConfig} config
|
|
134
|
+
* @param {string} cwd
|
|
78
135
|
* @returns {ValidatedConfig}
|
|
79
136
|
*/
|
|
80
|
-
export function process_config(config,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
137
|
+
export function process_config(config, cwd) {
|
|
138
|
+
if (
|
|
139
|
+
config.csp?.directives?.['require-trusted-types-for']?.includes('script') &&
|
|
140
|
+
config.serviceWorker.register &&
|
|
141
|
+
resolve_entry(path.resolve(cwd, config.files.serviceWorker)) &&
|
|
142
|
+
!config.csp?.directives?.['trusted-types']?.includes('sveltekit-trusted-url')
|
|
143
|
+
) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"The `csp.directives['trusted-types']` option must include 'sveltekit-trusted-url' when `serviceWorker.register` is true"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
85
148
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
149
|
+
config.outDir = path.resolve(cwd, config.outDir);
|
|
150
|
+
config.env.dir = path.resolve(cwd, config.env.dir);
|
|
151
|
+
|
|
152
|
+
for (const key in config.files) {
|
|
153
|
+
if (key === 'hooks') {
|
|
154
|
+
config.files.hooks.client = path.resolve(cwd, config.files.hooks.client);
|
|
155
|
+
config.files.hooks.server = path.resolve(cwd, config.files.hooks.server);
|
|
156
|
+
config.files.hooks.universal = path.resolve(cwd, config.files.hooks.universal);
|
|
157
|
+
} else if (key !== 'lib' /* TODO remove when we remove the `lib` option altogether */) {
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
config.files[key] = path.resolve(cwd, config.files[key]);
|
|
98
160
|
}
|
|
99
|
-
|
|
100
|
-
return validated;
|
|
101
|
-
} catch (e) {
|
|
102
|
-
const error = /** @type {Error} */ (e);
|
|
103
|
-
|
|
104
|
-
// redact the stack trace — it's not helpful to users
|
|
105
|
-
error.stack = `Error loading ${source}: ${error.message}\n`;
|
|
106
|
-
throw error;
|
|
107
161
|
}
|
|
162
|
+
|
|
163
|
+
return config;
|
|
108
164
|
}
|
|
109
165
|
|
|
110
166
|
/**
|
|
111
167
|
* @param {Config} config
|
|
112
|
-
* @param {string} [cwd]
|
|
113
168
|
* @returns {ValidatedConfig}
|
|
114
169
|
*/
|
|
115
|
-
export function validate_config(config
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
'The Svelte config file must have a configuration object as its default export. See https://svelte.dev/docs/kit/configuration'
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** @type {ValidatedConfig} */
|
|
123
|
-
const validated = options(config, 'config');
|
|
124
|
-
const files = validated.kit.files;
|
|
125
|
-
|
|
126
|
-
files.hooks.client ??= path.join(files.src, 'hooks.client');
|
|
127
|
-
files.hooks.server ??= path.join(files.src, 'hooks.server');
|
|
128
|
-
files.hooks.universal ??= path.join(files.src, 'hooks');
|
|
129
|
-
files.lib ??= path.join(files.src, 'lib');
|
|
130
|
-
files.params ??= path.join(files.src, 'params');
|
|
131
|
-
files.routes ??= path.join(files.src, 'routes');
|
|
132
|
-
files.serviceWorker ??= path.join(files.src, 'service-worker');
|
|
133
|
-
files.appTemplate ??= path.join(files.src, 'app.html');
|
|
134
|
-
files.errorTemplate ??= path.join(files.src, 'error.html');
|
|
135
|
-
|
|
136
|
-
if (validated.kit.router.resolution === 'server') {
|
|
137
|
-
if (validated.kit.router.type === 'hash') {
|
|
138
|
-
throw new Error(
|
|
139
|
-
"The `router.resolution` option cannot be 'server' if `router.type` is 'hash'"
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
if (validated.kit.output.bundleStrategy !== 'split') {
|
|
170
|
+
export function validate_config(config) {
|
|
171
|
+
try {
|
|
172
|
+
if (typeof config !== 'object') {
|
|
143
173
|
throw new Error(
|
|
144
|
-
|
|
174
|
+
'The SvelteKit options from the Vite config must be an object. See https://svelte.dev/docs/kit/configuration'
|
|
145
175
|
);
|
|
146
176
|
}
|
|
147
|
-
}
|
|
148
177
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
178
|
+
const validated = validate_options(config, 'config');
|
|
179
|
+
const files = validated.files;
|
|
180
|
+
|
|
181
|
+
files.hooks.client ??= path.join(files.src, 'hooks.client');
|
|
182
|
+
files.hooks.server ??= path.join(files.src, 'hooks.server');
|
|
183
|
+
files.hooks.universal ??= path.join(files.src, 'hooks');
|
|
184
|
+
files.params ??= path.join(files.src, 'params');
|
|
185
|
+
files.routes ??= path.join(files.src, 'routes');
|
|
186
|
+
files.serviceWorker ??= path.join(files.src, 'service-worker');
|
|
187
|
+
files.appTemplate ??= path.join(files.src, 'app.html');
|
|
188
|
+
files.errorTemplate ??= path.join(files.src, 'error.html');
|
|
189
|
+
|
|
190
|
+
if (validated.router.resolution === 'server') {
|
|
191
|
+
if (validated.router.type === 'hash') {
|
|
192
|
+
throw new Error(
|
|
193
|
+
"The `router.resolution` option cannot be 'server' if `router.type` is 'hash'"
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
if (validated.output.bundleStrategy !== 'split') {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"The `router.resolution` option cannot be 'server' if `output.bundleStrategy` is 'inline' or 'single'"
|
|
199
|
+
);
|
|
200
|
+
}
|
|
154
201
|
}
|
|
202
|
+
|
|
155
203
|
if (
|
|
156
|
-
validated.
|
|
157
|
-
|
|
158
|
-
!validated.kit.csp?.directives?.['trusted-types']?.includes('sveltekit-trusted-url')
|
|
204
|
+
validated.csp?.directives?.['require-trusted-types-for']?.includes('script') &&
|
|
205
|
+
!validated.csp?.directives?.['trusted-types']?.includes('svelte-trusted-html')
|
|
159
206
|
) {
|
|
160
207
|
throw new Error(
|
|
161
|
-
"The `csp.directives['trusted-types']` option must include '
|
|
208
|
+
"The `csp.directives['trusted-types']` option must include 'svelte-trusted-html'"
|
|
162
209
|
);
|
|
163
210
|
}
|
|
164
|
-
}
|
|
165
211
|
|
|
166
|
-
|
|
212
|
+
return validated;
|
|
213
|
+
} catch (e) {
|
|
214
|
+
const error = /** @type {Error} */ (e);
|
|
215
|
+
|
|
216
|
+
// Print a nicer version of the error to the console
|
|
217
|
+
console.log(styleText(['bold', 'red'], `\n${error.message}\n`));
|
|
218
|
+
|
|
219
|
+
throw stackless('Failed to load SvelteKit options from Vite config');
|
|
220
|
+
}
|
|
167
221
|
}
|