Socket
Socket
Sign inDemoInstall

@sveltejs/kit

Package Overview
Dependencies
Maintainers
4
Versions
780
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sveltejs/kit - npm Package Compare versions

Comparing version 2.0.8 to 2.1.0

src/runtime/client/entry.js

2

package.json
{
"name": "@sveltejs/kit",
"version": "2.0.8",
"version": "2.1.0",
"description": "The fastest way to build Svelte apps",

@@ -5,0 +5,0 @@ "repository": {

@@ -119,3 +119,3 @@ import fs from 'node:fs';

client: {
start: `${runtime_base}/client/start.js`,
start: `${runtime_base}/client/entry.js`,
app: `${to_fs(svelte_config.kit.outDir)}/generated/client/app.js`,

@@ -122,0 +122,0 @@ imports: [],

@@ -558,3 +558,3 @@ import fs from 'node:fs';

} else {
input['entry/start'] = `${runtime_directory}/client/start.js`;
input['entry/start'] = `${runtime_directory}/client/entry.js`;
input['entry/app'] = `${kit.outDir}/generated/client-optimized/app.js`;

@@ -623,3 +623,3 @@

// eventhough server otherwise works without it
input: `${runtime_directory}/client/start.js`
input: `${runtime_directory}/client/entry.js`
}

@@ -762,3 +762,3 @@ },

find_deps(client_manifest, posixify(path.relative('.', f)), false);
const start = deps_of(`${runtime_directory}/client/start.js`);
const start = deps_of(`${runtime_directory}/client/entry.js`);
const app = deps_of(`${kit.outDir}/generated/client-optimized/app.js`);

@@ -765,0 +765,0 @@

import * as devalue from 'devalue';
import { BROWSER, DEV } from 'esm-env';
import { client } from '../client/singletons.js';
import { DEV } from 'esm-env';
import { invalidateAll } from './navigation.js';
import { applyAction } from '../client/client.js';
/**
* This action updates the `form` property of the current page with the given data and updates `$page.status`.
* In case of an error, it redirects to the nearest error page.
* @template {Record<string, unknown> | undefined} Success
* @template {Record<string, unknown> | undefined} Failure
* @param {import('@sveltejs/kit').ActionResult<Success, Failure>} result
* @returns {Promise<void>}
*/
export function applyAction(result) {
if (BROWSER) {
return client.apply_action(result);
} else {
throw new Error('Cannot call applyAction(...) on the server');
}
}
export { applyAction };

@@ -22,0 +8,0 @@ /**

@@ -1,142 +0,13 @@

import { client_method } from '../client/singletons.js';
/**
* If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
* This is generally discouraged, since it breaks user expectations.
* @returns {void}
*/
export const disableScrollHandling = /* @__PURE__ */ client_method('disable_scroll_handling');
/**
* Returns a Promise that resolves when SvelteKit navigates (or fails to navigate, in which case the promise rejects) to the specified `url`.
* For external URLs, use `window.location = url` instead of calling `goto(url)`.
*
* @type {(url: string | URL, opts?: { replaceState?: boolean; noScroll?: boolean; keepFocus?: boolean; invalidateAll?: boolean; state?: App.PageState }) => Promise<void>}
* @param {string | URL} url Where to navigate to. Note that if you've set [`config.kit.paths.base`](https://kit.svelte.dev/docs/configuration#paths) and the URL is root-relative, you need to prepend the base path if you want to navigate within the app.
* @param {Object} [opts] Options related to the navigation
* @param {boolean} [opts.replaceState] If `true`, will replace the current `history` entry rather than creating a new one with `pushState`
* @param {boolean} [opts.noScroll] If `true`, the browser will maintain its scroll position rather than scrolling to the top of the page after navigation
* @param {boolean} [opts.keepFocus] If `true`, the currently focused element will retain focus after navigation. Otherwise, focus will be reset to the body
* @param {boolean} [opts.invalidateAll] If `true`, all `load` functions of the page will be rerun. See https://kit.svelte.dev/docs/load#rerunning-load-functions for more info on invalidation.
* @param {App.PageState} [opts.state] An optional object that will be available on the `$page.state` store
* @returns {Promise<void>}
*/
export const goto = /* @__PURE__ */ client_method('goto');
/**
* Causes any `load` functions belonging to the currently active page to re-run if they depend on the `url` in question, via `fetch` or `depends`. Returns a `Promise` that resolves when the page is subsequently updated.
*
* If the argument is given as a `string` or `URL`, it must resolve to the same URL that was passed to `fetch` or `depends` (including query parameters).
* To create a custom identifier, use a string beginning with `[a-z]+:` (e.g. `custom:state`) — this is a valid URL.
*
* The `function` argument can be used define a custom predicate. It receives the full `URL` and causes `load` to rerun if `true` is returned.
* This can be useful if you want to invalidate based on a pattern instead of a exact match.
*
* ```ts
* // Example: Match '/path' regardless of the query parameters
* import { invalidate } from '$app/navigation';
*
* invalidate((url) => url.pathname === '/path');
* ```
* @type {(url: string | URL | ((url: URL) => boolean)) => Promise<void>}
* @param {string | URL | ((url: URL) => boolean)} url The invalidated URL
* @returns {Promise<void>}
*/
export const invalidate = /* @__PURE__ */ client_method('invalidate');
/**
* Causes all `load` functions belonging to the currently active page to re-run. Returns a `Promise` that resolves when the page is subsequently updated.
* @type {() => Promise<void>}
* @returns {Promise<void>}
*/
export const invalidateAll = /* @__PURE__ */ client_method('invalidate_all');
/**
* Programmatically preloads the given page, which means
* 1. ensuring that the code for the page is loaded, and
* 2. calling the page's load function with the appropriate options.
*
* This is the same behaviour that SvelteKit triggers when the user taps or mouses over an `<a>` element with `data-sveltekit-preload-data`.
* If the next navigation is to `href`, the values returned from load will be used, making navigation instantaneous.
* Returns a Promise that resolves with the result of running the new route's `load` functions once the preload is complete.
*
* @type {(href: string) => Promise<Record<string, any>>}
* @param {string} href Page to preload
* @returns {Promise<{ type: 'loaded'; status: number; data: Record<string, any> } | { type: 'redirect'; location: string }>}
*/
export const preloadData = /* @__PURE__ */ client_method('preload_data');
/**
* Programmatically imports the code for routes that haven't yet been fetched.
* Typically, you might call this to speed up subsequent navigation.
*
* You can specify routes by any matching pathname such as `/about` (to match `src/routes/about/+page.svelte`) or `/blog/*` (to match `src/routes/blog/[slug]/+page.svelte`).
*
* Unlike `preloadData`, this won't call `load` functions.
* Returns a Promise that resolves when the modules have been imported.
*
* @type {(url: string) => Promise<void>}
* @param {string} url
* @returns {Promise<void>}
*/
export const preloadCode = /* @__PURE__ */ client_method('preload_code');
/**
* A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls.
*
* Calling `cancel()` will prevent the navigation from completing. If `navigation.type === 'leave'` — meaning the user is navigating away from the app (or closing the tab) — calling `cancel` will trigger the native browser unload confirmation dialog. In this case, the navigation may or may not be cancelled depending on the user's response.
*
* When a navigation isn't to a SvelteKit-owned route (and therefore controlled by SvelteKit's client-side router), `navigation.to.route.id` will be `null`.
*
* If the navigation will (if not cancelled) cause the document to unload — in other words `'leave'` navigations and `'link'` navigations where `navigation.to.route === null` — `navigation.willUnload` is `true`.
*
* `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
* @type {(callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void) => void}
* @param {(navigation: import('@sveltejs/kit').BeforeNavigate) => void} callback
* @returns {void}
*/
export const beforeNavigate = /* @__PURE__ */ client_method('before_navigate');
/**
* A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations.
*
* If you return a `Promise`, SvelteKit will wait for it to resolve before completing the navigation. This allows you to — for example — use `document.startViewTransition`. Avoid promises that are slow to resolve, since navigation will appear stalled to the user.
*
* If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated.
*
* `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
* @type {(callback: (navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>) => void}
* @param {(navigation: import('@sveltejs/kit').OnNavigate) => void} callback
* @returns {void}
*/
export const onNavigate = /* @__PURE__ */ client_method('on_navigate');
/**
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
*
* `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
* @type {(callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void) => void}
* @param {(navigation: import('@sveltejs/kit').AfterNavigate) => void} callback
* @returns {void}
*/
export const afterNavigate = /* @__PURE__ */ client_method('after_navigate');
/**
* Programmatically create a new history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing).
*
* @type {(url: string | URL, state: App.PageState) => void}
* @param {string | URL} url
* @param {App.PageState} state
* @returns {void}
*/
export const pushState = /* @__PURE__ */ client_method('push_state');
/**
* Programmatically replace the current history entry with the given `$page.state`. To use the current URL, you can pass `''` as the first argument. Used for [shallow routing](https://kit.svelte.dev/docs/shallow-routing).
*
* @type {(url: string | URL, state: App.PageState) => void}
* @param {string | URL} url
* @param {App.PageState} state
* @returns {void}
*/
export const replaceState = /* @__PURE__ */ client_method('replace_state');
export {
afterNavigate,
beforeNavigate,
disableScrollHandling,
goto,
invalidate,
invalidateAll,
onNavigate,
preloadCode,
preloadData,
pushState,
replaceState
} from '../client/client.js';
import { getContext } from 'svelte';
import { browser } from './environment.js';
import { stores as browser_stores } from '../client/singletons.js';
import { BROWSER } from 'esm-env';
import { stores as browser_stores } from '../client/client.js';

@@ -10,3 +10,3 @@ /**

export const getStores = () => {
const stores = browser ? browser_stores : getContext('__svelte__');
const stores = BROWSER ? browser_stores : getContext('__svelte__');

@@ -66,3 +66,3 @@ return {

if (browser) {
if (BROWSER) {
updated.check = store.check;

@@ -75,3 +75,3 @@ }

throw new Error(
browser
BROWSER
? 'Cannot check updated store before subscribing'

@@ -78,0 +78,0 @@ : 'Can only check updated store in browser'

@@ -1,2 +0,2 @@

import { DEV } from 'esm-env';
import { BROWSER, DEV } from 'esm-env';
import { hash } from '../hash.js';

@@ -6,3 +6,4 @@

export const native_fetch = window.fetch;
/** @type {typeof fetch} */
export const native_fetch = BROWSER ? window.fetch : /** @type {any} */ (() => {});

@@ -17,3 +18,3 @@ export function lock_fetch() {

if (DEV) {
if (DEV && BROWSER) {
let can_inspect_stack_trace = false;

@@ -66,3 +67,3 @@

};
} else {
} else if (BROWSER) {
window.fetch = (input, init) => {

@@ -69,0 +70,0 @@ const method = input instanceof Request ? input.method : init?.method || 'GET';

@@ -1,14 +0,1 @@

import { applyAction } from '../app/forms.js';
import {
afterNavigate,
beforeNavigate,
onNavigate,
goto,
invalidate,
invalidateAll,
preloadCode,
preloadData,
pushState,
replaceState
} from '../app/navigation.js';
import { SvelteComponent } from 'svelte';

@@ -45,30 +32,2 @@ import { ClientHooks, CSRPageNode, CSRPageNodeLoader, CSRRoute, TrailingSlash, Uses } from 'types';

export interface Client {
// public API, exposed via $app/navigation
after_navigate: typeof afterNavigate;
before_navigate: typeof beforeNavigate;
on_navigate: typeof onNavigate;
disable_scroll_handling(): void;
goto: typeof goto;
invalidate: typeof invalidate;
invalidate_all: typeof invalidateAll;
preload_code: typeof preloadCode;
preload_data: typeof preloadData;
push_state: typeof pushState;
replace_state: typeof replaceState;
apply_action: typeof applyAction;
// private API
_hydrate(opts: {
status: number;
error: App.Error | null;
node_ids: number[];
params: Record<string, string>;
route: { id: string | null };
data: Array<import('types').ServerDataNode | null>;
form: Record<string, any> | null;
}): Promise<void>;
_start_router(): void;
}
export type NavigationIntent = {

@@ -75,0 +34,0 @@ /** `url.pathname + url.search` */

// generated during release, do not modify
/** @type {string} */
export const VERSION = '2.0.8';
export const VERSION = '2.1.0';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc