Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jquire

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquire - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

2

docs/components/AlertBox.js

@@ -1,2 +0,2 @@

import { natives, nodes, css, paths } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives, nodes, css, paths } from "https://cdn.jsdelivr.net/npm/jquire@1.5.0/src/jquire.min.js"

@@ -3,0 +3,0 @@ const { div, img, h4, p } = natives

@@ -1,2 +0,2 @@

import { natives, nodes, css, state, watch } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives, nodes, css, state, watch } from "https://cdn.jsdelivr.net/npm/jquire@1.5.0/src/jquire.min.js"
const { pre, code } = natives

@@ -3,0 +3,0 @@ const { attr } = nodes

@@ -1,2 +0,2 @@

import { natives } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives, css } from "https://cdn.jsdelivr.net/npm/jquire@1.5.0/src/jquire.min.js"

@@ -3,0 +3,0 @@ const { em } = natives

@@ -1,2 +0,2 @@

import { natives } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives, css } from "https://cdn.jsdelivr.net/npm/jquire@1.5.0/src/jquire.min.js"

@@ -3,0 +3,0 @@ const { a } = natives

import {
natives, nodes, on, state, each, watch, paths, css, when
} from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
} from "https://cdn.jsdelivr.net/npm/jquire@1.5.0/src/jquire.min.js"

@@ -835,8 +835,3 @@ import highlight from "https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@latest/build/es/highlight.min.js"

p(
`All styles on block elements are scoped by default using the `,
Link(
"Shadow DOM.",
attr.href("https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM")
),
` You can even specify css rules in them.`
`All styles on block elements are scoped by default using unique class names. You can even specify css rules in them.`
),

@@ -843,0 +838,0 @@ CSSProperties(),

