svelte 3.46.3 → 3.46.4

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
@@ -5814,6 +5814,7 @@ const globals = new Set([
5814
5814
  'Event',
5815
5815
  'EventSource',
5816
5816
  'fetch',
5817
+ 'FormData',
5817
5818
  'global',
5818
5819
  'globalThis',
5819
5820
  'history',
@@ -6704,6 +6705,19 @@ function extract_identifiers(param, nodes = []) {
6704
6705
  return nodes;
6705
6706
  }
6706
6707
 
6708
+ /**
6709
+ * Does `array.push` for all `items`. Needed because `array.push(...items)` throws
6710
+ * "Maximum call stack size exceeded" when `items` is too big of an array.
6711
+ *
6712
+ * @param {any[]} array
6713
+ * @param {any[]} items
6714
+ */
6715
+ function push_array(array, items) {
6716
+ for (let i = 0; i < items.length; i++) {
6717
+ array.push(items[i]);
6718
+ }
6719
+ }
6720
+
6707
6721
  // heavily based on https://github.com/davidbonnet/astring
6708
6722
 
6709
6723
  /** @typedef {import('estree').ArrowFunctionExpression} ArrowFunctionExpression */
@@ -6951,7 +6965,8 @@ const join = (nodes, separator) => {
6951
6965
 
6952
6966
  const joined = [...nodes[0]];
6953
6967
  for (let i = 1; i < nodes.length; i += 1) {
6954
- joined.push(separator, ...nodes[i]);
6968
+ joined.push(separator);
6969
+ push_array(joined, nodes[i]);
6955
6970
  }
6956
6971
  return joined;
6957
6972
  };
@@ -7029,9 +7044,7 @@ const handle_body = (nodes, state) => {
7029
7044
  );
7030
7045
  }
7031
7046
 
7032
- chunks.push(
7033
- ...body[i]
7034
- );
7047
+ push_array(chunks, body[i]);
7035
7048
 
7036
7049
  needed_padding = needs_padding;
7037
7050
  }
@@ -7058,13 +7071,7 @@ const handle_var_declaration = (node, state) => {
7058
7071
 
7059
7072
  const separator = c(multiple_lines ? `,\n${state.indent}\t` : ', ');
7060
7073
 
7061
- if (multiple_lines) {
7062
- chunks.push(...join(declarators, separator));
7063
- } else {
7064
- chunks.push(
7065
- ...join(declarators, separator)
7066
- );
7067
- }
7074
+ push_array(chunks, join(declarators, separator));
7068
7075
 
7069
7076
  return chunks;
7070
7077
  };
@@ -7119,10 +7126,8 @@ const handlers = {
7119
7126
  ];
7120
7127
 
7121
7128
  if (node.alternate) {
7122
- chunks.push(
7123
- c(' else '),
7124
- ...handle(node.alternate, state)
7125
- );
7129
+ chunks.push(c(' else '));
7130
+ push_array(chunks, handle(node.alternate, state));
7126
7131
  }
7127
7132
 
7128
7133
  return chunks;
