@sveltejs/kit 1.0.0-next.286 → 1.0.0-next.287

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.
@@ -6,7 +6,7 @@ import { r as runtime, S as SVELTE_KIT_ASSETS, a as resolve_entry, $, b as SVELT
6
6
  import fs__default from 'fs';
7
7
  import { URL } from 'url';
8
8
  import { s as sirv } from './build.js';
9
- import { __fetch_polyfill } from '../install-fetch.js';
9
+ import { installFetch } from '../install-fetch.js';
10
10
  import { getRequest, setResponse } from '../node.js';
11
11
  import { sequence } from '../hooks.js';
12
12
  import './misc.js';
@@ -46,7 +46,7 @@ async function create_plugin(config, cwd) {
46
46
  name: 'vite-plugin-svelte-kit',
47
47
 
48
48
  configureServer(vite) {
49
- __fetch_polyfill();
49
+ installFetch();
50
50
 
51
51
  /** @type {import('types').SSRManifest} */
52
52
  let manifest;
@@ -2,7 +2,7 @@ import { b as SVELTE_KIT, m as mkdirp, h as rimraf, i as copy, $, j as logger }
2
2
  import { readFileSync, writeFileSync } from 'fs';
3
3
  import { resolve as resolve$1, join, dirname } from 'path';
4
4
  import { pathToFileURL, URL } from 'url';
5
- import { __fetch_polyfill } from '../install-fetch.js';
5
+ import { installFetch } from '../install-fetch.js';
6
6
  import { g as generate_manifest } from './index4.js';
7
7
  import 'sade';
8
8
  import 'child_process';
@@ -458,7 +458,7 @@ async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
458
458
  return prerendered;
459
459
  }
460
460
 
461
- __fetch_polyfill();
461
+ installFetch();
462
462
 
463
463
  const server_root = resolve$1(cwd, `${SVELTE_KIT}/output`);
464
464
 
@@ -5,7 +5,7 @@ import { resolve, join } from 'path';
5
5
  import { s as sirv } from './build.js';
6
6
  import { pathToFileURL } from 'url';
7
7
  import { getRequest, setResponse } from '../node.js';
8
- import { __fetch_polyfill } from '../install-fetch.js';
8
+ import { installFetch } from '../install-fetch.js';
9
9
  import { b as SVELTE_KIT, S as SVELTE_KIT_ASSETS } from '../cli.js';
10
10
  import 'querystring';
11
11
  import 'stream';
@@ -43,7 +43,7 @@ async function preview({
43
43
  https: use_https = false,
44
44
  cwd = process.cwd()
45
45
  }) {
46
- __fetch_polyfill();
46
+ installFetch();
47
47
 
48
48
  const index_file = resolve(cwd, `${SVELTE_KIT}/output/server/index.js`);
49
49
  const manifest_file = resolve(cwd, `${SVELTE_KIT}/output/server/manifest.js`);
package/dist/cli.js CHANGED
@@ -998,7 +998,7 @@ async function launch(port, https) {
998
998
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
999
999
  }
1000
1000
 
1001
- const prog = sade('svelte-kit').version('1.0.0-next.286');
1001
+ const prog = sade('svelte-kit').version('1.0.0-next.287');
1002
1002
 
1003
1003
  prog
1004
1004
  .command('dev')
@@ -1156,7 +1156,7 @@ async function check_port(port) {
1156
1156
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1157
1157
  if (open) launch(port, https);
1158
1158
 
1159
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.286'}\n`));
1159
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.287'}\n`));
1160
1160
 
1161
1161
  const protocol = https ? 'https:' : 'http:';
1162
1162
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -6490,7 +6490,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6490
6490
  }
6491
6491
 
6492
6492
  // exported for dev/preview and node environments
6493
- function __fetch_polyfill() {
6493
+ function installFetch() {
6494
6494
  Object.defineProperties(globalThis, {
6495
6495
  fetch: {
6496
6496
  enumerable: true,
@@ -6515,4 +6515,4 @@ function __fetch_polyfill() {
6515
6515
  });
6516
6516
  }
6517
6517
 
6518
- export { FormData as F, Headers, Request, Response, __fetch_polyfill, File as a, commonjsGlobal as c, fetch };
6518
+ export { FormData as F, File as a, commonjsGlobal as c, installFetch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.286",
3
+ "version": "1.0.0-next.287",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -15,7 +15,7 @@
15
15
  "vite": "^2.8.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@playwright/test": "^1.17.1",
18
+ "@playwright/test": "^1.19.1",
19
19
  "@rollup/plugin-replace": "^4.0.0",
20
20
  "@types/amphtml-validator": "^1.0.1",
21
21
  "@types/cookie": "^0.4.1",
@@ -82,8 +82,9 @@
82
82
  "check": "tsc && svelte-check --ignore test/prerendering,src/packaging/test",
83
83
  "format": "npm run check-format -- --write",
84
84
  "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
85
- "test": "npm run test:unit && npm run test:packaging && npm run test:prerendering && npm run test:integration",
85
+ "test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:prerendering && npm run test:integration",
86
86
  "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
87
+ "test:typings": "tsc --project test/typings",
87
88
  "test:prerendering": "pnpm test:prerendering:basics && pnpm test:prerendering:options",
88
89
  "test:prerendering:basics": "cd test/prerendering/basics && pnpm test",
89
90
  "test:prerendering:options": "cd test/prerendering/options && pnpm test",
@@ -281,11 +281,10 @@ declare module '@sveltejs/kit/hooks' {
281
281
  * A polyfill for `fetch` and its related interfaces, used by adapters for environments that don't provide a native implementation.
282
282
  */
283
283
  declare module '@sveltejs/kit/install-fetch' {
284
- import fetch, { Headers, Request, Response } from 'node-fetch';
285
-
286
- export function __fetch_polyfill(): void;
287
-
288
- export { fetch, Headers, Request, Response };
284
+ /**
285
+ * Make `fetch`, `Headers`, `Request` and `Response` available as globals, via `node-fetch`
286
+ */
287
+ export function installFetch(): void;
289
288
  }
290
289
 
291
290
  /**
package/types/index.d.ts CHANGED
@@ -9,7 +9,6 @@ import {
9
9
  Builder,
10
10
  CspDirectives,
11
11
  Either,
12
- EndpointOutput,
13
12
  ErrorLoadInput,
14
13
  Fallthrough,
15
14
  LoadInput,
@@ -18,6 +17,7 @@ import {
18
17
  PrerenderOnErrorValue,
19
18
  RequestEvent,
20
19
  ResolveOptions,
20
+ ResponseHeaders,
21
21
  TrailingSlash
22
22
  } from './private';
23
23
 
@@ -134,7 +134,16 @@ export interface Navigation {
134
134
  * JavaScript, delete handles are called `del` instead.
135
135
  */
136
136
  export interface RequestHandler<Params = Record<string, string>, Output extends Body = Body> {
137
- (event: RequestEvent<Params>): MaybePromise<
138
- Either<Output extends Response ? Response : EndpointOutput<Output>, Fallthrough>
139
- >;
137
+ (event: RequestEvent<Params>): RequestHandlerOutput<Output>;
140
138
  }
139
+
140
+ export type RequestHandlerOutput<Output extends Body = Body> = MaybePromise<
141
+ Either<
142
+ {
143
+ status?: number;
144
+ headers?: Headers | Partial<ResponseHeaders>;
145
+ body?: Output;
146
+ },
147
+ Fallthrough
148
+ >
149
+ >;
@@ -195,12 +195,6 @@ export type CspDirectives = {
195
195
 
196
196
  export type Either<T, U> = Only<T, U> | Only<U, T>;
197
197
 
198
- export interface EndpointOutput<Output extends Body = Body> {
199
- status?: number;
200
- headers?: Headers | Partial<ResponseHeaders>;
201
- body?: Output;
202
- }
203
-
204
198
  export interface ErrorLoadInput<Params = Record<string, string>> extends LoadInput<Params> {
205
199
  status?: number;
206
200
  error?: Error;