rumious 1.0.13 → 2.0.1

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.
Files changed (87) hide show
  1. package/dist/app/app.d.ts +10 -8
  2. package/dist/app/index.d.ts +0 -1
  3. package/dist/component/component.d.ts +15 -24
  4. package/dist/component/element.d.ts +10 -15
  5. package/dist/global.d.ts +15 -0
  6. package/dist/index.d.ts +7 -27
  7. package/dist/index.js +1042 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/jsx/component.d.ts +3 -0
  10. package/dist/jsx/dynamic.d.ts +2 -0
  11. package/dist/jsx/element.d.ts +9 -0
  12. package/dist/jsx/index.d.ts +4 -4
  13. package/dist/jsx/template.d.ts +25 -0
  14. package/dist/{app/module.d.ts → module/index.d.ts} +1 -1
  15. package/dist/ref/index.d.ts +1 -2
  16. package/dist/ref/ref.d.ts +37 -0
  17. package/dist/render/context.d.ts +7 -9
  18. package/dist/render/index.d.ts +4 -3
  19. package/dist/render/list.d.ts +16 -0
  20. package/dist/render/render.d.ts +3 -2
  21. package/dist/render/view.d.ts +19 -0
  22. package/dist/state/index.d.ts +1 -2
  23. package/dist/state/list.d.ts +14 -0
  24. package/dist/state/reactor.d.ts +15 -16
  25. package/dist/state/state.d.ts +11 -8
  26. package/dist/types/component.d.ts +5 -0
  27. package/dist/types/index.d.ts +3 -0
  28. package/dist/types/jsx.d.ts +16 -8
  29. package/dist/types/state.d.ts +8 -0
  30. package/dist/types/template.d.ts +5 -0
  31. package/dist/utils/checker.d.ts +2 -0
  32. package/package.json +34 -53
  33. package/rollup.config.js +21 -0
  34. package/src/app/app.ts +45 -0
  35. package/src/app/index.ts +1 -0
  36. package/src/component/component.ts +69 -0
  37. package/src/component/element.ts +76 -0
  38. package/src/component/index.ts +2 -0
  39. package/src/global.ts +20 -0
  40. package/src/index.ts +13 -0
  41. package/src/jsx/component.ts +17 -0
  42. package/src/jsx/dynamic.ts +87 -0
  43. package/src/jsx/element.ts +77 -0
  44. package/src/jsx/index.ts +7 -0
  45. package/src/jsx/template.ts +377 -0
  46. package/src/module/index.ts +7 -0
  47. package/src/ref/index.ts +1 -0
  48. package/src/ref/ref.ts +178 -0
  49. package/src/render/context.ts +11 -0
  50. package/src/render/index.ts +4 -0
  51. package/src/render/list.ts +115 -0
  52. package/src/render/render.ts +31 -0
  53. package/src/render/view.ts +101 -0
  54. package/src/state/index.ts +2 -0
  55. package/src/state/list.ts +96 -0
  56. package/src/state/reactor.ts +65 -0
  57. package/src/state/state.ts +68 -0
  58. package/src/types/component.ts +6 -0
  59. package/src/types/index.ts +3 -0
  60. package/src/types/state.ts +16 -0
  61. package/src/types/template.ts +7 -0
  62. package/src/utils/checker.ts +5 -0
  63. package/tsconfig.json +20 -0
  64. package/README.md +0 -7
  65. package/dist/context/context.d.ts +0 -12
  66. package/dist/context/index.d.ts +0 -1
  67. package/dist/index.cjs +0 -1
  68. package/dist/index.esm.js +0 -1
  69. package/dist/index.global.d.ts +0 -46
  70. package/dist/index.min.js +0 -1
  71. package/dist/performance/index.d.ts +0 -5
  72. package/dist/ref/children.d.ts +0 -23
  73. package/dist/ref/element.d.ts +0 -49
  74. package/dist/render/array.d.ts +0 -21
  75. package/dist/render/directives.d.ts +0 -1
  76. package/dist/render/dynamic.d.ts +0 -2
  77. package/dist/render/injector.d.ts +0 -15
  78. package/dist/render/struct.d.ts +0 -85
  79. package/dist/render/template.d.ts +0 -5
  80. package/dist/state/array.d.ts +0 -22
  81. package/dist/state/object.d.ts +0 -31
  82. package/dist/types/render.d.ts +0 -5
  83. package/dist/types/utils.d.ts +0 -1
  84. package/dist/types/warp.d.ts +0 -5
  85. package/dist/utils/checkers.d.ts +0 -1
  86. package/dist/utils/name.d.ts +0 -2
  87. package/dist/utils/oberve.d.ts +0 -1
