@itwin/core-common 3.6.0-dev.5 → 3.6.0-dev.51

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 (123) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/AuthorizationClient.d.ts +9 -3
  4. package/lib/cjs/AuthorizationClient.d.ts.map +1 -1
  5. package/lib/cjs/AuthorizationClient.js.map +1 -1
  6. package/lib/cjs/Code.d.ts +20 -7
  7. package/lib/cjs/Code.d.ts.map +1 -1
  8. package/lib/cjs/Code.js +13 -26
  9. package/lib/cjs/Code.js.map +1 -1
  10. package/lib/cjs/ElementMesh.js +2 -2
  11. package/lib/cjs/ElementMesh.js.map +1 -1
  12. package/lib/cjs/ElementProps.d.ts +5 -1
  13. package/lib/cjs/ElementProps.d.ts.map +1 -1
  14. package/lib/cjs/ElementProps.js.map +1 -1
  15. package/lib/cjs/EntityProps.d.ts +2 -1
  16. package/lib/cjs/EntityProps.d.ts.map +1 -1
  17. package/lib/cjs/EntityProps.js +1 -0
  18. package/lib/cjs/EntityProps.js.map +1 -1
  19. package/lib/cjs/IModelError.d.ts +10 -4
  20. package/lib/cjs/IModelError.d.ts.map +1 -1
  21. package/lib/cjs/IModelError.js +3 -4
  22. package/lib/cjs/IModelError.js.map +1 -1
  23. package/lib/cjs/Localization.d.ts.map +1 -1
  24. package/lib/cjs/Localization.js +8 -1
  25. package/lib/cjs/Localization.js.map +1 -1
  26. package/lib/cjs/RealityModelDisplaySettings.d.ts +65 -0
  27. package/lib/cjs/RealityModelDisplaySettings.d.ts.map +1 -1
  28. package/lib/cjs/RealityModelDisplaySettings.js +30 -2
  29. package/lib/cjs/RealityModelDisplaySettings.js.map +1 -1
  30. package/lib/cjs/ViewFlags.d.ts +2 -6
  31. package/lib/cjs/ViewFlags.d.ts.map +1 -1
  32. package/lib/cjs/ViewFlags.js.map +1 -1
  33. package/lib/cjs/core-common.d.ts +0 -1
  34. package/lib/cjs/core-common.d.ts.map +1 -1
  35. package/lib/cjs/core-common.js +0 -1
  36. package/lib/cjs/core-common.js.map +1 -1
  37. package/lib/cjs/geometry/BoundingSphere.d.ts +15 -2
  38. package/lib/cjs/geometry/BoundingSphere.d.ts.map +1 -1
  39. package/lib/cjs/geometry/BoundingSphere.js +18 -4
  40. package/lib/cjs/geometry/BoundingSphere.js.map +1 -1
  41. package/lib/cjs/geometry/FrustumPlanes.d.ts +59 -10
  42. package/lib/cjs/geometry/FrustumPlanes.d.ts.map +1 -1
  43. package/lib/cjs/geometry/FrustumPlanes.js +94 -33
  44. package/lib/cjs/geometry/FrustumPlanes.js.map +1 -1
  45. package/lib/cjs/tile/B3dmTileIO.js +5 -5
  46. package/lib/cjs/tile/B3dmTileIO.js.map +1 -1
  47. package/lib/cjs/tile/CompositeTileIO.js +2 -2
  48. package/lib/cjs/tile/CompositeTileIO.js.map +1 -1
  49. package/lib/cjs/tile/GltfTileIO.js +5 -5
  50. package/lib/cjs/tile/GltfTileIO.js.map +1 -1
  51. package/lib/cjs/tile/I3dmTileIO.js +6 -6
  52. package/lib/cjs/tile/I3dmTileIO.js.map +1 -1
  53. package/lib/cjs/tile/IModelTileIO.js +10 -10
  54. package/lib/cjs/tile/IModelTileIO.js.map +1 -1
  55. package/lib/cjs/tile/PntsTileIO.js +5 -5
  56. package/lib/cjs/tile/PntsTileIO.js.map +1 -1
  57. package/lib/cjs/tile/TileIO.js +3 -3
  58. package/lib/cjs/tile/TileIO.js.map +1 -1
  59. package/lib/esm/AuthorizationClient.d.ts +9 -3
  60. package/lib/esm/AuthorizationClient.d.ts.map +1 -1
  61. package/lib/esm/AuthorizationClient.js.map +1 -1
  62. package/lib/esm/Code.d.ts +20 -7
  63. package/lib/esm/Code.d.ts.map +1 -1
  64. package/lib/esm/Code.js +13 -26
  65. package/lib/esm/Code.js.map +1 -1
  66. package/lib/esm/ElementMesh.js +2 -2
  67. package/lib/esm/ElementMesh.js.map +1 -1
  68. package/lib/esm/ElementProps.d.ts +5 -1
  69. package/lib/esm/ElementProps.d.ts.map +1 -1
  70. package/lib/esm/ElementProps.js.map +1 -1
  71. package/lib/esm/EntityProps.d.ts +2 -1
  72. package/lib/esm/EntityProps.d.ts.map +1 -1
  73. package/lib/esm/EntityProps.js +1 -0
  74. package/lib/esm/EntityProps.js.map +1 -1
  75. package/lib/esm/IModelError.d.ts +10 -4
  76. package/lib/esm/IModelError.d.ts.map +1 -1
  77. package/lib/esm/IModelError.js +3 -2
  78. package/lib/esm/IModelError.js.map +1 -1
  79. package/lib/esm/Localization.d.ts.map +1 -1
  80. package/lib/esm/Localization.js +8 -1
  81. package/lib/esm/Localization.js.map +1 -1
  82. package/lib/esm/RealityModelDisplaySettings.d.ts +65 -0
  83. package/lib/esm/RealityModelDisplaySettings.d.ts.map +1 -1
  84. package/lib/esm/RealityModelDisplaySettings.js +30 -2
  85. package/lib/esm/RealityModelDisplaySettings.js.map +1 -1
  86. package/lib/esm/ViewFlags.d.ts +2 -6
  87. package/lib/esm/ViewFlags.d.ts.map +1 -1
  88. package/lib/esm/ViewFlags.js.map +1 -1
  89. package/lib/esm/core-common.d.ts +0 -1
  90. package/lib/esm/core-common.d.ts.map +1 -1
  91. package/lib/esm/core-common.js +0 -1
  92. package/lib/esm/core-common.js.map +1 -1
  93. package/lib/esm/geometry/BoundingSphere.d.ts +15 -2
  94. package/lib/esm/geometry/BoundingSphere.d.ts.map +1 -1
  95. package/lib/esm/geometry/BoundingSphere.js +18 -4
  96. package/lib/esm/geometry/BoundingSphere.js.map +1 -1
  97. package/lib/esm/geometry/FrustumPlanes.d.ts +59 -10
  98. package/lib/esm/geometry/FrustumPlanes.d.ts.map +1 -1
  99. package/lib/esm/geometry/FrustumPlanes.js +94 -33
  100. package/lib/esm/geometry/FrustumPlanes.js.map +1 -1
  101. package/lib/esm/tile/B3dmTileIO.js +5 -5
  102. package/lib/esm/tile/B3dmTileIO.js.map +1 -1
  103. package/lib/esm/tile/CompositeTileIO.js +2 -2
  104. package/lib/esm/tile/CompositeTileIO.js.map +1 -1
  105. package/lib/esm/tile/GltfTileIO.js +5 -5
  106. package/lib/esm/tile/GltfTileIO.js.map +1 -1
  107. package/lib/esm/tile/I3dmTileIO.js +6 -6
  108. package/lib/esm/tile/I3dmTileIO.js.map +1 -1
  109. package/lib/esm/tile/IModelTileIO.js +10 -10
  110. package/lib/esm/tile/IModelTileIO.js.map +1 -1
  111. package/lib/esm/tile/PntsTileIO.js +5 -5
  112. package/lib/esm/tile/PntsTileIO.js.map +1 -1
  113. package/lib/esm/tile/TileIO.js +3 -3
  114. package/lib/esm/tile/TileIO.js.map +1 -1
  115. package/package.json +7 -7
  116. package/lib/cjs/FeatureGates.d.ts +0 -32
  117. package/lib/cjs/FeatureGates.d.ts.map +0 -1
  118. package/lib/cjs/FeatureGates.js +0 -56
  119. package/lib/cjs/FeatureGates.js.map +0 -1
  120. package/lib/esm/FeatureGates.d.ts +0 -32
  121. package/lib/esm/FeatureGates.d.ts.map +0 -1
  122. package/lib/esm/FeatureGates.js +0 -52
  123. package/lib/esm/FeatureGates.js.map +0 -1
