@vuu-ui/vuu-data-remote 2.1.13 → 2.1.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketConnection.js","sources":["../../../packages/vuu-data-remote/src/WebSocketConnection.ts"],"sourcesContent":["import { WebSocketProtocol } from \"@vuu-ui/vuu-data-types\";\nimport {\n InvalidSessionReason,\n InvalidTokenReason,\n LoginErrorMessage,\n VuuClientMessage,\n VuuServerMessage,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DeferredPromise,\n EventEmitter,\n isLoginErrorMessage,\n logger,\n} from \"@vuu-ui/vuu-utils\";\n\nexport type ConnectionPhase =\n | \"initial-connection\"\n | \"post-disconnect-reconnection\";\nexport type ConnectingStatus = \"connecting\" | \"reconnecting\";\nexport type ConnectedStatus = \"connected\" | \"reconnected\";\nexport type ConnectionStatus =\n | ConnectingStatus\n | ConnectedStatus\n | \"closed\"\n | \"websocket-open\"\n | \"disconnected\"\n | \"failed\"\n | \"inactive\";\n\nexport const isInvalidTokenReason = (\n text: string,\n): text is InvalidTokenReason =>\n text === \"Invalid token\" || text === \"Token has expired\";\n\nexport const isInvalidSessionReason = (\n text: string,\n): text is InvalidSessionReason =>\n text === \"Invalid session\" || text === \"User session limit exceeded\";\n\nconst { debug, debugEnabled, info } = logger(\"WebSocketConnection\");\n\nexport const isWebSocketConnectionStatus = (\n msg: unknown,\n): msg is ConnectionStatus =>\n typeof msg === \"string\" &&\n [\n \"connecting\",\n \"websocket-open\",\n \"connected\",\n \"reconnecting\",\n \"reconnected\",\n \"disconnected\",\n \"closed\",\n \"failed\",\n ].includes(msg);\n\nexport const isConnected = (\n status: ConnectionStatus,\n): status is ConnectedStatus =>\n status === \"connected\" || status === \"reconnected\";\n\nexport type LoginRejectedMessage = {\n type: \"LOGIN_REJECTED\";\n reason: LoginErrorMessage;\n};\n\nexport const isLoginRejectedMessage = (\n message: object,\n): message is LoginRejectedMessage =>\n message !== null && \"type\" in message && message.type === \"LOGIN_REJECTED\";\n\nexport type VuuServerMessageCallback = (\n msg: VuuServerMessage | LoginRejectedMessage,\n) => void;\n\nexport type WebSocketConnectionConfig = {\n url: string;\n protocols: WebSocketProtocol;\n callback: VuuServerMessageCallback;\n connectionTimeout?: number;\n};\n\nconst DEFAULT_CONNECTION_TIMEOUT = 10000;\n\nconst parseWebSocketMessage = (message: string): VuuServerMessage => {\n try {\n return JSON.parse(message) as VuuServerMessage;\n } catch (e) {\n throw Error(`Error parsing JSON response from server ${message}`);\n }\n};\n\nexport type WebSocketConnectionCloseReason =\n | LoginErrorMessage\n | \"failure\"\n | \"shutdown\";\n\nexport type WebSocketConnectionEvents = {\n \"connection-status\": (status: ConnectionStatus) => void;\n};\n\nexport class WebSocketConnection extends EventEmitter<WebSocketConnectionEvents> {\n #callback;\n /**\n We are not confirmedOpen until we receive the first message from the\n server. If we get an unexpected close event before that, we consider\n the reconnect attempts as still within the connection phase, not true\n reconnection. This can happen e.g. when connecting to remote host via\n a proxy.\n */\n #confirmedOpen = false;\n #connectionPhase: ConnectionPhase = \"initial-connection\";\n #connectionStatus: ConnectionStatus = \"closed\";\n\n #connectionTimeout;\n #deferredOpen?: DeferredPromise;\n #protocols;\n #url;\n #ws?: WebSocket;\n\n constructor({\n callback,\n connectionTimeout = DEFAULT_CONNECTION_TIMEOUT,\n protocols,\n url,\n }: WebSocketConnectionConfig) {\n super();\n\n this.#callback = callback;\n this.#connectionTimeout = connectionTimeout;\n this.#url = url;\n this.#protocols = protocols;\n }\n\n get connectionTimeout() {\n return this.#connectionTimeout;\n }\n\n get protocols() {\n return this.#protocols;\n }\n\n get isClosed() {\n return this.#connectionStatus === \"closed\";\n }\n get isDisconnected() {\n return this.#connectionStatus === \"disconnected\";\n }\n\n get connectionPhase() {\n return this.#connectionPhase;\n }\n\n get connectionStatus() {\n return this.#connectionStatus;\n }\n\n private set connectionStatus(connectionStatus: ConnectionStatus) {\n if (\n connectionStatus !== \"connecting\" &&\n connectionStatus !== \"reconnecting\"\n ) {\n this.#connectionStatus = connectionStatus;\n this.emit(\"connection-status\", this.#connectionStatus);\n }\n }\n\n get confirmedOpen() {\n return this.#confirmedOpen;\n }\n\n /**\n * We are 'confirmedOpen' when we see the first message transmitted\n * from the server. This ensures that even if we have one or more\n * proxies in our route to the endPoint, all connections have been\n * opened successfully.\n * First time in here (on our initial successful connection) we switch\n * from 'connect' phase to 'reconnect' phase. We may have different\n * retry configurations for these two phases.\n */\n private set confirmedOpen(confirmedOpen: boolean) {\n this.#confirmedOpen = confirmedOpen;\n if (confirmedOpen && this.#connectionPhase === \"initial-connection\") {\n this.#connectionPhase = \"post-disconnect-reconnection\";\n }\n }\n\n get url() {\n return this.#url;\n }\n\n async openWebSocket() {\n const initialConnect = this.#connectionPhase === \"initial-connection\";\n if (this.#deferredOpen === undefined) {\n this.#deferredOpen = new DeferredPromise();\n }\n const { connectionTimeout, protocols, url } = this;\n this.#connectionStatus = initialConnect ? \"connecting\" : \"reconnecting\";\n\n const timer = setTimeout(() => {\n throw Error(\n `Failed to open WebSocket connection to ${url}, timed out after ${connectionTimeout}ms`,\n );\n }, connectionTimeout);\n\n const ws = (this.#ws = new WebSocket(url, protocols));\n\n ws.onopen = () => {\n this.connectionStatus = \"websocket-open\";\n\n clearTimeout(timer);\n\n // Do we do this here or after login\n if (this.#deferredOpen) {\n this.#deferredOpen.resolve(undefined);\n this.#deferredOpen = undefined;\n }\n };\n\n ws.onerror = () => {\n clearTimeout(timer);\n };\n\n ws.onclose = () => {\n if (!this.isClosed) {\n this.confirmedOpen = false;\n // Do we emit disconnected even if not confirmed open ?\n // this will emit disconnected\n this.connectionStatus = \"disconnected\";\n // this will emit closed\n this.close(\"failure\");\n }\n };\n\n ws.onmessage = (evt) => {\n this.receive(evt);\n };\n\n return this.#deferredOpen?.promise;\n }\n\n private receive = (evt: MessageEvent) => {\n if (isLoginErrorMessage(evt.data)) {\n console.log(`[WebSocketConnection] closed because of login issue`);\n if (this.#deferredOpen) {\n console.log(`... and qwe have a deferred connection`);\n }\n\n this.#callback({\n type: \"LOGIN_REJECTED\",\n reason: evt.data,\n });\n this.close(evt.data);\n } else {\n const vuuMessageFromServer = parseWebSocketMessage(evt.data);\n\n if (debugEnabled) {\n if (vuuMessageFromServer.body.type !== \"HB\") {\n debug(`${vuuMessageFromServer.body.type}`);\n if (vuuMessageFromServer.body.type === \"CHANGE_VP_SUCCESS\") {\n debug(JSON.stringify(vuuMessageFromServer.body));\n }\n }\n }\n this.#callback(vuuMessageFromServer);\n\n if (!this.confirmedOpen) {\n if (vuuMessageFromServer.body.type === \"LOGIN_SUCCESS\") {\n // Now that we are confirmedOpen any subsequent close events\n // will be treated as part of a reconnection phase.\n this.connectionStatus =\n this.#connectionPhase === \"initial-connection\"\n ? \"connected\"\n : \"reconnected\";\n this.confirmedOpen = true;\n }\n }\n }\n };\n\n send = (msg: VuuClientMessage) => {\n if (msg.body.type === \"CHANGE_VP_RANGE\") {\n info?.(\n `CHANGE_VP_RANGE<#${msg.requestId}> ${msg.body.from}-${msg.body.to}`,\n );\n }\n this.#ws?.send(JSON.stringify(msg));\n };\n\n close(reason: WebSocketConnectionCloseReason = \"shutdown\") {\n this.connectionStatus = \"closed\";\n if (reason === \"failure\") {\n if (this.#deferredOpen) {\n this.#deferredOpen.reject(Error(\"connection failed\"));\n this.#deferredOpen = undefined;\n }\n } else {\n this.#ws?.close();\n }\n this.#ws = undefined;\n }\n}\n"],"names":["logger"],"mappings":";;;;AAuCsCA,gBAAO,qBAAqB;AAE3D,MAAM,2BAA8B,GAAA,CACzC,GAEA,KAAA,OAAO,QAAQ,QACf,IAAA;AAAA,EACE,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,CAAE,SAAS,GAAG;AAET,MAAM,WAAc,GAAA,CACzB,MAEA,KAAA,MAAA,KAAW,eAAe,MAAW,KAAA;;;;;"}
1
+ {"version":3,"file":"WebSocketConnection.js","sources":["../../../packages/vuu-data-remote/src/WebSocketConnection.ts"],"sourcesContent":["import { WebSocketProtocol } from \"@vuu-ui/vuu-data-types\";\nimport {\n InvalidSessionReason,\n InvalidTokenReason,\n LoginErrorMessage,\n VuuClientMessage,\n VuuServerMessage,\n} from \"@vuu-ui/vuu-protocol-types\";\nimport {\n DeferredPromise,\n EventEmitter,\n isLoginErrorMessage,\n logger,\n} from \"@vuu-ui/vuu-utils\";\n\nexport type ConnectionPhase =\n | \"initial-connection\"\n | \"post-disconnect-reconnection\";\nexport type ConnectingStatus = \"connecting\" | \"reconnecting\";\nexport type ConnectedStatus = \"connected\" | \"reconnected\";\nexport type ConnectionStatus =\n | ConnectingStatus\n | ConnectedStatus\n | \"closed\"\n | \"websocket-open\"\n | \"disconnected\"\n | \"failed\"\n | \"inactive\";\n\nexport const isInvalidTokenReason = (\n text: string,\n): text is InvalidTokenReason =>\n text === \"Invalid token\" || text === \"Token has expired\";\n\nexport const isInvalidSessionReason = (\n text: string,\n): text is InvalidSessionReason =>\n text === \"Invalid session\" || text === \"User session limit exceeded\";\n\nconst { debug, debugEnabled, info } = logger(\"WebSocketConnection\");\n\nexport const isWebSocketConnectionStatus = (\n msg: unknown,\n): msg is ConnectionStatus =>\n typeof msg === \"string\" &&\n [\n \"connecting\",\n \"websocket-open\",\n \"connected\",\n \"reconnecting\",\n \"reconnected\",\n \"disconnected\",\n \"closed\",\n \"failed\",\n ].includes(msg);\n\nexport const isConnected = (\n status: ConnectionStatus,\n): status is ConnectedStatus =>\n status === \"connected\" || status === \"reconnected\";\n\nexport type LoginRejectedMessage = {\n type: \"LOGIN_REJECTED\";\n reason: LoginErrorMessage;\n};\n\nexport const isLoginRejectedMessage = (\n message: object,\n): message is LoginRejectedMessage =>\n message !== null && \"type\" in message && message.type === \"LOGIN_REJECTED\";\n\nexport type VuuServerMessageCallback = (\n msg: VuuServerMessage | LoginRejectedMessage,\n) => void;\n\nexport type WebSocketConnectionConfig = {\n url: string;\n protocols: WebSocketProtocol;\n callback: VuuServerMessageCallback;\n connectionTimeout?: number;\n};\n\nconst DEFAULT_CONNECTION_TIMEOUT = 10000;\n\nconst parseWebSocketMessage = (message: string): VuuServerMessage => {\n try {\n return JSON.parse(message) as VuuServerMessage;\n } catch (e) {\n throw Error(`Error parsing JSON response from server ${message}`);\n }\n};\n\nexport type WebSocketConnectionCloseReason =\n | LoginErrorMessage\n | \"failure\"\n | \"shutdown\";\n\nexport type WebSocketConnectionEvents = {\n \"connection-status\": (status: ConnectionStatus) => void;\n};\n\nexport class WebSocketConnection extends EventEmitter<WebSocketConnectionEvents> {\n #callback;\n /**\n We are not confirmedOpen until we receive the first message from the\n server. If we get an unexpected close event before that, we consider\n the reconnect attempts as still within the connection phase, not true\n reconnection. This can happen e.g. when connecting to remote host via\n a proxy.\n */\n #confirmedOpen = false;\n #connectionPhase: ConnectionPhase = \"initial-connection\";\n #connectionStatus: ConnectionStatus = \"closed\";\n\n #connectionTimeout;\n #deferredOpen?: DeferredPromise;\n #protocols;\n #url;\n #ws?: WebSocket;\n\n constructor({\n callback,\n connectionTimeout = DEFAULT_CONNECTION_TIMEOUT,\n protocols,\n url,\n }: WebSocketConnectionConfig) {\n super();\n\n this.#callback = callback;\n this.#connectionTimeout = connectionTimeout;\n this.#url = url;\n this.#protocols = protocols;\n }\n\n get connectionTimeout() {\n return this.#connectionTimeout;\n }\n\n get protocols() {\n return this.#protocols;\n }\n\n get isClosed() {\n return this.#connectionStatus === \"closed\";\n }\n get isDisconnected() {\n return this.#connectionStatus === \"disconnected\";\n }\n\n get connectionPhase() {\n return this.#connectionPhase;\n }\n\n get connectionStatus() {\n return this.#connectionStatus;\n }\n\n private set connectionStatus(connectionStatus: ConnectionStatus) {\n if (\n connectionStatus !== \"connecting\" &&\n connectionStatus !== \"reconnecting\"\n ) {\n this.#connectionStatus = connectionStatus;\n this.emit(\"connection-status\", this.#connectionStatus);\n }\n }\n\n get confirmedOpen() {\n return this.#confirmedOpen;\n }\n\n /**\n * We are 'confirmedOpen' when we see the first message transmitted\n * from the server. This ensures that even if we have one or more\n * proxies in our route to the endPoint, all connections have been\n * opened successfully.\n * First time in here (on our initial successful connection) we switch\n * from 'connect' phase to 'reconnect' phase. We may have different\n * retry configurations for these two phases.\n */\n private set confirmedOpen(confirmedOpen: boolean) {\n this.#confirmedOpen = confirmedOpen;\n if (confirmedOpen && this.#connectionPhase === \"initial-connection\") {\n this.#connectionPhase = \"post-disconnect-reconnection\";\n }\n }\n\n get url() {\n return this.#url;\n }\n\n async openWebSocket() {\n const initialConnect = this.#connectionPhase === \"initial-connection\";\n if (this.#deferredOpen === undefined) {\n this.#deferredOpen = new DeferredPromise();\n }\n const { connectionTimeout, protocols, url } = this;\n this.#connectionStatus = initialConnect ? \"connecting\" : \"reconnecting\";\n\n const timer = setTimeout(() => {\n throw Error(\n `Failed to open WebSocket connection to ${url}, timed out after ${connectionTimeout}ms`,\n );\n }, connectionTimeout);\n\n const ws = (this.#ws = new WebSocket(url, protocols));\n\n ws.onopen = () => {\n this.connectionStatus = \"websocket-open\";\n\n clearTimeout(timer);\n\n // Do we do this here or after login\n if (this.#deferredOpen) {\n this.#deferredOpen.resolve(undefined);\n this.#deferredOpen = undefined;\n }\n };\n\n ws.onerror = () => {\n clearTimeout(timer);\n };\n\n ws.onclose = () => {\n if (!this.isClosed) {\n this.confirmedOpen = false;\n // Do we emit disconnected even if not confirmed open ?\n // this will emit disconnected\n this.connectionStatus = \"disconnected\";\n // this will emit closed\n this.close(\"failure\");\n }\n };\n\n ws.onmessage = (evt) => {\n this.receive(evt);\n };\n\n return this.#deferredOpen?.promise;\n }\n\n private receive = (evt: MessageEvent) => {\n if (isLoginErrorMessage(evt.data)) {\n console.warn(`[WebSocketConnection] closed because of login issue`);\n if (this.#deferredOpen) {\n console.warn(`... and we have a deferred connection`);\n }\n\n this.#callback({\n type: \"LOGIN_REJECTED\",\n reason: evt.data,\n });\n this.close(evt.data);\n } else {\n const vuuMessageFromServer = parseWebSocketMessage(evt.data);\n\n if (debugEnabled) {\n if (vuuMessageFromServer.body.type !== \"HB\") {\n debug(`<=== ${vuuMessageFromServer.body.type}`);\n if (vuuMessageFromServer.body.type === \"CHANGE_VP_SUCCESS\") {\n debug(JSON.stringify(vuuMessageFromServer.body));\n }\n }\n }\n this.#callback(vuuMessageFromServer);\n\n if (!this.confirmedOpen) {\n if (vuuMessageFromServer.body.type === \"LOGIN_SUCCESS\") {\n // Now that we are confirmedOpen any subsequent close events\n // will be treated as part of a reconnection phase.\n this.connectionStatus =\n this.#connectionPhase === \"initial-connection\"\n ? \"connected\"\n : \"reconnected\";\n this.confirmedOpen = true;\n }\n }\n }\n };\n\n send = (msg: VuuClientMessage) => {\n if (msg.body.type === \"CHANGE_VP_RANGE\") {\n info?.(\n `===> CHANGE_VP_RANGE<#${msg.requestId}> ${msg.body.from}-${msg.body.to}`,\n );\n }\n this.#ws?.send(JSON.stringify(msg));\n };\n\n close(reason: WebSocketConnectionCloseReason = \"shutdown\") {\n this.connectionStatus = \"closed\";\n if (reason === \"failure\") {\n if (this.#deferredOpen) {\n this.#deferredOpen.reject(Error(\"connection failed\"));\n this.#deferredOpen = undefined;\n }\n } else {\n this.#ws?.close();\n }\n this.#ws = undefined;\n }\n}\n"],"names":["logger"],"mappings":";;;;AAuCsCA,gBAAO,qBAAqB;AAE3D,MAAM,2BAA8B,GAAA,CACzC,GAEA,KAAA,OAAO,QAAQ,QACf,IAAA;AAAA,EACE,YAAA;AAAA,EACA,gBAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,CAAE,SAAS,GAAG;AAET,MAAM,WAAc,GAAA,CACzB,MAEA,KAAA,MAAA,KAAW,eAAe,MAAW,KAAA;;;;;"}
@@ -132,6 +132,45 @@ var EventEmitter = class {
132
132
  };
