@itwin/core-quantity 5.10.0-dev.7 → 5.10.0-dev.8

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/BasicUnitsProvider.js.map +1 -1
  3. package/lib/cjs/CompositeUnitsProvider.js.map +1 -1
  4. package/lib/cjs/Constants.js.map +1 -1
  5. package/lib/cjs/Exception.js.map +1 -1
  6. package/lib/cjs/FormatSpecHandle.js.map +1 -1
  7. package/lib/cjs/Formatter/Format.js.map +1 -1
  8. package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
  9. package/lib/cjs/Formatter/Formatter.js.map +1 -1
  10. package/lib/cjs/Formatter/FormatterSpec.js.map +1 -1
  11. package/lib/cjs/Formatter/FormattingReadyCollector.js.map +1 -1
  12. package/lib/cjs/Formatter/Interfaces.js.map +1 -1
  13. package/lib/cjs/Interfaces.js.map +1 -1
  14. package/lib/cjs/Parser.js.map +1 -1
  15. package/lib/cjs/ParserSpec.js.map +1 -1
  16. package/lib/cjs/Quantity.js.map +1 -1
  17. package/lib/cjs/QuantityLoggerCategory.js.map +1 -1
  18. package/lib/cjs/SerializedUnitSchema.js.map +1 -1
  19. package/lib/cjs/Unit.js.map +1 -1
  20. package/lib/cjs/UnitConversion/Graph.js.map +1 -1
  21. package/lib/cjs/UnitConversion/Parser.js.map +1 -1
  22. package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
  23. package/lib/cjs/UnitConversion/UnitDefinitionResolver.js.map +1 -1
  24. package/lib/cjs/UnitConversion/nameUtils.js.map +1 -1
  25. package/lib/cjs/core-quantity.js.map +1 -1
  26. package/lib/cjs/internal/cross-package.js.map +1 -1
  27. package/lib/esm/BasicUnitsProvider.js.map +1 -1
  28. package/lib/esm/CompositeUnitsProvider.js.map +1 -1
  29. package/lib/esm/Constants.js.map +1 -1
  30. package/lib/esm/Exception.js.map +1 -1
  31. package/lib/esm/FormatSpecHandle.js.map +1 -1
  32. package/lib/esm/Formatter/Format.js.map +1 -1
  33. package/lib/esm/Formatter/FormatEnums.js.map +1 -1
  34. package/lib/esm/Formatter/Formatter.js.map +1 -1
  35. package/lib/esm/Formatter/FormatterSpec.js.map +1 -1
  36. package/lib/esm/Formatter/FormattingReadyCollector.js.map +1 -1
  37. package/lib/esm/Formatter/Interfaces.js.map +1 -1
  38. package/lib/esm/Interfaces.js.map +1 -1
  39. package/lib/esm/Parser.js.map +1 -1
  40. package/lib/esm/ParserSpec.js.map +1 -1
  41. package/lib/esm/Quantity.js.map +1 -1
  42. package/lib/esm/QuantityLoggerCategory.js.map +1 -1
  43. package/lib/esm/SerializedUnitSchema.js.map +1 -1
  44. package/lib/esm/Unit.js.map +1 -1
  45. package/lib/esm/UnitConversion/Graph.js.map +1 -1
  46. package/lib/esm/UnitConversion/Parser.js.map +1 -1
  47. package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
  48. package/lib/esm/UnitConversion/UnitDefinitionResolver.js.map +1 -1
  49. package/lib/esm/UnitConversion/nameUtils.js.map +1 -1
  50. package/lib/esm/core-quantity.js.map +1 -1
  51. package/lib/esm/internal/cross-package.js.map +1 -1
  52. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @itwin/core-quantity
2
2
 
3
- This log was last generated on Tue, 05 May 2026 17:44:54 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 08 May 2026 20:37:55 GMT and should not be manually modified.
4
+
5
+ ## 5.9.2
6
+ Fri, 08 May 2026 20:36:41 GMT
7
+
8
+ ### Updates
9
+
10
+ - Fix FormatSpecHandle stale state during onFormattingReady
4
11
 
5
12
  ## 5.9.1
