-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pull] main from microsoft:main #31
base: main
Are you sure you want to change the base?
Conversation
@@ -1 +1 @@ | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,l){if(i<=o)return;const a=function(t,r,n,o,i){const s=t[i];e(t,o,i);let l=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,l,i),++l);return e(t,o,l),l}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<a&&t(r,n,o,a-1,s,l),a<l&&t(r,n,a+1,i,s,l)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const l=r(e[i],t[s]);!n&&l||o.push(l<=0?e[i]:t[s]),l<=0&&i++,l>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,l=!1,a=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),l=t(e[s]),a=l===n,a?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var a=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,l=0,a=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,l=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,l=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,l=0)}if(o&&"forward"!==o&&"both"!==o)s=e,a=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,a=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,a=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,l),u.setEnd(s,a),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const g=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},p=new Map([["8∶5","16∶10"]]);var m=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:g,aspectRatio:(e,t)=>{const r=g(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return p.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var b=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const E=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},_=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),x=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),N=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},w=function(){return"^[]{}()\\.^$*+?|-,"},S=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};var O=Object.freeze({__proto__:null,escapeCharacters:E,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(x.has(r))return x.get(r);return"\\x"+_(r.charCodeAt(0),2)}if(n){return"\\u"+_(n.charCodeAt(0),4)}return t?x.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:N,findLineEndingIndexes:e=>{const t=N(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:w,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r){const n=t?"g":"gi";let o;if(r)try{o=new RegExp(e,n)}catch(e){}return o||(o=S(e,n)),o},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>E(e,"^[]{}()\\.^$*+?|-,"),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},createPlainTextSearchRegex:S,toLowerCaseString:function(e){return e.toLowerCase()},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r}});function v(e){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}`)}function C(e,t){throw new Error(t)}function A(e){return e}var y=Object.freeze({__proto__:null,assertNotNullOrUndefined:v,assertNever:C,assertUnhandled:A});var U=Object.freeze({__proto__:null,LocalizedEmptyString:""});class R extends Error{message;constructor(e){super(e),this.message=e}}var M=Object.freeze({__proto__:null,UserVisibleError:R,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof R}});function T(e,t="DCHECK"){}export{i as ArrayUtilities,s as Brand,T as DCHECK,u as DOMUtilities,l as DateUtilities,a as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,m as NumberUtilities,b as SetUtilities,O as StringUtilities,y as TypeScriptUtilities,U as UIString,M as UserVisibleError,C as assertNever,v as assertNotNullOrUndefined,A as assertUnhandled}; | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,a){if(i<=o)return;const l=function(t,r,n,o,i){const s=t[i];e(t,o,i);let a=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,a,i),++a);return e(t,o,a),a}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<l&&t(r,n,o,l-1,s,a),l<a&&t(r,n,l+1,i,s,a)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const a=r(e[i],t[s]);!n&&a||o.push(a<=0?e[i]:t[s]),a<=0&&i++,a>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,a=!1,l=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),a=t(e[s]),l=a===n,l?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var a=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,a=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,a=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,a=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,a=0)}if(o&&"forward"!==o&&"both"!==o)s=e,l=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,l=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,a),u.setEnd(s,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const p=new Set(["application/ecmascript","application/javascript","application/json","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||p.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var w=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});var S=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const N=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},O=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),v=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),C=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},A=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,T="^[]{}()\\.^$*+?|-,",y=function(){return T},z=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==y().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const R=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(R)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var j=Object.freeze({__proto__:null,escapeCharacters:N,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(v.has(r))return v.get(r);return"\\x"+O(r.charCodeAt(0),2)}if(n){return"\\u"+O(n.charCodeAt(0),4)}return t?v.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:C,findLineEndingIndexes:e=>{const t=C(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>A.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:y,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==T.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=z(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>N(e,T),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:z,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var $=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});function L(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function U(e,t){throw new Error(t)}function F(e){return e}var k=Object.freeze({__proto__:null,assertNotNullOrUndefined:L,assertNever:U,assertUnhandled:F});var B=Object.freeze({__proto__:null,LocalizedEmptyString:""});class D extends Error{message;constructor(e){super(e),this.message=e}}var I=Object.freeze({__proto__:null,UserVisibleError:D,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof D}});export{i as ArrayUtilities,s as Brand,u as DOMUtilities,a as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,b as MimeType,w as NumberUtilities,E as PromiseUtilities,S as SetUtilities,j as StringUtilities,$ as Timing,k as TypeScriptUtilities,B as UIString,I as UserVisibleError,U as assertNever,L as assertNotNullOrUndefined,F as assertUnhandled}; |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
@@ -1 +1 @@ | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,l){if(i<=o)return;const a=function(t,r,n,o,i){const s=t[i];e(t,o,i);let l=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,l,i),++l);return e(t,o,l),l}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<a&&t(r,n,o,a-1,s,l),a<l&&t(r,n,a+1,i,s,l)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const l=r(e[i],t[s]);!n&&l||o.push(l<=0?e[i]:t[s]),l<=0&&i++,l>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,l=!1,a=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),l=t(e[s]),a=l===n,a?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var a=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,l=0,a=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,l=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,l=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,l=0)}if(o&&"forward"!==o&&"both"!==o)s=e,a=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,a=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,a=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,l),u.setEnd(s,a),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const g=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},p=new Map([["8∶5","16∶10"]]);var m=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:g,aspectRatio:(e,t)=>{const r=g(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return p.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var b=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const E=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},_=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),x=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),N=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},w=function(){return"^[]{}()\\.^$*+?|-,"},S=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};var O=Object.freeze({__proto__:null,escapeCharacters:E,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(x.has(r))return x.get(r);return"\\x"+_(r.charCodeAt(0),2)}if(n){return"\\u"+_(n.charCodeAt(0),4)}return t?x.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:N,findLineEndingIndexes:e=>{const t=N(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:w,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r){const n=t?"g":"gi";let o;if(r)try{o=new RegExp(e,n)}catch(e){}return o||(o=S(e,n)),o},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>E(e,"^[]{}()\\.^$*+?|-,"),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},createPlainTextSearchRegex:S,toLowerCaseString:function(e){return e.toLowerCase()},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r}});function v(e){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}`)}function C(e,t){throw new Error(t)}function A(e){return e}var y=Object.freeze({__proto__:null,assertNotNullOrUndefined:v,assertNever:C,assertUnhandled:A});var U=Object.freeze({__proto__:null,LocalizedEmptyString:""});class R extends Error{message;constructor(e){super(e),this.message=e}}var M=Object.freeze({__proto__:null,UserVisibleError:R,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof R}});function T(e,t="DCHECK"){}export{i as ArrayUtilities,s as Brand,T as DCHECK,u as DOMUtilities,l as DateUtilities,a as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,m as NumberUtilities,b as SetUtilities,O as StringUtilities,y as TypeScriptUtilities,U as UIString,M as UserVisibleError,C as assertNever,v as assertNotNullOrUndefined,A as assertUnhandled}; | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,a){if(i<=o)return;const l=function(t,r,n,o,i){const s=t[i];e(t,o,i);let a=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,a,i),++a);return e(t,o,a),a}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<l&&t(r,n,o,l-1,s,a),l<a&&t(r,n,l+1,i,s,a)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const a=r(e[i],t[s]);!n&&a||o.push(a<=0?e[i]:t[s]),a<=0&&i++,a>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,a=!1,l=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),a=t(e[s]),l=a===n,l?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var a=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,a=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,a=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,a=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,a=0)}if(o&&"forward"!==o&&"both"!==o)s=e,l=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,l=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,a),u.setEnd(s,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const p=new Set(["application/ecmascript","application/javascript","application/json","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||p.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var w=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});var S=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const N=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},O=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),v=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),C=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},A=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,T="^[]{}()\\.^$*+?|-,",y=function(){return T},z=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==y().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const R=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(R)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var j=Object.freeze({__proto__:null,escapeCharacters:N,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(v.has(r))return v.get(r);return"\\x"+O(r.charCodeAt(0),2)}if(n){return"\\u"+O(n.charCodeAt(0),4)}return t?v.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:C,findLineEndingIndexes:e=>{const t=C(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>A.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:y,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==T.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=z(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>N(e,T),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:z,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var $=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});function L(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function U(e,t){throw new Error(t)}function F(e){return e}var k=Object.freeze({__proto__:null,assertNotNullOrUndefined:L,assertNever:U,assertUnhandled:F});var B=Object.freeze({__proto__:null,LocalizedEmptyString:""});class D extends Error{message;constructor(e){super(e),this.message=e}}var I=Object.freeze({__proto__:null,UserVisibleError:D,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof D}});export{i as ArrayUtilities,s as Brand,u as DOMUtilities,a as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,b as MimeType,w as NumberUtilities,E as PromiseUtilities,S as SetUtilities,j as StringUtilities,$ as Timing,k as TypeScriptUtilities,B as UIString,I as UserVisibleError,U as assertNever,L as assertNotNullOrUndefined,F as assertUnhandled}; |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
@@ -1 +1 @@ | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,l){if(i<=o)return;const a=function(t,r,n,o,i){const s=t[i];e(t,o,i);let l=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,l,i),++l);return e(t,o,l),l}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<a&&t(r,n,o,a-1,s,l),a<l&&t(r,n,a+1,i,s,l)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const l=r(e[i],t[s]);!n&&l||o.push(l<=0?e[i]:t[s]),l<=0&&i++,l>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,l=!1,a=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),l=t(e[s]),a=l===n,a?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var a=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,l=0,a=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,l=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,l=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,l=0)}if(o&&"forward"!==o&&"both"!==o)s=e,a=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,a=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,a=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,l),u.setEnd(s,a),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const g=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},p=new Map([["8∶5","16∶10"]]);var m=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:g,aspectRatio:(e,t)=>{const r=g(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return p.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var b=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const E=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},_=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),x=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),N=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},w=function(){return"^[]{}()\\.^$*+?|-,"},S=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};var O=Object.freeze({__proto__:null,escapeCharacters:E,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(x.has(r))return x.get(r);return"\\x"+_(r.charCodeAt(0),2)}if(n){return"\\u"+_(n.charCodeAt(0),4)}return t?x.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:N,findLineEndingIndexes:e=>{const t=N(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:w,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r){const n=t?"g":"gi";let o;if(r)try{o=new RegExp(e,n)}catch(e){}return o||(o=S(e,n)),o},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>E(e,"^[]{}()\\.^$*+?|-,"),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},createPlainTextSearchRegex:S,toLowerCaseString:function(e){return e.toLowerCase()},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r}});function v(e){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}`)}function C(e,t){throw new Error(t)}function A(e){return e}var y=Object.freeze({__proto__:null,assertNotNullOrUndefined:v,assertNever:C,assertUnhandled:A});var U=Object.freeze({__proto__:null,LocalizedEmptyString:""});class R extends Error{message;constructor(e){super(e),this.message=e}}var M=Object.freeze({__proto__:null,UserVisibleError:R,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof R}});function T(e,t="DCHECK"){}export{i as ArrayUtilities,s as Brand,T as DCHECK,u as DOMUtilities,l as DateUtilities,a as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,m as NumberUtilities,b as SetUtilities,O as StringUtilities,y as TypeScriptUtilities,U as UIString,M as UserVisibleError,C as assertNever,v as assertNotNullOrUndefined,A as assertUnhandled}; | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,a){if(i<=o)return;const l=function(t,r,n,o,i){const s=t[i];e(t,o,i);let a=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,a,i),++a);return e(t,o,a),a}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<l&&t(r,n,o,l-1,s,a),l<a&&t(r,n,l+1,i,s,a)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const a=r(e[i],t[s]);!n&&a||o.push(a<=0?e[i]:t[s]),a<=0&&i++,a>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,a=!1,l=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),a=t(e[s]),l=a===n,l?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var a=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,a=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,a=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,a=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,a=0)}if(o&&"forward"!==o&&"both"!==o)s=e,l=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,l=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,a),u.setEnd(s,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const p=new Set(["application/ecmascript","application/javascript","application/json","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||p.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var w=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});var S=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const N=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},O=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),v=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),C=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},A=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,T="^[]{}()\\.^$*+?|-,",y=function(){return T},z=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==y().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const R=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(R)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var j=Object.freeze({__proto__:null,escapeCharacters:N,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(v.has(r))return v.get(r);return"\\x"+O(r.charCodeAt(0),2)}if(n){return"\\u"+O(n.charCodeAt(0),4)}return t?v.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:C,findLineEndingIndexes:e=>{const t=C(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>A.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:y,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==T.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=z(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>N(e,T),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:z,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var $=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});function L(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function U(e,t){throw new Error(t)}function F(e){return e}var k=Object.freeze({__proto__:null,assertNotNullOrUndefined:L,assertNever:U,assertUnhandled:F});var B=Object.freeze({__proto__:null,LocalizedEmptyString:""});class D extends Error{message;constructor(e){super(e),this.message=e}}var I=Object.freeze({__proto__:null,UserVisibleError:D,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof D}});export{i as ArrayUtilities,s as Brand,u as DOMUtilities,a as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,b as MimeType,w as NumberUtilities,E as PromiseUtilities,S as SetUtilities,j as StringUtilities,$ as Timing,k as TypeScriptUtilities,B as UIString,I as UserVisibleError,U as assertNever,L as assertNotNullOrUndefined,F as assertUnhandled}; |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
@@ -1 +1 @@ | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,l){if(i<=o)return;const a=function(t,r,n,o,i){const s=t[i];e(t,o,i);let l=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,l,i),++l);return e(t,o,l),l}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<a&&t(r,n,o,a-1,s,l),a<l&&t(r,n,a+1,i,s,l)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const l=r(e[i],t[s]);!n&&l||o.push(l<=0?e[i]:t[s]),l<=0&&i++,l>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,l=!1,a=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),l=t(e[s]),a=l===n,a?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var l=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var a=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,l=0,a=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,l=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,l=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,l=0)}if(o&&"forward"!==o&&"both"!==o)s=e,a=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,a=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,a=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,l),u.setEnd(s,a),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const g=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},p=new Map([["8∶5","16∶10"]]);var m=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:g,aspectRatio:(e,t)=>{const r=g(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return p.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var b=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const E=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},_=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),x=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),N=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},w=function(){return"^[]{}()\\.^$*+?|-,"},S=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};var O=Object.freeze({__proto__:null,escapeCharacters:E,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(x.has(r))return x.get(r);return"\\x"+_(r.charCodeAt(0),2)}if(n){return"\\u"+_(n.charCodeAt(0),4)}return t?x.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:N,findLineEndingIndexes:e=>{const t=N(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:w,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!=="^[]{}()\\.^$*+?|-,".indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r){const n=t?"g":"gi";let o;if(r)try{o=new RegExp(e,n)}catch(e){}return o||(o=S(e,n)),o},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>E(e,"^[]{}()\\.^$*+?|-,"),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},createPlainTextSearchRegex:S,toLowerCaseString:function(e){return e.toLowerCase()},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r}});function v(e){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}`)}function C(e,t){throw new Error(t)}function A(e){return e}var y=Object.freeze({__proto__:null,assertNotNullOrUndefined:v,assertNever:C,assertUnhandled:A});var U=Object.freeze({__proto__:null,LocalizedEmptyString:""});class R extends Error{message;constructor(e){super(e),this.message=e}}var M=Object.freeze({__proto__:null,UserVisibleError:R,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof R}});function T(e,t="DCHECK"){}export{i as ArrayUtilities,s as Brand,T as DCHECK,u as DOMUtilities,l as DateUtilities,a as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,m as NumberUtilities,b as SetUtilities,O as StringUtilities,y as TypeScriptUtilities,U as UIString,M as UserVisibleError,C as assertNever,v as assertNotNullOrUndefined,A as assertUnhandled}; | |||
function e(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function t(r,n,o,i,s,a){if(i<=o)return;const l=function(t,r,n,o,i){const s=t[i];e(t,o,i);let a=n;for(let i=n;i<o;++i)r(t[i],s)<0&&(e(t,a,i),++a);return e(t,o,a),a}(r,n,o,i,Math.floor(Math.random()*(i-o))+o);s<l&&t(r,n,o,l-1,s,a),l<a&&t(r,n,l+1,i,s,a)}function r(e,t,r,n){const o=[];let i=0,s=0;for(;i<e.length&&s<t.length;){const a=r(e[i],t[s]);!n&&a||o.push(a<=0?e[i]:t[s]),a<=0&&i++,a>=0&&s++}if(n){for(;i<e.length;)o.push(e[i++]);for(;s<t.length;)o.push(t[s++])}return o}function n(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>0?i=n+1:s=n}return s}function o(e,t,r){const n="END"===r;if(0===e.length)return null;let o=0,i=e.length-1,s=0,a=!1,l=!1,u=0;do{u=o+(i-o)/2,s=n?Math.ceil(u):Math.floor(u),a=t(e[s]),l=a===n,l?o=Math.min(i,s+(o===s?1:0)):i=Math.max(o,s+(i===s?-1:0))}while(i!==o);return t(e[o])?o:null}var i=Object.freeze({__proto__:null,removeElement:(e,t,r)=>{let n=e.indexOf(t);if(-1===n)return!1;if(r)return e.splice(n,1),!0;for(let r=n+1,o=e.length;r<o;++r)e[r]!==t&&(e[n++]=e[r]);return e.length=n,!0},sortRange:function(e,r,n,o,i,s){return 0===n&&o===e.length-1&&0===i&&s>=o?e.sort(r):t(e,r,n,o,i,s),e},binaryIndexOf:(e,t,r)=>{const o=n(e,t,r);return o<e.length&&0===r(t,e[o])?o:-1},intersectOrdered:(e,t,n)=>r(e,t,n,!1),mergeOrdered:(e,t,n)=>r(e,t,n,!0),DEFAULT_COMPARATOR:(e,t)=>e<t?-1:e>t?1:0,lowerBound:n,upperBound:function(e,t,r,n,o){let i=n||0,s=void 0!==o?o:e.length;for(;i<s;){const n=i+s>>1;r(t,e[n])>=0?i=n+1:s=n}return s},nearestIndexFromBeginning:function(e,t){return o(e,t,"BEGINNING")},nearestIndexFromEnd:function(e,t){return o(e,t,"END")},arrayDoesNotContainNullOrUndefined:function(e){return!e.includes(null)&&!e.includes(void 0)}}),s=Object.freeze({__proto__:null});var a=Object.freeze({__proto__:null,isValid:e=>!isNaN(e.getTime()),toISO8601Compact:e=>{function t(e){return(e>9?"":"0")+e}return e.getFullYear()+t(e.getMonth()+1)+t(e.getDate())+"T"+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}});var l=Object.freeze({__proto__:null,EmptyUrlString:"",EmptyRawPathString:"",EmptyEncodedPathString:""});var u=Object.freeze({__proto__:null,deepActiveElement:function(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t},getEnclosingShadowRootForNode:function(e){let t=e.parentNodeOrShadowHost();for(;t;){if(t instanceof ShadowRoot)return t;t=t.parentNodeOrShadowHost()}return null},rangeOfWord:function(e,t,r,n,o){let i,s,a=0,l=0;if(n||(n=e),o&&"backward"!==o&&"both"!==o)i=e,a=t;else{let o=e;for(;o;){if(o===n){i||(i=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t-1:o.nodeValue.length-1;n>=0;--n)if(-1!==r.indexOf(o.nodeValue[n])){i=o,a=n+1;break}}if(i)break;o=o.traversePreviousNode(n)}i||(i=n,a=0)}if(o&&"forward"!==o&&"both"!==o)s=e,l=t;else{let o=e;for(;o;){if(o===n){s||(s=n);break}if(o.nodeType===Node.TEXT_NODE&&null!==o.nodeValue){for(let n=o===e?t:0;n<o.nodeValue.length;++n)if(-1!==r.indexOf(o.nodeValue[n])){s=o,l=n;break}}if(s)break;o=o.traverseNextNode(n)}s||(s=n,l=n.nodeType===Node.TEXT_NODE?n.nodeValue?.length||0:n.childNodes.length)}if(!e.ownerDocument)throw new Error("No `ownerDocument` found for rootNode");const u=e.ownerDocument.createRange();return u.setStart(i,a),u.setEnd(s,l),u}});const c=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);var f=Object.freeze({__proto__:null,ENTER_KEY:"Enter",ESCAPE_KEY:"Escape",TAB_KEY:"Tab",ARROW_KEYS:c,keyIsArrowKey:function(e){return c.has(e)},isEscKey:function(e){return"Escape"===e.key},isEnterOrSpaceKey:function(e){return"Enter"===e.key||" "===e.key}});class d{map=new Map;set(e,t){let r=this.map.get(e);r||(r=new Set,this.map.set(e,r)),r.add(t)}get(e){return this.map.get(e)||new Set}has(e){return this.map.has(e)}hasValue(e,t){const r=this.map.get(e);return!!r&&r.has(t)}get size(){return this.map.size}delete(e,t){const r=this.get(e);if(!r)return!1;const n=r.delete(t);return r.size||this.map.delete(e),n}deleteAll(e){this.map.delete(e)}keysArray(){return[...this.map.keys()]}valuesArray(){const e=[];for(const t of this.map.values())e.push(...t.values());return e}clear(){this.map.clear()}}var h=Object.freeze({__proto__:null,inverse:function(e){const t=new d;for(const[r,n]of e.entries())t.set(n,r);return t},Multimap:d,getWithDefault:function(e,t,r){let n=e.get(t);return n||(n=r(t),e.set(t,n)),n}});const p=new Set(["application/ecmascript","application/javascript","application/json","application/vnd.dart","application/xml","application/x-aspx","application/x-javascript","application/x-jsp","application/x-httpd-php"]);function g(e,t,r=0){for(let n=r;n<e.length;n++)if(t.includes(e[n]))return n;return-1}function m(e,t,r=0){for(let n=r;n<e.length;n++)if(!t.includes(e[n]))return n;return-1}var b=Object.freeze({__proto__:null,isTextType:function(e){return e.startsWith("text/")||e.endsWith("+json")||e.endsWith("+xml")||p.has(e)},parseContentType:function(e){if("*/*"===e)return{mimeType:null,charset:null};const{mimeType:t,params:r}=function(e){e=e.trim();let t=g(e," \t;(");t<0&&(t=e.length);const r=e.indexOf("/");if(r<0||r>t)return{mimeType:null,params:new Map};const n=e.substring(0,t).toLowerCase(),o=new Map;let i=e.indexOf(";",t);for(;i>=0&&i<e.length;){if(++i,i=m(e," \t",i),i<0)continue;const t=i;if(i=g(e,";=",i),i<0||";"===e[i])continue;const r=e.substring(t,i).toLowerCase();++i,i=m(e," \t",i);let n="";if(!(i<0||";"===e[i])){if('"'!==e[i]){const t=i;i=e.indexOf(";",i);const r=i>=0?i:e.length;n=e.substring(t,r).trimEnd()}else{for(++i;i<e.length&&'"'!==e[i];)"\\"===e[i]&&i+1<e.length&&++i,n+=e[i],++i;i=e.indexOf(";",i)}o.has(r)||o.set(r,n)}}return{mimeType:n,params:o}}(e);return{mimeType:t,charset:r.get("charset")?.toLowerCase().trim()??null}}});const _=(e,t)=>{for(e=Math.round(e),t=Math.round(t);0!==t;){const r=t;t=e%t,e=r}return e},x=new Map([["8∶5","16∶10"]]);var w=Object.freeze({__proto__:null,clamp:(e,t,r)=>{let n=e;return e<t?n=t:e>r&&(n=r),n},mod:(e,t)=>(e%t+t)%t,bytesToString:e=>{if(e<1e3)return`${e.toFixed(0)} B`;const t=e/1e3;if(t<100)return`${t.toFixed(1)} kB`;if(t<1e3)return`${t.toFixed(0)} kB`;const r=t/1e3;return r<100?`${r.toFixed(1)} MB`:`${r.toFixed(0)} MB`},toFixedIfFloating:e=>{if(!e||Number.isNaN(Number(e)))return e;const t=Number(e);return t%1?t.toFixed(3):String(t)},floor:(e,t=0)=>{const r=Math.pow(10,t);return Math.floor(e*r)/r},greatestCommonDivisor:_,aspectRatio:(e,t)=>{const r=_(e,t);0!==r&&(e/=r,t/=r);const n=`${e}∶${t}`;return x.get(n)||n},withThousandsSeparator:function(e){let t=String(e);const r=/(\d+)(\d{3})/;for(;t.match(r);)t=t.replace(r,"$1 $2");return t}});var E=Object.freeze({__proto__:null,promiseWithResolvers:function(){let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),resolve:e,reject:t}}});var S=Object.freeze({__proto__:null,addAll:function(e,t){for(const r of t)e.add(r)},isEqual:function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}});const N=(e,t)=>{let r=!1;for(let n=0;n<t.length;++n)if(-1!==e.indexOf(t.charAt(n))){r=!0;break}if(!r)return String(e);let n="";for(let r=0;r<e.length;++r)-1!==t.indexOf(e.charAt(r))&&(n+="\\"),n+=e.charAt(r);return n},O=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0"),v=new Map([["\b","\\b"],["\f","\\f"],["\n","\\n"],["\r","\\r"],["\t","\\t"],["\v","\\v"],["'","\\'"],["\\","\\\\"],["\x3c!--","\\x3C!--"],["<script","\\x3Cscript"],["</script","\\x3C/script"]]),C=(e,t)=>{const r=[];let n=e.indexOf(t);for(;-1!==n;)r.push(n),n=e.indexOf(t,n+t.length);return r},A=/^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/,T="^[]{}()\\.^$*+?|-,",y=function(){return T},z=function(e,t){let r="";for(let t=0;t<e.length;++t){const n=e.charAt(t);-1!==y().indexOf(n)&&(r+="\\"),r+=n}return new RegExp(r,t||"")};const R=/[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\b|_)|[A-Za-z][0-9]+[a-z]|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g,M=function(e){return e.match?.(R)?.map((e=>e.toLowerCase())).join("-").replaceAll("-.-",".")||e};var j=Object.freeze({__proto__:null,escapeCharacters:N,formatAsJSLiteral:e=>{const t=/(\\|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,r=/(\\|'|<(?:!--|\/?script))|(\p{Control})|(\p{Surrogate})/gu,n=(e,t,r,n)=>{if(r){if(v.has(r))return v.get(r);return"\\x"+O(r.charCodeAt(0),2)}if(n){return"\\u"+O(n.charCodeAt(0),4)}return t?v.get(t)||"":e};let o="",i="";return e.includes("'")?e.includes('"')?e.includes("`")||e.includes("${")?(i="'",o=e.replaceAll(r,n)):(i="`",o=e.replaceAll(t,n)):(i='"',o=e.replaceAll(t,n)):(i="'",o=e.replaceAll(t,n)),`${i}${o}${i}`},sprintf:(e,...t)=>{let r=0;return e.replaceAll(/%(?:(\d+)\$)?(?:\.(\d*))?([%dfs])/g,((e,n,o,i)=>{if("%"===i)return"%";if(void 0!==n&&(r=parseInt(n,10)-1,r<0))throw new RangeError(`Invalid parameter index ${r+1}`);if(r>=t.length)throw new RangeError(`Expected at least ${r+1} format parameters, but only ${t.length} where given.`);if("s"===i){const e=String(t[r++]);return void 0!==o?e.substring(0,Number(o)):e}let s=Number(t[r++]);return isNaN(s)&&(s=0),"d"===i?String(Math.floor(s)).padStart(Number(o),"0"):void 0!==o?s.toFixed(Number(o)):String(s)}))},toBase64:e=>{function t(e){return e<26?e+65:e<52?e+71:e<62?e-4:62===e?43:63===e?47:65}const r=(new TextEncoder).encode(e.toString()),n=r.length;let o,i="";if(0===n)return i;let s=0;for(let e=0;e<n;e++)o=e%3,s|=r[e]<<(16>>>o&24),2===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),t(63&s)),s=0);return 0===o?i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),61,61):1===o&&(i+=String.fromCharCode(t(s>>>18&63),t(s>>>12&63),t(s>>>6&63),61)),i},findIndexesOfSubString:C,findLineEndingIndexes:e=>{const t=C(e,"\n");return t.push(e.length),t},isWhitespace:e=>/^\s*$/.test(e),trimURL:(e,t)=>{let r=e.replace(/^(https|http|file):\/\//i,"");return t&&r.toLowerCase().startsWith(t.toLowerCase())&&(r=r.substr(t.length)),r},collapseWhitespace:e=>e.replace(/[\s\xA0]+/g," "),reverse:e=>e.split("").reverse().join(""),replaceControlCharacters:e=>e.replace(/[\0-\x08\x0B\f\x0E-\x1F\x80-\x9F]/g,"�"),countWtf8Bytes:e=>{let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<=127)t++;else if(n<=2047)t+=2;else if(n<55296||57343<n)t+=3;else{if(n<=56319&&r+1<e.length){const n=e.charCodeAt(r+1);if(56320<=n&&n<=57343){t+=4,r++;continue}}t+=3}}return t},stripLineBreaks:e=>e.replace(/(\r)?\n/g,""),isExtendedKebabCase:e=>A.test(e),toTitleCase:e=>e.substring(0,1).toUpperCase()+e.substring(1),removeURLFragment:e=>{const t=new URL(e);return t.hash="",t.toString()},regexSpecialCharacters:y,filterRegex:function(e){let t="^(?:.*\\0)?";for(let r=0;r<e.length;++r){let n=e.charAt(r);-1!==T.indexOf(n)&&(n="\\"+n),t+="[^\\0"+n+"]*"+n}return new RegExp(t,"i")},createSearchRegex:function(e,t,r,n=!1){const o=t?"g":"gi";let i;if(r)try{i=new RegExp(e,o)}catch(e){}return i||(i=z(e,o)),n&&i&&(i=new RegExp(`\\b${i.source}\\b`,o)),i},caseInsensetiveComparator:function(e,t){return(e=e.toUpperCase())===(t=t.toUpperCase())?0:e>t?1:-1},hashCode:function(e){if(!e)return 0;const t=4294967291;let r=0,n=1;for(let o=0;o<e.length;o++){r=(r+n*(1506996573*e.charCodeAt(o)))%t,n=1345575271*n%t}return r=(r+n*(t-1))%t,Math.abs(0|r)},compare:(e,t)=>e>t?1:e<t?-1:0,trimMiddle:(e,t)=>{if(e.length<=t)return String(e);let r=t>>1,n=t-r-1;return e.codePointAt(e.length-n-1)>=65536&&(--n,++r),r>0&&e.codePointAt(r-1)>=65536&&--r,e.substr(0,r)+"…"+e.substr(e.length-n,n)},trimEndWithMaxLength:(e,t)=>e.length<=t?String(e):e.substr(0,t-1)+"…",escapeForRegExp:e=>N(e,T),naturalOrderComparator:(e,t)=>{const r=/^\d+|^\D+/;let n,o,i,s;for(;;){if(!e)return t?-1:0;if(!t)return 1;if(n=e.match(r)[0],o=t.match(r)[0],i=!Number.isNaN(Number(n)),s=!Number.isNaN(Number(o)),i&&!s)return-1;if(s&&!i)return 1;if(i&&s){const e=Number(n)-Number(o);if(e)return e;if(n.length!==o.length)return Number(n)||Number(o)?o.length-n.length:n.length-o.length}else if(n!==o)return n<o?-1:1;e=e.substring(n.length),t=t.substring(o.length)}},base64ToSize:function(e){if(!e)return 0;let t=3*e.length/4;return"="===e[e.length-1]&&t--,e.length>1&&"="===e[e.length-2]&&t--,t},SINGLE_QUOTE:"'",DOUBLE_QUOTE:'"',findUnclosedCssQuote:function(e){let t="";for(let r=0;r<e.length;++r){const n=e[r];"\\"!==n?"'"!==n&&'"'!==n||(t===n?t="":""===t&&(t=n)):r++}return t},countUnmatchedLeftParentheses:e=>{let t=0;for(const r of e)"("===r?t++:")"===r&&t>0&&t--;return t},createPlainTextSearchRegex:z,toLowerCaseString:function(e){return e.toLowerCase()},toKebabCase:M,toKebabCaseKeys:function(e){const t={};for(const[r,n]of Object.entries(e))t[M(r)]=n;return t},replaceLast:function(e,t,r){const n=e.lastIndexOf(t);return-1===n?e:e.slice(0,n)+e.slice(n).replace(t,r)},stringifyWithPrecision:function(e,t=2){if(0===t)return e.toFixed(0);const r=e.toFixed(t).replace(/\.?0*$/,"");return"-0"===r?"0":r},concatBase64:function(e,t){if(0===e.length||!e.endsWith("="))return e+t;const r=e.substring(0,e.length-4),n=e.substring(e.length-4);return r+window.btoa(window.atob(n)+window.atob(t))}});var $=Object.freeze({__proto__:null,secondsToMilliSeconds:function(e){return 1e3*e},milliSecondsToSeconds:function(e){return e/1e3},microSecondsToMilliSeconds:function(e){return e/1e3}});function L(e,t){if(null==e)throw new Error(`Expected given value to not be null/undefined but it was: ${e}${t?`\n${t}`:""}`)}function U(e,t){throw new Error(t)}function F(e){return e}var k=Object.freeze({__proto__:null,assertNotNullOrUndefined:L,assertNever:U,assertUnhandled:F});var B=Object.freeze({__proto__:null,LocalizedEmptyString:""});class D extends Error{message;constructor(e){super(e),this.message=e}}var I=Object.freeze({__proto__:null,UserVisibleError:D,isUserVisibleError:function(e){return"object"==typeof e&&null!==e&&e instanceof D}});export{i as ArrayUtilities,s as Brand,u as DOMUtilities,a as DateUtilities,l as DevToolsPath,f as KeyboardUtilities,h as MapUtilities,b as MimeType,w as NumberUtilities,E as PromiseUtilities,S as SetUtilities,j as StringUtilities,$ as Timing,k as TypeScriptUtilities,B as UIString,I as UserVisibleError,U as assertNever,L as assertNotNullOrUndefined,F as assertUnhandled}; |
Check failure
Code scanning / CodeQL
Incomplete multi-character sanitization High library
<!--
@@ -1 +1 @@ | |||
import*as e from"../../core/platform/platform.js";import"../../core/common/common.js";import*as n from"../../core/protocol_client/protocol_client.js";import*as t from"../../core/root/root.js";import*as r from"../../models/bindings/bindings.js";import*as o from"../../models/workspace/workspace.js";import*as s from"../../ui/components/code_highlighter/code_highlighter.js";import*as i from"../../ui/legacy/legacy.js";function a(){return!self.testRunner||Boolean(t.Runtime.Runtime.queryParam("debugFrontend"))}self.Platform=self.Platform||{},self.Platform.StringUtilities=e.StringUtilities,self.Platform.MapUtilities=e.MapUtilities,self.Platform.ArrayUtilities=e.ArrayUtilities,self.Platform.DOMUtilities=e.DOMUtilities,self.createPlainTextSearchRegex=e.StringUtilities.createPlainTextSearchRegex,String.sprintf=e.StringUtilities.sprintf,String.regexSpecialCharacters=e.StringUtilities.regexSpecialCharacters,String.caseInsensetiveComparator=e.StringUtilities.caseInsensetiveComparator,self.onerror=(e,n,t,r,o)=>{l("TEST ENDED IN ERROR: "+o.stack),p()},self.addEventListener("unhandledrejection",(e=>{l(`PROMISE FAILURE: ${e.reason.stack}`),p()})),a()||(console.log=(...e)=>{l(`log: ${e}`)},console.error=(...e)=>{l(`error: ${e}`)},console.info=(...e)=>{l(`info: ${e}`)},console.assert=(e,...n)=>{e||l(`ASSERTION FAILURE: ${n.join(" ")}`)});let u=[],c=e=>{u.push(String(e))};function l(e){c(e)}let d=!1,f=()=>{d||(d=!0,function(){Array.prototype.forEach.call(document.documentElement.childNodes,(e=>e.remove()));const e=document.createElement("div");e.style&&(e.style.whiteSpace="pre",e.style.height="10px",e.style.overflow="hidden");document.documentElement.appendChild(e);for(let n=0;n<u.length;n++)e.appendChild(document.createTextNode(u[n])),e.appendChild(document.createElement("br"));u=[]}(),self.testRunner.notifyDone())};function p(){f()}self.TestRunner=self.TestRunner||{};const m=new Map([["panels/animation","animation"],["panels/browser_debugger","browser_debugger"],["panels/changes","changes"],["panels/console","console"],["panels/elements","elements"],["panels/emulation","emulation"],["panels/mobile_throttling","mobile_throttling"],["panels/network","network"],["panels/profiler","profiler"],["panels/application","resources"],["panels/search","search"],["panels/sources","sources"],["panels/snippets","snippets"],["panels/settings","settings"],["panels/timeline","timeline"],["panels/web_audio","web_audio"],["models/persistence","persistence"],["models/workspace_diff","workspace_diff"],["entrypoints/main","main"],["third_party/diff","diff"],["ui/legacy/components/inline_editor","inline_editor"],["ui/legacy/components/data_grid","data_grid"],["ui/legacy/components/perf_ui","perf_ui"],["ui/legacy/components/source_frame","source_frame"],["ui/legacy/components/color_picker","color_picker"],["ui/legacy/components/cookie_table","cookie_table"],["ui/legacy/components/quick_open","quick_open"],["ui/legacy/components/utils","components"]]);function g(e,n){return function(){if(!e)return;const t=this;try{return e.apply(t,arguments)}catch(t){l("Exception while running: "+e+"\n"+(t.stack||t)),n?g(n)():p()}}}function T(e){return async function(){if(!e)return;const n=this;try{return await e.apply(n,arguments)}catch(n){l("Exception while running: "+e+"\n"+(n.stack||n)),p()}}}function R(e){function n(n){let t=0;for(;n&&n!==e;)"OL"!==n.nodeName||n.classList&&n.classList.contains("object-properties-section")||++t,n=n.parentNode;return Array(4*t+1).join(" ")}let t="",r=e,o=!1;for(;r.traverseNextNode(e);)if(r=r.traverseNextNode(e),r.nodeType===Node.TEXT_NODE&&r.parentNode?.nodeType!==Node.DOCUMENT_FRAGMENT_NODE)t+=r.nodeValue;else if("LI"===r.nodeName||"TR"===r.nodeName)o?o=!1:t+="\n"+n(r);else{if("STYLE"===r.nodeName){r=r.traverseNextNode(e);continue}r.classList&&r.classList.contains("object-properties-section")&&(o=!0)}return t}async function h(e,n){const t=await v(e);g(n)(t.result.value,t.exceptionDetails)}let y=0;async function v(e){const r=(new Error).stack.split("at "),o=t.Runtime.Runtime.queryParam("test"),s=r.reduce(((e,n)=>n.includes(o)?n:e),r[r.length-2]).trim().split("/"),i=s[s.length-1].slice(0,-1).split(":"),a=i[0],u=`test://evaluations/${y++}/`+a,c=parseInt(i[1],10);-1===(e="\n".repeat(c-1)+e).indexOf("sourceURL=")&&(e+=`//# sourceURL=${u}`);const d=await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console"}),f=d[n.InspectorBackend.ProtocolError];return f?(l("Error: "+f),void p()):d}async function w(e,t){const r=await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console",userGesture:t});if(!r[n.InspectorBackend.ProtocolError])return r.result.value;l("Error: "+(r.exceptionDetails&&r.exceptionDetails.text||"exception from evaluateInPageAnonymously.")),p()}async function S(e){const t=await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console",includeCommandLineAPI:!1,awaitPromise:!0}),r=t[n.InspectorBackend.ProtocolError];if(!r&&!t.exceptionDetails)return t.result.value;let o="Error: ";r?o+=r:t.exceptionDetails&&(o+=t.exceptionDetails.text,t.exceptionDetails.exception&&(o+=" "+t.exceptionDetails.exception.description)),l(o),p()}function E(e){if(!e.includes("<base")){const n=/(<!DOCTYPE.*?>)/i,t=`<base href="${j()}">`;e=e.match(n)?e.replace(n,"$1"+t):t+e}return w(`document.write(\`${e=e.replace(/'/g,"\\'").replace(/\n/g,"\\n")}\`);document.close();`)}const x={formatAsTypeName:e=>"<"+typeof e+">",formatAsTypeNameOrNull:e=>null===e?"null":x.formatAsTypeName(e),formatAsRecentTime(e){if("object"!=typeof e||!(e instanceof Date))return x.formatAsTypeName(e);const n=Date.now()-e;return 0<=n&&n<18e5?"<plausible>":e},formatAsURL(e){if(!e)return e;const n=e.lastIndexOf("devtools/");return n<0?e:".../"+e.substr(n)},formatAsDescription:e=>e?'"'+e.replace(/^function [gs]et /,"function ")+'"':e};function P(e,n,t,r){t=t||"",l((r=r||t)+"{");const o=Object.keys(e);o.sort();for(let r=0;r<o.length;++r){const s=o[r];if(!e.hasOwnProperty(s))continue;const i=" "+t+s+" : ",a=e[s];if(n&&n[s]){const e=n[s];if("skip"!==e){l(i+(0,x[e])(a))}}else D(a,n," "+t,i)}l(t+"}")}function A(e,n,t,r){t=t||"",l((r=r||t)+"[");for(let r=0;r<e.length;++r)D(e[r],n,t+" ");l(t+"]")}function D(e,n,t,r){(r=r||t)&&r.length>80?l(r+"was skipped due to prefix length limit"):null===e?l(r+"null"):e&&e.constructor&&"Array"===e.constructor.name?A(e,n,t,r):"object"==typeof e?P(e,n,t,r):l("string"==typeof e?r+'"'+e+'"':r+e)}function M(e,n,t){return t=t||function(){return!0},new Promise((r=>{n.addEventListener(e,(function o(s){if(!t(s.data))return;n.removeEventListener(e,o),r(s.data)}))}))}function b(e){return e.executionContexts().length?Promise.resolve(e.executionContexts()[0]):e.once(SDK.RuntimeModel.Events.ExecutionContextCreated)}let k;function N(e,n){k=g(n),TestRunner.resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load,L),w("window.location.replace('"+e+"')")}function L(){TestRunner.resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.Load,L),_()}function C(e){I(!1,void 0,e)}function I(e,n,t){k=g(t),TestRunner.resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load,O),TestRunner.resourceTreeModel.reloadPage(e,n)}function O(){TestRunner.resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.Load,O),l("Page reloaded."),_()}async function _(){if(await b(TestRunner.runtimeModel),k){const e=k;k=void 0,e()}}function K(e,n,t){if(e===n)return;let r;throw r=t?"Failure ("+t+"):":"Failure:",new Error(r+" expected <"+e+"> found <"+n+">")}function j(e=""){const n=t.Runtime.Runtime.queryParam("inspected_test")||t.Runtime.Runtime.queryParam("test");return new URL(e,n+"/../").href}async function U(){const e=Root.Runtime.queryParam("test");if(a())return n=console.log,c=n,f=()=>console.log("Test completed"),void(self.test=async function(){await import(e)});var n;try{await import(e)}catch(e){l("TEST ENDED EARLY DUE TO UNCAUGHT ERROR:"),l(e&&e.stack||e),l("=== DO NOT COMMIT THIS INTO -expected.txt ==="),p()}}self.testRunner,TestRunner.StringOutputStream=class{constructor(e){this.callback=e,this.buffer=""}async open(e){return!0}async write(e){this.buffer+=e}async close(){this.callback(this.buffer)}},TestRunner.MockSetting=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}},TestRunner.formatters=x,TestRunner.completeTest=p,TestRunner.addResult=l,TestRunner.addResults=function(e){if(e)for(let n=0,t=e.length;n<t;++n)l(e[n])},TestRunner.runTests=function(e){!function n(){const t=e.shift();if(!t)return void p();l("\ntest: "+t.name);let r=t();r instanceof Promise||(r=Promise.resolve());r.then(n)}()},TestRunner.addSniffer=function(e,n,t,r){t=g(t);const o=e[n];if("function"!=typeof o)throw new Error("Cannot find method to override: "+n);e[n]=function(s){let i;try{i=o.apply(this,arguments)}finally{r||(e[n]=o)}try{Array.prototype.push.call(arguments,i),t.apply(this,arguments)}catch(e){throw new Error("Exception in overriden method '"+n+"': "+e)}return i}},TestRunner.addSnifferPromise=function(e,n){return new Promise((function(t,r){const o=e[n];"function"==typeof o?e[n]=function(s){let i;try{i=o.apply(this,arguments)}finally{e[n]=o}try{Array.prototype.push.call(arguments,i),t.apply(this,arguments)}catch(e){r("Exception in overridden method '"+n+"': "+e),p()}return i}:r("Cannot find method to override: "+n)}))},TestRunner.showPanel=function(e){return i.ViewManager.ViewManager.instance().showView(e)},TestRunner.createKeyEvent=function(e,n,t,r,o){return new KeyboardEvent("keydown",{key:e,bubbles:!0,cancelable:!0,ctrlKey:Boolean(n),altKey:Boolean(t),shiftKey:Boolean(r),metaKey:Boolean(o)})},TestRunner.safeWrap=g,TestRunner.textContentWithLineBreaks=R,TestRunner.textContentWithLineBreaksTrimmed=function(e){return R(e).replace(/\s{3,}/g," ")},TestRunner.textContentWithoutStyles=function(e){let n="",t=e;for(;t.traverseNextNode(e);)t=t.traverseNextNode(e,"DEVTOOLS-CSS-LENGTH"===t.tagName||"DEVTOOLS-ICON"===t.tagName),t.nodeType===Node.TEXT_NODE?n+=t.nodeValue:"STYLE"===t.nodeName&&(t=t.traverseNextNode(e));return n},TestRunner.evaluateInPagePromise=function(e){return new Promise((n=>h(e,n)))},TestRunner.callFunctionInPageAsync=function(e,n){return S(e+"("+(n=n||[]).map((e=>JSON.stringify(e))).join(",")+")")},TestRunner.evaluateInPageWithTimeout=function(e,n){w("setTimeout(unescape('"+escape(e)+"'), 1)",n)},TestRunner.evaluateFunctionInOverlay=function(e,n){const t='internals.evaluateInInspectorOverlay("(" + '+e+' + ")()")';TestRunner.runtimeModel.executionContexts()[0].evaluate({expression:t,objectGroup:"",includeCommandLineAPI:!1,silent:!1,returnByValue:!0,generatePreview:!1},!1,!1).then((e=>{n(e.object.value)}))},TestRunner.check=function(e,n){e||l("FAIL: "+n)},TestRunner.deprecatedRunAfterPendingDispatches=function(e){ProtocolClient.test.deprecatedRunAfterPendingDispatches(e)},TestRunner.loadHTML=E,TestRunner.addScriptTag=function(e){return S(`\n (function(){\n let script = document.createElement('script');\n script.src = '${e}';\n document.head.append(script);\n return new Promise(f => script.onload = f);\n })();\n `)},TestRunner.addStylesheetTag=function(e){return S(`\n (function(){\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = '${e}';\n link.onload = onload;\n document.head.append(link);\n let resolve;\n const promise = new Promise(r => resolve = r);\n function onload() {\n // TODO(chenwilliam): It shouldn't be necessary to force\n // style recalc here but some tests rely on it.\n window.getComputedStyle(document.body).color;\n resolve();\n }\n return promise;\n })();\n `)},TestRunner.addIframe=function(e,n={}){return n.id=n.id||"",n.name=n.name||"",S(`\n (function(){\n const iframe = document.createElement('iframe');\n iframe.src = '${e}';\n iframe.id = '${n.id}';\n iframe.name = '${n.name}';\n document.body.appendChild(iframe);\n return new Promise(f => iframe.onload = f);\n })();\n `)},TestRunner.markStep=function(e){l("\nRunning: "+e)},TestRunner.startDumpingProtocolMessages=function(){ProtocolClient.test.dumpProtocol=self.testRunner.logToStderr.bind(self.testRunner)},TestRunner.addScriptForFrame=function(e,n,t){n+="\n//# sourceURL="+e;const r=TestRunner.runtimeModel.executionContexts().find((e=>e.frameId===t.id));TestRunner.RuntimeAgent.evaluate(n,"console",!1,!1,r.id)},TestRunner.addObject=P,TestRunner.addArray=A,TestRunner.dumpDeepInnerHTML=function(e){!function e(n,t){const r=[];if(t.nodeType===Node.TEXT_NODE)return void(t.parentElement&&"STYLE"===t.parentElement.nodeName||l(t.nodeValue));r.push("<"+t.nodeName);const o=t.attributes;for(let e=0;o&&e<o.length;++e)r.push(o[e].name+"="+o[e].value);r.push(">"),l(n+r.join(" "));for(let r=t.firstChild;r;r=r.nextSibling)e(n+" ",r);t.shadowRoot&&e(n+" ",t.shadowRoot),l(n+"</"+t.nodeName+">")}("",e)},TestRunner.deepTextContent=function e(n){if(!n)return"";if(n.nodeType===Node.TEXT_NODE&&n.nodeValue)return n.parentElement&&"STYLE"===n.parentElement.nodeName?"":n.nodeValue;let t="";const r=n.childNodes;for(let n=0;n<r.length;++n)t+=e(r[n]);return n.shadowRoot&&(t+=e(n.shadowRoot)),t},TestRunner.dump=D,TestRunner.waitForEvent=M,TestRunner.waitForTarget=function(e){e=e||(e=>!0);for(const n of self.SDK.targetManager.targets())if(e(n))return Promise.resolve(n);return new Promise((n=>{const t={targetAdded:function(r){e(r)&&(self.SDK.targetManager.unobserveTargets(t),n(r))},targetRemoved:function(){}};self.SDK.targetManager.observeTargets(t)}))},TestRunner.waitForTargetRemoved=function(e){return new Promise((n=>{const t={targetRemoved:function(r){r===e&&(self.SDK.targetManager.unobserveTargets(t),n(r))},targetAdded:function(){}};self.SDK.targetManager.observeTargets(t)}))},TestRunner.waitForExecutionContext=b,TestRunner.waitForExecutionContextDestroyed=function(e){const n=e.runtimeModel;return-1===n.executionContexts().indexOf(e)?Promise.resolve():M(SDK.RuntimeModel.Events.ExecutionContextDestroyed,n,(n=>n===e))},TestRunner.assertGreaterOrEqual=function(e,n,t){e<n&&l("FAILED: "+(t?t+": ":"")+e+" < "+n)},TestRunner.navigate=N,TestRunner.navigatePromise=function(e){return new Promise((n=>N(e,n)))},TestRunner.hardReloadPage=function(e){I(!0,void 0,e)},TestRunner.reloadPage=C,TestRunner.reloadPageWithInjectedScript=function(e,n){I(!1,e,n)},TestRunner.reloadPagePromise=function(){return new Promise((e=>C(e)))},TestRunner.pageLoaded=O,TestRunner.waitForPageLoad=function(e){TestRunner.resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load,(function n(){TestRunner.resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.Load,n),e()}))},TestRunner.runWhenPageLoads=function(e){const n=k;k=g((function(){n&&n(),e()}))},TestRunner.runTestSuite=function(e){const n=e.slice();!function e(){if(!n.length)return void p();const t=n.shift();l(""),l("Running: "+/function\s([^(]*)/.exec(t)[1]),g(t)(e)}()},TestRunner.assertEquals=K,TestRunner.assertTrue=function(e,n){K(!0,Boolean(e),n)},TestRunner.override=function(e,n,t,r){t=g(t);const o=e[n];if("function"!=typeof o)throw new Error("Cannot find method to override: "+n);return e[n]=function(s){try{return t.apply(this,arguments)}catch(e){throw new Error("Exception in overriden method '"+n+"': "+e)}finally{r||(e[n]=o)}},o},TestRunner.clearSpecificInfoFromStackFrames=function(e){let n=e.replace(/\(file:\/\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)");return n=n.replace(/\(http:\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)"),n=n.replace(/\(test:\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)"),n=n.replace(/\(<anonymous>:[^)]+\)/g,"(...)"),n=n.replace(/VM\d+/g,"VM"),n.replace(/\s*at[^()]+\(native\)/g,"")},TestRunner.hideInspectorView=function(){i.InspectorView.InspectorView.instance().element.setAttribute("style","display:none !important")},TestRunner.mainFrame=function(){return TestRunner.resourceTreeModel.mainFrame},TestRunner.waitForUISourceCode=function(e,n){function t(t){return(!n||t.project().type()===n)&&(!(!n&&t.project().type()===o.Workspace.projectTypes.Service)&&!(e&&!t.url().endsWith(e)))}for(const n of self.Workspace.workspace.uiSourceCodes())if(e&&t(n))return Promise.resolve(n);return M(o.Workspace.Events.UISourceCodeAdded,self.Workspace.workspace,t)},TestRunner.waitForUISourceCodeRemoved=function(e){self.Workspace.workspace.once(o.Workspace.Events.UISourceCodeRemoved).then(e)},TestRunner.url=j,TestRunner.dumpSyntaxHighlight=function(e,n){const t=document.createElement("span");return t.textContent=e,s.CodeHighlighter.highlightNode(t,n).then((function(){const n=[];for(let e=0;e<t.childNodes.length;e++)t.childNodes[e].getAttribute?n.push(t.childNodes[e].getAttribute("class")):n.push("*");l(e+": "+n.join(", "))}))},TestRunner.loadLegacyModule=async function(e){let n=e;for(const[t,r]of m.entries())r===e&&(n=t);await import(`../../${n}/${n.split("/").reverse()[0]}-legacy.js`)},TestRunner.evaluateInPageRemoteObject=async function(e){const n=await v(e);return TestRunner.runtimeModel.createRemoteObject(n.result)},TestRunner.evaluateInPage=h,TestRunner.evaluateInPageAnonymously=w,TestRunner.evaluateInPageAsync=S,TestRunner.deprecatedInitAsync=async function(e){await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console"})},TestRunner.runAsyncTestSuite=async function(e){for(const n of e)l(""),l("Running: "+/function\s([^(]*)/.exec(n)[1]),await T(n)();p()},TestRunner.dumpInspectedPageElementText=async function(e){l(await S(`document.querySelector('${e}').innerText`))},TestRunner.waitForPendingLiveLocationUpdates=async function(){await r.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pendingLiveLocationChangesPromise(),await r.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().pendingLiveLocationChangesPromise()},TestRunner.findLineEndingIndexes=function(e){const n=function(e,n){const t=[];let r=e.indexOf(n);for(;-1!==r;)t.push(r),r=e.indexOf(n,r+n.length);return t}(e,"\n");return n.push(e.length),n},TestRunner.selectTextInTextNode=function(e,n,t){n=n||0,t=t||e.textContent.length,n<0&&(n=t+n);const r=e.getComponentSelection();r.removeAllRanges();const o=e.ownerDocument.createRange();return o.setStart(e,n),o.setEnd(e,t),r.addRange(o),e},TestRunner.isScrolledToBottom=i.UIUtils.isScrolledToBottom,self.Platform=self.Platform||{},self.Platform.StringUtilities=e.StringUtilities;let F=!1;class W{targetAdded(e){if("main"===e.id()&&"frame"===e.type()||"tab"===e.parentTarget()?.type()&&"frame"===e.type()&&!e.targetInfo()?.subtype?.length){if(function(e){self.TestRunner.BrowserAgent=e.browserAgent(),self.TestRunner.CSSAgent=e.cssAgent(),self.TestRunner.DeviceOrientationAgent=e.deviceOrientationAgent(),self.TestRunner.DOMAgent=e.domAgent(),self.TestRunner.DOMDebuggerAgent=e.domdebuggerAgent(),self.TestRunner.DebuggerAgent=e.debuggerAgent(),self.TestRunner.EmulationAgent=e.emulationAgent(),self.TestRunner.HeapProfilerAgent=e.heapProfilerAgent(),self.TestRunner.InputAgent=e.inputAgent(),self.TestRunner.InspectorAgent=e.inspectorAgent(),self.TestRunner.NetworkAgent=e.networkAgent(),self.TestRunner.OverlayAgent=e.overlayAgent(),self.TestRunner.PageAgent=e.pageAgent(),self.TestRunner.ProfilerAgent=e.profilerAgent(),self.TestRunner.RuntimeAgent=e.runtimeAgent(),self.TestRunner.TargetAgent=e.targetAgent(),self.TestRunner.networkManager=e.model(SDK.NetworkManager),self.TestRunner.securityOriginManager=e.model(SDK.SecurityOriginManager),self.TestRunner.storageKeyManager=e.model(SDK.StorageKeyManager),self.TestRunner.resourceTreeModel=e.model(SDK.ResourceTreeModel),self.TestRunner.debuggerModel=e.model(SDK.DebuggerModel),self.TestRunner.runtimeModel=e.model(SDK.RuntimeModel),self.TestRunner.domModel=e.model(SDK.DOMModel),self.TestRunner.domDebuggerModel=e.model(SDK.DOMDebuggerModel),self.TestRunner.cssModel=e.model(SDK.CSSModel),self.TestRunner.cpuProfilerModel=e.model(SDK.CPUProfilerModel),self.TestRunner.overlayModel=e.model(SDK.OverlayModel),self.TestRunner.serviceWorkerManager=e.model(SDK.ServiceWorkerManager),self.TestRunner.tracingManager=e.model(SDK.TracingManager),self.TestRunner.mainTarget=e}(e),F)return;F=!0,E(`\n <head>\n <base href="${j()}">\n </head>\n <body>\n </body>\n `).then((()=>U()))}}targetRemoved(e){}}SDK.targetManager.observeTargets(new W);const B=self.TestRunner;export{B as TestRunner,W as _TestObserver,U as _executeTestScript}; | |||
import*as e from"../../core/root/root.js";import*as n from"../../core/sdk/sdk.js";import*as t from"../../models/trace/trace.js";import"../../core/common/common.js";import*as r from"../../core/protocol_client/protocol_client.js";import*as o from"../../models/bindings/bindings.js";import*as s from"../../models/workspace/workspace.js";import*as i from"../../ui/components/code_highlighter/code_highlighter.js";import*as a from"../../ui/legacy/legacy.js";function u(){return!self.testRunner||Boolean(e.Runtime.Runtime.queryParam("debugFrontend"))}self.onerror=(e,n,t,r,o)=>{d("TEST ENDED IN ERROR: "+o.stack),g()},self.addEventListener("unhandledrejection",(e=>{d(`PROMISE FAILURE: ${e.reason.stack??e.reason}`),g()})),u()||(console.log=(...e)=>{d(`log: ${e}`)},console.error=(...e)=>{d(`error: ${e}`)},console.info=(...e)=>{d(`info: ${e}`)},console.assert=(e,...n)=>{e||d(`ASSERTION FAILURE: ${n.join(" ")}`)});let c=[],l=e=>{c.push(String(e))};function d(e){l(e)}let f=!1,m=()=>{f||(f=!0,function(){Array.prototype.forEach.call(document.documentElement.childNodes,(e=>e.remove()));const e=document.createElement("div");e.style&&(e.style.whiteSpace="pre",e.style.height="10px",e.style.overflow="hidden");document.documentElement.appendChild(e);for(let n=0;n<c.length;n++)e.appendChild(document.createTextNode(c[n])),e.appendChild(document.createElement("br"));c=[]}(),self.testRunner.notifyDone())};function g(){m()}function p(e,n){return function(){if(!e)return;const t=this;try{return e.apply(t,arguments)}catch(t){d("Exception while running: "+e+"\n"+(t.stack||t)),n?p(n)():g()}}}function T(e){return async function(){if(!e)return;const n=this;try{return await e.apply(n,arguments)}catch(n){d("Exception while running: "+e+"\n"+(n.stack||n)),g()}}}function R(e){function n(n){let t=0;for(;n&&n!==e;)"OL"!==n.nodeName||n.classList&&n.classList.contains("object-properties-section")||++t,n=n.parentNode;return Array(4*t+1).join(" ")}let t="",r=e,o=!1;for(;r.traverseNextNode(e);)if(r=r.traverseNextNode(e),r.nodeType===Node.TEXT_NODE&&r.parentNode?.nodeType!==Node.DOCUMENT_FRAGMENT_NODE)t+=r.nodeValue;else if("LI"===r.nodeName||"TR"===r.nodeName)o?o=!1:t+="\n"+n(r);else{if("STYLE"===r.nodeName){r=r.traverseNextNode(e);continue}r.classList&&r.classList.contains("object-properties-section")&&(o=!0)}return t}async function h(e,n){const t=await v(e);p(n)(t.result.value,t.exceptionDetails)}self.TestRunner=self.TestRunner||{};let y=0;async function v(n){const t=(new Error).stack.split("at "),o=e.Runtime.Runtime.queryParam("test"),s=t.reduce(((e,n)=>n.includes(o)?n:e),t[t.length-2]).trim().split("/"),i=s[s.length-1].slice(0,-1).split(":"),a=i[0],u=`test://evaluations/${y++}/`+a,c=parseInt(i[1],10);-1===(n="\n".repeat(c-1)+n).indexOf("sourceURL=")&&(n+=`//# sourceURL=${u}`);const l=await TestRunner.RuntimeAgent.invoke_evaluate({expression:n,objectGroup:"console"}),f=l[r.InspectorBackend.ProtocolError];return f?(d("Error: "+f),void g()):l}async function E(e,n){const t=await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console",userGesture:n});if(!t[r.InspectorBackend.ProtocolError])return t.result.value;d("Error: "+(t.exceptionDetails&&t.exceptionDetails.text||"exception from evaluateInPageAnonymously.")),g()}async function M(e){const n=await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console",includeCommandLineAPI:!1,awaitPromise:!0}),t=n[r.InspectorBackend.ProtocolError];if(!t&&!n.exceptionDetails)return n.result.value;let o="Error: ";t?o+=t:n.exceptionDetails&&(o+=n.exceptionDetails.text,n.exceptionDetails.exception&&(o+=" "+n.exceptionDetails.exception.description)),d(o),g()}function w(e){if(!e.includes("<base")){const n=/(<!DOCTYPE.*?>)/i,t=`<base href="${W()}">`;e=e.match(n)?e.replace(n,"$1"+t):t+e}return E(`document.write(\`${e=e.replace(/'/g,"\\'").replace(/\n/g,"\\n")}\`);document.close();`)}const A={formatAsTypeName:e=>"<"+typeof e+">",formatAsTypeNameOrNull:e=>null===e?"null":A.formatAsTypeName(e),formatAsRecentTime(e){if("object"!=typeof e||!(e instanceof Date))return A.formatAsTypeName(e);const n=Date.now()-e;return 0<=n&&n<18e5?"<plausible>":e},formatAsURL(e){if(!e)return e;const n=e.lastIndexOf("devtools/");return n<0?e:".../"+e.substr(n)},formatAsDescription:e=>e?'"'+e.replace(/^function [gs]et /,"function ")+'"':e};function x(e,n,t,r){t=t||"",d((r=r||t)+"{");const o=Object.keys(e);o.sort();for(let r=0;r<o.length;++r){const s=o[r];if(!e.hasOwnProperty(s))continue;const i=" "+t+s+" : ",a=e[s];if(n&&n[s]){const e=n[s];if("skip"!==e){d(i+(0,A[e])(a))}}else b(a,n," "+t,i)}d(t+"}")}function P(e,n,t,r){t=t||"",d((r=r||t)+"[");for(let r=0;r<e.length;++r)b(e[r],n,t+" ");d(t+"]")}function b(e,n,t,r){(r=r||t)&&r.length>80?d(r+"was skipped due to prefix length limit"):null===e?d(r+"null"):e&&e.constructor&&"Array"===e.constructor.name?P(e,n,t,r):"object"==typeof e?x(e,n,t,r):d("string"==typeof e?r+'"'+e+'"':r+e)}function S(e,n,t){return t=t||function(){return!0},new Promise((r=>{n.addEventListener(e,(function o(s){if(!t(s.data))return;n.removeEventListener(e,o),r(s.data)}))}))}function N(e){return e.executionContexts().length?Promise.resolve(e.executionContexts()[0]):e.once(n.RuntimeModel.Events.ExecutionContextCreated)}let k;function I(e,t){k=p(t),TestRunner.resourceTreeModel.addEventListener(n.ResourceTreeModel.Events.Load,L),E("window.location.replace('"+e+"')")}function L(){TestRunner.resourceTreeModel.removeEventListener(n.ResourceTreeModel.Events.Load,L),j()}function O(e){D(!1,void 0,e)}function D(e,t,r){k=p(r),TestRunner.resourceTreeModel.addEventListener(n.ResourceTreeModel.Events.Load,C),TestRunner.resourceTreeModel.reloadPage(e,t)}function C(){TestRunner.resourceTreeModel.removeEventListener(n.ResourceTreeModel.Events.Load,C),d("Page reloaded."),j()}async function j(){if(await N(TestRunner.runtimeModel),k){const e=k;k=void 0,e()}}function F(e,n,t){if(e===n)return;let r;throw r=t?"Failure ("+t+"):":"Failure:",new Error(r+" expected <"+e+"> found <"+n+">")}function W(n=""){const t=e.Runtime.Runtime.queryParam("inspected_test")||e.Runtime.Runtime.queryParam("test");return new URL(n,t+"/../").href}async function B(){const n=e.Runtime.Runtime.queryParam("test");if(u())return t=console.log,l=t,m=()=>console.log("Test completed"),void(self.test=async function(){await import(n)});var t;try{await import(n)}catch(e){d("TEST ENDED EARLY DUE TO UNCAUGHT ERROR:"),d(e&&e.stack||e),d("=== DO NOT COMMIT THIS INTO -expected.txt ==="),g()}}self.testRunner,TestRunner.StringOutputStream=class{constructor(e){this.callback=e,this.buffer=""}async open(e){return!0}async write(e){this.buffer+=e}async close(){this.callback(this.buffer)}},TestRunner.MockSetting=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}},TestRunner.formatters=A,TestRunner.completeTest=g,TestRunner.addResult=d,TestRunner.addResults=function(e){if(e)for(let n=0,t=e.length;n<t;++n)d(e[n])},TestRunner.runTests=function(e){!function n(){const t=e.shift();if(!t)return void g();d("\ntest: "+t.name);let r=t();r instanceof Promise||(r=Promise.resolve());r.then(n)}()},TestRunner.addSniffer=function(e,n,t,r){t=p(t);const o=e[n];if("function"!=typeof o)throw new Error("Cannot find method to override: "+n);e[n]=function(s){let i;try{i=o.apply(this,arguments)}finally{r||(e[n]=o)}try{Array.prototype.push.call(arguments,i),t.apply(this,arguments)}catch(e){throw new Error("Exception in overriden method '"+n+"': "+e)}return i}},TestRunner.addSnifferPromise=function(e,n){return new Promise((function(t,r){const o=e[n];"function"==typeof o?e[n]=function(s){let i;try{i=o.apply(this,arguments)}finally{e[n]=o}try{Array.prototype.push.call(arguments,i),t.apply(this,arguments)}catch(e){r("Exception in overridden method '"+n+"': "+e),g()}return i}:r("Cannot find method to override: "+n)}))},TestRunner.showPanel=function(e){return a.ViewManager.ViewManager.instance().showView(e)},TestRunner.createKeyEvent=function(e,n,t,r,o){return new KeyboardEvent("keydown",{key:e,bubbles:!0,cancelable:!0,ctrlKey:Boolean(n),altKey:Boolean(t),shiftKey:Boolean(r),metaKey:Boolean(o)})},TestRunner.safeWrap=p,TestRunner.textContentWithLineBreaks=R,TestRunner.textContentWithLineBreaksTrimmed=function(e){return R(e).replace(/\s{3,}/g," ")},TestRunner.textContentWithoutStyles=function(e){let n="",t=e;for(;t=t.traverseNextNode(e,"DEVTOOLS-CSS-LENGTH"===t.tagName||"DEVTOOLS-ICON"===t.tagName),t;)t.nodeType===Node.TEXT_NODE?n+=t.nodeValue:"STYLE"===t.nodeName&&(t=t.traverseNextNode(e));return n},TestRunner.evaluateInPagePromise=function(e){return new Promise((n=>h(e,n)))},TestRunner.callFunctionInPageAsync=function(e,n){return M(e+"("+(n=n||[]).map((e=>JSON.stringify(e))).join(",")+")")},TestRunner.evaluateInPageWithTimeout=function(e,n){E("setTimeout(unescape('"+escape(e)+"'), 1)",n)},TestRunner.evaluateFunctionInOverlay=function(e,n){const t='internals.evaluateInInspectorOverlay("(" + '+e+' + ")()")';TestRunner.runtimeModel.executionContexts()[0].evaluate({expression:t,objectGroup:"",includeCommandLineAPI:!1,silent:!1,returnByValue:!0,generatePreview:!1},!1,!1).then((e=>{n(e.object.value)}))},TestRunner.check=function(e,n){e||d("FAIL: "+n)},TestRunner.deprecatedRunAfterPendingDispatches=function(e){r.InspectorBackend.test.deprecatedRunAfterPendingDispatches(e)},TestRunner.loadHTML=w,TestRunner.addScriptTag=function(e){return M(`\n (function(){\n let script = document.createElement('script');\n script.src = '${e}';\n document.head.append(script);\n return new Promise(f => script.onload = f);\n })();\n `)},TestRunner.addStylesheetTag=function(e){return M(`\n (function(){\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = '${e}';\n link.onload = onload;\n document.head.append(link);\n let resolve;\n const promise = new Promise(r => resolve = r);\n function onload() {\n // TODO(chenwilliam): It shouldn't be necessary to force\n // style recalc here but some tests rely on it.\n window.getComputedStyle(document.body).color;\n resolve();\n }\n return promise;\n })();\n `)},TestRunner.addIframe=function(e,n={}){return n.id=n.id||"",n.name=n.name||"",M(`\n (function(){\n const iframe = document.createElement('iframe');\n iframe.src = '${e}';\n iframe.id = '${n.id}';\n iframe.name = '${n.name}';\n document.body.appendChild(iframe);\n return new Promise(f => iframe.onload = f);\n })();\n `)},TestRunner.markStep=function(e){d("\nRunning: "+e)},TestRunner.startDumpingProtocolMessages=function(){r.InspectorBackend.test.dumpProtocol=self.testRunner.logToStderr.bind(self.testRunner)},TestRunner.addScriptForFrame=function(e,n,t){n+="\n//# sourceURL="+e;const r=TestRunner.runtimeModel.executionContexts().find((e=>e.frameId===t.id));TestRunner.RuntimeAgent.evaluate(n,"console",!1,!1,r.id)},TestRunner.addObject=x,TestRunner.addArray=P,TestRunner.dumpDeepInnerHTML=function(e){!function e(n,t){const r=[];if(t.nodeType===Node.TEXT_NODE)return void(t.parentElement&&"STYLE"===t.parentElement.nodeName||d(t.nodeValue));r.push("<"+t.nodeName);const o=t.attributes;for(let e=0;o&&e<o.length;++e)r.push(o[e].name+"="+o[e].value);r.push(">"),d(n+r.join(" "));for(let r=t.firstChild;r;r=r.nextSibling)e(n+" ",r);t.shadowRoot&&e(n+" ",t.shadowRoot),d(n+"</"+t.nodeName+">")}("",e)},TestRunner.deepTextContent=function e(n){if(!n)return"";if(n.nodeType===Node.TEXT_NODE&&n.nodeValue)return n.parentElement&&"STYLE"===n.parentElement.nodeName?"":n.nodeValue;let t="";const r=n.childNodes;for(let n=0;n<r.length;++n)t+=e(r[n]);return n.shadowRoot&&(t+=e(n.shadowRoot)),t},TestRunner.dump=b,TestRunner.waitForEvent=S,TestRunner.waitForTarget=function(e){e=e||(e=>!0);for(const t of n.TargetManager.TargetManager.instance().targets())if(e(t))return Promise.resolve(t);return new Promise((t=>{const r={targetAdded:function(o){e(o)&&(n.TargetManager.TargetManager.instance().unobserveTargets(r),t(o))},targetRemoved:function(){}};n.TargetManager.TargetManager.instance().observeTargets(r)}))},TestRunner.waitForTargetRemoved=function(e){return new Promise((t=>{const r={targetRemoved:function(o){o===e&&(n.TargetManager.TargetManager.instance().unobserveTargets(r),t(o))},targetAdded:function(){}};n.TargetManager.TargetManager.instance().observeTargets(r)}))},TestRunner.waitForExecutionContext=N,TestRunner.waitForExecutionContextDestroyed=function(e){const t=e.runtimeModel;return-1===t.executionContexts().indexOf(e)?Promise.resolve():S(n.RuntimeModel.Events.ExecutionContextDestroyed,t,(n=>n===e))},TestRunner.assertGreaterOrEqual=function(e,n,t){e<n&&d("FAILED: "+(t?t+": ":"")+e+" < "+n)},TestRunner.navigate=I,TestRunner.navigatePromise=function(e){return new Promise((n=>I(e,n)))},TestRunner.hardReloadPage=function(e){D(!0,void 0,e)},TestRunner.reloadPage=O,TestRunner.reloadPageWithInjectedScript=function(e,n){D(!1,e,n)},TestRunner.reloadPagePromise=function(){return new Promise((e=>O(e)))},TestRunner.pageLoaded=C,TestRunner.waitForPageLoad=function(e){TestRunner.resourceTreeModel.addEventListener(n.ResourceTreeModel.Events.Load,(function t(){TestRunner.resourceTreeModel.removeEventListener(n.ResourceTreeModel.Events.Load,t),e()}))},TestRunner.runWhenPageLoads=function(e){const n=k;k=p((function(){n&&n(),e()}))},TestRunner.runTestSuite=function(e){const n=e.slice();!function e(){if(!n.length)return void g();const t=n.shift();d(""),d("Running: "+/function\s([^(]*)/.exec(t)[1]),p(t)(e)}()},TestRunner.assertEquals=F,TestRunner.assertTrue=function(e,n){F(!0,Boolean(e),n)},TestRunner.override=function(e,n,t,r){t=p(t);const o=e[n];if("function"!=typeof o)throw new Error("Cannot find method to override: "+n);return e[n]=function(s){try{return t.apply(this,arguments)}catch(e){throw new Error("Exception in overriden method '"+n+"': "+e)}finally{r||(e[n]=o)}},o},TestRunner.clearSpecificInfoFromStackFrames=function(e){let n=e.replace(/\(file:\/\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)");return n=n.replace(/\(http:\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)"),n=n.replace(/\(test:\/\/(?:[^)]+\)|[\w\/:-]+)/g,"(...)"),n=n.replace(/\(<anonymous>:[^)]+\)/g,"(...)"),n=n.replace(/VM\d+/g,"VM"),n.replace(/\s*at[^()]+\(native\)/g,"")},TestRunner.hideInspectorView=function(){a.InspectorView.InspectorView.instance().element.setAttribute("style","display:none !important")},TestRunner.mainFrame=function(){return TestRunner.resourceTreeModel.mainFrame},TestRunner.waitForUISourceCode=function(e,n){function t(t){return(!n||t.project().type()===n)&&(!(!n&&t.project().type()===s.Workspace.projectTypes.Service)&&!(e&&!t.url().endsWith(e)))}for(const n of s.Workspace.WorkspaceImpl.instance().uiSourceCodes())if(e&&t(n))return Promise.resolve(n);return S(s.Workspace.Events.UISourceCodeAdded,s.Workspace.WorkspaceImpl.instance(),t)},TestRunner.waitForUISourceCodeRemoved=function(e){s.Workspace.WorkspaceImpl.instance().once(s.Workspace.Events.UISourceCodeRemoved).then(e)},TestRunner.url=W,TestRunner.dumpSyntaxHighlight=function(e,n){const t=document.createElement("span");return t.textContent=e,i.CodeHighlighter.highlightNode(t,n).then((function(){const n=[];for(let e=0;e<t.childNodes.length;e++)t.childNodes[e].getAttribute?n.push(t.childNodes[e].getAttribute("class")):n.push("*");d(e+": "+n.join(", "))}))},TestRunner.evaluateInPageRemoteObject=async function(e){const n=await v(e);return TestRunner.runtimeModel.createRemoteObject(n.result)},TestRunner.evaluateInPage=h,TestRunner.evaluateInPageAnonymously=E,TestRunner.evaluateInPageAsync=M,TestRunner.deprecatedInitAsync=async function(e){await TestRunner.RuntimeAgent.invoke_evaluate({expression:e,objectGroup:"console"})},TestRunner.runAsyncTestSuite=async function(e){for(const n of e)d(""),d("Running: "+/function\s([^(]*)/.exec(n)[1]),await T(n)();g()},TestRunner.dumpInspectedPageElementText=async function(e){d(await M(`document.querySelector('${e}').innerText`))},TestRunner.waitForPendingLiveLocationUpdates=async function(){await o.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().pendingLiveLocationChangesPromise(),await o.CSSWorkspaceBinding.CSSWorkspaceBinding.instance().pendingLiveLocationChangesPromise()},TestRunner.findLineEndingIndexes=function(e){const n=function(e,n){const t=[];let r=e.indexOf(n);for(;-1!==r;)t.push(r),r=e.indexOf(n,r+n.length);return t}(e,"\n");return n.push(e.length),n},TestRunner.selectTextInTextNode=function(e,n,t){n=n||0,t=t||e.textContent.length,n<0&&(n=t+n);const r=e.getComponentSelection();r.removeAllRanges();const o=e.ownerDocument.createRange();return o.setStart(e,n),o.setEnd(e,t),r.addRange(o),e},TestRunner.isScrolledToBottom=a.UIUtils.isScrolledToBottom;let U=!1;class ${targetAdded(e){if("main"===e.id()&&"frame"===e.type()||"tab"===e.parentTarget()?.type()&&"frame"===e.type()&&!e.targetInfo()?.subtype?.length){if(function(e){self.TestRunner.BrowserAgent=e.browserAgent(),self.TestRunner.CSSAgent=e.cssAgent(),self.TestRunner.DeviceOrientationAgent=e.deviceOrientationAgent(),self.TestRunner.DOMAgent=e.domAgent(),self.TestRunner.DOMDebuggerAgent=e.domdebuggerAgent(),self.TestRunner.DebuggerAgent=e.debuggerAgent(),self.TestRunner.EmulationAgent=e.emulationAgent(),self.TestRunner.HeapProfilerAgent=e.heapProfilerAgent(),self.TestRunner.InputAgent=e.inputAgent(),self.TestRunner.InspectorAgent=e.inspectorAgent(),self.TestRunner.NetworkAgent=e.networkAgent(),self.TestRunner.OverlayAgent=e.overlayAgent(),self.TestRunner.PageAgent=e.pageAgent(),self.TestRunner.ProfilerAgent=e.profilerAgent(),self.TestRunner.RuntimeAgent=e.runtimeAgent(),self.TestRunner.TargetAgent=e.targetAgent(),self.TestRunner.networkManager=e.model(n.NetworkManager.NetworkManager),self.TestRunner.securityOriginManager=e.model(n.SecurityOriginManager.SecurityOriginManager),self.TestRunner.storageKeyManager=e.model(n.StorageKeyManager.StorageKeyManager),self.TestRunner.resourceTreeModel=e.model(n.ResourceTreeModel.ResourceTreeModel),self.TestRunner.debuggerModel=e.model(n.DebuggerModel.DebuggerModel),self.TestRunner.runtimeModel=e.model(n.RuntimeModel.RuntimeModel),self.TestRunner.domModel=e.model(n.DOMModel.DOMModel),self.TestRunner.domDebuggerModel=e.model(n.DOMDebuggerModel.DOMDebuggerModel),self.TestRunner.cssModel=e.model(n.CSSModel.CSSModel),self.TestRunner.cpuProfilerModel=e.model(n.CPUProfilerModel.CPUProfilerModel),self.TestRunner.overlayModel=e.model(n.OverlayModel.OverlayModel),self.TestRunner.serviceWorkerManager=e.model(n.ServiceWorkerManager.ServiceWorkerManager),self.TestRunner.tracingManager=e.model(t.TracingManager.TracingManager),self.TestRunner.mainTarget=e}(e),U)return;U=!0,w(`\n <head>\n <base href="${W()}">\n </head>\n <body>\n </body>\n `).then((()=>B()))}}targetRemoved(e){}}n.TargetManager.TargetManager.instance().observeTargets(new $);const V=self.TestRunner;export{V as TestRunner,$ as _TestObserver,B as _executeTestScript}; |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High library test
Summary: Pull Request resolved: facebook#47529 RuntimeExecutor, RuntimeScheduler, etc. can execute arbitrary c++ on the javascript thread. If that c++ throws a non-jsi::JSError, it will bypass the js error handler (and start tearing down the react instance 😱). Let's have the js error handler manage all exceptions raised while native is calling into js. This is more sane. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D64626610 fbshipit-source-id: 40132f24b4e2737ae3f055fbd09153111404e5bf
…47528) Summary: Pull Request resolved: facebook#47528 After the js pipeline fails to handle the error, reset the hasHandledFatalError var. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D65678387 fbshipit-source-id: ac7cd4724954ea78bf33542e208c5f5d3dba5383
Summary: Pull Request resolved: facebook#47531 When the activity is paused, or destroyed, we should disable the devsupportmanager. (This performs cleanup). When the activity is resumed, we should re-enable devsupportmanager. (This performs re-initialization). Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D65689053 fbshipit-source-id: 99de0906b8cdc84f56b4d334ac0eeecc7b436dd5
Summary: Fixes rn-tester bundled images example Before:  After:  ## Changelog: [IOS] [FIXED] - Fixes rn-tester bundled images examples Pull Request resolved: facebook#44482 Test Plan: N/L Reviewed By: dmytrorykun Differential Revision: D65757405 Pulled By: cipolleschi fbshipit-source-id: 29a82acacee58d803f2bfea93444adae6aee1b79
Summary: Resolve warning on ios build: ``` .../ios/Pods/Headers/Public/React-Core/React/RCTAppearance.h:16:60 A function declaration without a prototype is deprecated in all versions of C ``` ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [FIXED] - Resolve deprecated function prototype warning in RCTAppearance.h Pull Request resolved: facebook#47564 Test Plan: Jest Result (`yarn test`): ``` Test Suites: 234 passed, 234 total Tests: 2 skipped, 4899 passed, 4901 total Snapshots: 1687 passed, 1687 total Time: 46.387 s Ran all test suites. ``` Reviewed By: cipolleschi Differential Revision: D65816584 Pulled By: javache fbshipit-source-id: 212021c39dfde7e638752940e67a9f964d2194ab
…book#47553) Summary: Pull Request resolved: facebook#47553 As per title. Changelog: [Internal] Reviewed By: javache Differential Revision: D65598615 fbshipit-source-id: c4f0e137e3ff350b263f5ce11dd61b78a5be9894
Summary: Pull Request resolved: facebook#47028 This is a mostly internal diff enabling us to selectively enable Fusebox in release builds (experimental). Changelog: [Internal] Reviewed By: javache Differential Revision: D64110061 fbshipit-source-id: a5f5d59d7a512bb47603cf83fd60f2c2202c22ab
Summary: Pull Request resolved: facebook#47560 Reviewed By: elicwhite Differential Revision: D65790732 Pulled By: rickhanlonii fbshipit-source-id: 7156f85c7525cec31aa80fb0757d853d517bbef8
Summary: Pull Request resolved: facebook#47517 The `RCTThirdPartyLibraryComponentProvider` has been introduced to automate the component registration of third party libraries in the apps. However, it has some serious flaws: * It is generated in the React/Fabric folder, which means that it is generated in node_modules * It is generated when the user installs the components in the app, which means that we can't prebuild and redistribute React Native as a binary * it does not work with Frameworks and dynamic linking: in this scenarion, Fabric must build in isolation and if there are third party libraries involved, the lookup of the `xxxCls` function will fail This change removes the generation of the `RCTThirdPartyLibraryComponentProvider`. In the next diffs we will implement a different mechanism to register components ## Changelog [iOS][Changed] - Stop generating the RCTThirdPartyLibraryComponentProvider Reviewed By: dmytrorykun Differential Revision: D65601939 fbshipit-source-id: 9cc8c46102827d124b93b8aa6705b5e6014695c1
Summary: Pull Request resolved: facebook#47518 This change reintroduce the generation of the `RCTThirdPartyComponentProvider` but in the right place and with the right patterns. 1. We are generating it in the user space, not in the node_modules (fixes the circular dependency) 2. We are not using weak function signature that have to be implicitly linked to some symbols found during compilation The change needs to crawl the folder to retrieve the information it needs. We need to implement it this way not to be breaking with respect of the current implementation. The assumption is that components have a function in their `.mm` file with this shape: ```objc Class<RCTComponentViewProtocol> <componentName>Cls(void) { return <ComponentViewClass>.class; } ``` I verified on GH that all the libraries out there follow this pattern. A better approach will let library owner to specify the association of `componentName, componentClass` in the `codegenConfig`. We will implement that as the next step and we will support both for some versions for backward compatibility. ## Changelog [iOS][Changed] - Change how components automatically register Reviewed By: dmytrorykun Differential Revision: D65614347 fbshipit-source-id: a378b8bc31c1ab3d49552f2f6a4c86c3b578746b
…ok#47520) Summary: Pull Request resolved: facebook#47520 Right now, when a 3p library needs to register a component in the component system, we have to crawl the library to try and get the mappng, best effort. With this approach, we are enriching the `codegenConfig` property to allow library developers to define the mapping themselves. For example: ```json //... "codegenConfig": { //.. "ios": { "componentProvider": { "RNTMyNativeView": "RNTMyNativeViewComponentView" } } }, ``` means that the JS component `RNTMyNativeView` will be mapped to the `RNTMyNativeViewComponentView` class. This also work for local apps, and it warns the users about what libraries are using the deprecated approach, so they can open an issue or a PR to those libraries. ## Changelog: [iOS][Added] - Allow 3p developers to specify the association between components and classes in Fabric Reviewed By: dmytrorykun Differential Revision: D65666061 fbshipit-source-id: 692e753635873ff9260e131d2d18ed226b2378c2
…acebook#47571) Summary: Pull Request resolved: facebook#47571 As per title. Changelog: [Internal] Reviewed By: tdn120 Differential Revision: D65600851 fbshipit-source-id: cd88beca23f5d7b1036354457e67d0d530e62a95
…5187) Summary: in iOS on a scroll generated programatically, the `onMomentScrollEnd` is fired, though in case of android the same does not happen, this PR tries to implement the same behaviour for android as well, while diving through the code it seems we have two extra `onMomentumScrollEnd` events. Only one event should be fired. **iOS Behaviour on Programmatic Scroll** https://github.com/facebook/react-native/assets/72331432/fb8f16b1-4db6-49fe-83a1-a1c40bf49705 https://github.com/facebook/react-native/assets/72331432/9842f522-b616-4fb3-b197-40817f4aa9cb **Android Behaviour on Programmatic Scroll** https://github.com/facebook/react-native/assets/72331432/c24d3f06-4e2a-4bef-81af-d9227a3b1a4a https://github.com/facebook/react-native/assets/72331432/d4917843-730b-4bd7-90d9-33efb0f471a7 If closely observed we can see the `onMomentumScrollEnd` does not gets called in Android unlike to iOS. ## Changelog: [Android][Fixed] - Dispatch onMomentumScrollEnd after programmatic scrolling Pull Request resolved: facebook#45187 Test Plan: i have added updates to the FlatList example and ScrollViewSimple here is a ScreenRecording of `onMomentumScrollEnd` firing in android after the code changes https://github.com/facebook/react-native/assets/72331432/f036d1a5-6ebf-47ba-becd-4db98a406b15 https://github.com/facebook/react-native/assets/72331432/8c788c39-3392-4822-99c5-6e320398714b Reviewed By: javache Differential Revision: D65539724 Pulled By: Abbondanzo fbshipit-source-id: f3a5527ac5979f5ec0c6ae18d80fdc20c9c9c14b
…ebook#47426) Summary: This PR follows up on facebook#47182 and facebook#47348 by adding `force-cache`, the final missing option to align caching controls with the existing behavior on iOS. Local caching behavior remains unchanged: if a cached image is available locally, it will be returned; otherwise, a network request will be made. When an image request is sent over the network, the `force-cache` option sent from the sent fJS side will now use the `okhttp3.CacheControl.FORCE_CACHE` directive. ## Changelog: [ANDROID] [ADDED] - Image `force-cache` caching control option Pull Request resolved: facebook#47426 Test Plan: New example added to the RNTester under the cache policy examples. Then inspecting that the cache control is set correctly before sending it in the `okhttp3.Request` builder. ```kt FLog.w("ReactNative", "fetching uri: %s, with cacheControl: %s", uri, cacheControlBuilder.build().toString()) // fetching uri: https:...png?cacheBust=force-cache, with cacheControl: no-store, max-stale=2147483647, only-if-cached ``` This case was a bit more tricky to test in terms of e2e as it would involve some caching in the server as well, I'm open to suggestions to make this more complete. Reviewed By: javache Differential Revision: D65490360 Pulled By: Abbondanzo fbshipit-source-id: f807a9793f85caea39c59a370d057b9a1d450a78
Summary: Add changelog for 0.73.11 ## Changelog: [Internal] - Add Changelog for 0.73.11 Pull Request resolved: facebook#47574 Test Plan: N/A Reviewed By: lunaleaps Differential Revision: D65826153 Pulled By: cipolleschi fbshipit-source-id: 9eb3bf6afbb1203296dc416d9abdcf83efcb28bc
Summary: Pull Request resolved: facebook#47565 Changelog: [internal] We unified the feature flags for the event loop in facebook#47084, but we left the legacy flags defined for temporary backwards compatibility. We don't need that anymore, so we can clean them up. Reviewed By: fabriziocucci Differential Revision: D65606068 fbshipit-source-id: 403c278cef2afc8eddf07592d88cadc58765f660
Summary: Pull Request resolved: facebook#47579 BridgeReactContext is public only for testing. I'm annotating it with VisibileForTesting to make it explicit changelog: [internal] internal Reviewed By: javache Differential Revision: D65705093 fbshipit-source-id: d4d7c4195926e2d0397e805b4c49b0710a82a7eb
…ueueAndroid (facebook#47566) Summary: Pull Request resolved: facebook#47566 Changelog: [Android][Changed] TurboModules marked as requiring eager init will now be constructed on the mqt_native thread to increase concurrency in React Native init. Reviewed By: rshest Differential Revision: D65661887 fbshipit-source-id: c1863ea44771de5caedc2968a325abcc7022c792
) Summary: Pull Request resolved: facebook#47567 Changelog: [Android][Changed] Invocations to JS will now invoke their callbacks immediately if the instance is ready. Surface starts will not wait for the main thread to become available to dispatch the work in JS. Reviewed By: rshest Differential Revision: D65661888 fbshipit-source-id: c67802bd56fac6bc6c145b96d823274e2b97de69
…ing mode != max content (#1687)" (facebook#47581) Summary: X-link: facebook/yoga#1741 Pull Request resolved: facebook#47581 Reverting facebook/yoga#1687 as it appears to regress Yoga performance anywhere from 10-33%. ## Changelog [Internal] Reviewed By: rshest Differential Revision: D65863569 fbshipit-source-id: e6992e05dd59ba75548a5d633cb7f5c3fa99a6e4
…k#47441) Summary: Fixes facebook#29244, also mentioned in facebook#25009 As mentioned in the linked issues, the current return key label in the input accessory view is not localized. In the code, right now the texts are hardcoded (see: [RCTTextInputComponentView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L552) and [RCTBaseTextInputView.mm](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L694)). I could not find the historical reason for this, but doing some investigation there doesn't seem to be a way of getting the translated text into the code by using the existing props. (Ref: https://stackoverflow.com/a/58190342/5415299) The solution: adding a new property `inputAccessoryViewButtonLabel` which can be used to overwrite these defaults non-translated values. The property is optional to avoid breaking changes. The implementation works for both Fabric and Paper. ## Changelog: [IOS] [ADDED] - TextInput `inputAccessoryViewButtonLabel` prop Pull Request resolved: facebook#47441 Test Plan: A new example has been added under the `TextInput` examples in the RNTester. See below: <details> <summary>Video demonstrating how the new prop behaves</summary> https://github.com/user-attachments/assets/b15cb8b8-494a-4f41-b434-e33eeef5d267 </details> Reviewed By: cipolleschi Differential Revision: D65533493 Pulled By: javache fbshipit-source-id: d80bf501ba3e38bf3b09833170780df45a26bb61
Summary: Pull Request resolved: facebook#47585 We have two classes named ReactFontManager and during the Kotlin migration this got mixed up. Changelog: [Android][Fixed] Fixed crash in legacy ReactFontManager Reviewed By: fabriziocucci Differential Revision: D65877606 fbshipit-source-id: d9dc4f29045ad377adb216216334af5501c5546e
Summary: Pull Request resolved: facebook#47593 Changelog: [Internal] - Update `react-native/debugger-frontend` from ff343d8...b61aae3 Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](facebookexperimental/rn-chrome-devtools-frontend@ff343d8...b61aae3). Reviewed By: huntie Differential Revision: D65894096 fbshipit-source-id: e2fd4bff7d643fc56abde2ddea0ef5fab91d2b4d
…ge (facebook#47577) Summary: Pull Request resolved: facebook#47577 Changelog: [Android][Fixed] ensure setSelection in onAttachedToWindow is within text range Reviewed By: javache Differential Revision: D65824906 fbshipit-source-id: 3dc7d27bf4f9a10762f11fa4a0bcae8af13c7db7
Summary: This PR adds support for negative values in enums. Currently when we try to use an enum with negative value: ```ts enum MyEnum { ZERO = 0, POSITIVE = 1, NEGATIVE = -1, } export interface Spec extends TurboModule { useArg(arg: MyEnum): void; } export default TurboModuleRegistry.get<Spec>('Foo'); ``` It will fail: ``` Enum values can not be mixed. They all must be either blank, number, or string values. ``` This is because negative values are parsed as `UnaryExpressions` which have `-` operator in front and value as argument. With the new approach codegen properly generates enums with negative values. ## Changelog: [GENERAL] [ADDED] - Codegen: Support negative values in enums Pull Request resolved: facebook#47452 Test Plan: I've added tests to see if everything is working properly Reviewed By: vzaidman Differential Revision: D65887888 Pulled By: elicwhite fbshipit-source-id: edb25f663dc58afa68c69cb84a47cfc67fc1f7e7
…book#47551) Summary: Pull Request resolved: facebook#47551 ## Summary I'm working to get the main `react-native` package parsable by modern Flow tooling (both `flow-bundler`, `flow-api-translator`), and one blocker is legacy `module.exports` syntax. This diff updates files which are [synced to `react-native`](https://github.com/facebook/react-native/tree/main/packages/react-native/Libraries/Renderer/shims) from this repo. ## How did you test this change? Files were pasted into `react-native-github` under fbsource, where Flow validates ✅. DiffTrain build for [5c56b873efb300b4d1afc4ba6f16acf17e4e5800](facebook/react@5c56b87) Test Plan: Sandcastle tests Reviewed By: sammy-SC Differential Revision: D65672576 Pulled By: huntie fbshipit-source-id: 3d1f2eee0a4872d6a167cbc10e9f022e20f2bdc3
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The four fields below are mandatory. --> <!-- This fork of react-native provides React Native for macOS for the community. It also contains some changes that are required for usage internal to Microsoft. We are working on reducing the diff between Facebook's public version of react-native and our microsoft/react-native-macos fork. Long term, we want this fork to only contain macOS concerns and have the other iOS and Android concerns contributed upstream. If you are making a new change then one of the following should be done: - Consider if it is possible to achieve the desired behavior without making a change to microsoft/react-native-macos. Often a change can be made in a layer above in facebook/react-native instead. - Create a corresponding PR against [facebook/react-native](https://github.com/facebook/react-native) **Note:** Ideally you would wait for Facebook feedback before submitting to Microsoft, since we want to ensure that this fork doesn't deviate from upstream. --> ## Summary: Problem: Setting the accessible prop to false on RN Image does not remove the image from the accessibility tree on macOS. This is because the accessible prop is mapped to the accessibilityElement property but is set on NSImageView which has no effect. Instead, the accessibilityElement prop should be set on NSImageCell. Solution: Add a way to retrieve NSImageCell from NSImageView and map RN's accessible prop to the accessibilityElement property on it. ## Test Plan: Added a toggle to the 'Accessibility' test example in ImageExamples.js to test the value of the accessible prop. Hovered over the image with Accessibility Inspector and verified that the image is not found when accessible is false. Also verified by turning on VoiceOver and confirmed the image did not get read when the accessible prop is false. accessible prop is true: <img width="1279" alt="Screenshot 2025-01-07 at 11 19 22 AM" src="https://github.com/user-attachments/assets/5b5abe39-f671-4f63-8931-fb0b454ecb3a" /> accessible prop is false: <img width="1277" alt="Screenshot 2025-01-07 at 11 20 29 AM" src="https://github.com/user-attachments/assets/f5704a5f-1416-4559-89d1-b11d80b43b48" />
…r/focus on (#2325) Co-authored-by: Adam Gleitman <[email protected]>
* ci: Enable publishing of stable releases * ci: check publish_react_native_macos with a runtime condition * ci: add `--verbose` flag to `nx release` * chore: don't use `workspace:*` dependencies in react-native-macos * ci: rename `npm-publish` to `npm-publish-steps` * ci: move xcode-select into apple-tools-setup * ci: switch branch before publishing artifacts (#2317) * ci: split out `nx release publish` into a separate call * Update npm publish template path in YAML * back to workspace:* * downloadAllPlatforms --------- Co-authored-by: Tommy Nguyen <[email protected]>
…llKeyEvents` (#1615) * Remove `validKeysDown`, `validKeysUp`, `passThroughAllKeyEvents`
… grammer callbacks (#2299)
…2341) * Account for float dimensions when showing scroller * Use fabs() --------- Co-authored-by: Saad Najmi <[email protected]>
## Summary: Merge up to the 0.77-stable branch cut upstream. This one was fairly easy, the original set of diffs was resolved in half a day. The rest of the changes are in the commit" followup changes" that I'll rebase back into the merge commit before checking in ## Test Plan: CI should pass ## Notes Original set of merge conflicts: ``` both modified: .gitignore both modified: package.json both modified: packages/helloworld/package.json both modified: packages/react-native-test-library/package.json both modified: packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h both modified: packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm both modified: packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm both modified: packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js both modified: packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js both modified: packages/react-native/Libraries/Components/Touchable/TouchableBounce.js both modified: packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js both modified: packages/react-native/Libraries/Image/Image.ios.js both modified: packages/react-native/Libraries/Image/ImageProps.js both modified: packages/react-native/Libraries/Image/RCTResizeMode.h both modified: packages/react-native/Libraries/Lists/SectionListModern.js both modified: packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h both modified: packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.h both modified: packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap both modified: packages/react-native/React/CoreModules/RCTActionSheetManager.mm both modified: packages/react-native/React/CoreModules/RCTAppearance.h both modified: packages/react-native/React/CoreModules/RCTAppearance.mm both modified: packages/react-native/React/CoreModules/RCTDevLoadingView.mm both modified: packages/react-native/React/CoreModules/RCTDevMenu.mm both modified: packages/react-native/React/CoreModules/React-CoreModules.podspec both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm both modified: packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm both modified: packages/react-native/React/Modules/RCTUIManager.mm both modified: packages/react-native/React/Views/RCTBorderDrawing.h both modified: packages/react-native/React/Views/RCTBorderDrawing.m both modified: packages/react-native/React/Views/RCTView.m both modified: packages/react-native/React/Views/ScrollView/RCTScrollEvent.m both modified: packages/react-native/React/Views/ScrollView/RCTScrollView.h both modified: packages/react-native/React/Views/ScrollView/RCTScrollView.m both modified: packages/react-native/ReactCommon/react/renderer/components/textinput/TextInputEventEmitter.h both modified: packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTFontUtils.mm both modified: packages/react-native/index.js both modified: packages/react-native/package.json both modified: packages/react-native/scripts/codegen/generate-artifacts-executor.js both modified: packages/react-native/sdks/hermes-engine/hermes-engine.podspec both modified: packages/rn-tester/NativeComponentExample/ios/RNTMyLegacyNativeViewManager.mm both modified: packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewComponentView.mm both modified: packages/rn-tester/Podfile.lock both modified: packages/rn-tester/RNTester/AppDelegate.mm both modified: packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj both modified: packages/rn-tester/RNTesterUnitTests/RCTViewTests.m both modified: packages/rn-tester/js/components/ListExampleShared.js both modified: packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js both modified: packages/rn-tester/js/examples/Image/ImageExample.js both modified: packages/rn-tester/js/examples/Layout/LayoutEventsExample.js both modified: packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js both modified: packages/rn-tester/package.json both modified: packages/virtualized-lists/package.json both modified: scripts/releases-ci/publish-npm.js both modified: yarn.lock ```
* Revert accidental change to Platform.select in 0.77 merge * Add extra unit tests * nit: fix formatting --------- Co-authored-by: Adam Gleitman <[email protected]>
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )