svelte 3.46.3 → 3.46.6

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.js CHANGED
@@ -5820,6 +5820,7 @@
5820
5820
  'Event',
5821
5821
  'EventSource',
5822
5822
  'fetch',
5823
+ 'FormData',
5823
5824
  'global',
5824
5825
  'globalThis',
5825
5826
  'history',
@@ -6710,6 +6711,19 @@
6710
6711
  return nodes;
6711
6712
  }
6712
6713
 
6714
+ /**
6715
+ * Does `array.push` for all `items`. Needed because `array.push(...items)` throws
6716
+ * "Maximum call stack size exceeded" when `items` is too big of an array.
6717
+ *
6718
+ * @param {any[]} array
6719
+ * @param {any[]} items
6720
+ */
6721
+ function push_array(array, items) {
6722
+ for (let i = 0; i < items.length; i++) {
6723
+ array.push(items[i]);
6724
+ }
6725
+ }
6726
+
6713
6727
  // heavily based on https://github.com/davidbonnet/astring
6714
6728
 
6715
6729
  /** @typedef {import('estree').ArrowFunctionExpression} ArrowFunctionExpression */
@@ -6957,7 +6971,8 @@
6957
6971
 
6958
6972
  const joined = [...nodes[0]];
6959
6973
  for (let i = 1; i < nodes.length; i += 1) {
6960
- joined.push(separator, ...nodes[i]);
6974
+ joined.push(separator);
6975
+ push_array(joined, nodes[i]);
6961
6976
  }
6962
6977
  return joined;
6963
6978
  };
@@ -7035,9 +7050,7 @@
7035
7050
  );
7036
7051
  }
7037
7052
 
7038
- chunks.push(
7039
- ...body[i]
7040
- );
7053
+ push_array(chunks, body[i]);
7041
7054
 
7042
7055
  needed_padding = needs_padding;
7043
7056
  }
@@ -7064,13 +7077,7 @@
7064
7077
 
7065
7078
  const separator = c(multiple_lines ? `,\n${state.indent}\t` : ', ');
7066
7079
 
7067
- if (multiple_lines) {
7068
- chunks.push(...join(declarators, separator));
7069
- } else {
7070
- chunks.push(
7071
- ...join(declarators, separator)
7072
- );
7073
- }
7080
+ push_array(chunks, join(declarators, separator));
7074
7081
 
7075
7082
  return chunks;
7076
7083
  };
@@ -7125,10 +7132,8 @@
7125
7132
  ];
7126
7133
 
7127
7134
  if (node.alternate) {
7128
- chunks.push(
7129
- c(' else '),
7130
- ...handle(node.alternate, state)
7131
- );
7135
+ chunks.push(c(' else '));
7136
+ push_array(chunks, handle(node.alternate, state));
7132
7137
  }
7133
7138
 
7134
7139
  return chunks;
@@ -7172,20 +7177,16 @@
7172
7177
 
7173
7178
  node.cases.forEach(block => {
7174
7179
  if (block.test) {
7175
- chunks.push(
7176
- c(`\n${state.indent}\tcase `),
7177
- ...handle(block.test, { ...state, indent: `${state.indent}\t` }),
7178
- c(':')
7179
- );
7180
+ chunks.push(c(`\n${state.indent}\tcase `));
7181
+ push_array(chunks, handle(block.test, { ...state, indent: `${state.indent}\t` }));
7182
+ chunks.push(c(':'));
7180
7183
  } else {
7181
7184
  chunks.push(c(`\n${state.indent}\tdefault:`));
7182
7185
  }
7183
7186
 
7184
7187
  block.consequent.forEach(statement => {
7185
- chunks.push(
7186
- c(`\n${state.indent}\t\t`),
7187
- ...handle(statement, { ...state, indent: `${state.indent}\t\t` })
7188
- );
7188
+ chunks.push(c(`\n${state.indent}\t\t`));
7189
+ push_array(chunks, handle(statement, { ...state, indent: `${state.indent}\t\t` }));
7189
7190
  });
7190
7191
  });
7191
7192
 
@@ -7223,20 +7224,19 @@
7223
7224
 
7224
7225
  if (node.handler) {
7225
7226
  if (node.handler.param) {
7226
- chunks.push(
7227
- c(' catch('),
7228
- ...handle(node.handler.param, state),
7229
- c(') ')
7230
- );
7227
+ chunks.push(c(' catch('));
7228
+ push_array(chunks, handle(node.handler.param, state));
7229
+ chunks.push(c(') '));
7231
7230
  } else {
7232
7231
  chunks.push(c(' catch '));
7233
7232
  }
7234
7233
 
7235
- chunks.push(...handle(node.handler.body, state));
7234
+ push_array(chunks, handle(node.handler.body, state));
7236
7235
  }
7237
7236
 
7238
7237
  if (node.finalizer) {
7239
- chunks.push(c(' finally '), ...handle(node.finalizer, state));
7238
+ chunks.push(c(' finally '));
7239
+ push_array(chunks, handle(node.finalizer, state));
7240
7240
  }
7241
7241
 
7242
7242
  return chunks;
@@ -7266,21 +7266,19 @@
7266
7266
 
7267
7267
  if (node.init) {
7268
7268
  if (node.init.type === 'VariableDeclaration') {
7269
- chunks.push(...handle_var_declaration(node.init, state));
7269
+ push_array(chunks, handle_var_declaration(node.init, state));
7270
7270
  } else {
7271
- chunks.push(...handle(node.init, state));
7271
+ push_array(chunks, handle(node.init, state));
7272
7272
  }
7273
7273
  }
7274
7274
 
7275
7275
  chunks.push(c('; '));
7276
- if (node.test) chunks.push(...handle(node.test, state));
7276
+ if (node.test) push_array(chunks, handle(node.test, state));
7277
7277
  chunks.push(c('; '));
7278
- if (node.update) chunks.push(...handle(node.update, state));
7278
+ if (node.update) push_array(chunks, handle(node.update, state));
7279
7279
 
7280
- chunks.push(
7281
- c(') '),
7282
- ...handle(node.body, state)
7283
- );
7280
+ chunks.push(c(') '));
7281
+ push_array(chunks, handle(node.body, state));
7284
7282
 
7285
7283
  return chunks;
7286
7284
  }),
@@ -7291,17 +7289,15 @@
7291
7289
  ];
7292
7290
 
7293
7291
  if (node.left.type === 'VariableDeclaration') {
7294
- chunks.push(...handle_var_declaration(node.left, state));
7292
+ push_array(chunks, handle_var_declaration(node.left, state));
7295
7293
  } else {
7296
- chunks.push(...handle(node.left, state));
7294
+ push_array(chunks, handle(node.left, state));
7297
7295
  }
7298
7296
 
7299
- chunks.push(
7300
- c(node.type === 'ForInStatement' ? ` in ` : ` of `),
7301
- ...handle(node.right, state),
7302
- c(') '),
7303
- ...handle(node.body, state)
7304
- );
7297
+ chunks.push(c(node.type === 'ForInStatement' ? ` in ` : ` of `));
7298
+ push_array(chunks, handle(node.right, state));
7299
+ chunks.push(c(') '));
7300
+ push_array(chunks, handle(node.body, state));
7305
7301
 
7306
7302
  return chunks;
7307
7303
  }),
@@ -7315,7 +7311,7 @@
7315
7311
 
7316
7312
  if (node.async) chunks.push(c('async '));
7317
7313
  chunks.push(c(node.generator ? 'function* ' : 'function '));
7318
- if (node.id) chunks.push(...handle(node.id, state));
7314
+ if (node.id) push_array(chunks, handle(node.id, state));
7319
7315
  chunks.push(c('('));
7320
7316
 
7321
7317
  const params = node.params.map(p => handle(p, {
@@ -7331,21 +7327,15 @@
7331
7327
  const separator = c(multiple_lines ? `,\n${state.indent}` : ', ');
7332
7328
 
7333
7329
  if (multiple_lines) {
7334
- chunks.push(
7335
- c(`\n${state.indent}\t`),
7336
- ...join(params, separator),
7337
- c(`\n${state.indent}`)
7338
- );
7330
+ chunks.push(c(`\n${state.indent}\t`));
7331
+ push_array(chunks, join(params, separator));
7332
+ chunks.push(c(`\n${state.indent}`));
7339
7333
  } else {
7340
- chunks.push(
7341
- ...join(params, separator)
7342
- );
7334
+ push_array(chunks, join(params, separator));
7343
7335
  }
7344
7336
 
7345
- chunks.push(
7346
- c(') '),
7347
- ...handle(node.body, state)
7348
- );
7337
+ chunks.push(c(') '));
7338
+ push_array(chunks, handle(node.body, state));
7349
7339
 
7350
7340
  return chunks;
7351
7341
  }),
@@ -7369,17 +7359,18 @@
7369
7359
  ClassDeclaration(node, state) {
7370
7360
  const chunks = [c('class ')];
7371
7361
 
7372
- if (node.id) chunks.push(...handle(node.id, state), c(' '));
7362
+ if (node.id) {
7363
+ push_array(chunks, handle(node.id, state));
7364
+ chunks.push(c(' '));
7365
+ }
7373
7366
 
7374
7367
  if (node.superClass) {
7375
- chunks.push(
7376
- c('extends '),
7377
- ...handle(node.superClass, state),
7378
- c(' ')
7379
- );
7368
+ chunks.push(c('extends '));
7369
+ push_array(chunks, handle(node.superClass, state));
7370
+ chunks.push(c(' '));
7380
7371
  }
7381
7372
 
7382
- chunks.push(...handle(node.body, state));
7373
+ push_array(chunks, handle(node.body, state));
7383
7374
 
7384
7375
  return chunks;
7385
7376
  },
@@ -7427,27 +7418,21 @@
7427
7418
  const width = get_length(chunks) + specifiers.map(get_length).reduce(sum, 0) + (2 * specifiers.length) + 6 + get_length(source);
7428
7419
 
7429
7420
  if (width > 80) {
7430
- chunks.push(
7431
- c(`{\n\t`),
7432
- ...join(specifiers, c(',\n\t')),
7433
- c('\n}')
7434
- );
7421
+ chunks.push(c(`{\n\t`));
7422
+ push_array(chunks, join(specifiers, c(',\n\t')));
7423
+ chunks.push(c('\n}'));
7435
7424
  } else {
7436
- chunks.push(
7437
- c(`{ `),
7438
- ...join(specifiers, c(', ')),
7439
- c(' }')
7440
- );
7425
+ chunks.push(c(`{ `));
7426
+ push_array(chunks, join(specifiers, c(', ')));
7427
+ chunks.push(c(' }'));
7441
7428
  }
7442
7429
  }
