@sveltejs/kit 1.0.0-next.289 → 1.0.0-next.291
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/navigation.js +11 -66
- package/assets/client/singletons.js +5 -13
- package/assets/client/start.js +765 -827
- package/dist/chunks/{build.js → constants.js} +6 -1
- package/dist/chunks/index.js +18 -7
- package/dist/chunks/index2.js +10 -8
- package/dist/chunks/index3.js +1 -1
- package/dist/chunks/index4.js +13 -16
- package/dist/chunks/index5.js +6 -16
- package/dist/chunks/index6.js +1 -1
- package/dist/chunks/tsconfig.js +9 -9
- package/dist/cli.js +11 -13
- package/package.json +1 -1
- package/types/index.d.ts +9 -2
- package/types/private.d.ts +2 -2
- package/assets/chunks/utils.js +0 -13
|
@@ -655,4 +655,9 @@ function sirv (dir, opts={}) {
|
|
|
655
655
|
};
|
|
656
656
|
}
|
|
657
657
|
|
|
658
|
-
|
|
658
|
+
// in `svelte-kit dev` and `svelte-kit preview`, we use a fake
|
|
659
|
+
// asset path so that we can serve local assets while still
|
|
660
|
+
// verifying that requests are correctly prefixed
|
|
661
|
+
const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
|
|
662
|
+
|
|
663
|
+
export { SVELTE_KIT_ASSETS as S, sirv as s };
|
package/dist/chunks/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import path__default from 'path';
|
|
|
2
2
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
3
|
import vite from 'vite';
|
|
4
4
|
import { c as create_manifest_data, a as create_app, g as generate_tsconfig, d as deep_merge } from './tsconfig.js';
|
|
5
|
-
import {
|
|
5
|
+
import { g as get_runtime_path, r as resolve_entry, $, p as posixify, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as copy_assets, d as get_aliases, e as print_config_conflicts } from '../cli.js';
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
8
|
-
import { s as sirv } from './
|
|
8
|
+
import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
9
9
|
import { installFetch } from '../install-fetch.js';
|
|
10
10
|
import { getRequest, setResponse } from '../node.js';
|
|
11
11
|
import { sequence } from '../hooks.js';
|
|
@@ -29,6 +29,8 @@ import 'stream';
|
|
|
29
29
|
* @returns {Promise<import('vite').Plugin>}
|
|
30
30
|
*/
|
|
31
31
|
async function create_plugin(config, cwd) {
|
|
32
|
+
const runtime = get_runtime_path(config);
|
|
33
|
+
|
|
32
34
|
/** @type {import('types').Handle} */
|
|
33
35
|
let amp;
|
|
34
36
|
|
|
@@ -238,9 +240,18 @@ async function create_plugin(config, cwd) {
|
|
|
238
240
|
throw new Error('The serverFetch hook has been renamed to externalFetch.');
|
|
239
241
|
}
|
|
240
242
|
|
|
241
|
-
|
|
243
|
+
// TODO the / prefix will probably fail if outDir is outside the cwd (which
|
|
244
|
+
// could be the case in a monorepo setup), but without it these modules
|
|
245
|
+
// can get loaded twice via different URLs, which causes failures. Might
|
|
246
|
+
// require changes to Vite to fix
|
|
247
|
+
const { default: root } = await vite.ssrLoadModule(
|
|
248
|
+
`/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`
|
|
249
|
+
);
|
|
250
|
+
|
|
242
251
|
const paths = await vite.ssrLoadModule(
|
|
243
|
-
true
|
|
252
|
+
true
|
|
253
|
+
? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
|
|
254
|
+
: `/@fs${runtime}/paths.js`
|
|
244
255
|
);
|
|
245
256
|
|
|
246
257
|
paths.set_paths({
|
|
@@ -405,7 +416,7 @@ function find_deps(node, deps) {
|
|
|
405
416
|
|
|
406
417
|
/** @param {Options} opts */
|
|
407
418
|
async function dev({ cwd, port, host, https, config }) {
|
|
408
|
-
copy_assets(
|
|
419
|
+
copy_assets(path__default.join(config.kit.outDir, 'runtime'));
|
|
409
420
|
|
|
410
421
|
generate_tsconfig(config);
|
|
411
422
|
|
|
@@ -418,8 +429,8 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
418
429
|
config.kit.files.assets,
|
|
419
430
|
config.kit.files.lib,
|
|
420
431
|
config.kit.files.routes,
|
|
432
|
+
config.kit.outDir,
|
|
421
433
|
path__default.resolve(cwd, 'src'),
|
|
422
|
-
path__default.resolve(cwd, SVELTE_KIT),
|
|
423
434
|
path__default.resolve(cwd, 'node_modules'),
|
|
424
435
|
path__default.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
|
|
425
436
|
])
|
|
@@ -442,7 +453,7 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
442
453
|
rollupOptions: {
|
|
443
454
|
// Vite dependency crawler needs an explicit JS entry point
|
|
444
455
|
// eventhough server otherwise works without it
|
|
445
|
-
input: `${
|
|
456
|
+
input: `${get_runtime_path(config)}/client/start.js`
|
|
446
457
|
}
|
|
447
458
|
},
|
|
448
459
|
plugins: [
|
package/dist/chunks/index2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs__default from 'fs';
|
|
2
2
|
import path__default from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { e as print_config_conflicts, b as copy_assets, p as posixify, d as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template, m as mkdirp, f as rimraf } from '../cli.js';
|
|
4
4
|
import { d as deep_merge, a as create_app, g as generate_tsconfig, c as create_manifest_data } from './tsconfig.js';
|
|
5
5
|
import { g as generate_manifest } from './index3.js';
|
|
6
6
|
import vite from 'vite';
|
|
@@ -39,7 +39,7 @@ async function build_service_worker(
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const service_worker = `${
|
|
42
|
+
const service_worker = `${config.kit.outDir}/generated/service-worker.js`;
|
|
43
43
|
|
|
44
44
|
fs__default.writeFileSync(
|
|
45
45
|
service_worker,
|
|
@@ -167,7 +167,7 @@ async function build_client({
|
|
|
167
167
|
cwd
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
copy_assets(
|
|
170
|
+
copy_assets(path__default.join(config.kit.outDir, 'runtime'));
|
|
171
171
|
|
|
172
172
|
process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : '';
|
|
173
173
|
|
|
@@ -264,11 +264,12 @@ async function build_client({
|
|
|
264
264
|
* hooks: string;
|
|
265
265
|
* config: import('types').ValidatedConfig;
|
|
266
266
|
* has_service_worker: boolean;
|
|
267
|
+
* runtime: string;
|
|
267
268
|
* template: string;
|
|
268
269
|
* }} opts
|
|
269
270
|
* @returns
|
|
270
271
|
*/
|
|
271
|
-
const server_template = ({ config, hooks, has_service_worker, template }) => `
|
|
272
|
+
const server_template = ({ config, hooks, has_service_worker, runtime, template }) => `
|
|
272
273
|
import root from '__GENERATED__/root.svelte';
|
|
273
274
|
import { respond } from '${runtime}/server/index.js';
|
|
274
275
|
import { set_paths, assets, base } from '${runtime}/paths.js';
|
|
@@ -383,7 +384,7 @@ async function build_server(
|
|
|
383
384
|
) {
|
|
384
385
|
let hooks_file = resolve_entry(config.kit.files.hooks);
|
|
385
386
|
if (!hooks_file || !fs__default.existsSync(hooks_file)) {
|
|
386
|
-
hooks_file = path__default.
|
|
387
|
+
hooks_file = path__default.join(config.kit.outDir, 'build/hooks.js');
|
|
387
388
|
fs__default.writeFileSync(hooks_file, '');
|
|
388
389
|
}
|
|
389
390
|
|
|
@@ -427,6 +428,7 @@ async function build_server(
|
|
|
427
428
|
config,
|
|
428
429
|
hooks: app_relative(hooks_file),
|
|
429
430
|
has_service_worker: service_worker_register && !!service_worker_entry_file,
|
|
431
|
+
runtime: get_runtime_path(config),
|
|
430
432
|
template: load_template(cwd, config)
|
|
431
433
|
})
|
|
432
434
|
);
|
|
@@ -590,11 +592,11 @@ function get_methods(cwd, output, manifest_data) {
|
|
|
590
592
|
async function build(config) {
|
|
591
593
|
const cwd = process.cwd(); // TODO is this necessary?
|
|
592
594
|
|
|
593
|
-
const build_dir = path__default.
|
|
595
|
+
const build_dir = path__default.join(config.kit.outDir, 'build');
|
|
594
596
|
rimraf(build_dir);
|
|
595
597
|
mkdirp(build_dir);
|
|
596
598
|
|
|
597
|
-
const output_dir = path__default.
|
|
599
|
+
const output_dir = path__default.join(config.kit.outDir, 'output');
|
|
598
600
|
rimraf(output_dir);
|
|
599
601
|
mkdirp(output_dir);
|
|
600
602
|
|
|
@@ -614,7 +616,7 @@ async function build(config) {
|
|
|
614
616
|
cwd
|
|
615
617
|
}),
|
|
616
618
|
output_dir,
|
|
617
|
-
client_entry_file: path__default.relative(cwd, `${
|
|
619
|
+
client_entry_file: path__default.relative(cwd, `${get_runtime_path(config)}/client/start.js`),
|
|
618
620
|
service_worker_entry_file: resolve_entry(config.kit.files.serviceWorker),
|
|
619
621
|
service_worker_register: config.kit.serviceWorker.register
|
|
620
622
|
};
|
package/dist/chunks/index3.js
CHANGED
package/dist/chunks/index4.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as mkdirp, f as rimraf, h as copy, $, i as logger } from '../cli.js';
|
|
2
2
|
import { readFileSync, writeFileSync } from 'fs';
|
|
3
|
-
import {
|
|
3
|
+
import { join, dirname } from 'path';
|
|
4
4
|
import { pathToFileURL, URL } from 'url';
|
|
5
5
|
import { installFetch } from '../install-fetch.js';
|
|
6
6
|
import { g as generate_manifest } from './index3.js';
|
|
@@ -450,7 +450,6 @@ const REDIRECT = 3;
|
|
|
450
450
|
|
|
451
451
|
/**
|
|
452
452
|
* @param {{
|
|
453
|
-
* cwd: string;
|
|
454
453
|
* out: string;
|
|
455
454
|
* log: Logger;
|
|
456
455
|
* config: import('types').ValidatedConfig;
|
|
@@ -459,7 +458,7 @@ const REDIRECT = 3;
|
|
|
459
458
|
* all: boolean; // disregard `export const prerender = true`
|
|
460
459
|
* }} opts
|
|
461
460
|
*/
|
|
462
|
-
async function prerender({
|
|
461
|
+
async function prerender({ out, log, config, build_data, fallback, all }) {
|
|
463
462
|
/** @type {import('types').Prerendered} */
|
|
464
463
|
const prerendered = {
|
|
465
464
|
pages: new Map(),
|
|
@@ -474,7 +473,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
474
473
|
|
|
475
474
|
installFetch();
|
|
476
475
|
|
|
477
|
-
const server_root =
|
|
476
|
+
const server_root = join(config.kit.outDir, 'output');
|
|
478
477
|
|
|
479
478
|
/** @type {import('types').ServerModule} */
|
|
480
479
|
const { Server, override } = await import(pathToFileURL(`${server_root}/server/index.js`).href);
|
|
@@ -707,14 +706,13 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
|
|
|
707
706
|
|
|
708
707
|
/**
|
|
709
708
|
* @param {{
|
|
710
|
-
* cwd: string;
|
|
711
709
|
* config: import('types').ValidatedConfig;
|
|
712
710
|
* build_data: import('types').BuildData;
|
|
713
711
|
* log: import('types').Logger;
|
|
714
712
|
* }} opts
|
|
715
713
|
* @returns {import('types').Builder}
|
|
716
714
|
*/
|
|
717
|
-
function create_builder({
|
|
715
|
+
function create_builder({ config, build_data, log }) {
|
|
718
716
|
/** @type {Set<string>} */
|
|
719
717
|
let prerendered_paths;
|
|
720
718
|
|
|
@@ -820,15 +818,15 @@ function create_builder({ cwd, config, build_data, log }) {
|
|
|
820
818
|
},
|
|
821
819
|
|
|
822
820
|
getBuildDirectory(name) {
|
|
823
|
-
return `${
|
|
821
|
+
return `${config.kit.outDir}/${name}`;
|
|
824
822
|
},
|
|
825
823
|
|
|
826
824
|
getClientDirectory() {
|
|
827
|
-
return `${
|
|
825
|
+
return `${config.kit.outDir}/output/client`;
|
|
828
826
|
},
|
|
829
827
|
|
|
830
828
|
getServerDirectory() {
|
|
831
|
-
return `${
|
|
829
|
+
return `${config.kit.outDir}/output/server`;
|
|
832
830
|
},
|
|
833
831
|
|
|
834
832
|
getStaticDirectory() {
|
|
@@ -836,13 +834,13 @@ function create_builder({ cwd, config, build_data, log }) {
|
|
|
836
834
|
},
|
|
837
835
|
|
|
838
836
|
writeClient(dest) {
|
|
839
|
-
return copy(`${
|
|
837
|
+
return copy(`${config.kit.outDir}/output/client`, dest, {
|
|
840
838
|
filter: (file) => file[0] !== '.'
|
|
841
839
|
});
|
|
842
840
|
},
|
|
843
841
|
|
|
844
842
|
writeServer(dest) {
|
|
845
|
-
return copy(`${
|
|
843
|
+
return copy(`${config.kit.outDir}/output/server`, dest, {
|
|
846
844
|
filter: (file) => file[0] !== '.'
|
|
847
845
|
});
|
|
848
846
|
},
|
|
@@ -861,7 +859,6 @@ function create_builder({ cwd, config, build_data, log }) {
|
|
|
861
859
|
const prerendered = await prerender({
|
|
862
860
|
out: dest,
|
|
863
861
|
all,
|
|
864
|
-
cwd,
|
|
865
862
|
config,
|
|
866
863
|
build_data,
|
|
867
864
|
fallback,
|
|
@@ -878,15 +875,15 @@ function create_builder({ cwd, config, build_data, log }) {
|
|
|
878
875
|
/**
|
|
879
876
|
* @param {import('types').ValidatedConfig} config
|
|
880
877
|
* @param {import('types').BuildData} build_data
|
|
881
|
-
* @param {{
|
|
878
|
+
* @param {{ verbose: boolean }} opts
|
|
882
879
|
*/
|
|
883
|
-
async function adapt(config, build_data, {
|
|
880
|
+
async function adapt(config, build_data, { verbose }) {
|
|
884
881
|
const { name, adapt } = config.kit.adapter;
|
|
885
882
|
|
|
886
883
|
console.log($.bold().cyan(`\n> Using ${name}`));
|
|
887
884
|
|
|
888
885
|
const log = logger({ verbose });
|
|
889
|
-
const builder = create_builder({
|
|
886
|
+
const builder = create_builder({ config, build_data, log });
|
|
890
887
|
await adapt(builder);
|
|
891
888
|
|
|
892
889
|
log.success('done');
|
package/dist/chunks/index5.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import fs__default from 'fs';
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import https from 'https';
|
|
4
|
-
import {
|
|
5
|
-
import { s as sirv } from './
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { s as sirv, S as SVELTE_KIT_ASSETS } from './constants.js';
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { getRequest, setResponse } from '../node.js';
|
|
8
8
|
import { installFetch } from '../install-fetch.js';
|
|
9
|
-
import { b as SVELTE_KIT, S as SVELTE_KIT_ASSETS } from '../cli.js';
|
|
10
9
|
import 'querystring';
|
|
11
10
|
import 'stream';
|
|
12
11
|
import 'node:http';
|
|
@@ -16,9 +15,6 @@ import 'node:stream';
|
|
|
16
15
|
import 'node:util';
|
|
17
16
|
import 'node:url';
|
|
18
17
|
import 'net';
|
|
19
|
-
import 'sade';
|
|
20
|
-
import 'child_process';
|
|
21
|
-
import 'os';
|
|
22
18
|
|
|
23
19
|
/** @param {string} dir */
|
|
24
20
|
const mutable = (dir) =>
|
|
@@ -36,17 +32,11 @@ const mutable = (dir) =>
|
|
|
36
32
|
* cwd?: string;
|
|
37
33
|
* }} opts
|
|
38
34
|
*/
|
|
39
|
-
async function preview({
|
|
40
|
-
port,
|
|
41
|
-
host,
|
|
42
|
-
config,
|
|
43
|
-
https: use_https = false,
|
|
44
|
-
cwd = process.cwd()
|
|
45
|
-
}) {
|
|
35
|
+
async function preview({ port, host, config, https: use_https = false }) {
|
|
46
36
|
installFetch();
|
|
47
37
|
|
|
48
|
-
const index_file =
|
|
49
|
-
const manifest_file =
|
|
38
|
+
const index_file = join(config.kit.outDir, 'output/server/index.js');
|
|
39
|
+
const manifest_file = join(config.kit.outDir, 'output/server/manifest.js');
|
|
50
40
|
|
|
51
41
|
/** @type {import('types').ServerModule} */
|
|
52
42
|
const { Server, override } = await import(pathToFileURL(index_file).href);
|
|
@@ -61,7 +51,7 @@ async function preview({
|
|
|
61
51
|
return next();
|
|
62
52
|
};
|
|
63
53
|
|
|
64
|
-
const assets_handler = sirv(
|
|
54
|
+
const assets_handler = sirv(join(config.kit.outDir, 'output/client'), {
|
|
65
55
|
maxAge: 31536000,
|
|
66
56
|
immutable: true
|
|
67
57
|
});
|
package/dist/chunks/index6.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
import {
|
|
4
|
+
import { f as rimraf, m as mkdirp, w as walk$1, $ } from '../cli.js';
|
|
5
5
|
import 'sade';
|
|
6
6
|
import 'child_process';
|
|
7
7
|
import 'net';
|
package/dist/chunks/tsconfig.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs__default from 'fs';
|
|
2
2
|
import path__default from 'path';
|
|
3
3
|
import { s } from './misc.js';
|
|
4
|
-
import { m as mkdirp,
|
|
4
|
+
import { m as mkdirp, g as get_runtime_path, p as posixify, $ } from '../cli.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Takes zero or more objects and returns a new object that has all the values
|
|
@@ -110,7 +110,7 @@ function write_if_changed(file, code) {
|
|
|
110
110
|
* }} options
|
|
111
111
|
*/
|
|
112
112
|
function create_app({ config, manifest_data, cwd = process.cwd() }) {
|
|
113
|
-
const output =
|
|
113
|
+
const output = path__default.join(config.kit.outDir, 'generated');
|
|
114
114
|
const base = path__default.relative(cwd, output);
|
|
115
115
|
|
|
116
116
|
write_if_changed(`${output}/manifest.js`, generate_client_manifest(manifest_data, base));
|
|
@@ -329,7 +329,7 @@ function create_types(config, manifest_data) {
|
|
|
329
329
|
.filter(Boolean)
|
|
330
330
|
.join(', ');
|
|
331
331
|
|
|
332
|
-
const file = `${
|
|
332
|
+
const file = `${config.kit.outDir}/types/${key || 'index'}.d.ts`;
|
|
333
333
|
const content = [
|
|
334
334
|
'// this file is auto-generated',
|
|
335
335
|
`import type { ${imports} } from '@sveltejs/kit';`,
|
|
@@ -480,7 +480,7 @@ const specials = new Set(['__layout', '__layout.reset', '__error']);
|
|
|
480
480
|
*/
|
|
481
481
|
function create_manifest_data({
|
|
482
482
|
config,
|
|
483
|
-
fallback = `${
|
|
483
|
+
fallback = `${get_runtime_path(config)}/components`,
|
|
484
484
|
cwd = process.cwd()
|
|
485
485
|
}) {
|
|
486
486
|
/**
|
|
@@ -910,18 +910,18 @@ const exists = (file) => fs__default.existsSync(file) && file;
|
|
|
910
910
|
|
|
911
911
|
/** @param {import('types').ValidatedConfig} config */
|
|
912
912
|
function generate_tsconfig(config) {
|
|
913
|
-
const out = path__default.
|
|
913
|
+
const out = path__default.join(config.kit.outDir, 'tsconfig.json');
|
|
914
914
|
const user_file = exists('tsconfig.json') || exists('jsconfig.json');
|
|
915
915
|
|
|
916
916
|
if (user_file) validate(config, out, user_file);
|
|
917
917
|
|
|
918
|
-
mkdirp(
|
|
918
|
+
mkdirp(config.kit.outDir);
|
|
919
919
|
|
|
920
920
|
/** @param {string} file */
|
|
921
921
|
const project_relative = (file) => posixify(path__default.relative('.', file));
|
|
922
922
|
|
|
923
923
|
/** @param {string} file */
|
|
924
|
-
const config_relative = (file) => posixify(path__default.relative(
|
|
924
|
+
const config_relative = (file) => posixify(path__default.relative(config.kit.outDir, file));
|
|
925
925
|
|
|
926
926
|
const dirs = new Set([
|
|
927
927
|
project_relative(path__default.dirname(config.kit.files.routes)),
|
|
@@ -937,7 +937,7 @@ function generate_tsconfig(config) {
|
|
|
937
937
|
});
|
|
938
938
|
|
|
939
939
|
fs__default.writeFileSync(
|
|
940
|
-
|
|
940
|
+
out,
|
|
941
941
|
JSON.stringify(
|
|
942
942
|
{
|
|
943
943
|
compilerOptions: {
|
|
@@ -1018,7 +1018,7 @@ function validate(config, out, user_file) {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
} else {
|
|
1020
1020
|
let relative = posixify(path__default.relative('.', out));
|
|
1021
|
-
if (relative.startsWith(
|
|
1021
|
+
if (!relative.startsWith('./')) relative = './' + relative;
|
|
1022
1022
|
|
|
1023
1023
|
console.warn(
|
|
1024
1024
|
$
|
package/dist/cli.js
CHANGED
|
@@ -320,17 +320,11 @@ function posixify(str) {
|
|
|
320
320
|
return str.replace(/\\/g, '/');
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
const SVELTE_KIT = '.svelte-kit';
|
|
324
|
-
|
|
325
|
-
// in `svelte-kit dev` and `svelte-kit preview`, we use a fake
|
|
326
|
-
// asset path so that we can serve local assets while still
|
|
327
|
-
// verifying that requests are correctly prefixed
|
|
328
|
-
const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
|
|
329
|
-
|
|
330
323
|
const __filename = fileURLToPath(import.meta.url);
|
|
331
324
|
const __dirname = path__default.dirname(__filename);
|
|
332
325
|
|
|
333
|
-
const
|
|
326
|
+
const get_runtime_path = /** @param {import('types').ValidatedConfig} config */ (config) =>
|
|
327
|
+
posixify_path(path__default.join(config.kit.outDir, 'runtime'))
|
|
334
328
|
;
|
|
335
329
|
|
|
336
330
|
/** @param {string} str */
|
|
@@ -425,8 +419,8 @@ function get_mime_lookup(manifest_data) {
|
|
|
425
419
|
/** @param {import('types').ValidatedConfig} config */
|
|
426
420
|
function get_aliases(config) {
|
|
427
421
|
const alias = {
|
|
428
|
-
__GENERATED__: path__default.posix.
|
|
429
|
-
$app: `${
|
|
422
|
+
__GENERATED__: path__default.posix.join(config.kit.outDir, 'generated'),
|
|
423
|
+
$app: `${get_runtime_path(config)}/app`,
|
|
430
424
|
$lib: config.kit.files.lib
|
|
431
425
|
};
|
|
432
426
|
|
|
@@ -575,6 +569,8 @@ const options = object(
|
|
|
575
569
|
})
|
|
576
570
|
}),
|
|
577
571
|
|
|
572
|
+
outDir: string('.svelte-kit'),
|
|
573
|
+
|
|
578
574
|
package: object({
|
|
579
575
|
dir: string('package'),
|
|
580
576
|
// excludes all .d.ts and filename starting with _
|
|
@@ -915,6 +911,8 @@ async function load_config({ cwd = process.cwd() } = {}) {
|
|
|
915
911
|
|
|
916
912
|
const validated = validate_config(config.default);
|
|
917
913
|
|
|
914
|
+
validated.kit.outDir = path__default.resolve(cwd, validated.kit.outDir);
|
|
915
|
+
|
|
918
916
|
validated.kit.files.assets = path__default.resolve(cwd, validated.kit.files.assets);
|
|
919
917
|
validated.kit.files.hooks = path__default.resolve(cwd, validated.kit.files.hooks);
|
|
920
918
|
validated.kit.files.lib = path__default.resolve(cwd, validated.kit.files.lib);
|
|
@@ -998,7 +996,7 @@ async function launch(port, https) {
|
|
|
998
996
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
999
997
|
}
|
|
1000
998
|
|
|
1001
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
999
|
+
const prog = sade('svelte-kit').version('1.0.0-next.291');
|
|
1002
1000
|
|
|
1003
1001
|
prog
|
|
1004
1002
|
.command('dev')
|
|
@@ -1156,7 +1154,7 @@ async function check_port(port) {
|
|
|
1156
1154
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1157
1155
|
if (open) launch(port, https);
|
|
1158
1156
|
|
|
1159
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1157
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.291'}\n`));
|
|
1160
1158
|
|
|
1161
1159
|
const protocol = https ? 'https:' : 'http:';
|
|
1162
1160
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1193,4 +1191,4 @@ function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
|
1193
1191
|
console.log('\n');
|
|
1194
1192
|
}
|
|
1195
1193
|
|
|
1196
|
-
export { $,
|
|
1194
|
+
export { $, get_mime_lookup as a, copy_assets as b, coalesce_to_error as c, get_aliases as d, print_config_conflicts as e, rimraf as f, get_runtime_path as g, copy as h, logger as i, load_template as l, mkdirp as m, posixify as p, resolve_entry as r, walk as w };
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export interface Config {
|
|
|
55
55
|
parameter?: string;
|
|
56
56
|
allowed?: string[];
|
|
57
57
|
};
|
|
58
|
+
outDir?: string;
|
|
58
59
|
package?: {
|
|
59
60
|
dir?: string;
|
|
60
61
|
emitTypes?: boolean;
|
|
@@ -115,8 +116,14 @@ export interface HandleError {
|
|
|
115
116
|
*
|
|
116
117
|
* Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
|
|
117
118
|
*/
|
|
118
|
-
export interface Load<
|
|
119
|
-
|
|
119
|
+
export interface Load<
|
|
120
|
+
Params extends Record<string, string> = Record<string, string>,
|
|
121
|
+
InputProps extends Record<string, any> = Record<string, any>,
|
|
122
|
+
OutputProps extends Record<string, any> = InputProps
|
|
123
|
+
> {
|
|
124
|
+
(input: LoadInput<Params, InputProps>): MaybePromise<
|
|
125
|
+
Either<Fallthrough, LoadOutput<OutputProps>>
|
|
126
|
+
>;
|
|
120
127
|
}
|
|
121
128
|
|
|
122
129
|
export interface Navigation {
|
package/types/private.d.ts
CHANGED
|
@@ -220,10 +220,10 @@ export type JSONValue =
|
|
|
220
220
|
| JSONValue[]
|
|
221
221
|
| JSONObject;
|
|
222
222
|
|
|
223
|
-
export interface LoadInput<Params = Record<string, string>> {
|
|
223
|
+
export interface LoadInput<Params = Record<string, string>, Props = Record<string, any>> {
|
|
224
224
|
url: URL;
|
|
225
225
|
params: Params;
|
|
226
|
-
props:
|
|
226
|
+
props: Props;
|
|
227
227
|
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
228
228
|
session: App.Session;
|
|
229
229
|
stuff: Partial<App.Stuff>;
|
package/assets/chunks/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @param {HTMLDocument} doc */
|
|
2
|
-
function get_base_uri(doc) {
|
|
3
|
-
let baseURI = doc.baseURI;
|
|
4
|
-
|
|
5
|
-
if (!baseURI) {
|
|
6
|
-
const baseTags = doc.getElementsByTagName('base');
|
|
7
|
-
baseURI = baseTags.length ? baseTags[0].href : doc.URL;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return baseURI;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { get_base_uri as g };
|