@sveltejs/kit 1.0.0-next.377 → 1.0.0-next.378

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 CHANGED
@@ -5,7 +5,7 @@ This is the [SvelteKit](https://kit.svelte.dev) framework and CLI.
5
5
  The quickest way to get started is via the [create-svelte](https://github.com/sveltejs/kit/tree/master/packages/create-svelte) package:
6
6
 
7
7
  ```bash
8
- npm init svelte my-app
8
+ npm create svelte@latest my-app
9
9
  cd my-app
10
10
  npm install
11
11
  npm run dev
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ function handle_error(e) {
18
18
  process.exit(1);
19
19
  }
20
20
 
21
- const prog = sade('svelte-kit').version('1.0.0-next.377');
21
+ const prog = sade('svelte-kit').version('1.0.0-next.378');
22
22
 
23
23
  prog
24
24
  .command('package')
package/dist/node.js CHANGED
@@ -2,7 +2,7 @@ import http from 'node:http';
2
2
  import 'node:https';
3
3
  import 'node:zlib';
4
4
  import Stream, { PassThrough } from 'node:stream';
5
- import { Buffer as Buffer$1 } from 'node:buffer';
5
+ import { Buffer } from 'node:buffer';
6
6
  import { promisify, deprecate, types } from 'node:util';
7
7
  import { c as commonjsGlobal } from './chunks/_commonjsHelpers.js';
8
8
  import { format } from 'node:url';
@@ -4945,13 +4945,13 @@ class Body {
4945
4945
  body = null;
4946
4946
  } else if (isURLSearchParameters(body)) {
4947
4947
  // Body is a URLSearchParams
4948
- body = Buffer$1.from(body.toString());
4949
- } else if (isBlob(body)) ; else if (Buffer$1.isBuffer(body)) ; else if (types.isAnyArrayBuffer(body)) {
4948
+ body = Buffer.from(body.toString());
4949
+ } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (types.isAnyArrayBuffer(body)) {
4950
4950
  // Body is ArrayBuffer
4951
- body = Buffer$1.from(body);
4951
+ body = Buffer.from(body);
4952
4952
  } else if (ArrayBuffer.isView(body)) {
4953
4953
  // Body is ArrayBufferView
4954
- body = Buffer$1.from(body.buffer, body.byteOffset, body.byteLength);
4954
+ body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
4955
4955
  } else if (body instanceof Stream) ; else if (body instanceof FormData) {
4956
4956
  // Body is FormData
4957
4957
  body = formDataToBlob(body);
@@ -4959,12 +4959,12 @@ class Body {
4959
4959
  } else {
4960
4960
  // None of the above
4961
4961
  // coerce to string then buffer
4962
- body = Buffer$1.from(String(body));
4962
+ body = Buffer.from(String(body));
4963
4963
  }
4964
4964
 
4965
4965
  let stream = body;
4966
4966
 
4967
- if (Buffer$1.isBuffer(body)) {
4967
+ if (Buffer.isBuffer(body)) {
4968
4968
  stream = Stream.Readable.from(body);
4969
4969
  } else if (isBlob(body)) {
4970
4970
  stream = Stream.Readable.from(body.stream());
@@ -5106,12 +5106,12 @@ async function consumeBody(data) {
5106
5106
 
5107
5107
  // Body is null
5108
5108
  if (body === null) {
5109
- return Buffer$1.alloc(0);
5109
+ return Buffer.alloc(0);
5110
5110
  }
5111
5111
 
5112
5112
  /* c8 ignore next 3 */
5113
5113
  if (!(body instanceof Stream)) {
5114
- return Buffer$1.alloc(0);
5114
+ return Buffer.alloc(0);
5115
5115
  }
5116
5116
 
5117
5117
  // Body is stream
@@ -5138,10 +5138,10 @@ async function consumeBody(data) {
5138
5138
  if (body.readableEnded === true || body._readableState.ended === true) {
5139
5139
  try {
5140
5140
  if (accum.every(c => typeof c === 'string')) {
5141
- return Buffer$1.from(accum.join(''));
5141
+ return Buffer.from(accum.join(''));
5142
5142
  }
5143
5143
 
5144
- return Buffer$1.concat(accum, accumBytes);
5144
+ return Buffer.concat(accum, accumBytes);
5145
5145
  } catch (error) {
5146
5146
  throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${error.message}`, 'system', error);
5147
5147
  }
@@ -5221,7 +5221,7 @@ const extractContentType = (body, request) => {
5221
5221
  }
5222
5222
 
5223
5223
  // Body is a Buffer (Buffer, ArrayBuffer or ArrayBufferView)
5224
- if (Buffer$1.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
5224
+ if (Buffer.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
5225
5225
  return null;
5226
5226
  }
5227
5227
 
@@ -5745,6 +5745,12 @@ function get_raw_body(req) {
5745
5745
  return null;
5746
5746
  }
5747
5747
 
5748
+ if (req.destroyed) {
5749
+ const readable = new ReadableStream();
5750
+ readable.cancel();
5751
+ return readable;
5752
+ }
5753
+
5748
5754
  let size = 0;
5749
5755
  let cancelled = false;
5750
5756
 
@@ -5755,31 +5761,34 @@ function get_raw_body(req) {
5755
5761
  });
5756
5762
 
5757
5763
  req.on('end', () => {
5758
- if (!cancelled) {
5759
- controller.close();
5760
- }
5764
+ if (cancelled) return;
5765
+ controller.close();
5761
5766
  });
5762
- },
5763
5767
 