{
"name": "jquire",
"version": "1.5.0",
"version": "1.5.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/jquire.js",

@@ -98,3 +98,3 @@ <p align="center"><img src="./docs/assets/logo.png" alt="jQuire Logo" width="200"/></p>

All styles on block elements are scoped by default using ShadowRoot. You can even specify css rules in them.
All styles on block elements are scoped by default using unique class names. You can even specify css rules in them.

@@ -101,0 +101,0 @@ ### CSS Properties

@@ -1,2 +0,2 @@

const t=Symbol("created"),e=Symbol("updated"),n=Symbol("deleted"),o=Symbol("unchanged"),r=Symbol("OnAttachCallback"),i=Symbol("OnDetachCallback"),s=Symbol("StateReference"),a=Symbol("PromisePending"),c=Symbol("PromiseResolved"),l=Symbol("PromiseRejected"),d=Object.create(null),h=t=>t!==Object(t),u=(...t)=>t.every((t=>t instanceof JqElement)),f=(...t)=>t.every((t=>t instanceof JqAttribute)),m=(...t)=>t.every((t=>t instanceof JqFragment)),q=(...t)=>t.every((t=>t instanceof JqText));function p(...t){return t.every((t=>null==t))}const J=()=>[JqElement,JqAttribute,JqCSSProperty,JqCSSRule,JqAnimation,JqEvent,JqWatch,JqFragment,JqText,JqEach,JqEvent,JqCondition,JqLifecycle,JqList,JqPromise],b=(t,e=Error)=>{throw new e(t)},S=Symbol("JqNodeReference");function y(t){const e=[],n=[],o=[],r=[],i=[],s=[],a=[],c=[],l=[],d=[],u=[];let f=0;for(const e of t)m(e,f),f++;return{childNodes:e,attributes:n,events:o,animations:r,inlineStyles:d,blockStyles:u,watchers:i,conditions:s,iterators:a,lifecycles:c,promiseStates:l};function m(t,f){if(t instanceof JqElement)t.nodePosition=f,e.push(t);else if(t instanceof JqFragment)t.nodePosition=f,e.push(t);else if(t instanceof JqText)t.nodePosition=f,e.push(t);else if(t instanceof JqAttribute)t.nodePosition=f,n.push(t);else if(t instanceof JqList&&t.nodeClass===JqAttribute)for(const e of t)e.nodePosition=f,n.push(e);else if(t instanceof JqEvent)t.nodePosition=f,o.push(t);else if(t instanceof JqWatch)t.nodePosition=f,i.push(t);else if(t instanceof JqCondition)t.nodePosition=f,s.push(t);else if(t instanceof JqEach)t.nodePosition=f,a.push(t);else if(t instanceof JqLifecycle)t.nodePosition=f,c.push(t);else if(t instanceof JqPromiseState)t.nodePosition=f,l.push(t);else if(t instanceof JqAnimation)t.nodePosition=f,r.push(t);else if(t instanceof JqCSSProperty)t.nodePosition=f,d.push(t);else if(t instanceof JqCSSRule)t.nodePosition=f,u.push(t);else if(Array.isArray(t)){const n=g(t,null);n.nodePosition=f,e.push(n)}else{if("function"==typeof t){return m(E(t),f)}if(h(t)){const n=g(t,null);n.nodePosition=f,e.push(n)}}}}function E(t){try{t()}catch(e){if((()=>e instanceof JqWatch||e instanceof JqEvent||e instanceof JqCondition||e instanceof JqEach||e instanceof JqLifecycle)())return e.callback=t,e;throw e}throw new TypeError('JqError - Expected a JqCallback<"watch" | "event" | "condition" | "each" | "mount" | "unmount"> but instead found a \'function\'')}function g(t,e){return Array.isArray(t)?(t=>{const n=y(t),o=n.childNodes;for(let t=0;t<o.length;t++){o[t].nodePosition=t}const r=new JqFragment(o);return r.jqParent=e,r.conditions=n.conditions,r.iterators=n.iterators,r.lifecycles=n.lifecycles,r.promisesStates=n.promiseStates,r.watchers=n.watchers,r})(t):h(t)?(t=>{const n=new JqText(t??"");return n.jqParent=e,n})(t):"function"==typeof t?(t=>{const n=E(t);return n.jqParent=e,n})(t):J().some((e=>t instanceof e))?t:b("JqError - Unexpected value found in place of a JqNode")}const P=(t,e)=>{let n=t;for(let t=0;t<e.length;t++)if(n=n?.[e[t]],p(n))return n;return n};class JqPromiseState{nodePosition=-1;jqParent=null;state;jqPromise;constructor(t,e){this.state=t,this.jqPromise=e}}class JqPromise{state=a;callback;subscriptions={pending:[],resolved:[],rejected:[]};promise=null;constructor(t){this.callback=t}invoke(){const t=this.promise=this.callback();return this.subscriptions.pending.forEach((e=>e.callback(t))),t.then((t=>this.subscriptions.resolved.forEach((e=>(this.state=c,e.callback(t)))))).catch((t=>this.subscriptions.rejected.forEach((e=>(this.state=l,e.callback(t)))))),t}subscribe(t){const{subscriber:e,callback:n,type:o}=t;this.subscriptions[o].push({subscriber:e,callback:n})}get pending(){throw new JqPromiseState(a,this)}get then(){throw new JqPromiseState(c,this)}get catch(){throw new JqPromiseState(l,this)}}class JqLifecycle{nodePosition=-1;jqParent=null;type;callback;constructor(t){this.type=t}delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent,n=e.lifecycles.findIndex((e=>Object.is(e,t)));return-1==n&&b("JqInternalError - JqLifecycle not found in its jqParent.lifecycles"),e.lifecycles.splice(n,1),this}}}class JqEach{nodePosition=-1;jqParent=null;iterable;callback=t=>"";returned=null;constructor(t){this.iterable=t}invoke(){let t=0;const e=[];for(const n of this.iterable){const o=this.callback([n,t,this.iterable]);e.push(o),t++}const n=g(e,this.jqParent);return n.nodePosition=this.nodePosition,n}delete={context:this,deleteSelf(){const t=this.context;return v.delete.deleteSelf(t),t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqEach not found in its jqParent.iterators"};static getInstancesFromParent(t){return t.iterators}}class JqCondition{nodePosition=-1;jqParent=null;condition=!1;callback=t=>"";returned=null;constructor(t){this.condition=t}invoke(){const t=E(this.callback);this.condition=t.condition;return this.condition?t.callback(this.condition):new JqText}delete={context:this,deleteSelf(){const t=this.context;return v.delete.deleteSelf(t),t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqCondition not found in its jqParent.conditions"};static getInstancesFromParent(t){return t.conditions}}class JqEvent{nodePosition=-1;event;callback;jqParent=null;constructor(t,e=(t=>"")){this.event=t,this.callback=e}attachHandler(t){t.addEventListener(this.event,this.callback)}detachHandler(t){t.removeEventListener(this.event,this.callback)}attachTo(t){if(t instanceof HTMLElement)this.attachHandler(t);else{if(!(t instanceof JqElement))throw new Error(JqEvent.errors.invalidAttachTo(this));this.jqParent=t,t.events.includes(this)||t.events.push(this),this.attachHandler(t.domNode)}return this}delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent;v.delete.deleteSelf(t);const n=e.domNode;return n&&t.detachHandler(n),this}};static errors={invalidAttachTo:t=>`JqError - Cannot attach JqEvent '${t.event}' to a node not of instance JqElement or JqFragment or HTMLElement`,invalidParent:t=>"JqInternalError - JqEvent not found in its jqParent.events"};static getInstancesFromParent(t){return t instanceof JqFragment?[]:t.events}}class JqWatch{nodePosition=-1;jqParent=null;jqStates=[];callback=t=>"";returned=null;constructor(...t){this.jqStates=t}invoke(){return this.callback(this.jqStates.map((t=>t[s])))}reconcile(){const t=this.returned,n=v.extractEffectReturn(this,this.jqParent);n.attachTo(null,!1);const o=x(t,n);return JqWatch.reconcile(o),o[e].length&&(this.returned=n),this}delete={context:this,deleteSelf(){const t=this.context;v.delete.deleteSelf(t);for(const e of t.jqStates){e[S].delete.removeWatcher(t)}return t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqWatch not found in its jqParent.watchers"};static getInstancesFromParent(t){return t.watchers}static reconcile(o){const r=o.node1,i=o.node2,s=o[e],a=o[t],c=o[n];for(const[t,...e]of s)q(r,i)?"text"==t&&JqWatch.updateText(o,[t,...e]):f(r,i)?"value"==t&&JqWatch.updateAttribute(o,[t,...e]):p(r)||p(i)||JqWatch.updateElement(o,[t,...e]);for(const[t,...e]of a)q(r,i)||f(r,i)||(m(r,i)?"childNodes"==t&&JqWatch.createFragment(o,[t,...e]):u(r,i)&&"childNodes"==t&&JqWatch.createElement(o,[t,...e]));for(const[t,...e]of c)m(r,i)?JqWatch.deleteFragmentChild(o,[t,...e]):u(r,i)?JqWatch.deleteElementChild(o,[t,...e]):r.delete.deleteSelf();for(const t of o.childDiffs)JqWatch.reconcile(t)}static updateAttribute(t,e){if(![t.node1,t.node2].every((t=>t instanceof JqAttribute)))return this;const n=t.node1,o=t.node2;return n.update.setAttribute(o.value)}static updateText(t,e){if(![t.node1,t.node2].every((t=>t instanceof JqText)))return this;const n=t.node1,o=t.node2;n.update.setText(o.text)}static updateElement(t,e){const n=t.node1,o=t.node2;n.jqParent.update.replaceChild(n,o)}static createElement(t,[e,n]){if(![t.node1,t.node2].every((t=>t instanceof JqElement)))return this;const o=t.node1;t.node2;const r=n;return r.jqParent=o.jqParent,r.nodePosition=o.childNodes.length,o.childNodes.splice(o.childNodes.length,0,r),r.attachTo(o),this}static createFragment(t,[e,n]){if(![t.node1,t.node2].every((t=>t instanceof JqFragment)))return this;const o=t.node1;t.node2;const r=n;return r.jqParent=o.jqParent,r.nodePosition=o.childNodes.length,r.attachTo(o),this}static deleteFragmentChild(t,[e,n]){t.node1,t.node2;n.delete.deleteSelf()}static deleteElementChild(t,[e,n]){t.node1,t.node2;n.delete.deleteSelf()}}class JqState{[S];[s];watchers=[];constructor(t){this[s]=t,this[S]=this}delete={context:this,removeWatcher(t){const e=this.context,n=e.watchers.findIndex((e=>Object.is(e,t)));return-1==n&&b("JqInternalError - JqWatcher not found in one of its jqState.watchers"),e.watchers.splice(n,1),this}}}class JqAnimation{domAnimation=null;nodePosition=-1;parameters;jqParent=null;constructor(...t){this.parameters=t}attachTo(t){if(t instanceof HTMLElement)this.animate(t);else{if(!(t instanceof JqElement))throw new Error("JqError - Cannot attach JqAnimation to a node not of instance JqElement or JqFragment or HTMLElement");this.jqParent=t,this.animate(t.domNode)}return this}animate(t){const[e,n,...o]=this.parameters;let r=null,i=h(n)?null:n;const[s,a,c]=[n,...o];c&&(r=c);const l={duration:s??400,easing:a??"linear",fill:"forwards"};i??=l;const d=Array.isArray(e)?e.map((t=>t instanceof Map?Object.fromEntries(t):t)):e instanceof Map?Object.fromEntries(e):e,u=Array.isArray(d)?d.map((e=>JqAnimation.setInitialStyles(t,e))):JqAnimation.setInitialStyles(t,d);return this.domAnimation=t.animate(u,i),r&&this.domAnimation.addEventListener("finish",r),this.domAnimation}static setInitialStyles(t,e,...n){const o=Object.keys(e).filter((t=>!Array.isArray(e[t]))).map((n=>{const o=e[n];return[n,[getComputedStyle(t).getPropertyValue(n),o]]}));return{...e,...Object.fromEntries(o)}}}class JqCSSProperty{name;value;nodePosition=-1;jqParent=null;constructor(t,e){this.name=j(t).replace(/_/g,"-"),this.value=String(e)}attachTo(t){if(t instanceof HTMLElement)t.style.setProperty(this.name,this.value);else{if(!(t instanceof JqElement))throw new Error(JqCSSProperty.errors.invalidAttachTo(this));this.jqParent=t}return this}toString(t=1){return`${this.name}: ${this.value};`}static errors={invalidAttachTo:t=>"JqError - Cannot attach JqCSSProperty to a node not of instance JqElement or JqFragment or HTMLElement"};static getStyleFragment(t){const e=new JqText(t.name),n=new JqText(t.value),o=y([e,new JqText(": "),n,new JqText(";")]).childNodes;return new JqFragment(o)}}class JqCSSRule{nodePosition=-1;head;body=[];jqParent=null;constructor([t,...e],...n){this.head=[t,...e];const o=JqCSSRule.errors.invalidHeadArgument(this);this.body=n.flatMap((t=>t instanceof JqCSSProperty||t instanceof JqCSSRule?t:function(t,e){n=e,(null===n||"object"!=typeof n)&&b(t);var n;const o=Object.entries(e).map((([t,e])=>new JqCSSProperty(t,e)));return new JqList(JqCSSProperty,o)}(o,t).nodes))}attachTo(t){if(t instanceof HTMLElement){const e=document.createElement("style");e.textContent=this.toString(),t.appendChild(e)}else{if(!(t instanceof JqElement))throw new Error(JqCSSRule.errors.invalidAttachTo(this));this.jqParent=t}return this}toString(t=1){const e="\t".repeat(t);return`${this.head.join(" ").trim()} {\n${e}${this.body.map((e=>e.toString(t+1))).join("\n"+e)}\n${"\t".repeat(t-1)}}`}static errors={invalidAttachTo:t=>"JqError - Cannot attach JqCSSRule to a node not of instance JqElement or JqFragment or HTMLElement",invalidHeadArgument:t=>`JqError - Invalid argument passed to ${t.head.join(" ").trim()}(...)`};static getStyleFragment(t){const e=new JqFragment(y(t.head).childNodes),n=t.body.map((t=>w.getStyleClass(t).getStyleFragment(t))),o=y([e,new JqText(" {\n"),...n,new JqText("\n}")]).childNodes;return new JqFragment(o)}}class JqList{nodes=[];nodeClass;constructor(t,e){this.nodeClass=t,this.nodes=e}push(t){if(!(t instanceof this.nodeClass))throw new TypeError(`JqError - Cannot push node not of instance '${this.nodeClass.name}' into JqList<${this.nodeClass.name}>`);this.nodes.push(t)}pop(){return this.nodes.pop()}[Symbol.iterator]=()=>this.nodes[Symbol.iterator]()}class JqAttribute{_name="";_value="";nodePosition=-1;attrNode=null;jqParent=null;constructor(t,e){this.name=j(t).replace(/_/g,"-"),this.value=e}get name(){return this._name}set name(t){this._name=t}get value(){return this._value}set value(t){this._value=t}attachTo(t){if(this.initial.createNode(),t instanceof HTMLElement)t.setAttributeNode(this.attrNode);else{if(!(t instanceof JqElement))throw new TypeError(`JqError - Cannot attach JqAttribute '${this.name}' to a node not of instance JqElement or JqFragment or HTMLElement`);this.jqParent=t,t.domNode.setAttributeNode(this.attrNode)}return this}initial={context:this,createNode(){const t=this.context;return t.attrNode=document.createAttribute(t.name),t.attrNode.value=t.value,this}};update={context:this,updateAttribute(){const t=this.context;return t.attrNode.value=t.value,this},setAttribute(t){const e=this.context;return t===e.value||(e.value=t,e.attrNode.value=t),this}};delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent;return e?(e.delete.removeAttribute(t),t.attrNode=null,this):this}};static objectToJqAttributes(t){if(null===t||"object"!=typeof t)throw new TypeError("JqError - Invalid argument passed to attr(...)");const e=Object.entries(t).map((([t,e])=>{const n=j(t).replace(/_/g,"-"),o=String(e);return new JqAttribute(n,o)}));return new JqList(JqAttribute,e)}}class JqText{nodePosition=-1;jqParent=null;domNode=null;text="";constructor(...t){this.text=t.map((t=>String(t??""))).join("")}attachTo(t,e=!0){if(null===t)return this.toString();if(this.initial.createNode(),t instanceof HTMLElement)return e&&t.appendChild(this.domNode),this.toString();if(t instanceof JqElement)this.jqParent=t,t.childNodes.includes(this)||t.childNodes.splice(this.nodePosition,0,this),e&&(t.shadowRoot??t.domNode).appendChild(this.domNode);else{if(!(t instanceof JqFragment))throw new TypeError(JqText.errors.invalidAttachTo(this));this.jqParent=t,t.childNodes.includes(this)||t.childNodes.splice(this.nodePosition,0,this),e&&t.domNode.appendChild(this.domNode)}return this.toString()}toString(t=0){return this.text}initial={context:this,createNode(){const t=this.context;return t.domNode=document.createTextNode(t.text),this}};update={context:this,setText(t){const e=this.context;e.domNode.nodeValue=e.text=t}};delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent,n=e.childNodes.findIndex((e=>Object.is(e,t)));return e.childNodes.splice(n,1),t.domNode.remove(),this}};static errors={invalidAttachTo:t=>"JqError - Cannot attach JqText to a node not of instance JqElement or JqFragment or HTMLElement"}}class JqFragment{nodePosition=-1;jqParent=null;domNode=null;childNodes=[];watchers=[];conditions=[];iterators=[];lifecycles=[];promisesStates=[];scopedStyleSheet=null;constructor(t){this.childNodes=t}attachTo(t,e=!0){return N.attachTo(this,t,JqFragment.attachNode,e)}toString(t=0){return this.childNodes.map((e=>e.toString(t))).join("\n"+"\t".repeat(t))}initial={context:this,createNode(){return this.context.domNode=document.createDocumentFragment(),this},attachChildren(t=!0){const e=this.context;return N.initial.attachChildren(e,t),this}};update={context:this,replaceChild(t,e){const n=this.context;return N.update.replaceChild(n,t,e),this}};delete={context:this,deleteSelf(){const t=this.context;return N.delete.deleteSelf(t),this}};static errors={invalidAttachTo:t=>"JqError - Cannot attach JqFragment to a node not of instance JqElement or JqFragment or HTMLElement",childNodeNotFound:t=>"JqInternalError - childNode not found in JqFragment.childNodes",invalidParent:t=>"JqInternalError - JqFragment not found in its jqParent.childNodes"};static attachNode(t,e,n){return n?t.initial.createNode().attachChildren():t.initial.attachChildren(n)}static collectDetachableEffectNodes(t,e){}}class JqElement{name;nodePosition=-1;jqParent=null;shadowRoot=null;domNode=null;childNodes=[];attributes=[];events=[];animations=[];inlineStyles=[];blockStyles=[];watchers=[];conditions=[];iterators=[];lifecycles=[];promisesStates=[];scopedStyleSheet=null;id="jq"+((t=5)=>Math.random().toString(32).replace(/\d\./,"").slice(0,t))();constructor(t,e){this.name=t,Object.assign(this,e)}attachTo(t,e=!0){return N.attachTo(this,t,JqElement.attachNode,e)}toString(t=0){const e=e=>e>0?"\n"+"\t".repeat(t+1):"",n=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(this.name)?"/":"",o=this.childNodes.map((e=>e.toString(t+1))).join("\n"+"\t".repeat(t+1)),r=this.attributes.map((t=>`${t.name} = "${String(t.value??"")}"`)).join(" "),i=this.watchers.map((e=>e.returned?.toString(t+1)??"")).join("\n"+"\t".repeat(t)),s=`<${this.name}${r.length?" ":""}${r}${n}>`,a=`${e(o.length||i.length)+o+(i.length?e(o.length)+i:"")+(c=o.length||i.length,c>0?"\n"+"\t".repeat(t):"")}</${this.name}>`;var c;return`${s}${n?"":a}`}initial={context:this,createNode(){const t=this.context;return t.domNode=document.createElement(t.name),this},attachAttributes(){const t=this.context;for(const e of t.attributes)e.attachTo(t);return this},attachChildren(t=!0){const e=this.context;return N.initial.attachChildren(e,t),this},attachEventListeners(){const t=this.context;for(const e of t.events)e.attachTo(t);return this},attachAnimations(){const t=this.context;return 0==t.animations.length||(e=t.domNode,new IntersectionObserver((t=>(e,n)=>e.forEach((e=>t([e,n]))))((([e,n])=>{if(e.isIntersecting){for(const e of t.animations)e.attachTo(t);n.disconnect()}}))).observe(e)),this;var e},attachStyles(t){const e=this.context;return JqElement.attachStyles(e,t),this}};update={context:this,replaceChild(t,e){const n=this.context;return N.update.replaceChild(n,t,e),this}};delete={context:this,removeAttribute(t){const e=this.context,n=e.attributes.indexOf(t);return-1!=n&&e.attributes.splice(n,1),e.domNode.removeAttribute(t.name),this},deleteSelf(){const t=this.context;return N.delete.deleteSelf(t),t.domNode.remove(),this}};static custom=(t,e,n)=>new JqElement(e,{...n,domNode:t});static errors={invalidAttachTo:t=>`JqError - Cannot attach JqElement '${t.name}' to a node not of instance JqElement or JqFragment or HTMLElement`,childNodeNotFound:t=>"JqInternalError - childNode not found in JqElement.childNodes",invalidParent:t=>"JqInternalError - JqElement not found in its jqParent.childNodes",unstylableElement:t=>`JqError - The HTML '${t.name}' Element cannot be styled`};static attachNode(t,e,n){return n?t.initial.createNode().attachStyles(e).attachAttributes().attachChildren().attachEventListeners().attachAnimations():t.initial.attachChildren(n)}static attachStyles(t,e){const{formatSelectorAndGetStyleFragment:n,maybeAttachStyleElementToHTMLParent:o,attachStylesToStylesheet:r}=w,i=/style|script|template|link|meta|br|head|wbr|title|track/i.test(t.name);if(null==e)return;if(o(t,e,i),0==t.blockStyles.length&&0==t.inlineStyles.length)return;i&&b(JqElement.errors.unstylableElement(t));t.domNode.classList.add(t.id);const s=new JqCSSRule(["."+t.id],...t.inlineStyles),a=Array.from(t.blockStyles,(e=>n(e,t.id)));a.push(JqCSSRule.getStyleFragment(s)),r(t,a)}static collectDetachableEffectNodes(t,e){return e.push(...t.events),e.push(...t.lifecycles),e}}const N={attachTo(t,e,n,o=!0){if(null===e)n(t,e,o);else if(e instanceof HTMLElement)n(t,e,o),o&&e.appendChild(t.domNode);else if(e instanceof JqElement){t.jqParent=e,t.scopedStyleSheet=e.scopedStyleSheet,n(t,e,o),e.childNodes.includes(t)||e.childNodes.splice(t.nodePosition,0,t);const r=e.shadowRoot??e.domNode;o&&r.appendChild(t.domNode)}else{if(!(e instanceof JqFragment)){const e=(t instanceof JqElement?JqElement:JqFragment).errors;throw new Error(e.invalidAttachTo(t))}if(t.jqParent=e,t.scopedStyleSheet=e.scopedStyleSheet,n(t,e,o),e.childNodes.includes(t)||e.childNodes.splice(t.nodePosition,0,t),o){e.domNode.appendChild(t.domNode);let n=e.jqParent;for(;null!=n&&m(n);)n=n.jqParent;null!=n&&n.domNode.appendChild(t.domNode)}}if(o)for(let e=0;e<t.lifecycles.length;e++){const n=t.lifecycles[e];n.jqParent=t,n.type==r&&n.callback(t)}return t.toString()},initial:{attachChildren(t,e=!0){const n=v.getEffectNodes(t),o=t.childNodes,r=o.length;for(let i=0;i<r;i++){const r=o[i],s=v.getPrecedingEffectNodes(n,r);v.attachEffectNodes(s,t,e),r.attachTo(t,e)}v.attachEffectNodes(n,t,e)}},update:{replaceChild(t,e,n){if(-1==t.childNodes.findIndex((t=>Object.is(t,e)))){const e=(t instanceof JqElement?JqElement:JqFragment).errors;b(e.childNodeNotFound(t))}n.nodePosition=e.nodePosition,n.attachTo(t),e.delete.deleteSelf()}},delete:{deleteSelf(t){const{errors:e,collectDetachableEffectNodes:n}=N.getParentableClass(t),o=t.jqParent,r=o.childNodes.findIndex((e=>Object.is(e,t)));-1==r&&b(e.invalidParent(t));for(let e=0;e<t.lifecycles.length;e++){const n=t.lifecycles[e];n.type==i&&n.callback(t)}for(o.childNodes.splice(r,1);t.childNodes.length;){t.childNodes[0].delete.deleteSelf()}const s=v.getEffectNodes(t);n(t,s);for(const t of s)t.delete.deleteSelf()}},getParentableClass(t){if(t instanceof JqElement)return JqElement;if(t instanceof JqFragment)return JqFragment;throw new Error("JqInternalError - Expected an instance of JqElement | JqFragment as the first argument")}},v={delete:{deleteSelf(t){const e=t.jqParent,{errors:n,getInstancesFromParent:o}=v.getEffectClass(t),r=o(e),i=r.findIndex((e=>Object.is(e,t)));-1==i&&b(n.invalidParent(t)),r.splice(i,1)}},getEffectClass(t){if(t instanceof JqEach)return JqEach;if(t instanceof JqCondition)return JqCondition;if(t instanceof JqEvent)return JqEvent;if(t instanceof JqWatch)return JqWatch;throw new Error("JqInternalError - Expected an instance of JqEffectNode as the first argument")},isInvokableEffectNode:t=>t instanceof JqEach||t instanceof JqCondition||t instanceof JqWatch,attachEffectNodes(t,e,n){for(const o of t){o.jqParent=e;const t=o.returned;if(o.jqParent.childNodes.includes(t))continue;const r=v.extractEffectReturn(o,e);if(o.returned=r,o instanceof JqWatch)for(const t of o.jqStates){const e=t[S],n=e.watchers.findIndex((t=>t.callback.toString()==o.callback.toString()));-1!=n?e.watchers.splice(n,1,o):e.watchers.push(o)}r.attachTo(e,n)}},getPrecedingEffectNodes(t,e){const n=[];for(let o=0;o<t.length;o++){const r=t[o],i=r.nodePosition;i>e.nodePosition||(t.splice(i,1),n.push(r))}return n},getEffectNodes(t){const e=[],n=Math.max(t.watchers.length,t.conditions.length,t.iterators.length);for(let o=0;o<n;o++){const n=[t.watchers[o],t.conditions[o],t.iterators[o]].filter(Boolean);e.push(...n)}return e},extractEffectReturn(t,e){let n=t.invoke();for(;v.isInvokableEffectNode(n)||"function"==typeof n;)n=g(n,e),n=n.invoke();const o=g(n,e);return o.nodePosition=t.nodePosition,o}},w={getStyleClass(t){if(t instanceof JqCSSProperty)return JqCSSProperty;if(t instanceof JqCSSRule)return JqCSSRule;throw new Error("JqInternalError - Expected an instance of JqStyleNode as the first argument")},attachStylesToStylesheet(t,e){const n=t.scopedStyleSheet;return e.forEach((t=>t.attachTo(n))),n},maybeAttachStyleElementToHTMLParent(t,e,n){if(!(e instanceof HTMLElement)||n)return;const o=new JqElement("style",{});o.attachTo(e),t.scopedStyleSheet=o},formatSelectorAndGetStyleFragment:(t,e)=>(t.head[0]=w.formatSelector(e,t.head[0]),JqCSSRule.getStyleFragment(t)),formatSelector(t,e){const n="."+t;return":JqCSSRule"==e?n:e.startsWith("@")?e:e.startsWith("::")?`${n}${e}`:`${n} :where(${e})`}};const j=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((t,e)=>(e?"-":"")+t.toLowerCase()));function x(r,i){const s=function(r,i){return u(r)&&u(i)?function(r,i){const s=r.childNodes,a=i.childNodes,c=r.attributes,l=i.attributes,d={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],r=a[e];void 0===o?d[t].push(["childNodes",r]):void 0===r?d[n].push(["childNodes",o]):d.childDiffs.push(x(o,r))}for(let e=0;e<Math.max(c.length,l.length);e++){const o=c[e],r=l[e];void 0===o?d[t].push(["attributes",r]):void 0===r?d[n].push(["attributes",o]):d.childDiffs.push(x(o,r))}return d}(r,i):m(r)&&m(i)?function(r,i){const s=r.childNodes,a=i.childNodes,c={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],r=a[e];void 0===o?c[t].push(["childNodes",r]):void 0===r?c[n].push(["childNodes",o]):c.childDiffs.push(x(o,r))}return c}(r,i):f(r)&&f(i)?function(t,e){const n=a({object:t,props:[["name"],["value"]]},{object:e,props:[["name"],["value"]]});return n}(r,i):q(r)&&q(i)?function(t,e){const n={object:t,props:[["text"]]},o={object:e,props:[["text"]]},r=a(n,o);return r}(r,i):function(r,i){const s={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},[a,c]=[p(r),p(i)];a&&s[t].push(["self"]);c&&s[n].push(["self"]);return a||c?s(r.jqParent):(s[e].push(["childNodes",i]),s)}(r,i)}(r,i);return s;function a(r,i){const s={type:Object.getPrototypeOf(r.object).constructor,node1:r.object,node2:i.object,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},a=r.props.filter((t=>p(P(i.object,t))));s[n]=a;const c=i.props.filter((t=>p(P(r.object,t))));s[t]=c;const l=r.props.filter((t=>P(i.object,t)!==P(r.object,t)));s[e]=l;const d=r.props.filter((t=>P(i.object,t)===P(r.object,t)));return s[o]=d,s}}const C=["a","address","article","aside","audio","b","base","bdo","br","button","canvas","caption","cite","code","col","colgroup","command","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figure","figcaption","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","portal","q","ruby","s","section","small","span","strike","tt","u","var","video","wbr","abbr","area","bdi","blockquote","body","iframe","menu","meta","picture","rb","rp","rt","rtc","samp","script","select","slot","source","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul"],T=Symbol("CustomElements"),A=new Proxy({},{get:(t,e)=>"symbol"==typeof e?t[e]:"globalize"==e?k:(...t)=>new JqElement(e,y(t))});function k(t){C.forEach((e=>(t??globalThis)[e]=A[e]))}const F=new Proxy((function(t,...e){return function(t){const e=String(t??"");return new JqText(e)}(Array.isArray(t)?t.reduce(((t,n,o)=>t+String(n??"")+String(e[o]??"")),""):t)}),{}),L=new Proxy((function(t){return JqAttribute.objectToJqAttributes(t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>function(t,e){const n=String(e??"");return new JqAttribute(t,n)}(e,t)}),I=new Proxy((function(t){throw new JqEvent(t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>new JqEvent(e,t)}),M=new Proxy((function(...t){const[e,...n]=t;if(1==t.length&&!h(e)){return new JqCSSRule([":JqCSSRule",...n],e)}return(...t)=>new JqCSSRule([e,...n],...t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>new JqCSSProperty(e,t)}),O=Object.assign(((t,e=HTMLElement)=>{if(customElements.get(t))throw new TypeError(`JqError - custom element '${t}' was already defined`);O[T].push(t);const n=Symbol("_JqElement"),o=class extends e{static[n]=null;constructor(t,e){super(),o[n]=JqElement.custom(this,t,y(e))}};return customElements.define(t,o),(...e)=>(new o(t,e),o[n])}),{[T]:[]}),$=new Proxy(O,{get:(t,e)=>"symbol"==typeof e?t[e]:t(j(e))});function H(...t){return new JqAnimation(...t)}function R(t={}){if(h(t))throw new TypeError("JqError - Expected an object as a value to state(...)");const e=Array.isArray(t),n=new JqState(t);return new Proxy(n,{get:(t,e)=>e==S?t:e==s?t[s]:t[s][e],set(t,n,o){if(t[s][n]=o,e&&"length"==n)return!0;for(const e of t.watchers)e.reconcile();return!0},has:(t,e)=>Reflect.has(t[s],e)})}function W(...t){throw new JqWatch(...t)}function D(t){throw new JqCondition(t)}function _(t){throw new JqEach(t)}function z(){throw new JqLifecycle(r)}function G(){throw new JqLifecycle(i)}function V(t){return new JqPromise(t)}const Z={attr:L,text:F,fragment:function(...t){const{childNodes:e}=y(t);return new JqFragment(e)}};export{H as animate,z as attach,M as css,$ as custom,G as detach,_ as each,y as getNodes,A as natives,Z as nodes,I as on,d as paths,R as state,V as wait,W as watch,D as when};
const t=Symbol("created"),e=Symbol("updated"),n=Symbol("deleted"),o=Symbol("unchanged"),r=Symbol("OnAttachCallback"),i=Symbol("OnDetachCallback"),s=Symbol("StateReference"),a=Symbol("PromisePending"),c=Symbol("PromiseResolved"),l=Symbol("PromiseRejected"),d=Object.create(null),h=t=>t!==Object(t),u=(...t)=>t.every((t=>t instanceof JqElement)),f=(...t)=>t.every((t=>t instanceof JqAttribute)),m=(...t)=>t.every((t=>t instanceof JqFragment)),q=(...t)=>t.every((t=>t instanceof JqText));function p(...t){return t.every((t=>null==t))}const J=()=>[JqElement,JqAttribute,JqCSSProperty,JqCSSRule,JqAnimation,JqEvent,JqWatch,JqFragment,JqText,JqEach,JqEvent,JqCondition,JqLifecycle,JqList,JqPromise],b=(t,e=Error)=>{throw new e(t)},S=Symbol("JqNodeReference");function y(t){const e=[],n=[],o=[],r=[],i=[],s=[],a=[],c=[],l=[],d=[],u=[];let f=0;for(const e of t)m(e,f),f++;return{childNodes:e,attributes:n,events:o,animations:r,inlineStyles:d,blockStyles:u,watchers:i,conditions:s,iterators:a,lifecycles:c,promiseStates:l};function m(t,f){if(t instanceof JqElement)t.nodePosition=f,e.push(t);else if(t instanceof JqFragment)t.nodePosition=f,e.push(t);else if(t instanceof JqText)t.nodePosition=f,e.push(t);else if(t instanceof JqAttribute)t.nodePosition=f,n.push(t);else if(t instanceof JqList&&t.nodeClass===JqAttribute)for(const e of t)e.nodePosition=f,n.push(e);else if(t instanceof JqEvent)t.nodePosition=f,o.push(t);else if(t instanceof JqWatch)t.nodePosition=f,i.push(t);else if(t instanceof JqCondition)t.nodePosition=f,s.push(t);else if(t instanceof JqEach)t.nodePosition=f,a.push(t);else if(t instanceof JqLifecycle)t.nodePosition=f,c.push(t);else if(t instanceof JqPromiseState)t.nodePosition=f,l.push(t);else if(t instanceof JqAnimation)t.nodePosition=f,r.push(t);else if(t instanceof JqCSSProperty)t.nodePosition=f,d.push(t);else if(t instanceof JqCSSRule)t.nodePosition=f,u.push(t);else if(Array.isArray(t)){const n=g(t,null);n.nodePosition=f,e.push(n)}else{if("function"==typeof t){return m(E(t),f)}if(h(t)){const n=g(t,null);n.nodePosition=f,e.push(n)}}}}function E(t){try{t()}catch(e){if((()=>e instanceof JqWatch||e instanceof JqEvent||e instanceof JqCondition||e instanceof JqEach||e instanceof JqLifecycle)())return e.callback=t,e;throw e}throw new TypeError('JqError - Expected a JqCallback<"watch" | "event" | "condition" | "each" | "mount" | "unmount"> but instead found a \'function\'')}function g(t,e){return Array.isArray(t)?(t=>{const n=y(t),o=n.childNodes;for(let t=0;t<o.length;t++){o[t].nodePosition=t}const r=new JqFragment(o);return r.jqParent=e,r.conditions=n.conditions,r.iterators=n.iterators,r.lifecycles=n.lifecycles,r.promisesStates=n.promiseStates,r.watchers=n.watchers,r})(t):h(t)?(t=>{const n=new JqText(t??"");return n.jqParent=e,n})(t):"function"==typeof t?(t=>{const n=E(t);return n.jqParent=e,n})(t):J().some((e=>t instanceof e))?t:b("JqError - Unexpected value found in place of a JqNode")}const P=(t,e)=>{let n=t;for(let t=0;t<e.length;t++)if(n=n?.[e[t]],p(n))return n;return n};class JqPromiseState{nodePosition=-1;jqParent=null;state;jqPromise;constructor(t,e){this.state=t,this.jqPromise=e}}class JqPromise{state=a;callback;subscriptions={pending:[],resolved:[],rejected:[]};promise=null;constructor(t){this.callback=t}invoke(){const t=this.promise=this.callback();return this.subscriptions.pending.forEach((e=>e.callback(t))),t.then((t=>this.subscriptions.resolved.forEach((e=>(this.state=c,e.callback(t)))))).catch((t=>this.subscriptions.rejected.forEach((e=>(this.state=l,e.callback(t)))))),t}subscribe(t){const{subscriber:e,callback:n,type:o}=t;this.subscriptions[o].push({subscriber:e,callback:n})}get pending(){throw new JqPromiseState(a,this)}get then(){throw new JqPromiseState(c,this)}get catch(){throw new JqPromiseState(l,this)}}class JqLifecycle{nodePosition=-1;jqParent=null;type;callback;constructor(t){this.type=t}delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent,n=e.lifecycles.findIndex((e=>Object.is(e,t)));return-1==n&&b("JqInternalError - JqLifecycle not found in its jqParent.lifecycles"),e.lifecycles.splice(n,1),this}}}class JqEach{nodePosition=-1;jqParent=null;iterable;callback=t=>"";returned=null;constructor(t){this.iterable=t}invoke(){let t=0;const e=[];for(const n of this.iterable){const o=this.callback([n,t,this.iterable]);e.push(o),t++}const n=g(e,this.jqParent);return n.nodePosition=this.nodePosition,n}delete={context:this,deleteSelf(){const t=this.context;return v.delete.deleteSelf(t),t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqEach not found in its jqParent.iterators"};static getInstancesFromParent(t){return t.iterators}}class JqCondition{nodePosition=-1;jqParent=null;condition=!1;callback=t=>"";returned=null;constructor(t){this.condition=t}invoke(){const t=E(this.callback);this.condition=t.condition;return this.condition?t.callback(this.condition):new JqText}delete={context:this,deleteSelf(){const t=this.context;return v.delete.deleteSelf(t),t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqCondition not found in its jqParent.conditions"};static getInstancesFromParent(t){return t.conditions}}class JqEvent{nodePosition=-1;event;callback;jqParent=null;constructor(t,e=(t=>"")){this.event=t,this.callback=e}attachHandler(t){t.addEventListener(this.event,this.callback)}detachHandler(t){t.removeEventListener(this.event,this.callback)}attachTo(t){if(t instanceof HTMLElement)this.attachHandler(t);else{if(!(t instanceof JqElement))throw new Error(JqEvent.errors.invalidAttachTo(this));this.jqParent=t,t.events.includes(this)||t.events.push(this),this.attachHandler(t.domNode)}return this}delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent;v.delete.deleteSelf(t);const n=e.domNode;return n&&t.detachHandler(n),this}};static errors={invalidAttachTo:t=>`JqError - Cannot attach JqEvent '${t.event}' to a node not of instance JqElement or JqFragment or HTMLElement`,invalidParent:t=>"JqInternalError - JqEvent not found in its jqParent.events"};static getInstancesFromParent(t){return t instanceof JqFragment?[]:t.events}}class JqWatch{nodePosition=-1;jqParent=null;jqStates=[];callback=t=>"";returned=null;constructor(...t){this.jqStates=t}invoke(){return this.callback(this.jqStates.map((t=>t[s])))}reconcile(){const t=this.returned,n=v.extractEffectReturn(this,this.jqParent);n.attachTo(null,!1);const o=x(t,n);return JqWatch.reconcile(o),o[e].length&&(this.returned=n),this}delete={context:this,deleteSelf(){const t=this.context;v.delete.deleteSelf(t);for(const e of t.jqStates){e[S].delete.removeWatcher(t)}return t.returned=null,this}};static errors={invalidParent:t=>"JqInternalError - JqWatch not found in its jqParent.watchers"};static getInstancesFromParent(t){return t.watchers}static reconcile(o){const r=o.node1,i=o.node2,s=o[e],a=o[t],c=o[n];for(const[t,...e]of s)q(r,i)?"text"==t&&JqWatch.updateText(o,[t,...e]):f(r,i)?"value"==t&&JqWatch.updateAttribute(o,[t,...e]):p(r)||p(i)||JqWatch.updateElement(o,[t,...e]);for(const[t,...e]of a)q(r,i)||f(r,i)||(m(r,i)?"childNodes"==t&&JqWatch.createFragment(o,[t,...e]):u(r,i)&&"childNodes"==t&&JqWatch.createElement(o,[t,...e]));for(const[t,...e]of c)m(r,i)?JqWatch.deleteFragmentChild(o,[t,...e]):u(r,i)?JqWatch.deleteElementChild(o,[t,...e]):r.delete.deleteSelf();for(const t of o.childDiffs)JqWatch.reconcile(t)}static updateAttribute(t,e){if(![t.node1,t.node2].every((t=>t instanceof JqAttribute)))return this;const n=t.node1,o=t.node2;return n.update.setAttribute(o.value)}static updateText(t,e){if(![t.node1,t.node2].every((t=>t instanceof JqText)))return this;const n=t.node1,o=t.node2;n.update.setText(o.text)}static updateElement(t,e){const n=t.node1,o=t.node2;n.jqParent.update.replaceChild(n,o)}static createElement(t,[e,n]){if(![t.node1,t.node2].every((t=>t instanceof JqElement)))return this;const o=t.node1;t.node2;const r=n;return r.jqParent=o.jqParent,r.nodePosition=o.childNodes.length,o.childNodes.splice(o.childNodes.length,0,r),r.attachTo(o),this}static createFragment(t,[e,n]){if(![t.node1,t.node2].every((t=>t instanceof JqFragment)))return this;const o=t.node1;t.node2;const r=n;return r.jqParent=o.jqParent,r.nodePosition=o.childNodes.length,r.attachTo(o),this}static deleteFragmentChild(t,[e,n]){t.node1,t.node2;n.delete.deleteSelf()}static deleteElementChild(t,[e,n]){t.node1,t.node2;n.delete.deleteSelf()}}class JqState{[S];[s];watchers=[];constructor(t){this[s]=t,this[S]=this}delete={context:this,removeWatcher(t){const e=this.context,n=e.watchers.findIndex((e=>Object.is(e,t)));return-1==n&&b("JqInternalError - JqWatcher not found in one of its jqState.watchers"),e.watchers.splice(n,1),this}}}class JqAnimation{domAnimation=null;nodePosition=-1;parameters;jqParent=null;constructor(...t){this.parameters=t}attachTo(t){if(t instanceof HTMLElement)this.animate(t);else{if(!(t instanceof JqElement))throw new Error("JqError - Cannot attach JqAnimation to a node not of instance JqElement or JqFragment or HTMLElement");this.jqParent=t,this.animate(t.domNode)}return this}animate(t){const[e,n,...o]=this.parameters;let r=null,i=h(n)?null:n;const[s,a,c]=[n,...o];c&&(r=c);const l={duration:s??400,easing:a??"linear",fill:"forwards"};i??=l;const d=Array.isArray(e)?e.map((t=>t instanceof Map?Object.fromEntries(t):t)):e instanceof Map?Object.fromEntries(e):e,u=Array.isArray(d)?d.map((e=>JqAnimation.setInitialStyles(t,e))):JqAnimation.setInitialStyles(t,d);return this.domAnimation=t.animate(u,i),r&&this.domAnimation.addEventListener("finish",r),this.domAnimation}static setInitialStyles(t,e,...n){const o=Object.keys(e).filter((t=>!Array.isArray(e[t]))).map((n=>{const o=e[n];return[n,[getComputedStyle(t).getPropertyValue(n),o]]}));return{...e,...Object.fromEntries(o)}}}class JqCSSProperty{name;value;nodePosition=-1;jqParent=null;constructor(t,e){this.name=j(t).replace(/_/g,"-"),this.value=String(e)}attachTo(t){if(t instanceof HTMLElement)t.style.setProperty(this.name,this.value);else{if(!(t instanceof JqElement))throw new Error(JqCSSProperty.errors.invalidAttachTo(this));this.jqParent=t}return this}toString(t=1){return`${this.name}: ${this.value};`}static errors={invalidAttachTo:t=>"JqError - Cannot attach JqCSSProperty to a node not of instance JqElement or JqFragment or HTMLElement"};static getStyleFragment(t){const e=new JqText(t.name),n=new JqText(t.value),o=y([e,new JqText(": "),n,new JqText(";")]).childNodes;return new JqFragment(o)}}class JqCSSRule{nodePosition=-1;head;body=[];jqParent=null;constructor([t,...e],...n){this.head=[t,...e];const o=JqCSSRule.errors.invalidHeadArgument(this);this.body=n.flatMap((t=>t instanceof JqCSSProperty||t instanceof JqCSSRule?t:function(t,e){n=e,(null===n||"object"!=typeof n)&&b(t);var n;const o=Object.entries(e).map((([t,e])=>new JqCSSProperty(t,e)));return new JqList(JqCSSProperty,o)}(o,t).nodes))}attachTo(t){if(t instanceof HTMLElement){const e=document.createElement("style");e.textContent=this.toString(),t.appendChild(e)}else{if(!(t instanceof JqElement))throw new Error(JqCSSRule.errors.invalidAttachTo(this));this.jqParent=t}return this}toString(t=1){const e="\t".repeat(t);return`${this.head.join(" ").trim()} {\n${e}${this.body.map((e=>e.toString(t+1))).join("\n"+e)}\n${"\t".repeat(t-1)}}`}static errors={invalidAttachTo:t=>"JqError - Cannot attach JqCSSRule to a node not of instance JqElement or JqFragment or HTMLElement",invalidHeadArgument:t=>`JqError - Invalid argument passed to ${t.head.join(" ").trim()}(...)`};static getStyleFragment(t){const e=new JqFragment(y(t.head).childNodes),n=t.body.map((t=>w.getStyleClass(t).getStyleFragment(t))),o=y([e,new JqText(" {\n"),...n,new JqText("\n}")]).childNodes;return new JqFragment(o)}}class JqList{nodes=[];nodeClass;constructor(t,e){this.nodeClass=t,this.nodes=e}push(t){if(!(t instanceof this.nodeClass))throw new TypeError(`JqError - Cannot push node not of instance '${this.nodeClass.name}' into JqList<${this.nodeClass.name}>`);this.nodes.push(t)}pop(){return this.nodes.pop()}[Symbol.iterator]=()=>this.nodes[Symbol.iterator]()}class JqAttribute{_name="";_value="";nodePosition=-1;attrNode=null;jqParent=null;constructor(t,e){this.name=j(t).replace(/_/g,"-"),this.value=e}get name(){return this._name}set name(t){this._name=t}get value(){return this._value}set value(t){this._value=t}attachTo(t){if(this.initial.createNode(),t instanceof HTMLElement)t.setAttributeNode(this.attrNode);else{if(!(t instanceof JqElement))throw new TypeError(`JqError - Cannot attach JqAttribute '${this.name}' to a node not of instance JqElement or JqFragment or HTMLElement`);this.jqParent=t,t.domNode.setAttributeNode(this.attrNode)}return this}initial={context:this,createNode(){const t=this.context;return t.attrNode=document.createAttribute(t.name),t.attrNode.value=t.value,this}};update={context:this,updateAttribute(){const t=this.context;return t.attrNode.value=t.value,this},setAttribute(t){const e=this.context;return t===e.value||(e.value=t,e.attrNode.value=t),this}};delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent;return e?(e.delete.removeAttribute(t),t.attrNode=null,this):this}};static objectToJqAttributes(t){if(null===t||"object"!=typeof t)throw new TypeError("JqError - Invalid argument passed to attr(...)");const e=Object.entries(t).map((([t,e])=>{const n=j(t).replace(/_/g,"-"),o=String(e);return new JqAttribute(n,o)}));return new JqList(JqAttribute,e)}}class JqText{nodePosition=-1;jqParent=null;domNode=null;text="";constructor(...t){this.text=t.map((t=>String(t??""))).join("")}attachTo(t,e=!0){if(null===t)return this.toString();if(this.initial.createNode(),t instanceof HTMLElement)return e&&t.appendChild(this.domNode),this.toString();if(t instanceof JqElement)this.jqParent=t,t.childNodes.includes(this)||t.childNodes.splice(this.nodePosition,0,this),e&&(t.shadowRoot??t.domNode).appendChild(this.domNode);else{if(!(t instanceof JqFragment))throw new TypeError(JqText.errors.invalidAttachTo(this));this.jqParent=t,t.childNodes.includes(this)||t.childNodes.splice(this.nodePosition,0,this),e&&t.domNode.appendChild(this.domNode)}return this.toString()}toString(t=0){return this.text}initial={context:this,createNode(){const t=this.context;return t.domNode=document.createTextNode(t.text),this}};update={context:this,setText(t){const e=this.context;e.domNode.nodeValue=e.text=t}};delete={context:this,deleteSelf(){const t=this.context,e=t.jqParent,n=e.childNodes.findIndex((e=>Object.is(e,t)));return e.childNodes.splice(n,1),t.domNode.remove(),this}};static errors={invalidAttachTo:t=>"JqError - Cannot attach JqText to a node not of instance JqElement or JqFragment or HTMLElement"}}class JqFragment{nodePosition=-1;jqParent=null;domNode=null;childNodes=[];watchers=[];conditions=[];iterators=[];lifecycles=[];promisesStates=[];scopedStyleSheet=null;constructor(t){this.childNodes=t}attachTo(t,e=!0){return N.attachTo(this,t,JqFragment.attachNode,e)}toString(t=0){return this.childNodes.map((e=>e.toString(t))).join("\n"+"\t".repeat(t))}initial={context:this,createNode(){return this.context.domNode=document.createDocumentFragment(),this},attachChildren(t=!0){const e=this.context;return N.initial.attachChildren(e,t),this}};update={context:this,replaceChild(t,e){const n=this.context;return N.update.replaceChild(n,t,e),this}};delete={context:this,deleteSelf(){const t=this.context;return N.delete.deleteSelf(t),this}};static errors={invalidAttachTo:t=>"JqError - Cannot attach JqFragment to a node not of instance JqElement or JqFragment or HTMLElement",childNodeNotFound:t=>"JqInternalError - childNode not found in JqFragment.childNodes",invalidParent:t=>"JqInternalError - JqFragment not found in its jqParent.childNodes"};static attachNode(t,e,n){return n?t.initial.createNode().attachChildren():t.initial.attachChildren(n)}static collectDetachableEffectNodes(t,e){}}class JqElement{name;nodePosition=-1;jqParent=null;shadowRoot=null;domNode=null;childNodes=[];attributes=[];events=[];animations=[];inlineStyles=[];blockStyles=[];watchers=[];conditions=[];iterators=[];lifecycles=[];promisesStates=[];scopedStyleSheet=null;id="jq"+((t=5)=>Math.random().toString(32).replace(/\d\./,"").slice(0,t))();constructor(t,e){this.name=t,Object.assign(this,e)}attachTo(t,e=!0){return N.attachTo(this,t,JqElement.attachNode,e)}toString(t=0){const e=e=>e>0?"\n"+"\t".repeat(t+1):"",n=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(this.name)?"/":"",o=this.childNodes.map((e=>e.toString(t+1))).join("\n"+"\t".repeat(t+1)),r=this.attributes.map((t=>`${t.name} = "${String(t.value??"")}"`)).join(" "),i=this.watchers.map((e=>e.returned?.toString(t+1)??"")).join("\n"+"\t".repeat(t)),s=`<${this.name}${r.length?" ":""}${r}${n}>`,a=`${e(o.length||i.length)+o+(i.length?e(o.length)+i:"")+(c=o.length||i.length,c>0?"\n"+"\t".repeat(t):"")}</${this.name}>`;var c;return`${s}${n?"":a}`}initial={context:this,createNode(){const t=this.context;return t.domNode=document.createElement(t.name),this},attachAttributes(){const t=this.context;for(const e of t.attributes)e.attachTo(t);return this},attachChildren(t=!0){const e=this.context;return N.initial.attachChildren(e,t),this},attachEventListeners(){const t=this.context;for(const e of t.events)e.attachTo(t);return this},attachAnimations(){const t=this.context;return 0==t.animations.length||(e=t.domNode,new IntersectionObserver((t=>(e,n)=>e.forEach((e=>t([e,n]))))((([e,n])=>{if(e.isIntersecting){for(const e of t.animations)e.attachTo(t);n.disconnect()}}))).observe(e)),this;var e},attachStyles(t){const e=this.context;return JqElement.attachStyles(e,t),this}};update={context:this,replaceChild(t,e){const n=this.context;return N.update.replaceChild(n,t,e),this}};delete={context:this,removeAttribute(t){const e=this.context,n=e.attributes.indexOf(t);return-1!=n&&e.attributes.splice(n,1),e.domNode.removeAttribute(t.name),this},deleteSelf(){const t=this.context;return N.delete.deleteSelf(t),t.domNode.remove(),this}};static custom=(t,e,n)=>new JqElement(e,{...n,domNode:t});static errors={invalidAttachTo:t=>`JqError - Cannot attach JqElement '${t.name}' to a node not of instance JqElement or JqFragment or HTMLElement`,childNodeNotFound:t=>"JqInternalError - childNode not found in JqElement.childNodes",invalidParent:t=>"JqInternalError - JqElement not found in its jqParent.childNodes",unstylableElement:t=>`JqError - The HTML '${t.name}' Element cannot be styled`};static attachNode(t,e,n){return n?t.initial.createNode().attachStyles(e).attachAttributes().attachChildren().attachEventListeners().attachAnimations():t.initial.attachChildren(n)}static attachStyles(t,e){const{formatSelectorAndGetStyleFragment:n,maybeAttachStyleElementToHTMLParent:o,attachStylesToStylesheet:r}=w,i=/^(?:style|script|template|link|meta|br|head|wbr|title|track)$/i.test(t.name);if(null==e)return;if(o(t,e,i),0==t.blockStyles.length&&0==t.inlineStyles.length)return;i&&b(JqElement.errors.unstylableElement(t));t.domNode.classList.add(t.id);const s=new JqCSSRule(["."+t.id],...t.inlineStyles),a=Array.from(t.blockStyles,(e=>n(e,t.id)));a.push(JqCSSRule.getStyleFragment(s)),r(t,a)}static collectDetachableEffectNodes(t,e){return e.push(...t.events),e.push(...t.lifecycles),e}}const N={attachTo(t,e,n,o=!0){if(null===e)n(t,e,o);else if(e instanceof HTMLElement)n(t,e,o),o&&e.appendChild(t.domNode);else if(e instanceof JqElement){t.jqParent=e,t.scopedStyleSheet=e.scopedStyleSheet,n(t,e,o),e.childNodes.includes(t)||e.childNodes.splice(t.nodePosition,0,t);const r=e.shadowRoot??e.domNode;o&&r.appendChild(t.domNode)}else{if(!(e instanceof JqFragment)){const e=(t instanceof JqElement?JqElement:JqFragment).errors;throw new Error(e.invalidAttachTo(t))}if(t.jqParent=e,t.scopedStyleSheet=e.scopedStyleSheet,n(t,e,o),e.childNodes.includes(t)||e.childNodes.splice(t.nodePosition,0,t),o){e.domNode.appendChild(t.domNode);let n=e.jqParent;for(;null!=n&&m(n);)n=n.jqParent;null!=n&&n.domNode.appendChild(t.domNode)}}if(o)for(let e=0;e<t.lifecycles.length;e++){const n=t.lifecycles[e];n.jqParent=t,n.type==r&&n.callback(t)}return t.toString()},initial:{attachChildren(t,e=!0){const n=v.getEffectNodes(t),o=t.childNodes,r=o.length;for(let i=0;i<r;i++){const r=o[i],s=v.getPrecedingEffectNodes(n,r);v.attachEffectNodes(s,t,e),r.attachTo(t,e)}v.attachEffectNodes(n,t,e)}},update:{replaceChild(t,e,n){if(-1==t.childNodes.findIndex((t=>Object.is(t,e)))){const e=(t instanceof JqElement?JqElement:JqFragment).errors;b(e.childNodeNotFound(t))}n.nodePosition=e.nodePosition,n.attachTo(t),e.delete.deleteSelf()}},delete:{deleteSelf(t){const{errors:e,collectDetachableEffectNodes:n}=N.getParentableClass(t),o=t.jqParent,r=o.childNodes.findIndex((e=>Object.is(e,t)));-1==r&&b(e.invalidParent(t));for(let e=0;e<t.lifecycles.length;e++){const n=t.lifecycles[e];n.type==i&&n.callback(t)}for(o.childNodes.splice(r,1);t.childNodes.length;){t.childNodes[0].delete.deleteSelf()}const s=v.getEffectNodes(t);n(t,s);for(const t of s)t.delete.deleteSelf()}},getParentableClass(t){if(t instanceof JqElement)return JqElement;if(t instanceof JqFragment)return JqFragment;throw new Error("JqInternalError - Expected an instance of JqElement | JqFragment as the first argument")}},v={delete:{deleteSelf(t){const e=t.jqParent,{errors:n,getInstancesFromParent:o}=v.getEffectClass(t),r=o(e),i=r.findIndex((e=>Object.is(e,t)));-1==i&&b(n.invalidParent(t)),r.splice(i,1)}},getEffectClass(t){if(t instanceof JqEach)return JqEach;if(t instanceof JqCondition)return JqCondition;if(t instanceof JqEvent)return JqEvent;if(t instanceof JqWatch)return JqWatch;throw new Error("JqInternalError - Expected an instance of JqEffectNode as the first argument")},isInvokableEffectNode:t=>t instanceof JqEach||t instanceof JqCondition||t instanceof JqWatch,attachEffectNodes(t,e,n){for(const o of t){o.jqParent=e;const t=o.returned;if(o.jqParent.childNodes.includes(t))continue;const r=v.extractEffectReturn(o,e);if(o.returned=r,o instanceof JqWatch)for(const t of o.jqStates){const e=t[S],n=e.watchers.findIndex((t=>t.callback.toString()==o.callback.toString()));-1!=n?e.watchers.splice(n,1,o):e.watchers.push(o)}r.attachTo(e,n)}},getPrecedingEffectNodes(t,e){const n=[];for(let o=0;o<t.length;o++){const r=t[o],i=r.nodePosition;i>e.nodePosition||(t.splice(i,1),n.push(r))}return n},getEffectNodes(t){const e=[],n=Math.max(t.watchers.length,t.conditions.length,t.iterators.length);for(let o=0;o<n;o++){const n=[t.watchers[o],t.conditions[o],t.iterators[o]].filter(Boolean);e.push(...n)}return e},extractEffectReturn(t,e){let n=t.invoke();for(;v.isInvokableEffectNode(n)||"function"==typeof n;)n=g(n,e),n=n.invoke();const o=g(n,e);return o.nodePosition=t.nodePosition,o}},w={getStyleClass(t){if(t instanceof JqCSSProperty)return JqCSSProperty;if(t instanceof JqCSSRule)return JqCSSRule;throw new Error("JqInternalError - Expected an instance of JqStyleNode as the first argument")},attachStylesToStylesheet(t,e){const n=t.scopedStyleSheet;return e.forEach((t=>t.attachTo(n))),n},maybeAttachStyleElementToHTMLParent(t,e,n){if(!(e instanceof HTMLElement)||n)return;const o=new JqElement("style",{});o.attachTo(e),t.scopedStyleSheet=o},formatSelectorAndGetStyleFragment:(t,e)=>(t.head[0]=w.formatSelector(e,t.head[0]),JqCSSRule.getStyleFragment(t)),formatSelector(t,e){const n="."+t;return":JqCSSRule"==e?n:e.startsWith("@")?e:e.startsWith("::")?`${n}${e}`:`${n} :where(${e})`}};const j=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((t,e)=>(e?"-":"")+t.toLowerCase()));function x(r,i){const s=function(r,i){return u(r)&&u(i)?function(r,i){const s=r.childNodes,a=i.childNodes,c=r.attributes,l=i.attributes,d={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],r=a[e];void 0===o?d[t].push(["childNodes",r]):void 0===r?d[n].push(["childNodes",o]):d.childDiffs.push(x(o,r))}for(let e=0;e<Math.max(c.length,l.length);e++){const o=c[e],r=l[e];void 0===o?d[t].push(["attributes",r]):void 0===r?d[n].push(["attributes",o]):d.childDiffs.push(x(o,r))}return d}(r,i):m(r)&&m(i)?function(r,i){const s=r.childNodes,a=i.childNodes,c={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],r=a[e];void 0===o?c[t].push(["childNodes",r]):void 0===r?c[n].push(["childNodes",o]):c.childDiffs.push(x(o,r))}return c}(r,i):f(r)&&f(i)?function(t,e){const n=a({object:t,props:[["name"],["value"]]},{object:e,props:[["name"],["value"]]});return n}(r,i):q(r)&&q(i)?function(t,e){const n={object:t,props:[["text"]]},o={object:e,props:[["text"]]},r=a(n,o);return r}(r,i):function(r,i){const s={type:Object.getPrototypeOf(r).constructor,node1:r,node2:i,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},[a,c]=[p(r),p(i)];a&&s[t].push(["self"]);c&&s[n].push(["self"]);return a||c?s(r.jqParent):(s[e].push(["childNodes",i]),s)}(r,i)}(r,i);return s;function a(r,i){const s={type:Object.getPrototypeOf(r.object).constructor,node1:r.object,node2:i.object,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},a=r.props.filter((t=>p(P(i.object,t))));s[n]=a;const c=i.props.filter((t=>p(P(r.object,t))));s[t]=c;const l=r.props.filter((t=>P(i.object,t)!==P(r.object,t)));s[e]=l;const d=r.props.filter((t=>P(i.object,t)===P(r.object,t)));return s[o]=d,s}}const C=["a","address","article","aside","audio","b","base","bdo","br","button","canvas","caption","cite","code","col","colgroup","command","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figure","figcaption","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","portal","q","ruby","s","section","small","span","strike","tt","u","var","video","wbr","abbr","area","bdi","blockquote","body","iframe","menu","meta","picture","rb","rp","rt","rtc","samp","script","select","slot","source","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul"],T=Symbol("CustomElements"),A=new Proxy({},{get:(t,e)=>"symbol"==typeof e?t[e]:"globalize"==e?k:(...t)=>new JqElement(e,y(t))});function k(t){C.forEach((e=>(t??globalThis)[e]=A[e]))}const F=new Proxy((function(t,...e){return function(t){const e=String(t??"");return new JqText(e)}(Array.isArray(t)?t.reduce(((t,n,o)=>t+String(n??"")+String(e[o]??"")),""):t)}),{}),L=new Proxy((function(t){return JqAttribute.objectToJqAttributes(t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>function(t,e){const n=String(e??"");return new JqAttribute(t,n)}(e,t)}),I=new Proxy((function(t){throw new JqEvent(t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>new JqEvent(e,t)}),$=new Proxy((function(...t){const[e,...n]=t;if(1==t.length&&!h(e)){return new JqCSSRule([":JqCSSRule",...n],e)}return(...t)=>new JqCSSRule([e,...n],...t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>new JqCSSProperty(e,t)}),M=Object.assign(((t,e=HTMLElement)=>{if(customElements.get(t))throw new TypeError(`JqError - custom element '${t}' was already defined`);M[T].push(t);const n=Symbol("_JqElement"),o=class extends e{static[n]=null;constructor(t,e){super(),o[n]=JqElement.custom(this,t,y(e))}};return customElements.define(t,o),(...e)=>(new o(t,e),o[n])}),{[T]:[]}),O=new Proxy(M,{get:(t,e)=>"symbol"==typeof e?t[e]:t(j(e))});function H(...t){return new JqAnimation(...t)}function R(t={}){if(h(t))throw new TypeError("JqError - Expected an object as a value to state(...)");const e=Array.isArray(t),n=new JqState(t);return new Proxy(n,{get:(t,e)=>e==S?t:e==s?t[s]:t[s][e],set(t,n,o){if(t[s][n]=o,e&&"length"==n)return!0;for(const e of t.watchers)e.reconcile();return!0},has:(t,e)=>Reflect.has(t[s],e)})}function W(...t){throw new JqWatch(...t)}function D(t){throw new JqCondition(t)}function _(t){throw new JqEach(t)}function z(){throw new JqLifecycle(r)}function G(){throw new JqLifecycle(i)}function V(t){return new JqPromise(t)}const Z={attr:L,text:F,fragment:function(...t){const{childNodes:e}=y(t);return new JqFragment(e)}};export{H as animate,z as attach,$ as css,O as custom,G as detach,_ as each,y as getNodes,A as natives,Z as nodes,I as on,d as paths,R as state,V as wait,W as watch,D as when};
//# sourceMappingURL=jquire.min.js.map

@@ -12,3 +12,4 @@ import {

main, nav, a, br, hr, ul, li,
footer, template, span, aside
footer, template, span, aside,
header
} = natives

@@ -40,2 +41,3 @@

div(
header(css.border("1px solid green")),
a("efgh", attr.href("#")),

@@ -42,0 +44,0 @@ (_ = watch(sidebarST)) => (_ = when(sidebarST.clicked)) =>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc