906508832b
3 lines
13 KiB
JavaScript
3 lines
13 KiB
JavaScript
detect typo in metadata when linting
makes use of https://github.com/openstyles/usercss-meta/pull/78
|
var usercssMeta=function(e){"use strict";class n extends Error{constructor(e){super(e.message),delete e.message,this.name="ParseError",Object.assign(this,e)}}class t extends n{constructor(e,n){super({code:"missingChar",args:e,message:`Missing character: ${e.map((e=>`'${e}'`)).join(", ")}`,index:n})}}class a extends n{constructor(e){super({code:"EOF",message:"Unexpected end of file",index:e})}}const s=/<<<EOT([\s\S]+?)EOT;/y,l=/.*/y,r=/-?(\d+(\.\d+)?|\.\d+)([eE]-?\d+)?\s*/y,i=/\s*/y,o=/[^\S\n]*/y,u=/([\w-]+)\s*/y,d=/(`(?:\\`|[\s\S])*?`)/y,c=/((['"])(?:\\\2|[^\n])*?\2|\w+)/y,x=/[^"]*/y,p=/^v?\d+(\.\d+)*(?:-(\w[-\w]*(\.[-\w]+)*))?(?:\+(\w[-\w]*(\.[-\w]+)*))?$/,f={__proto__:null,null:null,true:!0,false:!1};function v(e){return e.replace(/\*\\\//g,"*/")}function y(e){const n=e[0];return n!==e[e.length-1]||'"'!==n&&"'"!==n&&"`"!==n?v(e):e.slice(1,-1).replace(new RegExp(`\\\\([${n}\\\\/bfnrt]|u[0-9a-fA-F]{4})`,"g"),(e=>e[1]===n?n:JSON.parse(`"${e}"`)))}function g(e){l.lastIndex=e.lastIndex,l.exec(e.text),e.lastIndex=l.lastIndex}function m(e){i.lastIndex=e.lastIndex,e.lastIndex+=i.exec(e.text)[0].length}function h(e){if(e.lastIndex>=e.text.length)throw new a(e.lastIndex);e.index=e.lastIndex,e.value=e.text[e.lastIndex],e.lastIndex++,m(e)}function w(e){const t=e.lastIndex;u.lastIndex=t;const a=u.exec(e.text);if(!a)throw new n({code:"invalidWord",message:"Invalid word",index:t});e.index=t,e.value=a[1],e.lastIndex+=a[0].length}function I(e){const n=e.lastIndex;try{$(e)}catch(e){throw e.message=`Invalid JSON: ${e.message}`,e}e.index=n}function b(e){const t=e.lastIndex;s.lastIndex=t;const a=s.exec(e.text);if(!a)throw new n({code:"missingEOT",message:"Missing EOT",index:t});e.index=t,e.lastIndex+=a[0].length,e.value=v(a[1].trim()),m(e)}function O(e){x.lastIndex=e.lastIndex;const n=x.exec(e.text);e.index=e.lastIndex,e.lastIndex=x.lastIndex,e.value=n[0].trim().replace(/\s+/g,"-")}function S(e,t=!1){const a=e.lastIndex,s="`"===e.text[a]?d:c;s.lastIndex=a;const l=s.exec(e.text);if(!l)throw new n({code:"invalidString",message:"Invalid string",index:a});e.index=a,e.lastIndex+=l[0].length,e.value=y(l[1]),t?function(e){o.lastIndex=e.lastIndex,e.lastIndex+=o.exec(e.text)[0].length}(e):m(e)}function $(e){const{text:a}=e;if("{"===a[e.lastIndex]){const n={};for(e.lastIndex++,m(e);"}"!==a[e.lastIndex];){S(e);const s=e.value;if(":"!==a[e.lastIndex])throw new t([":"],e.lastIndex);if(e.lastIndex++,m(e),$(e),n[s]=e.value,","===a[e.lastIndex])e.lastIndex++,m(e);else if("}"!==a[e.lastIndex])throw new t([",","}"],e.lastIndex)}e.lastIndex++,m(e),e.value=n}else if("["===a[e.lastIndex]){const n=[];for(e.lastIndex++,m(e);"]"!==a[e.lastIndex];)if($(e),n.push(e.value),","===a[e.lastIndex])e.lastIndex++,m(e);else if("]"!==a[e.lastIndex])throw new t([",","]"],e.lastIndex);e.lastIndex++,m(e),e.value=n}else if('"'===a[e.lastIndex]||"'"===a[e.lastIndex]||"`"===a[e.lastIndex])S(e);else if(/[-\d.]/.test(a[e.lastIndex]))k(e);else{if(w(e),!(e.value in f))throw new n({code:"unknownJSONLiteral",args:[e.value],message:`Unknown literal '${e.value}'`,index:e.index});e.value=f[e.value]}}function k(e){const t=e.lastIndex;r.lastIndex=t;const a=r.exec(e.text);if(!a)throw new n({code:"invalidNumber",message:"Invalid number",index:t});e.index=t,e.value=Number(a[0].trim()),e.lastIndex+=a[0].length}function R(e){l.lastIndex=e.lastIndex;const t=l.exec(e.text)[0].trim();if(!t)throw new n({code:"missingValue",message:"Missing value",index:l.lastIndex});e.index=e.lastIndex,e.value=y(t),e.lastIndex=l.lastIndex}function j(e){return p.test(e)}var E={__proto__:null,eatLine:g,eatWhitespace:m,parseChar:h,parseEOT:b,parseJSON:I,parseNumber:k,parseString:S,parseStringToEnd:R,parseStringUnquoted:O,parseWord:w,unquote:y,isValidVersion:j};const M=self.URL,U=new Set(["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","in","pt","pc","px","deg","grad","rad","turn","s","ms","Hz","kHz","dpi","dpcm","dppx","%"]),N={name:R,version:R,namespace:R,author:R,description:R,homepageURL:R,supportURL:R,updateURL:R,license:R,preprocessor:R},T={version:function(e){if(!j(e.va
|
||
//# sourceMappingURL=usercss-meta.min.js.map
|