@sveltejs/adapter-netlify 4.3.3 → 4.3.5

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/edge.js CHANGED
@@ -54,6 +54,8 @@ function is_static_file(request) {
54
54
  return (
55
55
  manifest.assets.has(file) ||
56
56
  manifest.assets.has(file + '/index.html') ||
57
+ file in manifest._.server_assets ||
58
+ file + '/index.html' in manifest._.server_assets ||
57
59
  prerendered.has(pathname || '/')
58
60
  );
59
61
  }
@@ -2,235 +2,246 @@ import './shims.js';
2
2
  import { Server } from '0SERVER';
3
3
  import { createReadStream } from 'node:fs';
4
4
  import { Readable } from 'node:stream';
5
+ import process from 'node:process';
5
6
  import 'node:buffer';
6
7
  import 'node:crypto';
7
8
 
8
9
  var setCookie = {exports: {}};
9
10
 
10
- var defaultParseOptions = {
11
- decodeValues: true,
12
- map: false,
13
- silent: false,
14
- };
11
+ var hasRequiredSetCookie;
15
12
 
16
- function isNonEmptyString(str) {
17
- return typeof str === "string" && !!str.trim();
18
- }
13
+ function requireSetCookie () {
14
+ if (hasRequiredSetCookie) return setCookie.exports;
15
+ hasRequiredSetCookie = 1;
19
16
 
20
- function parseString(setCookieValue, options) {
21
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
22
-
23
- var nameValuePairStr = parts.shift();
24
- var parsed = parseNameValuePair(nameValuePairStr);
25
- var name = parsed.name;
26
- var value = parsed.value;
27
-
28
- options = options
29
- ? Object.assign({}, defaultParseOptions, options)
30
- : defaultParseOptions;
31
-
32
- try {
33
- value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
34
- } catch (e) {
35
- console.error(
36
- "set-cookie-parser encountered an error while decoding a cookie with value '" +
37
- value +
38
- "'. Set options.decodeValues to false to disable this feature.",
39
- e
40
- );
41
- }
42
-
43
- var cookie = {
44
- name: name,
45
- value: value,
46
- };
47
-
48
- parts.forEach(function (part) {
49
- var sides = part.split("=");
50
- var key = sides.shift().trimLeft().toLowerCase();
51
- var value = sides.join("=");
52
- if (key === "expires") {
53
- cookie.expires = new Date(value);
54
- } else if (key === "max-age") {
55
- cookie.maxAge = parseInt(value, 10);
56
- } else if (key === "secure") {
57
- cookie.secure = true;
58
- } else if (key === "httponly") {
59
- cookie.httpOnly = true;
60
- } else if (key === "samesite") {
61
- cookie.sameSite = value;
62
- } else {
63
- cookie[key] = value;
64
- }
65
- });
66
-
67
- return cookie;
68
- }
17
+ var defaultParseOptions = {
18
+ decodeValues: true,
19
+ map: false,
20
+ silent: false,
21
+ };
69
22
 
70
- function parseNameValuePair(nameValuePairStr) {
71
- // Parses name-value-pair according to rfc6265bis draft
23
+ function isNonEmptyString(str) {
24
+ return typeof str === "string" && !!str.trim();
25
+ }
72
26
 
73
- var name = "";
74
- var value = "";
75
- var nameValueArr = nameValuePairStr.split("=");
76
- if (nameValueArr.length > 1) {
77
- name = nameValueArr.shift();
78
- value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
79
- } else {
80
- value = nameValuePairStr;
81
- }
27
+ function parseString(setCookieValue, options) {
28
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
29
+
30
+ var nameValuePairStr = parts.shift();
31
+ var parsed = parseNameValuePair(nameValuePairStr);
32
+ var name = parsed.name;
33
+ var value = parsed.value;
34
+
35
+ options = options
36
+ ? Object.assign({}, defaultParseOptions, options)
37
+ : defaultParseOptions;
38
+
39
+ try {
40
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
41
+ } catch (e) {
42
+ console.error(
43
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
44
+ value +
45
+ "'. Set options.decodeValues to false to disable this feature.",
46
+ e
47
+ );
48
+ }
49
+
50
+ var cookie = {
51
+ name: name,
52
+ value: value,
53
+ };
54
+
55
+ parts.forEach(function (part) {
56
+ var sides = part.split("=");
57
+ var key = sides.shift().trimLeft().toLowerCase();
58
+ var value = sides.join("=");
59
+ if (key === "expires") {
60
+ cookie.expires = new Date(value);
61
+ } else if (key === "max-age") {
62
+ cookie.maxAge = parseInt(value, 10);
63
+ } else if (key === "secure") {
64
+ cookie.secure = true;
65
+ } else if (key === "httponly") {
66
+ cookie.httpOnly = true;
67
+ } else if (key === "samesite") {
68
+ cookie.sameSite = value;
69
+ } else {
70
+ cookie[key] = value;
71
+ }
72
+ });
73
+
74
+ return cookie;
75
+ }
82
76
 
83
- return { name: name, value: value };
84
- }
77
+ function parseNameValuePair(nameValuePairStr) {
78
+ // Parses name-value-pair according to rfc6265bis draft
85
79
 
86
- function parse(input, options) {
87
- options = options
88
- ? Object.assign({}, defaultParseOptions, options)
89
- : defaultParseOptions;
90
-
91
- if (!input) {
92
- if (!options.map) {
93
- return [];
94
- } else {
95
- return {};
96
- }
97
- }
98
-
99
- if (input.headers) {
100
- if (typeof input.headers.getSetCookie === "function") {
101
- // for fetch responses - they combine headers of the same type in the headers array,
102
- // but getSetCookie returns an uncombined array
103
- input = input.headers.getSetCookie();
104
- } else if (input.headers["set-cookie"]) {
105
- // fast-path for node.js (which automatically normalizes header names to lower-case
106
- input = input.headers["set-cookie"];
107
- } else {
108
- // slow-path for other environments - see #25
109
- var sch =
110
- input.headers[
111
- Object.keys(input.headers).find(function (key) {
112
- return key.toLowerCase() === "set-cookie";
113
- })
114
- ];
115
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
116
- if (!sch && input.headers.cookie && !options.silent) {
117
- console.warn(
118
- "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."
119
- );
120
- }
121
- input = sch;
122
- }
123
- }
124
- if (!Array.isArray(input)) {
125
- input = [input];
126
- }
127
-
128
- options = options
129
- ? Object.assign({}, defaultParseOptions, options)
130
- : defaultParseOptions;
131
-
132
- if (!options.map) {
133
- return input.filter(isNonEmptyString).map(function (str) {
134
- return parseString(str, options);
135
- });
136
- } else {
137
- var cookies = {};
138
- return input.filter(isNonEmptyString).reduce(function (cookies, str) {
139
- var cookie = parseString(str, options);
140
- cookies[cookie.name] = cookie;
141
- return cookies;
142
- }, cookies);
143
- }
144
- }
80
+ var name = "";
81
+ var value = "";
82
+ var nameValueArr = nameValuePairStr.split("=");
83
+ if (nameValueArr.length > 1) {
84
+ name = nameValueArr.shift();
85
+ value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
86
+ } else {
87
+ value = nameValuePairStr;
88
+ }
89
+
90
+ return { name: name, value: value };
91
+ }
92
+
93
+ function parse(input, options) {
94
+ options = options
95
+ ? Object.assign({}, defaultParseOptions, options)
96
+ : defaultParseOptions;
97
+
98
+ if (!input) {
99
+ if (!options.map) {
100
+ return [];
101
+ } else {
102
+ return {};
103
+ }
104
+ }
105
+
106
+ if (input.headers) {
107
+ if (typeof input.headers.getSetCookie === "function") {
108
+ // for fetch responses - they combine headers of the same type in the headers array,
109
+ // but getSetCookie returns an uncombined array
110
+ input = input.headers.getSetCookie();
111
+ } else if (input.headers["set-cookie"]) {
112
+ // fast-path for node.js (which automatically normalizes header names to lower-case
113
+ input = input.headers["set-cookie"];
114
+ } else {
115
+ // slow-path for other environments - see #25
116
+ var sch =
117
+ input.headers[
118
+ Object.keys(input.headers).find(function (key) {
119
+ return key.toLowerCase() === "set-cookie";
120
+ })
121
+ ];
122
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
123
+ if (!sch && input.headers.cookie && !options.silent) {
124
+ console.warn(
125
+ "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."
126
+ );
127
+ }
128
+ input = sch;
129
+ }
130
+ }
131
+ if (!Array.isArray(input)) {
132
+ input = [input];
133
+ }
134
+
135
+ options = options
136
+ ? Object.assign({}, defaultParseOptions, options)
137
+ : defaultParseOptions;
138
+
139
+ if (!options.map) {
140
+ return input.filter(isNonEmptyString).map(function (str) {
141
+ return parseString(str, options);
142
+ });
143
+ } else {
144
+ var cookies = {};
145
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
146
+ var cookie = parseString(str, options);
147
+ cookies[cookie.name] = cookie;
148
+ return cookies;
149
+ }, cookies);
150
+ }
151
+ }
152
+
153
+ /*
154
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
155
+ that are within a single set-cookie field-value, such as in the Expires portion.
156
+
157
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
158
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
159
+ React Native's fetch does this for *every* header, including set-cookie.
160
+
161
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
162
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
163
+ */
164
+ function splitCookiesString(cookiesString) {
165
+ if (Array.isArray(cookiesString)) {
166
+ return cookiesString;
167
+ }
168
+ if (typeof cookiesString !== "string") {
169
+ return [];
170
+ }
171
+
172
+ var cookiesStrings = [];
173
+ var pos = 0;
174
+ var start;
175
+ var ch;
176
+ var lastComma;
177
+ var nextStart;
178
+ var cookiesSeparatorFound;
179
+
180
+ function skipWhitespace() {
181
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
182
+ pos += 1;
183
+ }
184
+ return pos < cookiesString.length;
185
+ }
186
+
187
+ function notSpecialChar() {
188
+ ch = cookiesString.charAt(pos);
189
+
190
+ return ch !== "=" && ch !== ";" && ch !== ",";
191
+ }
192
+
193
+ while (pos < cookiesString.length) {
194
+ start = pos;
195
+ cookiesSeparatorFound = false;
196
+
197
+ while (skipWhitespace()) {
198
+ ch = cookiesString.charAt(pos);
199
+ if (ch === ",") {
200
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
201
+ lastComma = pos;
202
+ pos += 1;
203
+
204
+ skipWhitespace();
205
+ nextStart = pos;
206
+
207
+ while (pos < cookiesString.length && notSpecialChar()) {
208
+ pos += 1;
209
+ }
210
+
211
+ // currently special character
212
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
213
+ // we found cookies separator
214
+ cookiesSeparatorFound = true;
215
+ // pos is inside the next cookie, so back up and return it.
216
+ pos = nextStart;
217
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
218
+ start = pos;
219
+ } else {
220
+ // in param ',' or param separator ';',
221
+ // we continue from that comma
222
+ pos = lastComma + 1;
223
+ }
224
+ } else {
225
+ pos += 1;
226
+ }
227
+ }
228
+
229
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
230
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
231
+ }
232
+ }
233
+
234
+ return cookiesStrings;
235
+ }
145
236
 
