@sveltejs/kit 3.0.0-next.13 → 3.0.0-next.15
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 +6 -3
- package/src/cli.js +8 -5
- package/src/core/adapt/builder.js +20 -10
- package/src/core/config/index.js +4 -5
- package/src/core/env.js +3 -3
- package/src/core/generate_manifest/index.js +6 -0
- package/src/core/postbuild/entities.js +8 -2
- package/src/core/postbuild/fallback.js +2 -1
- package/src/core/postbuild/prerender.js +18 -13
- package/src/core/sync/create_manifest_data/conflict.js +1 -1
- package/src/core/sync/create_manifest_data/index.js +33 -2
- package/src/core/sync/sync.js +3 -2
- package/src/core/sync/utils.js +2 -2
- package/src/core/sync/write_app_types.js +72 -27
- package/src/core/sync/write_tsconfig/index.js +73 -54
- package/src/core/sync/write_tsconfig/utils.js +0 -61
- package/src/core/sync/write_tsconfig/validate.js +128 -0
- package/src/core/sync/write_types/index.js +7 -4
- package/src/exports/node/index.js +2 -7
- package/src/exports/public.d.ts +25 -18
- package/src/exports/vite/build/build_server.js +2 -3
- package/src/exports/vite/dev/index.js +44 -36
- package/src/exports/vite/index.js +91 -16
- package/src/exports/vite/utils.js +62 -15
- package/src/runner.js +4 -2
- package/src/runtime/app/forms.js +4 -7
- package/src/runtime/app/internal/transport.js +53 -0
- package/src/runtime/app/paths/client.js +2 -2
- package/src/runtime/app/paths/internal/client.js +2 -2
- package/src/runtime/app/server/remote/prerender.js +6 -10
- package/src/runtime/app/server/remote/query.js +3 -9
- package/src/runtime/app/server/remote/requested.js +2 -2
- package/src/runtime/app/server/remote/shared.js +1 -16
- package/src/runtime/client/client.js +177 -63
- package/src/runtime/client/fetcher.js +2 -13
- package/src/runtime/client/parse.js +1 -1
- package/src/runtime/client/remote-functions/command.svelte.js +1 -2
- package/src/runtime/client/remote-functions/form.svelte.js +3 -7
- package/src/runtime/client/remote-functions/prerender.svelte.js +2 -2
- package/src/runtime/client/remote-functions/query/index.js +1 -1
- package/src/runtime/client/remote-functions/query/proxy.js +2 -2
- package/src/runtime/client/remote-functions/query-batch.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
- package/src/runtime/client/remote-functions/shared.svelte.js +1 -1
- package/src/runtime/client/utils.js +1 -0
- package/src/runtime/form-utils.js +4 -6
- package/src/runtime/pathname.js +37 -0
- package/src/runtime/server/data/index.js +5 -8
- package/src/runtime/server/dev.js +22 -0
- package/src/runtime/server/endpoint.js +3 -4
- package/src/runtime/server/fetch.js +25 -30
- package/src/runtime/server/index.js +64 -46
- package/src/runtime/server/internal.js +12 -5
- package/src/runtime/server/page/actions.js +18 -43
- package/src/runtime/server/page/crypto.js +2 -2
- package/src/runtime/server/page/csp.js +2 -1
- package/src/runtime/server/page/data_serializer.js +12 -13
- package/src/runtime/server/page/index.js +16 -32
- package/src/runtime/server/page/load_data.js +28 -44
- package/src/runtime/server/page/render.js +28 -12
- package/src/runtime/server/page/respond_with_error.js +8 -20
- package/src/runtime/server/page/serialize_data.js +2 -13
- package/src/runtime/server/page/server_routing.js +58 -9
- package/src/runtime/server/remote-functions.js +11 -15
- package/src/runtime/server/respond.js +44 -56
- package/src/runtime/server/state.js +60 -0
- package/src/runtime/server/utils.js +0 -20
- package/src/runtime/shared.js +20 -40
- package/src/runtime/utils.js +3 -0
- package/src/types/ambient-private.d.ts +1 -1
- package/src/types/ambient.d.ts +58 -7
- package/src/types/global-private.d.ts +1 -1
- package/src/types/internal.d.ts +47 -53
- package/src/utils/filesystem.js +1 -23
- package/src/utils/hash.js +21 -0
- package/src/utils/http.js +8 -7
- package/src/utils/import.js +2 -1
- package/src/utils/params.js +1 -1
- package/src/utils/regex.js +9 -0
- package/src/utils/routing.js +52 -27
- package/src/utils/url.js +1 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +98 -28
- package/types/index.d.ts.map +1 -1
- package/src/exports/node/polyfills.js +0 -30
- package/src/runtime/server/app.js +0 -9
|
@@ -6,13 +6,12 @@ import { styleText } from 'node:util';
|
|
|
6
6
|
import { write_if_changed } from '../utils.js';
|
|
7
7
|
import {
|
|
8
8
|
ESSENTIAL_OPTIONS,
|
|
9
|
-
extends_id,
|
|
10
9
|
get_subpath_imports,
|
|
11
10
|
normalize_config,
|
|
12
11
|
RECOMMENDED_OPTIONS,
|
|
13
|
-
remove_trailing_slashstar
|
|
14
|
-
validate_resolved_config
|
|
12
|
+
remove_trailing_slashstar
|
|
15
13
|
} from './utils.js';
|
|
14
|
+
import { extends_id, validate_resolved_config } from './validate.js';
|
|
16
15
|
|
|
17
16
|
/** @type {import('typescript')} */
|
|
18
17
|
let ts;
|
|
@@ -29,16 +28,16 @@ try {
|
|
|
29
28
|
*/
|
|
30
29
|
export function write_tsconfig(kit, root) {
|
|
31
30
|
const paths = get_paths(kit, root);
|
|
31
|
+
const types = ['$app/types'];
|
|
32
32
|
|
|
33
33
|
write_parent_tsconfig(
|
|
34
|
-
root,
|
|
35
34
|
root,
|
|
36
35
|
'$app/tsconfig',
|
|
37
36
|
{
|
|
38
37
|
compilerOptions: {
|
|
39
38
|
paths,
|
|
40
39
|
rootDirs: ['.', `${kit.outDir}/types`],
|
|
41
|
-
types
|
|
40
|
+
types,
|
|
42
41
|
|
|
43
42
|
// This is required for svelte-package to work as expected
|
|
44
43
|
// Can be overwritten
|
|
@@ -46,89 +45,109 @@ export function write_tsconfig(kit, root) {
|
|
|
46
45
|
|
|
47
46
|
...ESSENTIAL_OPTIONS,
|
|
48
47
|
...RECOMMENDED_OPTIONS
|
|
49
|
-
}
|
|
50
|
-
exclude: [kit.files.serviceWorker]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
extends: '$app/tsconfig',
|
|
54
|
-
include: ['src']
|
|
48
|
+
}
|
|
55
49
|
},
|
|
56
50
|
kit.typescript.config
|
|
57
51
|
);
|
|
58
52
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
validate_config(root, {
|
|
54
|
+
paths,
|
|
55
|
+
types,
|
|
56
|
+
exclusions: [kit.files.serviceWorker],
|
|
57
|
+
example: {
|
|
58
|
+
extends: '$app/tsconfig'
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
write_parent_tsconfig(root, '$app/tsconfig/service-worker', {
|
|
63
|
+
compilerOptions: {
|
|
64
|
+
paths,
|
|
65
|
+
types,
|
|
66
|
+
lib: ['ESNext', 'WebWorker'],
|
|
67
|
+
...ESSENTIAL_OPTIONS,
|
|
68
|
+
...RECOMMENDED_OPTIONS
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
validate_config(kit.files.serviceWorker, {
|
|
73
|
+
paths,
|
|
74
|
+
types,
|
|
75
|
+
example: {
|
|
72
76
|
extends: '$app/tsconfig/service-worker'
|
|
73
77
|
}
|
|
74
|
-
);
|
|
78
|
+
});
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
/**
|
|
78
82
|
* Write a generated `tsconfig.json` inside `node_modules`, for the
|
|
79
83
|
* user config to extend
|
|
80
84
|
* @param {string} root The project root
|
|
81
|
-
* @param {string} dir The directory to resolve a user config from
|
|
82
85
|
* @param {string} id The id of the generated config
|
|
83
86
|
* @param {any} config The contents of the generated tsconfig, with paths relative to `root`
|
|
84
|
-
* @param {any} example What to print if the user config does _not_ extend the generated config
|
|
85
87
|
* @param {ValidatedKitConfig['typescript']['config']} [transform] TODO get rid of this
|
|
86
88
|
*/
|
|
87
|
-
function write_parent_tsconfig(root,
|
|
88
|
-
|
|
89
|
+
function write_parent_tsconfig(root, id, config, transform) {
|
|
90
|
+
// simplified tsconfig resolvers (e.g. Playwright's) only find `${id}.json`, not `${id}/tsconfig.json`
|
|
91
|
+
const out_file = path.join(root, `node_modules/${id}.json`);
|
|
89
92
|
|
|
90
93
|
let normalized = normalize_config(out_file, config);
|
|
91
94
|
normalized = transform?.(normalized) ?? normalized;
|
|
92
95
|
|
|
93
96
|
write_if_changed(out_file, JSON.stringify(normalized, null, '\t'));
|
|
97
|
+
}
|
|
94
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @param {string} dir The directory to resolve a user config from
|
|
101
|
+
* @param {Object} options
|
|
102
|
+
* @param {Record<string, string[]>} options.paths The expected paths
|
|
103
|
+
* @param {string[]} options.types The expected types
|
|
104
|
+
* @param {string[]} [options.exclusions] Files that should be excluded
|
|
105
|
+
* @param {any} options.example What to print if the user config does _not_ extend the generated config
|
|
106
|
+
*/
|
|
107
|
+
function validate_config(dir, options) {
|
|
95
108
|
if (!ts) {
|
|
96
109
|
// The user has not installed TypeScript. Skip validation of config.
|
|
97
110
|
return;
|
|
98
111
|
}
|
|
99
112
|
|
|
100
113
|
const user_config = load_user_tsconfig(dir);
|
|
114
|
+
if (!user_config || !modified_since_last_check(user_config.file)) return;
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
116
|
+
// now that we've written the parent config, we can resolve the
|
|
117
|
+
// user config and validate that nothing important was overwritten
|
|
118
|
+
if (!extends_id(user_config.options, options.example.extends)) {
|
|
119
|
+
console.warn(
|
|
120
|
+
styleText(
|
|
121
|
+
['bold', 'yellow'],
|
|
122
|
+
`${path.relative(process.cwd(), user_config.file)} should extend SvelteKit's built-in configuration:`
|
|
123
|
+
)
|
|
124
|
+
);
|
|
112
125
|
|
|
113
|
-
|
|
126
|
+
console.warn(JSON.stringify(options.example, null, ' '));
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
const warnings = validate_resolved_config(resolved, config.compilerOptions);
|
|
131
|
+
const resolved = ts.parseJsonConfigFileContent(user_config.options, ts.sys, dir);
|
|
120
132
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
const warnings = validate_resolved_config(
|
|
134
|
+
dir,
|
|
135
|
+
resolved,
|
|
136
|
+
options.paths,
|
|
137
|
+
options.types,
|
|
138
|
+
options.exclusions
|
|
139
|
+
);
|
|
128
140
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
if (warnings.length > 0) {
|
|
142
|
+
console.warn(
|
|
143
|
+
styleText(
|
|
144
|
+
['bold', 'yellow'],
|
|
145
|
+
`Found issues while validating ${path.relative(process.cwd(), user_config.file)}`
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
for (const warning of warnings) {
|
|
150
|
+
console.warn(` - ${warning}`);
|
|
132
151
|
}
|
|
133
152
|
}
|
|
134
153
|
}
|
|
@@ -36,16 +36,6 @@ export const RECOMMENDED_OPTIONS = {
|
|
|
36
36
|
noEmit: true // prevent tsconfig error "overwriting input files" - Vite handles the build and ignores this
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* Validates that a tsconfig contains `"extends": "<id>"`
|
|
41
|
-
* @param {any} options
|
|
42
|
-
* @param {string} id
|
|
43
|
-
*/
|
|
44
|
-
export function extends_id(options, id) {
|
|
45
|
-
const o = options.extends;
|
|
46
|
-
return Array.isArray(o) ? o.includes(id) : o === id;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
39
|
/**
|
|
50
40
|
* Makes paths relative to the output file
|
|
51
41
|
* @param {string} out
|
|
@@ -76,57 +66,6 @@ export function normalize_config(out, config, transform) {
|
|
|
76
66
|
return transform?.(normalized) ?? normalized;
|
|
77
67
|
}
|
|
78
68
|
|
|
79
|
-
/**
|
|
80
|
-
* @param {any} resolved
|
|
81
|
-
* @param {any} options
|
|
82
|
-
*/
|
|
83
|
-
export function validate_resolved_config(resolved, options) {
|
|
84
|
-
const warnings = [];
|
|
85
|
-
|
|
86
|
-
const join = (/** @type {string[]} */ array) =>
|
|
87
|
-
array
|
|
88
|
-
.map((v) => JSON.stringify(v))
|
|
89
|
-
.join(', ')
|
|
90
|
-
.replace(/, ([^,]*)$/, ' and $1');
|
|
91
|
-
|
|
92
|
-
const missing_types = options.types?.filter(
|
|
93
|
-
(/** @type {string} */ type) => !resolved.types?.includes(type)
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (missing_types.length > 0) {
|
|
97
|
-
warnings.push(`"types" was overwritten. It must include ${join(missing_types)}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (options.paths) {
|
|
101
|
-
/** @type {Set<string>} */
|
|
102
|
-
const mismatch = new Set();
|
|
103
|
-
|
|
104
|
-
for (const [k, expected] of Object.entries(options.paths)) {
|
|
105
|
-
const actual = resolved.paths?.[k]?.map((/** @type {string} */ x) =>
|
|
106
|
-
path.resolve(/** @type {string} */ (resolved.pathsBasePath), x)
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
if (JSON.stringify(expected) !== JSON.stringify(actual)) {
|
|
110
|
-
mismatch.add(remove_trailing_slashstar(k));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (mismatch.size > 0) {
|
|
115
|
-
const joined = join([...mismatch]);
|
|
116
|
-
|
|
117
|
-
warnings.push(`"paths" was overwritten. Imports from ${joined} may not typecheck`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
for (const key in ESSENTIAL_OPTIONS) {
|
|
122
|
-
if (resolved[key] !== options[key]) {
|
|
123
|
-
warnings.push(`"${key}" was overwritten. It should be ${JSON.stringify(options[key])}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return warnings;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
69
|
/**
|
|
131
70
|
* @param {string} file
|
|
132
71
|
*/
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** @import ts from 'typescript' */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ESSENTIAL_OPTIONS, remove_trailing_slashstar } from './utils.js';
|
|
4
|
+
import { posixify } from '../../../utils/os.js';
|
|
5
|
+
|
|
6
|
+
const formatter = new Intl.ListFormat('en-gb', { type: 'conjunction' });
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string[]} things
|
|
10
|
+
*/
|
|
11
|
+
function join(things) {
|
|
12
|
+
return formatter.format(things.map((thing) => JSON.stringify(thing)));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} dir
|
|
17
|
+
* @param {ts.ParsedCommandLine} resolved
|
|
18
|
+
* @param {Record<string, string[]>} paths
|
|
19
|
+
* @param {string[]} types
|
|
20
|
+
* @param {string[]} [exclusions]
|
|
21
|
+
*/
|
|
22
|
+
export function validate_resolved_config(dir, resolved, paths, types, exclusions) {
|
|
23
|
+
/** @type {string[]} */
|
|
24
|
+
const warnings = [];
|
|
25
|
+
|
|
26
|
+
if (resolved.options.types) {
|
|
27
|
+
validate_types(warnings, types, resolved.options.types);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (resolved.options.paths) {
|
|
31
|
+
validate_paths(
|
|
32
|
+
warnings,
|
|
33
|
+
/** @type {string} */ (resolved.options.pathsBasePath),
|
|
34
|
+
paths,
|
|
35
|
+
resolved.options.paths
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (exclusions) {
|
|
40
|
+
validate_exclusions(warnings, dir, exclusions, resolved.fileNames);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const key in ESSENTIAL_OPTIONS) {
|
|
44
|
+
if (resolved.options[key] !== ESSENTIAL_OPTIONS[key]) {
|
|
45
|
+
warnings.push(
|
|
46
|
+
`"${key}" was overwritten. It should be ${JSON.stringify(ESSENTIAL_OPTIONS[key])}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return warnings;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string[]} warnings
|
|
56
|
+
* @param {string[]} expected
|
|
57
|
+
* @param {string[]} actual
|
|
58
|
+
*/
|
|
59
|
+
export function validate_types(warnings, expected, actual) {
|
|
60
|
+
const missing_types = expected.filter((/** @type {string} */ type) => !actual.includes(type));
|
|
61
|
+
|
|
62
|
+
if (missing_types.length > 0) {
|
|
63
|
+
warnings.push(`"types" was overwritten. It must include ${join(missing_types)}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return warnings;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {string[]} warnings
|
|
71
|
+
* @param {string} base
|
|
72
|
+
* @param {Record<string, string[]>} expected
|
|
73
|
+
* @param {ts.MapLike<string[]>} actual
|
|
74
|
+
*/
|
|
75
|
+
export function validate_paths(warnings, base, expected, actual) {
|
|
76
|
+
/** @type {Set<string>} */
|
|
77
|
+
const mismatch = new Set();
|
|
78
|
+
|
|
79
|
+
for (const [k, e] of Object.entries(expected)) {
|
|
80
|
+
const a = actual[k]?.map((/** @type {string} */ x) =>
|
|
81
|
+
path.resolve(/** @type {string} */ (base), x)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (JSON.stringify(e) !== JSON.stringify(a)) {
|
|
85
|
+
mismatch.add(remove_trailing_slashstar(k));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (mismatch.size > 0) {
|
|
90
|
+
const joined = join([...mismatch]);
|
|
91
|
+
|
|
92
|
+
warnings.push(`"paths" was overwritten. Imports from ${joined} may not typecheck`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return warnings;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {string[]} warnings
|
|
100
|
+
* @param {string} dir
|
|
101
|
+
* @param {string[]} exclusions
|
|
102
|
+
* @param {string[]} files
|
|
103
|
+
*/
|
|
104
|
+
export function validate_exclusions(warnings, dir, exclusions, files) {
|
|
105
|
+
const missing_exclusions = exclusions.map(posixify).filter((exclusion) => {
|
|
106
|
+
return files.some(
|
|
107
|
+
(f) => f === exclusion || f.startsWith(exclusion + '/') || f.startsWith(exclusion + '.')
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (missing_exclusions.length > 0) {
|
|
112
|
+
warnings.push(
|
|
113
|
+
`${join(missing_exclusions.map((file) => posixify(path.relative(dir, file))))} should be added to the "exclude" array`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return warnings;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Validates that a tsconfig contains `"extends": "<id>"`
|
|
122
|
+
* @param {any} options
|
|
123
|
+
* @param {string} id
|
|
124
|
+
*/
|
|
125
|
+
export function extends_id(options, id) {
|
|
126
|
+
const o = options.extends;
|
|
127
|
+
return Array.isArray(o) ? o.includes(id) : o === id;
|
|
128
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import MagicString from 'magic-string';
|
|
4
|
-
import {
|
|
4
|
+
import { walk, resolve_entry } from '../../../utils/filesystem.js';
|
|
5
5
|
import { compact } from '../../../utils/array.js';
|
|
6
6
|
import { posixify } from '../../../utils/os.js';
|
|
7
7
|
import { ts } from '../ts.js';
|
|
8
|
+
import { is_page_route } from '../create_manifest_data/index.js';
|
|
8
9
|
const remove_relative_parent_traversals = (/** @type {string} */ path) =>
|
|
9
10
|
path.replace(/\.\.\//g, '');
|
|
10
11
|
const is_whitespace = (/** @type {string} */ char) => /\s/.test(char);
|
|
@@ -48,7 +49,7 @@ export function write_all_types(config, manifest_data, root) {
|
|
|
48
49
|
for (const file of walk(types_dir)) {
|
|
49
50
|
const dir = path.dirname(file);
|
|
50
51
|
if (!expected_directories.has(dir)) {
|
|
51
|
-
|
|
52
|
+
fs.rmSync(path.join(types_dir, file), { force: true, recursive: true });
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -278,7 +279,9 @@ function update_types(config, routes, route, root, to_delete = new Set()) {
|
|
|
278
279
|
let all_pages_have_load = true;
|
|
279
280
|
/** @type {import('types').RouteParam[]} */
|
|
280
281
|
const layout_params = [];
|
|
281
|
-
|
|
282
|
+
// a layout can live in a directory that has no `+page` of its own, in which case its own id
|
|
283
|
+
// is never the matched route — a request to a colocated `+server` doesn't execute layouts
|
|
284
|
+
const ids = is_page_route(route) ? ['RouteId'] : [];
|
|
282
285
|
|
|
283
286
|
route.layout.child_pages?.forEach((page) => {
|
|
284
287
|
const leaf = routes.get(page);
|
|
@@ -312,7 +315,7 @@ function update_types(config, routes, route, root, to_delete = new Set()) {
|
|
|
312
315
|
ids.push('null');
|
|
313
316
|
}
|
|
314
317
|
|
|
315
|
-
declarations.push(`type LayoutRouteId = ${ids.join(' | ')}`);
|
|
318
|
+
declarations.push(`type LayoutRouteId = ${ids.join(' | ') || 'never'}`);
|
|
316
319
|
|
|
317
320
|
declarations.push(
|
|
318
321
|
'type LayoutParams = RouteParams & ' + generate_params_type(layout_params, outdir, config)
|
|
@@ -137,14 +137,9 @@ export function getRequest({ request, base, bodySizeLimit }) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
const controller = new AbortController();
|
|
140
|
-
|
|
141
|
-
// see https://github.com/nodejs/node/blob/5cf3c3e24c7257a0c6192ed8ef71efec8ddac22b/lib/internal/streams/readable.js#L1443-L1453
|
|
142
|
-
let errored = false;
|
|
143
|
-
let end_emitted = false;
|
|
144
|
-
request.once('error', () => (errored = true));
|
|
145
|
-
request.once('end', () => (end_emitted = true));
|
|
140
|
+
|
|
146
141
|
request.once('close', () => {
|
|
147
|
-
if (
|
|
142
|
+
if (request.readableAborted) {
|
|
148
143
|
controller.abort();
|
|
149
144
|
}
|
|
150
145
|
});
|
package/src/exports/public.d.ts
CHANGED
|
@@ -121,9 +121,15 @@ type UnpackValidationError<T> =
|
|
|
121
121
|
export interface Builder {
|
|
122
122
|
/** Print messages to the console. `log.info` and `log.minor` are silent unless Vite's `logLevel` is `info`. */
|
|
123
123
|
log: Logger;
|
|
124
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Remove `dir` and all its contents.
|
|
126
|
+
* @deprecated Use `fs.rmSync(dir, { force: true, recursive: true })` instead
|
|
127
|
+
*/
|
|
125
128
|
rimraf: (dir: string) => void;
|
|
126
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Create `dir` and any required parent directories.
|
|
131
|
+
* @deprecated Use `fs.mkdirSync(dir, { recursive: true })` instead
|
|
132
|
+
*/
|
|
127
133
|
mkdirp: (dir: string) => void;
|
|
128
134
|
|
|
129
135
|
/** The fully resolved SvelteKit config. */
|
|
@@ -253,8 +259,9 @@ export interface Builder {
|
|
|
253
259
|
/**
|
|
254
260
|
* Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals.
|
|
255
261
|
* @param {string} directory The directory containing the files to be compressed
|
|
262
|
+
* @returns an array of the files in `directory` that were compressed
|
|
256
263
|
*/
|
|
257
|
-
compress: (directory: string) => Promise<
|
|
264
|
+
compress: (directory: string) => Promise<string[]>;
|
|
258
265
|
}
|
|
259
266
|
|
|
260
267
|
/**
|
|
@@ -862,7 +869,7 @@ export interface KitConfig {
|
|
|
862
869
|
* A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
|
|
863
870
|
* This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.
|
|
864
871
|
*
|
|
865
|
-
* Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig
|
|
872
|
+
* Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig.json`.
|
|
866
873
|
*
|
|
867
874
|
* @default (config) => config
|
|
868
875
|
* @since 1.3.0
|
|
@@ -1613,7 +1620,7 @@ export interface RequestEvent<
|
|
|
1613
1620
|
/**
|
|
1614
1621
|
* Get or set cookies related to the current request
|
|
1615
1622
|
*/
|
|
1616
|
-
cookies: Cookies;
|
|
1623
|
+
readonly cookies: Cookies;
|
|
1617
1624
|
/**
|
|
1618
1625
|
* `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
|
|
1619
1626
|
*
|
|
@@ -1625,15 +1632,15 @@ export interface RequestEvent<
|
|
|
1625
1632
|
*
|
|
1626
1633
|
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
1627
1634
|
*/
|
|
1628
|
-
fetch: typeof fetch;
|
|
1635
|
+
readonly fetch: typeof fetch;
|
|
1629
1636
|
/**
|
|
1630
1637
|
* The client's IP address, set by the adapter.
|
|
1631
1638
|
*/
|
|
1632
|
-
getClientAddress: () => string;
|
|
1639
|
+
readonly getClientAddress: () => string;
|
|
1633
1640
|
/**
|
|
1634
1641
|
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
1635
1642
|
*/
|
|
1636
|
-
locals: App.Locals;
|
|
1643
|
+
readonly locals: App.Locals;
|
|
1637
1644
|
/**
|
|
1638
1645
|
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
1639
1646
|
*
|
|
@@ -1642,19 +1649,19 @@ export interface RequestEvent<
|
|
|
1642
1649
|
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
1643
1650
|
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1644
1651
|
*/
|
|
1645
|
-
params: Params;
|
|
1652
|
+
readonly params: Params;
|
|
1646
1653
|
/**
|
|
1647
1654
|
* Additional data made available through the adapter.
|
|
1648
1655
|
*/
|
|
1649
|
-
platform: Readonly<App.Platform> | undefined;
|
|
1656
|
+
readonly platform: Readonly<App.Platform> | undefined;
|
|
1650
1657
|
/**
|
|
1651
1658
|
* The original request object.
|
|
1652
1659
|
*/
|
|
1653
|
-
request: Request;
|
|
1660
|
+
readonly request: Request;
|
|
1654
1661
|
/**
|
|
1655
1662
|
* Info about the current route.
|
|
1656
1663
|
*/
|
|
1657
|
-
route: {
|
|
1664
|
+
readonly route: {
|
|
1658
1665
|
/**
|
|
1659
1666
|
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
1660
1667
|
*
|
|
@@ -1687,7 +1694,7 @@ export interface RequestEvent<
|
|
|
1687
1694
|
*
|
|
1688
1695
|
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.
|
|
1689
1696
|
*/
|
|
1690
|
-
setHeaders: (headers: Record<string, string>) => void;
|
|
1697
|
+
readonly setHeaders: (headers: Record<string, string>) => void;
|
|
1691
1698
|
/**
|
|
1692
1699
|
* The requested URL.
|
|
1693
1700
|
*
|
|
@@ -1696,22 +1703,22 @@ export interface RequestEvent<
|
|
|
1696
1703
|
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
1697
1704
|
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
1698
1705
|
*/
|
|
1699
|
-
url: URL;
|
|
1706
|
+
readonly url: URL;
|
|
1700
1707
|
/**
|
|
1701
1708
|
* `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
|
|
1702
1709
|
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
1703
1710
|
*/
|
|
1704
|
-
isDataRequest: boolean;
|
|
1711
|
+
readonly isDataRequest: boolean;
|
|
1705
1712
|
/**
|
|
1706
1713
|
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
1707
1714
|
*/
|
|
1708
|
-
isSubRequest: boolean;
|
|
1715
|
+
readonly isSubRequest: boolean;
|
|
1709
1716
|
|
|
1710
1717
|
/**
|
|
1711
1718
|
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
1712
1719
|
* @since 2.31.0
|
|
1713
1720
|
*/
|
|
1714
|
-
tracing: {
|
|
1721
|
+
readonly tracing: {
|
|
1715
1722
|
/** Whether tracing is enabled. */
|
|
1716
1723
|
enabled: boolean;
|
|
1717
1724
|
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
@@ -1724,7 +1731,7 @@ export interface RequestEvent<
|
|
|
1724
1731
|
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
1725
1732
|
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
1726
1733
|
*/
|
|
1727
|
-
isRemoteRequest: boolean;
|
|
1734
|
+
readonly isRemoteRequest: boolean;
|
|
1728
1735
|
}
|
|
1729
1736
|
|
|
1730
1737
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @import { AssetDependencies, ManifestData, SSRNode, ValidatedKitConfig } from 'types' */
|
|
2
2
|
/** @import { Manifest, Rolldown } from 'vite' */
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
-
import { mkdirp } from '../../../utils/filesystem.js';
|
|
5
4
|
import {
|
|
6
5
|
create_function_as_string,
|
|
7
6
|
filter_fonts,
|
|
@@ -36,8 +35,8 @@ export function build_server_nodes(
|
|
|
36
35
|
chunks,
|
|
37
36
|
root
|
|
38
37
|
) {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
fs.mkdirSync(`${out}/server/nodes`, { recursive: true });
|
|
39
|
+
fs.mkdirSync(`${out}/server/stylesheets`, { recursive: true });
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* Stylesheet names and their contents which are below the inline threshold
|