6
13
  Tue, 05 May 2026 17:43:30 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"BasicUnitsProvider.js","sourceRoot":"","sources":["../../src/BasicUnitsProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAq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E,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAClF,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,iCAAoB,CAAC,mBAAmB,EAAE,CAAC;YACrG,CAAC;QACH,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC9D,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAClF,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,iCAAoB,CAAC,oBAAoB,EAAE,CAAC;YACtG,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChF,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;CACF;AA9GD,gDA8GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { UnitConversionInvert, type UnitConversionProps, type UnitProps, type UnitsProvider } from \"./Interfaces\";\r\nimport type { SerializedInvertedUnit, SerializedUnit, SerializedUnitSchema } from \"./SerializedUnitSchema\";\r\nimport { type ResolvedUnit, UnitDefinitionResolver } from \"./UnitConversion/UnitDefinitionResolver\";\r\nimport { qualifyItemName } from \"./UnitConversion/nameUtils\";\r\nimport { BadUnit } from \"./Unit\";\r\n\r\ninterface IndexedUnit {\r\n readonly props: UnitProps;\r\n readonly resolved: ResolvedUnit;\r\n}\r\n\r\ninterface InvertedEntry {\r\n readonly props: UnitProps;\r\n readonly invertsUnitName: string;\r\n}\r\n\r\n/** Immutable lookup indexes resolved from the bundled Units.json. */\r\ninterface ResolvedState {\r\n readonly nameMap: Map<string, IndexedUnit>;\r\n readonly labelMap: Map<string, IndexedUnit[]>;\r\n readonly phenomenonMap: Map<string, IndexedUnit[]>;\r\n readonly invertedUnits: Map<string, InvertedEntry>;\r\n readonly schemaName: string;\r\n}\r\n\r\n// Module-level cache: the unit data is derived deterministically from the bundled Units.json\r\n// asset, so the resolved indexes are effectively an immutable constant. Caching at module\r\n// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.\r\n// in tests or when composed inside CompositeUnitsProvider).\r\n// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint\r\n// near-zero until a provider method is actually called.\r\nlet _resolvePromise: Promise<ResolvedState> | undefined;\r\nlet _permanentError: Error | undefined;\r\n\r\nasync function resolveState(): Promise<ResolvedState> {\r\n if (_permanentError !== undefined) {\r\n throw _permanentError;\r\n }\r\n if (!_resolvePromise) {\r\n _resolvePromise = _buildState().catch((err) => {\r\n _permanentError = err instanceof Error ? err : new Error(String(err));\r\n _resolvePromise = undefined;\r\n throw _permanentError;\r\n });\r\n }\r\n return _resolvePromise;\r\n}\r\n\r\n/** @internal — test use only. Resets the module-level lazy cache. */\r\nexport function _testResetUnitsCache(): void {\r\n _resolvePromise = undefined;\r\n _permanentError = undefined;\r\n}\r\n\r\nasync function _buildState(): Promise<ResolvedState> {\r\n const { default: schema } = await import(\"./assets/Units.json\");\r\n\r\n const nameMap = new Map<string, IndexedUnit>();\r\n const labelMap = new Map<string, IndexedUnit[]>();\r\n const phenomenonMap = new Map<string, IndexedUnit[]>();\r\n const invertedUnits = new Map<string, InvertedEntry>();\r\n\r\n const s = schema as SerializedUnitSchema;\r\n const resolver = new UnitDefinitionResolver(s);\r\n const resolved = resolver.resolveAll();\r\n\r\n for (const [name, entry] of resolved) {\r\n const item = s.items[name] as SerializedUnit;\r\n const phenomenon = item.phenomenon;\r\n const unitSystem = item.unitSystem;\r\n\r\n const fullName = `${s.name}.${name}`;\r\n const props: UnitProps = {\r\n name: fullName,\r\n label: entry.label,\r\n phenomenon,\r\n isValid: true,\r\n system: unitSystem,\r\n };\r\n\r\n const indexed: IndexedUnit = { props, resolved: entry };\r\n\r\n nameMap.set(fullName, indexed);\r\n const lowerLabel = entry.label.toLowerCase();\r\n const byLabel = labelMap.get(lowerLabel) ?? [];\r\n byLabel.push(indexed);\r\n labelMap.set(lowerLabel, byLabel);\r\n\r\n const byPhen = phenomenonMap.get(phenomenon) ?? [];\r\n byPhen.push(indexed);\r\n phenomenonMap.set(phenomenon, byPhen);\r\n }\r\n\r\n // Handle InvertedUnit items — must run after nameMap is fully populated above because\r\n // invertedSource lookup requires the inverted unit's target to already be in nameMap.\r\n for (const [name, item] of Object.entries(s.items)) {\r\n if (item.schemaItemType !== \"InvertedUnit\") {\r\n continue;\r\n }\r\n const inv: SerializedInvertedUnit = item;\r\n const fullName = `${s.name}.${name}`;\r\n const invertsName = qualifyItemName(inv.invertsUnit, s.name);\r\n const unitSystem = inv.unitSystem;\r\n\r\n const invertedSource = nameMap.get(invertsName);\r\n const phenomenon = invertedSource?.props.phenomenon ?? \"\";\r\n\r\n const props: UnitProps = {\r\n name: fullName,\r\n label: inv.label ?? name,\r\n phenomenon,\r\n isValid: true,\r\n system: unitSystem,\r\n };\r\n\r\n invertedUnits.set(fullName, { props, invertsUnitName: invertsName });\r\n\r\n if (invertedSource) {\r\n const indexed: IndexedUnit = {\r\n props,\r\n resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },\r\n };\r\n nameMap.set(fullName, indexed);\r\n\r\n const lowerLabel = props.label.toLowerCase();\r\n const byLabel = labelMap.get(lowerLabel) ?? [];\r\n byLabel.push(indexed);\r\n labelMap.set(lowerLabel, byLabel);\r\n\r\n const byPhen = phenomenonMap.get(phenomenon) ?? [];\r\n byPhen.push(indexed);\r\n phenomenonMap.set(phenomenon, byPhen);\r\n }\r\n }\r\n\r\n return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };\r\n}\r\n\r\n/**\r\n * A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.\r\n *\r\n * The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method\r\n * call and cached at module scope — construction is essentially free, and multiple instances\r\n * share the same immutable lookup indexes.\r\n *\r\n * This is the zero-dependency default for backends, tools, and any frontend that doesn't need\r\n * iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.\r\n *\r\n * @see createUnitsProvider for layering schema-defined units on top of basic BIS units.\r\n * @beta\r\n */\r\nexport class BasicUnitsProvider implements UnitsProvider {\r\n\r\n // ── UnitsProvider implementation ─────────────────────────────────────\r\n\r\n /** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.\r\n * @param unitLabel - The display label to search for (case-insensitive).\r\n * @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `\"Units\"`.\r\n * @param phenomenon - Optional phenomenon filter (e.g. `\"Units.LENGTH\"`).\r\n * @param unitSystem - Optional unit system filter (e.g. `\"Units.METRIC\"`).\r\n * @returns The matching `UnitProps`, or a `BadUnit` if no match is found.\r\n */\r\n public async findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\r\n const state = await resolveState();\r\n if (schemaName && schemaName !== state.schemaName) {\r\n return new BadUnit();\r\n }\r\n const candidates = state.labelMap.get(unitLabel.toLowerCase());\r\n if (!candidates || candidates.length === 0) {\r\n return new BadUnit();\r\n }\r\n\r\n for (const c of candidates) {\r\n if (phenomenon && c.props.phenomenon !== phenomenon) {\r\n continue;\r\n }\r\n if (unitSystem && c.props.system !== unitSystem) {\r\n continue;\r\n }\r\n return c.props;\r\n }\r\n\r\n return new BadUnit();\r\n }\r\n\r\n /** Return all units belonging to the given phenomenon (unit family).\r\n * @param phenomenon - The phenomenon full name (e.g. `\"Units.LENGTH\"`).\r\n * @returns An array of matching `UnitProps`, or an empty array if none.\r\n */\r\n public async getUnitsByFamily(phenomenon: string): Promise<UnitProps[]> {\r\n const state = await resolveState();\r\n const entries = state.phenomenonMap.get(phenomenon);\r\n return entries ? entries.map((e) => e.props) : [];\r\n }\r\n\r\n /** Find a unit by its fully-qualified name (e.g. `\"Units.M\"`).\r\n * @param unitName - The qualified unit name.\r\n * @returns The matching `UnitProps`, or a `BadUnit` if not found.\r\n */\r\n public async findUnitByName(unitName: string): Promise<UnitProps> {\r\n const state = await resolveState();\r\n const entry = state.nameMap.get(unitName);\r\n return entry ? entry.props : new BadUnit();\r\n }\r\n\r\n /** Compute the conversion factors from `fromUnit` to `toUnit`.\r\n * Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.\r\n * @param fromUnit - The source unit.\r\n * @param toUnit - The target unit.\r\n * @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.\r\n */\r\n public async getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps> {\r\n const state = await resolveState();\r\n const from = state.nameMap.get(fromUnit.name);\r\n const to = state.nameMap.get(toUnit.name);\r\n\r\n if (!from || !to) {\r\n return { factor: 1.0, offset: 0.0, error: true };\r\n }\r\n\r\n const fromInverted = state.invertedUnits.get(fromUnit.name);\r\n const toInverted = state.invertedUnits.get(toUnit.name);\r\n\r\n const fromPhenomenon = fromInverted\r\n ? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon\r\n : from.props.phenomenon;\r\n const toPhenomenon = toInverted\r\n ? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon\r\n : to.props.phenomenon;\r\n if (fromPhenomenon !== toPhenomenon) {\r\n return { factor: 1.0, offset: 0.0, error: true };\r\n }\r\n\r\n if (fromInverted && toInverted) {\r\n const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);\r\n const innerTo = state.nameMap.get(toInverted.invertsUnitName);\r\n if (innerFrom && innerTo) {\r\n const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);\r\n return { factor: c.factor, offset: c.offset };\r\n }\r\n }\r\n\r\n if (fromInverted) {\r\n const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);\r\n if (innerFrom) {\r\n const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);\r\n return { factor: c.factor, offset: c.offset, inversion: UnitConversionInvert.InvertPreConversion };\r\n }\r\n }\r\n\r\n if (toInverted) {\r\n const innerTo = state.nameMap.get(toInverted.invertsUnitName);\r\n if (innerTo) {\r\n const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);\r\n return { factor: c.factor, offset: c.offset, inversion: UnitConversionInvert.InvertPostConversion };\r\n }\r\n }\r\n\r\n const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);\r\n return { factor: conv.factor, offset: conv.offset };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BasicUnitsProvider.js","sourceRoot":"","sources":["../../src/BasicUnitsProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,oDAGC;AAxDD;;;+FAG+F;AAC/F,6CAAkH;AAElH,oFAAoG;AACpG,0DAA6D;AAC7D,iCAAiC;AAqBjC,6FAA6F;AAC7F,0FAA0F;AAC1F,2FAA2F;AAC3F,4DAA4D;AAC5D,4FAA4F;AAC5F,wDAAwD;AACxD,IAAI,eAAmD,CAAC;AACxD,IAAI,eAAkC,CAAC;AAEvC,KAAK,UAAU,YAAY;IACzB,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC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AAC;QACH,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YAC9D,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAClF,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,iCAAoB,CAAC,oBAAoB,EAAE,CAAC;YACtG,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChF,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;CACF;AA9GD,gDA8GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { UnitConversionInvert, type UnitConversionProps, type UnitProps, type UnitsProvider } from \"./Interfaces\";\nimport type { SerializedInvertedUnit, SerializedUnit, SerializedUnitSchema } from \"./SerializedUnitSchema\";\nimport { type ResolvedUnit, UnitDefinitionResolver } from \"./UnitConversion/UnitDefinitionResolver\";\nimport { qualifyItemName } from \"./UnitConversion/nameUtils\";\nimport { BadUnit } from \"./Unit\";\n\ninterface IndexedUnit {\n readonly props: UnitProps;\n readonly resolved: ResolvedUnit;\n}\n\ninterface InvertedEntry {\n readonly props: UnitProps;\n readonly invertsUnitName: string;\n}\n\n/** Immutable lookup indexes resolved from the bundled Units.json. */\ninterface ResolvedState {\n readonly nameMap: Map<string, IndexedUnit>;\n readonly labelMap: Map<string, IndexedUnit[]>;\n readonly phenomenonMap: Map<string, IndexedUnit[]>;\n readonly invertedUnits: Map<string, InvertedEntry>;\n readonly schemaName: string;\n}\n\n// Module-level cache: the unit data is derived deterministically from the bundled Units.json\n// asset, so the resolved indexes are effectively an immutable constant. Caching at module\n// scope avoids redundant work when multiple BasicUnitsProvider instances are created (e.g.\n// in tests or when composed inside CompositeUnitsProvider).\n// The JSON is loaded lazily via dynamic import() on first use, keeping the module footprint\n// near-zero until a provider method is actually called.\nlet _resolvePromise: Promise<ResolvedState> | undefined;\nlet _permanentError: Error | undefined;\n\nasync function resolveState(): Promise<ResolvedState> {\n if (_permanentError !== undefined) {\n throw _permanentError;\n }\n if (!_resolvePromise) {\n _resolvePromise = _buildState().catch((err) => {\n _permanentError = err instanceof Error ? err : new Error(String(err));\n _resolvePromise = undefined;\n throw _permanentError;\n });\n }\n return _resolvePromise;\n}\n\n/** @internal — test use only. Resets the module-level lazy cache. */\nexport function _testResetUnitsCache(): void {\n _resolvePromise = undefined;\n _permanentError = undefined;\n}\n\nasync function _buildState(): Promise<ResolvedState> {\n const { default: schema } = await import(\"./assets/Units.json\");\n\n const nameMap = new Map<string, IndexedUnit>();\n const labelMap = new Map<string, IndexedUnit[]>();\n const phenomenonMap = new Map<string, IndexedUnit[]>();\n const invertedUnits = new Map<string, InvertedEntry>();\n\n const s = schema as SerializedUnitSchema;\n const resolver = new UnitDefinitionResolver(s);\n const resolved = resolver.resolveAll();\n\n for (const [name, entry] of resolved) {\n const item = s.items[name] as SerializedUnit;\n const phenomenon = item.phenomenon;\n const unitSystem = item.unitSystem;\n\n const fullName = `${s.name}.${name}`;\n const props: UnitProps = {\n name: fullName,\n label: entry.label,\n phenomenon,\n isValid: true,\n system: unitSystem,\n };\n\n const indexed: IndexedUnit = { props, resolved: entry };\n\n nameMap.set(fullName, indexed);\n const lowerLabel = entry.label.toLowerCase();\n const byLabel = labelMap.get(lowerLabel) ?? [];\n byLabel.push(indexed);\n labelMap.set(lowerLabel, byLabel);\n\n const byPhen = phenomenonMap.get(phenomenon) ?? [];\n byPhen.push(indexed);\n phenomenonMap.set(phenomenon, byPhen);\n }\n\n // Handle InvertedUnit items — must run after nameMap is fully populated above because\n // invertedSource lookup requires the inverted unit's target to already be in nameMap.\n for (const [name, item] of Object.entries(s.items)) {\n if (item.schemaItemType !== \"InvertedUnit\") {\n continue;\n }\n const inv: SerializedInvertedUnit = item;\n const fullName = `${s.name}.${name}`;\n const invertsName = qualifyItemName(inv.invertsUnit, s.name);\n const unitSystem = inv.unitSystem;\n\n const invertedSource = nameMap.get(invertsName);\n const phenomenon = invertedSource?.props.phenomenon ?? \"\";\n\n const props: UnitProps = {\n name: fullName,\n label: inv.label ?? name,\n phenomenon,\n isValid: true,\n system: unitSystem,\n };\n\n invertedUnits.set(fullName, { props, invertsUnitName: invertsName });\n\n if (invertedSource) {\n const indexed: IndexedUnit = {\n props,\n resolved: { ...invertedSource.resolved, name: fullName, label: props.label, unitSystem },\n };\n nameMap.set(fullName, indexed);\n\n const lowerLabel = props.label.toLowerCase();\n const byLabel = labelMap.get(lowerLabel) ?? [];\n byLabel.push(indexed);\n labelMap.set(lowerLabel, byLabel);\n\n const byPhen = phenomenonMap.get(phenomenon) ?? [];\n byPhen.push(indexed);\n phenomenonMap.set(phenomenon, byPhen);\n }\n }\n\n return { nameMap, labelMap, phenomenonMap, invertedUnits, schemaName: s.name };\n}\n\n/**\n * A `UnitsProvider` backed by the full BIS `Units.ecschema.json` bundled as a JSON asset.\n *\n * The ~90 KB bundled JSON is loaded lazily via dynamic `import()` on the first provider method\n * call and cached at module scope — construction is essentially free, and multiple instances\n * share the same immutable lookup indexes.\n *\n * This is the zero-dependency default for backends, tools, and any frontend that doesn't need\n * iModel overrides. Equivalent to calling `createUnitsProvider()` with no arguments.\n *\n * @see createUnitsProvider for layering schema-defined units on top of basic BIS units.\n * @beta\n */\nexport class BasicUnitsProvider implements UnitsProvider {\n\n // ── UnitsProvider implementation ─────────────────────────────────────\n\n /** Find a unit by its display label, optionally filtering by schema name, phenomenon, and unit system.\n * @param unitLabel - The display label to search for (case-insensitive).\n * @param schemaName - Optional schema name filter. Returns `BadUnit` if provided and not `\"Units\"`.\n * @param phenomenon - Optional phenomenon filter (e.g. `\"Units.LENGTH\"`).\n * @param unitSystem - Optional unit system filter (e.g. `\"Units.METRIC\"`).\n * @returns The matching `UnitProps`, or a `BadUnit` if no match is found.\n */\n public async findUnit(unitLabel: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n const state = await resolveState();\n if (schemaName && schemaName !== state.schemaName) {\n return new BadUnit();\n }\n const candidates = state.labelMap.get(unitLabel.toLowerCase());\n if (!candidates || candidates.length === 0) {\n return new BadUnit();\n }\n\n for (const c of candidates) {\n if (phenomenon && c.props.phenomenon !== phenomenon) {\n continue;\n }\n if (unitSystem && c.props.system !== unitSystem) {\n continue;\n }\n return c.props;\n }\n\n return new BadUnit();\n }\n\n /** Return all units belonging to the given phenomenon (unit family).\n * @param phenomenon - The phenomenon full name (e.g. `\"Units.LENGTH\"`).\n * @returns An array of matching `UnitProps`, or an empty array if none.\n */\n public async getUnitsByFamily(phenomenon: string): Promise<UnitProps[]> {\n const state = await resolveState();\n const entries = state.phenomenonMap.get(phenomenon);\n return entries ? entries.map((e) => e.props) : [];\n }\n\n /** Find a unit by its fully-qualified name (e.g. `\"Units.M\"`).\n * @param unitName - The qualified unit name.\n * @returns The matching `UnitProps`, or a `BadUnit` if not found.\n */\n public async findUnitByName(unitName: string): Promise<UnitProps> {\n const state = await resolveState();\n const entry = state.nameMap.get(unitName);\n return entry ? entry.props : new BadUnit();\n }\n\n /** Compute the conversion factors from `fromUnit` to `toUnit`.\n * Handles normal units, inverted units, and mixed (inverted ↔ non-inverted) conversions.\n * @param fromUnit - The source unit.\n * @param toUnit - The target unit.\n * @returns A `UnitConversionProps` with `factor`, `offset`, and optionally `inversion` and `error`.\n */\n public async getConversion(fromUnit: UnitProps, toUnit: UnitProps): Promise<UnitConversionProps> {\n const state = await resolveState();\n const from = state.nameMap.get(fromUnit.name);\n const to = state.nameMap.get(toUnit.name);\n\n if (!from || !to) {\n return { factor: 1.0, offset: 0.0, error: true };\n }\n\n const fromInverted = state.invertedUnits.get(fromUnit.name);\n const toInverted = state.invertedUnits.get(toUnit.name);\n\n const fromPhenomenon = fromInverted\n ? state.nameMap.get(fromInverted.invertsUnitName)?.props.phenomenon\n : from.props.phenomenon;\n const toPhenomenon = toInverted\n ? state.nameMap.get(toInverted.invertsUnitName)?.props.phenomenon\n : to.props.phenomenon;\n if (fromPhenomenon !== toPhenomenon) {\n return { factor: 1.0, offset: 0.0, error: true };\n }\n\n if (fromInverted && toInverted) {\n const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);\n const innerTo = state.nameMap.get(toInverted.invertsUnitName);\n if (innerFrom && innerTo) {\n const c = innerFrom.resolved.conversion.inverse().compose(innerTo.resolved.conversion);\n return { factor: c.factor, offset: c.offset };\n }\n }\n\n if (fromInverted) {\n const innerFrom = state.nameMap.get(fromInverted.invertsUnitName);\n if (innerFrom) {\n const c = innerFrom.resolved.conversion.inverse().compose(to.resolved.conversion);\n return { factor: c.factor, offset: c.offset, inversion: UnitConversionInvert.InvertPreConversion };\n }\n }\n\n if (toInverted) {\n const innerTo = state.nameMap.get(toInverted.invertsUnitName);\n if (innerTo) {\n const c = from.resolved.conversion.inverse().compose(innerTo.resolved.conversion);\n return { factor: c.factor, offset: c.offset, inversion: UnitConversionInvert.InvertPostConversion };\n }\n }\n\n const conv = from.resolved.conversion.inverse().compose(to.resolved.conversion);\n return { factor: conv.factor, offset: conv.offset };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CompositeUnitsProvider.js","sourceRoot":"","sources":["../../src/CompositeUnitsProvider.ts"],"names":[],"mappings":";;AAoDA,kDAYC;AAhED;;;+FAG+F;AAC/F,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xD,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,EAA8B;IACnD,IAAI,CAAC;QAAC,OAAO,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AACjD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { BasicUnitsProvider } from \"./BasicUnitsProvider\";\r\nimport type { UnitConversionProps, UnitProps, UnitsProvider } from \"./Interfaces\";\r\nimport { BadUnit } from \"./Unit\";\r\n\r\n/**\r\n * Options for [[createUnitsProvider]].\r\n * @beta\r\n */\r\nexport interface CreateUnitsProviderOptions {\r\n /**\r\n * A `UnitsProvider` consulted before the basic BIS units (e.g. a `SchemaUnitProvider`\r\n * for an open iModel's `SchemaContext`). When omitted, the returned provider behaves\r\n * exactly like `new BasicUnitsProvider()`.\r\n */\r\n primary?: UnitsProvider;\r\n\r\n /**\r\n * Controls which provider is consulted first and wins ties.\r\n * - `\"preferSchema\"` (default): `primary` is authoritative; bundled BIS units are fallback.\r\n * - `\"preferBundled\"`: bundled BIS units win; `primary` is consulted only for units not in\r\n * the bundled set. Use when the iModel's schema may be stale.\r\n *\r\n * Affects `findUnit`, `findUnitByName`, and `getConversion` (first-consulted wins or\r\n * falls through). `getUnitsByFamily` always merges both providers — the first-consulted\r\n * provider wins name collisions.\r\n *\r\n * Has no effect when `primary` is omitted — the returned provider is a plain `BasicUnitsProvider`.\r\n */\r\n bisUnitsPolicy?: \"preferSchema\" | \"preferBundled\";\r\n}\r\n\r\n/**\r\n * Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional\r\n * `primary` provider. Typical use: layer an iModel's schema units on top of the bundled\r\n * defaults from `@itwin/core-quantity`.\r\n *\r\n * Precedence rules:\r\n * - When `primary` is supplied and `bisUnitsPolicy` is `\"preferSchema\"` (the default): `primary` wins;\r\n * basic BIS units fill any gaps where `primary` returns an invalid unit or throws.\r\n * - When `bisUnitsPolicy` is `\"preferBundled\"`: basic BIS units win; `primary` is consulted only when the\r\n * basic provider can't answer.\r\n * - `getUnitsByFamily` always merges results from both providers, deduplicated by\r\n * `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.\r\n * - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`\r\n * (no wrapper), preserving `instanceof` checks and keeping the hot path fast.\r\n *\r\n * @beta\r\n */\r\nexport function createUnitsProvider(options: CreateUnitsProviderOptions = {}): UnitsProvider {\r\n const basic = new BasicUnitsProvider();\r\n const primary = options.primary;\r\n // NOTE: returns BasicUnitsProvider directly when no primary is provided.\r\n // QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.\r\n // If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.\r\n if (!primary) {\r\n return basic;\r\n }\r\n\r\n const providers = options.bisUnitsPolicy === \"preferBundled\" ? [basic, primary] : [primary, basic];\r\n return new CompositeUnitsProvider(providers);\r\n}\r\n\r\nclass CompositeUnitsProvider implements UnitsProvider {\r\n constructor(private readonly _providers: UnitsProvider[]) {}\r\n\r\n public async findUnit(label: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\r\n for (let i = 0; i < this._providers.length - 1; i++) {\r\n const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));\r\n if (hit?.isValid) {\r\n return hit;\r\n }\r\n }\r\n return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new BadUnit());\r\n }\r\n\r\n public async findUnitByName(name: string): Promise<UnitProps> {\r\n for (let i = 0; i < this._providers.length - 1; i++) {\r\n const hit = await tryFind(async () => this._providers[i].findUnitByName(name));\r\n if (hit?.isValid) {\r\n return hit;\r\n }\r\n }\r\n return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new BadUnit());\r\n }\r\n\r\n public async getUnitsByFamily(phenomenon: string): Promise<UnitProps[]> {\r\n const seen = new Set<string>();\r\n const out: UnitProps[] = [];\r\n // Query all providers in parallel; process results in declaration order to honour precedence.\r\n const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));\r\n for (const units of results) {\r\n for (const u of units) {\r\n if (!seen.has(u.name)) {\r\n seen.add(u.name);\r\n out.push(u);\r\n }\r\n }\r\n }\r\n return out;\r\n }\r\n\r\n public async getConversion(from: UnitProps, to: UnitProps): Promise<UnitConversionProps> {\r\n for (let i = 0; i < this._providers.length - 1; i++) {\r\n try {\r\n const result = await this._providers[i].getConversion(from, to);\r\n if (!result.error) {\r\n return result;\r\n }\r\n } catch { /* fall through to next provider */ }\r\n }\r\n try {\r\n return await this._providers[this._providers.length - 1].getConversion(from, to);\r\n } catch {\r\n return { factor: 1.0, offset: 0.0, error: true };\r\n }\r\n }\r\n}\r\n\r\nasync function tryFind(fn: () => Promise<UnitProps>): Promise<UnitProps | undefined> {\r\n try { return await fn(); } catch { return undefined; }\r\n}\r\n\r\nasync function tryList(fn: () => Promise<UnitProps[]>): Promise<UnitProps[]> {\r\n try { return await fn(); } catch { return []; }\r\n}\r\n"]}
