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

data-tier-list

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-tier-list - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

dist/data-tier-list.js

@@ -29,3 +29,3 @@ import { ties } from './data-tier/data-tier.min.js';

connectedCallback() {
this.setAttribute('hidden', '');
this.hidden = true;
this[TEMPLATE_PROCESSOR_KEY]();

@@ -32,0 +32,0 @@ }

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

import{ties}from"./data-tier/data-tier.min.js";import{Observable}from"./data-tier/object-observer.min.js";const DATA_TIER_LIST="data-tier-list",SELF_TEMPLATE='<slot id="template"></slot>',ITEM_KEY=Symbol("item.key"),ITEMS_KEY=Symbol("items.key"),TEMPLATE_KEY=Symbol("template"),OBSERVER_KEY=Symbol("observer"),FULL_UPDATER_KEY=Symbol("full.updater"),PART_UPDATER_KEY=Symbol("part.updater"),CONTAINER_RESOLVER_KEY=Symbol("container.resolver"),TEMPLATE_PROCESSOR_KEY=Symbol("template.processor");class DataTierList extends HTMLElement{constructor(){super(),this[ITEMS_KEY]=null,this[TEMPLATE_KEY]=null,this[OBSERVER_KEY]=this[OBSERVER_KEY].bind(this),this.attachShadow({mode:"open"}).innerHTML=SELF_TEMPLATE,this.shadowRoot.querySelector("#template").addEventListener("slotchange",()=>this[TEMPLATE_PROCESSOR_KEY]())}connectedCallback(){this.setAttribute("hidden",""),this[TEMPLATE_PROCESSOR_KEY]()}get defaultTieTarget(){return"items"}set items(e){this[ITEMS_KEY]!==e&&(null===e||""===e?this[ITEMS_KEY]&&(this[ITEMS_KEY].unobserve(this[OBSERVER_KEY]),this[ITEMS_KEY]=null,this[FULL_UPDATER_KEY]()):"object"==typeof e?(this[ITEMS_KEY]&&this[ITEMS_KEY].unobserve(this[OBSERVER_KEY]),this[ITEMS_KEY]=Observable.from(e),this[ITEMS_KEY].observe(this[OBSERVER_KEY],{pathsOf:""}),this[FULL_UPDATER_KEY]()):console.error(`items MAY ONLY be set to an object, got '${e}'`))}get items(){return this[ITEMS_KEY]}[CONTAINER_RESOLVER_KEY](){let e;const t=this.getAttribute("data-list-target");if(t){if(!(e=this.getRootNode().querySelector(t)))throw new Error(`failed to resolve target container by the given query '${t}'`)}else e=this.parentNode;return e}[TEMPLATE_PROCESSOR_KEY](){const e=this.children;let t=null;1===e.length?(t=e[0].outerHTML,e[0]!==this.__currentTemplate&&(this.__currentTemplate&&ties.remove(this.__currentTemplate),ties.create(e[0]),this.__currentTemplate=e[0],this[TEMPLATE_KEY]=t,this[FULL_UPDATER_KEY]())):console.error(`list item template MAY have 1 root element only, got ${e.length}`)}[OBSERVER_KEY](e){for(const t of e)"shuffle"===t.type||"reverse"===t.type?this[FULL_UPDATER_KEY]():this[PART_UPDATER_KEY](t)}[FULL_UPDATER_KEY](){if(!this[TEMPLATE_KEY]||!this.items)return;const e=this[CONTAINER_RESOLVER_KEY](),t=e.contains(this)?1:0,i=Object.keys(this.items),s=i.length;let E,r=e.childElementCount-t;for(;r>s;)(E=e.lastElementChild)!==this&&E.remove(),r--;let n="";for(;r<s;)n+=this[TEMPLATE_KEY],r++;if(n){const t=document.createElement("template");t.innerHTML=n,e.appendChild(t.content)}for(let s=t,E=e.children.length;s<E;s++){const E=e.children[s];E[ITEM_KEY]=i[s-t],ties.update(E,this.items[i[s-t]])}}[PART_UPDATER_KEY](e){if(!this[TEMPLATE_KEY]||!this.items)return;const t=this[CONTAINER_RESOLVER_KEY](),i=t.contains(this)?1:0,s=document.createElement("template");if(!(e.path.length>1))if(Array.isArray(this.items)){const n=parseInt(e.path[0],10);if("insert"===e.type)s.innerHTML=this[TEMPLATE_KEY],ties.create(s.content.firstElementChild,e.value),t.insertBefore(s.content,t.children[n+i]);else if("update"===e.type)ties.update(t.children[n+i],e.value);else if("delete"===e.type)t.removeChild(t.children[n+i]);else if("reverse"===e.type)for(var E=i+1,r=t.children.length-i/2;E<r;E++)t.insertBefore(t.children[E],t.children[E-1]);else console.warn(`unsupported change type ${e.type}`)}else{const E=Object.keys(this.items).indexOf(e.path[0]);if("insert"===e.type)s.innerHTML=this[TEMPLATE_KEY],ties.create(s.content.firstElementChild,e.value),t.insertBefore(s.content,t.children[e.path[0]+i]);else if("update"===e.type)ties.update(t.children[E+i],e.value);else if("delete"===e.type){for(const i of t.children)if(i[ITEM_KEY]===e.path[0]){i.remove();break}}else console.warn(`unsupported change type ${e.type}`)}}}customElements.get(DATA_TIER_LIST)?console.warn("'data-tier-list' is already defined in this environment, won't redefine"):customElements.define(DATA_TIER_LIST,DataTierList);
import{ties}from"./data-tier/data-tier.min.js";import{Observable}from"./data-tier/object-observer.min.js";const DATA_TIER_LIST="data-tier-list",SELF_TEMPLATE='<slot id="template"></slot>',ITEM_KEY=Symbol("item.key"),ITEMS_KEY=Symbol("items.key"),TEMPLATE_KEY=Symbol("template"),OBSERVER_KEY=Symbol("observer"),FULL_UPDATER_KEY=Symbol("full.updater"),PART_UPDATER_KEY=Symbol("part.updater"),CONTAINER_RESOLVER_KEY=Symbol("container.resolver"),TEMPLATE_PROCESSOR_KEY=Symbol("template.processor");class DataTierList extends HTMLElement{constructor(){super(),this[ITEMS_KEY]=null,this[TEMPLATE_KEY]=null,this[OBSERVER_KEY]=this[OBSERVER_KEY].bind(this),this.attachShadow({mode:"open"}).innerHTML=SELF_TEMPLATE,this.shadowRoot.querySelector("#template").addEventListener("slotchange",()=>this[TEMPLATE_PROCESSOR_KEY]())}connectedCallback(){this.hidden=!0,this[TEMPLATE_PROCESSOR_KEY]()}get defaultTieTarget(){return"items"}set items(e){this[ITEMS_KEY]!==e&&(null===e||""===e?this[ITEMS_KEY]&&(this[ITEMS_KEY].unobserve(this[OBSERVER_KEY]),this[ITEMS_KEY]=null,this[FULL_UPDATER_KEY]()):"object"==typeof e?(this[ITEMS_KEY]&&this[ITEMS_KEY].unobserve(this[OBSERVER_KEY]),this[ITEMS_KEY]=Observable.from(e),this[ITEMS_KEY].observe(this[OBSERVER_KEY],{pathsOf:""}),this[FULL_UPDATER_KEY]()):console.error(`items MAY ONLY be set to an object, got '${e}'`))}get items(){return this[ITEMS_KEY]}[CONTAINER_RESOLVER_KEY](){let e;const t=this.getAttribute("data-list-target");if(t){if(!(e=this.getRootNode().querySelector(t)))throw new Error(`failed to resolve target container by the given query '${t}'`)}else e=this.parentNode;return e}[TEMPLATE_PROCESSOR_KEY](){const e=this.children;let t=null;1===e.length?(t=e[0].outerHTML,e[0]!==this.__currentTemplate&&(this.__currentTemplate&&ties.remove(this.__currentTemplate),ties.create(e[0]),this.__currentTemplate=e[0],this[TEMPLATE_KEY]=t,this[FULL_UPDATER_KEY]())):console.error(`list item template MAY have 1 root element only, got ${e.length}`)}[OBSERVER_KEY](e){for(const t of e)"shuffle"===t.type||"reverse"===t.type?this[FULL_UPDATER_KEY]():this[PART_UPDATER_KEY](t)}[FULL_UPDATER_KEY](){if(!this[TEMPLATE_KEY]||!this.items)return;const e=this[CONTAINER_RESOLVER_KEY](),t=e.contains(this)?1:0,i=Object.keys(this.items),s=i.length;let E,r=e.childElementCount-t;for(;r>s;)(E=e.lastElementChild)!==this&&E.remove(),r--;let n="";for(;r<s;)n+=this[TEMPLATE_KEY],r++;if(n){const t=document.createElement("template");t.innerHTML=n,e.appendChild(t.content)}for(let s=t,E=e.children.length;s<E;s++){const E=e.children[s];E[ITEM_KEY]=i[s-t],ties.update(E,this.items[i[s-t]])}}[PART_UPDATER_KEY](e){if(!this[TEMPLATE_KEY]||!this.items)return;const t=this[CONTAINER_RESOLVER_KEY](),i=t.contains(this)?1:0,s=document.createElement("template");if(!(e.path.length>1))if(Array.isArray(this.items)){const n=parseInt(e.path[0],10);if("insert"===e.type)s.innerHTML=this[TEMPLATE_KEY],ties.create(s.content.firstElementChild,e.value),t.insertBefore(s.content,t.children[n+i]);else if("update"===e.type)ties.update(t.children[n+i],e.value);else if("delete"===e.type)t.removeChild(t.children[n+i]);else if("reverse"===e.type)for(var E=i+1,r=t.children.length-i/2;E<r;E++)t.insertBefore(t.children[E],t.children[E-1]);else console.warn(`unsupported change type ${e.type}`)}else{const E=Object.keys(this.items).indexOf(e.path[0]);if("insert"===e.type)s.innerHTML=this[TEMPLATE_KEY],ties.create(s.content.firstElementChild,e.value),t.insertBefore(s.content,t.children[e.path[0]+i]);else if("update"===e.type)ties.update(t.children[E+i],e.value);else if("delete"===e.type){for(const i of t.children)if(i[ITEM_KEY]===e.path[0]){i.remove();break}}else console.warn(`unsupported change type ${e.type}`)}}}customElements.get(DATA_TIER_LIST)?console.warn("'data-tier-list' is already defined in this environment, won't redefine"):customElements.define(DATA_TIER_LIST,DataTierList);

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

