@itwin/ecschema-rpcinterface-tests 5.10.0-dev.1 → 5.10.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dist/bundled-tests.js +1042 -525
- package/lib/dist/bundled-tests.js.map +1 -1
- package/lib/dist/core_frontend_lib_esm_ApproximateTerrainHeightsProps_js.bundled-tests.js.map +1 -1
- package/lib/dist/core_quantity_lib_esm_assets_Units_json.bundled-tests.js +14 -0
- package/lib/dist/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9.bundled-tests.js.map +1 -1
- package/package.json +16 -16
|
@@ -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.
|
|
@@ -308819,6 +308446,362 @@ class UrlFS extends _FileStorage__WEBPACK_IMPORTED_MODULE_6__.FileStorage {
|
|
|
308819
308446
|
}
|
|
308820
308447
|
|
|
308821
308448
|
|
|
308449
|
+
/***/ }),
|
|
308450
|
+
|
|
308451
|
+
/***/ "../../core/quantity/lib/esm/BasicUnitsProvider.js":
|
|
308452
|
+
/*!*********************************************************!*\
|
|
308453
|
+
!*** ../../core/quantity/lib/esm/BasicUnitsProvider.js ***!
|
|
308454
|
+
\*********************************************************/
|
|
308455
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
308456
|
+
|
|
308457
|
+
"use strict";
|
|
308458
|
+
__webpack_require__.r(__webpack_exports__);
|
|
308459
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
308460
|
+
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
308461
|
+
/* harmony export */ _testResetUnitsCache: () => (/* binding */ _testResetUnitsCache)
|
|
308462
|
+
/* harmony export */ });
|
|
308463
|
+
/* harmony import */ var _Interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Interfaces */ "../../core/quantity/lib/esm/Interfaces.js");
|
|
308464
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
308465
|
+
/* harmony import */ var _UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./UnitConversion/nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
308466
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
308467
|
+
/*---------------------------------------------------------------------------------------------
|
|
308468
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
308469
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
308470
|
+
*--------------------------------------------------------------------------------------------*/
|
|
308471
|
+
|
|
308472
|
+
|
|
308473
|
+
|
|
308474
|
+
|
|
308475
|
+
// Module-level cache: the unit data is derived deterministically from the bundled Units.json
|
|
308476
|
+
// asset, so the resolved indexes are effectively an immutable constant. Caching at module
|
|
308477
|
+
// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.
|
|
308478
|
+
// in tests or when composed inside CompositeUnitsProvider).
|
|
308479
|
+
// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint
|
|
308480
|
+
// near-zero until a provider method is actually called.
|
|
308481
|
+
let _resolvePromise;
|
|
308482
|
+
let _permanentError;
|
|
308483
|
+
async function resolveState() {
|
|
308484
|
+
if (_permanentError !== undefined) {
|
|
308485
|
+
throw _permanentError;
|
|
308486
|
+
}
|
|
308487
|
+
if (!_resolvePromise) {
|
|
308488
|
+
_resolvePromise = _buildState().catch((err) => {
|
|
308489
|
+
_permanentError = err instanceof Error ? err : new Error(String(err));
|
|
308490
|
+
_resolvePromise = undefined;
|
|
308491
|
+
throw _permanentError;
|
|
308492
|
+
});
|
|
308493
|
+
}
|
|
308494
|
+
return _resolvePromise;
|
|
308495
|
+
}
|
|
308496
|
+
/** @internal — test use only. Resets the module-level lazy cache. */
|
|
308497
|
+
function _testResetUnitsCache() {
|
|
308498
|
+
_resolvePromise = undefined;
|
|
308499
|
+
_permanentError = undefined;
|
|
308500
|
+
}
|
|
308501
|
+
async function _buildState() {
|
|
308502
|
+
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));
|
|
308503
|
+
const nameMap = new Map();
|
|
308504
|
+
const labelMap = new Map();
|
|
308505
|
+
const phenomenonMap = new Map();
|
|
308506
|
+
const invertedUnits = new Map();
|
|
308507
|
+
const s = schema;
|
|
308508
|
+
const resolver = new _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__.UnitDefinitionResolver(s);
|
|
308509
|
+
const resolved = resolver.resolveAll();
|
|
308510
|
+
for (const [name, entry] of resolved) {
|
|
308511
|
+
const item = s.items[name];
|
|
308512
|
+
const phenomenon = item.phenomenon;
|
|
308513
|
+
const unitSystem = item.unitSystem;
|
|
308514
|
+
const fullName = `${s.name}.${name}`;
|
|
308515
|
+
const props = {
|
|
308516
|
+
name: fullName,
|
|
308517
|
+
label: entry.label,
|
|
308518
|
+
phenomenon,
|
|
308519
|
+
isValid: true,
|
|
308520
|
+
system: unitSystem,
|
|
308521
|
+
};
|
|
308522
|
+
const indexed = { props, resolved: entry };
|
|
308523
|
+
nameMap.set(fullName, indexed);
|
|
308524
|
+
const lowerLabel = entry.label.toLowerCase();
|
|
308525
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
308526
|
+
byLabel.push(indexed);
|
|
308527
|
+
labelMap.set(lowerLabel, byLabel);
|
|
308528
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
308529
|
+
byPhen.push(indexed);
|
|
308530
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
308531
|
+
}
|
|
308532
|
+
// Handle InvertedUnit items — must run after nameMap is fully populated above because
|
|
308533
|
+
// invertedSource lookup requires the inverted unit's target to already be in nameMap.
|
|
308534
|
+
for (const [name, item] of Object.entries(s.items)) {
|
|
308535
|
+
if (item.schemaItemType !== "InvertedUnit") {
|
|
308536
|
+
continue;
|
|
308537
|
+
}
|
|
308538
|
+
const inv = item;
|
|
308539
|
+
const fullName = `${s.name}.${name}`;
|
|
308540
|
+
const invertsName = (0,_UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__.qualifyItemName)(inv.invertsUnit, s.name);
|
|
308541
|
+
const unitSystem = inv.unitSystem;
|
|
308542
|
+
const invertedSource = nameMap.get(invertsName);
|
|
308543
|
+
const phenomenon = invertedSource?.props.phenomenon ?? "";
|
|
308544
|
+
const props = {
|
|
308545
|
+
name: fullName,
|
|
308546
|
+
label: inv.label ?? name,
|
|
308547
|
+
phenomenon,
|
|
308548
|
+
isValid: true,
|
|
308549
|
+
system: unitSystem,
|
|
308550
|
+
};
|
|
308551
|
+
invertedUnits.set(fullName, { props, invertsUnitName: invertsName });
|
|
308552
|
+
if (invertedSource) {
|
|
308553
|
+
const indexed = {
|
|
308554
|
+
props,
|
|
308555
|
+
resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },
|
|
308556
|
+
};
|
|
308557
|
+
nameMap.set(fullName, indexed);
|
|
308558
|
+
const lowerLabel = props.label.toLowerCase();
|
|
308559
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
308560
|
+
byLabel.push(indexed);
|
|
308561
|
+
labelMap.set(lowerLabel, byLabel);
|
|
308562
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
308563
|
+
byPhen.push(indexed);
|
|
308564
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
308565
|
+
}
|
|
308566
|
+
}
|
|
308567
|
+
return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };
|
|
308568
|
+
}
|
|
308569
|
+
/**
|
|
308570
|
+
* A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.
|
|
308571
|
+
*
|
|
308572
|
+
* The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method
|
|
308573
|
+
* call and cached at module scope — construction is essentially free, and multiple instances
|
|
308574
|
+
* share the same immutable lookup indexes.
|
|
308575
|
+
*
|
|
308576
|
+
* This is the zero-dependency default for backends, tools, and any frontend that doesn't need
|
|
308577
|
+
* iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.
|
|
308578
|
+
*
|
|
308579
|
+
* @see createUnitsProvider for layering schema-defined units on top of basic BIS units.
|
|
308580
|
+
* @beta
|
|
308581
|
+
*/
|
|
308582
|
+
class BasicUnitsProvider {
|
|
308583
|
+
// ── UnitsProvider implementation ─────────────────────────────────────
|
|
308584
|
+
/** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.
|
|
308585
|
+
* @param unitLabel - The display label to search for (case-insensitive).
|
|
308586
|
+
* @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `"Units"`.
|
|
308587
|
+
* @param phenomenon - Optional phenomenon filter (e.g. `"Units.LENGTH"`).
|
|
308588
|
+
* @param unitSystem - Optional unit system filter (e.g. `"Units.METRIC"`).
|
|
308589
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if no match is found.
|
|
308590
|
+
*/
|
|
308591
|
+
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
308592
|
+
const state = await resolveState();
|
|
308593
|
+
if (schemaName && schemaName !== state.schemaName) {
|
|
308594
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308595
|
+
}
|
|
308596
|
+
const candidates = state.labelMap.get(unitLabel.toLowerCase());
|
|
308597
|
+
if (!candidates || candidates.length === 0) {
|
|
308598
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308599
|
+
}
|
|
308600
|
+
for (const c of candidates) {
|
|
308601
|
+
if (phenomenon && c.props.phenomenon !== phenomenon) {
|
|
308602
|
+
continue;
|
|
308603
|
+
}
|
|
308604
|
+
if (unitSystem && c.props.system !== unitSystem) {
|
|
308605
|
+
continue;
|
|
308606
|
+
}
|
|
308607
|
+
return c.props;
|
|
308608
|
+
}
|
|
308609
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308610
|
+
}
|
|
308611
|
+
/** Return all units belonging to the given phenomenon (unit family).
|
|
308612
|
+
* @param phenomenon - The phenomenon full name (e.g. `"Units.LENGTH"`).
|
|
308613
|
+
* @returns An array of matching `UnitProps`, or an empty array if none.
|
|
308614
|
+
*/
|
|
308615
|
+
async getUnitsByFamily(phenomenon) {
|
|
308616
|
+
const state = await resolveState();
|
|
308617
|
+
const entries = state.phenomenonMap.get(phenomenon);
|
|
308618
|
+
return entries ? entries.map((e) => e.props) : [];
|
|
308619
|
+
}
|
|
308620
|
+
/** Find a unit by its fully-qualified name (e.g. `"Units.M"`).
|
|
308621
|
+
* @param unitName - The qualified unit name.
|
|
308622
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if not found.
|
|
308623
|
+
*/
|
|
308624
|
+
async findUnitByName(unitName) {
|
|
308625
|
+
const state = await resolveState();
|
|
308626
|
+
const entry = state.nameMap.get(unitName);
|
|
308627
|
+
return entry ? entry.props : new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
308628
|
+
}
|
|
308629
|
+
/** Compute the conversion factors from `fromUnit` to `toUnit`.
|
|
308630
|
+
* Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.
|
|
308631
|
+
* @param fromUnit - The source unit.
|
|
308632
|
+
* @param toUnit - The target unit.
|
|
308633
|
+
* @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.
|
|
308634
|
+
*/
|
|
308635
|
+
async getConversion(fromUnit, toUnit) {
|
|
308636
|
+
const state = await resolveState();
|
|
308637
|
+
const from = state.nameMap.get(fromUnit.name);
|
|
308638
|
+
const to = state.nameMap.get(toUnit.name);
|
|
308639
|
+
if (!from || !to) {
|
|
308640
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308641
|
+
}
|
|
308642
|
+
const fromInverted = state.invertedUnits.get(fromUnit.name);
|
|
308643
|
+
const toInverted = state.invertedUnits.get(toUnit.name);
|
|
308644
|
+
const fromPhenomenon = fromInverted
|
|
308645
|
+
? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon
|
|
308646
|
+
: from.props.phenomenon;
|
|
308647
|
+
const toPhenomenon = toInverted
|
|
308648
|
+
? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon
|
|
308649
|
+
: to.props.phenomenon;
|
|
308650
|
+
if (fromPhenomenon !== toPhenomenon) {
|
|
308651
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308652
|
+
}
|
|
308653
|
+
if (fromInverted && toInverted) {
|
|
308654
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
308655
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
308656
|
+
if (innerFrom && innerTo) {
|
|
308657
|
+
const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
308658
|
+
return { factor: c.factor, offset: c.offset };
|
|
308659
|
+
}
|
|
308660
|
+
}
|
|
308661
|
+
if (fromInverted) {
|
|
308662
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
308663
|
+
if (innerFrom) {
|
|
308664
|
+
const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
308665
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPreConversion };
|
|
308666
|
+
}
|
|
308667
|
+
}
|
|
308668
|
+
if (toInverted) {
|
|
308669
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
308670
|
+
if (innerTo) {
|
|
308671
|
+
const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
308672
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPostConversion };
|
|
308673
|
+
}
|
|
308674
|
+
}
|
|
308675
|
+
const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
308676
|
+
return { factor: conv.factor, offset: conv.offset };
|
|
308677
|
+
}
|
|
308678
|
+
}
|
|
308679
|
+
|
|
308680
|
+
|
|
308681
|
+
/***/ }),
|
|
308682
|
+
|
|
308683
|
+
/***/ "../../core/quantity/lib/esm/CompositeUnitsProvider.js":
|
|
308684
|
+
/*!*************************************************************!*\
|
|
308685
|
+
!*** ../../core/quantity/lib/esm/CompositeUnitsProvider.js ***!
|
|
308686
|
+
\*************************************************************/
|
|
308687
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
308688
|
+
|
|
308689
|
+
"use strict";
|
|
308690
|
+
__webpack_require__.r(__webpack_exports__);
|
|
308691
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
308692
|
+
/* harmony export */ createUnitsProvider: () => (/* binding */ createUnitsProvider)
|
|
308693
|
+
/* harmony export */ });
|
|
308694
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
308695
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
308696
|
+
/*---------------------------------------------------------------------------------------------
|
|
308697
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
308698
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
308699
|
+
*--------------------------------------------------------------------------------------------*/
|
|
308700
|
+
|
|
308701
|
+
|
|
308702
|
+
/**
|
|
308703
|
+
* Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional
|
|
308704
|
+
* `primary` provider. Typical use: layer an iModel's schema units on top of the bundled
|
|
308705
|
+
* defaults from `@itwin/core-quantity`.
|
|
308706
|
+
*
|
|
308707
|
+
* Precedence rules:
|
|
308708
|
+
* - When `primary` is supplied and `bisUnitsPolicy` is `"preferSchema"` (the default): `primary` wins;
|
|
308709
|
+
* basic BIS units fill any gaps where `primary` returns an invalid unit or throws.
|
|
308710
|
+
* - When `bisUnitsPolicy` is `"preferBundled"`: basic BIS units win; `primary` is consulted only when the
|
|
308711
|
+
* basic provider can't answer.
|
|
308712
|
+
* - `getUnitsByFamily` always merges results from both providers, deduplicated by
|
|
308713
|
+
* `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.
|
|
308714
|
+
* - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`
|
|
308715
|
+
* (no wrapper), preserving `instanceof` checks and keeping the hot path fast.
|
|
308716
|
+
*
|
|
308717
|
+
* @beta
|
|
308718
|
+
*/
|
|
308719
|
+
function createUnitsProvider(options = {}) {
|
|
308720
|
+
const basic = new _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__.BasicUnitsProvider();
|
|
308721
|
+
const primary = options.primary;
|
|
308722
|
+
// NOTE: returns BasicUnitsProvider directly when no primary is provided.
|
|
308723
|
+
// QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.
|
|
308724
|
+
// If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.
|
|
308725
|
+
if (!primary) {
|
|
308726
|
+
return basic;
|
|
308727
|
+
}
|
|
308728
|
+
const providers = options.bisUnitsPolicy === "preferBundled" ? [basic, primary] : [primary, basic];
|
|
308729
|
+
return new CompositeUnitsProvider(providers);
|
|
308730
|
+
}
|
|
308731
|
+
class CompositeUnitsProvider {
|
|
308732
|
+
_providers;
|
|
308733
|
+
constructor(_providers) {
|
|
308734
|
+
this._providers = _providers;
|
|
308735
|
+
}
|
|
308736
|
+
async findUnit(label, schemaName, phenomenon, unitSystem) {
|
|
308737
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308738
|
+
const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));
|
|
308739
|
+
if (hit?.isValid) {
|
|
308740
|
+
return hit;
|
|
308741
|
+
}
|
|
308742
|
+
}
|
|
308743
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
308744
|
+
}
|
|
308745
|
+
async findUnitByName(name) {
|
|
308746
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308747
|
+
const hit = await tryFind(async () => this._providers[i].findUnitByName(name));
|
|
308748
|
+
if (hit?.isValid) {
|
|
308749
|
+
return hit;
|
|
308750
|
+
}
|
|
308751
|
+
}
|
|
308752
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
308753
|
+
}
|
|
308754
|
+
async getUnitsByFamily(phenomenon) {
|
|
308755
|
+
const seen = new Set();
|
|
308756
|
+
const out = [];
|
|
308757
|
+
// Query all providers in parallel; process results in declaration order to honour precedence.
|
|
308758
|
+
const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));
|
|
308759
|
+
for (const units of results) {
|
|
308760
|
+
for (const u of units) {
|
|
308761
|
+
if (!seen.has(u.name)) {
|
|
308762
|
+
seen.add(u.name);
|
|
308763
|
+
out.push(u);
|
|
308764
|
+
}
|
|
308765
|
+
}
|
|
308766
|
+
}
|
|
308767
|
+
return out;
|
|
308768
|
+
}
|
|
308769
|
+
async getConversion(from, to) {
|
|
308770
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
308771
|
+
try {
|
|
308772
|
+
const result = await this._providers[i].getConversion(from, to);
|
|
308773
|
+
if (!result.error) {
|
|
308774
|
+
return result;
|
|
308775
|
+
}
|
|
308776
|
+
}
|
|
308777
|
+
catch { /* fall through to next provider */ }
|
|
308778
|
+
}
|
|
308779
|
+
try {
|
|
308780
|
+
return await this._providers[this._providers.length - 1].getConversion(from, to);
|
|
308781
|
+
}
|
|
308782
|
+
catch {
|
|
308783
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
308784
|
+
}
|
|
308785
|
+
}
|
|
308786
|
+
}
|
|
308787
|
+
async function tryFind(fn) {
|
|
308788
|
+
try {
|
|
308789
|
+
return await fn();
|
|
308790
|
+
}
|
|
308791
|
+
catch {
|
|
308792
|
+
return undefined;
|
|
308793
|
+
}
|
|
308794
|
+
}
|
|
308795
|
+
async function tryList(fn) {
|
|
308796
|
+
try {
|
|
308797
|
+
return await fn();
|
|
308798
|
+
}
|
|
308799
|
+
catch {
|
|
308800
|
+
return [];
|
|
308801
|
+
}
|
|
308802
|
+
}
|
|
308803
|
+
|
|
308804
|
+
|
|
308822
308805
|
/***/ }),
|
|
308823
308806
|
|
|
308824
308807
|
/***/ "../../core/quantity/lib/esm/Constants.js":
|
|
@@ -310615,8 +310598,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310615
310598
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
310616
310599
|
/* harmony export */ FormatterSpec: () => (/* binding */ FormatterSpec)
|
|
310617
310600
|
/* harmony export */ });
|
|
310618
|
-
/* harmony import */ var
|
|
310619
|
-
/* harmony import */ var
|
|
310601
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
310602
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
310603
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
310604
|
+
/* harmony import */ var _Formatter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter */ "../../core/quantity/lib/esm/Formatter/Formatter.js");
|
|
310620
310605
|
/*---------------------------------------------------------------------------------------------
|
|
310621
310606
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
310622
310607
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -310626,6 +310611,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310626
310611
|
*/
|
|
310627
310612
|
|
|
310628
310613
|
|
|
310614
|
+
|
|
310615
|
+
|
|
310629
310616
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
310630
310617
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
310631
310618
|
/** 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.
|
|
@@ -310679,6 +310666,9 @@ class FormatterSpec {
|
|
|
310679
310666
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
310680
310667
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
310681
310668
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
310669
|
+
if (denominatorToNumerator.error) {
|
|
310670
|
+
_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.`);
|
|
310671
|
+
}
|
|
310682
310672
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
310683
310673
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
310684
310674
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -310729,7 +310719,7 @@ class FormatterSpec {
|
|
|
310729
310719
|
}
|
|
310730
310720
|
}
|
|
310731
310721
|
// Handle 2-unit composite for ratio formats (scale factors)
|
|
310732
|
-
if (format.type ===
|
|
310722
|
+
if (format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
310733
310723
|
return FormatterSpec.getRatioUnitConversions(format.units, unitsProvider, persistenceUnit);
|
|
310734
310724
|
}
|
|
310735
310725
|
if (format.units) {
|
|
@@ -310738,6 +310728,9 @@ class FormatterSpec {
|
|
|
310738
310728
|
let unitConversion;
|
|
310739
310729
|
if (convertFromUnit) {
|
|
310740
310730
|
unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
|
|
310731
|
+
if (unitConversion.error) {
|
|
310732
|
+
_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.`);
|
|
310733
|
+
}
|
|
310741
310734
|
}
|
|
310742
310735
|
else {
|
|
310743
310736
|
unitConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310770,6 +310763,9 @@ class FormatterSpec {
|
|
|
310770
310763
|
if (format.azimuthBaseUnit !== undefined) {
|
|
310771
310764
|
if (inputUnit !== undefined) {
|
|
310772
310765
|
azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);
|
|
310766
|
+
if (azimuthBaseConversion.error) {
|
|
310767
|
+
_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.`);
|
|
310768
|
+
}
|
|
310773
310769
|
}
|
|
310774
310770
|
else {
|
|
310775
310771
|
azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310779,6 +310775,9 @@ class FormatterSpec {
|
|
|
310779
310775
|
if (format.revolutionUnit !== undefined) {
|
|
310780
310776
|
if (inputUnit !== undefined) {
|
|
310781
310777
|
revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);
|
|
310778
|
+
if (revolutionConversion.error) {
|
|
310779
|
+
_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.`);
|
|
310780
|
+
}
|
|
310782
310781
|
}
|
|
310783
310782
|
else {
|
|
310784
310783
|
revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -310788,7 +310787,7 @@ class FormatterSpec {
|
|
|
310788
310787
|
}
|
|
310789
310788
|
/** Format a quantity value. */
|
|
310790
310789
|
applyFormatting(magnitude) {
|
|
310791
|
-
return
|
|
310790
|
+
return _Formatter__WEBPACK_IMPORTED_MODULE_3__.Formatter.formatQuantity(magnitude, this);
|
|
310792
310791
|
}
|
|
310793
310792
|
}
|
|
310794
310793
|
|
|
@@ -310923,10 +310922,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310923
310922
|
/* harmony export */ ParseError: () => (/* binding */ ParseError),
|
|
310924
310923
|
/* harmony export */ Parser: () => (/* binding */ Parser)
|
|
310925
310924
|
/* harmony export */ });
|
|
310926
|
-
/* harmony import */ var
|
|
310927
|
-
/* harmony import */ var
|
|
310928
|
-
/* harmony import */ var
|
|
310929
|
-
/* harmony import */ var
|
|
310925
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
310926
|
+
/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants */ "../../core/quantity/lib/esm/Constants.js");
|
|
310927
|
+
/* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Exception */ "../../core/quantity/lib/esm/Exception.js");
|
|
310928
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
310929
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
310930
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
310930
310931
|
/*---------------------------------------------------------------------------------------------
|
|
310931
310932
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
310932
310933
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -310938,6 +310939,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
310938
310939
|
|
|
310939
310940
|
|
|
310940
310941
|
|
|
310942
|
+
|
|
310943
|
+
|
|
310941
310944
|
/** Possible parser errors
|
|
310942
310945
|
* @beta
|
|
310943
310946
|
*/
|
|
@@ -311031,7 +311034,7 @@ class Parser {
|
|
|
311031
311034
|
let i = index + 1;
|
|
311032
311035
|
for (; i < stringToParse.length; i++) {
|
|
311033
311036
|
const charCode = stringToParse.charCodeAt(i);
|
|
311034
|
-
if (Parser.isDigit(charCode) || ((charCode ===
|
|
311037
|
+
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)))) {
|
|
311035
311038
|
exponentString = exponentString.concat(stringToParse[i]);
|
|
311036
311039
|
}
|
|
311037
311040
|
else {
|
|
@@ -311039,7 +311042,7 @@ class Parser {
|
|
|
311039
311042
|
break;
|
|
311040
311043
|
}
|
|
311041
311044
|
}
|
|
311042
|
-
if (exponentString.length > 1 || ((exponentString.length === 1) && (exponentString.charCodeAt(0) !==
|
|
311045
|
+
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)))
|
|
311043
311046
|
return new ScientificToken(i, exponentString);
|
|
311044
311047
|
return new ScientificToken(index);
|
|
311045
311048
|
}
|
|
@@ -311063,7 +311066,7 @@ class Parser {
|
|
|
311063
311066
|
}
|
|
311064
311067
|
}
|
|
311065
311068
|
else {
|
|
311066
|
-
if (processingNumerator && (charCode ===
|
|
311069
|
+
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)) {
|
|
311067
311070
|
processingNumerator = false;
|
|
311068
311071
|
}
|
|
311069
311072
|
else {
|
|
@@ -311083,7 +311086,7 @@ class Parser {
|
|
|
311083
311086
|
return new FractionToken(index + 1);
|
|
311084
311087
|
}
|
|
311085
311088
|
static isDigit(charCode) {
|
|
311086
|
-
return (charCode >=
|
|
311089
|
+
return (charCode >= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_ZERO) && (charCode <= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_NINE);
|
|
311087
311090
|
}
|
|
311088
311091
|
static isDigitOrDecimalSeparator(charCode, format) {
|
|
311089
311092
|
return (charCode === format.decimalSeparator.charCodeAt(0)) || Parser.isDigit(charCode);
|
|
@@ -311101,10 +311104,10 @@ class Parser {
|
|
|
311101
311104
|
let uomSeparatorToIgnore = 0;
|
|
311102
311105
|
let fractionDashCode = 0;
|
|
311103
311106
|
const skipCodes = [format.thousandSeparator.charCodeAt(0)];
|
|
311104
|
-
if (format.type ===
|
|
311107
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && format.stationSeparator && format.stationSeparator.length === 1)
|
|
311105
311108
|
skipCodes.push(format.stationSeparator.charCodeAt(0));
|
|
311106
|
-
if (format.type ===
|
|
311107
|
-
fractionDashCode =
|
|
311109
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && format.hasFormatTraitSet(_Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.FractionDash)) {
|
|
311110
|
+
fractionDashCode = _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS;
|
|
311108
311111
|
}
|
|
311109
311112
|
if (format.uomSeparator && format.uomSeparator !== " " && format.uomSeparator.length === 1) {
|
|
311110
311113
|
uomSeparatorToIgnore = format.uomSeparator.charCodeAt(0);
|
|
@@ -311126,7 +311129,7 @@ class Parser {
|
|
|
311126
311129
|
}
|
|
311127
311130
|
else {
|
|
311128
311131
|
if (processingNumber) {
|
|
311129
|
-
if (charCode ===
|
|
311132
|
+
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) {
|
|
311130
311133
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore, wipToken);
|
|
311131
311134
|
let fraction = fractSymbol.fraction;
|
|
311132
311135
|
i = fractSymbol.index;
|
|
@@ -311144,7 +311147,7 @@ class Parser {
|
|
|
311144
311147
|
}
|
|
311145
311148
|
else {
|
|
311146
311149
|
// a space may signify end of number or start of decimal
|
|
311147
|
-
if (charCode ===
|
|
311150
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE || charCode === fractionDashCode) {
|
|
311148
311151
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore);
|
|
311149
311152
|
let fraction = fractSymbol.fraction;
|
|
311150
311153
|
if (fractSymbol.fraction !== 0.0) {
|
|
@@ -311160,7 +311163,7 @@ class Parser {
|
|
|
311160
311163
|
processingNumber = false;
|
|
311161
311164
|
wipToken = "";
|
|
311162
311165
|
}
|
|
311163
|
-
else if (format.type ===
|
|
311166
|
+
else if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && wipToken.length > 0) {
|
|
311164
311167
|
if (signToken.length > 0) {
|
|
311165
311168
|
wipToken = signToken + wipToken;
|
|
311166
311169
|
signToken = "";
|
|
@@ -311173,7 +311176,7 @@ class Parser {
|
|
|
311173
311176
|
}
|
|
311174
311177
|
else {
|
|
311175
311178
|
// an "E" or "e" may signify scientific notation
|
|
311176
|
-
if (charCode ===
|
|
311179
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_UPPER_E || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_LOWER_E) {
|
|
311177
311180
|
const exponentSymbol = Parser.checkForScientificNotation(i, str, uomSeparatorToIgnore);
|
|
311178
311181
|
i = exponentSymbol.index;
|
|
311179
311182
|
if (exponentSymbol.exponent && exponentSymbol.exponent.length > 0) {
|
|
@@ -311191,7 +311194,7 @@ class Parser {
|
|
|
311191
311194
|
}
|
|
311192
311195
|
}
|
|
311193
311196
|
}
|
|
311194
|
-
if (format.type ===
|
|
311197
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && charCode === format.stationSeparator.charCodeAt(0)) {
|
|
311195
311198
|
if (!isStationSeparatorAdded) {
|
|
311196
311199
|
isStationSeparatorAdded = true;
|
|
311197
311200
|
continue;
|
|
@@ -311217,15 +311220,15 @@ class Parser {
|
|
|
311217
311220
|
else {
|
|
311218
311221
|
// not processing a number
|
|
311219
311222
|
const isCharOperator = isOperator(charCode);
|
|
311220
|
-
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !==
|
|
311223
|
+
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE;
|
|
311221
311224
|
if (isSpacer && i > 0 && i < str.length - 1) {
|
|
311222
311225
|
const prevCharCode = str.charCodeAt(i - 1);
|
|
311223
|
-
if (isCharOperator && prevCharCode !==
|
|
311226
|
+
if (isCharOperator && prevCharCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
311224
311227
|
// ignore spacer if it's not at the start or end, not whitespace, and is not in front of a whitespace
|
|
311225
311228
|
continue;
|
|
311226
311229
|
}
|
|
311227
311230
|
}
|
|
311228
|
-
if (wipToken.length === 0 && charCode ===
|
|
311231
|
+
if (wipToken.length === 0 && charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
311229
311232
|
// Don't add space when the wip token is empty.
|
|
311230
311233
|
continue;
|
|
311231
311234
|
}
|
|
@@ -311317,6 +311320,9 @@ class Parser {
|
|
|
311317
311320
|
else {
|
|
311318
311321
|
// Add new conversion to the list.
|
|
311319
311322
|
const conversion = await unitsProvider.getConversion(unitProps, outUnit);
|
|
311323
|
+
if (conversion.error) {
|
|
311324
|
+
_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.`);
|
|
311325
|
+
}
|
|
311320
311326
|
if (conversion) {
|
|
311321
311327
|
spec = {
|
|
311322
311328
|
conversion,
|
|
@@ -311337,12 +311343,16 @@ class Parser {
|
|
|
311337
311343
|
static async createQuantityFromParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider) {
|
|
311338
311344
|
const unitConversionInfos = await this.getRequiredUnitsConversionsToParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider);
|
|
311339
311345
|
if (unitConversionInfos.outUnit) {
|
|
311340
|
-
const
|
|
311346
|
+
const outUnitConversion = await unitsProvider.getConversion(unitConversionInfos.outUnit, unitConversionInfos.outUnit);
|
|
311347
|
+
if (outUnitConversion.error) {
|
|
311348
|
+
_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.`);
|
|
311349
|
+
}
|
|
311350
|
+
const value = Parser.getQuantityValueFromParseTokens(tokens, format, unitConversionInfos.specs, outUnitConversion);
|
|
311341
311351
|
if (value.ok) {
|
|
311342
|
-
return new
|
|
311352
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(unitConversionInfos.outUnit, value.value);
|
|
311343
311353
|
}
|
|
311344
311354
|
}
|
|
311345
|
-
return new
|
|
311355
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity();
|
|
311346
311356
|
}
|
|
311347
311357
|
/** Async method to generate a Quantity given a string that represents a quantity value and likely a unit label.
|
|
311348
311358
|
* @param inString A string that contains text represent a quantity.
|
|
@@ -311407,7 +311417,7 @@ class Parser {
|
|
|
311407
311417
|
}
|
|
311408
311418
|
// if there were unique unit labels but not matched to any units, throw an error
|
|
311409
311419
|
if (uniqueUnitLabels.length > 0)
|
|
311410
|
-
throw new
|
|
311420
|
+
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.`);
|
|
311411
311421
|
}
|
|
311412
311422
|
return unitConversion;
|
|
311413
311423
|
}
|
|
@@ -311460,10 +311470,10 @@ class Parser {
|
|
|
311460
311470
|
}
|
|
311461
311471
|
catch (e) {
|
|
311462
311472
|
// If we failed to get the default unit conversion, we need to return an error.
|
|
311463
|
-
if (e instanceof
|
|
311473
|
+
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnitLabelSuppliedButNotMatched)
|
|
311464
311474
|
return { ok: false, error: ParseError.UnitLabelSuppliedButNotMatched };
|
|
311465
311475
|
}
|
|
311466
|
-
if (format.type ===
|
|
311476
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && format.units !== undefined && format.units.length > 0) {
|
|
311467
311477
|
const units = format.units;
|
|
311468
311478
|
const desiredNumberOfTokens = units.length;
|
|
311469
311479
|
if (tokens.length < desiredNumberOfTokens && tokens[0].isNumber && desiredNumberOfTokens <= 3) {
|
|
@@ -311523,7 +311533,7 @@ class Parser {
|
|
|
311523
311533
|
}
|
|
311524
311534
|
}
|
|
311525
311535
|
if (conversion) {
|
|
311526
|
-
value = (0,
|
|
311536
|
+
value = (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(value, conversion);
|
|
311527
311537
|
}
|
|
311528
311538
|
mag = mag + value;
|
|
311529
311539
|
compositeUnitIndex++;
|
|
@@ -311556,13 +311566,13 @@ class Parser {
|
|
|
311556
311566
|
}
|
|
311557
311567
|
});
|
|
311558
311568
|
}
|
|
311559
|
-
if (parserSpec.format.type ===
|
|
311569
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing) {
|
|
311560
311570
|
return this.parseBearingFormat(inString, parserSpec);
|
|
311561
311571
|
}
|
|
311562
|
-
if (parserSpec.format.type ===
|
|
311572
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
311563
311573
|
return this.parseAzimuthFormat(inString, parserSpec);
|
|
311564
311574
|
}
|
|
311565
|
-
if (parserSpec.format.type ===
|
|
311575
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
311566
311576
|
return this.parseRatioFormat(inString, parserSpec);
|
|
311567
311577
|
}
|
|
311568
311578
|
return this.parseAndProcessTokens(inString, parserSpec.format, parserSpec.unitConversions);
|
|
@@ -311588,9 +311598,9 @@ class Parser {
|
|
|
311588
311598
|
}
|
|
311589
311599
|
});
|
|
311590
311600
|
}
|
|
311591
|
-
if (format.type ===
|
|
311601
|
+
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) {
|
|
311592
311602
|
// throw error indicating to call parseQuantityString instead
|
|
311593
|
-
throw new
|
|
311603
|
+
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.`);
|
|
311594
311604
|
}
|
|
311595
311605
|
return this.parseAndProcessTokens(inString, format, unitsConversions);
|
|
311596
311606
|
}
|
|
@@ -311603,7 +311613,7 @@ class Parser {
|
|
|
311603
311613
|
const conversion = this.tryFindUnitConversion(specialDirUnit.label, spec.unitConversions, preferredUnit);
|
|
311604
311614
|
if (!conversion)
|
|
311605
311615
|
return { ok: true, value: mag };
|
|
311606
|
-
return { ok: true, value: (0,
|
|
311616
|
+
return { ok: true, value: (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(mag, conversion) };
|
|
311607
311617
|
}
|
|
311608
311618
|
static parseBearingFormat(inString, spec) {
|
|
311609
311619
|
const specialDirections = {
|
|
@@ -311693,12 +311703,12 @@ class Parser {
|
|
|
311693
311703
|
let azimuthBase = 0.0;
|
|
311694
311704
|
if (spec.format.azimuthBase !== undefined) {
|
|
311695
311705
|
if (spec.azimuthBaseConversion === undefined) {
|
|
311696
|
-
throw new
|
|
311706
|
+
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.`);
|
|
311697
311707
|
}
|
|
311698
|
-
const azBaseQuantity = new
|
|
311708
|
+
const azBaseQuantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);
|
|
311699
311709
|
const azBaseConverted = azBaseQuantity.convertTo(spec.outUnit, spec.azimuthBaseConversion);
|
|
311700
311710
|
if (!azBaseConverted.isValid) {
|
|
311701
|
-
throw new
|
|
311711
|
+
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}.`);
|
|
311702
311712
|
}
|
|
311703
311713
|
azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);
|
|
311704
311714
|
}
|
|
@@ -311730,7 +311740,7 @@ class Parser {
|
|
|
311730
311740
|
static parseRatioPart(partStr, format) {
|
|
311731
311741
|
partStr = partStr.trim();
|
|
311732
311742
|
// Parse tokens - fractions are automatically converted to decimal values by parseQuantitySpecification
|
|
311733
|
-
const tempFormat = format.clone({ type:
|
|
311743
|
+
const tempFormat = format.clone({ type: _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal });
|
|
311734
311744
|
const tokens = Parser.parseQuantitySpecification(partStr, tempFormat);
|
|
311735
311745
|
let value = NaN;
|
|
311736
311746
|
let unitLabel;
|
|
@@ -311804,7 +311814,7 @@ class Parser {
|
|
|
311804
311814
|
const defaultUnit = spec.format.units && spec.format.units.length > 0 ? spec.format.units[0][0] : undefined;
|
|
311805
311815
|
const unitConversion = defaultUnit ? Parser.tryFindUnitConversion(defaultUnit.label, spec.unitConversions, defaultUnit) : undefined;
|
|
311806
311816
|
if (!unitConversion) {
|
|
311807
|
-
throw new
|
|
311817
|
+
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}.`);
|
|
311808
311818
|
}
|
|
311809
311819
|
if (denominatorPart.value === 0) {
|
|
311810
311820
|
if (unitConversion.inversion && numeratorPart.value === 1)
|
|
@@ -311814,10 +311824,10 @@ class Parser {
|
|
|
311814
311824
|
}
|
|
311815
311825
|
let quantity;
|
|
311816
311826
|
if (spec.format.units && spec.outUnit) {
|
|
311817
|
-
quantity = new
|
|
311827
|
+
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.units[0][0], numeratorPart.value / denominatorPart.value);
|
|
311818
311828
|
}
|
|
311819
311829
|
else {
|
|
311820
|
-
throw new
|
|
311830
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, "Missing presentation unit or persistence unit for ratio format.");
|
|
311821
311831
|
}
|
|
311822
311832
|
let converted;
|
|
311823
311833
|
try {
|
|
@@ -311825,13 +311835,13 @@ class Parser {
|
|
|
311825
311835
|
}
|
|
311826
311836
|
catch (err) {
|
|
311827
311837
|
// for input of "0:N" with reversed unit
|
|
311828
|
-
if (err instanceof
|
|
311838
|
+
if (err instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && err.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.InvertingZero) {
|
|
311829
311839
|
return { ok: false, error: ParseError.InvalidMathResult };
|
|
311830
311840
|
}
|
|
311831
311841
|
throw err;
|
|
311832
311842
|
}
|
|
311833
311843
|
if (!converted.isValid) {
|
|
311834
|
-
throw new
|
|
311844
|
+
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}.`);
|
|
311835
311845
|
}
|
|
311836
311846
|
return { ok: true, value: converted.magnitude };
|
|
311837
311847
|
}
|
|
@@ -311844,12 +311854,12 @@ class Parser {
|
|
|
311844
311854
|
}
|
|
311845
311855
|
static getRevolution(spec) {
|
|
311846
311856
|
if (spec.revolutionConversion === undefined) {
|
|
311847
|
-
throw new
|
|
311857
|
+
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.`);
|
|
311848
311858
|
}
|
|
311849
|
-
const revolution = new
|
|
311859
|
+
const revolution = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.revolutionUnit, 1.0);
|
|
311850
311860
|
const converted = revolution.convertTo(spec.outUnit, spec.revolutionConversion);
|
|
311851
311861
|
if (!converted.isValid) {
|
|
311852
|
-
throw new
|
|
311862
|
+
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}.`);
|
|
311853
311863
|
}
|
|
311854
311864
|
return converted.magnitude;
|
|
311855
311865
|
}
|
|
@@ -311872,6 +311882,9 @@ class Parser {
|
|
|
311872
311882
|
const familyUnits = await unitsProvider.getUnitsByFamily(outUnit.phenomenon);
|
|
311873
311883
|
for (const unit of familyUnits) {
|
|
311874
311884
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
311885
|
+
if (conversion.error) {
|
|
311886
|
+
_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.`);
|
|
311887
|
+
}
|
|
311875
311888
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
311876
311889
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
311877
311890
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -311909,6 +311922,9 @@ class Parser {
|
|
|
311909
311922
|
continue;
|
|
311910
311923
|
}
|
|
311911
311924
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
311925
|
+
if (conversion.error) {
|
|
311926
|
+
_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.`);
|
|
311927
|
+
}
|
|
311912
311928
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
311913
311929
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
311914
311930
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -311953,8 +311969,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
311953
311969
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
311954
311970
|
/* harmony export */ ParserSpec: () => (/* binding */ ParserSpec)
|
|
311955
311971
|
/* harmony export */ });
|
|
311956
|
-
/* harmony import */ var
|
|
311957
|
-
/* harmony import */ var
|
|
311972
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
311973
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
311974
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/Parser.js");
|
|
311975
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
311958
311976
|
/*---------------------------------------------------------------------------------------------
|
|
311959
311977
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
311960
311978
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -311964,6 +311982,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
311964
311982
|
*/
|
|
311965
311983
|
|
|
311966
311984
|
|
|
311985
|
+
|
|
311986
|
+
|
|
311967
311987
|
/** A ParserSpec holds information needed to parse a string into a quantity synchronously.
|
|
311968
311988
|
* @beta
|
|
311969
311989
|
*/
|
|
@@ -311996,6 +312016,9 @@ class ParserSpec {
|
|
|
311996
312016
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
311997
312017
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
311998
312018
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
312019
|
+
if (denominatorToNumerator.error) {
|
|
312020
|
+
_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.`);
|
|
312021
|
+
}
|
|
311999
312022
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
312000
312023
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
312001
312024
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -312044,16 +312067,20 @@ class ParserSpec {
|
|
|
312044
312067
|
static async create(format, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
312045
312068
|
let conversions;
|
|
312046
312069
|
// For ratio formats with 2 composite units, use private helper method
|
|
312047
|
-
if (format.type ===
|
|
312070
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
312048
312071
|
conversions = await ParserSpec.getRatioUnitConversions(format.units, unitsProvider, outUnit, altUnitLabelsProvider);
|
|
312049
312072
|
}
|
|
312050
312073
|
else {
|
|
312051
|
-
conversions = await
|
|
312074
|
+
conversions = await _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.createUnitConversionSpecsForUnit(unitsProvider, outUnit, altUnitLabelsProvider);
|
|
312052
312075
|
}
|
|
312053
312076
|
const spec = new ParserSpec(outUnit, format, conversions);
|
|
312054
312077
|
if (format.azimuthBaseUnit !== undefined) {
|
|
312055
312078
|
if (outUnit !== undefined) {
|
|
312056
|
-
|
|
312079
|
+
const azimuthResult = await unitsProvider.getConversion(format.azimuthBaseUnit, outUnit);
|
|
312080
|
+
if (azimuthResult.error) {
|
|
312081
|
+
_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.`);
|
|
312082
|
+
}
|
|
312083
|
+
spec._azimuthBaseConversion = azimuthResult;
|
|
312057
312084
|
}
|
|
312058
312085
|
else {
|
|
312059
312086
|
spec._azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -312061,7 +312088,11 @@ class ParserSpec {
|
|
|
312061
312088
|
}
|
|
312062
312089
|
if (format.revolutionUnit !== undefined) {
|
|
312063
312090
|
if (outUnit !== undefined) {
|
|
312064
|
-
|
|
312091
|
+
const revolutionResult = await unitsProvider.getConversion(format.revolutionUnit, outUnit);
|
|
312092
|
+
if (revolutionResult.error) {
|
|
312093
|
+
_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.`);
|
|
312094
|
+
}
|
|
312095
|
+
spec._revolutionConversion = revolutionResult;
|
|
312065
312096
|
}
|
|
312066
312097
|
else {
|
|
312067
312098
|
spec._revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -312071,7 +312102,7 @@ class ParserSpec {
|
|
|
312071
312102
|
}
|
|
312072
312103
|
/** Do the parsing. Done this way to allow Custom Parser Specs to parse custom formatted strings into their quantities. */
|
|
312073
312104
|
parseToQuantityValue(inString) {
|
|
312074
|
-
return
|
|
312105
|
+
return _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.parseQuantityString(inString, this);
|
|
312075
312106
|
}
|
|
312076
312107
|
}
|
|
312077
312108
|
|
|
@@ -312218,9 +312249,47 @@ var QuantityLoggerCategory;
|
|
|
312218
312249
|
QuantityLoggerCategory["Package"] = "core-quantity";
|
|
312219
312250
|
/** Logger category for quantity formatting operations. */
|
|
312220
312251
|
QuantityLoggerCategory["Formatting"] = "core-quantity.Formatting";
|
|
312252
|
+
/** Logger category for quantity parsing operations. */
|
|
312253
|
+
QuantityLoggerCategory["Parsing"] = "core-quantity.Parsing";
|
|
312221
312254
|
})(QuantityLoggerCategory || (QuantityLoggerCategory = {}));
|
|
312222
312255
|
|
|
312223
312256
|
|
|
312257
|
+
/***/ }),
|
|
312258
|
+
|
|
312259
|
+
/***/ "../../core/quantity/lib/esm/SerializedUnitSchema.js":
|
|
312260
|
+
/*!***********************************************************!*\
|
|
312261
|
+
!*** ../../core/quantity/lib/esm/SerializedUnitSchema.js ***!
|
|
312262
|
+
\***********************************************************/
|
|
312263
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312264
|
+
|
|
312265
|
+
"use strict";
|
|
312266
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312267
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312268
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* binding */ SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
312269
|
+
/* harmony export */ });
|
|
312270
|
+
/*---------------------------------------------------------------------------------------------
|
|
312271
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312272
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312273
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312274
|
+
/** Current version of the serialization format for `SerializedUnitSchema`.
|
|
312275
|
+
*
|
|
312276
|
+
* This value is written into `Units.json` as the `version` field and checked at
|
|
312277
|
+
* parse time. Two version axes exist:
|
|
312278
|
+
*
|
|
312279
|
+
* - **Format version** (`SERIALIZED_UNIT_SCHEMA_VERSION` / `Units.json.version`): bump
|
|
312280
|
+
* the major version when the shape of the `SerializedUnitSchema` interfaces changes
|
|
312281
|
+
* incompatibly (e.g. renaming fields, removing required properties). Minor bumps for
|
|
312282
|
+
* backward-compatible additions.
|
|
312283
|
+
*
|
|
312284
|
+
* - **Source provenance** (`sourceEcSchemaVersion` inside `Units.json`): records which
|
|
312285
|
+
* version of the BIS Units EC schema the data was derived from (e.g. `"01.00.09"`).
|
|
312286
|
+
* This is a traceability marker, not a runtime contract.
|
|
312287
|
+
*
|
|
312288
|
+
* @internal
|
|
312289
|
+
*/
|
|
312290
|
+
const SERIALIZED_UNIT_SCHEMA_VERSION = "01.00.00";
|
|
312291
|
+
|
|
312292
|
+
|
|
312224
312293
|
/***/ }),
|
|
312225
312294
|
|
|
312226
312295
|
/***/ "../../core/quantity/lib/esm/Unit.js":
|
|
@@ -312274,6 +312343,399 @@ class BadUnit {
|
|
|
312274
312343
|
}
|
|
312275
312344
|
|
|
312276
312345
|
|
|
312346
|
+
/***/ }),
|
|
312347
|
+
|
|
312348
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Graph.js":
|
|
312349
|
+
/*!***********************************************************!*\
|
|
312350
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Graph.js ***!
|
|
312351
|
+
\***********************************************************/
|
|
312352
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312353
|
+
|
|
312354
|
+
"use strict";
|
|
312355
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312356
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312357
|
+
/* harmony export */ UnitConversionGraph: () => (/* binding */ UnitConversionGraph)
|
|
312358
|
+
/* harmony export */ });
|
|
312359
|
+
/*---------------------------------------------------------------------------------------------
|
|
312360
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312361
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312362
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312363
|
+
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
312364
|
+
/** @internal */
|
|
312365
|
+
class UnitConversionGraph {
|
|
312366
|
+
_edgeKeyDelim = "\x01";
|
|
312367
|
+
_label = "";
|
|
312368
|
+
_nodeCount = 0;
|
|
312369
|
+
_edgeCount = 0;
|
|
312370
|
+
_nodes;
|
|
312371
|
+
_edgeObjs;
|
|
312372
|
+
_edgeLabels;
|
|
312373
|
+
_outEdges;
|
|
312374
|
+
constructor() {
|
|
312375
|
+
this._nodes = {};
|
|
312376
|
+
this._edgeObjs = {};
|
|
312377
|
+
this._edgeLabels = {};
|
|
312378
|
+
this._outEdges = {};
|
|
312379
|
+
}
|
|
312380
|
+
setGraph = (label) => {
|
|
312381
|
+
this._label = label;
|
|
312382
|
+
return this;
|
|
312383
|
+
};
|
|
312384
|
+
graph = () => {
|
|
312385
|
+
return this._label;
|
|
312386
|
+
};
|
|
312387
|
+
nodeCount = () => {
|
|
312388
|
+
return this._nodeCount;
|
|
312389
|
+
};
|
|
312390
|
+
nodes = () => {
|
|
312391
|
+
return Object.keys(this._nodes);
|
|
312392
|
+
};
|
|
312393
|
+
setNode = (nodeKey, nodeValue) => {
|
|
312394
|
+
if (nodeKey in this._nodes) {
|
|
312395
|
+
this._nodes[nodeKey] = nodeValue;
|
|
312396
|
+
return;
|
|
312397
|
+
}
|
|
312398
|
+
this._nodes[nodeKey] = nodeValue;
|
|
312399
|
+
this._outEdges[nodeKey] = {};
|
|
312400
|
+
++this._nodeCount;
|
|
312401
|
+
};
|
|
312402
|
+
node = (nodeKey) => {
|
|
312403
|
+
return this._nodes[nodeKey];
|
|
312404
|
+
};
|
|
312405
|
+
hasNode = (nodeKey) => {
|
|
312406
|
+
return nodeKey in this._nodes;
|
|
312407
|
+
};
|
|
312408
|
+
edgeCount = () => {
|
|
312409
|
+
return this._edgeCount;
|
|
312410
|
+
};
|
|
312411
|
+
edges = () => {
|
|
312412
|
+
return Object.values(this._edgeObjs);
|
|
312413
|
+
};
|
|
312414
|
+
setEdge = (v, w, value) => {
|
|
312415
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
312416
|
+
if (edgeId in this._edgeLabels) {
|
|
312417
|
+
// Update exponent, specific to this graph's use case
|
|
312418
|
+
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
312419
|
+
return;
|
|
312420
|
+
}
|
|
312421
|
+
this._edgeLabels[edgeId] = value;
|
|
312422
|
+
const edgeObj = {
|
|
312423
|
+
v,
|
|
312424
|
+
w,
|
|
312425
|
+
};
|
|
312426
|
+
this._edgeObjs[edgeId] = edgeObj;
|
|
312427
|
+
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
312428
|
+
this._outEdges[v][edgeId] = edgeObj;
|
|
312429
|
+
this._edgeCount++;
|
|
312430
|
+
};
|
|
312431
|
+
edge = (v, w) => {
|
|
312432
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
312433
|
+
return this._edgeLabels[edgeId];
|
|
312434
|
+
};
|
|
312435
|
+
outEdges = (v) => {
|
|
312436
|
+
const outV = this._outEdges[v];
|
|
312437
|
+
const edges = Object.values(outV);
|
|
312438
|
+
return edges;
|
|
312439
|
+
};
|
|
312440
|
+
}
|
|
312441
|
+
|
|
312442
|
+
|
|
312443
|
+
/***/ }),
|
|
312444
|
+
|
|
312445
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Parser.js":
|
|
312446
|
+
/*!************************************************************!*\
|
|
312447
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Parser.js ***!
|
|
312448
|
+
\************************************************************/
|
|
312449
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312450
|
+
|
|
312451
|
+
"use strict";
|
|
312452
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312453
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312454
|
+
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
312455
|
+
/* harmony export */ });
|
|
312456
|
+
/*---------------------------------------------------------------------------------------------
|
|
312457
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312458
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312459
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312460
|
+
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
312461
|
+
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
312462
|
+
const sp = "*";
|
|
312463
|
+
/** @internal */
|
|
312464
|
+
var Tokens;
|
|
312465
|
+
(function (Tokens) {
|
|
312466
|
+
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
312467
|
+
Tokens[Tokens["Word"] = 2] = "Word";
|
|
312468
|
+
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
312469
|
+
})(Tokens || (Tokens = {}));
|
|
312470
|
+
/** @internal */
|
|
312471
|
+
function parseDefinition(definition) {
|
|
312472
|
+
const unitMap = new Map();
|
|
312473
|
+
if (expressionRgx.test(definition)) {
|
|
312474
|
+
for (const unit of definition.split(sp)) {
|
|
312475
|
+
const tokens = unit.split(tokenRgx);
|
|
312476
|
+
const name = tokens[Tokens.Word];
|
|
312477
|
+
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
312478
|
+
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
312479
|
+
if (unitMap.has(name)) {
|
|
312480
|
+
const currentDefinition = unitMap.get(name);
|
|
312481
|
+
if (currentDefinition)
|
|
312482
|
+
unitMap.set(name, { ...currentDefinition, exponent: currentDefinition.exponent + exponent });
|
|
312483
|
+
}
|
|
312484
|
+
else {
|
|
312485
|
+
unitMap.set(name, { name, exponent, constant });
|
|
312486
|
+
}
|
|
312487
|
+
}
|
|
312488
|
+
return unitMap;
|
|
312489
|
+
}
|
|
312490
|
+
else {
|
|
312491
|
+
throw new Error("Invalid definition expression.");
|
|
312492
|
+
}
|
|
312493
|
+
}
|
|
312494
|
+
|
|
312495
|
+
|
|
312496
|
+
/***/ }),
|
|
312497
|
+
|
|
312498
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js":
|
|
312499
|
+
/*!********************************************************************!*\
|
|
312500
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
312501
|
+
\********************************************************************/
|
|
312502
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312503
|
+
|
|
312504
|
+
"use strict";
|
|
312505
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312506
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312507
|
+
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
312508
|
+
/* harmony export */ });
|
|
312509
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
312510
|
+
/*---------------------------------------------------------------------------------------------
|
|
312511
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312512
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312513
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312514
|
+
|
|
312515
|
+
/**
|
|
312516
|
+
* Class used for storing calculated conversion between two Units and converting values from one Unit to another.
|
|
312517
|
+
* @internal
|
|
312518
|
+
*/
|
|
312519
|
+
class UnitConversion {
|
|
312520
|
+
factor;
|
|
312521
|
+
offset;
|
|
312522
|
+
constructor(factor = 1.0, offset = 0.0) {
|
|
312523
|
+
this.factor = factor;
|
|
312524
|
+
this.offset = offset;
|
|
312525
|
+
}
|
|
312526
|
+
/**
|
|
312527
|
+
* Converts x using UnitConversion
|
|
312528
|
+
* @param x Input magnitude to be converted
|
|
312529
|
+
* @returns Output magnitude after conversion
|
|
312530
|
+
*/
|
|
312531
|
+
evaluate(x) {
|
|
312532
|
+
return this.factor * x + this.offset;
|
|
312533
|
+
}
|
|
312534
|
+
/**
|
|
312535
|
+
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
312536
|
+
* @internal
|
|
312537
|
+
*/
|
|
312538
|
+
inverse() {
|
|
312539
|
+
const inverseFactor = 1.0 / this.factor;
|
|
312540
|
+
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
312541
|
+
}
|
|
312542
|
+
/**
|
|
312543
|
+
* Combines two UnitConversions
|
|
312544
|
+
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
312545
|
+
* @internal
|
|
312546
|
+
*/
|
|
312547
|
+
compose(conversion) {
|
|
312548
|
+
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
312549
|
+
}
|
|
312550
|
+
/**
|
|
312551
|
+
* Multiples two UnitConversions together to calculate factor during reducing
|
|
312552
|
+
* @internal
|
|
312553
|
+
*/
|
|
312554
|
+
multiply(conversion) {
|
|
312555
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(conversion.offset, 0.0) && (0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
312556
|
+
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
312557
|
+
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
312558
|
+
}
|
|
312559
|
+
/**
|
|
312560
|
+
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
312561
|
+
* @internal
|
|
312562
|
+
*/
|
|
312563
|
+
raise(power) {
|
|
312564
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 1.0))
|
|
312565
|
+
return new UnitConversion(this.factor, this.offset);
|
|
312566
|
+
else if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 0.0))
|
|
312567
|
+
return new UnitConversion(1.0, 0.0);
|
|
312568
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
312569
|
+
return new UnitConversion(this.factor ** power, 0.0);
|
|
312570
|
+
throw new Error("Cannot raise map with non-zero offset");
|
|
312571
|
+
}
|
|
312572
|
+
/** @internal */
|
|
312573
|
+
static identity = new UnitConversion();
|
|
312574
|
+
/**
|
|
312575
|
+
* Returns UnitConversion with source's numerator and denominator in factor and source's offset in offset for reducing.
|
|
312576
|
+
* Accepts any object that structurally satisfies `UnitConversionSource` (e.g. EC `Unit` or `Constant`).
|
|
312577
|
+
* @internal
|
|
312578
|
+
*/
|
|
312579
|
+
static from(source) {
|
|
312580
|
+
const offset = source.offset ?? 0;
|
|
312581
|
+
const hasOffset = !(0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(offset, 0.0);
|
|
312582
|
+
return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);
|
|
312583
|
+
}
|
|
312584
|
+
}
|
|
312585
|
+
|
|
312586
|
+
|
|
312587
|
+
/***/ }),
|
|
312588
|
+
|
|
312589
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js":
|
|
312590
|
+
/*!****************************************************************************!*\
|
|
312591
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js ***!
|
|
312592
|
+
\****************************************************************************/
|
|
312593
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312594
|
+
|
|
312595
|
+
"use strict";
|
|
312596
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312597
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312598
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* binding */ UnitDefinitionResolver)
|
|
312599
|
+
/* harmony export */ });
|
|
312600
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
312601
|
+
/* harmony import */ var _UnitConversion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
312602
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
312603
|
+
/* harmony import */ var _nameUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
312604
|
+
/*---------------------------------------------------------------------------------------------
|
|
312605
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312606
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312607
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312608
|
+
|
|
312609
|
+
|
|
312610
|
+
|
|
312611
|
+
|
|
312612
|
+
const MAX_RESOLUTION_DEPTH = 30;
|
|
312613
|
+
/** Resolves every unit in a `SerializedUnitSchema` to a `UnitConversion` relative to its phenomenon's base unit.
|
|
312614
|
+
* @internal
|
|
312615
|
+
*/
|
|
312616
|
+
class UnitDefinitionResolver {
|
|
312617
|
+
_schema;
|
|
312618
|
+
_cache = new Map();
|
|
312619
|
+
constructor(schema) {
|
|
312620
|
+
if (schema.version !== _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
312621
|
+
throw new Error(`Unsupported Units.json version "${schema.version}". Expected "${_SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION}".`);
|
|
312622
|
+
this._schema = schema;
|
|
312623
|
+
}
|
|
312624
|
+
/** Resolve all Unit items in the schema and return a map from item name to `ResolvedUnit`. */
|
|
312625
|
+
resolveAll() {
|
|
312626
|
+
const result = new Map();
|
|
312627
|
+
for (const [name, item] of Object.entries(this._schema.items)) {
|
|
312628
|
+
if (item.schemaItemType === "Unit") {
|
|
312629
|
+
const conversion = this._resolveUnit(name, 0);
|
|
312630
|
+
result.set(name, {
|
|
312631
|
+
name,
|
|
312632
|
+
label: item.label ?? name,
|
|
312633
|
+
phenomenon: item.phenomenon,
|
|
312634
|
+
unitSystem: item.unitSystem,
|
|
312635
|
+
conversion,
|
|
312636
|
+
});
|
|
312637
|
+
}
|
|
312638
|
+
}
|
|
312639
|
+
return result;
|
|
312640
|
+
}
|
|
312641
|
+
/** Resolve a single unit by unqualified name, returning its conversion to base. */
|
|
312642
|
+
_resolveUnit(name, depth) {
|
|
312643
|
+
if (depth > MAX_RESOLUTION_DEPTH)
|
|
312644
|
+
throw new Error(`Unit resolution depth exceeded ${MAX_RESOLUTION_DEPTH} for "${name}"`);
|
|
312645
|
+
const cached = this._cache.get(name);
|
|
312646
|
+
if (cached)
|
|
312647
|
+
return cached;
|
|
312648
|
+
const item = this._schema.items[name];
|
|
312649
|
+
if (!item)
|
|
312650
|
+
throw new Error(`Unknown schema item: "${name}"`);
|
|
312651
|
+
let conversion;
|
|
312652
|
+
if (item.schemaItemType === "Constant") {
|
|
312653
|
+
conversion = this._resolveConstant(name, item, depth);
|
|
312654
|
+
}
|
|
312655
|
+
else if (item.schemaItemType === "Unit") {
|
|
312656
|
+
conversion = this._resolveUnitItem(name, item, depth);
|
|
312657
|
+
}
|
|
312658
|
+
else {
|
|
312659
|
+
throw new Error(`Cannot resolve item of type "${item.schemaItemType}": "${name}"`);
|
|
312660
|
+
}
|
|
312661
|
+
this._cache.set(name, conversion);
|
|
312662
|
+
return conversion;
|
|
312663
|
+
}
|
|
312664
|
+
_resolveConstant(name, item, depth) {
|
|
312665
|
+
// A constant is identity if its definition is its own name
|
|
312666
|
+
if (item.definition === name)
|
|
312667
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312668
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
312669
|
+
numerator: item.numerator ?? 1,
|
|
312670
|
+
denominator: item.denominator ?? 1,
|
|
312671
|
+
});
|
|
312672
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
312673
|
+
return defConv.compose(selfConv);
|
|
312674
|
+
}
|
|
312675
|
+
_resolveUnitItem(name, item, depth) {
|
|
312676
|
+
// A unit is a base unit if its definition is its own name
|
|
312677
|
+
if (item.definition === name)
|
|
312678
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312679
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
312680
|
+
numerator: item.numerator ?? 1,
|
|
312681
|
+
denominator: item.denominator ?? 1,
|
|
312682
|
+
offset: item.offset,
|
|
312683
|
+
});
|
|
312684
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
312685
|
+
return defConv.compose(selfConv);
|
|
312686
|
+
}
|
|
312687
|
+
/** Parse and resolve a compound definition string like `[MILLI]*M` or `IN`. */
|
|
312688
|
+
_resolveDefinition(definition, depth) {
|
|
312689
|
+
const fragments = (0,_Parser__WEBPACK_IMPORTED_MODULE_2__.parseDefinition)(definition);
|
|
312690
|
+
let result;
|
|
312691
|
+
for (const [, fragment] of fragments) {
|
|
312692
|
+
// Strip alias prefix if present (definitions in the schema use unqualified names)
|
|
312693
|
+
const fragName = (0,_nameUtils__WEBPACK_IMPORTED_MODULE_3__.stripAliasPrefix)(fragment.name);
|
|
312694
|
+
const fragConv = this._resolveUnit(fragName, depth + 1);
|
|
312695
|
+
const raised = fragConv.raise(fragment.exponent);
|
|
312696
|
+
result = result ? result.multiply(raised) : raised;
|
|
312697
|
+
}
|
|
312698
|
+
return result ?? _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
312699
|
+
}
|
|
312700
|
+
}
|
|
312701
|
+
|
|
312702
|
+
|
|
312703
|
+
/***/ }),
|
|
312704
|
+
|
|
312705
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js":
|
|
312706
|
+
/*!***************************************************************!*\
|
|
312707
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/nameUtils.js ***!
|
|
312708
|
+
\***************************************************************/
|
|
312709
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312710
|
+
|
|
312711
|
+
"use strict";
|
|
312712
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312713
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312714
|
+
/* harmony export */ qualifyItemName: () => (/* binding */ qualifyItemName),
|
|
312715
|
+
/* harmony export */ stripAliasPrefix: () => (/* binding */ stripAliasPrefix)
|
|
312716
|
+
/* harmony export */ });
|
|
312717
|
+
/*---------------------------------------------------------------------------------------------
|
|
312718
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312719
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312720
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312721
|
+
/** Strips alias prefix from a schema item reference.
|
|
312722
|
+
* `"u:FT"` → `"FT"`, `"FT"` → `"FT"`.
|
|
312723
|
+
* @internal
|
|
312724
|
+
*/
|
|
312725
|
+
function stripAliasPrefix(raw) {
|
|
312726
|
+
return raw.includes(":") ? raw.split(":")[1] : raw;
|
|
312727
|
+
}
|
|
312728
|
+
/** Normalizes a schema item reference to fully-qualified `SchemaName.ItemName` format.
|
|
312729
|
+
* Handles: already qualified (`"Units.FT"`), alias-qualified (`"u:FT"`), unqualified (`"FT"`).
|
|
312730
|
+
* @internal
|
|
312731
|
+
*/
|
|
312732
|
+
function qualifyItemName(raw, schemaName) {
|
|
312733
|
+
if (raw.includes("."))
|
|
312734
|
+
return raw;
|
|
312735
|
+
return `${schemaName}.${stripAliasPrefix(raw)}`;
|
|
312736
|
+
}
|
|
312737
|
+
|
|
312738
|
+
|
|
312277
312739
|
/***/ }),
|
|
312278
312740
|
|
|
312279
312741
|
/***/ "../../core/quantity/lib/esm/core-quantity.js":
|
|
@@ -312288,6 +312750,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312288
312750
|
/* harmony export */ BadUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BadUnit),
|
|
312289
312751
|
/* harmony export */ BaseFormat: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.BaseFormat),
|
|
312290
312752
|
/* harmony export */ BasicUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BasicUnit),
|
|
312753
|
+
/* harmony export */ BasicUnitsProvider: () => (/* reexport safe */ _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__.BasicUnitsProvider),
|
|
312291
312754
|
/* harmony export */ DecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.DecimalPrecision),
|
|
312292
312755
|
/* harmony export */ Format: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.Format),
|
|
312293
312756
|
/* harmony export */ FormatSpecHandle: () => (/* reexport safe */ _FormatSpecHandle__WEBPACK_IMPORTED_MODULE_2__.FormatSpecHandle),
|
|
@@ -312307,12 +312770,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312307
312770
|
/* harmony export */ QuantityStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus),
|
|
312308
312771
|
/* harmony export */ RatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioFormatType),
|
|
312309
312772
|
/* harmony export */ RatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioType),
|
|
312773
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* reexport safe */ _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__.SERIALIZED_UNIT_SCHEMA_VERSION),
|
|
312310
312774
|
/* harmony export */ ScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ScientificType),
|
|
312311
312775
|
/* harmony export */ ShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ShowSignOption),
|
|
312776
|
+
/* harmony export */ UnitConversion: () => (/* reexport safe */ _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__.UnitConversion),
|
|
312777
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.UnitConversionGraph),
|
|
312312
312778
|
/* harmony export */ UnitConversionInvert: () => (/* reexport safe */ _Interfaces__WEBPACK_IMPORTED_MODULE_3__.UnitConversionInvert),
|
|
312779
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* reexport safe */ _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__.UnitDefinitionResolver),
|
|
312313
312780
|
/* harmony export */ almostEqual: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostEqual),
|
|
312314
312781
|
/* harmony export */ almostZero: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostZero),
|
|
312315
312782
|
/* harmony export */ applyConversion: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.applyConversion),
|
|
312783
|
+
/* harmony export */ createUnitsProvider: () => (/* reexport safe */ _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__.createUnitsProvider),
|
|
312316
312784
|
/* harmony export */ formatStringRgx: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatStringRgx),
|
|
312317
312785
|
/* harmony export */ formatTraitsToArray: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTraitsToArray),
|
|
312318
312786
|
/* harmony export */ formatTypeToString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTypeToString),
|
|
@@ -312320,6 +312788,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312320
312788
|
/* harmony export */ getTraitString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.getTraitString),
|
|
312321
312789
|
/* harmony export */ isCustomFormatProps: () => (/* reexport safe */ _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__.isCustomFormatProps),
|
|
312322
312790
|
/* harmony export */ parseDecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseDecimalPrecision),
|
|
312791
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.parseDefinition),
|
|
312323
312792
|
/* harmony export */ parseFormatTrait: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatTrait),
|
|
312324
312793
|
/* harmony export */ parseFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatType),
|
|
312325
312794
|
/* harmony export */ parseFractionalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFractionalPrecision),
|
|
@@ -312346,6 +312815,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312346
312815
|
/* harmony import */ var _Formatter_FormattingReadyCollector__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Formatter/FormattingReadyCollector */ "../../core/quantity/lib/esm/Formatter/FormattingReadyCollector.js");
|
|
312347
312816
|
/* harmony import */ var _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Formatter/Interfaces */ "../../core/quantity/lib/esm/Formatter/Interfaces.js");
|
|
312348
312817
|
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
312818
|
+
/* harmony import */ var _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./UnitConversion/UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
312819
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
312820
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
312821
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
312822
|
+
/* harmony import */ var _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./CompositeUnitsProvider */ "../../core/quantity/lib/esm/CompositeUnitsProvider.js");
|
|
312823
|
+
/* harmony import */ var _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./internal/cross-package */ "../../core/quantity/lib/esm/internal/cross-package.js");
|
|
312349
312824
|
/*---------------------------------------------------------------------------------------------
|
|
312350
312825
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312351
312826
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -312364,20 +312839,59 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
312364
312839
|
|
|
312365
312840
|
|
|
312366
312841
|
|
|
312842
|
+
|
|
312843
|
+
|
|
312844
|
+
|
|
312845
|
+
|
|
312846
|
+
|
|
312847
|
+
|
|
312367
312848
|
|
|
312368
312849
|
/** @docs-package-description
|
|
312369
|
-
* The core-quantity package
|
|
312850
|
+
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
312370
312851
|
*/
|
|
312371
312852
|
/**
|
|
312372
312853
|
* @docs-group-description Quantity
|
|
312373
312854
|
* Classes, Interfaces, and definitions used to format and parse quantity values.
|
|
312374
312855
|
*/
|
|
312856
|
+
/**
|
|
312857
|
+
* @docs-group-description BasicUnitsProvider
|
|
312858
|
+
* A UnitsProvider backed by the bundled BIS Units schema JSON asset.
|
|
312859
|
+
*/
|
|
312860
|
+
/**
|
|
312861
|
+
* @docs-group-description CompositeUnitsProvider
|
|
312862
|
+
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
312863
|
+
*/
|
|
312375
312864
|
/**
|
|
312376
312865
|
* @docs-group-description Logging
|
|
312377
312866
|
* Logger categories used by this package.
|
|
312378
312867
|
*/
|
|
312379
312868
|
|
|
312380
312869
|
|
|
312870
|
+
/***/ }),
|
|
312871
|
+
|
|
312872
|
+
/***/ "../../core/quantity/lib/esm/internal/cross-package.js":
|
|
312873
|
+
/*!*************************************************************!*\
|
|
312874
|
+
!*** ../../core/quantity/lib/esm/internal/cross-package.js ***!
|
|
312875
|
+
\*************************************************************/
|
|
312876
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
312877
|
+
|
|
312878
|
+
"use strict";
|
|
312879
|
+
__webpack_require__.r(__webpack_exports__);
|
|
312880
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312881
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__.UnitConversionGraph),
|
|
312882
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__.parseDefinition)
|
|
312883
|
+
/* harmony export */ });
|
|
312884
|
+
/* harmony import */ var _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../UnitConversion/Graph */ "../../core/quantity/lib/esm/UnitConversion/Graph.js");
|
|
312885
|
+
/* harmony import */ var _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../UnitConversion/Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
312886
|
+
/*---------------------------------------------------------------------------------------------
|
|
312887
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
312888
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
312889
|
+
*--------------------------------------------------------------------------------------------*/
|
|
312890
|
+
// Used by ecschema-metadata (UnitTree.ts)
|
|
312891
|
+
|
|
312892
|
+
|
|
312893
|
+
|
|
312894
|
+
|
|
312381
312895
|
/***/ }),
|
|
312382
312896
|
|
|
312383
312897
|
/***/ "../../core/webgl-compatibility/lib/esm/Capabilities.js":
|
|
@@ -314151,7 +314665,7 @@ class UiLayoutDataProvider extends _UiDataProvider__WEBPACK_IMPORTED_MODULE_4__.
|
|
|
314151
314665
|
return this._rows;
|
|
314152
314666
|
}
|
|
314153
314667
|
loadItemsInternal(items) {
|
|
314154
|
-
this._items = items
|
|
314668
|
+
this._items = items ?? [];
|
|
314155
314669
|
this._rows = this.layoutDialogRows();
|
|
314156
314670
|
}
|
|
314157
314671
|
/** Called by UI to request available properties that can be bound to user supplied UI components (See Tool1UiProvider for example). */
|
|
@@ -314160,10 +314674,13 @@ class UiLayoutDataProvider extends _UiDataProvider__WEBPACK_IMPORTED_MODULE_4__.
|
|
|
314160
314674
|
throw (new Error("Derived UiDataProvider must implement this method to supply set of properties."));
|
|
314161
314675
|
}
|
|
314162
314676
|
get items() {
|
|
314163
|
-
|
|
314164
|
-
|
|
314165
|
-
|
|
314166
|
-
|
|
314677
|
+
const items = this._items;
|
|
314678
|
+
if (undefined !== items)
|
|
314679
|
+
return items;
|
|
314680
|
+
this.loadItemsInternal(this.supplyDialogItems());
|
|
314681
|
+
// If _items is undefined, the hook above failed to initialize it
|
|
314682
|
+
// Deemed more honest to use the non-null assertion than explicit cast
|
|
314683
|
+
return this._items; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
314167
314684
|
}
|
|
314168
314685
|
/** Called to inform listeners that new properties are ready for display in UI. */
|
|
314169
314686
|
reloadDialogItems(emitEvent = true) {
|
|
@@ -315235,14 +315752,14 @@ class BaseQuantityDescription {
|
|
|
315235
315752
|
this.displayLabel = displayLabel;
|
|
315236
315753
|
this.kindOfQuantityName = kindOfQuantityName;
|
|
315237
315754
|
this.typename = _properties_StandardTypeNames__WEBPACK_IMPORTED_MODULE_1__.StandardTypeNames.Number;
|
|
315755
|
+
const editorParams = [{
|
|
315756
|
+
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.CustomFormattedNumber,
|
|
315757
|
+
formatFunction: this.format,
|
|
315758
|
+
parseFunction: this.parse,
|
|
315759
|
+
}];
|
|
315238
315760
|
this.editor = {
|
|
315239
315761
|
name: _properties_StandardEditorNames__WEBPACK_IMPORTED_MODULE_2__.StandardEditorNames.NumberCustom,
|
|
315240
|
-
params:
|
|
315241
|
-
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.CustomFormattedNumber,
|
|
315242
|
-
formatFunction: this.format,
|
|
315243
|
-
parseFunction: this.parse,
|
|
315244
|
-
},
|
|
315245
|
-
],
|
|
315762
|
+
params: editorParams,
|
|
315246
315763
|
};
|
|
315247
315764
|
// istanbul ignore else
|
|
315248
315765
|
if (iconSpec) {
|
|
@@ -315250,7 +315767,7 @@ class BaseQuantityDescription {
|
|
|
315250
315767
|
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.Icon,
|
|
315251
315768
|
definition: { iconSpec },
|
|
315252
315769
|
};
|
|
315253
|
-
|
|
315770
|
+
editorParams.push(params);
|
|
315254
315771
|
}
|
|
315255
315772
|
}
|
|
315256
315773
|
format = (numberValue) => {
|
|
@@ -326420,7 +326937,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
326420
326937
|
/***/ ((module) => {
|
|
326421
326938
|
|
|
326422
326939
|
"use strict";
|
|
326423
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.10.0-dev.
|
|
326940
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.10.0-dev.3","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"}}');
|
|
326424
326941
|
|
|
326425
326942
|
/***/ })
|
|
326426
326943
|
|