@@ -7166,20 +7171,16 @@ const handlers = {
7166
7171
 
7167
7172
  node.cases.forEach(block => {
7168
7173
  if (block.test) {
7169
- chunks.push(
7170
- c(`\n${state.indent}\tcase `),
7171
- ...handle(block.test, { ...state, indent: `${state.indent}\t` }),
7172
- c(':')
7173
- );
7174
+ chunks.push(c(`\n${state.indent}\tcase `));
7175
+ push_array(chunks, handle(block.test, { ...state, indent: `${state.indent}\t` }));
7176
+ chunks.push(c(':'));
7174
7177
  } else {
7175
7178
  chunks.push(c(`\n${state.indent}\tdefault:`));
7176
7179
  }
7177
7180
 
7178
7181
  block.consequent.forEach(statement => {
7179
- chunks.push(
7180
- c(`\n${state.indent}\t\t`),
7181
- ...handle(statement, { ...state, indent: `${state.indent}\t\t` })
7182
- );
7182
+ chunks.push(c(`\n${state.indent}\t\t`));
7183
+ push_array(chunks, handle(statement, { ...state, indent: `${state.indent}\t\t` }));
7183
7184
  });
7184
7185
  });
7185
7186
 
@@ -7217,20 +7218,19 @@ const handlers = {
7217
7218
 
7218
7219
  if (node.handler) {
7219
7220
  if (node.handler.param) {
7220
- chunks.push(
7221
- c(' catch('),
7222
- ...handle(node.handler.param, state),
7223
- c(') ')
7224
- );
7221
+ chunks.push(c(' catch('));
7222
+ push_array(chunks, handle(node.handler.param, state));
7223
+ chunks.push(c(') '));
7225
7224
  } else {
7226
7225
  chunks.push(c(' catch '));
7227
7226
  }
7228
7227
 
7229
- chunks.push(...handle(node.handler.body, state));
7228
+ push_array(chunks, handle(node.handler.body, state));
7230
7229
  }
7231
7230
 
7232
7231
  if (node.finalizer) {
7233
- chunks.push(c(' finally '), ...handle(node.finalizer, state));
7232
+ chunks.push(c(' finally '));
7233
+ push_array(chunks, handle(node.finalizer, state));
7234
7234
  }
7235
7235
 
7236
7236
  return chunks;
@@ -7260,21 +7260,19 @@ const handlers = {
7260
7260
 
7261
7261
  if (node.init) {
7262
7262
  if (node.init.type === 'VariableDeclaration') {
7263
- chunks.push(...handle_var_declaration(node.init, state));
7263
+ push_array(chunks, handle_var_declaration(node.init, state));
7264
7264
  } else {
7265
- chunks.push(...handle(node.init, state));
7265
+ push_array(chunks, handle(node.init, state));
7266
7266
  }
7267
7267
  }
7268
7268
 
7269
7269
  chunks.push(c('; '));
7270
- if (node.test) chunks.push(...handle(node.test, state));
7270
+ if (node.test) push_array(chunks, handle(node.test, state));
7271
7271
  chunks.push(c('; '));
7272
- if (node.update) chunks.push(...handle(node.update, state));
7272
+ if (node.update) push_array(chunks, handle(node.update, state));
7273
7273
 
7274
- chunks.push(
7275
- c(') '),
7276
- ...handle(node.body, state)
7277
- );
7274
+ chunks.push(c(') '));
7275
+ push_array(chunks, handle(node.body, state));
7278
7276
 
7279
7277
  return chunks;
7280
7278
  }),
@@ -7285,17 +7283,15 @@ const handlers = {
7285
7283
  ];
7286
7284
 
7287
7285
  if (node.left.type === 'VariableDeclaration') {
7288
- chunks.push(...handle_var_declaration(node.left, state));
7286
+ push_array(chunks, handle_var_declaration(node.left, state));
7289
7287
  } else {
7290
- chunks.push(...handle(node.left, state));
7288
+ push_array(chunks, handle(node.left, state));
7291
7289
  }
7292
7290
 
7293
- chunks.push(
7294
- c(node.type === 'ForInStatement' ? ` in ` : ` of `),
7295
- ...handle(node.right, state),
7296
- c(') '),
7297
- ...handle(node.body, state)
7298
- );
7291
+ chunks.push(c(node.type === 'ForInStatement' ? ` in ` : ` of `));
7292
+ push_array(chunks, handle(node.right, state));
7293
+ chunks.push(c(') '));
7294
+ push_array(chunks, handle(node.body, state));
7299
7295
 
7300
7296
  return chunks;
7301
7297
  }),