133
133
  _events = new WeakMap();
134
134
 
135
+ // ../vuu-utils/src/protocol-message-utils.ts
136
+ var MENU_RPC_TYPES = [
137
+ "VIEW_PORT_MENUS_SELECT_RPC",
138
+ "VIEW_PORT_MENU_TABLE_RPC",
139
+ "VIEW_PORT_MENU_ROW_RPC",
140
+ "VIEW_PORT_MENU_CELL_RPC"
141
+ ];
142
+ var INVALID_SESSION = "Invalid session";
143
+ var SESSION_LIMIT_EXCEEDED = "User session limit exceeded";
144
+ var INVALID_TOKEN = "Invalid token";
145
+ var TOKEN_EXPIRED = "Token has expired";
146
+ var InvalidLoginMessages = [
147
+ INVALID_SESSION,
148
+ SESSION_LIMIT_EXCEEDED,
149
+ INVALID_TOKEN,
150
+ TOKEN_EXPIRED
151
+ ];
152
+ var isErrorMessage = (message) => typeof message == "object" && (message == null ? void 0 : message.type) === "ERROR";
153
+ var isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
154
+ var isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
155
+ var isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
156
+ var hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
157
+ var isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
158
+ var isOpenDialogAction = (action) => action !== void 0 && action.type === "OPEN_DIALOG_ACTION";
159
+ var isCreateVpSuccess = (response) => response.type === "CREATE_VP_SUCCESS";
160
+ var isSessionTable = (table) => {
161
+ if (table !== null && typeof table === "object" && "table" in table && "module" in table) {
162
+ return table.table.startsWith("session");
163
+ }
164
+ return false;
165
+ };
166
+ function isActionMessage(rpcResponse) {
167
+ return rpcResponse.type === "VIEW_PORT_MENU_RESP";
168
+ }
169
+ function isSessionTableActionMessage(rpcResponse) {
170
+ var _a, _b;
171
+ return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && (((_a = rpcResponse.action) == null ? void 0 : _a.renderComponent) === "inline-form" || ((_b = rpcResponse.action) == null ? void 0 : _b.renderComponent) === "grid");
172
+ }
173
+
135
174
  // ../vuu-utils/src/datasource/datasource-utils.ts
