@dra2020/baseclient 1.0.164 → 1.0.166

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.
@@ -5274,11 +5274,10 @@ class OTClientEngine extends OTE.OTEngine {
5274
5274
  this.clientID = cid;
5275
5275
  this.initialize();
5276
5276
  this.bReadOnly = false;
5277
- this.valCache = {};
5278
5277
  }
5279
5278
  initialize() {
5280
5279
  if (this.prefailCache === undefined && this.clientSequenceNo > 0)
5281
- this.prefailCache = this.valCache;
5280
+ this.prefailCache = this.toValue();
5282
5281
  this.clientSequenceNo = 0;
5283
5282
  this.isNeedAck = false;
5284
5283
  this.isNeedResend = false;
@@ -5301,9 +5300,13 @@ class OTClientEngine extends OTE.OTEngine {
5301
5300
  return this.resourceID;
5302
5301
  }
5303
5302
  toPartialValue(resourceName) {
5303
+ if (!this.valCache)
5304
+ this.valCache = {};
5304
5305
  return this.valCache[resourceName];
5305
5306
  }
5306
5307
  toValue() {
5308
+ if (!this.valCache)
5309
+ this.valCache = this.stateLocal.toValue();
5307
5310
  return this.valCache;
5308
5311
  }
5309
5312
  toPrefailValue() {
@@ -5363,14 +5366,14 @@ class OTClientEngine extends OTE.OTEngine {
5363
5366
  failbackToInitialState() {
5364
5367
  console.log('otclientengine: failbackToInitialState');
5365
5368
  if (this.prefailCache === undefined)
5366
- this.prefailCache = this.valCache;
5369
+ this.prefailCache = this.toValue();
5367
5370
  this.initialize();
5368
5371
  }
5369
5372
  // When I have server state but my state got mixed up
5370
5373
  failbackToServerState() {
5371
5374
  console.log('otclientengine: failbackToServerState');
5372
5375
  if (this.prefailCache === undefined)
5373
- this.prefailCache = this.valCache;
5376
+ this.prefailCache = this.toValue();
5374
5377
  this.stateLocal = this.stateServer.copy();
5375
5378
  this.isNeedAck = false;
5376
5379
  this.actionSentClient.empty();
@@ -5378,7 +5381,7 @@ class OTClientEngine extends OTE.OTEngine {
5378
5381
  this.actionServerInterposedSentClient.empty();
5379
5382
  this.actionAllPendingClient.empty();
5380
5383
  this.actionAllClient.empty();
5381
- this.valCache = this.stateLocal.toValue();
5384
+ delete this.valCache;
5382
5385
  this.emit('state');
5383
5386
  }
5384
5387
  //
@@ -5464,7 +5467,7 @@ class OTClientEngine extends OTE.OTEngine {
5464
5467
  if (this.isNeedAck)
5465
5468
  this.actionServerInterposedSentClient.compose(orig);
5466
5469
  // Let clients know
5467
- this.valCache = this.stateLocal.toValue();
5470
+ delete this.valCache;
5468
5471
  this.emit('state');
5469
5472
  }
5470
5473
  }
@@ -5494,7 +5497,7 @@ class OTClientEngine extends OTE.OTEngine {
5494
5497
  this.actionAllClient.compose(orig);
5495
5498
  this.actionAllPendingClient.compose(orig);
5496
5499
  this.stateLocal.compose(orig);
5497
- this.valCache = this.stateLocal.toValue();
5500
+ delete this.valCache;
5498
5501
  this.emit('state');
5499
5502
  }
5500
5503
  catch (err) {
@@ -6633,6 +6636,7 @@ __exportStar(__webpack_require__(/*! ./blend */ "./lib/poly/blend.ts"), exports)
6633
6636
  __exportStar(__webpack_require__(/*! ./cartesian */ "./lib/poly/cartesian.ts"), exports);
6634
6637
  __exportStar(__webpack_require__(/*! ./minbound */ "./lib/poly/minbound.ts"), exports);
6635
6638
  __exportStar(__webpack_require__(/*! ./polyround */ "./lib/poly/polyround.ts"), exports);
6639
+ __exportStar(__webpack_require__(/*! ./polyconvert */ "./lib/poly/polyconvert.ts"), exports);
6636
6640
  __exportStar(__webpack_require__(/*! ./topo */ "./lib/poly/topo.ts"), exports);
6637
6641
  __exportStar(__webpack_require__(/*! ./selfintersect */ "./lib/poly/selfintersect.ts"), exports);
6638
6642
  __exportStar(__webpack_require__(/*! ./shamos */ "./lib/poly/shamos.ts"), exports);
@@ -9068,6 +9072,153 @@ function topoFromBuffer(coder, ab) {
9068
9072
  }
9069
9073
 
9070
9074
 
9075
+ /***/ }),
9076
+
9077
+ /***/ "./lib/poly/polyconvert.ts":
9078
+ /*!*********************************!*\
9079
+ !*** ./lib/poly/polyconvert.ts ***!
9080
+ \*********************************/
9081
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9082
+
9083
+
9084
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9085
+ if (k2 === undefined) k2 = k;
9086
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9087
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9088
+ desc = { enumerable: true, get: function() { return m[k]; } };
9089
+ }
9090
+ Object.defineProperty(o, k2, desc);
9091
+ }) : (function(o, m, k, k2) {
9092
+ if (k2 === undefined) k2 = k;
9093
+ o[k2] = m[k];
9094
+ }));
9095
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
9096
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
9097
+ }) : function(o, v) {
9098
+ o["default"] = v;
9099
+ });
9100
+ var __importStar = (this && this.__importStar) || (function () {
9101
+ var ownKeys = function(o) {
9102
+ ownKeys = Object.getOwnPropertyNames || function (o) {
9103
+ var ar = [];
9104
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
9105
+ return ar;
9106
+ };
9107
+ return ownKeys(o);
9108
+ };
9109
+ return function (mod) {
9110
+ if (mod && mod.__esModule) return mod;
9111
+ var result = {};
9112
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
9113
+ __setModuleDefault(result, mod);
9114
+ return result;
9115
+ };
9116
+ })();
9117
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
9118
+ exports.polyConvert = polyConvert;
9119
+ exports.polyFrom32614 = polyFrom32614;
9120
+ exports.colValidateCRS = colValidateCRS;
9121
+ exports.utm14ToLonLat = utm14ToLonLat;
9122
+ const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
9123
+ // Convert geometry given point conversion function. Takes any form of feature, collection or coordinate array(s)
9124
+ function polyConvert(o, cvt) {
9125
+ if (o) {
9126
+ if (Array.isArray(o)) {
9127
+ if (o.length && typeof o[0] === 'number') {
9128
+ for (let i = 0; i < o.length; i += 2) {
9129
+ const p = cvt([o[i], o[i + 1]]);
9130
+ o[i] = p[0];
9131
+ o[i + 1] = p[1];
9132
+ }
9133
+ }
9134
+ else
9135
+ o.forEach((e) => { polyConvert(e, cvt); });
9136
+ }
9137
+ else if (o.features !== undefined && Array.isArray(o.features))
9138
+ o.features.forEach((f) => { polyConvert(f, cvt); });
9139
+ else if (o.geometry !== undefined && o.geometry.coordinates !== undefined)
9140
+ polyConvert(o.geometry.coordinates, cvt);
9141
+ else if (o.geometry !== undefined && o.geometry.packed !== undefined)
9142
+ PP.polyPackEachPoint(o.geometry.packed, (b, iPoly, iRing, iOffset) => {
9143
+ const p = cvt([b[iOffset], b[iOffset + 1]]);
9144
+ b[iOffset] = p[0];
9145
+ b[iOffset + 1] = p[1];
9146
+ });
9147
+ }
9148
+ return o;
9149
+ }
9150
+ function polyFrom32614(o) {
9151
+ return polyConvert(o, utm14ToLonLat);
9152
+ }
9153
+ // If coordinates in 32614 format, convert to WGS84 (GeoJSON standard format)
9154
+ //
9155
+ function colValidateCRS(o) {
9156
+ // "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32614" } },
9157
+ var _a, _b;
9158
+ if (((_b = (_a = o === null || o === void 0 ? void 0 : o.crs) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.name) === 'urn:ogc:def:crs:EPSG::32614') {
9159
+ delete o.crs;
9160
+ return polyFrom32614(o);
9161
+ }
9162
+ return o;
9163
+ }
9164
+ /**
9165
+ * Convert UTM Zone 14N (EPSG:32614) coordinates to WGS84 lon/lat.
9166
+ * Input: [easting, northing] in meters
9167
+ * Output: [longitude, latitude] in degrees
9168
+ */
9169
+ function utm14ToLonLat([E, N]) {
9170
+ // WGS84 parameters
9171
+ const a = 6378137.0;
9172
+ const f = 1 / 298.257223563;
9173
+ const k0 = 0.9996;
9174
+ const e = Math.sqrt(f * (2 - f)); // eccentricity
9175
+ const e1sq = e * e / (1 - e * e);
9176
+ // UTM zone parameters
9177
+ const zone = 14;
9178
+ const lonOrigin = (zone - 1) * 6 - 180 + 3; // central meridian
9179
+ const falseEasting = 500000;
9180
+ // Remove false northing for northern hemisphere (EPSG:326xx always north)
9181
+ const x = E - falseEasting;
9182
+ const y = N;
9183
+ // Footpoint latitude
9184
+ const M = y / k0;
9185
+ const mu = M / (a * (1 - e * e / 4 - 3 * Math.pow(e, 4) / 64 - 5 * Math.pow(e, 6) / 256));
9186
+ const e1 = (1 - Math.sqrt(1 - e * e)) / (1 + Math.sqrt(1 - e * e));
9187
+ const J1 = (3 * e1 / 2 - 27 * Math.pow(e1, 3) / 32);
9188
+ const J2 = (21 * Math.pow(e1, 2) / 16 - 55 * Math.pow(e1, 4) / 32);
9189
+ const J3 = (151 * Math.pow(e1, 3) / 96);
9190
+ const J4 = (1097 * Math.pow(e1, 4) / 512);
9191
+ const fp = mu
9192
+ + J1 * Math.sin(2 * mu)
9193
+ + J2 * Math.sin(4 * mu)
9194
+ + J3 * Math.sin(6 * mu)
9195
+ + J4 * Math.sin(8 * mu);
9196
+ // Precompute trig functions
9197
+ const sinfp = Math.sin(fp);
9198
+ const cosfp = Math.cos(fp);
9199
+ const tanfp = Math.tan(fp);
9200
+ const C1 = e1sq * Math.pow(cosfp, 2);
9201
+ const T1 = Math.pow(tanfp, 2);
9202
+ const R1 = a * (1 - e * e) / Math.pow(1 - e * e * Math.pow(sinfp, 2), 3 / 2);
9203
+ const N1 = a / Math.sqrt(1 - e * e * Math.pow(sinfp, 2));
9204
+ const D = x / (N1 * k0);
9205
+ // Latitude (φ)
9206
+ const lat = fp
9207
+ - (N1 * tanfp / R1) *
9208
+ (Math.pow(D, 2) / 2
9209
+ - (5 + 3 * T1 + 10 * C1 - 4 * Math.pow(C1, 2) - 9 * e1sq) * Math.pow(D, 4) / 24
9210
+ + (61 + 90 * T1 + 298 * C1 + 45 * Math.pow(T1, 2) - 252 * e1sq - 3 * Math.pow(C1, 2)) * Math.pow(D, 6) / 720);
9211
+ // Longitude (λ)
9212
+ const lon = (D
9213
+ - (1 + 2 * T1 + C1) * Math.pow(D, 3) / 6
9214
+ + (5 - 2 * C1 + 28 * T1 - 3 * Math.pow(C1, 2) + 8 * e1sq + 24 * Math.pow(T1, 2)) * Math.pow(D, 5) / 120) / cosfp;
9215
+ // Convert to degrees and apply central meridian offset
9216
+ const latitude = lat * (180 / Math.PI);
9217
+ const longitude = lonOrigin + lon * (180 / Math.PI);
9218
+ return [longitude, latitude];
9219
+ }
9220
+
9221
+
9071
9222
  /***/ }),
9072
9223
 
9073
9224
  /***/ "./lib/poly/polyhash.ts":