146
- /*
147
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
148
- that are within a single set-cookie field-value, such as in the Expires portion.
149
-
150
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
151
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
152
- React Native's fetch does this for *every* header, including set-cookie.
153
-
154
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
155
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
156
- */
157
- function splitCookiesString(cookiesString) {
158
- if (Array.isArray(cookiesString)) {
159
- return cookiesString;
160
- }
161
- if (typeof cookiesString !== "string") {
162
- return [];
163
- }
164
-
165
- var cookiesStrings = [];
166
- var pos = 0;
167
- var start;
168
- var ch;
169
- var lastComma;
170
- var nextStart;
171
- var cookiesSeparatorFound;
172
-
173
- function skipWhitespace() {
174
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
175
- pos += 1;
176
- }
177
- return pos < cookiesString.length;
178
- }
179
-
180
- function notSpecialChar() {
181
- ch = cookiesString.charAt(pos);
182
-
183
- return ch !== "=" && ch !== ";" && ch !== ",";
184
- }
185
-
186
- while (pos < cookiesString.length) {
187
- start = pos;
188
- cookiesSeparatorFound = false;
189
-
190
- while (skipWhitespace()) {
191
- ch = cookiesString.charAt(pos);
192
- if (ch === ",") {
193
- // ',' is a cookie separator if we have later first '=', not ';' or ','
194
- lastComma = pos;
195
- pos += 1;
196
-
197
- skipWhitespace();
198
- nextStart = pos;
199
-
200
- while (pos < cookiesString.length && notSpecialChar()) {
201
- pos += 1;
202
- }
203
-
204
- // currently special character
205
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
206
- // we found cookies separator
207
- cookiesSeparatorFound = true;
208
- // pos is inside the next cookie, so back up and return it.
209
- pos = nextStart;
210
- cookiesStrings.push(cookiesString.substring(start, lastComma));
211
- start = pos;
212
- } else {
213
- // in param ',' or param separator ';',
214
- // we continue from that comma
215
- pos = lastComma + 1;
216
- }
217
- } else {
218
- pos += 1;
219
- }
220
- }
221
-
222
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
223
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
224
- }
225
- }
226
-
227
- return cookiesStrings;
237
+ setCookie.exports = parse;
238
+ setCookie.exports.parse = parse;
239
+ setCookie.exports.parseString = parseString;
240
+ setCookie.exports.splitCookiesString = splitCookiesString;
241
+ return setCookie.exports;
228
242
  }
