Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/vite/dist/node-cjs/publicUtils.cjs
rd565449 r0c6b92a 39 39 charToInt[c] = i; 40 40 } 41 function encodeInteger(builder, num, relative) { 42 let delta = num - relative; 43 delta = delta < 0 ? (-delta << 1) | 1 : delta << 1; 44 do { 45 let clamped = delta & 0b011111; 46 delta >>>= 5; 47 if (delta > 0) 48 clamped |= 0b100000; 49 builder.write(intToChar[clamped]); 50 } while (delta > 0); 51 return num; 52 } 53 54 const bufLength = 1024 * 16; 41 55 // Provide a fallback for older environments. 42 56 const td = typeof TextDecoder !== 'undefined' … … 58 72 }, 59 73 }; 74 class StringWriter { 75 constructor() { 76 this.pos = 0; 77 this.out = ''; 78 this.buffer = new Uint8Array(bufLength); 79 } 80 write(v) { 81 const { buffer } = this; 82 buffer[this.pos++] = v; 83 if (this.pos === bufLength) { 84 this.out += td.decode(buffer); 85 this.pos = 0; 86 } 87 } 88 flush() { 89 const { buffer, out, pos } = this; 90 return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out; 91 } 92 } 60 93 function encode(decoded) { 61 const state = new Int32Array(5); 62 const bufLength = 1024 * 16; 63 const subLength = bufLength - 36; 64 const buf = new Uint8Array(bufLength); 65 const sub = buf.subarray(0, subLength); 66 let pos = 0; 67 let out = ''; 94 const writer = new StringWriter(); 95 let sourcesIndex = 0; 96 let sourceLine = 0; 97 let sourceColumn = 0; 98 let namesIndex = 0; 68 99 for (let i = 0; i < decoded.length; i++) { 69 100 const line = decoded[i]; 70 if (i > 0) { 71 if (pos === bufLength) { 72 out += td.decode(buf); 73 pos = 0; 74 } 75 buf[pos++] = semicolon; 76 } 101 if (i > 0) 102 writer.write(semicolon); 77 103 if (line.length === 0) 78 104 continue; 79 state[0]= 0;105 let genColumn = 0; 80 106 for (let j = 0; j < line.length; j++) { 81 107 const segment = line[j]; 82 // We can push up to 5 ints, each int can take at most 7 chars, and we83 // may push a comma.84 if (pos > subLength) {85 out += td.decode(sub);86 buf.copyWithin(0, subLength, pos);87 pos -= subLength;88 }89 108 if (j > 0) 90 buf[pos++] = comma;91 pos = encodeInteger(buf, pos, state, segment, 0); // genColumn109 writer.write(comma); 110 genColumn = encodeInteger(writer, segment[0], genColumn); 92 111 if (segment.length === 1) 93 112 continue; 94 pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex95 pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine96 pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn113 sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex); 114 sourceLine = encodeInteger(writer, segment[2], sourceLine); 115 sourceColumn = encodeInteger(writer, segment[3], sourceColumn); 97 116 if (segment.length === 4) 98 117 continue; 99 pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex118 namesIndex = encodeInteger(writer, segment[4], namesIndex); 100 119 } 101 120 } 102 return out + td.decode(buf.subarray(0, pos)); 103 } 104 function encodeInteger(buf, pos, state, segment, j) { 105 const next = segment[j]; 106 let num = next - state[j]; 107 state[j] = next; 108 num = num < 0 ? (-num << 1) | 1 : num << 1; 109 do { 110 let clamped = num & 0b011111; 111 num >>>= 5; 112 if (num > 0) 113 clamped |= 0b100000; 114 buf[pos++] = intToChar[clamped]; 115 } while (num > 0); 116 return pos; 121 return writer.flush(); 117 122 } 118 123 … … 786 791 } 787 792 793 let m; 794 788 795 // Is webkit? http://stackoverflow.com/a/16459606/376773 789 796 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 … … 793 800 // Is firefox >= v31? 794 801 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 795 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||802 (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || 796 803 // Double check webkit in userAgent just in case we are in a worker 797 804 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); … … 3506 3513 ]; 3507 3514 continue; 3515 } else if (key === "server" && rootPath === "server.hmr") { 3516 merged[key] = value; 3517 continue; 3508 3518 } 3509 3519 if (Array.isArray(existing) || Array.isArray(value)) { … … 4794 4804 if (typeof content !== 'string') throw new TypeError('replacement content must be a string'); 4795 4805 4796 while (start < 0) start += this.original.length; 4797 while (end < 0) end += this.original.length; 4806 if (this.original.length !== 0) { 4807 while (start < 0) start += this.original.length; 4808 while (end < 0) end += this.original.length; 4809 } 4798 4810 4799 4811 if (end > this.original.length) throw new Error('end is out of bounds'); … … 4891 4903 4892 4904 remove(start, end) { 4893 while (start < 0) start += this.original.length; 4894 while (end < 0) end += this.original.length; 4905 if (this.original.length !== 0) { 4906 while (start < 0) start += this.original.length; 4907 while (end < 0) end += this.original.length; 4908 } 4895 4909 4896 4910 if (start === end) return this; … … 4915 4929 4916 4930 reset(start, end) { 4917 while (start < 0) start += this.original.length; 4918 while (end < 0) end += this.original.length; 4931 if (this.original.length !== 0) { 4932 while (start < 0) start += this.original.length; 4933 while (end < 0) end += this.original.length; 4934 } 4919 4935 4920 4936 if (start === end) return this; … … 4978 4994 4979 4995 slice(start = 0, end = this.original.length) { 4980 while (start < 0) start += this.original.length; 4981 while (end < 0) end += this.original.length; 4996 if (this.original.length !== 0) { 4997 while (start < 0) start += this.original.length; 4998 while (end < 0) end += this.original.length; 4999 } 4982 5000 4983 5001 let result = '';
Note:
See TracChangeset
for help on using the changeset viewer.