@sveltejs/kit 2.36.2 → 2.36.3
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 -4
- package/src/exports/public.d.ts +1 -1
- package/src/exports/vite/index.js +0 -2
- package/src/runtime/app/state/server.js +9 -9
- package/src/runtime/app/stores.js +4 -4
- package/src/runtime/client/remote-functions/form.svelte.js +2 -2
- package/src/runtime/server/cookie.js +3 -2
- package/src/runtime/server/page/actions.js +2 -2
- package/src/runtime/server/page/csp.js +4 -3
- package/src/runtime/server/page/load_data.js +2 -2
- package/src/runtime/server/page/render.js +5 -5
- package/src/runtime/server/respond.js +1 -2
- package/src/runtime/server/utils.js +1 -1
- package/src/types/ambient.d.ts +1 -1
- package/src/types/global-private.d.ts +0 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "2.36.
|
|
3
|
+
"version": "2.36.3",
|
|
4
4
|
"description": "SvelteKit is the fastest way to build Svelte apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@types/cookie": "^0.6.0",
|
|
24
24
|
"acorn": "^8.14.1",
|
|
25
25
|
"cookie": "^0.6.0",
|
|
26
|
-
"devalue": "^5.
|
|
26
|
+
"devalue": "^5.3.2",
|
|
27
27
|
"esm-env": "^1.2.2",
|
|
28
28
|
"kleur": "^4.1.5",
|
|
29
29
|
"magic-string": "^0.30.5",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/set-cookie-parser": "^2.4.7",
|
|
42
42
|
"dts-buddy": "^0.6.2",
|
|
43
43
|
"rollup": "^4.14.2",
|
|
44
|
-
"svelte": "^5.
|
|
44
|
+
"svelte": "^5.38.5",
|
|
45
45
|
"svelte-preprocess": "^6.0.0",
|
|
46
46
|
"typescript": "^5.3.3",
|
|
47
47
|
"vite": "^6.3.5",
|
|
@@ -115,7 +115,9 @@
|
|
|
115
115
|
"test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build",
|
|
116
116
|
"test:server-side-route-resolution:dev": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:server-side-route-resolution:dev",
|
|
117
117
|
"test:server-side-route-resolution:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:server-side-route-resolution:build",
|
|
118
|
-
"test:unit": "vitest --config kit.vitest.config.js run",
|
|
118
|
+
"test:unit:dev": "vitest --config kit.vitest.config.js run",
|
|
119
|
+
"test:unit:prod": "NODE_ENV=production vitest --config kit.vitest.config.js run csp.spec.js cookie.spec.js",
|
|
120
|
+
"test:unit": "pnpm test:unit:dev && pnpm test:unit:prod",
|
|
119
121
|
"generate:version": "node scripts/generate-version.js",
|
|
120
122
|
"generate:types": "node scripts/generate-dts.js"
|
|
121
123
|
}
|
package/src/exports/public.d.ts
CHANGED
|
@@ -1822,7 +1822,7 @@ export type RemoteQuery<T> = RemoteResource<T> & {
|
|
|
1822
1822
|
* await submit().updates(
|
|
1823
1823
|
* todos.withOverride((todos) => [...todos, { text: data.get('text') }])
|
|
1824
1824
|
* );
|
|
1825
|
-
* }}>
|
|
1825
|
+
* })}>
|
|
1826
1826
|
* <input type="text" name="text" />
|
|
1827
1827
|
* <button type="submit">Add Todo</button>
|
|
1828
1828
|
* </form>
|
|
@@ -335,7 +335,6 @@ async function kit({ svelte_config }) {
|
|
|
335
335
|
__SVELTEKIT_ADAPTER_NAME__: s(kit.adapter?.name),
|
|
336
336
|
__SVELTEKIT_APP_VERSION_FILE__: s(`${kit.appDir}/version.json`),
|
|
337
337
|
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: s(kit.version.pollInterval),
|
|
338
|
-
__SVELTEKIT_DEV__: 'false',
|
|
339
338
|
__SVELTEKIT_EMBEDDED__: s(kit.embedded),
|
|
340
339
|
__SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: s(kit.experimental.remoteFunctions),
|
|
341
340
|
__SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),
|
|
@@ -351,7 +350,6 @@ async function kit({ svelte_config }) {
|
|
|
351
350
|
} else {
|
|
352
351
|
new_config.define = {
|
|
353
352
|
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
|
|
354
|
-
__SVELTEKIT_DEV__: 'true',
|
|
355
353
|
__SVELTEKIT_EMBEDDED__: s(kit.embedded),
|
|
356
354
|
__SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: s(kit.experimental.remoteFunctions),
|
|
357
355
|
__SVELTEKIT_CLIENT_ROUTING__: s(kit.router.resolution === 'client'),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEV } from 'esm-env';
|
|
1
2
|
import { getContext } from 'svelte';
|
|
2
3
|
|
|
3
4
|
function context() {
|
|
@@ -16,31 +17,30 @@ function context_dev(name) {
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
// TODO we're using DEV in some places and __SVELTEKIT_DEV__ in others - why? Can we consolidate?
|
|
20
20
|
export const page = {
|
|
21
21
|
get data() {
|
|
22
|
-
return (
|
|
22
|
+
return (DEV ? context_dev('page.data') : context()).page.data;
|
|
23
23
|
},
|
|
24
24
|
get error() {
|
|
25
|
-
return (
|
|
25
|
+
return (DEV ? context_dev('page.error') : context()).page.error;
|
|
26
26
|
},
|
|
27
27
|
get form() {
|
|
28
|
-
return (
|
|
28
|
+
return (DEV ? context_dev('page.form') : context()).page.form;
|
|
29
29
|
},
|
|
30
30
|
get params() {
|
|
31
|
-
return (
|
|
31
|
+
return (DEV ? context_dev('page.params') : context()).page.params;
|
|
32
32
|
},
|
|
33
33
|
get route() {
|
|
34
|
-
return (
|
|
34
|
+
return (DEV ? context_dev('page.route') : context()).page.route;
|
|
35
35
|
},
|
|
36
36
|
get state() {
|
|
37
|
-
return (
|
|
37
|
+
return (DEV ? context_dev('page.state') : context()).page.state;
|
|
38
38
|
},
|
|
39
39
|
get status() {
|
|
40
|
-
return (
|
|
40
|
+
return (DEV ? context_dev('page.status') : context()).page.status;
|
|
41
41
|
},
|
|
42
42
|
get url() {
|
|
43
|
-
return (
|
|
43
|
+
return (DEV ? context_dev('page.url') : context()).page.url;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getContext } from 'svelte';
|
|
2
|
-
import { BROWSER } from 'esm-env';
|
|
2
|
+
import { BROWSER, DEV } from 'esm-env';
|
|
3
3
|
import { stores as browser_stores } from '../client/client.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -35,7 +35,7 @@ export const getStores = () => {
|
|
|
35
35
|
*/
|
|
36
36
|
export const page = {
|
|
37
37
|
subscribe(fn) {
|
|
38
|
-
const store =
|
|
38
|
+
const store = DEV ? get_store('page') : getStores().page;
|
|
39
39
|
return store.subscribe(fn);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -52,7 +52,7 @@ export const page = {
|
|
|
52
52
|
*/
|
|
53
53
|
export const navigating = {
|
|
54
54
|
subscribe(fn) {
|
|
55
|
-
const store =
|
|
55
|
+
const store = DEV ? get_store('navigating') : getStores().navigating;
|
|
56
56
|
return store.subscribe(fn);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
@@ -67,7 +67,7 @@ export const navigating = {
|
|
|
67
67
|
*/
|
|
68
68
|
export const updated = {
|
|
69
69
|
subscribe(fn) {
|
|
70
|
-
const store =
|
|
70
|
+
const store = DEV ? get_store('updated') : getStores().updated;
|
|
71
71
|
|
|
72
72
|
if (BROWSER) {
|
|
73
73
|
updated.check = store.check;
|
|
@@ -210,7 +210,7 @@ export function form(id) {
|
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
-
instance.onsubmit = form_onsubmit(({ submit }) => submit());
|
|
213
|
+
instance.onsubmit = form_onsubmit(({ submit, form }) => submit().then(() => form.reset()));
|
|
214
214
|
|
|
215
215
|
/** @param {Parameters<RemoteForm<any>['buttonProps']['enhance']>[0]} callback */
|
|
216
216
|
const form_action_onclick = (callback) => {
|
|
@@ -247,7 +247,7 @@ export function form(id) {
|
|
|
247
247
|
type: 'submit',
|
|
248
248
|
formmethod: 'POST',
|
|
249
249
|
formaction: action,
|
|
250
|
-
onclick: form_action_onclick(({ submit }) => submit())
|
|
250
|
+
onclick: form_action_onclick(({ submit, form }) => submit().then(() => form.reset()))
|
|
251
251
|
};
|
|
252
252
|
|
|
253
253
|
Object.defineProperty(button_props, 'enhance', {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parse, serialize } from 'cookie';
|
|
2
|
+
import { DEV } from 'esm-env';
|
|
2
3
|
import { normalize_path, resolve } from '../../utils/url.js';
|
|
3
4
|
import { add_data_suffix } from '../pathname.js';
|
|
4
5
|
import { text_encoder } from '../utils.js';
|
|
@@ -96,7 +97,7 @@ export function get_cookies(request, url) {
|
|
|
96
97
|
// in development, if the cookie was set during this session with `cookies.set`,
|
|
97
98
|
// but at a different path, warn the user. (ignore cookies from request headers,
|
|
98
99
|
// since we don't know which path they were set at)
|
|
99
|
-
if (
|
|
100
|
+
if (DEV && !cookie) {
|
|
100
101
|
const paths = Array.from(cookie_paths[name] ?? []).filter((path) => {
|
|
101
102
|
// we only care about paths that are _more_ specific than the current path
|
|
102
103
|
return path_matches(path, url.pathname) && path !== url.pathname;
|
|
@@ -252,7 +253,7 @@ export function get_cookies(request, url) {
|
|
|
252
253
|
const cookie = { name, value, options: { ...options, path } };
|
|
253
254
|
new_cookies.set(cookie_key, cookie);
|
|
254
255
|
|
|
255
|
-
if (
|
|
256
|
+
if (DEV) {
|
|
256
257
|
const serialized = serialize(name, value, cookie.options);
|
|
257
258
|
if (text_encoder.encode(serialized).byteLength > MAX_COOKIE_SIZE) {
|
|
258
259
|
throw new Error(`Cookie "${name}" is too large, and will be discarded by the browser`);
|
|
@@ -57,7 +57,7 @@ export async function handle_action_json_request(event, event_state, options, se
|
|
|
57
57
|
try {
|
|
58
58
|
const data = await call_action(event, event_state, actions);
|
|
59
59
|
|
|
60
|
-
if (
|
|
60
|
+
if (DEV) {
|
|
61
61
|
validate_action_return(data);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -176,7 +176,7 @@ export async function handle_action_request(event, event_state, server) {
|
|
|
176
176
|
try {
|
|
177
177
|
const data = await call_action(event, event_state, actions);
|
|
178
178
|
|
|
179
|
-
if (
|
|
179
|
+
if (DEV) {
|
|
180
180
|
validate_action_return(data);
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEV } from 'esm-env';
|
|
1
2
|
import { escape_html } from '../../../utils/escape.js';
|
|
2
3
|
import { sha256 } from './crypto.js';
|
|
3
4
|
|
|
@@ -77,7 +78,7 @@ class BaseProvider {
|
|
|
77
78
|
*/
|
|
78
79
|
constructor(use_hashes, directives, nonce) {
|
|
79
80
|
this.#use_hashes = use_hashes;
|
|
80
|
-
this.#directives =
|
|
81
|
+
this.#directives = DEV ? { ...directives } : directives; // clone in dev so we can safely mutate
|
|
81
82
|
|
|
82
83
|
const d = this.#directives;
|
|
83
84
|
|
|
@@ -93,7 +94,7 @@ class BaseProvider {
|
|
|
93
94
|
const style_src_attr = d['style-src-attr'];
|
|
94
95
|
const style_src_elem = d['style-src-elem'];
|
|
95
96
|
|
|
96
|
-
if (
|
|
97
|
+
if (DEV) {
|
|
97
98
|
// remove strict-dynamic in dev...
|
|
98
99
|
// TODO reinstate this if we can figure out how to make strict-dynamic work
|
|
99
100
|
// if (d['default-src']) {
|
|
@@ -148,7 +149,7 @@ class BaseProvider {
|
|
|
148
149
|
|
|
149
150
|
this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
|
|
150
151
|
this.#style_needs_csp =
|
|
151
|
-
!
|
|
152
|
+
!DEV &&
|
|
152
153
|
(this.#style_src_needs_csp ||
|
|
153
154
|
this.#style_src_attr_needs_csp ||
|
|
154
155
|
this.#style_src_elem_needs_csp);
|
|
@@ -176,7 +176,7 @@ export async function load_server_data({ event, event_state, state, node, parent
|
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
|
|
179
|
-
if (
|
|
179
|
+
if (DEV) {
|
|
180
180
|
validate_load_response(result, `in ${node.server_id}`);
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -278,7 +278,7 @@ export async function load_data({
|
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
-
if (
|
|
281
|
+
if (DEV) {
|
|
282
282
|
validate_load_response(result, `in ${node.universal_id}`);
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -182,7 +182,7 @@ export async function render_response({
|
|
|
182
182
|
])
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
if (
|
|
185
|
+
if (DEV) {
|
|
186
186
|
const fetch = globalThis.fetch;
|
|
187
187
|
let warned = false;
|
|
188
188
|
globalThis.fetch = (info, init) => {
|
|
@@ -255,7 +255,7 @@ export async function render_response({
|
|
|
255
255
|
: Array.from(inline_styles.values()).join('\n');
|
|
256
256
|
|
|
257
257
|
if (style) {
|
|
258
|
-
const attributes =
|
|
258
|
+
const attributes = DEV ? [' data-sveltekit'] : [];
|
|
259
259
|
if (csp.style_needs_nonce) attributes.push(` nonce="${csp.nonce}"`);
|
|
260
260
|
|
|
261
261
|
csp.add_style(style);
|
|
@@ -295,7 +295,7 @@ export async function render_response({
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
const global =
|
|
298
|
+
const global = DEV ? '__sveltekit_dev' : `__sveltekit_${options.version_hash}`;
|
|
299
299
|
|
|
300
300
|
const { data, chunks } = get_data(
|
|
301
301
|
event,
|
|
@@ -516,10 +516,10 @@ export async function render_response({
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
if (options.service_worker) {
|
|
519
|
-
let opts =
|
|
519
|
+
let opts = DEV ? ", { type: 'module' }" : '';
|
|
520
520
|
if (options.service_worker_options != null) {
|
|
521
521
|
const service_worker_options = { ...options.service_worker_options };
|
|
522
|
-
if (
|
|
522
|
+
if (DEV) {
|
|
523
523
|
service_worker_options.type = 'module';
|
|
524
524
|
}
|
|
525
525
|
opts = `, ${s(service_worker_options)}`;
|
|
@@ -40,7 +40,6 @@ import { record_span } from '../telemetry/record_span.js';
|
|
|
40
40
|
import { otel } from '../telemetry/otel.js';
|
|
41
41
|
|
|
42
42
|
/* global __SVELTEKIT_ADAPTER_NAME__ */
|
|
43
|
-
/* global __SVELTEKIT_DEV__ */
|
|
44
43
|
|
|
45
44
|
/** @type {import('types').RequiredResolveOptions['transformPageChunk']} */
|
|
46
45
|
const default_transform = ({ html }) => html;
|
|
@@ -167,7 +166,7 @@ export async function internal_respond(request, options, manifest, state) {
|
|
|
167
166
|
request,
|
|
168
167
|
route: { id: null },
|
|
169
168
|
setHeaders: (new_headers) => {
|
|
170
|
-
if (
|
|
169
|
+
if (DEV) {
|
|
171
170
|
validateHeaders(new_headers);
|
|
172
171
|
}
|
|
173
172
|
|
|
@@ -104,7 +104,7 @@ export async function handle_error_and_jsonify(event, state, options, error) {
|
|
|
104
104
|
return { message: 'Unknown Error', ...error.body };
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
if (
|
|
107
|
+
if (DEV && typeof error == 'object') {
|
|
108
108
|
fix_stack_trace(error);
|
|
109
109
|
}
|
|
110
110
|
|
package/src/types/ambient.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ declare module '$service-worker' {
|
|
|
66
66
|
*/
|
|
67
67
|
export const build: string[];
|
|
68
68
|
/**
|
|
69
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration)
|
|
69
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
|
|
70
70
|
*/
|
|
71
71
|
export const files: string[];
|
|
72
72
|
/**
|
|
@@ -2,7 +2,6 @@ declare global {
|
|
|
2
2
|
const __SVELTEKIT_ADAPTER_NAME__: string;
|
|
3
3
|
const __SVELTEKIT_APP_VERSION_FILE__: string;
|
|
4
4
|
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
|
|
5
|
-
const __SVELTEKIT_DEV__: boolean;
|
|
6
5
|
const __SVELTEKIT_EMBEDDED__: boolean;
|
|
7
6
|
/** True if `config.kit.experimental.instrumentation.server` is `true` */
|
|
8
7
|
const __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1798,7 +1798,7 @@ declare module '@sveltejs/kit' {
|
|
|
1798
1798
|
* await submit().updates(
|
|
1799
1799
|
* todos.withOverride((todos) => [...todos, { text: data.get('text') }])
|
|
1800
1800
|
* );
|
|
1801
|
-
* }}>
|
|
1801
|
+
* })}>
|
|
1802
1802
|
* <input type="text" name="text" />
|
|
1803
1803
|
* <button type="submit">Add Todo</button>
|
|
1804
1804
|
* </form>
|
|
@@ -3087,7 +3087,7 @@ declare module '$service-worker' {
|
|
|
3087
3087
|
*/
|
|
3088
3088
|
export const build: string[];
|
|
3089
3089
|
/**
|
|
3090
|
-
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration)
|
|
3090
|
+
* An array of URL strings representing the files in your static directory, or whatever directory is specified by `config.kit.files.assets`. You can customize which files are included from `static` directory using [`config.kit.serviceWorker.files`](https://svelte.dev/docs/kit/configuration#serviceWorker)
|
|
3091
3091
|
*/
|
|
3092
3092
|
export const files: string[];
|
|
3093
3093
|
/**
|