vite 5.0.0-beta.6 → 5.0.0-beta.8

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.
@@ -23,25 +23,25 @@ import os$4 from 'node:os';
23
23
  import { exec } from 'node:child_process';
24
24
  import { createHash as createHash$2 } from 'node:crypto';
25
25
  import { promises } from 'node:dns';
26
- import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, SPECIAL_QUERY_RE, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
26
+ import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
27
27
  import require$$3$1 from 'crypto';
28
28
  import { Buffer as Buffer$1 } from 'node:buffer';
29
29
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
30
- import { VERSION } from 'rollup';
31
30
  import assert$1 from 'node:assert';
32
31
  import process$1 from 'node:process';
33
32
  import v8 from 'node:v8';
33
+ import { VERSION } from 'rollup';
34
+ import * as qs from 'querystring';
35
+ import readline from 'node:readline';
36
+ import { EventEmitter as EventEmitter$4 } from 'node:events';
34
37
  import { createServer as createServer$3, STATUS_CODES } from 'node:http';
35
38
  import { createServer as createServer$2 } from 'node:https';
36
39
  import require$$0$a from 'zlib';
37
40
  import require$$0$b from 'buffer';
38
41
  import require$$1$2 from 'https';
39
42
  import require$$4$2 from 'tls';
40
- import require$$1 from 'worker_threads';
41
- import * as qs from 'querystring';
42
- import readline from 'node:readline';
43
- import { EventEmitter as EventEmitter$4 } from 'node:events';
44
43
  import zlib$1, { gzip } from 'node:zlib';
44
+ import require$$1 from 'worker_threads';
45
45
 
46
46
  import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
47
47
  import { dirname as __cjs_dirname } from 'node:path';
@@ -2147,7 +2147,7 @@ const scan$1 = scan_1;
2147
2147
  const parse$g = parse_1$3;
2148
2148
  const utils$h = utils$k;
2149
2149
  const constants$4 = constants$6;
2150
- const isObject$4 = val => val && typeof val === 'object' && !Array.isArray(val);
2150
+ const isObject$3 = val => val && typeof val === 'object' && !Array.isArray(val);
2151
2151
 
2152
2152
  /**
2153
2153
  * Creates a matcher function from one or more glob patterns. The
@@ -2184,7 +2184,7 @@ const picomatch$5 = (glob, options, returnState = false) => {
2184
2184
  return arrayMatcher;
2185
2185
  }
2186
2186
 
2187
- const isState = isObject$4(glob) && glob.tokens && glob.input;
2187
+ const isState = isObject$3(glob) && glob.tokens && glob.input;
2188
2188
 
2189
2189
  if (glob === '' || (typeof glob !== 'string' && !isState)) {
2190
2190
  throw new TypeError('Expected pattern to be a non-empty string');
@@ -6291,7 +6291,7 @@ function encodeInteger(buf, pos, state, segment, j) {
6291
6291
  return pos;
6292
6292
  }
6293
6293
 
6294
- let BitSet$1 = class BitSet {
6294
+ class BitSet {
6295
6295
  constructor(arg) {
6296
6296
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
6297
6297
  }
@@ -6303,9 +6303,9 @@ let BitSet$1 = class BitSet {
6303
6303
  has(n) {
6304
6304
  return !!(this.bits[n >> 5] & (1 << (n & 31)));
6305
6305
  }
6306
- };
6306
+ }
6307
6307
 
6308
- let Chunk$1 = class Chunk {
6308
+ class Chunk {
6309
6309
  constructor(start, end, content) {
6310
6310
  this.start = start;
6311
6311
  this.end = end;
@@ -6400,6 +6400,13 @@ let Chunk$1 = class Chunk {
6400
6400
  this.end = index;
6401
6401
 
6402
6402
  if (this.edited) {
6403
+ // after split we should save the edit content record into the correct chunk
6404
+ // to make sure sourcemap correct
6405
+ // For example:
6406
+ // ' test'.trim()
6407
+ // split -> ' ' + 'test'
6408
+ // ✔️ edit -> '' + 'test'
6409
+ // ✖️ edit -> 'test' + ''
6403
6410
  // TODO is this block necessary?...
6404
6411
  newChunk.edit('', false);
6405
6412
  this.content = '';
@@ -6428,6 +6435,10 @@ let Chunk$1 = class Chunk {
6428
6435
  if (trimmed.length) {
6429
6436
  if (trimmed !== this.content) {
6430
6437
  this.split(this.start + trimmed.length).edit('', undefined, true);
6438
+ if (this.edited) {
6439
+ // save the change, if it has been edited
6440
+ this.edit(trimmed, this.storeName, true);
6441
+ }
6431
6442
  }
6432
6443
  return true;
6433
6444
  } else {
@@ -6446,7 +6457,11 @@ let Chunk$1 = class Chunk {
6446
6457
 
6447
6458
  if (trimmed.length) {
6448
6459
  if (trimmed !== this.content) {
6449
- this.split(this.end - trimmed.length);
6460
+ const newChunk = this.split(this.end - trimmed.length);
6461
+ if (this.edited) {
6462
+ // save the change, if it has been edited
6463
+ newChunk.edit(trimmed, this.storeName, true);
6464
+ }
6450
6465
  this.edit('', undefined, true);
6451
6466
  }
6452
6467
  return true;
@@ -6457,9 +6472,9 @@ let Chunk$1 = class Chunk {
6457
6472
  if (this.outro.length) return true;
6458
6473
  }
6459
6474
  }
6460
- };
6475
+ }
6461
6476
 
6462
- function getBtoa$1 () {
6477
+ function getBtoa() {
6463
6478
  if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
6464
6479
  return (str) => window.btoa(unescape(encodeURIComponent(str)));
6465
6480
  } else if (typeof Buffer === 'function') {
@@ -6471,9 +6486,9 @@ function getBtoa$1 () {
6471
6486
  }
6472
6487
  }
6473
6488
 
6474
- const btoa$2 = /*#__PURE__*/ getBtoa$1();
6489
+ const btoa$1 = /*#__PURE__*/ getBtoa();
6475
6490
 
