New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hydroxide-dom

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydroxide-dom - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

8

dist/dev-cjs.js

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

/* hydroxide-dom v0.7.0 */
/* hydroxide-dom v0.8.0 */
'use strict';

@@ -664,7 +664,7 @@

if (path && path.length > 1) {
const reactive = listInfo.list[path[0]].value;
const reactive = listInfo.list[path[0]].value; // immutable
if (!reactive.mutable) {
// @ts-ignore
reactive(path.slice(1)).set(value);
reactive(...path.slice(1)).set(value);
} else {

@@ -681,3 +681,3 @@ // faster path

target[lastIndex] = value;
target[path[lastIndex]] = value;
hydroxide.invalidate(reactive);

@@ -684,0 +684,0 @@ }

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

/* hydroxide-dom v0.7.0 */
/* hydroxide-dom v0.8.0 */
import { detect, valueAt, effect, CONNECTION_PHASE, coreInfo, reactive, invalidate, subscribe, LIST_PHASE, RENDER_PHASE } from 'hydroxide';

@@ -660,7 +660,7 @@

if (path && path.length > 1) {
const reactive = listInfo.list[path[0]].value;
const reactive = listInfo.list[path[0]].value; // immutable
if (!reactive.mutable) {
// @ts-ignore
reactive(path.slice(1)).set(value);
reactive(...path.slice(1)).set(value);
} else {

@@ -677,3 +677,3 @@ // faster path

target[lastIndex] = value;
target[path[lastIndex]] = value;
invalidate(reactive);

@@ -680,0 +680,0 @@ }

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("hydroxide");function t(e){return{$$list:e}}function n(n,o){const r=n(o||{});if(o&&n!==t){const[t]=e.detect((()=>{for(const e in o)o[e]}));t.size&&t.forEach((e=>{e.mutable=!1}))}return r}t.Indexed=function(e){return{$$list:e,indexed:!0}};const o=new Set;function r(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document});null!==n;){const o=n[t];if(o&&!n.disabled&&(Array.isArray(o)?o[0](o[1],e):o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Node?n.host:n.parentNode}}function c(t,n,o){const r={isConnected:!0},c=e.coreInfo.context;e.coreInfo.context=r;const s=e.reactive(t);let i;n.indexed&&(i=e.reactive(o));const l=n.props.as(s,i);r.onConnect&&r.onConnect.forEach((e=>e())),e.coreInfo.context=c;const a={el:l,value:s,context:r};return n.indexed&&(a.index=i),a}function s(e,t,n){const o=n.list.length;if(n.indexed){const o=e+t.length;o<n.dirtyIndexStart&&(n.dirtyIndexStart=o)}if(e===o||0===o)return function(e,t){const n=t.list.length;for(let o=0;o<e.length;o++){const r=c(e[o],t,n+o);t.parent.appendChild(r.el),t.list[n+o]=r}}(t,n);const r=new Array(t.length),s=n.list[e].el;for(let o=0;o<t.length;o++){const i=c(t[o],n,e+o);n.parent.insertBefore(i.el,s),r[o]=i}n.list.splice(e,0,...r)}function i(e,t,n){if(t!==n.list.length){if(n.indexed){const t=e;t<n.dirtyIndexStart&&(n.dirtyIndexStart=t)}for(let o=e;o<e+t;o++){const e=n.list[o];e.context.onDisconnect&&e.context.onDisconnect.forEach((e=>e())),e.el.remove()}n.list.splice(e,t)}else l(n)}function l(e){const t=e.list.length;for(let n=0;n<t;n++){const t=e.list[n].context;t.onDisconnect&&t.onDisconnect.forEach((e=>e()))}e.list=[],e.parent.textContent=""}const a=document.createComment("");function f(e,t,n){const o=n.list,r=o[e].el,c=o[t].el,s=o[e];o[e]=o[t],o[t]=s,c.replaceWith(a),r.replaceWith(c),a.replaceWith(r),n.indexed&&(o[e].index.set(e),o[t].index.set(t))}function u(e){const t=e.currentValue,n=function(e,t){const n=[];if(0===e.length)return n.push({indexes:[0,t.length-1],insertAt:0}),n;if(0===t.length)return n.push({clear:!0}),n;let o,r=e.length-1,c=t.length-1,s=0,i=0,l=0;for(;s<=r||i<=c;){if(s>r){n.push({insertAt:i,indexes:i===c?[i]:[i,c]});break}if(i>c){s<=r&&(n.push({removeAt:s-l,count:r-s+1}),l++);break}if(e[s]===t[i])s++,i++;else if(e[r]===t[c])r--,c--;else if(e[s]===t[c]&&t[i]===e[r])n.push({swap:[s,r]}),s++,i++,r--,c--;else if(s+1<=r&&e[s]===t[i+1]&&e[s+1]===t[i])n.push({swap:[s,s+1]}),s+=2,i+=2;else if(s+1<=r&&e[r]===t[c-1]&&e[r-1]===t[c])n.push({swap:[r,r-1]}),r-=2,c-=2;else{if(!o){o=new Map;for(let e=i;e<=c;e++)o.set(t[e],e)}if(o.has(e[s])){const t=o.get(e[s]);if(i<=t&&t<=c){let a=1;for(let n=s+1;n<=r&&n<=c&&o.get(e[n])===t+a;n++)a++;if(t-i<a){const e=t-1;n.push({indexes:i===e?[i]:[i,e],insertAt:i}),i=t}else n.push({replace:[s-l,i]}),i++,s++}else s++}else{const e=n[n.length-1];n.length>0&&"removeAt"in e&&e.removeAt+e.count===s?e.count++:n.push({removeAt:s-l,count:1}),l++,s++}}}return n}(e.prevValue,t);for(let o=0;o<n.length;o++){const r=n[o];if("removeAt"in r)i(r.removeAt,r.count,e);else if("insertAt"in r){const[n,o=n]=r.indexes,c=[];for(let e=n;e<=o;e++)c.push(t[e]);s(r.insertAt,c,e)}else if("swap"in r){const[t,n]=r.swap;f(t,n,e)}else if("replace"in r){const[t,n]=r.replace,o=e.list[t].value,c=e.currentValue[n];o.set(c)}else"clear"in r&&l(e)}}function d(t,n,o=!1){const r=t.parentElement;t.remove();const c={indexed:o,context:e.coreInfo.context,props:n,parent:r,prevValue:[],currentValue:[],list:[]};o&&(c.dirtyIndexStart=1/0);const[a,d]=e.detect((()=>n.each));if(c.prevValue=d,s(0,d,c),0===a.size)return;let p,h=!0;if(1===a.size){p=a.values().next().value;h=p()!==d,h&&(p.mutable=!1)}if(h){function x(){c.currentValue=n.each,u(c),c.prevValue=c.currentValue}e.subscribe(p,x,e.CONNECTION_PHASE)}else{const b=(t,o,r)=>{switch(c.currentValue=n.each,t){case"insert":s(o,r,c);break;case"remove":i(o,r,c);break;case"swap":f(o,r,c);break;case"clear":l(c);break;case"set":!function(t,n,o){if(t&&t.length>1){const r=o.list[t[0]].value;if(r.mutable){let o=r.value;const c=t.length-1;for(let e=1;e<c;e++)o=o[t[e]];o[c]=n,e.invalidate(r)}else r(t.slice(1)).set(n)}else u(o)}(o,r,c)}c.prevValue=c.currentValue};e.subscribe(p,b,e.LIST_PHASE),o&&e.subscribe(p,(()=>{if(c.dirtyIndexStart!==1/0){const e=c.dirtyIndexStart,t=c.list,n=t.length;for(let o=e;o<n;o++)t[o].index.set(o);c.dirtyIndexStart=1/0}}),e.RENDER_PHASE)}}function p(e){const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild}exports.ErrorBoundary=function(e){try{return e.children}catch(t){return e.fallback||"Error"}},exports.List=t,exports.bind=function(t,n,o){let r,c;"reactive"in o?(r=o.reactive,c=o.path):r=o;const s=typeof(c?e.valueAt(r.value,c):r.value);t.$$input=e=>{let t=e.target[n];"number"===s&&(t=Number(t)),o.set(t)},e.effect((()=>{t[n]=c?e.valueAt(r(),c):r()}))},exports.branch=function(...t){let n,o,r;const c=[],s=[];function i(e,t){o?(o.onDisconnect&&o.onDisconnect.forEach((e=>e())),r.replaceWith(t)):n.replaceWith(t),o=e,r=t,e.onConnect&&e.onConnect.forEach((e=>e()))}function l(){let l=-1;for(let e=0;e<t.length;e++)if(t[e][0]()){l=e;break}e.coreInfo.detectorEnabled=!1,-1===l?o&&r&&(o.onDisconnect&&o.onDisconnect.forEach((e=>e())),r.replaceWith(n),o=void 0,r=void 0):function(n){if(!o||o!==c[n])if(c[n])i(c[n],s[n]);else{const o=e.coreInfo.context;e.coreInfo.context=c[n]={isConnected:!0},s[n]=t[n][1](),e.coreInfo.context=o,i(c[n],s[n])}}(l)}return{$$branch:t=>{n=t,e.effect(l,e.CONNECTION_PHASE)}}},exports.component=n,exports.delegateEvents=function(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];o.has(n)||(o.add(n),document.addEventListener(n,r))}},exports.insert=function t(n,o){if(o instanceof Node)n.replaceWith(o);else if("function"==typeof o){const[r,c]=e.detect(o);if(r.size){const s=document.createTextNode(c+"");function i(){const e=o();s.textContent=e}e.coreInfo.context,s.textContent=c,r.forEach((t=>{e.subscribe(t,i,e.RENDER_PHASE)})),n.replaceWith(s)}else"object"==typeof c?t(n,c):n.replaceWith(c+"")}else if(Array.isArray(o))o.forEach((t=>{if("function"==typeof t){const[o,r]=e.detect(t);if(r instanceof Node)n.before(r);else if(o.size){const c=document.createTextNode(r+"");function s(){c.textContent=t()}o.forEach((t=>{e.subscribe(t,s,e.RENDER_PHASE)}))}}else n.before(t)})),n.remove();else{if(o&&o.$$list)return d(n,o.$$list,o.indexed);if(o&&o.$$branch)return o.$$branch(n);{const l=document.createTextNode(o+"");n.replaceWith(l)}}},exports.render=function(t,o){e.coreInfo.context={isConnected:!0};const r=n(t);o.appendChild(r),e.coreInfo.context.onConnect&&e.coreInfo.context.onConnect.forEach((e=>e())),e.coreInfo.context=null},exports.setAttribute=function(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)},exports.svg=function(e){return p(`<svg>${e}</svg>`).firstChild},exports.template=p;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("hydroxide");function t(e){return{$$list:e}}function n(n,o){const r=n(o||{});if(o&&n!==t){const[t]=e.detect((()=>{for(const e in o)o[e]}));t.size&&t.forEach((e=>{e.mutable=!1}))}return r}t.Indexed=function(e){return{$$list:e,indexed:!0}};const o=new Set;function r(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document});null!==n;){const o=n[t];if(o&&!n.disabled&&(Array.isArray(o)?o[0](o[1],e):o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Node?n.host:n.parentNode}}function c(t,n,o){const r={isConnected:!0},c=e.coreInfo.context;e.coreInfo.context=r;const s=e.reactive(t);let i;n.indexed&&(i=e.reactive(o));const l=n.props.as(s,i);r.onConnect&&r.onConnect.forEach((e=>e())),e.coreInfo.context=c;const a={el:l,value:s,context:r};return n.indexed&&(a.index=i),a}function s(e,t,n){const o=n.list.length;if(n.indexed){const o=e+t.length;o<n.dirtyIndexStart&&(n.dirtyIndexStart=o)}if(e===o||0===o)return function(e,t){const n=t.list.length;for(let o=0;o<e.length;o++){const r=c(e[o],t,n+o);t.parent.appendChild(r.el),t.list[n+o]=r}}(t,n);const r=new Array(t.length),s=n.list[e].el;for(let o=0;o<t.length;o++){const i=c(t[o],n,e+o);n.parent.insertBefore(i.el,s),r[o]=i}n.list.splice(e,0,...r)}function i(e,t,n){if(t!==n.list.length){if(n.indexed){const t=e;t<n.dirtyIndexStart&&(n.dirtyIndexStart=t)}for(let o=e;o<e+t;o++){const e=n.list[o];e.context.onDisconnect&&e.context.onDisconnect.forEach((e=>e())),e.el.remove()}n.list.splice(e,t)}else l(n)}function l(e){const t=e.list.length;for(let n=0;n<t;n++){const t=e.list[n].context;t.onDisconnect&&t.onDisconnect.forEach((e=>e()))}e.list=[],e.parent.textContent=""}const a=document.createComment("");function f(e,t,n){const o=n.list,r=o[e].el,c=o[t].el,s=o[e];o[e]=o[t],o[t]=s,c.replaceWith(a),r.replaceWith(c),a.replaceWith(r),n.indexed&&(o[e].index.set(e),o[t].index.set(t))}function u(e){const t=e.currentValue,n=function(e,t){const n=[];if(0===e.length)return n.push({indexes:[0,t.length-1],insertAt:0}),n;if(0===t.length)return n.push({clear:!0}),n;let o,r=e.length-1,c=t.length-1,s=0,i=0,l=0;for(;s<=r||i<=c;){if(s>r){n.push({insertAt:i,indexes:i===c?[i]:[i,c]});break}if(i>c){s<=r&&(n.push({removeAt:s-l,count:r-s+1}),l++);break}if(e[s]===t[i])s++,i++;else if(e[r]===t[c])r--,c--;else if(e[s]===t[c]&&t[i]===e[r])n.push({swap:[s,r]}),s++,i++,r--,c--;else if(s+1<=r&&e[s]===t[i+1]&&e[s+1]===t[i])n.push({swap:[s,s+1]}),s+=2,i+=2;else if(s+1<=r&&e[r]===t[c-1]&&e[r-1]===t[c])n.push({swap:[r,r-1]}),r-=2,c-=2;else{if(!o){o=new Map;for(let e=i;e<=c;e++)o.set(t[e],e)}if(o.has(e[s])){const t=o.get(e[s]);if(i<=t&&t<=c){let a=1;for(let n=s+1;n<=r&&n<=c&&o.get(e[n])===t+a;n++)a++;if(t-i<a){const e=t-1;n.push({indexes:i===e?[i]:[i,e],insertAt:i}),i=t}else n.push({replace:[s-l,i]}),i++,s++}else s++}else{const e=n[n.length-1];n.length>0&&"removeAt"in e&&e.removeAt+e.count===s?e.count++:n.push({removeAt:s-l,count:1}),l++,s++}}}return n}(e.prevValue,t);for(let o=0;o<n.length;o++){const r=n[o];if("removeAt"in r)i(r.removeAt,r.count,e);else if("insertAt"in r){const[n,o=n]=r.indexes,c=[];for(let e=n;e<=o;e++)c.push(t[e]);s(r.insertAt,c,e)}else if("swap"in r){const[t,n]=r.swap;f(t,n,e)}else if("replace"in r){const[t,n]=r.replace,o=e.list[t].value,c=e.currentValue[n];o.set(c)}else"clear"in r&&l(e)}}function d(t,n,o=!1){const r=t.parentElement;t.remove();const c={indexed:o,context:e.coreInfo.context,props:n,parent:r,prevValue:[],currentValue:[],list:[]};o&&(c.dirtyIndexStart=1/0);const[a,d]=e.detect((()=>n.each));if(c.prevValue=d,s(0,d,c),0===a.size)return;let p,h=!0;if(1===a.size){p=a.values().next().value;h=p()!==d,h&&(p.mutable=!1)}if(h){function x(){c.currentValue=n.each,u(c),c.prevValue=c.currentValue}e.subscribe(p,x,e.CONNECTION_PHASE)}else{const b=(t,o,r)=>{switch(c.currentValue=n.each,t){case"insert":s(o,r,c);break;case"remove":i(o,r,c);break;case"swap":f(o,r,c);break;case"clear":l(c);break;case"set":!function(t,n,o){if(t&&t.length>1){const r=o.list[t[0]].value;if(r.mutable){let o=r.value;const c=t.length-1;for(let e=1;e<c;e++)o=o[t[e]];o[t[c]]=n,e.invalidate(r)}else r(...t.slice(1)).set(n)}else u(o)}(o,r,c)}c.prevValue=c.currentValue};e.subscribe(p,b,e.LIST_PHASE),o&&e.subscribe(p,(()=>{if(c.dirtyIndexStart!==1/0){const e=c.dirtyIndexStart,t=c.list,n=t.length;for(let o=e;o<n;o++)t[o].index.set(o);c.dirtyIndexStart=1/0}}),e.RENDER_PHASE)}}function p(e){const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild}exports.ErrorBoundary=function(e){try{return e.children}catch(t){return e.fallback||"Error"}},exports.List=t,exports.bind=function(t,n,o){let r,c;"reactive"in o?(r=o.reactive,c=o.path):r=o;const s=typeof(c?e.valueAt(r.value,c):r.value);t.$$input=e=>{let t=e.target[n];"number"===s&&(t=Number(t)),o.set(t)},e.effect((()=>{t[n]=c?e.valueAt(r(),c):r()}))},exports.branch=function(...t){let n,o,r;const c=[],s=[];function i(e,t){o?(o.onDisconnect&&o.onDisconnect.forEach((e=>e())),r.replaceWith(t)):n.replaceWith(t),o=e,r=t,e.onConnect&&e.onConnect.forEach((e=>e()))}function l(){let l=-1;for(let e=0;e<t.length;e++)if(t[e][0]()){l=e;break}e.coreInfo.detectorEnabled=!1,-1===l?o&&r&&(o.onDisconnect&&o.onDisconnect.forEach((e=>e())),r.replaceWith(n),o=void 0,r=void 0):function(n){if(!o||o!==c[n])if(c[n])i(c[n],s[n]);else{const o=e.coreInfo.context;e.coreInfo.context=c[n]={isConnected:!0},s[n]=t[n][1](),e.coreInfo.context=o,i(c[n],s[n])}}(l)}return{$$branch:t=>{n=t,e.effect(l,e.CONNECTION_PHASE)}}},exports.component=n,exports.delegateEvents=function(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];o.has(n)||(o.add(n),document.addEventListener(n,r))}},exports.insert=function t(n,o){if(o instanceof Node)n.replaceWith(o);else if("function"==typeof o){const[r,c]=e.detect(o);if(r.size){const s=document.createTextNode(c+"");function i(){const e=o();s.textContent=e}e.coreInfo.context,s.textContent=c,r.forEach((t=>{e.subscribe(t,i,e.RENDER_PHASE)})),n.replaceWith(s)}else"object"==typeof c?t(n,c):n.replaceWith(c+"")}else if(Array.isArray(o))o.forEach((t=>{if("function"==typeof t){const[o,r]=e.detect(t);if(r instanceof Node)n.before(r);else if(o.size){const c=document.createTextNode(r+"");function s(){c.textContent=t()}o.forEach((t=>{e.subscribe(t,s,e.RENDER_PHASE)}))}}else n.before(t)})),n.remove();else{if(o&&o.$$list)return d(n,o.$$list,o.indexed);if(o&&o.$$branch)return o.$$branch(n);{const l=document.createTextNode(o+"");n.replaceWith(l)}}},exports.render=function(t,o){e.coreInfo.context={isConnected:!0};const r=n(t);o.appendChild(r),e.coreInfo.context.onConnect&&e.coreInfo.context.onConnect.forEach((e=>e())),e.coreInfo.context=null},exports.setAttribute=function(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)},exports.svg=function(e){return p(`<svg>${e}</svg>`).firstChild},exports.template=p;

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

import{detect as e,valueAt as t,effect as n,CONNECTION_PHASE as o,coreInfo as c,reactive as r,invalidate as i,subscribe as s,LIST_PHASE as l,RENDER_PHASE as a}from"hydroxide";function f(e){return{$$list:e}}function u(t,n){const o=t(n||{});if(n&&t!==f){const[t]=e((()=>{for(const e in n)n[e]}));t.size&&t.forEach((e=>{e.mutable=!1}))}return o}function d(e){try{return e.children}catch(t){return e.fallback||"Error"}}function h(e,o,c){let r,i;"reactive"in c?(r=c.reactive,i=c.path):r=c;const s=typeof(i?t(r.value,i):r.value);e.$$input=e=>{let t=e.target[o];"number"===s&&(t=Number(t)),c.set(t)},n((()=>{e[o]=i?t(r(),i):r()}))}function p(...e){let t,r,i;const s=[],l=[];function a(e,n){r?(r.onDisconnect&&r.onDisconnect.forEach((e=>e())),i.replaceWith(n)):t.replaceWith(n),r=e,i=n,e.onConnect&&e.onConnect.forEach((e=>e()))}function f(){let n=-1;for(let t=0;t<e.length;t++)if(e[t][0]()){n=t;break}c.detectorEnabled=!1,-1===n?r&&i&&(r.onDisconnect&&r.onDisconnect.forEach((e=>e())),i.replaceWith(t),r=void 0,i=void 0):function(t){if(!r||r!==s[t])if(s[t])a(s[t],l[t]);else{const n=c.context;c.context=s[t]={isConnected:!0},l[t]=e[t][1](),c.context=n,a(s[t],l[t])}}(n)}return{$$branch:e=>{t=e,n(f,o)}}}f.Indexed=function(e){return{$$list:e,indexed:!0}};const x=new Set;function g(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];x.has(n)||(x.add(n),document.addEventListener(n,m))}}function m(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document});null!==n;){const o=n[t];if(o&&!n.disabled&&(Array.isArray(o)?o[0](o[1],e):o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Node?n.host:n.parentNode}}function v(e,t,n){const o={isConnected:!0},i=c.context;c.context=o;const s=r(e);let l;t.indexed&&(l=r(n));const a=t.props.as(s,l);o.onConnect&&o.onConnect.forEach((e=>e())),c.context=i;const f={el:a,value:s,context:o};return t.indexed&&(f.index=l),f}function b(e,t,n){const o=n.list.length;if(n.indexed){const o=e+t.length;o<n.dirtyIndexStart&&(n.dirtyIndexStart=o)}if(e===o||0===o)return function(e,t){const n=t.list.length;for(let o=0;o<e.length;o++){const c=v(e[o],t,n+o);t.parent.appendChild(c.el),t.list[n+o]=c}}(t,n);const c=new Array(t.length),r=n.list[e].el;for(let o=0;o<t.length;o++){const i=v(t[o],n,e+o);n.parent.insertBefore(i.el,r),c[o]=i}n.list.splice(e,0,...c)}function y(e,t,n){if(t!==n.list.length){if(n.indexed){const t=e;t<n.dirtyIndexStart&&(n.dirtyIndexStart=t)}for(let o=e;o<e+t;o++){const e=n.list[o];e.context.onDisconnect&&e.context.onDisconnect.forEach((e=>e())),e.el.remove()}n.list.splice(e,t)}else $(n)}function $(e){const t=e.list.length;for(let n=0;n<t;n++){const t=e.list[n].context;t.onDisconnect&&t.onDisconnect.forEach((e=>e()))}e.list=[],e.parent.textContent=""}const A=document.createComment("");function C(e,t,n){const o=n.list,c=o[e].el,r=o[t].el,i=o[e];o[e]=o[t],o[t]=i,r.replaceWith(A),c.replaceWith(r),A.replaceWith(c),n.indexed&&(o[e].index.set(e),o[t].index.set(t))}function E(e){const t=e.currentValue,n=function(e,t){const n=[];if(0===e.length)return n.push({indexes:[0,t.length-1],insertAt:0}),n;if(0===t.length)return n.push({clear:!0}),n;let o,c=e.length-1,r=t.length-1,i=0,s=0,l=0;for(;i<=c||s<=r;){if(i>c){n.push({insertAt:s,indexes:s===r?[s]:[s,r]});break}if(s>r){i<=c&&(n.push({removeAt:i-l,count:c-i+1}),l++);break}if(e[i]===t[s])i++,s++;else if(e[c]===t[r])c--,r--;else if(e[i]===t[r]&&t[s]===e[c])n.push({swap:[i,c]}),i++,s++,c--,r--;else if(i+1<=c&&e[i]===t[s+1]&&e[i+1]===t[s])n.push({swap:[i,i+1]}),i+=2,s+=2;else if(i+1<=c&&e[c]===t[r-1]&&e[c-1]===t[r])n.push({swap:[c,c-1]}),c-=2,r-=2;else{if(!o){o=new Map;for(let e=s;e<=r;e++)o.set(t[e],e)}if(o.has(e[i])){const t=o.get(e[i]);if(s<=t&&t<=r){let a=1;for(let n=i+1;n<=c&&n<=r&&o.get(e[n])===t+a;n++)a++;if(t-s<a){const e=t-1;n.push({indexes:s===e?[s]:[s,e],insertAt:s}),s=t}else n.push({replace:[i-l,s]}),s++,i++}else i++}else{const e=n[n.length-1];n.length>0&&"removeAt"in e&&e.removeAt+e.count===i?e.count++:n.push({removeAt:i-l,count:1}),l++,i++}}}return n}(e.prevValue,t);for(let o=0;o<n.length;o++){const c=n[o];if("removeAt"in c)y(c.removeAt,c.count,e);else if("insertAt"in c){const[n,o=n]=c.indexes,r=[];for(let e=n;e<=o;e++)r.push(t[e]);b(c.insertAt,r,e)}else if("swap"in c){const[t,n]=c.swap;C(t,n,e)}else if("replace"in c){const[t,n]=c.replace,o=e.list[t].value,r=e.currentValue[n];o.set(r)}else"clear"in c&&$(e)}}function V(t,n,r=!1){const f=t.parentElement;t.remove();const u={indexed:r,context:c.context,props:n,parent:f,prevValue:[],currentValue:[],list:[]};r&&(u.dirtyIndexStart=1/0);const[d,h]=e((()=>n.each));if(u.prevValue=h,b(0,h,u),0===d.size)return;let p,x=!0;if(1===d.size){p=d.values().next().value;x=p()!==h,x&&(p.mutable=!1)}if(x){s(p,(function(){u.currentValue=n.each,E(u),u.prevValue=u.currentValue}),o)}else{const e=(e,t,o)=>{switch(u.currentValue=n.each,e){case"insert":b(t,o,u);break;case"remove":y(t,o,u);break;case"swap":C(t,o,u);break;case"clear":$(u);break;case"set":!function(e,t,n){if(e&&e.length>1){const o=n.list[e[0]].value;if(o.mutable){let n=o.value;const c=e.length-1;for(let t=1;t<c;t++)n=n[e[t]];n[c]=t,i(o)}else o(e.slice(1)).set(t)}else E(n)}(t,o,u)}u.prevValue=u.currentValue};s(p,e,l),r&&s(p,(()=>{if(u.dirtyIndexStart!==1/0){const e=u.dirtyIndexStart,t=u.list,n=t.length;for(let o=e;o<n;o++)t[o].index.set(o);u.dirtyIndexStart=1/0}}),a)}}function w(t,n){if(n instanceof Node)t.replaceWith(n);else if("function"==typeof n){const[r,i]=e(n);if(r.size){const l=document.createTextNode(i+"");function o(){const e=n();l.textContent=e}c.context,l.textContent=i,r.forEach((e=>{s(e,o,a)})),t.replaceWith(l)}else"object"==typeof i?w(t,i):t.replaceWith(i+"")}else if(Array.isArray(n))n.forEach((n=>{if("function"==typeof n){const[c,r]=e(n);if(r instanceof Node)t.before(r);else if(c.size){const i=document.createTextNode(r+"");function o(){i.textContent=n()}c.forEach((e=>{s(e,o,a)}))}}else t.before(n)})),t.remove();else{if(n&&n.$$list)return V(t,n.$$list,n.indexed);if(n&&n.$$branch)return n.$$branch(t);{const f=document.createTextNode(n+"");t.replaceWith(f)}}}function W(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)}function I(e,t){c.context={isConnected:!0};const n=u(e);t.appendChild(n),c.context.onConnect&&c.context.onConnect.forEach((e=>e())),c.context=null}function S(e){const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild}function k(e){return S(`<svg>${e}</svg>`).firstChild}export{d as ErrorBoundary,f as List,h as bind,p as branch,u as component,g as delegateEvents,w as insert,I as render,W as setAttribute,k as svg,S as template};
import{detect as e,valueAt as t,effect as n,CONNECTION_PHASE as o,coreInfo as c,reactive as r,invalidate as i,subscribe as s,LIST_PHASE as l,RENDER_PHASE as a}from"hydroxide";function f(e){return{$$list:e}}function u(t,n){const o=t(n||{});if(n&&t!==f){const[t]=e((()=>{for(const e in n)n[e]}));t.size&&t.forEach((e=>{e.mutable=!1}))}return o}function d(e){try{return e.children}catch(t){return e.fallback||"Error"}}function h(e,o,c){let r,i;"reactive"in c?(r=c.reactive,i=c.path):r=c;const s=typeof(i?t(r.value,i):r.value);e.$$input=e=>{let t=e.target[o];"number"===s&&(t=Number(t)),c.set(t)},n((()=>{e[o]=i?t(r(),i):r()}))}function p(...e){let t,r,i;const s=[],l=[];function a(e,n){r?(r.onDisconnect&&r.onDisconnect.forEach((e=>e())),i.replaceWith(n)):t.replaceWith(n),r=e,i=n,e.onConnect&&e.onConnect.forEach((e=>e()))}function f(){let n=-1;for(let t=0;t<e.length;t++)if(e[t][0]()){n=t;break}c.detectorEnabled=!1,-1===n?r&&i&&(r.onDisconnect&&r.onDisconnect.forEach((e=>e())),i.replaceWith(t),r=void 0,i=void 0):function(t){if(!r||r!==s[t])if(s[t])a(s[t],l[t]);else{const n=c.context;c.context=s[t]={isConnected:!0},l[t]=e[t][1](),c.context=n,a(s[t],l[t])}}(n)}return{$$branch:e=>{t=e,n(f,o)}}}f.Indexed=function(e){return{$$list:e,indexed:!0}};const x=new Set;function g(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];x.has(n)||(x.add(n),document.addEventListener(n,m))}}function m(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get:()=>n||document});null!==n;){const o=n[t];if(o&&!n.disabled&&(Array.isArray(o)?o[0](o[1],e):o(e),e.cancelBubble))return;n=n.host&&n.host!==n&&n.host instanceof Node?n.host:n.parentNode}}function v(e,t,n){const o={isConnected:!0},i=c.context;c.context=o;const s=r(e);let l;t.indexed&&(l=r(n));const a=t.props.as(s,l);o.onConnect&&o.onConnect.forEach((e=>e())),c.context=i;const f={el:a,value:s,context:o};return t.indexed&&(f.index=l),f}function b(e,t,n){const o=n.list.length;if(n.indexed){const o=e+t.length;o<n.dirtyIndexStart&&(n.dirtyIndexStart=o)}if(e===o||0===o)return function(e,t){const n=t.list.length;for(let o=0;o<e.length;o++){const c=v(e[o],t,n+o);t.parent.appendChild(c.el),t.list[n+o]=c}}(t,n);const c=new Array(t.length),r=n.list[e].el;for(let o=0;o<t.length;o++){const i=v(t[o],n,e+o);n.parent.insertBefore(i.el,r),c[o]=i}n.list.splice(e,0,...c)}function y(e,t,n){if(t!==n.list.length){if(n.indexed){const t=e;t<n.dirtyIndexStart&&(n.dirtyIndexStart=t)}for(let o=e;o<e+t;o++){const e=n.list[o];e.context.onDisconnect&&e.context.onDisconnect.forEach((e=>e())),e.el.remove()}n.list.splice(e,t)}else $(n)}function $(e){const t=e.list.length;for(let n=0;n<t;n++){const t=e.list[n].context;t.onDisconnect&&t.onDisconnect.forEach((e=>e()))}e.list=[],e.parent.textContent=""}const A=document.createComment("");function C(e,t,n){const o=n.list,c=o[e].el,r=o[t].el,i=o[e];o[e]=o[t],o[t]=i,r.replaceWith(A),c.replaceWith(r),A.replaceWith(c),n.indexed&&(o[e].index.set(e),o[t].index.set(t))}function E(e){const t=e.currentValue,n=function(e,t){const n=[];if(0===e.length)return n.push({indexes:[0,t.length-1],insertAt:0}),n;if(0===t.length)return n.push({clear:!0}),n;let o,c=e.length-1,r=t.length-1,i=0,s=0,l=0;for(;i<=c||s<=r;){if(i>c){n.push({insertAt:s,indexes:s===r?[s]:[s,r]});break}if(s>r){i<=c&&(n.push({removeAt:i-l,count:c-i+1}),l++);break}if(e[i]===t[s])i++,s++;else if(e[c]===t[r])c--,r--;else if(e[i]===t[r]&&t[s]===e[c])n.push({swap:[i,c]}),i++,s++,c--,r--;else if(i+1<=c&&e[i]===t[s+1]&&e[i+1]===t[s])n.push({swap:[i,i+1]}),i+=2,s+=2;else if(i+1<=c&&e[c]===t[r-1]&&e[c-1]===t[r])n.push({swap:[c,c-1]}),c-=2,r-=2;else{if(!o){o=new Map;for(let e=s;e<=r;e++)o.set(t[e],e)}if(o.has(e[i])){const t=o.get(e[i]);if(s<=t&&t<=r){let a=1;for(let n=i+1;n<=c&&n<=r&&o.get(e[n])===t+a;n++)a++;if(t-s<a){const e=t-1;n.push({indexes:s===e?[s]:[s,e],insertAt:s}),s=t}else n.push({replace:[i-l,s]}),s++,i++}else i++}else{const e=n[n.length-1];n.length>0&&"removeAt"in e&&e.removeAt+e.count===i?e.count++:n.push({removeAt:i-l,count:1}),l++,i++}}}return n}(e.prevValue,t);for(let o=0;o<n.length;o++){const c=n[o];if("removeAt"in c)y(c.removeAt,c.count,e);else if("insertAt"in c){const[n,o=n]=c.indexes,r=[];for(let e=n;e<=o;e++)r.push(t[e]);b(c.insertAt,r,e)}else if("swap"in c){const[t,n]=c.swap;C(t,n,e)}else if("replace"in c){const[t,n]=c.replace,o=e.list[t].value,r=e.currentValue[n];o.set(r)}else"clear"in c&&$(e)}}function V(t,n,r=!1){const f=t.parentElement;t.remove();const u={indexed:r,context:c.context,props:n,parent:f,prevValue:[],currentValue:[],list:[]};r&&(u.dirtyIndexStart=1/0);const[d,h]=e((()=>n.each));if(u.prevValue=h,b(0,h,u),0===d.size)return;let p,x=!0;if(1===d.size){p=d.values().next().value;x=p()!==h,x&&(p.mutable=!1)}if(x){s(p,(function(){u.currentValue=n.each,E(u),u.prevValue=u.currentValue}),o)}else{const e=(e,t,o)=>{switch(u.currentValue=n.each,e){case"insert":b(t,o,u);break;case"remove":y(t,o,u);break;case"swap":C(t,o,u);break;case"clear":$(u);break;case"set":!function(e,t,n){if(e&&e.length>1){const o=n.list[e[0]].value;if(o.mutable){let n=o.value;const c=e.length-1;for(let t=1;t<c;t++)n=n[e[t]];n[e[c]]=t,i(o)}else o(...e.slice(1)).set(t)}else E(n)}(t,o,u)}u.prevValue=u.currentValue};s(p,e,l),r&&s(p,(()=>{if(u.dirtyIndexStart!==1/0){const e=u.dirtyIndexStart,t=u.list,n=t.length;for(let o=e;o<n;o++)t[o].index.set(o);u.dirtyIndexStart=1/0}}),a)}}function w(t,n){if(n instanceof Node)t.replaceWith(n);else if("function"==typeof n){const[r,i]=e(n);if(r.size){const l=document.createTextNode(i+"");function o(){const e=n();l.textContent=e}c.context,l.textContent=i,r.forEach((e=>{s(e,o,a)})),t.replaceWith(l)}else"object"==typeof i?w(t,i):t.replaceWith(i+"")}else if(Array.isArray(n))n.forEach((n=>{if("function"==typeof n){const[c,r]=e(n);if(r instanceof Node)t.before(r);else if(c.size){const i=document.createTextNode(r+"");function o(){i.textContent=n()}c.forEach((e=>{s(e,o,a)}))}}else t.before(n)})),t.remove();else{if(n&&n.$$list)return V(t,n.$$list,n.indexed);if(n&&n.$$branch)return n.$$branch(t);{const f=document.createTextNode(n+"");t.replaceWith(f)}}}function W(e,t,n){n?e.setAttribute(t,n):e.removeAttribute(t)}function I(e,t){c.context={isConnected:!0};const n=u(e);t.appendChild(n),c.context.onConnect&&c.context.onConnect.forEach((e=>e())),c.context=null}function S(e){const t=document.createElement("template");return t.innerHTML=e,t.content.firstChild}function k(e){return S(`<svg>${e}</svg>`).firstChild}export{d as ErrorBoundary,f as List,h as bind,p as branch,u as component,g as delegateEvents,w as insert,I as render,W as setAttribute,k as svg,S as template};
{
"name": "hydroxide-dom",
"description": "Client side renderer for Hydroxide Framework",
"version": "0.7.0",
"version": "0.8.0",
"author": "Manan Tank",

@@ -6,0 +6,0 @@ "license": "MIT",

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