@dra2020/baseclient 1.0.129 → 1.0.131
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 +2 -0
- package/dist/baseclient.js +180 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/detail/all.d.ts +1 -0
- package/dist/detail/detail.d.ts +17 -0
- package/lib/all/all.ts +2 -0
- package/lib/detail/all.ts +1 -0
- package/lib/detail/detail.ts +166 -0
- package/package.json +1 -1
package/dist/all/all.d.ts
CHANGED
package/dist/baseclient.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
42
|
-
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;
|
|
42
|
+
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;
|
|
43
43
|
// Client and Server
|
|
44
44
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
45
45
|
exports.Util = Util;
|
|
@@ -69,6 +69,8 @@ const Colors = __importStar(__webpack_require__(/*! ../colors/colors */ "./lib/c
|
|
|
69
69
|
exports.Colors = Colors;
|
|
70
70
|
const DataFlow = __importStar(__webpack_require__(/*! ../dataflow/all */ "./lib/dataflow/all.ts"));
|
|
71
71
|
exports.DataFlow = DataFlow;
|
|
72
|
+
const Detail = __importStar(__webpack_require__(/*! ../detail/all */ "./lib/detail/all.ts"));
|
|
73
|
+
exports.Detail = Detail;
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
/***/ }),
|
|
@@ -1133,6 +1135,183 @@ class DataFlowStamp extends DataFlow {
|
|
|
1133
1135
|
exports.DataFlowStamp = DataFlowStamp;
|
|
1134
1136
|
|
|
1135
1137
|
|
|
1138
|
+
/***/ }),
|
|
1139
|
+
|
|
1140
|
+
/***/ "./lib/detail/all.ts":
|
|
1141
|
+
/*!***************************!*\
|
|
1142
|
+
!*** ./lib/detail/all.ts ***!
|
|
1143
|
+
\***************************/
|
|
1144
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1148
|
+
if (k2 === undefined) k2 = k;
|
|
1149
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1150
|
+
}) : (function(o, m, k, k2) {
|
|
1151
|
+
if (k2 === undefined) k2 = k;
|
|
1152
|
+
o[k2] = m[k];
|
|
1153
|
+
}));
|
|
1154
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
1155
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1156
|
+
};
|
|
1157
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1158
|
+
__exportStar(__webpack_require__(/*! ./detail */ "./lib/detail/detail.ts"), exports);
|
|
1159
|
+
|
|
1160
|
+
|
|
1161
|
+
/***/ }),
|
|
1162
|
+
|
|
1163
|
+
/***/ "./lib/detail/detail.ts":
|
|
1164
|
+
/*!******************************!*\
|
|
1165
|
+
!*** ./lib/detail/detail.ts ***!
|
|
1166
|
+
\******************************/
|
|
1167
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
//
|
|
1171
|
+
// FormatDetail will take an expression that specifies a format detail lines.
|
|
1172
|
+
// Given an object with a set of integer properties, it will evaluate the expression and produce
|
|
1173
|
+
// a result { k: string, n: number, v: string } results for displaying the contents of the object.
|
|
1174
|
+
//
|
|
1175
|
+
// The formatting string is a statement of the form:
|
|
1176
|
+
// =expr
|
|
1177
|
+
// Expr can be an arithmetic expression using +-/*()?: as operators and variables are the field
|
|
1178
|
+
// names of properties on the object passed in. The special field name _tot represents the
|
|
1179
|
+
// total of all properties. The expression may also include double-quoted strings that are
|
|
1180
|
+
// passed through (e.g. for use as labels = area" sqm")
|
|
1181
|
+
//
|
|
1182
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1183
|
+
if (k2 === undefined) k2 = k;
|
|
1184
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1185
|
+
}) : (function(o, m, k, k2) {
|
|
1186
|
+
if (k2 === undefined) k2 = k;
|
|
1187
|
+
o[k2] = m[k];
|
|
1188
|
+
}));
|
|
1189
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1190
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1191
|
+
}) : function(o, v) {
|
|
1192
|
+
o["default"] = v;
|
|
1193
|
+
});
|
|
1194
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1195
|
+
if (mod && mod.__esModule) return mod;
|
|
1196
|
+
var result = {};
|
|
1197
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1198
|
+
__setModuleDefault(result, mod);
|
|
1199
|
+
return result;
|
|
1200
|
+
};
|
|
1201
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1202
|
+
exports.FormatDetail = void 0;
|
|
1203
|
+
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1204
|
+
const reIdentifier = /\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g;
|
|
1205
|
+
const reParam = /^__\d+$/;
|
|
1206
|
+
class Evaluator {
|
|
1207
|
+
constructor(expr) {
|
|
1208
|
+
this.expr = expr;
|
|
1209
|
+
}
|
|
1210
|
+
eval(o) {
|
|
1211
|
+
try {
|
|
1212
|
+
// Convert property names to valid Javascript to ensure expression safety
|
|
1213
|
+
o = Util.shallowCopy(o);
|
|
1214
|
+
let namemap = {};
|
|
1215
|
+
Object.keys(o).forEach((n, i) => {
|
|
1216
|
+
namemap[n] = `__${i}`;
|
|
1217
|
+
});
|
|
1218
|
+
// Extract variable names and values from the object
|
|
1219
|
+
let names = Object.keys(o);
|
|
1220
|
+
let values = Object.values(o);
|
|
1221
|
+
let safeexpr = this.expr;
|
|
1222
|
+
let safenames = names.map(n => namemap[n]);
|
|
1223
|
+
// replace longest field names first in case they contain substrings of short field names
|
|
1224
|
+
names.sort((n1, n2) => n2.length - n1.length);
|
|
1225
|
+
names.forEach((n, i) => {
|
|
1226
|
+
while (safeexpr.indexOf(n) >= 0)
|
|
1227
|
+
safeexpr = safeexpr.replace(n, namemap[n]);
|
|
1228
|
+
});
|
|
1229
|
+
// Remove any identifiers that aren't the simple parameters to prevent out-of-sandbox execution
|
|
1230
|
+
safeexpr = safeexpr.replace(reIdentifier, (match) => { return reParam.test(match) ? match : "invalid"; });
|
|
1231
|
+
// Create a new function that accepts the variables as parameters
|
|
1232
|
+
// and evaluates the expression
|
|
1233
|
+
const func = new Function(...safenames, `return ${safeexpr};`);
|
|
1234
|
+
// Call the function with the variable values
|
|
1235
|
+
let r = func(...values);
|
|
1236
|
+
return isNaN(r) ? 0 : r;
|
|
1237
|
+
}
|
|
1238
|
+
catch (err) {
|
|
1239
|
+
return 0;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const reInvalidChars = /[\.\[\]\\]/;
|
|
1244
|
+
const reExpr = /^=(.*)$/;
|
|
1245
|
+
class FormatDetail {
|
|
1246
|
+
constructor(pattern) {
|
|
1247
|
+
this.valid = true;
|
|
1248
|
+
this.pattern = pattern.trim();
|
|
1249
|
+
let a = reExpr.exec(pattern);
|
|
1250
|
+
if (a && a.length == 2) {
|
|
1251
|
+
this.items = [];
|
|
1252
|
+
const expr = a[1];
|
|
1253
|
+
const parse = expr.split('"');
|
|
1254
|
+
let state = 'expr';
|
|
1255
|
+
parse.forEach(subexpr => {
|
|
1256
|
+
if (state === 'expr') {
|
|
1257
|
+
if (subexpr.length) {
|
|
1258
|
+
// Don't allow unsafe actions
|
|
1259
|
+
if (reInvalidChars.test(subexpr))
|
|
1260
|
+
this.items.push({ text: subexpr });
|
|
1261
|
+
else
|
|
1262
|
+
this.items.push({ expr: subexpr });
|
|
1263
|
+
}
|
|
1264
|
+
state = 'text';
|
|
1265
|
+
}
|
|
1266
|
+
else // state === 'text'
|
|
1267
|
+
{
|
|
1268
|
+
if (subexpr.length)
|
|
1269
|
+
this.items.push({ text: subexpr });
|
|
1270
|
+
state = 'expr';
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
else {
|
|
1275
|
+
this.valid = false;
|
|
1276
|
+
this.items = [{ text: 'invalid' }];
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
prepare(o) {
|
|
1280
|
+
if (o) {
|
|
1281
|
+
// Make sure there is a total field
|
|
1282
|
+
o = Util.deepCopy(o);
|
|
1283
|
+
if (o['Tot'] !== undefined)
|
|
1284
|
+
o['_tot'] = o['Tot'];
|
|
1285
|
+
else {
|
|
1286
|
+
let t = 0;
|
|
1287
|
+
Object.values(o).forEach((v) => {
|
|
1288
|
+
if (!isNaN(v) && typeof v === 'number')
|
|
1289
|
+
t += v;
|
|
1290
|
+
});
|
|
1291
|
+
o['_tot'] = t;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return o;
|
|
1295
|
+
}
|
|
1296
|
+
format(o) {
|
|
1297
|
+
if (!o)
|
|
1298
|
+
return { n: 0, v: '' };
|
|
1299
|
+
let n;
|
|
1300
|
+
let av = this.items.map(di => {
|
|
1301
|
+
if (di.text)
|
|
1302
|
+
return di.text;
|
|
1303
|
+
else {
|
|
1304
|
+
let e = new Evaluator(di.expr);
|
|
1305
|
+
n = e.eval(o);
|
|
1306
|
+
return Util.precisionRound(n, 0).toLocaleString();
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
return { n, v: av.join('') };
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
exports.FormatDetail = FormatDetail;
|
|
1313
|
+
|
|
1314
|
+
|
|
1136
1315
|
/***/ }),
|
|
1137
1316
|
|
|
1138
1317
|
/***/ "./lib/emit/all.ts":
|