svelte 3.44.0 → 3.45.0

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/compiler.mjs CHANGED
@@ -6492,7 +6492,7 @@ const handlers = {
6492
6492
  }),
6493
6493
 
6494
6494
  EmptyStatement(node, state) {
6495
- return [];
6495
+ return [c(';')];
6496
6496
  },
6497
6497
 
6498
6498
  ParenthesizedExpression(node, state) {
@@ -6598,10 +6598,11 @@ const handlers = {
6598
6598
 
6599
6599
  ReturnStatement(node, state) {
6600
6600
  if (node.argument) {
6601
+ const contains_comment = node.argument.leadingComments && node.argument.leadingComments.some((/** @type import('../utils/comments.js').CommentWithLocation */ comment) => comment.has_trailing_newline);
6601
6602
  return [
6602
- c('return '),
6603
+ c(contains_comment ? 'return (' : 'return '),
6603
6604
  ...handle(node.argument, state),
6604
- c(';')
6605
+ c(contains_comment ? ');' : ';')
6605
6606
  ];
6606
6607
  } else {
6607
6608
  return [c('return;')];
@@ -6992,7 +6993,10 @@ const handlers = {
6992
6993
 
6993
6994
  chunks.push(c(' => '));
6994
6995
 
6995
- if (node.body.type === 'ObjectExpression') {
6996
+ if (
6997
+ node.body.type === 'ObjectExpression' ||
6998
+ (node.body.type === 'AssignmentExpression' && node.body.left.type === 'ObjectPattern')
6999
+ ) {
6996
7000
  chunks.push(
6997
7001
  c('('),
6998
7002
  ...handle(node.body, state),
@@ -7955,7 +7959,7 @@ const inject = (raw, node, values, comments) => {
7955
7959
 
7956
7960
  const { enter, leave } = get_comment_handlers(comments, raw);
7957
7961
 
7958
- walk(node, {
7962
+ return walk(node, {
7959
7963
  enter,
7960
7964
 
7961
7965
  /** @param {any} node */
@@ -8057,7 +8061,6 @@ const inject = (raw, node, values, comments) => {
8057
8061
  node.update = node.update === EMPTY ? null : node.update;
8058
8062
  }
8059
8063
 
8060
- // @ts-ignore
8061
8064
  leave(node);
8062
8065
  }
8063
8066
  });
@@ -8076,11 +8079,11 @@ function b(strings, ...values) {
8076
8079
  const comments = [];
8077
8080
 
8078
8081
  try {
8079
- const ast = /** @type {any} */ (
8082
+ let ast = /** @type {any} */ (
8080
8083
  parse(str, acorn_opts(comments, str))
8081
8084
  );
8082
8085
 
8083
- inject(str, ast, values, comments);
8086
+ ast = inject(str, ast, values, comments);
8084
8087
 
8085
8088
  return ast.body;
8086
8089
  } catch (err) {
@@ -8101,7 +8104,7 @@ function x(strings, ...values) {
8101
8104
  const comments = [];
8102
8105
 
8103
8106
  try {
8104
- const expression =
8107
+ let expression =
8105
8108
  /** @type {Expression & { start: Number, end: number }} */ (
8106
8109
  parseExpressionAt(str, 0, acorn_opts(comments, str))
8107
8110
  );
@@ -8110,7 +8113,9 @@ function x(strings, ...values) {
8110
8113
  throw new Error(`Unexpected token '${match[0]}'`);
8111
8114
  }
8112
8115
 
8113
- inject(str, expression, values, comments);
8116
+ expression = /** @type {Expression & { start: Number, end: number }} */ (
8117
+ inject(str, expression, values, comments)
8118
+ );
8114
8119
 
8115
8120
  return expression;
8116
8121
  } catch (err) {
@@ -8131,11 +8136,11 @@ function p(strings, ...values) {
8131
8136
  const comments = [];
8132
8137
 
8133
8138
  try {
8134
- const expression = /** @type {any} */ (
8139
+ let expression = /** @type {any} */ (
8135
8140
  parseExpressionAt(str, 0, acorn_opts(comments, str))
8136
8141
  );
8137
8142
 
8138
- inject(str, expression, values, comments);
8143
+ expression = inject(str, expression, values, comments);
8139
8144
 
8140
8145
  return expression.properties[0];
8141
8146
  } catch (err) {
@@ -8204,6 +8209,8 @@ const parse_expression_at = (source, index) => parseExpressionAt$1(source, index
8204
8209
  });
8205
8210
 
8206
8211
  const whitespace = /[ \t\r\n]/;
8212
+ const start_whitespace = /^[ \t\r\n]*/;
8213
+ const end_whitespace = /[ \t\r\n]*$/;
8207
8214
  const dimensions = /^(?:offset|client)(?:Width|Height)$/;
8208
8215
 
8209
8216
  function list(items, conjunction = 'or') {
@@ -16390,6 +16397,7 @@ const globals = new Set([
16390
16397
  'undefined',
16391
16398
  'URIError',
16392
16399
  'URL',
16400
+ 'URLSearchParams',
16393
16401
  'window'
16394
16402
  ]);
16395
16403
  const reserved = new Set([
@@ -17218,16 +17226,10 @@ function read_context(parser) {
17218
17226
  }
17219
17227
 
17220
17228
  function trim_start(str) {
17221
- let i = 0;
17222
- while (whitespace.test(str[i]))
17223
- i += 1;
17224
- return str.slice(i);
17229
+ return str.replace(start_whitespace, '');
17225
17230
  }
17226
17231
  function trim_end(str) {
17227
- let i = str.length;
17228
- while (whitespace.test(str[i - 1]))
17229
- i -= 1;
17230
- return str.slice(0, i);
17232
+ return str.replace(end_whitespace, '');
17231
17233
  }
17232
17234
 
17233
17235
  function to_string(node) {
@@ -19218,7 +19220,7 @@ function fix_attribute_casing(name) {
19218
19220
 
19219
19221
  // The `foreign` namespace covers all DOM implementations that aren't HTML5.
19220
19222
  // It opts out of HTML5-specific a11y checks and case-insensitive attribute names.
19221
- const foreign = 'https://svelte.dev/docs#svelte_options';
19223
+ const foreign = 'https://svelte.dev/docs#template-syntax-svelte-options';
19222
19224
  const html = 'http://www.w3.org/1999/xhtml';
19223
19225
  const mathml = 'http://www.w3.org/1998/Math/MathML';
19224
19226
  const svg = 'http://www.w3.org/2000/svg';
@@ -19253,6 +19255,20 @@ function handle_select_value_binding(attr, dependencies) {
19253
19255
  }
19254
19256
  }
19255
19257
 
19258
+ const non_textlike_input_types = new Set([
19259
+ 'button',
19260
+ 'checkbox',
19261
+ 'color',
19262
+ 'date',
19263
+ 'datetime-local',
19264
+ 'file',
19265
+ 'hidden',
19266
+ 'image',
19267
+ 'radio',
19268
+ 'range',
19269
+ 'reset',
19270
+ 'submit'
19271
+ ]);
19256
19272
  class BaseAttributeWrapper {
19257
19273
  constructor(parent, block, node) {
19258
19274
  this.node = node;
@@ -19399,7 +19415,7 @@ class AttributeWrapper extends BaseAttributeWrapper {
19399
19415
  }
19400
19416
  if (this.is_input_value) {
19401
19417
  const type = element.node.get_static_attribute_value('type');
19402
- if (type === null || type === '' || type === 'text' || type === 'email' || type === 'password') {
19418
+ if (type !== true && !non_textlike_input_types.has(type)) {
19403
19419
  condition = x `${condition} && ${element.var}.${property_name} !== ${should_cache ? last : value}`;
19404
19420
  }
19405
19421
  }
@@ -19836,6 +19852,28 @@ class BindingWrapper {
19836
19852
  });
19837
19853
  return dependencies;
19838
19854
  }
19855
+ get_update_dependencies() {
19856
+ const object = this.object;
19857
+ const dependencies = new Set();
19858
+ if (this.node.expression.template_scope.names.has(object)) {
19859
+ this.node.expression.template_scope.dependencies_for_name
19860
+ .get(object)
19861
+ .forEach((name) => dependencies.add(name));
19862
+ }
19863
+ else {
19864
+ dependencies.add(object);
19865
+ }
19866
+ const result = new Set(dependencies);
19867
+ dependencies.forEach((dependency) => {
19868
+ const indirect_dependencies = this.parent.renderer.component.indirect_dependencies.get(dependency);
19869
+ if (indirect_dependencies) {
19870
+ indirect_dependencies.forEach(indirect_dependency => {
19871
+ result.add(indirect_dependency);
19872
+ });
19873
+ }
19874
+ });
19875
+ return result;
19876
+ }
19839
19877
  is_readonly_media_attribute() {
19840
19878
  return this.node.is_readonly_media_attribute();
19841
19879
  }
@@ -20127,7 +20165,7 @@ function bind_this(component, block, binding, variable) {
20127
20165
  block.renderer.add_to_context(fn.name);
20128
20166
  const callee = block.renderer.reference(fn.name);
20129
20167
  const { contextual_dependencies, mutation } = binding.handler;
20130
- const dependencies = binding.get_dependencies();
20168
+ const dependencies = binding.get_update_dependencies();
20131
20169
  const body = b `
20132
20170
  ${mutation}
20133
20171
  ${Array.from(dependencies)
@@ -21439,7 +21477,7 @@ class ElementWrapper extends Wrapper {
21439
21477
  const contextual_dependencies = new Set();
21440
21478
  binding_group.bindings.forEach(binding => {
21441
21479
  // TODO this is a mess
21442
- add_to_set(dependencies, binding.get_dependencies());
21480
+ add_to_set(dependencies, binding.get_update_dependencies());
21443
21481
  add_to_set(contextual_dependencies, binding.handler.contextual_dependencies);
21444
21482
  binding.render(block, lock);
21445
21483
  });
@@ -22044,12 +22082,13 @@ class IfBlockWrapper extends Wrapper {
22044
22082
  if (this.needs_update) {
22045
22083
  block.chunks.init.push(b `
22046
22084
  function ${select_block_type}(#ctx, #dirty) {
22047
- ${this.branches.map(({ dependencies, condition, snippet, block }) => condition
22085
+ ${this.branches.map(({ dependencies, condition, snippet }) => {
22086
+ return b `${snippet && dependencies.length > 0 ? b `if (${block.renderer.dirty(dependencies)}) ${condition} = null;` : null}`;
22087
+ })}
22088
+ ${this.branches.map(({ condition, snippet, block }) => condition
22048
22089
  ? b `
22049
- ${snippet && (dependencies.length > 0
22050
- ? b `if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
22051
- : b `if (${condition} == null) ${condition} = !!${snippet}`)}
22052
- if (${condition}) return ${block.name};`
22090
+ ${snippet && b `if (${condition} == null) ${condition} = !!${snippet}`}
22091
+ if (${condition}) return ${block.name};`
22053
22092
  : b `return ${block.name};`)}
22054
22093
  }
22055
22094
  `);
@@ -22147,11 +22186,12 @@ class IfBlockWrapper extends Wrapper {
22147
22186
  ${this.needs_update
22148
22187
  ? b `
22149
22188
  function ${select_block_type}(#ctx, #dirty) {
22150
- ${this.branches.map(({ dependencies, condition, snippet }, i) => condition
22189
+ ${this.branches.map(({ dependencies, condition, snippet }) => {
22190
+ return b `${snippet && dependencies.length > 0 ? b `if (${block.renderer.dirty(dependencies)}) ${condition} = null;` : null}`;
22191
+ })}
22192
+ ${this.branches.map(({ condition, snippet }, i) => condition
22151
22193
  ? b `
22152
- ${snippet && (dependencies.length > 0
22153
- ? b `if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
22154
- : b `if (${condition} == null) ${condition} = !!${snippet}`)}
22194
+ ${snippet && b `if (${condition} == null) ${condition} = !!${snippet}`}
22155
22195
  if (${condition}) return ${i};`
22156
22196
  : b `return ${i};`)}
22157
22197
  ${!has_else && b `return -1;`}
@@ -22625,6 +22665,10 @@ var compiler_warnings = {
22625
22665
  code: 'a11y-unknown-role',
22626
22666
  message: `A11y: Unknown role '${role}'` + (suggestion ? ` (did you mean '${suggestion}'?)` : '')
22627
22667
  }),
22668
+ a11y_no_redundant_roles: (role) => ({
22669
+ code: 'a11y-no-redundant-roles',
22670
+ message: `A11y: Redundant role '${role}'`
22671
+ }),
22628
22672
  a11y_accesskey: {
22629
22673
  code: 'a11y-accesskey',
22630
22674
  message: 'A11y: Avoid using accesskey'
@@ -25958,7 +26002,7 @@ class CatchBlock extends AbstractBlock {
25958
26002
  }
25959
26003
  }
25960
26004
 
25961
- function unpack_destructuring(contexts, node, modifier = node => node, default_modifier = node => node) {
26005
+ function unpack_destructuring({ contexts, node, modifier = (node) => node, default_modifier = (node) => node, scope, component }) {
25962
26006
  if (!node)
25963
26007
  return;
25964
26008
  if (node.type === 'Identifier') {
@@ -25978,14 +26022,36 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
25978
26022
  else if (node.type === 'ArrayPattern') {
25979
26023
  node.elements.forEach((element, i) => {
25980
26024
  if (element && element.type === 'RestElement') {
25981
- unpack_destructuring(contexts, element, node => x `${modifier(node)}.slice(${i})`, default_modifier);
26025
+ unpack_destructuring({
26026
+ contexts,
26027
+ node: element,
26028
+ modifier: (node) => x `${modifier(node)}.slice(${i})`,
26029
+ default_modifier,
26030
+ scope,
26031
+ component
26032
+ });
25982
26033
  }
25983
26034
  else if (element && element.type === 'AssignmentPattern') {
25984
26035
  const n = contexts.length;
25985
- unpack_destructuring(contexts, element.left, node => x `${modifier(node)}[${i}]`, (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, element.right, to_ctx)}`);
26036
+ mark_referenced(element.right, scope, component);
26037
+ unpack_destructuring({
26038
+ contexts,
26039
+ node: element.left,
26040
+ modifier: (node) => x `${modifier(node)}[${i}]`,
26041
+ default_modifier: (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, element.right, to_ctx)}`,
26042
+ scope,
26043
+ component
26044
+ });
25986
26045
  }
25987
26046
  else {
25988
- unpack_destructuring(contexts, element, node => x `${modifier(node)}[${i}]`, default_modifier);
26047
+ unpack_destructuring({
26048
+ contexts,
26049
+ node: element,
26050
+ modifier: (node) => x `${modifier(node)}[${i}]`,
26051
+ default_modifier,
26052
+ scope,
26053
+ component
26054
+ });
25989
26055
  }
25990
26056
  });
25991
26057
  }
@@ -25993,7 +26059,14 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
25993
26059
  const used_properties = [];
25994
26060
  node.properties.forEach((property) => {
25995
26061
  if (property.type === 'RestElement') {
25996
- unpack_destructuring(contexts, property.argument, node => x `@object_without_properties(${modifier(node)}, [${used_properties}])`, default_modifier);
26062
+ unpack_destructuring({
26063
+ contexts,
26064
+ node: property.argument,
26065
+ modifier: (node) => x `@object_without_properties(${modifier(node)}, [${used_properties}])`,
26066
+ default_modifier,
26067
+ scope,
26068
+ component
26069
+ });
25997
26070
  }
25998
26071
  else {
25999
26072
  const key = property.key;
@@ -26001,10 +26074,25 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
26001
26074
  used_properties.push(x `"${key.name}"`);
26002
26075
  if (value.type === 'AssignmentPattern') {
26003
26076
  const n = contexts.length;
26004
- unpack_destructuring(contexts, value.left, node => x `${modifier(node)}.${key.name}`, (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, value.right, to_ctx)}`);
26077
+ mark_referenced(value.right, scope, component);
26078
+ unpack_destructuring({
26079
+ contexts,
26080
+ node: value.left,
26081
+ modifier: (node) => x `${modifier(node)}.${key.name}`,
26082
+ default_modifier: (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, value.right, to_ctx)}`,
26083
+ scope,
26084
+ component
26085
+ });
26005
26086
  }
26006
26087
  else {
26007
- unpack_destructuring(contexts, value, node => x `${modifier(node)}.${key.name}`, default_modifier);
26088
+ unpack_destructuring({
26089
+ contexts,
26090
+ node: value,
26091
+ modifier: (node) => x `${modifier(node)}.${key.name}`,
26092
+ default_modifier,
26093
+ scope,
26094
+ component
26095
+ });
26008
26096
  }
26009
26097
  }
26010
26098
  });
@@ -26035,6 +26123,18 @@ function update_reference(contexts, n, expression, to_ctx) {
26035
26123
  });
26036
26124
  return expression;
26037
26125
  }
26126
+ function mark_referenced(node, scope, component) {
26127
+ walk(node, {
26128
+ enter(node, parent) {
26129
+ if (is_reference(node, parent)) {
26130
+ const { name } = flatten_reference(node);
26131
+ if (!scope.is_let(name) && !scope.names.has(name)) {
26132
+ component.add_reference(name);
26133
+ }
26134
+ }
26135
+ }
26136
+ });
26137
+ }
26038
26138
 
26039
26139
  class AwaitBlock$1 extends Node$1 {
26040
26140
  constructor(component, parent, scope, info) {
@@ -26044,11 +26144,11 @@ class AwaitBlock$1 extends Node$1 {
26044
26144
  this.catch_node = info.error;
26045
26145
  if (this.then_node) {
26046
26146
  this.then_contexts = [];
26047
- unpack_destructuring(this.then_contexts, info.value);
26147
+ unpack_destructuring({ contexts: this.then_contexts, node: info.value, scope, component });
26048
26148
  }
26049
26149
  if (this.catch_node) {
26050
26150
  this.catch_contexts = [];
26051
- unpack_destructuring(this.catch_contexts, info.error);
26151
+ unpack_destructuring({ contexts: this.catch_contexts, node: info.error, scope, component });
26052
26152
  }
26053
26153
  this.pending = new PendingBlock(component, this, scope, info.pending);
26054
26154
  this.then = new ThenBlock(component, this, scope, info.then);
@@ -26144,7 +26244,7 @@ class EachBlock$1 extends AbstractBlock {
26144
26244
  this.index = info.index;
26145
26245
  this.scope = scope.child();
26146
26246
  this.contexts = [];
26147
- unpack_destructuring(this.contexts, info.context);
26247
+ unpack_destructuring({ contexts: this.contexts, node: info.context, scope, component });
26148
26248
  this.contexts.forEach(context => {
26149
26249
  this.scope.add(context.key.name, this.expression.dependencies, this);
26150
26250
  });
@@ -26479,6 +26579,44 @@ const a11y_labelable = new Set([
26479
26579
  'select',
26480
26580
  'textarea'
26481
26581
  ]);
26582
+ const a11y_nested_implicit_semantics = new Map([
26583
+ ['header', 'banner'],
26584
+ ['footer', 'contentinfo']
26585
+ ]);
26586
+ const a11y_implicit_semantics = new Map([
26587
+ ['a', 'link'],
26588
+ ['aside', 'complementary'],
26589
+ ['body', 'document'],
26590
+ ['datalist', 'listbox'],
26591
+ ['dd', 'definition'],
26592
+ ['dfn', 'term'],
26593
+ ['details', 'group'],
26594
+ ['dt', 'term'],
26595
+ ['fieldset', 'group'],
26596
+ ['form', 'form'],
26597
+ ['h1', 'heading'],
26598
+ ['h2', 'heading'],
26599
+ ['h3', 'heading'],
26600
+ ['h4', 'heading'],
26601
+ ['h5', 'heading'],
26602
+ ['h6', 'heading'],
26603
+ ['hr', 'separator'],
26604
+ ['li', 'listitem'],
26605
+ ['menu', 'list'],
26606
+ ['nav', 'navigation'],
26607
+ ['ol', 'list'],
26608
+ ['optgroup', 'group'],
26609
+ ['output', 'status'],
26610
+ ['progress', 'progressbar'],
26611
+ ['section', 'region'],
26612
+ ['summary', 'button'],
26613
+ ['tbody', 'rowgroup'],
26614
+ ['textarea', 'textbox'],
26615
+ ['tfoot', 'rowgroup'],
26616
+ ['thead', 'rowgroup'],
26617
+ ['tr', 'row'],
26618
+ ['ul', 'list']
26619
+ ]);
26482
26620
  const invisible_elements = new Set(['meta', 'html', 'script', 'style']);
26483
26621
  const valid_modifiers = new Set([
26484
26622
  'preventDefault',
@@ -26502,6 +26640,21 @@ const react_attributes = new Map([
26502
26640
  ['htmlFor', 'for']
26503
26641
  ]);
26504
26642
  const attributes_to_compact_whitespace = ['class', 'style'];
26643
+ function is_parent(parent, elements) {
26644
+ let check = false;
26645
+ while (parent) {
26646
+ const parent_name = parent.name;
26647
+ if (elements.includes(parent_name)) {
26648
+ check = true;
26649
+ break;
26650
+ }
26651
+ if (parent.type === 'Element') {
26652
+ break;
26653
+ }
26654
+ parent = parent.parent;
26655
+ }
26656
+ return check;
26657
+ }
26505
26658
  function get_namespace(parent, element, explicit_namespace) {
26506
26659
  const parent_element = parent.find_nearest(/^Element/);
26507
26660
  if (!parent_element) {
@@ -26707,6 +26860,19 @@ class Element$1 extends Node$1 {
26707
26860
  const match = fuzzymatch(value, aria_roles);
26708
26861
  component.warn(attribute, compiler_warnings.a11y_unknown_role(value, match));
26709
26862
  }
26863
+ // no-redundant-roles
26864
+ const has_redundant_role = value === a11y_implicit_semantics.get(this.name);
26865
+ if (this.name === value || has_redundant_role) {
26866
+ component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value));
26867
+ }
26868
+ // Footers and headers are special cases, and should not have redundant roles unless they are the children of sections or articles.
26869
+ const is_parent_section_or_article = is_parent(this.parent, ['section', 'article']);
26870
+ if (!is_parent_section_or_article) {
26871
+ const has_nested_redundant_role = value === a11y_nested_implicit_semantics.get(this.name);
26872
+ if (has_nested_redundant_role) {
26873
+ component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value));
26874
+ }
26875
+ }
26710
26876
  }
26711
26877
  // no-access-key
26712
26878
  if (name === 'accesskey') {
@@ -30136,7 +30302,7 @@ class Component {
30136
30302
  if (result) {
30137
30303
  const { compile_options, name } = this;
30138
30304
  const { format = 'esm' } = compile_options;
30139
- const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.44.0'}`;
30305
+ const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.45.0'}`;
30140
30306
  const program = { type: 'Program', body: result.js };
30141
30307
  walk(program, {
30142
30308
  enter: (node, parent, key) => {
@@ -30560,11 +30726,12 @@ class Component {
30560
30726
  to_remove.unshift([parent, prop, index]);
30561
30727
  };
30562
30728
  let scope_updated = false;
30563
- let generator_count = 0;
30729
+ const current_function_stack = [];
30730
+ let current_function = null;
30564
30731
  walk(content, {
30565
30732
  enter(node, parent, prop, index) {
30566
- if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
30567
- generator_count++;
30733
+ if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
30734
+ current_function_stack.push(current_function = node);
30568
30735
  }
30569
30736
  if (map.has(node)) {
30570
30737
  scope = map.get(node);
@@ -30589,11 +30756,12 @@ class Component {
30589
30756
  component.warn_on_undefined_store_value_references(node, parent, prop, scope);
30590
30757
  },
30591
30758
  leave(node) {
30592
- if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') && node.generator === true) {
30593
- generator_count--;
30759
+ if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
30760
+ current_function_stack.pop();
30761
+ current_function = current_function_stack[current_function_stack.length - 1];
30594
30762
  }
30595
30763
  // do it on leave, to prevent infinite loop
30596
- if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && generator_count <= 0) {
30764
+ if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && (!current_function || (!current_function.generator && !current_function.async))) {
30597
30765
  const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
30598
30766
  if (to_replace_for_loop_protect) {
30599
30767
  this.replace(to_replace_for_loop_protect);
@@ -31583,10 +31751,10 @@ async function process_tag(tag_name, preprocessor, source) {
31583
31751
  const { string, map } = await replace_in_code(tag_regex, process_single_tag, source);
31584
31752
  return { string, map, dependencies };
31585
31753
  }
31586
- async function process_markup(filename, process, source) {
31754
+ async function process_markup(process, source) {
31587
31755
  const processed = await process({
31588
31756
  content: source.source,
31589
- filename
31757
+ filename: source.filename
31590
31758
  });
31591
31759
  if (processed) {
31592
31760
  return {
@@ -31605,7 +31773,6 @@ async function process_markup(filename, process, source) {
31605
31773
  }
31606
31774
  }
31607
31775
  async function preprocess(source, preprocessor, options) {
31608
- // @ts-ignore todo: doublecheck
31609
31776
  const filename = (options && options.filename) || preprocessor.filename; // legacy
31610
31777
  const preprocessors = preprocessor ? (Array.isArray(preprocessor) ? preprocessor : [preprocessor]) : [];
31611
31778
  const markup = preprocessors.map(p => p.markup).filter(Boolean);
@@ -31615,7 +31782,7 @@ async function preprocess(source, preprocessor, options) {
31615
31782
  // TODO keep track: what preprocessor generated what sourcemap?
31616
31783
  // to make debugging easier = detect low-resolution sourcemaps in fn combine_mappings
31617
31784
  for (const process of markup) {
31618
- result.update_source(await process_markup(filename, process, result));
31785
+ result.update_source(await process_markup(process, result));
31619
31786
  }
31620
31787
  for (const process of script) {
31621
31788
  result.update_source(await process_tag('script', process, result));
@@ -31626,7 +31793,7 @@ async function preprocess(source, preprocessor, options) {
31626
31793
  return result.to_processed();
31627
31794
  }
31628
31795
 
31629
- const VERSION = '3.44.0';
31796
+ const VERSION = '3.45.0';
31630
31797
 
31631
31798
  export { VERSION, compile, parse$3 as parse, preprocess, walk };
31632
31799
  //# sourceMappingURL=compiler.mjs.map