Comparing version 7.0.1 to 7.1.0
@@ -249,2 +249,4 @@ import { Assignable } from "vis-util/esnext"; | ||
length: number; | ||
/** The key of id property. */ | ||
idProp: IdProp; | ||
/** | ||
@@ -251,0 +253,0 @@ * Add a universal event listener. |
@@ -97,2 +97,4 @@ import { DataInterface, DataInterfaceForEachOptions, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DeepPartial, FullItem, Id, PartItem, UpdateItem } from "./data-interface"; | ||
length: number; | ||
/** @inheritDoc */ | ||
get idProp(): IdProp; | ||
/** | ||
@@ -99,0 +101,0 @@ * @param options - DataSet configuration. |
@@ -68,2 +68,4 @@ import { DataInterface, DataInterfaceForEachOptions, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, FullItem, Id, PartItem } from "./data-interface"; | ||
length: number; | ||
/** @inheritDoc */ | ||
get idProp(): IdProp; | ||
/** | ||
@@ -70,0 +72,0 @@ * Create a DataView. |
export { DataInterface, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DataInterfaceOrder, EventCallbacks, EventCallbacksWithAny, EventName, EventNameWithAny, } from "./data-interface"; | ||
export * from "./data-pipe"; | ||
export { DELETE } from "vis-util/esnext"; | ||
export { DataSet, DataSetOptions } from "./data-set"; | ||
@@ -7,3 +8,4 @@ export { DataStream } from "./data-stream"; | ||
export { Queue } from "./queue"; | ||
export { DELETE } from "vis-util/esnext"; | ||
export { isDataSetLike } from "./data-set-check"; | ||
export { isDataViewLike } from "./data-view-check"; | ||
//# sourceMappingURL=entry-esnext.d.ts.map |
@@ -7,4 +7,4 @@ /** | ||
* | ||
* @version 7.0.1 | ||
* @date 2020-10-13T17:07:07.867Z | ||
* @version 7.1.0 | ||
* @date 2020-10-13T20:44:00.711Z | ||
* | ||
@@ -27,3 +27,3 @@ * @copyright (c) 2011-2017 Almende B.V, http://almende.com | ||
*/ | ||
import{v4 as t}from"uuid";import{pureDeepObjectAssign as e}from"vis-util/esnext/esm/vis-util.js";export{DELETE}from"vis-util/esnext/esm/vis-util.js"; | ||
import{pureDeepObjectAssign as t}from"vis-util/esnext/esm/vis-util.js";export{DELETE}from"vis-util/esnext/esm/vis-util.js";import{v4 as e}from"uuid"; | ||
/*! ***************************************************************************** | ||
@@ -42,3 +42,3 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function s(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function r(t,e,s){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,s),s}var i,n,o,h,l,a,u,d,f,c,p,g,m,y;function _(t){return new v(t)}class w{constructor(t,e,s){this._source=t,this._transformers=e,this._target=s,this._listeners={add:this._add.bind(this),remove:this._remove.bind(this),update:this._update.bind(this)}}all(){return this._target.update(this._transformItems(this._source.get())),this}start(){return this._source.on("add",this._listeners.add),this._source.on("remove",this._listeners.remove),this._source.on("update",this._listeners.update),this}stop(){return this._source.off("add",this._listeners.add),this._source.off("remove",this._listeners.remove),this._source.off("update",this._listeners.update),this}_transformItems(t){return this._transformers.reduce(((t,e)=>e(t)),t)}_add(t,e){null!=e&&this._target.add(this._transformItems(this._source.get(e.items)))}_update(t,e){null!=e&&this._target.update(this._transformItems(this._source.get(e.items)))}_remove(t,e){null!=e&&this._target.remove(this._transformItems(e.oldData))}}class v{constructor(t){this._source=t,i.set(this,[])}filter(t){return s(this,i).push((e=>e.filter(t))),this}map(t){return s(this,i).push((e=>e.map(t))),this}flatMap(t){return s(this,i).push((e=>e.flatMap(t))),this}to(t){return new w(this._source,s(this,i),t)}}function b(t){return"string"==typeof t||"number"==typeof t}i=new WeakMap;class I{constructor(t){n.set(this,[]),o.set(this,null),h.set(this,null),this.delay=null,this.max=1/0,this.setOptions(t)}setOptions(t){t&&void 0!==t.delay&&(this.delay=t.delay),t&&void 0!==t.max&&(this.max=t.max),this._flushIfNeeded()}static extend(t,e){const s=new I(e);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=()=>{s.flush()};const i=[{name:"flush",original:void 0}];if(e&&e.replace)for(let r=0;r<e.replace.length;r++){const n=e.replace[r];i.push({name:n,original:t[n]}),s.replace(t,n)}return r(s,h,{object:t,methods:i}),s}destroy(){if(this.flush(),s(this,h)){const t=s(this,h).object,e=s(this,h).methods;for(let s=0;s<e.length;s++){const r=e[s];r.original?t[r.name]=r.original:delete t[r.name]}r(this,h,null)}}replace(t,e){const s=this,r=t[e];if(!r)throw new Error("Method "+e+" undefined");t[e]=function(...t){s.queue({args:t,fn:r,context:this})}}queue(t){"function"==typeof t?s(this,n).push({fn:t}):s(this,n).push(t),this._flushIfNeeded()}_flushIfNeeded(){s(this,n).length>this.max&&this.flush(),null!=s(this,o)&&(clearTimeout(s(this,o)),r(this,o,null)),this.queue.length>0&&"number"==typeof this.delay&&r(this,o,setTimeout((()=>{this.flush()}),this.delay))}flush(){s(this,n).splice(0).forEach((t=>{t.fn.apply(t.context||t.fn,t.args||[])}))}}n=new WeakMap,o=new WeakMap,h=new WeakMap;class k{constructor(){l.set(this,{"*":[],add:[],remove:[],update:[]}),this.subscribe=k.prototype.on,this.unsubscribe=k.prototype.off}_trigger(t,e,r){if("*"===t)throw new Error("Cannot trigger event *");[...s(this,l)[t],...s(this,l)["*"]].forEach((s=>{s(t,e,null!=r?r:null)}))}on(t,e){"function"==typeof e&&s(this,l)[t].push(e)}off(t,e){s(this,l)[t]=s(this,l)[t].filter((t=>t!==e))}}l=new WeakMap;class E{constructor(t){a.set(this,void 0),r(this,a,t)}*[(a=new WeakMap,Symbol.iterator)](){for(const[t,e]of s(this,a))yield[t,e]}*entries(){for(const[t,e]of s(this,a))yield[t,e]}*keys(){for(const[t]of s(this,a))yield t}*values(){for(const[,t]of s(this,a))yield t}toIdArray(){return[...s(this,a)].map((t=>t[0]))}toItemArray(){return[...s(this,a)].map((t=>t[1]))}toEntryArray(){return[...s(this,a)]}toObjectMap(){const t=Object.create(null);for(const[e,r]of s(this,a))t[e]=r;return t}toMap(){return new Map(s(this,a))}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new E([...s(this,a)])}distinct(t){const e=new Set;for(const[r,i]of s(this,a))e.add(t(i,r));return e}filter(t){const e=s(this,a);return new E({*[Symbol.iterator](){for(const[s,r]of e)t(r,s)&&(yield[s,r])}})}forEach(t){for(const[e,r]of s(this,a))t(r,e)}map(t){const e=s(this,a);return new E({*[Symbol.iterator](){for(const[s,r]of e)yield[s,t(r,s)]}})}max(t){const e=s(this,a)[Symbol.iterator]();let r=e.next();if(r.done)return null;let i=r.value[1],n=t(r.value[1],r.value[0]);for(;!(r=e.next()).done;){const[e,s]=r.value,o=t(s,e);o>n&&(n=o,i=s)}return i}min(t){const e=s(this,a)[Symbol.iterator]();let r=e.next();if(r.done)return null;let i=r.value[1],n=t(r.value[1],r.value[0]);for(;!(r=e.next()).done;){const[e,s]=r.value,o=t(s,e);o<n&&(n=o,i=s)}return i}reduce(t,e){for(const[r,i]of s(this,a))e=t(e,i,r);return e}sort(t){return new E({[Symbol.iterator]:()=>[...s(this,a)].sort((([e,s],[r,i])=>t(s,i,e,r)))[Symbol.iterator]()})}}class x extends k{constructor(t,e){super(),u.set(this,void 0),d.set(this,void 0),f.set(this,void 0),c.set(this,null),t&&!Array.isArray(t)&&(e=t,t=[]),r(this,u,e||{}),r(this,d,new Map),this.length=0,r(this,f,s(this,u).fieldId||"id"),t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?s(this,c)&&(s(this,c).destroy(),r(this,c,null)):(s(this,c)||r(this,c,I.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&s(this,c).setOptions(t.queue)))}add(t,e){const r=[];let i;if(Array.isArray(t)){if(t.map((t=>t[s(this,f)])).some((t=>s(this,d).has(t))))throw new Error("A duplicate id was found in the parameter array.");for(let e=0,s=t.length;e<s;e++)i=this._addItem(t[e]),r.push(i)}else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");i=this._addItem(t),r.push(i)}return r.length&&this._trigger("add",{items:r},e),r}update(t,e){const r=[],i=[],n=[],o=[],h=s(this,f),l=t=>{const e=t[h];if(null!=e&&s(this,d).has(e)){const r=t,h=Object.assign({},s(this,d).get(e)),l=this._updateItem(r);i.push(l),o.push(r),n.push(h)}else{const e=this._addItem(t);r.push(e)}};if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]&&"object"==typeof t[e]?l(t[e]):console.warn("Ignoring input item, which is not an object at index "+e);else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");l(t)}if(r.length&&this._trigger("add",{items:r},e),i.length){const t={items:i,oldData:n,data:o};this._trigger("update",t,e)}return r.concat(i)}updateOnly(t,r){Array.isArray(t)||(t=[t]);const i=t.map((t=>{const e=s(this,d).get(t[s(this,f)]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}})).map((({oldData:t,update:r})=>{const i=t[s(this,f)],n=e(t,r);return s(this,d).set(i,n),{id:i,oldData:t,updatedData:n}}));if(i.length){const t={items:i.map((t=>t.id)),oldData:i.map((t=>t.oldData)),data:i.map((t=>t.updatedData))};return this._trigger("update",t,r),t.items}return[]}get(t,e){let r=void 0,i=void 0,n=void 0;b(t)?(r=t,n=e):Array.isArray(t)?(i=t,n=e):n=t;const o=n&&"Object"===n.returnType?"Object":"Array",h=n&&n.filter,l=[];let a=void 0,u=void 0,c=void 0;if(null!=r)a=s(this,d).get(r),a&&h&&!h(a)&&(a=void 0);else if(null!=i)for(let t=0,e=i.length;t<e;t++)a=s(this,d).get(i[t]),null==a||h&&!h(a)||l.push(a);else{u=[...s(this,d).keys()];for(let t=0,e=u.length;t<e;t++)c=u[t],a=s(this,d).get(c),null==a||h&&!h(a)||l.push(a)}if(n&&n.order&&null==r&&this._sort(l,n.order),n&&n.fields){const t=n.fields;if(null!=r&&null!=a)a=this._filterFields(a,t);else for(let e=0,s=l.length;e<s;e++)l[e]=this._filterFields(l[e],t)}if("Object"==o){const t={};for(let e=0,r=l.length;e<r;e++){const r=l[e];t[r[s(this,f)]]=r}return t}return null!=r?null!=a?a:null:l}getIds(t){const e=s(this,d),r=t&&t.filter,i=t&&t.order,n=[...e.keys()],o=[];if(r)if(i){const t=[];for(let e=0,i=n.length;e<i;e++){const i=n[e],o=s(this,d).get(i);null!=o&&r(o)&&t.push(o)}this._sort(t,i);for(let e=0,r=t.length;e<r;e++)o.push(t[e][s(this,f)])}else for(let t=0,e=n.length;t<e;t++){const e=n[t],i=s(this,d).get(e);null!=i&&r(i)&&o.push(i[s(this,f)])}else if(i){const t=[];for(let s=0,r=n.length;s<r;s++){const r=n[s];t.push(e.get(r))}this._sort(t,i);for(let e=0,r=t.length;e<r;e++)o.push(t[e][s(this,f)])}else for(let t=0,r=n.length;t<r;t++){const r=n[t],i=e.get(r);null!=i&&o.push(i[s(this,f)])}return o}getDataSet(){return this}forEach(t,e){const r=e&&e.filter,i=[...s(this,d).keys()];if(e&&e.order){const r=this.get(e);for(let e=0,i=r.length;e<i;e++){const i=r[e];t(i,i[s(this,f)])}}else for(let e=0,n=i.length;e<n;e++){const n=i[e],o=s(this,d).get(n);null==o||r&&!r(o)||t(o,n)}}map(t,e){const r=e&&e.filter,i=[],n=[...s(this,d).keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],h=s(this,d).get(o);null==h||r&&!r(h)||i.push(t(h,o))}return e&&e.order&&this._sort(i,e.order),i}_filterFields(t,e){return t?(Array.isArray(e)?e:Object.keys(e)).reduce(((e,s)=>(e[s]=t[s],e)),{}):t}_sort(t,e){if("string"==typeof e){const s=e;t.sort(((t,e)=>{const r=t[s],i=e[s];return r>i?1:r<i?-1:0}))}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}}remove(t,e){const r=[],i=[],n=Array.isArray(t)?t:[t];for(let t=0,e=n.length;t<e;t++){const e=this._remove(n[t]);if(e){const t=e[s(this,f)];null!=t&&(r.push(t),i.push(e))}}return r.length&&this._trigger("remove",{items:r,oldData:i},e),r}_remove(t){let e;if(b(t)?e=t:t&&"object"==typeof t&&(e=t[s(this,f)]),null!=e&&s(this,d).has(e)){const t=s(this,d).get(e)||null;return s(this,d).delete(e),--this.length,t}return null}clear(t){const e=[...s(this,d).keys()],r=[];for(let t=0,i=e.length;t<i;t++)r.push(s(this,d).get(e[t]));return s(this,d).clear(),this.length=0,this._trigger("remove",{items:e,oldData:r},t),e}max(t){let e=null,r=null;for(const i of s(this,d).values()){const s=i[t];"number"==typeof s&&(null==r||s>r)&&(e=i,r=s)}return e||null}min(t){let e=null,r=null;for(const i of s(this,d).values()){const s=i[t];"number"==typeof s&&(null==r||s<r)&&(e=i,r=s)}return e||null}distinct(t){const e=s(this,d),r=[...e.keys()],i=[];let n=0;for(let s=0,o=r.length;s<o;s++){const o=r[s],h=e.get(o)[t];let l=!1;for(let t=0;t<n;t++)if(i[t]==h){l=!0;break}l||void 0===h||(i[n]=h,n++)}return i}_addItem(e){const r=function(e,s){return null==e[s]&&(e[s]=t()),e}(e,s(this,f)),i=r[s(this,f)];if(s(this,d).has(i))throw new Error("Cannot add item: item with id "+i+" already exists");return s(this,d).set(i,r),++this.length,i}_updateItem(t){const e=t[s(this,f)];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const r=s(this,d).get(e);if(!r)throw new Error("Cannot update item: no item with id "+e+" found");return s(this,d).set(e,{...r,...t}),e}stream(t){if(t){const e=s(this,d);return new E({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new E({[Symbol.iterator]:s(this,d).entries.bind(s(this,d))})}}u=new WeakMap,d=new WeakMap,f=new WeakMap,c=new WeakMap;class D extends k{constructor(t,e){super(),this.length=0,p.set(this,void 0),g.set(this,void 0),m.set(this,new Set),y.set(this,void 0),r(this,y,e||{}),r(this,p,this._onEvent.bind(this)),this.setData(t)}setData(t){if(s(this,g)){s(this,g).off&&s(this,g).off("*",s(this,p));const t=s(this,g).getIds({filter:s(this,y).filter}),e=s(this,g).get(t);s(this,m).clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){r(this,g,t);const e=s(this,g).getIds({filter:s(this,y).filter});for(let t=0,r=e.length;t<r;t++){const r=e[t];s(this,m).add(r)}this.length=e.length,this._trigger("add",{items:e})}else r(this,g,new x);s(this,g).on&&s(this,g).on("*",s(this,p))}refresh(){const t=s(this,g).getIds({filter:s(this,y).filter}),e=[...s(this,m)],r={},i=[],n=[],o=[];for(let e=0,n=t.length;e<n;e++){const n=t[e];r[n]=!0,s(this,m).has(n)||(i.push(n),s(this,m).add(n))}for(let t=0,i=e.length;t<i;t++){const i=e[t],h=s(this,g).get(i);null==h?console.error("If you see this, report it please."):r[i]||(n.push(i),o.push(h),s(this,m).delete(i))}this.length+=i.length-n.length,i.length&&this._trigger("add",{items:i}),n.length&&this._trigger("remove",{items:n,oldData:o})}get(t,e){if(null==s(this,g))return null;let r,i=null;b(t)||Array.isArray(t)?(i=t,r=e):r=t;const n=Object.assign({},s(this,y),r),o=s(this,y).filter,h=r&&r.filter;return o&&h&&(n.filter=t=>o(t)&&h(t)),null==i?s(this,g).get(n):s(this,g).get(i,n)}getIds(t){if(s(this,g).length){const e=s(this,y).filter,r=null!=t?t.filter:null;let i;return i=r?e?t=>e(t)&&r(t):r:e,s(this,g).getIds({filter:i,order:t&&t.order})}return[]}forEach(t,e){if(s(this,g)){const r=s(this,y).filter,i=e&&e.filter;let n;n=i?r?function(t){return r(t)&&i(t)}:i:r,s(this,g).forEach(t,{filter:n,order:e&&e.order})}}map(t,e){if(s(this,g)){const r=s(this,y).filter,i=e&&e.filter;let n;return n=i?r?t=>r(t)&&i(t):i:r,s(this,g).map(t,{filter:n,order:e&&e.order})}return[]}getDataSet(){return s(this,g).getDataSet()}stream(t){return s(this,g).stream(t||{[Symbol.iterator]:s(this,m).keys.bind(s(this,m))})}dispose(){var t;(null===(t=s(this,g))||void 0===t?void 0:t.off)&&s(this,g).off("*",s(this,p));const e="This data view has already been disposed of.",r={get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1};for(const t of Reflect.ownKeys(D.prototype))Object.defineProperty(this,t,r)}_onEvent(t,e,r){if(!e||!e.items||!s(this,g))return;const i=e.items,n=[],o=[],h=[],l=[],a=[],u=[];switch(t){case"add":for(let t=0,e=i.length;t<e;t++){const e=i[t];this.get(e)&&(s(this,m).add(e),n.push(e))}break;case"update":for(let t=0,r=i.length;t<r;t++){const r=i[t];this.get(r)?s(this,m).has(r)?(o.push(r),a.push(e.data[t]),l.push(e.oldData[t])):(s(this,m).add(r),n.push(r)):s(this,m).has(r)&&(s(this,m).delete(r),h.push(r),u.push(e.oldData[t]))}break;case"remove":for(let t=0,r=i.length;t<r;t++){const r=i[t];s(this,m).has(r)&&(s(this,m).delete(r),h.push(r),u.push(e.oldData[t]))}}this.length+=n.length-h.length,n.length&&this._trigger("add",{items:n},r),o.length&&this._trigger("update",{items:o,oldData:l,data:a},r),h.length&&this._trigger("remove",{items:h,oldData:u},r)}}p=new WeakMap,g=new WeakMap,m=new WeakMap,y=new WeakMap;export{x as DataSet,E as DataStream,D as DataView,I as Queue,_ as createNewDataPipeFrom}; | ||
***************************************************************************** */function s(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function i(t,e,s){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,s),s}var r,n,o,h,l,a,u,f,d,c,p,g,m,y;function _(t){return new v(t)}class w{constructor(t,e,s){this._source=t,this._transformers=e,this._target=s,this._listeners={add:this._add.bind(this),remove:this._remove.bind(this),update:this._update.bind(this)}}all(){return this._target.update(this._transformItems(this._source.get())),this}start(){return this._source.on("add",this._listeners.add),this._source.on("remove",this._listeners.remove),this._source.on("update",this._listeners.update),this}stop(){return this._source.off("add",this._listeners.add),this._source.off("remove",this._listeners.remove),this._source.off("update",this._listeners.update),this}_transformItems(t){return this._transformers.reduce(((t,e)=>e(t)),t)}_add(t,e){null!=e&&this._target.add(this._transformItems(this._source.get(e.items)))}_update(t,e){null!=e&&this._target.update(this._transformItems(this._source.get(e.items)))}_remove(t,e){null!=e&&this._target.remove(this._transformItems(e.oldData))}}class v{constructor(t){this._source=t,r.set(this,[])}filter(t){return s(this,r).push((e=>e.filter(t))),this}map(t){return s(this,r).push((e=>e.map(t))),this}flatMap(t){return s(this,r).push((e=>e.flatMap(t))),this}to(t){return new w(this._source,s(this,r),t)}}function b(t){return"string"==typeof t||"number"==typeof t}r=new WeakMap;class I{constructor(t){n.set(this,[]),o.set(this,null),h.set(this,null),this.delay=null,this.max=1/0,this.setOptions(t)}setOptions(t){t&&void 0!==t.delay&&(this.delay=t.delay),t&&void 0!==t.max&&(this.max=t.max),this._flushIfNeeded()}static extend(t,e){const s=new I(e);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=()=>{s.flush()};const r=[{name:"flush",original:void 0}];if(e&&e.replace)for(let i=0;i<e.replace.length;i++){const n=e.replace[i];r.push({name:n,original:t[n]}),s.replace(t,n)}return i(s,h,{object:t,methods:r}),s}destroy(){if(this.flush(),s(this,h)){const t=s(this,h).object,e=s(this,h).methods;for(let s=0;s<e.length;s++){const i=e[s];i.original?t[i.name]=i.original:delete t[i.name]}i(this,h,null)}}replace(t,e){const s=this,i=t[e];if(!i)throw new Error("Method "+e+" undefined");t[e]=function(...t){s.queue({args:t,fn:i,context:this})}}queue(t){"function"==typeof t?s(this,n).push({fn:t}):s(this,n).push(t),this._flushIfNeeded()}_flushIfNeeded(){s(this,n).length>this.max&&this.flush(),null!=s(this,o)&&(clearTimeout(s(this,o)),i(this,o,null)),this.queue.length>0&&"number"==typeof this.delay&&i(this,o,setTimeout((()=>{this.flush()}),this.delay))}flush(){s(this,n).splice(0).forEach((t=>{t.fn.apply(t.context||t.fn,t.args||[])}))}}n=new WeakMap,o=new WeakMap,h=new WeakMap;class E{constructor(){l.set(this,{"*":[],add:[],remove:[],update:[]}),this.subscribe=E.prototype.on,this.unsubscribe=E.prototype.off}_trigger(t,e,i){if("*"===t)throw new Error("Cannot trigger event *");[...s(this,l)[t],...s(this,l)["*"]].forEach((s=>{s(t,e,null!=i?i:null)}))}on(t,e){"function"==typeof e&&s(this,l)[t].push(e)}off(t,e){s(this,l)[t]=s(this,l)[t].filter((t=>t!==e))}}l=new WeakMap;class k{constructor(t){a.set(this,void 0),i(this,a,t)}*[(a=new WeakMap,Symbol.iterator)](){for(const[t,e]of s(this,a))yield[t,e]}*entries(){for(const[t,e]of s(this,a))yield[t,e]}*keys(){for(const[t]of s(this,a))yield t}*values(){for(const[,t]of s(this,a))yield t}toIdArray(){return[...s(this,a)].map((t=>t[0]))}toItemArray(){return[...s(this,a)].map((t=>t[1]))}toEntryArray(){return[...s(this,a)]}toObjectMap(){const t=Object.create(null);for(const[e,i]of s(this,a))t[e]=i;return t}toMap(){return new Map(s(this,a))}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new k([...s(this,a)])}distinct(t){const e=new Set;for(const[i,r]of s(this,a))e.add(t(r,i));return e}filter(t){const e=s(this,a);return new k({*[Symbol.iterator](){for(const[s,i]of e)t(i,s)&&(yield[s,i])}})}forEach(t){for(const[e,i]of s(this,a))t(i,e)}map(t){const e=s(this,a);return new k({*[Symbol.iterator](){for(const[s,i]of e)yield[s,t(i,s)]}})}max(t){const e=s(this,a)[Symbol.iterator]();let i=e.next();if(i.done)return null;let r=i.value[1],n=t(i.value[1],i.value[0]);for(;!(i=e.next()).done;){const[e,s]=i.value,o=t(s,e);o>n&&(n=o,r=s)}return r}min(t){const e=s(this,a)[Symbol.iterator]();let i=e.next();if(i.done)return null;let r=i.value[1],n=t(i.value[1],i.value[0]);for(;!(i=e.next()).done;){const[e,s]=i.value,o=t(s,e);o<n&&(n=o,r=s)}return r}reduce(t,e){for(const[i,r]of s(this,a))e=t(e,r,i);return e}sort(t){return new k({[Symbol.iterator]:()=>[...s(this,a)].sort((([e,s],[i,r])=>t(s,r,e,i)))[Symbol.iterator]()})}}class D extends E{constructor(t,e){super(),u.set(this,void 0),f.set(this,void 0),d.set(this,void 0),c.set(this,null),t&&!Array.isArray(t)&&(e=t,t=[]),i(this,u,e||{}),i(this,f,new Map),this.length=0,i(this,d,s(this,u).fieldId||"id"),t&&t.length&&this.add(t),this.setOptions(e)}get idProp(){return s(this,d)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?s(this,c)&&(s(this,c).destroy(),i(this,c,null)):(s(this,c)||i(this,c,I.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&s(this,c).setOptions(t.queue)))}add(t,e){const i=[];let r;if(Array.isArray(t)){if(t.map((t=>t[s(this,d)])).some((t=>s(this,f).has(t))))throw new Error("A duplicate id was found in the parameter array.");for(let e=0,s=t.length;e<s;e++)r=this._addItem(t[e]),i.push(r)}else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");r=this._addItem(t),i.push(r)}return i.length&&this._trigger("add",{items:i},e),i}update(t,e){const i=[],r=[],n=[],o=[],h=s(this,d),l=t=>{const e=t[h];if(null!=e&&s(this,f).has(e)){const i=t,h=Object.assign({},s(this,f).get(e)),l=this._updateItem(i);r.push(l),o.push(i),n.push(h)}else{const e=this._addItem(t);i.push(e)}};if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]&&"object"==typeof t[e]?l(t[e]):console.warn("Ignoring input item, which is not an object at index "+e);else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");l(t)}if(i.length&&this._trigger("add",{items:i},e),r.length){const t={items:r,oldData:n,data:o};this._trigger("update",t,e)}return i.concat(r)}updateOnly(e,i){Array.isArray(e)||(e=[e]);const r=e.map((t=>{const e=s(this,f).get(t[s(this,d)]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}})).map((({oldData:e,update:i})=>{const r=e[s(this,d)],n=t(e,i);return s(this,f).set(r,n),{id:r,oldData:e,updatedData:n}}));if(r.length){const t={items:r.map((t=>t.id)),oldData:r.map((t=>t.oldData)),data:r.map((t=>t.updatedData))};return this._trigger("update",t,i),t.items}return[]}get(t,e){let i=void 0,r=void 0,n=void 0;b(t)?(i=t,n=e):Array.isArray(t)?(r=t,n=e):n=t;const o=n&&"Object"===n.returnType?"Object":"Array",h=n&&n.filter,l=[];let a=void 0,u=void 0,c=void 0;if(null!=i)a=s(this,f).get(i),a&&h&&!h(a)&&(a=void 0);else if(null!=r)for(let t=0,e=r.length;t<e;t++)a=s(this,f).get(r[t]),null==a||h&&!h(a)||l.push(a);else{u=[...s(this,f).keys()];for(let t=0,e=u.length;t<e;t++)c=u[t],a=s(this,f).get(c),null==a||h&&!h(a)||l.push(a)}if(n&&n.order&&null==i&&this._sort(l,n.order),n&&n.fields){const t=n.fields;if(null!=i&&null!=a)a=this._filterFields(a,t);else for(let e=0,s=l.length;e<s;e++)l[e]=this._filterFields(l[e],t)}if("Object"==o){const t={};for(let e=0,i=l.length;e<i;e++){const i=l[e];t[i[s(this,d)]]=i}return t}return null!=i?null!=a?a:null:l}getIds(t){const e=s(this,f),i=t&&t.filter,r=t&&t.order,n=[...e.keys()],o=[];if(i)if(r){const t=[];for(let e=0,r=n.length;e<r;e++){const r=n[e],o=s(this,f).get(r);null!=o&&i(o)&&t.push(o)}this._sort(t,r);for(let e=0,i=t.length;e<i;e++)o.push(t[e][s(this,d)])}else for(let t=0,e=n.length;t<e;t++){const e=n[t],r=s(this,f).get(e);null!=r&&i(r)&&o.push(r[s(this,d)])}else if(r){const t=[];for(let s=0,i=n.length;s<i;s++){const i=n[s];t.push(e.get(i))}this._sort(t,r);for(let e=0,i=t.length;e<i;e++)o.push(t[e][s(this,d)])}else for(let t=0,i=n.length;t<i;t++){const i=n[t],r=e.get(i);null!=r&&o.push(r[s(this,d)])}return o}getDataSet(){return this}forEach(t,e){const i=e&&e.filter,r=[...s(this,f).keys()];if(e&&e.order){const i=this.get(e);for(let e=0,r=i.length;e<r;e++){const r=i[e];t(r,r[s(this,d)])}}else for(let e=0,n=r.length;e<n;e++){const n=r[e],o=s(this,f).get(n);null==o||i&&!i(o)||t(o,n)}}map(t,e){const i=e&&e.filter,r=[],n=[...s(this,f).keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],h=s(this,f).get(o);null==h||i&&!i(h)||r.push(t(h,o))}return e&&e.order&&this._sort(r,e.order),r}_filterFields(t,e){return t?(Array.isArray(e)?e:Object.keys(e)).reduce(((e,s)=>(e[s]=t[s],e)),{}):t}_sort(t,e){if("string"==typeof e){const s=e;t.sort(((t,e)=>{const i=t[s],r=e[s];return i>r?1:i<r?-1:0}))}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}}remove(t,e){const i=[],r=[],n=Array.isArray(t)?t:[t];for(let t=0,e=n.length;t<e;t++){const e=this._remove(n[t]);if(e){const t=e[s(this,d)];null!=t&&(i.push(t),r.push(e))}}return i.length&&this._trigger("remove",{items:i,oldData:r},e),i}_remove(t){let e;if(b(t)?e=t:t&&"object"==typeof t&&(e=t[s(this,d)]),null!=e&&s(this,f).has(e)){const t=s(this,f).get(e)||null;return s(this,f).delete(e),--this.length,t}return null}clear(t){const e=[...s(this,f).keys()],i=[];for(let t=0,r=e.length;t<r;t++)i.push(s(this,f).get(e[t]));return s(this,f).clear(),this.length=0,this._trigger("remove",{items:e,oldData:i},t),e}max(t){let e=null,i=null;for(const r of s(this,f).values()){const s=r[t];"number"==typeof s&&(null==i||s>i)&&(e=r,i=s)}return e||null}min(t){let e=null,i=null;for(const r of s(this,f).values()){const s=r[t];"number"==typeof s&&(null==i||s<i)&&(e=r,i=s)}return e||null}distinct(t){const e=s(this,f),i=[...e.keys()],r=[];let n=0;for(let s=0,o=i.length;s<o;s++){const o=i[s],h=e.get(o)[t];let l=!1;for(let t=0;t<n;t++)if(r[t]==h){l=!0;break}l||void 0===h||(r[n]=h,n++)}return r}_addItem(t){const i=function(t,s){return null==t[s]&&(t[s]=e()),t}(t,s(this,d)),r=i[s(this,d)];if(s(this,f).has(r))throw new Error("Cannot add item: item with id "+r+" already exists");return s(this,f).set(r,i),++this.length,r}_updateItem(t){const e=t[s(this,d)];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const i=s(this,f).get(e);if(!i)throw new Error("Cannot update item: no item with id "+e+" found");return s(this,f).set(e,{...i,...t}),e}stream(t){if(t){const e=s(this,f);return new k({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new k({[Symbol.iterator]:s(this,f).entries.bind(s(this,f))})}}u=new WeakMap,f=new WeakMap,d=new WeakMap,c=new WeakMap;class x extends E{constructor(t,e){super(),this.length=0,p.set(this,void 0),g.set(this,void 0),m.set(this,new Set),y.set(this,void 0),i(this,y,e||{}),i(this,p,this._onEvent.bind(this)),this.setData(t)}get idProp(){return this.getDataSet().idProp}setData(t){if(s(this,g)){s(this,g).off&&s(this,g).off("*",s(this,p));const t=s(this,g).getIds({filter:s(this,y).filter}),e=s(this,g).get(t);s(this,m).clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){i(this,g,t);const e=s(this,g).getIds({filter:s(this,y).filter});for(let t=0,i=e.length;t<i;t++){const i=e[t];s(this,m).add(i)}this.length=e.length,this._trigger("add",{items:e})}else i(this,g,new D);s(this,g).on&&s(this,g).on("*",s(this,p))}refresh(){const t=s(this,g).getIds({filter:s(this,y).filter}),e=[...s(this,m)],i={},r=[],n=[],o=[];for(let e=0,n=t.length;e<n;e++){const n=t[e];i[n]=!0,s(this,m).has(n)||(r.push(n),s(this,m).add(n))}for(let t=0,r=e.length;t<r;t++){const r=e[t],h=s(this,g).get(r);null==h?console.error("If you see this, report it please."):i[r]||(n.push(r),o.push(h),s(this,m).delete(r))}this.length+=r.length-n.length,r.length&&this._trigger("add",{items:r}),n.length&&this._trigger("remove",{items:n,oldData:o})}get(t,e){if(null==s(this,g))return null;let i,r=null;b(t)||Array.isArray(t)?(r=t,i=e):i=t;const n=Object.assign({},s(this,y),i),o=s(this,y).filter,h=i&&i.filter;return o&&h&&(n.filter=t=>o(t)&&h(t)),null==r?s(this,g).get(n):s(this,g).get(r,n)}getIds(t){if(s(this,g).length){const e=s(this,y).filter,i=null!=t?t.filter:null;let r;return r=i?e?t=>e(t)&&i(t):i:e,s(this,g).getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(s(this,g)){const i=s(this,y).filter,r=e&&e.filter;let n;n=r?i?function(t){return i(t)&&r(t)}:r:i,s(this,g).forEach(t,{filter:n,order:e&&e.order})}}map(t,e){if(s(this,g)){const i=s(this,y).filter,r=e&&e.filter;let n;return n=r?i?t=>i(t)&&r(t):r:i,s(this,g).map(t,{filter:n,order:e&&e.order})}return[]}getDataSet(){return s(this,g).getDataSet()}stream(t){return s(this,g).stream(t||{[Symbol.iterator]:s(this,m).keys.bind(s(this,m))})}dispose(){var t;(null===(t=s(this,g))||void 0===t?void 0:t.off)&&s(this,g).off("*",s(this,p));const e="This data view has already been disposed of.",i={get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1};for(const t of Reflect.ownKeys(x.prototype))Object.defineProperty(this,t,i)}_onEvent(t,e,i){if(!e||!e.items||!s(this,g))return;const r=e.items,n=[],o=[],h=[],l=[],a=[],u=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(s(this,m).add(e),n.push(e))}break;case"update":for(let t=0,i=r.length;t<i;t++){const i=r[t];this.get(i)?s(this,m).has(i)?(o.push(i),a.push(e.data[t]),l.push(e.oldData[t])):(s(this,m).add(i),n.push(i)):s(this,m).has(i)&&(s(this,m).delete(i),h.push(i),u.push(e.oldData[t]))}break;case"remove":for(let t=0,i=r.length;t<i;t++){const i=r[t];s(this,m).has(i)&&(s(this,m).delete(i),h.push(i),u.push(e.oldData[t]))}}this.length+=n.length-h.length,n.length&&this._trigger("add",{items:n},i),o.length&&this._trigger("update",{items:o,oldData:l,data:a},i),h.length&&this._trigger("remove",{items:h,oldData:u},i)}}function S(t,e){return"object"==typeof e&&null!==e&&t===e.idProp&&"function"==typeof e.add&&"function"==typeof e.clear&&"function"==typeof e.distinct&&"function"==typeof e.forEach&&"function"==typeof e.get&&"function"==typeof e.getDataSet&&"function"==typeof e.getIds&&"number"==typeof e.length&&"function"==typeof e.map&&"function"==typeof e.max&&"function"==typeof e.min&&"function"==typeof e.off&&"function"==typeof e.on&&"function"==typeof e.remove&&"function"==typeof e.setOptions&&"function"==typeof e.stream&&"function"==typeof e.update&&"function"==typeof e.updateOnly}function A(t,e){return"object"==typeof e&&null!==e&&t===e.idProp&&"function"==typeof e.forEach&&"function"==typeof e.get&&"function"==typeof e.getDataSet&&"function"==typeof e.getIds&&"number"==typeof e.length&&"function"==typeof e.map&&"function"==typeof e.off&&"function"==typeof e.on&&"function"==typeof e.stream&&S(t,e.getDataSet())}p=new WeakMap,g=new WeakMap,m=new WeakMap,y=new WeakMap;export{D as DataSet,k as DataStream,x as DataView,I as Queue,_ as createNewDataPipeFrom,S as isDataSetLike,A as isDataViewLike}; | ||
//# sourceMappingURL=vis-data.min.js.map |
@@ -7,4 +7,4 @@ /** | ||
* | ||
* @version 7.0.1 | ||
* @date 2020-10-13T17:07:07.867Z | ||
* @version 7.1.0 | ||
* @date 2020-10-13T20:44:00.711Z | ||
* | ||
@@ -27,3 +27,3 @@ * @copyright (c) 2011-2017 Almende B.V, http://almende.com | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("uuid"),require("vis-util/esnext/umd/vis-util.js")):"function"==typeof define&&define.amd?define(["exports","uuid","vis-util/esnext/umd/vis-util.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vis=t.vis||{},t.uuidv4,t.vis)}(this,(function(t,e,s){ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vis-util/esnext/umd/vis-util.js"),require("uuid")):"function"==typeof define&&define.amd?define(["exports","vis-util/esnext/umd/vis-util.js","uuid"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vis=t.vis||{},t.vis,t.uuidv4)}(this,(function(t,e,s){ | ||
/*! ***************************************************************************** | ||
@@ -43,3 +43,3 @@ Copyright (c) Microsoft Corporation. | ||
***************************************************************************** */ | ||
function i(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function r(t,e,s){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,s),s}var n,o,h,l,a,u,d,f,c,p,g,m,y,_;class w{constructor(t,e,s){this._source=t,this._transformers=e,this._target=s,this._listeners={add:this._add.bind(this),remove:this._remove.bind(this),update:this._update.bind(this)}}all(){return this._target.update(this._transformItems(this._source.get())),this}start(){return this._source.on("add",this._listeners.add),this._source.on("remove",this._listeners.remove),this._source.on("update",this._listeners.update),this}stop(){return this._source.off("add",this._listeners.add),this._source.off("remove",this._listeners.remove),this._source.off("update",this._listeners.update),this}_transformItems(t){return this._transformers.reduce(((t,e)=>e(t)),t)}_add(t,e){null!=e&&this._target.add(this._transformItems(this._source.get(e.items)))}_update(t,e){null!=e&&this._target.update(this._transformItems(this._source.get(e.items)))}_remove(t,e){null!=e&&this._target.remove(this._transformItems(e.oldData))}}class v{constructor(t){this._source=t,n.set(this,[])}filter(t){return i(this,n).push((e=>e.filter(t))),this}map(t){return i(this,n).push((e=>e.map(t))),this}flatMap(t){return i(this,n).push((e=>e.flatMap(t))),this}to(t){return new w(this._source,i(this,n),t)}}function b(t){return"string"==typeof t||"number"==typeof t}n=new WeakMap;class D{constructor(t){o.set(this,[]),h.set(this,null),l.set(this,null),this.delay=null,this.max=1/0,this.setOptions(t)}setOptions(t){t&&void 0!==t.delay&&(this.delay=t.delay),t&&void 0!==t.max&&(this.max=t.max),this._flushIfNeeded()}static extend(t,e){const s=new D(e);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=()=>{s.flush()};const i=[{name:"flush",original:void 0}];if(e&&e.replace)for(let r=0;r<e.replace.length;r++){const n=e.replace[r];i.push({name:n,original:t[n]}),s.replace(t,n)}return r(s,l,{object:t,methods:i}),s}destroy(){if(this.flush(),i(this,l)){const t=i(this,l).object,e=i(this,l).methods;for(let s=0;s<e.length;s++){const i=e[s];i.original?t[i.name]=i.original:delete t[i.name]}r(this,l,null)}}replace(t,e){const s=this,i=t[e];if(!i)throw new Error("Method "+e+" undefined");t[e]=function(...t){s.queue({args:t,fn:i,context:this})}}queue(t){"function"==typeof t?i(this,o).push({fn:t}):i(this,o).push(t),this._flushIfNeeded()}_flushIfNeeded(){i(this,o).length>this.max&&this.flush(),null!=i(this,h)&&(clearTimeout(i(this,h)),r(this,h,null)),this.queue.length>0&&"number"==typeof this.delay&&r(this,h,setTimeout((()=>{this.flush()}),this.delay))}flush(){i(this,o).splice(0).forEach((t=>{t.fn.apply(t.context||t.fn,t.args||[])}))}}o=new WeakMap,h=new WeakMap,l=new WeakMap;class E{constructor(){a.set(this,{"*":[],add:[],remove:[],update:[]}),this.subscribe=E.prototype.on,this.unsubscribe=E.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...i(this,a)[t],...i(this,a)["*"]].forEach((i=>{i(t,e,null!=s?s:null)}))}on(t,e){"function"==typeof e&&i(this,a)[t].push(e)}off(t,e){i(this,a)[t]=i(this,a)[t].filter((t=>t!==e))}}a=new WeakMap;class I{constructor(t){u.set(this,void 0),r(this,u,t)}*[(u=new WeakMap,Symbol.iterator)](){for(const[t,e]of i(this,u))yield[t,e]}*entries(){for(const[t,e]of i(this,u))yield[t,e]}*keys(){for(const[t]of i(this,u))yield t}*values(){for(const[,t]of i(this,u))yield t}toIdArray(){return[...i(this,u)].map((t=>t[0]))}toItemArray(){return[...i(this,u)].map((t=>t[1]))}toEntryArray(){return[...i(this,u)]}toObjectMap(){const t=Object.create(null);for(const[e,s]of i(this,u))t[e]=s;return t}toMap(){return new Map(i(this,u))}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new I([...i(this,u)])}distinct(t){const e=new Set;for(const[s,r]of i(this,u))e.add(t(r,s));return e}filter(t){const e=i(this,u);return new I({*[Symbol.iterator](){for(const[s,i]of e)t(i,s)&&(yield[s,i])}})}forEach(t){for(const[e,s]of i(this,u))t(s,e)}map(t){const e=i(this,u);return new I({*[Symbol.iterator](){for(const[s,i]of e)yield[s,t(i,s)]}})}max(t){const e=i(this,u)[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],n=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,i]=s.value,o=t(i,e);o>n&&(n=o,r=i)}return r}min(t){const e=i(this,u)[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],n=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,i]=s.value,o=t(i,e);o<n&&(n=o,r=i)}return r}reduce(t,e){for(const[s,r]of i(this,u))e=t(e,r,s);return e}sort(t){return new I({[Symbol.iterator]:()=>[...i(this,u)].sort((([e,s],[i,r])=>t(s,r,e,i)))[Symbol.iterator]()})}}class k extends E{constructor(t,e){super(),d.set(this,void 0),f.set(this,void 0),c.set(this,void 0),p.set(this,null),t&&!Array.isArray(t)&&(e=t,t=[]),r(this,d,e||{}),r(this,f,new Map),this.length=0,r(this,c,i(this,d).fieldId||"id"),t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?i(this,p)&&(i(this,p).destroy(),r(this,p,null)):(i(this,p)||r(this,p,D.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&i(this,p).setOptions(t.queue)))}add(t,e){const s=[];let r;if(Array.isArray(t)){if(t.map((t=>t[i(this,c)])).some((t=>i(this,f).has(t))))throw new Error("A duplicate id was found in the parameter array.");for(let e=0,i=t.length;e<i;e++)r=this._addItem(t[e]),s.push(r)}else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");r=this._addItem(t),s.push(r)}return s.length&&this._trigger("add",{items:s},e),s}update(t,e){const s=[],r=[],n=[],o=[],h=i(this,c),l=t=>{const e=t[h];if(null!=e&&i(this,f).has(e)){const s=t,h=Object.assign({},i(this,f).get(e)),l=this._updateItem(s);r.push(l),o.push(s),n.push(h)}else{const e=this._addItem(t);s.push(e)}};if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]&&"object"==typeof t[e]?l(t[e]):console.warn("Ignoring input item, which is not an object at index "+e);else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");l(t)}if(s.length&&this._trigger("add",{items:s},e),r.length){const t={items:r,oldData:n,data:o};this._trigger("update",t,e)}return s.concat(r)}updateOnly(t,e){Array.isArray(t)||(t=[t]);const r=t.map((t=>{const e=i(this,f).get(t[i(this,c)]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}})).map((({oldData:t,update:e})=>{const r=t[i(this,c)],n=s.pureDeepObjectAssign(t,e);return i(this,f).set(r,n),{id:r,oldData:t,updatedData:n}}));if(r.length){const t={items:r.map((t=>t.id)),oldData:r.map((t=>t.oldData)),data:r.map((t=>t.updatedData))};return this._trigger("update",t,e),t.items}return[]}get(t,e){let s=void 0,r=void 0,n=void 0;b(t)?(s=t,n=e):Array.isArray(t)?(r=t,n=e):n=t;const o=n&&"Object"===n.returnType?"Object":"Array",h=n&&n.filter,l=[];let a=void 0,u=void 0,d=void 0;if(null!=s)a=i(this,f).get(s),a&&h&&!h(a)&&(a=void 0);else if(null!=r)for(let t=0,e=r.length;t<e;t++)a=i(this,f).get(r[t]),null==a||h&&!h(a)||l.push(a);else{u=[...i(this,f).keys()];for(let t=0,e=u.length;t<e;t++)d=u[t],a=i(this,f).get(d),null==a||h&&!h(a)||l.push(a)}if(n&&n.order&&null==s&&this._sort(l,n.order),n&&n.fields){const t=n.fields;if(null!=s&&null!=a)a=this._filterFields(a,t);else for(let e=0,s=l.length;e<s;e++)l[e]=this._filterFields(l[e],t)}if("Object"==o){const t={};for(let e=0,s=l.length;e<s;e++){const s=l[e];t[s[i(this,c)]]=s}return t}return null!=s?null!=a?a:null:l}getIds(t){const e=i(this,f),s=t&&t.filter,r=t&&t.order,n=[...e.keys()],o=[];if(s)if(r){const t=[];for(let e=0,r=n.length;e<r;e++){const r=n[e],o=i(this,f).get(r);null!=o&&s(o)&&t.push(o)}this._sort(t,r);for(let e=0,s=t.length;e<s;e++)o.push(t[e][i(this,c)])}else for(let t=0,e=n.length;t<e;t++){const e=n[t],r=i(this,f).get(e);null!=r&&s(r)&&o.push(r[i(this,c)])}else if(r){const t=[];for(let s=0,i=n.length;s<i;s++){const i=n[s];t.push(e.get(i))}this._sort(t,r);for(let e=0,s=t.length;e<s;e++)o.push(t[e][i(this,c)])}else for(let t=0,s=n.length;t<s;t++){const s=n[t],r=e.get(s);null!=r&&o.push(r[i(this,c)])}return o}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,r=[...i(this,f).keys()];if(e&&e.order){const s=this.get(e);for(let e=0,r=s.length;e<r;e++){const r=s[e];t(r,r[i(this,c)])}}else for(let e=0,n=r.length;e<n;e++){const n=r[e],o=i(this,f).get(n);null==o||s&&!s(o)||t(o,n)}}map(t,e){const s=e&&e.filter,r=[],n=[...i(this,f).keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],h=i(this,f).get(o);null==h||s&&!s(h)||r.push(t(h,o))}return e&&e.order&&this._sort(r,e.order),r}_filterFields(t,e){return t?(Array.isArray(e)?e:Object.keys(e)).reduce(((e,s)=>(e[s]=t[s],e)),{}):t}_sort(t,e){if("string"==typeof e){const s=e;t.sort(((t,e)=>{const i=t[s],r=e[s];return i>r?1:i<r?-1:0}))}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}}remove(t,e){const s=[],r=[],n=Array.isArray(t)?t:[t];for(let t=0,e=n.length;t<e;t++){const e=this._remove(n[t]);if(e){const t=e[i(this,c)];null!=t&&(s.push(t),r.push(e))}}return s.length&&this._trigger("remove",{items:s,oldData:r},e),s}_remove(t){let e;if(b(t)?e=t:t&&"object"==typeof t&&(e=t[i(this,c)]),null!=e&&i(this,f).has(e)){const t=i(this,f).get(e)||null;return i(this,f).delete(e),--this.length,t}return null}clear(t){const e=[...i(this,f).keys()],s=[];for(let t=0,r=e.length;t<r;t++)s.push(i(this,f).get(e[t]));return i(this,f).clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const r of i(this,f).values()){const i=r[t];"number"==typeof i&&(null==s||i>s)&&(e=r,s=i)}return e||null}min(t){let e=null,s=null;for(const r of i(this,f).values()){const i=r[t];"number"==typeof i&&(null==s||i<s)&&(e=r,s=i)}return e||null}distinct(t){const e=i(this,f),s=[...e.keys()],r=[];let n=0;for(let i=0,o=s.length;i<o;i++){const o=s[i],h=e.get(o)[t];let l=!1;for(let t=0;t<n;t++)if(r[t]==h){l=!0;break}l||void 0===h||(r[n]=h,n++)}return r}_addItem(t){const s=function(t,s){return null==t[s]&&(t[s]=e.v4()),t}(t,i(this,c)),r=s[i(this,c)];if(i(this,f).has(r))throw new Error("Cannot add item: item with id "+r+" already exists");return i(this,f).set(r,s),++this.length,r}_updateItem(t){const e=t[i(this,c)];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=i(this,f).get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");return i(this,f).set(e,{...s,...t}),e}stream(t){if(t){const e=i(this,f);return new I({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new I({[Symbol.iterator]:i(this,f).entries.bind(i(this,f))})}}d=new WeakMap,f=new WeakMap,c=new WeakMap,p=new WeakMap;class x extends E{constructor(t,e){super(),this.length=0,g.set(this,void 0),m.set(this,void 0),y.set(this,new Set),_.set(this,void 0),r(this,_,e||{}),r(this,g,this._onEvent.bind(this)),this.setData(t)}setData(t){if(i(this,m)){i(this,m).off&&i(this,m).off("*",i(this,g));const t=i(this,m).getIds({filter:i(this,_).filter}),e=i(this,m).get(t);i(this,y).clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){r(this,m,t);const e=i(this,m).getIds({filter:i(this,_).filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];i(this,y).add(s)}this.length=e.length,this._trigger("add",{items:e})}else r(this,m,new k);i(this,m).on&&i(this,m).on("*",i(this,g))}refresh(){const t=i(this,m).getIds({filter:i(this,_).filter}),e=[...i(this,y)],s={},r=[],n=[],o=[];for(let e=0,n=t.length;e<n;e++){const n=t[e];s[n]=!0,i(this,y).has(n)||(r.push(n),i(this,y).add(n))}for(let t=0,r=e.length;t<r;t++){const r=e[t],h=i(this,m).get(r);null==h?console.error("If you see this, report it please."):s[r]||(n.push(r),o.push(h),i(this,y).delete(r))}this.length+=r.length-n.length,r.length&&this._trigger("add",{items:r}),n.length&&this._trigger("remove",{items:n,oldData:o})}get(t,e){if(null==i(this,m))return null;let s,r=null;b(t)||Array.isArray(t)?(r=t,s=e):s=t;const n=Object.assign({},i(this,_),s),o=i(this,_).filter,h=s&&s.filter;return o&&h&&(n.filter=t=>o(t)&&h(t)),null==r?i(this,m).get(n):i(this,m).get(r,n)}getIds(t){if(i(this,m).length){const e=i(this,_).filter,s=null!=t?t.filter:null;let r;return r=s?e?t=>e(t)&&s(t):s:e,i(this,m).getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(i(this,m)){const s=i(this,_).filter,r=e&&e.filter;let n;n=r?s?function(t){return s(t)&&r(t)}:r:s,i(this,m).forEach(t,{filter:n,order:e&&e.order})}}map(t,e){if(i(this,m)){const s=i(this,_).filter,r=e&&e.filter;let n;return n=r?s?t=>s(t)&&r(t):r:s,i(this,m).map(t,{filter:n,order:e&&e.order})}return[]}getDataSet(){return i(this,m).getDataSet()}stream(t){return i(this,m).stream(t||{[Symbol.iterator]:i(this,y).keys.bind(i(this,y))})}dispose(){var t;(null===(t=i(this,m))||void 0===t?void 0:t.off)&&i(this,m).off("*",i(this,g));const e="This data view has already been disposed of.",s={get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1};for(const t of Reflect.ownKeys(x.prototype))Object.defineProperty(this,t,s)}_onEvent(t,e,s){if(!e||!e.items||!i(this,m))return;const r=e.items,n=[],o=[],h=[],l=[],a=[],u=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(i(this,y).add(e),n.push(e))}break;case"update":for(let t=0,s=r.length;t<s;t++){const s=r[t];this.get(s)?i(this,y).has(s)?(o.push(s),a.push(e.data[t]),l.push(e.oldData[t])):(i(this,y).add(s),n.push(s)):i(this,y).has(s)&&(i(this,y).delete(s),h.push(s),u.push(e.oldData[t]))}break;case"remove":for(let t=0,s=r.length;t<s;t++){const s=r[t];i(this,y).has(s)&&(i(this,y).delete(s),h.push(s),u.push(e.oldData[t]))}}this.length+=n.length-h.length,n.length&&this._trigger("add",{items:n},s),o.length&&this._trigger("update",{items:o,oldData:l,data:a},s),h.length&&this._trigger("remove",{items:h,oldData:u},s)}}g=new WeakMap,m=new WeakMap,y=new WeakMap,_=new WeakMap,Object.defineProperty(t,"DELETE",{enumerable:!0,get:function(){return s.DELETE}}),t.DataSet=k,t.DataStream=I,t.DataView=x,t.Queue=D,t.createNewDataPipeFrom=function(t){return new v(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
function i(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function r(t,e,s){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,s),s}var n,o,h,l,a,u,f,d,c,p,g,m,y,w;class _{constructor(t,e,s){this._source=t,this._transformers=e,this._target=s,this._listeners={add:this._add.bind(this),remove:this._remove.bind(this),update:this._update.bind(this)}}all(){return this._target.update(this._transformItems(this._source.get())),this}start(){return this._source.on("add",this._listeners.add),this._source.on("remove",this._listeners.remove),this._source.on("update",this._listeners.update),this}stop(){return this._source.off("add",this._listeners.add),this._source.off("remove",this._listeners.remove),this._source.off("update",this._listeners.update),this}_transformItems(t){return this._transformers.reduce(((t,e)=>e(t)),t)}_add(t,e){null!=e&&this._target.add(this._transformItems(this._source.get(e.items)))}_update(t,e){null!=e&&this._target.update(this._transformItems(this._source.get(e.items)))}_remove(t,e){null!=e&&this._target.remove(this._transformItems(e.oldData))}}class v{constructor(t){this._source=t,n.set(this,[])}filter(t){return i(this,n).push((e=>e.filter(t))),this}map(t){return i(this,n).push((e=>e.map(t))),this}flatMap(t){return i(this,n).push((e=>e.flatMap(t))),this}to(t){return new _(this._source,i(this,n),t)}}function b(t){return"string"==typeof t||"number"==typeof t}n=new WeakMap;class D{constructor(t){o.set(this,[]),h.set(this,null),l.set(this,null),this.delay=null,this.max=1/0,this.setOptions(t)}setOptions(t){t&&void 0!==t.delay&&(this.delay=t.delay),t&&void 0!==t.max&&(this.max=t.max),this._flushIfNeeded()}static extend(t,e){const s=new D(e);if(void 0!==t.flush)throw new Error("Target object already has a property flush");t.flush=()=>{s.flush()};const i=[{name:"flush",original:void 0}];if(e&&e.replace)for(let r=0;r<e.replace.length;r++){const n=e.replace[r];i.push({name:n,original:t[n]}),s.replace(t,n)}return r(s,l,{object:t,methods:i}),s}destroy(){if(this.flush(),i(this,l)){const t=i(this,l).object,e=i(this,l).methods;for(let s=0;s<e.length;s++){const i=e[s];i.original?t[i.name]=i.original:delete t[i.name]}r(this,l,null)}}replace(t,e){const s=this,i=t[e];if(!i)throw new Error("Method "+e+" undefined");t[e]=function(...t){s.queue({args:t,fn:i,context:this})}}queue(t){"function"==typeof t?i(this,o).push({fn:t}):i(this,o).push(t),this._flushIfNeeded()}_flushIfNeeded(){i(this,o).length>this.max&&this.flush(),null!=i(this,h)&&(clearTimeout(i(this,h)),r(this,h,null)),this.queue.length>0&&"number"==typeof this.delay&&r(this,h,setTimeout((()=>{this.flush()}),this.delay))}flush(){i(this,o).splice(0).forEach((t=>{t.fn.apply(t.context||t.fn,t.args||[])}))}}o=new WeakMap,h=new WeakMap,l=new WeakMap;class E{constructor(){a.set(this,{"*":[],add:[],remove:[],update:[]}),this.subscribe=E.prototype.on,this.unsubscribe=E.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...i(this,a)[t],...i(this,a)["*"]].forEach((i=>{i(t,e,null!=s?s:null)}))}on(t,e){"function"==typeof e&&i(this,a)[t].push(e)}off(t,e){i(this,a)[t]=i(this,a)[t].filter((t=>t!==e))}}a=new WeakMap;class I{constructor(t){u.set(this,void 0),r(this,u,t)}*[(u=new WeakMap,Symbol.iterator)](){for(const[t,e]of i(this,u))yield[t,e]}*entries(){for(const[t,e]of i(this,u))yield[t,e]}*keys(){for(const[t]of i(this,u))yield t}*values(){for(const[,t]of i(this,u))yield t}toIdArray(){return[...i(this,u)].map((t=>t[0]))}toItemArray(){return[...i(this,u)].map((t=>t[1]))}toEntryArray(){return[...i(this,u)]}toObjectMap(){const t=Object.create(null);for(const[e,s]of i(this,u))t[e]=s;return t}toMap(){return new Map(i(this,u))}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new I([...i(this,u)])}distinct(t){const e=new Set;for(const[s,r]of i(this,u))e.add(t(r,s));return e}filter(t){const e=i(this,u);return new I({*[Symbol.iterator](){for(const[s,i]of e)t(i,s)&&(yield[s,i])}})}forEach(t){for(const[e,s]of i(this,u))t(s,e)}map(t){const e=i(this,u);return new I({*[Symbol.iterator](){for(const[s,i]of e)yield[s,t(i,s)]}})}max(t){const e=i(this,u)[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],n=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,i]=s.value,o=t(i,e);o>n&&(n=o,r=i)}return r}min(t){const e=i(this,u)[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],n=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,i]=s.value,o=t(i,e);o<n&&(n=o,r=i)}return r}reduce(t,e){for(const[s,r]of i(this,u))e=t(e,r,s);return e}sort(t){return new I({[Symbol.iterator]:()=>[...i(this,u)].sort((([e,s],[i,r])=>t(s,r,e,i)))[Symbol.iterator]()})}}class k extends E{constructor(t,e){super(),f.set(this,void 0),d.set(this,void 0),c.set(this,void 0),p.set(this,null),t&&!Array.isArray(t)&&(e=t,t=[]),r(this,f,e||{}),r(this,d,new Map),this.length=0,r(this,c,i(this,f).fieldId||"id"),t&&t.length&&this.add(t),this.setOptions(e)}get idProp(){return i(this,c)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?i(this,p)&&(i(this,p).destroy(),r(this,p,null)):(i(this,p)||r(this,p,D.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&i(this,p).setOptions(t.queue)))}add(t,e){const s=[];let r;if(Array.isArray(t)){if(t.map((t=>t[i(this,c)])).some((t=>i(this,d).has(t))))throw new Error("A duplicate id was found in the parameter array.");for(let e=0,i=t.length;e<i;e++)r=this._addItem(t[e]),s.push(r)}else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");r=this._addItem(t),s.push(r)}return s.length&&this._trigger("add",{items:s},e),s}update(t,e){const s=[],r=[],n=[],o=[],h=i(this,c),l=t=>{const e=t[h];if(null!=e&&i(this,d).has(e)){const s=t,h=Object.assign({},i(this,d).get(e)),l=this._updateItem(s);r.push(l),o.push(s),n.push(h)}else{const e=this._addItem(t);s.push(e)}};if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]&&"object"==typeof t[e]?l(t[e]):console.warn("Ignoring input item, which is not an object at index "+e);else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");l(t)}if(s.length&&this._trigger("add",{items:s},e),r.length){const t={items:r,oldData:n,data:o};this._trigger("update",t,e)}return s.concat(r)}updateOnly(t,s){Array.isArray(t)||(t=[t]);const r=t.map((t=>{const e=i(this,d).get(t[i(this,c)]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}})).map((({oldData:t,update:s})=>{const r=t[i(this,c)],n=e.pureDeepObjectAssign(t,s);return i(this,d).set(r,n),{id:r,oldData:t,updatedData:n}}));if(r.length){const t={items:r.map((t=>t.id)),oldData:r.map((t=>t.oldData)),data:r.map((t=>t.updatedData))};return this._trigger("update",t,s),t.items}return[]}get(t,e){let s=void 0,r=void 0,n=void 0;b(t)?(s=t,n=e):Array.isArray(t)?(r=t,n=e):n=t;const o=n&&"Object"===n.returnType?"Object":"Array",h=n&&n.filter,l=[];let a=void 0,u=void 0,f=void 0;if(null!=s)a=i(this,d).get(s),a&&h&&!h(a)&&(a=void 0);else if(null!=r)for(let t=0,e=r.length;t<e;t++)a=i(this,d).get(r[t]),null==a||h&&!h(a)||l.push(a);else{u=[...i(this,d).keys()];for(let t=0,e=u.length;t<e;t++)f=u[t],a=i(this,d).get(f),null==a||h&&!h(a)||l.push(a)}if(n&&n.order&&null==s&&this._sort(l,n.order),n&&n.fields){const t=n.fields;if(null!=s&&null!=a)a=this._filterFields(a,t);else for(let e=0,s=l.length;e<s;e++)l[e]=this._filterFields(l[e],t)}if("Object"==o){const t={};for(let e=0,s=l.length;e<s;e++){const s=l[e];t[s[i(this,c)]]=s}return t}return null!=s?null!=a?a:null:l}getIds(t){const e=i(this,d),s=t&&t.filter,r=t&&t.order,n=[...e.keys()],o=[];if(s)if(r){const t=[];for(let e=0,r=n.length;e<r;e++){const r=n[e],o=i(this,d).get(r);null!=o&&s(o)&&t.push(o)}this._sort(t,r);for(let e=0,s=t.length;e<s;e++)o.push(t[e][i(this,c)])}else for(let t=0,e=n.length;t<e;t++){const e=n[t],r=i(this,d).get(e);null!=r&&s(r)&&o.push(r[i(this,c)])}else if(r){const t=[];for(let s=0,i=n.length;s<i;s++){const i=n[s];t.push(e.get(i))}this._sort(t,r);for(let e=0,s=t.length;e<s;e++)o.push(t[e][i(this,c)])}else for(let t=0,s=n.length;t<s;t++){const s=n[t],r=e.get(s);null!=r&&o.push(r[i(this,c)])}return o}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,r=[...i(this,d).keys()];if(e&&e.order){const s=this.get(e);for(let e=0,r=s.length;e<r;e++){const r=s[e];t(r,r[i(this,c)])}}else for(let e=0,n=r.length;e<n;e++){const n=r[e],o=i(this,d).get(n);null==o||s&&!s(o)||t(o,n)}}map(t,e){const s=e&&e.filter,r=[],n=[...i(this,d).keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],h=i(this,d).get(o);null==h||s&&!s(h)||r.push(t(h,o))}return e&&e.order&&this._sort(r,e.order),r}_filterFields(t,e){return t?(Array.isArray(e)?e:Object.keys(e)).reduce(((e,s)=>(e[s]=t[s],e)),{}):t}_sort(t,e){if("string"==typeof e){const s=e;t.sort(((t,e)=>{const i=t[s],r=e[s];return i>r?1:i<r?-1:0}))}else{if("function"!=typeof e)throw new TypeError("Order must be a function or a string");t.sort(e)}}remove(t,e){const s=[],r=[],n=Array.isArray(t)?t:[t];for(let t=0,e=n.length;t<e;t++){const e=this._remove(n[t]);if(e){const t=e[i(this,c)];null!=t&&(s.push(t),r.push(e))}}return s.length&&this._trigger("remove",{items:s,oldData:r},e),s}_remove(t){let e;if(b(t)?e=t:t&&"object"==typeof t&&(e=t[i(this,c)]),null!=e&&i(this,d).has(e)){const t=i(this,d).get(e)||null;return i(this,d).delete(e),--this.length,t}return null}clear(t){const e=[...i(this,d).keys()],s=[];for(let t=0,r=e.length;t<r;t++)s.push(i(this,d).get(e[t]));return i(this,d).clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const r of i(this,d).values()){const i=r[t];"number"==typeof i&&(null==s||i>s)&&(e=r,s=i)}return e||null}min(t){let e=null,s=null;for(const r of i(this,d).values()){const i=r[t];"number"==typeof i&&(null==s||i<s)&&(e=r,s=i)}return e||null}distinct(t){const e=i(this,d),s=[...e.keys()],r=[];let n=0;for(let i=0,o=s.length;i<o;i++){const o=s[i],h=e.get(o)[t];let l=!1;for(let t=0;t<n;t++)if(r[t]==h){l=!0;break}l||void 0===h||(r[n]=h,n++)}return r}_addItem(t){const e=function(t,e){return null==t[e]&&(t[e]=s.v4()),t}(t,i(this,c)),r=e[i(this,c)];if(i(this,d).has(r))throw new Error("Cannot add item: item with id "+r+" already exists");return i(this,d).set(r,e),++this.length,r}_updateItem(t){const e=t[i(this,c)];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=i(this,d).get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");return i(this,d).set(e,{...s,...t}),e}stream(t){if(t){const e=i(this,d);return new I({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new I({[Symbol.iterator]:i(this,d).entries.bind(i(this,d))})}}f=new WeakMap,d=new WeakMap,c=new WeakMap,p=new WeakMap;class S extends E{constructor(t,e){super(),this.length=0,g.set(this,void 0),m.set(this,void 0),y.set(this,new Set),w.set(this,void 0),r(this,w,e||{}),r(this,g,this._onEvent.bind(this)),this.setData(t)}get idProp(){return this.getDataSet().idProp}setData(t){if(i(this,m)){i(this,m).off&&i(this,m).off("*",i(this,g));const t=i(this,m).getIds({filter:i(this,w).filter}),e=i(this,m).get(t);i(this,y).clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){r(this,m,t);const e=i(this,m).getIds({filter:i(this,w).filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];i(this,y).add(s)}this.length=e.length,this._trigger("add",{items:e})}else r(this,m,new k);i(this,m).on&&i(this,m).on("*",i(this,g))}refresh(){const t=i(this,m).getIds({filter:i(this,w).filter}),e=[...i(this,y)],s={},r=[],n=[],o=[];for(let e=0,n=t.length;e<n;e++){const n=t[e];s[n]=!0,i(this,y).has(n)||(r.push(n),i(this,y).add(n))}for(let t=0,r=e.length;t<r;t++){const r=e[t],h=i(this,m).get(r);null==h?console.error("If you see this, report it please."):s[r]||(n.push(r),o.push(h),i(this,y).delete(r))}this.length+=r.length-n.length,r.length&&this._trigger("add",{items:r}),n.length&&this._trigger("remove",{items:n,oldData:o})}get(t,e){if(null==i(this,m))return null;let s,r=null;b(t)||Array.isArray(t)?(r=t,s=e):s=t;const n=Object.assign({},i(this,w),s),o=i(this,w).filter,h=s&&s.filter;return o&&h&&(n.filter=t=>o(t)&&h(t)),null==r?i(this,m).get(n):i(this,m).get(r,n)}getIds(t){if(i(this,m).length){const e=i(this,w).filter,s=null!=t?t.filter:null;let r;return r=s?e?t=>e(t)&&s(t):s:e,i(this,m).getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(i(this,m)){const s=i(this,w).filter,r=e&&e.filter;let n;n=r?s?function(t){return s(t)&&r(t)}:r:s,i(this,m).forEach(t,{filter:n,order:e&&e.order})}}map(t,e){if(i(this,m)){const s=i(this,w).filter,r=e&&e.filter;let n;return n=r?s?t=>s(t)&&r(t):r:s,i(this,m).map(t,{filter:n,order:e&&e.order})}return[]}getDataSet(){return i(this,m).getDataSet()}stream(t){return i(this,m).stream(t||{[Symbol.iterator]:i(this,y).keys.bind(i(this,y))})}dispose(){var t;(null===(t=i(this,m))||void 0===t?void 0:t.off)&&i(this,m).off("*",i(this,g));const e="This data view has already been disposed of.",s={get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1};for(const t of Reflect.ownKeys(S.prototype))Object.defineProperty(this,t,s)}_onEvent(t,e,s){if(!e||!e.items||!i(this,m))return;const r=e.items,n=[],o=[],h=[],l=[],a=[],u=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(i(this,y).add(e),n.push(e))}break;case"update":for(let t=0,s=r.length;t<s;t++){const s=r[t];this.get(s)?i(this,y).has(s)?(o.push(s),a.push(e.data[t]),l.push(e.oldData[t])):(i(this,y).add(s),n.push(s)):i(this,y).has(s)&&(i(this,y).delete(s),h.push(s),u.push(e.oldData[t]))}break;case"remove":for(let t=0,s=r.length;t<s;t++){const s=r[t];i(this,y).has(s)&&(i(this,y).delete(s),h.push(s),u.push(e.oldData[t]))}}this.length+=n.length-h.length,n.length&&this._trigger("add",{items:n},s),o.length&&this._trigger("update",{items:o,oldData:l,data:a},s),h.length&&this._trigger("remove",{items:h,oldData:u},s)}}function j(t,e){return"object"==typeof e&&null!==e&&t===e.idProp&&"function"==typeof e.add&&"function"==typeof e.clear&&"function"==typeof e.distinct&&"function"==typeof e.forEach&&"function"==typeof e.get&&"function"==typeof e.getDataSet&&"function"==typeof e.getIds&&"number"==typeof e.length&&"function"==typeof e.map&&"function"==typeof e.max&&"function"==typeof e.min&&"function"==typeof e.off&&"function"==typeof e.on&&"function"==typeof e.remove&&"function"==typeof e.setOptions&&"function"==typeof e.stream&&"function"==typeof e.update&&"function"==typeof e.updateOnly}g=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,Object.defineProperty(t,"DELETE",{enumerable:!0,get:function(){return e.DELETE}}),t.DataSet=k,t.DataStream=I,t.DataView=S,t.Queue=D,t.createNewDataPipeFrom=function(t){return new v(t)},t.isDataSetLike=j,t.isDataViewLike=function(t,e){return"object"==typeof e&&null!==e&&t===e.idProp&&"function"==typeof e.forEach&&"function"==typeof e.get&&"function"==typeof e.getDataSet&&"function"==typeof e.getIds&&"number"==typeof e.length&&"function"==typeof e.map&&"function"==typeof e.off&&"function"==typeof e.on&&"function"==typeof e.stream&&j(t,e.getDataSet())},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=vis-data.min.js.map |
{ | ||
"name": "vis-data", | ||
"version": "7.0.1", | ||
"version": "7.1.0", | ||
"description": "Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.", | ||
@@ -100,2 +100,3 @@ "homepage": "http://visjs.org/", | ||
"rollup": "2.29.0", | ||
"sazerac": "2.0.0", | ||
"sinon": "9.2.0", | ||
@@ -102,0 +103,0 @@ "snap-shot-it": "7.9.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8040664
88
46777
25