7443
7430
 
7444
7431
  chunks.push(c(' from '));
7445
7432
  }
7446
7433
 
7447
- chunks.push(
7448
- ...source,
7449
- c(';')
7450
- );
7434
+ push_array(chunks, source);
7435
+ chunks.push(c(';'));
7451
7436
 
7452
7437
  return chunks;
7453
7438
  },
@@ -7473,7 +7458,7 @@
7473
7458
  const chunks = [c('export ')];
7474
7459
 
7475
7460
  if (node.declaration) {
7476
- chunks.push(...handle(node.declaration, state));
7461
+ push_array(chunks, handle(node.declaration, state));
7477
7462
  } else {
7478
7463
  const specifiers = node.specifiers.map((/** @type {ExportSpecifier} */ specifier) => {
7479
7464
  const name = handle(specifier.local, state)[0];
@@ -7489,24 +7474,18 @@
7489
7474
  const width = 7 + specifiers.map(get_length).reduce(sum, 0) + 2 * specifiers.length;
7490
7475
 
7491
7476
  if (width > 80) {
7492
- chunks.push(
7493
- c('{\n\t'),
7494
- ...join(specifiers, c(',\n\t')),
7495
- c('\n}')
7496
- );
7477
+ chunks.push(c('{\n\t'));
7478
+ push_array(chunks, join(specifiers, c(',\n\t')));
7479
+ chunks.push(c('\n}'));
7497
7480
  } else {
7498
- chunks.push(
7499
- c('{ '),
7500
- ...join(specifiers, c(', ')),
7501
- c(' }')
7502
- );
7481
+ chunks.push(c('{ '));
7482
+ push_array(chunks, join(specifiers, c(', ')));
7483
+ chunks.push(c(' }'));
7503
7484
  }
7504
7485
 
7505
7486
  if (node.source) {
7506
- chunks.push(
7507
- c(' from '),
7508
- ...handle(node.source, state)
7509
- );
7487
+ chunks.push(c(' from '));
7488
+ push_array(chunks, handle(node.source, state));
7510
7489
  }
7511
7490
  }
7512
7491
 
@@ -7544,27 +7523,23 @@
7544
7523
  }
7545
7524
 
7546
7525
  if (node.computed) {
7547
- chunks.push(
7548
- c('['),
7549
- ...handle(node.key, state),
7550
- c(']')
7551
- );
7526
+ chunks.push(c('['));
7527
+ push_array(chunks, handle(node.key, state));
7528
+ chunks.push(c(']'));
7552
7529
  } else {
7553
- chunks.push(...handle(node.key, state));
7530
+ push_array(chunks, handle(node.key, state));
7554
7531
  }
7555
7532
 
7556
7533
  chunks.push(c('('));
7557
7534
 
7558
7535
  const { params } = node.value;
7559
7536
  for (let i = 0; i < params.length; i += 1) {
7560
- chunks.push(...handle(params[i], state));
7537
+ push_array(chunks, handle(params[i], state));
7561
7538
  if (i < params.length - 1) chunks.push(c(', '));
7562
7539
  }
7563
7540
 
7564
- chunks.push(
7565
- c(') '),
7566
- ...handle(node.value.body, state)
7567
- );
7541
+ chunks.push(c(') '));
7542
+ push_array(chunks, handle(node.value.body, state));
7568
7543
 
7569
7544
  return chunks;
7570
7545
  },
@@ -7575,18 +7550,16 @@
7575
7550
  if (node.async) chunks.push(c('async '));
7576
7551
 
7577
7552
  if (node.params.length === 1 && node.params[0].type === 'Identifier') {
7578
- chunks.push(...handle(node.params[0], state));
7553
+ push_array(chunks, handle(node.params[0], state));
7579
7554
  } else {
7580
7555
  const params = node.params.map(param => handle(param, {
7581
7556
  ...state,
7582
7557
  indent: state.indent + '\t'
7583
7558
  }));
7584
7559
 
7585
- chunks.push(
7586
- c('('),
7587
- ...join(params, c(', ')),
7588
- c(')')
7589
- );
7560
+ chunks.push(c('('));
7561
+ push_array(chunks, join(params, c(', ')));
7562
+ chunks.push(c(')'));
7590
7563
  }
7591
7564
 
7592
7565
  chunks.push(c(' => '));
@@ -7595,13 +7568,11 @@
7595
7568
  node.body.type === 'ObjectExpression' ||
7596
7569
  (node.body.type === 'AssignmentExpression' && node.body.left.type === 'ObjectPattern')
