@dra2020/baseclient 1.0.129 → 1.0.130
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 +183 -1
- package/dist/baseclient.js.map +1 -1
- package/dist/detail/all.d.ts +1 -0
- package/dist/detail/detail.d.ts +22 -0
- package/lib/all/all.ts +2 -0
- package/lib/detail/all.ts +1 -0
- package/lib/detail/detail.ts +173 -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,186 @@ 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 a pattern that specifies a set of formatted detail lines.
|
|
1172
|
+
// Given an object with a set of integer properties, it will evaluate the pattern and produce
|
|
1173
|
+
// an array of { k: string, n: number, v: string } results for displaying the contents of the object.
|
|
1174
|
+
//
|
|
1175
|
+
// The formatting string contains a series of statements, separated by newline or semicolon.
|
|
1176
|
+
// A single statement is of the form:
|
|
1177
|
+
// label=expr
|
|
1178
|
+
// Expr can be an arithmetic expression using +-/*() as operators and variables are the field
|
|
1179
|
+
// names of properties on the object passed in. The special field name _tot represents the
|
|
1180
|
+
// total of all properties. The expression may also include double-quoted strings that are
|
|
1181
|
+
// passed through (e.g. for use as labels = area" sqm")
|
|
1182
|
+
//
|
|
1183
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1184
|
+
if (k2 === undefined) k2 = k;
|
|
1185
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
1186
|
+
}) : (function(o, m, k, k2) {
|
|
1187
|
+
if (k2 === undefined) k2 = k;
|
|
1188
|
+
o[k2] = m[k];
|
|
1189
|
+
}));
|
|
1190
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
1191
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1192
|
+
}) : function(o, v) {
|
|
1193
|
+
o["default"] = v;
|
|
1194
|
+
});
|
|
1195
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
1196
|
+
if (mod && mod.__esModule) return mod;
|
|
1197
|
+
var result = {};
|
|
1198
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1199
|
+
__setModuleDefault(result, mod);
|
|
1200
|
+
return result;
|
|
1201
|
+
};
|
|
1202
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1203
|
+
exports.FormatDetail = void 0;
|
|
1204
|
+
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1205
|
+
const reIdentifier = /\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g;
|
|
1206
|
+
const reParam = /^__\d+$/;
|
|
1207
|
+
class Evaluator {
|
|
1208
|
+
constructor(expr) {
|
|
1209
|
+
this.expr = expr;
|
|
1210
|
+
}
|
|
1211
|
+
eval(o) {
|
|
1212
|
+
try {
|
|
1213
|
+
// Convert property names to valid Javascript to ensure expression safety
|
|
1214
|
+
o = Util.shallowCopy(o);
|
|
1215
|
+
let namemap = {};
|
|
1216
|
+
Object.keys(o).forEach((n, i) => {
|
|
1217
|
+
namemap[n] = `__${i}`;
|
|
1218
|
+
});
|
|
1219
|
+
// Extract variable names and values from the object
|
|
1220
|
+
let names = Object.keys(o);
|
|
1221
|
+
let values = Object.values(o);
|
|
1222
|
+
let safeexpr = this.expr;
|
|
1223
|
+
let safenames = names.map(n => namemap[n]);
|
|
1224
|
+
// replace longest field names first in case they contain substrings of short field names
|
|
1225
|
+
names.sort((n1, n2) => n2.length - n1.length);
|
|
1226
|
+
names.forEach((n, i) => {
|
|
1227
|
+
while (safeexpr.indexOf(n) >= 0)
|
|
1228
|
+
safeexpr = safeexpr.replace(n, namemap[n]);
|
|
1229
|
+
});
|
|
1230
|
+
// Remove any identifiers that aren't the simple parameters to prevent out-of-sandbox execution
|
|
1231
|
+
safeexpr = safeexpr.replace(reIdentifier, (match) => { return reParam.test(match) ? match : "invalid"; });
|
|
1232
|
+
// Create a new function that accepts the variables as parameters
|
|
1233
|
+
// and evaluates the expression
|
|
1234
|
+
const func = new Function(...safenames, `return ${safeexpr};`);
|
|
1235
|
+
// Call the function with the variable values
|
|
1236
|
+
let r = func(...values);
|
|
1237
|
+
return isNaN(r) ? 0 : r;
|
|
1238
|
+
}
|
|
1239
|
+
catch (err) {
|
|
1240
|
+
return 0;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
const reInvalidChars = /[\.\[\]\\]/;
|
|
1245
|
+
class FormatDetail {
|
|
1246
|
+
constructor(pattern) {
|
|
1247
|
+
this.valid = true;
|
|
1248
|
+
this.pattern = pattern;
|
|
1249
|
+
this.lines = [];
|
|
1250
|
+
let lines = this.pattern.split(/[;\n]/).map(l => l.trim()).filter(l => !!l);
|
|
1251
|
+
lines.forEach(line => {
|
|
1252
|
+
let sides = line.split('=').map(l => l.trim()).filter(l => !!l);
|
|
1253
|
+
if (sides.length != 2)
|
|
1254
|
+
this.valid = false;
|
|
1255
|
+
else {
|
|
1256
|
+
const lhs = sides[0];
|
|
1257
|
+
const rhs = sides[1];
|
|
1258
|
+
let parse = rhs.split('"');
|
|
1259
|
+
let items = [];
|
|
1260
|
+
let state = 'expr';
|
|
1261
|
+
parse.forEach(subexpr => {
|
|
1262
|
+
if (state === 'expr') {
|
|
1263
|
+
if (subexpr.length) {
|
|
1264
|
+
// Don't allow unsafe actions
|
|
1265
|
+
if (reInvalidChars.test(subexpr))
|
|
1266
|
+
items.push({ text: subexpr });
|
|
1267
|
+
else
|
|
1268
|
+
items.push({ expr: subexpr });
|
|
1269
|
+
}
|
|
1270
|
+
state = 'text';
|
|
1271
|
+
}
|
|
1272
|
+
else // state === 'text'
|
|
1273
|
+
{
|
|
1274
|
+
if (subexpr.length)
|
|
1275
|
+
items.push({ text: subexpr });
|
|
1276
|
+
state = 'expr';
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
this.lines.push({ label: lhs, items });
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
format(o) {
|
|
1284
|
+
if (!o)
|
|
1285
|
+
return [];
|
|
1286
|
+
// Make sure there is a total field
|
|
1287
|
+
o = Util.deepCopy(o);
|
|
1288
|
+
if (o['Tot'] !== undefined)
|
|
1289
|
+
o['_tot'] = o['Tot'];
|
|
1290
|
+
else {
|
|
1291
|
+
let t = 0;
|
|
1292
|
+
Object.values(o).forEach((v) => {
|
|
1293
|
+
if (!isNaN(v) && typeof v === 'number')
|
|
1294
|
+
t += v;
|
|
1295
|
+
});
|
|
1296
|
+
o['_tot'] = t;
|
|
1297
|
+
}
|
|
1298
|
+
let result = [];
|
|
1299
|
+
this.lines.forEach(line => {
|
|
1300
|
+
let n;
|
|
1301
|
+
let av = line.items.map(di => {
|
|
1302
|
+
if (di.text)
|
|
1303
|
+
return di.text;
|
|
1304
|
+
else {
|
|
1305
|
+
let e = new Evaluator(di.expr);
|
|
1306
|
+
n = e.eval(o);
|
|
1307
|
+
return Util.precisionRound(n, 0).toLocaleString();
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
result.push({ k: line.label, n, v: av.join('') });
|
|
1311
|
+
});
|
|
1312
|
+
return result;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
exports.FormatDetail = FormatDetail;
|
|
1316
|
+
|
|
1317
|
+
|
|
1136
1318
|
/***/ }),
|
|
1137
1319
|
|
|
1138
1320
|
/***/ "./lib/emit/all.ts":
|