@openui5/sap.ui.core 1.93.3 → 1.96.2
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/.eslintrc.json +13 -2
- package/.reuse/dep5 +6 -11
- package/THIRDPARTY.txt +10 -16
- package/package.json +1 -1
- package/src/jquery.sap.global.js +5 -2
- package/src/jquery.sap.properties.js +1 -1
- package/src/jquery.sap.resources.js +1 -1
- package/src/jquery.sap.script.js +1 -1
- package/src/jquery.sap.storage.js +3 -3
- package/src/jquery.sap.stubs.js +2 -1
- package/src/jquery.sap.trace.js +2 -1
- package/src/sap/base/i18n/ResourceBundle.js +6 -2
- package/src/sap/base/strings/whitespaceReplacer.js +52 -0
- package/src/sap/base/util/restricted/_CancelablePromise.js +1 -1
- package/src/sap/base/util/restricted/_castArray.js +1 -1
- package/src/sap/base/util/restricted/_compact.js +1 -1
- package/src/sap/base/util/restricted/_curry.js +1 -1
- package/src/sap/base/util/restricted/_debounce.js +1 -1
- package/src/sap/base/util/restricted/_difference.js +1 -1
- package/src/sap/base/util/restricted/_differenceBy.js +1 -1
- package/src/sap/base/util/restricted/_differenceWith.js +1 -1
- package/src/sap/base/util/restricted/_flatMap.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDeep.js +1 -1
- package/src/sap/base/util/restricted/_flatMapDepth.js +1 -1
- package/src/sap/base/util/restricted/_flatten.js +1 -1
- package/src/sap/base/util/restricted/_flattenDeep.js +1 -1
- package/src/sap/base/util/restricted/_flattenDepth.js +1 -1
- package/src/sap/base/util/restricted/_intersection.js +1 -1
- package/src/sap/base/util/restricted/_intersectionBy.js +1 -1
- package/src/sap/base/util/restricted/_intersectionWith.js +1 -1
- package/src/sap/base/util/restricted/_isEqual.js +1 -1
- package/src/sap/base/util/restricted/_isEqualWith.js +1 -1
- package/src/sap/base/util/restricted/_isNil.js +1 -1
- package/src/sap/base/util/restricted/_max.js +1 -1
- package/src/sap/base/util/restricted/_merge.js +1 -1
- package/src/sap/base/util/restricted/_mergeWith.js +1 -1
- package/src/sap/base/util/restricted/_min.js +1 -1
- package/src/sap/base/util/restricted/_omit.js +1 -1
- package/src/sap/base/util/restricted/_pick.js +1 -1
- package/src/sap/base/util/restricted/_pickBy.js +1 -1
- package/src/sap/base/util/restricted/_throttle.js +1 -1
- package/src/sap/base/util/restricted/_toArray.js +1 -1
- package/src/sap/base/util/restricted/_union.js +1 -1
- package/src/sap/base/util/restricted/_unionBy.js +1 -1
- package/src/sap/base/util/restricted/_unionWith.js +1 -1
- package/src/sap/base/util/restricted/_uniq.js +1 -1
- package/src/sap/base/util/restricted/_uniqBy.js +1 -1
- package/src/sap/base/util/restricted/_uniqWith.js +1 -1
- package/src/sap/base/util/restricted/_without.js +1 -1
- package/src/sap/base/util/restricted/_xor.js +1 -1
- package/src/sap/base/util/restricted/_xorBy.js +1 -1
- package/src/sap/base/util/restricted/_xorWith.js +1 -1
- package/src/sap/base/util/restricted/_zipObject.js +1 -1
- package/src/sap/base/util/restricted/_zipObjectDeep.js +1 -1
- package/src/sap/ui/Device.js +37 -42
- package/src/sap/ui/Global.js +8 -7
- package/src/sap/ui/base/DataType.js +14 -8
- package/src/sap/ui/base/Event.js +1 -1
- package/src/sap/ui/base/EventProvider.js +1 -1
- package/src/sap/ui/base/ExpressionParser.js +9 -6
- package/src/sap/ui/base/Interface.js +3 -49
- package/src/sap/ui/base/ManagedObject.js +12 -7
- package/src/sap/ui/base/ManagedObjectMetadata.js +1 -1
- package/src/sap/ui/base/Metadata.js +1 -1
- package/src/sap/ui/base/Object.js +49 -4
- package/src/sap/ui/base/ObjectPool.js +1 -1
- package/src/sap/ui/base/syncXHRFix.js +2 -1
- package/src/sap/ui/core/.library +5 -5
- package/src/sap/ui/core/AppCacheBuster.js +4 -4
- package/src/sap/ui/core/BusyIndicator.js +1 -11
- package/src/sap/ui/core/Component.js +300 -140
- package/src/sap/ui/core/ComponentContainer.js +24 -8
- package/src/sap/ui/core/ComponentMetadata.js +14 -3
- package/src/sap/ui/core/ComponentSupport.js +1 -1
- package/src/sap/ui/core/Configuration.js +67 -31
- package/src/sap/ui/core/Control.js +1 -1
- package/src/sap/ui/core/Core.js +103 -25
- package/src/sap/ui/core/CustomData.js +1 -1
- package/src/sap/ui/core/CustomizingConfiguration.js +35 -260
- package/src/sap/ui/core/DeclarativeSupport.js +3 -2
- package/src/sap/ui/core/Element.js +1 -1
- package/src/sap/ui/core/ElementMetadata.js +4 -2
- package/src/sap/ui/core/EnabledPropagator.js +91 -73
- package/src/sap/ui/core/EventBus.js +1 -1
- package/src/sap/ui/core/ExtensionPoint.js +7 -14
- package/src/sap/ui/core/Fragment.js +30 -32
- package/src/sap/ui/core/HTML.js +1 -1
- package/src/sap/ui/core/History.js +1 -1
- package/src/sap/ui/core/Icon.js +7 -8
- package/src/sap/ui/core/IconPool.js +26 -1097
- package/src/sap/ui/core/IconRenderer.js +6 -6
- package/src/sap/ui/core/IndicationColorSupport.js +1 -1
- package/src/sap/ui/core/IntervalTrigger.js +1 -1
- package/src/sap/ui/core/InvisibleMessage.js +1 -1
- package/src/sap/ui/core/InvisibleRenderer.js +1 -1
- package/src/sap/ui/core/InvisibleText.js +1 -1
- package/src/sap/ui/core/Item.js +1 -1
- package/src/sap/ui/core/LabelEnablement.js +1 -1
- package/src/sap/ui/core/LayoutData.js +1 -1
- package/src/sap/ui/core/ListItem.js +1 -1
- package/src/sap/ui/core/LocalBusyIndicator.js +1 -1
- package/src/sap/ui/core/Locale.js +26 -4
- package/src/sap/ui/core/LocaleData.js +1 -1
- package/src/sap/ui/core/Manifest.js +4 -61
- package/src/sap/ui/core/Message.js +1 -1
- package/src/sap/ui/core/Patcher.js +27 -3
- package/src/sap/ui/core/Placeholder.js +28 -15
- package/src/sap/ui/core/RenderManager.js +36 -6
- package/src/sap/ui/core/Renderer.js +13 -3
- package/src/sap/ui/core/ResizeHandler.js +1 -1
- package/src/sap/ui/core/ScrollBar.js +2 -2
- package/src/sap/ui/core/SeparatorItem.js +1 -1
- package/src/sap/ui/core/ShortcutHintsMixin.js +14 -7
- package/src/sap/ui/core/Title.js +1 -1
- package/src/sap/ui/core/TooltipBase.js +1 -1
- package/src/sap/ui/core/UIArea.js +1 -1
- package/src/sap/ui/core/UIComponent.js +42 -16
- package/src/sap/ui/core/UIComponentMetadata.js +1 -1
- package/src/sap/ui/core/ValueStateSupport.js +1 -1
- package/src/sap/ui/core/VariantLayoutData.js +1 -1
- package/src/sap/ui/core/XMLComposite.js +2 -2
- package/src/sap/ui/core/XMLCompositeMetadata.js +2 -2
- package/src/sap/ui/core/XMLTemplateProcessor.js +116 -41
- package/src/sap/ui/core/_IconRegistry.js +1148 -0
- package/src/sap/ui/core/delegate/ItemNavigation.js +1 -1
- package/src/sap/ui/core/delegate/ScrollEnablement.js +6 -3
- package/src/sap/ui/core/dnd/DragDropBase.js +1 -1
- package/src/sap/ui/core/dnd/DragDropInfo.js +1 -1
- package/src/sap/ui/core/dnd/DragInfo.js +2 -2
- package/src/sap/ui/core/dnd/DropInfo.js +1 -1
- package/src/sap/ui/core/format/NumberFormat.js +16 -1
- package/src/sap/ui/core/hyphenation/Hyphenation.js +73 -221
- package/src/sap/ui/core/hyphenation/HyphenationTestingWords.js +11 -10
- package/src/sap/ui/core/library.js +3 -3
- package/src/sap/ui/core/message/ControlMessageProcessor.js +1 -1
- package/src/sap/ui/core/message/Message.js +1 -1
- package/src/sap/ui/core/message/MessageManager.js +13 -15
- package/src/sap/ui/core/message/MessageParser.js +1 -1
- package/src/sap/ui/core/message/MessageProcessor.js +1 -1
- package/src/sap/ui/core/messagebundle_de.properties +1 -1
- package/src/sap/ui/core/messagebundle_fr.properties +1 -1
- package/src/sap/ui/core/messagebundle_it.properties +1 -1
- package/src/sap/ui/core/messagebundle_pl.properties +1 -1
- package/src/sap/ui/core/messagebundle_th.properties +2 -2
- package/src/sap/ui/core/mvc/Controller.js +38 -19
- package/src/sap/ui/core/mvc/ControllerExtensionProvider.js +30 -32
- package/src/sap/ui/core/mvc/ControllerMetadata.js +18 -18
- package/src/sap/ui/core/mvc/HTMLView.js +2 -2
- package/src/sap/ui/core/mvc/JSONView.js +2 -2
- package/src/sap/ui/core/mvc/JSView.js +2 -2
- package/src/sap/ui/core/mvc/TemplateView.js +2 -2
- package/src/sap/ui/core/mvc/View.js +58 -85
- package/src/sap/ui/core/mvc/XMLView.js +2 -2
- package/src/sap/ui/core/mvc/XMLViewRenderer.js +17 -20
- package/src/sap/ui/core/plugin/DeclarativeSupport.js +1 -1
- package/src/sap/ui/core/plugin/LessSupport.js +1 -1
- package/src/sap/ui/core/plugin/TemplatingSupport.js +1 -1
- package/src/sap/ui/core/postmessage/Bus.js +1 -1
- package/src/sap/ui/core/postmessage/confirmationDialog.js +1 -1
- package/src/sap/ui/core/routing/History.js +10 -2
- package/src/sap/ui/core/routing/Router.js +8 -1
- package/src/sap/ui/core/routing/Target.js +13 -0
- package/src/sap/ui/core/routing/Targets.js +13 -2
- package/src/sap/ui/core/routing/async/Route.js +1 -1
- package/src/sap/ui/core/routing/async/Target.js +353 -259
- package/src/sap/ui/core/search/OpenSearchProvider.js +1 -1
- package/src/sap/ui/core/search/SearchProvider.js +1 -1
- package/src/sap/ui/core/service/Service.js +1 -1
- package/src/sap/ui/core/service/ServiceFactory.js +1 -1
- package/src/sap/ui/core/service/ServiceFactoryRegistry.js +1 -1
- package/src/sap/ui/core/support/BootSupportTool.js +11 -0
- package/src/sap/ui/core/support/InteractionTree.css +4 -0
- package/src/sap/ui/core/support/Plugin.js +1 -1
- package/src/sap/ui/core/support/Support.js +1 -1
- package/src/sap/ui/core/support/ViewInfo.css +599 -0
- package/src/sap/ui/core/support/controls/InteractionTree.js +352 -222
- package/src/sap/ui/core/support/controls/ObjectViewer.js +3 -41
- package/src/sap/ui/core/support/controls/TimelineOverview.js +49 -24
- package/src/sap/ui/core/support/controls/TreeViewer.js +12 -58
- package/src/sap/ui/core/support/plugins/ControlTree.js +59 -68
- package/src/sap/ui/core/support/plugins/Debugging.js +9 -11
- package/src/sap/ui/core/support/plugins/Interaction.js +2 -2
- package/src/sap/ui/core/support/plugins/LocalStorage.js +1 -1
- package/src/sap/ui/core/support/plugins/Performance.js +147 -75
- package/src/sap/ui/core/support/plugins/Selector.js +19 -24
- package/src/sap/ui/core/support/plugins/TechInfo.js +5 -5
- package/src/sap/ui/core/support/plugins/Trace.js +95 -32
- package/src/sap/ui/core/support/plugins/ViewInfo.js +9 -73
- package/src/sap/ui/core/support/support.css +109 -14
- package/src/sap/ui/core/support/support.html +6 -2
- package/src/sap/ui/core/support/techinfo/TechnicalInfo.fragment.xml +1 -0
- package/src/sap/ui/core/support/techinfo/TechnicalInfo.js +149 -72
- package/src/sap/ui/core/themes/base/Icon.less +9 -0
- package/src/sap/ui/core/themes/base/fonts/SAP-icons.woff2 +0 -0
- package/src/sap/ui/core/theming/Parameters.js +6 -4
- package/src/sap/ui/core/tmpl/DOMAttribute.js +1 -1
- package/src/sap/ui/core/tmpl/DOMElement.js +1 -1
- package/src/sap/ui/core/tmpl/HandlebarsTemplate.js +1 -1
- package/src/sap/ui/core/tmpl/Template.js +10 -28
- package/src/sap/ui/core/tmpl/TemplateControl.js +4 -4
- package/src/sap/ui/core/tmpl/_parsePath.js +35 -0
- package/src/sap/ui/core/util/AsyncHintsHelper.js +1 -1
- package/src/sap/ui/core/util/DraftEnabledMockServer.js +9 -4
- package/src/sap/ui/core/util/Export.js +1 -1
- package/src/sap/ui/core/util/ExportCell.js +1 -1
- package/src/sap/ui/core/util/ExportColumn.js +1 -1
- package/src/sap/ui/core/util/ExportRow.js +1 -1
- package/src/sap/ui/core/util/ExportType.js +1 -1
- package/src/sap/ui/core/util/ExportTypeCSV.js +1 -1
- package/src/sap/ui/core/util/File.js +1 -1
- package/src/sap/ui/core/util/LibraryInfo.js +1 -1
- package/src/sap/ui/core/util/MockServer.js +5 -5
- package/src/sap/ui/core/util/MockServerAnnotationsHandler.js +3 -2
- package/src/sap/ui/core/util/PasteHelper.js +1 -1
- package/src/sap/ui/core/util/XMLPreprocessor.js +11 -12
- package/src/sap/ui/core/util/reflection/BaseTreeModifier.js +136 -63
- package/src/sap/ui/core/util/reflection/JsControlTreeModifier.js +170 -153
- package/src/sap/ui/core/util/reflection/XmlTreeModifier.js +424 -293
- package/src/sap/ui/core/util/serializer/HTMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/Serializer.js +1 -1
- package/src/sap/ui/core/util/serializer/ViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/XMLViewSerializer.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/Delegate.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/HTML.js +1 -1
- package/src/sap/ui/core/util/serializer/delegate/XML.js +1 -1
- package/src/sap/ui/core/ws/ReadyState.js +1 -1
- package/src/sap/ui/core/ws/SapPcpWebSocket.js +1 -1
- package/src/sap/ui/core/ws/WebSocket.js +1 -1
- package/src/sap/ui/debug/ControlTree.js +10 -4
- package/src/sap/ui/debug/DebugEnv.js +3 -4
- package/src/sap/ui/debug/Highlighter.js +8 -2
- package/src/sap/ui/debug/PropertyList.css +55 -0
- package/src/sap/ui/debug/PropertyList.js +111 -182
- package/src/sap/ui/model/Binding.js +174 -118
- package/src/sap/ui/model/ClientContextBinding.js +1 -1
- package/src/sap/ui/model/ClientListBinding.js +1 -3
- package/src/sap/ui/model/ClientModel.js +4 -4
- package/src/sap/ui/model/ClientPropertyBinding.js +4 -2
- package/src/sap/ui/model/ClientTreeBinding.js +15 -9
- package/src/sap/ui/model/ClientTreeBindingAdapter.js +28 -23
- package/src/sap/ui/model/CompositeBinding.js +98 -77
- package/src/sap/ui/model/CompositeDataState.js +2 -2
- package/src/sap/ui/model/CompositeType.js +2 -2
- package/src/sap/ui/model/Context.js +4 -2
- package/src/sap/ui/model/ContextBinding.js +6 -14
- package/src/sap/ui/model/DataState.js +2 -2
- package/src/sap/ui/model/Filter.js +255 -53
- package/src/sap/ui/model/FilterOperator.js +1 -1
- package/src/sap/ui/model/FilterProcessor.js +27 -17
- package/src/sap/ui/model/FilterType.js +1 -1
- package/src/sap/ui/model/ListBinding.js +180 -117
- package/src/sap/ui/model/MetaModel.js +4 -9
- package/src/sap/ui/model/Model.js +345 -294
- package/src/sap/ui/model/PropertyBinding.js +92 -58
- package/src/sap/ui/model/SelectionModel.js +2 -2
- package/src/sap/ui/model/SimpleType.js +2 -2
- package/src/sap/ui/model/Sorter.js +1 -1
- package/src/sap/ui/model/SorterProcessor.js +1 -1
- package/src/sap/ui/model/StaticBinding.js +1 -1
- package/src/sap/ui/model/TreeAutoExpandMode.js +2 -2
- package/src/sap/ui/model/TreeBinding.js +1 -1
- package/src/sap/ui/model/TreeBindingAdapter.js +251 -100
- package/src/sap/ui/model/TreeBindingCompatibilityAdapter.js +16 -9
- package/src/sap/ui/model/TreeBindingUtils.js +1 -0
- package/src/sap/ui/model/Type.js +1 -1
- package/src/sap/ui/model/analytics/AnalyticalBinding.js +8 -4
- package/src/sap/ui/model/analytics/AnalyticalTreeBindingAdapter.js +1 -1
- package/src/sap/ui/model/analytics/AnalyticalVersionInfo.js +1 -1
- package/src/sap/ui/model/analytics/BatchResponseCollector.js +1 -1
- package/src/sap/ui/model/analytics/ODataModelAdapter.js +1 -1
- package/src/sap/ui/model/analytics/odata4analytics.js +34 -25
- package/src/sap/ui/model/base/ManagedObjectModel.js +4 -0
- package/src/sap/ui/model/json/JSONListBinding.js +8 -5
- package/src/sap/ui/model/json/JSONModel.js +24 -15
- package/src/sap/ui/model/json/JSONPropertyBinding.js +4 -3
- package/src/sap/ui/model/json/JSONTreeBinding.js +1 -1
- package/src/sap/ui/model/message/MessageListBinding.js +6 -3
- package/src/sap/ui/model/message/MessageModel.js +23 -15
- package/src/sap/ui/model/message/MessagePropertyBinding.js +2 -2
- package/src/sap/ui/model/odata/AnnotationHelper.js +1 -1
- package/src/sap/ui/model/odata/AnnotationParser.js +1 -1
- package/src/sap/ui/model/odata/CountMode.js +1 -1
- package/src/sap/ui/model/odata/Filter.js +1 -1
- package/src/sap/ui/model/odata/ODataAnnotations.js +2 -2
- package/src/sap/ui/model/odata/ODataContextBinding.js +1 -1
- package/src/sap/ui/model/odata/ODataListBinding.js +1 -1
- package/src/sap/ui/model/odata/ODataMessageParser.js +2 -2
- package/src/sap/ui/model/odata/ODataMetaModel.js +5 -3
- package/src/sap/ui/model/odata/ODataMetadata.js +2 -2
- package/src/sap/ui/model/odata/ODataModel.js +8 -7
- package/src/sap/ui/model/odata/ODataPropertyBinding.js +1 -1
- package/src/sap/ui/model/odata/ODataTreeBinding.js +65 -33
- package/src/sap/ui/model/odata/ODataTreeBindingAdapter.js +1 -1
- package/src/sap/ui/model/odata/ODataTreeBindingFlat.js +2 -2
- package/src/sap/ui/model/odata/ODataUtils.js +13 -11
- package/src/sap/ui/model/odata/OperationMode.js +1 -1
- package/src/sap/ui/model/odata/_AnnotationHelperExpression.js +1 -1
- package/src/sap/ui/model/odata/type/Boolean.js +1 -1
- package/src/sap/ui/model/odata/type/Byte.js +1 -1
- package/src/sap/ui/model/odata/type/Currency.js +1 -1
- package/src/sap/ui/model/odata/type/Date.js +1 -1
- package/src/sap/ui/model/odata/type/DateTime.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeBase.js +1 -1
- package/src/sap/ui/model/odata/type/DateTimeOffset.js +1 -1
- package/src/sap/ui/model/odata/type/Decimal.js +1 -1
- package/src/sap/ui/model/odata/type/Double.js +1 -1
- package/src/sap/ui/model/odata/type/Guid.js +1 -1
- package/src/sap/ui/model/odata/type/Int.js +1 -1
- package/src/sap/ui/model/odata/type/Int16.js +1 -1
- package/src/sap/ui/model/odata/type/Int32.js +1 -1
- package/src/sap/ui/model/odata/type/Int64.js +1 -1
- package/src/sap/ui/model/odata/type/ODataType.js +1 -1
- package/src/sap/ui/model/odata/type/Raw.js +1 -1
- package/src/sap/ui/model/odata/type/SByte.js +1 -1
- package/src/sap/ui/model/odata/type/Single.js +1 -1
- package/src/sap/ui/model/odata/type/Stream.js +1 -1
- package/src/sap/ui/model/odata/type/String.js +1 -1
- package/src/sap/ui/model/odata/type/Time.js +1 -1
- package/src/sap/ui/model/odata/type/TimeOfDay.js +1 -1
- package/src/sap/ui/model/odata/type/Unit.js +1 -1
- package/src/sap/ui/model/odata/v2/Context.js +81 -9
- package/src/sap/ui/model/odata/v2/ODataAnnotations.js +3 -3
- package/src/sap/ui/model/odata/v2/ODataContextBinding.js +39 -49
- package/src/sap/ui/model/odata/v2/ODataListBinding.js +236 -73
- package/src/sap/ui/model/odata/v2/ODataModel.js +314 -164
- package/src/sap/ui/model/odata/v2/ODataTreeBinding.js +110 -97
- package/src/sap/ui/model/odata/v2/_CreatedContextsCache.js +129 -0
- package/src/sap/ui/model/odata/v4/Context.js +6 -3
- package/src/sap/ui/model/odata/v4/ODataBinding.js +5 -6
- package/src/sap/ui/model/odata/v4/ODataContextBinding.js +117 -40
- package/src/sap/ui/model/odata/v4/ODataListBinding.js +95 -15
- package/src/sap/ui/model/odata/v4/ODataMetaModel.js +44 -31
- package/src/sap/ui/model/odata/v4/ODataModel.js +86 -78
- package/src/sap/ui/model/odata/v4/ODataParentBinding.js +47 -28
- package/src/sap/ui/model/odata/v4/ODataPropertyBinding.js +11 -7
- package/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js +10 -3
- package/src/sap/ui/model/odata/v4/lib/_AggregationCache.js +8 -1
- package/src/sap/ui/model/odata/v4/lib/_Cache.js +24 -16
- package/src/sap/ui/model/odata/v4/lib/_Helper.js +32 -30
- package/src/sap/ui/model/odata/v4/lib/_Requestor.js +52 -17
- package/src/sap/ui/model/odata/v4/lib/_V2Requestor.js +2 -2
- package/src/sap/ui/model/resource/ResourceModel.js +6 -2
- package/src/sap/ui/model/resource/ResourcePropertyBinding.js +1 -1
- package/src/sap/ui/model/type/Boolean.js +2 -2
- package/src/sap/ui/model/type/Currency.js +2 -2
- package/src/sap/ui/model/type/Date.js +9 -3
- package/src/sap/ui/model/type/DateInterval.js +4 -2
- package/src/sap/ui/model/type/DateTime.js +2 -2
- package/src/sap/ui/model/type/DateTimeInterval.js +2 -2
- package/src/sap/ui/model/type/FileSize.js +4 -2
- package/src/sap/ui/model/type/Float.js +4 -2
- package/src/sap/ui/model/type/Integer.js +4 -2
- package/src/sap/ui/model/type/String.js +2 -2
- package/src/sap/ui/model/type/Time.js +2 -2
- package/src/sap/ui/model/type/TimeInterval.js +2 -2
- package/src/sap/ui/model/type/Unit.js +14 -7
- package/src/sap/ui/model/xml/XMLListBinding.js +15 -9
- package/src/sap/ui/model/xml/XMLModel.js +70 -41
- package/src/sap/ui/model/xml/XMLPropertyBinding.js +4 -4
- package/src/sap/ui/model/xml/XMLTreeBinding.js +5 -4
- package/src/sap/ui/performance/trace/Interaction.js +30 -15
- package/src/sap/ui/performance/trace/initTraces.js +1 -1
- package/src/sap/ui/qunit/QUnitUtils.js +3 -2
- package/src/sap/ui/qunit/utils/ControlIterator.js +1 -1
- package/src/sap/ui/qunit/utils/MemoryLeakCheck.js +9 -11
- package/src/sap/ui/test/TestUtils.js +11 -4
- package/src/sap/ui/test/actions/Drag.js +6 -2
- package/src/sap/ui/test/actions/Drop.js +6 -2
- package/src/sap/ui/test/actions/EnterText.js +6 -0
- package/src/sap/ui/test/actions/Press.js +6 -0
- package/src/sap/ui/test/actions/Scroll.js +6 -0
- package/src/sap/ui/test/autowaiter/_resourceWaiter.js +4 -4
- package/src/sap/ui/test/launchers/componentLauncher.js +0 -4
- package/src/sap/ui/test/matchers/I18NText.js +29 -11
- package/src/sap/ui/test/opaQunit.js +5 -0
- package/src/sap/ui/thirdparty/crossroads.js +6 -4
- package/src/sap/ui/thirdparty/hyphenopoly/Hyphenopoly.js +1196 -0
- package/src/sap/ui/thirdparty/hyphenopoly/Hyphenopoly_Loader.js +797 -0
- package/src/sap/ui/thirdparty/hyphenopoly/hyphenEngine.asm.js +108 -127
- package/src/sap/ui/thirdparty/hyphenopoly/hyphenEngine.wasm +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/bg.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/ca.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/da.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/de.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/el-monoton.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/en-us.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/es.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/et.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/fi.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/fr.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/hi.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/hr.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/hu.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/it.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/lt.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/nb-no.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/nl.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/pt.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/ru.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/sl.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/sv.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/th.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/tr.hpb +0 -0
- package/src/sap/ui/thirdparty/hyphenopoly/patterns/uk.hpb +0 -0
- package/src/sap/ui/thirdparty/jquery.js +9 -1
- package/src/sap/ui/thirdparty/qunit-2.js +1 -1
- package/src/sap/ui/thirdparty/qunit.js +1 -1
- package/src/sap/ui/util/Mobile.js +2 -20
- package/src/sap/ui/util/Storage.js +1 -1
- package/src/sap/ui/util/isCrossOriginURL.js +16 -6
- package/src/sap-ui-core-nojQuery.js +1 -1
- package/src/sap-ui-core.js +1 -1
- package/src/sap-ui-debug.js +3 -17
- package/ui5.yaml +5 -2
- package/src/sap/ui/core/support/plugins/MessageTest.js +0 -96
- package/src/sap/ui/thirdparty/hyphenopoly/hyphenopoly.bundle.js +0 -860
|
@@ -0,0 +1,1196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Hyphenopoly 3.4.0 - client side hyphenation for webbrowsers
|
|
3
|
+
* ©2019 Mathias Nater, Zürich (mathiasnater at gmail dot com)
|
|
4
|
+
* https://github.com/mnater/Hyphenopoly
|
|
5
|
+
*
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* http://mnater.github.io/Hyphenopoly/LICENSE
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* globals asmHyphenEngine:readonly, Hyphenopoly:readonly */
|
|
11
|
+
|
|
12
|
+
(function mainWrapper(w) {
|
|
13
|
+
"use strict";
|
|
14
|
+
var SOFTHYPHEN = String.fromCharCode(173);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create Object without standard Object-prototype
|
|
18
|
+
* @returns {Object} empty object
|
|
19
|
+
*/
|
|
20
|
+
function empty() {
|
|
21
|
+
return Object.create(null);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Polyfill Math.imul
|
|
26
|
+
* @param {number} a LHS
|
|
27
|
+
* @param {number} b RHS
|
|
28
|
+
* @returns {number} empty object
|
|
29
|
+
*/
|
|
30
|
+
/* eslint-disable no-bitwise */
|
|
31
|
+
Math.imul = Math.imul || function imul(a, b) {
|
|
32
|
+
var aHi = (a >>> 16) & 0xffff;
|
|
33
|
+
var aLo = a & 0xffff;
|
|
34
|
+
var bHi = (b >>> 16) & 0xffff;
|
|
35
|
+
var bLo = b & 0xffff;
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* The shift by 0 fixes the sign on the high part.
|
|
39
|
+
* The final |0 converts the unsigned value into a signed value
|
|
40
|
+
*/
|
|
41
|
+
return ((aLo * bLo) + ((((aHi * bLo) + (aLo * bHi)) << 16) >>> 0) | 0);
|
|
42
|
+
};
|
|
43
|
+
/* eslint-enable no-bitwise */
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set value and properties of object member
|
|
47
|
+
* Argument <props> is a bit pattern:
|
|
48
|
+
* 1. bit: configurable
|
|
49
|
+
* 2. bit: enumerable
|
|
50
|
+
* 3. bit writable
|
|
51
|
+
* e.g. 011(2) = 3(10) => configurable: f, enumerable: t, writable: t
|
|
52
|
+
* or 010(2) = 2(10) => configurable: f, enumerable: t, writable: f
|
|
53
|
+
* @param {any} val The value
|
|
54
|
+
* @param {number} props bitfield
|
|
55
|
+
* @returns {Object} Property object
|
|
56
|
+
*/
|
|
57
|
+
function setProp(val, props) {
|
|
58
|
+
/* eslint-disable no-bitwise, sort-keys */
|
|
59
|
+
return {
|
|
60
|
+
"configurable": (props & 4) > 0,
|
|
61
|
+
"enumerable": (props & 2) > 0,
|
|
62
|
+
"writable": (props & 1) > 0,
|
|
63
|
+
"value": val
|
|
64
|
+
};
|
|
65
|
+
/* eslint-enable no-bitwise, sort-keys */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Register copy event on element
|
|
70
|
+
* @param {Object} el The element
|
|
71
|
+
* @returns {undefined}
|
|
72
|
+
*/
|
|
73
|
+
function registerOnCopy(el) {
|
|
74
|
+
el.addEventListener(
|
|
75
|
+
"copy",
|
|
76
|
+
function oncopy(e) {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
var sel = w.getSelection();
|
|
79
|
+
var docFrag = sel.getRangeAt(0).cloneContents();
|
|
80
|
+
var div = document.createElement("div");
|
|
81
|
+
div.appendChild(docFrag);
|
|
82
|
+
var selectedHTML = div.innerHTML;
|
|
83
|
+
var selectedText = sel.toString();
|
|
84
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
85
|
+
e.clipboardData.setData("text/plain", selectedText.replace(new RegExp(SOFTHYPHEN, "g"), ""));
|
|
86
|
+
e.clipboardData.setData("text/html", selectedHTML.replace(new RegExp(SOFTHYPHEN, "g"), ""));
|
|
87
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
88
|
+
},
|
|
89
|
+
true
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
(function configurationFactory(H) {
|
|
94
|
+
var generalDefaults = Object.create(null, {
|
|
95
|
+
"defaultLanguage": setProp("en-us", 2),
|
|
96
|
+
"dontHyphenate": setProp((function createList() {
|
|
97
|
+
var r = empty();
|
|
98
|
+
var list = "abbr,acronym,audio,br,button,code,img,input,kbd,label,math,option,pre,samp,script,style,sub,sup,svg,textarea,var,video";
|
|
99
|
+
list.split(",").forEach(function add(value) {
|
|
100
|
+
/* eslint-disable security/detect-object-injection */
|
|
101
|
+
r[value] = true;
|
|
102
|
+
/* eslint-enable security/detect-object-injection */
|
|
103
|
+
});
|
|
104
|
+
return r;
|
|
105
|
+
}()), 2),
|
|
106
|
+
"dontHyphenateClass": setProp("donthyphenate", 2),
|
|
107
|
+
"exceptions": setProp(empty(), 2),
|
|
108
|
+
"keepAlive": setProp(true, 2),
|
|
109
|
+
"normalize": setProp(false, 2),
|
|
110
|
+
"safeCopy": setProp(true, 2),
|
|
111
|
+
"timeout": setProp(1000, 2)
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
var settings = Object.create(generalDefaults);
|
|
115
|
+
|
|
116
|
+
var perClassDefaults = Object.create(null, {
|
|
117
|
+
"compound": setProp("hyphen", 2),
|
|
118
|
+
"hyphen": setProp(SOFTHYPHEN, 2),
|
|
119
|
+
"leftmin": setProp(0, 2),
|
|
120
|
+
"leftminPerLang": setProp(0, 2),
|
|
121
|
+
"minWordLength": setProp(6, 2),
|
|
122
|
+
"mixedCase": setProp(true, 2),
|
|
123
|
+
"orphanControl": setProp(1, 2),
|
|
124
|
+
"rightmin": setProp(0, 2),
|
|
125
|
+
"rightminPerLang": setProp(0, 2)
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
Object.keys(H.setup).forEach(function copySettings(key) {
|
|
129
|
+
if (key === "selectors") {
|
|
130
|
+
var selectors = Object.keys(H.setup.selectors);
|
|
131
|
+
Object.defineProperty(
|
|
132
|
+
settings,
|
|
133
|
+
"selectors",
|
|
134
|
+
setProp(selectors, 2)
|
|
135
|
+
);
|
|
136
|
+
selectors.forEach(function copySelectors(sel) {
|
|
137
|
+
var tmp = empty();
|
|
138
|
+
/* eslint-disable security/detect-object-injection */
|
|
139
|
+
Object.keys(H.setup.selectors[sel]).forEach(
|
|
140
|
+
function copySelectorSettings(k) {
|
|
141
|
+
tmp[k] = setProp(H.setup.selectors[sel][k], 2);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
/* eslint-enable security/detect-object-injection */
|
|
145
|
+
Object.defineProperty(
|
|
146
|
+
settings,
|
|
147
|
+
sel,
|
|
148
|
+
setProp(Object.create(perClassDefaults, tmp), 2)
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
} else if (key === "dontHyphenate") {
|
|
152
|
+
var tmp = empty();
|
|
153
|
+
Object.keys(H.setup.dontHyphenate).forEach(
|
|
154
|
+
function copyTagNames(k) {
|
|
155
|
+
/* eslint-disable security/detect-object-injection */
|
|
156
|
+
tmp[k] = setProp(H.setup.dontHyphenate[k], 2);
|
|
157
|
+
/* eslint-enable security/detect-object-injection */
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
Object.defineProperty(
|
|
161
|
+
settings,
|
|
162
|
+
key,
|
|
163
|
+
setProp(
|
|
164
|
+
Object.create(generalDefaults.dontHyphenate, tmp), 3
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
} else {
|
|
168
|
+
/* eslint-disable security/detect-object-injection */
|
|
169
|
+
Object.defineProperty(
|
|
170
|
+
settings,
|
|
171
|
+
key,
|
|
172
|
+
setProp(H.setup[key], 3)
|
|
173
|
+
);
|
|
174
|
+
/* eslint-enable security/detect-object-injection */
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
H.c = settings;
|
|
178
|
+
}(Hyphenopoly));
|
|
179
|
+
|
|
180
|
+
(function H9Y(H) {
|
|
181
|
+
var C = H.c;
|
|
182
|
+
var mainLanguage = null;
|
|
183
|
+
var elements = null;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Factory for elements
|
|
187
|
+
* @returns {Object} elements-object
|
|
188
|
+
*/
|
|
189
|
+
function makeElementCollection() {
|
|
190
|
+
var list = new Map();
|
|
191
|
+
|
|
192
|
+
/*
|
|
193
|
+
* Counter counts the elements to be hyphenated.
|
|
194
|
+
* Needs to be an object (Pass by reference)
|
|
195
|
+
*/
|
|
196
|
+
var counter = [0];
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Add element to elements
|
|
200
|
+
* @param {object} el The element
|
|
201
|
+
* @param {string} lang The language of the element
|
|
202
|
+
* @param {string} sel The selector of the element
|
|
203
|
+
* @returns {Object} An element-object
|
|
204
|
+
*/
|
|
205
|
+
function add(el, lang, sel) {
|
|
206
|
+
var elo = {
|
|
207
|
+
"element": el,
|
|
208
|
+
"selector": sel
|
|
209
|
+
};
|
|
210
|
+
if (!list.has(lang)) {
|
|
211
|
+
list.set(lang, []);
|
|
212
|
+
}
|
|
213
|
+
list.get(lang).push(elo);
|
|
214
|
+
counter[0] += 1;
|
|
215
|
+
return elo;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Removes elements from the list and updates the counter
|
|
220
|
+
* @param {string} lang - The lang of the elements to remove
|
|
221
|
+
*/
|
|
222
|
+
function rem(lang) {
|
|
223
|
+
var langCount = 0;
|
|
224
|
+
if (list.has(lang)) {
|
|
225
|
+
langCount = list.get(lang).length;
|
|
226
|
+
list.delete(lang);
|
|
227
|
+
counter[0] -= langCount;
|
|
228
|
+
if (counter[0] === 0) {
|
|
229
|
+
H.events.dispatch("hyphenopolyEnd");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Execute fn for each element
|
|
236
|
+
* @param {function} fn The function to execute
|
|
237
|
+
* @returns {undefined}
|
|
238
|
+
*/
|
|
239
|
+
function each(fn) {
|
|
240
|
+
list.forEach(function eachElement(val, key) {
|
|
241
|
+
fn(key, val);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
"add": add,
|
|
247
|
+
"counter": counter,
|
|
248
|
+
"each": each,
|
|
249
|
+
"list": list,
|
|
250
|
+
"rem": rem
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get language of element by searching its parents or fallback
|
|
256
|
+
* @param {Object} el The element
|
|
257
|
+
* @param {boolean} fallback Will falback to mainlanguage
|
|
258
|
+
* @returns {string|null} The language or null
|
|
259
|
+
*/
|
|
260
|
+
function getLang(el, fallback) {
|
|
261
|
+
try {
|
|
262
|
+
return (el.getAttribute("lang"))
|
|
263
|
+
? el.getAttribute("lang").toLowerCase()
|
|
264
|
+
: el.tagName.toLowerCase() === "html"
|
|
265
|
+
? fallback
|
|
266
|
+
? mainLanguage
|
|
267
|
+
: null
|
|
268
|
+
: getLang(el.parentNode, fallback);
|
|
269
|
+
} catch (ignore) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Set mainLanguage
|
|
276
|
+
* @returns {undefined}
|
|
277
|
+
*/
|
|
278
|
+
function autoSetMainLanguage() {
|
|
279
|
+
var el = w.document.getElementsByTagName("html")[0];
|
|
280
|
+
mainLanguage = getLang(el, false);
|
|
281
|
+
if (!mainLanguage && C.defaultLanguage !== "") {
|
|
282
|
+
mainLanguage = C.defaultLanguage;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Check if node is matched by a given selector
|
|
288
|
+
* @param {Node} n The Node to check
|
|
289
|
+
* @param {String} sel Selector(s)
|
|
290
|
+
* @returns {Boolean} true if matched, false if not matched
|
|
291
|
+
*/
|
|
292
|
+
function nodeMatchedBy(n, sel) {
|
|
293
|
+
if (!n.matches) {
|
|
294
|
+
n.matches = n.msMatchesSelector || n.webkitMatchesSelector;
|
|
295
|
+
}
|
|
296
|
+
return n.matches(sel);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Collect elements that have a selector defined in C.selectors
|
|
301
|
+
* and add them to elements.
|
|
302
|
+
* @returns {undefined}
|
|
303
|
+
*/
|
|
304
|
+
function collectElements() {
|
|
305
|
+
elements = makeElementCollection();
|
|
306
|
+
|
|
307
|
+
var dontHyphenateSelector = (function createSel() {
|
|
308
|
+
var s = "." + H.c.dontHyphenateClass;
|
|
309
|
+
var k = null;
|
|
310
|
+
for (k in C.dontHyphenate) {
|
|
311
|
+
/* eslint-disable security/detect-object-injection */
|
|
312
|
+
if (C.dontHyphenate[k]) {
|
|
313
|
+
s += ", " + k;
|
|
314
|
+
}
|
|
315
|
+
/* eslint-enable security/detect-object-injection */
|
|
316
|
+
}
|
|
317
|
+
return s;
|
|
318
|
+
}());
|
|
319
|
+
var matchingSelectors = C.selectors.join(", ") + ", " + dontHyphenateSelector;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Get Language of Element or of one of its ancestors.
|
|
323
|
+
* @param {Object} el The element to scan
|
|
324
|
+
* @param {string} pLang The language of the parent element
|
|
325
|
+
* @returns {string} the language
|
|
326
|
+
*/
|
|
327
|
+
function getElementLanguage(el, pLang) {
|
|
328
|
+
if (el.lang && typeof el.lang === "string") {
|
|
329
|
+
return el.lang.toLowerCase();
|
|
330
|
+
} else if (pLang && pLang !== "") {
|
|
331
|
+
return pLang.toLowerCase();
|
|
332
|
+
}
|
|
333
|
+
return getLang(el, true);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Recursively walk all elements in el, lending lang and selName
|
|
338
|
+
* add them to elements if necessary.
|
|
339
|
+
* @param {Object} el The element to scan
|
|
340
|
+
* @param {string} pLang The language of the oarent element
|
|
341
|
+
* @param {string} sel The selector of the parent element
|
|
342
|
+
* @param {boolean} isChild If el is a child element
|
|
343
|
+
* @returns {undefined}
|
|
344
|
+
*/
|
|
345
|
+
function processElements(el, pLang, sel, isChild) {
|
|
346
|
+
isChild = isChild || false;
|
|
347
|
+
var eLang = getElementLanguage(el, pLang);
|
|
348
|
+
/* eslint-disable security/detect-object-injection */
|
|
349
|
+
if (H.cf.langs[eLang] === "H9Y") {
|
|
350
|
+
elements.add(el, eLang, sel);
|
|
351
|
+
if (!isChild && C.safeCopy) {
|
|
352
|
+
registerOnCopy(el);
|
|
353
|
+
}
|
|
354
|
+
} else if (!H.cf.langs[eLang]) {
|
|
355
|
+
H.events.dispatch("error", {
|
|
356
|
+
"lvl": "warn",
|
|
357
|
+
"msg": "Element with '" + eLang + "' found, but '" + eLang + ".hpb' not loaded. Check language tags!"
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/* eslint-enable security/detect-object-injection */
|
|
361
|
+
var cn = el.childNodes;
|
|
362
|
+
Array.prototype.forEach.call(cn, function eachChildNode(n) {
|
|
363
|
+
if (n.nodeType === 1 &&
|
|
364
|
+
!nodeMatchedBy(n, matchingSelectors)) {
|
|
365
|
+
processElements(n, eLang, sel, true);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
C.selectors.forEach(function eachSelector(sel) {
|
|
370
|
+
var nl = w.document.querySelectorAll(sel);
|
|
371
|
+
Array.prototype.forEach.call(nl, function eachNode(n) {
|
|
372
|
+
processElements(n, getLang(n, true), sel, false);
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
H.elementsReady = true;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
var wordHyphenatorPool = new Map();
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Factory for hyphenatorFunctions for a specific language and class
|
|
382
|
+
* @param {Object} lo Language-Object
|
|
383
|
+
* @param {string} lang The language
|
|
384
|
+
* @param {string} sel The selector
|
|
385
|
+
* @returns {function} The hyphenate function
|
|
386
|
+
*/
|
|
387
|
+
function createWordHyphenator(lo, lang, sel) {
|
|
388
|
+
/* eslint-disable-next-line security/detect-object-injection */
|
|
389
|
+
var classSettings = C[sel];
|
|
390
|
+
var hyphen = classSettings.hyphen;
|
|
391
|
+
lo.cache.set(sel, new Map());
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* HyphenateFunction for compound words
|
|
395
|
+
* @param {string} word The word
|
|
396
|
+
* @returns {string} The hyphenated compound word
|
|
397
|
+
*/
|
|
398
|
+
function hyphenateCompound(word) {
|
|
399
|
+
var zeroWidthSpace = String.fromCharCode(8203);
|
|
400
|
+
var parts = null;
|
|
401
|
+
var wordHyphenator = null;
|
|
402
|
+
if (classSettings.compound === "auto" ||
|
|
403
|
+
classSettings.compound === "all") {
|
|
404
|
+
wordHyphenator = createWordHyphenator(lo, lang, sel);
|
|
405
|
+
parts = word.split("-").map(function h7eParts(p) {
|
|
406
|
+
if (p.length >= classSettings.minWordLength) {
|
|
407
|
+
return wordHyphenator(p);
|
|
408
|
+
}
|
|
409
|
+
return p;
|
|
410
|
+
});
|
|
411
|
+
if (classSettings.compound === "auto") {
|
|
412
|
+
word = parts.join("-");
|
|
413
|
+
} else {
|
|
414
|
+
word = parts.join("-" + zeroWidthSpace);
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
word = word.replace("-", "-" + zeroWidthSpace);
|
|
418
|
+
}
|
|
419
|
+
return word;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Checks if a string is mixed case
|
|
424
|
+
* @param {string} s The string
|
|
425
|
+
* @returns {boolean} true if s is mixed case
|
|
426
|
+
*/
|
|
427
|
+
function isMixedCase(s) {
|
|
428
|
+
return Array.prototype.map.call(s, function mapper(c) {
|
|
429
|
+
return (c === c.toLowerCase());
|
|
430
|
+
}).some(function checker(v, i, a) {
|
|
431
|
+
return (v !== a[0]);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/* eslint-disable complexity */
|
|
436
|
+
/**
|
|
437
|
+
* HyphenateFunction for words (compound or not)
|
|
438
|
+
* @param {string} word The word
|
|
439
|
+
* @returns {string} The hyphenated word
|
|
440
|
+
*/
|
|
441
|
+
function hyphenator(word) {
|
|
442
|
+
var hw = lo.cache.get(sel).get(word);
|
|
443
|
+
if (!classSettings.mixedCase && isMixedCase(word)) {
|
|
444
|
+
hw = word;
|
|
445
|
+
}
|
|
446
|
+
if (!hw) {
|
|
447
|
+
if (lo.exceptions.has(word)) {
|
|
448
|
+
hw = lo.exceptions.get(word).replace(
|
|
449
|
+
/-/g,
|
|
450
|
+
classSettings.hyphen
|
|
451
|
+
);
|
|
452
|
+
} else if (word.indexOf("-") === -1) {
|
|
453
|
+
if (word.length > 61) {
|
|
454
|
+
H.events.dispatch("error", {
|
|
455
|
+
"lvl": "warn",
|
|
456
|
+
"msg": "found word longer than 61 characters"
|
|
457
|
+
});
|
|
458
|
+
hw = word;
|
|
459
|
+
} else {
|
|
460
|
+
/* eslint-disable security/detect-object-injection */
|
|
461
|
+
hw = lo.hyphenateFunction(
|
|
462
|
+
word,
|
|
463
|
+
hyphen.charCodeAt(0),
|
|
464
|
+
classSettings.leftminPerLang[lang],
|
|
465
|
+
classSettings.rightminPerLang[lang]
|
|
466
|
+
);
|
|
467
|
+
/* eslint-enable security/detect-object-injection */
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
hw = hyphenateCompound(word);
|
|
471
|
+
}
|
|
472
|
+
lo.cache.get(sel).set(word, hw);
|
|
473
|
+
}
|
|
474
|
+
return hw;
|
|
475
|
+
}
|
|
476
|
+
/* eslint-enable complexity */
|
|
477
|
+
wordHyphenatorPool.set(lang + "-" + sel, hyphenator);
|
|
478
|
+
return hyphenator;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
var orphanControllerPool = new Map();
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Factory for function that handles orphans
|
|
485
|
+
* @param {string} sel The selector
|
|
486
|
+
* @returns {function} The function created
|
|
487
|
+
*/
|
|
488
|
+
function createOrphanController(sel) {
|
|
489
|
+
/**
|
|
490
|
+
* Function template
|
|
491
|
+
* @param {string} ignore unused result of replace
|
|
492
|
+
* @param {string} leadingWhiteSpace The leading whiteSpace
|
|
493
|
+
* @param {string} lastWord The last word
|
|
494
|
+
* @param {string} trailingWhiteSpace The trailing whiteSpace
|
|
495
|
+
* @returns {string} Treated end of text
|
|
496
|
+
*/
|
|
497
|
+
function controlOrphans(
|
|
498
|
+
ignore,
|
|
499
|
+
leadingWhiteSpace,
|
|
500
|
+
lastWord,
|
|
501
|
+
trailingWhiteSpace
|
|
502
|
+
) {
|
|
503
|
+
/* eslint-disable security/detect-object-injection */
|
|
504
|
+
var classSettings = C[sel];
|
|
505
|
+
/* eslint-enable security/detect-object-injection */
|
|
506
|
+
var h = classSettings.hyphen;
|
|
507
|
+
if (".\\+*?[^]$(){}=!<>|:-".indexOf(classSettings.hyphen) !== -1) {
|
|
508
|
+
h = "\\" + classSettings.hyphen;
|
|
509
|
+
}
|
|
510
|
+
if (classSettings.orphanControl === 3 && leadingWhiteSpace === " ") {
|
|
511
|
+
leadingWhiteSpace = String.fromCharCode(160);
|
|
512
|
+
}
|
|
513
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
514
|
+
return leadingWhiteSpace + lastWord.replace(new RegExp(h, "g"), "") + trailingWhiteSpace;
|
|
515
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
516
|
+
}
|
|
517
|
+
orphanControllerPool.set(sel, controlOrphans);
|
|
518
|
+
return controlOrphans;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Hyphenate an entitiy (text string or Element-Object)
|
|
523
|
+
* @param {string} lang - the language of the string
|
|
524
|
+
* @param {string} sel - the selectorName of settings
|
|
525
|
+
* @param {string} entity - the entity to be hyphenated
|
|
526
|
+
* @returns {string | null} hyphenated str according to setting of sel
|
|
527
|
+
*/
|
|
528
|
+
function hyphenate(lang, sel, entity) {
|
|
529
|
+
var lo = H.languages.get(lang);
|
|
530
|
+
/* eslint-disable security/detect-object-injection */
|
|
531
|
+
var classSettings = C[sel];
|
|
532
|
+
/* eslint-enable security/detect-object-injection */
|
|
533
|
+
var minWordLength = classSettings.minWordLength;
|
|
534
|
+
var normalize = C.normalize &&
|
|
535
|
+
Boolean(String.prototype.normalize);
|
|
536
|
+
var poolKey = lang + "-" + sel;
|
|
537
|
+
var wordHyphenator = (wordHyphenatorPool.has(poolKey))
|
|
538
|
+
? wordHyphenatorPool.get(poolKey)
|
|
539
|
+
: createWordHyphenator(lo, lang, sel);
|
|
540
|
+
var orphanController = (orphanControllerPool.has(sel))
|
|
541
|
+
? orphanControllerPool.get(sel)
|
|
542
|
+
: createOrphanController(sel);
|
|
543
|
+
var re = lo.genRegExps.get(sel);
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Hyphenate text according to setting in sel
|
|
547
|
+
* @param {string} text - the strint to be hyphenated
|
|
548
|
+
* @returns {string} hyphenated string according to setting of sel
|
|
549
|
+
*/
|
|
550
|
+
function hyphenateText(text) {
|
|
551
|
+
var tn = null;
|
|
552
|
+
if (normalize) {
|
|
553
|
+
tn = text.normalize("NFC").replace(re, wordHyphenator);
|
|
554
|
+
} else {
|
|
555
|
+
tn = text.replace(re, wordHyphenator);
|
|
556
|
+
}
|
|
557
|
+
if (classSettings.orphanControl !== 1) {
|
|
558
|
+
tn = tn.replace(
|
|
559
|
+
// eslint-disable-next-line prefer-named-capture-group
|
|
560
|
+
/(\u0020*)(\S+)(\s*)$/,
|
|
561
|
+
orphanController
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
return tn;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Hyphenate element according to setting in sel
|
|
569
|
+
* @param {object} el - the HTMLElement to be hyphenated
|
|
570
|
+
* @returns {undefined}
|
|
571
|
+
*/
|
|
572
|
+
function hyphenateElement(el) {
|
|
573
|
+
H.events.dispatch("beforeElementHyphenation", {
|
|
574
|
+
"el": el,
|
|
575
|
+
"lang": lang
|
|
576
|
+
});
|
|
577
|
+
var cn = el.childNodes;
|
|
578
|
+
Array.prototype.forEach.call(cn, function eachChildNode(n) {
|
|
579
|
+
if (
|
|
580
|
+
n.nodeType === 3 &&
|
|
581
|
+
n.data.length >= minWordLength
|
|
582
|
+
) {
|
|
583
|
+
n.data = hyphenateText(n.data);
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
elements.counter[0] -= 1;
|
|
587
|
+
H.events.dispatch("afterElementHyphenation", {
|
|
588
|
+
"el": el,
|
|
589
|
+
"lang": lang
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
var r = null;
|
|
593
|
+
if (typeof entity === "string") {
|
|
594
|
+
r = hyphenateText(entity);
|
|
595
|
+
} else if (entity instanceof HTMLElement) {
|
|
596
|
+
hyphenateElement(entity);
|
|
597
|
+
}
|
|
598
|
+
return r;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
H.createHyphenator = function createHyphenator(lang) {
|
|
602
|
+
return function hyphenator(entity, sel) {
|
|
603
|
+
sel = sel || ".hyphenate";
|
|
604
|
+
return hyphenate(lang, sel, entity);
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
H.unhyphenate = function unhyphenate() {
|
|
609
|
+
elements.each(function eachLang(lang, els) {
|
|
610
|
+
els.forEach(function eachElem(elo) {
|
|
611
|
+
var n = elo.element.firstChild;
|
|
612
|
+
var h = C[elo.selector].hyphen;
|
|
613
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
614
|
+
n.data = n.data.replace(new RegExp(h, "g"), "");
|
|
615
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Hyphenate all elements with a given language
|
|
622
|
+
* @param {string} lang The language
|
|
623
|
+
* @param {Array} elArr Array of elements
|
|
624
|
+
* @returns {undefined}
|
|
625
|
+
*/
|
|
626
|
+
function hyphenateLangElements(lang, elArr) {
|
|
627
|
+
if (elArr) {
|
|
628
|
+
elArr.forEach(function eachElem(elo) {
|
|
629
|
+
hyphenate(lang, elo.selector, elo.element);
|
|
630
|
+
});
|
|
631
|
+
} else {
|
|
632
|
+
H.events.dispatch("error", {
|
|
633
|
+
"lvl": "warn",
|
|
634
|
+
"msg": "engine for language '" + lang + "' loaded, but no elements found."
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
if (elements.counter[0] === 0) {
|
|
638
|
+
H.events.dispatch("hyphenopolyEnd");
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Convert exceptions to object
|
|
644
|
+
* @param {string} exc comma separated list of exceptions
|
|
645
|
+
* @returns {Object} Map of exceptions
|
|
646
|
+
*/
|
|
647
|
+
function convertExceptions(exc) {
|
|
648
|
+
var r = new Map();
|
|
649
|
+
exc.split(", ").forEach(function eachExc(e) {
|
|
650
|
+
var key = e.replace(/-/g, "");
|
|
651
|
+
r.set(key, e);
|
|
652
|
+
});
|
|
653
|
+
return r;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Create lang Object
|
|
658
|
+
* @param {string} lang The language
|
|
659
|
+
* @returns {Object} The newly
|
|
660
|
+
*/
|
|
661
|
+
function createLangObj(lang) {
|
|
662
|
+
if (!H.languages) {
|
|
663
|
+
H.languages = new Map();
|
|
664
|
+
}
|
|
665
|
+
if (!H.languages.has(lang)) {
|
|
666
|
+
H.languages.set(lang, empty());
|
|
667
|
+
}
|
|
668
|
+
return H.languages.get(lang);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Setup lo
|
|
673
|
+
* @param {string} lang The language
|
|
674
|
+
* @param {function} hyphenateFunction The hyphenateFunction
|
|
675
|
+
* @param {string} alphabet List of used characters
|
|
676
|
+
* @param {number} leftmin leftmin
|
|
677
|
+
* @param {number} rightmin rightmin
|
|
678
|
+
* @returns {undefined}
|
|
679
|
+
*/
|
|
680
|
+
function prepareLanguagesObj(
|
|
681
|
+
lang,
|
|
682
|
+
hyphenateFunction,
|
|
683
|
+
alphabet,
|
|
684
|
+
leftmin,
|
|
685
|
+
rightmin
|
|
686
|
+
) {
|
|
687
|
+
alphabet = alphabet.replace(/-/g, "");
|
|
688
|
+
var lo = createLangObj(lang);
|
|
689
|
+
if (!lo.engineReady) {
|
|
690
|
+
lo.cache = new Map();
|
|
691
|
+
/* eslint-disable security/detect-object-injection */
|
|
692
|
+
if (H.c.exceptions.global) {
|
|
693
|
+
if (H.c.exceptions[lang]) {
|
|
694
|
+
H.c.exceptions[lang] += ", " + H.c.exceptions.global;
|
|
695
|
+
} else {
|
|
696
|
+
H.c.exceptions[lang] = H.c.exceptions.global;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if (H.c.exceptions[lang]) {
|
|
700
|
+
lo.exceptions = convertExceptions(H.c.exceptions[lang]);
|
|
701
|
+
delete H.c.exceptions[lang];
|
|
702
|
+
} else {
|
|
703
|
+
lo.exceptions = new Map();
|
|
704
|
+
}
|
|
705
|
+
/* eslint-enable security/detect-object-injection */
|
|
706
|
+
lo.genRegExps = new Map();
|
|
707
|
+
lo.leftmin = leftmin;
|
|
708
|
+
lo.rightmin = rightmin;
|
|
709
|
+
lo.hyphenateFunction = hyphenateFunction;
|
|
710
|
+
C.selectors.forEach(function eachSelector(sel) {
|
|
711
|
+
/* eslint-disable security/detect-object-injection */
|
|
712
|
+
var classSettings = C[sel];
|
|
713
|
+
/* eslint-enable security/detect-object-injection */
|
|
714
|
+
if (classSettings.leftminPerLang === 0) {
|
|
715
|
+
Object.defineProperty(
|
|
716
|
+
classSettings,
|
|
717
|
+
"leftminPerLang",
|
|
718
|
+
setProp(empty(), 2)
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
if (classSettings.rightminPerLang === 0) {
|
|
722
|
+
Object.defineProperty(
|
|
723
|
+
classSettings,
|
|
724
|
+
"rightminPerLang",
|
|
725
|
+
setProp(empty(), 2)
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
/* eslint-disable security/detect-object-injection */
|
|
729
|
+
if (classSettings.leftminPerLang[lang]) {
|
|
730
|
+
classSettings.leftminPerLang[lang] = Math.max(
|
|
731
|
+
lo.leftmin,
|
|
732
|
+
classSettings.leftmin,
|
|
733
|
+
classSettings.leftminPerLang[lang]
|
|
734
|
+
);
|
|
735
|
+
} else {
|
|
736
|
+
classSettings.leftminPerLang[lang] = Math.max(
|
|
737
|
+
lo.leftmin,
|
|
738
|
+
classSettings.leftmin
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
if (classSettings.rightminPerLang[lang]) {
|
|
742
|
+
classSettings.rightminPerLang[lang] = Math.max(
|
|
743
|
+
lo.rightmin,
|
|
744
|
+
classSettings.rightmin,
|
|
745
|
+
classSettings.rightminPerLang[lang]
|
|
746
|
+
);
|
|
747
|
+
} else {
|
|
748
|
+
classSettings.rightminPerLang[lang] = Math.max(
|
|
749
|
+
lo.rightmin,
|
|
750
|
+
classSettings.rightmin
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
/* eslint-enable security/detect-object-injection */
|
|
754
|
+
|
|
755
|
+
/*
|
|
756
|
+
* Find words with characters from `alphabet` and
|
|
757
|
+
* `Zero Width Non-Joiner` and `-` with a min length.
|
|
758
|
+
*
|
|
759
|
+
* This regexp is not perfect. It also finds parts of words
|
|
760
|
+
* that follow a character that is not in the `alphabet`.
|
|
761
|
+
* Word delimiters are not taken in account.
|
|
762
|
+
*/
|
|
763
|
+
/* eslint-disable security/detect-non-literal-regexp */
|
|
764
|
+
lo.genRegExps.set(sel, new RegExp("[\\w" + alphabet + String.fromCharCode(8204) + "-]{" + classSettings.minWordLength + ",}", "gi"));
|
|
765
|
+
/* eslint-enable security/detect-non-literal-regexp */
|
|
766
|
+
});
|
|
767
|
+
lo.engineReady = true;
|
|
768
|
+
}
|
|
769
|
+
Hyphenopoly.events.dispatch("engineReady", {"msg": lang});
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Calculate heap size for (w)asm
|
|
774
|
+
* wasm page size: 65536 = 64 Ki
|
|
775
|
+
* asm: http://asmjs.org/spec/latest/#linking-0
|
|
776
|
+
* @param {number} targetSize The targetet Size
|
|
777
|
+
* @returns {number} The necessary heap size
|
|
778
|
+
*/
|
|
779
|
+
function calculateHeapSize(targetSize) {
|
|
780
|
+
/* eslint-disable no-bitwise */
|
|
781
|
+
if (H.cf.wasm) {
|
|
782
|
+
return Math.ceil(targetSize / 65536) * 65536;
|
|
783
|
+
}
|
|
784
|
+
var exp = Math.ceil(Math.log(targetSize) * Math.LOG2E);
|
|
785
|
+
if (exp <= 12) {
|
|
786
|
+
return 1 << 12;
|
|
787
|
+
}
|
|
788
|
+
if (exp < 24) {
|
|
789
|
+
return 1 << exp;
|
|
790
|
+
}
|
|
791
|
+
return Math.ceil(targetSize / (1 << 24)) * (1 << 24);
|
|
792
|
+
/* eslint-enable no-bitwise */
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Polyfill for TextDecoder
|
|
797
|
+
*/
|
|
798
|
+
var decode = (function makeDecoder() {
|
|
799
|
+
if (w.TextDecoder) {
|
|
800
|
+
var utf16ledecoder = new TextDecoder("utf-16le");
|
|
801
|
+
return function decoder(ui16) {
|
|
802
|
+
return utf16ledecoder.decode(ui16);
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
return function decoder(ui16) {
|
|
806
|
+
return String.fromCharCode.apply(null, ui16);
|
|
807
|
+
};
|
|
808
|
+
}());
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Calculate Base Data
|
|
812
|
+
*
|
|
813
|
+
* Build Heap (the heap object's byteLength must be
|
|
814
|
+
* either 2^n for n in [12, 24)
|
|
815
|
+
* or 2^24 · n for n ≥ 1;)
|
|
816
|
+
*
|
|
817
|
+
* MEMORY LAYOUT:
|
|
818
|
+
*
|
|
819
|
+
* -------------------- <- Offset 0
|
|
820
|
+
* | translateMap |
|
|
821
|
+
* | keys: |
|
|
822
|
+
* |256 chars * 2Bytes|
|
|
823
|
+
* | + |
|
|
824
|
+
* | values: |
|
|
825
|
+
* |256 chars * 1Byte |
|
|
826
|
+
* -------------------- <- 768 Bytes
|
|
827
|
+
* | alphabet |
|
|
828
|
+
* |256 chars * 2Bytes|
|
|
829
|
+
* -------------------- <- valueStoreOffset (vs) = 1280
|
|
830
|
+
* | valueStore |
|
|
831
|
+
* | 1 Byte |
|
|
832
|
+
* |* valueStoreLength|
|
|
833
|
+
* --------------------
|
|
834
|
+
* | align to 4Bytes |
|
|
835
|
+
* -------------------- <- patternTrieOffset (pt)
|
|
836
|
+
* | patternTrie |
|
|
837
|
+
* | 4 Bytes |
|
|
838
|
+
* |*patternTrieLength|
|
|
839
|
+
* -------------------- <- wordOffset (wo)
|
|
840
|
+
* | wordStore |
|
|
841
|
+
* | Uint16[64] | 128 bytes
|
|
842
|
+
* -------------------- <- translatedWordOffset (tw)
|
|
843
|
+
* | transl.WordStore |
|
|
844
|
+
* | Uint8[64] | 64 bytes
|
|
845
|
+
* -------------------- <- hyphenPointsOffset (hp)
|
|
846
|
+
* | hyphenPoints |
|
|
847
|
+
* | Uint8[64] | 64 bytes
|
|
848
|
+
* -------------------- <- hyphenatedWordOffset (hw)
|
|
849
|
+
* | hyphenatedWord |
|
|
850
|
+
* | Uint16[128] | 256 Bytes
|
|
851
|
+
* -------------------- <- hpbOffset (ho) -
|
|
852
|
+
* | HEADER | |
|
|
853
|
+
* | 6*4 Bytes | |
|
|
854
|
+
* | 24 Bytes | |
|
|
855
|
+
* -------------------- |
|
|
856
|
+
* | PATTERN LIC | |
|
|
857
|
+
* | variable Length | |
|
|
858
|
+
* -------------------- |
|
|
859
|
+
* | align to 4Bytes | } this is the .hpb-file
|
|
860
|
+
* -------------------- <- hpbTranslateOffset |
|
|
861
|
+
* | TRANSLATE | |
|
|
862
|
+
* | 2 + [0] * 2Bytes | |
|
|
863
|
+
* -------------------- <-hpbPatternsOffset(po)|
|
|
864
|
+
* | PATTERNS | |
|
|
865
|
+
* | patternsLength | |
|
|
866
|
+
* -------------------- <- heapEnd -
|
|
867
|
+
* | align to 4Bytes |
|
|
868
|
+
* -------------------- <- heapSize (hs)
|
|
869
|
+
* @param {Object} hpbBuf FileBuffer from .hpb-file
|
|
870
|
+
* @returns {Object} baseData-object
|
|
871
|
+
*/
|
|
872
|
+
function calculateBaseData(hpbBuf) {
|
|
873
|
+
var hpbMetaData = new Uint32Array(hpbBuf).subarray(0, 8);
|
|
874
|
+
if (hpbMetaData[0] !== 40005736) {
|
|
875
|
+
/*
|
|
876
|
+
* Pattern files must begin with "hpb2"
|
|
877
|
+
* Get current utf8 values with
|
|
878
|
+
* `new Uint8Array(Uint32Array.of(hpbMetaData[0]).buffer)`
|
|
879
|
+
*/
|
|
880
|
+
H.events.dispatch("error", {
|
|
881
|
+
"lvl": "error",
|
|
882
|
+
"msg": "Pattern file format error: " + new Uint8Array(Uint32Array.of(hpbMetaData[0]).buffer)
|
|
883
|
+
});
|
|
884
|
+
throw new Error("Pattern file format error!");
|
|
885
|
+
}
|
|
886
|
+
var valueStoreLength = hpbMetaData[7];
|
|
887
|
+
var valueStoreOffset = 1280;
|
|
888
|
+
var patternTrieOffset = valueStoreOffset + valueStoreLength +
|
|
889
|
+
(4 - ((valueStoreOffset + valueStoreLength) % 4));
|
|
890
|
+
var wordOffset = patternTrieOffset + (hpbMetaData[6] * 4);
|
|
891
|
+
return {
|
|
892
|
+
// Set hpbOffset
|
|
893
|
+
"ho": wordOffset + 512,
|
|
894
|
+
// Set hyphenPointsOffset
|
|
895
|
+
"hp": wordOffset + 192,
|
|
896
|
+
// Set heapSize
|
|
897
|
+
"hs": Math.max(calculateHeapSize(wordOffset + 512 + hpbMetaData[2] + hpbMetaData[3]), 32 * 1024 * 64),
|
|
898
|
+
// Set hyphenatedWordOffset
|
|
899
|
+
"hw": wordOffset + 256,
|
|
900
|
+
// Set leftmin
|
|
901
|
+
"lm": hpbMetaData[4],
|
|
902
|
+
// Set patternsLength
|
|
903
|
+
"pl": hpbMetaData[3],
|
|
904
|
+
// Set hpbPatternsOffset
|
|
905
|
+
"po": wordOffset + 512 + hpbMetaData[2],
|
|
906
|
+
// Set patternTrieOffset
|
|
907
|
+
"pt": patternTrieOffset,
|
|
908
|
+
// Set rightmin
|
|
909
|
+
"rm": hpbMetaData[5],
|
|
910
|
+
// Set translateOffset
|
|
911
|
+
"to": wordOffset + 512 + hpbMetaData[1],
|
|
912
|
+
// Set translatedWordOffset
|
|
913
|
+
"tw": wordOffset + 128,
|
|
914
|
+
// Set valueStoreOffset
|
|
915
|
+
"vs": valueStoreOffset,
|
|
916
|
+
// Set wordOffset
|
|
917
|
+
"wo": wordOffset
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Setup env for hyphenateFunction
|
|
923
|
+
* @param {Object} baseData baseData
|
|
924
|
+
* @param {function} hyphenateFunc hyphenateFunction
|
|
925
|
+
* @returns {function} hyphenateFunction with closured environment
|
|
926
|
+
*/
|
|
927
|
+
function encloseHyphenateFunction(baseData, hyphenateFunc) {
|
|
928
|
+
/* eslint-disable no-bitwise */
|
|
929
|
+
var heapBuffer = H.cf.wasm
|
|
930
|
+
? baseData.wasmMemory.buffer
|
|
931
|
+
: baseData.heapBuffer;
|
|
932
|
+
var wordStore = (new Uint16Array(heapBuffer)).subarray(
|
|
933
|
+
baseData.wo >> 1,
|
|
934
|
+
(baseData.wo >> 1) + 64
|
|
935
|
+
);
|
|
936
|
+
var hydWrdStore = (new Uint16Array(heapBuffer)).subarray(
|
|
937
|
+
baseData.hw >> 1,
|
|
938
|
+
(baseData.hw >> 1) + 128
|
|
939
|
+
);
|
|
940
|
+
/* eslint-enable no-bitwise */
|
|
941
|
+
wordStore[0] = 95;
|
|
942
|
+
return function enclHyphenate(word, hyphencc, leftmin, rightmin) {
|
|
943
|
+
var i = 0;
|
|
944
|
+
var cc = 0;
|
|
945
|
+
do {
|
|
946
|
+
cc = word.charCodeAt(i);
|
|
947
|
+
i += 1;
|
|
948
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
949
|
+
wordStore[i] = cc;
|
|
950
|
+
} while (cc);
|
|
951
|
+
/* eslint-disable security/detect-object-injection */
|
|
952
|
+
wordStore[i] = 95;
|
|
953
|
+
wordStore[i + 1] = 0;
|
|
954
|
+
/* eslint-enable security/detect-object-injection */
|
|
955
|
+
if (hyphenateFunc(leftmin, rightmin, hyphencc) === 1) {
|
|
956
|
+
word = decode(hydWrdStore.subarray(1, hydWrdStore[0] + 1));
|
|
957
|
+
}
|
|
958
|
+
return word;
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Instantiate Wasm Engine
|
|
964
|
+
* @param {string} lang The language
|
|
965
|
+
* @returns {undefined}
|
|
966
|
+
*/
|
|
967
|
+
function instantiateWasmEngine(lang) {
|
|
968
|
+
Promise.all([H.bins.get(lang), H.bins.get("hyphenEngine")]).then(
|
|
969
|
+
function onAll(binaries) {
|
|
970
|
+
var hpbBuf = binaries[0];
|
|
971
|
+
var baseData = calculateBaseData(hpbBuf);
|
|
972
|
+
var wasmModule = binaries[1];
|
|
973
|
+
var specMem = H.specMems.get(lang);
|
|
974
|
+
var wasmMemory = (
|
|
975
|
+
specMem.buffer.byteLength >= baseData.hs
|
|
976
|
+
)
|
|
977
|
+
? specMem
|
|
978
|
+
: new WebAssembly.Memory({
|
|
979
|
+
"initial": baseData.hs / 65536,
|
|
980
|
+
"maximum": 256
|
|
981
|
+
});
|
|
982
|
+
var ui32wasmMemory = new Uint32Array(wasmMemory.buffer);
|
|
983
|
+
ui32wasmMemory.set(
|
|
984
|
+
new Uint32Array(hpbBuf),
|
|
985
|
+
// eslint-disable-next-line no-bitwise
|
|
986
|
+
baseData.ho >> 2
|
|
987
|
+
);
|
|
988
|
+
baseData.wasmMemory = wasmMemory;
|
|
989
|
+
WebAssembly.instantiate(wasmModule, {
|
|
990
|
+
"env": {
|
|
991
|
+
"memory": baseData.wasmMemory,
|
|
992
|
+
"memoryBase": 0
|
|
993
|
+
},
|
|
994
|
+
"x": baseData
|
|
995
|
+
}).then(
|
|
996
|
+
function runWasm(result) {
|
|
997
|
+
var alphalen = result.exports.convert();
|
|
998
|
+
prepareLanguagesObj(
|
|
999
|
+
lang,
|
|
1000
|
+
encloseHyphenateFunction(
|
|
1001
|
+
baseData,
|
|
1002
|
+
result.exports.hyphenate
|
|
1003
|
+
),
|
|
1004
|
+
decode(
|
|
1005
|
+
(new Uint16Array(wasmMemory.buffer)).
|
|
1006
|
+
subarray(385, 384 + alphalen)
|
|
1007
|
+
),
|
|
1008
|
+
baseData.lm,
|
|
1009
|
+
baseData.rm
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Instantiate asm Engine
|
|
1019
|
+
* @param {string} lang The language
|
|
1020
|
+
* @returns {undefined}
|
|
1021
|
+
*/
|
|
1022
|
+
function instantiateAsmEngine(lang) {
|
|
1023
|
+
var hpbBuf = H.bins.get(lang);
|
|
1024
|
+
var baseData = calculateBaseData(hpbBuf);
|
|
1025
|
+
var specMem = H.specMems.get(lang);
|
|
1026
|
+
var heapBuffer = (specMem.byteLength >= baseData.hs)
|
|
1027
|
+
? specMem
|
|
1028
|
+
: new ArrayBuffer(baseData.hs);
|
|
1029
|
+
var ui8Heap = new Uint8Array(heapBuffer);
|
|
1030
|
+
var ui8Patterns = new Uint8Array(hpbBuf);
|
|
1031
|
+
ui8Heap.set(ui8Patterns, baseData.ho);
|
|
1032
|
+
baseData.heapBuffer = heapBuffer;
|
|
1033
|
+
var theHyphenEngine = asmHyphenEngine(
|
|
1034
|
+
{
|
|
1035
|
+
"Int32Array": w.Int32Array,
|
|
1036
|
+
"Math": Math,
|
|
1037
|
+
"Uint16Array": w.Uint16Array,
|
|
1038
|
+
"Uint8Array": w.Uint8Array
|
|
1039
|
+
},
|
|
1040
|
+
baseData,
|
|
1041
|
+
baseData.heapBuffer
|
|
1042
|
+
);
|
|
1043
|
+
var alphalen = theHyphenEngine.convert();
|
|
1044
|
+
prepareLanguagesObj(
|
|
1045
|
+
lang,
|
|
1046
|
+
encloseHyphenateFunction(baseData, theHyphenEngine.hyphenate),
|
|
1047
|
+
decode(
|
|
1048
|
+
(new Uint16Array(heapBuffer)).
|
|
1049
|
+
subarray(385, 384 + alphalen)
|
|
1050
|
+
),
|
|
1051
|
+
baseData.lm,
|
|
1052
|
+
baseData.rm
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
var engineInstantiator = null;
|
|
1057
|
+
var hpb = [];
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Instantiate hyphenEngines for languages
|
|
1061
|
+
* @param {string} lang The language
|
|
1062
|
+
* @param {string} engineType The engineType: "wasm" or "asm"
|
|
1063
|
+
* @returns {undefined}
|
|
1064
|
+
*/
|
|
1065
|
+
function prepare(lang, engineType) {
|
|
1066
|
+
if (lang === "*") {
|
|
1067
|
+
if (engineType === "wasm") {
|
|
1068
|
+
engineInstantiator = instantiateWasmEngine;
|
|
1069
|
+
} else if (engineType === "asm") {
|
|
1070
|
+
engineInstantiator = instantiateAsmEngine;
|
|
1071
|
+
}
|
|
1072
|
+
hpb.forEach(function eachHbp(hpbLang) {
|
|
1073
|
+
engineInstantiator(hpbLang);
|
|
1074
|
+
});
|
|
1075
|
+
} else if (engineInstantiator) {
|
|
1076
|
+
engineInstantiator(lang);
|
|
1077
|
+
} else {
|
|
1078
|
+
hpb.push(lang);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
H.events.define(
|
|
1083
|
+
"contentLoaded",
|
|
1084
|
+
function onContentLoaded() {
|
|
1085
|
+
autoSetMainLanguage();
|
|
1086
|
+
collectElements();
|
|
1087
|
+
H.events.dispatch("elementsReady");
|
|
1088
|
+
},
|
|
1089
|
+
false
|
|
1090
|
+
);
|
|
1091
|
+
|
|
1092
|
+
H.events.define(
|
|
1093
|
+
"elementsReady",
|
|
1094
|
+
function onElementsReady() {
|
|
1095
|
+
elements.each(function eachElem(lang, values) {
|
|
1096
|
+
if (H.languages &&
|
|
1097
|
+
H.languages.has(lang) &&
|
|
1098
|
+
H.languages.get(lang).engineReady
|
|
1099
|
+
) {
|
|
1100
|
+
hyphenateLangElements(lang, values);
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
},
|
|
1104
|
+
false
|
|
1105
|
+
);
|
|
1106
|
+
|
|
1107
|
+
H.events.define(
|
|
1108
|
+
"engineLoaded",
|
|
1109
|
+
function onEngineLoaded(e) {
|
|
1110
|
+
prepare("*", e.msg);
|
|
1111
|
+
},
|
|
1112
|
+
false
|
|
1113
|
+
);
|
|
1114
|
+
|
|
1115
|
+
H.events.define(
|
|
1116
|
+
"hpbLoaded",
|
|
1117
|
+
function onHpbLoaded(e) {
|
|
1118
|
+
prepare(e.msg, "*");
|
|
1119
|
+
},
|
|
1120
|
+
false
|
|
1121
|
+
);
|
|
1122
|
+
|
|
1123
|
+
H.events.addListener(
|
|
1124
|
+
"loadError",
|
|
1125
|
+
function onLoadError(e) {
|
|
1126
|
+
if (e.msg !== "wasm") {
|
|
1127
|
+
elements.rem(e.name);
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
false
|
|
1131
|
+
);
|
|
1132
|
+
|
|
1133
|
+
H.events.define(
|
|
1134
|
+
"engineReady",
|
|
1135
|
+
function onEngineReady(e) {
|
|
1136
|
+
if (H.elementsReady) {
|
|
1137
|
+
hyphenateLangElements(e.msg, elements.list.get(e.msg));
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1140
|
+
false
|
|
1141
|
+
);
|
|
1142
|
+
|
|
1143
|
+
H.events.define(
|
|
1144
|
+
"hyphenopolyStart",
|
|
1145
|
+
null,
|
|
1146
|
+
true
|
|
1147
|
+
);
|
|
1148
|
+
|
|
1149
|
+
H.events.define(
|
|
1150
|
+
"hyphenopolyEnd",
|
|
1151
|
+
function def() {
|
|
1152
|
+
w.clearTimeout(C.timeOutHandler);
|
|
1153
|
+
if (C.hide !== "none") {
|
|
1154
|
+
H.toggle("on");
|
|
1155
|
+
}
|
|
1156
|
+
if (!C.keepAlive) {
|
|
1157
|
+
window.Hyphenopoly = null;
|
|
1158
|
+
}
|
|
1159
|
+
},
|
|
1160
|
+
false
|
|
1161
|
+
);
|
|
1162
|
+
|
|
1163
|
+
H.events.define(
|
|
1164
|
+
"beforeElementHyphenation",
|
|
1165
|
+
null,
|
|
1166
|
+
true
|
|
1167
|
+
);
|
|
1168
|
+
|
|
1169
|
+
H.events.define(
|
|
1170
|
+
"afterElementHyphenation",
|
|
1171
|
+
null,
|
|
1172
|
+
true
|
|
1173
|
+
);
|
|
1174
|
+
|
|
1175
|
+
H.events.tempRegister.forEach(function eachEo(eo) {
|
|
1176
|
+
H.events.addListener(eo.name, eo.handler, false);
|
|
1177
|
+
});
|
|
1178
|
+
delete H.events.tempRegister;
|
|
1179
|
+
|
|
1180
|
+
H.events.dispatch("hyphenopolyStart", {"msg": "Hyphenopoly started"});
|
|
1181
|
+
|
|
1182
|
+
w.clearTimeout(H.c.timeOutHandler);
|
|
1183
|
+
|
|
1184
|
+
Object.defineProperty(C, "timeOutHandler", setProp(
|
|
1185
|
+
w.setTimeout(function ontimeout() {
|
|
1186
|
+
H.events.dispatch("timeout", {"delay": C.timeout});
|
|
1187
|
+
}, C.timeout),
|
|
1188
|
+
2
|
|
1189
|
+
));
|
|
1190
|
+
|
|
1191
|
+
H.events.deferred.forEach(function eachDeferred(deferredeo) {
|
|
1192
|
+
H.events.dispatch(deferredeo.name, deferredeo.data);
|
|
1193
|
+
});
|
|
1194
|
+
delete H.events.deferred;
|
|
1195
|
+
}(Hyphenopoly));
|
|
1196
|
+
}(window));
|