@sveltejs/kit 2.63.0 → 3.0.0-next.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.
- package/package.json +17 -22
- package/src/cli.js +19 -16
- package/src/core/adapt/builder.js +25 -77
- package/src/core/adapt/index.js +6 -4
- package/src/core/config/index.js +12 -84
- package/src/core/config/options.js +36 -46
- package/src/core/env.js +5 -130
- package/src/core/generate_manifest/find_server_assets.js +3 -2
- package/src/core/generate_manifest/index.js +11 -3
- package/src/core/postbuild/analyse.js +19 -16
- package/src/core/postbuild/fallback.js +0 -3
- package/src/core/postbuild/prerender.js +18 -17
- package/src/core/postbuild/queue.js +3 -4
- package/src/core/sync/create_manifest_data/index.js +16 -18
- package/src/core/sync/sync.js +30 -25
- package/src/core/sync/utils.js +0 -15
- package/src/core/sync/write_ambient.js +3 -54
- package/src/core/sync/write_client_manifest.js +8 -9
- package/src/core/sync/write_env.js +5 -1
- package/src/core/sync/write_non_ambient.js +7 -7
- package/src/core/sync/write_root.js +40 -88
- package/src/core/sync/write_server.js +16 -23
- package/src/core/sync/write_tsconfig.js +28 -24
- package/src/core/sync/write_types/index.js +31 -25
- package/src/core/utils.js +14 -11
- package/src/exports/index.js +8 -21
- package/src/exports/node/index.js +8 -13
- package/src/exports/public.d.ts +35 -76
- package/src/exports/vite/build/build_server.js +14 -11
- package/src/exports/vite/build/remote.js +6 -7
- package/src/exports/vite/build/utils.js +7 -5
- package/src/exports/vite/dev/index.js +30 -31
- package/src/exports/vite/index.js +938 -732
- package/src/exports/vite/module_ids.js +1 -6
- package/src/exports/vite/options.js +17 -0
- package/src/exports/vite/preview/index.js +3 -5
- package/src/exports/vite/static_analysis/index.js +11 -5
- package/src/exports/vite/utils.js +9 -45
- package/src/runtime/app/env/internal.js +3 -0
- package/src/runtime/app/env/public/client.js +0 -6
- package/src/runtime/app/env/public/server.js +0 -6
- package/src/runtime/app/server/index.js +4 -2
- package/src/runtime/app/server/remote/form.js +0 -51
- package/src/runtime/app/server/remote/query.js +0 -7
- package/src/runtime/app/server/remote/shared.js +4 -3
- package/src/runtime/app/state/client.js +1 -12
- package/src/runtime/client/client.js +1 -1
- package/src/runtime/client/constants.js +0 -1
- package/src/runtime/client/remote-functions/form.svelte.js +0 -31
- package/src/runtime/client/remote-functions/query/index.js +2 -2
- package/src/runtime/client/remote-functions/query/instance.svelte.js +1 -2
- package/src/runtime/client/remote-functions/query-batch.svelte.js +2 -2
- package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -8
- package/src/runtime/client/utils.js +8 -10
- package/src/runtime/components/{svelte-5/layout.svelte → layout.svelte} +1 -1
- package/src/runtime/form-utils.js +4 -41
- package/src/runtime/server/cookie.js +21 -37
- package/src/runtime/server/env_module.js +1 -3
- package/src/runtime/server/fetch.js +6 -10
- package/src/runtime/server/index.js +3 -9
- package/src/runtime/server/page/render.js +32 -44
- package/src/runtime/server/page/types.d.ts +4 -2
- package/src/runtime/server/respond.js +2 -2
- package/src/runtime/server/utils.js +2 -4
- package/src/runtime/shared-server.js +0 -22
- package/src/runtime/shared.js +0 -15
- package/src/types/global-private.d.ts +5 -1
- package/src/types/internal.d.ts +3 -8
- package/src/utils/css.js +3 -19
- package/src/utils/filesystem.js +1 -30
- package/src/utils/http.js +0 -21
- package/src/utils/import.js +7 -6
- package/src/utils/os.js +7 -0
- package/src/utils/path.js +23 -0
- package/src/utils/shared-iterator.js +3 -0
- package/src/utils/streaming.js +2 -4
- package/src/utils/url.js +1 -1
- package/src/utils/vite.js +28 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +45 -138
- package/types/index.d.ts.map +1 -8
- package/src/exports/vite/build/build_service_worker.js +0 -165
- package/src/runtime/app/environment/index.js +0 -10
- package/src/runtime/app/environment/types.d.ts +0 -19
- package/src/runtime/components/svelte-4/error.svelte +0 -6
- package/src/runtime/components/svelte-4/layout.svelte +0 -1
- package/src/runtime/env/dynamic/private.js +0 -1
- package/src/runtime/env/dynamic/public.js +0 -1
- package/src/types/synthetic/$env+dynamic+private.md +0 -43
- package/src/types/synthetic/$env+dynamic+public.md +0 -46
- package/src/types/synthetic/$env+static+private.md +0 -31
- package/src/types/synthetic/$env+static+public.md +0 -31
- package/src/utils/env.js +0 -13
- package/src/utils/promise.js +0 -29
- /package/src/runtime/components/{svelte-5/error.svelte → error.svelte} +0 -0
package/src/utils/css.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import MagicString from 'magic-string';
|
|
2
|
-
import
|
|
2
|
+
import { parseCss } from 'svelte/compiler';
|
|
3
3
|
|
|
4
|
-
/** @typedef {ReturnType<typeof
|
|
4
|
+
/** @typedef {ReturnType<typeof parseCss>['children']} StyleSheetChildren */
|
|
5
5
|
|
|
6
6
|
/** @typedef {{ property: string; value: string; start: number; end: number; type: 'Declaration' }} Declaration */
|
|
7
7
|
|
|
8
|
-
const parse = svelte.parseCss
|
|
9
|
-
? svelte.parseCss
|
|
10
|
-
: /** @param {string} css */
|
|
11
|
-
(css) => {
|
|
12
|
-
return /** @type {{ css: { children: StyleSheetChildren } }} */ (
|
|
13
|
-
svelte.parse(`<style>${css}</style>`)
|
|
14
|
-
).css;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
8
|
const SKIP_PARSING_REGEX = /url\(/i;
|
|
18
9
|
|
|
19
10
|
/** Capture a single url(...) so we can process them one at a time */
|
|
@@ -31,8 +22,6 @@ const HASH_OR_QUERY_REGEX = /[#?]/;
|
|
|
31
22
|
*/
|
|
32
23
|
const VITE_ASSET_PREFIX = './';
|
|
33
24
|
|
|
34
|
-
const AST_OFFSET = '<style>'.length;
|
|
35
|
-
|
|
36
25
|
/**
|
|
37
26
|
* We need to fix the asset URLs in the CSS before we inline them into a document
|
|
38
27
|
* because they are now relative to the document instead of the CSS file.
|
|
@@ -70,7 +59,7 @@ export function fix_css_urls({
|
|
|
70
59
|
|
|
71
60
|
const s = new MagicString(css);
|
|
72
61
|
|
|
73
|
-
const parsed =
|
|
62
|
+
const parsed = parseCss(css);
|
|
74
63
|
|
|
75
64
|
for (const child of parsed.children) {
|
|
76
65
|
find_declarations(child, (declaration) => {
|
|
@@ -128,11 +117,6 @@ export function fix_css_urls({
|
|
|
128
117
|
|
|
129
118
|
if (declaration.value === new_value) return;
|
|
130
119
|
|
|
131
|
-
if (!svelte.parseCss) {
|
|
132
|
-
declaration.start = declaration.start - AST_OFFSET;
|
|
133
|
-
declaration.end = declaration.end - AST_OFFSET;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
120
|
s.update(declaration.start, declaration.end, `${declaration.property}: ${new_value}`);
|
|
137
121
|
});
|
|
138
122
|
}
|
package/src/utils/filesystem.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { posixify } from './os.js';
|
|
3
4
|
|
|
4
5
|
/** @param {string} dir */
|
|
5
6
|
export function mkdirp(dir) {
|
|
@@ -110,11 +111,6 @@ export function walk(cwd, dirs = false) {
|
|
|
110
111
|
return (walk_dir(''), all_files);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
/** @param {string} str */
|
|
114
|
-
export function posixify(str) {
|
|
115
|
-
return str.replace(/\\/g, '/');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
114
|
/**
|
|
119
115
|
* Like `path.join`, but posixified and with a leading `./` if necessary
|
|
120
116
|
* @param {string[]} str
|
|
@@ -138,31 +134,6 @@ export function relative_path(from, to) {
|
|
|
138
134
|
return join_relative(path.relative(from, to));
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
/**
|
|
142
|
-
* Prepend given path with `/@fs` prefix
|
|
143
|
-
* @param {string} str
|
|
144
|
-
*/
|
|
145
|
-
export function to_fs(str) {
|
|
146
|
-
str = posixify(str);
|
|
147
|
-
return `/@fs${
|
|
148
|
-
// Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
|
|
149
|
-
str.startsWith('/') ? '' : '/'
|
|
150
|
-
}${str}`;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Removes `/@fs` prefix from given path and posixifies it
|
|
155
|
-
* @param {string} str
|
|
156
|
-
*/
|
|
157
|
-
export function from_fs(str) {
|
|
158
|
-
str = posixify(str);
|
|
159
|
-
if (!str.startsWith('/@fs')) return str;
|
|
160
|
-
|
|
161
|
-
str = str.slice(4);
|
|
162
|
-
// Windows/Linux separation - Windows starts with a drive letter, we need to strip the additional / here
|
|
163
|
-
return str[2] === ':' && /[A-Z]/.test(str[1]) ? str.slice(1) : str;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
137
|
/**
|
|
167
138
|
* Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
|
|
168
139
|
* @param {string} entry
|
package/src/utils/http.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as set_cookie_parser from 'set-cookie-parser';
|
|
2
1
|
import { BINARY_FORM_CONTENT_TYPE } from '../runtime/form-utils.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -57,26 +56,6 @@ export function negotiate(accept, types) {
|
|
|
57
56
|
return accepted;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
/**
|
|
61
|
-
* Reads all `Set-Cookie` headers as separate values. `Headers.get('set-cookie')`
|
|
62
|
-
* collapses them into a single comma-joined string that browsers cannot parse, so
|
|
63
|
-
* we use `Headers.getSetCookie()` where available and fall back to splitting the
|
|
64
|
-
* joined string otherwise.
|
|
65
|
-
*
|
|
66
|
-
* TODO 3.0 `getSetCookie` is available in Node 19.7+; once we drop support for
|
|
67
|
-
* older versions we can use it directly and remove the `splitCookiesString` fallback
|
|
68
|
-
* @param {Headers} headers
|
|
69
|
-
* @returns {string[]}
|
|
70
|
-
*/
|
|
71
|
-
export function get_set_cookies(headers) {
|
|
72
|
-
if (typeof headers.getSetCookie === 'function') {
|
|
73
|
-
return headers.getSetCookie();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const set_cookie = headers.get('set-cookie');
|
|
77
|
-
return set_cookie ? set_cookie_parser.splitCookiesString(set_cookie) : [];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
59
|
/**
|
|
81
60
|
* Returns `true` if the request contains a `content-type` header with the given type
|
|
82
61
|
* @param {Request} request
|
package/src/utils/import.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
* Resolves a peer dependency relative to the current
|
|
5
|
+
* Resolves a peer dependency relative to the current working directory. Duplicated with `packages/adapter-auto`
|
|
7
6
|
* @param {string} dependency
|
|
7
|
+
* @param {string} root
|
|
8
8
|
*/
|
|
9
|
-
function resolve_peer(dependency) {
|
|
9
|
+
function resolve_peer(dependency, root) {
|
|
10
10
|
let [name, ...parts] = dependency.split('/');
|
|
11
11
|
if (name[0] === '@') name += `/${parts.shift()}`;
|
|
12
12
|
|
|
13
|
-
let dir =
|
|
13
|
+
let dir = root;
|
|
14
14
|
|
|
15
15
|
while (!fs.existsSync(`${dir}/node_modules/${name}/package.json`)) {
|
|
16
16
|
if (dir === (dir = path.dirname(dir))) {
|
|
@@ -42,10 +42,11 @@ function resolve_peer(dependency) {
|
|
|
42
42
|
* Resolve a dependency relative to the current working directory,
|
|
43
43
|
* rather than relative to this package (but falls back to trying that, if necessary)
|
|
44
44
|
* @param {string} dependency
|
|
45
|
+
* @param {string} root
|
|
45
46
|
*/
|
|
46
|
-
export async function import_peer(dependency) {
|
|
47
|
+
export async function import_peer(dependency, root) {
|
|
47
48
|
try {
|
|
48
|
-
return await import(/* @vite-ignore */ resolve_peer(dependency));
|
|
49
|
+
return await import(/* @vite-ignore */ resolve_peer(dependency, root));
|
|
49
50
|
} catch {
|
|
50
51
|
return await import(/* @vite-ignore */ dependency);
|
|
51
52
|
}
|
package/src/utils/os.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// This file contains Node-agnostic path utilities so that it can be used in
|
|
2
|
+
// environments that do not have access to `node:path` (e.g. Cloudflare Workers).
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {string} from
|
|
6
|
+
* @param {string} to
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function relative(from, to) {
|
|
10
|
+
const from_parts = from.split('/').filter(Boolean);
|
|
11
|
+
const to_parts = to.split('/').filter(Boolean);
|
|
12
|
+
let i = 0;
|
|
13
|
+
while (i < from_parts.length && i < to_parts.length && from_parts[i] === to_parts[i]) i++;
|
|
14
|
+
return [...Array(from_parts.length - i).fill('..'), ...to_parts.slice(i)].join('/') || '.';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {...string} parts
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function join(...parts) {
|
|
22
|
+
return parts.join('/');
|
|
23
|
+
}
|
package/src/utils/streaming.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { with_resolvers } from './promise.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Create an async iterator and a function to push values into it
|
|
5
3
|
* @template T
|
|
@@ -12,7 +10,7 @@ export function create_async_iterator() {
|
|
|
12
10
|
let resolved = -1;
|
|
13
11
|
let returned = -1;
|
|
14
12
|
|
|
15
|
-
/** @type {
|
|
13
|
+
/** @type {PromiseWithResolvers<T>[]} */
|
|
16
14
|
const deferred = [];
|
|
17
15
|
|
|
18
16
|
return {
|
|
@@ -32,7 +30,7 @@ export function create_async_iterator() {
|
|
|
32
30
|
};
|
|
33
31
|
},
|
|
34
32
|
add: (promise) => {
|
|
35
|
-
deferred.push(
|
|
33
|
+
deferred.push(Promise.withResolvers());
|
|
36
34
|
void promise.then((value) => {
|
|
37
35
|
deferred[++resolved].resolve(value);
|
|
38
36
|
});
|
package/src/utils/url.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// this file needs to be runtime agnostic and avoid importing from `node:*` since
|
|
2
|
+
// it may not be available in edge environments
|
|
3
|
+
import { posixify } from './os.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Prepend given path with `/@fs` prefix
|
|
7
|
+
* @param {string} str
|
|
8
|
+
*/
|
|
9
|
+
export function to_fs(str) {
|
|
10
|
+
str = posixify(str);
|
|
11
|
+
return `/@fs${
|
|
12
|
+
// Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
|
|
13
|
+
str.startsWith('/') ? '' : '/'
|
|
14
|
+
}${str}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Removes `/@fs` prefix from given path and posixifies it
|
|
19
|
+
* @param {string} str
|
|
20
|
+
*/
|
|
21
|
+
export function from_fs(str) {
|
|
22
|
+
str = posixify(str);
|
|
23
|
+
if (!str.startsWith('/@fs')) return str;
|
|
24
|
+
|
|
25
|
+
str = str.slice(4);
|
|
26
|
+
// Windows/Linux separation - Windows starts with a drive letter, we need to strip the additional / here
|
|
27
|
+
return str[2] === ':' && /[A-Z]/.test(str[1]) ? str.slice(1) : str;
|
|
28
|
+
}
|
package/src/version.js
CHANGED