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.4.45 to 1.5.0

2

docs/components/AlertBox.js
import { natives, nodes, css, paths } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
const { div, img, h4, p } = natives
const { attr, text, fragment } = nodes
const { attr } = nodes

@@ -6,0 +6,0 @@ export default (heading = '', content = '') => {

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

@@ -46,6 +46,2 @@ export default (language = '', sourceCode = '', highlighter) => {

css(`:host::-webkit-scrollbar-thumb`)(codeBoxScrollbarThumbStyle),
link(
attr.rel("stylesheet"),
(_ = watch(codeThemeLinkST)) => attr.href(codeThemeLinkST.codeThemeLink)
),
pre(

@@ -52,0 +48,0 @@ codeBlock = code(

@@ -1,12 +0,17 @@

import { natives, nodes } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
const { em } = natives
const { attr } = nodes
export default (...props) => {
const style = `color: var(--font-color); font-style: normal; background-color: var(--background-color-tertiary); padding: 0.1rem 0.45rem; border-radius: 0.2rem; margin: 0rem 0.3rem; font-family: monospace;`
return em(
...props,
attr.style(style)
)
const style = {
color: "var(--font-color)",
fontStyle: "normal",
backgroundColor: "var(--background-color-tertiary)",
padding: "0.1rem 0.45rem",
borderRadius: "0.2rem",
margin: "0rem 0.3rem",
fontFamily: "monospace",
}
return em(css(style), ...props)
}

@@ -1,12 +0,8 @@

import { natives, nodes } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
import { natives } from "https://cdn.jsdelivr.net/npm/jquire@1.4.4/src/jquire.min.js"
const { a } = natives
const { attr } = nodes
export default (...props) => {
const style = `color: var(--greenish-fountain-blue)`
return a(
...props,
attr.style(style)
)
const style = { color: "var(--greenish-fountain-blue)" }
return a(css(style), ...props)
}
{
"name": "jquire",
"version": "1.4.45",
"version": "1.5.0",
"description": "",

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

@@ -202,3 +202,3 @@ import {

if (args.length == 1 && !isPrimitive(ruleName)) {
const rule = new JqCSSRule([":host", ...ruleArgs],
const rule = new JqCSSRule([":JqCSSRule", ...ruleArgs],
/**@type {{ [x: string]: import("./utility.js").Primitive }}*/(ruleName))

@@ -205,0 +205,0 @@ return rule

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

const t=Symbol("created"),e=Symbol("updated"),n=Symbol("deleted"),o=Symbol("unchanged"),i=Symbol("OnAttachCallback"),r=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)},E=Symbol("JqNodeReference");function g(t){const e=[],n=[],o=[],i=[],r=[],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:i,inlineStyles:d,blockStyles:u,watchers:r,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,r.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,i.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=y(t,null);n.nodePosition=f,e.push(n)}else{if("function"==typeof t){return m(P(t),f)}if(h(t)){const n=y(t,null);n.nodePosition=f,e.push(n)}}}}function P(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 y(t,e){return Array.isArray(t)?(t=>{const n=g(t),o=n.childNodes;for(let t=0;t<o.length;t++){o[t].nodePosition=t}const i=new JqFragment(o);return i.jqParent=e,i.conditions=n.conditions,i.iterators=n.iterators,i.lifecycles=n.lifecycles,i.promisesStates=n.promiseStates,i.watchers=n.watchers,i})(t):h(t)?(t=>{const n=new JqText(t??"");return n.jqParent=e,n})(t):"function"==typeof t?(t=>{const n=P(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 S=(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=y(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=P(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=w(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[E].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 i=o.node1,r=o.node2,s=o[e],a=o[t],c=o[n];for(const[t,...e]of s)q(i,r)?"text"==t&&JqWatch.updateText(o,[t,...e]):f(i,r)?"value"==t&&JqWatch.updateAttribute(o,[t,...e]):p(i)||p(r)||JqWatch.updateElement(o,[t,...e]);for(const[t,...e]of a)q(i,r)||f(i,r)||(m(i,r)?"childNodes"==t&&JqWatch.createFragment(o,[t,...e]):u(i,r)&&"childNodes"==t&&JqWatch.createElement(o,[t,...e]));for(const[t,...e]of c)m(i,r)?JqWatch.deleteFragmentChild(o,[t,...e]):u(i,r)?JqWatch.deleteElementChild(o,[t,...e]):i.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 i=n;return i.jqParent=o.jqParent,i.nodePosition=o.childNodes.length,o.childNodes.splice(o.childNodes.length,0,i),i.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 i=n;return i.jqParent=o.jqParent,i.nodePosition=o.childNodes.length,i.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{[E];[s];watchers=[];constructor(t){this[s]=t,this[E]=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 i=null,r=h(n)?null:n;const[s,a,c]=[n,...o];c&&(i=c);const l={duration:s??400,easing:a??"linear",fill:"forwards"};r??=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,r),i&&this.domAnimation.addEventListener("finish",i),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("JqError - Cannot attach JqCSS.Property to a node not of instance JqElement or JqFragment or HTMLElement");this.jqParent=t}return this}toString(t=1){return`${this.name}: ${this.value};`}}class JqCSSRule{nodePosition=-1;head;body=[];jqParent=null;constructor([t,...e],...n){this.head=[t,...e];const o=`JqError - Invalid argument passed to ${this.head.join(" ").trim()}(...)`;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);else{if(!(t instanceof JqElement))throw new Error("JqError - Cannot attach JqCSS.Rule to a node not of instance JqElement or JqFragment or HTMLElement");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)}}`}}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),e&&t.jqParent?.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=[];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){return e?t.initial.createNode().attachChildren():t.initial.attachChildren(e)}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;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)),i=this.attributes.map((t=>`${t.name} = "${String(t.value??"")}"`)).join(" "),r=this.watchers.map((e=>e.returned?.toString(t+1)??"")).join("\n"+"\t".repeat(t)),s=`<${this.name}${i.length?" ":""}${i}${n}>`,a=`${e(o.length||r.length)+o+(r.length?e(o.length)+r:"")+(c=o.length||r.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(){const t=this.context;if(0==t.inlineStyles.length&&0==t.blockStyles.length)return this;if(function(t){try{return Boolean(t.cloneNode().attachShadow({mode:"open"}))}catch{return!1}}(t.domNode)){t.shadowRoot=t.domNode.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent="",t.scopedStyleSheet=e,t.shadowRoot.appendChild(e);const n=[];for(const e of t.inlineStyles)e.attachTo(t),n.push(e);for(const n of t.blockStyles)n.attachTo(t),e.textContent+="\n"+n.toString();const o=n.join("\n\t");return o.length>0&&(e.textContent+=`\n:host {\n\t${o}\n}`),this}throw new Error(`JqError - scoped styles are not supported for '${t.name}' element.`)}};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"};static attachNode(t,e){return e?t.initial.createNode().attachStyles().attachAttributes().attachChildren().attachEventListeners().attachAnimations():t.initial.attachChildren(e)}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,o);else if(e instanceof HTMLElement)n(t,o),o&&e.appendChild(t.domNode);else if(e instanceof JqElement){t.jqParent=e,n(t,o),e.childNodes.includes(t)||e.childNodes.splice(t.nodePosition,0,t);const i=e.shadowRoot??e.domNode;o&&i.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,n(t,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==i&&n.callback(t)}return t.toString()},initial:{attachChildren(t,e=!0){const n=v.getEffectNodes(t),o=t.childNodes,i=o.length;for(let r=0;r<i;r++){const i=o[r],s=v.getPrecedingEffectNodes(n,i);v.attachEffectNodes(s,t,e),i.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,i=o.childNodes.findIndex((e=>Object.is(e,t)));-1==i&&b(e.invalidParent(t));for(let e=0;e<t.lifecycles.length;e++){const n=t.lifecycles[e];n.type==r&&n.callback(t)}for(o.childNodes.splice(i,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),i=o(e),r=i.findIndex((e=>Object.is(e,t)));-1==r&&b(n.invalidParent(t)),i.splice(r,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 i=v.extractEffectReturn(o,e);if(o.returned=i,o instanceof JqWatch)for(const t of o.jqStates){const e=t[E],n=e.watchers.findIndex((t=>t.callback.toString()==o.callback.toString()));-1!=n?e.watchers.splice(n,1,o):e.watchers.push(o)}i.attachTo(e,n)}},getPrecedingEffectNodes(t,e){const n=[];for(let o=0;o<t.length;o++){const i=t[o],r=i.nodePosition;r>e.nodePosition||(t.splice(r,1),n.push(i))}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=y(n,e),n=n.invoke();const o=y(n,e);return o.nodePosition=t.nodePosition,o}};const j=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,((t,e)=>(e?"-":"")+t.toLowerCase()));function w(i,r){const s=function(i,r){return u(i)&&u(r)?function(i,r){const s=i.childNodes,a=r.childNodes,c=i.attributes,l=r.attributes,d={type:Object.getPrototypeOf(i).constructor,node1:i,node2:r,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],i=a[e];void 0===o?d[t].push(["childNodes",i]):void 0===i?d[n].push(["childNodes",o]):d.childDiffs.push(w(o,i))}for(let e=0;e<Math.max(c.length,l.length);e++){const o=c[e],i=l[e];void 0===o?d[t].push(["attributes",i]):void 0===i?d[n].push(["attributes",o]):d.childDiffs.push(w(o,i))}return d}(i,r):m(i)&&m(r)?function(i,r){const s=i.childNodes,a=r.childNodes,c={type:Object.getPrototypeOf(i).constructor,node1:i,node2:r,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]};for(let e=0;e<Math.max(s.length,a.length);e++){const o=s[e],i=a[e];void 0===o?c[t].push(["childNodes",i]):void 0===i?c[n].push(["childNodes",o]):c.childDiffs.push(w(o,i))}return c}(i,r):f(i)&&f(r)?function(t,e){const n=a({object:t,props:[["name"],["value"]]},{object:e,props:[["name"],["value"]]});return n}(i,r):q(i)&&q(r)?function(t,e){const n={object:t,props:[["text"]]},o={object:e,props:[["text"]]},i=a(n,o);return i}(i,r):function(i,r){const s={type:Object.getPrototypeOf(i).constructor,node1:i,node2:r,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},[a,c]=[p(i),p(r)];a&&s[t].push(["self"]);c&&s[n].push(["self"]);return a||c?s(i.jqParent):(s[e].push(["childNodes",r]),s)}(i,r)}(i,r);return s;function a(i,r){const s={type:Object.getPrototypeOf(i.object).constructor,node1:i.object,node2:r.object,[t]:[],[e]:[],[n]:[],[o]:[],childDiffs:[]},a=i.props.filter((t=>p(S(r.object,t))));s[n]=a;const c=r.props.filter((t=>p(S(i.object,t))));s[t]=c;const l=i.props.filter((t=>S(r.object,t)!==S(i.object,t)));s[e]=l;const d=i.props.filter((t=>S(r.object,t)===S(i.object,t)));return s[o]=d,s}}const x=["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"],C=Symbol("CustomElements"),T=new Proxy({},{get:(t,e)=>"symbol"==typeof e?t[e]:"globalize"==e?A:(...t)=>new JqElement(e,g(t))});function A(t){x.forEach((e=>(t??globalThis)[e]=T[e]))}const k=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)}),{}),F=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)}),L=new Proxy((function(t){throw new JqEvent(t)}),{get:(t,e)=>"symbol"==typeof e?t[e]:t=>new JqEvent(e,t)}),I=new Proxy((function(...t){const[e,...n]=t;if(1==t.length&&!h(e)){return new JqCSSRule([":host",...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[C].push(t);const n=Symbol("_JqElement"),o=class extends e{static[n]=null;constructor(t,e){super(),o[n]=JqElement.custom(this,t,g(e))}};return customElements.define(t,o),(...e)=>(new o(t,e),o[n])}),{[C]:[]}),$=new Proxy(O,{get:(t,e)=>"symbol"==typeof e?t[e]:t(j(e))});function M(...t){return new JqAnimation(...t)}function W(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==E?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 H(...t){throw new JqWatch(...t)}function R(t){throw new JqCondition(t)}function D(t){throw new JqEach(t)}function _(){throw new JqLifecycle(i)}function z(){throw new JqLifecycle(r)}function B(t){return new JqPromise(t)}const V={attr:F,text:k,fragment:function(...t){const{childNodes:e}=g(t);return new JqFragment(e)}};export{M as animate,_ as attach,I as css,$ as custom,z as detach,D as each,g as getNodes,T as natives,V as nodes,L as on,d as paths,W as state,B as wait,H as watch,R 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)}),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};
//# sourceMappingURL=jquire.min.js.map

@@ -19,8 +19,23 @@ import {

const numbersST = state(Array.from({ length: 2 }, (_, i) => i + 1))
const style = {
lineHeight: "8px"
}
const app = div(
div(
css({ color: "red", display: "flex" }),
css.backgroundColor("purple"),
css.alignItems("center"),
css("::before")({
backgroundColor: "black", display: "block", width: "100px", height: "100px", content: "''"
}),
css("a")({ textDecoration: "none", color: "yellow" }),
css("a:hover")({ color: "fuchsia" }),
"abcd",
div(
span("anshbj"),
div(
a("abcd", attr.href("#"))
)
)
),
div(
a("efgh", attr.href("#")),
(_ = watch(sidebarST)) => (_ = when(sidebarST.clicked)) =>

@@ -38,8 +53,8 @@ aside(

div(
(changed = watch(data)) => null, [✔]
(condition = when(x == y)) => null, [✔]
(event = on("click")) => null, [✔]
([item, idx] = each(data)) => null, [✔]
(event = mount()) => null, [✔]
(event = unmount()) => null, [✔]
(changed = watch(data)) => null, [✔]
(condition = when(x == y)) => null, [✔]
(event = on("click")) => null, [✔]
([item, idx] = each(data)) => null, [✔]
(event = attach()) => null, [✔]
(event = detach()) => null, [✔]
(promise = awaitable.pending) => null,

@@ -46,0 +61,0 @@ (value = awaitable.then) => null,

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