@sveltejs/adapter-netlify 1.0.4 → 1.0.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.
@@ -648,8 +648,23 @@ function ReadableStreamFrom$1 (iterable) {
648
648
  )
649
649
  }
650
650
 
651
+ // The chunk should be a FormData instance and contains
652
+ // all the required methods.
651
653
  function isFormDataLike (chunk) {
652
- return chunk && chunk.constructor && chunk.constructor.name === 'FormData'
654
+ return (chunk &&
655
+ chunk.constructor && chunk.constructor.name === 'FormData' &&
656
+ typeof chunk === 'object' &&
657
+ (typeof chunk.append === 'function' &&
658
+ typeof chunk.delete === 'function' &&
659
+ typeof chunk.get === 'function' &&
660
+ typeof chunk.getAll === 'function' &&
661
+ typeof chunk.has === 'function' &&
662
+ typeof chunk.set === 'function' &&
663
+ typeof chunk.entries === 'function' &&
664
+ typeof chunk.keys === 'function' &&
665
+ typeof chunk.values === 'function' &&
666
+ typeof chunk.forEach === 'function')
667
+ )
653
668
  }
654
669
 
655
670
  const kEnumerableProperty = Object.create(null);
@@ -4461,6 +4476,12 @@ function requireDataURL () {
4461
4476
 
4462
4477
  const encoder = new TextEncoder();
4463
4478
 
4479
+ // Regex
4480
+ const HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-z0-9]+$/;
4481
+ const HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/; // eslint-disable-line
4482
+ // https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point
4483
+ const HTTP_QUOTED_STRING_TOKENS = /^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/; // eslint-disable-line
4484
+
4464
4485
  // https://fetch.spec.whatwg.org/#data-url-processor
4465
4486
  /** @param {URL} dataURL */