5764
- pull(controller) {
5765
- return new Promise((fulfil) => {
5766
- req.once('data', (chunk) => {
5767
- if (!cancelled) {
5768
- size += chunk.length;
5769
- if (size > length) {
5770
- controller.error(new Error('content-length exceeded'));
5771
- }
5768
+ req.on('data', (chunk) => {
5769
+ if (cancelled) return;
5770
+
5771
+ size += chunk.length;
5772
+ if (size > length) {
5773
+ controller.error(new Error('content-length exceeded'));
5774
+ return;
5775
+ }
5772
5776
 
5773
- controller.enqueue(chunk);
5774
- }
5777
+ controller.enqueue(chunk);
5775
5778
 
5776
- fulfil();
5777
- });
5779
+ if (controller.desiredSize === null || controller.desiredSize <= 0) {
5780
+ req.pause();
5781
+ }
5778
5782
  });
5779
5783
  },
5780
5784
 
5781
- cancel() {
5785
+ pull() {
5786
+ req.resume();
5787
+ },
5788
+
5789
+ cancel(reason) {
5782
5790
  cancelled = true;
5791
+ req.destroy(reason);
5783
5792
  }
5784
5793
  });
5785
5794
  }
@@ -5831,16 +5840,26 @@ async function setResponse(res, response) {
5831
5840
  res.writeHead(response.status, headers);
5832
5841
 
5833
5842
  if (response.body) {
5834
- let cancelled = false;
5835
-
5836
5843
  const reader = response.body.getReader();
5837
5844
 
5845
+ if (res.destroyed) {
5846
+ reader.cancel();
5847
+ return;
5848
+ }
5849
+
5850
+ let cancelled = false;
5851
+
5838
5852
  res.on('close', () => {
5839
5853
  reader.cancel();
5840
5854
  cancelled = true;
5841
5855
  });
5842
5856
 
5843
- const next = async () => {
5857
+ res.on('error', (error) => {
5858
+ reader.cancel(error);
5859
+ cancelled = true;
5860
+ });
5861
+
5862
+ for (;;) {
5844
5863
  const { done, value } = await reader.read();
5845
5864
 
5846
5865
  if (cancelled) return;
@@ -5850,17 +5869,12 @@ async function setResponse(res, response) {
5850
5869
  return;
5851
5870
  }
5852
5871
 
5853
- res.write(Buffer.from(value), (error) => {
5854
- if (error) {
5855
- console.error('Error writing stream', error);
5856
- res.end();
5857
- } else {
5858
- next();
5859
- }
5860
- });
5861
- };
5872
+ const ok = res.write(value);
5862
5873
 
5863
- next();
5874
+ if (!ok) {
5875
+ await new Promise((fulfil) => res.once('drain', fulfil));
5876
+ }
5877
+ }
5864
5878
  } else {
5865
5879
  res.end();
5866
5880
  }
package/dist/vite.js CHANGED
@@ -4,7 +4,7 @@ import path__default, { join, dirname, resolve as resolve$1, normalize } from 'p
4
4
  import { a as load_template, $, c as coalesce_to_error, l as load_config } from './chunks/error.js';
5
5
  import { svelte } from '@sveltejs/vite-plugin-svelte';
6
6
  import * as vite from 'vite';
7
- import { loadConfigFromFile, searchForWorkspaceRoot } from 'vite';
7
+ import { loadConfigFromFile } from 'vite';
8
8
  import { p as posixify, m as mkdirp, r as rimraf } from './chunks/write_tsconfig.js';
9
9
  import { g as get_runtime_directory, s, i as init, a as get_runtime_prefix, u as update, b as get_mime_lookup, p as parse_route_id, c as all, l as logger } from './chunks/sync.js';
10
10
  import { pathToFileURL, URL as URL$1 } from 'url';
@@ -2986,7 +2986,7 @@ function kit() {
2986
2986
  svelte_config.kit.outDir,
2987
2987
  path__default.resolve(cwd, 'src'),
2988
2988
  path__default.resolve(cwd, 'node_modules'),
2989
- path__default.resolve(searchForWorkspaceRoot(cwd), 'node_modules')
2989
+ path__default.resolve(vite.searchForWorkspaceRoot(cwd), 'node_modules')
2990
2990
  ])
2991
2991
  ]
2992
2992
  },
@@ -3166,18 +3166,14 @@ function kit() {
3166
3166
  }
3167
3167
 
3168
3168
  function check_vite_version() {
3169
- let vite_major = 3;
3169
+ // TODO parse from kit peer deps and maybe do a full semver compare if we ever require feature releases a min
3170
+ const min_required_vite_major = 3;
3171
+ const vite_version = vite.version ?? '2.x'; // vite started exporting it's version in 3.0
3172
+ const current_vite_major = parseInt(vite_version.split('.')[0], 10);
3170
3173
 
3171
- try {
3172
- const pkg = JSON.parse(fs__default.readFileSync('package.json', 'utf-8'));
3173
- vite_major = +pkg.devDependencies['vite'].replace(/^[~^]/, '')[0];
3174
- } catch {
3175
- // do nothing
3176
- }
3177
-
3178
- if (vite_major < 3) {
3174
+ if (current_vite_major < min_required_vite_major) {
3179
3175
  throw new Error(
3180
- `Vite version ${vite_major} is no longer supported. Please upgrade to version 3`
3176
+ `Vite version ${current_vite_major} is no longer supported. Please upgrade to version ${min_required_vite_major}`
3181
3177
  );
3182
3178
  }
3183
3179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.377",
3
+ "version": "1.0.0-next.378",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -15,7 +15,7 @@
15
15
  "sade": "^1.8.1"
16
16
  },
17
17
  "devDependencies": {
18
- "@playwright/test": "^1.23.3",
18
+ "@playwright/test": "^1.23.4",
19
19
  "@rollup/plugin-replace": "^4.0.0",
20
20
  "@types/connect": "^3.4.35",
21
21
  "@types/cookie": "^0.5.1",