svelte 3.45.0 → 3.46.3

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 (30) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/compiler.js +20015 -19621
  3. package/compiler.js.map +1 -1
  4. package/compiler.mjs +19396 -19002
  5. package/compiler.mjs.map +1 -1
  6. package/internal/index.js +75 -20
  7. package/internal/index.mjs +74 -21
  8. package/package.json +1 -1
  9. package/types/compiler/compile/Component.d.ts +2 -2
  10. package/types/compiler/compile/nodes/CatchBlock.d.ts +2 -0
  11. package/types/compiler/compile/nodes/EachBlock.d.ts +2 -0
  12. package/types/compiler/compile/nodes/Element.d.ts +2 -0
  13. package/types/compiler/compile/nodes/SlotTemplate.d.ts +2 -0
  14. package/types/compiler/compile/nodes/Style.d.ts +12 -0
  15. package/types/compiler/compile/nodes/StyleDirective.d.ts +12 -0
  16. package/types/compiler/compile/nodes/ThenBlock.d.ts +2 -0
  17. package/types/compiler/compile/nodes/interfaces.d.ts +4 -2
  18. package/types/compiler/compile/nodes/shared/Expression.d.ts +1 -1
  19. package/types/compiler/compile/nodes/shared/TemplateScope.d.ts +3 -1
  20. package/types/compiler/compile/nodes/shared/map_children.d.ts +2 -1
  21. package/types/compiler/compile/render_dom/Renderer.d.ts +1 -1
  22. package/types/compiler/compile/render_dom/wrappers/AwaitBlock.d.ts +2 -1
  23. package/types/compiler/compile/render_dom/wrappers/Element/index.d.ts +1 -0
  24. package/types/compiler/compile/render_dom/wrappers/SlotTemplate.d.ts +4 -11
  25. package/types/compiler/compile/render_ssr/handlers/SlotTemplate.d.ts +1 -3
  26. package/types/compiler/compile/utils/nodes_to_template_literal.d.ts +7 -0
  27. package/types/compiler/interfaces.d.ts +18 -6
  28. package/types/runtime/animate/index.d.ts +1 -2
  29. package/types/runtime/internal/dom.d.ts +1 -1
  30. package/types/runtime/internal/ssr.d.ts +3 -1
package/internal/index.js CHANGED
@@ -333,7 +333,7 @@ function get_root_for_style(node) {
333
333
  function append_empty_stylesheet(node) {
334
334
  const style_element = element('style');
335
335
  append_stylesheet(get_root_for_style(node), style_element);
336
- return style_element;
336
+ return style_element.sheet;
337
337
  }
338
338
  function append_stylesheet(node, style) {
339
339
  append(node.head || node, style);
@@ -619,7 +619,7 @@ function claim_html_tag(nodes) {
619
619
  return new HtmlTagHydration();
620
620
  }
621
621
  init_claim_info(nodes);
622
- const html_tag_nodes = nodes.splice(start_index, end_index + 1);
622
+ const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);
623
623
  detach(html_tag_nodes[0]);
624
624
  detach(html_tag_nodes[html_tag_nodes.length - 1]);
625
625
  const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
@@ -646,7 +646,12 @@ function set_input_type(input, type) {
646
646
  }
647
647
  }
648
648
  function set_style(node, key, value, important) {
649
- node.style.setProperty(key, value, important ? 'important' : '');
649
+ if (value === null) {
650
+ node.style.removeProperty(key);
651
+ }
652
+ else {
653
+ node.style.setProperty(key, value, important ? 'important' : '');
654
+ }
650
655
  }
