@sveltejs/kit 1.0.0-next.340 → 1.0.0-next.343
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 +63 -49
- package/assets/server/index.js +12 -29
- package/dist/chunks/cert.js +1 -1
- package/dist/chunks/index.js +29 -27
- package/dist/chunks/index2.js +4 -3
- package/dist/chunks/index5.js +11 -5
- package/dist/chunks/multipart-parser.js +2 -1
- package/dist/cli.js +20 -23
- package/dist/{install-fetch.js → node/polyfills.js} +21 -25
- package/dist/node.js +210 -3
- package/package.json +4 -4
- package/types/ambient.d.ts +8 -3
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;
|
|
@@ -682,6 +692,10 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
682
692
|
if (started) {
|
|
683
693
|
current = navigation_result.state;
|
|
684
694
|
|
|
695
|
+
if (navigation_result.props.page) {
|
|
696
|
+
navigation_result.props.page.url = url;
|
|
697
|
+
}
|
|
698
|
+
|
|
685
699
|
root.$set(navigation_result.props);
|
|
686
700
|
} else {
|
|
687
701
|
initialize(navigation_result);
|
|
@@ -992,7 +1006,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
992
1006
|
add_dependency(normalized);
|
|
993
1007
|
|
|
994
1008
|
// prerendered pages may be served from any origin, so `initial_fetch` urls shouldn't be normalized
|
|
995
|
-
return started ?
|
|
1009
|
+
return started ? native_fetch(normalized, init) : initial_fetch(requested, init);
|
|
996
1010
|
},
|
|
997
1011
|
status: status ?? null,
|
|
998
1012
|
error: error ?? null
|
|
@@ -1011,10 +1025,10 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1011
1025
|
|
|
1012
1026
|
if (import.meta.env.DEV) {
|
|
1013
1027
|
try {
|
|
1014
|
-
|
|
1028
|
+
lock_fetch();
|
|
1015
1029
|
loaded = await module.load.call(null, load_input);
|
|
1016
1030
|
} finally {
|
|
1017
|
-
|
|
1031
|
+
unlock_fetch();
|
|
1018
1032
|
}
|
|
1019
1033
|
} else {
|
|
1020
1034
|
loaded = await module.load.call(null, load_input);
|
|
@@ -1102,7 +1116,7 @@ function create_client({ target, session, base, trailing_slash }) {
|
|
|
1102
1116
|
const is_shadow_page = has_shadow && i === a.length - 1;
|
|
1103
1117
|
|
|
1104
1118
|
if (is_shadow_page) {
|
|
1105
|
-
const res = await
|
|
1119
|
+
const res = await native_fetch(
|
|
1106
1120
|
`${url.pathname}${url.pathname.endsWith('/') ? '' : '/'}__data.json${url.search}`,
|
|
1107
1121
|
{
|
|
1108
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}
|
|
@@ -885,33 +885,11 @@ function base64(bytes) {
|
|
|
885
885
|
/** @type {Promise<void>} */
|
|
886
886
|
let csp_ready;
|
|
887
887
|
|
|
888
|
-
|
|
889
|
-
let generate_nonce;
|
|
888
|
+
const array = new Uint8Array(16);
|
|
890
889
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
if (typeof crypto !== 'undefined') {
|
|
895
|
-
const array = new Uint8Array(16);
|
|
896
|
-
|
|
897
|
-
generate_nonce = () => {
|
|
898
|
-
crypto.getRandomValues(array);
|
|
899
|
-
return base64(array);
|
|
900
|
-
};
|
|
901
|
-
|
|
902
|
-
generate_hash = sha256;
|
|
903
|
-
} else {
|
|
904
|
-
// TODO: remove this in favor of web crypto API once we no longer support Node 14
|
|
905
|
-
const name = 'crypto'; // store in a variable to fool esbuild when adapters bundle kit
|
|
906
|
-
csp_ready = import(name).then((crypto) => {
|
|
907
|
-
generate_nonce = () => {
|
|
908
|
-
return crypto.randomBytes(16).toString('base64');
|
|
909
|
-
};
|
|
910
|
-
|
|
911
|
-
generate_hash = (input) => {
|
|
912
|
-
return crypto.createHash('sha256').update(input, 'utf-8').digest().toString('base64');
|
|
913
|
-
};
|
|
914
|
-
});
|
|
890
|
+
function generate_nonce() {
|
|
891
|
+
crypto.getRandomValues(array);
|
|
892
|
+
return base64(array);
|
|
915
893
|
}
|
|
916
894
|
|
|
917
895
|
const quoted = new Set([
|
|
@@ -1014,7 +992,7 @@ class Csp {
|
|
|
1014
992
|
add_script(content) {
|
|
1015
993
|
if (this.#script_needs_csp) {
|
|
1016
994
|
if (this.#use_hashes) {
|
|
1017
|
-
this.#script_src.push(`sha256-${
|
|
995
|
+
this.#script_src.push(`sha256-${sha256(content)}`);
|
|
1018
996
|
} else if (this.#script_src.length === 0) {
|
|
1019
997
|
this.#script_src.push(`nonce-${this.nonce}`);
|
|
1020
998
|
}
|
|
@@ -1025,7 +1003,7 @@ class Csp {
|
|
|
1025
1003
|
add_style(content) {
|
|
1026
1004
|
if (this.#style_needs_csp) {
|
|
1027
1005
|
if (this.#use_hashes) {
|
|
1028
|
-
this.#style_src.push(`sha256-${
|
|
1006
|
+
this.#style_src.push(`sha256-${sha256(content)}`);
|
|
1029
1007
|
} else if (this.#style_src.length === 0) {
|
|
1030
1008
|
this.#style_src.push(`nonce-${this.nonce}`);
|
|
1031
1009
|
}
|
|
@@ -2132,6 +2110,11 @@ async function load_node({
|
|
|
2132
2110
|
props: shadow.body || {},
|
|
2133
2111
|
routeId: event.routeId,
|
|
2134
2112
|
get session() {
|
|
2113
|
+
if (node.module.prerender ?? options.prerender.default) {
|
|
2114
|
+
throw Error(
|
|
2115
|
+
'Attempted to access session from a prerendered page. Session would never be populated.'
|
|
2116
|
+
);
|
|
2117
|
+
}
|
|
2135
2118
|
uses_credentials = true;
|
|
2136
2119
|
return $session;
|
|
2137
2120
|
},
|
package/dist/chunks/cert.js
CHANGED
package/dist/chunks/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import path__default from 'path';
|
|
|
2
2
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
3
3
|
import * as vite from 'vite';
|
|
4
4
|
import { d as deep_merge } from './object.js';
|
|
5
|
-
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
5
|
+
import { g as get_runtime_path, r as resolve_entry, $, l as load_template, c as coalesce_to_error, a as get_mime_lookup, b as load_config, d as get_aliases, p as print_config_conflicts } from '../cli.js';
|
|
6
6
|
import fs__default from 'fs';
|
|
7
7
|
import { URL } from 'url';
|
|
8
8
|
import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
9
|
-
import {
|
|
9
|
+
import { installPolyfills } from '../node/polyfills.js';
|
|
10
10
|
import { update, init } from './sync.js';
|
|
11
11
|
import { getRequest, setResponse } from '../node.js';
|
|
12
12
|
import { p as posixify } from './filesystem.js';
|
|
@@ -23,6 +23,7 @@ import 'node:zlib';
|
|
|
23
23
|
import 'node:stream';
|
|
24
24
|
import 'node:util';
|
|
25
25
|
import 'node:url';
|
|
26
|
+
import 'crypto';
|
|
26
27
|
import './write_tsconfig.js';
|
|
27
28
|
import 'stream';
|
|
28
29
|
|
|
@@ -30,12 +31,13 @@ import 'stream';
|
|
|
30
31
|
// https://github.com/vitejs/vite/blob/3edd1af56e980aef56641a5a51cf2932bb580d41/packages/vite/src/node/plugins/css.ts#L96
|
|
31
32
|
const style_pattern = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/;
|
|
32
33
|
|
|
34
|
+
const cwd$1 = process.cwd();
|
|
35
|
+
|
|
33
36
|
/**
|
|
34
37
|
* @param {import('types').ValidatedConfig} config
|
|
35
|
-
* @param {string} cwd
|
|
36
38
|
* @returns {Promise<import('vite').Plugin>}
|
|
37
39
|
*/
|
|
38
|
-
async function create_plugin(config
|
|
40
|
+
async function create_plugin(config) {
|
|
39
41
|
const runtime = get_runtime_path(config);
|
|
40
42
|
|
|
41
43
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
@@ -47,7 +49,7 @@ async function create_plugin(config, cwd) {
|
|
|
47
49
|
name: 'vite-plugin-svelte-kit',
|
|
48
50
|
|
|
49
51
|
configureServer(vite) {
|
|
50
|
-
|
|
52
|
+
installPolyfills();
|
|
51
53
|
|
|
52
54
|
/** @type {import('types').SSRManifest} */
|
|
53
55
|
let manifest;
|
|
@@ -123,7 +125,7 @@ async function create_plugin(config, cwd) {
|
|
|
123
125
|
types,
|
|
124
126
|
shadow: route.shadow
|
|
125
127
|
? async () => {
|
|
126
|
-
const url = path__default.resolve(cwd, /** @type {string} */ (route.shadow));
|
|
128
|
+
const url = path__default.resolve(cwd$1, /** @type {string} */ (route.shadow));
|
|
127
129
|
return await vite.ssrLoadModule(url, { fixStacktrace: false });
|
|
128
130
|
}
|
|
129
131
|
: null,
|
|
@@ -139,7 +141,7 @@ async function create_plugin(config, cwd) {
|
|
|
139
141
|
names,
|
|
140
142
|
types,
|
|
141
143
|
load: async () => {
|
|
142
|
-
const url = path__default.resolve(cwd, route.file);
|
|
144
|
+
const url = path__default.resolve(cwd$1, route.file);
|
|
143
145
|
return await vite.ssrLoadModule(url, { fixStacktrace: false });
|
|
144
146
|
}
|
|
145
147
|
};
|
|
@@ -150,7 +152,7 @@ async function create_plugin(config, cwd) {
|
|
|
150
152
|
|
|
151
153
|
for (const key in manifest_data.matchers) {
|
|
152
154
|
const file = manifest_data.matchers[key];
|
|
153
|
-
const url = path__default.resolve(cwd, file);
|
|
155
|
+
const url = path__default.resolve(cwd$1, file);
|
|
154
156
|
const module = await vite.ssrLoadModule(url, { fixStacktrace: false });
|
|
155
157
|
|
|
156
158
|
if (module.match) {
|
|
@@ -207,14 +209,16 @@ async function create_plugin(config, cwd) {
|
|
|
207
209
|
const file = config.kit.files.assets + pathname;
|
|
208
210
|
|
|
209
211
|
if (fs__default.existsSync(file) && !fs__default.statSync(file).isDirectory()) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
+
}
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
216
|
-
if (req.url === '/favicon.ico') return not_found(res);
|
|
217
|
-
|
|
218
222
|
if (!decoded.startsWith(config.kit.paths.base)) {
|
|
219
223
|
return not_found(res, `Not found (did you mean ${config.kit.paths.base + req.url}?)`);
|
|
220
224
|
}
|
|
@@ -261,13 +265,13 @@ async function create_plugin(config, cwd) {
|
|
|
261
265
|
// can get loaded twice via different URLs, which causes failures. Might
|
|
262
266
|
// require changes to Vite to fix
|
|
263
267
|
const { default: root } = await vite.ssrLoadModule(
|
|
264
|
-
`/${posixify(path__default.relative(cwd, `${config.kit.outDir}/generated/root.svelte`))}`,
|
|
268
|
+
`/${posixify(path__default.relative(cwd$1, `${config.kit.outDir}/generated/root.svelte`))}`,
|
|
265
269
|
{ fixStacktrace: false }
|
|
266
270
|
);
|
|
267
271
|
|
|
268
272
|
const paths = await vite.ssrLoadModule(
|
|
269
273
|
true
|
|
270
|
-
? `/${posixify(path__default.relative(cwd, `${config.kit.outDir}/runtime/paths.js`))}`
|
|
274
|
+
? `/${posixify(path__default.relative(cwd$1, `${config.kit.outDir}/runtime/paths.js`))}`
|
|
271
275
|
: `/@fs${runtime}/paths.js`,
|
|
272
276
|
{ fixStacktrace: false }
|
|
273
277
|
);
|
|
@@ -286,7 +290,7 @@ async function create_plugin(config, cwd) {
|
|
|
286
290
|
return res.end(err.reason || 'Invalid request body');
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
const template = load_template(cwd, config);
|
|
293
|
+
const template = load_template(cwd$1, config);
|
|
290
294
|
|
|
291
295
|
const rendered = await respond(
|
|
292
296
|
request,
|
|
@@ -440,19 +444,22 @@ async function find_deps(vite, node, deps) {
|
|
|
440
444
|
await Promise.all(branches);
|
|
441
445
|
}
|
|
442
446
|
|
|
447
|
+
const cwd = process.cwd();
|
|
448
|
+
|
|
443
449
|
/**
|
|
444
450
|
* @typedef {{
|
|
445
|
-
* cwd: string,
|
|
446
451
|
* port: number,
|
|
447
452
|
* host?: string,
|
|
448
453
|
* https: boolean,
|
|
449
|
-
* config: import('types').ValidatedConfig
|
|
450
454
|
* }} Options
|
|
451
455
|
* @typedef {import('types').SSRComponent} SSRComponent
|
|
452
456
|
*/
|
|
453
457
|
|
|
454
458
|
/** @param {Options} opts */
|
|
455
|
-
async function dev({
|
|
459
|
+
async function dev({ port, host, https }) {
|
|
460
|
+
/** @type {import('types').ValidatedConfig} */
|
|
461
|
+
const config = await load_config();
|
|
462
|
+
|
|
456
463
|
init(config);
|
|
457
464
|
|
|
458
465
|
const [vite_config] = deep_merge(
|
|
@@ -504,7 +511,7 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
504
511
|
},
|
|
505
512
|
configFile: false
|
|
506
513
|
}),
|
|
507
|
-
await create_plugin(config
|
|
514
|
+
await create_plugin(config)
|
|
508
515
|
],
|
|
509
516
|
base: '/'
|
|
510
517
|
});
|
|
@@ -530,14 +537,9 @@ async function dev({ cwd, port, host, https, config }) {
|
|
|
530
537
|
const server = await vite.createServer(merged_config);
|
|
531
538
|
await server.listen(port);
|
|
532
539
|
|
|
533
|
-
const address_info = /** @type {import('net').AddressInfo} */ (
|
|
534
|
-
/** @type {import('http').Server} */ (server.httpServer).address()
|
|
535
|
-
);
|
|
536
|
-
|
|
537
540
|
return {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
close: () => server.close()
|
|
541
|
+
server,
|
|
542
|
+
config
|
|
541
543
|
};
|
|
542
544
|
}
|
|
543
545
|
|
package/dist/chunks/index2.js
CHANGED
|
@@ -2,14 +2,14 @@ import fs__default, { readFileSync, writeFileSync } from 'fs';
|
|
|
2
2
|
import path__default, { join, dirname } from 'path';
|
|
3
3
|
import { p as posixify, m as mkdirp, r as rimraf } from './filesystem.js';
|
|
4
4
|
import { all } from './sync.js';
|
|
5
|
-
import { p as print_config_conflicts,
|
|
5
|
+
import { p as print_config_conflicts, d as get_aliases, r as resolve_entry, g as get_runtime_path, l as load_template } from '../cli.js';
|
|
6
6
|
import { g as generate_manifest } from './index3.js';
|
|
7
7
|
import * as vite from 'vite';
|
|
8
8
|
import { s } from './misc.js';
|
|
9
9
|
import { d as deep_merge } from './object.js';
|
|
10
10
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
11
11
|
import { pathToFileURL, URL as URL$1 } from 'url';
|
|
12
|
-
import {
|
|
12
|
+
import { installPolyfills } from '../node/polyfills.js';
|
|
13
13
|
import './write_tsconfig.js';
|
|
14
14
|
import 'sade';
|
|
15
15
|
import 'child_process';
|
|
@@ -22,6 +22,7 @@ import 'node:zlib';
|
|
|
22
22
|
import 'node:stream';
|
|
23
23
|
import 'node:util';
|
|
24
24
|
import 'node:url';
|
|
25
|
+
import 'crypto';
|
|
25
26
|
|
|
26
27
|
const absolute = /^([a-z]+:)?\/?\//;
|
|
27
28
|
const scheme = /^[a-z]+:/;
|
|
@@ -1068,7 +1069,7 @@ async function prerender({ config, entries, files, log }) {
|
|
|
1068
1069
|
return prerendered;
|
|
1069
1070
|
}
|
|
1070
1071
|
|
|
1071
|
-
|
|
1072
|
+
installPolyfills();
|
|
1072
1073
|
|
|
1073
1074
|
const server_root = join(config.kit.outDir, 'output');
|
|
1074
1075
|
|
package/dist/chunks/index5.js
CHANGED
|
@@ -5,7 +5,8 @@ import { join } from 'path';
|
|
|
5
5
|
import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { getRequest, setResponse } from '../node.js';
|
|
8
|
-
import {
|
|
8
|
+
import { installPolyfills } from '../node/polyfills.js';
|
|
9
|
+
import { b as load_config } from '../cli.js';
|
|
9
10
|
import 'querystring';
|
|
10
11
|
import 'stream';
|
|
11
12
|
import 'node:http';
|
|
@@ -15,6 +16,11 @@ import 'node:stream';
|
|
|
15
16
|
import 'node:util';
|
|
16
17
|
import 'node:url';
|
|
17
18
|
import 'net';
|
|
19
|
+
import 'crypto';
|
|
20
|
+
import 'sade';
|
|
21
|
+
import 'child_process';
|
|
22
|
+
import 'chokidar';
|
|
23
|
+
import 'os';
|
|
18
24
|
|
|
19
25
|
/** @typedef {import('http').IncomingMessage} Req */
|
|
20
26
|
/** @typedef {import('http').ServerResponse} Res */
|
|
@@ -36,14 +42,14 @@ const mutable = (dir) =>
|
|
|
36
42
|
* @param {{
|
|
37
43
|
* port: number;
|
|
38
44
|
* host?: string;
|
|
39
|
-
* config: import('types').ValidatedConfig;
|
|
40
45
|
* https?: boolean;
|
|
41
46
|
* cwd?: string;
|
|
42
47
|
* }} opts
|
|
43
48
|
*/
|
|
44
|
-
async function preview({ port, host,
|
|
45
|
-
|
|
49
|
+
async function preview({ port, host, https: use_https = false }) {
|
|
50
|
+
installPolyfills();
|
|
46
51
|
|
|
52
|
+
const config = await load_config();
|
|
47
53
|
const { paths } = config.kit;
|
|
48
54
|
const base = paths.base;
|
|
49
55
|
const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
|
|
@@ -171,7 +177,7 @@ async function preview({ port, host, config, https: use_https = false }) {
|
|
|
171
177
|
|
|
172
178
|
return new Promise((fulfil) => {
|
|
173
179
|
http_server.listen(port, host, () => {
|
|
174
|
-
fulfil(http_server);
|
|
180
|
+
fulfil({ server: http_server, config });
|
|
175
181
|
});
|
|
176
182
|
});
|
|
177
183
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'node:fs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import { MessageChannel } from 'node:worker_threads';
|
|
4
|
-
import { F as FormData, a as File } from '../
|
|
4
|
+
import { F as FormData, a as File } from '../node/polyfills.js';
|
|
5
5
|
import 'node:http';
|
|
6
6
|
import 'node:https';
|
|
7
7
|
import 'node:zlib';
|
|
@@ -9,6 +9,7 @@ import 'node:stream';
|
|
|
9
9
|
import 'node:util';
|
|
10
10
|
import 'node:url';
|
|
11
11
|
import 'net';
|
|
12
|
+
import 'crypto';
|
|
12
13
|
|
|
13
14
|
globalThis.DOMException || (() => {
|
|
14
15
|
const port = new MessageChannel().port1;
|
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.343');
|
|
908
908
|
|
|
909
909
|
prog
|
|
910
910
|
.command('dev')
|
|
@@ -922,34 +922,34 @@ prog
|
|
|
922
922
|
/** @type {() => Promise<void>} */
|
|
923
923
|
let close;
|
|
924
924
|
|
|
925
|
-
|
|
926
|
-
async function start(config) {
|
|
925
|
+
async function start() {
|
|
927
926
|
const { dev } = await import('./chunks/index.js');
|
|
928
927
|
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
const { address_info, server_config, close } = await dev({
|
|
932
|
-
cwd,
|
|
928
|
+
const { server, config } = await dev({
|
|
933
929
|
port,
|
|
934
930
|
host,
|
|
935
|
-
https
|
|
936
|
-
config
|
|
931
|
+
https
|
|
937
932
|
});
|
|
938
933
|
|
|
934
|
+
const address_info = /** @type {import('net').AddressInfo} */ (
|
|
935
|
+
/** @type {import('http').Server} */ (server.httpServer).address()
|
|
936
|
+
);
|
|
937
|
+
|
|
938
|
+
const vite_config = server.config;
|
|
939
|
+
|
|
939
940
|
welcome({
|
|
940
941
|
port: address_info.port,
|
|
941
942
|
host: address_info.address,
|
|
942
|
-
https: !!(https ||
|
|
943
|
-
open: first && (open || !!
|
|
943
|
+
https: !!(https || vite_config.server.https),
|
|
944
|
+
open: first && (open || !!vite_config.server.open),
|
|
944
945
|
base: config.kit.paths.base,
|
|
945
|
-
loose:
|
|
946
|
-
allow:
|
|
947
|
-
cwd
|
|
946
|
+
loose: vite_config.server.fs.strict === false,
|
|
947
|
+
allow: vite_config.server.fs.allow
|
|
948
948
|
});
|
|
949
949
|
|
|
950
950
|
first = false;
|
|
951
951
|
|
|
952
|
-
return close;
|
|
952
|
+
return server.close;
|
|
953
953
|
}
|
|
954
954
|
|
|
955
955
|
async function relaunch() {
|
|
@@ -957,9 +957,8 @@ prog
|
|
|
957
957
|
relaunching = true;
|
|
958
958
|
|
|
959
959
|
try {
|
|
960
|
-
const updated_config = await load_config();
|
|
961
960
|
await close();
|
|
962
|
-
close = await start(
|
|
961
|
+
close = await start();
|
|
963
962
|
|
|
964
963
|
if (id !== uid) relaunch();
|
|
965
964
|
} catch (e) {
|
|
@@ -979,8 +978,7 @@ prog
|
|
|
979
978
|
|
|
980
979
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
981
980
|
|
|
982
|
-
|
|
983
|
-
close = await start(config);
|
|
981
|
+
close = await start();
|
|
984
982
|
|
|
985
983
|
chokidar.watch('svelte.config.js', { ignoreInitial: true }).on('change', () => {
|
|
986
984
|
if (relaunching) uid += 1;
|
|
@@ -1043,11 +1041,10 @@ prog
|
|
|
1043
1041
|
await check_port(port);
|
|
1044
1042
|
|
|
1045
1043
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
1046
|
-
const config = await load_config();
|
|
1047
1044
|
|
|
1048
1045
|
const { preview } = await import('./chunks/index5.js');
|
|
1049
1046
|
|
|
1050
|
-
await preview({ port, host,
|
|
1047
|
+
const { config } = await preview({ port, host, https });
|
|
1051
1048
|
|
|
1052
1049
|
welcome({ port, host, https, open, base: config.kit.paths.base });
|
|
1053
1050
|
} catch (error) {
|
|
@@ -1126,7 +1123,7 @@ async function check_port(port) {
|
|
|
1126
1123
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1127
1124
|
if (open) launch(port, https, base);
|
|
1128
1125
|
|
|
1129
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1126
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.343'}\n`));
|
|
1130
1127
|
|
|
1131
1128
|
const protocol = https ? 'https:' : 'http:';
|
|
1132
1129
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
|
@@ -1164,4 +1161,4 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
|
1164
1161
|
console.log('\n');
|
|
1165
1162
|
}
|
|
1166
1163
|
|
|
1167
|
-
export { $, get_mime_lookup as a,
|
|
1164
|
+
export { $, get_mime_lookup as a, load_config as b, coalesce_to_error as c, get_aliases as d, get_runtime_path as g, load_template as l, print_config_conflicts as p, resolve_entry as r };
|
|
@@ -5,6 +5,9 @@ import Stream, { PassThrough, pipeline } from 'node:stream';
|
|
|
5
5
|
import { types, deprecate } from 'node:util';
|
|
6
6
|
import { format } from 'node:url';
|
|
7
7
|
import { isIP } from 'net';
|
|
8
|
+
import { webcrypto } from 'crypto';
|
|
9
|
+
|
|
10
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Returns a `Buffer` instance from the given data URI `uri`.
|
|
@@ -58,8 +61,6 @@ function dataUriToBuffer(uri) {
|
|
|
58
61
|
return buffer;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
62
|
-
|
|
63
64
|
var ponyfill_es2018 = {exports: {}};
|
|
64
65
|
|
|
65
66
|
/**
|
|
@@ -4840,7 +4841,7 @@ class Body {
|
|
|
4840
4841
|
return formData;
|
|
4841
4842
|
}
|
|
4842
4843
|
|
|
4843
|
-
const {toFormData} = await import('
|
|
4844
|
+
const {toFormData} = await import('../chunks/multipart-parser.js');
|
|
4844
4845
|
return toFormData(this.body, ct);
|
|
4845
4846
|
}
|
|
4846
4847
|
|
|
@@ -6489,30 +6490,25 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6489
6490
|
});
|
|
6490
6491
|
}
|
|
6491
6492
|
|
|
6493
|
+
/** @type {Record<string, any>} */
|
|
6494
|
+
const globals = {
|
|
6495
|
+
crypto: webcrypto,
|
|
6496
|
+
fetch,
|
|
6497
|
+
Response,
|
|
6498
|
+
Request,
|
|
6499
|
+
Headers
|
|
6500
|
+
};
|
|
6501
|
+
|
|
6492
6502
|
// exported for dev/preview and node environments
|
|
6493
|
-
function
|
|
6494
|
-
|
|
6495
|
-
fetch
|
|
6496
|
-
|
|
6497
|
-
configurable: true,
|
|
6498
|
-
value: fetch
|
|
6499
|
-
},
|
|
6500
|
-
Response: {
|
|
6503
|
+
function installPolyfills() {
|
|
6504
|
+
for (const name in globals) {
|
|
6505
|
+
// TODO use built-in fetch once https://github.com/nodejs/undici/issues/1262 is resolved
|
|
6506
|
+
Object.defineProperty(globalThis, name, {
|
|
6501
6507
|
enumerable: true,
|
|
6502
6508
|
configurable: true,
|
|
6503
|
-
value:
|
|
6504
|
-
}
|
|
6505
|
-
|
|
6506
|
-
enumerable: true,
|
|
6507
|
-
configurable: true,
|
|
6508
|
-
value: Request
|
|
6509
|
-
},
|
|
6510
|
-
Headers: {
|
|
6511
|
-
enumerable: true,
|
|
6512
|
-
configurable: true,
|
|
6513
|
-
value: Headers
|
|
6514
|
-
}
|
|
6515
|
-
});
|
|
6509
|
+
value: globals[name]
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6516
6512
|
}
|
|
6517
6513
|
|
|
6518
|
-
export { FormData as F, File as a, commonjsGlobal as c,
|
|
6514
|
+
export { FormData as F, File as a, commonjsGlobal as c, installPolyfills };
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,208 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
2
|
|
|
3
|
+
var setCookie = {exports: {}};
|
|
4
|
+
|
|
5
|
+
var defaultParseOptions = {
|
|
6
|
+
decodeValues: true,
|
|
7
|
+
map: false,
|
|
8
|
+
silent: false,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function isNonEmptyString(str) {
|
|
12
|
+
return typeof str === "string" && !!str.trim();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function parseString(setCookieValue, options) {
|
|
16
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
17
|
+
var nameValue = parts.shift().split("=");
|
|
18
|
+
var name = nameValue.shift();
|
|
19
|
+
var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
|
20
|
+
|
|
21
|
+
options = options
|
|
22
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
23
|
+
: defaultParseOptions;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error(
|
|
29
|
+
"set-cookie-parser encountered an error while decoding a cookie with value '" +
|
|
30
|
+
value +
|
|
31
|
+
"'. Set options.decodeValues to false to disable this feature.",
|
|
32
|
+
e
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var cookie = {
|
|
37
|
+
name: name, // grab everything before the first =
|
|
38
|
+
value: value,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
parts.forEach(function (part) {
|
|
42
|
+
var sides = part.split("=");
|
|
43
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
44
|
+
var value = sides.join("=");
|
|
45
|
+
if (key === "expires") {
|
|
46
|
+
cookie.expires = new Date(value);
|
|
47
|
+
} else if (key === "max-age") {
|
|
48
|
+
cookie.maxAge = parseInt(value, 10);
|
|
49
|
+
} else if (key === "secure") {
|
|
50
|
+
cookie.secure = true;
|
|
51
|
+
} else if (key === "httponly") {
|
|
52
|
+
cookie.httpOnly = true;
|
|
53
|
+
} else if (key === "samesite") {
|
|
54
|
+
cookie.sameSite = value;
|
|
55
|
+
} else {
|
|
56
|
+
cookie[key] = value;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return cookie;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parse(input, options) {
|
|
64
|
+
options = options
|
|
65
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
66
|
+
: defaultParseOptions;
|
|
67
|
+
|
|
68
|
+
if (!input) {
|
|
69
|
+
if (!options.map) {
|
|
70
|
+
return [];
|
|
71
|
+
} else {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (input.headers && input.headers["set-cookie"]) {
|
|
77
|
+
// fast-path for node.js (which automatically normalizes header names to lower-case
|
|
78
|
+
input = input.headers["set-cookie"];
|
|
79
|
+
} else if (input.headers) {
|
|
80
|
+
// slow-path for other environments - see #25
|
|
81
|
+
var sch =
|
|
82
|
+
input.headers[
|
|
83
|
+
Object.keys(input.headers).find(function (key) {
|
|
84
|
+
return key.toLowerCase() === "set-cookie";
|
|
85
|
+
})
|
|
86
|
+
];
|
|
87
|
+
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
|
88
|
+
if (!sch && input.headers.cookie && !options.silent) {
|
|
89
|
+
console.warn(
|
|
90
|
+
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
input = sch;
|
|
94
|
+
}
|
|
95
|
+
if (!Array.isArray(input)) {
|
|
96
|
+
input = [input];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
options = options
|
|
100
|
+
? Object.assign({}, defaultParseOptions, options)
|
|
101
|
+
: defaultParseOptions;
|
|
102
|
+
|
|
103
|
+
if (!options.map) {
|
|
104
|
+
return input.filter(isNonEmptyString).map(function (str) {
|
|
105
|
+
return parseString(str, options);
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
var cookies = {};
|
|
109
|
+
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
|
110
|
+
var cookie = parseString(str, options);
|
|
111
|
+
cookies[cookie.name] = cookie;
|
|
112
|
+
return cookies;
|
|
113
|
+
}, cookies);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
|
119
|
+
that are within a single set-cookie field-value, such as in the Expires portion.
|
|
120
|
+
|
|
121
|
+
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
|
122
|
+
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
|
123
|
+
React Native's fetch does this for *every* header, including set-cookie.
|
|
124
|
+
|
|
125
|
+
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
|
126
|
+
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
|
127
|
+
*/
|
|
128
|
+
function splitCookiesString(cookiesString) {
|
|
129
|
+
if (Array.isArray(cookiesString)) {
|
|
130
|
+
return cookiesString;
|
|
131
|
+
}
|
|
132
|
+
if (typeof cookiesString !== "string") {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var cookiesStrings = [];
|
|
137
|
+
var pos = 0;
|
|
138
|
+
var start;
|
|
139
|
+
var ch;
|
|
140
|
+
var lastComma;
|
|
141
|
+
var nextStart;
|
|
142
|
+
var cookiesSeparatorFound;
|
|
143
|
+
|
|
144
|
+
function skipWhitespace() {
|
|
145
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
146
|
+
pos += 1;
|
|
147
|
+
}
|
|
148
|
+
return pos < cookiesString.length;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function notSpecialChar() {
|
|
152
|
+
ch = cookiesString.charAt(pos);
|
|
153
|
+
|
|
154
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
while (pos < cookiesString.length) {
|
|
158
|
+
start = pos;
|
|
159
|
+
cookiesSeparatorFound = false;
|
|
160
|
+
|
|
161
|
+
while (skipWhitespace()) {
|
|
162
|
+
ch = cookiesString.charAt(pos);
|
|
163
|
+
if (ch === ",") {
|
|
164
|
+
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
|
165
|
+
lastComma = pos;
|
|
166
|
+
pos += 1;
|
|
167
|
+
|
|
168
|
+
skipWhitespace();
|
|
169
|
+
nextStart = pos;
|
|
170
|
+
|
|
171
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
172
|
+
pos += 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// currently special character
|
|
176
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
177
|
+
// we found cookies separator
|
|
178
|
+
cookiesSeparatorFound = true;
|
|
179
|
+
// pos is inside the next cookie, so back up and return it.
|
|
180
|
+
pos = nextStart;
|
|
181
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
182
|
+
start = pos;
|
|
183
|
+
} else {
|
|
184
|
+
// in param ',' or param separator ';',
|
|
185
|
+
// we continue from that comma
|
|
186
|
+
pos = lastComma + 1;
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
pos += 1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
194
|
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return cookiesStrings;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
setCookie.exports = parse;
|
|
202
|
+
setCookie.exports.parse = parse;
|
|
203
|
+
setCookie.exports.parseString = parseString;
|
|
204
|
+
var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
|
|
205
|
+
|
|
3
206
|
/** @param {import('http').IncomingMessage} req */
|
|
4
207
|
function get_raw_body(req) {
|
|
5
208
|
return new Promise((fulfil, reject) => {
|
|
@@ -56,6 +259,7 @@ async function getRequest(base, req) {
|
|
|
56
259
|
if (req.httpVersionMajor === 2) {
|
|
57
260
|
// we need to strip out the HTTP/2 pseudo-headers because node-fetch's
|
|
58
261
|
// Request implementation doesn't like them
|
|
262
|
+
// TODO is this still true with Node 18
|
|
59
263
|
headers = Object.assign({}, headers);
|
|
60
264
|
delete headers[':method'];
|
|
61
265
|
delete headers[':path'];
|
|
@@ -74,8 +278,11 @@ async function setResponse(res, response) {
|
|
|
74
278
|
const headers = Object.fromEntries(response.headers);
|
|
75
279
|
|
|
76
280
|
if (response.headers.has('set-cookie')) {
|
|
77
|
-
|
|
78
|
-
|
|
281
|
+
const header = /** @type {string} */ (response.headers.get('set-cookie'));
|
|
282
|
+
const split = splitCookiesString_1(header);
|
|
283
|
+
|
|
284
|
+
// @ts-expect-error
|
|
285
|
+
headers['set-cookie'] = split;
|
|
79
286
|
}
|
|
80
287
|
|
|
81
288
|
res.writeHead(response.status, headers);
|
|
@@ -84,7 +291,7 @@ async function setResponse(res, response) {
|
|
|
84
291
|
response.body.pipe(res);
|
|
85
292
|
} else {
|
|
86
293
|
if (response.body) {
|
|
87
|
-
res.write(await response.arrayBuffer());
|
|
294
|
+
res.write(new Uint8Array(await response.arrayBuffer()));
|
|
88
295
|
}
|
|
89
296
|
|
|
90
297
|
res.end();
|
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.343",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"./node": {
|
|
53
53
|
"import": "./dist/node.js"
|
|
54
54
|
},
|
|
55
|
+
"./node/polyfills": {
|
|
56
|
+
"import": "./dist/node/polyfills.js"
|
|
57
|
+
},
|
|
55
58
|
"./hooks": {
|
|
56
59
|
"import": "./dist/hooks.js"
|
|
57
|
-
},
|
|
58
|
-
"./install-fetch": {
|
|
59
|
-
"import": "./dist/install-fetch.js"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"types": "types/index.d.ts",
|
package/types/ambient.d.ts
CHANGED
|
@@ -283,11 +283,16 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
283
283
|
/**
|
|
284
284
|
* A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
|
|
285
285
|
*/
|
|
286
|
-
declare module '@sveltejs/kit/
|
|
286
|
+
declare module '@sveltejs/kit/node/polyfills' {
|
|
287
287
|
/**
|
|
288
|
-
* Make
|
|
288
|
+
* Make various web APIs available as globals:
|
|
289
|
+
* - `crypto`
|
|
290
|
+
* - `fetch`
|
|
291
|
+
* - `Headers`
|
|
292
|
+
* - `Request`
|
|
293
|
+
* - `Response`
|
|
289
294
|
*/
|
|
290
|
-
export function
|
|
295
|
+
export function installPolyfills(): void;
|
|
291
296
|
}
|
|
292
297
|
|
|
293
298
|
/**
|