136
175
  var isConnectionQualityMetrics = (msg) => msg.type === "connection-metrics";
137
176
  var isVisualLinkMessage = (msg) => msg.type.endsWith("_VISUAL_LINK");
@@ -306,45 +345,6 @@ var RangeMonitor = class {
306
345
  }
307
346
  };
308
347
 
309
- // ../vuu-utils/src/protocol-message-utils.ts
310
- var MENU_RPC_TYPES = [
311
- "VIEW_PORT_MENUS_SELECT_RPC",
312
- "VIEW_PORT_MENU_TABLE_RPC",
313
- "VIEW_PORT_MENU_ROW_RPC",
314
- "VIEW_PORT_MENU_CELL_RPC"
315
- ];
316
- var INVALID_SESSION = "Invalid session";
317
- var SESSION_LIMIT_EXCEEDED = "User session limit exceeded";
318
- var INVALID_TOKEN = "Invalid token";
319
- var TOKEN_EXPIRED = "Token has expired";
320
- var InvalidLoginMessages = [
321
- INVALID_SESSION,
322
- SESSION_LIMIT_EXCEEDED,
323
- INVALID_TOKEN,
324
- TOKEN_EXPIRED
325
- ];
326
- var isErrorMessage = (message) => typeof message == "object" && (message == null ? void 0 : message.type) === "ERROR";
327
- var isLoginErrorMessage = (message) => typeof message === "string" && InvalidLoginMessages.includes(message);
328
- var isSelectRequest = (message) => message && typeof message === "object" && "type" in message && (message.type === "SELECT_ROW" || message.type === "DESELECT_ROW" || message.type === "SELECT_ROW_RANGE" || message.type === "SELECT_ALL" || message.type === "DESELECT_ALL");
329
- var isRpcServiceRequest = (message) => message.type === "RPC_REQUEST";
330
- var hasViewPortContext = (message) => message.context.type === "VIEWPORT_CONTEXT";
331
- var isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
332
- var isOpenDialogAction = (action) => action !== void 0 && action.type === "OPEN_DIALOG_ACTION";
333
- var isCreateVpSuccess = (response) => response.type === "CREATE_VP_SUCCESS";
334
- var isSessionTable = (table) => {
335
- if (table !== null && typeof table === "object" && "table" in table && "module" in table) {
336
- return table.table.startsWith("session");
337
- }
338
- return false;
339
- };
340
- function isActionMessage(rpcResponse) {
341
- return rpcResponse.type === "VIEW_PORT_MENU_RESP";
342
- }
343
- function isSessionTableActionMessage(rpcResponse) {
344
- var _a, _b;
345
- return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && (((_a = rpcResponse.action) == null ? void 0 : _a.renderComponent) === "inline-form" || ((_b = rpcResponse.action) == null ? void 0 : _b.renderComponent) === "grid");
346
- }
347
-
348
348
  // ../vuu-utils/src/keyset.ts
