@itwin/presentation-common 4.5.0-dev.3 → 4.5.0-dev.30
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 +43 -1
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/Ruleset.schema.json +72 -19
- package/lib/cjs/assets/locales/en/Presentation.json +19 -19
- package/lib/cjs/presentation-common/AsyncTasks.d.ts.map +1 -1
- package/lib/cjs/presentation-common/AsyncTasks.js +6 -4
- package/lib/cjs/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/cjs/presentation-common/CommonLoggerCategory.js +3 -3
- package/lib/cjs/presentation-common/CommonLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-common/Diagnostics.d.ts.map +1 -1
- package/lib/cjs/presentation-common/Diagnostics.js +27 -15
- package/lib/cjs/presentation-common/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-common/EC.d.ts +7 -4
- package/lib/cjs/presentation-common/EC.d.ts.map +1 -1
- package/lib/cjs/presentation-common/EC.js +22 -17
- package/lib/cjs/presentation-common/EC.js.map +1 -1
- package/lib/cjs/presentation-common/ElementProperties.js +3 -3
- package/lib/cjs/presentation-common/ElementProperties.js.map +1 -1
- package/lib/cjs/presentation-common/Error.d.ts.map +1 -1
- package/lib/cjs/presentation-common/Error.js +5 -4
- package/lib/cjs/presentation-common/Error.js.map +1 -1
- package/lib/cjs/presentation-common/InstanceFilterDefinition.d.ts.map +1 -1
- package/lib/cjs/presentation-common/InstanceFilterDefinition.js +3 -3
- package/lib/cjs/presentation-common/InstanceFilterDefinition.js.map +1 -1
- package/lib/cjs/presentation-common/KeySet.d.ts.map +1 -1
- package/lib/cjs/presentation-common/KeySet.js +80 -46
- package/lib/cjs/presentation-common/KeySet.js.map +1 -1
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/cjs/presentation-common/LabelDefinition.d.ts.map +1 -1
- package/lib/cjs/presentation-common/LabelDefinition.js +5 -4
- package/lib/cjs/presentation-common/LabelDefinition.js.map +1 -1
- package/lib/cjs/presentation-common/LocalizationHelper.d.ts +1 -1
- package/lib/cjs/presentation-common/LocalizationHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationIpcInterface.js +3 -3
- package/lib/cjs/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.js +3 -3
- package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
- package/lib/cjs/presentation-common/PresentationRpcInterface.js +52 -20
- package/lib/cjs/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.d.ts.map +1 -1
- package/lib/cjs/presentation-common/RegisteredRuleset.js +21 -9
- package/lib/cjs/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/cjs/presentation-common/RpcRequestsHandler.d.ts +1 -1
- package/lib/cjs/presentation-common/RpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-common/RpcRequestsHandler.js +19 -15
- package/lib/cjs/presentation-common/RpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-common/RulesetVariables.d.ts.map +1 -1
- package/lib/cjs/presentation-common/RulesetVariables.js +7 -5
- package/lib/cjs/presentation-common/RulesetVariables.js.map +1 -1
- package/lib/cjs/presentation-common/RulesetsFactory.d.ts.map +1 -1
- package/lib/cjs/presentation-common/RulesetsFactory.js +42 -26
- package/lib/cjs/presentation-common/RulesetsFactory.js.map +1 -1
- package/lib/cjs/presentation-common/Update.d.ts.map +1 -1
- package/lib/cjs/presentation-common/Update.js +4 -3
- package/lib/cjs/presentation-common/Update.js.map +1 -1
- package/lib/cjs/presentation-common/Utils.js +3 -3
- package/lib/cjs/presentation-common/Utils.js.map +1 -1
- package/lib/cjs/presentation-common/content/Category.js +3 -3
- package/lib/cjs/presentation-common/content/Category.js.map +1 -1
- package/lib/cjs/presentation-common/content/Content.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Content.js +10 -9
- package/lib/cjs/presentation-common/content/Content.js.map +1 -1
- package/lib/cjs/presentation-common/content/ContentTraverser.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/ContentTraverser.js +47 -25
- package/lib/cjs/presentation-common/content/ContentTraverser.js.map +1 -1
- package/lib/cjs/presentation-common/content/Descriptor.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Descriptor.js +56 -21
- package/lib/cjs/presentation-common/content/Descriptor.js.map +1 -1
- package/lib/cjs/presentation-common/content/DisplayTypes.js +3 -3
- package/lib/cjs/presentation-common/content/DisplayTypes.js.map +1 -1
- package/lib/cjs/presentation-common/content/Editor.js +3 -3
- package/lib/cjs/presentation-common/content/Editor.js.map +1 -1
- package/lib/cjs/presentation-common/content/Fields.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Fields.js +47 -23
- package/lib/cjs/presentation-common/content/Fields.js.map +1 -1
- package/lib/cjs/presentation-common/content/Item.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Item.js +8 -6
- package/lib/cjs/presentation-common/content/Item.js.map +1 -1
- package/lib/cjs/presentation-common/content/Property.d.ts +1 -1
- package/lib/cjs/presentation-common/content/Property.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Property.js +4 -4
- package/lib/cjs/presentation-common/content/Property.js.map +1 -1
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.js +13 -11
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.js.map +1 -1
- package/lib/cjs/presentation-common/content/Renderer.js +3 -3
- package/lib/cjs/presentation-common/content/Renderer.js.map +1 -1
- package/lib/cjs/presentation-common/content/TypeDescription.js +3 -3
- package/lib/cjs/presentation-common/content/TypeDescription.js.map +1 -1
- package/lib/cjs/presentation-common/content/Value.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Value.js +46 -30
- package/lib/cjs/presentation-common/content/Value.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.js +3 -3
- package/lib/cjs/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Key.d.ts.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Key.js +14 -8
- package/lib/cjs/presentation-common/hierarchy/Key.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Node.d.ts.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/Node.js +7 -5
- package/lib/cjs/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/NodePathElement.d.ts.map +1 -1
- package/lib/cjs/presentation-common/hierarchy/NodePathElement.js +11 -7
- package/lib/cjs/presentation-common/hierarchy/NodePathElement.js.map +1 -1
- package/lib/cjs/presentation-common/rules/ClassSpecifications.js +3 -3
- package/lib/cjs/presentation-common/rules/ClassSpecifications.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.d.ts +39 -11
- package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/RelatedInstanceSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelationshipDirection.js +3 -3
- package/lib/cjs/presentation-common/rules/RelationshipDirection.js.map +1 -1
- package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/RelationshipPathSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Rule.js +3 -3
- package/lib/cjs/presentation-common/rules/Rule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Ruleset.js +3 -3
- package/lib/cjs/presentation-common/rules/Ruleset.js.map +1 -1
- package/lib/cjs/presentation-common/rules/SchemasSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/SchemasSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/Variables.js +3 -3
- package/lib/cjs/presentation-common/rules/Variables.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentRelatedInstancesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/ContentRelatedInstancesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentRule.js +3 -3
- package/lib/cjs/presentation-common/rules/content/ContentRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentSpecification.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/content/ContentSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/ContentSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/DefaultPropertyCategoryOverride.js +3 -3
- package/lib/cjs/presentation-common/rules/content/DefaultPropertyCategoryOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/PropertySpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/PropertySpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/SelectedNodeInstancesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/SelectedNodeInstancesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/CustomRendererSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/CustomRendererSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/CheckBoxRule.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/CheckBoxRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/CustomizationRule.d.ts +1 -5
- package/lib/cjs/presentation-common/rules/customization/CustomizationRule.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/CustomizationRule.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/CustomizationRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/ExtendedDataRule.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/ExtendedDataRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/GroupingRule.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/ImageIdOverride.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/ImageIdOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/InstanceLabelOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/LabelOverride.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/LabelOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/SortingRule.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/SortingRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/customization/StyleOverride.js +3 -3
- package/lib/cjs/presentation-common/rules/customization/StyleOverride.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
- package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.js +3 -3
- package/lib/cjs/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
- package/lib/cjs/presentation-common/selection/SelectionScope.js +3 -3
- package/lib/cjs/presentation-common/selection/SelectionScope.js.map +1 -1
- package/lib/cjs/presentation-common.js +3 -3
- package/lib/cjs/presentation-common.js.map +1 -1
- package/lib/esm/presentation-common/AsyncTasks.d.ts.map +1 -1
- package/lib/esm/presentation-common/AsyncTasks.js +6 -4
- package/lib/esm/presentation-common/AsyncTasks.js.map +1 -1
- package/lib/esm/presentation-common/CommonLoggerCategory.js +3 -3
- package/lib/esm/presentation-common/CommonLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-common/Diagnostics.d.ts.map +1 -1
- package/lib/esm/presentation-common/Diagnostics.js +27 -15
- package/lib/esm/presentation-common/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-common/EC.d.ts +7 -4
- package/lib/esm/presentation-common/EC.d.ts.map +1 -1
- package/lib/esm/presentation-common/EC.js +22 -17
- package/lib/esm/presentation-common/EC.js.map +1 -1
- package/lib/esm/presentation-common/ElementProperties.js +3 -3
- package/lib/esm/presentation-common/ElementProperties.js.map +1 -1
- package/lib/esm/presentation-common/Error.d.ts.map +1 -1
- package/lib/esm/presentation-common/Error.js +5 -4
- package/lib/esm/presentation-common/Error.js.map +1 -1
- package/lib/esm/presentation-common/InstanceFilterDefinition.d.ts.map +1 -1
- package/lib/esm/presentation-common/InstanceFilterDefinition.js +3 -3
- package/lib/esm/presentation-common/InstanceFilterDefinition.js.map +1 -1
- package/lib/esm/presentation-common/KeySet.d.ts.map +1 -1
- package/lib/esm/presentation-common/KeySet.js +80 -46
- package/lib/esm/presentation-common/KeySet.js.map +1 -1
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -1
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -1
- package/lib/esm/presentation-common/LabelDefinition.d.ts.map +1 -1
- package/lib/esm/presentation-common/LabelDefinition.js +5 -4
- package/lib/esm/presentation-common/LabelDefinition.js.map +1 -1
- package/lib/esm/presentation-common/LocalizationHelper.d.ts +1 -1
- package/lib/esm/presentation-common/LocalizationHelper.d.ts.map +1 -1
- package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-common/PresentationIpcInterface.js +3 -3
- package/lib/esm/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.js +3 -3
- package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/esm/presentation-common/PresentationRpcInterface.d.ts.map +1 -1
- package/lib/esm/presentation-common/PresentationRpcInterface.js +52 -20
- package/lib/esm/presentation-common/PresentationRpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.d.ts.map +1 -1
- package/lib/esm/presentation-common/RegisteredRuleset.js +21 -9
- package/lib/esm/presentation-common/RegisteredRuleset.js.map +1 -1
- package/lib/esm/presentation-common/RpcRequestsHandler.d.ts +1 -1
- package/lib/esm/presentation-common/RpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-common/RpcRequestsHandler.js +20 -16
- package/lib/esm/presentation-common/RpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-common/RulesetVariables.d.ts.map +1 -1
- package/lib/esm/presentation-common/RulesetVariables.js +7 -5
- package/lib/esm/presentation-common/RulesetVariables.js.map +1 -1
- package/lib/esm/presentation-common/RulesetsFactory.d.ts.map +1 -1
- package/lib/esm/presentation-common/RulesetsFactory.js +42 -26
- package/lib/esm/presentation-common/RulesetsFactory.js.map +1 -1
- package/lib/esm/presentation-common/Update.d.ts.map +1 -1
- package/lib/esm/presentation-common/Update.js +4 -3
- package/lib/esm/presentation-common/Update.js.map +1 -1
- package/lib/esm/presentation-common/Utils.js +3 -3
- package/lib/esm/presentation-common/Utils.js.map +1 -1
- package/lib/esm/presentation-common/content/Category.js +3 -3
- package/lib/esm/presentation-common/content/Category.js.map +1 -1
- package/lib/esm/presentation-common/content/Content.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Content.js +10 -9
- package/lib/esm/presentation-common/content/Content.js.map +1 -1
- package/lib/esm/presentation-common/content/ContentTraverser.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/ContentTraverser.js +47 -25
- package/lib/esm/presentation-common/content/ContentTraverser.js.map +1 -1
- package/lib/esm/presentation-common/content/Descriptor.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Descriptor.js +56 -21
- package/lib/esm/presentation-common/content/Descriptor.js.map +1 -1
- package/lib/esm/presentation-common/content/DisplayTypes.js +3 -3
- package/lib/esm/presentation-common/content/DisplayTypes.js.map +1 -1
- package/lib/esm/presentation-common/content/Editor.js +3 -3
- package/lib/esm/presentation-common/content/Editor.js.map +1 -1
- package/lib/esm/presentation-common/content/Fields.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Fields.js +47 -23
- package/lib/esm/presentation-common/content/Fields.js.map +1 -1
- package/lib/esm/presentation-common/content/Item.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Item.js +8 -6
- package/lib/esm/presentation-common/content/Item.js.map +1 -1
- package/lib/esm/presentation-common/content/Property.d.ts +1 -1
- package/lib/esm/presentation-common/content/Property.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Property.js +4 -4
- package/lib/esm/presentation-common/content/Property.js.map +1 -1
- package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/PropertyValueFormatter.js +13 -11
- package/lib/esm/presentation-common/content/PropertyValueFormatter.js.map +1 -1
- package/lib/esm/presentation-common/content/Renderer.js +3 -3
- package/lib/esm/presentation-common/content/Renderer.js.map +1 -1
- package/lib/esm/presentation-common/content/TypeDescription.js +3 -3
- package/lib/esm/presentation-common/content/TypeDescription.js.map +1 -1
- package/lib/esm/presentation-common/content/Value.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Value.js +46 -30
- package/lib/esm/presentation-common/content/Value.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/HierarchyLevel.js +3 -3
- package/lib/esm/presentation-common/hierarchy/HierarchyLevel.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Key.d.ts.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Key.js +14 -8
- package/lib/esm/presentation-common/hierarchy/Key.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Node.d.ts.map +1 -1
- package/lib/esm/presentation-common/hierarchy/Node.js +7 -5
- package/lib/esm/presentation-common/hierarchy/Node.js.map +1 -1
- package/lib/esm/presentation-common/hierarchy/NodePathElement.d.ts.map +1 -1
- package/lib/esm/presentation-common/hierarchy/NodePathElement.js +11 -7
- package/lib/esm/presentation-common/hierarchy/NodePathElement.js.map +1 -1
- package/lib/esm/presentation-common/rules/ClassSpecifications.js +3 -3
- package/lib/esm/presentation-common/rules/ClassSpecifications.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.d.ts +39 -11
- package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/RelatedInstanceSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelationshipDirection.js +3 -3
- package/lib/esm/presentation-common/rules/RelationshipDirection.js.map +1 -1
- package/lib/esm/presentation-common/rules/RelationshipPathSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/RelationshipPathSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/Rule.js +3 -3
- package/lib/esm/presentation-common/rules/Rule.js.map +1 -1
- package/lib/esm/presentation-common/rules/Ruleset.js +3 -3
- package/lib/esm/presentation-common/rules/Ruleset.js.map +1 -1
- package/lib/esm/presentation-common/rules/SchemasSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/SchemasSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/Variables.js +3 -3
- package/lib/esm/presentation-common/rules/Variables.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentRelatedInstancesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/ContentRelatedInstancesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentRule.js +3 -3
- package/lib/esm/presentation-common/rules/content/ContentRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentSpecification.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/content/ContentSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/ContentSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/DefaultPropertyCategoryOverride.js +3 -3
- package/lib/esm/presentation-common/rules/content/DefaultPropertyCategoryOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/PropertySpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/PropertySpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/SelectedNodeInstancesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/SelectedNodeInstancesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/CustomRendererSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/CustomRendererSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyCategorySpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/PropertyEditorsSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/content/modifiers/RelatedPropertiesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/CheckBoxRule.js +3 -3
- package/lib/esm/presentation-common/rules/customization/CheckBoxRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/CustomizationRule.d.ts +1 -5
- package/lib/esm/presentation-common/rules/customization/CustomizationRule.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/customization/CustomizationRule.js +3 -3
- package/lib/esm/presentation-common/rules/customization/CustomizationRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/ExtendedDataRule.js +3 -3
- package/lib/esm/presentation-common/rules/customization/ExtendedDataRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/GroupingRule.js +3 -3
- package/lib/esm/presentation-common/rules/customization/GroupingRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/ImageIdOverride.js +3 -3
- package/lib/esm/presentation-common/rules/customization/ImageIdOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.js +3 -3
- package/lib/esm/presentation-common/rules/customization/InstanceLabelOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/LabelOverride.js +3 -3
- package/lib/esm/presentation-common/rules/customization/LabelOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/SortingRule.js +3 -3
- package/lib/esm/presentation-common/rules/customization/SortingRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/customization/StyleOverride.js +3 -3
- package/lib/esm/presentation-common/rules/customization/StyleOverride.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/ChildNodeSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/CustomNodeSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/NavigationRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/NodeArtifactsRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/RootNodeRule.js.map +1 -1
- package/lib/esm/presentation-common/rules/hierarchy/SubCondition.js +3 -3
- package/lib/esm/presentation-common/rules/hierarchy/SubCondition.js.map +1 -1
- package/lib/esm/presentation-common/selection/SelectionScope.js +3 -3
- package/lib/esm/presentation-common/selection/SelectionScope.js.map +1 -1
- package/lib/esm/presentation-common.js +3 -3
- package/lib/esm/presentation-common.js.map +1 -1
- package/lib/public/locales/en/Presentation.json +19 -19
- package/package.json +14 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
@@ -12,6 +12,7 @@ const core_bentley_1 = require("@itwin/core-bentley");
|
|
|
12
12
|
const Error_1 = require("./Error");
|
|
13
13
|
const Key_1 = require("./hierarchy/Key");
|
|
14
14
|
/** @public */
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
15
16
|
var Key;
|
|
16
17
|
(function (Key) {
|
|
17
18
|
/** Check if the supplied key is a `NodeKey` */
|
|
@@ -46,8 +47,9 @@ class KeySet {
|
|
|
46
47
|
this._lowerCaseMap = new Map();
|
|
47
48
|
this._nodeKeys = new Set();
|
|
48
49
|
this.recalculateGuid();
|
|
49
|
-
if (source)
|
|
50
|
+
if (source) {
|
|
50
51
|
this.add(source);
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
recalculateGuid() {
|
|
53
55
|
// empty keyset should have empty guid, otherwise use a random guid value
|
|
@@ -58,7 +60,9 @@ class KeySet {
|
|
|
58
60
|
* does not uniquely identify contents of the keyset, but it can be
|
|
59
61
|
* used to check whether keyset has changed.
|
|
60
62
|
*/
|
|
61
|
-
get guid() {
|
|
63
|
+
get guid() {
|
|
64
|
+
return this._guid;
|
|
65
|
+
}
|
|
62
66
|
/**
|
|
63
67
|
* Get a map of instance keys stored in this KeySet
|
|
64
68
|
*
|
|
@@ -67,8 +71,9 @@ class KeySet {
|
|
|
67
71
|
*/
|
|
68
72
|
get instanceKeys() {
|
|
69
73
|
const map = new Map();
|
|
70
|
-
for (const entry of this._instanceKeys)
|
|
74
|
+
for (const entry of this._instanceKeys) {
|
|
71
75
|
map.set(this._lowerCaseMap.get(entry["0"]), new Set([...entry["1"]].map((key) => core_bentley_1.Id64.fromJSON(key))));
|
|
76
|
+
}
|
|
72
77
|
return map;
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
@@ -76,7 +81,7 @@ class KeySet {
|
|
|
76
81
|
*/
|
|
77
82
|
get instanceKeysCount() {
|
|
78
83
|
let count = 0;
|
|
79
|
-
this._instanceKeys.forEach((set) => count += set.size);
|
|
84
|
+
this._instanceKeys.forEach((set) => (count += set.size));
|
|
80
85
|
return count;
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
@@ -111,8 +116,9 @@ class KeySet {
|
|
|
111
116
|
* @returns itself
|
|
112
117
|
*/
|
|
113
118
|
clear() {
|
|
114
|
-
if (this.isEmpty)
|
|
119
|
+
if (this.isEmpty) {
|
|
115
120
|
return this;
|
|
121
|
+
}
|
|
116
122
|
this._instanceKeys = new Map();
|
|
117
123
|
this._lowerCaseMap = new Map();
|
|
118
124
|
this._nodeKeys = new Set();
|
|
@@ -122,8 +128,9 @@ class KeySet {
|
|
|
122
128
|
addKeySet(keyset, pred) {
|
|
123
129
|
for (const key of keyset._nodeKeys) {
|
|
124
130
|
// eslint-disable-next-line deprecation/deprecation
|
|
125
|
-
if (!pred || pred(Key_1.NodeKey.fromJSON(JSON.parse(key))))
|
|
131
|
+
if (!pred || pred(Key_1.NodeKey.fromJSON(JSON.parse(key)))) {
|
|
126
132
|
this._nodeKeys.add(key);
|
|
133
|
+
}
|
|
127
134
|
}
|
|
128
135
|
for (const entry of keyset._instanceKeys) {
|
|
129
136
|
let set = this._instanceKeys.get(entry["0"]);
|
|
@@ -134,22 +141,20 @@ class KeySet {
|
|
|
134
141
|
this._lowerCaseMap.set(entry["0"], className);
|
|
135
142
|
}
|
|
136
143
|
entry["1"].forEach((id) => {
|
|
137
|
-
if (!pred || pred({ className, id }))
|
|
144
|
+
if (!pred || pred({ className, id })) {
|
|
138
145
|
set.add(id);
|
|
146
|
+
}
|
|
139
147
|
});
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
addKeySetJSON(keyset) {
|
|
143
|
-
for (const key of keyset.nodeKeys)
|
|
151
|
+
for (const key of keyset.nodeKeys) {
|
|
144
152
|
this._nodeKeys.add(JSON.stringify(key));
|
|
153
|
+
}
|
|
145
154
|
for (const entry of keyset.instanceKeys) {
|
|
146
155
|
const lcClassName = entry["0"].toLowerCase();
|
|
147
156
|
const idsJson = entry["1"];
|
|
148
|
-
const ids = typeof idsJson === "string"
|
|
149
|
-
? idsJson === core_bentley_1.Id64.invalid
|
|
150
|
-
? new Set([core_bentley_1.Id64.invalid])
|
|
151
|
-
: core_bentley_1.CompressedId64Set.decompressSet(idsJson)
|
|
152
|
-
: new Set(idsJson);
|
|
157
|
+
const ids = typeof idsJson === "string" ? (idsJson === core_bentley_1.Id64.invalid ? new Set([core_bentley_1.Id64.invalid]) : core_bentley_1.CompressedId64Set.decompressSet(idsJson)) : new Set(idsJson);
|
|
153
158
|
this._instanceKeys.set(lcClassName, ids);
|
|
154
159
|
this._lowerCaseMap.set(lcClassName, entry["0"]);
|
|
155
160
|
}
|
|
@@ -161,8 +166,9 @@ class KeySet {
|
|
|
161
166
|
* @returns itself
|
|
162
167
|
*/
|
|
163
168
|
add(value, pred) {
|
|
164
|
-
if (!value)
|
|
169
|
+
if (!value) {
|
|
165
170
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
171
|
+
}
|
|
166
172
|
const sizeBefore = this.size;
|
|
167
173
|
if (this.isKeySet(value)) {
|
|
168
174
|
this.addKeySet(value, pred);
|
|
@@ -190,13 +196,15 @@ class KeySet {
|
|
|
190
196
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
|
-
if (this.size !== sizeBefore)
|
|
199
|
+
if (this.size !== sizeBefore) {
|
|
194
200
|
this.recalculateGuid();
|
|
201
|
+
}
|
|
195
202
|
return this;
|
|
196
203
|
}
|
|
197
204
|
deleteKeySet(keyset) {
|
|
198
|
-
for (const key of keyset._nodeKeys)
|
|
205
|
+
for (const key of keyset._nodeKeys) {
|
|
199
206
|
this._nodeKeys.delete(key);
|
|
207
|
+
}
|
|
200
208
|
for (const entry of keyset._instanceKeys) {
|
|
201
209
|
const set = this._instanceKeys.get(entry["0"].toLowerCase());
|
|
202
210
|
if (set) {
|
|
@@ -212,23 +220,26 @@ class KeySet {
|
|
|
212
220
|
* @returns itself
|
|
213
221
|
*/
|
|
214
222
|
delete(value) {
|
|
215
|
-
if (!value)
|
|
223
|
+
if (!value) {
|
|
216
224
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
225
|
+
}
|
|
217
226
|
const sizeBefore = this.size;
|
|
218
227
|
if (this.isKeySet(value)) {
|
|
219
228
|
this.deleteKeySet(value);
|
|
220
229
|
}
|
|
221
230
|
else if (this.isKeysArray(value)) {
|
|
222
|
-
for (const key of value)
|
|
231
|
+
for (const key of value) {
|
|
223
232
|
this.delete(key);
|
|
233
|
+
}
|
|
224
234
|
}
|
|
225
235
|
else if (Key.isEntityProps(value)) {
|
|
226
236
|
this.delete({ className: value.classFullName, id: value.id });
|
|
227
237
|
}
|
|
228
238
|
else if (Key.isInstanceKey(value)) {
|
|
229
239
|
const set = this._instanceKeys.get(value.className.toLowerCase());
|
|
230
|
-
if (set)
|
|
240
|
+
if (set) {
|
|
231
241
|
set.delete(value.id);
|
|
242
|
+
}
|
|
232
243
|
}
|
|
233
244
|
else if (Key.isNodeKey(value)) {
|
|
234
245
|
this._nodeKeys.delete(JSON.stringify(value));
|
|
@@ -236,8 +247,9 @@ class KeySet {
|
|
|
236
247
|
else {
|
|
237
248
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
238
249
|
}
|
|
239
|
-
if (this.size !== sizeBefore)
|
|
250
|
+
if (this.size !== sizeBefore) {
|
|
240
251
|
this.recalculateGuid();
|
|
252
|
+
}
|
|
241
253
|
return this;
|
|
242
254
|
}
|
|
243
255
|
/**
|
|
@@ -245,59 +257,71 @@ class KeySet {
|
|
|
245
257
|
* @param value The key to check.
|
|
246
258
|
*/
|
|
247
259
|
has(value) {
|
|
248
|
-
if (!value)
|
|
260
|
+
if (!value) {
|
|
249
261
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
250
|
-
|
|
262
|
+
}
|
|
263
|
+
if (Key.isEntityProps(value)) {
|
|
251
264
|
return this.has({ className: value.classFullName, id: value.id });
|
|
265
|
+
}
|
|
252
266
|
if (Key.isInstanceKey(value)) {
|
|
253
267
|
const set = this._instanceKeys.get(value.className.toLowerCase());
|
|
254
268
|
return !!(set && set.has(value.id));
|
|
255
269
|
}
|
|
256
|
-
if (Key.isNodeKey(value))
|
|
270
|
+
if (Key.isNodeKey(value)) {
|
|
257
271
|
return this._nodeKeys.has(JSON.stringify(value));
|
|
272
|
+
}
|
|
258
273
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);
|
|
259
274
|
}
|
|
260
275
|
hasKeySet(readonlyKeys, checkType) {
|
|
261
276
|
// note: cast-away read-onlyness to access private members...
|
|
262
277
|
const keys = readonlyKeys;
|
|
263
278
|
if (checkType === "all") {
|
|
264
|
-
if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size)
|
|
279
|
+
if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size) {
|
|
265
280
|
return false;
|
|
266
|
-
|
|
281
|
+
}
|
|
282
|
+
if ([...keys._nodeKeys].some((key) => !this._nodeKeys.has(key))) {
|
|
267
283
|
return false;
|
|
284
|
+
}
|
|
268
285
|
for (const otherEntry of keys._instanceKeys) {
|
|
269
286
|
const thisEntryKeys = this._instanceKeys.get(otherEntry["0"].toLowerCase());
|
|
270
|
-
if (!thisEntryKeys || thisEntryKeys.size < otherEntry["1"].size)
|
|
287
|
+
if (!thisEntryKeys || thisEntryKeys.size < otherEntry["1"].size) {
|
|
271
288
|
return false;
|
|
272
|
-
|
|
289
|
+
}
|
|
290
|
+
if ([...otherEntry["1"]].some((key) => !thisEntryKeys.has(key))) {
|
|
273
291
|
return false;
|
|
292
|
+
}
|
|
274
293
|
}
|
|
275
294
|
return true;
|
|
276
295
|
}
|
|
277
296
|
// "any" check type
|
|
278
|
-
if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key)))
|
|
297
|
+
if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key))) {
|
|
279
298
|
return true;
|
|
299
|
+
}
|
|
280
300
|
for (const otherEntry of keys._instanceKeys) {
|
|
281
301
|
const thisEntryKeys = this._instanceKeys.get(otherEntry["0"].toLowerCase());
|
|
282
|
-
if (thisEntryKeys && [...otherEntry["1"]].some((key) => thisEntryKeys.has(key)))
|
|
302
|
+
if (thisEntryKeys && [...otherEntry["1"]].some((key) => thisEntryKeys.has(key))) {
|
|
283
303
|
return true;
|
|
304
|
+
}
|
|
284
305
|
}
|
|
285
306
|
return false;
|
|
286
307
|
}
|
|
287
308
|
hasKeysArray(keys, checkType) {
|
|
288
309
|
if (checkType === "all") {
|
|
289
|
-
if (this.size < keys.length)
|
|
310
|
+
if (this.size < keys.length) {
|
|
290
311
|
return false;
|
|
312
|
+
}
|
|
291
313
|
for (const key of keys) {
|
|
292
|
-
if (!this.has(key))
|
|
314
|
+
if (!this.has(key)) {
|
|
293
315
|
return false;
|
|
316
|
+
}
|
|
294
317
|
}
|
|
295
318
|
return true;
|
|
296
319
|
}
|
|
297
320
|
// "any" check type
|
|
298
321
|
for (const key of keys) {
|
|
299
|
-
if (this.has(key))
|
|
322
|
+
if (this.has(key)) {
|
|
300
323
|
return true;
|
|
324
|
+
}
|
|
301
325
|
}
|
|
302
326
|
return false;
|
|
303
327
|
}
|
|
@@ -306,12 +330,15 @@ class KeySet {
|
|
|
306
330
|
* @param keys The keys to check.
|
|
307
331
|
*/
|
|
308
332
|
hasAll(keys) {
|
|
309
|
-
if (!keys)
|
|
333
|
+
if (!keys) {
|
|
310
334
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);
|
|
311
|
-
|
|
335
|
+
}
|
|
336
|
+
if (this.isKeySet(keys)) {
|
|
312
337
|
return this.hasKeySet(keys, "all");
|
|
313
|
-
|
|
338
|
+
}
|
|
339
|
+
if (this.isKeysArray(keys)) {
|
|
314
340
|
return this.hasKeysArray(keys, "all");
|
|
341
|
+
}
|
|
315
342
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);
|
|
316
343
|
}
|
|
317
344
|
/**
|
|
@@ -319,12 +346,15 @@ class KeySet {
|
|
|
319
346
|
* @param keys The keys to check.
|
|
320
347
|
*/
|
|
321
348
|
hasAny(keys) {
|
|
322
|
-
if (!keys)
|
|
349
|
+
if (!keys) {
|
|
323
350
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);
|
|
324
|
-
|
|
351
|
+
}
|
|
352
|
+
if (this.isKeySet(keys)) {
|
|
325
353
|
return this.hasKeySet(keys, "any");
|
|
326
|
-
|
|
354
|
+
}
|
|
355
|
+
if (this.isKeysArray(keys)) {
|
|
327
356
|
return this.hasKeysArray(keys, "any");
|
|
357
|
+
}
|
|
328
358
|
throw new Error_1.PresentationError(Error_1.PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);
|
|
329
359
|
}
|
|
330
360
|
/**
|
|
@@ -333,8 +363,9 @@ class KeySet {
|
|
|
333
363
|
get size() {
|
|
334
364
|
const nodeKeysCount = this._nodeKeys.size;
|
|
335
365
|
let instanceIdsCount = 0;
|
|
336
|
-
for (const set of this._instanceKeys.values())
|
|
366
|
+
for (const set of this._instanceKeys.values()) {
|
|
337
367
|
instanceIdsCount += set.size;
|
|
368
|
+
}
|
|
338
369
|
return nodeKeysCount + instanceIdsCount;
|
|
339
370
|
}
|
|
340
371
|
/**
|
|
@@ -347,8 +378,9 @@ class KeySet {
|
|
|
347
378
|
some(callback) {
|
|
348
379
|
for (const entry of this._instanceKeys) {
|
|
349
380
|
const className = this._lowerCaseMap.get(entry["0"].toLowerCase());
|
|
350
|
-
if (some(entry[1], (id) => callback({ className, id })))
|
|
381
|
+
if (some(entry[1], (id) => callback({ className, id }))) {
|
|
351
382
|
return true;
|
|
383
|
+
}
|
|
352
384
|
}
|
|
353
385
|
// eslint-disable-next-line deprecation/deprecation
|
|
354
386
|
return some(this._nodeKeys, (serializedKey) => callback(Key_1.NodeKey.fromJSON(JSON.parse(serializedKey))));
|
|
@@ -379,7 +411,7 @@ class KeySet {
|
|
|
379
411
|
this.forEach((key, index) => {
|
|
380
412
|
batch.add(key);
|
|
381
413
|
++currBatchSize;
|
|
382
|
-
if (currBatchSize === batchSize || index ===
|
|
414
|
+
if (currBatchSize === batchSize || index === size - 1) {
|
|
383
415
|
callback(batch, batchIndex++);
|
|
384
416
|
batch = new KeySet();
|
|
385
417
|
currBatchSize = 0;
|
|
@@ -401,8 +433,9 @@ class KeySet {
|
|
|
401
433
|
}
|
|
402
434
|
// eslint-disable-next-line deprecation/deprecation
|
|
403
435
|
const nodeKeys = [];
|
|
404
|
-
for (const serializedKey of this._nodeKeys.values())
|
|
436
|
+
for (const serializedKey of this._nodeKeys.values()) {
|
|
405
437
|
nodeKeys.push(JSON.parse(serializedKey));
|
|
438
|
+
}
|
|
406
439
|
return {
|
|
407
440
|
instanceKeys,
|
|
408
441
|
nodeKeys,
|
|
@@ -421,8 +454,9 @@ class KeySet {
|
|
|
421
454
|
exports.KeySet = KeySet;
|
|
422
455
|
const some = (set, cb) => {
|
|
423
456
|
for (const item of set) {
|
|
424
|
-
if (cb(item))
|
|
457
|
+
if (cb(item)) {
|
|
425
458
|
return true;
|
|
459
|
+
}
|
|
426
460
|
}
|
|
427
461
|
return false;
|
|
428
462
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeySet.js","sourceRoot":"","sources":["../../../src/presentation-common/KeySet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4F;AAG5F,mCAAgE;AAChE,yCAAuD;AAQvD,cAAc;AACd,IAAiB,GAAG,CAenB;AAfD,WAAiB,GAAG;IAClB,+CAA+C;IAC/C,SAAgB,SAAS,CAAC,GAAQ;QAChC,OAAO,CAAC,CAAE,GAAe,CAAC,IAAI,CAAC;IACjC,CAAC;IAFe,aAAS,YAExB,CAAA;IAED,oDAAoD;IACpD,SAAgB,aAAa,CAAC,GAAQ;QACpC,OAAO,CAAC,CAAE,GAAmB,CAAC,SAAS,IAAI,CAAC,CAAE,GAAmB,CAAC,EAAE,CAAC;IACvE,CAAC;IAFe,iBAAa,gBAE5B,CAAA;IAED,oDAAoD;IACpD,SAAgB,aAAa,CAAC,GAAQ;QACpC,OAAO,CAAC,CAAE,GAAmB,CAAC,aAAa,IAAI,CAAC,CAAE,GAAmB,CAAC,EAAE,CAAC;IAC3E,CAAC;IAFe,iBAAa,gBAE5B,CAAA;AACH,CAAC,EAfgB,GAAG,GAAH,WAAG,KAAH,WAAG,QAenB;AAoBD;;;;;GAKG;AACH,MAAa,MAAM;IAOjB;;;OAGG;IACH,YAAY,MAAa;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;QAC/B,IAAI,CAAC,S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,EAAE;QACtB,IAAI,EAAE,CAAC,IAAI,CAAC;YACV,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC,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 Core\r\n */\r\n\r\nimport { CompressedId64Set, Guid, GuidString, Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { EntityProps } from \"@itwin/core-common\";\r\nimport { InstanceId, InstanceKey } from \"./EC\";\r\nimport { PresentationError, PresentationStatus } from \"./Error\";\r\nimport { NodeKey, NodeKeyJSON } from \"./hierarchy/Key\";\r\n\r\n/**\r\n * A single key that identifies something in an iTwin.js application\r\n * @public\r\n */\r\nexport type Key = Readonly<NodeKey> | Readonly<InstanceKey> | Readonly<EntityProps>;\r\n\r\n/** @public */\r\nexport namespace Key { // eslint-disable-line @typescript-eslint/no-redeclare\r\n /** Check if the supplied key is a `NodeKey` */\r\n export function isNodeKey(key: Key): key is NodeKey {\r\n return !!(key as NodeKey).type;\r\n }\r\n\r\n /** Check if the supplied key is an `InstanceKey` */\r\n export function isInstanceKey(key: Key): key is InstanceKey {\r\n return !!(key as InstanceKey).className && !!(key as InstanceKey).id;\r\n }\r\n\r\n /** Check if the supplied key is an `EntityProps` */\r\n export function isEntityProps(key: Key): key is EntityProps {\r\n return !!(key as EntityProps).classFullName && !!(key as EntityProps).id;\r\n }\r\n}\r\n\r\n/**\r\n * A type for multiple keys that identify something in iModel.js application\r\n * @public\r\n */\r\nexport type Keys = ReadonlyArray<Key> | Readonly<KeySet>;\r\n\r\n/**\r\n * A data structure of serialized [[KeySet]]\r\n * @public\r\n */\r\nexport interface KeySetJSON {\r\n /** JSON representation of a list of instance keys */\r\n instanceKeys: Array<[string, string]>;\r\n /** An array of serialized node keys */\r\n // eslint-disable-next-line deprecation/deprecation\r\n nodeKeys: NodeKeyJSON[];\r\n}\r\n\r\n/**\r\n * A class that holds multiple [[Key]] objects. It's basically\r\n * used as a container that holds multiple keys of different types.\r\n *\r\n * @public\r\n */\r\nexport class KeySet {\r\n // note: all keys are stored as strings because we need ability to find them by value\r\n private _instanceKeys: Map<string, Set<string>>; // lower case class name => instance ids\r\n private _lowerCaseMap: Map<string, string>; // lower case class name => most recent class name\r\n private _nodeKeys: Set<string>;\r\n private _guid!: GuidString;\r\n\r\n /**\r\n * Creates an instance of KeySet.\r\n * @param source Optional source to initialize from.\r\n */\r\n constructor(source?: Keys) {\r\n this._instanceKeys = new Map();\r\n this._lowerCaseMap = new Map();\r\n this._nodeKeys = new Set();\r\n this.recalculateGuid();\r\n if (source)\r\n this.add(source);\r\n }\r\n\r\n private recalculateGuid() {\r\n // empty keyset should have empty guid, otherwise use a random guid value\r\n this._guid = this.isEmpty ? Guid.empty : Guid.createValue();\r\n }\r\n\r\n /**\r\n * Get a GUID that identifies changes in this keyset. The value\r\n * does not uniquely identify contents of the keyset, but it can be\r\n * used to check whether keyset has changed.\r\n */\r\n public get guid(): GuidString { return this._guid; }\r\n\r\n /**\r\n * Get a map of instance keys stored in this KeySet\r\n *\r\n * **Warning**: getting instance keys might be expensive for\r\n * large KeySets.\r\n */\r\n public get instanceKeys(): Map<string, Set<InstanceId>> {\r\n const map = new Map<string, Set<InstanceId>>();\r\n for (const entry of this._instanceKeys)\r\n map.set(this._lowerCaseMap.get(entry[\"0\"])!, new Set([...entry[\"1\"]].map((key: string) => Id64.fromJSON(key))));\r\n return map;\r\n }\r\n\r\n /**\r\n * Get instance keys count\r\n */\r\n public get instanceKeysCount(): number {\r\n let count = 0;\r\n this._instanceKeys.forEach((set: Set<string>) => count += set.size);\r\n return count;\r\n }\r\n\r\n /**\r\n * Get a set of node keys stored in this KeySet\r\n *\r\n * **Warning**: getting node keys might be expensive for\r\n * large KeySets.\r\n */\r\n public get nodeKeys(): Set<NodeKey> {\r\n const set = new Set<NodeKey>();\r\n for (const serialized of this._nodeKeys) {\r\n // eslint-disable-next-line deprecation/deprecation\r\n const key = NodeKey.fromJSON(JSON.parse(serialized));\r\n set.add(key);\r\n }\r\n return set;\r\n }\r\n\r\n /**\r\n * Get node keys count\r\n */\r\n public get nodeKeysCount(): number {\r\n return this._nodeKeys.size;\r\n }\r\n\r\n private isKeySet(set: Keys | Key): set is Readonly<KeySet> {\r\n return !!(set as KeySet)._nodeKeys && !!(set as KeySet)._instanceKeys;\r\n }\r\n\r\n private isKeysArray(keys: Keys | Key): keys is ReadonlyArray<Key> {\r\n return Array.isArray(keys);\r\n }\r\n\r\n /**\r\n * Clear this KeySet.\r\n * @returns itself\r\n */\r\n public clear(): KeySet {\r\n if (this.isEmpty)\r\n return this;\r\n\r\n this._instanceKeys = new Map();\r\n this._lowerCaseMap = new Map();\r\n this._nodeKeys = new Set();\r\n this.recalculateGuid();\r\n return this;\r\n }\r\n\r\n private addKeySet(keyset: Readonly<KeySet>, pred?: (key: Key) => boolean): void {\r\n for (const key of (keyset as any)._nodeKeys) {\r\n // eslint-disable-next-line deprecation/deprecation\r\n if (!pred || pred(NodeKey.fromJSON(JSON.parse(key))))\r\n this._nodeKeys.add(key);\r\n }\r\n for (const entry of (keyset as any)._instanceKeys) {\r\n let set = this._instanceKeys.get(entry[\"0\"]);\r\n const className = (keyset as KeySet)._lowerCaseMap.get(entry[\"0\"])!;\r\n if (!set) {\r\n set = new Set();\r\n this._instanceKeys.set(entry[\"0\"], set);\r\n this._lowerCaseMap.set(entry[\"0\"], className);\r\n }\r\n entry[\"1\"].forEach((id: Id64String) => {\r\n if (!pred || pred({ className, id }))\r\n set!.add(id);\r\n });\r\n }\r\n }\r\n\r\n private addKeySetJSON(keyset: Readonly<KeySetJSON>): void {\r\n for (const key of keyset.nodeKeys)\r\n this._nodeKeys.add(JSON.stringify(key));\r\n for (const entry of keyset.instanceKeys) {\r\n const lcClassName = entry[\"0\"].toLowerCase();\r\n const idsJson: string | Id64String[] = entry[\"1\"];\r\n const ids: Set<Id64String> =\r\n typeof idsJson === \"string\"\r\n ? idsJson === Id64.invalid\r\n ? new Set([Id64.invalid])\r\n : CompressedId64Set.decompressSet(idsJson)\r\n : new Set(idsJson);\r\n this._instanceKeys.set(lcClassName, ids);\r\n this._lowerCaseMap.set(lcClassName, entry[\"0\"]);\r\n }\r\n }\r\n\r\n /**\r\n * Add a key or keys to this KeySet.\r\n * @param value A key or keys to add.\r\n * @param pred An optional predicate function that indicates whether a key should be added\r\n * @returns itself\r\n */\r\n public add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet {\r\n if (!value)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n const sizeBefore = this.size;\r\n if (this.isKeySet(value)) {\r\n this.addKeySet(value, pred);\r\n } else if (this.isKeysArray(value)) {\r\n value.forEach((key) => this.add(key, pred));\r\n } else if (!pred || pred(value)) {\r\n if (Key.isEntityProps(value)) {\r\n this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);\r\n } else if (Key.isInstanceKey(value)) {\r\n const lcClassName = value.className.toLowerCase();\r\n if (!this._instanceKeys.has(lcClassName)) {\r\n this._instanceKeys.set(lcClassName, new Set());\r\n this._lowerCaseMap.set(lcClassName, value.className);\r\n }\r\n this._lowerCaseMap.set(lcClassName, value.className);\r\n this._instanceKeys.get(lcClassName)!.add(value.id);\r\n } else if (Key.isNodeKey(value)) {\r\n this._nodeKeys.add(JSON.stringify(value));\r\n } else {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n }\r\n }\r\n if (this.size !== sizeBefore)\r\n this.recalculateGuid();\r\n return this;\r\n }\r\n\r\n private deleteKeySet(keyset: Readonly<KeySet>): void {\r\n for (const key of (keyset as any)._nodeKeys)\r\n this._nodeKeys.delete(key);\r\n for (const entry of (keyset as any)._instanceKeys) {\r\n const set = this._instanceKeys.get(entry[\"0\"].toLowerCase());\r\n if (set) {\r\n entry[\"1\"].forEach((key: string) => {\r\n set.delete(key);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Deletes a key or keys from this KeySet.\r\n * @param value A key or keys to delete.\r\n * @returns itself\r\n */\r\n public delete(value: Keys | Key): KeySet {\r\n if (!value)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n const sizeBefore = this.size;\r\n if (this.isKeySet(value)) {\r\n this.deleteKeySet(value);\r\n } else if (this.isKeysArray(value)) {\r\n for (const key of value)\r\n this.delete(key);\r\n } else if (Key.isEntityProps(value)) {\r\n this.delete({ className: value.classFullName, id: value.id! } as InstanceKey);\r\n } else if (Key.isInstanceKey(value)) {\r\n const set = this._instanceKeys.get(value.className.toLowerCase());\r\n if (set)\r\n set.delete(value.id);\r\n } else if (Key.isNodeKey(value)) {\r\n this._nodeKeys.delete(JSON.stringify(value));\r\n } else {\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n }\r\n if (this.size !== sizeBefore)\r\n this.recalculateGuid();\r\n return this;\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains the specified key.\r\n * @param value The key to check.\r\n */\r\n public has(value: Key): boolean {\r\n if (!value)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n if (Key.isEntityProps(value))\r\n return this.has({ className: value.classFullName, id: value.id! } as InstanceKey);\r\n if (Key.isInstanceKey(value)) {\r\n const set = this._instanceKeys.get(value.className.toLowerCase());\r\n return !!(set && set.has(value.id));\r\n }\r\n if (Key.isNodeKey(value))\r\n return this._nodeKeys.has(JSON.stringify(value));\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\r\n }\r\n\r\n private hasKeySet(readonlyKeys: Readonly<KeySet>, checkType: \"all\" | \"any\"): boolean {\r\n // note: cast-away read-onlyness to access private members...\r\n const keys = readonlyKeys as KeySet;\r\n\r\n if (checkType === \"all\") {\r\n if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size)\r\n return false;\r\n if ([...keys._nodeKeys].some((key) => !this._nodeKeys.has(key)))\r\n return false;\r\n for (const otherEntry of keys._instanceKeys) {\r\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"].toLowerCase());\r\n if (!thisEntryKeys || thisEntryKeys.size < otherEntry[\"1\"].size)\r\n return false;\r\n if ([...otherEntry[\"1\"]].some((key) => !thisEntryKeys.has(key)))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n // \"any\" check type\r\n if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key)))\r\n return true;\r\n for (const otherEntry of keys._instanceKeys) {\r\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"].toLowerCase());\r\n if (thisEntryKeys && [...otherEntry[\"1\"]].some((key) => thisEntryKeys.has(key)))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private hasKeysArray(keys: ReadonlyArray<Key>, checkType: \"all\" | \"any\"): boolean {\r\n if (checkType === \"all\") {\r\n if (this.size < keys.length)\r\n return false;\r\n for (const key of keys) {\r\n if (!this.has(key))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n // \"any\" check type\r\n for (const key of keys) {\r\n if (this.has(key))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains all the specified keys.\r\n * @param keys The keys to check.\r\n */\r\n public hasAll(keys: Keys): boolean {\r\n if (!keys)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);\r\n if (this.isKeySet(keys))\r\n return this.hasKeySet(keys, \"all\");\r\n if (this.isKeysArray(keys))\r\n return this.hasKeysArray(keys, \"all\");\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);\r\n }\r\n\r\n /**\r\n * Check if this KeySet contains any of the specified keys.\r\n * @param keys The keys to check.\r\n */\r\n public hasAny(keys: Keys): boolean {\r\n if (!keys)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);\r\n if (this.isKeySet(keys))\r\n return this.hasKeySet(keys, \"any\");\r\n if (this.isKeysArray(keys))\r\n return this.hasKeysArray(keys, \"any\");\r\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);\r\n }\r\n\r\n /**\r\n * Get the number of keys stored in this KeySet.\r\n */\r\n public get size(): number {\r\n const nodeKeysCount = this._nodeKeys.size;\r\n let instanceIdsCount = 0;\r\n for (const set of this._instanceKeys.values())\r\n instanceIdsCount += set.size;\r\n return nodeKeysCount + instanceIdsCount;\r\n }\r\n\r\n /**\r\n * Is this KeySet currently empty.\r\n */\r\n public get isEmpty(): boolean {\r\n return 0 === this.size;\r\n }\r\n\r\n /** Iterate over all keys in this keyset. */\r\n public some(callback: (key: Key) => boolean) {\r\n for (const entry of this._instanceKeys) {\r\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase())!;\r\n if (some(entry[1], (id: Id64String) => callback({ className, id })))\r\n return true;\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n return some(this._nodeKeys, (serializedKey: string) => callback(NodeKey.fromJSON(JSON.parse(serializedKey))));\r\n }\r\n\r\n /** Iterate over all keys in this keyset. */\r\n public forEach(callback: (key: InstanceKey | NodeKey, index: number) => void) {\r\n let index = 0;\r\n this._instanceKeys.forEach((ids: Set<Id64String>, className: string) => {\r\n const recentClassName = this._lowerCaseMap.get(className.toLowerCase())!;\r\n ids.forEach((id: Id64String) => callback({ className: recentClassName, id }, index++));\r\n });\r\n this._nodeKeys.forEach((serializedKey: string) => {\r\n // eslint-disable-next-line deprecation/deprecation\r\n callback(NodeKey.fromJSON(JSON.parse(serializedKey)), index++);\r\n });\r\n }\r\n\r\n /** Iterate over all keys in this keyset in batches */\r\n public forEachBatch(batchSize: number, callback: (batch: KeySet, index: number) => void) {\r\n const size = this.size;\r\n const count = Math.ceil(size / batchSize);\r\n if (1 === count) {\r\n callback(this, 0);\r\n return;\r\n }\r\n let batch = new KeySet();\r\n let batchIndex = 0;\r\n let currBatchSize = 0;\r\n this.forEach((key, index) => {\r\n batch.add(key);\r\n ++currBatchSize;\r\n if (currBatchSize === batchSize || index === (size - 1)) {\r\n callback(batch, batchIndex++);\r\n batch = new KeySet();\r\n currBatchSize = 0;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Serializes this KeySet to JSON\r\n * @public\r\n */\r\n public toJSON(): KeySetJSON {\r\n const instanceKeys: [string, string][] = [];\r\n for (const entry of this._instanceKeys.entries()) {\r\n if (entry[\"1\"].size > 0) {\r\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase());\r\n const compressedIds = CompressedId64Set.sortAndCompress(entry[\"1\"]);\r\n instanceKeys.push([className!, compressedIds.length > 0 ? compressedIds : Id64.invalid]);\r\n }\r\n }\r\n // eslint-disable-next-line deprecation/deprecation\r\n const nodeKeys: NodeKeyJSON[] = [];\r\n for (const serializedKey of this._nodeKeys.values())\r\n nodeKeys.push(JSON.parse(serializedKey));\r\n return {\r\n instanceKeys,\r\n nodeKeys,\r\n };\r\n }\r\n\r\n /**\r\n * Creates a KeySet from JSON\r\n * @public\r\n */\r\n public static fromJSON(json: KeySetJSON): KeySet {\r\n const keyset = new KeySet();\r\n keyset.addKeySetJSON(json);\r\n return keyset;\r\n }\r\n}\r\n\r\nconst some = <TItem>(set: Set<TItem>, cb: (item: TItem) => boolean) => {\r\n for (const item of set) {\r\n if (cb(item))\r\n return true;\r\n }\r\n return false;\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"KeySet.js","sourceRoot":"","sources":["../../../src/presentation-common/KeySet.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA4F;AAG5F,mCAAgE;AAChE,yCAAuD;AAQvD,cAAc;AACd,2DAA2D;AAC3D,IAAiB,GAAG,CAenB;AAfD,WAAiB,GAAG;IAClB,+CAA+C;IAC/C,S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------------\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 Core\n */\n\nimport { CompressedId64Set, Guid, GuidString, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { EntityProps } from \"@itwin/core-common\";\nimport { InstanceId, InstanceKey } from \"./EC\";\nimport { PresentationError, PresentationStatus } from \"./Error\";\nimport { NodeKey, NodeKeyJSON } from \"./hierarchy/Key\";\n\n/**\n * A single key that identifies something in an iTwin.js application\n * @public\n */\nexport type Key = Readonly<NodeKey> | Readonly<InstanceKey> | Readonly<EntityProps>;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Key {\n /** Check if the supplied key is a `NodeKey` */\n export function isNodeKey(key: Key): key is NodeKey {\n return !!(key as NodeKey).type;\n }\n\n /** Check if the supplied key is an `InstanceKey` */\n export function isInstanceKey(key: Key): key is InstanceKey {\n return !!(key as InstanceKey).className && !!(key as InstanceKey).id;\n }\n\n /** Check if the supplied key is an `EntityProps` */\n export function isEntityProps(key: Key): key is EntityProps {\n return !!(key as EntityProps).classFullName && !!(key as EntityProps).id;\n }\n}\n\n/**\n * A type for multiple keys that identify something in iModel.js application\n * @public\n */\nexport type Keys = ReadonlyArray<Key> | Readonly<KeySet>;\n\n/**\n * A data structure of serialized [[KeySet]]\n * @public\n */\nexport interface KeySetJSON {\n /** JSON representation of a list of instance keys */\n instanceKeys: Array<[string, string]>;\n /** An array of serialized node keys */\n // eslint-disable-next-line deprecation/deprecation\n nodeKeys: NodeKeyJSON[];\n}\n\n/**\n * A class that holds multiple [[Key]] objects. It's basically\n * used as a container that holds multiple keys of different types.\n *\n * @public\n */\nexport class KeySet {\n // note: all keys are stored as strings because we need ability to find them by value\n private _instanceKeys: Map<string, Set<string>>; // lower case class name => instance ids\n private _lowerCaseMap: Map<string, string>; // lower case class name => most recent class name\n private _nodeKeys: Set<string>;\n private _guid!: GuidString;\n\n /**\n * Creates an instance of KeySet.\n * @param source Optional source to initialize from.\n */\n constructor(source?: Keys) {\n this._instanceKeys = new Map();\n this._lowerCaseMap = new Map();\n this._nodeKeys = new Set();\n this.recalculateGuid();\n if (source) {\n this.add(source);\n }\n }\n\n private recalculateGuid() {\n // empty keyset should have empty guid, otherwise use a random guid value\n this._guid = this.isEmpty ? Guid.empty : Guid.createValue();\n }\n\n /**\n * Get a GUID that identifies changes in this keyset. The value\n * does not uniquely identify contents of the keyset, but it can be\n * used to check whether keyset has changed.\n */\n public get guid(): GuidString {\n return this._guid;\n }\n\n /**\n * Get a map of instance keys stored in this KeySet\n *\n * **Warning**: getting instance keys might be expensive for\n * large KeySets.\n */\n public get instanceKeys(): Map<string, Set<InstanceId>> {\n const map = new Map<string, Set<InstanceId>>();\n for (const entry of this._instanceKeys) {\n map.set(this._lowerCaseMap.get(entry[\"0\"])!, new Set([...entry[\"1\"]].map((key: string) => Id64.fromJSON(key))));\n }\n return map;\n }\n\n /**\n * Get instance keys count\n */\n public get instanceKeysCount(): number {\n let count = 0;\n this._instanceKeys.forEach((set: Set<string>) => (count += set.size));\n return count;\n }\n\n /**\n * Get a set of node keys stored in this KeySet\n *\n * **Warning**: getting node keys might be expensive for\n * large KeySets.\n */\n public get nodeKeys(): Set<NodeKey> {\n const set = new Set<NodeKey>();\n for (const serialized of this._nodeKeys) {\n // eslint-disable-next-line deprecation/deprecation\n const key = NodeKey.fromJSON(JSON.parse(serialized));\n set.add(key);\n }\n return set;\n }\n\n /**\n * Get node keys count\n */\n public get nodeKeysCount(): number {\n return this._nodeKeys.size;\n }\n\n private isKeySet(set: Keys | Key): set is Readonly<KeySet> {\n return !!(set as KeySet)._nodeKeys && !!(set as KeySet)._instanceKeys;\n }\n\n private isKeysArray(keys: Keys | Key): keys is ReadonlyArray<Key> {\n return Array.isArray(keys);\n }\n\n /**\n * Clear this KeySet.\n * @returns itself\n */\n public clear(): KeySet {\n if (this.isEmpty) {\n return this;\n }\n\n this._instanceKeys = new Map();\n this._lowerCaseMap = new Map();\n this._nodeKeys = new Set();\n this.recalculateGuid();\n return this;\n }\n\n private addKeySet(keyset: Readonly<KeySet>, pred?: (key: Key) => boolean): void {\n for (const key of (keyset as any)._nodeKeys) {\n // eslint-disable-next-line deprecation/deprecation\n if (!pred || pred(NodeKey.fromJSON(JSON.parse(key)))) {\n this._nodeKeys.add(key);\n }\n }\n for (const entry of (keyset as any)._instanceKeys) {\n let set = this._instanceKeys.get(entry[\"0\"]);\n const className = (keyset as KeySet)._lowerCaseMap.get(entry[\"0\"])!;\n if (!set) {\n set = new Set();\n this._instanceKeys.set(entry[\"0\"], set);\n this._lowerCaseMap.set(entry[\"0\"], className);\n }\n entry[\"1\"].forEach((id: Id64String) => {\n if (!pred || pred({ className, id })) {\n set!.add(id);\n }\n });\n }\n }\n\n private addKeySetJSON(keyset: Readonly<KeySetJSON>): void {\n for (const key of keyset.nodeKeys) {\n this._nodeKeys.add(JSON.stringify(key));\n }\n for (const entry of keyset.instanceKeys) {\n const lcClassName = entry[\"0\"].toLowerCase();\n const idsJson: string | Id64String[] = entry[\"1\"];\n const ids: Set<Id64String> =\n typeof idsJson === \"string\" ? (idsJson === Id64.invalid ? new Set([Id64.invalid]) : CompressedId64Set.decompressSet(idsJson)) : new Set(idsJson);\n this._instanceKeys.set(lcClassName, ids);\n this._lowerCaseMap.set(lcClassName, entry[\"0\"]);\n }\n }\n\n /**\n * Add a key or keys to this KeySet.\n * @param value A key or keys to add.\n * @param pred An optional predicate function that indicates whether a key should be added\n * @returns itself\n */\n public add(value: Keys | Key, pred?: (key: Key) => boolean): KeySet {\n if (!value) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n const sizeBefore = this.size;\n if (this.isKeySet(value)) {\n this.addKeySet(value, pred);\n } else if (this.isKeysArray(value)) {\n value.forEach((key) => this.add(key, pred));\n } else if (!pred || pred(value)) {\n if (Key.isEntityProps(value)) {\n this.add({ className: value.classFullName, id: Id64.fromJSON(value.id) } as InstanceKey);\n } else if (Key.isInstanceKey(value)) {\n const lcClassName = value.className.toLowerCase();\n if (!this._instanceKeys.has(lcClassName)) {\n this._instanceKeys.set(lcClassName, new Set());\n this._lowerCaseMap.set(lcClassName, value.className);\n }\n this._lowerCaseMap.set(lcClassName, value.className);\n this._instanceKeys.get(lcClassName)!.add(value.id);\n } else if (Key.isNodeKey(value)) {\n this._nodeKeys.add(JSON.stringify(value));\n } else {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n }\n if (this.size !== sizeBefore) {\n this.recalculateGuid();\n }\n return this;\n }\n\n private deleteKeySet(keyset: Readonly<KeySet>): void {\n for (const key of (keyset as any)._nodeKeys) {\n this._nodeKeys.delete(key);\n }\n for (const entry of (keyset as any)._instanceKeys) {\n const set = this._instanceKeys.get(entry[\"0\"].toLowerCase());\n if (set) {\n entry[\"1\"].forEach((key: string) => {\n set.delete(key);\n });\n }\n }\n }\n\n /**\n * Deletes a key or keys from this KeySet.\n * @param value A key or keys to delete.\n * @returns itself\n */\n public delete(value: Keys | Key): KeySet {\n if (!value) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n const sizeBefore = this.size;\n if (this.isKeySet(value)) {\n this.deleteKeySet(value);\n } else if (this.isKeysArray(value)) {\n for (const key of value) {\n this.delete(key);\n }\n } else if (Key.isEntityProps(value)) {\n this.delete({ className: value.classFullName, id: value.id! } as InstanceKey);\n } else if (Key.isInstanceKey(value)) {\n const set = this._instanceKeys.get(value.className.toLowerCase());\n if (set) {\n set.delete(value.id);\n }\n } else if (Key.isNodeKey(value)) {\n this._nodeKeys.delete(JSON.stringify(value));\n } else {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n if (this.size !== sizeBefore) {\n this.recalculateGuid();\n }\n return this;\n }\n\n /**\n * Check if this KeySet contains the specified key.\n * @param value The key to check.\n */\n public has(value: Key): boolean {\n if (!value) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n if (Key.isEntityProps(value)) {\n return this.has({ className: value.classFullName, id: value.id! } as InstanceKey);\n }\n if (Key.isInstanceKey(value)) {\n const set = this._instanceKeys.get(value.className.toLowerCase());\n return !!(set && set.has(value.id));\n }\n if (Key.isNodeKey(value)) {\n return this._nodeKeys.has(JSON.stringify(value));\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${value}`);\n }\n\n private hasKeySet(readonlyKeys: Readonly<KeySet>, checkType: \"all\" | \"any\"): boolean {\n // note: cast-away read-onlyness to access private members...\n const keys = readonlyKeys as KeySet;\n\n if (checkType === \"all\") {\n if (this._nodeKeys.size < keys._nodeKeys.size || this._instanceKeys.size < keys._instanceKeys.size) {\n return false;\n }\n if ([...keys._nodeKeys].some((key) => !this._nodeKeys.has(key))) {\n return false;\n }\n for (const otherEntry of keys._instanceKeys) {\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"].toLowerCase());\n if (!thisEntryKeys || thisEntryKeys.size < otherEntry[\"1\"].size) {\n return false;\n }\n if ([...otherEntry[\"1\"]].some((key) => !thisEntryKeys.has(key))) {\n return false;\n }\n }\n return true;\n }\n\n // \"any\" check type\n if ([...keys._nodeKeys].some((key) => this._nodeKeys.has(key))) {\n return true;\n }\n for (const otherEntry of keys._instanceKeys) {\n const thisEntryKeys = this._instanceKeys.get(otherEntry[\"0\"].toLowerCase());\n if (thisEntryKeys && [...otherEntry[\"1\"]].some((key) => thisEntryKeys.has(key))) {\n return true;\n }\n }\n return false;\n }\n\n private hasKeysArray(keys: ReadonlyArray<Key>, checkType: \"all\" | \"any\"): boolean {\n if (checkType === \"all\") {\n if (this.size < keys.length) {\n return false;\n }\n for (const key of keys) {\n if (!this.has(key)) {\n return false;\n }\n }\n return true;\n }\n\n // \"any\" check type\n for (const key of keys) {\n if (this.has(key)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if this KeySet contains all the specified keys.\n * @param keys The keys to check.\n */\n public hasAll(keys: Keys): boolean {\n if (!keys) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);\n }\n if (this.isKeySet(keys)) {\n return this.hasKeySet(keys, \"all\");\n }\n if (this.isKeysArray(keys)) {\n return this.hasKeysArray(keys, \"all\");\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);\n }\n\n /**\n * Check if this KeySet contains any of the specified keys.\n * @param keys The keys to check.\n */\n public hasAny(keys: Keys): boolean {\n if (!keys) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: value = ${keys}`);\n }\n if (this.isKeySet(keys)) {\n return this.hasKeySet(keys, \"any\");\n }\n if (this.isKeysArray(keys)) {\n return this.hasKeysArray(keys, \"any\");\n }\n throw new PresentationError(PresentationStatus.InvalidArgument, `Invalid argument: keys = ${keys}`);\n }\n\n /**\n * Get the number of keys stored in this KeySet.\n */\n public get size(): number {\n const nodeKeysCount = this._nodeKeys.size;\n let instanceIdsCount = 0;\n for (const set of this._instanceKeys.values()) {\n instanceIdsCount += set.size;\n }\n return nodeKeysCount + instanceIdsCount;\n }\n\n /**\n * Is this KeySet currently empty.\n */\n public get isEmpty(): boolean {\n return 0 === this.size;\n }\n\n /** Iterate over all keys in this keyset. */\n public some(callback: (key: Key) => boolean) {\n for (const entry of this._instanceKeys) {\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase())!;\n if (some(entry[1], (id: Id64String) => callback({ className, id }))) {\n return true;\n }\n }\n // eslint-disable-next-line deprecation/deprecation\n return some(this._nodeKeys, (serializedKey: string) => callback(NodeKey.fromJSON(JSON.parse(serializedKey))));\n }\n\n /** Iterate over all keys in this keyset. */\n public forEach(callback: (key: InstanceKey | NodeKey, index: number) => void) {\n let index = 0;\n this._instanceKeys.forEach((ids: Set<Id64String>, className: string) => {\n const recentClassName = this._lowerCaseMap.get(className.toLowerCase())!;\n ids.forEach((id: Id64String) => callback({ className: recentClassName, id }, index++));\n });\n this._nodeKeys.forEach((serializedKey: string) => {\n // eslint-disable-next-line deprecation/deprecation\n callback(NodeKey.fromJSON(JSON.parse(serializedKey)), index++);\n });\n }\n\n /** Iterate over all keys in this keyset in batches */\n public forEachBatch(batchSize: number, callback: (batch: KeySet, index: number) => void) {\n const size = this.size;\n const count = Math.ceil(size / batchSize);\n if (1 === count) {\n callback(this, 0);\n return;\n }\n let batch = new KeySet();\n let batchIndex = 0;\n let currBatchSize = 0;\n this.forEach((key, index) => {\n batch.add(key);\n ++currBatchSize;\n if (currBatchSize === batchSize || index === size - 1) {\n callback(batch, batchIndex++);\n batch = new KeySet();\n currBatchSize = 0;\n }\n });\n }\n\n /**\n * Serializes this KeySet to JSON\n * @public\n */\n public toJSON(): KeySetJSON {\n const instanceKeys: [string, string][] = [];\n for (const entry of this._instanceKeys.entries()) {\n if (entry[\"1\"].size > 0) {\n const className = this._lowerCaseMap.get(entry[\"0\"].toLowerCase());\n const compressedIds = CompressedId64Set.sortAndCompress(entry[\"1\"]);\n instanceKeys.push([className!, compressedIds.length > 0 ? compressedIds : Id64.invalid]);\n }\n }\n // eslint-disable-next-line deprecation/deprecation\n const nodeKeys: NodeKeyJSON[] = [];\n for (const serializedKey of this._nodeKeys.values()) {\n nodeKeys.push(JSON.parse(serializedKey));\n }\n return {\n instanceKeys,\n nodeKeys,\n };\n }\n\n /**\n * Creates a KeySet from JSON\n * @public\n */\n public static fromJSON(json: KeySetJSON): KeySet {\n const keyset = new KeySet();\n keyset.addKeySetJSON(json);\n return keyset;\n }\n}\n\nconst some = <TItem>(set: Set<TItem>, cb: (item: TItem) => boolean) => {\n for (const item of set) {\n if (cb(item)) {\n return true;\n }\n }\n return false;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KoqPropertyValueFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,WAAW,EAAE,aAAa,EAAE,UAAU,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAIL,aAAa,EAMd,MAAM,0BAA0B,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;CAC7D;AAED,aAAa;AACb,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED,aAAa;AACb,qBAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"KoqPropertyValueFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,WAAW,EAAE,aAAa,EAAE,UAAU,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAIL,aAAa,EAMd,MAAM,0BAA0B,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;CAC7D;AAED,aAAa;AACb,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED,aAAa;AACb,qBAAa,yBAAyB;IAKlC,OAAO,CAAC,cAAc;IAJxB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,CAAC;IAC5F,CAAC;IACD,QAAQ,QAAQ,EAAE;QAChB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjF,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3E,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;KAClF;IACD,OAAO,EAAE,CAAC;AACZ,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 Core\r\n */\r\n\r\nimport { Format, FormatProps, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n getFormatProps,\r\n InvertedUnit,\r\n KindOfQuantity,\r\n SchemaContext,\r\n SchemaKey,\r\n SchemaMatchType,\r\n SchemaUnitProvider,\r\n Unit,\r\n UnitSystem,\r\n} from \"@itwin/ecschema-metadata\";\r\n\r\n/**\r\n * A data structure that associates unit systems with property value formatting props. The associations are used for\r\n * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).\r\n *\r\n * @public\r\n */\r\nexport interface UnitSystemFormat {\r\n unitSystems: UnitSystemKey[];\r\n format: FormatProps;\r\n}\r\n\r\n/**\r\n * A data structure that associates specific phenomenon with one or more formatting props for specific unit system.\r\n *\r\n * Example:\r\n * ```json\r\n * {\r\n * length: [{\r\n * unitSystems: [\"metric\"],\r\n * format: formatForCentimeters,\r\n * }, {\r\n * unitSystems: [\"imperial\", \"usCustomary\"],\r\n * format: formatForInches,\r\n * }, {\r\n * unitSystems: [\"usSurvey\"],\r\n * format: formatForUsSurveyInches,\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport interface FormatsMap {\r\n [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];\r\n}\r\n\r\n/** @alpha */\r\nexport interface FormatOptions {\r\n koqName: string;\r\n unitSystem?: UnitSystemKey;\r\n}\r\n\r\n/** @alpha */\r\nexport class KoqPropertyValueFormatter {\r\n private _unitsProvider: UnitsProvider;\r\n private _defaultFormats?: FormatsMap;\r\n\r\n constructor(private _schemaContext: SchemaContext, defaultFormats?: FormatsMap) {\r\n this._unitsProvider = new SchemaUnitProvider(_schemaContext);\r\n this._defaultFormats = defaultFormats\r\n ? Object.entries(defaultFormats).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})\r\n : /* istanbul ignore next */ undefined;\r\n }\r\n\r\n public async format(value: number, options: FormatOptions) {\r\n const formatterSpec = await this.getFormatterSpec(options);\r\n if (!formatterSpec) {\r\n return undefined;\r\n }\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n\r\n public async getFormatterSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\r\n if (!formattingProps) {\r\n return undefined;\r\n }\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\r\n }\r\n\r\n public async getParserSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\r\n if (!formattingProps) {\r\n return undefined;\r\n }\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\r\n }\r\n}\r\n\r\ninterface FormattingProps {\r\n formatProps: FormatProps;\r\n persistenceUnitName: string;\r\n}\r\n\r\nasync function getFormattingProps(\r\n schemaLocater: SchemaContext,\r\n defaultFormats: FormatsMap | undefined,\r\n options: FormatOptions,\r\n): Promise<FormattingProps | undefined> {\r\n const { koqName, unitSystem } = options;\r\n\r\n const koq = await getKoq(schemaLocater, koqName);\r\n if (!koq) {\r\n return undefined;\r\n }\r\n\r\n const persistenceUnit = await koq.persistenceUnit;\r\n // istanbul ignore if\r\n if (!persistenceUnit) {\r\n return undefined;\r\n }\r\n\r\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, defaultFormats, unitSystem);\r\n if (!formatProps) {\r\n return undefined;\r\n }\r\n\r\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\r\n}\r\n\r\nasync function getKoq(schemaLocater: SchemaContext, fullName: string) {\r\n const [schemaName, propKoqName] = fullName.split(\":\");\r\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\r\n if (!schema) {\r\n return undefined;\r\n }\r\n return schema.getItem<KindOfQuantity>(propKoqName);\r\n}\r\n\r\nasync function getKoqFormatProps(\r\n koq: KindOfQuantity,\r\n persistenceUnit: Unit | InvertedUnit,\r\n defaultFormats: FormatsMap | undefined,\r\n unitSystem?: UnitSystemKey,\r\n) {\r\n const unitSystemMatchers = getUnitSystemGroupMatchers(unitSystem);\r\n // use one of KOQ presentation format that matches requested unit system\r\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystemMatchers);\r\n if (presentationFormat) {\r\n return getFormatProps(presentationFormat);\r\n }\r\n\r\n // use one of the formats in default formats map if there is one for matching phenomena and requested unit\r\n // system combination\r\n if (defaultFormats && unitSystem) {\r\n const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* istanbul ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;\r\n const phenomenon = await actualPersistenceUnit?.phenomenon;\r\n // istanbul ignore else\r\n if (phenomenon && defaultFormats[phenomenon.name.toUpperCase()]) {\r\n const defaultPhenomenonFormats = defaultFormats[phenomenon.name.toUpperCase()];\r\n for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)\r\n ? /* istanbul ignore next */ defaultPhenomenonFormats\r\n : [defaultPhenomenonFormats]) {\r\n if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {\r\n return defaultUnitSystemFormat.format;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\r\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\r\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\r\n return getPersistenceUnitFormatProps(persistenceUnit);\r\n }\r\n\r\n // use default presentation format if persistence unit does not match requested unit system\r\n if (koq.defaultPresentationFormat) {\r\n return getFormatProps(koq.defaultPresentationFormat);\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystemMatchers: Array<(unitSystem: UnitSystem) => boolean>) {\r\n const presentationFormats = koq.presentationFormats;\r\n for (const matcher of unitSystemMatchers) {\r\n for (const format of presentationFormats) {\r\n const unit = format.units && format.units[0][0];\r\n // istanbul ignore if\r\n if (!unit) {\r\n continue;\r\n }\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && matcher(currentUnitSystem)) {\r\n return format;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n uomSeparator: \" \",\r\n decimalSeparator: \".\",\r\n composite: {\r\n units: [\r\n {\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n },\r\n ],\r\n },\r\n };\r\n}\r\n\r\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\r\n function createMatcher(name: string | string[]) {\r\n const names = Array.isArray(name) ? name : [name];\r\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\r\n }\r\n switch (groupKey) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"metric\":\r\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\r\n }\r\n return [];\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"KoqPropertyValueFormatter.js","sourceRoot":"","sources":["../../../src/presentation-common/KoqPropertyValueFormatter.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,wDAAoH;AACpH,gEAUkC;AA4ClC,aAAa;AACb,MAAa,yBAAyB;IAIpC,YACU,cAA6B,EACrC,cAA2B;QADnB,mBAAc,GAAd,cAAc,CAAe;QAGrC,IAAI,CAAC,cAAc,GAAG,IAAI,sCAAkB,CAAC,cAAc,CAAC,CAAC;QAC7D,IAAI,CAAC,eAAe,GAAG,cAAc;YACnC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,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AAK,EAAE,eAAe,CAAC,KAAK;iBAC7B;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B,CAAC,QAAwB;IAC1D,SAAS,aAAa,CAAC,IAAuB;QAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAClD,OAAO,CAAC,UAAsB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5F,CAAC;IACD,QAAQ,QAAQ,EAAE;QAChB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjF,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3E,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACrE,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;KAClF;IACD,OAAO,EAAE,CAAC;AACZ,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 Core\n */\n\nimport { Format, FormatProps, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\nimport {\n getFormatProps,\n InvertedUnit,\n KindOfQuantity,\n SchemaContext,\n SchemaKey,\n SchemaMatchType,\n SchemaUnitProvider,\n Unit,\n UnitSystem,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * A data structure that associates unit systems with property value formatting props. The associations are used for\n * assigning formatting props for specific phenomenon and unit system combinations (see [[FormatsMap]]).\n *\n * @public\n */\nexport interface UnitSystemFormat {\n unitSystems: UnitSystemKey[];\n format: FormatProps;\n}\n\n/**\n * A data structure that associates specific phenomenon with one or more formatting props for specific unit system.\n *\n * Example:\n * ```json\n * {\n * length: [{\n * unitSystems: [\"metric\"],\n * format: formatForCentimeters,\n * }, {\n * unitSystems: [\"imperial\", \"usCustomary\"],\n * format: formatForInches,\n * }, {\n * unitSystems: [\"usSurvey\"],\n * format: formatForUsSurveyInches,\n * }]\n * }\n * ```\n *\n * @public\n */\nexport interface FormatsMap {\n [phenomenon: string]: UnitSystemFormat | UnitSystemFormat[];\n}\n\n/** @alpha */\nexport interface FormatOptions {\n koqName: string;\n unitSystem?: UnitSystemKey;\n}\n\n/** @alpha */\nexport class KoqPropertyValueFormatter {\n private _unitsProvider: UnitsProvider;\n private _defaultFormats?: FormatsMap;\n\n constructor(\n private _schemaContext: SchemaContext,\n defaultFormats?: FormatsMap,\n ) {\n this._unitsProvider = new SchemaUnitProvider(_schemaContext);\n this._defaultFormats = defaultFormats\n ? Object.entries(defaultFormats).reduce((acc, [phenomenon, unitSystemFormats]) => ({ ...acc, [phenomenon.toUpperCase()]: unitSystemFormats }), {})\n : /* istanbul ignore next */ undefined;\n }\n\n public async format(value: number, options: FormatOptions) {\n const formatterSpec = await this.getFormatterSpec(options);\n if (!formatterSpec) {\n return undefined;\n }\n return formatterSpec.applyFormatting(value);\n }\n\n public async getFormatterSpec(options: FormatOptions) {\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\n }\n\n public async getParserSpec(options: FormatOptions) {\n const formattingProps = await getFormattingProps(this._schemaContext, this._defaultFormats, options);\n if (!formattingProps) {\n return undefined;\n }\n const { formatProps, persistenceUnitName } = formattingProps;\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\n }\n}\n\ninterface FormattingProps {\n formatProps: FormatProps;\n persistenceUnitName: string;\n}\n\nasync function getFormattingProps(\n schemaLocater: SchemaContext,\n defaultFormats: FormatsMap | undefined,\n options: FormatOptions,\n): Promise<FormattingProps | undefined> {\n const { koqName, unitSystem } = options;\n\n const koq = await getKoq(schemaLocater, koqName);\n if (!koq) {\n return undefined;\n }\n\n const persistenceUnit = await koq.persistenceUnit;\n // istanbul ignore if\n if (!persistenceUnit) {\n return undefined;\n }\n\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, defaultFormats, unitSystem);\n if (!formatProps) {\n return undefined;\n }\n\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\n}\n\nasync function getKoq(schemaLocater: SchemaContext, fullName: string) {\n const [schemaName, propKoqName] = fullName.split(\":\");\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\n if (!schema) {\n return undefined;\n }\n return schema.getItem<KindOfQuantity>(propKoqName);\n}\n\nasync function getKoqFormatProps(\n koq: KindOfQuantity,\n persistenceUnit: Unit | InvertedUnit,\n defaultFormats: FormatsMap | undefined,\n unitSystem?: UnitSystemKey,\n) {\n const unitSystemMatchers = getUnitSystemGroupMatchers(unitSystem);\n // use one of KOQ presentation format that matches requested unit system\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystemMatchers);\n if (presentationFormat) {\n return getFormatProps(presentationFormat);\n }\n\n // use one of the formats in default formats map if there is one for matching phenomena and requested unit\n // system combination\n if (defaultFormats && unitSystem) {\n const actualPersistenceUnit = persistenceUnit instanceof InvertedUnit ? /* istanbul ignore next */ await persistenceUnit.invertsUnit : persistenceUnit;\n const phenomenon = await actualPersistenceUnit?.phenomenon;\n // istanbul ignore else\n if (phenomenon && defaultFormats[phenomenon.name.toUpperCase()]) {\n const defaultPhenomenonFormats = defaultFormats[phenomenon.name.toUpperCase()];\n for (const defaultUnitSystemFormat of Array.isArray(defaultPhenomenonFormats)\n ? /* istanbul ignore next */ defaultPhenomenonFormats\n : [defaultPhenomenonFormats]) {\n if (defaultUnitSystemFormat.unitSystems.includes(unitSystem)) {\n return defaultUnitSystemFormat.format;\n }\n }\n }\n }\n\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\n if (persistenceUnitSystem && unitSystemMatchers.some((matcher) => matcher(persistenceUnitSystem))) {\n return getPersistenceUnitFormatProps(persistenceUnit);\n }\n\n // use default presentation format if persistence unit does not match requested unit system\n if (koq.defaultPresentationFormat) {\n return getFormatProps(koq.defaultPresentationFormat);\n }\n\n return undefined;\n}\n\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystemMatchers: Array<(unitSystem: UnitSystem) => boolean>) {\n const presentationFormats = koq.presentationFormats;\n for (const matcher of unitSystemMatchers) {\n for (const format of presentationFormats) {\n const unit = format.units && format.units[0][0];\n // istanbul ignore if\n if (!unit) {\n continue;\n }\n const currentUnitSystem = await unit.unitSystem;\n if (currentUnitSystem && matcher(currentUnitSystem)) {\n return format;\n }\n }\n }\n return undefined;\n}\n\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\n // Same as Format \"DefaultRealU\" in Formats ecschema\n return {\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\n precision: 6,\n type: \"Decimal\",\n uomSeparator: \" \",\n decimalSeparator: \".\",\n composite: {\n units: [\n {\n name: persistenceUnit.fullName,\n label: persistenceUnit.label,\n },\n ],\n },\n };\n}\n\nfunction getUnitSystemGroupMatchers(groupKey?: UnitSystemKey) {\n function createMatcher(name: string | string[]) {\n const names = Array.isArray(name) ? name : [name];\n return (unitSystem: UnitSystem) => names.some((n) => n === unitSystem.name.toUpperCase());\n }\n switch (groupKey) {\n case \"imperial\":\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"metric\":\n return [[\"SI\", \"METRIC\"], \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usCustomary\":\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n case \"usSurvey\":\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"].map(createMatcher);\n }\n return [];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LabelDefinition.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/LabelDefinition.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,cAAc;AACd,yBAAiB,mBAAmB,CAAC;IACnC;;;OAGG;IAEH,SAAgB,MAAM,CAAC,cAAc,EAAE,mBAAmB,GAAG,uBAAuB,CAEnF;IAED;;;OAGG;IAEH,SAAgB,QAAQ,CAAC,IAAI,EAAE,uBAAuB,GAAG,mBAAmB,CAE3E;CACF;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,iB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aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,QAAQ,EAAE,aAAa,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,cAAc;AACd,yBAAiB,eAAe,CAAC;IAC/B;;;OAGG;IAEH,SAAgB,MAAM,CAAC,eAAe,EAAE,eAAe,GAAG,mBAAmB,CAE5E;IAED;;;OAGG;IAEH,SAAgB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,GAAG,eAAe,CAK5E;IAED,gBAAgB;IACT,MAAM,6BAA6B,cAAc,CAAC;IAEzD;;;OAGG;IACH,SAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,GAAG,IAAI,eAAe,GAAG;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,CAEtH;IAED;;;OAGG;IACH,SAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAM9D;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
-
*--------------------------------------------------------------------------------------------*/
|
|
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
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Hierarchies
|
|
8
8
|
*/
|
|
@@ -48,8 +48,9 @@ var LabelDefinition;
|
|
|
48
48
|
*/
|
|
49
49
|
// eslint-disable-next-line deprecation/deprecation
|
|
50
50
|
function fromJSON(json) {
|
|
51
|
-
if (typeof json === "string")
|
|
51
|
+
if (typeof json === "string") {
|
|
52
52
|
return JSON.parse(json);
|
|
53
|
+
}
|
|
53
54
|
return { ...json };
|
|
54
55
|
}
|
|
55
56
|
LabelDefinition.fromJSON = fromJSON;
|