svelte 3.44.2 → 3.46.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE.md +1 -1
  3. package/compiler.js +19389 -18851
  4. package/compiler.js.map +1 -1
  5. package/compiler.mjs +19962 -19424
  6. package/compiler.mjs.map +1 -1
  7. package/internal/index.js +101 -28
  8. package/internal/index.mjs +100 -29
  9. package/package.json +4 -4
  10. package/types/compiler/compile/Component.d.ts +2 -2
  11. package/types/compiler/compile/nodes/CatchBlock.d.ts +2 -0
  12. package/types/compiler/compile/nodes/EachBlock.d.ts +2 -0
  13. package/types/compiler/compile/nodes/Element.d.ts +2 -0
  14. package/types/compiler/compile/nodes/SlotTemplate.d.ts +2 -0
  15. package/types/compiler/compile/nodes/Style.d.ts +12 -0
  16. package/types/compiler/compile/nodes/StyleDirective.d.ts +12 -0
  17. package/types/compiler/compile/nodes/ThenBlock.d.ts +2 -0
  18. package/types/compiler/compile/nodes/interfaces.d.ts +4 -2
  19. package/types/compiler/compile/nodes/shared/Context.d.ts +10 -1
  20. package/types/compiler/compile/nodes/shared/Expression.d.ts +1 -1
  21. package/types/compiler/compile/nodes/shared/TemplateScope.d.ts +3 -1
  22. package/types/compiler/compile/nodes/shared/map_children.d.ts +2 -1
  23. package/types/compiler/compile/render_dom/Renderer.d.ts +1 -1
  24. package/types/compiler/compile/render_dom/wrappers/AwaitBlock.d.ts +2 -1
  25. package/types/compiler/compile/render_dom/wrappers/Element/Binding.d.ts +1 -0
  26. package/types/compiler/compile/render_dom/wrappers/Element/index.d.ts +1 -0
  27. package/types/compiler/compile/render_dom/wrappers/SlotTemplate.d.ts +4 -11
  28. package/types/compiler/compile/render_ssr/handlers/SlotTemplate.d.ts +1 -3
  29. package/types/compiler/compile/utils/nodes_to_template_literal.d.ts +7 -0
  30. package/types/compiler/interfaces.d.ts +18 -6
  31. package/types/compiler/utils/namespaces.d.ts +1 -1
  32. package/types/runtime/internal/dom.d.ts +1 -1
  33. package/types/runtime/internal/ssr.d.ts +3 -1
@@ -7,7 +7,9 @@ import Binding from './Binding';
7
7
  import Body from './Body';
8
8
  import CatchBlock from './CatchBlock';
9
9
  import Class from './Class';
10
+ import StyleDirective from './StyleDirective';
10
11
  import Comment from './Comment';
12
+ import ConstTag from './ConstTag';
11
13
  import DebugTag from './DebugTag';
12
14
  import EachBlock from './EachBlock';
13
15
  import Element from './Element';
@@ -25,10 +27,10 @@ import PendingBlock from './PendingBlock';
25
27
  import RawMustacheTag from './RawMustacheTag';
26
28
  import Slot from './Slot';
27
29
  import SlotTemplate from './SlotTemplate';
28
- import DefaultSlotTemplate from './DefaultSlotTemplate';
29
30
  import Text from './Text';
30
31
  import ThenBlock from './ThenBlock';
31
32
  import Title from './Title';
32
33
  import Transition from './Transition';
33
34
  import Window from './Window';
34
- export declare type INode = Action | Animation | Attribute | AwaitBlock | Binding | Body | CatchBlock | Class | Comment | DebugTag | EachBlock | Element | ElseBlock | EventHandler | Fragment | Head | IfBlock | InlineComponent | KeyBlock | Let | MustacheTag | Options | PendingBlock | RawMustacheTag | Slot | SlotTemplate | DefaultSlotTemplate | Tag | Text | ThenBlock | Title | Transition | Window;
35
+ export declare type INode = Action | Animation | Attribute | AwaitBlock | Binding | Body | CatchBlock | Class | Comment | ConstTag | DebugTag | EachBlock | Element | ElseBlock | EventHandler | Fragment | Head | IfBlock | InlineComponent | KeyBlock | Let | MustacheTag | Options | PendingBlock | RawMustacheTag | Slot | SlotTemplate | StyleDirective | Tag | Text | ThenBlock | Title | Transition | Window;
36
+ export declare type INodeAllowConstTag = EachBlock | CatchBlock | ThenBlock | InlineComponent | SlotTemplate;
@@ -1,8 +1,17 @@
1
1
  import { Node, Identifier } from 'estree';