import{DOMProcessor as o}from"./dom-processor.min.js";import{Ties as t}from"./ties.min.js";import{Views as e}from"./views.min.js";export{DEFAULT_TIE_TARGET_PROVIDER,CHANGE_EVENT_NAME_PROVIDER}from"./utils.min.js";export const version="2.11.1";const s=performance.now();console.info("DT (2.11.1): starting initialization...");const r=new class{constructor(){this.params=Object.freeze(Array.from(new URL(import.meta.url).searchParams).reduce((o,t)=>(o[t[0]]=t[1],o),{})),this.paramsKey=Symbol("view.params.key"),this.domProcessor=new o(this),this.ties=new t(this),this.views=new e(this),"false"!==this.params.autostart&&!1!==this.params.autostart&&this.domProcessor.addDocument(document)}};export const ties=r.ties;export const addDocument=r.domProcessor.addDocument.bind(r.domProcessor);export const removeDocument=r.domProcessor.removeDocument.bind(r.domProcessor);export const addRootDocument=addDocument;export const removeRootDocument=removeDocument;console.info(`DT (2.11.1): ... initialization DONE (took ${(performance.now()-s).toFixed(2)}ms)`);
import{DOMProcessor as o}from"./dom-processor.min.js";import{Ties as e}from"./ties.min.js";import{Views as t}from"./views.min.js";export{Observable}from"./ties.min.js";export const version="3.1.6";const s=performance.now();console.info("DT (3.1.6): starting initialization...");const r=new class{constructor(){this.params=Object.freeze(Array.from(new URL(import.meta.url).searchParams).reduce((o,e)=>(o[e[0]]=e[1],o),{})),this.paramsKey=Symbol("view.params.key"),this.domProcessor=new o(this),this.ties=new e(this),this.views=new t(this),"false"!==this.params.autostart&&!1!==this.params.autostart&&this.domProcessor.addDocument(document)}};export const ties=r.ties;export const addDocument=r.domProcessor.addDocument.bind(r.domProcessor);export const removeDocument=r.domProcessor.removeDocument.bind(r.domProcessor);export const addRootDocument=addDocument;export const removeRootDocument=removeDocument;console.info(`DT (3.1.6): ... initialization DONE (took ${(performance.now()-s).toFixed(2)}ms)`);

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

import{getTargetProperty as e,addChangeListener as t,delChangeListener as s,getPath as n,setPath as o,callViewFunction as i}from"./utils.min.js";const r=Object.freeze({subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-tie"],attributeOldValue:!0,characterData:!1,characterDataOldValue:!1}),a=Symbol("bound.dom.observer"),d=Symbol("bound.change.listener");export class DOMProcessor{constructor(e){this._dtInstance=e,this._roots=new WeakMap,this._elementsMap=new WeakSet,this[a]=this._processDomChanges.bind(this),this[d]=this._changeListener.bind(this)}addDocument(e){if(!e||Node.DOCUMENT_NODE!==e.nodeType&&Node.DOCUMENT_FRAGMENT_NODE!==e.nodeType)throw new Error("invalid argument, must be one of: DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE");if(this._roots.has(e))return console.warn("any root document may be added only once"),!1;const t=new MutationObserver(this[a]);t.observe(e,r),this._roots.set(e,t);for(let t=0,s=e.children.length;t<s;t++)this._addTree(e.children[t]);return!0}removeDocument(e){if(!this._roots.has(e))return console.warn(`no root document ${e} known`),!1;this._roots.get(e).disconnect(),this._roots.delete(e);for(let t=0,s=e.children.length;t<s;t++)this._dropTree(e.children[t]);return!0}_processDomChanges(e){const t=e.length;let s,n,o=0;for(;o<t;o++)if("attributes"===(n=(s=e[o]).type)){const e=s.attributeName,t=s.target,n=s.oldValue,o=t.getAttribute(e);n!==o&&"data-tie"===e&&this._onTieParamChange(t,o,n)}else if("childList"===n){const e=s.addedNodes;for(let t=0,s=e.length;t<s;t++){let s=e[t];s.nodeType===Node.ELEMENT_NODE&&this._addTree(s)}const t=s.removedNodes;for(let e=0,s=t.length;e<s;e++){let s=t[e];s.nodeType===Node.ELEMENT_NODE&&this._dropTree(s)}}}_onTieParamChange(e,n,o){if(o){const t=e[this._dtInstance.paramsKey];t&&(this._dtInstance.views.delView(e,t),s(e,this[d]))}if(n){const s=this._dtInstance.views.addView(e);s&&(this._updateFromView(e,s),t(e,this[d]))}}_addTree(e){if(this._addOne(e),e.childElementCount){let t;const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t=s.nextNode();)this._addOne(t)}}_dropTree(e){if(this._dropOne(e),e.childElementCount){let t;const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t=s.nextNode();)this._dropOne(t)}}_addOne(e){if(!this._elementsMap.has(e))if(this._elementsMap.add(e),e.tagName.indexOf("-")>0&&!e.matches(":defined"))this._waitDefined(e);else{const s=this._dtInstance.views.addView(e);s&&(this._updateFromView(e,s),t(e,this[d])),e.shadowRoot&&this.addDocument(e.shadowRoot)}}_waitDefined(e){customElements.whenDefined(e.tagName.toLowerCase()).then(()=>{this._elementsMap.delete(e),this._addOne(e)})}_dropOne(e){if(!this._elementsMap.has(e))return;this._elementsMap.delete(e);let t=e[this._dtInstance.paramsKey];t&&(this._dtInstance.views.delView(e,t),s(e,this[d])),e.shadowRoot&&this.removeDocument(e.shadowRoot)}_changeListener(t){const s=t.currentTarget,n=e(s),i=s[this._dtInstance.paramsKey];let r,a,d;if(!i)return;let h=i.length;for(;h--;)(r=i[h]).targetProperty===n&&(a=this._dtInstance.ties.get(r.tieKey))&&(d=s[n],o(a,r.path,d))}_updateFromView(e,t){let s=t.length;for(;s--;){const o=t[s];if(o.isFunctional){let t=!1;const s=[];o.fParams.forEach(e=>{let o;const i=this._dtInstance.ties.get(e.tieKey);i&&(o=n(i,e.path),t=!0),s.push(o)}),t&&(s.push(null),i(e,o.targetProperty,s))}else{const t=this._dtInstance.ties.get(o.tieKey);if(t){let s=n(t,o.path);void 0===s&&(s=""),this._dtInstance.views.setViewProperty(e,o,s)}}}}};
import{getPath as e,setPath as t,callViewFunction as n}from"./utils.min.js";const s=Object.freeze({subtree:!0,childList:!0,attributes:!0,attributeFilter:["data-tie"],attributeOldValue:!0,characterData:!1,characterDataOldValue:!1}),o=Symbol("bound.dom.observer"),i=Symbol("bound.change.listener");export class DOMProcessor{constructor(e){this._dtInstance=e,this._roots=new WeakMap,this._elementsMap=new WeakSet,this[o]=this._processDomChanges.bind(this),this[i]=this._changeListener.bind(this)}addDocument(e){if(!e||Node.DOCUMENT_NODE!==e.nodeType&&Node.DOCUMENT_FRAGMENT_NODE!==e.nodeType)throw new Error("invalid argument, must be one of: DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE");if(this._roots.has(e))return console.warn("any root document may be added only once"),!1;const t=new MutationObserver(this[o]);t.observe(e,s),this._roots.set(e,t);for(let t=0,n=e.children.length;t<n;t++)this._addTree(e.children[t]);return!0}removeDocument(e){if(!this._roots.has(e))return console.warn(`no root document ${e} known`),!1;this._roots.get(e).disconnect(),this._roots.delete(e);for(let t=0,n=e.children.length;t<n;t++)this._dropTree(e.children[t]);return!0}_processDomChanges(e){const t=e.length;let n,s,o=0;for(;o<t;o++)if("attributes"===(s=(n=e[o]).type)){const e=n.attributeName,t=n.target,s=n.oldValue,o=t.getAttribute(e);s!==o&&"data-tie"===e&&this._onTieParamChange(t,o,s)}else if("childList"===s){const e=n.addedNodes;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.nodeType===Node.ELEMENT_NODE&&this._addTree(n)}const t=n.removedNodes;for(let e=0,n=t.length;e<n;e++){let n=t[e];n.nodeType===Node.ELEMENT_NODE&&this._dropTree(n)}}}_onTieParamChange(e,t,n){if(n){const t=e[this._dtInstance.paramsKey];if(t){this._dtInstance.views.delView(e,t);for(const n of t)n.changeEvent&&e.removeEventListener(n.changeEvent,this[i])}}if(t){const t=this._dtInstance.views.addView(e);if(t){this._updateFromView(e,t);for(const n of t)n.changeEvent&&e.addEventListener(n.changeEvent,this[i])}}}_addTree(e){if(this._addOne(e),e.childElementCount){let t;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t=n.nextNode();)this._addOne(t)}}_dropTree(e){if(this._dropOne(e),e.childElementCount){let t;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t=n.nextNode();)this._dropOne(t)}}_addOne(e){if(!this._elementsMap.has(e))if(this._elementsMap.add(e),e.nodeName.indexOf("-")>0&&!e.matches(":defined"))this._waitDefined(e);else{const t=this._dtInstance.views.addView(e);if(t){this._updateFromView(e,t);for(const n of t)n.changeEvent&&e.addEventListener(n.changeEvent,this[i])}e.shadowRoot&&this.addDocument(e.shadowRoot)}}_waitDefined(e){customElements.whenDefined(e.nodeName.toLowerCase()).then(()=>{this._elementsMap.delete(e),this._addOne(e)})}_dropOne(e){if(!this._elementsMap.has(e))return;this._elementsMap.delete(e);let t=e[this._dtInstance.paramsKey];if(t){this._dtInstance.views.delView(e,t);for(const n of t)n.changeEvent&&e.removeEventListener(n.changeEvent,this[i])}e.shadowRoot&&this.removeDocument(e.shadowRoot)}_changeListener(e){const n=e.type,s=e.currentTarget,o=s[this._dtInstance.paramsKey];if(!o)return;let i,r,a,d=o.length;for(;d--;)(i=o[d]).changeEvent===n&&(r=this._dtInstance.ties.get(i.tieKey))&&(a=s[i.targetProperty],t(r,i.path,a))}_updateFromView(t,s){let o=s.length;for(;o--;){const i=s[o];if(i.isFunctional){let s=!1;const o=[];i.fParams.forEach(t=>{let n;const i=this._dtInstance.ties.get(t.tieKey);i&&(n=e(i,t.path),s=!0),o.push(n)}),s&&(o.push(null),n(t,i.targetProperty,o))}else{const n=this._dtInstance.ties.get(i.tieKey);if(void 0!==n){const s=e(n,i.path);this._dtInstance.views.setViewProperty(t,i,s)}}}}};

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

