@itwin/rpcinterface-full-stack-tests 5.9.0-dev.17 → 5.9.0-dev.18
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.
|
@@ -112094,247 +112094,6 @@ class SchemaPartVisitorDelegate {
|
|
|
112094
112094
|
}
|
|
112095
112095
|
|
|
112096
112096
|
|
|
112097
|
-
/***/ }),
|
|
112098
|
-
|
|
112099
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js":
|
|
112100
|
-
/*!********************************************************************!*\
|
|
112101
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js ***!
|
|
112102
|
-
\********************************************************************/
|
|
112103
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112104
|
-
|
|
112105
|
-
"use strict";
|
|
112106
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112107
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112108
|
-
/* harmony export */ Graph: () => (/* binding */ Graph)
|
|
112109
|
-
/* harmony export */ });
|
|
112110
|
-
/*---------------------------------------------------------------------------------------------
|
|
112111
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112112
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
112113
|
-
*--------------------------------------------------------------------------------------------*/
|
|
112114
|
-
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
112115
|
-
/** @internal */
|
|
112116
|
-
class Graph {
|
|
112117
|
-
_edgeKeyDelim = "\x01";
|
|
112118
|
-
_label = "";
|
|
112119
|
-
_nodeCount = 0;
|
|
112120
|
-
_edgeCount = 0;
|
|
112121
|
-
_nodes;
|
|
112122
|
-
_edgeObjs;
|
|
112123
|
-
_edgeLabels;
|
|
112124
|
-
_outEdges;
|
|
112125
|
-
constructor() {
|
|
112126
|
-
this._nodes = {};
|
|
112127
|
-
this._edgeObjs = {};
|
|
112128
|
-
this._edgeLabels = {};
|
|
112129
|
-
this._outEdges = {};
|
|
112130
|
-
}
|
|
112131
|
-
setGraph = (label) => {
|
|
112132
|
-
this._label = label;
|
|
112133
|
-
return this;
|
|
112134
|
-
};
|
|
112135
|
-
graph = () => {
|
|
112136
|
-
return this._label;
|
|
112137
|
-
};
|
|
112138
|
-
nodeCount = () => {
|
|
112139
|
-
return this._nodeCount;
|
|
112140
|
-
};
|
|
112141
|
-
nodes = () => {
|
|
112142
|
-
return Object.keys(this._nodes);
|
|
112143
|
-
};
|
|
112144
|
-
setNode = (nodeKey, nodeValue) => {
|
|
112145
|
-
if (nodeKey in this._nodes) {
|
|
112146
|
-
this._nodes[nodeKey] = nodeValue;
|
|
112147
|
-
return;
|
|
112148
|
-
}
|
|
112149
|
-
this._nodes[nodeKey] = nodeValue;
|
|
112150
|
-
this._outEdges[nodeKey] = {};
|
|
112151
|
-
++this._nodeCount;
|
|
112152
|
-
};
|
|
112153
|
-
node = (nodeKey) => {
|
|
112154
|
-
return this._nodes[nodeKey];
|
|
112155
|
-
};
|
|
112156
|
-
hasNode = (nodeKey) => {
|
|
112157
|
-
return nodeKey in this._nodes;
|
|
112158
|
-
};
|
|
112159
|
-
edgeCount = () => {
|
|
112160
|
-
return this._edgeCount;
|
|
112161
|
-
};
|
|
112162
|
-
edges = () => {
|
|
112163
|
-
return Object.values(this._edgeObjs);
|
|
112164
|
-
};
|
|
112165
|
-
setEdge = (v, w, value) => {
|
|
112166
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
112167
|
-
if (edgeId in this._edgeLabels) {
|
|
112168
|
-
// this._edgeLabels[edgeId] = value;
|
|
112169
|
-
// Update exponent, specific to this graph's use case
|
|
112170
|
-
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
112171
|
-
return;
|
|
112172
|
-
}
|
|
112173
|
-
this._edgeLabels[edgeId] = value;
|
|
112174
|
-
const edgeObj = {
|
|
112175
|
-
v,
|
|
112176
|
-
w,
|
|
112177
|
-
};
|
|
112178
|
-
this._edgeObjs[edgeId] = edgeObj;
|
|
112179
|
-
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
112180
|
-
this._outEdges[v][edgeId] = edgeObj;
|
|
112181
|
-
this._edgeCount++;
|
|
112182
|
-
};
|
|
112183
|
-
edge = (v, w) => {
|
|
112184
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
112185
|
-
return this._edgeLabels[edgeId];
|
|
112186
|
-
};
|
|
112187
|
-
outEdges = (v) => {
|
|
112188
|
-
const outV = this._outEdges[v];
|
|
112189
|
-
const edges = Object.values(outV);
|
|
112190
|
-
return edges;
|
|
112191
|
-
};
|
|
112192
|
-
}
|
|
112193
|
-
|
|
112194
|
-
|
|
112195
|
-
/***/ }),
|
|
112196
|
-
|
|
112197
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js":
|
|
112198
|
-
/*!*********************************************************************!*\
|
|
112199
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js ***!
|
|
112200
|
-
\*********************************************************************/
|
|
112201
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112202
|
-
|
|
112203
|
-
"use strict";
|
|
112204
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112205
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112206
|
-
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
112207
|
-
/* harmony export */ });
|
|
112208
|
-
/*---------------------------------------------------------------------------------------------
|
|
112209
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112210
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
112211
|
-
*--------------------------------------------------------------------------------------------*/
|
|
112212
|
-
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
112213
|
-
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
112214
|
-
const sp = "*";
|
|
112215
|
-
/** @internal */
|
|
112216
|
-
var Tokens;
|
|
112217
|
-
(function (Tokens) {
|
|
112218
|
-
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
112219
|
-
Tokens[Tokens["Word"] = 2] = "Word";
|
|
112220
|
-
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
112221
|
-
})(Tokens || (Tokens = {}));
|
|
112222
|
-
/** @internal */
|
|
112223
|
-
function parseDefinition(definition) {
|
|
112224
|
-
const unitMap = new Map();
|
|
112225
|
-
if (expressionRgx.test(definition)) {
|
|
112226
|
-
for (const unit of definition.split(sp)) {
|
|
112227
|
-
const tokens = unit.split(tokenRgx);
|
|
112228
|
-
const name = tokens[Tokens.Word];
|
|
112229
|
-
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
112230
|
-
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
112231
|
-
if (unitMap.has(name)) {
|
|
112232
|
-
const currentDefinition = unitMap.get(name);
|
|
112233
|
-
if (currentDefinition) {
|
|
112234
|
-
currentDefinition.exponent += exponent;
|
|
112235
|
-
unitMap.set(name, currentDefinition);
|
|
112236
|
-
}
|
|
112237
|
-
}
|
|
112238
|
-
else {
|
|
112239
|
-
unitMap.set(name, { name, exponent, constant });
|
|
112240
|
-
}
|
|
112241
|
-
}
|
|
112242
|
-
return unitMap;
|
|
112243
|
-
}
|
|
112244
|
-
else {
|
|
112245
|
-
throw new Error("Invalid definition expression.");
|
|
112246
|
-
}
|
|
112247
|
-
}
|
|
112248
|
-
|
|
112249
|
-
|
|
112250
|
-
/***/ }),
|
|
112251
|
-
|
|
112252
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js":
|
|
112253
|
-
/*!*****************************************************************************!*\
|
|
112254
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
112255
|
-
\*****************************************************************************/
|
|
112256
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112257
|
-
|
|
112258
|
-
"use strict";
|
|
112259
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112260
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112261
|
-
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
112262
|
-
/* harmony export */ });
|
|
112263
|
-
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
112264
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112265
|
-
|
|
112266
|
-
|
|
112267
|
-
/**
|
|
112268
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
112269
|
-
* @internal
|
|
112270
|
-
*/
|
|
112271
|
-
class UnitConversion {
|
|
112272
|
-
factor;
|
|
112273
|
-
offset;
|
|
112274
|
-
constructor(factor = 1.0, offset = 0.0) {
|
|
112275
|
-
this.factor = factor;
|
|
112276
|
-
this.offset = offset;
|
|
112277
|
-
}
|
|
112278
|
-
/**
|
|
112279
|
-
* Converts x using UnitConversion
|
|
112280
|
-
* @param x Input magnitude to be converted
|
|
112281
|
-
* @returns Output magnitude after conversion
|
|
112282
|
-
*/
|
|
112283
|
-
evaluate(x) {
|
|
112284
|
-
return this.factor * x + this.offset;
|
|
112285
|
-
}
|
|
112286
|
-
/**
|
|
112287
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
112288
|
-
* @internal
|
|
112289
|
-
*/
|
|
112290
|
-
inverse() {
|
|
112291
|
-
const inverseFactor = 1.0 / this.factor;
|
|
112292
|
-
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
112293
|
-
}
|
|
112294
|
-
/**
|
|
112295
|
-
* Combines two UnitConversions
|
|
112296
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
112297
|
-
* @internal
|
|
112298
|
-
*/
|
|
112299
|
-
compose(conversion) {
|
|
112300
|
-
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
112301
|
-
}
|
|
112302
|
-
/**
|
|
112303
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
112304
|
-
* @internal
|
|
112305
|
-
*/
|
|
112306
|
-
multiply(conversion) {
|
|
112307
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(conversion.offset, 0.0) && (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(this.offset, 0.0))
|
|
112308
|
-
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
112309
|
-
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
112310
|
-
}
|
|
112311
|
-
/**
|
|
112312
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
112313
|
-
* @internal
|
|
112314
|
-
*/
|
|
112315
|
-
raise(power) {
|
|
112316
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 1.0))
|
|
112317
|
-
return new UnitConversion(this.factor, this.offset);
|
|
112318
|
-
else if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 0.0))
|
|
112319
|
-
return new UnitConversion(1.0, 0.0);
|
|
112320
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(this.offset, 0.0))
|
|
112321
|
-
return new UnitConversion(this.factor ** power, 0.0);
|
|
112322
|
-
throw new Error("Cannot raise map with non-zero offset");
|
|
112323
|
-
}
|
|
112324
|
-
/** @internal */
|
|
112325
|
-
static identity = new UnitConversion();
|
|
112326
|
-
/**
|
|
112327
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
112328
|
-
* @internal
|
|
112329
|
-
*/
|
|
112330
|
-
static from(unitOrConstant) {
|
|
112331
|
-
if (_Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__.Unit.isUnit(unitOrConstant))
|
|
112332
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);
|
|
112333
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);
|
|
112334
|
-
}
|
|
112335
|
-
}
|
|
112336
|
-
|
|
112337
|
-
|
|
112338
112097
|
/***/ }),
|
|
112339
112098
|
|
|
112340
112099
|
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js":
|
|
@@ -112352,7 +112111,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112352
112111
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
112353
112112
|
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
112354
112113
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
112355
|
-
/* harmony import */ var
|
|
112114
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112356
112115
|
/* harmony import */ var _UnitTree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./UnitTree */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitTree.js");
|
|
112357
112116
|
/*---------------------------------------------------------------------------------------------
|
|
112358
112117
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -112412,7 +112171,7 @@ class UnitConverter {
|
|
|
112412
112171
|
*/
|
|
112413
112172
|
async processUnits(from, to) {
|
|
112414
112173
|
if (from.key.matches(to.key))
|
|
112415
|
-
return
|
|
112174
|
+
return _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112416
112175
|
const areCompatible = await _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__.Unit.areCompatible(from, to);
|
|
112417
112176
|
if (!areCompatible)
|
|
112418
112177
|
throw new _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BentleyError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BentleyStatus.ERROR, `Source and target units do not belong to same phenomenon`, () => {
|
|
@@ -112432,8 +112191,8 @@ class UnitConverter {
|
|
|
112432
112191
|
return { from, to };
|
|
112433
112192
|
});
|
|
112434
112193
|
// Final calculations to get singular UnitConversion between from -> to
|
|
112435
|
-
const fromMap = fromMapStore.get(from.key.fullName) ||
|
|
112436
|
-
const toMap = toMapStore.get(to.key.fullName) ||
|
|
112194
|
+
const fromMap = fromMapStore.get(from.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112195
|
+
const toMap = toMapStore.get(to.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112437
112196
|
const fromInverse = fromMap.inverse();
|
|
112438
112197
|
return fromInverse.compose(toMap);
|
|
112439
112198
|
}
|
|
@@ -112488,9 +112247,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112488
112247
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
112489
112248
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
112490
112249
|
/* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
|
|
112491
|
-
/* harmony import */ var
|
|
112492
|
-
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Parser */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js");
|
|
112493
|
-
/* harmony import */ var _Graph__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Graph */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js");
|
|
112250
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112494
112251
|
/*---------------------------------------------------------------------------------------------
|
|
112495
112252
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112496
112253
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -112500,13 +112257,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112500
112257
|
|
|
112501
112258
|
|
|
112502
112259
|
|
|
112503
|
-
|
|
112504
|
-
|
|
112505
112260
|
/** @internal */
|
|
112506
112261
|
class GraphUtils {
|
|
112507
112262
|
/**
|
|
112508
112263
|
* DFS traversal - Post order
|
|
112509
|
-
* @param _graph
|
|
112264
|
+
* @param _graph DirectedGraph to traverse
|
|
112510
112265
|
* @param start Starting node
|
|
112511
112266
|
* @param keyFrom Get key from label
|
|
112512
112267
|
* @param op Reducing function
|
|
@@ -112537,7 +112292,7 @@ class GraphUtils {
|
|
|
112537
112292
|
/** @internal */
|
|
112538
112293
|
class UnitGraph {
|
|
112539
112294
|
_context;
|
|
112540
|
-
_graph = new
|
|
112295
|
+
_graph = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversionGraph();
|
|
112541
112296
|
_unitsInProgress = new Map();
|
|
112542
112297
|
constructor(_context) {
|
|
112543
112298
|
this._context = _context;
|
|
@@ -112616,7 +112371,7 @@ class UnitGraph {
|
|
|
112616
112371
|
.finally(() => this._unitsInProgress.delete(unit.key.fullName));
|
|
112617
112372
|
}
|
|
112618
112373
|
async addUnitToGraph(unit) {
|
|
112619
|
-
const umap = (0,
|
|
112374
|
+
const umap = (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.parseDefinition)(unit.definition);
|
|
112620
112375
|
const promiseArray = [];
|
|
112621
112376
|
for (const [key, value] of umap) {
|
|
112622
112377
|
promiseArray.push(this.resolveUnit(key, unit.schema).then((u) => [u, value]));
|
|
@@ -112650,17 +112405,19 @@ class UnitGraph {
|
|
|
112650
112405
|
const cmap = outEdges.reduce((pm, e) => {
|
|
112651
112406
|
const { exponent } = this._graph.edge(e.v, e.w);
|
|
112652
112407
|
const stored = innermapStore.get(e.w);
|
|
112653
|
-
const map = stored ? stored :
|
|
112408
|
+
const map = stored ? stored : _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112654
112409
|
const emap = map.raise(exponent);
|
|
112655
112410
|
return pm ? pm.multiply(emap) : emap;
|
|
112656
112411
|
}, undefined);
|
|
112657
|
-
|
|
112658
|
-
|
|
112412
|
+
// EC Constant nodes have no offset property → UnitConversionSource.offset is undefined → 0.
|
|
112413
|
+
// Matches the prior explicit 0.0 branch before UnitConversion moved to core-quantity.
|
|
112414
|
+
const thisMap = this._graph.node(unitFullName) ? _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.from(this._graph.node(unitFullName)) : _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112415
|
+
const other = cmap || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112659
112416
|
const result = other.compose(thisMap);
|
|
112660
112417
|
innermapStore.set(unitFullName, result);
|
|
112661
112418
|
}
|
|
112662
112419
|
else {
|
|
112663
|
-
innermapStore.set(unitFullName,
|
|
112420
|
+
innermapStore.set(unitFullName, _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity);
|
|
112664
112421
|
}
|
|
112665
112422
|
return innermapStore;
|
|
112666
112423
|
}
|
|
@@ -112704,6 +112461,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112704
112461
|
|
|
112705
112462
|
/**
|
|
112706
112463
|
* Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.
|
|
112464
|
+
*
|
|
112465
|
+
* To layer schema-defined units on top of the bundled BIS units from `@itwin/core-quantity`,
|
|
112466
|
+
* pass this as `primary` to `createUnitsProvider` from `@itwin/core-quantity`.
|
|
112707
112467
|
* @beta
|
|
112708
112468
|
*/
|
|
112709
112469
|
class SchemaUnitProvider {
|
|
@@ -113055,7 +112815,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113055
112815
|
/* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
|
|
113056
112816
|
/* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
|
|
113057
112817
|
/* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
|
|
113058
|
-
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */
|
|
112818
|
+
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
|
|
113059
112819
|
/* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
|
|
113060
112820
|
/* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
|
|
113061
112821
|
/* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
|
|
@@ -113063,8 +112823,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113063
112823
|
/* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
|
|
113064
112824
|
/* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
|
|
113065
112825
|
/* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
|
|
113066
|
-
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */
|
|
113067
|
-
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */
|
|
112826
|
+
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */ _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.FormatSetFormatsProvider),
|
|
112827
|
+
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
|
|
113068
112828
|
/* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
|
|
113069
112829
|
/* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
|
|
113070
112830
|
/* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
|
|
@@ -113086,8 +112846,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113086
112846
|
/* harmony export */ Schema: () => (/* reexport safe */ _Metadata_Schema__WEBPACK_IMPORTED_MODULE_25__.Schema),
|
|
113087
112847
|
/* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
|
|
113088
112848
|
/* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
|
|
113089
|
-
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */
|
|
113090
|
-
/* harmony export */ SchemaGraph: () => (/* reexport safe */
|
|
112849
|
+
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__.SchemaFormatsProvider),
|
|
112850
|
+
/* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
|
|
113091
112851
|
/* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
|
|
113092
112852
|
/* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
|
|
113093
112853
|
/* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
|
|
@@ -113096,18 +112856,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113096
112856
|
/* harmony export */ SchemaKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaKey),
|
|
113097
112857
|
/* harmony export */ SchemaLoader: () => (/* reexport safe */ _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__.SchemaLoader),
|
|
113098
112858
|
/* harmony export */ SchemaMatchType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.SchemaMatchType),
|
|
113099
|
-
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */
|
|
112859
|
+
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */ _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__.SchemaPartVisitorDelegate),
|
|
113100
112860
|
/* harmony export */ SchemaReadHelper: () => (/* reexport safe */ _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_5__.SchemaReadHelper),
|
|
113101
|
-
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */
|
|
113102
|
-
/* harmony export */ SchemaWalker: () => (/* reexport safe */
|
|
112861
|
+
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */ _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__.SchemaUnitProvider),
|
|
112862
|
+
/* harmony export */ SchemaWalker: () => (/* reexport safe */ _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__.SchemaWalker),
|
|
113103
112863
|
/* harmony export */ StrengthDirection: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthDirection),
|
|
113104
112864
|
/* harmony export */ StrengthType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthType),
|
|
113105
112865
|
/* harmony export */ StructArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructArrayProperty),
|
|
113106
112866
|
/* harmony export */ StructClass: () => (/* reexport safe */ _Metadata_Class__WEBPACK_IMPORTED_MODULE_11__.StructClass),
|
|
113107
112867
|
/* harmony export */ StructProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructProperty),
|
|
113108
112868
|
/* harmony export */ Unit: () => (/* reexport safe */ _Metadata_Unit__WEBPACK_IMPORTED_MODULE_27__.Unit),
|
|
113109
|
-
/* harmony export */
|
|
113110
|
-
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_34__.UnitConverter),
|
|
112869
|
+
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__.UnitConverter),
|
|
113111
112870
|
/* harmony export */ UnitSystem: () => (/* reexport safe */ _Metadata_UnitSystem__WEBPACK_IMPORTED_MODULE_28__.UnitSystem),
|
|
113112
112871
|
/* harmony export */ XmlParser: () => (/* reexport safe */ _Deserialization_XmlParser__WEBPACK_IMPORTED_MODULE_6__.XmlParser),
|
|
113113
112872
|
/* harmony export */ classModifierToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.classModifierToString),
|
|
@@ -113162,16 +112921,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113162
112921
|
/* harmony import */ var _SchemaJsonLocater__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./SchemaJsonLocater */ "../../core/ecschema-metadata/lib/esm/SchemaJsonLocater.js");
|
|
113163
112922
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
113164
112923
|
/* harmony import */ var _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./SchemaLoader */ "../../core/ecschema-metadata/lib/esm/SchemaLoader.js");
|
|
113165
|
-
/* harmony import */ var
|
|
113166
|
-
/* harmony import */ var
|
|
113167
|
-
/* harmony import */ var
|
|
113168
|
-
/* harmony import */ var
|
|
113169
|
-
/* harmony import */ var
|
|
113170
|
-
/* harmony import */ var
|
|
113171
|
-
/* harmony import */ var
|
|
113172
|
-
/* harmony import */ var
|
|
113173
|
-
/* harmony import */ var
|
|
113174
|
-
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
112924
|
+
/* harmony import */ var _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./UnitConversion/UnitConverter */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js");
|
|
112925
|
+
/* harmony import */ var _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./UnitProvider/SchemaUnitProvider */ "../../core/ecschema-metadata/lib/esm/UnitProvider/SchemaUnitProvider.js");
|
|
112926
|
+
/* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
|
|
112927
|
+
/* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
|
|
112928
|
+
/* harmony import */ var _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./Formatting/SchemaFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/SchemaFormatsProvider.js");
|
|
112929
|
+
/* harmony import */ var _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./Formatting/FormatSetFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/FormatSetFormatsProvider.js");
|
|
112930
|
+
/* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
|
|
112931
|
+
/* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
|
|
112932
|
+
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
113175
112933
|
/*---------------------------------------------------------------------------------------------
|
|
113176
112934
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
113177
112935
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -113216,7 +112974,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113216
112974
|
|
|
113217
112975
|
|
|
113218
112976
|
|
|
113219
|
-
|
|
113220
112977
|
|
|
113221
112978
|
|
|
113222
112979
|
/** @docs-package-description
|
|
@@ -194085,6 +193842,44 @@ class EngineeringLengthDescription extends _FormattedQuantityDescription__WEBPAC
|
|
|
194085
193842
|
}
|
|
194086
193843
|
|
|
194087
193844
|
|
|
193845
|
+
/***/ }),
|
|
193846
|
+
|
|
193847
|
+
/***/ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js":
|
|
193848
|
+
/*!******************************************************************************!*\
|
|
193849
|
+
!*** ../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js ***!
|
|
193850
|
+
\******************************************************************************/
|
|
193851
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
193852
|
+
|
|
193853
|
+
"use strict";
|
|
193854
|
+
__webpack_require__.r(__webpack_exports__);
|
|
193855
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
193856
|
+
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
193857
|
+
/* harmony export */ });
|
|
193858
|
+
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
193859
|
+
/*---------------------------------------------------------------------------------------------
|
|
193860
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
193861
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
193862
|
+
*--------------------------------------------------------------------------------------------*/
|
|
193863
|
+
/** @packageDocumentation
|
|
193864
|
+
* @module QuantityFormatting
|
|
193865
|
+
*/
|
|
193866
|
+
|
|
193867
|
+
/** Function to generate default set of alternate unit labels
|
|
193868
|
+
* @internal
|
|
193869
|
+
*/
|
|
193870
|
+
function getDefaultAlternateUnitLabels() {
|
|
193871
|
+
const altDisplayLabelsMap = new Map();
|
|
193872
|
+
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_0__.UNIT_EXTRA_DATA) {
|
|
193873
|
+
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
193874
|
+
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
193875
|
+
}
|
|
193876
|
+
}
|
|
193877
|
+
if (altDisplayLabelsMap.size)
|
|
193878
|
+
return altDisplayLabelsMap;
|
|
193879
|
+
return undefined;
|
|
193880
|
+
}
|
|
193881
|
+
|
|
193882
|
+
|
|
194088
193883
|
/***/ }),
|
|
194089
193884
|
|
|
194090
193885
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/BaseUnitFormattingSettingsProvider.js":
|
|
@@ -194228,178 +194023,6 @@ class BaseUnitFormattingSettingsProvider {
|
|
|
194228
194023
|
}
|
|
194229
194024
|
|
|
194230
194025
|
|
|
194231
|
-
/***/ }),
|
|
194232
|
-
|
|
194233
|
-
/***/ "../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js":
|
|
194234
|
-
/*!*****************************************************************************!*\
|
|
194235
|
-
!*** ../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js ***!
|
|
194236
|
-
\*****************************************************************************/
|
|
194237
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
194238
|
-
|
|
194239
|
-
"use strict";
|
|
194240
|
-
__webpack_require__.r(__webpack_exports__);
|
|
194241
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
194242
|
-
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
194243
|
-
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
194244
|
-
/* harmony export */ });
|
|
194245
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
194246
|
-
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
194247
|
-
/*---------------------------------------------------------------------------------------------
|
|
194248
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
194249
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
194250
|
-
*--------------------------------------------------------------------------------------------*/
|
|
194251
|
-
/** @packageDocumentation
|
|
194252
|
-
* @module QuantityFormatting
|
|
194253
|
-
*/
|
|
194254
|
-
|
|
194255
|
-
|
|
194256
|
-
// cSpell:ignore ussurvey USCUSTOM
|
|
194257
|
-
/** Units provider that provides a limited number of UnitDefinitions that are needed to support basic tools.
|
|
194258
|
-
* @internal
|
|
194259
|
-
*/
|
|
194260
|
-
class BasicUnitsProvider {
|
|
194261
|
-
/** Find a unit given the unitLabel. */
|
|
194262
|
-
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
194263
|
-
const labelToFind = unitLabel.toLowerCase();
|
|
194264
|
-
const unitFamilyToFind = phenomenon ? phenomenon.toLowerCase() : undefined;
|
|
194265
|
-
const unitSystemToFind = unitSystem ? unitSystem.toLowerCase() : undefined;
|
|
194266
|
-
for (const entry of UNIT_DATA) {
|
|
194267
|
-
if (schemaName && schemaName !== "Units")
|
|
194268
|
-
continue;
|
|
194269
|
-
if (phenomenon && entry.phenomenon.toLowerCase() !== unitFamilyToFind)
|
|
194270
|
-
continue;
|
|
194271
|
-
if (unitSystemToFind && entry.system.toLowerCase() !== unitSystemToFind)
|
|
194272
|
-
continue;
|
|
194273
|
-
if (entry.displayLabel.toLowerCase() === labelToFind || entry.name.toLowerCase() === labelToFind) {
|
|
194274
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
194275
|
-
return unitProps;
|
|
194276
|
-
}
|
|
194277
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
194278
|
-
if (entry.altDisplayLabels.findIndex((ref) => ref.toLowerCase() === labelToFind) !== -1) {
|
|
194279
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
194280
|
-
return unitProps;
|
|
194281
|
-
}
|
|
194282
|
-
}
|
|
194283
|
-
}
|
|
194284
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
194285
|
-
}
|
|
194286
|
-
/** Find all units given phenomenon */
|
|
194287
|
-
async getUnitsByFamily(phenomenon) {
|
|
194288
|
-
const units = [];
|
|
194289
|
-
for (const entry of UNIT_DATA) {
|
|
194290
|
-
if (entry.phenomenon !== phenomenon)
|
|
194291
|
-
continue;
|
|
194292
|
-
units.push(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system));
|
|
194293
|
-
}
|
|
194294
|
-
return units;
|
|
194295
|
-
}
|
|
194296
|
-
findUnitDefinition(name) {
|
|
194297
|
-
for (const entry of UNIT_DATA) {
|
|
194298
|
-
if (entry.name === name)
|
|
194299
|
-
return entry;
|
|
194300
|
-
}
|
|
194301
|
-
return undefined;
|
|
194302
|
-
}
|
|
194303
|
-
/** Find a unit given the unit's unique name. */
|
|
194304
|
-
async findUnitByName(unitName) {
|
|
194305
|
-
const unitDataEntry = this.findUnitDefinition(unitName);
|
|
194306
|
-
if (unitDataEntry) {
|
|
194307
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(unitDataEntry.name, unitDataEntry.displayLabel, unitDataEntry.phenomenon, unitDataEntry.system);
|
|
194308
|
-
}
|
|
194309
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
194310
|
-
}
|
|
194311
|
-
/** Return the information needed to convert a value between two different units. The units should be from the same phenomenon. */
|
|
194312
|
-
async getConversion(fromUnit, toUnit) {
|
|
194313
|
-
const fromUnitData = this.findUnitDefinition(fromUnit.name);
|
|
194314
|
-
const toUnitData = this.findUnitDefinition(toUnit.name);
|
|
194315
|
-
if (fromUnitData && toUnitData) {
|
|
194316
|
-
const deltaOffset = toUnitData.conversion.offset - fromUnitData.conversion.offset;
|
|
194317
|
-
const deltaNumerator = toUnitData.conversion.numerator * fromUnitData.conversion.denominator;
|
|
194318
|
-
const deltaDenominator = toUnitData.conversion.denominator * fromUnitData.conversion.numerator;
|
|
194319
|
-
const conversionData = new ConversionData();
|
|
194320
|
-
conversionData.factor = deltaNumerator / deltaDenominator;
|
|
194321
|
-
conversionData.offset = deltaOffset;
|
|
194322
|
-
return conversionData;
|
|
194323
|
-
}
|
|
194324
|
-
return new ConversionData();
|
|
194325
|
-
}
|
|
194326
|
-
}
|
|
194327
|
-
/** Class that implements the minimum UnitConversionProps interface to provide information needed to convert unit values.
|
|
194328
|
-
* @alpha
|
|
194329
|
-
*/
|
|
194330
|
-
class ConversionData {
|
|
194331
|
-
factor = 1.0;
|
|
194332
|
-
offset = 0.0;
|
|
194333
|
-
error = false;
|
|
194334
|
-
}
|
|
194335
|
-
/** Function to generate default set of alternate unit labels
|
|
194336
|
-
* @internal
|
|
194337
|
-
*/
|
|
194338
|
-
function getDefaultAlternateUnitLabels() {
|
|
194339
|
-
const altDisplayLabelsMap = new Map();
|
|
194340
|
-
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_1__.UNIT_EXTRA_DATA) {
|
|
194341
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
194342
|
-
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
194343
|
-
}
|
|
194344
|
-
}
|
|
194345
|
-
if (altDisplayLabelsMap.size)
|
|
194346
|
-
return altDisplayLabelsMap;
|
|
194347
|
-
return undefined;
|
|
194348
|
-
}
|
|
194349
|
-
// ========================================================================================================================================
|
|
194350
|
-
// Minimum set of UNITs to be removed when official UnitsProvider is available
|
|
194351
|
-
// ========================================================================================================================================
|
|
194352
|
-
// cSpell:ignore MILLIINCH, MICROINCH, MILLIFOOT
|
|
194353
|
-
// Set of supported units - this information will come from Schema-based units once the EC package is ready to provide this information.
|
|
194354
|
-
const UNIT_DATA = [
|
|
194355
|
-
// Angles ( base unit radian )
|
|
194356
|
-
{ name: "Units.RAD", phenomenon: "Units.ANGLE", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "rad" },
|
|
194357
|
-
// 1 rad = 180.0/PI °
|
|
194358
|
-
{ name: "Units.ARC_DEG", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 180.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "°" },
|
|
194359
|
-
{ name: "Units.ARC_MINUTE", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 10800.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "'" },
|
|
194360
|
-
{ name: "Units.ARC_SECOND", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 648000.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: '"' },
|
|
194361
|
-
{ name: "Units.GRAD", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 200, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "grad" },
|
|
194362
|
-
// Time ( base unit second )
|
|
194363
|
-
{ name: "Units.S", phenomenon: "Units.TIME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "s" },
|
|
194364
|
-
{ name: "Units.MIN", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 60.0, offset: 0.0 }, displayLabel: "min" },
|
|
194365
|
-
{ name: "Units.HR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 3600.0, offset: 0.0 }, displayLabel: "h" },
|
|
194366
|
-
{ name: "Units.DAY", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 86400.0, offset: 0.0 }, displayLabel: "days" },
|
|
194367
|
-
{ name: "Units.WEEK", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 604800.0, offset: 0.0 }, displayLabel: "weeks" },
|
|
194368
|
-
// 1 sec = 1/31536000.0 yr
|
|
194369
|
-
{ name: "Units.YR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 31536000.0, offset: 0.0 }, displayLabel: "years" },
|
|
194370
|
-
// conversion => specified unit to base unit of m
|
|
194371
|
-
{ name: "Units.M", phenomenon: "Units.LENGTH", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m" },
|
|
194372
|
-
{ name: "Units.MM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "mm" },
|
|
194373
|
-
{ name: "Units.CM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 100.0, denominator: 1.0, offset: 0.0 }, displayLabel: "cm" },
|
|
194374
|
-
{ name: "Units.DM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 10.0, denominator: 1.0, offset: 0.0 }, displayLabel: "dm" },
|
|
194375
|
-
{ name: "Units.KM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1.0, denominator: 1000.0, offset: 0.0 }, displayLabel: "km" },
|
|
194376
|
-
{ name: "Units.UM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "µm" },
|
|
194377
|
-
{ name: "Units.MILLIINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "mil" },
|
|
194378
|
-
{ name: "Units.MICROINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "µin" },
|
|
194379
|
-
{ name: "Units.MILLIFOOT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "mft" },
|
|
194380
|
-
{ name: "Units.IN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "in" },
|
|
194381
|
-
{ name: "Units.FT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "ft" },
|
|
194382
|
-
{ name: "Units.CHAIN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 66.0 * 0.3048, offset: 0.0 }, displayLabel: "chain" },
|
|
194383
|
-
{ name: "Units.YRD", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.9144, offset: 0.0 }, displayLabel: "yd" },
|
|
194384
|
-
{ name: "Units.MILE", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 1609.344, offset: 0.0 }, displayLabel: "mi" },
|
|
194385
|
-
{ name: "Units.US_SURVEY_FT", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 1200.0, offset: 0.0 }, displayLabel: "ft (US Survey)" },
|
|
194386
|
-
{ name: "Units.US_SURVEY_YRD", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 3.0 * 1200.0, offset: 0.0 }, displayLabel: "yrd (US Survey)" },
|
|
194387
|
-
{ name: "Units.US_SURVEY_IN", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 100.0, offset: 0.0 }, displayLabel: "in (US Survey)" },
|
|
194388
|
-
{ name: "Units.US_SURVEY_MILE", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 5280.0 * 1200.0, offset: 0.0 }, displayLabel: "mi (US Survey)" },
|
|
194389
|
-
{ name: "Units.US_SURVEY_CHAIN", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 1.0, denominator: 20.11684, offset: 0.0 }, displayLabel: "chain (US Survey)" },
|
|
194390
|
-
// conversion => specified unit to base unit of m²
|
|
194391
|
-
{ name: "Units.SQ_FT", phenomenon: "Units.AREA", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: .09290304, offset: 0.0 }, displayLabel: "ft²" },
|
|
194392
|
-
{ name: "Units.SQ_US_SURVEY_FT", phenomenon: "Units.AREA", system: "Units.USCUSTOM", conversion: { numerator: 15499969.0, denominator: 1440000, offset: 0.0 }, displayLabel: "ft² (US Survey)" },
|
|
194393
|
-
{ name: "Units.SQ_M", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m²" },
|
|
194394
|
-
{ name: "Units.SQ_KM", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1000000.0, offset: 0.0 }, displayLabel: "km²" },
|
|
194395
|
-
// conversion => specified unit to base unit m³
|
|
194396
|
-
{ name: "Units.CUB_FT", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.028316847, offset: 0.0 }, displayLabel: "ft³" },
|
|
194397
|
-
{ name: "Units.CUB_US_SURVEY_FT", phenomenon: "Units.VOLUME", system: "Units.USSURVEY", conversion: { numerator: 1, denominator: 0.0283170164937591, offset: 0.0 }, displayLabel: "ft³" },
|
|
194398
|
-
{ name: "Units.CUB_YRD", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.76455486, offset: 0.0 }, displayLabel: "yd³" },
|
|
194399
|
-
{ name: "Units.CUB_M", phenomenon: "Units.VOLUME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m³" },
|
|
194400
|
-
];
|
|
194401
|
-
|
|
194402
|
-
|
|
194403
194026
|
/***/ }),
|
|
194404
194027
|
|
|
194405
194028
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/LocalUnitFormatProvider.js":
|
|
@@ -194507,7 +194130,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
194507
194130
|
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
194508
194131
|
/* harmony import */ var _common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/FrontendLoggerCategory */ "../../core/frontend/lib/esm/common/FrontendLoggerCategory.js");
|
|
194509
194132
|
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
194510
|
-
/* harmony import */ var
|
|
194133
|
+
/* harmony import */ var _AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./AlternateUnitLabels */ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js");
|
|
194511
194134
|
/*---------------------------------------------------------------------------------------------
|
|
194512
194135
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
194513
194136
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -194715,8 +194338,8 @@ class FormatsProviderManager {
|
|
|
194715
194338
|
*/
|
|
194716
194339
|
class QuantityFormatter {
|
|
194717
194340
|
static _allUnitSystems = ["metric", "imperial", "usCustomary", "usSurvey"];
|
|
194718
|
-
_unitsProvider = new
|
|
194719
|
-
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,
|
|
194341
|
+
_unitsProvider = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider();
|
|
194342
|
+
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,_AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__.getDefaultAlternateUnitLabels)());
|
|
194720
194343
|
/** Registry containing available quantity type definitions. */
|
|
194721
194344
|
_quantityTypeRegistry = new Map();
|
|
194722
194345
|
/** Registry containing available FormatterSpec and ParserSpec, mapped by keys.
|
|
@@ -195168,9 +194791,10 @@ class QuantityFormatter {
|
|
|
195168
194791
|
* `IModelApp.toolAdmin.restartPrimitiveTool()` to allow the tool to reinitialize itself.
|
|
195169
194792
|
*/
|
|
195170
194793
|
async resetToUseInternalUnitsProvider() {
|
|
195171
|
-
|
|
194794
|
+
// Coupled to createUnitsProvider() returning BasicUnitsProvider directly when no primary is set.
|
|
194795
|
+
if (this._unitsProvider instanceof _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider)
|
|
195172
194796
|
return;
|
|
195173
|
-
await this.setUnitsProvider(new
|
|
194797
|
+
await this.setUnitsProvider(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider());
|
|
195174
194798
|
}
|
|
195175
194799
|
/** Async call to register a CustomQuantityType and load the FormatSpec and ParserSpec for the new type. */
|
|
195176
194800
|
async registerQuantityType(entry, replace) {
|
|
@@ -195458,7 +195082,10 @@ class QuantityFormatter {
|
|
|
195458
195082
|
}
|
|
195459
195083
|
/** Returns data needed to convert from one Unit to another in the same Unit Family/Phenomenon. */
|
|
195460
195084
|
async getConversion(fromUnit, toUnit) {
|
|
195461
|
-
|
|
195085
|
+
const result = await this._unitsProvider.getConversion(fromUnit, toUnit);
|
|
195086
|
+
if (result.error)
|
|
195087
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(`${_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__.FrontendLoggerCategory.Package}.quantityFormatter`, `Unit conversion from "${fromUnit.name}" to "${toUnit.name}" could not be resolved.`);
|
|
195088
|
+
return result;
|
|
195462
195089
|
}
|
|
195463
195090
|
/**
|
|
195464
195091
|
* Creates a [[FormatterSpec]] for a given persistence unit name and format properties, using the [[UnitsProvider]] to resolve the persistence unit.
|
|
@@ -345469,6 +345096,362 @@ class UrlFS extends _FileStorage__WEBPACK_IMPORTED_MODULE_6__.FileStorage {
|
|
|
345469
345096
|
}
|
|
345470
345097
|
|
|
345471
345098
|
|
|
345099
|
+
/***/ }),
|
|
345100
|
+
|
|
345101
|
+
/***/ "../../core/quantity/lib/esm/BasicUnitsProvider.js":
|
|
345102
|
+
/*!*********************************************************!*\
|
|
345103
|
+
!*** ../../core/quantity/lib/esm/BasicUnitsProvider.js ***!
|
|
345104
|
+
\*********************************************************/
|
|
345105
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
345106
|
+
|
|
345107
|
+
"use strict";
|
|
345108
|
+
__webpack_require__.r(__webpack_exports__);
|
|
345109
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
345110
|
+
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
345111
|
+
/* harmony export */ _testResetUnitsCache: () => (/* binding */ _testResetUnitsCache)
|
|
345112
|
+
/* harmony export */ });
|
|
345113
|
+
/* harmony import */ var _Interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Interfaces */ "../../core/quantity/lib/esm/Interfaces.js");
|
|
345114
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
345115
|
+
/* harmony import */ var _UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./UnitConversion/nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
345116
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
345117
|
+
/*---------------------------------------------------------------------------------------------
|
|
345118
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
345119
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
345120
|
+
*--------------------------------------------------------------------------------------------*/
|
|
345121
|
+
|
|
345122
|
+
|
|
345123
|
+
|
|
345124
|
+
|
|
345125
|
+
// Module-level cache: the unit data is derived deterministically from the bundled Units.json
|
|
345126
|
+
// asset, so the resolved indexes are effectively an immutable constant. Caching at module
|
|
345127
|
+
// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.
|
|
345128
|
+
// in tests or when composed inside CompositeUnitsProvider).
|
|
345129
|
+
// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint
|
|
345130
|
+
// near-zero until a provider method is actually called.
|
|
345131
|
+
let _resolvePromise;
|
|
345132
|
+
let _permanentError;
|
|
345133
|
+
async function resolveState() {
|
|
345134
|
+
if (_permanentError !== undefined) {
|
|
345135
|
+
throw _permanentError;
|
|
345136
|
+
}
|
|
345137
|
+
if (!_resolvePromise) {
|
|
345138
|
+
_resolvePromise = _buildState().catch((err) => {
|
|
345139
|
+
_permanentError = err instanceof Error ? err : new Error(String(err));
|
|
345140
|
+
_resolvePromise = undefined;
|
|
345141
|
+
throw _permanentError;
|
|
345142
|
+
});
|
|
345143
|
+
}
|
|
345144
|
+
return _resolvePromise;
|
|
345145
|
+
}
|
|
345146
|
+
/** @internal — test use only. Resets the module-level lazy cache. */
|
|
345147
|
+
function _testResetUnitsCache() {
|
|
345148
|
+
_resolvePromise = undefined;
|
|
345149
|
+
_permanentError = undefined;
|
|
345150
|
+
}
|
|
345151
|
+
async function _buildState() {
|
|
345152
|
+
const { default: schema } = await __webpack_require__.e(/*! import() */ "core_quantity_lib_esm_assets_Units_json").then(__webpack_require__.t.bind(__webpack_require__, /*! ./assets/Units.json */ "../../core/quantity/lib/esm/assets/Units.json", 19));
|
|
345153
|
+
const nameMap = new Map();
|
|
345154
|
+
const labelMap = new Map();
|
|
345155
|
+
const phenomenonMap = new Map();
|
|
345156
|
+
const invertedUnits = new Map();
|
|
345157
|
+
const s = schema;
|
|
345158
|
+
const resolver = new _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__.UnitDefinitionResolver(s);
|
|
345159
|
+
const resolved = resolver.resolveAll();
|
|
345160
|
+
for (const [name, entry] of resolved) {
|
|
345161
|
+
const item = s.items[name];
|
|
345162
|
+
const phenomenon = item.phenomenon;
|
|
345163
|
+
const unitSystem = item.unitSystem;
|
|
345164
|
+
const fullName = `${s.name}.${name}`;
|
|
345165
|
+
const props = {
|
|
345166
|
+
name: fullName,
|
|
345167
|
+
label: entry.label,
|
|
345168
|
+
phenomenon,
|
|
345169
|
+
isValid: true,
|
|
345170
|
+
system: unitSystem,
|
|
345171
|
+
};
|
|
345172
|
+
const indexed = { props, resolved: entry };
|
|
345173
|
+
nameMap.set(fullName, indexed);
|
|
345174
|
+
const lowerLabel = entry.label.toLowerCase();
|
|
345175
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
345176
|
+
byLabel.push(indexed);
|
|
345177
|
+
labelMap.set(lowerLabel, byLabel);
|
|
345178
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
345179
|
+
byPhen.push(indexed);
|
|
345180
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
345181
|
+
}
|
|
345182
|
+
// Handle InvertedUnit items — must run after nameMap is fully populated above because
|
|
345183
|
+
// invertedSource lookup requires the inverted unit's target to already be in nameMap.
|
|
345184
|
+
for (const [name, item] of Object.entries(s.items)) {
|
|
345185
|
+
if (item.schemaItemType !== "InvertedUnit") {
|
|
345186
|
+
continue;
|
|
345187
|
+
}
|
|
345188
|
+
const inv = item;
|
|
345189
|
+
const fullName = `${s.name}.${name}`;
|
|
345190
|
+
const invertsName = (0,_UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__.qualifyItemName)(inv.invertsUnit, s.name);
|
|
345191
|
+
const unitSystem = inv.unitSystem;
|
|
345192
|
+
const invertedSource = nameMap.get(invertsName);
|
|
345193
|
+
const phenomenon = invertedSource?.props.phenomenon ?? "";
|
|
345194
|
+
const props = {
|
|
345195
|
+
name: fullName,
|
|
345196
|
+
label: inv.label ?? name,
|
|
345197
|
+
phenomenon,
|
|
345198
|
+
isValid: true,
|
|
345199
|
+
system: unitSystem,
|
|
345200
|
+
};
|
|
345201
|
+
invertedUnits.set(fullName, { props, invertsUnitName: invertsName });
|
|
345202
|
+
if (invertedSource) {
|
|
345203
|
+
const indexed = {
|
|
345204
|
+
props,
|
|
345205
|
+
resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },
|
|
345206
|
+
};
|
|
345207
|
+
nameMap.set(fullName, indexed);
|
|
345208
|
+
const lowerLabel = props.label.toLowerCase();
|
|
345209
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
345210
|
+
byLabel.push(indexed);
|
|
345211
|
+
labelMap.set(lowerLabel, byLabel);
|
|
345212
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
345213
|
+
byPhen.push(indexed);
|
|
345214
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
345215
|
+
}
|
|
345216
|
+
}
|
|
345217
|
+
return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };
|
|
345218
|
+
}
|
|
345219
|
+
/**
|
|
345220
|
+
* A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.
|
|
345221
|
+
*
|
|
345222
|
+
* The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method
|
|
345223
|
+
* call and cached at module scope — construction is essentially free, and multiple instances
|
|
345224
|
+
* share the same immutable lookup indexes.
|
|
345225
|
+
*
|
|
345226
|
+
* This is the zero-dependency default for backends, tools, and any frontend that doesn't need
|
|
345227
|
+
* iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.
|
|
345228
|
+
*
|
|
345229
|
+
* @see createUnitsProvider for layering schema-defined units on top of basic BIS units.
|
|
345230
|
+
* @beta
|
|
345231
|
+
*/
|
|
345232
|
+
class BasicUnitsProvider {
|
|
345233
|
+
// ── UnitsProvider implementation ─────────────────────────────────────
|
|
345234
|
+
/** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.
|
|
345235
|
+
* @param unitLabel - The display label to search for (case-insensitive).
|
|
345236
|
+
* @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `"Units"`.
|
|
345237
|
+
* @param phenomenon - Optional phenomenon filter (e.g. `"Units.LENGTH"`).
|
|
345238
|
+
* @param unitSystem - Optional unit system filter (e.g. `"Units.METRIC"`).
|
|
345239
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if no match is found.
|
|
345240
|
+
*/
|
|
345241
|
+
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
345242
|
+
const state = await resolveState();
|
|
345243
|
+
if (schemaName && schemaName !== state.schemaName) {
|
|
345244
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345245
|
+
}
|
|
345246
|
+
const candidates = state.labelMap.get(unitLabel.toLowerCase());
|
|
345247
|
+
if (!candidates || candidates.length === 0) {
|
|
345248
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345249
|
+
}
|
|
345250
|
+
for (const c of candidates) {
|
|
345251
|
+
if (phenomenon && c.props.phenomenon !== phenomenon) {
|
|
345252
|
+
continue;
|
|
345253
|
+
}
|
|
345254
|
+
if (unitSystem && c.props.system !== unitSystem) {
|
|
345255
|
+
continue;
|
|
345256
|
+
}
|
|
345257
|
+
return c.props;
|
|
345258
|
+
}
|
|
345259
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345260
|
+
}
|
|
345261
|
+
/** Return all units belonging to the given phenomenon (unit family).
|
|
345262
|
+
* @param phenomenon - The phenomenon full name (e.g. `"Units.LENGTH"`).
|
|
345263
|
+
* @returns An array of matching `UnitProps`, or an empty array if none.
|
|
345264
|
+
*/
|
|
345265
|
+
async getUnitsByFamily(phenomenon) {
|
|
345266
|
+
const state = await resolveState();
|
|
345267
|
+
const entries = state.phenomenonMap.get(phenomenon);
|
|
345268
|
+
return entries ? entries.map((e) => e.props) : [];
|
|
345269
|
+
}
|
|
345270
|
+
/** Find a unit by its fully-qualified name (e.g. `"Units.M"`).
|
|
345271
|
+
* @param unitName - The qualified unit name.
|
|
345272
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if not found.
|
|
345273
|
+
*/
|
|
345274
|
+
async findUnitByName(unitName) {
|
|
345275
|
+
const state = await resolveState();
|
|
345276
|
+
const entry = state.nameMap.get(unitName);
|
|
345277
|
+
return entry ? entry.props : new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345278
|
+
}
|
|
345279
|
+
/** Compute the conversion factors from `fromUnit` to `toUnit`.
|
|
345280
|
+
* Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.
|
|
345281
|
+
* @param fromUnit - The source unit.
|
|
345282
|
+
* @param toUnit - The target unit.
|
|
345283
|
+
* @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.
|
|
345284
|
+
*/
|
|
345285
|
+
async getConversion(fromUnit, toUnit) {
|
|
345286
|
+
const state = await resolveState();
|
|
345287
|
+
const from = state.nameMap.get(fromUnit.name);
|
|
345288
|
+
const to = state.nameMap.get(toUnit.name);
|
|
345289
|
+
if (!from || !to) {
|
|
345290
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345291
|
+
}
|
|
345292
|
+
const fromInverted = state.invertedUnits.get(fromUnit.name);
|
|
345293
|
+
const toInverted = state.invertedUnits.get(toUnit.name);
|
|
345294
|
+
const fromPhenomenon = fromInverted
|
|
345295
|
+
? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon
|
|
345296
|
+
: from.props.phenomenon;
|
|
345297
|
+
const toPhenomenon = toInverted
|
|
345298
|
+
? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon
|
|
345299
|
+
: to.props.phenomenon;
|
|
345300
|
+
if (fromPhenomenon !== toPhenomenon) {
|
|
345301
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345302
|
+
}
|
|
345303
|
+
if (fromInverted && toInverted) {
|
|
345304
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
345305
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
345306
|
+
if (innerFrom && innerTo) {
|
|
345307
|
+
const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
345308
|
+
return { factor: c.factor, offset: c.offset };
|
|
345309
|
+
}
|
|
345310
|
+
}
|
|
345311
|
+
if (fromInverted) {
|
|
345312
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
345313
|
+
if (innerFrom) {
|
|
345314
|
+
const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
345315
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPreConversion };
|
|
345316
|
+
}
|
|
345317
|
+
}
|
|
345318
|
+
if (toInverted) {
|
|
345319
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
345320
|
+
if (innerTo) {
|
|
345321
|
+
const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
345322
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPostConversion };
|
|
345323
|
+
}
|
|
345324
|
+
}
|
|
345325
|
+
const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
345326
|
+
return { factor: conv.factor, offset: conv.offset };
|
|
345327
|
+
}
|
|
345328
|
+
}
|
|
345329
|
+
|
|
345330
|
+
|
|
345331
|
+
/***/ }),
|
|
345332
|
+
|
|
345333
|
+
/***/ "../../core/quantity/lib/esm/CompositeUnitsProvider.js":
|
|
345334
|
+
/*!*************************************************************!*\
|
|
345335
|
+
!*** ../../core/quantity/lib/esm/CompositeUnitsProvider.js ***!
|
|
345336
|
+
\*************************************************************/
|
|
345337
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
345338
|
+
|
|
345339
|
+
"use strict";
|
|
345340
|
+
__webpack_require__.r(__webpack_exports__);
|
|
345341
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
345342
|
+
/* harmony export */ createUnitsProvider: () => (/* binding */ createUnitsProvider)
|
|
345343
|
+
/* harmony export */ });
|
|
345344
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
345345
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
345346
|
+
/*---------------------------------------------------------------------------------------------
|
|
345347
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
345348
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
345349
|
+
*--------------------------------------------------------------------------------------------*/
|
|
345350
|
+
|
|
345351
|
+
|
|
345352
|
+
/**
|
|
345353
|
+
* Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional
|
|
345354
|
+
* `primary` provider. Typical use: layer an iModel's schema units on top of the bundled
|
|
345355
|
+
* defaults from `@itwin/core-quantity`.
|
|
345356
|
+
*
|
|
345357
|
+
* Precedence rules:
|
|
345358
|
+
* - When `primary` is supplied and `bisUnitsPolicy` is `"preferSchema"` (the default): `primary` wins;
|
|
345359
|
+
* basic BIS units fill any gaps where `primary` returns an invalid unit or throws.
|
|
345360
|
+
* - When `bisUnitsPolicy` is `"preferBundled"`: basic BIS units win; `primary` is consulted only when the
|
|
345361
|
+
* basic provider can't answer.
|
|
345362
|
+
* - `getUnitsByFamily` always merges results from both providers, deduplicated by
|
|
345363
|
+
* `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.
|
|
345364
|
+
* - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`
|
|
345365
|
+
* (no wrapper), preserving `instanceof` checks and keeping the hot path fast.
|
|
345366
|
+
*
|
|
345367
|
+
* @beta
|
|
345368
|
+
*/
|
|
345369
|
+
function createUnitsProvider(options = {}) {
|
|
345370
|
+
const basic = new _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__.BasicUnitsProvider();
|
|
345371
|
+
const primary = options.primary;
|
|
345372
|
+
// NOTE: returns BasicUnitsProvider directly when no primary is provided.
|
|
345373
|
+
// QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.
|
|
345374
|
+
// If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.
|
|
345375
|
+
if (!primary) {
|
|
345376
|
+
return basic;
|
|
345377
|
+
}
|
|
345378
|
+
const providers = options.bisUnitsPolicy === "preferBundled" ? [basic, primary] : [primary, basic];
|
|
345379
|
+
return new CompositeUnitsProvider(providers);
|
|
345380
|
+
}
|
|
345381
|
+
class CompositeUnitsProvider {
|
|
345382
|
+
_providers;
|
|
345383
|
+
constructor(_providers) {
|
|
345384
|
+
this._providers = _providers;
|
|
345385
|
+
}
|
|
345386
|
+
async findUnit(label, schemaName, phenomenon, unitSystem) {
|
|
345387
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345388
|
+
const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));
|
|
345389
|
+
if (hit?.isValid) {
|
|
345390
|
+
return hit;
|
|
345391
|
+
}
|
|
345392
|
+
}
|
|
345393
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
345394
|
+
}
|
|
345395
|
+
async findUnitByName(name) {
|
|
345396
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345397
|
+
const hit = await tryFind(async () => this._providers[i].findUnitByName(name));
|
|
345398
|
+
if (hit?.isValid) {
|
|
345399
|
+
return hit;
|
|
345400
|
+
}
|
|
345401
|
+
}
|
|
345402
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
345403
|
+
}
|
|
345404
|
+
async getUnitsByFamily(phenomenon) {
|
|
345405
|
+
const seen = new Set();
|
|
345406
|
+
const out = [];
|
|
345407
|
+
// Query all providers in parallel; process results in declaration order to honour precedence.
|
|
345408
|
+
const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));
|
|
345409
|
+
for (const units of results) {
|
|
345410
|
+
for (const u of units) {
|
|
345411
|
+
if (!seen.has(u.name)) {
|
|
345412
|
+
seen.add(u.name);
|
|
345413
|
+
out.push(u);
|
|
345414
|
+
}
|
|
345415
|
+
}
|
|
345416
|
+
}
|
|
345417
|
+
return out;
|
|
345418
|
+
}
|
|
345419
|
+
async getConversion(from, to) {
|
|
345420
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345421
|
+
try {
|
|
345422
|
+
const result = await this._providers[i].getConversion(from, to);
|
|
345423
|
+
if (!result.error) {
|
|
345424
|
+
return result;
|
|
345425
|
+
}
|
|
345426
|
+
}
|
|
345427
|
+
catch { /* fall through to next provider */ }
|
|
345428
|
+
}
|
|
345429
|
+
try {
|
|
345430
|
+
return await this._providers[this._providers.length - 1].getConversion(from, to);
|
|
345431
|
+
}
|
|
345432
|
+
catch {
|
|
345433
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345434
|
+
}
|
|
345435
|
+
}
|
|
345436
|
+
}
|
|
345437
|
+
async function tryFind(fn) {
|
|
345438
|
+
try {
|
|
345439
|
+
return await fn();
|
|
345440
|
+
}
|
|
345441
|
+
catch {
|
|
345442
|
+
return undefined;
|
|
345443
|
+
}
|
|
345444
|
+
}
|
|
345445
|
+
async function tryList(fn) {
|
|
345446
|
+
try {
|
|
345447
|
+
return await fn();
|
|
345448
|
+
}
|
|
345449
|
+
catch {
|
|
345450
|
+
return [];
|
|
345451
|
+
}
|
|
345452
|
+
}
|
|
345453
|
+
|
|
345454
|
+
|
|
345472
345455
|
/***/ }),
|
|
345473
345456
|
|
|
345474
345457
|
/***/ "../../core/quantity/lib/esm/Constants.js":
|
|
@@ -347265,8 +347248,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347265
347248
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
347266
347249
|
/* harmony export */ FormatterSpec: () => (/* binding */ FormatterSpec)
|
|
347267
347250
|
/* harmony export */ });
|
|
347268
|
-
/* harmony import */ var
|
|
347269
|
-
/* harmony import */ var
|
|
347251
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
347252
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
347253
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
347254
|
+
/* harmony import */ var _Formatter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter */ "../../core/quantity/lib/esm/Formatter/Formatter.js");
|
|
347270
347255
|
/*---------------------------------------------------------------------------------------------
|
|
347271
347256
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
347272
347257
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -347276,6 +347261,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347276
347261
|
*/
|
|
347277
347262
|
|
|
347278
347263
|
|
|
347264
|
+
|
|
347265
|
+
|
|
347279
347266
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
347280
347267
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
347281
347268
|
/** A class that contains both formatting information and the conversion factors necessary to convert from an input unit to the units specified in the format.
|
|
@@ -347329,6 +347316,9 @@ class FormatterSpec {
|
|
|
347329
347316
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
347330
347317
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
347331
347318
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
347319
|
+
if (denominatorToNumerator.error) {
|
|
347320
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.QuantityLoggerCategory.Formatting, `Unit conversion from "${denominatorUnit.name}" to "${numeratorUnit.name}" could not be resolved.`);
|
|
347321
|
+
}
|
|
347332
347322
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
347333
347323
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
347334
347324
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -347379,7 +347369,7 @@ class FormatterSpec {
|
|
|
347379
347369
|
}
|
|
347380
347370
|
}
|
|
347381
347371
|
// Handle 2-unit composite for ratio formats (scale factors)
|
|
347382
|
-
if (format.type ===
|
|
347372
|
+
if (format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
347383
347373
|
return FormatterSpec.getRatioUnitConversions(format.units, unitsProvider, persistenceUnit);
|
|
347384
347374
|
}
|
|
347385
347375
|
if (format.units) {
|
|
@@ -347388,6 +347378,9 @@ class FormatterSpec {
|
|
|
347388
347378
|
let unitConversion;
|
|
347389
347379
|
if (convertFromUnit) {
|
|
347390
347380
|
unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
|
|
347381
|
+
if (unitConversion.error) {
|
|
347382
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.QuantityLoggerCategory.Formatting, `Unit conversion from "${convertFromUnit.name}" to "${unit[0].name}" could not be resolved.`);
|
|
347383
|
+
}
|
|
347391
347384
|
}
|
|
347392
347385
|
else {
|
|
347393
347386
|
unitConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347420,6 +347413,9 @@ class FormatterSpec {
|
|
|
347420
347413
|
if (format.azimuthBaseUnit !== undefined) {
|
|
347421
347414
|
if (inputUnit !== undefined) {
|
|
347422
347415
|
azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);
|
|
347416
|
+
if (azimuthBaseConversion.error) {
|
|
347417
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.QuantityLoggerCategory.Formatting, `Unit conversion from "${format.azimuthBaseUnit.name}" to "${inputUnit.name}" could not be resolved.`);
|
|
347418
|
+
}
|
|
347423
347419
|
}
|
|
347424
347420
|
else {
|
|
347425
347421
|
azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347429,6 +347425,9 @@ class FormatterSpec {
|
|
|
347429
347425
|
if (format.revolutionUnit !== undefined) {
|
|
347430
347426
|
if (inputUnit !== undefined) {
|
|
347431
347427
|
revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);
|
|
347428
|
+
if (revolutionConversion.error) {
|
|
347429
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__.QuantityLoggerCategory.Formatting, `Unit conversion from "${format.revolutionUnit.name}" to "${inputUnit.name}" could not be resolved.`);
|
|
347430
|
+
}
|
|
347432
347431
|
}
|
|
347433
347432
|
else {
|
|
347434
347433
|
revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347438,7 +347437,7 @@ class FormatterSpec {
|
|
|
347438
347437
|
}
|
|
347439
347438
|
/** Format a quantity value. */
|
|
347440
347439
|
applyFormatting(magnitude) {
|
|
347441
|
-
return
|
|
347440
|
+
return _Formatter__WEBPACK_IMPORTED_MODULE_3__.Formatter.formatQuantity(magnitude, this);
|
|
347442
347441
|
}
|
|
347443
347442
|
}
|
|
347444
347443
|
|
|
@@ -347573,10 +347572,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347573
347572
|
/* harmony export */ ParseError: () => (/* binding */ ParseError),
|
|
347574
347573
|
/* harmony export */ Parser: () => (/* binding */ Parser)
|
|
347575
347574
|
/* harmony export */ });
|
|
347576
|
-
/* harmony import */ var
|
|
347577
|
-
/* harmony import */ var
|
|
347578
|
-
/* harmony import */ var
|
|
347579
|
-
/* harmony import */ var
|
|
347575
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
347576
|
+
/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants */ "../../core/quantity/lib/esm/Constants.js");
|
|
347577
|
+
/* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Exception */ "../../core/quantity/lib/esm/Exception.js");
|
|
347578
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
347579
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
347580
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
347580
347581
|
/*---------------------------------------------------------------------------------------------
|
|
347581
347582
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
347582
347583
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -347588,6 +347589,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347588
347589
|
|
|
347589
347590
|
|
|
347590
347591
|
|
|
347592
|
+
|
|
347593
|
+
|
|
347591
347594
|
/** Possible parser errors
|
|
347592
347595
|
* @beta
|
|
347593
347596
|
*/
|
|
@@ -347681,7 +347684,7 @@ class Parser {
|
|
|
347681
347684
|
let i = index + 1;
|
|
347682
347685
|
for (; i < stringToParse.length; i++) {
|
|
347683
347686
|
const charCode = stringToParse.charCodeAt(i);
|
|
347684
|
-
if (Parser.isDigit(charCode) || ((charCode ===
|
|
347687
|
+
if (Parser.isDigit(charCode) || ((charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_PLUS) && (i === (index + 1)))) {
|
|
347685
347688
|
exponentString = exponentString.concat(stringToParse[i]);
|
|
347686
347689
|
}
|
|
347687
347690
|
else {
|
|
@@ -347689,7 +347692,7 @@ class Parser {
|
|
|
347689
347692
|
break;
|
|
347690
347693
|
}
|
|
347691
347694
|
}
|
|
347692
|
-
if (exponentString.length > 1 || ((exponentString.length === 1) && (exponentString.charCodeAt(0) !==
|
|
347695
|
+
if (exponentString.length > 1 || ((exponentString.length === 1) && (exponentString.charCodeAt(0) !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS) && (exponentString.charCodeAt(0) !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_PLUS)))
|
|
347693
347696
|
return new ScientificToken(i, exponentString);
|
|
347694
347697
|
return new ScientificToken(index);
|
|
347695
347698
|
}
|
|
@@ -347713,7 +347716,7 @@ class Parser {
|
|
|
347713
347716
|
}
|
|
347714
347717
|
}
|
|
347715
347718
|
else {
|
|
347716
|
-
if (processingNumerator && (charCode ===
|
|
347719
|
+
if (processingNumerator && (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SLASH || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIVISION_SLASH || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIVISION_SLASH)) {
|
|
347717
347720
|
processingNumerator = false;
|
|
347718
347721
|
}
|
|
347719
347722
|
else {
|
|
@@ -347733,7 +347736,7 @@ class Parser {
|
|
|
347733
347736
|
return new FractionToken(index + 1);
|
|
347734
347737
|
}
|
|
347735
347738
|
static isDigit(charCode) {
|
|
347736
|
-
return (charCode >=
|
|
347739
|
+
return (charCode >= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_ZERO) && (charCode <= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_NINE);
|
|
347737
347740
|
}
|
|
347738
347741
|
static isDigitOrDecimalSeparator(charCode, format) {
|
|
347739
347742
|
return (charCode === format.decimalSeparator.charCodeAt(0)) || Parser.isDigit(charCode);
|
|
@@ -347751,10 +347754,10 @@ class Parser {
|
|
|
347751
347754
|
let uomSeparatorToIgnore = 0;
|
|
347752
347755
|
let fractionDashCode = 0;
|
|
347753
347756
|
const skipCodes = [format.thousandSeparator.charCodeAt(0)];
|
|
347754
|
-
if (format.type ===
|
|
347757
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && format.stationSeparator && format.stationSeparator.length === 1)
|
|
347755
347758
|
skipCodes.push(format.stationSeparator.charCodeAt(0));
|
|
347756
|
-
if (format.type ===
|
|
347757
|
-
fractionDashCode =
|
|
347759
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && format.hasFormatTraitSet(_Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.FractionDash)) {
|
|
347760
|
+
fractionDashCode = _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS;
|
|
347758
347761
|
}
|
|
347759
347762
|
if (format.uomSeparator && format.uomSeparator !== " " && format.uomSeparator.length === 1) {
|
|
347760
347763
|
uomSeparatorToIgnore = format.uomSeparator.charCodeAt(0);
|
|
@@ -347776,7 +347779,7 @@ class Parser {
|
|
|
347776
347779
|
}
|
|
347777
347780
|
else {
|
|
347778
347781
|
if (processingNumber) {
|
|
347779
|
-
if (charCode ===
|
|
347782
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SLASH || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_FRACTION_SLASH || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIVISION_SLASH) {
|
|
347780
347783
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore, wipToken);
|
|
347781
347784
|
let fraction = fractSymbol.fraction;
|
|
347782
347785
|
i = fractSymbol.index;
|
|
@@ -347794,7 +347797,7 @@ class Parser {
|
|
|
347794
347797
|
}
|
|
347795
347798
|
else {
|
|
347796
347799
|
// a space may signify end of number or start of decimal
|
|
347797
|
-
if (charCode ===
|
|
347800
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE || charCode === fractionDashCode) {
|
|
347798
347801
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore);
|
|
347799
347802
|
let fraction = fractSymbol.fraction;
|
|
347800
347803
|
if (fractSymbol.fraction !== 0.0) {
|
|
@@ -347810,7 +347813,7 @@ class Parser {
|
|
|
347810
347813
|
processingNumber = false;
|
|
347811
347814
|
wipToken = "";
|
|
347812
347815
|
}
|
|
347813
|
-
else if (format.type ===
|
|
347816
|
+
else if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && wipToken.length > 0) {
|
|
347814
347817
|
if (signToken.length > 0) {
|
|
347815
347818
|
wipToken = signToken + wipToken;
|
|
347816
347819
|
signToken = "";
|
|
@@ -347823,7 +347826,7 @@ class Parser {
|
|
|
347823
347826
|
}
|
|
347824
347827
|
else {
|
|
347825
347828
|
// an "E" or "e" may signify scientific notation
|
|
347826
|
-
if (charCode ===
|
|
347829
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_UPPER_E || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_LOWER_E) {
|
|
347827
347830
|
const exponentSymbol = Parser.checkForScientificNotation(i, str, uomSeparatorToIgnore);
|
|
347828
347831
|
i = exponentSymbol.index;
|
|
347829
347832
|
if (exponentSymbol.exponent && exponentSymbol.exponent.length > 0) {
|
|
@@ -347841,7 +347844,7 @@ class Parser {
|
|
|
347841
347844
|
}
|
|
347842
347845
|
}
|
|
347843
347846
|
}
|
|
347844
|
-
if (format.type ===
|
|
347847
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && charCode === format.stationSeparator.charCodeAt(0)) {
|
|
347845
347848
|
if (!isStationSeparatorAdded) {
|
|
347846
347849
|
isStationSeparatorAdded = true;
|
|
347847
347850
|
continue;
|
|
@@ -347867,15 +347870,15 @@ class Parser {
|
|
|
347867
347870
|
else {
|
|
347868
347871
|
// not processing a number
|
|
347869
347872
|
const isCharOperator = isOperator(charCode);
|
|
347870
|
-
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !==
|
|
347873
|
+
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE;
|
|
347871
347874
|
if (isSpacer && i > 0 && i < str.length - 1) {
|
|
347872
347875
|
const prevCharCode = str.charCodeAt(i - 1);
|
|
347873
|
-
if (isCharOperator && prevCharCode !==
|
|
347876
|
+
if (isCharOperator && prevCharCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
347874
347877
|
// ignore spacer if it's not at the start or end, not whitespace, and is not in front of a whitespace
|
|
347875
347878
|
continue;
|
|
347876
347879
|
}
|
|
347877
347880
|
}
|
|
347878
|
-
if (wipToken.length === 0 && charCode ===
|
|
347881
|
+
if (wipToken.length === 0 && charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
347879
347882
|
// Don't add space when the wip token is empty.
|
|
347880
347883
|
continue;
|
|
347881
347884
|
}
|
|
@@ -347967,6 +347970,9 @@ class Parser {
|
|
|
347967
347970
|
else {
|
|
347968
347971
|
// Add new conversion to the list.
|
|
347969
347972
|
const conversion = await unitsProvider.getConversion(unitProps, outUnit);
|
|
347973
|
+
if (conversion.error) {
|
|
347974
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__.QuantityLoggerCategory.Parsing, `Unit conversion from "${unitProps.name}" to "${outUnit.name}" could not be resolved.`);
|
|
347975
|
+
}
|
|
347970
347976
|
if (conversion) {
|
|
347971
347977
|
spec = {
|
|
347972
347978
|
conversion,
|
|
@@ -347987,12 +347993,16 @@ class Parser {
|
|
|
347987
347993
|
static async createQuantityFromParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider) {
|
|
347988
347994
|
const unitConversionInfos = await this.getRequiredUnitsConversionsToParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider);
|
|
347989
347995
|
if (unitConversionInfos.outUnit) {
|
|
347990
|
-
const
|
|
347996
|
+
const outUnitConversion = await unitsProvider.getConversion(unitConversionInfos.outUnit, unitConversionInfos.outUnit);
|
|
347997
|
+
if (outUnitConversion.error) {
|
|
347998
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__.QuantityLoggerCategory.Parsing, `Unit conversion from "${unitConversionInfos.outUnit.name}" to "${unitConversionInfos.outUnit.name}" could not be resolved.`);
|
|
347999
|
+
}
|
|
348000
|
+
const value = Parser.getQuantityValueFromParseTokens(tokens, format, unitConversionInfos.specs, outUnitConversion);
|
|
347991
348001
|
if (value.ok) {
|
|
347992
|
-
return new
|
|
348002
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(unitConversionInfos.outUnit, value.value);
|
|
347993
348003
|
}
|
|
347994
348004
|
}
|
|
347995
|
-
return new
|
|
348005
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity();
|
|
347996
348006
|
}
|
|
347997
348007
|
/** Async method to generate a Quantity given a string that represents a quantity value and likely a unit label.
|
|
347998
348008
|
* @param inString A string that contains text represent a quantity.
|
|
@@ -348057,7 +348067,7 @@ class Parser {
|
|
|
348057
348067
|
}
|
|
348058
348068
|
// if there were unique unit labels but not matched to any units, throw an error
|
|
348059
348069
|
if (uniqueUnitLabels.length > 0)
|
|
348060
|
-
throw new
|
|
348070
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnitLabelSuppliedButNotMatched, `The unit label(s) ${uniqueUnitLabels.join(", ")} could not be matched to a known unit.`);
|
|
348061
348071
|
}
|
|
348062
348072
|
return unitConversion;
|
|
348063
348073
|
}
|
|
@@ -348110,10 +348120,10 @@ class Parser {
|
|
|
348110
348120
|
}
|
|
348111
348121
|
catch (e) {
|
|
348112
348122
|
// If we failed to get the default unit conversion, we need to return an error.
|
|
348113
|
-
if (e instanceof
|
|
348123
|
+
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnitLabelSuppliedButNotMatched)
|
|
348114
348124
|
return { ok: false, error: ParseError.UnitLabelSuppliedButNotMatched };
|
|
348115
348125
|
}
|
|
348116
|
-
if (format.type ===
|
|
348126
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && format.units !== undefined && format.units.length > 0) {
|
|
348117
348127
|
const units = format.units;
|
|
348118
348128
|
const desiredNumberOfTokens = units.length;
|
|
348119
348129
|
if (tokens.length < desiredNumberOfTokens && tokens[0].isNumber && desiredNumberOfTokens <= 3) {
|
|
@@ -348173,7 +348183,7 @@ class Parser {
|
|
|
348173
348183
|
}
|
|
348174
348184
|
}
|
|
348175
348185
|
if (conversion) {
|
|
348176
|
-
value = (0,
|
|
348186
|
+
value = (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(value, conversion);
|
|
348177
348187
|
}
|
|
348178
348188
|
mag = mag + value;
|
|
348179
348189
|
compositeUnitIndex++;
|
|
@@ -348206,13 +348216,13 @@ class Parser {
|
|
|
348206
348216
|
}
|
|
348207
348217
|
});
|
|
348208
348218
|
}
|
|
348209
|
-
if (parserSpec.format.type ===
|
|
348219
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing) {
|
|
348210
348220
|
return this.parseBearingFormat(inString, parserSpec);
|
|
348211
348221
|
}
|
|
348212
|
-
if (parserSpec.format.type ===
|
|
348222
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
348213
348223
|
return this.parseAzimuthFormat(inString, parserSpec);
|
|
348214
348224
|
}
|
|
348215
|
-
if (parserSpec.format.type ===
|
|
348225
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
348216
348226
|
return this.parseRatioFormat(inString, parserSpec);
|
|
348217
348227
|
}
|
|
348218
348228
|
return this.parseAndProcessTokens(inString, parserSpec.format, parserSpec.unitConversions);
|
|
@@ -348238,9 +348248,9 @@ class Parser {
|
|
|
348238
348248
|
}
|
|
348239
348249
|
});
|
|
348240
348250
|
}
|
|
348241
|
-
if (format.type ===
|
|
348251
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing || format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth || format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
348242
348252
|
// throw error indicating to call parseQuantityString instead
|
|
348243
|
-
throw new
|
|
348253
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnsupportedUnit, `Bearing, Azimuth or Ratio format must be parsed using a ParserSpec. Call parseQuantityString instead.`);
|
|
348244
348254
|
}
|
|
348245
348255
|
return this.parseAndProcessTokens(inString, format, unitsConversions);
|
|
348246
348256
|
}
|
|
@@ -348253,7 +348263,7 @@ class Parser {
|
|
|
348253
348263
|
const conversion = this.tryFindUnitConversion(specialDirUnit.label, spec.unitConversions, preferredUnit);
|
|
348254
348264
|
if (!conversion)
|
|
348255
348265
|
return { ok: true, value: mag };
|
|
348256
|
-
return { ok: true, value: (0,
|
|
348266
|
+
return { ok: true, value: (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(mag, conversion) };
|
|
348257
348267
|
}
|
|
348258
348268
|
static parseBearingFormat(inString, spec) {
|
|
348259
348269
|
const specialDirections = {
|
|
@@ -348343,12 +348353,12 @@ class Parser {
|
|
|
348343
348353
|
let azimuthBase = 0.0;
|
|
348344
348354
|
if (spec.format.azimuthBase !== undefined) {
|
|
348345
348355
|
if (spec.azimuthBaseConversion === undefined) {
|
|
348346
|
-
throw new
|
|
348356
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, `Missing azimuth base conversion for interpreting ${spec.format.name}'s azimuth base.`);
|
|
348347
348357
|
}
|
|
348348
|
-
const azBaseQuantity = new
|
|
348358
|
+
const azBaseQuantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);
|
|
348349
348359
|
const azBaseConverted = azBaseQuantity.convertTo(spec.outUnit, spec.azimuthBaseConversion);
|
|
348350
348360
|
if (!azBaseConverted.isValid) {
|
|
348351
|
-
throw new
|
|
348361
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnsupportedUnit, `Failed to convert azimuth base unit to ${spec.outUnit.name}.`);
|
|
348352
348362
|
}
|
|
348353
348363
|
azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);
|
|
348354
348364
|
}
|
|
@@ -348380,7 +348390,7 @@ class Parser {
|
|
|
348380
348390
|
static parseRatioPart(partStr, format) {
|
|
348381
348391
|
partStr = partStr.trim();
|
|
348382
348392
|
// Parse tokens - fractions are automatically converted to decimal values by parseQuantitySpecification
|
|
348383
|
-
const tempFormat = format.clone({ type:
|
|
348393
|
+
const tempFormat = format.clone({ type: _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal });
|
|
348384
348394
|
const tokens = Parser.parseQuantitySpecification(partStr, tempFormat);
|
|
348385
348395
|
let value = NaN;
|
|
348386
348396
|
let unitLabel;
|
|
@@ -348454,7 +348464,7 @@ class Parser {
|
|
|
348454
348464
|
const defaultUnit = spec.format.units && spec.format.units.length > 0 ? spec.format.units[0][0] : undefined;
|
|
348455
348465
|
const unitConversion = defaultUnit ? Parser.tryFindUnitConversion(defaultUnit.label, spec.unitConversions, defaultUnit) : undefined;
|
|
348456
348466
|
if (!unitConversion) {
|
|
348457
|
-
throw new
|
|
348467
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, `Missing input unit or unit conversion for interpreting ${spec.format.name}.`);
|
|
348458
348468
|
}
|
|
348459
348469
|
if (denominatorPart.value === 0) {
|
|
348460
348470
|
if (unitConversion.inversion && numeratorPart.value === 1)
|
|
@@ -348464,10 +348474,10 @@ class Parser {
|
|
|
348464
348474
|
}
|
|
348465
348475
|
let quantity;
|
|
348466
348476
|
if (spec.format.units && spec.outUnit) {
|
|
348467
|
-
quantity = new
|
|
348477
|
+
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.units[0][0], numeratorPart.value / denominatorPart.value);
|
|
348468
348478
|
}
|
|
348469
348479
|
else {
|
|
348470
|
-
throw new
|
|
348480
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, "Missing presentation unit or persistence unit for ratio format.");
|
|
348471
348481
|
}
|
|
348472
348482
|
let converted;
|
|
348473
348483
|
try {
|
|
@@ -348475,13 +348485,13 @@ class Parser {
|
|
|
348475
348485
|
}
|
|
348476
348486
|
catch (err) {
|
|
348477
348487
|
// for input of "0:N" with reversed unit
|
|
348478
|
-
if (err instanceof
|
|
348488
|
+
if (err instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && err.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.InvertingZero) {
|
|
348479
348489
|
return { ok: false, error: ParseError.InvalidMathResult };
|
|
348480
348490
|
}
|
|
348481
348491
|
throw err;
|
|
348482
348492
|
}
|
|
348483
348493
|
if (!converted.isValid) {
|
|
348484
|
-
throw new
|
|
348494
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnsupportedUnit, `Failed to convert from ${spec.format.units[0][0].name} to ${spec.outUnit.name} On format ${spec.format.name}.`);
|
|
348485
348495
|
}
|
|
348486
348496
|
return { ok: true, value: converted.magnitude };
|
|
348487
348497
|
}
|
|
@@ -348494,12 +348504,12 @@ class Parser {
|
|
|
348494
348504
|
}
|
|
348495
348505
|
static getRevolution(spec) {
|
|
348496
348506
|
if (spec.revolutionConversion === undefined) {
|
|
348497
|
-
throw new
|
|
348507
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, `Missing revolution unit conversion for calculating ${spec.format.name}'s revolution.`);
|
|
348498
348508
|
}
|
|
348499
|
-
const revolution = new
|
|
348509
|
+
const revolution = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.revolutionUnit, 1.0);
|
|
348500
348510
|
const converted = revolution.convertTo(spec.outUnit, spec.revolutionConversion);
|
|
348501
348511
|
if (!converted.isValid) {
|
|
348502
|
-
throw new
|
|
348512
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnsupportedUnit, `Failed to convert revolution unit to ${spec.outUnit.name} On format ${spec.format.name}.`);
|
|
348503
348513
|
}
|
|
348504
348514
|
return converted.magnitude;
|
|
348505
348515
|
}
|
|
@@ -348522,6 +348532,9 @@ class Parser {
|
|
|
348522
348532
|
const familyUnits = await unitsProvider.getUnitsByFamily(outUnit.phenomenon);
|
|
348523
348533
|
for (const unit of familyUnits) {
|
|
348524
348534
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
348535
|
+
if (conversion.error) {
|
|
348536
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__.QuantityLoggerCategory.Parsing, `Unit conversion from "${unit.name}" to "${outUnit.name}" could not be resolved.`);
|
|
348537
|
+
}
|
|
348525
348538
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
348526
348539
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
348527
348540
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -348559,6 +348572,9 @@ class Parser {
|
|
|
348559
348572
|
continue;
|
|
348560
348573
|
}
|
|
348561
348574
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
348575
|
+
if (conversion.error) {
|
|
348576
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__.QuantityLoggerCategory.Parsing, `Unit conversion from "${unit.name}" to "${outUnit.name}" could not be resolved.`);
|
|
348577
|
+
}
|
|
348562
348578
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
348563
348579
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
348564
348580
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -348603,8 +348619,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348603
348619
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
348604
348620
|
/* harmony export */ ParserSpec: () => (/* binding */ ParserSpec)
|
|
348605
348621
|
/* harmony export */ });
|
|
348606
|
-
/* harmony import */ var
|
|
348607
|
-
/* harmony import */ var
|
|
348622
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
348623
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
348624
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/Parser.js");
|
|
348625
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
348608
348626
|
/*---------------------------------------------------------------------------------------------
|
|
348609
348627
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
348610
348628
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -348614,6 +348632,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348614
348632
|
*/
|
|
348615
348633
|
|
|
348616
348634
|
|
|
348635
|
+
|
|
348636
|
+
|
|
348617
348637
|
/** A ParserSpec holds information needed to parse a string into a quantity synchronously.
|
|
348618
348638
|
* @beta
|
|
348619
348639
|
*/
|
|
@@ -348646,6 +348666,9 @@ class ParserSpec {
|
|
|
348646
348666
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
348647
348667
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
348648
348668
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
348669
|
+
if (denominatorToNumerator.error) {
|
|
348670
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.QuantityLoggerCategory.Parsing, `Unit conversion from "${denominatorUnit.name}" to "${numeratorUnit.name}" could not be resolved.`);
|
|
348671
|
+
}
|
|
348649
348672
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
348650
348673
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
348651
348674
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -348694,16 +348717,20 @@ class ParserSpec {
|
|
|
348694
348717
|
static async create(format, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
348695
348718
|
let conversions;
|
|
348696
348719
|
// For ratio formats with 2 composite units, use private helper method
|
|
348697
|
-
if (format.type ===
|
|
348720
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
348698
348721
|
conversions = await ParserSpec.getRatioUnitConversions(format.units, unitsProvider, outUnit, altUnitLabelsProvider);
|
|
348699
348722
|
}
|
|
348700
348723
|
else {
|
|
348701
|
-
conversions = await
|
|
348724
|
+
conversions = await _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.createUnitConversionSpecsForUnit(unitsProvider, outUnit, altUnitLabelsProvider);
|
|
348702
348725
|
}
|
|
348703
348726
|
const spec = new ParserSpec(outUnit, format, conversions);
|
|
348704
348727
|
if (format.azimuthBaseUnit !== undefined) {
|
|
348705
348728
|
if (outUnit !== undefined) {
|
|
348706
|
-
|
|
348729
|
+
const azimuthResult = await unitsProvider.getConversion(format.azimuthBaseUnit, outUnit);
|
|
348730
|
+
if (azimuthResult.error) {
|
|
348731
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.QuantityLoggerCategory.Parsing, `Unit conversion from "${format.azimuthBaseUnit.name}" to "${outUnit.name}" could not be resolved.`);
|
|
348732
|
+
}
|
|
348733
|
+
spec._azimuthBaseConversion = azimuthResult;
|
|
348707
348734
|
}
|
|
348708
348735
|
else {
|
|
348709
348736
|
spec._azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -348711,7 +348738,11 @@ class ParserSpec {
|
|
|
348711
348738
|
}
|
|
348712
348739
|
if (format.revolutionUnit !== undefined) {
|
|
348713
348740
|
if (outUnit !== undefined) {
|
|
348714
|
-
|
|
348741
|
+
const revolutionResult = await unitsProvider.getConversion(format.revolutionUnit, outUnit);
|
|
348742
|
+
if (revolutionResult.error) {
|
|
348743
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(_QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__.QuantityLoggerCategory.Parsing, `Unit conversion from "${format.revolutionUnit.name}" to "${outUnit.name}" could not be resolved.`);
|
|
348744
|
+
}
|
|
348745
|
+
spec._revolutionConversion = revolutionResult;
|
|
348715
348746
|
}
|
|
348716
348747
|
else {
|
|
348717
348748
|
spec._revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -348721,7 +348752,7 @@ class ParserSpec {
|
|
|
348721
348752
|
}
|
|
348722
348753
|
/** Do the parsing. Done this way to allow Custom Parser Specs to parse custom formatted strings into their quantities. */
|
|
348723
348754
|
parseToQuantityValue(inString) {
|
|
348724
|
-
return
|
|
348755
|
+
return _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.parseQuantityString(inString, this);
|
|
348725
348756
|
}
|
|
348726
348757
|
}
|
|
348727
348758
|
|
|
@@ -348868,9 +348899,47 @@ var QuantityLoggerCategory;
|
|
|
348868
348899
|
QuantityLoggerCategory["Package"] = "core-quantity";
|
|
348869
348900
|
/** Logger category for quantity formatting operations. */
|
|
348870
348901
|
QuantityLoggerCategory["Formatting"] = "core-quantity.Formatting";
|
|
348902
|
+
/** Logger category for quantity parsing operations. */
|
|
348903
|
+
QuantityLoggerCategory["Parsing"] = "core-quantity.Parsing";
|
|
348871
348904
|
})(QuantityLoggerCategory || (QuantityLoggerCategory = {}));
|
|
348872
348905
|
|
|
348873
348906
|
|
|
348907
|
+
/***/ }),
|
|
348908
|
+
|
|
348909
|
+
/***/ "../../core/quantity/lib/esm/SerializedUnitSchema.js":
|
|
348910
|
+
/*!***********************************************************!*\
|
|
348911
|
+
!*** ../../core/quantity/lib/esm/SerializedUnitSchema.js ***!
|
|
348912
|
+
\***********************************************************/
|
|
348913
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
348914
|
+
|
|
348915
|
+
"use strict";
|
|
348916
|
+
__webpack_require__.r(__webpack_exports__);
|
|
348917
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
348918
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* binding */ SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
348919
|
+
/* harmony export */ });
|
|
348920
|
+
/*---------------------------------------------------------------------------------------------
|
|
348921
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
348922
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
348923
|
+
*--------------------------------------------------------------------------------------------*/
|
|
348924
|
+
/** Current version of the serialization format for `SerializedUnitSchema`.
|
|
348925
|
+
*
|
|
348926
|
+
* This value is written into `Units.json` as the `version` field and checked at
|
|
348927
|
+
* parse time. Two version axes exist:
|
|
348928
|
+
*
|
|
348929
|
+
* - **Format version** (`SERIALIZED_UNIT_SCHEMA_VERSION` / `Units.json.version`): bump
|
|
348930
|
+
* the major version when the shape of the `SerializedUnitSchema` interfaces changes
|
|
348931
|
+
* incompatibly (e.g. renaming fields, removing required properties). Minor bumps for
|
|
348932
|
+
* backward-compatible additions.
|
|
348933
|
+
*
|
|
348934
|
+
* - **Source provenance** (`sourceEcSchemaVersion` inside `Units.json`): records which
|
|
348935
|
+
* version of the BIS Units EC schema the data was derived from (e.g. `"01.00.09"`).
|
|
348936
|
+
* This is a traceability marker, not a runtime contract.
|
|
348937
|
+
*
|
|
348938
|
+
* @internal
|
|
348939
|
+
*/
|
|
348940
|
+
const SERIALIZED_UNIT_SCHEMA_VERSION = "01.00.00";
|
|
348941
|
+
|
|
348942
|
+
|
|
348874
348943
|
/***/ }),
|
|
348875
348944
|
|
|
348876
348945
|
/***/ "../../core/quantity/lib/esm/Unit.js":
|
|
@@ -348924,6 +348993,399 @@ class BadUnit {
|
|
|
348924
348993
|
}
|
|
348925
348994
|
|
|
348926
348995
|
|
|
348996
|
+
/***/ }),
|
|
348997
|
+
|
|
348998
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Graph.js":
|
|
348999
|
+
/*!***********************************************************!*\
|
|
349000
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Graph.js ***!
|
|
349001
|
+
\***********************************************************/
|
|
349002
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349003
|
+
|
|
349004
|
+
"use strict";
|
|
349005
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349006
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349007
|
+
/* harmony export */ UnitConversionGraph: () => (/* binding */ UnitConversionGraph)
|
|
349008
|
+
/* harmony export */ });
|
|
349009
|
+
/*---------------------------------------------------------------------------------------------
|
|
349010
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349011
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349012
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349013
|
+
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
349014
|
+
/** @internal */
|
|
349015
|
+
class UnitConversionGraph {
|
|
349016
|
+
_edgeKeyDelim = "\x01";
|
|
349017
|
+
_label = "";
|
|
349018
|
+
_nodeCount = 0;
|
|
349019
|
+
_edgeCount = 0;
|
|
349020
|
+
_nodes;
|
|
349021
|
+
_edgeObjs;
|
|
349022
|
+
_edgeLabels;
|
|
349023
|
+
_outEdges;
|
|
349024
|
+
constructor() {
|
|
349025
|
+
this._nodes = {};
|
|
349026
|
+
this._edgeObjs = {};
|
|
349027
|
+
this._edgeLabels = {};
|
|
349028
|
+
this._outEdges = {};
|
|
349029
|
+
}
|
|
349030
|
+
setGraph = (label) => {
|
|
349031
|
+
this._label = label;
|
|
349032
|
+
return this;
|
|
349033
|
+
};
|
|
349034
|
+
graph = () => {
|
|
349035
|
+
return this._label;
|
|
349036
|
+
};
|
|
349037
|
+
nodeCount = () => {
|
|
349038
|
+
return this._nodeCount;
|
|
349039
|
+
};
|
|
349040
|
+
nodes = () => {
|
|
349041
|
+
return Object.keys(this._nodes);
|
|
349042
|
+
};
|
|
349043
|
+
setNode = (nodeKey, nodeValue) => {
|
|
349044
|
+
if (nodeKey in this._nodes) {
|
|
349045
|
+
this._nodes[nodeKey] = nodeValue;
|
|
349046
|
+
return;
|
|
349047
|
+
}
|
|
349048
|
+
this._nodes[nodeKey] = nodeValue;
|
|
349049
|
+
this._outEdges[nodeKey] = {};
|
|
349050
|
+
++this._nodeCount;
|
|
349051
|
+
};
|
|
349052
|
+
node = (nodeKey) => {
|
|
349053
|
+
return this._nodes[nodeKey];
|
|
349054
|
+
};
|
|
349055
|
+
hasNode = (nodeKey) => {
|
|
349056
|
+
return nodeKey in this._nodes;
|
|
349057
|
+
};
|
|
349058
|
+
edgeCount = () => {
|
|
349059
|
+
return this._edgeCount;
|
|
349060
|
+
};
|
|
349061
|
+
edges = () => {
|
|
349062
|
+
return Object.values(this._edgeObjs);
|
|
349063
|
+
};
|
|
349064
|
+
setEdge = (v, w, value) => {
|
|
349065
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
349066
|
+
if (edgeId in this._edgeLabels) {
|
|
349067
|
+
// Update exponent, specific to this graph's use case
|
|
349068
|
+
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
349069
|
+
return;
|
|
349070
|
+
}
|
|
349071
|
+
this._edgeLabels[edgeId] = value;
|
|
349072
|
+
const edgeObj = {
|
|
349073
|
+
v,
|
|
349074
|
+
w,
|
|
349075
|
+
};
|
|
349076
|
+
this._edgeObjs[edgeId] = edgeObj;
|
|
349077
|
+
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
349078
|
+
this._outEdges[v][edgeId] = edgeObj;
|
|
349079
|
+
this._edgeCount++;
|
|
349080
|
+
};
|
|
349081
|
+
edge = (v, w) => {
|
|
349082
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
349083
|
+
return this._edgeLabels[edgeId];
|
|
349084
|
+
};
|
|
349085
|
+
outEdges = (v) => {
|
|
349086
|
+
const outV = this._outEdges[v];
|
|
349087
|
+
const edges = Object.values(outV);
|
|
349088
|
+
return edges;
|
|
349089
|
+
};
|
|
349090
|
+
}
|
|
349091
|
+
|
|
349092
|
+
|
|
349093
|
+
/***/ }),
|
|
349094
|
+
|
|
349095
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Parser.js":
|
|
349096
|
+
/*!************************************************************!*\
|
|
349097
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Parser.js ***!
|
|
349098
|
+
\************************************************************/
|
|
349099
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349100
|
+
|
|
349101
|
+
"use strict";
|
|
349102
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349103
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349104
|
+
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
349105
|
+
/* harmony export */ });
|
|
349106
|
+
/*---------------------------------------------------------------------------------------------
|
|
349107
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349108
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349109
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349110
|
+
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
349111
|
+
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
349112
|
+
const sp = "*";
|
|
349113
|
+
/** @internal */
|
|
349114
|
+
var Tokens;
|
|
349115
|
+
(function (Tokens) {
|
|
349116
|
+
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
349117
|
+
Tokens[Tokens["Word"] = 2] = "Word";
|
|
349118
|
+
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
349119
|
+
})(Tokens || (Tokens = {}));
|
|
349120
|
+
/** @internal */
|
|
349121
|
+
function parseDefinition(definition) {
|
|
349122
|
+
const unitMap = new Map();
|
|
349123
|
+
if (expressionRgx.test(definition)) {
|
|
349124
|
+
for (const unit of definition.split(sp)) {
|
|
349125
|
+
const tokens = unit.split(tokenRgx);
|
|
349126
|
+
const name = tokens[Tokens.Word];
|
|
349127
|
+
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
349128
|
+
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
349129
|
+
if (unitMap.has(name)) {
|
|
349130
|
+
const currentDefinition = unitMap.get(name);
|
|
349131
|
+
if (currentDefinition)
|
|
349132
|
+
unitMap.set(name, { ...currentDefinition, exponent: currentDefinition.exponent + exponent });
|
|
349133
|
+
}
|
|
349134
|
+
else {
|
|
349135
|
+
unitMap.set(name, { name, exponent, constant });
|
|
349136
|
+
}
|
|
349137
|
+
}
|
|
349138
|
+
return unitMap;
|
|
349139
|
+
}
|
|
349140
|
+
else {
|
|
349141
|
+
throw new Error("Invalid definition expression.");
|
|
349142
|
+
}
|
|
349143
|
+
}
|
|
349144
|
+
|
|
349145
|
+
|
|
349146
|
+
/***/ }),
|
|
349147
|
+
|
|
349148
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js":
|
|
349149
|
+
/*!********************************************************************!*\
|
|
349150
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
349151
|
+
\********************************************************************/
|
|
349152
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349153
|
+
|
|
349154
|
+
"use strict";
|
|
349155
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349156
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349157
|
+
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
349158
|
+
/* harmony export */ });
|
|
349159
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
349160
|
+
/*---------------------------------------------------------------------------------------------
|
|
349161
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349162
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349163
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349164
|
+
|
|
349165
|
+
/**
|
|
349166
|
+
* Class used for storing calculated conversion between two Units and converting values from one Unit to another.
|
|
349167
|
+
* @internal
|
|
349168
|
+
*/
|
|
349169
|
+
class UnitConversion {
|
|
349170
|
+
factor;
|
|
349171
|
+
offset;
|
|
349172
|
+
constructor(factor = 1.0, offset = 0.0) {
|
|
349173
|
+
this.factor = factor;
|
|
349174
|
+
this.offset = offset;
|
|
349175
|
+
}
|
|
349176
|
+
/**
|
|
349177
|
+
* Converts x using UnitConversion
|
|
349178
|
+
* @param x Input magnitude to be converted
|
|
349179
|
+
* @returns Output magnitude after conversion
|
|
349180
|
+
*/
|
|
349181
|
+
evaluate(x) {
|
|
349182
|
+
return this.factor * x + this.offset;
|
|
349183
|
+
}
|
|
349184
|
+
/**
|
|
349185
|
+
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
349186
|
+
* @internal
|
|
349187
|
+
*/
|
|
349188
|
+
inverse() {
|
|
349189
|
+
const inverseFactor = 1.0 / this.factor;
|
|
349190
|
+
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
349191
|
+
}
|
|
349192
|
+
/**
|
|
349193
|
+
* Combines two UnitConversions
|
|
349194
|
+
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
349195
|
+
* @internal
|
|
349196
|
+
*/
|
|
349197
|
+
compose(conversion) {
|
|
349198
|
+
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
349199
|
+
}
|
|
349200
|
+
/**
|
|
349201
|
+
* Multiples two UnitConversions together to calculate factor during reducing
|
|
349202
|
+
* @internal
|
|
349203
|
+
*/
|
|
349204
|
+
multiply(conversion) {
|
|
349205
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(conversion.offset, 0.0) && (0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
349206
|
+
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
349207
|
+
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
349208
|
+
}
|
|
349209
|
+
/**
|
|
349210
|
+
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
349211
|
+
* @internal
|
|
349212
|
+
*/
|
|
349213
|
+
raise(power) {
|
|
349214
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 1.0))
|
|
349215
|
+
return new UnitConversion(this.factor, this.offset);
|
|
349216
|
+
else if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 0.0))
|
|
349217
|
+
return new UnitConversion(1.0, 0.0);
|
|
349218
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
349219
|
+
return new UnitConversion(this.factor ** power, 0.0);
|
|
349220
|
+
throw new Error("Cannot raise map with non-zero offset");
|
|
349221
|
+
}
|
|
349222
|
+
/** @internal */
|
|
349223
|
+
static identity = new UnitConversion();
|
|
349224
|
+
/**
|
|
349225
|
+
* Returns UnitConversion with source's numerator and denominator in factor and source's offset in offset for reducing.
|
|
349226
|
+
* Accepts any object that structurally satisfies `UnitConversionSource` (e.g. EC `Unit` or `Constant`).
|
|
349227
|
+
* @internal
|
|
349228
|
+
*/
|
|
349229
|
+
static from(source) {
|
|
349230
|
+
const offset = source.offset ?? 0;
|
|
349231
|
+
const hasOffset = !(0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(offset, 0.0);
|
|
349232
|
+
return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);
|
|
349233
|
+
}
|
|
349234
|
+
}
|
|
349235
|
+
|
|
349236
|
+
|
|
349237
|
+
/***/ }),
|
|
349238
|
+
|
|
349239
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js":
|
|
349240
|
+
/*!****************************************************************************!*\
|
|
349241
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js ***!
|
|
349242
|
+
\****************************************************************************/
|
|
349243
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349244
|
+
|
|
349245
|
+
"use strict";
|
|
349246
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349247
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349248
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* binding */ UnitDefinitionResolver)
|
|
349249
|
+
/* harmony export */ });
|
|
349250
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
349251
|
+
/* harmony import */ var _UnitConversion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
349252
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
349253
|
+
/* harmony import */ var _nameUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
349254
|
+
/*---------------------------------------------------------------------------------------------
|
|
349255
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349256
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349257
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349258
|
+
|
|
349259
|
+
|
|
349260
|
+
|
|
349261
|
+
|
|
349262
|
+
const MAX_RESOLUTION_DEPTH = 30;
|
|
349263
|
+
/** Resolves every unit in a `SerializedUnitSchema` to a `UnitConversion` relative to its phenomenon's base unit.
|
|
349264
|
+
* @internal
|
|
349265
|
+
*/
|
|
349266
|
+
class UnitDefinitionResolver {
|
|
349267
|
+
_schema;
|
|
349268
|
+
_cache = new Map();
|
|
349269
|
+
constructor(schema) {
|
|
349270
|
+
if (schema.version !== _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
349271
|
+
throw new Error(`Unsupported Units.json version "${schema.version}". Expected "${_SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION}".`);
|
|
349272
|
+
this._schema = schema;
|
|
349273
|
+
}
|
|
349274
|
+
/** Resolve all Unit items in the schema and return a map from item name to `ResolvedUnit`. */
|
|
349275
|
+
resolveAll() {
|
|
349276
|
+
const result = new Map();
|
|
349277
|
+
for (const [name, item] of Object.entries(this._schema.items)) {
|
|
349278
|
+
if (item.schemaItemType === "Unit") {
|
|
349279
|
+
const conversion = this._resolveUnit(name, 0);
|
|
349280
|
+
result.set(name, {
|
|
349281
|
+
name,
|
|
349282
|
+
label: item.label ?? name,
|
|
349283
|
+
phenomenon: item.phenomenon,
|
|
349284
|
+
unitSystem: item.unitSystem,
|
|
349285
|
+
conversion,
|
|
349286
|
+
});
|
|
349287
|
+
}
|
|
349288
|
+
}
|
|
349289
|
+
return result;
|
|
349290
|
+
}
|
|
349291
|
+
/** Resolve a single unit by unqualified name, returning its conversion to base. */
|
|
349292
|
+
_resolveUnit(name, depth) {
|
|
349293
|
+
if (depth > MAX_RESOLUTION_DEPTH)
|
|
349294
|
+
throw new Error(`Unit resolution depth exceeded ${MAX_RESOLUTION_DEPTH} for "${name}"`);
|
|
349295
|
+
const cached = this._cache.get(name);
|
|
349296
|
+
if (cached)
|
|
349297
|
+
return cached;
|
|
349298
|
+
const item = this._schema.items[name];
|
|
349299
|
+
if (!item)
|
|
349300
|
+
throw new Error(`Unknown schema item: "${name}"`);
|
|
349301
|
+
let conversion;
|
|
349302
|
+
if (item.schemaItemType === "Constant") {
|
|
349303
|
+
conversion = this._resolveConstant(name, item, depth);
|
|
349304
|
+
}
|
|
349305
|
+
else if (item.schemaItemType === "Unit") {
|
|
349306
|
+
conversion = this._resolveUnitItem(name, item, depth);
|
|
349307
|
+
}
|
|
349308
|
+
else {
|
|
349309
|
+
throw new Error(`Cannot resolve item of type "${item.schemaItemType}": "${name}"`);
|
|
349310
|
+
}
|
|
349311
|
+
this._cache.set(name, conversion);
|
|
349312
|
+
return conversion;
|
|
349313
|
+
}
|
|
349314
|
+
_resolveConstant(name, item, depth) {
|
|
349315
|
+
// A constant is identity if its definition is its own name
|
|
349316
|
+
if (item.definition === name)
|
|
349317
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349318
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
349319
|
+
numerator: item.numerator ?? 1,
|
|
349320
|
+
denominator: item.denominator ?? 1,
|
|
349321
|
+
});
|
|
349322
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
349323
|
+
return defConv.compose(selfConv);
|
|
349324
|
+
}
|
|
349325
|
+
_resolveUnitItem(name, item, depth) {
|
|
349326
|
+
// A unit is a base unit if its definition is its own name
|
|
349327
|
+
if (item.definition === name)
|
|
349328
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349329
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
349330
|
+
numerator: item.numerator ?? 1,
|
|
349331
|
+
denominator: item.denominator ?? 1,
|
|
349332
|
+
offset: item.offset,
|
|
349333
|
+
});
|
|
349334
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
349335
|
+
return defConv.compose(selfConv);
|
|
349336
|
+
}
|
|
349337
|
+
/** Parse and resolve a compound definition string like `[MILLI]*M` or `IN`. */
|
|
349338
|
+
_resolveDefinition(definition, depth) {
|
|
349339
|
+
const fragments = (0,_Parser__WEBPACK_IMPORTED_MODULE_2__.parseDefinition)(definition);
|
|
349340
|
+
let result;
|
|
349341
|
+
for (const [, fragment] of fragments) {
|
|
349342
|
+
// Strip alias prefix if present (definitions in the schema use unqualified names)
|
|
349343
|
+
const fragName = (0,_nameUtils__WEBPACK_IMPORTED_MODULE_3__.stripAliasPrefix)(fragment.name);
|
|
349344
|
+
const fragConv = this._resolveUnit(fragName, depth + 1);
|
|
349345
|
+
const raised = fragConv.raise(fragment.exponent);
|
|
349346
|
+
result = result ? result.multiply(raised) : raised;
|
|
349347
|
+
}
|
|
349348
|
+
return result ?? _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349349
|
+
}
|
|
349350
|
+
}
|
|
349351
|
+
|
|
349352
|
+
|
|
349353
|
+
/***/ }),
|
|
349354
|
+
|
|
349355
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js":
|
|
349356
|
+
/*!***************************************************************!*\
|
|
349357
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/nameUtils.js ***!
|
|
349358
|
+
\***************************************************************/
|
|
349359
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349360
|
+
|
|
349361
|
+
"use strict";
|
|
349362
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349363
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349364
|
+
/* harmony export */ qualifyItemName: () => (/* binding */ qualifyItemName),
|
|
349365
|
+
/* harmony export */ stripAliasPrefix: () => (/* binding */ stripAliasPrefix)
|
|
349366
|
+
/* harmony export */ });
|
|
349367
|
+
/*---------------------------------------------------------------------------------------------
|
|
349368
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349369
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349370
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349371
|
+
/** Strips alias prefix from a schema item reference.
|
|
349372
|
+
* `"u:FT"` → `"FT"`, `"FT"` → `"FT"`.
|
|
349373
|
+
* @internal
|
|
349374
|
+
*/
|
|
349375
|
+
function stripAliasPrefix(raw) {
|
|
349376
|
+
return raw.includes(":") ? raw.split(":")[1] : raw;
|
|
349377
|
+
}
|
|
349378
|
+
/** Normalizes a schema item reference to fully-qualified `SchemaName.ItemName` format.
|
|
349379
|
+
* Handles: already qualified (`"Units.FT"`), alias-qualified (`"u:FT"`), unqualified (`"FT"`).
|
|
349380
|
+
* @internal
|
|
349381
|
+
*/
|
|
349382
|
+
function qualifyItemName(raw, schemaName) {
|
|
349383
|
+
if (raw.includes("."))
|
|
349384
|
+
return raw;
|
|
349385
|
+
return `${schemaName}.${stripAliasPrefix(raw)}`;
|
|
349386
|
+
}
|
|
349387
|
+
|
|
349388
|
+
|
|
348927
349389
|
/***/ }),
|
|
348928
349390
|
|
|
348929
349391
|
/***/ "../../core/quantity/lib/esm/core-quantity.js":
|
|
@@ -348938,6 +349400,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348938
349400
|
/* harmony export */ BadUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BadUnit),
|
|
348939
349401
|
/* harmony export */ BaseFormat: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.BaseFormat),
|
|
348940
349402
|
/* harmony export */ BasicUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BasicUnit),
|
|
349403
|
+
/* harmony export */ BasicUnitsProvider: () => (/* reexport safe */ _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__.BasicUnitsProvider),
|
|
348941
349404
|
/* harmony export */ DecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.DecimalPrecision),
|
|
348942
349405
|
/* harmony export */ Format: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.Format),
|
|
348943
349406
|
/* harmony export */ FormatSpecHandle: () => (/* reexport safe */ _FormatSpecHandle__WEBPACK_IMPORTED_MODULE_2__.FormatSpecHandle),
|
|
@@ -348957,12 +349420,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348957
349420
|
/* harmony export */ QuantityStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus),
|
|
348958
349421
|
/* harmony export */ RatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioFormatType),
|
|
348959
349422
|
/* harmony export */ RatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioType),
|
|
349423
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* reexport safe */ _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__.SERIALIZED_UNIT_SCHEMA_VERSION),
|
|
348960
349424
|
/* harmony export */ ScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ScientificType),
|
|
348961
349425
|
/* harmony export */ ShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ShowSignOption),
|
|
349426
|
+
/* harmony export */ UnitConversion: () => (/* reexport safe */ _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__.UnitConversion),
|
|
349427
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.UnitConversionGraph),
|
|
348962
349428
|
/* harmony export */ UnitConversionInvert: () => (/* reexport safe */ _Interfaces__WEBPACK_IMPORTED_MODULE_3__.UnitConversionInvert),
|
|
349429
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* reexport safe */ _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__.UnitDefinitionResolver),
|
|
348963
349430
|
/* harmony export */ almostEqual: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostEqual),
|
|
348964
349431
|
/* harmony export */ almostZero: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostZero),
|
|
348965
349432
|
/* harmony export */ applyConversion: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.applyConversion),
|
|
349433
|
+
/* harmony export */ createUnitsProvider: () => (/* reexport safe */ _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__.createUnitsProvider),
|
|
348966
349434
|
/* harmony export */ formatStringRgx: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatStringRgx),
|
|
348967
349435
|
/* harmony export */ formatTraitsToArray: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTraitsToArray),
|
|
348968
349436
|
/* harmony export */ formatTypeToString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTypeToString),
|
|
@@ -348970,6 +349438,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348970
349438
|
/* harmony export */ getTraitString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.getTraitString),
|
|
348971
349439
|
/* harmony export */ isCustomFormatProps: () => (/* reexport safe */ _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__.isCustomFormatProps),
|
|
348972
349440
|
/* harmony export */ parseDecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseDecimalPrecision),
|
|
349441
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.parseDefinition),
|
|
348973
349442
|
/* harmony export */ parseFormatTrait: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatTrait),
|
|
348974
349443
|
/* harmony export */ parseFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatType),
|
|
348975
349444
|
/* harmony export */ parseFractionalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFractionalPrecision),
|
|
@@ -348996,6 +349465,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348996
349465
|
/* harmony import */ var _Formatter_FormattingReadyCollector__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Formatter/FormattingReadyCollector */ "../../core/quantity/lib/esm/Formatter/FormattingReadyCollector.js");
|
|
348997
349466
|
/* harmony import */ var _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Formatter/Interfaces */ "../../core/quantity/lib/esm/Formatter/Interfaces.js");
|
|
348998
349467
|
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
349468
|
+
/* harmony import */ var _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./UnitConversion/UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
349469
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
349470
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
349471
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
349472
|
+
/* harmony import */ var _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./CompositeUnitsProvider */ "../../core/quantity/lib/esm/CompositeUnitsProvider.js");
|
|
349473
|
+
/* harmony import */ var _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./internal/cross-package */ "../../core/quantity/lib/esm/internal/cross-package.js");
|
|
348999
349474
|
/*---------------------------------------------------------------------------------------------
|
|
349000
349475
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349001
349476
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -349014,20 +349489,59 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
349014
349489
|
|
|
349015
349490
|
|
|
349016
349491
|
|
|
349492
|
+
|
|
349493
|
+
|
|
349494
|
+
|
|
349495
|
+
|
|
349496
|
+
|
|
349497
|
+
|
|
349017
349498
|
|
|
349018
349499
|
/** @docs-package-description
|
|
349019
|
-
* The core-quantity package
|
|
349500
|
+
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
349020
349501
|
*/
|
|
349021
349502
|
/**
|
|
349022
349503
|
* @docs-group-description Quantity
|
|
349023
349504
|
* Classes, Interfaces, and definitions used to format and parse quantity values.
|
|
349024
349505
|
*/
|
|
349506
|
+
/**
|
|
349507
|
+
* @docs-group-description BasicUnitsProvider
|
|
349508
|
+
* A UnitsProvider backed by the bundled BIS Units schema JSON asset.
|
|
349509
|
+
*/
|
|
349510
|
+
/**
|
|
349511
|
+
* @docs-group-description CompositeUnitsProvider
|
|
349512
|
+
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
349513
|
+
*/
|
|
349025
349514
|
/**
|
|
349026
349515
|
* @docs-group-description Logging
|
|
349027
349516
|
* Logger categories used by this package.
|
|
349028
349517
|
*/
|
|
349029
349518
|
|
|
349030
349519
|
|
|
349520
|
+
/***/ }),
|
|
349521
|
+
|
|
349522
|
+
/***/ "../../core/quantity/lib/esm/internal/cross-package.js":
|
|
349523
|
+
/*!*************************************************************!*\
|
|
349524
|
+
!*** ../../core/quantity/lib/esm/internal/cross-package.js ***!
|
|
349525
|
+
\*************************************************************/
|
|
349526
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349527
|
+
|
|
349528
|
+
"use strict";
|
|
349529
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349530
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349531
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__.UnitConversionGraph),
|
|
349532
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__.parseDefinition)
|
|
349533
|
+
/* harmony export */ });
|
|
349534
|
+
/* harmony import */ var _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../UnitConversion/Graph */ "../../core/quantity/lib/esm/UnitConversion/Graph.js");
|
|
349535
|
+
/* harmony import */ var _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../UnitConversion/Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
349536
|
+
/*---------------------------------------------------------------------------------------------
|
|
349537
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349538
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349539
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349540
|
+
// Used by ecschema-metadata (UnitTree.ts)
|
|
349541
|
+
|
|
349542
|
+
|
|
349543
|
+
|
|
349544
|
+
|
|
349031
349545
|
/***/ }),
|
|
349032
349546
|
|
|
349033
349547
|
/***/ "../../core/webgl-compatibility/lib/esm/Capabilities.js":
|
|
@@ -349945,7 +350459,7 @@ class TestContext {
|
|
|
349945
350459
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
349946
350460
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
349947
350461
|
await core_frontend_1.NoRenderApp.startup({
|
|
349948
|
-
applicationVersion: "5.9.0-dev.
|
|
350462
|
+
applicationVersion: "5.9.0-dev.18",
|
|
349949
350463
|
applicationId: this.settings.gprid,
|
|
349950
350464
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
349951
350465
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -377220,7 +377734,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
377220
377734
|
/***/ ((module) => {
|
|
377221
377735
|
|
|
377222
377736
|
"use strict";
|
|
377223
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.9.0-dev.
|
|
377737
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.9.0-dev.18","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts && npm run -s extract","extract":"betools extract --fileExt=ts --extractFrom=./src/test/example-code --recursive --out=../../generated-docs/extract","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@bentley/aec-units-schema":"^1.0.3","@bentley/formats-schema":"^1.0.0","@bentley/units-schema":"^1.0.9","@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/chai-as-promised":"^7","@types/draco3d":"^1.4.10","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^10.5.0","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"~4.3.4","@loaders.gl/draco":"~4.3.4","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
|
|
377224
377738
|
|
|
377225
377739
|
/***/ }),
|
|
377226
377740
|
|