2
+ import Component from '../../Component';
3
+ import TemplateScope from './TemplateScope';
2
4
  export interface Context {
3
5
  key: Identifier;
4
6
  name?: string;
5
7
  modifier: (node: Node) => Node;
6
8
  default_modifier: (node: Node, to_ctx: (name: string) => Node) => Node;
7
9
  }
8
- export declare function unpack_destructuring(contexts: Context[], node: Node, modifier?: Context['modifier'], default_modifier?: Context['default_modifier']): void;
10
+ export declare function unpack_destructuring({ contexts, node, modifier, default_modifier, scope, component }: {
11
+ contexts: Context[];
12
+ node: Node;
13
+ modifier?: Context['modifier'];
14
+ default_modifier?: Context['default_modifier'];
15
+ scope: TemplateScope;
16
+ component: Component;
17
+ }): void;
@@ -21,6 +21,6 @@ export default class Expression {
21
21
  manipulated: Node;
22
22
  constructor(component: Component, owner: Owner, template_scope: TemplateScope, info: Node, lazy?: boolean);
23
23
  dynamic_dependencies(): string[];
24
- manipulate(block?: Block): Node;
24
+ manipulate(block?: Block, ctx?: string | void): Node;
25
25
  }
26
26
  export {};
@@ -4,7 +4,8 @@ import CatchBlock from '../CatchBlock';
4
4
  import InlineComponent from '../InlineComponent';
5
5
  import Element from '../Element';
6
6
  import SlotTemplate from '../SlotTemplate';
