@vuu-ui/vuu-data-remote 0.8.32 → 0.8.33
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/cjs/index.js +31 -1
- package/package.json +9 -11
- package/types/inlined-worker.d.ts +1 -1
- package/types/vuu-data-source.d.ts +2 -1
- package/LICENSE +0 -201
- package/README.md +0 -19
- package/cjs/index.js.map +0 -7
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -7
package/cjs/index.js
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(t,r)=>{for(var e in r)D(t,e,{get:r[e],enumerable:!0})},se=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Y(r))!ee.call(t,n)&&n!==e&&D(t,n,{get:()=>r[n],enumerable:!(s=Q(r,n))||s.enumerable});return t};var ie=t=>se(D({},"__esModule",{value:!0}),t);var z=(t,r,e)=>{if(!r.has(t))throw TypeError("Cannot "+e)};var i=(t,r,e)=>(z(t,r,"read from private field"),e?e.call(t):r.get(t)),g=(t,r,e)=>{if(r.has(t))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(t):r.set(t,e)},l=(t,r,e,s)=>(z(t,r,"write to private field"),s?s.call(t,e):r.set(t,e),e);var Ve={};te(Ve,{ConnectionManager:()=>L,VuuDataSource:()=>B,authenticate:()=>ne,connectToServer:()=>fe,connectionId:()=>Re,createSchemaFromTableMetadata:()=>ye,getFirstAndLastRows:()=>me,getServerAPI:()=>$,groupRowsByViewport:()=>_e,isDataSourceConfigMessage:()=>W,isSessionTable:()=>G,isSessionTableActionMessage:()=>ue,isSizeOnly:()=>oe,isVuuMenuRpcRequest:()=>Ce,isVuuRpcRequest:()=>Te,makeRpcCall:()=>we,msgType:()=>be,shouldMessageBeRoutedToDataSource:()=>A,stripRequestId:()=>Se,toDataSourceConfig:()=>ae});module.exports=ie(Ve);var re="api/authn",ne=async(t,r,e=re)=>fetch(e,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","access-control-allow-origin":location.host},body:JSON.stringify({username:t,password:r})}).then(s=>{if(s.ok){let n=s.headers.get("vuu-auth-token");if(typeof n=="string"&&n.length>0)return n;throw Error("Authentication failed auth token not returned by server")}else throw Error(`Authentication failed ${s.status} ${s.statusText}`)});var p=require("@vuu-ui/vuu-utils");var oe=t=>t.type==="viewport-update"&&t.mode==="size-only",ae=t=>{switch(t.type){case"aggregate":return{aggregations:t.aggregations};case"columns":return{columns:t.columns};case"filter":return{filter:t.filter};case"groupBy":return{groupBy:t.groupBy};case"sort":return{sort:t.sort};case"config":return t.config}},le=["config","aggregate","viewport-update","columns","debounce-begin","disabled","enabled","filter","groupBy","vuu-link-created","vuu-link-removed","vuu-links","vuu-menu","sort","subscribed"],A=t=>{let r=t.type;return le.includes(r)},W=t=>["config","aggregate","columns","filter","groupBy","sort"].includes(t.type),ue=t=>t.type==="VIEW_PORT_MENU_RESP"&&t.action!==null&&G(t.action.table),G=t=>t!==null&&typeof t=="object"&&"table"in t&&"module"in t?t.table.startsWith("session"):!1;var F="GET_TABLE_META";var J='\nvar ie=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var m=(r,e,t)=>(ie(r,e,"read from private field"),t?t.call(r):e.get(r)),ae=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,n)=>(ie(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);function le(r,e,t=[],n=[]){for(let s=0,o=r.length;s<o;s++)(e(r[s],s)?t:n).push(r[s]);return[t,n]}var Je=6,B={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:Je,SELECTED:7,count:8,PARENT_IDX:"parent_idx",IDX_POINTER:"idx_pointer",FILTER_COUNT:"filter_count",NEXT_FILTER_IDX:"next_filter_idx"};var{DEPTH:It,IS_LEAF:Pt}=B;var ce=r=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split("; ").find(n=>n.startsWith(`${r}=`)))==null?void 0:t.split("=")[1]};function G({from:r,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(r===0&&e===0)return{from:r,to:e};if(t===0)return n<r?{from:0,to:0}:{from:r,to:Math.min(e,n)};if(r===0)return{from:r,to:Math.min(e+t,n)};{let s=r-t<0,o=n-(e+t)<0;return s&&o?{from:0,to:n}:s?{from:0,to:e+t}:o?{from:Math.max(0,r-t),to:n}:{from:r-t,to:e+t}}}var je=(r,{from:e,to:t})=>r>=e&&r<t;var I=class r{constructor(e,t){this.from=e,this.to=t}isWithin(e){return je(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new r(this.from,this.to)}};var pe=r=>r.type==="connection-status",de=r=>r.type==="connection-metrics";var ge=r=>"viewport"in r;var Ye=["error","warn","info","debug"],Qe=r=>typeof r=="string"&&Ye.includes(r),Xe="error",P=()=>{},Ze="error",{loggingLevel:L=Ze}=et(),b=r=>{let e=L==="debug",t=e||L==="info",n=t||L==="warn",s=n||L==="error",o=t?p=>console.info(`[${r}] ${p}`):P,i=n?p=>console.warn(`[${r}] ${p}`):P,u=e?p=>console.debug(`[${r}] ${p}`):P;return{errorEnabled:s,error:s?p=>console.error(`[${r}] ${p}`):P}};function et(){return typeof loggingSettings<"u"?loggingSettings:{loggingLevel:tt()}}function tt(){let r=ce("vuu-logging-level");return Qe(r)?r:Xe}var{debug:nt,debugEnabled:st}=b("range-monitor"),x=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)st&&nt(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};var rt=[],k=class{constructor(e){this.keys=new Map;this.nextKeyValue=0;this.range=e,this.init(e)}next(e=rt){return e.length>0?e.shift():this.nextKeyValue++}init({from:e,to:t}){this.keys.clear(),this.nextKeyValue=0;for(let n=e;n<t;n++){let s=this.next();this.keys.set(n,s)}return!0}reset(e){let{from:t,to:n}=e,s=n-t,o=this.range.to-this.range.from;if(this.range=e,o>s)return this.init(e);let i=[];this.keys.forEach((u,l)=>{(l<t||l>=n)&&(i.push(u),this.keys.delete(l))});for(let u=t;u<n;u++)if(!this.keys.has(u)){let l=this.next(i);this.keys.set(u,l)}return!1}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return`${this.keys.size} keys\n${Array.from(this.keys.entries()).sort(([e],[t])=>e-t).map(([e,t])=>`${e}=>${t}`).join(",")}]\n`}};var{SELECTED:$t}=B,E={False:0,True:1,First:2,Last:4};var ot=(r,e)=>e>=r[0]&&e<=r[1],it=E.True+E.First+E.Last,at=E.True+E.First,ut=E.True+E.Last,H=(r,e)=>{for(let t of r)if(typeof t=="number"){if(t===e)return it}else if(ot(t,e))return e===t[0]?at:e===t[1]?ut:E.True;return E.False};var he=r=>{if(r.every(t=>typeof t=="number"))return r;let e=[];for(let t of r)if(typeof t=="number")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var fe=r=>r.type==="VIEW_PORT_MENU_RESP"&&r.action!==null&&O(r.action.table),O=r=>r!==null&&typeof r=="object"&&"table"in r&&"module"in r?r.table.startsWith("session"):!1;var lt=["VIEW_PORT_MENUS_SELECT_RPC","VIEW_PORT_MENU_TABLE_RPC","VIEW_PORT_MENU_ROW_RPC","VIEW_PORT_MENU_CELL_RPC","VP_EDIT_CELL_RPC","VP_EDIT_ROW_RPC","VP_EDIT_ADD_ROW_RPC","VP_EDIT_DELETE_CELL_RPC","VP_EDIT_DELETE_ROW_RPC","VP_EDIT_SUBMIT_FORM_RPC"],me=r=>lt.includes(r.type),Ce=r=>r.type==="VIEW_PORT_RPC_CALL",A=({requestId:r,...e})=>[r,e],Re=r=>{let e=r.at(0);if(e.updateType==="SIZE"){if(r.length===1)return r;e=r.at(1)}let t=r.at(-1);return[e,t]},Se=r=>{let e={};for(let t of r)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e},z=({columns:r,dataTypes:e,key:t,table:n})=>({table:n,columns:r.map((s,o)=>({name:s,serverDataType:e[o]})),key:t});var Te="CHANGE_VP_SUCCESS";var be="CLOSE_TREE_NODE",we="CLOSE_TREE_SUCCESS";var Ee="CREATE_VP",Ve="DISABLE_VP",ve="DISABLE_VP_SUCCESS";var Me="ENABLE_VP",ye="ENABLE_VP_SUCCESS";var K="GET_VP_VISUAL_LINKS",_e="GET_VIEW_PORT_MENUS";var De="HB",Ie="HB_RESP",Pe="LOGIN",Le="OPEN_TREE_NODE",xe="OPEN_TREE_SUCCESS";var ke="REMOVE_VP";var Oe="SET_SELECTION_SUCCESS";var We=r=>{switch(r){case"TypeAheadRpcHandler":return"TYPEAHEAD";default:return"SIMUL"}};var Ne=[],C=b("array-backed-moving-window");function ct(r,e){if(!e||e.data.length!==r.data.length||e.sel!==r.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==r.data[t])return!1;return!0}var h,W=class{constructor({from:e,to:t},{from:n,to:s},o){ae(this,h,void 0);this.setRowCount=e=>{var t;if((t=C.info)==null||t.call(C,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let s=this.clientRange.from;s<n;s++){let o=s-m(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return m(this,h).to-t<n?!0:m(this,h).from>0&&e-m(this,h).from<n};this.bufferSize=o,this.clientRange=new I(e,t),ue(this,h,new I(n,s)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return m(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:s}=this.range;if(t<n||e>=s)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-m(this,h).from;if(ct(e,this.internalData[n]))return!1;let s=this.isWithinClientRange(t);return(s||this.isWithinRange(t))&&(!this.internalData[n]&&s&&(this.rowsWithinRange+=1),this.internalData[n]=e),s}getAtIndex(e){return m(this,h).isWithin(e)&&this.internalData[e-m(this,h).from]!=null?this.internalData[e-m(this,h).from]:void 0}isWithinRange(e){return m(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var p;(p=C.debug)==null||p.call(C,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,s=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===s)return[!1,Ne];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let a=e;a<t;a++){let c=a-m(this,h).from;this.internalData[c]&&(this.rowsWithinRange+=1)}let i=Ne,u=m(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let a=Math.max(e,o.to);i=this.internalData.slice(a-u,t-u)}else{let a=Math.min(o.from,t);i=this.internalData.slice(e-u,a-u)}return[this.bufferBreakout(e,t),i]}setRange(e,t){var n,s;if(e!==m(this,h).from||t!==m(this,h).to){(n=C.debug)==null||n.call(C,`setRange ${e} - ${t}`);let[o,i]=m(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let l=o;l<i;l++){let p=this.getAtIndex(l);if(p){let a=l-e;u[a]=p,this.isWithinClientRange(l)&&(this.rowsWithinRange+=1)}}this.internalData=u,m(this,h).from=e,m(this,h).to=t}else(s=C.debug)==null||s.call(C,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=m(this,h),{from:n,to:s}=this.clientRange,o=Math.max(0,n-e),i=Math.min(t-e,t,s-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,i)}clear(){var e;(e=C.debug)==null||e.call(C,"clear"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,s=this.internalData[t-1];if(n&&s)return[n.rowIndex,s.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){s=e[o];break}return n&&s?[n.rowIndex,s.rowIndex]:[-1,-1]}};h=new WeakMap;var{debug:f,debugEnabled:N,error:pt,info:d,infoEnabled:dt,warn:M}=b("viewport"),gt=({rowKey:r,updateType:e})=>e==="U"&&!r.startsWith("$root"),U=[void 0,void 0],ht={count:0,mode:void 0,size:0,ts:0},q=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:s,groupBy:o=[],table:i,range:u,sort:l,title:p,viewport:a,visualLink:c},g){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.useBatchMode=!0;this.lastUpdateStatus=ht;this.updateThrottleTimer=void 0;this.rangeMonitor=new x("ViewPort");this.disabled=!1;this.isTree=!1;this.status="";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,s=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,s=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,s=0;return this.lastUpdateStatus.mode=e,s};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:s}=e;for(let{from:o,to:i}of this.pendingRangeRequests)if(s>=o&&s<i){if(e.to+n<=i)return!0;s=i}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:"size-only",size:this.lastUpdateStatus.size,type:"viewport-update"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return e==="size-only"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(d==null||d("throttling updates setTimeout to 2000"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=a,this.columns=n,this.filter=s,this.groupBy=o,this.keys=new k(u),this.pendingLinkedParent=c,this.table=i,this.sort=l,this.title=p,dt&&(d==null||d(`constructor #${a} ${i.table} bufferSize=${t}`)),this.dataWindow=new W(this.clientRange,u,this.bufferSize),this.postMessageToClient=g}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status==="subscribed"?"resubscribing":"subscribing",{type:Ee,table:this.table,range:G(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:s,range:o,sort:i,groupBy:u,table:l},p){this.serverViewportId=e,this.status="subscribed",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to);let a=l===p.table.table?p:{...p,table:{...p.table,session:l}};return{aggregations:t,type:"subscribed",clientViewportId:this.clientViewportId,columns:n,filter:s,groupBy:u,range:o,sort:i,tableSchema:a}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:s}=this,o=s.get(e);if(!o){pt(`no matching operation found to complete for requestId ${e}`);return}let{type:i}=o;if(d==null||d(`completeOperation ${i}`),s.delete(e),i==="CHANGE_VP_RANGE"){let[l,p]=t;(u=this.dataWindow)==null||u.setRange(l,p);for(let a=this.pendingRangeRequests.length-1;a>=0;a--){let c=this.pendingRangeRequests[a];if(c.requestId===e){c.acked=!0;break}else M==null||M("range requests sent faster than they are being ACKed")}}else if(i==="config"){let{aggregations:l,columns:p,filter:a,groupBy:c,sort:g}=o.data;return this.aggregations=l,this.columns=p,this.filter=a,this.groupBy=c,this.sort=g,c.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),f==null||f(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,config:o.data}}else{if(i==="groupBy")return this.isTree=o.data.length>0,this.groupBy=o.data,f==null||f(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,groupBy:o.data};if(i==="columns")return this.columns=o.data,{clientViewportId:n,type:i,columns:o.data};if(i==="filter")return this.filter=o.data,{clientViewportId:n,type:i,filter:o.data};if(i==="aggregate")return this.aggregations=o.data,{clientViewportId:n,type:"aggregate",aggregations:this.aggregations};if(i==="sort")return this.sort=o.data,{clientViewportId:n,type:i,sort:this.sort};if(i!=="selection"){if(i==="disable")return this.disabled=!0,{type:"disabled",clientViewportId:n};if(i==="enable")return this.disabled=!1,{type:"enabled",clientViewportId:n};if(i==="CREATE_VISUAL_LINK"){let[l,p,a]=t;return this.linkedParent={colName:l,parentViewportId:p,parentColName:a},this.pendingLinkedParent=void 0,{type:"vuu-link-created",clientViewportId:n,colName:l,parentViewportId:p,parentColName:a}}else if(i==="REMOVE_VISUAL_LINK")return this.linkedParent=void 0,{type:"vuu-link-removed",clientViewportId:n}}}}rangeRequest(e,t){N&&this.rangeMonitor.set(t);let n="CHANGE_VP_RANGE";if(this.dataWindow){let[s,o]=this.dataWindow.setClientRange(t.from,t.to),i,u=this.dataWindow.rowCount||void 0,l=s&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...G(t,this.bufferSize,u)}:null;if(l){N&&(f==null||f(`create CHANGE_VP_RANGE: [${l.from} - ${l.to}]`)),this.awaitOperation(e,{type:n});let a=this.pendingRangeRequests.at(-1);if(a)if(a.acked)console.warn("Range Request before previous request is filled");else{let{from:c,to:g}=a;this.dataWindow.outOfRange(c,g)?i={clientViewportId:this.clientViewportId,type:"debounce-begin"}:M==null||M("Range Request before previous request is acked")}this.pendingRangeRequests.push({...l,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let p=this.isTree?j:J;return o.length?[l,o.map(a=>p(a,this.keys,this.selectedRows))]:i?[l,void 0,i]:[l]}else return[null]}setLinks(e){return this.links=e,[{type:"vuu-links",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:"vuu-menu",menu:e,clientViewportId:this.clientViewportId}}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Le,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:be,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,s){let o={type:"CREATE_VISUAL_LINK",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:s,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:"REMOVE_VISUAL_LINK",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,d==null||d("suspend")}resume(){return this.suspended=!1,N&&(f==null||f(`resume: ${this.currentData()}`)),[this.size,this.currentData()]}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,s=this.isTree?j:J;for(let o of t)o&&e.push(s(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:"enable"}),d==null||d(`enable: ${this.serverViewportId}`),{type:Me,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:"disable"}),d==null||d(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Ve,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:"columns",data:t}),f==null||f(`columnRequest: ${t}`),this.createRequest({columns:t})}setConfig(e,t){var o;this.awaitOperation(e,{type:"config",data:t});let{filter:n,...s}=t;return this.useBatchMode&&(this.batchMode=!0),N?f==null||f(`setConfig ${JSON.stringify(t)}`):d==null||d("setConfig"),!this.isTree&&t.groupBy.length>0&&((o=this.dataWindow)==null||o.clear()),this.createRequest({...s,filterSpec:typeof(n==null?void 0:n.filter)=="string"?{filter:n.filter}:{filter:""}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:"aggregate",data:t}),d==null||d(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:"sort",data:t}),d==null||d(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:"selection",data:t}),d==null||d(`selectRequest: ${t}`),{type:"SET_SELECTION",vpId:this.serverViewportId,selection:he(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:s,to:o}=this.pendingRangeRequests[n],i=!0;if(e>=s&&e<o||t>s&&t<o){i||console.warn("removePendingRangeRequest TABLE_ROWS are not for latest request"),this.pendingRangeRequests.splice(n,1);break}else i=!1}}updateRows(e){var s,o,i;let[t,n]=Re(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){f==null||f(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType==="SIZE"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&>(u)||((u.updateType==="SIZE"||((s=this.dataWindow)==null?void 0:s.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType==="U"&&(i=this.dataWindow)!=null&&i.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t="size-only";if(!this.hasUpdates&&!this.rowCountChanged)return U;if(this.hasUpdates){let{keys:n,selectedRows:s}=this,o=this.isTree?j:J;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t="update";for(let i of this.pendingUpdates)e.push(o(i,n,s));this.pendingUpdates.length=0}else{let i=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t="batch";for(let u of i)e.push(o(u,n,s));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?U:[e,t]}createRequest(e,t=!1){return t?{type:"CHANGE_VP",viewPortId:this.serverViewportId,...e}:{type:"CHANGE_VP",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},J=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>[r,s.keyFor(r),!0,!1,0,0,e,t?H(o,r):0].concat(n),j=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>{let[i,u,,l,,p,...a]=n;return[r,s.keyFor(r),l,u,i,p,e,t?H(o,r):0].concat(a)};var Ue=1;var{debug:V,debugEnabled:Y,error:y,info:T,infoEnabled:ft,warn:Q}=b("server-proxy"),R=()=>`${Ue++}`,mt={},Ct=r=>r.disabled!==!0&&r.suspended!==!0,Rt={type:"NO_ACTION"},St=(r,e,t)=>r.map(n=>n.parentVpId===e?{...n,label:t}:n);function Tt(r,e){return r.map(t=>{let{parentVpId:n}=t,s=e.get(n);if(s)return{...t,parentClientVpId:s.clientViewportId,label:s.title};throw Error("addLabelsToLinks viewport not found")})}var F=class{constructor(e,t){this.authToken="";this.user="user";this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableMetaRequests=new Map;this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=le(Array.from(this.viewports.values()),Ct);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=s=>{s.forEach(o=>{let{clientViewportId:i}=o;this.viewports.set(i,o),this.sendMessageToServer(o.subscribe(),i)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t="user"){if(e)return this.authToken=e,this.user=t,new Promise((n,s)=>{this.sendMessageToServer({type:Pe,token:this.authToken,user:t},""),this.pendingLogin={resolve:n,reject:s}});this.authToken===""&&y("login, cannot login until auth token has been obtained")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))y(`spurious subscribe call ${e.viewport}`);else{let t=this.getTableMeta(e.table),n=new q(e,this.postMessageToClient);this.viewports.set(e.viewport,n);let s=this.awaitResponseToMessage(n.subscribe(),e.viewport);Promise.all([s,t]).then(([i,u])=>{let{viewPortId:l}=i,{status:p}=n;e.viewport!==l&&(this.viewports.delete(e.viewport),this.viewports.set(l,n)),this.mapClientToServerViewport.set(e.viewport,l);let a=n.handleSubscribed(i,u);a&&(this.postMessageToClient(a),Y&&V(`post DataSourceSubscribedMessage to client: ${JSON.stringify(a)}`)),n.disabled&&this.disableViewport(n),this.queuedRequests.length>0&&this.processQueuedRequests(),p==="subscribing"&&!O(n.table)&&(this.sendMessageToServer({type:K,vpId:l}),this.sendMessageToServer({type:_e,vpId:l}),Array.from(this.viewports.entries()).filter(([c,{disabled:g}])=>c!==l&&!g).forEach(([c])=>{this.sendMessageToServer({type:K,vpId:c})}))})}}processQueuedRequests(){let e={};for(;this.queuedRequests.length;){let t=this.queuedRequests.pop();if(t){let{clientViewportId:n,message:s,requestId:o}=t;if(s.type==="CHANGE_VP_RANGE"){if(e.CHANGE_VP_RANGE)continue;e.CHANGE_VP_RANGE=!0;let i=this.mapClientToServerViewport.get(n);i&&this.sendMessageToServer({...s,viewPortId:i},o)}}}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(T==null||T(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:ke,viewPortId:t})):y(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let s=this.viewports.get(n);if(s)return s;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=R(),[s,o,i]=e.rangeRequest(n,t.range);T==null||T(`setViewRange ${t.range.from} - ${t.range.to}`),s&&(this.sendIfReady(s,n,e.status==="subscribed")||this.queuedRequests.push({clientViewportId:t.viewport,message:s,requestId:n})),o?(T==null||T(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:"batch",type:"viewport-update",clientViewportId:e.clientViewportId,rows:o})):i&&this.postMessageToClient(i)}setConfig(e,t){let n=R(),s=e.setConfig(n,t.config);this.sendIfReady(s,n,e.status==="subscribed")}aggregate(e,t){let n=R(),s=e.aggregateRequest(n,t.aggregations);this.sendIfReady(s,n,e.status==="subscribed")}sort(e,t){let n=R(),s=e.sortRequest(n,t.sort);this.sendIfReady(s,n,e.status==="subscribed")}setColumns(e,t){let n=R(),{columns:s}=t,o=e.columnRequest(n,s);this.sendIfReady(o,n,e.status==="subscribed")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=R(),{selected:s}=t,o=e.selectRequest(n,s);this.sendIfReady(o,n,e.status==="subscribed")}disableViewport(e){let t=R(),n=e.disable(t);this.sendIfReady(n,t,e.status==="subscribed")}enableViewport(e){if(e.disabled){let t=R(),n=e.enable(t);this.sendIfReady(n,t,e.status==="subscribed")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{T==null||T("suspendTimer expired, escalate suspend to disable"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(V==null||V("clear suspend timer"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let[t,n]=e.resume();V==null||V(`resumeViewport size ${t}, ${n.length} rows sent to client`),this.postMessageToClient({clientViewportId:e.clientViewportId,mode:"batch",rows:n,size:t,type:"viewport-update"})}openTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.openTreeNode(n,t),n,e.status==="subscribed")}}closeTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.closeTreeNode(n,t),n,e.status==="subscribed")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:s,childColumnName:o}=t,i=R(),u=this.mapClientToServerViewport.get(n);if(u){let l=e.createLink(i,o,u,s);this.sendMessageToServer(l,i)}else y("ServerProxy unable to create link, viewport not found")}removeLink(e){let t=R(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var s;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(s=o.links)!=null&&s.some(i=>i.parentVpId===t)){let[i]=o.setLinks(St(o.links,t,n));this.postMessageToClient(i)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:s})=>s===e)){let[s]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(s)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId},n)}}viewportRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId,namedParams:{}},n)}}rpcCall(e){let[t,n]=A(e),s=We(n.service);this.sendMessageToServer(n,t,{module:s})}handleMessageFromClient(e){var t;if(ge(e))if(e.type==="disable"){let n=this.getViewportForClient(e.viewport,!1);return n!==null?this.disableViewport(n):void 0}else{let n=this.getViewportForClient(e.viewport);switch(e.type){case"setViewRange":return this.setViewRange(n,e);case"config":return this.setConfig(n,e);case"aggregate":return this.aggregate(n,e);case"sort":return this.sort(n,e);case"select":return this.select(n,e);case"suspend":return this.suspendViewport(n);case"resume":return this.resumeViewport(n);case"enable":return this.enableViewport(n);case"openTreeNode":return this.openTreeNode(n,e);case"closeTreeNode":return this.closeTreeNode(n,e);case"createLink":return this.createLink(n,e);case"removeLink":return this.removeLink(n);case"setColumns":return this.setColumns(n,e);case"setTitle":return this.setTitle(n,e);default:}}else{if(Ce(e))return this.viewportRpcCall(e);if(me(e))return this.menuRpcCall(e);{let{type:n,requestId:s}=e;switch(n){case"GET_TABLE_LIST":{(t=this.tableList)!=null||(this.tableList=this.awaitResponseToMessage({type:n},s)),this.tableList.then(o=>{this.postMessageToClient({type:"TABLE_LIST_RESP",tables:o.tables,requestId:s})});return}case"GET_TABLE_META":{this.getTableMeta(e.table,s).then(o=>{o&&this.postMessageToClient({type:"TABLE_META_RESP",tableSchema:o,requestId:s})});return}case"RPC_CALL":return this.rpcCall(e);default:}}}y(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}getTableMeta(e,t=R()){if(O(e))return Promise.resolve(void 0);let n=`${e.module}:${e.table}`,s=this.cachedTableMetaRequests.get(n);return s||(s=this.awaitResponseToMessage({type:"GET_TABLE_META",table:e},t),this.cachedTableMetaRequests.set(n,s)),s==null?void 0:s.then(o=>this.cacheTableMeta(o))}awaitResponseToMessage(e,t=R()){return new Promise((n,s)=>{this.sendMessageToServer(e,t),this.pendingRequests.set(t,{reject:s,resolve:n})})}sendIfReady(e,t,n=!0){return n&&this.sendMessageToServer(e,t),n}sendMessageToServer(e,t=`${Ue++}`,n=mt){let{module:s="CORE"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:s,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:s}=e,o=this.pendingRequests.get(n);if(o){let{resolve:a}=o;this.pendingRequests.delete(n),a(t);return}let{viewports:i}=this;switch(t.type){case De:this.sendMessageToServer({type:Ie,ts:+new Date},"NA");break;case"LOGIN_SUCCESS":if(s)this.sessionId=s,(u=this.pendingLogin)==null||u.resolve(s),this.pendingLogin=void 0;else throw Error("LOGIN_SUCCESS did not provide sessionId");break;case"REMOVE_VP_SUCCESS":{let a=i.get(t.viewPortId);a&&(this.mapClientToServerViewport.delete(a.clientViewportId),i.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case Oe:{let a=this.viewports.get(t.vpId);a&&a.completeOperation(n)}break;case Te:case ve:if(i.has(t.viewPortId)){let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);c!==void 0&&(this.postMessageToClient(c),Y&&V(`postMessageToClient ${JSON.stringify(c)}`))}}break;case ye:{let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);if(c){this.postMessageToClient(c);let[g,S]=a.resume();this.postMessageToClient({clientViewportId:a.clientViewportId,mode:"batch",rows:S,size:g,type:"viewport-update"})}}}break;case"TABLE_ROW":{let a=Se(t.rows);for(let[c,g]of Object.entries(a)){let S=i.get(c);S?S.updateRows(g):Q==null||Q(`TABLE_ROW message received for non registered viewport ${c}`)}this.processUpdates()}break;case"CHANGE_VP_RANGE_SUCCESS":{let a=this.viewports.get(t.viewPortId);if(a){let{from:c,to:g}=t;a.completeOperation(n,c,g)}}break;case xe:case we:break;case"CREATE_VISUAL_LINK_SUCCESS":{let a=this.viewports.get(t.childVpId),c=this.viewports.get(t.parentVpId);if(a&&c){let{childColumnName:g,parentColumnName:S}=t,D=a.completeOperation(n,g,c.clientViewportId,S);D&&this.postMessageToClient(D)}}break;case"REMOVE_VISUAL_LINK_SUCCESS":{let a=this.viewports.get(t.childVpId);if(a){let c=a.completeOperation(n);c&&this.postMessageToClient(c)}}break;case"VP_VISUAL_LINKS_RESP":{let a=this.getActiveLinks(t.links),c=this.viewports.get(t.vpId);if(a.length&&c){let g=Tt(a,this.viewports),[S,D]=c.setLinks(g);if(this.postMessageToClient(S),D){let{link:se,parentClientVpId:ze}=D,re=R(),oe=this.mapClientToServerViewport.get(ze);if(oe){let Ke=c.createLink(re,se.fromColumn,oe,se.toColumn);this.sendMessageToServer(Ke,re)}}}}break;case"VIEW_PORT_MENUS_RESP":if(t.menu.name){let a=this.viewports.get(t.vpId);if(a){let c=a.setMenu(t.menu);this.postMessageToClient(c)}}break;case"VP_EDIT_RPC_RESPONSE":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:"VP_EDIT_RPC_RESPONSE"});break;case"VP_EDIT_RPC_REJECT":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:"VP_EDIT_RPC_REJECT",error:t.error});break;case"VIEW_PORT_MENU_REJ":{console.log("send menu error back to client");let{error:a,rpcName:c,vpId:g}=t,S=this.viewports.get(g);S&&this.postMessageToClient({clientViewportId:S.clientViewportId,error:a,rpcName:c,type:"VIEW_PORT_MENU_REJ",requestId:n});break}case"VIEW_PORT_MENU_RESP":if(fe(t)){let{action:a,rpcName:c}=t;this.awaitResponseToMessage({type:"GET_TABLE_META",table:a.table}).then(g=>{let S=z(g);this.postMessageToClient({rpcName:c,type:"VIEW_PORT_MENU_RESP",action:{...a,tableSchema:S},tableAlreadyOpen:this.isTableOpen(a.table),requestId:n})})}else{let{action:a}=t;this.postMessageToClient({type:"VIEW_PORT_MENU_RESP",action:a||Rt,tableAlreadyOpen:a!==null&&this.isTableOpen(a.table),requestId:n})}break;case"RPC_RESP":{let{method:a,result:c}=t;this.postMessageToClient({type:"RPC_RESP",method:a,result:c,requestId:n})}break;case"VIEW_PORT_RPC_REPONSE":{let{method:a,action:c}=t;this.postMessageToClient({type:"VIEW_PORT_RPC_RESPONSE",rpcName:a,action:c,requestId:n})}break;case"ERROR":y(t.msg);break;default:ft&&T(`handleMessageFromServer ${t.type}.`)}}cacheTableMeta(e){let{module:t,table:n}=e.table,s=`${t}:${n}`,o=this.cachedTableSchemas.get(s);return o||(o=z(e),this.cachedTableSchemas.set(s,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==U){let[s,o]=n,i=e.getNewRowCount();(i!==void 0||s&&s.length>0)&&(Y&&V(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=s==null?void 0:s.length)!=null?t:"no"} rows, size ${i}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:s,size:i,type:"viewport-update"}))}}})}};var{debug:un,debugEnabled:ln,error:qe,info:w,infoEnabled:bt,warn:_}=b("websocket-connection"),Be={},Z=Symbol("setWebsocket"),$=Symbol("connectionCallback");async function Ge(r,e,t,n=10,s=5){return Be[r]={status:"connecting",connect:{allowed:s,remaining:s},reconnect:{allowed:n,remaining:n}},He(r,e,t)}async function X(r){throw Error("connection broken")}async function He(r,e,t,n){let{status:s,connect:o,reconnect:i}=Be[r],u=s==="connecting"?o:i;try{t({type:"connection-status",status:"connecting"});let l=typeof n<"u",p=await Et(r,e);console.info("%c\u26A1 %cconnected","font-size: 24px;color: green;font-weight: bold;","color:green; font-size: 14px;"),n!==void 0&&n[Z](p);let a=n!=null?n:new ee(p,r,e,t),c=l?"reconnected":"connection-open-awaiting-session";return t({type:"connection-status",status:c}),a.status=c,u.remaining=u.allowed,a}catch{let p=--u.remaining>0;if(t({type:"connection-status",status:"disconnected",reason:"failed to connect",retry:p}),p)return wt(r,e,t,n,2e3);throw t({type:"connection-status",status:"failed",reason:"unable to connect",retry:p}),Error("Failed to establish connection")}}var wt=(r,e,t,n,s)=>new Promise(o=>{setTimeout(()=>{o(He(r,e,t,n))},s)}),Et=(r,e)=>new Promise((t,n)=>{bt&&e!==void 0&&w(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let s=new WebSocket(r,e);s.onopen=()=>t(s),s.onerror=o=>n(o)}),Fe=()=>{_==null||_("Connection cannot be closed, socket not yet opened")},$e=r=>{_==null||_(`Message cannot be sent, socket closed ${r.body.type}`)},Vt=r=>{try{return JSON.parse(r)}catch{throw Error(`Error parsing JSON response from server ${r}`)}},ee=class{constructor(e,t,n,s){this.close=Fe;this.requiresLogin=!0;this.send=$e;this.status="ready";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Vt(e.data);this.messagesCount+=1,this[$](t)};this.url=t,this.protocol=n,this[$]=s,this[Z](e)}reconnect(){X(this)}[($,Z)](e){let t=this[$];e.onmessage=o=>{this.status="connected",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:"connection-metrics",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{qe("\u26A1 connection error"),t({type:"connection-status",status:"disconnected",reason:"error"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status==="connection-open-awaiting-session"?qe("Websocket connection lost before Vuu session established, check websocket configuration"):this.status!=="closed"&&(X(this),this.send=s)},e.onclose=()=>{w==null||w("\u26A1 connection close"),t({type:"connection-status",status:"disconnected",reason:"close"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!=="closed"&&(X(this),this.send=s)};let n=o=>{e.send(JSON.stringify(o))},s=o=>{w==null||w(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status="closed",e.close(),this.close=Fe,this.send=$e,w==null||w("close websocket")}}};var v,{info:te,infoEnabled:ne}=b("worker");async function vt(r,e,t,n,s,o,i){let u=await Ge(r,e,l=>{de(l)?postMessage({type:"connection-metrics",messages:l}):pe(l)?(s(l),l.status==="reconnected"&&v.reconnect()):v.handleMessageFromServer(l)},o,i);v=new F(u,l=>Mt(l)),u.requiresLogin&&await v.login(t,n)}function Mt(r){postMessage(r)}var yt=async({data:r})=>{switch(r.type){case"connect":try{await vt(r.url,r.protocol,r.token,r.username,postMessage,r.retryLimitDisconnect,r.retryLimitStartup),postMessage({type:"connected"})}catch(e){postMessage({type:"connection-failed",reason:String(e)})}break;case"subscribe":ne&&te(`client subscribe: ${JSON.stringify(r)}`),v.subscribe(r);break;case"unsubscribe":ne&&te(`client unsubscribe: ${JSON.stringify(r)}`),v.unsubscribe(r.viewport);break;default:ne&&te(`client message: ${JSON.stringify(r)}`),v.handleMessageFromClient(r)}};self.addEventListener("message",yt);postMessage({type:"ready"});\n\n';var he=new Blob([(0,p.getLoggingConfigForWorker)()+J],{type:"text/javascript"}),pe=URL.createObjectURL(he),C,U,y=[],K,H,j=new Promise((t,r)=>{K=t,H=r}),$=()=>j,I=new Map,k=new Map,de=async({handleConnectionStatusChange:t,protocol:r,retryLimitDisconnect:e,retryLimitStartup:s,token:n="",username:c,url:h})=>n===""&&U===void 0?new Promise((f,w)=>{y.push({resolve:f,reject:w})}):U||(U=new Promise((f,w)=>{let v=new Worker(pe),m=window.setTimeout(()=>{w(Error("timed out waiting for worker to load"))},1e3);v.onmessage=_=>{let{data:R}=_;if(R.type==="ready")window.clearTimeout(m),v.postMessage({protocol:r,retryLimitDisconnect:e,retryLimitStartup:s,token:n,type:"connect",url:h,username:c});else if(R.type==="connected"){v.onmessage=X,f(v);for(let N of y)N.resolve(v);y.length=0}else if((0,p.isConnectionStatusMessage)(R))t({data:R});else if(R.type==="connection-failed"){w(R.reason);for(let N of y)N.reject(R.reason);y.length=0}else console.warn("ConnectionManager: Unexpected message from the worker")}}));function X({data:t}){if(A(t)){let r=I.get(t.clientViewportId);r?r.postMessageToClientDataSource(t):console.error(`[ConnectionManager] ${t.type} message received, viewport not found`)}else if((0,p.isConnectionStatusMessage)(t))L.emit("connection-status",t);else if((0,p.isConnectionQualityMetrics)(t))L.emit("connection-metrics",t);else{let r=t.requestId;if(k.has(r)){let{resolve:e}=k.get(r);k.delete(r);let{type:s,requestId:n,...c}=t;(0,p.messageHasResult)(t)?e(t.result):t.type==="VP_EDIT_RPC_RESPONSE"||t.type==="VP_EDIT_RPC_REJECT"?e(t):(0,p.isTableSchema)(t)?e(t.tableSchema):e(c)}else console.warn("%cConnectionManager Unexpected message from the worker","color:red;font-weight:bold;")}}var q=t=>{let r=(0,p.uuid)();return C.postMessage({requestId:r,...t}),new Promise((e,s)=>{k.set(r,{resolve:e,reject:s})})},ge={subscribe:(t,r)=>{if(I.get(t.viewport))throw Error("ConnectionManager attempting to subscribe with an existing viewport id");I.set(t.viewport,{status:"subscribing",request:t,postMessageToClientDataSource:r}),C.postMessage({type:"subscribe",...t})},unsubscribe:t=>{C.postMessage({type:"unsubscribe",viewport:t})},send:t=>{C.postMessage(t)},destroy:t=>{t&&I.has(t)&&I.delete(t)},rpcCall:async t=>q(t),getTableList:async()=>q({type:"GET_TABLE_LIST"}),getTableSchema:async t=>q({type:F,table:t})},x=class extends p.EventEmitter{async connect({url:r,authToken:e,username:s,protocol:n,retryLimitDisconnect:c,retryLimitStartup:h}){return C=await de({protocol:n,url:r,token:e,username:s,retryLimitDisconnect:c,retryLimitStartup:h,handleConnectionStatusChange:X}),ge}destroy(){C.terminate()}},L=new x,fe=async({url:t,protocol:r=void 0,authToken:e,username:s,retryLimitDisconnect:n,retryLimitStartup:c})=>{try{let h=await L.connect({protocol:r,url:t,authToken:e,username:s,retryLimitDisconnect:n,retryLimitStartup:c});return K(h),"connected"}catch(h){return H(h),"rejected"}},we=async t=>{try{return(await j).rpcCall(t)}catch{throw Error("Error accessing server api")}};var ve=0,Re={get nextValue(){return ve++}},be={connect:"connect",connectionStatus:"connection-status",getFilterData:"GetFilterData",rowData:"rowData",rowSet:"rowset",select:"select",selectAll:"selectAll",selectNone:"selectNone",selected:"selected",snapshot:"snapshot",update:"update",createLink:"createLink",disable:"disable",enable:"enable",suspend:"suspend",resume:"resume",addSubscription:"AddSubscription",closeTreeNode:"closeTreeNode",columnList:"ColumnList",data:"data",openTreeNode:"openTreeNode",aggregate:"aggregate",filter:"filter",filterQuery:"filterQuery",filterData:"filterData",getSearchData:"GetSearchData",groupBy:"groupBy",modifySubscription:"ModifySubscription",searchData:"searchData",setGroupState:"setGroupState",size:"size",sort:"sort",subscribed:"Subscribed",tableList:"TableList",unsubscribe:"TerminateSubscription",viewRangeChanged:"ViewRangeChanged"};var Ee=["VIEW_PORT_MENUS_SELECT_RPC","VIEW_PORT_MENU_TABLE_RPC","VIEW_PORT_MENU_ROW_RPC","VIEW_PORT_MENU_CELL_RPC","VP_EDIT_CELL_RPC","VP_EDIT_ROW_RPC","VP_EDIT_ADD_ROW_RPC","VP_EDIT_DELETE_CELL_RPC","VP_EDIT_DELETE_ROW_RPC","VP_EDIT_SUBMIT_FORM_RPC"],Ce=t=>Ee.includes(t.type),Te=t=>t.type==="VIEW_PORT_RPC_CALL",Se=({requestId:t,...r})=>[t,r],me=t=>{let r=t.at(0);if(r.updateType==="SIZE"){if(t.length===1)return t;r=t.at(1)}let e=t.at(-1);return[r,e]},_e=t=>{let r={};for(let e of t)(r[e.viewPortId]||(r[e.viewPortId]=[])).push(e);return r},ye=({columns:t,dataTypes:r,key:e,table:s})=>({table:s,columns:t.map((n,c)=>({name:n,serverDataType:r[c]})),key:e});var Z=require("@vuu-ui/vuu-filter-parser"),u=require("@vuu-ui/vuu-utils");var{info:d}=(0,u.logger)("VuuDataSource"),{KEY:Ie}=u.metadataKeys,o,O,V,P,T,b,M,S,a,E,B=class extends u.EventEmitter{constructor({bufferSize:e=100,aggregations:s,columns:n,filter:c,groupBy:h,sort:f,table:w,title:v,viewport:m,visualLink:_}){super();this.server=null;g(this,o,u.vanillaConfig);g(this,O,[]);g(this,V,void 0);g(this,P,void 0);g(this,T,"throttle");g(this,b,{from:0,to:0});g(this,M,0);g(this,S,0);g(this,a,"initialising");g(this,E,void 0);this.handleMessageFromServer=e=>{var s,n;if(e.type==="subscribed")l(this,a,"subscribed"),e.tableSchema&&(this.tableSchema=e.tableSchema),(s=this.clientCallback)==null||s.call(this,e);else if(e.type==="disabled")l(this,a,"disabled");else if(e.type==="enabled")l(this,a,"enabled");else{if(W(e))return;e.type==="debounce-begin"?this.optimize="debounce":(e.type==="viewport-update"&&e.size!==void 0&&e.size!==i(this,S)&&(l(this,S,e.size),this.emit("resize",e.size)),this.configChangePending&&this.setConfigPending(),(0,u.isViewportMenusAction)(e)?l(this,P,e.menu):(0,u.isVisualLinksAction)(e)?l(this,V,e.links):(n=this.clientCallback)==null||n.call(this,e),this.optimize==="debounce"&&this.revertDebounce())}};this.revertDebounce=(0,u.debounce)(()=>{this.optimize="throttle"},100);this.rawRangeRequest=e=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:e})};this.debounceRangeRequest=(0,u.debounce)(e=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:e})},50);this.throttleRangeRequest=(0,u.throttle)(e=>{this.viewport&&this.server&&this.server.send({viewport:this.viewport,type:"setViewRange",range:e})},80);if(!w)throw Error("RemoteDataSource constructor called without table");this.bufferSize=e,this.table=w,this.viewport=m,l(this,o,{...i(this,o),aggregations:s||i(this,o).aggregations,columns:n||i(this,o).columns,filter:c||i(this,o).filter,groupBy:h||i(this,o).groupBy,sort:f||i(this,o).sort,visualLink:_||i(this,o).visualLink}),l(this,E,v),this.rangeRequest=this.throttleRangeRequest}async subscribe({viewport:e=(m=>(m=this.viewport)!=null?m:this.viewport=(0,u.uuid)())(),columns:s,aggregations:n,range:c,sort:h,groupBy:f,filter:w},v){var R;if(i(this,a)==="disabled"||i(this,a)==="disabling"){this.enable(v);return}if(this.clientCallback=v,(n||s||w||f||h)&&l(this,o,{...i(this,o),aggregations:n||i(this,o).aggregations,columns:s||i(this,o).columns,filter:w||i(this,o).filter,groupBy:f||i(this,o).groupBy,sort:h||i(this,o).sort}),c&&l(this,b,c),i(this,a)!=="initialising"&&i(this,a)!=="unsubscribed")return;l(this,a,"subscribing"),this.viewport=e,this.server=await $();let{bufferSize:_}=this;(R=this.server)==null||R.subscribe({...i(this,o),bufferSize:_,viewport:e,table:this.table,range:i(this,b),title:i(this,E)},this.handleMessageFromServer)}unsubscribe(){var e,s;console.log(`unsubscribe #${this.viewport}`),d==null||d(`unsubscribe #${this.viewport}`),this.viewport&&((e=this.server)==null||e.unsubscribe(this.viewport)),(s=this.server)==null||s.destroy(this.viewport),this.server=null,this.removeAllListeners(),l(this,a,"unsubscribed"),this.viewport=void 0,this.range={from:0,to:0}}suspend(){var e;return console.log(`suspend #${this.viewport}, current status ${i(this,a)}`),d==null||d(`suspend #${this.viewport}, current status ${i(this,a)}`),this.viewport&&(l(this,a,"suspended"),(e=this.server)==null||e.send({type:"suspend",viewport:this.viewport})),this}resume(){var n;console.log(`resume #${this.viewport}, current status ${i(this,a)}`);let e=i(this,a).startsWith("disabl"),s=i(this,a)==="suspended";return d==null||d(`resume #${this.viewport}, current status ${i(this,a)}`),this.viewport&&(e?this.enable():s&&((n=this.server)==null||n.send({type:"resume",viewport:this.viewport}),l(this,a,"subscribed"))),this}disable(){var e;return d==null||d(`disable #${this.viewport}, current status ${i(this,a)}`),this.viewport&&(l(this,a,"disabling"),(e=this.server)==null||e.send({viewport:this.viewport,type:"disable"})),this}enable(e){var s;return d==null||d(`enable #${this.viewport}, current status ${i(this,a)}`),this.viewport&&(i(this,a)==="disabled"||i(this,a)==="disabling")&&(l(this,a,"enabling"),e&&(this.clientCallback=e),(s=this.server)==null||s.send({viewport:this.viewport,type:"enable"})),this}select(e){var s;l(this,M,e.length),this.viewport&&((s=this.server)==null||s.send({viewport:this.viewport,type:"select",selected:e}))}openTreeNode(e){var s;this.viewport&&((s=this.server)==null||s.send({viewport:this.viewport,type:"openTreeNode",key:e}))}closeTreeNode(e){var s;this.viewport&&((s=this.server)==null||s.send({viewport:this.viewport,type:"closeTreeNode",key:e}))}get links(){return i(this,V)}get menu(){return i(this,P)}get status(){return i(this,a)}get optimize(){return i(this,T)}set optimize(e){if(e!==i(this,T)){switch(l(this,T,e),e){case"none":this.rangeRequest=this.rawRangeRequest;break;case"debounce":this.rangeRequest=this.debounceRangeRequest;break;case"throttle":this.rangeRequest=this.throttleRangeRequest;break}this.emit("optimize",e)}}get selectedRowsCount(){return i(this,M)}get size(){return i(this,S)}get range(){return i(this,b)}set range(e){(e.from!==i(this,b).from||e.to!==i(this,b).to)&&(l(this,b,e),this.rangeRequest(e))}get config(){return i(this,o)}set config(e){var n;let s=this.applyConfig(e);s&&(i(this,o)&&this.viewport&&e&&((n=this.server)==null||n.send({viewport:this.viewport,type:"config",config:i(this,o)})),this.emit("config",i(this,o),void 0,s))}applyConfig(e){var c;let{noChanges:s,...n}=(0,u.isConfigChanged)(i(this,o),e);if(s!==!0&&e){let h=(c=e==null?void 0:e.filter)!=null&&c.filter&&(e==null?void 0:e.filter.filterStruct)===void 0?{...e,filter:{filter:e.filter.filter,filterStruct:(0,Z.parseFilter)(e.filter.filter)}}:e;return l(this,o,(0,u.withConfigDefaults)(h)),n}}get columns(){return i(this,o).columns}set columns(e){if(l(this,o,{...i(this,o),columns:e}),this.viewport){let s={viewport:this.viewport,type:"setColumns",columns:e};this.server&&this.server.send(s)}this.emit("config",i(this,o))}get aggregations(){return i(this,o).aggregations}set aggregations(e){var s;l(this,o,{...i(this,o),aggregations:e}),this.viewport&&((s=this.server)==null||s.send({viewport:this.viewport,type:"aggregate",aggregations:e})),this.emit("config",i(this,o))}get sort(){return i(this,o).sort}set sort(e){var s;if(l(this,o,{...i(this,o),sort:e}),this.viewport){let n={viewport:this.viewport,type:"sort",sort:e};(s=this.server)==null||s.send(n)}this.emit("config",i(this,o))}get filter(){return i(this,o).filter}set filter(e){this.config={...i(this,o),filter:e}}get groupBy(){return i(this,o).groupBy}set groupBy(e){var s;if((0,u.itemsOrOrderChanged)(this.groupBy,e)){let n=i(this,O).length>0;this.config={...i(this,o),groupBy:e},!n&&e.length>0&&this.viewport&&((s=this.clientCallback)==null||s.call(this,{clientViewportId:this.viewport,mode:"batch",type:"viewport-update",size:0,rows:[]})),this.setConfigPending({groupBy:e})}}get title(){return i(this,E)}set title(e){var s;l(this,E,e),this.viewport&&e&&((s=this.server)==null||s.send({type:"setTitle",title:e,viewport:this.viewport}))}get visualLink(){return i(this,o).visualLink}set visualLink(e){var s,n;if(l(this,o,{...i(this,o),visualLink:e}),e){let{parentClientVpId:c,link:{fromColumn:h,toColumn:f}}=e;this.viewport&&((s=this.server)==null||s.send({viewport:this.viewport,type:"createLink",parentClientVpId:c,parentColumnName:f,childColumnName:h}))}else this.viewport&&((n=this.server)==null||n.send({type:"removeLink",viewport:this.viewport}));this.emit("config",i(this,o))}setConfigPending(e){let s=this.configChangePending;this.configChangePending=e,e!==void 0?this.emit("config",e,!1):this.emit("config",s,!0)}async rpcCall(e){var s;if(this.viewport)return(s=this.server)==null?void 0:s.rpcCall({vpId:this.viewport,...e})}async menuRpcCall(e){var s;if(this.viewport)return(s=this.server)==null?void 0:s.rpcCall({vpId:this.viewport,...e})}applyEdit(e,s,n){return this.menuRpcCall({rowKey:e[Ie],field:s,value:n,type:"VP_EDIT_CELL_RPC"}).then(c=>c!=null&&c.error?c.error:!0)}insertRow(e,s){return this.menuRpcCall({rowKey:e,data:s,type:"VP_EDIT_ADD_ROW_RPC"}).then(n=>n!=null&&n.error?n.error:!0)}deleteRow(e){return this.menuRpcCall({rowKey:e,type:"VP_EDIT_DELETE_ROW_RPC"}).then(s=>s!=null&&s.error?s.error:!0)}};o=new WeakMap,O=new WeakMap,V=new WeakMap,P=new WeakMap,T=new WeakMap,b=new WeakMap,M=new WeakMap,S=new WeakMap,a=new WeakMap,E=new WeakMap;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var authenticate = require('./authenticate.js');
|
|
4
|
+
var connectionManager = require('./connection-manager.js');
|
|
5
|
+
var constants = require('./constants.js');
|
|
6
|
+
var dataSource = require('./data-source.js');
|
|
7
|
+
var messageUtils = require('./message-utils.js');
|
|
8
|
+
var vuuDataSource = require('./vuu-data-source.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.authenticate = authenticate.authenticate;
|
|
13
|
+
exports.ConnectionManager = connectionManager.ConnectionManager;
|
|
14
|
+
exports.connectToServer = connectionManager.connectToServer;
|
|
15
|
+
exports.getServerAPI = connectionManager.getServerAPI;
|
|
16
|
+
exports.makeRpcCall = connectionManager.makeRpcCall;
|
|
17
|
+
exports.connectionId = constants.connectionId;
|
|
18
|
+
exports.msgType = constants.msgType;
|
|
19
|
+
exports.isDataSourceConfigMessage = dataSource.isDataSourceConfigMessage;
|
|
20
|
+
exports.isSessionTable = dataSource.isSessionTable;
|
|
21
|
+
exports.isSessionTableActionMessage = dataSource.isSessionTableActionMessage;
|
|
22
|
+
exports.isSizeOnly = dataSource.isSizeOnly;
|
|
23
|
+
exports.shouldMessageBeRoutedToDataSource = dataSource.shouldMessageBeRoutedToDataSource;
|
|
24
|
+
exports.toDataSourceConfig = dataSource.toDataSourceConfig;
|
|
25
|
+
exports.createSchemaFromTableMetadata = messageUtils.createSchemaFromTableMetadata;
|
|
26
|
+
exports.getFirstAndLastRows = messageUtils.getFirstAndLastRows;
|
|
27
|
+
exports.groupRowsByViewport = messageUtils.groupRowsByViewport;
|
|
28
|
+
exports.isVuuMenuRpcRequest = messageUtils.isVuuMenuRpcRequest;
|
|
29
|
+
exports.isVuuRpcRequest = messageUtils.isVuuRpcRequest;
|
|
30
|
+
exports.stripRequestId = messageUtils.stripRequestId;
|
|
31
|
+
exports.VuuDataSource = vuuDataSource.VuuDataSource;
|
|
2
32
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"version": "0.8.32",
|
|
2
|
+
"version": "0.8.33",
|
|
4
3
|
"author": "heswell",
|
|
5
4
|
"license": "Apache-2.0",
|
|
6
5
|
"devDependencies": {
|
|
7
|
-
"@vuu-ui/vuu-data-types": "0.8.
|
|
8
|
-
"@vuu-ui/vuu-table-types": "0.8.
|
|
9
|
-
"@vuu-ui/vuu-filter-types": "0.8.
|
|
10
|
-
"@vuu-ui/vuu-protocol-types": "0.8.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "0.8.33",
|
|
7
|
+
"@vuu-ui/vuu-table-types": "0.8.33",
|
|
8
|
+
"@vuu-ui/vuu-filter-types": "0.8.33",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.8.33"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
13
|
-
"@vuu-ui/vuu-filter-parser": "0.8.
|
|
14
|
-
"@vuu-ui/vuu-utils": "0.8.
|
|
12
|
+
"@vuu-ui/vuu-filter-parser": "0.8.33",
|
|
13
|
+
"@vuu-ui/vuu-utils": "0.8.33"
|
|
15
14
|
},
|
|
16
15
|
"files": [
|
|
17
|
-
"cjs",
|
|
18
|
-
"esm",
|
|
19
16
|
"README.md",
|
|
20
17
|
"/types"
|
|
21
18
|
],
|
|
22
|
-
"module": "esm/index.js",
|
|
23
19
|
"main": "cjs/index.js",
|
|
20
|
+
"module": "esm/index.js",
|
|
21
|
+
"name": "@vuu-ui/vuu-data-remote",
|
|
24
22
|
"types": "types/index.d.ts"
|
|
25
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const workerSourceCode: "\nvar ie=(r,e,t)=>{if(!e.has(r))throw TypeError(\"Cannot \"+t)};var m=(r,e,t)=>(ie(r,e,\"read from private field\"),t?t.call(r):e.get(r)),ae=(r,e,t)=>{if(e.has(r))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,n)=>(ie(r,e,\"write to private field\"),n?n.call(r,t):e.set(r,t),t);function le(r,e,t=[],n=[]){for(let s=0,o=r.length;s<o;s++)(e(r[s],s)?t:n).push(r[s]);return[t,n]}var Je=6,B={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:Je,SELECTED:7,count:8,PARENT_IDX:\"parent_idx\",IDX_POINTER:\"idx_pointer\",FILTER_COUNT:\"filter_count\",NEXT_FILTER_IDX:\"next_filter_idx\"};var{DEPTH:It,IS_LEAF:Pt}=B;var ce=r=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split(\"; \").find(n=>n.startsWith(`${r}=`)))==null?void 0:t.split(\"=\")[1]};function G({from:r,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(r===0&&e===0)return{from:r,to:e};if(t===0)return n<r?{from:0,to:0}:{from:r,to:Math.min(e,n)};if(r===0)return{from:r,to:Math.min(e+t,n)};{let s=r-t<0,o=n-(e+t)<0;return s&&o?{from:0,to:n}:s?{from:0,to:e+t}:o?{from:Math.max(0,r-t),to:n}:{from:r-t,to:e+t}}}var je=(r,{from:e,to:t})=>r>=e&&r<t;var I=class r{constructor(e,t){this.from=e,this.to=t}isWithin(e){return je(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new r(this.from,this.to)}};var pe=r=>r.type===\"connection-status\",de=r=>r.type===\"connection-metrics\";var ge=r=>\"viewport\"in r;var Ye=[\"error\",\"warn\",\"info\",\"debug\"],Qe=r=>typeof r==\"string\"&&Ye.includes(r),Xe=\"error\",P=()=>{},Ze=\"error\",{loggingLevel:L=Ze}=et(),b=r=>{let e=L===\"debug\",t=e||L===\"info\",n=t||L===\"warn\",s=n||L===\"error\",o=t?p=>console.info(`[${r}] ${p}`):P,i=n?p=>console.warn(`[${r}] ${p}`):P,u=e?p=>console.debug(`[${r}] ${p}`):P;return{errorEnabled:s,error:s?p=>console.error(`[${r}] ${p}`):P}};function et(){return typeof loggingSettings<\"u\"?loggingSettings:{loggingLevel:tt()}}function tt(){let r=ce(\"vuu-logging-level\");return Qe(r)?r:Xe}var{debug:nt,debugEnabled:st}=b(\"range-monitor\"),x=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)st&&nt(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};var rt=[],k=class{constructor(e){this.keys=new Map;this.nextKeyValue=0;this.range=e,this.init(e)}next(e=rt){return e.length>0?e.shift():this.nextKeyValue++}init({from:e,to:t}){this.keys.clear(),this.nextKeyValue=0;for(let n=e;n<t;n++){let s=this.next();this.keys.set(n,s)}return!0}reset(e){let{from:t,to:n}=e,s=n-t,o=this.range.to-this.range.from;if(this.range=e,o>s)return this.init(e);let i=[];this.keys.forEach((u,l)=>{(l<t||l>=n)&&(i.push(u),this.keys.delete(l))});for(let u=t;u<n;u++)if(!this.keys.has(u)){let l=this.next(i);this.keys.set(u,l)}return!1}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return`${this.keys.size} keys\n${Array.from(this.keys.entries()).sort(([e],[t])=>e-t).map(([e,t])=>`${e}=>${t}`).join(\",\")}]\n`}};var{SELECTED:$t}=B,E={False:0,True:1,First:2,Last:4};var ot=(r,e)=>e>=r[0]&&e<=r[1],it=E.True+E.First+E.Last,at=E.True+E.First,ut=E.True+E.Last,H=(r,e)=>{for(let t of r)if(typeof t==\"number\"){if(t===e)return it}else if(ot(t,e))return e===t[0]?at:e===t[1]?ut:E.True;return E.False};var he=r=>{if(r.every(t=>typeof t==\"number\"))return r;let e=[];for(let t of r)if(typeof t==\"number\")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var fe=r=>r.type===\"VIEW_PORT_MENU_RESP\"&&r.action!==null&&O(r.action.table),O=r=>r!==null&&typeof r==\"object\"&&\"table\"in r&&\"module\"in r?r.table.startsWith(\"session\"):!1;var lt=[\"VIEW_PORT_MENUS_SELECT_RPC\",\"VIEW_PORT_MENU_TABLE_RPC\",\"VIEW_PORT_MENU_ROW_RPC\",\"VIEW_PORT_MENU_CELL_RPC\",\"VP_EDIT_CELL_RPC\",\"VP_EDIT_ROW_RPC\",\"VP_EDIT_ADD_ROW_RPC\",\"VP_EDIT_DELETE_CELL_RPC\",\"VP_EDIT_DELETE_ROW_RPC\",\"VP_EDIT_SUBMIT_FORM_RPC\"],me=r=>lt.includes(r.type),Ce=r=>r.type===\"VIEW_PORT_RPC_CALL\",A=({requestId:r,...e})=>[r,e],Re=r=>{let e=r.at(0);if(e.updateType===\"SIZE\"){if(r.length===1)return r;e=r.at(1)}let t=r.at(-1);return[e,t]},Se=r=>{let e={};for(let t of r)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e},z=({columns:r,dataTypes:e,key:t,table:n})=>({table:n,columns:r.map((s,o)=>({name:s,serverDataType:e[o]})),key:t});var Te=\"CHANGE_VP_SUCCESS\";var be=\"CLOSE_TREE_NODE\",we=\"CLOSE_TREE_SUCCESS\";var Ee=\"CREATE_VP\",Ve=\"DISABLE_VP\",ve=\"DISABLE_VP_SUCCESS\";var Me=\"ENABLE_VP\",ye=\"ENABLE_VP_SUCCESS\";var K=\"GET_VP_VISUAL_LINKS\",_e=\"GET_VIEW_PORT_MENUS\";var De=\"HB\",Ie=\"HB_RESP\",Pe=\"LOGIN\",Le=\"OPEN_TREE_NODE\",xe=\"OPEN_TREE_SUCCESS\";var ke=\"REMOVE_VP\";var Oe=\"SET_SELECTION_SUCCESS\";var We=r=>{switch(r){case\"TypeAheadRpcHandler\":return\"TYPEAHEAD\";default:return\"SIMUL\"}};var Ne=[],C=b(\"array-backed-moving-window\");function ct(r,e){if(!e||e.data.length!==r.data.length||e.sel!==r.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==r.data[t])return!1;return!0}var h,W=class{constructor({from:e,to:t},{from:n,to:s},o){ae(this,h,void 0);this.setRowCount=e=>{var t;if((t=C.info)==null||t.call(C,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let s=this.clientRange.from;s<n;s++){let o=s-m(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return m(this,h).to-t<n?!0:m(this,h).from>0&&e-m(this,h).from<n};this.bufferSize=o,this.clientRange=new I(e,t),ue(this,h,new I(n,s)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return m(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:s}=this.range;if(t<n||e>=s)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-m(this,h).from;if(ct(e,this.internalData[n]))return!1;let s=this.isWithinClientRange(t);return(s||this.isWithinRange(t))&&(!this.internalData[n]&&s&&(this.rowsWithinRange+=1),this.internalData[n]=e),s}getAtIndex(e){return m(this,h).isWithin(e)&&this.internalData[e-m(this,h).from]!=null?this.internalData[e-m(this,h).from]:void 0}isWithinRange(e){return m(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var p;(p=C.debug)==null||p.call(C,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,s=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===s)return[!1,Ne];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let a=e;a<t;a++){let c=a-m(this,h).from;this.internalData[c]&&(this.rowsWithinRange+=1)}let i=Ne,u=m(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let a=Math.max(e,o.to);i=this.internalData.slice(a-u,t-u)}else{let a=Math.min(o.from,t);i=this.internalData.slice(e-u,a-u)}return[this.bufferBreakout(e,t),i]}setRange(e,t){var n,s;if(e!==m(this,h).from||t!==m(this,h).to){(n=C.debug)==null||n.call(C,`setRange ${e} - ${t}`);let[o,i]=m(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let l=o;l<i;l++){let p=this.getAtIndex(l);if(p){let a=l-e;u[a]=p,this.isWithinClientRange(l)&&(this.rowsWithinRange+=1)}}this.internalData=u,m(this,h).from=e,m(this,h).to=t}else(s=C.debug)==null||s.call(C,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=m(this,h),{from:n,to:s}=this.clientRange,o=Math.max(0,n-e),i=Math.min(t-e,t,s-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,i)}clear(){var e;(e=C.debug)==null||e.call(C,\"clear\"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,s=this.internalData[t-1];if(n&&s)return[n.rowIndex,s.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){s=e[o];break}return n&&s?[n.rowIndex,s.rowIndex]:[-1,-1]}};h=new WeakMap;var{debug:f,debugEnabled:N,error:pt,info:d,infoEnabled:dt,warn:M}=b(\"viewport\"),gt=({rowKey:r,updateType:e})=>e===\"U\"&&!r.startsWith(\"$root\"),U=[void 0,void 0],ht={count:0,mode:void 0,size:0,ts:0},q=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:s,groupBy:o=[],table:i,range:u,sort:l,title:p,viewport:a,visualLink:c},g){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.useBatchMode=!0;this.lastUpdateStatus=ht;this.updateThrottleTimer=void 0;this.rangeMonitor=new x(\"ViewPort\");this.disabled=!1;this.isTree=!1;this.status=\"\";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,s=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,s=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,s=0;return this.lastUpdateStatus.mode=e,s};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:s}=e;for(let{from:o,to:i}of this.pendingRangeRequests)if(s>=o&&s<i){if(e.to+n<=i)return!0;s=i}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:\"size-only\",size:this.lastUpdateStatus.size,type:\"viewport-update\"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return e===\"size-only\"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(d==null||d(\"throttling updates setTimeout to 2000\"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=a,this.columns=n,this.filter=s,this.groupBy=o,this.keys=new k(u),this.pendingLinkedParent=c,this.table=i,this.sort=l,this.title=p,dt&&(d==null||d(`constructor #${a} ${i.table} bufferSize=${t}`)),this.dataWindow=new W(this.clientRange,u,this.bufferSize),this.postMessageToClient=g}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status===\"subscribed\"?\"resubscribing\":\"subscribing\",{type:Ee,table:this.table,range:G(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:s,range:o,sort:i,groupBy:u,table:l},p){this.serverViewportId=e,this.status=\"subscribed\",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to);let a=l===p.table.table?p:{...p,table:{...p.table,session:l}};return{aggregations:t,type:\"subscribed\",clientViewportId:this.clientViewportId,columns:n,filter:s,groupBy:u,range:o,sort:i,tableSchema:a}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:s}=this,o=s.get(e);if(!o){pt(`no matching operation found to complete for requestId ${e}`);return}let{type:i}=o;if(d==null||d(`completeOperation ${i}`),s.delete(e),i===\"CHANGE_VP_RANGE\"){let[l,p]=t;(u=this.dataWindow)==null||u.setRange(l,p);for(let a=this.pendingRangeRequests.length-1;a>=0;a--){let c=this.pendingRangeRequests[a];if(c.requestId===e){c.acked=!0;break}else M==null||M(\"range requests sent faster than they are being ACKed\")}}else if(i===\"config\"){let{aggregations:l,columns:p,filter:a,groupBy:c,sort:g}=o.data;return this.aggregations=l,this.columns=p,this.filter=a,this.groupBy=c,this.sort=g,c.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),f==null||f(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,config:o.data}}else{if(i===\"groupBy\")return this.isTree=o.data.length>0,this.groupBy=o.data,f==null||f(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,groupBy:o.data};if(i===\"columns\")return this.columns=o.data,{clientViewportId:n,type:i,columns:o.data};if(i===\"filter\")return this.filter=o.data,{clientViewportId:n,type:i,filter:o.data};if(i===\"aggregate\")return this.aggregations=o.data,{clientViewportId:n,type:\"aggregate\",aggregations:this.aggregations};if(i===\"sort\")return this.sort=o.data,{clientViewportId:n,type:i,sort:this.sort};if(i!==\"selection\"){if(i===\"disable\")return this.disabled=!0,{type:\"disabled\",clientViewportId:n};if(i===\"enable\")return this.disabled=!1,{type:\"enabled\",clientViewportId:n};if(i===\"CREATE_VISUAL_LINK\"){let[l,p,a]=t;return this.linkedParent={colName:l,parentViewportId:p,parentColName:a},this.pendingLinkedParent=void 0,{type:\"vuu-link-created\",clientViewportId:n,colName:l,parentViewportId:p,parentColName:a}}else if(i===\"REMOVE_VISUAL_LINK\")return this.linkedParent=void 0,{type:\"vuu-link-removed\",clientViewportId:n}}}}rangeRequest(e,t){N&&this.rangeMonitor.set(t);let n=\"CHANGE_VP_RANGE\";if(this.dataWindow){let[s,o]=this.dataWindow.setClientRange(t.from,t.to),i,u=this.dataWindow.rowCount||void 0,l=s&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...G(t,this.bufferSize,u)}:null;if(l){N&&(f==null||f(`create CHANGE_VP_RANGE: [${l.from} - ${l.to}]`)),this.awaitOperation(e,{type:n});let a=this.pendingRangeRequests.at(-1);if(a)if(a.acked)console.warn(\"Range Request before previous request is filled\");else{let{from:c,to:g}=a;this.dataWindow.outOfRange(c,g)?i={clientViewportId:this.clientViewportId,type:\"debounce-begin\"}:M==null||M(\"Range Request before previous request is acked\")}this.pendingRangeRequests.push({...l,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let p=this.isTree?j:J;return o.length?[l,o.map(a=>p(a,this.keys,this.selectedRows))]:i?[l,void 0,i]:[l]}else return[null]}setLinks(e){return this.links=e,[{type:\"vuu-links\",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:\"vuu-menu\",menu:e,clientViewportId:this.clientViewportId}}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Le,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:be,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,s){let o={type:\"CREATE_VISUAL_LINK\",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:s,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:\"REMOVE_VISUAL_LINK\",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,d==null||d(\"suspend\")}resume(){return this.suspended=!1,N&&(f==null||f(`resume: ${this.currentData()}`)),[this.size,this.currentData()]}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,s=this.isTree?j:J;for(let o of t)o&&e.push(s(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:\"enable\"}),d==null||d(`enable: ${this.serverViewportId}`),{type:Me,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:\"disable\"}),d==null||d(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Ve,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:\"columns\",data:t}),f==null||f(`columnRequest: ${t}`),this.createRequest({columns:t})}setConfig(e,t){var o;this.awaitOperation(e,{type:\"config\",data:t});let{filter:n,...s}=t;return this.useBatchMode&&(this.batchMode=!0),N?f==null||f(`setConfig ${JSON.stringify(t)}`):d==null||d(\"setConfig\"),!this.isTree&&t.groupBy.length>0&&((o=this.dataWindow)==null||o.clear()),this.createRequest({...s,filterSpec:typeof(n==null?void 0:n.filter)==\"string\"?{filter:n.filter}:{filter:\"\"}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:\"aggregate\",data:t}),d==null||d(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:\"sort\",data:t}),d==null||d(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:\"selection\",data:t}),d==null||d(`selectRequest: ${t}`),{type:\"SET_SELECTION\",vpId:this.serverViewportId,selection:he(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:s,to:o}=this.pendingRangeRequests[n],i=!0;if(e>=s&&e<o||t>s&&t<o){i||console.warn(\"removePendingRangeRequest TABLE_ROWS are not for latest request\"),this.pendingRangeRequests.splice(n,1);break}else i=!1}}updateRows(e){var s,o,i;let[t,n]=Re(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){f==null||f(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType===\"SIZE\"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&>(u)||((u.updateType===\"SIZE\"||((s=this.dataWindow)==null?void 0:s.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType===\"U\"&&(i=this.dataWindow)!=null&&i.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t=\"size-only\";if(!this.hasUpdates&&!this.rowCountChanged)return U;if(this.hasUpdates){let{keys:n,selectedRows:s}=this,o=this.isTree?j:J;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t=\"update\";for(let i of this.pendingUpdates)e.push(o(i,n,s));this.pendingUpdates.length=0}else{let i=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t=\"batch\";for(let u of i)e.push(o(u,n,s));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?U:[e,t]}createRequest(e,t=!1){return t?{type:\"CHANGE_VP\",viewPortId:this.serverViewportId,...e}:{type:\"CHANGE_VP\",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},J=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>[r,s.keyFor(r),!0,!1,0,0,e,t?H(o,r):0].concat(n),j=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>{let[i,u,,l,,p,...a]=n;return[r,s.keyFor(r),l,u,i,p,e,t?H(o,r):0].concat(a)};var Ue=1;var{debug:V,debugEnabled:Y,error:y,info:T,infoEnabled:ft,warn:Q}=b(\"server-proxy\"),R=()=>`${Ue++}`,mt={},Ct=r=>r.disabled!==!0&&r.suspended!==!0,Rt={type:\"NO_ACTION\"},St=(r,e,t)=>r.map(n=>n.parentVpId===e?{...n,label:t}:n);function Tt(r,e){return r.map(t=>{let{parentVpId:n}=t,s=e.get(n);if(s)return{...t,parentClientVpId:s.clientViewportId,label:s.title};throw Error(\"addLabelsToLinks viewport not found\")})}var F=class{constructor(e,t){this.authToken=\"\";this.user=\"user\";this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableMetaRequests=new Map;this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=le(Array.from(this.viewports.values()),Ct);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=s=>{s.forEach(o=>{let{clientViewportId:i}=o;this.viewports.set(i,o),this.sendMessageToServer(o.subscribe(),i)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t=\"user\"){if(e)return this.authToken=e,this.user=t,new Promise((n,s)=>{this.sendMessageToServer({type:Pe,token:this.authToken,user:t},\"\"),this.pendingLogin={resolve:n,reject:s}});this.authToken===\"\"&&y(\"login, cannot login until auth token has been obtained\")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))y(`spurious subscribe call ${e.viewport}`);else{let t=this.getTableMeta(e.table),n=new q(e,this.postMessageToClient);this.viewports.set(e.viewport,n);let s=this.awaitResponseToMessage(n.subscribe(),e.viewport);Promise.all([s,t]).then(([i,u])=>{let{viewPortId:l}=i,{status:p}=n;e.viewport!==l&&(this.viewports.delete(e.viewport),this.viewports.set(l,n)),this.mapClientToServerViewport.set(e.viewport,l);let a=n.handleSubscribed(i,u);a&&(this.postMessageToClient(a),Y&&V(`post DataSourceSubscribedMessage to client: ${JSON.stringify(a)}`)),n.disabled&&this.disableViewport(n),this.queuedRequests.length>0&&this.processQueuedRequests(),p===\"subscribing\"&&!O(n.table)&&(this.sendMessageToServer({type:K,vpId:l}),this.sendMessageToServer({type:_e,vpId:l}),Array.from(this.viewports.entries()).filter(([c,{disabled:g}])=>c!==l&&!g).forEach(([c])=>{this.sendMessageToServer({type:K,vpId:c})}))})}}processQueuedRequests(){let e={};for(;this.queuedRequests.length;){let t=this.queuedRequests.pop();if(t){let{clientViewportId:n,message:s,requestId:o}=t;if(s.type===\"CHANGE_VP_RANGE\"){if(e.CHANGE_VP_RANGE)continue;e.CHANGE_VP_RANGE=!0;let i=this.mapClientToServerViewport.get(n);i&&this.sendMessageToServer({...s,viewPortId:i},o)}}}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(T==null||T(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:ke,viewPortId:t})):y(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let s=this.viewports.get(n);if(s)return s;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=R(),[s,o,i]=e.rangeRequest(n,t.range);T==null||T(`setViewRange ${t.range.from} - ${t.range.to}`),s&&(this.sendIfReady(s,n,e.status===\"subscribed\")||this.queuedRequests.push({clientViewportId:t.viewport,message:s,requestId:n})),o?(T==null||T(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:\"batch\",type:\"viewport-update\",clientViewportId:e.clientViewportId,rows:o})):i&&this.postMessageToClient(i)}setConfig(e,t){let n=R(),s=e.setConfig(n,t.config);this.sendIfReady(s,n,e.status===\"subscribed\")}aggregate(e,t){let n=R(),s=e.aggregateRequest(n,t.aggregations);this.sendIfReady(s,n,e.status===\"subscribed\")}sort(e,t){let n=R(),s=e.sortRequest(n,t.sort);this.sendIfReady(s,n,e.status===\"subscribed\")}setColumns(e,t){let n=R(),{columns:s}=t,o=e.columnRequest(n,s);this.sendIfReady(o,n,e.status===\"subscribed\")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=R(),{selected:s}=t,o=e.selectRequest(n,s);this.sendIfReady(o,n,e.status===\"subscribed\")}disableViewport(e){let t=R(),n=e.disable(t);this.sendIfReady(n,t,e.status===\"subscribed\")}enableViewport(e){if(e.disabled){let t=R(),n=e.enable(t);this.sendIfReady(n,t,e.status===\"subscribed\")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{T==null||T(\"suspendTimer expired, escalate suspend to disable\"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(V==null||V(\"clear suspend timer\"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let[t,n]=e.resume();V==null||V(`resumeViewport size ${t}, ${n.length} rows sent to client`),this.postMessageToClient({clientViewportId:e.clientViewportId,mode:\"batch\",rows:n,size:t,type:\"viewport-update\"})}openTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.openTreeNode(n,t),n,e.status===\"subscribed\")}}closeTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.closeTreeNode(n,t),n,e.status===\"subscribed\")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:s,childColumnName:o}=t,i=R(),u=this.mapClientToServerViewport.get(n);if(u){let l=e.createLink(i,o,u,s);this.sendMessageToServer(l,i)}else y(\"ServerProxy unable to create link, viewport not found\")}removeLink(e){let t=R(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var s;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(s=o.links)!=null&&s.some(i=>i.parentVpId===t)){let[i]=o.setLinks(St(o.links,t,n));this.postMessageToClient(i)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:s})=>s===e)){let[s]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(s)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId},n)}}viewportRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId,namedParams:{}},n)}}rpcCall(e){let[t,n]=A(e),s=We(n.service);this.sendMessageToServer(n,t,{module:s})}handleMessageFromClient(e){var t;if(ge(e))if(e.type===\"disable\"){let n=this.getViewportForClient(e.viewport,!1);return n!==null?this.disableViewport(n):void 0}else{let n=this.getViewportForClient(e.viewport);switch(e.type){case\"setViewRange\":return this.setViewRange(n,e);case\"config\":return this.setConfig(n,e);case\"aggregate\":return this.aggregate(n,e);case\"sort\":return this.sort(n,e);case\"select\":return this.select(n,e);case\"suspend\":return this.suspendViewport(n);case\"resume\":return this.resumeViewport(n);case\"enable\":return this.enableViewport(n);case\"openTreeNode\":return this.openTreeNode(n,e);case\"closeTreeNode\":return this.closeTreeNode(n,e);case\"createLink\":return this.createLink(n,e);case\"removeLink\":return this.removeLink(n);case\"setColumns\":return this.setColumns(n,e);case\"setTitle\":return this.setTitle(n,e);default:}}else{if(Ce(e))return this.viewportRpcCall(e);if(me(e))return this.menuRpcCall(e);{let{type:n,requestId:s}=e;switch(n){case\"GET_TABLE_LIST\":{(t=this.tableList)!=null||(this.tableList=this.awaitResponseToMessage({type:n},s)),this.tableList.then(o=>{this.postMessageToClient({type:\"TABLE_LIST_RESP\",tables:o.tables,requestId:s})});return}case\"GET_TABLE_META\":{this.getTableMeta(e.table,s).then(o=>{o&&this.postMessageToClient({type:\"TABLE_META_RESP\",tableSchema:o,requestId:s})});return}case\"RPC_CALL\":return this.rpcCall(e);default:}}}y(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}getTableMeta(e,t=R()){if(O(e))return Promise.resolve(void 0);let n=`${e.module}:${e.table}`,s=this.cachedTableMetaRequests.get(n);return s||(s=this.awaitResponseToMessage({type:\"GET_TABLE_META\",table:e},t),this.cachedTableMetaRequests.set(n,s)),s==null?void 0:s.then(o=>this.cacheTableMeta(o))}awaitResponseToMessage(e,t=R()){return new Promise((n,s)=>{this.sendMessageToServer(e,t),this.pendingRequests.set(t,{reject:s,resolve:n})})}sendIfReady(e,t,n=!0){return n&&this.sendMessageToServer(e,t),n}sendMessageToServer(e,t=`${Ue++}`,n=mt){let{module:s=\"CORE\"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:s,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:s}=e,o=this.pendingRequests.get(n);if(o){let{resolve:a}=o;this.pendingRequests.delete(n),a(t);return}let{viewports:i}=this;switch(t.type){case De:this.sendMessageToServer({type:Ie,ts:+new Date},\"NA\");break;case\"LOGIN_SUCCESS\":if(s)this.sessionId=s,(u=this.pendingLogin)==null||u.resolve(s),this.pendingLogin=void 0;else throw Error(\"LOGIN_SUCCESS did not provide sessionId\");break;case\"REMOVE_VP_SUCCESS\":{let a=i.get(t.viewPortId);a&&(this.mapClientToServerViewport.delete(a.clientViewportId),i.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case Oe:{let a=this.viewports.get(t.vpId);a&&a.completeOperation(n)}break;case Te:case ve:if(i.has(t.viewPortId)){let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);c!==void 0&&(this.postMessageToClient(c),Y&&V(`postMessageToClient ${JSON.stringify(c)}`))}}break;case ye:{let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);if(c){this.postMessageToClient(c);let[g,S]=a.resume();this.postMessageToClient({clientViewportId:a.clientViewportId,mode:\"batch\",rows:S,size:g,type:\"viewport-update\"})}}}break;case\"TABLE_ROW\":{let a=Se(t.rows);for(let[c,g]of Object.entries(a)){let S=i.get(c);S?S.updateRows(g):Q==null||Q(`TABLE_ROW message received for non registered viewport ${c}`)}this.processUpdates()}break;case\"CHANGE_VP_RANGE_SUCCESS\":{let a=this.viewports.get(t.viewPortId);if(a){let{from:c,to:g}=t;a.completeOperation(n,c,g)}}break;case xe:case we:break;case\"CREATE_VISUAL_LINK_SUCCESS\":{let a=this.viewports.get(t.childVpId),c=this.viewports.get(t.parentVpId);if(a&&c){let{childColumnName:g,parentColumnName:S}=t,D=a.completeOperation(n,g,c.clientViewportId,S);D&&this.postMessageToClient(D)}}break;case\"REMOVE_VISUAL_LINK_SUCCESS\":{let a=this.viewports.get(t.childVpId);if(a){let c=a.completeOperation(n);c&&this.postMessageToClient(c)}}break;case\"VP_VISUAL_LINKS_RESP\":{let a=this.getActiveLinks(t.links),c=this.viewports.get(t.vpId);if(a.length&&c){let g=Tt(a,this.viewports),[S,D]=c.setLinks(g);if(this.postMessageToClient(S),D){let{link:se,parentClientVpId:ze}=D,re=R(),oe=this.mapClientToServerViewport.get(ze);if(oe){let Ke=c.createLink(re,se.fromColumn,oe,se.toColumn);this.sendMessageToServer(Ke,re)}}}}break;case\"VIEW_PORT_MENUS_RESP\":if(t.menu.name){let a=this.viewports.get(t.vpId);if(a){let c=a.setMenu(t.menu);this.postMessageToClient(c)}}break;case\"VP_EDIT_RPC_RESPONSE\":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:\"VP_EDIT_RPC_RESPONSE\"});break;case\"VP_EDIT_RPC_REJECT\":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:\"VP_EDIT_RPC_REJECT\",error:t.error});break;case\"VIEW_PORT_MENU_REJ\":{console.log(\"send menu error back to client\");let{error:a,rpcName:c,vpId:g}=t,S=this.viewports.get(g);S&&this.postMessageToClient({clientViewportId:S.clientViewportId,error:a,rpcName:c,type:\"VIEW_PORT_MENU_REJ\",requestId:n});break}case\"VIEW_PORT_MENU_RESP\":if(fe(t)){let{action:a,rpcName:c}=t;this.awaitResponseToMessage({type:\"GET_TABLE_META\",table:a.table}).then(g=>{let S=z(g);this.postMessageToClient({rpcName:c,type:\"VIEW_PORT_MENU_RESP\",action:{...a,tableSchema:S},tableAlreadyOpen:this.isTableOpen(a.table),requestId:n})})}else{let{action:a}=t;this.postMessageToClient({type:\"VIEW_PORT_MENU_RESP\",action:a||Rt,tableAlreadyOpen:a!==null&&this.isTableOpen(a.table),requestId:n})}break;case\"RPC_RESP\":{let{method:a,result:c}=t;this.postMessageToClient({type:\"RPC_RESP\",method:a,result:c,requestId:n})}break;case\"VIEW_PORT_RPC_REPONSE\":{let{method:a,action:c}=t;this.postMessageToClient({type:\"VIEW_PORT_RPC_RESPONSE\",rpcName:a,action:c,requestId:n})}break;case\"ERROR\":y(t.msg);break;default:ft&&T(`handleMessageFromServer ${t.type}.`)}}cacheTableMeta(e){let{module:t,table:n}=e.table,s=`${t}:${n}`,o=this.cachedTableSchemas.get(s);return o||(o=z(e),this.cachedTableSchemas.set(s,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==U){let[s,o]=n,i=e.getNewRowCount();(i!==void 0||s&&s.length>0)&&(Y&&V(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=s==null?void 0:s.length)!=null?t:\"no\"} rows, size ${i}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:s,size:i,type:\"viewport-update\"}))}}})}};var{debug:un,debugEnabled:ln,error:qe,info:w,infoEnabled:bt,warn:_}=b(\"websocket-connection\"),Be={},Z=Symbol(\"setWebsocket\"),$=Symbol(\"connectionCallback\");async function Ge(r,e,t,n=10,s=5){return Be[r]={status:\"connecting\",connect:{allowed:s,remaining:s},reconnect:{allowed:n,remaining:n}},He(r,e,t)}async function X(r){throw Error(\"connection broken\")}async function He(r,e,t,n){let{status:s,connect:o,reconnect:i}=Be[r],u=s===\"connecting\"?o:i;try{t({type:\"connection-status\",status:\"connecting\"});let l=typeof n<\"u\",p=await Et(r,e);console.info(\"%c⚡ %cconnected\",\"font-size: 24px;color: green;font-weight: bold;\",\"color:green; font-size: 14px;\"),n!==void 0&&n[Z](p);let a=n!=null?n:new ee(p,r,e,t),c=l?\"reconnected\":\"connection-open-awaiting-session\";return t({type:\"connection-status\",status:c}),a.status=c,u.remaining=u.allowed,a}catch{let p=--u.remaining>0;if(t({type:\"connection-status\",status:\"disconnected\",reason:\"failed to connect\",retry:p}),p)return wt(r,e,t,n,2e3);throw t({type:\"connection-status\",status:\"failed\",reason:\"unable to connect\",retry:p}),Error(\"Failed to establish connection\")}}var wt=(r,e,t,n,s)=>new Promise(o=>{setTimeout(()=>{o(He(r,e,t,n))},s)}),Et=(r,e)=>new Promise((t,n)=>{bt&&e!==void 0&&w(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let s=new WebSocket(r,e);s.onopen=()=>t(s),s.onerror=o=>n(o)}),Fe=()=>{_==null||_(\"Connection cannot be closed, socket not yet opened\")},$e=r=>{_==null||_(`Message cannot be sent, socket closed ${r.body.type}`)},Vt=r=>{try{return JSON.parse(r)}catch{throw Error(`Error parsing JSON response from server ${r}`)}},ee=class{constructor(e,t,n,s){this.close=Fe;this.requiresLogin=!0;this.send=$e;this.status=\"ready\";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Vt(e.data);this.messagesCount+=1,this[$](t)};this.url=t,this.protocol=n,this[$]=s,this[Z](e)}reconnect(){X(this)}[($,Z)](e){let t=this[$];e.onmessage=o=>{this.status=\"connected\",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:\"connection-metrics\",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{qe(\"⚡ connection error\"),t({type:\"connection-status\",status:\"disconnected\",reason:\"error\"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status===\"connection-open-awaiting-session\"?qe(\"Websocket connection lost before Vuu session established, check websocket configuration\"):this.status!==\"closed\"&&(X(this),this.send=s)},e.onclose=()=>{w==null||w(\"⚡ connection close\"),t({type:\"connection-status\",status:\"disconnected\",reason:\"close\"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!==\"closed\"&&(X(this),this.send=s)};let n=o=>{e.send(JSON.stringify(o))},s=o=>{w==null||w(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status=\"closed\",e.close(),this.close=Fe,this.send=$e,w==null||w(\"close websocket\")}}};var v,{info:te,infoEnabled:ne}=b(\"worker\");async function vt(r,e,t,n,s,o,i){let u=await Ge(r,e,l=>{de(l)?postMessage({type:\"connection-metrics\",messages:l}):pe(l)?(s(l),l.status===\"reconnected\"&&v.reconnect()):v.handleMessageFromServer(l)},o,i);v=new F(u,l=>Mt(l)),u.requiresLogin&&await v.login(t,n)}function Mt(r){postMessage(r)}var yt=async({data:r})=>{switch(r.type){case\"connect\":try{await vt(r.url,r.protocol,r.token,r.username,postMessage,r.retryLimitDisconnect,r.retryLimitStartup),postMessage({type:\"connected\"})}catch(e){postMessage({type:\"connection-failed\",reason:String(e)})}break;case\"subscribe\":ne&&te(`client subscribe: ${JSON.stringify(r)}`),v.subscribe(r);break;case\"unsubscribe\":ne&&te(`client unsubscribe: ${JSON.stringify(r)}`),v.unsubscribe(r.viewport);break;default:ne&&te(`client message: ${JSON.stringify(r)}`),v.handleMessageFromClient(r)}};self.addEventListener(\"message\",yt);postMessage({type:\"ready\"});\n\n";
|
|
1
|
+
export const workerSourceCode: "\nvar ie=(r,e,t)=>{if(!e.has(r))throw TypeError(\"Cannot \"+t)};var m=(r,e,t)=>(ie(r,e,\"read from private field\"),t?t.call(r):e.get(r)),ae=(r,e,t)=>{if(e.has(r))throw TypeError(\"Cannot add the same private member more than once\");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,n)=>(ie(r,e,\"write to private field\"),n?n.call(r,t):e.set(r,t),t);function le(r,e,t=[],n=[]){for(let s=0,o=r.length;s<o;s++)(e(r[s],s)?t:n).push(r[s]);return[t,n]}var Je=6,B={IDX:0,RENDER_IDX:1,IS_LEAF:2,IS_EXPANDED:3,DEPTH:4,COUNT:5,KEY:Je,SELECTED:7,count:8,PARENT_IDX:\"parent_idx\",IDX_POINTER:\"idx_pointer\",FILTER_COUNT:\"filter_count\",NEXT_FILTER_IDX:\"next_filter_idx\"};var{DEPTH:It,IS_LEAF:Pt}=B;var ce=r=>{var e,t;if(((e=globalThis.document)==null?void 0:e.cookie)!==void 0)return(t=globalThis.document.cookie.split(\"; \").find(n=>n.startsWith(`${r}=`)))==null?void 0:t.split(\"=\")[1]};function G({from:r,to:e},t=0,n=Number.MAX_SAFE_INTEGER){if(r===0&&e===0)return{from:r,to:e};if(t===0)return n<r?{from:0,to:0}:{from:r,to:Math.min(e,n)};if(r===0)return{from:r,to:Math.min(e+t,n)};{let s=r-t<0,o=n-(e+t)<0;return s&&o?{from:0,to:n}:s?{from:0,to:e+t}:o?{from:Math.max(0,r-t),to:n}:{from:r-t,to:e+t}}}var je=(r,{from:e,to:t})=>r>=e&&r<t;var I=class r{constructor(e,t){this.from=e,this.to=t}isWithin(e){return je(e,this)}overlap(e,t){return e>=this.to||t<this.from?[0,0]:[Math.max(e,this.from),Math.min(t,this.to)]}copy(){return new r(this.from,this.to)}};var pe=r=>r.type===\"connection-status\",de=r=>r.type===\"connection-metrics\";var ge=r=>\"viewport\"in r;var Ye=[\"error\",\"warn\",\"info\",\"debug\"],Qe=r=>typeof r==\"string\"&&Ye.includes(r),Xe=\"error\",P=()=>{},Ze=\"error\",{loggingLevel:L=Ze}=et(),b=r=>{let e=L===\"debug\",t=e||L===\"info\",n=t||L===\"warn\",s=n||L===\"error\",o=t?p=>console.info(`[${r}] ${p}`):P,i=n?p=>console.warn(`[${r}] ${p}`):P,u=e?p=>console.debug(`[${r}] ${p}`):P;return{errorEnabled:s,error:s?p=>console.error(`[${r}] ${p}`):P}};function et(){return typeof loggingSettings<\"u\"?loggingSettings:{loggingLevel:tt()}}function tt(){let r=ce(\"vuu-logging-level\");return Qe(r)?r:Xe}var{debug:nt,debugEnabled:st}=b(\"range-monitor\"),k=class{constructor(e){this.source=e;this.range={from:0,to:0};this.timestamp=0}isSet(){return this.timestamp!==0}set({from:e,to:t}){let{timestamp:n}=this;if(this.range.from=e,this.range.to=t,this.timestamp=performance.now(),n)st&&nt(`<${this.source}> [${e}-${t}], ${(this.timestamp-n).toFixed(0)} ms elapsed`);else return 0}};var rt=[],x=class{constructor(e){this.keys=new Map;this.nextKeyValue=0;this.range=e,this.init(e)}next(e=rt){return e.length>0?e.shift():this.nextKeyValue++}init({from:e,to:t}){this.keys.clear(),this.nextKeyValue=0;for(let n=e;n<t;n++){let s=this.next();this.keys.set(n,s)}return!0}reset(e){let{from:t,to:n}=e,s=n-t,o=this.range.to-this.range.from;if(this.range=e,o>s)return this.init(e);let i=[];this.keys.forEach((u,l)=>{(l<t||l>=n)&&(i.push(u),this.keys.delete(l))});for(let u=t;u<n;u++)if(!this.keys.has(u)){let l=this.next(i);this.keys.set(u,l)}return!1}keyFor(e){let t=this.keys.get(e);if(t===void 0)throw console.log(`key not found\n keys: ${this.toDebugString()}\n `),Error(`KeySet, no key found for rowIndex ${e}`);return t}toDebugString(){return`${this.keys.size} keys\n${Array.from(this.keys.entries()).sort(([e],[t])=>e-t).map(([e,t])=>`${e}=>${t}`).join(\",\")}]\n`}};var{SELECTED:Ft}=B,E={False:0,True:1,First:2,Last:4};var ot=(r,e)=>e>=r[0]&&e<=r[1],it=E.True+E.First+E.Last,at=E.True+E.First,ut=E.True+E.Last,H=(r,e)=>{for(let t of r)if(typeof t==\"number\"){if(t===e)return it}else if(ot(t,e))return e===t[0]?at:e===t[1]?ut:E.True;return E.False};var he=r=>{if(r.every(t=>typeof t==\"number\"))return r;let e=[];for(let t of r)if(typeof t==\"number\")e.push(t);else for(let n=t[0];n<=t[1];n++)e.push(n);return e};var fe=r=>r.type===\"VIEW_PORT_MENU_RESP\"&&r.action!==null&&O(r.action.table),O=r=>r!==null&&typeof r==\"object\"&&\"table\"in r&&\"module\"in r?r.table.startsWith(\"session\"):!1;var lt=[\"VIEW_PORT_MENUS_SELECT_RPC\",\"VIEW_PORT_MENU_TABLE_RPC\",\"VIEW_PORT_MENU_ROW_RPC\",\"VIEW_PORT_MENU_CELL_RPC\",\"VP_EDIT_CELL_RPC\",\"VP_EDIT_ROW_RPC\",\"VP_EDIT_ADD_ROW_RPC\",\"VP_EDIT_DELETE_CELL_RPC\",\"VP_EDIT_DELETE_ROW_RPC\",\"VP_EDIT_SUBMIT_FORM_RPC\"],me=r=>lt.includes(r.type),Ce=r=>r.type===\"VIEW_PORT_RPC_CALL\",A=({requestId:r,...e})=>[r,e],Re=r=>{let e=r.at(0);if(e.updateType===\"SIZE\"){if(r.length===1)return r;e=r.at(1)}let t=r.at(-1);return[e,t]},Se=r=>{let e={};for(let t of r)(e[t.viewPortId]||(e[t.viewPortId]=[])).push(t);return e},z=({columns:r,dataTypes:e,key:t,table:n})=>({table:n,columns:r.map((s,o)=>({name:s,serverDataType:e[o]})),key:t});var Te=\"CHANGE_VP_SUCCESS\";var be=\"CLOSE_TREE_NODE\",we=\"CLOSE_TREE_SUCCESS\";var Ee=\"CREATE_VP\",Ve=\"DISABLE_VP\",ve=\"DISABLE_VP_SUCCESS\";var Me=\"ENABLE_VP\",ye=\"ENABLE_VP_SUCCESS\";var K=\"GET_VP_VISUAL_LINKS\",_e=\"GET_VIEW_PORT_MENUS\";var De=\"HB\",Ie=\"HB_RESP\",Pe=\"LOGIN\",Le=\"OPEN_TREE_NODE\",ke=\"OPEN_TREE_SUCCESS\";var xe=\"REMOVE_VP\";var Oe=\"SET_SELECTION_SUCCESS\";var We=r=>{switch(r){case\"TypeAheadRpcHandler\":return\"TYPEAHEAD\";default:return\"SIMUL\"}};var Ne=[],C=b(\"array-backed-moving-window\");function ct(r,e){if(!e||e.data.length!==r.data.length||e.sel!==r.sel)return!1;for(let t=0;t<e.data.length;t++)if(e.data[t]!==r.data[t])return!1;return!0}var h,W=class{constructor({from:e,to:t},{from:n,to:s},o){ae(this,h,void 0);this.setRowCount=e=>{var t;if((t=C.info)==null||t.call(C,`setRowCount ${e}`),e<this.internalData.length&&(this.internalData.length=e),e<this.rowCount){this.rowsWithinRange=0;let n=Math.min(e,this.clientRange.to);for(let s=this.clientRange.from;s<n;s++){let o=s-m(this,h).from;this.internalData[o]!==void 0&&(this.rowsWithinRange+=1)}}this.rowCount=e};this.bufferBreakout=(e,t)=>{let n=this.bufferSize*.25;return m(this,h).to-t<n?!0:m(this,h).from>0&&e-m(this,h).from<n};this.bufferSize=o,this.clientRange=new I(e,t),ue(this,h,new I(n,s)),this.internalData=new Array(o),this.rowsWithinRange=0,this.rowCount=0}get range(){return m(this,h)}get hasAllRowsWithinRange(){return this.rowsWithinRange===this.clientRange.to-this.clientRange.from||this.rowCount>0&&this.clientRange.from+this.rowsWithinRange===this.rowCount}outOfRange(e,t){let{from:n,to:s}=this.range;if(t<n||e>=s)return!0}setAtIndex(e){let{rowIndex:t}=e,n=t-m(this,h).from;if(ct(e,this.internalData[n]))return!1;let s=this.isWithinClientRange(t);return(s||this.isWithinRange(t))&&(!this.internalData[n]&&s&&(this.rowsWithinRange+=1),this.internalData[n]=e),s}getAtIndex(e){return m(this,h).isWithin(e)&&this.internalData[e-m(this,h).from]!=null?this.internalData[e-m(this,h).from]:void 0}isWithinRange(e){return m(this,h).isWithin(e)}isWithinClientRange(e){return this.clientRange.isWithin(e)}setClientRange(e,t){var p;(p=C.debug)==null||p.call(C,`setClientRange ${e} - ${t}`);let n=this.clientRange.from,s=Math.min(this.clientRange.to,this.rowCount);if(e===n&&t===s)return[!1,Ne];let o=this.clientRange.copy();this.clientRange.from=e,this.clientRange.to=t,this.rowsWithinRange=0;for(let a=e;a<t;a++){let c=a-m(this,h).from;this.internalData[c]&&(this.rowsWithinRange+=1)}let i=Ne,u=m(this,h).from;if(this.hasAllRowsWithinRange)if(t>o.to){let a=Math.max(e,o.to);i=this.internalData.slice(a-u,t-u)}else{let a=Math.min(o.from,t);i=this.internalData.slice(e-u,a-u)}return[this.bufferBreakout(e,t),i]}setRange(e,t){var n,s;if(e!==m(this,h).from||t!==m(this,h).to){(n=C.debug)==null||n.call(C,`setRange ${e} - ${t}`);let[o,i]=m(this,h).overlap(e,t),u=new Array(t-e);this.rowsWithinRange=0;for(let l=o;l<i;l++){let p=this.getAtIndex(l);if(p){let a=l-e;u[a]=p,this.isWithinClientRange(l)&&(this.rowsWithinRange+=1)}}this.internalData=u,m(this,h).from=e,m(this,h).to=t}else(s=C.debug)==null||s.call(C,`setRange ${e} - ${t} IGNORED because not changed`)}get data(){return this.internalData}getData(){var u;let{from:e,to:t}=m(this,h),{from:n,to:s}=this.clientRange,o=Math.max(0,n-e),i=Math.min(t-e,t,s-e,(u=this.rowCount)!=null?u:t);return this.internalData.slice(o,i)}clear(){var e;(e=C.debug)==null||e.call(C,\"clear\"),this.internalData.length=0,this.rowsWithinRange=0,this.setRowCount(0)}getCurrentDataRange(){let e=this.internalData,t=e.length,[n]=this.internalData,s=this.internalData[t-1];if(n&&s)return[n.rowIndex,s.rowIndex];for(let o=0;o<t;o++)if(e[o]!==void 0){n=e[o];break}for(let o=t-1;o>=0;o--)if(e[o]!==void 0){s=e[o];break}return n&&s?[n.rowIndex,s.rowIndex]:[-1,-1]}};h=new WeakMap;var{debug:f,debugEnabled:N,error:pt,info:d,infoEnabled:dt,warn:M}=b(\"viewport\"),gt=({rowKey:r,updateType:e})=>e===\"U\"&&!r.startsWith(\"$root\"),U=[void 0,void 0],ht={count:0,mode:void 0,size:0,ts:0},q=class{constructor({aggregations:e,bufferSize:t=50,columns:n,filter:s,groupBy:o=[],table:i,range:u,sort:l,title:p,viewport:a,visualLink:c},g){this.batchMode=!0;this.hasUpdates=!1;this.pendingUpdates=[];this.pendingOperations=new Map;this.pendingRangeRequests=[];this.rowCountChanged=!1;this.selectedRows=[];this.useBatchMode=!0;this.lastUpdateStatus=ht;this.updateThrottleTimer=void 0;this.rangeMonitor=new k(\"ViewPort\");this.disabled=!1;this.isTree=!1;this.status=\"\";this.suspended=!1;this.suspendTimer=null;this.setLastSizeOnlyUpdateSize=e=>{this.lastUpdateStatus.size=e};this.setLastUpdate=e=>{let{ts:t,mode:n}=this.lastUpdateStatus,s=0;if(n===e){let o=Date.now();this.lastUpdateStatus.count+=1,this.lastUpdateStatus.ts=o,s=t===0?0:o-t}else this.lastUpdateStatus.count=1,this.lastUpdateStatus.ts=0,s=0;return this.lastUpdateStatus.mode=e,s};this.rangeRequestAlreadyPending=e=>{let{bufferSize:t}=this,n=t*.25,{from:s}=e;for(let{from:o,to:i}of this.pendingRangeRequests)if(s>=o&&s<i){if(e.to+n<=i)return!0;s=i}return!1};this.sendThrottledSizeMessage=()=>{this.updateThrottleTimer=void 0,this.lastUpdateStatus.count=3,this.postMessageToClient({clientViewportId:this.clientViewportId,mode:\"size-only\",size:this.lastUpdateStatus.size,type:\"viewport-update\"})};this.shouldThrottleMessage=e=>{let t=this.setLastUpdate(e);return e===\"size-only\"&&t>0&&t<500&&this.lastUpdateStatus.count>3};this.throttleMessage=e=>this.shouldThrottleMessage(e)?(d==null||d(\"throttling updates setTimeout to 2000\"),this.updateThrottleTimer===void 0&&(this.updateThrottleTimer=setTimeout(this.sendThrottledSizeMessage,2e3)),!0):(this.updateThrottleTimer!==void 0&&(clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),!1);this.getNewRowCount=()=>{if(this.rowCountChanged&&this.dataWindow)return this.rowCountChanged=!1,this.dataWindow.rowCount};this.aggregations=e,this.bufferSize=t,this.clientRange=u,this.clientViewportId=a,this.columns=n,this.filter=s,this.groupBy=o,this.keys=new x(u),this.pendingLinkedParent=c,this.table=i,this.sort=l,this.title=p,dt&&(d==null||d(`constructor #${a} ${i.table} bufferSize=${t}`)),this.dataWindow=new W(this.clientRange,u,this.bufferSize),this.postMessageToClient=g}get hasUpdatesToProcess(){return this.suspended?!1:this.rowCountChanged||this.hasUpdates}get size(){var e;return(e=this.dataWindow.rowCount)!=null?e:0}subscribe(){let{filter:e}=this.filter;return this.status=this.status===\"subscribed\"?\"resubscribing\":\"subscribing\",{type:Ee,table:this.table,range:G(this.clientRange,this.bufferSize),aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:e}}}handleSubscribed({viewPortId:e,aggregations:t,columns:n,filterSpec:s,range:o,sort:i,groupBy:u,table:l},p){this.serverViewportId=e,this.status=\"subscribed\",this.aggregations=t,this.columns=n,this.groupBy=u,this.isTree=u&&u.length>0,this.dataWindow.setRange(o.from,o.to);let a=l===p.table.table?p:{...p,table:{...p.table,session:l}};return{aggregations:t,type:\"subscribed\",clientViewportId:this.clientViewportId,columns:n,filter:s,groupBy:u,range:o,sort:i,tableSchema:a}}awaitOperation(e,t){this.pendingOperations.set(e,t)}completeOperation(e,...t){var u;let{clientViewportId:n,pendingOperations:s}=this,o=s.get(e);if(!o){pt(`no matching operation found to complete for requestId ${e}`);return}let{type:i}=o;if(d==null||d(`completeOperation ${i}`),s.delete(e),i===\"CHANGE_VP_RANGE\"){let[l,p]=t;(u=this.dataWindow)==null||u.setRange(l,p);for(let a=this.pendingRangeRequests.length-1;a>=0;a--){let c=this.pendingRangeRequests[a];if(c.requestId===e){c.acked=!0;break}else M==null||M(\"range requests sent faster than they are being ACKed\")}}else if(i===\"config\"){let{aggregations:l,columns:p,filter:a,groupBy:c,sort:g}=o.data;return this.aggregations=l,this.columns=p,this.filter=a,this.groupBy=c,this.sort=g,c.length>0?this.isTree=!0:this.isTree&&(this.isTree=!1),f==null||f(`config change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,config:o.data}}else{if(i===\"groupBy\")return this.isTree=o.data.length>0,this.groupBy=o.data,f==null||f(`groupBy change confirmed, isTree : ${this.isTree}`),{clientViewportId:n,type:i,groupBy:o.data};if(i===\"columns\")return this.columns=o.data,{clientViewportId:n,type:i,columns:o.data};if(i===\"filter\")return this.filter=o.data,{clientViewportId:n,type:i,filter:o.data};if(i===\"aggregate\")return this.aggregations=o.data,{clientViewportId:n,type:\"aggregate\",aggregations:this.aggregations};if(i===\"sort\")return this.sort=o.data,{clientViewportId:n,type:i,sort:this.sort};if(i!==\"selection\"){if(i===\"disable\")return this.disabled=!0,{type:\"disabled\",clientViewportId:n};if(i===\"enable\")return this.disabled=!1,{type:\"enabled\",clientViewportId:n};if(i===\"CREATE_VISUAL_LINK\"){let[l,p,a]=t;return this.linkedParent={colName:l,parentViewportId:p,parentColName:a},this.pendingLinkedParent=void 0,{type:\"vuu-link-created\",clientViewportId:n,colName:l,parentViewportId:p,parentColName:a}}else if(i===\"REMOVE_VISUAL_LINK\")return this.linkedParent=void 0,{type:\"vuu-link-removed\",clientViewportId:n}}}}rangeRequest(e,t){N&&this.rangeMonitor.set(t);let n=\"CHANGE_VP_RANGE\";if(this.dataWindow){let[s,o]=this.dataWindow.setClientRange(t.from,t.to),i,u=this.dataWindow.rowCount||void 0,l=s&&!this.rangeRequestAlreadyPending(t)?{type:n,viewPortId:this.serverViewportId,...G(t,this.bufferSize,u)}:null;if(l){N&&(f==null||f(`create CHANGE_VP_RANGE: [${l.from} - ${l.to}]`)),this.awaitOperation(e,{type:n});let a=this.pendingRangeRequests.at(-1);if(a)if(a.acked)console.warn(\"Range Request before previous request is filled\");else{let{from:c,to:g}=a;this.dataWindow.outOfRange(c,g)?i={clientViewportId:this.clientViewportId,type:\"debounce-begin\"}:M==null||M(\"Range Request before previous request is acked\")}this.pendingRangeRequests.push({...l,requestId:e}),this.useBatchMode&&(this.batchMode=!0)}else o.length>0&&(this.batchMode=!1);this.keys.reset(this.dataWindow.clientRange);let p=this.isTree?j:J;return o.length?[l,o.map(a=>p(a,this.keys,this.selectedRows))]:i?[l,void 0,i]:[l]}else return[null]}setLinks(e){return this.links=e,[{type:\"vuu-links\",links:e,clientViewportId:this.clientViewportId},this.pendingLinkedParent]}setMenu(e){return{type:\"vuu-menu\",menu:e,clientViewportId:this.clientViewportId}}openTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:Le,vpId:this.serverViewportId,treeKey:t.key}}closeTreeNode(e,t){return this.useBatchMode&&(this.batchMode=!0),{type:be,vpId:this.serverViewportId,treeKey:t.key}}createLink(e,t,n,s){let o={type:\"CREATE_VISUAL_LINK\",parentVpId:n,childVpId:this.serverViewportId,parentColumnName:s,childColumnName:t};return this.awaitOperation(e,o),this.useBatchMode&&(this.batchMode=!0),o}removeLink(e){let t={type:\"REMOVE_VISUAL_LINK\",childVpId:this.serverViewportId};return this.awaitOperation(e,t),t}suspend(){this.suspended=!0,d==null||d(\"suspend\")}resume(){return this.suspended=!1,N&&(f==null||f(`resume: ${this.currentData()}`)),[this.size,this.currentData()]}currentData(){let e=[];if(this.dataWindow){let t=this.dataWindow.getData(),{keys:n}=this,s=this.isTree?j:J;for(let o of t)o&&e.push(s(o,n,this.selectedRows))}return e}enable(e){return this.awaitOperation(e,{type:\"enable\"}),d==null||d(`enable: ${this.serverViewportId}`),{type:Me,viewPortId:this.serverViewportId}}disable(e){return this.awaitOperation(e,{type:\"disable\"}),d==null||d(`disable: ${this.serverViewportId}`),this.suspended=!1,{type:Ve,viewPortId:this.serverViewportId}}columnRequest(e,t){return this.awaitOperation(e,{type:\"columns\",data:t}),f==null||f(`columnRequest: ${t}`),this.createRequest({columns:t})}setConfig(e,t){var o;this.awaitOperation(e,{type:\"config\",data:t});let{filter:n,...s}=t;return this.useBatchMode&&(this.batchMode=!0),N?f==null||f(`setConfig ${JSON.stringify(t)}`):d==null||d(\"setConfig\"),!this.isTree&&t.groupBy.length>0&&((o=this.dataWindow)==null||o.clear()),this.createRequest({...s,filterSpec:typeof(n==null?void 0:n.filter)==\"string\"?{filter:n.filter}:{filter:\"\"}},!0)}aggregateRequest(e,t){return this.awaitOperation(e,{type:\"aggregate\",data:t}),d==null||d(`aggregateRequest: ${t}`),this.createRequest({aggregations:t})}sortRequest(e,t){return this.awaitOperation(e,{type:\"sort\",data:t}),d==null||d(`sortRequest: ${JSON.stringify(t.sortDefs)}`),this.createRequest({sort:t})}selectRequest(e,t){return this.selectedRows=t,this.awaitOperation(e,{type:\"selection\",data:t}),d==null||d(`selectRequest: ${t}`),{type:\"SET_SELECTION\",vpId:this.serverViewportId,selection:he(t)}}removePendingRangeRequest(e,t){for(let n=this.pendingRangeRequests.length-1;n>=0;n--){let{from:s,to:o}=this.pendingRangeRequests[n],i=!0;if(e>=s&&e<o||t>s&&t<o){i||console.warn(\"removePendingRangeRequest TABLE_ROWS are not for latest request\"),this.pendingRangeRequests.splice(n,1);break}else i=!1}}updateRows(e){var s,o,i;let[t,n]=Re(e);if(t&&n&&this.removePendingRangeRequest(t.rowIndex,n.rowIndex),e.length===1)if(t.vpSize===0&&this.disabled){f==null||f(`ignore a SIZE=0 message on disabled viewport (${e.length} rows)`);return}else t.updateType===\"SIZE\"&&this.setLastSizeOnlyUpdateSize(t.vpSize);for(let u of e)this.isTree&>(u)||((u.updateType===\"SIZE\"||((s=this.dataWindow)==null?void 0:s.rowCount)!==u.vpSize)&&((o=this.dataWindow)==null||o.setRowCount(u.vpSize),this.rowCountChanged=!0),u.updateType===\"U\"&&(i=this.dataWindow)!=null&&i.setAtIndex(u)&&(this.hasUpdates=!0,this.batchMode||this.pendingUpdates.push(u)))}getClientRows(){let e,t=\"size-only\";if(!this.hasUpdates&&!this.rowCountChanged)return U;if(this.hasUpdates){let{keys:n,selectedRows:s}=this,o=this.isTree?j:J;if(this.updateThrottleTimer&&(self.clearTimeout(this.updateThrottleTimer),this.updateThrottleTimer=void 0),this.pendingUpdates.length>0){e=[],t=\"update\";for(let i of this.pendingUpdates)e.push(o(i,n,s));this.pendingUpdates.length=0}else{let i=this.dataWindow.getData();if(this.dataWindow.hasAllRowsWithinRange){e=[],t=\"batch\";for(let u of i)e.push(o(u,n,s));this.batchMode=!1}}this.hasUpdates=!1}return this.throttleMessage(t)?U:[e,t]}createRequest(e,t=!1){return t?{type:\"CHANGE_VP\",viewPortId:this.serverViewportId,...e}:{type:\"CHANGE_VP\",viewPortId:this.serverViewportId,aggregations:this.aggregations,columns:this.columns,sort:this.sort,groupBy:this.groupBy,filterSpec:{filter:this.filter.filter},...e}}},J=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>[r,s.keyFor(r),!0,!1,0,0,e,t?H(o,r):0].concat(n),j=({rowIndex:r,rowKey:e,sel:t,data:n},s,o)=>{let[i,u,,l,,p,...a]=n;return[r,s.keyFor(r),l,u,i,p,e,t?H(o,r):0].concat(a)};var Ue=1;var{debug:V,debugEnabled:Y,error:y,info:T,infoEnabled:ft,warn:Q}=b(\"server-proxy\"),R=()=>`${Ue++}`,mt={},Ct=r=>r.disabled!==!0&&r.suspended!==!0,Rt={type:\"NO_ACTION\"},St=(r,e,t)=>r.map(n=>n.parentVpId===e?{...n,label:t}:n);function Tt(r,e){return r.map(t=>{let{parentVpId:n}=t,s=e.get(n);if(s)return{...t,parentClientVpId:s.clientViewportId,label:s.title};throw Error(\"addLabelsToLinks viewport not found\")})}var $=class{constructor(e,t){this.authToken=\"\";this.user=\"user\";this.pendingRequests=new Map;this.queuedRequests=[];this.cachedTableMetaRequests=new Map;this.cachedTableSchemas=new Map;this.connection=e,this.postMessageToClient=t,this.viewports=new Map,this.mapClientToServerViewport=new Map}async reconnect(){await this.login(this.authToken);let[e,t]=le(Array.from(this.viewports.values()),Ct);this.viewports.clear(),this.mapClientToServerViewport.clear();let n=s=>{s.forEach(o=>{let{clientViewportId:i}=o;this.viewports.set(i,o),this.sendMessageToServer(o.subscribe(),i)})};n(e),setTimeout(()=>{n(t)},2e3)}async login(e,t=\"user\"){if(e)return this.authToken=e,this.user=t,new Promise((n,s)=>{this.sendMessageToServer({type:Pe,token:this.authToken,user:t},\"\"),this.pendingLogin={resolve:n,reject:s}});this.authToken===\"\"&&y(\"login, cannot login until auth token has been obtained\")}subscribe(e){if(this.mapClientToServerViewport.has(e.viewport))y(`spurious subscribe call ${e.viewport}`);else{let t=this.getTableMeta(e.table),n=new q(e,this.postMessageToClient);this.viewports.set(e.viewport,n);let s=this.awaitResponseToMessage(n.subscribe(),e.viewport);Promise.all([s,t]).then(([i,u])=>{let{viewPortId:l}=i,{status:p}=n;e.viewport!==l&&(this.viewports.delete(e.viewport),this.viewports.set(l,n)),this.mapClientToServerViewport.set(e.viewport,l);let a=n.handleSubscribed(i,u);a&&(this.postMessageToClient(a),Y&&V(`post DataSourceSubscribedMessage to client: ${JSON.stringify(a)}`)),n.disabled&&this.disableViewport(n),this.queuedRequests.length>0&&this.processQueuedRequests(),p===\"subscribing\"&&!O(n.table)&&(this.sendMessageToServer({type:K,vpId:l}),this.sendMessageToServer({type:_e,vpId:l}),Array.from(this.viewports.entries()).filter(([c,{disabled:g}])=>c!==l&&!g).forEach(([c])=>{this.sendMessageToServer({type:K,vpId:c})}))})}}processQueuedRequests(){let e={};for(;this.queuedRequests.length;){let t=this.queuedRequests.pop();if(t){let{clientViewportId:n,message:s,requestId:o}=t;if(s.type===\"CHANGE_VP_RANGE\"){if(e.CHANGE_VP_RANGE)continue;e.CHANGE_VP_RANGE=!0;let i=this.mapClientToServerViewport.get(n);i&&this.sendMessageToServer({...s,viewPortId:i},o)}}}}unsubscribe(e){let t=this.mapClientToServerViewport.get(e);t?(T==null||T(`Unsubscribe Message (Client to Server):\n ${t}`),this.sendMessageToServer({type:xe,viewPortId:t})):y(`failed to unsubscribe client viewport ${e}, viewport not found`)}getViewportForClient(e,t=!0){let n=this.mapClientToServerViewport.get(e);if(n){let s=this.viewports.get(n);if(s)return s;if(t)throw Error(`Viewport not found for client viewport ${e}`);return null}else{if(this.viewports.has(e))return this.viewports.get(e);if(t)throw Error(`Viewport server id not found for client viewport ${e}`);return null}}setViewRange(e,t){let n=R(),[s,o,i]=e.rangeRequest(n,t.range);T==null||T(`setViewRange ${t.range.from} - ${t.range.to}`),s&&(this.sendIfReady(s,n,e.status===\"subscribed\")||this.queuedRequests.push({clientViewportId:t.viewport,message:s,requestId:n})),o?(T==null||T(`setViewRange ${o.length} rows returned from cache`),this.postMessageToClient({mode:\"batch\",type:\"viewport-update\",clientViewportId:e.clientViewportId,rows:o})):i&&this.postMessageToClient(i)}setConfig(e,t){let n=R(),s=e.setConfig(n,t.config);this.sendIfReady(s,n,e.status===\"subscribed\")}aggregate(e,t){let n=R(),s=e.aggregateRequest(n,t.aggregations);this.sendIfReady(s,n,e.status===\"subscribed\")}sort(e,t){let n=R(),s=e.sortRequest(n,t.sort);this.sendIfReady(s,n,e.status===\"subscribed\")}setColumns(e,t){let n=R(),{columns:s}=t,o=e.columnRequest(n,s);this.sendIfReady(o,n,e.status===\"subscribed\")}setTitle(e,t){e&&(e.title=t.title,this.updateTitleOnVisualLinks(e))}select(e,t){let n=R(),{selected:s}=t,o=e.selectRequest(n,s);this.sendIfReady(o,n,e.status===\"subscribed\")}disableViewport(e){let t=R(),n=e.disable(t);this.sendIfReady(n,t,e.status===\"subscribed\")}enableViewport(e){if(e.disabled){let t=R(),n=e.enable(t);this.sendIfReady(n,t,e.status===\"subscribed\")}}suspendViewport(e){e.suspend(),e.suspendTimer=setTimeout(()=>{T==null||T(\"suspendTimer expired, escalate suspend to disable\"),this.disableViewport(e)},3e3)}resumeViewport(e){e.suspendTimer&&(V==null||V(\"clear suspend timer\"),clearTimeout(e.suspendTimer),e.suspendTimer=null);let[t,n]=e.resume();V==null||V(`resumeViewport size ${t}, ${n.length} rows sent to client`),this.postMessageToClient({clientViewportId:e.clientViewportId,mode:\"batch\",rows:n,size:t,type:\"viewport-update\"})}openTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.openTreeNode(n,t),n,e.status===\"subscribed\")}}closeTreeNode(e,t){if(e.serverViewportId){let n=R();this.sendIfReady(e.closeTreeNode(n,t),n,e.status===\"subscribed\")}}createLink(e,t){let{parentClientVpId:n,parentColumnName:s,childColumnName:o}=t,i=R(),u=this.mapClientToServerViewport.get(n);if(u){let l=e.createLink(i,o,u,s);this.sendMessageToServer(l,i)}else y(\"ServerProxy unable to create link, viewport not found\")}removeLink(e){let t=R(),n=e.removeLink(t);this.sendMessageToServer(n,t)}updateTitleOnVisualLinks(e){var s;let{serverViewportId:t,title:n}=e;for(let o of this.viewports.values())if(o!==e&&o.links&&t&&n&&(s=o.links)!=null&&s.some(i=>i.parentVpId===t)){let[i]=o.setLinks(St(o.links,t,n));this.postMessageToClient(i)}}removeViewportFromVisualLinks(e){var t;for(let n of this.viewports.values())if((t=n.links)!=null&&t.some(({parentVpId:s})=>s===e)){let[s]=n.setLinks(n.links.filter(({parentVpId:o})=>o!==e));this.postMessageToClient(s)}}menuRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId},n)}}viewportRpcCall(e){let t=this.getViewportForClient(e.vpId,!1);if(t!=null&&t.serverViewportId){let[n,s]=A(e);this.sendMessageToServer({...s,vpId:t.serverViewportId,namedParams:{}},n)}}rpcCall(e){let[t,n]=A(e),s=We(n.service);this.sendMessageToServer(n,t,{module:s})}handleMessageFromClient(e){var t;if(ge(e))if(e.type===\"disable\"){let n=this.getViewportForClient(e.viewport,!1);return n!==null?this.disableViewport(n):void 0}else{let n=this.getViewportForClient(e.viewport);switch(e.type){case\"setViewRange\":return this.setViewRange(n,e);case\"config\":return this.setConfig(n,e);case\"aggregate\":return this.aggregate(n,e);case\"sort\":return this.sort(n,e);case\"select\":return this.select(n,e);case\"suspend\":return this.suspendViewport(n);case\"resume\":return this.resumeViewport(n);case\"enable\":return this.enableViewport(n);case\"openTreeNode\":return this.openTreeNode(n,e);case\"closeTreeNode\":return this.closeTreeNode(n,e);case\"createLink\":return this.createLink(n,e);case\"removeLink\":return this.removeLink(n);case\"setColumns\":return this.setColumns(n,e);case\"setTitle\":return this.setTitle(n,e);default:}}else{if(Ce(e))return this.viewportRpcCall(e);if(me(e))return this.menuRpcCall(e);{let{type:n,requestId:s}=e;switch(n){case\"GET_TABLE_LIST\":{(t=this.tableList)!=null||(this.tableList=this.awaitResponseToMessage({type:n},s)),this.tableList.then(o=>{this.postMessageToClient({type:\"TABLE_LIST_RESP\",tables:o.tables,requestId:s})});return}case\"GET_TABLE_META\":{this.getTableMeta(e.table,s).then(o=>{o&&this.postMessageToClient({type:\"TABLE_META_RESP\",tableSchema:o,requestId:s})});return}case\"RPC_CALL\":return this.rpcCall(e);default:}}}y(`Vuu ServerProxy Unexpected message from client ${JSON.stringify(e)}`)}getTableMeta(e,t=R()){if(O(e))return Promise.resolve(void 0);let n=`${e.module}:${e.table}`,s=this.cachedTableMetaRequests.get(n);return s||(s=this.awaitResponseToMessage({type:\"GET_TABLE_META\",table:e},t),this.cachedTableMetaRequests.set(n,s)),s==null?void 0:s.then(o=>this.cacheTableMeta(o))}awaitResponseToMessage(e,t=R()){return new Promise((n,s)=>{this.sendMessageToServer(e,t),this.pendingRequests.set(t,{reject:s,resolve:n})})}sendIfReady(e,t,n=!0){return n&&this.sendMessageToServer(e,t),n}sendMessageToServer(e,t=`${Ue++}`,n=mt){let{module:s=\"CORE\"}=n;this.authToken&&this.connection.send({requestId:t,sessionId:this.sessionId,token:this.authToken,user:this.user,module:s,body:e})}handleMessageFromServer(e){var u;let{body:t,requestId:n,sessionId:s}=e,o=this.pendingRequests.get(n);if(o){let{resolve:a}=o;this.pendingRequests.delete(n),a(t);return}let{viewports:i}=this;switch(t.type){case De:this.sendMessageToServer({type:Ie,ts:+new Date},\"NA\");break;case\"LOGIN_SUCCESS\":if(s)this.sessionId=s,(u=this.pendingLogin)==null||u.resolve(s),this.pendingLogin=void 0;else throw Error(\"LOGIN_SUCCESS did not provide sessionId\");break;case\"REMOVE_VP_SUCCESS\":{let a=i.get(t.viewPortId);a&&(this.mapClientToServerViewport.delete(a.clientViewportId),i.delete(t.viewPortId),this.removeViewportFromVisualLinks(t.viewPortId))}break;case Oe:{let a=this.viewports.get(t.vpId);a&&a.completeOperation(n)}break;case Te:case ve:if(i.has(t.viewPortId)){let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);c!==void 0&&(this.postMessageToClient(c),Y&&V(`postMessageToClient ${JSON.stringify(c)}`))}}break;case ye:{let a=this.viewports.get(t.viewPortId);if(a){let c=a.completeOperation(n);if(c){this.postMessageToClient(c);let[g,S]=a.resume();this.postMessageToClient({clientViewportId:a.clientViewportId,mode:\"batch\",rows:S,size:g,type:\"viewport-update\"})}}}break;case\"TABLE_ROW\":{let a=Se(t.rows);for(let[c,g]of Object.entries(a)){let S=i.get(c);S?S.updateRows(g):Q==null||Q(`TABLE_ROW message received for non registered viewport ${c}`)}this.processUpdates()}break;case\"CHANGE_VP_RANGE_SUCCESS\":{let a=this.viewports.get(t.viewPortId);if(a){let{from:c,to:g}=t;a.completeOperation(n,c,g)}}break;case ke:case we:break;case\"CREATE_VISUAL_LINK_SUCCESS\":{let a=this.viewports.get(t.childVpId),c=this.viewports.get(t.parentVpId);if(a&&c){let{childColumnName:g,parentColumnName:S}=t,D=a.completeOperation(n,g,c.clientViewportId,S);D&&this.postMessageToClient(D)}}break;case\"REMOVE_VISUAL_LINK_SUCCESS\":{let a=this.viewports.get(t.childVpId);if(a){let c=a.completeOperation(n);c&&this.postMessageToClient(c)}}break;case\"VP_VISUAL_LINKS_RESP\":{let a=this.getActiveLinks(t.links),c=this.viewports.get(t.vpId);if(a.length&&c){let g=Tt(a,this.viewports),[S,D]=c.setLinks(g);if(this.postMessageToClient(S),D){let{link:se,parentClientVpId:ze}=D,re=R(),oe=this.mapClientToServerViewport.get(ze);if(oe){let Ke=c.createLink(re,se.fromColumn,oe,se.toColumn);this.sendMessageToServer(Ke,re)}}}}break;case\"VIEW_PORT_MENUS_RESP\":if(t.menu.name){let a=this.viewports.get(t.vpId);if(a){let c=a.setMenu(t.menu);this.postMessageToClient(c)}}break;case\"VP_EDIT_RPC_RESPONSE\":this.postMessageToClient({action:t.action,requestId:n,rpcName:t.rpcName,type:\"VP_EDIT_RPC_RESPONSE\"});break;case\"VP_EDIT_RPC_REJECT\":this.viewports.get(t.vpId)&&this.postMessageToClient({requestId:n,type:\"VP_EDIT_RPC_REJECT\",error:t.error});break;case\"VIEW_PORT_MENU_REJ\":{console.log(\"send menu error back to client\");let{error:a,rpcName:c,vpId:g}=t,S=this.viewports.get(g);S&&this.postMessageToClient({clientViewportId:S.clientViewportId,error:a,rpcName:c,type:\"VIEW_PORT_MENU_REJ\",requestId:n});break}case\"VIEW_PORT_MENU_RESP\":if(fe(t)){let{action:a,rpcName:c}=t;this.awaitResponseToMessage({type:\"GET_TABLE_META\",table:a.table}).then(g=>{let S=z(g);this.postMessageToClient({rpcName:c,type:\"VIEW_PORT_MENU_RESP\",action:{...a,tableSchema:S},tableAlreadyOpen:this.isTableOpen(a.table),requestId:n})})}else{let{action:a}=t;this.postMessageToClient({type:\"VIEW_PORT_MENU_RESP\",action:a||Rt,tableAlreadyOpen:a!==null&&this.isTableOpen(a.table),requestId:n})}break;case\"RPC_RESP\":{let{method:a,result:c}=t;this.postMessageToClient({type:\"RPC_RESP\",method:a,result:c,requestId:n})}break;case\"VIEW_PORT_RPC_REPONSE\":{let{method:a,action:c}=t;this.postMessageToClient({type:\"VIEW_PORT_RPC_RESPONSE\",rpcName:a,action:c,requestId:n})}break;case\"ERROR\":y(t.msg);break;default:ft&&T(`handleMessageFromServer ${t.type}.`)}}cacheTableMeta(e){let{module:t,table:n}=e.table,s=`${t}:${n}`,o=this.cachedTableSchemas.get(s);return o||(o=z(e),this.cachedTableSchemas.set(s,o)),o}isTableOpen(e){if(e){let t=e.table;for(let n of this.viewports.values())if(!n.suspended&&n.table.table===t)return!0}}getActiveLinks(e){return e.filter(t=>{let n=this.viewports.get(t.parentVpId);return n&&!n.suspended})}processUpdates(){this.viewports.forEach(e=>{var t;if(e.hasUpdatesToProcess){let n=e.getClientRows();if(n!==U){let[s,o]=n,i=e.getNewRowCount();(i!==void 0||s&&s.length>0)&&(Y&&V(`postMessageToClient #${e.clientViewportId} viewport-update ${o}, ${(t=s==null?void 0:s.length)!=null?t:\"no\"} rows, size ${i}`),o&&this.postMessageToClient({clientViewportId:e.clientViewportId,mode:o,rows:s,size:i,type:\"viewport-update\"}))}}})}};var{debug:un,debugEnabled:ln,error:qe,info:w,infoEnabled:bt,warn:_}=b(\"websocket-connection\"),Be={},Z=Symbol(\"setWebsocket\"),F=Symbol(\"connectionCallback\");async function Ge(r,e,t,n=10,s=5){return Be[r]={status:\"connecting\",connect:{allowed:s,remaining:s},reconnect:{allowed:n,remaining:n}},He(r,e,t)}async function X(r){throw Error(\"connection broken\")}async function He(r,e,t,n){let{status:s,connect:o,reconnect:i}=Be[r],u=s===\"connecting\"?o:i;try{t({type:\"connection-status\",status:\"connecting\"});let l=typeof n<\"u\",p=await Et(r,e);console.info(\"%c⚡ %cconnected\",\"font-size: 24px;color: green;font-weight: bold;\",\"color:green; font-size: 14px;\"),n!==void 0&&n[Z](p);let a=n!=null?n:new ee(p,r,e,t),c=l?\"reconnected\":\"connection-open-awaiting-session\";return t({type:\"connection-status\",status:c}),a.status=c,u.remaining=u.allowed,a}catch{let p=--u.remaining>0;if(t({type:\"connection-status\",status:\"disconnected\",reason:\"failed to connect\",retry:p}),p)return wt(r,e,t,n,2e3);throw t({type:\"connection-status\",status:\"failed\",reason:\"unable to connect\",retry:p}),Error(\"Failed to establish connection\")}}var wt=(r,e,t,n,s)=>new Promise(o=>{setTimeout(()=>{o(He(r,e,t,n))},s)}),Et=(r,e)=>new Promise((t,n)=>{bt&&e!==void 0&&w(`WebSocket Protocol ${e==null?void 0:e.toString()}`);let s=new WebSocket(r,e);s.onopen=()=>t(s),s.onerror=o=>n(o)}),$e=()=>{_==null||_(\"Connection cannot be closed, socket not yet opened\")},Fe=r=>{_==null||_(`Message cannot be sent, socket closed ${r.body.type}`)},Vt=r=>{try{return JSON.parse(r)}catch{throw Error(`Error parsing JSON response from server ${r}`)}},ee=class{constructor(e,t,n,s){this.close=$e;this.requiresLogin=!0;this.send=Fe;this.status=\"ready\";this.messagesCount=0;this.connectionMetricsInterval=null;this.handleWebsocketMessage=e=>{let t=Vt(e.data);this.messagesCount+=1,this[F](t)};this.url=t,this.protocol=n,this[F]=s,this[Z](e)}reconnect(){X(this)}[(F,Z)](e){let t=this[F];e.onmessage=o=>{this.status=\"connected\",e.onmessage=this.handleWebsocketMessage,this.handleWebsocketMessage(o)},this.connectionMetricsInterval=setInterval(()=>{t({type:\"connection-metrics\",messagesLength:this.messagesCount}),this.messagesCount=0},2e3),e.onerror=()=>{qe(\"⚡ connection error\"),t({type:\"connection-status\",status:\"disconnected\",reason:\"error\"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status===\"connection-open-awaiting-session\"?qe(\"Websocket connection lost before Vuu session established, check websocket configuration\"):this.status!==\"closed\"&&(X(this),this.send=s)},e.onclose=()=>{w==null||w(\"⚡ connection close\"),t({type:\"connection-status\",status:\"disconnected\",reason:\"close\"}),this.connectionMetricsInterval&&(clearInterval(this.connectionMetricsInterval),this.connectionMetricsInterval=null),this.status!==\"closed\"&&(X(this),this.send=s)};let n=o=>{e.send(JSON.stringify(o))},s=o=>{w==null||w(`TODO queue message until websocket reconnected ${o.body.type}`)};this.send=n,this.close=()=>{this.status=\"closed\",e.close(),this.close=$e,this.send=Fe,w==null||w(\"close websocket\")}}};var v,{info:te,infoEnabled:ne}=b(\"worker\");async function vt(r,e,t,n,s,o,i){let u=await Ge(r,e,l=>{de(l)?postMessage({type:\"connection-metrics\",messages:l}):pe(l)?(s(l),l.status===\"reconnected\"&&v.reconnect()):v.handleMessageFromServer(l)},o,i);v=new $(u,l=>Mt(l)),u.requiresLogin&&await v.login(t,n)}function Mt(r){postMessage(r)}var yt=async({data:r})=>{switch(r.type){case\"connect\":try{await vt(r.url,r.protocol,r.token,r.username,postMessage,r.retryLimitDisconnect,r.retryLimitStartup),postMessage({type:\"connected\"})}catch(e){postMessage({type:\"connection-failed\",reason:String(e)})}break;case\"subscribe\":ne&&te(`client subscribe: ${JSON.stringify(r)}`),v.subscribe(r);break;case\"unsubscribe\":ne&&te(`client unsubscribe: ${JSON.stringify(r)}`),v.unsubscribe(r.viewport);break;default:ne&&te(`client message: ${JSON.stringify(r)}`),v.handleMessageFromClient(r)}};self.addEventListener(\"message\",yt);postMessage({type:\"ready\"});\n\n";
|
|
@@ -10,7 +10,6 @@ export declare class VuuDataSource extends EventEmitter<DataSourceEvents> implem
|
|
|
10
10
|
private configChangePending;
|
|
11
11
|
private rangeRequest;
|
|
12
12
|
table: VuuTable;
|
|
13
|
-
tableSchema: TableSchema | undefined;
|
|
14
13
|
viewport: string | undefined;
|
|
15
14
|
constructor({ bufferSize, aggregations, columns, filter, groupBy, sort, table, title, viewport, visualLink, }: DataSourceConstructorProps);
|
|
16
15
|
subscribe({ viewport, columns, aggregations, range, sort, groupBy, filter, }: SubscribeProps, callback: SubscribeCallback): Promise<void>;
|
|
@@ -23,6 +22,8 @@ export declare class VuuDataSource extends EventEmitter<DataSourceEvents> implem
|
|
|
23
22
|
select(selected: Selection): void;
|
|
24
23
|
openTreeNode(key: string): void;
|
|
25
24
|
closeTreeNode(key: string): void;
|
|
25
|
+
get tableSchema(): TableSchema | undefined;
|
|
26
|
+
set tableSchema(tableSchema: TableSchema | undefined);
|
|
26
27
|
get links(): LinkDescriptorWithLabel[] | undefined;
|
|
27
28
|
get menu(): VuuMenu | undefined;
|
|
28
29
|
get status(): DataSourceStatus;
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2015 UBS
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|