~repos /gromer

#golang#htmx#ssr

git clone https://pyrossh.dev/repos/gromer.git

gromer is a framework and cli to build multipage web apps in golang using htmx and alpinejs.


614dbec7 Peter John

tag: v0.3.1

v0.3.1

4 years ago
remove example
example/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- # Binaries for programs and plugins
2
- *.exe
3
- *.exe~
4
- *.dll
5
- *.so
6
- *.dylib
7
- *.app
8
-
9
- # Test binary, build with `go test -c`
10
- *.test
11
- test
12
-
13
-
14
- # Output of the go coverage tool, specifically when used with LiteIDE
15
- *.out
16
-
17
- # Static generated files
18
- *.gz
19
- *.gcloudignore
20
- *.wasm
21
- main
example/assets/alpine.js DELETED
@@ -1,5 +0,0 @@
1
- (()=>{var Ie=!1,Le=!1,Y=[];function yt(e){Ir(e)}function Ir(e){Y.includes(e)||Y.push(e),Lr()}function Lr(){!Le&&!Ie&&(Ie=!0,queueMicrotask($r))}function $r(){Ie=!1,Le=!0;for(let e=0;e<Y.length;e++)Y[e]();Y.length=0,Le=!1}var v,M,z,$e,Fe=!0;function xt(e){Fe=!1,e(),Fe=!0}function bt(e){v=e.reactive,z=e.release,M=t=>e.effect(t,{scheduler:r=>{Fe?yt(r):r()}}),$e=e.raw}function je(e){M=e}function vt(e){let t=()=>{};return[n=>{let i=M(n);e._x_effects||(e._x_effects=new Set,e._x_runEffects=()=>{e._x_effects.forEach(o=>o())}),e._x_effects.add(i),t=()=>{i!==void 0&&(e._x_effects.delete(i),z(i))}},()=>{t()}]}var wt=[],Et=[],St=[];function At(e){St.push(e)}function Ot(e){Et.push(e)}function Tt(e){wt.push(e)}function Rt(e,t,r){e._x_attributeCleanups||(e._x_attributeCleanups={}),e._x_attributeCleanups[t]||(e._x_attributeCleanups[t]=[]),e._x_attributeCleanups[t].push(r)}function Ke(e,t){!e._x_attributeCleanups||Object.entries(e._x_attributeCleanups).forEach(([r,n])=>{(t===void 0||t.includes(r))&&n.forEach(i=>i()),delete e._x_attributeCleanups[r]})}var ze=new MutationObserver(Ct),Ve=!1;function He(){ze.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0}),Ve=!0}function Fr(){ze.disconnect(),Ve=!1}var J=[],Be=!1;function Kr(){J=J.concat(ze.takeRecords()),J.length&&!Be&&(Be=!0,queueMicrotask(()=>{jr(),Be=!1}))}function jr(){Ct(J),J.length=0}function m(e){if(!Ve)return e();Kr(),Fr();let t=e();return He(),t}function Ct(e){let t=[],r=[],n=new Map,i=new Map;for(let o=0;o<e.length;o++)if(!e[o].target._x_ignoreMutationObserver&&(e[o].type==="childList"&&(e[o].addedNodes.forEach(s=>s.nodeType===1&&t.push(s)),e[o].removedNodes.forEach(s=>s.nodeType===1&&r.push(s))),e[o].type==="attributes")){let s=e[o].target,a=e[o].attributeName,c=e[o].oldValue,l=()=>{n.has(s)||n.set(s,[]),n.get(s).push({name:a,value:s.getAttribute(a)})},u=()=>{i.has(s)||i.set(s,[]),i.get(s).push(a)};s.hasAttribute(a)&&c===null?l():s.hasAttribute(a)?(u(),l()):u()}i.forEach((o,s)=>{Ke(s,o)}),n.forEach((o,s)=>{wt.forEach(a=>a(s,o))});for(let o of t)r.includes(o)||St.forEach(s=>s(o));for(let o of r)t.includes(o)||Et.forEach(s=>s(o));t=null,r=null,n=null,i=null}function V(e,t,r){return e._x_dataStack=[t,...Z(r||e)],()=>{e._x_dataStack=e._x_dataStack.filter(n=>n!==t)}}function qe(e,t){let r=e._x_dataStack[0];Object.entries(t).forEach(([n,i])=>{r[n]=i})}function Z(e){return e._x_dataStack?e._x_dataStack:typeof ShadowRoot=="function"&&e instanceof ShadowRoot?Z(e.host):e.parentNode?Z(e.parentNode):[]}function Ue(e){return new Proxy({},{ownKeys:()=>Array.from(new Set(e.flatMap(t=>Object.keys(t)))),has:(t,r)=>e.some(n=>n.hasOwnProperty(r)),get:(t,r)=>(e.find(n=>n.hasOwnProperty(r))||{})[r],set:(t,r,n)=>{let i=e.find(o=>o.hasOwnProperty(r));return i?i[r]=n:e[e.length-1][r]=n,!0}})}function Mt(e){let t=n=>typeof n=="object"&&!Array.isArray(n)&&n!==null,r=(n,i="")=>{Object.entries(n).forEach(([o,s])=>{let a=i===""?o:`${i}.${o}`;typeof s=="object"&&s!==null&&s._x_interceptor?n[o]=s.initialize(e,a,o):t(s)&&s!==n&&!(s instanceof Element)&&r(s,a)})};return r(e)}function de(e,t=()=>{}){let r={initialValue:void 0,_x_interceptor:!0,initialize(n,i,o){return e(this.initialValue,()=>zr(n,i),s=>We(n,i,s),i,o)}};return t(r),n=>{if(typeof n=="object"&&n!==null&&n._x_interceptor){let i=r.initialize.bind(r);r.initialize=(o,s,a)=>{let c=n.initialize(o,s,a);return r.initialValue=c,i(o,s,a)}}else r.initialValue=n;return r}}function zr(e,t){return t.split(".").reduce((r,n)=>r[n],e)}function We(e,t,r){if(typeof t=="string"&&(t=t.split(".")),t.length===1)e[t[0]]=r;else{if(t.length===0)throw error;return e[t[0]]||(e[t[0]]={}),We(e[t[0]],t.slice(1),r)}}var Nt={};function x(e,t){Nt[e]=t}function Q(e,t){return Object.entries(Nt).forEach(([r,n])=>{Object.defineProperty(e,`$${r}`,{get(){return n(t,{Alpine:S,interceptor:de})},enumerable:!1})}),e}function b(e,t,r={}){let n;return h(e,t)(i=>n=i,r),n}function h(...e){return kt(...e)}var kt=Ge;function Dt(e){kt=e}function Ge(e,t){let r={};Q(r,e);let n=[r,...Z(e)];if(typeof t=="function")return Vr(n,t);let i=Hr(n,t);return Br.bind(null,e,t,i)}function Vr(e,t){return(r=()=>{},{scope:n={},params:i=[]}={})=>{let o=t.apply(Ue([n,...e]),i);pe(r,o)}}var Ye={};function qr(e){if(Ye[e])return Ye[e];let t=Object.getPrototypeOf(async function(){}).constructor,r=/^[\n\s]*if.*\(.*\)/.test(e)||/^(let|const)/.test(e)?`(() => { ${e} })()`:e,n=new t(["__self","scope"],`with (scope) { __self.result = ${r} }; __self.finished = true; return __self.result;`);return Ye[e]=n,n}function Hr(e,t){let r=qr(t);return(n=()=>{},{scope:i={},params:o=[]}={})=>{r.result=void 0,r.finished=!1;let s=Ue([i,...e]),a=r(r,s);r.finished?pe(n,r.result,s,o):a.then(c=>{pe(n,c,s,o)})}}function pe(e,t,r,n){if(typeof t=="function"){let i=t.apply(r,n);i instanceof Promise?i.then(o=>pe(e,o,r,n)):e(i)}else e(t)}function Br(e,t,r,...n){try{return r(...n)}catch(i){throw console.warn(`Alpine Expression Error: ${i.message}
2
-
3
- Expression: "${t}"
4
-
5
- `,e),i}}var Je="x-";function A(e=""){return Je+e}function Pt(e){Je=e}var It={};function p(e,t){It[e]=t}function X(e,t,r){let n={};return Array.from(t).map(Lt((o,s)=>n[o]=s)).filter($t).map(Wr(n,r)).sort(Gr).map(o=>Ur(e,o))}function Ft(e){return Array.from(e).map(Lt()).filter(t=>!$t(t))}var Ze=!1,ee=new Map,jt=Symbol();function Kt(e){Ze=!0;let t=Symbol();jt=t,ee.set(t,[]);let r=()=>{for(;ee.get(t).length;)ee.get(t).shift()();ee.delete(t)},n=()=>{Ze=!1,r()};e(r),n()}function Ur(e,t){let r=()=>{},n=It[t.type]||r,i=[],o=d=>i.push(d),[s,a]=vt(e);i.push(a);let c={Alpine:S,effect:s,cleanup:o,evaluateLater:h.bind(h,e),evaluate:b.bind(b,e)},l=()=>i.forEach(d=>d());Rt(e,t.original,l);let u=()=>{e._x_ignore||e._x_ignoreSelf||(n.inline&&n.inline(e,t,c),n=n.bind(n,e,t,c),Ze?ee.get(jt).push(n):n())};return u.runCleanups=l,u}var me=(e,t)=>({name:r,value:n})=>(r.startsWith(e)&&(r=r.replace(e,t)),{name:r,value:n}),he=e=>e;function Lt(e=()=>{}){return({name:t,value:r})=>{let{name:n,value:i}=zt.reduce((o,s)=>s(o),{name:t,value:r});return n!==t&&e(n,t),{name:n,value:i}}}var zt=[];function H(e){zt.push(e)}function $t({name:e}){return Vt().test(e)}var Vt=()=>new RegExp(`^${Je}([^:^.]+)\\b`);function Wr(e,t){return({name:r,value:n})=>{let i=r.match(Vt()),o=r.match(/:([a-zA-Z0-9\-:]+)/),s=r.match(/\.[^.\]]+(?=[^\]]*$)/g)||[],a=t||e[r]||r;return{type:i?i[1]:null,value:o?o[1]:null,modifiers:s.map(c=>c.replace(".","")),expression:n,original:a}}}var Qe="DEFAULT",ge=["ignore","ref","data","bind","init","for","model","transition","show","if",Qe,"element"];function Gr(e,t){let r=ge.indexOf(e.type)===-1?Qe:e.type,n=ge.indexOf(t.type)===-1?Qe:t.type;return ge.indexOf(r)-ge.indexOf(n)}function $(e,t,r={}){e.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0,cancelable:!0}))}var Xe=[],et=!1;function B(e){Xe.push(e),queueMicrotask(()=>{et||setTimeout(()=>{_e()})})}function _e(){for(et=!1;Xe.length;)Xe.shift()()}function Ht(){et=!0}function k(e,t){if(typeof ShadowRoot=="function"&&e instanceof ShadowRoot){Array.from(e.children).forEach(i=>k(i,t));return}let r=!1;if(t(e,()=>r=!0),r)return;let n=e.firstElementChild;for(;n;)k(n,t,!1),n=n.nextElementSibling}function ye(e,...t){console.warn(`Alpine Warning: ${e}`,...t)}function Bt(){document.body||ye("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"),$(document,"alpine:init"),$(document,"alpine:initializing"),He(),At(t=>T(t,k)),Ot(t=>B(()=>Jr(t))),Tt((t,r)=>{X(t,r).forEach(n=>n())});let e=t=>!O(t.parentElement);Array.from(document.querySelectorAll(Yr())).filter(e).forEach(t=>{T(t)}),$(document,"alpine:initialized")}var tt=[],qt=[];function Ut(){return tt.map(e=>e())}function Yr(){return tt.concat(qt).map(e=>e())}function xe(e){tt.push(e)}function Wt(e){qt.push(e)}function O(e){if(!!e){if(Ut().some(t=>e.matches(t)))return e;if(!!e.parentElement)return O(e.parentElement)}}function Gt(e){return Ut().some(t=>e.matches(t))}function T(e,t=k){Kt(()=>{t(e,(r,n)=>{X(r,r.attributes).forEach(i=>i()),r._x_ignore&&n()})})}function Jr(e){k(e,t=>Ke(t))}function be(e,t){var r;return function(){var n=this,i=arguments,o=function(){r=null,e.apply(n,i)};clearTimeout(r),r=setTimeout(o,t)}}function ve(e,t){let r;return function(){let n=this,i=arguments;r||(e.apply(n,i),r=!0,setTimeout(()=>r=!1,t))}}function Yt(e){e(S)}var q={},Jt=!1;function Zt(e,t){if(Jt||(q=v(q),Jt=!0),t===void 0)return q[e];q[e]=t,typeof t=="object"&&t!==null&&t.hasOwnProperty("init")&&typeof t.init=="function"&&q[e].init()}function Qt(){return q}var rt=!1;function U(e){return(...t)=>rt||e(...t)}function Xt(e,t){t._x_dataStack=e._x_dataStack,rt=!0,Qr(()=>{Zr(t)}),rt=!1}function Zr(e){let t=!1;T(e,(n,i)=>{k(n,(o,s)=>{if(t&&Gt(o))return s();t=!0,i(o,s)})})}function Qr(e){let t=M;je((r,n)=>{let i=t(r);return z(i),()=>{}}),e(),je(t)}var er={};function tr(e,t){er[e]=t}function rr(e,t){return Object.entries(er).forEach(([r,n])=>{Object.defineProperty(e,r,{get(){return(...i)=>n.bind(t)(...i)},enumerable:!1})}),e}var Xr={get reactive(){return v},get release(){return z},get effect(){return M},get raw(){return $e},version:"3.3.3",disableEffectScheduling:xt,setReactivityEngine:bt,addRootSelector:xe,mapAttributes:H,evaluateLater:h,setEvaluator:Dt,closestRoot:O,interceptor:de,mutateDom:m,directive:p,throttle:ve,debounce:be,evaluate:b,initTree:T,nextTick:B,prefix:Pt,plugin:Yt,magic:x,store:Zt,start:Bt,clone:Xt,data:tr},S=Xr;function nt(e,t){let r=Object.create(null),n=e.split(",");for(let i=0;i<n.length;i++)r[n[i]]=!0;return t?i=>!!r[i.toLowerCase()]:i=>!!r[i]}var so={[1]:"TEXT",[2]:"CLASS",[4]:"STYLE",[8]:"PROPS",[16]:"FULL_PROPS",[32]:"HYDRATE_EVENTS",[64]:"STABLE_FRAGMENT",[128]:"KEYED_FRAGMENT",[256]:"UNKEYED_FRAGMENT",[512]:"NEED_PATCH",[1024]:"DYNAMIC_SLOTS",[2048]:"DEV_ROOT_FRAGMENT",[-1]:"HOISTED",[-2]:"BAIL"},ao={[1]:"STABLE",[2]:"DYNAMIC",[3]:"FORWARDED"};var en="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";var co=nt(en+",async,autofocus,autoplay,controls,default,defer,disabled,hidden,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected");var nr=Object.freeze({}),lo=Object.freeze([]);var it=Object.assign;var tn=Object.prototype.hasOwnProperty,te=(e,t)=>tn.call(e,t),D=Array.isArray,W=e=>ir(e)==="[object Map]";var rn=e=>typeof e=="string",we=e=>typeof e=="symbol",re=e=>e!==null&&typeof e=="object";var nn=Object.prototype.toString,ir=e=>nn.call(e),ot=e=>ir(e).slice(8,-1);var Ee=e=>rn(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e;var Se=e=>{let t=Object.create(null);return r=>t[r]||(t[r]=e(r))},on=/-(\w)/g,uo=Se(e=>e.replace(on,(t,r)=>r?r.toUpperCase():"")),sn=/\B([A-Z])/g,fo=Se(e=>e.replace(sn,"-$1").toLowerCase()),st=Se(e=>e.charAt(0).toUpperCase()+e.slice(1)),po=Se(e=>e?`on${st(e)}`:""),at=(e,t)=>e!==t&&(e===e||t===t);var ct=new WeakMap,ne=[],R,F=Symbol("iterate"),lt=Symbol("Map key iterate");function an(e){return e&&e._isEffect===!0}function or(e,t=nr){an(e)&&(e=e.raw);let r=cn(e,t);return t.lazy||r(),r}function ar(e){e.active&&(sr(e),e.options.onStop&&e.options.onStop(),e.active=!1)}var ln=0;function cn(e,t){let r=function(){if(!r.active)return e();if(!ne.includes(r)){sr(r);try{return un(),ne.push(r),R=r,e()}finally{ne.pop(),cr(),R=ne[ne.length-1]}}};return r.id=ln++,r.allowRecurse=!!t.allowRecurse,r._isEffect=!0,r.active=!0,r.raw=e,r.deps=[],r.options=t,r}function sr(e){let{deps:t}=e;if(t.length){for(let r=0;r<t.length;r++)t[r].delete(e);t.length=0}}var G=!0,ut=[];function fn(){ut.push(G),G=!1}function un(){ut.push(G),G=!0}function cr(){let e=ut.pop();G=e===void 0?!0:e}function w(e,t,r){if(!G||R===void 0)return;let n=ct.get(e);n||ct.set(e,n=new Map);let i=n.get(r);i||n.set(r,i=new Set),i.has(R)||(i.add(R),R.deps.push(i),R.options.onTrack&&R.options.onTrack({effect:R,target:e,type:t,key:r}))}function P(e,t,r,n,i,o){let s=ct.get(e);if(!s)return;let a=new Set,c=u=>{u&&u.forEach(d=>{(d!==R||d.allowRecurse)&&a.add(d)})};if(t==="clear")s.forEach(c);else if(r==="length"&&D(e))s.forEach((u,d)=>{(d==="length"||d>=n)&&c(u)});else switch(r!==void 0&&c(s.get(r)),t){case"add":D(e)?Ee(r)&&c(s.get("length")):(c(s.get(F)),W(e)&&c(s.get(lt)));break;case"delete":D(e)||(c(s.get(F)),W(e)&&c(s.get(lt)));break;case"set":W(e)&&c(s.get(F));break}let l=u=>{u.options.onTrigger&&u.options.onTrigger({effect:u,target:e,key:r,type:t,newValue:n,oldValue:i,oldTarget:o}),u.options.scheduler?u.options.scheduler(u):u()};a.forEach(l)}var dn=nt("__proto__,__v_isRef,__isVue"),lr=new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(we)),pn=Ae(),mn=Ae(!1,!0),hn=Ae(!0),gn=Ae(!0,!0),Oe={};["includes","indexOf","lastIndexOf"].forEach(e=>{let t=Array.prototype[e];Oe[e]=function(...r){let n=g(this);for(let o=0,s=this.length;o<s;o++)w(n,"get",o+"");let i=t.apply(n,r);return i===-1||i===!1?t.apply(n,r.map(g)):i}});["push","pop","shift","unshift","splice"].forEach(e=>{let t=Array.prototype[e];Oe[e]=function(...r){fn();let n=t.apply(this,r);return cr(),n}});function Ae(e=!1,t=!1){return function(n,i,o){if(i==="__v_isReactive")return!e;if(i==="__v_isReadonly")return e;if(i==="__v_raw"&&o===(e?t?yn:fr:t?_n:ur).get(n))return n;let s=D(n);if(!e&&s&&te(Oe,i))return Reflect.get(Oe,i,o);let a=Reflect.get(n,i,o);return(we(i)?lr.has(i):dn(i))||(e||w(n,"get",i),t)?a:ft(a)?!s||!Ee(i)?a.value:a:re(a)?e?dr(a):Te(a):a}}var xn=pr(),bn=pr(!0);function pr(e=!1){return function(r,n,i,o){let s=r[n];if(!e&&(i=g(i),s=g(s),!D(r)&&ft(s)&&!ft(i)))return s.value=i,!0;let a=D(r)&&Ee(n)?Number(n)<r.length:te(r,n),c=Reflect.set(r,n,i,o);return r===g(o)&&(a?at(i,s)&&P(r,"set",n,i,s):P(r,"add",n,i)),c}}function vn(e,t){let r=te(e,t),n=e[t],i=Reflect.deleteProperty(e,t);return i&&r&&P(e,"delete",t,void 0,n),i}function wn(e,t){let r=Reflect.has(e,t);return(!we(t)||!lr.has(t))&&w(e,"has",t),r}function En(e){return w(e,"iterate",D(e)?"length":F),Reflect.ownKeys(e)}var mr={get:pn,set:xn,deleteProperty:vn,has:wn,ownKeys:En},hr={get:hn,set(e,t){return console.warn(`Set operation on key "${String(t)}" failed: target is readonly.`,e),!0},deleteProperty(e,t){return console.warn(`Delete operation on key "${String(t)}" failed: target is readonly.`,e),!0}},xo=it({},mr,{get:mn,set:bn}),bo=it({},hr,{get:gn}),dt=e=>re(e)?Te(e):e,pt=e=>re(e)?dr(e):e,mt=e=>e,Re=e=>Reflect.getPrototypeOf(e);function Ce(e,t,r=!1,n=!1){e=e.__v_raw;let i=g(e),o=g(t);t!==o&&!r&&w(i,"get",t),!r&&w(i,"get",o);let{has:s}=Re(i),a=n?mt:r?pt:dt;if(s.call(i,t))return a(e.get(t));if(s.call(i,o))return a(e.get(o));e!==i&&e.get(t)}function Me(e,t=!1){let r=this.__v_raw,n=g(r),i=g(e);return e!==i&&!t&&w(n,"has",e),!t&&w(n,"has",i),e===i?r.has(e):r.has(e)||r.has(i)}function Ne(e,t=!1){return e=e.__v_raw,!t&&w(g(e),"iterate",F),Reflect.get(e,"size",e)}function gr(e){e=g(e);let t=g(this);return Re(t).has.call(t,e)||(t.add(e),P(t,"add",e,e)),this}function yr(e,t){t=g(t);let r=g(this),{has:n,get:i}=Re(r),o=n.call(r,e);o?_r(r,n,e):(e=g(e),o=n.call(r,e));let s=i.call(r,e);return r.set(e,t),o?at(t,s)&&P(r,"set",e,t,s):P(r,"add",e,t),this}function xr(e){let t=g(this),{has:r,get:n}=Re(t),i=r.call(t,e);i?_r(t,r,e):(e=g(e),i=r.call(t,e));let o=n?n.call(t,e):void 0,s=t.delete(e);return i&&P(t,"delete",e,void 0,o),s}function br(){let e=g(this),t=e.size!==0,r=W(e)?new Map(e):new Set(e),n=e.clear();return t&&P(e,"clear",void 0,void 0,r),n}function ke(e,t){return function(n,i){let o=this,s=o.__v_raw,a=g(s),c=t?mt:e?pt:dt;return!e&&w(a,"iterate",F),s.forEach((l,u)=>n.call(i,c(l),c(u),o))}}function De(e,t,r){return function(...n){let i=this.__v_raw,o=g(i),s=W(o),a=e==="entries"||e===Symbol.iterator&&s,c=e==="keys"&&s,l=i[e](...n),u=r?mt:t?pt:dt;return!t&&w(o,"iterate",c?lt:F),{next(){let{value:d,done:E}=l.next();return E?{value:d,done:E}:{value:a?[u(d[0]),u(d[1])]:u(d),done:E}},[Symbol.iterator](){return this}}}}function I(e){return function(...t){{let r=t[0]?`on key "${t[0]}" `:"";console.warn(`${st(e)} operation ${r}failed: target is readonly.`,g(this))}return e==="delete"?!1:this}}var vr={get(e){return Ce(this,e)},get size(){return Ne(this)},has:Me,add:gr,set:yr,delete:xr,clear:br,forEach:ke(!1,!1)},wr={get(e){return Ce(this,e,!1,!0)},get size(){return Ne(this)},has:Me,add:gr,set:yr,delete:xr,clear:br,forEach:ke(!1,!0)},Er={get(e){return Ce(this,e,!0)},get size(){return Ne(this,!0)},has(e){return Me.call(this,e,!0)},add:I("add"),set:I("set"),delete:I("delete"),clear:I("clear"),forEach:ke(!0,!1)},Sr={get(e){return Ce(this,e,!0,!0)},get size(){return Ne(this,!0)},has(e){return Me.call(this,e,!0)},add:I("add"),set:I("set"),delete:I("delete"),clear:I("clear"),forEach:ke(!0,!0)},Sn=["keys","values","entries",Symbol.iterator];Sn.forEach(e=>{vr[e]=De(e,!1,!1),Er[e]=De(e,!0,!1),wr[e]=De(e,!1,!0),Sr[e]=De(e,!0,!0)});function Pe(e,t){let r=t?e?Sr:wr:e?Er:vr;return(n,i,o)=>i==="__v_isReactive"?!e:i==="__v_isReadonly"?e:i==="__v_raw"?n:Reflect.get(te(r,i)&&i in n?r:n,i,o)}var An={get:Pe(!1,!1)},vo={get:Pe(!1,!0)},On={get:Pe(!0,!1)},wo={get:Pe(!0,!0)};function _r(e,t,r){let n=g(r);if(n!==r&&t.call(e,n)){let i=ot(e);console.warn(`Reactive ${i} contains both the raw and reactive versions of the same object${i==="Map"?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}var ur=new WeakMap,_n=new WeakMap,fr=new WeakMap,yn=new WeakMap;function Tn(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Rn(e){return e.__v_skip||!Object.isExtensible(e)?0:Tn(ot(e))}function Te(e){return e&&e.__v_isReadonly?e:Ar(e,!1,mr,An,ur)}function dr(e){return Ar(e,!0,hr,On,fr)}function Ar(e,t,r,n,i){if(!re(e))return console.warn(`value cannot be made reactive: ${String(e)}`),e;if(e.__v_raw&&!(t&&e.__v_isReactive))return e;let o=i.get(e);if(o)return o;let s=Rn(e);if(s===0)return e;let a=new Proxy(e,s===2?n:r);return i.set(e,a),a}function g(e){return e&&g(e.__v_raw)||e}function ft(e){return Boolean(e&&e.__v_isRef===!0)}x("nextTick",()=>B);x("dispatch",e=>$.bind($,e));x("watch",e=>(t,r)=>{let n=h(e,t),i=!0,o;M(()=>n(s=>{let a=document.createElement("div");a.dataset.throwAway=s,i?o=s:queueMicrotask(()=>{r(s,o),o=s}),i=!1}))});x("store",Qt);x("root",e=>O(e));x("refs",e=>O(e)._x_refs||{});x("el",e=>e);function ie(e,t){return Array.isArray(t)?Or(e,t.join(" ")):typeof t=="object"&&t!==null?Cn(e,t):typeof t=="function"?ie(e,t()):Or(e,t)}function Or(e,t){let r=o=>o.split(" ").filter(Boolean),n=o=>o.split(" ").filter(s=>!e.classList.contains(s)).filter(Boolean),i=o=>(e.classList.add(...o),()=>{e.classList.remove(...o)});return t=t===!0?t="":t||"",i(n(t))}function Cn(e,t){let r=a=>a.split(" ").filter(Boolean),n=Object.entries(t).flatMap(([a,c])=>c?r(a):!1).filter(Boolean),i=Object.entries(t).flatMap(([a,c])=>c?!1:r(a)).filter(Boolean),o=[],s=[];return i.forEach(a=>{e.classList.contains(a)&&(e.classList.remove(a),s.push(a))}),n.forEach(a=>{e.classList.contains(a)||(e.classList.add(a),o.push(a))}),()=>{s.forEach(a=>e.classList.add(a)),o.forEach(a=>e.classList.remove(a))}}function oe(e,t){return typeof t=="object"&&t!==null?Mn(e,t):Nn(e,t)}function Mn(e,t){let r={};return Object.entries(t).forEach(([n,i])=>{r[n]=e.style[n],e.style.setProperty(kn(n),i)}),setTimeout(()=>{e.style.length===0&&e.removeAttribute("style")}),()=>{oe(e,r)}}function Nn(e,t){let r=e.getAttribute("style",t);return e.setAttribute("style",t),()=>{e.setAttribute("style",r)}}function kn(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function se(e,t=()=>{}){let r=!1;return function(){r?t.apply(this,arguments):(r=!0,e.apply(this,arguments))}}p("transition",(e,{value:t,modifiers:r,expression:n},{evaluate:i})=>{typeof n=="function"&&(n=i(n)),n?Dn(e,n,t):Pn(e,r,t)});function Dn(e,t,r){Tr(e,ie,""),{enter:i=>{e._x_transition.enter.during=i},"enter-start":i=>{e._x_transition.enter.start=i},"enter-end":i=>{e._x_transition.enter.end=i},leave:i=>{e._x_transition.leave.during=i},"leave-start":i=>{e._x_transition.leave.start=i},"leave-end":i=>{e._x_transition.leave.end=i}}[r](t)}function Pn(e,t,r){Tr(e,oe);let n=!t.includes("in")&&!t.includes("out")&&!r,i=n||t.includes("in")||["enter"].includes(r),o=n||t.includes("out")||["leave"].includes(r);t.includes("in")&&!n&&(t=t.filter((_,y)=>y<t.indexOf("out"))),t.includes("out")&&!n&&(t=t.filter((_,y)=>y>t.indexOf("out")));let s=!t.includes("opacity")&&!t.includes("scale"),a=s||t.includes("opacity"),c=s||t.includes("scale"),l=a?0:1,u=c?ae(t,"scale",95)/100:1,d=ae(t,"delay",0),E=ae(t,"origin","center"),L="opacity, transform",j=ae(t,"duration",150)/1e3,ue=ae(t,"duration",75)/1e3,f="cubic-bezier(0.4, 0.0, 0.2, 1)";i&&(e._x_transition.enter.during={transformOrigin:E,transitionDelay:d,transitionProperty:L,transitionDuration:`${j}s`,transitionTimingFunction:f},e._x_transition.enter.start={opacity:l,transform:`scale(${u})`},e._x_transition.enter.end={opacity:1,transform:"scale(1)"}),o&&(e._x_transition.leave.during={transformOrigin:E,transitionDelay:d,transitionProperty:L,transitionDuration:`${ue}s`,transitionTimingFunction:f},e._x_transition.leave.start={opacity:1,transform:"scale(1)"},e._x_transition.leave.end={opacity:l,transform:`scale(${u})`})}function Tr(e,t,r={}){e._x_transition||(e._x_transition={enter:{during:r,start:r,end:r},leave:{during:r,start:r,end:r},in(n=()=>{},i=()=>{}){Rr(e,t,{during:this.enter.during,start:this.enter.start,end:this.enter.end,entering:!0},n,i)},out(n=()=>{},i=()=>{}){Rr(e,t,{during:this.leave.during,start:this.leave.start,end:this.leave.end,entering:!1},n,i)}})}window.Element.prototype._x_toggleAndCascadeWithTransitions=function(e,t,r,n){let i=()=>requestAnimationFrame(r);if(t){e._x_transition?e._x_transition.in(r):i();return}e._x_hidePromise=e._x_transition?new Promise((o,s)=>{e._x_transition.out(()=>{},()=>o(n)),e._x_transitioning.beforeCancel(()=>s({isFromCancelledTransition:!0}))}):Promise.resolve(n),queueMicrotask(()=>{let o=Cr(e);o?(o._x_hideChildren||(o._x_hideChildren=[]),o._x_hideChildren.push(e)):queueMicrotask(()=>{let s=a=>{let c=Promise.all([a._x_hidePromise,...(a._x_hideChildren||[]).map(s)]).then(([l])=>l());return delete a._x_hidePromise,delete a._x_hideChildren,c};s(e).catch(a=>{if(!a.isFromCancelledTransition)throw a})})})};function Cr(e){let t=e.parentNode;if(!!t)return t._x_hidePromise?t:Cr(t)}function Rr(e,t,{during:r,start:n,end:i,entering:o}={},s=()=>{},a=()=>{}){if(e._x_transitioning&&e._x_transitioning.cancel(),Object.keys(r).length===0&&Object.keys(n).length===0&&Object.keys(i).length===0){s(),a();return}let c,l,u;In(e,{start(){c=t(e,n)},during(){l=t(e,r)},before:s,end(){c(),u=t(e,i)},after:a,cleanup(){l(),u()}},o)}function In(e,t,r){let n,i,o,s=se(()=>{m(()=>{n=!0,i||t.before(),o||(t.end(),_e()),t.after(),e.isConnected&&t.cleanup(),delete e._x_transitioning})});e._x_transitioning={beforeCancels:[],beforeCancel(a){this.beforeCancels.push(a)},cancel:se(function(){for(;this.beforeCancels.length;)this.beforeCancels.shift()();s()}),finish:s,entering:r},m(()=>{t.start(),t.during()}),Ht(),requestAnimationFrame(()=>{if(n)return;let a=Number(getComputedStyle(e).transitionDuration.replace(/,.*/,"").replace("s",""))*1e3,c=Number(getComputedStyle(e).transitionDelay.replace(/,.*/,"").replace("s",""))*1e3;a===0&&(a=Number(getComputedStyle(e).animationDuration.replace("s",""))*1e3),m(()=>{t.before()}),i=!0,requestAnimationFrame(()=>{n||(m(()=>{t.end()}),_e(),setTimeout(e._x_transitioning.finish,a+c),o=!0)})})}function ae(e,t,r){if(e.indexOf(t)===-1)return r;let n=e[e.indexOf(t)+1];if(!n||t==="scale"&&isNaN(n))return r;if(t==="duration"){let i=n.match(/([0-9]+)ms/);if(i)return i[1]}return t==="origin"&&["top","right","left","center","bottom"].includes(e[e.indexOf(t)+2])?[n,e[e.indexOf(t)+2]].join(" "):n}var Mr=()=>{};Mr.inline=(e,{modifiers:t},{cleanup:r})=>{t.includes("self")?e._x_ignoreSelf=!0:e._x_ignore=!0,r(()=>{t.includes("self")?delete e._x_ignoreSelf:delete e._x_ignore})};p("ignore",Mr);p("effect",(e,{expression:t},{effect:r})=>r(h(e,t)));function ce(e,t,r,n=[]){switch(e._x_bindings||(e._x_bindings=v({})),e._x_bindings[t]=r,t=n.includes("camel")?Kn(t):t,t){case"value":Ln(e,r);break;case"style":Fn(e,r);break;case"class":$n(e,r);break;default:jn(e,t,r);break}}function Ln(e,t){if(e.type==="radio")e.attributes.value===void 0&&(e.value=t),window.fromModel&&(e.checked=Nr(e.value,t));else if(e.type==="checkbox")Number.isInteger(t)?e.value=t:!Number.isInteger(t)&&!Array.isArray(t)&&typeof t!="boolean"&&![null,void 0].includes(t)?e.value=String(t):Array.isArray(t)?e.checked=t.some(r=>Nr(r,e.value)):e.checked=!!t;else if(e.tagName==="SELECT")zn(e,t);else{if(e.value===t)return;e.value=t}}function $n(e,t){e._x_undoAddedClasses&&e._x_undoAddedClasses(),e._x_undoAddedClasses=ie(e,t)}function Fn(e,t){e._x_undoAddedStyles&&e._x_undoAddedStyles(),e._x_undoAddedStyles=oe(e,t)}function jn(e,t,r){[null,void 0,!1].includes(r)&&Bn(t)?e.removeAttribute(t):(Hn(t)&&(r=t),Vn(e,t,r))}function Vn(e,t,r){e.getAttribute(t)!=r&&e.setAttribute(t,r)}function zn(e,t){let r=[].concat(t).map(n=>n+"");Array.from(e.options).forEach(n=>{n.selected=r.includes(n.value)})}function Kn(e){return e.toLowerCase().replace(/-(\w)/g,(t,r)=>r.toUpperCase())}function Nr(e,t){return e==t}function Hn(e){return["disabled","checked","required","readonly","hidden","open","selected","autofocus","itemscope","multiple","novalidate","allowfullscreen","allowpaymentrequest","formnovalidate","autoplay","controls","loop","muted","playsinline","default","ismap","reversed","async","defer","nomodule"].includes(e)}function Bn(e){return!["aria-pressed","aria-checked"].includes(e)}function le(e,t,r,n){let i=e,o=c=>n(c),s={},a=(c,l)=>u=>l(c,u);if(r.includes("dot")&&(t=qn(t)),r.includes("camel")&&(t=Un(t)),r.includes("passive")&&(s.passive=!0),r.includes("window")&&(i=window),r.includes("document")&&(i=document),r.includes("prevent")&&(o=a(o,(c,l)=>{l.preventDefault(),c(l)})),r.includes("stop")&&(o=a(o,(c,l)=>{l.stopPropagation(),c(l)})),r.includes("self")&&(o=a(o,(c,l)=>{l.target===e&&c(l)})),(r.includes("away")||r.includes("outside"))&&(i=document,o=a(o,(c,l)=>{e.contains(l.target)||e.offsetWidth<1&&e.offsetHeight<1||c(l)})),o=a(o,(c,l)=>{Wn(t)&&Gn(l,r)||c(l)}),r.includes("debounce")){let c=r[r.indexOf("debounce")+1]||"invalid-wait",l=ht(c.split("ms")[0])?Number(c.split("ms")[0]):250;o=be(o,l)}if(r.includes("throttle")){let c=r[r.indexOf("throttle")+1]||"invalid-wait",l=ht(c.split("ms")[0])?Number(c.split("ms")[0]):250;o=ve(o,l)}return r.includes("once")&&(o=a(o,(c,l)=>{c(l),i.removeEventListener(t,o,s)})),i.addEventListener(t,o,s),()=>{i.removeEventListener(t,o,s)}}function qn(e){return e.replace(/-/g,".")}function Un(e){return e.toLowerCase().replace(/-(\w)/g,(t,r)=>r.toUpperCase())}function ht(e){return!Array.isArray(e)&&!isNaN(e)}function Yn(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]/,"-").toLowerCase()}function Wn(e){return["keydown","keyup"].includes(e)}function Gn(e,t){let r=t.filter(o=>!["window","document","prevent","stop","once"].includes(o));if(r.includes("debounce")){let o=r.indexOf("debounce");r.splice(o,ht((r[o+1]||"invalid-wait").split("ms")[0])?2:1)}if(r.length===0||r.length===1&&kr(e.key).includes(r[0]))return!1;let i=["ctrl","shift","alt","meta","cmd","super"].filter(o=>r.includes(o));return r=r.filter(o=>!i.includes(o)),!(i.length>0&&i.filter(s=>((s==="cmd"||s==="super")&&(s="meta"),e[`${s}Key`])).length===i.length&&kr(e.key).includes(r[0]))}function kr(e){if(!e)return[];e=Yn(e);let t={ctrl:"control",slash:"/",space:"-",spacebar:"-",cmd:"meta",esc:"escape",up:"arrow-up",down:"arrow-down",left:"arrow-left",right:"arrow-right",period:".",equal:"="};return t[e]=e,Object.keys(t).map(r=>{if(t[r]===e)return r}).filter(r=>r)}p("model",(e,{modifiers:t,expression:r},{effect:n,cleanup:i})=>{let o=h(e,r),s=`${r} = rightSideOfExpression($event, ${r})`,a=h(e,s);var c=e.tagName.toLowerCase()==="select"||["checkbox","radio"].includes(e.type)||t.includes("lazy")?"change":"input";let l=Jn(e,t,r),u=le(e,c,t,d=>{a(()=>{},{scope:{$event:d,rightSideOfExpression:l}})});i(()=>u()),e._x_forceModelUpdate=()=>{o(d=>{d===void 0&&r.match(/\./)&&(d=""),window.fromModel=!0,m(()=>ce(e,"value",d)),delete window.fromModel})},n(()=>{t.includes("unintrusive")&&document.activeElement.isSameNode(e)||e._x_forceModelUpdate()})});function Jn(e,t,r){return e.type==="radio"&&m(()=>{e.hasAttribute("name")||e.setAttribute("name",r)}),(n,i)=>m(()=>{if(n instanceof CustomEvent&&n.detail!==void 0)return n.detail||n.target.value;if(e.type==="checkbox")if(Array.isArray(i)){let o=t.includes("number")?gt(n.target.value):n.target.value;return n.target.checked?i.concat([o]):i.filter(s=>!Zn(s,o))}else return n.target.checked;else{if(e.tagName.toLowerCase()==="select"&&e.multiple)return t.includes("number")?Array.from(n.target.selectedOptions).map(o=>{let s=o.value||o.text;return gt(s)}):Array.from(n.target.selectedOptions).map(o=>o.value||o.text);{let o=n.target.value;return t.includes("number")?gt(o):t.includes("trim")?o.trim():o}}})}function gt(e){let t=e?parseFloat(e):null;return Qn(t)?t:e}function Zn(e,t){return e==t}function Qn(e){return!Array.isArray(e)&&!isNaN(e)}p("cloak",e=>queueMicrotask(()=>m(()=>e.removeAttribute(A("cloak")))));Wt(()=>`[${A("init")}]`);p("init",U((e,{expression:t})=>typeof t=="string"?!!t.trim()&&b(e,t,{},!1):b(e,t,{},!1)));p("text",(e,{expression:t},{effect:r,evaluateLater:n})=>{let i=n(t);r(()=>{i(o=>{m(()=>{e.textContent=o})})})});p("html",(e,{expression:t},{effect:r,evaluateLater:n})=>{let i=n(t);r(()=>{i(o=>{e.innerHTML=o})})});H(me(":",he(A("bind:"))));p("bind",(e,{value:t,modifiers:r,expression:n,original:i},{effect:o})=>{if(!t)return Xn(e,n,i,o);if(t==="key")return ei(e,n);let s=h(e,n);o(()=>s(a=>{a===void 0&&n.match(/\./)&&(a=""),m(()=>ce(e,t,a,r))}))});function Xn(e,t,r,n){let i=h(e,t),o=[];n(()=>{for(;o.length;)o.pop()();i(s=>{let a=Object.entries(s).map(([c,l])=>({name:c,value:l}));Ft(a).forEach(({name:c,value:l},u)=>{a[u]={name:`x-bind:${c}`,value:`"${l}"`}}),X(e,a,r).map(c=>{o.push(c.runCleanups),c()})})})}function ei(e,t){e._x_keyExpression=t}xe(()=>`[${A("data")}]`);p("data",U((e,{expression:t},{cleanup:r})=>{t=t===""?"{}":t;let n={};Q(n,e);let i={};rr(i,n);let o=b(e,t,{scope:i});Q(o,e);let s=v(o);Mt(s);let a=V(e,s);s.init&&b(e,s.init),r(()=>{a(),s.destroy&&b(e,s.destroy)})}));p("show",(e,{modifiers:t,expression:r},{effect:n})=>{let i=h(e,r),o=()=>m(()=>{e.style.display="none",e._x_isShown=!1}),s=()=>m(()=>{e.style.length===1&&e.style.display==="none"?e.removeAttribute("style"):e.style.removeProperty("display"),e._x_isShown=!0}),a=()=>setTimeout(s),c=se(d=>d?s():o(),d=>{typeof e._x_toggleAndCascadeWithTransitions=="function"?e._x_toggleAndCascadeWithTransitions(e,d,s,o):d?a():o()}),l,u=!0;n(()=>i(d=>{!u&&d===l||(t.includes("immediate")&&(d?a():o()),c(d),l=d,u=!1)}))});p("for",(e,{expression:t},{effect:r,cleanup:n})=>{let i=ri(t),o=h(e,i.items),s=h(e,e._x_keyExpression||"index");e._x_prevKeys=[],e._x_lookup={},r(()=>ti(e,i,o,s)),n(()=>{Object.values(e._x_lookup).forEach(a=>a.remove()),delete e._x_prevKeys,delete e._x_lookup})});function ti(e,t,r,n){let i=s=>typeof s=="object"&&!Array.isArray(s),o=e;r(s=>{ni(s)&&s>=0&&(s=Array.from(Array(s).keys(),f=>f+1)),s===void 0&&(s=[]);let a=e._x_lookup,c=e._x_prevKeys,l=[],u=[];if(i(s))s=Object.entries(s).map(([f,_])=>{let y=Dr(t,_,f,s);n(C=>u.push(C),{scope:{index:f,...y}}),l.push(y)});else for(let f=0;f<s.length;f++){let _=Dr(t,s[f],f,s);n(y=>u.push(y),{scope:{index:f,..._}}),l.push(_)}let d=[],E=[],L=[],j=[];for(let f=0;f<c.length;f++){let _=c[f];u.indexOf(_)===-1&&L.push(_)}c=c.filter(f=>!L.includes(f));let ue="template";for(let f=0;f<u.length;f++){let _=u[f],y=c.indexOf(_);if(y===-1)c.splice(f,0,_),d.push([ue,f]);else if(y!==f){let C=c.splice(f,1)[0],N=c.splice(y-1,1)[0];c.splice(f,0,N),c.splice(y,0,C),E.push([C,N])}else j.push(_);ue=_}for(let f=0;f<L.length;f++){let _=L[f];a[_].remove(),a[_]=null,delete a[_]}for(let f=0;f<E.length;f++){let[_,y]=E[f],C=a[_],N=a[y],K=document.createElement("div");m(()=>{N.after(K),C.after(N),K.before(C),K.remove()}),qe(N,l[u.indexOf(y)])}for(let f=0;f<d.length;f++){let[_,y]=d[f],C=_==="template"?o:a[_],N=l[y],K=u[y],fe=document.importNode(o.content,!0).firstElementChild;V(fe,v(N),o),m(()=>{C.after(fe),T(fe)}),typeof K=="object"&&ye("x-for key cannot be an object, it must be a string or an integer",o),a[K]=fe}for(let f=0;f<j.length;f++)qe(a[j[f]],l[u.indexOf(j[f])]);o._x_prevKeys=u})}function ri(e){let t=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,r=/^\s*\(|\)\s*$/g,n=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,i=e.match(n);if(!i)return;let o={};o.items=i[2].trim();let s=i[1].replace(r,"").trim(),a=s.match(t);return a?(o.item=s.replace(t,"").trim(),o.index=a[1].trim(),a[2]&&(o.collection=a[2].trim())):o.item=s,o}function Dr(e,t,r,n){let i={};return/^\[.*\]$/.test(e.item)&&Array.isArray(t)?e.item.replace("[","").replace("]","").split(",").map(s=>s.trim()).forEach((s,a)=>{i[s]=t[a]}):/^\{.*\}$/.test(e.item)&&!Array.isArray(t)&&typeof t=="object"?e.item.replace("{","").replace("}","").split(",").map(s=>s.trim()).forEach(s=>{i[s]=t[s]}):i[e.item]=t,e.index&&(i[e.index]=r),e.collection&&(i[e.collection]=n),i}function ni(e){return!Array.isArray(e)&&!isNaN(e)}function Pr(){}Pr.inline=(e,{expression:t},{cleanup:r})=>{let n=O(e);n._x_refs||(n._x_refs={}),n._x_refs[t]=e,r(()=>delete n._x_refs[t])};p("ref",Pr);p("if",(e,{expression:t},{effect:r,cleanup:n})=>{let i=h(e,t),o=()=>{if(e._x_currentIfEl)return e._x_currentIfEl;let a=e.content.cloneNode(!0).firstElementChild;return V(a,{},e),m(()=>{e.after(a),T(a)}),e._x_currentIfEl=a,e._x_undoIf=()=>{a.remove(),delete e._x_currentIfEl},a},s=()=>{!e._x_undoIf||(e._x_undoIf(),delete e._x_undoIf)};r(()=>i(a=>{a?o():s()})),n(()=>e._x_undoIf&&e._x_undoIf())});H(me("@",he(A("on:"))));p("on",U((e,{value:t,modifiers:r,expression:n},{cleanup:i})=>{let o=n?h(e,n):()=>{},s=le(e,t,r,a=>{o(()=>{},{scope:{$event:a},params:[a]})});i(()=>s())}));S.setEvaluator(Ge);S.setReactivityEngine({reactive:Te,effect:or,release:ar,raw:g});var _t=S;window.Alpine=_t;queueMicrotask(()=>{_t.start()});})();
example/assets/config.css DELETED
@@ -1,11 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
4
-
5
- .btn {
6
- @apply bg-gray-300 text-gray-700 rounded hover:bg-gray-200 px-4 py-2 focus:outline-none m-20
7
- }
8
-
9
- .link {
10
- @apply border-b-2 border-white hover:border-red-700 mr-4
11
- }
example/assets/icon.png DELETED
Binary file
example/assets/styles.css DELETED
@@ -1,769 +0,0 @@
1
- /*! modern-normalize v1.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */
2
-
3
- /*
4
- Document
5
- ========
6
- */
7
-
8
- /**
9
- Use a better box model (opinionated).
10
- */
11
-
12
- *,
13
- *::before,
14
- *::after {
15
- box-sizing: border-box;
16
- }
17
-
18
- /**
19
- Use a more readable tab size (opinionated).
20
- */
21
-
22
- :root {
23
- -moz-tab-size: 4;
24
- -o-tab-size: 4;
25
- tab-size: 4;
26
- }
27
-
28
- /**
29
- 1. Correct the line height in all browsers.
30
- 2. Prevent adjustments of font size after orientation changes in iOS.
31
- */
32
-
33
- html {
34
- line-height: 1.15; /* 1 */
35
- -webkit-text-size-adjust: 100%; /* 2 */
36
- }
37
-
38
- /*
39
- Sections
40
- ========
41
- */
42
-
43
- /**
44
- Remove the margin in all browsers.
45
- */
46
-
47
- body {
48
- margin: 0;
49
- }
50
-
51
- /**
52
- Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
53
- */
54
-
55
- body {
56
- font-family:
57
- system-ui,
58
- -apple-system, /* Firefox supports this but not yet `system-ui` */
59
- 'Segoe UI',
60
- Roboto,
61
- Helvetica,
62
- Arial,
63
- sans-serif,
64
- 'Apple Color Emoji',
65
- 'Segoe UI Emoji';
66
- }
67
-
68
- /*
69
- Grouping content
70
- ================
71
- */
72
-
73
- /**
74
- 1. Add the correct height in Firefox.
75
- 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
76
- */
77
-
78
- hr {
79
- height: 0; /* 1 */
80
- color: inherit; /* 2 */
81
- }
82
-
83
- /*
84
- Text-level semantics
85
- ====================
86
- */
87
-
88
- /**
89
- Add the correct text decoration in Chrome, Edge, and Safari.
90
- */
91
-
92
- abbr[title] {
93
- -webkit-text-decoration: underline dotted;
94
- text-decoration: underline dotted;
95
- }
96
-
97
- /**
98
- Add the correct font weight in Edge and Safari.
99
- */
100
-
101
- b,
102
- strong {
103
- font-weight: bolder;
104
- }
105
-
106
- /**
107
- 1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
108
- 2. Correct the odd 'em' font sizing in all browsers.
109
- */
110
-
111
- code,
112
- kbd,
113
- samp,
114
- pre {
115
- font-family:
116
- ui-monospace,
117
- SFMono-Regular,
118
- Consolas,
119
- 'Liberation Mono',
120
- Menlo,
121
- monospace; /* 1 */
122
- font-size: 1em; /* 2 */
123
- }
124
-
125
- /**
126
- Add the correct font size in all browsers.
127
- */
128
-
129
- small {
130
- font-size: 80%;
131
- }
132
-
133
- /**
134
- Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
135
- */
136
-
137
- sub,
138
- sup {
139
- font-size: 75%;
140
- line-height: 0;
141
- position: relative;
142
- vertical-align: baseline;
143
- }
144
-
145
- sub {
146
- bottom: -0.25em;
147
- }
148
-
149
- sup {
150
- top: -0.5em;
151
- }
152
-
153
- /*
154
- Tabular data
155
- ============
156
- */
157
-
158
- /**
159
- 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
160
- 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
161
- */
162
-
163
- table {
164
- text-indent: 0; /* 1 */
165
- border-color: inherit; /* 2 */
166
- }
167
-
168
- /*
169
- Forms
170
- =====
171
- */
172
-
173
- /**
174
- 1. Change the font styles in all browsers.
175
- 2. Remove the margin in Firefox and Safari.
176
- */
177
-
178
- button,
179
- input,
180
- optgroup,
181
- select,
182
- textarea {
183
- font-family: inherit; /* 1 */
184
- font-size: 100%; /* 1 */
185
- line-height: 1.15; /* 1 */
186
- margin: 0; /* 2 */
187
- }
188
-
189
- /**
190
- Remove the inheritance of text transform in Edge and Firefox.
191
- 1. Remove the inheritance of text transform in Firefox.
192
- */
193
-
194
- button,
195
- select { /* 1 */
196
- text-transform: none;
197
- }
198
-
199
- /**
200
- Correct the inability to style clickable types in iOS and Safari.
201
- */
202
-
203
- button {
204
- -webkit-appearance: button;
205
- }
206
-
207
- /**
208
- Remove the inner border and padding in Firefox.
209
- */
210
-
211
- /**
212
- Restore the focus styles unset by the previous rule.
213
- */
214
-
215
- /**
216
- Remove the additional ':invalid' styles in Firefox.
217
- See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737
218
- */
219
-
220
- /**
221
- Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
222
- */
223
-
224
- legend {
225
- padding: 0;
226
- }
227
-
228
- /**
229
- Add the correct vertical alignment in Chrome and Firefox.
230
- */
231
-
232
- progress {
233
- vertical-align: baseline;
234
- }
235
-
236
- /**
237
- Correct the cursor style of increment and decrement buttons in Safari.
238
- */
239
-
240
- /**
241
- 1. Correct the odd appearance in Chrome and Safari.
242
- 2. Correct the outline style in Safari.
243
- */
244
-
245
- /**
246
- Remove the inner padding in Chrome and Safari on macOS.
247
- */
248
-
249
- /**
250
- 1. Correct the inability to style clickable types in iOS and Safari.
251
- 2. Change font properties to 'inherit' in Safari.
252
- */
253
-
254
- /*
255
- Interactive
256
- ===========
257
- */
258
-
259
- /*
260
- Add the correct display in Chrome and Safari.
261
- */
262
-
263
- summary {
264
- display: list-item;
265
- }
266
-
267
- /**
268
- * Manually forked from SUIT CSS Base: https://github.com/suitcss/base
269
- * A thin layer on top of normalize.css that provides a starting point more
270
- * suitable for web applications.
271
- */
272
-
273
- /**
274
- * Removes the default spacing and border for appropriate elements.
275
- */
276
-
277
- blockquote,
278
- dl,
279
- dd,
280
- h1,
281
- h2,
282
- h3,
283
- h4,
284
- h5,
285
- h6,
286
- hr,
287
- figure,
288
- p,
289
- pre {
290
- margin: 0;
291
- }
292
-
293
- button {
294
- background-color: transparent;
295
- background-image: none;
296
- }
297
-
298
- /**
299
- * Work around a Firefox/IE bug where the transparent `button` background
300
- * results in a loss of the default `button` focus styles.
301
- */
302
-
303
- button:focus {
304
- outline: 1px dotted;
305
- outline: 5px auto -webkit-focus-ring-color;
306
- }
307
-
308
- fieldset {
309
- margin: 0;
310
- padding: 0;
311
- }
312
-
313
- ol,
314
- ul {
315
- list-style: none;
316
- margin: 0;
317
- padding: 0;
318
- }
319
-
320
- /**
321
- * Tailwind custom reset styles
322
- */
323
-
324
- /**
325
- * 1. Use the user's configured `sans` font-family (with Tailwind's default
326
- * sans-serif font stack as a fallback) as a sane default.
327
- * 2. Use Tailwind's default "normal" line-height so the user isn't forced
328
- * to override it to ensure consistency even when using the default theme.
329
- */
330
-
331
- html {
332
- font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 1 */
333
- line-height: 1.5; /* 2 */
334
- }
335
-
336
- /**
337
- * Inherit font-family and line-height from `html` so users can set them as
338
- * a class directly on the `html` element.
339
- */
340
-
341
- body {
342
- font-family: inherit;
343
- line-height: inherit;
344
- }
345
-
346
- /**
347
- * 1. Prevent padding and border from affecting element width.
348
- *
349
- * We used to set this in the html element and inherit from
350
- * the parent element for everything else. This caused issues
351
- * in shadow-dom-enhanced elements like <details> where the content
352
- * is wrapped by a div with box-sizing set to `content-box`.
353
- *
354
- * https://github.com/mozdevs/cssremedy/issues/4
355
- *
356
- *
357
- * 2. Allow adding a border to an element by just adding a border-width.
358
- *
359
- * By default, the way the browser specifies that an element should have no
360
- * border is by setting it's border-style to `none` in the user-agent
361
- * stylesheet.
362
- *
363
- * In order to easily add borders to elements by just setting the `border-width`
364
- * property, we change the default border-style for all elements to `solid`, and
365
- * use border-width to hide them instead. This way our `border` utilities only
366
- * need to set the `border-width` property instead of the entire `border`
367
- * shorthand, making our border utilities much more straightforward to compose.
368
- *
369
- * https://github.com/tailwindcss/tailwindcss/pull/116
370
- */
371
-
372
- *,
373
- ::before,
374
- ::after {
375
- box-sizing: border-box; /* 1 */
376
- border-width: 0; /* 2 */
377
- border-style: solid; /* 2 */
378
- border-color: #e5e7eb; /* 2 */
379
- }
380
-
381
- /*
382
- * Ensure horizontal rules are visible by default
383
- */
384
-
385
- hr {
386
- border-top-width: 1px;
387
- }
388
-
389
- /**
390
- * Undo the `border-style: none` reset that Normalize applies to images so that
391
- * our `border-{width}` utilities have the expected effect.
392
- *
393
- * The Normalize reset is unnecessary for us since we default the border-width
394
- * to 0 on all elements.
395
- *
396
- * https://github.com/tailwindcss/tailwindcss/issues/362
397
- */
398
-
399
- img {
400
- border-style: solid;
401
- }
402
-
403
- textarea {
404
- resize: vertical;
405
- }
406
-
407
- input::-moz-placeholder, textarea::-moz-placeholder {
408
- color: #9ca3af;
409
- }
410
-
411
- input:-ms-input-placeholder, textarea:-ms-input-placeholder {
412
- color: #9ca3af;
413
- }
414
-
415
- input::placeholder,
416
- textarea::placeholder {
417
- color: #9ca3af;
418
- }
419
-
420
- button {
421
- cursor: pointer;
422
- }
423
-
424
- table {
425
- border-collapse: collapse;
426
- }
427
-
428
- h1,
429
- h2,
430
- h3,
431
- h4,
432
- h5,
433
- h6 {
434
- font-size: inherit;
435
- font-weight: inherit;
436
- }
437
-
438
- /**
439
- * Reset links to optimize for opt-in styling instead of
440
- * opt-out.
441
- */
442
-
443
- a {
444
- color: inherit;
445
- text-decoration: inherit;
446
- }
447
-
448
- /**
449
- * Reset form element properties that are easy to forget to
450
- * style explicitly so you don't inadvertently introduce
451
- * styles that deviate from your design system. These styles
452
- * supplement a partial reset that is already applied by
453
- * normalize.css.
454
- */
455
-
456
- button,
457
- input,
458
- optgroup,
459
- select,
460
- textarea {
461
- padding: 0;
462
- line-height: inherit;
463
- color: inherit;
464
- }
465
-
466
- /**
467
- * Use the configured 'mono' font family for elements that
468
- * are expected to be rendered with a monospace font, falling
469
- * back to the system monospace stack if there is no configured
470
- * 'mono' font family.
471
- */
472
-
473
- pre,
474
- code,
475
- kbd,
476
- samp {
477
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
478
- }
479
-
480
- /**
481
- * Make replaced elements `display: block` by default as that's
482
- * the behavior you want almost all of the time. Inspired by
483
- * CSS Remedy, with `svg` added as well.
484
- *
485
- * https://github.com/mozdevs/cssremedy/issues/14
486
- */
487
-
488
- img,
489
- svg,
490
- video,
491
- canvas,
492
- audio,
493
- iframe,
494
- embed,
495
- object {
496
- display: block;
497
- vertical-align: middle;
498
- }
499
-
500
- /**
501
- * Constrain images and videos to the parent width and preserve
502
- * their instrinsic aspect ratio.
503
- *
504
- * https://github.com/mozdevs/cssremedy/issues/14
505
- */
506
-
507
- img,
508
- video {
509
- max-width: 100%;
510
- height: auto;
511
- }
512
-
513
- .border-white {
514
- --tw-border-opacity: 1;
515
- border-color: rgba(255, 255, 255, var(--tw-border-opacity));
516
- }
517
-
518
- .border-b-2 {
519
- border-bottom-width: 2px;
520
- }
521
-
522
- .flex {
523
- display: flex;
524
- }
525
-
526
- .table {
527
- display: table;
528
- }
529
-
530
- .flex-row {
531
- flex-direction: row;
532
- }
533
-
534
- .flex-col {
535
- flex-direction: column;
536
- }
537
-
538
- .items-end {
539
- align-items: flex-end;
540
- }
541
-
542
- .items-center {
543
- align-items: center;
544
- }
545
-
546
- .justify-end {
547
- justify-content: flex-end;
548
- }
549
-
550
- .justify-center {
551
- justify-content: center;
552
- }
553
-
554
- .flex-1 {
555
- flex: 1 1 0%;
556
- }
557
-
558
- .font-bold {
559
- font-weight: 700;
560
- }
561
-
562
- .text-lg {
563
- font-size: 1.125rem;
564
- line-height: 1.75rem;
565
- }
566
-
567
- .text-xl {
568
- font-size: 1.25rem;
569
- line-height: 1.75rem;
570
- }
571
-
572
- .text-3xl {
573
- font-size: 1.875rem;
574
- line-height: 2.25rem;
575
- }
576
-
577
- .text-4xl {
578
- font-size: 2.25rem;
579
- line-height: 2.5rem;
580
- }
581
-
582
- .text-5xl {
583
- font-size: 3rem;
584
- line-height: 1;
585
- }
586
-
587
- .m-20 {
588
- margin: 5rem;
589
- }
590
-
591
- .mr-4 {
592
- margin-right: 1rem;
593
- }
594
-
595
- .mt-6 {
596
- margin-top: 1.5rem;
597
- }
598
-
599
- .mt-10 {
600
- margin-top: 2.5rem;
601
- }
602
-
603
- .mb-20 {
604
- margin-bottom: 5rem;
605
- }
606
-
607
- .p-2 {
608
- padding: 0.5rem;
609
- }
610
-
611
- .p-4 {
612
- padding: 1rem;
613
- }
614
-
615
- * {
616
- --tw-shadow: 0 0 #0000;
617
- }
618
-
619
- * {
620
- --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
621
- --tw-ring-offset-width: 0px;
622
- --tw-ring-offset-color: #fff;
623
- --tw-ring-color: rgba(59, 130, 246, 0.5);
624
- --tw-ring-offset-shadow: 0 0 #0000;
625
- --tw-ring-shadow: 0 0 #0000;
626
- }
627
-
628
- .text-gray-700 {
629
- --tw-text-opacity: 1;
630
- color: rgba(55, 65, 81, var(--tw-text-opacity));
631
- }
632
-
633
- .text-blue-700 {
634
- --tw-text-opacity: 1;
635
- color: rgba(29, 78, 216, var(--tw-text-opacity));
636
- }
637
-
638
- .underline {
639
- text-decoration: underline;
640
- }
641
-
642
- .w-full {
643
- width: 100%;
644
- }
645
-
646
- @-webkit-keyframes spin {
647
- to {
648
- transform: rotate(360deg);
649
- }
650
- }
651
-
652
- @keyframes spin {
653
- to {
654
- transform: rotate(360deg);
655
- }
656
- }
657
-
658
- @-webkit-keyframes ping {
659
- 75%, 100% {
660
- transform: scale(2);
661
- opacity: 0;
662
- }
663
- }
664
-
665
- @keyframes ping {
666
- 75%, 100% {
667
- transform: scale(2);
668
- opacity: 0;
669
- }
670
- }
671
-
672
- @-webkit-keyframes pulse {
673
- 50% {
674
- opacity: .5;
675
- }
676
- }
677
-
678
- @keyframes pulse {
679
- 50% {
680
- opacity: .5;
681
- }
682
- }
683
-
684
- @-webkit-keyframes bounce {
685
- 0%, 100% {
686
- transform: translateY(-25%);
687
- -webkit-animation-timing-function: cubic-bezier(0.8,0,1,1);
688
- animation-timing-function: cubic-bezier(0.8,0,1,1);
689
- }
690
-
691
- 50% {
692
- transform: none;
693
- -webkit-animation-timing-function: cubic-bezier(0,0,0.2,1);
694
- animation-timing-function: cubic-bezier(0,0,0.2,1);
695
- }
696
- }
697
-
698
- @keyframes bounce {
699
- 0%, 100% {
700
- transform: translateY(-25%);
701
- -webkit-animation-timing-function: cubic-bezier(0.8,0,1,1);
702
- animation-timing-function: cubic-bezier(0.8,0,1,1);
703
- }
704
-
705
- 50% {
706
- transform: none;
707
- -webkit-animation-timing-function: cubic-bezier(0,0,0.2,1);
708
- animation-timing-function: cubic-bezier(0,0,0.2,1);
709
- }
710
- }
711
-
712
- .btn {
713
- --tw-bg-opacity: 1;
714
- background-color: rgba(209, 213, 219, var(--tw-bg-opacity))
715
- }
716
-
717
- .btn:hover {
718
- --tw-bg-opacity: 1;
719
- background-color: rgba(229, 231, 235, var(--tw-bg-opacity));
720
- }
721
-
722
- .btn {
723
- border-radius: 0.25rem;
724
- margin: 5rem;
725
- }
726
-
727
- .btn:focus {
728
- outline: 2px solid transparent;
729
- outline-offset: 2px;
730
- }
731
-
732
- .btn {
733
- padding-top: 0.5rem;
734
- padding-bottom: 0.5rem;
735
- padding-left: 1rem;
736
- padding-right: 1rem;
737
- --tw-text-opacity: 1;
738
- color: rgba(55, 65, 81, var(--tw-text-opacity));
739
- }
740
-
741
- .link {
742
- --tw-border-opacity: 1;
743
- border-color: rgba(255, 255, 255, var(--tw-border-opacity))
744
- }
745
-
746
- .link:hover {
747
- --tw-border-opacity: 1;
748
- border-color: rgba(185, 28, 28, var(--tw-border-opacity));
749
- }
750
-
751
- .link {
752
- border-bottom-width: 2px;
753
- margin-right: 1rem;
754
- }
755
-
756
- @media (min-width: 640px) {
757
- }
758
-
759
- @media (min-width: 768px) {
760
- }
761
-
762
- @media (min-width: 1024px) {
763
- }
764
-
765
- @media (min-width: 1280px) {
766
- }
767
-
768
- @media (min-width: 1536px) {
769
- }
example/components/counter.go DELETED
@@ -1,87 +0,0 @@
1
- package components
2
-
3
- import (
4
- "strconv"
5
-
6
- . "github.com/pyros2097/wapp"
7
- . "github.com/pyros2097/wapp/example/context"
8
- )
9
-
10
- // data := map[string]interface{}{
11
- // "count": 1,
12
- // "names": []string{"123", "123"},
13
- // "increment": func() string {
14
- // return "this.count += 1;"
15
- // },
16
- // "decrement": func() string {
17
- // return "this.count -= 1;"
18
- // },
19
- // }
20
-
21
- func Counter(ctx ReqContext, start int) *Element {
22
- UseData(ctx, "counter", M{
23
- "count": start,
24
- "increment": func() string { return "this.count += 1;" },
25
- "decrement": func() string { return "this.count -= 1;" },
26
- })
27
- return Col(Css("text-3xl text-gray-700"),
28
- Row(
29
- Row(Css("underline"),
30
- Text("Counter"),
31
- ),
32
- ),
33
- Row(XData("counter"),
34
- Button(Css("btn m-20"), OnClick("decrement"),
35
- Text("-"),
36
- ),
37
- Row(Css("m-20 text-8xl"), XText("count"),
38
- Text(strconv.Itoa(start)),
39
- ),
40
- Button(Css("btn m-20"), OnClick("increment"),
41
- Text("+"),
42
- ),
43
- ),
44
- )
45
- }
46
-
47
- // func HTML(s string, m map[string]interface{}) string {
48
- // return s
49
- // }
50
-
51
- // func Counter2(start int) string {
52
- // return HTML(`
53
- // <div class="flex flex-col justify-center items-center text-3xl text-gray-700">
54
- // <div class="flex flex-row justify-center items-center">
55
- // <div class="flex flex-row justify-center items-center underline">
56
- // Counter
57
- // </div>
58
- // </div>
59
- // <div class="flex flex-row justify-center items-center" x-data="counter">
60
- // <button @click="decrement" class="btn m-20">-</button>
61
- // <div class="flex flex-row justify-center items-center m-20">{{ count }}</div>
62
- // <button @click="increment" class="btn m-20">+</button>
63
- // </div>
64
- // <div>
65
- // {{#if true }}
66
- // render this
67
- // {{/if}}
68
- // </div>
69
- // <div>
70
- // {{#each names}}
71
- // <li>{{ @index }} - {{ @value }}</li>
72
- // {{/each}}
73
- // </div>
74
- // </div>
75
- // `, data)
76
- // }
77
-
78
- // if becomes
79
- // <template x-if="open">
80
- // </template>
81
-
82
- // each becomes
83
- // <ul x-data="{ names: ['Red', 'Orange', 'Yellow'] }">
84
- // <template x-for="name in names">
85
- // <li x-text="names"></li>
86
- // </template>
87
- // </ul>
example/components/header.go DELETED
@@ -1,21 +0,0 @@
1
- package components
2
-
3
- import (
4
- . "github.com/pyros2097/wapp"
5
- )
6
-
7
- func Header() *Element {
8
- return Row(Css("w-full mb-20 font-bold text-xl text-gray-700 p-4"),
9
- Div(Css("text-blue-700"),
10
- A(Href("https://pyros.sh"), Text("pyros.sh")),
11
- ),
12
- Div(Css("flex flex-row flex-1 justify-end items-end p-2"),
13
- Div(Css("border-b-2 border-white text-lg text-blue-700 mr-4"), Text("Examples: ")),
14
- Div(Css("link mr-4"), A(Href("/"), Text("Home"))),
15
- Div(Css("link mr-4"), A(Href("/clock"), Text("Clock"))),
16
- Div(Css("link mr-4"), A(Href("/about"), Text("About"))),
17
- Div(Css("link mr-4"), A(Href("/container"), Text("Container"))),
18
- Div(Css("link mr-4"), A(Href("/panic"), Text("Panic"))),
19
- ),
20
- )
21
- }
example/components/page.go DELETED
@@ -1,28 +0,0 @@
1
- package components
2
-
3
- import (
4
- "fmt"
5
- . "github.com/pyros2097/wapp"
6
- . "github.com/pyros2097/wapp/example/context"
7
- )
8
-
9
- func Page(ctx ReqContext, elem *Element) *Element {
10
- return Html(
11
- Head(
12
- Title("123"),
13
- Meta("description", "123"),
14
- Meta("author", "123"),
15
- Meta("keywords", "123"),
16
- Meta("viewport", "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover"),
17
- Link("icon", "/assets/icon.png"),
18
- Link("apple-touch-icon", "/assets/icon.png"),
19
- Link("stylesheet", "/assets/styles.css"),
20
- Script(Src("/assets/alpine.js"), Defer()),
21
- ),
22
- Body(elem, Script(Text(fmt.Sprintf(`
23
- document.addEventListener('alpine:init', () => {
24
- %s
25
- });
26
- `, ctx.JS.String())))),
27
- )
28
- }
example/context/context.go DELETED
@@ -1,159 +0,0 @@
1
- package context
2
-
3
- import (
4
- "bytes"
5
- c "context"
6
- "encoding/json"
7
- "io/ioutil"
8
- "net/http"
9
- "reflect"
10
-
11
- "github.com/gobuffalo/velvet"
12
- "github.com/gorilla/mux"
13
- . "github.com/pyros2097/wapp"
14
- "golang.org/x/net/html"
15
- )
16
-
17
- type ReqContext struct {
18
- c.Context
19
- Path string
20
- PathParams map[string]string
21
- QueryParams map[string]string
22
- Body []byte
23
- JS *bytes.Buffer
24
- CSS *bytes.Buffer
25
- UserID string
26
- }
27
-
28
- func NewReqContext(r *http.Request) (ReqContext, error) {
29
- pathParams := mux.Vars(r)
30
- var body []byte
31
- var err error
32
- if r.Method == "POST" || r.Method == "PUT" || r.Method == "PATCH" {
33
- body, err = ioutil.ReadAll(r.Body)
34
- if err != nil {
35
- return ReqContext{}, err
36
- }
37
- }
38
- return ReqContext{
39
- Path: r.URL.Path,
40
- QueryParams: map[string]string{},
41
- PathParams: pathParams,
42
- Body: body,
43
- JS: bytes.NewBuffer(nil),
44
- CSS: bytes.NewBuffer(nil),
45
- UserID: "123",
46
- }, nil
47
- }
48
-
49
- type Handler func(c ReqContext) (interface{}, int, error)
50
-
51
- func Wrap(h Handler) func(http.ResponseWriter, *http.Request) {
52
- return func(w http.ResponseWriter, r *http.Request) {
53
- ctx, err := NewReqContext(r)
54
- if err != nil {
55
- w.Header().Set("Content-Type", "application/json")
56
- data, _ := json.Marshal(M{
57
- "error": err.Error(),
58
- })
59
- w.Write(data)
60
- return
61
- }
62
- value, status, err := h(ctx)
63
- w.WriteHeader(status)
64
- if err != nil {
65
- w.Header().Set("Content-Type", "application/json")
66
- data, _ := json.Marshal(M{
67
- "error": err.Error(),
68
- })
69
- w.Write(data)
70
- return
71
- }
72
- if v, ok := value.(*Element); ok {
73
- w.Header().Set("Content-Type", "text/html")
74
- v.WriteHtml(w)
75
- return
76
- }
77
- w.Header().Set("Content-Type", "application/json")
78
- data, _ := json.Marshal(value)
79
- w.Write(data)
80
- }
81
- }
82
-
83
- func IsFunc(v interface{}) bool {
84
- return reflect.TypeOf(v).Kind() == reflect.Func
85
- }
86
-
87
- func UseData(ctx ReqContext, name string, data map[string]interface{}) {
88
- v := velvet.NewContext()
89
- v.Set("name", name)
90
- generatedMap := M{}
91
- for k, v := range data {
92
- if IsFunc(v) {
93
- f := v.(func() string)
94
- generatedMap[k] = "() {" + f() + "}"
95
- } else {
96
- generatedMap[k+":"] = v
97
- }
98
- }
99
- v.Set("data", generatedMap)
100
- s, err := velvet.Render(`
101
- Alpine.data('{{ name }}', () => {
102
- return {
103
- {{#each data}}
104
- {{ @key }}{{ @value }},
105
- {{/each}}
106
- };
107
- });
108
- `, v)
109
- if err != nil {
110
- panic(err)
111
- }
112
- ctx.JS.WriteString(s)
113
- }
114
-
115
- type Component func(ReqContext) string
116
-
117
- var components = map[string]Component{}
118
-
119
- func RegisterComponent(k string, v Component) {
120
- components[k] = v
121
- }
122
-
123
- func Html2(ctx ReqContext, input string, data map[string]interface{}) string {
124
- vctx := velvet.NewContext()
125
- for k, v := range data {
126
- vctx.Set(k, v)
127
- }
128
- doc, err := html.Parse(bytes.NewBufferString(input))
129
- if err != nil {
130
- panic(err)
131
- }
132
- var f func(*html.Node)
133
- f = func(n *html.Node) {
134
- if c, ok := components[n.Data]; ok {
135
- txt := c(ctx)
136
- println(n.Data, txt)
137
- // newNode, err := html.Parse(bytes.NewBufferString(txt))
138
- // if err != nil {
139
- // panic(err)
140
- // }
141
- println(n.NextSibling.Type)
142
- // n.RemoveChild(n.NextSibling)
143
- // n.RemoveChild(n.PrevSibling)
144
- // n.AppendChild(newNode)
145
- }
146
- if n.Type == html.ElementNode && n.Data == "h1" {
147
- println("h1")
148
- }
149
- for c := n.FirstChild; c != nil; c = c.NextSibling {
150
- f(c)
151
- }
152
- }
153
- f(doc)
154
- s, err := velvet.Render(input, vctx)
155
- if err != nil {
156
- panic(err)
157
- }
158
- return s
159
- }
example/main.go DELETED
@@ -1,38 +0,0 @@
1
- package main
2
-
3
- import (
4
- "embed"
5
- "log"
6
- "net/http"
7
- "os"
8
- "time"
9
-
10
- "github.com/apex/gateway/v2"
11
- "github.com/gorilla/mux"
12
- . "github.com/pyros2097/wapp/example/context"
13
- "github.com/pyros2097/wapp/example/pages"
14
- )
15
-
16
- //go:embed assets/*
17
- var assetsFS embed.FS
18
-
19
- func main() {
20
- isLambda := os.Getenv("_LAMBDA_SERVER_PORT") != ""
21
- r := mux.NewRouter()
22
- r.PathPrefix("/assets/").Handler(http.FileServer(http.FS(assetsFS)))
23
- r.HandleFunc("/", Wrap(pages.Index)).Methods("GET")
24
- r.HandleFunc("/about", Wrap(pages.About)).Methods("GET")
25
- if !isLambda {
26
- println("http server listening on http://localhost:3000")
27
- srv := &http.Server{
28
- Handler: r,
29
- Addr: "127.0.0.1:3000",
30
- WriteTimeout: 30 * time.Second,
31
- ReadTimeout: 30 * time.Second,
32
- }
33
- log.Fatal(srv.ListenAndServe())
34
- } else {
35
- log.Print("running in lambda mode")
36
- log.Fatal(gateway.ListenAndServe(":3000", r))
37
- }
38
- }
example/makefile DELETED
@@ -1,21 +0,0 @@
1
- run:
2
- go run main.go
3
-
4
- local:
5
- sam local start-api
6
-
7
- css:
8
- npx tailwindcss-cli@latest build -i assets/config.css -o assets/styles.css
9
-
10
- build: export GOOS=linux
11
- build: export GOARCH=amd64
12
- build:
13
- go build -o main
14
-
15
- deploy: export NODE_ENV=production
16
- deploy:
17
- make css
18
- make build
19
- sam deploy
20
- aws s3 sync ./assets s3://wapp-example/assets --delete
21
- aws cloudfront create-invalidation --distribution-id E3C93YR5O58WG6 --paths "/*"
example/models/todo.go DELETED
@@ -1,7 +0,0 @@
1
- package models
2
-
3
- type Todo struct {
4
- ID string `json:"id"`
5
- Text string `json:"text"`
6
- Completed bool `json:"completed"`
7
- }
example/pages/about.go DELETED
@@ -1,19 +0,0 @@
1
- package pages
2
-
3
- import (
4
- . "github.com/pyros2097/wapp"
5
- . "github.com/pyros2097/wapp/example/components"
6
- "github.com/pyros2097/wapp/example/context"
7
- )
8
-
9
- //wapp:page method=GET path=/about
10
- func About(c context.ReqContext) (interface{}, int, error) {
11
- return Page(c,
12
- Col(
13
- Header(),
14
- Row(Css("text-5xl text-gray-700"),
15
- Text("About Me"),
16
- ),
17
- ),
18
- ), 200, nil
19
- }
example/pages/api/todo.go DELETED
@@ -1,43 +0,0 @@
1
- package pages
2
-
3
- import (
4
- "context"
5
- )
6
-
7
- type Todo struct {
8
- ID string `json:"id"`
9
- Text string `json:"text"`
10
- Completed bool `json:"completed"`
11
- }
12
-
13
- func GetParam(c context.Context, k string) string {
14
- return ""
15
- }
16
-
17
- //wapp:api method=GET path=/api/todos
18
- func GetAllTodos(c context.Context) (interface{}, error) {
19
- return []Todo{}, nil
20
- }
21
-
22
- // GetTodoById(c context.Context, id string)
23
-
24
- //wapp:api method=GET path=/api/todos/:id
25
- func GetTodoById(c context.Context) (interface{}, error) {
26
- id := GetParam(c, ":id")
27
- return Todo{ID: id}, nil
28
- }
29
-
30
- // UpdateTodo(c context.Context, id string, body *Todo)
31
-
32
- //wapp:api method=POST path=/api/todos
33
- func CreateTodo(c context.Context) (interface{}, error) {
34
- var todo Todo
35
- // GetBody(c, &todo)
36
- return todo, nil
37
- }
38
-
39
- //wapp:api method=PUT path=/api/todos/:id
40
- func UpdateTodo(c context.Context) (interface{}, error) {
41
- id := GetParam(c, ":id")
42
- return Todo{ID: id}, nil
43
- }
example/pages/api/todos/_id/delete.go DELETED
@@ -1,11 +0,0 @@
1
- package todo
2
-
3
- import (
4
- "context"
5
-
6
- . "github.com/pyros2097/wapp/example/models"
7
- )
8
-
9
- func DELETE(c context.Context, id string, params map[string]interface{}) (interface{}, error) {
10
- return Todo{}, nil
11
- }
example/pages/api/todos/_id/get.go DELETED
@@ -1,11 +0,0 @@
1
- package todo
2
-
3
- import (
4
- "context"
5
-
6
- . "github.com/pyros2097/wapp/example/models"
7
- )
8
-
9
- func GET(c context.Context, id string, params map[string]interface{}) (interface{}, error) {
10
- return Todo{}, nil
11
- }
example/pages/api/todos/_id/put.go DELETED
@@ -1,11 +0,0 @@
1
- package todo
2
-
3
- import (
4
- "context"
5
-
6
- . "github.com/pyros2097/wapp/example/models"
7
- )
8
-
9
- func PUT(c context.Context, id string, params map[string]interface{}) (interface{}, error) {
10
- return Todo{}, nil
11
- }
example/pages/api/todos/get.go DELETED
@@ -1,11 +0,0 @@
1
- package pages
2
-
3
- import (
4
- "context"
5
-
6
- . "github.com/pyros2097/wapp/example/models"
7
- )
8
-
9
- func GET(c context.Context) (interface{}, error) {
10
- return []Todo{}, nil
11
- }
example/pages/api/todos/post.go DELETED
@@ -1,11 +0,0 @@
1
- package pages
2
-
3
- import (
4
- "context"
5
-
6
- . "github.com/pyros2097/wapp/example/models"
7
- )
8
-
9
- func POST(c context.Context) (interface{}, error) {
10
- return Todo{}, nil
11
- }
example/pages/index.go DELETED
@@ -1,64 +0,0 @@
1
- package pages
2
-
3
- import (
4
- . "github.com/pyros2097/wapp"
5
- . "github.com/pyros2097/wapp/example/components"
6
- . "github.com/pyros2097/wapp/example/context"
7
- )
8
-
9
- func init() {
10
- RegisterComponent("page", func(c ReqContext) string {
11
- return Html2(c, `
12
- <html>
13
- <body>
14
- <slot></slot>
15
- </body>
16
- </html>
17
- `, M{})
18
- })
19
- }
20
-
21
- func Index(c ReqContext) (interface{}, int, error) {
22
- ss := Html2(c, `
23
- <page x-data="pageData">
24
- <div class="flex flex-col items-center justify-center">
25
- <header></header>
26
- <h1>Hello {{ userID }}</h1>
27
- <h2>Hello this is a h1</h1>
28
- <h2>Hello this is a h2</h1>
29
- <h3 x-text="message"></h3>
30
- <counter start={4}></counter>
31
- </div>
32
- </page>
33
- `, M{"userID": c.UserID})
34
- println("ss", ss)
35
- return Page(c,
36
- Col(
37
- Header(),
38
- H1(Text("Hello "+c.UserID)),
39
- H1(Text("Hello this is a h1")),
40
- H2(Text("Hello this is a h2")),
41
- H3(XData("{ message: 'I ❤️ Alpine' }"), XText("message"), Text("")),
42
- Counter(c, 4),
43
- ),
44
- ), 200, nil
45
- }
46
-
47
- // func Index2(c *context.ReqContext) (interface{}, int, error) {
48
- // data := M{
49
- // "userID": c.UserID,
50
- // "message": "I ❤️ Alpine",
51
- // }
52
- // return Html(`
53
- // <page x-data="pageData">
54
- // <div class="flex flex-col items-center justify-center">
55
- // <header></header>
56
- // <h1>Hello <template x-text="userID"></template></h1>
57
- // <h2>Hello this is a h1</h1>
58
- // <h2>Hello this is a h2</h1>
59
- // <h3 x-text="message"></h3>
60
- // <counter start={4}></counter>
61
- // </div>
62
- // </page>
63
- // `, data), 200, nil
64
- // }
example/tailwind.config.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- purge: {
3
- content: [
4
- './**/*.go',
5
- ],
6
- options: {
7
- safelist: ['flex', 'flex-col', 'flex-row', 'justify-center', 'items-center'],
8
- }
9
- },
10
- theme: {},
11
- variants: {},
12
- plugins: [],
13
- }
example/template.yml DELETED
@@ -1,88 +0,0 @@
1
- ---
2
- AWSTemplateFormatVersion: '2010-09-09'
3
- Transform: AWS::Serverless-2016-10-31
4
-
5
- Outputs:
6
- DistributionId:
7
- Value: !Ref CloudFrontDistribution
8
- AppUrl:
9
- Value: !GetAtt CloudFrontDistribution.DomainName
10
- ApiUrl:
11
- Value: !Sub https://${ServerlessHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/
12
-
13
- Resources:
14
- WebBucket:
15
- Type: AWS::S3::Bucket
16
- Properties:
17
- BucketName: wapp-example
18
-
19
- CloudFrontOriginAccessIdentity:
20
- Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
21
- Properties:
22
- CloudFrontOriginAccessIdentityConfig:
23
- Comment: 'CloudFront OAI'
24
-
25
- WebBucketPolicy:
26
- Type: AWS::S3::BucketPolicy
27
- Properties:
28
- Bucket: !Ref WebBucket
29
- PolicyDocument:
30
- Statement:
31
- - Effect: Allow
32
- Principal:
33
- CanonicalUser: !GetAtt CloudFrontOriginAccessIdentity.S3CanonicalUserId
34
- Action: s3:GetObject
35
- Resource: !Join ['/', [!GetAtt WebBucket.Arn, '*']]
36
- - Effect: Allow
37
- Principal:
38
- CanonicalUser: !GetAtt CloudFrontOriginAccessIdentity.S3CanonicalUserId
39
- Action: s3:ListBucket
40
- Resource: !GetAtt WebBucket.Arn
41
-
42
- HttpApiLambda:
43
- Type: AWS::Serverless::Function
44
- Properties:
45
- Runtime: go1.x
46
- MemorySize: 128
47
- Timeout: 30
48
- Handler: ./main
49
- Events:
50
- ApiEvent:
51
- Type: HttpApi
52
- Properties:
53
- Method: ANY
54
- Path: '$default'
55
-
56
- CloudFrontDistribution:
57
- Type: AWS::CloudFront::Distribution
58
- Properties:
59
- DistributionConfig:
60
- HttpVersion: http2
61
- Enabled: true
62
- IPV6Enabled: true
63
- PriceClass: PriceClass_All
64
- Origins:
65
- - Id: s3
66
- DomainName: !GetAtt WebBucket.DomainName
67
- S3OriginConfig:
68
- OriginAccessIdentity: !Sub 'origin-access-identity/cloudfront/${CloudFrontOriginAccessIdentity}'
69
- - Id: app
70
- DomainName: !Sub ${ServerlessHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}
71
- CustomOriginConfig:
72
- OriginProtocolPolicy: https-only
73
- DefaultCacheBehavior:
74
- TargetOriginId: app
75
- AllowedMethods: [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
76
- ViewerProtocolPolicy: https-only
77
- Compress: true
78
- ForwardedValues:
79
- QueryString: true
80
- CacheBehaviors:
81
- - TargetOriginId: s3
82
- PathPattern: /assets/*
83
- AllowedMethods: [HEAD, GET]
84
- CachedMethods: [HEAD, GET]
85
- ViewerProtocolPolicy: https-only
86
- Compress: true
87
- ForwardedValues:
88
- QueryString: false