349
349
  var EMPTY = [];
350
350
  var KeySet = class {
@@ -592,9 +592,13 @@ var ArrayBackedMovingWindow = class {
592
592
  get range() {
593
593
  return __privateGet(this, _range);
594
594
  }
595
- get hasAllRowsWithinRange() {
596
- return this.rowsWithinRange === this.clientRange.to - this.clientRange.from || this.rowCount > 0 && this.clientRange.from + this.rowsWithinRange === this.rowCount;
597
- }
595
+ // get hasAllRowsWithinRange(): boolean {
596
+ // return (
597
+ // this.rowsWithinRange === this.clientRange.to - this.clientRange.from ||
598
+ // (this.rowCount > 0 &&
599
+ // this.clientRange.from + this.rowsWithinRange === this.rowCount)
600
+ // );
601
+ // }
598
602
  // Check to see if set of rows is outside the current viewport range, indicating
599
603
  // that veiwport is being scrolled quickly and server is not able to keep up.
600
604
  outOfRange(firstIndex, lastIndex) {
@@ -908,9 +912,7 @@ var Viewport = class {
908
912
  this.table = table;
909
913
  this.sort = sort;
910
914
  this.title = title;
911
- infoEnabled && (info == null ? void 0 : info(
912
- \`constructor #\${viewport} \${table.table} bufferSize=\${bufferSize}\`
913
- ));
915
+ infoEnabled && (info == null ? void 0 : info(\`\${table.table} #\${viewport}, bufferSize=\${bufferSize}\`));
914
916
  this.dataWindow = new ArrayBackedMovingWindow(
915
917
  __privateGet(this, _clientRange),
916
918
  range,
@@ -1225,6 +1227,7 @@ var Viewport = class {
1225
1227
  }
1226
1228
  suspend() {
1227
1229
  this.suspended = true;
1230
+ this.pendingUpdates.length = 0;
1228
1231
  info == null ? void 0 : info("suspend");
1229
1232
  }
1230
1233
  resume() {
@@ -1362,9 +1365,11 @@ var Viewport = class {
1362
1365
  }
1363
1366
  if (row.updateType === "U") {
1364
1367
  if ((_c = this.dataWindow) == null ? void 0 : _c.setAtIndex(row)) {
1365
- this.hasUpdates = true;
1366
- if (!this.batchMode) {
1367
- this.pendingUpdates.push(row);
1368
+ if (this.suspended !== true) {
1369
+ this.hasUpdates = true;
1370
+ if (!this.batchMode) {
1371
+ this.pendingUpdates.push(row);
1372
+ }
1368
1373
  }
1369
1374
  }
1370
1375
  }
@@ -1500,9 +1505,9 @@ var WebSocketConnection = class extends EventEmitter {
1500
1505
  __privateAdd(this, _ws);
1501
1506
  __publicField(this, "receive", (evt) => {
1502
1507
  if (isLoginErrorMessage(evt.data)) {
1503
- console.log(\`[WebSocketConnection] closed because of login issue\`);
1508
+ console.warn(\`[WebSocketConnection] closed because of login issue\`);
1504
1509
  if (__privateGet(this, _deferredOpen)) {
1505
- console.log(\`... and qwe have a deferred connection\`);
1510
+ console.warn(\`... and we have a deferred connection\`);
1506
1511
  }
1507
1512
  __privateGet(this, _callback).call(this, {
1508
1513
  type: "LOGIN_REJECTED",
@@ -1513,7 +1518,7 @@ var WebSocketConnection = class extends EventEmitter {
1513
1518
  const vuuMessageFromServer = parseWebSocketMessage(evt.data);
1514
1519
  if (debugEnabled3) {
1515
1520
  if (vuuMessageFromServer.body.type !== "HB") {
1516
- debug3(\`\${vuuMessageFromServer.body.type}\`);
1521
+ debug3(\`<=== \${vuuMessageFromServer.body.type}\`);
1517
1522
  if (vuuMessageFromServer.body.type === "CHANGE_VP_SUCCESS") {
1518
1523
  debug3(JSON.stringify(vuuMessageFromServer.body));
1519
1524
  }
@@ -1532,7 +1537,7 @@ var WebSocketConnection = class extends EventEmitter {
1532
1537
  var _a;
1533
1538
  if (msg.body.type === "CHANGE_VP_RANGE") {
1534
1539
  info2 == null ? void 0 : info2(
1535
- \`CHANGE_VP_RANGE<#\${msg.requestId}> \${msg.body.from}-\${msg.body.to}\`
1540
+ \`===> CHANGE_VP_RANGE<#\${msg.requestId}> \${msg.body.from}-\${msg.body.to}\`
1536
1541
  );
1537
1542
  }
1538
1543
  (_a = __privateGet(this, _ws)) == null ? void 0 : _a.send(JSON.stringify(msg));
@@ -2421,26 +2426,26 @@ var ServerProxy = class {
2421
2426
  if (debugEnabled4) {
2422
2427
  const [firstRow] = body.rows;
2423
2428
  if (body.rows.length === 0) {
2424
- infoEnabled2 && info3("handleMessageFromServer TABLE_ROW 0 rows");
2429
+ infoEnabled2 && info3("<=== TABLE_ROW 0 rows");
2425
2430
  } else if ((firstRow == null ? void 0 : firstRow.rowIndex) === -1) {
2426
2431
  if (body.rows.length === 1) {
2427
2432
  if (firstRow.updateType === "SIZE") {
2428
2433
  infoEnabled2 && info3(
2429
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
2434
+ \`<=== [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
2430
2435
  );
2431
2436
  } else {
2432
2437
  infoEnabled2 && info3(
2433
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
2438
+ \`<=== [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
2434
2439
  );
2435
2440
  }
2436
2441
  } else {
2437
2442
  infoEnabled2 && info3(
2438
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2443
+ \`<=== TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2439
2444
  );
2440
2445
  }
2441
2446
  } else {
2442
2447
  infoEnabled2 && info3(
2443
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2448
+ \`<=== TABLE_ROW \${body.rows.length} rows [\${body.rows.map((r) => r.rowIndex).join(",")}]\`
2444
2449
  );
2445
2450
  }
2446
2451
  }
@@ -2462,7 +2467,9 @@ var ServerProxy = class {
2462
2467
  const viewport = this.viewports.get(body.viewPortId);
2463
2468
  if (viewport) {
2464
2469
  const { from, to } = body;
2465
- infoEnabled2 && info3(\`CHANGE_VP_RANGE_SUCCESS<#\${requestId}> \${from} - \${to}\`);
2470
+ infoEnabled2 && info3(
2471
+ \`<=== CHANGE_VP_RANGE_SUCCESS<#\${requestId}> \${from} - \${to}\`
2472
+ );
2466
2473
  viewport.completeOperation(requestId, from, to);
2467
2474
  }
2468
2475
  }
@@ -2607,7 +2614,7 @@ var ServerProxy = class {
2607
2614
  error2(body.msg);
2608
2615
  break;
2609
2616
  default:
2610
- infoEnabled2 && info3(\`handleMessageFromServer \${body["type"]}.\`);
2617
+ infoEnabled2 && info3(\`<=== \${body["type"]}.\`);
2611
2618
  }
2612
2619
  }
2613
2620
  cacheTableMeta(messageBody) {
@@ -2647,7 +2654,7 @@ var ServerProxy = class {
2647
2654
  const size = viewport.getNewRowCount();
2648
2655
  if (size !== void 0 || rows && rows.length > 0) {
2649
2656
  debugEnabled4 && debug4(
2650
- \`postMessageToClient #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
2657
+ \`===> #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
2651
2658
  );
2652
2659
  if (mode) {
2653
2660
  this.postMessageToClient({
@@ -2714,15 +2721,15 @@ var handleMessageFromClient = async ({
2714
2721
  webSocketConnection == null ? void 0 : webSocketConnection.close();
2715
2722
  break;
2716
2723
  case "subscribe":
2717
- infoEnabled3 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
2724
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2718
2725
  serverProxy.subscribe(message);
2719
2726
  break;
2720
2727
  case "unsubscribe":
2721
- infoEnabled3 && info4(\`client unsubscribe: \${JSON.stringify(message)}\`);
2728
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2722
2729
  serverProxy.unsubscribe(message.viewport);
2723
2730
  break;
2724
2731
  default:
2725
- infoEnabled3 && info4(\`client message: \${JSON.stringify(message)}\`);
2732
+ infoEnabled3 && info4(\`===> \${JSON.stringify(message)}\`);
2726
2733
  serverProxy.handleMessageFromClient(message);
2727
2734
  }
2728
2735
  };