7597
7570
  ) {
7598
- chunks.push(
7599
- c('('),
7600
- ...handle(node.body, state),
7601
- c(')')
7602
- );
7571
+ chunks.push(c('('));
7572
+ push_array(chunks, handle(node.body, state));
7573
+ chunks.push(c(')'));
7603
7574
  } else {
7604
- chunks.push(...handle(node.body, state));
7575
+ push_array(chunks, handle(node.body, state));
7605
7576
  }
7606
7577
 
7607
7578
  return chunks;
@@ -7649,10 +7620,10 @@
7649
7620
  for (let i = 0; i < expressions.length; i++) {
7650
7621
  chunks.push(
7651
7622
  c(quasis[i].value.raw),
7652
- c('${'),
7653
- ...handle(expressions[i], state),
7654
- c('}')
7623
+ c('${')
7655
7624
  );
7625
+ push_array(chunks, handle(expressions[i], state));
7626
+ chunks.push(c('}'));
7656
7627
  }
7657
7628
 
7658
7629
  chunks.push(
@@ -7696,14 +7667,13 @@
7696
7667
  );
7697
7668
 
7698
7669
  if (multiple_lines) {
7699
- chunks.push(
7700
- c(`\n${state.indent}\t`),
7701
- ...join(elements, c(`,\n${state.indent}\t`)),
7702
- c(`\n${state.indent}`),
7703
- ...sparse_commas
7704
- );
7670
+ chunks.push(c(`\n${state.indent}\t`));
7671
+ push_array(chunks, join(elements, c(`,\n${state.indent}\t`)));
7672
+ chunks.push(c(`\n${state.indent}`));
7673
+ push_array(chunks, sparse_commas);
7705
7674
  } else {
7706
- chunks.push(...join(elements, c(', ')), ...sparse_commas);
7675
+ push_array(chunks, join(elements, c(', ')));
7676
+ push_array(chunks, sparse_commas);
7707
7677
  }
7708
7678
 
7709
7679
  chunks.push(c(']'));
@@ -7723,7 +7693,7 @@
7723
7693
  const separator = c(', ');
7724
7694
 
7725
7695
  node.properties.forEach((p, i) => {
7726
- chunks.push(...handle(p, {
7696
+ push_array(chunks, handle(p, {
7727
7697
  ...state,
7728
7698
  indent: state.indent + '\t'
7729
7699
  }));
@@ -7811,13 +7781,11 @@
7811
7781
  chunks.push(c('*'));
7812
7782
  }
7813
7783
 
7814
- chunks.push(
7815
- ...(node.computed ? [c('['), ...key, c(']')] : key),
7816
- c('('),
7817
- ...join(node.value.params.map((/** @type {Pattern} */ param) => handle(param, state)), c(', ')),
7818
- c(') '),
7819
- ...handle(node.value.body, state)
7820
- );
7784
+ push_array(chunks, node.computed ? [c('['), ...key, c(']')] : key);
7785
+ chunks.push(c('('));
7786
+ push_array(chunks, join(node.value.params.map((/** @type {Pattern} */ param) => handle(param, state)), c(', ')));
7787
+ chunks.push(c(') '));
7788
+ push_array(chunks, handle(node.value.body, state));
7821
7789
 
7822
7790
  return chunks;
7823
7791
  }
@@ -7842,7 +7810,7 @@
7842
7810
  const chunks = [c('{ ')];
7843
7811
 
7844
7812
  for (let i = 0; i < node.properties.length; i += 1) {
7845
- chunks.push(...handle(node.properties[i], state));
7813
+ push_array(chunks, handle(node.properties[i], state));
7846
7814
  if (i < node.properties.length - 1) chunks.push(c(', '));
7847
7815
  }
7848
7816
 
@@ -7872,13 +7840,11 @@
7872
7840
  EXPRESSIONS_PRECEDENCE[node.argument.type] <
7873
7841
  EXPRESSIONS_PRECEDENCE.UnaryExpression
7874
7842
  ) {
7875
- chunks.push(
7876
- c('('),
7877
- ...handle(node.argument, state),
7878
- c(')')
7879
- );
7843
+ chunks.push(c('('));
7844
+ push_array(chunks, handle(node.argument, state));
7845
+ chunks.push(c(')'));
7880
7846
  } else {
7881
- chunks.push(...handle(node.argument, state));
7847
+ push_array(chunks, handle(node.argument, state));
7882
7848
  }
7883
7849
 
7884
7850
  return chunks;
@@ -7899,6 +7865,9 @@
7899
7865
  },
7900
7866
 
7901
7867
  BinaryExpression(node, state) {
7868
+ /**
7869
+ * @type any[]
7870
+ */
7902
7871
  const chunks = [];
7903
7872
 
7904
7873
  // TODO
@@ -7909,44 +7878,41 @@
7909
7878
  // }
7910
7879
 
7911
7880
  if (needs_parens(node.left, node, false)) {
7912
- chunks.push(
7913
- c('('),
7914
- ...handle(node.left, state),
7915
- c(')')
7916
- );
7881
+ chunks.push(c('('));
7882
+ push_array(chunks, handle(node.left, state));
7883
+ chunks.push(c(')'));
7917
7884
  } else {
7918
- chunks.push(...handle(node.left, state));
7885
+ push_array(chunks, handle(node.left, state));
7919
7886
  }
7920
7887
 
7921
7888
  chunks.push(c(` ${node.operator} `));
7922
7889
 
7923
7890
  if (needs_parens(node.right, node, true)) {
7924
- chunks.push(
7925
- c('('),
7926
- ...handle(node.right, state),
7927
- c(')')
7928
- );
7891
+ chunks.push(c('('));
7892
+ push_array(chunks, handle(node.right, state));
7893
+ chunks.push(c(')'));
7929
7894
  } else {
7930
- chunks.push(...handle(node.right, state));
7895
+ push_array(chunks, handle(node.right, state));
7931
7896
  }
7932
7897
 
7933
7898
  return chunks;
7934
7899
  },
7935
7900
 
7936
7901
  ConditionalExpression(node, state) {
7902
+ /**
7903
+ * @type any[]
7904
+ */
7937
7905
  const chunks = [];
7938
7906
 
7939
7907
  if (
7940
7908
  EXPRESSIONS_PRECEDENCE[node.test.type] >
7941
7909
  EXPRESSIONS_PRECEDENCE.ConditionalExpression
7942
7910
  ) {
7943
- chunks.push(...handle(node.test, state));
7911
+ push_array(chunks, handle(node.test, state));
7944
7912
  } else {
7945
- chunks.push(
7946
- c('('),
7947
- ...handle(node.test, state),
7948
- c(')')
7949
- );
7913
+ chunks.push(c('('));
7914
+ push_array(chunks, handle(node.test, state));
7915
+ chunks.push(c(')'));
7950
7916
  }
7951
7917
 
7952
7918
  const child_state = { ...state, indent: state.indent + '\t' };
@@ -7960,19 +7926,15 @@
7960
7926
  );
7961
7927
 
7962
7928
  if (multiple_lines) {
7963
- chunks.push(
7964
- c(`\n${state.indent}? `),
7965
- ...consequent,
7966
- c(`\n${state.indent}: `),
7967
- ...alternate
7968
- );
7929
+ chunks.push(c(`\n${state.indent}? `));
7930
+ push_array(chunks, consequent);
7931
+ chunks.push(c(`\n${state.indent}: `));
7932
+ push_array(chunks, alternate);
7969
7933
  } else {
7970
- chunks.push(
7971
- c(` ? `),
7972
- ...consequent,
7973
- c(` : `),
7974
- ...alternate
7975
- );
7934
+ chunks.push(c(` ? `));
7935
+ push_array(chunks, consequent);
7936
+ chunks.push(c(` : `));
7937
+ push_array(chunks, alternate);
7976
7938
  }
7977
7939
 
7978
7940
  return chunks;
@@ -7985,13 +7947,11 @@
7985
7947
  EXPRESSIONS_PRECEDENCE[node.callee.type] <
7986
7948
  EXPRESSIONS_PRECEDENCE.CallExpression || has_call_expression(node.callee)
7987
7949
  ) {
7988
- chunks.push(
7989
- c('('),
7990
- ...handle(node.callee, state),
7991
- c(')')
7992
- );
7950
+ chunks.push(c('('));
7951
+ push_array(chunks, handle(node.callee, state));
7952
+ chunks.push(c(')'));
7993
7953
  } else {
7994
- chunks.push(...handle(node.callee, state));
7954
+ push_array(chunks, handle(node.callee, state));
7995
7955
  }
