Home / File/ public.d.ts — svelte Source File

public.d.ts — svelte Source File

Architecture documentation for public.d.ts, a typescript file in the svelte codebase. 2 imports, 0 dependents.

File typescript SharedInternal DOMUtils 2 imports 1 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  9a4c629d_1cfd_8602_0675_d0dd3a38ce22["public.d.ts"]
  c9f47bf7_98ce_9478_f813_adff17e72bf4["./public.js"]
  9a4c629d_1cfd_8602_0675_d0dd3a38ce22 --> c9f47bf7_98ce_9478_f813_adff17e72bf4
  a3606df5_f49b_e9dc_3e08_62e97fe13aa4["./private.js"]
  9a4c629d_1cfd_8602_0675_d0dd3a38ce22 --> a3606df5_f49b_e9dc_3e08_62e97fe13aa4
  style 9a4c629d_1cfd_8602_0675_d0dd3a38ce22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { Readable, type Unsubscriber } from '../store/public.js';
import { SpringUpdateOpts, TweenedOptions, Updater, SpringOpts } from './private.js';

// TODO we do declaration merging here in order to not have a breaking change (renaming the Spring interface)
// this means both the Spring class and the Spring interface are merged into one with some things only
// existing on one side. In Svelte 6, remove the type definition and move the jsdoc onto the class in spring.js

export interface Spring<T> extends Readable<T> {
	set(new_value: T, opts?: SpringUpdateOpts): Promise<void>;
	/**
	 * @deprecated Only exists on the legacy `spring` store, not the `Spring` class
	 */
	update: (fn: Updater<T>, opts?: SpringUpdateOpts) => Promise<void>;
	/**
	 * @deprecated Only exists on the legacy `spring` store, not the `Spring` class
	 */
	subscribe(fn: (value: T) => void): Unsubscriber;
	precision: number;
	damping: number;
	stiffness: number;
}

/**
 * A wrapper for a value that behaves in a spring-like fashion. Changes to `spring.target` will cause `spring.current` to
 * move towards it over time, taking account of the `spring.stiffness` and `spring.damping` parameters.
 *
 * ```svelte
 * <script>
 * 	import { Spring } from 'svelte/motion';
 *
 * 	const spring = new Spring(0);
 * </script>
 *
 * <input type="range" bind:value={spring.target} />
 * <input type="range" bind:value={spring.current} disabled />
 * ```
 * @since 5.8.0
 */
export class Spring<T> {
	constructor(value: T, options?: SpringOpts);

	/**
	 * Create a spring whose value is bound to the return value of `fn`. This must be called
	 * inside an effect root (for example, during component initialisation).
	 *
	 * ```svelte
	 * <script>
	 * 	import { Spring } from 'svelte/motion';
	 *
	 * 	let { number } = $props();
	 *
	 * 	const spring = Spring.of(() => number);
	 * </script>
	 * ```
	 */
	static of<U>(fn: () => U, options?: SpringOpts): Spring<U>;

	/**
	 * Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it.
	 *
	 * If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
	 *
	 * If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
	 * the specified number of milliseconds. This is useful for things like 'fling' gestures.
	 */
	set(value: T, options?: SpringUpdateOpts): Promise<void>;

	damping: number;
	precision: number;
	stiffness: number;
	/**
	 * The end value of the spring.
	 * This property only exists on the `Spring` class, not the legacy `spring` store.
	 */
	target: T;
	/**
	 * The current value of the spring.
	 * This property only exists on the `Spring` class, not the legacy `spring` store.
	 */
	get current(): T;
}

export interface Tweened<T> extends Readable<T> {
	set(value: T, opts?: TweenedOptions<T>): Promise<void>;
	update(updater: Updater<T>, opts?: TweenedOptions<T>): Promise<void>;
}

export { prefersReducedMotion, spring, tweened, Tween } from './index.js';

Subdomains

Functions

Classes

Dependencies

  • ./private.js
  • ./public.js

Frequently Asked Questions

What does public.d.ts do?
public.d.ts is a source file in the svelte codebase, written in typescript. It belongs to the SharedInternal domain, DOMUtils subdomain.
What functions are defined in public.d.ts?
public.d.ts defines 1 function(s): fn.
What does public.d.ts depend on?
public.d.ts imports 2 module(s): ./private.js, ./public.js.
Where is public.d.ts in the architecture?
public.d.ts is located at packages/svelte/src/motion/public.d.ts (domain: SharedInternal, subdomain: DOMUtils, directory: packages/svelte/src/motion).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free