@sveltejs/adapter-netlify 1.0.0-next.40 → 1.0.0-next.41
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/files/cjs/handler.js +20 -24
- package/files/esm/handler.js +19 -23
- package/index.js +6 -2
- package/package.json +2 -2
package/files/cjs/handler.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('./shims-24e5b259.js');
|
|
6
|
-
var
|
|
6
|
+
var APP = require('APP');
|
|
7
7
|
require('node:http');
|
|
8
8
|
require('node:https');
|
|
9
9
|
require('node:zlib');
|
|
@@ -13,13 +13,11 @@ require('node:url');
|
|
|
13
13
|
require('net');
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
16
|
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
18
17
|
* @returns {import('@netlify/functions').Handler}
|
|
19
18
|
*/
|
|
20
19
|
function init(manifest) {
|
|
21
|
-
|
|
22
|
-
const app = new app_js.App(manifest);
|
|
20
|
+
const app = new APP.App(manifest);
|
|
23
21
|
|
|
24
22
|
return async (event) => {
|
|
25
23
|
const { httpMethod, headers, rawUrl, body, isBase64Encoded } = event;
|
|
@@ -27,25 +25,20 @@ function init(manifest) {
|
|
|
27
25
|
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
28
26
|
const rawBody = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
29
27
|
|
|
30
|
-
const rendered = await app.render(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!rendered) {
|
|
38
|
-
return {
|
|
39
|
-
statusCode: 404,
|
|
40
|
-
body: 'Not found'
|
|
41
|
-
};
|
|
42
|
-
}
|
|
28
|
+
const rendered = await app.render(
|
|
29
|
+
new Request(rawUrl, {
|
|
30
|
+
method: httpMethod,
|
|
31
|
+
headers: new Headers(headers),
|
|
32
|
+
body: rawBody
|
|
33
|
+
})
|
|
34
|
+
);
|
|
43
35
|
|
|
44
36
|
const partial_response = {
|
|
45
37
|
statusCode: rendered.status,
|
|
46
38
|
...split_headers(rendered.headers)
|
|
47
39
|
};
|
|
48
40
|
|
|
41
|
+
// TODO this is probably wrong now?
|
|
49
42
|
if (rendered.body instanceof Uint8Array) {
|
|
50
43
|
// Function responses should be strings (or undefined), and responses with binary
|
|
51
44
|
// content should be base64 encoded and set isBase64Encoded to true.
|
|
@@ -59,14 +52,14 @@ function init(manifest) {
|
|
|
59
52
|
|
|
60
53
|
return {
|
|
61
54
|
...partial_response,
|
|
62
|
-
body: rendered.
|
|
55
|
+
body: await rendered.text()
|
|
63
56
|
};
|
|
64
57
|
};
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
61
|
* Splits headers into two categories: single value and multi value
|
|
69
|
-
* @param {
|
|
62
|
+
* @param {Headers} headers
|
|
70
63
|
* @returns {{
|
|
71
64
|
* headers: Record<string, string>,
|
|
72
65
|
* multiValueHeaders: Record<string, string[]>
|
|
@@ -79,11 +72,14 @@ function split_headers(headers) {
|
|
|
79
72
|
/** @type {Record<string, string[]>} */
|
|
80
73
|
const m = {};
|
|
81
74
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
headers.forEach((value, key) => {
|
|
76
|
+
if (key === 'set-cookie') {
|
|
77
|
+
m[key] = value.split(', ');
|
|
78
|
+
} else {
|
|
79
|
+
h[key] = value;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
87
83
|
return {
|
|
88
84
|
headers: h,
|
|
89
85
|
multiValueHeaders: m
|
package/files/esm/handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './shims-c8fba98f.js';
|
|
2
|
-
import { App } from '
|
|
2
|
+
import { App } from 'APP';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import 'node:https';
|
|
5
5
|
import 'node:zlib';
|
|
@@ -9,12 +9,10 @@ import 'node:url';
|
|
|
9
9
|
import 'net';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
12
|
* @param {import('@sveltejs/kit').SSRManifest} manifest
|
|
14
13
|
* @returns {import('@netlify/functions').Handler}
|
|
15
14
|
*/
|
|
16
15
|
function init(manifest) {
|
|
17
|
-
/** @type {import('@sveltejs/kit').App} */
|
|
18
16
|
const app = new App(manifest);
|
|
19
17
|
|
|
20
18
|
return async (event) => {
|
|
@@ -23,25 +21,20 @@ function init(manifest) {
|
|
|
23
21
|
const encoding = isBase64Encoded ? 'base64' : 'utf-8';
|
|
24
22
|
const rawBody = typeof body === 'string' ? Buffer.from(body, encoding) : body;
|
|
25
23
|
|
|
26
|
-
const rendered = await app.render(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!rendered) {
|
|
34
|
-
return {
|
|
35
|
-
statusCode: 404,
|
|
36
|
-
body: 'Not found'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
24
|
+
const rendered = await app.render(
|
|
25
|
+
new Request(rawUrl, {
|
|
26
|
+
method: httpMethod,
|
|
27
|
+
headers: new Headers(headers),
|
|
28
|
+
body: rawBody
|
|
29
|
+
})
|
|
30
|
+
);
|
|
39
31
|
|
|
40
32
|
const partial_response = {
|
|
41
33
|
statusCode: rendered.status,
|
|
42
34
|
...split_headers(rendered.headers)
|
|
43
35
|
};
|
|
44
36
|
|
|
37
|
+
// TODO this is probably wrong now?
|
|
45
38
|
if (rendered.body instanceof Uint8Array) {
|
|
46
39
|
// Function responses should be strings (or undefined), and responses with binary
|
|
47
40
|
// content should be base64 encoded and set isBase64Encoded to true.
|
|
@@ -55,14 +48,14 @@ function init(manifest) {
|
|
|
55
48
|
|
|
56
49
|
return {
|
|
57
50
|
...partial_response,
|
|
58
|
-
body: rendered.
|
|
51
|
+
body: await rendered.text()
|
|
59
52
|
};
|
|
60
53
|
};
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
/**
|
|
64
57
|
* Splits headers into two categories: single value and multi value
|
|
65
|
-
* @param {
|
|
58
|
+
* @param {Headers} headers
|
|
66
59
|
* @returns {{
|
|
67
60
|
* headers: Record<string, string>,
|
|
68
61
|
* multiValueHeaders: Record<string, string[]>
|
|
@@ -75,11 +68,14 @@ function split_headers(headers) {
|
|
|
75
68
|
/** @type {Record<string, string[]>} */
|
|
76
69
|
const m = {};
|
|
77
70
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
headers.forEach((value, key) => {
|
|
72
|
+
if (key === 'set-cookie') {
|
|
73
|
+
m[key] = value.split(', ');
|
|
74
|
+
} else {
|
|
75
|
+
h[key] = value;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
83
79
|
return {
|
|
84
80
|
headers: h,
|
|
85
81
|
multiValueHeaders: m
|
package/index.js
CHANGED
|
@@ -50,8 +50,12 @@ export default function ({ split = false } = {}) {
|
|
|
50
50
|
/** @type {string[]} */
|
|
51
51
|
const redirects = [];
|
|
52
52
|
|
|
53
|
+
const replace = {
|
|
54
|
+
APP: './server/app.js'
|
|
55
|
+
};
|
|
56
|
+
|
|
53
57
|
if (esm) {
|
|
54
|
-
builder.copy(`${files}/esm`, '.netlify');
|
|
58
|
+
builder.copy(`${files}/esm`, '.netlify', { replace });
|
|
55
59
|
} else {
|
|
56
60
|
glob('**/*.js', { cwd: '.netlify/server' }).forEach((file) => {
|
|
57
61
|
const filepath = `.netlify/server/${file}`;
|
|
@@ -60,7 +64,7 @@ export default function ({ split = false } = {}) {
|
|
|
60
64
|
writeFileSync(filepath, output);
|
|
61
65
|
});
|
|
62
66
|
|
|
63
|
-
builder.copy(`${files}/cjs`, '.netlify');
|
|
67
|
+
builder.copy(`${files}/cjs`, '.netlify', { replace });
|
|
64
68
|
writeFileSync(join('.netlify', 'package.json'), JSON.stringify({ type: 'commonjs' }));
|
|
65
69
|
}
|
|
66
70
|
|
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.41",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -31,7 +31,7 @@
|
|
|
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.234",
|
|
35
35
|
"rimraf": "^3.0.2",
|
|
36
36
|
"rollup": "^2.58.0"
|
|
37
37
|
},
|