@sveltejs/kit 1.0.0-next.227 → 1.0.0-next.230
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/app → app}/env.js +0 -0
- package/assets/{runtime/app → app}/navigation.js +1 -1
- package/assets/{runtime/app → app}/paths.js +0 -0
- package/assets/{runtime/app → app}/stores.js +0 -0
- package/assets/{runtime/chunks → chunks}/utils.js +0 -0
- package/assets/{runtime/internal → client}/singletons.js +0 -0
- package/assets/{runtime/internal → client}/start.js +3 -5
- package/assets/{runtime/env.js → env.js} +0 -0
- package/assets/{runtime/paths.js → paths.js} +0 -0
- package/assets/{kit.js → server/index.js} +41 -30
- package/dist/chunks/index.js +1943 -29
- package/dist/chunks/index2.js +13 -9
- package/dist/chunks/index3.js +28 -42
- package/dist/chunks/index5.js +1 -3
- package/dist/chunks/index6.js +4 -1
- package/dist/chunks/index7.js +1 -2
- package/dist/cli.js +69 -27
- package/package.json +2 -5
- package/dist/chunks/constants.js +0 -8
- package/dist/chunks/error.js +0 -12
- package/dist/ssr.js +0 -1917
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderer, router as router$1 } from '../
|
|
1
|
+
import { renderer, router as router$1 } from '../client/singletons.js';
|
|
2
2
|
import { g as get_base_uri } from '../chunks/utils.js';
|
|
3
3
|
|
|
4
4
|
const router = /** @type {import('../client/router').Router} */ (router$1);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Root from '
|
|
2
|
-
import { fallback, routes } from '
|
|
1
|
+
import Root from '__GENERATED__/root.svelte';
|
|
2
|
+
import { fallback, routes } from '__GENERATED__/manifest.js';
|
|
3
3
|
import { onMount, tick } from 'svelte';
|
|
4
4
|
import { g as get_base_uri } from '../chunks/utils.js';
|
|
5
5
|
import { writable } from 'svelte/store';
|
|
@@ -156,7 +156,7 @@ class Router {
|
|
|
156
156
|
addEventListener('sveltekit:trigger_prefetch', trigger_prefetch);
|
|
157
157
|
|
|
158
158
|
/** @param {MouseEvent} event */
|
|
159
|
-
addEventListener('click',
|
|
159
|
+
addEventListener('click', (event) => {
|
|
160
160
|
if (!this.enabled) return;
|
|
161
161
|
|
|
162
162
|
// Adapted from https://github.com/visionmedia/page.js
|
|
@@ -1326,8 +1326,6 @@ class Renderer {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
1328
1328
|
|
|
1329
|
-
// @ts-expect-error - doesn't exist yet. generated by Rollup
|
|
1330
|
-
|
|
1331
1329
|
/**
|
|
1332
1330
|
* @param {{
|
|
1333
1331
|
* paths: {
|
|
File without changes
|
|
File without changes
|
|
@@ -537,12 +537,25 @@ function escape(str, dict, unicode_encoder) {
|
|
|
537
537
|
|
|
538
538
|
const s = JSON.stringify;
|
|
539
539
|
|
|
540
|
+
/** @param {URL} url */
|
|
541
|
+
function create_prerendering_url_proxy(url) {
|
|
542
|
+
return new Proxy(url, {
|
|
543
|
+
get: (target, prop, receiver) => {
|
|
544
|
+
if (prop === 'search' || prop === 'searchParams') {
|
|
545
|
+
throw new Error(`Cannot access url.${prop} on a page with prerendering enabled`);
|
|
546
|
+
}
|
|
547
|
+
return Reflect.get(target, prop, receiver);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
540
552
|
// TODO rename this function/module
|
|
541
553
|
|
|
542
554
|
/**
|
|
543
555
|
* @param {{
|
|
544
556
|
* branch: Array<import('./types').Loaded>;
|
|
545
557
|
* options: import('types/internal').SSRRenderOptions;
|
|
558
|
+
* state: import('types/internal').SSRRenderState;
|
|
546
559
|
* $session: any;
|
|
547
560
|
* page_config: { hydrate: boolean, router: boolean };
|
|
548
561
|
* status: number;
|
|
@@ -556,6 +569,7 @@ const s = JSON.stringify;
|
|
|
556
569
|
async function render_response({
|
|
557
570
|
branch,
|
|
558
571
|
options,
|
|
572
|
+
state,
|
|
559
573
|
$session,
|
|
560
574
|
page_config,
|
|
561
575
|
status,
|
|
@@ -605,7 +619,13 @@ async function render_response({
|
|
|
605
619
|
navigating: writable(null),
|
|
606
620
|
session
|
|
607
621
|
},
|
|
608
|
-
page: {
|
|
622
|
+
page: {
|
|
623
|
+
url: state.prerender ? create_prerendering_url_proxy(url) : url,
|
|
624
|
+
params,
|
|
625
|
+
status,
|
|
626
|
+
error,
|
|
627
|
+
stuff
|
|
628
|
+
},
|
|
609
629
|
components: branch.map(({ node }) => node.module.default)
|
|
610
630
|
};
|
|
611
631
|
|
|
@@ -895,7 +915,6 @@ function is_root_relative(path) {
|
|
|
895
915
|
* node: import('types/internal').SSRNode;
|
|
896
916
|
* $session: any;
|
|
897
917
|
* stuff: Record<string, any>;
|
|
898
|
-
* prerender_enabled: boolean;
|
|
899
918
|
* is_error: boolean;
|
|
900
919
|
* status?: number;
|
|
901
920
|
* error?: Error;
|
|
@@ -912,7 +931,6 @@ async function load_node({
|
|
|
912
931
|
node,
|
|
913
932
|
$session,
|
|
914
933
|
stuff,
|
|
915
|
-
prerender_enabled,
|
|
916
934
|
is_error,
|
|
917
935
|
status,
|
|
918
936
|
error
|
|
@@ -937,19 +955,10 @@ async function load_node({
|
|
|
937
955
|
|
|
938
956
|
let loaded;
|
|
939
957
|
|
|
940
|
-
const url_proxy = new Proxy(url, {
|
|
941
|
-
get: (target, prop, receiver) => {
|
|
942
|
-
if (prerender_enabled && (prop === 'search' || prop === 'searchParams')) {
|
|
943
|
-
throw new Error('Cannot access query on a page with prerendering enabled');
|
|
944
|
-
}
|
|
945
|
-
return Reflect.get(target, prop, receiver);
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
|
|
949
958
|
if (module.load) {
|
|
950
959
|
/** @type {import('types/page').LoadInput | import('types/page').ErrorLoadInput} */
|
|
951
960
|
const load_input = {
|
|
952
|
-
url:
|
|
961
|
+
url: state.prerender ? create_prerendering_url_proxy(url) : url,
|
|
953
962
|
params,
|
|
954
963
|
get session() {
|
|
955
964
|
uses_credentials = true;
|
|
@@ -1196,7 +1205,6 @@ async function load_node({
|
|
|
1196
1205
|
|
|
1197
1206
|
/**
|
|
1198
1207
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
1199
|
-
* @typedef {import('types/internal').SSRNode} SSRNode
|
|
1200
1208
|
* @typedef {import('types/internal').SSRRenderOptions} SSRRenderOptions
|
|
1201
1209
|
* @typedef {import('types/internal').SSRRenderState} SSRRenderState
|
|
1202
1210
|
*/
|
|
@@ -1239,7 +1247,6 @@ async function respond_with_error({
|
|
|
1239
1247
|
node: default_layout,
|
|
1240
1248
|
$session,
|
|
1241
1249
|
stuff: {},
|
|
1242
|
-
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
|
1243
1250
|
is_error: false
|
|
1244
1251
|
})
|
|
1245
1252
|
);
|
|
@@ -1255,7 +1262,6 @@ async function respond_with_error({
|
|
|
1255
1262
|
node: default_error,
|
|
1256
1263
|
$session,
|
|
1257
1264
|
stuff: layout_loaded ? layout_loaded.stuff : {},
|
|
1258
|
-
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
|
1259
1265
|
is_error: true,
|
|
1260
1266
|
status,
|
|
1261
1267
|
error
|
|
@@ -1264,6 +1270,7 @@ async function respond_with_error({
|
|
|
1264
1270
|
|
|
1265
1271
|
return await render_response({
|
|
1266
1272
|
options,
|
|
1273
|
+
state,
|
|
1267
1274
|
$session,
|
|
1268
1275
|
page_config: {
|
|
1269
1276
|
hydrate: options.hydrate,
|
|
@@ -1290,17 +1297,6 @@ async function respond_with_error({
|
|
|
1290
1297
|
}
|
|
1291
1298
|
}
|
|
1292
1299
|
|
|
1293
|
-
/**
|
|
1294
|
-
* @param {SSRRenderOptions} options
|
|
1295
|
-
* @param {SSRNode} node
|
|
1296
|
-
* @param {SSRRenderState} state
|
|
1297
|
-
*/
|
|
1298
|
-
function is_prerender_enabled(options, node, state) {
|
|
1299
|
-
return (
|
|
1300
|
-
options.prerender && (!!node.module.prerender || (!!state.prerender && state.prerender.all))
|
|
1301
|
-
);
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
1300
|
/**
|
|
1305
1301
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
1306
1302
|
* @typedef {import('types/hooks').ServerResponse} ServerResponse
|
|
@@ -1403,7 +1399,6 @@ async function respond$1(opts) {
|
|
|
1403
1399
|
url: request.url,
|
|
1404
1400
|
node,
|
|
1405
1401
|
stuff,
|
|
1406
|
-
prerender_enabled: is_prerender_enabled(options, node, state),
|
|
1407
1402
|
is_error: false
|
|
1408
1403
|
});
|
|
1409
1404
|
|
|
@@ -1458,7 +1453,6 @@ async function respond$1(opts) {
|
|
|
1458
1453
|
url: request.url,
|
|
1459
1454
|
node: error_node,
|
|
1460
1455
|
stuff: node_loaded.stuff,
|
|
1461
|
-
prerender_enabled: is_prerender_enabled(options, error_node, state),
|
|
1462
1456
|
is_error: true,
|
|
1463
1457
|
status,
|
|
1464
1458
|
error
|
|
@@ -1892,6 +1886,7 @@ async function respond(incoming, options, state = {}) {
|
|
|
1892
1886
|
url: request.url,
|
|
1893
1887
|
params: request.params,
|
|
1894
1888
|
options,
|
|
1889
|
+
state,
|
|
1895
1890
|
$session: await options.hooks.getSession(request),
|
|
1896
1891
|
page_config: { router: true, hydrate: true },
|
|
1897
1892
|
stuff: {},
|
|
@@ -1926,9 +1921,25 @@ async function respond(incoming, options, state = {}) {
|
|
|
1926
1921
|
const etag = `"${hash(response.body || '')}"`;
|
|
1927
1922
|
|
|
1928
1923
|
if (if_none_match_value === etag) {
|
|
1924
|
+
/** @type {import('types/helper').ResponseHeaders} */
|
|
1925
|
+
const headers = { etag };
|
|
1926
|
+
|
|
1927
|
+
// https://datatracker.ietf.org/doc/html/rfc7232#section-4.1
|
|
1928
|
+
for (const key of [
|
|
1929
|
+
'cache-control',
|
|
1930
|
+
'content-location',
|
|
1931
|
+
'date',
|
|
1932
|
+
'expires',
|
|
1933
|
+
'vary'
|
|
1934
|
+
]) {
|
|
1935
|
+
if (key in response.headers) {
|
|
1936
|
+
headers[key] = /** @type {string} */ (response.headers[key]);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1929
1940
|
return {
|
|
1930
1941
|
status: 304,
|
|
1931
|
-
headers
|
|
1942
|
+
headers
|
|
1932
1943
|
};
|
|
1933
1944
|
}
|
|
1934
1945
|
|