@itwin/core-quantity 5.10.0-dev.8 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/README.md +17 -0
- package/lib/cjs/BasicUnitsProvider.d.ts +8 -5
- package/lib/cjs/BasicUnitsProvider.d.ts.map +1 -1
- package/lib/cjs/BasicUnitsProvider.js +16 -139
- package/lib/cjs/BasicUnitsProvider.js.map +1 -1
- package/lib/cjs/Exception.d.ts +2 -1
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +1 -0
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/FormatSpecHandle.d.ts +1 -2
- package/lib/cjs/FormatSpecHandle.d.ts.map +1 -1
- package/lib/cjs/FormatSpecHandle.js +0 -1
- package/lib/cjs/FormatSpecHandle.js.map +1 -1
- package/lib/cjs/Quantity.d.ts +4 -0
- package/lib/cjs/Quantity.d.ts.map +1 -1
- package/lib/cjs/Quantity.js +12 -23
- package/lib/cjs/Quantity.js.map +1 -1
- package/lib/cjs/UnitConversion/UnitConversion.js +6 -6
- package/lib/cjs/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/cjs/UnitConversions.d.ts +40 -0
- package/lib/cjs/UnitConversions.d.ts.map +1 -0
- package/lib/cjs/UnitConversions.js +121 -0
- package/lib/cjs/UnitConversions.js.map +1 -0
- package/lib/cjs/assets/Units.json +72 -1
- package/lib/cjs/core-quantity.d.ts +6 -0
- package/lib/cjs/core-quantity.d.ts.map +1 -1
- package/lib/cjs/core-quantity.js +6 -0
- package/lib/cjs/core-quantity.js.map +1 -1
- package/lib/cjs/generated/Units.generated.d.ts +785 -0
- package/lib/cjs/generated/Units.generated.d.ts.map +1 -0
- package/lib/cjs/generated/Units.generated.js +775 -0
- package/lib/cjs/generated/Units.generated.js.map +1 -0
- package/lib/cjs/internal/BasicUnitConversionData.d.ts +33 -0
- package/lib/cjs/internal/BasicUnitConversionData.d.ts.map +1 -0
- package/lib/cjs/internal/BasicUnitConversionData.js +126 -0
- package/lib/cjs/internal/BasicUnitConversionData.js.map +1 -0
- package/lib/cjs/internal/BasicUnitConversions.generated.d.ts +507 -0
- package/lib/cjs/internal/BasicUnitConversions.generated.d.ts.map +1 -0
- package/lib/cjs/internal/BasicUnitConversions.generated.js +515 -0
- package/lib/cjs/internal/BasicUnitConversions.generated.js.map +1 -0
- package/lib/cjs/internal/BasicUnitsResolvedStateCache.d.ts +12 -0
- package/lib/cjs/internal/BasicUnitsResolvedStateCache.d.ts.map +1 -0
- package/lib/cjs/internal/BasicUnitsResolvedStateCache.js +37 -0
- package/lib/cjs/internal/BasicUnitsResolvedStateCache.js.map +1 -0
- package/lib/cjs/internal/DefaultPersistenceUnits.generated.d.ts +84 -0
- package/lib/cjs/internal/DefaultPersistenceUnits.generated.d.ts.map +1 -0
- package/lib/cjs/internal/DefaultPersistenceUnits.generated.js +94 -0
- package/lib/cjs/internal/DefaultPersistenceUnits.generated.js.map +1 -0
- package/lib/cjs/internal/UnitConversionMath.d.ts +21 -0
- package/lib/cjs/internal/UnitConversionMath.d.ts.map +1 -0
- package/lib/cjs/internal/UnitConversionMath.js +55 -0
- package/lib/cjs/internal/UnitConversionMath.js.map +1 -0
- package/lib/esm/BasicUnitsProvider.d.ts +8 -5
- package/lib/esm/BasicUnitsProvider.d.ts.map +1 -1
- package/lib/esm/BasicUnitsProvider.js +16 -139
- package/lib/esm/BasicUnitsProvider.js.map +1 -1
- package/lib/esm/Exception.d.ts +2 -1
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +1 -0
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/FormatSpecHandle.d.ts +1 -2
- package/lib/esm/FormatSpecHandle.d.ts.map +1 -1
- package/lib/esm/FormatSpecHandle.js +0 -1
- package/lib/esm/FormatSpecHandle.js.map +1 -1
- package/lib/esm/Quantity.d.ts +4 -0
- package/lib/esm/Quantity.d.ts.map +1 -1
- package/lib/esm/Quantity.js +12 -23
- package/lib/esm/Quantity.js.map +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js +1 -1
- package/lib/esm/UnitConversion/UnitConversion.js.map +1 -1
- package/lib/esm/UnitConversions.d.ts +40 -0
- package/lib/esm/UnitConversions.d.ts.map +1 -0
- package/lib/esm/UnitConversions.js +116 -0
- package/lib/esm/UnitConversions.js.map +1 -0
- package/lib/esm/assets/Units.json +72 -1
- package/lib/esm/core-quantity.d.ts +6 -0
- package/lib/esm/core-quantity.d.ts.map +1 -1
- package/lib/esm/core-quantity.js +6 -0
- package/lib/esm/core-quantity.js.map +1 -1
- package/lib/esm/generated/Units.generated.d.ts +785 -0
- package/lib/esm/generated/Units.generated.d.ts.map +1 -0
- package/lib/esm/generated/Units.generated.js +772 -0
- package/lib/esm/generated/Units.generated.js.map +1 -0
- package/lib/esm/internal/BasicUnitConversionData.d.ts +33 -0
- package/lib/esm/internal/BasicUnitConversionData.d.ts.map +1 -0
- package/lib/esm/internal/BasicUnitConversionData.js +122 -0
- package/lib/esm/internal/BasicUnitConversionData.js.map +1 -0
- package/lib/esm/internal/BasicUnitConversions.generated.d.ts +507 -0
- package/lib/esm/internal/BasicUnitConversions.generated.d.ts.map +1 -0
- package/lib/esm/internal/BasicUnitConversions.generated.js +512 -0
- package/lib/esm/internal/BasicUnitConversions.generated.js.map +1 -0
- package/lib/esm/internal/BasicUnitsResolvedStateCache.d.ts +12 -0
- package/lib/esm/internal/BasicUnitsResolvedStateCache.d.ts.map +1 -0
- package/lib/esm/internal/BasicUnitsResolvedStateCache.js +33 -0
- package/lib/esm/internal/BasicUnitsResolvedStateCache.js.map +1 -0
- package/lib/esm/internal/DefaultPersistenceUnits.generated.d.ts +84 -0
- package/lib/esm/internal/DefaultPersistenceUnits.generated.d.ts.map +1 -0
- package/lib/esm/internal/DefaultPersistenceUnits.generated.js +91 -0
- package/lib/esm/internal/DefaultPersistenceUnits.generated.js.map +1 -0
- package/lib/esm/internal/UnitConversionMath.d.ts +21 -0
- package/lib/esm/internal/UnitConversionMath.d.ts.map +1 -0
- package/lib/esm/internal/UnitConversionMath.js +49 -0
- package/lib/esm/internal/UnitConversionMath.js.map +1 -0
- package/package.json +10 -8
|
@@ -5,7 +5,7 @@ exports.UnitConversion = void 0;
|
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
const
|
|
8
|
+
const UnitConversionMath_1 = require("../internal/UnitConversionMath");
|
|
9
9
|
/**
|
|
10
10
|
* Class used for storing calculated conversion between two Units and converting values from one Unit to another.
|
|
11
11
|
* @internal
|
|
@@ -46,7 +46,7 @@ class UnitConversion {
|
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
48
|
multiply(conversion) {
|
|
49
|
-
if ((0,
|
|
49
|
+
if ((0, UnitConversionMath_1.almostEqual)(conversion.offset, 0.0) && (0, UnitConversionMath_1.almostEqual)(this.offset, 0.0))
|
|
50
50
|
return new UnitConversion(this.factor * conversion.factor, 0.0);
|
|
51
51
|
throw new Error("Cannot multiply two maps with non-zero offsets");
|
|
52
52
|
}
|
|
@@ -55,11 +55,11 @@ class UnitConversion {
|
|
|
55
55
|
* @internal
|
|
56
56
|
*/
|
|
57
57
|
raise(power) {
|
|
58
|
-
if ((0,
|
|
58
|
+
if ((0, UnitConversionMath_1.almostEqual)(power, 1.0))
|
|
59
59
|
return new UnitConversion(this.factor, this.offset);
|
|
60
|
-
else if ((0,
|
|
60
|
+
else if ((0, UnitConversionMath_1.almostEqual)(power, 0.0))
|
|
61
61
|
return new UnitConversion(1.0, 0.0);
|
|
62
|
-
if ((0,
|
|
62
|
+
if ((0, UnitConversionMath_1.almostEqual)(this.offset, 0.0))
|
|
63
63
|
return new UnitConversion(this.factor ** power, 0.0);
|
|
64
64
|
throw new Error("Cannot raise map with non-zero offset");
|
|
65
65
|
}
|
|
@@ -72,7 +72,7 @@ class UnitConversion {
|
|
|
72
72
|
*/
|
|
73
73
|
static from(source) {
|
|
74
74
|
const offset = source.offset ?? 0;
|
|
75
|
-
const hasOffset = !(0,
|
|
75
|
+
const hasOffset = !(0, UnitConversionMath_1.almostEqual)(offset, 0.0);
|
|
76
76
|
return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitConversion.js","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,
|
|
1
|
+
{"version":3,"file":"UnitConversion.js","sourceRoot":"","sources":["../../../src/UnitConversion/UnitConversion.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,uEAA6D;AAc7D;;;GAGG;AACH,MAAa,cAAc;IACG;IAAsC;IAAlE,YAA4B,SAAiB,GAAG,EAAkB,SAAiB,GAAG;QAA1D,WAAM,GAAN,MAAM,CAAc;QAAkB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE1F;;;;OAIG;IACI,QAAQ,CAAC,CAAS;QACvB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;QACxC,OAAO,IAAI,cAAc,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;IACzE,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,UAA0B;QACvC,OAAO,IAAI,cAAc,CACvB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,EAC/B,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CACpD,CAAC;IACJ,CAAC;I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AAG,CAAC,CAAC;IAC9F,CAAC;;AAxEH,wCAyEC","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 { almostEqual } from \"../internal/UnitConversionMath\";\n\n/**\n * Structural interface satisfied by any object that carries a numerator/denominator\n * factor and an optional offset — for example, the EC `Unit` and `Constant` classes in\n * `@itwin/ecschema-metadata`.\n * @internal\n */\nexport interface UnitConversionSource {\n readonly numerator: number;\n readonly denominator: number;\n readonly offset?: number;\n}\n\n/**\n * Class used for storing calculated conversion between two Units and converting values from one Unit to another.\n * @internal\n */\nexport class UnitConversion {\n constructor(public readonly factor: number = 1.0, public readonly offset: number = 0.0) {}\n\n /**\n * Converts x using UnitConversion\n * @param x Input magnitude to be converted\n * @returns Output magnitude after conversion\n */\n public evaluate(x: number): number {\n return this.factor * x + this.offset;\n }\n\n /**\n * Used to invert source's UnitConversion so that it can be composed with target's UnitConversion cleanly\n * @internal\n */\n public inverse(): UnitConversion {\n const inverseFactor = 1.0 / this.factor;\n return new UnitConversion(inverseFactor, -this.offset * inverseFactor);\n }\n\n /**\n * Combines two UnitConversions\n * Used to combine source's UnitConversion and target's UnitConversion for a final UnitConversion that can be evaluated\n * @internal\n */\n public compose(conversion: UnitConversion): UnitConversion {\n return new UnitConversion(\n this.factor * conversion.factor,\n conversion.factor * this.offset + conversion.offset,\n );\n }\n\n /**\n * Multiples two UnitConversions together to calculate factor during reducing\n * @internal\n */\n public multiply(conversion: UnitConversion): UnitConversion {\n if (almostEqual(conversion.offset, 0.0) && almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor * conversion.factor, 0.0);\n\n throw new Error(\"Cannot multiply two maps with non-zero offsets\");\n }\n\n /**\n * Raise UnitConversion's factor with power exponent to calculate factor during reducing\n * @internal\n */\n public raise(power: number): UnitConversion {\n if (almostEqual(power, 1.0))\n return new UnitConversion(this.factor, this.offset);\n else if (almostEqual(power, 0.0))\n return new UnitConversion(1.0, 0.0);\n\n if (almostEqual(this.offset, 0.0))\n return new UnitConversion(this.factor ** power, 0.0);\n\n throw new Error(\"Cannot raise map with non-zero offset\");\n }\n\n /** @internal */\n public static identity = new UnitConversion();\n\n /**\n * Returns UnitConversion with source's numerator and denominator in factor and source's offset in offset for reducing.\n * Accepts any object that structurally satisfies `UnitConversionSource` (e.g. EC `Unit` or `Constant`).\n * @internal\n */\n public static from(source: UnitConversionSource): UnitConversion {\n const offset = source.offset ?? 0;\n const hasOffset = !almostEqual(offset, 0.0);\n return new UnitConversion(source.denominator / source.numerator, hasOffset ? -offset : 0.0);\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Quantity
|
|
3
|
+
*/
|
|
4
|
+
import { type UnitConversionProps } from "./Interfaces";
|
|
5
|
+
import { Phenomena, type PhenomenonName, type UnitName } from "./generated/Units.generated";
|
|
6
|
+
/** Type guard verifying a string is a known canonical built-in unit name.
|
|
7
|
+
*
|
|
8
|
+
* Returns true only for unit names shipped in the bundled built-in canonical unit set.
|
|
9
|
+
* Use this at system boundaries (e.g. when ingesting unit names from JSON config,
|
|
10
|
+
* iModel metadata, user input, or other dynamic sources) before calling
|
|
11
|
+
* `UnitConversions.getConversion`, `convert`, or `isCompatible`. Narrows the input
|
|
12
|
+
* type to `UnitName` so subsequent calls type-check without casts.
|
|
13
|
+
*
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export declare function isUnitName(value: string): value is UnitName;
|
|
17
|
+
/** Returns the package's default built-in persistence unit for a supported bundled built-in phenomenon.
|
|
18
|
+
*
|
|
19
|
+
* This helper is intentionally limited to the built-in canonical unit set shipped with `@itwin/core-quantity`.
|
|
20
|
+
* `Phenomena.LENGTH_RATIO` is intentionally excluded because the bundled built-in unit set does not yet provide an agreed default for that phenomenon.
|
|
21
|
+
* For schema-defined, custom, or iModel-specific persistence units, use a `UnitsProvider`-based workflow instead.
|
|
22
|
+
*
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export declare function getDefaultPersistenceUnit(phenomenon: Exclude<PhenomenonName, typeof Phenomena.LENGTH_RATIO>): UnitName;
|
|
26
|
+
/** One-stop unit conversion helpers for the built-in canonical unit set generated from `@bentley/units-schema`.
|
|
27
|
+
* This surface is synchronous and only supports built-in canonical unit names shipped with `core-quantity`.
|
|
28
|
+
* `getConversion(...)` returns `UnitConversionProps` and uses `error: true` as the compatibility sentinel for known-but-incompatible built-in units.
|
|
29
|
+
* `convert(...)` and `convertValue(...)` are the throwing application helpers to use when invalid conversion metadata should fail fast.
|
|
30
|
+
* `isCompatible(...)` is the explicit built-in compatibility check to use before applying a conversion when a non-throwing branch is preferred.
|
|
31
|
+
* For schema-defined, custom, or provider-resolved units outside that built-in set, use a `UnitsProvider`-based workflow instead.
|
|
32
|
+
* @beta
|
|
33
|
+
*/
|
|
34
|
+
export declare const UnitConversions: {
|
|
35
|
+
readonly getConversion: (fromUnit: UnitName, toUnit: UnitName) => UnitConversionProps;
|
|
36
|
+
readonly convert: (fromUnit: UnitName, toUnit: UnitName, value: number) => number;
|
|
37
|
+
readonly convertValue: (value: number, conversion: UnitConversionProps) => number;
|
|
38
|
+
readonly isCompatible: (fromUnit: UnitName, toUnit: UnitName) => boolean;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=UnitConversions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitConversions.d.ts","sourceRoot":"","sources":["../../src/UnitConversions.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAqC5F;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAE3D;AAkED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,OAAO,CAAC,cAAc,EAAE,OAAO,SAAS,CAAC,YAAY,CAAC,GACjE,QAAQ,CAEV;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,eAAe,EAAE;IAC5B,QAAQ,CAAC,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,KAAK,mBAAmB,CAAC;IACtF,QAAQ,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAClF,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,KAAK,MAAM,CAAC;IAClF,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC;CAM1E,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Quantity
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.UnitConversions = void 0;
|
|
11
|
+
exports.isUnitName = isUnitName;
|
|
12
|
+
exports.getDefaultPersistenceUnit = getDefaultPersistenceUnit;
|
|
13
|
+
const Exception_1 = require("./Exception");
|
|
14
|
+
const Interfaces_1 = require("./Interfaces");
|
|
15
|
+
const BasicUnitConversions_generated_1 = require("./internal/BasicUnitConversions.generated");
|
|
16
|
+
const DefaultPersistenceUnits_generated_1 = require("./internal/DefaultPersistenceUnits.generated");
|
|
17
|
+
const UnitConversionMath_1 = require("./internal/UnitConversionMath");
|
|
18
|
+
const basicUnitConversionLookup = BasicUnitConversions_generated_1.basicUnitConversionData;
|
|
19
|
+
function getUnitEntryFields([phenomenon, factor, offset, invertsUnitName]) {
|
|
20
|
+
return { phenomenon, factor, offset, invertsUnitName };
|
|
21
|
+
}
|
|
22
|
+
function throwUnknownUnit(unitName) {
|
|
23
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.UnknownUnit, `Unknown unit "${unitName}".`);
|
|
24
|
+
}
|
|
25
|
+
function getUnitEntry(unitName) {
|
|
26
|
+
if (!Object.prototype.hasOwnProperty.call(basicUnitConversionLookup, unitName))
|
|
27
|
+
return throwUnknownUnit(unitName);
|
|
28
|
+
return basicUnitConversionLookup[unitName];
|
|
29
|
+
}
|
|
30
|
+
/** Type guard verifying a string is a known canonical built-in unit name.
|
|
31
|
+
*
|
|
32
|
+
* Returns true only for unit names shipped in the bundled built-in canonical unit set.
|
|
33
|
+
* Use this at system boundaries (e.g. when ingesting unit names from JSON config,
|
|
34
|
+
* iModel metadata, user input, or other dynamic sources) before calling
|
|
35
|
+
* `UnitConversions.getConversion`, `convert`, or `isCompatible`. Narrows the input
|
|
36
|
+
* type to `UnitName` so subsequent calls type-check without casts.
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
function isUnitName(value) {
|
|
41
|
+
return Object.prototype.hasOwnProperty.call(basicUnitConversionLookup, value);
|
|
42
|
+
}
|
|
43
|
+
function getComparableEntry(unit) {
|
|
44
|
+
const { invertsUnitName } = getUnitEntryFields(unit);
|
|
45
|
+
return invertsUnitName ? getUnitEntry(invertsUnitName) : unit;
|
|
46
|
+
}
|
|
47
|
+
function composeConversion(fromUnit, toUnit) {
|
|
48
|
+
const { factor: fromFactor, offset: fromOffset } = getUnitEntryFields(fromUnit);
|
|
49
|
+
const { factor: toFactor, offset: toOffset } = getUnitEntryFields(toUnit);
|
|
50
|
+
return {
|
|
51
|
+
factor: toFactor / fromFactor,
|
|
52
|
+
offset: toOffset - ((toFactor * fromOffset) / fromFactor),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function getConversion(fromUnit, toUnit) {
|
|
56
|
+
const from = getUnitEntry(fromUnit);
|
|
57
|
+
const to = getUnitEntry(toUnit);
|
|
58
|
+
const comparableFrom = getComparableEntry(from);
|
|
59
|
+
const comparableTo = getComparableEntry(to);
|
|
60
|
+
const fromFields = getUnitEntryFields(from);
|
|
61
|
+
const toFields = getUnitEntryFields(to);
|
|
62
|
+
const comparableFromFields = getUnitEntryFields(comparableFrom);
|
|
63
|
+
const comparableToFields = getUnitEntryFields(comparableTo);
|
|
64
|
+
if (comparableFromFields.phenomenon !== comparableToFields.phenomenon)
|
|
65
|
+
return { factor: 1.0, offset: 0.0, error: true };
|
|
66
|
+
if (fromFields.invertsUnitName && toFields.invertsUnitName)
|
|
67
|
+
return composeConversion(comparableFrom, comparableTo);
|
|
68
|
+
if (fromFields.invertsUnitName) {
|
|
69
|
+
return {
|
|
70
|
+
...composeConversion(comparableFrom, to),
|
|
71
|
+
inversion: Interfaces_1.UnitConversionInvert.InvertPreConversion,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (toFields.invertsUnitName) {
|
|
75
|
+
return {
|
|
76
|
+
...composeConversion(from, comparableTo),
|
|
77
|
+
inversion: Interfaces_1.UnitConversionInvert.InvertPostConversion,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return composeConversion(from, to);
|
|
81
|
+
}
|
|
82
|
+
function convert(fromUnit, toUnit, value) {
|
|
83
|
+
const conversion = getConversion(fromUnit, toUnit);
|
|
84
|
+
if (conversion.error)
|
|
85
|
+
throw new Exception_1.QuantityError(Exception_1.QuantityStatus.InvalidUnitConversion, `Cannot convert value from "${fromUnit}" to "${toUnit}" using invalid conversion metadata.`);
|
|
86
|
+
return (0, UnitConversionMath_1.convertValueOrThrow)(value, conversion);
|
|
87
|
+
}
|
|
88
|
+
function isCompatible(fromUnit, toUnit) {
|
|
89
|
+
const from = getComparableEntry(getUnitEntry(fromUnit));
|
|
90
|
+
const to = getComparableEntry(getUnitEntry(toUnit));
|
|
91
|
+
const { phenomenon: fromPhenomenon } = getUnitEntryFields(from);
|
|
92
|
+
const { phenomenon: toPhenomenon } = getUnitEntryFields(to);
|
|
93
|
+
return fromPhenomenon === toPhenomenon;
|
|
94
|
+
}
|
|
95
|
+
/** Returns the package's default built-in persistence unit for a supported bundled built-in phenomenon.
|
|
96
|
+
*
|
|
97
|
+
* This helper is intentionally limited to the built-in canonical unit set shipped with `@itwin/core-quantity`.
|
|
98
|
+
* `Phenomena.LENGTH_RATIO` is intentionally excluded because the bundled built-in unit set does not yet provide an agreed default for that phenomenon.
|
|
99
|
+
* For schema-defined, custom, or iModel-specific persistence units, use a `UnitsProvider`-based workflow instead.
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
function getDefaultPersistenceUnit(phenomenon) {
|
|
104
|
+
return DefaultPersistenceUnits_generated_1.defaultPersistenceUnits[phenomenon];
|
|
105
|
+
}
|
|
106
|
+
/** One-stop unit conversion helpers for the built-in canonical unit set generated from `@bentley/units-schema`.
|
|
107
|
+
* This surface is synchronous and only supports built-in canonical unit names shipped with `core-quantity`.
|
|
108
|
+
* `getConversion(...)` returns `UnitConversionProps` and uses `error: true` as the compatibility sentinel for known-but-incompatible built-in units.
|
|
109
|
+
* `convert(...)` and `convertValue(...)` are the throwing application helpers to use when invalid conversion metadata should fail fast.
|
|
110
|
+
* `isCompatible(...)` is the explicit built-in compatibility check to use before applying a conversion when a non-throwing branch is preferred.
|
|
111
|
+
* For schema-defined, custom, or provider-resolved units outside that built-in set, use a `UnitsProvider`-based workflow instead.
|
|
112
|
+
* @beta
|
|
113
|
+
*/
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
115
|
+
exports.UnitConversions = {
|
|
116
|
+
getConversion,
|
|
117
|
+
convert,
|
|
118
|
+
convertValue: UnitConversionMath_1.convertValueOrThrow,
|
|
119
|
+
isCompatible,
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=UnitConversions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitConversions.js","sourceRoot":"","sources":["../../src/UnitConversions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAmDH,gCAEC;AA0ED,8DAIC;AAjID,2CAA4D;AAC5D,6CAA8E;AAE9E,8FAAoF;AACpF,oGAAuF;AACvF,sEAAoE;AAgBpE,MAAM,yBAAyB,GAC7B,wDAA0E,CAAC;AAE7E,SAAS,kBAAkB,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAA2B;IACjG,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;AACzD,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,IAAI,yBAAa,CAAC,0BAAc,CAAC,WAAW,EAAE,iBAAiB,QAAQ,IAAI,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,QAAgB;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC;QAC5E,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEpC,OAAO,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA8B;IACxD,MAAM,EAAE,eAAe,EAAE,GAAG,kBAAkB,CAA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AED;;;;;;;GAOG;AACH,SAAgB,yBAAyB,CACvC,UAAkE;IAElE,OAAO,2DAAuB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,gEAAgE;AACnD,QAAA,eAAe,GAKxB;IACF,aAAa;IACb,OAAO;IACP,YAAY,EAAE,wCAAmB;IACjC,YAAY;CACb,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 { QuantityError, QuantityStatus } from \"./Exception\";\nimport { UnitConversionInvert, type UnitConversionProps } from \"./Interfaces\";\nimport { Phenomena, type PhenomenonName, type UnitName } from \"./generated/Units.generated\";\nimport { basicUnitConversionData } from \"./internal/BasicUnitConversions.generated\";\nimport { defaultPersistenceUnits } from \"./internal/DefaultPersistenceUnits.generated\";\nimport { convertValueOrThrow } from \"./internal/UnitConversionMath\";\n\ntype BasicUnitConversionEntry = readonly [\n phenomenon: string,\n factor: number,\n offset: number,\n invertsUnitName?: string,\n];\n\ninterface BasicUnitConversionFields {\n readonly phenomenon: string;\n readonly factor: number;\n readonly offset: number;\n readonly invertsUnitName?: string;\n}\n\nconst basicUnitConversionLookup: Record<string, BasicUnitConversionEntry> =\n basicUnitConversionData satisfies Record<string, BasicUnitConversionEntry>;\n\nfunction getUnitEntryFields([phenomenon, factor, offset, invertsUnitName]: BasicUnitConversionEntry): BasicUnitConversionFields {\n return { phenomenon, factor, offset, invertsUnitName };\n}\n\nfunction throwUnknownUnit(unitName: string): never {\n throw new QuantityError(QuantityStatus.UnknownUnit, `Unknown unit \"${unitName}\".`);\n}\n\nfunction getUnitEntry(unitName: string): BasicUnitConversionEntry {\n if (!Object.prototype.hasOwnProperty.call(basicUnitConversionLookup, unitName))\n return throwUnknownUnit(unitName);\n\n return basicUnitConversionLookup[unitName];\n}\n\n/** Type guard verifying a string is a known canonical built-in unit name.\n *\n * Returns true only for unit names shipped in the bundled built-in canonical unit set.\n * Use this at system boundaries (e.g. when ingesting unit names from JSON config,\n * iModel metadata, user input, or other dynamic sources) before calling\n * `UnitConversions.getConversion`, `convert`, or `isCompatible`. Narrows the input\n * type to `UnitName` so subsequent calls type-check without casts.\n *\n * @beta\n */\nexport function isUnitName(value: string): value is UnitName {\n return Object.prototype.hasOwnProperty.call(basicUnitConversionLookup, value);\n}\n\nfunction getComparableEntry(unit: BasicUnitConversionEntry): BasicUnitConversionEntry {\n const { invertsUnitName } = getUnitEntryFields(unit);\n return invertsUnitName ? getUnitEntry(invertsUnitName) : unit;\n}\n\nfunction composeConversion(fromUnit: BasicUnitConversionEntry, toUnit: BasicUnitConversionEntry): UnitConversionProps {\n const { factor: fromFactor, offset: fromOffset } = getUnitEntryFields(fromUnit);\n const { factor: toFactor, offset: toOffset } = getUnitEntryFields(toUnit);\n\n return {\n factor: toFactor / fromFactor,\n offset: toOffset - ((toFactor * fromOffset) / fromFactor),\n };\n}\n\nfunction getConversion(fromUnit: UnitName, toUnit: UnitName): UnitConversionProps {\n const from = getUnitEntry(fromUnit);\n const to = getUnitEntry(toUnit);\n const comparableFrom = getComparableEntry(from);\n const comparableTo = getComparableEntry(to);\n const fromFields = getUnitEntryFields(from);\n const toFields = getUnitEntryFields(to);\n const comparableFromFields = getUnitEntryFields(comparableFrom);\n const comparableToFields = getUnitEntryFields(comparableTo);\n\n if (comparableFromFields.phenomenon !== comparableToFields.phenomenon)\n return { factor: 1.0, offset: 0.0, error: true };\n\n if (fromFields.invertsUnitName && toFields.invertsUnitName)\n return composeConversion(comparableFrom, comparableTo);\n\n if (fromFields.invertsUnitName) {\n return {\n ...composeConversion(comparableFrom, to),\n inversion: UnitConversionInvert.InvertPreConversion,\n };\n }\n\n if (toFields.invertsUnitName) {\n return {\n ...composeConversion(from, comparableTo),\n inversion: UnitConversionInvert.InvertPostConversion,\n };\n }\n\n return composeConversion(from, to);\n}\n\nfunction convert(fromUnit: UnitName, toUnit: UnitName, value: number): number {\n const conversion = getConversion(fromUnit, toUnit);\n if (conversion.error)\n throw new QuantityError(QuantityStatus.InvalidUnitConversion, `Cannot convert value from \"${fromUnit}\" to \"${toUnit}\" using invalid conversion metadata.`);\n\n return convertValueOrThrow(value, conversion);\n}\n\nfunction isCompatible(fromUnit: UnitName, toUnit: UnitName): boolean {\n const from = getComparableEntry(getUnitEntry(fromUnit));\n const to = getComparableEntry(getUnitEntry(toUnit));\n const { phenomenon: fromPhenomenon } = getUnitEntryFields(from);\n const { phenomenon: toPhenomenon } = getUnitEntryFields(to);\n return fromPhenomenon === toPhenomenon;\n}\n\n/** Returns the package's default built-in persistence unit for a supported bundled built-in phenomenon.\n *\n * This helper is intentionally limited to the built-in canonical unit set shipped with `@itwin/core-quantity`.\n * `Phenomena.LENGTH_RATIO` is intentionally excluded because the bundled built-in unit set does not yet provide an agreed default for that phenomenon.\n * For schema-defined, custom, or iModel-specific persistence units, use a `UnitsProvider`-based workflow instead.\n *\n * @beta\n */\nexport function getDefaultPersistenceUnit(\n phenomenon: Exclude<PhenomenonName, typeof Phenomena.LENGTH_RATIO>,\n): UnitName {\n return defaultPersistenceUnits[phenomenon];\n}\n\n/** One-stop unit conversion helpers for the built-in canonical unit set generated from `@bentley/units-schema`.\n * This surface is synchronous and only supports built-in canonical unit names shipped with `core-quantity`.\n * `getConversion(...)` returns `UnitConversionProps` and uses `error: true` as the compatibility sentinel for known-but-incompatible built-in units.\n * `convert(...)` and `convertValue(...)` are the throwing application helpers to use when invalid conversion metadata should fail fast.\n * `isCompatible(...)` is the explicit built-in compatibility check to use before applying a conversion when a non-throwing branch is preferred.\n * For schema-defined, custom, or provider-resolved units outside that built-in set, use a `UnitsProvider`-based workflow instead.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const UnitConversions: {\n readonly getConversion: (fromUnit: UnitName, toUnit: UnitName) => UnitConversionProps;\n readonly convert: (fromUnit: UnitName, toUnit: UnitName, value: number) => number;\n readonly convertValue: (value: number, conversion: UnitConversionProps) => number;\n readonly isCompatible: (fromUnit: UnitName, toUnit: UnitName) => boolean;\n} = {\n getConversion,\n convert,\n convertValue: convertValueOrThrow,\n isCompatible,\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "01.00.00",
|
|
3
|
-
"sourceEcSchemaVersion": "01.00.
|
|
3
|
+
"sourceEcSchemaVersion": "01.00.10",
|
|
4
4
|
"name": "Units",
|
|
5
5
|
"alias": "u",
|
|
6
6
|
"label": "Units",
|
|
@@ -400,6 +400,11 @@
|
|
|
400
400
|
"label": "Angle",
|
|
401
401
|
"definition": "ANGLE"
|
|
402
402
|
},
|
|
403
|
+
"HORIZONTAL_DIRECTION": {
|
|
404
|
+
"schemaItemType": "Phenomenon",
|
|
405
|
+
"label": "Horizontal Direction",
|
|
406
|
+
"definition": "HORIZONTAL_DIRECTION"
|
|
407
|
+
},
|
|
403
408
|
"SOLIDANGLE": {
|
|
404
409
|
"schemaItemType": "Phenomenon",
|
|
405
410
|
"label": "Solid Angle",
|
|
@@ -1284,6 +1289,58 @@
|
|
|
1284
1289
|
"unitSystem": "Units.METRIC",
|
|
1285
1290
|
"definition": "[TWO_PI]*RAD"
|
|
1286
1291
|
},
|
|
1292
|
+
"HORIZONTAL_DIR_ARC_DEG": {
|
|
1293
|
+
"schemaItemType": "Unit",
|
|
1294
|
+
"label": "°",
|
|
1295
|
+
"description": "1/180",
|
|
1296
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1297
|
+
"unitSystem": "Units.METRIC",
|
|
1298
|
+
"definition": "[PI]*HORIZONTAL_DIR_RAD",
|
|
1299
|
+
"denominator": 180
|
|
1300
|
+
},
|
|
1301
|
+
"HORIZONTAL_DIR_ARC_MINUTE": {
|
|
1302
|
+
"schemaItemType": "Unit",
|
|
1303
|
+
"label": "'",
|
|
1304
|
+
"description": "1/60",
|
|
1305
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1306
|
+
"unitSystem": "Units.METRIC",
|
|
1307
|
+
"definition": "HORIZONTAL_DIR_ARC_DEG",
|
|
1308
|
+
"denominator": 60
|
|
1309
|
+
},
|
|
1310
|
+
"HORIZONTAL_DIR_ARC_SECOND": {
|
|
1311
|
+
"schemaItemType": "Unit",
|
|
1312
|
+
"label": "''",
|
|
1313
|
+
"description": "1/3600",
|
|
1314
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1315
|
+
"unitSystem": "Units.METRIC",
|
|
1316
|
+
"definition": "HORIZONTAL_DIR_ARC_DEG",
|
|
1317
|
+
"denominator": 3600
|
|
1318
|
+
},
|
|
1319
|
+
"HORIZONTAL_DIR_GRAD": {
|
|
1320
|
+
"schemaItemType": "Unit",
|
|
1321
|
+
"label": "grad",
|
|
1322
|
+
"description": "1/200",
|
|
1323
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1324
|
+
"unitSystem": "Units.METRIC",
|
|
1325
|
+
"definition": "[PI]*HORIZONTAL_DIR_RAD",
|
|
1326
|
+
"denominator": 200
|
|
1327
|
+
},
|
|
1328
|
+
"HORIZONTAL_DIR_MILLIRAD": {
|
|
1329
|
+
"schemaItemType": "Unit",
|
|
1330
|
+
"label": "mrad",
|
|
1331
|
+
"description": "1/1000",
|
|
1332
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1333
|
+
"unitSystem": "Units.METRIC",
|
|
1334
|
+
"definition": "[PI]*HORIZONTAL_DIR_RAD",
|
|
1335
|
+
"denominator": 1000
|
|
1336
|
+
},
|
|
1337
|
+
"HORIZONTAL_DIR_REVOLUTION": {
|
|
1338
|
+
"schemaItemType": "Unit",
|
|
1339
|
+
"label": "r",
|
|
1340
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
1341
|
+
"unitSystem": "Units.METRIC",
|
|
1342
|
+
"definition": "[TWO_PI]*HORIZONTAL_DIR_RAD"
|
|
1343
|
+
},
|
|
1287
1344
|
"SQ_M": {
|
|
1288
1345
|
"schemaItemType": "Unit",
|
|
1289
1346
|
"label": "m²",
|
|
@@ -3795,6 +3852,13 @@
|
|
|
3795
3852
|
"unitSystem": "Units.METRIC",
|
|
3796
3853
|
"definition": "[MEGA]*LITRE"
|
|
3797
3854
|
},
|
|
3855
|
+
"MILLILITRE": {
|
|
3856
|
+
"schemaItemType": "Unit",
|
|
3857
|
+
"label": "mL",
|
|
3858
|
+
"phenomenon": "Units.VOLUME",
|
|
3859
|
+
"unitSystem": "Units.METRIC",
|
|
3860
|
+
"definition": "[MILLI]*LITRE"
|
|
3861
|
+
},
|
|
3798
3862
|
"MICROLITRE": {
|
|
3799
3863
|
"schemaItemType": "Unit",
|
|
3800
3864
|
"label": "µliter",
|
|
@@ -4061,6 +4125,13 @@
|
|
|
4061
4125
|
"unitSystem": "Units.SI",
|
|
4062
4126
|
"definition": "RAD"
|
|
4063
4127
|
},
|
|
4128
|
+
"HORIZONTAL_DIR_RAD": {
|
|
4129
|
+
"schemaItemType": "Unit",
|
|
4130
|
+
"label": "rad",
|
|
4131
|
+
"phenomenon": "Units.HORIZONTAL_DIRECTION",
|
|
4132
|
+
"unitSystem": "Units.SI",
|
|
4133
|
+
"definition": "HORIZONTAL_DIR_RAD"
|
|
4134
|
+
},
|
|
4064
4135
|
"STERAD": {
|
|
4065
4136
|
"schemaItemType": "Unit",
|
|
4066
4137
|
"label": "sterad",
|
|
@@ -5,6 +5,7 @@ export * from "./Interfaces";
|
|
|
5
5
|
export * from "./Parser";
|
|
6
6
|
export * from "./ParserSpec";
|
|
7
7
|
export * from "./Quantity";
|
|
8
|
+
export * from "./UnitConversions";
|
|
8
9
|
export * from "./Unit";
|
|
9
10
|
export * from "./Formatter/Format";
|
|
10
11
|
export * from "./Formatter/FormatterSpec";
|
|
@@ -18,6 +19,7 @@ export * from "./UnitConversion/UnitDefinitionResolver";
|
|
|
18
19
|
export * from "./SerializedUnitSchema";
|
|
19
20
|
export { BasicUnitsProvider } from "./BasicUnitsProvider";
|
|
20
21
|
export * from "./CompositeUnitsProvider";
|
|
22
|
+
export * from "./generated/Units.generated";
|
|
21
23
|
export * from "./internal/cross-package";
|
|
22
24
|
/** @docs-package-description
|
|
23
25
|
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
@@ -34,6 +36,10 @@ export * from "./internal/cross-package";
|
|
|
34
36
|
* @docs-group-description CompositeUnitsProvider
|
|
35
37
|
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
36
38
|
*/
|
|
39
|
+
/**
|
|
40
|
+
* @docs-group-description Units.generated
|
|
41
|
+
* Generated built-in canonical unit, phenomenon, and unit-system identifiers.
|
|
42
|
+
*/
|
|
37
43
|
/**
|
|
38
44
|
* @docs-group-description Logging
|
|
39
45
|
* Logger categories used by this package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-quantity.d.ts","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AAEzC;;GAEG;AAEH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
1
|
+
{"version":3,"file":"core-quantity.d.ts","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAEzC;;GAEG;AAEH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
package/lib/cjs/core-quantity.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./Interfaces"), exports);
|
|
|
26
26
|
__exportStar(require("./Parser"), exports);
|
|
27
27
|
__exportStar(require("./ParserSpec"), exports);
|
|
28
28
|
__exportStar(require("./Quantity"), exports);
|
|
29
|
+
__exportStar(require("./UnitConversions"), exports);
|
|
29
30
|
__exportStar(require("./Unit"), exports);
|
|
30
31
|
__exportStar(require("./Formatter/Format"), exports);
|
|
31
32
|
__exportStar(require("./Formatter/FormatterSpec"), exports);
|
|
@@ -40,6 +41,7 @@ __exportStar(require("./SerializedUnitSchema"), exports);
|
|
|
40
41
|
var BasicUnitsProvider_1 = require("./BasicUnitsProvider");
|
|
41
42
|
Object.defineProperty(exports, "BasicUnitsProvider", { enumerable: true, get: function () { return BasicUnitsProvider_1.BasicUnitsProvider; } });
|
|
42
43
|
__exportStar(require("./CompositeUnitsProvider"), exports);
|
|
44
|
+
__exportStar(require("./generated/Units.generated"), exports);
|
|
43
45
|
__exportStar(require("./internal/cross-package"), exports);
|
|
44
46
|
/** @docs-package-description
|
|
45
47
|
* The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.
|
|
@@ -56,6 +58,10 @@ __exportStar(require("./internal/cross-package"), exports);
|
|
|
56
58
|
* @docs-group-description CompositeUnitsProvider
|
|
57
59
|
* Factory and composition utilities for layering multiple UnitsProviders.
|
|
58
60
|
*/
|
|
61
|
+
/**
|
|
62
|
+
* @docs-group-description Units.generated
|
|
63
|
+
* Generated built-in canonical unit, phenomenon, and unit-system identifiers.
|
|
64
|
+
*/
|
|
59
65
|
/**
|
|
60
66
|
* @docs-group-description Logging
|
|
61
67
|
* Logger categories used by this package.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-quantity.js","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,8CAA4B;AAC5B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,+CAA6B;AAC7B,6CAA2B;AAC3B,yCAAuB;AACvB,qDAAmC;AACnC,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,uEAAqD;AACrD,yDAAuC;AACvC,2DAAyC;AAEzC,kEAAgD;AAChD,0EAAwD;AACxD,yDAAuC;AACvC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,2DAAyC;AACzC,2DAAyC;AAEzC;;GAEG;AAEH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./Constants\";\nexport * from \"./Exception\";\nexport * from \"./FormatSpecHandle\";\nexport * from \"./Interfaces\";\nexport * from \"./Parser\";\nexport * from \"./ParserSpec\";\nexport * from \"./Quantity\";\nexport * from \"./Unit\";\nexport * from \"./Formatter/Format\";\nexport * from \"./Formatter/FormatterSpec\";\nexport * from \"./Formatter/FormatEnums\";\nexport * from \"./Formatter/Formatter\";\nexport * from \"./Formatter/FormattingReadyCollector\";\nexport * from \"./Formatter/Interfaces\";\nexport * from \"./QuantityLoggerCategory\";\n\nexport * from \"./UnitConversion/UnitConversion\";\nexport * from \"./UnitConversion/UnitDefinitionResolver\";\nexport * from \"./SerializedUnitSchema\";\nexport { BasicUnitsProvider } from \"./BasicUnitsProvider\";\nexport * from \"./CompositeUnitsProvider\";\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.\n */\n\n/**\n * @docs-group-description Quantity\n * Classes, Interfaces, and definitions used to format and parse quantity values.\n */\n/**\n * @docs-group-description BasicUnitsProvider\n * A UnitsProvider backed by the bundled BIS Units schema JSON asset.\n */\n/**\n * @docs-group-description CompositeUnitsProvider\n * Factory and composition utilities for layering multiple UnitsProviders.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n"]}
|
|
1
|
+
{"version":3,"file":"core-quantity.js","sourceRoot":"","sources":["../../src/core-quantity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,8CAA4B;AAC5B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,+CAA6B;AAC7B,6CAA2B;AAC3B,oDAAkC;AAClC,yCAAuB;AACvB,qDAAmC;AACnC,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,uEAAqD;AACrD,yDAAuC;AACvC,2DAAyC;AAEzC,kEAAgD;AAChD,0EAAwD;AACxD,yDAAuC;AACvC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,2DAAyC;AACzC,8DAA4C;AAC5C,2DAAyC;AAEzC;;GAEG;AAEH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./Constants\";\nexport * from \"./Exception\";\nexport * from \"./FormatSpecHandle\";\nexport * from \"./Interfaces\";\nexport * from \"./Parser\";\nexport * from \"./ParserSpec\";\nexport * from \"./Quantity\";\nexport * from \"./UnitConversions\";\nexport * from \"./Unit\";\nexport * from \"./Formatter/Format\";\nexport * from \"./Formatter/FormatterSpec\";\nexport * from \"./Formatter/FormatEnums\";\nexport * from \"./Formatter/Formatter\";\nexport * from \"./Formatter/FormattingReadyCollector\";\nexport * from \"./Formatter/Interfaces\";\nexport * from \"./QuantityLoggerCategory\";\n\nexport * from \"./UnitConversion/UnitConversion\";\nexport * from \"./UnitConversion/UnitDefinitionResolver\";\nexport * from \"./SerializedUnitSchema\";\nexport { BasicUnitsProvider } from \"./BasicUnitsProvider\";\nexport * from \"./CompositeUnitsProvider\";\nexport * from \"./generated/Units.generated\";\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-quantity package contains classes, interfaces, and definitions for formatting and parsing quantity values.\n */\n\n/**\n * @docs-group-description Quantity\n * Classes, Interfaces, and definitions used to format and parse quantity values.\n */\n/**\n * @docs-group-description BasicUnitsProvider\n * A UnitsProvider backed by the bundled BIS Units schema JSON asset.\n */\n/**\n * @docs-group-description CompositeUnitsProvider\n * Factory and composition utilities for layering multiple UnitsProviders.\n */\n/**\n * @docs-group-description Units.generated\n * Generated built-in canonical unit, phenomenon, and unit-system identifiers.\n */\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n"]}
|