@sveltejs/kit 1.0.0-next.327 → 1.0.0-next.328
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/assets/server/index.js +2 -7
- package/dist/chunks/index.js +2 -6
- package/dist/chunks/index2.js +78 -25
- package/dist/chunks/index5.js +12 -0
- package/dist/chunks/{url.js → object.js} +1 -56
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/assets/server/index.js
CHANGED
|
@@ -3142,13 +3142,7 @@ async function respond(request, options, state) {
|
|
|
3142
3142
|
|
|
3143
3143
|
if (is_data_request) {
|
|
3144
3144
|
decoded = decoded.slice(0, -DATA_SUFFIX.length) || '/';
|
|
3145
|
-
|
|
3146
|
-
const normalized = normalize_path(
|
|
3147
|
-
url.pathname.slice(0, -DATA_SUFFIX.length),
|
|
3148
|
-
options.trailing_slash
|
|
3149
|
-
);
|
|
3150
|
-
|
|
3151
|
-
url = new URL(url.origin + normalized + url.search);
|
|
3145
|
+
url = new URL(url.origin + url.pathname.slice(0, -DATA_SUFFIX.length) + url.search);
|
|
3152
3146
|
}
|
|
3153
3147
|
|
|
3154
3148
|
if (!state.prerender || !state.prerender.fallback) {
|
|
@@ -3174,6 +3168,7 @@ async function respond(request, options, state) {
|
|
|
3174
3168
|
return new Response(undefined, {
|
|
3175
3169
|
status: 301,
|
|
3176
3170
|
headers: {
|
|
3171
|
+
'x-sveltekit-normalize': '1',
|
|
3177
3172
|
location:
|
|
3178
3173
|
// ensure paths starting with '//' are not treated as protocol-relative
|
|
3179
3174
|
(normalized.startsWith('//') ? url.origin + normalized : normalized) +
|
package/dist/chunks/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path__default from 'path';
|
|
2
2
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
3
|
import vite from 'vite';
|
|
4
|
-
import {
|
|
4
|
+
import { d as deep_merge } from './object.js';
|
|
5
5
|
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
@@ -216,11 +216,7 @@ async function create_plugin(config, cwd) {
|
|
|
216
216
|
if (req.url === '/favicon.ico') return not_found(res);
|
|
217
217
|
|
|
218
218
|
if (!decoded.startsWith(config.kit.paths.base)) {
|
|
219
|
-
|
|
220
|
-
config.kit.paths.base + req.url,
|
|
221
|
-
config.kit.trailingSlash
|
|
222
|
-
);
|
|
223
|
-
return not_found(res, `Not found (did you mean ${suggestion}?)`);
|
|
219
|
+
return not_found(res, `Not found (did you mean ${config.kit.paths.base + req.url}?)`);
|
|
224
220
|
}
|
|
225
221
|
|
|
226
222
|
/** @type {Partial<import('types').Hooks>} */
|
package/dist/chunks/index2.js
CHANGED
|
@@ -6,7 +6,7 @@ import { p as print_config_conflicts, b as get_aliases, r as resolve_entry, g as
|
|
|
6
6
|
import { g as generate_manifest } from './index3.js';
|
|
7
7
|
import vite from 'vite';
|
|
8
8
|
import { s } from './misc.js';
|
|
9
|
-
import {
|
|
9
|
+
import { d as deep_merge } from './object.js';
|
|
10
10
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
11
11
|
import { pathToFileURL, URL as URL$1 } from 'url';
|
|
12
12
|
import { installFetch } from '../install-fetch.js';
|
|
@@ -22,6 +22,61 @@ import 'node:stream';
|
|
|
22
22
|
import 'node:util';
|
|
23
23
|
import 'node:url';
|
|
24
24
|
|
|
25
|
+
const absolute = /^([a-z]+:)?\/?\//;
|
|
26
|
+
const scheme = /^[a-z]+:/;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} base
|
|
30
|
+
* @param {string} path
|
|
31
|
+
*/
|
|
32
|
+
function resolve(base, path) {
|
|
33
|
+
if (scheme.test(path)) return path;
|
|
34
|
+
|
|
35
|
+
const base_match = absolute.exec(base);
|
|
36
|
+
const path_match = absolute.exec(path);
|
|
37
|
+
|
|
38
|
+
if (!base_match) {
|
|
39
|
+
throw new Error(`bad base path: "${base}"`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
|
43
|
+
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
|
44
|
+
|
|
45
|
+
baseparts.pop();
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < pathparts.length; i += 1) {
|
|
48
|
+
const part = pathparts[i];
|
|
49
|
+
if (part === '.') continue;
|
|
50
|
+
else if (part === '..') baseparts.pop();
|
|
51
|
+
else baseparts.push(part);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
|
55
|
+
|
|
56
|
+
return `${prefix}${baseparts.join('/')}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @param {string} path */
|
|
60
|
+
function is_root_relative(path) {
|
|
61
|
+
return path[0] === '/' && path[1] !== '/';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} path
|
|
66
|
+
* @param {import('types').TrailingSlash} trailing_slash
|
|
67
|
+
*/
|
|
68
|
+
function normalize_path(path, trailing_slash) {
|
|
69
|
+
if (path === '/' || trailing_slash === 'ignore') return path;
|
|
70
|
+
|
|
71
|
+
if (trailing_slash === 'never') {
|
|
72
|
+
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
73
|
+
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
|
74
|
+
return path + '/';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return path;
|
|
78
|
+
}
|
|
79
|
+
|
|
25
80
|
/**
|
|
26
81
|
* @param {{
|
|
27
82
|
* cwd: string;
|
|
@@ -1045,7 +1100,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1045
1100
|
}
|
|
1046
1101
|
|
|
1047
1102
|
if (is_html && !file.endsWith('.html')) {
|
|
1048
|
-
return file + (
|
|
1103
|
+
return file + (file.endsWith('/') ? 'index.html' : '.html');
|
|
1049
1104
|
}
|
|
1050
1105
|
|
|
1051
1106
|
return file;
|
|
@@ -1120,11 +1175,8 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1120
1175
|
const resolved = resolve(encoded, href);
|
|
1121
1176
|
if (!is_root_relative(resolved)) continue;
|
|
1122
1177
|
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1125
|
-
if (parsed.search) ;
|
|
1178
|
+
const { pathname, search } = new URL$1(resolved, 'http://localhost');
|
|
1126
1179
|
|
|
1127
|
-
const pathname = normalize_path(parsed.pathname, config.kit.trailingSlash);
|
|
1128
1180
|
enqueue(decoded, decodeURI(pathname), pathname);
|
|
1129
1181
|
}
|
|
1130
1182
|
}
|
|
@@ -1154,28 +1206,29 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1154
1206
|
const location = response.headers.get('location');
|
|
1155
1207
|
|
|
1156
1208
|
if (location) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
log.warn(`${response.status} ${decoded} -> ${location}`);
|
|
1160
|
-
|
|
1161
|
-
writeFileSync(
|
|
1162
|
-
dest,
|
|
1163
|
-
`<meta http-equiv="refresh" content=${escape_html_attr(`0;url=${location}`)}>`
|
|
1164
|
-
);
|
|
1165
|
-
|
|
1166
|
-
let resolved = resolve(encoded, location);
|
|
1209
|
+
const resolved = resolve(encoded, location);
|
|
1167
1210
|
if (is_root_relative(resolved)) {
|
|
1168
|
-
resolved = normalize_path(resolved, config.kit.trailingSlash);
|
|
1169
1211
|
enqueue(decoded, decodeURI(resolved), resolved);
|
|
1170
1212
|
}
|
|
1171
1213
|
|
|
1172
|
-
if (!
|
|
1173
|
-
|
|
1174
|
-
status: response.status,
|
|
1175
|
-
location: resolved
|
|
1176
|
-
});
|
|
1214
|
+
if (!response.headers.get('x-sveltekit-normalize')) {
|
|
1215
|
+
mkdirp(dirname(dest));
|
|
1177
1216
|
|
|
1178
|
-
|
|
1217
|
+
log.warn(`${response.status} ${decoded} -> ${location}`);
|
|
1218
|
+
|
|
1219
|
+
writeFileSync(
|
|
1220
|
+
dest,
|
|
1221
|
+
`<meta http-equiv="refresh" content=${escape_html_attr(`0;url=${location}`)}>`
|
|
1222
|
+
);
|
|
1223
|
+
|
|
1224
|
+
if (!prerendered.redirects.has(decoded)) {
|
|
1225
|
+
prerendered.redirects.set(decoded, {
|
|
1226
|
+
status: response.status,
|
|
1227
|
+
location: resolved
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
prerendered.paths.push(normalize_path(decoded, 'never'));
|
|
1231
|
+
}
|
|
1179
1232
|
}
|
|
1180
1233
|
} else {
|
|
1181
1234
|
log.warn(`location header missing on redirect received from ${decoded}`);
|
|
@@ -1210,10 +1263,10 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1210
1263
|
for (const entry of config.kit.prerender.entries) {
|
|
1211
1264
|
if (entry === '*') {
|
|
1212
1265
|
for (const entry of entries) {
|
|
1213
|
-
enqueue(null,
|
|
1266
|
+
enqueue(null, config.kit.paths.base + entry); // TODO can we pre-normalize these?
|
|
1214
1267
|
}
|
|
1215
1268
|
} else {
|
|
1216
|
-
enqueue(null,
|
|
1269
|
+
enqueue(null, config.kit.paths.base + entry);
|
|
1217
1270
|
}
|
|
1218
1271
|
}
|
|
1219
1272
|
|
package/dist/chunks/index5.js
CHANGED
|
@@ -79,6 +79,18 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
79
79
|
})
|
|
80
80
|
),
|
|
81
81
|
|
|
82
|
+
(req, res, next) => {
|
|
83
|
+
const original_url = /** @type {string} */ (req.url);
|
|
84
|
+
const { pathname } = new URL(original_url, 'http://dummy');
|
|
85
|
+
|
|
86
|
+
if (pathname.startsWith(base)) {
|
|
87
|
+
next();
|
|
88
|
+
} else {
|
|
89
|
+
res.statusCode = 404;
|
|
90
|
+
res.end(`Not found (did you mean ${base + pathname}?)`);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
82
94
|
// prerendered dependencies
|
|
83
95
|
scoped(base, mutable(join(config.kit.outDir, 'output/prerendered/dependencies'))),
|
|
84
96
|
|
|
@@ -80,59 +80,4 @@ function merge_into(a, b, conflicts = [], path = []) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
const scheme = /^[a-z]+:/;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @param {string} base
|
|
88
|
-
* @param {string} path
|
|
89
|
-
*/
|
|
90
|
-
function resolve(base, path) {
|
|
91
|
-
if (scheme.test(path)) return path;
|
|
92
|
-
|
|
93
|
-
const base_match = absolute.exec(base);
|
|
94
|
-
const path_match = absolute.exec(path);
|
|
95
|
-
|
|
96
|
-
if (!base_match) {
|
|
97
|
-
throw new Error(`bad base path: "${base}"`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
|
101
|
-
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
|
102
|
-
|
|
103
|
-
baseparts.pop();
|
|
104
|
-
|
|
105
|
-
for (let i = 0; i < pathparts.length; i += 1) {
|
|
106
|
-
const part = pathparts[i];
|
|
107
|
-
if (part === '.') continue;
|
|
108
|
-
else if (part === '..') baseparts.pop();
|
|
109
|
-
else baseparts.push(part);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
|
113
|
-
|
|
114
|
-
return `${prefix}${baseparts.join('/')}`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** @param {string} path */
|
|
118
|
-
function is_root_relative(path) {
|
|
119
|
-
return path[0] === '/' && path[1] !== '/';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @param {string} path
|
|
124
|
-
* @param {import('types').TrailingSlash} trailing_slash
|
|
125
|
-
*/
|
|
126
|
-
function normalize_path(path, trailing_slash) {
|
|
127
|
-
if (path === '/' || trailing_slash === 'ignore') return path;
|
|
128
|
-
|
|
129
|
-
if (trailing_slash === 'never') {
|
|
130
|
-
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
131
|
-
} else if (trailing_slash === 'always' && !path.endsWith('/')) {
|
|
132
|
-
return path + '/';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return path;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export { deep_merge as d, is_root_relative as i, normalize_path as n, resolve as r };
|
|
83
|
+
export { deep_merge as d };
|
package/dist/cli.js
CHANGED
|
@@ -870,7 +870,7 @@ async function launch(port, https, base) {
|
|
|
870
870
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
871
871
|
}
|
|
872
872
|
|
|
873
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
873
|
+
const prog = sade('svelte-kit').version('1.0.0-next.328');
|
|
874
874
|
|
|
875
875
|
prog
|
|
876
876
|
.command('dev')
|
|
@@ -1049,7 +1049,7 @@ async function check_port(port) {
|
|
|
1049
1049
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1050
1050
|
if (open) launch(port, https, base);
|
|
1051
1051
|
|
|
1052
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1052
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.328'}\n`));
|
|
1053
1053
|
|
|
1054
1054
|
const protocol = https ? 'https:' : 'http:';
|
|
1055
1055
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|