const t="insert",e="update",o="delete",r=Symbol("observable-meta-key"),n={async:1},s={path:1,pathsOf:1,pathsFrom:1},i={[r]:{value:null},observe:{value:function(t,e){if("function"!=typeof t)throw new Error(`observer MUST be a function, got '${t}'`);const o=this[r].observers;if(o.some(e=>e[0]===t))console.warn("observer may be bound to an observable only once; will NOT rebind");else{let r;r=e?function(t){const e={};if(void 0!==t.path){if("string"!=typeof t.path||""===t.path)throw new Error('"path" option, if/when provided, MUST be a non-empty string');e.path=t.path}if(void 0!==t.pathsOf){if(t.path)throw new Error('"pathsOf" option MAY NOT be specified together with "path" option');if("string"!=typeof t.pathsOf)throw new Error('"pathsOf" option, if/when provided, MUST be a string (MAY be empty)');e.pathsOf=t.pathsOf.split(".").filter(t=>t)}if(void 0!==t.pathsFrom){if(t.path||t.pathsOf)throw new Error('"pathsFrom" option MAY NOT be specified together with "path"/"pathsOf" option/s');if("string"!=typeof t.pathsFrom||""===t.pathsFrom)throw new Error('"pathsFrom" option, if/when provided, MUST be a non-empty string');e.pathsFrom=t.pathsFrom}const o=Object.keys(t).filter(t=>!s.hasOwnProperty(t));if(o.length)throw new Error(`'${o.join(", ")}' is/are not a valid observer option/s`);return e}(e):{},o.push([t,r])}}},unobserve:{value:function(){const t=this[r].observers;let e=t.length;if(e){let o=arguments.length;if(o)for(;o--;){let r=e;for(;r--;)t[r][0]===arguments[o]&&(t.splice(r,1),e--)}else t.splice(0)}}}},a=function(t,e){i[r].value=e;const o=Object.defineProperties({},i);for(const r of Object.keys(t))o[r]=y(t[r],r,e);return o},h=function(t,e){let o=0,n=t.length;i[r].value=e;const s=Object.defineProperties(new Array(n),i);for(;o<n;o++)s[o]=y(t[o],o,e);return s},p=function(t,e){return i[r].value=e,Object.defineProperties(t,i),t},l=function(t,e){let o=e;if(t.path){const r=t.path;o=e.filter(t=>t.path.join(".")===r)}else if(t.pathsOf){const r=t.pathsOf;o=e.filter(t=>t.path.length===r.length+1||t.path.length===r.length&&("reverse"===t.type||"shuffle"===t.type))}else if(t.pathsFrom){const r=t.pathsFrom;o=e.filter(t=>t.path.join(".").startsWith(r))}return o},c=function(t,e){try{t(e)}catch(o){console.error(`failed to notify listener ${t} with ${e}`,o)}},f=function(){const t=this.batches;this.batches=null;for(const[e,o]of t)c(e,o)},u=function(t,e){let o,r,n,s,i,a,h,p=t;const u=e.length;do{for(i=(o=p.observers).length;i--;)if([r,n]=o[i],(s=l(n,e)).length)if(p.options.async){p.batches||(p.batches=[],queueMicrotask(f.bind(p)));let t=p.batches.find(t=>t[0]===r);t||(t=[r,[]],p.batches.push(t)),Array.prototype.push.apply(t[1],s)}else c(r,s);let t;if(p.parent){t=new Array(u);for(let o=0;o<u;o++)h=e[o],a=[p.ownKey,...h.path],t[o]={type:h.type,path:a,value:h.value,oldValue:h.oldValue,object:h.object};e=t,p=p.parent}else p=null}while(p)},y=function(t,e,o){return t&&"object"==typeof t?Array.isArray(t)?new x({target:t,ownKey:e,parent:o}).proxy:ArrayBuffer.isView(t)?new M({target:t,ownKey:e,parent:o}).proxy:t instanceof Date||t instanceof Blob||t instanceof Error?t:new m({target:t,ownKey:e,parent:o}).proxy:t},b=function(){const t=this[r],e=t.target;let o,n,s;for(e.reverse(),o=0,n=e.length;o<n;o++)if((s=e[o])&&"object"==typeof s){const t=s[r];t&&(t.ownKey=o)}return u(t,[{type:"reverse",path:[],object:this}]),this},w=function(t){const e=this[r],o=e.target;let n,s,i;for(o.sort(t),n=0,s=o.length;n<s;n++)if((i=o[n])&&"object"==typeof i){const t=i[r];t&&(t.ownKey=n)}return u(e,[{type:"shuffle",path:[],object:this}]),this},g=function(o,n,s){const i=this[r],a=i.target,h=[],p=a.length,l=a.slice(0);if(n=void 0===n?0:n<0?Math.max(p+n,0):Math.min(n,p),s=void 0===s?p:s<0?Math.max(p+s,0):Math.min(s,p),n<p&&s>n){let p;a.fill(o,n,s);for(let o,c,f=n;f<s;f++)o=a[f],a[f]=y(o,f,i),l.hasOwnProperty(f)?((c=l[f])&&"object"==typeof c&&(p=c[r])&&(c=p.detach()),h.push({type:e,path:[f],value:a[f],oldValue:c,object:this})):h.push({type:t,path:[f],value:a[f],object:this});u(i,h)}return this},v=function(t,o,n){const s=this[r],i=s.target,a=i.length;t=t<0?Math.max(a+t,0):t,o=void 0===o?0:o<0?Math.max(a+o,0):Math.min(o,a),n=void 0===n?a:n<0?Math.max(a+n,0):Math.min(n,a);const h=Math.min(n-o,a-t);if(t<a&&t!==o&&h>0){const a=i.slice(0),p=[];i.copyWithin(t,o,n);for(let o,n,l,c=t;c<t+h;c++)(o=i[c])&&"object"==typeof o&&(o=y(o,c,s),i[c]=o),(n=a[c])&&"object"==typeof n&&(l=n[r])&&(n=l.detach()),"object"!=typeof o&&o===n||p.push({type:e,path:[c],value:o,oldValue:n,object:this});u(s,p)}return this},d={pop:function(){const t=this[r],e=t.target,n=e.length-1;let s=e.pop();if(s&&"object"==typeof s){const t=s[r];t&&(s=t.detach())}return u(t,[{type:o,path:[n],oldValue:s,object:this}]),s},push:function(){const e=this[r],o=e.target,n=arguments.length,s=new Array(n),i=o.length;for(let t=0;t<n;t++)s[t]=y(arguments[t],i+t,e);const a=Reflect.apply(o.push,o,s),h=[];for(let e=i,r=o.length;e<r;e++)h[e-i]={type:t,path:[e],value:o[e],object:this};return u(e,h),a},shift:function(){const t=this[r],e=t.target;let n,s,i,a,h;for((n=e.shift())&&"object"==typeof n&&(h=n[r])&&(n=h.detach()),s=0,i=e.length;s<i;s++)(a=e[s])&&"object"==typeof a&&(h=a[r])&&(h.ownKey=s);return u(t,[{type:o,path:[0],oldValue:n,object:this}]),n},unshift:function(){const e=this[r],o=e.target,n=arguments.length,s=new Array(n);for(let t=0;t<n;t++)s[t]=y(arguments[t],t,e);const i=Reflect.apply(o.unshift,o,s);for(let t,e=0,n=o.length;e<n;e++)if((t=o[e])&&"object"==typeof t){const o=t[r];o&&(o.ownKey=e)}const a=s.length,h=new Array(a);for(let e=0;e<a;e++)h[e]={type:t,path:[e],value:o[e],object:this};return u(e,h),i},reverse:b,sort:w,fill:g,copyWithin:v,splice:function(){const n=this[r],s=n.target,i=arguments.length,a=new Array(i),h=s.length;for(let t=0;t<i;t++)a[t]=y(arguments[t],t,n);const p=0===i?0:a[0]<0?h+a[0]:a[0],l=i<2?h-p:a[1],c=Math.max(i-2,0),f=Reflect.apply(s.splice,s,a),b=s.length;let w,g,v,d;for(let t,e=0;e<b;e++)(t=s[e])&&"object"==typeof t&&(w=t[r])&&(w.ownKey=e);for(g=0,v=f.length;g<v;g++)(d=f[g])&&"object"==typeof d&&(w=d[r])&&(f[g]=w.detach());const j=[];let O;for(O=0;O<l;O++)O<c?j.push({type:e,path:[p+O],value:s[p+O],oldValue:f[O],object:this}):j.push({type:o,path:[p+O],oldValue:f[O],object:this});for(;O<c;O++)j.push({type:t,path:[p+O],value:s[p+O],object:this});return u(n,j),f}},j={reverse:b,sort:w,fill:g,copyWithin:v,set:function(t,o){const n=this[r],s=n.target,i=t.length,a=s.slice(0);o=o||0,s.set(t,o);const h=new Array(i);for(let t=o;t<i+o;t++)h[t-o]={type:e,path:[t],value:s[t],oldValue:a[t],object:this};u(n,h)}};class O{constructor(t,e){const{target:o,parent:r,ownKey:n}=t;r&&void 0!==n?(this.parent=r,this.ownKey=n):(this.parent=null,this.ownKey=null);const s=e(o,this);this.observers=[],this.revocable=Proxy.revocable(s,this),this.proxy=this.revocable.proxy,this.target=s,this.options=this.processOptions(t.options)}processOptions(t){if(t){if("object"!=typeof t)throw new Error(`Observable options if/when provided, MAY only be an object, got '${t}'`);const e=Object.keys(t).filter(t=>!n.hasOwnProperty(t));if(e.length)throw new Error(`'${e.join(", ")}' is/are not a valid Observable option/s`);return Object.assign({},t)}return{}}detach(){return this.parent=null,this.target}set(o,n,s){let i=o[n];if(s!==i){const a=y(s,n,this);if(o[n]=a,i&&"object"==typeof i){const t=i[r];t&&(i=t.detach())}const h=void 0===i?[{type:t,path:[n],value:a,object:this.proxy}]:[{type:e,path:[n],value:a,oldValue:i,object:this.proxy}];u(this,h)}return!0}deleteProperty(t,e){let n=t[e];if(delete t[e],n&&"object"==typeof n){const t=n[r];t&&(n=t.detach())}const s=[{type:o,path:[e],oldValue:n,object:this.proxy}];return u(this,s),!0}}class m extends O{constructor(t){super(t,a)}}class x extends O{constructor(t){super(t,h)}get(t,e){return d.hasOwnProperty(e)?d[e]:t[e]}}class M extends O{constructor(t){super(t,p)}get(t,e){return j.hasOwnProperty(e)?j[e]:t[e]}}class A{constructor(){throw new Error('Observable MAY NOT be created via constructor, see "Observable.from" API')}static from(t,e){if(t&&"object"==typeof t){if(t[r])return t;if(Array.isArray(t))return new x({target:t,ownKey:null,parent:null,options:e}).proxy;if(ArrayBuffer.isView(t))return new M({target:t,ownKey:null,parent:null,options:e}).proxy;if(t instanceof Date||t instanceof Blob||t instanceof Error)throw new Error(`${t} found to be one of a on-observable types`);return new m({target:t,ownKey:null,parent:null,options:e}).proxy}throw new Error("observable MAY ONLY be created from a non-null object")}static isObservable(t){return!(!t||!t[r])}}Object.freeze(A);export{A as Observable};
export{A as Observable,k as ObjectObserver};const t="insert",e="update",o="delete",n=Symbol("observable-meta-key"),r={async:1},s={[n]:{value:null},observe:{value:function(t,e){if("function"!=typeof t)throw new Error(`observer MUST be a function, got '${t}'`);const o=this[n].observers;o.some(e=>e[0]===t)?console.warn("observer may be bound to an observable only once; will NOT rebind"):o.push([t,(t=>{if(!t||"object"!=typeof t)return null;const e={},o=[];for(const[n,r]of Object.entries(t))if("path"===n){if("string"!=typeof r||""===r)throw new Error('"path" option, if/when provided, MUST be a non-empty string');e[n]=r}else if("pathsOf"===n){if(t.path)throw new Error('"pathsOf" option MAY NOT be specified together with "path" option');if("string"!=typeof r)throw new Error('"pathsOf" option, if/when provided, MUST be a string (MAY be empty)');e[n]=t.pathsOf.split(".").filter(Boolean)}else if("pathsFrom"===n){if(t.path||t.pathsOf)throw new Error('"pathsFrom" option MAY NOT be specified together with "path"/"pathsOf" option/s');if("string"!=typeof r||""===r)throw new Error('"pathsFrom" option, if/when provided, MUST be a non-empty string');e[n]=r}else o.push(n);if(o.length)throw new Error(`'${o.join(", ")}' is/are not a valid observer option/s`);return e})(e)])}},unobserve:{value:function(){const t=this[n].observers;let e=t.length;if(e){let o=arguments.length;if(o)for(;o--;){let n=e;for(;n--;)t[n][0]===arguments[o]&&(t.splice(n,1),e--)}else t.splice(0)}}}},i=(t,e)=>{s[n].value=e;const o=Object.defineProperties({},s);for(const n of Object.keys(t))o[n]=u(t[n],n,e);return o},h=(t,e)=>{let o=0,r=t.length;s[n].value=e;const i=Object.defineProperties(new Array(r),s);for(;o<r;o++)i[o]=u(t[o],o,e);return i},a=(t,e)=>(s[n].value=e,Object.defineProperties(t,s),t),l=(t,e)=>{let o=e;if(t)if(t.path){const n=t.path;o=e.filter(t=>t.path.join(".")===n)}else if(t.pathsOf){const n=t.pathsOf;o=e.filter(t=>t.path.length===n.length+1||t.path.length===n.length&&("reverse"===t.type||"shuffle"===t.type))}else if(t.pathsFrom){const n=t.pathsFrom;o=e.filter(t=>t.path.join(".").startsWith(n))}return o},c=(t,e)=>{try{t(e)}catch(o){console.error(`failed to notify listener ${t} with ${e}`,o)}},f=function(){const t=this.batches;this.batches=null;for(const[e,o]of t)c(e,o)},p=(t,e)=>{let o,n,r,s,i,h,a,p=t;const u=e.length;do{for(i=(o=p.observers).length;i--;)if([n,r]=o[i],(s=l(r,e)).length)if(p.options.async){let t;p.batches||(p.batches=[],queueMicrotask(f.bind(p)));for(const e of p.batches)if(e[0]===n){t=e;break}t||(t=[n,[]],p.batches.push(t)),Array.prototype.push.apply(t[1],s)}else c(n,s);let t;if(p.parent){t=new Array(u);for(let o=0;o<u;o++)a=e[o],h=[p.ownKey,...a.path],t[o]={type:a.type,path:h,value:a.value,oldValue:a.oldValue,object:a.object};e=t,p=p.parent}else p=null}while(p)},u=(t,e,o)=>t&&"object"==typeof t?Array.isArray(t)?new x({target:t,ownKey:e,parent:o}).proxy:ArrayBuffer.isView(t)?new M({target:t,ownKey:e,parent:o}).proxy:t instanceof Date||t instanceof Blob||t instanceof Error?t:new O({target:t,ownKey:e,parent:o}).proxy:t,y=function(){const t=this[n],e=t.target;let o,r,s;for(e.reverse(),o=0,r=e.length;o<r;o++)if((s=e[o])&&"object"==typeof s){const t=s[n];t&&(t.ownKey=o)}const i=[new j("reverse",[],void 0,void 0,this)];return p(t,i),this},b=function(t){const e=this[n],o=e.target;let r,s,i;for(o.sort(t),r=0,s=o.length;r<s;r++)if((i=o[r])&&"object"==typeof i){const t=i[n];t&&(t.ownKey=r)}const h=[new j("shuffle",[],void 0,void 0,this)];return p(e,h),this},w=function(o,r,s){const i=this[n],h=i.target,a=[],l=h.length,c=h.slice(0);if(r=void 0===r?0:r<0?Math.max(l+r,0):Math.min(r,l),s=void 0===s?l:s<0?Math.max(l+s,0):Math.min(s,l),r<l&&s>r){let l;h.fill(o,r,s);for(let o,f,p=r;p<s;p++)o=h[p],h[p]=u(o,p,i),p in c?((f=c[p])&&"object"==typeof f&&(l=f[n])&&(f=l.detach()),a.push(new j(e,[p],h[p],f,this))):a.push(new j(t,[p],h[p],void 0,this));p(i,a)}return this},d=function(t,o,r){const s=this[n],i=s.target,h=i.length;t=t<0?Math.max(h+t,0):t,o=void 0===o?0:o<0?Math.max(h+o,0):Math.min(o,h),r=void 0===r?h:r<0?Math.max(h+r,0):Math.min(r,h);const a=Math.min(r-o,h-t);if(t<h&&t!==o&&a>0){const h=i.slice(0),l=[];i.copyWithin(t,o,r);for(let o,r,c,f=t;f<t+a;f++)(o=i[f])&&"object"==typeof o&&(o=u(o,f,s),i[f]=o),(r=h[f])&&"object"==typeof r&&(c=r[n])&&(r=c.detach()),"object"!=typeof o&&o===r||l.push(new j(e,[f],o,r,this));p(s,l)}return this},v={pop:function(){const t=this[n],e=t.target,r=e.length-1;let s=e.pop();if(s&&"object"==typeof s){const t=s[n];t&&(s=t.detach())}const i=[new j(o,[r],void 0,s,this)];return p(t,i),s},push:function(){const e=this[n],o=e.target,r=arguments.length,s=new Array(r),i=o.length;for(let t=0;t<r;t++)s[t]=u(arguments[t],i+t,e);const h=Reflect.apply(o.push,o,s),a=[];for(let e=i,n=o.length;e<n;e++)a[e-i]=new j(t,[e],o[e],void 0,this);return p(e,a),h},shift:function(){const t=this[n],e=t.target;let r,s,i,h,a;for((r=e.shift())&&"object"==typeof r&&(a=r[n])&&(r=a.detach()),s=0,i=e.length;s<i;s++)(h=e[s])&&"object"==typeof h&&(a=h[n])&&(a.ownKey=s);const l=[new j(o,[0],void 0,r,this)];return p(t,l),r},unshift:function(){const e=this[n],o=e.target,r=arguments.length,s=new Array(r);for(let t=0;t<r;t++)s[t]=u(arguments[t],t,e);const i=Reflect.apply(o.unshift,o,s);for(let t,e=0,r=o.length;e<r;e++)if((t=o[e])&&"object"==typeof t){const o=t[n];o&&(o.ownKey=e)}const h=s.length,a=new Array(h);for(let e=0;e<h;e++)a[e]=new j(t,[e],o[e],void 0,this);return p(e,a),i},reverse:y,sort:b,fill:w,copyWithin:d,splice:function(){const r=this[n],s=r.target,i=arguments.length,h=new Array(i),a=s.length;for(let t=0;t<i;t++)h[t]=u(arguments[t],t,r);const l=0===i?0:h[0]<0?a+h[0]:h[0],c=i<2?a-l:h[1],f=Math.max(i-2,0),y=Reflect.apply(s.splice,s,h),b=s.length;let w,d,v,g;for(let t,e=0;e<b;e++)(t=s[e])&&"object"==typeof t&&(w=t[n])&&(w.ownKey=e);for(d=0,v=y.length;d<v;d++)(g=y[d])&&"object"==typeof g&&(w=g[n])&&(y[d]=w.detach());const m=[];let O;for(O=0;O<c;O++)O<f?m.push(new j(e,[l+O],s[l+O],y[O],this)):m.push(new j(o,[l+O],void 0,y[O],this));for(;O<f;O++)m.push(new j(t,[l+O],s[l+O],void 0,this));return p(r,m),y}},g={reverse:y,sort:b,fill:w,copyWithin:d,set:function(t,o){const r=this[n],s=r.target,i=t.length,h=s.slice(0);o=o||0,s.set(t,o);const a=new Array(i);for(let t=o;t<i+o;t++)a[t-o]=new j(e,[t],s[t],h[t],this);p(r,a)}};class j{constructor(t,e,o,n,r){this.type=t,this.path=e,this.value=o,this.oldValue=n,this.object=r}}class m{constructor(t,e){const{target:o,parent:n,ownKey:r}=t;n&&void 0!==r?(this.parent=n,this.ownKey=r):(this.parent=null,this.ownKey=null);const s=e(o,this);this.observers=[],this.revocable=Proxy.revocable(s,this),this.proxy=this.revocable.proxy,this.target=s,this.options=this.processOptions(t.options)}processOptions(t){if(t){if("object"!=typeof t)throw new Error(`Observable options if/when provided, MAY only be an object, got '${t}'`);const e=Object.keys(t).filter(t=>!(t in r));if(e.length)throw new Error(`'${e.join(", ")}' is/are not a valid Observable option/s`);return Object.assign({},t)}return{}}detach(){return this.parent=null,this.target}set(o,r,s){let i=o[r];if(s!==i){const h=u(s,r,this);if(o[r]=h,i&&"object"==typeof i){const t=i[n];t&&(i=t.detach())}const a=void 0===i?[new j(t,[r],h,void 0,this.proxy)]:[new j(e,[r],h,i,this.proxy)];p(this,a)}return!0}deleteProperty(t,e){let r=t[e];if(delete t[e],r&&"object"==typeof r){const t=r[n];t&&(r=t.detach())}const s=[new j(o,[e],void 0,r,this.proxy)];return p(this,s),!0}}class O extends m{constructor(t){super(t,i)}}class x extends m{constructor(t){super(t,h)}get(t,e){return v[e]||t[e]}}class M extends m{constructor(t){super(t,a)}get(t,e){return g[e]||t[e]}}const A=Object.freeze({from:(t,e)=>{if(t&&"object"==typeof t){if(t[n])return t;if(Array.isArray(t))return new x({target:t,ownKey:null,parent:null,options:e}).proxy;if(ArrayBuffer.isView(t))return new M({target:t,ownKey:null,parent:null,options:e}).proxy;if(t instanceof Date||t instanceof Blob||t instanceof Error)throw new Error(`${t} found to be one of a on-observable types`);return new O({target:t,ownKey:null,parent:null,options:e}).proxy}throw new Error("observable MAY ONLY be created from a non-null object")},isObservable:t=>!(!t||!t[n])}),K=Symbol("callback-key"),E=Symbol("targets-key");class k{constructor(t){this[K]=t,this[E]=new Set,Object.freeze(this)}observe(t,e){const o=A.from(t);return o.observe(this[K],e),this[E].add(o),o}unobserve(t){t.unobserve(this[K]),this[E].delete(t)}disconnect(){for(const t of this[E])t.unobserve(this[K]);this[E].clear()}}

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

