@sveltejs/kit 1.0.2 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -1,8 +1,9 @@
1
1
  import { readFileSync, writeFileSync } from 'fs';
2
2
  import { dirname, join } from 'path';
3
3
  import { pathToFileURL, URL } from 'url';
4
- import { mkdirp, posixify, walk } from '../../utils/filesystem.js';
5
4
  import { installPolyfills } from '../../exports/node/polyfills.js';
5
+ import { mkdirp, posixify, walk } from '../../utils/filesystem.js';
6
+ import { should_polyfill } from '../../utils/platform.js';
6
7
  import { is_root_relative, resolve } from '../../utils/url.js';
7
8
  import { queue } from './queue.js';
8
9
  import { crawl } from './crawl.js';
@@ -89,7 +90,9 @@ export async function prerender() {
89
90
  verbose: verbose === 'true'
90
91
  });
91
92
 
92
- installPolyfills();
93
+ if (should_polyfill) {
94
+ installPolyfills();
95
+ }
93
96
 
94
97
  const server_root = join(config.outDir, 'output');
95
98
 
@@ -16,6 +16,7 @@ const globals = {
16
16
  };
17
17
 
18
18
  // exported for dev/preview and node environments
19
+ // TODO: remove this once we only support Node 18.11+ (the version multipart/form-data was added)
19
20
  export function installPolyfills() {
20
21
  for (const name in globals) {
21
22
  Object.defineProperty(globalThis, name, {
@@ -8,6 +8,7 @@ import { getRequest, setResponse } from '../../../exports/node/index.js';
8
8
  import { installPolyfills } from '../../../exports/node/polyfills.js';
9
9
  import { coalesce_to_error } from '../../../utils/error.js';
10
10
  import { posixify, resolve_entry, to_fs } from '../../../utils/filesystem.js';
11
+ import { should_polyfill } from '../../../utils/platform.js';
11
12
  import { load_error_page, load_template } from '../../../core/config/index.js';
12
13
  import { SVELTE_KIT_ASSETS } from '../../../constants.js';
13
14
  import * as sync from '../../../core/sync/sync.js';
@@ -24,7 +25,9 @@ const cwd = process.cwd();
24
25
  * @return {Promise<Promise<() => void>>}
25
26
  */
26
27
  export async function dev(vite, vite_config, svelte_config) {
27
- installPolyfills();
28
+ if (should_polyfill) {
29
+ installPolyfills();
30
+ }
28
31
 
29
32
  sync.init(svelte_config, vite_config.mode);
30
33
 
@@ -2,10 +2,11 @@ import fs from 'fs';
2
2
  import { join } from 'path';
3
3
  import sirv from 'sirv';
4
4
  import { pathToFileURL } from 'url';
5
+ import { loadEnv, normalizePath } from 'vite';
5
6
  import { getRequest, setResponse } from '../../../exports/node/index.js';
6
7
  import { installPolyfills } from '../../../exports/node/polyfills.js';
7
8
  import { SVELTE_KIT_ASSETS } from '../../../constants.js';
8
- import { loadEnv, normalizePath } from 'vite';
9
+ import { should_polyfill } from '../../../utils/platform.js';
9
10
  import { not_found } from '../utils.js';
10
11
 
11
12
  /** @typedef {import('http').IncomingMessage} Req */
@@ -21,7 +22,9 @@ import { not_found } from '../utils.js';
21
22
  * @param {import('types').ValidatedConfig} svelte_config
22
23
  */
23
24
  export async function preview(vite, vite_config, svelte_config) {
24
- installPolyfills();
25
+ if (should_polyfill) {
26
+ installPolyfills();
27
+ }
25
28
 
26
29
  const { paths } = svelte_config.kit;
27
30
  const base = paths.base;
@@ -1461,21 +1461,28 @@ export function create_client({ target, base }) {
1461
1461
  if (method !== 'get') return;
1462
1462
 
1463
1463
  const url = new URL(
1464
- (event.submitter?.hasAttribute('formaction') && submitter?.formAction) || form.action
1464
+ (submitter?.hasAttribute('formaction') && submitter?.formAction) || form.action
1465
1465
  );
1466
1466
 
1467
1467
  if (is_external_url(url, base)) return;
1468
1468
 
1469
- const { noscroll, reload } = get_router_options(
1470
- /** @type {HTMLFormElement} */ (event.target)
1471
- );
1469
+ const event_form = /** @type {HTMLFormElement} */ (event.target);
1470
+
1471
+ const { noscroll, reload } = get_router_options(event_form);
1472
1472
  if (reload) return;
1473
1473
 
1474
1474
  event.preventDefault();
1475
1475
  event.stopPropagation();
1476
1476
 
1477
+ const data = new FormData(event_form);
1478
+
1479
+ const submitter_name = submitter?.getAttribute('name');
1480
+ if (submitter_name) {
1481
+ data.append(submitter_name, submitter?.getAttribute('value') ?? '');
1482
+ }
1483
+
1477
1484
  // @ts-expect-error `URLSearchParams(fd)` is kosher, but typescript doesn't know that
1478
- url.search = new URLSearchParams(new FormData(event.target)).toString();
1485
+ url.search = new URLSearchParams(data).toString();
1479
1486
 
1480
1487
  navigate({
1481
1488
  url,
@@ -0,0 +1 @@
1
+ export const should_polyfill = typeof Deno === 'undefined' && typeof Bun === 'undefined';
package/types/index.d.ts CHANGED
@@ -865,7 +865,7 @@ export interface RequestEvent<
865
865
  /**
866
866
  * Additional data made available through the adapter.
867
867
  */
868
- platform: Readonly<App.Platform>;
868
+ platform: Readonly<App.Platform> | undefined;
869
869
  /**
870
870
  * The original request object
871
871
  */
@@ -389,4 +389,6 @@ declare global {
389
389
  const __SVELTEKIT_BROWSER__: boolean;
390
390
  const __SVELTEKIT_DEV__: boolean;
391
391
  const __SVELTEKIT_EMBEDDED__: boolean;
392
+ var Bun: object;
393
+ var Deno: object;
392
394
  }