@sveltejs/kit 1.0.0-next.199 → 1.0.0-next.201
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/dist/chunks/index.js +1 -1
- package/dist/chunks/index4.js +8 -3
- package/dist/chunks/url.js +62 -0
- package/dist/cli.js +2 -2
- package/dist/ssr.js +2 -33
- package/package.json +5 -3
- package/dist/chunks/http.js +0 -23
package/dist/chunks/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { S as SVELTE_KIT, a as SVELTE_KIT_ASSETS } from './constants.js';
|
|
|
22
22
|
import { c as coalesce_to_error } from './error.js';
|
|
23
23
|
import 'sade';
|
|
24
24
|
import 'net';
|
|
25
|
-
import './
|
|
25
|
+
import './url.js';
|
|
26
26
|
import './standard.js';
|
|
27
27
|
import 'zlib';
|
|
28
28
|
import 'stream';
|
package/dist/chunks/index4.js
CHANGED
|
@@ -2,9 +2,9 @@ import { m as mkdirp, r as rimraf, d as copy, $, l as logger } from '../cli.js';
|
|
|
2
2
|
import { S as SVELTE_KIT } from './constants.js';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
4
4
|
import { resolve, join, dirname } from 'path';
|
|
5
|
-
import { pathToFileURL,
|
|
5
|
+
import { pathToFileURL, URL } from 'url';
|
|
6
6
|
import { __fetch_polyfill } from '../install-fetch.js';
|
|
7
|
-
import { g as get_single_valued_header } from './
|
|
7
|
+
import { g as get_single_valued_header, r as resolve$1, i as is_root_relative } from './url.js';
|
|
8
8
|
import 'sade';
|
|
9
9
|
import 'child_process';
|
|
10
10
|
import 'net';
|
|
@@ -202,6 +202,11 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
202
202
|
log.warn(`${rendered.status} ${decoded_path} -> ${location}`);
|
|
203
203
|
writeFileSync(file, `<meta http-equiv="refresh" content="0;url=${encodeURI(location)}">`);
|
|
204
204
|
written_files.push(file);
|
|
205
|
+
|
|
206
|
+
const resolved = resolve$1(path, location);
|
|
207
|
+
if (is_root_relative(resolved)) {
|
|
208
|
+
await visit(resolved, path);
|
|
209
|
+
}
|
|
205
210
|
} else {
|
|
206
211
|
log.warn(`location header missing on redirect received from ${decoded_path}`);
|
|
207
212
|
}
|
|
@@ -275,7 +280,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
275
280
|
if (!href) continue;
|
|
276
281
|
|
|
277
282
|
const resolved = resolve$1(path, href);
|
|
278
|
-
if (!
|
|
283
|
+
if (!is_root_relative(resolved)) continue;
|
|
279
284
|
|
|
280
285
|
const parsed = new URL(resolved, 'http://localhost');
|
|
281
286
|
const pathname = decodeURI(parsed.pathname).replace(config.kit.paths.base, '');
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Record<string, string | string[]>} headers
|
|
3
|
+
* @param {string} key
|
|
4
|
+
* @returns {string | undefined}
|
|
5
|
+
* @throws {Error}
|
|
6
|
+
*/
|
|
7
|
+
function get_single_valued_header(headers, key) {
|
|
8
|
+
const value = headers[key];
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
if (value.length === 0) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
if (value.length > 1) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`Multiple headers provided for ${key}. Multiple may be provided only for set-cookie`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return value[0];
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const absolute = /^([a-z]+:)?\/?\//;
|
|
24
|
+
const scheme = /^[a-z]+:/;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} base
|
|
28
|
+
* @param {string} path
|
|
29
|
+
*/
|
|
30
|
+
function resolve(base, path) {
|
|
31
|
+
if (scheme.test(path)) return path;
|
|
32
|
+
|
|
33
|
+
const base_match = absolute.exec(base);
|
|
34
|
+
const path_match = absolute.exec(path);
|
|
35
|
+
|
|
36
|
+
if (!base_match) {
|
|
37
|
+
throw new Error(`bad base path: "${base}"`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
|
41
|
+
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
|
42
|
+
|
|
43
|
+
baseparts.pop();
|
|
44
|
+
|
|
45
|
+
for (let i = 0; i < pathparts.length; i += 1) {
|
|
46
|
+
const part = pathparts[i];
|
|
47
|
+
if (part === '.') continue;
|
|
48
|
+
else if (part === '..') baseparts.pop();
|
|
49
|
+
else baseparts.push(part);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
|
53
|
+
|
|
54
|
+
return `${prefix}${baseparts.join('/')}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @param {string} path */
|
|
58
|
+
function is_root_relative(path) {
|
|
59
|
+
return path[0] === '/' && path[1] !== '/';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { get_single_valued_header as g, is_root_relative as i, resolve as r };
|
package/dist/cli.js
CHANGED
|
@@ -822,7 +822,7 @@ async function launch(port, https) {
|
|
|
822
822
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
825
|
+
const prog = sade('svelte-kit').version('1.0.0-next.201');
|
|
826
826
|
|
|
827
827
|
prog
|
|
828
828
|
.command('dev')
|
|
@@ -987,7 +987,7 @@ async function check_port(port) {
|
|
|
987
987
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
988
988
|
if (open) launch(port, https);
|
|
989
989
|
|
|
990
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
990
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.201'}\n`));
|
|
991
991
|
|
|
992
992
|
const protocol = https ? 'https:' : 'http:';
|
|
993
993
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/dist/ssr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as get_single_valued_header } from './chunks/
|
|
1
|
+
import { g as get_single_valued_header, r as resolve, i as is_root_relative } from './chunks/url.js';
|
|
2
2
|
import { c as coalesce_to_error } from './chunks/error.js';
|
|
3
3
|
|
|
4
4
|
/** @param {Record<string, any>} obj */
|
|
@@ -900,7 +900,7 @@ async function load_node({
|
|
|
900
900
|
`http://${page.host}/${asset.file}`,
|
|
901
901
|
/** @type {RequestInit} */ (opts)
|
|
902
902
|
);
|
|
903
|
-
} else if (
|
|
903
|
+
} else if (is_root_relative(resolved)) {
|
|
904
904
|
const relative = resolved;
|
|
905
905
|
|
|
906
906
|
const headers = /** @type {import('types/helper').RequestHeaders} */ ({
|
|
@@ -1078,37 +1078,6 @@ async function load_node({
|
|
|
1078
1078
|
};
|
|
1079
1079
|
}
|
|
1080
1080
|
|
|
1081
|
-
const absolute = /^([a-z]+:)?\/?\//;
|
|
1082
|
-
|
|
1083
|
-
/**
|
|
1084
|
-
* @param {string} base
|
|
1085
|
-
* @param {string} path
|
|
1086
|
-
*/
|
|
1087
|
-
function resolve(base, path) {
|
|
1088
|
-
const base_match = absolute.exec(base);
|
|
1089
|
-
const path_match = absolute.exec(path);
|
|
1090
|
-
|
|
1091
|
-
if (!base_match) {
|
|
1092
|
-
throw new Error(`bad base path: "${base}"`);
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
const baseparts = path_match ? [] : base.slice(base_match[0].length).split('/');
|
|
1096
|
-
const pathparts = path_match ? path.slice(path_match[0].length).split('/') : path.split('/');
|
|
1097
|
-
|
|
1098
|
-
baseparts.pop();
|
|
1099
|
-
|
|
1100
|
-
for (let i = 0; i < pathparts.length; i += 1) {
|
|
1101
|
-
const part = pathparts[i];
|
|
1102
|
-
if (part === '.') continue;
|
|
1103
|
-
else if (part === '..') baseparts.pop();
|
|
1104
|
-
else baseparts.push(part);
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
const prefix = (path_match && path_match[0]) || (base_match && base_match[0]) || '';
|
|
1108
|
-
|
|
1109
|
-
return `${prefix}${baseparts.join('/')}`;
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
1081
|
/**
|
|
1113
1082
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
1114
1083
|
* @typedef {import('types/internal').SSRNode} SSRNode
|
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.201",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
],
|
|
56
56
|
"exports": {
|
|
57
57
|
"./package.json": "./package.json",
|
|
58
|
+
".": {
|
|
59
|
+
"types": "./types/index.d.ts"
|
|
60
|
+
},
|
|
58
61
|
"./ssr": {
|
|
59
62
|
"import": "./dist/ssr.js"
|
|
60
63
|
},
|
|
@@ -66,8 +69,7 @@
|
|
|
66
69
|
},
|
|
67
70
|
"./install-fetch": {
|
|
68
71
|
"import": "./dist/install-fetch.js"
|
|
69
|
-
}
|
|
70
|
-
"./types": "./types/index.d.ts"
|
|
72
|
+
}
|
|
71
73
|
},
|
|
72
74
|
"types": "types/index.d.ts",
|
|
73
75
|
"engines": {
|
package/dist/chunks/http.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Record<string, string | string[]>} headers
|
|
3
|
-
* @param {string} key
|
|
4
|
-
* @returns {string | undefined}
|
|
5
|
-
* @throws {Error}
|
|
6
|
-
*/
|
|
7
|
-
function get_single_valued_header(headers, key) {
|
|
8
|
-
const value = headers[key];
|
|
9
|
-
if (Array.isArray(value)) {
|
|
10
|
-
if (value.length === 0) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
if (value.length > 1) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`Multiple headers provided for ${key}. Multiple may be provided only for set-cookie`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return value[0];
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { get_single_valued_header as g };
|