@sveltejs/kit 1.0.0-next.211 → 1.0.0-next.212
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/kit.js +1 -1
- package/assets/runtime/app/stores.js +3 -3
- package/assets/runtime/internal/start.js +8 -6
- package/dist/chunks/index.js +12 -3
- package/dist/chunks/index2.js +3 -0
- package/dist/chunks/index3.js +41 -37
- package/dist/cli.js +2 -2
- package/dist/ssr.js +1 -1
- package/package.json +1 -1
- package/types/ambient-modules.d.ts +4 -0
package/assets/kit.js
CHANGED
|
@@ -57,7 +57,7 @@ const navigating = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
/** @param {string} verb */
|
|
60
|
-
const
|
|
60
|
+
const throw_error = (verb) => {
|
|
61
61
|
throw new Error(
|
|
62
62
|
ssr
|
|
63
63
|
? `Can only ${verb} session store in browser`
|
|
@@ -77,8 +77,8 @@ const session = {
|
|
|
77
77
|
|
|
78
78
|
return store.subscribe(fn);
|
|
79
79
|
},
|
|
80
|
-
set: () =>
|
|
81
|
-
update: () =>
|
|
80
|
+
set: () => throw_error('set'),
|
|
81
|
+
update: () => throw_error('update')
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export { getStores, navigating, page, session, stores };
|
|
@@ -563,7 +563,7 @@ class Renderer {
|
|
|
563
563
|
|
|
564
564
|
result = error_args
|
|
565
565
|
? await this._load_error(error_args)
|
|
566
|
-
: await this._get_navigation_result_from_branch({ url, params, branch });
|
|
566
|
+
: await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
567
567
|
} catch (e) {
|
|
568
568
|
if (error) throw e;
|
|
569
569
|
|
|
@@ -800,9 +800,11 @@ class Renderer {
|
|
|
800
800
|
* url: URL;
|
|
801
801
|
* params: Record<string, string>;
|
|
802
802
|
* branch: Array<import('./types').BranchNode | undefined>;
|
|
803
|
+
* status: number;
|
|
804
|
+
* error?: Error;
|
|
803
805
|
* }} opts
|
|
804
806
|
*/
|
|
805
|
-
async _get_navigation_result_from_branch({ url, params, branch }) {
|
|
807
|
+
async _get_navigation_result_from_branch({ url, params, branch, status, error }) {
|
|
806
808
|
const filtered = /** @type {import('./types').BranchNode[] } */ (branch.filter(Boolean));
|
|
807
809
|
const redirect = filtered.find((f) => f.loaded && f.loaded.redirect);
|
|
808
810
|
|
|
@@ -826,7 +828,7 @@ class Renderer {
|
|
|
826
828
|
}
|
|
827
829
|
|
|
828
830
|
if (!this.current.url || url.href !== this.current.url.href) {
|
|
829
|
-
result.props.page = { url, params };
|
|
831
|
+
result.props.page = { url, params, status, error };
|
|
830
832
|
|
|
831
833
|
// TODO remove this for 1.0
|
|
832
834
|
/**
|
|
@@ -1120,12 +1122,12 @@ class Renderer {
|
|
|
1120
1122
|
}
|
|
1121
1123
|
}
|
|
1122
1124
|
|
|
1123
|
-
return await this._get_navigation_result_from_branch({ url, params, branch });
|
|
1125
|
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
1124
1126
|
}
|
|
1125
1127
|
|
|
1126
1128
|
/**
|
|
1127
1129
|
* @param {{
|
|
1128
|
-
* status
|
|
1130
|
+
* status: number;
|
|
1129
1131
|
* error: Error;
|
|
1130
1132
|
* url: URL;
|
|
1131
1133
|
* }} opts
|
|
@@ -1153,7 +1155,7 @@ class Renderer {
|
|
|
1153
1155
|
})
|
|
1154
1156
|
];
|
|
1155
1157
|
|
|
1156
|
-
return await this._get_navigation_result_from_branch({ url, params, branch });
|
|
1158
|
+
return await this._get_navigation_result_from_branch({ url, params, branch, status, error });
|
|
1157
1159
|
}
|
|
1158
1160
|
}
|
|
1159
1161
|
|
package/dist/chunks/index.js
CHANGED
|
@@ -4540,14 +4540,16 @@ function find_deps(node, deps) {
|
|
|
4540
4540
|
}
|
|
4541
4541
|
}
|
|
4542
4542
|
|
|
4543
|
-
/**
|
|
4543
|
+
/**
|
|
4544
|
+
* @typedef {{
|
|
4544
4545
|
* cwd: string,
|
|
4545
4546
|
* port: number,
|
|
4546
4547
|
* host?: string,
|
|
4547
4548
|
* https: boolean,
|
|
4548
4549
|
* config: import('types/config').ValidatedConfig
|
|
4549
|
-
* }} Options
|
|
4550
|
-
|
|
4550
|
+
* }} Options
|
|
4551
|
+
* @typedef {import('types/internal').SSRComponent} SSRComponent
|
|
4552
|
+
*/
|
|
4551
4553
|
|
|
4552
4554
|
/** @param {Options} opts */
|
|
4553
4555
|
async function dev({ cwd, port, host, https, config }) {
|
|
@@ -4590,6 +4592,13 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
4590
4592
|
$lib: config.kit.files.lib
|
|
4591
4593
|
}
|
|
4592
4594
|
},
|
|
4595
|
+
build: {
|
|
4596
|
+
rollupOptions: {
|
|
4597
|
+
// Vite dependency crawler needs an explicit JS entry point
|
|
4598
|
+
// eventhough server otherwise works without it
|
|
4599
|
+
input: path__default.resolve(`${output}/runtime/internal/start.js`)
|
|
4600
|
+
}
|
|
4601
|
+
},
|
|
4593
4602
|
plugins: [
|
|
4594
4603
|
svelte({
|
|
4595
4604
|
extensions: config.extensions,
|
package/dist/chunks/index2.js
CHANGED
|
@@ -686,6 +686,9 @@ function comparator(a, b) {
|
|
|
686
686
|
if (!b_sub_part) return -1;
|
|
687
687
|
|
|
688
688
|
if (a_sub_part.rest && b_sub_part.rest) {
|
|
689
|
+
if (a.is_page !== b.is_page) {
|
|
690
|
+
return a.is_page ? 1 : -1;
|
|
691
|
+
}
|
|
689
692
|
// sort alphabetically
|
|
690
693
|
return a_sub_part.content < b_sub_part.content ? -1 : 1;
|
|
691
694
|
}
|
package/dist/chunks/index3.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import fs__default
|
|
1
|
+
import fs__default from 'fs';
|
|
2
2
|
import path__default from 'path';
|
|
3
|
-
import { p as print_config_conflicts, c as copy_assets, b as posixify, r as resolve_entry,
|
|
3
|
+
import { p as print_config_conflicts, c as copy_assets, b as posixify, r as resolve_entry, m as mkdirp, a as rimraf } from '../cli.js';
|
|
4
4
|
import { d as deep_merge, a as create_app, c as create_manifest_data } from './index2.js';
|
|
5
5
|
import { S as SVELTE_KIT } from './constants.js';
|
|
6
6
|
import { g as generate_manifest } from './index4.js';
|
|
7
|
-
import { s } from './misc.js';
|
|
8
7
|
import vite from 'vite';
|
|
8
|
+
import { s } from './misc.js';
|
|
9
9
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
10
10
|
import 'sade';
|
|
11
11
|
import 'child_process';
|
|
@@ -358,10 +358,12 @@ export class App {
|
|
|
358
358
|
* output_dir: string;
|
|
359
359
|
* }} options
|
|
360
360
|
* @param {string} runtime
|
|
361
|
+
* @param {{ vite_manifest: import('vite').Manifest, assets: import('rollup').OutputAsset[] }} client
|
|
361
362
|
*/
|
|
362
363
|
async function build_server(
|
|
363
364
|
{ cwd, assets_base, config, manifest_data, build_dir, output_dir },
|
|
364
|
-
runtime
|
|
365
|
+
runtime,
|
|
366
|
+
client
|
|
365
367
|
) {
|
|
366
368
|
let hooks_file = resolve_entry(config.kit.files.hooks);
|
|
367
369
|
if (!hooks_file || !fs__default.existsSync(hooks_file)) {
|
|
@@ -482,10 +484,42 @@ async function build_server(
|
|
|
482
484
|
}
|
|
483
485
|
});
|
|
484
486
|
|
|
487
|
+
/** @type {import('vite').Manifest} */
|
|
488
|
+
const vite_manifest = JSON.parse(fs__default.readFileSync(`${output_dir}/server/manifest.json`, 'utf-8'));
|
|
489
|
+
|
|
490
|
+
const styles_lookup = new Map();
|
|
491
|
+
if (config.kit.amp) {
|
|
492
|
+
client.assets.forEach((asset) => {
|
|
493
|
+
if (asset.fileName.endsWith('.css')) {
|
|
494
|
+
styles_lookup.set(asset.fileName, asset.source);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
mkdirp(`${output_dir}/server/nodes`);
|
|
500
|
+
manifest_data.components.forEach((component, i) => {
|
|
501
|
+
const file = `${output_dir}/server/nodes/${i}.js`;
|
|
502
|
+
|
|
503
|
+
const js = new Set();
|
|
504
|
+
const css = new Set();
|
|
505
|
+
find_deps(component, client.vite_manifest, js, css);
|
|
506
|
+
|
|
507
|
+
const styles = config.kit.amp && Array.from(css).map((file) => styles_lookup.get(file));
|
|
508
|
+
|
|
509
|
+
const node = `import * as module from '../${vite_manifest[component].file}';
|
|
510
|
+
export { module };
|
|
511
|
+
export const entry = '${client.vite_manifest[component].file}';
|
|
512
|
+
export const js = ${JSON.stringify(Array.from(js))};
|
|
513
|
+
export const css = ${JSON.stringify(Array.from(css))};
|
|
514
|
+
${styles ? `export const styles = ${s(styles)}` : ''}
|
|
515
|
+
`.replace(/^\t\t\t/gm, '');
|
|
516
|
+
|
|
517
|
+
fs__default.writeFileSync(file, node);
|
|
518
|
+
});
|
|
519
|
+
|
|
485
520
|
return {
|
|
486
521
|
chunks,
|
|
487
|
-
|
|
488
|
-
vite_manifest: JSON.parse(fs__default.readFileSync(`${output_dir}/server/manifest.json`, 'utf-8')),
|
|
522
|
+
vite_manifest,
|
|
489
523
|
methods: get_methods(cwd, chunks, manifest_data)
|
|
490
524
|
};
|
|
491
525
|
}
|
|
@@ -564,37 +598,7 @@ async function build(config, { cwd = process.cwd(), runtime = './kit.js' } = {})
|
|
|
564
598
|
};
|
|
565
599
|
|
|
566
600
|
const client = await build_client(options);
|
|
567
|
-
const server = await build_server(options, runtime);
|
|
568
|
-
|
|
569
|
-
const styles_lookup = new Map();
|
|
570
|
-
if (options.config.kit.amp) {
|
|
571
|
-
client.assets.forEach((asset) => {
|
|
572
|
-
if (asset.fileName.endsWith('.css')) {
|
|
573
|
-
styles_lookup.set(asset.fileName, asset.source);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
mkdirp(`${output_dir}/server/nodes`);
|
|
579
|
-
options.manifest_data.components.forEach((component, i) => {
|
|
580
|
-
const file = `${output_dir}/server/nodes/${i}.js`;
|
|
581
|
-
|
|
582
|
-
const js = new Set();
|
|
583
|
-
const css = new Set();
|
|
584
|
-
find_deps(component, client.vite_manifest, js, css);
|
|
585
|
-
|
|
586
|
-
const styles = config.kit.amp && Array.from(css).map((file) => styles_lookup.get(file));
|
|
587
|
-
|
|
588
|
-
const node = `import * as module from '../${server.vite_manifest[component].file}';
|
|
589
|
-
export { module };
|
|
590
|
-
export const entry = '${client.vite_manifest[component].file}';
|
|
591
|
-
export const js = ${JSON.stringify(Array.from(js))};
|
|
592
|
-
export const css = ${JSON.stringify(Array.from(css))};
|
|
593
|
-
${styles ? `export const styles = ${s(styles)}` : ''}
|
|
594
|
-
`.replace(/^\t\t\t/gm, '');
|
|
595
|
-
|
|
596
|
-
writeFileSync(file, node);
|
|
597
|
-
});
|
|
601
|
+
const server = await build_server(options, runtime, client);
|
|
598
602
|
|
|
599
603
|
if (options.service_worker_entry_file) {
|
|
600
604
|
if (config.kit.paths.assets) {
|
package/dist/cli.js
CHANGED
|
@@ -887,7 +887,7 @@ async function launch(port, https) {
|
|
|
887
887
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
888
888
|
}
|
|
889
889
|
|
|
890
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
890
|
+
const prog = sade('svelte-kit').version('1.0.0-next.212');
|
|
891
891
|
|
|
892
892
|
prog
|
|
893
893
|
.command('dev')
|
|
@@ -1039,7 +1039,7 @@ async function check_port(port) {
|
|
|
1039
1039
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1040
1040
|
if (open) launch(port, https);
|
|
1041
1041
|
|
|
1042
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1042
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.212'}\n`));
|
|
1043
1043
|
|
|
1044
1044
|
const protocol = https ? 'https:' : 'http:';
|
|
1045
1045
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/dist/ssr.js
CHANGED
package/package.json
CHANGED
|
@@ -93,6 +93,8 @@ declare module '$app/stores' {
|
|
|
93
93
|
page: Readable<{
|
|
94
94
|
url: URL;
|
|
95
95
|
params: Record<string, string>;
|
|
96
|
+
status: number;
|
|
97
|
+
error: Error | null;
|
|
96
98
|
}>;
|
|
97
99
|
session: Writable<Session>;
|
|
98
100
|
};
|
|
@@ -103,6 +105,8 @@ declare module '$app/stores' {
|
|
|
103
105
|
export const page: Readable<{
|
|
104
106
|
url: URL;
|
|
105
107
|
params: Record<string, string>;
|
|
108
|
+
status: number;
|
|
109
|
+
error: Error | null;
|
|
106
110
|
}>;
|
|
107
111
|
/**
|
|
108
112
|
* A readable store.
|