7996
7956
 
7997
7957
  // TODO this is copied from CallExpression — DRY it out
@@ -8004,11 +7964,9 @@
8004
7964
  ? c(',\n' + state.indent)
8005
7965
  : c(', ');
8006
7966
 
8007
- chunks.push(
8008
- c('('),
8009
- ...join(args, separator),
8010
- c(')')
8011
- );
7967
+ chunks.push(c('('));
7968
+ push_array(chunks, join(args, separator));
7969
+ chunks.push(c(')'));
8012
7970
 
8013
7971
  return chunks;
8014
7972
  },
@@ -8018,19 +7976,20 @@
8018
7976
  },
8019
7977
 
8020
7978
  CallExpression(/** @type {CallExpression} */ node, state) {
7979
+ /**
7980
+ * @type any[]
7981
+ */
8021
7982
  const chunks = [];
8022
7983
 
8023
7984
  if (
8024
7985
  EXPRESSIONS_PRECEDENCE[node.callee.type] <
8025
7986
  EXPRESSIONS_PRECEDENCE.CallExpression
8026
7987
  ) {
8027
- chunks.push(
8028
- c('('),
8029
- ...handle(node.callee, state),
8030
- c(')')
8031
- );
7988
+ chunks.push(c('('));
7989
+ push_array(chunks, handle(node.callee, state));
7990
+ chunks.push(c(')'));
8032
7991
  } else {
8033
- chunks.push(...handle(node.callee, state));
7992
+ push_array(chunks, handle(node.callee, state));
8034
7993
  }
8035
7994
 
8036
7995
  if (/** @type {SimpleCallExpression} */ (node).optional) {
@@ -8048,49 +8007,42 @@
8048
8007
  indent: `${state.indent}\t`
8049
8008
  }));
8050
8009
 
