@sveltejs/kit 1.0.0-next.203 → 1.0.0-next.208
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/internal/start.js +114 -119
- package/dist/chunks/index.js +100 -114
- package/dist/chunks/index2.js +29 -15
- package/dist/chunks/index3.js +403 -821
- package/dist/chunks/index4.js +89 -378
- package/dist/chunks/index5.js +524 -723
- package/dist/chunks/index6.js +737 -15485
- package/dist/chunks/index7.js +15575 -0
- package/dist/chunks/misc.js +3 -0
- package/dist/cli.js +91 -26
- package/dist/ssr.js +210 -135
- package/package.json +2 -3
- package/types/ambient-modules.d.ts +15 -7
- package/types/app.d.ts +29 -5
- package/types/config.d.ts +79 -12
- package/types/hooks.d.ts +16 -4
- package/types/index.d.ts +3 -3
- package/types/internal.d.ts +40 -28
- package/types/page.d.ts +2 -8
package/dist/cli.js
CHANGED
|
@@ -231,27 +231,60 @@ function rimraf(path) {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
* @param {string}
|
|
235
|
-
* @param {string}
|
|
236
|
-
* @param {
|
|
234
|
+
* @param {string} source
|
|
235
|
+
* @param {string} target
|
|
236
|
+
* @param {{
|
|
237
|
+
* filter?: (basename: string) => boolean;
|
|
238
|
+
* replace?: Record<string, string>;
|
|
239
|
+
* }} opts
|
|
237
240
|
*/
|
|
238
|
-
function copy(
|
|
239
|
-
if (!fs__default.existsSync(
|
|
240
|
-
if (!filter(path__default.basename(from))) return [];
|
|
241
|
+
function copy(source, target, opts = {}) {
|
|
242
|
+
if (!fs__default.existsSync(source)) return [];
|
|
241
243
|
|
|
244
|
+
/** @type {string[]} */
|
|
242
245
|
const files = [];
|
|
243
|
-
const stats = fs__default.statSync(from);
|
|
244
246
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
})
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
247
|
+
const prefix = posixify(target) + '/';
|
|
248
|
+
|
|
249
|
+
const regex = opts.replace
|
|
250
|
+
? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g')
|
|
251
|
+
: null;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @param {string} from
|
|
255
|
+
* @param {string} to
|
|
256
|
+
*/
|
|
257
|
+
function go(from, to) {
|
|
258
|
+
if (opts.filter && !opts.filter(path__default.basename(from))) return;
|
|
259
|
+
|
|
260
|
+
const stats = fs__default.statSync(from);
|
|
261
|
+
|
|
262
|
+
if (stats.isDirectory()) {
|
|
263
|
+
fs__default.readdirSync(from).forEach((file) => {
|
|
264
|
+
go(path__default.join(from, file), path__default.join(to, file));
|
|
265
|
+
});
|
|
266
|
+
} else {
|
|
267
|
+
mkdirp(path__default.dirname(to));
|
|
268
|
+
|
|
269
|
+
if (opts.replace) {
|
|
270
|
+
const data = fs__default.readFileSync(from, 'utf-8');
|
|
271
|
+
fs__default.writeFileSync(
|
|
272
|
+
to,
|
|
273
|
+
data.replace(
|
|
274
|
+
/** @type {RegExp} */ (regex),
|
|
275
|
+
(match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
|
|
276
|
+
)
|
|
277
|
+
);
|
|
278
|
+
} else {
|
|
279
|
+
fs__default.copyFileSync(from, to);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
files.push(to === target ? posixify(path__default.basename(to)) : posixify(to).replace(prefix, ''));
|
|
283
|
+
}
|
|
253
284
|
}
|
|
254
285
|
|
|
286
|
+
go(source, target);
|
|
287
|
+
|
|
255
288
|
return files;
|
|
256
289
|
}
|
|
257
290
|
|
|
@@ -354,7 +387,21 @@ function posixify(str) {
|
|
|
354
387
|
return str.replace(/\\/g, '/');
|
|
355
388
|
}
|
|
356
389
|
|
|
357
|
-
/** @
|
|
390
|
+
/** @param {import('./create_app/index.js').ManifestData} manifest_data */
|
|
391
|
+
function get_mime_lookup(manifest_data) {
|
|
392
|
+
/** @type {Record<string, string>} */
|
|
393
|
+
const mime = {};
|
|
394
|
+
|
|
395
|
+
manifest_data.assets.forEach((asset) => {
|
|
396
|
+
if (asset.type) {
|
|
397
|
+
const ext = path__default.extname(asset.file);
|
|
398
|
+
mime[ext] = asset.type;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
return mime;
|
|
403
|
+
}
|
|
404
|
+
|
|
358
405
|
/** @typedef {import('./types').Validator} Validator */
|
|
359
406
|
|
|
360
407
|
/** @type {Validator} */
|
|
@@ -423,9 +470,12 @@ const options = object(
|
|
|
423
470
|
|
|
424
471
|
floc: boolean(false),
|
|
425
472
|
|
|
426
|
-
|
|
473
|
+
headers: object({
|
|
474
|
+
host: string(null),
|
|
475
|
+
protocol: string(null)
|
|
476
|
+
}),
|
|
427
477
|
|
|
428
|
-
|
|
478
|
+
host: string(null),
|
|
429
479
|
|
|
430
480
|
hydrate: boolean(true),
|
|
431
481
|
|
|
@@ -471,6 +521,7 @@ const options = object(
|
|
|
471
521
|
}),
|
|
472
522
|
|
|
473
523
|
prerender: object({
|
|
524
|
+
concurrency: number(1),
|
|
474
525
|
crawl: boolean(true),
|
|
475
526
|
enabled: boolean(true),
|
|
476
527
|
entries: validate(['*'], (input, keypath) => {
|
|
@@ -515,9 +566,12 @@ const options = object(
|
|
|
515
566
|
})
|
|
516
567
|
}),
|
|
517
568
|
|
|
569
|
+
protocol: string(null),
|
|
570
|
+
|
|
518
571
|
router: boolean(true),
|
|
519
572
|
|
|
520
573
|
serviceWorker: object({
|
|
574
|
+
register: boolean(true),
|
|
521
575
|
files: fun((filename) => !/\.DS_STORE/.test(filename))
|
|
522
576
|
}),
|
|
523
577
|
|
|
@@ -617,6 +671,19 @@ function string(fallback, allow_empty = true) {
|
|
|
617
671
|
});
|
|
618
672
|
}
|
|
619
673
|
|
|
674
|
+
/**
|
|
675
|
+
* @param {number} fallback
|
|
676
|
+
* @returns {Validator}
|
|
677
|
+
*/
|
|
678
|
+
function number(fallback) {
|
|
679
|
+
return validate(fallback, (input, keypath) => {
|
|
680
|
+
if (typeof input !== 'number') {
|
|
681
|
+
throw new Error(`${keypath} should be a number, if specified`);
|
|
682
|
+
}
|
|
683
|
+
return input;
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
|
|
620
687
|
/**
|
|
621
688
|
* @param {boolean} fallback
|
|
622
689
|
* @returns {Validator}
|
|
@@ -671,8 +738,6 @@ function assert_string(input, keypath) {
|
|
|
671
738
|
}
|
|
672
739
|
}
|
|
673
740
|
|
|
674
|
-
/** @typedef {import('./types').ConfigDefinition} ConfigDefinition */
|
|
675
|
-
|
|
676
741
|
/**
|
|
677
742
|
* @param {string} cwd
|
|
678
743
|
* @param {import('types/config').ValidatedConfig} validated
|
|
@@ -822,7 +887,7 @@ async function launch(port, https) {
|
|
|
822
887
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
823
888
|
}
|
|
824
889
|
|
|
825
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
890
|
+
const prog = sade('svelte-kit').version('1.0.0-next.208');
|
|
826
891
|
|
|
827
892
|
prog
|
|
828
893
|
.command('dev')
|
|
@@ -892,7 +957,7 @@ prog
|
|
|
892
957
|
);
|
|
893
958
|
|
|
894
959
|
if (config.kit.adapter) {
|
|
895
|
-
const { adapt } = await import('./chunks/
|
|
960
|
+
const { adapt } = await import('./chunks/index5.js');
|
|
896
961
|
await adapt(config, build_data, { verbose });
|
|
897
962
|
|
|
898
963
|
// this is necessary to close any open db connections, etc
|
|
@@ -923,7 +988,7 @@ prog
|
|
|
923
988
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
924
989
|
const config = await get_config();
|
|
925
990
|
|
|
926
|
-
const { preview } = await import('./chunks/
|
|
991
|
+
const { preview } = await import('./chunks/index6.js');
|
|
927
992
|
|
|
928
993
|
try {
|
|
929
994
|
await preview({ port, host, config, https });
|
|
@@ -941,7 +1006,7 @@ prog
|
|
|
941
1006
|
.action(async () => {
|
|
942
1007
|
const config = await get_config();
|
|
943
1008
|
|
|
944
|
-
const { make_package } = await import('./chunks/
|
|
1009
|
+
const { make_package } = await import('./chunks/index7.js');
|
|
945
1010
|
|
|
946
1011
|
try {
|
|
947
1012
|
await make_package(config);
|
|
@@ -987,7 +1052,7 @@ async function check_port(port) {
|
|
|
987
1052
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
988
1053
|
if (open) launch(port, https);
|
|
989
1054
|
|
|
990
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1055
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.208'}\n`));
|
|
991
1056
|
|
|
992
1057
|
const protocol = https ? 'https:' : 'http:';
|
|
993
1058
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1024,4 +1089,4 @@ function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
|
1024
1089
|
console.log('\n');
|
|
1025
1090
|
}
|
|
1026
1091
|
|
|
1027
|
-
export { $, resolve_entry as a, posixify as b, copy_assets as c, copy as d, logger as l, mkdirp as m, print_config_conflicts as p, rimraf as r, walk as w };
|
|
1092
|
+
export { $, resolve_entry as a, posixify as b, copy_assets as c, copy as d, get_mime_lookup as g, logger as l, mkdirp as m, print_config_conflicts as p, rimraf as r, walk as w };
|