@itwin/ecschema-rpcinterface-tests 5.9.0-dev.16 → 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.
|
@@ -75423,247 +75423,6 @@ class SchemaPartVisitorDelegate {
|
|
|
75423
75423
|
}
|
|
75424
75424
|
|
|
75425
75425
|
|
|
75426
|
-
/***/ }),
|
|
75427
|
-
|
|
75428
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js":
|
|
75429
|
-
/*!********************************************************************!*\
|
|
75430
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js ***!
|
|
75431
|
-
\********************************************************************/
|
|
75432
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
75433
|
-
|
|
75434
|
-
"use strict";
|
|
75435
|
-
__webpack_require__.r(__webpack_exports__);
|
|
75436
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
75437
|
-
/* harmony export */ Graph: () => (/* binding */ Graph)
|
|
75438
|
-
/* harmony export */ });
|
|
75439
|
-
/*---------------------------------------------------------------------------------------------
|
|
75440
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
75441
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
75442
|
-
*--------------------------------------------------------------------------------------------*/
|
|
75443
|
-
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
75444
|
-
/** @internal */
|
|
75445
|
-
class Graph {
|
|
75446
|
-
_edgeKeyDelim = "\x01";
|
|
75447
|
-
_label = "";
|
|
75448
|
-
_nodeCount = 0;
|
|
75449
|
-
_edgeCount = 0;
|
|
75450
|
-
_nodes;
|
|
75451
|
-
_edgeObjs;
|
|
75452
|
-
_edgeLabels;
|
|
75453
|
-
_outEdges;
|
|
75454
|
-
constructor() {
|
|
75455
|
-
this._nodes = {};
|
|
75456
|
-
this._edgeObjs = {};
|
|
75457
|
-
this._edgeLabels = {};
|
|
75458
|
-
this._outEdges = {};
|
|
75459
|
-
}
|
|
75460
|
-
setGraph = (label) => {
|
|
75461
|
-
this._label = label;
|
|
75462
|
-
return this;
|
|
75463
|
-
};
|
|
75464
|
-
graph = () => {
|
|
75465
|
-
return this._label;
|
|
75466
|
-
};
|
|
75467
|
-
nodeCount = () => {
|
|
75468
|
-
return this._nodeCount;
|
|
75469
|
-
};
|
|
75470
|
-
nodes = () => {
|
|
75471
|
-
return Object.keys(this._nodes);
|
|
75472
|
-
};
|
|
75473
|
-
setNode = (nodeKey, nodeValue) => {
|
|
75474
|
-
if (nodeKey in this._nodes) {
|
|
75475
|
-
this._nodes[nodeKey] = nodeValue;
|
|
75476
|
-
return;
|
|
75477
|
-
}
|
|
75478
|
-
this._nodes[nodeKey] = nodeValue;
|
|
75479
|
-
this._outEdges[nodeKey] = {};
|
|
75480
|
-
++this._nodeCount;
|
|
75481
|
-
};
|
|
75482
|
-
node = (nodeKey) => {
|
|
75483
|
-
return this._nodes[nodeKey];
|
|
75484
|
-
};
|
|
75485
|
-
hasNode = (nodeKey) => {
|
|
75486
|
-
return nodeKey in this._nodes;
|
|
75487
|
-
};
|
|
75488
|
-
edgeCount = () => {
|
|
75489
|
-
return this._edgeCount;
|
|
75490
|
-
};
|
|
75491
|
-
edges = () => {
|
|
75492
|
-
return Object.values(this._edgeObjs);
|
|
75493
|
-
};
|
|
75494
|
-
setEdge = (v, w, value) => {
|
|
75495
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
75496
|
-
if (edgeId in this._edgeLabels) {
|
|
75497
|
-
// this._edgeLabels[edgeId] = value;
|
|
75498
|
-
// Update exponent, specific to this graph's use case
|
|
75499
|
-
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
75500
|
-
return;
|
|
75501
|
-
}
|
|
75502
|
-
this._edgeLabels[edgeId] = value;
|
|
75503
|
-
const edgeObj = {
|
|
75504
|
-
v,
|
|
75505
|
-
w,
|
|
75506
|
-
};
|
|
75507
|
-
this._edgeObjs[edgeId] = edgeObj;
|
|
75508
|
-
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
75509
|
-
this._outEdges[v][edgeId] = edgeObj;
|
|
75510
|
-
this._edgeCount++;
|
|
75511
|
-
};
|
|
75512
|
-
edge = (v, w) => {
|
|
75513
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
75514
|
-
return this._edgeLabels[edgeId];
|
|
75515
|
-
};
|
|
75516
|
-
outEdges = (v) => {
|
|
75517
|
-
const outV = this._outEdges[v];
|
|
75518
|
-
const edges = Object.values(outV);
|
|
75519
|
-
return edges;
|
|
75520
|
-
};
|
|
75521
|
-
}
|
|
75522
|
-
|
|
75523
|
-
|
|
75524
|
-
/***/ }),
|
|
75525
|
-
|
|
75526
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js":
|
|
75527
|
-
/*!*********************************************************************!*\
|
|
75528
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js ***!
|
|
75529
|
-
\*********************************************************************/
|
|
75530
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
75531
|
-
|
|
75532
|
-
"use strict";
|
|
75533
|
-
__webpack_require__.r(__webpack_exports__);
|
|
75534
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
75535
|
-
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
75536
|
-
/* harmony export */ });
|
|
75537
|
-
/*---------------------------------------------------------------------------------------------
|
|
75538
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
75539
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
75540
|
-
*--------------------------------------------------------------------------------------------*/
|
|
75541
|
-
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
75542
|
-
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
75543
|
-
const sp = "*";
|
|
75544
|
-
/** @internal */
|
|
75545
|
-
var Tokens;
|
|
75546
|
-
(function (Tokens) {
|
|
75547
|
-
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
75548
|
-
Tokens[Tokens["Word"] = 2] = "Word";
|
|
75549
|
-
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
75550
|
-
})(Tokens || (Tokens = {}));
|
|
75551
|
-
/** @internal */
|
|
75552
|
-
function parseDefinition(definition) {
|
|
75553
|
-
const unitMap = new Map();
|
|
75554
|
-
if (expressionRgx.test(definition)) {
|
|
75555
|
-
for (const unit of definition.split(sp)) {
|
|
75556
|
-
const tokens = unit.split(tokenRgx);
|
|
75557
|
-
const name = tokens[Tokens.Word];
|
|
75558
|
-
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
75559
|
-
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
75560
|
-
if (unitMap.has(name)) {
|
|
75561
|
-
const currentDefinition = unitMap.get(name);
|
|
75562
|
-
if (currentDefinition) {
|
|
75563
|
-
currentDefinition.exponent += exponent;
|
|
75564
|
-
unitMap.set(name, currentDefinition);
|
|
75565
|
-
}
|
|
75566
|
-
}
|
|
75567
|
-
else {
|
|
75568
|
-
unitMap.set(name, { name, exponent, constant });
|
|
75569
|
-
}
|
|
75570
|
-
}
|
|
75571
|
-
return unitMap;
|
|
75572
|
-
}
|
|
75573
|
-
else {
|
|
75574
|
-
throw new Error("Invalid definition expression.");
|
|
75575
|
-
}
|
|
75576
|
-
}
|
|
75577
|
-
|
|
75578
|
-
|
|
75579
|
-
/***/ }),
|
|
75580
|
-
|
|
75581
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js":
|
|
75582
|
-
/*!*****************************************************************************!*\
|
|
75583
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
75584
|
-
\*****************************************************************************/
|
|
75585
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
75586
|
-
|
|
75587
|
-
"use strict";
|
|
75588
|
-
__webpack_require__.r(__webpack_exports__);
|
|
75589
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
75590
|
-
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
75591
|
-
/* harmony export */ });
|
|
75592
|
-
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
75593
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
75594
|
-
|
|
75595
|
-
|
|
75596
|
-
/**
|
|
75597
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
75598
|
-
* @internal
|
|
75599
|
-
*/
|
|
75600
|
-
class UnitConversion {
|
|
75601
|
-
factor;
|
|
75602
|
-
offset;
|
|
75603
|
-
constructor(factor = 1.0, offset = 0.0) {
|
|
75604
|
-
this.factor = factor;
|
|
75605
|
-
this.offset = offset;
|
|
75606
|
-
}
|
|
75607
|
-
/**
|
|
75608
|
-
* Converts x using UnitConversion
|
|
75609
|
-
* @param x Input magnitude to be converted
|
|
75610
|
-
* @returns Output magnitude after conversion
|
|
75611
|
-
*/
|
|
75612
|
-
evaluate(x) {
|
|
75613
|
-
return this.factor * x + this.offset;
|
|
75614
|
-
}
|
|
75615
|
-
/**
|
|
75616
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
75617
|
-
* @internal
|
|
75618
|
-
*/
|
|
75619
|
-
inverse() {
|
|
75620
|
-
const inverseFactor = 1.0 / this.factor;
|
|
75621
|
-
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
75622
|
-
}
|
|
75623
|
-
/**
|
|
75624
|
-
* Combines two UnitConversions
|
|
75625
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
75626
|
-
* @internal
|
|
75627
|
-
*/
|
|
75628
|
-
compose(conversion) {
|
|
75629
|
-
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
75630
|
-
}
|
|
75631
|
-
/**
|
|
75632
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
75633
|
-
* @internal
|
|
75634
|
-
*/
|
|
75635
|
-
multiply(conversion) {
|
|
75636
|
-
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))
|
|
75637
|
-
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
75638
|
-
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
75639
|
-
}
|
|
75640
|
-
/**
|
|
75641
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
75642
|
-
* @internal
|
|
75643
|
-
*/
|
|
75644
|
-
raise(power) {
|
|
75645
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 1.0))
|
|
75646
|
-
return new UnitConversion(this.factor, this.offset);
|
|
75647
|
-
else if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 0.0))
|
|
75648
|
-
return new UnitConversion(1.0, 0.0);
|
|
75649
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(this.offset, 0.0))
|
|
75650
|
-
return new UnitConversion(this.factor ** power, 0.0);
|
|
75651
|
-
throw new Error("Cannot raise map with non-zero offset");
|
|
75652
|
-
}
|
|
75653
|
-
/** @internal */
|
|
75654
|
-
static identity = new UnitConversion();
|
|
75655
|
-
/**
|
|
75656
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
75657
|
-
* @internal
|
|
75658
|
-
*/
|
|
75659
|
-
static from(unitOrConstant) {
|
|
75660
|
-
if (_Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__.Unit.isUnit(unitOrConstant))
|
|
75661
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);
|
|
75662
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);
|
|
75663
|
-
}
|
|
75664
|
-
}
|
|
75665
|
-
|
|
75666
|
-
|
|
75667
75426
|
/***/ }),
|
|
75668
75427
|
|
|
75669
75428
|
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js":
|
|
@@ -75681,7 +75440,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
75681
75440
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
75682
75441
|
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
75683
75442
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
75684
|
-
/* harmony import */ var
|
|
75443
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
75685
75444
|
/* harmony import */ var _UnitTree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./UnitTree */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitTree.js");
|
|
75686
75445
|
/*---------------------------------------------------------------------------------------------
|
|
75687
75446
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -75741,7 +75500,7 @@ class UnitConverter {
|
|
|
75741
75500
|
*/
|
|
75742
75501
|
async processUnits(from, to) {
|
|
75743
75502
|
if (from.key.matches(to.key))
|
|
75744
|
-
return
|
|
75503
|
+
return _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
75745
75504
|
const areCompatible = await _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__.Unit.areCompatible(from, to);
|
|
75746
75505
|
if (!areCompatible)
|
|
75747
75506
|
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`, () => {
|
|
@@ -75761,8 +75520,8 @@ class UnitConverter {
|
|
|
75761
75520
|
return { from, to };
|
|
75762
75521
|
});
|
|
75763
75522
|
// Final calculations to get singular UnitConversion between from -> to
|
|
75764
|
-
const fromMap = fromMapStore.get(from.key.fullName) ||
|
|
75765
|
-
const toMap = toMapStore.get(to.key.fullName) ||
|
|
75523
|
+
const fromMap = fromMapStore.get(from.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
75524
|
+
const toMap = toMapStore.get(to.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
75766
75525
|
const fromInverse = fromMap.inverse();
|
|
75767
75526
|
return fromInverse.compose(toMap);
|
|
75768
75527
|
}
|
|
@@ -75817,9 +75576,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
75817
75576
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
75818
75577
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
75819
75578
|
/* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
|
|
75820
|
-
/* harmony import */ var
|
|
75821
|
-
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Parser */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js");
|
|
75822
|
-
/* harmony import */ var _Graph__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Graph */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js");
|
|
75579
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
75823
75580
|
/*---------------------------------------------------------------------------------------------
|
|
75824
75581
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
75825
75582
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -75829,13 +75586,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
75829
75586
|
|
|
75830
75587
|
|
|
75831
75588
|
|
|
75832
|
-
|
|
75833
|
-
|
|
75834
75589
|
/** @internal */
|
|
75835
75590
|
class GraphUtils {
|
|
75836
75591
|
/**
|
|
75837
75592
|
* DFS traversal - Post order
|
|
75838
|
-
* @param _graph
|
|
75593
|
+
* @param _graph DirectedGraph to traverse
|
|
75839
75594
|
* @param start Starting node
|
|
75840
75595
|
* @param keyFrom Get key from label
|
|
75841
75596
|
* @param op Reducing function
|
|
@@ -75866,7 +75621,7 @@ class GraphUtils {
|
|
|
75866
75621
|
/** @internal */
|
|
75867
75622
|
class UnitGraph {
|
|
75868
75623
|
_context;
|
|
75869
|
-
_graph = new
|
|
75624
|
+
_graph = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversionGraph();
|
|
75870
75625
|
_unitsInProgress = new Map();
|
|
75871
75626
|
constructor(_context) {
|
|
75872
75627
|
this._context = _context;
|
|
@@ -75945,7 +75700,7 @@ class UnitGraph {
|
|
|
75945
75700
|
.finally(() => this._unitsInProgress.delete(unit.key.fullName));
|
|
75946
75701
|
}
|
|
75947
75702
|
async addUnitToGraph(unit) {
|
|
75948
|
-
const umap = (0,
|
|
75703
|
+
const umap = (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.parseDefinition)(unit.definition);
|
|
75949
75704
|
const promiseArray = [];
|
|
75950
75705
|
for (const [key, value] of umap) {
|
|
75951
75706
|
promiseArray.push(this.resolveUnit(key, unit.schema).then((u) => [u, value]));
|
|
@@ -75979,17 +75734,19 @@ class UnitGraph {
|
|
|
75979
75734
|
const cmap = outEdges.reduce((pm, e) => {
|
|
75980
75735
|
const { exponent } = this._graph.edge(e.v, e.w);
|
|
75981
75736
|
const stored = innermapStore.get(e.w);
|
|
75982
|
-
const map = stored ? stored :
|
|
75737
|
+
const map = stored ? stored : _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
75983
75738
|
const emap = map.raise(exponent);
|
|
75984
75739
|
return pm ? pm.multiply(emap) : emap;
|
|
75985
75740
|
}, undefined);
|
|
75986
|
-
|
|
75987
|
-
|
|
75741
|
+
// EC Constant nodes have no offset property → UnitConversionSource.offset is undefined → 0.
|
|
75742
|
+
// Matches the prior explicit 0.0 branch before UnitConversion moved to core-quantity.
|
|
75743
|
+
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;
|
|
75744
|
+
const other = cmap || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
75988
75745
|
const result = other.compose(thisMap);
|
|
75989
75746
|
innermapStore.set(unitFullName, result);
|
|
75990
75747
|
}
|
|
75991
75748
|
else {
|
|
75992
|
-
innermapStore.set(unitFullName,
|
|
75749
|
+
innermapStore.set(unitFullName, _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity);
|
|
75993
75750
|
}
|
|
75994
75751
|
return innermapStore;
|
|
75995
75752
|
}
|
|
@@ -76033,6 +75790,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76033
75790
|
|
|
76034
75791
|
/**
|
|
76035
75792
|
* Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.
|
|
75793
|
+
*
|
|
75794
|
+
* To layer schema-defined units on top of the bundled BIS units from `@itwin/core-quantity`,
|
|
75795
|
+
* pass this as `primary` to `createUnitsProvider` from `@itwin/core-quantity`.
|
|
76036
75796
|
* @beta
|
|
76037
75797
|
*/
|
|
76038
75798
|
class SchemaUnitProvider {
|
|
@@ -76384,7 +76144,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76384
76144
|
/* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
|
|
76385
76145
|
/* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
|
|
76386
76146
|
/* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
|
|
76387
|
-
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */
|
|
76147
|
+
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
|
|
76388
76148
|
/* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
|
|
76389
76149
|
/* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
|
|
76390
76150
|
/* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
|
|
@@ -76392,8 +76152,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76392
76152
|
/* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
|
|
76393
76153
|
/* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
|
|
76394
76154
|
/* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
|
|
76395
|
-
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */
|
|
76396
|
-
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */
|
|
76155
|
+
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */ _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.FormatSetFormatsProvider),
|
|
76156
|
+
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
|
|
76397
76157
|
/* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
|
|
76398
76158
|
/* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
|
|
76399
76159
|
/* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
|
|
@@ -76415,8 +76175,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76415
76175
|
/* harmony export */ Schema: () => (/* reexport safe */ _Metadata_Schema__WEBPACK_IMPORTED_MODULE_25__.Schema),
|
|
76416
76176
|
/* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
|
|
76417
76177
|
/* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
|
|
76418
|
-
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */
|
|
76419
|
-
/* harmony export */ SchemaGraph: () => (/* reexport safe */
|
|
76178
|
+
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__.SchemaFormatsProvider),
|
|
76179
|
+
/* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
|
|
76420
76180
|
/* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
|
|
76421
76181
|
/* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
|
|
76422
76182
|
/* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
|
|
@@ -76425,18 +76185,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76425
76185
|
/* harmony export */ SchemaKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaKey),
|
|
76426
76186
|
/* harmony export */ SchemaLoader: () => (/* reexport safe */ _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__.SchemaLoader),
|
|
76427
76187
|
/* harmony export */ SchemaMatchType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.SchemaMatchType),
|
|
76428
|
-
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */
|
|
76188
|
+
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */ _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__.SchemaPartVisitorDelegate),
|
|
76429
76189
|
/* harmony export */ SchemaReadHelper: () => (/* reexport safe */ _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_5__.SchemaReadHelper),
|
|
76430
|
-
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */
|
|
76431
|
-
/* harmony export */ SchemaWalker: () => (/* reexport safe */
|
|
76190
|
+
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */ _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__.SchemaUnitProvider),
|
|
76191
|
+
/* harmony export */ SchemaWalker: () => (/* reexport safe */ _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__.SchemaWalker),
|
|
76432
76192
|
/* harmony export */ StrengthDirection: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthDirection),
|
|
76433
76193
|
/* harmony export */ StrengthType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthType),
|
|
76434
76194
|
/* harmony export */ StructArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructArrayProperty),
|
|
76435
76195
|
/* harmony export */ StructClass: () => (/* reexport safe */ _Metadata_Class__WEBPACK_IMPORTED_MODULE_11__.StructClass),
|
|
76436
76196
|
/* harmony export */ StructProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructProperty),
|
|
76437
76197
|
/* harmony export */ Unit: () => (/* reexport safe */ _Metadata_Unit__WEBPACK_IMPORTED_MODULE_27__.Unit),
|
|
76438
|
-
/* harmony export */
|
|
76439
|
-
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_34__.UnitConverter),
|
|
76198
|
+
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__.UnitConverter),
|
|
76440
76199
|
/* harmony export */ UnitSystem: () => (/* reexport safe */ _Metadata_UnitSystem__WEBPACK_IMPORTED_MODULE_28__.UnitSystem),
|
|
76441
76200
|
/* harmony export */ XmlParser: () => (/* reexport safe */ _Deserialization_XmlParser__WEBPACK_IMPORTED_MODULE_6__.XmlParser),
|
|
76442
76201
|
/* harmony export */ classModifierToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.classModifierToString),
|
|
@@ -76491,16 +76250,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76491
76250
|
/* harmony import */ var _SchemaJsonLocater__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./SchemaJsonLocater */ "../../core/ecschema-metadata/lib/esm/SchemaJsonLocater.js");
|
|
76492
76251
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
76493
76252
|
/* harmony import */ var _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./SchemaLoader */ "../../core/ecschema-metadata/lib/esm/SchemaLoader.js");
|
|
76494
|
-
/* harmony import */ var
|
|
76495
|
-
/* harmony import */ var
|
|
76496
|
-
/* harmony import */ var
|
|
76497
|
-
/* harmony import */ var
|
|
76498
|
-
/* harmony import */ var
|
|
76499
|
-
/* harmony import */ var
|
|
76500
|
-
/* harmony import */ var
|
|
76501
|
-
/* harmony import */ var
|
|
76502
|
-
/* harmony import */ var
|
|
76503
|
-
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
76253
|
+
/* harmony import */ var _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./UnitConversion/UnitConverter */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js");
|
|
76254
|
+
/* harmony import */ var _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./UnitProvider/SchemaUnitProvider */ "../../core/ecschema-metadata/lib/esm/UnitProvider/SchemaUnitProvider.js");
|
|
76255
|
+
/* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
|
|
76256
|
+
/* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
|
|
76257
|
+
/* harmony import */ var _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./Formatting/SchemaFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/SchemaFormatsProvider.js");
|
|
76258
|
+
/* harmony import */ var _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./Formatting/FormatSetFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/FormatSetFormatsProvider.js");
|
|
76259
|
+
/* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
|
|
76260
|
+
/* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
|
|
76261
|
+
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
76504
76262
|
/*---------------------------------------------------------------------------------------------
|
|
76505
76263
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
76506
76264
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -76545,7 +76303,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
76545
76303
|
|
|
76546
76304
|
|
|
76547
76305
|
|
|
76548
|
-
|
|
76549
76306
|
|
|
76550
76307
|
|
|
76551
76308
|
/** @docs-package-description
|
|
@@ -157414,6 +157171,44 @@ class EngineeringLengthDescription extends _FormattedQuantityDescription__WEBPAC
|
|
|
157414
157171
|
}
|
|
157415
157172
|
|
|
157416
157173
|
|
|
157174
|
+
/***/ }),
|
|
157175
|
+
|
|
157176
|
+
/***/ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js":
|
|
157177
|
+
/*!******************************************************************************!*\
|
|
157178
|
+
!*** ../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js ***!
|
|
157179
|
+
\******************************************************************************/
|
|
157180
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
157181
|
+
|
|
157182
|
+
"use strict";
|
|
157183
|
+
__webpack_require__.r(__webpack_exports__);
|
|
157184
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
157185
|
+
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
157186
|
+
/* harmony export */ });
|
|
157187
|
+
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
157188
|
+
/*---------------------------------------------------------------------------------------------
|
|
157189
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
157190
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
157191
|
+
*--------------------------------------------------------------------------------------------*/
|
|
157192
|
+
/** @packageDocumentation
|
|
157193
|
+
* @module QuantityFormatting
|
|
157194
|
+
*/
|
|
157195
|
+
|
|
157196
|
+
/** Function to generate default set of alternate unit labels
|
|
157197
|
+
* @internal
|
|
157198
|
+
*/
|
|
157199
|
+
function getDefaultAlternateUnitLabels() {
|
|
157200
|
+
const altDisplayLabelsMap = new Map();
|
|
157201
|
+
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_0__.UNIT_EXTRA_DATA) {
|
|
157202
|
+
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
157203
|
+
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
157204
|
+
}
|
|
157205
|
+
}
|
|
157206
|
+
if (altDisplayLabelsMap.size)
|
|
157207
|
+
return altDisplayLabelsMap;
|
|
157208
|
+
return undefined;
|
|
157209
|
+
}
|
|
157210
|
+
|
|
157211
|
+
|
|
157417
157212
|
/***/ }),
|
|
157418
157213
|
|
|
157419
157214
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/BaseUnitFormattingSettingsProvider.js":
|
|
@@ -157557,178 +157352,6 @@ class BaseUnitFormattingSettingsProvider {
|
|
|
157557
157352
|
}
|
|
157558
157353
|
|
|
157559
157354
|
|
|
157560
|
-
/***/ }),
|
|
157561
|
-
|
|
157562
|
-
/***/ "../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js":
|
|
157563
|
-
/*!*****************************************************************************!*\
|
|
157564
|
-
!*** ../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js ***!
|
|
157565
|
-
\*****************************************************************************/
|
|
157566
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
157567
|
-
|
|
157568
|
-
"use strict";
|
|
157569
|
-
__webpack_require__.r(__webpack_exports__);
|
|
157570
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
157571
|
-
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
157572
|
-
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
157573
|
-
/* harmony export */ });
|
|
157574
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
157575
|
-
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
157576
|
-
/*---------------------------------------------------------------------------------------------
|
|
157577
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
157578
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
157579
|
-
*--------------------------------------------------------------------------------------------*/
|
|
157580
|
-
/** @packageDocumentation
|
|
157581
|
-
* @module QuantityFormatting
|
|
157582
|
-
*/
|
|
157583
|
-
|
|
157584
|
-
|
|
157585
|
-
// cSpell:ignore ussurvey USCUSTOM
|
|
157586
|
-
/** Units provider that provides a limited number of UnitDefinitions that are needed to support basic tools.
|
|
157587
|
-
* @internal
|
|
157588
|
-
*/
|
|
157589
|
-
class BasicUnitsProvider {
|
|
157590
|
-
/** Find a unit given the unitLabel. */
|
|
157591
|
-
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
157592
|
-
const labelToFind = unitLabel.toLowerCase();
|
|
157593
|
-
const unitFamilyToFind = phenomenon ? phenomenon.toLowerCase() : undefined;
|
|
157594
|
-
const unitSystemToFind = unitSystem ? unitSystem.toLowerCase() : undefined;
|
|
157595
|
-
for (const entry of UNIT_DATA) {
|
|
157596
|
-
if (schemaName && schemaName !== "Units")
|
|
157597
|
-
continue;
|
|
157598
|
-
if (phenomenon && entry.phenomenon.toLowerCase() !== unitFamilyToFind)
|
|
157599
|
-
continue;
|
|
157600
|
-
if (unitSystemToFind && entry.system.toLowerCase() !== unitSystemToFind)
|
|
157601
|
-
continue;
|
|
157602
|
-
if (entry.displayLabel.toLowerCase() === labelToFind || entry.name.toLowerCase() === labelToFind) {
|
|
157603
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
157604
|
-
return unitProps;
|
|
157605
|
-
}
|
|
157606
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
157607
|
-
if (entry.altDisplayLabels.findIndex((ref) => ref.toLowerCase() === labelToFind) !== -1) {
|
|
157608
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
157609
|
-
return unitProps;
|
|
157610
|
-
}
|
|
157611
|
-
}
|
|
157612
|
-
}
|
|
157613
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
157614
|
-
}
|
|
157615
|
-
/** Find all units given phenomenon */
|
|
157616
|
-
async getUnitsByFamily(phenomenon) {
|
|
157617
|
-
const units = [];
|
|
157618
|
-
for (const entry of UNIT_DATA) {
|
|
157619
|
-
if (entry.phenomenon !== phenomenon)
|
|
157620
|
-
continue;
|
|
157621
|
-
units.push(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system));
|
|
157622
|
-
}
|
|
157623
|
-
return units;
|
|
157624
|
-
}
|
|
157625
|
-
findUnitDefinition(name) {
|
|
157626
|
-
for (const entry of UNIT_DATA) {
|
|
157627
|
-
if (entry.name === name)
|
|
157628
|
-
return entry;
|
|
157629
|
-
}
|
|
157630
|
-
return undefined;
|
|
157631
|
-
}
|
|
157632
|
-
/** Find a unit given the unit's unique name. */
|
|
157633
|
-
async findUnitByName(unitName) {
|
|
157634
|
-
const unitDataEntry = this.findUnitDefinition(unitName);
|
|
157635
|
-
if (unitDataEntry) {
|
|
157636
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(unitDataEntry.name, unitDataEntry.displayLabel, unitDataEntry.phenomenon, unitDataEntry.system);
|
|
157637
|
-
}
|
|
157638
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
157639
|
-
}
|
|
157640
|
-
/** Return the information needed to convert a value between two different units. The units should be from the same phenomenon. */
|
|
157641
|
-
async getConversion(fromUnit, toUnit) {
|
|
157642
|
-
const fromUnitData = this.findUnitDefinition(fromUnit.name);
|
|
157643
|
-
const toUnitData = this.findUnitDefinition(toUnit.name);
|
|
157644
|
-
if (fromUnitData && toUnitData) {
|
|
157645
|
-
const deltaOffset = toUnitData.conversion.offset - fromUnitData.conversion.offset;
|
|
157646
|
-
const deltaNumerator = toUnitData.conversion.numerator * fromUnitData.conversion.denominator;
|
|
157647
|
-
const deltaDenominator = toUnitData.conversion.denominator * fromUnitData.conversion.numerator;
|
|
157648
|
-
const conversionData = new ConversionData();
|
|
157649
|
-
conversionData.factor = deltaNumerator / deltaDenominator;
|
|
157650
|
-
conversionData.offset = deltaOffset;
|
|
157651
|
-
return conversionData;
|
|
157652
|
-
}
|
|
157653
|
-
return new ConversionData();
|
|
157654
|
-
}
|
|
157655
|
-
}
|
|
157656
|
-
/** Class that implements the minimum UnitConversionProps interface to provide information needed to convert unit values.
|
|
157657
|
-
* @alpha
|
|
157658
|
-
*/
|
|
157659
|
-
class ConversionData {
|
|
157660
|
-
factor = 1.0;
|
|
157661
|
-
offset = 0.0;
|
|
157662
|
-
error = false;
|
|
157663
|
-
}
|
|
157664
|
-
/** Function to generate default set of alternate unit labels
|
|
157665
|
-
* @internal
|
|
157666
|
-
*/
|
|
157667
|
-
function getDefaultAlternateUnitLabels() {
|
|
157668
|
-
const altDisplayLabelsMap = new Map();
|
|
157669
|
-
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_1__.UNIT_EXTRA_DATA) {
|
|
157670
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
157671
|
-
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
157672
|
-
}
|
|
157673
|
-
}
|
|
157674
|
-
if (altDisplayLabelsMap.size)
|
|
157675
|
-
return altDisplayLabelsMap;
|
|
157676
|
-
return undefined;
|
|
157677
|
-
}
|
|
157678
|
-
// ========================================================================================================================================
|
|
157679
|
-
// Minimum set of UNITs to be removed when official UnitsProvider is available
|
|
157680
|
-
// ========================================================================================================================================
|
|
157681
|
-
// cSpell:ignore MILLIINCH, MICROINCH, MILLIFOOT
|
|
157682
|
-
// Set of supported units - this information will come from Schema-based units once the EC package is ready to provide this information.
|
|
157683
|
-
const UNIT_DATA = [
|
|
157684
|
-
// Angles ( base unit radian )
|
|
157685
|
-
{ name: "Units.RAD", phenomenon: "Units.ANGLE", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "rad" },
|
|
157686
|
-
// 1 rad = 180.0/PI °
|
|
157687
|
-
{ name: "Units.ARC_DEG", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 180.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "°" },
|
|
157688
|
-
{ name: "Units.ARC_MINUTE", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 10800.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "'" },
|
|
157689
|
-
{ name: "Units.ARC_SECOND", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 648000.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: '"' },
|
|
157690
|
-
{ name: "Units.GRAD", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 200, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "grad" },
|
|
157691
|
-
// Time ( base unit second )
|
|
157692
|
-
{ name: "Units.S", phenomenon: "Units.TIME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "s" },
|
|
157693
|
-
{ name: "Units.MIN", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 60.0, offset: 0.0 }, displayLabel: "min" },
|
|
157694
|
-
{ name: "Units.HR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 3600.0, offset: 0.0 }, displayLabel: "h" },
|
|
157695
|
-
{ name: "Units.DAY", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 86400.0, offset: 0.0 }, displayLabel: "days" },
|
|
157696
|
-
{ name: "Units.WEEK", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 604800.0, offset: 0.0 }, displayLabel: "weeks" },
|
|
157697
|
-
// 1 sec = 1/31536000.0 yr
|
|
157698
|
-
{ name: "Units.YR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 31536000.0, offset: 0.0 }, displayLabel: "years" },
|
|
157699
|
-
// conversion => specified unit to base unit of m
|
|
157700
|
-
{ name: "Units.M", phenomenon: "Units.LENGTH", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m" },
|
|
157701
|
-
{ name: "Units.MM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "mm" },
|
|
157702
|
-
{ name: "Units.CM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 100.0, denominator: 1.0, offset: 0.0 }, displayLabel: "cm" },
|
|
157703
|
-
{ name: "Units.DM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 10.0, denominator: 1.0, offset: 0.0 }, displayLabel: "dm" },
|
|
157704
|
-
{ name: "Units.KM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1.0, denominator: 1000.0, offset: 0.0 }, displayLabel: "km" },
|
|
157705
|
-
{ name: "Units.UM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "µm" },
|
|
157706
|
-
{ name: "Units.MILLIINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "mil" },
|
|
157707
|
-
{ name: "Units.MICROINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "µin" },
|
|
157708
|
-
{ name: "Units.MILLIFOOT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "mft" },
|
|
157709
|
-
{ name: "Units.IN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "in" },
|
|
157710
|
-
{ name: "Units.FT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "ft" },
|
|
157711
|
-
{ name: "Units.CHAIN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 66.0 * 0.3048, offset: 0.0 }, displayLabel: "chain" },
|
|
157712
|
-
{ name: "Units.YRD", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.9144, offset: 0.0 }, displayLabel: "yd" },
|
|
157713
|
-
{ name: "Units.MILE", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 1609.344, offset: 0.0 }, displayLabel: "mi" },
|
|
157714
|
-
{ 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)" },
|
|
157715
|
-
{ 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)" },
|
|
157716
|
-
{ 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)" },
|
|
157717
|
-
{ 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)" },
|
|
157718
|
-
{ 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)" },
|
|
157719
|
-
// conversion => specified unit to base unit of m²
|
|
157720
|
-
{ name: "Units.SQ_FT", phenomenon: "Units.AREA", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: .09290304, offset: 0.0 }, displayLabel: "ft²" },
|
|
157721
|
-
{ 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)" },
|
|
157722
|
-
{ name: "Units.SQ_M", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m²" },
|
|
157723
|
-
{ name: "Units.SQ_KM", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1000000.0, offset: 0.0 }, displayLabel: "km²" },
|
|
157724
|
-
// conversion => specified unit to base unit m³
|
|
157725
|
-
{ name: "Units.CUB_FT", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.028316847, offset: 0.0 }, displayLabel: "ft³" },
|
|
157726
|
-
{ name: "Units.CUB_US_SURVEY_FT", phenomenon: "Units.VOLUME", system: "Units.USSURVEY", conversion: { numerator: 1, denominator: 0.0283170164937591, offset: 0.0 }, displayLabel: "ft³" },
|
|
157727
|
-
{ name: "Units.CUB_YRD", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.76455486, offset: 0.0 }, displayLabel: "yd³" },
|
|
157728
|
-
{ name: "Units.CUB_M", phenomenon: "Units.VOLUME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m³" },
|
|
157729
|
-
];
|
|
157730
|
-
|
|
157731
|
-
|
|
157732
157355
|
/***/ }),
|
|
157733
157356
|
|
|
157734
157357
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/LocalUnitFormatProvider.js":
|
|
@@ -157836,7 +157459,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
157836
157459
|
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
157837
157460
|
/* harmony import */ var _common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/FrontendLoggerCategory */ "../../core/frontend/lib/esm/common/FrontendLoggerCategory.js");
|
|
157838
157461
|
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
157839
|
-
/* harmony import */ var
|
|
157462
|
+
/* harmony import */ var _AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./AlternateUnitLabels */ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js");
|
|
157840
157463
|
/*---------------------------------------------------------------------------------------------
|
|
157841
157464
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
157842
157465
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -158044,8 +157667,8 @@ class FormatsProviderManager {
|
|
|
158044
157667
|
*/
|
|
158045
157668
|
class QuantityFormatter {
|
|
158046
157669
|
static _allUnitSystems = ["metric", "imperial", "usCustomary", "usSurvey"];
|
|
158047
|
-
_unitsProvider = new
|
|
158048
|
-
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,
|
|
157670
|
+
_unitsProvider = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider();
|
|
157671
|
+
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,_AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__.getDefaultAlternateUnitLabels)());
|
|
158049
157672
|
/** Registry containing available quantity type definitions. */
|
|
158050
157673
|
_quantityTypeRegistry = new Map();
|
|
158051
157674
|
/** Registry containing available FormatterSpec and ParserSpec, mapped by keys.
|
|
@@ -158497,9 +158120,10 @@ class QuantityFormatter {
|
|
|
158497
158120
|
* `IModelApp.toolAdmin.restartPrimitiveTool()` to allow the tool to reinitialize itself.
|
|
158498
158121
|
*/
|
|
158499
158122
|
async resetToUseInternalUnitsProvider() {
|
|
158500
|
-
|
|
158123
|
+
// Coupled to createUnitsProvider() returning BasicUnitsProvider directly when no primary is set.
|
|
158124
|
+
if (this._unitsProvider instanceof _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider)
|
|
158501
158125
|
return;
|
|
158502
|
-
await this.setUnitsProvider(new
|
|
158126
|
+
await this.setUnitsProvider(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider());
|
|
158503
158127
|
}
|
|
158504
158128
|
/** Async call to register a CustomQuantityType and load the FormatSpec and ParserSpec for the new type. */
|
|
158505
158129
|
async registerQuantityType(entry, replace) {
|
|
@@ -158787,7 +158411,10 @@ class QuantityFormatter {
|
|
|
158787
158411
|
}
|
|
158788
158412
|
/** Returns data needed to convert from one Unit to another in the same Unit Family/Phenomenon. */
|
|
158789
158413
|
async getConversion(fromUnit, toUnit) {
|
|
158790
|
-
|
|
158414
|
+
const result = await this._unitsProvider.getConversion(fromUnit, toUnit);
|
|
158415
|
+
if (result.error)
|
|
158416
|
+
_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.`);
|
|
158417
|
+
return result;
|
|
158791
158418
|
}
|
|
158792
158419
|
/**
|
|
158793
158420
|
* Creates a [[FormatterSpec]] for a given persistence unit name and format properties, using the [[UnitsProvider]] to resolve the persistence unit.
|
|
@@ -308798,6 +308425,362 @@ class UrlFS extends _FileStorage__WEBPACK_IMPORTED_MODULE_6__.FileStorage {
|
|
|
308798
308425
|
}
|
|
308799
308426
|
|
|
308800
308427
|
|
|
308428
|
+
/***/ }),
|
|
308429
|
+
|
|
308430
|
+
/***/ "../../core/quantity/lib/esm/BasicUnitsProvider.js":
|
|
308431
|
+
/*!*********************************************************!*\
|
|
308432
|
+
!*** ../../core/quantity/lib/esm/BasicUnitsProvider.js ***!
|
|
308433
|
+
\*********************************************************/
|
|
308434
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
308435
|
+
|
|
308436
|
+
"use strict";
|
|
308437
|
+
__webpack_require__.r(__webpack_exports__);
|
|
308438
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
308439
|
+
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
308440
|
+
/* harmony export */ _testResetUnitsCache: () => (/* binding */ _testResetUnitsCache)
|
|
308441
|
+
/* harmony export */ });
|
|
308442
|
+
/* harmony import */ var _Interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Interfaces */ "../../core/quantity/lib/esm/Interfaces.js");
|
|
308443
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
308444
|
+
/* harmony import */ var _UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./UnitConversion/nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
308445
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
308446
|
+
/*---------------------------------------------------------------------------------------------
|
|
308447
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
308448
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
308449
|
+
*--------------------------------------------------------------------------------------------*/
|
|
308450
|
+
|
|
308451
|
+
|
|
308452
|
+
|
|
308453
|
+
|
|
308454
|
+
// Module-level cache: the unit data is derived deterministically from the bundled Units.json
|
|
308455
|
+
// asset, so the resolved indexes are effectively an immutable constant. Caching at module
|
|
308456
|
+
// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.
|
|
308457
|
+
// in tests or when composed inside CompositeUnitsProvider).
|
|
308458
|
+
// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint
|
|
308459
|
+
// near-zero until a provider method is actually called.
|
|
308460
|
+
let _resolvePromise;
|
|
308461
|
+
let _permanentError;
|
|
308462
|
+
async function resolveState() {
|
|
308463
|
+
if (_permanentError !== undefined) {
|
|
308464
|
+
throw _permanentError;
|
|
308465
|
+
}
|
|
308466
|
+
if (!_resolvePromise) {
|
|
308467
|
+
_resolvePromise = _buildState().catch((err) => {
|
|
308468
|
+
_permanentError = err instanceof Error ? err : new Error(String(err));
|
|
308469
|
+
_resolvePromise = undefined;
|
|
308470
|
+
throw _permanentError;
|
|
308471
|
+
});
|
|
308472
|
+
}
|
|
308473
|
+
return _resolvePromise;
|
|
308474
|
+
}
|
|
308475
|
+
/** @internal — test use only. Resets the module-level lazy cache. */
|
|
308476
|
+
function _testResetUnitsCache() {
|
|
308477
|
+
_resolvePromise = undefined;
|
|
308478
|
+
_permanentError = undefined;
|
|
308479
|
+
}
|
|
308480
|
+
async function _buildState() {
|
|
308481
|
+
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));
|
|
308482
|
+
const nameMap = new Map();
|
|
308483
|
+
const labelMap = new Map();
|
|
308484
|
+
const phenomenonMap = new Map();
|
|
308485
|
+
const invertedUnits = new Map();
|
|
308486
|
+
const s = schema;
|
|
308487
|
+
const resolver = new _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__.UnitDefinitionResolver(s);
|
|
308488
|
+
const resolved = resolver.resolveAll();
|
|
308489
|
+
for (const [name, entry] of resolved) {
|
|
308490
|
+
const item = s.items[name];
|
|
308491
|
+
const phenomenon = item.phenomenon;
|
|
308492
|
+
const unitSystem = item.unitSystem;
|
|
308493
|
+
const fullName = `${s.name}.${name}`;
|
|
308494
|
+
const props = {
|
|
308495
|
+
name: fullName,
|
|
308496
|
+
label: entry.label,
|
|
308497
|
+
phenomenon,
|
|
308498
|
+
isValid: true,
|
|
308499
|
+
system: unitSystem,
|
|
308500
|
+
};
|
|
308501
|
+
const indexed = { props, resolved: entry };
|
|
308502
|
+
nameMap.set(fullName, indexed);
|
|
308503
|
+
const lowerLabel = entry.label.toLowerCase();
|
|
308504
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
308505
|
+
byLabel.push(indexed);
|
|
308506
|
+
labelMap.set(lowerLabel, byLabel);
|
|
308507
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
308508
|
+
byPhen.push(indexed);
|
|
308509
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
308510
|
+
}
|
|
308511
|
+
// Handle InvertedUnit items — must run after nameMap is fully populated above because
|
|
308512
|
+
// invertedSource lookup requires the inverted unit's target to already be in nameMap.
|
|
308513
|
+
for (const [name, item] of Object.entries(s.items)) {
|
|
308514
|
+
if (item.schemaItemType !== "InvertedUnit") {
|
|
308515
|
+
continue;
|
|
308516
|
+
}
|
|
308517
|
+
const inv = item;
|
|
308518
|
+
const fullName = `${s.name}.${name}`;
|
|
308519
|
+
const invertsName = (0,_UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__.qualifyItemName)(inv.invertsUnit, s.name);
|
|
308520
|
+
const unitSystem = inv.unitSystem;
|
|
308521
|
+
const invertedSource = nameMap.get(invertsName);
|
|
308522
|
+
const phenomenon = invertedSource?.props.phenomenon ?? "";
|
|
308523
|
+
const props = {
|
|
308524
|
+
name: fullName,
|
|
308525
|
+
label: inv.label ?? name,
|
|
308526
|
+
phenomenon,
|
|
308527
|
+
isValid: true,
|
|
308528
|
+
system: unitSystem,
|
|
308529
|
+
};
|
|
308530
|
+
invertedUnits.set(fullName, { props, invertsUnitName: invertsName });
|
|
308531
|
+
if (invertedSource) {
|
|
308532
|
+
const indexed = {
|
|
308533
|
+
props,
|
|
308534
|
+
resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },
|
|
308535
|
+
};
|
|
308536
|
+
nameMap.set(fullName, indexed);
|
|
308537
|
+
const lowerLabel = props.label.toLowerCase();
|
|
308538
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
308539
|
+
byLabel.push(indexed);
|
|
308540
|
+
labelMap.set(lowerLabel, byLabel);
|
|
308541
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
308542
|
+
byPhen.push(indexed);
|
|
308543
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
308544
|
+
}
|
|
308545
|
+
}
|
|
308546
|
+
return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };
|
|
308547
|
+
}
|
|
308548
|
+
/**
|
|
308549
|
+
* A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.
|
|
308550
|
+
*
|
|
308551
|
+
* The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method
|
|
308552
|
+
* call and cached at module scope — construction is essentially free, and multiple instances
|
|
308553
|
+
* share the same immutable lookup indexes.
|
|
308554
|
+
*
|
|
308555
|
+
* This is the zero-dependency default for backends, tools, and any frontend that doesn't need
|
|
308556
|
+
* iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.
|
|
308557
|
+
*
|
|
308558
|
+
* @see createUnitsProvider for layering schema-defined units on top of basic BIS units.
|
|
308559
|
+
* @beta
|
|
308560
|
+
*/
|
|
308561
|
+
class BasicUnitsProvider {
|
|
308562
|
+
// ── UnitsProvider implementation ─────────────────────────────────────
|
|
308563
|
+
/** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.
|
|
308564
|
+
* @param unitLabel - The display label to search for (case-insensitive).
|
|
308565
|
+
* @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `"Units"`.
|
|
308566
|
+
* @param phenomenon - Optional phenomenon filter (e.g. `"Units.LENGTH"`).
|
|
308567
|
+
* @param unitSystem - Optional unit system filter (e.g. `"Units.METRIC"`).
|
|
308568
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if no match is found.
|
|
308569
|
+
*/
|
|
308570
|
+
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
308571
|
+
const state = await resolveState();
|
|
308572
|
+
if (schemaName && schemaName !== state.schemaName) {
|
|
308573
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308574
|
+
}
|
|
308575
|
+
const candidates = state.labelMap.get(unitLabel.toLowerCase());
|
|
308576
|
+
if (!candidates || candidates.length === 0) {
|
|
308577
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308578
|
+
}
|
|
308579
|
+
for (const c of candidates) {
|
|
308580
|
+
if (phenomenon && c.props.phenomenon !== phenomenon) {
|
|
308581
|
+
continue;
|
|
308582
|
+
}
|
|
308583
|
+
if (unitSystem && c.props.system !== unitSystem) {
|
|
308584
|
+
continue;
|
|
308585
|
+
}
|
|
308586
|
+
return c.props;
|
|
308587
|
+
}
|
|
308588
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308589
|
+
}
|
|
308590
|
+
/** Return all units belonging to the given phenomenon (unit family).
|
|
308591
|
+
* @param phenomenon - The phenomenon full name (e.g. `"Units.LENGTH"`).
|
|
308592
|
+
* @returns An array of matching `UnitProps`, or an empty array if none.
|
|
308593
|
+
*/
|
|
308594
|
+
async getUnitsByFamily(phenomenon) {
|
|
308595
|
+
const state = await resolveState();
|
|
308596
|
+
const entries = state.phenomenonMap.get(phenomenon);
|
|
308597
|
+
return entries ? entries.map((e) => e.props) : [];
|
|
308598
|
+
}
|
|
308599
|
+
/** Find a unit by its fully-qualified name (e.g. `"Units.M"`).
|
|
308600
|
+
* @param unitName - The qualified unit name.
|
|
308601
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if not found.
|
|
308602
|
+
*/
|
|
308603
|
+
async findUnitByName(unitName) {
|
|
308604
|
+
const state = await resolveState();
|
|
308605
|
+
const entry = state.nameMap.get(unitName);
|
|
308606
|
+
return entry ? entry.props : new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308607
|
+
}
|
|
308608
|
+
/** Compute the conversion factors from `fromUnit` to `toUnit`.
|
|
308609
|
+
* Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.
|
|
308610
|
+
* @param fromUnit - The source unit.
|
|
308611
|
+
* @param toUnit - The target unit.
|
|
308612
|
+
* @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.
|
|
308613
|
+
*/
|
|
308614
|
+
async getConversion(fromUnit, toUnit) {
|
|
308615
|
+
const state = await resolveState();
|
|
308616
|
+
const from = state.nameMap.get(fromUnit.name);
|
|
308617
|
+
const to = state.nameMap.get(toUnit.name);
|
|
308618
|
+
if (!from || !to) {
|
|
308619
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308620
|
+
}
|
|
308621
|
+
const fromInverted = state.invertedUnits.get(fromUnit.name);
|
|
308622
|
+
const toInverted = state.invertedUnits.get(toUnit.name);
|
|
308623
|
+
const fromPhenomenon = fromInverted
|
|
308624
|
+
? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon
|
|
308625
|
+
: from.props.phenomenon;
|
|
308626
|
+
const toPhenomenon = toInverted
|
|
308627
|
+
? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon
|
|
308628
|
+
: to.props.phenomenon;
|
|
308629
|
+
if (fromPhenomenon !== toPhenomenon) {
|
|
308630
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308631
|
+
}
|
|
308632
|
+
if (fromInverted && toInverted) {
|
|
308633
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
308634
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
308635
|
+
if (innerFrom && innerTo) {
|
|
308636
|
+
const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
308637
|
+
return { factor: c.factor, offset: c.offset };
|
|
308638
|
+
}
|
|
308639
|
+
}
|
|
308640
|
+
if (fromInverted) {
|
|
308641
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
308642
|
+
if (innerFrom) {
|
|
308643
|
+
const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
308644
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPreConversion };
|
|
308645
|
+
}
|
|
308646
|
+
}
|
|
308647
|
+
if (toInverted) {
|
|
308648
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
308649
|
+
if (innerTo) {
|
|
308650
|
+
const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
308651
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPostConversion };
|
|
308652
|
+
}
|
|
308653
|
+
}
|
|
308654
|
+
const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
308655
|
+
return { factor: conv.factor, offset: conv.offset };
|
|
308656
|
+
}
|
|
308657
|
+
}
|
|
308658
|
+
|
|
308659
|
+
|
|
308660
|
+
/***/ }),
|
|
308661
|
+
|
|
308662
|
+
/***/ "../../core/quantity/lib/esm/CompositeUnitsProvider.js":
|
|
308663
|
+
/*!*************************************************************!*\
|
|
308664
|
+
!*** ../../core/quantity/lib/esm/CompositeUnitsProvider.js ***!
|
|
308665
|
+
\*************************************************************/
|
|
308666
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
308667
|
+
|
|
308668
|
+
"use strict";
|
|
308669
|
+
__webpack_require__.r(__webpack_exports__);
|
|
308670
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
308671
|
+
/* harmony export */ createUnitsProvider: () => (/* binding */ createUnitsProvider)
|
|
308672
|
+
/* harmony export */ });
|
|
308673
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
308674
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
308675
|
+
/*---------------------------------------------------------------------------------------------
|
|
308676
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
308677
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
308678
|
+
*--------------------------------------------------------------------------------------------*/
|
|
308679
|
+
|
|
308680
|
+
|
|
308681
|
+
/**
|
|
308682
|
+
* Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional
|
|
308683
|
+
* `primary` provider. Typical use: layer an iModel's schema units on top of the bundled
|
|
308684
|
+
* defaults from `@itwin/core-quantity`.
|
|
308685
|
+
*
|
|
308686
|
+
* Precedence rules:
|
|
308687
|
+
* - When `primary` is supplied and `bisUnitsPolicy` is `"preferSchema"` (the default): `primary` wins;
|
|
308688
|
+
* basic BIS units fill any gaps where `primary` returns an invalid unit or throws.
|
|
308689
|
+
* - When `bisUnitsPolicy` is `"preferBundled"`: basic BIS units win; `primary` is consulted only when the
|
|
308690
|
+
* basic provider can't answer.
|
|
308691
|
+
* - `getUnitsByFamily` always merges results from both providers, deduplicated by
|
|
308692
|
+
* `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.
|
|
308693
|
+
* - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`
|
|
308694
|
+
* (no wrapper), preserving `instanceof` checks and keeping the hot path fast.
|
|
308695
|
+
*
|
|
308696
|
+
* @beta
|
|
308697
|
+
*/
|
|
308698
|
+
function createUnitsProvider(options = {}) {
|
|
308699
|
+
const basic = new _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__.BasicUnitsProvider();
|
|
308700
|
+
const primary = options.primary;
|
|
308701
|
+
// NOTE: returns BasicUnitsProvider directly when no primary is provided.
|
|
308702
|
+
// QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.
|
|
308703
|
+
// If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.
|
|
308704
|
+
if (!primary) {
|
|
308705
|
+
return basic;
|
|
308706
|
+
}
|
|
308707
|
+
const providers = options.bisUnitsPolicy === "preferBundled" ? [basic, primary] : [primary, basic];
|
|
308708
|
+
return new CompositeUnitsProvider(providers);
|
|
308709
|
+
}
|
|
308710
|
+
class CompositeUnitsProvider {
|
|
308711
|
+
_providers;
|
|
308712
|
+
constructor(_providers) {
|
|
308713
|
+
this._providers = _providers;
|
|
308714
|
+
}
|
|
308715
|
+
async findUnit(label, schemaName, phenomenon, unitSystem) {
|
|
308716
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308717
|
+
const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));
|
|
308718
|
+
if (hit?.isValid) {
|
|
308719
|
+
return hit;
|
|
308720
|
+
}
|
|
308721
|
+
}
|
|
308722
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
308723
|
+
}
|
|
308724
|
+
async findUnitByName(name) {
|
|
308725
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308726
|
+
const hit = await tryFind(async () => this._providers[i].findUnitByName(name));
|
|
308727
|
+
if (hit?.isValid) {
|
|
308728
|
+
return hit;
|
|
308729
|
+
}
|
|
308730
|
+
}
|
|
308731
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
308732
|
+
}
|
|
308733
|
+
async getUnitsByFamily(phenomenon) {
|
|
308734
|
+
const seen = new Set();
|
|
308735
|
+
const out = [];
|
|
308736
|
+
// Query all providers in parallel; process results in declaration order to honour precedence.
|
|
308737
|
+
const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));
|
|
308738
|
+
for (const units of results) {
|
|
308739
|
+
for (const u of units) {
|
|
308740
|
+
if (!seen.has(u.name)) {
|
|
308741
|
+
seen.add(u.name);
|
|
308742
|
+
out.push(u);
|
|
308743
|
+
}
|
|
308744
|
+
}
|
|
308745
|
+
}
|
|
308746
|
+
return out;
|
|
308747
|
+
}
|
|
308748
|
+
async getConversion(from, to) {
|
|
308749
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308750
|
+
try {
|
|
308751
|
+
const result = await this._providers[i].getConversion(from, to);
|
|
308752
|
+
if (!result.error) {
|
|
308753
|
+
return result;
|
|
308754
|
+
}
|
|
308755
|
+
}
|
|
308756
|
+
catch { /* fall through to next provider */ }
|
|
308757
|
+
}
|
|
308758
|
+
try {
|
|
308759
|
+
return await this._providers[this._providers.length - 1].getConversion(from, to);
|
|
308760
|
+
}
|
|
308761
|
+
catch {
|
|
308762
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308763
|
+
}
|
|
308764
|
+
}
|
|
308765
|
+
}
|
|
308766
|
+
async function tryFind(fn) {
|
|
308767
|
+
try {
|
|
308768
|
+
return await fn();
|
|
308769
|
+
}
|
|
308770
|
+
catch {
|
|
308771
|
+
return undefined;
|
|
308772
|
+
}
|
|
308773
|
+
}
|
|
308774
|
+
async function tryList(fn) {
|
|
308775
|
+
try {
|
|
308776
|
+
return await fn();
|
|
308777
|
+
}
|
|
308778
|
+
catch {
|
|
308779
|
+
return [];
|
|
308780
|
+
}
|
|
308781
|
+
}
|
|
308782
|
+
|
|
308783
|
+
|
|
308801
308784
|
/***/ }),
|
|
308802
308785
|
|
|
308803
308786
|
/***/ "../../core/quantity/lib/esm/Constants.js":
|
|
@@ -310594,8 +310577,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310594
310577
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
310595
310578
|
/* harmony export */ FormatterSpec: () => (/* binding */ FormatterSpec)
|
|
310596
310579
|
/* harmony export */ });
|
|
310597
|
-
/* harmony import */ var
|
|
310598
|
-
/* harmony import */ var
|
|
310580
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
310581
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
310582
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
310583
|
+
/* harmony import */ var _Formatter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter */ "../../core/quantity/lib/esm/Formatter/Formatter.js");
|
|
310599
310584
|
/*---------------------------------------------------------------------------------------------
|
|
310600
310585
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
310601
310586
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -310605,6 +310590,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310605
310590
|
*/
|
|
310606
310591
|
|
|
310607
310592
|
|
|
310593
|
+
|
|
310594
|
+
|
|
310608
310595
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
310609
310596
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
310610
310597
|
/** 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.
|
|
@@ -310658,6 +310645,9 @@ class FormatterSpec {
|
|
|
310658
310645
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
310659
310646
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
310660
310647
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
310648
|
+
if (denominatorToNumerator.error) {
|
|
310649
|
+
_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.`);
|
|
310650
|
+
}
|
|
310661
310651
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
310662
310652
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
310663
310653
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -310708,7 +310698,7 @@ class FormatterSpec {
|
|
|
310708
310698
|
}
|
|
310709
310699
|
}
|
|
310710
310700
|
// Handle 2-unit composite for ratio formats (scale factors)
|
|
310711
|
-
if (format.type ===
|
|
310701
|
+
if (format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
310712
310702
|
return FormatterSpec.getRatioUnitConversions(format.units, unitsProvider, persistenceUnit);
|
|
310713
310703
|
}
|
|
310714
310704
|
if (format.units) {
|
|
@@ -310717,6 +310707,9 @@ class FormatterSpec {
|
|
|
310717
310707
|
let unitConversion;
|
|
310718
310708
|
if (convertFromUnit) {
|
|
310719
310709
|
unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
|
|
310710
|
+
if (unitConversion.error) {
|
|
310711
|
+
_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.`);
|
|
310712
|
+
}
|
|
310720
310713
|
}
|
|
310721
310714
|
else {
|
|
310722
310715
|
unitConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310749,6 +310742,9 @@ class FormatterSpec {
|
|
|
310749
310742
|
if (format.azimuthBaseUnit !== undefined) {
|
|
310750
310743
|
if (inputUnit !== undefined) {
|
|
310751
310744
|
azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);
|
|
310745
|
+
if (azimuthBaseConversion.error) {
|
|
310746
|
+
_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.`);
|
|
310747
|
+
}
|
|
310752
310748
|
}
|
|
310753
310749
|
else {
|
|
310754
310750
|
azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310758,6 +310754,9 @@ class FormatterSpec {
|
|
|
310758
310754
|
if (format.revolutionUnit !== undefined) {
|
|
310759
310755
|
if (inputUnit !== undefined) {
|
|
310760
310756
|
revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);
|
|
310757
|
+
if (revolutionConversion.error) {
|
|
310758
|
+
_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.`);
|
|
310759
|
+
}
|
|
310761
310760
|
}
|
|
310762
310761
|
else {
|
|
310763
310762
|
revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310767,7 +310766,7 @@ class FormatterSpec {
|
|
|
310767
310766
|
}
|
|
310768
310767
|
/** Format a quantity value. */
|
|
310769
310768
|
applyFormatting(magnitude) {
|
|
310770
|
-
return
|
|
310769
|
+
return _Formatter__WEBPACK_IMPORTED_MODULE_3__.Formatter.formatQuantity(magnitude, this);
|
|
310771
310770
|
}
|
|
310772
310771
|
}
|
|
310773
310772
|
|
|
@@ -310902,10 +310901,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310902
310901
|
/* harmony export */ ParseError: () => (/* binding */ ParseError),
|
|
310903
310902
|
/* harmony export */ Parser: () => (/* binding */ Parser)
|
|
310904
310903
|
/* harmony export */ });
|
|
310905
|
-
/* harmony import */ var
|
|
310906
|
-
/* harmony import */ var
|
|
310907
|
-
/* harmony import */ var
|
|
310908
|
-
/* harmony import */ var
|
|
310904
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
310905
|
+
/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants */ "../../core/quantity/lib/esm/Constants.js");
|
|
310906
|
+
/* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Exception */ "../../core/quantity/lib/esm/Exception.js");
|
|
310907
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
310908
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
310909
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
310909
310910
|
/*---------------------------------------------------------------------------------------------
|
|
310910
310911
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
310911
310912
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -310917,6 +310918,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310917
310918
|
|
|
310918
310919
|
|
|
310919
310920
|
|
|
310921
|
+
|
|
310922
|
+
|
|
310920
310923
|
/** Possible parser errors
|
|
310921
310924
|
* @beta
|
|
310922
310925
|
*/
|
|
@@ -311010,7 +311013,7 @@ class Parser {
|
|
|
311010
311013
|
let i = index + 1;
|
|
311011
311014
|
for (; i < stringToParse.length; i++) {
|
|
311012
311015
|
const charCode = stringToParse.charCodeAt(i);
|
|
311013
|
-
if (Parser.isDigit(charCode) || ((charCode ===
|
|
311016
|
+
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)))) {
|
|
311014
311017
|
exponentString = exponentString.concat(stringToParse[i]);
|
|
311015
311018
|
}
|
|
311016
311019
|
else {
|
|
@@ -311018,7 +311021,7 @@ class Parser {
|
|
|
311018
311021
|
break;
|
|
311019
311022
|
}
|
|
311020
311023
|
}
|
|
311021
|
-
if (exponentString.length > 1 || ((exponentString.length === 1) && (exponentString.charCodeAt(0) !==
|
|
311024
|
+
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)))
|
|
311022
311025
|
return new ScientificToken(i, exponentString);
|
|
311023
311026
|
return new ScientificToken(index);
|
|
311024
311027
|
}
|
|
@@ -311042,7 +311045,7 @@ class Parser {
|
|
|
311042
311045
|
}
|
|
311043
311046
|
}
|
|
311044
311047
|
else {
|
|
311045
|
-
if (processingNumerator && (charCode ===
|
|
311048
|
+
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)) {
|
|
311046
311049
|
processingNumerator = false;
|
|
311047
311050
|
}
|
|
311048
311051
|
else {
|
|
@@ -311062,7 +311065,7 @@ class Parser {
|
|
|
311062
311065
|
return new FractionToken(index + 1);
|
|
311063
311066
|
}
|
|
311064
311067
|
static isDigit(charCode) {
|
|
311065
|
-
return (charCode >=
|
|
311068
|
+
return (charCode >= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_ZERO) && (charCode <= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_NINE);
|
|
311066
311069
|
}
|
|
311067
311070
|
static isDigitOrDecimalSeparator(charCode, format) {
|
|
311068
311071
|
return (charCode === format.decimalSeparator.charCodeAt(0)) || Parser.isDigit(charCode);
|
|
@@ -311080,10 +311083,10 @@ class Parser {
|
|
|
311080
311083
|
let uomSeparatorToIgnore = 0;
|
|
311081
311084
|
let fractionDashCode = 0;
|
|
311082
311085
|
const skipCodes = [format.thousandSeparator.charCodeAt(0)];
|
|
311083
|
-
if (format.type ===
|
|
311086
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && format.stationSeparator && format.stationSeparator.length === 1)
|
|
311084
311087
|
skipCodes.push(format.stationSeparator.charCodeAt(0));
|
|
311085
|
-
if (format.type ===
|
|
311086
|
-
fractionDashCode =
|
|
311088
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && format.hasFormatTraitSet(_Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.FractionDash)) {
|
|
311089
|
+
fractionDashCode = _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS;
|
|
311087
311090
|
}
|
|
311088
311091
|
if (format.uomSeparator && format.uomSeparator !== " " && format.uomSeparator.length === 1) {
|
|
311089
311092
|
uomSeparatorToIgnore = format.uomSeparator.charCodeAt(0);
|
|
@@ -311105,7 +311108,7 @@ class Parser {
|
|
|
311105
311108
|
}
|
|
311106
311109
|
else {
|
|
311107
311110
|
if (processingNumber) {
|
|
311108
|
-
if (charCode ===
|
|
311111
|
+
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) {
|
|
311109
311112
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore, wipToken);
|
|
311110
311113
|
let fraction = fractSymbol.fraction;
|
|
311111
311114
|
i = fractSymbol.index;
|
|
@@ -311123,7 +311126,7 @@ class Parser {
|
|
|
311123
311126
|
}
|
|
311124
311127
|
else {
|
|
311125
311128
|
// a space may signify end of number or start of decimal
|
|
311126
|
-
if (charCode ===
|
|
311129
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE || charCode === fractionDashCode) {
|
|
311127
311130
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore);
|
|
311128
311131
|
let fraction = fractSymbol.fraction;
|
|
311129
311132
|
if (fractSymbol.fraction !== 0.0) {
|
|
@@ -311139,7 +311142,7 @@ class Parser {
|
|
|
311139
311142
|
processingNumber = false;
|
|
311140
311143
|
wipToken = "";
|
|
311141
311144
|
}
|
|
311142
|
-
else if (format.type ===
|
|
311145
|
+
else if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && wipToken.length > 0) {
|
|
311143
311146
|
if (signToken.length > 0) {
|
|
311144
311147
|
wipToken = signToken + wipToken;
|
|
311145
311148
|
signToken = "";
|
|
@@ -311152,7 +311155,7 @@ class Parser {
|
|
|
311152
311155
|
}
|
|
311153
311156
|
else {
|
|
311154
311157
|
// an "E" or "e" may signify scientific notation
|
|
311155
|
-
if (charCode ===
|
|
311158
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_UPPER_E || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_LOWER_E) {
|
|
311156
311159
|
const exponentSymbol = Parser.checkForScientificNotation(i, str, uomSeparatorToIgnore);
|
|
311157
311160
|
i = exponentSymbol.index;
|
|
311158
311161
|
if (exponentSymbol.exponent && exponentSymbol.exponent.length > 0) {
|
|
@@ -311170,7 +311173,7 @@ class Parser {
|
|
|
311170
311173
|
}
|
|
311171
311174
|
}
|
|
311172
311175
|
}
|
|
311173
|
-
if (format.type ===
|
|
311176
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && charCode === format.stationSeparator.charCodeAt(0)) {
|
|
311174
311177
|
if (!isStationSeparatorAdded) {
|
|
311175
311178
|
isStationSeparatorAdded = true;
|
|
311176
311179
|
continue;
|
|
@@ -311196,15 +311199,15 @@ class Parser {
|
|
|
311196
311199
|
else {
|
|
311197
311200
|
// not processing a number
|
|
311198
311201
|
const isCharOperator = isOperator(charCode);
|
|
311199
|
-
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !==
|
|
311202
|
+
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE;
|
|
311200
311203
|
if (isSpacer && i > 0 && i < str.length - 1) {
|
|
311201
311204
|
const prevCharCode = str.charCodeAt(i - 1);
|
|
311202
|
-
if (isCharOperator && prevCharCode !==
|
|
311205
|
+
if (isCharOperator && prevCharCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
311203
311206
|
// ignore spacer if it's not at the start or end, not whitespace, and is not in front of a whitespace
|
|
311204
311207
|
continue;
|
|
311205
311208
|
}
|
|
311206
311209
|
}
|
|
311207
|
-
if (wipToken.length === 0 && charCode ===
|
|
311210
|
+
if (wipToken.length === 0 && charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
311208
311211
|
// Don't add space when the wip token is empty.
|
|
311209
311212
|
continue;
|
|
311210
311213
|
}
|
|
@@ -311296,6 +311299,9 @@ class Parser {
|
|
|
311296
311299
|
else {
|
|
311297
311300
|
// Add new conversion to the list.
|
|
311298
311301
|
const conversion = await unitsProvider.getConversion(unitProps, outUnit);
|
|
311302
|
+
if (conversion.error) {
|
|
311303
|
+
_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.`);
|
|
311304
|
+
}
|
|
311299
311305
|
if (conversion) {
|
|
311300
311306
|
spec = {
|
|
311301
311307
|
conversion,
|
|
@@ -311316,12 +311322,16 @@ class Parser {
|
|
|
311316
311322
|
static async createQuantityFromParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider) {
|
|
311317
311323
|
const unitConversionInfos = await this.getRequiredUnitsConversionsToParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider);
|
|
311318
311324
|
if (unitConversionInfos.outUnit) {
|
|
311319
|
-
const
|
|
311325
|
+
const outUnitConversion = await unitsProvider.getConversion(unitConversionInfos.outUnit, unitConversionInfos.outUnit);
|
|
311326
|
+
if (outUnitConversion.error) {
|
|
311327
|
+
_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.`);
|
|
311328
|
+
}
|
|
311329
|
+
const value = Parser.getQuantityValueFromParseTokens(tokens, format, unitConversionInfos.specs, outUnitConversion);
|
|
311320
311330
|
if (value.ok) {
|
|
311321
|
-
return new
|
|
311331
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(unitConversionInfos.outUnit, value.value);
|
|
311322
311332
|
}
|
|
311323
311333
|
}
|
|
311324
|
-
return new
|
|
311334
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity();
|
|
311325
311335
|
}
|
|
311326
311336
|
/** Async method to generate a Quantity given a string that represents a quantity value and likely a unit label.
|
|
311327
311337
|
* @param inString A string that contains text represent a quantity.
|
|
@@ -311386,7 +311396,7 @@ class Parser {
|
|
|
311386
311396
|
}
|
|
311387
311397
|
// if there were unique unit labels but not matched to any units, throw an error
|
|
311388
311398
|
if (uniqueUnitLabels.length > 0)
|
|
311389
|
-
throw new
|
|
311399
|
+
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.`);
|
|
311390
311400
|
}
|
|
311391
311401
|
return unitConversion;
|
|
311392
311402
|
}
|
|
@@ -311439,10 +311449,10 @@ class Parser {
|
|
|
311439
311449
|
}
|
|
311440
311450
|
catch (e) {
|
|
311441
311451
|
// If we failed to get the default unit conversion, we need to return an error.
|
|
311442
|
-
if (e instanceof
|
|
311452
|
+
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnitLabelSuppliedButNotMatched)
|
|
311443
311453
|
return { ok: false, error: ParseError.UnitLabelSuppliedButNotMatched };
|
|
311444
311454
|
}
|
|
311445
|
-
if (format.type ===
|
|
311455
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && format.units !== undefined && format.units.length > 0) {
|
|
311446
311456
|
const units = format.units;
|
|
311447
311457
|
const desiredNumberOfTokens = units.length;
|
|
311448
311458
|
if (tokens.length < desiredNumberOfTokens && tokens[0].isNumber && desiredNumberOfTokens <= 3) {
|
|
@@ -311502,7 +311512,7 @@ class Parser {
|
|
|
311502
311512
|
}
|
|
311503
311513
|
}
|
|
311504
311514
|
if (conversion) {
|
|
311505
|
-
value = (0,
|
|
311515
|
+
value = (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(value, conversion);
|
|
311506
311516
|
}
|
|
311507
311517
|
mag = mag + value;
|
|
311508
311518
|
compositeUnitIndex++;
|
|
@@ -311535,13 +311545,13 @@ class Parser {
|
|
|
311535
311545
|
}
|
|
311536
311546
|
});
|
|
311537
311547
|
}
|
|
311538
|
-
if (parserSpec.format.type ===
|
|
311548
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing) {
|
|
311539
311549
|
return this.parseBearingFormat(inString, parserSpec);
|
|
311540
311550
|
}
|
|
311541
|
-
if (parserSpec.format.type ===
|
|
311551
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
311542
311552
|
return this.parseAzimuthFormat(inString, parserSpec);
|
|
311543
311553
|
}
|
|
311544
|
-
if (parserSpec.format.type ===
|
|
311554
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
311545
311555
|
return this.parseRatioFormat(inString, parserSpec);
|
|
311546
311556
|
}
|
|
311547
311557
|
return this.parseAndProcessTokens(inString, parserSpec.format, parserSpec.unitConversions);
|
|
@@ -311567,9 +311577,9 @@ class Parser {
|
|
|
311567
311577
|
}
|
|
311568
311578
|
});
|
|
311569
311579
|
}
|
|
311570
|
-
if (format.type ===
|
|
311580
|
+
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) {
|
|
311571
311581
|
// throw error indicating to call parseQuantityString instead
|
|
311572
|
-
throw new
|
|
311582
|
+
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.`);
|
|
311573
311583
|
}
|
|
311574
311584
|
return this.parseAndProcessTokens(inString, format, unitsConversions);
|
|
311575
311585
|
}
|
|
@@ -311582,7 +311592,7 @@ class Parser {
|
|
|
311582
311592
|
const conversion = this.tryFindUnitConversion(specialDirUnit.label, spec.unitConversions, preferredUnit);
|
|
311583
311593
|
if (!conversion)
|
|
311584
311594
|
return { ok: true, value: mag };
|
|
311585
|
-
return { ok: true, value: (0,
|
|
311595
|
+
return { ok: true, value: (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(mag, conversion) };
|
|
311586
311596
|
}
|
|
311587
311597
|
static parseBearingFormat(inString, spec) {
|
|
311588
311598
|
const specialDirections = {
|
|
@@ -311672,12 +311682,12 @@ class Parser {
|
|
|
311672
311682
|
let azimuthBase = 0.0;
|
|
311673
311683
|
if (spec.format.azimuthBase !== undefined) {
|
|
311674
311684
|
if (spec.azimuthBaseConversion === undefined) {
|
|
311675
|
-
throw new
|
|
311685
|
+
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.`);
|
|
311676
311686
|
}
|
|
311677
|
-
const azBaseQuantity = new
|
|
311687
|
+
const azBaseQuantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);
|
|
311678
311688
|
const azBaseConverted = azBaseQuantity.convertTo(spec.outUnit, spec.azimuthBaseConversion);
|
|
311679
311689
|
if (!azBaseConverted.isValid) {
|
|
311680
|
-
throw new
|
|
311690
|
+
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}.`);
|
|
311681
311691
|
}
|
|
311682
311692
|
azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);
|
|
311683
311693
|
}
|
|
@@ -311709,7 +311719,7 @@ class Parser {
|
|
|
311709
311719
|
static parseRatioPart(partStr, format) {
|
|
311710
311720
|
partStr = partStr.trim();
|
|
311711
311721
|
// Parse tokens - fractions are automatically converted to decimal values by parseQuantitySpecification
|
|
311712
|
-
const tempFormat = format.clone({ type:
|
|
311722
|
+
const tempFormat = format.clone({ type: _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal });
|
|
311713
311723
|
const tokens = Parser.parseQuantitySpecification(partStr, tempFormat);
|
|
311714
311724
|
let value = NaN;
|
|
311715
311725
|
let unitLabel;
|
|
@@ -311783,7 +311793,7 @@ class Parser {
|
|
|
311783
311793
|
const defaultUnit = spec.format.units && spec.format.units.length > 0 ? spec.format.units[0][0] : undefined;
|
|
311784
311794
|
const unitConversion = defaultUnit ? Parser.tryFindUnitConversion(defaultUnit.label, spec.unitConversions, defaultUnit) : undefined;
|
|
311785
311795
|
if (!unitConversion) {
|
|
311786
|
-
throw new
|
|
311796
|
+
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}.`);
|
|
311787
311797
|
}
|
|
311788
311798
|
if (denominatorPart.value === 0) {
|
|
311789
311799
|
if (unitConversion.inversion && numeratorPart.value === 1)
|
|
@@ -311793,10 +311803,10 @@ class Parser {
|
|
|
311793
311803
|
}
|
|
311794
311804
|
let quantity;
|
|
311795
311805
|
if (spec.format.units && spec.outUnit) {
|
|
311796
|
-
quantity = new
|
|
311806
|
+
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.units[0][0], numeratorPart.value / denominatorPart.value);
|
|
311797
311807
|
}
|
|
311798
311808
|
else {
|
|
311799
|
-
throw new
|
|
311809
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, "Missing presentation unit or persistence unit for ratio format.");
|
|
311800
311810
|
}
|
|
311801
311811
|
let converted;
|
|
311802
311812
|
try {
|
|
@@ -311804,13 +311814,13 @@ class Parser {
|
|
|
311804
311814
|
}
|
|
311805
311815
|
catch (err) {
|
|
311806
311816
|
// for input of "0:N" with reversed unit
|
|
311807
|
-
if (err instanceof
|
|
311817
|
+
if (err instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && err.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.InvertingZero) {
|
|
311808
311818
|
return { ok: false, error: ParseError.InvalidMathResult };
|
|
311809
311819
|
}
|
|
311810
311820
|
throw err;
|
|
311811
311821
|
}
|
|
311812
311822
|
if (!converted.isValid) {
|
|
311813
|
-
throw new
|
|
311823
|
+
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}.`);
|
|
311814
311824
|
}
|
|
311815
311825
|
return { ok: true, value: converted.magnitude };
|
|
311816
311826
|
}
|
|
@@ -311823,12 +311833,12 @@ class Parser {
|
|
|
311823
311833
|
}
|
|
311824
311834
|
static getRevolution(spec) {
|
|
311825
311835
|
if (spec.revolutionConversion === undefined) {
|
|
311826
|
-
throw new
|
|
311836
|
+
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.`);
|
|
311827
311837
|
}
|
|
311828
|
-
const revolution = new
|
|
311838
|
+
const revolution = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.revolutionUnit, 1.0);
|
|
311829
311839
|
const converted = revolution.convertTo(spec.outUnit, spec.revolutionConversion);
|
|
311830
311840
|
if (!converted.isValid) {
|
|
311831
|
-
throw new
|
|
311841
|
+
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}.`);
|
|
311832
311842
|
}
|
|
311833
311843
|
return converted.magnitude;
|
|
311834
311844
|
}
|
|
@@ -311851,6 +311861,9 @@ class Parser {
|
|
|
311851
311861
|
const familyUnits = await unitsProvider.getUnitsByFamily(outUnit.phenomenon);
|
|
311852
311862
|
for (const unit of familyUnits) {
|
|
311853
311863
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
311864
|
+
if (conversion.error) {
|
|
311865
|
+
_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.`);
|
|
311866
|
+
}
|
|
311854
311867
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
311855
311868
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
311856
311869
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -311888,6 +311901,9 @@ class Parser {
|
|
|
311888
311901
|
continue;
|
|
311889
311902
|
}
|
|
311890
311903
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
311904
|
+
if (conversion.error) {
|
|
311905
|
+
_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.`);
|
|
311906
|
+
}
|
|
311891
311907
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
311892
311908
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
311893
311909
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -311932,8 +311948,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
311932
311948
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
311933
311949
|
/* harmony export */ ParserSpec: () => (/* binding */ ParserSpec)
|
|
311934
311950
|
/* harmony export */ });
|
|
311935
|
-
/* harmony import */ var
|
|
311936
|
-
/* harmony import */ var
|
|
311951
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
311952
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
311953
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/Parser.js");
|
|
311954
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
311937
311955
|
/*---------------------------------------------------------------------------------------------
|
|
311938
311956
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
311939
311957
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -311943,6 +311961,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
311943
311961
|
*/
|
|
311944
311962
|
|
|
311945
311963
|
|
|
311964
|
+
|
|
311965
|
+
|
|
311946
311966
|
/** A ParserSpec holds information needed to parse a string into a quantity synchronously.
|
|
311947
311967
|
* @beta
|
|
311948
311968
|
*/
|
|
@@ -311975,6 +311995,9 @@ class ParserSpec {
|
|
|
311975
311995
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
311976
311996
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
311977
311997
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
311998
|
+
if (denominatorToNumerator.error) {
|
|
311999
|
+
_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.`);
|
|
312000
|
+
}
|
|
311978
312001
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
311979
312002
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
311980
312003
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -312023,16 +312046,20 @@ class ParserSpec {
|
|
|
312023
312046
|
static async create(format, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
312024
312047
|
let conversions;
|
|
312025
312048
|
// For ratio formats with 2 composite units, use private helper method
|
|
312026
|
-
if (format.type ===
|
|
312049
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
312027
312050
|
conversions = await ParserSpec.getRatioUnitConversions(format.units, unitsProvider, outUnit, altUnitLabelsProvider);
|
|
312028
312051
|
}
|
|
312029
312052
|
else {
|
|
312030
|
-
conversions = await
|
|
312053
|
+
conversions = await _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.createUnitConversionSpecsForUnit(unitsProvider, outUnit, altUnitLabelsProvider);
|
|
312031
312054
|
}
|
|
312032
312055
|
const spec = new ParserSpec(outUnit, format, conversions);
|
|
312033
312056
|
if (format.azimuthBaseUnit !== undefined) {
|
|
312034
312057
|
if (outUnit !== undefined) {
|
|
312035
|
-
|
|
312058
|
+
const azimuthResult = await unitsProvider.getConversion(format.azimuthBaseUnit, outUnit);
|
|
312059
|
+
if (azimuthResult.error) {
|
|
312060
|
+
_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.`);
|
|
312061
|
+
}
|
|
312062
|
+
spec._azimuthBaseConversion = azimuthResult;
|
|
312036
312063
|
}
|
|
312037
312064
|
else {
|
|
312038
312065
|
spec._azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -312040,7 +312067,11 @@ class ParserSpec {
|
|
|
312040
312067
|
}
|
|
312041
312068
|
if (format.revolutionUnit !== undefined) {
|
|
312042
312069
|
if (outUnit !== undefined) {
|
|
312043
|
-
|
|
312070
|
+
const revolutionResult = await unitsProvider.getConversion(format.revolutionUnit, outUnit);
|
|
312071
|
+
if (revolutionResult.error) {
|
|
312072
|
+
_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.`);
|
|
312073
|
+
}
|
|
312074
|
+
spec._revolutionConversion = revolutionResult;
|
|
312044
312075
|
}
|
|
312045
312076
|
else {
|
|
312046
312077
|
spec._revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -312050,7 +312081,7 @@ class ParserSpec {
|
|
|
312050
312081
|
}
|
|
312051
312082
|
/** Do the parsing. Done this way to allow Custom Parser Specs to parse custom formatted strings into their quantities. */
|
|
312052
312083
|
parseToQuantityValue(inString) {
|
|
312053
|
-
return
|
|
312084
|
+
return _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.parseQuantityString(inString, this);
|
|
312054
312085
|
}
|
|
312055
312086
|
}
|
|
312056
312087
|
|
|
@@ -312197,9 +312228,47 @@ var QuantityLoggerCategory;
|
|
|
312197
312228
|
QuantityLoggerCategory["Package"] = "core-quantity";
|
|
312198
312229
|
/** Logger category for quantity formatting operations. */
|
|
312199
312230
|
QuantityLoggerCategory["Formatting"] = "core-quantity.Formatting";
|
|
312231
|
+
/** Logger category for quantity parsing operations. */
|
|
312232
|
+
QuantityLoggerCategory["Parsing"] = "core-quantity.Parsing";
|
|
312200
312233
|
})(QuantityLoggerCategory || (QuantityLoggerCategory = {}));
|
|
312201
312234
|
|
|
312202
312235
|
|
|
312236
|
+
/***/ }),
|
|
312237
|
+
|
|
312238
|
+
/***/ "../../core/quantity/lib/esm/SerializedUnitSchema.js":
|
|
312239
|
+
/*!***********************************************************!*\
|
|
312240
|
+
!*** ../../core/quantity/lib/esm/SerializedUnitSchema.js ***!
|
|
312241
|
+
\***********************************************************/
|
|
312242
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312243
|
+
|
|
312244
|
+
"use strict";
|
|
312245
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312246
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312247
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* binding */ SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
312248
|
+
/* harmony export */ });
|
|
312249
|
+
/*---------------------------------------------------------------------------------------------
|
|
312250
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312251
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312252
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312253
|
+
/** Current version of the serialization format for `SerializedUnitSchema`.
|
|
312254
|
+
*
|
|
312255
|
+
* This value is written into `Units.json` as the `version` field and checked at
|
|
312256
|
+
* parse time. Two version axes exist:
|
|
312257
|
+
*
|
|
312258
|
+
* - **Format version** (`SERIALIZED_UNIT_SCHEMA_VERSION` / `Units.json.version`): bump
|
|
312259
|
+
* the major version when the shape of the `SerializedUnitSchema` interfaces changes
|
|
312260
|
+
* incompatibly (e.g. renaming fields, removing required properties). Minor bumps for
|
|
312261
|
+
* backward-compatible additions.
|
|
312262
|
+
*
|
|
312263
|
+
* - **Source provenance** (`sourceEcSchemaVersion` inside `Units.json`): records which
|
|
312264
|
+
* version of the BIS Units EC schema the data was derived from (e.g. `"01.00.09"`).
|
|
312265
|
+
* This is a traceability marker, not a runtime contract.
|
|
312266
|
+
*
|
|
312267
|
+
* @internal
|
|
312268
|
+
*/
|
|
312269
|
+
const SERIALIZED_UNIT_SCHEMA_VERSION = "01.00.00";
|
|
312270
|
+
|
|
312271
|
+
|
|
312203
312272
|
/***/ }),
|
|
312204
312273
|
|
|
312205
312274
|
/***/ "../../core/quantity/lib/esm/Unit.js":
|
|
@@ -312253,6 +312322,399 @@ class BadUnit {
|
|
|
312253
312322
|
}
|
|
312254
312323
|
|
|
312255
312324
|
|
|
312325
|
+
/***/ }),
|
|
312326
|
+
|
|
312327
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Graph.js":
|
|
312328
|
+
/*!***********************************************************!*\
|
|
312329
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Graph.js ***!
|
|
312330
|
+
\***********************************************************/
|
|
312331
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312332
|
+
|
|
312333
|
+
"use strict";
|
|
312334
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312335
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312336
|
+
/* harmony export */ UnitConversionGraph: () => (/* binding */ UnitConversionGraph)
|
|
312337
|
+
/* harmony export */ });
|
|
312338
|
+
/*---------------------------------------------------------------------------------------------
|
|
312339
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312340
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312341
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312342
|
+
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
312343
|
+
/** @internal */
|
|
312344
|
+
class UnitConversionGraph {
|
|
312345
|
+
_edgeKeyDelim = "\x01";
|
|
312346
|
+
_label = "";
|
|
312347
|
+
_nodeCount = 0;
|
|
312348
|
+
_edgeCount = 0;
|
|
312349
|
+
_nodes;
|
|
312350
|
+
_edgeObjs;
|
|
312351
|
+
_edgeLabels;
|
|
312352
|
+
_outEdges;
|
|
312353
|
+
constructor() {
|
|
312354
|
+
this._nodes = {};
|
|
312355
|
+
this._edgeObjs = {};
|
|
312356
|
+
this._edgeLabels = {};
|
|
312357
|
+
this._outEdges = {};
|
|
312358
|
+
}
|
|
312359
|
+
setGraph = (label) => {
|
|
312360
|
+
this._label = label;
|
|
312361
|
+
return this;
|
|
312362
|
+
};
|
|
312363
|
+
graph = () => {
|
|
312364
|
+
return this._label;
|
|
312365
|
+
};
|
|
312366
|
+
nodeCount = () => {
|
|
312367
|
+
return this._nodeCount;
|
|
312368
|
+
};
|
|
312369
|
+
nodes = () => {
|
|
312370
|
+
return Object.keys(this._nodes);
|
|
312371
|
+
};
|
|
312372
|
+
setNode = (nodeKey, nodeValue) => {
|
|
312373
|
+
if (nodeKey in this._nodes) {
|
|
312374
|
+
this._nodes[nodeKey] = nodeValue;
|
|
312375
|
+
return;
|
|
312376
|
+
}
|
|
312377
|
+
this._nodes[nodeKey] = nodeValue;
|
|
312378
|
+
this._outEdges[nodeKey] = {};
|
|
312379
|
+
++this._nodeCount;
|
|
312380
|
+
};
|
|
312381
|
+
node = (nodeKey) => {
|
|
312382
|
+
return this._nodes[nodeKey];
|
|
312383
|
+
};
|
|
312384
|
+
hasNode = (nodeKey) => {
|
|
312385
|
+
return nodeKey in this._nodes;
|
|
312386
|
+
};
|
|
312387
|
+
edgeCount = () => {
|
|
312388
|
+
return this._edgeCount;
|
|
312389
|
+
};
|
|
312390
|
+
edges = () => {
|
|
312391
|
+
return Object.values(this._edgeObjs);
|
|
312392
|
+
};
|
|
312393
|
+
setEdge = (v, w, value) => {
|
|
312394
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
312395
|
+
if (edgeId in this._edgeLabels) {
|
|
312396
|
+
// Update exponent, specific to this graph's use case
|
|
312397
|
+
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
312398
|
+
return;
|
|
312399
|
+
}
|
|
312400
|
+
this._edgeLabels[edgeId] = value;
|
|
312401
|
+
const edgeObj = {
|
|
312402
|
+
v,
|
|
312403
|
+
w,
|
|
312404
|
+
};
|
|
312405
|
+
this._edgeObjs[edgeId] = edgeObj;
|
|
312406
|
+
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
312407
|
+
this._outEdges[v][edgeId] = edgeObj;
|
|
312408
|
+
this._edgeCount++;
|
|
312409
|
+
};
|
|
312410
|
+
edge = (v, w) => {
|
|
312411
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
312412
|
+
return this._edgeLabels[edgeId];
|
|
312413
|
+
};
|
|
312414
|
+
outEdges = (v) => {
|
|
312415
|
+
const outV = this._outEdges[v];
|
|
312416
|
+
const edges = Object.values(outV);
|
|
312417
|
+
return edges;
|
|
312418
|
+
};
|
|
312419
|
+
}
|
|
312420
|
+
|
|
312421
|
+
|
|
312422
|
+
/***/ }),
|
|
312423
|
+
|
|
312424
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Parser.js":
|
|
312425
|
+
/*!************************************************************!*\
|
|
312426
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Parser.js ***!
|
|
312427
|
+
\************************************************************/
|
|
312428
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312429
|
+
|
|
312430
|
+
"use strict";
|
|
312431
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312432
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312433
|
+
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
312434
|
+
/* harmony export */ });
|
|
312435
|
+
/*---------------------------------------------------------------------------------------------
|
|
312436
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312437
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312438
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312439
|
+
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
312440
|
+
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
312441
|
+
const sp = "*";
|
|
312442
|
+
/** @internal */
|
|
312443
|
+
var Tokens;
|
|
312444
|
+
(function (Tokens) {
|
|
312445
|
+
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
312446
|
+
Tokens[Tokens["Word"] = 2] = "Word";
|
|
312447
|
+
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
312448
|
+
})(Tokens || (Tokens = {}));
|
|
312449
|
+
/** @internal */
|
|
312450
|
+
function parseDefinition(definition) {
|
|
312451
|
+
const unitMap = new Map();
|
|
312452
|
+
if (expressionRgx.test(definition)) {
|
|
312453
|
+
for (const unit of definition.split(sp)) {
|
|
312454
|
+
const tokens = unit.split(tokenRgx);
|
|
312455
|
+
const name = tokens[Tokens.Word];
|
|
312456
|
+
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
312457
|
+
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
312458
|
+
if (unitMap.has(name)) {
|
|
312459
|
+
const currentDefinition = unitMap.get(name);
|
|
312460
|
+
if (currentDefinition)
|
|
312461
|
+
unitMap.set(name, { ...currentDefinition, exponent: currentDefinition.exponent + exponent });
|
|
312462
|
+
}
|
|
312463
|
+
else {
|
|
312464
|
+
unitMap.set(name, { name, exponent, constant });
|
|
312465
|
+
}
|
|
312466
|
+
}
|
|
312467
|
+
return unitMap;
|
|
312468
|
+
}
|
|
312469
|
+
else {
|
|
312470
|
+
throw new Error("Invalid definition expression.");
|
|
312471
|
+
}
|
|
312472
|
+
}
|
|
312473
|
+
|
|
312474
|
+
|
|
312475
|
+
/***/ }),
|
|
312476
|
+
|
|
312477
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js":
|
|
312478
|
+
/*!********************************************************************!*\
|
|
312479
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
312480
|
+
\********************************************************************/
|
|
312481
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312482
|
+
|
|
312483
|
+
"use strict";
|
|
312484
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312485
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312486
|
+
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
312487
|
+
/* harmony export */ });
|
|
312488
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
312489
|
+
/*---------------------------------------------------------------------------------------------
|
|
312490
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312491
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312492
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312493
|
+
|
|
312494
|
+
/**
|
|
312495
|
+
* Class used for storing calculated conversion between two Units and converting values from one Unit to another.
|
|
312496
|
+
* @internal
|
|
312497
|
+
*/
|
|
312498
|
+
class UnitConversion {
|
|
312499
|
+
factor;
|
|
312500
|
+
offset;
|
|
312501
|
+
constructor(factor = 1.0, offset = 0.0) {
|
|
312502
|
+
this.factor = factor;
|
|
312503
|
+
this.offset = offset;
|
|
312504
|
+
}
|
|
312505
|
+
/**
|
|
312506
|
+
* Converts x using UnitConversion
|
|
312507
|
+
* @param x Input magnitude to be converted
|
|
312508
|
+
* @returns Output magnitude after conversion
|
|
312509
|
+
*/
|
|
312510
|
+
evaluate(x) {
|
|
312511
|
+
return this.factor * x + this.offset;
|
|
312512
|
+
}
|
|
312513
|
+
/**
|
|
312514
|
+
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
312515
|
+
* @internal
|
|
312516
|
+
*/
|
|
312517
|
+
inverse() {
|
|
312518
|
+
const inverseFactor = 1.0 / this.factor;
|
|
312519
|
+
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
312520
|
+
}
|
|
312521
|
+
/**
|
|
312522
|
+
* Combines two UnitConversions
|
|
312523
|
+
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
312524
|
+
* @internal
|
|
312525
|
+
*/
|
|
312526
|
+
compose(conversion) {
|
|
312527
|
+
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
312528
|
+
}
|
|
312529
|
+
/**
|
|
312530
|
+
* Multiples two UnitConversions together to calculate factor during reducing
|
|
312531
|
+
* @internal
|
|
312532
|
+
*/
|
|
312533
|
+
multiply(conversion) {
|
|
312534
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(conversion.offset, 0.0) && (0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
312535
|
+
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
312536
|
+
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
312537
|
+
}
|
|
312538
|
+
/**
|
|
312539
|
+
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
312540
|
+
* @internal
|
|
312541
|
+
*/
|
|
312542
|
+
raise(power) {
|
|
312543
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 1.0))
|
|
312544
|
+
return new UnitConversion(this.factor, this.offset);
|
|
312545
|
+
else if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 0.0))
|
|
312546
|
+
return new UnitConversion(1.0, 0.0);
|
|
312547
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
312548
|
+
return new UnitConversion(this.factor ** power, 0.0);
|
|
312549
|
+
throw new Error("Cannot raise map with non-zero offset");
|
|
312550
|
+
}
|
|
312551
|
+
/** @internal */
|
|
312552
|
+
static identity = new UnitConversion();
|
|
312553
|
+
/**
|
|
312554
|
+
* Returns UnitConversion with source's numerator and denominator in factor and source's offset in offset for reducing.
|
|
312555
|
+
* Accepts any object that structurally satisfies `UnitConversionSource` (e.g. EC `Unit` or `Constant`).
|
|
312556
|
+
* @internal
|
|
312557
|
+
*/
|
|
312558
|
+
static from(source) {
|
|
312559
|
+
const offset = source.offset ?? 0;
|
|
312560
|
+
const hasOffset = !(0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(offset, 0.0);
|
|
312561
|
+
return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);
|
|
312562
|
+
}
|
|
312563
|
+
}
|
|
312564
|
+
|
|
312565
|
+
|
|
312566
|
+
/***/ }),
|
|
312567
|
+
|
|
312568
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js":
|
|
312569
|
+
/*!****************************************************************************!*\
|
|
312570
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js ***!
|
|
312571
|
+
\****************************************************************************/
|
|
312572
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312573
|
+
|
|
312574
|
+
"use strict";
|
|
312575
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312576
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312577
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* binding */ UnitDefinitionResolver)
|
|
312578
|
+
/* harmony export */ });
|
|
312579
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
312580
|
+
/* harmony import */ var _UnitConversion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
312581
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
312582
|
+
/* harmony import */ var _nameUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
312583
|
+
/*---------------------------------------------------------------------------------------------
|
|
312584
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312585
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312586
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312587
|
+
|
|
312588
|
+
|
|
312589
|
+
|
|
312590
|
+
|
|
312591
|
+
const MAX_RESOLUTION_DEPTH = 30;
|
|
312592
|
+
/** Resolves every unit in a `SerializedUnitSchema` to a `UnitConversion` relative to its phenomenon's base unit.
|
|
312593
|
+
* @internal
|
|
312594
|
+
*/
|
|
312595
|
+
class UnitDefinitionResolver {
|
|
312596
|
+
_schema;
|
|
312597
|
+
_cache = new Map();
|
|
312598
|
+
constructor(schema) {
|
|
312599
|
+
if (schema.version !== _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
312600
|
+
throw new Error(`Unsupported Units.json version "${schema.version}". Expected "${_SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION}".`);
|
|
312601
|
+
this._schema = schema;
|
|
312602
|
+
}
|
|
312603
|
+
/** Resolve all Unit items in the schema and return a map from item name to `ResolvedUnit`. */
|
|
312604
|
+
resolveAll() {
|
|
312605
|
+
const result = new Map();
|
|
312606
|
+
for (const [name, item] of Object.entries(this._schema.items)) {
|
|
312607
|
+
if (item.schemaItemType === "Unit") {
|
|
312608
|
+
const conversion = this._resolveUnit(name, 0);
|
|
312609
|
+
result.set(name, {
|
|
312610
|
+
name,
|
|
312611
|
+
label: item.label ?? name,
|
|
312612
|
+
phenomenon: item.phenomenon,
|
|
312613
|
+
unitSystem: item.unitSystem,
|
|
312614
|
+
conversion,
|
|
312615
|
+
});
|
|
312616
|
+
}
|
|
312617
|
+
}
|
|
312618
|
+
return result;
|
|
312619
|
+
}
|
|
312620
|
+
/** Resolve a single unit by unqualified name, returning its conversion to base. */
|
|
312621
|
+
_resolveUnit(name, depth) {
|
|
312622
|
+
if (depth > MAX_RESOLUTION_DEPTH)
|
|
312623
|
+
throw new Error(`Unit resolution depth exceeded ${MAX_RESOLUTION_DEPTH} for "${name}"`);
|
|
312624
|
+
const cached = this._cache.get(name);
|
|
312625
|
+
if (cached)
|
|
312626
|
+
return cached;
|
|
312627
|
+
const item = this._schema.items[name];
|
|
312628
|
+
if (!item)
|
|
312629
|
+
throw new Error(`Unknown schema item: "${name}"`);
|
|
312630
|
+
let conversion;
|
|
312631
|
+
if (item.schemaItemType === "Constant") {
|
|
312632
|
+
conversion = this._resolveConstant(name, item, depth);
|
|
312633
|
+
}
|
|
312634
|
+
else if (item.schemaItemType === "Unit") {
|
|
312635
|
+
conversion = this._resolveUnitItem(name, item, depth);
|
|
312636
|
+
}
|
|
312637
|
+
else {
|
|
312638
|
+
throw new Error(`Cannot resolve item of type "${item.schemaItemType}": "${name}"`);
|
|
312639
|
+
}
|
|
312640
|
+
this._cache.set(name, conversion);
|
|
312641
|
+
return conversion;
|
|
312642
|
+
}
|
|
312643
|
+
_resolveConstant(name, item, depth) {
|
|
312644
|
+
// A constant is identity if its definition is its own name
|
|
312645
|
+
if (item.definition === name)
|
|
312646
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312647
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
312648
|
+
numerator: item.numerator ?? 1,
|
|
312649
|
+
denominator: item.denominator ?? 1,
|
|
312650
|
+
});
|
|
312651
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
312652
|
+
return defConv.compose(selfConv);
|
|
312653
|
+
}
|
|
312654
|
+
_resolveUnitItem(name, item, depth) {
|
|
312655
|
+
// A unit is a base unit if its definition is its own name
|
|
312656
|
+
if (item.definition === name)
|
|
312657
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312658
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
312659
|
+
numerator: item.numerator ?? 1,
|
|
312660
|
+
denominator: item.denominator ?? 1,
|
|
312661
|
+
offset: item.offset,
|
|
312662
|
+
});
|
|
312663
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
312664
|
+
return defConv.compose(selfConv);
|
|
312665
|
+
}
|
|
312666
|
+
/** Parse and resolve a compound definition string like `[MILLI]*M` or `IN`. */
|
|
312667
|
+
_resolveDefinition(definition, depth) {
|
|
312668
|
+
const fragments = (0,_Parser__WEBPACK_IMPORTED_MODULE_2__.parseDefinition)(definition);
|
|
312669
|
+
let result;
|
|
312670
|
+
for (const [, fragment] of fragments) {
|
|
312671
|
+
// Strip alias prefix if present (definitions in the schema use unqualified names)
|
|
312672
|
+
const fragName = (0,_nameUtils__WEBPACK_IMPORTED_MODULE_3__.stripAliasPrefix)(fragment.name);
|
|
312673
|
+
const fragConv = this._resolveUnit(fragName, depth + 1);
|
|
312674
|
+
const raised = fragConv.raise(fragment.exponent);
|
|
312675
|
+
result = result ? result.multiply(raised) : raised;
|
|
312676
|
+
}
|
|
312677
|
+
return result ?? _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312678
|
+
}
|
|
312679
|
+
}
|
|
312680
|
+
|
|
312681
|
+
|
|
312682
|
+
/***/ }),
|
|
312683
|
+
|
|
312684
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js":
|
|
312685
|
+
/*!***************************************************************!*\
|
|
312686
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/nameUtils.js ***!
|
|
312687
|
+
\***************************************************************/
|
|
312688
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312689
|
+
|
|
312690
|
+
"use strict";
|
|
312691
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312692
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312693
|
+
/* harmony export */ qualifyItemName: () => (/* binding */ qualifyItemName),
|
|
312694
|
+
/* harmony export */ stripAliasPrefix: () => (/* binding */ stripAliasPrefix)
|
|
312695
|
+
/* harmony export */ });
|
|
312696
|
+
/*---------------------------------------------------------------------------------------------
|
|
312697
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312698
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312699
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312700
|
+
/** Strips alias prefix from a schema item reference.
|
|
312701
|
+
* `"u:FT"` → `"FT"`, `"FT"` → `"FT"`.
|
|
312702
|
+
* @internal
|
|
312703
|
+
*/
|
|
312704
|
+
function stripAliasPrefix(raw) {
|
|
312705
|
+
return raw.includes(":") ? raw.split(":")[1] : raw;
|
|
312706
|
+
}
|
|
312707
|
+
/** Normalizes a schema item reference to fully-qualified `SchemaName.ItemName` format.
|
|
312708
|
+
* Handles: already qualified (`"Units.FT"`), alias-qualified (`"u:FT"`), unqualified (`"FT"`).
|
|
312709
|
+
* @internal
|
|
312710
|
+
*/
|
|
312711
|
+
function qualifyItemName(raw, schemaName) {
|
|
312712
|
+
if (raw.includes("."))
|
|
312713
|
+
return raw;
|
|
312714
|
+
return `${schemaName}.${stripAliasPrefix(raw)}`;
|
|
312715
|
+
}
|
|
312716
|
+
|
|
312717
|
+
|
|
312256
312718
|
/***/ }),
|
|
312257
312719
|
|
|
312258
312720
|
/***/ "../../core/quantity/lib/esm/core-quantity.js":
|
|
@@ -312267,6 +312729,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312267
312729
|
/* harmony export */ BadUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BadUnit),
|
|
312268
312730
|
/* harmony export */ BaseFormat: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.BaseFormat),
|
|
312269
312731
|
/* harmony export */ BasicUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BasicUnit),
|
|
312732
|
+
/* harmony export */ BasicUnitsProvider: () => (/* reexport safe */ _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__.BasicUnitsProvider),
|
|
312270
312733
|
/* harmony export */ DecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.DecimalPrecision),
|
|
312271
312734
|
/* harmony export */ Format: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.Format),
|
|
312272
312735
|
/* harmony export */ FormatSpecHandle: () => (/* reexport safe */ _FormatSpecHandle__WEBPACK_IMPORTED_MODULE_2__.FormatSpecHandle),
|
|
@@ -312286,12 +312749,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312286
312749
|
/* harmony export */ QuantityStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus),
|
|
312287
312750
|
/* harmony export */ RatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioFormatType),
|
|
312288
312751
|
/* harmony export */ RatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioType),
|
|
312752
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* reexport safe */ _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__.SERIALIZED_UNIT_SCHEMA_VERSION),
|
|
312289
312753
|
/* harmony export */ ScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ScientificType),
|
|
312290
312754
|
/* harmony export */ ShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ShowSignOption),
|
|
312755
|
+
/* harmony export */ UnitConversion: () => (/* reexport safe */ _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__.UnitConversion),
|
|
312756
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.UnitConversionGraph),
|
|
312291
312757
|
/* harmony export */ UnitConversionInvert: () => (/* reexport safe */ _Interfaces__WEBPACK_IMPORTED_MODULE_3__.UnitConversionInvert),
|
|
312758
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* reexport safe */ _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__.UnitDefinitionResolver),
|
|
312292
312759
|
/* harmony export */ almostEqual: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostEqual),
|
|
312293
312760
|
/* harmony export */ almostZero: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostZero),
|
|
312294
312761
|
/* harmony export */ applyConversion: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.applyConversion),
|
|
312762
|
+
/* harmony export */ createUnitsProvider: () => (/* reexport safe */ _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__.createUnitsProvider),
|
|
312295
312763
|
/* harmony export */ formatStringRgx: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatStringRgx),
|
|
312296
312764
|
/* harmony export */ formatTraitsToArray: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTraitsToArray),
|
|
312297
312765
|
/* harmony export */ formatTypeToString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTypeToString),
|
|
@@ -312299,6 +312767,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312299
312767
|
/* harmony export */ getTraitString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.getTraitString),
|
|
312300
312768
|
/* harmony export */ isCustomFormatProps: () => (/* reexport safe */ _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__.isCustomFormatProps),
|
|
312301
312769
|
/* harmony export */ parseDecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseDecimalPrecision),
|
|
312770
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.parseDefinition),
|
|
312302
312771
|
/* harmony export */ parseFormatTrait: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatTrait),
|
|
312303
312772
|
/* harmony export */ parseFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatType),
|
|
312304
312773
|
/* harmony export */ parseFractionalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFractionalPrecision),
|
|
@@ -312325,6 +312794,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312325
312794
|
/* harmony import */ var _Formatter_FormattingReadyCollector__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Formatter/FormattingReadyCollector */ "../../core/quantity/lib/esm/Formatter/FormattingReadyCollector.js");
|
|
312326
312795
|
/* harmony import */ var _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Formatter/Interfaces */ "../../core/quantity/lib/esm/Formatter/Interfaces.js");
|
|
312327
312796
|
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
312797
|
+
/* harmony import */ var _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./UnitConversion/UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
312798
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
312799
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
312800
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
312801
|
+
/* harmony import */ var _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./CompositeUnitsProvider */ "../../core/quantity/lib/esm/CompositeUnitsProvider.js");
|
|
312802
|
+
/* harmony import */ var _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./internal/cross-package */ "../../core/quantity/lib/esm/internal/cross-package.js");
|
|
312328
312803
|
/*---------------------------------------------------------------------------------------------
|
|
312329
312804
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312330
312805
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -312343,20 +312818,59 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312343
312818
|
|
|
312344
312819
|
|
|
312345
312820
|
|
|
312821
|
+
|
|
312822
|
+
|
|
312823
|
+
|
|
312824
|
+
|
|
312825
|
+
|
|
312826
|
+
|
|
312346
312827
|
|
|
312347
312828
|
/** @docs-package-description
|
|
312348
|
-
* The core-quantity package
|
|
312829
|
+
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
312349
312830
|
*/
|
|
312350
312831
|
/**
|
|
312351
312832
|
* @docs-group-description Quantity
|
|
312352
312833
|
* Classes, Interfaces, and definitions used to format and parse quantity values.
|
|
312353
312834
|
*/
|
|
312835
|
+
/**
|
|
312836
|
+
* @docs-group-description BasicUnitsProvider
|
|
312837
|
+
* A UnitsProvider backed by the bundled BIS Units schema JSON asset.
|
|
312838
|
+
*/
|
|
312839
|
+
/**
|
|
312840
|
+
* @docs-group-description CompositeUnitsProvider
|
|
312841
|
+
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
312842
|
+
*/
|
|
312354
312843
|
/**
|
|
312355
312844
|
* @docs-group-description Logging
|
|
312356
312845
|
* Logger categories used by this package.
|
|
312357
312846
|
*/
|
|
312358
312847
|
|
|
312359
312848
|
|
|
312849
|
+
/***/ }),
|
|
312850
|
+
|
|
312851
|
+
/***/ "../../core/quantity/lib/esm/internal/cross-package.js":
|
|
312852
|
+
/*!*************************************************************!*\
|
|
312853
|
+
!*** ../../core/quantity/lib/esm/internal/cross-package.js ***!
|
|
312854
|
+
\*************************************************************/
|
|
312855
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312856
|
+
|
|
312857
|
+
"use strict";
|
|
312858
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312859
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312860
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__.UnitConversionGraph),
|
|
312861
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__.parseDefinition)
|
|
312862
|
+
/* harmony export */ });
|
|
312863
|
+
/* harmony import */ var _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../UnitConversion/Graph */ "../../core/quantity/lib/esm/UnitConversion/Graph.js");
|
|
312864
|
+
/* harmony import */ var _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../UnitConversion/Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
312865
|
+
/*---------------------------------------------------------------------------------------------
|
|
312866
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312867
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312868
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312869
|
+
// Used by ecschema-metadata (UnitTree.ts)
|
|
312870
|
+
|
|
312871
|
+
|
|
312872
|
+
|
|
312873
|
+
|
|
312360
312874
|
/***/ }),
|
|
312361
312875
|
|
|
312362
312876
|
/***/ "../../core/webgl-compatibility/lib/esm/Capabilities.js":
|
|
@@ -326399,7 +326913,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
326399
326913
|
/***/ ((module) => {
|
|
326400
326914
|
|
|
326401
326915
|
"use strict";
|
|
326402
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.9.0-dev.
|
|
326916
|
+
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"}}');
|
|
326403
326917
|
|
|
326404
326918
|
/***/ })
|
|
326405
326919
|
|