xote 1.0.2 → 1.2.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/LICENSE +11 -18
- package/README.md +97 -41
- package/dist/xote.cjs +1 -0
- package/dist/xote.mjs +1041 -0
- package/dist/xote.umd.js +1 -0
- package/package.json +23 -3
- package/.gitattributes +0 -2
- package/.github/workflows/release.yml +0 -44
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -9
- package/dist/index.mjs.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/docs/CHANGELOG.md +0 -27
- package/index.html +0 -28
- package/rescript.json +0 -18
- package/src/Xote.res +0 -5
- package/src/Xote.res.mjs +0 -21
- package/src/Xote__Component.res +0 -151
- package/src/Xote__Component.res.mjs +0 -202
- package/src/Xote__Computed.res +0 -43
- package/src/Xote__Computed.res.mjs +0 -61
- package/src/Xote__Core.res +0 -105
- package/src/Xote__Core.res.mjs +0 -148
- package/src/Xote__Effect.res +0 -36
- package/src/Xote__Effect.res.mjs +0 -57
- package/src/Xote__Example.res +0 -266
- package/src/Xote__Example.res.mjs +0 -303
- package/src/Xote__Id.res +0 -5
- package/src/Xote__Id.res.mjs +0 -17
- package/src/Xote__Observer.res +0 -12
- package/src/Xote__Observer.res.mjs +0 -12
- package/src/Xote__Signal.res +0 -31
- package/src/Xote__Signal.res.mjs +0 -64
- package/src/demo/TodoApp.res +0 -289
- package/src/demo/TodoApp.res.mjs +0 -326
- package/vite.config.js +0 -45
package/dist/xote.umd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(v,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(v=typeof globalThis<"u"?globalThis:v||self,T(v.xote={}))})(this,(function(v){"use strict";var T={contents:0};function L(){return T.contents=T.contents+1|0,T.contents}var Z=(function(e,n){for(var r in e)n(r)});function K(e,n){if(e===n)return!0;var r=typeof e;if(r==="string"||r==="number"||r==="bigint"||r==="boolean"||r==="undefined"||e===null)return!1;var t=typeof n;if(r==="function"||t==="function")throw{RE_EXN_ID:"Invalid_argument",_1:"equal: functional value",Error:new Error};if(t==="number"||t==="bigint"||t==="undefined"||n===null)return!1;var u=e.TAG,a=n.TAG;if(u===248)return e[1]===n[1];if(u===251)throw{RE_EXN_ID:"Invalid_argument",_1:"equal: abstract value",Error:new Error};if(u!==a)return!1;var o=e.length|0,i=n.length|0;if(o===i)if(Array.isArray(e))for(var f=0;;){var c=f;if(c===o)return!0;if(!K(e[c],n[c]))return!1;f=c+1|0}else{if(e instanceof Date&&n instanceof Date)return!(e>n||e<n);var d={contents:!0},E=function(S){if(!Object.prototype.hasOwnProperty.call(n,S)){d.contents=!1;return}},z=function(S){if(!Object.prototype.hasOwnProperty.call(e,S)||!K(n[S],e[S])){d.contents=!1;return}};return Z(e,E),d.contents&&Z(n,z),d.contents}else return!1}function ee(e,n,r){for(var t=new Array(r),u=0,a=n;u<r;)t[u]=e[a],u=u+1|0,a=a+1|0;return t}function ne(e,n){for(;;){var r=n,t=e,u=t.length,a=u===0?1:u,o=r.length,i=a-o|0;if(i===0)return t.apply(null,r);if(i>=0)return(function(f,c){return function(d){return ne(f,c.concat([d]))}})(t,r);n=ee(r,a,-i|0),e=t.apply(null,ee(r,0,a))}}function ge(e,n){var r=e.length;if(r===1)return e(n);switch(r){case 1:return e(n);case 2:return function(t){return e(n,t)};case 3:return function(t,u){return e(n,t,u)};case 4:return function(t,u,a){return e(n,t,u,a)};case 5:return function(t,u,a,o){return e(n,t,u,a,o)};case 6:return function(t,u,a,o,i){return e(n,t,u,a,o,i)};case 7:return function(t,u,a,o,i,f){return e(n,t,u,a,o,i,f)};default:return ne(e,[n])}}function Ee(e){var n=e.length;return n===1?e:function(r){return ge(e,r)}}function Se(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function X(e){if(!(e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0))return e;var n=e.BS_PRIVATE_NESTED_SOME_NONE;if(n!==0)return{BS_PRIVATE_NESTED_SOME_NONE:n-1|0}}function j(e){return e!==void 0?e.h:0}function m(e,n,r,t){var u=j(e),a=j(t);return{k:n,v:r,h:u>=a?u+1|0:a+1|0,l:e,r:t}}function ye(e,n){return{k:e,v:n,h:1,l:void 0,r:void 0}}function $e(e,n){return e.v===n?e:{k:e.k,v:n,h:e.h,l:e.l,r:e.r}}function O(e,n,r,t){var u=e!==void 0?e.h:0,a=t!==void 0?t.h:0;if(u>(a+2|0)){var o=e.l,i=e.r;return j(o)>=j(i)?m(o,e.k,e.v,m(i,n,r,t)):m(m(o,e.k,e.v,i.l),i.k,i.v,m(i.r,n,r,t))}if(a<=(u+2|0))return{k:n,v:r,h:u>=a?u+1|0:a+1|0,l:e,r:t};var f=t.l,c=t.r;return j(c)>=j(f)?m(m(e,n,r,f),t.k,t.v,c):m(m(e,n,r,f.l),f.k,f.v,m(f.r,t.k,t.v,c))}function re(e,n,r){var t=e.l;return t!==void 0?O(re(t,n,r),e.k,e.v,e.r):(n.contents=e.k,r.contents=e.v,e.r)}function be(e,n){for(;;){var r=e;if(r===void 0)return;var t=r.k;if(n===t)return Se(r.v);e=n<t?r.l:r.r}}function A(e,n,r){if(e===void 0)return ye(n,r);var t=e.k;if(n===t)return $e(e,r);var u=e.v;return n<t?O(A(e.l,n,r),t,u,e.r):O(e.l,t,u,A(e.r,n,r))}function q(e,n){var r=e.k,t=e.l,u=e.r;if(n===r){if(t===void 0)return u;if(u===void 0)return t;var a={contents:u.k},o={contents:u.v},i=re(u,a,o);return O(t,a.contents,o.contents,i)}if(n<r){if(t===void 0)return e;var f=q(t,n);return f===t?e:O(f,r,e.v,u)}if(u===void 0)return e;var c=q(u,n);return O(t,r,e.v,c)}function Te(e,n){if(e!==void 0)return q(e,n)}var C=be;function te(e){if(e!==void 0)return X(e);throw{RE_EXN_ID:"Not_found",Error:new Error}}function _(e,n,r){var t=e!==void 0?e.h:0,u=r!==void 0?r.h:0;return{v:n,h:(t>=u?t:u)+1|0,l:e,r}}function Ae(e){return{v:e,h:1,l:void 0,r:void 0}}function ue(e,n){return n!==void 0?e!==void 0?e.h>=n.h:!1:!0}function I(e,n,r){var t=e!==void 0?e.h:0,u=r!==void 0?r.h:0;if(t>(u+2|0)){var a=e.l,o=e.r;return ue(a,o)?_(a,e.v,_(o,n,r)):_(_(a,e.v,o.l),o.v,_(o.r,n,r))}if(u<=(t+2|0))return{v:n,h:(t>=u?t:u)+1|0,l:e,r};var i=r.l,f=r.r;return ue(f,i)?_(_(e,n,i),r.v,f):_(_(e,n,i.l),i.v,_(i.r,r.v,f))}function ae(e,n){var r=e.l;return r!==void 0?I(ae(r,n),e.v,e.r):(n.contents=e.v,e.r)}function ie(e,n){for(;;){var r=e;if(r===void 0)return;ie(r.l,n),n(r.v),e=r.r}}function Ce(e,n){ie(e,Ee(n))}function ke(e,n){for(;;){var r=e;if(r===void 0)return!1;var t=r.v;if(n===t)return!0;e=n<t?r.l:r.r}}function N(e,n){if(e===void 0)return Ae(n);var r=e.v;if(n===r)return e;var t=e.l,u=e.r;if(n<r){var a=N(t,n);return a===t?e:I(a,r,u)}var o=N(u,n);return o===u?e:I(t,r,o)}function J(e,n){if(e===void 0)return e;var r=e.v,t=e.l,u=e.r;if(n===r){if(t===void 0)return u;if(u===void 0)return t;var a={contents:u.v},o=ae(u,a);return I(t,a.contents,o)}if(n<r){var i=J(t,n);return i===t?e:I(i,r,u)}var f=J(u,n);return f===u?e:I(t,r,f)}var je=ke,B=Ce,g={contents:void 0},p={contents:void 0},Oe={contents:void 0},s={contents:void 0},y={contents:void 0},w={contents:!1};function F(e){var n=C(p.contents,e);if(n===void 0){p.contents=A(p.contents,e,void 0);return}}function oe(e,n){F(n);var r=te(C(g.contents,e));if(K(s.contents,e)&&je(r.deps,n)===!1){r.deps=N(r.deps,n);var t=te(C(p.contents,n));p.contents=A(p.contents,n,N(t,e))}}function P(e){B(e.deps,(function(n){var r=C(p.contents,n);if(r!==void 0){p.contents=A(p.contents,n,J(X(r),e.id));return}})),e.deps=void 0}function W(e){if(y.contents=N(y.contents,e),w.contents===!1){var n=y.contents;y.contents=void 0,B(n,(function(r){var t=C(g.contents,r);if(t!==void 0){P(t),s.contents=r,t.run(),s.contents=void 0;return}}))}}function fe(e){F(e);var n=C(p.contents,e);if(n!==void 0)return B(X(n),W)}function Ie(e){var n=s.contents;s.contents=void 0;var r=e();return s.contents=n,r}function Me(e){var n=w.contents;w.contents=!0;var r=e();if(w.contents=n,y.contents!==void 0){var t=y.contents;y.contents=void 0,B(t,(function(u){W(u)}))}return r}var Ne,we,Pe,Re;const Ge=Object.freeze(Object.defineProperty({__proto__:null,Id:Re,IntMap:we,IntSet:Ne,Observer:Pe,addDep:oe,batch:Me,batching:w,clearDeps:P,currentObserverId:s,ensureSignalBucket:F,notify:fe,observers:g,pending:y,schedule:W,signalObservers:p,signalPeeks:Oe,untrack:Ie},Symbol.toStringTag,{value:"Module"}));function R(e){var n=L(),r={id:n,kind:"Effect",run:(function(){e()}),deps:void 0};g.contents=A(g.contents,n,r),P(r),s.contents=n,r.run(),s.contents=void 0;var t=function(){var u=C(g.contents,n);if(u!==void 0){P(u),g.contents=Te(g.contents,n);return}};return{dispose:t}}var De,Xe,Be,Fe,Ve,ze;const Le=Object.freeze(Object.defineProperty({__proto__:null,Core:ze,Id:Be,IntMap:Xe,IntSet:De,Observer:Fe,Signal:Ve,run:R},Symbol.toStringTag,{value:"Module"}));function H(e){var n=L();return F(n),{id:n,value:{contents:e},version:{contents:0}}}function $(e){var n=s.contents;return n!==void 0&&oe(n,e.id),e.value.contents}function V(e){return e.value.contents}function b(e,n){e.value.contents=n,e.version.contents=e.version.contents+1|0,fe(e.id)}function Ke(e,n){b(e,n(e.value.contents))}var qe,Je,We,He,Ue;const xe=Object.freeze(Object.defineProperty({__proto__:null,Core:Ue,Id:He,IntMap:Je,IntSet:qe,Observer:We,get:$,make:H,peek:V,set:b,update:Ke},Symbol.toStringTag,{value:"Module"}));function M(e){var n=H(),r={contents:!1},t=L(),u=function(){var o=e();return r.contents===!1&&(r.contents=!0),b(n,o)},a={id:t,kind:{NAME:"Computed",VAL:n.id},run:u,deps:void 0};return g.contents=A(g.contents,t,a),P(a),s.contents=t,a.run(),s.contents=void 0,n}var Qe,Ye,Ze,en,nn,rn;const tn=Object.freeze(Object.defineProperty({__proto__:null,Core:en,Id:rn,IntMap:Ye,IntSet:Qe,Observer:nn,Signal:Ze,make:M},Symbol.toStringTag,{value:"Module"}));function l(e,n){return[e,{TAG:"Static",_0:n}]}function un(e,n){return[e,{TAG:"SignalValue",_0:n}]}function an(e,n){return[e,{TAG:"Compute",_0:n}]}function ce(e){return{TAG:"Text",_0:e}}function on(e){var n=M(e);return{TAG:"SignalText",_0:n}}function U(e){return{TAG:"Fragment",_0:e}}function x(e){return{TAG:"SignalFragment",_0:e}}function fn(e,n){var r=M(function(){return $(e).map(n)});return{TAG:"SignalFragment",_0:r}}function h(e,n,r,t,u){var a=n!==void 0?n:[].map(function(f){return f}),o=r!==void 0?r:[].map(function(f){return f}),i=t!==void 0?t:[].map(function(f){return f});return{TAG:"Element",tag:e,attrs:a,events:o,children:i}}function cn(e,n,r,t){return h("div",e,n,r)}function dn(e,n,r,t){return h("span",e,n,r)}function vn(e,n,r,t){return h("button",e,n,r)}function sn(e,n,r){return h("input",e,n,void 0)}function ln(e,n,r,t){return h("h1",e,n,r)}function hn(e,n,r,t){return h("h2",e,n,r)}function pn(e,n,r,t){return h("h3",e,n,r)}function mn(e,n,r,t){return h("p",e,n,r)}function _n(e,n,r,t){return h("ul",e,n,r)}function gn(e,n,r,t){return h("li",e,n,r)}function de(e,n,r,t){return h("a",e,n,r)}function G(e){switch(e.TAG){case"Element":var n=document.createElement(e.tag);return e.attrs.forEach(function(i){var f=i[1],c=i[0];switch(f.TAG){case"Static":n.setAttribute(c,f._0);return;case"SignalValue":var d=f._0;n.setAttribute(c,V(d)),R(function(){var S=$(d);n.setAttribute(c,S)});return;case"Compute":var E=f._0,z=M(function(){return E()});n.setAttribute(c,V(z)),R(function(){var S=$(z);n.setAttribute(c,S)});return}}),e.events.forEach(function(i){n.addEventListener(i[0],i[1])}),e.children.forEach(function(i){var f=G(i);n.appendChild(f)}),n;case"Text":return document.createTextNode(e._0);case"SignalText":var r=e._0,t=document.createTextNode(V(r));return R(function(){var i=$(r);t.textContent=i}),t;case"Fragment":var u=document.createDocumentFragment();return e._0.forEach(function(i){var f=G(i);u.appendChild(f)}),u;case"SignalFragment":var a=e._0,o=document.createElement("div");return o.setAttribute("data-signal-fragment","true"),o.setAttribute("style","display: contents"),R(function(){var i=$(a);o.innerHTML="",i.forEach(function(f){var c=G(f);o.appendChild(c)})}),o}}function ve(e,n){var r=G(e);n.appendChild(r)}function En(e,n){var r=document.getElementById(n);if(r==null){console.error("Container element not found: "+n);return}else return ve(e,r)}var Sn,yn,$n,bn;const Tn=Object.freeze(Object.defineProperty({__proto__:null,Computed:bn,Core:$n,Effect:yn,Signal:Sn,a:de,attr:l,button:vn,computedAttr:an,div:cn,element:h,fragment:U,h1:ln,h2:hn,h3:pn,input:sn,li:gn,list:fn,mount:ve,mountById:En,p:mn,render:G,signalAttr:un,signalFragment:x,span:dn,text:ce,textSignal:on,ul:_n},Symbol.toStringTag,{value:"Module"}));function An(e,n){return e(n)}function Cn(e,n){return e(n)}function kn(e,n,r,t){return e(n)}function jn(e,n,r,t){return e(n)}function On(e){var n=e.children;return n!==void 0?n:U([])}function In(e){return U(e)}function Mn(){return ce("")}function se(e){var n=[],r=e.id;r!==void 0&&n.push(l("id",r));var t=e.class;t!==void 0&&n.push(l("class",t));var u=e.style;u!==void 0&&n.push(l("style",u));var a=e.type;a!==void 0&&n.push(l("type",a));var o=e.value;o!==void 0&&n.push(l("value",o));var i=e.placeholder;i!==void 0&&n.push(l("placeholder",i));var f=e.disabled;f!==void 0&&f&&n.push(l("disabled","true"));var c=e.checked;c!==void 0&&c&&n.push(l("checked","true"));var d=e.href;d!==void 0&&n.push(l("href",d));var E=e.target;return E!==void 0&&n.push(l("target",E)),n}function le(e){var n=[],r=e.onClick;r!==void 0&&n.push(["click",r]);var t=e.onInput;t!==void 0&&n.push(["input",t]);var u=e.onChange;u!==void 0&&n.push(["change",u]);var a=e.onSubmit;a!==void 0&&n.push(["submit",a]);var o=e.onFocus;o!==void 0&&n.push(["focus",o]);var i=e.onBlur;i!==void 0&&n.push(["blur",i]);var f=e.onKeyDown;f!==void 0&&n.push(["keydown",f]);var c=e.onKeyUp;c!==void 0&&n.push(["keyup",c]);var d=e.onMouseEnter;d!==void 0&&n.push(["mouseenter",d]);var E=e.onMouseLeave;return E!==void 0&&n.push(["mouseleave",E]),n}function he(e){var n=e.children;return n!==void 0?n.TAG==="Fragment"?n._0:[n]:[]}function D(e,n){return{TAG:"Element",tag:e,attrs:se(n),events:le(n),children:he(n)}}function Nn(e,n){return D(e,n)}function wn(e,n){return D(e,n)}function Pn(e,n,r,t){return D(e,n)}function Rn(e,n,r,t){return D(e,n)}var Gn={propsToAttrs:se,propsToEvents:le,getChildren:he,createElement:D,jsx:Nn,jsxs:wn,jsxKeyed:Pn,jsxsKeyed:Rn},Dn;const Xn=Object.freeze(Object.defineProperty({__proto__:null,$$null:Mn,Component:Dn,Elements:Gn,array:In,jsx:An,jsxFragment:On,jsxKeyed:kn,jsxs:Cn,jsxsKeyed:jn},Symbol.toStringTag,{value:"Module"}));function Bn(e,n){for(var r=e.length,t=new Array(r),u=0,a=0;a<r;++a){var o=e[a],i=n(o);i!==void 0&&(t[u]=X(i),u=u+1|0)}return t.length=u,t}function Fn(e,n){for(var r=0;;){var t=r;if(t===e.length)return;var u=n(e[t]);if(u!==void 0)return u;r=t+1|0}}function pe(e){return Bn(e.split("/"),(function(n){if(n!=="")return n.startsWith(":")?{TAG:"Param",_0:n.slice(1)}:{TAG:"Static",_0:n}}))}function me(e,n){var r=n.split("/").filter(function(a){return a!==""});if(e.length!==r.length)return"NoMatch";var t={},u=e.every(function(a,o){var i=r[o];return a.TAG==="Static"?i===a._0:(t[a._0]=i,!0)});return u?{TAG:"Match",_0:t}:"NoMatch"}function Q(e,n){return me(pe(e),n)}const Vn=Object.freeze(Object.defineProperty({__proto__:null,match:Q,matchPath:me,parsePattern:pe},Symbol.toStringTag,{value:"Module"}));var k=H({pathname:"/",search:"",hash:""});function Y(){return{pathname:window.location.pathname,search:window.location.search,hash:window.location.hash}}function zn(){b(k,Y());var e=function(n){b(k,Y())};window.addEventListener("popstate",e)}function _e(e,n,r,t){var u=n!==void 0?n:"",a=r!==void 0?r:"",o={pathname:e,search:u,hash:a},i=e+u+a,f={};window.history.pushState(f,"",i),b(k,o)}function Ln(e,n,r,t){var u=n!==void 0?n:"",a=r!==void 0?r:"",o={pathname:e,search:u,hash:a},i=e+u+a,f={};window.history.replaceState(f,"",i),b(k,o)}function Kn(e,n){return x(M(function(){var r=$(k),t=Q(e,r.pathname);return typeof t!="object"?[]:[n(t._0)]}))}function qn(e){return x(M(function(){var n=$(k),r=Fn(e,(function(t){var u=Q(t.pattern,n.pathname);if(typeof u=="object")return t.render(u._0)}));return r!==void 0?[r]:[]}))}function Jn(e,n,r,t){var u=n!==void 0?n:[],a=r!==void 0?r:[],o=function(i){i.preventDefault(),_e(e,void 0,void 0)};return de(u.concat([l("href",e)]),[["click",o]],a)}var Wn,Hn,Un,xn,Qn;const Yn=Object.freeze(Object.defineProperty({__proto__:null,$$location:k,Component:Un,Computed:Hn,Core:Qn,Route:xn,Signal:Wn,getCurrentLocation:Y,init:zn,link:Jn,push:_e,replace:Ln,route:Kn,routes:qn},Symbol.toStringTag,{value:"Module"}));var Zn=Tn,er=tn,nr=Ge,rr=Le,tr=Xn,ur=Vn,ar=Yn,ir=xe;v.Component=Zn,v.Computed=er,v.Core=nr,v.Effect=rr,v.JSX=tr,v.Route=ur,v.Router=ar,v.Signal=ir,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xote",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/brnrdog/xote"
|
|
6
6
|
},
|
|
7
|
+
"main": "./dist/xote.cjs",
|
|
8
|
+
"module": "./dist/xote.mjs",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
7
13
|
"scripts": {
|
|
8
14
|
"res:build": "rescript",
|
|
9
15
|
"res:clean": "rescript clean",
|
|
10
16
|
"res:dev": "rescript -w",
|
|
11
17
|
"dev": "vite",
|
|
12
18
|
"build": "vite build",
|
|
13
|
-
"preview": "vite preview"
|
|
19
|
+
"preview": "vite preview",
|
|
20
|
+
"build:demos": "vite build --config vite.demos.config.js",
|
|
21
|
+
"copy:demos": "mkdir -p website/static/demos && cp -r demos-dist/* website/static/demos/",
|
|
22
|
+
"prepare:demos": "npm run res:build && npm run build:demos && npm run copy:demos",
|
|
23
|
+
"docs:start": "npm run prepare:demos && cd website && npm start",
|
|
24
|
+
"docs:build": "npm run prepare:demos && cd website && npm run build",
|
|
25
|
+
"docs:serve": "cd website && npm run serve"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/xote.mjs",
|
|
30
|
+
"require": "./dist/xote.cjs"
|
|
31
|
+
}
|
|
14
32
|
},
|
|
15
33
|
"keywords": [
|
|
16
34
|
"rescript",
|
|
@@ -39,11 +57,12 @@
|
|
|
39
57
|
]
|
|
40
58
|
}
|
|
41
59
|
],
|
|
60
|
+
"@semantic-release/github",
|
|
42
61
|
"@semantic-release/npm"
|
|
43
62
|
]
|
|
44
63
|
},
|
|
45
64
|
"author": "Bernardo Gurgel <brnrdog@hey.com>",
|
|
46
|
-
"license": "
|
|
65
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
47
66
|
"devDependencies": {
|
|
48
67
|
"@rescript/core": "^1.6.1",
|
|
49
68
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -52,6 +71,7 @@
|
|
|
52
71
|
"@semantic-release/github": "^12.0.0",
|
|
53
72
|
"@semantic-release/npm": "^13.1.1",
|
|
54
73
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
74
|
+
"glob": "^11.0.3",
|
|
55
75
|
"rescript": "^11.1.4",
|
|
56
76
|
"semantic-release": "^25.0.1",
|
|
57
77
|
"vite": "^7.1.12"
|
package/.gitattributes
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ main ]
|
|
6
|
-
workflow_dispatch: {}
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: write # create releases, push changelog commits
|
|
10
|
-
issues: write # (optional) if plugins comment on issues
|
|
11
|
-
pull-requests: write # (optional) if plugins post to PRs
|
|
12
|
-
id-token: write
|
|
13
|
-
|
|
14
|
-
concurrency:
|
|
15
|
-
group: release-${{ github.ref }}
|
|
16
|
-
cancel-in-progress: false
|
|
17
|
-
|
|
18
|
-
jobs:
|
|
19
|
-
release:
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
|
|
22
|
-
steps:
|
|
23
|
-
- name: Checkout
|
|
24
|
-
uses: actions/checkout@v4
|
|
25
|
-
with:
|
|
26
|
-
fetch-depth: 0 # semantic-release needs full history & tags
|
|
27
|
-
|
|
28
|
-
- name: Use Node.js 24
|
|
29
|
-
uses: actions/setup-node@v4
|
|
30
|
-
with:
|
|
31
|
-
node-version: 24.10.0
|
|
32
|
-
cache: npm
|
|
33
|
-
registry-url: https://registry.npmjs.org
|
|
34
|
-
|
|
35
|
-
- name: Install dependencies
|
|
36
|
-
run: npm install
|
|
37
|
-
|
|
38
|
-
- name: Build
|
|
39
|
-
run: npm run build
|
|
40
|
-
- name: Release
|
|
41
|
-
env:
|
|
42
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
43
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
44
|
-
run: npx semantic-release
|
package/dist/index.cjs
DELETED
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/Xote.res.mjs"],"sourcesContent":["// Generated by ReScript, PLEASE EDIT WITH CARE\n\n\nvar Component;\n\nvar Computed;\n\nvar Core;\n\nvar Effect;\n\nvar Signal;\n\nexport {\n Component ,\n Computed ,\n Core ,\n Effect ,\n Signal ,\n}\n/* No side effect */\n"],"names":["Component","Computed","Core","Effect","Signal"],"mappings":"gFAGG,IAACA,EAEAC,EAEAC,EAEAC,EAEAC"}
|
package/dist/index.mjs
DELETED
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/Xote.res.mjs"],"sourcesContent":["// Generated by ReScript, PLEASE EDIT WITH CARE\n\n\nvar Component;\n\nvar Computed;\n\nvar Core;\n\nvar Effect;\n\nvar Signal;\n\nexport {\n Component ,\n Computed ,\n Core ,\n Effect ,\n Signal ,\n}\n/* No side effect */\n"],"names":["Component","Computed","Core","Effect","Signal"],"mappings":"AAGG,IAACA,GAEAC,GAEAC,GAEAC,GAEAC;"}
|
package/dist/index.umd.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e.xote={}))})(this,(function(e){"use strict";var n,o,t,f,i;e.Component=n,e.Computed=o,e.Core=t,e.Effect=f,e.Signal=i,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
2
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/Xote.res.mjs"],"sourcesContent":["// Generated by ReScript, PLEASE EDIT WITH CARE\n\n\nvar Component;\n\nvar Computed;\n\nvar Core;\n\nvar Effect;\n\nvar Signal;\n\nexport {\n Component ,\n Computed ,\n Core ,\n Effect ,\n Signal ,\n}\n/* No side effect */\n"],"names":["Component","Computed","Core","Effect","Signal"],"mappings":"+OAGG,IAACA,EAEAC,EAEAC,EAEAC,EAEAC"}
|
package/docs/CHANGELOG.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
## [1.0.2](https://github.com/brnrdog/xote/compare/v1.0.1...v1.0.2) (2025-10-30)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* version bump ([2794ae6](https://github.com/brnrdog/xote/commit/2794ae697f5c3448d946b9fc5c7d1c0defa8be1a))
|
|
7
|
-
|
|
8
|
-
## [1.0.1](https://github.com/brnrdog/xote/compare/v1.0.0...v1.0.1) (2025-10-30)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* version bump for release ([72fb74f](https://github.com/brnrdog/xote/commit/72fb74f2cf3d4a2389daf5363457d5d7ad4eaed1))
|
|
14
|
-
|
|
15
|
-
# 1.0.0 (2025-10-30)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* improve signal reactivity and add todo styling ([495f0bb](https://github.com/brnrdog/xote/commit/495f0bb52eaa8de89214f957f30b078f07029569))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Features
|
|
24
|
-
|
|
25
|
-
* add Component system with automatic reactivity ([38815ed](https://github.com/brnrdog/xote/commit/38815ed3d1400c5511b790011d60081b317a69ac))
|
|
26
|
-
* add demo ([cf3faf3](https://github.com/brnrdog/xote/commit/cf3faf34c07d85a60d78d5f9539d2e2132f3b85a))
|
|
27
|
-
* minimal signal implementation based on the TC39 proposal ([9b78d0b](https://github.com/brnrdog/xote/commit/9b78d0b62ba21c953d909459036246f334b6613e))
|
package/index.html
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>Xote Demo</title>
|
|
7
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
8
|
-
<script>
|
|
9
|
-
tailwind.config = {
|
|
10
|
-
darkMode: 'class',
|
|
11
|
-
theme: {
|
|
12
|
-
extend: {}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
</script>
|
|
16
|
-
<style>
|
|
17
|
-
.todo-list li.completed span {
|
|
18
|
-
text-decoration: line-through;
|
|
19
|
-
@apply text-gray-500 dark:text-gray-400;
|
|
20
|
-
}
|
|
21
|
-
</style>
|
|
22
|
-
</head>
|
|
23
|
-
<body class="bg-gray-50 dark:bg-gray-900 min-h-screen">
|
|
24
|
-
<div id="app"></div>
|
|
25
|
-
<script type="module" src="./src/demo/TodoApp.res.mjs">
|
|
26
|
-
</script>
|
|
27
|
-
</body>
|
|
28
|
-
</html>
|
package/rescript.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xote",
|
|
3
|
-
"sources": {
|
|
4
|
-
"dir": "src",
|
|
5
|
-
"subdirs": true
|
|
6
|
-
},
|
|
7
|
-
"package-specs": {
|
|
8
|
-
"module": "esmodule",
|
|
9
|
-
"in-source": true
|
|
10
|
-
},
|
|
11
|
-
"suffix": ".res.mjs",
|
|
12
|
-
"bs-dependencies": [
|
|
13
|
-
"@rescript/core"
|
|
14
|
-
],
|
|
15
|
-
"bsc-flags": [
|
|
16
|
-
"-open RescriptCore"
|
|
17
|
-
]
|
|
18
|
-
}
|
package/src/Xote.res
DELETED
package/src/Xote.res.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var Component;
|
|
5
|
-
|
|
6
|
-
var Computed;
|
|
7
|
-
|
|
8
|
-
var Core;
|
|
9
|
-
|
|
10
|
-
var Effect;
|
|
11
|
-
|
|
12
|
-
var Signal;
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
Component ,
|
|
16
|
-
Computed ,
|
|
17
|
-
Core ,
|
|
18
|
-
Effect ,
|
|
19
|
-
Signal ,
|
|
20
|
-
}
|
|
21
|
-
/* No side effect */
|
package/src/Xote__Component.res
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
module Signal = Xote__Signal
|
|
2
|
-
module Effect = Xote__Effect
|
|
3
|
-
module Core = Xote__Core
|
|
4
|
-
module Computed = Xote__Computed
|
|
5
|
-
|
|
6
|
-
/* Type representing a virtual node */
|
|
7
|
-
type rec node =
|
|
8
|
-
| Element({
|
|
9
|
-
tag: string,
|
|
10
|
-
attrs: array<(string, string)>,
|
|
11
|
-
events: array<(string, Dom.event => unit)>,
|
|
12
|
-
children: array<node>,
|
|
13
|
-
})
|
|
14
|
-
| Text(string)
|
|
15
|
-
| SignalText(Core.t<string>)
|
|
16
|
-
| Fragment(array<node>)
|
|
17
|
-
| SignalFragment(Core.t<array<node>>)
|
|
18
|
-
|
|
19
|
-
/* Create a text node */
|
|
20
|
-
let text = (content: string): node => Text(content)
|
|
21
|
-
|
|
22
|
-
/* Create a reactive text node from a signal */
|
|
23
|
-
let textSignal = (signal: Core.t<string>): node => SignalText(signal)
|
|
24
|
-
|
|
25
|
-
/* Create a fragment (multiple children without wrapper) */
|
|
26
|
-
let fragment = (children: array<node>): node => Fragment(children)
|
|
27
|
-
|
|
28
|
-
/* Create a reactive fragment from a signal */
|
|
29
|
-
let signalFragment = (signal: Core.t<array<node>>): node => SignalFragment(signal)
|
|
30
|
-
|
|
31
|
-
/* Create a reactive list from a signal and render function */
|
|
32
|
-
let list = (signal: Core.t<array<'a>>, renderItem: 'a => node): node => {
|
|
33
|
-
let nodesSignal = Computed.make(() => {
|
|
34
|
-
Signal.get(signal)->Array.map(renderItem)
|
|
35
|
-
})
|
|
36
|
-
SignalFragment(nodesSignal)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* Create an element */
|
|
40
|
-
let element = (
|
|
41
|
-
tag: string,
|
|
42
|
-
~attrs: array<(string, string)>=[]->Array.map(x => x),
|
|
43
|
-
~events: array<(string, Dom.event => unit)>=[]->Array.map(x => x),
|
|
44
|
-
~children: array<node>=[]->Array.map(x => x),
|
|
45
|
-
(),
|
|
46
|
-
): node => Element({tag, attrs, events, children})
|
|
47
|
-
|
|
48
|
-
/* Helper to create common elements */
|
|
49
|
-
let div = (~attrs=?, ~events=?, ~children=?, ()) => element("div", ~attrs?, ~events?, ~children?, ())
|
|
50
|
-
let span = (~attrs=?, ~events=?, ~children=?, ()) => element("span", ~attrs?, ~events?, ~children?, ())
|
|
51
|
-
let button = (~attrs=?, ~events=?, ~children=?, ()) =>
|
|
52
|
-
element("button", ~attrs?, ~events?, ~children?, ())
|
|
53
|
-
let input = (~attrs=?, ~events=?, ()) => element("input", ~attrs?, ~events?, ())
|
|
54
|
-
let h1 = (~attrs=?, ~events=?, ~children=?, ()) => element("h1", ~attrs?, ~events?, ~children?, ())
|
|
55
|
-
let h2 = (~attrs=?, ~events=?, ~children=?, ()) => element("h2", ~attrs?, ~events?, ~children?, ())
|
|
56
|
-
let h3 = (~attrs=?, ~events=?, ~children=?, ()) => element("h3", ~attrs?, ~events?, ~children?, ())
|
|
57
|
-
let p = (~attrs=?, ~events=?, ~children=?, ()) => element("p", ~attrs?, ~events?, ~children?, ())
|
|
58
|
-
let ul = (~attrs=?, ~events=?, ~children=?, ()) => element("ul", ~attrs?, ~events?, ~children?, ())
|
|
59
|
-
let li = (~attrs=?, ~events=?, ~children=?, ()) => element("li", ~attrs?, ~events?, ~children?, ())
|
|
60
|
-
|
|
61
|
-
/* External bindings for DOM manipulation */
|
|
62
|
-
@val @scope("document") external createElement: string => Dom.element = "createElement"
|
|
63
|
-
@val @scope("document") external createTextNode: string => Dom.element = "createTextNode"
|
|
64
|
-
@val @scope("document") external createDocumentFragment: unit => Dom.element = "createDocumentFragment"
|
|
65
|
-
@val @scope("document") external getElementById: string => Nullable.t<Dom.element> = "getElementById"
|
|
66
|
-
|
|
67
|
-
@send external setAttribute: (Dom.element, string, string) => unit = "setAttribute"
|
|
68
|
-
@send external addEventListener: (Dom.element, string, Dom.event => unit) => unit = "addEventListener"
|
|
69
|
-
@send external appendChild: (Dom.element, Dom.element) => unit = "appendChild"
|
|
70
|
-
@set external setTextContent: (Dom.element, string) => unit = "textContent"
|
|
71
|
-
|
|
72
|
-
/* Render a virtual node to a real DOM element */
|
|
73
|
-
let rec render = (node: node): Dom.element => {
|
|
74
|
-
switch node {
|
|
75
|
-
| Text(content) => createTextNode(content)
|
|
76
|
-
| SignalText(signal) => {
|
|
77
|
-
let el = createTextNode(Signal.peek(signal))
|
|
78
|
-
|
|
79
|
-
/* Set up effect to update text when signal changes */
|
|
80
|
-
let _ = Effect.run(() => {
|
|
81
|
-
let content = Signal.get(signal)
|
|
82
|
-
el->setTextContent(content)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
el
|
|
86
|
-
}
|
|
87
|
-
| Element({tag, attrs, events, children}) => {
|
|
88
|
-
let el = createElement(tag)
|
|
89
|
-
|
|
90
|
-
/* Set attributes */
|
|
91
|
-
attrs->Array.forEach(((key, value)) => {
|
|
92
|
-
el->setAttribute(key, value)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
/* Attach event listeners */
|
|
96
|
-
events->Array.forEach(((eventName, handler)) => {
|
|
97
|
-
el->addEventListener(eventName, handler)
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
/* Append children */
|
|
101
|
-
children->Array.forEach(child => {
|
|
102
|
-
let childEl = render(child)
|
|
103
|
-
el->appendChild(childEl)
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
el
|
|
107
|
-
}
|
|
108
|
-
| Fragment(children) => {
|
|
109
|
-
let fragment = createDocumentFragment()
|
|
110
|
-
children->Array.forEach(child => {
|
|
111
|
-
let childEl = render(child)
|
|
112
|
-
fragment->appendChild(childEl)
|
|
113
|
-
})
|
|
114
|
-
fragment
|
|
115
|
-
}
|
|
116
|
-
| SignalFragment(signal) => {
|
|
117
|
-
/* Create a container element to hold the dynamic children */
|
|
118
|
-
let container = createElement("div")
|
|
119
|
-
setAttribute(container, "data-signal-fragment", "true")
|
|
120
|
-
setAttribute(container, "style", "display: contents")
|
|
121
|
-
|
|
122
|
-
/* Set up effect to update children when signal changes */
|
|
123
|
-
let _ = Effect.run(() => {
|
|
124
|
-
let children = Signal.get(signal)
|
|
125
|
-
/* Clear existing children */
|
|
126
|
-
%raw(`container.innerHTML = ''`)
|
|
127
|
-
/* Render and append new children */
|
|
128
|
-
children->Array.forEach(child => {
|
|
129
|
-
let childEl = render(child)
|
|
130
|
-
container->appendChild(childEl)
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
container
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/* Mount a node to a container element */
|
|
140
|
-
let mount = (node: node, container: Dom.element): unit => {
|
|
141
|
-
let el = render(node)
|
|
142
|
-
container->appendChild(el)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/* Mount a node to a container by ID */
|
|
146
|
-
let mountById = (node: node, containerId: string): unit => {
|
|
147
|
-
switch getElementById(containerId)->Nullable.toOption {
|
|
148
|
-
| Some(container) => mount(node, container)
|
|
149
|
-
| None => Console.error("Container element not found: " ++ containerId)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Xote__Effect from "./Xote__Effect.res.mjs";
|
|
4
|
-
import * as Xote__Signal from "./Xote__Signal.res.mjs";
|
|
5
|
-
import * as Xote__Computed from "./Xote__Computed.res.mjs";
|
|
6
|
-
|
|
7
|
-
function text(content) {
|
|
8
|
-
return {
|
|
9
|
-
TAG: "Text",
|
|
10
|
-
_0: content
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function textSignal(signal) {
|
|
15
|
-
return {
|
|
16
|
-
TAG: "SignalText",
|
|
17
|
-
_0: signal
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function fragment(children) {
|
|
22
|
-
return {
|
|
23
|
-
TAG: "Fragment",
|
|
24
|
-
_0: children
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function signalFragment(signal) {
|
|
29
|
-
return {
|
|
30
|
-
TAG: "SignalFragment",
|
|
31
|
-
_0: signal
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function list(signal, renderItem) {
|
|
36
|
-
var nodesSignal = Xote__Computed.make(function () {
|
|
37
|
-
return Xote__Signal.get(signal).map(renderItem);
|
|
38
|
-
});
|
|
39
|
-
return {
|
|
40
|
-
TAG: "SignalFragment",
|
|
41
|
-
_0: nodesSignal
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function element(tag, attrsOpt, eventsOpt, childrenOpt, param) {
|
|
46
|
-
var attrs = attrsOpt !== undefined ? attrsOpt : [].map(function (x) {
|
|
47
|
-
return x;
|
|
48
|
-
});
|
|
49
|
-
var events = eventsOpt !== undefined ? eventsOpt : [].map(function (x) {
|
|
50
|
-
return x;
|
|
51
|
-
});
|
|
52
|
-
var children = childrenOpt !== undefined ? childrenOpt : [].map(function (x) {
|
|
53
|
-
return x;
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
TAG: "Element",
|
|
57
|
-
tag: tag,
|
|
58
|
-
attrs: attrs,
|
|
59
|
-
events: events,
|
|
60
|
-
children: children
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function div(attrs, events, children, param) {
|
|
65
|
-
return element("div", attrs, events, children, undefined);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function span(attrs, events, children, param) {
|
|
69
|
-
return element("span", attrs, events, children, undefined);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function button(attrs, events, children, param) {
|
|
73
|
-
return element("button", attrs, events, children, undefined);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function input(attrs, events, param) {
|
|
77
|
-
return element("input", attrs, events, undefined, undefined);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function h1(attrs, events, children, param) {
|
|
81
|
-
return element("h1", attrs, events, children, undefined);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function h2(attrs, events, children, param) {
|
|
85
|
-
return element("h2", attrs, events, children, undefined);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function h3(attrs, events, children, param) {
|
|
89
|
-
return element("h3", attrs, events, children, undefined);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function p(attrs, events, children, param) {
|
|
93
|
-
return element("p", attrs, events, children, undefined);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function ul(attrs, events, children, param) {
|
|
97
|
-
return element("ul", attrs, events, children, undefined);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function li(attrs, events, children, param) {
|
|
101
|
-
return element("li", attrs, events, children, undefined);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function render(node) {
|
|
105
|
-
switch (node.TAG) {
|
|
106
|
-
case "Element" :
|
|
107
|
-
var el = document.createElement(node.tag);
|
|
108
|
-
node.attrs.forEach(function (param) {
|
|
109
|
-
el.setAttribute(param[0], param[1]);
|
|
110
|
-
});
|
|
111
|
-
node.events.forEach(function (param) {
|
|
112
|
-
el.addEventListener(param[0], param[1]);
|
|
113
|
-
});
|
|
114
|
-
node.children.forEach(function (child) {
|
|
115
|
-
var childEl = render(child);
|
|
116
|
-
el.appendChild(childEl);
|
|
117
|
-
});
|
|
118
|
-
return el;
|
|
119
|
-
case "Text" :
|
|
120
|
-
return document.createTextNode(node._0);
|
|
121
|
-
case "SignalText" :
|
|
122
|
-
var signal = node._0;
|
|
123
|
-
var el$1 = document.createTextNode(Xote__Signal.peek(signal));
|
|
124
|
-
Xote__Effect.run(function () {
|
|
125
|
-
var content = Xote__Signal.get(signal);
|
|
126
|
-
el$1.textContent = content;
|
|
127
|
-
});
|
|
128
|
-
return el$1;
|
|
129
|
-
case "Fragment" :
|
|
130
|
-
var fragment = document.createDocumentFragment();
|
|
131
|
-
node._0.forEach(function (child) {
|
|
132
|
-
var childEl = render(child);
|
|
133
|
-
fragment.appendChild(childEl);
|
|
134
|
-
});
|
|
135
|
-
return fragment;
|
|
136
|
-
case "SignalFragment" :
|
|
137
|
-
var signal$1 = node._0;
|
|
138
|
-
var container = document.createElement("div");
|
|
139
|
-
container.setAttribute("data-signal-fragment", "true");
|
|
140
|
-
container.setAttribute("style", "display: contents");
|
|
141
|
-
Xote__Effect.run(function () {
|
|
142
|
-
var children = Xote__Signal.get(signal$1);
|
|
143
|
-
((container.innerHTML = ''));
|
|
144
|
-
children.forEach(function (child) {
|
|
145
|
-
var childEl = render(child);
|
|
146
|
-
container.appendChild(childEl);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
return container;
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function mount(node, container) {
|
|
155
|
-
var el = render(node);
|
|
156
|
-
container.appendChild(el);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function mountById(node, containerId) {
|
|
160
|
-
var container = document.getElementById(containerId);
|
|
161
|
-
if (container == null) {
|
|
162
|
-
console.error("Container element not found: " + containerId);
|
|
163
|
-
return ;
|
|
164
|
-
} else {
|
|
165
|
-
return mount(node, container);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var Signal;
|
|
170
|
-
|
|
171
|
-
var Effect;
|
|
172
|
-
|
|
173
|
-
var Core;
|
|
174
|
-
|
|
175
|
-
var Computed;
|
|
176
|
-
|
|
177
|
-
export {
|
|
178
|
-
Signal ,
|
|
179
|
-
Effect ,
|
|
180
|
-
Core ,
|
|
181
|
-
Computed ,
|
|
182
|
-
text ,
|
|
183
|
-
textSignal ,
|
|
184
|
-
fragment ,
|
|
185
|
-
signalFragment ,
|
|
186
|
-
list ,
|
|
187
|
-
element ,
|
|
188
|
-
div ,
|
|
189
|
-
span ,
|
|
190
|
-
button ,
|
|
191
|
-
input ,
|
|
192
|
-
h1 ,
|
|
193
|
-
h2 ,
|
|
194
|
-
h3 ,
|
|
195
|
-
p ,
|
|
196
|
-
ul ,
|
|
197
|
-
li ,
|
|
198
|
-
render ,
|
|
199
|
-
mount ,
|
|
200
|
-
mountById ,
|
|
201
|
-
}
|
|
202
|
-
/* No side effect */
|
package/src/Xote__Computed.res
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
module IntSet = Belt.Set.Int
|
|
2
|
-
module IntMap = Belt.Map.Int
|
|
3
|
-
module Signal = Xote__Signal
|
|
4
|
-
module Core = Xote__Core
|
|
5
|
-
module Observer = Xote__Observer
|
|
6
|
-
module Id = Xote__Id
|
|
7
|
-
|
|
8
|
-
let make = (calc: unit => 'a): Core.t<'a> => {
|
|
9
|
-
/* create backing signal */
|
|
10
|
-
let s = Signal.make((Obj.magic(): 'a))
|
|
11
|
-
/* mark it as absent; force first compute */
|
|
12
|
-
let initialized = ref(false)
|
|
13
|
-
|
|
14
|
-
let id = Id.make()
|
|
15
|
-
let rec recompute = () => {
|
|
16
|
-
let next = calc()
|
|
17
|
-
if initialized.contents == false {
|
|
18
|
-
initialized := true
|
|
19
|
-
Signal.set(s, next)
|
|
20
|
-
} else {
|
|
21
|
-
Signal.set(s, next)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let rec o: Observer.t = {
|
|
26
|
-
id,
|
|
27
|
-
kind: #Computed(s.id),
|
|
28
|
-
run: recompute,
|
|
29
|
-
deps: IntSet.empty,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
Core.observers := IntMap.set(Core.observers.contents, id, o)
|
|
33
|
-
|
|
34
|
-
/* initial compute under tracking */
|
|
35
|
-
Core.clearDeps(o)
|
|
36
|
-
Core.currentObserverId := Some(id)
|
|
37
|
-
o.run()
|
|
38
|
-
Core.currentObserverId := None
|
|
39
|
-
|
|
40
|
-
/* When dependencies change, scheduler will run `recompute` which writes to s,
|
|
41
|
-
and that write will notify s's own dependents. */
|
|
42
|
-
s
|
|
43
|
-
}
|