@sveltejs/kit 1.0.3 → 1.0.6

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.3",
3
+ "version": "1.0.6",
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;
@@ -286,7 +286,7 @@ export function create_client({ target, base }) {
286
286
  );
287
287
  return false;
288
288
  }
289
- } else if (navigation_result.props?.page?.status >= 400) {
289
+ } else if (/** @type {number} */ (navigation_result.props?.page?.status) >= 400) {
290
290
  const updated = await stores.updated.check();
291
291
  if (updated) {
292
292
  await native_navigation(url);
@@ -369,7 +369,7 @@ export function create_client({ target, base }) {
369
369
  const style = document.querySelector('style[data-sveltekit]');
370
370
  if (style) style.remove();
371
371
 
372
- page = result.props.page;
372
+ page = /** @type {import('types').Page} */ (result.props.page);
373
373
 
374
374
  root = new Root({
375
375
  target,
@@ -435,6 +435,7 @@ export function create_client({ target, base }) {
435
435
  route
436
436
  },
437
437
  props: {
438
+ // @ts-ignore Somehow it's getting SvelteComponent and SvelteComponentDev mixed up
438
439
  components: filtered.map((branch_node) => branch_node.node.component)
439
440
  }
440
441
  };
@@ -473,7 +474,9 @@ export function create_client({ target, base }) {
473
474
  result.props.page = {
474
475
  error,
475
476
  params,
476
- route,
477
+ route: {
478
+ id: route?.id ?? null
479
+ },
477
480
  status,
478
481
  url: new URL(url),
479
482
  form: form ?? null,
@@ -8,7 +8,8 @@ import {
8
8
  preloadCode,
9
9
  preloadData
10
10
  } from '$app/navigation';
11
- import { CSRPageNode, CSRPageNodeLoader, CSRRoute, TrailingSlash, Uses } from 'types';
11
+ import { SvelteComponent } from 'svelte';
12
+ import { CSRPageNode, CSRPageNodeLoader, CSRRoute, Page, TrailingSlash, Uses } from 'types';
12
13
 
13
14
  export interface Client {
14
15
  // public API, exposed via $app/navigation
@@ -58,7 +59,12 @@ export type NavigationRedirect = {
58
59
  export type NavigationFinished = {
59
60
  type: 'loaded';
60
61
  state: NavigationState;
61
- props: Record<string, any>;
62
+ props: {
63
+ components: Array<typeof SvelteComponent>;
64
+ page?: Page;
65
+ form?: Record<string, any> | null;
66
+ [key: `data_${number}`]: Record<string, any>;
67
+ };
62
68
  };
63
69
 
64
70
  export type BranchNode = {
@@ -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
  }