229
243
 
230
- setCookie.exports = parse;
231
- setCookie.exports.parse = parse;
232
- setCookie.exports.parseString = parseString;
233
- var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
244
+ var setCookieExports = /*@__PURE__*/ requireSetCookie();
234
245
 
235
246
  /**
236
247
  * Splits headers into two categories: single value and multi value
@@ -250,7 +261,7 @@ function split_headers(headers) {
250
261
  headers.forEach((value, key) => {
251
262
  if (key === 'set-cookie') {
252
263
  if (!m[key]) m[key] = [];
253
- m[key].push(...splitCookiesString_1(value));
264
+ m[key].push(...setCookieExports.splitCookiesString(value));
254
265
  } else {
255
266
  h[key] = value;
256
267
  }
package/index.js CHANGED
@@ -2,6 +2,7 @@ import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync }
2
2
  import { dirname, join, resolve, posix } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { builtinModules } from 'node:module';
5
+ import process from 'node:process';
5
6
  import esbuild from 'esbuild';
6
7
  import toml from '@iarna/toml';
7
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "4.3.3",
3
+ "version": "4.3.5",
4
4
  "description": "A SvelteKit adapter that creates a Netlify app",
5
5
  "keywords": [
6
6
  "adapter",
@@ -38,16 +38,16 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@netlify/functions": "^2.4.1",
41
- "@rollup/plugin-commonjs": "^26.0.1",
41
+ "@rollup/plugin-commonjs": "^28.0.0",
42
42
  "@rollup/plugin-json": "^6.1.0",
43
- "@rollup/plugin-node-resolve": "^15.2.3",
43
+ "@rollup/plugin-node-resolve": "^15.3.0",
44
44
  "@sveltejs/vite-plugin-svelte": "^3.0.1",
45
- "@types/node": "^18.19.3",
45
+ "@types/node": "^18.19.48",
46
46
  "@types/set-cookie-parser": "^2.4.7",
47
47
  "rollup": "^4.14.2",
48
48
  "typescript": "^5.3.3",
49
49
  "vitest": "^2.0.1",
50
- "@sveltejs/kit": "^2.5.22"
50
+ "@sveltejs/kit": "^2.7.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@sveltejs/kit": "^2.4.0"