651
656
  function select_option(select, value) {
652
657
  for (let i = 0; i < select.options.length; i += 1) {
@@ -803,7 +808,9 @@ function get_custom_elements_slots(element) {
803
808
  return result;
804
809
  }
805
810
 
806
- const active_docs = new Set();
811
+ // we need to store the information for multiple documents because a Svelte application could also contain iframes
812
+ // https://github.com/sveltejs/svelte/issues/3624
813
+ const managed_styles = new Map();
807
814
  let active = 0;
808
815
  // https://github.com/darkskyapp/string-hash/blob/master/index.js
809
816
  function hash(str) {
@@ -813,6 +820,11 @@ function hash(str) {
813
820
  hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
814
821
  return hash >>> 0;
815
822
  }
823
+ function create_style_information(doc, node) {
824
+ const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
825
+ managed_styles.set(doc, info);
826
+ return info;
827
+ }
816
828
  function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
817
829
  const step = 16.666 / duration;
818
830
  let keyframes = '{\n';
@@ -823,11 +835,9 @@ function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
823
835
  const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
824
836
  const name = `__svelte_${hash(rule)}_${uid}`;
825
837
  const doc = get_root_for_style(node);
826
- active_docs.add(doc);
827
- const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet(node).sheet);
828
- const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});
829
- if (!current_rules[name]) {
830
- current_rules[name] = true;
838
+ const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
839
+ if (!rules[name]) {
840
+ rules[name] = true;
831
841
  stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
832
842
  }
833
843
  const animation = node.style.animation || '';
@@ -853,14 +863,14 @@ function clear_rules() {
853
863
  exports.raf(() => {
854
864
  if (active)
855
865
  return;
856
- active_docs.forEach(doc => {
857
- const stylesheet = doc.__svelte_stylesheet;
866
+ managed_styles.forEach(info => {
867
+ const { stylesheet } = info;
858
868
  let i = stylesheet.cssRules.length;
859
869
  while (i--)
860
870
  stylesheet.deleteRule(i);
861
- doc.__svelte_rules = {};
871
+ info.rules = {};
862
872
  });
863
- active_docs.clear();
873
+ managed_styles.clear();
864
874
  });
865
875
  }
866
876
 
@@ -1615,14 +1625,26 @@ const boolean_attributes = new Set([
1615
1625
  const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1616
1626
  // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1617
1627
  // https://infra.spec.whatwg.org/#noncharacter
1618
- function spread(args, classes_to_add) {
1628
+ function spread(args, attrs_to_add) {
1619
1629
  const attributes = Object.assign({}, ...args);
1620
- if (classes_to_add) {
1621
- if (attributes.class == null) {
1622
- attributes.class = classes_to_add;
1630
+ if (attrs_to_add) {
1631
+ const classes_to_add = attrs_to_add.classes;
1632
+ const styles_to_add = attrs_to_add.styles;
1633
+ if (classes_to_add) {
1634
+ if (attributes.class == null) {
1635
+ attributes.class = classes_to_add;
1636
+ }
1637
+ else {
1638
+ attributes.class += ' ' + classes_to_add;
1639
+ }
1623
1640
  }
1624
- else {
1625
- attributes.class += ' ' + classes_to_add;
1641
+ if (styles_to_add) {
1642
+ if (attributes.style == null) {
1643
+ attributes.style = style_object_to_string(styles_to_add);
1644
+ }
1645
+ else {
1646
+ attributes.style = style_object_to_string(merge_ssr_styles(attributes.style, styles_to_add));
1647
+ }
1626
1648
  }
1627
1649
  }
1628
1650
  let str = '';
@@ -1642,6 +1664,27 @@ function spread(args, classes_to_add) {
1642
1664
  });
1643
1665
  return str;
1644
1666
  }
1667
+ function merge_ssr_styles(style_attribute, style_directive) {
1668
+ const style_object = {};
1669
+ for (const individual_style of style_attribute.split(';')) {
1670
+ const colon_index = individual_style.indexOf(':');
1671
+ const name = individual_style.slice(0, colon_index).trim();
1672
+ const value = individual_style.slice(colon_index + 1).trim();
1673
+ if (!name)
1674
+ continue;
1675
+ style_object[name] = value;
1676
+ }
1677
+ for (const name in style_directive) {
1678
+ const value = style_directive[name];
1679
+ if (value) {
1680
+ style_object[name] = value;
1681
+ }
1682
+ else {
1683
+ delete style_object[name];
1684
+ }
1685
+ }
1686
+ return style_object;
1687
+ }
1645
1688
  const escaped = {
1646
1689
  '"': '&quot;',
1647
1690
  "'": '&#39;',
@@ -1729,6 +1772,16 @@ function add_attribute(name, value, boolean) {
1729
1772
  function add_classes(classes) {
1730
1773
  return classes ? ` class="${classes}"` : '';
1731
1774
  }
1775
+ function style_object_to_string(style_object) {
1776
+ return Object.keys(style_object)
1777
+ .filter(key => style_object[key])
1778
+ .map(key => `${key}: ${style_object[key]};`)
1779
+ .join(' ');
1780
+ }
1781
+ function add_styles(style_object) {
1782
+ const styles = style_object_to_string(style_object);
1783
+ return styles ? ` style="${styles}"` : '';
1784
+ }
1732
1785
 
1733
1786
  function bind(component, name, callback) {
1734
1787
  const index = component.$$.props[name];
@@ -1916,7 +1969,7 @@ class SvelteComponent {
1916
1969
  }
1917
1970
 
1918
1971
  function dispatch_dev(type, detail) {
1919
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.45.0' }, detail), true));
1972
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.46.3' }, detail), true));
1920
1973
  }
1921
1974
  function append_dev(target, node) {
1922
1975
  dispatch_dev('SvelteDOMInsert', { target, node });
@@ -2080,6 +2133,7 @@ exports.add_flush_callback = add_flush_callback;
2080
2133
  exports.add_location = add_location;
2081
2134
  exports.add_render_callback = add_render_callback;
2082
2135
  exports.add_resize_listener = add_resize_listener;
2136
+ exports.add_styles = add_styles;
2083
2137
  exports.add_transform = add_transform;
2084
2138
  exports.afterUpdate = afterUpdate;
2085
2139
  exports.append = append;
@@ -2177,6 +2231,7 @@ exports.listen = listen;
2177
2231
  exports.listen_dev = listen_dev;
2178
2232
  exports.loop = loop;
2179
2233
  exports.loop_guard = loop_guard;
2234
+ exports.merge_ssr_styles = merge_ssr_styles;
2180
2235
  exports.missing_component = missing_component;
2181
2236
  exports.mount_component = mount_component;
2182
2237
  exports.noop = noop;
@@ -329,7 +329,7 @@ function get_root_for_style(node) {
329
329
  function append_empty_stylesheet(node) {
330
330
  const style_element = element('style');
331
331
  append_stylesheet(get_root_for_style(node), style_element);
332
- return style_element;
332
+ return style_element.sheet;
333
333
  }
334
334
  function append_stylesheet(node, style) {
335
335
  append(node.head || node, style);
@@ -615,7 +615,7 @@ function claim_html_tag(nodes) {
615
615
  return new HtmlTagHydration();
616
616
  }
617
617
  init_claim_info(nodes);
618
- const html_tag_nodes = nodes.splice(start_index, end_index + 1);
618
+ const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);
619
619
  detach(html_tag_nodes[0]);
620
620
  detach(html_tag_nodes[html_tag_nodes.length - 1]);
621
621
  const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
@@ -642,7 +642,12 @@ function set_input_type(input, type) {
642
642
  }
643
643
  }
644
644
  function set_style(node, key, value, important) {
645
- node.style.setProperty(key, value, important ? 'important' : '');
645
+ if (value === null) {
646
+ node.style.removeProperty(key);
647
+ }
648
+ else {
649
+ node.style.setProperty(key, value, important ? 'important' : '');
650
+ }
646
651
  }
647
652
  function select_option(select, value) {
648
653
  for (let i = 0; i < select.options.length; i += 1) {
@@ -799,7 +804,9 @@ function get_custom_elements_slots(element) {
799
804
  return result;
800
805
  }
801
806
 
802
- const active_docs = new Set();
807
+ // we need to store the information for multiple documents because a Svelte application could also contain iframes
808
+ // https://github.com/sveltejs/svelte/issues/3624
809
+ const managed_styles = new Map();
803
810
  let active = 0;
804
811
  // https://github.com/darkskyapp/string-hash/blob/master/index.js
805
812
  function hash(str) {
@@ -809,6 +816,11 @@ function hash(str) {
809
816
  hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
810
817
  return hash >>> 0;
811
818
  }
819
+ function create_style_information(doc, node) {
820
+ const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
821
+ managed_styles.set(doc, info);
822
+ return info;
823
+ }
812
824
  function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
813
825
  const step = 16.666 / duration;
814
826
  let keyframes = '{\n';
@@ -819,11 +831,9 @@ function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
819
831
  const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
820
832
  const name = `__svelte_${hash(rule)}_${uid}`;
821
833
  const doc = get_root_for_style(node);
822
- active_docs.add(doc);
823
- const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet(node).sheet);
824
- const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});
825
- if (!current_rules[name]) {
826
- current_rules[name] = true;
834
+ const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
835
+ if (!rules[name]) {
836
+ rules[name] = true;
827
837
  stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
828
838
  }
829
839
  const animation = node.style.animation || '';
@@ -849,14 +859,14 @@ function clear_rules() {
849
859
  raf(() => {
850
860
  if (active)
851
861
  return;
852
- active_docs.forEach(doc => {
853
- const stylesheet = doc.__svelte_stylesheet;
862
+ managed_styles.forEach(info => {
863
+ const { stylesheet } = info;
854
864
  let i = stylesheet.cssRules.length;
855
865
  while (i--)
856
866
  stylesheet.deleteRule(i);
857
- doc.__svelte_rules = {};
867
+ info.rules = {};
858
868
  });
859
- active_docs.clear();
869
+ managed_styles.clear();
860
870
  });
861
871
  }
862
872
 
@@ -1612,14 +1622,26 @@ const boolean_attributes = new Set([
1612
1622
  const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1613
1623
  // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1614
1624
  // https://infra.spec.whatwg.org/#noncharacter
1615
- function spread(args, classes_to_add) {
1625
+ function spread(args, attrs_to_add) {
1616
1626
  const attributes = Object.assign({}, ...args);
1617
- if (classes_to_add) {
1618
- if (attributes.class == null) {
1619
- attributes.class = classes_to_add;
1627
+ if (attrs_to_add) {
1628
+ const classes_to_add = attrs_to_add.classes;
1629
+ const styles_to_add = attrs_to_add.styles;
1630
+ if (classes_to_add) {
1631
+ if (attributes.class == null) {
1632
+ attributes.class = classes_to_add;
1633
+ }
1634
+ else {
1635
+ attributes.class += ' ' + classes_to_add;
1636
+ }
1620
1637
  }
1621
- else {
1622
- attributes.class += ' ' + classes_to_add;
1638
+ if (styles_to_add) {
1639
+ if (attributes.style == null) {
1640
+ attributes.style = style_object_to_string(styles_to_add);
1641
+ }
1642
+ else {
1643
+ attributes.style = style_object_to_string(merge_ssr_styles(attributes.style, styles_to_add));
1644
+ }
1623
1645
  }
1624
1646
  }
1625
1647
  let str = '';
@@ -1639,6 +1661,27 @@ function spread(args, classes_to_add) {
1639
1661
  });
1640
1662
  return str;
1641
1663
  }
1664
+ function merge_ssr_styles(style_attribute, style_directive) {
1665
+ const style_object = {};
1666
+ for (const individual_style of style_attribute.split(';')) {
1667
+ const colon_index = individual_style.indexOf(':');
1668
+ const name = individual_style.slice(0, colon_index).trim();
1669
+ const value = individual_style.slice(colon_index + 1).trim();
1670
+ if (!name)
1671
+ continue;
1672
+ style_object[name] = value;
1673
+ }
1674
+ for (const name in style_directive) {
1675
+ const value = style_directive[name];
1676
+ if (value) {
1677
+ style_object[name] = value;
1678
+ }
1679
+ else {
1680
+ delete style_object[name];
1681
+ }
1682
+ }
1683
+ return style_object;
1684
+ }
1642
1685
  const escaped = {
1643
1686
  '"': '&quot;',
1644
1687
  "'": '&#39;',
@@ -1726,6 +1769,16 @@ function add_attribute(name, value, boolean) {
1726
1769
  function add_classes(classes) {
1727
1770
  return classes ? ` class="${classes}"` : '';
1728
1771
  }
1772
+ function style_object_to_string(style_object) {
1773
+ return Object.keys(style_object)
1774
+ .filter(key => style_object[key])
1775
+ .map(key => `${key}: ${style_object[key]};`)
1776
+ .join(' ');
1777
+ }
1778
+ function add_styles(style_object) {
1779
+ const styles = style_object_to_string(style_object);
1780
+ return styles ? ` style="${styles}"` : '';
1781
+ }
1729
1782
 
1730
1783
  function bind(component, name, callback) {
1731
1784
  const index = component.$$.props[name];
@@ -1914,7 +1967,7 @@ class SvelteComponent {
1914
1967
  }
1915
1968
 
1916
1969
  function dispatch_dev(type, detail) {
1917
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.45.0' }, detail), true));
1970
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.46.3' }, detail), true));
1918
1971
  }
1919
1972
  function append_dev(target, node) {
1920
1973
  dispatch_dev('SvelteDOMInsert', { target, node });
@@ -2066,4 +2119,4 @@ function loop_guard(timeout) {
2066
2119
  };
2067
2120
  }
2068
2121
 
2069
- export { HtmlTag, HtmlTagHydration, SvelteComponent, SvelteComponentDev, SvelteComponentTyped, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_transform, afterUpdate, append, append_dev, append_empty_stylesheet, append_hydration, append_hydration_dev, append_styles, assign, attr, attr_dev, attribute_to_object, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_html_tag, claim_space, claim_svg_element, claim_text, clear_loops, component_subscribe, compute_rest_props, compute_slots, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, end_hydrating, escape, escape_attribute_value, escape_object, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getAllContexts, getContext, get_all_dirty_from_scope, get_binding_group_value, get_current_component, get_custom_elements_slots, get_root_for_style, get_slot_changes, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, hasContext, has_prop, identity, init, insert, insert_dev, insert_hydration, insert_hydration_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, src_url_equal, start_hydrating, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, trusted, update_await_block_branch, update_keyed_each, update_slot, update_slot_base, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };
2122
+ export { HtmlTag, HtmlTagHydration, SvelteComponent, SvelteComponentDev, SvelteComponentTyped, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_styles, add_transform, afterUpdate, append, append_dev, append_empty_stylesheet, append_hydration, append_hydration_dev, append_styles, assign, attr, attr_dev, attribute_to_object, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_html_tag, claim_space, claim_svg_element, claim_text, clear_loops, component_subscribe, compute_rest_props, compute_slots, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, end_hydrating, escape, escape_attribute_value, escape_object, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getAllContexts, getContext, get_all_dirty_from_scope, get_binding_group_value, get_current_component, get_custom_elements_slots, get_root_for_style, get_slot_changes, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, hasContext, has_prop, identity, init, insert, insert_dev, insert_hydration, insert_hydration_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, merge_ssr_styles, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, src_url_equal, start_hydrating, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, trusted, update_await_block_branch, update_keyed_each, update_slot, update_slot_base, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte",
3
- "version": "3.45.0",
3
+ "version": "3.46.3",
4
4
  "description": "Cybernetically enhanced web apps",
5
5
  "module": "index.mjs",
6
6
  "main": "index",
@@ -66,8 +66,8 @@ export default class Component {
66
66
  slots: Map<string, Slot>;
67
67
  slot_outlets: Set<string>;
68
68
  constructor(ast: Ast, source: string, name: string, compile_options: CompileOptions, stats: Stats, warnings: Warning[]);
69
- add_var(variable: Var, add_to_lookup?: boolean): void;
70
- add_reference(name: string): void;
69
+ add_var(node: Node, variable: Var, add_to_lookup?: boolean): void;
70
+ add_reference(node: Node, name: string): void;
71
71
  alias(name: string): Identifier;
72
72
  apply_stylesheet(element: Element): void;
73
73
  global(name: string): Identifier;
@@ -3,8 +3,10 @@ import AbstractBlock from './shared/AbstractBlock';
3
3
  import AwaitBlock from './AwaitBlock';
4
4
  import Component from '../Component';
5
5
  import { TemplateNode } from '../../interfaces';
6
+ import ConstTag from './ConstTag';
6
7
  export default class CatchBlock extends AbstractBlock {
7
8
  type: 'CatchBlock';
8
9
  scope: TemplateScope;
10
+ const_tags: ConstTag[];
9
11
  constructor(component: Component, parent: AwaitBlock, scope: TemplateScope, info: TemplateNode);
10
12
  }
@@ -2,6 +2,7 @@ import ElseBlock from './ElseBlock';
2
2
  import Expression from './shared/Expression';
3
3
  import TemplateScope from './shared/TemplateScope';
4
4
  import AbstractBlock from './shared/AbstractBlock';
5
+ import ConstTag from './ConstTag';
5
6
  import { Context } from './shared/Context';
6
7
  import { Node } from 'estree';
7
8
  import Component from '../Component';
@@ -16,6 +17,7 @@ export default class EachBlock extends AbstractBlock {
16
17
  key: Expression;
17
18
  scope: TemplateScope;
18
19
  contexts: Context[];
20
+ const_tags: ConstTag[];
19
21
  has_animation: boolean;
20
22
  has_binding: boolean;
21
23
  has_index_binding: boolean;
@@ -6,6 +6,7 @@ import Transition from './Transition';
6
6
  import Animation from './Animation';
7
7
  import Action from './Action';
8
8
  import Class from './Class';
9
+ import StyleDirective from './StyleDirective';
9
10
  import Let from './Let';
10
11
  import TemplateScope from './shared/TemplateScope';
11
12
  import { INode } from './interfaces';
@@ -18,6 +19,7 @@ export default class Element extends Node {
18
19
  actions: Action[];
19
20
  bindings: Binding[];
20
21
  classes: Class[];
22
+ styles: StyleDirective[];
21
23
  handlers: EventHandler[];
22
24
  lets: Let[];
23
25
  intro?: Transition;
@@ -4,11 +4,13 @@ import Node from './shared/Node';
4
4
  import Let from './Let';
5
5
  import Attribute from './Attribute';
6
6
  import { INode } from './interfaces';
7
+ import ConstTag from './ConstTag';
7
8
  export default class SlotTemplate extends Node {
8
9
  type: 'SlotTemplate';
9
10
  scope: TemplateScope;
10
11
  children: INode[];
11
12
  lets: Let[];
13
+ const_tags: ConstTag[];
12
14
  slot_attribute: Attribute;
13
15
  slot_template_name: string;
14
16
  constructor(component: Component, parent: INode, scope: TemplateScope, info: any);
@@ -0,0 +1,12 @@
1
+ import Node from './shared/Node';
2
+ import Expression from './shared/Expression';
3
+ import { TemplateNode } from '../../interfaces';
4
+ import TemplateScope from './shared/TemplateScope';
5
+ import Component from '../Component';
6
+ export default class Style extends Node {
7
+ type: 'Style';
8
+ name: string;
9
+ expression: Expression;
10
+ should_cache: boolean;
11
+ constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
12
+ }
@@ -0,0 +1,12 @@
1
+ import { TemplateNode } from '../../interfaces';
2
+ import Component from '../Component';
3
+ import Expression from './shared/Expression';
4
+ import Node from './shared/Node';
5
+ import TemplateScope from './shared/TemplateScope';
6
+ export default class StyleDirective extends Node {
7
+ type: 'StyleDirective';
8
+ name: string;
9
+ expression: Expression;
10
+ should_cache: boolean;
11
+ constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
12
+ }
@@ -3,8 +3,10 @@ import AbstractBlock from './shared/AbstractBlock';
3
3
  import AwaitBlock from './AwaitBlock';
4
4
  import Component from '../Component';
5
5
  import { TemplateNode } from '../../interfaces';
6
+ import ConstTag from './ConstTag';
6
7
  export default class ThenBlock extends AbstractBlock {
7
8
  type: 'ThenBlock';
8
9
  scope: TemplateScope;
10
+ const_tags: ConstTag[];
9
11
  constructor(component: Component, parent: AwaitBlock, scope: TemplateScope, info: TemplateNode);
10
12
  }
@@ -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;
@@ -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;
@@ -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;