@sveltejs/kit 1.0.0-next.550 → 1.0.0-next.552
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 +2 -2
- package/src/core/sync/create_manifest_data/index.js +14 -0
- package/src/exports/vite/build/build_server.js +4 -2
- package/src/exports/vite/build/utils.js +0 -1
- package/src/exports/vite/dev/index.js +11 -2
- package/src/runtime/app/environment.js +1 -1
- package/src/runtime/client/client.js +2 -2
- package/src/runtime/client/start.js +4 -1
- package/src/runtime/client/utils.js +4 -3
- package/src/runtime/control.js +1 -1
- package/src/runtime/env.js +6 -0
- package/src/runtime/server/fetch.js +11 -0
- package/src/runtime/server/index.js +1 -1
- package/src/runtime/server/page/render.js +2 -1
- package/types/ambient.d.ts +5 -0
- package/types/index.d.ts +29 -8
- package/types/internal.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.552",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/node": "^16.11.68",
|
|
32
32
|
"@types/sade": "^1.7.4",
|
|
33
33
|
"@types/set-cookie-parser": "^2.4.2",
|
|
34
|
-
"marked": "^4.
|
|
34
|
+
"marked": "^4.2.2",
|
|
35
35
|
"rollup": "^2.79.1",
|
|
36
36
|
"svelte": "^3.52.0",
|
|
37
37
|
"svelte-preprocess": "^4.10.7",
|
|
@@ -195,6 +195,20 @@ function create_routes_and_nodes(cwd, config, fallback) {
|
|
|
195
195
|
if (!file.name.startsWith('+')) continue;
|
|
196
196
|
if (!valid_extensions.find((ext) => file.name.endsWith(ext))) continue;
|
|
197
197
|
|
|
198
|
+
if (file.name.endsWith('.d.ts')) {
|
|
199
|
+
let name = file.name.slice(0, -5);
|
|
200
|
+
const ext = valid_extensions.find((ext) => name.endsWith(ext));
|
|
201
|
+
if (ext) name = name.slice(0, -ext.length);
|
|
202
|
+
|
|
203
|
+
const valid =
|
|
204
|
+
/^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/.test(name) ||
|
|
205
|
+
/^\+(?:(server)|(page(?:(@[a-zA-Z0-9_-]*))?(\.server)?)|(layout(?:(@[a-zA-Z0-9_-]*))?(\.server)?))$/.test(
|
|
206
|
+
name
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
if (valid) continue;
|
|
210
|
+
}
|
|
211
|
+
|
|
198
212
|
const project_relative = posixify(path.relative(cwd, path.join(dir, file.name)));
|
|
199
213
|
|
|
200
214
|
const item = analyze(
|
|
@@ -27,7 +27,7 @@ const server_template = ({ config, hooks, has_service_worker, runtime, template,
|
|
|
27
27
|
import root from '__GENERATED__/root.svelte';
|
|
28
28
|
import { respond } from '${runtime}/server/index.js';
|
|
29
29
|
import { set_paths, assets, base } from '${runtime}/paths.js';
|
|
30
|
-
import { set_prerendering } from '${runtime}/env.js';
|
|
30
|
+
import { set_prerendering, set_version } from '${runtime}/env.js';
|
|
31
31
|
import { set_private_env } from '${runtime}/env-private.js';
|
|
32
32
|
import { set_public_env } from '${runtime}/env-public.js';
|
|
33
33
|
|
|
@@ -44,6 +44,7 @@ const error_template = ({ status, message }) => ${s(error_page)
|
|
|
44
44
|
let read = null;
|
|
45
45
|
|
|
46
46
|
set_paths(${s(config.kit.paths)});
|
|
47
|
+
set_version(${s(config.kit.version.name)});
|
|
47
48
|
|
|
48
49
|
let default_protocol = 'https';
|
|
49
50
|
|
|
@@ -86,7 +87,8 @@ export class Server {
|
|
|
86
87
|
app_template,
|
|
87
88
|
app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
|
|
88
89
|
error_template,
|
|
89
|
-
trailing_slash: ${s(config.kit.trailingSlash)}
|
|
90
|
+
trailing_slash: ${s(config.kit.trailingSlash)},
|
|
91
|
+
version: ${s(config.kit.version.name)}
|
|
90
92
|
};
|
|
91
93
|
}
|
|
92
94
|
|
|
@@ -147,7 +147,6 @@ export function get_default_build_config({ config, input, ssr, outDir }) {
|
|
|
147
147
|
},
|
|
148
148
|
define: {
|
|
149
149
|
__SVELTEKIT_ADAPTER_NAME__: JSON.stringify(config.kit.adapter?.name),
|
|
150
|
-
__SVELTEKIT_APP_VERSION__: JSON.stringify(config.kit.version.name),
|
|
151
150
|
__SVELTEKIT_APP_VERSION_FILE__: JSON.stringify(`${config.kit.appDir}/version.json`),
|
|
152
151
|
__SVELTEKIT_APP_VERSION_POLL_INTERVAL__: JSON.stringify(config.kit.version.pollInterval),
|
|
153
152
|
__SVELTEKIT_BROWSER__: ssr ? 'false' : 'true',
|
|
@@ -236,7 +236,10 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
236
236
|
dev: true,
|
|
237
237
|
etag: true,
|
|
238
238
|
maxAge: 0,
|
|
239
|
-
extensions: []
|
|
239
|
+
extensions: [],
|
|
240
|
+
setHeaders: (res) => {
|
|
241
|
+
res.setHeader('access-control-allow-origin', '*');
|
|
242
|
+
}
|
|
240
243
|
});
|
|
241
244
|
|
|
242
245
|
vite.middlewares.use(async (req, res, next) => {
|
|
@@ -268,6 +271,11 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
268
271
|
}
|
|
269
272
|
});
|
|
270
273
|
|
|
274
|
+
// set `import { version } from '$app/environment'`
|
|
275
|
+
(await vite.ssrLoadModule(`${runtime_prefix}/env.js`)).set_version(
|
|
276
|
+
svelte_config.kit.version.name
|
|
277
|
+
);
|
|
278
|
+
|
|
271
279
|
return () => {
|
|
272
280
|
const serve_static_middleware = vite.middlewares.stack.find(
|
|
273
281
|
(middleware) =>
|
|
@@ -472,7 +480,8 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
472
480
|
service_worker:
|
|
473
481
|
svelte_config.kit.serviceWorker.register &&
|
|
474
482
|
!!resolve_entry(svelte_config.kit.files.serviceWorker),
|
|
475
|
-
trailing_slash: svelte_config.kit.trailingSlash
|
|
483
|
+
trailing_slash: svelte_config.kit.trailingSlash,
|
|
484
|
+
version: svelte_config.kit.version.name
|
|
476
485
|
},
|
|
477
486
|
{
|
|
478
487
|
getClientAddress: () => {
|
|
@@ -1202,13 +1202,13 @@ export function create_client({ target, base, trailing_slash }) {
|
|
|
1202
1202
|
|
|
1203
1203
|
goto: (href, opts = {}) => {
|
|
1204
1204
|
// TODO remove for 1.0
|
|
1205
|
-
if ('keepfocus' in opts) {
|
|
1205
|
+
if ('keepfocus' in opts && !('keepFocus' in opts)) {
|
|
1206
1206
|
throw new Error(
|
|
1207
1207
|
'`keepfocus` has been renamed to `keepFocus` (note the difference in casing)'
|
|
1208
1208
|
);
|
|
1209
1209
|
}
|
|
1210
1210
|
|
|
1211
|
-
if ('noscroll' in opts) {
|
|
1211
|
+
if ('noscroll' in opts && !('noScroll' in opts)) {
|
|
1212
1212
|
throw new Error(
|
|
1213
1213
|
'`noscroll` has been renamed to `noScroll` (note the difference in casing)'
|
|
1214
1214
|
);
|
|
@@ -2,6 +2,7 @@ import { create_client } from './client.js';
|
|
|
2
2
|
import { init } from './singletons.js';
|
|
3
3
|
import { set_paths } from '../paths.js';
|
|
4
4
|
import { set_public_env } from '../env-public.js';
|
|
5
|
+
import { set_version } from '../env.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @param {{
|
|
@@ -13,11 +14,13 @@ import { set_public_env } from '../env-public.js';
|
|
|
13
14
|
* },
|
|
14
15
|
* target: Element;
|
|
15
16
|
* trailing_slash: import('types').TrailingSlash;
|
|
17
|
+
* version: string;
|
|
16
18
|
* }} opts
|
|
17
19
|
*/
|
|
18
|
-
export async function start({ env, hydrate, paths, target, trailing_slash }) {
|
|
20
|
+
export async function start({ env, hydrate, paths, target, trailing_slash, version }) {
|
|
19
21
|
set_public_env(env);
|
|
20
22
|
set_paths(paths);
|
|
23
|
+
set_version(version);
|
|
21
24
|
|
|
22
25
|
if (__SVELTEKIT_DEV__ && target === document.body) {
|
|
23
26
|
console.warn(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { writable } from 'svelte/store';
|
|
2
2
|
import { assets } from '../paths.js';
|
|
3
|
+
import { version } from '../env.js';
|
|
3
4
|
|
|
4
|
-
/* global
|
|
5
|
+
/* global __SVELTEKIT_APP_VERSION_FILE__, __SVELTEKIT_APP_VERSION_POLL_INTERVAL__ */
|
|
5
6
|
|
|
6
7
|
/** @param {HTMLDocument} doc */
|
|
7
8
|
export function get_base_uri(doc) {
|
|
@@ -143,8 +144,8 @@ export function create_updated_store() {
|
|
|
143
144
|
});
|
|
144
145
|
|
|
145
146
|
if (res.ok) {
|
|
146
|
-
const
|
|
147
|
-
const updated = version !==
|
|
147
|
+
const data = await res.json();
|
|
148
|
+
const updated = data.version !== version;
|
|
148
149
|
|
|
149
150
|
if (updated) {
|
|
150
151
|
set(true);
|
package/src/runtime/control.js
CHANGED
package/src/runtime/env.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export let prerendering = false;
|
|
2
|
+
export let version = '';
|
|
2
3
|
|
|
3
4
|
/** @param {boolean} value */
|
|
4
5
|
export function set_prerendering(value) {
|
|
5
6
|
prerendering = value;
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
/** @param {string} value */
|
|
10
|
+
export function set_version(value) {
|
|
11
|
+
version = value;
|
|
12
|
+
}
|
|
@@ -128,6 +128,17 @@ export function create_fetch({ event, options, state, get_cookie_header }) {
|
|
|
128
128
|
throw new Error('Request body must be a string or TypedArray');
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
if (!request.headers.has('accept')) {
|
|
132
|
+
request.headers.set('accept', '*/*');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!request.headers.has('accept-language')) {
|
|
136
|
+
request.headers.set(
|
|
137
|
+
'accept-language',
|
|
138
|
+
/** @type {string} */ (event.request.headers.get('accept-language'))
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
131
142
|
response = await respond(request, options, state);
|
|
132
143
|
|
|
133
144
|
const set_cookie = response.headers.get('set-cookie');
|
|
@@ -27,7 +27,7 @@ const default_transform = ({ html }) => html;
|
|
|
27
27
|
const default_filter = () => false;
|
|
28
28
|
|
|
29
29
|
/** @type {import('types').RequiredResolveOptions['preload']} */
|
|
30
|
-
const default_preload = ({ type }) => type
|
|
30
|
+
const default_preload = ({ type }) => type === 'js' || type === 'css';
|
|
31
31
|
|
|
32
32
|
/** @type {import('types').Respond} */
|
|
33
33
|
export async function respond(request, options, state) {
|
|
@@ -281,7 +281,8 @@ export async function render_response({
|
|
|
281
281
|
}` : 'null'},
|
|
282
282
|
paths: ${s(options.paths)},
|
|
283
283
|
target: document.querySelector('[data-sveltekit-hydrate="${target}"]').parentNode,
|
|
284
|
-
trailing_slash: ${s(options.trailing_slash)}
|
|
284
|
+
trailing_slash: ${s(options.trailing_slash)},
|
|
285
|
+
version: ${s(options.version)}
|
|
285
286
|
});
|
|
286
287
|
`;
|
|
287
288
|
|
package/types/ambient.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
UniqueInterface
|
|
19
19
|
} from './private.js';
|
|
20
20
|
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
|
|
21
|
-
import { HttpError, Redirect } from '../src/runtime/control.js';
|
|
22
21
|
|
|
23
22
|
export { PrerenderOption } from './private.js';
|
|
24
23
|
|
|
@@ -53,13 +52,6 @@ type OptionalUnion<
|
|
|
53
52
|
A extends keyof U = U extends U ? keyof U : never
|
|
54
53
|
> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
|
|
55
54
|
|
|
56
|
-
// Needs to be here, else ActionData will be resolved to unknown - probably because of "d.ts file imports .js file" in combination with allowJs
|
|
57
|
-
export interface ValidationError<T extends Record<string, unknown> | undefined = undefined>
|
|
58
|
-
extends UniqueInterface {
|
|
59
|
-
status: number;
|
|
60
|
-
data: T;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
55
|
type UnpackValidationError<T> = T extends ValidationError<infer X>
|
|
64
56
|
? X
|
|
65
57
|
: T extends void
|
|
@@ -752,6 +744,16 @@ export function error(
|
|
|
752
744
|
body?: { message: string } extends App.Error ? App.Error | string | undefined : never
|
|
753
745
|
): HttpError;
|
|
754
746
|
|
|
747
|
+
/**
|
|
748
|
+
* The object returned by the `error` function
|
|
749
|
+
*/
|
|
750
|
+
export interface HttpError {
|
|
751
|
+
/** The HTTP status code */
|
|
752
|
+
status: number;
|
|
753
|
+
/** The error message */
|
|
754
|
+
body: App.Error;
|
|
755
|
+
}
|
|
756
|
+
|
|
755
757
|
/**
|
|
756
758
|
* Creates a `Redirect` object. If thrown during request handling, SvelteKit will
|
|
757
759
|
* return a redirect response.
|
|
@@ -761,6 +763,16 @@ export function redirect(
|
|
|
761
763
|
location: string
|
|
762
764
|
): Redirect;
|
|
763
765
|
|
|
766
|
+
/**
|
|
767
|
+
* The object returned by the `redirect` function
|
|
768
|
+
*/
|
|
769
|
+
export interface Redirect {
|
|
770
|
+
/** The HTTP status code */
|
|
771
|
+
status: 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308;
|
|
772
|
+
/** The location to redirect to */
|
|
773
|
+
location: string;
|
|
774
|
+
}
|
|
775
|
+
|
|
764
776
|
/**
|
|
765
777
|
* Generates a JSON `Response` object from the supplied data.
|
|
766
778
|
*/
|
|
@@ -773,3 +785,12 @@ export function invalid<T extends Record<string, unknown> | undefined>(
|
|
|
773
785
|
status: number,
|
|
774
786
|
data?: T
|
|
775
787
|
): ValidationError<T>;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* The object returned by the `invalid` function
|
|
791
|
+
*/
|
|
792
|
+
export interface ValidationError<T extends Record<string, unknown> | undefined = undefined>
|
|
793
|
+
extends UniqueInterface {
|
|
794
|
+
status: number;
|
|
795
|
+
data: T;
|
|
796
|
+
}
|
package/types/internal.d.ts
CHANGED
|
@@ -313,6 +313,7 @@ export interface SSROptions {
|
|
|
313
313
|
app_template_contains_nonce: boolean;
|
|
314
314
|
error_template({ message, status }: { message: string; status: number }): string;
|
|
315
315
|
trailing_slash: TrailingSlash;
|
|
316
|
+
version: string;
|
|
316
317
|
}
|
|
317
318
|
|
|
318
319
|
export interface SSRErrorPage {
|