7
- declare type NodeWithScope = EachBlock | ThenBlock | CatchBlock | InlineComponent | Element | SlotTemplate;
7
+ import ConstTag from '../ConstTag';
8
+ declare type NodeWithScope = EachBlock | ThenBlock | CatchBlock | InlineComponent | Element | SlotTemplate | ConstTag;
8
9
  export default class TemplateScope {
9
10
  names: Set<string>;
10
11
  dependencies_for_name: Map<string, Set<string>>;
@@ -17,5 +18,6 @@ export default class TemplateScope {
17
18
  get_owner(name: string): NodeWithScope;
18
19
  is_let(name: string): boolean;
19
20
  is_await(name: string): boolean;
21
+ is_const(name: string): boolean;
20
22
  }
21
23
  export {};
@@ -1,5 +1,6 @@
1
1
  import AwaitBlock from '../AwaitBlock';
2
2
  import Body from '../Body';
3
+ import ConstTag from '../ConstTag';
3
4
  import Comment from '../Comment';
4
5
  import EachBlock from '../EachBlock';
5
6
  import Element from '../Element';
@@ -17,4 +18,4 @@ import Title from '../Title';
17
18
  import Window from '../Window';
18
19
  import { TemplateNode } from '../../../interfaces';
19
20
  export declare type Children = ReturnType<typeof map_children>;
20
- export default function map_children(component: any, parent: any, scope: any, children: TemplateNode[]): (AwaitBlock | Body | Comment | DebugTag | EachBlock | Element | Head | IfBlock | InlineComponent | KeyBlock | MustacheTag | Options | RawMustacheTag | SlotTemplate | Text | Title | Window)[];
21
+ export default function map_children(component: any, parent: any, scope: any, children: TemplateNode[]): (AwaitBlock | Body | Comment | ConstTag | DebugTag | EachBlock | Element | Head | IfBlock | InlineComponent | KeyBlock | MustacheTag | Options | RawMustacheTag | SlotTemplate | Text | Title | Window)[];
@@ -40,7 +40,7 @@ export default class Renderer {
40
40
  invalidate(name: string, value?: any, main_execution_context?: boolean): any;
41
41
  dirty(names: string[], is_reactive_declaration?: boolean): Expression;
42
42
  get_initial_dirty(): UnaryExpression | ArrayExpression;
43
- reference(node: string | Identifier | MemberExpression): any;
43
+ reference(node: string | Identifier | MemberExpression, ctx?: string | void): any;
44
44
  remove_block(block: Block | Node | Node[]): void;
45
45
  }
46
46
  export {};
@@ -23,8 +23,9 @@ declare class AwaitBlockBranch extends Wrapper {
23
23
  is_destructured: boolean;
24
24
  constructor(status: Status, renderer: Renderer, block: Block, parent: AwaitBlockWrapper, node: PendingBlock | ThenBlock | CatchBlock, strip_whitespace: boolean, next_sibling: Wrapper);
25
25
  add_context(node: Node | null, contexts: Context[]): void;
26
+ has_consts(node: PendingBlock | ThenBlock | CatchBlock): node is ThenBlock | CatchBlock;
26
27
  render(block: Block, parent_node: Identifier, parent_nodes: Identifier): void;
27
- render_destructure(): void;
28
+ render_get_context(): void;
28
29
  }
29
30
  export default class AwaitBlockWrapper extends Wrapper {
30
31
  node: AwaitBlock;
@@ -18,6 +18,7 @@ export default class BindingWrapper {
18
18
  needs_lock: boolean;
19
19
  constructor(block: Block, node: Binding, parent: ElementWrapper | InlineComponentWrapper);
20
20
  get_dependencies(): Set<string>;
21
+ get_update_dependencies(): Set<string>;
21
22
  is_readonly_media_attribute(): boolean;
22
23
  render(block: Block, lock: Identifier): void;
23
24
  }
@@ -198,6 +198,7 @@ export default class ElementWrapper extends Wrapper {
198
198
  add_transitions(block: Block): void;
199
199
  add_animation(block: Block): void;
200
200
  add_classes(block: Block): void;
201
+ add_styles(block: Block): void;
201
202
  add_manual_style_scoping(block: any): void;
202
203
  }
203
204
  export {};
@@ -3,20 +3,13 @@ import Renderer from '../Renderer';
3
3
  import Block from '../Block';
4
4
  import FragmentWrapper from './Fragment';
5
5
  import InlineComponentWrapper from './InlineComponent';
6
- import { INode } from '../../nodes/interfaces';
7
- import Let from '../../nodes/Let';
8
- import TemplateScope from '../../nodes/shared/TemplateScope';
9
- declare type NodeWithLets = INode & {
10
- scope: TemplateScope;
11
- lets: Let[];
12
- slot_template_name: string;
13
- };
6
+ import SlotTemplate from '../../nodes/SlotTemplate';
14
7
  export default class SlotTemplateWrapper extends Wrapper {
15
- node: NodeWithLets;
8
+ node: SlotTemplate;
16
9
  fragment: FragmentWrapper;
17
10
  block: Block;
18
11
  parent: InlineComponentWrapper;
19
- constructor(renderer: Renderer, block: Block, parent: Wrapper, node: NodeWithLets, strip_whitespace: boolean, next_sibling: Wrapper);
12
+ constructor(renderer: Renderer, block: Block, parent: Wrapper, node: SlotTemplate, strip_whitespace: boolean, next_sibling: Wrapper);
20
13
  render(): void;
14
+ render_get_context(): void;
21
15
  }
22
- export {};
@@ -1,7 +1,5 @@
1
1
  import Renderer, { RenderOptions } from '../Renderer';
2
2
  import SlotTemplate from '../../nodes/SlotTemplate';
3
- import InlineComponent from '../../nodes/InlineComponent';
4
- import Element from '../../nodes/Element';
5
- export default function (node: SlotTemplate | Element | InlineComponent, renderer: Renderer, options: RenderOptions & {
3
+ export default function (node: SlotTemplate, renderer: Renderer, options: RenderOptions & {
6
4
  slot_scopes: Map<any, any>;
7
5
  }): void;
@@ -0,0 +1,7 @@
1
+ import { TemplateLiteral } from 'estree';
2
+ import { MustacheTag, Text } from '../../interfaces';
3
+ /**
4
+ * Transforms a list of Text and MustacheTags into a TemplateLiteral expression.
5
+ * Start/End positions on the elements of the expression are not set.
6
+ */
7
+ export declare function nodes_to_template_literal(value: Array<Text | MustacheTag>): TemplateLiteral;
@@ -1,4 +1,4 @@
1
- import { Node, Program } from 'estree';
1
+ import { AssignmentExpression, Node, Program } from 'estree';
2
2
  import { SourceMap } from 'magic-string';
3
3
  interface BaseNode {
4
4
  start: number;
@@ -16,7 +16,7 @@ export interface Text extends BaseNode {
16
16
  data: string;
17
17
  }
18
18
  export interface MustacheTag extends BaseNode {
19
- type: 'MustacheTag';
19
+ type: 'MustacheTag' | 'RawMustacheTag';
20
20
  expression: Node;
21
21
  }
22
22
  export interface Comment extends BaseNode {
@@ -24,8 +24,20 @@ export interface Comment extends BaseNode {
24
24
  data: string;
25
25
  ignores: string[];
26
26
  }
27
- export declare type DirectiveType = 'Action' | 'Animation' | 'Binding' | 'Class' | 'EventHandler' | 'Let' | 'Ref' | 'Transition';
27
+ export interface ConstTag extends BaseNode {
28
+ type: 'ConstTag';
29
+ expression: AssignmentExpression;
30
+ }
31
+ interface DebugTag extends BaseNode {
32
+ type: 'DebugTag';
33
+ identifiers: Node[];
34
+ }
35
+ export declare type DirectiveType = 'Action' | 'Animation' | 'Binding' | 'Class' | 'StyleDirective' | 'EventHandler' | 'Let' | 'Ref' | 'Transition';
28
36
  interface BaseDirective extends BaseNode {
37
+ type: DirectiveType;
38
+ name: string;
39
+ }
40
+ interface BaseExpressionDirective extends BaseDirective {
29
41
  type: DirectiveType;
30
42
  expression: null | Node;
31
43
  name: string;
@@ -45,13 +57,13 @@ export interface SpreadAttribute extends BaseNode {
45
57
  type: 'Spread';
46
58
  expression: Node;
47
59
  }
48
- export interface Transition extends BaseDirective {
60
+ export interface Transition extends BaseExpressionDirective {
49
61
  type: 'Transition';
50
62
  intro: boolean;
51
63
  outro: boolean;
52
64
  }
53
- export declare type Directive = BaseDirective | Transition;
54
- export declare type TemplateNode = Text | MustacheTag | BaseNode | Element | Attribute | SpreadAttribute | Directive | Transition | Comment;
65
+ export declare type Directive = BaseDirective | BaseExpressionDirective | Transition;
66
+ export declare type TemplateNode = Text | ConstTag | DebugTag | MustacheTag | BaseNode | Element | Attribute | SpreadAttribute | Directive | Transition | Comment;
55
67
  export interface Parser {
56
68
  readonly template: string;
57
69
  readonly filename?: string;
@@ -1,4 +1,4 @@
1
- export declare const foreign = "https://svelte.dev/docs#svelte_options";
1
+ export declare const foreign = "https://svelte.dev/docs#template-syntax-svelte-options";
2
2
  export declare const html = "http://www.w3.org/1999/xhtml";
3
3
  export declare const mathml = "http://www.w3.org/1998/Math/MathML";
4
4
  export declare const svg = "http://www.w3.org/2000/svg";
@@ -9,7 +9,7 @@ declare type NodeEx = Node & {
9
9
  export declare function append(target: Node, node: Node): void;
10
10
  export declare function append_styles(target: Node, style_sheet_id: string, styles: string): void;
11
11
  export declare function get_root_for_style(node: Node): ShadowRoot | Document;
12
- export declare function append_empty_stylesheet(node: Node): HTMLStyleElement;
12
+ export declare function append_empty_stylesheet(node: Node): CSSStyleSheet;
13
13
  export declare function append_hydration(target: NodeEx, node: NodeEx): void;
14
14
  export declare function insert(target: Node, node: Node, anchor?: Node): void;
15
15
  export declare function insert_hydration(target: NodeEx, node: NodeEx, anchor?: NodeEx): void;
@@ -1,5 +1,6 @@
1
1
  export declare const invalid_attribute_name_character: RegExp;
2
- export declare function spread(args: any, classes_to_add: any): string;
2
+ export declare function spread(args: any, attrs_to_add: any): string;
3
+ export declare function merge_ssr_styles(style_attribute: any, style_directive: any): {};
3
4
  export declare const escaped: {
4
5
  '"': string;
5
6
  "'": string;
@@ -32,3 +33,4 @@ export declare function create_ssr_component(fn: any): {
32
33
  };
33
34
  export declare function add_attribute(name: any, value: any, boolean: any): string;
34
35
  export declare function add_classes(classes: any): string;
36
+ export declare function add_styles(style_object: any): string;