@vuu-ui/vuu-data-react 0.8.18-debug → 0.8.19-debug

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/esm/index.js CHANGED
@@ -30,24 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
31
  mod
32
32
  ));
33
- var __accessCheck = (obj, member, msg) => {
34
- if (!member.has(obj))
35
- throw TypeError("Cannot " + msg);
36
- };
37
- var __privateGet = (obj, member, getter) => {
38
- __accessCheck(obj, member, "read from private field");
39
- return getter ? getter.call(obj) : member.get(obj);
40
- };
41
- var __privateAdd = (obj, member, value) => {
42
- if (member.has(obj))
43
- throw TypeError("Cannot add the same private member more than once");
44
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45
- };
46
- var __privateSet = (obj, member, value, setter) => {
47
- __accessCheck(obj, member, "write to private field");
48
- setter ? setter.call(obj, value) : member.set(obj, value);
49
- return value;
50
- };
51
33
 
52
34
  // ../../node_modules/object-assign/index.js
53
35
  var require_object_assign = __commonJS({
@@ -1956,13 +1938,13 @@ var require_react_dom_development = __commonJS({
1956
1938
  }
1957
1939
  function getStackByFiberInDevAndProd(workInProgress2) {
1958
1940
  try {
1959
- var info2 = "";
1941
+ var info = "";
1960
1942
  var node = workInProgress2;
1961
1943
  do {
1962
- info2 += describeFiber(node);
1944
+ info += describeFiber(node);
1963
1945
  node = node.return;
1964
1946
  } while (node);
1965
- return info2;
1947
+ return info;
1966
1948
  } catch (x) {
1967
1949
  return "\nError generating stack: " + x.message + "\n" + x.stack;
1968
1950
  }
@@ -6614,9 +6596,9 @@ var require_react_dom_development = __commonJS({
6614
6596
  priorFocusedElem.focus();
6615
6597
  }
6616
6598
  for (var i = 0; i < ancestors.length; i++) {
6617
- var info2 = ancestors[i];
6618
- info2.element.scrollLeft = info2.left;
6619
- info2.element.scrollTop = info2.top;
6599
+ var info = ancestors[i];
6600
+ info.element.scrollLeft = info.left;
6601
+ info.element.scrollTop = info.top;
6620
6602
  }
6621
6603
  }
6622
6604
  }
@@ -7919,7 +7901,7 @@ var require_react_dom_development = __commonJS({
7919
7901
  };
7920
7902
  updatedAncestorInfo = function(oldInfo, tag) {
7921
7903
  var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
7922
- var info2 = {
7904
+ var info = {
7923
7905
  tag
7924
7906
  };
7925
7907
  if (inScopeTags.indexOf(tag) !== -1) {
@@ -7934,27 +7916,27 @@ var require_react_dom_development = __commonJS({
7934
7916
  ancestorInfo.listItemTagAutoclosing = null;
7935
7917
  ancestorInfo.dlItemTagAutoclosing = null;
7936
7918
  }
7937
- ancestorInfo.current = info2;
7919
+ ancestorInfo.current = info;
7938
7920
  if (tag === "form") {
7939
- ancestorInfo.formTag = info2;
7921
+ ancestorInfo.formTag = info;
7940
7922
  }
7941
7923
  if (tag === "a") {
7942
- ancestorInfo.aTagInScope = info2;
7924
+ ancestorInfo.aTagInScope = info;
7943
7925
  }
7944
7926
  if (tag === "button") {
7945
- ancestorInfo.buttonTagInScope = info2;
7927
+ ancestorInfo.buttonTagInScope = info;
7946
7928
  }
7947
7929
  if (tag === "nobr") {
7948
- ancestorInfo.nobrTagInScope = info2;
7930
+ ancestorInfo.nobrTagInScope = info;
7949
7931
  }
7950
7932
  if (tag === "p") {
7951
- ancestorInfo.pTagInButtonScope = info2;
7933
+ ancestorInfo.pTagInButtonScope = info;
7952
7934
  }
7953
7935
  if (tag === "li") {
7954
- ancestorInfo.listItemTagAutoclosing = info2;
7936
+ ancestorInfo.listItemTagAutoclosing = info;
7955
7937
  }
7956
7938
  if (tag === "dd" || tag === "dt") {
7957
- ancestorInfo.dlItemTagAutoclosing = info2;
7939
+ ancestorInfo.dlItemTagAutoclosing = info;
7958
7940
  }
7959
7941
  return ancestorInfo;
7960
7942
  };
@@ -8104,11 +8086,11 @@ var require_react_dom_development = __commonJS({
8104
8086
  tagDisplayName = "<" + childTag + ">";
8105
8087
  }
8106
8088
  if (invalidParent) {
8107
- var info2 = "";
8089
+ var info = "";
8108
8090
  if (ancestorTag === "table" && childTag === "tr") {
8109
- info2 += " Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by the browser.";
8091
+ info += " Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by the browser.";
8110
8092
  }
8111
- error2("validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s", tagDisplayName, ancestorTag, whitespaceInfo, info2);
8093
+ error2("validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s", tagDisplayName, ancestorTag, whitespaceInfo, info);
8112
8094
  } else {
8113
8095
  error2("validateDOMNesting(...): %s cannot appear as a descendant of <%s>.", tagDisplayName, ancestorTag);
8114
8096
  }
@@ -8593,7 +8575,7 @@ var require_react_dom_development = __commonJS({
8593
8575
  }
8594
8576
  }
8595
8577
  }
8596
- function checkPropTypes(typeSpecs, values, location2, componentName, element) {
8578
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
8597
8579
  {
8598
8580
  var has2 = Function.call.bind(Object.prototype.hasOwnProperty);
8599
8581
  for (var typeSpecName in typeSpecs) {
@@ -8601,23 +8583,23 @@ var require_react_dom_development = __commonJS({
8601
8583
  var error$1 = void 0;
8602
8584
  try {
8603
8585
  if (typeof typeSpecs[typeSpecName] !== "function") {
8604
- var err = Error((componentName || "React class") + ": " + location2 + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
8586
+ var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
8605
8587
  err.name = "Invariant Violation";
8606
8588
  throw err;
8607
8589
  }
8608
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location2, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
8590
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
8609
8591
  } catch (ex) {
8610
8592
  error$1 = ex;
8611
8593
  }
8612
8594
  if (error$1 && !(error$1 instanceof Error)) {
8613
8595
  setCurrentlyValidatingElement(element);
8614
- error2("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location2, typeSpecName, typeof error$1);
8596
+ error2("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
8615
8597
  setCurrentlyValidatingElement(null);
8616
8598
  }
8617
8599
  if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
8618
8600
  loggedTypeFailures[error$1.message] = true;
8619
8601
  setCurrentlyValidatingElement(element);
8620
- error2("Failed %s type: %s", location2, error$1.message);
8602
+ error2("Failed %s type: %s", location, error$1.message);
8621
8603
  setCurrentlyValidatingElement(null);
8622
8604
  }
8623
8605
  }
@@ -13849,10 +13831,10 @@ var require_react_dom_development = __commonJS({
13849
13831
  }
13850
13832
  }
13851
13833
  if (workInProgress2.ref !== null) {
13852
- var info2 = "";
13834
+ var info = "";
13853
13835
  var ownerName = getCurrentFiberOwnerNameInDevOrNull();
13854
13836
  if (ownerName) {
13855
- info2 += "\n\nCheck the render method of `" + ownerName + "`.";
13837
+ info += "\n\nCheck the render method of `" + ownerName + "`.";
13856
13838
  }
13857
13839
  var warningKey = ownerName || workInProgress2._debugID || "";
13858
13840
  var debugSource = workInProgress2._debugSource;
@@ -13861,7 +13843,7 @@ var require_react_dom_development = __commonJS({
13861
13843
  }
13862
13844
  if (!didWarnAboutFunctionRefs[warningKey]) {
13863
13845
  didWarnAboutFunctionRefs[warningKey] = true;
13864
- error2("Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", info2);
13846
+ error2("Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", info);
13865
13847
  }
13866
13848
  }
13867
13849
  if (typeof Component.getDerivedStateFromProps === "function") {
@@ -18521,19 +18503,19 @@ For more info, visit https://reactjs.org/link/mock-scheduler`);
18521
18503
  break getTag;
18522
18504
  }
18523
18505
  }
18524
- var info2 = "";
18506
+ var info = "";
18525
18507
  {
18526
18508
  if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
18527
- info2 += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
18509
+ info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
18528
18510
  }
18529
18511
  var ownerName = owner ? getComponentName(owner.type) : null;
18530
18512
  if (ownerName) {
18531
- info2 += "\n\nCheck the render method of `" + ownerName + "`.";
18513
+ info += "\n\nCheck the render method of `" + ownerName + "`.";
18532
18514
  }
18533
18515
  }
18534
18516
  {
18535
18517
  {
18536
- throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info2);
18518
+ throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info);
18537
18519
  }
18538
18520
  }
18539
18521
  }
@@ -19626,3293 +19608,8 @@ var MovingWindow = class {
19626
19608
  }
19627
19609
  };
19628
19610
 
19629
- // ../vuu-data-remote/src/connection-manager.ts
19630
- import {
19631
- EventEmitter,
19632
- getLoggingConfigForWorker,
19633
- isConnectionQualityMetrics,
19634
- isConnectionStatusMessage,
19635
- isTableSchema,
19636
- messageHasResult,
19637
- uuid
19638
- } from "@vuu-ui/vuu-utils";
19639
-
19640
- // ../vuu-data-remote/src/data-source.ts
19641
- var datasourceMessages = [
19642
- "config",
19643
- "aggregate",
19644
- "viewport-update",
19645
- "columns",
19646
- "debounce-begin",
19647
- "disabled",
19648
- "enabled",
19649
- "filter",
19650
- "groupBy",
19651
- "vuu-link-created",
19652
- "vuu-link-removed",
19653
- "vuu-links",
19654
- "vuu-menu",
19655
- "sort",
19656
- "subscribed"
19657
- ];
19658
- var shouldMessageBeRoutedToDataSource = (message) => {
19659
- const type = message.type;
19660
- return datasourceMessages.includes(type);
19661
- };
19662
- var isDataSourceConfigMessage = (message) => ["config", "aggregate", "columns", "filter", "groupBy", "sort"].includes(
19663
- message.type
19664
- );
19665
-
19666
- // ../vuu-data-remote/src/server-proxy/messages.ts
19667
- var GET_TABLE_META = "GET_TABLE_META";
19668
-
19669
- // ../vuu-data-remote/src/inlined-worker.js
19670
- var workerSourceCode = `
19671
- var __accessCheck = (obj, member, msg) => {
19672
- if (!member.has(obj))
19673
- throw TypeError("Cannot " + msg);
19674
- };
19675
- var __privateGet = (obj, member, getter) => {
19676
- __accessCheck(obj, member, "read from private field");
19677
- return getter ? getter.call(obj) : member.get(obj);
19678
- };
19679
- var __privateAdd = (obj, member, value) => {
19680
- if (member.has(obj))
19681
- throw TypeError("Cannot add the same private member more than once");
19682
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19683
- };
19684
- var __privateSet = (obj, member, value, setter) => {
19685
- __accessCheck(obj, member, "write to private field");
19686
- setter ? setter.call(obj, value) : member.set(obj, value);
19687
- return value;
19688
- };
19689
-
19690
- // ../vuu-utils/src/array-utils.ts
19691
- function partition(array, test, pass = [], fail = []) {
19692
- for (let i = 0, len = array.length; i < len; i++) {
19693
- (test(array[i], i) ? pass : fail).push(array[i]);
19694
- }
19695
- return [pass, fail];
19696
- }
19697
-
19698
- // ../vuu-utils/src/column-utils.ts
19699
- var metadataKeys = {
19700
- IDX: 0,
19701
- RENDER_IDX: 1,
19702
- IS_LEAF: 2,
19703
- IS_EXPANDED: 3,
19704
- DEPTH: 4,
19705
- COUNT: 5,
19706
- KEY: 6,
19707
- SELECTED: 7,
19708
- count: 8,
19709
- // TODO following only used in datamodel
19710
- PARENT_IDX: "parent_idx",
19711
- IDX_POINTER: "idx_pointer",
19712
- FILTER_COUNT: "filter_count",
19713
- NEXT_FILTER_IDX: "next_filter_idx"
19714
- };
19715
- var { DEPTH, IS_LEAF } = metadataKeys;
19716
-
19717
- // ../vuu-utils/src/cookie-utils.ts
19718
- var getCookieValue = (name) => {
19719
- var _a, _b;
19720
- if (((_a = globalThis.document) == null ? void 0 : _a.cookie) !== void 0) {
19721
- return (_b = globalThis.document.cookie.split("; ").find((row) => row.startsWith(\`\${name}=\`))) == null ? void 0 : _b.split("=")[1];
19722
- }
19723
- };
19724
-
19725
- // ../vuu-utils/src/range-utils.ts
19726
- function getFullRange({ from, to }, bufferSize = 0, rowCount = Number.MAX_SAFE_INTEGER) {
19727
- if (bufferSize === 0) {
19728
- if (rowCount < from) {
19729
- return { from: 0, to: 0 };
19730
- } else {
19731
- return { from, to: Math.min(to, rowCount) };
19732
- }
19733
- } else if (from === 0) {
19734
- return { from, to: Math.min(to + bufferSize, rowCount) };
19735
- } else {
19736
- const rangeSize = to - from;
19737
- const buff = Math.round(bufferSize / 2);
19738
- const shortfallBefore = from - buff < 0;
19739
- const shortFallAfter = rowCount - (to + buff) < 0;
19740
- if (shortfallBefore && shortFallAfter) {
19741
- return { from: 0, to: rowCount };
19742
- } else if (shortfallBefore) {
19743
- return { from: 0, to: rangeSize + bufferSize };
19744
- } else if (shortFallAfter) {
19745
- return {
19746
- from: Math.max(0, rowCount - (rangeSize + bufferSize)),
19747
- to: rowCount
19748
- };
19749
- } else {
19750
- return { from: from - buff, to: to + buff };
19751
- }
19752
- }
19753
- }
19754
- var withinRange = (value, { from, to }) => value >= from && value < to;
19755
- var WindowRange = class _WindowRange {
19756
- constructor(from, to) {
19757
- this.from = from;
19758
- this.to = to;
19759
- }
19760
- isWithin(index) {
19761
- return withinRange(index, this);
19762
- }
19763
- //find the overlap of this range and a new one
19764
- overlap(from, to) {
19765
- return from >= this.to || to < this.from ? [0, 0] : [Math.max(from, this.from), Math.min(to, this.to)];
19766
- }
19767
- copy() {
19768
- return new _WindowRange(this.from, this.to);
19769
- }
19770
- };
19771
-
19772
- // ../vuu-utils/src/datasource-utils.ts
19773
- var isConnectionStatusMessage = (msg) => msg.type === "connection-status";
19774
- var isConnectionQualityMetrics = (msg) => msg.type === "connection-metrics";
19775
- var isViewporttMessage = (msg) => "viewport" in msg;
19776
-
19777
- // ../vuu-utils/src/logging-utils.ts
19778
- var logLevels = ["error", "warn", "info", "debug"];
19779
- var isValidLogLevel = (value) => typeof value === "string" && logLevels.includes(value);
19780
- var DEFAULT_LOG_LEVEL = "error";
19781
- var NO_OP = () => void 0;
19782
- var DEFAULT_DEBUG_LEVEL = false ? "error" : "info";
19783
- var { loggingLevel = DEFAULT_DEBUG_LEVEL } = getLoggingSettings();
19784
- var logger = (category) => {
19785
- const debugEnabled5 = loggingLevel === "debug";
19786
- const infoEnabled5 = debugEnabled5 || loggingLevel === "info";
19787
- const warnEnabled = infoEnabled5 || loggingLevel === "warn";
19788
- const errorEnabled = warnEnabled || loggingLevel === "error";
19789
- const info5 = infoEnabled5 ? (message) => console.info(\`[\${category}] \${message}\`) : NO_OP;
19790
- const warn4 = warnEnabled ? (message) => console.warn(\`[\${category}] \${message}\`) : NO_OP;
19791
- const debug5 = debugEnabled5 ? (message) => console.debug(\`[\${category}] \${message}\`) : NO_OP;
19792
- const error4 = errorEnabled ? (message) => console.error(\`[\${category}] \${message}\`) : NO_OP;
19793
- if (false) {
19794
- return {
19795
- errorEnabled,
19796
- error: error4
19797
- };
19798
- } else {
19799
- return {
19800
- debugEnabled: debugEnabled5,
19801
- infoEnabled: infoEnabled5,
19802
- warnEnabled,
19803
- errorEnabled,
19804
- info: info5,
19805
- warn: warn4,
19806
- debug: debug5,
19807
- error: error4
19808
- };
19809
- }
19810
- };
19811
- function getLoggingSettings() {
19812
- if (typeof loggingSettings !== "undefined") {
19813
- return loggingSettings;
19814
- } else {
19815
- return {
19816
- loggingLevel: getLoggingLevelFromCookie()
19817
- };
19818
- }
19819
- }
19820
- function getLoggingLevelFromCookie() {
19821
- const value = getCookieValue("vuu-logging-level");
19822
- if (isValidLogLevel(value)) {
19823
- return value;
19824
- } else {
19825
- return DEFAULT_LOG_LEVEL;
19826
- }
19827
- }
19828
-
19829
- // ../vuu-utils/src/debug-utils.ts
19830
- var { debug, debugEnabled } = logger("range-monitor");
19831
- var RangeMonitor = class {
19832
- constructor(source) {
19833
- this.source = source;
19834
- this.range = { from: 0, to: 0 };
19835
- this.timestamp = 0;
19836
- }
19837
- isSet() {
19838
- return this.timestamp !== 0;
19839
- }
19840
- set({ from, to }) {
19841
- const { timestamp } = this;
19842
- this.range.from = from;
19843
- this.range.to = to;
19844
- this.timestamp = performance.now();
19845
- if (timestamp) {
19846
- debugEnabled && debug(
19847
- \`<\${this.source}> [\${from}-\${to}], \${(this.timestamp - timestamp).toFixed(0)} ms elapsed\`
19848
- );
19849
- } else {
19850
- return 0;
19851
- }
19852
- }
19853
- };
19854
-
19855
- // ../vuu-utils/src/keyset.ts
19856
- var KeySet = class {
19857
- constructor(range) {
19858
- this.keys = /* @__PURE__ */ new Map();
19859
- this.free = [];
19860
- this.nextKeyValue = 0;
19861
- this.reset(range);
19862
- }
19863
- next() {
19864
- if (this.free.length > 0) {
19865
- return this.free.pop();
19866
- } else {
19867
- return this.nextKeyValue++;
19868
- }
19869
- }
19870
- reset({ from, to }) {
19871
- this.keys.forEach((keyValue, rowIndex) => {
19872
- if (rowIndex < from || rowIndex >= to) {
19873
- this.free.push(keyValue);
19874
- this.keys.delete(rowIndex);
19875
- }
19876
- });
19877
- const size = to - from;
19878
- if (this.keys.size + this.free.length > size) {
19879
- this.free.length = Math.max(0, size - this.keys.size);
19880
- }
19881
- for (let rowIndex = from; rowIndex < to; rowIndex++) {
19882
- if (!this.keys.has(rowIndex)) {
19883
- const nextKeyValue = this.next();
19884
- this.keys.set(rowIndex, nextKeyValue);
19885
- }
19886
- }
19887
- if (this.nextKeyValue > this.keys.size) {
19888
- this.nextKeyValue = this.keys.size;
19889
- }
19890
- }
19891
- keyFor(rowIndex) {
19892
- const key = this.keys.get(rowIndex);
19893
- if (key === void 0) {
19894
- console.log(\`key not found
19895
- keys: \${this.toDebugString()}
19896
- free : \${this.free.join(",")}
19897
- \`);
19898
- throw Error(\`KeySet, no key found for rowIndex \${rowIndex}\`);
19899
- }
19900
- return key;
19901
- }
19902
- toDebugString() {
19903
- return Array.from(this.keys.entries()).map((k, v) => \`\${k}=>\${v}\`).join(",");
19904
- }
19905
- };
19906
-
19907
- // ../vuu-utils/src/selection-utils.ts
19908
- var { SELECTED } = metadataKeys;
19909
- var RowSelected = {
19910
- False: 0,
19911
- True: 1,
19912
- First: 2,
19913
- Last: 4
19914
- };
19915
- var rangeIncludes = (range, index) => index >= range[0] && index <= range[1];
19916
- var SINGLE_SELECTED_ROW = RowSelected.True + RowSelected.First + RowSelected.Last;
19917
- var FIRST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.First;
19918
- var LAST_SELECTED_ROW_OF_BLOCK = RowSelected.True + RowSelected.Last;
19919
- var getSelectionStatus = (selected, itemIndex) => {
19920
- for (const item of selected) {
19921
- if (typeof item === "number") {
19922
- if (item === itemIndex) {
19923
- return SINGLE_SELECTED_ROW;
19924
- }
19925
- } else if (rangeIncludes(item, itemIndex)) {
19926
- if (itemIndex === item[0]) {
19927
- return FIRST_SELECTED_ROW_OF_BLOCK;
19928
- } else if (itemIndex === item[1]) {
19929
- return LAST_SELECTED_ROW_OF_BLOCK;
19930
- } else {
19931
- return RowSelected.True;
19932
- }
19933
- }
19934
- }
19935
- return RowSelected.False;
19936
- };
19937
- var expandSelection = (selected) => {
19938
- if (selected.every((selectedItem) => typeof selectedItem === "number")) {
19939
- return selected;
19940
- }
19941
- const expandedSelected = [];
19942
- for (const selectedItem of selected) {
19943
- if (typeof selectedItem === "number") {
19944
- expandedSelected.push(selectedItem);
19945
- } else {
19946
- for (let i = selectedItem[0]; i <= selectedItem[1]; i++) {
19947
- expandedSelected.push(i);
19948
- }
19949
- }
19950
- }
19951
- return expandedSelected;
19952
- };
19953
-
19954
- // src/data-source.ts
19955
- var isSessionTableActionMessage = (messageBody) => messageBody.type === "VIEW_PORT_MENU_RESP" && messageBody.action !== null && isSessionTable(messageBody.action.table);
19956
- var isSessionTable = (table) => {
19957
- if (table !== null && typeof table === "object" && "table" in table && "module" in table) {
19958
- return table.table.startsWith("session");
19959
- }
19960
- return false;
19961
- };
19962
-
19963
- // src/message-utils.ts
19964
- var MENU_RPC_TYPES = [
19965
- "VIEW_PORT_MENUS_SELECT_RPC",
19966
- "VIEW_PORT_MENU_TABLE_RPC",
19967
- "VIEW_PORT_MENU_ROW_RPC",
19968
- "VIEW_PORT_MENU_CELL_RPC",
19969
- "VP_EDIT_CELL_RPC",
19970
- "VP_EDIT_ROW_RPC",
19971
- "VP_EDIT_ADD_ROW_RPC",
19972
- "VP_EDIT_DELETE_CELL_RPC",
19973
- "VP_EDIT_DELETE_ROW_RPC",
19974
- "VP_EDIT_SUBMIT_FORM_RPC"
19975
- ];
19976
- var isVuuMenuRpcRequest = (message) => MENU_RPC_TYPES.includes(message["type"]);
19977
- var isVuuRpcRequest = (message) => message["type"] === "VIEW_PORT_RPC_CALL";
19978
- var stripRequestId = ({
19979
- requestId,
19980
- ...rest
19981
- }) => [requestId, rest];
19982
- var getFirstAndLastRows = (rows) => {
19983
- let firstRow = rows.at(0);
19984
- if (firstRow.updateType === "SIZE") {
19985
- if (rows.length === 1) {
19986
- return rows;
19987
- } else {
19988
- firstRow = rows.at(1);
19989
- }
19990
- }
19991
- const lastRow = rows.at(-1);
19992
- return [firstRow, lastRow];
19993
- };
19994
- var groupRowsByViewport = (rows) => {
19995
- const result = {};
19996
- for (const row of rows) {
19997
- const rowsForViewport = result[row.viewPortId] || (result[row.viewPortId] = []);
19998
- rowsForViewport.push(row);
19999
- }
20000
- return result;
20001
- };
20002
- var createSchemaFromTableMetadata = ({
20003
- columns,
20004
- dataTypes,
20005
- key,
20006
- table
20007
- }) => {
20008
- return {
20009
- table,
20010
- columns: columns.map((col, idx) => ({
20011
- name: col,
20012
- serverDataType: dataTypes[idx]
20013
- })),
20014
- key
20015
- };
20016
- };
20017
-
20018
- // src/server-proxy/messages.ts
20019
- var CHANGE_VP_SUCCESS = "CHANGE_VP_SUCCESS";
20020
- var CLOSE_TREE_NODE = "CLOSE_TREE_NODE";
20021
- var CLOSE_TREE_SUCCESS = "CLOSE_TREE_SUCCESS";
20022
- var CREATE_VP = "CREATE_VP";
20023
- var DISABLE_VP = "DISABLE_VP";
20024
- var DISABLE_VP_SUCCESS = "DISABLE_VP_SUCCESS";
20025
- var ENABLE_VP = "ENABLE_VP";
20026
- var ENABLE_VP_SUCCESS = "ENABLE_VP_SUCCESS";
20027
- var GET_VP_VISUAL_LINKS = "GET_VP_VISUAL_LINKS";
20028
- var GET_VIEW_PORT_MENUS = "GET_VIEW_PORT_MENUS";
20029
- var HB = "HB";
20030
- var HB_RESP = "HB_RESP";
20031
- var LOGIN = "LOGIN";
20032
- var OPEN_TREE_NODE = "OPEN_TREE_NODE";
20033
- var OPEN_TREE_SUCCESS = "OPEN_TREE_SUCCESS";
20034
- var REMOVE_VP = "REMOVE_VP";
20035
- var SET_SELECTION_SUCCESS = "SET_SELECTION_SUCCESS";
20036
-
20037
- // src/server-proxy/rpc-services.ts
20038
- var getRpcServiceModule = (service) => {
20039
- switch (service) {
20040
- case "TypeAheadRpcHandler":
20041
- return "TYPEAHEAD";
20042
- default:
20043
- return "SIMUL";
20044
- }
20045
- };
20046
-
20047
- // src/server-proxy/array-backed-moving-window.ts
20048
- var EMPTY_ARRAY = [];
20049
- var log = logger("array-backed-moving-window");
20050
- function dataIsUnchanged(newRow, existingRow) {
20051
- if (!existingRow) {
20052
- return false;
20053
- }
20054
- if (existingRow.data.length !== newRow.data.length) {
20055
- return false;
20056
- }
20057
- if (existingRow.sel !== newRow.sel) {
20058
- return false;
20059
- }
20060
- for (let i = 0; i < existingRow.data.length; i++) {
20061
- if (existingRow.data[i] !== newRow.data[i]) {
20062
- return false;
20063
- }
20064
- }
20065
- return true;
20066
- }
20067
- var _range;
20068
- var ArrayBackedMovingWindow = class {
20069
- // Note, the buffer is already accounted for in the range passed in here
20070
- constructor({ from: clientFrom, to: clientTo }, { from, to }, bufferSize) {
20071
- __privateAdd(this, _range, void 0);
20072
- this.setRowCount = (rowCount) => {
20073
- var _a;
20074
- (_a = log.info) == null ? void 0 : _a.call(log, \`setRowCount \${rowCount}\`);
20075
- if (rowCount < this.internalData.length) {
20076
- this.internalData.length = rowCount;
20077
- }
20078
- if (rowCount < this.rowCount) {
20079
- this.rowsWithinRange = 0;
20080
- const end = Math.min(rowCount, this.clientRange.to);
20081
- for (let i = this.clientRange.from; i < end; i++) {
20082
- const rowIndex = i - __privateGet(this, _range).from;
20083
- if (this.internalData[rowIndex] !== void 0) {
20084
- this.rowsWithinRange += 1;
20085
- }
20086
- }
20087
- }
20088
- this.rowCount = rowCount;
20089
- };
20090
- this.bufferBreakout = (from, to) => {
20091
- const bufferPerimeter = this.bufferSize * 0.25;
20092
- if (__privateGet(this, _range).to - to < bufferPerimeter) {
20093
- return true;
20094
- } else if (__privateGet(this, _range).from > 0 && from - __privateGet(this, _range).from < bufferPerimeter) {
20095
- return true;
20096
- } else {
20097
- return false;
20098
- }
20099
- };
20100
- this.bufferSize = bufferSize;
20101
- this.clientRange = new WindowRange(clientFrom, clientTo);
20102
- __privateSet(this, _range, new WindowRange(from, to));
20103
- this.internalData = new Array(bufferSize);
20104
- this.rowsWithinRange = 0;
20105
- this.rowCount = 0;
20106
- }
20107
- get range() {
20108
- return __privateGet(this, _range);
20109
- }
20110
- // TODO we shpuld probably have a hasAllClientRowsWithinRange
20111
- get hasAllRowsWithinRange() {
20112
- return this.rowsWithinRange === this.clientRange.to - this.clientRange.from || // this.rowsWithinRange === this.range.to - this.range.from ||
20113
- this.rowCount > 0 && this.clientRange.from + this.rowsWithinRange === this.rowCount;
20114
- }
20115
- // Check to see if set of rows is outside the current viewport range, indicating
20116
- // that veiwport is being scrolled quickly and server is not able to keep up.
20117
- outOfRange(firstIndex, lastIndex) {
20118
- const { from, to } = this.range;
20119
- if (lastIndex < from) {
20120
- return true;
20121
- }
20122
- if (firstIndex >= to) {
20123
- return true;
20124
- }
20125
- }
20126
- setAtIndex(row) {
20127
- const { rowIndex: index } = row;
20128
- const internalIndex = index - __privateGet(this, _range).from;
20129
- if (dataIsUnchanged(row, this.internalData[internalIndex])) {
20130
- return false;
20131
- }
20132
- const isWithinClientRange = this.isWithinClientRange(index);
20133
- if (isWithinClientRange || this.isWithinRange(index)) {
20134
- if (!this.internalData[internalIndex] && isWithinClientRange) {
20135
- this.rowsWithinRange += 1;
20136
- }
20137
- this.internalData[internalIndex] = row;
20138
- }
20139
- return isWithinClientRange;
20140
- }
20141
- getAtIndex(index) {
20142
- return __privateGet(this, _range).isWithin(index) && this.internalData[index - __privateGet(this, _range).from] != null ? this.internalData[index - __privateGet(this, _range).from] : void 0;
20143
- }
20144
- isWithinRange(index) {
20145
- return __privateGet(this, _range).isWithin(index);
20146
- }
20147
- isWithinClientRange(index) {
20148
- return this.clientRange.isWithin(index);
20149
- }
20150
- // Returns [false] or [serverDataRequired, clientRows, holdingRows]
20151
- setClientRange(from, to) {
20152
- var _a;
20153
- (_a = log.debug) == null ? void 0 : _a.call(log, \`setClientRange \${from} - \${to}\`);
20154
- const currentFrom = this.clientRange.from;
20155
- const currentTo = Math.min(this.clientRange.to, this.rowCount);
20156
- if (from === currentFrom && to === currentTo) {
20157
- return [
20158
- false,
20159
- EMPTY_ARRAY
20160
- /*, EMPTY_ARRAY*/
20161
- ];
20162
- }
20163
- const originalRange = this.clientRange.copy();
20164
- this.clientRange.from = from;
20165
- this.clientRange.to = to;
20166
- this.rowsWithinRange = 0;
20167
- for (let i = from; i < to; i++) {
20168
- const internalIndex = i - __privateGet(this, _range).from;
20169
- if (this.internalData[internalIndex]) {
20170
- this.rowsWithinRange += 1;
20171
- }
20172
- }
20173
- let clientRows = EMPTY_ARRAY;
20174
- const offset = __privateGet(this, _range).from;
20175
- if (this.hasAllRowsWithinRange) {
20176
- if (to > originalRange.to) {
20177
- const start = Math.max(from, originalRange.to);
20178
- clientRows = this.internalData.slice(start - offset, to - offset);
20179
- } else {
20180
- const end = Math.min(originalRange.from, to);
20181
- clientRows = this.internalData.slice(from - offset, end - offset);
20182
- }
20183
- }
20184
- const serverDataRequired = this.bufferBreakout(from, to);
20185
- return [serverDataRequired, clientRows];
20186
- }
20187
- setRange(from, to) {
20188
- var _a, _b;
20189
- if (from !== __privateGet(this, _range).from || to !== __privateGet(this, _range).to) {
20190
- (_a = log.debug) == null ? void 0 : _a.call(log, \`setRange \${from} - \${to}\`);
20191
- const [overlapFrom, overlapTo] = __privateGet(this, _range).overlap(from, to);
20192
- const newData = new Array(to - from);
20193
- this.rowsWithinRange = 0;
20194
- for (let i = overlapFrom; i < overlapTo; i++) {
20195
- const data = this.getAtIndex(i);
20196
- if (data) {
20197
- const index = i - from;
20198
- newData[index] = data;
20199
- if (this.isWithinClientRange(i)) {
20200
- this.rowsWithinRange += 1;
20201
- }
20202
- }
20203
- }
20204
- this.internalData = newData;
20205
- __privateGet(this, _range).from = from;
20206
- __privateGet(this, _range).to = to;
20207
- } else {
20208
- (_b = log.debug) == null ? void 0 : _b.call(log, \`setRange \${from} - \${to} IGNORED because not changed\`);
20209
- }
20210
- }
20211
- //TODO temp
20212
- get data() {
20213
- return this.internalData;
20214
- }
20215
- getData() {
20216
- var _a;
20217
- const { from, to } = __privateGet(this, _range);
20218
- const { from: clientFrom, to: clientTo } = this.clientRange;
20219
- const startOffset = Math.max(0, clientFrom - from);
20220
- const endOffset = Math.min(
20221
- to - from,
20222
- to,
20223
- clientTo - from,
20224
- (_a = this.rowCount) != null ? _a : to
20225
- );
20226
- return this.internalData.slice(startOffset, endOffset);
20227
- }
20228
- clear() {
20229
- var _a;
20230
- (_a = log.debug) == null ? void 0 : _a.call(log, "clear");
20231
- this.internalData.length = 0;
20232
- this.rowsWithinRange = 0;
20233
- this.setRowCount(0);
20234
- }
20235
- // used only for debugging
20236
- getCurrentDataRange() {
20237
- const rows = this.internalData;
20238
- const len = rows.length;
20239
- let [firstRow] = this.internalData;
20240
- let lastRow = this.internalData[len - 1];
20241
- if (firstRow && lastRow) {
20242
- return [firstRow.rowIndex, lastRow.rowIndex];
20243
- } else {
20244
- for (let i = 0; i < len; i++) {
20245
- if (rows[i] !== void 0) {
20246
- firstRow = rows[i];
20247
- break;
20248
- }
20249
- }
20250
- for (let i = len - 1; i >= 0; i--) {
20251
- if (rows[i] !== void 0) {
20252
- lastRow = rows[i];
20253
- break;
20254
- }
20255
- }
20256
- if (firstRow && lastRow) {
20257
- return [firstRow.rowIndex, lastRow.rowIndex];
20258
- } else {
20259
- return [-1, -1];
20260
- }
20261
- }
20262
- }
20263
- };
20264
- _range = new WeakMap();
20265
-
20266
- // src/server-proxy/viewport.ts
20267
- var EMPTY_GROUPBY = [];
20268
- var { debug: debug2, debugEnabled: debugEnabled2, error, info, infoEnabled, warn } = logger("viewport");
20269
- var isLeafUpdate = ({ rowKey, updateType }) => updateType === "U" && !rowKey.startsWith("$root");
20270
- var NO_DATA_UPDATE = [
20271
- void 0,
20272
- void 0
20273
- ];
20274
- var NO_UPDATE_STATUS = {
20275
- count: 0,
20276
- mode: void 0,
20277
- size: 0,
20278
- ts: 0
20279
- };
20280
- var Viewport = class {
20281
- constructor({
20282
- aggregations,
20283
- bufferSize = 50,
20284
- columns,
20285
- filter,
20286
- groupBy = [],
20287
- table,
20288
- range,
20289
- sort,
20290
- title,
20291
- viewport,
20292
- visualLink
20293
- }, postMessageToClient) {
20294
- /** batchMode is irrelevant for Vuu Table, it was introduced to try and improve rendering performance of AgGrid */
20295
- this.batchMode = true;
20296
- this.hasUpdates = false;
20297
- this.pendingUpdates = [];
20298
- this.pendingOperations = /* @__PURE__ */ new Map();
20299
- this.pendingRangeRequests = [];
20300
- this.rowCountChanged = false;
20301
- this.selectedRows = [];
20302
- this.useBatchMode = true;
20303
- this.lastUpdateStatus = NO_UPDATE_STATUS;
20304
- this.updateThrottleTimer = void 0;
20305
- this.rangeMonitor = new RangeMonitor("ViewPort");
20306
- this.disabled = false;
20307
- this.isTree = false;
20308
- // TODO roll disabled/suspended into status
20309
- this.status = "";
20310
- this.suspended = false;
20311
- this.suspendTimer = null;
20312
- // Records SIZE only updates
20313
- this.setLastSizeOnlyUpdateSize = (size) => {
20314
- this.lastUpdateStatus.size = size;
20315
- };
20316
- this.setLastUpdate = (mode) => {
20317
- const { ts: lastTS, mode: lastMode } = this.lastUpdateStatus;
20318
- let elapsedTime = 0;
20319
- if (lastMode === mode) {
20320
- const ts = Date.now();
20321
- this.lastUpdateStatus.count += 1;
20322
- this.lastUpdateStatus.ts = ts;
20323
- elapsedTime = lastTS === 0 ? 0 : ts - lastTS;
20324
- } else {
20325
- this.lastUpdateStatus.count = 1;
20326
- this.lastUpdateStatus.ts = 0;
20327
- elapsedTime = 0;
20328
- }
20329
- this.lastUpdateStatus.mode = mode;
20330
- return elapsedTime;
20331
- };
20332
- this.rangeRequestAlreadyPending = (range) => {
20333
- const { bufferSize } = this;
20334
- const bufferThreshold = bufferSize * 0.25;
20335
- let { from: stillPendingFrom } = range;
20336
- for (const { from, to } of this.pendingRangeRequests) {
20337
- if (stillPendingFrom >= from && stillPendingFrom < to) {
20338
- if (range.to + bufferThreshold <= to) {
20339
- return true;
20340
- } else {
20341
- stillPendingFrom = to;
20342
- }
20343
- }
20344
- }
20345
- return false;
20346
- };
20347
- this.sendThrottledSizeMessage = () => {
20348
- this.updateThrottleTimer = void 0;
20349
- this.lastUpdateStatus.count = 3;
20350
- this.postMessageToClient({
20351
- clientViewportId: this.clientViewportId,
20352
- mode: "size-only",
20353
- size: this.lastUpdateStatus.size,
20354
- type: "viewport-update"
20355
- });
20356
- };
20357
- // If we are receiving multiple SIZE updates but no data, table is loading rows
20358
- // outside of our viewport. We can safely throttle these requests. Doing so will
20359
- // alleviate pressure on UI DataTable.
20360
- this.shouldThrottleMessage = (mode) => {
20361
- const elapsedTime = this.setLastUpdate(mode);
20362
- return mode === "size-only" && elapsedTime > 0 && elapsedTime < 500 && this.lastUpdateStatus.count > 3;
20363
- };
20364
- this.throttleMessage = (mode) => {
20365
- if (this.shouldThrottleMessage(mode)) {
20366
- info == null ? void 0 : info("throttling updates setTimeout to 2000");
20367
- if (this.updateThrottleTimer === void 0) {
20368
- this.updateThrottleTimer = setTimeout(
20369
- this.sendThrottledSizeMessage,
20370
- 2e3
20371
- );
20372
- }
20373
- return true;
20374
- } else if (this.updateThrottleTimer !== void 0) {
20375
- clearTimeout(this.updateThrottleTimer);
20376
- this.updateThrottleTimer = void 0;
20377
- }
20378
- return false;
20379
- };
20380
- this.getNewRowCount = () => {
20381
- if (this.rowCountChanged && this.dataWindow) {
20382
- this.rowCountChanged = false;
20383
- return this.dataWindow.rowCount;
20384
- }
20385
- };
20386
- this.aggregations = aggregations;
20387
- this.bufferSize = bufferSize;
20388
- this.clientRange = range;
20389
- this.clientViewportId = viewport;
20390
- this.columns = columns;
20391
- this.filter = filter;
20392
- this.groupBy = groupBy;
20393
- this.keys = new KeySet(range);
20394
- this.pendingLinkedParent = visualLink;
20395
- this.table = table;
20396
- this.sort = sort;
20397
- this.title = title;
20398
- infoEnabled && (info == null ? void 0 : info(
20399
- \`constructor #\${viewport} \${table.table} bufferSize=\${bufferSize}\`
20400
- ));
20401
- this.dataWindow = new ArrayBackedMovingWindow(
20402
- this.clientRange,
20403
- range,
20404
- this.bufferSize
20405
- );
20406
- this.postMessageToClient = postMessageToClient;
20407
- }
20408
- get hasUpdatesToProcess() {
20409
- if (this.suspended) {
20410
- return false;
20411
- }
20412
- return this.rowCountChanged || this.hasUpdates;
20413
- }
20414
- get size() {
20415
- var _a;
20416
- return (_a = this.dataWindow.rowCount) != null ? _a : 0;
20417
- }
20418
- subscribe() {
20419
- const { filter } = this.filter;
20420
- this.status = this.status === "subscribed" ? "resubscribing" : "subscribing";
20421
- return {
20422
- type: CREATE_VP,
20423
- table: this.table,
20424
- range: getFullRange(this.clientRange, this.bufferSize),
20425
- aggregations: this.aggregations,
20426
- columns: this.columns,
20427
- sort: this.sort,
20428
- groupBy: this.groupBy,
20429
- filterSpec: { filter }
20430
- };
20431
- }
20432
- handleSubscribed({
20433
- viewPortId,
20434
- aggregations,
20435
- columns,
20436
- filterSpec: filter,
20437
- range,
20438
- sort,
20439
- groupBy
20440
- }, tableSchema) {
20441
- this.serverViewportId = viewPortId;
20442
- this.status = "subscribed";
20443
- this.aggregations = aggregations;
20444
- this.columns = columns;
20445
- this.groupBy = groupBy;
20446
- this.isTree = groupBy && groupBy.length > 0;
20447
- this.dataWindow.setRange(range.from, range.to);
20448
- return {
20449
- aggregations,
20450
- type: "subscribed",
20451
- clientViewportId: this.clientViewportId,
20452
- columns,
20453
- filter,
20454
- groupBy,
20455
- range,
20456
- sort,
20457
- tableSchema
20458
- };
20459
- }
20460
- awaitOperation(requestId, msg) {
20461
- this.pendingOperations.set(requestId, msg);
20462
- }
20463
- // Return a message if we need to communicate this to client UI
20464
- completeOperation(requestId, ...params) {
20465
- var _a;
20466
- const { clientViewportId, pendingOperations } = this;
20467
- const pendingOperation = pendingOperations.get(requestId);
20468
- if (!pendingOperation) {
20469
- error(
20470
- \`no matching operation found to complete for requestId \${requestId}\`
20471
- );
20472
- return;
20473
- }
20474
- const { type } = pendingOperation;
20475
- info == null ? void 0 : info(\`completeOperation \${type}\`);
20476
- pendingOperations.delete(requestId);
20477
- if (type === "CHANGE_VP_RANGE") {
20478
- const [from, to] = params;
20479
- (_a = this.dataWindow) == null ? void 0 : _a.setRange(from, to);
20480
- for (let i = this.pendingRangeRequests.length - 1; i >= 0; i--) {
20481
- const pendingRangeRequest = this.pendingRangeRequests[i];
20482
- if (pendingRangeRequest.requestId === requestId) {
20483
- pendingRangeRequest.acked = true;
20484
- break;
20485
- } else {
20486
- warn == null ? void 0 : warn("range requests sent faster than they are being ACKed");
20487
- }
20488
- }
20489
- } else if (type === "config") {
20490
- const { aggregations, columns, filter, groupBy, sort } = pendingOperation.data;
20491
- this.aggregations = aggregations;
20492
- this.columns = columns;
20493
- this.filter = filter;
20494
- this.groupBy = groupBy;
20495
- this.sort = sort;
20496
- if (groupBy.length > 0) {
20497
- this.isTree = true;
20498
- } else if (this.isTree) {
20499
- this.isTree = false;
20500
- }
20501
- debug2 == null ? void 0 : debug2(\`config change confirmed, isTree : \${this.isTree}\`);
20502
- return {
20503
- clientViewportId,
20504
- type,
20505
- config: pendingOperation.data
20506
- };
20507
- } else if (type === "groupBy") {
20508
- this.isTree = pendingOperation.data.length > 0;
20509
- this.groupBy = pendingOperation.data;
20510
- debug2 == null ? void 0 : debug2(\`groupBy change confirmed, isTree : \${this.isTree}\`);
20511
- return {
20512
- clientViewportId,
20513
- type,
20514
- groupBy: pendingOperation.data
20515
- };
20516
- } else if (type === "columns") {
20517
- this.columns = pendingOperation.data;
20518
- return {
20519
- clientViewportId,
20520
- type,
20521
- columns: pendingOperation.data
20522
- };
20523
- } else if (type === "filter") {
20524
- this.filter = pendingOperation.data;
20525
- return {
20526
- clientViewportId,
20527
- type,
20528
- filter: pendingOperation.data
20529
- };
20530
- } else if (type === "aggregate") {
20531
- this.aggregations = pendingOperation.data;
20532
- return {
20533
- clientViewportId,
20534
- type: "aggregate",
20535
- aggregations: this.aggregations
20536
- };
20537
- } else if (type === "sort") {
20538
- this.sort = pendingOperation.data;
20539
- return {
20540
- clientViewportId,
20541
- type,
20542
- sort: this.sort
20543
- };
20544
- } else if (type === "selection") {
20545
- } else if (type === "disable") {
20546
- this.disabled = true;
20547
- return {
20548
- type: "disabled",
20549
- clientViewportId
20550
- };
20551
- } else if (type === "enable") {
20552
- this.disabled = false;
20553
- return {
20554
- type: "enabled",
20555
- clientViewportId
20556
- };
20557
- } else if (type === "CREATE_VISUAL_LINK") {
20558
- const [colName, parentViewportId, parentColName] = params;
20559
- this.linkedParent = {
20560
- colName,
20561
- parentViewportId,
20562
- parentColName
20563
- };
20564
- this.pendingLinkedParent = void 0;
20565
- return {
20566
- type: "vuu-link-created",
20567
- clientViewportId,
20568
- colName,
20569
- parentViewportId,
20570
- parentColName
20571
- };
20572
- } else if (type === "REMOVE_VISUAL_LINK") {
20573
- this.linkedParent = void 0;
20574
- return {
20575
- type: "vuu-link-removed",
20576
- clientViewportId
20577
- };
20578
- }
20579
- }
20580
- // TODO when a range request arrives, consider the viewport to be scrolling
20581
- // until data arrives and we have the full range.
20582
- // When not scrolling, any server data is an update
20583
- // When scrolling, we are in batch mode
20584
- rangeRequest(requestId, range) {
20585
- if (debugEnabled2) {
20586
- this.rangeMonitor.set(range);
20587
- }
20588
- const type = "CHANGE_VP_RANGE";
20589
- if (this.dataWindow) {
20590
- const [serverDataRequired, clientRows] = this.dataWindow.setClientRange(
20591
- range.from,
20592
- range.to
20593
- );
20594
- let debounceRequest;
20595
- const maxRange = this.dataWindow.rowCount || void 0;
20596
- const serverRequest = serverDataRequired && !this.rangeRequestAlreadyPending(range) ? {
20597
- type,
20598
- viewPortId: this.serverViewportId,
20599
- ...getFullRange(range, this.bufferSize, maxRange)
20600
- } : null;
20601
- if (serverRequest) {
20602
- debugEnabled2 && (debug2 == null ? void 0 : debug2(
20603
- \`create CHANGE_VP_RANGE: [\${serverRequest.from} - \${serverRequest.to}]\`
20604
- ));
20605
- this.awaitOperation(requestId, { type });
20606
- const pendingRequest = this.pendingRangeRequests.at(-1);
20607
- if (pendingRequest) {
20608
- if (pendingRequest.acked) {
20609
- console.warn("Range Request before previous request is filled");
20610
- } else {
20611
- const { from, to } = pendingRequest;
20612
- if (this.dataWindow.outOfRange(from, to)) {
20613
- debounceRequest = {
20614
- clientViewportId: this.clientViewportId,
20615
- type: "debounce-begin"
20616
- };
20617
- } else {
20618
- warn == null ? void 0 : warn("Range Request before previous request is acked");
20619
- }
20620
- }
20621
- }
20622
- this.pendingRangeRequests.push({ ...serverRequest, requestId });
20623
- if (this.useBatchMode) {
20624
- this.batchMode = true;
20625
- }
20626
- } else if (clientRows.length > 0) {
20627
- this.batchMode = false;
20628
- }
20629
- this.keys.reset(this.dataWindow.clientRange);
20630
- const toClient = this.isTree ? toClientRowTree : toClientRow;
20631
- if (clientRows.length) {
20632
- return [
20633
- serverRequest,
20634
- clientRows.map((row) => {
20635
- return toClient(row, this.keys, this.selectedRows);
20636
- })
20637
- ];
20638
- } else if (debounceRequest) {
20639
- return [serverRequest, void 0, debounceRequest];
20640
- } else {
20641
- return [serverRequest];
20642
- }
20643
- } else {
20644
- return [null];
20645
- }
20646
- }
20647
- setLinks(links) {
20648
- this.links = links;
20649
- return [
20650
- {
20651
- type: "vuu-links",
20652
- links,
20653
- clientViewportId: this.clientViewportId
20654
- },
20655
- this.pendingLinkedParent
20656
- ];
20657
- }
20658
- setMenu(menu) {
20659
- return {
20660
- type: "vuu-menu",
20661
- menu,
20662
- clientViewportId: this.clientViewportId
20663
- };
20664
- }
20665
- openTreeNode(requestId, message) {
20666
- if (this.useBatchMode) {
20667
- this.batchMode = true;
20668
- }
20669
- return {
20670
- type: OPEN_TREE_NODE,
20671
- vpId: this.serverViewportId,
20672
- treeKey: message.key
20673
- };
20674
- }
20675
- closeTreeNode(requestId, message) {
20676
- if (this.useBatchMode) {
20677
- this.batchMode = true;
20678
- }
20679
- return {
20680
- type: CLOSE_TREE_NODE,
20681
- vpId: this.serverViewportId,
20682
- treeKey: message.key
20683
- };
20684
- }
20685
- createLink(requestId, colName, parentVpId, parentColumnName) {
20686
- const message = {
20687
- type: "CREATE_VISUAL_LINK",
20688
- parentVpId,
20689
- childVpId: this.serverViewportId,
20690
- parentColumnName,
20691
- childColumnName: colName
20692
- };
20693
- this.awaitOperation(requestId, message);
20694
- if (this.useBatchMode) {
20695
- this.batchMode = true;
20696
- }
20697
- return message;
20698
- }
20699
- removeLink(requestId) {
20700
- const message = {
20701
- type: "REMOVE_VISUAL_LINK",
20702
- childVpId: this.serverViewportId
20703
- };
20704
- this.awaitOperation(requestId, message);
20705
- return message;
20706
- }
20707
- suspend() {
20708
- this.suspended = true;
20709
- info == null ? void 0 : info("suspend");
20710
- }
20711
- resume() {
20712
- this.suspended = false;
20713
- if (debugEnabled2) {
20714
- debug2 == null ? void 0 : debug2(\`resume: \${this.currentData()}\`);
20715
- }
20716
- return [this.size, this.currentData()];
20717
- }
20718
- currentData() {
20719
- const out = [];
20720
- if (this.dataWindow) {
20721
- const records = this.dataWindow.getData();
20722
- const { keys } = this;
20723
- const toClient = this.isTree ? toClientRowTree : toClientRow;
20724
- for (const row of records) {
20725
- if (row) {
20726
- out.push(toClient(row, keys, this.selectedRows));
20727
- }
20728
- }
20729
- }
20730
- return out;
20731
- }
20732
- enable(requestId) {
20733
- this.awaitOperation(requestId, { type: "enable" });
20734
- info == null ? void 0 : info(\`enable: \${this.serverViewportId}\`);
20735
- return {
20736
- type: ENABLE_VP,
20737
- viewPortId: this.serverViewportId
20738
- };
20739
- }
20740
- disable(requestId) {
20741
- this.awaitOperation(requestId, { type: "disable" });
20742
- info == null ? void 0 : info(\`disable: \${this.serverViewportId}\`);
20743
- this.suspended = false;
20744
- return {
20745
- type: DISABLE_VP,
20746
- viewPortId: this.serverViewportId
20747
- };
20748
- }
20749
- columnRequest(requestId, columns) {
20750
- this.awaitOperation(requestId, {
20751
- type: "columns",
20752
- data: columns
20753
- });
20754
- debug2 == null ? void 0 : debug2(\`columnRequest: \${columns}\`);
20755
- return this.createRequest({ columns });
20756
- }
20757
- filterRequest(requestId, dataSourceFilter) {
20758
- this.awaitOperation(requestId, {
20759
- type: "filter",
20760
- data: dataSourceFilter
20761
- });
20762
- if (this.useBatchMode) {
20763
- this.batchMode = true;
20764
- }
20765
- const { filter } = dataSourceFilter;
20766
- info == null ? void 0 : info(\`filterRequest: \${filter}\`);
20767
- return this.createRequest({ filterSpec: { filter } });
20768
- }
20769
- setConfig(requestId, config) {
20770
- this.awaitOperation(requestId, { type: "config", data: config });
20771
- const { filter, ...remainingConfig } = config;
20772
- if (this.useBatchMode) {
20773
- this.batchMode = true;
20774
- }
20775
- debugEnabled2 ? debug2 == null ? void 0 : debug2(\`setConfig \${JSON.stringify(config)}\`) : info == null ? void 0 : info(\`setConfig\`);
20776
- return this.createRequest(
20777
- {
20778
- ...remainingConfig,
20779
- filterSpec: typeof (filter == null ? void 0 : filter.filter) === "string" ? {
20780
- filter: filter.filter
20781
- } : {
20782
- filter: ""
20783
- }
20784
- },
20785
- true
20786
- );
20787
- }
20788
- aggregateRequest(requestId, aggregations) {
20789
- this.awaitOperation(requestId, { type: "aggregate", data: aggregations });
20790
- info == null ? void 0 : info(\`aggregateRequest: \${aggregations}\`);
20791
- return this.createRequest({ aggregations });
20792
- }
20793
- sortRequest(requestId, sort) {
20794
- this.awaitOperation(requestId, { type: "sort", data: sort });
20795
- info == null ? void 0 : info(\`sortRequest: \${JSON.stringify(sort.sortDefs)}\`);
20796
- return this.createRequest({ sort });
20797
- }
20798
- groupByRequest(requestId, groupBy = EMPTY_GROUPBY) {
20799
- var _a;
20800
- this.awaitOperation(requestId, { type: "groupBy", data: groupBy });
20801
- if (this.useBatchMode) {
20802
- this.batchMode = true;
20803
- }
20804
- if (!this.isTree) {
20805
- (_a = this.dataWindow) == null ? void 0 : _a.clear();
20806
- }
20807
- return this.createRequest({ groupBy });
20808
- }
20809
- selectRequest(requestId, selected) {
20810
- this.selectedRows = selected;
20811
- this.awaitOperation(requestId, { type: "selection", data: selected });
20812
- info == null ? void 0 : info(\`selectRequest: \${selected}\`);
20813
- return {
20814
- type: "SET_SELECTION",
20815
- vpId: this.serverViewportId,
20816
- selection: expandSelection(selected)
20817
- };
20818
- }
20819
- removePendingRangeRequest(firstIndex, lastIndex) {
20820
- for (let i = this.pendingRangeRequests.length - 1; i >= 0; i--) {
20821
- const { from, to } = this.pendingRangeRequests[i];
20822
- let isLast = true;
20823
- if (firstIndex >= from && firstIndex < to || lastIndex > from && lastIndex < to) {
20824
- if (!isLast) {
20825
- console.warn(
20826
- "removePendingRangeRequest TABLE_ROWS are not for latest request"
20827
- );
20828
- }
20829
- this.pendingRangeRequests.splice(i, 1);
20830
- break;
20831
- } else {
20832
- isLast = false;
20833
- }
20834
- }
20835
- }
20836
- updateRows(rows) {
20837
- var _a, _b, _c;
20838
- const [firstRow, lastRow] = getFirstAndLastRows(rows);
20839
- if (firstRow && lastRow) {
20840
- this.removePendingRangeRequest(firstRow.rowIndex, lastRow.rowIndex);
20841
- }
20842
- if (rows.length === 1) {
20843
- if (firstRow.vpSize === 0 && this.disabled) {
20844
- debug2 == null ? void 0 : debug2(
20845
- \`ignore a SIZE=0 message on disabled viewport (\${rows.length} rows)\`
20846
- );
20847
- return;
20848
- } else if (firstRow.updateType === "SIZE") {
20849
- this.setLastSizeOnlyUpdateSize(firstRow.vpSize);
20850
- }
20851
- }
20852
- for (const row of rows) {
20853
- if (this.isTree && isLeafUpdate(row)) {
20854
- continue;
20855
- } else {
20856
- if (row.updateType === "SIZE" || ((_a = this.dataWindow) == null ? void 0 : _a.rowCount) !== row.vpSize) {
20857
- (_b = this.dataWindow) == null ? void 0 : _b.setRowCount(row.vpSize);
20858
- this.rowCountChanged = true;
20859
- }
20860
- if (row.updateType === "U") {
20861
- if ((_c = this.dataWindow) == null ? void 0 : _c.setAtIndex(row)) {
20862
- this.hasUpdates = true;
20863
- if (!this.batchMode) {
20864
- this.pendingUpdates.push(row);
20865
- }
20866
- }
20867
- }
20868
- }
20869
- }
20870
- }
20871
- // This is called only after new data has been received from server - data
20872
- // returned direcly from buffer does not use this.
20873
- getClientRows() {
20874
- let out = void 0;
20875
- let mode = "size-only";
20876
- if (!this.hasUpdates && !this.rowCountChanged) {
20877
- return NO_DATA_UPDATE;
20878
- }
20879
- if (this.hasUpdates) {
20880
- const { keys, selectedRows } = this;
20881
- const toClient = this.isTree ? toClientRowTree : toClientRow;
20882
- if (this.updateThrottleTimer) {
20883
- self.clearTimeout(this.updateThrottleTimer);
20884
- this.updateThrottleTimer = void 0;
20885
- }
20886
- if (this.pendingUpdates.length > 0) {
20887
- out = [];
20888
- mode = "update";
20889
- for (const row of this.pendingUpdates) {
20890
- out.push(toClient(row, keys, selectedRows));
20891
- }
20892
- this.pendingUpdates.length = 0;
20893
- } else {
20894
- const records = this.dataWindow.getData();
20895
- if (this.dataWindow.hasAllRowsWithinRange) {
20896
- out = [];
20897
- mode = "batch";
20898
- for (const row of records) {
20899
- out.push(toClient(row, keys, selectedRows));
20900
- }
20901
- this.batchMode = false;
20902
- }
20903
- }
20904
- this.hasUpdates = false;
20905
- }
20906
- if (this.throttleMessage(mode)) {
20907
- return NO_DATA_UPDATE;
20908
- } else {
20909
- return [out, mode];
20910
- }
20911
- }
20912
- createRequest(params, overWrite = false) {
20913
- if (overWrite) {
20914
- return {
20915
- type: "CHANGE_VP",
20916
- viewPortId: this.serverViewportId,
20917
- ...params
20918
- };
20919
- } else {
20920
- return {
20921
- type: "CHANGE_VP",
20922
- viewPortId: this.serverViewportId,
20923
- aggregations: this.aggregations,
20924
- columns: this.columns,
20925
- sort: this.sort,
20926
- groupBy: this.groupBy,
20927
- filterSpec: {
20928
- filter: this.filter.filter
20929
- },
20930
- ...params
20931
- };
20932
- }
20933
- }
20934
- };
20935
- var toClientRow = ({ rowIndex, rowKey, sel: isSelected, data }, keys, selectedRows) => {
20936
- return [
20937
- rowIndex,
20938
- keys.keyFor(rowIndex),
20939
- true,
20940
- false,
20941
- 0,
20942
- 0,
20943
- rowKey,
20944
- isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0
20945
- ].concat(data);
20946
- };
20947
- var toClientRowTree = ({ rowIndex, rowKey, sel: isSelected, data }, keys, selectedRows) => {
20948
- const [depth, isExpanded, , isLeaf, , count, ...rest] = data;
20949
- return [
20950
- rowIndex,
20951
- keys.keyFor(rowIndex),
20952
- isLeaf,
20953
- isExpanded,
20954
- depth,
20955
- count,
20956
- rowKey,
20957
- isSelected ? getSelectionStatus(selectedRows, rowIndex) : 0
20958
- ].concat(rest);
20959
- };
20960
-
20961
- // src/server-proxy/server-proxy.ts
20962
- var _requestId = 1;
20963
- var { debug: debug3, debugEnabled: debugEnabled3, error: error2, info: info2, infoEnabled: infoEnabled2, warn: warn2 } = logger("server-proxy");
20964
- var nextRequestId = () => \`\${_requestId++}\`;
20965
- var DEFAULT_OPTIONS = {};
20966
- var isActiveViewport = (viewPort) => viewPort.disabled !== true && viewPort.suspended !== true;
20967
- var NO_ACTION = {
20968
- type: "NO_ACTION"
20969
- };
20970
- var addTitleToLinks = (links, serverViewportId, label) => links.map(
20971
- (link) => link.parentVpId === serverViewportId ? { ...link, label } : link
20972
- );
20973
- function addLabelsToLinks(links, viewports) {
20974
- return links.map((linkDescriptor) => {
20975
- const { parentVpId } = linkDescriptor;
20976
- const viewport = viewports.get(parentVpId);
20977
- if (viewport) {
20978
- return {
20979
- ...linkDescriptor,
20980
- parentClientVpId: viewport.clientViewportId,
20981
- label: viewport.title
20982
- };
20983
- } else {
20984
- throw Error("addLabelsToLinks viewport not found");
20985
- }
20986
- });
20987
- }
20988
- var ServerProxy = class {
20989
- constructor(connection, callback) {
20990
- this.authToken = "";
20991
- this.user = "user";
20992
- this.pendingRequests = /* @__PURE__ */ new Map();
20993
- this.queuedRequests = [];
20994
- this.cachedTableMetaRequests = /* @__PURE__ */ new Map();
20995
- this.cachedTableSchemas = /* @__PURE__ */ new Map();
20996
- this.connection = connection;
20997
- this.postMessageToClient = callback;
20998
- this.viewports = /* @__PURE__ */ new Map();
20999
- this.mapClientToServerViewport = /* @__PURE__ */ new Map();
21000
- }
21001
- async reconnect() {
21002
- await this.login(this.authToken);
21003
- const [activeViewports, inactiveViewports] = partition(
21004
- Array.from(this.viewports.values()),
21005
- isActiveViewport
21006
- );
21007
- this.viewports.clear();
21008
- this.mapClientToServerViewport.clear();
21009
- const reconnectViewports = (viewports) => {
21010
- viewports.forEach((viewport) => {
21011
- const { clientViewportId } = viewport;
21012
- this.viewports.set(clientViewportId, viewport);
21013
- this.sendMessageToServer(viewport.subscribe(), clientViewportId);
21014
- });
21015
- };
21016
- reconnectViewports(activeViewports);
21017
- setTimeout(() => {
21018
- reconnectViewports(inactiveViewports);
21019
- }, 2e3);
21020
- }
21021
- async login(authToken, user = "user") {
21022
- if (authToken) {
21023
- this.authToken = authToken;
21024
- this.user = user;
21025
- return new Promise((resolve, reject) => {
21026
- this.sendMessageToServer(
21027
- { type: LOGIN, token: this.authToken, user },
21028
- ""
21029
- );
21030
- this.pendingLogin = { resolve, reject };
21031
- });
21032
- } else if (this.authToken === "") {
21033
- error2("login, cannot login until auth token has been obtained");
21034
- }
21035
- }
21036
- subscribe(message) {
21037
- if (!this.mapClientToServerViewport.has(message.viewport)) {
21038
- const pendingTableSchema = this.getTableMeta(message.table);
21039
- const viewport = new Viewport(message, this.postMessageToClient);
21040
- this.viewports.set(message.viewport, viewport);
21041
- const pendingSubscription = this.awaitResponseToMessage(
21042
- viewport.subscribe(),
21043
- message.viewport
21044
- );
21045
- const awaitPendingReponses = Promise.all([
21046
- pendingSubscription,
21047
- pendingTableSchema
21048
- ]);
21049
- awaitPendingReponses.then(([subscribeResponse, tableSchema]) => {
21050
- const { viewPortId: serverViewportId } = subscribeResponse;
21051
- const { status: previousViewportStatus } = viewport;
21052
- if (message.viewport !== serverViewportId) {
21053
- this.viewports.delete(message.viewport);
21054
- this.viewports.set(serverViewportId, viewport);
21055
- }
21056
- this.mapClientToServerViewport.set(message.viewport, serverViewportId);
21057
- const clientResponse = viewport.handleSubscribed(
21058
- subscribeResponse,
21059
- tableSchema
21060
- );
21061
- if (clientResponse) {
21062
- this.postMessageToClient(clientResponse);
21063
- if (debugEnabled3) {
21064
- debug3(
21065
- \`post DataSourceSubscribedMessage to client: \${JSON.stringify(
21066
- clientResponse
21067
- )}\`
21068
- );
21069
- }
21070
- }
21071
- if (viewport.disabled) {
21072
- this.disableViewport(viewport);
21073
- }
21074
- if (this.queuedRequests.length > 0) {
21075
- this.processQueuedRequests();
21076
- }
21077
- if (previousViewportStatus === "subscribing" && // A session table will never have Visual Links, nor Context Menus
21078
- !isSessionTable(viewport.table)) {
21079
- this.sendMessageToServer({
21080
- type: GET_VP_VISUAL_LINKS,
21081
- vpId: serverViewportId
21082
- });
21083
- this.sendMessageToServer({
21084
- type: GET_VIEW_PORT_MENUS,
21085
- vpId: serverViewportId
21086
- });
21087
- Array.from(this.viewports.entries()).filter(
21088
- ([id, { disabled }]) => id !== serverViewportId && !disabled
21089
- ).forEach(([vpId]) => {
21090
- this.sendMessageToServer({
21091
- type: GET_VP_VISUAL_LINKS,
21092
- vpId
21093
- });
21094
- });
21095
- }
21096
- });
21097
- } else {
21098
- error2(\`spurious subscribe call \${message.viewport}\`);
21099
- }
21100
- }
21101
- processQueuedRequests() {
21102
- const messageTypesProcessed = {};
21103
- while (this.queuedRequests.length) {
21104
- const queuedRequest = this.queuedRequests.pop();
21105
- if (queuedRequest) {
21106
- const { clientViewportId, message, requestId } = queuedRequest;
21107
- if (message.type === "CHANGE_VP_RANGE") {
21108
- if (messageTypesProcessed.CHANGE_VP_RANGE) {
21109
- continue;
21110
- }
21111
- messageTypesProcessed.CHANGE_VP_RANGE = true;
21112
- const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
21113
- if (serverViewportId) {
21114
- this.sendMessageToServer(
21115
- {
21116
- ...message,
21117
- viewPortId: serverViewportId
21118
- },
21119
- requestId
21120
- );
21121
- }
21122
- }
21123
- }
21124
- }
21125
- }
21126
- unsubscribe(clientViewportId) {
21127
- const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
21128
- if (serverViewportId) {
21129
- info2 == null ? void 0 : info2(
21130
- \`Unsubscribe Message (Client to Server):
21131
- \${serverViewportId}\`
21132
- );
21133
- this.sendMessageToServer({
21134
- type: REMOVE_VP,
21135
- viewPortId: serverViewportId
21136
- });
21137
- } else {
21138
- error2(
21139
- \`failed to unsubscribe client viewport \${clientViewportId}, viewport not found\`
21140
- );
21141
- }
21142
- }
21143
- getViewportForClient(clientViewportId, throws = true) {
21144
- const serverViewportId = this.mapClientToServerViewport.get(clientViewportId);
21145
- if (serverViewportId) {
21146
- const viewport = this.viewports.get(serverViewportId);
21147
- if (viewport) {
21148
- return viewport;
21149
- } else if (throws) {
21150
- throw Error(
21151
- \`Viewport not found for client viewport \${clientViewportId}\`
21152
- );
21153
- } else {
21154
- return null;
21155
- }
21156
- } else if (this.viewports.has(clientViewportId)) {
21157
- return this.viewports.get(clientViewportId);
21158
- } else if (throws) {
21159
- throw Error(
21160
- \`Viewport server id not found for client viewport \${clientViewportId}\`
21161
- );
21162
- } else {
21163
- return null;
21164
- }
21165
- }
21166
- /**********************************************************************/
21167
- /* Handle messages from client */
21168
- /**********************************************************************/
21169
- setViewRange(viewport, message) {
21170
- const requestId = nextRequestId();
21171
- const [serverRequest, rows, debounceRequest] = viewport.rangeRequest(
21172
- requestId,
21173
- message.range
21174
- );
21175
- info2 == null ? void 0 : info2(\`setViewRange \${message.range.from} - \${message.range.to}\`);
21176
- if (serverRequest) {
21177
- if (true) {
21178
- info2 == null ? void 0 : info2(
21179
- \`CHANGE_VP_RANGE [\${message.range.from}-\${message.range.to}] => [\${serverRequest.from}-\${serverRequest.to}]\`
21180
- );
21181
- }
21182
- const sentToServer = this.sendIfReady(
21183
- serverRequest,
21184
- requestId,
21185
- viewport.status === "subscribed"
21186
- );
21187
- if (!sentToServer) {
21188
- this.queuedRequests.push({
21189
- clientViewportId: message.viewport,
21190
- message: serverRequest,
21191
- requestId
21192
- });
21193
- }
21194
- }
21195
- if (rows) {
21196
- info2 == null ? void 0 : info2(\`setViewRange \${rows.length} rows returned from cache\`);
21197
- this.postMessageToClient({
21198
- mode: "batch",
21199
- type: "viewport-update",
21200
- clientViewportId: viewport.clientViewportId,
21201
- rows
21202
- });
21203
- } else if (debounceRequest) {
21204
- this.postMessageToClient(debounceRequest);
21205
- }
21206
- }
21207
- setConfig(viewport, message) {
21208
- const requestId = nextRequestId();
21209
- const request = viewport.setConfig(requestId, message.config);
21210
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21211
- }
21212
- aggregate(viewport, message) {
21213
- const requestId = nextRequestId();
21214
- const request = viewport.aggregateRequest(requestId, message.aggregations);
21215
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21216
- }
21217
- sort(viewport, message) {
21218
- const requestId = nextRequestId();
21219
- const request = viewport.sortRequest(requestId, message.sort);
21220
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21221
- }
21222
- groupBy(viewport, message) {
21223
- const requestId = nextRequestId();
21224
- const request = viewport.groupByRequest(requestId, message.groupBy);
21225
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21226
- }
21227
- filter(viewport, message) {
21228
- const requestId = nextRequestId();
21229
- const { filter } = message;
21230
- const request = viewport.filterRequest(requestId, filter);
21231
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21232
- }
21233
- setColumns(viewport, message) {
21234
- const requestId = nextRequestId();
21235
- const { columns } = message;
21236
- const request = viewport.columnRequest(requestId, columns);
21237
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21238
- }
21239
- setTitle(viewport, message) {
21240
- if (viewport) {
21241
- viewport.title = message.title;
21242
- this.updateTitleOnVisualLinks(viewport);
21243
- }
21244
- }
21245
- select(viewport, message) {
21246
- const requestId = nextRequestId();
21247
- const { selected } = message;
21248
- const request = viewport.selectRequest(requestId, selected);
21249
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21250
- }
21251
- disableViewport(viewport) {
21252
- const requestId = nextRequestId();
21253
- const request = viewport.disable(requestId);
21254
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21255
- }
21256
- enableViewport(viewport) {
21257
- if (viewport.disabled) {
21258
- const requestId = nextRequestId();
21259
- const request = viewport.enable(requestId);
21260
- this.sendIfReady(request, requestId, viewport.status === "subscribed");
21261
- }
21262
- }
21263
- suspendViewport(viewport) {
21264
- viewport.suspend();
21265
- viewport.suspendTimer = setTimeout(() => {
21266
- info2 == null ? void 0 : info2("suspendTimer expired, escalate suspend to disable");
21267
- this.disableViewport(viewport);
21268
- }, 3e3);
21269
- }
21270
- resumeViewport(viewport) {
21271
- if (viewport.suspendTimer) {
21272
- debug3 == null ? void 0 : debug3("clear suspend timer");
21273
- clearTimeout(viewport.suspendTimer);
21274
- viewport.suspendTimer = null;
21275
- }
21276
- const [size, rows] = viewport.resume();
21277
- debug3 == null ? void 0 : debug3(\`resumeViewport size \${size}, \${rows.length} rows sent to client\`);
21278
- this.postMessageToClient({
21279
- clientViewportId: viewport.clientViewportId,
21280
- mode: "batch",
21281
- rows,
21282
- size,
21283
- type: "viewport-update"
21284
- });
21285
- }
21286
- openTreeNode(viewport, message) {
21287
- if (viewport.serverViewportId) {
21288
- const requestId = nextRequestId();
21289
- this.sendIfReady(
21290
- viewport.openTreeNode(requestId, message),
21291
- requestId,
21292
- viewport.status === "subscribed"
21293
- );
21294
- }
21295
- }
21296
- closeTreeNode(viewport, message) {
21297
- if (viewport.serverViewportId) {
21298
- const requestId = nextRequestId();
21299
- this.sendIfReady(
21300
- viewport.closeTreeNode(requestId, message),
21301
- requestId,
21302
- viewport.status === "subscribed"
21303
- );
21304
- }
21305
- }
21306
- createLink(viewport, message) {
21307
- const { parentClientVpId, parentColumnName, childColumnName } = message;
21308
- const requestId = nextRequestId();
21309
- const parentVpId = this.mapClientToServerViewport.get(parentClientVpId);
21310
- if (parentVpId) {
21311
- const request = viewport.createLink(
21312
- requestId,
21313
- childColumnName,
21314
- parentVpId,
21315
- parentColumnName
21316
- );
21317
- this.sendMessageToServer(request, requestId);
21318
- } else {
21319
- error2("ServerProxy unable to create link, viewport not found");
21320
- }
21321
- }
21322
- removeLink(viewport) {
21323
- const requestId = nextRequestId();
21324
- const request = viewport.removeLink(requestId);
21325
- this.sendMessageToServer(request, requestId);
21326
- }
21327
- updateTitleOnVisualLinks(viewport) {
21328
- var _a;
21329
- const { serverViewportId, title } = viewport;
21330
- for (const vp of this.viewports.values()) {
21331
- if (vp !== viewport && vp.links && serverViewportId && title) {
21332
- if ((_a = vp.links) == null ? void 0 : _a.some((link) => link.parentVpId === serverViewportId)) {
21333
- const [messageToClient] = vp.setLinks(
21334
- addTitleToLinks(vp.links, serverViewportId, title)
21335
- );
21336
- this.postMessageToClient(messageToClient);
21337
- }
21338
- }
21339
- }
21340
- }
21341
- removeViewportFromVisualLinks(serverViewportId) {
21342
- var _a;
21343
- for (const vp of this.viewports.values()) {
21344
- if ((_a = vp.links) == null ? void 0 : _a.some(({ parentVpId }) => parentVpId === serverViewportId)) {
21345
- const [messageToClient] = vp.setLinks(
21346
- vp.links.filter(({ parentVpId }) => parentVpId !== serverViewportId)
21347
- );
21348
- this.postMessageToClient(messageToClient);
21349
- }
21350
- }
21351
- }
21352
- menuRpcCall(message) {
21353
- const viewport = this.getViewportForClient(message.vpId, false);
21354
- if (viewport == null ? void 0 : viewport.serverViewportId) {
21355
- const [requestId, rpcRequest] = stripRequestId(message);
21356
- this.sendMessageToServer(
21357
- {
21358
- ...rpcRequest,
21359
- vpId: viewport.serverViewportId
21360
- },
21361
- requestId
21362
- );
21363
- }
21364
- }
21365
- viewportRpcCall(message) {
21366
- const viewport = this.getViewportForClient(message.vpId, false);
21367
- if (viewport == null ? void 0 : viewport.serverViewportId) {
21368
- const [requestId, rpcRequest] = stripRequestId(message);
21369
- this.sendMessageToServer(
21370
- {
21371
- ...rpcRequest,
21372
- vpId: viewport.serverViewportId,
21373
- namedParams: {}
21374
- },
21375
- requestId
21376
- );
21377
- }
21378
- }
21379
- rpcCall(message) {
21380
- const [requestId, rpcRequest] = stripRequestId(message);
21381
- const module = getRpcServiceModule(rpcRequest.service);
21382
- this.sendMessageToServer(rpcRequest, requestId, { module });
21383
- }
21384
- handleMessageFromClient(message) {
21385
- var _a;
21386
- if (isViewporttMessage(message)) {
21387
- if (message.type === "disable") {
21388
- const viewport = this.getViewportForClient(message.viewport, false);
21389
- if (viewport !== null) {
21390
- return this.disableViewport(viewport);
21391
- } else {
21392
- return;
21393
- }
21394
- } else {
21395
- const viewport = this.getViewportForClient(message.viewport);
21396
- switch (message.type) {
21397
- case "setViewRange":
21398
- return this.setViewRange(viewport, message);
21399
- case "config":
21400
- return this.setConfig(viewport, message);
21401
- case "aggregate":
21402
- return this.aggregate(viewport, message);
21403
- case "sort":
21404
- return this.sort(viewport, message);
21405
- case "groupBy":
21406
- return this.groupBy(viewport, message);
21407
- case "filter":
21408
- return this.filter(viewport, message);
21409
- case "select":
21410
- return this.select(viewport, message);
21411
- case "suspend":
21412
- return this.suspendViewport(viewport);
21413
- case "resume":
21414
- return this.resumeViewport(viewport);
21415
- case "enable":
21416
- return this.enableViewport(viewport);
21417
- case "openTreeNode":
21418
- return this.openTreeNode(viewport, message);
21419
- case "closeTreeNode":
21420
- return this.closeTreeNode(viewport, message);
21421
- case "createLink":
21422
- return this.createLink(viewport, message);
21423
- case "removeLink":
21424
- return this.removeLink(viewport);
21425
- case "setColumns":
21426
- return this.setColumns(viewport, message);
21427
- case "setTitle":
21428
- return this.setTitle(viewport, message);
21429
- default:
21430
- }
21431
- }
21432
- } else if (isVuuRpcRequest(message)) {
21433
- return this.viewportRpcCall(
21434
- message
21435
- );
21436
- } else if (isVuuMenuRpcRequest(message)) {
21437
- return this.menuRpcCall(message);
21438
- } else {
21439
- const { type, requestId } = message;
21440
- switch (type) {
21441
- case "GET_TABLE_LIST": {
21442
- (_a = this.tableList) != null ? _a : this.tableList = this.awaitResponseToMessage(
21443
- { type },
21444
- requestId
21445
- );
21446
- this.tableList.then((response) => {
21447
- this.postMessageToClient({
21448
- type: "TABLE_LIST_RESP",
21449
- tables: response.tables,
21450
- requestId
21451
- });
21452
- });
21453
- return;
21454
- }
21455
- case "GET_TABLE_META": {
21456
- this.getTableMeta(message.table, requestId).then((tableSchema) => {
21457
- if (tableSchema) {
21458
- this.postMessageToClient({
21459
- type: "TABLE_META_RESP",
21460
- tableSchema,
21461
- requestId
21462
- });
21463
- }
21464
- });
21465
- return;
21466
- }
21467
- case "RPC_CALL":
21468
- return this.rpcCall(message);
21469
- default:
21470
- }
21471
- }
21472
- error2(
21473
- \`Vuu ServerProxy Unexpected message from client \${JSON.stringify(
21474
- message
21475
- )}\`
21476
- );
21477
- }
21478
- getTableMeta(table, requestId = nextRequestId()) {
21479
- if (isSessionTable(table)) {
21480
- return Promise.resolve(void 0);
21481
- }
21482
- const key = \`\${table.module}:\${table.table}\`;
21483
- let tableMetaRequest = this.cachedTableMetaRequests.get(key);
21484
- if (!tableMetaRequest) {
21485
- tableMetaRequest = this.awaitResponseToMessage(
21486
- { type: "GET_TABLE_META", table },
21487
- requestId
21488
- );
21489
- this.cachedTableMetaRequests.set(key, tableMetaRequest);
21490
- }
21491
- return tableMetaRequest == null ? void 0 : tableMetaRequest.then((response) => this.cacheTableMeta(response));
21492
- }
21493
- awaitResponseToMessage(message, requestId = nextRequestId()) {
21494
- return new Promise((resolve, reject) => {
21495
- this.sendMessageToServer(message, requestId);
21496
- this.pendingRequests.set(requestId, { reject, resolve });
21497
- });
21498
- }
21499
- sendIfReady(message, requestId, isReady = true) {
21500
- if (isReady) {
21501
- this.sendMessageToServer(message, requestId);
21502
- }
21503
- return isReady;
21504
- }
21505
- sendMessageToServer(body, requestId = \`\${_requestId++}\`, options = DEFAULT_OPTIONS) {
21506
- const { module = "CORE" } = options;
21507
- if (this.authToken) {
21508
- this.connection.send({
21509
- requestId,
21510
- sessionId: this.sessionId,
21511
- token: this.authToken,
21512
- user: this.user,
21513
- module,
21514
- body
21515
- });
21516
- }
21517
- }
21518
- handleMessageFromServer(message) {
21519
- var _a, _b, _c;
21520
- const { body, requestId, sessionId } = message;
21521
- const pendingRequest = this.pendingRequests.get(requestId);
21522
- if (pendingRequest) {
21523
- const { resolve } = pendingRequest;
21524
- this.pendingRequests.delete(requestId);
21525
- resolve(body);
21526
- return;
21527
- }
21528
- const { viewports } = this;
21529
- switch (body.type) {
21530
- case HB:
21531
- this.sendMessageToServer(
21532
- { type: HB_RESP, ts: +/* @__PURE__ */ new Date() },
21533
- "NA"
21534
- );
21535
- break;
21536
- case "LOGIN_SUCCESS":
21537
- if (sessionId) {
21538
- this.sessionId = sessionId;
21539
- (_a = this.pendingLogin) == null ? void 0 : _a.resolve(sessionId);
21540
- this.pendingLogin = void 0;
21541
- } else {
21542
- throw Error("LOGIN_SUCCESS did not provide sessionId");
21543
- }
21544
- break;
21545
- case "REMOVE_VP_SUCCESS":
21546
- {
21547
- const viewport = viewports.get(body.viewPortId);
21548
- if (viewport) {
21549
- this.mapClientToServerViewport.delete(viewport.clientViewportId);
21550
- viewports.delete(body.viewPortId);
21551
- this.removeViewportFromVisualLinks(body.viewPortId);
21552
- }
21553
- }
21554
- break;
21555
- case SET_SELECTION_SUCCESS:
21556
- {
21557
- const viewport = this.viewports.get(body.vpId);
21558
- if (viewport) {
21559
- viewport.completeOperation(requestId);
21560
- }
21561
- }
21562
- break;
21563
- case CHANGE_VP_SUCCESS:
21564
- case DISABLE_VP_SUCCESS:
21565
- if (viewports.has(body.viewPortId)) {
21566
- const viewport = this.viewports.get(body.viewPortId);
21567
- if (viewport) {
21568
- const response = viewport.completeOperation(requestId);
21569
- if (response !== void 0) {
21570
- this.postMessageToClient(response);
21571
- if (debugEnabled3) {
21572
- debug3(\`postMessageToClient \${JSON.stringify(response)}\`);
21573
- }
21574
- }
21575
- }
21576
- }
21577
- break;
21578
- case ENABLE_VP_SUCCESS:
21579
- {
21580
- const viewport = this.viewports.get(body.viewPortId);
21581
- if (viewport) {
21582
- const response = viewport.completeOperation(requestId);
21583
- if (response) {
21584
- this.postMessageToClient(response);
21585
- const [size, rows] = viewport.resume();
21586
- this.postMessageToClient({
21587
- clientViewportId: viewport.clientViewportId,
21588
- mode: "batch",
21589
- rows,
21590
- size,
21591
- type: "viewport-update"
21592
- });
21593
- }
21594
- }
21595
- }
21596
- break;
21597
- case "TABLE_ROW":
21598
- {
21599
- const viewportRowMap = groupRowsByViewport(body.rows);
21600
- if (debugEnabled3) {
21601
- const [firstRow, secondRow] = body.rows;
21602
- if (body.rows.length === 0) {
21603
- debug3("handleMessageFromServer TABLE_ROW 0 rows");
21604
- } else if ((firstRow == null ? void 0 : firstRow.rowIndex) === -1) {
21605
- if (body.rows.length === 1) {
21606
- if (firstRow.updateType === "SIZE") {
21607
- debug3(
21608
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE ONLY \${firstRow.vpSize}\`
21609
- );
21610
- } else {
21611
- debug3(
21612
- \`handleMessageFromServer [\${firstRow.viewPortId}] TABLE_ROW SIZE \${firstRow.vpSize} rowIdx \${firstRow.rowIndex}\`
21613
- );
21614
- }
21615
- } else {
21616
- debug3(
21617
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows, SIZE \${firstRow.vpSize}, [\${secondRow == null ? void 0 : secondRow.rowIndex}] - [\${(_b = body.rows[body.rows.length - 1]) == null ? void 0 : _b.rowIndex}]\`
21618
- );
21619
- }
21620
- } else {
21621
- debug3(
21622
- \`handleMessageFromServer TABLE_ROW \${body.rows.length} rows [\${firstRow == null ? void 0 : firstRow.rowIndex}] - [\${(_c = body.rows[body.rows.length - 1]) == null ? void 0 : _c.rowIndex}]\`
21623
- );
21624
- }
21625
- }
21626
- for (const [viewportId, rows] of Object.entries(viewportRowMap)) {
21627
- const viewport = viewports.get(viewportId);
21628
- if (viewport) {
21629
- viewport.updateRows(rows);
21630
- } else {
21631
- warn2 == null ? void 0 : warn2(
21632
- \`TABLE_ROW message received for non registered viewport \${viewportId}\`
21633
- );
21634
- }
21635
- }
21636
- this.processUpdates();
21637
- }
21638
- break;
21639
- case "CHANGE_VP_RANGE_SUCCESS":
21640
- {
21641
- const viewport = this.viewports.get(body.viewPortId);
21642
- if (viewport) {
21643
- const { from, to } = body;
21644
- if (true) {
21645
- info2 == null ? void 0 : info2(\`CHANGE_VP_RANGE_SUCCESS \${from} - \${to}\`);
21646
- }
21647
- viewport.completeOperation(requestId, from, to);
21648
- }
21649
- }
21650
- break;
21651
- case OPEN_TREE_SUCCESS:
21652
- case CLOSE_TREE_SUCCESS:
21653
- break;
21654
- case "CREATE_VISUAL_LINK_SUCCESS":
21655
- {
21656
- const viewport = this.viewports.get(body.childVpId);
21657
- const parentViewport = this.viewports.get(body.parentVpId);
21658
- if (viewport && parentViewport) {
21659
- const { childColumnName, parentColumnName } = body;
21660
- const response = viewport.completeOperation(
21661
- requestId,
21662
- childColumnName,
21663
- parentViewport.clientViewportId,
21664
- parentColumnName
21665
- );
21666
- if (response) {
21667
- this.postMessageToClient(response);
21668
- }
21669
- }
21670
- }
21671
- break;
21672
- case "REMOVE_VISUAL_LINK_SUCCESS":
21673
- {
21674
- const viewport = this.viewports.get(body.childVpId);
21675
- if (viewport) {
21676
- const response = viewport.completeOperation(
21677
- requestId
21678
- );
21679
- if (response) {
21680
- this.postMessageToClient(response);
21681
- }
21682
- }
21683
- }
21684
- break;
21685
- case "VP_VISUAL_LINKS_RESP":
21686
- {
21687
- const activeLinkDescriptors = this.getActiveLinks(body.links);
21688
- const viewport = this.viewports.get(body.vpId);
21689
- if (activeLinkDescriptors.length && viewport) {
21690
- const linkDescriptorsWithLabels = addLabelsToLinks(
21691
- activeLinkDescriptors,
21692
- this.viewports
21693
- );
21694
- const [clientMessage, pendingLink] = viewport.setLinks(
21695
- linkDescriptorsWithLabels
21696
- );
21697
- this.postMessageToClient(clientMessage);
21698
- if (pendingLink) {
21699
- const { link, parentClientVpId } = pendingLink;
21700
- const requestId2 = nextRequestId();
21701
- const serverViewportId = this.mapClientToServerViewport.get(parentClientVpId);
21702
- if (serverViewportId) {
21703
- const message2 = viewport.createLink(
21704
- requestId2,
21705
- link.fromColumn,
21706
- serverViewportId,
21707
- link.toColumn
21708
- );
21709
- this.sendMessageToServer(message2, requestId2);
21710
- }
21711
- }
21712
- }
21713
- }
21714
- break;
21715
- case "VIEW_PORT_MENUS_RESP":
21716
- if (body.menu.name) {
21717
- const viewport = this.viewports.get(body.vpId);
21718
- if (viewport) {
21719
- const clientMessage = viewport.setMenu(body.menu);
21720
- this.postMessageToClient(clientMessage);
21721
- }
21722
- }
21723
- break;
21724
- case "VP_EDIT_RPC_RESPONSE":
21725
- {
21726
- this.postMessageToClient({
21727
- action: body.action,
21728
- requestId,
21729
- rpcName: body.rpcName,
21730
- type: "VP_EDIT_RPC_RESPONSE"
21731
- });
21732
- }
21733
- break;
21734
- case "VP_EDIT_RPC_REJECT":
21735
- {
21736
- const viewport = this.viewports.get(body.vpId);
21737
- if (viewport) {
21738
- this.postMessageToClient({
21739
- requestId,
21740
- type: "VP_EDIT_RPC_REJECT",
21741
- error: body.error
21742
- });
21743
- }
21744
- }
21745
- break;
21746
- case "VIEW_PORT_MENU_REJ": {
21747
- console.log(\`send menu error back to client\`);
21748
- const { error: error4, rpcName, vpId } = body;
21749
- const viewport = this.viewports.get(vpId);
21750
- if (viewport) {
21751
- this.postMessageToClient({
21752
- clientViewportId: viewport.clientViewportId,
21753
- error: error4,
21754
- rpcName,
21755
- type: "VIEW_PORT_MENU_REJ",
21756
- requestId
21757
- });
21758
- }
21759
- break;
21760
- }
21761
- case "VIEW_PORT_MENU_RESP":
21762
- {
21763
- if (isSessionTableActionMessage(body)) {
21764
- const { action, rpcName } = body;
21765
- this.awaitResponseToMessage({
21766
- type: "GET_TABLE_META",
21767
- table: action.table
21768
- }).then((response) => {
21769
- const tableSchema = createSchemaFromTableMetadata(
21770
- response
21771
- );
21772
- this.postMessageToClient({
21773
- rpcName,
21774
- type: "VIEW_PORT_MENU_RESP",
21775
- action: {
21776
- ...action,
21777
- tableSchema
21778
- },
21779
- tableAlreadyOpen: this.isTableOpen(action.table),
21780
- requestId
21781
- });
21782
- });
21783
- } else {
21784
- const { action } = body;
21785
- this.postMessageToClient({
21786
- type: "VIEW_PORT_MENU_RESP",
21787
- action: action || NO_ACTION,
21788
- tableAlreadyOpen: action !== null && this.isTableOpen(action.table),
21789
- requestId
21790
- });
21791
- }
21792
- }
21793
- break;
21794
- case "RPC_RESP":
21795
- {
21796
- const { method, result } = body;
21797
- this.postMessageToClient({
21798
- type: "RPC_RESP",
21799
- method,
21800
- result,
21801
- requestId
21802
- });
21803
- }
21804
- break;
21805
- case "VIEW_PORT_RPC_REPONSE":
21806
- {
21807
- const { method, action } = body;
21808
- this.postMessageToClient({
21809
- type: "VIEW_PORT_RPC_RESPONSE",
21810
- rpcName: method,
21811
- action,
21812
- requestId
21813
- });
21814
- }
21815
- break;
21816
- case "ERROR":
21817
- error2(body.msg);
21818
- break;
21819
- default:
21820
- infoEnabled2 && info2(\`handleMessageFromServer \${body["type"]}.\`);
21821
- }
21822
- }
21823
- cacheTableMeta(messageBody) {
21824
- const { module, table } = messageBody.table;
21825
- const key = \`\${module}:\${table}\`;
21826
- let tableSchema = this.cachedTableSchemas.get(key);
21827
- if (!tableSchema) {
21828
- tableSchema = createSchemaFromTableMetadata(messageBody);
21829
- this.cachedTableSchemas.set(key, tableSchema);
21830
- }
21831
- return tableSchema;
21832
- }
21833
- isTableOpen(table) {
21834
- if (table) {
21835
- const tableName = table.table;
21836
- for (const viewport of this.viewports.values()) {
21837
- if (!viewport.suspended && viewport.table.table === tableName) {
21838
- return true;
21839
- }
21840
- }
21841
- }
21842
- }
21843
- // Eliminate links to suspended viewports
21844
- getActiveLinks(linkDescriptors) {
21845
- return linkDescriptors.filter((linkDescriptor) => {
21846
- const viewport = this.viewports.get(linkDescriptor.parentVpId);
21847
- return viewport && !viewport.suspended;
21848
- });
21849
- }
21850
- processUpdates() {
21851
- this.viewports.forEach((viewport) => {
21852
- var _a;
21853
- if (viewport.hasUpdatesToProcess) {
21854
- const result = viewport.getClientRows();
21855
- if (result !== NO_DATA_UPDATE) {
21856
- const [rows, mode] = result;
21857
- const size = viewport.getNewRowCount();
21858
- if (size !== void 0 || rows && rows.length > 0) {
21859
- debugEnabled3 && debug3(
21860
- \`postMessageToClient #\${viewport.clientViewportId} viewport-update \${mode}, \${(_a = rows == null ? void 0 : rows.length) != null ? _a : "no"} rows, size \${size}\`
21861
- );
21862
- if (mode) {
21863
- this.postMessageToClient({
21864
- clientViewportId: viewport.clientViewportId,
21865
- mode,
21866
- rows,
21867
- size,
21868
- type: "viewport-update"
21869
- });
21870
- }
21871
- }
21872
- }
21873
- }
21874
- });
21875
- }
21876
- };
21877
-
21878
- // src/websocket-connection.ts
21879
- var { debug: debug4, debugEnabled: debugEnabled4, error: error3, info: info3, infoEnabled: infoEnabled3, warn: warn3 } = logger(
21880
- "websocket-connection"
21881
- );
21882
- var WS = "ws";
21883
- var isWebsocketUrl = (url) => url.startsWith(WS + "://") || url.startsWith(WS + "s://");
21884
- var connectionAttemptStatus = {};
21885
- var setWebsocket = Symbol("setWebsocket");
21886
- var connectionCallback = Symbol("connectionCallback");
21887
- async function connect(connectionString, protocol, callback, retryLimitDisconnect = 10, retryLimitStartup = 5) {
21888
- connectionAttemptStatus[connectionString] = {
21889
- status: "connecting",
21890
- connect: {
21891
- allowed: retryLimitStartup,
21892
- remaining: retryLimitStartup
21893
- },
21894
- reconnect: {
21895
- allowed: retryLimitDisconnect,
21896
- remaining: retryLimitDisconnect
21897
- }
21898
- };
21899
- return makeConnection(connectionString, protocol, callback);
21900
- }
21901
- async function reconnect(connection) {
21902
- throw Error("connection broken");
21903
- }
21904
- async function makeConnection(url, protocol, callback, connection) {
21905
- const {
21906
- status: currentStatus,
21907
- connect: connectStatus,
21908
- reconnect: reconnectStatus
21909
- } = connectionAttemptStatus[url];
21910
- const trackedStatus = currentStatus === "connecting" ? connectStatus : reconnectStatus;
21911
- try {
21912
- callback({ type: "connection-status", status: "connecting" });
21913
- const reconnecting = typeof connection !== "undefined";
21914
- const ws = await createWebsocket(url, protocol);
21915
- console.info(
21916
- "%c\u26A1 %cconnected",
21917
- "font-size: 24px;color: green;font-weight: bold;",
21918
- "color:green; font-size: 14px;"
21919
- );
21920
- if (connection !== void 0) {
21921
- connection[setWebsocket](ws);
21922
- }
21923
- const websocketConnection = connection != null ? connection : new WebsocketConnection(ws, url, protocol, callback);
21924
- const status = reconnecting ? "reconnected" : "connection-open-awaiting-session";
21925
- callback({ type: "connection-status", status });
21926
- websocketConnection.status = status;
21927
- trackedStatus.remaining = trackedStatus.allowed;
21928
- return websocketConnection;
21929
- } catch (err) {
21930
- const retry = --trackedStatus.remaining > 0;
21931
- callback({
21932
- type: "connection-status",
21933
- status: "disconnected",
21934
- reason: "failed to connect",
21935
- retry
21936
- });
21937
- if (retry) {
21938
- return makeConnectionIn(url, protocol, callback, connection, 2e3);
21939
- } else {
21940
- throw Error("Failed to establish connection");
21941
- }
21942
- }
21943
- }
21944
- var makeConnectionIn = (url, protocol, callback, connection, delay) => new Promise((resolve) => {
21945
- setTimeout(() => {
21946
- resolve(makeConnection(url, protocol, callback, connection));
21947
- }, delay);
21948
- });
21949
- var createWebsocket = (connectionString, protocol) => new Promise((resolve, reject) => {
21950
- const websocketUrl = isWebsocketUrl(connectionString) ? connectionString : \`wss://\${connectionString}\`;
21951
- if (infoEnabled3 && protocol !== void 0) {
21952
- info3(\`WebSocket Protocol \${protocol == null ? void 0 : protocol.toString()}\`);
21953
- }
21954
- const ws = new WebSocket(websocketUrl, protocol);
21955
- ws.onopen = () => resolve(ws);
21956
- ws.onerror = (evt) => reject(evt);
21957
- });
21958
- var closeWarn = () => {
21959
- warn3 == null ? void 0 : warn3(\`Connection cannot be closed, socket not yet opened\`);
21960
- };
21961
- var sendWarn = (msg) => {
21962
- warn3 == null ? void 0 : warn3(\`Message cannot be sent, socket closed \${msg.body.type}\`);
21963
- };
21964
- var parseMessage = (message) => {
21965
- try {
21966
- return JSON.parse(message);
21967
- } catch (e) {
21968
- throw Error(\`Error parsing JSON response from server \${message}\`);
21969
- }
21970
- };
21971
- var WebsocketConnection = class {
21972
- constructor(ws, url, protocol, callback) {
21973
- this.close = closeWarn;
21974
- this.requiresLogin = true;
21975
- this.send = sendWarn;
21976
- this.status = "ready";
21977
- this.messagesCount = 0;
21978
- this.connectionMetricsInterval = null;
21979
- this.handleWebsocketMessage = (evt) => {
21980
- const vuuMessageFromServer = parseMessage(evt.data);
21981
- this.messagesCount += 1;
21982
- if (true) {
21983
- if (debugEnabled4 && vuuMessageFromServer.body.type !== "HB") {
21984
- debug4 == null ? void 0 : debug4(\`<<< \${vuuMessageFromServer.body.type}\`);
21985
- }
21986
- }
21987
- this[connectionCallback](vuuMessageFromServer);
21988
- };
21989
- this.url = url;
21990
- this.protocol = protocol;
21991
- this[connectionCallback] = callback;
21992
- this[setWebsocket](ws);
21993
- }
21994
- reconnect() {
21995
- reconnect(this);
21996
- }
21997
- [(connectionCallback, setWebsocket)](ws) {
21998
- const callback = this[connectionCallback];
21999
- ws.onmessage = (evt) => {
22000
- this.status = "connected";
22001
- ws.onmessage = this.handleWebsocketMessage;
22002
- this.handleWebsocketMessage(evt);
22003
- };
22004
- this.connectionMetricsInterval = setInterval(() => {
22005
- callback({
22006
- type: "connection-metrics",
22007
- messagesLength: this.messagesCount
22008
- });
22009
- this.messagesCount = 0;
22010
- }, 2e3);
22011
- ws.onerror = () => {
22012
- error3(\`\u26A1 connection error\`);
22013
- callback({
22014
- type: "connection-status",
22015
- status: "disconnected",
22016
- reason: "error"
22017
- });
22018
- if (this.connectionMetricsInterval) {
22019
- clearInterval(this.connectionMetricsInterval);
22020
- this.connectionMetricsInterval = null;
22021
- }
22022
- if (this.status === "connection-open-awaiting-session") {
22023
- error3(
22024
- \`Websocket connection lost before Vuu session established, check websocket configuration\`
22025
- );
22026
- } else if (this.status !== "closed") {
22027
- reconnect(this);
22028
- this.send = queue;
22029
- }
22030
- };
22031
- ws.onclose = () => {
22032
- info3 == null ? void 0 : info3(\`\u26A1 connection close\`);
22033
- callback({
22034
- type: "connection-status",
22035
- status: "disconnected",
22036
- reason: "close"
22037
- });
22038
- if (this.connectionMetricsInterval) {
22039
- clearInterval(this.connectionMetricsInterval);
22040
- this.connectionMetricsInterval = null;
22041
- }
22042
- if (this.status !== "closed") {
22043
- reconnect(this);
22044
- this.send = queue;
22045
- }
22046
- };
22047
- const send = (msg) => {
22048
- if (true) {
22049
- if (debugEnabled4 && msg.body.type !== "HB_RESP") {
22050
- debug4 == null ? void 0 : debug4(\`>>> \${msg.body.type}\`);
22051
- }
22052
- }
22053
- ws.send(JSON.stringify(msg));
22054
- };
22055
- const queue = (msg) => {
22056
- info3 == null ? void 0 : info3(\`TODO queue message until websocket reconnected \${msg.body.type}\`);
22057
- };
22058
- this.send = send;
22059
- this.close = () => {
22060
- this.status = "closed";
22061
- ws.close();
22062
- this.close = closeWarn;
22063
- this.send = sendWarn;
22064
- info3 == null ? void 0 : info3("close websocket");
22065
- };
22066
- }
22067
- };
22068
-
22069
- // src/worker.ts
22070
- var server;
22071
- var { info: info4, infoEnabled: infoEnabled4 } = logger("worker");
22072
- async function connectToServer(url, protocol, token, username, onConnectionStatusChange, retryLimitDisconnect, retryLimitStartup) {
22073
- const connection = await connect(
22074
- url,
22075
- protocol,
22076
- // if this was called during connect, we would get a ReferenceError, but it will
22077
- // never be called until subscriptions have been made, so this is safe.
22078
- //TODO do we need to listen in to the connection messages here so we can lock back in, in the event of a reconnenct ?
22079
- (msg) => {
22080
- if (isConnectionQualityMetrics(msg)) {
22081
- postMessage({ type: "connection-metrics", messages: msg });
22082
- } else if (isConnectionStatusMessage(msg)) {
22083
- onConnectionStatusChange(msg);
22084
- if (msg.status === "reconnected") {
22085
- server.reconnect();
22086
- }
22087
- } else {
22088
- server.handleMessageFromServer(msg);
22089
- }
22090
- },
22091
- retryLimitDisconnect,
22092
- retryLimitStartup
22093
- );
22094
- server = new ServerProxy(connection, (msg) => sendMessageToClient(msg));
22095
- if (connection.requiresLogin) {
22096
- await server.login(token, username);
22097
- }
22098
- }
22099
- function sendMessageToClient(message) {
22100
- postMessage(message);
22101
- }
22102
- var handleMessageFromClient = async ({
22103
- data: message
22104
- }) => {
22105
- switch (message.type) {
22106
- case "connect":
22107
- await connectToServer(
22108
- message.url,
22109
- message.protocol,
22110
- message.token,
22111
- message.username,
22112
- postMessage,
22113
- message.retryLimitDisconnect,
22114
- message.retryLimitStartup
22115
- );
22116
- postMessage({ type: "connected" });
22117
- break;
22118
- case "subscribe":
22119
- infoEnabled4 && info4(\`client subscribe: \${JSON.stringify(message)}\`);
22120
- server.subscribe(message);
22121
- break;
22122
- case "unsubscribe":
22123
- infoEnabled4 && info4(\`client unsubscribe: \${JSON.stringify(message)}\`);
22124
- server.unsubscribe(message.viewport);
22125
- break;
22126
- default:
22127
- infoEnabled4 && info4(\`client message: \${JSON.stringify(message)}\`);
22128
- server.handleMessageFromClient(message);
22129
- }
22130
- };
22131
- self.addEventListener("message", handleMessageFromClient);
22132
- postMessage({ type: "ready" });
22133
-
22134
- `;
22135
-
22136
- // ../vuu-data-remote/src/connection-manager.ts
22137
- var workerBlob = new Blob([getLoggingConfigForWorker() + workerSourceCode], {
22138
- type: "text/javascript"
22139
- });
22140
- var workerBlobUrl = URL.createObjectURL(workerBlob);
22141
- var worker;
22142
- var pendingWorker;
22143
- var pendingWorkerNoToken = [];
22144
- var resolveServer;
22145
- var rejectServer;
22146
- var serverAPI = new Promise((resolve, reject) => {
22147
- resolveServer = resolve;
22148
- rejectServer = reject;
22149
- });
22150
- var getServerAPI = () => serverAPI;
22151
- var viewports = /* @__PURE__ */ new Map();
22152
- var pendingRequests = /* @__PURE__ */ new Map();
22153
- var getWorker = async ({
22154
- handleConnectionStatusChange,
22155
- protocol,
22156
- retryLimitDisconnect,
22157
- retryLimitStartup,
22158
- token = "",
22159
- username,
22160
- url
22161
- }) => {
22162
- if (token === "" && pendingWorker === void 0) {
22163
- return new Promise((resolve) => {
22164
- pendingWorkerNoToken.push({ resolve });
22165
- });
22166
- }
22167
- return pendingWorker || // we get this far when we receive the first request with auth token
22168
- (pendingWorker = new Promise((resolve) => {
22169
- const worker2 = new Worker(workerBlobUrl);
22170
- const timer = window.setTimeout(() => {
22171
- console.error("timed out waiting for worker to load");
22172
- }, 1e3);
22173
- worker2.onmessage = (msg) => {
22174
- const { data: message } = msg;
22175
- if (message.type === "ready") {
22176
- window.clearTimeout(timer);
22177
- worker2.postMessage({
22178
- protocol,
22179
- retryLimitDisconnect,
22180
- retryLimitStartup,
22181
- token,
22182
- type: "connect",
22183
- url,
22184
- username
22185
- });
22186
- } else if (message.type === "connected") {
22187
- worker2.onmessage = handleMessageFromWorker;
22188
- resolve(worker2);
22189
- for (const pendingWorkerRequest of pendingWorkerNoToken) {
22190
- pendingWorkerRequest.resolve(worker2);
22191
- }
22192
- pendingWorkerNoToken.length = 0;
22193
- } else if (isConnectionStatusMessage(message)) {
22194
- handleConnectionStatusChange({ data: message });
22195
- } else {
22196
- console.warn("ConnectionManager: Unexpected message from the worker");
22197
- }
22198
- };
22199
- }));
22200
- };
22201
- function handleMessageFromWorker({
22202
- data: message
22203
- }) {
22204
- if (shouldMessageBeRoutedToDataSource(message)) {
22205
- const viewport = viewports.get(message.clientViewportId);
22206
- if (viewport) {
22207
- viewport.postMessageToClientDataSource(message);
22208
- } else {
22209
- console.error(
22210
- `[ConnectionManager] ${message.type} message received, viewport not found`
22211
- );
22212
- }
22213
- } else if (isConnectionStatusMessage(message)) {
22214
- ConnectionManager.emit("connection-status", message);
22215
- } else if (isConnectionQualityMetrics(message)) {
22216
- ConnectionManager.emit("connection-metrics", message);
22217
- } else {
22218
- const requestId = message.requestId;
22219
- if (pendingRequests.has(requestId)) {
22220
- const { resolve } = pendingRequests.get(requestId);
22221
- pendingRequests.delete(requestId);
22222
- const {
22223
- type: _1,
22224
- requestId: _2,
22225
- ...rest
22226
- } = message;
22227
- if (messageHasResult(message)) {
22228
- resolve(message.result);
22229
- } else if (message.type === "VP_EDIT_RPC_RESPONSE" || message.type === "VP_EDIT_RPC_REJECT") {
22230
- resolve(message);
22231
- } else if (isTableSchema(message)) {
22232
- resolve(message.tableSchema);
22233
- } else {
22234
- resolve(rest);
22235
- }
22236
- } else {
22237
- console.warn(
22238
- "%cConnectionManager Unexpected message from the worker",
22239
- "color:red;font-weight:bold;"
22240
- );
22241
- }
22242
- }
22243
- }
22244
- var asyncRequest = (msg) => {
22245
- const requestId = uuid();
22246
- worker.postMessage({
22247
- requestId,
22248
- ...msg
22249
- });
22250
- return new Promise((resolve, reject) => {
22251
- pendingRequests.set(requestId, { resolve, reject });
22252
- });
22253
- };
22254
- var connectedServerAPI = {
22255
- subscribe: (message, callback) => {
22256
- if (viewports.get(message.viewport)) {
22257
- throw Error(
22258
- `ConnectionManager attempting to subscribe with an existing viewport id`
22259
- );
22260
- }
22261
- viewports.set(message.viewport, {
22262
- status: "subscribing",
22263
- request: message,
22264
- postMessageToClientDataSource: callback
22265
- });
22266
- worker.postMessage({ type: "subscribe", ...message });
22267
- },
22268
- unsubscribe: (viewport) => {
22269
- worker.postMessage({ type: "unsubscribe", viewport });
22270
- },
22271
- send: (message) => {
22272
- worker.postMessage(message);
22273
- },
22274
- destroy: (viewportId) => {
22275
- if (viewportId && viewports.has(viewportId)) {
22276
- viewports.delete(viewportId);
22277
- }
22278
- },
22279
- rpcCall: async (message) => asyncRequest(message),
22280
- getTableList: async () => asyncRequest({ type: "GET_TABLE_LIST" }),
22281
- getTableSchema: async (table) => asyncRequest({
22282
- type: GET_TABLE_META,
22283
- table
22284
- })
22285
- };
22286
- var _ConnectionManager = class extends EventEmitter {
22287
- // The first request must have the token. We can change this to block others until
22288
- // the request with token is received.
22289
- async connect({
22290
- url,
22291
- authToken,
22292
- username,
22293
- protocol,
22294
- retryLimitDisconnect,
22295
- retryLimitStartup
22296
- }) {
22297
- worker = await getWorker({
22298
- protocol,
22299
- url,
22300
- token: authToken,
22301
- username,
22302
- retryLimitDisconnect,
22303
- retryLimitStartup,
22304
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22305
- // @ts-ignore
22306
- handleConnectionStatusChange: handleMessageFromWorker
22307
- });
22308
- return connectedServerAPI;
22309
- }
22310
- destroy() {
22311
- worker.terminate();
22312
- }
22313
- };
22314
- var ConnectionManager = new _ConnectionManager();
22315
- var makeRpcCall = async (rpcRequest) => {
22316
- try {
22317
- return (await serverAPI).rpcCall(rpcRequest);
22318
- } catch (err) {
22319
- throw Error("Error accessing server api");
22320
- }
22321
- };
22322
-
22323
- // ../vuu-data-remote/src/vuu-data-source.ts
22324
- import { parseFilter } from "@vuu-ui/vuu-filter-parser";
22325
- import {
22326
- configChanged,
22327
- debounce,
22328
- EventEmitter as EventEmitter2,
22329
- isViewportMenusAction,
22330
- isVisualLinksAction,
22331
- itemsOrOrderChanged,
22332
- logger,
22333
- metadataKeys as metadataKeys2,
22334
- throttle,
22335
- uuid as uuid2,
22336
- vanillaConfig,
22337
- withConfigDefaults
22338
- } from "@vuu-ui/vuu-utils";
22339
- var { info } = logger("VuuDataSource");
22340
- var { KEY } = metadataKeys2;
22341
- var _config, _groupBy, _links, _menu, _optimize, _range, _selectedRowsCount, _size, _status, _title;
22342
- var VuuDataSource = class extends EventEmitter2 {
22343
- constructor({
22344
- bufferSize = 100,
22345
- aggregations,
22346
- columns,
22347
- filter,
22348
- groupBy,
22349
- sort,
22350
- table,
22351
- title,
22352
- viewport,
22353
- visualLink
22354
- }) {
22355
- super();
22356
- this.server = null;
22357
- __privateAdd(this, _config, vanillaConfig);
22358
- __privateAdd(this, _groupBy, []);
22359
- __privateAdd(this, _links, void 0);
22360
- __privateAdd(this, _menu, void 0);
22361
- __privateAdd(this, _optimize, "throttle");
22362
- __privateAdd(this, _range, { from: 0, to: 0 });
22363
- __privateAdd(this, _selectedRowsCount, 0);
22364
- __privateAdd(this, _size, 0);
22365
- __privateAdd(this, _status, "initialising");
22366
- __privateAdd(this, _title, void 0);
22367
- this.handleMessageFromServer = (message) => {
22368
- var _a3, _b;
22369
- if (message.type === "subscribed") {
22370
- __privateSet(this, _status, "subscribed");
22371
- if (message.tableSchema) {
22372
- this.tableSchema = message.tableSchema;
22373
- }
22374
- (_a3 = this.clientCallback) == null ? void 0 : _a3.call(this, message);
22375
- } else if (message.type === "disabled") {
22376
- __privateSet(this, _status, "disabled");
22377
- } else if (message.type === "enabled") {
22378
- __privateSet(this, _status, "enabled");
22379
- } else if (isDataSourceConfigMessage(message)) {
22380
- return;
22381
- } else if (message.type === "debounce-begin") {
22382
- this.optimize = "debounce";
22383
- } else {
22384
- if (message.type === "viewport-update" && message.size !== void 0 && message.size !== __privateGet(this, _size)) {
22385
- __privateSet(this, _size, message.size);
22386
- this.emit("resize", message.size);
22387
- }
22388
- if (this.configChangePending) {
22389
- this.setConfigPending();
22390
- }
22391
- if (isViewportMenusAction(message)) {
22392
- __privateSet(this, _menu, message.menu);
22393
- } else if (isVisualLinksAction(message)) {
22394
- __privateSet(this, _links, message.links);
22395
- } else {
22396
- (_b = this.clientCallback) == null ? void 0 : _b.call(this, message);
22397
- }
22398
- if (this.optimize === "debounce") {
22399
- this.revertDebounce();
22400
- }
22401
- }
22402
- };
22403
- this.revertDebounce = debounce(() => {
22404
- this.optimize = "throttle";
22405
- }, 100);
22406
- this.rawRangeRequest = (range) => {
22407
- if (this.viewport && this.server) {
22408
- this.server.send({
22409
- viewport: this.viewport,
22410
- type: "setViewRange",
22411
- range
22412
- });
22413
- }
22414
- };
22415
- this.debounceRangeRequest = debounce((range) => {
22416
- if (this.viewport && this.server) {
22417
- this.server.send({
22418
- viewport: this.viewport,
22419
- type: "setViewRange",
22420
- range
22421
- });
22422
- }
22423
- }, 50);
22424
- this.throttleRangeRequest = throttle((range) => {
22425
- if (this.viewport && this.server) {
22426
- this.server.send({
22427
- viewport: this.viewport,
22428
- type: "setViewRange",
22429
- range
22430
- });
22431
- }
22432
- }, 80);
22433
- if (!table)
22434
- throw Error("RemoteDataSource constructor called without table");
22435
- this.bufferSize = bufferSize;
22436
- this.table = table;
22437
- this.viewport = viewport;
22438
- __privateSet(this, _config, {
22439
- ...__privateGet(this, _config),
22440
- aggregations: aggregations || __privateGet(this, _config).aggregations,
22441
- columns: columns || __privateGet(this, _config).columns,
22442
- filter: filter || __privateGet(this, _config).filter,
22443
- groupBy: groupBy || __privateGet(this, _config).groupBy,
22444
- sort: sort || __privateGet(this, _config).sort,
22445
- visualLink: visualLink || __privateGet(this, _config).visualLink
22446
- });
22447
- __privateSet(this, _title, title);
22448
- this.rangeRequest = this.throttleRangeRequest;
22449
- }
22450
- async subscribe({
22451
- viewport = ((_a3) => (_a3 = this.viewport) != null ? _a3 : this.viewport = uuid2())(),
22452
- columns,
22453
- aggregations,
22454
- range,
22455
- sort,
22456
- groupBy,
22457
- filter
22458
- }, callback) {
22459
- var _a4;
22460
- if (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling") {
22461
- this.enable(callback);
22462
- return;
22463
- }
22464
- this.clientCallback = callback;
22465
- if (aggregations || columns || filter || groupBy || sort) {
22466
- __privateSet(this, _config, {
22467
- ...__privateGet(this, _config),
22468
- aggregations: aggregations || __privateGet(this, _config).aggregations,
22469
- columns: columns || __privateGet(this, _config).columns,
22470
- filter: filter || __privateGet(this, _config).filter,
22471
- groupBy: groupBy || __privateGet(this, _config).groupBy,
22472
- sort: sort || __privateGet(this, _config).sort
22473
- });
22474
- }
22475
- if (range) {
22476
- __privateSet(this, _range, range);
22477
- }
22478
- if (__privateGet(this, _status) !== "initialising" && __privateGet(this, _status) !== "unsubscribed") {
22479
- return;
22480
- }
22481
- __privateSet(this, _status, "subscribing");
22482
- this.viewport = viewport;
22483
- this.server = await getServerAPI();
22484
- const { bufferSize } = this;
22485
- (_a4 = this.server) == null ? void 0 : _a4.subscribe(
22486
- {
22487
- ...__privateGet(this, _config),
22488
- bufferSize,
22489
- viewport,
22490
- table: this.table,
22491
- range: __privateGet(this, _range),
22492
- title: __privateGet(this, _title)
22493
- },
22494
- this.handleMessageFromServer
22495
- );
22496
- }
22497
- unsubscribe() {
22498
- var _a3, _b;
22499
- console.log(`unsubscribe #${this.viewport}`);
22500
- info == null ? void 0 : info(`unsubscribe #${this.viewport}`);
22501
- if (this.viewport) {
22502
- (_a3 = this.server) == null ? void 0 : _a3.unsubscribe(this.viewport);
22503
- }
22504
- (_b = this.server) == null ? void 0 : _b.destroy(this.viewport);
22505
- this.server = null;
22506
- this.removeAllListeners();
22507
- __privateSet(this, _status, "unsubscribed");
22508
- this.viewport = void 0;
22509
- this.range = { from: 0, to: 0 };
22510
- }
22511
- suspend() {
22512
- var _a3;
22513
- console.log(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
22514
- info == null ? void 0 : info(`suspend #${this.viewport}, current status ${__privateGet(this, _status)}`);
22515
- if (this.viewport) {
22516
- __privateSet(this, _status, "suspended");
22517
- (_a3 = this.server) == null ? void 0 : _a3.send({
22518
- type: "suspend",
22519
- viewport: this.viewport
22520
- });
22521
- }
22522
- return this;
22523
- }
22524
- resume() {
22525
- var _a3;
22526
- console.log(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
22527
- const isDisabled2 = __privateGet(this, _status).startsWith("disabl");
22528
- const isSuspended = __privateGet(this, _status) === "suspended";
22529
- info == null ? void 0 : info(`resume #${this.viewport}, current status ${__privateGet(this, _status)}`);
22530
- if (this.viewport) {
22531
- if (isDisabled2) {
22532
- this.enable();
22533
- } else if (isSuspended) {
22534
- (_a3 = this.server) == null ? void 0 : _a3.send({
22535
- type: "resume",
22536
- viewport: this.viewport
22537
- });
22538
- __privateSet(this, _status, "subscribed");
22539
- }
22540
- }
22541
- return this;
22542
- }
22543
- disable() {
22544
- var _a3;
22545
- info == null ? void 0 : info(`disable #${this.viewport}, current status ${__privateGet(this, _status)}`);
22546
- if (this.viewport) {
22547
- __privateSet(this, _status, "disabling");
22548
- (_a3 = this.server) == null ? void 0 : _a3.send({
22549
- viewport: this.viewport,
22550
- type: "disable"
22551
- });
22552
- }
22553
- return this;
22554
- }
22555
- enable(callback) {
22556
- var _a3;
22557
- info == null ? void 0 : info(`enable #${this.viewport}, current status ${__privateGet(this, _status)}`);
22558
- if (this.viewport && (__privateGet(this, _status) === "disabled" || __privateGet(this, _status) === "disabling")) {
22559
- __privateSet(this, _status, "enabling");
22560
- if (callback) {
22561
- this.clientCallback = callback;
22562
- }
22563
- (_a3 = this.server) == null ? void 0 : _a3.send({
22564
- viewport: this.viewport,
22565
- type: "enable"
22566
- });
22567
- }
22568
- return this;
22569
- }
22570
- select(selected) {
22571
- var _a3;
22572
- __privateSet(this, _selectedRowsCount, selected.length);
22573
- if (this.viewport) {
22574
- (_a3 = this.server) == null ? void 0 : _a3.send({
22575
- viewport: this.viewport,
22576
- type: "select",
22577
- selected
22578
- });
22579
- }
22580
- }
22581
- openTreeNode(key) {
22582
- var _a3;
22583
- if (this.viewport) {
22584
- (_a3 = this.server) == null ? void 0 : _a3.send({
22585
- viewport: this.viewport,
22586
- type: "openTreeNode",
22587
- key
22588
- });
22589
- }
22590
- }
22591
- closeTreeNode(key) {
22592
- var _a3;
22593
- if (this.viewport) {
22594
- (_a3 = this.server) == null ? void 0 : _a3.send({
22595
- viewport: this.viewport,
22596
- type: "closeTreeNode",
22597
- key
22598
- });
22599
- }
22600
- }
22601
- get links() {
22602
- return __privateGet(this, _links);
22603
- }
22604
- get menu() {
22605
- return __privateGet(this, _menu);
22606
- }
22607
- get status() {
22608
- return __privateGet(this, _status);
22609
- }
22610
- get optimize() {
22611
- return __privateGet(this, _optimize);
22612
- }
22613
- set optimize(optimize) {
22614
- if (optimize !== __privateGet(this, _optimize)) {
22615
- __privateSet(this, _optimize, optimize);
22616
- switch (optimize) {
22617
- case "none":
22618
- this.rangeRequest = this.rawRangeRequest;
22619
- break;
22620
- case "debounce":
22621
- this.rangeRequest = this.debounceRangeRequest;
22622
- break;
22623
- case "throttle":
22624
- this.rangeRequest = this.throttleRangeRequest;
22625
- break;
22626
- }
22627
- this.emit("optimize", optimize);
22628
- }
22629
- }
22630
- get selectedRowsCount() {
22631
- return __privateGet(this, _selectedRowsCount);
22632
- }
22633
- get size() {
22634
- return __privateGet(this, _size);
22635
- }
22636
- get range() {
22637
- return __privateGet(this, _range);
22638
- }
22639
- set range(range) {
22640
- if (range.from !== __privateGet(this, _range).from || range.to !== __privateGet(this, _range).to) {
22641
- __privateSet(this, _range, range);
22642
- this.rangeRequest(range);
22643
- }
22644
- }
22645
- get config() {
22646
- return __privateGet(this, _config);
22647
- }
22648
- set config(config2) {
22649
- var _a3;
22650
- if (this.applyConfig(config2)) {
22651
- if (__privateGet(this, _config) && this.viewport && this.server) {
22652
- if (config2) {
22653
- (_a3 = this.server) == null ? void 0 : _a3.send({
22654
- viewport: this.viewport,
22655
- type: "config",
22656
- config: __privateGet(this, _config)
22657
- });
22658
- }
22659
- }
22660
- this.emit("config", __privateGet(this, _config));
22661
- }
22662
- }
22663
- applyConfig(config2) {
22664
- var _a3;
22665
- if (configChanged(__privateGet(this, _config), config2)) {
22666
- if (config2) {
22667
- const newConfig = ((_a3 = config2 == null ? void 0 : config2.filter) == null ? void 0 : _a3.filter) && (config2 == null ? void 0 : config2.filter.filterStruct) === void 0 ? {
22668
- ...config2,
22669
- filter: {
22670
- filter: config2.filter.filter,
22671
- filterStruct: parseFilter(config2.filter.filter)
22672
- }
22673
- } : config2;
22674
- __privateSet(this, _config, withConfigDefaults(newConfig));
22675
- return true;
22676
- }
22677
- }
22678
- }
22679
- //TODO replace all these individual server calls with calls to setConfig
22680
- get columns() {
22681
- return __privateGet(this, _config).columns;
22682
- }
22683
- set columns(columns) {
22684
- __privateSet(this, _config, {
22685
- ...__privateGet(this, _config),
22686
- columns
22687
- });
22688
- if (this.viewport) {
22689
- const message = {
22690
- viewport: this.viewport,
22691
- type: "setColumns",
22692
- columns
22693
- };
22694
- if (this.server) {
22695
- this.server.send(message);
22696
- }
22697
- }
22698
- this.emit("config", __privateGet(this, _config));
22699
- }
22700
- get aggregations() {
22701
- return __privateGet(this, _config).aggregations;
22702
- }
22703
- set aggregations(aggregations) {
22704
- var _a3;
22705
- __privateSet(this, _config, {
22706
- ...__privateGet(this, _config),
22707
- aggregations
22708
- });
22709
- if (this.viewport) {
22710
- (_a3 = this.server) == null ? void 0 : _a3.send({
22711
- viewport: this.viewport,
22712
- type: "aggregate",
22713
- aggregations
22714
- });
22715
- }
22716
- this.emit("config", __privateGet(this, _config));
22717
- }
22718
- get sort() {
22719
- return __privateGet(this, _config).sort;
22720
- }
22721
- set sort(sort) {
22722
- __privateSet(this, _config, {
22723
- ...__privateGet(this, _config),
22724
- sort
22725
- });
22726
- if (this.viewport) {
22727
- const message = {
22728
- viewport: this.viewport,
22729
- type: "sort",
22730
- sort
22731
- };
22732
- if (this.server) {
22733
- this.server.send(message);
22734
- }
22735
- }
22736
- this.emit("config", __privateGet(this, _config));
22737
- }
22738
- get filter() {
22739
- return __privateGet(this, _config).filter;
22740
- }
22741
- set filter(filter) {
22742
- __privateSet(this, _config, {
22743
- ...__privateGet(this, _config),
22744
- filter
22745
- });
22746
- if (this.viewport) {
22747
- const message = {
22748
- viewport: this.viewport,
22749
- type: "filter",
22750
- filter
22751
- };
22752
- if (this.server) {
22753
- this.server.send(message);
22754
- }
22755
- }
22756
- this.emit("config", __privateGet(this, _config));
22757
- }
22758
- get groupBy() {
22759
- return __privateGet(this, _config).groupBy;
22760
- }
22761
- set groupBy(groupBy) {
22762
- var _a3;
22763
- if (itemsOrOrderChanged(this.groupBy, groupBy)) {
22764
- const wasGrouped = __privateGet(this, _groupBy).length > 0;
22765
- __privateSet(this, _config, {
22766
- ...__privateGet(this, _config),
22767
- groupBy
22768
- });
22769
- if (this.viewport) {
22770
- const message = {
22771
- viewport: this.viewport,
22772
- type: "groupBy",
22773
- groupBy: __privateGet(this, _config).groupBy
22774
- };
22775
- if (this.server) {
22776
- this.server.send(message);
22777
- }
22778
- }
22779
- if (!wasGrouped && groupBy.length > 0 && this.viewport) {
22780
- (_a3 = this.clientCallback) == null ? void 0 : _a3.call(this, {
22781
- clientViewportId: this.viewport,
22782
- mode: "batch",
22783
- type: "viewport-update",
22784
- size: 0,
22785
- rows: []
22786
- });
22787
- }
22788
- this.emit("config", __privateGet(this, _config));
22789
- this.setConfigPending({ groupBy });
22790
- }
22791
- }
22792
- get title() {
22793
- return __privateGet(this, _title);
22794
- }
22795
- set title(title) {
22796
- var _a3;
22797
- __privateSet(this, _title, title);
22798
- if (this.viewport && title) {
22799
- (_a3 = this.server) == null ? void 0 : _a3.send({
22800
- type: "setTitle",
22801
- title,
22802
- viewport: this.viewport
22803
- });
22804
- }
22805
- }
22806
- get visualLink() {
22807
- return __privateGet(this, _config).visualLink;
22808
- }
22809
- set visualLink(visualLink) {
22810
- var _a3, _b;
22811
- __privateSet(this, _config, {
22812
- ...__privateGet(this, _config),
22813
- visualLink
22814
- });
22815
- if (visualLink) {
22816
- const {
22817
- parentClientVpId,
22818
- link: { fromColumn, toColumn }
22819
- } = visualLink;
22820
- if (this.viewport) {
22821
- (_a3 = this.server) == null ? void 0 : _a3.send({
22822
- viewport: this.viewport,
22823
- type: "createLink",
22824
- parentClientVpId,
22825
- parentColumnName: toColumn,
22826
- childColumnName: fromColumn
22827
- });
22828
- }
22829
- } else {
22830
- if (this.viewport) {
22831
- (_b = this.server) == null ? void 0 : _b.send({
22832
- type: "removeLink",
22833
- viewport: this.viewport
22834
- });
22835
- }
22836
- }
22837
- this.emit("config", __privateGet(this, _config));
22838
- }
22839
- setConfigPending(config2) {
22840
- const pendingConfig = this.configChangePending;
22841
- this.configChangePending = config2;
22842
- if (config2 !== void 0) {
22843
- this.emit("config", config2, false);
22844
- } else {
22845
- this.emit("config", pendingConfig, true);
22846
- }
22847
- }
22848
- async rpcCall(rpcRequest) {
22849
- var _a3;
22850
- if (this.viewport) {
22851
- return (_a3 = this.server) == null ? void 0 : _a3.rpcCall({
22852
- vpId: this.viewport,
22853
- ...rpcRequest
22854
- });
22855
- }
22856
- }
22857
- async menuRpcCall(rpcRequest) {
22858
- var _a3;
22859
- if (this.viewport) {
22860
- return (_a3 = this.server) == null ? void 0 : _a3.rpcCall({
22861
- vpId: this.viewport,
22862
- ...rpcRequest
22863
- });
22864
- }
22865
- }
22866
- applyEdit(row, columnName, value) {
22867
- return this.menuRpcCall({
22868
- rowKey: row[KEY],
22869
- field: columnName,
22870
- value,
22871
- type: "VP_EDIT_CELL_RPC"
22872
- }).then((response) => {
22873
- if (response == null ? void 0 : response.error) {
22874
- return response.error;
22875
- } else {
22876
- return true;
22877
- }
22878
- });
22879
- }
22880
- insertRow(key, data) {
22881
- return this.menuRpcCall({
22882
- rowKey: key,
22883
- data,
22884
- type: "VP_EDIT_ADD_ROW_RPC"
22885
- }).then((response) => {
22886
- if (response == null ? void 0 : response.error) {
22887
- return response.error;
22888
- } else {
22889
- return true;
22890
- }
22891
- });
22892
- }
22893
- deleteRow(rowKey) {
22894
- return this.menuRpcCall({
22895
- rowKey,
22896
- type: "VP_EDIT_DELETE_ROW_RPC"
22897
- }).then((response) => {
22898
- if (response == null ? void 0 : response.error) {
22899
- return response.error;
22900
- } else {
22901
- return true;
22902
- }
22903
- });
22904
- }
22905
- };
22906
- _config = new WeakMap();
22907
- _groupBy = new WeakMap();
22908
- _links = new WeakMap();
22909
- _menu = new WeakMap();
22910
- _optimize = new WeakMap();
22911
- _range = new WeakMap();
22912
- _selectedRowsCount = new WeakMap();
22913
- _size = new WeakMap();
22914
- _status = new WeakMap();
22915
- _title = new WeakMap();
19611
+ // src/hooks/useLookupValues.ts
19612
+ import { VuuDataSource as VuuDataSource2 } from "@vuu-ui/vuu-data-remote";
22916
19613
 
22917
19614
  // ../vuu-shell/src/app-header/AppHeader.tsx
22918
19615
  import { useCallback as useCallback57 } from "react";
@@ -24702,17 +21399,17 @@ var useContextMenu = (menuBuilder, menuActionHandler) => {
24702
21399
  [dataMode, densityClass, themeClass]
24703
21400
  );
24704
21401
  const buildMenuOptions = useCallback9(
24705
- (menuBuilders, location2, options) => {
21402
+ (menuBuilders, location, options) => {
24706
21403
  let results = [];
24707
21404
  for (const menuBuilder2 of menuBuilders) {
24708
- results = results.concat(menuBuilder2(location2, options));
21405
+ results = results.concat(menuBuilder2(location, options));
24709
21406
  }
24710
21407
  return results;
24711
21408
  },
24712
21409
  []
24713
21410
  );
24714
21411
  const handleShowContextMenu = useCallback9(
24715
- (e, location2, { ContextMenuProps: ContextMenuProps2, contextMenu, ...options }) => {
21412
+ (e, location, { ContextMenuProps: ContextMenuProps2, contextMenu, ...options }) => {
24716
21413
  var _a3, _b;
24717
21414
  (_a3 = e.stopPropagation) == null ? void 0 : _a3.call(e);
24718
21415
  (_b = e.preventDefault) == null ? void 0 : _b.call(e);
@@ -24735,7 +21432,7 @@ var useContextMenu = (menuBuilder, menuActionHandler) => {
24735
21432
  if (menuBuilders.length > 0) {
24736
21433
  const menuItemDescriptors = buildMenuOptions(
24737
21434
  menuBuilders,
24738
- location2,
21435
+ location,
24739
21436
  options
24740
21437
  );
24741
21438
  const menuHandler = (action) => {
@@ -25111,7 +21808,7 @@ import {
25111
21808
  } from "react";
25112
21809
 
25113
21810
  // ../vuu-layout/src/layout-reducer/layoutUtils.ts
25114
- import { uuid as uuid3 } from "@vuu-ui/vuu-utils";
21811
+ import { uuid } from "@vuu-ui/vuu-utils";
25115
21812
  import React5, { cloneElement as cloneElement2 } from "react";
25116
21813
 
25117
21814
  // ../vuu-layout/src/use-persistent-state.ts
@@ -25258,9 +21955,9 @@ var useViewActionDispatcher = (id, root, viewPath, dropTargets) => {
25258
21955
  );
25259
21956
  const dispatchLayoutAction = useLayoutProviderDispatch();
25260
21957
  const updateContributions = useCallback14(
25261
- (location2, content2) => {
21958
+ (location, content2) => {
25262
21959
  const updatedContributions = contributions.concat([
25263
- { location: location2, content: content2 }
21960
+ { location, content: content2 }
25264
21961
  ]);
25265
21962
  saveSessionState(id, "contributions", updatedContributions);
25266
21963
  setContributions(updatedContributions);
@@ -31265,7 +27962,7 @@ var Tabstrip = ({
31265
27962
  className: classNameProp,
31266
27963
  id: idProp,
31267
27964
  keyBoardActivation = "manual",
31268
- location: location2,
27965
+ location,
31269
27966
  onActiveChange,
31270
27967
  onAddTab,
31271
27968
  onCloseTab,
@@ -31328,7 +28025,7 @@ var Tabstrip = ({
31328
28025
  id: tabId,
31329
28026
  index,
31330
28027
  key: index,
31331
- location: clsx_default(location2, tabLocation),
28028
+ location: clsx_default(location, tabLocation),
31332
28029
  selected,
31333
28030
  showMenuButton,
31334
28031
  tabIndex: selected ? 0 : -1
@@ -31363,7 +28060,7 @@ var Tabstrip = ({
31363
28060
  tabClassName,
31364
28061
  draggedItemIndex,
31365
28062
  focusVisible,
31366
- location2
28063
+ location
31367
28064
  ]
31368
28065
  );
31369
28066
  return /* @__PURE__ */ jsxs7(Fragment6, { children: [
@@ -31403,7 +28100,7 @@ var TabMenu = ({
31403
28100
  allowRename,
31404
28101
  controlledComponentId,
31405
28102
  controlledComponentTitle,
31406
- location: location2,
28103
+ location,
31407
28104
  onMenuAction,
31408
28105
  onMenuClose,
31409
28106
  index
@@ -31440,7 +28137,7 @@ var TabMenu = ({
31440
28137
  className: classBase13,
31441
28138
  menuBuilder,
31442
28139
  menuActionHandler: onMenuAction,
31443
- menuLocation: clsx_default("tab", location2),
28140
+ menuLocation: clsx_default("tab", location),
31444
28141
  menuOptions,
31445
28142
  onMenuClose,
31446
28143
  tabIndex: -1,
@@ -31464,7 +28161,7 @@ var Tab = forwardRef15(function Tab2({
31464
28161
  focusVisible,
31465
28162
  index = -1,
31466
28163
  label,
31467
- location: location2,
28164
+ location,
31468
28165
  onClick,
31469
28166
  onClose,
31470
28167
  onEnterEditMode = noop3,
@@ -31475,7 +28172,7 @@ var Tab = forwardRef15(function Tab2({
31475
28172
  onMenuClose,
31476
28173
  orientation,
31477
28174
  selected,
31478
- showMenuButton = closeable || editable2 || Boolean(location2),
28175
+ showMenuButton = closeable || editable2 || Boolean(location),
31479
28176
  tabIndex,
31480
28177
  ...props
31481
28178
  }, ref) {
@@ -31571,7 +28268,7 @@ var Tab = forwardRef15(function Tab2({
31571
28268
  allowRename: editable2,
31572
28269
  controlledComponentId: ariaControls,
31573
28270
  controlledComponentTitle: label,
31574
- location: location2,
28271
+ location,
31575
28272
  onMenuAction,
31576
28273
  onMenuClose,
31577
28274
  index
@@ -33749,6 +30446,7 @@ var TextInput = forwardRef22(function TextInput2({
33749
30446
 
33750
30447
  // ../vuu-filters/src/filter-clause/useFilterClauseEditor.ts
33751
30448
  import {
30449
+ getColumnByName,
33752
30450
  isMultiValueFilter,
33753
30451
  isSingleValueFilter,
33754
30452
  isValidFilterClauseOp
@@ -42116,15 +38814,15 @@ var ViewState = class {
42116
38814
  this.computeVisibleRanges();
42117
38815
  }
42118
38816
  updateForViewport() {
42119
- let viewports2 = [this.viewport], { main } = this.state.selection;
38817
+ let viewports = [this.viewport], { main } = this.state.selection;
42120
38818
  for (let i = 0; i <= 1; i++) {
42121
38819
  let pos = i ? main.head : main.anchor;
42122
- if (!viewports2.some(({ from, to }) => pos >= from && pos <= to)) {
38820
+ if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {
42123
38821
  let { from, to } = this.lineBlockAt(pos);
42124
- viewports2.push(new Viewport(from, to));
38822
+ viewports.push(new Viewport(from, to));
42125
38823
  }
42126
38824
  }
42127
- this.viewports = viewports2.sort((a, b) => a.from - b.from);
38825
+ this.viewports = viewports.sort((a, b) => a.from - b.from);
42128
38826
  this.scaler = this.heightMap.height <= 7e6 ? IdScaler : new BigScaler(this.heightOracle, this.heightMap, this.viewports);
42129
38827
  }
42130
38828
  updateViewportLines() {
@@ -42506,9 +39204,9 @@ var IdScaler = {
42506
39204
  scale: 1
42507
39205
  };
42508
39206
  var BigScaler = class {
42509
- constructor(oracle, heightMap, viewports2) {
39207
+ constructor(oracle, heightMap, viewports) {
42510
39208
  let vpHeight = 0, base2 = 0, domBase = 0;
42511
- this.viewports = viewports2.map(({ from, to }) => {
39209
+ this.viewports = viewports.map(({ from, to }) => {
42512
39210
  let top2 = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;
42513
39211
  let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;
42514
39212
  vpHeight += bottom - top2;
@@ -44661,7 +41359,7 @@ function drawSelection(config2 = {}) {
44661
41359
  nativeSelectionHidden.of(true)
44662
41360
  ];
44663
41361
  }
44664
- function configChanged2(update) {
41362
+ function configChanged(update) {
44665
41363
  return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
44666
41364
  }
44667
41365
  var cursorLayer = /* @__PURE__ */ layer({
@@ -44683,7 +41381,7 @@ var cursorLayer = /* @__PURE__ */ layer({
44683
41381
  update(update, dom) {
44684
41382
  if (update.transactions.some((tr) => tr.selection))
44685
41383
  dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
44686
- let confChange = configChanged2(update);
41384
+ let confChange = configChanged(update);
44687
41385
  if (confChange)
44688
41386
  setBlinkRate(update.state, dom);
44689
41387
  return update.docChanged || update.selectionSet || confChange;
@@ -44702,7 +41400,7 @@ var selectionLayer = /* @__PURE__ */ layer({
44702
41400
  return view.state.selection.ranges.map((r2) => r2.empty ? [] : RectangleMarker.forRange(view, "cm-selectionBackground", r2)).reduce((a, b) => a.concat(b));
44703
41401
  },
44704
41402
  update(update, dom) {
44705
- return update.docChanged || update.selectionSet || update.viewportChanged || configChanged2(update);
41403
+ return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);
44706
41404
  },
44707
41405
  class: "cm-selectionLayer"
44708
41406
  });
@@ -49705,6 +46403,7 @@ import { jsx as jsx67, jsxs as jsxs28 } from "react/jsx-runtime";
49705
46403
  import { jsx as jsx68, jsxs as jsxs29 } from "react/jsx-runtime";
49706
46404
 
49707
46405
  // ../vuu-shell/src/session-editing-form/SessionEditingForm.tsx
46406
+ import { VuuDataSource } from "@vuu-ui/vuu-data-remote";
49708
46407
  import {
49709
46408
  buildColumnMap,
49710
46409
  hasAction,
@@ -49722,8 +46421,9 @@ import {
49722
46421
  import { jsx as jsx69, jsxs as jsxs30 } from "react/jsx-runtime";
49723
46422
 
49724
46423
  // ../vuu-shell/src/shell.tsx
46424
+ import { connectToServer } from "@vuu-ui/vuu-data-remote";
49725
46425
  import {
49726
- logger as logger2,
46426
+ logger,
49727
46427
  ThemeProvider,
49728
46428
  useThemeAttributes as useThemeAttributes4
49729
46429
  } from "@vuu-ui/vuu-utils";
@@ -49755,7 +46455,7 @@ if (typeof StackLayout !== "function") {
49755
46455
  "StackLayout module not loaded, will be unsbale to deserialize from layout JSON"
49756
46456
  );
49757
46457
  }
49758
- var { error } = logger2("Shell");
46458
+ var { error } = logger("Shell");
49759
46459
 
49760
46460
  // ../vuu-shell/src/ShellContextProvider.tsx
49761
46461
  import { createContext as createContext9, useContext as useContext11 } from "react";
@@ -49792,7 +46492,7 @@ var loadLookupValues = ({
49792
46492
  const promise = new Promise((resolve) => {
49793
46493
  const columns = [valueColumn, labelColumn];
49794
46494
  const columnMap = buildColumnMap2(columns);
49795
- const dataSource = new VuuDataSource({
46495
+ const dataSource = new VuuDataSource2({
49796
46496
  bufferSize: 0,
49797
46497
  table
49798
46498
  });
@@ -49865,6 +46565,7 @@ var useLookupValues = (column, initialValueProp) => {
49865
46565
 
49866
46566
  // src/hooks/useServerConnectionStatus.ts
49867
46567
  import { useCallback as useCallback78, useEffect as useEffect24, useState as useState44 } from "react";
46568
+ import { ConnectionManager } from "@vuu-ui/vuu-data-remote";
49868
46569
  var useServerConnectionStatus = () => {
49869
46570
  const [connectionStatus, setConnectionStatus] = useState44("disconnected");
49870
46571
  const handleStatusChange = useCallback78(
@@ -49884,15 +46585,16 @@ var useServerConnectionStatus = () => {
49884
46585
 
49885
46586
  // src/hooks/useServerConnectionQuality.ts
49886
46587
  import { useCallback as useCallback79, useEffect as useEffect25, useState as useState45 } from "react";
46588
+ import { ConnectionManager as ConnectionManager2 } from "@vuu-ui/vuu-data-remote";
49887
46589
  var useServerConnectionQuality = () => {
49888
46590
  const [messagesPerSecond, setMessagesPerSecond] = useState45(0);
49889
46591
  const handleConnectivityMessage = useCallback79(({ messages }) => {
49890
46592
  setMessagesPerSecond(messages.messagesLength);
49891
46593
  }, []);
49892
46594
  useEffect25(() => {
49893
- ConnectionManager.on("connection-metrics", handleConnectivityMessage);
46595
+ ConnectionManager2.on("connection-metrics", handleConnectivityMessage);
49894
46596
  return () => {
49895
- ConnectionManager.removeListener(
46597
+ ConnectionManager2.removeListener(
49896
46598
  "connection-metrics",
49897
46599
  handleConnectivityMessage
49898
46600
  );
@@ -49903,6 +46605,7 @@ var useServerConnectionQuality = () => {
49903
46605
 
49904
46606
  // src/hooks/useTypeaheadSuggestions.ts
49905
46607
  import { useCallback as useCallback80 } from "react";
46608
+ import { makeRpcCall } from "@vuu-ui/vuu-data-remote";
49906
46609
  var TYPEAHEAD_MESSAGE_CONSTANTS = {
49907
46610
  type: "RPC_CALL",
49908
46611
  service: "TypeAheadRpcHandler"
@@ -49931,11 +46634,11 @@ import { getFilterPredicate } from "@vuu-ui/vuu-filter-parser";
49931
46634
  import {
49932
46635
  getRowRecord,
49933
46636
  isGroupMenuItemDescriptor as isGroupMenuItemDescriptor2,
49934
- metadataKeys as metadataKeys3
46637
+ metadataKeys as metadataKeys2
49935
46638
  } from "@vuu-ui/vuu-utils";
49936
46639
  import { useCallback as useCallback81 } from "react";
49937
46640
  var addRowsFromInstruments = "addRowsFromInstruments";
49938
- var { KEY: KEY2 } = metadataKeys3;
46641
+ var { KEY } = metadataKeys2;
49939
46642
  var NO_CONFIG = {};
49940
46643
  var isMenuItem = (menu) => "rpcName" in menu;
49941
46644
  var isGroupMenuItem = (menu) => "menus" in menu;
@@ -50000,7 +46703,7 @@ var getMenuRpcRequest = (options) => {
50000
46703
  };
50001
46704
  }
50002
46705
  };
50003
- var isTableLocation = (location2) => ["grid", "header", "filter"].includes(location2);
46706
+ var isTableLocation = (location) => ["grid", "header", "filter"].includes(location);
50004
46707
  var hasFilter = ({ filter }) => typeof filter === "string" && filter.length > 0;
50005
46708
  var getMenuItemOptions = (menu, options) => {
50006
46709
  switch (menu.context) {
@@ -50008,14 +46711,14 @@ var getMenuItemOptions = (menu, options) => {
50008
46711
  return {
50009
46712
  ...menu,
50010
46713
  field: options.columnName,
50011
- rowKey: options.row[KEY2],
46714
+ rowKey: options.row[KEY],
50012
46715
  value: options.row[options.columnMap[options.columnName]]
50013
46716
  };
50014
46717
  case "row":
50015
46718
  return {
50016
46719
  ...menu,
50017
46720
  row: getRowRecord(options.row, options.columnMap),
50018
- rowKey: options.row[KEY2]
46721
+ rowKey: options.row[KEY]
50019
46722
  };
50020
46723
  default:
50021
46724
  return menu;
@@ -50079,11 +46782,11 @@ var useVuuMenuActions = ({
50079
46782
  onRpcResponse
50080
46783
  }) => {
50081
46784
  const buildViewserverMenuOptions = useCallback81(
50082
- (location2, options) => {
46785
+ (location, options) => {
50083
46786
  const { links, menu } = dataSource;
50084
46787
  const { visualLink } = menuActionConfig;
50085
46788
  const descriptors = [];
50086
- if (location2 === "grid" && links && !visualLink) {
46789
+ if (location === "grid" && links && !visualLink) {
50087
46790
  links.forEach((linkDescriptor) => {
50088
46791
  const { link, label: linkLabel } = linkDescriptor;
50089
46792
  const label = linkLabel ? linkLabel : link.toTable;
@@ -50094,10 +46797,10 @@ var useVuuMenuActions = ({
50094
46797
  });
50095
46798
  });
50096
46799
  }
50097
- if (menu && isTableLocation(location2)) {
46800
+ if (menu && isTableLocation(location)) {
50098
46801
  const menuDescriptor = buildMenuDescriptor(
50099
46802
  menu,
50100
- location2,
46803
+ location,
50101
46804
  options
50102
46805
  );
50103
46806
  if (isRoot2(menu) && isGroupMenuItemDescriptor2(menuDescriptor)) {
@@ -50140,6 +46843,7 @@ var useVuuMenuActions = ({
50140
46843
  };
50141
46844
 
50142
46845
  // src/hooks/useVuuTables.ts
46846
+ import { getServerAPI } from "@vuu-ui/vuu-data-remote";
50143
46847
  import { useCallback as useCallback82, useEffect as useEffect26, useState as useState46 } from "react";
50144
46848
  var useVuuTables = () => {
50145
46849
  const [tables, setTables] = useState46();