Comparing version 6.6.1 to 7.0.0
@@ -5,16 +5,2 @@ import { Assignable } from "vis-util/esnext"; | ||
declare type ValueOf<T> = T[keyof T]; | ||
/** | ||
* Available types for enforcing property types. | ||
* | ||
* | Name | Description | Examples | | ||
* |---------|-----------------------------------------|-----------------------------------------------------------| | ||
* | Boolean | A JavaScript Boolean | `true`, `false` | | ||
* | Number | A JavaScript Number | `32`, `2.4` | | ||
* | String | A JavaScript String | `"hello world"`, `"2013-06-28"` | | ||
* | Date | A JavaScript Date object | `new Date()`, `new Date(2013, 5, 28)`, `new Date(13723 | | ||
* | Moment | A Moment object, created with moment.js | `moment()`, `moment('2013-06-28')` | | ||
* | ISODate | A string containing an ISO Date | `new Date().toISOString()`, `"2013-06-27T22:00:00.000Z"` | | ||
* | ASPDate | A string containing an ASP Date | `"/Date(1372370400000)/"`, `"/Date(1198908717056-0700)/"` | | ||
*/ | ||
export declare type Types = "boolean" | "Boolean" | "number" | "Number" | "string" | "String" | "Date" | "ISODate" | "ASPDate" | "Moment"; | ||
/** Valid id type. */ | ||
@@ -159,4 +145,2 @@ export declare type Id = number | string; | ||
export declare type EventNameWithAny = keyof EventPayloadsWithAny<never, "">; | ||
/** Maps property name to their types. */ | ||
export declare type TypeMap = Record<string, Types>; | ||
/** | ||
@@ -187,9 +171,2 @@ * Data interface order parameter. | ||
order?: DataInterfaceOrder<Item>; | ||
/** | ||
* An object containing field names as key, and data types as value. By default, the type of the properties of an item are left unchanged. When a field type is specified, this field in the items will be converted to the specified type. This can be used for example to convert ISO strings containing a date to a JavaScript Date object, or convert strings to numbers or vice versa. | ||
* | ||
* @remarks | ||
* **Warning**: There is no TypeScript support for this. | ||
*/ | ||
type?: TypeMap; | ||
} | ||
@@ -238,4 +215,2 @@ /** | ||
order?: DataInterfaceOrder<Item>; | ||
/** An object containing field names as key, and data types as value. By default, the type of the properties of an item are left unchanged. When a field type is specified, this field in the items will be converted to the specified type. This can be used for example to convert ISO strings containing a date to a JavaScript Date object, or convert strings to numbers or vice versa. */ | ||
type?: TypeMap; | ||
} | ||
@@ -254,4 +229,2 @@ /** | ||
order?: DataInterfaceOrder<Item>; | ||
/** An object containing field names as key, and data types as value. By default, the type of the properties of an item are left unchanged. When a field type is specified, this field in the items will be converted to the specified type. This can be used for example to convert ISO strings containing a date to a JavaScript Date object, or convert strings to numbers or vice versa. */ | ||
type?: TypeMap; | ||
} | ||
@@ -271,4 +244,2 @@ /** | ||
order?: DataInterfaceOrder<Mapped>; | ||
/** An object containing field names as key, and data types as value. By default, the type of the properties of an item are left unchanged. When a field type is specified, this field in the items will be converted to the specified type. This can be used for example to convert ISO strings containing a date to a JavaScript Date object, or convert strings to numbers or vice versa. */ | ||
type?: TypeMap; | ||
} | ||
@@ -275,0 +246,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { DataInterface, DataInterfaceForEachOptions, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DeepPartial, FullItem, Id, PartItem, TypeMap, UpdateItem } from "./data-interface"; | ||
import { DataInterface, DataInterfaceForEachOptions, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DeepPartial, FullItem, Id, PartItem, UpdateItem } from "./data-interface"; | ||
import { QueueOptions } from "./queue"; | ||
@@ -16,11 +16,2 @@ import { DataSetPart } from "./data-set-part"; | ||
/** | ||
* An object containing field names as key, and data types as value. By default, the type of the properties of items are left unchanged. Item properties can be normalized by specifying a field type. This is useful for example to automatically convert stringified dates coming from a server into JavaScript Date objects. The available data types are listed in [[TypeMap]]. | ||
* | ||
* @remarks | ||
* **Warning**: There is no TypeScript support for this. | ||
* | ||
* @deprecated | ||
*/ | ||
type?: TypeMap; | ||
/** | ||
* Queue data changes ('add', 'update', 'remove') and flush them at once. The queue can be flushed manually by calling `DataSet.flush()`, or can be flushed after a configured delay or maximum number of entries. | ||
@@ -45,3 +36,8 @@ * | ||
* | ||
* Vis.js comes with a flexible DataSet, which can be used to hold and manipulate unstructured data and listen for changes in the data. The DataSet is key/value based. Data items can be added, updated and removed from the DataSet, and one can subscribe to changes in the DataSet. The data in the DataSet can be filtered and ordered, and fields (like dates) can be converted to a specific type. Data can be normalized when appending it to the DataSet as well. | ||
* Vis.js comes with a flexible DataSet, which can be used to hold and | ||
* manipulate unstructured data and listen for changes in the data. The DataSet | ||
* is key/value based. Data items can be added, updated and removed from the | ||
* DataSet, and one can subscribe to changes in the DataSet. The data in the | ||
* DataSet can be filtered and ordered. Data can be normalized when appending it | ||
* to the DataSet as well. | ||
* | ||
@@ -105,3 +101,2 @@ * ## Example | ||
private readonly _idProp; | ||
private readonly _type; | ||
private _queue?; | ||
@@ -344,3 +339,2 @@ /** | ||
private _addItem; | ||
private _getItem; | ||
/** | ||
@@ -350,3 +344,3 @@ * Update a single item: merge with existing item. | ||
* | ||
* @param item - The new item | ||
* @param update - The new item | ||
* | ||
@@ -353,0 +347,0 @@ * @returns The id of the updated item. |
@@ -1,2 +0,2 @@ | ||
export { DataInterface, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DataInterfaceOrder, EventCallbacks, EventCallbacksWithAny, EventName, EventNameWithAny, TypeMap, Types, } from "./data-interface"; | ||
export { DataInterface, DataInterfaceGetIdsOptions, DataInterfaceGetOptions, DataInterfaceGetOptionsArray, DataInterfaceGetOptionsObject, DataInterfaceMapOptions, DataInterfaceOrder, EventCallbacks, EventCallbacksWithAny, EventName, EventNameWithAny, } from "./data-interface"; | ||
export * from "./data-pipe"; | ||
@@ -3,0 +3,0 @@ export { DataSet, DataSetOptions } from "./data-set"; |
@@ -7,4 +7,4 @@ /** | ||
* | ||
* @version 6.6.1 | ||
* @date 2020-06-15T13:21:34.180Z | ||
* @version 7.0.0 | ||
* @date 2020-08-02T17:48:43.502Z | ||
* | ||
@@ -27,3 +27,3 @@ * @copyright (c) 2011-2017 Almende B.V, http://almende.com | ||
*/ | ||
import{v4 as t}from"uuid";import{isNumber as e,isString as s,getType as r,pureDeepObjectAssign as i}from"vis-util/esnext/esm/vis-util.js";export{DELETE}from"vis-util/esnext/esm/vis-util.js";import n from"moment";function o(t){return new h(t)}class a{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 h{constructor(t){this._source=t,this._transformers=[]}filter(t){return this._transformers.push(e=>e.filter(t)),this}map(t){return this._transformers.push(e=>e.map(t)),this}flatMap(t){return this._transformers.push(e=>e.flatMap(t)),this}to(t){return new a(this._source,this._transformers,t)}}const l=/^\/?Date\((-?\d+)/i;function u(t){return n.isMoment(t)}function d(t,i){let o;if(void 0!==t){if(null===t)return null;if(!i)return t;if("string"!=typeof i&&!(i instanceof String))throw new Error("Type must be a string");switch(i){case"boolean":case"Boolean":return Boolean(t);case"number":case"Number":return s(t)&&!isNaN(Date.parse(t))?n(t).valueOf():Number(t.valueOf());case"string":case"String":return String(t);case"Date":if(e(t))return new Date(t);if(t instanceof Date)return new Date(t.valueOf());if(u(t))return new Date(t.valueOf());if(s(t))return o=l.exec(t),o?new Date(Number(o[1])):n(new Date(t)).toDate();throw new Error("Cannot convert object of type "+r(t)+" to type Date");case"Moment":if(e(t))return n(t);if(t instanceof Date)return n(t.valueOf());if(u(t))return n(t);if(s(t))return o=l.exec(t),n(o?Number(o[1]):t);throw new Error("Cannot convert object of type "+r(t)+" to type Date");case"ISODate":if(e(t))return new Date(t);if(t instanceof Date)return t.toISOString();if(u(t))return t.toDate().toISOString();if(s(t))return o=l.exec(t),o?new Date(Number(o[1])).toISOString():n(t).format();throw new Error("Cannot convert object of type "+r(t)+" to type ISODate");case"ASPDate":if(e(t))return"/Date("+t+")/";if(t instanceof Date||u(t))return"/Date("+t.valueOf()+")/";if(s(t)){let e;return o=l.exec(t),e=o?new Date(Number(o[1])).valueOf():new Date(t).valueOf(),"/Date("+e+")/"}throw new Error("Cannot convert object of type "+r(t)+" to type ASPDate");default:throw new Error("Unknown type "+i)}}}function f(t){return"string"==typeof t||"number"==typeof t}class _{constructor(t){this._queue=[],this._timeout=null,this._extended=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 _(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 s._extended={object:t,methods:r},s}destroy(){if(this.flush(),this._extended){const t=this._extended.object,e=this._extended.methods;for(let s=0;s<e.length;s++){const r=e[s];r.original?t[r.name]=r.original:delete t[r.name]}this._extended=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?this._queue.push({fn:t}):this._queue.push(t),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),null!=this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&"number"==typeof this.delay&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(t=>{t.fn.apply(t.context||t.fn,t.args||[])})}}class c{constructor(){this._subscribers={"*":[],add:[],remove:[],update:[]},this.subscribe=c.prototype.on,this.unsubscribe=c.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...this._subscribers[t],...this._subscribers["*"]].forEach(r=>{r(t,e,null!=s?s:null)})}on(t,e){"function"==typeof e&&this._subscribers[t].push(e)}off(t,e){this._subscribers[t]=this._subscribers[t].filter(t=>t!==e)}}class p{constructor(t){this._pairs=t}*[Symbol.iterator](){for(const[t,e]of this._pairs)yield[t,e]}*entries(){for(const[t,e]of this._pairs)yield[t,e]}*keys(){for(const[t]of this._pairs)yield t}*values(){for(const[,t]of this._pairs)yield t}toIdArray(){return[...this._pairs].map(t=>t[0])}toItemArray(){return[...this._pairs].map(t=>t[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){const t=Object.create(null);for(const[e,s]of this._pairs)t[e]=s;return t}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new p([...this._pairs])}distinct(t){const e=new Set;for(const[s,r]of this._pairs)e.add(t(r,s));return e}filter(t){const e=this._pairs;return new p({*[Symbol.iterator](){for(const[s,r]of e)t(r,s)&&(yield[s,r])}})}forEach(t){for(const[e,s]of this._pairs)t(s,e)}map(t){const e=this._pairs;return new p({*[Symbol.iterator](){for(const[s,r]of e)yield[s,t(r,s)]}})}max(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o>i&&(i=o,r=n)}return r}min(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o<i&&(i=o,r=n)}return r}reduce(t,e){for(const[s,r]of this._pairs)e=t(e,r,s);return e}sort(t){return new p({[Symbol.iterator]:()=>[...this._pairs].sort(([e,s],[r,i])=>t(s,i,e,r))[Symbol.iterator]()})}}const g=()=>{console.warn("Type coercion has been deprecated. Please, use data pipes instead. See https://visjs.github.io/vis-data/data/datapipe.html#TypeCoercion for more details with working migration example.")};class m extends c{constructor(t,e){if(super(),t&&!Array.isArray(t)&&(e=t,t=[]),this._options=e||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",this._type={},this._options.type){g();const t=Object.keys(this._options.type);for(let e=0,s=t.length;e<s;e++){const s=t[e],r=this._options.type[s];this._type[s]="Date"==r||"ISODate"==r||"ASPDate"==r?"Date":r}}t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=_.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&this._queue.setOptions(t.queue)))}add(t,e){const s=[];let r;if(Array.isArray(t)){if(t.map(t=>t[this._idProp]).some(t=>this._data.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=[],i=[],n=[],o=this._idProp,a=t=>{const e=t[o];if(null!=e&&this._data.has(e)){const s=t,o=Object.assign({},this._data.get(e)),a=this._updateItem(s);r.push(a),n.push(s),i.push(o)}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]?a(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");a(t)}if(s.length&&this._trigger("add",{items:s},e),r.length){const t={items:r,oldData:i,data:n};this._trigger("update",t,e)}return s.concat(r)}updateOnly(t,e){Array.isArray(t)||(t=[t]);const s=t.map(t=>{const e=this._data.get(t[this._idProp]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}}).map(({oldData:t,update:e})=>{const s=t[this._idProp],r=i(t,e);return this._data.set(s,r),{id:s,oldData:t,updatedData:r}});if(s.length){const t={items:s.map(t=>t.id),oldData:s.map(t=>t.oldData),data:s.map(t=>t.updatedData)};return this._trigger("update",t,e),t.items}return[]}get(t,e){let s=void 0,r=void 0,i=void 0;f(t)?(s=t,i=e):Array.isArray(t)?(r=t,i=e):i=t;const n=i&&"Object"===i.returnType?"Object":"Array",o=i&&i.type||this._options.type,a=i&&i.filter,h=[];let l=null,u=null,d=null;if(null!=s)l=this._getItem(s,o),l&&a&&!a(l)&&(l=null);else if(null!=r)for(let t=0,e=r.length;t<e;t++)l=this._getItem(r[t],o),null==l||a&&!a(l)||h.push(l);else{u=[...this._data.keys()];for(let t=0,e=u.length;t<e;t++)d=u[t],l=this._getItem(d,o),null==l||a&&!a(l)||h.push(l)}if(i&&i.order&&null==s&&this._sort(h,i.order),i&&i.fields){const t=i.fields;if(null!=s&&null!=l)l=this._filterFields(l,t);else for(let e=0,s=h.length;e<s;e++)h[e]=this._filterFields(h[e],t)}if("Object"==n){const t={};for(let e=0,s=h.length;e<s;e++){const s=h[e];t[s[this._idProp]]=s}return t}return null!=s?l:h}getIds(t){const e=this._data,s=t&&t.filter,r=t&&t.order,i=t&&t.type||this._options.type,n=[...e.keys()],o=[];let a,h;if(s)if(r){h=[];for(let t=0,e=n.length;t<e;t++){const e=n[t];a=this._getItem(e,i),s(a)&&h.push(a)}this._sort(h,r);for(let t=0,e=h.length;t<e;t++)o.push(h[t][this._idProp])}else for(let t=0,e=n.length;t<e;t++){const e=n[t];a=this._getItem(e,i),s(a)&&o.push(a[this._idProp])}else if(r){h=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];h.push(e.get(s))}this._sort(h,r);for(let t=0,e=h.length;t<e;t++)o.push(h[t][this._idProp])}else for(let t=0,s=n.length;t<s;t++){const s=n[t];a=e.get(s),o.push(a[this._idProp])}return o}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,r=e&&e.type||this._options.type,i=[...this._data.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[this._idProp])}}else for(let e=0,n=i.length;e<n;e++){const n=i[e],o=this._getItem(n,r);s&&!s(o)||t(o,n)}}map(t,e){const s=e&&e.filter,r=e&&e.type||this._options.type,i=[],n=[...this._data.keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],a=this._getItem(o,r);s&&!s(a)||i.push(t(a,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 s=[],r=[],i=Array.isArray(t)?t:[t];for(let t=0,e=i.length;t<e;t++){const e=this._remove(i[t]);if(e){const t=e[this._idProp];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(f(t)?e=t:t&&"object"==typeof t&&(e=t[this._idProp]),null!=e&&this._data.has(e)){const t=this._data.get(e)||null;return this._data.delete(e),--this.length,t}return null}clear(t){const e=[...this._data.keys()],s=[];for(let t=0,r=e.length;t<r;t++)s.push(this._data.get(e[t]));return this._data.clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const r of this._data.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 this._data.values()){const i=r[t];"number"==typeof i&&(null==s||i<s)&&(e=r,s=i)}return e||null}distinct(t){const e=this._data,s=[...e.keys()],r=[],i=this._options.type&&this._options.type[t]||null;let n=0;for(let i=0,o=s.length;i<o;i++){const o=s[i],a=e.get(o)[t];let h=!1;for(let t=0;t<n;t++)if(r[t]==a){h=!0;break}h||void 0===a||(r[n]=a,n++)}if(i)for(let t=0,e=r.length;t<e;t++)r[t]=d(r[t],i);return r}_addItem(e){let s=e[this._idProp];if(null!=s){if(this._data.has(s))throw new Error("Cannot add item: item with id "+s+" already exists")}else s=t(),e[this._idProp]=s;const r={},i=Object.keys(e);for(let t=0,s=i.length;t<s;t++){const s=i[t],n=this._type[s];r[s]=d(e[s],n)}return this._data.set(s,r),++this.length,s}_getItem(t,e){const s=this._data.get(t);if(!s)return null;let r;const i=Object.keys(s);if(e){g(),r={};for(let t=0,n=i.length;t<n;t++){const n=i[t],o=s[n];r[n]=d(o,e[n])}}else r={...s};return null==r[this._idProp]&&(r[this._idProp]=s.id),r}_updateItem(t){const e=t[this._idProp];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=this._data.get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");const r=Object.keys(t);for(let e=0,i=r.length;e<i;e++){const i=r[e],n=this._type[i];s[i]=d(t[i],n)}return e}stream(t){if(t){const e=this._data;return new p({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new p({[Symbol.iterator]:this._data.entries.bind(this._data)})}}class y extends c{constructor(t,e){super(),this.length=0,this._ids=new Set,this._options=e||{},this._listener=this._onEvent.bind(this),this.setData(t)}setData(t){if(this._data){this._data.off&&this._data.off("*",this._listener);const t=this._data.getIds({filter:this._options.filter}),e=this._data.get(t);this._ids.clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){this._data=t;const e=this._data.getIds({filter:this._options.filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];this._ids.add(s)}this.length=e.length,this._trigger("add",{items:e})}else this._data=new m;this._data.on&&this._data.on("*",this._listener)}refresh(){const t=this._data.getIds({filter:this._options.filter}),e=[...this._ids],s={},r=[],i=[],n=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];s[i]=!0,this._ids.has(i)||(r.push(i),this._ids.add(i))}for(let t=0,r=e.length;t<r;t++){const r=e[t],o=this._data.get(r);null==o?console.error("If you see this, report it please."):s[r]||(i.push(r),n.push(o),this._ids.delete(r))}this.length+=r.length-i.length,r.length&&this._trigger("add",{items:r}),i.length&&this._trigger("remove",{items:i,oldData:n})}get(t,e){if(null==this._data)return null;let s,r=null;f(t)||Array.isArray(t)?(r=t,s=e):s=t;const i=Object.assign({},this._options,s),n=this._options.filter,o=s&&s.filter;return n&&o&&(i.filter=t=>n(t)&&o(t)),null==r?this._data.get(i):this._data.get(r,i)}getIds(t){if(this._data.length){const e=this._options.filter,s=null!=t?t.filter:null;let r;return r=s?e?t=>e(t)&&s(t):s:e,this._data.getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;i=r?s?function(t){return s(t)&&r(t)}:r:s,this._data.forEach(t,{filter:i,order:e&&e.order})}}map(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;return i=r?s?t=>s(t)&&r(t):r:s,this._data.map(t,{filter:i,order:e&&e.order})}return[]}getDataSet(){return this._data.getDataSet()}stream(t){return this._data.stream(t||{[Symbol.iterator]:this._ids.keys.bind(this._ids)})}dispose(){var t;(null===(t=this._data)||void 0===t?void 0:t.off)&&this._data.off("*",this._listener);const e="This data view has already been disposed of.";Object.defineProperty(this,"_data",{get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1})}_onEvent(t,e,s){if(!e||!e.items||!this._data)return;const r=e.items,i=[],n=[],o=[],a=[],h=[],l=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(this._ids.add(e),i.push(e))}break;case"update":for(let t=0,s=r.length;t<s;t++){const s=r[t];this.get(s)?this._ids.has(s)?(n.push(s),h.push(e.data[t]),a.push(e.oldData[t])):(this._ids.add(s),i.push(s)):this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}break;case"remove":for(let t=0,s=r.length;t<s;t++){const s=r[t];this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}}this.length+=i.length-o.length,i.length&&this._trigger("add",{items:i},s),n.length&&this._trigger("update",{items:n,oldData:a,data:h},s),o.length&&this._trigger("remove",{items:o,oldData:l},s)}}export{m as DataSet,p as DataStream,y as DataView,_ as Queue,o as createNewDataPipeFrom}; | ||
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";function s(t){return new i(t)}class r{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 i{constructor(t){this._source=t,this._transformers=[]}filter(t){return this._transformers.push(e=>e.filter(t)),this}map(t){return this._transformers.push(e=>e.map(t)),this}flatMap(t){return this._transformers.push(e=>e.flatMap(t)),this}to(t){return new r(this._source,this._transformers,t)}}function o(t){return"string"==typeof t||"number"==typeof t}class n{constructor(t){this._queue=[],this._timeout=null,this._extended=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 n(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 o=e.replace[i];r.push({name:o,original:t[o]}),s.replace(t,o)}return s._extended={object:t,methods:r},s}destroy(){if(this.flush(),this._extended){const t=this._extended.object,e=this._extended.methods;for(let s=0;s<e.length;s++){const r=e[s];r.original?t[r.name]=r.original:delete t[r.name]}this._extended=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?this._queue.push({fn:t}):this._queue.push(t),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),null!=this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&"number"==typeof this.delay&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(t=>{t.fn.apply(t.context||t.fn,t.args||[])})}}class a{constructor(){this._subscribers={"*":[],add:[],remove:[],update:[]},this.subscribe=a.prototype.on,this.unsubscribe=a.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...this._subscribers[t],...this._subscribers["*"]].forEach(r=>{r(t,e,null!=s?s:null)})}on(t,e){"function"==typeof e&&this._subscribers[t].push(e)}off(t,e){this._subscribers[t]=this._subscribers[t].filter(t=>t!==e)}}class h{constructor(t){this._pairs=t}*[Symbol.iterator](){for(const[t,e]of this._pairs)yield[t,e]}*entries(){for(const[t,e]of this._pairs)yield[t,e]}*keys(){for(const[t]of this._pairs)yield t}*values(){for(const[,t]of this._pairs)yield t}toIdArray(){return[...this._pairs].map(t=>t[0])}toItemArray(){return[...this._pairs].map(t=>t[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){const t=Object.create(null);for(const[e,s]of this._pairs)t[e]=s;return t}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new h([...this._pairs])}distinct(t){const e=new Set;for(const[s,r]of this._pairs)e.add(t(r,s));return e}filter(t){const e=this._pairs;return new h({*[Symbol.iterator](){for(const[s,r]of e)t(r,s)&&(yield[s,r])}})}forEach(t){for(const[e,s]of this._pairs)t(s,e)}map(t){const e=this._pairs;return new h({*[Symbol.iterator](){for(const[s,r]of e)yield[s,t(r,s)]}})}max(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,o]=s.value,n=t(o,e);n>i&&(i=n,r=o)}return r}min(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,o]=s.value,n=t(o,e);n<i&&(i=n,r=o)}return r}reduce(t,e){for(const[s,r]of this._pairs)e=t(e,r,s);return e}sort(t){return new h({[Symbol.iterator]:()=>[...this._pairs].sort(([e,s],[r,i])=>t(s,i,e,r))[Symbol.iterator]()})}}class l extends a{constructor(t,e){super(),t&&!Array.isArray(t)&&(e=t,t=[]),this._options=e||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=n.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&this._queue.setOptions(t.queue)))}add(t,e){const s=[];let r;if(Array.isArray(t)){if(t.map(t=>t[this._idProp]).some(t=>this._data.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=[],i=[],o=[],n=this._idProp,a=t=>{const e=t[n];if(null!=e&&this._data.has(e)){const s=t,n=Object.assign({},this._data.get(e)),a=this._updateItem(s);r.push(a),o.push(s),i.push(n)}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]?a(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");a(t)}if(s.length&&this._trigger("add",{items:s},e),r.length){const t={items:r,oldData:i,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=this._data.get(t[this._idProp]);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[this._idProp],i=e(t,s);return this._data.set(r,i),{id:r,oldData:t,updatedData:i}});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,i=void 0;o(t)?(s=t,i=e):Array.isArray(t)?(r=t,i=e):i=t;const n=i&&"Object"===i.returnType?"Object":"Array",a=i&&i.filter,h=[];let l=void 0,d=void 0,u=void 0;if(null!=s)l=this._data.get(s),l&&a&&!a(l)&&(l=void 0);else if(null!=r)for(let t=0,e=r.length;t<e;t++)l=this._data.get(r[t]),null==l||a&&!a(l)||h.push(l);else{d=[...this._data.keys()];for(let t=0,e=d.length;t<e;t++)u=d[t],l=this._data.get(u),null==l||a&&!a(l)||h.push(l)}if(i&&i.order&&null==s&&this._sort(h,i.order),i&&i.fields){const t=i.fields;if(null!=s&&null!=l)l=this._filterFields(l,t);else for(let e=0,s=h.length;e<s;e++)h[e]=this._filterFields(h[e],t)}if("Object"==n){const t={};for(let e=0,s=h.length;e<s;e++){const s=h[e];t[s[this._idProp]]=s}return t}return null!=s?null!=l?l:null:h}getIds(t){const e=this._data,s=t&&t.filter,r=t&&t.order,i=[...e.keys()],o=[];if(s)if(r){const t=[];for(let e=0,r=i.length;e<r;e++){const r=i[e],o=this._data.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][this._idProp])}else for(let t=0,e=i.length;t<e;t++){const e=i[t],r=this._data.get(e);null!=r&&s(r)&&o.push(r[this._idProp])}else if(r){const t=[];for(let s=0,r=i.length;s<r;s++){const r=i[s];t.push(e.get(r))}this._sort(t,r);for(let e=0,s=t.length;e<s;e++)o.push(t[e][this._idProp])}else for(let t=0,s=i.length;t<s;t++){const s=i[t],r=e.get(s);null!=r&&o.push(r[this._idProp])}return o}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,r=[...this._data.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[this._idProp])}}else for(let e=0,i=r.length;e<i;e++){const i=r[e],o=this._data.get(i);null==o||s&&!s(o)||t(o,i)}}map(t,e){const s=e&&e.filter,r=[],i=[...this._data.keys()];for(let e=0,o=i.length;e<o;e++){const o=i[e],n=this._data.get(o);null==n||s&&!s(n)||r.push(t(n,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 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 s=[],r=[],i=Array.isArray(t)?t:[t];for(let t=0,e=i.length;t<e;t++){const e=this._remove(i[t]);if(e){const t=e[this._idProp];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(o(t)?e=t:t&&"object"==typeof t&&(e=t[this._idProp]),null!=e&&this._data.has(e)){const t=this._data.get(e)||null;return this._data.delete(e),--this.length,t}return null}clear(t){const e=[...this._data.keys()],s=[];for(let t=0,r=e.length;t<r;t++)s.push(this._data.get(e[t]));return this._data.clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const r of this._data.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 this._data.values()){const i=r[t];"number"==typeof i&&(null==s||i<s)&&(e=r,s=i)}return e||null}distinct(t){const e=this._data,s=[...e.keys()],r=[];let i=0;for(let o=0,n=s.length;o<n;o++){const n=s[o],a=e.get(n)[t];let h=!1;for(let t=0;t<i;t++)if(r[t]==a){h=!0;break}h||void 0===a||(r[i]=a,i++)}return r}_addItem(e){const s=function(e,s){return null==e[s]&&(e[s]=t()),e}(e,this._idProp),r=s[this._idProp];if(this._data.has(r))throw new Error("Cannot add item: item with id "+r+" already exists");return this._data.set(r,s),++this.length,r}_updateItem(t){const e=t[this._idProp];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=this._data.get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");return this._data.set(e,{...s,...t}),e}stream(t){if(t){const e=this._data;return new h({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new h({[Symbol.iterator]:this._data.entries.bind(this._data)})}}class d extends a{constructor(t,e){super(),this.length=0,this._ids=new Set,this._options=e||{},this._listener=this._onEvent.bind(this),this.setData(t)}setData(t){if(this._data){this._data.off&&this._data.off("*",this._listener);const t=this._data.getIds({filter:this._options.filter}),e=this._data.get(t);this._ids.clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){this._data=t;const e=this._data.getIds({filter:this._options.filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];this._ids.add(s)}this.length=e.length,this._trigger("add",{items:e})}else this._data=new l;this._data.on&&this._data.on("*",this._listener)}refresh(){const t=this._data.getIds({filter:this._options.filter}),e=[...this._ids],s={},r=[],i=[],o=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];s[i]=!0,this._ids.has(i)||(r.push(i),this._ids.add(i))}for(let t=0,r=e.length;t<r;t++){const r=e[t],n=this._data.get(r);null==n?console.error("If you see this, report it please."):s[r]||(i.push(r),o.push(n),this._ids.delete(r))}this.length+=r.length-i.length,r.length&&this._trigger("add",{items:r}),i.length&&this._trigger("remove",{items:i,oldData:o})}get(t,e){if(null==this._data)return null;let s,r=null;o(t)||Array.isArray(t)?(r=t,s=e):s=t;const i=Object.assign({},this._options,s),n=this._options.filter,a=s&&s.filter;return n&&a&&(i.filter=t=>n(t)&&a(t)),null==r?this._data.get(i):this._data.get(r,i)}getIds(t){if(this._data.length){const e=this._options.filter,s=null!=t?t.filter:null;let r;return r=s?e?t=>e(t)&&s(t):s:e,this._data.getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;i=r?s?function(t){return s(t)&&r(t)}:r:s,this._data.forEach(t,{filter:i,order:e&&e.order})}}map(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;return i=r?s?t=>s(t)&&r(t):r:s,this._data.map(t,{filter:i,order:e&&e.order})}return[]}getDataSet(){return this._data.getDataSet()}stream(t){return this._data.stream(t||{[Symbol.iterator]:this._ids.keys.bind(this._ids)})}dispose(){var t;(null===(t=this._data)||void 0===t?void 0:t.off)&&this._data.off("*",this._listener);const e="This data view has already been disposed of.";Object.defineProperty(this,"_data",{get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1})}_onEvent(t,e,s){if(!e||!e.items||!this._data)return;const r=e.items,i=[],o=[],n=[],a=[],h=[],l=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(this._ids.add(e),i.push(e))}break;case"update":for(let t=0,s=r.length;t<s;t++){const s=r[t];this.get(s)?this._ids.has(s)?(o.push(s),h.push(e.data[t]),a.push(e.oldData[t])):(this._ids.add(s),i.push(s)):this._ids.has(s)&&(this._ids.delete(s),n.push(s),l.push(e.oldData[t]))}break;case"remove":for(let t=0,s=r.length;t<s;t++){const s=r[t];this._ids.has(s)&&(this._ids.delete(s),n.push(s),l.push(e.oldData[t]))}}this.length+=i.length-n.length,i.length&&this._trigger("add",{items:i},s),o.length&&this._trigger("update",{items:o,oldData:a,data:h},s),n.length&&this._trigger("remove",{items:n,oldData:l},s)}}export{l as DataSet,h as DataStream,d as DataView,n as Queue,s as createNewDataPipeFrom}; | ||
//# sourceMappingURL=vis-data.min.js.map |
@@ -7,4 +7,4 @@ /** | ||
* | ||
* @version 6.6.1 | ||
* @date 2020-06-15T13:21:34.180Z | ||
* @version 7.0.0 | ||
* @date 2020-08-02T17:48:43.502Z | ||
* | ||
@@ -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"),require("moment")):"function"==typeof define&&define.amd?define(["exports","uuid","vis-util/esnext/umd/vis-util.js","moment"],e):e((t=t||self).vis=t.vis||{},t.uuidv4,t.vis,t.moment)}(this,(function(t,e,s,r){r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;class i{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 n{constructor(t){this._source=t,this._transformers=[]}filter(t){return this._transformers.push(e=>e.filter(t)),this}map(t){return this._transformers.push(e=>e.map(t)),this}flatMap(t){return this._transformers.push(e=>e.flatMap(t)),this}to(t){return new i(this._source,this._transformers,t)}}const o=/^\/?Date\((-?\d+)/i;function a(t){return r.isMoment(t)}function h(t,e){let i;if(void 0!==t){if(null===t)return null;if(!e)return t;if("string"!=typeof e&&!(e instanceof String))throw new Error("Type must be a string");switch(e){case"boolean":case"Boolean":return Boolean(t);case"number":case"Number":return s.isString(t)&&!isNaN(Date.parse(t))?r(t).valueOf():Number(t.valueOf());case"string":case"String":return String(t);case"Date":if(s.isNumber(t))return new Date(t);if(t instanceof Date)return new Date(t.valueOf());if(a(t))return new Date(t.valueOf());if(s.isString(t))return i=o.exec(t),i?new Date(Number(i[1])):r(new Date(t)).toDate();throw new Error("Cannot convert object of type "+s.getType(t)+" to type Date");case"Moment":if(s.isNumber(t))return r(t);if(t instanceof Date)return r(t.valueOf());if(a(t))return r(t);if(s.isString(t))return i=o.exec(t),r(i?Number(i[1]):t);throw new Error("Cannot convert object of type "+s.getType(t)+" to type Date");case"ISODate":if(s.isNumber(t))return new Date(t);if(t instanceof Date)return t.toISOString();if(a(t))return t.toDate().toISOString();if(s.isString(t))return i=o.exec(t),i?new Date(Number(i[1])).toISOString():r(t).format();throw new Error("Cannot convert object of type "+s.getType(t)+" to type ISODate");case"ASPDate":if(s.isNumber(t))return"/Date("+t+")/";if(t instanceof Date||a(t))return"/Date("+t.valueOf()+")/";if(s.isString(t)){let e;return i=o.exec(t),e=i?new Date(Number(i[1])).valueOf():new Date(t).valueOf(),"/Date("+e+")/"}throw new Error("Cannot convert object of type "+s.getType(t)+" to type ASPDate");default:throw new Error("Unknown type "+e)}}}function l(t){return"string"==typeof t||"number"==typeof t}class u{constructor(t){this._queue=[],this._timeout=null,this._extended=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 u(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 s._extended={object:t,methods:r},s}destroy(){if(this.flush(),this._extended){const t=this._extended.object,e=this._extended.methods;for(let s=0;s<e.length;s++){const r=e[s];r.original?t[r.name]=r.original:delete t[r.name]}this._extended=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?this._queue.push({fn:t}):this._queue.push(t),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),null!=this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&"number"==typeof this.delay&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(t=>{t.fn.apply(t.context||t.fn,t.args||[])})}}class d{constructor(){this._subscribers={"*":[],add:[],remove:[],update:[]},this.subscribe=d.prototype.on,this.unsubscribe=d.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...this._subscribers[t],...this._subscribers["*"]].forEach(r=>{r(t,e,null!=s?s:null)})}on(t,e){"function"==typeof e&&this._subscribers[t].push(e)}off(t,e){this._subscribers[t]=this._subscribers[t].filter(t=>t!==e)}}class f{constructor(t){this._pairs=t}*[Symbol.iterator](){for(const[t,e]of this._pairs)yield[t,e]}*entries(){for(const[t,e]of this._pairs)yield[t,e]}*keys(){for(const[t]of this._pairs)yield t}*values(){for(const[,t]of this._pairs)yield t}toIdArray(){return[...this._pairs].map(t=>t[0])}toItemArray(){return[...this._pairs].map(t=>t[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){const t=Object.create(null);for(const[e,s]of this._pairs)t[e]=s;return t}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new f([...this._pairs])}distinct(t){const e=new Set;for(const[s,r]of this._pairs)e.add(t(r,s));return e}filter(t){const e=this._pairs;return new f({*[Symbol.iterator](){for(const[s,r]of e)t(r,s)&&(yield[s,r])}})}forEach(t){for(const[e,s]of this._pairs)t(s,e)}map(t){const e=this._pairs;return new f({*[Symbol.iterator](){for(const[s,r]of e)yield[s,t(r,s)]}})}max(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o>i&&(i=o,r=n)}return r}min(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let r=s.value[1],i=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o<i&&(i=o,r=n)}return r}reduce(t,e){for(const[s,r]of this._pairs)e=t(e,r,s);return e}sort(t){return new f({[Symbol.iterator]:()=>[...this._pairs].sort(([e,s],[r,i])=>t(s,i,e,r))[Symbol.iterator]()})}}const c=()=>{console.warn("Type coercion has been deprecated. Please, use data pipes instead. See https://visjs.github.io/vis-data/data/datapipe.html#TypeCoercion for more details with working migration example.")};class _ extends d{constructor(t,e){if(super(),t&&!Array.isArray(t)&&(e=t,t=[]),this._options=e||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",this._type={},this._options.type){c();const t=Object.keys(this._options.type);for(let e=0,s=t.length;e<s;e++){const s=t[e],r=this._options.type[s];this._type[s]="Date"==r||"ISODate"==r||"ASPDate"==r?"Date":r}}t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=u.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&this._queue.setOptions(t.queue)))}add(t,e){const s=[];let r;if(Array.isArray(t)){if(t.map(t=>t[this._idProp]).some(t=>this._data.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=[],i=[],n=[],o=this._idProp,a=t=>{const e=t[o];if(null!=e&&this._data.has(e)){const s=t,o=Object.assign({},this._data.get(e)),a=this._updateItem(s);r.push(a),n.push(s),i.push(o)}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]?a(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");a(t)}if(s.length&&this._trigger("add",{items:s},e),r.length){const t={items:r,oldData:i,data:n};this._trigger("update",t,e)}return s.concat(r)}updateOnly(t,e){Array.isArray(t)||(t=[t]);const r=t.map(t=>{const e=this._data.get(t[this._idProp]);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[this._idProp],i=s.pureDeepObjectAssign(t,e);return this._data.set(r,i),{id:r,oldData:t,updatedData:i}});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,i=void 0;l(t)?(s=t,i=e):Array.isArray(t)?(r=t,i=e):i=t;const n=i&&"Object"===i.returnType?"Object":"Array",o=i&&i.type||this._options.type,a=i&&i.filter,h=[];let u=null,d=null,f=null;if(null!=s)u=this._getItem(s,o),u&&a&&!a(u)&&(u=null);else if(null!=r)for(let t=0,e=r.length;t<e;t++)u=this._getItem(r[t],o),null==u||a&&!a(u)||h.push(u);else{d=[...this._data.keys()];for(let t=0,e=d.length;t<e;t++)f=d[t],u=this._getItem(f,o),null==u||a&&!a(u)||h.push(u)}if(i&&i.order&&null==s&&this._sort(h,i.order),i&&i.fields){const t=i.fields;if(null!=s&&null!=u)u=this._filterFields(u,t);else for(let e=0,s=h.length;e<s;e++)h[e]=this._filterFields(h[e],t)}if("Object"==n){const t={};for(let e=0,s=h.length;e<s;e++){const s=h[e];t[s[this._idProp]]=s}return t}return null!=s?u:h}getIds(t){const e=this._data,s=t&&t.filter,r=t&&t.order,i=t&&t.type||this._options.type,n=[...e.keys()],o=[];let a,h;if(s)if(r){h=[];for(let t=0,e=n.length;t<e;t++){const e=n[t];a=this._getItem(e,i),s(a)&&h.push(a)}this._sort(h,r);for(let t=0,e=h.length;t<e;t++)o.push(h[t][this._idProp])}else for(let t=0,e=n.length;t<e;t++){const e=n[t];a=this._getItem(e,i),s(a)&&o.push(a[this._idProp])}else if(r){h=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];h.push(e.get(s))}this._sort(h,r);for(let t=0,e=h.length;t<e;t++)o.push(h[t][this._idProp])}else for(let t=0,s=n.length;t<s;t++){const s=n[t];a=e.get(s),o.push(a[this._idProp])}return o}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,r=e&&e.type||this._options.type,i=[...this._data.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[this._idProp])}}else for(let e=0,n=i.length;e<n;e++){const n=i[e],o=this._getItem(n,r);s&&!s(o)||t(o,n)}}map(t,e){const s=e&&e.filter,r=e&&e.type||this._options.type,i=[],n=[...this._data.keys()];for(let e=0,o=n.length;e<o;e++){const o=n[e],a=this._getItem(o,r);s&&!s(a)||i.push(t(a,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 s=[],r=[],i=Array.isArray(t)?t:[t];for(let t=0,e=i.length;t<e;t++){const e=this._remove(i[t]);if(e){const t=e[this._idProp];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(l(t)?e=t:t&&"object"==typeof t&&(e=t[this._idProp]),null!=e&&this._data.has(e)){const t=this._data.get(e)||null;return this._data.delete(e),--this.length,t}return null}clear(t){const e=[...this._data.keys()],s=[];for(let t=0,r=e.length;t<r;t++)s.push(this._data.get(e[t]));return this._data.clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const r of this._data.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 this._data.values()){const i=r[t];"number"==typeof i&&(null==s||i<s)&&(e=r,s=i)}return e||null}distinct(t){const e=this._data,s=[...e.keys()],r=[],i=this._options.type&&this._options.type[t]||null;let n=0;for(let i=0,o=s.length;i<o;i++){const o=s[i],a=e.get(o)[t];let h=!1;for(let t=0;t<n;t++)if(r[t]==a){h=!0;break}h||void 0===a||(r[n]=a,n++)}if(i)for(let t=0,e=r.length;t<e;t++)r[t]=h(r[t],i);return r}_addItem(t){let s=t[this._idProp];if(null!=s){if(this._data.has(s))throw new Error("Cannot add item: item with id "+s+" already exists")}else s=e.v4(),t[this._idProp]=s;const r={},i=Object.keys(t);for(let e=0,s=i.length;e<s;e++){const s=i[e],n=this._type[s];r[s]=h(t[s],n)}return this._data.set(s,r),++this.length,s}_getItem(t,e){const s=this._data.get(t);if(!s)return null;let r;const i=Object.keys(s);if(e){c(),r={};for(let t=0,n=i.length;t<n;t++){const n=i[t],o=s[n];r[n]=h(o,e[n])}}else r={...s};return null==r[this._idProp]&&(r[this._idProp]=s.id),r}_updateItem(t){const e=t[this._idProp];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=this._data.get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");const r=Object.keys(t);for(let e=0,i=r.length;e<i;e++){const i=r[e],n=this._type[i];s[i]=h(t[i],n)}return e}stream(t){if(t){const e=this._data;return new f({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new f({[Symbol.iterator]:this._data.entries.bind(this._data)})}}Object.defineProperty(t,"DELETE",{enumerable:!0,get:function(){return s.DELETE}}),t.DataSet=_,t.DataStream=f,t.DataView=class extends d{constructor(t,e){super(),this.length=0,this._ids=new Set,this._options=e||{},this._listener=this._onEvent.bind(this),this.setData(t)}setData(t){if(this._data){this._data.off&&this._data.off("*",this._listener);const t=this._data.getIds({filter:this._options.filter}),e=this._data.get(t);this._ids.clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){this._data=t;const e=this._data.getIds({filter:this._options.filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];this._ids.add(s)}this.length=e.length,this._trigger("add",{items:e})}else this._data=new _;this._data.on&&this._data.on("*",this._listener)}refresh(){const t=this._data.getIds({filter:this._options.filter}),e=[...this._ids],s={},r=[],i=[],n=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];s[i]=!0,this._ids.has(i)||(r.push(i),this._ids.add(i))}for(let t=0,r=e.length;t<r;t++){const r=e[t],o=this._data.get(r);null==o?console.error("If you see this, report it please."):s[r]||(i.push(r),n.push(o),this._ids.delete(r))}this.length+=r.length-i.length,r.length&&this._trigger("add",{items:r}),i.length&&this._trigger("remove",{items:i,oldData:n})}get(t,e){if(null==this._data)return null;let s,r=null;l(t)||Array.isArray(t)?(r=t,s=e):s=t;const i=Object.assign({},this._options,s),n=this._options.filter,o=s&&s.filter;return n&&o&&(i.filter=t=>n(t)&&o(t)),null==r?this._data.get(i):this._data.get(r,i)}getIds(t){if(this._data.length){const e=this._options.filter,s=null!=t?t.filter:null;let r;return r=s?e?t=>e(t)&&s(t):s:e,this._data.getIds({filter:r,order:t&&t.order})}return[]}forEach(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;i=r?s?function(t){return s(t)&&r(t)}:r:s,this._data.forEach(t,{filter:i,order:e&&e.order})}}map(t,e){if(this._data){const s=this._options.filter,r=e&&e.filter;let i;return i=r?s?t=>s(t)&&r(t):r:s,this._data.map(t,{filter:i,order:e&&e.order})}return[]}getDataSet(){return this._data.getDataSet()}stream(t){return this._data.stream(t||{[Symbol.iterator]:this._ids.keys.bind(this._ids)})}dispose(){var t;(null===(t=this._data)||void 0===t?void 0:t.off)&&this._data.off("*",this._listener);const e="This data view has already been disposed of.";Object.defineProperty(this,"_data",{get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1})}_onEvent(t,e,s){if(!e||!e.items||!this._data)return;const r=e.items,i=[],n=[],o=[],a=[],h=[],l=[];switch(t){case"add":for(let t=0,e=r.length;t<e;t++){const e=r[t];this.get(e)&&(this._ids.add(e),i.push(e))}break;case"update":for(let t=0,s=r.length;t<s;t++){const s=r[t];this.get(s)?this._ids.has(s)?(n.push(s),h.push(e.data[t]),a.push(e.oldData[t])):(this._ids.add(s),i.push(s)):this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}break;case"remove":for(let t=0,s=r.length;t<s;t++){const s=r[t];this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}}this.length+=i.length-o.length,i.length&&this._trigger("add",{items:i},s),n.length&&this._trigger("update",{items:n,oldData:a,data:h},s),o.length&&this._trigger("remove",{items:o,oldData:l},s)}},t.Queue=u,t.createNewDataPipeFrom=function(t){return new n(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!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){class i{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 r{constructor(t){this._source=t,this._transformers=[]}filter(t){return this._transformers.push(e=>e.filter(t)),this}map(t){return this._transformers.push(e=>e.map(t)),this}flatMap(t){return this._transformers.push(e=>e.flatMap(t)),this}to(t){return new i(this._source,this._transformers,t)}}function n(t){return"string"==typeof t||"number"==typeof t}class o{constructor(t){this._queue=[],this._timeout=null,this._extended=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 o(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 s._extended={object:t,methods:i},s}destroy(){if(this.flush(),this._extended){const t=this._extended.object,e=this._extended.methods;for(let s=0;s<e.length;s++){const i=e[s];i.original?t[i.name]=i.original:delete t[i.name]}this._extended=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?this._queue.push({fn:t}):this._queue.push(t),this._flushIfNeeded()}_flushIfNeeded(){this._queue.length>this.max&&this.flush(),null!=this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&"number"==typeof this.delay&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(t=>{t.fn.apply(t.context||t.fn,t.args||[])})}}class a{constructor(){this._subscribers={"*":[],add:[],remove:[],update:[]},this.subscribe=a.prototype.on,this.unsubscribe=a.prototype.off}_trigger(t,e,s){if("*"===t)throw new Error("Cannot trigger event *");[...this._subscribers[t],...this._subscribers["*"]].forEach(i=>{i(t,e,null!=s?s:null)})}on(t,e){"function"==typeof e&&this._subscribers[t].push(e)}off(t,e){this._subscribers[t]=this._subscribers[t].filter(t=>t!==e)}}class h{constructor(t){this._pairs=t}*[Symbol.iterator](){for(const[t,e]of this._pairs)yield[t,e]}*entries(){for(const[t,e]of this._pairs)yield[t,e]}*keys(){for(const[t]of this._pairs)yield t}*values(){for(const[,t]of this._pairs)yield t}toIdArray(){return[...this._pairs].map(t=>t[0])}toItemArray(){return[...this._pairs].map(t=>t[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){const t=Object.create(null);for(const[e,s]of this._pairs)t[e]=s;return t}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new h([...this._pairs])}distinct(t){const e=new Set;for(const[s,i]of this._pairs)e.add(t(i,s));return e}filter(t){const e=this._pairs;return new h({*[Symbol.iterator](){for(const[s,i]of e)t(i,s)&&(yield[s,i])}})}forEach(t){for(const[e,s]of this._pairs)t(s,e)}map(t){const e=this._pairs;return new h({*[Symbol.iterator](){for(const[s,i]of e)yield[s,t(i,s)]}})}max(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let i=s.value[1],r=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o>r&&(r=o,i=n)}return i}min(t){const e=this._pairs[Symbol.iterator]();let s=e.next();if(s.done)return null;let i=s.value[1],r=t(s.value[1],s.value[0]);for(;!(s=e.next()).done;){const[e,n]=s.value,o=t(n,e);o<r&&(r=o,i=n)}return i}reduce(t,e){for(const[s,i]of this._pairs)e=t(e,i,s);return e}sort(t){return new h({[Symbol.iterator]:()=>[...this._pairs].sort(([e,s],[i,r])=>t(s,r,e,i))[Symbol.iterator]()})}}class l extends a{constructor(t,e){super(),t&&!Array.isArray(t)&&(e=t,t=[]),this._options=e||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",t&&t.length&&this.add(t),this.setOptions(e)}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),delete this._queue):(this._queue||(this._queue=o.extend(this,{replace:["add","update","remove"]})),t.queue&&"object"==typeof t.queue&&this._queue.setOptions(t.queue)))}add(t,e){const s=[];let i;if(Array.isArray(t)){if(t.map(t=>t[this._idProp]).some(t=>this._data.has(t)))throw new Error("A duplicate id was found in the parameter array.");for(let e=0,r=t.length;e<r;e++)i=this._addItem(t[e]),s.push(i)}else{if(!t||"object"!=typeof t)throw new Error("Unknown dataType");i=this._addItem(t),s.push(i)}return s.length&&this._trigger("add",{items:s},e),s}update(t,e){const s=[],i=[],r=[],n=[],o=this._idProp,a=t=>{const e=t[o];if(null!=e&&this._data.has(e)){const s=t,o=Object.assign({},this._data.get(e)),a=this._updateItem(s);i.push(a),n.push(s),r.push(o)}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]?a(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");a(t)}if(s.length&&this._trigger("add",{items:s},e),i.length){const t={items:i,oldData:r,data:n};this._trigger("update",t,e)}return s.concat(i)}updateOnly(t,e){Array.isArray(t)||(t=[t]);const i=t.map(t=>{const e=this._data.get(t[this._idProp]);if(null==e)throw new Error("Updating non-existent items is not allowed.");return{oldData:e,update:t}}).map(({oldData:t,update:e})=>{const i=t[this._idProp],r=s.pureDeepObjectAssign(t,e);return this._data.set(i,r),{id:i,oldData:t,updatedData:r}});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,e),t.items}return[]}get(t,e){let s=void 0,i=void 0,r=void 0;n(t)?(s=t,r=e):Array.isArray(t)?(i=t,r=e):r=t;const o=r&&"Object"===r.returnType?"Object":"Array",a=r&&r.filter,h=[];let l=void 0,d=void 0,u=void 0;if(null!=s)l=this._data.get(s),l&&a&&!a(l)&&(l=void 0);else if(null!=i)for(let t=0,e=i.length;t<e;t++)l=this._data.get(i[t]),null==l||a&&!a(l)||h.push(l);else{d=[...this._data.keys()];for(let t=0,e=d.length;t<e;t++)u=d[t],l=this._data.get(u),null==l||a&&!a(l)||h.push(l)}if(r&&r.order&&null==s&&this._sort(h,r.order),r&&r.fields){const t=r.fields;if(null!=s&&null!=l)l=this._filterFields(l,t);else for(let e=0,s=h.length;e<s;e++)h[e]=this._filterFields(h[e],t)}if("Object"==o){const t={};for(let e=0,s=h.length;e<s;e++){const s=h[e];t[s[this._idProp]]=s}return t}return null!=s?null!=l?l:null:h}getIds(t){const e=this._data,s=t&&t.filter,i=t&&t.order,r=[...e.keys()],n=[];if(s)if(i){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],n=this._data.get(i);null!=n&&s(n)&&t.push(n)}this._sort(t,i);for(let e=0,s=t.length;e<s;e++)n.push(t[e][this._idProp])}else for(let t=0,e=r.length;t<e;t++){const e=r[t],i=this._data.get(e);null!=i&&s(i)&&n.push(i[this._idProp])}else if(i){const t=[];for(let s=0,i=r.length;s<i;s++){const i=r[s];t.push(e.get(i))}this._sort(t,i);for(let e=0,s=t.length;e<s;e++)n.push(t[e][this._idProp])}else for(let t=0,s=r.length;t<s;t++){const s=r[t],i=e.get(s);null!=i&&n.push(i[this._idProp])}return n}getDataSet(){return this}forEach(t,e){const s=e&&e.filter,i=[...this._data.keys()];if(e&&e.order){const s=this.get(e);for(let e=0,i=s.length;e<i;e++){const i=s[e];t(i,i[this._idProp])}}else for(let e=0,r=i.length;e<r;e++){const r=i[e],n=this._data.get(r);null==n||s&&!s(n)||t(n,r)}}map(t,e){const s=e&&e.filter,i=[],r=[...this._data.keys()];for(let e=0,n=r.length;e<n;e++){const n=r[e],o=this._data.get(n);null==o||s&&!s(o)||i.push(t(o,n))}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 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=[],i=[],r=Array.isArray(t)?t:[t];for(let t=0,e=r.length;t<e;t++){const e=this._remove(r[t]);if(e){const t=e[this._idProp];null!=t&&(s.push(t),i.push(e))}}return s.length&&this._trigger("remove",{items:s,oldData:i},e),s}_remove(t){let e;if(n(t)?e=t:t&&"object"==typeof t&&(e=t[this._idProp]),null!=e&&this._data.has(e)){const t=this._data.get(e)||null;return this._data.delete(e),--this.length,t}return null}clear(t){const e=[...this._data.keys()],s=[];for(let t=0,i=e.length;t<i;t++)s.push(this._data.get(e[t]));return this._data.clear(),this.length=0,this._trigger("remove",{items:e,oldData:s},t),e}max(t){let e=null,s=null;for(const i of this._data.values()){const r=i[t];"number"==typeof r&&(null==s||r>s)&&(e=i,s=r)}return e||null}min(t){let e=null,s=null;for(const i of this._data.values()){const r=i[t];"number"==typeof r&&(null==s||r<s)&&(e=i,s=r)}return e||null}distinct(t){const e=this._data,s=[...e.keys()],i=[];let r=0;for(let n=0,o=s.length;n<o;n++){const o=s[n],a=e.get(o)[t];let h=!1;for(let t=0;t<r;t++)if(i[t]==a){h=!0;break}h||void 0===a||(i[r]=a,r++)}return i}_addItem(t){const s=function(t,s){return null==t[s]&&(t[s]=e.v4()),t}(t,this._idProp),i=s[this._idProp];if(this._data.has(i))throw new Error("Cannot add item: item with id "+i+" already exists");return this._data.set(i,s),++this.length,i}_updateItem(t){const e=t[this._idProp];if(null==e)throw new Error("Cannot update item: item has no id (item: "+JSON.stringify(t)+")");const s=this._data.get(e);if(!s)throw new Error("Cannot update item: no item with id "+e+" found");return this._data.set(e,{...s,...t}),e}stream(t){if(t){const e=this._data;return new h({*[Symbol.iterator](){for(const s of t){const t=e.get(s);null!=t&&(yield[s,t])}}})}return new h({[Symbol.iterator]:this._data.entries.bind(this._data)})}}Object.defineProperty(t,"DELETE",{enumerable:!0,get:function(){return s.DELETE}}),t.DataSet=l,t.DataStream=h,t.DataView=class extends a{constructor(t,e){super(),this.length=0,this._ids=new Set,this._options=e||{},this._listener=this._onEvent.bind(this),this.setData(t)}setData(t){if(this._data){this._data.off&&this._data.off("*",this._listener);const t=this._data.getIds({filter:this._options.filter}),e=this._data.get(t);this._ids.clear(),this.length=0,this._trigger("remove",{items:t,oldData:e})}if(null!=t){this._data=t;const e=this._data.getIds({filter:this._options.filter});for(let t=0,s=e.length;t<s;t++){const s=e[t];this._ids.add(s)}this.length=e.length,this._trigger("add",{items:e})}else this._data=new l;this._data.on&&this._data.on("*",this._listener)}refresh(){const t=this._data.getIds({filter:this._options.filter}),e=[...this._ids],s={},i=[],r=[],n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e];s[r]=!0,this._ids.has(r)||(i.push(r),this._ids.add(r))}for(let t=0,i=e.length;t<i;t++){const i=e[t],o=this._data.get(i);null==o?console.error("If you see this, report it please."):s[i]||(r.push(i),n.push(o),this._ids.delete(i))}this.length+=i.length-r.length,i.length&&this._trigger("add",{items:i}),r.length&&this._trigger("remove",{items:r,oldData:n})}get(t,e){if(null==this._data)return null;let s,i=null;n(t)||Array.isArray(t)?(i=t,s=e):s=t;const r=Object.assign({},this._options,s),o=this._options.filter,a=s&&s.filter;return o&&a&&(r.filter=t=>o(t)&&a(t)),null==i?this._data.get(r):this._data.get(i,r)}getIds(t){if(this._data.length){const e=this._options.filter,s=null!=t?t.filter:null;let i;return i=s?e?t=>e(t)&&s(t):s:e,this._data.getIds({filter:i,order:t&&t.order})}return[]}forEach(t,e){if(this._data){const s=this._options.filter,i=e&&e.filter;let r;r=i?s?function(t){return s(t)&&i(t)}:i:s,this._data.forEach(t,{filter:r,order:e&&e.order})}}map(t,e){if(this._data){const s=this._options.filter,i=e&&e.filter;let r;return r=i?s?t=>s(t)&&i(t):i:s,this._data.map(t,{filter:r,order:e&&e.order})}return[]}getDataSet(){return this._data.getDataSet()}stream(t){return this._data.stream(t||{[Symbol.iterator]:this._ids.keys.bind(this._ids)})}dispose(){var t;(null===(t=this._data)||void 0===t?void 0:t.off)&&this._data.off("*",this._listener);const e="This data view has already been disposed of.";Object.defineProperty(this,"_data",{get:()=>{throw new Error(e)},set:()=>{throw new Error(e)},configurable:!1})}_onEvent(t,e,s){if(!e||!e.items||!this._data)return;const i=e.items,r=[],n=[],o=[],a=[],h=[],l=[];switch(t){case"add":for(let t=0,e=i.length;t<e;t++){const e=i[t];this.get(e)&&(this._ids.add(e),r.push(e))}break;case"update":for(let t=0,s=i.length;t<s;t++){const s=i[t];this.get(s)?this._ids.has(s)?(n.push(s),h.push(e.data[t]),a.push(e.oldData[t])):(this._ids.add(s),r.push(s)):this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}break;case"remove":for(let t=0,s=i.length;t<s;t++){const s=i[t];this._ids.has(s)&&(this._ids.delete(s),o.push(s),l.push(e.oldData[t]))}}this.length+=r.length-o.length,r.length&&this._trigger("add",{items:r},s),n.length&&this._trigger("update",{items:n,oldData:a,data:h},s),o.length&&this._trigger("remove",{items:o,oldData:l},s)}},t.Queue=o,t.createNewDataPipeFrom=function(t){return new r(t)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=vis-data.min.js.map |
{ | ||
"name": "vis-data", | ||
"version": "6.6.1", | ||
"version": "7.0.0", | ||
"description": "Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.", | ||
@@ -70,3 +70,2 @@ "homepage": "http://visjs.org/", | ||
"peerDependencies": { | ||
"moment": "^2.24.0", | ||
"vis-util": "^4.0.0", | ||
@@ -76,20 +75,20 @@ "uuid": "^7.0.0 || ^8.0.0" | ||
"devDependencies": { | ||
"@babel/core": "7.10.2", | ||
"@babel/plugin-proposal-class-properties": "7.10.1", | ||
"@babel/plugin-transform-runtime": "7.10.1", | ||
"@babel/preset-env": "7.10.2", | ||
"@babel/preset-typescript": "7.10.1", | ||
"@babel/register": "7.10.1", | ||
"@babel/runtime": "7.10.2", | ||
"@babel/runtime-corejs3": "7.10.2", | ||
"@rollup/plugin-commonjs": "13.0.0", | ||
"@babel/core": "7.11.0", | ||
"@babel/plugin-proposal-class-properties": "7.10.4", | ||
"@babel/plugin-transform-runtime": "7.11.0", | ||
"@babel/preset-env": "7.11.0", | ||
"@babel/preset-typescript": "7.10.4", | ||
"@babel/register": "7.10.5", | ||
"@babel/runtime": "7.11.0", | ||
"@babel/runtime-corejs3": "7.11.0", | ||
"@rollup/plugin-commonjs": "14.0.0", | ||
"@rollup/plugin-json": "4.1.0", | ||
"@rollup/plugin-node-resolve": "8.0.1", | ||
"@rollup/plugin-strip": "1.3.3", | ||
"@types/chai": "4.2.11", | ||
"@types/mocha": "7.0.2", | ||
"@rollup/plugin-node-resolve": "8.4.0", | ||
"@rollup/plugin-strip": "2.0.0", | ||
"@types/chai": "4.2.12", | ||
"@types/mocha": "8.0.1", | ||
"@types/sinon": "9.0.4", | ||
"@types/uuid": "8.0.0", | ||
"@typescript-eslint/eslint-plugin": "2.34.0", | ||
"@typescript-eslint/parser": "2.34.0", | ||
"@typescript-eslint/eslint-plugin": "3.7.1", | ||
"@typescript-eslint/parser": "3.7.1", | ||
"babel-plugin-css-modules-transform": "1.6.2", | ||
@@ -99,3 +98,3 @@ "babel-plugin-istanbul": "6.0.0", | ||
"core-js": "3.6.5", | ||
"eslint": "7.2.0", | ||
"eslint": "7.6.0", | ||
"eslint-config-prettier": "6.11.0", | ||
@@ -105,5 +104,4 @@ "eslint-plugin-prettier": "3.1.4", | ||
"husky": "4.2.5", | ||
"lint-staged": "10.2.10", | ||
"mocha": "8.0.1", | ||
"moment": "2.26.0", | ||
"lint-staged": "10.2.11", | ||
"mocha": "8.1.0", | ||
"nyc": "15.1.0", | ||
@@ -114,4 +112,4 @@ "opencollective": "1.0.3", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.16.1", | ||
"rollup-plugin-analyzer": "3.2.3", | ||
"rollup": "2.23.0", | ||
"rollup-plugin-analyzer": "3.3.0", | ||
"rollup-plugin-babel": "4.4.0", | ||
@@ -122,3 +120,3 @@ "rollup-plugin-banner": "0.2.1", | ||
"rollup-plugin-node-resolve": "5.2.0", | ||
"rollup-plugin-postcss": "3.1.2", | ||
"rollup-plugin-postcss": "3.1.3", | ||
"rollup-plugin-terser": "6.1.0", | ||
@@ -128,7 +126,7 @@ "rollup-plugin-typescript2": "0.27.1", | ||
"snap-shot-it": "7.9.3", | ||
"typedoc": "0.17.7", | ||
"typescript": "3.9.5", | ||
"uuid": "8.1.0", | ||
"vis-dev-utils": "2.3.2", | ||
"vis-util": "4.3.1" | ||
"typedoc": "0.17.8", | ||
"typescript": "3.9.7", | ||
"uuid": "8.3.0", | ||
"vis-dev-utils": "2.3.7", | ||
"vis-util": "4.3.4" | ||
}, | ||
@@ -135,0 +133,0 @@ "collective": { |
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
2
51
7544738
84
44722