@sveltejs/kit 1.0.0-next.214 → 1.0.0-next.218
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 +22 -13
- package/assets/runtime/internal/start.js +15 -12
- package/dist/chunks/error.js +1 -10
- package/dist/chunks/index.js +5 -5
- package/dist/chunks/index3.js +11 -8
- package/dist/chunks/index5.js +3 -1
- package/dist/chunks/url.js +1 -1
- package/dist/cli.js +42 -83
- package/dist/ssr.js +21 -12
- package/package.json +9 -2
- package/types/config.d.ts +2 -0
- package/types/endpoint.d.ts +1 -1
- package/types/hooks.d.ts +1 -1
- package/types/internal.d.ts +1 -1
package/assets/kit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Record<string, string | string[]>} headers
|
|
2
|
+
* @param {Record<string, string | string[] | undefined>} headers
|
|
3
3
|
* @param {string} key
|
|
4
4
|
* @returns {string | undefined}
|
|
5
5
|
* @throws {Error}
|
|
@@ -68,21 +68,24 @@ function is_string(s) {
|
|
|
68
68
|
return typeof s === 'string' || s instanceof String;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
const text_types = new Set([
|
|
72
|
+
'application/xml',
|
|
73
|
+
'application/json',
|
|
74
|
+
'application/x-www-form-urlencoded',
|
|
75
|
+
'multipart/form-data'
|
|
76
|
+
]);
|
|
77
|
+
|
|
71
78
|
/**
|
|
72
79
|
* Decides how the body should be parsed based on its mime type. Should match what's in parse_body
|
|
73
80
|
*
|
|
74
81
|
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
|
75
82
|
* @returns {boolean}
|
|
76
83
|
*/
|
|
77
|
-
function
|
|
84
|
+
function is_text(content_type) {
|
|
78
85
|
if (!content_type) return true; // defaults to json
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
type === 'application/json' ||
|
|
83
|
-
type === 'application/x-www-form-urlencoded' ||
|
|
84
|
-
type === 'multipart/form-data'
|
|
85
|
-
);
|
|
86
|
+
const type = content_type.split(';')[0].toLowerCase(); // get the mime type
|
|
87
|
+
|
|
88
|
+
return type.startsWith('text/') || type.endsWith('+xml') || text_types.has(type);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
/**
|
|
@@ -121,9 +124,7 @@ async function render_endpoint(request, route, match) {
|
|
|
121
124
|
headers = lowercase_keys(headers);
|
|
122
125
|
const type = get_single_valued_header(headers, 'content-type');
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (!is_type_textual && !(body instanceof Uint8Array || is_string(body))) {
|
|
127
|
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
|
127
128
|
return error(
|
|
128
129
|
`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`
|
|
129
130
|
);
|
|
@@ -743,10 +744,18 @@ async function render_response({
|
|
|
743
744
|
headers['permissions-policy'] = 'interest-cohort=()';
|
|
744
745
|
}
|
|
745
746
|
|
|
747
|
+
const segments = url.pathname.slice(options.paths.base.length).split('/').slice(2);
|
|
748
|
+
const assets =
|
|
749
|
+
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');
|
|
750
|
+
|
|
746
751
|
return {
|
|
747
752
|
status,
|
|
748
753
|
headers,
|
|
749
|
-
body: options.template({
|
|
754
|
+
body: options.template({
|
|
755
|
+
head,
|
|
756
|
+
body,
|
|
757
|
+
assets
|
|
758
|
+
})
|
|
750
759
|
};
|
|
751
760
|
}
|
|
752
761
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Root from '../../generated/root.svelte';
|
|
2
2
|
import { fallback, routes } from '../../generated/manifest.js';
|
|
3
3
|
import { g as get_base_uri } from '../chunks/utils.js';
|
|
4
|
+
import { tick } from 'svelte';
|
|
4
5
|
import { writable } from 'svelte/store';
|
|
5
6
|
import { init } from './singletons.js';
|
|
6
7
|
import { set_paths } from '../paths.js';
|
|
@@ -162,16 +163,17 @@ class Router {
|
|
|
162
163
|
|
|
163
164
|
if (!this.owns(url)) return;
|
|
164
165
|
|
|
165
|
-
|
|
166
|
+
// Check if new url only differs by hash
|
|
167
|
+
if (url.href.split('#')[0] === location.href.split('#')[0]) {
|
|
168
|
+
// Call `pushState` to add url to history so going back works.
|
|
169
|
+
// Also make a delay, otherwise the browser default behaviour would not kick in
|
|
170
|
+
setTimeout(() => history.pushState({}, '', url.href));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
166
173
|
|
|
167
|
-
const i1 = url_string.indexOf('#');
|
|
168
|
-
const i2 = location.href.indexOf('#');
|
|
169
|
-
const u1 = i1 >= 0 ? url_string.substring(0, i1) : url_string;
|
|
170
|
-
const u2 = i2 >= 0 ? location.href.substring(0, i2) : location.href;
|
|
171
174
|
history.pushState({}, '', url.href);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
+
|
|
176
|
+
const noscroll = a.hasAttribute('sveltekit:noscroll');
|
|
175
177
|
this._navigate(url, noscroll ? scroll_state() : null, false, [], url.hash);
|
|
176
178
|
event.preventDefault();
|
|
177
179
|
});
|
|
@@ -660,7 +662,7 @@ class Renderer {
|
|
|
660
662
|
this._init(navigation_result);
|
|
661
663
|
}
|
|
662
664
|
|
|
663
|
-
// opts must be passed if we're navigating
|
|
665
|
+
// opts must be passed if we're navigating
|
|
664
666
|
if (opts) {
|
|
665
667
|
const { hash, scroll, keepfocus } = opts;
|
|
666
668
|
|
|
@@ -669,7 +671,8 @@ class Renderer {
|
|
|
669
671
|
document.body.focus();
|
|
670
672
|
}
|
|
671
673
|
|
|
672
|
-
|
|
674
|
+
// need to render the DOM before we can scroll to the rendered elements
|
|
675
|
+
await tick();
|
|
673
676
|
|
|
674
677
|
if (this.autoscroll) {
|
|
675
678
|
const deep_linked = hash && document.getElementById(hash.slice(1));
|
|
@@ -685,8 +688,8 @@ class Renderer {
|
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
690
|
} else {
|
|
688
|
-
//
|
|
689
|
-
await
|
|
691
|
+
// in this case we're simply invalidating
|
|
692
|
+
await tick();
|
|
690
693
|
}
|
|
691
694
|
|
|
692
695
|
this.loading.promise = null;
|
package/dist/chunks/error.js
CHANGED
|
@@ -9,13 +9,4 @@ function coalesce_to_error(err) {
|
|
|
9
9
|
: new Error(JSON.stringify(err));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* @param {Error} err
|
|
14
|
-
* @param {any} errorCode
|
|
15
|
-
* @return {err is Error & {code: any}}
|
|
16
|
-
*/
|
|
17
|
-
function has_error_code(err, errorCode = undefined) {
|
|
18
|
-
return 'code' in err && (errorCode === undefined || /** @type {any} */ (err).code === errorCode);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { coalesce_to_error as c, has_error_code as h };
|
|
12
|
+
export { coalesce_to_error as c };
|
package/dist/chunks/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import 'querystring';
|
|
|
12
12
|
import { URL } from 'url';
|
|
13
13
|
import require$$10 from 'vm';
|
|
14
14
|
import vite from 'vite';
|
|
15
|
-
import { r as resolve_entry, $, g as get_mime_lookup, a as rimraf, c as copy_assets, p as print_config_conflicts } from '../cli.js';
|
|
15
|
+
import { r as resolve_entry, $, l as load_template, g as get_mime_lookup, a as rimraf, c as copy_assets, p as print_config_conflicts } from '../cli.js';
|
|
16
16
|
import { c as create_manifest_data, a as create_app, d as deep_merge } from './index2.js';
|
|
17
17
|
import { S as SVELTE_KIT, a as SVELTE_KIT_ASSETS } from './constants.js';
|
|
18
18
|
import { respond } from '../ssr.js';
|
|
@@ -4406,11 +4406,11 @@ function create_plugin(config, output, cwd, amp) {
|
|
|
4406
4406
|
router: config.kit.router,
|
|
4407
4407
|
ssr: config.kit.ssr,
|
|
4408
4408
|
target: config.kit.target,
|
|
4409
|
-
template: ({ head, body }) => {
|
|
4410
|
-
let rendered =
|
|
4411
|
-
.readFileSync(config.kit.files.template, 'utf8')
|
|
4409
|
+
template: ({ head, body, assets }) => {
|
|
4410
|
+
let rendered = load_template(cwd, config)
|
|
4412
4411
|
.replace('%svelte.head%', () => head)
|
|
4413
|
-
.replace('%svelte.body%', () => body)
|
|
4412
|
+
.replace('%svelte.body%', () => body)
|
|
4413
|
+
.replace(/%svelte\.assets%/g, assets);
|
|
4414
4414
|
|
|
4415
4415
|
if (amp) {
|
|
4416
4416
|
const result = amp.validateString(rendered);
|
package/dist/chunks/index3.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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, m as mkdirp, a as rimraf } from '../cli.js';
|
|
3
|
+
import { p as print_config_conflicts, c as copy_assets, b as posixify, r as resolve_entry, l as load_template, 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';
|
|
@@ -247,23 +247,25 @@ async function build_client({
|
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
249
|
* @param {{
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
250
|
+
* cwd: string;
|
|
251
|
+
* runtime: string;
|
|
252
|
+
* hooks: string;
|
|
253
|
+
* config: import('types/config').ValidatedConfig;
|
|
254
|
+
* has_service_worker: boolean;
|
|
254
255
|
* }} opts
|
|
255
256
|
* @returns
|
|
256
257
|
*/
|
|
257
|
-
const template = ({ config, hooks, runtime, has_service_worker }) => `
|
|
258
|
+
const template = ({ cwd, config, hooks, runtime, has_service_worker }) => `
|
|
258
259
|
import { respond } from '${runtime}';
|
|
259
260
|
import root from './generated/root.svelte';
|
|
260
261
|
import { set_paths, assets, base } from './runtime/paths.js';
|
|
261
262
|
import { set_prerendering } from './runtime/env.js';
|
|
262
263
|
import * as user_hooks from ${s(hooks)};
|
|
263
264
|
|
|
264
|
-
const template = ({ head, body }) => ${s(
|
|
265
|
+
const template = ({ head, body, assets }) => ${s(load_template(cwd, config))
|
|
265
266
|
.replace('%svelte.head%', '" + head + "')
|
|
266
|
-
.replace('%svelte.body%', '" + body + "')
|
|
267
|
+
.replace('%svelte.body%', '" + body + "')
|
|
268
|
+
.replace(/%svelte\.assets%/g, '" + assets + "')};
|
|
267
269
|
|
|
268
270
|
let read = null;
|
|
269
271
|
|
|
@@ -415,6 +417,7 @@ async function build_server(
|
|
|
415
417
|
fs__default.writeFileSync(
|
|
416
418
|
input.app,
|
|
417
419
|
template({
|
|
420
|
+
cwd,
|
|
418
421
|
config,
|
|
419
422
|
hooks: app_relative(hooks_file),
|
|
420
423
|
runtime,
|
package/dist/chunks/index5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as mkdirp, a as rimraf, d as copy, $,
|
|
1
|
+
import { m as mkdirp, a as rimraf, d as copy, $, e as logger } from '../cli.js';
|
|
2
2
|
import { S as SVELTE_KIT } from './constants.js';
|
|
3
3
|
import { readFileSync, writeFileSync } from 'fs';
|
|
4
4
|
import { resolve, join, dirname } from 'path';
|
|
@@ -470,6 +470,8 @@ function create_builder({ cwd, config, build_data, log }) {
|
|
|
470
470
|
mkdirp,
|
|
471
471
|
copy,
|
|
472
472
|
|
|
473
|
+
appDir: config.kit.appDir,
|
|
474
|
+
|
|
473
475
|
createEntries(fn) {
|
|
474
476
|
generated_manifest = true;
|
|
475
477
|
|
package/dist/chunks/url.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import fs__default, { existsSync } from 'fs';
|
|
2
1
|
import sade from 'sade';
|
|
3
2
|
import path__default, { relative } from 'path';
|
|
4
3
|
import { exec as exec$1 } from 'child_process';
|
|
5
4
|
import { createConnection, createServer } from 'net';
|
|
5
|
+
import fs__default from 'fs';
|
|
6
6
|
import * as url from 'url';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { networkInterfaces, release } from 'os';
|
|
9
|
-
import { c as coalesce_to_error
|
|
9
|
+
import { c as coalesce_to_error } from './chunks/error.js';
|
|
10
10
|
|
|
11
11
|
let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;
|
|
12
12
|
if (typeof process !== 'undefined') {
|
|
@@ -740,10 +740,10 @@ function assert_string(input, keypath) {
|
|
|
740
740
|
|
|
741
741
|
/**
|
|
742
742
|
* @param {string} cwd
|
|
743
|
-
* @param {import('types/config').ValidatedConfig}
|
|
743
|
+
* @param {import('types/config').ValidatedConfig} config
|
|
744
744
|
*/
|
|
745
|
-
function
|
|
746
|
-
const { template } =
|
|
745
|
+
function load_template(cwd, config) {
|
|
746
|
+
const { template } = config.kit.files;
|
|
747
747
|
const relative = path__default.relative(cwd, template);
|
|
748
748
|
|
|
749
749
|
if (fs__default.existsSync(template)) {
|
|
@@ -757,13 +757,19 @@ function validate_template(cwd, validated) {
|
|
|
757
757
|
} else {
|
|
758
758
|
throw new Error(`${relative} does not exist`);
|
|
759
759
|
}
|
|
760
|
+
|
|
761
|
+
return fs__default.readFileSync(template, 'utf-8');
|
|
760
762
|
}
|
|
761
763
|
|
|
762
764
|
async function load_config({ cwd = process.cwd() } = {}) {
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
765
|
+
const config_file = path__default.join(cwd, 'svelte.config.js');
|
|
766
|
+
|
|
767
|
+
if (!fs__default.existsSync(config_file)) {
|
|
768
|
+
throw new Error(
|
|
769
|
+
'You need to create a svelte.config.js file. See https://kit.svelte.dev/docs#configuration'
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
|
|
767
773
|
const config = await import(url.pathToFileURL(config_file).href);
|
|
768
774
|
|
|
769
775
|
const validated = validate_config(config.default);
|
|
@@ -775,10 +781,6 @@ async function load_config({ cwd = process.cwd() } = {}) {
|
|
|
775
781
|
validated.kit.files.serviceWorker = path__default.resolve(cwd, validated.kit.files.serviceWorker);
|
|
776
782
|
validated.kit.files.template = path__default.resolve(cwd, validated.kit.files.template);
|
|
777
783
|
|
|
778
|
-
validate_template(cwd, validated);
|
|
779
|
-
|
|
780
|
-
// TODO check all the `files` exist when the config is loaded?
|
|
781
|
-
|
|
782
784
|
return validated;
|
|
783
785
|
}
|
|
784
786
|
|
|
@@ -787,17 +789,9 @@ async function load_config({ cwd = process.cwd() } = {}) {
|
|
|
787
789
|
* @returns {import('types/config').ValidatedConfig}
|
|
788
790
|
*/
|
|
789
791
|
function validate_config(config) {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
if (type === 'undefined') {
|
|
793
|
-
throw new Error(
|
|
794
|
-
'Your config is missing default exports. Make sure to include "export default config;"'
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
if (type !== 'object') {
|
|
792
|
+
if (typeof config !== 'object') {
|
|
799
793
|
throw new Error(
|
|
800
|
-
|
|
794
|
+
'svelte.config.js must have a configuration object as its default export. See https://kit.svelte.dev/docs#configuration'
|
|
801
795
|
);
|
|
802
796
|
}
|
|
803
797
|
|
|
@@ -819,52 +813,17 @@ function print_config_conflicts(conflicts, pathPrefix = '', scope) {
|
|
|
819
813
|
});
|
|
820
814
|
}
|
|
821
815
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
// prettier-ignore
|
|
826
|
-
console.error($.bold().red(
|
|
827
|
-
'svelte.config.cjs should be renamed to svelte.config.js and converted to an ES module. See https://kit.svelte.dev/docs#configuration for an example'
|
|
828
|
-
));
|
|
829
|
-
}
|
|
816
|
+
/** @param {unknown} e */
|
|
817
|
+
function handle_error(e) {
|
|
818
|
+
const error = coalesce_to_error(e);
|
|
830
819
|
|
|
831
|
-
if (
|
|
832
|
-
// prettier-ignore
|
|
833
|
-
console.error($.bold().red(
|
|
834
|
-
'Please remove vite.config.js and put Vite config in svelte.config.js: https://kit.svelte.dev/docs#configuration-vite'
|
|
835
|
-
));
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
try {
|
|
839
|
-
return await load_config();
|
|
840
|
-
} catch (err) {
|
|
841
|
-
const error = coalesce_to_error(err);
|
|
842
|
-
let message = error.message;
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
has_error_code(error, 'MODULE_NOT_FOUND') &&
|
|
846
|
-
/Cannot find module svelte\.config\./.test(error.message)
|
|
847
|
-
) {
|
|
848
|
-
message = 'Missing svelte.config.js';
|
|
849
|
-
} else if (error.name === 'SyntaxError') {
|
|
850
|
-
message = 'Malformed svelte.config.js';
|
|
851
|
-
}
|
|
820
|
+
if (error.name === 'SyntaxError') throw error;
|
|
852
821
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
process.exit(1);
|
|
822
|
+
console.log($.bold().red(`> ${error.message}`));
|
|
823
|
+
if (error.stack) {
|
|
824
|
+
console.log($.gray(error.stack.split('\n').slice(1).join('\n')));
|
|
858
825
|
}
|
|
859
|
-
}
|
|
860
826
|
|
|
861
|
-
/** @param {unknown} error */
|
|
862
|
-
function handle_error(error) {
|
|
863
|
-
const err = coalesce_to_error(error);
|
|
864
|
-
console.log($.bold().red(`> ${err.message}`));
|
|
865
|
-
if (err.stack) {
|
|
866
|
-
console.log($.gray(err.stack));
|
|
867
|
-
}
|
|
868
827
|
process.exit(1);
|
|
869
828
|
}
|
|
870
829
|
|
|
@@ -887,7 +846,7 @@ async function launch(port, https) {
|
|
|
887
846
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
888
847
|
}
|
|
889
848
|
|
|
890
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
849
|
+
const prog = sade('svelte-kit').version('1.0.0-next.218');
|
|
891
850
|
|
|
892
851
|
prog
|
|
893
852
|
.command('dev')
|
|
@@ -897,12 +856,12 @@ prog
|
|
|
897
856
|
.option('-H, --https', 'Use self-signed HTTPS certificate')
|
|
898
857
|
.option('-o, --open', 'Open a browser tab')
|
|
899
858
|
.action(async ({ port, host, https, open }) => {
|
|
900
|
-
|
|
901
|
-
|
|
859
|
+
try {
|
|
860
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
861
|
+
const config = await load_config();
|
|
902
862
|
|
|
903
|
-
|
|
863
|
+
const { dev } = await import('./chunks/index.js');
|
|
904
864
|
|
|
905
|
-
try {
|
|
906
865
|
const cwd = process.cwd();
|
|
907
866
|
|
|
908
867
|
const { address_info, server_config } = await dev({
|
|
@@ -932,10 +891,10 @@ prog
|
|
|
932
891
|
.describe('Create a production build of your app')
|
|
933
892
|
.option('--verbose', 'Log more stuff', false)
|
|
934
893
|
.action(async ({ verbose }) => {
|
|
935
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
936
|
-
const config = await get_config();
|
|
937
|
-
|
|
938
894
|
try {
|
|
895
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
896
|
+
const config = await load_config();
|
|
897
|
+
|
|
939
898
|
const { build } = await import('./chunks/index3.js');
|
|
940
899
|
const build_data = await build(config);
|
|
941
900
|
|
|
@@ -970,14 +929,14 @@ prog
|
|
|
970
929
|
.option('-H, --https', 'Use self-signed HTTPS certificate', false)
|
|
971
930
|
.option('-o, --open', 'Open a browser tab', false)
|
|
972
931
|
.action(async ({ port, host, https, open }) => {
|
|
973
|
-
|
|
932
|
+
try {
|
|
933
|
+
await check_port(port);
|
|
974
934
|
|
|
975
|
-
|
|
976
|
-
|
|
935
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
936
|
+
const config = await load_config();
|
|
977
937
|
|
|
978
|
-
|
|
938
|
+
const { preview } = await import('./chunks/index6.js');
|
|
979
939
|
|
|
980
|
-
try {
|
|
981
940
|
await preview({ port, host, config, https });
|
|
982
941
|
|
|
983
942
|
welcome({ port, host, https, open });
|
|
@@ -991,11 +950,11 @@ prog
|
|
|
991
950
|
.describe('Create a package')
|
|
992
951
|
.option('-d, --dir', 'Destination directory', 'package')
|
|
993
952
|
.action(async () => {
|
|
994
|
-
|
|
953
|
+
try {
|
|
954
|
+
const config = await load_config();
|
|
995
955
|
|
|
996
|
-
|
|
956
|
+
const { make_package } = await import('./chunks/index7.js');
|
|
997
957
|
|
|
998
|
-
try {
|
|
999
958
|
await make_package(config);
|
|
1000
959
|
} catch (error) {
|
|
1001
960
|
handle_error(error);
|
|
@@ -1039,7 +998,7 @@ async function check_port(port) {
|
|
|
1039
998
|
function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
1040
999
|
if (open) launch(port, https);
|
|
1041
1000
|
|
|
1042
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1001
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.218'}\n`));
|
|
1043
1002
|
|
|
1044
1003
|
const protocol = https ? 'https:' : 'http:';
|
|
1045
1004
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1076,4 +1035,4 @@ function welcome({ port, host, https, open, loose, allow, cwd }) {
|
|
|
1076
1035
|
console.log('\n');
|
|
1077
1036
|
}
|
|
1078
1037
|
|
|
1079
|
-
export { $, rimraf as a, posixify as b, copy_assets as c, copy as d, get_mime_lookup as g,
|
|
1038
|
+
export { $, rimraf as a, posixify as b, copy_assets as c, copy as d, logger as e, get_mime_lookup as g, load_template as l, mkdirp as m, print_config_conflicts as p, resolve_entry as r, walk as w };
|
package/dist/ssr.js
CHANGED
|
@@ -50,21 +50,24 @@ function is_string(s) {
|
|
|
50
50
|
return typeof s === 'string' || s instanceof String;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const text_types = new Set([
|
|
54
|
+
'application/xml',
|
|
55
|
+
'application/json',
|
|
56
|
+
'application/x-www-form-urlencoded',
|
|
57
|
+
'multipart/form-data'
|
|
58
|
+
]);
|
|
59
|
+
|
|
53
60
|
/**
|
|
54
61
|
* Decides how the body should be parsed based on its mime type. Should match what's in parse_body
|
|
55
62
|
*
|
|
56
63
|
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
|
57
64
|
* @returns {boolean}
|
|
58
65
|
*/
|
|
59
|
-
function
|
|
66
|
+
function is_text(content_type) {
|
|
60
67
|
if (!content_type) return true; // defaults to json
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type === 'application/json' ||
|
|
65
|
-
type === 'application/x-www-form-urlencoded' ||
|
|
66
|
-
type === 'multipart/form-data'
|
|
67
|
-
);
|
|
68
|
+
const type = content_type.split(';')[0].toLowerCase(); // get the mime type
|
|
69
|
+
|
|
70
|
+
return type.startsWith('text/') || type.endsWith('+xml') || text_types.has(type);
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
/**
|
|
@@ -103,9 +106,7 @@ async function render_endpoint(request, route, match) {
|
|
|
103
106
|
headers = lowercase_keys(headers);
|
|
104
107
|
const type = get_single_valued_header(headers, 'content-type');
|
|
105
108
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!is_type_textual && !(body instanceof Uint8Array || is_string(body))) {
|
|
109
|
+
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) {
|
|
109
110
|
return error(
|
|
110
111
|
`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`
|
|
111
112
|
);
|
|
@@ -712,10 +713,18 @@ async function render_response({
|
|
|
712
713
|
headers['permissions-policy'] = 'interest-cohort=()';
|
|
713
714
|
}
|
|
714
715
|
|
|
716
|
+
const segments = url.pathname.slice(options.paths.base.length).split('/').slice(2);
|
|
717
|
+
const assets =
|
|
718
|
+
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');
|
|
719
|
+
|
|
715
720
|
return {
|
|
716
721
|
status,
|
|
717
722
|
headers,
|
|
718
|
-
body: options.template({
|
|
723
|
+
body: options.template({
|
|
724
|
+
head,
|
|
725
|
+
body,
|
|
726
|
+
assets
|
|
727
|
+
})
|
|
719
728
|
};
|
|
720
729
|
}
|
|
721
730
|
|
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.218",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"vite": "^2.7.2"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@playwright/test": "^1.17.1",
|
|
18
19
|
"@rollup/plugin-replace": "^3.0.0",
|
|
19
20
|
"@types/amphtml-validator": "^1.0.1",
|
|
20
21
|
"@types/cookie": "^0.4.1",
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"@types/sade": "^1.7.3",
|
|
25
26
|
"amphtml-validator": "^1.0.35",
|
|
26
27
|
"cookie": "^0.4.1",
|
|
28
|
+
"cross-env": "^7.0.3",
|
|
27
29
|
"devalue": "^2.0.1",
|
|
28
30
|
"eslint": "^8.3.0",
|
|
29
31
|
"kleur": "^4.1.4",
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
"sirv": "^1.0.19",
|
|
38
40
|
"svelte": "^3.44.2",
|
|
39
41
|
"svelte-check": "^2.2.10",
|
|
42
|
+
"svelte-preprocess": "^4.9.8",
|
|
40
43
|
"svelte2tsx": "~0.4.10",
|
|
41
44
|
"tiny-glob": "^0.2.9",
|
|
42
45
|
"uvu": "^0.5.2"
|
|
@@ -85,6 +88,10 @@
|
|
|
85
88
|
"test": "npm run test:unit && npm run test:packaging && npm run test:integration",
|
|
86
89
|
"test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
|
|
87
90
|
"test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
|
|
88
|
-
"test:integration": "
|
|
91
|
+
"test:integration": "pnpm test:integration:amp && pnpm test:integration:basics && pnpm test:integration:options && pnpm test:integration:options-2",
|
|
92
|
+
"test:integration:amp": "cd test/apps/amp && pnpm test",
|
|
93
|
+
"test:integration:basics": "cd test/apps/basics && pnpm test",
|
|
94
|
+
"test:integration:options": "cd test/apps/options && pnpm test",
|
|
95
|
+
"test:integration:options-2": "cd test/apps/options-2 && pnpm test"
|
|
89
96
|
}
|
|
90
97
|
}
|
package/types/config.d.ts
CHANGED
package/types/endpoint.d.ts
CHANGED
package/types/hooks.d.ts
CHANGED
package/types/internal.d.ts
CHANGED
|
@@ -144,7 +144,7 @@ export interface SSRRenderOptions {
|
|
|
144
144
|
service_worker?: string;
|
|
145
145
|
ssr: boolean;
|
|
146
146
|
target: string;
|
|
147
|
-
template({ head, body }: { head: string; body: string }): string;
|
|
147
|
+
template({ head, body, assets }: { head: string; body: string; assets: string }): string;
|
|
148
148
|
trailing_slash: TrailingSlash;
|
|
149
149
|
}
|
|
150
150
|
|