@@ -7309,7 +7305,7 @@ const handlers = {
7309
7305
 
7310
7306
  if (node.async) chunks.push(c('async '));
7311
7307
  chunks.push(c(node.generator ? 'function* ' : 'function '));
7312
- if (node.id) chunks.push(...handle(node.id, state));
7308
+ if (node.id) push_array(chunks, handle(node.id, state));
7313
7309
  chunks.push(c('('));
7314
7310
 
7315
7311
  const params = node.params.map(p => handle(p, {
@@ -7325,21 +7321,15 @@ const handlers = {
7325
7321
  const separator = c(multiple_lines ? `,\n${state.indent}` : ', ');
7326
7322
 
7327
7323
  if (multiple_lines) {
7328
- chunks.push(
7329
- c(`\n${state.indent}\t`),
7330
- ...join(params, separator),
7331
- c(`\n${state.indent}`)
7332
- );
7324
+ chunks.push(c(`\n${state.indent}\t`));
7325
+ push_array(chunks, join(params, separator));
7326
+ chunks.push(c(`\n${state.indent}`));
7333
7327
  } else {
7334
- chunks.push(
7335
- ...join(params, separator)
7336
- );
7328
+ push_array(chunks, join(params, separator));
7337
7329
  }
7338
7330
 
7339
- chunks.push(
7340
- c(') '),
7341
- ...handle(node.body, state)
7342
- );
7331
+ chunks.push(c(') '));
7332
+ push_array(chunks, handle(node.body, state));
7343
7333
 
7344
7334
  return chunks;
7345
7335
  }),
@@ -7363,17 +7353,18 @@ const handlers = {
7363
7353
  ClassDeclaration(node, state) {
7364
7354
  const chunks = [c('class ')];
7365
7355
 
7366
- if (node.id) chunks.push(...handle(node.id, state), c(' '));
7356
+ if (node.id) {
7357
+ push_array(chunks, handle(node.id, state));
7358
+ chunks.push(c(' '));
7359
+ }
7367
7360
 
7368
7361
  if (node.superClass) {
7369
- chunks.push(
7370
- c('extends '),
7371
- ...handle(node.superClass, state),
7372
- c(' ')
7373
- );
7362
+ chunks.push(c('extends '));
7363
+ push_array(chunks, handle(node.superClass, state));
7364
+ chunks.push(c(' '));
7374
7365
  }
7375
7366
 
7376
- chunks.push(...handle(node.body, state));
7367
+ push_array(chunks, handle(node.body, state));
7377
7368
 
7378
7369
  return chunks;
7379
7370
  },
@@ -7421,27 +7412,21 @@ const handlers = {
7421
7412
  const width = get_length(chunks) + specifiers.map(get_length).reduce(sum, 0) + (2 * specifiers.length) + 6 + get_length(source);
7422
7413
 
7423
7414
  if (width > 80) {
7424
- chunks.push(
7425
- c(`{\n\t`),
7426
- ...join(specifiers, c(',\n\t')),
7427
- c('\n}')
7428
- );
7415
+ chunks.push(c(`{\n\t`));
7416
+ push_array(chunks, join(specifiers, c(',\n\t')));
7417
+ chunks.push(c('\n}'));
7429
7418
  } else {
7430
- chunks.push(
7431
- c(`{ `),
7432
- ...join(specifiers, c(', ')),
7433
- c(' }')
7434
- );
7419
+ chunks.push(c(`{ `));
7420
+ push_array(chunks, join(specifiers, c(', ')));
7421
+ chunks.push(c(' }'));
7435
7422
  }
7436
7423
  }
7437
7424
 
7438
7425
  chunks.push(c(' from '));
7439
7426
  }
7440
7427
 
7441
- chunks.push(
7442
- ...source,
7443
- c(';')
7444
- );
7428
+ push_array(chunks, source);
7429
+ chunks.push(c(';'));
7445
7430
 
7446
7431
  return chunks;
7447
7432
  },
@@ -7467,7 +7452,7 @@ const handlers = {
7467
7452
  const chunks = [c('export ')];
7468
7453
 
7469
7454
  if (node.declaration) {
7470
- chunks.push(...handle(node.declaration, state));
7455
+ push_array(chunks, handle(node.declaration, state));
7471
7456
  } else {
7472
7457
  const specifiers = node.specifiers.map((/** @type {ExportSpecifier} */ specifier) => {
7473
7458
  const name = handle(specifier.local, state)[0];
@@ -7483,24 +7468,18 @@ const handlers = {
7483
7468
  const width = 7 + specifiers.map(get_length).reduce(sum, 0) + 2 * specifiers.length;
7484
7469
 
7485
7470
  if (width > 80) {
7486
- chunks.push(
7487
- c('{\n\t'),
7488
- ...join(specifiers, c(',\n\t')),
7489
- c('\n}')
7490
- );
7471
+ chunks.push(c('{\n\t'));
7472
+ push_array(chunks, join(specifiers, c(',\n\t')));
7473
+ chunks.push(c('\n}'));
7491
7474
  } else {
7492
- chunks.push(
7493
- c('{ '),
7494
- ...join(specifiers, c(', ')),
7495
- c(' }')
7496
- );
7475
+ chunks.push(c('{ '));
7476
+ push_array(chunks, join(specifiers, c(', ')));
7477
+ chunks.push(c(' }'));
7497
7478
  }
7498
7479
 
7499
7480
  if (node.source) {
7500
- chunks.push(
7501
- c(' from '),
7502
- ...handle(node.source, state)
7503
- );
7481
+ chunks.push(c(' from '));
7482
+ push_array(chunks, handle(node.source, state));
7504
7483
  }
7505
7484
  }
7506
7485
 
@@ -7538,27 +7517,23 @@ const handlers = {
7538
7517
  }
7539
7518
 
7540
7519
  if (node.computed) {
7541
- chunks.push(
7542
- c('['),
7543
- ...handle(node.key, state),
7544
- c(']')
7545
- );
7520
+ chunks.push(c('['));
7521
+ push_array(chunks, handle(node.key, state));
7522
+ chunks.push(c(']'));
7546
7523
  } else {
7547
- chunks.push(...handle(node.key, state));
7524
+ push_array(chunks, handle(node.key, state));
7548
7525
  }
7549
7526
 
7550
7527
  chunks.push(c('('));
7551
7528
 
7552
7529
  const { params } = node.value;
7553
7530
  for (let i = 0; i < params.length; i += 1) {
7554
- chunks.push(...handle(params[i], state));
7531
+ push_array(chunks, handle(params[i], state));
7555
7532
  if (i < params.length - 1) chunks.push(c(', '));
7556
7533
  }
7557
7534
 
7558
- chunks.push(
7559
- c(') '),
7560
- ...handle(node.value.body, state)
7561
- );
7535
+ chunks.push(c(') '));
7536
+ push_array(chunks, handle(node.value.body, state));
7562
7537
 
7563
7538
  return chunks;
7564
7539
  },
@@ -7569,18 +7544,16 @@ const handlers = {
7569
7544
  if (node.async) chunks.push(c('async '));
7570
7545
 
7571
7546
  if (node.params.length === 1 && node.params[0].type === 'Identifier') {
7572
- chunks.push(...handle(node.params[0], state));
7547
+ push_array(chunks, handle(node.params[0], state));
7573
7548
  } else {
7574
7549
  const params = node.params.map(param => handle(param, {
7575
7550
  ...state,
7576
7551
  indent: state.indent + '\t'
7577
7552
  }));
7578
7553
 
7579
- chunks.push(
7580
- c('('),
7581
- ...join(params, c(', ')),
7582
- c(')')
7583
- );
7554
+ chunks.push(c('('));
7555
+ push_array(chunks, join(params, c(', ')));
7556
+ chunks.push(c(')'));
7584
7557
  }
7585
7558
 
7586
7559
  chunks.push(c(' => '));
@@ -7589,13 +7562,11 @@ const handlers = {
7589
7562
  node.body.type === 'ObjectExpression' ||
7590
7563
  (node.body.type === 'AssignmentExpression' && node.body.left.type === 'ObjectPattern')
7591
7564
  ) {
7592
- chunks.push(
7593
- c('('),
7594
- ...handle(node.body, state),
7595
- c(')')
7596
- );
7565
+ chunks.push(c('('));
7566
+ push_array(chunks, handle(node.body, state));
7567
+ chunks.push(c(')'));
7597
7568
  } else {
7598
- chunks.push(...handle(node.body, state));
7569
+ push_array(chunks, handle(node.body, state));
7599
7570
  }
7600
7571
 
7601
7572
  return chunks;
@@ -7643,10 +7614,10 @@ const handlers = {
7643
7614
  for (let i = 0; i < expressions.length; i++) {
7644
7615
  chunks.push(
7645
7616
  c(quasis[i].value.raw),
7646
- c('${'),
7647
- ...handle(expressions[i], state),
7648
- c('}')
7617
+ c('${')
7649
7618
  );
7619
+ push_array(chunks, handle(expressions[i], state));
7620
+ chunks.push(c('}'));
7650
7621
  }
7651
7622
 
7652
7623
  chunks.push(
@@ -7690,14 +7661,13 @@ const handlers = {
7690
7661
  );
7691
7662
 
7692
7663
  if (multiple_lines) {
7693
- chunks.push(
7694
- c(`\n${state.indent}\t`),
7695
- ...join(elements, c(`,\n${state.indent}\t`)),
7696
- c(`\n${state.indent}`),
7697
- ...sparse_commas
7698
- );
7664
+ chunks.push(c(`\n${state.indent}\t`));
7665
+ push_array(chunks, join(elements, c(`,\n${state.indent}\t`)));
7666
+ chunks.push(c(`\n${state.indent}`));
7667
+ push_array(chunks, sparse_commas);
7699
7668
  } else {
7700
- chunks.push(...join(elements, c(', ')), ...sparse_commas);
7669
+ push_array(chunks, join(elements, c(', ')));
7670
+ push_array(chunks, sparse_commas);
7701
7671
  }
7702
7672
 
7703
7673
  chunks.push(c(']'));
@@ -7717,7 +7687,7 @@ const handlers = {
7717
7687
  const separator = c(', ');
7718
7688
 
7719
7689
  node.properties.forEach((p, i) => {
7720
- chunks.push(...handle(p, {
7690
+ push_array(chunks, handle(p, {
7721
7691
  ...state,
7722
7692
  indent: state.indent + '\t'
7723
7693
  }));
@@ -7805,13 +7775,11 @@ const handlers = {
7805
7775
  chunks.push(c('*'));
7806
7776
  }
7807
7777
 
7808
- chunks.push(
7809
- ...(node.computed ? [c('['), ...key, c(']')] : key),
7810
- c('('),
7811
- ...join(node.value.params.map((/** @type {Pattern} */ param) => handle(param, state)), c(', ')),
7812
- c(') '),
7813
- ...handle(node.value.body, state)
7814
- );
7778
+ push_array(chunks, node.computed ? [c('['), ...key, c(']')] : key);
7779
+ chunks.push(c('('));
7780
+ push_array(chunks, join(node.value.params.map((/** @type {Pattern} */ param) => handle(param, state)), c(', ')));
7781
+ chunks.push(c(') '));
7782
+ push_array(chunks, handle(node.value.body, state));
7815
7783
 
7816
7784
  return chunks;
7817
7785
  }
@@ -7836,7 +7804,7 @@ const handlers = {
7836
7804
  const chunks = [c('{ ')];
7837
7805
 
7838
7806
  for (let i = 0; i < node.properties.length; i += 1) {
7839
- chunks.push(...handle(node.properties[i], state));
7807
+ push_array(chunks, handle(node.properties[i], state));
7840
7808
  if (i < node.properties.length - 1) chunks.push(c(', '));
7841
7809
  }
7842
7810
 
@@ -7866,13 +7834,11 @@ const handlers = {
7866
7834
  EXPRESSIONS_PRECEDENCE[node.argument.type] <
7867
7835
  EXPRESSIONS_PRECEDENCE.UnaryExpression
7868
7836
  ) {
7869
- chunks.push(
7870
- c('('),
7871
- ...handle(node.argument, state),
7872
- c(')')
7873
- );
7837
+ chunks.push(c('('));
7838
+ push_array(chunks, handle(node.argument, state));
7839
+ chunks.push(c(')'));
7874
7840
  } else {
7875
- chunks.push(...handle(node.argument, state));
7841
+ push_array(chunks, handle(node.argument, state));
7876
7842
  }
7877
7843
 
7878
7844
  return chunks;
@@ -7893,6 +7859,9 @@ const handlers = {
7893
7859
  },
7894
7860
 
7895
7861
  BinaryExpression(node, state) {
7862
+ /**
7863
+ * @type any[]
7864
+ */
7896
7865
  const chunks = [];
7897
7866
 
7898
7867
  // TODO
@@ -7903,44 +7872,41 @@ const handlers = {
7903
7872
  // }
7904
7873
 
7905
7874
  if (needs_parens(node.left, node, false)) {
7906
- chunks.push(
7907
- c('('),
7908
- ...handle(node.left, state),
7909
- c(')')
7910
- );
7875
+ chunks.push(c('('));
7876
+ push_array(chunks, handle(node.left, state));
7877
+ chunks.push(c(')'));
7911
7878
  } else {
7912
- chunks.push(...handle(node.left, state));
7879
+ push_array(chunks, handle(node.left, state));
7913
7880
  }
7914
7881
 
7915
7882
  chunks.push(c(` ${node.operator} `));
7916
7883
 
7917
7884
  if (needs_parens(node.right, node, true)) {
7918
- chunks.push(
7919
- c('('),
7920
- ...handle(node.right, state),
7921
- c(')')
7922
- );
7885
+ chunks.push(c('('));
7886
+ push_array(chunks, handle(node.right, state));
7887
+ chunks.push(c(')'));
7923
7888
  } else {
7924
- chunks.push(...handle(node.right, state));
7889
+ push_array(chunks, handle(node.right, state));
7925
7890
  }
7926
7891
 
7927
7892
  return chunks;
7928
7893
  },
7929
7894
 
7930
7895
  ConditionalExpression(node, state) {
7896
+ /**
7897
+ * @type any[]
7898
+ */
7931
7899
  const chunks = [];
7932
7900
 
7933
7901
  if (
7934
7902
  EXPRESSIONS_PRECEDENCE[node.test.type] >
7935
7903
  EXPRESSIONS_PRECEDENCE.ConditionalExpression
7936
7904
  ) {
7937
- chunks.push(...handle(node.test, state));
7905
+ push_array(chunks, handle(node.test, state));
7938
7906
  } else {
7939
- chunks.push(
7940
- c('('),
7941
- ...handle(node.test, state),
7942
- c(')')
7943
- );
7907
+ chunks.push(c('('));
7908
+ push_array(chunks, handle(node.test, state));
7909
+ chunks.push(c(')'));
7944
7910
  }
7945
7911
 
7946
7912
  const child_state = { ...state, indent: state.indent + '\t' };
@@ -7954,19 +7920,15 @@ const handlers = {
7954
7920
  );
7955
7921
 
7956
7922
  if (multiple_lines) {
7957
- chunks.push(
7958
- c(`\n${state.indent}? `),
7959
- ...consequent,
7960
- c(`\n${state.indent}: `),
7961
- ...alternate
7962
- );
7923
+ chunks.push(c(`\n${state.indent}? `));
7924
+ push_array(chunks, consequent);
7925
+ chunks.push(c(`\n${state.indent}: `));
7926
+ push_array(chunks, alternate);
7963
7927
  } else {
7964
- chunks.push(
7965
- c(` ? `),
7966
- ...consequent,
7967
- c(` : `),
7968
- ...alternate
7969
- );
7928
+ chunks.push(c(` ? `));
7929
+ push_array(chunks, consequent);
7930
+ chunks.push(c(` : `));
7931
+ push_array(chunks, alternate);
7970
7932
  }
7971
7933
 
7972
7934
  return chunks;
@@ -7979,13 +7941,11 @@ const handlers = {
7979
7941
  EXPRESSIONS_PRECEDENCE[node.callee.type] <
7980
7942
  EXPRESSIONS_PRECEDENCE.CallExpression || has_call_expression(node.callee)
7981
7943
  ) {
7982
- chunks.push(
7983
- c('('),
7984
- ...handle(node.callee, state),
7985
- c(')')
7986
- );
7944
+ chunks.push(c('('));
7945
+ push_array(chunks, handle(node.callee, state));
7946
+ chunks.push(c(')'));
7987
7947
  } else {
7988
- chunks.push(...handle(node.callee, state));
7948
+ push_array(chunks, handle(node.callee, state));
7989
7949
  }
7990
7950
 
7991
7951
  // TODO this is copied from CallExpression — DRY it out
@@ -7998,11 +7958,9 @@ const handlers = {
7998
7958
  ? c(',\n' + state.indent)
7999
7959
  : c(', ');
8000
7960
 
8001
- chunks.push(
8002
- c('('),
8003
- ...join(args, separator),
8004
- c(')')
8005
- );
7961
+ chunks.push(c('('));
7962
+ push_array(chunks, join(args, separator));
7963
+ chunks.push(c(')'));
8006
7964
 
8007
7965
  return chunks;
8008
7966
  },
@@ -8012,19 +7970,20 @@ const handlers = {
8012
7970
  },
8013
7971
 
8014
7972
  CallExpression(/** @type {CallExpression} */ node, state) {
7973
+ /**
7974
+ * @type any[]
7975
+ */
8015
7976
  const chunks = [];
8016
7977
 
8017
7978
  if (
8018
7979
  EXPRESSIONS_PRECEDENCE[node.callee.type] <
8019
7980
  EXPRESSIONS_PRECEDENCE.CallExpression
8020
7981
  ) {
8021
- chunks.push(
8022
- c('('),
8023
- ...handle(node.callee, state),
8024
- c(')')
8025
- );
7982
+ chunks.push(c('('));
7983
+ push_array(chunks, handle(node.callee, state));
7984
+ chunks.push(c(')'));
8026
7985
  } else {
8027
- chunks.push(...handle(node.callee, state));
7986
+ push_array(chunks, handle(node.callee, state));
8028
7987
  }
8029
7988
 
8030
7989
  if (/** @type {SimpleCallExpression} */ (node).optional) {
@@ -8042,49 +8001,42 @@ const handlers = {
8042
8001
  indent: `${state.indent}\t`
8043
8002
  }));
8044
8003
 
8045
- chunks.push(
8046
- c(`(\n${state.indent}\t`),
8047
- ...join(args, c(`,\n${state.indent}\t`)),
8048
- c(`\n${state.indent})`)
8049
- );
8004
+ chunks.push(c(`(\n${state.indent}\t`));
8005
+ push_array(chunks, join(args, c(`,\n${state.indent}\t`)));
8006
+ chunks.push(c(`\n${state.indent})`));
8050
8007
  } else {
8051
- chunks.push(
8052
- c('('),
8053
- ...join(args, c(', ')),
8054
- c(')')
8055
- );
8008
+ chunks.push(c('('));
8009
+ push_array(chunks, join(args, c(', ')));
8010
+ chunks.push(c(')'));
8056
8011
  }
8057
8012
 
8058
8013
  return chunks;
8059
8014
  },
8060
8015
 
8061
8016
  MemberExpression(node, state) {
8017
+ /**
8018
+ * @type any[]
8019
+ */
8062
8020
  const chunks = [];
8063
8021
 
8064
8022
  if (EXPRESSIONS_PRECEDENCE[node.object.type] < EXPRESSIONS_PRECEDENCE.MemberExpression) {
8065
- chunks.push(
8066
- c('('),
8067
- ...handle(node.object, state),
8068
- c(')')
8069
- );
8023
+ chunks.push(c('('));
8024
+ push_array(chunks, handle(node.object, state));
8025
+ chunks.push(c(')'));
8070
8026
  } else {
8071
- chunks.push(...handle(node.object, state));
8027
+ push_array(chunks, handle(node.object, state));
8072
8028
  }
8073
8029
 
8074
8030
  if (node.computed) {
8075
8031
  if (node.optional) {
8076
8032
  chunks.push(c('?.'));
8077
8033
  }
8078
- chunks.push(
8079
- c('['),
8080
- ...handle(node.property, state),
8081
- c(']')
8082
- );
8034
+ chunks.push(c('['));
8035
+ push_array(chunks, handle(node.property, state));
8036
+ chunks.push(c(']'));
8083
8037
  } else {
8084
- chunks.push(
8085
- c(node.optional ? '?.' : '.'),
8086
- ...handle(node.property, state)
8087
- );
8038
+ chunks.push(c(node.optional ? '?.' : '.'));
8039
+ push_array(chunks, handle(node.property, state));
8088
8040
  }
8089
8041
 
8090
8042
  return chunks;
@@ -19113,7 +19065,11 @@ var compiler_errors = {
19113
19065
  cyclical_const_tags: (cycle) => ({
19114
19066
  code: 'cyclical-const-tags',
19115
19067
  message: `Cyclical dependency detected: ${cycle.join(' → ')}`
19116
- })
19068
+ }),
19069
+ invalid_component_style_directive: {
19070
+ code: 'invalid-component-style-directive',
19071
+ message: 'Style directives cannot be used on components'
19072
+ }
19117
19073
  };
19118
19074
 
19119
19075
  class Expression {
@@ -20137,6 +20093,21 @@ class Text extends Node$1 {
20137
20093
  }
20138
20094
  return parent_element.namespace || elements_without_text.has(parent_element.name);
20139
20095
  }
20096
+ keep_space() {
20097
+ if (this.component.component_options.preserveWhitespace)
20098
+ return true;
20099
+ return this.within_pre();
20100
+ }
20101
+ within_pre() {
20102
+ let node = this.parent;
20103
+ while (node) {
20104
+ if (node.type === 'Element' && node.name === 'pre') {
20105
+ return true;
20106
+ }
20107
+ node = node.parent;
20108
+ }
20109
+ return false;
20110
+ }
20140
20111
  }
20141
20112
 
20142
20113
  // The `foreign` namespace covers all DOM implementations that aren't HTML5.
@@ -20991,6 +20962,8 @@ class InlineComponent extends Node$1 {
20991
20962
  break;
20992
20963
  case 'Transition':
20993
20964
  return component.error(node, compiler_errors.invalid_transition);
20965
+ case 'StyleDirective':
20966
+ return component.error(node, compiler_errors.invalid_component_style_directive);
20994
20967
  default:
20995
20968
  throw new Error(`Not implemented: ${node.type}`);
20996
20969
  }
@@ -21272,6 +21245,19 @@ class Window extends Node$1 {
21272
21245
  }
21273
21246
  }
21274
21247
 
21248
+ /**
21249
+ * Pushes all `items` into `array` using `push`, therefore mutating the array.
21250
+ * We do this for memory and perf reasons, and because `array.push(...items)` would
21251
+ * run into a "max call stack size exceeded" error with too many items (~65k).
21252
+ * @param array
21253
+ * @param items
21254
+ */
21255
+ function push_array$1(array, items) {
21256
+ for (let i = 0; i < items.length; i++) {
21257
+ array.push(items[i]);
21258
+ }
21259
+ }
21260
+
21275
21261
  function get_constructor(type) {
21276
21262
  switch (type) {
21277
21263
  case 'AwaitBlock': return AwaitBlock;
@@ -21308,7 +21294,7 @@ function map_children(component, parent, scope, children) {
21308
21294
  if (use_ignores)
21309
21295
  component.pop_ignores(), ignores = [];
21310
21296
  if (node.type === 'Comment' && node.ignores.length) {
21311
- ignores.push(...node.ignores);
21297
+ push_array$1(ignores, node.ignores);
21312
21298
  }
21313
21299
  if (last)
21314
21300
  last.next = node;
@@ -22254,14 +22240,7 @@ class TextWrapper extends Wrapper {
22254
22240
  return false;
22255
22241
  if (/[\S\u00A0]/.test(this.data))
22256
22242
  return false;
22257
- let node = this.parent && this.parent.node;
22258
- while (node) {
22259
- if (node.type === 'Element' && node.name === 'pre') {
22260
- return false;
22261
- }
22262
- node = node.parent;
22263
- }
22264
- return true;
22243
+ return !this.node.within_pre();
22265
22244
  }
22266
22245
  render(block, parent_node, parent_nodes) {
22267
22246
  if (this.skip)
@@ -23754,7 +23733,7 @@ class ElementWrapper extends Wrapper {
23754
23733
  this.attributes.forEach((attribute) => {
23755
23734
  if (attribute.node.name === 'class') {
23756
23735
  const dependencies = attribute.node.get_dependencies();
23757
- this.class_dependencies.push(...dependencies);
23736
+ push_array$1(this.class_dependencies, dependencies);
23758
23737
  }
23759
23738
  });
23760
23739
  if (this.node.attributes.some(attr => attr.is_spread)) {
@@ -24228,7 +24207,7 @@ class IfBlockWrapper extends Wrapper {
24228
24207
  block.has_intro_method = has_intros;
24229
24208
  block.has_outro_method = has_outros;
24230
24209
  });
24231
- renderer.blocks.push(...blocks);
24210
+ push_array$1(renderer.blocks, blocks);
24232
24211
  }
24233
24212
  render(block, parent_node, parent_nodes) {
24234
24213
  const name = this.var;
@@ -25721,7 +25700,7 @@ class FragmentWrapper {
25721
25700
  // *unless* there is no whitespace between this node and its next sibling
25722
25701
  if (this.nodes.length === 0) {
25723
25702
  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'));
25724
- if (should_trim) {
25703
+ if (should_trim && !child.keep_space()) {
25725
25704
  data = trim_end(data);
25726
25705
  if (!data)
25727
25706
  continue;
@@ -25749,7 +25728,7 @@ class FragmentWrapper {
25749
25728
  }
25750
25729
  if (strip_whitespace) {
25751
25730
  const first = this.nodes[0];
25752
- if (first && first.node.type === 'Text') {
25731
+ if (first && first.node.type === 'Text' && !first.node.keep_space()) {
25753
25732
  first.data = trim_start(first.data);
25754
25733
  if (!first.data) {
25755
25734
  first.var = null;
@@ -26808,13 +26787,6 @@ function merge_tables(this_table, other_table) {
26808
26787
  }
26809
26788
  return [new_table, idx_map, val_changed, idx_changed];
26810
26789
  }
26811
- function pushArray(_this, other) {
26812
- // We use push to mutate in place for memory and perf reasons
26813
- // We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore)
26814
- for (let i = 0; i < other.length; i++) {
26815
- _this.push(other[i]);
26816
- }
26817
- }
26818
26790
  class MappedCode {
26819
26791
  constructor(string = '', map = null) {
26820
26792
  this.string = string;
@@ -26902,9 +26874,9 @@ class MappedCode {
26902
26874
  }
26903
26875
  }
26904
26876
  // combine last line + first line
26905
- pushArray(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
26877
+ push_array$1(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
26906
26878
  // append other lines
26907
- pushArray(m1.mappings, m2.mappings);
26879
+ push_array$1(m1.mappings, m2.mappings);
26908
26880
  return this;
26909
26881
  }
26910
26882
  static from_processed(string, map) {
@@ -27095,7 +27067,7 @@ function dom(component, options) {
27095
27067
  // fix order
27096
27068
  // TODO the deconflicted names of blocks are reversed... should set them here
27097
27069
  const blocks = renderer.blocks.slice().reverse();
27098
- body.push(...blocks.map(block => {
27070
+ push_array$1(body, blocks.map(block => {
27099
27071
  // TODO this is a horrible mess — renderer.blocks
27100
27072
  // contains a mixture of Blocks and Nodes
27101
27073
  if (block.render)
@@ -27516,7 +27488,7 @@ function dom(component, options) {
27516
27488
  }`
27517
27489
  });
27518
27490
  }
27519
- declaration.body.body.push(...accessors);
27491
+ push_array$1(declaration.body.body, accessors);
27520
27492
  body.push(declaration);
27521
27493
  if (component.tag != null) {
27522
27494
  body.push(b `
@@ -27550,7 +27522,7 @@ function dom(component, options) {
27550
27522
  }
27551
27523
  }
27552
27524
  `[0];
27553
- declaration.body.body.push(...accessors);
27525
+ push_array$1(declaration.body.body, accessors);
27554
27526
  body.push(declaration);
27555
27527
  }
27556
27528
  return { js: flatten(body), css };
@@ -27701,7 +27673,7 @@ function remove_whitespace_children(children, next) {
27701
27673
  /^\s/.test(next.data) &&
27702
27674
  trimmable_at$1(child, next)
27703
27675
  : !child.has_ancestor('EachBlock');
27704
- if (should_trim) {
27676
+ if (should_trim && !child.keep_space()) {
27705
27677
  data = trim_end(data);
27706
27678
  if (!data)
27707
27679
  continue;
@@ -27721,7 +27693,7 @@ function remove_whitespace_children(children, next) {
27721
27693
  }
27722
27694
  }
27723
27695
  const first = nodes[0];
27724
- if (first && first.type === 'Text') {
27696
+ if (first && first.type === 'Text' && !first.keep_space()) {
27725
27697
  first.data = trim_start(first.data);
27726
27698
  if (!first.data) {
27727
27699
  first.var = null;
@@ -30370,7 +30342,7 @@ class Stylesheet {
30370
30342
  const at_rule_declarations = node.block.children
30371
30343
  .filter(node => node.type === 'Declaration')
30372
30344
  .map(node => new Declaration$1(node));
30373
- atrule.declarations.push(...at_rule_declarations);
30345
+ push_array$1(atrule.declarations, at_rule_declarations);
30374
30346
  }
30375
30347
  current_atrule = atrule;
30376
30348
  }
@@ -30694,7 +30666,7 @@ class Component {
30694
30666
  if (result) {
30695
30667
  const { compile_options, name } = this;
30696
30668
  const { format = 'esm' } = compile_options;
30697
- const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.3'}`;
30669
+ const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.4'}`;
30698
30670
  const program = { type: 'Program', body: result.js };
30699
30671
  walk(program, {
30700
30672
  enter: (node, parent, key) => {
@@ -32187,7 +32159,7 @@ async function preprocess(source, preprocessor, options) {
32187
32159
  return result.to_processed();
32188
32160
  }
32189
32161
 
32190
- const VERSION = '3.46.3';
32162
+ const VERSION = '3.46.4';
32191
32163
 
32192
32164
  export { VERSION, compile, parse$3 as parse, preprocess, walk };
32193
32165
  //# sourceMappingURL=compiler.mjs.map