@sveltejs/kit 1.0.0-next.188 → 1.0.0-next.191
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/runtime/app/navigation.js +1 -3
- package/assets/runtime/internal/start.js +2 -10
- package/dist/chunks/index.js +16 -1
- package/dist/chunks/index2.js +2 -3
- package/dist/chunks/index3.js +4 -10
- package/dist/chunks/index4.js +15 -5
- package/dist/cli.js +17 -5
- package/package.json +2 -2
- package/types/ambient-modules.d.ts +1 -1
- package/types/config.d.ts +21 -4
- package/types/internal.d.ts +6 -6
|
@@ -47,9 +47,7 @@ async function prefetchRoutes_(pathnames) {
|
|
|
47
47
|
? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
|
|
48
48
|
: router.routes;
|
|
49
49
|
|
|
50
|
-
const promises = matching
|
|
51
|
-
.filter(/** @returns {r is import('types/internal').CSRPage} */ (r) => r && r.length > 1)
|
|
52
|
-
.map((r) => Promise.all(r[1].map((load) => load())));
|
|
50
|
+
const promises = matching.map((r) => Promise.all(r[1].map((load) => load())));
|
|
53
51
|
|
|
54
52
|
await Promise.all(promises);
|
|
55
53
|
}
|
|
@@ -749,21 +749,13 @@ class Renderer {
|
|
|
749
749
|
for (let i = 0; i < info.routes.length; i += 1) {
|
|
750
750
|
const route = info.routes[i];
|
|
751
751
|
|
|
752
|
-
// check if endpoint route
|
|
753
|
-
if (route.length === 1) {
|
|
754
|
-
return { reload: true, props: {}, state: this.current };
|
|
755
|
-
}
|
|
756
|
-
|
|
757
752
|
// load code for subsequent routes immediately, if they are as
|
|
758
753
|
// likely to match the current path/query as the current one
|
|
759
754
|
let j = i + 1;
|
|
760
755
|
while (j < info.routes.length) {
|
|
761
756
|
const next = info.routes[j];
|
|
762
757
|
if (next[0].toString() === route[0].toString()) {
|
|
763
|
-
|
|
764
|
-
if (next.length !== 1) {
|
|
765
|
-
next[1].forEach((loader) => loader());
|
|
766
|
-
}
|
|
758
|
+
next[1].forEach((loader) => loader());
|
|
767
759
|
j += 1;
|
|
768
760
|
} else {
|
|
769
761
|
break;
|
|
@@ -1141,7 +1133,7 @@ class Renderer {
|
|
|
1141
1133
|
}
|
|
1142
1134
|
}
|
|
1143
1135
|
|
|
1144
|
-
// @ts-expect-error -
|
|
1136
|
+
// @ts-expect-error - doesn't exist yet. generated by Rollup
|
|
1145
1137
|
|
|
1146
1138
|
/**
|
|
1147
1139
|
* @param {{
|
package/dist/chunks/index.js
CHANGED
|
@@ -4268,6 +4268,20 @@ class Watcher extends EventEmitter {
|
|
|
4268
4268
|
});
|
|
4269
4269
|
}
|
|
4270
4270
|
|
|
4271
|
+
allowed_directories() {
|
|
4272
|
+
return [
|
|
4273
|
+
...new Set([
|
|
4274
|
+
this.config.kit.files.assets,
|
|
4275
|
+
this.config.kit.files.lib,
|
|
4276
|
+
this.config.kit.files.routes,
|
|
4277
|
+
path__default.resolve(this.cwd, 'src'),
|
|
4278
|
+
path__default.resolve(this.cwd, '.svelte-kit'),
|
|
4279
|
+
path__default.resolve(this.cwd, 'node_modules'),
|
|
4280
|
+
path__default.resolve(vite.searchForWorkspaceRoot(this.cwd), 'node_modules')
|
|
4281
|
+
])
|
|
4282
|
+
];
|
|
4283
|
+
}
|
|
4284
|
+
|
|
4271
4285
|
async init_server() {
|
|
4272
4286
|
if (!this.manifest) throw new Error('Must call init() before init_server()');
|
|
4273
4287
|
|
|
@@ -4277,7 +4291,8 @@ class Watcher extends EventEmitter {
|
|
|
4277
4291
|
const default_config = {
|
|
4278
4292
|
server: {
|
|
4279
4293
|
fs: {
|
|
4280
|
-
strict: true
|
|
4294
|
+
strict: true,
|
|
4295
|
+
allow: this.allowed_directories()
|
|
4281
4296
|
},
|
|
4282
4297
|
strictPort: true
|
|
4283
4298
|
}
|
package/dist/chunks/index2.js
CHANGED
|
@@ -171,8 +171,6 @@ function generate_client_manifest(manifest_data, base) {
|
|
|
171
171
|
if (params) tuple.push(params);
|
|
172
172
|
|
|
173
173
|
return `// ${route.a[route.a.length - 1]}\n\t\t[${tuple.join(', ')}]`;
|
|
174
|
-
} else {
|
|
175
|
-
return `// ${route.file}\n\t\t[${route.pattern}]`;
|
|
176
174
|
}
|
|
177
175
|
})
|
|
178
176
|
.join(',\n\n\t\t')}
|
|
@@ -200,7 +198,8 @@ function generate_app(manifest_data) {
|
|
|
200
198
|
const max_depth = Math.max(
|
|
201
199
|
...manifest_data.routes.map((route) =>
|
|
202
200
|
route.type === 'page' ? route.a.filter(Boolean).length : 0
|
|
203
|
-
)
|
|
201
|
+
),
|
|
202
|
+
1
|
|
204
203
|
);
|
|
205
204
|
|
|
206
205
|
const levels = [];
|
package/dist/chunks/index3.js
CHANGED
|
@@ -466,12 +466,6 @@ var glob = sync;
|
|
|
466
466
|
/** @param {any} value */
|
|
467
467
|
const s = (value) => JSON.stringify(value);
|
|
468
468
|
|
|
469
|
-
/** @typedef {Record<string, {
|
|
470
|
-
* file: string;
|
|
471
|
-
* css: string[];
|
|
472
|
-
* imports: string[];
|
|
473
|
-
* }>} ClientManifest */
|
|
474
|
-
|
|
475
469
|
/**
|
|
476
470
|
* @param {import('types/config').ValidatedConfig} config
|
|
477
471
|
* @param {{
|
|
@@ -562,7 +556,6 @@ async function build_client({
|
|
|
562
556
|
process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : '';
|
|
563
557
|
|
|
564
558
|
const client_out_dir = `${output_dir}/client/${config.kit.appDir}`;
|
|
565
|
-
const client_manifest_file = `${client_out_dir}/manifest.json`;
|
|
566
559
|
|
|
567
560
|
/** @type {Record<string, string>} */
|
|
568
561
|
const input = {
|
|
@@ -637,7 +630,8 @@ async function build_client({
|
|
|
637
630
|
|
|
638
631
|
await vite.build(merged_config);
|
|
639
632
|
|
|
640
|
-
|
|
633
|
+
const client_manifest_file = `${client_out_dir}/manifest.json`;
|
|
634
|
+
/** @type {import('vite').Manifest} */
|
|
641
635
|
const client_manifest = JSON.parse(fs__default.readFileSync(client_manifest_file, 'utf-8'));
|
|
642
636
|
fs__default.renameSync(client_manifest_file, `${output_dir}/manifest.json`); // inspectable but not shipped
|
|
643
637
|
|
|
@@ -655,7 +649,7 @@ async function build_client({
|
|
|
655
649
|
* client_entry_file: string;
|
|
656
650
|
* service_worker_entry_file: string | null;
|
|
657
651
|
* }} options
|
|
658
|
-
* @param {
|
|
652
|
+
* @param {import('vite').Manifest} client_manifest
|
|
659
653
|
* @param {string} runtime
|
|
660
654
|
*/
|
|
661
655
|
async function build_server(
|
|
@@ -961,7 +955,7 @@ async function build_server(
|
|
|
961
955
|
* client_entry_file: string;
|
|
962
956
|
* service_worker_entry_file: string | null;
|
|
963
957
|
* }} options
|
|
964
|
-
* @param {
|
|
958
|
+
* @param {import('vite').Manifest} client_manifest
|
|
965
959
|
*/
|
|
966
960
|
async function build_service_worker(
|
|
967
961
|
{ cwd, assets_base, config, manifest, build_dir, output_dir, service_worker_entry_file },
|
package/dist/chunks/index4.js
CHANGED
|
@@ -103,10 +103,11 @@ const REDIRECT = 3;
|
|
|
103
103
|
* fallback?: string;
|
|
104
104
|
* all: boolean; // disregard `export const prerender = true`
|
|
105
105
|
* }} opts
|
|
106
|
+
* @returns {Promise<Array<string>>} returns a promise that resolves to an array of paths corresponding to the files that have been prerendered.
|
|
106
107
|
*/
|
|
107
108
|
async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
108
109
|
if (!config.kit.prerender.enabled && !fallback) {
|
|
109
|
-
return;
|
|
110
|
+
return [];
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
__fetch_polyfill();
|
|
@@ -129,6 +130,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
129
130
|
const error = chooseErrorHandler(log, config.kit.prerender.onError);
|
|
130
131
|
|
|
131
132
|
const files = new Set([...build_data.static, ...build_data.client]);
|
|
133
|
+
const written_files = [];
|
|
132
134
|
|
|
133
135
|
build_data.static.forEach((file) => {
|
|
134
136
|
if (file.endsWith('/index.html')) {
|
|
@@ -199,6 +201,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
199
201
|
if (location) {
|
|
200
202
|
log.warn(`${rendered.status} ${decoded_path} -> ${location}`);
|
|
201
203
|
writeFileSync(file, `<meta http-equiv="refresh" content="0;url=${encodeURI(location)}">`);
|
|
204
|
+
written_files.push(file);
|
|
202
205
|
} else {
|
|
203
206
|
log.warn(`location header missing on redirect received from ${decoded_path}`);
|
|
204
207
|
}
|
|
@@ -209,6 +212,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
209
212
|
if (rendered.status === 200) {
|
|
210
213
|
log.info(`${rendered.status} ${decoded_path}`);
|
|
211
214
|
writeFileSync(file, rendered.body || '');
|
|
215
|
+
written_files.push(file);
|
|
212
216
|
} else if (response_type !== OK) {
|
|
213
217
|
error({ status: rendered.status, path, referrer, referenceType: 'linked' });
|
|
214
218
|
}
|
|
@@ -226,7 +230,10 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
226
230
|
const file = `${out}${parts.join('/')}`;
|
|
227
231
|
mkdirp(dirname(file));
|
|
228
232
|
|
|
229
|
-
if (result.body)
|
|
233
|
+
if (result.body) {
|
|
234
|
+
writeFileSync(file, result.body);
|
|
235
|
+
written_files.push(file);
|
|
236
|
+
}
|
|
230
237
|
|
|
231
238
|
if (response_type === OK) {
|
|
232
239
|
log.info(`${result.status} ${dependency_path}`);
|
|
@@ -318,7 +325,10 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
318
325
|
const file = join(out, fallback);
|
|
319
326
|
mkdirp(dirname(file));
|
|
320
327
|
writeFileSync(file, rendered.body || '');
|
|
328
|
+
written_files.push(file);
|
|
321
329
|
}
|
|
330
|
+
|
|
331
|
+
return written_files;
|
|
322
332
|
}
|
|
323
333
|
|
|
324
334
|
/**
|
|
@@ -338,15 +348,15 @@ function get_utils({ cwd, config, build_data, log }) {
|
|
|
338
348
|
copy,
|
|
339
349
|
|
|
340
350
|
copy_client_files(dest) {
|
|
341
|
-
copy(`${cwd}/${SVELTE_KIT}/output/client`, dest, (file) => file[0] !== '.');
|
|
351
|
+
return copy(`${cwd}/${SVELTE_KIT}/output/client`, dest, (file) => file[0] !== '.');
|
|
342
352
|
},
|
|
343
353
|
|
|
344
354
|
copy_server_files(dest) {
|
|
345
|
-
copy(`${cwd}/${SVELTE_KIT}/output/server`, dest, (file) => file[0] !== '.');
|
|
355
|
+
return copy(`${cwd}/${SVELTE_KIT}/output/server`, dest, (file) => file[0] !== '.');
|
|
346
356
|
},
|
|
347
357
|
|
|
348
358
|
copy_static_files(dest) {
|
|
349
|
-
copy(config.kit.files.assets, dest);
|
|
359
|
+
return copy(config.kit.files.assets, dest);
|
|
350
360
|
},
|
|
351
361
|
|
|
352
362
|
async prerender({ all = false, dest, fallback }) {
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs__default, { existsSync } from 'fs';
|
|
2
2
|
import sade from 'sade';
|
|
3
|
+
import path__default, { relative } from 'path';
|
|
3
4
|
import { exec as exec$1 } from 'child_process';
|
|
4
5
|
import { createConnection, createServer } from 'net';
|
|
5
|
-
import path__default from 'path';
|
|
6
6
|
import * as url from 'url';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { networkInterfaces, release } from 'os';
|
|
@@ -817,7 +817,7 @@ async function launch(port, https) {
|
|
|
817
817
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
820
|
+
const prog = sade('svelte-kit').version('1.0.0-next.191');
|
|
821
821
|
|
|
822
822
|
prog
|
|
823
823
|
.command('dev')
|
|
@@ -854,7 +854,14 @@ prog
|
|
|
854
854
|
https = https || !!config.kit.vite().server?.https;
|
|
855
855
|
open = open || !!config.kit.vite().server?.open;
|
|
856
856
|
|
|
857
|
-
welcome({
|
|
857
|
+
welcome({
|
|
858
|
+
port: address_info.port,
|
|
859
|
+
host: address_info.address,
|
|
860
|
+
https,
|
|
861
|
+
open,
|
|
862
|
+
allow: watcher.allowed_directories(),
|
|
863
|
+
cwd: watcher.cwd
|
|
864
|
+
});
|
|
858
865
|
} catch (error) {
|
|
859
866
|
handle_error(error);
|
|
860
867
|
}
|
|
@@ -964,12 +971,14 @@ async function check_port(port) {
|
|
|
964
971
|
* host: string;
|
|
965
972
|
* https: boolean;
|
|
966
973
|
* port: number;
|
|
974
|
+
* allow?: string[];
|
|
975
|
+
* cwd?: string;
|
|
967
976
|
* }} param0
|
|
968
977
|
*/
|
|
969
|
-
function welcome({ port, host, https, open }) {
|
|
978
|
+
function welcome({ port, host, https, open, allow, cwd }) {
|
|
970
979
|
if (open) launch(port, https);
|
|
971
980
|
|
|
972
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
981
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.191'}\n`));
|
|
973
982
|
|
|
974
983
|
const protocol = https ? 'https:' : 'http:';
|
|
975
984
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -987,6 +996,9 @@ function welcome({ port, host, https, open }) {
|
|
|
987
996
|
|
|
988
997
|
if (exposed) {
|
|
989
998
|
console.log(` ${$.gray('network:')} ${protocol}//${$.bold(`${details.address}:${port}`)}`);
|
|
999
|
+
if (allow?.length && cwd) {
|
|
1000
|
+
console.log(`\n ${$.yellow('Note that all files in the following directories will be accessible to anyone on your network: ' + allow.map(a => relative(cwd, a)).join(', '))}`);
|
|
1001
|
+
}
|
|
990
1002
|
} else {
|
|
991
1003
|
console.log(` ${$.gray('network: not exposed')}`);
|
|
992
1004
|
}
|
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.191",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
|
|
13
13
|
"cheap-watch": "^1.0.4",
|
|
14
14
|
"sade": "^1.7.4",
|
|
15
|
-
"vite": "^2.6.
|
|
15
|
+
"vite": "^2.6.12"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -161,7 +161,7 @@ declare module '@sveltejs/kit/ssr' {
|
|
|
161
161
|
type State = import('@sveltejs/kit/types/internal').SSRRenderState;
|
|
162
162
|
|
|
163
163
|
export interface Respond {
|
|
164
|
-
(incoming: IncomingRequest, options: Options, state?: State): Response
|
|
164
|
+
(incoming: IncomingRequest, options: Options, state?: State): Promise<Response>;
|
|
165
165
|
}
|
|
166
166
|
export const respond: Respond;
|
|
167
167
|
}
|
package/types/config.d.ts
CHANGED
|
@@ -6,10 +6,27 @@ export interface AdapterUtils {
|
|
|
6
6
|
log: Logger;
|
|
7
7
|
rimraf(dir: string): void;
|
|
8
8
|
mkdirp(dir: string): void;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param dest the destination folder to which files should be copied
|
|
11
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
12
|
+
*/
|
|
13
|
+
copy_client_files(dest: string): string[];
|
|
14
|
+
/**
|
|
15
|
+
* @param dest the destination folder to which files should be copied
|
|
16
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
17
|
+
*/
|
|
18
|
+
copy_server_files(dest: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* @param dest the destination folder to which files should be copied
|
|
21
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
22
|
+
*/
|
|
23
|
+
copy_static_files(dest: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* @param from the source folder from which files should be copied
|
|
26
|
+
* @param to the destination folder to which files should be copied
|
|
27
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
28
|
+
*/
|
|
29
|
+
copy(from: string, to: string, filter?: (basename: string) => boolean): string[];
|
|
13
30
|
prerender(options: { all?: boolean; dest: string; fallback?: string }): Promise<void>;
|
|
14
31
|
}
|
|
15
32
|
|
package/types/internal.d.ts
CHANGED
|
@@ -103,11 +103,7 @@ export interface SSREndpoint {
|
|
|
103
103
|
|
|
104
104
|
export type SSRRoute = SSREndpoint | SSRPage;
|
|
105
105
|
|
|
106
|
-
export type
|
|
107
|
-
|
|
108
|
-
export type CSREndpoint = [RegExp];
|
|
109
|
-
|
|
110
|
-
export type CSRRoute = CSREndpoint | CSRPage;
|
|
106
|
+
export type CSRRoute = [RegExp, CSRComponentLoader[], CSRComponentLoader[], GetParams?];
|
|
111
107
|
|
|
112
108
|
export interface SSRManifest {
|
|
113
109
|
assets: Asset[];
|
|
@@ -125,9 +121,13 @@ export interface Hooks {
|
|
|
125
121
|
|
|
126
122
|
export interface SSRNode {
|
|
127
123
|
module: SSRComponent;
|
|
128
|
-
|
|
124
|
+
/** client-side module URL for this component */
|
|
125
|
+
entry: string;
|
|
126
|
+
/** external CSS files */
|
|
129
127
|
css: string[];
|
|
128
|
+
/** external JS files */
|
|
130
129
|
js: string[];
|
|
130
|
+
/** inlined styles */
|
|
131
131
|
styles: string[];
|
|
132
132
|
}
|
|
133
133
|
|