vis-data 7.1.0 → 7.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/data-interface.d.ts +1 -28
- package/declarations/data-interface.d.ts.map +1 -1
- package/declarations/data-pipe.d.ts +5 -9
- package/declarations/data-pipe.d.ts.map +1 -1
- package/declarations/data-set-check.d.ts +0 -1
- package/declarations/data-set-check.d.ts.map +1 -1
- package/declarations/data-set-part.d.ts +1 -1
- package/declarations/data-set-part.d.ts.map +1 -1
- package/declarations/data-set.d.ts +4 -17
- package/declarations/data-set.d.ts.map +1 -1
- package/declarations/data-stream.d.ts +1 -17
- package/declarations/data-stream.d.ts.map +1 -1
- package/declarations/data-view-check.d.ts +0 -1
- package/declarations/data-view-check.d.ts.map +1 -1
- package/declarations/data-view.d.ts +4 -2
- package/declarations/data-view.d.ts.map +1 -1
- package/declarations/queue.d.ts +3 -2
- package/declarations/queue.d.ts.map +1 -1
- package/dist/esm.js +7435 -3483
- package/dist/esm.js.map +1 -1
- package/dist/umd.js +11969 -8016
- package/dist/umd.js.map +1 -1
- package/esnext/esm/vis-data.js +162 -266
- package/esnext/esm/vis-data.js.map +1 -1
- package/esnext/esm/vis-data.min.js +3 -17
- package/esnext/esm/vis-data.min.js.map +1 -1
- package/esnext/umd/vis-data.js +2009 -2115
- package/esnext/umd/vis-data.js.map +1 -1
- package/esnext/umd/vis-data.min.js +3 -18
- package/esnext/umd/vis-data.min.js.map +1 -1
- package/package.json +75 -27
- package/peer/esm/vis-data.js +7428 -3475
- package/peer/esm/vis-data.js.map +1 -1
- package/peer/esm/vis-data.min.js +8 -41
- package/peer/esm/vis-data.min.js.map +1 -1
- package/peer/umd/vis-data.js +11928 -7975
- package/peer/umd/vis-data.js.map +1 -1
- package/peer/umd/vis-data.min.js +9 -42
- package/peer/umd/vis-data.min.js.map +1 -1
- package/standalone/esm/vis-data.js +7428 -3475
- package/standalone/esm/vis-data.js.map +1 -1
- package/standalone/esm/vis-data.min.js +8 -41
- package/standalone/esm/vis-data.min.js.map +1 -1
- package/standalone/umd/vis-data.js +11928 -7975
- package/standalone/umd/vis-data.js.map +1 -1
- package/standalone/umd/vis-data.min.js +9 -42
- package/standalone/umd/vis-data.min.js.map +1 -1
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
|
|
6
6
|
*
|
|
7
|
-
* @version 7.1.
|
|
8
|
-
* @date
|
|
7
|
+
* @version 7.1.3
|
|
8
|
+
* @date 2022-03-02T13:02:54.265Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -23,20 +23,5 @@
|
|
|
23
23
|
*
|
|
24
24
|
* vis.js may be distributed under either license.
|
|
25
25
|
*/
|
|
26
|
-
!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){
|
|
27
|
-
/*! *****************************************************************************
|
|
28
|
-
Copyright (c) Microsoft Corporation.
|
|
29
|
-
|
|
30
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
-
purpose with or without fee is hereby granted.
|
|
32
|
-
|
|
33
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
-
***************************************************************************** */
|
|
41
|
-
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})}));
|
|
26
|
+
!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){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 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 i=[{name:"flush",original:void 0}];if(e&&e.replace)for(let r=0;r<e.replace.length;r++){const o=e.replace[r];i.push({name:o,original:t[o]}),s.replace(t,o)}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,o]=s.value,n=t(o,e);n>r&&(r=n,i=o)}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,o]=s.value,n=t(o,e);n<r&&(r=n,i=o)}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(),this._queue=null,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)}get idProp(){return this._idProp}setOptions(t){t&&void 0!==t.queue&&(!1===t.queue?this._queue&&(this._queue.destroy(),this._queue=null):(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 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=[],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);i.push(a),o.push(s),r.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),i.length){const t={items:i,oldData:r,data:o};this._trigger("update",t,e)}return s.concat(i)}updateOnly(t,s){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:s})=>{const i=t[this._idProp],r=e.pureDeepObjectAssign(t,s);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,s),t.items}return[]}get(t,e){let s=void 0,i=void 0,r=void 0;o(t)?(s=t,r=e):Array.isArray(t)?(i=t,r=e):r=t;const n=r&&"Object"===r.returnType?"Object":"Array",a=r&&r.filter,h=[];let l=void 0,u=void 0,d=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{u=[...this._data.keys()];for(let t=0,e=u.length;t<e;t++)d=u[t],l=this._data.get(d),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"==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??null:h}getIds(t){const e=this._data,s=t&&t.filter,i=t&&t.order,r=[...e.keys()],o=[];if(s)if(i){const t=[];for(let e=0,i=r.length;e<i;e++){const i=r[e],o=this._data.get(i);null!=o&&s(o)&&t.push(o)}this._sort(t,i);for(let e=0,s=t.length;e<s;e++)o.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)&&o.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++)o.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&&o.push(i[this._idProp])}return o}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],o=this._data.get(r);null==o||s&&!s(o)||t(o,r)}}map(t,e){const s=e&&e.filter,i=[],r=[...this._data.keys()];for(let e=0,o=r.length;e<o;e++){const o=r[e],n=this._data.get(o);null==n||s&&!s(n)||i.push(t(n,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 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(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,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 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<r;t++)if(i[t]==a){h=!0;break}h||void 0===a||(i[r]=a,r++)}return i}_addItem(t){const e=function(t,e){return null==t[e]&&(t[e]=s.v4()),t}(t,this._idProp),i=e[this._idProp];if(this._data.has(i))throw new Error("Cannot add item: item with id "+i+" already exists");return this._data.set(i,e),++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)})}}class u 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)}get idProp(){return this.getDataSet().idProp}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=[],o=[];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],n=this._data.get(i);null==n?console.error("If you see this, report it please."):s[i]||(r.push(i),o.push(n),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:o})}get(t,e){if(null==this._data)return null;let s,i=null;o(t)||Array.isArray(t)?(i=t,s=e):s=t;const r=Object.assign({},this._options,s),n=this._options.filter,a=s&&s.filter;return n&&a&&(r.filter=t=>n(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(){this._data?.off&&this._data.off("*",this._listener);const t="This data view has already been disposed of.",e={get:()=>{throw new Error(t)},set:()=>{throw new Error(t)},configurable:!1};for(const t of Reflect.ownKeys(u.prototype))Object.defineProperty(this,t,e)}_onEvent(t,e,s){if(!e||!e.items||!this._data)return;const i=e.items,r=[],o=[],n=[],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)?(o.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),n.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),n.push(s),l.push(e.oldData[t]))}}this.length+=r.length-n.length,r.length&&this._trigger("add",{items:r},s),o.length&&this._trigger("update",{items:o,oldData:a,data:h},s),n.length&&this._trigger("remove",{items:n,oldData:l},s)}}function d(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}Object.defineProperty(t,"DELETE",{enumerable:!0,get:function(){return e.DELETE}}),t.DataSet=l,t.DataStream=h,t.DataView=u,t.Queue=n,t.createNewDataPipeFrom=function(t){return new r(t)},t.isDataSetLike=d,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&&d(t,e.getDataSet())},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
42
27
|
//# sourceMappingURL=vis-data.min.js.map
|