import{ensureObservable as e,getPath as t,callViewFunction as i,getRandomKey as s}from"./utils.min.js";const o=Symbol("model.key"),r=/^[a-zA-Z0-9]+$/,n=["scope"];class a{constructor(e,t,i){this.key=e,this.ties=i,this.model=t}set model(t){this[o]=e(t),this[o].observe(e=>this.processDataChanges(e))}get model(){return this[o]}processDataChanges(e){const t=this.ties.dti.views.obtainTieViews(this.key),i=t._pathsCache,s=i.length;let o,r,n,a,h,l,d,p,c,f,y,u,g,w,m,b,T,v="";if(s)for(o=0,r=e.length;o<r;o++)if(l=(h=(n=e[o]).path).length,!h.some(e=>"symbol"==typeof e)){for(w=!1,a=n.object,!Array.isArray(a)||"insert"!==n.type&&"delete"!==n.type||isNaN(h[h.length-1])?1===l?v=h[0]:l&&(v=2===l?h[0]+"."+h[1]:h.join(".")):(v=h.slice(0,-1).join("."),w=!0),y=v.length,d=s,T=[];d--;)if(y>(p=i[d]).length?(u=p,g=v):(u=v,g=p),m=u===g&&!w,0===g.indexOf(u))for(f=(c=t[p]).length;f--;)b=c[f],T.push([b,p,m]);this.updateViews(T,n)}}updateViews(e,s){let r,n;for(const[a,h,l]of e)for(n=(r=a[this.ties.dti.paramsKey]).length;n--;){const e=r[n];if(e.isFunctional){if(e.fParams.some(e=>e.tieKey===this.key&&e.rawPath===h)){let o=!1;const r=[];e.fParams.forEach(e=>{let i;const s=this.ties.get(e.tieKey);s&&(i=t(s,e.path),o=!0),r.push(i)}),o&&(r.push([s]),i(a,e.targetProperty,r))}}else{if(e.tieKey!==this.key||e.rawPath!==h)continue;let i;void 0===(i=s&&void 0!==s.value&&l?s.value:t(this[o],e.path))&&(i=""),this.ties.dti.views.setViewProperty(a,e,i)}}}}export class Ties{constructor(e){this.dti=e,this.ties={}}get(e){const t="string"==typeof e?e:e&&e.getAttribute?e.getAttribute("data-tie-scope"):null,i=this.ties[t];return i?i.model:null}create(e,t){if(null===t)throw new Error("initial model, when provided, MUST NOT be null");let i;if("string"==typeof e?i=e:e&&e.nodeType===Node.ELEMENT_NODE&&((i=e.getAttribute("data-tie-scope"))?console.log("inspect this"):(i=s(16),e.setAttribute("data-tie-scope",i))),Ties.validateTieKey(i),this.ties[i])throw new Error(`tie '${i}' already exists`);e.nodeType&&this.dti.views.addScope(e);const o=new a(i,t,this);return this.ties[i]=o,o.processDataChanges([{path:[]}]),o.model}update(e,t){if(!t||"object"!=typeof t)throw new Error("model MUST be a non-null object");const i="string"==typeof e?e:e&&e.getAttribute?e.getAttribute("data-tie-scope"):null,s=this.ties[i];return s?(s.model!==t&&(s.model=t,s.processDataChanges([{path:[]}])),s.model):this.create(e,t)}remove(e){let t=e;if("object"==typeof e)t=e.nodeType===Node.ELEMENT_NODE?e.getAttribute("data-tie-scope"):Object.keys(this.ties).find(t=>this.ties[t].model===e);else if("string"!=typeof e)throw new Error(`invalid tieToRemove parameter ${e}`);this.ties[t]&&(delete this.ties[t],this.dti.views.deleteTieViews(t))}static validateTieKey(e){if(!e||"string"!=typeof e)throw new Error(`invalid key '${e}'`);if(!r.test(e))throw new Error(`tie key MUST match ${r}; '${e}' doesn't`);if(n.indexOf(e)>=0)throw new Error(`tie key MUST NOT be one of those: ${n.join(", ")}`)}};
import{Observable as e}from"./object-observer.min.js";import{getPath as t,callViewFunction as i,getRandomKey as s}from"./utils.min.js";export{e as Observable};const o=Symbol("model.key"),r=/^[a-zA-Z0-9]+$/,a=["scope"];class n{constructor(e,t,i){this.key=e,this.ties=i,this.model=t}set model(t){const[i,s]=function(t={}){return e.isObservable(t)?[t,!0]:t&&"object"==typeof t?[e.from(t),!0]:[t,!1]}(t);this[o]=i,s&&this[o].observe(e=>this.processDataChanges(e))}get model(){return this[o]}processDataChanges(e){const t=this.ties._dti.views.obtainTieViews(this.key),i=t._pathsCache,s=i.length;let o,r,a,n,h,l,d,c,p,f,y,g,m,u,w,b,v="";if(s)for(o=0,r=e.length;o<r;o++)if(l=(h=(a=e[o]).path).length,!h.some(e=>"symbol"==typeof e))for(u=!1,n=a.object,!Array.isArray(n)||"insert"!==a.type&&"delete"!==a.type||isNaN(h[h.length-1])?1===l?v=h[0]:l&&(v=2===l?h[0]+"."+h[1]:h.join(".")):(v=h.slice(0,-1).join("."),u=!0),y=v.length,d=s;d--;)if(y>(c=i[d]).length?(g=c,m=v):(g=v,m=c),w=g===m&&!u,0===m.indexOf(g))for(f=(p=t[c]).length;f--;)b=p[f],this.updateView(b,c,w,a)}updateView(e,s,r,a){const n=e[this.ties._dti.paramsKey];let h=n.length;for(;h--;){const l=n[h];if(l.isFunctional){if(l.fParams.some(e=>e.tieKey===this.key&&e.rawPath===s)){let s=!1;const o=[];l.fParams.forEach(e=>{let i;const r=this.ties.get(e.tieKey);r&&(i=t(r,e.path),s=!0),o.push(i)}),s&&(o.push([a]),i(e,l.targetProperty,o))}}else{if(l.tieKey!==this.key||l.rawPath!==s)continue;let i;i=void 0!==a.value&&r?a.value:t(this[o],l.path),this.ties._dti.views.setViewProperty(e,l,i)}}}}export class Ties{constructor(e){this._dti=e,this._ties={}}get(e){const t="string"==typeof e?e:e&&e.getAttribute?e.getAttribute("data-tie-scope"):null,i=this._ties[t];return i?i.model:void 0}create(e,t){let i;if("string"==typeof e?i=e:e&&e.nodeType===Node.ELEMENT_NODE&&((i=e.getAttribute("data-tie-scope"))?console.log("inspect this"):(i=s(16),e.setAttribute("data-tie-scope",i))),Ties.validateTieKey(i),this._ties[i])throw new Error(`tie '${i}' already exists`);e.nodeType&&this._dti.views.addScope(e);const o=new n(i,t,this);return this._ties[i]=o,o.processDataChanges([{path:[]}]),o.model}update(e,t){if(void 0===t)throw new Error(`illegal model '${t}'`);const i="string"==typeof e?e:e&&e.getAttribute?e.getAttribute("data-tie-scope"):null,s=this._ties[i];return s?(s.model!==t&&(s.model=t,s.processDataChanges([{path:[]}])),s.model):this.create(e,t)}remove(e){let t=e;if("object"==typeof e)t=e.nodeType===Node.ELEMENT_NODE?e.getAttribute("data-tie-scope"):Object.keys(this._ties).find(t=>this._ties[t].model===e);else if("string"!=typeof e)throw new Error(`invalid tieToRemove parameter ${e}`);this._ties[t]&&(delete this._ties[t],this._dti.views.deleteTieViews(t))}static validateTieKey(e){if(!e||"string"!=typeof e)throw new Error(`invalid key '${e}'`);if(!r.test(e))throw new Error(`tie key MUST match ${r}; '${e}' doesn't`);if(a.indexOf(e)>=0)throw new Error(`tie key MUST NOT be one of those: ${a.join(", ")}`)}};

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

