@sveltejs/kit 1.0.0-next.345 → 1.0.0-next.346
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/client/start.js +6 -0
- package/assets/server/index.js +1 -4
- package/dist/chunks/index.js +1260 -456
- package/dist/chunks/index2.js +88 -1361
- package/dist/chunks/index3.js +165 -99
- package/dist/chunks/index4.js +227 -147
- package/dist/chunks/index5.js +15690 -202
- package/dist/chunks/plugin.js +538 -0
- package/dist/chunks/sync.js +4 -3
- package/dist/cli.js +73 -35
- package/package.json +2 -2
- package/types/private.d.ts +2 -2
- package/dist/chunks/index6.js +0 -15749
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
2
|
import fs__default from 'fs';
|
|
3
3
|
import path__default, { join, relative } from 'path';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import * as child_process from 'child_process';
|
|
5
|
+
import * as net from 'net';
|
|
6
|
+
import sade from 'sade';
|
|
7
|
+
import * as vite from 'vite';
|
|
7
8
|
import * as url from 'url';
|
|
8
9
|
import { networkInterfaces, release } from 'os';
|
|
9
10
|
|
|
@@ -114,15 +115,20 @@ function init(open, close) {
|
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
/** @param {string} cmd */
|
|
117
119
|
function exec(cmd) {
|
|
118
120
|
return new Promise((fulfil, reject) => {
|
|
119
|
-
exec
|
|
121
|
+
child_process.exec(cmd, (error, stdout, stderr) => {
|
|
120
122
|
if (error) return reject(error);
|
|
121
123
|
fulfil({ stdout, stderr });
|
|
122
124
|
});
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Find the PID of the process using `port`
|
|
130
|
+
* @param {number} port
|
|
131
|
+
*/
|
|
126
132
|
async function blame(port) {
|
|
127
133
|
try {
|
|
128
134
|
const { stdout } = await exec(`lsof -i :${port} -sTCP:LISTEN -Fp`);
|
|
@@ -137,6 +143,9 @@ async function blame(port) {
|
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
const host = 'localhost';
|
|
147
|
+
|
|
148
|
+
/** @type {Promise<any>} */
|
|
140
149
|
let promise;
|
|
141
150
|
|
|
142
151
|
function weird() {
|
|
@@ -146,9 +155,10 @@ function weird() {
|
|
|
146
155
|
return promise;
|
|
147
156
|
}
|
|
148
157
|
|
|
158
|
+
/** @param {number} port */
|
|
149
159
|
function get_weird(port) {
|
|
150
|
-
return new Promise(fulfil => {
|
|
151
|
-
const server = createServer();
|
|
160
|
+
return new Promise((fulfil) => {
|
|
161
|
+
const server = net.createServer();
|
|
152
162
|
|
|
153
163
|
server.unref();
|
|
154
164
|
|
|
@@ -156,8 +166,8 @@ function get_weird(port) {
|
|
|
156
166
|
fulfil(get_weird(port + 1));
|
|
157
167
|
});
|
|
158
168
|
|
|
159
|
-
server.listen({ port }, () => {
|
|
160
|
-
const server2 = createServer();
|
|
169
|
+
server.listen({ host, port }, () => {
|
|
170
|
+
const server2 = net.createServer();
|
|
161
171
|
|
|
162
172
|
server2.unref();
|
|
163
173
|
|
|
@@ -167,7 +177,7 @@ function get_weird(port) {
|
|
|
167
177
|
});
|
|
168
178
|
});
|
|
169
179
|
|
|
170
|
-
server2.listen({ port }, () => {
|
|
180
|
+
server2.listen({ host, port }, () => {
|
|
171
181
|
server2.close(() => {
|
|
172
182
|
server.close(() => {
|
|
173
183
|
fulfil(true);
|
|
@@ -178,14 +188,18 @@ function get_weird(port) {
|
|
|
178
188
|
});
|
|
179
189
|
}
|
|
180
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Check if `port` is available
|
|
193
|
+
* @param {number} port
|
|
194
|
+
*/
|
|
181
195
|
function check(port) {
|
|
182
|
-
return weird().then(weird => {
|
|
196
|
+
return weird().then((weird) => {
|
|
183
197
|
if (weird) {
|
|
184
198
|
return check_weird(port);
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
return new Promise(fulfil => {
|
|
188
|
-
const server = createServer();
|
|
201
|
+
return new Promise((fulfil) => {
|
|
202
|
+
const server = net.createServer();
|
|
189
203
|
|
|
190
204
|
server.unref();
|
|
191
205
|
|
|
@@ -193,7 +207,7 @@ function check(port) {
|
|
|
193
207
|
fulfil(false);
|
|
194
208
|
});
|
|
195
209
|
|
|
196
|
-
server.listen({ port }, () => {
|
|
210
|
+
server.listen({ host, port }, () => {
|
|
197
211
|
server.close(() => {
|
|
198
212
|
fulfil(true);
|
|
199
213
|
});
|
|
@@ -202,9 +216,11 @@ function check(port) {
|
|
|
202
216
|
});
|
|
203
217
|
}
|
|
204
218
|
|
|
219
|
+
/** @param {number} port */
|
|
205
220
|
function check_weird(port) {
|
|
206
|
-
return new Promise(fulfil => {
|
|
207
|
-
const client =
|
|
221
|
+
return new Promise((fulfil) => {
|
|
222
|
+
const client = net
|
|
223
|
+
.createConnection({ host, port }, () => {
|
|
208
224
|
client.end();
|
|
209
225
|
fulfil(false);
|
|
210
226
|
})
|
|
@@ -904,7 +920,7 @@ async function launch(port, https, base) {
|
|
|
904
920
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
905
921
|
}
|
|
906
922
|
|
|
907
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
923
|
+
const prog = sade('svelte-kit').version('1.0.0-next.346');
|
|
908
924
|
|
|
909
925
|
prog
|
|
910
926
|
.command('dev')
|
|
@@ -923,28 +939,49 @@ prog
|
|
|
923
939
|
let close;
|
|
924
940
|
|
|
925
941
|
async function start() {
|
|
926
|
-
const
|
|
942
|
+
const svelte_config = await load_config();
|
|
943
|
+
const { plugins } = await import('./chunks/plugin.js');
|
|
944
|
+
const vite_config = await svelte_config.kit.vite();
|
|
945
|
+
|
|
946
|
+
/** @type {import('vite').UserConfig} */
|
|
947
|
+
const config = {
|
|
948
|
+
plugins: [...(vite_config.plugins || []), plugins(svelte_config)]
|
|
949
|
+
};
|
|
950
|
+
config.server = {};
|
|
951
|
+
|
|
952
|
+
// optional config from command-line flags
|
|
953
|
+
// these should take precedence, but not print conflict warnings
|
|
954
|
+
if (host) {
|
|
955
|
+
config.server.host = host;
|
|
956
|
+
}
|
|
927
957
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
https
|
|
932
|
-
}
|
|
958
|
+
// if https is already enabled then do nothing. it could be an object and we
|
|
959
|
+
// don't want to overwrite with a boolean
|
|
960
|
+
if (https && !vite_config?.server?.https) {
|
|
961
|
+
config.server.https = https;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
if (port) {
|
|
965
|
+
config.server.port = port;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
const server = await vite.createServer(config);
|
|
969
|
+
await server.listen(port);
|
|
933
970
|
|
|
934
971
|
const address_info = /** @type {import('net').AddressInfo} */ (
|
|
935
972
|
/** @type {import('http').Server} */ (server.httpServer).address()
|
|
936
973
|
);
|
|
937
974
|
|
|
938
|
-
const
|
|
975
|
+
const resolved_config = server.config;
|
|
939
976
|
|
|
940
977
|
welcome({
|
|
941
978
|
port: address_info.port,
|
|
942
979
|
host: address_info.address,
|
|
943
|
-
https: !!(https ||
|
|
944
|
-
open: first && (open || !!
|
|
945
|
-
base:
|
|
946
|
-
loose:
|
|
947
|
-
allow:
|
|
980
|
+
https: !!(https || resolved_config.server.https),
|
|
981
|
+
open: first && (open || !!resolved_config.server.open),
|
|
982
|
+
base: svelte_config.kit.paths.base,
|
|
983
|
+
loose: resolved_config.server.fs.strict === false,
|
|
984
|
+
allow: resolved_config.server.fs.allow
|
|
948
985
|
});
|
|
949
986
|
|
|
950
987
|
first = false;
|
|
@@ -952,6 +989,7 @@ prog
|
|
|
952
989
|
return server.close;
|
|
953
990
|
}
|
|
954
991
|
|
|
992
|
+
// TODO: we should probably replace this with something like vite-plugin-restart
|
|
955
993
|
async function relaunch() {
|
|
956
994
|
const id = uid;
|
|
957
995
|
relaunching = true;
|
|
@@ -1000,7 +1038,7 @@ prog
|
|
|
1000
1038
|
|
|
1001
1039
|
const log = logger({ verbose });
|
|
1002
1040
|
|
|
1003
|
-
const { build } = await import('./chunks/
|
|
1041
|
+
const { build } = await import('./chunks/index.js');
|
|
1004
1042
|
const { build_data, prerendered } = await build(config, { log });
|
|
1005
1043
|
|
|
1006
1044
|
console.log(
|
|
@@ -1008,7 +1046,7 @@ prog
|
|
|
1008
1046
|
);
|
|
1009
1047
|
|
|
1010
1048
|
if (config.kit.adapter) {
|
|
1011
|
-
const { adapt } = await import('./chunks/
|
|
1049
|
+
const { adapt } = await import('./chunks/index3.js');
|
|
1012
1050
|
await adapt(config, build_data, prerendered, { log });
|
|
1013
1051
|
|
|
1014
1052
|
// this is necessary to close any open db connections, etc
|
|
@@ -1042,7 +1080,7 @@ prog
|
|
|
1042
1080
|
|
|
1043
1081
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
1044
1082
|
|
|
1045
|
-
const { preview } = await import('./chunks/
|
|
1083
|
+
const { preview } = await import('./chunks/index4.js');
|
|
1046
1084
|
|
|
1047
1085
|
const { config } = await preview({ port, host, https });
|
|
1048
1086
|
|
|
@@ -1059,7 +1097,7 @@ prog
|
|
|
1059
1097
|
.action(async ({ watch }) => {
|
|
1060
1098
|
try {
|
|
1061
1099
|
const config = await load_config();
|
|
1062
|
-
const packaging = await import('./chunks/
|
|
1100
|
+
const packaging = await import('./chunks/index5.js');
|
|
1063
1101
|
|
|
1064
1102
|
await (watch ? packaging.watch(config) : packaging.build(config));
|
|
1065
1103
|
} catch (error) {
|
|
@@ -1123,7 +1161,7 @@ async function check_port(port) {
|
|
|
1123
1161
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1124
1162
|
if (open) launch(port, https, base);
|
|
1125
1163
|
|
|
1126
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1164
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.346'}\n`));
|
|
1127
1165
|
|
|
1128
1166
|
const protocol = https ? 'https:' : 'http:';
|
|
1129
1167
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1161,4 +1199,4 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
|
1161
1199
|
console.log('\n');
|
|
1162
1200
|
}
|
|
1163
1201
|
|
|
1164
|
-
export { $,
|
|
1202
|
+
export { $, get_runtime_path as a, get_mime_lookup as b, coalesce_to_error as c, load_config as d, get_aliases as g, load_template as l, print_config_conflicts as p, resolve_entry as r };
|
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.346",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"homepage": "https://kit.svelte.dev",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.
|
|
13
|
+
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.46",
|
|
14
14
|
"chokidar": "^3.5.3",
|
|
15
15
|
"sade": "^1.7.4",
|
|
16
16
|
"vite": "^2.9.9"
|
package/types/private.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export interface AdapterEntry {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export type BodyValidator<T> = {
|
|
30
|
-
[P in keyof T]: T[P] extends { [k: string]:
|
|
31
|
-
? BodyValidator<
|
|
30
|
+
[P in keyof T]: T[P] extends { [k: string]: unknown }
|
|
31
|
+
? BodyValidator<T[P]> // recurse when T[P] is an object
|
|
32
32
|
: T[P] extends BigInt | Function | Symbol
|
|
33
33
|
? never
|
|
34
34
|
: T[P];
|