6476
- let SourceMap$2 = class SourceMap {
6491
+ let SourceMap$1 = class SourceMap {
6477
6492
  constructor(properties) {
6478
6493
  this.version = 3;
6479
6494
  this.file = properties.file;
@@ -6481,6 +6496,9 @@ let SourceMap$2 = class SourceMap {
6481
6496
  this.sourcesContent = properties.sourcesContent;
6482
6497
  this.names = properties.names;
6483
6498
  this.mappings = encode$1(properties.mappings);
6499
+ if (typeof properties.x_google_ignoreList !== 'undefined') {
6500
+ this.x_google_ignoreList = properties.x_google_ignoreList;
6501
+ }
6484
6502
  }
6485
6503
 
6486
6504
  toString() {
@@ -6488,11 +6506,11 @@ let SourceMap$2 = class SourceMap {
6488
6506
  }
6489
6507
 
6490
6508
  toUrl() {
6491
- return 'data:application/json;charset=utf-8;base64,' + btoa$2(this.toString());
6509
+ return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
6492
6510
  }
6493
6511
  };
6494
6512
 
6495
- function guessIndent$1(code) {
6513
+ function guessIndent(code) {
6496
6514
  const lines = code.split('\n');
6497
6515
 
6498
6516
  const tabbed = lines.filter((line) => /^\t+/.test(line));
@@ -6518,7 +6536,7 @@ function guessIndent$1(code) {
6518
6536
  return new Array(min + 1).join(' ');
6519
6537
  }
6520
6538
 
6521
- function getRelativePath$1(from, to) {
6539
+ function getRelativePath(from, to) {
6522
6540
  const fromParts = from.split(/[/\\]/);
6523
6541
  const toParts = to.split(/[/\\]/);
6524
6542
 
@@ -6537,13 +6555,13 @@ function getRelativePath$1(from, to) {
6537
6555
  return fromParts.concat(toParts).join('/');
6538
6556
  }
6539
6557
 
6540
- const toString$3 = Object.prototype.toString;
6558
+ const toString$2 = Object.prototype.toString;
6541
6559
 
6542
- function isObject$3(thing) {
6543
- return toString$3.call(thing) === '[object Object]';
6560
+ function isObject$2(thing) {
6561
+ return toString$2.call(thing) === '[object Object]';
6544
6562
  }
6545
6563
 
6546
- function getLocator$1(source) {
6564
+ function getLocator(source) {
6547
6565
  const originalLines = source.split('\n');
6548
6566
  const lineOffsets = [];
6549
6567
 
@@ -6569,7 +6587,9 @@ function getLocator$1(source) {
6569
6587
  };
6570
6588
  }
6571
6589
 
6572
- let Mappings$1 = class Mappings {
6590
+ const wordRegex = /\w/;
6591
+
6592
+ class Mappings {
6573
6593
  constructor(hires) {
6574
6594
  this.hires = hires;
6575
6595
  this.generatedCodeLine = 0;
@@ -6581,26 +6601,64 @@ let Mappings$1 = class Mappings {
6581
6601
 
6582
6602
  addEdit(sourceIndex, content, loc, nameIndex) {
6583
6603
  if (content.length) {
6604
+ let contentLineEnd = content.indexOf('\n', 0);
6605
+ let previousContentLineEnd = -1;
6606
+ while (contentLineEnd >= 0) {
6607
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
6608
+ if (nameIndex >= 0) {
6609
+ segment.push(nameIndex);
6610
+ }
6611
+ this.rawSegments.push(segment);
6612
+
6613
+ this.generatedCodeLine += 1;
6614
+ this.raw[this.generatedCodeLine] = this.rawSegments = [];
6615
+ this.generatedCodeColumn = 0;
6616
+
6617
+ previousContentLineEnd = contentLineEnd;
6618
+ contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
6619
+ }
6620
+
6584
6621
  const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
6585
6622
  if (nameIndex >= 0) {
6586
6623
  segment.push(nameIndex);
6587
6624
  }
6588
6625
  this.rawSegments.push(segment);
6626
+
6627
+ this.advance(content.slice(previousContentLineEnd + 1));
6589
6628
  } else if (this.pending) {
6590
6629
  this.rawSegments.push(this.pending);
6630
+ this.advance(content);
6591
6631
  }
6592
6632
 
6593
- this.advance(content);
6594
6633
  this.pending = null;
6595
6634
  }
6596
6635
 
6597
6636
  addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
6598
6637
  let originalCharIndex = chunk.start;
6599
6638
  let first = true;
6639
+ // when iterating each char, check if it's in a word boundary
6640
+ let charInHiresBoundary = false;
6600
6641
 
6601
6642
  while (originalCharIndex < chunk.end) {
6602
6643
  if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
6603
- this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
6644
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
6645
+
6646
+ if (this.hires === 'boundary') {
6647
+ // in hires "boundary", group segments per word boundary than per char
6648
+ if (wordRegex.test(original[originalCharIndex])) {
6649
+ // for first char in the boundary found, start the boundary by pushing a segment
6650
+ if (!charInHiresBoundary) {
6651
+ this.rawSegments.push(segment);
6652
+ charInHiresBoundary = true;
6653
+ }
6654
+ } else {
6655
+ // for non-word char, end the boundary by pushing a segment
6656
+ this.rawSegments.push(segment);
6657
+ charInHiresBoundary = false;
6658
+ }
6659
+ } else {
6660
+ this.rawSegments.push(segment);
6661
+ }
6604
6662
  }
6605
6663
 
6606
6664
  if (original[originalCharIndex] === '\n') {
@@ -6637,19 +6695,19 @@ let Mappings$1 = class Mappings {
6637
6695
 
6638
6696
  this.generatedCodeColumn += lines[lines.length - 1].length;
6639
6697
  }
6640
- };
6698
+ }
6641
6699
 
6642
- const n$2 = '\n';
6700
+ const n$1 = '\n';
6643
6701
 
6644
- const warned$1 = {
6702
+ const warned = {
6645
6703
  insertLeft: false,
6646
6704
  insertRight: false,
6647
6705
  storeName: false,
6648
6706
  };
6649
6707
 
6650
- let MagicString$1 = class MagicString {
6708
+ class MagicString {
6651
6709
  constructor(string, options = {}) {
6652
- const chunk = new Chunk$1(0, string.length, string);
6710
+ const chunk = new Chunk(0, string.length, string);
6653
6711
 
6654
6712
  Object.defineProperties(this, {
6655
6713
  original: { writable: true, value: string },
@@ -6662,9 +6720,10 @@ let MagicString$1 = class MagicString {
6662
6720
  byEnd: { writable: true, value: {} },
6663
6721
  filename: { writable: true, value: options.filename },
6664
6722
  indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
6665
- sourcemapLocations: { writable: true, value: new BitSet$1() },
6723
+ sourcemapLocations: { writable: true, value: new BitSet() },
6666
6724
  storedNames: { writable: true, value: {} },
6667
6725
  indentStr: { writable: true, value: undefined },
6726
+ ignoreList: { writable: true, value: options.ignoreList },
6668
6727
  });
6669
6728
 
6670
6729
  this.byStart[0] = chunk;
@@ -6741,7 +6800,7 @@ let MagicString$1 = class MagicString {
6741
6800
  cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
6742
6801
  }
6743
6802
 
6744
- cloned.sourcemapLocations = new BitSet$1(this.sourcemapLocations);
6803
+ cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
6745
6804
 
6746
6805
  cloned.intro = this.intro;
6747
6806
  cloned.outro = this.outro;
@@ -6754,9 +6813,9 @@ let MagicString$1 = class MagicString {
6754
6813
 
6755
6814
  const sourceIndex = 0;
6756
6815
  const names = Object.keys(this.storedNames);
6757
- const mappings = new Mappings$1(options.hires);
6816
+ const mappings = new Mappings(options.hires);
6758
6817
 
6759
- const locate = getLocator$1(this.original);
6818
+ const locate = getLocator(this.original);
6760
6819
 
6761
6820
  if (this.intro) {
6762
6821
  mappings.advance(this.intro);
@@ -6772,7 +6831,7 @@ let MagicString$1 = class MagicString {
6772
6831
  sourceIndex,
6773
6832
  chunk.content,
6774
6833
  loc,
6775
- chunk.storeName ? names.indexOf(chunk.original) : -1
6834
+ chunk.storeName ? names.indexOf(chunk.original) : -1,
6776
6835
  );
6777
6836
  } else {
6778
6837
  mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
@@ -6782,21 +6841,24 @@ let MagicString$1 = class MagicString {
6782
6841
  });
6783
6842
 
6784
6843
  return {
6785
- file: options.file ? options.file.split(/[/\\]/).pop() : null,
6786
- sources: [options.source ? getRelativePath$1(options.file || '', options.source) : null],
6787
- sourcesContent: options.includeContent ? [this.original] : [null],
6844
+ file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
6845
+ sources: [
6846
+ options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
6847
+ ],
6848
+ sourcesContent: options.includeContent ? [this.original] : undefined,
6788
6849
  names,
6789
6850
  mappings: mappings.raw,
6851
+ x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
6790
6852
  };
6791
6853
  }
6792
6854
 
6793
6855
  generateMap(options) {
6794
- return new SourceMap$2(this.generateDecodedMap(options));
6856
+ return new SourceMap$1(this.generateDecodedMap(options));
6795
6857
  }
6796
6858
 
6797
6859
  _ensureindentStr() {
6798
6860
  if (this.indentStr === undefined) {
6799
- this.indentStr = guessIndent$1(this.original);
6861
+ this.indentStr = guessIndent(this.original);
6800
6862
  }
6801
6863
  }
6802
6864
 
@@ -6813,7 +6875,7 @@ let MagicString$1 = class MagicString {
6813
6875
  indent(indentStr, options) {
6814
6876
  const pattern = /^[^\r\n]/gm;
6815
6877
 
6816
- if (isObject$3(indentStr)) {
6878
+ if (isObject$2(indentStr)) {
6817
6879
  options = indentStr;
6818
6880
  indentStr = undefined;
6819
6881
  }
@@ -6900,27 +6962,27 @@ let MagicString$1 = class MagicString {
6900
6962
 
6901
6963
  insert() {
6902
6964
  throw new Error(
6903
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
6965
+ 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
6904
6966
  );
6905
6967
  }
6906
6968
 
6907
6969
  insertLeft(index, content) {
6908
- if (!warned$1.insertLeft) {
6970
+ if (!warned.insertLeft) {
6909
6971
  console.warn(
6910
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
6972
+ 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
6911
6973
  ); // eslint-disable-line no-console
6912
- warned$1.insertLeft = true;
6974
+ warned.insertLeft = true;
6913
6975
  }
6914
6976
 
6915
6977
  return this.appendLeft(index, content);
6916
6978
  }
6917
6979
 
6918
6980
  insertRight(index, content) {
6919
- if (!warned$1.insertRight) {
6981
+ if (!warned.insertRight) {
6920
6982
  console.warn(
6921
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
6983
+ 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
6922
6984
  ); // eslint-disable-line no-console
6923
- warned$1.insertRight = true;
6985
+ warned.insertRight = true;
6924
6986
  }
6925
6987
 
6926
6988
  return this.prependRight(index, content);
@@ -6977,18 +7039,18 @@ let MagicString$1 = class MagicString {
6977
7039
  if (end > this.original.length) throw new Error('end is out of bounds');
6978
7040
  if (start === end)
6979
7041
  throw new Error(
6980
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
7042
+ 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
6981
7043
  );
6982
7044
 
6983
7045
  this._split(start);
6984
7046
  this._split(end);
6985
7047
 
6986
7048
  if (options === true) {
6987
- if (!warned$1.storeName) {
7049
+ if (!warned.storeName) {
6988
7050
  console.warn(
6989
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
7051
+ 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
6990
7052
  ); // eslint-disable-line no-console
6991
- warned$1.storeName = true;
7053
+ warned.storeName = true;
6992
7054
  }
6993
7055
 
6994
7056
  options = { storeName: true };
@@ -7021,7 +7083,7 @@ let MagicString$1 = class MagicString {
7021
7083
  first.edit(content, storeName, !overwrite);
7022
7084
  } else {
7023
7085
  // must be inserting at the end
7024
- const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
7086
+ const newChunk = new Chunk(start, end, '').edit(content, storeName);
7025
7087
 
7026
7088
  // TODO last chunk in the array may not be the last chunk, if it's moved...
7027
7089
  last.next = newChunk;
@@ -7104,30 +7166,30 @@ let MagicString$1 = class MagicString {
7104
7166
  }
7105
7167
 
7106
7168
  lastLine() {
7107
- let lineIndex = this.outro.lastIndexOf(n$2);
7169
+ let lineIndex = this.outro.lastIndexOf(n$1);
7108
7170
  if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
7109
7171
  let lineStr = this.outro;
7110
7172
  let chunk = this.lastChunk;
7111
7173
  do {
7112
7174
  if (chunk.outro.length > 0) {
7113
- lineIndex = chunk.outro.lastIndexOf(n$2);
7175
+ lineIndex = chunk.outro.lastIndexOf(n$1);
7114
7176
  if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
7115
7177
  lineStr = chunk.outro + lineStr;
7116
7178
  }
7117
7179
 
7118
7180
  if (chunk.content.length > 0) {
7119
- lineIndex = chunk.content.lastIndexOf(n$2);
7181
+ lineIndex = chunk.content.lastIndexOf(n$1);
7120
7182
  if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
7121
7183
  lineStr = chunk.content + lineStr;
7122
7184
  }
7123
7185
 
7124
7186
  if (chunk.intro.length > 0) {
7125
- lineIndex = chunk.intro.lastIndexOf(n$2);
7187
+ lineIndex = chunk.intro.lastIndexOf(n$1);
7126
7188
  if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
7127
7189
  lineStr = chunk.intro + lineStr;
7128
7190
  }
7129
7191
  } while ((chunk = chunk.previous));
7130
- lineIndex = this.intro.lastIndexOf(n$2);
7192
+ lineIndex = this.intro.lastIndexOf(n$1);
7131
7193
  if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
7132
7194
  return this.intro + lineStr;
7133
7195
  }
@@ -7206,9 +7268,9 @@ let MagicString$1 = class MagicString {
7206
7268
  _splitChunk(chunk, index) {
7207
7269
  if (chunk.edited && chunk.content.length) {
7208
7270
  // zero-length edited chunks are a special case (overlapping replacements)
7209
- const loc = getLocator$1(this.original)(index);
7271
+ const loc = getLocator(this.original)(index);
7210
7272
  throw new Error(
7211
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`
7273
+ `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
7212
7274
  );
7213
7275
  }
7214
7276
 
@@ -7367,7 +7429,7 @@ let MagicString$1 = class MagicString {
7367
7429
  this.overwrite(
7368
7430
  match.index,
7369
7431
  match.index + match[0].length,
7370
- getReplacement(match, this.original)
7432
+ getReplacement(match, this.original),
7371
7433
  );
7372
7434
  });
7373
7435
  } else {
@@ -7376,7 +7438,7 @@ let MagicString$1 = class MagicString {
7376
7438
  this.overwrite(
7377
7439
  match.index,
7378
7440
  match.index + match[0].length,
7379
- getReplacement(match, this.original)
7441
+ getReplacement(match, this.original),
7380
7442
  );
7381
7443
  }
7382
7444
  return this;
@@ -7422,13 +7484,13 @@ let MagicString$1 = class MagicString {
7422
7484
 
7423
7485
  if (!searchValue.global) {
7424
7486
  throw new TypeError(
7425
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument'
7487
+ 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
7426
7488
  );
7427
7489
  }
7428
7490
 
7429
7491
  return this._replaceRegexp(searchValue, replacement);
7430
7492
  }
7431
- };
7493
+ }
7432
7494
 
7433
7495
  function isReference(node, parent) {
7434
7496
  if (node.type === 'MemberExpression') {
@@ -7460,7 +7522,7 @@ function isReference(node, parent) {
7460
7522
  return false;
7461
7523
  }
7462
7524
 
7463
- var version$3 = "25.0.5";
7525
+ var version$3 = "25.0.7";
7464
7526
  var peerDependencies = {
7465
7527
  rollup: "^2.68.0||^3.0.0||^4.0.0"
7466
7528
  };
@@ -7883,7 +7945,7 @@ async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
7883
7945
  return `export { default } from ${JSON.stringify(id)};`;
7884
7946
  }
7885
7947
 
7886
- function getEntryProxy(id, defaultIsModuleExports, getModuleInfo) {
7948
+ function getEntryProxy(id, defaultIsModuleExports, getModuleInfo, shebang) {
7887
7949
  const {
7888
7950
  meta: { commonjs: commonjsMeta },
7889
7951
  hasDefaultExport
@@ -7894,9 +7956,13 @@ function getEntryProxy(id, defaultIsModuleExports, getModuleInfo) {
7894
7956
  if (hasDefaultExport) {
7895
7957
  code += `export { default } from ${stringifiedId};`;
7896
7958
  }
7897
- return code;
7959
+ return shebang + code;
7898
7960
  }
7899
- return getEsImportProxy(id, defaultIsModuleExports);
7961
+ const result = getEsImportProxy(id, defaultIsModuleExports);
7962
+ return {
7963
+ ...result,
7964
+ code: shebang + result.code
7965
+ };
7900
7966
  }
7901
7967
 
7902
7968
  function getEsImportProxy(id, defaultIsModuleExports) {
@@ -8936,7 +9002,7 @@ async function transformCommonjs(
8936
9002
  commonjsMeta
8937
9003
  ) {
8938
9004
  const ast = astCache || tryParse(parse, code, id);
8939
- const magicString = new MagicString$1(code);
9005
+ const magicString = new MagicString(code);
8940
9006
  const uses = {
8941
9007
  module: false,
8942
9008
  exports: false,
@@ -9350,6 +9416,13 @@ async function transformCommonjs(
9350
9416
  magicString.remove(0, commentEnd).trim();
9351
9417
  }
9352
9418
 
9419
+ let shebang = '';
9420
+ if (code.startsWith('#!')) {
9421
+ const shebangEndPosition = code.indexOf('\n') + 1;
9422
+ shebang = code.slice(0, shebangEndPosition);
9423
+ magicString.remove(0, shebangEndPosition).trim();
9424
+ }
9425
+
9353
9426
  const exportMode = isEsModule
9354
9427
  ? 'none'
9355
9428
  : shouldWrap
@@ -9433,14 +9506,14 @@ function ${requireName} () {
9433
9506
 
9434
9507
  magicString
9435
9508
  .trim()
9436
- .prepend(leadingComment + importBlock)
9509
+ .prepend(shebang + leadingComment + importBlock)
9437
9510
  .append(exportBlock);
9438
9511
 
9439
9512
  return {
9440
9513
  code: magicString.toString(),
9441
9514
  map: sourceMap ? magicString.generateMap() : null,
9442
9515
  syntheticNamedExports: isEsModule || usesRequireWrapper ? false : '__moduleExports',
9443
- meta: { commonjs: commonjsMeta }
9516
+ meta: { commonjs: { ...commonjsMeta, shebang } }
9444
9517
  };
9445
9518
  }
9446
9519
 
@@ -9682,7 +9755,16 @@ function commonjs(options = {}) {
9682
9755
  // entry suffix is just appended to not mess up relative external resolution
9683
9756
  if (id.endsWith(ENTRY_SUFFIX)) {
9684
9757
  const acutalId = id.slice(0, -ENTRY_SUFFIX.length);
9685
- return getEntryProxy(acutalId, getDefaultIsModuleExports(acutalId), this.getModuleInfo);
9758
+ const {
9759
+ meta: { commonjs: commonjsMeta }
9760
+ } = this.getModuleInfo(acutalId);
9761
+ const shebang = commonjsMeta?.shebang ?? '';
9762
+ return getEntryProxy(
9763
+ acutalId,
9764
+ getDefaultIsModuleExports(acutalId),
9765
+ this.getModuleInfo,
9766
+ shebang
9767
+ );
9686
9768
  }
9687
9769
 
9688
9770
  if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
@@ -10535,7 +10617,7 @@ function build$2(map, loader, importer, importerDepth) {
10535
10617
  * A SourceMap v3 compatible sourcemap, which only includes fields that were
10536
10618
  * provided to it.
10537
10619
  */
10538
- let SourceMap$1 = class SourceMap {
10620
+ class SourceMap {
10539
10621
  constructor(map, options) {
10540
10622
  const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
10541
10623
  this.version = out.version; // SourceMap spec says this should be first.
@@ -10551,7 +10633,7 @@ let SourceMap$1 = class SourceMap {
10551
10633
  toString() {
10552
10634
  return JSON.stringify(this);
10553
10635
  }
10554
- };
10636
+ }
10555
10637
 
10556
10638
  /**
10557
10639
  * Traces through all the mappings in the root sourcemap, through the sources
@@ -10571,7 +10653,7 @@ let SourceMap$1 = class SourceMap {
10571
10653
  function remapping(input, loader, options) {
10572
10654
  const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };
10573
10655
  const tree = buildSourceMapTree(input, loader);
10574
- return new SourceMap$1(traceMappings(tree), opts);
10656
+ return new SourceMap(traceMappings(tree), opts);
10575
10657
  }
10576
10658
 
10577
10659
  var src$2 = {exports: {}};
@@ -12026,7 +12108,7 @@ const dataUrlRE = /^\s*data:/i;
12026
12108
  const isDataUrl = (url) => dataUrlRE.test(url);
12027
12109
  const virtualModuleRE = /^virtual-module:.*/;
12028
12110
  const virtualModulePrefix = 'virtual-module:';
12029
- const knownJsSrcRE = /\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba)(?:$|\?)/;
12111
+ const knownJsSrcRE = /\.(?:[jt]sx?|m[jt]s|vue|marko|svelte|astro|imba|mdx)(?:$|\?)/;
12030
12112
  const isJSRequest = (url) => {
12031
12113
  url = cleanUrl(url);
12032
12114
  if (knownJsSrcRE.test(url)) {
@@ -12110,7 +12192,7 @@ function prettifyUrl(url, root) {
12110
12192
  return colors$1.dim(url);
12111
12193
  }
12112
12194
  }
12113
- function isObject$2(value) {
12195
+ function isObject$1(value) {
12114
12196
  return Object.prototype.toString.call(value) === '[object Object]';
12115
12197
  }
12116
12198
  function isDefined(value) {
@@ -12653,7 +12735,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
12653
12735
  merged[key] = [...arraify(existing ?? []), ...arraify(value ?? [])];
12654
12736
  continue;
12655
12737
  }
12656
- if (isObject$2(existing) && isObject$2(value)) {
12738
+ if (isObject$1(existing) && isObject$1(value)) {
12657
12739
  merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
12658
12740
  continue;
12659
12741
  }
@@ -12672,7 +12754,7 @@ function mergeAlias(a, b) {
12672
12754
  return b;
12673
12755
  if (!b)
12674
12756
  return a;
12675
- if (isObject$2(a) && isObject$2(b)) {
12757
+ if (isObject$1(a) && isObject$1(b)) {
12676
12758
  return { ...a, ...b };
12677
12759
  }
12678
12760
  // the order is flipped because the alias is resolved from top-down,
@@ -14656,7 +14738,7 @@ async function reloadOnTsconfigChange(changedFile) {
14656
14738
  // clear module graph to remove code compiled with outdated config
14657
14739
  server.moduleGraph.invalidateAll();
14658
14740
  // reset tsconfck so that recompile works with up2date configs
14659
- tsconfckCache.clear();
14741
+ tsconfckCache?.clear();
14660
14742
  // server may not be available if vite config is updated at the same time
14661
14743
  if (server) {
14662
14744
  // force full reload
@@ -14901,1636 +14983,435 @@ var jsonStableStringify = function (obj, opts) {
14901
14983
  var key = keys[i];
14902
14984
  var value = stringify(node, key, node[key], level + 1);
14903
14985
 
14904
- if (!value) { continue; }
14905
-
14906
- var keyValue = json.stringify(key)
14907
- + colonSeparator
14908
- + value;
14909
-
14910
- out.push(indent + space + keyValue);
14911
- }
14912
- seen.splice(seen.indexOf(node), 1);
14913
- return '{' + out.join(',') + indent + '}';
14914
-
14915
- }({ '': obj }, '', obj, 0));
14916
- };
14917
-
14918
- var jsonStableStringify$1 = /*@__PURE__*/getDefaultExportFromCjs(jsonStableStringify);
14919
-
14920
- const mimes$1 = {
14921
- "ez": "application/andrew-inset",
14922
- "aw": "application/applixware",
14923
- "atom": "application/atom+xml",
14924
- "atomcat": "application/atomcat+xml",
14925
- "atomdeleted": "application/atomdeleted+xml",
14926
- "atomsvc": "application/atomsvc+xml",
14927
- "dwd": "application/atsc-dwd+xml",
14928
- "held": "application/atsc-held+xml",
14929
- "rsat": "application/atsc-rsat+xml",
14930
- "bdoc": "application/bdoc",
14931
- "xcs": "application/calendar+xml",
14932
- "ccxml": "application/ccxml+xml",
14933
- "cdfx": "application/cdfx+xml",
14934
- "cdmia": "application/cdmi-capability",
14935
- "cdmic": "application/cdmi-container",
14936
- "cdmid": "application/cdmi-domain",
14937
- "cdmio": "application/cdmi-object",
14938
- "cdmiq": "application/cdmi-queue",
14939
- "cu": "application/cu-seeme",
14940
- "mpd": "application/dash+xml",
14941
- "davmount": "application/davmount+xml",
14942
- "dbk": "application/docbook+xml",
14943
- "dssc": "application/dssc+der",
14944
- "xdssc": "application/dssc+xml",
14945
- "es": "application/ecmascript",
14946
- "ecma": "application/ecmascript",
14947
- "emma": "application/emma+xml",
14948
- "emotionml": "application/emotionml+xml",
14949
- "epub": "application/epub+zip",
14950
- "exi": "application/exi",
14951
- "fdt": "application/fdt+xml",
14952
- "pfr": "application/font-tdpfr",
14953
- "geojson": "application/geo+json",
14954
- "gml": "application/gml+xml",
14955
- "gpx": "application/gpx+xml",
14956
- "gxf": "application/gxf",
14957
- "gz": "application/gzip",
14958
- "hjson": "application/hjson",
14959
- "stk": "application/hyperstudio",
14960
- "ink": "application/inkml+xml",
14961
- "inkml": "application/inkml+xml",
14962
- "ipfix": "application/ipfix",
14963
- "its": "application/its+xml",
14964
- "jar": "application/java-archive",
14965
- "war": "application/java-archive",
14966
- "ear": "application/java-archive",
14967
- "ser": "application/java-serialized-object",
14968
- "class": "application/java-vm",
14969
- "js": "application/javascript",
14970
- "mjs": "application/javascript",
14971
- "json": "application/json",
14972
- "map": "application/json",
14973
- "json5": "application/json5",
14974
- "jsonml": "application/jsonml+json",
14975
- "jsonld": "application/ld+json",
14976
- "lgr": "application/lgr+xml",
14977
- "lostxml": "application/lost+xml",
14978
- "hqx": "application/mac-binhex40",
14979
- "cpt": "application/mac-compactpro",
14980
- "mads": "application/mads+xml",
14981
- "webmanifest": "application/manifest+json",
14982
- "mrc": "application/marc",
14983
- "mrcx": "application/marcxml+xml",
14984
- "ma": "application/mathematica",
14985
- "nb": "application/mathematica",
14986
- "mb": "application/mathematica",
14987
- "mathml": "application/mathml+xml",
14988
- "mbox": "application/mbox",
14989
- "mscml": "application/mediaservercontrol+xml",
14990
- "metalink": "application/metalink+xml",
14991
- "meta4": "application/metalink4+xml",
14992
- "mets": "application/mets+xml",
14993
- "maei": "application/mmt-aei+xml",
14994
- "musd": "application/mmt-usd+xml",
14995
- "mods": "application/mods+xml",
14996
- "m21": "application/mp21",
14997
- "mp21": "application/mp21",
14998
- "mp4s": "application/mp4",
14999
- "m4p": "application/mp4",
15000
- "doc": "application/msword",
15001
- "dot": "application/msword",
15002
- "mxf": "application/mxf",
15003
- "nq": "application/n-quads",
15004
- "nt": "application/n-triples",
15005
- "cjs": "application/node",
15006
- "bin": "application/octet-stream",
15007
- "dms": "application/octet-stream",
15008
- "lrf": "application/octet-stream",
15009
- "mar": "application/octet-stream",
15010
- "so": "application/octet-stream",
15011
- "dist": "application/octet-stream",
15012
- "distz": "application/octet-stream",
15013
- "pkg": "application/octet-stream",
15014
- "bpk": "application/octet-stream",
15015
- "dump": "application/octet-stream",
15016
- "elc": "application/octet-stream",
15017
- "deploy": "application/octet-stream",
15018
- "exe": "application/octet-stream",
15019
- "dll": "application/octet-stream",
15020
- "deb": "application/octet-stream",
15021
- "dmg": "application/octet-stream",
15022
- "iso": "application/octet-stream",
15023
- "img": "application/octet-stream",
15024
- "msi": "application/octet-stream",
15025
- "msp": "application/octet-stream",
15026
- "msm": "application/octet-stream",
15027
- "buffer": "application/octet-stream",
15028
- "oda": "application/oda",
15029
- "opf": "application/oebps-package+xml",
15030
- "ogx": "application/ogg",
15031
- "omdoc": "application/omdoc+xml",
15032
- "onetoc": "application/onenote",
15033
- "onetoc2": "application/onenote",
15034
- "onetmp": "application/onenote",
15035
- "onepkg": "application/onenote",
15036
- "oxps": "application/oxps",
15037
- "relo": "application/p2p-overlay+xml",
15038
- "xer": "application/patch-ops-error+xml",
15039
- "pdf": "application/pdf",
15040
- "pgp": "application/pgp-encrypted",
15041
- "asc": "application/pgp-signature",
15042
- "sig": "application/pgp-signature",
15043
- "prf": "application/pics-rules",
15044
- "p10": "application/pkcs10",
15045
- "p7m": "application/pkcs7-mime",
15046
- "p7c": "application/pkcs7-mime",
15047
- "p7s": "application/pkcs7-signature",
15048
- "p8": "application/pkcs8",
15049
- "ac": "application/pkix-attr-cert",
15050
- "cer": "application/pkix-cert",
15051
- "crl": "application/pkix-crl",
15052
- "pkipath": "application/pkix-pkipath",
15053
- "pki": "application/pkixcmp",
15054
- "pls": "application/pls+xml",
15055
- "ai": "application/postscript",
15056
- "eps": "application/postscript",
15057
- "ps": "application/postscript",
15058
- "provx": "application/provenance+xml",
15059
- "cww": "application/prs.cww",
15060
- "pskcxml": "application/pskc+xml",
15061
- "raml": "application/raml+yaml",
15062
- "rdf": "application/rdf+xml",
15063
- "owl": "application/rdf+xml",
15064
- "rif": "application/reginfo+xml",
15065
- "rnc": "application/relax-ng-compact-syntax",
15066
- "rl": "application/resource-lists+xml",
15067
- "rld": "application/resource-lists-diff+xml",
15068
- "rs": "application/rls-services+xml",
15069
- "rapd": "application/route-apd+xml",
15070
- "sls": "application/route-s-tsid+xml",
15071
- "rusd": "application/route-usd+xml",
15072
- "gbr": "application/rpki-ghostbusters",
15073
- "mft": "application/rpki-manifest",
15074
- "roa": "application/rpki-roa",
15075
- "rsd": "application/rsd+xml",
15076
- "rss": "application/rss+xml",
15077
- "rtf": "application/rtf",
15078
- "sbml": "application/sbml+xml",
15079
- "scq": "application/scvp-cv-request",
15080
- "scs": "application/scvp-cv-response",
15081
- "spq": "application/scvp-vp-request",
15082
- "spp": "application/scvp-vp-response",
15083
- "sdp": "application/sdp",
15084
- "senmlx": "application/senml+xml",
15085
- "sensmlx": "application/sensml+xml",
15086
- "setpay": "application/set-payment-initiation",
15087
- "setreg": "application/set-registration-initiation",
15088
- "shf": "application/shf+xml",
15089
- "siv": "application/sieve",
15090
- "sieve": "application/sieve",
15091
- "smi": "application/smil+xml",
15092
- "smil": "application/smil+xml",
15093
- "rq": "application/sparql-query",
15094
- "srx": "application/sparql-results+xml",
15095
- "gram": "application/srgs",
15096
- "grxml": "application/srgs+xml",
15097
- "sru": "application/sru+xml",
15098
- "ssdl": "application/ssdl+xml",
15099
- "ssml": "application/ssml+xml",
15100
- "swidtag": "application/swid+xml",
15101
- "tei": "application/tei+xml",
15102
- "teicorpus": "application/tei+xml",
15103
- "tfi": "application/thraud+xml",
15104
- "tsd": "application/timestamped-data",
15105
- "toml": "application/toml",
15106
- "trig": "application/trig",
15107
- "ttml": "application/ttml+xml",
15108
- "ubj": "application/ubjson",
15109
- "rsheet": "application/urc-ressheet+xml",
15110
- "td": "application/urc-targetdesc+xml",
15111
- "vxml": "application/voicexml+xml",
15112
- "wasm": "application/wasm",
15113
- "wgt": "application/widget",
15114
- "hlp": "application/winhlp",
15115
- "wsdl": "application/wsdl+xml",
15116
- "wspolicy": "application/wspolicy+xml",
15117
- "xaml": "application/xaml+xml",
15118
- "xav": "application/xcap-att+xml",
15119
- "xca": "application/xcap-caps+xml",
15120
- "xdf": "application/xcap-diff+xml",
15121
- "xel": "application/xcap-el+xml",
15122
- "xns": "application/xcap-ns+xml",
15123
- "xenc": "application/xenc+xml",
15124
- "xhtml": "application/xhtml+xml",
15125
- "xht": "application/xhtml+xml",
15126
- "xlf": "application/xliff+xml",
15127
- "xml": "application/xml",
15128
- "xsl": "application/xml",
15129
- "xsd": "application/xml",
15130
- "rng": "application/xml",
15131
- "dtd": "application/xml-dtd",
15132
- "xop": "application/xop+xml",
15133
- "xpl": "application/xproc+xml",
15134
- "xslt": "application/xml",
15135
- "xspf": "application/xspf+xml",
15136
- "mxml": "application/xv+xml",
15137
- "xhvml": "application/xv+xml",
15138
- "xvml": "application/xv+xml",
15139
- "xvm": "application/xv+xml",
15140
- "yang": "application/yang",
15141
- "yin": "application/yin+xml",
15142
- "zip": "application/zip",
15143
- "3gpp": "video/3gpp",
15144
- "adp": "audio/adpcm",
15145
- "amr": "audio/amr",
15146
- "au": "audio/basic",
15147
- "snd": "audio/basic",
15148
- "mid": "audio/midi",
15149
- "midi": "audio/midi",
15150
- "kar": "audio/midi",
15151
- "rmi": "audio/midi",
15152
- "mxmf": "audio/mobile-xmf",
15153
- "mp3": "audio/mpeg",
15154
- "m4a": "audio/mp4",
15155
- "mp4a": "audio/mp4",
15156
- "mpga": "audio/mpeg",
15157
- "mp2": "audio/mpeg",
15158
- "mp2a": "audio/mpeg",
15159
- "m2a": "audio/mpeg",
15160
- "m3a": "audio/mpeg",
15161
- "oga": "audio/ogg",
15162
- "ogg": "audio/ogg",
15163
- "spx": "audio/ogg",
15164
- "opus": "audio/ogg",
15165
- "s3m": "audio/s3m",
15166
- "sil": "audio/silk",
15167
- "wav": "audio/wav",
15168
- "weba": "audio/webm",
15169
- "xm": "audio/xm",
15170
- "ttc": "font/collection",
15171
- "otf": "font/otf",
15172
- "ttf": "font/ttf",
15173
- "woff": "font/woff",
15174
- "woff2": "font/woff2",
15175
- "exr": "image/aces",
15176
- "apng": "image/apng",
15177
- "avif": "image/avif",
15178
- "bmp": "image/bmp",
15179
- "cgm": "image/cgm",
15180
- "drle": "image/dicom-rle",
15181
- "emf": "image/emf",
15182
- "fits": "image/fits",
15183
- "g3": "image/g3fax",
15184
- "gif": "image/gif",
15185
- "heic": "image/heic",
15186
- "heics": "image/heic-sequence",
15187
- "heif": "image/heif",
15188
- "heifs": "image/heif-sequence",
15189
- "hej2": "image/hej2k",
15190
- "hsj2": "image/hsj2",
15191
- "ief": "image/ief",
15192
- "jls": "image/jls",
15193
- "jp2": "image/jp2",
15194
- "jpg2": "image/jp2",
15195
- "jpeg": "image/jpeg",
15196
- "jpg": "image/jpeg",
15197
- "jpe": "image/jpeg",
15198
- "jph": "image/jph",
15199
- "jhc": "image/jphc",
15200
- "jpm": "image/jpm",
15201
- "jpx": "image/jpx",
15202
- "jpf": "image/jpx",
15203
- "jxr": "image/jxr",
15204
- "jxra": "image/jxra",
15205
- "jxrs": "image/jxrs",
15206
- "jxs": "image/jxs",
15207
- "jxsc": "image/jxsc",
15208
- "jxsi": "image/jxsi",
15209
- "jxss": "image/jxss",
15210
- "ktx": "image/ktx",
15211
- "ktx2": "image/ktx2",
15212
- "png": "image/png",
15213
- "btif": "image/prs.btif",
15214
- "pti": "image/prs.pti",
15215
- "sgi": "image/sgi",
15216
- "svg": "image/svg+xml",
15217
- "svgz": "image/svg+xml",
15218
- "t38": "image/t38",
15219
- "tif": "image/tiff",
15220
- "tiff": "image/tiff",
15221
- "tfx": "image/tiff-fx",
15222
- "webp": "image/webp",
15223
- "wmf": "image/wmf",
15224
- "disposition-notification": "message/disposition-notification",
15225
- "u8msg": "message/global",
15226
- "u8dsn": "message/global-delivery-status",
15227
- "u8mdn": "message/global-disposition-notification",
15228
- "u8hdr": "message/global-headers",
15229
- "eml": "message/rfc822",
15230
- "mime": "message/rfc822",
15231
- "3mf": "model/3mf",
15232
- "gltf": "model/gltf+json",
15233
- "glb": "model/gltf-binary",
15234
- "igs": "model/iges",
15235
- "iges": "model/iges",
15236
- "msh": "model/mesh",
15237
- "mesh": "model/mesh",
15238
- "silo": "model/mesh",
15239
- "mtl": "model/mtl",
15240
- "obj": "model/obj",
15241
- "stpz": "model/step+zip",
15242
- "stpxz": "model/step-xml+zip",
15243
- "stl": "model/stl",
15244
- "wrl": "model/vrml",
15245
- "vrml": "model/vrml",
15246
- "x3db": "model/x3d+fastinfoset",
15247
- "x3dbz": "model/x3d+binary",
15248
- "x3dv": "model/x3d-vrml",
15249
- "x3dvz": "model/x3d+vrml",
15250
- "x3d": "model/x3d+xml",
15251
- "x3dz": "model/x3d+xml",
15252
- "appcache": "text/cache-manifest",
15253
- "manifest": "text/cache-manifest",
15254
- "ics": "text/calendar",
15255
- "ifb": "text/calendar",
15256
- "coffee": "text/coffeescript",
15257
- "litcoffee": "text/coffeescript",
15258
- "css": "text/css",
15259
- "csv": "text/csv",
15260
- "html": "text/html",
15261
- "htm": "text/html",
15262
- "shtml": "text/html",
15263
- "jade": "text/jade",
15264
- "jsx": "text/jsx",
15265
- "less": "text/less",
15266
- "markdown": "text/markdown",
15267
- "md": "text/markdown",
15268
- "mml": "text/mathml",
15269
- "mdx": "text/mdx",
15270
- "n3": "text/n3",
15271
- "txt": "text/plain",
15272
- "text": "text/plain",
15273
- "conf": "text/plain",
15274
- "def": "text/plain",
15275
- "list": "text/plain",
15276
- "log": "text/plain",
15277
- "in": "text/plain",
15278
- "ini": "text/plain",
15279
- "dsc": "text/prs.lines.tag",
15280
- "rtx": "text/richtext",
15281
- "sgml": "text/sgml",
15282
- "sgm": "text/sgml",
15283
- "shex": "text/shex",
15284
- "slim": "text/slim",
15285
- "slm": "text/slim",
15286
- "spdx": "text/spdx",
15287
- "stylus": "text/stylus",
15288
- "styl": "text/stylus",
15289
- "tsv": "text/tab-separated-values",
15290
- "t": "text/troff",
15291
- "tr": "text/troff",
15292
- "roff": "text/troff",
15293
- "man": "text/troff",
15294
- "me": "text/troff",
15295
- "ms": "text/troff",
15296
- "ttl": "text/turtle",
15297
- "uri": "text/uri-list",
15298
- "uris": "text/uri-list",
15299
- "urls": "text/uri-list",
15300
- "vcard": "text/vcard",
15301
- "vtt": "text/vtt",
15302
- "yaml": "text/yaml",
15303
- "yml": "text/yaml",
15304
- "3gp": "video/3gpp",
15305
- "3g2": "video/3gpp2",
15306
- "h261": "video/h261",
15307
- "h263": "video/h263",
15308
- "h264": "video/h264",
15309
- "m4s": "video/iso.segment",
15310
- "jpgv": "video/jpeg",
15311
- "jpgm": "image/jpm",
15312
- "mj2": "video/mj2",
15313
- "mjp2": "video/mj2",
15314
- "ts": "video/mp2t",
15315
- "mp4": "video/mp4",
15316
- "mp4v": "video/mp4",
15317
- "mpg4": "video/mp4",
15318
- "mpeg": "video/mpeg",
15319
- "mpg": "video/mpeg",
15320
- "mpe": "video/mpeg",
15321
- "m1v": "video/mpeg",
15322
- "m2v": "video/mpeg",
15323
- "ogv": "video/ogg",
15324
- "qt": "video/quicktime",
15325
- "mov": "video/quicktime",
15326
- "webm": "video/webm"
15327
- };
15328
-
15329
- function lookup(extn) {
15330
- let tmp = ('' + extn).trim().toLowerCase();
15331
- let idx = tmp.lastIndexOf('.');
15332
- return mimes$1[!~idx ? tmp : tmp.substring(++idx)];
15333
- }
15334
-
15335
- class BitSet {
15336
- constructor(arg) {
15337
- this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
15338
- }
15339
-
15340
- add(n) {
15341
- this.bits[n >> 5] |= 1 << (n & 31);
15342
- }
15343
-
15344
- has(n) {
15345
- return !!(this.bits[n >> 5] & (1 << (n & 31)));
15346
- }
15347
- }
15348
-
15349
- class Chunk {
15350
- constructor(start, end, content) {
15351
- this.start = start;
15352
- this.end = end;
15353
- this.original = content;
15354
-
15355
- this.intro = '';
15356
- this.outro = '';
15357
-
15358
- this.content = content;
15359
- this.storeName = false;
15360
- this.edited = false;
15361
-
15362
- {
15363
- this.previous = null;
15364
- this.next = null;
15365
- }
15366
- }
15367
-
15368
- appendLeft(content) {
15369
- this.outro += content;
15370
- }
15371
-
15372
- appendRight(content) {
15373
- this.intro = this.intro + content;
15374
- }
15375
-
15376
- clone() {
15377
- const chunk = new Chunk(this.start, this.end, this.original);
15378
-
15379
- chunk.intro = this.intro;
15380
- chunk.outro = this.outro;
15381
- chunk.content = this.content;
15382
- chunk.storeName = this.storeName;
15383
- chunk.edited = this.edited;
15384
-
15385
- return chunk;
15386
- }
15387
-
15388
- contains(index) {
15389
- return this.start < index && index < this.end;
15390
- }
15391
-
15392
- eachNext(fn) {
15393
- let chunk = this;
15394
- while (chunk) {
15395
- fn(chunk);
15396
- chunk = chunk.next;
15397
- }
15398
- }
15399
-
15400
- eachPrevious(fn) {
15401
- let chunk = this;
15402
- while (chunk) {
15403
- fn(chunk);
15404
- chunk = chunk.previous;
15405
- }
15406
- }
15407
-
15408
- edit(content, storeName, contentOnly) {
15409
- this.content = content;
15410
- if (!contentOnly) {
15411
- this.intro = '';
15412
- this.outro = '';
15413
- }
15414
- this.storeName = storeName;
15415
-
15416
- this.edited = true;
15417
-
15418
- return this;
15419
- }
15420
-
15421
- prependLeft(content) {
15422
- this.outro = content + this.outro;
15423
- }
15424
-
15425
- prependRight(content) {
15426
- this.intro = content + this.intro;
15427
- }
15428
-
15429
- split(index) {
15430
- const sliceIndex = index - this.start;
15431
-
15432
- const originalBefore = this.original.slice(0, sliceIndex);
15433
- const originalAfter = this.original.slice(sliceIndex);
15434
-
15435
- this.original = originalBefore;
15436
-
15437
- const newChunk = new Chunk(index, this.end, originalAfter);
15438
- newChunk.outro = this.outro;
15439
- this.outro = '';
15440
-
15441
- this.end = index;
15442
-
15443
- if (this.edited) {
15444
- // after split we should save the edit content record into the correct chunk
15445
- // to make sure sourcemap correct
15446
- // For example:
15447
- // ' test'.trim()
15448
- // split -> ' ' + 'test'
15449
- // ✔️ edit -> '' + 'test'
15450
- // ✖️ edit -> 'test' + ''
15451
- // TODO is this block necessary?...
15452
- newChunk.edit('', false);
15453
- this.content = '';
15454
- } else {
15455
- this.content = originalBefore;
15456
- }
15457
-
15458
- newChunk.next = this.next;
15459
- if (newChunk.next) newChunk.next.previous = newChunk;
15460
- newChunk.previous = this;
15461
- this.next = newChunk;
15462
-
15463
- return newChunk;
15464
- }
15465
-
15466
- toString() {
15467
- return this.intro + this.content + this.outro;
15468
- }
15469
-
15470
- trimEnd(rx) {
15471
- this.outro = this.outro.replace(rx, '');
15472
- if (this.outro.length) return true;
15473
-
15474
- const trimmed = this.content.replace(rx, '');
15475
-
15476
- if (trimmed.length) {
15477
- if (trimmed !== this.content) {
15478
- this.split(this.start + trimmed.length).edit('', undefined, true);
15479
- if (this.edited) {
15480
- // save the change, if it has been edited
15481
- this.edit(trimmed, this.storeName, true);
15482
- }
15483
- }
15484
- return true;
15485
- } else {
15486
- this.edit('', undefined, true);
15487
-
15488
- this.intro = this.intro.replace(rx, '');
15489
- if (this.intro.length) return true;
15490
- }
15491
- }
15492
-
15493
- trimStart(rx) {
15494
- this.intro = this.intro.replace(rx, '');
15495
- if (this.intro.length) return true;
15496
-
15497
- const trimmed = this.content.replace(rx, '');
15498
-
15499
- if (trimmed.length) {
15500
- if (trimmed !== this.content) {
15501
- const newChunk = this.split(this.end - trimmed.length);
15502
- if (this.edited) {
15503
- // save the change, if it has been edited
15504
- newChunk.edit(trimmed, this.storeName, true);
15505
- }
15506
- this.edit('', undefined, true);
15507
- }
15508
- return true;
15509
- } else {
15510
- this.edit('', undefined, true);
15511
-
15512
- this.outro = this.outro.replace(rx, '');
15513
- if (this.outro.length) return true;
15514
- }
15515
- }
15516
- }
15517
-
15518
- function getBtoa() {
15519
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
15520
- return (str) => window.btoa(unescape(encodeURIComponent(str)));
15521
- } else if (typeof Buffer === 'function') {
15522
- return (str) => Buffer.from(str, 'utf-8').toString('base64');
15523
- } else {
15524
- return () => {
15525
- throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
15526
- };
15527
- }
15528
- }
15529
-
15530
- const btoa$1 = /*#__PURE__*/ getBtoa();
15531
-
15532
- class SourceMap {
15533
- constructor(properties) {
15534
- this.version = 3;
15535
- this.file = properties.file;
15536
- this.sources = properties.sources;
15537
- this.sourcesContent = properties.sourcesContent;
15538
- this.names = properties.names;
15539
- this.mappings = encode$1(properties.mappings);
15540
- if (typeof properties.x_google_ignoreList !== 'undefined') {
15541
- this.x_google_ignoreList = properties.x_google_ignoreList;
15542
- }
15543
- }
15544
-
15545
- toString() {
15546
- return JSON.stringify(this);
15547
- }
15548
-
15549
- toUrl() {
15550
- return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
15551
- }
15552
- }
15553
-
15554
- function guessIndent(code) {
15555
- const lines = code.split('\n');
15556
-
15557
- const tabbed = lines.filter((line) => /^\t+/.test(line));
15558
- const spaced = lines.filter((line) => /^ {2,}/.test(line));
15559
-
15560
- if (tabbed.length === 0 && spaced.length === 0) {
15561
- return null;
15562
- }
15563
-
15564
- // More lines tabbed than spaced? Assume tabs, and
15565
- // default to tabs in the case of a tie (or nothing
15566
- // to go on)
15567
- if (tabbed.length >= spaced.length) {
15568
- return '\t';
15569
- }
15570
-
15571
- // Otherwise, we need to guess the multiple
15572
- const min = spaced.reduce((previous, current) => {
15573
- const numSpaces = /^ +/.exec(current)[0].length;
15574
- return Math.min(numSpaces, previous);
15575
- }, Infinity);
15576
-
15577
- return new Array(min + 1).join(' ');
15578
- }
15579
-
15580
- function getRelativePath(from, to) {
15581
- const fromParts = from.split(/[/\\]/);
15582
- const toParts = to.split(/[/\\]/);
15583
-
15584
- fromParts.pop(); // get dirname
15585
-
15586
- while (fromParts[0] === toParts[0]) {
15587
- fromParts.shift();
15588
- toParts.shift();
15589
- }
15590
-
15591
- if (fromParts.length) {
15592
- let i = fromParts.length;
15593
- while (i--) fromParts[i] = '..';
15594
- }
15595
-
15596
- return fromParts.concat(toParts).join('/');
15597
- }
15598
-
15599
- const toString$2 = Object.prototype.toString;
15600
-
15601
- function isObject$1(thing) {
15602
- return toString$2.call(thing) === '[object Object]';
15603
- }
15604
-
15605
- function getLocator(source) {
15606
- const originalLines = source.split('\n');
15607
- const lineOffsets = [];
15608
-
15609
- for (let i = 0, pos = 0; i < originalLines.length; i++) {
15610
- lineOffsets.push(pos);
15611
- pos += originalLines[i].length + 1;
15612
- }
15613
-
15614
- return function locate(index) {
15615
- let i = 0;
15616
- let j = lineOffsets.length;
15617
- while (i < j) {
15618
- const m = (i + j) >> 1;
15619
- if (index < lineOffsets[m]) {
15620
- j = m;
15621
- } else {
15622
- i = m + 1;
15623
- }
15624
- }
15625
- const line = i - 1;
15626
- const column = index - lineOffsets[line];
15627
- return { line, column };
15628
- };
15629
- }
15630
-
15631
- const wordRegex = /\w/;
15632
-
15633
- class Mappings {
15634
- constructor(hires) {
15635
- this.hires = hires;
15636
- this.generatedCodeLine = 0;
15637
- this.generatedCodeColumn = 0;
15638
- this.raw = [];
15639
- this.rawSegments = this.raw[this.generatedCodeLine] = [];
15640
- this.pending = null;
15641
- }
15642
-
15643
- addEdit(sourceIndex, content, loc, nameIndex) {
15644
- if (content.length) {
15645
- let contentLineEnd = content.indexOf('\n', 0);
15646
- let previousContentLineEnd = -1;
15647
- while (contentLineEnd >= 0) {
15648
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
15649
- if (nameIndex >= 0) {
15650
- segment.push(nameIndex);
15651
- }
15652
- this.rawSegments.push(segment);
15653
-
15654
- this.generatedCodeLine += 1;
15655
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
15656
- this.generatedCodeColumn = 0;
15657
-
15658
- previousContentLineEnd = contentLineEnd;
15659
- contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
15660
- }
15661
-
15662
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
15663
- if (nameIndex >= 0) {
15664
- segment.push(nameIndex);
15665
- }
15666
- this.rawSegments.push(segment);
15667
-
15668
- this.advance(content.slice(previousContentLineEnd + 1));
15669
- } else if (this.pending) {
15670
- this.rawSegments.push(this.pending);
15671
- this.advance(content);
15672
- }
15673
-
15674
- this.pending = null;
15675
- }
15676
-
15677
- addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
15678
- let originalCharIndex = chunk.start;
15679
- let first = true;
15680
- // when iterating each char, check if it's in a word boundary
15681
- let charInHiresBoundary = false;
15682
-
15683
- while (originalCharIndex < chunk.end) {
15684
- if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
15685
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
15686
-
15687
- if (this.hires === 'boundary') {
15688
- // in hires "boundary", group segments per word boundary than per char
15689
- if (wordRegex.test(original[originalCharIndex])) {
15690
- // for first char in the boundary found, start the boundary by pushing a segment
15691
- if (!charInHiresBoundary) {
15692
- this.rawSegments.push(segment);
15693
- charInHiresBoundary = true;
15694
- }
15695
- } else {
15696
- // for non-word char, end the boundary by pushing a segment
15697
- this.rawSegments.push(segment);
15698
- charInHiresBoundary = false;
15699
- }
15700
- } else {
15701
- this.rawSegments.push(segment);
15702
- }
15703
- }
15704
-
15705
- if (original[originalCharIndex] === '\n') {
15706
- loc.line += 1;
15707
- loc.column = 0;
15708
- this.generatedCodeLine += 1;
15709
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
15710
- this.generatedCodeColumn = 0;
15711
- first = true;
15712
- } else {
15713
- loc.column += 1;
15714
- this.generatedCodeColumn += 1;
15715
- first = false;
15716
- }
15717
-
15718
- originalCharIndex += 1;
15719
- }
15720
-
15721
- this.pending = null;
15722
- }
15723
-
15724
- advance(str) {
15725
- if (!str) return;
15726
-
15727
- const lines = str.split('\n');
15728
-
15729
- if (lines.length > 1) {
15730
- for (let i = 0; i < lines.length - 1; i++) {
15731
- this.generatedCodeLine++;
15732
- this.raw[this.generatedCodeLine] = this.rawSegments = [];
15733
- }
15734
- this.generatedCodeColumn = 0;
15735
- }
15736
-
15737
- this.generatedCodeColumn += lines[lines.length - 1].length;
15738
- }
15739
- }
15740
-
15741
- const n$1 = '\n';
15742
-
15743
- const warned = {
15744
- insertLeft: false,
15745
- insertRight: false,
15746
- storeName: false,
15747
- };
15748
-
15749
- class MagicString {
15750
- constructor(string, options = {}) {
15751
- const chunk = new Chunk(0, string.length, string);
15752
-
15753
- Object.defineProperties(this, {
15754
- original: { writable: true, value: string },
15755
- outro: { writable: true, value: '' },
15756
- intro: { writable: true, value: '' },
15757
- firstChunk: { writable: true, value: chunk },
15758
- lastChunk: { writable: true, value: chunk },
15759
- lastSearchedChunk: { writable: true, value: chunk },
15760
- byStart: { writable: true, value: {} },
15761
- byEnd: { writable: true, value: {} },
15762
- filename: { writable: true, value: options.filename },
15763
- indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
15764
- sourcemapLocations: { writable: true, value: new BitSet() },
15765
- storedNames: { writable: true, value: {} },
15766
- indentStr: { writable: true, value: undefined },
15767
- ignoreList: { writable: true, value: options.ignoreList },
15768
- });
15769
-
15770
- this.byStart[0] = chunk;
15771
- this.byEnd[string.length] = chunk;
15772
- }
15773
-
15774
- addSourcemapLocation(char) {
15775
- this.sourcemapLocations.add(char);
15776
- }
15777
-
15778
- append(content) {
15779
- if (typeof content !== 'string') throw new TypeError('outro content must be a string');
15780
-
15781
- this.outro += content;
15782
- return this;
15783
- }
15784
-
15785
- appendLeft(index, content) {
15786
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
15787
-
15788
- this._split(index);
15789
-
15790
- const chunk = this.byEnd[index];
15791
-
15792
- if (chunk) {
15793
- chunk.appendLeft(content);
15794
- } else {
15795
- this.intro += content;
15796
- }
15797
- return this;
15798
- }
15799
-
15800
- appendRight(index, content) {
15801
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
15802
-
15803
- this._split(index);
15804
-
15805
- const chunk = this.byStart[index];
15806
-
15807
- if (chunk) {
15808
- chunk.appendRight(content);
15809
- } else {
15810
- this.outro += content;
15811
- }
15812
- return this;
15813
- }
15814
-
15815
- clone() {
15816
- const cloned = new MagicString(this.original, { filename: this.filename });
15817
-
15818
- let originalChunk = this.firstChunk;
15819
- let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
15820
-
15821
- while (originalChunk) {
15822
- cloned.byStart[clonedChunk.start] = clonedChunk;
15823
- cloned.byEnd[clonedChunk.end] = clonedChunk;
15824
-
15825
- const nextOriginalChunk = originalChunk.next;
15826
- const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
15827
-
15828
- if (nextClonedChunk) {
15829
- clonedChunk.next = nextClonedChunk;
15830
- nextClonedChunk.previous = clonedChunk;
15831
-
15832
- clonedChunk = nextClonedChunk;
15833
- }
15834
-
15835
- originalChunk = nextOriginalChunk;
15836
- }
15837
-
15838
- cloned.lastChunk = clonedChunk;
15839
-
15840
- if (this.indentExclusionRanges) {
15841
- cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
15842
- }
15843
-
15844
- cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
15845
-
15846
- cloned.intro = this.intro;
15847
- cloned.outro = this.outro;
15848
-
15849
- return cloned;
15850
- }
15851
-
15852
- generateDecodedMap(options) {
15853
- options = options || {};
15854
-
15855
- const sourceIndex = 0;
15856
- const names = Object.keys(this.storedNames);
15857
- const mappings = new Mappings(options.hires);
15858
-
15859
- const locate = getLocator(this.original);
15860
-
15861
- if (this.intro) {
15862
- mappings.advance(this.intro);
15863
- }
15864
-
15865
- this.firstChunk.eachNext((chunk) => {
15866
- const loc = locate(chunk.start);
15867
-
15868
- if (chunk.intro.length) mappings.advance(chunk.intro);
15869
-
15870
- if (chunk.edited) {
15871
- mappings.addEdit(
15872
- sourceIndex,
15873
- chunk.content,
15874
- loc,
15875
- chunk.storeName ? names.indexOf(chunk.original) : -1,
15876
- );
15877
- } else {
15878
- mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
15879
- }
15880
-
15881
- if (chunk.outro.length) mappings.advance(chunk.outro);
15882
- });
15883
-
15884
- return {
15885
- file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
15886
- sources: [
15887
- options.source ? getRelativePath(options.file || '', options.source) : options.file || '',
15888
- ],
15889
- sourcesContent: options.includeContent ? [this.original] : undefined,
15890
- names,
15891
- mappings: mappings.raw,
15892
- x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined,
15893
- };
15894
- }
15895
-
15896
- generateMap(options) {
15897
- return new SourceMap(this.generateDecodedMap(options));
15898
- }
15899
-
15900
- _ensureindentStr() {
15901
- if (this.indentStr === undefined) {
15902
- this.indentStr = guessIndent(this.original);
15903
- }
15904
- }
15905
-
15906
- _getRawIndentString() {
15907
- this._ensureindentStr();
15908
- return this.indentStr;
15909
- }
15910
-
15911
- getIndentString() {
15912
- this._ensureindentStr();
15913
- return this.indentStr === null ? '\t' : this.indentStr;
15914
- }
15915
-
15916
- indent(indentStr, options) {
15917
- const pattern = /^[^\r\n]/gm;
15918
-
15919
- if (isObject$1(indentStr)) {
15920
- options = indentStr;
15921
- indentStr = undefined;
15922
- }
15923
-
15924
- if (indentStr === undefined) {
15925
- this._ensureindentStr();
15926
- indentStr = this.indentStr || '\t';
15927
- }
15928
-
15929
- if (indentStr === '') return this; // noop
15930
-
15931
- options = options || {};
15932
-
15933
- // Process exclusion ranges
15934
- const isExcluded = {};
15935
-
15936
- if (options.exclude) {
15937
- const exclusions =
15938
- typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
15939
- exclusions.forEach((exclusion) => {
15940
- for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
15941
- isExcluded[i] = true;
15942
- }
15943
- });
15944
- }
15945
-
15946
- let shouldIndentNextCharacter = options.indentStart !== false;
15947
- const replacer = (match) => {
15948
- if (shouldIndentNextCharacter) return `${indentStr}${match}`;
15949
- shouldIndentNextCharacter = true;
15950
- return match;
15951
- };
15952
-
15953
- this.intro = this.intro.replace(pattern, replacer);
15954
-
15955
- let charIndex = 0;
15956
- let chunk = this.firstChunk;
15957
-
15958
- while (chunk) {
15959
- const end = chunk.end;
15960
-
15961
- if (chunk.edited) {
15962
- if (!isExcluded[charIndex]) {
15963
- chunk.content = chunk.content.replace(pattern, replacer);
15964
-
15965
- if (chunk.content.length) {
15966
- shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
15967
- }
15968
- }
15969
- } else {
15970
- charIndex = chunk.start;
15971
-
15972
- while (charIndex < end) {
15973
- if (!isExcluded[charIndex]) {
15974
- const char = this.original[charIndex];
15975
-
15976
- if (char === '\n') {
15977
- shouldIndentNextCharacter = true;
15978
- } else if (char !== '\r' && shouldIndentNextCharacter) {
15979
- shouldIndentNextCharacter = false;
15980
-
15981
- if (charIndex === chunk.start) {
15982
- chunk.prependRight(indentStr);
15983
- } else {
15984
- this._splitChunk(chunk, charIndex);
15985
- chunk = chunk.next;
15986
- chunk.prependRight(indentStr);
15987
- }
15988
- }
15989
- }
15990
-
15991
- charIndex += 1;
15992
- }
15993
- }
15994
-
15995
- charIndex = chunk.end;
15996
- chunk = chunk.next;
15997
- }
15998
-
15999
- this.outro = this.outro.replace(pattern, replacer);
16000
-
16001
- return this;
16002
- }
16003
-
16004
- insert() {
16005
- throw new Error(
16006
- 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
16007
- );
16008
- }
16009
-
16010
- insertLeft(index, content) {
16011
- if (!warned.insertLeft) {
16012
- console.warn(
16013
- 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
16014
- ); // eslint-disable-line no-console
16015
- warned.insertLeft = true;
16016
- }
16017
-
16018
- return this.appendLeft(index, content);
16019
- }
16020
-
16021
- insertRight(index, content) {
16022
- if (!warned.insertRight) {
16023
- console.warn(
16024
- 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
16025
- ); // eslint-disable-line no-console
16026
- warned.insertRight = true;
16027
- }
16028
-
16029
- return this.prependRight(index, content);
16030
- }
16031
-
16032
- move(start, end, index) {
16033
- if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
16034
-
16035
- this._split(start);
16036
- this._split(end);
16037
- this._split(index);
16038
-
16039
- const first = this.byStart[start];
16040
- const last = this.byEnd[end];
16041
-
16042
- const oldLeft = first.previous;
16043
- const oldRight = last.next;
16044
-
16045
- const newRight = this.byStart[index];
16046
- if (!newRight && last === this.lastChunk) return this;
16047
- const newLeft = newRight ? newRight.previous : this.lastChunk;
16048
-
16049
- if (oldLeft) oldLeft.next = oldRight;
16050
- if (oldRight) oldRight.previous = oldLeft;
16051
-
16052
- if (newLeft) newLeft.next = first;
16053
- if (newRight) newRight.previous = last;
16054
-
16055
- if (!first.previous) this.firstChunk = last.next;
16056
- if (!last.next) {
16057
- this.lastChunk = first.previous;
16058
- this.lastChunk.next = null;
16059
- }
16060
-
16061
- first.previous = newLeft;
16062
- last.next = newRight || null;
16063
-
16064
- if (!newLeft) this.firstChunk = first;
16065
- if (!newRight) this.lastChunk = last;
16066
- return this;
16067
- }
16068
-
16069
- overwrite(start, end, content, options) {
16070
- options = options || {};
16071
- return this.update(start, end, content, { ...options, overwrite: !options.contentOnly });
16072
- }
16073
-
16074
- update(start, end, content, options) {
16075
- if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
16076
-
16077
- while (start < 0) start += this.original.length;
16078
- while (end < 0) end += this.original.length;
16079
-
16080
- if (end > this.original.length) throw new Error('end is out of bounds');
16081
- if (start === end)
16082
- throw new Error(
16083
- 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
16084
- );
16085
-
16086
- this._split(start);
16087
- this._split(end);
16088
-
16089
- if (options === true) {
16090
- if (!warned.storeName) {
16091
- console.warn(
16092
- 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
16093
- ); // eslint-disable-line no-console
16094
- warned.storeName = true;
16095
- }
16096
-
16097
- options = { storeName: true };
16098
- }
16099
- const storeName = options !== undefined ? options.storeName : false;
16100
- const overwrite = options !== undefined ? options.overwrite : false;
16101
-
16102
- if (storeName) {
16103
- const original = this.original.slice(start, end);
16104
- Object.defineProperty(this.storedNames, original, {
16105
- writable: true,
16106
- value: true,
16107
- enumerable: true,
16108
- });
16109
- }
16110
-
16111
- const first = this.byStart[start];
16112
- const last = this.byEnd[end];
16113
-
16114
- if (first) {
16115
- let chunk = first;
16116
- while (chunk !== last) {
16117
- if (chunk.next !== this.byStart[chunk.end]) {
16118
- throw new Error('Cannot overwrite across a split point');
16119
- }
16120
- chunk = chunk.next;
16121
- chunk.edit('', false);
16122
- }
16123
-
16124
- first.edit(content, storeName, !overwrite);
16125
- } else {
16126
- // must be inserting at the end
16127
- const newChunk = new Chunk(start, end, '').edit(content, storeName);
16128
-
16129
- // TODO last chunk in the array may not be the last chunk, if it's moved...
16130
- last.next = newChunk;
16131
- newChunk.previous = last;
16132
- }
16133
- return this;
16134
- }
16135
-
16136
- prepend(content) {
16137
- if (typeof content !== 'string') throw new TypeError('outro content must be a string');
16138
-
16139
- this.intro = content + this.intro;
16140
- return this;
16141
- }
16142
-
16143
- prependLeft(index, content) {
16144
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
16145
-
16146
- this._split(index);
16147
-
16148
- const chunk = this.byEnd[index];
16149
-
16150
- if (chunk) {
16151
- chunk.prependLeft(content);
16152
- } else {
16153
- this.intro = content + this.intro;
16154
- }
16155
- return this;
16156
- }
16157
-
16158
- prependRight(index, content) {
16159
- if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
16160
-
16161
- this._split(index);
16162
-
16163
- const chunk = this.byStart[index];
16164
-
16165
- if (chunk) {
16166
- chunk.prependRight(content);
16167
- } else {
16168
- this.outro = content + this.outro;
16169
- }
16170
- return this;
16171
- }
16172
-
16173
- remove(start, end) {
16174
- while (start < 0) start += this.original.length;
16175
- while (end < 0) end += this.original.length;
16176
-
16177
- if (start === end) return this;
16178
-
16179
- if (start < 0 || end > this.original.length) throw new Error('Character is out of bounds');
16180
- if (start > end) throw new Error('end must be greater than start');
16181
-
16182
- this._split(start);
16183
- this._split(end);
16184
-
16185
- let chunk = this.byStart[start];
16186
-
16187
- while (chunk) {
16188
- chunk.intro = '';
16189
- chunk.outro = '';
16190
- chunk.edit('');
16191
-
16192
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
16193
- }
16194
- return this;
16195
- }
16196
-
16197
- lastChar() {
16198
- if (this.outro.length) return this.outro[this.outro.length - 1];
16199
- let chunk = this.lastChunk;
16200
- do {
16201
- if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
16202
- if (chunk.content.length) return chunk.content[chunk.content.length - 1];
16203
- if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
16204
- } while ((chunk = chunk.previous));
16205
- if (this.intro.length) return this.intro[this.intro.length - 1];
16206
- return '';
16207
- }
16208
-
16209
- lastLine() {
16210
- let lineIndex = this.outro.lastIndexOf(n$1);
16211
- if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
16212
- let lineStr = this.outro;
16213
- let chunk = this.lastChunk;
16214
- do {
16215
- if (chunk.outro.length > 0) {
16216
- lineIndex = chunk.outro.lastIndexOf(n$1);
16217
- if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
16218
- lineStr = chunk.outro + lineStr;
16219
- }
16220
-
16221
- if (chunk.content.length > 0) {
16222
- lineIndex = chunk.content.lastIndexOf(n$1);
16223
- if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
16224
- lineStr = chunk.content + lineStr;
16225
- }
16226
-
16227
- if (chunk.intro.length > 0) {
16228
- lineIndex = chunk.intro.lastIndexOf(n$1);
16229
- if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
16230
- lineStr = chunk.intro + lineStr;
16231
- }
16232
- } while ((chunk = chunk.previous));
16233
- lineIndex = this.intro.lastIndexOf(n$1);
16234
- if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
16235
- return this.intro + lineStr;
16236
- }
16237
-
16238
- slice(start = 0, end = this.original.length) {
16239
- while (start < 0) start += this.original.length;
16240
- while (end < 0) end += this.original.length;
16241
-
16242
- let result = '';
16243
-
16244
- // find start chunk
16245
- let chunk = this.firstChunk;
16246
- while (chunk && (chunk.start > start || chunk.end <= start)) {
16247
- // found end chunk before start
16248
- if (chunk.start < end && chunk.end >= end) {
16249
- return result;
16250
- }
16251
-
16252
- chunk = chunk.next;
16253
- }
16254
-
16255
- if (chunk && chunk.edited && chunk.start !== start)
16256
- throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
16257
-
16258
- const startChunk = chunk;
16259
- while (chunk) {
16260
- if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
16261
- result += chunk.intro;
16262
- }
16263
-
16264
- const containsEnd = chunk.start < end && chunk.end >= end;
16265
- if (containsEnd && chunk.edited && chunk.end !== end)
16266
- throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
16267
-
16268
- const sliceStart = startChunk === chunk ? start - chunk.start : 0;
16269
- const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
16270
-
16271
- result += chunk.content.slice(sliceStart, sliceEnd);
16272
-
16273
- if (chunk.outro && (!containsEnd || chunk.end === end)) {
16274
- result += chunk.outro;
16275
- }
16276
-
16277
- if (containsEnd) {
16278
- break;
16279
- }
16280
-
16281
- chunk = chunk.next;
16282
- }
16283
-
16284
- return result;
16285
- }
16286
-
16287
- // TODO deprecate this? not really very useful
16288
- snip(start, end) {
16289
- const clone = this.clone();
16290
- clone.remove(0, start);
16291
- clone.remove(end, clone.original.length);
16292
-
16293
- return clone;
16294
- }
16295
-
16296
- _split(index) {
16297
- if (this.byStart[index] || this.byEnd[index]) return;
16298
-
16299
- let chunk = this.lastSearchedChunk;
16300
- const searchForward = index > chunk.end;
16301
-
16302
- while (chunk) {
16303
- if (chunk.contains(index)) return this._splitChunk(chunk, index);
16304
-
16305
- chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
16306
- }
16307
- }
16308
-
16309
- _splitChunk(chunk, index) {
16310
- if (chunk.edited && chunk.content.length) {
16311
- // zero-length edited chunks are a special case (overlapping replacements)
16312
- const loc = getLocator(this.original)(index);
16313
- throw new Error(
16314
- `Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
16315
- );
16316
- }
16317
-
16318
- const newChunk = chunk.split(index);
16319
-
16320
- this.byEnd[index] = chunk;
16321
- this.byStart[index] = newChunk;
16322
- this.byEnd[newChunk.end] = newChunk;
16323
-
16324
- if (chunk === this.lastChunk) this.lastChunk = newChunk;
16325
-
16326
- this.lastSearchedChunk = chunk;
16327
- return true;
16328
- }
16329
-
16330
- toString() {
16331
- let str = this.intro;
16332
-
16333
- let chunk = this.firstChunk;
16334
- while (chunk) {
16335
- str += chunk.toString();
16336
- chunk = chunk.next;
16337
- }
16338
-
16339
- return str + this.outro;
16340
- }
16341
-
16342
- isEmpty() {
16343
- let chunk = this.firstChunk;
16344
- do {
16345
- if (
16346
- (chunk.intro.length && chunk.intro.trim()) ||
16347
- (chunk.content.length && chunk.content.trim()) ||
16348
- (chunk.outro.length && chunk.outro.trim())
16349
- )
16350
- return false;
16351
- } while ((chunk = chunk.next));
16352
- return true;
16353
- }
16354
-
16355
- length() {
16356
- let chunk = this.firstChunk;
16357
- let length = 0;
16358
- do {
16359
- length += chunk.intro.length + chunk.content.length + chunk.outro.length;
16360
- } while ((chunk = chunk.next));
16361
- return length;
16362
- }
16363
-
16364
- trimLines() {
16365
- return this.trim('[\\r\\n]');
16366
- }
16367
-
16368
- trim(charType) {
16369
- return this.trimStart(charType).trimEnd(charType);
16370
- }
16371
-
16372
- trimEndAborted(charType) {
16373
- const rx = new RegExp((charType || '\\s') + '+$');
16374
-
16375
- this.outro = this.outro.replace(rx, '');
16376
- if (this.outro.length) return true;
16377
-
16378
- let chunk = this.lastChunk;
16379
-
16380
- do {
16381
- const end = chunk.end;
16382
- const aborted = chunk.trimEnd(rx);
16383
-
16384
- // if chunk was trimmed, we have a new lastChunk
16385
- if (chunk.end !== end) {
16386
- if (this.lastChunk === chunk) {
16387
- this.lastChunk = chunk.next;
16388
- }
16389
-
16390
- this.byEnd[chunk.end] = chunk;
16391
- this.byStart[chunk.next.start] = chunk.next;
16392
- this.byEnd[chunk.next.end] = chunk.next;
16393
- }
16394
-
16395
- if (aborted) return true;
16396
- chunk = chunk.previous;
16397
- } while (chunk);
16398
-
16399
- return false;
16400
- }
16401
-
16402
- trimEnd(charType) {
16403
- this.trimEndAborted(charType);
16404
- return this;
16405
- }
16406
- trimStartAborted(charType) {
16407
- const rx = new RegExp('^' + (charType || '\\s') + '+');
16408
-
16409
- this.intro = this.intro.replace(rx, '');
16410
- if (this.intro.length) return true;
16411
-
16412
- let chunk = this.firstChunk;
16413
-
16414
- do {
16415
- const end = chunk.end;
16416
- const aborted = chunk.trimStart(rx);
16417
-
16418
- if (chunk.end !== end) {
16419
- // special case...
16420
- if (chunk === this.lastChunk) this.lastChunk = chunk.next;
16421
-
16422
- this.byEnd[chunk.end] = chunk;
16423
- this.byStart[chunk.next.start] = chunk.next;
16424
- this.byEnd[chunk.next.end] = chunk.next;
16425
- }
16426
-
16427
- if (aborted) return true;
16428
- chunk = chunk.next;
16429
- } while (chunk);
16430
-
16431
- return false;
16432
- }
16433
-
16434
- trimStart(charType) {
16435
- this.trimStartAborted(charType);
16436
- return this;
16437
- }
16438
-
16439
- hasChanged() {
16440
- return this.original !== this.toString();
16441
- }
16442
-
16443
- _replaceRegexp(searchValue, replacement) {
16444
- function getReplacement(match, str) {
16445
- if (typeof replacement === 'string') {
16446
- return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
16447
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_string_as_a_parameter
16448
- if (i === '$') return '$';
16449
- if (i === '&') return match[0];
16450
- const num = +i;
16451
- if (num < match.length) return match[+i];
16452
- return `$${i}`;
16453
- });
16454
- } else {
16455
- return replacement(...match, match.index, str, match.groups);
16456
- }
16457
- }
16458
- function matchAll(re, str) {
16459
- let match;
16460
- const matches = [];
16461
- while ((match = re.exec(str))) {
16462
- matches.push(match);
16463
- }
16464
- return matches;
16465
- }
16466
- if (searchValue.global) {
16467
- const matches = matchAll(searchValue, this.original);
16468
- matches.forEach((match) => {
16469
- if (match.index != null)
16470
- this.overwrite(
16471
- match.index,
16472
- match.index + match[0].length,
16473
- getReplacement(match, this.original),
16474
- );
16475
- });
16476
- } else {
16477
- const match = this.original.match(searchValue);
16478
- if (match && match.index != null)
16479
- this.overwrite(
16480
- match.index,
16481
- match.index + match[0].length,
16482
- getReplacement(match, this.original),
16483
- );
16484
- }
16485
- return this;
16486
- }
16487
-
16488
- _replaceString(string, replacement) {
16489
- const { original } = this;
16490
- const index = original.indexOf(string);
16491
-
16492
- if (index !== -1) {
16493
- this.overwrite(index, index + string.length, replacement);
16494
- }
16495
-
16496
- return this;
16497
- }
16498
-
16499
- replace(searchValue, replacement) {
16500
- if (typeof searchValue === 'string') {
16501
- return this._replaceString(searchValue, replacement);
16502
- }
14986
+ if (!value) { continue; }
16503
14987
 
16504
- return this._replaceRegexp(searchValue, replacement);
16505
- }
14988
+ var keyValue = json.stringify(key)
14989
+ + colonSeparator
14990
+ + value;
16506
14991
 
16507
- _replaceAllString(string, replacement) {
16508
- const { original } = this;
16509
- const stringLength = string.length;
16510
- for (
16511
- let index = original.indexOf(string);
16512
- index !== -1;
16513
- index = original.indexOf(string, index + stringLength)
16514
- ) {
16515
- this.overwrite(index, index + stringLength, replacement);
14992
+ out.push(indent + space + keyValue);
16516
14993
  }
14994
+ seen.splice(seen.indexOf(node), 1);
14995
+ return '{' + out.join(',') + indent + '}';
16517
14996
 
16518
- return this;
16519
- }
14997
+ }({ '': obj }, '', obj, 0));
14998
+ };
16520
14999
 
16521
- replaceAll(searchValue, replacement) {
16522
- if (typeof searchValue === 'string') {
16523
- return this._replaceAllString(searchValue, replacement);
16524
- }
15000
+ var jsonStableStringify$1 = /*@__PURE__*/getDefaultExportFromCjs(jsonStableStringify);
16525
15001
 
16526
- if (!searchValue.global) {
16527
- throw new TypeError(
16528
- 'MagicString.prototype.replaceAll called with a non-global RegExp argument',
16529
- );
16530
- }
15002
+ const mimes$1 = {
15003
+ "ez": "application/andrew-inset",
15004
+ "aw": "application/applixware",
15005
+ "atom": "application/atom+xml",
15006
+ "atomcat": "application/atomcat+xml",
15007
+ "atomdeleted": "application/atomdeleted+xml",
15008
+ "atomsvc": "application/atomsvc+xml",
15009
+ "dwd": "application/atsc-dwd+xml",
15010
+ "held": "application/atsc-held+xml",
15011
+ "rsat": "application/atsc-rsat+xml",
15012
+ "bdoc": "application/bdoc",
15013
+ "xcs": "application/calendar+xml",
15014
+ "ccxml": "application/ccxml+xml",
15015
+ "cdfx": "application/cdfx+xml",
15016
+ "cdmia": "application/cdmi-capability",
15017
+ "cdmic": "application/cdmi-container",
15018
+ "cdmid": "application/cdmi-domain",
15019
+ "cdmio": "application/cdmi-object",
15020
+ "cdmiq": "application/cdmi-queue",
15021
+ "cu": "application/cu-seeme",
15022
+ "mpd": "application/dash+xml",
15023
+ "davmount": "application/davmount+xml",
15024
+ "dbk": "application/docbook+xml",
15025
+ "dssc": "application/dssc+der",
15026
+ "xdssc": "application/dssc+xml",
15027
+ "es": "application/ecmascript",
15028
+ "ecma": "application/ecmascript",
15029
+ "emma": "application/emma+xml",
15030
+ "emotionml": "application/emotionml+xml",
15031
+ "epub": "application/epub+zip",
15032
+ "exi": "application/exi",
15033
+ "fdt": "application/fdt+xml",
15034
+ "pfr": "application/font-tdpfr",
15035
+ "geojson": "application/geo+json",
15036
+ "gml": "application/gml+xml",
15037
+ "gpx": "application/gpx+xml",
15038
+ "gxf": "application/gxf",
15039
+ "gz": "application/gzip",
15040
+ "hjson": "application/hjson",
15041
+ "stk": "application/hyperstudio",
15042
+ "ink": "application/inkml+xml",
15043
+ "inkml": "application/inkml+xml",
15044
+ "ipfix": "application/ipfix",
15045
+ "its": "application/its+xml",
15046
+ "jar": "application/java-archive",
15047
+ "war": "application/java-archive",
15048
+ "ear": "application/java-archive",
15049
+ "ser": "application/java-serialized-object",
15050
+ "class": "application/java-vm",
15051
+ "js": "application/javascript",
15052
+ "mjs": "application/javascript",
15053
+ "json": "application/json",
15054
+ "map": "application/json",
15055
+ "json5": "application/json5",
15056
+ "jsonml": "application/jsonml+json",
15057
+ "jsonld": "application/ld+json",
15058
+ "lgr": "application/lgr+xml",
15059
+ "lostxml": "application/lost+xml",
15060
+ "hqx": "application/mac-binhex40",
15061
+ "cpt": "application/mac-compactpro",
15062
+ "mads": "application/mads+xml",
15063
+ "webmanifest": "application/manifest+json",
15064
+ "mrc": "application/marc",
15065
+ "mrcx": "application/marcxml+xml",
15066
+ "ma": "application/mathematica",
15067
+ "nb": "application/mathematica",
15068
+ "mb": "application/mathematica",
15069
+ "mathml": "application/mathml+xml",
15070
+ "mbox": "application/mbox",
15071
+ "mscml": "application/mediaservercontrol+xml",
15072
+ "metalink": "application/metalink+xml",
15073
+ "meta4": "application/metalink4+xml",
15074
+ "mets": "application/mets+xml",
15075
+ "maei": "application/mmt-aei+xml",
15076
+ "musd": "application/mmt-usd+xml",
15077
+ "mods": "application/mods+xml",
15078
+ "m21": "application/mp21",
15079
+ "mp21": "application/mp21",
15080
+ "mp4s": "application/mp4",
15081
+ "m4p": "application/mp4",
15082
+ "doc": "application/msword",
15083
+ "dot": "application/msword",
15084
+ "mxf": "application/mxf",
15085
+ "nq": "application/n-quads",
15086
+ "nt": "application/n-triples",
15087
+ "cjs": "application/node",
15088
+ "bin": "application/octet-stream",
15089
+ "dms": "application/octet-stream",
15090
+ "lrf": "application/octet-stream",
15091
+ "mar": "application/octet-stream",
15092
+ "so": "application/octet-stream",
15093
+ "dist": "application/octet-stream",
15094
+ "distz": "application/octet-stream",
15095
+ "pkg": "application/octet-stream",
15096
+ "bpk": "application/octet-stream",
15097
+ "dump": "application/octet-stream",
15098
+ "elc": "application/octet-stream",
15099
+ "deploy": "application/octet-stream",
15100
+ "exe": "application/octet-stream",
15101
+ "dll": "application/octet-stream",
15102
+ "deb": "application/octet-stream",
15103
+ "dmg": "application/octet-stream",
15104
+ "iso": "application/octet-stream",
15105
+ "img": "application/octet-stream",
15106
+ "msi": "application/octet-stream",
15107
+ "msp": "application/octet-stream",
15108
+ "msm": "application/octet-stream",
15109
+ "buffer": "application/octet-stream",
15110
+ "oda": "application/oda",
15111
+ "opf": "application/oebps-package+xml",
15112
+ "ogx": "application/ogg",
15113
+ "omdoc": "application/omdoc+xml",
15114
+ "onetoc": "application/onenote",
15115
+ "onetoc2": "application/onenote",
15116
+ "onetmp": "application/onenote",
15117
+ "onepkg": "application/onenote",
15118
+ "oxps": "application/oxps",
15119
+ "relo": "application/p2p-overlay+xml",
15120
+ "xer": "application/patch-ops-error+xml",
15121
+ "pdf": "application/pdf",
15122
+ "pgp": "application/pgp-encrypted",
15123
+ "asc": "application/pgp-signature",
15124
+ "sig": "application/pgp-signature",
15125
+ "prf": "application/pics-rules",
15126
+ "p10": "application/pkcs10",
15127
+ "p7m": "application/pkcs7-mime",
15128
+ "p7c": "application/pkcs7-mime",
15129
+ "p7s": "application/pkcs7-signature",
15130
+ "p8": "application/pkcs8",
15131
+ "ac": "application/pkix-attr-cert",
15132
+ "cer": "application/pkix-cert",
15133
+ "crl": "application/pkix-crl",
15134
+ "pkipath": "application/pkix-pkipath",
15135
+ "pki": "application/pkixcmp",
15136
+ "pls": "application/pls+xml",
15137
+ "ai": "application/postscript",
15138
+ "eps": "application/postscript",
15139
+ "ps": "application/postscript",
15140
+ "provx": "application/provenance+xml",
15141
+ "cww": "application/prs.cww",
15142
+ "pskcxml": "application/pskc+xml",
15143
+ "raml": "application/raml+yaml",
15144
+ "rdf": "application/rdf+xml",
15145
+ "owl": "application/rdf+xml",
15146
+ "rif": "application/reginfo+xml",
15147
+ "rnc": "application/relax-ng-compact-syntax",
15148
+ "rl": "application/resource-lists+xml",
15149
+ "rld": "application/resource-lists-diff+xml",
15150
+ "rs": "application/rls-services+xml",
15151
+ "rapd": "application/route-apd+xml",
15152
+ "sls": "application/route-s-tsid+xml",
15153
+ "rusd": "application/route-usd+xml",
15154
+ "gbr": "application/rpki-ghostbusters",
15155
+ "mft": "application/rpki-manifest",
15156
+ "roa": "application/rpki-roa",
15157
+ "rsd": "application/rsd+xml",
15158
+ "rss": "application/rss+xml",
15159
+ "rtf": "application/rtf",
15160
+ "sbml": "application/sbml+xml",
15161
+ "scq": "application/scvp-cv-request",
15162
+ "scs": "application/scvp-cv-response",
15163
+ "spq": "application/scvp-vp-request",
15164
+ "spp": "application/scvp-vp-response",
15165
+ "sdp": "application/sdp",
15166
+ "senmlx": "application/senml+xml",
15167
+ "sensmlx": "application/sensml+xml",
15168
+ "setpay": "application/set-payment-initiation",
15169
+ "setreg": "application/set-registration-initiation",
15170
+ "shf": "application/shf+xml",
15171
+ "siv": "application/sieve",
15172
+ "sieve": "application/sieve",
15173
+ "smi": "application/smil+xml",
15174
+ "smil": "application/smil+xml",
15175
+ "rq": "application/sparql-query",
15176
+ "srx": "application/sparql-results+xml",
15177
+ "gram": "application/srgs",
15178
+ "grxml": "application/srgs+xml",
15179
+ "sru": "application/sru+xml",
15180
+ "ssdl": "application/ssdl+xml",
15181
+ "ssml": "application/ssml+xml",
15182
+ "swidtag": "application/swid+xml",
15183
+ "tei": "application/tei+xml",
15184
+ "teicorpus": "application/tei+xml",
15185
+ "tfi": "application/thraud+xml",
15186
+ "tsd": "application/timestamped-data",
15187
+ "toml": "application/toml",
15188
+ "trig": "application/trig",
15189
+ "ttml": "application/ttml+xml",
15190
+ "ubj": "application/ubjson",
15191
+ "rsheet": "application/urc-ressheet+xml",
15192
+ "td": "application/urc-targetdesc+xml",
15193
+ "vxml": "application/voicexml+xml",
15194
+ "wasm": "application/wasm",
15195
+ "wgt": "application/widget",
15196
+ "hlp": "application/winhlp",
15197
+ "wsdl": "application/wsdl+xml",
15198
+ "wspolicy": "application/wspolicy+xml",
15199
+ "xaml": "application/xaml+xml",
15200
+ "xav": "application/xcap-att+xml",
15201
+ "xca": "application/xcap-caps+xml",
15202
+ "xdf": "application/xcap-diff+xml",
15203
+ "xel": "application/xcap-el+xml",
15204
+ "xns": "application/xcap-ns+xml",
15205
+ "xenc": "application/xenc+xml",
15206
+ "xhtml": "application/xhtml+xml",
15207
+ "xht": "application/xhtml+xml",
15208
+ "xlf": "application/xliff+xml",
15209
+ "xml": "application/xml",
15210
+ "xsl": "application/xml",
15211
+ "xsd": "application/xml",
15212
+ "rng": "application/xml",
15213
+ "dtd": "application/xml-dtd",
15214
+ "xop": "application/xop+xml",
15215
+ "xpl": "application/xproc+xml",
15216
+ "xslt": "application/xml",
15217
+ "xspf": "application/xspf+xml",
15218
+ "mxml": "application/xv+xml",
15219
+ "xhvml": "application/xv+xml",
15220
+ "xvml": "application/xv+xml",
15221
+ "xvm": "application/xv+xml",
15222
+ "yang": "application/yang",
15223
+ "yin": "application/yin+xml",
15224
+ "zip": "application/zip",
15225
+ "3gpp": "video/3gpp",
15226
+ "adp": "audio/adpcm",
15227
+ "amr": "audio/amr",
15228
+ "au": "audio/basic",
15229
+ "snd": "audio/basic",
15230
+ "mid": "audio/midi",
15231
+ "midi": "audio/midi",
15232
+ "kar": "audio/midi",
15233
+ "rmi": "audio/midi",
15234
+ "mxmf": "audio/mobile-xmf",
15235
+ "mp3": "audio/mpeg",
15236
+ "m4a": "audio/mp4",
15237
+ "mp4a": "audio/mp4",
15238
+ "mpga": "audio/mpeg",
15239
+ "mp2": "audio/mpeg",
15240
+ "mp2a": "audio/mpeg",
15241
+ "m2a": "audio/mpeg",
15242
+ "m3a": "audio/mpeg",
15243
+ "oga": "audio/ogg",
15244
+ "ogg": "audio/ogg",
15245
+ "spx": "audio/ogg",
15246
+ "opus": "audio/ogg",
15247
+ "s3m": "audio/s3m",
15248
+ "sil": "audio/silk",
15249
+ "wav": "audio/wav",
15250
+ "weba": "audio/webm",
15251
+ "xm": "audio/xm",
15252
+ "ttc": "font/collection",
15253
+ "otf": "font/otf",
15254
+ "ttf": "font/ttf",
15255
+ "woff": "font/woff",
15256
+ "woff2": "font/woff2",
15257
+ "exr": "image/aces",
15258
+ "apng": "image/apng",
15259
+ "avif": "image/avif",
15260
+ "bmp": "image/bmp",
15261
+ "cgm": "image/cgm",
15262
+ "drle": "image/dicom-rle",
15263
+ "emf": "image/emf",
15264
+ "fits": "image/fits",
15265
+ "g3": "image/g3fax",
15266
+ "gif": "image/gif",
15267
+ "heic": "image/heic",
15268
+ "heics": "image/heic-sequence",
15269
+ "heif": "image/heif",
15270
+ "heifs": "image/heif-sequence",
15271
+ "hej2": "image/hej2k",
15272
+ "hsj2": "image/hsj2",
15273
+ "ief": "image/ief",
15274
+ "jls": "image/jls",
15275
+ "jp2": "image/jp2",
15276
+ "jpg2": "image/jp2",
15277
+ "jpeg": "image/jpeg",
15278
+ "jpg": "image/jpeg",
15279
+ "jpe": "image/jpeg",
15280
+ "jph": "image/jph",
15281
+ "jhc": "image/jphc",
15282
+ "jpm": "image/jpm",
15283
+ "jpx": "image/jpx",
15284
+ "jpf": "image/jpx",
15285
+ "jxr": "image/jxr",
15286
+ "jxra": "image/jxra",
15287
+ "jxrs": "image/jxrs",
15288
+ "jxs": "image/jxs",
15289
+ "jxsc": "image/jxsc",
15290
+ "jxsi": "image/jxsi",
15291
+ "jxss": "image/jxss",
15292
+ "ktx": "image/ktx",
15293
+ "ktx2": "image/ktx2",
15294
+ "png": "image/png",
15295
+ "btif": "image/prs.btif",
15296
+ "pti": "image/prs.pti",
15297
+ "sgi": "image/sgi",
15298
+ "svg": "image/svg+xml",
15299
+ "svgz": "image/svg+xml",
15300
+ "t38": "image/t38",
15301
+ "tif": "image/tiff",
15302
+ "tiff": "image/tiff",
15303
+ "tfx": "image/tiff-fx",
15304
+ "webp": "image/webp",
15305
+ "wmf": "image/wmf",
15306
+ "disposition-notification": "message/disposition-notification",
15307
+ "u8msg": "message/global",
15308
+ "u8dsn": "message/global-delivery-status",
15309
+ "u8mdn": "message/global-disposition-notification",
15310
+ "u8hdr": "message/global-headers",
15311
+ "eml": "message/rfc822",
15312
+ "mime": "message/rfc822",
15313
+ "3mf": "model/3mf",
15314
+ "gltf": "model/gltf+json",
15315
+ "glb": "model/gltf-binary",
15316
+ "igs": "model/iges",
15317
+ "iges": "model/iges",
15318
+ "msh": "model/mesh",
15319
+ "mesh": "model/mesh",
15320
+ "silo": "model/mesh",
15321
+ "mtl": "model/mtl",
15322
+ "obj": "model/obj",
15323
+ "stpz": "model/step+zip",
15324
+ "stpxz": "model/step-xml+zip",
15325
+ "stl": "model/stl",
15326
+ "wrl": "model/vrml",
15327
+ "vrml": "model/vrml",
15328
+ "x3db": "model/x3d+fastinfoset",
15329
+ "x3dbz": "model/x3d+binary",
15330
+ "x3dv": "model/x3d-vrml",
15331
+ "x3dvz": "model/x3d+vrml",
15332
+ "x3d": "model/x3d+xml",
15333
+ "x3dz": "model/x3d+xml",
15334
+ "appcache": "text/cache-manifest",
15335
+ "manifest": "text/cache-manifest",
15336
+ "ics": "text/calendar",
15337
+ "ifb": "text/calendar",
15338
+ "coffee": "text/coffeescript",
15339
+ "litcoffee": "text/coffeescript",
15340
+ "css": "text/css",
15341
+ "csv": "text/csv",
15342
+ "html": "text/html",
15343
+ "htm": "text/html",
15344
+ "shtml": "text/html",
15345
+ "jade": "text/jade",
15346
+ "jsx": "text/jsx",
15347
+ "less": "text/less",
15348
+ "markdown": "text/markdown",
15349
+ "md": "text/markdown",
15350
+ "mml": "text/mathml",
15351
+ "mdx": "text/mdx",
15352
+ "n3": "text/n3",
15353
+ "txt": "text/plain",
15354
+ "text": "text/plain",
15355
+ "conf": "text/plain",
15356
+ "def": "text/plain",
15357
+ "list": "text/plain",
15358
+ "log": "text/plain",
15359
+ "in": "text/plain",
15360
+ "ini": "text/plain",
15361
+ "dsc": "text/prs.lines.tag",
15362
+ "rtx": "text/richtext",
15363
+ "sgml": "text/sgml",
15364
+ "sgm": "text/sgml",
15365
+ "shex": "text/shex",
15366
+ "slim": "text/slim",
15367
+ "slm": "text/slim",
15368
+ "spdx": "text/spdx",
15369
+ "stylus": "text/stylus",
15370
+ "styl": "text/stylus",
15371
+ "tsv": "text/tab-separated-values",
15372
+ "t": "text/troff",
15373
+ "tr": "text/troff",
15374
+ "roff": "text/troff",
15375
+ "man": "text/troff",
15376
+ "me": "text/troff",
15377
+ "ms": "text/troff",
15378
+ "ttl": "text/turtle",
15379
+ "uri": "text/uri-list",
15380
+ "uris": "text/uri-list",
15381
+ "urls": "text/uri-list",
15382
+ "vcard": "text/vcard",
15383
+ "vtt": "text/vtt",
15384
+ "yaml": "text/yaml",
15385
+ "yml": "text/yaml",
15386
+ "3gp": "video/3gpp",
15387
+ "3g2": "video/3gpp2",
15388
+ "h261": "video/h261",
15389
+ "h263": "video/h263",
15390
+ "h264": "video/h264",
15391
+ "m4s": "video/iso.segment",
15392
+ "jpgv": "video/jpeg",
15393
+ "jpgm": "image/jpm",
15394
+ "mj2": "video/mj2",
15395
+ "mjp2": "video/mj2",
15396
+ "ts": "video/mp2t",
15397
+ "mp4": "video/mp4",
15398
+ "mp4v": "video/mp4",
15399
+ "mpg4": "video/mp4",
15400
+ "mpeg": "video/mpeg",
15401
+ "mpg": "video/mpeg",
15402
+ "mpe": "video/mpeg",
15403
+ "m1v": "video/mpeg",
15404
+ "m2v": "video/mpeg",
15405
+ "ogv": "video/ogg",
15406
+ "qt": "video/quicktime",
15407
+ "mov": "video/quicktime",
15408
+ "webm": "video/webm"
15409
+ };
16531
15410
 
16532
- return this._replaceRegexp(searchValue, replacement);
16533
- }
15411
+ function lookup(extn) {
15412
+ let tmp = ('' + extn).trim().toLowerCase();
15413
+ let idx = tmp.lastIndexOf('.');
15414
+ return mimes$1[!~idx ? tmp : tmp.substring(++idx)];
16534
15415
  }
16535
15416
 
16536
15417
  const assetUrlRE = /__VITE_ASSET__([a-z\d]+)__(?:\$_(.*?)__)?/g;
@@ -28511,7 +27392,7 @@ const browserExternalId = '__vite-browser-external';
28511
27392
  // special id for packages that are optional peer deps
28512
27393
  const optionalPeerDepId = '__vite-optional-peer-dep';
28513
27394
  const subpathImportsPrefix = '#';
28514
- const startsWithWordCharRE = /^\w/;
27395
+ const startsWithWordCharRE$1 = /^\w/;
28515
27396
  const debug$e = createDebugger('vite:resolve-details', {
28516
27397
  onlyWhenFocused: true,
28517
27398
  });
@@ -28603,7 +27484,7 @@ function resolvePlugin(resolveOptions) {
28603
27484
  // relative
28604
27485
  if (id[0] === '.' ||
28605
27486
  ((preferRelative || importer?.endsWith('.html')) &&
28606
- startsWithWordCharRE.test(id))) {
27487
+ startsWithWordCharRE$1.test(id))) {
28607
27488
  const basedir = importer ? path$o.dirname(importer) : process.cwd();
28608
27489
  const fsPath = path$o.resolve(basedir, id);
28609
27490
  // handle browser field mapping for relative imports
@@ -29121,7 +28002,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
29121
28002
  // https://github.com/defunctzombie/package-browser-field-spec
29122
28003
  const browserEntry = typeof data.browser === 'string'
29123
28004
  ? data.browser
29124
- : isObject$2(data.browser) && data.browser['.'];
28005
+ : isObject$1(data.browser) && data.browser['.'];
29125
28006
  if (browserEntry) {
29126
28007
  // check if the package also has a "module" field.
29127
28008
  if (!options.isRequire &&
@@ -29181,7 +28062,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
29181
28062
  else {
29182
28063
  // resolve object browser field in package.json
29183
28064
  const { browser: browserField } = data;
29184
- if (targetWeb && options.browserField && isObject$2(browserField)) {
28065
+ if (targetWeb && options.browserField && isObject$1(browserField)) {
29185
28066
  entry = mapWithBrowserField(entry, browserField) || entry;
29186
28067
  }
29187
28068
  }
@@ -29237,7 +28118,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
29237
28118
  const { exports: exportsField, browser: browserField } = data;
29238
28119
  // map relative based on exports data
29239
28120
  if (exportsField) {
29240
- if (isObject$2(exportsField) && !Array.isArray(exportsField)) {
28121
+ if (isObject$1(exportsField) && !Array.isArray(exportsField)) {
29241
28122
  // resolve without postfix (see #7098)
29242
28123
  const { file, postfix } = splitFileAndPostfix(relativeId);
29243
28124
  const exportsId = resolveExportsOrImports(data, file, options, targetWeb, 'exports');
@@ -29257,7 +28138,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
29257
28138
  `${path$o.join(dir, 'package.json')}.`);
29258
28139
  }
29259
28140
  }
29260
- else if (targetWeb && options.browserField && isObject$2(browserField)) {
28141
+ else if (targetWeb && options.browserField && isObject$1(browserField)) {
29261
28142
  // resolve without postfix (see #7098)
29262
28143
  const { file, postfix } = splitFileAndPostfix(relativeId);
29263
28144
  const mapped = mapWithBrowserField(file, browserField);
@@ -29282,7 +28163,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
29282
28163
  let res;
29283
28164
  const pkg = importer &&
29284
28165
  findNearestPackageData(path$o.dirname(importer), options.packageCache);
29285
- if (pkg && isObject$2(pkg.data.browser)) {
28166
+ if (pkg && isObject$1(pkg.data.browser)) {
29286
28167
  const mapId = isFilePath ? './' + slash$1(path$o.relative(pkg.dir, id)) : id;
29287
28168
  const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
29288
28169
  if (browserMappedPath) {
@@ -38053,7 +36934,7 @@ function buildHtmlPlugin(config) {
38053
36934
  // newline trailing the previous node
38054
36935
  const lineStartOffset = node.sourceCodeLocation.startOffset -
38055
36936
  node.sourceCodeLocation.startCol;
38056
- const line = s.slice(lineStartOffset, node.sourceCodeLocation.startOffset);
36937
+ const line = s.slice(Math.max(0, lineStartOffset), node.sourceCodeLocation.startOffset);
38057
36938
  // <previous-line-node></previous-line-node>
38058
36939
  // <target-node></target-node>
38059
36940
  //
@@ -38127,21 +37008,7 @@ function buildHtmlPlugin(config) {
38127
37008
  }
38128
37009
  else if (node.childNodes.length) {
38129
37010
  const scriptNode = node.childNodes.pop();
38130
- const cleanCode = stripLiteral(scriptNode.value);
38131
- let match;
38132
- inlineImportRE.lastIndex = 0;
38133
- while ((match = inlineImportRE.exec(cleanCode))) {
38134
- const { 1: url, index } = match;
38135
- const startUrl = cleanCode.indexOf(url, index);
38136
- const start = startUrl + 1;
38137
- const end = start + url.length - 2;
38138
- const startOffset = scriptNode.sourceCodeLocation.startOffset;
38139
- scriptUrls.push({
38140
- start: start + startOffset,
38141
- end: end + startOffset,
38142
- url: scriptNode.value.slice(start, end),
38143
- });
38144
- }
37011
+ scriptUrls.push(...extractImportExpressionFromClassicScript(scriptNode));
38145
37012
  }
38146
37013
  }
38147
37014
  // For asset references in index.html, also generate an import
@@ -38182,26 +37049,19 @@ function buildHtmlPlugin(config) {
38182
37049
  }
38183
37050
  }
38184
37051
  }
38185
- // <tag style="... url(...) or image-set(...) ..."></tag>
38186
- // extract inline styles as virtual css and add class attribute to tag for selecting
38187
- const inlineStyle = node.attrs.find((prop) => prop.prefix === undefined &&
38188
- prop.name === 'style' &&
38189
- // only url(...) or image-set(...) in css need to emit file
38190
- (prop.value.includes('url(') ||
38191
- prop.value.includes('image-set(')));
37052
+ const inlineStyle = findNeedTransformStyleAttribute(node);
38192
37053
  if (inlineStyle) {
38193
37054
  inlineModuleIndex++;
38194
- // replace `inline style` to class
37055
+ // replace `inline style` with __VITE_INLINE_CSS__**_**__
38195
37056
  // and import css in js code
38196
- const code = inlineStyle.value;
37057
+ const code = inlineStyle.attr.value;
38197
37058
  const filePath = id.replace(normalizePath$3(config.root), '');
38198
37059
  addToHTMLProxyCache(config, filePath, inlineModuleIndex, { code });
38199
37060
  // will transform with css plugin and cache result with css-post plugin
38200
37061
  js += `\nimport "${id}?html-proxy&inline-css&style-attr&index=${inlineModuleIndex}.css"`;
38201
37062
  const hash = getHash(cleanUrl(id));
38202
37063
  // will transform in `applyHtmlTransforms`
38203
- const sourceCodeLocation = node.sourceCodeLocation.attrs['style'];
38204
- overwriteAttrValue(s, sourceCodeLocation, `__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__`);
37064
+ overwriteAttrValue(s, inlineStyle.location, `__VITE_INLINE_CSS__${hash}_${inlineModuleIndex}__`);
38205
37065
  }
38206
37066
  // <style>...</style>
38207
37067
  if (node.nodeName === 'style' && node.childNodes.length) {
@@ -38460,6 +37320,37 @@ function buildHtmlPlugin(config) {
38460
37320
  },
38461
37321
  };
38462
37322
  }
37323
+ // <tag style="... url(...) or image-set(...) ..."></tag>
37324
+ // extract inline styles as virtual css
37325
+ function findNeedTransformStyleAttribute(node) {
37326
+ const attr = node.attrs.find((prop) => prop.prefix === undefined &&
37327
+ prop.name === 'style' &&
37328
+ // only url(...) or image-set(...) in css need to emit file
37329
+ (prop.value.includes('url(') || prop.value.includes('image-set(')));
37330
+ if (!attr)
37331
+ return undefined;
37332
+ const location = node.sourceCodeLocation?.attrs?.['style'];
37333
+ return { attr, location };
37334
+ }
37335
+ function extractImportExpressionFromClassicScript(scriptTextNode) {
37336
+ const startOffset = scriptTextNode.sourceCodeLocation.startOffset;
37337
+ const cleanCode = stripLiteral(scriptTextNode.value);
37338
+ const scriptUrls = [];
37339
+ let match;
37340
+ inlineImportRE.lastIndex = 0;
37341
+ while ((match = inlineImportRE.exec(cleanCode))) {
37342
+ const { 1: url, index } = match;
37343
+ const startUrl = cleanCode.indexOf(url, index);
37344
+ const start = startUrl + 1;
37345
+ const end = start + url.length - 2;
37346
+ scriptUrls.push({
37347
+ start: start + startOffset,
37348
+ end: end + startOffset,
37349
+ url: scriptTextNode.value.slice(start, end),
37350
+ });
37351
+ }
37352
+ return scriptUrls;
37353
+ }
38463
37354
  function preImportMapHook(config) {
38464
37355
  return (html, ctx) => {
38465
37356
  const importMapIndex = html.match(importMapRE)?.index;
@@ -38913,6 +37804,19 @@ function cssPostPlugin(config) {
38913
37804
  return;
38914
37805
  }
38915
37806
  css = stripBomTag(css);
37807
+ // cache css compile result to map
37808
+ // and then use the cache replace inline-style-flag
37809
+ // when `generateBundle` in vite:build-html plugin and devHtmlHook
37810
+ const inlineCSS = inlineCSSRE.test(id);
37811
+ const isHTMLProxy = htmlProxyRE.test(id);
37812
+ if (inlineCSS && isHTMLProxy) {
37813
+ const query = parseRequest(id);
37814
+ if (styleAttrRE.test(id)) {
37815
+ css = css.replace(/"/g, '&quot;');
37816
+ }
37817
+ addToHTMLProxyTransformResult(`${getHash(cleanUrl(id))}_${Number.parseInt(query.index)}`, css);
37818
+ return `export default ''`;
37819
+ }
38916
37820
  const inlined = inlineRE.test(id);
38917
37821
  const modules = cssModulesCache.get(config).get(id);
38918
37822
  // #6984, #7552
@@ -38956,18 +37860,6 @@ function cssPostPlugin(config) {
38956
37860
  }
38957
37861
  // build CSS handling ----------------------------------------------------
38958
37862
  // record css
38959
- // cache css compile result to map
38960
- // and then use the cache replace inline-style-flag when `generateBundle` in vite:build-html plugin
38961
- const inlineCSS = inlineCSSRE.test(id);
38962
- const isHTMLProxy = htmlProxyRE.test(id);
38963
- const query = parseRequest(id);
38964
- if (inlineCSS && isHTMLProxy) {
38965
- if (styleAttrRE.test(id)) {
38966
- css = css.replace(/"/g, '&quot;');
38967
- }
38968
- addToHTMLProxyTransformResult(`${getHash(cleanUrl(id))}_${Number.parseInt(query.index)}`, css);
38969
- return `export default ''`;
38970
- }
38971
37863
  if (!inlined) {
38972
37864
  styles.set(id, css);
38973
37865
  }
@@ -39528,8 +38420,8 @@ function createCachedImport(imp) {
39528
38420
  return cached;
39529
38421
  };
39530
38422
  }
39531
- const importPostcssImport = createCachedImport(() => import('./dep-ce41d4ea.js').then(function (n) { return n.i; }));
39532
- const importPostcssModules = createCachedImport(() => import('./dep-c3c41c00.js').then(function (n) { return n.i; }));
38423
+ const importPostcssImport = createCachedImport(() => import('./dep-0b82e789.js').then(function (n) { return n.i; }));
38424
+ const importPostcssModules = createCachedImport(() => import('./dep-3accc834.js').then(function (n) { return n.i; }));
39533
38425
  const importPostcss = createCachedImport(() => import('postcss'));
39534
38426
  /**
39535
38427
  * @experimental
@@ -39583,7 +38475,7 @@ async function resolvePostcssConfig(config) {
39583
38475
  }
39584
38476
  // inline postcss config via vite config
39585
38477
  const inlineOptions = config.css?.postcss;
39586
- if (isObject$2(inlineOptions)) {
38478
+ if (isObject$1(inlineOptions)) {
39587
38479
  const options = { ...inlineOptions };
39588
38480
  delete options.plugins;
39589
38481
  result = {
@@ -42350,19 +41242,8 @@ function importAnalysisPlugin(config) {
42350
41242
  [imports, exports] = parse$e(source);
42351
41243
  }
42352
41244
  catch (e) {
42353
- const isVue = importer.endsWith('.vue');
42354
- const isJsx = importer.endsWith('.jsx') || importer.endsWith('.tsx');
42355
- const maybeJSX = !isVue && isJSRequest(importer);
42356
- const msg = isVue
42357
- ? `Install @vitejs/plugin-vue to handle .vue files.`
42358
- : maybeJSX
42359
- ? isJsx
42360
- ? `If you use tsconfig.json, make sure to not set jsx to preserve.`
42361
- : `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
42362
- : `You may need to install appropriate plugins to handle the ${path$o.extname(importer)} file format, or if it's an asset, add "**/*${path$o.extname(importer)}" to \`assetsInclude\` in your configuration.`;
42363
- this.error(`Failed to parse source for import analysis because the content ` +
42364
- `contains invalid JS syntax. ` +
42365
- msg, e.idx);
41245
+ const { message, showCodeFrame } = createParseErrorInfo(importer, source);
41246
+ this.error(message, showCodeFrame ? e.idx : undefined);
42366
41247
  }
42367
41248
  const depsOptimizer = getDepsOptimizer(config, ssr);
42368
41249
  const { moduleGraph } = server;
@@ -42753,6 +41634,25 @@ function mergeAcceptedUrls(orderedUrls) {
42753
41634
  }
42754
41635
  return acceptedUrls;
42755
41636
  }
41637
+ function createParseErrorInfo(importer, source) {
41638
+ const isVue = importer.endsWith('.vue');
41639
+ const isJsx = importer.endsWith('.jsx') || importer.endsWith('.tsx');
41640
+ const maybeJSX = !isVue && isJSRequest(importer);
41641
+ const probablyBinary = source.includes('\ufffd' /* unicode replacement character */);
41642
+ const msg = isVue
41643
+ ? `Install @vitejs/plugin-vue to handle .vue files.`
41644
+ : maybeJSX
41645
+ ? isJsx
41646
+ ? `If you use tsconfig.json, make sure to not set jsx to preserve.`
41647
+ : `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
41648
+ : `You may need to install appropriate plugins to handle the ${path$o.extname(importer)} file format, or if it's an asset, add "**/*${path$o.extname(importer)}" to \`assetsInclude\` in your configuration.`;
41649
+ return {
41650
+ message: `Failed to parse source for import analysis because the content ` +
41651
+ `contains invalid JS syntax. ` +
41652
+ msg,
41653
+ showCodeFrame: !probablyBinary,
41654
+ };
41655
+ }
42756
41656
  function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
42757
41657
  const source = str.original;
42758
41658
  const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
@@ -42892,7 +41792,7 @@ function clientInjectionsPlugin(config) {
42892
41792
  const devBase = config.base;
42893
41793
  const serverHost = `${resolvedServerHostname}:${resolvedServerPort}${devBase}`;
42894
41794
  let hmrConfig = config.server.hmr;
42895
- hmrConfig = isObject$2(hmrConfig) ? hmrConfig : undefined;
41795
+ hmrConfig = isObject$1(hmrConfig) ? hmrConfig : undefined;
42896
41796
  const host = hmrConfig?.host || null;
42897
41797
  const protocol = hmrConfig?.protocol || null;
42898
41798
  const timeout = hmrConfig?.timeout || 30000;
@@ -44947,7 +43847,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
44947
43847
  const handler = 'handler' in plugin.load ? plugin.load.handler : plugin.load;
44948
43848
  const result = await handleHookPromise(handler.call(ctx, id, { ssr }));
44949
43849
  if (result != null) {
44950
- if (isObject$2(result)) {
43850
+ if (isObject$1(result)) {
44951
43851
  updateModuleInfo(id, result);
44952
43852
  }
44953
43853
  return result;
@@ -44982,7 +43882,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
44982
43882
  if (!result)
44983
43883
  continue;
44984
43884
  debugPluginTransform?.(timeFrom(start), plugin.name, prettifyUrl(id, root));
44985
- if (isObject$2(result)) {
43885
+ if (isObject$1(result)) {
44986
43886
  if (result.code !== undefined) {
44987
43887
  code = result.code;
44988
43888
  if (result.map) {
@@ -45132,7 +44032,7 @@ async function computeEntries(config) {
45132
44032
  else if (Array.isArray(buildInput)) {
45133
44033
  entries = buildInput.map(resolvePath);
45134
44034
  }
45135
- else if (isObject$2(buildInput)) {
44035
+ else if (isObject$1(buildInput)) {
45136
44036
  entries = Object.values(buildInput).map(resolvePath);
45137
44037
  }
45138
44038
  else {
@@ -47297,7 +46197,8 @@ function buildImportAnalysisPlugin(config) {
47297
46197
  imports = parse$e(source)[0];
47298
46198
  }
47299
46199
  catch (e) {
47300
- this.error(e, e.idx);
46200
+ const { message, showCodeFrame } = createParseErrorInfo(importer, source);
46201
+ this.error(message, showCodeFrame ? e.idx : undefined);
47301
46202
  }
47302
46203
  if (!imports.length) {
47303
46204
  return null;
@@ -55563,7 +54464,7 @@ async function resolveHttpServer({ proxy }, app, httpsOptions) {
55563
54464
  async function resolveHttpsConfig(https) {
55564
54465
  if (!https)
55565
54466
  return undefined;
55566
- if (!isObject$2(https))
54467
+ if (!isObject$1(https))
55567
54468
  return {};
55568
54469
  const [ca, cert, key, pfx] = await Promise.all([
55569
54470
  readFileIfExists(https.ca),
@@ -55764,7 +54665,7 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
55764
54665
  }
55765
54666
  else {
55766
54667
  debugLoad?.(`${timeFrom(loadStart)} [plugin] ${prettyUrl}`);
55767
- if (isObject$2(loadResult)) {
54668
+ if (isObject$1(loadResult)) {
55768
54669
  code = loadResult.code;
55769
54670
  map = loadResult.map;
55770
54671
  }
@@ -55801,7 +54702,7 @@ async function loadAndTransform(id, url, server, options, timestamp, mod, resolv
55801
54702
  });
55802
54703
  const originalCode = code;
55803
54704
  if (transformResult == null ||
55804
- (isObject$2(transformResult) && transformResult.code == null)) {
54705
+ (isObject$1(transformResult) && transformResult.code == null)) {
55805
54706
  // no transform applied, keep code as-is
55806
54707
  debugTransform?.(timeFrom(transformStart) + colors$1.dim(` [skipped] ${prettyUrl}`));
55807
54708
  }
@@ -62577,7 +61478,7 @@ const wsServerEvents = [
62577
61478
  function createWebSocketServer(server, config, httpsOptions) {
62578
61479
  let wss;
62579
61480
  let wsHttpServer = undefined;
62580
- const hmr = isObject$2(config.server.hmr) && config.server.hmr;
61481
+ const hmr = isObject$1(config.server.hmr) && config.server.hmr;
62581
61482
  const hmrServer = hmr && hmr.server;
62582
61483
  const hmrPort = hmr && hmr.port;
62583
61484
  // TODO: the main server port may not have been chosen yet as it may use the next available
@@ -62805,9 +61706,9 @@ function baseMiddleware({ config, }) {
62805
61706
  res.end();
62806
61707
  return;
62807
61708
  }
62808
- else if (req.headers.accept?.includes('text/html')) {
62809
- // non-based page visit
62810
- const redirectPath = withTrailingSlash(url) !== base ? joinUrlSegments(base, url) : base;
61709
+ // non-based page visit
61710
+ const redirectPath = withTrailingSlash(url) !== base ? joinUrlSegments(base, url) : base;
61711
+ if (req.headers.accept?.includes('text/html')) {
62811
61712
  res.writeHead(404, {
62812
61713
  'Content-Type': 'text/html',
62813
61714
  });
@@ -62815,7 +61716,15 @@ function baseMiddleware({ config, }) {
62815
61716
  `did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
62816
61717
  return;
62817
61718
  }
62818
- next();
61719
+ else {
61720
+ // not found for resources
61721
+ res.writeHead(404, {
61722
+ 'Content-Type': 'text/plain',
61723
+ });
61724
+ res.end(`The server is configured with a public base URL of ${base} - ` +
61725
+ `did you mean to visit ${redirectPath} instead?`);
61726
+ return;
61727
+ }
62819
61728
  };
62820
61729
  }
62821
61730
 
@@ -64947,7 +63856,8 @@ function proxyMiddleware(httpServer, options, config) {
64947
63856
  }
64948
63857
  else if (bypassResult === false) {
64949
63858
  debug$1?.(`bypass: ${req.url} -> 404`);
64950
- return res.end(404);
63859
+ res.statusCode = 404;
63860
+ return res.end();
64951
63861
  }
64952
63862
  }
64953
63863
  debug$1?.(`${req.url} -> ${opts.target || opts.forward}`);
@@ -65352,8 +64262,9 @@ function getHtmlFilename(url, server) {
65352
64262
  function shouldPreTransform(url, config) {
65353
64263
  return (!checkPublicFile(url, config) && (isJSRequest(url) || isCSSRequest(url)));
65354
64264
  }
65355
- const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalUrl, server) => {
65356
- let url = attr.value || '';
64265
+ const startsWithWordCharRE = /^\w/;
64266
+ const isSrcSet = (attr) => attr.name === 'srcset' && attr.prefix === undefined;
64267
+ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, server) => {
65357
64268
  if (server?.moduleGraph) {
65358
64269
  const mod = server.moduleGraph.urlToModuleMap.get(url);
65359
64270
  if (mod && mod.lastHMRTimestamp > 0) {
@@ -65364,12 +64275,12 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
65364
64275
  if (url[0] === '/' && url[1] !== '/') {
65365
64276
  // prefix with base (dev only, base is never relative)
65366
64277
  const fullUrl = path$o.posix.join(devBase, url);
65367
- overwriteAttrValue(s, sourceCodeLocation, fullUrl);
65368
64278
  if (server && shouldPreTransform(url, config)) {
65369
64279
  preTransformRequest(server, fullUrl, devBase);
65370
64280
  }
64281
+ return fullUrl;
65371
64282
  }
65372
- else if (url[0] === '.' &&
64283
+ else if ((url[0] === '.' || startsWithWordCharRE.test(url)) &&
65373
64284
  originalUrl &&
65374
64285
  originalUrl !== '/' &&
65375
64286
  htmlPath === '/index.html') {
@@ -65385,10 +64296,10 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
65385
64296
  // path will add `/a/` prefix, it will caused 404.
65386
64297
  // rewrite before `./index.js` -> `localhost:5173/a/index.js`.
65387
64298
  // rewrite after `../index.js` -> `localhost:5173/index.js`.
65388
- const processedUrl = attr.name === 'srcset' && attr.prefix === undefined
64299
+ const processedUrl = useSrcSetReplacer
65389
64300
  ? processSrcSetSync(url, ({ url }) => replacer(url))
65390
64301
  : replacer(url);
65391
- overwriteAttrValue(s, sourceCodeLocation, processedUrl);
64302
+ return processedUrl;
65392
64303
  }
65393
64304
  };
65394
64305
  const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
@@ -65416,6 +64327,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
65416
64327
  let inlineModuleIndex = -1;
65417
64328
  const proxyCacheUrl = cleanUrl(proxyModulePath).replace(normalizePath$3(config.root), '');
65418
64329
  const styleUrl = [];
64330
+ const inlineStyles = [];
65419
64331
  const addInlineModule = (node, ext) => {
65420
64332
  inlineModuleIndex++;
65421
64333
  const contentNode = node.childNodes[0];
@@ -65448,11 +64360,32 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
65448
64360
  if (node.nodeName === 'script') {
65449
64361
  const { src, sourceCodeLocation, isModule } = getScriptInfo(node);
65450
64362
  if (src) {
65451
- processNodeUrl(src, sourceCodeLocation, s, config, htmlPath, originalUrl, server);
64363
+ const processedUrl = processNodeUrl(src.value, isSrcSet(src), config, htmlPath, originalUrl, server);
64364
+ if (processedUrl) {
64365
+ overwriteAttrValue(s, sourceCodeLocation, processedUrl);
64366
+ }
65452
64367
  }
65453
64368
  else if (isModule && node.childNodes.length) {
65454
64369
  addInlineModule(node, 'js');
65455
64370
  }
64371
+ else if (node.childNodes.length) {
64372
+ const scriptNode = node.childNodes[node.childNodes.length - 1];
64373
+ for (const { url, start, end, } of extractImportExpressionFromClassicScript(scriptNode)) {
64374
+ const processedUrl = processNodeUrl(url, false, config, htmlPath, originalUrl);
64375
+ if (processedUrl) {
64376
+ s.update(start, end, processedUrl);
64377
+ }
64378
+ }
64379
+ }
64380
+ }
64381
+ const inlineStyle = findNeedTransformStyleAttribute(node);
64382
+ if (inlineStyle) {
64383
+ inlineModuleIndex++;
64384
+ inlineStyles.push({
64385
+ index: inlineModuleIndex,
64386
+ location: inlineStyle.location,
64387
+ code: inlineStyle.attr.value,
64388
+ });
65456
64389
  }
65457
64390
  if (node.nodeName === 'style' && node.childNodes.length) {
65458
64391
  const children = node.childNodes[0];
@@ -65468,31 +64401,46 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
65468
64401
  for (const p of node.attrs) {
65469
64402
  const attrKey = getAttrKey(p);
65470
64403
  if (p.value && assetAttrs.includes(attrKey)) {
65471
- processNodeUrl(p, node.sourceCodeLocation.attrs[attrKey], s, config, htmlPath, originalUrl);
64404
+ const processedUrl = processNodeUrl(p.value, isSrcSet(p), config, htmlPath, originalUrl);
64405
+ if (processedUrl) {
64406
+ overwriteAttrValue(s, node.sourceCodeLocation.attrs[attrKey], processedUrl);
64407
+ }
65472
64408
  }
65473
64409
  }
65474
64410
  }
65475
64411
  });
65476
- await Promise.all(styleUrl.map(async ({ start, end, code }, index) => {
65477
- const url = `${proxyModulePath}?html-proxy&direct&index=${index}.css`;
65478
- // ensure module in graph after successful load
65479
- const mod = await moduleGraph.ensureEntryFromUrl(url, false);
65480
- ensureWatchedFile(watcher, mod.file, config.root);
65481
- const result = await server.pluginContainer.transform(code, mod.id);
65482
- let content = '';
65483
- if (result) {
65484
- if (result.map && 'version' in result.map) {
65485
- if (result.map.mappings) {
65486
- await injectSourcesContent(result.map, proxyModulePath, config.logger);
64412
+ await Promise.all([
64413
+ ...styleUrl.map(async ({ start, end, code }, index) => {
64414
+ const url = `${proxyModulePath}?html-proxy&direct&index=${index}.css`;
64415
+ // ensure module in graph after successful load
64416
+ const mod = await moduleGraph.ensureEntryFromUrl(url, false);
64417
+ ensureWatchedFile(watcher, mod.file, config.root);
64418
+ const result = await server.pluginContainer.transform(code, mod.id);
64419
+ let content = '';
64420
+ if (result) {
64421
+ if (result.map && 'version' in result.map) {
64422
+ if (result.map.mappings) {
64423
+ await injectSourcesContent(result.map, proxyModulePath, config.logger);
64424
+ }
64425
+ content = getCodeWithSourcemap('css', result.code, result.map);
64426
+ }
64427
+ else {
64428
+ content = result.code;
65487
64429
  }
65488
- content = getCodeWithSourcemap('css', result.code, result.map);
65489
- }
65490
- else {
65491
- content = result.code;
65492
64430
  }
65493
- }
65494
- s.overwrite(start, end, content);
65495
- }));
64431
+ s.overwrite(start, end, content);
64432
+ }),
64433
+ ...inlineStyles.map(async ({ index, location, code }) => {
64434
+ // will transform with css plugin and cache result with css-post plugin
64435
+ const url = `${proxyModulePath}?html-proxy&inline-css&style-attr&index=${index}.css`;
64436
+ const mod = await moduleGraph.ensureEntryFromUrl(url, false);
64437
+ ensureWatchedFile(watcher, mod.file, config.root);
64438
+ await server?.pluginContainer.transform(code, mod.id);
64439
+ const hash = getHash(cleanUrl(mod.id));
64440
+ const result = htmlProxyResult.get(`${hash}_${index}`);
64441
+ overwriteAttrValue(s, location, result ?? '');
64442
+ }),
64443
+ ]);
65496
64444
  html = s.toString();
65497
64445
  return {
65498
64446
  html,
@@ -65673,7 +64621,11 @@ class ModuleGraph {
65673
64621
  mod.ssrTransformResult = null;
65674
64622
  mod.ssrModule = null;
65675
64623
  mod.ssrError = null;
65676
- // Fix #3033
64624
+ // https://github.com/vitejs/vite/issues/3033
64625
+ // Given b.js -> c.js -> b.js (arrow means top-level import), if c.js self-accepts
64626
+ // and refetches itself, the execution order becomes c.js -> b.js -> c.js. The import
64627
+ // order matters here as it will fail. The workaround for now is to not hmr invalidate
64628
+ // b.js so that c.js refetches the already cached b.js, skipping the import loop.
65677
64629
  if (hmrBoundaries.includes(mod)) {
65678
64630
  return;
65679
64631
  }
@@ -66918,8 +65870,8 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
66918
65870
  */
66919
65871
  function resolveBaseUrl(base = '/', isBuild, logger) {
66920
65872
  if (base[0] === '.') {
66921
- logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "base" option: ${base}. The value can only be an absolute ` +
66922
- `URL, ./, or an empty string.`)));
65873
+ logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "base" option: "${base}". The value can only be an absolute ` +
65874
+ `URL, "./", or an empty string.`)));
66923
65875
  return '/';
66924
65876
  }
66925
65877
  // external URL flag
@@ -67000,7 +65952,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
67000
65952
  const config = await (typeof userConfig === 'function'
67001
65953
  ? userConfig(configEnv)
67002
65954
  : userConfig);
67003
- if (!isObject$2(config)) {
65955
+ if (!isObject$1(config)) {
67004
65956
  throw new Error(`config must export or return an object.`);
67005
65957
  }
67006
65958
  return {
@@ -67201,4 +66153,4 @@ function isDepsOptimizerEnabled(config, ssr) {
67201
66153
  (command === 'serve' && disabled === 'dev'));
67202
66154
  }
67203
66155
 
67204
- export { loadEnv as A, resolveEnvPrefix as B, colors$1 as C, getDefaultExportFromCjs as D, commonjsGlobal as E, index$1 as F, build$1 as G, index as H, preview$1 as I, preprocessCSS as a, build as b, createServer as c, resolvePackageData as d, buildErrorMessage as e, formatPostcssSourceMap as f, defineConfig as g, resolveConfig as h, isInNodeModules$1 as i, resolveBaseUrl as j, getDepOptimizationConfig as k, loadConfigFromFile as l, isDepsOptimizerEnabled as m, normalizePath$3 as n, optimizeDeps as o, preview as p, mergeConfig as q, resolvePackageEntry as r, sortUserPlugins as s, transformWithEsbuild as t, mergeAlias as u, createFilter as v, send$2 as w, createLogger as x, searchForWorkspaceRoot as y, isFileServingAllowed as z };
66156
+ export { index$1 as A, build$1 as B, index as C, preview$1 as D, preprocessCSS as a, build as b, createServer as c, defineConfig as d, buildErrorMessage as e, formatPostcssSourceMap as f, mergeAlias as g, createFilter as h, isInNodeModules$1 as i, send$2 as j, createLogger as k, loadConfigFromFile as l, mergeConfig as m, normalizePath$3 as n, optimizeDeps as o, preview as p, searchForWorkspaceRoot as q, resolveConfig as r, sortUserPlugins as s, transformWithEsbuild as t, isFileServingAllowed as u, loadEnv as v, resolveEnvPrefix as w, colors$1 as x, getDefaultExportFromCjs as y, commonjsGlobal as z };