@sveltejs/kit 1.0.0-next.506 → 1.0.0-next.508
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/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.508",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
"kleur": "^4.1.4",
|
|
18
18
|
"magic-string": "^0.26.2",
|
|
19
19
|
"mime": "^3.0.0",
|
|
20
|
-
"node-fetch": "^3.2.4",
|
|
21
20
|
"sade": "^1.8.1",
|
|
22
21
|
"set-cookie-parser": "^2.4.8",
|
|
23
22
|
"sirv": "^2.0.2",
|
|
24
23
|
"tiny-glob": "^0.2.9",
|
|
25
|
-
"undici": "^5.
|
|
24
|
+
"undici": "^5.11.0"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@playwright/test": "^1.25.0",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { fetch, Response, Request, Headers } from 'undici';
|
|
1
|
+
import { fetch, Response, Request, Headers, FormData } from 'undici';
|
|
2
2
|
import { ReadableStream, TransformStream, WritableStream } from 'stream/web';
|
|
3
|
-
import { Readable } from 'stream';
|
|
4
|
-
import { Request as NodeFetchRequest, FormData } from 'node-fetch';
|
|
5
3
|
import { webcrypto as crypto } from 'crypto';
|
|
6
4
|
|
|
7
5
|
/** @type {Record<string, any>} */
|
|
@@ -9,18 +7,7 @@ const globals = {
|
|
|
9
7
|
crypto,
|
|
10
8
|
fetch,
|
|
11
9
|
Response,
|
|
12
|
-
|
|
13
|
-
// https://github.com/nodejs/undici/issues/974
|
|
14
|
-
Request: class extends Request {
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
formData() {
|
|
17
|
-
return new NodeFetchRequest(this.url, {
|
|
18
|
-
method: this.method,
|
|
19
|
-
headers: this.headers,
|
|
20
|
-
body: this.body && Readable.from(this.body)
|
|
21
|
-
}).formData();
|
|
22
|
-
}
|
|
23
|
-
},
|
|
10
|
+
Request,
|
|
24
11
|
Headers,
|
|
25
12
|
ReadableStream,
|
|
26
13
|
TransformStream,
|
|
@@ -71,7 +71,7 @@ export function initial_fetch(resource, resolved, opts) {
|
|
|
71
71
|
|
|
72
72
|
let selector = `script[data-sveltekit-fetched][data-url=${url}]`;
|
|
73
73
|
|
|
74
|
-
if (opts && typeof opts.body === 'string') {
|
|
74
|
+
if (opts?.body && (typeof opts.body === 'string' || ArrayBuffer.isView(opts.body))) {
|
|
75
75
|
selector += `[data-hash="${hash(opts.body)}"]`;
|
|
76
76
|
}
|
|
77
77
|
|
package/src/runtime/hash.js
CHANGED
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function hash(value) {
|
|
6
6
|
let hash = 5381;
|
|
7
|
-
let i = value.length;
|
|
8
7
|
|
|
9
8
|
if (typeof value === 'string') {
|
|
9
|
+
let i = value.length;
|
|
10
10
|
while (i) hash = (hash * 33) ^ value.charCodeAt(--i);
|
|
11
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
12
|
+
const buffer = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
13
|
+
let i = buffer.length;
|
|
14
|
+
while (i) hash = (hash * 33) ^ buffer[--i];
|
|
11
15
|
} else {
|
|
12
|
-
|
|
16
|
+
throw new TypeError('value must be a string or TypedArray');
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
return (hash >>> 0).toString(36);
|
|
@@ -165,13 +165,13 @@ export function create_fetch({ event, options, state, route, prerender_default,
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
if (request_body && typeof request_body !== 'string') {
|
|
168
|
+
if (request_body && typeof request_body !== 'string' && !ArrayBuffer.isView(request_body)) {
|
|
169
169
|
// TODO is this still necessary? we just bail out below
|
|
170
170
|
// per https://developer.mozilla.org/en-US/docs/Web/API/Request/Request, this can be a
|
|
171
171
|
// Blob, BufferSource, FormData, URLSearchParams, USVString, or ReadableStream object.
|
|
172
172
|
// non-string bodies are irksome to deal with, but luckily aren't particularly useful
|
|
173
173
|
// in this context anyway, so we take the easy route and ban them
|
|
174
|
-
throw new Error('Request body must be a string');
|
|
174
|
+
throw new Error('Request body must be a string or TypedArray');
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
response = await respond(request, options, {
|
|
@@ -220,7 +220,7 @@ export function create_fetch({ event, options, state, route, prerender_default,
|
|
|
220
220
|
? request.url.slice(event.url.origin.length)
|
|
221
221
|
: request.url,
|
|
222
222
|
method: request.method,
|
|
223
|
-
request_body: /** @type {string | undefined} */ (request_body),
|
|
223
|
+
request_body: /** @type {string | ArrayBufferView | undefined} */ (request_body),
|
|
224
224
|
response_body: body,
|
|
225
225
|
response: response
|
|
226
226
|
});
|
package/types/internal.d.ts
CHANGED