simple-syntax-highlighter
Advanced tools
Comparing version 2.2.5 to 3.0.0
@@ -1,2 +0,3 @@ | ||
"use strict";const c=require("vue");const f=(e,t)=>{const n=e.__vccOpts||e;for(const[l,a]of t)n[l]=a;return n},s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)(?=.*\{})/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"<",">":">"})[t])},isColorDark(e){let t,n,l,a,o,i;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))l=parseInt(t[1])<=100,a=parseInt(t[2])<=100,o=parseInt(t[3])<=100,i=parseFloat(t[4])<.3;else if(n=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const r=n[1].length===3;l=parseInt(n[1][0])<=9,a=parseInt(n[1][r?1:2])<=9,o=parseInt(n[1][r?2:4])<=9}return(l&&a&&o||l&&a&&!o||!l&&a&&o)&&!i},createRegexPattern(){let e="";const t=[];for(const n in m[this.language]){const l=x[this.language][n]||1;for(let a=0;a<l;a++)t.push(n);e+=(e?"|":"")+m[this.language][n].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(l,a,o,i,r)=>`${a}<span class="attribute">${o}</span>`+(r?'<span class="punctuation">=</span>':"")+(r?`<span class="quote">${i||""}${r||""}${i||""}</span>`:"");let n=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const l=(e[1]||"").replace(/#[a-z\d-]+/g,a=>`<span class="id">${a}</span>`).replace(/\.[a-z\d-]+/g,a=>`<span class="class">${a}</span>`);return n&&(n='<span class="punctuation">(</span>'+n+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${l}${n}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+n+`<span class="punctuation">${e[3]}</span>`},syntaxHighlightContent(e){if(!this.knownLanguages.includes(this.language))return e;const[t,n]=this.createRegexPattern();return this.unhtmlize(e).replace(new RegExp(t,"gs"),(l,...a)=>{a=a.slice(0,a.length-2);let o;const i=this.language==="pug";let r=a.find((u,d)=>u&&(o=n[d])&&u);if(o==="quote")r=this.unhtmlize(r);else if(o==="comment")if(i){const[u,d,p]=a.slice(n.indexOf("comment"));r=`${u}${d}${this.unhtmlize(p)}`}else r=this.unhtmlize(r);else{if(o==="text"&&i)return`${a[0]}<span class="punctuation">|</span>${a[1]}<span class="text">${a[2]}</span>`;if(o==="text2"&&i){const[,,,u,d,p]=a,b=this.syntaxHighlightContent(d);return`${u}${b}<span class="punctuation">.</span> | ||
<span class="text">${p}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(o==="variable"&&r[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${r.substr(1)}</span>`}}let h="";return o==="color"&&this.language==="css"&&(h=` style="background-color: ${r};color: #${this.isColorDark(r)?"fff":"000"}"`),o&&`<span class="${o}"${h}>${r}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";this.slotTexts!==e&&(this.slotTexts=e,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(e){e.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const t=document.getElementById("clipboard-textarea");t.select(),t.setSelectionRange(0,99999),document.execCommand("copy"),t.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()}},v=["data-type","data-label","reactive"],w=["innerHTML"];function T(e,t,n,l,a,o){return c.openBlock(),c.createElementBlock("div",{class:c.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null,reactive:n.reactive&&o.checkSlots()||null},[n.copyButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...i)=>o.copyCode&&o.copyCode(...i))},[c.renderSlot(e.$slots,"copy-button",{},()=>[c.createTextVNode("Copy")])])):c.createCommentVNode("",!0),c.createTextVNode(),c.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,w)],10,v)}const k=f(E,[["render",T]]);module.exports=k; | ||
"use strict";const c=require("vue");const y=(t,e)=>{const n=t.__vccOpts||t;for(const[o,a]of e)n[o]=a;return n},i={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?(?:\*\/|$))/,doctype:/(<\!DOCTYPE.*?>)/,htmlTag:/<(?:([a-zA-Z][\w\d-]*)((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)(\s*\/?)|(\/?)([a-zA-Z][\w\d-]*))>/,htmlentity:/(&(?:[a-zA-Z]+|#x?\d+);)/,punctuation:new RegExp("(!==?|(?:[[\\](){}.:,+\\-?=!])+|(?<!&(?:[a-zA-Z]+|#x?\\d+));|\\|\\||<|>|&)"),number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},h={shell:{quote:i.quote,comment:/(#.*?)(?:\n|$)/,keyword:/\b(p?npm|yarn|i(?:nstall)?|run|audit|outdated|update|publish|whoami|cd|sudo|chmod|chown|ls|cat|vim?|scp|rm|mv|mkdir|ln|open|cwd|which|clear|curl|ping|systemctl|echo|export|open|bash|exit)\b/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},html:{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},"html-vue":{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:i.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,"inline-tag":/#\[([^\[\]]+)\]/},css:{comment:/(\/\*.+?(?:\*\/|$))/,quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)(?=.*\{})/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:i.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:i.htmlentity,punctuation:/([:,;{}@#()!]+)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/,error:/([:,;{}@#()!]+|<|>|&)/},json:{quote:/("(?:\\"|[^"])*")/,number:i.number,boolean:i.boolean,punctuation:/([[\](){}:,]+)/,error:/(&(:?lt|gt|amp);|(?!\s).)/},js:{quote:i.quote,comment:i.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:i.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document(?:Element)?|window|console|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|Proxy|WeakMap|WeakSet|Symbol|SyncManager|File(?:Reader)?|DataTransfer|DocumentFragment|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN|atob|btoa|getComputedStyle)(?=\W)/,htmlentity:i.htmlentity,punctuation:/(!==?|[[\]!(){}:;,+\-%*/?=]+|\.+(?![a-zA-Z])|\|\||<|>|&)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:i.quote,comment:i.comment,special:/(<\?(?:php)?|\?>|__(?:DIR|FILE|LINE|CLASS|METHOD|FUNCTION|NAMESPACE|TRAIT)__)/,punctuation:i.punctuation,number:i.number,boolean:i.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:i.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:i.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:i.boolean,keyword:/\b(\*|DECLARE|BEGIN|END|RETURNS|FUNCTION|CREATE|DATABASE|TABLE|VIEW|COLUMN|INDEX|GRANT|REVOKE|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|CHECK|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|THEN|NULL|EXISTS|UNIQUE|SELECT|UPDATE|DELETE|(?:INSERT|REPLACE)(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER|CROSS) |)JOIN|AS|ON|COUNT|AVG|SUM|MIN|MAX|CASE|TO|WHEN|BETWEEN|AND|OR|NOT|IN|LIKE|IS|CONCAT|SUBSTRING|CURRENT_(?:DATE|TIMESTAMP)|USING|HAVING?)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},b={xml:/(\s*)([a-zA-Z\d\-:]+)(?:=("|')(.*?)\3)?/g,html:/(\s*)([a-zA-Z-]+)(?:=("|')(.*?)\3)?/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},E={shell:{quote:2},xml:{quote:2,tag:5},html:{quote:2,tag:5},"html-vue":{quote:2,tag:5},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},m=t=>t.map(e=>{if(!e.children||typeof e.children=="string")return e.children||"";if(Array.isArray(e.children))return m(e.children);if(e.children.default)return m(e.children.default())}).join(""),x={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},tab:{type:[Boolean,String],default:" "},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1},editable:{type:Boolean,default:!0}},data:()=>({knownLanguages:Object.keys(h),content:"",slotTexts:""}),methods:{htmlize(t){return t.replace(/&(lt|gt|amp);/g,(e,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(t){return t.replace(/[<>]/g,e=>({"<":"<",">":">"})[e])},isColorDark(t){let e,n,o,a,s,r;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))o=parseInt(e[1])<=100,a=parseInt(e[2])<=100,s=parseInt(e[3])<=100,r=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const l=n[1].length===3;o=parseInt(n[1][0])<=9,a=parseInt(n[1][l?1:2])<=9,s=parseInt(n[1][l?2:4])<=9}return(o&&a&&s||o&&a&&!s||!o&&a&&s)&&!r},createRegexPattern(){let t="";const e=[];for(const n in h[this.language]){const o=E[this.language][n]||1;for(let a=0;a<o;a++)e.push(n);t+=(t?"|":"")+h[this.language][n].source}return[t,e]},syntaxHighlightHtmlTag(t){const e=(n,o,a,s,r)=>`${o}<span class="attribute">${a}</span>`+(s||r?'<span class="punctuation">=</span>':"")+(s||r?`<span class="quote">${s||""}${r||""}${s||""}</span>`:"");if(this.language==="pug"){let[n,o="",a="",s="",r="",l=""]=t;return o=o.replace(/#[a-z\d-]+/g,p=>`<span class="id">${p}</span>`).replace(/\.[a-z\d-]+/g,p=>`<span class="class">${p}</span>`),a&&(a=a.replace(b.pug,e),a='<span class="punctuation">(</span>'+a+'<span class="punctuation">)</span>'),l&&(l=this.highlightPugInlineTag(l)),`<span class="tag-name">${n}</span>${o}${a}`+(s?'<span class="punctuation">.</span>':"")+(r||"")+(l?`<span class="text">${l}</span>`:"")}else{const[n,o="",a="",s="",r]=t,l=o.replace(b[this.language],e);return`<span class="punctuation"><${s}</span><span class="tag-name">${n||r}</span>`+l+`<span class="punctuation">${a}></span>`}},highlightPugInlineTag(t){return t.replace(new RegExp(h.pug["inline-tag"],"gs"),(e,n)=>'<span class="inline-tag">#[</span>'+n.replace(new RegExp(h.pug.tag,"s"),(o,...a)=>(a=a.slice(0,a.length-2),this.syntaxHighlightHtmlTag(a)))+'<span class="inline-tag">]</span>')},highlightInPre(){if(this.knownLanguages.includes(this.language)){const t=this.getCaretPositionInPlainText();this.$refs.code.innerHTML=this.syntaxHighlightContent(this.$refs.code.innerText),this.reinjectCaret(this.$refs.code.childNodes,t)}},getCaretPositionInPlainText(){const t=window.getSelection();t.collapseToEnd();const e=new Range;return e.setStart(this.$refs.code,0),e.setEnd(t.extentNode,t.extentOffset),e.toString().length},reinjectCaret(t,e){var o,a;let n=0;for(const s of t){const r=((o=s.innerText)==null?void 0:o.length)||s.length;if(n+r>=e){s.childNodes.length>1?this.reinjectCaret(s.childNodes,e-n):document.getSelection().setPosition(((a=s.childNodes)==null?void 0:a[0])||s,e-n);break}n+=r}},onKeydown(t){switch(t.which){case 9:this.injectAtCaret(this.tab),t.preventDefault();break;case 13:this.injectAtCaret(` | ||
`),t.preventDefault();break}},injectAtCaret(t){const e=window.getSelection(),n=e.getRangeAt(0),o=document.createTextNode(t);n.insertNode(o),e.collapseToEnd()},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t.replace(/&/g,"&")).replace(new RegExp(e,"gs"),(o,...a)=>{a=a.slice(0,a.length-2);let s;const r=this.language==="pug";let l=a.find((u,d)=>u&&(s=n[d])&&u);if(["punctuation","quote","htmlentity"].includes(s))l=this.unhtmlize(l);else if(s==="comment")if(r){const[u,d,g]=a.slice(n.indexOf("comment"));l=`${u}${d}${this.unhtmlize(g)}`}else l=this.unhtmlize(l);else if(s==="text"&&r){let[u,d,g]=a;return g=this.highlightPugInlineTag(g),`${u}<span class="punctuation">|</span>${d}<span class="text">${g}</span>`}else if(s==="text2"&&r){const[,,,u,d,g]=a,f=this.syntaxHighlightContent(d);return`${u}${f}<span class="punctuation">.</span> | ||
<span class="text">${g}</span>`}else{if(s==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(s==="variable"&&l[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${l.substr(1)}</span>`}let p="";return s==="color"&&this.language==="css"&&(p=` style="background-color: ${l};color: #${this.isColorDark(l)?"fff":"000"}"`),s&&`<span class="${s}"${p}>${l}</span>`||""})},getSlotContent(){return this.$slots.default&&m(this.$slots.default())||""},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){const t=this.getSlotContent();this.$refs.code.innerText=t,this.$refs.code.innerHTML=this.syntaxHighlightContent(this.$refs.code.innerText)},beforeUpdate(){this.$refs.code.innerHTML=this.syntaxHighlightContent(this.getSlotContent())}},T=["data-type","data-label"],w=["contenteditable"],N={class:"ssh-pre__original"};function C(t,e,n,o,a,s){return c.openBlock(),c.createElementBlock("div",{class:c.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null},[n.copyButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:e[0]||(e[0]=(...r)=>s.copyCode&&s.copyCode(...r))},[c.renderSlot(t.$slots,"copy-button",{},()=>[c.createTextVNode("Copy")])])):c.createCommentVNode("",!0),c.createTextVNode(),c.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",contenteditable:n.editable?"true":"false",onKeydown:e[1]||(e[1]=r=>n.editable&&s.onKeydown(r)),onInput:e[2]||(e[2]=(...r)=>s.highlightInPre&&s.highlightInPre(...r))}," ",40,w),c.createTextVNode(),c.createElementVNode("div",N,[c.renderSlot(t.$slots,"default")])],10,T)}const A=y(x,[["render",C]]);module.exports=A; |
@@ -1,13 +0,14 @@ | ||
import { openBlock as h, createElementBlock as b, normalizeClass as x, renderSlot as E, createTextVNode as f, createCommentVNode as w, createElementVNode as v } from "vue"; | ||
const T = (t, e) => { | ||
import { openBlock as f, createElementBlock as b, normalizeClass as w, renderSlot as y, createTextVNode as h, createCommentVNode as C, createElementVNode as E } from "vue"; | ||
const N = (t, e) => { | ||
const n = t.__vccOpts || t; | ||
for (const [l, a] of e) | ||
n[l] = a; | ||
for (const [o, a] of e) | ||
n[o] = a; | ||
return n; | ||
}, s = { | ||
}, i = { | ||
quote: /("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/, | ||
comment: /(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/, | ||
htmlTag: /(<([^>])*>)/, | ||
htmlentity: /(&[a-zA-Z0-9#]+;)/, | ||
punctuation: /(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/, | ||
comment: /(\/\/.*?(?:\n|$)|\/\*.*?(?:\*\/|$))/, | ||
doctype: /(<\!DOCTYPE.*?>)/, | ||
htmlTag: /<(?:([a-zA-Z][\w\d-]*)((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)(\s*\/?)|(\/?)([a-zA-Z][\w\d-]*))>/, | ||
htmlentity: /(&(?:[a-zA-Z]+|#x?\d+);)/, | ||
punctuation: new RegExp("(!==?|(?:[[\\](){}.:,+\\-?=!])+|(?<!&(?:[a-zA-Z]+|#x?\\d+));|\\|\\||<|>|&)"), | ||
number: /(-?(?:\.\d+|\d+(?:\.\d+)?))/, | ||
@@ -17,27 +18,27 @@ boolean: /\b(true|false)\b/ | ||
shell: { | ||
quote: s.quote, | ||
quote: i.quote, | ||
comment: /(#.*?)(?:\n|$)/, | ||
keyword: /(?:^|\b)(npm|yarn|install|run)(?:\b|$)/, | ||
keyword: /\b(p?npm|yarn|i(?:nstall)?|run|audit|outdated|update|publish|whoami|cd|sudo|chmod|chown|ls|cat|vim?|scp|rm|mv|mkdir|ln|open|cwd|which|clear|curl|ping|systemctl|echo|export|open|bash|exit)\b/, | ||
param: /( --(?:save|save-dev))(?:\s|$)/ | ||
}, | ||
xml: { | ||
doctype: /(<\!DOCTYPE.*?>)/, | ||
quote: s.quote, | ||
comment: /(<!--.*?-->)/, | ||
htmlentity: s.htmlentity, | ||
tag: /(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/ | ||
doctype: i.doctype, | ||
quote: i.quote, | ||
comment: /(<!--.*?(?:-->|$))/, | ||
htmlentity: i.htmlentity, | ||
tag: i.htmlTag | ||
}, | ||
html: { | ||
doctype: /(DOCTYPE)/, | ||
quote: s.quote, | ||
comment: /(<!--.*?-->)/, | ||
htmlentity: s.htmlentity, | ||
tag: /(<\/?)([a-z]\w*)(.*?)(\/?>)/ | ||
doctype: i.doctype, | ||
quote: i.quote, | ||
comment: /(<!--.*?(?:-->|$))/, | ||
htmlentity: i.htmlentity, | ||
tag: i.htmlTag | ||
}, | ||
"html-vue": { | ||
doctype: /(DOCTYPE)/, | ||
quote: s.quote, | ||
comment: /(<!--.*?-->)/, | ||
htmlentity: s.htmlentity, | ||
tag: /(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/ | ||
doctype: i.doctype, | ||
quote: i.quote, | ||
comment: /(<!--.*?(?:-->|$))/, | ||
htmlentity: i.htmlentity, | ||
tag: i.htmlTag | ||
}, | ||
@@ -47,10 +48,10 @@ pug: { | ||
text2: /([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/, | ||
quote: s.quote, | ||
quote: i.quote, | ||
comment: /(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/, | ||
tag: /([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/, | ||
punctuation: /(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/ | ||
tag: /([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/, | ||
"inline-tag": /#\[([^\[\]]+)\]/ | ||
}, | ||
css: { | ||
quote: s.quote, | ||
comment: /(\/\*.*?\*\/)/, | ||
comment: /(\/\*.+?(?:\*\/|$))/, | ||
quote: /("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/, | ||
pseudo: /(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/, | ||
@@ -66,35 +67,36 @@ "selector keyword vendor": /(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/, | ||
"value keyword important": /( ?!important)/, | ||
number: s.number, | ||
number: i.number, | ||
color: /(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/, | ||
htmlentity: /(&.*?;)/, | ||
punctuation: /([:,;{}@#()!]+|<|>)/, | ||
htmlentity: i.htmlentity, | ||
punctuation: /([:,;{}@#()!]+)/, | ||
attribute: /([a-zA-Z-]+)(?=\s*:)/, | ||
unit: /(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/ | ||
unit: /(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/, | ||
error: /([:,;{}@#()!]+|<|>|&)/ | ||
}, | ||
json: { | ||
quote: s.quote, | ||
comment: s.comment, | ||
number: s.number, | ||
boolean: s.boolean, | ||
punctuation: /([[\](){}:;,-]+)/ | ||
quote: /("(?:\\"|[^"])*")/, | ||
number: i.number, | ||
boolean: i.boolean, | ||
punctuation: /([[\](){}:,]+)/, | ||
error: /(&(:?lt|gt|amp);|(?!\s).)/ | ||
}, | ||
js: { | ||
quote: s.quote, | ||
comment: s.comment, | ||
quote: i.quote, | ||
comment: i.comment, | ||
number: /\b(\d+(?:\.\d+)?|null)\b/, | ||
boolean: s.boolean, | ||
boolean: i.boolean, | ||
this: /\b(this)(?=\W)/, | ||
keyword: /\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/, | ||
punctuation: /(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/, | ||
keyword: /\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document(?:Element)?|window|console|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|Proxy|WeakMap|WeakSet|Symbol|SyncManager|File(?:Reader)?|DataTransfer|DocumentFragment|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN|atob|btoa|getComputedStyle)(?=\W)/, | ||
htmlentity: i.htmlentity, | ||
punctuation: /(!==?|[[\]!(){}:;,+\-%*/?=]+|\.+(?![a-zA-Z])|\|\||<|>|&)/, | ||
variable: /(\.?[a-zA-Z_][\w\d]*)/, | ||
htmlentity: /(&.*?;)/, | ||
"external-var": /(\$|jQuery|JSON)(?=\W|$)/ | ||
}, | ||
php: { | ||
quote: s.quote, | ||
comment: s.comment, | ||
special: /(<\?php|\?>|__(?:DIR|FILE|LINE)__)/, | ||
punctuation: s.punctuation, | ||
number: s.number, | ||
boolean: s.boolean, | ||
quote: i.quote, | ||
comment: i.comment, | ||
special: /(<\?(?:php)?|\?>|__(?:DIR|FILE|LINE|CLASS|METHOD|FUNCTION|NAMESPACE|TRAIT)__)/, | ||
punctuation: i.punctuation, | ||
number: i.number, | ||
boolean: i.boolean, | ||
variable: /(\$[\w\d_]+)/, | ||
@@ -104,22 +106,22 @@ keyword: /\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/ | ||
sql: { | ||
quote: s.quote, | ||
quote: i.quote, | ||
comment: /((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/, | ||
punctuation: s.punctuation, | ||
punctuation: i.punctuation, | ||
number: /\b(\d+(?:\.\d+)?|null)\b/, | ||
boolean: s.boolean, | ||
keyword: /\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/, | ||
boolean: i.boolean, | ||
keyword: /\b(\*|DECLARE|BEGIN|END|RETURNS|FUNCTION|CREATE|DATABASE|TABLE|VIEW|COLUMN|INDEX|GRANT|REVOKE|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|CHECK|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|THEN|NULL|EXISTS|UNIQUE|SELECT|UPDATE|DELETE|(?:INSERT|REPLACE)(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER|CROSS) |)JOIN|AS|ON|COUNT|AVG|SUM|MIN|MAX|CASE|TO|WHEN|BETWEEN|AND|OR|NOT|IN|LIKE|IS|CONCAT|SUBSTRING|CURRENT_(?:DATE|TIMESTAMP)|USING|HAVING?)(?=\W|$)/, | ||
"var-type": /\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/ | ||
} | ||
}, k = { | ||
xml: /(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g, | ||
html: /(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g, | ||
}, x = { | ||
xml: /(\s*)([a-zA-Z\d\-:]+)(?:=("|')(.*?)\3)?/g, | ||
html: /(\s*)([a-zA-Z-]+)(?:=("|')(.*?)\3)?/g, | ||
"html-vue": /(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g, | ||
pug: /(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g | ||
}, $ = { | ||
}, A = { | ||
shell: { quote: 2 }, | ||
xml: { quote: 2, tag: 4 }, | ||
html: { quote: 2, tag: 4 }, | ||
"html-vue": { quote: 2, tag: 4 }, | ||
xml: { quote: 2, tag: 5 }, | ||
html: { quote: 2, tag: 5 }, | ||
"html-vue": { quote: 2, tag: 5 }, | ||
pug: { text: 3, text2: 3, quote: 2, comment: 3, tag: 6 }, | ||
json: { quote: 2 }, | ||
json: {}, | ||
php: { quote: 2 }, | ||
@@ -136,3 +138,3 @@ sql: { quote: 2 }, | ||
return m(e.children.default()); | ||
}).join(""), A = { | ||
}).join(""), I = { | ||
name: "sshpre", | ||
@@ -142,5 +144,6 @@ props: { | ||
label: { type: [String, Boolean], default: !1 }, | ||
reactive: { type: Boolean, default: !1 }, | ||
tab: { type: [Boolean, String], default: " " }, | ||
dark: { type: Boolean, default: !1 }, | ||
copyButton: { type: Boolean, default: !1 } | ||
copyButton: { type: Boolean, default: !1 }, | ||
editable: { type: Boolean, default: !0 } | ||
}, | ||
@@ -160,10 +163,10 @@ data: () => ({ | ||
isColorDark(t) { | ||
let e, n, l, a, o, i; | ||
let e, n, o, a, s, r; | ||
if (e = t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/)) | ||
l = parseInt(e[1]) <= 100, a = parseInt(e[2]) <= 100, o = parseInt(e[3]) <= 100, i = parseFloat(e[4]) < 0.3; | ||
o = parseInt(e[1]) <= 100, a = parseInt(e[2]) <= 100, s = parseInt(e[3]) <= 100, r = parseFloat(e[4]) < 0.3; | ||
else if (n = t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)) { | ||
const r = n[1].length === 3; | ||
l = parseInt(n[1][0]) <= 9, a = parseInt(n[1][r ? 1 : 2]) <= 9, o = parseInt(n[1][r ? 2 : 4]) <= 9; | ||
const l = n[1].length === 3; | ||
o = parseInt(n[1][0]) <= 9, a = parseInt(n[1][l ? 1 : 2]) <= 9, s = parseInt(n[1][l ? 2 : 4]) <= 9; | ||
} | ||
return (l && a && o || l && a && !o || !l && a && o) && !i; | ||
return (o && a && s || o && a && !s || !o && a && s) && !r; | ||
}, | ||
@@ -174,4 +177,4 @@ createRegexPattern() { | ||
for (const n in p[this.language]) { | ||
const l = $[this.language][n] || 1; | ||
for (let a = 0; a < l; a++) | ||
const o = A[this.language][n] || 1; | ||
for (let a = 0; a < o; a++) | ||
e.push(n); | ||
@@ -183,10 +186,53 @@ t += (t ? "|" : "") + p[this.language][n].source; | ||
syntaxHighlightHtmlTag(t) { | ||
const e = (l, a, o, i, r) => `${a}<span class="attribute">${o}</span>` + (r ? '<span class="punctuation">=</span>' : "") + (r ? `<span class="quote">${i || ""}${r || ""}${i || ""}</span>` : ""); | ||
let n = (t[2] || "").replace(k[this.language], e); | ||
const e = (n, o, a, s, r) => `${o}<span class="attribute">${a}</span>` + (s || r ? '<span class="punctuation">=</span>' : "") + (s || r ? `<span class="quote">${s || ""}${r || ""}${s || ""}</span>` : ""); | ||
if (this.language === "pug") { | ||
const l = (t[1] || "").replace(/#[a-z\d-]+/g, (a) => `<span class="id">${a}</span>`).replace(/\.[a-z\d-]+/g, (a) => `<span class="class">${a}</span>`); | ||
return n && (n = '<span class="punctuation">(</span>' + n + '<span class="punctuation">)</span>'), `<span class="tag-name">${t[0] || ""}</span>${l}${n}` + (t[3] ? '<span class="punctuation">.</span>' : "") + (t[4] || "") + (t[5] ? `<span class="text">${t[5]}</span>` : ""); | ||
let [n, o = "", a = "", s = "", r = "", l = ""] = t; | ||
return o = o.replace(/#[a-z\d-]+/g, (g) => `<span class="id">${g}</span>`).replace(/\.[a-z\d-]+/g, (g) => `<span class="class">${g}</span>`), a && (a = a.replace(x.pug, e), a = '<span class="punctuation">(</span>' + a + '<span class="punctuation">)</span>'), l && (l = this.highlightPugInlineTag(l)), `<span class="tag-name">${n}</span>${o}${a}` + (s ? '<span class="punctuation">.</span>' : "") + (r || "") + (l ? `<span class="text">${l}</span>` : ""); | ||
} else { | ||
const [n, o = "", a = "", s = "", r] = t, l = o.replace(x[this.language], e); | ||
return `<span class="punctuation"><${s}</span><span class="tag-name">${n || r}</span>` + l + `<span class="punctuation">${a}></span>`; | ||
} | ||
return `<span class="punctuation">${t[0]}</span><span class="tag-name">${t[1]}</span>` + n + `<span class="punctuation">${t[3]}</span>`; | ||
}, | ||
highlightPugInlineTag(t) { | ||
return t.replace(new RegExp(p.pug["inline-tag"], "gs"), (e, n) => '<span class="inline-tag">#[</span>' + n.replace(new RegExp(p.pug.tag, "s"), (o, ...a) => (a = a.slice(0, a.length - 2), this.syntaxHighlightHtmlTag(a))) + '<span class="inline-tag">]</span>'); | ||
}, | ||
highlightInPre() { | ||
if (this.knownLanguages.includes(this.language)) { | ||
const t = this.getCaretPositionInPlainText(); | ||
this.$refs.code.innerHTML = this.syntaxHighlightContent(this.$refs.code.innerText), this.reinjectCaret(this.$refs.code.childNodes, t); | ||
} | ||
}, | ||
getCaretPositionInPlainText() { | ||
const t = window.getSelection(); | ||
t.collapseToEnd(); | ||
const e = new Range(); | ||
return e.setStart(this.$refs.code, 0), e.setEnd(t.extentNode, t.extentOffset), e.toString().length; | ||
}, | ||
reinjectCaret(t, e) { | ||
var o, a; | ||
let n = 0; | ||
for (const s of t) { | ||
const r = ((o = s.innerText) == null ? void 0 : o.length) || s.length; | ||
if (n + r >= e) { | ||
s.childNodes.length > 1 ? this.reinjectCaret(s.childNodes, e - n) : document.getSelection().setPosition(((a = s.childNodes) == null ? void 0 : a[0]) || s, e - n); | ||
break; | ||
} | ||
n += r; | ||
} | ||
}, | ||
onKeydown(t) { | ||
switch (t.which) { | ||
case 9: | ||
this.injectAtCaret(this.tab), t.preventDefault(); | ||
break; | ||
case 13: | ||
this.injectAtCaret(` | ||
`), t.preventDefault(); | ||
break; | ||
} | ||
}, | ||
injectAtCaret(t) { | ||
const e = window.getSelection(), n = e.getRangeAt(0), o = document.createTextNode(t); | ||
n.insertNode(o), e.collapseToEnd(); | ||
}, | ||
syntaxHighlightContent(t) { | ||
@@ -196,36 +242,34 @@ if (!this.knownLanguages.includes(this.language)) | ||
const [e, n] = this.createRegexPattern(); | ||
return this.unhtmlize(t).replace(new RegExp(e, "gs"), (l, ...a) => { | ||
return this.unhtmlize(t.replace(/&/g, "&")).replace(new RegExp(e, "gs"), (o, ...a) => { | ||
a = a.slice(0, a.length - 2); | ||
let o; | ||
const i = this.language === "pug"; | ||
let r = a.find((c, u) => c && (o = n[u]) && c); | ||
if (o === "quote") | ||
r = this.unhtmlize(r); | ||
else if (o === "comment") | ||
if (i) { | ||
let s; | ||
const r = this.language === "pug"; | ||
let l = a.find((c, u) => c && (s = n[u]) && c); | ||
if (["punctuation", "quote", "htmlentity"].includes(s)) | ||
l = this.unhtmlize(l); | ||
else if (s === "comment") | ||
if (r) { | ||
const [c, u, d] = a.slice(n.indexOf("comment")); | ||
r = `${c}${u}${this.unhtmlize(d)}`; | ||
l = `${c}${u}${this.unhtmlize(d)}`; | ||
} else | ||
r = this.unhtmlize(r); | ||
else { | ||
if (o === "text" && i) | ||
return `${a[0]}<span class="punctuation">|</span>${a[1]}<span class="text">${a[2]}</span>`; | ||
if (o === "text2" && i) { | ||
const [, , , c, u, d] = a, y = this.syntaxHighlightContent(u); | ||
return `${c}${y}<span class="punctuation">.</span> | ||
l = this.unhtmlize(l); | ||
else if (s === "text" && r) { | ||
let [c, u, d] = a; | ||
return d = this.highlightPugInlineTag(d), `${c}<span class="punctuation">|</span>${u}<span class="text">${d}</span>`; | ||
} else if (s === "text2" && r) { | ||
const [, , , c, u, d] = a, T = this.syntaxHighlightContent(u); | ||
return `${c}${T}<span class="punctuation">.</span> | ||
<span class="text">${d}</span>`; | ||
} else { | ||
if (o === "tag" && ["xml", "html", "html-vue", "pug"].includes(this.language)) | ||
return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag"))); | ||
if (o === "variable" && r[0] === "." && this.language === "js") | ||
return `<span class="punctuation">.</span><span class="obj-attr">${r.substr(1)}</span>`; | ||
} | ||
} else { | ||
if (s === "tag" && ["xml", "html", "html-vue", "pug"].includes(this.language)) | ||
return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag"))); | ||
if (s === "variable" && l[0] === "." && this.language === "js") | ||
return `<span class="punctuation">.</span><span class="obj-attr">${l.substr(1)}</span>`; | ||
} | ||
let g = ""; | ||
return o === "color" && this.language === "css" && (g = ` style="background-color: ${r};color: #${this.isColorDark(r) ? "fff" : "000"}"`), o && `<span class="${o}"${g}>${r}</span>` || ""; | ||
return s === "color" && this.language === "css" && (g = ` style="background-color: ${l};color: #${this.isColorDark(l) ? "fff" : "000"}"`), s && `<span class="${s}"${g}>${l}</span>` || ""; | ||
}); | ||
}, | ||
checkSlots() { | ||
const t = this.$slots.default && m(this.$slots.default()) || ""; | ||
this.slotTexts !== t && (this.slotTexts = t, this.content = this.syntaxHighlightContent(this.slotTexts)); | ||
getSlotContent() { | ||
return this.$slots.default && m(this.$slots.default()) || ""; | ||
}, | ||
@@ -242,32 +286,41 @@ copyCode(t) { | ||
mounted() { | ||
this.checkSlots(); | ||
const t = this.getSlotContent(); | ||
this.$refs.code.innerText = t, this.$refs.code.innerHTML = this.syntaxHighlightContent(this.$refs.code.innerText); | ||
}, | ||
beforeUpdate() { | ||
this.$refs.code.innerHTML = this.syntaxHighlightContent(this.getSlotContent()); | ||
} | ||
}, C = ["data-type", "data-label", "reactive"], _ = ["innerHTML"]; | ||
function q(t, e, n, l, a, o) { | ||
return h(), b("div", { | ||
class: x(["ssh-pre", { "ssh-pre--dark": n.dark }]), | ||
}, v = ["data-type", "data-label"], $ = ["contenteditable"], k = { class: "ssh-pre__original" }; | ||
function S(t, e, n, o, a, s) { | ||
return f(), b("div", { | ||
class: w(["ssh-pre", { "ssh-pre--dark": n.dark }]), | ||
"data-type": n.language, | ||
"data-label": n.label || null, | ||
reactive: n.reactive && o.checkSlots() || null | ||
"data-label": n.label || null | ||
}, [ | ||
n.copyButton ? (h(), b("button", { | ||
n.copyButton ? (f(), b("button", { | ||
key: 0, | ||
class: "ssh-pre__copy", | ||
onClick: e[0] || (e[0] = (...i) => o.copyCode && o.copyCode(...i)) | ||
onClick: e[0] || (e[0] = (...r) => s.copyCode && s.copyCode(...r)) | ||
}, [ | ||
E(t.$slots, "copy-button", {}, () => [ | ||
f("Copy") | ||
y(t.$slots, "copy-button", {}, () => [ | ||
h("Copy") | ||
]) | ||
])) : w("", !0), | ||
f(), | ||
v("pre", { | ||
])) : C("", !0), | ||
h(), | ||
E("pre", { | ||
ref: "code", | ||
class: "ssh-pre__content", | ||
innerHTML: t.content | ||
}, null, 8, _) | ||
], 10, C); | ||
contenteditable: n.editable ? "true" : "false", | ||
onKeydown: e[1] || (e[1] = (r) => n.editable && s.onKeydown(r)), | ||
onInput: e[2] || (e[2] = (...r) => s.highlightInPre && s.highlightInPre(...r)) | ||
}, " ", 40, $), | ||
h(), | ||
E("div", k, [ | ||
y(t.$slots, "default") | ||
]) | ||
], 10, v); | ||
} | ||
const N = /* @__PURE__ */ T(A, [["render", q]]); | ||
const _ = /* @__PURE__ */ N(I, [["render", S]]); | ||
export { | ||
N as default | ||
_ as default | ||
}; |
@@ -1,2 +0,3 @@ | ||
(function(r,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("vue")):typeof define=="function"&&define.amd?define(["vue"],p):(r=typeof globalThis<"u"?globalThis:r||self,r.sshpre=p(r.Vue))})(this,function(r){"use strict";const p="",b=(e,t)=>{const n=e.__vccOpts||e;for(const[l,a]of t)n[l]=a;return n},s={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?\*\/)/,htmlTag:/(<([^>])*>)/,htmlentity:/(&[a-zA-Z0-9#]+;)/,punctuation:/(!==?|(?:[[\](){}.:;,+\-?=!]|<|>)+|&&|\|\|)/,number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},m={shell:{quote:s.quote,comment:/(#.*?)(?:\n|$)/,keyword:/(?:^|\b)(npm|yarn|install|run)(?:\b|$)/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:/(<\!DOCTYPE.*?>)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z\-:]+)(.*?)(\/?>)/},html:{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-z]\w*)(.*?)(\/?>)/},"html-vue":{doctype:/(DOCTYPE)/,quote:s.quote,comment:/(<!--.*?-->)/,htmlentity:s.htmlentity,tag:/(<\/?)([a-zA-Z][\w\d-]*)((?:.|\s)*?)(\/?>)/},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:s.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\((.*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,punctuation:/(!==?|(?:[#[\]().,+\-?=!|]|<|>)+)/},css:{quote:s.quote,comment:/(\/\*.*?\*\/)/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)(?=.*\{})/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:s.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:/(&.*?;)/,punctuation:/([:,;{}@#()!]+|<|>)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/},json:{quote:s.quote,comment:s.comment,number:s.number,boolean:s.boolean,punctuation:/([[\](){}:;,-]+)/},js:{quote:s.quote,comment:s.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document|window|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN)(?=\W)/,punctuation:/(!==?|(?:[[\]!(){}:;,+\-%*/?=]|<|>)+|\.+(?![a-zA-Z])|&&|\|\|)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,htmlentity:/(&.*?;)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:s.quote,comment:s.comment,special:/(<\?php|\?>|__(?:DIR|FILE|LINE)__)/,punctuation:s.punctuation,number:s.number,boolean:s.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:s.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:s.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:s.boolean,keyword:/\b(\*|CREATE|DATABASE|TABLE|GRANT|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|NOT|NULL|EXISTS|SELECT|UPDATE|DELETE|INSERT(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER) |)JOIN|AS|ON|COUNT|CASE|TO|WHEN|BETWEEN|AND|OR|IN|LIKE|CONCAT|CURRENT_TIMESTAMP)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},y={xml:/(\s*)([a-zA-Z\d\-:]+)=("|')(.*?)\3/g,html:/(\s*)([a-zA-Z-]+)=("|')(.*?)\3/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},x={shell:{quote:2},xml:{quote:2,tag:4},html:{quote:2,tag:4},"html-vue":{quote:2,tag:4},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{quote:2},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},g=e=>e.map(t=>{if(!t.children||typeof t.children=="string")return t.children||"";if(Array.isArray(t.children))return g(t.children);if(t.children.default)return g(t.children.default())}).join(""),E={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},reactive:{type:Boolean,default:!1},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1}},data:()=>({knownLanguages:Object.keys(m),content:"",slotTexts:""}),methods:{htmlize(e){return e.replace(/&(lt|gt|amp);/g,(t,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(e){return e.replace(/[<>]/g,t=>({"<":"<",">":">"})[t])},isColorDark(e){let t,n,l,a,o,c;if(t=e.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))l=parseInt(t[1])<=100,a=parseInt(t[2])<=100,o=parseInt(t[3])<=100,c=parseFloat(t[4])<.3;else if(n=e.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const i=n[1].length===3;l=parseInt(n[1][0])<=9,a=parseInt(n[1][i?1:2])<=9,o=parseInt(n[1][i?2:4])<=9}return(l&&a&&o||l&&a&&!o||!l&&a&&o)&&!c},createRegexPattern(){let e="";const t=[];for(const n in m[this.language]){const l=x[this.language][n]||1;for(let a=0;a<l;a++)t.push(n);e+=(e?"|":"")+m[this.language][n].source}return[e,t]},syntaxHighlightHtmlTag(e){const t=(l,a,o,c,i)=>`${a}<span class="attribute">${o}</span>`+(i?'<span class="punctuation">=</span>':"")+(i?`<span class="quote">${c||""}${i||""}${c||""}</span>`:"");let n=(e[2]||"").replace(y[this.language],t);if(this.language==="pug"){const l=(e[1]||"").replace(/#[a-z\d-]+/g,a=>`<span class="id">${a}</span>`).replace(/\.[a-z\d-]+/g,a=>`<span class="class">${a}</span>`);return n&&(n='<span class="punctuation">(</span>'+n+'<span class="punctuation">)</span>'),`<span class="tag-name">${e[0]||""}</span>${l}${n}`+(e[3]?'<span class="punctuation">.</span>':"")+(e[4]||"")+(e[5]?`<span class="text">${e[5]}</span>`:"")}return`<span class="punctuation">${e[0]}</span><span class="tag-name">${e[1]}</span>`+n+`<span class="punctuation">${e[3]}</span>`},syntaxHighlightContent(e){if(!this.knownLanguages.includes(this.language))return e;const[t,n]=this.createRegexPattern();return this.unhtmlize(e).replace(new RegExp(t,"gs"),(l,...a)=>{a=a.slice(0,a.length-2);let o;const c=this.language==="pug";let i=a.find((u,d)=>u&&(o=n[d])&&u);if(o==="quote")i=this.unhtmlize(i);else if(o==="comment")if(c){const[u,d,h]=a.slice(n.indexOf("comment"));i=`${u}${d}${this.unhtmlize(h)}`}else i=this.unhtmlize(i);else{if(o==="text"&&c)return`${a[0]}<span class="punctuation">|</span>${a[1]}<span class="text">${a[2]}</span>`;if(o==="text2"&&c){const[,,,u,d,h]=a,v=this.syntaxHighlightContent(d);return`${u}${v}<span class="punctuation">.</span> | ||
<span class="text">${h}</span>`}else{if(o==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(o==="variable"&&i[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${i.substr(1)}</span>`}}let f="";return o==="color"&&this.language==="css"&&(f=` style="background-color: ${i};color: #${this.isColorDark(i)?"fff":"000"}"`),o&&`<span class="${o}"${f}>${i}</span>`||""})},checkSlots(){const e=this.$slots.default&&g(this.$slots.default())||"";this.slotTexts!==e&&(this.slotTexts=e,this.content=this.syntaxHighlightContent(this.slotTexts))},copyCode(e){e.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const t=document.getElementById("clipboard-textarea");t.select(),t.setSelectionRange(0,99999),document.execCommand("copy"),t.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){this.checkSlots()}},w=["data-type","data-label","reactive"],T=["innerHTML"];function k(e,t,n,l,a,o){return r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null,reactive:n.reactive&&o.checkSlots()||null},[n.copyButton?(r.openBlock(),r.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:t[0]||(t[0]=(...c)=>o.copyCode&&o.copyCode(...c))},[r.renderSlot(e.$slots,"copy-button",{},()=>[r.createTextVNode("Copy")])])):r.createCommentVNode("",!0),r.createTextVNode(),r.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",innerHTML:e.content},null,8,T)],10,w)}return b(E,[["render",k]])}); | ||
(function(c,m){typeof exports=="object"&&typeof module<"u"?module.exports=m(require("vue")):typeof define=="function"&&define.amd?define(["vue"],m):(c=typeof globalThis<"u"?globalThis:c||self,c.sshpre=m(c.Vue))})(this,function(c){"use strict";const m="",y=(t,e)=>{const n=t.__vccOpts||t;for(const[o,a]of e)n[o]=a;return n},i={quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,comment:/(\/\/.*?(?:\n|$)|\/\*.*?(?:\*\/|$))/,doctype:/(<\!DOCTYPE.*?>)/,htmlTag:/<(?:([a-zA-Z][\w\d-]*)((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)(\s*\/?)|(\/?)([a-zA-Z][\w\d-]*))>/,htmlentity:/(&(?:[a-zA-Z]+|#x?\d+);)/,punctuation:new RegExp("(!==?|(?:[[\\](){}.:,+\\-?=!])+|(?<!&(?:[a-zA-Z]+|#x?\\d+));|\\|\\||<|>|&)"),number:/(-?(?:\.\d+|\d+(?:\.\d+)?))/,boolean:/\b(true|false)\b/},h={shell:{quote:i.quote,comment:/(#.*?)(?:\n|$)/,keyword:/\b(p?npm|yarn|i(?:nstall)?|run|audit|outdated|update|publish|whoami|cd|sudo|chmod|chown|ls|cat|vim?|scp|rm|mv|mkdir|ln|open|cwd|which|clear|curl|ping|systemctl|echo|export|open|bash|exit)\b/,param:/( --(?:save|save-dev))(?:\s|$)/},xml:{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},html:{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},"html-vue":{doctype:i.doctype,quote:i.quote,comment:/(<!--.*?(?:-->|$))/,htmlentity:i.htmlentity,tag:i.htmlTag},pug:{text:/((?:^|\n)[ \t]*|^)\|([ \t]*)([^\n]+(?=\s*(?:\n|$)))/,text2:/([ \t]*)([.#\-\w\d]+(?:\([^)]*\))*)\.\n((?:\n+(?=\4[ \t]+)|(?=\4[ \t]+).+?(?:\n|$)*?)*)(?=\s*(?:\n|$))/,quote:i.quote,comment:/(^|\n)([ \t]*|^)(\/\/-[ \t]*(?:[^\n]*?(?:\n\10[ \t]+[^\n]*)+|[^\n]+(?=\n|$)))/,tag:/([a-zA-Z][\w\d-]*|)([.#][a-zA-Z][-.\w\d]*|)\b(?:\(((?:[\w\d\- ]+=(?:"[^"]*"|'[^']*'))*|(?:(?!&(?:lt|amp);).)*?)\))?(\.?)([ \t]*)([^\n]+)?(?=\n|$)/,"inline-tag":/#\[([^\[\]]+)\]/},css:{comment:/(\/\*.+?(?:\*\/|$))/,quote:/("(?:\\"|[^"])*")|('(?:\\'|[^'])*')/,pseudo:/(:(?:hover|active|focus|visited|not|before|after|(?:first|last|nth)-child))/,"selector keyword vendor":/(@-(?:moz|o|webkit|ms)-(?=keyframes\s))/,"selector keyword":/((?:@(?:import|media|font-face|keyframes)|screen|print|and)(?=[\s({])|keyframes|\s(?:ul|ol|li|table|div|pre|p|a|img|br|hr|h[1-6]|em|strong|span|html|body|iframe|video|audio|input|button|form|label|fieldset|small|abbr|i|dd|dt)\b)(?=.*\{})/,variable:/(--[a-zA-Z0-9\-]+)/,selector:/((?:[.#-\w*+ >:,[\]="~\n]|>)+)(?=\s*\{)/,"attribute keyword vendor":/(-(?:moz|o|webkit|ms)-(?=transform|transition|user-select|tap-highlight-color|animation|background-size|box-shadow))/,"attribute keyword":/\b(content|float|display|position|top|left|right|bottom|(?:(?:max|min)-)?width|(?:(?:max|min|line)-)?height|font(?:-(?:family|style|size|weight|variant|stretch))?|vertical-align|color|opacity|visibility|z-index|pointer-events|user-select|transform(?:-(?:origin|style|delay|duration|property|timing-function))?|transition(?:-(?:delay|duration))?|animation(?:-(?:name|delay|duration|direction|fill-mode))?|backface-visibility|backdrop-filter|background(?:-(?:color|position|image|repeat|size|attachment|origin|clip|blend-mode))?|(?:padding|margin|border)(?:-(?:top|left|right|bottom))?|border(?:-(?:radius|color|width|style|spacing))|white-space|text-(?:align|transform|decoration|shadow|indent)|overflow(?:-(?:x|y))?|(?:letter|word)-spacing|word-break|box-(?:sizing|shadow)|stroke(?:-(?:width|opacity|dasharray|dashoffset|linecap|linejoin))?|fill|speak|outline|user-select|cursor|flex(?:-(?:direction|flow|grow|shrink|basis|wrap))?|(?:justify|align)-(?:content|self|items))(?=\s*:)/,"value keyword vendor":/(-(?:moz|o|webkit|ms)-(?=linear-gradient))/,"value keyword":/\b(inherit|initial|normal|none|unset|auto|inline(?:-(?:block|flex))?|block|flex|absolute|relative|static|fixed|sticky|hidden|visible|top|left|right|bottom|center|middle|baseline|solid|dotted|dashed|line-through|(?:over|under)line|wavy|double|(?:pre-|no)?wrap|pre|break-word|(?:upper|lower)case|capitalize|italic|bold|attr\(.*?\)|linear|ease(?:-in)?(?:-out)?|all|infinite|cubic-bezier|(?:translate|rotate)(?:[X-Z]|3d)?|skew[XY]?|scale|(?:no-)?repeat|repeat(?:-x|-y)|contain|cover|url|(?:repeating-)?(?:linear|radial)-gradient|inset|pointer|(?:flex-)?(?:start|end)|space-(?:between|evenly|around)|stretch|revert|row(?:-reverse)?|column(?:-reverse)?)(?=\s*[,;}(]|\s+[\da-z!])/,"value keyword important":/( ?!important)/,number:i.number,color:/(transparent|#(?:[\da-fA-F]{6}|[\da-fA-F]{3})|rgba?\([\d., ]*\))/,htmlentity:i.htmlentity,punctuation:/([:,;{}@#()!]+)/,attribute:/([a-zA-Z-]+)(?=\s*:)/,unit:/(px|pt|cm|%|r?em|m?s|deg|vh|vw|vmin|vmax)(?=(?:\s*[;,{}})]|\s+[-\da-z#]))/,error:/([:,;{}@#()!]+|<|>|&)/},json:{quote:/("(?:\\"|[^"])*")/,number:i.number,boolean:i.boolean,punctuation:/([[\](){}:,]+)/,error:/(&(:?lt|gt|amp);|(?!\s).)/},js:{quote:i.quote,comment:i.comment,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:i.boolean,this:/\b(this)(?=\W)/,keyword:/\b(new|getElementsBy(?:Tag|Class|)Name|getElementById|querySelector|querySelectorAll|arguments|if|else|do|return|case|default|(?:f|F)unction|typeof|instanceof|undefined|document(?:Element)?|window|console|while|for|forEach|switch|in|break|continue|delete|length|var|let|const|export|import|as|require|from|Class|constructor|Number|Boolean|String|Array|Object|RegExp|Integer|Date|Promise|Proxy|WeakMap|WeakSet|Symbol|SyncManager|File(?:Reader)?|DataTransfer|DocumentFragment|async|await|(?:clear|set)(?:Timeout|Interval)|parse(?:Int|Float)|Math(?=\.)|isNaN|atob|btoa|getComputedStyle)(?=\W)/,htmlentity:i.htmlentity,punctuation:/(!==?|[[\]!(){}:;,+\-%*/?=]+|\.+(?![a-zA-Z])|\|\||<|>|&)/,variable:/(\.?[a-zA-Z_][\w\d]*)/,"external-var":/(\$|jQuery|JSON)(?=\W|$)/},php:{quote:i.quote,comment:i.comment,special:/(<\?(?:php)?|\?>|__(?:DIR|FILE|LINE|CLASS|METHOD|FUNCTION|NAMESPACE|TRAIT)__)/,punctuation:i.punctuation,number:i.number,boolean:i.boolean,variable:/(\$[\w\d_]+)/,keyword:/\b(define|echo|die|exit|print_r|var_dump|if|else|elseif|do|return|case|default|function|\$this|while|foreach|for|switch|in|break|continue|empty|isset|unset|parse_ini_file|session_(?:start|destroy|id)|header|json_(?:encode|decode)|error_log|(require|include)(:?_once)?|try|throw|new|Exception|catch|finally|preg_(?:match|replace)|list|strlen|substr|str_replace|array_(?:keys|values))(?=\W|$)/},sql:{quote:i.quote,comment:/((?:\-\-|#)\s.*?(?:\n|$)|\/\*.*?\*\/)/,punctuation:i.punctuation,number:/\b(\d+(?:\.\d+)?|null)\b/,boolean:i.boolean,keyword:/\b(\*|DECLARE|BEGIN|END|RETURNS|FUNCTION|CREATE|DATABASE|TABLE|VIEW|COLUMN|INDEX|GRANT|REVOKE|ALL|PRIVILEGES|IDENTIFIED|FLUSH|ALTER|MODIFY|DROP|TRUNCATE|CONSTRAINT|ADD|CHECK|(?:(?:PRIMARY|FOREIGN|UNIQUE) )?KEY|REFERENCES|AUTO_INCREMENT|COMMENT|DEFAULT|UNSIGNED|CHARSET|COLLATE|CHARACTER|ENGINE|SQL_MODE|USE|IF|THEN|NULL|EXISTS|UNIQUE|SELECT|UPDATE|DELETE|(?:INSERT|REPLACE)(?: INTO)?|VALUES|SET|FROM|WHERE|(?:ORDER|GROUP) BY|LIMIT|(?:(?:LEFT|RIGHT|INNER|OUTER|CROSS) |)JOIN|AS|ON|COUNT|AVG|SUM|MIN|MAX|CASE|TO|WHEN|BETWEEN|AND|OR|NOT|IN|LIKE|IS|CONCAT|SUBSTRING|CURRENT_(?:DATE|TIMESTAMP)|USING|HAVING?)(?=\W|$)/,"var-type":/\b((?:var)?char|(?:tiny|small|medium|big)?int|decimal|float|double|real|bit|boolean|date(?:time)?|time(?:stamp)?|year|(?:tiny|medium|long)?(?:text|blob)|enum)\b/}},b={xml:/(\s*)([a-zA-Z\d\-:]+)(?:=("|')(.*?)\3)?/g,html:/(\s*)([a-zA-Z-]+)(?:=("|')(.*?)\3)?/g,"html-vue":/(\s*)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g,pug:/(\s*|,)([@:#]?[a-zA-Z\d-]+)(?:(?:=("|')(.*?)\3)|)/g},E={shell:{quote:2},xml:{quote:2,tag:5},html:{quote:2,tag:5},"html-vue":{quote:2,tag:5},pug:{text:3,text2:3,quote:2,comment:3,tag:6},json:{},php:{quote:2},sql:{quote:2},css:{quote:2},js:{quote:2}},f=t=>t.map(e=>{if(!e.children||typeof e.children=="string")return e.children||"";if(Array.isArray(e.children))return f(e.children);if(e.children.default)return f(e.children.default())}).join(""),x={name:"sshpre",props:{language:{type:String,default:""},label:{type:[String,Boolean],default:!1},tab:{type:[Boolean,String],default:" "},dark:{type:Boolean,default:!1},copyButton:{type:Boolean,default:!1},editable:{type:Boolean,default:!0}},data:()=>({knownLanguages:Object.keys(h),content:"",slotTexts:""}),methods:{htmlize(t){return t.replace(/&(lt|gt|amp);/g,(e,n)=>({lt:"<",gt:">",amp:"&"})[n])},unhtmlize(t){return t.replace(/[<>]/g,e=>({"<":"<",">":">"})[e])},isColorDark(t){let e,n,o,a,s,r;if(e=t.match(/rgba?\((.*),\s*(.*),\s*(.*?)(?:,\s*([^)]*))\)/))o=parseInt(e[1])<=100,a=parseInt(e[2])<=100,s=parseInt(e[3])<=100,r=parseFloat(e[4])<.3;else if(n=t.match(/#([\da-f]{3}(?:[\da-f]{3})?)/)){const l=n[1].length===3;o=parseInt(n[1][0])<=9,a=parseInt(n[1][l?1:2])<=9,s=parseInt(n[1][l?2:4])<=9}return(o&&a&&s||o&&a&&!s||!o&&a&&s)&&!r},createRegexPattern(){let t="";const e=[];for(const n in h[this.language]){const o=E[this.language][n]||1;for(let a=0;a<o;a++)e.push(n);t+=(t?"|":"")+h[this.language][n].source}return[t,e]},syntaxHighlightHtmlTag(t){const e=(n,o,a,s,r)=>`${o}<span class="attribute">${a}</span>`+(s||r?'<span class="punctuation">=</span>':"")+(s||r?`<span class="quote">${s||""}${r||""}${s||""}</span>`:"");if(this.language==="pug"){let[n,o="",a="",s="",r="",l=""]=t;return o=o.replace(/#[a-z\d-]+/g,g=>`<span class="id">${g}</span>`).replace(/\.[a-z\d-]+/g,g=>`<span class="class">${g}</span>`),a&&(a=a.replace(b.pug,e),a='<span class="punctuation">(</span>'+a+'<span class="punctuation">)</span>'),l&&(l=this.highlightPugInlineTag(l)),`<span class="tag-name">${n}</span>${o}${a}`+(s?'<span class="punctuation">.</span>':"")+(r||"")+(l?`<span class="text">${l}</span>`:"")}else{const[n,o="",a="",s="",r]=t,l=o.replace(b[this.language],e);return`<span class="punctuation"><${s}</span><span class="tag-name">${n||r}</span>`+l+`<span class="punctuation">${a}></span>`}},highlightPugInlineTag(t){return t.replace(new RegExp(h.pug["inline-tag"],"gs"),(e,n)=>'<span class="inline-tag">#[</span>'+n.replace(new RegExp(h.pug.tag,"s"),(o,...a)=>(a=a.slice(0,a.length-2),this.syntaxHighlightHtmlTag(a)))+'<span class="inline-tag">]</span>')},highlightInPre(){if(this.knownLanguages.includes(this.language)){const t=this.getCaretPositionInPlainText();this.$refs.code.innerHTML=this.syntaxHighlightContent(this.$refs.code.innerText),this.reinjectCaret(this.$refs.code.childNodes,t)}},getCaretPositionInPlainText(){const t=window.getSelection();t.collapseToEnd();const e=new Range;return e.setStart(this.$refs.code,0),e.setEnd(t.extentNode,t.extentOffset),e.toString().length},reinjectCaret(t,e){var o,a;let n=0;for(const s of t){const r=((o=s.innerText)==null?void 0:o.length)||s.length;if(n+r>=e){s.childNodes.length>1?this.reinjectCaret(s.childNodes,e-n):document.getSelection().setPosition(((a=s.childNodes)==null?void 0:a[0])||s,e-n);break}n+=r}},onKeydown(t){switch(t.which){case 9:this.injectAtCaret(this.tab),t.preventDefault();break;case 13:this.injectAtCaret(` | ||
`),t.preventDefault();break}},injectAtCaret(t){const e=window.getSelection(),n=e.getRangeAt(0),o=document.createTextNode(t);n.insertNode(o),e.collapseToEnd()},syntaxHighlightContent(t){if(!this.knownLanguages.includes(this.language))return t;const[e,n]=this.createRegexPattern();return this.unhtmlize(t.replace(/&/g,"&")).replace(new RegExp(e,"gs"),(o,...a)=>{a=a.slice(0,a.length-2);let s;const r=this.language==="pug";let l=a.find((d,u)=>d&&(s=n[u])&&d);if(["punctuation","quote","htmlentity"].includes(s))l=this.unhtmlize(l);else if(s==="comment")if(r){const[d,u,p]=a.slice(n.indexOf("comment"));l=`${d}${u}${this.unhtmlize(p)}`}else l=this.unhtmlize(l);else if(s==="text"&&r){let[d,u,p]=a;return p=this.highlightPugInlineTag(p),`${d}<span class="punctuation">|</span>${u}<span class="text">${p}</span>`}else if(s==="text2"&&r){const[,,,d,u,p]=a,A=this.syntaxHighlightContent(u);return`${d}${A}<span class="punctuation">.</span> | ||
<span class="text">${p}</span>`}else{if(s==="tag"&&["xml","html","html-vue","pug"].includes(this.language))return this.syntaxHighlightHtmlTag(a.slice(n.indexOf("tag")));if(s==="variable"&&l[0]==="."&&this.language==="js")return`<span class="punctuation">.</span><span class="obj-attr">${l.substr(1)}</span>`}let g="";return s==="color"&&this.language==="css"&&(g=` style="background-color: ${l};color: #${this.isColorDark(l)?"fff":"000"}"`),s&&`<span class="${s}"${g}>${l}</span>`||""})},getSlotContent(){return this.$slots.default&&f(this.$slots.default())||""},copyCode(t){t.target.insertAdjacentHTML("afterend",`<textarea id="clipboard-textarea">${this.$refs.code.innerText}</textarea>`);const e=document.getElementById("clipboard-textarea");e.select(),e.setSelectionRange(0,99999),document.execCommand("copy"),e.remove(),this.$emit("copied",this.$refs.code.innerText)}},mounted(){const t=this.getSlotContent();this.$refs.code.innerText=t,this.$refs.code.innerHTML=this.syntaxHighlightContent(this.$refs.code.innerText)},beforeUpdate(){this.$refs.code.innerHTML=this.syntaxHighlightContent(this.getSlotContent())}},T=["data-type","data-label"],w=["contenteditable"],N={class:"ssh-pre__original"};function C(t,e,n,o,a,s){return c.openBlock(),c.createElementBlock("div",{class:c.normalizeClass(["ssh-pre",{"ssh-pre--dark":n.dark}]),"data-type":n.language,"data-label":n.label||null},[n.copyButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"ssh-pre__copy",onClick:e[0]||(e[0]=(...r)=>s.copyCode&&s.copyCode(...r))},[c.renderSlot(t.$slots,"copy-button",{},()=>[c.createTextVNode("Copy")])])):c.createCommentVNode("",!0),c.createTextVNode(),c.createElementVNode("pre",{ref:"code",class:"ssh-pre__content",contenteditable:n.editable?"true":"false",onKeydown:e[1]||(e[1]=r=>n.editable&&s.onKeydown(r)),onInput:e[2]||(e[2]=(...r)=>s.highlightInPre&&s.highlightInPre(...r))}," ",40,w),c.createTextVNode(),c.createElementVNode("div",N,[c.renderSlot(t.$slots,"default")])],10,T)}return y(x,[["render",C]])}); |
{ | ||
"name": "simple-syntax-highlighter", | ||
"version": "2.2.5", | ||
"version": "3.0.0", | ||
"description": "A Vue.js syntax highlighter that reads the source code you provide and highlights it, for Humans.", | ||
@@ -42,18 +42,18 @@ "author": "Antoni Andre <antoniandre.web@gmail.com>", | ||
"@babel/eslint-parser": "^7.19.1", | ||
"@vitejs/plugin-vue": "^3.1.2", | ||
"@vue/compiler-sfc": "^3.2.41", | ||
"@vitejs/plugin-vue": "^3.2.0", | ||
"@vue/compiler-sfc": "^3.2.47", | ||
"@vue/eslint-config-standard": "^6.1.0", | ||
"autoprefixer": "^10.4.12", | ||
"autoprefixer": "^10.4.13", | ||
"eslint": "^7.32.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.2.0", | ||
"eslint-plugin-vue": "^7.20.0", | ||
"postcss": "^8.4.18", | ||
"postcss": "^8.4.21", | ||
"pug": "^3.0.2", | ||
"rollup-plugin-delete": "^2.0.0", | ||
"sass": "^1.55.0", | ||
"vite": "^3.1.8", | ||
"vue": "^3.2.41", | ||
"wave-ui": "^2.43.1" | ||
"sass": "^1.58.0", | ||
"vite": "^3.2.5", | ||
"vue": "^3.2.47", | ||
"wave-ui": "^3.0.0" | ||
}, | ||
@@ -60,0 +60,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
54771
458