8051
- chunks.push(
8052
- c(`(\n${state.indent}\t`),
8053
- ...join(args, c(`,\n${state.indent}\t`)),
8054
- c(`\n${state.indent})`)
8055
- );
8010
+ chunks.push(c(`(\n${state.indent}\t`));
8011
+ push_array(chunks, join(args, c(`,\n${state.indent}\t`)));
8012
+ chunks.push(c(`\n${state.indent})`));
8056
8013
  } else {
8057
- chunks.push(
8058
- c('('),
8059
- ...join(args, c(', ')),
8060
- c(')')
8061
- );
8014
+ chunks.push(c('('));
8015
+ push_array(chunks, join(args, c(', ')));
8016
+ chunks.push(c(')'));
8062
8017
  }
8063
8018
 
8064
8019
  return chunks;
8065
8020
  },
8066
8021
 
8067
8022
  MemberExpression(node, state) {
8023
+ /**
8024
+ * @type any[]
8025
+ */
8068
8026
  const chunks = [];
8069
8027
 
8070
8028
  if (EXPRESSIONS_PRECEDENCE[node.object.type] < EXPRESSIONS_PRECEDENCE.MemberExpression) {
8071
- chunks.push(
8072
- c('('),
8073
- ...handle(node.object, state),
8074
- c(')')
8075
- );
8029
+ chunks.push(c('('));
8030
+ push_array(chunks, handle(node.object, state));
8031
+ chunks.push(c(')'));
8076
8032
  } else {
8077
- chunks.push(...handle(node.object, state));
8033
+ push_array(chunks, handle(node.object, state));
8078
8034
  }
8079
8035
 
8080
8036
  if (node.computed) {
8081
8037
  if (node.optional) {
8082
8038
  chunks.push(c('?.'));
8083
8039
  }
8084
- chunks.push(
8085
- c('['),
8086
- ...handle(node.property, state),
8087
- c(']')
8088
- );
8040
+ chunks.push(c('['));
8041
+ push_array(chunks, handle(node.property, state));
8042
+ chunks.push(c(']'));
8089
8043
  } else {
8090
- chunks.push(
8091
- c(node.optional ? '?.' : '.'),
8092
- ...handle(node.property, state)
8093
- );
8044
+ chunks.push(c(node.optional ? '?.' : '.'));
8045
+ push_array(chunks, handle(node.property, state));
8094
8046
  }
8095
8047
 
8096
8048
  return chunks;
@@ -19119,7 +19071,11 @@
19119
19071
  cyclical_const_tags: (cycle) => ({
19120
19072
  code: 'cyclical-const-tags',
19121
19073
  message: `Cyclical dependency detected: ${cycle.join(' → ')}`
19122
- })
19074
+ }),
19075
+ invalid_component_style_directive: {
19076
+ code: 'invalid-component-style-directive',
19077
+ message: 'Style directives cannot be used on components'
19078
+ }
19123
19079
  };
19124
19080
 
19125
19081
  class Expression {
@@ -20143,6 +20099,21 @@
20143
20099
  }
20144
20100
  return parent_element.namespace || elements_without_text.has(parent_element.name);
20145
20101
  }
20102
+ keep_space() {
20103
+ if (this.component.component_options.preserveWhitespace)
20104
+ return true;
20105
+ return this.within_pre();
20106
+ }
20107
+ within_pre() {
20108
+ let node = this.parent;
20109
+ while (node) {
20110
+ if (node.type === 'Element' && node.name === 'pre') {
20111
+ return true;
20112
+ }
20113
+ node = node.parent;
20114
+ }
20115
+ return false;
20116
+ }
20146
20117
  }
20147
20118
 
20148
20119
  // The `foreign` namespace covers all DOM implementations that aren't HTML5.
@@ -20206,7 +20177,7 @@
20206
20177
  }
20207
20178
 
20208
20179
  const svg$1 = /^(?:altGlyph|altGlyphDef|altGlyphItem|animate|animateColor|animateMotion|animateTransform|circle|clipPath|color-profile|cursor|defs|desc|discard|ellipse|feBlend|feColorMatrix|feComponentTransfer|feComposite|feConvolveMatrix|feDiffuseLighting|feDisplacementMap|feDistantLight|feDropShadow|feFlood|feFuncA|feFuncB|feFuncG|feFuncR|feGaussianBlur|feImage|feMerge|feMergeNode|feMorphology|feOffset|fePointLight|feSpecularLighting|feSpotLight|feTile|feTurbulence|filter|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|foreignObject|g|glyph|glyphRef|hatch|hatchpath|hkern|image|line|linearGradient|marker|mask|mesh|meshgradient|meshpatch|meshrow|metadata|missing-glyph|mpath|path|pattern|polygon|polyline|radialGradient|rect|set|solidcolor|stop|svg|switch|symbol|text|textPath|tref|tspan|unknown|use|view|vkern)$/;
20209
- const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
20180
+ const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
20210
20181
  const aria_attribute_set = new Set(aria_attributes);
20211
20182
  const aria_roles = 'alert alertdialog application article banner blockquote button caption cell checkbox code columnheader combobox complementary contentinfo definition deletion dialog directory document emphasis feed figure form generic graphics-document graphics-object graphics-symbol grid gridcell group heading img link list listbox listitem log main marquee math meter menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option paragraph presentation progressbar radio radiogroup region row rowgroup rowheader scrollbar search searchbox separator slider spinbutton status strong subscript superscript switch tab table tablist tabpanel term textbox time timer toolbar tooltip tree treegrid treeitem'.split(' ');
20212
20183
  const aria_role_set = new Set(aria_roles);
@@ -20997,6 +20968,8 @@
20997
20968
  break;
20998
20969
  case 'Transition':
20999
20970
  return component.error(node, compiler_errors.invalid_transition);
20971
+ case 'StyleDirective':
20972
+ return component.error(node, compiler_errors.invalid_component_style_directive);
21000
20973
  default:
21001
20974
  throw new Error(`Not implemented: ${node.type}`);
21002
20975
  }
@@ -21278,6 +21251,19 @@
21278
21251
  }
21279
21252
  }
21280
21253
 
21254
+ /**
21255
+ * Pushes all `items` into `array` using `push`, therefore mutating the array.
21256
+ * We do this for memory and perf reasons, and because `array.push(...items)` would
21257
+ * run into a "max call stack size exceeded" error with too many items (~65k).
21258
+ * @param array
21259
+ * @param items
21260
+ */
21261
+ function push_array$1(array, items) {
21262
+ for (let i = 0; i < items.length; i++) {
21263
+ array.push(items[i]);
21264
+ }
21265
+ }
21266
+
21281
21267
  function get_constructor(type) {
21282
21268
  switch (type) {
21283
21269
  case 'AwaitBlock': return AwaitBlock;
@@ -21314,7 +21300,7 @@
21314
21300
  if (use_ignores)
21315
21301
  component.pop_ignores(), ignores = [];
21316
21302
  if (node.type === 'Comment' && node.ignores.length) {
21317
- ignores.push(...node.ignores);
21303
+ push_array$1(ignores, node.ignores);
21318
21304
  }
21319
21305
  if (last)
21320
21306
  last.next = node;
@@ -22260,14 +22246,7 @@
22260
22246
  return false;
22261
22247
  if (/[\S\u00A0]/.test(this.data))
22262
22248
  return false;
22263
- let node = this.parent && this.parent.node;
22264
- while (node) {
22265
- if (node.type === 'Element' && node.name === 'pre') {
22266
- return false;
22267
- }
22268
- node = node.parent;
22269
- }
22270
- return true;
22249
+ return !this.node.within_pre();
22271
22250
  }
22272
22251
  render(block, parent_node, parent_nodes) {
22273
22252
  if (this.skip)
@@ -23462,6 +23441,7 @@
23462
23441
  node.classes.length > 0 ||
23463
23442
  node.intro || node.outro ||
23464
23443
  node.handlers.length > 0 ||
23444
+ node.styles.length > 0 ||
23465
23445
  this.node.name === 'option' ||
23466
23446
  renderer.options.dev) {
23467
23447
  this.parent.cannot_use_innerhtml(); // need to use add_location
@@ -23760,7 +23740,7 @@
23760
23740
  this.attributes.forEach((attribute) => {
23761
23741
  if (attribute.node.name === 'class') {
23762
23742
  const dependencies = attribute.node.get_dependencies();
23763
- this.class_dependencies.push(...dependencies);
23743
+ push_array$1(this.class_dependencies, dependencies);
23764
23744
  }
23765
23745
  });
23766
23746
  if (this.node.attributes.some(attr => attr.is_spread)) {
@@ -24234,7 +24214,7 @@
24234
24214
  block.has_intro_method = has_intros;
24235
24215
  block.has_outro_method = has_outros;
24236
24216
  });
24237
- renderer.blocks.push(...blocks);
24217
+ push_array$1(renderer.blocks, blocks);
24238
24218
  }
