@sveltejs/kit 1.0.0-next.248 → 1.0.0-next.251
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 +1 -1
- package/dist/chunks/index.js +4 -4
- package/dist/chunks/index2.js +6 -7
- package/dist/chunks/index3.js +5 -4
- package/dist/chunks/index4.js +6 -1
- package/dist/chunks/index5.js +21 -12
- package/dist/cli.js +40 -37
- package/package.json +1 -1
- package/types/config.d.ts +6 -2
- package/types/internal.d.ts +1 -0
package/assets/server/index.js
CHANGED
|
@@ -175,7 +175,7 @@ function is_pojo(body) {
|
|
|
175
175
|
if (body._readableState && body._writableState && body._events) return false;
|
|
176
176
|
|
|
177
177
|
// similarly, it could be a web ReadableStream
|
|
178
|
-
if (body
|
|
178
|
+
if (typeof ReadableStream !== 'undefined' && body instanceof ReadableStream) return false;
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
return true;
|
package/dist/chunks/index.js
CHANGED
|
@@ -201,7 +201,7 @@ function is_pojo(body) {
|
|
|
201
201
|
if (body._readableState && body._writableState && body._events) return false;
|
|
202
202
|
|
|
203
203
|
// similarly, it could be a web ReadableStream
|
|
204
|
-
if (body
|
|
204
|
+
if (typeof ReadableStream !== 'undefined' && body instanceof ReadableStream) return false;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
return true;
|
|
@@ -2488,7 +2488,7 @@ async function create_plugin(config, cwd) {
|
|
|
2488
2488
|
});
|
|
2489
2489
|
},
|
|
2490
2490
|
hooks,
|
|
2491
|
-
hydrate: config.kit.hydrate,
|
|
2491
|
+
hydrate: config.kit.browser.hydrate,
|
|
2492
2492
|
manifest,
|
|
2493
2493
|
method_override: config.kit.methodOverride,
|
|
2494
2494
|
paths: {
|
|
@@ -2499,7 +2499,7 @@ async function create_plugin(config, cwd) {
|
|
|
2499
2499
|
prerender: config.kit.prerender.enabled,
|
|
2500
2500
|
read: (file) => fs__default.readFileSync(path__default.join(config.kit.files.assets, file)),
|
|
2501
2501
|
root,
|
|
2502
|
-
router: config.kit.router,
|
|
2502
|
+
router: config.kit.browser.router,
|
|
2503
2503
|
target: config.kit.target,
|
|
2504
2504
|
template: ({ head, body, assets, nonce }) => {
|
|
2505
2505
|
return (
|
|
@@ -2647,7 +2647,7 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
2647
2647
|
extensions: config.extensions,
|
|
2648
2648
|
emitCss: !config.kit.amp,
|
|
2649
2649
|
compilerOptions: {
|
|
2650
|
-
hydratable: !!config.kit.hydrate
|
|
2650
|
+
hydratable: !!config.kit.browser.hydrate
|
|
2651
2651
|
}
|
|
2652
2652
|
}),
|
|
2653
2653
|
await create_plugin(config, cwd)
|
package/dist/chunks/index2.js
CHANGED
|
@@ -455,17 +455,16 @@ function create_manifest_data({
|
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
457
|
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
throw new Error(`Files and directories prefixed with __ are reserved (saw ${file})`);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
return;
|
|
458
|
+
if (basename.startsWith('__') && !specials.has(name)) {
|
|
459
|
+
throw new Error(`Files and directories prefixed with __ are reserved (saw ${file})`);
|
|
464
460
|
}
|
|
465
461
|
|
|
466
|
-
if (basename[0] === '.' && basename !== '.well-known') return null;
|
|
467
462
|
if (!is_dir && !/^(\.[a-z0-9]+)+$/i.test(ext)) return null; // filter out tmp files etc
|
|
468
463
|
|
|
464
|
+
if (!config.kit.routes(file)) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
|
|
469
468
|
const segment = is_dir ? basename : name;
|
|
470
469
|
|
|
471
470
|
if (/\]\[/.test(segment)) {
|
package/dist/chunks/index3.js
CHANGED
|
@@ -209,7 +209,7 @@ async function build_client({
|
|
|
209
209
|
extensions: config.extensions,
|
|
210
210
|
emitCss: !config.kit.amp,
|
|
211
211
|
compilerOptions: {
|
|
212
|
-
hydratable: !!config.kit.hydrate
|
|
212
|
+
hydratable: !!config.kit.browser.hydrate
|
|
213
213
|
}
|
|
214
214
|
})
|
|
215
215
|
]
|
|
@@ -309,7 +309,7 @@ export class App {
|
|
|
309
309
|
error.stack = this.options.get_stack(error);
|
|
310
310
|
},
|
|
311
311
|
hooks,
|
|
312
|
-
hydrate: ${s(config.kit.hydrate)},
|
|
312
|
+
hydrate: ${s(config.kit.browser.hydrate)},
|
|
313
313
|
manifest,
|
|
314
314
|
method_override: ${s(config.kit.methodOverride)},
|
|
315
315
|
paths: { base, assets },
|
|
@@ -318,7 +318,7 @@ export class App {
|
|
|
318
318
|
read,
|
|
319
319
|
root,
|
|
320
320
|
service_worker: ${has_service_worker ? "base + '/service-worker.js'" : 'null'},
|
|
321
|
-
router: ${s(config.kit.router)},
|
|
321
|
+
router: ${s(config.kit.browser.router)},
|
|
322
322
|
target: ${s(config.kit.target)},
|
|
323
323
|
template,
|
|
324
324
|
template_contains_nonce: ${template.includes('%svelte.nonce%')},
|
|
@@ -447,7 +447,7 @@ async function build_server(
|
|
|
447
447
|
svelte({
|
|
448
448
|
extensions: config.extensions,
|
|
449
449
|
compilerOptions: {
|
|
450
|
-
hydratable: !!config.kit.hydrate
|
|
450
|
+
hydratable: !!config.kit.browser.hydrate
|
|
451
451
|
}
|
|
452
452
|
})
|
|
453
453
|
],
|
|
@@ -626,6 +626,7 @@ async function build(config) {
|
|
|
626
626
|
const build_data = {
|
|
627
627
|
app_dir: config.kit.appDir,
|
|
628
628
|
manifest_data: options.manifest_data,
|
|
629
|
+
service_worker: options.service_worker_entry_file ? 'service_worker.js' : null, // TODO make file configurable?
|
|
629
630
|
client,
|
|
630
631
|
server,
|
|
631
632
|
static: options.manifest_data.assets.map((asset) => posixify(asset.file)),
|
package/dist/chunks/index4.js
CHANGED
|
@@ -47,10 +47,15 @@ function generate_manifest(
|
|
|
47
47
|
? (path) => `() => import('${path}')`
|
|
48
48
|
: (path) => `() => Promise.resolve().then(() => require('${path}'))`;
|
|
49
49
|
|
|
50
|
+
const assets = build_data.manifest_data.assets.map((asset) => asset.file);
|
|
51
|
+
if (build_data.service_worker) {
|
|
52
|
+
assets.push(build_data.service_worker);
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
// prettier-ignore
|
|
51
56
|
return `{
|
|
52
57
|
appDir: ${s(build_data.app_dir)},
|
|
53
|
-
assets: new Set(${s(
|
|
58
|
+
assets: new Set(${s(assets)}),
|
|
54
59
|
_: {
|
|
55
60
|
mime: ${s(get_mime_lookup(build_data.manifest_data))},
|
|
56
61
|
entry: ${s(build_data.client.entry)},
|
package/dist/chunks/index5.js
CHANGED
|
@@ -393,6 +393,25 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
393
393
|
|
|
394
394
|
const q = queue(config.kit.prerender.concurrency);
|
|
395
395
|
|
|
396
|
+
/**
|
|
397
|
+
* @param {string} path
|
|
398
|
+
* @param {boolean} is_html
|
|
399
|
+
*/
|
|
400
|
+
function output_filename(path, is_html) {
|
|
401
|
+
if (path === '/') {
|
|
402
|
+
return '/index.html';
|
|
403
|
+
}
|
|
404
|
+
const parts = path.split('/');
|
|
405
|
+
if (is_html && parts[parts.length - 1] !== 'index.html') {
|
|
406
|
+
if (config.kit.prerender.createIndexFiles) {
|
|
407
|
+
parts.push('index.html');
|
|
408
|
+
} else {
|
|
409
|
+
parts[parts.length - 1] += '.html';
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return parts.join('/');
|
|
413
|
+
}
|
|
414
|
+
|
|
396
415
|
/**
|
|
397
416
|
* @param {string} decoded_path
|
|
398
417
|
* @param {string?} referrer
|
|
@@ -431,12 +450,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
431
450
|
const type = rendered.headers.get('content-type');
|
|
432
451
|
const is_html = response_type === REDIRECT || type === 'text/html';
|
|
433
452
|
|
|
434
|
-
const
|
|
435
|
-
if (is_html && parts[parts.length - 1] !== 'index.html') {
|
|
436
|
-
parts.push('index.html');
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const file = `${out}${parts.join('/')}`;
|
|
453
|
+
const file = `${out}${output_filename(decoded_path, is_html)}`;
|
|
440
454
|
|
|
441
455
|
if (response_type === REDIRECT) {
|
|
442
456
|
const location = rendered.headers.get('location');
|
|
@@ -481,12 +495,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
481
495
|
|
|
482
496
|
const is_html = headers.get('content-type') === 'text/html';
|
|
483
497
|
|
|
484
|
-
const
|
|
485
|
-
if (is_html && parts[parts.length - 1] !== 'index.html') {
|
|
486
|
-
parts.push('index.html');
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const file = `${out}${parts.join('/')}`;
|
|
498
|
+
const file = `${out}${output_filename(dependency_path, is_html)}`;
|
|
490
499
|
mkdirp(dirname(file));
|
|
491
500
|
|
|
492
501
|
writeFileSync(
|
package/dist/cli.js
CHANGED
|
@@ -490,6 +490,11 @@ const options = object(
|
|
|
490
490
|
return input;
|
|
491
491
|
}),
|
|
492
492
|
|
|
493
|
+
browser: object({
|
|
494
|
+
hydrate: boolean(true),
|
|
495
|
+
router: boolean(true)
|
|
496
|
+
}),
|
|
497
|
+
|
|
493
498
|
csp: object({
|
|
494
499
|
mode: list(['auto', 'hash', 'nonce']),
|
|
495
500
|
directives: object({
|
|
@@ -539,24 +544,19 @@ const options = object(
|
|
|
539
544
|
floc: boolean(false),
|
|
540
545
|
|
|
541
546
|
// TODO: remove this for the 1.0 release
|
|
542
|
-
headers:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
}),
|
|
547
|
+
headers: error(
|
|
548
|
+
(keypath) =>
|
|
549
|
+
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
550
|
+
),
|
|
549
551
|
|
|
550
552
|
// TODO: remove this for the 1.0 release
|
|
551
|
-
host:
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
}),
|
|
553
|
+
host: error(
|
|
554
|
+
(keypath) =>
|
|
555
|
+
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
556
|
+
),
|
|
558
557
|
|
|
559
|
-
|
|
558
|
+
// TODO remove for 1.0
|
|
559
|
+
hydrate: error((keypath) => `${keypath} has been moved to config.kit.browser.hydrate`),
|
|
560
560
|
|
|
561
561
|
inlineStyleThreshold: number(0),
|
|
562
562
|
|
|
@@ -619,6 +619,7 @@ const options = object(
|
|
|
619
619
|
prerender: object({
|
|
620
620
|
concurrency: number(1),
|
|
621
621
|
crawl: boolean(true),
|
|
622
|
+
createIndexFiles: boolean(true),
|
|
622
623
|
enabled: boolean(true),
|
|
623
624
|
entries: validate(['*'], (input, keypath) => {
|
|
624
625
|
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
|
|
@@ -658,23 +659,19 @@ const options = object(
|
|
|
658
659
|
}),
|
|
659
660
|
|
|
660
661
|
// TODO: remove this for the 1.0 release
|
|
661
|
-
pages:
|
|
662
|
-
if (typeof input !== undefined) {
|
|
663
|
-
throw new Error(`${keypath} has been renamed to \`entries\`.`);
|
|
664
|
-
}
|
|
665
|
-
})
|
|
662
|
+
pages: error((keypath) => `${keypath} has been renamed to \`entries\`.`)
|
|
666
663
|
}),
|
|
667
664
|
|
|
668
665
|
// TODO: remove this for the 1.0 release
|
|
669
|
-
protocol:
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
}),
|
|
666
|
+
protocol: error(
|
|
667
|
+
(keypath) =>
|
|
668
|
+
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
669
|
+
),
|
|
676
670
|
|
|
677
|
-
|
|
671
|
+
// TODO remove for 1.0
|
|
672
|
+
router: error((keypath) => `${keypath} has been moved to config.kit.browser.router`),
|
|
673
|
+
|
|
674
|
+
routes: fun((filepath) => !/(?:(?:^_|\/_)|(?:^\.|\/\.)(?!well-known))/.test(filepath)),
|
|
678
675
|
|
|
679
676
|
serviceWorker: object({
|
|
680
677
|
register: boolean(true),
|
|
@@ -682,13 +679,10 @@ const options = object(
|
|
|
682
679
|
}),
|
|
683
680
|
|
|
684
681
|
// TODO remove this for 1.0
|
|
685
|
-
ssr:
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
);
|
|
690
|
-
}
|
|
691
|
-
}),
|
|
682
|
+
ssr: error(
|
|
683
|
+
(keypath) =>
|
|
684
|
+
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs#hooks-handle'`
|
|
685
|
+
),
|
|
692
686
|
|
|
693
687
|
target: string(null),
|
|
694
688
|
|
|
@@ -867,6 +861,15 @@ function assert_string(input, keypath) {
|
|
|
867
861
|
}
|
|
868
862
|
}
|
|
869
863
|
|
|
864
|
+
/** @param {(keypath?: string) => string} fn */
|
|
865
|
+
function error(fn) {
|
|
866
|
+
return validate(undefined, (input, keypath) => {
|
|
867
|
+
if (input !== undefined) {
|
|
868
|
+
throw new Error(fn(keypath));
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
|
|
870
873
|
/**
|
|
871
874
|
* @param {string} cwd
|
|
872
875
|
* @param {import('types/config').ValidatedConfig} config
|
|
@@ -986,7 +989,7 @@ async function launch(port, https) {
|
|
|
986
989
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
987
990
|
}
|
|
988
991
|
|
|
989
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
992
|
+
const prog = sade('svelte-kit').version('1.0.0-next.251');
|
|
990
993
|
|
|
991
994
|
prog
|
|
992
995
|
.command('dev')
|
|
@@ -1144,7 +1147,7 @@ async function check_port(port) {
|
|
|
1144
1147
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1145
1148
|
if (open) launch(port, https);
|
|
1146
1149
|
|
|
1147
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1150
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.251'}\n`));
|
|
1148
1151
|
|
|
1149
1152
|
const protocol = https ? 'https:' : 'http:';
|
|
1150
1153
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/package.json
CHANGED
package/types/config.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ export interface Config {
|
|
|
118
118
|
adapter?: Adapter;
|
|
119
119
|
amp?: boolean;
|
|
120
120
|
appDir?: string;
|
|
121
|
+
browser?: {
|
|
122
|
+
hydrate?: boolean;
|
|
123
|
+
router?: boolean;
|
|
124
|
+
};
|
|
121
125
|
csp?: {
|
|
122
126
|
mode?: 'hash' | 'nonce' | 'auto';
|
|
123
127
|
directives?: CspDirectives;
|
|
@@ -131,7 +135,6 @@ export interface Config {
|
|
|
131
135
|
template?: string;
|
|
132
136
|
};
|
|
133
137
|
floc?: boolean;
|
|
134
|
-
hydrate?: boolean;
|
|
135
138
|
inlineStyleThreshold?: number;
|
|
136
139
|
methodOverride?: {
|
|
137
140
|
parameter?: string;
|
|
@@ -150,11 +153,12 @@ export interface Config {
|
|
|
150
153
|
prerender?: {
|
|
151
154
|
concurrency?: number;
|
|
152
155
|
crawl?: boolean;
|
|
156
|
+
createIndexFiles?: boolean;
|
|
153
157
|
enabled?: boolean;
|
|
154
158
|
entries?: string[];
|
|
155
159
|
onError?: PrerenderOnErrorValue;
|
|
156
160
|
};
|
|
157
|
-
|
|
161
|
+
routes?: (filepath: string) => boolean;
|
|
158
162
|
serviceWorker?: {
|
|
159
163
|
register?: boolean;
|
|
160
164
|
files?: (filepath: string) => boolean;
|
package/types/internal.d.ts
CHANGED