@dra2020/baseclient 1.0.165 → 1.0.167

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/dist/all/all.d.ts CHANGED
@@ -14,8 +14,8 @@ import * as OT from '../ot-js/all';
14
14
  export { OT };
15
15
  import * as OTE from '../ot-editutil/all';
16
16
  export { OTE };
17
- import { FilterExpr } from '../filterexpr/all';
18
- export { FilterExpr };
17
+ import { FilterExpr, cacheFilterExpr } from '../filterexpr/all';
18
+ export { FilterExpr, cacheFilterExpr };
19
19
  import * as G from '../geo/all';
20
20
  export { G };
21
21
  import * as Emit from '../emit/all';
@@ -53,7 +53,7 @@ var __importStar = (this && this.__importStar) || (function () {
53
53
  };
54
54
  })();
55
55
  Object.defineProperty(exports, "__esModule", ({ value: true }));
56
- exports.Control = exports.Detail = exports.DataFlow = exports.Colors = exports.CSV = exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
56
+ exports.Control = exports.Detail = exports.DataFlow = exports.Colors = exports.CSV = exports.Emit = exports.G = exports.cacheFilterExpr = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
57
57
  // Client and Server
58
58
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
59
59
  exports.Util = Util;
@@ -73,6 +73,7 @@ const OTE = __importStar(__webpack_require__(/*! ../ot-editutil/all */ "./lib/ot
73
73
  exports.OTE = OTE;
74
74
  const all_1 = __webpack_require__(/*! ../filterexpr/all */ "./lib/filterexpr/all.ts");
75
75
  Object.defineProperty(exports, "FilterExpr", ({ enumerable: true, get: function () { return all_1.FilterExpr; } }));
76
+ Object.defineProperty(exports, "cacheFilterExpr", ({ enumerable: true, get: function () { return all_1.cacheFilterExpr; } }));
76
77
  const G = __importStar(__webpack_require__(/*! ../geo/all */ "./lib/geo/all.ts"));
77
78
  exports.G = G;
78
79
  const Emit = __importStar(__webpack_require__(/*! ../emit/all */ "./lib/emit/all.ts"));
@@ -1502,6 +1503,7 @@ var __importStar = (this && this.__importStar) || (function () {
1502
1503
  })();
1503
1504
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1504
1505
  exports.FilterExpr = void 0;
1506
+ exports.cacheFilterExpr = cacheFilterExpr;
1505
1507
  const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
1506
1508
  const Space = 32;
1507
1509
  const Tab = 9;
@@ -2035,38 +2037,48 @@ class FilterExpr {
2035
2037
  return a.join(' ');
2036
2038
  }
2037
2039
  testClause(o, types, clause, prop, relation) {
2040
+ const filterProp = (p) => {
2041
+ let s = toString(o[p]);
2042
+ if (s) {
2043
+ let t = types ? types[p] : undefined;
2044
+ if (t === 'skip')
2045
+ return false;
2046
+ if (t && t === 'date')
2047
+ s = wordyDate(s);
2048
+ s = s.toLowerCase();
2049
+ if (relation === undefined) {
2050
+ if (s.indexOf(clause.op.text) >= 0)
2051
+ return true;
2052
+ }
2053
+ else {
2054
+ let op2 = isNaN(Number(clause.op.text)) ? clause.op.text : Number(clause.op.text);
2055
+ let op1 = typeof op2 === 'number' ? Number(s) : s;
2056
+ switch (relation) {
2057
+ case TokType.Equal: return op1 === op2;
2058
+ case TokType.LessThan: return op1 < op2;
2059
+ case TokType.LessThanEqual: return op1 <= op2;
2060
+ case TokType.GreaterThanEqual: return op1 >= op2;
2061
+ case TokType.GreaterThan: return op1 > op2;
2062
+ case TokType.NotEqual: return op1 !== op2;
2063
+ }
2064
+ }
2065
+ }
2066
+ };
2038
2067
  if (clause == null)
2039
2068
  return true;
2040
2069
  switch (clause.op.tt) {
2041
2070
  case TokType.Text:
2042
- for (let p in o)
2043
- if (o.hasOwnProperty(p) && (prop == null || p.toLowerCase() === prop)) {
2044
- let s = toString(o[p]);
2045
- if (s) {
2046
- let t = types ? types[p] : undefined;
2047
- if (t === 'skip')
2048
- continue;
2049
- if (t && t === 'date')
2050
- s = wordyDate(s);
2051
- s = s.toLowerCase();
2052
- if (relation === undefined) {
2053
- if (s.indexOf(clause.op.text) >= 0)
2054
- return true;
2055
- }
2056
- else {
2057
- let op2 = isNaN(Number(clause.op.text)) ? clause.op.text : Number(clause.op.text);
2058
- let op1 = typeof op2 === 'number' ? Number(s) : s;
2059
- switch (relation) {
2060
- case TokType.Equal: return op1 === op2;
2061
- case TokType.LessThan: return op1 < op2;
2062
- case TokType.LessThanEqual: return op1 <= op2;
2063
- case TokType.GreaterThanEqual: return op1 >= op2;
2064
- case TokType.GreaterThan: return op1 > op2;
2065
- case TokType.NotEqual: return op1 !== op2;
2066
- }
2067
- }
2068
- }
2069
- }
2071
+ if (o._filtercache) {
2072
+ if (prop == null)
2073
+ return o._filtercache.indexOf(clause.op.text) >= 0;
2074
+ else
2075
+ return filterProp(prop);
2076
+ }
2077
+ else {
2078
+ for (let p in o)
2079
+ if ((prop == null || p === prop) && filterProp(p))
2080
+ return true;
2081
+ }
2070
2082
  return false;
2071
2083
  case TokType.Colon:
2072
2084
  if (clause.operand1 && clause.operand1.op.tt === TokType.Text)
@@ -2092,6 +2104,26 @@ class FilterExpr {
2092
2104
  }
2093
2105
  }
2094
2106
  exports.FilterExpr = FilterExpr;
2107
+ function cacheFilterExpr(o, types) {
2108
+ if (o) {
2109
+ delete o._filtercache;
2110
+ let a = [];
2111
+ for (let p in o) {
2112
+ let s;
2113
+ let t = types ? types[p] : undefined;
2114
+ if (t === 'skip')
2115
+ s = '';
2116
+ else {
2117
+ s = toString(o[p]);
2118
+ if (t === 'date')
2119
+ s = wordyDate(s);
2120
+ s = s.toLowerCase();
2121
+ }
2122
+ a.push(s);
2123
+ }
2124
+ o._filtercache = a.join('|'); // insert separator to reduce likelihood of spurious matches that cross property values
2125
+ }
2126
+ }
2095
2127
 
2096
2128
 
2097
2129
  /***/ }),
@@ -5274,11 +5306,10 @@ class OTClientEngine extends OTE.OTEngine {
5274
5306
  this.clientID = cid;
5275
5307
  this.initialize();
5276
5308
  this.bReadOnly = false;
5277
- this.valCache = {};
5278
5309
  }
5279
5310
  initialize() {
5280
5311
  if (this.prefailCache === undefined && this.clientSequenceNo > 0)
5281
- this.prefailCache = this.valCache;
5312
+ this.prefailCache = this.toValue();
5282
5313
  this.clientSequenceNo = 0;
5283
5314
  this.isNeedAck = false;
5284
5315
  this.isNeedResend = false;
@@ -5301,9 +5332,13 @@ class OTClientEngine extends OTE.OTEngine {
5301
5332
  return this.resourceID;
5302
5333
  }
5303
5334
  toPartialValue(resourceName) {
5335
+ if (!this.valCache)
5336
+ this.valCache = {};
5304
5337
  return this.valCache[resourceName];
5305
5338
  }
5306
5339
  toValue() {
5340
+ if (!this.valCache)
5341
+ this.valCache = this.stateLocal.toValue();
5307
5342
  return this.valCache;
5308
5343
  }
5309
5344
  toPrefailValue() {
@@ -5363,14 +5398,14 @@ class OTClientEngine extends OTE.OTEngine {
5363
5398
  failbackToInitialState() {
5364
5399
  console.log('otclientengine: failbackToInitialState');
5365
5400
  if (this.prefailCache === undefined)
5366
- this.prefailCache = this.valCache;
5401
+ this.prefailCache = this.toValue();
5367
5402
  this.initialize();
5368
5403
  }
5369
5404
  // When I have server state but my state got mixed up
5370
5405
  failbackToServerState() {
5371
5406
  console.log('otclientengine: failbackToServerState');
5372
5407
  if (this.prefailCache === undefined)
5373
- this.prefailCache = this.valCache;
5408
+ this.prefailCache = this.toValue();
5374
5409
  this.stateLocal = this.stateServer.copy();
5375
5410
  this.isNeedAck = false;
5376
5411
  this.actionSentClient.empty();
@@ -5378,7 +5413,7 @@ class OTClientEngine extends OTE.OTEngine {
5378
5413
  this.actionServerInterposedSentClient.empty();
5379
5414
  this.actionAllPendingClient.empty();
5380
5415
  this.actionAllClient.empty();
5381
- this.valCache = this.stateLocal.toValue();
5416
+ delete this.valCache;
5382
5417
  this.emit('state');
5383
5418
  }
5384
5419
  //
@@ -5464,7 +5499,7 @@ class OTClientEngine extends OTE.OTEngine {
5464
5499
  if (this.isNeedAck)
5465
5500
  this.actionServerInterposedSentClient.compose(orig);
5466
5501
  // Let clients know
5467
- this.valCache = this.stateLocal.toValue();
5502
+ delete this.valCache;
5468
5503
  this.emit('state');
5469
5504
  }
5470
5505
  }
@@ -5494,7 +5529,7 @@ class OTClientEngine extends OTE.OTEngine {
5494
5529
  this.actionAllClient.compose(orig);
5495
5530
  this.actionAllPendingClient.compose(orig);
5496
5531
  this.stateLocal.compose(orig);
5497
- this.valCache = this.stateLocal.toValue();
5532
+ delete this.valCache;
5498
5533
  this.emit('state');
5499
5534
  }
5500
5535
  catch (err) {