svelte 3.30.0 → 3.31.2
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/CHANGELOG.md +27 -0
- package/LICENSE +1 -1
- package/compiler.js +349 -146
- package/compiler.js.map +1 -1
- package/compiler.mjs +349 -146
- package/compiler.mjs.map +1 -1
- package/index.js +12 -0
- package/index.mjs +1 -1
- package/internal/index.js +48 -4
- package/internal/index.mjs +48 -5
- package/package.json +8 -8
- package/transition/index.js +10 -10
- package/transition/index.mjs +10 -10
- package/types/compiler/compile/nodes/Action.d.ts +4 -1
- package/types/compiler/compile/nodes/Animation.d.ts +4 -1
- package/types/compiler/compile/nodes/Attribute.d.ts +2 -1
- package/types/compiler/compile/nodes/AwaitBlock.d.ts +1 -1
- package/types/compiler/compile/nodes/Binding.d.ts +5 -1
- package/types/compiler/compile/nodes/Body.d.ts +4 -1
- package/types/compiler/compile/nodes/Class.d.ts +4 -1
- package/types/compiler/compile/nodes/Comment.d.ts +4 -1
- package/types/compiler/compile/nodes/DebugTag.d.ts +5 -1
- package/types/compiler/compile/nodes/EachBlock.d.ts +3 -1
- package/types/compiler/compile/nodes/Element.d.ts +1 -1
- package/types/compiler/compile/nodes/ElseBlock.d.ts +4 -1
- package/types/compiler/compile/nodes/EventHandler.d.ts +4 -2
- package/types/compiler/compile/nodes/Fragment.d.ts +2 -1
- package/types/compiler/compile/nodes/Head.d.ts +4 -1
- package/types/compiler/compile/nodes/IfBlock.d.ts +5 -1
- package/types/compiler/compile/nodes/InlineComponent.d.ts +2 -1
- package/types/compiler/compile/nodes/KeyBlock.d.ts +5 -1
- package/types/compiler/compile/nodes/Let.d.ts +3 -1
- package/types/compiler/compile/nodes/PendingBlock.d.ts +5 -1
- package/types/compiler/compile/nodes/Slot.d.ts +2 -1
- package/types/compiler/compile/nodes/Text.d.ts +2 -1
- package/types/compiler/compile/nodes/Title.d.ts +3 -1
- package/types/compiler/compile/nodes/Transition.d.ts +4 -1
- package/types/compiler/compile/nodes/Window.d.ts +4 -1
- package/types/compiler/compile/nodes/shared/Expression.d.ts +2 -2
- package/types/compiler/compile/nodes/shared/Node.d.ts +2 -1
- package/types/compiler/compile/nodes/shared/is_contextual.d.ts +3 -0
- package/types/compiler/compile/render_dom/Block.d.ts +1 -0
- package/types/compiler/compile/render_dom/Renderer.d.ts +1 -0
- package/types/compiler/compile/render_dom/invalidate.d.ts +1 -0
- package/types/compiler/compile/render_dom/wrappers/EachBlock.d.ts +2 -2
- package/types/compiler/compile/utils/get_slot_data.d.ts +1 -1
- package/types/compiler/utils/string_with_sourcemap.d.ts +1 -1
- package/types/runtime/index.d.ts +1 -1
- package/types/runtime/internal/Component.d.ts +7 -4
- package/types/runtime/internal/dev.d.ts +63 -4
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import AbstractBlock from './shared/AbstractBlock';
|
|
2
|
+
import Component from '../Component';
|
|
3
|
+
import TemplateScope from './shared/TemplateScope';
|
|
4
|
+
import { TemplateNode } from '../../interfaces';
|
|
5
|
+
import Node from './shared/Node';
|
|
2
6
|
export default class PendingBlock extends AbstractBlock {
|
|
3
7
|
type: 'PendingBlock';
|
|
4
|
-
constructor(component:
|
|
8
|
+
constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
|
|
5
9
|
}
|
|
@@ -3,11 +3,12 @@ import Attribute from './Attribute';
|
|
|
3
3
|
import Component from '../Component';
|
|
4
4
|
import TemplateScope from './shared/TemplateScope';
|
|
5
5
|
import { INode } from './interfaces';
|
|
6
|
+
import { TemplateNode } from '../../interfaces';
|
|
6
7
|
export default class Slot extends Element {
|
|
7
8
|
type: 'Element';
|
|
8
9
|
name: string;
|
|
9
10
|
children: INode[];
|
|
10
11
|
slot_name: string;
|
|
11
12
|
values: Map<string, Attribute>;
|
|
12
|
-
constructor(component: Component, parent: INode, scope: TemplateScope, info:
|
|
13
|
+
constructor(component: Component, parent: INode, scope: TemplateScope, info: TemplateNode);
|
|
13
14
|
}
|
|
@@ -2,10 +2,11 @@ import Node from './shared/Node';
|
|
|
2
2
|
import Component from '../Component';
|
|
3
3
|
import TemplateScope from './shared/TemplateScope';
|
|
4
4
|
import { INode } from './interfaces';
|
|
5
|
+
import { TemplateNode } from '../../interfaces';
|
|
5
6
|
export default class Text extends Node {
|
|
6
7
|
type: 'Text';
|
|
7
8
|
data: string;
|
|
8
9
|
synthetic: boolean;
|
|
9
|
-
constructor(component: Component, parent: INode, scope: TemplateScope, info:
|
|
10
|
+
constructor(component: Component, parent: INode, scope: TemplateScope, info: TemplateNode);
|
|
10
11
|
should_skip(): any;
|
|
11
12
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Node from './shared/Node';
|
|
2
2
|
import { Children } from './shared/map_children';
|
|
3
3
|
import Component from '../Component';
|
|
4
|
+
import TemplateScope from './shared/TemplateScope';
|
|
5
|
+
import { TemplateNode } from '../../interfaces';
|
|
4
6
|
export default class Title extends Node {
|
|
5
7
|
type: 'Title';
|
|
6
8
|
children: Children;
|
|
7
9
|
should_cache: boolean;
|
|
8
|
-
constructor(component: Component, parent:
|
|
10
|
+
constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
|
|
9
11
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import Node from './shared/Node';
|
|
2
2
|
import Expression from './shared/Expression';
|
|
3
3
|
import Component from '../Component';
|
|
4
|
+
import TemplateScope from './shared/TemplateScope';
|
|
5
|
+
import { TemplateNode } from '../../interfaces';
|
|
6
|
+
import Element from './Element';
|
|
4
7
|
export default class Transition extends Node {
|
|
5
8
|
type: 'Transition';
|
|
6
9
|
name: string;
|
|
7
10
|
directive: string;
|
|
8
11
|
expression: Expression;
|
|
9
12
|
is_local: boolean;
|
|
10
|
-
constructor(component: Component, parent:
|
|
13
|
+
constructor(component: Component, parent: Element, scope: TemplateScope, info: TemplateNode);
|
|
11
14
|
}
|
|
@@ -2,10 +2,13 @@ import Node from './shared/Node';
|
|
|
2
2
|
import Binding from './Binding';
|
|
3
3
|
import EventHandler from './EventHandler';
|
|
4
4
|
import Action from './Action';
|
|
5
|
+
import Component from '../Component';
|
|
6
|
+
import TemplateScope from './shared/TemplateScope';
|
|
7
|
+
import { TemplateNode } from '../../interfaces';
|
|
5
8
|
export default class Window extends Node {
|
|
6
9
|
type: 'Window';
|
|
7
10
|
handlers: EventHandler[];
|
|
8
11
|
bindings: Binding[];
|
|
9
12
|
actions: Action[];
|
|
10
|
-
constructor(component:
|
|
13
|
+
constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
|
|
11
14
|
}
|
|
@@ -9,7 +9,7 @@ export default class Expression {
|
|
|
9
9
|
type: 'Expression';
|
|
10
10
|
component: Component;
|
|
11
11
|
owner: Owner;
|
|
12
|
-
node:
|
|
12
|
+
node: Node;
|
|
13
13
|
references: Set<string>;
|
|
14
14
|
dependencies: Set<string>;
|
|
15
15
|
contextual_dependencies: Set<string>;
|
|
@@ -19,7 +19,7 @@ export default class Expression {
|
|
|
19
19
|
declarations: Array<(Node | Node[])>;
|
|
20
20
|
uses_context: boolean;
|
|
21
21
|
manipulated: Node;
|
|
22
|
-
constructor(component: Component, owner: Owner, template_scope: TemplateScope, info:
|
|
22
|
+
constructor(component: Component, owner: Owner, template_scope: TemplateScope, info: Node, lazy?: boolean);
|
|
23
23
|
dynamic_dependencies(): string[];
|
|
24
24
|
manipulate(block?: Block): Node;
|
|
25
25
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Attribute from '../Attribute';
|
|
2
2
|
import Component from '../../Component';
|
|
3
3
|
import { INode } from '../interfaces';
|
|
4
|
+
import { TemplateNode } from '../../../interfaces';
|
|
4
5
|
export default class Node {
|
|
5
6
|
readonly start: number;
|
|
6
7
|
readonly end: number;
|
|
@@ -12,7 +13,7 @@ export default class Node {
|
|
|
12
13
|
can_use_innerhtml: boolean;
|
|
13
14
|
var: string;
|
|
14
15
|
attributes: Attribute[];
|
|
15
|
-
constructor(component: Component, parent:
|
|
16
|
+
constructor(component: Component, parent: Node, _scope: any, info: TemplateNode);
|
|
16
17
|
cannot_use_innerhtml(): void;
|
|
17
18
|
find_nearest(selector: RegExp): any;
|
|
18
19
|
get_static_attribute_value(name: string): string | true;
|
|
@@ -2,3 +2,4 @@ import { Scope } from '../utils/scope';
|
|
|
2
2
|
import { Node } from 'estree';
|
|
3
3
|
import Renderer from './Renderer';
|
|
4
4
|
export declare function invalidate(renderer: Renderer, scope: Scope, node: Node, names: Set<string>, main_execution_context?: boolean): any;
|
|
5
|
+
export declare function renderer_invalidate(renderer: Renderer, name: string, value?: any, main_execution_context?: boolean): any;
|
|
@@ -24,8 +24,8 @@ export default class EachBlockWrapper extends Wrapper {
|
|
|
24
24
|
get_each_context: Identifier;
|
|
25
25
|
iterations: Identifier;
|
|
26
26
|
fixed_length: number;
|
|
27
|
-
data_length:
|
|
28
|
-
view_length:
|
|
27
|
+
data_length: Node | number;
|
|
28
|
+
view_length: Node | number;
|
|
29
29
|
};
|
|
30
30
|
context_props: Array<Node | Node[]>;
|
|
31
31
|
index_name: Identifier;
|
|
@@ -4,6 +4,6 @@ export default function get_slot_data(values: Map<string, Attribute>, block?: Bl
|
|
|
4
4
|
type: string;
|
|
5
5
|
properties: (import("estree").Property | import("estree").SpreadElement | {
|
|
6
6
|
type: string;
|
|
7
|
-
argument:
|
|
7
|
+
argument: import("estree").Identifier | import("estree").SimpleLiteral | import("estree").RegExpLiteral | import("estree").Program | import("estree").FunctionDeclaration | import("estree").FunctionExpression | import("estree").ArrowFunctionExpression | import("estree").SwitchCase | import("estree").CatchClause | import("estree").VariableDeclarator | import("estree").ExpressionStatement | import("estree").BlockStatement | import("estree").EmptyStatement | import("estree").DebuggerStatement | import("estree").WithStatement | import("estree").ReturnStatement | import("estree").LabeledStatement | import("estree").BreakStatement | import("estree").ContinueStatement | import("estree").IfStatement | import("estree").SwitchStatement | import("estree").ThrowStatement | import("estree").TryStatement | import("estree").WhileStatement | import("estree").DoWhileStatement | import("estree").ForStatement | import("estree").ForInStatement | import("estree").ForOfStatement | import("estree").VariableDeclaration | import("estree").ClassDeclaration | import("estree").ThisExpression | import("estree").ArrayExpression | import("estree").ObjectExpression | import("estree").YieldExpression | import("estree").UnaryExpression | import("estree").UpdateExpression | import("estree").BinaryExpression | import("estree").AssignmentExpression | import("estree").LogicalExpression | import("estree").MemberExpression | import("estree").ConditionalExpression | import("estree").SimpleCallExpression | import("estree").NewExpression | import("estree").SequenceExpression | import("estree").TemplateLiteral | import("estree").TaggedTemplateExpression | import("estree").ClassExpression | import("estree").MetaProperty | import("estree").AwaitExpression | import("estree").ImportExpression | import("estree").ChainExpression | import("estree").Property | import("estree").Super | import("estree").TemplateElement | import("estree").SpreadElement | import("estree").ObjectPattern | import("estree").ArrayPattern | import("estree").RestElement | import("estree").AssignmentPattern | import("estree").ClassBody | import("estree").MethodDefinition | import("estree").ImportDeclaration | import("estree").ExportNamedDeclaration | import("estree").ExportDefaultDeclaration | import("estree").ExportAllDeclaration | import("estree").ImportSpecifier | import("estree").ImportDefaultSpecifier | import("estree").ImportNamespaceSpecifier | import("estree").ExportSpecifier;
|
|
8
8
|
})[];
|
|
9
9
|
};
|
|
@@ -4,7 +4,7 @@ declare type SourceLocation = {
|
|
|
4
4
|
line: number;
|
|
5
5
|
column: number;
|
|
6
6
|
};
|
|
7
|
-
export declare function sourcemap_add_offset(map: DecodedSourceMap, offset: SourceLocation):
|
|
7
|
+
export declare function sourcemap_add_offset(map: DecodedSourceMap, offset: SourceLocation, source_index: number): void;
|
|
8
8
|
export declare class StringWithSourcemap {
|
|
9
9
|
string: string;
|
|
10
10
|
map: DecodedSourceMap;
|
package/types/runtime/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './ambient';
|
|
2
|
-
export { onMount, onDestroy, beforeUpdate, afterUpdate, setContext, getContext, tick, createEventDispatcher, SvelteComponentDev as SvelteComponent } from 'svelte/internal';
|
|
2
|
+
export { onMount, onDestroy, beforeUpdate, afterUpdate, setContext, getContext, hasContext, tick, createEventDispatcher, SvelteComponentDev as SvelteComponent, SvelteComponentTyped } from 'svelte/internal';
|
|
@@ -36,11 +36,14 @@ export declare function mount_component(component: any, target: any, anchor: any
|
|
|
36
36
|
export declare function destroy_component(component: any, detaching: any): void;
|
|
37
37
|
export declare function init(component: any, options: any, instance: any, create_fragment: any, not_equal: any, props: any, dirty?: number[]): void;
|
|
38
38
|
export declare let SvelteElement: any;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Base class for Svelte components. Used when dev=false.
|
|
41
|
+
*/
|
|
42
|
+
export declare class SvelteComponent {
|
|
40
43
|
$$: T$$;
|
|
41
|
-
$$set?: ($$props:
|
|
44
|
+
$$set?: ($$props: any) => void;
|
|
42
45
|
$destroy(): void;
|
|
43
|
-
$on
|
|
44
|
-
$set($$props:
|
|
46
|
+
$on(type: any, callback: any): () => void;
|
|
47
|
+
$set($$props: any): void;
|
|
45
48
|
}
|
|
46
49
|
export {};
|
|
@@ -13,13 +13,73 @@ export declare function dataset_dev(node: HTMLElement, property: string, value?:
|
|
|
13
13
|
export declare function set_data_dev(text: any, data: any): void;
|
|
14
14
|
export declare function validate_each_argument(arg: any): void;
|
|
15
15
|
export declare function validate_slots(name: any, slot: any, keys: any): void;
|
|
16
|
-
|
|
16
|
+
declare type Props = Record<string, any>;
|
|
17
|
+
export interface SvelteComponentDev {
|
|
18
|
+
$set(props?: Props): void;
|
|
19
|
+
$on(event: string, callback: (event: any) => void): () => void;
|
|
20
|
+
$destroy(): void;
|
|
21
|
+
[accessor: string]: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SvelteComponentDev extends SvelteComponent {
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
* For type checking capabilities only.
|
|
30
|
+
* Does not exist at runtime.
|
|
31
|
+
* ### DO NOT USE!
|
|
32
|
+
*/
|
|
33
|
+
$$prop_def: Props;
|
|
34
|
+
constructor(options: {
|
|
35
|
+
target: Element;
|
|
36
|
+
anchor?: Element;
|
|
37
|
+
props?: Props;
|
|
38
|
+
hydrate?: boolean;
|
|
39
|
+
intro?: boolean;
|
|
40
|
+
$$inline?: boolean;
|
|
41
|
+
});
|
|
42
|
+
$capture_state(): void;
|
|
43
|
+
$inject_state(): void;
|
|
44
|
+
}
|
|
45
|
+
export interface SvelteComponentTyped<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> {
|
|
17
46
|
$set(props?: Partial<Props>): void;
|
|
18
47
|
$on<K extends Extract<keyof Events, string>>(type: K, callback: (e: Events[K]) => void): () => void;
|
|
19
48
|
$destroy(): void;
|
|
20
49
|
[accessor: string]: any;
|
|
21
50
|
}
|
|
22
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Base class to create strongly typed Svelte components.
|
|
53
|
+
* This only exists for typing purposes and should be used in `.d.ts` files.
|
|
54
|
+
*
|
|
55
|
+
* ### Example:
|
|
56
|
+
*
|
|
57
|
+
* You have component library on npm called `component-library`, from which
|
|
58
|
+
* you export a component called `MyComponent`. For Svelte+TypeScript users,
|
|
59
|
+
* you want to provide typings. Therefore you create a `index.d.ts`:
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { SvelteComponentTyped } from "svelte";
|
|
62
|
+
* export class MyComponent extends SvelteComponentTyped<{foo: string}> {}
|
|
63
|
+
* ```
|
|
64
|
+
* Typing this makes it possible for IDEs like VS Code with the Svelte extension
|
|
65
|
+
* to provide intellisense and to use the component like this in a Svelte file
|
|
66
|
+
* with TypeScript:
|
|
67
|
+
* ```svelte
|
|
68
|
+
* <script lang="ts">
|
|
69
|
+
* import { MyComponent } from "component-library";
|
|
70
|
+
* </script>
|
|
71
|
+
* <MyComponent foo={'bar'} />
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* #### Why not make this part of `SvelteComponent(Dev)`?
|
|
75
|
+
* Because
|
|
76
|
+
* ```ts
|
|
77
|
+
* class ASubclassOfSvelteComponent extends SvelteComponent<{foo: string}> {}
|
|
78
|
+
* const component: typeof SvelteComponent = ASubclassOfSvelteComponent;
|
|
79
|
+
* ```
|
|
80
|
+
* will throw a type error, so we need to seperate the more strictly typed class.
|
|
81
|
+
*/
|
|
82
|
+
export declare class SvelteComponentTyped<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any> extends SvelteComponentDev {
|
|
23
83
|
/**
|
|
24
84
|
* @private
|
|
25
85
|
* For type checking capabilities only.
|
|
@@ -49,7 +109,6 @@ export declare class SvelteComponentDev<Props extends Record<string, any> = any,
|
|
|
49
109
|
intro?: boolean;
|
|
50
110
|
$$inline?: boolean;
|
|
51
111
|
});
|
|
52
|
-
$capture_state(): void;
|
|
53
|
-
$inject_state(): void;
|
|
54
112
|
}
|
|
55
113
|
export declare function loop_guard(timeout: any): () => void;
|
|
114
|
+
export {};
|