4466
4487
  function dataURLProcessor (dataURL) {
@@ -4673,7 +4694,7 @@ function requireDataURL () {
4673
4694
  // 4. If type is the empty string or does not solely
4674
4695
  // contain HTTP token code points, then return failure.
4675
4696
  // https://mimesniff.spec.whatwg.org/#http-token-code-point
4676
- if (type.length === 0 || !/^[!#$%&'*+-.^_|~A-z0-9]+$/.test(type)) {
4697
+ if (type.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(type)) {
4677
4698
  return 'failure'
4678
4699
  }
4679
4700
 
@@ -4700,7 +4721,7 @@ function requireDataURL () {
4700
4721
 
4701
4722
  // 9. If subtype is the empty string or does not solely
4702
4723
  // contain HTTP token code points, then return failure.
4703
- if (subtype.length === 0 || !/^[!#$%&'*+-.^_|~A-z0-9]+$/.test(subtype)) {
4724
+ if (subtype.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(subtype)) {
4704
4725
  return 'failure'
4705
4726
  }
4706
4727
 
@@ -4714,9 +4735,7 @@ function requireDataURL () {
4714
4735
  /** @type {Map<string, string>} */
4715
4736
  parameters: new Map(),
4716
4737
  // https://mimesniff.spec.whatwg.org/#mime-type-essence
4717
- get essence () {
4718
- return `${this.type}/${this.subtype}`
4719
- }
4738
+ essence: `${type}/${subtype}`
4720
4739
  };
4721
4740
 
4722
4741
  // 11. While position is not past the end of input:
@@ -4728,7 +4747,7 @@ function requireDataURL () {
4728
4747
  // whitespace from input given position.
4729
4748
  collectASequenceOfCodePoints(
4730
4749
  // https://fetch.spec.whatwg.org/#http-whitespace
4731
- (char) => /(\u000A|\u000D|\u0009|\u0020)/.test(char), // eslint-disable-line
4750
+ char => HTTP_WHITESPACE_REGEX.test(char),
4732
4751
  input,
4733
4752
  position
4734
4753
  );
@@ -4811,9 +4830,8 @@ function requireDataURL () {
4811
4830
  // then set mimeType’s parameters[parameterName] to parameterValue.
4812
4831
  if (
4813
4832
  parameterName.length !== 0 &&
4814
- /^[!#$%&'*+-.^_|~A-z0-9]+$/.test(parameterName) &&
4815
- // https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point
4816
- !/^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/.test(parameterValue) && // eslint-disable-line
4833
+ HTTP_TOKEN_CODEPOINTS.test(parameterName) &&
4834
+ !HTTP_QUOTED_STRING_TOKENS.test(parameterValue) &&
4817
4835
  !mimeType.parameters.has(parameterName)
4818
4836
  ) {
4819
4837
  mimeType.parameters.set(parameterName, parameterValue);
@@ -5615,7 +5633,7 @@ function requireFormdata () {
5615
5633
  lastModified: value.lastModified
5616
5634
  };
5617
5635
 
5618
- value = value instanceof File
5636
+ value = (NativeFile && value instanceof NativeFile) || value instanceof UndiciFile
5619
5637
  ? new File([value], filename, options)
5620
5638
  : new FileLike(value, filename, options);
5621
5639
  }
@@ -6376,7 +6394,7 @@ let Request$1 = class Request {
6376
6394
 
6377
6395
  this.blocking = blocking == null ? false : blocking;
6378
6396
 
6379
- this.reset = reset == null ? false : reset;
6397
+ this.reset = reset == null ? null : reset;
6380
6398
 
6381
6399
  this.host = null;
6382
6400
 
@@ -7926,9 +7944,8 @@ async function lazyllhttp () {
7926
7944
  }
7927
7945
 
7928
7946
  let llhttpInstance = null;
7929
- let llhttpPromise = lazyllhttp()
7930
- .catch(() => {
7931
- });
7947
+ let llhttpPromise = lazyllhttp();
7948
+ llhttpPromise.catch();
7932
7949
 
7933
7950
  let currentParser = null;
7934
7951
  let currentBufferRef = null;
@@ -7964,6 +7981,7 @@ class Parser {
7964
7981
 
7965
7982
  this.keepAlive = '';
7966
7983
  this.contentLength = '';
7984
+ this.connection = '';
7967
7985
  this.maxResponseSize = client[kMaxResponseSize];
7968
7986
  }
7969
7987
 
@@ -8139,6 +8157,8 @@ class Parser {
8139
8157
  const key = this.headers[len - 2];
8140
8158
  if (key.length === 10 && key.toString().toLowerCase() === 'keep-alive') {
8141
8159
  this.keepAlive += buf.toString();
8160
+ } else if (key.length === 10 && key.toString().toLowerCase() === 'connection') {
8161
+ this.connection += buf.toString();
8142
8162
  } else if (key.length === 14 && key.toString().toLowerCase() === 'content-length') {
8143
8163
  this.contentLength += buf.toString();
8144
8164
  }
@@ -8232,7 +8252,11 @@ class Parser {
8232
8252
  assert$3.strictEqual(this.timeoutType, TIMEOUT_HEADERS);
8233
8253
 
8234
8254
  this.statusCode = statusCode;
8235
- this.shouldKeepAlive = shouldKeepAlive;
8255
+ this.shouldKeepAlive = (
8256
+ shouldKeepAlive ||
8257
+ // Override llhttp value which does not allow keepAlive for HEAD.
8258
+ (request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive')
8259
+ );
8236
8260
 
8237
8261
  if (this.statusCode >= 200) {
8238
8262
  const bodyTimeout = request.bodyTimeout != null
@@ -8262,7 +8286,7 @@ class Parser {
8262
8286
  this.headers = [];
8263
8287
  this.headersSize = 0;
8264
8288
 
8265
- if (shouldKeepAlive && client[kPipelining]) {
8289
+ if (this.shouldKeepAlive && client[kPipelining]) {
8266
8290
  const keepAliveTimeout = this.keepAlive ? util$b.parseKeepAliveTimeout(this.keepAlive) : null;
8267
8291
 
8268
8292
  if (keepAliveTimeout != null) {
@@ -8292,7 +8316,6 @@ class Parser {
8292
8316
  }
8293
8317
 
8294
8318
  if (request.method === 'HEAD') {
8295
- assert$3(socket[kReset]);
8296
8319
  return 1
8297
8320
  }
8298
8321
 
@@ -8366,6 +8389,7 @@ class Parser {
8366
8389
  this.bytesRead = 0;
8367
8390
  this.contentLength = '';
8368
8391
  this.keepAlive = '';
8392
+ this.connection = '';
8369
8393
 
8370
8394
  assert$3(this.headers.length % 2 === 0);
8371
8395
  this.headers = [];
@@ -8590,8 +8614,6 @@ async function connect$1 (client) {
8590
8614
 
8591
8615
  assert$3(socket);
8592
8616
 
8593
- client[kSocket] = socket;
8594
-
8595
8617
  socket[kNoRef] = false;
8596
8618
  socket[kWriting] = false;
8597
8619
  socket[kReset] = false;
@@ -8607,6 +8629,8 @@ async function connect$1 (client) {
8607
8629
  .on('end', onSocketEnd)
8608
8630
  .on('close', onSocketClose);
8609
8631
 
8632
+ client[kSocket] = socket;
8633
+
8610
8634
  if (channels.connected.hasSubscribers) {
8611
8635
  channels.connected.publish({
8612
8636
  connectParams: {
@@ -8692,7 +8716,7 @@ function _resume (client, sync) {
8692
8716
 
8693
8717
  const socket = client[kSocket];
8694
8718
 
8695
- if (socket) {
8719
+ if (socket && !socket.destroyed) {
8696
8720
  if (client[kSize$4] === 0) {
8697
8721
  if (!socket[kNoRef] && socket.unref) {
8698
8722
  socket.unref();
@@ -8759,7 +8783,7 @@ function _resume (client, sync) {
8759
8783
 
8760
8784
  if (!socket) {
8761
8785
  connect$1(client);
8762
- continue
8786
+ return
8763
8787
  }
8764
8788
 
8765
8789
  if (socket.destroyed || socket[kWriting] || socket[kReset] || socket[kBlocking]) {
@@ -8899,8 +8923,8 @@ function write (client, request) {
8899
8923
  socket[kReset] = true;
8900
8924
  }
8901
8925
 
8902
- if (reset) {
8903
- socket[kReset] = true;
8926
+ if (reset != null) {
8927
+ socket[kReset] = reset;
8904
8928
  }
8905
8929
 
8906
8930
  if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) {
@@ -12264,7 +12288,7 @@ class ProxyAgent extends DispatcherBase {
12264
12288
 
12265
12289
  this[kRequestTls] = opts.requestTls;
12266
12290
  this[kProxyTls] = opts.proxyTls;
12267
- this[kProxyHeaders] = {};
12291
+ this[kProxyHeaders] = opts.headers || {};
12268
12292
 
12269
12293
  if (opts.auth && opts.token) {
12270
12294
  throw new InvalidArgumentError$1('opts.auth cannot be used in combination with opts.token')
@@ -14554,7 +14578,7 @@ function requireFetch () {
14554
14578
  const { isErrored, isReadable } = util$g;
14555
14579
  const { dataURLProcessor, serializeAMimeType } = requireDataURL();
14556
14580
  const { TransformStream } = require$$13;
14557
- const { getGlobalDispatcher } = requireUndici();
14581
+ const { getGlobalDispatcher } = global$2;
14558
14582
  const { webidl } = requireWebidl();
14559
14583
  const { STATUS_CODES } = require$$2;
14560
14584
 
@@ -16375,8 +16399,6 @@ function requireFetch () {
16375
16399
  body: fetchParams.controller.dispatcher.isMockActive ? request.body && request.body.source : body,
16376
16400
  headers: request.headersList[kHeadersCaseInsensitive],
16377
16401
  maxRedirections: 0,
16378
- bodyTimeout: 300_000,
16379
- headersTimeout: 300_000,
16380
16402
  upgrade: request.mode === 'websocket' ? 'websocket' : undefined
16381
16403
  },
16382
16404
  {
@@ -19554,7 +19576,6 @@ function requireConnection () {
19554
19576
  if (hasRequiredConnection) return connection;
19555
19577
  hasRequiredConnection = 1;
19556
19578
 
19557
- // TODO: crypto isn't available in all environments
19558
19579
  const { randomBytes, createHash } = require$$0$5;
19559
19580
  const diagnosticsChannel = require$$1$2;
19560
19581
  const { uid, states } = requireConstants();
@@ -20192,23 +20213,14 @@ function requireWebsocket () {
20192
20213
  // not throw an exception must increase the bufferedAmount attribute
20193
20214
  // by the length of data’s buffer in bytes.
20194
20215
 
20195
- const ab = new ArrayBuffer(data.byteLength);
20216
+ const ab = Buffer.from(data, data.byteOffset, data.byteLength);
20196
20217
 
20197
- if (Buffer.isBuffer(data)) {
20198
- // new Buffer signature is deprecated
20199
- Buffer.from(ab).set(data);
20200
- } else {
20201
- new data.constructor(ab).set(data);
20202
- }
20203
-
20204
- const value = Buffer.from(ab);
20205
-
20206
- const frame = new WebsocketFrameSend(value);
20218
+ const frame = new WebsocketFrameSend(ab);
20207
20219
  const buffer = frame.createFrame(opcodes.BINARY);
20208
20220
 
20209
- this.#bufferedAmount += value.byteLength;
20221
+ this.#bufferedAmount += ab.byteLength;
20210
20222
  socket.write(buffer, () => {
20211
- this.#bufferedAmount -= value.byteLength;
20223
+ this.#bufferedAmount -= ab.byteLength;
20212
20224
  });
20213
20225
  } else if (isBlobLike(data)) {
20214
20226
  // If the WebSocket connection is established, and the WebSocket
@@ -20473,6 +20485,14 @@ function requireUndici () {
20473
20485
  const nodeMajor = Number(nodeVersion[0]);
20474
20486
  const nodeMinor = Number(nodeVersion[1]);
20475
20487
 
20488
+ let hasCrypto;
20489
+ try {
20490
+ require('crypto');
20491
+ hasCrypto = true;
20492
+ } catch {
20493
+ hasCrypto = false;
20494
+ }
20495
+
20476
20496
  Object.assign(Dispatcher.prototype, api$1);
20477
20497
 
20478
20498
  undici.Dispatcher = Dispatcher;
@@ -20577,7 +20597,7 @@ function requireUndici () {
20577
20597
  undici.setCookie = setCookie;
20578
20598
  }
20579
20599
 
20580
- if (nodeMajor >= 18) {
20600
+ if (nodeMajor >= 18 && hasCrypto) {
20581
20601
  const { WebSocket } = requireWebsocket();
20582
20602
 
20583
20603
  undici.WebSocket = WebSocket;
package/index.js CHANGED
@@ -263,7 +263,7 @@ function get_publish_directory(netlify_config, builder) {
263
263
  }
264
264
 
265
265
  builder.log.warn(
266
- 'No netlify.toml found. Using default publish directory. Consult https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#configuration for more details '
266
+ 'No netlify.toml found. Using default publish directory. Consult https://kit.svelte.dev/docs/adapter-netlify#usage for more details'
267
267
  );
268
268
  }
269
269
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -38,7 +38,7 @@
38
38
  "rollup": "^3.7.0",
39
39
  "typescript": "^4.9.4",
40
40
  "uvu": "^0.5.6",
41
- "@sveltejs/kit": "^1.1.3"
41
+ "@sveltejs/kit": "^1.2.4"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@sveltejs/kit": "^1.0.0"