package/dist/index.min.js DELETED
@@ -1 +0,0 @@
1
- !function(){class t{constructor(t,e){this.target=t,this.app=e,this.onRenderFinished=[]}findName(t){return this.target[t]}}function e(t,n,r){let i=n.generator.bind(t.target);t.renderHelper=e,i(r,t),setTimeout((async()=>{const e=[...t.onRenderFinished];t.onRenderFinished=[];for(const t of e)await t()}),0)}class n extends HTMLElement{constructor(){super(),this.props={}}setContext(t){this.context=t}setComponent(t){this.componentConstructor=t}setup(t,e){this.context=t,this.componentConstructor=e}connectedCallback(){this.componentConstructor?(this.componentInstance=new this.componentConstructor,this.componentInstance.element=this,this.componentConstructor.classNames&&(this.className=this.componentConstructor.classNames),this.componentInstance.prepare(this.context,this.props),this.componentInstance.onCreate(),this.componentInstance.requestRender()):console.warn("Rumious: Cannot find matching component constructor.")}disconnectedCallback(){this.componentInstance?.onDestroy()}}var r=Object.freeze({__proto__:null,RumiousComponent:class{static classNames="";static tagName="rumious-component";constructor(){this.renderOptions={mode:"idle"}}warp(t,n){let r=document.createDocumentFragment();e(this.context,t,r);let i=Date.now().toString(32),s=document.createElement("r-wrap");return s.id=`r-wrap-${i}`,s.appendChild(r),n.appendChild(s),{id:i,remove:()=>s.remove(),target:n}}render(t){let n=document.createDocumentFragment();return e(this.context,t,n),n}onCreate(){}onRender(){}onDestroy(){}async onBeforeRender(){}prepare(e,n){this.props=n,this.context=new t(this,e.app)}async requestRender(){await this.onBeforeRender();let t=this.template();e(this.context,t,this.element),this.onRender()}requestCleanup(){}},RumiousComponentElement:n,renderComponent:function(t,e){let n=window.RUMIOUS_JSX.createComponent(t);return n.props=e,n.setComponent(t),n}});class i{constructor(e,n={}){this.root=e,this.options=n,this.modules=[],this.context=new t(this,this)}addModule(t,e){const n=t.init(this,e);return this.modules.push(n),n}render(t){e(this.context,t,this.root)}}var s=Object.freeze({__proto__:null,RumiousApp:i,RumiousModule:class{},createApp:function(t,e){return new i(t,e)}});class o{constructor(t){this.generator=t}}class a{constructor(t){if(this.contents=t,this.targets=new Map,!t||0===t.length)throw new Error("Injector must be initialized with non-empty content");const e=t[0];this.type="string"==typeof e?"string":"element"}commit(t){this.contents=t;const e=t[0];this.type="string"==typeof e?"string":"element"}addTarget(t){this.targets.set(t,1)}inject(t){if(this.targets.has(t)&&this.contents)if(t.innerHTML="","string"===this.type)for(const e of this.contents)t.insertAdjacentHTML("beforeend",e);else for(const e of this.contents)t.appendChild(e)}injectAll(){for(const t of this.targets.keys())this.inject(t)}removeTarget(t){this.targets.delete(t)}clear(){this.targets.clear()}}class l{constructor(t){this.target=t}getElement(){return this.target}remove(){this.target.remove()}addChild(t){this.target.appendChild(t)}listChild(){return this.target.childNodes}querySelector(t){return this.target.querySelector(t)}querySelectorAll(t){return this.target.querySelectorAll(t)}set text(t){this.target.textContent=t}get text(){return this.target.textContent}set value(t){(this.target instanceof HTMLInputElement||this.target instanceof HTMLTextAreaElement)&&(this.target.value=t)}get value(){if(this.target instanceof HTMLInputElement||this.target instanceof HTMLTextAreaElement)return this.target.value}addClassName(t){this.target.classList.add(t)}removeClassName(t){this.target.classList.remove(t)}hasClassName(t){return this.target.classList.contains(t)}toggleClass(t,e){return this.target.classList.toggle(t,e)}setStyle(t){Object.assign(this.target.style,t)}getStyle(t){return getComputedStyle(this.target).getPropertyValue(t)}setAttribute(t,e){this.target.setAttribute(t,e)}getAttribute(t){return this.target.getAttribute(t)}removeAttribute(t){this.target.removeAttribute(t)}on(t,e,n){this.target.addEventListener(t,e,n)}off(t,e,n){this.target.removeEventListener(t,e,n)}set html(t){this.target.innerHTML=t}get html(){return this.target.innerHTML}getBoundingRect(){return this.target.getBoundingClientRect()}isInViewport(){const t=this.target.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}prependChild(t){this.target.prepend(t)}setDisabled(t){(this.target instanceof HTMLButtonElement||this.target instanceof HTMLInputElement||this.target instanceof HTMLTextAreaElement)&&(this.target.disabled=t)}addClasses(...t){this.target.classList.add(...t)}removeClasses(...t){this.target.classList.remove(...t)}replaceClass(t,e){this.target.classList.replace(t,e)}moveTo(t){t.appendChild(this.target)}getParent(){return this.target.parentElement}getNextSibling(){return this.target.nextElementSibling}getPreviousSibling(){return this.target.previousElementSibling}hide(){this.target.style.display="none"}show(){this.target.style.removeProperty("display")}isHidden(){return"none"===window.getComputedStyle(this.target).display}scrollIntoView(t={behavior:"smooth"}){this.target.scrollIntoView(t)}matches(t){return this.target.matches(t)}getChildren(){return Array.from(this.target.children)}insertAfter(t){this.target.parentNode&&this.target.parentNode.insertBefore(t,this.target.nextSibling)}insertBefore(t){this.target.parentNode&&this.target.parentNode.insertBefore(t,this.target)}clearChildren(){for(;this.target.firstChild;)this.target.removeChild(this.target.firstChild)}animate(t,e){return this.target.animate(t,e)}}function c(t){const e=t.indexOf("$");return-1!==e?t.slice(e+1):""}class u{constructor(t){this.target=t,this.bindings=[]}addBinding(t){this.bindings.push(t)}removeBinding(t){this.bindings=this.bindings.filter((e=>e!==t))}async emit(t){await Promise.allSettled(this.bindings.map((e=>{try{const n=e(t);return n instanceof Promise?n:Promise.resolve(n)}catch(t){return Promise.reject(t)}})))}}const h="remove",p="replace",f="add",d=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),g=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),m=Symbol.iterator,y={mutable:"mutable",immutable:"immutable"},v={};function b(t,e){return t instanceof Map?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function w(t,e){if(e in t){let n=Reflect.getPrototypeOf(t);for(;n;){const t=Reflect.getOwnPropertyDescriptor(n,e);if(t)return t;n=Reflect.getPrototypeOf(n)}}}function E(t){return Object.getPrototypeOf(t)===Set.prototype}function S(t){return Object.getPrototypeOf(t)===Map.prototype}function O(t){var e;return null!==(e=t.copy)&&void 0!==e?e:t.original}function M(t){return!!C(t)}function C(t){return"object"!=typeof t?null:null==t?void 0:t[d]}function k(t){var e;const n=C(t);return n?null!==(e=n.copy)&&void 0!==e?e:n.original:t}function j(t,e){if(!t||"object"!=typeof t)return!1;let n;return Object.getPrototypeOf(t)===Object.prototype||Array.isArray(t)||t instanceof Map||t instanceof Set||!!(null==e?void 0:e.mark)&&((n=e.mark(t,y))===y.immutable||"function"==typeof n)}function T(t,e=[]){if(Object.hasOwnProperty.call(t,"key")){const n=t.parent.copy,r=C(P(n,t.key));if(null!==r&&(null==r?void 0:r.original)!==t.original)return null;const i=3===t.parent.type,s=i?Array.from(t.parent.setMap.keys()).indexOf(t.key):t.key;if(!(i&&n.size>s||b(n,s)))return null;e.push(s)}if(t.parent)return T(t.parent,e);e.reverse();try{!function(t,e){for(let n=0;n<e.length-1;n+=1){const r=e[n];if("object"!=typeof(t=P(3===R(t)?Array.from(t):t,r)))throw new Error(`Cannot resolve patch at '${e.join("/")}'.`)}}(t.copy,e)}catch(t){return null}return e}function R(t){return Array.isArray(t)?1:t instanceof Map?2:t instanceof Set?3:0}function P(t,e){return 2===R(t)?t.get(e):t[e]}function A(t,e,n){2===R(t)?t.set(e,n):t[e]=n}function _(t,e){const n=C(t);return(n?O(n):t)[e]}function x(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function z(t){if(t)for(;t.finalities.revoke.length>0;){t.finalities.revoke.pop()()}}function D(t,e){return e?t:[""].concat(t).map((t=>{const e=`${t}`;return-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const N=Object.prototype.propertyIsEnumerable;function I(t,e){let n;if(Array.isArray(t))return Array.prototype.concat.call(t);if(t instanceof Set){if(!E(t)){return new(0,Object.getPrototypeOf(t).constructor)(t.values())}return Set.prototype.difference?Set.prototype.difference.call(t,new Set):new Set(t.values())}if(t instanceof Map){if(!S(t)){return new(0,Object.getPrototypeOf(t).constructor)(t)}return new Map(t)}if((null==e?void 0:e.mark)&&(n=e.mark(t,y),void 0!==n)&&n!==y.mutable){if(n===y.immutable)return function(t){const e=Object.create(Object.getPrototypeOf(t));return Reflect.ownKeys(t).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(t,n);r.enumerable&&r.configurable&&r.writable?e[n]=t[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:t[n]}),Reflect.defineProperty(e,n,r))})),e}(t);if("function"==typeof n){if(e.enablePatches||e.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype){const e={};return Object.keys(t).forEach((n=>{e[n]=t[n]})),Object.getOwnPropertySymbols(t).forEach((n=>{N.call(t,n)&&(e[n]=t[n])})),e}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function L(t){t.copy||(t.copy=I(t.original,t.options))}function H(t){if(!j(t))return k(t);if(Array.isArray(t))return t.map(H);if(t instanceof Map){const e=Array.from(t.entries()).map((([t,e])=>[t,H(e)]));if(!S(t)){return new(0,Object.getPrototypeOf(t).constructor)(e)}return new Map(e)}if(t instanceof Set){const e=Array.from(t).map(H);if(!E(t)){return new(0,Object.getPrototypeOf(t).constructor)(e)}return new Set(e)}const e=Object.create(Object.getPrototypeOf(t));for(const n in t)e[n]=H(t[n]);return e}function B(t){return M(t)?H(t):t}function F(t){var e;t.assignedMap=null!==(e=t.assignedMap)&&void 0!==e?e:new Map,t.operated||(t.operated=!0,t.parent&&F(t.parent))}function Y(){throw new Error("Cannot modify frozen object")}function V(t,e,n,r,i){{n=null!=n?n:new WeakMap,r=null!=r?r:[],i=null!=i?i:[];const s=n.has(t)?n.get(t):t;if(r.length>0){const t=r.indexOf(s);if(s&&"object"==typeof s&&-1!==t){if(r[0]===s)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${i.slice(0,t).map(((t,e)=>{if("symbol"==typeof t)return`[${t.toString()}]`;const n=r[e];return"object"==typeof t&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(t):t})).join("/")}`)}r.push(s),i.push(e)}else r.push(s)}if(Object.isFrozen(t)||M(t))return r.pop(),void i.pop();switch(R(t)){case 2:for(const[e,s]of t)V(e,e,n,r,i),V(s,e,n,r,i);t.set=t.clear=t.delete=Y;break;case 3:for(const e of t)V(e,e,n,r,i);t.add=t.clear=t.delete=Y;break;case 1:Object.freeze(t);let e=0;for(const s of t)V(s,e,n,r,i),e+=1;break;default:Object.freeze(t),Object.keys(t).forEach((e=>{V(t[e],e,n,r,i)}))}r.pop(),i.pop()}function q(t,e){const n=R(t);if(0===n)Reflect.ownKeys(t).forEach((n=>{e(n,t[n],t)}));else if(1===n){let n=0;for(const r of t)e(n,r,t),n+=1}else t.forEach(((n,r)=>e(r,n,t)))}function K(t,e,n){if(M(t)||!j(t,n)||e.has(t)||Object.isFrozen(t))return;const r=t instanceof Set,i=r?new Map:void 0;if(e.add(t),q(t,((s,o)=>{var a;if(M(o)){const e=C(o);L(e);const n=(null===(a=e.assignedMap)||void 0===a?void 0:a.size)||e.operated?e.copy:e.original;A(r?i:t,s,n)}else K(o,e,n)})),i){const e=t,n=Array.from(e);e.clear(),n.forEach((t=>{e.add(i.has(t)?i.get(t):t)}))}}function U(t,e){const n=3===t.type?t.setMap:t.copy;t.finalities.revoke.length>1&&t.assignedMap.get(e)&&n&&K(P(n,e),t.finalities.handledSet,t.options)}function W(t){3===t.type&&t.copy&&(t.copy.clear(),t.setMap.forEach((e=>{t.copy.add(k(e))})))}function $(t,e,n,r){if(t.operated&&t.assignedMap&&t.assignedMap.size>0&&!t.finalized){if(n&&r){const i=T(t);i&&e(t,i,n,r)}t.finalized=!0}}function J(t,e,n,r){const i=C(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push(((s,o)=>{var a;const l=3===t.type?t.setMap:t.copy;if(x(P(l,e),n)){let n=i.original;i.copy&&(n=i.copy),W(t),$(t,r,s,o),t.options.enableAutoFreeze&&(t.options.updatedValues=null!==(a=t.options.updatedValues)&&void 0!==a?a:new WeakMap,t.options.updatedValues.set(n,i.original)),A(l,e,n)}})),t.options.enableAutoFreeze&&i.finalities!==t.finalities&&(t.options.enableAutoFreeze=!1)),j(n,t.options)&&t.finalities.draft.push((()=>{x(P(3===t.type?t.setMap:t.copy,e),n)&&U(t,e)}))}function X(t,e,n,r){const{pathAsArray:i=!0}=t.options.enablePatches;switch(t.type){case 0:case 2:return function({original:t,copy:e,assignedMap:n},r,i,s,o){n.forEach(((n,a)=>{const l=P(t,a),c=B(P(e,a)),u=n?b(t,a)?p:f:h;if(x(l,c)&&u===p)return;const d=D(r.concat(a),o);i.push(u===h?{op:u,path:d}:{op:u,path:d,value:c}),s.push(u===f?{op:h,path:d}:u===h?{op:f,path:d,value:l}:{op:p,path:d,value:l})}))}(t,e,n,r,i);case 1:return function(t,e,n,r,i){let{original:s,assignedMap:o,options:a}=t,l=t.copy;l.length<s.length&&([s,l]=[l,s],[n,r]=[r,n]);for(let t=0;t<s.length;t+=1)if(o.get(t.toString())&&l[t]!==s[t]){const o=D(e.concat([t]),i);n.push({op:p,path:o,value:B(l[t])}),r.push({op:p,path:o,value:B(s[t])})}for(let t=s.length;t<l.length;t+=1){const r=D(e.concat([t]),i);n.push({op:f,path:r,value:B(l[t])})}if(s.length<l.length){const{arrayLengthAssignment:t=!0}=a.enablePatches;if(t){const t=D(e.concat(["length"]),i);r.push({op:p,path:t,value:s.length})}else for(let t=l.length;s.length<t;t-=1){const n=D(e.concat([t-1]),i);r.push({op:h,path:n})}}}(t,e,n,r,i);case 3:return function({original:t,copy:e},n,r,i,s){let o=0;t.forEach((t=>{if(!e.has(t)){const e=D(n.concat([o]),s);r.push({op:h,path:e,value:t}),i.unshift({op:f,path:e,value:t})}o+=1})),o=0,e.forEach((e=>{if(!t.has(e)){const t=D(n.concat([o]),s);r.push({op:f,path:t,value:e}),i.unshift({op:h,path:t,value:e})}o+=1}))}(t,e,n,r,i)}}const G=(t,e,n=!1)=>{if("object"==typeof t&&null!==t&&(!j(t,e)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},Q={get size(){return O(C(this)).size},has(t){return O(C(this)).has(t)},set(t,e){const n=C(this),r=O(n);return r.has(t)&&x(r.get(t),e)||(L(n),F(n),n.assignedMap.set(t,!0),n.copy.set(t,e),J(n,t,e,X)),this},delete(t){if(!this.has(t))return!1;const e=C(this);return L(e),F(e),e.original.has(t)?e.assignedMap.set(t,!1):e.assignedMap.delete(t),e.copy.delete(t),!0},clear(){const t=C(this);if(this.size){L(t),F(t),t.assignedMap=new Map;for(const[e]of t.original)t.assignedMap.set(e,!1);t.copy.clear()}},forEach(t,e){O(C(this)).forEach(((n,r)=>{t.call(e,this.get(r),r,this)}))},get(t){var e,n;const r=C(this),i=O(r).get(t),s=(null===(n=(e=r.options).mark)||void 0===n?void 0:n.call(e,i,y))===y.mutable;if(r.options.strict&&G(i,r.options,s),s)return i;if(r.finalized||!j(i,r.options))return i;if(i!==r.original.get(t))return i;const o=v.createDraft({original:i,parentDraft:r,key:t,finalities:r.finalities,options:r.options});return L(r),r.copy.set(t,o),o},keys(){return O(C(this)).keys()},values(){const t=this.keys();return{[m]:()=>this.values(),next:()=>{const e=t.next();if(e.done)return e;return{done:!1,value:this.get(e.value)}}}},entries(){const t=this.keys();return{[m]:()=>this.entries(),next:()=>{const e=t.next();if(e.done)return e;const n=this.get(e.value);return{done:!1,value:[e.value,n]}}}},[m](){return this.entries()}},Z=Reflect.ownKeys(Q),tt=(t,e,{isValuesIterator:n})=>()=>{var r,i;const s=e.next();if(s.done)return s;const o=s.value;let a=t.setMap.get(o);const l=C(a),c=(null===(i=(r=t.options).mark)||void 0===i?void 0:i.call(r,a,y))===y.mutable;if(t.options.strict&&G(o,t.options,c),c||l||!j(o,t.options)||t.finalized||!t.original.has(o))l&&(a=l.proxy);else{const e=v.createDraft({original:o,parentDraft:t,key:o,finalities:t.finalities,options:t.options});t.setMap.set(o,e),a=e}return{done:!1,value:n?a:[a,a]}},et={get size(){return C(this).setMap.size},has(t){const e=C(this);if(e.setMap.has(t))return!0;L(e);const n=C(t);return!(!n||!e.setMap.has(n.original))},add(t){const e=C(this);return this.has(t)||(L(e),F(e),e.assignedMap.set(t,!0),e.setMap.set(t,t),J(e,t,t,X)),this},delete(t){if(!this.has(t))return!1;const e=C(this);L(e),F(e);const n=C(t);return n&&e.setMap.has(n.original)?(e.assignedMap.set(n.original,!1),e.setMap.delete(n.original)):(!n&&e.setMap.has(t)?e.assignedMap.set(t,!1):e.assignedMap.delete(t),e.setMap.delete(t))},clear(){if(!this.size)return;const t=C(this);L(t),F(t);for(const e of t.original)t.assignedMap.set(e,!1);t.setMap.clear()},values(){const t=C(this);L(t);const e=t.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:tt(t,e,{isValuesIterator:!0})}},entries(){const t=C(this);L(t);const e=t.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:tt(t,e,{isValuesIterator:!1})}},keys(){return this.values()},[m](){return this.values()},forEach(t,e){const n=this.values();let r=n.next();for(;!r.done;)t.call(e,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(et,{intersection(t){return Set.prototype.intersection.call(new Set(this.values()),t)},union(t){return Set.prototype.union.call(new Set(this.values()),t)},difference(t){return Set.prototype.difference.call(new Set(this.values()),t)},symmetricDifference(t){return Set.prototype.symmetricDifference.call(new Set(this.values()),t)},isSubsetOf(t){return Set.prototype.isSubsetOf.call(new Set(this.values()),t)},isSupersetOf(t){return Set.prototype.isSupersetOf.call(new Set(this.values()),t)},isDisjointFrom(t){return Set.prototype.isDisjointFrom.call(new Set(this.values()),t)}});const nt=Reflect.ownKeys(et),rt=new WeakSet,it={get(t,e,n){var r,i;const s=null===(r=t.copy)||void 0===r?void 0:r[e];if(s&&rt.has(s))return s;if(e===d)return t;let o;if(t.options.mark){const r="size"===e&&(t.original instanceof Map||t.original instanceof Set)?Reflect.get(t.original,e):Reflect.get(t.original,e,n);if(o=t.options.mark(r,y),o===y.mutable)return t.options.strict&&G(r,t.options,!0),r}const a=O(t);if(a instanceof Map&&Z.includes(e)){if("size"===e)return Object.getOwnPropertyDescriptor(Q,"size").get.call(t.proxy);const n=Q[e];if(n)return n.bind(t.proxy)}if(a instanceof Set&&nt.includes(e)){if("size"===e)return Object.getOwnPropertyDescriptor(et,"size").get.call(t.proxy);const n=et[e];if(n)return n.bind(t.proxy)}if(!b(a,e)){const n=w(a,e);return n?"value"in n?n.value:null===(i=n.get)||void 0===i?void 0:i.call(t.proxy):void 0}const l=a[e];if(t.options.strict&&G(l,t.options),t.finalized||!j(l,t.options))return l;if(l===_(t.original,e)){if(L(t),t.copy[e]=st({original:t.original[e],parentDraft:t,key:1===t.type?Number(e):e,finalities:t.finalities,options:t.options}),"function"==typeof o){const n=C(t.copy[e]);return L(n),F(n),n.copy}return t.copy[e]}return l},set(t,e,n){var r;if(3===t.type||2===t.type)throw new Error("Map/Set draft does not support any property assignment.");let i;if(1===t.type&&"length"!==e&&(!(Number.isInteger(i=Number(e))&&i>=0)||0!==e&&0!==i&&String(i)!==String(e)))throw new Error("Only supports setting array indices and the 'length' property.");const s=w(O(t),e);if(null==s?void 0:s.set)return s.set.call(t.proxy,n),!0;const o=_(O(t),e),a=C(o);return a&&x(a.original,n)?(t.copy[e]=n,t.assignedMap=null!==(r=t.assignedMap)&&void 0!==r?r:new Map,t.assignedMap.set(e,!1),!0):(x(n,o)&&(void 0!==n||b(t.original,e))||(L(t),F(t),b(t.original,e)&&x(n,t.original[e])?t.assignedMap.delete(e):t.assignedMap.set(e,!0),t.copy[e]=n,J(t,e,n,X)),!0)},has:(t,e)=>e in O(t),ownKeys:t=>Reflect.ownKeys(O(t)),getOwnPropertyDescriptor(t,e){const n=O(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r?{writable:!0,configurable:1!==t.type||"length"!==e,enumerable:r.enumerable,value:n[e]}:r},getPrototypeOf:t=>Reflect.getPrototypeOf(t.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(t,e){var n;return 1===t.type?it.set.call(this,t,e,void 0,t.proxy):(void 0!==_(t.original,e)||e in t.original?(L(t),F(t),t.assignedMap.set(e,!1)):(t.assignedMap=null!==(n=t.assignedMap)&&void 0!==n?n:new Map,t.assignedMap.delete(e)),t.copy&&delete t.copy[e],!0)}};function st(t){const{original:e,parentDraft:n,key:r,finalities:i,options:s}=t,o=R(e),a={type:o,finalized:!1,parent:n,original:e,copy:null,proxy:null,finalities:i,options:s,setMap:3===o?new Map(e.entries()):void 0};(r||"key"in t)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===o?Object.assign([],a):a,it);if(i.revoke.push(c),rt.add(l),a.proxy=l,n){const t=n;t.finalities.draft.push(((e,n)=>{var i,s;const o=C(l);let a=3===t.type?t.setMap:t.copy;const c=P(a,r),u=C(c);if(u){let s=u.original;u.operated&&(s=k(c)),W(u),$(u,X,e,n),t.options.enableAutoFreeze&&(t.options.updatedValues=null!==(i=t.options.updatedValues)&&void 0!==i?i:new WeakMap,t.options.updatedValues.set(s,u.original)),A(a,r,s)}null===(s=o.callbacks)||void 0===s||s.forEach((t=>{t(e,n)}))}))}else{const t=C(l);t.finalities.draft.push(((e,n)=>{W(t),$(t,X,e,n)}))}return l}function ot(t,e,n,r,i){var s;const o=C(t),a=null!==(s=null==o?void 0:o.original)&&void 0!==s?s:t,l=!!e.length;if(null==o?void 0:o.operated)for(;o.finalities.draft.length>0;){o.finalities.draft.pop()(n,r)}const c=l?e[0]:o?o.operated?o.copy:o.original:t;return o&&z(o),i&&V(c,c,null==o?void 0:o.options.updatedValues),[c,n&&l?[{op:p,path:[],value:e[0]}]:n,r&&l?[{op:p,path:[],value:a}]:r]}function at(t){const{rootDraft:e,value:n,useRawReturn:r=!1,isRoot:i=!0}=t;q(n,((n,r,i)=>{const s=C(r);if(s&&e&&s.finalities===e.finalities){t.isContainDraft=!0;const e=s.original;if(i instanceof Set){const t=Array.from(i);i.clear(),t.forEach((t=>i.add(n===t?e:t)))}else A(i,n,e)}else"object"==typeof r&&null!==r&&(t.value=r,t.isRoot=!1,at(t))})),i&&(t.isContainDraft||console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."),r&&console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."))}function lt(t){var e;const n=C(t);if(!j(t,null==n?void 0:n.options))return t;const r=R(t);if(n&&!n.operated)return n.original;let i;function s(){i=2===r?S(t)?new Map(t):new(Object.getPrototypeOf(t).constructor)(t):3===r?Array.from(n.setMap.values()):I(t,null==n?void 0:n.options)}if(n){n.finalized=!0;try{s()}finally{n.finalized=!1}}else i=t;if(q(i,((e,r)=>{if(n&&x(P(n.original,e),r))return;const o=lt(r);o!==r&&(i===t&&s(),A(i,e,o))})),3===r){const t=null!==(e=null==n?void 0:n.original)&&void 0!==e?e:i;return E(t)?new Set(i):new(Object.getPrototypeOf(t).constructor)(i)}return i}function ct(t){if(!M(t))throw new Error(`current() is only used for Draft, parameter: ${t}`);return lt(t)}v.createDraft=st;const ut=function t(e,n,r){var i,s,o;if("function"==typeof e&&"function"!=typeof n)return function(r,...i){return t(r,(t=>e.call(this,t,...i)),n)};const a=e,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},ht),c);const u=M(a)?ct(a):a,h=Array.isArray(c.mark)?(t,e)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(t,e);if(r)return r}}:c.mark,p=null!==(i=c.enablePatches)&&void 0!==i&&i,f=null!==(s=c.strict)&&void 0!==s&&s,d={enableAutoFreeze:null!==(o=c.enableAutoFreeze)&&void 0!==o&&o,mark:h,strict:f,enablePatches:p};if(!j(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[m,v]=function(t,e){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let i,s;e.enablePatches&&(i=[],s=[]);const o=(null===(n=e.mark)||void 0===n?void 0:n.call(e,t,y))!==y.mutable&&j(t,e)?st({original:t,parentDraft:null,finalities:r,options:e}):t;return[o,(t=[])=>{const[n,r,a]=ot(o,t,i,s,e.enableAutoFreeze);return e.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!j(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[m,v]}let b;try{b=l(m)}catch(t){throw z(C(m)),t}const w=t=>{const e=C(m);if(!M(t)){if(void 0!==t&&!x(t,m)&&(null==e?void 0:e.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==t?void 0:t[g];if(n){const r=n[0];return d.strict&&"object"==typeof t&&null!==t&&at({rootDraft:e,value:t,useRawReturn:!0}),v([r])}if(void 0!==t)return"object"==typeof t&&null!==t&&at({rootDraft:e,value:t}),v([t])}if(t===m||void 0===t)return v([]);const n=C(t);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return v([ct(t)])}return v([t])};return b instanceof Promise?b.then(w,(t=>{throw z(C(m)),t})):w(b)};var ht;Object.prototype.constructor.toString();class pt{constructor(t,e){this.value=t,this.reactor=e??new u(this)}set(t){this.value=t,this.reactor.emit({type:"SET",target:this,value:t})}get(){return this.value}increase(t=1){"number"==typeof this.value&&this.set(this.value+t)}produce(t){const[e,n]=ut(this.value);t(e),this.set(n())}}function ft(t,e){t.reactor.addBinding(e)}function dt(t,e){t.reactor.removeBinding(e)}const gt={on:function(t,e,n,r){"string"==typeof r&&(r=t.findName(c(r))),e.addEventListener(n,r)},ref:function(t,e,n,r){if("string"==typeof r&&(r=t.findName(c(r))),!(r instanceof l))throw Error("Rumious: ref directive required RumiousElementRef !");r.target=e},inject:function(t,e,n,r){if("string"==typeof r&&(r=t.findName(c(r))),!(r instanceof a))throw Error("Rumious: inject directive required RumiousInjector !");r.addTarget(e),r.inject(e)},bind:function(t,e,n,r){if("string"==typeof r&&(r=t.findName(c(r))),!(r instanceof pt))throw Error("Rumious: bind directive requires RumiousState!");{const t={text:(t,e)=>e.textContent=t,html:(t,e)=>e.innerHTML=t,value:(t,e)=>e.value=t,class:(t,e)=>e.className=t,style:(t,e)=>e.style.cssText=t,checked:(t,e)=>e.checked=t,disabled:(t,e)=>{"disabled"in e&&(e.disabled=t)},readonly:(t,e)=>e.readOnly=t,required:(t,e)=>e.required=t,selected:(t,e)=>e.selected=t,src:(t,e)=>e.src=t,href:(t,e)=>e.href=t,placeholder:(t,e)=>e.placeholder=t,title:(t,e)=>e.title=t,show:(t,e)=>e.style.display=t?"":"none",hide:(t,e)=>e.style.display=t?"none":""}[n]??((t,e)=>e.setAttribute(n,t));t(r.value,e),r.reactor.addBinding((()=>t(r.value,e)))}},model:function(t,e,n,r){if("string"==typeof r&&(r=t.findName(c(r))),!(r instanceof pt&&(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)))throw Error("Rumious: model directive requires RumiousState and a valid form element!");{const t=e.type;e.addEventListener("input",(()=>{if(e instanceof HTMLInputElement)switch(t){case"checkbox":r.set(e.checked);break;case"radio":e.checked&&r.set(e.value);break;default:r.set(e.value)}else(e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&r.set(e.value)}))}}};class mt{constructor(t,e){this.state=t,this.callback=e}prepare(t,e){this.anchorElement=t,this.context=e}renderItem(t,e){const n=document.createDocumentFragment(),r=this.callback(t,e);return this.context.renderHelper(this.context,r,n),n}scheduleRenderAll(){requestAnimationFrame((()=>this.renderAll()))}async render(){this.state.reactor.addBinding(this.onStateChange.bind(this)),this.scheduleRenderAll()}renderAll(){const t=document.createDocumentFragment();this.state.value.forEach(((e,n)=>{t.appendChild(this.renderItem(e,n))})),this.anchorElement.replaceChildren(t)}updateElement(t,e){const n=this.anchorElement.children[t];n&&this.anchorElement.replaceChild(this.renderItem(e,t),n)}insertOrAppendElement(t,e){const n=this.renderItem(t,e),r=this.anchorElement.children[e];r?this.anchorElement.insertBefore(n,r):this.anchorElement.appendChild(n)}removeElement(t){this.anchorElement.children[t]?.remove()}appendElement(t,e){if(Array.isArray(t)){const n=document.createDocumentFragment();t.forEach(((t,r)=>{n.appendChild(this.renderItem(t,e+r))})),this.anchorElement.replaceChildren(n),this.anchorElement.appendChild(n)}}async onStateChange(t){if(document.contains(this.anchorElement))switch(t.type){case"SET":default:this.scheduleRenderAll();break;case"SET_BY_KEY":this.updateElement(t.key,t.value);break;case"REMOVE_BY_KEY":this.removeElement(t.key);break;case"INSERT_BY_KEY":this.insertOrAppendElement(t.value,t.key);break;case"APPEND":this.appendElement(t.value,this.state.value.length-t.value.length);break;case"PREPEND":this.anchorElement.prepend(this.renderItem(t.value,0))}else this.state.reactor.removeBinding(this.onStateChange.bind(this))}}class yt extends mt{isLoading=!1;constructor(t){super(t.data,t.template),this.options=t,this.limit=t.limit??50,this.offset=t.offset??0,this.onScroll=this.handleScroll.bind(this),this.onControl=this.handleControl.bind(this),this.onChange=this.handleStateChange.bind(this)}setState(t){this.options.state?.set(t)}async fetchData(){const t=await(this.options.loader?.(this.limit,this.offset))??[];return this.offset+=t.length,t}getScrollInfo(){const t=this.options.scrollElement;return t===window?{scrollTop:window.scrollY,scrollHeight:document.documentElement.scrollHeight,clientHeight:window.innerHeight}:{scrollTop:t.scrollTop,scrollHeight:t.scrollHeight,clientHeight:t.clientHeight}}async addData(){const t=this.options.scrollElement;this.isLoading=!0,this.setState("START_FETCH");const e=await this.fetchData();this.setState("END_FETCH"),0===e.length?(this.setState("NO_DATA"),t.removeEventListener("scroll",this.onScroll)):this.state.append(...e),this.isLoading=!1}async handleScroll(){const{scrollTop:t,scrollHeight:e,clientHeight:n}=this.getScrollInfo();t+n>=e-this.options.threshold&&!this.isLoading&&await this.addData()}handleControl(){"FETCH"===this.options?.controller?.get()&&this.addData()}handleStateChange(t){if(!document.contains(this.anchorElement))return this.options.controller&&dt(this.options.controller,this.onControl),void this.state.reactor.removeBinding(this.onChange);this.onStateChange(t)}async render(){this.options.scrollElement.addEventListener("scroll",this.onScroll),this.options.controller&&ft(this.options.controller,this.onControl),this.state.reactor.addBinding(this.onChange),this.scheduleRenderAll()}}class vt extends mt{constructor(t){super(t.data,t.template),this.options=t,this.size=t.size,this.currentPage=t.page??0}getPageData(){const t=this.currentPage*this.size,e=t+this.size;return this.state.value.slice(t,e)}renderPage(){const t=document.createDocumentFragment(),e=this.currentPage*this.size,n=e+this.size;this.state.value.slice(e,n).forEach(((n,r)=>{t.appendChild(this.renderItem(n,e+r))})),this.anchorElement.replaceChildren(t),this.calculate()}goToPage(t){const e=Math.floor(this.state.value.length/this.size);console.log(e),this.currentPage=Math.max(0,Math.min(t,e)),this.renderPage()}nextPage(){this.goToPage(this.currentPage+1)}prevPage(){this.goToPage(this.currentPage-1)}onControl({value:t}){switch(t){case"NEXT":this.nextPage();break;case"PREV":this.prevPage()}}async calculate(){if(this.options.info&&this.options.info.set({current:this.currentPage,size:this.options.size}),this.options.pages){const e=Math.floor(this.state.value.length/this.size);let n=[];for(var t=0;t<e;t++)n.push({isRender:this.currentPage===t,index:t});this.options.pages.set(n)}}async render(){ft(this.options.controller,this.onControl.bind(this)),this.options.controller,this.state.reactor.addBinding(this.onStateChange.bind(this)),this.renderPage()}async onStateChange(t){if(!document.contains(this.anchorElement))return dt(this.options.controller,this.onControl.bind(this)),void this.state.reactor.removeBinding(this.onStateChange.bind(this));const e=this.currentPage*this.size,n=e+this.size;switch(t.type){case"SET":this.currentPage=0,this.renderPage();break;case"SET_BY_KEY":case"REMOVE_BY_KEY":case"INSERT_BY_KEY":(r=t.key)>=e&&r<n&&this.renderPage();break;case"APPEND":const i=this.state.value.length,s=Math.floor((i-1)/this.size);this.currentPage===s&&this.renderPage();break;default:this.renderPage()}var r}}function bt(t){return t!==Object(t)}async function wt(t,e,r,i){if(e.parentNode)if(bt(r))!function(t,e){t.textContent=String(e)}(e,r);else if(r instanceof pt&&r.value instanceof Node)!function(t,e,r){let i=t;const s=()=>{if(!document.contains(i))return void e.reactor.removeBinding(s);const t=e.value;t instanceof n&&t.setContext(r),i.parentNode?.replaceChild(t,i),i=t};s(),e.reactor.addBinding(s)}(e,r,i);else if(r instanceof pt)!function(t,e){const n=()=>{document.contains(t)?t.textContent=String(e.value):e.reactor.removeBinding(n)};n(),e.reactor.addBinding(n)}(e,r);else if(Array.isArray(r))!function(t,e,n){const r=document.createDocumentFragment();for(const t of e)t instanceof o?n.renderHelper?.(n,t,r):bt(t)?r.appendChild(document.createTextNode(String(t))):t instanceof Node&&r.appendChild(t.cloneNode(!0));t.replaceWith(r)}(e,r,i);else if(r instanceof mt)r.prepare(e.parentElement,i),r.render(),e.remove();else if(r instanceof HTMLElement)e.replaceWith(r);else if(r instanceof o)!function(t,e,n){const r=document.createDocumentFragment();n.renderHelper?.(n,e,r),t.replaceWith(r)}(e,r,i);else if(r instanceof NodeList||r instanceof HTMLCollection)r.length>0?function(t,e){const n=document.createDocumentFragment();for(const t of Array.from(e))n.appendChild(t.cloneNode(!0));t.replaceWith(n)}(e,r):e.remove();else if(r&&"function"==typeof r.toString)try{e.textContent=r.toString()}catch{e.textContent=""}else e.textContent=""}function Et(t){return new o(t)}window.RUMIOUS_JSX={template:Et,createElement:function(...t){throw console.log(t),Error("Rumious doesn't use createElement !")},addDirective:function(t,e,n,r="",i){let s=gt[n];if(!s)throw Error("Rumious: Cannot solve directive !");s(e,t,r,i)},dynamicValue:function(t,e,n,r){wt(0,e,n,r)},createComponent:function(t){let e=t.tagName;return window.customElements.get(e)||window.customElements.define(e,class extends n{static tag=e}),document.createElement(e)}};var St=Object.freeze({__proto__:null,Fragment:function(...t){throw Error("Fragment element must be compiled by Rumious !")},template:Et}),Ot=Object.freeze({__proto__:null,RumiousDymanicInjector:a,RumiousRenderTemplate:o,createHTMLInjector:function(t){return new a([t])},createInfinityScroll:function(t){return new yt(t)},createPagination:function(t){return new vt(t)},renderList:function(t,e){return new mt(t,e)}});var Mt=Object.freeze({__proto__:null,RumiousChildrenRef:class{constructor(t){this.target=t}list(){return Array.from(this.target.children)}getChild(t){return this.list()[t]}remove(t){this.list()[t]?.remove()}add(t){this.target.appendChild(t)}querySelector(t){return this.target.querySelector(t)}querySelectorAll(t){return this.target.querySelectorAll(t)}clear(){this.target.innerHTML=""}replaceChild(t,e){const n=this.getChild(t);n&&this.target.replaceChild(e,n)}insertBefore(t,e){const n=this.getChild(e);n?this.target.insertBefore(t,n):this.add(t)}prepend(t){this.target.prepend(t)}getFirstChild(){return this.list()[0]}getLastChild(){return this.list()[this.list().length-1]}hasChildren(){return this.target.hasChildNodes()}count(){return this.target.children.length}find(t){return this.list().find(t)}forEach(t){this.list().forEach(t)}removeAllMatching(t){this.querySelectorAll(t).forEach((t=>t.remove()))}toggleClass(t){this.list().forEach((e=>e.classList.toggle(t)))}setAttribute(t,e){this.list().forEach((n=>n.setAttribute(t,e)))}},RumiousElementRef:l,createElementRef:function(){return new l(document.createElement("span"))}});class Ct extends pt{constructor(t,e){super(t,e)}set(t,e){if("number"==typeof t&&void 0!==e){const n=t,r=e;this.value[n]=r,this.reactor.emit({type:"SET_BY_KEY",value:r,target:this,key:n})}else{if(!Array.isArray(t))throw new Error("Invalid arguments passed to set()");super.set(t)}}get(t){return"number"==typeof t?this.value[t]:this.value}insert(t,e){return this.value.splice(t,0,e),this.reactor.emit({type:"INSERT_BY_KEY",value:e,target:this,key:t}),this}remove(t){return this.value.splice(t,1),this.reactor.emit({type:"REMOVE_BY_KEY",value:null,target:this,key:t}),this}append(...t){return this.value.push(...t),this.reactor.emit({type:"APPEND",value:t,target:this}),this}prepend(t){return this.value.unshift(t),this.reactor.emit({type:"PREPEND",value:t,target:this}),this}clear(){return this.value.length=0,this.reactor.emit({type:"SET",value:null,target:this}),this}replace(t,e){if(t<0||t>=this.value.length)throw new Error("Index out of bounds");return this.value[t]=e,this.reactor.emit({type:"SET_BY_KEY",value:e,target:this,key:t}),this}filter(t){return this.value=this.value.filter(t),this.reactor.emit({type:"SET",value:null,target:this}),this}map(t){return this.value=this.value.map(t),this.reactor.emit({type:"SET",value:null,target:this}),this}sort(t){return this.value.sort(t),this.reactor.emit({type:"SET",value:null,target:this}),this}reverse(){return this.value.reverse(),this.reactor.emit({type:"SET",value:null,target:this}),this}get length(){return this.value.length}forEach(t){this.value.forEach(t)}}class kt extends pt{#t=!1;constructor(t,e){super(t,e)}set(t,e){if(this.#t)throw new Error("Object is locked");if("string"==typeof t){const n=t,r=e;return this.value[n]=r,this.reactor.emit({type:"SET_BY_KEY",value:r,target:this,key:n}),this}if("object"!=typeof t)throw new Error("Invalid arguments passed to set()");super.set(t)}remove(t){if(this.#t)throw new Error("Object is locked");return t in this.value&&(delete this.value[t],this.reactor.emit({type:"REMOVE_BY_KEY",value:{...this.value},target:this,key:t})),this}merge(t){if(this.#t)throw new Error("Object is locked");return Object.assign(this.value,t),this.reactor.emit({type:"SET",value:{...this.value},target:this}),this}assign(t){if(this.#t)throw new Error("Object is locked");return this.value={...this.value,...t},this.reactor.emit({type:"SET",value:{...this.value},target:this}),this}clear(){if(this.#t)throw new Error("Object is locked");for(const t in this.value)delete this.value[t];return this.reactor.emit({type:"SET",value:{},target:this}),this}get(t){return"string"==typeof t?this.value[t]:this.value}keys(){return Object.keys(this.value)}values(){return Object.values(this.value)}entries(){return Object.entries(this.value)}has(t){return t in this.value}get size(){return Object.keys(this.value).length}forEach(t){Object.entries(this.value).forEach((([e,n])=>{t(n,e,this.value)}))}map(t){const e={};return Object.entries(this.value).forEach((([n,r])=>{e[n]=t(r,n,this.value)})),e}clone(){return JSON.parse(JSON.stringify(this.value))}toJSON(){return JSON.parse(JSON.stringify(this.value))}toObject(){return this.get()}lock(){return this.#t=!0,this}unlock(){return this.#t=!1,this}get isLocked(){return this.#t}freeze(){return Object.freeze(this.value),this}unfreeze(){return this.value=JSON.parse(JSON.stringify(this.value)),this}get isFrozen(){return Object.isFrozen(this.value)}}var jt=Object.freeze({__proto__:null,RumiousArrayState:Ct,RumiousObjectState:kt,RumiousState:pt,createArrayState:function(t){return new Ct(t)},createObjectState:function(t){return new kt(t)},createState:function(t){return new pt(t)},unwatch:dt,watch:ft});window.RUMIOUS_CONTEXTS={};class Tt{constructor(t={}){this.events={},this.values=t}has(t){return t in this.values}set(t,e){this.values[t]=e}get(t){return this.values[t]}on(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter((t=>t!==e)))}emit(t,e){this.events[t]&&this.events[t].forEach((t=>t(e)))}}const Rt={...r,...s,...St,...Ot,...Mt,...jt,...Object.freeze({__proto__:null,RumiousContext:Tt,createContext:function(t,e=function(t="_"){return`${t}${(Math.floor(9999*Math.random())*Date.now()).toString(32)}`}("rctx_")){if(window.RUMIOUS_CONTEXTS[e])return window.RUMIOUS_CONTEXTS[e];{let n=new Tt(t);return window.RUMIOUS_CONTEXTS[e]=n,n}}}),...Object.freeze({__proto__:null,denounce:function(t,e){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>t.apply(this,r)),e)}},leadingTrailingDebounce:function(t,e){let n,r=!0;return function(...i){r&&(t.apply(this,i),r=!1),clearTimeout(n),n=setTimeout((()=>{t.apply(this,i),r=!0}),e)}},rafThrottle:function(t){let e=!1;return function(...n){e||(e=!0,requestAnimationFrame((()=>{t.apply(this,n),e=!1})))}},tholle:function(t,e){let n=0;return function(...r){const i=Date.now();i-n>=e&&(n=i,t.apply(this,r))}},trailingThrottle:function(t,e){let n=0,r=null,i=null;function s(){n=Date.now(),t.apply(this,r),r=null}return function(...t){const o=Date.now();r=t,o-n>=e?s.call(this):i||(i=setTimeout((()=>{i=null,s.call(this)}),e-(o-n)))}}})};window.Rumious=Rt}();
@@ -1,5 +0,0 @@
1
- export declare function tholle<T extends (...args: any[]) => any>(func: T, limit: number): T;
2
- export declare function denounce<T extends (...args: any[]) => any>(func: T, delay: number): T;
3
- export declare function trailingThrottle<T extends (...args: any[]) => any>(func: T, limit: number): T;
4
- export declare function leadingTrailingDebounce<T extends (...args: any[]) => any>(func: T, delay: number): T;
5
- export declare function rafThrottle<T extends (...args: any[]) => any>(func: T): T;
@@ -1,23 +0,0 @@
1
- export declare class RumiousChildrenRef {
2
- target: HTMLElement;
3
- constructor(target: HTMLElement);
4
- list(): HTMLElement[];
5
- getChild(index: number): HTMLElement | undefined;
6
- remove(index: number): void;
7
- add(child: HTMLElement): void;
8
- querySelector(query: string): HTMLElement | null;
9
- querySelectorAll(query: string): NodeListOf<HTMLElement>;
10
- clear(): void;
11
- replaceChild(index: number, newChild: HTMLElement): void;
12
- insertBefore(newChild: HTMLElement, index: number): void;
13
- prepend(child: HTMLElement): void;
14
- getFirstChild(): HTMLElement | undefined;
15
- getLastChild(): HTMLElement | undefined;
16
- hasChildren(): boolean;
17
- count(): number;
18
- find(predicate: (child: HTMLElement, index: number) => boolean): HTMLElement | undefined;
19
- forEach(callback: (child: HTMLElement, index: number) => void): void;
20
- removeAllMatching(query: string): void;
21
- toggleClass(className: string): void;
22
- setAttribute(key: string, value: string): void;
23
- }
@@ -1,49 +0,0 @@
1
- export declare class RumiousElementRef {
2
- target: HTMLElement;
3
- constructor(target: HTMLElement);
4
- getElement(): HTMLElement;
5
- remove(): void;
6
- addChild(child: Node): void;
7
- listChild(): NodeList;
8
- querySelector(query: string): Node | null;
9
- querySelectorAll(query: string): NodeList;
10
- set text(t: string);
11
- get text(): string | null;
12
- set value(v: string);
13
- get value(): string | undefined;
14
- addClassName(className: string): void;
15
- removeClassName(className: string): void;
16
- hasClassName(className: string): boolean;
17
- toggleClass(className: string, force?: boolean): boolean;
18
- setStyle(styles: Partial<CSSStyleDeclaration>): void;
19
- getStyle(property: string): string;
20
- setAttribute(key: string, value: string): void;
21
- getAttribute(key: string): string | null;
22
- removeAttribute(key: string): void;
23
- on(event: string, callback: EventListener, options?: AddEventListenerOptions): void;
24
- off(event: string, callback: EventListener, options?: EventListenerOptions): void;
25
- set html(t: string);
26
- get html(): string | null;
27
- getBoundingRect(): DOMRect;
28
- isInViewport(): boolean;
29
- prependChild(child: Node): void;
30
- setDisabled(disabled: boolean): void;
31
- addClasses(...classNames: string[]): void;
32
- removeClasses(...classNames: string[]): void;
33
- replaceClass(oldClass: string, newClass: string): void;
34
- moveTo(newParent: HTMLElement): void;
35
- getParent(): HTMLElement | null;
36
- getNextSibling(): HTMLElement | null;
37
- getPreviousSibling(): HTMLElement | null;
38
- hide(): void;
39
- show(): void;
40
- isHidden(): boolean;
41
- scrollIntoView(options?: ScrollIntoViewOptions): void;
42
- matches(selector: string): boolean;
43
- getChildren(): HTMLElement[];
44
- insertAfter(newNode: Node): void;
45
- insertBefore(newNode: Node): void;
46
- clearChildren(): void;
47
- animate(keyframes: Keyframe[], options: KeyframeAnimationOptions | number): Animation;
48
- }
49
- export declare function createElementRef(): RumiousElementRef;
@@ -1,21 +0,0 @@
1
- import { RumiousRenderTemplate } from './template.js';
2
- import { RumiousArrayState } from '../state/array.js';
3
- import { RumiousRenderContext } from './context.js';
4
- import { RumiousStateCommit } from '../state/reactor.js';
5
- type RumiousListRenderFn = (item: any, index: any) => RumiousRenderTemplate;
6
- export declare class RumiousListRenderer<T> {
7
- state: RumiousArrayState<T>;
8
- callback: RumiousListRenderFn;
9
- anchorElement: HTMLElement;
10
- context: RumiousRenderContext;
11
- constructor(state: RumiousArrayState<T>, callback: RumiousListRenderFn);
12
- prepare(anchor: HTMLElement, context: RumiousRenderContext): void;
13
- render(): Promise<void>;
14
- renderAll(): void;
15
- updateElement(index: number, value: any): void;
16
- insertOrAppendElement(value: any, index: number): void;
17
- removeElement(index: number): void;
18
- onStateChange(commit: RumiousStateCommit<typeof this.state.value>): Promise<void>;
19
- }
20
- export declare function renderList<T>(state: RumiousArrayState<T>, callback: RumiousListRenderFn): RumiousListRenderer<T>;
21
- export {};
@@ -1 +0,0 @@
1
- export declare const directives: Record<string, Function>;
@@ -1,2 +0,0 @@
1
- import { RumiousRenderContext } from './context.js';
2
- export declare function dynamicValue(target: HTMLElement, textNode: Text, value: any, context: RumiousRenderContext): Promise<void>;
@@ -1,15 +0,0 @@
1
- type RumiousDymanicInjectorContentTypes = HTMLElement | string;
2
- export declare class RumiousDymanicInjector<T extends RumiousDymanicInjectorContentTypes> {
3
- contents?: T[] | undefined;
4
- private targets;
5
- private type;
6
- constructor(contents?: T[] | undefined);
7
- commit(contents: T[]): void;
8
- addTarget(element: HTMLElement): void;
9
- inject(element: HTMLElement): void;
10
- injectAll(): void;
11
- removeTarget(element: HTMLElement): void;
12
- clear(): void;
13
- }
14
- export declare function createHTMLInjector(html: string): RumiousDymanicInjector<string>;
15
- export {};
@@ -1,85 +0,0 @@
1
- import { RumiousRenderTemplate } from './template.js';
2
- import { RumiousArrayState } from '../state/array.js';
3
- import { RumiousRenderContext } from './context.js';
4
- import { RumiousStateCommit } from '../state/reactor.js';
5
- import { RumiousState } from '../state/state.js';
6
- type RumiousListRenderFn = (item: any, index: any) => RumiousRenderTemplate;
7
- export declare class RumiousListRenderer<T> {
8
- state: RumiousArrayState<T>;
9
- callback: RumiousListRenderFn;
10
- anchorElement: HTMLElement;
11
- context: RumiousRenderContext;
12
- constructor(state: RumiousArrayState<T>, callback: RumiousListRenderFn);
13
- prepare(anchor: HTMLElement, context: RumiousRenderContext): void;
14
- protected renderItem(value: T, index: number): DocumentFragment;
15
- protected scheduleRenderAll(): void;
16
- render(): Promise<void>;
17
- renderAll(): void;
18
- updateElement(index: number, value: any): void;
19
- insertOrAppendElement(value: any, index: number): void;
20
- removeElement(index: number): void;
21
- appendElement(values: any, startIndex: number): void;
22
- onStateChange(commit: RumiousStateCommit<typeof this.state.value>): Promise<void>;
23
- }
24
- export declare function renderList<T>(state: RumiousArrayState<T>, callback: RumiousListRenderFn): RumiousListRenderer<T>;
25
- export interface RumiousInfinityScrollRenderOptions<T> {
26
- data: RumiousArrayState<T>;
27
- template: RumiousListRenderFn;
28
- loader?: (limit: number, offset: number) => T[] | Promise<T[]>;
29
- scrollElement: HTMLElement | Window;
30
- state?: RumiousState<string>;
31
- controller?: RumiousState<string>;
32
- limit?: number;
33
- offset?: number;
34
- threshold: number;
35
- }
36
- export declare class RumiousInfinityScrollRenderer<T> extends RumiousListRenderer<T> {
37
- options: RumiousInfinityScrollRenderOptions<T>;
38
- private limit;
39
- private offset;
40
- private isLoading;
41
- private onScroll;
42
- private onControl;
43
- private onChange;
44
- constructor(options: RumiousInfinityScrollRenderOptions<T>);
45
- private setState;
46
- private fetchData;
47
- private getScrollInfo;
48
- private addData;
49
- private handleScroll;
50
- private handleControl;
51
- private handleStateChange;
52
- render(): Promise<void>;
53
- }
54
- export declare function createInfinityScroll<T>(options: RumiousInfinityScrollRenderOptions<T>): RumiousInfinityScrollRenderer<T>;
55
- export interface RumiousPagenationOptions<T> {
56
- data: RumiousArrayState<T>;
57
- template: RumiousListRenderFn;
58
- info?: RumiousState<object>;
59
- pages?: RumiousArrayState<{
60
- isRender: boolean;
61
- index: number;
62
- }>;
63
- controller: RumiousState<string>;
64
- size: number;
65
- page?: number;
66
- }
67
- export declare class RumiousPagenationRenderer<T> extends RumiousListRenderer<T> {
68
- options: RumiousPagenationOptions<T>;
69
- private size;
70
- private currentPage;
71
- constructor(options: RumiousPagenationOptions<T>);
72
- private getPageData;
73
- private renderPage;
74
- goToPage(page: number): void;
75
- nextPage(): void;
76
- prevPage(): void;
77
- onControl({ value }: {
78
- value: unknown;
79
- }): void;
80
- calculate(): Promise<void>;
81
- render(): Promise<void>;
82
- onStateChange(commit: RumiousStateCommit<typeof this.state.value>): Promise<void>;
83
- }
84
- export declare function createPagination<T>(options: RumiousPagenationOptions<T>): RumiousPagenationRenderer<T>;
85
- export {};
@@ -1,5 +0,0 @@
1
- import { RumiousTemplateGenerator } from '../types/render.js';
2
- export declare class RumiousRenderTemplate {
3
- generator: RumiousTemplateGenerator;
4
- constructor(generator: RumiousTemplateGenerator);
5
- }
@@ -1,22 +0,0 @@
1
- import { RumiousState } from './state.js';
2
- import { RumiousReactor } from './reactor.js';
3
- export declare class RumiousArrayState<T> extends RumiousState<T[]> {
4
- constructor(value: T[], reactor?: RumiousReactor<T[]>);
5
- set(value: T[]): void;
6
- set(index: number, value: T): void;
7
- get(index: number): T;
8
- get(): T[];
9
- insert(index: number, newItem: T): this;
10
- remove(index: number): this;
11
- append(...values: T[]): this;
12
- prepend(value: T): this;
13
- clear(): this;
14
- replace(index: number, newItem: T): this;
15
- filter(callback: (item: T, index: number, array: T[]) => boolean): this;
16
- map(callback: (item: T, index: number, array: T[]) => T): this;
17
- sort(compareFn?: (a: T, b: T) => number): this;
18
- reverse(): this;
19
- get length(): number;
20
- forEach(callback: (value: T, index: number) => void): void;
21
- }
22
- export declare function createArrayState<T>(value: T[]): RumiousArrayState<T>;
@@ -1,31 +0,0 @@
1
- import { RumiousState } from './state.js';
2
- import { RumiousReactor } from './reactor.js';
3
- export declare class RumiousObjectState<T extends Record<string, any>> extends RumiousState<T> {
4
- #private;
5
- constructor(value: T, reactor?: RumiousReactor<T>);
6
- set<K extends string>(key: K, newValue: any): this;
7
- set(newObject: T): void;
8
- remove<K extends string>(key: K): this;
9
- merge(partial: Partial<T>): this;
10
- assign(obj: Partial<T>): this;
11
- clear(): this;
12
- get<K extends string>(key: K): any;
13
- get(): T;
14
- keys(): string[];
15
- values(): any[];
16
- entries(): [string, any][];
17
- has(key: string): boolean;
18
- get size(): number;
19
- forEach(callback: (value: any, key: string, obj: T) => void): void;
20
- map(callback: (value: any, key: string, obj: T) => any): Record<string, any>;
21
- clone(): T;
22
- toJSON(): Record<string, any>;
23
- toObject(): T;
24
- lock(): this;
25
- unlock(): this;
26
- get isLocked(): boolean;
27
- freeze(): this;
28
- unfreeze(): this;
29
- get isFrozen(): boolean;
30
- }
31
- export declare function createObjectState<T extends Record<string, any>>(value: T): RumiousObjectState<T>;
@@ -1,5 +0,0 @@
1
- import type { RumiousApp } from '../app/index.js';
2
- import type { RumiousComponent } from '../component/component.js';
3
- export type RumiousRenderMode = 'idle' | 'async' | 'linear' | 'animate';
4
- export type RumiousRenderable = RumiousComponent | RumiousApp;
5
- export type RumiousTemplateGenerator = (root: HTMLElement | HTMLDocument | DocumentFragment, context: Record<any, any>) => HTMLElement | DocumentFragment | HTMLDocument | Node;
@@ -1 +0,0 @@
1
- export type Constructor<T> = new (...args: any[]) => T;
@@ -1,5 +0,0 @@
1
- export interface RumiousWarpController {
2
- id: string;
3
- remove: () => any;
4
- target: HTMLElement;
5
- }
@@ -1 +0,0 @@
1
- export declare function isPrimitive(value: any): boolean;
@@ -1,2 +0,0 @@
1
- export declare function extractName(str: string): string;
2
- export declare function generateName(prefix?: string): string;
@@ -1 +0,0 @@
1
- export declare function observeUnmount(targetNode: Node, onRemoved: () => void): () => void;