@@ -1,32 +0,0 @@
1
- import { BeEvent } from "@itwin/core-bentley";
2
- /** @internal */
3
- export declare type GateValue = number | boolean | string | undefined;
4
- /** A set of "gates" that can enable or disable features at runtime.
5
- * @internal
6
- */
7
- export declare class FeatureGates {
8
- /** Event raised every time any feature changes. */
9
- onChanged: BeEvent<(feature: string, val: GateValue) => void>;
10
- /** A map of the current set of features. */
11
- readonly gates: Map<string, GateValue>;
12
- /** Get the value of a potentially gated feature.
13
- * @param feature The name of the feature to check. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
14
- * Feature names are case-sensitive.
15
- * @param defaultVal Optionally, value to return if feature is undefined.
16
- */
17
- check(feature: string, defaultVal?: GateValue): GateValue;
18
- /** Gate access to a feature.
19
- * @param feature The name of the feature to gate. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
20
- * Feature names are case-sensitive.
21
- * @param val Value to set. If undefined, feature is deleted.
22
- */
23
- setGate(feature: string, val: GateValue): void;
24
- /** Register a listener to be called whenever the value of a specific gate changes.
25
- * @param feature The name of the feature to monitor
26
- * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).
27
- * @returns A function that may be called to remove the listener.
28
- * @note Use [[onChanged]] to listen to changes for *all* gates.
29
- */
30
- addMonitor(feature: string, monitor: (val: GateValue) => void): () => void;
31
- }
32
- //# sourceMappingURL=FeatureGates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeatureGates.d.ts","sourceRoot":"","sources":["../../src/FeatureGates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,gBAAgB;AAChB,oBAAY,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9D;;GAEG;AACH,qBAAa,YAAY;IACvB,mDAAmD;IAC5C,SAAS,oBAAyB,MAAM,OAAO,SAAS,KAAK,IAAI,EAAI;IAE5E,4CAA4C;IAC5C,SAAgB,KAAK,yBAAgC;IAErD;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS;IAKhE;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI;IAWrD;;;;;OAKG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CAMlF"}
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FeatureGates = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const core_bentley_1 = require("@itwin/core-bentley");
9
- /** A set of "gates" that can enable or disable features at runtime.
10
- * @internal
11
- */
12
- class FeatureGates {
13
- constructor() {
14
- /** Event raised every time any feature changes. */
15
- this.onChanged = new core_bentley_1.BeEvent();
16
- /** A map of the current set of features. */
17
- this.gates = new Map();
18
- }
19
- /** Get the value of a potentially gated feature.
20
- * @param feature The name of the feature to check. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
21
- * Feature names are case-sensitive.
22
- * @param defaultVal Optionally, value to return if feature is undefined.
23
- */
24
- check(feature, defaultVal) {
25
- const val = this.gates.get(feature);
26
- return val === undefined ? defaultVal : val;
27
- }
28
- /** Gate access to a feature.
29
- * @param feature The name of the feature to gate. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
30
- * Feature names are case-sensitive.
31
- * @param val Value to set. If undefined, feature is deleted.
32
- */
33
- setGate(feature, val) {
34
- if (feature.length === 0)
35
- return;
36
- if (val === undefined)
37
- this.gates.delete(feature);
38
- else
39
- this.gates.set(feature, val);
40
- this.onChanged.raiseEvent(feature, val);
41
- }
42
- /** Register a listener to be called whenever the value of a specific gate changes.
43
- * @param feature The name of the feature to monitor
44
- * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).
45
- * @returns A function that may be called to remove the listener.
46
- * @note Use [[onChanged]] to listen to changes for *all* gates.
47
- */
48
- addMonitor(feature, monitor) {
49
- return this.onChanged.addListener((changed, val) => {
50
- if (changed === feature)
51
- monitor(val);
52
- });
53
- }
54
- }
55
- exports.FeatureGates = FeatureGates;
56
- //# sourceMappingURL=FeatureGates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeatureGates.js","sourceRoot":"","sources":["../../src/FeatureGates.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAA8C;AAK9C;;GAEG;AACH,MAAa,YAAY;IAAzB;QACE,mDAAmD;QAC5C,cAAS,GAAG,IAAI,sBAAO,EAA6C,CAAC;QAE5E,4CAA4C;QAC5B,UAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAwCvD,CAAC;IAtCC;;;;OAIG;IACI,KAAK,CAAC,OAAe,EAAE,UAAsB;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAe,EAAE,GAAc;QAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YACtB,OAAO;QACT,IAAI,GAAG,KAAK,SAAS;YACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;;YAE3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE/B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,OAAe,EAAE,OAAiC;QAClE,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;YACjD,IAAI,OAAO,KAAK,OAAO;gBACrB,OAAO,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,oCA6CC","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 { BeEvent } from \"@itwin/core-bentley\";\r\n\r\n/** @internal */\r\nexport type GateValue = number | boolean | string | undefined;\r\n\r\n/** A set of \"gates\" that can enable or disable features at runtime.\r\n * @internal\r\n */\r\nexport class FeatureGates {\r\n /** Event raised every time any feature changes. */\r\n public onChanged = new BeEvent<(feature: string, val: GateValue) => void>();\r\n\r\n /** A map of the current set of features. */\r\n public readonly gates = new Map<string, GateValue>();\r\n\r\n /** Get the value of a potentially gated feature.\r\n * @param feature The name of the feature to check. May be a \"path\" of period-separated feature sub-groups (e.g. \"feature1.groupA.showMe\").\r\n * Feature names are case-sensitive.\r\n * @param defaultVal Optionally, value to return if feature is undefined.\r\n */\r\n public check(feature: string, defaultVal?: GateValue): GateValue {\r\n const val = this.gates.get(feature);\r\n return val === undefined ? defaultVal : val;\r\n }\r\n\r\n /** Gate access to a feature.\r\n * @param feature The name of the feature to gate. May be a \"path\" of period-separated feature sub-groups (e.g. \"feature1.groupA.showMe\").\r\n * Feature names are case-sensitive.\r\n * @param val Value to set. If undefined, feature is deleted.\r\n */\r\n public setGate(feature: string, val: GateValue): void {\r\n if (feature.length === 0)\r\n return;\r\n if (val === undefined)\r\n this.gates.delete(feature);\r\n else\r\n this.gates.set(feature, val);\r\n\r\n this.onChanged.raiseEvent(feature, val);\r\n }\r\n\r\n /** Register a listener to be called whenever the value of a specific gate changes.\r\n * @param feature The name of the feature to monitor\r\n * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).\r\n * @returns A function that may be called to remove the listener.\r\n * @note Use [[onChanged]] to listen to changes for *all* gates.\r\n */\r\n public addMonitor(feature: string, monitor: (val: GateValue) => void): () => void {\r\n return this.onChanged.addListener((changed, val) => {\r\n if (changed === feature)\r\n monitor(val);\r\n });\r\n }\r\n}\r\n"]}
@@ -1,32 +0,0 @@
1
- import { BeEvent } from "@itwin/core-bentley";
2
- /** @internal */
3
- export declare type GateValue = number | boolean | string | undefined;
4
- /** A set of "gates" that can enable or disable features at runtime.
5
- * @internal
6
- */
7
- export declare class FeatureGates {
8
- /** Event raised every time any feature changes. */
9
- onChanged: BeEvent<(feature: string, val: GateValue) => void>;
10
- /** A map of the current set of features. */
11
- readonly gates: Map<string, GateValue>;
12
- /** Get the value of a potentially gated feature.
13
- * @param feature The name of the feature to check. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
14
- * Feature names are case-sensitive.
15
- * @param defaultVal Optionally, value to return if feature is undefined.
16
- */
17
- check(feature: string, defaultVal?: GateValue): GateValue;
18
- /** Gate access to a feature.
19
- * @param feature The name of the feature to gate. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
20
- * Feature names are case-sensitive.
21
- * @param val Value to set. If undefined, feature is deleted.
22
- */
23
- setGate(feature: string, val: GateValue): void;
24
- /** Register a listener to be called whenever the value of a specific gate changes.
25
- * @param feature The name of the feature to monitor
26
- * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).
27
- * @returns A function that may be called to remove the listener.
28
- * @note Use [[onChanged]] to listen to changes for *all* gates.
29
- */
30
- addMonitor(feature: string, monitor: (val: GateValue) => void): () => void;
31
- }
32
- //# sourceMappingURL=FeatureGates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeatureGates.d.ts","sourceRoot":"","sources":["../../src/FeatureGates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,gBAAgB;AAChB,oBAAY,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9D;;GAEG;AACH,qBAAa,YAAY;IACvB,mDAAmD;IAC5C,SAAS,oBAAyB,MAAM,OAAO,SAAS,KAAK,IAAI,EAAI;IAE5E,4CAA4C;IAC5C,SAAgB,KAAK,yBAAgC;IAErD;;;;OAIG;IACI,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS;IAKhE;;;;OAIG;IACI,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI;IAWrD;;;;;OAKG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;CAMlF"}
@@ -1,52 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- import { BeEvent } from "@itwin/core-bentley";
6
- /** A set of "gates" that can enable or disable features at runtime.
7
- * @internal
8
- */
9
- export class FeatureGates {
10
- constructor() {
11
- /** Event raised every time any feature changes. */
12
- this.onChanged = new BeEvent();
13
- /** A map of the current set of features. */
14
- this.gates = new Map();
15
- }
16
- /** Get the value of a potentially gated feature.
17
- * @param feature The name of the feature to check. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
18
- * Feature names are case-sensitive.
19
- * @param defaultVal Optionally, value to return if feature is undefined.
20
- */
21
- check(feature, defaultVal) {
22
- const val = this.gates.get(feature);
23
- return val === undefined ? defaultVal : val;
24
- }
25
- /** Gate access to a feature.
26
- * @param feature The name of the feature to gate. May be a "path" of period-separated feature sub-groups (e.g. "feature1.groupA.showMe").
27
- * Feature names are case-sensitive.
28
- * @param val Value to set. If undefined, feature is deleted.
29
- */
30
- setGate(feature, val) {
31
- if (feature.length === 0)
32
- return;
33
- if (val === undefined)
34
- this.gates.delete(feature);
35
- else
36
- this.gates.set(feature, val);
37
- this.onChanged.raiseEvent(feature, val);
38
- }
39
- /** Register a listener to be called whenever the value of a specific gate changes.
40
- * @param feature The name of the feature to monitor
41
- * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).
42
- * @returns A function that may be called to remove the listener.
43
- * @note Use [[onChanged]] to listen to changes for *all* gates.
44
- */
45
- addMonitor(feature, monitor) {
46
- return this.onChanged.addListener((changed, val) => {
47
- if (changed === feature)
48
- monitor(val);
49
- });
50
- }
51
- }
52
- //# sourceMappingURL=FeatureGates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeatureGates.js","sourceRoot":"","sources":["../../src/FeatureGates.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9C;;GAEG;AACH,MAAM,OAAO,YAAY;IAAzB;QACE,mDAAmD;QAC5C,cAAS,GAAG,IAAI,OAAO,EAA6C,CAAC;QAE5E,4CAA4C;QAC5B,UAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAwCvD,CAAC;IAtCC;;;;OAIG;IACI,KAAK,CAAC,OAAe,EAAE,UAAsB;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpC,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,OAAe,EAAE,GAAc;QAC5C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YACtB,OAAO;QACT,IAAI,GAAG,KAAK,SAAS;YACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;;YAE3B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAE/B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,OAAe,EAAE,OAAiC;QAClE,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;YACjD,IAAI,OAAO,KAAK,OAAO;gBACrB,OAAO,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","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 { BeEvent } from \"@itwin/core-bentley\";\r\n\r\n/** @internal */\r\nexport type GateValue = number | boolean | string | undefined;\r\n\r\n/** A set of \"gates\" that can enable or disable features at runtime.\r\n * @internal\r\n */\r\nexport class FeatureGates {\r\n /** Event raised every time any feature changes. */\r\n public onChanged = new BeEvent<(feature: string, val: GateValue) => void>();\r\n\r\n /** A map of the current set of features. */\r\n public readonly gates = new Map<string, GateValue>();\r\n\r\n /** Get the value of a potentially gated feature.\r\n * @param feature The name of the feature to check. May be a \"path\" of period-separated feature sub-groups (e.g. \"feature1.groupA.showMe\").\r\n * Feature names are case-sensitive.\r\n * @param defaultVal Optionally, value to return if feature is undefined.\r\n */\r\n public check(feature: string, defaultVal?: GateValue): GateValue {\r\n const val = this.gates.get(feature);\r\n return val === undefined ? defaultVal : val;\r\n }\r\n\r\n /** Gate access to a feature.\r\n * @param feature The name of the feature to gate. May be a \"path\" of period-separated feature sub-groups (e.g. \"feature1.groupA.showMe\").\r\n * Feature names are case-sensitive.\r\n * @param val Value to set. If undefined, feature is deleted.\r\n */\r\n public setGate(feature: string, val: GateValue): void {\r\n if (feature.length === 0)\r\n return;\r\n if (val === undefined)\r\n this.gates.delete(feature);\r\n else\r\n this.gates.set(feature, val);\r\n\r\n this.onChanged.raiseEvent(feature, val);\r\n }\r\n\r\n /** Register a listener to be called whenever the value of a specific gate changes.\r\n * @param feature The name of the feature to monitor\r\n * @param monitor The listener to call when `feature` changes. Receives a single argument holding the new value of the feature (may be undefined).\r\n * @returns A function that may be called to remove the listener.\r\n * @note Use [[onChanged]] to listen to changes for *all* gates.\r\n */\r\n public addMonitor(feature: string, monitor: (val: GateValue) => void): () => void {\r\n return this.onChanged.addListener((changed, val) => {\r\n if (changed === feature)\r\n monitor(val);\r\n });\r\n }\r\n}\r\n"]}