24239
24219
  render(block, parent_node, parent_nodes) {
24240
24220
  const name = this.var;
@@ -25727,7 +25707,7 @@
25727
25707
  // *unless* there is no whitespace between this node and its next sibling
25728
25708
  if (this.nodes.length === 0) {
25729
25709
  const should_trim = (next_sibling ? (next_sibling.node.type === 'Text' && /^\s/.test(next_sibling.node.data) && trimmable_at(child, next_sibling)) : !child.has_ancestor('EachBlock'));
25730
- if (should_trim) {
25710
+ if (should_trim && !child.keep_space()) {
25731
25711
  data = trim_end(data);
25732
25712
  if (!data)
25733
25713
  continue;
@@ -25755,7 +25735,7 @@
25755
25735
  }
25756
25736
  if (strip_whitespace) {
25757
25737
  const first = this.nodes[0];
25758
- if (first && first.node.type === 'Text') {
25738
+ if (first && first.node.type === 'Text' && !first.node.keep_space()) {
25759
25739
  first.data = trim_start(first.data);
25760
25740
  if (!first.data) {
25761
25741
  first.var = null;
@@ -26814,13 +26794,6 @@
26814
26794
  }
26815
26795
  return [new_table, idx_map, val_changed, idx_changed];
26816
26796
  }
26817
- function pushArray(_this, other) {
26818
- // We use push to mutate in place for memory and perf reasons
26819
- // We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore)
26820
- for (let i = 0; i < other.length; i++) {
26821
- _this.push(other[i]);
26822
- }
26823
- }
26824
26797
  class MappedCode {
26825
26798
  constructor(string = '', map = null) {
26826
26799
  this.string = string;
@@ -26908,9 +26881,9 @@
26908
26881
  }
26909
26882
  }
26910
26883
  // combine last line + first line
26911
- pushArray(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
26884
+ push_array$1(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
26912
26885
  // append other lines
26913
- pushArray(m1.mappings, m2.mappings);
26886
+ push_array$1(m1.mappings, m2.mappings);
26914
26887
  return this;
26915
26888
  }
26916
26889
  static from_processed(string, map) {
@@ -27101,7 +27074,7 @@
27101
27074
  // fix order
27102
27075
  // TODO the deconflicted names of blocks are reversed... should set them here
27103
27076
  const blocks = renderer.blocks.slice().reverse();
27104
- body.push(...blocks.map(block => {
27077
+ push_array$1(body, blocks.map(block => {
27105
27078
  // TODO this is a horrible mess — renderer.blocks
27106
27079
  // contains a mixture of Blocks and Nodes
27107
27080
  if (block.render)
@@ -27522,7 +27495,7 @@
27522
27495
  }`
27523
27496
  });
27524
27497
  }
27525
- declaration.body.body.push(...accessors);
27498
+ push_array$1(declaration.body.body, accessors);
27526
27499
  body.push(declaration);
27527
27500
  if (component.tag != null) {
27528
27501
  body.push(b `
@@ -27556,7 +27529,7 @@
27556
27529
  }
27557
27530
  }
27558
27531
  `[0];
27559
- declaration.body.body.push(...accessors);
27532
+ push_array$1(declaration.body.body, accessors);
27560
27533
  body.push(declaration);
27561
27534
  }
27562
27535
  return { js: flatten(body), css };
@@ -27707,7 +27680,7 @@
27707
27680
  /^\s/.test(next.data) &&
27708
27681
  trimmable_at$1(child, next)
27709
27682
  : !child.has_ancestor('EachBlock');
27710
- if (should_trim) {
27683
+ if (should_trim && !child.keep_space()) {
27711
27684
  data = trim_end(data);
27712
27685
  if (!data)
27713
27686
  continue;
@@ -27727,7 +27700,7 @@
27727
27700
  }
27728
27701
  }
27729
27702
  const first = nodes[0];
27730
- if (first && first.type === 'Text') {
27703
+ if (first && first.type === 'Text' && !first.keep_space()) {
27731
27704
  first.data = trim_start(first.data);
27732
27705
  if (!first.data) {
27733
27706
  first.var = null;
@@ -30210,6 +30183,10 @@
30210
30183
  const first = this.node.value.children
30211
30184
  ? this.node.value.children[0]
30212
30185
  : this.node.value;
30186
+ // Don't minify whitespace in custom properties, since some browsers (Chromium < 99)
30187
+ // treat --foo: ; and --foo:; differently
30188
+ if (first.type === 'Raw' && /^\s+$/.test(first.value))
30189
+ return;
30213
30190
  let start = first.start;
30214
30191
  while (/\s/.test(code.original[start]))
30215
30192
  start += 1;
@@ -30376,7 +30353,7 @@
30376
30353
  const at_rule_declarations = node.block.children
30377
30354
  .filter(node => node.type === 'Declaration')
30378
30355
  .map(node => new Declaration$1(node));
30379
- atrule.declarations.push(...at_rule_declarations);
30356
+ push_array$1(atrule.declarations, at_rule_declarations);
30380
30357
  }
30381
30358
  current_atrule = atrule;
30382
30359
  }
@@ -30700,7 +30677,7 @@
30700
30677
  if (result) {
30701
30678
  const { compile_options, name } = this;
30702
30679
  const { format = 'esm' } = compile_options;
30703
- const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.3'}`;
30680
+ const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.6'}`;
30704
30681
  const program = { type: 'Program', body: result.js };
30705
30682
  walk(program, {
30706
30683
  enter: (node, parent, key) => {
@@ -30911,7 +30888,7 @@
30911
30888
  extract_names(declarator.id).forEach(name => {
30912
30889
  const variable = this.var_lookup.get(name);
30913
30890
  variable.export_name = name;
30914
- if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
30891
+ if (!module_script && variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
30915
30892
  this.warn(declarator, compiler_warnings.unused_export_let(this.name.name, name));
30916
30893
  }
30917
30894
  });
@@ -30929,7 +30906,7 @@
30929
30906
  const variable = this.var_lookup.get(specifier.local.name);
30930
30907
  if (variable) {
30931
30908
  variable.export_name = specifier.exported.name;
30932
- if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
30909
+ if (!module_script && variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
30933
30910
  this.warn(specifier, compiler_warnings.unused_export_let(this.name.name, specifier.exported.name));
30934
30911
  }
30935
30912
  }
@@ -32193,7 +32170,7 @@
32193
32170
  return result.to_processed();
32194
32171
  }
32195
32172
 
32196
- const VERSION = '3.46.3';
32173
+ const VERSION = '3.46.6';
32197
32174
 
32198
32175
  exports.VERSION = VERSION;
32199
32176
  exports.compile = compile;