@itwin/rpcinterface-full-stack-tests 5.6.0-dev.7 → 5.7.0-dev.1
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 +653 -135
- 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/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_node_modules_loaders_gl_draco_di-40e622.bundled-tests.js → vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9.bundled-tests.js} +79 -79
- package/lib/dist/{vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4_node_modules_loaders_gl_draco_di-40e622.bundled-tests.js.map → vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9.bundled-tests.js.map} +1 -1
- package/package.json +16 -16
|
@@ -81566,7 +81566,7 @@ class TextStyleSettings {
|
|
|
81566
81566
|
listMarker;
|
|
81567
81567
|
/** The frame settings of the [[TextAnnotation]]. */
|
|
81568
81568
|
frame;
|
|
81569
|
-
/**
|
|
81569
|
+
/** Multiplier used to calculate the margins to surround the document content. */
|
|
81570
81570
|
margins;
|
|
81571
81571
|
/** The alignment of the text content. */
|
|
81572
81572
|
justification;
|
|
@@ -100347,6 +100347,18 @@ class JsonParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_2__.AbstractPa
|
|
|
100347
100347
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);
|
|
100348
100348
|
if (undefined !== jsonObj.scientificType && typeof (jsonObj.scientificType) !== "string")
|
|
100349
100349
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'scientificType' attribute. It should be of type 'string'.`);
|
|
100350
|
+
if (undefined !== jsonObj.ratioType && typeof (jsonObj.ratioType) !== "string")
|
|
100351
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'ratioType' attribute. It should be of type 'string'.`);
|
|
100352
|
+
if (undefined !== jsonObj.ratioSeparator && typeof (jsonObj.ratioSeparator) !== "string")
|
|
100353
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);
|
|
100354
|
+
if (undefined !== jsonObj.ratioFormatType && typeof (jsonObj.ratioFormatType) !== "string")
|
|
100355
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'ratioFormatType' attribute. It should be of type 'string'.`);
|
|
100356
|
+
// Validate EC version if ratio properties exist - they require EC version 3.3+
|
|
100357
|
+
if (jsonObj.ratioType !== undefined || jsonObj.ratioSeparator !== undefined || jsonObj.ratioFormatType !== undefined) {
|
|
100358
|
+
if (this._ecSpecVersion === undefined || this._ecSpecVersion.readVersion < 3 || (this._ecSpecVersion.readVersion === 3 && this._ecSpecVersion.writeVersion < 3)) {
|
|
100359
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has ratio properties that require EC version 3.3 or newer.`);
|
|
100360
|
+
}
|
|
100361
|
+
}
|
|
100350
100362
|
if (undefined !== jsonObj.stationOffsetSize && typeof (jsonObj.stationOffsetSize) !== "number")
|
|
100351
100363
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_0__.ECSchemaStatus.InvalidECJson, `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);
|
|
100352
100364
|
if (undefined !== jsonObj.stationSeparator && typeof (jsonObj.stationSeparator) !== "string")
|
|
@@ -101060,6 +101072,15 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
|
|
|
101060
101072
|
const thousandSeparator = this.getOptionalAttribute(xmlElement, "thousandSeparator");
|
|
101061
101073
|
const uomSeparator = this.getOptionalAttribute(xmlElement, "uomSeparator");
|
|
101062
101074
|
const scientificType = this.getOptionalAttribute(xmlElement, "scientificType");
|
|
101075
|
+
const ratioType = this.getOptionalAttribute(xmlElement, "ratioType");
|
|
101076
|
+
const ratioSeparator = this.getOptionalAttribute(xmlElement, "ratioSeparator");
|
|
101077
|
+
const ratioFormatType = this.getOptionalAttribute(xmlElement, "ratioFormatType");
|
|
101078
|
+
// Validate EC version if ratio properties exist - they require EC version 3.3+
|
|
101079
|
+
if (ratioType !== undefined || ratioSeparator !== undefined || ratioFormatType !== undefined) {
|
|
101080
|
+
if (this._ecSpecVersion === undefined || this._ecSpecVersion.readVersion < 3 || (this._ecSpecVersion.readVersion === 3 && this._ecSpecVersion.writeVersion < 3)) {
|
|
101081
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidSchemaXML, `The Format ${this._currentItemFullName} has ratio properties that require EC version 3.3 or newer.`);
|
|
101082
|
+
}
|
|
101083
|
+
}
|
|
101063
101084
|
const stationOffsetSize = this.getOptionalIntAttribute(xmlElement, "stationOffsetSize", `The Format ${this._currentItemFullName} has an invalid 'stationOffsetSize' attribute. It should be a numeric value.`);
|
|
101064
101085
|
const stationSeparator = this.getOptionalAttribute(xmlElement, "stationSeparator");
|
|
101065
101086
|
let composite;
|
|
@@ -101102,6 +101123,9 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
|
|
|
101102
101123
|
thousandSeparator,
|
|
101103
101124
|
uomSeparator,
|
|
101104
101125
|
scientificType,
|
|
101126
|
+
ratioType,
|
|
101127
|
+
ratioSeparator,
|
|
101128
|
+
ratioFormatType,
|
|
101105
101129
|
stationOffsetSize,
|
|
101106
101130
|
stationSeparator,
|
|
101107
101131
|
composite,
|
|
@@ -102845,7 +102869,7 @@ class SchemaFormatsProvider {
|
|
|
102845
102869
|
// If no matching presentation format was found, use persistence unit format if it matches unit system.
|
|
102846
102870
|
const persistenceUnit = await kindOfQuantity.persistenceUnit;
|
|
102847
102871
|
const persistenceUnitSystem = await persistenceUnit?.unitSystem;
|
|
102848
|
-
if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
|
|
102872
|
+
if (persistenceUnit && persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {
|
|
102849
102873
|
this._formatsRetrieved.add(itemKey.fullName);
|
|
102850
102874
|
const props = getPersistenceUnitFormatProps(persistenceUnit);
|
|
102851
102875
|
return this.convertToFormatDefinition(props, kindOfQuantity);
|
|
@@ -105442,6 +105466,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
105442
105466
|
|
|
105443
105467
|
|
|
105444
105468
|
|
|
105469
|
+
const loggingCategory = "ECClass";
|
|
105445
105470
|
/**
|
|
105446
105471
|
* A common abstract class for all of the ECClass types.
|
|
105447
105472
|
* @public @preview
|
|
@@ -105496,7 +105521,13 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
|
|
|
105496
105521
|
async getDerivedClasses() {
|
|
105497
105522
|
const derivedClasses = [];
|
|
105498
105523
|
for (const derivedClassKey of this.schema.context.classHierarchy.getDerivedClassKeys(this.key)) {
|
|
105499
|
-
|
|
105524
|
+
let derivedClass = await this.schema.getItem(derivedClassKey.name, ECClass); // if the derived class is in the same schema this will get it without going to the context
|
|
105525
|
+
if (derivedClass) {
|
|
105526
|
+
derivedClasses.push(derivedClass);
|
|
105527
|
+
continue;
|
|
105528
|
+
}
|
|
105529
|
+
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logInfo(loggingCategory, `Derived class ${derivedClassKey.name} not found in schema ${this.schema.name}, looking in schema context.`);
|
|
105530
|
+
derivedClass = await this.schema.context.getSchemaItem(derivedClassKey, ECClass);
|
|
105500
105531
|
if (derivedClass)
|
|
105501
105532
|
derivedClasses.push(derivedClass);
|
|
105502
105533
|
}
|
|
@@ -105884,18 +105915,56 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
|
|
|
105884
105915
|
*/
|
|
105885
105916
|
async *getAllBaseClasses() {
|
|
105886
105917
|
for (const baseClassKey of this.schema.context.classHierarchy.getBaseClassKeys(this.key)) {
|
|
105887
|
-
const baseClass = await this.
|
|
105918
|
+
const baseClass = await this.getClassFromReferencesRecursively(baseClassKey); // Search in schema ref tree all the way to the top
|
|
105888
105919
|
if (baseClass)
|
|
105889
105920
|
yield baseClass;
|
|
105890
105921
|
}
|
|
105891
105922
|
}
|
|
105923
|
+
/**
|
|
105924
|
+
* gets a class from this schema or its references recursively using the item key
|
|
105925
|
+
* @param itemKey
|
|
105926
|
+
* @returns ECClass if it could be found, undefined otherwise
|
|
105927
|
+
* @internal
|
|
105928
|
+
*/
|
|
105929
|
+
async getClassFromReferencesRecursively(itemKey) {
|
|
105930
|
+
const schemaList = [this.schema];
|
|
105931
|
+
while (schemaList.length > 0) {
|
|
105932
|
+
const currentSchema = schemaList.shift();
|
|
105933
|
+
if (currentSchema.schemaKey.compareByName(itemKey.schemaKey)) {
|
|
105934
|
+
const baseClass = await currentSchema.getItem(itemKey.name, ECClass);
|
|
105935
|
+
schemaList.splice(0); // clear the list
|
|
105936
|
+
return baseClass;
|
|
105937
|
+
}
|
|
105938
|
+
schemaList.push(...currentSchema.references);
|
|
105939
|
+
}
|
|
105940
|
+
return undefined;
|
|
105941
|
+
}
|
|
105892
105942
|
*getAllBaseClassesSync() {
|
|
105893
105943
|
for (const baseClassKey of this.schema.context.classHierarchy.getBaseClassKeys(this.key)) {
|
|
105894
|
-
const baseClass = this.
|
|
105944
|
+
const baseClass = this.getClassFromReferencesRecursivelySync(baseClassKey); // Search in schema ref tree all the way to the top
|
|
105895
105945
|
if (baseClass)
|
|
105896
105946
|
yield baseClass;
|
|
105897
105947
|
}
|
|
105898
105948
|
}
|
|
105949
|
+
/**
|
|
105950
|
+
* gets a class from this schema or its references recursively using the item key synchronously
|
|
105951
|
+
* @param itemKey
|
|
105952
|
+
* @returns ECClass if it could be found, undefined otherwise
|
|
105953
|
+
* @internal
|
|
105954
|
+
*/
|
|
105955
|
+
getClassFromReferencesRecursivelySync(itemKey) {
|
|
105956
|
+
const schemaList = [this.schema];
|
|
105957
|
+
while (schemaList.length > 0) {
|
|
105958
|
+
const currentSchema = schemaList.shift();
|
|
105959
|
+
if (currentSchema.schemaKey.compareByName(itemKey.schemaKey)) {
|
|
105960
|
+
const baseClass = currentSchema.getItemSync(itemKey.name, ECClass);
|
|
105961
|
+
schemaList.splice(0); // clear the list
|
|
105962
|
+
return baseClass;
|
|
105963
|
+
}
|
|
105964
|
+
schemaList.push(...currentSchema.references);
|
|
105965
|
+
}
|
|
105966
|
+
return undefined;
|
|
105967
|
+
}
|
|
105899
105968
|
/**
|
|
105900
105969
|
*
|
|
105901
105970
|
* @param cache
|
|
@@ -107031,6 +107100,9 @@ class Format extends _SchemaItem__WEBPACK_IMPORTED_MODULE_5__.SchemaItem {
|
|
|
107031
107100
|
get stationSeparator() { return this._base.stationSeparator; }
|
|
107032
107101
|
get stationOffsetSize() { return this._base.stationOffsetSize; }
|
|
107033
107102
|
get stationBaseFactor() { return this._base.stationBaseFactor; }
|
|
107103
|
+
get ratioType() { return this._base.ratioType; }
|
|
107104
|
+
get ratioSeparator() { return this._base.ratioSeparator; }
|
|
107105
|
+
get ratioFormatType() { return this._base.ratioFormatType; }
|
|
107034
107106
|
get formatTraits() { return this._base.formatTraits; }
|
|
107035
107107
|
get spacer() { return this._base.spacer; }
|
|
107036
107108
|
get includeZero() { return this._base.includeZero; }
|
|
@@ -107052,10 +107124,13 @@ class Format extends _SchemaItem__WEBPACK_IMPORTED_MODULE_5__.SchemaItem {
|
|
|
107052
107124
|
addUnit(unit, label) {
|
|
107053
107125
|
if (undefined === this._units)
|
|
107054
107126
|
this._units = [];
|
|
107055
|
-
else {
|
|
107056
|
-
|
|
107057
|
-
|
|
107058
|
-
|
|
107127
|
+
else {
|
|
107128
|
+
const isDuplicateAllowed = this.type === _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio;
|
|
107129
|
+
if (!isDuplicateAllowed) {
|
|
107130
|
+
for (const existingUnit of this._units) {
|
|
107131
|
+
if (unit.fullName.toLowerCase() === existingUnit[0].fullName.toLowerCase())
|
|
107132
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has duplicate units, '${unit.fullName}'.`); // TODO: Validation - this should be a validation error not a hard failure.
|
|
107133
|
+
}
|
|
107059
107134
|
}
|
|
107060
107135
|
}
|
|
107061
107136
|
this._units.push([unit, label]);
|
|
@@ -107080,37 +107155,87 @@ class Format extends _SchemaItem__WEBPACK_IMPORTED_MODULE_5__.SchemaItem {
|
|
|
107080
107155
|
if (formatProps.composite.units.length <= 0 || formatProps.composite.units.length > 4)
|
|
107081
107156
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has an invalid 'Composite' attribute. It should have 1-4 units.`);
|
|
107082
107157
|
}
|
|
107158
|
+
// For Ratio formats: validate that composite is provided
|
|
107159
|
+
if (this.type === _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
107160
|
+
const hasComposite = undefined !== formatProps.composite && formatProps.composite.units.length > 0;
|
|
107161
|
+
if (!hasComposite) {
|
|
107162
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} is 'Ratio' type and must have 'composite' units.`);
|
|
107163
|
+
}
|
|
107164
|
+
}
|
|
107083
107165
|
}
|
|
107084
107166
|
fromJSONSync(formatProps) {
|
|
107085
107167
|
super.fromJSONSync(formatProps);
|
|
107086
107168
|
this.typecheck(formatProps);
|
|
107087
|
-
|
|
107088
|
-
|
|
107089
|
-
|
|
107090
|
-
|
|
107091
|
-
|
|
107092
|
-
|
|
107093
|
-
|
|
107094
|
-
|
|
107095
|
-
|
|
107096
|
-
|
|
107097
|
-
|
|
107169
|
+
// Process composite units
|
|
107170
|
+
if (undefined !== formatProps.composite) {
|
|
107171
|
+
for (const unit of formatProps.composite.units) {
|
|
107172
|
+
const newUnit = this.schema.lookupItemSync(unit.name);
|
|
107173
|
+
if (undefined === newUnit || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(newUnit) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(newUnit)))
|
|
107174
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, ``);
|
|
107175
|
+
const lazyUnit = _Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(newUnit)
|
|
107176
|
+
? new _DelayedPromise__WEBPACK_IMPORTED_MODULE_7__.DelayedPromiseWithProps(newUnit.key, async () => newUnit)
|
|
107177
|
+
: new _DelayedPromise__WEBPACK_IMPORTED_MODULE_7__.DelayedPromiseWithProps(newUnit.key, async () => newUnit);
|
|
107178
|
+
this.addUnit(lazyUnit, unit.label);
|
|
107179
|
+
}
|
|
107180
|
+
// For Ratio formats with 2 units: validate both units have the same phenomenon
|
|
107181
|
+
if (this.type === _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio && this._units && this._units.length === 2) {
|
|
107182
|
+
const unit1Item = this.schema.lookupItemSync(this._units[0][0].fullName);
|
|
107183
|
+
const unit2Item = this.schema.lookupItemSync(this._units[1][0].fullName);
|
|
107184
|
+
if (!unit1Item || !unit2Item || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unit1Item) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(unit1Item)) || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unit2Item) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(unit2Item)))
|
|
107185
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has invalid units.`);
|
|
107186
|
+
const getPhenomenon = (unitItem) => {
|
|
107187
|
+
if (_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unitItem)) {
|
|
107188
|
+
return unitItem.phenomenon;
|
|
107189
|
+
}
|
|
107190
|
+
const invertsUnit = unitItem.invertsUnit;
|
|
107191
|
+
if (invertsUnit) {
|
|
107192
|
+
const resolvedUnit = this.schema.lookupItemSync(invertsUnit.fullName);
|
|
107193
|
+
return resolvedUnit && _Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(resolvedUnit) ? resolvedUnit.phenomenon : undefined;
|
|
107194
|
+
}
|
|
107195
|
+
return undefined;
|
|
107196
|
+
};
|
|
107197
|
+
const phenomenon1 = getPhenomenon(unit1Item);
|
|
107198
|
+
const phenomenon2 = getPhenomenon(unit2Item);
|
|
107199
|
+
if (phenomenon1?.fullName !== phenomenon2?.fullName) {
|
|
107200
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has 2-unit composite with different phenomena. Both units must have the same phenomenon.`);
|
|
107201
|
+
}
|
|
107202
|
+
}
|
|
107098
107203
|
}
|
|
107099
107204
|
}
|
|
107100
107205
|
async fromJSON(formatProps) {
|
|
107101
107206
|
await super.fromJSON(formatProps);
|
|
107102
107207
|
this.typecheck(formatProps);
|
|
107103
|
-
|
|
107104
|
-
|
|
107105
|
-
|
|
107106
|
-
|
|
107107
|
-
|
|
107108
|
-
|
|
107109
|
-
|
|
107110
|
-
|
|
107111
|
-
|
|
107112
|
-
|
|
107113
|
-
|
|
107208
|
+
// Process composite units
|
|
107209
|
+
if (undefined !== formatProps.composite) {
|
|
107210
|
+
for (const unit of formatProps.composite.units) {
|
|
107211
|
+
const newUnit = await this.schema.lookupItem(unit.name);
|
|
107212
|
+
if (undefined === newUnit || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(newUnit) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(newUnit)))
|
|
107213
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, ``);
|
|
107214
|
+
const lazyUnit = _Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(newUnit)
|
|
107215
|
+
? new _DelayedPromise__WEBPACK_IMPORTED_MODULE_7__.DelayedPromiseWithProps(newUnit.key, async () => newUnit)
|
|
107216
|
+
: new _DelayedPromise__WEBPACK_IMPORTED_MODULE_7__.DelayedPromiseWithProps(newUnit.key, async () => newUnit);
|
|
107217
|
+
this.addUnit(lazyUnit, unit.label);
|
|
107218
|
+
}
|
|
107219
|
+
// For Ratio formats with 2 units: validate both units have the same phenomenon
|
|
107220
|
+
if (this.type === _itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio && this._units && this._units.length === 2) {
|
|
107221
|
+
const unit1Item = await this.schema.lookupItem(this._units[0][0].fullName);
|
|
107222
|
+
const unit2Item = await this.schema.lookupItem(this._units[1][0].fullName);
|
|
107223
|
+
if (!unit1Item || !unit2Item || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unit1Item) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(unit1Item)) || (!_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unit2Item) && !_InvertedUnit__WEBPACK_IMPORTED_MODULE_4__.InvertedUnit.isInvertedUnit(unit2Item)))
|
|
107224
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has invalid units.`);
|
|
107225
|
+
// Helper to extract phenomenon from Unit or InvertedUnit
|
|
107226
|
+
const getPhenomenon = async (unitItem) => {
|
|
107227
|
+
if (_Unit__WEBPACK_IMPORTED_MODULE_6__.Unit.isUnit(unitItem)) {
|
|
107228
|
+
return unitItem.phenomenon;
|
|
107229
|
+
}
|
|
107230
|
+
const invertsUnit = await unitItem.invertsUnit;
|
|
107231
|
+
return invertsUnit ? invertsUnit.phenomenon : undefined;
|
|
107232
|
+
};
|
|
107233
|
+
const phenomenon1 = await getPhenomenon(unit1Item);
|
|
107234
|
+
const phenomenon2 = await getPhenomenon(unit2Item);
|
|
107235
|
+
if (phenomenon1?.fullName !== phenomenon2?.fullName) {
|
|
107236
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `The Format ${this.fullName} has 2-unit composite with different phenomena. Both units must have the same phenomenon.`);
|
|
107237
|
+
}
|
|
107238
|
+
}
|
|
107114
107239
|
}
|
|
107115
107240
|
}
|
|
107116
107241
|
/**
|
|
@@ -107147,6 +107272,15 @@ class Format extends _SchemaItem__WEBPACK_IMPORTED_MODULE_5__.SchemaItem {
|
|
|
107147
107272
|
if (" " !== this.stationSeparator)
|
|
107148
107273
|
schemaJson.stationSeparator = this.stationSeparator;
|
|
107149
107274
|
}
|
|
107275
|
+
// Only include ratio properties for EC version 3.3+
|
|
107276
|
+
if (_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio === this.type && this.schema.originalECSpecMajorVersion === 3 && this.schema.originalECSpecMinorVersion !== undefined && this.schema.originalECSpecMinorVersion >= 3) {
|
|
107277
|
+
if (undefined !== this.ratioType)
|
|
107278
|
+
schemaJson.ratioType = this.ratioType;
|
|
107279
|
+
if (undefined !== this.ratioSeparator)
|
|
107280
|
+
schemaJson.ratioSeparator = this.ratioSeparator;
|
|
107281
|
+
if (undefined !== this.ratioFormatType)
|
|
107282
|
+
schemaJson.ratioFormatType = this.ratioFormatType;
|
|
107283
|
+
}
|
|
107150
107284
|
if (undefined === this.units)
|
|
107151
107285
|
return schemaJson;
|
|
107152
107286
|
schemaJson.composite = {};
|
|
@@ -107178,6 +107312,15 @@ class Format extends _SchemaItem__WEBPACK_IMPORTED_MODULE_5__.SchemaItem {
|
|
|
107178
107312
|
itemElement.setAttribute("minWidth", this.minWidth.toString());
|
|
107179
107313
|
if (undefined !== this.scientificType)
|
|
107180
107314
|
itemElement.setAttribute("scientificType", this.scientificType);
|
|
107315
|
+
// Only include ratio properties for EC version 3.3+
|
|
107316
|
+
if (this.schema.originalECSpecMajorVersion === 3 && this.schema.originalECSpecMinorVersion !== undefined && this.schema.originalECSpecMinorVersion >= 3) {
|
|
107317
|
+
if (undefined !== this.ratioType)
|
|
107318
|
+
itemElement.setAttribute("ratioType", this.ratioType);
|
|
107319
|
+
if (undefined !== this.ratioSeparator)
|
|
107320
|
+
itemElement.setAttribute("ratioSeparator", this.ratioSeparator);
|
|
107321
|
+
if (undefined !== this.ratioFormatType)
|
|
107322
|
+
itemElement.setAttribute("ratioFormatType", this.ratioFormatType);
|
|
107323
|
+
}
|
|
107181
107324
|
if (undefined !== this.stationOffsetSize)
|
|
107182
107325
|
itemElement.setAttribute("stationOffsetSize", this.stationOffsetSize.toString());
|
|
107183
107326
|
const formatTraits = (0,_itwin_core_quantity__WEBPACK_IMPORTED_MODULE_3__.formatTraitsToArray)(this.formatTraits);
|
|
@@ -107924,6 +108067,9 @@ class OverrideFormat {
|
|
|
107924
108067
|
get type() { return this.parent.type; }
|
|
107925
108068
|
get minWidth() { return this.parent.minWidth; }
|
|
107926
108069
|
get scientificType() { return this.parent.scientificType; }
|
|
108070
|
+
get ratioType() { return this.parent.ratioType; }
|
|
108071
|
+
get ratioSeparator() { return this.parent.ratioSeparator; }
|
|
108072
|
+
get ratioFormatType() { return this.parent.ratioFormatType; }
|
|
107927
108073
|
get showSignOption() { return this.parent.showSignOption; }
|
|
107928
108074
|
get decimalSeparator() { return this.parent.decimalSeparator; }
|
|
107929
108075
|
get thousandSeparator() { return this.parent.thousandSeparator; }
|
|
@@ -107948,7 +108094,7 @@ class OverrideFormat {
|
|
|
107948
108094
|
for (const [unit, unitLabel] of this._units) {
|
|
107949
108095
|
const unitSchema = koqSchema.context.getSchemaSync(unit.schemaKey);
|
|
107950
108096
|
if (unitSchema === undefined)
|
|
107951
|
-
throw new _Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaStatus.InvalidECJson, `The unit schema ${unit.schemaKey} is not found in the context.`);
|
|
108097
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaStatus.InvalidECJson, `The unit schema ${unit.schemaKey.toString()} is not found in the context.`);
|
|
107952
108098
|
fullName += "[";
|
|
107953
108099
|
fullName += _Deserialization_XmlSerializationUtils__WEBPACK_IMPORTED_MODULE_0__.XmlSerializationUtils.createXmlTypedName(koqSchema, unitSchema, unit.name);
|
|
107954
108100
|
if (unitLabel !== undefined)
|
|
@@ -125159,6 +125305,10 @@ class IModelApp {
|
|
|
125159
125305
|
* @beta
|
|
125160
125306
|
*/
|
|
125161
125307
|
static applicationLogoCard;
|
|
125308
|
+
/** Applications may implement this method to supply a Logo Card footer which will always be placed last.
|
|
125309
|
+
* @beta
|
|
125310
|
+
*/
|
|
125311
|
+
static applicationLogoCardFooter;
|
|
125162
125312
|
/** Make a new Logo Card. Call this method from your implementation of [[IModelApp.applicationLogoCard]]
|
|
125163
125313
|
* @param opts Options for Logo Card
|
|
125164
125314
|
* @beta
|
|
@@ -139210,6 +139360,9 @@ class ScreenViewport extends Viewport {
|
|
|
139210
139360
|
for (const ref of this.getTileTreeRefs()) {
|
|
139211
139361
|
promises.push(ref.addAttributions(logos, this));
|
|
139212
139362
|
}
|
|
139363
|
+
if (undefined !== _IModelApp__WEBPACK_IMPORTED_MODULE_10__.IModelApp.applicationLogoCardFooter) {
|
|
139364
|
+
logos.appendChild(_IModelApp__WEBPACK_IMPORTED_MODULE_10__.IModelApp.applicationLogoCardFooter());
|
|
139365
|
+
}
|
|
139213
139366
|
await Promise.all(promises);
|
|
139214
139367
|
ev.stopPropagation();
|
|
139215
139368
|
};
|
|
@@ -144787,7 +144940,9 @@ function createMeshArgs(mesh) {
|
|
|
144787
144940
|
if (!mesh.triangles || mesh.triangles.isEmpty || mesh.points.length === 0)
|
|
144788
144941
|
return undefined;
|
|
144789
144942
|
const texture = mesh.displayParams.textureMapping?.texture;
|
|
144790
|
-
const
|
|
144943
|
+
const useConstantLod = mesh.displayParams.textureMapping?.params?.useConstantLod;
|
|
144944
|
+
const constantLodParams = mesh.displayParams.textureMapping?.params?.constantLodParams;
|
|
144945
|
+
const textureMapping = texture && mesh.uvParams.length > 0 ? { texture, uvParams: mesh.uvParams, useConstantLod, constantLodParams } : undefined;
|
|
144791
144946
|
const colors = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorIndex();
|
|
144792
144947
|
mesh.colorMap.toColorIndex(colors, mesh.colors);
|
|
144793
144948
|
const features = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FeatureIndex();
|
|
@@ -186566,7 +186721,7 @@ function readPnts(stream, dataOffset, pnts) {
|
|
|
186566
186721
|
}
|
|
186567
186722
|
async function decodeDracoPointCloud(buf) {
|
|
186568
186723
|
try {
|
|
186569
|
-
const dracoLoader = (await __webpack_require__.e(/*! import() */ "vendors-
|
|
186724
|
+
const dracoLoader = (await __webpack_require__.e(/*! import() */ "vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9").then(__webpack_require__.bind(__webpack_require__, /*! @loaders.gl/draco */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/index.js"))).DracoLoader;
|
|
186570
186725
|
const mesh = await dracoLoader.parse(buf, {});
|
|
186571
186726
|
if (mesh.topology !== "point-list")
|
|
186572
186727
|
return undefined;
|
|
@@ -198005,14 +198160,47 @@ class GltfReader {
|
|
|
198005
198160
|
}
|
|
198006
198161
|
}
|
|
198007
198162
|
createDisplayParams(material, hasBakedLighting, isPointPrimitive = false) {
|
|
198163
|
+
let constantLodParamProps;
|
|
198164
|
+
let normalMapUseConstantLod = false;
|
|
198165
|
+
if (!(0,_common_gltf_GltfSchema__WEBPACK_IMPORTED_MODULE_12__.isGltf1Material)(material)) {
|
|
198166
|
+
// NOTE: EXT_textureInfo_constant_lod is not supported for occlusionTexture and metallicRoughnessTexture
|
|
198167
|
+
// Use the same texture fallback logic as extractTextureId
|
|
198168
|
+
const textureInfo = material.pbrMetallicRoughness?.baseColorTexture ?? material.emissiveTexture;
|
|
198169
|
+
const extConstantLod = textureInfo?.extensions?.EXT_textureInfo_constant_lod;
|
|
198170
|
+
const offset = extConstantLod?.offset;
|
|
198171
|
+
extConstantLod ? constantLodParamProps = {
|
|
198172
|
+
repetitions: extConstantLod?.repetitions,
|
|
198173
|
+
offset: offset ? { x: offset[0], y: offset[1] } : undefined,
|
|
198174
|
+
minDistClamp: extConstantLod?.minClampDistance,
|
|
198175
|
+
maxDistClamp: extConstantLod?.maxClampDistance,
|
|
198176
|
+
} : undefined;
|
|
198177
|
+
// Normal map only uses constant LOD if both the base texture and normal texture have the extension
|
|
198178
|
+
normalMapUseConstantLod = extConstantLod !== undefined && material.normalTexture?.extensions?.EXT_textureInfo_constant_lod !== undefined;
|
|
198179
|
+
}
|
|
198008
198180
|
const isTransparent = this.isMaterialTransparent(material);
|
|
198009
198181
|
const textureId = this.extractTextureId(material);
|
|
198010
198182
|
const normalMapId = this.extractNormalMapId(material);
|
|
198011
|
-
let textureMapping = (undefined !== textureId || undefined !== normalMapId) ? this.findTextureMapping(textureId, isTransparent, normalMapId) : undefined;
|
|
198183
|
+
let textureMapping = (undefined !== textureId || undefined !== normalMapId) ? this.findTextureMapping(textureId, isTransparent, normalMapId, constantLodParamProps, normalMapUseConstantLod) : undefined;
|
|
198012
198184
|
const color = colorFromMaterial(material, isTransparent);
|
|
198013
198185
|
let renderMaterial;
|
|
198014
|
-
if (undefined !== textureMapping
|
|
198015
|
-
|
|
198186
|
+
if (undefined !== textureMapping) {
|
|
198187
|
+
// Convert result of findTextureMapping (TextureMapping object) to MaterialTextureMappingProps interface
|
|
198188
|
+
const textureMappingProps = {
|
|
198189
|
+
texture: textureMapping.texture,
|
|
198190
|
+
normalMapParams: textureMapping.normalMapParams,
|
|
198191
|
+
mode: textureMapping.params.mode,
|
|
198192
|
+
transform: textureMapping.params.textureMatrix,
|
|
198193
|
+
weight: textureMapping.params.weight,
|
|
198194
|
+
worldMapping: textureMapping.params.worldMapping,
|
|
198195
|
+
useConstantLod: textureMapping.params.useConstantLod,
|
|
198196
|
+
constantLodProps: textureMapping.params.useConstantLod ? {
|
|
198197
|
+
repetitions: textureMapping.params.constantLodParams.repetitions,
|
|
198198
|
+
offset: textureMapping.params.constantLodParams.offset,
|
|
198199
|
+
minDistClamp: textureMapping.params.constantLodParams.minDistClamp,
|
|
198200
|
+
maxDistClamp: textureMapping.params.constantLodParams.maxDistClamp,
|
|
198201
|
+
} : undefined,
|
|
198202
|
+
};
|
|
198203
|
+
const args = { diffuse: { color }, specular: { color: _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.white }, textureMapping: textureMappingProps };
|
|
198016
198204
|
renderMaterial = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createRenderMaterial(args);
|
|
198017
198205
|
// DisplayParams doesn't want a separate texture mapping if the material already has one.
|
|
198018
198206
|
textureMapping = undefined;
|
|
@@ -198024,7 +198212,30 @@ class GltfReader {
|
|
|
198024
198212
|
width = pointStyle.diameter;
|
|
198025
198213
|
}
|
|
198026
198214
|
}
|
|
198027
|
-
|
|
198215
|
+
// Process BENTLEY_materials_planar_fill extension
|
|
198216
|
+
let fillFlags = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FillFlags.None;
|
|
198217
|
+
if (!(0,_common_gltf_GltfSchema__WEBPACK_IMPORTED_MODULE_12__.isGltf1Material)(material)) {
|
|
198218
|
+
const planarFill = material.extensions?.BENTLEY_materials_planar_fill;
|
|
198219
|
+
if (planarFill) {
|
|
198220
|
+
// Map wireframeFill: 0=NONE (no fill flags), 1=ALWAYS (Always flag), 2=TOGGLE (ByView flag)
|
|
198221
|
+
const wireframeFill = planarFill.wireframeFill ?? 0;
|
|
198222
|
+
if (wireframeFill === 1) {
|
|
198223
|
+
fillFlags |= _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FillFlags.Always;
|
|
198224
|
+
}
|
|
198225
|
+
else if (wireframeFill === 2) {
|
|
198226
|
+
fillFlags |= _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FillFlags.ByView;
|
|
198227
|
+
}
|
|
198228
|
+
// Map backgroundFill to Background flag
|
|
198229
|
+
if (planarFill.backgroundFill === true) {
|
|
198230
|
+
fillFlags |= _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FillFlags.Background;
|
|
198231
|
+
}
|
|
198232
|
+
// Map behind to Behind flag
|
|
198233
|
+
if (planarFill.behind === true) {
|
|
198234
|
+
fillFlags |= _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FillFlags.Behind;
|
|
198235
|
+
}
|
|
198236
|
+
}
|
|
198237
|
+
}
|
|
198238
|
+
return new _common_internal_render_DisplayParams__WEBPACK_IMPORTED_MODULE_8__.DisplayParams(_common_internal_render_DisplayParams__WEBPACK_IMPORTED_MODULE_8__.DisplayParams.Type.Mesh, color, color, width, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.LinePixels.Solid, fillFlags, renderMaterial, undefined, hasBakedLighting, textureMapping);
|
|
198028
198239
|
}
|
|
198029
198240
|
readMeshPrimitives(node, featureTable, thisTransform, thisBias, instances) {
|
|
198030
198241
|
const meshes = [];
|
|
@@ -198826,7 +199037,7 @@ class GltfReader {
|
|
|
198826
199037
|
if (_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.ProcessDetector.isIEBrowser) {
|
|
198827
199038
|
throw new Error("Unsupported browser for Draco decoding");
|
|
198828
199039
|
}
|
|
198829
|
-
const dracoLoader = (await __webpack_require__.e(/*! import() */ "vendors-
|
|
199040
|
+
const dracoLoader = (await __webpack_require__.e(/*! import() */ "vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9").then(__webpack_require__.bind(__webpack_require__, /*! @loaders.gl/draco */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/index.js"))).DracoLoader;
|
|
198830
199041
|
await Promise.all(dracoMeshes.map(async (x) => this.decodeDracoMesh(x, dracoLoader)));
|
|
198831
199042
|
}
|
|
198832
199043
|
catch (err) {
|
|
@@ -198970,7 +199181,7 @@ class GltfReader {
|
|
|
198970
199181
|
});
|
|
198971
199182
|
return renderTexture ?? false;
|
|
198972
199183
|
}
|
|
198973
|
-
findTextureMapping(id, isTransparent, normalMapId) {
|
|
199184
|
+
findTextureMapping(id, isTransparent, normalMapId, constantLodParamProps, normalMapUseConstantLod = false) {
|
|
198974
199185
|
if (undefined === id && undefined === normalMapId)
|
|
198975
199186
|
return undefined;
|
|
198976
199187
|
let texture;
|
|
@@ -198992,16 +199203,18 @@ class GltfReader {
|
|
|
198992
199203
|
nMap = {
|
|
198993
199204
|
normalMap,
|
|
198994
199205
|
greenUp,
|
|
199206
|
+
useConstantLod: normalMapUseConstantLod,
|
|
198995
199207
|
};
|
|
198996
199208
|
}
|
|
198997
199209
|
else {
|
|
198998
199210
|
texture = normalMap;
|
|
198999
|
-
nMap = { greenUp };
|
|
199211
|
+
nMap = { greenUp, useConstantLod: normalMapUseConstantLod };
|
|
199000
199212
|
}
|
|
199001
199213
|
}
|
|
199002
199214
|
if (!texture)
|
|
199003
199215
|
return undefined;
|
|
199004
|
-
const
|
|
199216
|
+
const useConstantLod = constantLodParamProps !== undefined;
|
|
199217
|
+
const textureMapping = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.TextureMapping(texture, new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.TextureMapping.Params({ useConstantLod, constantLodProps: constantLodParamProps }));
|
|
199005
199218
|
textureMapping.normalMapParams = nMap;
|
|
199006
199219
|
return textureMapping;
|
|
199007
199220
|
}
|
|
@@ -199038,7 +199251,7 @@ async function readGltfTemplate(args) {
|
|
|
199038
199251
|
}
|
|
199039
199252
|
/** Produce a [[RenderGraphic]] from a [glTF](https://www.khronos.org/gltf/) asset suitable for use in [view decorations]($docs/learning/frontend/ViewDecorations).
|
|
199040
199253
|
* @returns a graphic produced from the glTF asset's default scene, or `undefined` if a graphic could not be produced from the asset.
|
|
199041
|
-
* The returned graphic also includes the bounding boxes of the glTF model in world and local
|
|
199254
|
+
* The returned graphic also includes the bounding boxes of the glTF model in world and local coordinates.
|
|
199042
199255
|
* @note Support for the full [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html) is currently a work in progress.
|
|
199043
199256
|
* If a particular glTF asset fails to load and/or display properly, please
|
|
199044
199257
|
* [submit an issue](https://github.com/iTwin/itwinjs-core/issues).
|
|
@@ -199066,6 +199279,7 @@ class GltfGraphicsReader extends GltfReader {
|
|
|
199066
199279
|
_contentRange;
|
|
199067
199280
|
_transform;
|
|
199068
199281
|
_isLeaf;
|
|
199282
|
+
_useViewportRenderMode;
|
|
199069
199283
|
binaryData; // strictly for tests
|
|
199070
199284
|
meshes; // strictly for tests
|
|
199071
199285
|
constructor(props, args) {
|
|
@@ -199079,6 +199293,7 @@ class GltfGraphicsReader extends GltfReader {
|
|
|
199079
199293
|
this._contentRange = args.contentRange;
|
|
199080
199294
|
this._transform = args.transform;
|
|
199081
199295
|
this._isLeaf = true !== args.hasChildren;
|
|
199296
|
+
this._useViewportRenderMode = args.useViewportRenderMode ?? false;
|
|
199082
199297
|
this.binaryData = props.binaryData;
|
|
199083
199298
|
const pickableId = args.pickableOptions?.id;
|
|
199084
199299
|
if (pickableId) {
|
|
@@ -199089,7 +199304,8 @@ class GltfGraphicsReader extends GltfReader {
|
|
|
199089
199304
|
get viewFlagOverrides() {
|
|
199090
199305
|
return {
|
|
199091
199306
|
whiteOnWhiteReversal: false,
|
|
199092
|
-
renderMode
|
|
199307
|
+
// Don't override renderMode if using viewport's render mode - let the viewport control it.
|
|
199308
|
+
renderMode: this._useViewportRenderMode ? undefined : _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.RenderMode.SmoothShade,
|
|
199093
199309
|
};
|
|
199094
199310
|
}
|
|
199095
199311
|
get meshElementIdToFeatureIndex() {
|
|
@@ -340697,6 +340913,8 @@ class BaseFormat {
|
|
|
340697
340913
|
_stationOffsetSize; // required when type is station; positive integer > 0
|
|
340698
340914
|
_stationBaseFactor; // optional positive integer base factor for station formatting; default is 1
|
|
340699
340915
|
_ratioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor
|
|
340916
|
+
_ratioFormatType; // defaults to Decimal if not specified
|
|
340917
|
+
_ratioSeparator; // default is ":"; separator character used in ratio formatting
|
|
340700
340918
|
_azimuthBase; // value always clockwise from north
|
|
340701
340919
|
_azimuthBaseUnit; // unit for azimuthBase value
|
|
340702
340920
|
_azimuthCounterClockwise; // if set to true, azimuth values are returned counter-clockwise from base
|
|
@@ -340718,6 +340936,10 @@ class BaseFormat {
|
|
|
340718
340936
|
set scientificType(scientificType) { this._scientificType = scientificType; }
|
|
340719
340937
|
get ratioType() { return this._ratioType; }
|
|
340720
340938
|
set ratioType(ratioType) { this._ratioType = ratioType; }
|
|
340939
|
+
get ratioFormatType() { return this._ratioFormatType; }
|
|
340940
|
+
set ratioFormatType(ratioFormatType) { this._ratioFormatType = ratioFormatType; }
|
|
340941
|
+
get ratioSeparator() { return this._ratioSeparator; }
|
|
340942
|
+
set ratioSeparator(ratioSeparator) { this._ratioSeparator = ratioSeparator; }
|
|
340721
340943
|
get showSignOption() { return this._showSignOption; }
|
|
340722
340944
|
set showSignOption(showSignOption) { this._showSignOption = showSignOption; }
|
|
340723
340945
|
get decimalSeparator() { return this._decimalSeparator; }
|
|
@@ -340786,6 +341008,22 @@ class BaseFormat {
|
|
|
340786
341008
|
if (undefined === formatProps.ratioType)
|
|
340787
341009
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);
|
|
340788
341010
|
this._ratioType = (0,_FormatEnums__WEBPACK_IMPORTED_MODULE_2__.parseRatioType)(formatProps.ratioType, this.name);
|
|
341011
|
+
if (undefined !== formatProps.ratioSeparator) {
|
|
341012
|
+
if (typeof (formatProps.ratioSeparator) !== "string")
|
|
341013
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);
|
|
341014
|
+
if (formatProps.ratioSeparator.length !== 1)
|
|
341015
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be a one character string.`);
|
|
341016
|
+
this._ratioSeparator = formatProps.ratioSeparator;
|
|
341017
|
+
}
|
|
341018
|
+
else {
|
|
341019
|
+
this._ratioSeparator = ":"; // Apply default
|
|
341020
|
+
}
|
|
341021
|
+
if (undefined !== formatProps.ratioFormatType) {
|
|
341022
|
+
this._ratioFormatType = (0,_FormatEnums__WEBPACK_IMPORTED_MODULE_2__.parseRatioFormatType)(formatProps.ratioFormatType, this.name);
|
|
341023
|
+
}
|
|
341024
|
+
else {
|
|
341025
|
+
this._ratioFormatType = _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.RatioFormatType.Decimal; // Apply default
|
|
341026
|
+
}
|
|
340789
341027
|
}
|
|
340790
341028
|
if (undefined !== formatProps.roundFactor) { // optional; default is 0.0
|
|
340791
341029
|
if (typeof (formatProps.roundFactor) !== "number")
|
|
@@ -340910,6 +341148,8 @@ class Format extends BaseFormat {
|
|
|
340910
341148
|
newFormat._azimuthBaseUnit = this._azimuthBaseUnit;
|
|
340911
341149
|
newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;
|
|
340912
341150
|
newFormat._ratioType = this._ratioType;
|
|
341151
|
+
newFormat._ratioFormatType = this._ratioFormatType;
|
|
341152
|
+
newFormat._ratioSeparator = this._ratioSeparator;
|
|
340913
341153
|
newFormat._revolutionUnit = this._revolutionUnit;
|
|
340914
341154
|
newFormat._customProps = this._customProps;
|
|
340915
341155
|
this._units && (newFormat._units = [...this._units]);
|
|
@@ -340970,25 +341210,28 @@ class Format extends BaseFormat {
|
|
|
340970
341210
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);
|
|
340971
341211
|
}
|
|
340972
341212
|
if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units
|
|
340973
|
-
|
|
340974
|
-
|
|
340975
|
-
|
|
340976
|
-
|
|
340977
|
-
|
|
340978
|
-
|
|
340979
|
-
|
|
341213
|
+
const isDuplicateAllowed = this.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio;
|
|
341214
|
+
const seenUnits = new Set();
|
|
341215
|
+
this._units = [];
|
|
341216
|
+
for (const unitSpec of jsonObj.composite.units) {
|
|
341217
|
+
if (!isDuplicateAllowed) {
|
|
341218
|
+
const unitName = unitSpec.unit.name.toLowerCase();
|
|
341219
|
+
const existingName = seenUnits.has(unitName);
|
|
341220
|
+
if (existingName) {
|
|
341221
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} contains duplicate units: '${unitSpec.unit.name}'`);
|
|
340980
341222
|
}
|
|
341223
|
+
seenUnits.add(unitName);
|
|
340981
341224
|
}
|
|
340982
|
-
|
|
340983
|
-
this._units = [];
|
|
340984
|
-
}
|
|
340985
|
-
this._units.push([nextUnit.unit, nextUnit.label]);
|
|
341225
|
+
this._units.push([unitSpec.unit, unitSpec.label]);
|
|
340986
341226
|
}
|
|
340987
341227
|
}
|
|
340988
341228
|
}
|
|
340989
341229
|
if (undefined === this.units || this.units.length === 0)
|
|
340990
341230
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);
|
|
340991
341231
|
}
|
|
341232
|
+
if (this.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && (!this._units || this._units.length === 0)) {
|
|
341233
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type and must have 'composite' units.`);
|
|
341234
|
+
}
|
|
340992
341235
|
if (this.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Azimuth || this.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Bearing) {
|
|
340993
341236
|
this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;
|
|
340994
341237
|
this._revolutionUnit = jsonObj.revolutionUnit;
|
|
@@ -341055,6 +341298,8 @@ class Format extends BaseFormat {
|
|
|
341055
341298
|
uomSeparator: this.uomSeparator,
|
|
341056
341299
|
scientificType: this.scientificType ? this.scientificType : undefined,
|
|
341057
341300
|
ratioType: this.ratioType,
|
|
341301
|
+
ratioFormatType: this.ratioFormatType,
|
|
341302
|
+
ratioSeparator: this.ratioSeparator,
|
|
341058
341303
|
stationOffsetSize: this.stationOffsetSize,
|
|
341059
341304
|
stationSeparator: this.stationSeparator,
|
|
341060
341305
|
stationBaseFactor: this.stationBaseFactor,
|
|
@@ -341099,6 +341344,15 @@ async function resolveFormatProps(formatName, unitsProvider, jsonObj) {
|
|
|
341099
341344
|
const unit = await resolveCompositeUnit(unitsProvider, entry.name);
|
|
341100
341345
|
return { unit, label: entry.label };
|
|
341101
341346
|
}));
|
|
341347
|
+
// For Ratio formats with 2 units: validate both units have the same phenomenon
|
|
341348
|
+
const formatType = (0,_FormatEnums__WEBPACK_IMPORTED_MODULE_2__.parseFormatType)(jsonObj.type, formatName);
|
|
341349
|
+
if (formatType === _FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Ratio && units.length === 2) {
|
|
341350
|
+
const phenomenon1 = units[0].unit.phenomenon;
|
|
341351
|
+
const phenomenon2 = units[1].unit.phenomenon;
|
|
341352
|
+
if (phenomenon1 !== phenomenon2) {
|
|
341353
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidJson, `The Format ${formatName} has 2-unit composite with different phenomena. Both units must have the same phenomenon. Found '${phenomenon1}' and '${phenomenon2}'.`);
|
|
341354
|
+
}
|
|
341355
|
+
}
|
|
341102
341356
|
}
|
|
341103
341357
|
let azimuthBaseUnit, revolutionUnit;
|
|
341104
341358
|
const type = (0,_FormatEnums__WEBPACK_IMPORTED_MODULE_2__.parseFormatType)(jsonObj.type, formatName);
|
|
@@ -341139,6 +341393,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
341139
341393
|
/* harmony export */ FormatTraits: () => (/* binding */ FormatTraits),
|
|
341140
341394
|
/* harmony export */ FormatType: () => (/* binding */ FormatType),
|
|
341141
341395
|
/* harmony export */ FractionalPrecision: () => (/* binding */ FractionalPrecision),
|
|
341396
|
+
/* harmony export */ RatioFormatType: () => (/* binding */ RatioFormatType),
|
|
341142
341397
|
/* harmony export */ RatioType: () => (/* binding */ RatioType),
|
|
341143
341398
|
/* harmony export */ ScientificType: () => (/* binding */ ScientificType),
|
|
341144
341399
|
/* harmony export */ ShowSignOption: () => (/* binding */ ShowSignOption),
|
|
@@ -341152,6 +341407,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
341152
341407
|
/* harmony export */ parseFormatType: () => (/* binding */ parseFormatType),
|
|
341153
341408
|
/* harmony export */ parseFractionalPrecision: () => (/* binding */ parseFractionalPrecision),
|
|
341154
341409
|
/* harmony export */ parsePrecision: () => (/* binding */ parsePrecision),
|
|
341410
|
+
/* harmony export */ parseRatioFormatType: () => (/* binding */ parseRatioFormatType),
|
|
341155
341411
|
/* harmony export */ parseRatioType: () => (/* binding */ parseRatioType),
|
|
341156
341412
|
/* harmony export */ parseScientificType: () => (/* binding */ parseScientificType),
|
|
341157
341413
|
/* harmony export */ parseShowSignOption: () => (/* binding */ parseShowSignOption),
|
|
@@ -341296,6 +341552,16 @@ var RatioType;
|
|
|
341296
341552
|
/** scales the input ratio to its simplest integer form using the greatest common divisor (GCD) of the values. e.g. 0.3 turns into 3:10 */
|
|
341297
341553
|
RatioType["UseGreatestCommonDivisor"] = "UseGreatestCommonDivisor";
|
|
341298
341554
|
})(RatioType || (RatioType = {}));
|
|
341555
|
+
/** The format type for the numbers within a ratio.
|
|
341556
|
+
* @beta
|
|
341557
|
+
*/
|
|
341558
|
+
var RatioFormatType;
|
|
341559
|
+
(function (RatioFormatType) {
|
|
341560
|
+
/** Decimal display (ie 2.125) */
|
|
341561
|
+
RatioFormatType["Decimal"] = "Decimal";
|
|
341562
|
+
/** Fractional display (ie 2-1/8) */
|
|
341563
|
+
RatioFormatType["Fractional"] = "Fractional";
|
|
341564
|
+
})(RatioFormatType || (RatioFormatType = {}));
|
|
341299
341565
|
/** Determines how the sign of values are displayed
|
|
341300
341566
|
* @beta */
|
|
341301
341567
|
var ShowSignOption;
|
|
@@ -341341,6 +341607,18 @@ function parseRatioType(ratioType, formatName) {
|
|
|
341341
341607
|
}
|
|
341342
341608
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_0__.QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioType' attribute.`);
|
|
341343
341609
|
}
|
|
341610
|
+
/** @beta */
|
|
341611
|
+
function parseRatioFormatType(ratioFormatType, formatName) {
|
|
341612
|
+
const normalizedValue = ratioFormatType.toLowerCase();
|
|
341613
|
+
for (const key in RatioFormatType) {
|
|
341614
|
+
if (RatioFormatType.hasOwnProperty(key)) {
|
|
341615
|
+
const enumValue = RatioFormatType[key];
|
|
341616
|
+
if (enumValue.toLowerCase() === normalizedValue)
|
|
341617
|
+
return enumValue;
|
|
341618
|
+
}
|
|
341619
|
+
}
|
|
341620
|
+
throw new _Exception__WEBPACK_IMPORTED_MODULE_0__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_0__.QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'ratioFormatType' attribute.`);
|
|
341621
|
+
}
|
|
341344
341622
|
/** @beta */
|
|
341345
341623
|
function parseShowSignOption(showSignOption, formatName) {
|
|
341346
341624
|
switch (showSignOption.toLowerCase()) {
|
|
@@ -341502,10 +341780,18 @@ function parsePrecision(precision, type, formatName) {
|
|
|
341502
341780
|
case FormatType.Decimal:
|
|
341503
341781
|
case FormatType.Scientific:
|
|
341504
341782
|
case FormatType.Station:
|
|
341505
|
-
case FormatType.Ratio:
|
|
341506
341783
|
case FormatType.Bearing:
|
|
341507
341784
|
case FormatType.Azimuth:
|
|
341508
341785
|
return parseDecimalPrecision(precision, formatName);
|
|
341786
|
+
case FormatType.Ratio:
|
|
341787
|
+
// Ratio type can use either decimal or fractional precision depending on ratioFormatType
|
|
341788
|
+
// Try decimal first, if it fails, try fractional
|
|
341789
|
+
try {
|
|
341790
|
+
return parseDecimalPrecision(precision, formatName);
|
|
341791
|
+
}
|
|
341792
|
+
catch {
|
|
341793
|
+
return parseFractionalPrecision(precision, formatName);
|
|
341794
|
+
}
|
|
341509
341795
|
case FormatType.Fractional:
|
|
341510
341796
|
return parseFractionalPrecision(precision, formatName);
|
|
341511
341797
|
default:
|
|
@@ -341529,8 +341815,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
341529
341815
|
/* harmony export */ });
|
|
341530
341816
|
/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/quantity/lib/esm/Constants.js");
|
|
341531
341817
|
/* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Exception */ "../../core/quantity/lib/esm/Exception.js");
|
|
341532
|
-
/* harmony import */ var
|
|
341533
|
-
/* harmony import */ var
|
|
341818
|
+
/* harmony import */ var _FormatterSpec__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FormatterSpec */ "../../core/quantity/lib/esm/Formatter/FormatterSpec.js");
|
|
341819
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
341820
|
+
/* harmony import */ var _Quantity__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Quantity */ "../../core/quantity/lib/esm/Quantity.js");
|
|
341534
341821
|
/*---------------------------------------------------------------------------------------------
|
|
341535
341822
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
341536
341823
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -341542,6 +341829,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
341542
341829
|
|
|
341543
341830
|
|
|
341544
341831
|
|
|
341832
|
+
|
|
341545
341833
|
/** rounding additive
|
|
341546
341834
|
* @internal
|
|
341547
341835
|
*/
|
|
@@ -341642,7 +341930,7 @@ class Formatter {
|
|
|
341642
341930
|
static integerPartToText(wholePart, spec) {
|
|
341643
341931
|
// build invariant string represent wholePart
|
|
341644
341932
|
let formattedValue = wholePart.toFixed(0);
|
|
341645
|
-
if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(
|
|
341933
|
+
if ((formattedValue.length > 3) && (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.Use1000Separator) && (spec.format.thousandSeparator.length > 0))) {
|
|
341646
341934
|
let numSeparators = Math.floor(formattedValue.length / 3);
|
|
341647
341935
|
let groupLength = formattedValue.length % 3;
|
|
341648
341936
|
if (groupLength === 0) {
|
|
@@ -341689,7 +341977,7 @@ class Formatter {
|
|
|
341689
341977
|
else {
|
|
341690
341978
|
componentText = Formatter.formatMagnitude(compositeValue, spec);
|
|
341691
341979
|
}
|
|
341692
|
-
if (spec.format.hasFormatTraitSet(
|
|
341980
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ShowUnitLabel)) {
|
|
341693
341981
|
componentText = componentText + spec.format.uomSeparator + label;
|
|
341694
341982
|
}
|
|
341695
341983
|
return componentText;
|
|
@@ -341709,12 +341997,11 @@ class Formatter {
|
|
|
341709
341997
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);
|
|
341710
341998
|
if (i > 0 && unitConversion.offset !== 0) // offset should only ever be defined for major unit
|
|
341711
341999
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has a invalid unit specification.`);
|
|
341712
|
-
|
|
341713
|
-
if (spec.format.type ===
|
|
341714
|
-
|
|
341715
|
-
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidCompositeFormat, `The Format '${spec.format.name}' with type 'ratio' must have exactly one unit.`);
|
|
342000
|
+
// Handle ratio format with composite units
|
|
342001
|
+
if (spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio) {
|
|
342002
|
+
let ratioUnitValue = 0.0;
|
|
341716
342003
|
try {
|
|
341717
|
-
|
|
342004
|
+
ratioUnitValue = (0,_Quantity__WEBPACK_IMPORTED_MODULE_4__.applyConversion)(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;
|
|
341718
342005
|
}
|
|
341719
342006
|
catch (e) {
|
|
341720
342007
|
// The "InvertingZero" error is thrown when the value is zero and the conversion factor is inverted.
|
|
@@ -341722,12 +342009,13 @@ class Formatter {
|
|
|
341722
342009
|
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvertingZero) {
|
|
341723
342010
|
return { componentText: "1:0", isNegative: false };
|
|
341724
342011
|
}
|
|
342012
|
+
throw e;
|
|
341725
342013
|
}
|
|
341726
|
-
compositeStrings.push(this.formatRatio(
|
|
341727
|
-
isNegative =
|
|
342014
|
+
compositeStrings.push(this.formatRatio(ratioUnitValue, spec));
|
|
342015
|
+
isNegative = ratioUnitValue < 0;
|
|
341728
342016
|
continue;
|
|
341729
342017
|
}
|
|
341730
|
-
unitValue = (0,
|
|
342018
|
+
let unitValue = (0,_Quantity__WEBPACK_IMPORTED_MODULE_4__.applyConversion)(remainingMagnitude, unitConversion) + this.FPV_MINTHRESHOLD;
|
|
341731
342019
|
if (0 === i) {
|
|
341732
342020
|
// Only set isNegative from the first (major) unit conversion
|
|
341733
342021
|
isNegative = unitValue < 0;
|
|
@@ -341735,16 +342023,16 @@ class Formatter {
|
|
|
341735
342023
|
// but use higher precision if the format specifies it
|
|
341736
342024
|
const precisionScale = Math.pow(10, Math.max(8, spec.format.precision));
|
|
341737
342025
|
unitValue = Math.floor(unitValue * precisionScale + FPV_ROUNDFACTOR) / precisionScale;
|
|
341738
|
-
if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(
|
|
342026
|
+
if ((Math.abs(unitValue) < 0.0001) && spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ZeroEmpty))
|
|
341739
342027
|
return { componentText: "", isNegative: false };
|
|
341740
342028
|
}
|
|
341741
342029
|
if (i < (spec.format.units?.length ?? 0) - 1) {
|
|
341742
342030
|
let wholePart = Math.trunc(unitValue);
|
|
341743
342031
|
// Check if the remaining fractional part will round up to a full unit in the next (smaller) component
|
|
341744
|
-
if (spec.format.type ===
|
|
342032
|
+
if (spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && i === spec.unitConversions.length - 2) {
|
|
341745
342033
|
// For the second-to-last unit with fractional formatting, check if rounding causes carry-over
|
|
341746
342034
|
const fractionalPart = unitValue - wholePart;
|
|
341747
|
-
const nextUnitValue = (0,
|
|
342035
|
+
const nextUnitValue = (0,_Quantity__WEBPACK_IMPORTED_MODULE_4__.applyConversion)(fractionalPart, spec.unitConversions[i + 1].conversion);
|
|
341748
342036
|
// Create a FractionalNumeric to determine what the rounded value would be
|
|
341749
342037
|
const fn = new FractionalNumeric(Math.abs(nextUnitValue), spec.format.precision, true);
|
|
341750
342038
|
// If the fractional numeric rounds to a whole unit (integral part increased due to rounding)
|
|
@@ -341774,18 +342062,18 @@ class Formatter {
|
|
|
341774
342062
|
*/
|
|
341775
342063
|
static formatMagnitude(magnitude, spec) {
|
|
341776
342064
|
let posMagnitude = Math.abs(magnitude);
|
|
341777
|
-
if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(
|
|
342065
|
+
if ((Math.abs(posMagnitude) < 0.0001) && spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ZeroEmpty))
|
|
341778
342066
|
return "";
|
|
341779
|
-
if (spec.format.hasFormatTraitSet(
|
|
342067
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ApplyRounding))
|
|
341780
342068
|
posMagnitude = Math.abs(Formatter.roundDouble(magnitude, spec.format.roundFactor));
|
|
341781
|
-
const isSci = ((posMagnitude > 1.0e12) || spec.format.type ===
|
|
341782
|
-
const isDecimal = (isSci || spec.format.type ===
|
|
341783
|
-
const isFractional = (!isDecimal && spec.format.type ===
|
|
342069
|
+
const isSci = ((posMagnitude > 1.0e12) || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Scientific);
|
|
342070
|
+
const isDecimal = (isSci || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio;
|
|
342071
|
+
const isFractional = (!isDecimal && spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional);
|
|
341784
342072
|
/* const usesStops = spec.format.type === FormatType.Station; */
|
|
341785
|
-
const isPrecisionZero = spec.format.precision ===
|
|
341786
|
-
const isKeepSingleZero = spec.format.hasFormatTraitSet(
|
|
342073
|
+
const isPrecisionZero = spec.format.precision === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.DecimalPrecision.Zero;
|
|
342074
|
+
const isKeepSingleZero = spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.KeepSingleZero);
|
|
341787
342075
|
const precisionScale = Math.pow(10.0, spec.format.precision);
|
|
341788
|
-
const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(
|
|
342076
|
+
const isKeepTrailingZeroes = spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.TrailZeroes);
|
|
341789
342077
|
let expInt = 0.0;
|
|
341790
342078
|
if (isSci && (posMagnitude !== 0.0)) {
|
|
341791
342079
|
let exp = Math.log10(posMagnitude);
|
|
@@ -341795,10 +342083,10 @@ class Formatter {
|
|
|
341795
342083
|
negativeExp = true;
|
|
341796
342084
|
}
|
|
341797
342085
|
expInt = Math.floor(exp);
|
|
341798
|
-
if (spec.format.type ===
|
|
341799
|
-
if (spec.format.scientificType ===
|
|
342086
|
+
if (spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Scientific) {
|
|
342087
|
+
if (spec.format.scientificType === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ScientificType.ZeroNormalized && posMagnitude > 1.0)
|
|
341800
342088
|
expInt += 1.0;
|
|
341801
|
-
else if (spec.format.scientificType ===
|
|
342089
|
+
else if (spec.format.scientificType === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ScientificType.Normalized && posMagnitude < 1.0)
|
|
341802
342090
|
expInt += 1.0;
|
|
341803
342091
|
if (negativeExp)
|
|
341804
342092
|
expInt = -expInt;
|
|
@@ -341820,7 +342108,7 @@ class Formatter {
|
|
|
341820
342108
|
}
|
|
341821
342109
|
formattedValue = Formatter.integerPartToText(wholePart, spec);
|
|
341822
342110
|
if (isPrecisionZero) {
|
|
341823
|
-
if (spec.format.hasFormatTraitSet(
|
|
342111
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.KeepDecimalPoint) && !isKeepSingleZero)
|
|
341824
342112
|
formattedValue = formattedValue + spec.format.decimalSeparator;
|
|
341825
342113
|
else if (isKeepSingleZero)
|
|
341826
342114
|
formattedValue = `${formattedValue + spec.format.decimalSeparator}0`;
|
|
@@ -341835,7 +342123,7 @@ class Formatter {
|
|
|
341835
342123
|
if (fractionString.length > 0)
|
|
341836
342124
|
formattedValue = formattedValue + spec.format.decimalSeparator + fractionString;
|
|
341837
342125
|
else {
|
|
341838
|
-
if (spec.format.hasFormatTraitSet(
|
|
342126
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.KeepDecimalPoint))
|
|
341839
342127
|
formattedValue = formattedValue + spec.format.decimalSeparator + (isKeepSingleZero ? "0" : "");
|
|
341840
342128
|
}
|
|
341841
342129
|
}
|
|
@@ -341848,7 +342136,7 @@ class Formatter {
|
|
|
341848
342136
|
const fn = new FractionalNumeric(posMagnitude, spec.format.precision, true);
|
|
341849
342137
|
formattedValue = fn.getIntegralString();
|
|
341850
342138
|
if (!fn.isZero && fn.hasFractionPart) {
|
|
341851
|
-
const wholeFractionSeparator = spec.format.hasFormatTraitSet(
|
|
342139
|
+
const wholeFractionSeparator = spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.FractionDash) ? "-" : " ";
|
|
341852
342140
|
const fractionString = `${fn.getNumeratorString()}/${fn.getDenominatorString()}`;
|
|
341853
342141
|
formattedValue = formattedValue + wholeFractionSeparator + fractionString;
|
|
341854
342142
|
}
|
|
@@ -341877,7 +342165,7 @@ class Formatter {
|
|
|
341877
342165
|
else {
|
|
341878
342166
|
if (isKeepTrailingZeroes)
|
|
341879
342167
|
fractionString = spec.format.decimalSeparator + "".padEnd(spec.format.precision, "0");
|
|
341880
|
-
else if (spec.format.hasFormatTraitSet(
|
|
342168
|
+
else if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.KeepDecimalPoint))
|
|
341881
342169
|
fractionString = spec.format.decimalSeparator;
|
|
341882
342170
|
formattedValue = stationString + fractionString;
|
|
341883
342171
|
}
|
|
@@ -341906,21 +342194,21 @@ class Formatter {
|
|
|
341906
342194
|
let prefix = "";
|
|
341907
342195
|
let suffix = "";
|
|
341908
342196
|
switch (showSignOption) {
|
|
341909
|
-
case
|
|
342197
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ShowSignOption.NegativeParentheses:
|
|
341910
342198
|
if (isNegative) {
|
|
341911
342199
|
prefix = "(";
|
|
341912
342200
|
suffix = ")";
|
|
341913
342201
|
}
|
|
341914
342202
|
break;
|
|
341915
|
-
case
|
|
341916
|
-
if (isNegative && formatType !==
|
|
342203
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ShowSignOption.OnlyNegative:
|
|
342204
|
+
if (isNegative && formatType !== _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && formatType !== _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
341917
342205
|
prefix = "-";
|
|
341918
342206
|
}
|
|
341919
342207
|
break;
|
|
341920
|
-
case
|
|
342208
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ShowSignOption.SignAlways:
|
|
341921
342209
|
prefix = isNegative ? "-" : "+";
|
|
341922
342210
|
break;
|
|
341923
|
-
case
|
|
342211
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.ShowSignOption.NoSign:
|
|
341924
342212
|
default:
|
|
341925
342213
|
break;
|
|
341926
342214
|
}
|
|
@@ -341936,14 +342224,20 @@ class Formatter {
|
|
|
341936
342224
|
let suffix = "";
|
|
341937
342225
|
let formattedValue = "";
|
|
341938
342226
|
// Handle bearing/azimuth special formatting
|
|
341939
|
-
if (spec.format.type ===
|
|
342227
|
+
if (spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing || spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
341940
342228
|
const result = this.processBearingAndAzimuth(magnitude, spec);
|
|
341941
342229
|
magnitude = result.magnitude;
|
|
341942
342230
|
prefix = result.prefix ?? "";
|
|
341943
342231
|
suffix = result.suffix ?? "";
|
|
341944
342232
|
}
|
|
341945
342233
|
let formattedMagnitude = "";
|
|
341946
|
-
if (spec.format.
|
|
342234
|
+
if (spec.format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Ratio && spec.unitConversions.length >= 3) {
|
|
342235
|
+
// Handle ratio formatting separately when 2-unit composite provides 3 conversion specs
|
|
342236
|
+
const ratioResult = this.formatRatioQuantity(magnitude, spec);
|
|
342237
|
+
formattedMagnitude = ratioResult.componentText;
|
|
342238
|
+
valueIsNegative = ratioResult.isNegative;
|
|
342239
|
+
}
|
|
342240
|
+
else if (spec.format.hasUnits) {
|
|
341947
342241
|
const compositeResult = Formatter.formatComposite(magnitude, spec);
|
|
341948
342242
|
formattedMagnitude = compositeResult.componentText;
|
|
341949
342243
|
// Override the sign detection with the composite conversion result
|
|
@@ -341952,8 +342246,8 @@ class Formatter {
|
|
|
341952
342246
|
else {
|
|
341953
342247
|
// unitless quantity
|
|
341954
342248
|
formattedMagnitude = Formatter.formatMagnitude(magnitude, spec);
|
|
341955
|
-
if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(
|
|
341956
|
-
if (spec.format.hasFormatTraitSet(
|
|
342249
|
+
if (formattedMagnitude.length > 0 && spec.unitConversions.length > 0 && spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ShowUnitLabel)) {
|
|
342250
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.PrependUnitLabel))
|
|
341957
342251
|
formattedMagnitude = spec.unitConversions[0].label + spec.format.uomSeparator + formattedMagnitude;
|
|
341958
342252
|
else
|
|
341959
342253
|
formattedMagnitude = formattedMagnitude + spec.format.uomSeparator + spec.unitConversions[0].label;
|
|
@@ -341973,12 +342267,12 @@ class Formatter {
|
|
|
341973
342267
|
}
|
|
341974
342268
|
static processBearingAndAzimuth(magnitude, spec) {
|
|
341975
342269
|
const type = spec.format.type;
|
|
341976
|
-
if (type !==
|
|
342270
|
+
if (type !== _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing && type !== _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth)
|
|
341977
342271
|
return { magnitude };
|
|
341978
342272
|
const revolution = this.getRevolution(spec);
|
|
341979
342273
|
magnitude = this.normalizeAngle(magnitude, revolution);
|
|
341980
342274
|
const quarterRevolution = revolution / 4;
|
|
341981
|
-
if (type ===
|
|
342275
|
+
if (type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Bearing) {
|
|
341982
342276
|
let quadrant = 0;
|
|
341983
342277
|
while (magnitude > quarterRevolution) {
|
|
341984
342278
|
magnitude -= quarterRevolution;
|
|
@@ -342005,7 +342299,7 @@ class Formatter {
|
|
|
342005
342299
|
if (quadrant === 2 && spec.unitConversions.length > 0) {
|
|
342006
342300
|
// To determine if value is small, we need to convert it to the smallest unit presented and use the provided precision on it
|
|
342007
342301
|
const unitConversion = spec.unitConversions[spec.unitConversions.length - 1].conversion;
|
|
342008
|
-
const smallestFormattedDelta = (0,
|
|
342302
|
+
const smallestFormattedDelta = (0,_Quantity__WEBPACK_IMPORTED_MODULE_4__.applyConversion)((quarterRevolution - magnitude), unitConversion) + this.FPV_MINTHRESHOLD;
|
|
342009
342303
|
const precisionScale = Math.pow(10.0, spec.format.precision);
|
|
342010
342304
|
const floor = Math.floor((smallestFormattedDelta) * precisionScale + FPV_ROUNDFACTOR) / precisionScale;
|
|
342011
342305
|
if (floor === 0) {
|
|
@@ -342014,13 +342308,13 @@ class Formatter {
|
|
|
342014
342308
|
}
|
|
342015
342309
|
return { magnitude, prefix, suffix };
|
|
342016
342310
|
}
|
|
342017
|
-
if (type ===
|
|
342311
|
+
if (type === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Azimuth) {
|
|
342018
342312
|
let azimuthBase = 0; // default base is North
|
|
342019
342313
|
if (spec.format.azimuthBase !== undefined) {
|
|
342020
342314
|
if (spec.azimuthBaseConversion === undefined) {
|
|
342021
342315
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.MissingRequiredProperty, `Missing azimuth base conversion for interpreting ${spec.name}'s azimuth base.`);
|
|
342022
342316
|
}
|
|
342023
|
-
const azBaseQuantity = new
|
|
342317
|
+
const azBaseQuantity = new _Quantity__WEBPACK_IMPORTED_MODULE_4__.Quantity(spec.format.azimuthBaseUnit, spec.format.azimuthBase);
|
|
342024
342318
|
const azBaseConverted = azBaseQuantity.convertTo(spec.persistenceUnit, spec.azimuthBaseConversion);
|
|
342025
342319
|
if (azBaseConverted === undefined || !azBaseConverted.isValid) {
|
|
342026
342320
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.UnsupportedUnit, `Failed to convert azimuth base unit to ${spec.persistenceUnit.name}.`);
|
|
@@ -342050,40 +342344,87 @@ class Formatter {
|
|
|
342050
342344
|
if (spec.revolutionConversion === undefined) {
|
|
342051
342345
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.MissingRequiredProperty, `Missing revolution unit conversion for calculating ${spec.name}'s revolution.`);
|
|
342052
342346
|
}
|
|
342053
|
-
const revolution = new
|
|
342347
|
+
const revolution = new _Quantity__WEBPACK_IMPORTED_MODULE_4__.Quantity(spec.format.revolutionUnit, 1.0);
|
|
342054
342348
|
const converted = revolution.convertTo(spec.persistenceUnit, spec.revolutionConversion);
|
|
342055
342349
|
if (converted === undefined || !converted.isValid) {
|
|
342056
342350
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.UnsupportedUnit, `Failed to convert revolution unit to ${spec.persistenceUnit.name}.`);
|
|
342057
342351
|
}
|
|
342058
342352
|
return converted.magnitude;
|
|
342059
342353
|
}
|
|
342354
|
+
static formatRatioPart(value, spec, side) {
|
|
342355
|
+
const formatType = spec.format.ratioFormatType === "Fractional" ? _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional : _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Decimal;
|
|
342356
|
+
const tempFormat = spec.format.clone({ type: formatType });
|
|
342357
|
+
const tempSpec = new _FormatterSpec__WEBPACK_IMPORTED_MODULE_2__.FormatterSpec(spec.name, tempFormat, spec.unitConversions, spec.persistenceUnit);
|
|
342358
|
+
let formattedValue = this.formatMagnitude(value, tempSpec);
|
|
342359
|
+
// For fractional ratio formatting, suppress leading "0" if the value is purely fractional
|
|
342360
|
+
if (formatType === _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatType.Fractional && formattedValue.startsWith("0 ")) {
|
|
342361
|
+
formattedValue = formattedValue.substring(2); // Remove "0 " prefix
|
|
342362
|
+
}
|
|
342363
|
+
// Add unit label if ShowUnitLabel trait is set
|
|
342364
|
+
// unitConversions[0] = ratio scale factor, [1] = numerator unit, [2] = denominator unit
|
|
342365
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ShowUnitLabel) && spec.unitConversions.length >= 3) {
|
|
342366
|
+
const labelToAdd = side === "numerator" ? spec.unitConversions[1].label : spec.unitConversions[2].label;
|
|
342367
|
+
formattedValue = formattedValue + labelToAdd;
|
|
342368
|
+
}
|
|
342369
|
+
return formattedValue;
|
|
342370
|
+
}
|
|
342371
|
+
/** Format a ratio quantity value (separate from composite formatting) */
|
|
342372
|
+
static formatRatioQuantity(magnitude, spec) {
|
|
342373
|
+
const unitConversion = spec.unitConversions[0].conversion;
|
|
342374
|
+
let unitValue = 0.0;
|
|
342375
|
+
try {
|
|
342376
|
+
unitValue = (0,_Quantity__WEBPACK_IMPORTED_MODULE_4__.applyConversion)(magnitude, unitConversion) + this.FPV_MINTHRESHOLD;
|
|
342377
|
+
}
|
|
342378
|
+
catch (e) {
|
|
342379
|
+
// The "InvertingZero" error is thrown when the value is zero and the conversion factor is inverted.
|
|
342380
|
+
// For ratio, we return "1:0" as the formatted value.
|
|
342381
|
+
if (e instanceof _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError && e.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvertingZero) {
|
|
342382
|
+
return { componentText: "1:0", isNegative: false };
|
|
342383
|
+
}
|
|
342384
|
+
throw e;
|
|
342385
|
+
}
|
|
342386
|
+
const componentText = this.formatRatio(unitValue, spec);
|
|
342387
|
+
const isNegative = unitValue < 0;
|
|
342388
|
+
return { componentText, isNegative };
|
|
342389
|
+
}
|
|
342060
342390
|
static formatRatio(magnitude, spec) {
|
|
342061
342391
|
if (null === spec.format.ratioType)
|
|
342062
342392
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} must have a ratio type specified.`);
|
|
342063
342393
|
const precisionScale = Math.pow(10.0, spec.format.precision);
|
|
342394
|
+
const separator = spec.format.ratioSeparator;
|
|
342064
342395
|
let reciprocal = 0;
|
|
342396
|
+
// Helper to get unit labels if ShowUnitLabel is set
|
|
342397
|
+
const getUnitLabels = () => {
|
|
342398
|
+
if (spec.format.hasFormatTraitSet(_FormatEnums__WEBPACK_IMPORTED_MODULE_3__.FormatTraits.ShowUnitLabel) && spec.unitConversions.length >= 3) {
|
|
342399
|
+
return { numeratorLabel: spec.unitConversions[1].label, denominatorLabel: spec.unitConversions[2].label };
|
|
342400
|
+
}
|
|
342401
|
+
return { numeratorLabel: "", denominatorLabel: "" };
|
|
342402
|
+
};
|
|
342403
|
+
const { numeratorLabel, denominatorLabel } = getUnitLabels();
|
|
342065
342404
|
if (magnitude === 0.0)
|
|
342066
|
-
return
|
|
342405
|
+
return `0${separator}1`;
|
|
342067
342406
|
else
|
|
342068
342407
|
reciprocal = 1.0 / magnitude;
|
|
342069
342408
|
switch (spec.format.ratioType) {
|
|
342070
|
-
case
|
|
342071
|
-
return `1
|
|
342072
|
-
case
|
|
342073
|
-
return `${this.
|
|
342074
|
-
case
|
|
342075
|
-
if (magnitude > 1.0)
|
|
342076
|
-
return `${this.
|
|
342077
|
-
|
|
342078
|
-
|
|
342079
|
-
|
|
342409
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.RatioType.OneToN:
|
|
342410
|
+
return `1${numeratorLabel}${separator}${this.formatRatioPart(reciprocal, spec, "denominator")}`;
|
|
342411
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.RatioType.NToOne:
|
|
342412
|
+
return `${this.formatRatioPart(magnitude, spec, "numerator")}${separator}1${denominatorLabel}`;
|
|
342413
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.RatioType.ValueBased:
|
|
342414
|
+
if (magnitude > 1.0) {
|
|
342415
|
+
return `${this.formatRatioPart(magnitude, spec, "numerator")}${separator}1${denominatorLabel}`;
|
|
342416
|
+
}
|
|
342417
|
+
else {
|
|
342418
|
+
return `1${numeratorLabel}${separator}${this.formatRatioPart(reciprocal, spec, "denominator")}`;
|
|
342419
|
+
}
|
|
342420
|
+
case _FormatEnums__WEBPACK_IMPORTED_MODULE_3__.RatioType.UseGreatestCommonDivisor:
|
|
342080
342421
|
magnitude = Math.round(magnitude * precisionScale) / precisionScale;
|
|
342081
342422
|
let numerator = magnitude * precisionScale;
|
|
342082
342423
|
let denominator = precisionScale;
|
|
342083
342424
|
const gcd = FractionalNumeric.getGreatestCommonFactor(numerator, denominator);
|
|
342084
342425
|
numerator /= gcd;
|
|
342085
342426
|
denominator /= gcd;
|
|
342086
|
-
return `${this.
|
|
342427
|
+
return `${this.formatRatioPart(numerator, spec, "numerator")}${separator}${this.formatRatioPart(denominator, spec, "denominator")}`;
|
|
342087
342428
|
default:
|
|
342088
342429
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvalidCompositeFormat, `The Format ${spec.format.name} has an invalid ratio type specified.`);
|
|
342089
342430
|
}
|
|
@@ -342104,7 +342445,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
342104
342445
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
342105
342446
|
/* harmony export */ FormatterSpec: () => (/* binding */ FormatterSpec)
|
|
342106
342447
|
/* harmony export */ });
|
|
342107
|
-
/* harmony import */ var
|
|
342448
|
+
/* harmony import */ var _FormatEnums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
342449
|
+
/* harmony import */ var _Formatter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Formatter */ "../../core/quantity/lib/esm/Formatter/Formatter.js");
|
|
342108
342450
|
/*---------------------------------------------------------------------------------------------
|
|
342109
342451
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
342110
342452
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -342113,6 +342455,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
342113
342455
|
* @module Quantity
|
|
342114
342456
|
*/
|
|
342115
342457
|
|
|
342458
|
+
|
|
342116
342459
|
// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses
|
|
342117
342460
|
// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative
|
|
342118
342461
|
/** 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.
|
|
@@ -342159,6 +342502,49 @@ class FormatterSpec {
|
|
|
342159
342502
|
get persistenceUnit() { return this._persistenceUnit; }
|
|
342160
342503
|
get azimuthBaseConversion() { return this._azimuthBaseConversion; }
|
|
342161
342504
|
get revolutionConversion() { return this._revolutionConversion; }
|
|
342505
|
+
/** Build conversion specs for ratio format with 2 composite units (numerator/denominator). */
|
|
342506
|
+
static async getRatioUnitConversions(units, unitsProvider, persistenceUnit) {
|
|
342507
|
+
const conversions = [];
|
|
342508
|
+
const [numeratorUnit, numeratorLabel] = units[0];
|
|
342509
|
+
const [denominatorUnit, denominatorLabel] = units[1];
|
|
342510
|
+
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
342511
|
+
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
342512
|
+
const displayRatioScale = denominatorToNumerator.factor;
|
|
342513
|
+
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
342514
|
+
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
342515
|
+
const persistenceName = persistenceUnit.name.toUpperCase();
|
|
342516
|
+
const numName = numeratorUnit.name.toUpperCase().split(".").pop() ?? "";
|
|
342517
|
+
const denName = denominatorUnit.name.toUpperCase().split(".").pop() ?? "";
|
|
342518
|
+
// Split by word boundaries (underscores, dots) and check for exact token matches
|
|
342519
|
+
const persistenceTokens = persistenceName.split(/[._]/);
|
|
342520
|
+
const isPersistenceMatchingRatio = persistenceTokens.includes(numName) && persistenceTokens.includes(denName);
|
|
342521
|
+
const ratioScaleFactor = isPersistenceMatchingRatio ? 1.0 : displayRatioScale;
|
|
342522
|
+
// First conversion spec: effective ratio unit conversion
|
|
342523
|
+
const ratioConversionSpec = {
|
|
342524
|
+
name: `${numeratorUnit.name}_per_${denominatorUnit.name}`,
|
|
342525
|
+
label: "",
|
|
342526
|
+
system: numeratorUnit.system,
|
|
342527
|
+
conversion: { factor: ratioScaleFactor, offset: 0.0 },
|
|
342528
|
+
};
|
|
342529
|
+
conversions.push(ratioConversionSpec);
|
|
342530
|
+
// Numerator unit for label lookup
|
|
342531
|
+
const numeratorSpec = {
|
|
342532
|
+
name: numeratorUnit.name,
|
|
342533
|
+
label: numeratorLabel?.length ? numeratorLabel : numeratorUnit.label,
|
|
342534
|
+
system: numeratorUnit.system,
|
|
342535
|
+
conversion: { factor: 1.0, offset: 0.0 },
|
|
342536
|
+
};
|
|
342537
|
+
conversions.push(numeratorSpec);
|
|
342538
|
+
// Denominator unit for label lookup
|
|
342539
|
+
const denominatorSpec = {
|
|
342540
|
+
name: denominatorUnit.name,
|
|
342541
|
+
label: denominatorLabel?.length ? denominatorLabel : denominatorUnit.label,
|
|
342542
|
+
system: denominatorUnit.system,
|
|
342543
|
+
conversion: { factor: 1.0, offset: 0.0 },
|
|
342544
|
+
};
|
|
342545
|
+
conversions.push(denominatorSpec);
|
|
342546
|
+
return conversions;
|
|
342547
|
+
}
|
|
342162
342548
|
/** Get an array of UnitConversionSpecs, one for each unit that is to be shown in the formatted quantity string. */
|
|
342163
342549
|
static async getUnitConversions(format, unitsProvider, inputUnit) {
|
|
342164
342550
|
const conversions = [];
|
|
@@ -342172,6 +342558,10 @@ class FormatterSpec {
|
|
|
342172
342558
|
throw new Error("Formatter Spec needs persistence unit to be specified");
|
|
342173
342559
|
}
|
|
342174
342560
|
}
|
|
342561
|
+
// Handle 2-unit composite for ratio formats (scale factors)
|
|
342562
|
+
if (format.type === _FormatEnums__WEBPACK_IMPORTED_MODULE_0__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
342563
|
+
return FormatterSpec.getRatioUnitConversions(format.units, unitsProvider, persistenceUnit);
|
|
342564
|
+
}
|
|
342175
342565
|
if (format.units) {
|
|
342176
342566
|
let convertFromUnit = inputUnit;
|
|
342177
342567
|
for (const unit of format.units) {
|
|
@@ -342228,7 +342618,7 @@ class FormatterSpec {
|
|
|
342228
342618
|
}
|
|
342229
342619
|
/** Format a quantity value. */
|
|
342230
342620
|
applyFormatting(magnitude) {
|
|
342231
|
-
return
|
|
342621
|
+
return _Formatter__WEBPACK_IMPORTED_MODULE_1__.Formatter.formatQuantity(magnitude, this);
|
|
342232
342622
|
}
|
|
342233
342623
|
}
|
|
342234
342624
|
|
|
@@ -342336,13 +342726,14 @@ var ParseError;
|
|
|
342336
342726
|
ParseError[ParseError["BearingPrefixOrSuffixMissing"] = 7] = "BearingPrefixOrSuffixMissing";
|
|
342337
342727
|
ParseError[ParseError["MathematicOperationFoundButIsNotAllowed"] = 8] = "MathematicOperationFoundButIsNotAllowed";
|
|
342338
342728
|
ParseError[ParseError["BearingAngleOutOfRange"] = 9] = "BearingAngleOutOfRange";
|
|
342729
|
+
ParseError[ParseError["InvalidMathResult"] = 10] = "InvalidMathResult";
|
|
342339
342730
|
})(ParseError || (ParseError = {}));
|
|
342340
342731
|
var Operator;
|
|
342341
342732
|
(function (Operator) {
|
|
342342
342733
|
Operator["addition"] = "+";
|
|
342343
342734
|
Operator["subtraction"] = "-";
|
|
342344
342735
|
Operator["multiplication"] = "*";
|
|
342345
|
-
Operator["division"] = "/";
|
|
342736
|
+
Operator["division"] = "/";
|
|
342346
342737
|
})(Operator || (Operator = {}));
|
|
342347
342738
|
function isOperator(char) {
|
|
342348
342739
|
if (typeof char === "number") {
|
|
@@ -343097,36 +343488,107 @@ class Parser {
|
|
|
343097
343488
|
magnitude = this.normalizeAngle(magnitude, revolution);
|
|
343098
343489
|
return { ok: true, value: magnitude };
|
|
343099
343490
|
}
|
|
343491
|
+
/**
|
|
343492
|
+
* Parse a ratio part string (numerator or denominator) to extract the numeric value and optional unit label.
|
|
343493
|
+
* This method processes tokens without applying unit conversions, allowing the ratio format
|
|
343494
|
+
* handler to manage conversions at the ratio level.
|
|
343495
|
+
*
|
|
343496
|
+
*
|
|
343497
|
+
* @note Fractions are already handled by parseQuantitySpecification, which converts them to
|
|
343498
|
+
* single numeric tokens (e.g., "1/2" becomes 0.5).
|
|
343499
|
+
*
|
|
343500
|
+
* @param partStr The string to parse, which may contain a number, fraction, or mixed fraction with optional unit label.
|
|
343501
|
+
* @param format The format specification used for token parsing.
|
|
343502
|
+
* @returns An object containing the parsed numeric value and optional unit label. Returns NaN for value if no number is found.
|
|
343503
|
+
*/
|
|
343504
|
+
static parseRatioPart(partStr, format) {
|
|
343505
|
+
partStr = partStr.trim();
|
|
343506
|
+
// Parse tokens - fractions are automatically converted to decimal values by parseQuantitySpecification
|
|
343507
|
+
const tempFormat = format.clone({ type: _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_2__.FormatType.Decimal });
|
|
343508
|
+
const tokens = Parser.parseQuantitySpecification(partStr, tempFormat);
|
|
343509
|
+
let value = NaN;
|
|
343510
|
+
let unitLabel;
|
|
343511
|
+
// Pre-process: merge negative operators with following numbers
|
|
343512
|
+
const processedTokens = [];
|
|
343513
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
343514
|
+
const token = tokens[i];
|
|
343515
|
+
if (token.isOperator && i === 0 && token.value === "-" &&
|
|
343516
|
+
i + 1 < tokens.length && tokens[i + 1].isNumber) {
|
|
343517
|
+
// Merge negative sign with number
|
|
343518
|
+
processedTokens.push(new ParseToken(-tokens[i + 1].value));
|
|
343519
|
+
i++; // Skip the number token since we consumed it
|
|
343520
|
+
}
|
|
343521
|
+
else {
|
|
343522
|
+
processedTokens.push(token);
|
|
343523
|
+
}
|
|
343524
|
+
}
|
|
343525
|
+
// Extract numeric value and unit label from processed tokens
|
|
343526
|
+
for (const token of processedTokens) {
|
|
343527
|
+
if (token.isNumber && isNaN(value)) {
|
|
343528
|
+
value = token.value;
|
|
343529
|
+
}
|
|
343530
|
+
else if (token.isString && !token.isOperator) {
|
|
343531
|
+
// String token that's not an operator - treat as unit label
|
|
343532
|
+
unitLabel = token.value;
|
|
343533
|
+
}
|
|
343534
|
+
}
|
|
343535
|
+
return { value, unitLabel };
|
|
343536
|
+
}
|
|
343100
343537
|
static parseRatioFormat(inString, spec) {
|
|
343101
343538
|
if (!inString)
|
|
343102
343539
|
return { ok: false, error: ParseError.NoValueOrUnitFoundInString };
|
|
343103
|
-
const
|
|
343540
|
+
const separator = spec.format.ratioSeparator ?? ":";
|
|
343541
|
+
const parts = inString.split(separator);
|
|
343104
343542
|
if (parts.length > 2)
|
|
343105
343543
|
return { ok: false, error: ParseError.UnableToConvertParseTokensToQuantity };
|
|
343106
|
-
|
|
343107
|
-
|
|
343108
|
-
if (parts.length === 1) {
|
|
343109
|
-
|
|
343110
|
-
|
|
343111
|
-
|
|
343112
|
-
|
|
343544
|
+
// If the string doesn't contain the expected separator but contains other ratio-like separators,
|
|
343545
|
+
// return an error since the wrong separator was used
|
|
343546
|
+
if (parts.length === 1 && !inString.includes(separator)) {
|
|
343547
|
+
// Check if the string contains other common ratio separators
|
|
343548
|
+
const otherSeparators = [":", "=", "/"];
|
|
343549
|
+
for (const otherSep of otherSeparators) {
|
|
343550
|
+
if (otherSep !== separator && inString.includes(otherSep)) {
|
|
343551
|
+
// The string looks like a ratio but uses the wrong separator
|
|
343552
|
+
return { ok: false, error: ParseError.UnableToConvertParseTokensToQuantity };
|
|
343553
|
+
}
|
|
343554
|
+
}
|
|
343555
|
+
// Parse as a regular quantity value (numerator only, denominator = 1)
|
|
343556
|
+
const result = this.parseAndProcessTokens(inString, spec.format, spec.unitConversions);
|
|
343557
|
+
return result;
|
|
343113
343558
|
}
|
|
343114
|
-
|
|
343559
|
+
// Parse numerator and denominator parts which may include unit labels
|
|
343560
|
+
const numeratorPart = this.parseRatioPart(parts[0], spec.format);
|
|
343561
|
+
const denominatorPart = parts.length === 1 ? { value: 1.0 } : this.parseRatioPart(parts[1], spec.format);
|
|
343562
|
+
if (isNaN(numeratorPart.value) || isNaN(denominatorPart.value))
|
|
343115
343563
|
return { ok: false, error: ParseError.NoValueOrUnitFoundInString };
|
|
343564
|
+
// Handle 2-unit composite case - simpler conversion using the pre-computed scale factor
|
|
343565
|
+
if (spec.format.units && spec.format.units.length === 2 && spec.unitConversions.length >= 3) {
|
|
343566
|
+
const ratioConvSpec = spec.unitConversions[0];
|
|
343567
|
+
const scaleFactor = ratioConvSpec.conversion.factor;
|
|
343568
|
+
if (denominatorPart.value === 0) {
|
|
343569
|
+
return { ok: false, error: ParseError.InvalidMathResult };
|
|
343570
|
+
}
|
|
343571
|
+
// The ratio value is numerator/denominator in the display units (e.g., 12 for 12"=1')
|
|
343572
|
+
// Divide by scale factor to get persistence unit value (e.g., 12/12 = 1.0)
|
|
343573
|
+
const ratioValue = numeratorPart.value / denominatorPart.value;
|
|
343574
|
+
const convertedValue = ratioValue / scaleFactor;
|
|
343575
|
+
return { ok: true, value: convertedValue };
|
|
343576
|
+
}
|
|
343577
|
+
// Original flow for 1-unit composite - use Quantity.convertTo for proper unit conversion
|
|
343116
343578
|
const defaultUnit = spec.format.units && spec.format.units.length > 0 ? spec.format.units[0][0] : undefined;
|
|
343117
343579
|
const unitConversion = defaultUnit ? Parser.tryFindUnitConversion(defaultUnit.label, spec.unitConversions, defaultUnit) : undefined;
|
|
343118
343580
|
if (!unitConversion) {
|
|
343119
343581
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.MissingRequiredProperty, `Missing input unit or unit conversion for interpreting ${spec.format.name}.`);
|
|
343120
343582
|
}
|
|
343121
|
-
if (
|
|
343122
|
-
if (unitConversion.inversion &&
|
|
343583
|
+
if (denominatorPart.value === 0) {
|
|
343584
|
+
if (unitConversion.inversion && numeratorPart.value === 1)
|
|
343123
343585
|
return { ok: true, value: 0.0 };
|
|
343124
343586
|
else
|
|
343125
|
-
return { ok: false, error: ParseError.
|
|
343587
|
+
return { ok: false, error: ParseError.InvalidMathResult };
|
|
343126
343588
|
}
|
|
343127
343589
|
let quantity;
|
|
343128
343590
|
if (spec.format.units && spec.outUnit) {
|
|
343129
|
-
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_3__.Quantity(spec.format.units[0][0],
|
|
343591
|
+
quantity = new _Quantity__WEBPACK_IMPORTED_MODULE_3__.Quantity(spec.format.units[0][0], numeratorPart.value / denominatorPart.value);
|
|
343130
343592
|
}
|
|
343131
343593
|
else {
|
|
343132
343594
|
throw new _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError(_Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.MissingRequiredProperty, "Missing presentation unit or persistence unit for ratio format.");
|
|
@@ -343138,7 +343600,7 @@ class Parser {
|
|
|
343138
343600
|
catch (err) {
|
|
343139
343601
|
// for input of "0:N" with reversed unit
|
|
343140
343602
|
if (err instanceof _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError && err.errorNumber === _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus.InvertingZero) {
|
|
343141
|
-
return { ok: false, error: ParseError.
|
|
343603
|
+
return { ok: false, error: ParseError.InvalidMathResult };
|
|
343142
343604
|
}
|
|
343143
343605
|
}
|
|
343144
343606
|
if (converted === undefined || !converted.isValid) {
|
|
@@ -343264,7 +343726,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
343264
343726
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
343265
343727
|
/* harmony export */ ParserSpec: () => (/* binding */ ParserSpec)
|
|
343266
343728
|
/* harmony export */ });
|
|
343267
|
-
/* harmony import */ var
|
|
343729
|
+
/* harmony import */ var _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Formatter/FormatEnums */ "../../core/quantity/lib/esm/Formatter/FormatEnums.js");
|
|
343730
|
+
/* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Parser */ "../../core/quantity/lib/esm/Parser.js");
|
|
343268
343731
|
/*---------------------------------------------------------------------------------------------
|
|
343269
343732
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
343270
343733
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -343273,6 +343736,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
343273
343736
|
* @module Quantity
|
|
343274
343737
|
*/
|
|
343275
343738
|
|
|
343739
|
+
|
|
343276
343740
|
/** A ParserSpec holds information needed to parse a string into a quantity synchronously.
|
|
343277
343741
|
* @beta
|
|
343278
343742
|
*/
|
|
@@ -343298,6 +343762,51 @@ class ParserSpec {
|
|
|
343298
343762
|
get outUnit() { return this._outUnit; }
|
|
343299
343763
|
get azimuthBaseConversion() { return this._azimuthBaseConversion; }
|
|
343300
343764
|
get revolutionConversion() { return this._revolutionConversion; }
|
|
343765
|
+
/** Build conversion specs for ratio format with 2 composite units (numerator/denominator). */
|
|
343766
|
+
static async getRatioUnitConversions(units, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
343767
|
+
const conversions = [];
|
|
343768
|
+
const [numeratorUnit, numeratorLabel] = units[0];
|
|
343769
|
+
const [denominatorUnit, denominatorLabel] = units[1];
|
|
343770
|
+
// Compute ratio scale: how many numerator units per denominator unit (e.g., IN:FT = 12)
|
|
343771
|
+
const denominatorToNumerator = await unitsProvider.getConversion(denominatorUnit, numeratorUnit);
|
|
343772
|
+
const displayRatioScale = denominatorToNumerator.factor;
|
|
343773
|
+
// Avoid double-scaling: if persistence unit already encodes the display ratio, use factor 1.
|
|
343774
|
+
// Check by name heuristic (e.g., IN_PER_FT with ratioUnits [IN, FT] → no scaling needed)
|
|
343775
|
+
const persistenceName = outUnit.name.toUpperCase();
|
|
343776
|
+
const numName = numeratorUnit.name.toUpperCase().split(".").pop() ?? "";
|
|
343777
|
+
const denName = denominatorUnit.name.toUpperCase().split(".").pop() ?? "";
|
|
343778
|
+
// Split by word boundaries (underscores, dots) and check for exact token matches
|
|
343779
|
+
const persistenceTokens = persistenceName.split(/[._]/);
|
|
343780
|
+
const isPersistenceMatchingRatio = persistenceTokens.includes(numName) && persistenceTokens.includes(denName);
|
|
343781
|
+
const ratioScaleFactor = isPersistenceMatchingRatio ? 1.0 : displayRatioScale;
|
|
343782
|
+
// First conversion spec: effective ratio unit conversion
|
|
343783
|
+
const ratioConversionSpec = {
|
|
343784
|
+
name: `${numeratorUnit.name}_per_${denominatorUnit.name}`,
|
|
343785
|
+
label: "",
|
|
343786
|
+
system: numeratorUnit.system,
|
|
343787
|
+
conversion: { factor: ratioScaleFactor, offset: 0.0 },
|
|
343788
|
+
};
|
|
343789
|
+
conversions.push(ratioConversionSpec);
|
|
343790
|
+
// Numerator unit for label lookup
|
|
343791
|
+
const numeratorSpec = {
|
|
343792
|
+
name: numeratorUnit.name,
|
|
343793
|
+
label: numeratorLabel?.length ? numeratorLabel : numeratorUnit.label,
|
|
343794
|
+
system: numeratorUnit.system,
|
|
343795
|
+
conversion: { factor: 1.0, offset: 0.0 },
|
|
343796
|
+
parseLabels: altUnitLabelsProvider?.getAlternateUnitLabels(numeratorUnit),
|
|
343797
|
+
};
|
|
343798
|
+
conversions.push(numeratorSpec);
|
|
343799
|
+
// Denominator unit for label lookup
|
|
343800
|
+
const denominatorSpec = {
|
|
343801
|
+
name: denominatorUnit.name,
|
|
343802
|
+
label: denominatorLabel?.length ? denominatorLabel : denominatorUnit.label,
|
|
343803
|
+
system: denominatorUnit.system,
|
|
343804
|
+
conversion: { factor: 1.0, offset: 0.0 },
|
|
343805
|
+
parseLabels: altUnitLabelsProvider?.getAlternateUnitLabels(denominatorUnit),
|
|
343806
|
+
};
|
|
343807
|
+
conversions.push(denominatorSpec);
|
|
343808
|
+
return conversions;
|
|
343809
|
+
}
|
|
343301
343810
|
/** Static async method to create a ParserSpec given the format and unit of the quantity that will be passed to the Parser. The input unit will
|
|
343302
343811
|
* be used to generate conversion information for each unit specified in the Format. This method is async due to the fact that the units provider must make
|
|
343303
343812
|
* async calls to lookup unit definitions.
|
|
@@ -343306,7 +343815,14 @@ class ParserSpec {
|
|
|
343306
343815
|
* @param outUnit The unit a value will be formatted to. This unit is often referred to as persistence unit.
|
|
343307
343816
|
*/
|
|
343308
343817
|
static async create(format, unitsProvider, outUnit, altUnitLabelsProvider) {
|
|
343309
|
-
|
|
343818
|
+
let conversions;
|
|
343819
|
+
// For ratio formats with 2 composite units, use private helper method
|
|
343820
|
+
if (format.type === _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_0__.FormatType.Ratio && format.units && format.units.length === 2) {
|
|
343821
|
+
conversions = await ParserSpec.getRatioUnitConversions(format.units, unitsProvider, outUnit, altUnitLabelsProvider);
|
|
343822
|
+
}
|
|
343823
|
+
else {
|
|
343824
|
+
conversions = await _Parser__WEBPACK_IMPORTED_MODULE_1__.Parser.createUnitConversionSpecsForUnit(unitsProvider, outUnit, altUnitLabelsProvider);
|
|
343825
|
+
}
|
|
343310
343826
|
const spec = new ParserSpec(outUnit, format, conversions);
|
|
343311
343827
|
if (format.azimuthBaseUnit !== undefined) {
|
|
343312
343828
|
if (outUnit !== undefined) {
|
|
@@ -343328,7 +343844,7 @@ class ParserSpec {
|
|
|
343328
343844
|
}
|
|
343329
343845
|
/** Do the parsing. Done this way to allow Custom Parser Specs to parse custom formatted strings into their quantities. */
|
|
343330
343846
|
parseToQuantityValue(inString) {
|
|
343331
|
-
return
|
|
343847
|
+
return _Parser__WEBPACK_IMPORTED_MODULE_1__.Parser.parseQuantityString(inString, this);
|
|
343332
343848
|
}
|
|
343333
343849
|
}
|
|
343334
343850
|
|
|
@@ -343526,6 +344042,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
343526
344042
|
/* harmony export */ QuantityConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.QuantityConstants),
|
|
343527
344043
|
/* harmony export */ QuantityError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityError),
|
|
343528
344044
|
/* harmony export */ QuantityStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_1__.QuantityStatus),
|
|
344045
|
+
/* harmony export */ RatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.RatioFormatType),
|
|
343529
344046
|
/* harmony export */ RatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.RatioType),
|
|
343530
344047
|
/* harmony export */ ScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.ScientificType),
|
|
343531
344048
|
/* harmony export */ ShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.ShowSignOption),
|
|
@@ -343544,6 +344061,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
343544
344061
|
/* harmony export */ parseFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseFormatType),
|
|
343545
344062
|
/* harmony export */ parseFractionalPrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseFractionalPrecision),
|
|
343546
344063
|
/* harmony export */ parsePrecision: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parsePrecision),
|
|
344064
|
+
/* harmony export */ parseRatioFormatType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseRatioFormatType),
|
|
343547
344065
|
/* harmony export */ parseRatioType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseRatioType),
|
|
343548
344066
|
/* harmony export */ parseScientificType: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseScientificType),
|
|
343549
344067
|
/* harmony export */ parseShowSignOption: () => (/* reexport safe */ _Formatter_FormatEnums__WEBPACK_IMPORTED_MODULE_9__.parseShowSignOption),
|
|
@@ -344503,7 +345021,7 @@ class TestContext {
|
|
|
344503
345021
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
344504
345022
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
344505
345023
|
await core_frontend_1.NoRenderApp.startup({
|
|
344506
|
-
applicationVersion: "5.
|
|
345024
|
+
applicationVersion: "5.7.0-dev.1",
|
|
344507
345025
|
applicationId: this.settings.gprid,
|
|
344508
345026
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
344509
345027
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -371196,7 +371714,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
371196
371714
|
/***/ ((module) => {
|
|
371197
371715
|
|
|
371198
371716
|
"use strict";
|
|
371199
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.
|
|
371717
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.7.0-dev.1","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","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":{"@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","typemoq":"^2.1.0","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"}}');
|
|
371200
371718
|
|
|
371201
371719
|
/***/ }),
|
|
371202
371720
|
|