@sveltejs/kit 1.0.0-next.335 → 1.0.0-next.338
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/app/env.js +1 -5
- package/assets/client/start.js +53 -4
- package/assets/server/index.js +50 -69
- package/dist/chunks/filesystem.js +1 -1
- package/dist/chunks/index.js +35 -31
- package/dist/chunks/index2.js +11 -14
- package/dist/chunks/index4.js +1 -0
- package/dist/chunks/index6.js +1 -1
- package/dist/chunks/sync.js +8 -2
- package/dist/chunks/write_tsconfig.js +13 -11
- package/dist/cli.js +58 -10
- package/package.json +4 -5
- package/types/ambient.d.ts +1 -5
- package/types/index.d.ts +15 -3
- package/types/internal.d.ts +2 -3
- package/types/private.d.ts +0 -15
- package/dist/chunks/amp_hook.js +0 -56
- package/dist/chunks/index7.js +0 -4207
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs__default from 'fs';
|
|
|
3
3
|
import path__default, { join, relative } from 'path';
|
|
4
4
|
import { exec as exec$1 } from 'child_process';
|
|
5
5
|
import { createConnection, createServer } from 'net';
|
|
6
|
+
import chokidar from 'chokidar';
|
|
6
7
|
import * as url from 'url';
|
|
7
8
|
import { networkInterfaces, release } from 'os';
|
|
8
9
|
|
|
@@ -337,7 +338,11 @@ const options = object(
|
|
|
337
338
|
return input;
|
|
338
339
|
}),
|
|
339
340
|
|
|
340
|
-
|
|
341
|
+
// TODO: remove this for the 1.0 release
|
|
342
|
+
amp: error(
|
|
343
|
+
(keypath) =>
|
|
344
|
+
`${keypath} has been removed. See https://kit.svelte.dev/docs/seo#amp for details on how to support AMP`
|
|
345
|
+
),
|
|
341
346
|
|
|
342
347
|
appDir: validate('_app', (input, keypath) => {
|
|
343
348
|
assert_string(input, keypath);
|
|
@@ -782,7 +787,7 @@ async function load_config({ cwd = process.cwd() } = {}) {
|
|
|
782
787
|
);
|
|
783
788
|
}
|
|
784
789
|
|
|
785
|
-
const config = await import(url.pathToFileURL(config_file).href);
|
|
790
|
+
const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);
|
|
786
791
|
|
|
787
792
|
const validated = validate_config(config.default);
|
|
788
793
|
|
|
@@ -870,7 +875,7 @@ async function launch(port, https, base) {
|
|
|
870
875
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
871
876
|
}
|
|
872
877
|
|
|
873
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
878
|
+
const prog = sade('svelte-kit').version('1.0.0-next.338');
|
|
874
879
|
|
|
875
880
|
prog
|
|
876
881
|
.command('dev')
|
|
@@ -881,17 +886,20 @@ prog
|
|
|
881
886
|
.option('--https', 'Use self-signed HTTPS certificate')
|
|
882
887
|
.option('-H', 'no longer supported, use --https instead') // TODO remove for 1.0
|
|
883
888
|
.action(async ({ port, host, https, open, H }) => {
|
|
884
|
-
|
|
885
|
-
|
|
889
|
+
let first = true;
|
|
890
|
+
let relaunching = false;
|
|
891
|
+
let uid = 1;
|
|
886
892
|
|
|
887
|
-
|
|
888
|
-
|
|
893
|
+
/** @type {() => Promise<void>} */
|
|
894
|
+
let close;
|
|
889
895
|
|
|
896
|
+
/** @param {import('types').ValidatedConfig} config */
|
|
897
|
+
async function start(config) {
|
|
890
898
|
const { dev } = await import('./chunks/index.js');
|
|
891
899
|
|
|
892
900
|
const cwd = process.cwd();
|
|
893
901
|
|
|
894
|
-
const { address_info, server_config } = await dev({
|
|
902
|
+
const { address_info, server_config, close } = await dev({
|
|
895
903
|
cwd,
|
|
896
904
|
port,
|
|
897
905
|
host,
|
|
@@ -903,12 +911,52 @@ prog
|
|
|
903
911
|
port: address_info.port,
|
|
904
912
|
host: address_info.address,
|
|
905
913
|
https: !!(https || server_config.https),
|
|
906
|
-
open: open || !!server_config.open,
|
|
914
|
+
open: first && (open || !!server_config.open),
|
|
907
915
|
base: config.kit.paths.base,
|
|
908
916
|
loose: server_config.fs.strict === false,
|
|
909
917
|
allow: server_config.fs.allow,
|
|
910
918
|
cwd
|
|
911
919
|
});
|
|
920
|
+
|
|
921
|
+
first = false;
|
|
922
|
+
|
|
923
|
+
return close;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
async function relaunch() {
|
|
927
|
+
const id = uid;
|
|
928
|
+
relaunching = true;
|
|
929
|
+
|
|
930
|
+
try {
|
|
931
|
+
const updated_config = await load_config();
|
|
932
|
+
await close();
|
|
933
|
+
close = await start(updated_config);
|
|
934
|
+
|
|
935
|
+
if (id !== uid) relaunch();
|
|
936
|
+
} catch (e) {
|
|
937
|
+
const error = /** @type {Error} */ (e);
|
|
938
|
+
|
|
939
|
+
console.error($.bold().red(`> ${error.message}`));
|
|
940
|
+
if (error.stack) {
|
|
941
|
+
console.error($.gray(error.stack.split('\n').slice(1).join('\n')));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
relaunching = false;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
try {
|
|
949
|
+
if (H) throw new Error('-H is no longer supported — use --https instead');
|
|
950
|
+
|
|
951
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
952
|
+
|
|
953
|
+
const config = await load_config();
|
|
954
|
+
close = await start(config);
|
|
955
|
+
|
|
956
|
+
chokidar.watch('svelte.config.js', { ignoreInitial: true }).on('change', () => {
|
|
957
|
+
if (relaunching) uid += 1;
|
|
958
|
+
else relaunch();
|
|
959
|
+
});
|
|
912
960
|
} catch (error) {
|
|
913
961
|
handle_error(error);
|
|
914
962
|
}
|
|
@@ -1049,7 +1097,7 @@ async function check_port(port) {
|
|
|
1049
1097
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1050
1098
|
if (open) launch(port, https, base);
|
|
1051
1099
|
|
|
1052
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1100
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.338'}\n`));
|
|
1053
1101
|
|
|
1054
1102
|
const protocol = https ? 'https:' : 'http:';
|
|
1055
1103
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
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.338",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -10,15 +10,14 @@
|
|
|
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.44",
|
|
14
14
|
"chokidar": "^3.5.3",
|
|
15
15
|
"sade": "^1.7.4",
|
|
16
|
-
"vite": "^2.9.
|
|
16
|
+
"vite": "^2.9.9"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@playwright/test": "^1.21.0",
|
|
20
20
|
"@rollup/plugin-replace": "^4.0.0",
|
|
21
|
-
"@types/amphtml-validator": "^1.0.1",
|
|
22
21
|
"@types/connect": "^3.4.35",
|
|
23
22
|
"@types/cookie": "^0.5.0",
|
|
24
23
|
"@types/marked": "^4.0.1",
|
|
@@ -26,7 +25,6 @@
|
|
|
26
25
|
"@types/node": "^16.11.11",
|
|
27
26
|
"@types/sade": "^1.7.3",
|
|
28
27
|
"@types/set-cookie-parser": "^2.4.2",
|
|
29
|
-
"amphtml-validator": "^1.0.35",
|
|
30
28
|
"cookie": "^0.5.0",
|
|
31
29
|
"cross-env": "^7.0.3",
|
|
32
30
|
"devalue": "^2.0.1",
|
|
@@ -46,6 +44,7 @@
|
|
|
46
44
|
"svelte-preprocess": "^4.9.8",
|
|
47
45
|
"svelte2tsx": "~0.5.0",
|
|
48
46
|
"tiny-glob": "^0.2.9",
|
|
47
|
+
"typescript": "^4.6.4",
|
|
49
48
|
"uvu": "^0.5.2"
|
|
50
49
|
},
|
|
51
50
|
"peerDependencies": {
|
package/types/ambient.d.ts
CHANGED
|
@@ -49,14 +49,10 @@ declare namespace App {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* ```ts
|
|
52
|
-
* import {
|
|
52
|
+
* import { browser, dev, mode, prerendering } from '$app/env';
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
declare module '$app/env' {
|
|
56
|
-
/**
|
|
57
|
-
* Whether or not the app is running in [AMP mode](/docs/seo#manual-setup-amp).
|
|
58
|
-
*/
|
|
59
|
-
export const amp: boolean;
|
|
60
56
|
/**
|
|
61
57
|
* Whether the app is running in the browser or on the server.
|
|
62
58
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -13,9 +13,7 @@ import {
|
|
|
13
13
|
MaybePromise,
|
|
14
14
|
Prerendered,
|
|
15
15
|
PrerenderOnErrorValue,
|
|
16
|
-
RequestEvent,
|
|
17
16
|
RequestOptions,
|
|
18
|
-
ResolveOptions,
|
|
19
17
|
ResponseHeaders,
|
|
20
18
|
RouteDefinition,
|
|
21
19
|
TrailingSlash
|
|
@@ -95,7 +93,6 @@ export interface Config {
|
|
|
95
93
|
extensions?: string[];
|
|
96
94
|
kit?: {
|
|
97
95
|
adapter?: Adapter;
|
|
98
|
-
amp?: boolean;
|
|
99
96
|
appDir?: string;
|
|
100
97
|
browser?: {
|
|
101
98
|
hydrate?: boolean;
|
|
@@ -235,6 +232,16 @@ export interface ParamMatcher {
|
|
|
235
232
|
(param: string): boolean;
|
|
236
233
|
}
|
|
237
234
|
|
|
235
|
+
export interface RequestEvent<Params extends Record<string, string> = Record<string, string>> {
|
|
236
|
+
clientAddress: string;
|
|
237
|
+
locals: App.Locals;
|
|
238
|
+
params: Params;
|
|
239
|
+
platform: Readonly<App.Platform>;
|
|
240
|
+
request: Request;
|
|
241
|
+
routeId: string | null;
|
|
242
|
+
url: URL;
|
|
243
|
+
}
|
|
244
|
+
|
|
238
245
|
/**
|
|
239
246
|
* A `(event: RequestEvent) => RequestHandlerOutput` function exported from an endpoint that corresponds to an HTTP verb (`get`, `put`, `patch`, etc) and handles requests with that method. Note that since 'delete' is a reserved word in JavaScript, delete handles are called `del` instead.
|
|
240
247
|
*
|
|
@@ -253,6 +260,11 @@ export interface RequestHandlerOutput<Output = ResponseBody> {
|
|
|
253
260
|
body?: Output extends ResponseBody ? Output : BodyValidator<Output>;
|
|
254
261
|
}
|
|
255
262
|
|
|
263
|
+
export interface ResolveOptions {
|
|
264
|
+
ssr?: boolean;
|
|
265
|
+
transformPage?: ({ html }: { html: string }) => MaybePromise<string>;
|
|
266
|
+
}
|
|
267
|
+
|
|
256
268
|
export type ResponseBody = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
|
|
257
269
|
|
|
258
270
|
export class Server {
|
package/types/internal.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
Handle,
|
|
7
7
|
HandleError,
|
|
8
8
|
Load,
|
|
9
|
+
RequestEvent,
|
|
9
10
|
RequestHandler,
|
|
11
|
+
ResolveOptions,
|
|
10
12
|
Server,
|
|
11
13
|
SSRManifest
|
|
12
14
|
} from './index';
|
|
@@ -14,9 +16,7 @@ import {
|
|
|
14
16
|
HttpMethod,
|
|
15
17
|
JSONObject,
|
|
16
18
|
MaybePromise,
|
|
17
|
-
RequestEvent,
|
|
18
19
|
RequestOptions,
|
|
19
|
-
ResolveOptions,
|
|
20
20
|
ResponseHeaders,
|
|
21
21
|
TrailingSlash
|
|
22
22
|
} from './private';
|
|
@@ -240,7 +240,6 @@ export interface SSRNode {
|
|
|
240
240
|
export type SSRNodeLoader = () => Promise<SSRNode>;
|
|
241
241
|
|
|
242
242
|
export interface SSROptions {
|
|
243
|
-
amp: boolean;
|
|
244
243
|
csp: ValidatedConfig['kit']['csp'];
|
|
245
244
|
dev: boolean;
|
|
246
245
|
floc: boolean;
|
package/types/private.d.ts
CHANGED
|
@@ -206,26 +206,11 @@ export interface PrerenderErrorHandler {
|
|
|
206
206
|
|
|
207
207
|
export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
|
|
208
208
|
|
|
209
|
-
export interface RequestEvent<Params extends Record<string, string> = Record<string, string>> {
|
|
210
|
-
clientAddress: string;
|
|
211
|
-
locals: App.Locals;
|
|
212
|
-
params: Params;
|
|
213
|
-
platform: Readonly<App.Platform>;
|
|
214
|
-
request: Request;
|
|
215
|
-
routeId: string | null;
|
|
216
|
-
url: URL;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
209
|
export interface RequestOptions {
|
|
220
210
|
getClientAddress: () => string;
|
|
221
211
|
platform?: App.Platform;
|
|
222
212
|
}
|
|
223
213
|
|
|
224
|
-
export interface ResolveOptions {
|
|
225
|
-
ssr?: boolean;
|
|
226
|
-
transformPage?: ({ html }: { html: string }) => MaybePromise<string>;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
214
|
/** `string[]` is only for set-cookie, everything else must be type of `string` */
|
|
230
215
|
export type ResponseHeaders = Record<string, string | number | string[]>;
|
|
231
216
|
|
package/dist/chunks/amp_hook.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** @type {import('amphtml-validator').Validator} */
|
|
2
|
-
const amp = await (await import('./index7.js').then(function (n) { return n.i; })).getInstance();
|
|
3
|
-
|
|
4
|
-
/** @type {import('types').Handle} */
|
|
5
|
-
async function handle({ event, resolve }) {
|
|
6
|
-
const response = await resolve(event);
|
|
7
|
-
if (response.headers.get('content-type') !== 'text/html') {
|
|
8
|
-
return response;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let rendered = await response.text();
|
|
12
|
-
const result = amp.validateString(rendered);
|
|
13
|
-
|
|
14
|
-
if (result.status !== 'PASS') {
|
|
15
|
-
const lines = rendered.split('\n');
|
|
16
|
-
|
|
17
|
-
/** @param {string} str */
|
|
18
|
-
const escape = (str) => str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
19
|
-
|
|
20
|
-
rendered = `<!doctype html>
|
|
21
|
-
<head>
|
|
22
|
-
<meta charset="utf-8" />
|
|
23
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
24
|
-
<style>
|
|
25
|
-
body {
|
|
26
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
27
|
-
color: #333;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
pre {
|
|
31
|
-
background: #f4f4f4;
|
|
32
|
-
padding: 1em;
|
|
33
|
-
overflow-x: auto;
|
|
34
|
-
}
|
|
35
|
-
</style>
|
|
36
|
-
</head>
|
|
37
|
-
<h1>AMP validation failed</h1>
|
|
38
|
-
|
|
39
|
-
${result.errors
|
|
40
|
-
.map(
|
|
41
|
-
(error) => `
|
|
42
|
-
<h2>${error.severity}</h2>
|
|
43
|
-
<p>Line ${error.line}, column ${error.col}: ${error.message} (<a href="${error.specUrl}">${
|
|
44
|
-
error.code
|
|
45
|
-
}</a>)</p>
|
|
46
|
-
<pre>${escape(lines[error.line - 1])}</pre>
|
|
47
|
-
`
|
|
48
|
-
)
|
|
49
|
-
.join('\n\n')}
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return new Response(rendered, { status: response.status, headers: response.headers });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { handle };
|