@sveltejs/adapter-netlify 1.0.0-next.45 → 1.0.0-next.48
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 +1 -2
- package/files/cjs/handler.js +33 -32
- 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 +33 -32
- package/files/esm/{multipart-parser-781607e4.js → multipart-parser-5faf185a.js} +0 -0
- package/files/esm/shims.js +3 -3
- package/index.js +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ During compilation, redirect rules are automatically appended to your `_redirect
|
|
|
52
52
|
### Using Netlify Forms
|
|
53
53
|
|
|
54
54
|
1. Create your Netlify HTML form as described [here](https://docs.netlify.com/forms/setup/#html-forms), e.g. as `/routes/contact.svelte`. (Don't forget to add the hidden `form-name` input element!)
|
|
55
|
-
2. Netlify's build bot parses your HTML files at deploy time, which means your form must be [prerendered](https://kit.svelte.dev/docs
|
|
55
|
+
2. Netlify's build bot parses your HTML files at deploy time, which means your form must be [prerendered](https://kit.svelte.dev/docs/page-options#prerender) as HTML. You can either add `export const prerender = true` to your `contact.svelte` to prerender just that page or set the `kit.prerender.force: true` option to prerender all pages.
|
|
56
56
|
3. If your Netlify form has a [custom success message](https://docs.netlify.com/forms/setup/#success-messages) like `<form netlify ... action="/success">` then ensure the corresponding `/routes/success.svelte` exists and is prerendered.
|
|
57
57
|
|
|
58
58
|
### Using Netlify Functions
|
|
@@ -66,7 +66,6 @@ During compilation, redirect rules are automatically appended to your `_redirect
|
|
|
66
66
|
|
|
67
67
|
[functions]
|
|
68
68
|
directory = "functions"
|
|
69
|
-
node_bundler = "esbuild"
|
|
70
69
|
```
|
|
71
70
|
|
|
72
71
|
## Changelog
|
package/files/cjs/handler.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('./shims.js');
|
|
6
|
-
var
|
|
6
|
+
var _0SERVER = require('0SERVER');
|
|
7
7
|
require('node:http');
|
|
8
8
|
require('node:https');
|
|
9
9
|
require('node:zlib');
|
|
@@ -12,15 +12,45 @@ 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}
|
|
18
48
|
*/
|
|
19
49
|
function init(manifest) {
|
|
20
|
-
const
|
|
50
|
+
const server = new _0SERVER.Server(manifest);
|
|
21
51
|
|
|
22
52
|
return async (event) => {
|
|
23
|
-
const rendered = await
|
|
53
|
+
const rendered = await server.respond(to_request(event));
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './shims.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Server } from '0SERVER';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import 'node:https';
|
|
5
5
|
import 'node:zlib';
|
|
@@ -8,15 +8,45 @@ 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}
|
|
14
44
|
*/
|
|
15
45
|
function init(manifest) {
|
|
16
|
-
const
|
|
46
|
+
const server = new Server(manifest);
|
|
17
47
|
|
|
18
48
|
return async (event) => {
|
|
19
|
-
const rendered = await
|
|
49
|
+
const rendered = await server.respond(to_request(event));
|
|
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/index.js
CHANGED
|
@@ -51,7 +51,7 @@ export default function ({ split = false } = {}) {
|
|
|
51
51
|
const redirects = [];
|
|
52
52
|
|
|
53
53
|
const replace = {
|
|
54
|
-
'
|
|
54
|
+
'0SERVER': './server/index.js' // digit prefix prevents CJS build from using this as a variable name, which would also get replaced
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
if (esm) {
|
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.48",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
"tiny-glob": "^0.2.9"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@netlify/functions": "^0.
|
|
30
|
+
"@netlify/functions": "^1.0.0",
|
|
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.287",
|
|
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"
|