import{Observable as t}from"./object-observer.min.js";const e="defaultTieTarget",n="changeEventName",r=/\s*=>\s*/,i=/\s*[,;]\s*/,o={INPUT:1,SELECT:1,TEXTAREA:1},s={IMG:1,IFRAME:1,SOURCE:1},l={A:1,ANIMATE:1,AREA:1,BASE:1,DISCARD:1,IMAGE:1,LINK:1,PATTERN:1,use:1},a={INPUT:1,SELECT:1,TEXTAREA:1},c="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",u=c.length;export{e as DEFAULT_TIE_TARGET_PROVIDER,h as ensureObservable,p as getTargetProperty,d as extractViewParams,n as CHANGE_EVENT_NAME_PROVIDER,E as addChangeListener,A as delChangeListener,v as getPath,T as setPath,w as callViewFunction,P as getRandomKey};class f{constructor(t,e,n,r,i,o){this.tieKey=t,this.rawPath=e,this.path=n,this.targetProperty=r,this.isFunctional=i,this.fParams=o,this.iClasses=null}}function h(e){return e?t.isObservable(e)?e:t.from(e):t.from({})}function p(t){let n=t[e];if(!n){const e=t.nodeName;n="INPUT"===e&&"checkbox"===t.type?"checked":e in o?"value":e in s?"src":e in l?"href":"textContent"}return n}function d(t){const e=t.getAttribute("data-tie");if(e){const n=function(t,e){const n=[],r={},o=t.split(i),s=o.length;let l,a,c,u=0;for(;u<s;u++)if((l=o[u])&&(a&&(a+=","+l),!(l.indexOf("(")>0&&(a=l).indexOf(")")<0)))try{a?(c=g(a),a=null):c=m(l,e),c.targetProperty in r?console.error(`elements's property '${c.targetProperty}' tied more than once; all but first dismissed`):(n.push(c),r[c.targetProperty]=!0)}catch(t){console.error(`failed to parse one of a multi param parts (${l}), skipping it`,t)}return n}(e,t);return n.length?n:null}return null}function g(t){const e=t.split(/[()]/),n=e[1].split(/\s*,\s*/).map(t=>{const e=t.split(":");if(!e.length||e.length>2||!e[0])throw new Error("invalid function tied value: "+t);const n=e.length>1?e[1]:"";return{tieKey:e[0],rawPath:n,path:n.split(".").filter(t=>t)}});if(!n.length)throw new Error(`functional tie parameter MUST have at least one tied argument, '${t}' doesn't`);return new f(null,null,null,e[0],!0,n)}function m(t,e){const n=t.split(r);1===n.length&&n.push(p(e));const i=n[0].split(":");if(!i.length||i.length>2||!i[0])throw new Error(`invalid tie parameter '${t}'; expected (example): "orders:0.address.street, orders:0.address.apt => title"`);let o=i[0];const s=i.length>1?i[1]:"",l=new f(o,s,s.split(".").filter(t=>t),n[1],!1,null);return"classList"===l.targetProperty&&(l.iClasses=Array.from(e.classList)),l}function E(t,e){const n=y(t);n&&t.addEventListener(n,e)}function A(t,e){const n=y(t);n&&t.removeEventListener(n,e)}function y(t){let e=t[n];return e||t.nodeName in a&&(e="change"),e}function v(t,e){if(!t)return null;const n=e,r=n.length;if(!r)return t;let i,o=t,s=0;for(;s<r-1;s++)if(null===(o=o[i=n[s]])||void 0===o)return o;return o[n[s]]}function T(t,e,n){if(!t)return;const r=e.length;let i,o,s=0;for(;s<r-1;s++)if((o=t[i=e[s]])&&"object"==typeof o)t=o;else if(void 0===o||null===o)t[i]={},t=t[i];else if("object"!=typeof o)return void console.error("setting deep path MAY NOT override primitives along the way");t[e[s]]=n}function w(t,e,n){try{t[e].apply(t,n)}catch(r){console.error(`failed to call '${e}' of '${t}' with '${n}'`,r)}}function P(t){let e="",n=t;const r=crypto.getRandomValues(new Uint8Array(t));for(;n--;)e+=c.charAt(u*r[n]/256);return e}
const t=/\s*[,;]\s*/,e=/\s*=>\s*/,r={A:"href",ANIMATE:"href",AREA:"href",BASE:"href",DISCARD:"href",IMAGE:"href",LINK:"href",PATTERN:"href",use:"href",INPUT:"value",SELECT:"value",TEXTAREA:"value",IFRAME:"src",IMG:"src",SOURCE:"src"},n=["INPUT","SELECT","TEXTAREA"],i="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",o=i.length;export{l as extractViewParams,f as getPath,h as setPath,p as callViewFunction,d as getRandomKey};export{r as DEFAULT_TARGET,n as DEFAULT_EVENTS_CHANGE};class s{constructor(t,e,r,n,i,o,s){this.tieKey=t,this.rawPath=e,this.path=r,this.targetProperty=n,this.changeEvent=i,this.isFunctional=o,this.fParams=s,this.iClasses=null}}function l(e){const r=e.getAttribute("data-tie");if(r){const n=function(e,r){const n=[],i={},o=e.trim().split(t),s=o.length;let l,u,f,h=0;for(;h<s;h++)if((l=o[h])&&(u&&(u+=","+l),!(l.indexOf("(")>0&&(u=l).indexOf(")")<0)))try{u?(f=a(u),u=null):f=c(l,r),f.targetProperty in i?console.error(`elements's property '${f.targetProperty}' tied more than once; all but first tie dismissed`):(n.push(f),i[f.targetProperty]=!0)}catch(t){console.error(`failed to parse one of a multi param parts (${l}), skipping it`,t)}return n}(r,e);return n.length?n:null}return null}function a(t){const[e,r]=t.split(/[()]/),n=r.trim().split(/\s*,\s*/).map(u);if(!n.length)throw new Error(`functional tie parameter MUST have at least one tied argument, '${t}' doesn't`);return new s(null,null,null,e,null,!0,n)}function c(t,i){let[o,l,a]=t.split(e);const{tieKey:c,rawPath:f,path:h}=u(o);l=l||function(t){let e=r[t.nodeName];e?"checkbox"===t.type&&(e="checked"):e="textContent";return e}(i),a=a||function(t){let e=null;n.includes(t.nodeName)&&(e="change");return e}(i);const p=new s(c,f,h,l,a,!1,null);return"classList"===l&&(p.iClasses=Array.from(i.classList)),p}function u(t){const[e,r=""]=t.split(":");if(!e)throw new Error(`tie key missing in tie parameter '${t}'; expected example: "orders:0.address.apt => title"`);return{tieKey:e,rawPath:r,path:r.split(".").filter(Boolean)}}function f(t,e){if(!t)return t;const r=e,n=r.length;if(!n)return t;let i,o=t,s=0;for(;s<n;s++)if(null===(o=o[i=r[s]])||void 0===o)return o;return o}function h(t,e,r){if(!t)return;const n=e.length;let i,o,s=0;for(;s<n-1;s++)if((o=t[i=e[s]])&&"object"==typeof o)t=o;else if(void 0===o||null===o)t[i]={},t=t[i];else if("object"!=typeof o)return void console.error("setting deep path MAY NOT override primitives along the way");t[e[s]]=r}function p(t,e,r){try{t[e].apply(t,r)}catch(n){console.error(`failed to call '${e}' of '${t}' with '${r}'`,n)}}function d(t){let e="",r=t;const n=crypto.getRandomValues(new Uint8Array(t));for(;r--;)e+=i.charAt(o*n[r]/256);return e}

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

