Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js
rd565449 r0c6b92a 10792 10792 charToInt[c] = i; 10793 10793 } 10794 function decodeInteger(reader, relative) { 10795 let value = 0; 10796 let shift = 0; 10797 let integer = 0; 10798 do { 10799 const c = reader.next(); 10800 integer = charToInt[c]; 10801 value |= (integer & 31) << shift; 10802 shift += 5; 10803 } while (integer & 32); 10804 const shouldNegate = value & 1; 10805 value >>>= 1; 10806 if (shouldNegate) { 10807 value = -0x80000000 | -value; 10808 } 10809 return relative + value; 10810 } 10811 function encodeInteger(builder, num, relative) { 10812 let delta = num - relative; 10813 delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; 10814 do { 10815 let clamped = delta & 0b011111; 10816 delta >>>= 5; 10817 if (delta > 0) 10818 clamped |= 0b100000; 10819 builder.write(intToChar[clamped]); 10820 } while (delta > 0); 10821 return num; 10822 } 10823 function hasMoreVlq(reader, max) { 10824 if (reader.pos >= max) 10825 return false; 10826 return reader.peek() !== comma; 10827 } 10828 10829 const bufLength = 1024 * 16; 10794 10830 // Provide a fallback for older environments. 10795 10831 const td = typeof TextDecoder !== 'undefined' … … 10811 10847 }, 10812 10848 }; 10849 class StringWriter { 10850 constructor() { 10851 this.pos = 0; 10852 this.out = ''; 10853 this.buffer = new Uint8Array(bufLength); 10854 } 10855 write(v) { 10856 const { buffer } = this; 10857 buffer[this.pos++] = v; 10858 if (this.pos === bufLength) { 10859 this.out += td.decode(buffer); 10860 this.pos = 0; 10861 } 10862 } 10863 flush() { 10864 const { buffer, out, pos } = this; 10865 return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; 10866 } 10867 } 10868 class StringReader { 10869 constructor(buffer) { 10870 this.pos = 0; 10871 this.buffer = buffer; 10872 } 10873 next() { 10874 return this.buffer.charCodeAt(this.pos++); 10875 } 10876 peek() { 10877 return this.buffer.charCodeAt(this.pos); 10878 } 10879 indexOf(char) { 10880 const { buffer, pos } = this; 10881 const idx = buffer.indexOf(char, pos); 10882 return idx === -1 ? buffer.length : idx; 10883 } 10884 } 10885 10813 10886 function decode(mappings) { 10814 const state = new Int32Array(5); 10887 const { length } = mappings; 10888 const reader = new StringReader(mappings); 10815 10889 const decoded = []; 10816 let index = 0; 10890 let genColumn = 0; 10891 let sourcesIndex = 0; 10892 let sourceLine = 0; 10893 let sourceColumn = 0; 10894 let namesIndex = 0; 10817 10895 do { 10818 const semi = indexOf(mappings, index);10896 const semi = reader.indexOf(';'); 10819 10897 const line = []; 10820 10898 let sorted = true; 10821 10899 let lastCol = 0; 10822 state[0]= 0;10823 for (let i = index; i < semi; i++) {10900 genColumn = 0; 10901 while (reader.pos < semi) { 10824 10902 let seg; 10825 i = decodeInteger(mappings, i, state, 0); // genColumn 10826 const col = state[0]; 10827 if (col < lastCol) 10903 genColumn = decodeInteger(reader, genColumn); 10904 if (genColumn < lastCol) 10828 10905 sorted = false; 10829 lastCol = col;10830 if (hasMoreVlq( mappings, i, semi)) {10831 i = decodeInteger(mappings, i, state, 1); // sourcesIndex10832 i = decodeInteger(mappings, i, state, 2); // sourceLine10833 i = decodeInteger(mappings, i, state, 3); // sourceColumn10834 if (hasMoreVlq( mappings, i, semi)) {10835 i = decodeInteger(mappings, i, state, 4); // namesIndex10836 seg = [ col, state[1], state[2], state[3], state[4]];10906 lastCol = genColumn; 10907 if (hasMoreVlq(reader, semi)) { 10908 sourcesIndex = decodeInteger(reader, sourcesIndex); 10909 sourceLine = decodeInteger(reader, sourceLine); 10910 sourceColumn = decodeInteger(reader, sourceColumn); 10911 if (hasMoreVlq(reader, semi)) { 10912 namesIndex = decodeInteger(reader, namesIndex); 10913 seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]; 10837 10914 } 10838 10915 else { 10839 seg = [ col, state[1], state[2], state[3]];10916 seg = [genColumn, sourcesIndex, sourceLine, sourceColumn]; 10840 10917 } 10841 10918 } 10842 10919 else { 10843 seg = [ col];10920 seg = [genColumn]; 10844 10921 } 10845 10922 line.push(seg); 10923 reader.pos++; 10846 10924 } 10847 10925 if (!sorted) 10848 10926 sort(line); 10849 10927 decoded.push(line); 10850 index= semi + 1;10851 } while ( index <= mappings.length);10928 reader.pos = semi + 1; 10929 } while (reader.pos <= length); 10852 10930 return decoded; 10853 }10854 function indexOf(mappings, index) {10855 const idx = mappings.indexOf(';', index);10856 return idx === -1 ? mappings.length : idx;10857 }10858 function decodeInteger(mappings, pos, state, j) {10859 let value = 0;10860 let shift = 0;10861 let integer = 0;10862 do {10863 const c = mappings.charCodeAt(pos++);10864 integer = charToInt[c];10865 value |= (integer & 31) << shift;10866 shift += 5;10867 } while (integer & 32);10868 const shouldNegate = value & 1;10869 value >>>= 1;10870 if (shouldNegate) {10871 value = -0x80000000 | -value;10872 }10873 state[j] += value;10874 return pos;10875 }10876 function hasMoreVlq(mappings, i, length) {10877 if (i >= length)10878 return false;10879 return mappings.charCodeAt(i) !== comma;10880 10931 } 10881 10932 function sort(line) { … … 10886 10937 } 10887 10938 function encode$1(decoded) { 10888 const state = new Int32Array(5); 10889 const bufLength = 1024 * 16; 10890 const subLength = bufLength - 36; 10891 const buf = new Uint8Array(bufLength); 10892 const sub = buf.subarray(0, subLength); 10893 let pos = 0; 10894 let out = ''; 10939 const writer = new StringWriter(); 10940 let sourcesIndex = 0; 10941 let sourceLine = 0; 10942 let sourceColumn = 0; 10943 let namesIndex = 0; 10895 10944 for (let i = 0; i < decoded.length; i++) { 10896 10945 const line = decoded[i]; 10897 if (i > 0) { 10898 if (pos === bufLength) { 10899 out += td.decode(buf); 10900 pos = 0; 10901 } 10902 buf[pos++] = semicolon; 10903 } 10946 if (i > 0) 10947 writer.write(semicolon); 10904 10948 if (line.length === 0) 10905 10949 continue; 10906 state[0]= 0;10950 let genColumn = 0; 10907 10951 for (let j = 0; j < line.length; j++) { 10908 10952 const segment = line[j]; 10909 // We can push up to 5 ints, each int can take at most 7 chars, and we10910 // may push a comma.10911 if (pos > subLength) {10912 out += td.decode(sub);10913 buf.copyWithin(0, subLength, pos);10914 pos -= subLength;10915 }10916 10953 if (j > 0) 10917 buf[pos++] = comma;10918 pos = encodeInteger(buf, pos, state, segment, 0); // genColumn10954 writer.write(comma); 10955 genColumn = encodeInteger(writer, segment[0], genColumn); 10919 10956 if (segment.length === 1) 10920 10957 continue; 10921 pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex10922 pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine10923 pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn10958 sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); 10959 sourceLine = encodeInteger(writer, segment[2], sourceLine); 10960 sourceColumn = encodeInteger(writer, segment[3], sourceColumn); 10924 10961 if (segment.length === 4) 10925 10962 continue; 10926 pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex 10927 } 10928 } 10929 return out + td.decode(buf.subarray(0, pos)); 10930 } 10931 function encodeInteger(buf, pos, state, segment, j) { 10932 const next = segment[j]; 10933 let num = next - state[j]; 10934 state[j] = next; 10935 num = num < 0 ? (-num << 1) | 1 : num << 1; 10936 do { 10937 let clamped = num & 0b011111; 10938 num >>>= 5; 10939 if (num > 0) 10940 clamped |= 0b100000; 10941 buf[pos++] = intToChar[clamped]; 10942 } while (num > 0); 10943 return pos; 10963 namesIndex = encodeInteger(writer, segment[4], namesIndex); 10964 } 10965 } 10966 return writer.flush(); 10944 10967 } 10945 10968 … … 11699 11722 if (typeof content !== 'string') throw new TypeError('replacement content must be a string'); 11700 11723 11701 while (start < 0) start += this.original.length; 11702 while (end < 0) end += this.original.length; 11724 if (this.original.length !== 0) { 11725 while (start < 0) start += this.original.length; 11726 while (end < 0) end += this.original.length; 11727 } 11703 11728 11704 11729 if (end > this.original.length) throw new Error('end is out of bounds'); … … 11796 11821 11797 11822 remove(start, end) { 11798 while (start < 0) start += this.original.length; 11799 while (end < 0) end += this.original.length; 11823 if (this.original.length !== 0) { 11824 while (start < 0) start += this.original.length; 11825 while (end < 0) end += this.original.length; 11826 } 11800 11827 11801 11828 if (start === end) return this; … … 11820 11847 11821 11848 reset(start, end) { 11822 while (start < 0) start += this.original.length; 11823 while (end < 0) end += this.original.length; 11849 if (this.original.length !== 0) { 11850 while (start < 0) start += this.original.length; 11851 while (end < 0) end += this.original.length; 11852 } 11824 11853 11825 11854 if (start === end) return this; … … 11883 11912 11884 11913 slice(start = 0, end = this.original.length) { 11885 while (start < 0) start += this.original.length; 11886 while (end < 0) end += this.original.length; 11914 if (this.original.length !== 0) { 11915 while (start < 0) start += this.original.length; 11916 while (end < 0) end += this.original.length; 11917 } 11887 11918 11888 11919 let result = ''; … … 16020 16051 } 16021 16052 16053 let m; 16054 16022 16055 // Is webkit? http://stackoverflow.com/a/16459606/376773 16023 16056 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 … … 16027 16060 // Is firefox >= v31? 16028 16061 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 16029 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||16062 (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || 16030 16063 // Double check webkit in userAgent just in case we are in a worker 16031 16064 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); … … 16630 16663 invalidatePackageData(packageCache, path$n.normalize(id)); 16631 16664 } 16632 },16633 handleHotUpdate({ file }) {16634 if (file.endsWith("/package.json")) {16635 invalidatePackageData(packageCache, path$n.normalize(file));16636 }16637 16665 } 16638 16666 }; … … 16686 16714 const replaceSlashOrColonRE = /[/:]/g; 16687 16715 const replaceDotRE = /\./g; 16688 const replaceNestedIdRE = / (\s*>\s*)/g;16716 const replaceNestedIdRE = /\s*>\s*/g; 16689 16717 const replaceHashRE = /#/g; 16690 16718 const flattenId = (id) => { … … 17026 17054 for (const file of skip) { 17027 17055 if (path$n.dirname(file) !== ".") { 17028 const matched = file.match(splitFirstDirRE);17056 const matched = splitFirstDirRE.exec(file); 17029 17057 if (matched) { 17030 17058 nested ??= /* @__PURE__ */ new Map(); … … 17111 17139 return realPath; 17112 17140 } 17113 const parseNetUseRE = /^ (\w+)?+(\w:) +([^ ]+)\s/;17141 const parseNetUseRE = /^\w* +(\w:) +([^ ]+)\s/; 17114 17142 let firstSafeRealPathSyncRun = false; 17115 17143 function windowsSafeRealPathSync(path2) { … … 17138 17166 const lines = stdout.split("\n"); 17139 17167 for (const line of lines) { 17140 const m = line.match(parseNetUseRE);17141 if (m) windowsNetworkMap.set(m[ 3], m[2]);17168 const m = parseNetUseRE.exec(line); 17169 if (m) windowsNetworkMap.set(m[2], m[1]); 17142 17170 } 17143 17171 if (windowsNetworkMap.size === 0) { … … 17155 17183 } 17156 17184 } 17157 const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;17185 const escapedSpaceCharacters = /(?: |\\t|\\n|\\f|\\r)+/g; 17158 17186 const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/; 17159 17187 function joinSrcset(ret) { … … 17402 17430 ...backwardCompatibleWorkerPlugins(value) 17403 17431 ]; 17432 continue; 17433 } else if (key === "server" && rootPath === "server.hmr") { 17434 merged[key] = value; 17404 17435 continue; 17405 17436 } … … 18191 18222 let lastWildcardIndex = pattern.length; 18192 18223 let hasWildcard = false; 18224 let hasExtension = false; 18225 let hasSlash = false; 18226 let lastSlashIndex = -1; 18193 18227 for (let i = pattern.length - 1; i > -1; i--) { 18194 if (pattern[i] === '*' || pattern[i] === '?') { 18195 lastWildcardIndex = i; 18196 hasWildcard = true; 18228 const c = pattern[i]; 18229 if (!hasWildcard) { 18230 if (c === '*' || c === '?') { 18231 lastWildcardIndex = i; 18232 hasWildcard = true; 18233 } 18234 } 18235 if (!hasSlash) { 18236 if (c === '.') { 18237 hasExtension = true; 18238 } else if (c === '/') { 18239 lastSlashIndex = i; 18240 hasSlash = true; 18241 } 18242 } 18243 if (hasWildcard && hasSlash) { 18197 18244 break; 18198 18245 } 18246 } 18247 if (!hasExtension && (!hasWildcard || lastWildcardIndex < lastSlashIndex)) { 18248 // add implicit glob 18249 pattern += `${pattern.endsWith('/') ? '' : '/'}${GLOB_ALL_PATTERN}`; 18250 lastWildcardIndex = pattern.length - 1; 18251 hasWildcard = true; 18199 18252 } 18200 18253 … … 18235 18288 } 18236 18289 18237 // if no wildcard in pattern, filename must be equal to resolved pattern18238 18290 if (!hasWildcard) { 18291 // no wildcard in pattern, filename must be equal to resolved pattern 18239 18292 return filename === resolvedPattern; 18293 } else if ( 18294 firstWildcardIndex + GLOB_ALL_PATTERN.length === 18295 resolvedPattern.length - (pattern.length - 1 - lastWildcardIndex) && 18296 resolvedPattern.slice(firstWildcardIndex, firstWildcardIndex + GLOB_ALL_PATTERN.length) === 18297 GLOB_ALL_PATTERN 18298 ) { 18299 // singular glob-all pattern and we already validated prefix and suffix matches 18300 return true; 18240 18301 } 18241 18242 18302 // complex pattern, use regex to check it 18243 18303 if (PATTERN_REGEX_CACHE.has(resolvedPattern)) { … … 18296 18356 return JSON.parse( 18297 18357 JSON.stringify(tsconfig) 18298 // replace ${configDir} , accounting for rebaseRelative emitted ../${configDir}18299 .replaceAll(/" (?:\.\.\/)*\${configDir}/g, `"${native2posix(configDir)}`)18358 // replace ${configDir} 18359 .replaceAll(/"\${configDir}/g, `"${native2posix(configDir)}`) 18300 18360 ); 18301 18361 } … … 18891 18951 */ 18892 18952 function rebasePath(value, prependPath) { 18893 if (path$n.isAbsolute(value) ) {18953 if (path$n.isAbsolute(value) || value.startsWith('${configDir}')) { 18894 18954 return value; 18895 18955 } else { … … 19094 19154 19095 19155 const debug$h = createDebugger("vite:esbuild"); 19096 const IIFE_BEGIN_RE = /( const|var)\s+\S+\s*=\s*function\([^()]*\)\s*\{\s*"use strict";/;19156 const IIFE_BEGIN_RE = /(?:const|var)\s+\S+\s*=\s*function\([^()]*\)\s*\{\s*"use strict";/; 19097 19157 const validExtensionRE = /\.\w+$/; 19098 19158 const jsxExtensionsRE = /\.(?:j|t)sx\b/; … … 20276 20336 // Force rollup to keep this module from being shared between other entry points if it's an entrypoint. 20277 20337 // If the resulting chunk is empty, it will be removed in generateBundle. 20278 moduleSideEffects: config.command === "build" && this.getModuleInfo(id)?.isEntry ? "no-treeshake" : false 20338 moduleSideEffects: config.command === "build" && this.getModuleInfo(id)?.isEntry ? "no-treeshake" : false, 20339 meta: config.command === "build" ? { "vite:asset": true } : void 0 20279 20340 }; 20280 20341 }, … … 20293 20354 for (const file in bundle) { 20294 20355 const chunk = bundle[file]; 20295 if (chunk.type === "chunk" && chunk.isEntry && chunk.moduleIds.length === 1 && config.assetsInclude(chunk.moduleIds[0]) ) {20356 if (chunk.type === "chunk" && chunk.isEntry && chunk.moduleIds.length === 1 && config.assetsInclude(chunk.moduleIds[0]) && this.getModuleInfo(chunk.moduleIds[0])?.meta["vite:asset"]) { 20296 20357 delete bundle[file]; 20297 20358 } … … 20314 20375 } 20315 20376 } 20316 function fileToDevUrl(id, config ) {20377 function fileToDevUrl(id, config, skipBase = false) { 20317 20378 let rtn; 20318 20379 if (checkPublicFile(id, config)) { … … 20323 20384 rtn = path$n.posix.join(FS_PREFIX, id); 20324 20385 } 20325 const base = joinUrlSegments(config.server?.origin ?? "", config.base); 20386 if (skipBase) { 20387 return rtn; 20388 } 20389 const base = joinUrlSegments(config.server?.origin ?? "", config.decodedBase); 20326 20390 return joinUrlSegments(base, removeLeadingSlash(rtn)); 20327 20391 } … … 20333 20397 function publicFileToBuiltUrl(url, config) { 20334 20398 if (config.command !== "build") { 20335 return joinUrlSegments(config. base, url);20399 return joinUrlSegments(config.decodedBase, url); 20336 20400 } 20337 20401 const hash = getHash(url); … … 20378 20442 const { search, hash } = parse$h(id); 20379 20443 const postfix = (search || "") + (hash || ""); 20444 const originalFileName = normalizePath$3(path$n.relative(config.root, file)); 20380 20445 const referenceId = pluginContext.emitFile({ 20446 type: "asset", 20381 20447 // Ignore directory structure for asset file names 20382 20448 name: path$n.basename(file), 20383 type: "asset",20449 originalFileName, 20384 20450 source: content 20385 20451 }); 20386 const originalName = normalizePath$3(path$n.relative(config.root, file)); 20387 generatedAssets.get(config).set(referenceId, { originalName }); 20452 generatedAssets.get(config).set(referenceId, { originalFileName }); 20388 20453 url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`; 20389 20454 } … … 20496 20561 return manifestChunk; 20497 20562 } 20498 const fileNameToAssetMeta = /* @__PURE__ */ new Map();20499 20563 const assets = generatedAssets.get(config); 20500 assets.forEach((asset, referenceId) => { 20501 try { 20502 const fileName = this.getFileName(referenceId); 20503 fileNameToAssetMeta.set(fileName, asset); 20504 } catch (error) { 20505 assets.delete(referenceId); 20506 } 20507 }); 20564 const entryCssAssetFileNames = /* @__PURE__ */ new Set(); 20565 for (const [id, asset] of assets.entries()) { 20566 if (asset.isEntry) { 20567 try { 20568 const fileName = this.getFileName(id); 20569 entryCssAssetFileNames.add(fileName); 20570 } catch (error) { 20571 assets.delete(id); 20572 } 20573 } 20574 } 20508 20575 const fileNameToAsset = /* @__PURE__ */ new Map(); 20509 20576 for (const file in bundle) { … … 20512 20579 manifest[getChunkName(chunk)] = createChunk(chunk); 20513 20580 } else if (chunk.type === "asset" && typeof chunk.name === "string") { 20514 const assetMeta = fileNameToAssetMeta.get(chunk.fileName);20515 const src = assetMeta?.originalName ?? chunk.name;20516 const asset = createAsset(chunk, src, assetMeta?.isEntry);20581 const src = chunk.originalFileName ?? chunk.name; 20582 const isEntry = entryCssAssetFileNames.has(chunk.fileName); 20583 const asset = createAsset(chunk, src, isEntry); 20517 20584 const file2 = manifest[src]?.file; 20518 20585 if (file2 && endsWithJSRE.test(file2)) continue; … … 20521 20588 } 20522 20589 } 20523 assets.forEach(({ originalName }, referenceId) =>{20524 if (!manifest[original Name]) {20590 for (const [referenceId, { originalFileName }] of assets.entries()) { 20591 if (!manifest[originalFileName]) { 20525 20592 const fileName = this.getFileName(referenceId); 20526 20593 const asset = fileNameToAsset.get(fileName); 20527 20594 if (asset) { 20528 manifest[original Name] = asset;20595 manifest[originalFileName] = asset; 20529 20596 } 20530 20597 } 20531 } );20598 } 20532 20599 outputCount++; 20533 20600 const output = config.build.rollupOptions?.output; … … 20568 20635 }, 20569 20636 resolveId(id) { 20570 if (! dataUriRE.test(id)) {20637 if (!id.trimStart().startsWith("data:")) { 20571 20638 return; 20572 20639 } … … 20575 20642 return; 20576 20643 } 20577 const match = uri.pathname.match(dataUriRE);20644 const match = dataUriRE.exec(uri.pathname); 20578 20645 if (!match) { 20579 20646 return; … … 22732 22799 const picomatch$2 = picomatch$3; 22733 22800 const utils$b = utils$k; 22734 const isEmptyString = val => val === '' || val === './'; 22801 22802 const isEmptyString = v => v === '' || v === './'; 22803 const hasBraces = v => { 22804 const index = v.indexOf('{'); 22805 return index > -1 && v.indexOf('}', index) > -1; 22806 }; 22735 22807 22736 22808 /** … … 23173 23245 micromatch$1.braces = (pattern, options) => { 23174 23246 if (typeof pattern !== 'string') throw new TypeError('Expected a string'); 23175 if ((options && options.nobrace === true) || ! /\{.*\}/.test(pattern)) {23247 if ((options && options.nobrace === true) || !hasBraces(pattern)) { 23176 23248 return [pattern]; 23177 23249 } … … 23192 23264 */ 23193 23265 23266 // exposed for tests 23267 micromatch$1.hasBraces = hasBraces; 23194 23268 var micromatch_1 = micromatch$1; 23195 23269 … … 27038 27112 } 27039 27113 } 27040 Collection.maxFlowStringSingleLineLength = 60;27041 27114 27042 27115 /** … … 27070 27143 if (!lineWidth || lineWidth < 0) 27071 27144 return text; 27145 if (lineWidth < minContentWidth) 27146 minContentWidth = 0; 27072 27147 const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); 27073 27148 if (text.length <= endStep) … … 29642 29717 let commentSep = ''; 29643 29718 let hasNewline = false; 29644 let hasNewlineAfterProp = false;29645 29719 let reqSpace = false; 29646 29720 let tab = null; 29647 29721 let anchor = null; 29648 29722 let tag = null; 29723 let newlineAfterProp = null; 29649 29724 let comma = null; 29650 29725 let found = null; … … 29700 29775 hasNewline = true; 29701 29776 if (anchor || tag) 29702 hasNewlineAfterProp = true;29777 newlineAfterProp = token; 29703 29778 hasSpace = true; 29704 29779 break; … … 29774 29849 comment, 29775 29850 hasNewline, 29776 hasNewlineAfterProp,29777 29851 anchor, 29778 29852 tag, 29853 newlineAfterProp, 29779 29854 end, 29780 29855 start: start ?? end … … 29878 29953 continue; 29879 29954 } 29880 if (keyProps. hasNewlineAfterProp || containsNewline(key)) {29955 if (keyProps.newlineAfterProp || containsNewline(key)) { 29881 29956 onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); 29882 29957 } … … 30232 30307 return coll; 30233 30308 } 30234 function composeCollection(CN, ctx, token, tagToken, onError) { 30309 function composeCollection(CN, ctx, token, props, onError) { 30310 const tagToken = props.tag; 30235 30311 const tagName = !tagToken 30236 30312 ? null 30237 30313 : ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)); 30314 if (token.type === 'block-seq') { 30315 const { anchor, newlineAfterProp: nl } = props; 30316 const lastProp = anchor && tagToken 30317 ? anchor.offset > tagToken.offset 30318 ? anchor 30319 : tagToken 30320 : (anchor ?? tagToken); 30321 if (lastProp && (!nl || nl.offset < lastProp.offset)) { 30322 const message = 'Missing newline after block sequence props'; 30323 onError(lastProp, 'MISSING_CHAR', message); 30324 } 30325 } 30238 30326 const expType = token.type === 'block-map' 30239 30327 ? 'map' … … 30249 30337 tagName === '!' || 30250 30338 (tagName === YAMLMap.tagName && expType === 'map') || 30251 (tagName === YAMLSeq.tagName && expType === 'seq') || 30252 !expType) { 30339 (tagName === YAMLSeq.tagName && expType === 'seq')) { 30253 30340 return resolveCollection(CN, ctx, token, onError, tagName); 30254 30341 } … … 30818 30905 case 'block-seq': 30819 30906 case 'flow-collection': 30820 node = composeCollection(CN, ctx, token, tag, onError);30907 node = composeCollection(CN, ctx, token, props, onError); 30821 30908 if (anchor) 30822 30909 node.anchor = anchor.source.substring(1); … … 31890 31977 return this.setNext('line-start'); 31891 31978 const s = this.peek(3); 31892 if ( s === '---'&& isEmpty(this.charAt(3))) {31979 if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) { 31893 31980 yield* this.pushCount(3); 31894 31981 this.indentValue = 0; 31895 31982 this.indentNext = 0; 31896 return 'doc'; 31897 } 31898 else if (s === '...' && isEmpty(this.charAt(3))) { 31899 yield* this.pushCount(3); 31900 return 'stream'; 31983 return s === '---' ? 'doc' : 'stream'; 31901 31984 } 31902 31985 } … … 32416 32499 break loop; 32417 32500 } 32418 }32419 while (prev[++i]?.type === 'space') {32420 /* loop */32421 32501 } 32422 32502 return prev.splice(i, prev.length); … … 34926 35006 } 34927 35007 34928 const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.( js|css)$/;35008 const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/; 34929 35009 const isHtmlProxyRE = /\?html-proxy\b/; 34930 35010 const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g; … … 34953 35033 }, 34954 35034 load(id) { 34955 const proxyMatch = id.match(htmlProxyRE$1);35035 const proxyMatch = htmlProxyRE$1.exec(id); 34956 35036 if (proxyMatch) { 34957 35037 const index = Number(proxyMatch[1]); … … 34999 35079 } 35000 35080 function traverseNodes(node, visitor) { 35081 if (node.nodeName === "template") { 35082 node = node.content; 35083 } 35001 35084 visitor(node); 35002 35085 if (nodeIsElement(node) || node.nodeName === "#document" || node.nodeName === "#document-fragment") { … … 35042 35125 sourceCodeLocation.endOffset 35043 35126 ); 35044 const valueStart = srcString.match(attrValueStartRE);35127 const valueStart = attrValueStartRE.exec(srcString); 35045 35128 if (!valueStart) { 35046 35129 throw new Error( … … 35110 35193 if (id.endsWith(".html")) { 35111 35194 id = normalizePath$3(id); 35112 const relativeUrlPath = path$n.posix.relative(config.root, id);35195 const relativeUrlPath = normalizePath$3(path$n.relative(config.root, id)); 35113 35196 const publicPath = `/${relativeUrlPath}`; 35114 35197 const publicBase = getBaseInHTML(relativeUrlPath, config); … … 35444 35527 }; 35445 35528 for (const [normalizedId, html] of processedHtml) { 35446 const relativeUrlPath = path$n.posix.relative(config.root, normalizedId); 35529 const relativeUrlPath = normalizePath$3( 35530 path$n.relative(config.root, normalizedId) 35531 ); 35447 35532 const assetsBase = getBaseInHTML(relativeUrlPath, config); 35448 35533 const toOutputFilePath = (filename, type) => { … … 35560 35645 this.emitFile({ 35561 35646 type: "asset", 35647 originalFileName: normalizedId, 35562 35648 fileName: shortEmitName, 35563 35649 source: result … … 35828 35914 return html; 35829 35915 } 35830 const importRE = /\bimport\s*( "[^"]*[^\\]"|'[^']*[^\\]');*/g;35916 const importRE = /\bimport\s*(?:"[^"]*[^\\]"|'[^']*[^\\]');*/g; 35831 35917 const commentRE$1 = /\/\*[\s\S]*?\*\/|\/\/.*$/gm; 35832 35918 function isEntirelyImport(code) { … … 35981 36067 const functionCallRE = /^[A-Z_][\w-]*\(/i; 35982 36068 const transformOnlyRE = /[?&]transform-only\b/; 35983 const nonEscapedDoubleQuoteRe = /(?<!\\) (")/g;36069 const nonEscapedDoubleQuoteRe = /(?<!\\)"/g; 35984 36070 const cssBundleName = "style.css"; 35985 36071 const isCSSRequest = (request) => CSS_LANGS_RE.test(request); … … 36122 36208 return path$n.dirname( 36123 36209 assetFileNames({ 36210 type: "asset", 36124 36211 name: cssAssetName, 36125 type: "asset",36212 originalFileName: null, 36126 36213 source: "/* vite internal call, ignore */" 36127 36214 }) … … 36241 36328 const cssAssetDirname = encodedPublicUrls || relative ? slash$1(getCssAssetDirname(cssAssetName)) : void 0; 36242 36329 const toRelative = (filename) => { 36243 const relativePath = path$n.posix.relative(cssAssetDirname, filename); 36330 const relativePath = normalizePath$3( 36331 path$n.relative(cssAssetDirname, filename) 36332 ); 36244 36333 return relativePath[0] === "." ? relativePath : "./" + relativePath; 36245 36334 }; … … 36259 36348 }); 36260 36349 if (encodedPublicUrls) { 36261 const relativePathToPublicFromCSS = path$n.posix.relative( 36262 cssAssetDirname, 36263 "" 36350 const relativePathToPublicFromCSS = normalizePath$3( 36351 path$n.relative(cssAssetDirname, "") 36264 36352 ); 36265 36353 chunkCSS2 = chunkCSS2.replace(publicAssetUrlRE, (_, hash) => { … … 36292 36380 const [full, idHex] = match; 36293 36381 const id = Buffer.from(idHex, "hex").toString(); 36294 const originalFile name = cleanUrl(id);36382 const originalFileName = cleanUrl(id); 36295 36383 const cssAssetName = ensureFileExt( 36296 path$n.basename(originalFile name),36384 path$n.basename(originalFileName), 36297 36385 ".css" 36298 36386 ); … … 36306 36394 urlEmitTasks.push({ 36307 36395 cssAssetName, 36308 originalFile name,36396 originalFileName, 36309 36397 content: cssContent, 36310 36398 start: match.index, … … 36328 36416 for (const { 36329 36417 cssAssetName, 36330 originalFile name,36418 originalFileName, 36331 36419 content, 36332 36420 start, … … 36334 36422 } of urlEmitTasks) { 36335 36423 const referenceId = this.emitFile({ 36424 type: "asset", 36336 36425 name: cssAssetName, 36337 type: "asset",36426 originalFileName, 36338 36427 source: content 36339 36428 }); 36340 generatedAssets.get(config).set(referenceId, { original Name: originalFilename });36429 generatedAssets.get(config).set(referenceId, { originalFileName }); 36341 36430 const filename = this.getFileName(referenceId); 36342 36431 chunk.viteMetadata.importedAssets.add(cleanUrl(filename)); … … 36362 36451 const cssFullAssetName = ensureFileExt(chunk.name, ".css"); 36363 36452 const cssAssetName = chunk.isEntry && (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId)) ? path$n.basename(cssFullAssetName) : cssFullAssetName; 36364 const originalFile name = getChunkOriginalFileName(36453 const originalFileName = getChunkOriginalFileName( 36365 36454 chunk, 36366 36455 config.root, … … 36372 36461 }); 36373 36462 const referenceId = this.emitFile({ 36463 type: "asset", 36374 36464 name: cssAssetName, 36375 type: "asset",36465 originalFileName, 36376 36466 source: chunkCSS 36377 36467 }); 36378 generatedAssets.get(config).set(referenceId, { original Name: originalFilename, isEntry });36468 generatedAssets.get(config).set(referenceId, { originalFileName, isEntry }); 36379 36469 chunk.viteMetadata.importedCss.add(this.getFileName(referenceId)); 36380 36470 } else if (!config.build.ssr) { … … 36504 36594 }); 36505 36595 } 36596 const cssAssets = Object.values(bundle).filter( 36597 (asset) => asset.type === "asset" && asset.fileName.endsWith(".css") 36598 ); 36599 for (const cssAsset of cssAssets) { 36600 if (typeof cssAsset.source === "string") { 36601 cssAsset.source = cssAsset.source.replace(viteHashUpdateMarkerRE, ""); 36602 } 36603 } 36506 36604 } 36507 36605 }; … … 36526 36624 if (pluginImports) { 36527 36625 const depModules = /* @__PURE__ */ new Set(); 36528 const devBase = config.base;36529 36626 for (const file of pluginImports) { 36530 36627 depModules.add( 36531 36628 isCSSRequest(file) ? moduleGraph.createFileOnlyEntry(file) : await moduleGraph.ensureEntryFromUrl( 36532 stripBase( 36533 await fileToUrl$1(file, config, this), 36534 (config.server?.origin ?? "") + devBase 36629 fileToDevUrl( 36630 file, 36631 config, 36632 /* skipBase */ 36633 true 36535 36634 ), 36536 36635 ssr … … 36583 36682 }, 36584 36683 get sass() { 36585 return sassResolve || (sassResolve = config.createResolver({ 36586 extensions: [".scss", ".sass", ".css"], 36587 mainFields: ["sass", "style"], 36588 conditions: ["sass", "style"], 36589 tryIndex: true, 36590 tryPrefix: "_", 36591 preferRelative: true 36592 })); 36684 if (!sassResolve) { 36685 const resolver = config.createResolver({ 36686 extensions: [".scss", ".sass", ".css"], 36687 mainFields: ["sass", "style"], 36688 conditions: ["sass", "style"], 36689 tryIndex: true, 36690 tryPrefix: "_", 36691 preferRelative: true 36692 }); 36693 sassResolve = async (...args) => { 36694 if (args[0].startsWith("file://")) { 36695 args[0] = fileURLToPath(args[0]); 36696 } 36697 return resolver(...args); 36698 }; 36699 } 36700 return sassResolve; 36593 36701 }, 36594 36702 get less() { … … 36676 36784 const needInlineImport = code.includes("@import"); 36677 36785 const hasUrl = cssUrlRE.test(code) || cssImageSetRE.test(code); 36678 const lang = id.match(CSS_LANGS_RE)?.[1];36786 const lang = CSS_LANGS_RE.exec(id)?.[1]; 36679 36787 const postcssConfig = await resolvePostcssConfig(config); 36680 36788 if (lang === "css" && !postcssConfig && !isModule && !needInlineImport && !hasUrl) { … … 36725 36833 async load(id2) { 36726 36834 const code2 = await fs__default.promises.readFile(id2, "utf-8"); 36727 const lang2 = id2.match(CSS_LANGS_RE)?.[1];36835 const lang2 = CSS_LANGS_RE.exec(id2)?.[1]; 36728 36836 if (isPreProcessor(lang2)) { 36729 36837 const result = await compileCSSPreprocessors( … … 36883 36991 }; 36884 36992 } 36885 const importPostcssImport = createCachedImport(() => import('./dep- VqAwxVIc.js').then(function (n) { return n.i; }));36886 const importPostcssModules = createCachedImport(() => import('./dep- CjZz522d.js').then(function (n) { return n.i; }));36993 const importPostcssImport = createCachedImport(() => import('./dep-C6EFp3uH.js').then(function (n) { return n.i; })); 36994 const importPostcssModules = createCachedImport(() => import('./dep-Ba1kN6Mp.js').then(function (n) { return n.i; })); 36887 36995 const importPostcss = createCachedImport(() => import('postcss')); 36888 36996 const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap(); … … 36922 37030 ]) : map1; 36923 37031 } 37032 const viteHashUpdateMarker = "/*$vite$:1*/"; 37033 const viteHashUpdateMarkerRE = /\/\*\$vite\$:\d+\*\//; 36924 37034 async function finalizeCss(css, minify, config) { 36925 37035 if (css.includes("@import") || css.includes("@charset")) { … … 36929 37039 css = await minifyCSS(css, config, false); 36930 37040 } 37041 css += viteHashUpdateMarker; 36931 37042 return css; 36932 37043 } … … 37191 37302 } 37192 37303 } 37304 function loadSassPackage(root) { 37305 try { 37306 const path2 = loadPreprocessorPath("sass-embedded", root); 37307 return { name: "sass-embedded", path: path2 }; 37308 } catch (e1) { 37309 try { 37310 const path2 = loadPreprocessorPath("sass" /* sass */, root); 37311 return { name: "sass", path: path2 }; 37312 } catch (e2) { 37313 throw e1; 37314 } 37315 } 37316 } 37193 37317 let cachedSss; 37194 37318 function loadSss(root) { … … 37218 37342 return data; 37219 37343 } 37220 const makeScssWorker = (resolvers, alias, maxWorkers ) => {37344 const makeScssWorker = (resolvers, alias, maxWorkers, packageName) => { 37221 37345 const internalImporter = async (url, importer, filename) => { 37222 37346 importer = cleanScssBugUrl(importer); … … 37231 37355 resolvers.sass 37232 37356 ); 37357 if (packageName === "sass-embedded") { 37358 return data; 37359 } 37233 37360 return fixScssBugImportValue(data); 37234 37361 } catch (data) { … … 37288 37415 return worker; 37289 37416 }; 37417 const makeModernScssWorker = (resolvers, alias, maxWorkers) => { 37418 const internalCanonicalize = async (url, importer) => { 37419 importer = cleanScssBugUrl(importer); 37420 const resolved = await resolvers.sass(url, importer); 37421 return resolved ?? null; 37422 }; 37423 const internalLoad = async (file, rootFile) => { 37424 const result = await rebaseUrls(file, rootFile, alias, "$", resolvers.sass); 37425 if (result.contents) { 37426 return result.contents; 37427 } 37428 return await fsp.readFile(result.file, "utf-8"); 37429 }; 37430 const worker = new WorkerWithFallback( 37431 () => async (sassPath, data, options) => { 37432 const sass = require(sassPath); 37433 const path2 = require("node:path"); 37434 const { fileURLToPath: fileURLToPath2, pathToFileURL: pathToFileURL2 } = ( 37435 // eslint-disable-next-line no-restricted-globals 37436 require("node:url") 37437 ); 37438 const sassOptions = { ...options }; 37439 sassOptions.url = pathToFileURL2(options.filename); 37440 sassOptions.sourceMap = options.enableSourcemap; 37441 const internalImporter = { 37442 async canonicalize(url, context) { 37443 const importer = context.containingUrl ? fileURLToPath2(context.containingUrl) : options.filename; 37444 const resolved = await internalCanonicalize(url, importer); 37445 return resolved ? pathToFileURL2(resolved) : null; 37446 }, 37447 async load(canonicalUrl) { 37448 const ext = path2.extname(canonicalUrl.pathname); 37449 let syntax = "scss"; 37450 if (ext === ".sass") { 37451 syntax = "indented"; 37452 } else if (ext === ".css") { 37453 syntax = "css"; 37454 } 37455 const contents = await internalLoad( 37456 fileURLToPath2(canonicalUrl), 37457 options.filename 37458 ); 37459 return { contents, syntax, sourceMapUrl: canonicalUrl }; 37460 } 37461 }; 37462 sassOptions.importers = [ 37463 ...sassOptions.importers ?? [], 37464 internalImporter 37465 ]; 37466 const result = await sass.compileStringAsync(data, sassOptions); 37467 return { 37468 css: result.css, 37469 map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0, 37470 stats: { 37471 includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath2(url)) 37472 } 37473 }; 37474 }, 37475 { 37476 parentFunctions: { 37477 internalCanonicalize, 37478 internalLoad 37479 }, 37480 shouldUseFake(_sassPath, _data, options) { 37481 return !!(options.functions && Object.keys(options.functions).length > 0 || options.importers && (!Array.isArray(options.importers) || options.importers.length > 0)); 37482 }, 37483 max: maxWorkers 37484 } 37485 ); 37486 return worker; 37487 }; 37488 const makeModernCompilerScssWorker = (resolvers, alias, _maxWorkers) => { 37489 let compilerPromise; 37490 const worker = { 37491 async run(sassPath, data, options) { 37492 const sass = (await import(pathToFileURL(sassPath).href)).default; 37493 compilerPromise ??= sass.initAsyncCompiler(); 37494 const compiler = await compilerPromise; 37495 const sassOptions = { ...options }; 37496 sassOptions.url = pathToFileURL(options.filename); 37497 sassOptions.sourceMap = options.enableSourcemap; 37498 const internalImporter = { 37499 async canonicalize(url, context) { 37500 const importer = context.containingUrl ? fileURLToPath(context.containingUrl) : options.filename; 37501 const resolved = await resolvers.sass(url, cleanScssBugUrl(importer)); 37502 return resolved ? pathToFileURL(resolved) : null; 37503 }, 37504 async load(canonicalUrl) { 37505 const ext = path$n.extname(canonicalUrl.pathname); 37506 let syntax = "scss"; 37507 if (ext === ".sass") { 37508 syntax = "indented"; 37509 } else if (ext === ".css") { 37510 syntax = "css"; 37511 } 37512 const result2 = await rebaseUrls( 37513 fileURLToPath(canonicalUrl), 37514 options.filename, 37515 alias, 37516 "$", 37517 resolvers.sass 37518 ); 37519 const contents = result2.contents ?? await fsp.readFile(result2.file, "utf-8"); 37520 return { contents, syntax, sourceMapUrl: canonicalUrl }; 37521 } 37522 }; 37523 sassOptions.importers = [ 37524 ...sassOptions.importers ?? [], 37525 internalImporter 37526 ]; 37527 const result = await compiler.compileStringAsync(data, sassOptions); 37528 return { 37529 css: result.css, 37530 map: result.sourceMap ? JSON.stringify(result.sourceMap) : void 0, 37531 stats: { 37532 includedFiles: result.loadedUrls.filter((url) => url.protocol === "file:").map((url) => fileURLToPath(url)) 37533 } 37534 }; 37535 }, 37536 async stop() { 37537 (await compilerPromise)?.dispose(); 37538 compilerPromise = void 0; 37539 } 37540 }; 37541 return worker; 37542 }; 37290 37543 const scssProcessor = (maxWorkers) => { 37291 37544 const workerMap = /* @__PURE__ */ new Map(); … … 37297 37550 }, 37298 37551 async process(source, root, options, resolvers) { 37299 const sassPath = loadPreprocessorPath("sass" /* sass */, root); 37552 const sassPackage = loadSassPackage(root); 37553 const api = options.api ?? "legacy"; 37300 37554 if (!workerMap.has(options.alias)) { 37301 37555 workerMap.set( 37302 37556 options.alias, 37303 makeScssWorker(resolvers, options.alias, maxWorkers) 37557 api === "modern-compiler" ? makeModernCompilerScssWorker(resolvers, options.alias) : api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker( 37558 resolvers, 37559 options.alias, 37560 maxWorkers, 37561 sassPackage.name 37562 ) 37304 37563 ); 37305 37564 } … … 37317 37576 try { 37318 37577 const result = await worker.run( 37319 sassPa th,37578 sassPackage.path, 37320 37579 data, 37321 37580 optionsWithoutAdditionalData … … 37323 37582 const deps = result.stats.includedFiles.map((f) => cleanScssBugUrl(f)); 37324 37583 const map2 = result.map ? JSON.parse(result.map.toString()) : void 0; 37584 if (map2) { 37585 map2.sources = map2.sources.map( 37586 (url) => url.startsWith("file://") ? normalizePath$3(fileURLToPath(url)) : url 37587 ); 37588 } 37325 37589 return { 37326 37590 code: result.css.toString(), … … 37652 37916 source, 37653 37917 root, 37654 { ...options, indentedSyntax: true },37918 { ...options, indentedSyntax: true, syntax: "indented" }, 37655 37919 resolvers 37656 37920 ); … … 37740 38004 deps.add(dep.url); 37741 38005 if (urlReplacer) { 37742 const replaceUrl = await urlReplacer(dep.url, id); 38006 const replaceUrl = await urlReplacer( 38007 dep.url, 38008 toAbsolute(dep.loc.filePath) 38009 ); 37743 38010 css = css.replace(dep.placeholder, () => replaceUrl); 37744 38011 } else { … … 37809 38076 const targets = {}; 37810 38077 const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => { 37811 const match = e .match(esRE);38078 const match = esRE.exec(e); 37812 38079 if (!match) return e; 37813 38080 const year = Number(match[1]); … … 44839 45106 emacs: 'emacs', 44840 45107 gvim: 'gvim', 45108 idea: 'idea', 44841 45109 'idea.sh': 'idea', 45110 phpstorm: 'phpstorm', 44842 45111 'phpstorm.sh': 'phpstorm', 45112 pycharm: 'pycharm', 44843 45113 'pycharm.sh': 'pycharm', 45114 rubymine: 'rubymine', 44844 45115 'rubymine.sh': 'rubymine', 44845 45116 sublime_text: 'subl', 44846 45117 vim: 'vim', 45118 webstorm: 'webstorm', 44847 45119 'webstorm.sh': 'webstorm', 45120 goland: 'goland', 44848 45121 'goland.sh': 'goland', 45122 rider: 'rider', 44849 45123 'rider.sh': 'rider' 44850 45124 }; … … 45156 45430 } 45157 45431 45158 // cmd.exe on Windows is vulnerable to RCE attacks given a file name of the45159 // form "C:\Users\myusername\Downloads\& curl 172.21.93.52". Use a safe file45160 // name pattern to validate user-provided file names. This doesn't cover the45161 // entire range of valid file names but should cover almost all of them in practice.45162 // (Backport of45163 // https://github.com/facebook/create-react-app/pull/486645164 // and45165 // https://github.com/facebook/create-react-app/pull/5431)45166 45167 // Allows alphanumeric characters, periods, dashes, slashes, and underscores.45168 const WINDOWS_CMD_SAFE_FILE_NAME_PATTERN = /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-_\\]+$/u;45169 if (45170 process.platform === 'win32' &&45171 !WINDOWS_CMD_SAFE_FILE_NAME_PATTERN.test(fileName.trim())45172 ) {45173 console.log();45174 console.log(45175 colors.red('Could not open ' + path$5.basename(fileName) + ' in the editor.')45176 );45177 console.log();45178 console.log(45179 'When running on Windows, file names are checked against a safe file name ' +45180 'pattern to protect against remote code execution attacks. File names ' +45181 'may consist only of alphanumeric characters (all languages), periods, ' +45182 'dashes, slashes, and underscores.'45183 );45184 console.log();45185 return45186 }45187 45188 45432 if (lineNumber) { 45189 45433 const extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber); … … 45201 45445 45202 45446 if (process.platform === 'win32') { 45203 // On Windows, launch the editor in a shell because spawn can only 45204 // launch .exe files. 45205 _childProcess = childProcess$1.spawn( 45206 'cmd.exe', 45207 ['/C', editor].concat(args), 45208 { stdio: 'inherit' } 45209 ); 45447 // On Windows, we need to use `exec` with the `shell: true` option, 45448 // and some more sanitization is required. 45449 45450 // However, CMD.exe on Windows is vulnerable to RCE attacks given a file name of the 45451 // form "C:\Users\myusername\Downloads\& curl 172.21.93.52". 45452 // `create-react-app` used a safe file name pattern to validate user-provided file names: 45453 // - https://github.com/facebook/create-react-app/pull/4866 45454 // - https://github.com/facebook/create-react-app/pull/5431 45455 // But that's not a viable solution for this package because 45456 // it's depended on by so many meta frameworks that heavily rely on 45457 // special characters in file names for filesystem-based routing. 45458 // We need to at least: 45459 // - Support `+` because it's used in SvelteKit and Vike 45460 // - Support `$` because it's used in Remix 45461 // - Support `(` and `)` because they are used in Analog, SolidStart, and Vike 45462 // - Support `@` because it's used in Vike 45463 // - Support `[` and `]` because they are widely used for [slug] 45464 // So here we choose to use `^` to escape special characters instead. 45465 45466 // According to https://ss64.com/nt/syntax-esc.html, 45467 // we can use `^` to escape `&`, `<`, `>`, `|`, `%`, and `^` 45468 // I'm not sure if we have to escape all of these, but let's do it anyway 45469 function escapeCmdArgs (cmdArgs) { 45470 return cmdArgs.replace(/([&|<>,;=^])/g, '^$1') 45471 } 45472 45473 // Need to double quote the editor path in case it contains spaces; 45474 // If the fileName contains spaces, we also need to double quote it in the arguments 45475 // However, there's a case that it's concatenated with line number and column number 45476 // which is separated by `:`. We need to double quote the whole string in this case. 45477 // Also, if the string contains the escape character `^`, it needs to be quoted, too. 45478 function doubleQuoteIfNeeded(str) { 45479 if (str.includes('^')) { 45480 // If a string includes an escaped character, not only does it need to be quoted, 45481 // but the quotes need to be escaped too. 45482 return `^"${str}^"` 45483 } else if (str.includes(' ')) { 45484 return `"${str}"` 45485 } 45486 return str 45487 } 45488 const launchCommand = [editor, ...args.map(escapeCmdArgs)] 45489 .map(doubleQuoteIfNeeded) 45490 .join(' '); 45491 45492 _childProcess = childProcess$1.exec(launchCommand, { 45493 stdio: 'inherit', 45494 shell: true 45495 }); 45210 45496 } else { 45211 45497 _childProcess = childProcess$1.spawn(editor, args, { stdio: 'inherit' }); … … 45331 45617 logger.warn( 45332 45618 colors$1.yellow( 45333 "Server responded with status code 431. See https://vite js.dev/guide/troubleshooting.html#_431-request-header-fields-too-large."45619 "Server responded with status code 431. See https://vite.dev/guide/troubleshooting.html#_431-request-header-fields-too-large." 45334 45620 ) 45335 45621 ); … … 45355 45641 let fsUtils = cachedFsUtilsMap.get(config); 45356 45642 if (!fsUtils) { 45357 if (config.command !== "serve" || config.server.fs.cachedChecks === false || config.server.watch?.ignored || process.versions.pnp) {45643 if (config.command !== "serve" || config.server.fs.cachedChecks !== true || config.server.watch?.ignored || process.versions.pnp) { 45358 45644 fsUtils = commonFsUtils; 45359 45645 } else if (!config.resolve.preserveSymlinks && config.root !== getRealPath(config.root)) { … … 45946 46232 } else if (isProduction) { 45947 46233 this.warn( 45948 `Module "${id}" has been externalized for browser compatibility, imported by "${importer}". See https://vite js.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`46234 `Module "${id}" has been externalized for browser compatibility, imported by "${importer}". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.` 45949 46235 ); 45950 46236 } … … 45963 46249 return `export default new Proxy({}, { 45964 46250 get(_, key) { 45965 throw new Error(\`Module "${id}" has been externalized for browser compatibility. Cannot access "${id}.\${key}" in client code. See https://vite js.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`)46251 throw new Error(\`Module "${id}" has been externalized for browser compatibility. Cannot access "${id}.\${key}" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`) 45966 46252 } 45967 46253 })`; … … 46126 46412 function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = false, externalize, allowLinkedExternal = true) { 46127 46413 const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options; 46128 const deepMatch = id.match(deepImportRE);46414 const deepMatch = deepImportRE.exec(id); 46129 46415 const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(id); 46130 46416 let basedir; … … 46702 46988 key !== 'splice' 46703 46989 ) { 46704 console.warn(\`Module "${path2}" has been externalized for browser compatibility. Cannot access "${path2}.\${key}" in client code. See https://vite js.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`)46990 console.warn(\`Module "${path2}" has been externalized for browser compatibility. Cannot access "${path2}.\${key}" in client code. See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.\`) 46705 46991 } 46706 46992 } … … 46929 47215 const metadata = depsOptimizer.metadata; 46930 47216 const file = cleanUrl(id); 46931 const versionMatch = id.match(DEP_VERSION_RE);47217 const versionMatch = DEP_VERSION_RE.exec(file); 46932 47218 const browserHash = versionMatch ? versionMatch[1].split("=")[1] : void 0; 46933 47219 const info = optimizedDepInfoFromFile(metadata, file); … … 46987 47273 const nonJsRe = /\.json(?:$|\?)/; 46988 47274 const isNonJsRequest = (request) => nonJsRe.test(request); 47275 const importMetaEnvMarker = "__vite_import_meta_env__"; 47276 const importMetaEnvKeyReCache = /* @__PURE__ */ new Map(); 46989 47277 function definePlugin(config) { 46990 47278 const isBuild = config.command === "build"; … … 47035 47323 } 47036 47324 if ("import.meta.env" in define) { 47037 define["import.meta.env"] = serializeDefine({ 47038 ...importMetaEnvKeys, 47039 SSR: ssr + "", 47040 ...userDefineEnv 47041 }); 47042 } 47325 define["import.meta.env"] = importMetaEnvMarker; 47326 } 47327 const importMetaEnvVal = serializeDefine({ 47328 ...importMetaEnvKeys, 47329 SSR: ssr + "", 47330 ...userDefineEnv 47331 }); 47043 47332 const patternKeys = Object.keys(userDefine); 47044 47333 if (replaceProcessEnv && Object.keys(processEnv).length) { … … 47049 47338 } 47050 47339 const pattern = patternKeys.length ? new RegExp(patternKeys.map(escapeRegex).join("|")) : null; 47051 return [define, pattern ];47340 return [define, pattern, importMetaEnvVal]; 47052 47341 } 47053 47342 const defaultPattern = generatePattern(false); … … 47066 47355 return; 47067 47356 } 47068 const [define, pattern] = ssr ? ssrPattern : defaultPattern;47357 let [define, pattern, importMetaEnvVal] = ssr ? ssrPattern : defaultPattern; 47069 47358 if (!pattern) return; 47070 47359 pattern.lastIndex = 0; 47071 47360 if (!pattern.test(code)) return; 47072 return await replaceDefine(code, id, define, config); 47361 const hasDefineImportMetaEnv = "import.meta.env" in define; 47362 let marker = importMetaEnvMarker; 47363 if (hasDefineImportMetaEnv && code.includes(marker)) { 47364 let i = 1; 47365 do { 47366 marker = importMetaEnvMarker + i++; 47367 } while (code.includes(marker)); 47368 if (marker !== importMetaEnvMarker) { 47369 define = { ...define, "import.meta.env": marker }; 47370 } 47371 } 47372 const result = await replaceDefine(code, id, define, config); 47373 if (hasDefineImportMetaEnv) { 47374 result.code = result.code.replaceAll( 47375 getImportMetaEnvKeyRe(marker), 47376 (m) => "undefined".padEnd(m.length) 47377 ); 47378 if (result.code.includes(marker)) { 47379 result.code = `const ${marker} = ${importMetaEnvVal}; 47380 ` + result.code; 47381 if (result.map) { 47382 const map = JSON.parse(result.map); 47383 map.mappings = ";" + map.mappings; 47384 result.map = map; 47385 } 47386 } 47387 } 47388 return result; 47073 47389 } 47074 47390 }; 47075 47391 } 47076 47392 async function replaceDefine(code, id, define, config) { 47077 const replacementMarkers = {};47078 const env = define["import.meta.env"];47079 if (env && !canJsonParse(env)) {47080 const marker = `_${getHash(env, env.length - 2)}_`;47081 replacementMarkers[marker] = env;47082 define = { ...define, "import.meta.env": marker };47083 }47084 47393 const esbuildOptions = config.esbuild || {}; 47085 47394 const result = await transform$1(code, { … … 47107 47416 } 47108 47417 } 47109 for (const marker in replacementMarkers) {47110 result.code = result.code.replaceAll(marker, replacementMarkers[marker]);47111 }47112 47418 return { 47113 47419 code: result.code, … … 47133 47439 return JSON.stringify(value); 47134 47440 } 47135 function canJsonParse(value) {47136 try {47137 JSON.parse(value);47138 re turn true;47139 } catch {47140 return false;47141 }47441 function getImportMetaEnvKeyRe(marker) { 47442 let re = importMetaEnvKeyReCache.get(marker); 47443 if (!re) { 47444 re = new RegExp(`${marker}\\..+?\\b`, "g"); 47445 importMetaEnvKeyReCache.set(marker, re); 47446 } 47447 return re; 47142 47448 } 47143 47449 … … 47283 47589 } 47284 47590 throw new Error( 47285 '"ESM integration proposal for Wasm" is not supported currently. Use vite-plugin-wasm or other community plugins to handle this. Alternatively, you can use `.wasm?init` or `.wasm?url`. See https://vite js.dev/guide/features.html#webassembly for more details.'47591 '"ESM integration proposal for Wasm" is not supported currently. Use vite-plugin-wasm or other community plugins to handle this. Alternatively, you can use `.wasm?init` or `.wasm?url`. See https://vite.dev/guide/features.html#webassembly for more details.' 47286 47592 ); 47287 47593 } … … 47347 47653 saveEmitWorkerAsset(config, { 47348 47654 fileName: outputChunk2.fileName, 47655 originalFileName: null, 47349 47656 source: outputChunk2.code 47350 47657 }); … … 47364 47671 saveEmitWorkerAsset(config, { 47365 47672 fileName: mapFileName, 47673 originalFileName: null, 47366 47674 source: data 47367 47675 }); … … 47387 47695 saveEmitWorkerAsset(config, { 47388 47696 fileName, 47697 originalFileName: null, 47389 47698 source: outputChunk.code 47390 47699 }); … … 47465 47774 if (injectEnv) { 47466 47775 const s = new MagicString(raw); 47467 s.prepend(injectEnv );47776 s.prepend(injectEnv + ";\n"); 47468 47777 return { 47469 47778 code: s.toString(), … … 47484 47793 let urlCode; 47485 47794 if (isBuild) { 47486 if (isWorker && this.getModuleInfo(cleanUrl(id))?.isEntry) {47795 if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) { 47487 47796 urlCode = "self.location.href"; 47488 47797 } else if (inlineRE.test(id)) { … … 47611 47920 type: "asset", 47612 47921 fileName: asset.fileName, 47922 originalFileName: asset.originalFileName, 47613 47923 source: asset.source 47614 47924 }); … … 47813 48123 file ??= url[0] === "/" ? slash$1(path$n.join(config.publicDir, url)) : slash$1(path$n.resolve(path$n.dirname(id), url)); 47814 48124 } 47815 if (isBuild && config.isWorker && this.getModuleInfo(cleanUrl(file))?.isEntry) {48125 if (isBuild && config.isWorker && config.bundleChain.at(-1) === cleanUrl(file)) { 47816 48126 s.update(expStart, expEnd, "self.location.href"); 47817 48127 } else { … … 48468 48778 } 48469 48779 function cleanStack(stack) { 48470 return stack.split(/\n/ g).filter((l) => /^\s*at/.test(l)).join("\n");48780 return stack.split(/\n/).filter((l) => /^\s*at/.test(l)).join("\n"); 48471 48781 } 48472 48782 function logError(server, err) { … … 49306 49616 const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i; 49307 49617 const langRE = /\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i; 49308 const contextRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i; 49618 const svelteScriptModuleRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/i; 49619 const svelteModuleRE = /\smodule\b/i; 49309 49620 function esbuildScanPlugin(config, container, depImports, missing, entries) { 49310 49621 const seen = /* @__PURE__ */ new Map(); … … 49392 49703 const matches = raw.matchAll(scriptRE); 49393 49704 for (const [, openTag, content] of matches) { 49394 const typeMatch = openTag.match(typeRE);49705 const typeMatch = typeRE.exec(openTag); 49395 49706 const type = typeMatch && (typeMatch[1] || typeMatch[2] || typeMatch[3]); 49396 const langMatch = openTag.match(langRE);49707 const langMatch = langRE.exec(openTag); 49397 49708 const lang = langMatch && (langMatch[1] || langMatch[2] || langMatch[3]); 49398 49709 if (isHtml && type !== "module") { … … 49408 49719 loader = "ts"; 49409 49720 } 49410 const srcMatch = openTag.match(srcRE);49721 const srcMatch = srcRE.exec(openTag); 49411 49722 if (srcMatch) { 49412 49723 const src = srcMatch[1] || srcMatch[2] || srcMatch[3]; … … 49437 49748 } 49438 49749 const virtualModulePath = JSON.stringify(virtualModulePrefix + key); 49439 const contextMatch = openTag.match(contextRE); 49440 const context = contextMatch && (contextMatch[1] || contextMatch[2] || contextMatch[3]); 49441 if (p.endsWith(".svelte") && context !== "module") { 49442 js += `import ${virtualModulePath} 49750 let addedImport = false; 49751 if (p.endsWith(".svelte")) { 49752 let isModule = svelteModuleRE.test(openTag); 49753 if (!isModule) { 49754 const contextMatch = svelteScriptModuleRE.exec(openTag); 49755 const context = contextMatch && (contextMatch[1] || contextMatch[2] || contextMatch[3]); 49756 isModule = context === "module"; 49757 } 49758 if (!isModule) { 49759 addedImport = true; 49760 js += `import ${virtualModulePath} 49443 49761 `; 49444 } else { 49762 } 49763 } 49764 if (!addedImport) { 49445 49765 js += `export * from ${virtualModulePath} 49446 49766 `; … … 49659 49979 filePath = "./" + filePath; 49660 49980 } 49661 const matched2 = slash$1(filePath).match(exportsValueGlobRe);49981 const matched2 = exportsValueGlobRe.exec(slash$1(filePath)); 49662 49982 if (matched2) { 49663 49983 let allGlobSame = matched2.length === 2; … … 49770 50090 const logNewlyDiscoveredDeps = () => { 49771 50091 if (newDepsToLog.length) { 49772 config.logger.info(50092 logger.info( 49773 50093 colors$1.green( 49774 50094 `\u2728 new dependencies optimized: ${depsLogString(newDepsToLog)}` … … 49784 50104 const logDiscoveredDepsWhileScanning = () => { 49785 50105 if (discoveredDepsWhileScanning.length) { 49786 config.logger.info(50106 logger.info( 49787 50107 colors$1.green( 49788 50108 `\u2728 discovered while scanning: ${depsLogString( … … 49978 50298 if (warnAboutMissedDependencies) { 49979 50299 logDiscoveredDepsWhileScanning(); 49980 config.logger.info(50300 logger.info( 49981 50301 colors$1.magenta( 49982 50302 `\u2757 add these dependencies to optimizeDeps.include to speed up cold start` … … 50010 50330 if (warnAboutMissedDependencies) { 50011 50331 logDiscoveredDepsWhileScanning(); 50012 config.logger.info(50332 logger.info( 50013 50333 colors$1.magenta( 50014 50334 `\u2757 add these dependencies to optimizeDeps.include to avoid a full page reload during cold start` … … 50026 50346 ); 50027 50347 if (needsInteropMismatch.length > 0) { 50028 config.logger.warn(50348 logger.warn( 50029 50349 `Mixed ESM and CJS detected in ${colors$1.yellow( 50030 50350 needsInteropMismatch.join(", ") … … 51318 51638 }; 51319 51639 return function viteServePublicMiddleware(req, res, next) { 51320 if (publicFiles && !publicFiles.has(toFilePath(req.url)) || isImportRequest(req.url) || isInternalRequest(req.url)) { 51640 if (publicFiles && !publicFiles.has(toFilePath(req.url)) || isImportRequest(req.url) || isInternalRequest(req.url) || // for `/public-file.js?url` to be transformed 51641 urlRE.test(req.url)) { 51321 51642 return next(); 51322 51643 } … … 51414 51735 ${server.config.server.fs.allow.map((i) => `- ${i}`).join("\n")} 51415 51736 51416 Refer to docs https://vite js.dev/config/server-options.html#server-fs-allow for configurations and more details.`;51737 Refer to docs https://vite.dev/config/server-options.html#server-fs-allow for configurations and more details.`; 51417 51738 server.config.logger.error(urlMessage); 51418 51739 server.config.logger.warnOnce(hintMessage + "\n"); … … 52073 52394 const idToImportMap = /* @__PURE__ */ new Map(); 52074 52395 const declaredConst = /* @__PURE__ */ new Set(); 52075 const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0;52396 const hoistIndex = hashbangRE.exec(code)?.[0].length ?? 0; 52076 52397 function defineImport(index, source, metadata) { 52077 52398 deps.add(source); … … 52097 52418 ); 52098 52419 } 52420 const imports = []; 52421 const exports = []; 52099 52422 for (const node of ast.body) { 52100 52423 if (node.type === "ImportDeclaration") { 52101 const importId = defineImport(hoistIndex, node.source.value, { 52102 importedNames: node.specifiers.map((s2) => { 52103 if (s2.type === "ImportSpecifier") 52104 return s2.imported.type === "Identifier" ? s2.imported.name : ( 52105 // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet 52106 s2.imported.value 52107 ); 52108 else if (s2.type === "ImportDefaultSpecifier") return "default"; 52109 }).filter(isDefined) 52110 }); 52111 s.remove(node.start, node.end); 52112 for (const spec of node.specifiers) { 52113 if (spec.type === "ImportSpecifier") { 52114 if (spec.imported.type === "Identifier") { 52115 idToImportMap.set( 52116 spec.local.name, 52117 `${importId}.${spec.imported.name}` 52118 ); 52119 } else { 52120 idToImportMap.set( 52121 spec.local.name, 52122 `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet 52123 JSON.stringify(spec.imported.value)}]` 52124 ); 52125 } 52126 } else if (spec.type === "ImportDefaultSpecifier") { 52127 idToImportMap.set(spec.local.name, `${importId}.default`); 52424 imports.push(node); 52425 } else if (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportAllDeclaration") { 52426 exports.push(node); 52427 } 52428 } 52429 for (const node of imports) { 52430 const importId = defineImport(hoistIndex, node.source.value, { 52431 importedNames: node.specifiers.map((s2) => { 52432 if (s2.type === "ImportSpecifier") 52433 return s2.imported.type === "Identifier" ? s2.imported.name : ( 52434 // @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet 52435 s2.imported.value 52436 ); 52437 else if (s2.type === "ImportDefaultSpecifier") return "default"; 52438 }).filter(isDefined) 52439 }); 52440 s.remove(node.start, node.end); 52441 for (const spec of node.specifiers) { 52442 if (spec.type === "ImportSpecifier") { 52443 if (spec.imported.type === "Identifier") { 52444 idToImportMap.set( 52445 spec.local.name, 52446 `${importId}.${spec.imported.name}` 52447 ); 52128 52448 } else { 52129 idToImportMap.set(spec.local.name, importId); 52130 } 52131 } 52132 } 52133 } 52134 for (const node of ast.body) { 52449 idToImportMap.set( 52450 spec.local.name, 52451 `${importId}[${// @ts-expect-error TODO: Estree types don't consider arbitrary module namespace specifiers yet 52452 JSON.stringify(spec.imported.value)}]` 52453 ); 52454 } 52455 } else if (spec.type === "ImportDefaultSpecifier") { 52456 idToImportMap.set(spec.local.name, `${importId}.default`); 52457 } else { 52458 idToImportMap.set(spec.local.name, importId); 52459 } 52460 } 52461 } 52462 for (const node of exports) { 52135 52463 if (node.type === "ExportNamedDeclaration") { 52136 52464 if (node.declaration) { … … 52248 52576 }); 52249 52577 let map = s.generateMap({ hires: "boundary" }); 52578 map.sources = [path$n.basename(url)]; 52579 map.sourcesContent = [originalCode]; 52250 52580 if (inMap && inMap.mappings && "sources" in inMap && inMap.sources.length > 0) { 52251 52581 map = combineSourcemaps(url, [ 52252 { 52253 ...map, 52254 sources: inMap.sources, 52255 sourcesContent: inMap.sourcesContent 52256 }, 52582 map, 52257 52583 inMap 52258 52584 ]); 52259 } else {52260 map.sources = [path$n.basename(url)];52261 map.sourcesContent = [originalCode];52262 52585 } 52263 52586 return { … … 52526 52849 const pendingModuleDependencyGraph = /* @__PURE__ */ new Map(); 52527 52850 const importErrors = /* @__PURE__ */ new WeakMap(); 52528 async function ssrLoadModule(url, server, context = { global },fixStacktrace) {52851 async function ssrLoadModule(url, server, fixStacktrace) { 52529 52852 url = unwrapId$1(url); 52530 52853 const pending = pendingModules.get(url); … … 52532 52855 return pending; 52533 52856 } 52534 const modulePromise = instantiateModule(url, server, context,fixStacktrace);52857 const modulePromise = instantiateModule(url, server, fixStacktrace); 52535 52858 pendingModules.set(url, modulePromise); 52536 52859 modulePromise.catch(() => { … … 52540 52863 return modulePromise; 52541 52864 } 52542 async function instantiateModule(url, server, context = { global },fixStacktrace) {52865 async function instantiateModule(url, server, fixStacktrace) { 52543 52866 const { moduleGraph } = server; 52544 52867 const mod = await moduleGraph.ensureEntryFromUrl(url, true); … … 52604 52927 } 52605 52928 } 52606 return ssrLoadModule(dep, server, context,fixStacktrace);52929 return ssrLoadModule(dep, server, fixStacktrace); 52607 52930 } catch (err) { 52608 52931 importErrors.set(err, { importee: dep }); … … 52639 52962 try { 52640 52963 const initModule = new AsyncFunction( 52641 `global`,52642 52964 ssrModuleExportsKey, 52643 52965 ssrImportMetaKey, … … 52649 52971 ); 52650 52972 await initModule( 52651 context.global,52652 52973 ssrModule, 52653 52974 ssrImportMeta, … … 54036 54357 if (!normalizePath$3(outDir).startsWith(withTrailingSlash(root))) { 54037 54358 logger?.warn( 54038 picocolorsExports.yellow(54359 colors$1.yellow( 54039 54360 ` 54040 ${ picocolorsExports.bold(`(!)`)} outDir ${picocolorsExports.white(54041 picocolorsExports.dim(outDir)54361 ${colors$1.bold(`(!)`)} outDir ${colors$1.white( 54362 colors$1.dim(outDir) 54042 54363 )} is not inside project root and will not be emptied. 54043 54364 Use --emptyOutDir to override. … … 54050 54371 return true; 54051 54372 } 54052 function resolveChokidarOptions( config, options, resolvedOutDirs, emptyOutDir) {54373 function resolveChokidarOptions(options, resolvedOutDirs, emptyOutDir, cacheDir) { 54053 54374 const { ignored: ignoredList, ...otherOptions } = options ?? {}; 54054 54375 const ignored = [ … … 54057 54378 "**/test-results/**", 54058 54379 // Playwright 54059 glob.escapePath(c onfig.cacheDir) + "/**",54380 glob.escapePath(cacheDir) + "/**", 54060 54381 ...arraify(ignoredList || []) 54061 54382 ]; … … 61463 61784 if (ifNoneMatch) { 61464 61785 const moduleByEtag = server.moduleGraph.getModuleByEtag(ifNoneMatch); 61465 if (moduleByEtag?.transformResult?.etag === ifNoneMatch ) {61786 if (moduleByEtag?.transformResult?.etag === ifNoneMatch && moduleByEtag?.url === req.url) { 61466 61787 const maybeMixedEtag = isCSSRequest(req.url); 61467 61788 if (!maybeMixedEtag) { … … 61541 61862 warnAboutExplicitPublicPathInUrl(url); 61542 61863 } 61864 if ((rawRE.test(url) || urlRE.test(url)) && !ensureServingAccess(url, server, res, next)) { 61865 return; 61866 } 61543 61867 if (isJSRequest(url) || isImportRequest(url) || isCSSRequest(url) || isHTMLProxy(url)) { 61544 61868 url = removeImportQuery(url); … … 61713 62037 } 61714 62038 if (preTransformUrl) { 61715 preTransformRequest(server, preTransformUrl, config.base); 62039 try { 62040 preTransformUrl = decodeURI(preTransformUrl); 62041 } catch (err) { 62042 return url2; 62043 } 62044 preTransformRequest(server, preTransformUrl, config.decodedBase); 61716 62045 } 61717 62046 } … … 61724 62053 const { config, moduleGraph, watcher } = server; 61725 62054 const base = config.base || "/"; 62055 const decodedBase = config.decodedBase || "/"; 61726 62056 let proxyModulePath; 61727 62057 let proxyModuleUrl; … … 61735 62065 proxyModuleUrl = wrapId$1(proxyModulePath); 61736 62066 } 61737 proxyModuleUrl = joinUrlSegments( base, proxyModuleUrl);62067 proxyModuleUrl = joinUrlSegments(decodedBase, proxyModuleUrl); 61738 62068 const s = new MagicString(html); 61739 62069 let inlineModuleIndex = -1; … … 61767 62097 `<script type="module" src="${modulePath}"><\/script>` 61768 62098 ); 61769 preTransformRequest(server, modulePath, base);62099 preTransformRequest(server, modulePath, decodedBase); 61770 62100 }; 61771 62101 await traverseHtml(html, filename, (node) => { … … 61929 62259 }; 61930 62260 } 61931 function preTransformRequest(server, url, base) {62261 function preTransformRequest(server, decodedUrl, decodedBase) { 61932 62262 if (!server.config.server.preTransformRequests) return; 61933 try { 61934 url = unwrapId$1(stripBase(decodeURI(url), base)); 61935 } catch { 61936 return; 61937 } 61938 server.warmupRequest(url); 62263 decodedUrl = unwrapId$1(stripBase(decodedUrl, decodedBase)); 62264 server.warmupRequest(decodedUrl); 61939 62265 } 61940 62266 … … 62107 62433 mod.importers.forEach((importer) => { 62108 62434 if (!importer.acceptedHmrDeps.has(mod)) { 62109 const shouldSoftInvalidateImporter = importer.staticImportedUrls?.has(mod.url) || softInvalidate;62435 const shouldSoftInvalidateImporter = (importer.staticImportedUrls?.has(mod.url) || softInvalidate) && importer.type !== "css"; 62110 62436 this.invalidateModule( 62111 62437 importer, … … 62446 62772 ); 62447 62773 const resolvedWatchOptions = resolveChokidarOptions( 62448 config,62449 62774 { 62450 62775 disableGlobbing: true, … … 62452 62777 }, 62453 62778 resolvedOutDirs, 62454 emptyOutDir 62779 emptyOutDir, 62780 config.cacheDir 62455 62781 ); 62456 62782 const middlewares = connect$1(); … … 62532 62858 }, 62533 62859 async ssrLoadModule(url, opts) { 62534 return ssrLoadModule(url, server, void 0,opts?.fixStacktrace);62860 return ssrLoadModule(url, server, opts?.fixStacktrace); 62535 62861 }, 62536 62862 async ssrFetchModule(url, importer) { … … 63026 63352 seenIds.add(ignoredId); 63027 63353 markIdAsDone(ignoredId); 63354 } else { 63355 checkIfCrawlEndAfterTimeout(); 63028 63356 } 63029 63357 return onCrawlEndPromiseWithResolvers.promise; 63030 63358 } 63031 63359 function markIdAsDone(id) { 63032 if (registeredIds.has(id)) { 63033 registeredIds.delete(id); 63034 checkIfCrawlEndAfterTimeout(); 63035 } 63360 registeredIds.delete(id); 63361 checkIfCrawlEndAfterTimeout(); 63036 63362 } 63037 63363 function checkIfCrawlEndAfterTimeout() { … … 63742 64068 url = injectQuery(url, "import"); 63743 64069 } else if ((isRelative || isSelfImport) && !DEP_VERSION_RE.test(url)) { 63744 const versionMatch = importer.match(DEP_VERSION_RE);64070 const versionMatch = DEP_VERSION_RE.exec(importer); 63745 64071 if (versionMatch) { 63746 64072 url = injectQuery(url, versionMatch[1]); … … 64183 64509 } 64184 64510 const pathname = url.replace(/[?#].*$/, ""); 64185 const { search, hash } = new URL(url, "http://vite js.dev");64511 const { search, hash } = new URL(url, "http://vite.dev"); 64186 64512 return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ""}${hash || ""}`; 64187 64513 } … … 64215 64541 ); 64216 64542 const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce"); 64217 promise = Promise.all (64543 promise = Promise.allSettled( 64218 64544 deps.map((dep) => { 64219 64545 dep = assetsURL(dep, importerUrl); … … 64237 64563 if (!isCss) { 64238 64564 link.as = "script"; 64239 link.crossOrigin = "";64240 }64565 } 64566 link.crossOrigin = ""; 64241 64567 link.href = dep; 64242 64568 if (cspNonce) { … … 64256 64582 ); 64257 64583 } 64258 return promise.then(() => baseModule()).catch((err) => { 64259 const e = new Event("vite:preloadError", { cancelable: true }); 64584 function handlePreloadError(err) { 64585 const e = new Event("vite:preloadError", { 64586 cancelable: true 64587 }); 64260 64588 e.payload = err; 64261 64589 window.dispatchEvent(e); … … 64263 64591 throw err; 64264 64592 } 64593 } 64594 return promise.then((res) => { 64595 for (const item of res || []) { 64596 if (item.status !== "rejected") continue; 64597 handlePreloadError(item.reason); 64598 } 64599 return baseModule().catch(handlePreloadError); 64265 64600 }); 64266 64601 } … … 64269 64604 const isWorker = config.isWorker; 64270 64605 const insertPreload = !(ssr || !!config.build.lib || isWorker); 64271 const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;64272 64606 const renderBuiltUrl = config.experimental.renderBuiltUrl; 64273 const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);64274 64607 const isRelativeBase = config.base === "./" || config.base === ""; 64275 const optimizeModulePreloadRelativePaths = isRelativeBase && !customModulePreloadPaths;64276 64608 const { modulePreload } = config.build; 64277 64609 const scriptRel2 = modulePreload && modulePreload.polyfill ? `'modulepreload'` : `(${detectScriptRel.toString()})()`; 64278 const assetsURL2 = customModulePreloadPaths ? ( 64279 // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used 64280 // the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)` 64281 // a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized. 64282 `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }` 64283 ) : optimizeModulePreloadRelativePaths ? ( 64284 // If there isn't custom resolvers affecting the deps list, deps in the list are relative 64285 // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself. 64610 const assetsURL2 = renderBuiltUrl || isRelativeBase ? ( 64611 // If `experimental.renderBuiltUrl` is used, the dependencies might be relative to the current chunk. 64612 // If relative base is used, the dependencies are relative to the current chunk. 64286 64613 // The importerUrl is passed as third parameter to __vitePreload in this case 64287 64614 `function(dep, importerUrl) { return new URL(dep, importerUrl).href }` … … 64335 64662 } 64336 64663 if (match[3]) { 64337 let names2 = match[4].match(/\.([^.?]+)/)?.[1] || "";64664 let names2 = /\.([^.?]+)/.exec(match[4])?.[1] || ""; 64338 64665 if (names2 === "default") { 64339 64666 names2 = "default: __vite_default__"; … … 64377 64704 str().appendRight( 64378 64705 expEnd, 64379 `,${isModernFlag}?${preloadMarker}:void 0${ optimizeModulePreloadRelativePaths || customModulePreloadPaths? ",import.meta.url" : ""})`64706 `,${isModernFlag}?${preloadMarker}:void 0${renderBuiltUrl || isRelativeBase ? ",import.meta.url" : ""})` 64380 64707 ); 64381 64708 } … … 64558 64885 } 64559 64886 if (markerStartPos2 > 0) { 64560 const depsArray = deps.size > 1 || // main chunk is removed64887 let depsArray = deps.size > 1 || // main chunk is removed 64561 64888 hasRemovedPureCssChunk && deps.size > 0 ? modulePreload === false ? ( 64562 64889 // CSS deps use the same mechanism as module preloads, so even if disabled, … … 64564 64891 [...deps].filter((d) => d.endsWith(".css")) 64565 64892 ) : [...deps] : []; 64893 const resolveDependencies = modulePreload ? modulePreload.resolveDependencies : void 0; 64894 if (resolveDependencies && normalizedFile) { 64895 const cssDeps = []; 64896 const otherDeps = []; 64897 for (const dep of depsArray) { 64898 (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep); 64899 } 64900 depsArray = [ 64901 ...resolveDependencies(normalizedFile, otherDeps, { 64902 hostId: file, 64903 hostType: "js" 64904 }), 64905 ...cssDeps 64906 ]; 64907 } 64566 64908 let renderedDeps; 64567 if (normalizedFile && customModulePreloadPaths) { 64568 const { modulePreload: modulePreload2 } = config.build; 64569 const resolveDependencies = modulePreload2 ? modulePreload2.resolveDependencies : void 0; 64570 let resolvedDeps; 64571 if (resolveDependencies) { 64572 const cssDeps = []; 64573 const otherDeps = []; 64574 for (const dep of depsArray) { 64575 (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep); 64576 } 64577 resolvedDeps = [ 64578 ...resolveDependencies(normalizedFile, otherDeps, { 64579 hostId: file, 64580 hostType: "js" 64581 }), 64582 ...cssDeps 64583 ]; 64584 } else { 64585 resolvedDeps = depsArray; 64586 } 64587 renderedDeps = resolvedDeps.map((dep) => { 64909 if (renderBuiltUrl) { 64910 renderedDeps = depsArray.map((dep) => { 64588 64911 const replacement = toOutputFilePathInJS( 64589 64912 dep, … … 64604 64927 // Don't include the assets dir if the default asset file names 64605 64928 // are used, the path will be reconstructed by the import preload helper 64606 optimizeModulePreloadRelativePaths? addFileDep(toRelativePath(d, file)) : addFileDep(d)64929 isRelativeBase ? addFileDep(toRelativePath(d, file)) : addFileDep(d) 64607 64930 ) 64608 64931 ); … … 64919 65242 ); 64920 65243 const options = config.build; 65244 const { root, logger, packageCache } = config; 64921 65245 const ssr = !!options.ssr; 64922 65246 const libOptions = options.lib; 64923 config.logger.info(65247 logger.info( 64924 65248 colors$1.cyan( 64925 65249 `vite v${VERSION} ${colors$1.green( … … 64928 65252 ) 64929 65253 ); 64930 const resolve = (p) => path$n.resolve( config.root, p);65254 const resolve = (p) => path$n.resolve(root, p); 64931 65255 const input = libOptions ? options.rollupOptions?.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries( 64932 65256 Object.entries(libOptions.entry).map(([alias, file]) => [ … … 65001 65325 enhanceRollupError(e); 65002 65326 clearLine(); 65003 config.logger.error(e.message, { error: e });65327 logger.error(e.message, { error: e }); 65004 65328 }; 65005 65329 let bundle; … … 65008 65332 const buildOutputOptions = (output = {}) => { 65009 65333 if (output.output) { 65010 config.logger.warn(65334 logger.warn( 65011 65335 `You've set "rollupOptions.output.output" in your config. This is deprecated and will override all Vite.js default output options. Please use "rollupOptions.output" instead.` 65012 65336 ); … … 65018 65342 } 65019 65343 if (output.sourcemap) { 65020 config.logger.warnOnce(65344 logger.warnOnce( 65021 65345 colors$1.yellow( 65022 65346 `Vite does not support "rollupOptions.output.sourcemap". Please use "build.sourcemap" instead.` … … 65029 65353 const jsExt = ssrNodeBuild || libOptions ? resolveOutputJsExtension( 65030 65354 format, 65031 findNearestPackageData( config.root, config.packageCache)?.data.type65355 findNearestPackageData(root, packageCache)?.data.type 65032 65356 ) : "js"; 65033 65357 return { … … 65047 65371 format, 65048 65372 name, 65049 config.root,65373 root, 65050 65374 jsExt, 65051 config.packageCache65375 packageCache 65052 65376 ) : path$n.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`), 65053 65377 chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path$n.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`), … … 65060 65384 options.rollupOptions?.output, 65061 65385 libOptions, 65062 config.logger65386 logger 65063 65387 ); 65064 65388 const normalizedOutputs = []; … … 65071 65395 } 65072 65396 const resolvedOutDirs = getResolvedOutDirs( 65073 config.root,65397 root, 65074 65398 options.outDir, 65075 65399 options.rollupOptions?.output … … 65077 65401 const emptyOutDir = resolveEmptyOutDir( 65078 65402 options.emptyOutDir, 65079 config.root,65403 root, 65080 65404 resolvedOutDirs, 65081 config.logger65405 logger 65082 65406 ); 65083 65407 if (config.build.watch) { 65084 config.logger.info(colors$1.cyan(`65408 logger.info(colors$1.cyan(` 65085 65409 watching for file changes...`)); 65086 65410 const resolvedChokidarOptions = resolveChokidarOptions( 65087 config,65088 65411 config.build.watch.chokidar, 65089 65412 resolvedOutDirs, 65090 emptyOutDir 65413 emptyOutDir, 65414 config.cacheDir 65091 65415 ); 65092 65416 const { watch } = await import('rollup'); … … 65101 65425 watcher.on("event", (event) => { 65102 65426 if (event.code === "BUNDLE_START") { 65103 config.logger.info(colors$1.cyan(`65427 logger.info(colors$1.cyan(` 65104 65428 build started...`)); 65105 65429 if (options.write) { … … 65108 65432 } else if (event.code === "BUNDLE_END") { 65109 65433 event.result.close(); 65110 config.logger.info(colors$1.cyan(`built in ${event.duration}ms.`));65434 logger.info(colors$1.cyan(`built in ${event.duration}ms.`)); 65111 65435 } else if (event.code === "ERROR") { 65112 65436 outputBuildError(event.error); … … 65125 65449 res.push(await bundle[options.write ? "write" : "generate"](output)); 65126 65450 } 65127 config.logger.info(65451 logger.info( 65128 65452 `${colors$1.green(`\u2713 built in ${displayTime(Date.now() - startTime)}`)}` 65129 65453 ); … … 65133 65457 clearLine(); 65134 65458 if (startTime) { 65135 config.logger.error(65459 logger.error( 65136 65460 `${colors$1.red("x")} Build failed in ${displayTime(Date.now() - startTime)}` 65137 65461 ); … … 65380 65704 const getResolveUrl = (path2, URL = "URL") => `new ${URL}(${path2}).href`; 65381 65705 const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl( 65382 `'${escapeId(partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ""}document.currentScript && document.currentScript. src || document.baseURI`65706 `'${escapeId(partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ""}document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI` 65383 65707 ); 65384 65708 const getFileUrlFromFullPath = (path2) => `require('u' + 'rl').pathToFileURL(${path2}).href`; … … 65436 65760 return toRelative(filename, hostId); 65437 65761 } 65438 return joinUrlSegments(config. base, filename);65762 return joinUrlSegments(config.decodedBase, filename); 65439 65763 } 65440 65764 function createToImportMetaURLBasedRelativeRuntime(format, isWorker) { … … 65473 65797 return toRelative(filename, hostId); 65474 65798 } else { 65475 return joinUrlSegments(config. base, filename);65799 return joinUrlSegments(config.decodedBase, filename); 65476 65800 } 65477 65801 } … … 66005 66329 rollupOptions: config.worker?.rollupOptions || {} 66006 66330 }; 66331 const base = withTrailingSlash(resolvedBase); 66007 66332 resolved = { 66008 66333 configFile: configFile ? normalizePath$3(configFile) : void 0, … … 66012 66337 inlineConfig, 66013 66338 root: resolvedRoot, 66014 base: withTrailingSlash(resolvedBase), 66339 base, 66340 decodedBase: decodeURI(base), 66015 66341 rawBase: resolvedBase, 66016 66342 resolve: resolveOptions, … … 66163 66489 } 66164 66490 if (!isBuild || !isExternal) { 66165 base = new URL(base, "http://vite js.dev").pathname;66491 base = new URL(base, "http://vite.dev").pathname; 66166 66492 if (base[0] !== "/") { 66167 66493 base = "/" + base; … … 66201 66527 return null; 66202 66528 } 66203 const isESM = isFilePathESM(resolvedPath);66529 const isESM = typeof process.versions.deno === "string" || isFilePathESM(resolvedPath); 66204 66530 try { 66205 66531 const bundled = await bundleConfigFile(resolvedPath, isESM); … … 66237 66563 entryPoints: [fileName], 66238 66564 write: false, 66239 target: [ "node18"],66565 target: [`node${process.versions.node}`], 66240 66566 platform: "node", 66241 66567 bundle: true, … … 66306 66632 `Failed to resolve ${JSON.stringify( 66307 66633 id 66308 )}. This package is ESM only but it was tried to load by \`require\`. See https://vite js.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.`66634 )}. This package is ESM only but it was tried to load by \`require\`. See https://vite.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.` 66309 66635 ); 66310 66636 } … … 66319 66645 `${JSON.stringify( 66320 66646 id 66321 )} resolved to an ESM file. ESM file cannot be loaded by \`require\`. See https://vite js.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.`66647 )} resolved to an ESM file. ESM file cannot be loaded by \`require\`. See https://vite.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.` 66322 66648 ); 66323 66649 }
Note:
See TracChangeset
for help on using the changeset viewer.