@sveltejs/adapter-netlify 1.0.0-next.46 → 1.0.0-next.49
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/README.md +3 -2
- package/files/cjs/handler.js +32 -31
- package/files/cjs/{multipart-parser-b00119f1.js → multipart-parser-431aff0b.js} +0 -0
- package/files/cjs/shims.js +3 -3
- package/files/esm/handler.js +32 -31
- package/files/esm/{multipart-parser-781607e4.js → multipart-parser-5faf185a.js} +0 -0
- package/files/esm/shims.js +3 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -57,7 +57,9 @@ During compilation, redirect rules are automatically appended to your `_redirect
|
|
|
57
57
|
|
|
58
58
|
### Using Netlify Functions
|
|
59
59
|
|
|
60
|
-
[Netlify Functions](https://docs.netlify.com/functions/overview/)
|
|
60
|
+
With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and endpoints.
|
|
61
|
+
|
|
62
|
+
Additionally, you can add your own Netlify functions by creating a directory for them and adding the configuration to your `netlify.toml` file. For example:
|
|
61
63
|
|
|
62
64
|
```toml
|
|
63
65
|
[build]
|
|
@@ -66,7 +68,6 @@ During compilation, redirect rules are automatically appended to your `_redirect
|
|
|
66
68
|
|
|
67
69
|
[functions]
|
|
68
70
|
directory = "functions"
|
|
69
|
-
node_bundler = "esbuild"
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
## Changelog
|
package/files/cjs/handler.js
CHANGED
|
@@ -12,6 +12,36 @@ require('node:util');
|
|
|
12
12
|
require('node:url');
|
|
13
13
|
require('net');
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Splits headers into two categories: single value and multi value
|
|
17
|
+
* @param {Headers} headers
|
|
18
|
+
* @returns {{
|
|
19
|
+
* headers: Record<string, string>,
|
|
20
|
+
* multiValueHeaders: Record<string, string[]>
|
|
21
|
+
* }}
|
|
22
|
+
*/
|
|
23
|
+
function split_headers(headers) {
|
|
24
|
+
/** @type {Record<string, string>} */
|
|
25
|
+
const h = {};
|
|
26
|
+
|
|
27
|
+
/** @type {Record<string, string[]>} */
|
|
28
|
+
const m = {};
|
|
29
|
+
|
|
30
|
+
headers.forEach((value, key) => {
|
|
31
|
+
if (key === 'set-cookie') {
|
|
32
|
+
// @ts-expect-error (headers.raw() is non-standard)
|
|
33
|
+
m[key] = headers.raw()[key];
|
|
34
|
+
} else {
|
|
35
|
+
h[key] = value;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
headers: h,
|
|
41
|
+
multiValueHeaders: m
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
15
45
|
/**
|
|
16
46
|
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
17
47
|
* @returns {import('@netlify/functions').Handler}
|
|
@@ -19,8 +49,8 @@ require('net');
|
|
|
19
49
|
function init(manifest) {
|
|
20
50
|
const server = new _0SERVER.Server(manifest);
|
|
21
51
|
|
|
22
|
-
return async (event) => {
|
|
23
|
-
const rendered = await server.respond(to_request(event));
|
|
52
|
+
return async (event, context) => {
|
|
53
|
+
const rendered = await server.respond(to_request(event), { platform: { context } });
|
|
24
54
|
|
|
25
55
|
const partial_response = {
|
|
26
56
|
statusCode: rendered.status,
|
|
@@ -67,33 +97,4 @@ function to_request(event) {
|
|
|
67
97
|
return new Request(rawUrl, init);
|
|
68
98
|
}
|
|
69
99
|
|
|
70
|
-
/**
|
|
71
|
-
* Splits headers into two categories: single value and multi value
|
|
72
|
-
* @param {Headers} headers
|
|
73
|
-
* @returns {{
|
|
74
|
-
* headers: Record<string, string>,
|
|
75
|
-
* multiValueHeaders: Record<string, string[]>
|
|
76
|
-
* }}
|
|
77
|
-
*/
|
|
78
|
-
function split_headers(headers) {
|
|
79
|
-
/** @type {Record<string, string>} */
|
|
80
|
-
const h = {};
|
|
81
|
-
|
|
82
|
-
/** @type {Record<string, string[]>} */
|
|
83
|
-
const m = {};
|
|
84
|
-
|
|
85
|
-
headers.forEach((value, key) => {
|
|
86
|
-
if (key === 'set-cookie') {
|
|
87
|
-
m[key] = value.split(', ');
|
|
88
|
-
} else {
|
|
89
|
-
h[key] = value;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
headers: h,
|
|
95
|
-
multiValueHeaders: m
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
100
|
exports.init = init;
|
|
File without changes
|
package/files/cjs/shims.js
CHANGED
|
@@ -4851,7 +4851,7 @@ class Body {
|
|
|
4851
4851
|
return formData;
|
|
4852
4852
|
}
|
|
4853
4853
|
|
|
4854
|
-
const {toFormData} = await Promise.resolve().then(function () { return require('./multipart-parser-
|
|
4854
|
+
const {toFormData} = await Promise.resolve().then(function () { return require('./multipart-parser-431aff0b.js'); });
|
|
4855
4855
|
return toFormData(this.body, ct);
|
|
4856
4856
|
}
|
|
4857
4857
|
|
|
@@ -6501,7 +6501,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6501
6501
|
}
|
|
6502
6502
|
|
|
6503
6503
|
// exported for dev/preview and node environments
|
|
6504
|
-
function
|
|
6504
|
+
function installFetch() {
|
|
6505
6505
|
Object.defineProperties(globalThis, {
|
|
6506
6506
|
fetch: {
|
|
6507
6507
|
enumerable: true,
|
|
@@ -6526,7 +6526,7 @@ function __fetch_polyfill() {
|
|
|
6526
6526
|
});
|
|
6527
6527
|
}
|
|
6528
6528
|
|
|
6529
|
-
|
|
6529
|
+
installFetch();
|
|
6530
6530
|
|
|
6531
6531
|
exports.File = File;
|
|
6532
6532
|
exports.FormData = FormData;
|
package/files/esm/handler.js
CHANGED
|
@@ -8,6 +8,36 @@ import 'node:util';
|
|
|
8
8
|
import 'node:url';
|
|
9
9
|
import 'net';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Splits headers into two categories: single value and multi value
|
|
13
|
+
* @param {Headers} headers
|
|
14
|
+
* @returns {{
|
|
15
|
+
* headers: Record<string, string>,
|
|
16
|
+
* multiValueHeaders: Record<string, string[]>
|
|
17
|
+
* }}
|
|
18
|
+
*/
|
|
19
|
+
function split_headers(headers) {
|
|
20
|
+
/** @type {Record<string, string>} */
|
|
21
|
+
const h = {};
|
|
22
|
+
|
|
23
|
+
/** @type {Record<string, string[]>} */
|
|
24
|
+
const m = {};
|
|
25
|
+
|
|
26
|
+
headers.forEach((value, key) => {
|
|
27
|
+
if (key === 'set-cookie') {
|
|
28
|
+
// @ts-expect-error (headers.raw() is non-standard)
|
|
29
|
+
m[key] = headers.raw()[key];
|
|
30
|
+
} else {
|
|
31
|
+
h[key] = value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
headers: h,
|
|
37
|
+
multiValueHeaders: m
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
11
41
|
/**
|
|
12
42
|
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
13
43
|
* @returns {import('@netlify/functions').Handler}
|
|
@@ -15,8 +45,8 @@ import 'net';
|
|
|
15
45
|
function init(manifest) {
|
|
16
46
|
const server = new Server(manifest);
|
|
17
47
|
|
|
18
|
-
return async (event) => {
|
|
19
|
-
const rendered = await server.respond(to_request(event));
|
|
48
|
+
return async (event, context) => {
|
|
49
|
+
const rendered = await server.respond(to_request(event), { platform: { context } });
|
|
20
50
|
|
|
21
51
|
const partial_response = {
|
|
22
52
|
statusCode: rendered.status,
|
|
@@ -63,33 +93,4 @@ function to_request(event) {
|
|
|
63
93
|
return new Request(rawUrl, init);
|
|
64
94
|
}
|
|
65
95
|
|
|
66
|
-
/**
|
|
67
|
-
* Splits headers into two categories: single value and multi value
|
|
68
|
-
* @param {Headers} headers
|
|
69
|
-
* @returns {{
|
|
70
|
-
* headers: Record<string, string>,
|
|
71
|
-
* multiValueHeaders: Record<string, string[]>
|
|
72
|
-
* }}
|
|
73
|
-
*/
|
|
74
|
-
function split_headers(headers) {
|
|
75
|
-
/** @type {Record<string, string>} */
|
|
76
|
-
const h = {};
|
|
77
|
-
|
|
78
|
-
/** @type {Record<string, string[]>} */
|
|
79
|
-
const m = {};
|
|
80
|
-
|
|
81
|
-
headers.forEach((value, key) => {
|
|
82
|
-
if (key === 'set-cookie') {
|
|
83
|
-
m[key] = value.split(', ');
|
|
84
|
-
} else {
|
|
85
|
-
h[key] = value;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
headers: h,
|
|
91
|
-
multiValueHeaders: m
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
96
|
export { init };
|
|
File without changes
|
package/files/esm/shims.js
CHANGED
|
@@ -4840,7 +4840,7 @@ class Body {
|
|
|
4840
4840
|
return formData;
|
|
4841
4841
|
}
|
|
4842
4842
|
|
|
4843
|
-
const {toFormData} = await import('./multipart-parser-
|
|
4843
|
+
const {toFormData} = await import('./multipart-parser-5faf185a.js');
|
|
4844
4844
|
return toFormData(this.body, ct);
|
|
4845
4845
|
}
|
|
4846
4846
|
|
|
@@ -6490,7 +6490,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6490
6490
|
}
|
|
6491
6491
|
|
|
6492
6492
|
// exported for dev/preview and node environments
|
|
6493
|
-
function
|
|
6493
|
+
function installFetch() {
|
|
6494
6494
|
Object.defineProperties(globalThis, {
|
|
6495
6495
|
fetch: {
|
|
6496
6496
|
enumerable: true,
|
|
@@ -6515,6 +6515,6 @@ function __fetch_polyfill() {
|
|
|
6515
6515
|
});
|
|
6516
6516
|
}
|
|
6517
6517
|
|
|
6518
|
-
|
|
6518
|
+
installFetch();
|
|
6519
6519
|
|
|
6520
6520
|
export { FormData as F, File as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/adapter-netlify",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.49",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,13 +31,15 @@
|
|
|
31
31
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.0.5",
|
|
34
|
-
"@sveltejs/kit": "1.0.0-next.
|
|
34
|
+
"@sveltejs/kit": "1.0.0-next.288",
|
|
35
35
|
"rimraf": "^3.0.2",
|
|
36
|
-
"rollup": "^2.58.0"
|
|
36
|
+
"rollup": "^2.58.0",
|
|
37
|
+
"uvu": "^0.5.2"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
39
40
|
"dev": "rimraf files && rollup -cw",
|
|
40
41
|
"build": "rimraf files && rollup -c",
|
|
42
|
+
"test": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
|
|
41
43
|
"lint": "eslint --ignore-path .gitignore \"**/*.{ts,js,svelte}\" && npm run check-format",
|
|
42
44
|
"format": "npm run check-format -- --write",
|
|
43
45
|
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore"
|