import{extractViewParams as e,getRandomKey as t}from"./utils.min.js";export class Views{constructor(e){this.dti=e,this.views={},this.scopes={},this.unscoped=[]}obtainTieViews(e){return this.views[e]||(this.views[e]={_pathsCache:[]})}deleteTieViews(e){delete this.views[e]}addView(t){const s=e(t);if(!s)return null;let i,o,r,n,h=s.length;for(;h--;)if((i=s[h]).isFunctional)for(n=(o=i.fParams).length;n--;)r=o[n],this._seekAndInsertView(r,t);else this._seekAndInsertView(i,t);return t[this.dti.paramsKey]=s,s}delView(e,t){let s,i,o,r,n=t.length;for(;n--;)if((s=t[n]).isFunctional)for(r=(i=s.fParams).length;r--;)o=i[r],this._seekAndRemoveView(o,e);else this._seekAndRemoveView(s,e);delete e[this.dti.paramsKey]}addScope(e){let s=e.getAttribute("data-tie-scope");if(s){if(s in this.scopes&&this.scopes[s]!==e)throw new Error(`scope key '${s} already claimed by another element`);if(this.scopes[s]!==e){this.scopes[s]=e;for(const t of this.unscoped)e.contains(t)&&(this.addView(t),this.unscoped.splice(this.unscoped.indexOf(t),1))}}else e.setAttribute("data-tie-scope",t(16))}delScope(){throw new Error("not implemented")}_seekAndInsertView(e,t){let s=e.tieKey;if("scope"===s){if(!(s=this._lookupClosestScopeKey(t)))return void this.unscoped.push(t);e.tieKey=s}const i=e.rawPath,o=this.obtainTieViews(s);let r=o[i];r||(r=[],o[i]=r,o._pathsCache.push(i)),r.indexOf(t)<0&&r.push(t)}_seekAndRemoveView(e,t){const s=e.tieKey,i=e.rawPath,o=this.views[s];if(o){const e=o[i];if(e){const s=e.indexOf(t);s>=0&&e.splice(s,1)}}}setViewProperty(e,t,s){const i=t.targetProperty;try{this._unsafeSetProperty(e,t,s,i)}catch(t){console.error(`failed to set '${i}' of '${e}' to '${s}'`,t)}}_unsafeSetProperty(e,t,s,i){if("href"===i&&"object"==typeof e.href)e.href.baseVal=s;else if("scope"===i)this.dti.ties.update(e,s);else if("classList"===i){const i=t.iClasses.slice(0);s&&(Array.isArray(s)&&s.length?s.forEach(e=>{i.indexOf(e)<0&&i.push(e)}):"object"==typeof s?Object.keys(s).forEach(e=>{const t=i.indexOf(e);s[e]?t<0&&i.push(e):t>=0&&i.splice(t,1)}):"string"==typeof s&&i.indexOf(s)<0&&i.push(s)),e.className=i.join(" ")}else e[i]=s}_lookupClosestScopeKey(e){let t,s=e;do{(t=s.getAttribute("data-tie-scope"))||(s=s.parentNode).host&&(s=s.host)}while(!t&&s&&s.nodeType!==Node.DOCUMENT_NODE);return t}};
import{extractViewParams as e,getRandomKey as t}from"./utils.min.js";export class Views{constructor(e){this.dti=e,this.views={},this.scopes={},this.unscoped=[]}obtainTieViews(e){return this.views[e]||(this.views[e]={_pathsCache:[]})}deleteTieViews(e){delete this.views[e]}addView(t){const s=e(t);if(!s)return null;let i,o,n,r,h=s.length;for(;h--;)if((i=s[h]).isFunctional)for(r=(o=i.fParams).length;r--;)n=o[r],this._seekAndInsertView(n,t);else this._seekAndInsertView(i,t);return t[this.dti.paramsKey]=s,s}delView(e,t){let s,i,o,n,r=t.length;for(;r--;)if((s=t[r]).isFunctional)for(n=(i=s.fParams).length;n--;)o=i[n],this._seekAndRemoveView(o,e);else this._seekAndRemoveView(s,e);delete e[this.dti.paramsKey]}addScope(e){let s=e.getAttribute("data-tie-scope");if(s){if(s in this.scopes&&this.scopes[s]!==e)throw new Error(`scope key '${s} already claimed by another element`);if(this.scopes[s]!==e){this.scopes[s]=e;for(const t of this.unscoped)e.contains(t)&&(this.addView(t),this.unscoped.splice(this.unscoped.indexOf(t),1))}}else e.setAttribute("data-tie-scope",t(16))}delScope(){throw new Error("not implemented")}_seekAndInsertView(e,t){let s=e.tieKey;if("scope"===s){if(!(s=this._lookupClosestScopeKey(t)))return void this.unscoped.push(t);e.tieKey=s}const i=e.rawPath,o=this.obtainTieViews(s);let n=o[i];n||(n=[],o[i]=n,o._pathsCache.push(i)),n.indexOf(t)<0&&n.push(t)}_seekAndRemoveView(e,t){const s=e.tieKey,i=e.rawPath,o=this.views[s];if(o){const e=o[i];if(e){const s=e.indexOf(t);s>=0&&e.splice(s,1)}}}_lookupClosestScopeKey(e){let t,s=e;do{(t=s.getAttribute("data-tie-scope"))||(s=s.parentNode).host&&(s=s.host)}while(!t&&s&&s.nodeType!==Node.DOCUMENT_NODE);return t}setViewProperty(e,t,s){const i=t.targetProperty;try{this._unsafeSetProperty(e,t,s,i)}catch(t){console.error(`failed to set '${i}' of '${e}' to '${s}'`,t)}}_unsafeSetProperty(e,t,s,i){if("textContent"===i)this._setTextContentProperty(e,s);else if("value"===i)this._setValueProperty(e,s);else if("href"===i&&"object"==typeof e.href)e.href.baseVal=s;else if("scope"===i)this.dti.ties.update(e,s);else if("classList"===i){const i=t.iClasses.slice(0);s&&(Array.isArray(s)&&s.length?s.forEach(e=>{i.indexOf(e)<0&&i.push(e)}):"object"==typeof s?Object.keys(s).forEach(e=>{const t=i.indexOf(e);s[e]?t<0&&i.push(e):t>=0&&i.splice(t,1)}):"string"==typeof s&&i.indexOf(s)<0&&i.push(s)),e.className=i.join(" ")}else e[i]=s}_setTextContentProperty(e,t){e.textContent=void 0===t||null===t?"":t}_setValueProperty(e,t){let s=t;if(void 0===t||null===t){const t=e.nodeName;"INPUT"!==t&&"SELECT"!==t&&"TEXTAREA"!==t||(s="")}e.value=s}};
{
"name": "data-tier-list",
"version": "1.2.0",
"version": "1.2.1",
"description": "List component based on DataTier binding engine",

@@ -28,3 +28,3 @@ "keywords": [

},
"license": "MIT",
"license": "ISC",
"files": [

@@ -48,14 +48,15 @@ "dist"

"lint": "eslint -c ./ci/.eslintrc.json ./src/*.js ./tests/*.js ./ci/**/*.js",
"test": "node ./node_modules/just-test/dist/tests-runner/run-tests.js --config=./tests/tests-runner-config.json"
"test": "node ./node_modules/just-test/dist/tests-runner/run-tests.js --config=./tests/tests-runner-config.json",
"bump": "node ./ci/tools/version-utils.js"
},
"dependencies": {
"data-tier": "^2.11.1"
"data-tier": "^3.1.6"
},
"devDependencies": {
"eslint": "^7.13.0",
"fs-extra": "^9.0.1",
"eslint": "^7.25.0",
"fs-extra": "^9.1.0",
"uglify-es": "^3.3.9",
"just-test": "2.3.2",
"puppeteer": "^5.5.0"
"puppeteer": "^9.0.0"
}
}

