@itwin/rpcinterface-full-stack-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 +1043 -526
- 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 +14 -14
|
@@ -112094,247 +112094,6 @@ class SchemaPartVisitorDelegate {
|
|
|
112094
112094
|
}
|
|
112095
112095
|
|
|
112096
112096
|
|
|
112097
|
-
/***/ }),
|
|
112098
|
-
|
|
112099
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js":
|
|
112100
|
-
/*!********************************************************************!*\
|
|
112101
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js ***!
|
|
112102
|
-
\********************************************************************/
|
|
112103
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112104
|
-
|
|
112105
|
-
"use strict";
|
|
112106
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112107
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112108
|
-
/* harmony export */ Graph: () => (/* binding */ Graph)
|
|
112109
|
-
/* harmony export */ });
|
|
112110
|
-
/*---------------------------------------------------------------------------------------------
|
|
112111
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112112
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
112113
|
-
*--------------------------------------------------------------------------------------------*/
|
|
112114
|
-
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
112115
|
-
/** @internal */
|
|
112116
|
-
class Graph {
|
|
112117
|
-
_edgeKeyDelim = "\x01";
|
|
112118
|
-
_label = "";
|
|
112119
|
-
_nodeCount = 0;
|
|
112120
|
-
_edgeCount = 0;
|
|
112121
|
-
_nodes;
|
|
112122
|
-
_edgeObjs;
|
|
112123
|
-
_edgeLabels;
|
|
112124
|
-
_outEdges;
|
|
112125
|
-
constructor() {
|
|
112126
|
-
this._nodes = {};
|
|
112127
|
-
this._edgeObjs = {};
|
|
112128
|
-
this._edgeLabels = {};
|
|
112129
|
-
this._outEdges = {};
|
|
112130
|
-
}
|
|
112131
|
-
setGraph = (label) => {
|
|
112132
|
-
this._label = label;
|
|
112133
|
-
return this;
|
|
112134
|
-
};
|
|
112135
|
-
graph = () => {
|
|
112136
|
-
return this._label;
|
|
112137
|
-
};
|
|
112138
|
-
nodeCount = () => {
|
|
112139
|
-
return this._nodeCount;
|
|
112140
|
-
};
|
|
112141
|
-
nodes = () => {
|
|
112142
|
-
return Object.keys(this._nodes);
|
|
112143
|
-
};
|
|
112144
|
-
setNode = (nodeKey, nodeValue) => {
|
|
112145
|
-
if (nodeKey in this._nodes) {
|
|
112146
|
-
this._nodes[nodeKey] = nodeValue;
|
|
112147
|
-
return;
|
|
112148
|
-
}
|
|
112149
|
-
this._nodes[nodeKey] = nodeValue;
|
|
112150
|
-
this._outEdges[nodeKey] = {};
|
|
112151
|
-
++this._nodeCount;
|
|
112152
|
-
};
|
|
112153
|
-
node = (nodeKey) => {
|
|
112154
|
-
return this._nodes[nodeKey];
|
|
112155
|
-
};
|
|
112156
|
-
hasNode = (nodeKey) => {
|
|
112157
|
-
return nodeKey in this._nodes;
|
|
112158
|
-
};
|
|
112159
|
-
edgeCount = () => {
|
|
112160
|
-
return this._edgeCount;
|
|
112161
|
-
};
|
|
112162
|
-
edges = () => {
|
|
112163
|
-
return Object.values(this._edgeObjs);
|
|
112164
|
-
};
|
|
112165
|
-
setEdge = (v, w, value) => {
|
|
112166
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
112167
|
-
if (edgeId in this._edgeLabels) {
|
|
112168
|
-
// this._edgeLabels[edgeId] = value;
|
|
112169
|
-
// Update exponent, specific to this graph's use case
|
|
112170
|
-
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
112171
|
-
return;
|
|
112172
|
-
}
|
|
112173
|
-
this._edgeLabels[edgeId] = value;
|
|
112174
|
-
const edgeObj = {
|
|
112175
|
-
v,
|
|
112176
|
-
w,
|
|
112177
|
-
};
|
|
112178
|
-
this._edgeObjs[edgeId] = edgeObj;
|
|
112179
|
-
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
112180
|
-
this._outEdges[v][edgeId] = edgeObj;
|
|
112181
|
-
this._edgeCount++;
|
|
112182
|
-
};
|
|
112183
|
-
edge = (v, w) => {
|
|
112184
|
-
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
112185
|
-
return this._edgeLabels[edgeId];
|
|
112186
|
-
};
|
|
112187
|
-
outEdges = (v) => {
|
|
112188
|
-
const outV = this._outEdges[v];
|
|
112189
|
-
const edges = Object.values(outV);
|
|
112190
|
-
return edges;
|
|
112191
|
-
};
|
|
112192
|
-
}
|
|
112193
|
-
|
|
112194
|
-
|
|
112195
|
-
/***/ }),
|
|
112196
|
-
|
|
112197
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js":
|
|
112198
|
-
/*!*********************************************************************!*\
|
|
112199
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js ***!
|
|
112200
|
-
\*********************************************************************/
|
|
112201
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112202
|
-
|
|
112203
|
-
"use strict";
|
|
112204
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112205
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112206
|
-
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
112207
|
-
/* harmony export */ });
|
|
112208
|
-
/*---------------------------------------------------------------------------------------------
|
|
112209
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112210
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
112211
|
-
*--------------------------------------------------------------------------------------------*/
|
|
112212
|
-
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
112213
|
-
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
112214
|
-
const sp = "*";
|
|
112215
|
-
/** @internal */
|
|
112216
|
-
var Tokens;
|
|
112217
|
-
(function (Tokens) {
|
|
112218
|
-
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
112219
|
-
Tokens[Tokens["Word"] = 2] = "Word";
|
|
112220
|
-
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
112221
|
-
})(Tokens || (Tokens = {}));
|
|
112222
|
-
/** @internal */
|
|
112223
|
-
function parseDefinition(definition) {
|
|
112224
|
-
const unitMap = new Map();
|
|
112225
|
-
if (expressionRgx.test(definition)) {
|
|
112226
|
-
for (const unit of definition.split(sp)) {
|
|
112227
|
-
const tokens = unit.split(tokenRgx);
|
|
112228
|
-
const name = tokens[Tokens.Word];
|
|
112229
|
-
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
112230
|
-
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
112231
|
-
if (unitMap.has(name)) {
|
|
112232
|
-
const currentDefinition = unitMap.get(name);
|
|
112233
|
-
if (currentDefinition) {
|
|
112234
|
-
currentDefinition.exponent += exponent;
|
|
112235
|
-
unitMap.set(name, currentDefinition);
|
|
112236
|
-
}
|
|
112237
|
-
}
|
|
112238
|
-
else {
|
|
112239
|
-
unitMap.set(name, { name, exponent, constant });
|
|
112240
|
-
}
|
|
112241
|
-
}
|
|
112242
|
-
return unitMap;
|
|
112243
|
-
}
|
|
112244
|
-
else {
|
|
112245
|
-
throw new Error("Invalid definition expression.");
|
|
112246
|
-
}
|
|
112247
|
-
}
|
|
112248
|
-
|
|
112249
|
-
|
|
112250
|
-
/***/ }),
|
|
112251
|
-
|
|
112252
|
-
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js":
|
|
112253
|
-
/*!*****************************************************************************!*\
|
|
112254
|
-
!*** ../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
112255
|
-
\*****************************************************************************/
|
|
112256
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
112257
|
-
|
|
112258
|
-
"use strict";
|
|
112259
|
-
__webpack_require__.r(__webpack_exports__);
|
|
112260
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
112261
|
-
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
112262
|
-
/* harmony export */ });
|
|
112263
|
-
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
112264
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112265
|
-
|
|
112266
|
-
|
|
112267
|
-
/**
|
|
112268
|
-
* Class used for storing calculated conversion between two Units [[UnitConverter.calculateConversion]] and converting values from one Unit to another [[UnitConverter.evaluate]]
|
|
112269
|
-
* @internal
|
|
112270
|
-
*/
|
|
112271
|
-
class UnitConversion {
|
|
112272
|
-
factor;
|
|
112273
|
-
offset;
|
|
112274
|
-
constructor(factor = 1.0, offset = 0.0) {
|
|
112275
|
-
this.factor = factor;
|
|
112276
|
-
this.offset = offset;
|
|
112277
|
-
}
|
|
112278
|
-
/**
|
|
112279
|
-
* Converts x using UnitConversion
|
|
112280
|
-
* @param x Input magnitude to be converted
|
|
112281
|
-
* @returns Output magnitude after conversion
|
|
112282
|
-
*/
|
|
112283
|
-
evaluate(x) {
|
|
112284
|
-
return this.factor * x + this.offset;
|
|
112285
|
-
}
|
|
112286
|
-
/**
|
|
112287
|
-
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
112288
|
-
* @internal
|
|
112289
|
-
*/
|
|
112290
|
-
inverse() {
|
|
112291
|
-
const inverseFactor = 1.0 / this.factor;
|
|
112292
|
-
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
112293
|
-
}
|
|
112294
|
-
/**
|
|
112295
|
-
* Combines two UnitConversions
|
|
112296
|
-
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
112297
|
-
* @internal
|
|
112298
|
-
*/
|
|
112299
|
-
compose(conversion) {
|
|
112300
|
-
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
112301
|
-
}
|
|
112302
|
-
/**
|
|
112303
|
-
* Multiples two UnitConversions together to calculate factor during reducing
|
|
112304
|
-
* @internal
|
|
112305
|
-
*/
|
|
112306
|
-
multiply(conversion) {
|
|
112307
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(conversion.offset, 0.0) && (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(this.offset, 0.0))
|
|
112308
|
-
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
112309
|
-
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
112310
|
-
}
|
|
112311
|
-
/**
|
|
112312
|
-
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
112313
|
-
* @internal
|
|
112314
|
-
*/
|
|
112315
|
-
raise(power) {
|
|
112316
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 1.0))
|
|
112317
|
-
return new UnitConversion(this.factor, this.offset);
|
|
112318
|
-
else if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(power, 0.0))
|
|
112319
|
-
return new UnitConversion(1.0, 0.0);
|
|
112320
|
-
if ((0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.almostEqual)(this.offset, 0.0))
|
|
112321
|
-
return new UnitConversion(this.factor ** power, 0.0);
|
|
112322
|
-
throw new Error("Cannot raise map with non-zero offset");
|
|
112323
|
-
}
|
|
112324
|
-
/** @internal */
|
|
112325
|
-
static identity = new UnitConversion();
|
|
112326
|
-
/**
|
|
112327
|
-
* Returns UnitConversion with unit's numerator and denominator in factor and unit's offset in offset for reducing
|
|
112328
|
-
* @internal
|
|
112329
|
-
*/
|
|
112330
|
-
static from(unitOrConstant) {
|
|
112331
|
-
if (_Metadata_Unit__WEBPACK_IMPORTED_MODULE_0__.Unit.isUnit(unitOrConstant))
|
|
112332
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, -unitOrConstant.offset);
|
|
112333
|
-
return new UnitConversion(unitOrConstant.denominator / unitOrConstant.numerator, 0.0);
|
|
112334
|
-
}
|
|
112335
|
-
}
|
|
112336
|
-
|
|
112337
|
-
|
|
112338
112097
|
/***/ }),
|
|
112339
112098
|
|
|
112340
112099
|
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js":
|
|
@@ -112352,7 +112111,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112352
112111
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
112353
112112
|
/* harmony import */ var _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/Unit */ "../../core/ecschema-metadata/lib/esm/Metadata/Unit.js");
|
|
112354
112113
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
112355
|
-
/* harmony import */ var
|
|
112114
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112356
112115
|
/* harmony import */ var _UnitTree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./UnitTree */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitTree.js");
|
|
112357
112116
|
/*---------------------------------------------------------------------------------------------
|
|
112358
112117
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
@@ -112412,7 +112171,7 @@ class UnitConverter {
|
|
|
112412
112171
|
*/
|
|
112413
112172
|
async processUnits(from, to) {
|
|
112414
112173
|
if (from.key.matches(to.key))
|
|
112415
|
-
return
|
|
112174
|
+
return _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112416
112175
|
const areCompatible = await _Metadata_Unit__WEBPACK_IMPORTED_MODULE_2__.Unit.areCompatible(from, to);
|
|
112417
112176
|
if (!areCompatible)
|
|
112418
112177
|
throw new _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BentleyError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BentleyStatus.ERROR, `Source and target units do not belong to same phenomenon`, () => {
|
|
@@ -112432,8 +112191,8 @@ class UnitConverter {
|
|
|
112432
112191
|
return { from, to };
|
|
112433
112192
|
});
|
|
112434
112193
|
// Final calculations to get singular UnitConversion between from -> to
|
|
112435
|
-
const fromMap = fromMapStore.get(from.key.fullName) ||
|
|
112436
|
-
const toMap = toMapStore.get(to.key.fullName) ||
|
|
112194
|
+
const fromMap = fromMapStore.get(from.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112195
|
+
const toMap = toMapStore.get(to.key.fullName) || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112437
112196
|
const fromInverse = fromMap.inverse();
|
|
112438
112197
|
return fromInverse.compose(toMap);
|
|
112439
112198
|
}
|
|
@@ -112488,9 +112247,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112488
112247
|
/* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
|
|
112489
112248
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
112490
112249
|
/* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
|
|
112491
|
-
/* harmony import */ var
|
|
112492
|
-
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Parser */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Parser.js");
|
|
112493
|
-
/* harmony import */ var _Graph__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Graph */ "../../core/ecschema-metadata/lib/esm/UnitConversion/Graph.js");
|
|
112250
|
+
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
112494
112251
|
/*---------------------------------------------------------------------------------------------
|
|
112495
112252
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
112496
112253
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -112500,13 +112257,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112500
112257
|
|
|
112501
112258
|
|
|
112502
112259
|
|
|
112503
|
-
|
|
112504
|
-
|
|
112505
112260
|
/** @internal */
|
|
112506
112261
|
class GraphUtils {
|
|
112507
112262
|
/**
|
|
112508
112263
|
* DFS traversal - Post order
|
|
112509
|
-
* @param _graph
|
|
112264
|
+
* @param _graph DirectedGraph to traverse
|
|
112510
112265
|
* @param start Starting node
|
|
112511
112266
|
* @param keyFrom Get key from label
|
|
112512
112267
|
* @param op Reducing function
|
|
@@ -112537,7 +112292,7 @@ class GraphUtils {
|
|
|
112537
112292
|
/** @internal */
|
|
112538
112293
|
class UnitGraph {
|
|
112539
112294
|
_context;
|
|
112540
|
-
_graph = new
|
|
112295
|
+
_graph = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversionGraph();
|
|
112541
112296
|
_unitsInProgress = new Map();
|
|
112542
112297
|
constructor(_context) {
|
|
112543
112298
|
this._context = _context;
|
|
@@ -112616,7 +112371,7 @@ class UnitGraph {
|
|
|
112616
112371
|
.finally(() => this._unitsInProgress.delete(unit.key.fullName));
|
|
112617
112372
|
}
|
|
112618
112373
|
async addUnitToGraph(unit) {
|
|
112619
|
-
const umap = (0,
|
|
112374
|
+
const umap = (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.parseDefinition)(unit.definition);
|
|
112620
112375
|
const promiseArray = [];
|
|
112621
112376
|
for (const [key, value] of umap) {
|
|
112622
112377
|
promiseArray.push(this.resolveUnit(key, unit.schema).then((u) => [u, value]));
|
|
@@ -112650,17 +112405,19 @@ class UnitGraph {
|
|
|
112650
112405
|
const cmap = outEdges.reduce((pm, e) => {
|
|
112651
112406
|
const { exponent } = this._graph.edge(e.v, e.w);
|
|
112652
112407
|
const stored = innermapStore.get(e.w);
|
|
112653
|
-
const map = stored ? stored :
|
|
112408
|
+
const map = stored ? stored : _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112654
112409
|
const emap = map.raise(exponent);
|
|
112655
112410
|
return pm ? pm.multiply(emap) : emap;
|
|
112656
112411
|
}, undefined);
|
|
112657
|
-
|
|
112658
|
-
|
|
112412
|
+
// EC Constant nodes have no offset property → UnitConversionSource.offset is undefined → 0.
|
|
112413
|
+
// Matches the prior explicit 0.0 branch before UnitConversion moved to core-quantity.
|
|
112414
|
+
const thisMap = this._graph.node(unitFullName) ? _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.from(this._graph.node(unitFullName)) : _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112415
|
+
const other = cmap || _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity;
|
|
112659
112416
|
const result = other.compose(thisMap);
|
|
112660
112417
|
innermapStore.set(unitFullName, result);
|
|
112661
112418
|
}
|
|
112662
112419
|
else {
|
|
112663
|
-
innermapStore.set(unitFullName,
|
|
112420
|
+
innermapStore.set(unitFullName, _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_4__.UnitConversion.identity);
|
|
112664
112421
|
}
|
|
112665
112422
|
return innermapStore;
|
|
112666
112423
|
}
|
|
@@ -112704,6 +112461,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
112704
112461
|
|
|
112705
112462
|
/**
|
|
112706
112463
|
* Class used to find Units in SchemaContext by attributes such as Phenomenon and DisplayLabel.
|
|
112464
|
+
*
|
|
112465
|
+
* To layer schema-defined units on top of the bundled BIS units from `@itwin/core-quantity`,
|
|
112466
|
+
* pass this as `primary` to `createUnitsProvider` from `@itwin/core-quantity`.
|
|
112707
112467
|
* @beta
|
|
112708
112468
|
*/
|
|
112709
112469
|
class SchemaUnitProvider {
|
|
@@ -113055,7 +112815,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113055
112815
|
/* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
|
|
113056
112816
|
/* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
|
|
113057
112817
|
/* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
|
|
113058
|
-
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */
|
|
112818
|
+
/* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
|
|
113059
112819
|
/* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
|
|
113060
112820
|
/* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
|
|
113061
112821
|
/* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
|
|
@@ -113063,8 +112823,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113063
112823
|
/* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
|
|
113064
112824
|
/* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
|
|
113065
112825
|
/* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
|
|
113066
|
-
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */
|
|
113067
|
-
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */
|
|
112826
|
+
/* harmony export */ FormatSetFormatsProvider: () => (/* reexport safe */ _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.FormatSetFormatsProvider),
|
|
112827
|
+
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
|
|
113068
112828
|
/* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
|
|
113069
112829
|
/* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
|
|
113070
112830
|
/* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
|
|
@@ -113086,8 +112846,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113086
112846
|
/* harmony export */ Schema: () => (/* reexport safe */ _Metadata_Schema__WEBPACK_IMPORTED_MODULE_25__.Schema),
|
|
113087
112847
|
/* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
|
|
113088
112848
|
/* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
|
|
113089
|
-
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */
|
|
113090
|
-
/* harmony export */ SchemaGraph: () => (/* reexport safe */
|
|
112849
|
+
/* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__.SchemaFormatsProvider),
|
|
112850
|
+
/* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
|
|
113091
112851
|
/* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
|
|
113092
112852
|
/* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
|
|
113093
112853
|
/* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
|
|
@@ -113096,18 +112856,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113096
112856
|
/* harmony export */ SchemaKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaKey),
|
|
113097
112857
|
/* harmony export */ SchemaLoader: () => (/* reexport safe */ _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__.SchemaLoader),
|
|
113098
112858
|
/* harmony export */ SchemaMatchType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.SchemaMatchType),
|
|
113099
|
-
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */
|
|
112859
|
+
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */ _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__.SchemaPartVisitorDelegate),
|
|
113100
112860
|
/* harmony export */ SchemaReadHelper: () => (/* reexport safe */ _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_5__.SchemaReadHelper),
|
|
113101
|
-
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */
|
|
113102
|
-
/* harmony export */ SchemaWalker: () => (/* reexport safe */
|
|
112861
|
+
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */ _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__.SchemaUnitProvider),
|
|
112862
|
+
/* harmony export */ SchemaWalker: () => (/* reexport safe */ _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__.SchemaWalker),
|
|
113103
112863
|
/* harmony export */ StrengthDirection: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthDirection),
|
|
113104
112864
|
/* harmony export */ StrengthType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthType),
|
|
113105
112865
|
/* harmony export */ StructArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructArrayProperty),
|
|
113106
112866
|
/* harmony export */ StructClass: () => (/* reexport safe */ _Metadata_Class__WEBPACK_IMPORTED_MODULE_11__.StructClass),
|
|
113107
112867
|
/* harmony export */ StructProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.StructProperty),
|
|
113108
112868
|
/* harmony export */ Unit: () => (/* reexport safe */ _Metadata_Unit__WEBPACK_IMPORTED_MODULE_27__.Unit),
|
|
113109
|
-
/* harmony export */
|
|
113110
|
-
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_34__.UnitConverter),
|
|
112869
|
+
/* harmony export */ UnitConverter: () => (/* reexport safe */ _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__.UnitConverter),
|
|
113111
112870
|
/* harmony export */ UnitSystem: () => (/* reexport safe */ _Metadata_UnitSystem__WEBPACK_IMPORTED_MODULE_28__.UnitSystem),
|
|
113112
112871
|
/* harmony export */ XmlParser: () => (/* reexport safe */ _Deserialization_XmlParser__WEBPACK_IMPORTED_MODULE_6__.XmlParser),
|
|
113113
112872
|
/* harmony export */ classModifierToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.classModifierToString),
|
|
@@ -113162,16 +112921,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113162
112921
|
/* harmony import */ var _SchemaJsonLocater__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./SchemaJsonLocater */ "../../core/ecschema-metadata/lib/esm/SchemaJsonLocater.js");
|
|
113163
112922
|
/* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
|
|
113164
112923
|
/* harmony import */ var _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./SchemaLoader */ "../../core/ecschema-metadata/lib/esm/SchemaLoader.js");
|
|
113165
|
-
/* harmony import */ var
|
|
113166
|
-
/* harmony import */ var
|
|
113167
|
-
/* harmony import */ var
|
|
113168
|
-
/* harmony import */ var
|
|
113169
|
-
/* harmony import */ var
|
|
113170
|
-
/* harmony import */ var
|
|
113171
|
-
/* harmony import */ var
|
|
113172
|
-
/* harmony import */ var
|
|
113173
|
-
/* harmony import */ var
|
|
113174
|
-
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
112924
|
+
/* harmony import */ var _UnitConversion_UnitConverter__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./UnitConversion/UnitConverter */ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js");
|
|
112925
|
+
/* harmony import */ var _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./UnitProvider/SchemaUnitProvider */ "../../core/ecschema-metadata/lib/esm/UnitProvider/SchemaUnitProvider.js");
|
|
112926
|
+
/* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
|
|
112927
|
+
/* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
|
|
112928
|
+
/* harmony import */ var _Formatting_SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./Formatting/SchemaFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/SchemaFormatsProvider.js");
|
|
112929
|
+
/* harmony import */ var _Formatting_FormatSetFormatsProvider__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./Formatting/FormatSetFormatsProvider */ "../../core/ecschema-metadata/lib/esm/Formatting/FormatSetFormatsProvider.js");
|
|
112930
|
+
/* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
|
|
112931
|
+
/* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
|
|
112932
|
+
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
113175
112933
|
/*---------------------------------------------------------------------------------------------
|
|
113176
112934
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
113177
112935
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -113216,7 +112974,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
113216
112974
|
|
|
113217
112975
|
|
|
113218
112976
|
|
|
113219
|
-
|
|
113220
112977
|
|
|
113221
112978
|
|
|
113222
112979
|
/** @docs-package-description
|
|
@@ -194085,6 +193842,44 @@ class EngineeringLengthDescription extends _FormattedQuantityDescription__WEBPAC
|
|
|
194085
193842
|
}
|
|
194086
193843
|
|
|
194087
193844
|
|
|
193845
|
+
/***/ }),
|
|
193846
|
+
|
|
193847
|
+
/***/ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js":
|
|
193848
|
+
/*!******************************************************************************!*\
|
|
193849
|
+
!*** ../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js ***!
|
|
193850
|
+
\******************************************************************************/
|
|
193851
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
193852
|
+
|
|
193853
|
+
"use strict";
|
|
193854
|
+
__webpack_require__.r(__webpack_exports__);
|
|
193855
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
193856
|
+
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
193857
|
+
/* harmony export */ });
|
|
193858
|
+
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
193859
|
+
/*---------------------------------------------------------------------------------------------
|
|
193860
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
193861
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
193862
|
+
*--------------------------------------------------------------------------------------------*/
|
|
193863
|
+
/** @packageDocumentation
|
|
193864
|
+
* @module QuantityFormatting
|
|
193865
|
+
*/
|
|
193866
|
+
|
|
193867
|
+
/** Function to generate default set of alternate unit labels
|
|
193868
|
+
* @internal
|
|
193869
|
+
*/
|
|
193870
|
+
function getDefaultAlternateUnitLabels() {
|
|
193871
|
+
const altDisplayLabelsMap = new Map();
|
|
193872
|
+
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_0__.UNIT_EXTRA_DATA) {
|
|
193873
|
+
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
193874
|
+
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
193875
|
+
}
|
|
193876
|
+
}
|
|
193877
|
+
if (altDisplayLabelsMap.size)
|
|
193878
|
+
return altDisplayLabelsMap;
|
|
193879
|
+
return undefined;
|
|
193880
|
+
}
|
|
193881
|
+
|
|
193882
|
+
|
|
194088
193883
|
/***/ }),
|
|
194089
193884
|
|
|
194090
193885
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/BaseUnitFormattingSettingsProvider.js":
|
|
@@ -194228,178 +194023,6 @@ class BaseUnitFormattingSettingsProvider {
|
|
|
194228
194023
|
}
|
|
194229
194024
|
|
|
194230
194025
|
|
|
194231
|
-
/***/ }),
|
|
194232
|
-
|
|
194233
|
-
/***/ "../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js":
|
|
194234
|
-
/*!*****************************************************************************!*\
|
|
194235
|
-
!*** ../../core/frontend/lib/esm/quantity-formatting/BasicUnitsProvider.js ***!
|
|
194236
|
-
\*****************************************************************************/
|
|
194237
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
194238
|
-
|
|
194239
|
-
"use strict";
|
|
194240
|
-
__webpack_require__.r(__webpack_exports__);
|
|
194241
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
194242
|
-
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
194243
|
-
/* harmony export */ getDefaultAlternateUnitLabels: () => (/* binding */ getDefaultAlternateUnitLabels)
|
|
194244
|
-
/* harmony export */ });
|
|
194245
|
-
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
194246
|
-
/* harmony import */ var _UnitsData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitsData */ "../../core/frontend/lib/esm/quantity-formatting/UnitsData.js");
|
|
194247
|
-
/*---------------------------------------------------------------------------------------------
|
|
194248
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
194249
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
194250
|
-
*--------------------------------------------------------------------------------------------*/
|
|
194251
|
-
/** @packageDocumentation
|
|
194252
|
-
* @module QuantityFormatting
|
|
194253
|
-
*/
|
|
194254
|
-
|
|
194255
|
-
|
|
194256
|
-
// cSpell:ignore ussurvey USCUSTOM
|
|
194257
|
-
/** Units provider that provides a limited number of UnitDefinitions that are needed to support basic tools.
|
|
194258
|
-
* @internal
|
|
194259
|
-
*/
|
|
194260
|
-
class BasicUnitsProvider {
|
|
194261
|
-
/** Find a unit given the unitLabel. */
|
|
194262
|
-
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
194263
|
-
const labelToFind = unitLabel.toLowerCase();
|
|
194264
|
-
const unitFamilyToFind = phenomenon ? phenomenon.toLowerCase() : undefined;
|
|
194265
|
-
const unitSystemToFind = unitSystem ? unitSystem.toLowerCase() : undefined;
|
|
194266
|
-
for (const entry of UNIT_DATA) {
|
|
194267
|
-
if (schemaName && schemaName !== "Units")
|
|
194268
|
-
continue;
|
|
194269
|
-
if (phenomenon && entry.phenomenon.toLowerCase() !== unitFamilyToFind)
|
|
194270
|
-
continue;
|
|
194271
|
-
if (unitSystemToFind && entry.system.toLowerCase() !== unitSystemToFind)
|
|
194272
|
-
continue;
|
|
194273
|
-
if (entry.displayLabel.toLowerCase() === labelToFind || entry.name.toLowerCase() === labelToFind) {
|
|
194274
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
194275
|
-
return unitProps;
|
|
194276
|
-
}
|
|
194277
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
194278
|
-
if (entry.altDisplayLabels.findIndex((ref) => ref.toLowerCase() === labelToFind) !== -1) {
|
|
194279
|
-
const unitProps = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system);
|
|
194280
|
-
return unitProps;
|
|
194281
|
-
}
|
|
194282
|
-
}
|
|
194283
|
-
}
|
|
194284
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
194285
|
-
}
|
|
194286
|
-
/** Find all units given phenomenon */
|
|
194287
|
-
async getUnitsByFamily(phenomenon) {
|
|
194288
|
-
const units = [];
|
|
194289
|
-
for (const entry of UNIT_DATA) {
|
|
194290
|
-
if (entry.phenomenon !== phenomenon)
|
|
194291
|
-
continue;
|
|
194292
|
-
units.push(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(entry.name, entry.displayLabel, entry.phenomenon, entry.system));
|
|
194293
|
-
}
|
|
194294
|
-
return units;
|
|
194295
|
-
}
|
|
194296
|
-
findUnitDefinition(name) {
|
|
194297
|
-
for (const entry of UNIT_DATA) {
|
|
194298
|
-
if (entry.name === name)
|
|
194299
|
-
return entry;
|
|
194300
|
-
}
|
|
194301
|
-
return undefined;
|
|
194302
|
-
}
|
|
194303
|
-
/** Find a unit given the unit's unique name. */
|
|
194304
|
-
async findUnitByName(unitName) {
|
|
194305
|
-
const unitDataEntry = this.findUnitDefinition(unitName);
|
|
194306
|
-
if (unitDataEntry) {
|
|
194307
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BasicUnit(unitDataEntry.name, unitDataEntry.displayLabel, unitDataEntry.phenomenon, unitDataEntry.system);
|
|
194308
|
-
}
|
|
194309
|
-
return new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_0__.BadUnit();
|
|
194310
|
-
}
|
|
194311
|
-
/** Return the information needed to convert a value between two different units. The units should be from the same phenomenon. */
|
|
194312
|
-
async getConversion(fromUnit, toUnit) {
|
|
194313
|
-
const fromUnitData = this.findUnitDefinition(fromUnit.name);
|
|
194314
|
-
const toUnitData = this.findUnitDefinition(toUnit.name);
|
|
194315
|
-
if (fromUnitData && toUnitData) {
|
|
194316
|
-
const deltaOffset = toUnitData.conversion.offset - fromUnitData.conversion.offset;
|
|
194317
|
-
const deltaNumerator = toUnitData.conversion.numerator * fromUnitData.conversion.denominator;
|
|
194318
|
-
const deltaDenominator = toUnitData.conversion.denominator * fromUnitData.conversion.numerator;
|
|
194319
|
-
const conversionData = new ConversionData();
|
|
194320
|
-
conversionData.factor = deltaNumerator / deltaDenominator;
|
|
194321
|
-
conversionData.offset = deltaOffset;
|
|
194322
|
-
return conversionData;
|
|
194323
|
-
}
|
|
194324
|
-
return new ConversionData();
|
|
194325
|
-
}
|
|
194326
|
-
}
|
|
194327
|
-
/** Class that implements the minimum UnitConversionProps interface to provide information needed to convert unit values.
|
|
194328
|
-
* @alpha
|
|
194329
|
-
*/
|
|
194330
|
-
class ConversionData {
|
|
194331
|
-
factor = 1.0;
|
|
194332
|
-
offset = 0.0;
|
|
194333
|
-
error = false;
|
|
194334
|
-
}
|
|
194335
|
-
/** Function to generate default set of alternate unit labels
|
|
194336
|
-
* @internal
|
|
194337
|
-
*/
|
|
194338
|
-
function getDefaultAlternateUnitLabels() {
|
|
194339
|
-
const altDisplayLabelsMap = new Map();
|
|
194340
|
-
for (const entry of _UnitsData__WEBPACK_IMPORTED_MODULE_1__.UNIT_EXTRA_DATA) {
|
|
194341
|
-
if (entry.altDisplayLabels && entry.altDisplayLabels.length > 0) {
|
|
194342
|
-
altDisplayLabelsMap.set(entry.name, new Set(entry.altDisplayLabels));
|
|
194343
|
-
}
|
|
194344
|
-
}
|
|
194345
|
-
if (altDisplayLabelsMap.size)
|
|
194346
|
-
return altDisplayLabelsMap;
|
|
194347
|
-
return undefined;
|
|
194348
|
-
}
|
|
194349
|
-
// ========================================================================================================================================
|
|
194350
|
-
// Minimum set of UNITs to be removed when official UnitsProvider is available
|
|
194351
|
-
// ========================================================================================================================================
|
|
194352
|
-
// cSpell:ignore MILLIINCH, MICROINCH, MILLIFOOT
|
|
194353
|
-
// Set of supported units - this information will come from Schema-based units once the EC package is ready to provide this information.
|
|
194354
|
-
const UNIT_DATA = [
|
|
194355
|
-
// Angles ( base unit radian )
|
|
194356
|
-
{ name: "Units.RAD", phenomenon: "Units.ANGLE", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "rad" },
|
|
194357
|
-
// 1 rad = 180.0/PI °
|
|
194358
|
-
{ name: "Units.ARC_DEG", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 180.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "°" },
|
|
194359
|
-
{ name: "Units.ARC_MINUTE", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 10800.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "'" },
|
|
194360
|
-
{ name: "Units.ARC_SECOND", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 648000.0, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: '"' },
|
|
194361
|
-
{ name: "Units.GRAD", phenomenon: "Units.ANGLE", system: "Units.METRIC", conversion: { numerator: 200, denominator: 3.141592653589793, offset: 0.0 }, displayLabel: "grad" },
|
|
194362
|
-
// Time ( base unit second )
|
|
194363
|
-
{ name: "Units.S", phenomenon: "Units.TIME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "s" },
|
|
194364
|
-
{ name: "Units.MIN", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 60.0, offset: 0.0 }, displayLabel: "min" },
|
|
194365
|
-
{ name: "Units.HR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 3600.0, offset: 0.0 }, displayLabel: "h" },
|
|
194366
|
-
{ name: "Units.DAY", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 86400.0, offset: 0.0 }, displayLabel: "days" },
|
|
194367
|
-
{ name: "Units.WEEK", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 604800.0, offset: 0.0 }, displayLabel: "weeks" },
|
|
194368
|
-
// 1 sec = 1/31536000.0 yr
|
|
194369
|
-
{ name: "Units.YR", phenomenon: "Units.TIME", system: "Units.INTERNATIONAL", conversion: { numerator: 1.0, denominator: 31536000.0, offset: 0.0 }, displayLabel: "years" },
|
|
194370
|
-
// conversion => specified unit to base unit of m
|
|
194371
|
-
{ name: "Units.M", phenomenon: "Units.LENGTH", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m" },
|
|
194372
|
-
{ name: "Units.MM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "mm" },
|
|
194373
|
-
{ name: "Units.CM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 100.0, denominator: 1.0, offset: 0.0 }, displayLabel: "cm" },
|
|
194374
|
-
{ name: "Units.DM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 10.0, denominator: 1.0, offset: 0.0 }, displayLabel: "dm" },
|
|
194375
|
-
{ name: "Units.KM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1.0, denominator: 1000.0, offset: 0.0 }, displayLabel: "km" },
|
|
194376
|
-
{ name: "Units.UM", phenomenon: "Units.LENGTH", system: "Units.METRIC", conversion: { numerator: 1000000.0, denominator: 1.0, offset: 0.0 }, displayLabel: "µm" },
|
|
194377
|
-
{ name: "Units.MILLIINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "mil" },
|
|
194378
|
-
{ name: "Units.MICROINCH", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000000.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "µin" },
|
|
194379
|
-
{ name: "Units.MILLIFOOT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1000.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "mft" },
|
|
194380
|
-
{ name: "Units.IN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.0254, offset: 0.0 }, displayLabel: "in" },
|
|
194381
|
-
{ name: "Units.FT", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.3048, offset: 0.0 }, displayLabel: "ft" },
|
|
194382
|
-
{ name: "Units.CHAIN", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 66.0 * 0.3048, offset: 0.0 }, displayLabel: "chain" },
|
|
194383
|
-
{ name: "Units.YRD", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.9144, offset: 0.0 }, displayLabel: "yd" },
|
|
194384
|
-
{ name: "Units.MILE", phenomenon: "Units.LENGTH", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 1609.344, offset: 0.0 }, displayLabel: "mi" },
|
|
194385
|
-
{ name: "Units.US_SURVEY_FT", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 1200.0, offset: 0.0 }, displayLabel: "ft (US Survey)" },
|
|
194386
|
-
{ name: "Units.US_SURVEY_YRD", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 3.0 * 1200.0, offset: 0.0 }, displayLabel: "yrd (US Survey)" },
|
|
194387
|
-
{ name: "Units.US_SURVEY_IN", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 100.0, offset: 0.0 }, displayLabel: "in (US Survey)" },
|
|
194388
|
-
{ name: "Units.US_SURVEY_MILE", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 3937.0, denominator: 5280.0 * 1200.0, offset: 0.0 }, displayLabel: "mi (US Survey)" },
|
|
194389
|
-
{ name: "Units.US_SURVEY_CHAIN", phenomenon: "Units.LENGTH", system: "Units.USSURVEY", conversion: { numerator: 1.0, denominator: 20.11684, offset: 0.0 }, displayLabel: "chain (US Survey)" },
|
|
194390
|
-
// conversion => specified unit to base unit of m²
|
|
194391
|
-
{ name: "Units.SQ_FT", phenomenon: "Units.AREA", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: .09290304, offset: 0.0 }, displayLabel: "ft²" },
|
|
194392
|
-
{ name: "Units.SQ_US_SURVEY_FT", phenomenon: "Units.AREA", system: "Units.USCUSTOM", conversion: { numerator: 15499969.0, denominator: 1440000, offset: 0.0 }, displayLabel: "ft² (US Survey)" },
|
|
194393
|
-
{ name: "Units.SQ_M", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m²" },
|
|
194394
|
-
{ name: "Units.SQ_KM", phenomenon: "Units.AREA", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1000000.0, offset: 0.0 }, displayLabel: "km²" },
|
|
194395
|
-
// conversion => specified unit to base unit m³
|
|
194396
|
-
{ name: "Units.CUB_FT", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.028316847, offset: 0.0 }, displayLabel: "ft³" },
|
|
194397
|
-
{ name: "Units.CUB_US_SURVEY_FT", phenomenon: "Units.VOLUME", system: "Units.USSURVEY", conversion: { numerator: 1, denominator: 0.0283170164937591, offset: 0.0 }, displayLabel: "ft³" },
|
|
194398
|
-
{ name: "Units.CUB_YRD", phenomenon: "Units.VOLUME", system: "Units.USCUSTOM", conversion: { numerator: 1.0, denominator: 0.76455486, offset: 0.0 }, displayLabel: "yd³" },
|
|
194399
|
-
{ name: "Units.CUB_M", phenomenon: "Units.VOLUME", system: "Units.SI", conversion: { numerator: 1.0, denominator: 1.0, offset: 0.0 }, displayLabel: "m³" },
|
|
194400
|
-
];
|
|
194401
|
-
|
|
194402
|
-
|
|
194403
194026
|
/***/ }),
|
|
194404
194027
|
|
|
194405
194028
|
/***/ "../../core/frontend/lib/esm/quantity-formatting/LocalUnitFormatProvider.js":
|
|
@@ -194507,7 +194130,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
194507
194130
|
/* harmony import */ var _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-quantity */ "../../core/quantity/lib/esm/core-quantity.js");
|
|
194508
194131
|
/* harmony import */ var _common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/FrontendLoggerCategory */ "../../core/frontend/lib/esm/common/FrontendLoggerCategory.js");
|
|
194509
194132
|
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
194510
|
-
/* harmony import */ var
|
|
194133
|
+
/* harmony import */ var _AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./AlternateUnitLabels */ "../../core/frontend/lib/esm/quantity-formatting/AlternateUnitLabels.js");
|
|
194511
194134
|
/*---------------------------------------------------------------------------------------------
|
|
194512
194135
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
194513
194136
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -194715,8 +194338,8 @@ class FormatsProviderManager {
|
|
|
194715
194338
|
*/
|
|
194716
194339
|
class QuantityFormatter {
|
|
194717
194340
|
static _allUnitSystems = ["metric", "imperial", "usCustomary", "usSurvey"];
|
|
194718
|
-
_unitsProvider = new
|
|
194719
|
-
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,
|
|
194341
|
+
_unitsProvider = new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider();
|
|
194342
|
+
_alternateUnitLabelsRegistry = new AlternateUnitLabelsRegistry((0,_AlternateUnitLabels__WEBPACK_IMPORTED_MODULE_4__.getDefaultAlternateUnitLabels)());
|
|
194720
194343
|
/** Registry containing available quantity type definitions. */
|
|
194721
194344
|
_quantityTypeRegistry = new Map();
|
|
194722
194345
|
/** Registry containing available FormatterSpec and ParserSpec, mapped by keys.
|
|
@@ -195168,9 +194791,10 @@ class QuantityFormatter {
|
|
|
195168
194791
|
* `IModelApp.toolAdmin.restartPrimitiveTool()` to allow the tool to reinitialize itself.
|
|
195169
194792
|
*/
|
|
195170
194793
|
async resetToUseInternalUnitsProvider() {
|
|
195171
|
-
|
|
194794
|
+
// Coupled to createUnitsProvider() returning BasicUnitsProvider directly when no primary is set.
|
|
194795
|
+
if (this._unitsProvider instanceof _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider)
|
|
195172
194796
|
return;
|
|
195173
|
-
await this.setUnitsProvider(new
|
|
194797
|
+
await this.setUnitsProvider(new _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_1__.BasicUnitsProvider());
|
|
195174
194798
|
}
|
|
195175
194799
|
/** Async call to register a CustomQuantityType and load the FormatSpec and ParserSpec for the new type. */
|
|
195176
194800
|
async registerQuantityType(entry, replace) {
|
|
@@ -195458,7 +195082,10 @@ class QuantityFormatter {
|
|
|
195458
195082
|
}
|
|
195459
195083
|
/** Returns data needed to convert from one Unit to another in the same Unit Family/Phenomenon. */
|
|
195460
195084
|
async getConversion(fromUnit, toUnit) {
|
|
195461
|
-
|
|
195085
|
+
const result = await this._unitsProvider.getConversion(fromUnit, toUnit);
|
|
195086
|
+
if (result.error)
|
|
195087
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning(`${_common_FrontendLoggerCategory__WEBPACK_IMPORTED_MODULE_2__.FrontendLoggerCategory.Package}.quantityFormatter`, `Unit conversion from "${fromUnit.name}" to "${toUnit.name}" could not be resolved.`);
|
|
195088
|
+
return result;
|
|
195462
195089
|
}
|
|
195463
195090
|
/**
|
|
195464
195091
|
* Creates a [[FormatterSpec]] for a given persistence unit name and format properties, using the [[UnitsProvider]] to resolve the persistence unit.
|
|
@@ -345490,6 +345117,362 @@ class UrlFS extends _FileStorage__WEBPACK_IMPORTED_MODULE_6__.FileStorage {
|
|
|
345490
345117
|
}
|
|
345491
345118
|
|
|
345492
345119
|
|
|
345120
|
+
/***/ }),
|
|
345121
|
+
|
|
345122
|
+
/***/ "../../core/quantity/lib/esm/BasicUnitsProvider.js":
|
|
345123
|
+
/*!*********************************************************!*\
|
|
345124
|
+
!*** ../../core/quantity/lib/esm/BasicUnitsProvider.js ***!
|
|
345125
|
+
\*********************************************************/
|
|
345126
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
345127
|
+
|
|
345128
|
+
"use strict";
|
|
345129
|
+
__webpack_require__.r(__webpack_exports__);
|
|
345130
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
345131
|
+
/* harmony export */ BasicUnitsProvider: () => (/* binding */ BasicUnitsProvider),
|
|
345132
|
+
/* harmony export */ _testResetUnitsCache: () => (/* binding */ _testResetUnitsCache)
|
|
345133
|
+
/* harmony export */ });
|
|
345134
|
+
/* harmony import */ var _Interfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Interfaces */ "../../core/quantity/lib/esm/Interfaces.js");
|
|
345135
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
345136
|
+
/* harmony import */ var _UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./UnitConversion/nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
345137
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
345138
|
+
/*---------------------------------------------------------------------------------------------
|
|
345139
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
345140
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
345141
|
+
*--------------------------------------------------------------------------------------------*/
|
|
345142
|
+
|
|
345143
|
+
|
|
345144
|
+
|
|
345145
|
+
|
|
345146
|
+
// Module-level cache: the unit data is derived deterministically from the bundled Units.json
|
|
345147
|
+
// asset, so the resolved indexes are effectively an immutable constant. Caching at module
|
|
345148
|
+
// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.
|
|
345149
|
+
// in tests or when composed inside CompositeUnitsProvider).
|
|
345150
|
+
// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint
|
|
345151
|
+
// near-zero until a provider method is actually called.
|
|
345152
|
+
let _resolvePromise;
|
|
345153
|
+
let _permanentError;
|
|
345154
|
+
async function resolveState() {
|
|
345155
|
+
if (_permanentError !== undefined) {
|
|
345156
|
+
throw _permanentError;
|
|
345157
|
+
}
|
|
345158
|
+
if (!_resolvePromise) {
|
|
345159
|
+
_resolvePromise = _buildState().catch((err) => {
|
|
345160
|
+
_permanentError = err instanceof Error ? err : new Error(String(err));
|
|
345161
|
+
_resolvePromise = undefined;
|
|
345162
|
+
throw _permanentError;
|
|
345163
|
+
});
|
|
345164
|
+
}
|
|
345165
|
+
return _resolvePromise;
|
|
345166
|
+
}
|
|
345167
|
+
/** @internal — test use only. Resets the module-level lazy cache. */
|
|
345168
|
+
function _testResetUnitsCache() {
|
|
345169
|
+
_resolvePromise = undefined;
|
|
345170
|
+
_permanentError = undefined;
|
|
345171
|
+
}
|
|
345172
|
+
async function _buildState() {
|
|
345173
|
+
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));
|
|
345174
|
+
const nameMap = new Map();
|
|
345175
|
+
const labelMap = new Map();
|
|
345176
|
+
const phenomenonMap = new Map();
|
|
345177
|
+
const invertedUnits = new Map();
|
|
345178
|
+
const s = schema;
|
|
345179
|
+
const resolver = new _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_1__.UnitDefinitionResolver(s);
|
|
345180
|
+
const resolved = resolver.resolveAll();
|
|
345181
|
+
for (const [name, entry] of resolved) {
|
|
345182
|
+
const item = s.items[name];
|
|
345183
|
+
const phenomenon = item.phenomenon;
|
|
345184
|
+
const unitSystem = item.unitSystem;
|
|
345185
|
+
const fullName = `${s.name}.${name}`;
|
|
345186
|
+
const props = {
|
|
345187
|
+
name: fullName,
|
|
345188
|
+
label: entry.label,
|
|
345189
|
+
phenomenon,
|
|
345190
|
+
isValid: true,
|
|
345191
|
+
system: unitSystem,
|
|
345192
|
+
};
|
|
345193
|
+
const indexed = { props, resolved: entry };
|
|
345194
|
+
nameMap.set(fullName, indexed);
|
|
345195
|
+
const lowerLabel = entry.label.toLowerCase();
|
|
345196
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
345197
|
+
byLabel.push(indexed);
|
|
345198
|
+
labelMap.set(lowerLabel, byLabel);
|
|
345199
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
345200
|
+
byPhen.push(indexed);
|
|
345201
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
345202
|
+
}
|
|
345203
|
+
// Handle InvertedUnit items — must run after nameMap is fully populated above because
|
|
345204
|
+
// invertedSource lookup requires the inverted unit's target to already be in nameMap.
|
|
345205
|
+
for (const [name, item] of Object.entries(s.items)) {
|
|
345206
|
+
if (item.schemaItemType !== "InvertedUnit") {
|
|
345207
|
+
continue;
|
|
345208
|
+
}
|
|
345209
|
+
const inv = item;
|
|
345210
|
+
const fullName = `${s.name}.${name}`;
|
|
345211
|
+
const invertsName = (0,_UnitConversion_nameUtils__WEBPACK_IMPORTED_MODULE_2__.qualifyItemName)(inv.invertsUnit, s.name);
|
|
345212
|
+
const unitSystem = inv.unitSystem;
|
|
345213
|
+
const invertedSource = nameMap.get(invertsName);
|
|
345214
|
+
const phenomenon = invertedSource?.props.phenomenon ?? "";
|
|
345215
|
+
const props = {
|
|
345216
|
+
name: fullName,
|
|
345217
|
+
label: inv.label ?? name,
|
|
345218
|
+
phenomenon,
|
|
345219
|
+
isValid: true,
|
|
345220
|
+
system: unitSystem,
|
|
345221
|
+
};
|
|
345222
|
+
invertedUnits.set(fullName, { props, invertsUnitName: invertsName });
|
|
345223
|
+
if (invertedSource) {
|
|
345224
|
+
const indexed = {
|
|
345225
|
+
props,
|
|
345226
|
+
resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },
|
|
345227
|
+
};
|
|
345228
|
+
nameMap.set(fullName, indexed);
|
|
345229
|
+
const lowerLabel = props.label.toLowerCase();
|
|
345230
|
+
const byLabel = labelMap.get(lowerLabel) ?? [];
|
|
345231
|
+
byLabel.push(indexed);
|
|
345232
|
+
labelMap.set(lowerLabel, byLabel);
|
|
345233
|
+
const byPhen = phenomenonMap.get(phenomenon) ?? [];
|
|
345234
|
+
byPhen.push(indexed);
|
|
345235
|
+
phenomenonMap.set(phenomenon, byPhen);
|
|
345236
|
+
}
|
|
345237
|
+
}
|
|
345238
|
+
return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };
|
|
345239
|
+
}
|
|
345240
|
+
/**
|
|
345241
|
+
* A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.
|
|
345242
|
+
*
|
|
345243
|
+
* The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method
|
|
345244
|
+
* call and cached at module scope — construction is essentially free, and multiple instances
|
|
345245
|
+
* share the same immutable lookup indexes.
|
|
345246
|
+
*
|
|
345247
|
+
* This is the zero-dependency default for backends, tools, and any frontend that doesn't need
|
|
345248
|
+
* iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.
|
|
345249
|
+
*
|
|
345250
|
+
* @see createUnitsProvider for layering schema-defined units on top of basic BIS units.
|
|
345251
|
+
* @beta
|
|
345252
|
+
*/
|
|
345253
|
+
class BasicUnitsProvider {
|
|
345254
|
+
// ── UnitsProvider implementation ─────────────────────────────────────
|
|
345255
|
+
/** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.
|
|
345256
|
+
* @param unitLabel - The display label to search for (case-insensitive).
|
|
345257
|
+
* @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `"Units"`.
|
|
345258
|
+
* @param phenomenon - Optional phenomenon filter (e.g. `"Units.LENGTH"`).
|
|
345259
|
+
* @param unitSystem - Optional unit system filter (e.g. `"Units.METRIC"`).
|
|
345260
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if no match is found.
|
|
345261
|
+
*/
|
|
345262
|
+
async findUnit(unitLabel, schemaName, phenomenon, unitSystem) {
|
|
345263
|
+
const state = await resolveState();
|
|
345264
|
+
if (schemaName && schemaName !== state.schemaName) {
|
|
345265
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345266
|
+
}
|
|
345267
|
+
const candidates = state.labelMap.get(unitLabel.toLowerCase());
|
|
345268
|
+
if (!candidates || candidates.length === 0) {
|
|
345269
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345270
|
+
}
|
|
345271
|
+
for (const c of candidates) {
|
|
345272
|
+
if (phenomenon && c.props.phenomenon !== phenomenon) {
|
|
345273
|
+
continue;
|
|
345274
|
+
}
|
|
345275
|
+
if (unitSystem && c.props.system !== unitSystem) {
|
|
345276
|
+
continue;
|
|
345277
|
+
}
|
|
345278
|
+
return c.props;
|
|
345279
|
+
}
|
|
345280
|
+
return new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345281
|
+
}
|
|
345282
|
+
/** Return all units belonging to the given phenomenon (unit family).
|
|
345283
|
+
* @param phenomenon - The phenomenon full name (e.g. `"Units.LENGTH"`).
|
|
345284
|
+
* @returns An array of matching `UnitProps`, or an empty array if none.
|
|
345285
|
+
*/
|
|
345286
|
+
async getUnitsByFamily(phenomenon) {
|
|
345287
|
+
const state = await resolveState();
|
|
345288
|
+
const entries = state.phenomenonMap.get(phenomenon);
|
|
345289
|
+
return entries ? entries.map((e) => e.props) : [];
|
|
345290
|
+
}
|
|
345291
|
+
/** Find a unit by its fully-qualified name (e.g. `"Units.M"`).
|
|
345292
|
+
* @param unitName - The qualified unit name.
|
|
345293
|
+
* @returns The matching `UnitProps`, or a `BadUnit` if not found.
|
|
345294
|
+
*/
|
|
345295
|
+
async findUnitByName(unitName) {
|
|
345296
|
+
const state = await resolveState();
|
|
345297
|
+
const entry = state.nameMap.get(unitName);
|
|
345298
|
+
return entry ? entry.props : new _Unit__WEBPACK_IMPORTED_MODULE_3__.BadUnit();
|
|
345299
|
+
}
|
|
345300
|
+
/** Compute the conversion factors from `fromUnit` to `toUnit`.
|
|
345301
|
+
* Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.
|
|
345302
|
+
* @param fromUnit - The source unit.
|
|
345303
|
+
* @param toUnit - The target unit.
|
|
345304
|
+
* @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.
|
|
345305
|
+
*/
|
|
345306
|
+
async getConversion(fromUnit, toUnit) {
|
|
345307
|
+
const state = await resolveState();
|
|
345308
|
+
const from = state.nameMap.get(fromUnit.name);
|
|
345309
|
+
const to = state.nameMap.get(toUnit.name);
|
|
345310
|
+
if (!from || !to) {
|
|
345311
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345312
|
+
}
|
|
345313
|
+
const fromInverted = state.invertedUnits.get(fromUnit.name);
|
|
345314
|
+
const toInverted = state.invertedUnits.get(toUnit.name);
|
|
345315
|
+
const fromPhenomenon = fromInverted
|
|
345316
|
+
? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon
|
|
345317
|
+
: from.props.phenomenon;
|
|
345318
|
+
const toPhenomenon = toInverted
|
|
345319
|
+
? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon
|
|
345320
|
+
: to.props.phenomenon;
|
|
345321
|
+
if (fromPhenomenon !== toPhenomenon) {
|
|
345322
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345323
|
+
}
|
|
345324
|
+
if (fromInverted && toInverted) {
|
|
345325
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
345326
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
345327
|
+
if (innerFrom && innerTo) {
|
|
345328
|
+
const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
345329
|
+
return { factor: c.factor, offset: c.offset };
|
|
345330
|
+
}
|
|
345331
|
+
}
|
|
345332
|
+
if (fromInverted) {
|
|
345333
|
+
const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);
|
|
345334
|
+
if (innerFrom) {
|
|
345335
|
+
const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
345336
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPreConversion };
|
|
345337
|
+
}
|
|
345338
|
+
}
|
|
345339
|
+
if (toInverted) {
|
|
345340
|
+
const innerTo = state.nameMap.get(toInverted.invertsUnitName);
|
|
345341
|
+
if (innerTo) {
|
|
345342
|
+
const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);
|
|
345343
|
+
return { factor: c.factor, offset: c.offset, inversion: _Interfaces__WEBPACK_IMPORTED_MODULE_0__.UnitConversionInvert.InvertPostConversion };
|
|
345344
|
+
}
|
|
345345
|
+
}
|
|
345346
|
+
const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);
|
|
345347
|
+
return { factor: conv.factor, offset: conv.offset };
|
|
345348
|
+
}
|
|
345349
|
+
}
|
|
345350
|
+
|
|
345351
|
+
|
|
345352
|
+
/***/ }),
|
|
345353
|
+
|
|
345354
|
+
/***/ "../../core/quantity/lib/esm/CompositeUnitsProvider.js":
|
|
345355
|
+
/*!*************************************************************!*\
|
|
345356
|
+
!*** ../../core/quantity/lib/esm/CompositeUnitsProvider.js ***!
|
|
345357
|
+
\*************************************************************/
|
|
345358
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
345359
|
+
|
|
345360
|
+
"use strict";
|
|
345361
|
+
__webpack_require__.r(__webpack_exports__);
|
|
345362
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
345363
|
+
/* harmony export */ createUnitsProvider: () => (/* binding */ createUnitsProvider)
|
|
345364
|
+
/* harmony export */ });
|
|
345365
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
345366
|
+
/* harmony import */ var _Unit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Unit */ "../../core/quantity/lib/esm/Unit.js");
|
|
345367
|
+
/*---------------------------------------------------------------------------------------------
|
|
345368
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
345369
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
345370
|
+
*--------------------------------------------------------------------------------------------*/
|
|
345371
|
+
|
|
345372
|
+
|
|
345373
|
+
/**
|
|
345374
|
+
* Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional
|
|
345375
|
+
* `primary` provider. Typical use: layer an iModel's schema units on top of the bundled
|
|
345376
|
+
* defaults from `@itwin/core-quantity`.
|
|
345377
|
+
*
|
|
345378
|
+
* Precedence rules:
|
|
345379
|
+
* - When `primary` is supplied and `bisUnitsPolicy` is `"preferSchema"` (the default): `primary` wins;
|
|
345380
|
+
* basic BIS units fill any gaps where `primary` returns an invalid unit or throws.
|
|
345381
|
+
* - When `bisUnitsPolicy` is `"preferBundled"`: basic BIS units win; `primary` is consulted only when the
|
|
345382
|
+
* basic provider can't answer.
|
|
345383
|
+
* - `getUnitsByFamily` always merges results from both providers, deduplicated by
|
|
345384
|
+
* `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.
|
|
345385
|
+
* - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`
|
|
345386
|
+
* (no wrapper), preserving `instanceof` checks and keeping the hot path fast.
|
|
345387
|
+
*
|
|
345388
|
+
* @beta
|
|
345389
|
+
*/
|
|
345390
|
+
function createUnitsProvider(options = {}) {
|
|
345391
|
+
const basic = new _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_0__.BasicUnitsProvider();
|
|
345392
|
+
const primary = options.primary;
|
|
345393
|
+
// NOTE: returns BasicUnitsProvider directly when no primary is provided.
|
|
345394
|
+
// QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.
|
|
345395
|
+
// If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.
|
|
345396
|
+
if (!primary) {
|
|
345397
|
+
return basic;
|
|
345398
|
+
}
|
|
345399
|
+
const providers = options.bisUnitsPolicy === "preferBundled" ? [basic, primary] : [primary, basic];
|
|
345400
|
+
return new CompositeUnitsProvider(providers);
|
|
345401
|
+
}
|
|
345402
|
+
class CompositeUnitsProvider {
|
|
345403
|
+
_providers;
|
|
345404
|
+
constructor(_providers) {
|
|
345405
|
+
this._providers = _providers;
|
|
345406
|
+
}
|
|
345407
|
+
async findUnit(label, schemaName, phenomenon, unitSystem) {
|
|
345408
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345409
|
+
const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));
|
|
345410
|
+
if (hit?.isValid) {
|
|
345411
|
+
return hit;
|
|
345412
|
+
}
|
|
345413
|
+
}
|
|
345414
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
345415
|
+
}
|
|
345416
|
+
async findUnitByName(name) {
|
|
345417
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345418
|
+
const hit = await tryFind(async () => this._providers[i].findUnitByName(name));
|
|
345419
|
+
if (hit?.isValid) {
|
|
345420
|
+
return hit;
|
|
345421
|
+
}
|
|
345422
|
+
}
|
|
345423
|
+
return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new _Unit__WEBPACK_IMPORTED_MODULE_1__.BadUnit());
|
|
345424
|
+
}
|
|
345425
|
+
async getUnitsByFamily(phenomenon) {
|
|
345426
|
+
const seen = new Set();
|
|
345427
|
+
const out = [];
|
|
345428
|
+
// Query all providers in parallel; process results in declaration order to honour precedence.
|
|
345429
|
+
const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));
|
|
345430
|
+
for (const units of results) {
|
|
345431
|
+
for (const u of units) {
|
|
345432
|
+
if (!seen.has(u.name)) {
|
|
345433
|
+
seen.add(u.name);
|
|
345434
|
+
out.push(u);
|
|
345435
|
+
}
|
|
345436
|
+
}
|
|
345437
|
+
}
|
|
345438
|
+
return out;
|
|
345439
|
+
}
|
|
345440
|
+
async getConversion(from, to) {
|
|
345441
|
+
for (let i = 0; i < this._providers.length - 1; i++) {
|
|
345442
|
+
try {
|
|
345443
|
+
const result = await this._providers[i].getConversion(from, to);
|
|
345444
|
+
if (!result.error) {
|
|
345445
|
+
return result;
|
|
345446
|
+
}
|
|
345447
|
+
}
|
|
345448
|
+
catch { /* fall through to next provider */ }
|
|
345449
|
+
}
|
|
345450
|
+
try {
|
|
345451
|
+
return await this._providers[this._providers.length - 1].getConversion(from, to);
|
|
345452
|
+
}
|
|
345453
|
+
catch {
|
|
345454
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
345455
|
+
}
|
|
345456
|
+
}
|
|
345457
|
+
}
|
|
345458
|
+
async function tryFind(fn) {
|
|
345459
|
+
try {
|
|
345460
|
+
return await fn();
|
|
345461
|
+
}
|
|
345462
|
+
catch {
|
|
345463
|
+
return undefined;
|
|
345464
|
+
}
|
|
345465
|
+
}
|
|
345466
|
+
async function tryList(fn) {
|
|
345467
|
+
try {
|
|
345468
|
+
return await fn();
|
|
345469
|
+
}
|
|
345470
|
+
catch {
|
|
345471
|
+
return [];
|
|
345472
|
+
}
|
|
345473
|
+
}
|
|
345474
|
+
|
|
345475
|
+
|
|
345493
345476
|
/***/ }),
|
|
345494
345477
|
|
|
345495
345478
|
/***/ "../../core/quantity/lib/esm/Constants.js":
|
|
@@ -347286,8 +347269,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347286
347269
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
347287
347270
|
/* harmony export */ FormatterSpec: () => (/* binding */ FormatterSpec)
|
|
347288
347271
|
/* harmony export */ });
|
|
347289
|
-
/* harmony import */ var
|
|
347290
|
-
/* harmony import */ var
|
|
347272
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
347273
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
347274
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
347275
|
+
/* harmony import */ var _Formatter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter */ "../../core/quantity/lib/esm/Formatter/Formatter.js");
|
|
347291
347276
|
/*---------------------------------------------------------------------------------------------
|
|
347292
347277
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
347293
347278
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -347297,6 +347282,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347297
347282
|
*/
|
|
347298
347283
|
|
|
347299
347284
|
|
|
347285
|
+
|
|
347286
|
+
|
|
347300
347287
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
347301
347288
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
347302
347289
|
/** 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.
|
|
@@ -347350,6 +347337,9 @@ class FormatterSpec {
|
|
|
347350
347337
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
347351
347338
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
347352
347339
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
347340
|
+
if (denominatorToNumerator.error) {
|
|
347341
|
+
_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.`);
|
|
347342
|
+
}
|
|
347353
347343
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
347354
347344
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
347355
347345
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -347400,7 +347390,7 @@ class FormatterSpec {
|
|
|
347400
347390
|
}
|
|
347401
347391
|
}
|
|
347402
347392
|
// Handle 2-unit composite for ratio formats (scale factors)
|
|
347403
|
-
if (format.type ===
|
|
347393
|
+
if (format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
347404
347394
|
return FormatterSpec.getRatioUnitConversions(format.units, unitsProvider, persistenceUnit);
|
|
347405
347395
|
}
|
|
347406
347396
|
if (format.units) {
|
|
@@ -347409,6 +347399,9 @@ class FormatterSpec {
|
|
|
347409
347399
|
let unitConversion;
|
|
347410
347400
|
if (convertFromUnit) {
|
|
347411
347401
|
unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
|
|
347402
|
+
if (unitConversion.error) {
|
|
347403
|
+
_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.`);
|
|
347404
|
+
}
|
|
347412
347405
|
}
|
|
347413
347406
|
else {
|
|
347414
347407
|
unitConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347441,6 +347434,9 @@ class FormatterSpec {
|
|
|
347441
347434
|
if (format.azimuthBaseUnit !== undefined) {
|
|
347442
347435
|
if (inputUnit !== undefined) {
|
|
347443
347436
|
azimuthBaseConversion = await unitsProvider.getConversion(format.azimuthBaseUnit, inputUnit);
|
|
347437
|
+
if (azimuthBaseConversion.error) {
|
|
347438
|
+
_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.`);
|
|
347439
|
+
}
|
|
347444
347440
|
}
|
|
347445
347441
|
else {
|
|
347446
347442
|
azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347450,6 +347446,9 @@ class FormatterSpec {
|
|
|
347450
347446
|
if (format.revolutionUnit !== undefined) {
|
|
347451
347447
|
if (inputUnit !== undefined) {
|
|
347452
347448
|
revolutionConversion = await unitsProvider.getConversion(format.revolutionUnit, inputUnit);
|
|
347449
|
+
if (revolutionConversion.error) {
|
|
347450
|
+
_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.`);
|
|
347451
|
+
}
|
|
347453
347452
|
}
|
|
347454
347453
|
else {
|
|
347455
347454
|
revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -347459,7 +347458,7 @@ class FormatterSpec {
|
|
|
347459
347458
|
}
|
|
347460
347459
|
/** Format a quantity value. */
|
|
347461
347460
|
applyFormatting(magnitude) {
|
|
347462
|
-
return
|
|
347461
|
+
return _Formatter__WEBPACK_IMPORTED_MODULE_3__.Formatter.formatQuantity(magnitude, this);
|
|
347463
347462
|
}
|
|
347464
347463
|
}
|
|
347465
347464
|
|
|
@@ -347594,10 +347593,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347594
347593
|
/* harmony export */ ParseError: () => (/* binding */ ParseError),
|
|
347595
347594
|
/* harmony export */ Parser: () => (/* binding */ Parser)
|
|
347596
347595
|
/* harmony export */ });
|
|
347597
|
-
/* harmony import */ var
|
|
347598
|
-
/* harmony import */ var
|
|
347599
|
-
/* harmony import */ var
|
|
347600
|
-
/* harmony import */ var
|
|
347596
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
347597
|
+
/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants */ "../../core/quantity/lib/esm/Constants.js");
|
|
347598
|
+
/* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Exception */ "../../core/quantity/lib/esm/Exception.js");
|
|
347599
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
347600
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
347601
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
347601
347602
|
/*---------------------------------------------------------------------------------------------
|
|
347602
347603
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
347603
347604
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -347609,6 +347610,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
347609
347610
|
|
|
347610
347611
|
|
|
347611
347612
|
|
|
347613
|
+
|
|
347614
|
+
|
|
347612
347615
|
/** Possible parser errors
|
|
347613
347616
|
* @beta
|
|
347614
347617
|
*/
|
|
@@ -347702,7 +347705,7 @@ class Parser {
|
|
|
347702
347705
|
let i = index + 1;
|
|
347703
347706
|
for (; i < stringToParse.length; i++) {
|
|
347704
347707
|
const charCode = stringToParse.charCodeAt(i);
|
|
347705
|
-
if (Parser.isDigit(charCode) || ((charCode ===
|
|
347708
|
+
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)))) {
|
|
347706
347709
|
exponentString = exponentString.concat(stringToParse[i]);
|
|
347707
347710
|
}
|
|
347708
347711
|
else {
|
|
@@ -347710,7 +347713,7 @@ class Parser {
|
|
|
347710
347713
|
break;
|
|
347711
347714
|
}
|
|
347712
347715
|
}
|
|
347713
|
-
if (exponentString.length > 1 || ((exponentString.length === 1) && (exponentString.charCodeAt(0) !==
|
|
347716
|
+
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)))
|
|
347714
347717
|
return new ScientificToken(i, exponentString);
|
|
347715
347718
|
return new ScientificToken(index);
|
|
347716
347719
|
}
|
|
@@ -347734,7 +347737,7 @@ class Parser {
|
|
|
347734
347737
|
}
|
|
347735
347738
|
}
|
|
347736
347739
|
else {
|
|
347737
|
-
if (processingNumerator && (charCode ===
|
|
347740
|
+
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)) {
|
|
347738
347741
|
processingNumerator = false;
|
|
347739
347742
|
}
|
|
347740
347743
|
else {
|
|
@@ -347754,7 +347757,7 @@ class Parser {
|
|
|
347754
347757
|
return new FractionToken(index + 1);
|
|
347755
347758
|
}
|
|
347756
347759
|
static isDigit(charCode) {
|
|
347757
|
-
return (charCode >=
|
|
347760
|
+
return (charCode >= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_ZERO) && (charCode <= _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_DIGIT_NINE);
|
|
347758
347761
|
}
|
|
347759
347762
|
static isDigitOrDecimalSeparator(charCode, format) {
|
|
347760
347763
|
return (charCode === format.decimalSeparator.charCodeAt(0)) || Parser.isDigit(charCode);
|
|
@@ -347772,10 +347775,10 @@ class Parser {
|
|
|
347772
347775
|
let uomSeparatorToIgnore = 0;
|
|
347773
347776
|
let fractionDashCode = 0;
|
|
347774
347777
|
const skipCodes = [format.thousandSeparator.charCodeAt(0)];
|
|
347775
|
-
if (format.type ===
|
|
347778
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && format.stationSeparator && format.stationSeparator.length === 1)
|
|
347776
347779
|
skipCodes.push(format.stationSeparator.charCodeAt(0));
|
|
347777
|
-
if (format.type ===
|
|
347778
|
-
fractionDashCode =
|
|
347780
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && format.hasFormatTraitSet(_Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.FractionDash)) {
|
|
347781
|
+
fractionDashCode = _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_MINUS;
|
|
347779
347782
|
}
|
|
347780
347783
|
if (format.uomSeparator && format.uomSeparator !== " " && format.uomSeparator.length === 1) {
|
|
347781
347784
|
uomSeparatorToIgnore = format.uomSeparator.charCodeAt(0);
|
|
@@ -347797,7 +347800,7 @@ class Parser {
|
|
|
347797
347800
|
}
|
|
347798
347801
|
else {
|
|
347799
347802
|
if (processingNumber) {
|
|
347800
|
-
if (charCode ===
|
|
347803
|
+
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) {
|
|
347801
347804
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore, wipToken);
|
|
347802
347805
|
let fraction = fractSymbol.fraction;
|
|
347803
347806
|
i = fractSymbol.index;
|
|
@@ -347815,7 +347818,7 @@ class Parser {
|
|
|
347815
347818
|
}
|
|
347816
347819
|
else {
|
|
347817
347820
|
// a space may signify end of number or start of decimal
|
|
347818
|
-
if (charCode ===
|
|
347821
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE || charCode === fractionDashCode) {
|
|
347819
347822
|
const fractSymbol = Parser.checkForFractions(i + 1, str, uomSeparatorToIgnore);
|
|
347820
347823
|
let fraction = fractSymbol.fraction;
|
|
347821
347824
|
if (fractSymbol.fraction !== 0.0) {
|
|
@@ -347831,7 +347834,7 @@ class Parser {
|
|
|
347831
347834
|
processingNumber = false;
|
|
347832
347835
|
wipToken = "";
|
|
347833
347836
|
}
|
|
347834
|
-
else if (format.type ===
|
|
347837
|
+
else if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && wipToken.length > 0) {
|
|
347835
347838
|
if (signToken.length > 0) {
|
|
347836
347839
|
wipToken = signToken + wipToken;
|
|
347837
347840
|
signToken = "";
|
|
@@ -347844,7 +347847,7 @@ class Parser {
|
|
|
347844
347847
|
}
|
|
347845
347848
|
else {
|
|
347846
347849
|
// an "E" or "e" may signify scientific notation
|
|
347847
|
-
if (charCode ===
|
|
347850
|
+
if (charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_UPPER_E || charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_LOWER_E) {
|
|
347848
347851
|
const exponentSymbol = Parser.checkForScientificNotation(i, str, uomSeparatorToIgnore);
|
|
347849
347852
|
i = exponentSymbol.index;
|
|
347850
347853
|
if (exponentSymbol.exponent && exponentSymbol.exponent.length > 0) {
|
|
@@ -347862,7 +347865,7 @@ class Parser {
|
|
|
347862
347865
|
}
|
|
347863
347866
|
}
|
|
347864
347867
|
}
|
|
347865
|
-
if (format.type ===
|
|
347868
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Station && charCode === format.stationSeparator.charCodeAt(0)) {
|
|
347866
347869
|
if (!isStationSeparatorAdded) {
|
|
347867
347870
|
isStationSeparatorAdded = true;
|
|
347868
347871
|
continue;
|
|
@@ -347888,15 +347891,15 @@ class Parser {
|
|
|
347888
347891
|
else {
|
|
347889
347892
|
// not processing a number
|
|
347890
347893
|
const isCharOperator = isOperator(charCode);
|
|
347891
|
-
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !==
|
|
347894
|
+
const isSpacer = charCode === format.spacerOrDefault.charCodeAt(0) && charCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE;
|
|
347892
347895
|
if (isSpacer && i > 0 && i < str.length - 1) {
|
|
347893
347896
|
const prevCharCode = str.charCodeAt(i - 1);
|
|
347894
|
-
if (isCharOperator && prevCharCode !==
|
|
347897
|
+
if (isCharOperator && prevCharCode !== _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
347895
347898
|
// ignore spacer if it's not at the start or end, not whitespace, and is not in front of a whitespace
|
|
347896
347899
|
continue;
|
|
347897
347900
|
}
|
|
347898
347901
|
}
|
|
347899
|
-
if (wipToken.length === 0 && charCode ===
|
|
347902
|
+
if (wipToken.length === 0 && charCode === _Constants__WEBPACK_IMPORTED_MODULE_1__.QuantityConstants.CHAR_SPACE) {
|
|
347900
347903
|
// Don't add space when the wip token is empty.
|
|
347901
347904
|
continue;
|
|
347902
347905
|
}
|
|
@@ -347988,6 +347991,9 @@ class Parser {
|
|
|
347988
347991
|
else {
|
|
347989
347992
|
// Add new conversion to the list.
|
|
347990
347993
|
const conversion = await unitsProvider.getConversion(unitProps, outUnit);
|
|
347994
|
+
if (conversion.error) {
|
|
347995
|
+
_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.`);
|
|
347996
|
+
}
|
|
347991
347997
|
if (conversion) {
|
|
347992
347998
|
spec = {
|
|
347993
347999
|
conversion,
|
|
@@ -348008,12 +348014,16 @@ class Parser {
|
|
|
348008
348014
|
static async createQuantityFromParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider) {
|
|
348009
348015
|
const unitConversionInfos = await this.getRequiredUnitsConversionsToParseTokens(tokens, format, unitsProvider, altUnitLabelsProvider);
|
|
348010
348016
|
if (unitConversionInfos.outUnit) {
|
|
348011
|
-
const
|
|
348017
|
+
const outUnitConversion = await unitsProvider.getConversion(unitConversionInfos.outUnit, unitConversionInfos.outUnit);
|
|
348018
|
+
if (outUnitConversion.error) {
|
|
348019
|
+
_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.`);
|
|
348020
|
+
}
|
|
348021
|
+
const value = Parser.getQuantityValueFromParseTokens(tokens, format, unitConversionInfos.specs, outUnitConversion);
|
|
348012
348022
|
if (value.ok) {
|
|
348013
|
-
return new
|
|
348023
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(unitConversionInfos.outUnit, value.value);
|
|
348014
348024
|
}
|
|
348015
348025
|
}
|
|
348016
|
-
return new
|
|
348026
|
+
return new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity();
|
|
348017
348027
|
}
|
|
348018
348028
|
/** Async method to generate a Quantity given a string that represents a quantity value and likely a unit label.
|
|
348019
348029
|
* @param inString A string that contains text represent a quantity.
|
|
@@ -348078,7 +348088,7 @@ class Parser {
|
|
|
348078
348088
|
}
|
|
348079
348089
|
// if there were unique unit labels but not matched to any units, throw an error
|
|
348080
348090
|
if (uniqueUnitLabels.length > 0)
|
|
348081
|
-
throw new
|
|
348091
|
+
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.`);
|
|
348082
348092
|
}
|
|
348083
348093
|
return unitConversion;
|
|
348084
348094
|
}
|
|
@@ -348131,10 +348141,10 @@ class Parser {
|
|
|
348131
348141
|
}
|
|
348132
348142
|
catch (e) {
|
|
348133
348143
|
// If we failed to get the default unit conversion, we need to return an error.
|
|
348134
|
-
if (e instanceof
|
|
348144
|
+
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.UnitLabelSuppliedButNotMatched)
|
|
348135
348145
|
return { ok: false, error: ParseError.UnitLabelSuppliedButNotMatched };
|
|
348136
348146
|
}
|
|
348137
|
-
if (format.type ===
|
|
348147
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && format.units !== undefined && format.units.length > 0) {
|
|
348138
348148
|
const units = format.units;
|
|
348139
348149
|
const desiredNumberOfTokens = units.length;
|
|
348140
348150
|
if (tokens.length < desiredNumberOfTokens && tokens[0].isNumber && desiredNumberOfTokens <= 3) {
|
|
@@ -348194,7 +348204,7 @@ class Parser {
|
|
|
348194
348204
|
}
|
|
348195
348205
|
}
|
|
348196
348206
|
if (conversion) {
|
|
348197
|
-
value = (0,
|
|
348207
|
+
value = (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(value, conversion);
|
|
348198
348208
|
}
|
|
348199
348209
|
mag = mag + value;
|
|
348200
348210
|
compositeUnitIndex++;
|
|
@@ -348227,13 +348237,13 @@ class Parser {
|
|
|
348227
348237
|
}
|
|
348228
348238
|
});
|
|
348229
348239
|
}
|
|
348230
|
-
if (parserSpec.format.type ===
|
|
348240
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing) {
|
|
348231
348241
|
return this.parseBearingFormat(inString, parserSpec);
|
|
348232
348242
|
}
|
|
348233
|
-
if (parserSpec.format.type ===
|
|
348243
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
348234
348244
|
return this.parseAzimuthFormat(inString, parserSpec);
|
|
348235
348245
|
}
|
|
348236
|
-
if (parserSpec.format.type ===
|
|
348246
|
+
if (parserSpec.format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
348237
348247
|
return this.parseRatioFormat(inString, parserSpec);
|
|
348238
348248
|
}
|
|
348239
348249
|
return this.parseAndProcessTokens(inString, parserSpec.format, parserSpec.unitConversions);
|
|
@@ -348259,9 +348269,9 @@ class Parser {
|
|
|
348259
348269
|
}
|
|
348260
348270
|
});
|
|
348261
348271
|
}
|
|
348262
|
-
if (format.type ===
|
|
348272
|
+
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) {
|
|
348263
348273
|
// throw error indicating to call parseQuantityString instead
|
|
348264
|
-
throw new
|
|
348274
|
+
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.`);
|
|
348265
348275
|
}
|
|
348266
348276
|
return this.parseAndProcessTokens(inString, format, unitsConversions);
|
|
348267
348277
|
}
|
|
@@ -348274,7 +348284,7 @@ class Parser {
|
|
|
348274
348284
|
const conversion = this.tryFindUnitConversion(specialDirUnit.label, spec.unitConversions, preferredUnit);
|
|
348275
348285
|
if (!conversion)
|
|
348276
348286
|
return { ok: true, value: mag };
|
|
348277
|
-
return { ok: true, value: (0,
|
|
348287
|
+
return { ok: true, value: (0,_Quantity__WEBPACK_IMPORTED_MODULE_5__.applyConversion)(mag, conversion) };
|
|
348278
348288
|
}
|
|
348279
348289
|
static parseBearingFormat(inString, spec) {
|
|
348280
348290
|
const specialDirections = {
|
|
@@ -348364,12 +348374,12 @@ class Parser {
|
|
|
348364
348374
|
let azimuthBase = 0.0;
|
|
348365
348375
|
if (spec.format.azimuthBase !== undefined) {
|
|
348366
348376
|
if (spec.azimuthBaseConversion === undefined) {
|
|
348367
|
-
throw new
|
|
348377
|
+
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.`);
|
|
348368
348378
|
}
|
|
348369
|
-
const azBaseQuantity = new
|
|
348379
|
+
const azBaseQuantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);
|
|
348370
348380
|
const azBaseConverted = azBaseQuantity.convertTo(spec.outUnit, spec.azimuthBaseConversion);
|
|
348371
348381
|
if (!azBaseConverted.isValid) {
|
|
348372
|
-
throw new
|
|
348382
|
+
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}.`);
|
|
348373
348383
|
}
|
|
348374
348384
|
azimuthBase = this.normalizeAngle(azBaseConverted.magnitude, revolution);
|
|
348375
348385
|
}
|
|
@@ -348401,7 +348411,7 @@ class Parser {
|
|
|
348401
348411
|
static parseRatioPart(partStr, format) {
|
|
348402
348412
|
partStr = partStr.trim();
|
|
348403
348413
|
// Parse tokens - fractions are automatically converted to decimal values by parseQuantitySpecification
|
|
348404
|
-
const tempFormat = format.clone({ type:
|
|
348414
|
+
const tempFormat = format.clone({ type: _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal });
|
|
348405
348415
|
const tokens = Parser.parseQuantitySpecification(partStr, tempFormat);
|
|
348406
348416
|
let value = NaN;
|
|
348407
348417
|
let unitLabel;
|
|
@@ -348475,7 +348485,7 @@ class Parser {
|
|
|
348475
348485
|
const defaultUnit = spec.format.units && spec.format.units.length > 0 ? spec.format.units[0][0] : undefined;
|
|
348476
348486
|
const unitConversion = defaultUnit ? Parser.tryFindUnitConversion(defaultUnit.label, spec.unitConversions, defaultUnit) : undefined;
|
|
348477
348487
|
if (!unitConversion) {
|
|
348478
|
-
throw new
|
|
348488
|
+
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}.`);
|
|
348479
348489
|
}
|
|
348480
348490
|
if (denominatorPart.value === 0) {
|
|
348481
348491
|
if (unitConversion.inversion && numeratorPart.value === 1)
|
|
@@ -348485,10 +348495,10 @@ class Parser {
|
|
|
348485
348495
|
}
|
|
348486
348496
|
let quantity;
|
|
348487
348497
|
if (spec.format.units && spec.outUnit) {
|
|
348488
|
-
quantity = new
|
|
348498
|
+
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.units[0][0], numeratorPart.value / denominatorPart.value);
|
|
348489
348499
|
}
|
|
348490
348500
|
else {
|
|
348491
|
-
throw new
|
|
348501
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.MissingRequiredProperty, "Missing presentation unit or persistence unit for ratio format.");
|
|
348492
348502
|
}
|
|
348493
348503
|
let converted;
|
|
348494
348504
|
try {
|
|
@@ -348496,13 +348506,13 @@ class Parser {
|
|
|
348496
348506
|
}
|
|
348497
348507
|
catch (err) {
|
|
348498
348508
|
// for input of "0:N" with reversed unit
|
|
348499
|
-
if (err instanceof
|
|
348509
|
+
if (err instanceof _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityError && err.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_2__.QuantityStatus.InvertingZero) {
|
|
348500
348510
|
return { ok: false, error: ParseError.InvalidMathResult };
|
|
348501
348511
|
}
|
|
348502
348512
|
throw err;
|
|
348503
348513
|
}
|
|
348504
348514
|
if (!converted.isValid) {
|
|
348505
|
-
throw new
|
|
348515
|
+
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}.`);
|
|
348506
348516
|
}
|
|
348507
348517
|
return { ok: true, value: converted.magnitude };
|
|
348508
348518
|
}
|
|
@@ -348515,12 +348525,12 @@ class Parser {
|
|
|
348515
348525
|
}
|
|
348516
348526
|
static getRevolution(spec) {
|
|
348517
348527
|
if (spec.revolutionConversion === undefined) {
|
|
348518
|
-
throw new
|
|
348528
|
+
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.`);
|
|
348519
348529
|
}
|
|
348520
|
-
const revolution = new
|
|
348530
|
+
const revolution = new _Quantity__WEBPACK_IMPORTED_MODULE_5__.Quantity(spec.format.revolutionUnit, 1.0);
|
|
348521
348531
|
const converted = revolution.convertTo(spec.outUnit, spec.revolutionConversion);
|
|
348522
348532
|
if (!converted.isValid) {
|
|
348523
|
-
throw new
|
|
348533
|
+
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}.`);
|
|
348524
348534
|
}
|
|
348525
348535
|
return converted.magnitude;
|
|
348526
348536
|
}
|
|
@@ -348543,6 +348553,9 @@ class Parser {
|
|
|
348543
348553
|
const familyUnits = await unitsProvider.getUnitsByFamily(outUnit.phenomenon);
|
|
348544
348554
|
for (const unit of familyUnits) {
|
|
348545
348555
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
348556
|
+
if (conversion.error) {
|
|
348557
|
+
_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.`);
|
|
348558
|
+
}
|
|
348546
348559
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
348547
348560
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
348548
348561
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -348580,6 +348593,9 @@ class Parser {
|
|
|
348580
348593
|
continue;
|
|
348581
348594
|
}
|
|
348582
348595
|
const conversion = await unitsProvider.getConversion(unit, outUnit);
|
|
348596
|
+
if (conversion.error) {
|
|
348597
|
+
_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.`);
|
|
348598
|
+
}
|
|
348583
348599
|
const parseLabels = [unit.label.toLocaleLowerCase()];
|
|
348584
348600
|
const alternateLabels = altUnitLabelsProvider?.getAlternateUnitLabels(unit);
|
|
348585
348601
|
// add any alternate labels that may be defined for the Unit
|
|
@@ -348624,8 +348640,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348624
348640
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
348625
348641
|
/* harmony export */ ParserSpec: () => (/* binding */ ParserSpec)
|
|
348626
348642
|
/* harmony export */ });
|
|
348627
|
-
/* harmony import */ var
|
|
348628
|
-
/* harmony import */ var
|
|
348643
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
348644
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
348645
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/Parser.js");
|
|
348646
|
+
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
348629
348647
|
/*---------------------------------------------------------------------------------------------
|
|
348630
348648
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
348631
348649
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -348635,6 +348653,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348635
348653
|
*/
|
|
348636
348654
|
|
|
348637
348655
|
|
|
348656
|
+
|
|
348657
|
+
|
|
348638
348658
|
/** A ParserSpec holds information needed to parse a string into a quantity synchronously.
|
|
348639
348659
|
* @beta
|
|
348640
348660
|
*/
|
|
@@ -348667,6 +348687,9 @@ class ParserSpec {
|
|
|
348667
348687
|
const [denominatorUnit, denominatorLabel] = units[1];
|
|
348668
348688
|
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
348669
348689
|
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
348690
|
+
if (denominatorToNumerator.error) {
|
|
348691
|
+
_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.`);
|
|
348692
|
+
}
|
|
348670
348693
|
const displayRatioScale = denominatorToNumerator.factor;
|
|
348671
348694
|
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
348672
348695
|
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
@@ -348715,16 +348738,20 @@ class ParserSpec {
|
|
|
348715
348738
|
static async create(format, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
348716
348739
|
let conversions;
|
|
348717
348740
|
// For ratio formats with 2 composite units, use private helper method
|
|
348718
|
-
if (format.type ===
|
|
348741
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_1__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
348719
348742
|
conversions = await ParserSpec.getRatioUnitConversions(format.units, unitsProvider, outUnit, altUnitLabelsProvider);
|
|
348720
348743
|
}
|
|
348721
348744
|
else {
|
|
348722
|
-
conversions = await
|
|
348745
|
+
conversions = await _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.createUnitConversionSpecsForUnit(unitsProvider, outUnit, altUnitLabelsProvider);
|
|
348723
348746
|
}
|
|
348724
348747
|
const spec = new ParserSpec(outUnit, format, conversions);
|
|
348725
348748
|
if (format.azimuthBaseUnit !== undefined) {
|
|
348726
348749
|
if (outUnit !== undefined) {
|
|
348727
|
-
|
|
348750
|
+
const azimuthResult = await unitsProvider.getConversion(format.azimuthBaseUnit, outUnit);
|
|
348751
|
+
if (azimuthResult.error) {
|
|
348752
|
+
_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.`);
|
|
348753
|
+
}
|
|
348754
|
+
spec._azimuthBaseConversion = azimuthResult;
|
|
348728
348755
|
}
|
|
348729
348756
|
else {
|
|
348730
348757
|
spec._azimuthBaseConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -348732,7 +348759,11 @@ class ParserSpec {
|
|
|
348732
348759
|
}
|
|
348733
348760
|
if (format.revolutionUnit !== undefined) {
|
|
348734
348761
|
if (outUnit !== undefined) {
|
|
348735
|
-
|
|
348762
|
+
const revolutionResult = await unitsProvider.getConversion(format.revolutionUnit, outUnit);
|
|
348763
|
+
if (revolutionResult.error) {
|
|
348764
|
+
_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.`);
|
|
348765
|
+
}
|
|
348766
|
+
spec._revolutionConversion = revolutionResult;
|
|
348736
348767
|
}
|
|
348737
348768
|
else {
|
|
348738
348769
|
spec._revolutionConversion = { factor: 1.0, offset: 0.0 };
|
|
@@ -348742,7 +348773,7 @@ class ParserSpec {
|
|
|
348742
348773
|
}
|
|
348743
348774
|
/** Do the parsing. Done this way to allow Custom Parser Specs to parse custom formatted strings into their quantities. */
|
|
348744
348775
|
parseToQuantityValue(inString) {
|
|
348745
|
-
return
|
|
348776
|
+
return _Parser__WEBPACK_IMPORTED_MODULE_2__.Parser.parseQuantityString(inString, this);
|
|
348746
348777
|
}
|
|
348747
348778
|
}
|
|
348748
348779
|
|
|
@@ -348889,9 +348920,47 @@ var QuantityLoggerCategory;
|
|
|
348889
348920
|
QuantityLoggerCategory["Package"] = "core-quantity";
|
|
348890
348921
|
/** Logger category for quantity formatting operations. */
|
|
348891
348922
|
QuantityLoggerCategory["Formatting"] = "core-quantity.Formatting";
|
|
348923
|
+
/** Logger category for quantity parsing operations. */
|
|
348924
|
+
QuantityLoggerCategory["Parsing"] = "core-quantity.Parsing";
|
|
348892
348925
|
})(QuantityLoggerCategory || (QuantityLoggerCategory = {}));
|
|
348893
348926
|
|
|
348894
348927
|
|
|
348928
|
+
/***/ }),
|
|
348929
|
+
|
|
348930
|
+
/***/ "../../core/quantity/lib/esm/SerializedUnitSchema.js":
|
|
348931
|
+
/*!***********************************************************!*\
|
|
348932
|
+
!*** ../../core/quantity/lib/esm/SerializedUnitSchema.js ***!
|
|
348933
|
+
\***********************************************************/
|
|
348934
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
348935
|
+
|
|
348936
|
+
"use strict";
|
|
348937
|
+
__webpack_require__.r(__webpack_exports__);
|
|
348938
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
348939
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* binding */ SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
348940
|
+
/* harmony export */ });
|
|
348941
|
+
/*---------------------------------------------------------------------------------------------
|
|
348942
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
348943
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
348944
|
+
*--------------------------------------------------------------------------------------------*/
|
|
348945
|
+
/** Current version of the serialization format for `SerializedUnitSchema`.
|
|
348946
|
+
*
|
|
348947
|
+
* This value is written into `Units.json` as the `version` field and checked at
|
|
348948
|
+
* parse time. Two version axes exist:
|
|
348949
|
+
*
|
|
348950
|
+
* - **Format version** (`SERIALIZED_UNIT_SCHEMA_VERSION` / `Units.json.version`): bump
|
|
348951
|
+
* the major version when the shape of the `SerializedUnitSchema` interfaces changes
|
|
348952
|
+
* incompatibly (e.g. renaming fields, removing required properties). Minor bumps for
|
|
348953
|
+
* backward-compatible additions.
|
|
348954
|
+
*
|
|
348955
|
+
* - **Source provenance** (`sourceEcSchemaVersion` inside `Units.json`): records which
|
|
348956
|
+
* version of the BIS Units EC schema the data was derived from (e.g. `"01.00.09"`).
|
|
348957
|
+
* This is a traceability marker, not a runtime contract.
|
|
348958
|
+
*
|
|
348959
|
+
* @internal
|
|
348960
|
+
*/
|
|
348961
|
+
const SERIALIZED_UNIT_SCHEMA_VERSION = "01.00.00";
|
|
348962
|
+
|
|
348963
|
+
|
|
348895
348964
|
/***/ }),
|
|
348896
348965
|
|
|
348897
348966
|
/***/ "../../core/quantity/lib/esm/Unit.js":
|
|
@@ -348945,6 +349014,399 @@ class BadUnit {
|
|
|
348945
349014
|
}
|
|
348946
349015
|
|
|
348947
349016
|
|
|
349017
|
+
/***/ }),
|
|
349018
|
+
|
|
349019
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Graph.js":
|
|
349020
|
+
/*!***********************************************************!*\
|
|
349021
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Graph.js ***!
|
|
349022
|
+
\***********************************************************/
|
|
349023
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349024
|
+
|
|
349025
|
+
"use strict";
|
|
349026
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349027
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349028
|
+
/* harmony export */ UnitConversionGraph: () => (/* binding */ UnitConversionGraph)
|
|
349029
|
+
/* harmony export */ });
|
|
349030
|
+
/*---------------------------------------------------------------------------------------------
|
|
349031
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349032
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349033
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349034
|
+
// Following https://github.com/dagrejs/graphlib/blob/master/lib/graph.js
|
|
349035
|
+
/** @internal */
|
|
349036
|
+
class UnitConversionGraph {
|
|
349037
|
+
_edgeKeyDelim = "\x01";
|
|
349038
|
+
_label = "";
|
|
349039
|
+
_nodeCount = 0;
|
|
349040
|
+
_edgeCount = 0;
|
|
349041
|
+
_nodes;
|
|
349042
|
+
_edgeObjs;
|
|
349043
|
+
_edgeLabels;
|
|
349044
|
+
_outEdges;
|
|
349045
|
+
constructor() {
|
|
349046
|
+
this._nodes = {};
|
|
349047
|
+
this._edgeObjs = {};
|
|
349048
|
+
this._edgeLabels = {};
|
|
349049
|
+
this._outEdges = {};
|
|
349050
|
+
}
|
|
349051
|
+
setGraph = (label) => {
|
|
349052
|
+
this._label = label;
|
|
349053
|
+
return this;
|
|
349054
|
+
};
|
|
349055
|
+
graph = () => {
|
|
349056
|
+
return this._label;
|
|
349057
|
+
};
|
|
349058
|
+
nodeCount = () => {
|
|
349059
|
+
return this._nodeCount;
|
|
349060
|
+
};
|
|
349061
|
+
nodes = () => {
|
|
349062
|
+
return Object.keys(this._nodes);
|
|
349063
|
+
};
|
|
349064
|
+
setNode = (nodeKey, nodeValue) => {
|
|
349065
|
+
if (nodeKey in this._nodes) {
|
|
349066
|
+
this._nodes[nodeKey] = nodeValue;
|
|
349067
|
+
return;
|
|
349068
|
+
}
|
|
349069
|
+
this._nodes[nodeKey] = nodeValue;
|
|
349070
|
+
this._outEdges[nodeKey] = {};
|
|
349071
|
+
++this._nodeCount;
|
|
349072
|
+
};
|
|
349073
|
+
node = (nodeKey) => {
|
|
349074
|
+
return this._nodes[nodeKey];
|
|
349075
|
+
};
|
|
349076
|
+
hasNode = (nodeKey) => {
|
|
349077
|
+
return nodeKey in this._nodes;
|
|
349078
|
+
};
|
|
349079
|
+
edgeCount = () => {
|
|
349080
|
+
return this._edgeCount;
|
|
349081
|
+
};
|
|
349082
|
+
edges = () => {
|
|
349083
|
+
return Object.values(this._edgeObjs);
|
|
349084
|
+
};
|
|
349085
|
+
setEdge = (v, w, value) => {
|
|
349086
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
349087
|
+
if (edgeId in this._edgeLabels) {
|
|
349088
|
+
// Update exponent, specific to this graph's use case
|
|
349089
|
+
this._edgeLabels[edgeId].exponent += value.exponent;
|
|
349090
|
+
return;
|
|
349091
|
+
}
|
|
349092
|
+
this._edgeLabels[edgeId] = value;
|
|
349093
|
+
const edgeObj = {
|
|
349094
|
+
v,
|
|
349095
|
+
w,
|
|
349096
|
+
};
|
|
349097
|
+
this._edgeObjs[edgeId] = edgeObj;
|
|
349098
|
+
// setNode should have ran first, so this.outEdges[v] shouldn't be undefined
|
|
349099
|
+
this._outEdges[v][edgeId] = edgeObj;
|
|
349100
|
+
this._edgeCount++;
|
|
349101
|
+
};
|
|
349102
|
+
edge = (v, w) => {
|
|
349103
|
+
const edgeId = v + this._edgeKeyDelim + w + this._edgeKeyDelim;
|
|
349104
|
+
return this._edgeLabels[edgeId];
|
|
349105
|
+
};
|
|
349106
|
+
outEdges = (v) => {
|
|
349107
|
+
const outV = this._outEdges[v];
|
|
349108
|
+
const edges = Object.values(outV);
|
|
349109
|
+
return edges;
|
|
349110
|
+
};
|
|
349111
|
+
}
|
|
349112
|
+
|
|
349113
|
+
|
|
349114
|
+
/***/ }),
|
|
349115
|
+
|
|
349116
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/Parser.js":
|
|
349117
|
+
/*!************************************************************!*\
|
|
349118
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/Parser.js ***!
|
|
349119
|
+
\************************************************************/
|
|
349120
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349121
|
+
|
|
349122
|
+
"use strict";
|
|
349123
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349124
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349125
|
+
/* harmony export */ parseDefinition: () => (/* binding */ parseDefinition)
|
|
349126
|
+
/* harmony export */ });
|
|
349127
|
+
/*---------------------------------------------------------------------------------------------
|
|
349128
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349129
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349130
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349131
|
+
const expressionRgx = /^(([A-Z]\w*:)?([A-Z]\w*|\[([A-Z]\w*:)?[A-Z]\w*\])(\(-?\d+\))?(\*(?!$)|$))+$/i;
|
|
349132
|
+
const tokenRgx = /(?:(\[)?((?:[A-Z]\w*:)?[A-Z]\w*)\]?)(?:\((-?\d+)\))?/i;
|
|
349133
|
+
const sp = "*";
|
|
349134
|
+
/** @internal */
|
|
349135
|
+
var Tokens;
|
|
349136
|
+
(function (Tokens) {
|
|
349137
|
+
Tokens[Tokens["Bracket"] = 1] = "Bracket";
|
|
349138
|
+
Tokens[Tokens["Word"] = 2] = "Word";
|
|
349139
|
+
Tokens[Tokens["Exponent"] = 3] = "Exponent";
|
|
349140
|
+
})(Tokens || (Tokens = {}));
|
|
349141
|
+
/** @internal */
|
|
349142
|
+
function parseDefinition(definition) {
|
|
349143
|
+
const unitMap = new Map();
|
|
349144
|
+
if (expressionRgx.test(definition)) {
|
|
349145
|
+
for (const unit of definition.split(sp)) {
|
|
349146
|
+
const tokens = unit.split(tokenRgx);
|
|
349147
|
+
const name = tokens[Tokens.Word];
|
|
349148
|
+
const exponent = tokens[Tokens.Exponent] ? Number(tokens[Tokens.Exponent]) : 1;
|
|
349149
|
+
const constant = tokens[Tokens.Bracket] !== undefined;
|
|
349150
|
+
if (unitMap.has(name)) {
|
|
349151
|
+
const currentDefinition = unitMap.get(name);
|
|
349152
|
+
if (currentDefinition)
|
|
349153
|
+
unitMap.set(name, { ...currentDefinition, exponent: currentDefinition.exponent + exponent });
|
|
349154
|
+
}
|
|
349155
|
+
else {
|
|
349156
|
+
unitMap.set(name, { name, exponent, constant });
|
|
349157
|
+
}
|
|
349158
|
+
}
|
|
349159
|
+
return unitMap;
|
|
349160
|
+
}
|
|
349161
|
+
else {
|
|
349162
|
+
throw new Error("Invalid definition expression.");
|
|
349163
|
+
}
|
|
349164
|
+
}
|
|
349165
|
+
|
|
349166
|
+
|
|
349167
|
+
/***/ }),
|
|
349168
|
+
|
|
349169
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js":
|
|
349170
|
+
/*!********************************************************************!*\
|
|
349171
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitConversion.js ***!
|
|
349172
|
+
\********************************************************************/
|
|
349173
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349174
|
+
|
|
349175
|
+
"use strict";
|
|
349176
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349177
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349178
|
+
/* harmony export */ UnitConversion: () => (/* binding */ UnitConversion)
|
|
349179
|
+
/* harmony export */ });
|
|
349180
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
349181
|
+
/*---------------------------------------------------------------------------------------------
|
|
349182
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349183
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349184
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349185
|
+
|
|
349186
|
+
/**
|
|
349187
|
+
* Class used for storing calculated conversion between two Units and converting values from one Unit to another.
|
|
349188
|
+
* @internal
|
|
349189
|
+
*/
|
|
349190
|
+
class UnitConversion {
|
|
349191
|
+
factor;
|
|
349192
|
+
offset;
|
|
349193
|
+
constructor(factor = 1.0, offset = 0.0) {
|
|
349194
|
+
this.factor = factor;
|
|
349195
|
+
this.offset = offset;
|
|
349196
|
+
}
|
|
349197
|
+
/**
|
|
349198
|
+
* Converts x using UnitConversion
|
|
349199
|
+
* @param x Input magnitude to be converted
|
|
349200
|
+
* @returns Output magnitude after conversion
|
|
349201
|
+
*/
|
|
349202
|
+
evaluate(x) {
|
|
349203
|
+
return this.factor * x + this.offset;
|
|
349204
|
+
}
|
|
349205
|
+
/**
|
|
349206
|
+
* Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly
|
|
349207
|
+
* @internal
|
|
349208
|
+
*/
|
|
349209
|
+
inverse() {
|
|
349210
|
+
const inverseFactor = 1.0 / this.factor;
|
|
349211
|
+
return new UnitConversion(inverseFactor, -this.offset * inverseFactor);
|
|
349212
|
+
}
|
|
349213
|
+
/**
|
|
349214
|
+
* Combines two UnitConversions
|
|
349215
|
+
* Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated
|
|
349216
|
+
* @internal
|
|
349217
|
+
*/
|
|
349218
|
+
compose(conversion) {
|
|
349219
|
+
return new UnitConversion(this.factor * conversion.factor, conversion.factor * this.offset + conversion.offset);
|
|
349220
|
+
}
|
|
349221
|
+
/**
|
|
349222
|
+
* Multiples two UnitConversions together to calculate factor during reducing
|
|
349223
|
+
* @internal
|
|
349224
|
+
*/
|
|
349225
|
+
multiply(conversion) {
|
|
349226
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(conversion.offset, 0.0) && (0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
349227
|
+
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
349228
|
+
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
349229
|
+
}
|
|
349230
|
+
/**
|
|
349231
|
+
* Raise UnitConversion's factor with power exponent to calculate factor during reducing
|
|
349232
|
+
* @internal
|
|
349233
|
+
*/
|
|
349234
|
+
raise(power) {
|
|
349235
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 1.0))
|
|
349236
|
+
return new UnitConversion(this.factor, this.offset);
|
|
349237
|
+
else if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(power, 0.0))
|
|
349238
|
+
return new UnitConversion(1.0, 0.0);
|
|
349239
|
+
if ((0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(this.offset, 0.0))
|
|
349240
|
+
return new UnitConversion(this.factor ** power, 0.0);
|
|
349241
|
+
throw new Error("Cannot raise map with non-zero offset");
|
|
349242
|
+
}
|
|
349243
|
+
/** @internal */
|
|
349244
|
+
static identity = new UnitConversion();
|
|
349245
|
+
/**
|
|
349246
|
+
* Returns UnitConversion with source's numerator and denominator in factor and source's offset in offset for reducing.
|
|
349247
|
+
* Accepts any object that structurally satisfies `UnitConversionSource` (e.g. EC `Unit` or `Constant`).
|
|
349248
|
+
* @internal
|
|
349249
|
+
*/
|
|
349250
|
+
static from(source) {
|
|
349251
|
+
const offset = source.offset ?? 0;
|
|
349252
|
+
const hasOffset = !(0,_Quantity__WEBPACK_IMPORTED_MODULE_0__.almostEqual)(offset, 0.0);
|
|
349253
|
+
return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);
|
|
349254
|
+
}
|
|
349255
|
+
}
|
|
349256
|
+
|
|
349257
|
+
|
|
349258
|
+
/***/ }),
|
|
349259
|
+
|
|
349260
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js":
|
|
349261
|
+
/*!****************************************************************************!*\
|
|
349262
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js ***!
|
|
349263
|
+
\****************************************************************************/
|
|
349264
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349265
|
+
|
|
349266
|
+
"use strict";
|
|
349267
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349268
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349269
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* binding */ UnitDefinitionResolver)
|
|
349270
|
+
/* harmony export */ });
|
|
349271
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
349272
|
+
/* harmony import */ var _UnitConversion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
349273
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
349274
|
+
/* harmony import */ var _nameUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nameUtils */ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js");
|
|
349275
|
+
/*---------------------------------------------------------------------------------------------
|
|
349276
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349277
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349278
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349279
|
+
|
|
349280
|
+
|
|
349281
|
+
|
|
349282
|
+
|
|
349283
|
+
const MAX_RESOLUTION_DEPTH = 30;
|
|
349284
|
+
/** Resolves every unit in a `SerializedUnitSchema` to a `UnitConversion` relative to its phenomenon's base unit.
|
|
349285
|
+
* @internal
|
|
349286
|
+
*/
|
|
349287
|
+
class UnitDefinitionResolver {
|
|
349288
|
+
_schema;
|
|
349289
|
+
_cache = new Map();
|
|
349290
|
+
constructor(schema) {
|
|
349291
|
+
if (schema.version !== _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION)
|
|
349292
|
+
throw new Error(`Unsupported Units.json version "${schema.version}". Expected "${_SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_0__.SERIALIZED_UNIT_SCHEMA_VERSION}".`);
|
|
349293
|
+
this._schema = schema;
|
|
349294
|
+
}
|
|
349295
|
+
/** Resolve all Unit items in the schema and return a map from item name to `ResolvedUnit`. */
|
|
349296
|
+
resolveAll() {
|
|
349297
|
+
const result = new Map();
|
|
349298
|
+
for (const [name, item] of Object.entries(this._schema.items)) {
|
|
349299
|
+
if (item.schemaItemType === "Unit") {
|
|
349300
|
+
const conversion = this._resolveUnit(name, 0);
|
|
349301
|
+
result.set(name, {
|
|
349302
|
+
name,
|
|
349303
|
+
label: item.label ?? name,
|
|
349304
|
+
phenomenon: item.phenomenon,
|
|
349305
|
+
unitSystem: item.unitSystem,
|
|
349306
|
+
conversion,
|
|
349307
|
+
});
|
|
349308
|
+
}
|
|
349309
|
+
}
|
|
349310
|
+
return result;
|
|
349311
|
+
}
|
|
349312
|
+
/** Resolve a single unit by unqualified name, returning its conversion to base. */
|
|
349313
|
+
_resolveUnit(name, depth) {
|
|
349314
|
+
if (depth > MAX_RESOLUTION_DEPTH)
|
|
349315
|
+
throw new Error(`Unit resolution depth exceeded ${MAX_RESOLUTION_DEPTH} for "${name}"`);
|
|
349316
|
+
const cached = this._cache.get(name);
|
|
349317
|
+
if (cached)
|
|
349318
|
+
return cached;
|
|
349319
|
+
const item = this._schema.items[name];
|
|
349320
|
+
if (!item)
|
|
349321
|
+
throw new Error(`Unknown schema item: "${name}"`);
|
|
349322
|
+
let conversion;
|
|
349323
|
+
if (item.schemaItemType === "Constant") {
|
|
349324
|
+
conversion = this._resolveConstant(name, item, depth);
|
|
349325
|
+
}
|
|
349326
|
+
else if (item.schemaItemType === "Unit") {
|
|
349327
|
+
conversion = this._resolveUnitItem(name, item, depth);
|
|
349328
|
+
}
|
|
349329
|
+
else {
|
|
349330
|
+
throw new Error(`Cannot resolve item of type "${item.schemaItemType}": "${name}"`);
|
|
349331
|
+
}
|
|
349332
|
+
this._cache.set(name, conversion);
|
|
349333
|
+
return conversion;
|
|
349334
|
+
}
|
|
349335
|
+
_resolveConstant(name, item, depth) {
|
|
349336
|
+
// A constant is identity if its definition is its own name
|
|
349337
|
+
if (item.definition === name)
|
|
349338
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349339
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
349340
|
+
numerator: item.numerator ?? 1,
|
|
349341
|
+
denominator: item.denominator ?? 1,
|
|
349342
|
+
});
|
|
349343
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
349344
|
+
return defConv.compose(selfConv);
|
|
349345
|
+
}
|
|
349346
|
+
_resolveUnitItem(name, item, depth) {
|
|
349347
|
+
// A unit is a base unit if its definition is its own name
|
|
349348
|
+
if (item.definition === name)
|
|
349349
|
+
return _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349350
|
+
const selfConv = _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.from({
|
|
349351
|
+
numerator: item.numerator ?? 1,
|
|
349352
|
+
denominator: item.denominator ?? 1,
|
|
349353
|
+
offset: item.offset,
|
|
349354
|
+
});
|
|
349355
|
+
const defConv = this._resolveDefinition(item.definition, depth + 1);
|
|
349356
|
+
return defConv.compose(selfConv);
|
|
349357
|
+
}
|
|
349358
|
+
/** Parse and resolve a compound definition string like `[MILLI]*M` or `IN`. */
|
|
349359
|
+
_resolveDefinition(definition, depth) {
|
|
349360
|
+
const fragments = (0,_Parser__WEBPACK_IMPORTED_MODULE_2__.parseDefinition)(definition);
|
|
349361
|
+
let result;
|
|
349362
|
+
for (const [, fragment] of fragments) {
|
|
349363
|
+
// Strip alias prefix if present (definitions in the schema use unqualified names)
|
|
349364
|
+
const fragName = (0,_nameUtils__WEBPACK_IMPORTED_MODULE_3__.stripAliasPrefix)(fragment.name);
|
|
349365
|
+
const fragConv = this._resolveUnit(fragName, depth + 1);
|
|
349366
|
+
const raised = fragConv.raise(fragment.exponent);
|
|
349367
|
+
result = result ? result.multiply(raised) : raised;
|
|
349368
|
+
}
|
|
349369
|
+
return result ?? _UnitConversion__WEBPACK_IMPORTED_MODULE_1__.UnitConversion.identity;
|
|
349370
|
+
}
|
|
349371
|
+
}
|
|
349372
|
+
|
|
349373
|
+
|
|
349374
|
+
/***/ }),
|
|
349375
|
+
|
|
349376
|
+
/***/ "../../core/quantity/lib/esm/UnitConversion/nameUtils.js":
|
|
349377
|
+
/*!***************************************************************!*\
|
|
349378
|
+
!*** ../../core/quantity/lib/esm/UnitConversion/nameUtils.js ***!
|
|
349379
|
+
\***************************************************************/
|
|
349380
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349381
|
+
|
|
349382
|
+
"use strict";
|
|
349383
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349384
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349385
|
+
/* harmony export */ qualifyItemName: () => (/* binding */ qualifyItemName),
|
|
349386
|
+
/* harmony export */ stripAliasPrefix: () => (/* binding */ stripAliasPrefix)
|
|
349387
|
+
/* harmony export */ });
|
|
349388
|
+
/*---------------------------------------------------------------------------------------------
|
|
349389
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349390
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349391
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349392
|
+
/** Strips alias prefix from a schema item reference.
|
|
349393
|
+
* `"u:FT"` → `"FT"`, `"FT"` → `"FT"`.
|
|
349394
|
+
* @internal
|
|
349395
|
+
*/
|
|
349396
|
+
function stripAliasPrefix(raw) {
|
|
349397
|
+
return raw.includes(":") ? raw.split(":")[1] : raw;
|
|
349398
|
+
}
|
|
349399
|
+
/** Normalizes a schema item reference to fully-qualified `SchemaName.ItemName` format.
|
|
349400
|
+
* Handles: already qualified (`"Units.FT"`), alias-qualified (`"u:FT"`), unqualified (`"FT"`).
|
|
349401
|
+
* @internal
|
|
349402
|
+
*/
|
|
349403
|
+
function qualifyItemName(raw, schemaName) {
|
|
349404
|
+
if (raw.includes("."))
|
|
349405
|
+
return raw;
|
|
349406
|
+
return `${schemaName}.${stripAliasPrefix(raw)}`;
|
|
349407
|
+
}
|
|
349408
|
+
|
|
349409
|
+
|
|
348948
349410
|
/***/ }),
|
|
348949
349411
|
|
|
348950
349412
|
/***/ "../../core/quantity/lib/esm/core-quantity.js":
|
|
@@ -348959,6 +349421,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348959
349421
|
/* harmony export */ BadUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BadUnit),
|
|
348960
349422
|
/* harmony export */ BaseFormat: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.BaseFormat),
|
|
348961
349423
|
/* harmony export */ BasicUnit: () => (/* reexport safe */ _Unit__WEBPACK_IMPORTED_MODULE_7__.BasicUnit),
|
|
349424
|
+
/* harmony export */ BasicUnitsProvider: () => (/* reexport safe */ _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__.BasicUnitsProvider),
|
|
348962
349425
|
/* harmony export */ DecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.DecimalPrecision),
|
|
348963
349426
|
/* harmony export */ Format: () => (/* reexport safe */ _Formatter_Format__WEBPACK_IMPORTED_MODULE_8__.Format),
|
|
348964
349427
|
/* harmony export */ FormatSpecHandle: () => (/* reexport safe */ _FormatSpecHandle__WEBPACK_IMPORTED_MODULE_2__.FormatSpecHandle),
|
|
@@ -348978,12 +349441,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348978
349441
|
/* harmony export */ QuantityStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus),
|
|
348979
349442
|
/* harmony export */ RatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioFormatType),
|
|
348980
349443
|
/* harmony export */ RatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.RatioType),
|
|
349444
|
+
/* harmony export */ SERIALIZED_UNIT_SCHEMA_VERSION: () => (/* reexport safe */ _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__.SERIALIZED_UNIT_SCHEMA_VERSION),
|
|
348981
349445
|
/* harmony export */ ScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ScientificType),
|
|
348982
349446
|
/* harmony export */ ShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.ShowSignOption),
|
|
349447
|
+
/* harmony export */ UnitConversion: () => (/* reexport safe */ _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__.UnitConversion),
|
|
349448
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.UnitConversionGraph),
|
|
348983
349449
|
/* harmony export */ UnitConversionInvert: () => (/* reexport safe */ _Interfaces__WEBPACK_IMPORTED_MODULE_3__.UnitConversionInvert),
|
|
349450
|
+
/* harmony export */ UnitDefinitionResolver: () => (/* reexport safe */ _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__.UnitDefinitionResolver),
|
|
348984
349451
|
/* harmony export */ almostEqual: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostEqual),
|
|
348985
349452
|
/* harmony export */ almostZero: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.almostZero),
|
|
348986
349453
|
/* harmony export */ applyConversion: () => (/* reexport safe */ _Quantity__WEBPACK_IMPORTED_MODULE_6__.applyConversion),
|
|
349454
|
+
/* harmony export */ createUnitsProvider: () => (/* reexport safe */ _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__.createUnitsProvider),
|
|
348987
349455
|
/* harmony export */ formatStringRgx: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatStringRgx),
|
|
348988
349456
|
/* harmony export */ formatTraitsToArray: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTraitsToArray),
|
|
348989
349457
|
/* harmony export */ formatTypeToString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.formatTypeToString),
|
|
@@ -348991,6 +349459,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
348991
349459
|
/* harmony export */ getTraitString: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.getTraitString),
|
|
348992
349460
|
/* harmony export */ isCustomFormatProps: () => (/* reexport safe */ _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__.isCustomFormatProps),
|
|
348993
349461
|
/* harmony export */ parseDecimalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseDecimalPrecision),
|
|
349462
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__.parseDefinition),
|
|
348994
349463
|
/* harmony export */ parseFormatTrait: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatTrait),
|
|
348995
349464
|
/* harmony export */ parseFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFormatType),
|
|
348996
349465
|
/* harmony export */ parseFractionalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_10__.parseFractionalPrecision),
|
|
@@ -349017,6 +349486,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
349017
349486
|
/* harmony import */ var _Formatter_FormattingReadyCollector__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Formatter/FormattingReadyCollector */ "../../core/quantity/lib/esm/Formatter/FormattingReadyCollector.js");
|
|
349018
349487
|
/* harmony import */ var _Formatter_Interfaces__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Formatter/Interfaces */ "../../core/quantity/lib/esm/Formatter/Interfaces.js");
|
|
349019
349488
|
/* harmony import */ var _QuantityLoggerCategory__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./QuantityLoggerCategory */ "../../core/quantity/lib/esm/QuantityLoggerCategory.js");
|
|
349489
|
+
/* harmony import */ var _UnitConversion_UnitConversion__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./UnitConversion/UnitConversion */ "../../core/quantity/lib/esm/UnitConversion/UnitConversion.js");
|
|
349490
|
+
/* harmony import */ var _UnitConversion_UnitDefinitionResolver__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./UnitConversion/UnitDefinitionResolver */ "../../core/quantity/lib/esm/UnitConversion/UnitDefinitionResolver.js");
|
|
349491
|
+
/* harmony import */ var _SerializedUnitSchema__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SerializedUnitSchema */ "../../core/quantity/lib/esm/SerializedUnitSchema.js");
|
|
349492
|
+
/* harmony import */ var _BasicUnitsProvider__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./BasicUnitsProvider */ "../../core/quantity/lib/esm/BasicUnitsProvider.js");
|
|
349493
|
+
/* harmony import */ var _CompositeUnitsProvider__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./CompositeUnitsProvider */ "../../core/quantity/lib/esm/CompositeUnitsProvider.js");
|
|
349494
|
+
/* harmony import */ var _internal_cross_package__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./internal/cross-package */ "../../core/quantity/lib/esm/internal/cross-package.js");
|
|
349020
349495
|
/*---------------------------------------------------------------------------------------------
|
|
349021
349496
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349022
349497
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -349035,20 +349510,59 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
349035
349510
|
|
|
349036
349511
|
|
|
349037
349512
|
|
|
349513
|
+
|
|
349514
|
+
|
|
349515
|
+
|
|
349516
|
+
|
|
349517
|
+
|
|
349518
|
+
|
|
349038
349519
|
|
|
349039
349520
|
/** @docs-package-description
|
|
349040
|
-
* The core-quantity package
|
|
349521
|
+
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
349041
349522
|
*/
|
|
349042
349523
|
/**
|
|
349043
349524
|
* @docs-group-description Quantity
|
|
349044
349525
|
* Classes, Interfaces, and definitions used to format and parse quantity values.
|
|
349045
349526
|
*/
|
|
349527
|
+
/**
|
|
349528
|
+
* @docs-group-description BasicUnitsProvider
|
|
349529
|
+
* A UnitsProvider backed by the bundled BIS Units schema JSON asset.
|
|
349530
|
+
*/
|
|
349531
|
+
/**
|
|
349532
|
+
* @docs-group-description CompositeUnitsProvider
|
|
349533
|
+
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
349534
|
+
*/
|
|
349046
349535
|
/**
|
|
349047
349536
|
* @docs-group-description Logging
|
|
349048
349537
|
* Logger categories used by this package.
|
|
349049
349538
|
*/
|
|
349050
349539
|
|
|
349051
349540
|
|
|
349541
|
+
/***/ }),
|
|
349542
|
+
|
|
349543
|
+
/***/ "../../core/quantity/lib/esm/internal/cross-package.js":
|
|
349544
|
+
/*!*************************************************************!*\
|
|
349545
|
+
!*** ../../core/quantity/lib/esm/internal/cross-package.js ***!
|
|
349546
|
+
\*************************************************************/
|
|
349547
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
349548
|
+
|
|
349549
|
+
"use strict";
|
|
349550
|
+
__webpack_require__.r(__webpack_exports__);
|
|
349551
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
349552
|
+
/* harmony export */ UnitConversionGraph: () => (/* reexport safe */ _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__.UnitConversionGraph),
|
|
349553
|
+
/* harmony export */ parseDefinition: () => (/* reexport safe */ _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__.parseDefinition)
|
|
349554
|
+
/* harmony export */ });
|
|
349555
|
+
/* harmony import */ var _UnitConversion_Graph__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../UnitConversion/Graph */ "../../core/quantity/lib/esm/UnitConversion/Graph.js");
|
|
349556
|
+
/* harmony import */ var _UnitConversion_Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../UnitConversion/Parser */ "../../core/quantity/lib/esm/UnitConversion/Parser.js");
|
|
349557
|
+
/*---------------------------------------------------------------------------------------------
|
|
349558
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
349559
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
349560
|
+
*--------------------------------------------------------------------------------------------*/
|
|
349561
|
+
// Used by ecschema-metadata (UnitTree.ts)
|
|
349562
|
+
|
|
349563
|
+
|
|
349564
|
+
|
|
349565
|
+
|
|
349052
349566
|
/***/ }),
|
|
349053
349567
|
|
|
349054
349568
|
/***/ "../../core/webgl-compatibility/lib/esm/Capabilities.js":
|
|
@@ -349966,7 +350480,7 @@ class TestContext {
|
|
|
349966
350480
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
349967
350481
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
349968
350482
|
await core_frontend_1.NoRenderApp.startup({
|
|
349969
|
-
applicationVersion: "5.10.0-dev.
|
|
350483
|
+
applicationVersion: "5.10.0-dev.3",
|
|
349970
350484
|
applicationId: this.settings.gprid,
|
|
349971
350485
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
349972
350486
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -350889,7 +351403,7 @@ class UiLayoutDataProvider extends _UiDataProvider__WEBPACK_IMPORTED_MODULE_4__.
|
|
|
350889
351403
|
return this._rows;
|
|
350890
351404
|
}
|
|
350891
351405
|
loadItemsInternal(items) {
|
|
350892
|
-
this._items = items
|
|
351406
|
+
this._items = items ?? [];
|
|
350893
351407
|
this._rows = this.layoutDialogRows();
|
|
350894
351408
|
}
|
|
350895
351409
|
/** Called by UI to request available properties that can be bound to user supplied UI components (See Tool1UiProvider for example). */
|
|
@@ -350898,10 +351412,13 @@ class UiLayoutDataProvider extends _UiDataProvider__WEBPACK_IMPORTED_MODULE_4__.
|
|
|
350898
351412
|
throw (new Error("Derived UiDataProvider must implement this method to supply set of properties."));
|
|
350899
351413
|
}
|
|
350900
351414
|
get items() {
|
|
350901
|
-
|
|
350902
|
-
|
|
350903
|
-
|
|
350904
|
-
|
|
351415
|
+
const items = this._items;
|
|
351416
|
+
if (undefined !== items)
|
|
351417
|
+
return items;
|
|
351418
|
+
this.loadItemsInternal(this.supplyDialogItems());
|
|
351419
|
+
// If _items is undefined, the hook above failed to initialize it
|
|
351420
|
+
// Deemed more honest to use the non-null assertion than explicit cast
|
|
351421
|
+
return this._items; // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
350905
351422
|
}
|
|
350906
351423
|
/** Called to inform listeners that new properties are ready for display in UI. */
|
|
350907
351424
|
reloadDialogItems(emitEvent = true) {
|
|
@@ -351973,14 +352490,14 @@ class BaseQuantityDescription {
|
|
|
351973
352490
|
this.displayLabel = displayLabel;
|
|
351974
352491
|
this.kindOfQuantityName = kindOfQuantityName;
|
|
351975
352492
|
this.typename = _properties_StandardTypeNames__WEBPACK_IMPORTED_MODULE_1__.StandardTypeNames.Number;
|
|
352493
|
+
const editorParams = [{
|
|
352494
|
+
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.CustomFormattedNumber,
|
|
352495
|
+
formatFunction: this.format,
|
|
352496
|
+
parseFunction: this.parse,
|
|
352497
|
+
}];
|
|
351976
352498
|
this.editor = {
|
|
351977
352499
|
name: _properties_StandardEditorNames__WEBPACK_IMPORTED_MODULE_2__.StandardEditorNames.NumberCustom,
|
|
351978
|
-
params:
|
|
351979
|
-
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.CustomFormattedNumber,
|
|
351980
|
-
formatFunction: this.format,
|
|
351981
|
-
parseFunction: this.parse,
|
|
351982
|
-
},
|
|
351983
|
-
],
|
|
352500
|
+
params: editorParams,
|
|
351984
352501
|
};
|
|
351985
352502
|
// istanbul ignore else
|
|
351986
352503
|
if (iconSpec) {
|
|
@@ -351988,7 +352505,7 @@ class BaseQuantityDescription {
|
|
|
351988
352505
|
type: _properties_EditorParams__WEBPACK_IMPORTED_MODULE_0__.PropertyEditorParamTypes.Icon,
|
|
351989
352506
|
definition: { iconSpec },
|
|
351990
352507
|
};
|
|
351991
|
-
|
|
352508
|
+
editorParams.push(params);
|
|
351992
352509
|
}
|
|
351993
352510
|
}
|
|
351994
352511
|
format = (numberValue) => {
|
|
@@ -377241,7 +377758,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
377241
377758
|
/***/ ((module) => {
|
|
377242
377759
|
|
|
377243
377760
|
"use strict";
|
|
377244
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.10.0-dev.
|
|
377761
|
+
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"}}');
|
|
377245
377762
|
|
|
377246
377763
|
/***/ }),
|
|
377247
377764
|
|