@sveltejs/kit 1.0.0-next.341 → 1.0.0-next.342
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/client/start.js +59 -49
- package/assets/server/index.js +1 -1
- package/dist/chunks/index.js +7 -5
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/assets/client/start.js
CHANGED
|
@@ -110,23 +110,6 @@ function normalize_path(path, trailing_slash) {
|
|
|
110
110
|
return path;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* Hash using djb2
|
|
115
|
-
* @param {import('types').StrictBody} value
|
|
116
|
-
*/
|
|
117
|
-
function hash(value) {
|
|
118
|
-
let hash = 5381;
|
|
119
|
-
let i = value.length;
|
|
120
|
-
|
|
121
|
-
if (typeof value === 'string') {
|
|
122
|
-
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
|
123
|
-
} else {
|
|
124
|
-
while (i) hash = (hash * 33) ^ value[--i];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return (hash >>> 0).toString(36);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
113
|
/** @param {HTMLDocument} doc */
|
|
131
114
|
function get_base_uri(doc) {
|
|
132
115
|
let baseURI = doc.baseURI;
|
|
@@ -241,6 +224,60 @@ function create_updated_store() {
|
|
|
241
224
|
};
|
|
242
225
|
}
|
|
243
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Hash using djb2
|
|
229
|
+
* @param {import('types').StrictBody} value
|
|
230
|
+
*/
|
|
231
|
+
function hash(value) {
|
|
232
|
+
let hash = 5381;
|
|
233
|
+
let i = value.length;
|
|
234
|
+
|
|
235
|
+
if (typeof value === 'string') {
|
|
236
|
+
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
|
237
|
+
} else {
|
|
238
|
+
while (i) hash = (hash * 33) ^ value[--i];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (hash >>> 0).toString(36);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let loading = 0;
|
|
245
|
+
|
|
246
|
+
const native_fetch = window.fetch;
|
|
247
|
+
|
|
248
|
+
function lock_fetch() {
|
|
249
|
+
loading += 1;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function unlock_fetch() {
|
|
253
|
+
loading -= 1;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (import.meta.env.DEV) {
|
|
257
|
+
let can_inspect_stack_trace = false;
|
|
258
|
+
|
|
259
|
+
const check_stack_trace = async () => {
|
|
260
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
261
|
+
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
check_stack_trace();
|
|
265
|
+
|
|
266
|
+
window.fetch = (input, init) => {
|
|
267
|
+
const url = input instanceof Request ? input.url : input.toString();
|
|
268
|
+
const stack = /** @type {string} */ (new Error().stack);
|
|
269
|
+
|
|
270
|
+
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
271
|
+
if (heuristic) {
|
|
272
|
+
console.warn(
|
|
273
|
+
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return native_fetch(input, init);
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
244
281
|
/**
|
|
245
282
|
* @param {RequestInfo} resource
|
|
246
283
|
* @param {RequestInit} [opts]
|
|
@@ -260,7 +297,7 @@ function initial_fetch(resource, opts) {
|
|
|
260
297
|
return Promise.resolve(new Response(body, init));
|
|
261
298
|
}
|
|
262
299
|
|
|
263
|
-
return
|
|
300
|
+
return native_fetch(resource, opts);
|
|
264
301
|
}
|
|
265
302
|
|
|
266
303
|
const param_pattern = /^(\.\.\.)?(\w+)(?:=(\w+))?$/;
|
|
@@ -423,33 +460,6 @@ function update_scroll_positions(index) {
|
|
|
423
460
|
scroll_positions[index] = scroll_state();
|
|
424
461
|
}
|
|
425
462
|
|
|
426
|
-
const fetch$1 = window.fetch;
|
|
427
|
-
let loading = 0;
|
|
428
|
-
|
|
429
|
-
if (import.meta.env.DEV) {
|
|
430
|
-
let can_inspect_stack_trace = false;
|
|
431
|
-
|
|
432
|
-
const check_stack_trace = async () => {
|
|
433
|
-
const stack = /** @type {string} */ (new Error().stack);
|
|
434
|
-
can_inspect_stack_trace = stack.includes('check_stack_trace');
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
check_stack_trace();
|
|
438
|
-
|
|
439
|
-
window.fetch = (input, init) => {
|
|
440
|
-
const url = input instanceof Request ? input.url : input.toString();
|
|
441
|
-
const stack = /** @type {string} */ (new Error().stack);
|
|
442
|
-
|
|
443
|
-
const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
|
|
444
|
-
if (heuristic) {
|
|
445
|
-
console.warn(
|
|
446
|
-
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/loading#input-fetch`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
return fetch$1(input, init);
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
|
|
453
463
|
/**
|
|
454
464
|
* @param {{
|
|
455
465
|
* target: Element;
|
|
@@ -996,7 +1006,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
996
1006
|
add_dependency(normalized);
|
|
997
1007
|
|
|
998
1008
|
// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be normalized
|
|
999
|
-
return started ?
|
|
1009
|
+
return started ? native_fetch(normalized, init) : initial_fetch(requested, init);
|
|
1000
1010
|
},
|
|
1001
1011
|
status: status ?? null,
|
|
1002
1012
|
error: error ?? null
|
|
@@ -1015,10 +1025,10 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1015
1025
|
|
|
1016
1026
|
if (import.meta.env.DEV) {
|
|
1017
1027
|
try {
|
|
1018
|
-
|
|
1028
|
+
lock_fetch();
|
|
1019
1029
|
loaded = await module.load.call(null, load_input);
|
|
1020
1030
|
} finally {
|
|
1021
|
-
|
|
1031
|
+
unlock_fetch();
|
|
1022
1032
|
}
|
|
1023
1033
|
} else {
|
|
1024
1034
|
loaded = await module.load.call(null, load_input);
|
|
@@ -1106,7 +1116,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1106
1116
|
const is_shadow_page = has_shadow && i === a.length - 1;
|
|
1107
1117
|
|
|
1108
1118
|
if (is_shadow_page) {
|
|
1109
|
-
const res = await
|
|
1119
|
+
const res = await native_fetch(
|
|
1110
1120
|
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
|
1111
1121
|
{
|
|
1112
1122
|
headers: {
|
package/assets/server/index.js
CHANGED
|
@@ -115,7 +115,7 @@ const text_types = new Set([
|
|
|
115
115
|
]);
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
* Decides how the body should be parsed based on its mime type
|
|
118
|
+
* Decides how the body should be parsed based on its mime type
|
|
119
119
|
*
|
|
120
120
|
* @param {string | undefined | null} content_type The `content-type` header of a request/response.
|
|
121
121
|
* @returns {boolean}
|
package/dist/chunks/index.js
CHANGED
|
@@ -209,14 +209,16 @@ async function create_plugin(config) {
|
|
|
209
209
|
const file = config.kit.files.assets + pathname;
|
|
210
210
|
|
|
211
211
|
if (fs__default.existsSync(file) && !fs__default.statSync(file).isDirectory()) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
const has_correct_case = fs__default.realpathSync.native(file) === path__default.resolve(file);
|
|
213
|
+
|
|
214
|
+
if (has_correct_case) {
|
|
215
|
+
req.url = encodeURI(pathname); // don't need query/hash
|
|
216
|
+
asset_server(req, res);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
|
|
218
|
-
if (req.url === '/favicon.ico') return not_found(res);
|
|
219
|
-
|
|
220
222
|
if (!decoded.startsWith(config.kit.paths.base)) {
|
|
221
223
|
return not_found(res, `Not found (did you mean ${config.kit.paths.base + req.url}?)`);
|
|
222
224
|
}
|
package/dist/cli.js
CHANGED
|
@@ -904,7 +904,7 @@ async function launch(port, https, base) {
|
|
|
904
904
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
905
905
|
}
|
|
906
906
|
|
|
907
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
907
|
+
const prog = sade('svelte-kit').version('1.0.0-next.342');
|
|
908
908
|
|
|
909
909
|
prog
|
|
910
910
|
.command('dev')
|
|
@@ -1122,7 +1122,7 @@ async function check_port(port) {
|
|
|
1122
1122
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1123
1123
|
if (open) launch(port, https, base);
|
|
1124
1124
|
|
|
1125
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1125
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.342'}\n`));
|
|
1126
1126
|
|
|
1127
1127
|
const protocol = https ? 'https:' : 'http:';
|
|
1128
1128
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|