@@ -5,7 +5,7 @@ [![NPM](https://img.shields.io/npm/v/data-tier-list.svg?label=npm%20data-tier-list)](https://www.npmjs.com/package/data-tier-list)

[![Travis](https://img.shields.io/travis/gullerya/data-tier-list.svg)](https://travis-ci.org/gullerya/data-tier-list)
![Quality pipeline](https://github.com/gullerya/data-tier-list/workflows/Quality%20pipeline/badge.svg)
[![Codecov](https://img.shields.io/codecov/c/github/gullerya/data-tier-list/master.svg)](https://codecov.io/gh/gullerya/data-tier-list/branch/master)
[![Codacy](https://img.shields.io/codacy/grade/056de1a3a7c740678d517a0ee0b41b4f.svg?logo=codacy)](https://app.codacy.com/app/gullerya/data-tier-list)
# Summary
# `data-tier-list`

@@ -15,22 +15,43 @@ `data-tier-list` is a WebComponent, that provides repetative view functionality given any HTML template and a data set.

Main features and concepts:
* supported data set types: `Array`, `Object`
* if a provided data set is is not an [observable](https://github.com/gullerya/object-observer/blob/master/docs/observable.md), it is transformed (cloned) into such one
* data set mutations are observed and reflected
* template mutations are observed and reflected
* uniformity of a data items **is not** validated/enforced
- supported data set types: `Array`, `Object`
- if a provided data set is is not an [observable](https://github.com/gullerya/object-observer/blob/master/docs/observable.md), it is transformed (cloned) into such one
- data set mutations are observed and reflected
- template mutations are observed and reflected
- uniformity of a data items **is not** validated/enforced
`data-tier-list` relies on a [data-tier](https://github.com/gullerya/data-tier) library for the model-view tying part.
# APIs and conditions
#### Changelog is [here](docs/changelog.md)
* `data-tier-list` element self and it's light DOM **are not** displayed
## Preview
* light DOM of the `data-tier-list` is taken as an **template** for a single item
* template is observed for any changes; replacement of it or a change of its child/ren triggers a **full (re)render** of the list
* template may have **at most** one top level element (any nested elements tree allowed)
* template removal cleans the list
* template error (eg more than one child) throws, list remains untouched
For a preview/playground you are welcome to:
TBD
# Latest changelog
## Install
TBD
Use regular `npm install data-tier-list --save-prod` to use the library from your local environment:
```js
import 'node_modules/data-tier-list/dist/data-tier-list.min.js';
```
Alternatively, a __CDN__ deployment available (AWS driven), so one can import it directly:
```js
import 'https://libs.gullerya.com/data-tier-list/x.y.z/data-tier-list.min.js';
```
> Note: replace the `x.y.z` by the desired version, one of the listed in the [changelog](docs/changelog.md).
CDN features:
- HTTPS only, no untrusted man-in-the-middle
- highly available (with many geo spread edges)
- agressive caching setup
## API
- `data-tier-list` element self and it's light DOM __are not__ displayed
- light DOM of the `data-tier-list` is taken as a __template__ for a single item
- template is observed for any changes; replacement of it or a change of its child/ren triggers a __full (re)render__ of the list
- template may have __at most__ one top level element (any nested elements tree allowed)
- template removal cleans the list
- template error (eg more than one child) throws, list remains untouched
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