@sveltejs/kit 1.0.0-next.217 → 1.0.0-next.220
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 +65 -43
- package/assets/runtime/internal/start.js +7 -0
- package/dist/chunks/index.js +36 -4207
- package/dist/chunks/index2.js +31 -29
- package/dist/chunks/index3.js +3 -2
- package/dist/chunks/index5.js +8 -1
- package/dist/chunks/index6.js +20 -20
- package/dist/chunks/index8.js +4207 -0
- package/dist/cli.js +2 -2
- package/dist/ssr.js +65 -43
- package/package.json +2 -2
- package/types/config.d.ts +2 -0
- package/types/internal.d.ts +1 -1
package/assets/kit.js
CHANGED
|
@@ -744,10 +744,18 @@ async function render_response({
|
|
|
744
744
|
headers['permissions-policy'] = 'interest-cohort=()';
|
|
745
745
|
}
|
|
746
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
|
+
|
|
747
751
|
return {
|
|
748
752
|
status,
|
|
749
753
|
headers,
|
|
750
|
-
body: options.template({
|
|
754
|
+
body: options.template({
|
|
755
|
+
head,
|
|
756
|
+
body,
|
|
757
|
+
assets
|
|
758
|
+
})
|
|
751
759
|
};
|
|
752
760
|
}
|
|
753
761
|
|
|
@@ -1214,53 +1222,53 @@ async function load_node({
|
|
|
1214
1222
|
* }} opts
|
|
1215
1223
|
*/
|
|
1216
1224
|
async function respond_with_error({ request, options, state, $session, status, error }) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
/** @type {Record<string, string>} */
|
|
1221
|
-
const params = {}; // error page has no params
|
|
1225
|
+
try {
|
|
1226
|
+
const default_layout = await options.manifest._.nodes[0](); // 0 is always the root layout
|
|
1227
|
+
const default_error = await options.manifest._.nodes[1](); // 1 is always the root error
|
|
1222
1228
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
await load_node({
|
|
1226
|
-
request,
|
|
1227
|
-
options,
|
|
1228
|
-
state,
|
|
1229
|
-
route: null,
|
|
1230
|
-
url: request.url, // TODO this is redundant, no?
|
|
1231
|
-
params,
|
|
1232
|
-
node: default_layout,
|
|
1233
|
-
$session,
|
|
1234
|
-
stuff: {},
|
|
1235
|
-
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
|
1236
|
-
is_leaf: false,
|
|
1237
|
-
is_error: false
|
|
1238
|
-
})
|
|
1239
|
-
);
|
|
1229
|
+
/** @type {Record<string, string>} */
|
|
1230
|
+
const params = {}; // error page has no params
|
|
1240
1231
|
|
|
1241
|
-
|
|
1242
|
-
loaded
|
|
1243
|
-
/** @type {Loaded} */ (
|
|
1232
|
+
// error pages don't fall through, so we know it's not undefined
|
|
1233
|
+
const loaded = /** @type {Loaded} */ (
|
|
1244
1234
|
await load_node({
|
|
1245
1235
|
request,
|
|
1246
1236
|
options,
|
|
1247
1237
|
state,
|
|
1248
1238
|
route: null,
|
|
1249
|
-
url: request.url,
|
|
1239
|
+
url: request.url, // TODO this is redundant, no?
|
|
1250
1240
|
params,
|
|
1251
|
-
node:
|
|
1241
|
+
node: default_layout,
|
|
1252
1242
|
$session,
|
|
1253
|
-
stuff:
|
|
1243
|
+
stuff: {},
|
|
1254
1244
|
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
|
1255
1245
|
is_leaf: false,
|
|
1256
|
-
is_error:
|
|
1257
|
-
status,
|
|
1258
|
-
error
|
|
1246
|
+
is_error: false
|
|
1259
1247
|
})
|
|
1260
|
-
)
|
|
1261
|
-
|
|
1248
|
+
);
|
|
1249
|
+
|
|
1250
|
+
const branch = [
|
|
1251
|
+
loaded,
|
|
1252
|
+
/** @type {Loaded} */ (
|
|
1253
|
+
await load_node({
|
|
1254
|
+
request,
|
|
1255
|
+
options,
|
|
1256
|
+
state,
|
|
1257
|
+
route: null,
|
|
1258
|
+
url: request.url,
|
|
1259
|
+
params,
|
|
1260
|
+
node: default_error,
|
|
1261
|
+
$session,
|
|
1262
|
+
stuff: loaded ? loaded.stuff : {},
|
|
1263
|
+
prerender_enabled: is_prerender_enabled(options, default_error, state),
|
|
1264
|
+
is_leaf: false,
|
|
1265
|
+
is_error: true,
|
|
1266
|
+
status,
|
|
1267
|
+
error
|
|
1268
|
+
})
|
|
1269
|
+
)
|
|
1270
|
+
];
|
|
1262
1271
|
|
|
1263
|
-
try {
|
|
1264
1272
|
return await render_response({
|
|
1265
1273
|
options,
|
|
1266
1274
|
$session,
|
|
@@ -1897,16 +1905,30 @@ async function respond(incoming, options, state = {}) {
|
|
|
1897
1905
|
}
|
|
1898
1906
|
}
|
|
1899
1907
|
});
|
|
1900
|
-
} catch (/** @type {unknown} */
|
|
1901
|
-
const
|
|
1908
|
+
} catch (/** @type {unknown} */ e) {
|
|
1909
|
+
const error = coalesce_to_error(e);
|
|
1902
1910
|
|
|
1903
|
-
options.handle_error(
|
|
1911
|
+
options.handle_error(error, request);
|
|
1904
1912
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1913
|
+
try {
|
|
1914
|
+
const $session = await options.hooks.getSession(request);
|
|
1915
|
+
return await respond_with_error({
|
|
1916
|
+
request,
|
|
1917
|
+
options,
|
|
1918
|
+
state,
|
|
1919
|
+
$session,
|
|
1920
|
+
status: 500,
|
|
1921
|
+
error
|
|
1922
|
+
});
|
|
1923
|
+
} catch (/** @type {unknown} */ e) {
|
|
1924
|
+
const error = coalesce_to_error(e);
|
|
1925
|
+
|
|
1926
|
+
return {
|
|
1927
|
+
status: 500,
|
|
1928
|
+
headers: {},
|
|
1929
|
+
body: options.dev ? error.stack : error.message
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1910
1932
|
}
|
|
1911
1933
|
}
|
|
1912
1934
|
|
|
@@ -168,6 +168,10 @@ class Router {
|
|
|
168
168
|
// Call `pushState` to add url to history so going back works.
|
|
169
169
|
// Also make a delay, otherwise the browser default behaviour would not kick in
|
|
170
170
|
setTimeout(() => history.pushState({}, '', url.href));
|
|
171
|
+
const info = this.parse(url);
|
|
172
|
+
if (info) {
|
|
173
|
+
return this.renderer.update(info, [], false);
|
|
174
|
+
}
|
|
171
175
|
return;
|
|
172
176
|
}
|
|
173
177
|
|
|
@@ -543,6 +547,9 @@ class Renderer {
|
|
|
543
547
|
|
|
544
548
|
let error_args;
|
|
545
549
|
|
|
550
|
+
// url.hash is empty when coming from the server
|
|
551
|
+
url.hash = window.location.hash;
|
|
552
|
+
|
|
546
553
|
try {
|
|
547
554
|
for (let i = 0; i < nodes.length; i += 1) {
|
|
548
555
|
const is_leaf = i === nodes.length - 1;
|