svelte
- Version 4.2.15
- Published
- 2.63 MB
- 14 dependencies
- MIT license
Install
npm i svelte
yarn add svelte
pnpm add svelte
Overview
Cybernetically enhanced web apps
Index
Namespaces
svelte/easing
- backIn()
- backInOut()
- backOut()
- bounceIn()
- bounceInOut()
- bounceOut()
- circIn()
- circInOut()
- circOut()
- cubicIn()
- cubicInOut()
- cubicOut()
- elasticIn()
- elasticInOut()
- elasticOut()
- expoIn()
- expoInOut()
- expoOut()
- linear()
- quadIn()
- quadInOut()
- quadOut()
- quartIn()
- quartInOut()
- quartOut()
- quintIn()
- quintInOut()
- quintOut()
- sineIn()
- sineInOut()
- sineOut()
Namespaces
namespace *.svelte
module '*.svelte' {}
class SvelteComponent
class SvelteComponent< Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> extends SvelteComponent_1<Props, Events> {}
Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
Can be used to create strongly typed Svelte components.
#### Example:
You have component library on npm called
component-library
, from which you export a component calledMyComponent
. For Svelte+TypeScript users, you want to provide typings. Therefore you create aindex.d.ts
:import { SvelteComponent } from "svelte";export class MyComponent extends SvelteComponent<{foo: string}> {}Typing this makes it possible for IDEs like VS Code with the Svelte extension to provide intellisense and to use the component like this in a Svelte file with TypeScript:
<script lang="ts">import { MyComponent } from "component-library";</script><MyComponent foo={'bar'} />
constructor
constructor(options: ComponentConstructorOptions<Props>);
property $$events_def
$$events_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
property $$prop_def
$$prop_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
property $$slot_def
$$slot_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
method $capture_state
$capture_state: () => void;
method $inject_state
$inject_state: () => void;
namespace acorn
module 'acorn' {}
function isIdentifierChar
isIdentifierChar: (code: number, astral: boolean) => boolean;
function isIdentifierStart
isIdentifierStart: (code: number, astral: boolean) => boolean;
namespace svelte
module 'svelte' {}
function afterUpdate
afterUpdate: (fn: () => any) => void;
Schedules a callback to run immediately after the component has been updated.
The first time the callback runs will be after the initial
onMount
https://svelte.dev/docs/svelte#afterupdate
function beforeUpdate
beforeUpdate: (fn: () => any) => void;
Schedules a callback to run immediately before the component is updated after any state change.
The first time the callback runs will be before the initial
onMount
https://svelte.dev/docs/svelte#beforeupdate
function createEventDispatcher
createEventDispatcher: < EventMap extends Record<string, any> = any>() => EventDispatcher<EventMap>;
Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname). Event dispatchers are functions that can take two arguments:
name
anddetail
.Component events created with
createEventDispatcher
create a [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent). These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture). Thedetail
argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail) property and can contain any type of data.The event dispatcher can be typed to narrow the allowed event names and the type of the
detail
argument:const dispatch = createEventDispatcher<{loaded: never; // does not take a detail argumentchange: string; // takes a detail argument of type string, which is requiredoptional: number | null; // takes an optional detail argument of type number}>();https://svelte.dev/docs/svelte#createeventdispatcher
function getAllContexts
getAllContexts: <T extends Map<any, any> = Map<any, any>>() => T;
Retrieves the whole context map that belongs to the closest parent component. Must be called during component initialisation. Useful, for example, if you programmatically create a component and want to pass the existing context to it.
https://svelte.dev/docs/svelte#getallcontexts
function getContext
getContext: <T>(key: any) => T;
Retrieves the context that belongs to the closest parent component with the specified
key
. Must be called during component initialisation.https://svelte.dev/docs/svelte#getcontext
function hasContext
hasContext: (key: any) => boolean;
Checks whether a given
key
has been set in the context of a parent component. Must be called during component initialisation.https://svelte.dev/docs/svelte#hascontext
function onDestroy
onDestroy: (fn: () => any) => void;
Schedules a callback to run immediately before the component is unmounted.
Out of
onMount
,beforeUpdate
,afterUpdate
andonDestroy
, this is the only one that runs inside a server-side component.https://svelte.dev/docs/svelte#ondestroy
function onMount
onMount: <T>( fn: () => NotFunction<T> | Promise<NotFunction<T>> | (() => any)) => void;
The
onMount
function schedules a callback to run as soon as the component has been mounted to the DOM. It must be called during the component's initialisation (but doesn't need to live *inside* the component; it can be called from an external module).If a function is returned _synchronously_ from
onMount
, it will be called when the component is unmounted.onMount
does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api).https://svelte.dev/docs/svelte#onmount
function setContext
setContext: <T>(key: any, context: T) => T;
Associates an arbitrary
context
object with the current component and the specifiedkey
and returns that object. The context is then available to children of the component (including slotted content) withgetContext
.Like lifecycle functions, this must be called during component initialisation.
https://svelte.dev/docs/svelte#setcontext
function tick
tick: () => Promise<void>;
class SvelteComponent
class SvelteComponent< Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> extends SvelteComponent_1<Props, Events> {}
Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
Can be used to create strongly typed Svelte components.
#### Example:
You have component library on npm called
component-library
, from which you export a component calledMyComponent
. For Svelte+TypeScript users, you want to provide typings. Therefore you create aindex.d.ts
:import { SvelteComponent } from "svelte";export class MyComponent extends SvelteComponent<{foo: string}> {}Typing this makes it possible for IDEs like VS Code with the Svelte extension to provide intellisense and to use the component like this in a Svelte file with TypeScript:
<script lang="ts">import { MyComponent } from "component-library";</script><MyComponent foo={'bar'} />
constructor
constructor(options: ComponentConstructorOptions<Props>);
property $$events_def
$$events_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
property $$prop_def
$$prop_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
property $$slot_def
$$slot_def: Record<string, any>;
For type checking capabilities only. Does not exist at runtime. ### DO NOT USE!
method $capture_state
$capture_state: () => void;
method $inject_state
$inject_state: () => void;
class SvelteComponent_1
class SvelteComponent_1< Props extends Record<string, any> = any, Events extends Record<string, any> = any> {}
Base class for Svelte components. Used when dev=false.
property $$
$$: any;
### PRIVATE API
Do not use, may change at any time
property $$set
$$set: any;
### PRIVATE API
Do not use, may change at any time
method $destroy
$destroy: () => void;
method $on
$on: <K extends Extract<keyof Events, string>>( type: K, callback: (e: Events[K]) => void) => () => void;
method $set
$set: (props: Partial<Props>) => void;
class SvelteComponentTyped
class SvelteComponentTyped< Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> extends SvelteComponent<Props, Events, Slots> {}
Deprecated
Use
SvelteComponent
instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
interface ComponentConstructorOptions
interface ComponentConstructorOptions< Props extends Record<string, any> = Record<string, any>> {}
interface DispatchOptions
interface DispatchOptions {}
property cancelable
cancelable?: boolean;
interface EventDispatcher
interface EventDispatcher<EventMap extends Record<string, any>> {}
call signature
<Type extends keyof EventMap>( ...args: null extends EventMap[Type] ? [ type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions ] : undefined extends EventMap[Type] ? [ type: Type, parameter?: EventMap[Type] | null | undefined, options?: DispatchOptions ] : [type: Type, parameter: EventMap[Type], options?: DispatchOptions]): boolean;
type ComponentEvents
type ComponentEvents<Component extends SvelteComponent_1> = Component extends SvelteComponent<any, infer Events> ? Events : never;
Convenience type to get the events the given component expects. Example:
<script lang="ts">import type { ComponentEvents } from 'svelte';import Component from './Component.svelte';function handleCloseEvent(event: ComponentEvents<Component>['close']) {console.log(event.detail);}</script><Component on:close={handleCloseEvent} />
type ComponentProps
type ComponentProps<Component extends SvelteComponent_1> = Component extends SvelteComponent<infer Props> ? Props : never;
Convenience type to get the props the given component expects. Example:
<script lang="ts">import type { ComponentProps } from 'svelte';import Component from './Component.svelte';const props: ComponentProps<Component> = { foo: 'bar' }; // Errors if these aren't the correct props</script>
type ComponentType
type ComponentType<Component extends SvelteComponent = SvelteComponent> = (new ( options: ComponentConstructorOptions< Component extends SvelteComponent<infer Props> ? Props : Record<string, any> >) => Component) & { /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ element?: typeof HTMLElement;};
Convenience type to get the type of a Svelte component. Useful for example in combination with dynamic components using
<svelte:component>
.Example:
<script lang="ts">import type { ComponentType, SvelteComponent } from 'svelte';import Component1 from './Component1.svelte';import Component2 from './Component2.svelte';const component: ComponentType = someLogic() ? Component1 : Component2;const componentOfCertainSubType: ComponentType<SvelteComponent<{ needsThisProp: string }>> = someLogic() ? Component1 : Component2;</script><svelte:component this={component} /><svelte:component this={componentOfCertainSubType} needsThisProp="hello" />
type NotFunction
type NotFunction<T> = T extends Function ? never : T;
Anything except a function
namespace svelte/action
module 'svelte/action' {}
interface Action
interface Action< Element = HTMLElement, Parameter = undefined, Attributes extends Record<string, any> = Record<never, any>> {}
Actions are functions that are called when an element is created. You can use this interface to type such actions. The following example defines an action that only works on
<div>
elements and optionally accepts a parameter which it has a default value for:export const myAction: Action<HTMLDivElement, { someProperty: boolean } | undefined> = (node, param = { someProperty: true }) => {// ...}Action<HTMLDivElement>
andAction<HTMLDivElement, undefined>
both signal that the action accepts no parameters.You can return an object with methods
update
anddestroy
from the function and type which additional attributes and events it has. See interfaceActionReturn
for more details.Docs: https://svelte.dev/docs/svelte-action
call signature
<Node extends Element>( ...args: undefined extends Parameter ? [node: Node, parameter?: Parameter] : [node: Node, parameter: Parameter]): void | ActionReturn<Parameter, Attributes>;
interface ActionReturn
interface ActionReturn< Parameter = undefined, Attributes extends Record<string, any> = Record<never, any>> {}
Actions can return an object containing the two properties defined in this interface. Both are optional. - update: An action can have a parameter. This method will be called whenever that parameter changes, immediately after Svelte has applied updates to the markup.
ActionReturn
andActionReturn<undefined>
both mean that the action accepts no parameters. - destroy: Method that is called after the element is unmountedAdditionally, you can specify which additional attributes and events the action enables on the applied element. This applies to TypeScript typings only and has no effect at runtime.
Example usage:
interface Attributes {newprop?: string;'on:event': (e: CustomEvent<boolean>) => void;}export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn<Parameter, Attributes> {// ...return {update: (updatedParameter) => {...},destroy: () => {...}};}Docs: https://svelte.dev/docs/svelte-action
property $$_attributes
$$_attributes?: Attributes;
### DO NOT USE THIS This exists solely for type-checking and has no effect at runtime. Set this through the
Attributes
generic instead.
property destroy
destroy?: () => void;
property update
update?: (parameter: Parameter) => void;
namespace svelte/animate
module 'svelte/animate' {}
function flip
flip: ( node: Element, { from, to }: { from: DOMRect; to: DOMRect }, params?: FlipParams) => AnimationConfig;
The flip function calculates the start and end position of an element and animates between them, translating the x and y values.
flip
stands for [First, Last, Invert, Play](https://aerotwist.com/blog/flip-your-animations/).https://svelte.dev/docs/svelte-animate#flip
interface AnimationConfig
interface AnimationConfig {}
interface FlipParams
interface FlipParams {}
namespace svelte/compiler
module 'svelte/compiler' {}
variable VERSION
const VERSION: string;
The current version, as set in package.json.
https://svelte.dev/docs/svelte-compiler#svelte-version
function compile
compile: (source: string, options?: CompileOptions) => CompileResult;
compile
takes your component source code, and turns it into a JavaScript module that exports a class.https://svelte.dev/docs/svelte-compiler#svelte-compile
function parse
parse: (template: string, options?: ParserOptions) => Ast;
The parse function parses a component, returning only its abstract syntax tree.
https://svelte.dev/docs/svelte-compiler#svelte-parse
function preprocess
preprocess: ( source: string, preprocessor: PreprocessorGroup | PreprocessorGroup[], options?: { filename?: string | undefined } | undefined) => Promise<Processed>;
The preprocess function provides convenient hooks for arbitrarily transforming component source code. For example, it can be used to convert a block into vanilla CSS.
https://svelte.dev/docs/svelte-compiler#svelte-preprocess
interface CompileOptions
interface CompileOptions {}
property accessors
accessors?: boolean;
If
true
, getters and setters will be created for the component's props. Iffalse
, they will only be created for readonly exported values (i.e. those declared withconst
,class
andfunction
). If compiling withcustomElement: true
this option defaults totrue
.false
property css
css?: 'injected' | 'external' | 'none' | boolean;
-
'injected'
(formerlytrue
), styles will be included in the JavaScript class and injected at runtime for the components actually rendered. -'external'
(formerlyfalse
), the CSS will be returned in thecss
field of the compilation result. Most Svelte bundler plugins will set this to'external'
and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable.css
files. -'none'
, styles are completely avoided and no CSS output is generated.
property cssHash
cssHash?: CssHashGetter;
A function that takes a
{ hash, css, name, filename }
argument and returns the string that is used as a classname for scoped CSS. It defaults to returningsvelte-${hash(css)}
.undefined
property cssOutputFilename
cssOutputFilename?: string;
Used for your CSS sourcemap.
null
property customElement
customElement?: boolean;
If
true
, tells the compiler to generate a custom element constructor instead of a regular Svelte component.false
property dev
dev?: boolean;
If
true
, causes extra code to be added to components that will perform runtime checks and provide debugging information during development.false
property discloseVersion
discloseVersion?: boolean;
If
true
, exposes the Svelte major version in the browser by adding it to aSet
stored in the globalwindow.__svelte.v
.true
property enableSourcemap
enableSourcemap?: EnableSourcemap;
If
true
, Svelte generate sourcemaps for components. Use an object withjs
orcss
for more granular control of sourcemap generation.true
property errorMode
errorMode?: 'throw' | 'warn';
If
"throw"
, Svelte throws when a compilation error occurred. If"warn"
, Svelte will treat errors as warnings and add them to the warning report.'throw'
property filename
filename?: string;
Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically.
null
property generate
generate?: 'dom' | 'ssr' | false;
If
"dom"
, Svelte emits a JavaScript class for mounting to the DOM. If"ssr"
, Svelte emits an object with arender
method suitable for server-side rendering. Iffalse
, no JavaScript or CSS is returned; just metadata.'dom'
property hydratable
hydratable?: boolean;
If
true
when generating DOM code, enables thehydrate: true
runtime option, which allows a component to upgrade existing DOM rather than creating new DOM from scratch. When generating SSR code, this adds markers to<head>
elements so that hydration knows which to replace.false
property immutable
immutable?: boolean;
If
true
, tells the compiler that you promise not to mutate any objects. This allows it to be less conservative about checking whether values have changed.false
property legacy
legacy?: boolean;
If
true
, generates code that will work in IE9 and IE10, which don't support things likeelement.dataset
.false
property loopGuardTimeout
loopGuardTimeout?: number;
A
number
that tells Svelte to break the loop if it blocks the thread for more thanloopGuardTimeout
ms. This is useful to prevent infinite loops. **Only available whendev: true
**.0
property name
name?: string;
Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from
filename
'Component'
property namespace
namespace?: string;
The namespace of the element; e.g.,
"mathml"
,"svg"
,"foreign"
.'html'
property outputFilename
outputFilename?: string;
Used for your JavaScript sourcemap.
null
property preserveComments
preserveComments?: boolean;
If
true
, your HTML comments will be preserved during server-side rendering. By default, they are stripped out.false
property preserveWhitespace
preserveWhitespace?: boolean;
If
true
, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible.false
property sourcemap
sourcemap?: object | string;
An initial sourcemap that will be merged into the final output sourcemap. This is usually the preprocessor sourcemap.
null
property sveltePath
sveltePath?: string;
The location of the
svelte
package. Any imports fromsvelte
orsvelte/[module]
will be modified accordingly.'svelte'
property tag
tag?: string;
A
string
that tells Svelte what tag name to register the custom element with. It must be a lowercase alphanumeric string with at least one hyphen, e.g."my-element"
.null
property varsReport
varsReport?: 'full' | 'strict' | false;
If
"strict"
, Svelte returns a variables report with only variables that are not globals nor internals. If"full"
, Svelte returns a variables report with all detected variables. Iffalse
, no variables report is returned.'strict'
interface CompileResult
interface CompileResult {}
The returned shape of
compile
fromsvelte/compiler
property ast
ast: Ast;
The abstract syntax tree representing the structure of the component
property css
css: CssResult;
The resulting CSS code from compling the component
property js
js: { /** Code as a string */ code: string; /** A source map */ map: any;};
The resulting JavaScript code from compling the component
property stats
stats: { timings: { total: number; };};
An object used by the Svelte developer team for diagnosing the compiler. Avoid relying on it to stay the same!
property vars
vars: Var[];
An array of the component's declarations used by tooling in the ecosystem (like our ESLint plugin) to infer more information
property warnings
warnings: Warning[];
An array of warning objects that were generated during compilation. Each warning has several properties: - code is a string identifying the category of warning - message describes the issue in human-readable terms - start and end, if the warning relates to a specific location, are objects with line, column and character properties - frame, if applicable, is a string highlighting the offending code with line numbers
interface PreprocessorGroup
interface PreprocessorGroup {}
A preprocessor group is a set of preprocessors that are applied to a Svelte file.
interface Processed
interface Processed {}
The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged.
property attributes
attributes?: Record<string, string | boolean>;
Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged.
property code
code: string;
The new code
property dependencies
dependencies?: string[];
A list of additional files to watch for changes
property map
map?: string | object;
A source map mapping back to the original code
property toString
toString?: () => string;
interface SveltePreprocessor
interface SveltePreprocessor< PreprocessorType extends keyof PreprocessorGroup, Options = any> {}
Utility type to extract the type of a preprocessor from a preprocessor group
call signature
(options?: Options): Required<Pick<PreprocessorGroup, PreprocessorType>>;
type CssHashGetter
type CssHashGetter = (args: { name: string; filename: string | undefined; css: string; hash: (input: string) => string;}) => string;
type EnableSourcemap
type EnableSourcemap = boolean | { js: boolean; css: boolean };
type MarkupPreprocessor
type MarkupPreprocessor = (options: { /** * The whole Svelte file content */ content: string; /** * The filename of the Svelte file */ filename?: string;}) => Processed | void | Promise<Processed | void>;
A markup preprocessor that takes a string of code and returns a processed version.
type Preprocessor
type Preprocessor = (options: { /** * The script/style tag content */ content: string; /** * The attributes on the script/style tag */ attributes: Record<string, string | boolean>; /** * The whole Svelte file content */ markup: string; /** * The filename of the Svelte file */ filename?: string;}) => Processed | void | Promise<Processed | void>;
A script/style preprocessor that takes a string of code and returns a processed version.
namespace svelte/easing
module 'svelte/easing' {}
function backIn
backIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function backInOut
backInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function backOut
backOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function bounceIn
bounceIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function bounceInOut
bounceInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function bounceOut
bounceOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function circIn
circIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function circInOut
circInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function circOut
circOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function cubicIn
cubicIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function cubicInOut
cubicInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function cubicOut
cubicOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function elasticIn
elasticIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function elasticInOut
elasticInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function elasticOut
elasticOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function expoIn
expoIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function expoInOut
expoInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function expoOut
expoOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function linear
linear: (x: any) => any;
function quadIn
quadIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quadInOut
quadInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quadOut
quadOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quartIn
quartIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quartInOut
quartInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quartOut
quartOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quintIn
quintIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quintInOut
quintInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function quintOut
quintOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function sineIn
sineIn: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function sineInOut
sineInOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
function sineOut
sineOut: (t: number) => number;
https://svelte.dev/docs/svelte-easing
namespace svelte/motion
module 'svelte/motion' {}
function spring
spring: <T = any>( value?: T | undefined, opts?: SpringOpts | undefined) => Spring<T>;
The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.
https://svelte.dev/docs/svelte-motion#spring
function tweened
tweened: <T>( value?: T | undefined, defaults?: TweenedOptions<T> | undefined) => Tweened<T>;
A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.
https://svelte.dev/docs/svelte-motion#tweened
interface Readable
interface Readable<T> {}
Readable interface for subscribing.
method subscribe
subscribe: ( this: void, run: Subscriber<T>, invalidate?: Invalidator<T>) => Unsubscriber;
Subscribe on value changes.
Parameter run
subscription callback
Parameter invalidate
cleanup callback
interface Spring
interface Spring<T> extends Readable<T> {}
interface SpringOpts
interface SpringOpts {}
interface SpringUpdateOpts
interface SpringUpdateOpts {}
interface Tweened
interface Tweened<T> extends Readable<T> {}
interface TweenedOptions
interface TweenedOptions<T> {}
property delay
delay?: number;
property duration
duration?: number | ((from: T, to: T) => number);
property easing
easing?: (t: number) => number;
property interpolate
interpolate?: (a: T, b: T) => (t: number) => T;
type Invalidator
type Invalidator<T> = (value?: T) => void;
Cleanup logic callback.
type Subscriber
type Subscriber<T> = (value: T) => void;
Callback to inform of a value updates.
type Unsubscriber
type Unsubscriber = () => void;
Unsubscribes from value updates.
type Updater
type Updater<T> = (target_value: T, value: T) => T;
namespace svelte/store
module 'svelte/store' {}
function derived
derived: { <S extends Stores, T>( stores: S, fn: ( values: StoresValues<S>, set: (value: T) => void, update: (fn: Updater<T>) => void ) => Unsubscriber | void, initial_value?: T | undefined ): Readable<T>; <S extends Stores, T>( stores: S, fn: (values: StoresValues<S>) => T, initial_value?: T ): Readable<T>;};
Derived value store by synchronizing one or more readable stores and applying an aggregation function over its input values.
https://svelte.dev/docs/svelte-store#derived
function get
get: <T>(store: Readable<T>) => T;
Get the current value from a store by subscribing and immediately unsubscribing.
https://svelte.dev/docs/svelte-store#get
function readable
readable: <T>( value?: T | undefined, start?: StartStopNotifier<T> | undefined) => Readable<T>;
Creates a
Readable
store that allows reading by subscription.https://svelte.dev/docs/svelte-store#readable
Parameter value
initial value
function readonly
readonly: <T>(store: Readable<T>) => Readable<T>;
Takes a store and returns a new one derived from the old one that is readable.
https://svelte.dev/docs/svelte-store#readonly
Parameter store
store to make readonly
function writable
writable: <T>( value?: T | undefined, start?: StartStopNotifier<T> | undefined) => Writable<T>;
Create a
Writable
store that allows both updating and reading by subscription.https://svelte.dev/docs/svelte-store#writable
Parameter value
initial value
interface Readable
interface Readable<T> {}
Readable interface for subscribing.
method subscribe
subscribe: ( this: void, run: Subscriber<T>, invalidate?: Invalidator<T>) => Unsubscriber;
Subscribe on value changes.
Parameter run
subscription callback
Parameter invalidate
cleanup callback
interface Writable
interface Writable<T> extends Readable<T> {}
Writable interface for both updating and subscribing.
type Invalidator
type Invalidator<T> = (value?: T) => void;
Cleanup logic callback.
type StartStopNotifier
type StartStopNotifier<T> = ( set: (value: T) => void, update: (fn: Updater<T>) => void) => void | (() => void);
Start and stop notification callbacks. This function is called when the first subscriber subscribes.
Parameter set
Function that sets the value of the store.
Parameter update
Function that sets the value of the store after passing the current value to the update function.
Returns
Optionally, a cleanup function that is called when the last remaining subscriber unsubscribes.
type Stores
type Stores = | Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<Readable<any>>;
One or more
Readable
s.
type StoresValues
type StoresValues<T> = T extends Readable<infer U> ? U : { [K in keyof T]: T[K] extends Readable<infer U> ? U : never };
One or more values from
Readable
stores.
type Subscriber
type Subscriber<T> = (value: T) => void;
Callback to inform of a value updates.
type Unsubscriber
type Unsubscriber = () => void;
Unsubscribes from value updates.
type Updater
type Updater<T> = (value: T) => T;
Callback to update a value.
namespace svelte/transition
module 'svelte/transition' {}
function blur
blur: ( node: Element, { delay, duration, easing, amount, opacity }?: BlurParams | undefined) => TransitionConfig;
Animates a
blur
filter alongside an element's opacity.https://svelte.dev/docs/svelte-transition#blur
function crossfade
crossfade: ({ fallback, ...defaults}: CrossfadeParams & { fallback?: ( node: Element, params: CrossfadeParams, intro: boolean ) => TransitionConfig;}) => [ (node: any, params: CrossfadeParams & { key: any }) => () => TransitionConfig, (node: any, params: CrossfadeParams & { key: any }) => () => TransitionConfig];
The
crossfade
function creates a pair of [transitions](https://svelte.dev/docs#template-syntax-element-directives-transition-fn) calledsend
andreceive
. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, thefallback
transition is used.https://svelte.dev/docs/svelte-transition#crossfade
function draw
draw: ( node: SVGElement & { getTotalLength(): number }, { delay, speed, duration, easing }?: DrawParams | undefined) => TransitionConfig;
Animates the stroke of an SVG element, like a snake in a tube.
in
transitions begin with the path invisible and draw the path to the screen over time.out
transitions start in a visible state and gradually erase the path.draw
only works with elements that have agetTotalLength
method, like<path>
and<polyline>
.https://svelte.dev/docs/svelte-transition#draw
function fade
fade: ( node: Element, { delay, duration, easing }?: FadeParams | undefined) => TransitionConfig;
Animates the opacity of an element from 0 to the current opacity for
in
transitions and from the current opacity to 0 forout
transitions.https://svelte.dev/docs/svelte-transition#fade
function fly
fly: ( node: Element, { delay, duration, easing, x, y, opacity }?: FlyParams | undefined) => TransitionConfig;
Animates the x and y positions and the opacity of an element.
in
transitions animate from the provided values, passed as parameters to the element's default values.out
transitions animate from the element's default values to the provided values.https://svelte.dev/docs/svelte-transition#fly
function scale
scale: ( node: Element, { delay, duration, easing, start, opacity }?: ScaleParams | undefined) => TransitionConfig;
Animates the opacity and scale of an element.
in
transitions animate from an element's current (default) values to the provided values, passed as parameters.out
transitions animate from the provided values to an element's default values.https://svelte.dev/docs/svelte-transition#scale
function slide
slide: ( node: Element, { delay, duration, easing, axis }?: SlideParams | undefined) => TransitionConfig;
Slides an element in and out.
https://svelte.dev/docs/svelte-transition#slide
interface BlurParams
interface BlurParams {}
interface CrossfadeParams
interface CrossfadeParams {}
interface DrawParams
interface DrawParams {}
interface FadeParams
interface FadeParams {}
interface FlyParams
interface FlyParams {}
interface ScaleParams
interface ScaleParams {}
interface SlideParams
interface SlideParams {}
interface TransitionConfig
interface TransitionConfig {}
type EasingFunction
type EasingFunction = (t: number) => number;
namespace svelte/types/compiler/interfaces
module 'svelte/types/compiler/interfaces' {}
interface AppendTarget
interface AppendTarget {}
property slot_stack
slot_stack: string[];
property slots
slots: Record<string, string>;
interface Ast
interface Ast {}
interface Attribute
interface Attribute extends BaseNode {}
interface BaseDirective
interface BaseDirective extends BaseNode {}
interface BaseExpressionDirective
interface BaseExpressionDirective extends BaseDirective {}
property expression
expression: null | Node;
property modifiers
modifiers: string[];
property name
name: string;
property type
type: DirectiveType;
interface BaseNode
interface BaseNode {}
property children
children?: TemplateNode[];
property end
end: number;
property start
start: number;
property type
type: string;
index signature
[prop_name: string]: any;
interface Comment
interface Comment extends BaseNode {}
interface CompileOptions
interface CompileOptions {}
property accessors
accessors?: boolean;
If
true
, getters and setters will be created for the component's props. Iffalse
, they will only be created for readonly exported values (i.e. those declared withconst
,class
andfunction
). If compiling withcustomElement: true
this option defaults totrue
.false
property css
css?: 'injected' | 'external' | 'none' | boolean;
-
'injected'
(formerlytrue
), styles will be included in the JavaScript class and injected at runtime for the components actually rendered. -'external'
(formerlyfalse
), the CSS will be returned in thecss
field of the compilation result. Most Svelte bundler plugins will set this to'external'
and use the CSS that is statically generated for better performance, as it will result in smaller JavaScript bundles and the output can be served as cacheable.css
files. -'none'
, styles are completely avoided and no CSS output is generated.
property cssHash
cssHash?: CssHashGetter;
A function that takes a
{ hash, css, name, filename }
argument and returns the string that is used as a classname for scoped CSS. It defaults to returningsvelte-${hash(css)}
.undefined
property cssOutputFilename
cssOutputFilename?: string;
Used for your CSS sourcemap.
null
property customElement
customElement?: boolean;
If
true
, tells the compiler to generate a custom element constructor instead of a regular Svelte component.false
property dev
dev?: boolean;
If
true
, causes extra code to be added to components that will perform runtime checks and provide debugging information during development.false
property discloseVersion
discloseVersion?: boolean;
If
true
, exposes the Svelte major version in the browser by adding it to aSet
stored in the globalwindow.__svelte.v
.true
property enableSourcemap
enableSourcemap?: EnableSourcemap;
If
true
, Svelte generate sourcemaps for components. Use an object withjs
orcss
for more granular control of sourcemap generation.true
property errorMode
errorMode?: 'throw' | 'warn';
If
"throw"
, Svelte throws when a compilation error occurred. If"warn"
, Svelte will treat errors as warnings and add them to the warning report.'throw'
property filename
filename?: string;
Used for debugging hints and sourcemaps. Your bundler plugin will set it automatically.
null
property generate
generate?: 'dom' | 'ssr' | false;
If
"dom"
, Svelte emits a JavaScript class for mounting to the DOM. If"ssr"
, Svelte emits an object with arender
method suitable for server-side rendering. Iffalse
, no JavaScript or CSS is returned; just metadata.'dom'
property hydratable
hydratable?: boolean;
If
true
when generating DOM code, enables thehydrate: true
runtime option, which allows a component to upgrade existing DOM rather than creating new DOM from scratch. When generating SSR code, this adds markers to<head>
elements so that hydration knows which to replace.false
property immutable
immutable?: boolean;
If
true
, tells the compiler that you promise not to mutate any objects. This allows it to be less conservative about checking whether values have changed.false
property legacy
legacy?: boolean;
If
true
, generates code that will work in IE9 and IE10, which don't support things likeelement.dataset
.false
property loopGuardTimeout
loopGuardTimeout?: number;
A
number
that tells Svelte to break the loop if it blocks the thread for more thanloopGuardTimeout
ms. This is useful to prevent infinite loops. **Only available whendev: true
**.0
property name
name?: string;
Sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from
filename
'Component'
property namespace
namespace?: string;
The namespace of the element; e.g.,
"mathml"
,"svg"
,"foreign"
.'html'
property outputFilename
outputFilename?: string;
Used for your JavaScript sourcemap.
null
property preserveComments
preserveComments?: boolean;
If
true
, your HTML comments will be preserved during server-side rendering. By default, they are stripped out.false
property preserveWhitespace
preserveWhitespace?: boolean;
If
true
, whitespace inside and between elements is kept as you typed it, rather than removed or collapsed to a single space where possible.false
property sourcemap
sourcemap?: object | string;
An initial sourcemap that will be merged into the final output sourcemap. This is usually the preprocessor sourcemap.
null
property sveltePath
sveltePath?: string;
The location of the
svelte
package. Any imports fromsvelte
orsvelte/[module]
will be modified accordingly.'svelte'
property tag
tag?: string;
A
string
that tells Svelte what tag name to register the custom element with. It must be a lowercase alphanumeric string with at least one hyphen, e.g."my-element"
.null
property varsReport
varsReport?: 'full' | 'strict' | false;
If
"strict"
, Svelte returns a variables report with only variables that are not globals nor internals. If"full"
, Svelte returns a variables report with all detected variables. Iffalse
, no variables report is returned.'strict'
interface CompileResult
interface CompileResult {}
The returned shape of
compile
fromsvelte/compiler
property ast
ast: Ast;
The abstract syntax tree representing the structure of the component
property css
css: CssResult;
The resulting CSS code from compling the component
property js
js: { /** Code as a string */ code: string; /** A source map */ map: any;};
The resulting JavaScript code from compling the component
property stats
stats: { timings: { total: number; };};
An object used by the Svelte developer team for diagnosing the compiler. Avoid relying on it to stay the same!
property vars
vars: Var[];
An array of the component's declarations used by tooling in the ecosystem (like our ESLint plugin) to infer more information
property warnings
warnings: Warning[];
An array of warning objects that were generated during compilation. Each warning has several properties: - code is a string identifying the category of warning - message describes the issue in human-readable terms - start and end, if the warning relates to a specific location, are objects with line, column and character properties - frame, if applicable, is a string highlighting the offending code with line numbers
interface ConstTag
interface ConstTag extends BaseNode {}
property expression
expression: AssignmentExpression;
property type
type: 'ConstTag';
interface DebugTag
interface DebugTag extends BaseNode {}
property identifiers
identifiers: Node[];
property type
type: 'DebugTag';
interface Element
interface Element extends BaseNode {}
property attributes
attributes: Array<BaseDirective | Attribute | SpreadAttribute>;
property name
name: string;
property type
type: | 'InlineComponent' | 'SlotTemplate' | 'Title' | 'Slot' | 'Element' | 'Head' | 'Options' | 'Window' | 'Document' | 'Body';
interface Fragment
interface Fragment extends BaseNode {}
interface MustacheTag
interface MustacheTag extends BaseNode {}
property expression
expression: Node;
property type
type: 'MustacheTag' | 'RawMustacheTag';
interface Parser
interface Parser {}
interface ParserOptions
interface ParserOptions {}
property css
css?: 'injected' | 'external' | 'none' | boolean;
property customElement
customElement?: boolean;
property filename
filename?: string;
interface Script
interface Script extends BaseNode {}
interface SpreadAttribute
interface SpreadAttribute extends BaseNode {}
property expression
expression: Node;
property type
type: 'Spread';
interface Style
interface Style extends BaseNode {}
property attributes
attributes: any[];
property children
children: any[];
property content
content: { start: number; end: number; styles: string;};
property type
type: 'Style';
interface Text
interface Text extends BaseNode {}
interface Transition
interface Transition extends BaseExpressionDirective {}
interface Var
interface Var {}
property export_name
export_name?: string;
the
bar
inexport { foo as bar }
orexport let bar
property global
global?: boolean;
property hoistable
hoistable?: boolean;
property imported
imported?: boolean;
property initialised
initialised?: boolean;
property injected
injected?: boolean;
property internal
internal?: boolean;
property is_boolean
is_boolean?: boolean;
true if assigned a boolean default value (
export let foo = true
)
property is_reactive_dependency
is_reactive_dependency?: boolean;
property module
module?: boolean;
property mutated
mutated?: boolean;
property name
name: string;
property reassigned
reassigned?: boolean;
property referenced
referenced?: boolean;
property referenced_from_script
referenced_from_script?: boolean;
property subscribable
subscribable?: boolean;
property writable
writable?: boolean;
interface Visitor
interface Visitor {}
interface Warning
interface Warning {}
property code
code: string;
property end
end?: { line: number; column: number };
property filename
filename?: string;
property frame
frame?: string;
property message
message: string;
property pos
pos?: number;
property start
start?: { line: number; column: number; pos?: number };
property toString
toString: () => string;
type CssHashGetter
type CssHashGetter = (args: { name: string; filename: string | undefined; css: string; hash: (input: string) => string;}) => string;
type Directive
type Directive = BaseDirective | BaseExpressionDirective | Transition;
type DirectiveType
type DirectiveType = | 'Action' | 'Animation' | 'Binding' | 'Class' | 'StyleDirective' | 'EventHandler' | 'Let' | 'Ref' | 'Transition';
type EnableSourcemap
type EnableSourcemap = boolean | { js: boolean; css: boolean };
type TemplateNode
type TemplateNode = | Text | ConstTag | DebugTag | MustacheTag | BaseNode | Element | Attribute | SpreadAttribute | Directive | Transition | Comment;
namespace svelte/types/compiler/preprocess
module 'svelte/types/compiler/preprocess' {}
interface PreprocessorGroup
interface PreprocessorGroup {}
A preprocessor group is a set of preprocessors that are applied to a Svelte file.
interface Processed
interface Processed {}
The result of a preprocessor run. If the preprocessor does not return a result, it is assumed that the code is unchanged.
property attributes
attributes?: Record<string, string | boolean>;
Only for script/style preprocessors: The updated attributes to set on the tag. If undefined, attributes stay unchanged.
property code
code: string;
The new code
property dependencies
dependencies?: string[];
A list of additional files to watch for changes
property map
map?: string | object;
A source map mapping back to the original code
property toString
toString?: () => string;
interface SveltePreprocessor
interface SveltePreprocessor< PreprocessorType extends keyof PreprocessorGroup, Options = any> {}
Utility type to extract the type of a preprocessor from a preprocessor group
call signature
(options?: Options): Required<Pick<PreprocessorGroup, PreprocessorType>>;
type MarkupPreprocessor
type MarkupPreprocessor = (options: { /** * The whole Svelte file content */ content: string; /** * The filename of the Svelte file */ filename?: string;}) => Processed | void | Promise<Processed | void>;
A markup preprocessor that takes a string of code and returns a processed version.
type Preprocessor
type Preprocessor = (options: { /** * The script/style tag content */ content: string; /** * The attributes on the script/style tag */ attributes: Record<string, string | boolean>; /** * The whole Svelte file content */ markup: string; /** * The filename of the Svelte file */ filename?: string;}) => Processed | void | Promise<Processed | void>;
A script/style preprocessor that takes a string of code and returns a processed version.
Package Files (2)
Dependencies (14)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/svelte
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/svelte)
- HTML<a href="https://www.jsdocs.io/package/svelte"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 7838 ms. - Missing or incorrect documentation? Open an issue for this package.