mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 16:51:00 +00:00
2 lines
94 KiB
JavaScript
2 lines
94 KiB
JavaScript
|
(function(e,t){const r=t(e);if(typeof exports==="object"&&typeof exports["nodeName"]!=="string"){module.exports=r}else{e["_hyperscript"]=r;if("document"in e)e["_hyperscript"].browserInit()}})(typeof self!=="undefined"?self:this,(e=>{"use strict";const t={dynamicResolvers:[function(e,t){if(e==="Fixed"){return Number(t).toFixed()}else if(e.indexOf("Fixed:")===0){let r=e.split(":")[1];return Number(t).toFixed(parseInt(r))}}],String:function(e){if(e.toString){return e.toString()}else{return""+e}},Int:function(e){return parseInt(e)},Float:function(e){return parseFloat(e)},Number:function(e){return Number(e)},Date:function(e){return new Date(e)},Array:function(e){return Array.from(e)},JSON:function(e){return JSON.stringify(e)},Object:function(e){if(e instanceof String){e=e.toString()}if(typeof e==="string"){return JSON.parse(e)}else{return Object.assign({},e)}}};const r={attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",conversions:t};class n{static OP_TABLE={"+":"PLUS","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",".":"PERIOD","..":"ELLIPSIS","\\":"BACKSLASH",":":"COLON","%":"PERCENT","|":"PIPE","!":"EXCLAMATION","?":"QUESTION","#":"POUND","&":"AMPERSAND",$:"DOLLAR",";":"SEMI",",":"COMMA","(":"L_PAREN",")":"R_PAREN","<":"L_ANG",">":"R_ANG","<=":"LTE_ANG",">=":"GTE_ANG","==":"EQ","===":"EQQ","!=":"NEQ","!==":"NEQQ","{":"L_BRACE","}":"R_BRACE","[":"L_BRACKET","]":"R_BRACKET","=":"EQUALS"};static isValidCSSClassChar(e){return n.isAlpha(e)||n.isNumeric(e)||e==="-"||e==="_"||e===":"}static isValidCSSIDChar(e){return n.isAlpha(e)||n.isNumeric(e)||e==="-"||e==="_"||e===":"}static isWhitespace(e){return e===" "||e==="\t"||n.isNewline(e)}static positionString(e){return"[Line: "+e.line+", Column: "+e.column+"]"}static isNewline(e){return e==="\r"||e==="\n"}static isNumeric(e){return e>="0"&&e<="9"}static isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}static isIdentifierChar(e,t){return e==="_"||e==="$"}static isReservedChar(e){return e==="`"||e==="^"}static isValidSingleQuoteStringStart(e){if(e.length>0){var t=e[e.length-1];if(t.type==="IDENTIFIER"||t.type==="CLASS_REF"||t.type==="ID_REF"){return false}if(t.op&&(t.value===">"||t.value===")")){return false}}return true}static tokenize(e,t){var r=[];var a=e;var o=0;var s=0;var u=1;var l="<START>";var c=0;function f(){return t&&c===0}while(o<a.length){if(S()==="-"&&q()==="-"&&(n.isWhitespace(N(2))||N(2)===""||N(2)==="-")||S()==="/"&&q()==="/"){h()}else if(S()==="/"&&q()==="*"){v()}else{if(n.isWhitespace(S())){r.push(C())}else if(!R()&&S()==="."&&(n.isAlpha(q())||q()==="{")){r.push(d())}else if(!R()&&S()==="#"&&(n.isAlpha(q())||q()==="{")){r.push(k())}else if(S()==="["&&q()==="@"){r.push(E())}else if(S()==="@"){r.push(T())}else if(S()==="*"&&n.isAlpha(q())){r.push(y())}else if(n.isAlpha(S())||!f()&&n.isIdentifierChar(S())){r.push(x())}else if(n.isNumeric(S())){r.push(g())}else if(!f()&&(S()==='"'||S()==="`")){r.push(w())}else if(!f()&&S()==="'"){if(n.isValidSingleQuoteStringStart(r)){r.push(w())}else{r.push(b())}}else if(n.OP_TABLE[S()]){if(l==="$"&&S()==="{"){c++}if(S()==="}"){c--}r.push(b())}else if(f()||n.isReservedChar(S())){r.push(p("RESERVED",I()))}else{if(o<a.length){throw Error("Unknown token: "+S()+" ")}}}}return new i(r,[],a);function m(e,t){var r=p(e,t);r.op=true;return r}function p(e,t){return{type:e,value:t||"",start:o,end:o+1,column:s,line:u}}function h(){while(S()&&!n.isNewline(S())){I()}I()}function v(){while(S()&&!(S()==="*"&&q()==="/")){I()}I();I()}function d(){var e=p("CLASS_REF");var t=I();if(S()==="{"){e.template=true;t+=I();while(S()&&S()!=="}"){t+=I()}if(S()!=="}"){throw Error("Unterminated class reference")}else{t+=I()}}else{while(n.isValidCSSClassChar(S())){t+=I()}}e.value=t;e.end=o;return e}function E(){var e=p("ATTRIBUTE_REF");var t=I();while(o<a.length&&S()!=="]"){t+=I()}if(S()==="]"){t+=I()}e.value=t;e.end=o;return e}function T(){var e=p("ATTRIBUTE_REF");var t=I();while(n.isValidCSSIDChar(S())){t+=I()}e.value=t;e.end=o;return e}function y(){var e=p("STYLE_REF");var t=I();while(
|