S4WEB/js/riot+compiler.min.js

1 line
314 KiB
JavaScript
Raw Permalink Normal View History

var e,t;e=this,t=function(e){"use strict";const t=void 0;function n(e){return!r(e)&&e.constructor===Object}function r(e){return null==e}function i(){return"undefined"!=typeof process}function a(e){throw Error(e)}const s="exports",o="template",l="riot",c="RiotComponentWrapper",u="RiotComponent",p="javascript",h="template",d="script",f="style",m="textarea",y="isSpread";var g=Object.freeze({__proto__:null,JAVASCRIPT_OUTPUT_NAME:p,CSS_OUTPUT_NAME:"css",TEMPLATE_OUTPUT_NAME:h,JAVASCRIPT_TAG:d,STYLE_TAG:f,TEXTAREA_TAG:m,IS_RAW:"isRaw",IS_SELF_CLOSING:"isSelfClosing",IS_VOID:"isVoid",IS_BOOLEAN:"isBoolean",IS_CUSTOM:"isCustom",IS_SPREAD:y}),b=Object.freeze({__proto__:null,TAG:1,ATTR:2,TEXT:3,CDATA:4,COMMENT:8,DOCUMENT:9,DOCTYPE:10,DOCUMENT_FRAGMENT:11});const v="Unexpected end of file.",x=/^(?:\/[a-zA-Z]|[a-zA-Z][^\s>/]?)/,S=/(\/?[^\s>/]+)\s*(>)?/g,E=/(\S[^>/=\s]*)(?:\s*=\s*([^>/])?)?/g,T=/\.\.\./,k={script:/<\/script\s*>/gi,style:/<\/style\s*>/gi,textarea:/<\/textarea\s*>/gi},P=/^\/?(?:pre|textarea)$/;function w(e,t,n){return e.lastIndex=t,e.exec(n)}var _=e=>e.replace(/(?=[-[\](){^*+?.$|\\])/g,"\\");function A(e,t,n){n||(n=e.length);const r=(e.slice(0,n).match(/\r\n?|\n/g)||"").length+1;let i=0;for(;--n>=0&&!/[\r\n]/.test(e[n]);)++i;return`[${r},${i}]: ${t}`}function C(e,t,n){const r=/[`$\\]/g;let i;for(;r.lastIndex=t,r.exec(e);){if(i=e[(t=r.lastIndex)-1],"`"===i)return t;if("$"===i&&"{"===e[t++])return n.push("`","}"),t}throw A(e,"Unclosed ES6 template literal.",t)}function I(e,t,n){const r=A(e,t,n);throw Error(r)}const N="[{(,;:?=|&!^~>%*/",O=N+"+-",D=["case","default","do","else","in","instanceof","prefix","return","typeof","void","yield"],j=D.reduce(((e,t)=>e+t.slice(-1)),""),L=/^\/(?=[^*>/])[^[/\\]*(?:(?:\\.|\[(?:\\.|[^\]\\]*)*\])[^[\\/]*)*?\/[gimuy]*/,M=/[$\w]/,B=/.*/g;function F(e,t){for(;--t>=0&&/\s/.test(e[t]););return t}const V=/'[^'\n\r\\]*(?:\\(?:\r\n?|[\S\s])[^'\n\r\\]*)*'/.source,R=`${V}|${V.replace(/'/g,'"')}`,q={};function U(e,t,n,r){let i=0;switch(t){case"[":case"(":case"{":e.push("["===t?"]":"("===t?")":"}");break;case")":case"]":case"}":t!==e.pop()&&I(r,"Unexpected character %1.".replace("%1",t),i),"}"===t&&"`"===e[e.length-1]&&(t=e.pop()),i=n+1;break;case"/":i=function(e,t){let n=B.lastIndex=t++;const r=(B.exec(e)||" ")[0].match(L);if(r){const i=n+r[0].length;n=F(e,n);let a=e[n];if(n<0||N.includes(a))return i;if("."===a)"."===e[n-1]&&(t=i);else{if(("+"===a||"-"===a)&&(e[--n]!==a||(n=F(e,n))<0||O.includes(a=e[n])))return i;if(j.includes(a)){const r=n+1;for(;--n>=0&&M.test(e[n]););D.includes(e.slice(n+1,r))&&(t=i)}}}return t}(r,n)}return{char:t,index:i}}function z(e,t,n){const[r,i]=n,a=t+r.length,s=[],o=function(e){let t=q[e];if(!t){let n=_(e);e.length>1?n+="|[":n=/[{}[\]()]/.test(e)?"[":"["+n,q[e]=t=RegExp(`${R}|${n}\`/\\{}[\\]()]`,"g")}return t}(i);let l,c;for(o.lastIndex=a;c=o.exec(e);){const n=c.index,r=c[0];if(l=o.lastIndex,r===i&&!s.length)return{text:e.slice(a,n),start:t,end:l};const{char:u,index:p}=U(s,r[0],n,e);l=p||l,o.lastIndex="`"===u?C(e,l,s):l}s.length&&I(e,"Unclosed expression.",l)}function W(e){const t=e.last;e.last=null,t&&e.root&&e.builder.push(t)}function J(e,t,n){return e.slice(t,n)}function G(e,t,n,r){void 0===r&&(r={});const i=J(e.data,t,n),a=r.expressions,s=r.unescape;let o=e.last;return e.pos=n,o&&3===o.type?(o.text+=i,o.end=n):(W(e),e.last=o={type:3,text:i,start:t,end:n}),a&&a.length&&(o.expressions=(o.expressions||[]).concat(a)),s&&(o.unescape=s),3}function H(e,t,n,r){const i=function(e,t){const{brackets:n}=e.options,r=e.regexCache[t];if(r)return r;const i=_(n[0]);return Object.assign(e.regexCache,{[t]:RegExp(`(${t})|${i}`,"g")}),e.regexCache[t]}(e,n);i.lastIndex=r;const{unescape:a,expressions:s,end:o}=function(e,t){const{data:n,options:r}=e,{brackets:i}=r,a=[];let s,o,l;for(;(l=t.exec(n))&&!l[1];)if(o=l.index,"\\"===n[o-1])s=l[0];else{const e=z(n,o,i);e&&(a.push(e),t.lastIndex=e.end)}return l||I(n,v,o),{unescape:s,expressions:a,end:l.index}}(e,i);return t?(a&&(t.unescape=a),s.length&&(t.expressions=s)):G(e,r,o,{expressions:s,unescape:a}),o}const X=e=>e.filter(((e,t,n)=>n.indexOf(e)