1
+ {"version":3,"file":"CompositeUnitsProvider.js","sourceRoot":"","sources":["../../src/CompositeUnitsProvider.ts"],"names":[],"mappings":";;AAoDA,kDAYC;AAhED;;;+FAG+F;AAC/F,6DAA0D;AAE1D,iCAAiC;AA6BjC;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,mBAAmB,CAAC,UAAsC,EAAE;IAC1E,MAAM,KAAK,GAAG,IAAI,uCAAkB,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,yEAAyE;IACzE,uGAAuG;IACvG,sFAAsF;IACtF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,C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ACb,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,IAAe,EAAE,EAAa;QACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAChE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,MAAM,CAAC;gBAChB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC,CAAC,mCAAmC,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnF,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AAED,KAAK,UAAU,OAAO,CAAC,EAA4B;IACjD,IAAI,CAAC;QAAC,OAAO,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;AACxD,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,EAA8B;IACnD,IAAI,CAAC;QAAC,OAAO,MAAM,EAAE,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AACjD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BasicUnitsProvider } from \"./BasicUnitsProvider\";\nimport type { UnitConversionProps, UnitProps, UnitsProvider } from \"./Interfaces\";\nimport { BadUnit } from \"./Unit\";\n\n/**\n * Options for [[createUnitsProvider]].\n * @beta\n */\nexport interface CreateUnitsProviderOptions {\n /**\n * A `UnitsProvider` consulted before the basic BIS units (e.g. a `SchemaUnitProvider`\n * for an open iModel's `SchemaContext`). When omitted, the returned provider behaves\n * exactly like `new BasicUnitsProvider()`.\n */\n primary?: UnitsProvider;\n\n /**\n * Controls which provider is consulted first and wins ties.\n * - `\"preferSchema\"` (default): `primary` is authoritative; bundled BIS units are fallback.\n * - `\"preferBundled\"`: bundled BIS units win; `primary` is consulted only for units not in\n * the bundled set. Use when the iModel's schema may be stale.\n *\n * Affects `findUnit`, `findUnitByName`, and `getConversion` (first-consulted wins or\n * falls through). `getUnitsByFamily` always merges both providers — the first-consulted\n * provider wins name collisions.\n *\n * Has no effect when `primary` is omitted — the returned provider is a plain `BasicUnitsProvider`.\n */\n bisUnitsPolicy?: \"preferSchema\" | \"preferBundled\";\n}\n\n/**\n * Returns a `UnitsProvider` that layers the basic BIS units under (or over) an optional\n * `primary` provider. Typical use: layer an iModel's schema units on top of the bundled\n * defaults from `@itwin/core-quantity`.\n *\n * Precedence rules:\n * - When `primary` is supplied and `bisUnitsPolicy` is `\"preferSchema\"` (the default): `primary` wins;\n * basic BIS units fill any gaps where `primary` returns an invalid unit or throws.\n * - When `bisUnitsPolicy` is `\"preferBundled\"`: basic BIS units win; `primary` is consulted only when the\n * basic provider can't answer.\n * - `getUnitsByFamily` always merges results from both providers, deduplicated by\n * `UnitProps.name` (fully-qualified). The first-consulted provider wins ties.\n * - When no `primary` is supplied, the returned provider is exactly `new BasicUnitsProvider()`\n * (no wrapper), preserving `instanceof` checks and keeping the hot path fast.\n *\n * @beta\n */\nexport function createUnitsProvider(options: CreateUnitsProviderOptions = {}): UnitsProvider {\n const basic = new BasicUnitsProvider();\n const primary = options.primary;\n // NOTE: returns BasicUnitsProvider directly when no primary is provided.\n // QuantityFormatter.resetToUseInternalUnitsProvider uses instanceof BasicUnitsProvider to detect this.\n // If this fast-path is ever wrapped (e.g. for telemetry), that guard must be updated.\n if (!primary) {\n return basic;\n }\n\n const providers = options.bisUnitsPolicy === \"preferBundled\" ? [basic, primary] : [primary, basic];\n return new CompositeUnitsProvider(providers);\n}\n\nclass CompositeUnitsProvider implements UnitsProvider {\n constructor(private readonly _providers: UnitsProvider[]) {}\n\n public async findUnit(label: string, schemaName?: string, phenomenon?: string, unitSystem?: string): Promise<UnitProps> {\n for (let i = 0; i < this._providers.length - 1; i++) {\n const hit = await tryFind(async () => this._providers[i].findUnit(label, schemaName, phenomenon, unitSystem));\n if (hit?.isValid) {\n return hit;\n }\n }\n return tryFind(async () => this._providers[this._providers.length - 1].findUnit(label, schemaName, phenomenon, unitSystem)).then((hit) => hit ?? new BadUnit());\n }\n\n public async findUnitByName(name: string): Promise<UnitProps> {\n for (let i = 0; i < this._providers.length - 1; i++) {\n const hit = await tryFind(async () => this._providers[i].findUnitByName(name));\n if (hit?.isValid) {\n return hit;\n }\n }\n return tryFind(async () => this._providers[this._providers.length - 1].findUnitByName(name)).then((hit) => hit ?? new BadUnit());\n }\n\n public async getUnitsByFamily(phenomenon: string): Promise<UnitProps[]> {\n const seen = new Set<string>();\n const out: UnitProps[] = [];\n // Query all providers in parallel; process results in declaration order to honour precedence.\n const results = await Promise.all(this._providers.map(async (p) => tryList(async () => p.getUnitsByFamily(phenomenon))));\n for (const units of results) {\n for (const u of units) {\n if (!seen.has(u.name)) {\n seen.add(u.name);\n out.push(u);\n }\n }\n }\n return out;\n }\n\n public async getConversion(from: UnitProps, to: UnitProps): Promise<UnitConversionProps> {\n for (let i = 0; i < this._providers.length - 1; i++) {\n try {\n const result = await this._providers[i].getConversion(from, to);\n if (!result.error) {\n return result;\n }\n } catch { /* fall through to next provider */ }\n }\n try {\n return await this._providers[this._providers.length - 1].getConversion(from, to);\n } catch {\n return { factor: 1.0, offset: 0.0, error: true };\n }\n }\n}\n\nasync function tryFind(fn: () => Promise<UnitProps>): Promise<UnitProps | undefined> {\n try { return await fn(); } catch { return undefined; }\n}\n\nasync function tryList(fn: () => Promise<UnitProps[]>): Promise<UnitProps[]> {\n try { return await fn(); } catch { return []; }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yDAAyD;AAEzD;;GAEG;AACH,MAAa,iBAAiB;IACrB,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAChC,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAChC,MAAM,CAAU,WAAW,GAAG,EAAE,CAAC;IACjC,MAAM,CAAU,SAAS,GAAG,EAAE,CAAC;IAC/B,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAChC,MAAM,CAAU,WAAW,GAAG,EAAE,CAAC;IACjC,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAChC,MAAM,CAAU,mBAAmB,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAU,mBAAmB,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAU,gBAAgB,GAAG,GAAG,CAAC;IACvC,MAAM,CAAU,aAAa,GAAG,GAAG,CAAC;IACpC,MAAM,CAAU,kBAAkB,GAAG,GAAG,CAAC;IACzC,MAAM,CAAU,eAAe,GAAG,EAAE,CAAC;IACrC,MAAM,CAAU,eAAe,GAAG,EAAE,CAAC;IACrC,MAAM,CAAU,YAAY,GAAG,EAAE,CAAC;IAClC,MAAM,CAAU,YAAY,GAAG,GAAG,CAAC;IAClC,MAAM,CAAC,yBAAyB,GAAG,EAAE,CAAC;IACtC,MAAM,CAAC,0BAA0B,GAAG,EAAE,CAAC;IAE/C,2DAA2D;IACpD,MAAM,KAAK,8BAA8B;QAC9C,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,MAAM,GAAG,CAAC;YACxD,OAAO,iBAAiB,CAAC,yBAAyB,CAAC;QAErD,iBAAiB,CAAC,yBAAyB,GAAG,GAAG,CAAC;QAClD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAC/B,iBAAiB,CAAC,yBAAyB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3D,OAAO,iBAAiB,CAAC,yBAAyB,CAAC;IACrD,CAAC;IAED,4DAA4D;IACrD,MAAM,KAAK,+BAA+B;QAC/C,IAAI,iBAAiB,CAAC,0BAA0B,CAAC,MAAM,GAAG,CAAC;YACzD,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;QAEtD,iBAAiB,CAAC,0BAA0B,GAAG,GAAG,CAAC;QACnD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;YACpD,iBAAiB,CAAC,0BAA0B,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE5D,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;IACtD,CAAC;;AA5CH,8CA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/** Constants used internally for both formatting and parsing.\r\n * @internal\r\n */\r\nexport class QuantityConstants {\r\n public static readonly CHAR_COMMA = 44;\r\n public static readonly CHAR_SPACE = 32;\r\n public static readonly CHAR_NUMBER = 35;\r\n public static readonly CHAR_PLUS = 43;\r\n public static readonly CHAR_MINUS = 45;\r\n public static readonly CHAR_PERIOD = 46;\r\n public static readonly CHAR_SLASH = 47;\r\n public static readonly CHAR_DIVISION_SLASH = 8725;\r\n public static readonly CHAR_FRACTION_SLASH = 8260;\r\n public static readonly CHAR_ONE_QUARTER = 188;\r\n public static readonly CHAR_ONE_HALF = 189;\r\n public static readonly CHAR_THREE_QUARTER = 190;\r\n public static readonly CHAR_DIGIT_ZERO = 48;\r\n public static readonly CHAR_DIGIT_NINE = 57;\r\n public static readonly CHAR_UPPER_E = 69;\r\n public static readonly CHAR_LOWER_E = 101;\r\n private static _LOCALE_DECIMAL_SEPARATOR = \"\";\r\n private static _LOCALE_THOUSAND_SEPARATOR = \"\";\r\n\r\n /** Return the decimal separator for the current locale. */\r\n public static get LocaleSpecificDecimalSeparator(): string {\r\n if (QuantityConstants._LOCALE_DECIMAL_SEPARATOR.length > 0)\r\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\r\n\r\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = \".\";\r\n const matches = (12345.6789).toLocaleString().match(/345(.*)67/);\r\n if (matches && matches.length > 1)\r\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = matches[1];\r\n\r\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\r\n }\r\n\r\n /** Return the thousand separator for the current locale. */\r\n public static get LocaleSpecificThousandSeparator(): string {\r\n if (QuantityConstants._LOCALE_THOUSAND_SEPARATOR.length > 0)\r\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\r\n\r\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = \",\";\r\n const matches = (12345.6789).toLocaleString().match(/12(.*)345/);\r\n if (matches && matches.length > 1 && matches[1] !== \"\")\r\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];\r\n\r\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/Constants.ts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AAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3D,OAAO,iBAAiB,CAAC,yBAAyB,CAAC;IACrD,CAAC;IAED,4DAA4D;IACrD,MAAM,KAAK,+BAA+B;QAC/C,IAAI,iBAAiB,CAAC,0BAA0B,CAAC,MAAM,GAAG,CAAC;YACzD,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;QAEtD,iBAAiB,CAAC,0BAA0B,GAAG,GAAG,CAAC;QACnD,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjE,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;YACpD,iBAAiB,CAAC,0BAA0B,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAE5D,OAAO,iBAAiB,CAAC,0BAA0B,CAAC;IACtD,CAAC;;AA5CH,8CA6CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/* eslint-disable @typescript-eslint/naming-convention */\n\n/** Constants used internally for both formatting and parsing.\n * @internal\n */\nexport class QuantityConstants {\n public static readonly CHAR_COMMA = 44;\n public static readonly CHAR_SPACE = 32;\n public static readonly CHAR_NUMBER = 35;\n public static readonly CHAR_PLUS = 43;\n public static readonly CHAR_MINUS = 45;\n public static readonly CHAR_PERIOD = 46;\n public static readonly CHAR_SLASH = 47;\n public static readonly CHAR_DIVISION_SLASH = 8725;\n public static readonly CHAR_FRACTION_SLASH = 8260;\n public static readonly CHAR_ONE_QUARTER = 188;\n public static readonly CHAR_ONE_HALF = 189;\n public static readonly CHAR_THREE_QUARTER = 190;\n public static readonly CHAR_DIGIT_ZERO = 48;\n public static readonly CHAR_DIGIT_NINE = 57;\n public static readonly CHAR_UPPER_E = 69;\n public static readonly CHAR_LOWER_E = 101;\n private static _LOCALE_DECIMAL_SEPARATOR = \"\";\n private static _LOCALE_THOUSAND_SEPARATOR = \"\";\n\n /** Return the decimal separator for the current locale. */\n public static get LocaleSpecificDecimalSeparator(): string {\n if (QuantityConstants._LOCALE_DECIMAL_SEPARATOR.length > 0)\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\n\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = \".\";\n const matches = (12345.6789).toLocaleString().match(/345(.*)67/);\n if (matches && matches.length > 1)\n QuantityConstants._LOCALE_DECIMAL_SEPARATOR = matches[1];\n\n return QuantityConstants._LOCALE_DECIMAL_SEPARATOR;\n }\n\n /** Return the thousand separator for the current locale. */\n public static get LocaleSpecificThousandSeparator(): string {\n if (QuantityConstants._LOCALE_THOUSAND_SEPARATOR.length > 0)\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\n\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = \",\";\n const matches = (12345.6789).toLocaleString().match(/12(.*)345/);\n if (matches && matches.length > 1 && matches[1] !== \"\")\n QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];\n\n return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAE3D;;;GAGG;AACH,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,qEAAqC,CAAA;IACrC,2FAAgD,CAAA;IAChD,qGAAqD,CAAA;IACrD,mGAAoD,CAAA;IACpD,2GAAwD,CAAA;IACxD,qEAAqC,CAAA;IACrC,uHAA8D,CAAA;IAC9D,6EAAyC,CAAA;IACzC,6FAAiD,CAAA;IACjD,yEAAwC,CAAA;AAC1C,CAAC,EAbW,cAAc,8BAAd,cAAc,QAazB;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,2BAAY;IACD;IAA5C,YAA4C,WAAmB,EAAE,OAAgB;QAC/E,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QADc,gBAAW,GAAX,WAAW,CAAQ;QAE7D,IAAA,qBAAM,EAAC,WAAW,KAAK,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AALD,sCAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { assert, BentleyError } from \"@itwin/core-bentley\";\r\n\r\n/**\r\n * Status codes used during Quantity parsing and formatting processing.\r\n * @beta\r\n */\r\nexport enum QuantityStatus {\r\n QUANTITY_ERROR_BASE = 0x88DF,\r\n Success = 0,\r\n InvalidJson = QUANTITY_ERROR_BASE + 1,\r\n InvalidCompositeFormat = QUANTITY_ERROR_BASE + 2,\r\n UnableToGenerateParseTokens = QUANTITY_ERROR_BASE + 3,\r\n NoValueOrUnitFoundInString = QUANTITY_ERROR_BASE + 4,\r\n UnitLabelSuppliedButNotMatched = QUANTITY_ERROR_BASE + 5,\r\n UnknownUnit = QUANTITY_ERROR_BASE + 6,\r\n UnableToConvertParseTokensToQuantity = QUANTITY_ERROR_BASE + 7,\r\n UnsupportedUnit = QUANTITY_ERROR_BASE + 8,\r\n MissingRequiredProperty = QUANTITY_ERROR_BASE + 9,\r\n InvertingZero = QUANTITY_ERROR_BASE + 10,\r\n}\r\n\r\n/** The error type thrown by this module. See [[QuantityStatus]] for `errorNumber` values.\r\n * @beta\r\n */\r\nexport class QuantityError extends BentleyError {\r\n public constructor(public override readonly errorNumber: number, message?: string) {\r\n super(errorNumber, message);\r\n assert(errorNumber !== QuantityStatus.Success, message);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../src/Exception.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAE3D;;;GAGG;AACH,IAAY,cAaX;AAbD,WAAY,cAAc;IACxB,qFAA4B,CAAA;IAC5B,yDAAW,CAAA;IACX,qEAAqC,CAAA;IACrC,2FAAgD,CAAA;IAChD,qGAAqD,CAAA;IACrD,mGAAoD,CAAA;IACpD,2GAAwD,CAAA;IACxD,qEAAqC,CAAA;IACrC,uHAA8D,CAAA;IAC9D,6EAAyC,CAAA;IACzC,6FAAiD,CAAA;IACjD,yEAAwC,CAAA;AAC1C,CAAC,EAbW,cAAc,8BAAd,cAAc,QAazB;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,2BAAY;IACD;IAA5C,YAA4C,WAAmB,EAAE,OAAgB;QAC/E,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QADc,gBAAW,GAAX,WAAW,CAAQ;QAE7D,IAAA,qBAAM,EAAC,WAAW,KAAK,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;CACF;AALD,sCAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { assert, BentleyError } from \"@itwin/core-bentley\";\n\n/**\n * Status codes used during Quantity parsing and formatting processing.\n * @beta\n */\nexport enum QuantityStatus {\n QUANTITY_ERROR_BASE = 0x88DF,\n Success = 0,\n InvalidJson = QUANTITY_ERROR_BASE + 1,\n InvalidCompositeFormat = QUANTITY_ERROR_BASE + 2,\n UnableToGenerateParseTokens = QUANTITY_ERROR_BASE + 3,\n NoValueOrUnitFoundInString = QUANTITY_ERROR_BASE + 4,\n UnitLabelSuppliedButNotMatched = QUANTITY_ERROR_BASE + 5,\n UnknownUnit = QUANTITY_ERROR_BASE + 6,\n UnableToConvertParseTokensToQuantity = QUANTITY_ERROR_BASE + 7,\n UnsupportedUnit = QUANTITY_ERROR_BASE + 8,\n MissingRequiredProperty = QUANTITY_ERROR_BASE + 9,\n InvertingZero = QUANTITY_ERROR_BASE + 10,\n}\n\n/** The error type thrown by this module. See [[QuantityStatus]] for `errorNumber` values.\n * @beta\n */\nexport class QuantityError extends BentleyError {\n public constructor(public override readonly errorNumber: number, message?: string) {\n super(errorNumber, message);\n assert(errorNumber !== QuantityStatus.Success, message);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatSpecHandle.js","sourceRoot":"","sources":["../../src/FormatSpecHandle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAmB/F;;;;;;;;GAQG;AACH,MAAa,gBAAgB;IACnB,SAAS,GAAG,KAAK,CAAC;IACT,SAAS,CAAyB;IAClC,QAAQ,CAAS;IACjB,gBAAgB,CAAS;IACzB,OAAO,CAA4B;IAEpD,gBAAgB;IAChB,YAAY,IAA0B;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,4CAA4C;IAC5C,IAAW,OAAO,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtD,oDAAoD;IACpD,IAAW,eAAe,KAAa,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEtE,sFAAsF;IACtF,IAAW,MAAM,KAAgC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvE,iEAAiE;IACjE,IAAW,aAAa,KAAgC,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IAEjG,8DAA8D;IAC9D,IAAW,UAAU,KAA6B,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAExF;;;;OAIG;IACI,MAAM,CAAC,KAAa;QACzB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,aAAa;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEO,SAAS;QACf,IAAI,IAAI,CAAC,SAAS;YAChB,OAAO,SAAS,CAAC;QAEnB,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;YAC1C,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,mBAAmB,EAAE,IAAI,CAAC,gBAAgB;YAC1C,MAAM,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;CACF;AA5DD,4CA4DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport type { FormatterSpec } from \"./Formatter/FormatterSpec\";\r\nimport type { FormattingSpecArgs, FormattingSpecEntry, FormattingSpecProvider } from \"./Formatter/Interfaces\";\r\nimport type { ParserSpec } from \"./ParserSpec\";\r\nimport type { UnitSystemKey } from \"./Interfaces\";\r\n\r\n/** Arguments for constructing a [[FormatSpecHandle]].\r\n * @internal\r\n */\r\nexport interface FormatSpecHandleArgs extends FormattingSpecArgs {\r\n /** The provider that supplies current formatting spec lookups. */\r\n provider: FormattingSpecProvider;\r\n}\r\n\r\n/** A handle to formatting and parsing specs for a specific KoQ and persistence unit.\r\n * Reads the current specs from the provider on access. Use [[QuantityFormatter.getFormatSpecHandle]]\r\n * to create instances.\r\n *\r\n * When formatting is not yet ready, [[format]] returns a `value.toString()` fallback.\r\n * Dispose the handle when it is no longer needed to invalidate it.\r\n *\r\n * @beta\r\n */\r\nexport class FormatSpecHandle implements Disposable {\r\n private _disposed = false;\r\n private readonly _provider: FormattingSpecProvider;\r\n private readonly _koqName: string;\r\n private readonly _persistenceUnit: string;\r\n private readonly _system: UnitSystemKey | undefined;\r\n\r\n /** @internal */\r\n constructor(args: FormatSpecHandleArgs) {\r\n this._provider = args.provider;\r\n this._koqName = args.name;\r\n this._persistenceUnit = args.persistenceUnitName;\r\n this._system = args.system;\r\n }\r\n\r\n /** The KoQ name this handle is keyed to. */\r\n public get koqName(): string { return this._koqName; }\r\n\r\n /** The persistence unit this handle is keyed to. */\r\n public get persistenceUnit(): string { return this._persistenceUnit; }\r\n\r\n /** The unit system this handle is pinned to, or `undefined` for the active system. */\r\n public get system(): UnitSystemKey | undefined { return this._system; }\r\n\r\n /** The current FormatterSpec, or undefined if not yet loaded. */\r\n public get formatterSpec(): FormatterSpec | undefined { return this._getEntry()?.formatterSpec; }\r\n\r\n /** The current ParserSpec, or undefined if not yet loaded. */\r\n public get parserSpec(): ParserSpec | undefined { return this._getEntry()?.parserSpec; }\r\n\r\n /** Format a quantity value using the current spec.\r\n * If the formatter is not yet ready, returns `value.toString()` as a fallback.\r\n * @param value - The numeric value to format.\r\n * @returns The formatted string.\r\n */\r\n public format(value: number): string {\r\n const formatterSpec = this.formatterSpec;\r\n if (!formatterSpec)\r\n return value.toString();\r\n return this._provider.formatQuantity(value, formatterSpec);\r\n }\r\n\r\n /** Invalidate this handle.\r\n * Idempotent and safe to call multiple times.\r\n * No additional teardown is required because the handle owns no external resources.\r\n */\r\n public [Symbol.dispose](): void {\r\n this._disposed = true;\r\n }\r\n\r\n private _getEntry(): FormattingSpecEntry | undefined {\r\n if (this._disposed)\r\n return undefined;\r\n\r\n return this._provider.getSpecsByNameAndUnit({\r\n name: this._koqName,\r\n persistenceUnitName: this._persistenceUnit,\r\n system: this._system,\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FormatSpecHandle.js","sourceRoot":"","sources":["../../src/FormatSpecHandle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAmB/F;;;;;;;;GAQG;AACH,MAAa,gBAAgB;IACnB,SAAS,GAAG,KAAK,CAAC;IACT,SAAS,CAAyB;IAClC,QAAQ,CAAS;IACjB,gBAAgB,CAAS;IACzB,OAAO,CAA4B;IAEpD,gBAAgB;IAChB,YAAY,IAA0B;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,4CAA4C;IAC5C,IAAW,OAAO,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtD,oDAAoD;IACpD,IAAW,eAAe,KAAa,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEtE,sFAAsF;IACtF,IAAW,MAAM,KAAgC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvE,iEAAiE;IACjE,IAAW,aAAa,KAAgC,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IAEjG,8DAA8D;IAC9D,IAAW,UAAU,KAA6B,OAAO,IAAI,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;IAExF;;;;OAIG;IACI,MAAM,CAAC,KAAa;QACzB,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,aAAa;YAChB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEO,SAAS;QACf,IAAI,IAAI,CAAC,SAAS;YAChB,OAAO,SAAS,CAAC;QAEnB,OAAO,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC;YAC1C,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,mBAAmB,EAAE,IAAI,CAAC,gBAAgB;YAC1C,MAAM,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;CACF;AA5DD,4CA4DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport type { FormatterSpec } from \"./Formatter/FormatterSpec\";\nimport type { FormattingSpecArgs, FormattingSpecEntry, FormattingSpecProvider } from \"./Formatter/Interfaces\";\nimport type { ParserSpec } from \"./ParserSpec\";\nimport type { UnitSystemKey } from \"./Interfaces\";\n\n/** Arguments for constructing a [[FormatSpecHandle]].\n * @internal\n */\nexport interface FormatSpecHandleArgs extends FormattingSpecArgs {\n /** The provider that supplies current formatting spec lookups. */\n provider: FormattingSpecProvider;\n}\n\n/** A handle to formatting and parsing specs for a specific KoQ and persistence unit.\n * Reads the current specs from the provider on access. Use [[QuantityFormatter.getFormatSpecHandle]]\n * to create instances.\n *\n * When formatting is not yet ready, [[format]] returns a `value.toString()` fallback.\n * Dispose the handle when it is no longer needed to invalidate it.\n *\n * @beta\n */\nexport class FormatSpecHandle implements Disposable {\n private _disposed = false;\n private readonly _provider: FormattingSpecProvider;\n private readonly _koqName: string;\n private readonly _persistenceUnit: string;\n private readonly _system: UnitSystemKey | undefined;\n\n /** @internal */\n constructor(args: FormatSpecHandleArgs) {\n this._provider = args.provider;\n this._koqName = args.name;\n this._persistenceUnit = args.persistenceUnitName;\n this._system = args.system;\n }\n\n /** The KoQ name this handle is keyed to. */\n public get koqName(): string { return this._koqName; }\n\n /** The persistence unit this handle is keyed to. */\n public get persistenceUnit(): string { return this._persistenceUnit; }\n\n /** The unit system this handle is pinned to, or `undefined` for the active system. */\n public get system(): UnitSystemKey | undefined { return this._system; }\n\n /** The current FormatterSpec, or undefined if not yet loaded. */\n public get formatterSpec(): FormatterSpec | undefined { return this._getEntry()?.formatterSpec; }\n\n /** The current ParserSpec, or undefined if not yet loaded. */\n public get parserSpec(): ParserSpec | undefined { return this._getEntry()?.parserSpec; }\n\n /** Format a quantity value using the current spec.\n * If the formatter is not yet ready, returns `value.toString()` as a fallback.\n * @param value - The numeric value to format.\n * @returns The formatted string.\n */\n public format(value: number): string {\n const formatterSpec = this.formatterSpec;\n if (!formatterSpec)\n return value.toString();\n return this._provider.formatQuantity(value, formatterSpec);\n }\n\n /** Invalidate this handle.\n * Idempotent and safe to call multiple times.\n * No additional teardown is required because the handle owns no external resources.\n */\n public [Symbol.dispose](): void {\n this._disposed = true;\n }\n\n private _getEntry(): FormattingSpecEntry | undefined {\n if (this._disposed)\n return undefined;\n\n return this._provider.getSpecsByNameAndUnit({\n name: this._koqName,\n persistenceUnitName: this._persistenceUnit,\n system: this._system,\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,4CAAiD;AACjD,4CAA6D;AAE7D,+CAMuB;AAGvB,sFAAsF;AACtF,6JAA6J;AAE7J;;GAEG;AACH,MAAa,UAAU;IACb,KAAK,GAAG,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,IAAI,yBAAa,CACrB,0BAAc,CAAC,WAAW,EAC1B,cAAc,UAAU,oGAAoG,WAAW,UAAU,WAAW,IAAI,CACjK,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,eAAe,EAAE,cAAc,CAAC;IACpC,MAAM,IAAI,GAAG,IAAA,6BAAe,EAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,IAAI,KAAK,wBAAU,CAAC,OAAO,IAAI,IAAI,KAAK,wBAAU,CAAC,OAAO,EAAE,CAAC;QAC/D,eAAe,GAAG,MAAM,yBAAyB,CAAC,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;QACzG,cAAc,GAAG,MAAM,yBAAyB,CAAC,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;QAEvG,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,uFAAuF,CAAC,CAAC;QACvK,CAAC;QAED,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1D,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wFAAwF,CAAC,CAAC;QACxK,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,eAAe;QACf,cAAc;QACd,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACjB,GAAG,OAAO,CAAC,SAAS;YACpB,KAAK;SACN,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport {\r\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision, getTraitString,\r\n parseFormatTrait, parseFormatType, parsePrecision, parseRatioFormatType, parseRatioType, parseScientificType, parseShowSignOption,\r\n RatioFormatType, RatioType,\r\n ScientificType,\r\n ShowSignOption,\r\n} from \"./FormatEnums\";\r\nimport { CloneOptions, FormatProps, ResolvedFormatProps, ResolvedFormatUnitSpec } from \"./Interfaces\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\r\n * @beta\r\n */\r\nexport class BaseFormat {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\r\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\r\n protected _ratioFormatType?: RatioFormatType; // defaults to Decimal if not specified\r\n protected _ratioSeparator?: string; // default is \":\"; separator character used in ratio formatting\r\n protected _azimuthBase?: number; // value always clockwise from north\r\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\r\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\r\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\r\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\r\n\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\r\n\r\n public get type(): FormatType { return this._type; }\r\n public set type(formatType: FormatType) { this._type = formatType; }\r\n\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\r\n\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\r\n\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\r\n\r\n public get ratioType(): RatioType | undefined { return this._ratioType; }\r\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\r\n\r\n public get ratioFormatType(): RatioFormatType | undefined { return this._ratioFormatType; }\r\n public set ratioFormatType(ratioFormatType: RatioFormatType | undefined) { this._ratioFormatType = ratioFormatType; }\r\n\r\n public get ratioSeparator(): string | undefined { return this._ratioSeparator; }\r\n public set ratioSeparator(ratioSeparator: string | undefined) { this._ratioSeparator = ratioSeparator; }\r\n\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\r\n\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\r\n\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\r\n\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\r\n\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\r\n\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\r\n\r\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\r\n * for the base offset calculation. The default value is 1.\r\n */\r\n public get stationBaseFactor(): number | undefined {\r\n return this._stationBaseFactor;\r\n }\r\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\r\n this._stationBaseFactor = stationBaseFactor;\r\n }\r\n\r\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\r\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\r\n\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\r\n\r\n public get spacer(): string | undefined { return this._spacer; }\r\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\r\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\r\n\r\n public get includeZero(): boolean | undefined { return this._includeZero; }\r\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\r\n\r\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\r\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\r\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\r\n\r\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\r\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\r\n\r\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\r\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\r\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\r\n\r\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\r\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\r\n this._formatTraits = this.formatTraits | formatTrait;\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\r\n this._type = parseFormatType(formatProps.type, this.name);\r\n\r\n if (formatProps.precision !== undefined) {\r\n if (!Number.isInteger(formatProps.precision))\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n\r\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\r\n }\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === formatProps.scientificType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\r\n\r\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\r\n }\r\n\r\n if (this.type === FormatType.Ratio){\r\n if (undefined === formatProps.ratioType)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\r\n\r\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\r\n\r\n if (undefined !== formatProps.ratioSeparator) { // optional; default is 0.0\r\n if (typeof (formatProps.ratioSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.ratioSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be a one character string.`);\r\n this._ratioSeparator = formatProps.ratioSeparator;\r\n } else {\r\n this._ratioSeparator = \":\"; // Apply default\r\n }\r\n\r\n if (undefined !== formatProps.ratioFormatType) {\r\n this._ratioFormatType = parseRatioFormatType(formatProps.ratioFormatType, this.name);\r\n } else {\r\n this._ratioFormatType = RatioFormatType.Decimal; // Apply default\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.roundFactor) {\r\n if (typeof (formatProps.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = formatProps.roundFactor;\r\n }\r\n\r\n if (undefined !== formatProps.minWidth) {\r\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = formatProps.minWidth;\r\n }\r\n if (FormatType.Station === this.type) {\r\n if (undefined === formatProps.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\r\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = formatProps.stationOffsetSize;\r\n\r\n if (undefined !== formatProps.stationBaseFactor) {\r\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\r\n this._stationBaseFactor = formatProps.stationBaseFactor;\r\n }\r\n }\r\n\r\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\r\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) {\r\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.parseFormatTraits(formatProps.formatTraits);\r\n }\r\n\r\n if (undefined !== formatProps.decimalSeparator) {\r\n if (typeof (formatProps.decimalSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.decimalSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\r\n this._decimalSeparator = formatProps.decimalSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.thousandSeparator) {\r\n if (typeof (formatProps.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.thousandSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\r\n this._thousandSeparator = formatProps.thousandSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\r\n if (typeof (formatProps.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\r\n this._uomSeparator = formatProps.uomSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (formatProps.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.stationSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\r\n this._stationSeparator = formatProps.stationSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\r\n if (typeof (formatProps.azimuthBase) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\r\n this._azimuthBase = formatProps.azimuthBase;\r\n }\r\n\r\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false, azimuth values are clockwise from base\r\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\r\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\r\n }\r\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\r\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\r\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\r\n }\r\n }\r\n}\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format extends BaseFormat {\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n super(name);\r\n }\r\n\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._stationBaseFactor = this._stationBaseFactor;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._azimuthBase = this._azimuthBase;\r\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\r\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\r\n newFormat._ratioType = this._ratioType;\r\n newFormat._ratioFormatType = this._ratioFormatType;\r\n newFormat._ratioSeparator = this._ratioSeparator;\r\n newFormat._revolutionUnit = this._revolutionUnit;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\r\n return this.fromFullyResolvedJSON(json);\r\n }\r\n\r\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\r\n this.loadFormatProperties(jsonObj);\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined !== jsonObj.composite) {\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) {\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // If composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) {\r\n const isDuplicateAllowed = this.type === FormatType.Ratio;\r\n const seenUnits = new Set<string>();\r\n this._units = [];\r\n\r\n for (const unitSpec of jsonObj.composite.units) {\r\n if (!isDuplicateAllowed) {\r\n const unitName = unitSpec.unit.name.toLowerCase();\r\n const existingName = seenUnits.has(unitName);\r\n\r\n if (existingName) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${this.name} contains duplicate units: '${unitSpec.unit.name}'`\r\n );\r\n }\r\n seenUnits.add(unitName);\r\n }\r\n this._units.push([unitSpec.unit, unitSpec.label]);\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n\r\n if (this.type === FormatType.Ratio && (!this._units || this._units.length === 0)) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type and must have 'composite' units.`);\r\n }\r\n\r\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\r\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\r\n this._revolutionUnit = jsonObj.revolutionUnit;\r\n\r\n if (this._revolutionUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\r\n const actualFormat = new Format(name);\r\n actualFormat.fromFullyResolvedJSON(formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n const json = this.toFullyResolvedJSON();\r\n return {\r\n ...json,\r\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\r\n revolutionUnit: json.revolutionUnit?.name,\r\n composite: json.composite ? {\r\n ...json.composite,\r\n units: json.composite.units.map((unit) => {\r\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\r\n }),\r\n } : undefined,\r\n }\r\n }\r\n\r\n public toFullyResolvedJSON(): ResolvedFormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { unit: value[0], label: value[1] };\r\n else\r\n return { unit: value[0] };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n const azimuthBaseUnit = this.azimuthBaseUnit;\r\n const revolutionUnit = this.revolutionUnit;\r\n\r\n const baseFormatProps: ResolvedFormatProps = {\r\n type: this.type,\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: this.showSignOption,\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? this.scientificType : undefined,\r\n ratioType: this.ratioType,\r\n ratioFormatType: this.ratioFormatType,\r\n ratioSeparator: this.ratioSeparator,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n stationBaseFactor: this.stationBaseFactor,\r\n azimuthBase: this.azimuthBase,\r\n azimuthBaseUnit,\r\n azimuthCounterClockwise: this.azimuthCounterClockwise,\r\n revolutionUnit,\r\n composite,\r\n custom: this.customProps,\r\n };\r\n\r\n return baseFormatProps;\r\n }\r\n}\r\n\r\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\r\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(name);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n }\r\n\r\n return unit;\r\n}\r\n\r\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\r\n const unitName = jsonObj[key];\r\n if (undefined !== unitName) {\r\n if (typeof unitName !== \"string\") {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\r\n }\r\n\r\n const unit = await provider.findUnitByName(unitName);\r\n if (!unit || !unit.isValid) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\r\n }\r\n\r\n return unit;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\r\n let units: ResolvedFormatUnitSpec[] | undefined;\r\n if (undefined !== jsonObj.composite?.units) {\r\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\r\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\r\n return { unit, label: entry.label };\r\n }));\r\n\r\n // For Ratio formats with 2 units: validate both units have the same phenomenon\r\n const formatType = parseFormatType(jsonObj.type, formatName);\r\n if (formatType === FormatType.Ratio && units.length === 2) {\r\n const phenomenon1 = units[0].unit.phenomenon;\r\n const phenomenon2 = units[1].unit.phenomenon;\r\n if (phenomenon1 !== phenomenon2) {\r\n throw new QuantityError(\r\n QuantityStatus.InvalidJson,\r\n `The Format ${formatName} has 2-unit composite with different phenomena. Both units must have the same phenomenon. Found '${phenomenon1}' and '${phenomenon2}'.`\r\n );\r\n }\r\n }\r\n }\r\n\r\n let azimuthBaseUnit, revolutionUnit;\r\n const type = parseFormatType(jsonObj.type, formatName);\r\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\r\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\r\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\r\n\r\n if (!revolutionUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\r\n }\r\n\r\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\r\n }\r\n }\r\n\r\n return {\r\n ...jsonObj,\r\n azimuthBaseUnit,\r\n revolutionUnit,\r\n composite: units ? {\r\n ...jsonObj.composite,\r\n units,\r\n } : undefined,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,4CAAiD;AACjD,4CAA6D;AAE7D,+CAMuB;AAGvB,sFAAsF;AACtF,6JAA6J;AAE7J;;GAEG;AACH,MAAa,UAAU;IACb,KAAK,GAAG,EAAE,CAAC;IACT,YAAY,GAAW,GAAG,CAAC;IAC3B,KAAK,GAAe,wBAAU,CAAC,OAAO,CAAC,CAAC,iEAAiE;IACzG,UAAU,GAAW,8BAAgB,CAAC,GAAG,CAAC,CAAC,WAAW;IACtD,eAAe,GAAmB,4BAAc,CAAC,YAAY,CAAC,CAAC,iEAAiE;IAChI,iBAAiB,GAAW,6BAAiB,CAAC,8BAA8B,CAAC;IAC7E,kBAAkB,GAAW,6BAAiB,CAAC,+BAA+B,CAAC;IAC/E,aAAa,GAAG,GAAG,CAAC,CAAC,6EAA6E;IAClG,iBAAiB,GAAG,GAAG,CAAC,CAAC,2BAA2B;IACpD,aAAa,GAAiB,0BAAY,CAAC,aAAa,CAAC;IACzD,OAAO,GAAW,GAAG,CAAC,CAAC,2BAA2B;IAClD,YAAY,GAAY,IAAI,CAAC,CAAC,4BAA4B;IAC1D,SAAS,CAAU,CAAC,yBAAyB;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AC;YACpB,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,uFAAuF,CAAC,CAAC;QACvK,CAAC;QAED,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1D,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,cAAc,UAAU,wFAAwF,CAAC,CAAC;QACxK,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,OAAO;QACV,eAAe;QACf,cAAc;QACd,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACjB,GAAG,OAAO,CAAC,SAAS;YACpB,KAAK;SACN,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Quantity\n */\n\nimport { QuantityConstants } from \"../Constants\";\nimport { QuantityError, QuantityStatus } from \"../Exception\";\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\nimport {\n DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, FractionalPrecision, getTraitString,\n parseFormatTrait, parseFormatType, parsePrecision, parseRatioFormatType, parseRatioType, parseScientificType, parseShowSignOption,\n RatioFormatType, RatioType,\n ScientificType,\n ShowSignOption,\n} from \"./FormatEnums\";\nimport { CloneOptions, FormatProps, ResolvedFormatProps, ResolvedFormatUnitSpec } from \"./Interfaces\";\n\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\n\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\n * @beta\n */\nexport class BaseFormat {\n private _name = \"\";\n protected _roundFactor: number = 0.0;\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\n protected _precision: number = DecimalPrecision.Six; // required\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\n protected _spacer: string = \" \"; // optional; default is \" \"\n protected _includeZero: boolean = true; // optional; default is true\n protected _minWidth?: number; // optional; positive int\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\n protected _stationBaseFactor?: number; // optional positive integer base factor for station formatting; default is 1\n protected _ratioType?: RatioType; // required if type is ratio; options: oneToN, NToOne, ValueBased, useGreatestCommonDivisor\n protected _ratioFormatType?: RatioFormatType; // defaults to Decimal if not specified\n protected _ratioSeparator?: string; // default is \":\"; separator character used in ratio formatting\n protected _azimuthBase?: number; // value always clockwise from north\n protected _azimuthBaseUnit?: UnitProps; // unit for azimuthBase value\n protected _azimuthCounterClockwise?: boolean; // if set to true, azimuth values are returned counter-clockwise from base\n protected _revolutionUnit?: UnitProps; // unit that represents a revolution, required for bearing or azimuth types\n protected _allowMathematicOperations: boolean = false; // optional; enables calculating mathematic operations like addition and subtraction; default is false.\n\n constructor(name: string) {\n this._name = name;\n }\n\n public get name(): string { return this._name; }\n\n public get roundFactor(): number { return this._roundFactor; }\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\n\n public get type(): FormatType { return this._type; }\n public set type(formatType: FormatType) { this._type = formatType; }\n\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\n\n public get minWidth(): number | undefined { return this._minWidth; }\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\n\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\n\n public get ratioType(): RatioType | undefined { return this._ratioType; }\n public set ratioType(ratioType: RatioType | undefined) { this._ratioType = ratioType; }\n\n public get ratioFormatType(): RatioFormatType | undefined { return this._ratioFormatType; }\n public set ratioFormatType(ratioFormatType: RatioFormatType | undefined) { this._ratioFormatType = ratioFormatType; }\n\n public get ratioSeparator(): string | undefined { return this._ratioSeparator; }\n public set ratioSeparator(ratioSeparator: string | undefined) { this._ratioSeparator = ratioSeparator; }\n\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\n\n public get decimalSeparator(): string { return this._decimalSeparator; }\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\n\n public get thousandSeparator(): string { return this._thousandSeparator; }\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\n\n public get uomSeparator(): string { return this._uomSeparator; }\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\n\n public get stationSeparator(): string { return this._stationSeparator; }\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\n\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\n public set stationOffsetSize(stationOffsetSize: number | undefined) { stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\n\n /** Gets the station base factor used for station formatting. This is a positive integer that acts as a multiplier\n * for the base offset calculation. The default value is 1.\n */\n public get stationBaseFactor(): number | undefined {\n return this._stationBaseFactor;\n }\n public set stationBaseFactor(stationBaseFactor: number | undefined) {\n this._stationBaseFactor = stationBaseFactor;\n }\n\n public get allowMathematicOperations(): boolean { return this._allowMathematicOperations; }\n public set allowMathematicOperations(allowMathematicOperations: boolean) { this._allowMathematicOperations = allowMathematicOperations; }\n\n public get formatTraits(): FormatTraits { return this._formatTraits; }\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\n\n public get spacer(): string | undefined { return this._spacer; }\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\n public get spacerOrDefault(): string { return this._spacer ?? \" \"; }\n\n public get includeZero(): boolean | undefined { return this._includeZero; }\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\n\n // default \"north\" is applied by the formatter (quarter rotation counter clockwise from east, the value depends on the units used)\n public get azimuthBase(): number | undefined { return this._azimuthBase; }\n public set azimuthBase(azimuthBase: number | undefined) { this._azimuthBase = azimuthBase; }\n\n public get azimuthBaseUnit(): UnitProps | undefined { return this._azimuthBaseUnit; }\n public set azimuthBaseUnit(azimuthBaseUnit: UnitProps | undefined) { this._azimuthBaseUnit = azimuthBaseUnit; }\n\n public get azimuthCounterClockwise(): boolean | undefined { return this._azimuthCounterClockwise; }\n public set azimuthCounterClockwise(azimuthCounterClockwise: boolean | undefined) { this._azimuthCounterClockwise = azimuthCounterClockwise; }\n public get azimuthClockwiseOrDefault(): boolean { return !this._azimuthCounterClockwise; }\n\n public get revolutionUnit(): UnitProps | undefined { return this._revolutionUnit; }\n public set revolutionUnit(revolutionUnit: UnitProps | undefined) { this._revolutionUnit = revolutionUnit; }\n\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\n this._formatTraits = this.formatTraits | formatTrait;\n });\n }\n\n /** This method returns true if the formatTrait is set in this Format object. */\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\n return (this._formatTraits & formatTrait) === formatTrait;\n }\n\n public loadFormatProperties(formatProps: FormatProps | ResolvedFormatProps) {\n this._type = parseFormatType(formatProps.type, this.name);\n\n if (formatProps.precision !== undefined) {\n if (!Number.isInteger(formatProps.precision))\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\n\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\n }\n if (this.type === FormatType.Scientific) {\n if (undefined === formatProps.scientificType)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\n\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\n }\n\n if (this.type === FormatType.Ratio){\n if (undefined === formatProps.ratioType)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type therefore the attribute 'ratioType' is required.`);\n\n this._ratioType = parseRatioType(formatProps.ratioType, this.name);\n\n if (undefined !== formatProps.ratioSeparator) { // optional; default is 0.0\n if (typeof (formatProps.ratioSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.ratioSeparator.length !== 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'ratioSeparator' attribute. It should be a one character string.`);\n this._ratioSeparator = formatProps.ratioSeparator;\n } else {\n this._ratioSeparator = \":\"; // Apply default\n }\n\n if (undefined !== formatProps.ratioFormatType) {\n this._ratioFormatType = parseRatioFormatType(formatProps.ratioFormatType, this.name);\n } else {\n this._ratioFormatType = RatioFormatType.Decimal; // Apply default\n }\n }\n\n if (undefined !== formatProps.roundFactor) {\n if (typeof (formatProps.roundFactor) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\n this._roundFactor = formatProps.roundFactor;\n }\n\n if (undefined !== formatProps.minWidth) {\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\n this._minWidth = formatProps.minWidth;\n }\n if (FormatType.Station === this.type) {\n if (undefined === formatProps.stationOffsetSize)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize <= 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\n this._stationOffsetSize = formatProps.stationOffsetSize;\n\n if (undefined !== formatProps.stationBaseFactor) {\n if (!Number.isInteger(formatProps.stationBaseFactor) || formatProps.stationBaseFactor <= 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationBaseFactor' attribute. It should be a positive integer.`);\n this._stationBaseFactor = formatProps.stationBaseFactor;\n }\n }\n\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\n }\n\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) {\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\n this.parseFormatTraits(formatProps.formatTraits);\n }\n\n if (undefined !== formatProps.decimalSeparator) {\n if (typeof (formatProps.decimalSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.decimalSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\n this._decimalSeparator = formatProps.decimalSeparator;\n }\n\n if (undefined !== formatProps.thousandSeparator) {\n if (typeof (formatProps.thousandSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.thousandSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\n this._thousandSeparator = formatProps.thousandSeparator;\n }\n\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\n if (typeof (formatProps.uomSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\n this._uomSeparator = formatProps.uomSeparator;\n }\n\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\n if (typeof (formatProps.stationSeparator) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\n if (formatProps.stationSeparator.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\n this._stationSeparator = formatProps.stationSeparator;\n }\n\n if (undefined !== formatProps.azimuthBase) { // optional; default is a quarter rotation (90 degrees) which represents north\n if (typeof (formatProps.azimuthBase) !== \"number\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthBase' attribute. It should be of type 'number'.`);\n this._azimuthBase = formatProps.azimuthBase;\n }\n\n if (undefined !== formatProps.azimuthCounterClockwise) { // optional; default is false, azimuth values are clockwise from base\n if (typeof (formatProps.azimuthCounterClockwise) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'azimuthCounterClockwise' attribute. It should be of type 'boolean'.`);\n this._azimuthCounterClockwise = formatProps.azimuthCounterClockwise;\n }\n if (undefined !== formatProps.allowMathematicOperations) { // optional; default is false\n if (typeof (formatProps.allowMathematicOperations) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'allowMathematicOperations' attribute. It should be of type 'boolean'.`);\n this._allowMathematicOperations = formatProps.allowMathematicOperations;\n }\n }\n}\n\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\n * @beta\n */\nexport class Format extends BaseFormat {\n protected _units?: Array<[UnitProps, string | undefined]>;\n protected _customProps?: any; // used by custom formatters and parsers\n\n /** Constructor\n * @param name The name of a format specification. TODO: make optional or remove\n */\n constructor(name: string) {\n super(name);\n }\n\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\n public get customProps(): any { return this._customProps; }\n\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\n if (!formatProps.formatTraits)\n return false;\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\n const traitStr = getTraitString(trait);\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\n }\n\n /**\n * Clone Format\n */\n public clone(options?: CloneOptions): Format {\n const newFormat = new Format(this.name);\n newFormat._roundFactor = this._roundFactor;\n newFormat._type = this._type;\n newFormat._precision = this._precision;\n newFormat._minWidth = this._minWidth;\n newFormat._scientificType = this._scientificType;\n newFormat._showSignOption = this._showSignOption;\n newFormat._decimalSeparator = this._decimalSeparator;\n newFormat._thousandSeparator = this._thousandSeparator;\n newFormat._uomSeparator = this._uomSeparator;\n newFormat._stationSeparator = this._stationSeparator;\n newFormat._stationOffsetSize = this._stationOffsetSize;\n newFormat._stationBaseFactor = this._stationBaseFactor;\n newFormat._formatTraits = this._formatTraits;\n newFormat._spacer = this._spacer;\n newFormat._includeZero = this._includeZero;\n newFormat._azimuthBase = this._azimuthBase;\n newFormat._azimuthBaseUnit = this._azimuthBaseUnit;\n newFormat._azimuthCounterClockwise = this._azimuthCounterClockwise;\n newFormat._ratioType = this._ratioType;\n newFormat._ratioFormatType = this._ratioFormatType;\n newFormat._ratioSeparator = this._ratioSeparator;\n newFormat._revolutionUnit = this._revolutionUnit;\n newFormat._customProps = this._customProps;\n this._units && (newFormat._units = [...this._units]);\n\n if (newFormat._units) {\n if (options?.showOnlyPrimaryUnit) {\n if (newFormat._units.length > 1)\n newFormat._units.length = 1;\n }\n }\n\n if (undefined !== options?.traits)\n newFormat._formatTraits = options?.traits;\n\n if (undefined !== options?.type)\n newFormat._type = options.type;\n\n if (undefined !== options?.precision) {\n // ensure specified precision is valid\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\n newFormat._precision = precision;\n }\n\n if (undefined !== options?.primaryUnit) {\n if (options.primaryUnit.unit) {\n const newUnits = new Array<[UnitProps, string | undefined]>();\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\n newFormat._units = newUnits;\n } else if (options.primaryUnit.label && newFormat._units?.length) {\n // update label only\n newFormat._units[0][1] = options.primaryUnit.label;\n }\n }\n return newFormat;\n }\n\n /**\n * Populates this Format with the values from the provided.\n */\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\n const json = await resolveFormatProps(this.name, unitsProvider, jsonObj);\n return this.fromFullyResolvedJSON(json);\n }\n\n public fromFullyResolvedJSON(jsonObj: ResolvedFormatProps): void {\n this.loadFormatProperties(jsonObj);\n this._customProps = jsonObj.custom;\n\n if (undefined !== jsonObj.composite) {\n this._units = new Array<[UnitProps, string | undefined]>();\n if (jsonObj.composite.includeZero !== undefined) {\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\n this._includeZero = jsonObj.composite.includeZero;\n }\n if (jsonObj.composite.spacer !== undefined) {\n if (typeof (jsonObj.composite.spacer) !== \"string\")\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\n if (jsonObj.composite.spacer.length > 1)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\n this._spacer = jsonObj.composite.spacer;\n }\n if (jsonObj.composite.units !== undefined) { // If composite is defined, it must be an array with 1-4 units\n if (!Array.isArray(jsonObj.composite.units)) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\n }\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) {\n const isDuplicateAllowed = this.type === FormatType.Ratio;\n const seenUnits = new Set<string>();\n this._units = [];\n\n for (const unitSpec of jsonObj.composite.units) {\n if (!isDuplicateAllowed) {\n const unitName = unitSpec.unit.name.toLowerCase();\n const existingName = seenUnits.has(unitName);\n\n if (existingName) {\n throw new QuantityError(\n QuantityStatus.InvalidJson,\n `The Format ${this.name} contains duplicate units: '${unitSpec.unit.name}'`\n );\n }\n seenUnits.add(unitName);\n }\n this._units.push([unitSpec.unit, unitSpec.label]);\n }\n }\n }\n if (undefined === this.units || this.units.length === 0)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\n }\n\n if (this.type === FormatType.Ratio && (!this._units || this._units.length === 0)) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Ratio' type and must have 'composite' units.`);\n }\n\n if(this.type === FormatType.Azimuth || this.type === FormatType.Bearing) {\n this._azimuthBaseUnit = jsonObj.azimuthBaseUnit;\n this._revolutionUnit = jsonObj.revolutionUnit;\n\n if (this._revolutionUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\n if (this._azimuthBase !== undefined && this._azimuthBaseUnit === undefined)\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\n }\n }\n\n /** Create a Format from FormatProps */\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\n const actualFormat = new Format(name);\n await actualFormat.fromJSON(unitsProvider, formatProps);\n return actualFormat;\n }\n\n public static createFromFullyResolvedJSON(name: string, formatProps: ResolvedFormatProps) {\n const actualFormat = new Format(name);\n actualFormat.fromFullyResolvedJSON(formatProps);\n return actualFormat;\n }\n\n /**\n * Returns a JSON object that contain the specification for this Format.\n */\n public toJSON(): FormatProps {\n const json = this.toFullyResolvedJSON();\n return {\n ...json,\n azimuthBaseUnit: json.azimuthBaseUnit?.name,\n revolutionUnit: json.revolutionUnit?.name,\n composite: json.composite ? {\n ...json.composite,\n units: json.composite.units.map((unit) => {\n return undefined !== unit.label ? { name: unit.unit.name, label: unit.label } : { name: unit.unit.name };\n }),\n } : undefined,\n }\n }\n\n public toFullyResolvedJSON(): ResolvedFormatProps {\n let composite;\n if (this.units) {\n const units = this.units.map((value) => {\n if (undefined !== value[1])\n return { unit: value[0], label: value[1] };\n else\n return { unit: value[0] };\n });\n\n composite = {\n spacer: this.spacer,\n includeZero: this.includeZero,\n units,\n };\n }\n\n const azimuthBaseUnit = this.azimuthBaseUnit;\n const revolutionUnit = this.revolutionUnit;\n\n const baseFormatProps: ResolvedFormatProps = {\n type: this.type,\n precision: this.precision,\n roundFactor: this.roundFactor,\n minWidth: this.minWidth,\n showSignOption: this.showSignOption,\n formatTraits: formatTraitsToArray(this.formatTraits),\n decimalSeparator: this.decimalSeparator,\n thousandSeparator: this.thousandSeparator,\n uomSeparator: this.uomSeparator,\n scientificType: this.scientificType ? this.scientificType : undefined,\n ratioType: this.ratioType,\n ratioFormatType: this.ratioFormatType,\n ratioSeparator: this.ratioSeparator,\n stationOffsetSize: this.stationOffsetSize,\n stationSeparator: this.stationSeparator,\n stationBaseFactor: this.stationBaseFactor,\n azimuthBase: this.azimuthBase,\n azimuthBaseUnit,\n azimuthCounterClockwise: this.azimuthCounterClockwise,\n revolutionUnit,\n composite,\n custom: this.customProps,\n };\n\n return baseFormatProps;\n }\n}\n\nasync function resolveCompositeUnit(provider: UnitsProvider, name: string, label?: string): Promise<UnitProps> {\n if (typeof name !== \"string\" || (undefined !== label && typeof label !== \"string\")) {\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\n }\n\n const unit = await provider.findUnitByName(name);\n if (!unit || !unit.isValid) {\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\n }\n\n return unit;\n}\n\nasync function resolveAzimuthBearingUnit(formatName: string, jsonObj: FormatProps, key: \"revolutionUnit\" | \"azimuthBaseUnit\", provider: UnitsProvider): Promise<UnitProps | undefined> {\n const unitName = jsonObj[key];\n if (undefined !== unitName) {\n if (typeof unitName !== \"string\") {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid '${key}' attribute. It should be of type 'string'.`);\n }\n\n const unit = await provider.findUnitByName(unitName);\n if (!unit || !unit.isValid) {\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${unitName}' for ${key} in Format '${formatName}'.`);\n }\n\n return unit;\n }\n\n return undefined;\n}\n\nasync function resolveFormatProps(formatName: string, unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<ResolvedFormatProps> {\n let units: ResolvedFormatUnitSpec[] | undefined;\n if (undefined !== jsonObj.composite?.units) {\n units = await Promise.all(jsonObj.composite.units.map(async (entry) => {\n const unit = await resolveCompositeUnit(unitsProvider, entry.name);\n return { unit, label: entry.label };\n }));\n\n // For Ratio formats with 2 units: validate both units have the same phenomenon\n const formatType = parseFormatType(jsonObj.type, formatName);\n if (formatType === FormatType.Ratio && units.length === 2) {\n const phenomenon1 = units[0].unit.phenomenon;\n const phenomenon2 = units[1].unit.phenomenon;\n if (phenomenon1 !== phenomenon2) {\n throw new QuantityError(\n QuantityStatus.InvalidJson,\n `The Format ${formatName} has 2-unit composite with different phenomena. Both units must have the same phenomenon. Found '${phenomenon1}' and '${phenomenon2}'.`\n );\n }\n }\n }\n\n let azimuthBaseUnit, revolutionUnit;\n const type = parseFormatType(jsonObj.type, formatName);\n if (type === FormatType.Azimuth || type === FormatType.Bearing) {\n azimuthBaseUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"azimuthBaseUnit\", unitsProvider);\n revolutionUnit = await resolveAzimuthBearingUnit(formatName, jsonObj, \"revolutionUnit\", unitsProvider);\n\n if (!revolutionUnit) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} is 'Azimuth' or 'Bearing' type therefore the attribute 'revolutionUnit' is required.`);\n }\n\n if (jsonObj.azimuthBase !== undefined && !azimuthBaseUnit) {\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an 'azimuthBase' attribute therefore the attribute 'azimuthBaseUnit' is required.`);\n }\n }\n\n return {\n ...jsonObj,\n azimuthBaseUnit,\n revolutionUnit,\n composite: units ? {\n ...jsonObj.composite,\n units,\n } : undefined,\n };\n}\n"]}