@hyperfixi/engine 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +921 -0
- package/LICENSE +20 -0
- package/README.md +272 -0
- package/dist/additions.d.ts +30 -0
- package/dist/ast.d.ts +277 -0
- package/dist/commands/animation.d.ts +34 -0
- package/dist/commands/control.d.ts +36 -0
- package/dist/commands/dom-more.d.ts +68 -0
- package/dist/commands/dom.d.ts +50 -0
- package/dist/commands/events.d.ts +25 -0
- package/dist/commands/js.d.ts +22 -0
- package/dist/commands/loops.d.ts +34 -0
- package/dist/commands/misc.d.ts +36 -0
- package/dist/commands/morph.d.ts +18 -0
- package/dist/commands/pick.d.ts +22 -0
- package/dist/commands/platform.d.ts +44 -0
- package/dist/commands/setters.d.ts +38 -0
- package/dist/common.js +3020 -0
- package/dist/common.min.js +17 -0
- package/dist/conversions.d.ts +6 -0
- package/dist/cookies.d.ts +10 -0
- package/dist/core.js +2190 -0
- package/dist/core.min.js +17 -0
- package/dist/engine.d.ts +79 -0
- package/dist/everything.d.ts +2 -0
- package/dist/expressions-extra.d.ts +2 -0
- package/dist/expressions.d.ts +51 -0
- package/dist/features.d.ts +47 -0
- package/dist/full.js +5673 -0
- package/dist/full.min.js +19 -0
- package/dist/hyperfixi-hs.dev.js +5676 -0
- package/dist/hyperfixi-hs.js +19 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +5737 -0
- package/dist/live-templates.d.ts +3 -0
- package/dist/minimal.js +2580 -0
- package/dist/minimal.min.js +17 -0
- package/dist/on.d.ts +39 -0
- package/dist/parser.d.ts +97 -0
- package/dist/reactivity.d.ts +30 -0
- package/dist/runtime.d.ts +160 -0
- package/dist/statements.d.ts +24 -0
- package/dist/templates.d.ts +61 -0
- package/dist/tokenizer.d.ts +25 -0
- package/dist/util.d.ts +34 -0
- package/package.json +60 -0
package/dist/core.min.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";(()=>{var G=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",E=(e,t)=>G(e)?e.then(t):t(e),S=(e,t)=>e.some(G)?Promise.all(e).then(t):t(e),C=e=>e!=null,L=e=>typeof e=="function",g=(e,t)=>C(e)?e[t]:void 0,z=(e,t,n)=>{C(e)&&(e[t]=n)},k=e=>e instanceof Element,B=e=>L(g(e,"addEventListener"));var v=e=>e;var ae={attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",hideShowStrategies:{},fetchThrowsOn:[/^4/,/^5/]},ge=Object.assign(Object.create(null),{String:e=>String(e),Int:e=>parseInt(String(e)),Float:e=>parseFloat(String(e)),Number:e=>Number(e),Fragment:e=>Ue(e)}),ye=[],Y={process(e){},enter(e){}},ie=new WeakMap,$=e=>ie.get(e),De=e=>ie.delete(e);function U(e){let t=ie.get(e);return t||ie.set(e,t={}),t}var w={tracking:!1,readGlobal(e){},readElement(e,t){},readProperty(e,t){},readAttribute(e,t){},readQuery(e){},wroteGlobal(e){},wroteElement(e,t){},wroteProperty(e){},stop(e){}},se=e=>(w.tracking&&typeof e=="object"&&e!==null&&w.readProperty(e,"__mutation__"),e),qt={Array:["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"],Set:["add","delete","clear"],Map:["set","delete","clear"]};function Me(e,t){let n=g(g(e,"constructor"),"name");typeof n=="string"&&qt[n]?.includes(t)&&w.wroteProperty(e)}var ve=e=>{if(e instanceof Node){let t=e.getRootNode();if(t instanceof Document||t instanceof ShadowRoot)return t}return document},_t=e=>e.replace(/[:&()[\]/]/g,t=>"\\"+t);function we(e,t){return w.tracking&&w.readQuery(e),e.querySelectorAll(t)}var A=class{constructor(t,n,r=!1){this.raw=t;this.relativeTo=n;this.escape=r}get css(){return this.escape?_t(this.raw):this.raw}get className(){return this.raw.slice(1)}get length(){return this.select().length}contains(t){for(let n of this)if(n.contains(t))return!0;return!1}select(){return we(ve(this.relativeTo),this.css)}[Symbol.iterator](){return this.select()[Symbol.iterator]()}},Ee=e=>e instanceof A||Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList;function P(e,t){if(Ee(e))for(let n of e)t(n);else t(e)}var ue=(e,t)=>{if(e==null)return;let n=t(e);if(n!==void 0)return n;if(Ee(e))return Array.from(e,t)},Z=(e,t)=>(w.tracking&&w.readProperty(e,t),ue(e,n=>g(n,t))),J=(e,t)=>(w.tracking&&w.readAttribute(e,t),ue(e,n=>k(n)?n.getAttribute(t):void 0)),ce=(e,t)=>ue(e,n=>g(g(n,"style"),t)),le=(e,t)=>ue(e,n=>k(n)?getComputedStyle(n).getPropertyValue(t):void 0),K=(e,t,n)=>P(e,r=>{k(r)&&(n==null?r.removeAttribute(t):r.setAttribute(t,String(n)))}),fe=(e,t,n)=>P(e,r=>z(g(r,"style"),t,n)),de=(e,t,n)=>P(e,r=>{z(r,t,n),w.wroteProperty(r)});function R(e,t){if(e==null)throw new Error(`'${t}' is null`)}var be=e=>e==null||g(e,"length")===0;function je(e){if(e==null)return!1;if(Ee(e)){for(let t of e)return!0;return!1}return!0}function He(e,t,n){if(e==null&&n||Object.prototype.toString.call(e).slice(8,-1)===t)return!0;let r=g(globalThis,t);return L(r)&&e instanceof r}function $e(e,t){for(let r of ye){let o=r(t,e);if(o!==void 0)return o}if(e==null)return null;let n=ge[t];if(n)return n(e);throw new Error("Unknown conversion : "+t)}function Ue(e){let t=document.createDocumentFragment();return e==null?t.append("null"):P(e,n=>{if(n instanceof Node)t.append(n);else{let r=document.createElement("template");r.innerHTML=n===null?"":String(n),t.append(r.content)}}),t}function X(e,t){P(e,n=>{if(!k(n))return;let r=n.parentElement;n.replaceWith(t instanceof Node?t.cloneNode(!0):Ue(t)),r&&Y.process(r)})}function N(e,t,n={},r){if(!B(e))return!0;n.sender=r;let o=Object.assign(new Event(t,{bubbles:!0,cancelable:!0,composed:!0}),{detail:n});return e.dispatchEvent(o)}var We=(e,t="elementScope")=>(U(e).scopes??={})[t]??={},Lt=Object.create(null,{selection:{get:()=>getSelection()?.toString(),enumerable:!0},clipboard:{get:()=>navigator.clipboard.readText(),set:e=>void navigator.clipboard.writeText(String(e))}});function ee(e,t,n,r){let o=g(r,"detail"),i=Object.create(Lt);for(let s=k(e)?e:null;s;s=s.parentElement)Object.assign(i,$(s)?.features);return{meta:{owner:e,feature:t},locals:i,me:n,you:void 0,result:void 0,beingTested:null,event:r,target:g(r,"target")??null,detail:o??null,sender:g(o,"sender")??null,body:typeof document>"u"?null:document.body}}var he=["meta","it","result","locals","event","target","detail","sender","body"],Q=e=>{let t=e.meta.owner,n=e.meta.feature?.behavior;return C(t)?We(t,n?n+"Scope":void 0):{}};function Ge(e,t,n){let r=k(n)?n:k(t.meta.owner)?t.meta.owner:null;for(;r;){let o=$(r)?.scopes?.elementScope;if(o&&e in o)return{value:o[e],element:r};let i=r.getAttribute("dom-scope");if(i==="isolated")break;let s=i?.match(/^closest\s+(.+)/),c=i?.match(/^parent\s+of\s+(.+)/);s?r=r.parentElement?.closest(s[1])??null:c?r=r.closest(c[1])?.parentElement??null:r=r.parentElement}return{value:void 0,element:null}}function ze(e,t,n,r){if(e==="me"||e==="my"||e==="I")return t.me;if(e==="it"||e==="its")return t.beingTested??t.result;if(e==="result")return t.result;if(e==="you"||e==="your"||e==="yourself")return t.you;let o=t.meta.owner,i=()=>(w.tracking&&w.readGlobal(e),se(g(globalThis,e)));if(n==="global")return i();if(n==="element")return w.tracking&&w.readElement(e,o),se(Q(t)[e]);if(n==="inherited"){let l=Ge(e,t,r);return w.tracking&&w.readElement(e,l.element??(k(r)?r:o)),se(l.value)}let s=t.meta.context;if(s!=null){let l=g(s,e);if(l!==void 0)return l;let u=g(g(s,"detail"),e);if(u!==void 0)return u}let c=he.includes(e)?g(t,e):t.locals[e];if(c!==void 0)return c;let a=Q(t)[e];return a!==void 0?(w.tracking&&w.readElement(e,o),se(a)):i()}function Be(e,t,n,r,o){if(n==="global")z(globalThis,e,r),w.wroteGlobal(e);else if(n==="element")Q(t)[e]=r,w.wroteElement(e,t.meta.owner);else if(n==="inherited"){let s=Ge(e,t,o).element??(k(o)?o:t.meta.owner);C(s)&&(We(s)[e]=r),w.wroteElement(e,s)}else!he.includes(e)&&t.locals[e]!==void 0?t.locals[e]=r:Q(t)[e]!==void 0?(Q(t)[e]=r,w.wroteElement(e,t.meta.owner)):he.includes(e)?z(t,e,r):t.locals[e]=r}function H(e,t,n=0){for(let r=n;r<e.length;r++){let o=e[r].run(t);if(G(o))return o.then(i=>i||H(e,t,r+1));if(o)return o}}function V(e,t){try{let n=e();return G(n)?n.then(void 0,t):n}catch(n){return t(n)}}function Qe(e,t,n){let{errorSymbol:r,errorHandler:o,finallyHandler:i}=n,s=()=>V(()=>E(H(t,e),a=>{let l=g(a,"k");if(l==="break"||l==="continue")throw new Error(`Command \`${l}\` cannot be used outside of a \`repeat\` loop.`);return Le(a)}),a=>{if(!o||!r)throw a;return e.locals[r]=a,H(o,e)});if(!i)return s();let c=()=>V(()=>E(H(i,e),()=>{}),a=>console.error(" Exception in finally block: ",a));return V(()=>E(s(),a=>E(c(),()=>Le(a))),a=>E(c(),()=>{throw a}))}var Le=e=>{let t=g(e,"k");if(t==="return")return{k:"return",value:g(e,"value")};if(t==="break"||t==="continue")return{k:t}};var Ve=new Set("+ - * / . .. \\ : % | ! ? # & $ ; , ( ) < > <= >= == === != !== { } [ ] = ~ ^".split(" ")),Ye={b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" ",v:"\v"},q=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",_=e=>e>="0"&&e<="9",xe=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
|
+
`,ke=e=>q(e)||_(e)||e==="-"||e==="_"||e===":",Te=e=>q(e)||_(e)||e==="_"||e==="$";function te(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",c=0,a=()=>e.charAt(r),l=f=>e.charAt(r+f),u=()=>(s=e.charAt(r++),s===`
|
|
4
|
+
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;a()&&f(a());)h+=u();return h},y=()=>t&&c===0,I=()=>q(s)||_(s)||")\"'`}]".includes(s),j=(f,h)=>{let b=p(f),T=u();if(a()==="{"){if(b.template=!0,T+=u(),T+=d(Ft=>Ft!=="}"),a()!=="}")throw new Error("Unterminated "+(h?"class":"id")+" reference");let oe=u();h&&(T+=oe)}else if(h)for(;ke(a())||a()==="\\";)a()==="\\"&&u(),T+=u();else T+=d(ke);return m(b,T)},F=()=>{let f=p("STRING"),h=u();f.template=h==="`";let b="";for(;a()&&a()!==h;)if(a()==="\\"){u();let T=u();if(T in Ye)b+=Ye[T];else if(f.template&&T==="$")b+="\\$";else if(T==="x"){let oe=a()&&l(1)?parseInt(u()+u(),16):NaN;if(Number.isNaN(oe))throw new Error(`Invalid hexadecimal escape at [Line: ${f.line}, Column: ${f.column}]`);b+=String.fromCharCode(oe)}else b+=T}else b+=u();if(a()!==h)throw new Error(`Unterminated string at [Line: ${f.line}, Column: ${f.column}]`);return u(),m(f,b)},qe=()=>{let f=p("IDENTIFIER"),h=u()+d(Te);return a()==="!"&&h==="beep"&&(h+=u()),m(f,h)},Rt=()=>{let f=p("IDENTIFIER"),h=u(),b=h==="\\";for(b&&(h="");(Te(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!b);)a()==="\\"?(b=!0,u()):(b=!1,h+=u());return m(f,h)},Ot=()=>{let f=p("NUMBER"),h=u()+d(_);return a()==="."&&_(l(1))&&(h+=u()),h+=d(_),(a()==="e"||a()==="E")&&(_(l(1))?h+=u():l(1)==="-"&&(h+=u()+u())),m(f,h+d(_))},_e=()=>{let f=p("OP");f.op=!0;let h=u();for(;a()&&Ve.has(h+a());)h+=u();return m(f,h)},It=()=>{let f=p("ATTRIBUTE_REF"),h=u();return h==="["?(h+=d(b=>b!=="]"),a()==="]"&&(h+=u())):(h+=d(ke),a()==="="&&(h+=u(),a()==='"'||a()==="'"?h+=F().value:Te(a())&&(h+=qe().value))),m(f,h)},Ct=()=>{let f=n.at(-1);return f?f.type==="IDENTIFIER"||f.type==="CLASS_REF"||f.type==="ID_REF"?!1:!(f.op&&(f.value===">"||f.value===")")):!0},At=()=>{let f=a(),h=l(2);return(f==="-"||f==="/")&&l(1)===f&&(xe(h)||h===""||h===f)};for(;r<e.length;){let f=a(),h=l(1);if(At())d(b=>b!=="\r"&&b!==`
|
|
5
|
+
`),u();else if(xe(f))n.push(m(p("WHITESPACE"),d(xe)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(It());else if(f==="*"&&q(h)){let b=p("STYLE_REF");n.push(m(b,u()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(Rt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(qe());else if(_(f))n.push(Ot());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Ct()?F():_e());else if(Ve.has(f))s==="$"&&f==="{"&&c++,f==="}"&&c--,n.push(_e());else if(y()||f==="`"){let b=p("RESERVED");n.push(m(b,u()))}else throw new Error("Unknown token: "+f+" ")}return n}function x(e){return e.match("the"),Dt(e)}function Dt(e){let t=Je(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=Mt(o.value,t,Je(e));return t}function Mt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var jt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Pe(e){let t=Se(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=Se(e),c=jt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([u,p])=>c(u,p))}}return t}function Se(e){let t=D(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function D(e){e.match("the");let t=e.pos();if(e.match("not"))return Re(e,"logicalNot",t,D(e),n=>!n);if(e.match("no"))return Re(e,"noExpression",t,Se(e),be);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return $t(e)}function Re(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return i?O(e,s):s}var Ht="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function $t(e){let t=tt(e),n=e.matchAny(...Ht)??e.matchOp("%");if(n)return Ze(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return Ze(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function Ze(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function tt(e){let t=e.pos();return e.matchOp("-")?Re(e,"negativeNumber",t,tt(e),n=>-v(n)):Ut(e)}function Ut(e){let t=zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Wt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,u=!1)=>({operator:a,right:l,isType:u}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",c=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(c("match","matches"))return n(s+"match");if(c("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(c("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(c("precede","precedes"))return n(s+"precede");if(c("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function Je(e){let t=Pe(e),n=Wt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,c;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Pe(e),r.endsWith("match")&&(c=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Pe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let u=d=>l&&typeof d=="string"?d.toLowerCase():d,p=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),c??s?.ev(d),a?.ev(d)],([y,I,j])=>{if(o){let F=He(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!Z(y,p);return r==="is"?F:!F}return nt(r,u(y),u(I),j)})}}function Ke(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Gt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Xe=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function nt(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!nt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Gt(t,n);case"in":return n!=null&&Ke(n,t);case"contain":case"include":return t!=null&&Ke(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return v(t)>=v(n)&&v(t)<=v(r);case"precede":return Xe(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Xe(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return be(t);case"exist":return je(t)}throw new Error("Unknown comparison : "+e)}function zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ne("number",parseFloat(t.value),t);case"STRING":return Vt(e);case"ID_REF":return Kt(e);case"CLASS_REF":return Xt(e);case"ATTRIBUTE_REF":return Ie(e);case"STYLE_REF":return it(e)}if(t.op){if(t.value==="(")return Bt(e);if(t.value==="[")return Yt(e);if(t.value==="{")return Zt(e);if(t.value==="<")return en(e)}let n=e.match("true")??e.match("false");if(n)return Ne("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ne("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Jt(e)}function Ne(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Bt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>x(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Qt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function rt(e,t){let n=e.child(te(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,x(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function Vt(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=rt(e,n);r.ev=i=>Qt(o,i)}else r.stat=()=>n;return r}function Yt(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(x(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function Zt(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(x(e)),e.reqOp("]");else{let s="";for(let c=e.matchType("IDENTIFIER")??e.matchOp("-");c;c=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=c.value;n.push(s)}e.reqOp(":"),r.push(x(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((c,a)=>[String(s[a]),s[n.length+a]])))}}function ot(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Jt(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>x(e))),{type:"symbol",name:s,scope:a,start:t,end:e.endPos(),ev:u=>ze(s,u,a,l?.ev(u)),lhs:()=>{},put:(u,p,m)=>Be(s,u,a,m,l?.ev(u))}}var st=(e,t)=>{let n=t.value.substring(2);return x(e.child(te(n),n))};function Kt(e){let t=e.consume(),n=(o,i)=>ve(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>c&&X(c,s))};if(t.template){let o=r.expr=st(e,t);r.ev=i=>E(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Xt(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>E(n.ev(r),s=>X(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=st(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Oe=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function en(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>X(Array.from(c instanceof A?c:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=rt(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Oe(i.me,s))}return r}function Ie(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>J(s.you||s.me,r),lhs:()=>{},put:(s,c,a)=>K(s.you||s.me,r,a)}}function it(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?le:ce)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>fe(o.you||o.me,r,s)}}function at(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function ut(e,t="Expected event name"){return e.matchType("STRING")?.value??at(e)??e.err(t)}function O(e,t){return nn(e,t)??rn(e,t)??cn(e,t)??on(e,t)??sn(e,t)??an(e,t)??un(e,t)??fn(e,t)??tn(e,t)??t}function tn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function nn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),de(s,n,c)},del:(i,s)=>{R(s,r),P(s,c=>{C(c)&&delete c[n],w.wroteProperty(c)})}};return O(e,o)}function rn(e,t){if(!e.match("of"))return;let n=D(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!s||c===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:Z,attribute:J,style:ce,computed:le}[s],u={type:"ofExpression",root:n,name:c,kind:s,start:t.start,end:e.endPos(),ev:p=>E(u.root.ev(p),m=>l(m,c)),lhs:p=>u.root.ev(p),put:(p,m,d)=>{R(m,a),s==="attribute"?K(m,c,d):s==="property"?de(m,c,d):fe(m,c,d)},del:(p,m)=>{R(m,a),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(c):s==="property"?(C(d)&&delete d[c],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(c)})}};return r?(r.root=u,O(e,t)):O(e,u)}function on(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=Ie(e)??it(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),c=l=>i!==void 0?Z(l,i):o?.type==="attributeRef"?J(l,o.name):o?.type==="computedStyleRef"?le(l,o.name):o&&ce(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(a.root.ev(l),c),lhs:l=>a.root.ev(l),put:(l,u,p)=>{R(u,s),i!==void 0?de(u,i,p):o?.type==="attributeRef"?K(u,o.name,p):o&&fe(u,o.name,p)}};return O(e,a)}function sn(e,t){if(!e.match("in"))return;let n=D(e),r=(s,c)=>{if(s==null)return[];let a=[],l=g(s,"css");if(typeof l=="string")P(c,u=>k(u)&&a.push(...we(u,l)));else if(k(s)){let u=!1;if(P(c,p=>{p instanceof Node&&p.contains(s)&&(u=!0)}),u)return s}else P(s,u=>P(c,p=>u===p&&a.push(u)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([c,a])=>r(c,a)),lhs:s=>o.ev(s),put:(s,c,a)=>X(c,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function an(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=at(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:c=>E(s.root.ev(c),a=>$e(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function un(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(x(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let c=i.root,a=c.prop,l=a===void 0?void 0:c.root;return S([(l??c).ev(s),...n.map(u=>u.ev(s))],([u,...p])=>{if(!l||a===void 0)return et(u,void 0,p,s,r);R(u,o);let m=et(g(u,a),u,p,s,r);return Me(u,a),m})}};return O(e,i)}function et(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function cn(e,t){let n=Ie(e);return n&&ln(e,t,n)}function ln(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),K(s,n.name,c)}};return o}function fn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=x(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=x(e))),e.reqOp("]");let s=e.text(t),c=(u,p)=>v(p)<0?v(g(u,"length"))+v(p):v(p),a=(u,p,m)=>{let d=g(u,"slice");return L(d)?Reflect.apply(d,u,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:u=>S([l.root.ev(u),r.ev(u),i?.ev(u)],([p,m,d])=>p==null?null:n?a(p,0,c(p,m)+1):o?d==null?a(p,v(m)):a(p,v(m),c(p,d)+1):g(p,String(m))),lhs:u=>S([l.root.ev(u),r.ev(u)],p=>p),put:(u,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(u,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(c(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var M=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},ct=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),me=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new M(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Ce(e){let t=e.source.split(`
|
|
6
|
+
`),n=e.token.line?e.token.line-1:t.length-1,r=t[n]??"",o=e.token.line?e.token.column:Math.max(0,r.length-1),i=String(n+1).length,s=" ".repeat(i+5+o);return` ${n+1} | ${r}
|
|
7
|
+
`+s+"^".repeat(Math.max(1,e.token.value.length))+`
|
|
8
|
+
`+s+e.message+`
|
|
9
|
+
`}function lt(e){let t=e.pos();if(e.matchOp("(")){let a=lt(e)??e.err("Expected command");return e.reqOp(")"),a}let n=e.cur(),r=e.g.commands[n.value],o;if(r?o=e.match(n.value)&&r(e,n.value,t):n.type==="IDENTIFIER"&&(o=e.g.pseudo?.(e,t)),!o||!e.match("unless"))return o;let i=o,s=x(e);return{type:"unlessStatementModifier",command:i,condition:s,start:t,end:e.endPos(),run:a=>E(s.ev(a),l=>l?void 0:i.run(a))}}function W(e){let t=[];for(;e.hasMore();){let n=lt(e);if(!n)break;t.push(n),e.match("then")}return t}function ft(e){let t=e.pos();if(e.matchOp("(")){let o=ft(e);return e.reqOp(")"),o}let n=e.cur(),r=e.g.features[n.value];return!r||!e.match(n.value)?e.err("Expected feature"):r(e,t)}function Ae(e){let t=e.pos(),n=[];for(;e.hasMore();){let r=e.cur();if(e.featureStart(r)||r.value==="(")n.push(ft(e)),e.match("end");else{if(r.value==="end")break;e.err()}}return{type:"hyperscript",features:n,start:t,end:e.endPos()}}function dt(e){let t={};return e.match("catch")&&(t.errorSymbol=e.reqType("IDENTIFIER").value,t.errorHandler=W(e)),e.match("finally")&&(t.finallyHandler=W(e)),t}function mt(e){let t=[],n=e.tok(1).value,r=e.tok(2).value;if(e.cur().value==="("&&(n===")"||r===","||r===")")){e.matchOp("(");do t.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}return t}var gt=ct();function yt(...e){for(let t of e)t(gt)}var vt=e=>new me(gt,te(e),e);function dn(e){let t=vt(e),n=Ae(t);return t.hasMore()&&t.err(),n}function wt(e){let t=vt(e),n=t.cur(),r=t.commandStart(n)?{kind:"commands",commands:W(t)}:t.featureStart(n)?{kind:"features",program:Ae(t)}:{kind:"expression",expression:x(t)};return t.hasMore()&&t.err(),r}function pt(e,t){let n;try{n=wt(e)}catch(i){throw i instanceof M?new Error(i.message+`
|
|
10
|
+
|
|
11
|
+
`+Ce(i)):i}let r=document.body;if(n.kind==="features"){for(let i of n.program.features)i.install(r,r);return}let o=Object.assign(ee(r,void 0,r,null),t);return n.kind==="expression"?n.expression.ev(o):E(H(n.commands,o),i=>{let s=g(i,"k")==="return"?g(i,"value"):void 0;return s!==void 0?s:o.result})}var Et=()=>ae.attributes.replaceAll(" ","").split(","),bt=e=>e instanceof HTMLScriptElement&&e.type==="text/hyperscript";function mn(e){for(let t of Et())if(e.hasAttribute(t))return e.getAttribute(t);return bt(e)?e.innerText:null}var pn=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return t},xt=[];function ht(e){if(e.closest(ae.disableSelector))return;let t=mn(e);if(!t)return;let n=pn(t);if($(e)?.initialized){if($(e)?.scriptHash===n)return Y.enter(e);pe(e)}if(!N(e,"hyperscript:before:init"))return;Object.assign(U(e),{initialized:!0,scriptHash:n});let r=bt(e)?document.body:e,o=t;try{for(let s of xt)o=s(o,e)??o;let{features:i}=dn(o);Y.enter(e);for(let s of i)s.install(r,e);e.setAttribute("data-hyperscript-powered","true"),N(e,"hyperscript:after:init"),setTimeout(()=>N(r,"load",{hyperscript:!0}),1)}catch(i){if(i instanceof M){o!==t&&(i.written=t),N(e,"hyperscript:parse-error",{errors:[i]});let s=i.written?`
|
|
12
|
+
rewritten from: ${i.written}
|
|
13
|
+
`:"";console.error("hyperscript: 1 parse error(s) on:",e,`
|
|
14
|
+
|
|
15
|
+
`+Ce(i)+s)}else N(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
|
+
|
|
17
|
+
`,i)}}var kt=[],Tt=[];function re(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of kt)n(e);let t=Et().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&ht(e),e.querySelectorAll(t).forEach(ht);for(let n of Tt)n(e)}function pe(e){let t=$(e);if(t){N(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);w.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(pe),N(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),De(e)}}Y.process=re;function hn(e){try{let t=wt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof M)return{errors:[t]};throw t}}var Pt=Object.assign(pt,{config:Object.assign(ae,{conversions:Object.assign(ge,{dynamicResolvers:ye})}),use(e){e(Pt)},addBeforeProcessHook:e=>void kt.push(e),addAfterProcessHook:e=>void Tt.push(e),addSourceTransform:e=>void xt.push(e),evaluate:pt,parse:hn,process:re,processNode:re,cleanup:pe,internals:{runtime:{cleanup:pe,processNode:re}},version:"3.3.0"});function Nt(){if(Object.assign(globalThis,{_hyperscript:Pt}),typeof document>"u")return;let e=()=>{re(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function gn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=U(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function Fe(e,t){let n=gn(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>Fe(i,t),1),o){let{error:s}=o;console.error(g(s,"message")??s),console.error(g(s,"stack")),N(e.me,"exception",{error:s})}};V(()=>E(Qe(e,t.body,t),()=>r()),o=>r({error:o}))}function yn(e,t){if(!B(t))return;let n=U(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let c={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(ee(t,e,t,null)):[t];P(a,l=>{if(!B(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let u=s.on;if(s.mutationSpec&&l instanceof Node){u="hyperscript:mutation";let m=new MutationObserver(d=>N(l,u,{mutationList:d,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){u="hyperscript:intersection";let m=new IntersectionObserver(d=>{for(let y of d)N(l,u,{observer:m,entry:y,intersecting:y.isIntersecting,isIntersecting:y.isIntersecting,intersectionRatio:y.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){u="hyperscript:resize";let m=new ResizeObserver(d=>{for(let y of d){let{width:I,height:j}=y.contentRect;N(l,u,{width:I,height:j,contentRect:y.contentRect,entry:y})}});m.observe(l),o.push(m)}let p=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(u,p);return}let d=ee(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(d.result=l);for(let y of s.args){let I=g(m,y);I!==void 0?d.locals[y]=I:d.detail!=null&&(d.locals[y]=g(d.detail,y))}if(s.filter){d.meta.context=m;try{if(!s.filter.ev(d))return}finally{d.meta.context=void 0}}if(s.inExpr?.css){let y=m.target instanceof Element?m.target:null;for(;y&&!y.matches(s.inExpr.css);)y=y.parentElement;if(!y)return;d.result=y}if(c.execCount++,s.startCount){let y=c.execCount;if(s.endCount?y<s.startCount||y>s.endCount:s.unbounded?y<s.startCount:y!==s.startCount)return}if(s.debounceTime){c.debounced&&(clearTimeout(c.debounced),i.delete(c.debounced)),i.add(c.debounced=setTimeout(()=>Fe(d,e),s.debounceTime));return}if(s.throttleTime){if(c.lastExec&&Date.now()<c.lastExec+s.throttleTime)return;c.lastExec=Date.now()}Fe(d,e)}};l.addEventListener(u,p),r.push({target:l,event:u,handler:p})})}}function vn(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function wn(e){let t={};if(e.match("with")){let n=ne(x(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=ot(e):e.match("threshold")?t.threshold=Number(ne(x(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function En(e,t){let n=ut(e),r=mt(e),o;e.matchOp("[")&&(o=x(e),e.reqOp("]"));let i,s,c=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(c=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:c,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=wn(e):n==="mutation"&&(a.mutationSpec=vn(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>x(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=D(e));let l=()=>(e.req("at"),Number(ne(D(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function St(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(En(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let c=W(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:c,every:r,queue:s,...dt(t),start:n,end:t.endPos(),install:l=>yn(a,l)};return a}}yt(St);Nt();})();
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine: one grammar, DOM initialisation, and the public `_hyperscript` API.
|
|
3
|
+
*
|
|
4
|
+
* A bundle builds its engine by calling `register(...)` with the modules it wants.
|
|
5
|
+
* Follows upstream `_hyperscript.js` and the DOM half of `core/runtime/runtime.js`.
|
|
6
|
+
*/
|
|
7
|
+
import type { Cmd, Ctx, Expr, Program } from './ast';
|
|
8
|
+
import { ParseError, type Grammar } from './parser';
|
|
9
|
+
export type Module = (g: Grammar) => void;
|
|
10
|
+
export declare const grammar: Grammar;
|
|
11
|
+
/** Add grammar modules to this bundle's engine. */
|
|
12
|
+
export declare function register(...modules: Module[]): void;
|
|
13
|
+
/** Parse the script of an element. Throws `ParseError`; a leftover token is an error. */
|
|
14
|
+
export declare function parseProgram(src: string): Program;
|
|
15
|
+
export type Parsed = {
|
|
16
|
+
kind: 'commands';
|
|
17
|
+
commands: Cmd[];
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'features';
|
|
20
|
+
program: Program;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'expression';
|
|
23
|
+
expression: Expr;
|
|
24
|
+
};
|
|
25
|
+
/** Parse free-standing source: commands, features or one expression, decided by the first word. */
|
|
26
|
+
export declare function parse(src: string): Parsed;
|
|
27
|
+
/** Run source against a context. Synchronous unless the source itself waits on something. */
|
|
28
|
+
export declare function evaluate(src: string, overrides?: Partial<Ctx>): unknown;
|
|
29
|
+
/**
|
|
30
|
+
* A plugin's rewrite of a script, applied as the script is read (the multilingual adapter
|
|
31
|
+
* turns it into English). The element keeps the text its author wrote. Returning nothing
|
|
32
|
+
* leaves the script as it is.
|
|
33
|
+
*/
|
|
34
|
+
export type SourceTransform = (source: string, element: Element) => string | null | undefined;
|
|
35
|
+
type ProcessRoot = Element | Document | DocumentFragment;
|
|
36
|
+
type ProcessHook = (root: ProcessRoot) => void;
|
|
37
|
+
/** Initialise every scripted element in a subtree. Elements already initialised are skipped. */
|
|
38
|
+
export declare function processNode(node: unknown): void;
|
|
39
|
+
/** Remove everything an element's script installed: listeners, observers, timers, state. */
|
|
40
|
+
export declare function cleanup(elt: Element): void;
|
|
41
|
+
/**
|
|
42
|
+
* `parse` as a host exposes it, in upstream's shape: the parsed node with an
|
|
43
|
+
* `errors` list. A grammar error is reported in the list; a tokenizer error throws.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hostParse(src: string): {
|
|
46
|
+
errors: ParseError[];
|
|
47
|
+
features?: Program['features'];
|
|
48
|
+
};
|
|
49
|
+
/** The public object, shaped like upstream's `_hyperscript` so its plugins can be used. */
|
|
50
|
+
export declare const api: typeof evaluate & {
|
|
51
|
+
config: import("./runtime").Config & {
|
|
52
|
+
conversions: Record<string, import("./runtime").Conversion> & {
|
|
53
|
+
dynamicResolvers: ((name: string, value: unknown) => unknown)[];
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** `use(plugin)`: the plugin receives this object. */
|
|
57
|
+
use(plugin: (hyperscript: unknown) => void): void;
|
|
58
|
+
addBeforeProcessHook: (hook: ProcessHook) => undefined;
|
|
59
|
+
addAfterProcessHook: (hook: ProcessHook) => undefined;
|
|
60
|
+
/** Not in upstream: rewrite a script as it is read, leaving the attribute as written. */
|
|
61
|
+
addSourceTransform: (transform: SourceTransform) => undefined;
|
|
62
|
+
evaluate: typeof evaluate;
|
|
63
|
+
parse: typeof hostParse;
|
|
64
|
+
process: typeof processNode;
|
|
65
|
+
/** Upstream's older name for `process`. */
|
|
66
|
+
processNode: typeof processNode;
|
|
67
|
+
cleanup: typeof cleanup;
|
|
68
|
+
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
69
|
+
internals: {
|
|
70
|
+
runtime: {
|
|
71
|
+
cleanup: typeof cleanup;
|
|
72
|
+
processNode: typeof processNode;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
version: string;
|
|
76
|
+
};
|
|
77
|
+
/** Install as `window._hyperscript` and initialise the document once it is ready. */
|
|
78
|
+
export declare function boot(): void;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The expression grammar: precedence chain, literals, references and accesses.
|
|
3
|
+
*
|
|
4
|
+
* The chain and every rule's parse decisions follow upstream _hyperscript
|
|
5
|
+
* (`core/kernel.js`, `parsetree/expressions/*`): logical → comparison → math →
|
|
6
|
+
* collection → unary → postfix → primary (leaf, then indirect accesses).
|
|
7
|
+
* Less common kinds (positional, `closest`, collection operators, type checks)
|
|
8
|
+
* are separate modules that register themselves in the `Grammar`.
|
|
9
|
+
*/
|
|
10
|
+
import type { AttributeAccessNode, AttributeRefNode, ClassRefNode, Ctx, Expr, ImplicitMeNode, NamedArgsNode, ObjectNode, StyleLiteralNode, StyleRefNode, SymbolNode, UnaryNode } from './ast';
|
|
11
|
+
import type { Parser } from './parser';
|
|
12
|
+
export declare function expr(p: Parser): Expr;
|
|
13
|
+
export declare function unary(p: Parser): Expr;
|
|
14
|
+
export declare function unaryNode(p: Parser, type: UnaryNode['type'], start: number, root: Expr, f: (v: unknown, ctx: Ctx) => unknown, chain?: boolean): Expr;
|
|
15
|
+
export declare function primary(p: Parser): Expr;
|
|
16
|
+
/** A target that can be written to: `set <this> to …`. */
|
|
17
|
+
export declare function assignable(p: Parser): Expr;
|
|
18
|
+
/** The node under any parentheses, which must be one a value can be put into. */
|
|
19
|
+
export declare function writable(p: Parser, node: Expr): Expr;
|
|
20
|
+
/** Strip parentheses: `(x)` writes to `x`. */
|
|
21
|
+
export declare function unwrap(node: Expr): Expr;
|
|
22
|
+
/** The value of an expression that needs no context: a literal, `200ms`, an event name. */
|
|
23
|
+
export declare function evalStatic(node: Expr): unknown;
|
|
24
|
+
export declare function leaf(p: Parser): Expr | undefined;
|
|
25
|
+
/** The inside of a backtick string or a templated query: text, `$name`, `${expr}`. */
|
|
26
|
+
export declare function templateParts(p: Parser, raw: string): (string | Expr)[];
|
|
27
|
+
export declare function objectLiteral(p: Parser): ObjectNode;
|
|
28
|
+
/** `(name: value, …)` after an event name: the event's detail. */
|
|
29
|
+
export declare function namedArgumentList(p: Parser): NamedArgsNode | undefined;
|
|
30
|
+
/** `name: value, …` with no parentheses: `fetch /url with method: "POST"`. */
|
|
31
|
+
export declare function nakedNamedArguments(p: Parser, start?: number): NamedArgsNode;
|
|
32
|
+
/** A quoted string, or bare text up to the next whitespace. */
|
|
33
|
+
export declare function stringLike(p: Parser): string;
|
|
34
|
+
/** A bare URL (`/path`, `https://…`) taken as text, or an expression. */
|
|
35
|
+
export declare function urlOrExpression(p: Parser): Expr;
|
|
36
|
+
export declare function symbol(p: Parser): SymbolNode | undefined;
|
|
37
|
+
export declare function classRef(p: Parser): ClassRefNode | undefined;
|
|
38
|
+
export declare function attributeRef(p: Parser): AttributeRefNode | undefined;
|
|
39
|
+
export declare function styleRef(p: Parser): StyleRefNode | undefined;
|
|
40
|
+
/** `{ color: red; width: ${w}px }` — CSS text for `add` / `remove`. */
|
|
41
|
+
export declare function styleLiteral(p: Parser): StyleLiteralNode | undefined;
|
|
42
|
+
/** The target when a command names none: `you` inside `tell`, otherwise `me`. */
|
|
43
|
+
export declare function implicitMe(p: Parser): ImplicitMeNode;
|
|
44
|
+
/** `a.b.c` or `a:b:c` as plain text: event names and conversion names. */
|
|
45
|
+
export declare function dotOrColonPath(p: Parser): string | undefined;
|
|
46
|
+
export declare function eventName(p: Parser, message?: string): string;
|
|
47
|
+
export declare function indirect(p: Parser, root: Expr): Expr;
|
|
48
|
+
/** Call a function value; a hyperscript-defined function also receives the calling context. */
|
|
49
|
+
export declare function call(f: unknown, receiver: unknown, args: unknown[], ctx: Ctx, source: string): unknown;
|
|
50
|
+
/** `<root>@attr`: an attribute of the root's value. */
|
|
51
|
+
export declare function attributeAccessNode(p: Parser, root: Expr, attribute: AttributeRefNode): AttributeAccessNode;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Features other than `on`: `def`, `init`, `behavior`, `install`, and the
|
|
3
|
+
* top-level `set`. Follows upstream `parsetree/features/*`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Cmd, Feature, Handlers, NamedArgsNode } from './ast';
|
|
6
|
+
import { type SetNode } from './commands/setters';
|
|
7
|
+
import type { Grammar } from './parser';
|
|
8
|
+
export interface DefFeature extends Feature, Handlers {
|
|
9
|
+
type: 'defFeature';
|
|
10
|
+
name: string;
|
|
11
|
+
params: string[];
|
|
12
|
+
body: Cmd[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `def name(params) <commands> [catch …] [finally …] [end]`. The function
|
|
16
|
+
* returns its value directly when its body is synchronous and a promise when it
|
|
17
|
+
* waits; an uncaught error is thrown or rejected the same way.
|
|
18
|
+
*/
|
|
19
|
+
export declare function def(g: Grammar): void;
|
|
20
|
+
export interface InitFeature extends Feature {
|
|
21
|
+
type: 'initFeature';
|
|
22
|
+
body: Cmd[];
|
|
23
|
+
immediately: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** `init [immediately] <commands>`: run once when the element is initialised. */
|
|
26
|
+
export declare function init(g: Grammar): void;
|
|
27
|
+
export interface BehaviorFeature extends Feature {
|
|
28
|
+
type: 'behaviorFeature';
|
|
29
|
+
name: string;
|
|
30
|
+
params: string[];
|
|
31
|
+
features: Feature[];
|
|
32
|
+
}
|
|
33
|
+
/** `behavior Name(params) <features> end`: a reusable set of features, installed by name. */
|
|
34
|
+
export declare function behavior(g: Grammar): void;
|
|
35
|
+
export interface InstallFeature extends Feature {
|
|
36
|
+
type: 'installFeature';
|
|
37
|
+
name: string;
|
|
38
|
+
args?: NamedArgsNode;
|
|
39
|
+
}
|
|
40
|
+
/** `install Name(arg: value, …)`: apply a behavior to this element. */
|
|
41
|
+
export declare function install(g: Grammar): void;
|
|
42
|
+
export interface SetFeature extends Feature {
|
|
43
|
+
type: 'setFeature';
|
|
44
|
+
command: SetNode;
|
|
45
|
+
}
|
|
46
|
+
/** A `set` at the top of a script: initialise an element, global or inherited variable. */
|
|
47
|
+
export declare function setFeature(g: Grammar): void;
|