@sveltejs/kit 2.27.0 → 2.27.1
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 +1 -1
- package/src/core/generate_manifest/index.js +1 -1
- package/src/runtime/app/server/remote/command.js +1 -1
- package/src/runtime/app/server/remote/prerender.js +2 -2
- package/src/runtime/app/server/remote/query.js +1 -1
- package/src/runtime/server/page/render.js +2 -2
- package/src/types/internal.d.ts +1 -1
- package/src/utils/routing.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +10 -10
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ export function generate_manifest({ build_data, prerendered, relative_path, rout
|
|
|
59
59
|
assets.push(build_data.service_worker);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
// In case of server
|
|
62
|
+
// In case of server-side route resolution, we need to include all matchers. Prerendered routes are not part
|
|
63
63
|
// of the server manifest, and they could reference matchers that then would not be included.
|
|
64
64
|
const matchers = new Set(
|
|
65
65
|
build_data.client?.nodes ? Object.keys(build_data.manifest_data.matchers) : undefined
|
|
@@ -39,7 +39,7 @@ import { get_event_state } from '../../../server/event-state.js';
|
|
|
39
39
|
* @overload
|
|
40
40
|
* @param {Schema} validate
|
|
41
41
|
* @param {(arg: StandardSchemaV1.InferOutput<Schema>) => Output} fn
|
|
42
|
-
* @returns {RemoteCommand<StandardSchemaV1.
|
|
42
|
+
* @returns {RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>}
|
|
43
43
|
* @since 2.27
|
|
44
44
|
*/
|
|
45
45
|
/**
|
|
@@ -51,8 +51,8 @@ import { get_event_state } from '../../../server/event-state.js';
|
|
|
51
51
|
* @overload
|
|
52
52
|
* @param {Schema} schema
|
|
53
53
|
* @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn
|
|
54
|
-
* @param {{ inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.
|
|
55
|
-
* @returns {RemotePrerenderFunction<StandardSchemaV1.
|
|
54
|
+
* @param {{ inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.InferInput<Schema>>, dynamic?: boolean }} [options]
|
|
55
|
+
* @returns {RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>}
|
|
56
56
|
* @since 2.27
|
|
57
57
|
*/
|
|
58
58
|
/**
|
|
@@ -46,7 +46,7 @@ import { get_event_state } from '../../../server/event-state.js';
|
|
|
46
46
|
* @overload
|
|
47
47
|
* @param {Schema} schema
|
|
48
48
|
* @param {(arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>} fn
|
|
49
|
-
* @returns {RemoteQueryFunction<StandardSchemaV1.
|
|
49
|
+
* @returns {RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>}
|
|
50
50
|
* @since 2.27
|
|
51
51
|
*/
|
|
52
52
|
/**
|
|
@@ -178,11 +178,11 @@ export async function render_response({
|
|
|
178
178
|
globalThis.fetch = (info, init) => {
|
|
179
179
|
if (typeof info === 'string' && !SCHEME.test(info)) {
|
|
180
180
|
throw new Error(
|
|
181
|
-
`Cannot call \`fetch\` eagerly during server
|
|
181
|
+
`Cannot call \`fetch\` eagerly during server-side rendering with relative URL (${info}) — put your \`fetch\` calls inside \`onMount\` or a \`load\` function instead`
|
|
182
182
|
);
|
|
183
183
|
} else if (!warned) {
|
|
184
184
|
console.warn(
|
|
185
|
-
'Avoid calling `fetch` eagerly during server
|
|
185
|
+
'Avoid calling `fetch` eagerly during server-side rendering — put your `fetch` calls inside `onMount` or a `load` function instead'
|
|
186
186
|
);
|
|
187
187
|
warned = true;
|
|
188
188
|
}
|
package/src/types/internal.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export interface BuildData {
|
|
|
90
90
|
*/
|
|
91
91
|
css?: Array<string[] | undefined>;
|
|
92
92
|
/**
|
|
93
|
-
* Contains the client route manifest in a form suitable for the server which is used for server
|
|
93
|
+
* Contains the client route manifest in a form suitable for the server which is used for server-side route resolution.
|
|
94
94
|
* Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).
|
|
95
95
|
* Only set in case of `router.resolution === 'server'`.
|
|
96
96
|
*/
|
package/src/utils/routing.js
CHANGED
|
@@ -26,7 +26,7 @@ export function parse_route_id(id) {
|
|
|
26
26
|
rest: true,
|
|
27
27
|
chained: true
|
|
28
28
|
});
|
|
29
|
-
return '(?:/(
|
|
29
|
+
return '(?:/([^]*))?';
|
|
30
30
|
}
|
|
31
31
|
// special case — /[[optional]]/ could contain zero segments
|
|
32
32
|
const optional_match = /^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(segment);
|
|
@@ -86,7 +86,7 @@ export function parse_route_id(id) {
|
|
|
86
86
|
rest: !!is_rest,
|
|
87
87
|
chained: is_rest ? i === 1 && parts[0] === '' : false
|
|
88
88
|
});
|
|
89
|
-
return is_rest ? '(
|
|
89
|
+
return is_rest ? '([^]*?)' : is_optional ? '([^/]*)?' : '([^/]+?)';
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
return escape(content);
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1893,7 +1893,7 @@ declare module '@sveltejs/kit' {
|
|
|
1893
1893
|
*/
|
|
1894
1894
|
css?: Array<string[] | undefined>;
|
|
1895
1895
|
/**
|
|
1896
|
-
* Contains the client route manifest in a form suitable for the server which is used for server
|
|
1896
|
+
* Contains the client route manifest in a form suitable for the server which is used for server-side route resolution.
|
|
1897
1897
|
* Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).
|
|
1898
1898
|
* Only set in case of `router.resolution === 'server'`.
|
|
1899
1899
|
*/
|
|
@@ -2120,7 +2120,7 @@ declare module '@sveltejs/kit' {
|
|
|
2120
2120
|
* Checks whether this is an error thrown by {@link error}.
|
|
2121
2121
|
* @param status The status to filter for.
|
|
2122
2122
|
* */
|
|
2123
|
-
export function isHttpError<T extends number>(e: unknown, status?: T
|
|
2123
|
+
export function isHttpError<T extends number>(e: unknown, status?: T): e is (HttpError_1 & {
|
|
2124
2124
|
status: T extends undefined ? never : T;
|
|
2125
2125
|
});
|
|
2126
2126
|
/**
|
|
@@ -2150,13 +2150,13 @@ declare module '@sveltejs/kit' {
|
|
|
2150
2150
|
* @param data The value that will be serialized as JSON.
|
|
2151
2151
|
* @param init Options such as `status` and `headers` that will be added to the response. `Content-Type: application/json` and `Content-Length` headers will be added automatically.
|
|
2152
2152
|
*/
|
|
2153
|
-
export function json(data: any, init?: ResponseInit
|
|
2153
|
+
export function json(data: any, init?: ResponseInit): Response;
|
|
2154
2154
|
/**
|
|
2155
2155
|
* Create a `Response` object from the supplied body.
|
|
2156
2156
|
* @param body The value that will be used as-is.
|
|
2157
2157
|
* @param init Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.
|
|
2158
2158
|
*/
|
|
2159
|
-
export function text(body: string, init?: ResponseInit
|
|
2159
|
+
export function text(body: string, init?: ResponseInit): Response;
|
|
2160
2160
|
/**
|
|
2161
2161
|
* Create an `ActionFailure` object. Call when form submission fails.
|
|
2162
2162
|
* @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
|
|
@@ -2455,7 +2455,7 @@ declare module '$app/navigation' {
|
|
|
2455
2455
|
invalidateAll?: boolean | undefined;
|
|
2456
2456
|
invalidate?: (string | URL | ((url: URL) => boolean))[] | undefined;
|
|
2457
2457
|
state?: App.PageState | undefined;
|
|
2458
|
-
}
|
|
2458
|
+
}): Promise<void>;
|
|
2459
2459
|
/**
|
|
2460
2460
|
* Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated.
|
|
2461
2461
|
*
|
|
@@ -2484,7 +2484,7 @@ declare module '$app/navigation' {
|
|
|
2484
2484
|
* */
|
|
2485
2485
|
export function refreshAll({ includeLoadFunctions }?: {
|
|
2486
2486
|
includeLoadFunctions?: boolean;
|
|
2487
|
-
}
|
|
2487
|
+
}): Promise<void>;
|
|
2488
2488
|
/**
|
|
2489
2489
|
* Programmatically preloads the given page, which means
|
|
2490
2490
|
* 1. ensuring that the code for the page is loaded, and
|
|
@@ -2652,7 +2652,7 @@ declare module '$app/server' {
|
|
|
2652
2652
|
*
|
|
2653
2653
|
* @since 2.27
|
|
2654
2654
|
*/
|
|
2655
|
-
export function command<Schema extends StandardSchemaV1, Output>(validate: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Output): RemoteCommand<StandardSchemaV1.
|
|
2655
|
+
export function command<Schema extends StandardSchemaV1, Output>(validate: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Output): RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
2656
2656
|
/**
|
|
2657
2657
|
* Creates a form object that can be spread onto a `<form>` element.
|
|
2658
2658
|
*
|
|
@@ -2691,9 +2691,9 @@ declare module '$app/server' {
|
|
|
2691
2691
|
* @since 2.27
|
|
2692
2692
|
*/
|
|
2693
2693
|
export function prerender<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>, options?: {
|
|
2694
|
-
inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.
|
|
2694
|
+
inputs?: RemotePrerenderInputsGenerator<StandardSchemaV1.InferInput<Schema>>;
|
|
2695
2695
|
dynamic?: boolean;
|
|
2696
|
-
} | undefined): RemotePrerenderFunction<StandardSchemaV1.
|
|
2696
|
+
} | undefined): RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
2697
2697
|
/**
|
|
2698
2698
|
* Creates a remote query. When called from the browser, the function will be invoked on the server via a `fetch` call.
|
|
2699
2699
|
*
|
|
@@ -2717,7 +2717,7 @@ declare module '$app/server' {
|
|
|
2717
2717
|
*
|
|
2718
2718
|
* @since 2.27
|
|
2719
2719
|
*/
|
|
2720
|
-
export function query<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>): RemoteQueryFunction<StandardSchemaV1.
|
|
2720
|
+
export function query<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => MaybePromise<Output>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
2721
2721
|
type RemotePrerenderInputsGenerator<Input = any> = () => MaybePromise<Input[]>;
|
|
2722
2722
|
type MaybePromise<T> = T | Promise<T>;
|
|
2723
2723
|
|