instantsearch.js 4.49.0 → 4.49.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/README.md +3 -3
- package/cjs/components/Answers/Answers.js +6 -16
- package/cjs/components/Breadcrumb/Breadcrumb.js +5 -12
- package/cjs/components/ClearRefinements/ClearRefinements.js +4 -11
- package/cjs/components/CurrentRefinements/CurrentRefinements.js +5 -12
- package/cjs/components/GeoSearchControls/GeoSearchButton.js +4 -6
- package/cjs/components/GeoSearchControls/GeoSearchControls.js +11 -20
- package/cjs/components/GeoSearchControls/GeoSearchToggle.js +4 -6
- package/cjs/components/Highlight/Highlight.js +3 -11
- package/cjs/components/Hits/Hits.js +8 -20
- package/cjs/components/InfiniteHits/InfiniteHits.js +13 -25
- package/cjs/components/InternalHighlight/InternalHighlight.js +0 -3
- package/cjs/components/MenuSelect/MenuSelect.js +9 -19
- package/cjs/components/Pagination/Pagination.js +10 -17
- package/cjs/components/Panel/Panel.js +7 -26
- package/cjs/components/PoweredBy/PoweredBy.js +4 -5
- package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +2 -6
- package/cjs/components/RangeInput/RangeInput.js +16 -48
- package/cjs/components/RefinementList/RefinementList.js +19 -73
- package/cjs/components/RefinementList/RefinementListItem.js +8 -14
- package/cjs/components/RelevantSort/RelevantSort.js +4 -8
- package/cjs/components/ReverseHighlight/ReverseHighlight.js +3 -11
- package/cjs/components/ReverseSnippet/ReverseSnippet.js +3 -11
- package/cjs/components/SearchBox/SearchBox.js +25 -69
- package/cjs/components/Selector/Selector.js +3 -6
- package/cjs/components/Slider/Pit.js +3 -10
- package/cjs/components/Slider/Rheostat.js +63 -131
- package/cjs/components/Slider/Slider.js +28 -65
- package/cjs/components/Snippet/Snippet.js +3 -11
- package/cjs/components/Stats/Stats.js +7 -20
- package/cjs/components/Template/Template.js +8 -37
- package/cjs/components/ToggleRefinement/ToggleRefinement.js +4 -10
- package/cjs/components/VoiceSearch/VoiceSearch.js +8 -15
- package/cjs/connectors/answers/connectAnswers.js +21 -36
- package/cjs/connectors/autocomplete/connectAutocomplete.js +8 -25
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +17 -48
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +27 -45
- package/cjs/connectors/configure/connectConfigure.js +6 -20
- package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -36
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +18 -57
- package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -37
- package/cjs/connectors/geo-search/connectGeoSearch.js +17 -47
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -74
- package/cjs/connectors/hits/connectHits.js +10 -26
- package/cjs/connectors/hits/connectHitsWithInsights.js +0 -4
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +15 -38
- package/cjs/connectors/index.js +62 -96
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +26 -62
- package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +0 -4
- package/cjs/connectors/menu/connectMenu.js +28 -66
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +24 -78
- package/cjs/connectors/pagination/Paginator.js +3 -20
- package/cjs/connectors/pagination/connectPagination.js +8 -25
- package/cjs/connectors/powered-by/connectPoweredBy.js +4 -13
- package/cjs/connectors/query-rules/connectQueryRules.js +32 -56
- package/cjs/connectors/range/connectRange.js +41 -101
- package/cjs/connectors/rating-menu/connectRatingMenu.js +23 -79
- package/cjs/connectors/refinement-list/connectRefinementList.js +37 -70
- package/cjs/connectors/relevant-sort/connectRelevantSort.js +4 -14
- package/cjs/connectors/search-box/connectSearchBox.js +7 -23
- package/cjs/connectors/sort-by/connectSortBy.js +11 -21
- package/cjs/connectors/stats/connectStats.js +4 -11
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +29 -63
- package/cjs/connectors/voice-search/connectVoiceSearch.js +13 -35
- package/cjs/helpers/components/Highlight.js +4 -12
- package/cjs/helpers/components/ReverseHighlight.js +7 -19
- package/cjs/helpers/components/ReverseSnippet.js +7 -19
- package/cjs/helpers/components/Snippet.js +4 -12
- package/cjs/helpers/components/index.js +0 -8
- package/cjs/helpers/get-insights-anonymous-user-token.js +7 -12
- package/cjs/helpers/highlight.js +10 -16
- package/cjs/helpers/index.js +17 -31
- package/cjs/helpers/insights.js +5 -17
- package/cjs/helpers/reverseHighlight.js +10 -16
- package/cjs/helpers/reverseSnippet.js +10 -16
- package/cjs/helpers/snippet.js +10 -16
- package/cjs/index.js +3 -18
- package/cjs/lib/InstantSearch.js +79 -180
- package/cjs/lib/createHelpers.js +4 -11
- package/cjs/lib/formatNumber.js +0 -1
- package/cjs/lib/infiniteHitsCache/index.js +0 -2
- package/cjs/lib/infiniteHitsCache/sessionStorage.js +9 -18
- package/cjs/lib/insights/client.js +8 -34
- package/cjs/lib/insights/index.js +7 -13
- package/cjs/lib/insights/listener.js +4 -20
- package/cjs/lib/routers/history.js +63 -102
- package/cjs/lib/routers/index.js +0 -2
- package/cjs/lib/stateMappings/index.js +0 -3
- package/cjs/lib/stateMappings/simple.js +6 -13
- package/cjs/lib/stateMappings/singleIndex.js +1 -7
- package/cjs/lib/suit.js +2 -5
- package/cjs/lib/templating/index.js +0 -4
- package/cjs/lib/templating/prepareTemplateProps.js +8 -19
- package/cjs/lib/templating/renderTemplate.js +9 -24
- package/cjs/lib/utils/capitalize.js +0 -1
- package/cjs/lib/utils/checkIndexUiState.js +15 -43
- package/cjs/lib/utils/checkRendering.js +0 -2
- package/cjs/lib/utils/clearRefinements.js +2 -9
- package/cjs/lib/utils/concatHighlightedParts.js +1 -3
- package/cjs/lib/utils/createConcurrentSafePromise.js +0 -3
- package/cjs/lib/utils/createSendEventForFacet.js +7 -14
- package/cjs/lib/utils/createSendEventForHits.js +9 -33
- package/cjs/lib/utils/debounce.js +0 -3
- package/cjs/lib/utils/defer.js +0 -11
- package/cjs/lib/utils/detect-insights-client.js +0 -2
- package/cjs/lib/utils/documentation.js +2 -5
- package/cjs/lib/utils/escape-highlight.js +5 -22
- package/cjs/lib/utils/escape-html.js +9 -7
- package/cjs/lib/utils/escapeFacetValue.js +1 -5
- package/cjs/lib/utils/find.js +2 -5
- package/cjs/lib/utils/findIndex.js +0 -3
- package/cjs/lib/utils/geo-search.js +14 -34
- package/cjs/lib/utils/getAppIdAndApiKey.js +2 -3
- package/cjs/lib/utils/getContainerNode.js +0 -6
- package/cjs/lib/utils/getHighlightFromSiblings.js +0 -6
- package/cjs/lib/utils/getHighlightedParts.js +1 -4
- package/cjs/lib/utils/getObjectType.js +0 -1
- package/cjs/lib/utils/getPropertyByPath.js +0 -1
- package/cjs/lib/utils/getRefinements.js +13 -26
- package/cjs/lib/utils/getWidgetAttribute.js +0 -6
- package/cjs/lib/utils/hits-absolute-position.js +2 -6
- package/cjs/lib/utils/hits-query-id.js +2 -7
- package/cjs/lib/utils/index.js +0 -92
- package/cjs/lib/utils/isDomElement.js +0 -1
- package/cjs/lib/utils/isEqual.js +0 -8
- package/cjs/lib/utils/isFacetRefined.js +0 -1
- package/cjs/lib/utils/isFiniteNumber.js +0 -1
- package/cjs/lib/utils/isIndexWidget.js +0 -1
- package/cjs/lib/utils/isPlainObject.js +3 -11
- package/cjs/lib/utils/isSpecialClick.js +0 -1
- package/cjs/lib/utils/logger.js +3 -13
- package/cjs/lib/utils/mergeSearchParameters.js +16 -40
- package/cjs/lib/utils/noop.js +0 -1
- package/cjs/lib/utils/range.js +8 -14
- package/cjs/lib/utils/render-args.js +0 -2
- package/cjs/lib/utils/resolveSearchParameters.js +0 -3
- package/cjs/lib/utils/reverseHighlightedParts.js +2 -8
- package/cjs/lib/utils/safelyRunOnBrowser.js +7 -9
- package/cjs/lib/utils/serializer.js +1 -3
- package/cjs/lib/utils/setIndexHelperState.js +0 -5
- package/cjs/lib/utils/toArray.js +0 -1
- package/cjs/lib/utils/typedObject.js +0 -1
- package/cjs/lib/utils/uniq.js +0 -1
- package/cjs/lib/version.js +1 -1
- package/cjs/lib/voiceSearchHelper/index.js +8 -36
- package/cjs/middlewares/createInsightsMiddleware.js +15 -44
- package/cjs/middlewares/createMetadataMiddleware.js +4 -12
- package/cjs/middlewares/createRouterMiddleware.js +8 -19
- package/cjs/middlewares/index.js +0 -6
- package/cjs/types/algoliasearch.js +0 -2
- package/cjs/types/index.js +0 -28
- package/cjs/widgets/analytics/analytics.js +12 -47
- package/cjs/widgets/answers/answers.js +19 -39
- package/cjs/widgets/breadcrumb/breadcrumb.js +18 -38
- package/cjs/widgets/clear-refinements/clear-refinements.js +15 -35
- package/cjs/widgets/configure/configure.js +2 -10
- package/cjs/widgets/configure-related-items/configure-related-items.js +2 -10
- package/cjs/widgets/current-refinements/current-refinements.js +12 -30
- package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +6 -25
- package/cjs/widgets/geo-search/GeoSearchRenderer.js +41 -68
- package/cjs/widgets/geo-search/createHTMLMarker.js +30 -60
- package/cjs/widgets/geo-search/defaultTemplates.js +0 -3
- package/cjs/widgets/geo-search/geo-search.js +27 -59
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +4 -7
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +28 -47
- package/cjs/widgets/hits/hits.js +16 -37
- package/cjs/widgets/hits-per-page/hits-per-page.js +13 -31
- package/cjs/widgets/index/index.js +49 -95
- package/cjs/widgets/index.js +12 -50
- package/cjs/widgets/infinite-hits/infinite-hits.js +23 -44
- package/cjs/widgets/menu/defaultTemplates.js +3 -6
- package/cjs/widgets/menu/menu.js +23 -43
- package/cjs/widgets/menu-select/defaultTemplates.js +1 -3
- package/cjs/widgets/menu-select/menu-select.js +18 -38
- package/cjs/widgets/numeric-menu/defaultTemplates.js +3 -4
- package/cjs/widgets/numeric-menu/numeric-menu.js +17 -37
- package/cjs/widgets/pagination/pagination.js +32 -53
- package/cjs/widgets/panel/panel.js +20 -48
- package/cjs/widgets/places/places.js +16 -33
- package/cjs/widgets/powered-by/powered-by.js +10 -27
- package/cjs/widgets/query-rule-context/query-rule-context.js +2 -13
- package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +14 -32
- package/cjs/widgets/range-input/range-input.js +23 -50
- package/cjs/widgets/range-slider/range-slider.js +28 -53
- package/cjs/widgets/rating-menu/defaultTemplates.js +8 -14
- package/cjs/widgets/rating-menu/rating-menu.js +17 -38
- package/cjs/widgets/refinement-list/defaultTemplates.js +5 -8
- package/cjs/widgets/refinement-list/refinement-list.js +39 -60
- package/cjs/widgets/relevant-sort/relevant-sort.js +10 -29
- package/cjs/widgets/search-box/defaultTemplates.js +0 -5
- package/cjs/widgets/search-box/search-box.js +31 -49
- package/cjs/widgets/sort-by/sort-by.js +11 -29
- package/cjs/widgets/stats/defaultTemplates.js +0 -1
- package/cjs/widgets/stats/stats.js +27 -57
- package/cjs/widgets/toggle-refinement/toggle-refinement.js +16 -36
- package/cjs/widgets/voice-search/defaultTemplates.js +4 -14
- package/cjs/widgets/voice-search/voice-search.js +17 -36
- package/dist/instantsearch.development.d.ts +8 -6
- package/dist/instantsearch.development.js +1725 -3087
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +8 -6
- package/dist/instantsearch.production.min.d.ts +8 -6
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.js +6 -11
- package/es/components/Breadcrumb/Breadcrumb.js +5 -7
- package/es/components/ClearRefinements/ClearRefinements.js +4 -6
- package/es/components/CurrentRefinements/CurrentRefinements.js +7 -10
- package/es/components/GeoSearchControls/GeoSearchButton.js +6 -6
- package/es/components/GeoSearchControls/GeoSearchControls.js +11 -13
- package/es/components/GeoSearchControls/GeoSearchToggle.js +6 -6
- package/es/components/Highlight/Highlight.js +3 -7
- package/es/components/Hits/Hits.js +8 -15
- package/es/components/InfiniteHits/InfiniteHits.js +13 -20
- package/es/components/MenuSelect/MenuSelect.js +9 -13
- package/es/components/Pagination/Pagination.js +12 -15
- package/es/components/Panel/Panel.js +7 -20
- package/es/components/PoweredBy/PoweredBy.js +6 -5
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +4 -4
- package/es/components/RangeInput/RangeInput.js +16 -43
- package/es/components/RefinementList/RefinementList.js +19 -64
- package/es/components/RefinementList/RefinementListItem.js +8 -10
- package/es/components/RelevantSort/RelevantSort.js +6 -6
- package/es/components/ReverseHighlight/ReverseHighlight.js +3 -7
- package/es/components/ReverseSnippet/ReverseSnippet.js +3 -7
- package/es/components/SearchBox/SearchBox.js +25 -63
- package/es/components/Selector/Selector.js +5 -5
- package/es/components/Slider/Pit.js +3 -7
- package/es/components/Slider/Rheostat.js +64 -129
- package/es/components/Slider/Slider.js +28 -58
- package/es/components/Snippet/Snippet.js +3 -7
- package/es/components/Stats/Stats.js +7 -15
- package/es/components/Template/Template.js +8 -32
- package/es/components/ToggleRefinement/ToggleRefinement.js +4 -6
- package/es/components/VoiceSearch/VoiceSearch.js +10 -13
- package/es/connectors/answers/connectAnswers.js +21 -35
- package/es/connectors/autocomplete/connectAutocomplete.js +8 -23
- package/es/connectors/breadcrumb/connectBreadcrumb.js +17 -46
- package/es/connectors/clear-refinements/connectClearRefinements.js +27 -43
- package/es/connectors/configure/connectConfigure.js +7 -16
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -31
- package/es/connectors/current-refinements/connectCurrentRefinements.js +18 -55
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -35
- package/es/connectors/geo-search/connectGeoSearch.js +17 -45
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -72
- package/es/connectors/hits/connectHits.js +10 -24
- package/es/connectors/hits-per-page/connectHitsPerPage.js +15 -36
- package/es/connectors/index.d.ts +2 -1
- package/es/connectors/index.js +6 -3
- package/es/connectors/infinite-hits/connectInfiniteHits.js +26 -60
- package/es/connectors/menu/connectMenu.js +28 -64
- package/es/connectors/numeric-menu/connectNumericMenu.js +24 -76
- package/es/connectors/pagination/Paginator.js +3 -19
- package/es/connectors/pagination/connectPagination.js +8 -21
- package/es/connectors/powered-by/connectPoweredBy.js +4 -11
- package/es/connectors/query-rules/connectQueryRules.js +32 -54
- package/es/connectors/range/connectRange.js +41 -99
- package/es/connectors/rating-menu/connectRatingMenu.js +23 -77
- package/es/connectors/refinement-list/connectRefinementList.js +37 -68
- package/es/connectors/relevant-sort/connectRelevantSort.js +4 -13
- package/es/connectors/search-box/connectSearchBox.js +7 -21
- package/es/connectors/sort-by/connectSortBy.js +11 -19
- package/es/connectors/stats/connectStats.js +4 -9
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +29 -61
- package/es/connectors/voice-search/connectVoiceSearch.js +13 -31
- package/es/helpers/components/Highlight.js +4 -8
- package/es/helpers/components/ReverseHighlight.js +7 -15
- package/es/helpers/components/ReverseSnippet.js +7 -15
- package/es/helpers/components/Snippet.js +4 -8
- package/es/helpers/get-insights-anonymous-user-token.js +5 -7
- package/es/helpers/highlight.js +9 -11
- package/es/helpers/insights.js +3 -10
- package/es/helpers/reverseHighlight.js +9 -11
- package/es/helpers/reverseSnippet.js +9 -11
- package/es/helpers/snippet.js +9 -11
- package/es/index.js +0 -2
- package/es/lib/InstantSearch.js +79 -170
- package/es/lib/createHelpers.js +4 -8
- package/es/lib/infiniteHitsCache/sessionStorage.js +9 -16
- package/es/lib/insights/client.js +8 -32
- package/es/lib/insights/listener.js +6 -18
- package/es/lib/routers/history.js +63 -99
- package/es/lib/stateMappings/simple.js +6 -12
- package/es/lib/stateMappings/singleIndex.js +1 -6
- package/es/lib/suit.js +2 -3
- package/es/lib/templating/prepareTemplateProps.js +8 -18
- package/es/lib/templating/renderTemplate.js +9 -20
- package/es/lib/utils/checkIndexUiState.js +18 -40
- package/es/lib/utils/clearRefinements.js +2 -8
- package/es/lib/utils/concatHighlightedParts.js +1 -1
- package/es/lib/utils/createConcurrentSafePromise.js +0 -2
- package/es/lib/utils/createSendEventForFacet.js +7 -12
- package/es/lib/utils/createSendEventForHits.js +8 -30
- package/es/lib/utils/debounce.js +0 -2
- package/es/lib/utils/defer.js +0 -10
- package/es/lib/utils/documentation.js +2 -3
- package/es/lib/utils/escape-highlight.js +3 -16
- package/es/lib/utils/escape-html.js +9 -5
- package/es/lib/utils/escapeFacetValue.js +0 -2
- package/es/lib/utils/find.js +2 -4
- package/es/lib/utils/findIndex.js +0 -2
- package/es/lib/utils/geo-search.js +14 -32
- package/es/lib/utils/getAppIdAndApiKey.js +2 -2
- package/es/lib/utils/getContainerNode.js +1 -5
- package/es/lib/utils/getHighlightFromSiblings.js +0 -3
- package/es/lib/utils/getHighlightedParts.js +1 -2
- package/es/lib/utils/getRefinements.js +13 -24
- package/es/lib/utils/getWidgetAttribute.js +0 -5
- package/es/lib/utils/hits-absolute-position.js +2 -5
- package/es/lib/utils/hits-query-id.js +2 -6
- package/es/lib/utils/isEqual.js +0 -7
- package/es/lib/utils/isPlainObject.js +3 -10
- package/es/lib/utils/logger.js +2 -12
- package/es/lib/utils/mergeSearchParameters.js +16 -37
- package/es/lib/utils/range.js +8 -13
- package/es/lib/utils/resolveSearchParameters.js +0 -2
- package/es/lib/utils/reverseHighlightedParts.js +2 -6
- package/es/lib/utils/safelyRunOnBrowser.js +7 -8
- package/es/lib/utils/setIndexHelperState.js +0 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/lib/voiceSearchHelper/index.js +8 -35
- package/es/middlewares/createInsightsMiddleware.js +15 -41
- package/es/middlewares/createMetadataMiddleware.js +3 -9
- package/es/middlewares/createRouterMiddleware.js +8 -13
- package/es/types/index.js +9 -5
- package/es/widgets/analytics/analytics.js +12 -45
- package/es/widgets/answers/answers.js +19 -28
- package/es/widgets/breadcrumb/breadcrumb.js +18 -27
- package/es/widgets/clear-refinements/clear-refinements.js +15 -24
- package/es/widgets/configure/configure.js +3 -6
- package/es/widgets/configure-related-items/configure-related-items.js +2 -7
- package/es/widgets/current-refinements/current-refinements.js +12 -21
- package/es/widgets/dynamic-widgets/dynamic-widgets.js +6 -20
- package/es/widgets/geo-search/GeoSearchRenderer.js +41 -63
- package/es/widgets/geo-search/createHTMLMarker.js +30 -59
- package/es/widgets/geo-search/defaultTemplates.js +2 -2
- package/es/widgets/geo-search/geo-search.js +27 -49
- package/es/widgets/hierarchical-menu/defaultTemplates.js +5 -4
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +28 -36
- package/es/widgets/hits/hits.js +16 -25
- package/es/widgets/hits-per-page/hits-per-page.js +13 -22
- package/es/widgets/index/index.js +49 -91
- package/es/widgets/index.d.ts +2 -1
- package/es/widgets/index.js +4 -3
- package/es/widgets/infinite-hits/infinite-hits.js +23 -32
- package/es/widgets/menu/defaultTemplates.js +4 -3
- package/es/widgets/menu/menu.js +23 -32
- package/es/widgets/menu-select/defaultTemplates.js +1 -1
- package/es/widgets/menu-select/menu-select.js +18 -27
- package/es/widgets/numeric-menu/defaultTemplates.js +4 -3
- package/es/widgets/numeric-menu/numeric-menu.js +17 -26
- package/es/widgets/pagination/pagination.js +32 -44
- package/es/widgets/panel/panel.js +20 -40
- package/es/widgets/places/places.js +16 -32
- package/es/widgets/powered-by/powered-by.js +10 -18
- package/es/widgets/query-rule-context/query-rule-context.js +2 -9
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +13 -22
- package/es/widgets/range-input/range-input.js +23 -40
- package/es/widgets/range-slider/range-slider.js +28 -44
- package/es/widgets/rating-menu/defaultTemplates.js +9 -12
- package/es/widgets/rating-menu/rating-menu.js +17 -27
- package/es/widgets/refinement-list/defaultTemplates.js +6 -5
- package/es/widgets/refinement-list/refinement-list.js +39 -48
- package/es/widgets/relevant-sort/relevant-sort.js +10 -19
- package/es/widgets/search-box/defaultTemplates.js +1 -4
- package/es/widgets/search-box/search-box.js +31 -39
- package/es/widgets/sort-by/sort-by.js +11 -20
- package/es/widgets/stats/stats.js +26 -45
- package/es/widgets/toggle-refinement/toggle-refinement.js +16 -25
- package/es/widgets/voice-search/defaultTemplates.js +5 -13
- package/es/widgets/voice-search/voice-search.js +17 -26
- package/package.json +20 -119
- package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.input.js +0 -1
- package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.output.js +0 -1
- package/CHANGELOG.md +0 -3684
|
@@ -4,48 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.checkIndexUiState = checkIndexUiState;
|
|
7
|
-
|
|
8
7
|
var _capitalize = require("./capitalize.js");
|
|
9
|
-
|
|
10
8
|
var _logger = require("./logger.js");
|
|
11
|
-
|
|
12
9
|
var _typedObject = require("./typedObject.js");
|
|
13
|
-
|
|
14
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
-
|
|
16
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
|
|
18
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
19
|
-
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
13
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
-
|
|
22
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
|
-
|
|
24
15
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
-
|
|
26
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
-
|
|
28
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
-
|
|
30
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
31
|
-
|
|
18
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
32
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
|
-
|
|
34
20
|
// Some connectors are responsible for multiple widgets so we need
|
|
35
21
|
// to map them.
|
|
36
22
|
function getWidgetNames(connectorName) {
|
|
37
23
|
switch (connectorName) {
|
|
38
24
|
case 'range':
|
|
39
25
|
return [];
|
|
40
|
-
|
|
41
26
|
case 'menu':
|
|
42
27
|
return ['menu', 'menuSelect'];
|
|
43
|
-
|
|
44
28
|
default:
|
|
45
29
|
return [connectorName];
|
|
46
30
|
}
|
|
47
31
|
}
|
|
48
|
-
|
|
49
32
|
var stateToWidgetsMap = {
|
|
50
33
|
query: {
|
|
51
34
|
connectors: ['connectSearchBox'],
|
|
@@ -104,22 +87,18 @@ var stateToWidgetsMap = {
|
|
|
104
87
|
widgets: ['ais.places']
|
|
105
88
|
}
|
|
106
89
|
};
|
|
107
|
-
|
|
108
90
|
function checkIndexUiState(_ref) {
|
|
109
91
|
var index = _ref.index,
|
|
110
|
-
|
|
92
|
+
indexUiState = _ref.indexUiState;
|
|
111
93
|
var mountedWidgets = index.getWidgets().map(function (widget) {
|
|
112
94
|
return widget.$$type;
|
|
113
95
|
}).filter(Boolean);
|
|
114
96
|
var missingWidgets = (0, _typedObject.keys)(indexUiState).reduce(function (acc, parameter) {
|
|
115
97
|
var widgetUiState = stateToWidgetsMap[parameter];
|
|
116
|
-
|
|
117
98
|
if (!widgetUiState) {
|
|
118
99
|
return acc;
|
|
119
100
|
}
|
|
120
|
-
|
|
121
101
|
var requiredWidgets = widgetUiState.widgets;
|
|
122
|
-
|
|
123
102
|
if (requiredWidgets && !requiredWidgets.some(function (requiredWidget) {
|
|
124
103
|
return mountedWidgets.includes(requiredWidget);
|
|
125
104
|
})) {
|
|
@@ -130,16 +109,13 @@ function checkIndexUiState(_ref) {
|
|
|
130
109
|
})
|
|
131
110
|
}]);
|
|
132
111
|
}
|
|
133
|
-
|
|
134
112
|
return acc;
|
|
135
113
|
}, []);
|
|
136
114
|
process.env.NODE_ENV === 'development' ? (0, _logger.warning)(missingWidgets.length === 0, "The UI state for the index \"".concat(index.getIndexId(), "\" is not consistent with the widgets mounted.\n\nThis can happen when the UI state is specified via `initialUiState`, `routing` or `setUiState` but that the widgets responsible for this state were not added. This results in those query parameters not being sent to the API.\n\nTo fully reflect the state, some widgets need to be added to the index \"").concat(index.getIndexId(), "\":\n\n").concat(missingWidgets.map(function (_ref2) {
|
|
137
115
|
var _ref4;
|
|
138
|
-
|
|
139
116
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
117
|
+
stateParameter = _ref3[0],
|
|
118
|
+
widgets = _ref3[1].widgets;
|
|
143
119
|
return "- `".concat(stateParameter, "` needs one of these widgets: ").concat((_ref4 = []).concat.apply(_ref4, _toConsumableArray(widgets.map(function (name) {
|
|
144
120
|
return getWidgetNames(name);
|
|
145
121
|
}))).map(function (name) {
|
|
@@ -147,31 +123,27 @@ function checkIndexUiState(_ref) {
|
|
|
147
123
|
}).join(', '));
|
|
148
124
|
}).join('\n'), "\n\nIf you do not wish to display widgets but still want to support their search parameters, you can mount \"virtual widgets\" that don't render anything:\n\n```\n").concat(missingWidgets.filter(function (_ref5) {
|
|
149
125
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
126
|
+
_stateParameter = _ref6[0],
|
|
127
|
+
connectors = _ref6[1].connectors;
|
|
153
128
|
return connectors.length > 0;
|
|
154
129
|
}).map(function (_ref7) {
|
|
155
130
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
131
|
+
_stateParameter = _ref8[0],
|
|
132
|
+
_ref8$ = _ref8[1],
|
|
133
|
+
connectors = _ref8$.connectors,
|
|
134
|
+
widgets = _ref8$.widgets;
|
|
161
135
|
var capitalizedWidget = (0, _capitalize.capitalize)(widgets[0]);
|
|
162
136
|
var connectorName = connectors[0];
|
|
163
137
|
return "const virtual".concat(capitalizedWidget, " = ").concat(connectorName, "(() => null);");
|
|
164
138
|
}).join('\n'), "\n\nsearch.addWidgets([\n ").concat(missingWidgets.filter(function (_ref9) {
|
|
165
139
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
140
|
+
_stateParameter = _ref10[0],
|
|
141
|
+
connectors = _ref10[1].connectors;
|
|
169
142
|
return connectors.length > 0;
|
|
170
143
|
}).map(function (_ref11) {
|
|
171
144
|
var _ref12 = _slicedToArray(_ref11, 2),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
145
|
+
_stateParameter = _ref12[0],
|
|
146
|
+
widgets = _ref12[1].widgets;
|
|
175
147
|
var capitalizedWidget = (0, _capitalize.capitalize)(widgets[0]);
|
|
176
148
|
return "virtual".concat(capitalizedWidget, "({ /* ... */ })");
|
|
177
149
|
}).join(',\n '), "\n]);\n```\n\nIf you're using custom widgets that do set these query parameters, we recommend using connectors instead.\n\nSee https://www.algolia.com/doc/guides/building-search-ui/widgets/customize-an-existing-widget/js/#customize-the-complete-ui-of-the-widgets")) : void 0;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.checkRendering = checkRendering;
|
|
7
|
-
|
|
8
7
|
var _getObjectType = require("./getObjectType.js");
|
|
9
|
-
|
|
10
8
|
function checkRendering(rendering, usage) {
|
|
11
9
|
if (rendering === undefined || typeof rendering !== 'function') {
|
|
12
10
|
throw new Error("The render function is not valid (received type ".concat((0, _getObjectType.getObjectType)(rendering), ").\n\n").concat(usage));
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clearRefinements = clearRefinements;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Clears the refinements of a SearchParameters object based on rules provided.
|
|
10
9
|
* The included attributes list is applied before the excluded attributes list. If the list
|
|
@@ -13,32 +12,26 @@ exports.clearRefinements = clearRefinements;
|
|
|
13
12
|
*/
|
|
14
13
|
function clearRefinements(_ref) {
|
|
15
14
|
var helper = _ref.helper,
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
_ref$attributesToClea = _ref.attributesToClear,
|
|
16
|
+
attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea;
|
|
18
17
|
var finalState = helper.state.setPage(0);
|
|
19
18
|
finalState = attributesToClear.reduce(function (state, attribute) {
|
|
20
19
|
if (finalState.isNumericRefined(attribute)) {
|
|
21
20
|
return state.removeNumericRefinement(attribute);
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
if (finalState.isHierarchicalFacet(attribute)) {
|
|
25
23
|
return state.removeHierarchicalFacetRefinement(attribute);
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
if (finalState.isDisjunctiveFacet(attribute)) {
|
|
29
26
|
return state.removeDisjunctiveFacetRefinement(attribute);
|
|
30
27
|
}
|
|
31
|
-
|
|
32
28
|
if (finalState.isConjunctiveFacet(attribute)) {
|
|
33
29
|
return state.removeFacetRefinement(attribute);
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
return state;
|
|
37
32
|
}, finalState);
|
|
38
|
-
|
|
39
33
|
if (attributesToClear.indexOf('query') !== -1) {
|
|
40
34
|
finalState = finalState.setQuery('');
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
return finalState;
|
|
44
37
|
}
|
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.concatHighlightedParts = concatHighlightedParts;
|
|
7
|
-
|
|
8
7
|
var _escapeHighlight = require("./escape-highlight.js");
|
|
9
|
-
|
|
10
8
|
function concatHighlightedParts(parts) {
|
|
11
9
|
var highlightPreTag = _escapeHighlight.TAG_REPLACEMENT.highlightPreTag,
|
|
12
|
-
|
|
10
|
+
highlightPostTag = _escapeHighlight.TAG_REPLACEMENT.highlightPostTag;
|
|
13
11
|
return parts.map(function (part) {
|
|
14
12
|
return part.isHighlighted ? highlightPreTag + part.value + highlightPostTag : part.value;
|
|
15
13
|
}).join('');
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createConcurrentSafePromise = createConcurrentSafePromise;
|
|
7
|
-
|
|
8
7
|
// copied from
|
|
9
8
|
// https://github.com/algolia/autocomplete.js/blob/307a7acc4283e10a19cb7d067f04f1bea79dc56f/packages/autocomplete-core/src/utils/createConcurrentSafePromise.ts#L1:L1
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* Creates a runner that executes promises in a concurrent-safe way.
|
|
13
11
|
*
|
|
@@ -37,7 +35,6 @@ function createConcurrentSafePromise() {
|
|
|
37
35
|
if (latestResolvedValue && currentPromiseId < latestResolvedId) {
|
|
38
36
|
return latestResolvedValue;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
latestResolvedId = currentPromiseId;
|
|
42
39
|
latestResolvedValue = x;
|
|
43
40
|
return x;
|
|
@@ -4,28 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createSendEventForFacet = createSendEventForFacet;
|
|
7
|
-
|
|
8
7
|
var _isFacetRefined = require("./isFacetRefined.js");
|
|
9
|
-
|
|
10
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
11
|
-
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
9
|
function createSendEventForFacet(_ref) {
|
|
13
10
|
var instantSearchInstance = _ref.instantSearchInstance,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
helper = _ref.helper,
|
|
12
|
+
attr = _ref.attribute,
|
|
13
|
+
widgetType = _ref.widgetType;
|
|
18
14
|
var sendEventForFacet = function sendEventForFacet() {
|
|
19
15
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
16
|
args[_key] = arguments[_key];
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
var eventType = args[0],
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
facetValue = args[1],
|
|
20
|
+
_args$ = args[2],
|
|
21
|
+
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
27
22
|
var attribute = typeof attr === 'string' ? attr : attr(facetValue);
|
|
28
|
-
|
|
29
23
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
30
24
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
31
25
|
} else if (eventType === 'click' && (args.length === 2 || args.length === 3)) {
|
|
@@ -47,6 +41,5 @@ function createSendEventForFacet(_ref) {
|
|
|
47
41
|
throw new Error("You need to pass two arguments like:\n sendEvent('click', facetValue);\n\nIf you want to send a custom payload, you can pass one object: sendEvent(customPayload);\n");
|
|
48
42
|
}
|
|
49
43
|
};
|
|
50
|
-
|
|
51
44
|
return sendEventForFacet;
|
|
52
45
|
}
|
|
@@ -3,40 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createSendEventForHits = createSendEventForHits;
|
|
7
6
|
exports.createBindEventForHits = createBindEventForHits;
|
|
8
|
-
|
|
7
|
+
exports.createSendEventForHits = createSendEventForHits;
|
|
9
8
|
var _serializer = require("./serializer.js");
|
|
10
|
-
|
|
11
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
|
-
|
|
9
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
10
|
function chunk(arr) {
|
|
14
11
|
var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
|
|
15
12
|
var chunks = [];
|
|
16
|
-
|
|
17
13
|
for (var i = 0; i < Math.ceil(arr.length / chunkSize); i++) {
|
|
18
14
|
chunks.push(arr.slice(i * chunkSize, (i + 1) * chunkSize));
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
return chunks;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
var buildPayloads = function buildPayloads(_ref) {
|
|
25
19
|
var index = _ref.index,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
widgetType = _ref.widgetType,
|
|
21
|
+
methodName = _ref.methodName,
|
|
22
|
+
args = _ref.args,
|
|
23
|
+
isSearchStalled = _ref.isSearchStalled;
|
|
31
24
|
// when there's only one argument, that means it's custom
|
|
32
25
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
33
26
|
return [args[0]];
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
var eventType = args[0];
|
|
37
29
|
var hits = args[1];
|
|
38
30
|
var eventName = args[2];
|
|
39
|
-
|
|
40
31
|
if (!hits) {
|
|
41
32
|
if (process.env.NODE_ENV === 'development') {
|
|
42
33
|
throw new Error("You need to pass hit or hits as the second argument like:\n ".concat(methodName, "(eventType, hit);\n "));
|
|
@@ -44,7 +35,6 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
44
35
|
return [];
|
|
45
36
|
}
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
if ((eventType === 'click' || eventType === 'conversion') && !eventName) {
|
|
49
39
|
if (process.env.NODE_ENV === 'development') {
|
|
50
40
|
throw new Error("You need to pass eventName as the third argument for 'click' or 'conversion' events like:\n ".concat(methodName, "('click', hit, 'Product Purchased');\n\n To learn more about event naming: https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/in-depth/clicks-conversions-best-practices/\n "));
|
|
@@ -52,13 +42,10 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
52
42
|
return [];
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
|
-
|
|
56
45
|
var hitsArray = Array.isArray(hits) ? removeEscapedFromHits(hits) : [hits];
|
|
57
|
-
|
|
58
46
|
if (hitsArray.length === 0) {
|
|
59
47
|
return [];
|
|
60
48
|
}
|
|
61
|
-
|
|
62
49
|
var queryID = hitsArray[0].__queryID;
|
|
63
50
|
var hitsChunks = chunk(hitsArray);
|
|
64
51
|
var objectIDsByChunk = hitsChunks.map(function (batch) {
|
|
@@ -71,12 +58,10 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
71
58
|
return hit.__position;
|
|
72
59
|
});
|
|
73
60
|
});
|
|
74
|
-
|
|
75
61
|
if (eventType === 'view') {
|
|
76
62
|
if (isSearchStalled) {
|
|
77
63
|
return [];
|
|
78
64
|
}
|
|
79
|
-
|
|
80
65
|
return hitsChunks.map(function (batch, i) {
|
|
81
66
|
return {
|
|
82
67
|
insightsMethod: 'viewedObjectIDs',
|
|
@@ -127,22 +112,18 @@ var buildPayloads = function buildPayloads(_ref) {
|
|
|
127
112
|
return [];
|
|
128
113
|
}
|
|
129
114
|
};
|
|
130
|
-
|
|
131
115
|
function removeEscapedFromHits(hits) {
|
|
132
116
|
// remove `hits.__escaped` without mutating
|
|
133
117
|
return hits.slice();
|
|
134
118
|
}
|
|
135
|
-
|
|
136
119
|
function createSendEventForHits(_ref2) {
|
|
137
120
|
var instantSearchInstance = _ref2.instantSearchInstance,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
121
|
+
index = _ref2.index,
|
|
122
|
+
widgetType = _ref2.widgetType;
|
|
141
123
|
var sendEventForHits = function sendEventForHits() {
|
|
142
124
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
143
125
|
args[_key] = arguments[_key];
|
|
144
126
|
}
|
|
145
|
-
|
|
146
127
|
var payloads = buildPayloads({
|
|
147
128
|
widgetType: widgetType,
|
|
148
129
|
index: index,
|
|
@@ -154,19 +135,15 @@ function createSendEventForHits(_ref2) {
|
|
|
154
135
|
return instantSearchInstance.sendEventToInsights(payload);
|
|
155
136
|
});
|
|
156
137
|
};
|
|
157
|
-
|
|
158
138
|
return sendEventForHits;
|
|
159
139
|
}
|
|
160
|
-
|
|
161
140
|
function createBindEventForHits(_ref3) {
|
|
162
141
|
var index = _ref3.index,
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
widgetType = _ref3.widgetType;
|
|
165
143
|
var bindEventForHits = function bindEventForHits() {
|
|
166
144
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
167
145
|
args[_key2] = arguments[_key2];
|
|
168
146
|
}
|
|
169
|
-
|
|
170
147
|
var payloads = buildPayloads({
|
|
171
148
|
widgetType: widgetType,
|
|
172
149
|
index: index,
|
|
@@ -176,6 +153,5 @@ function createBindEventForHits(_ref3) {
|
|
|
176
153
|
});
|
|
177
154
|
return payloads.length ? "data-insights-event=".concat((0, _serializer.serializePayload)(payloads)) : '';
|
|
178
155
|
};
|
|
179
|
-
|
|
180
156
|
return bindEventForHits;
|
|
181
157
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.debounce = debounce;
|
|
7
|
-
|
|
8
7
|
// Debounce a function call to the trailing edge.
|
|
9
8
|
// The debounced function returns a promise.
|
|
10
9
|
function debounce(func, wait) {
|
|
@@ -13,12 +12,10 @@ function debounce(func, wait) {
|
|
|
13
12
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
13
|
args[_key] = arguments[_key];
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
return new Promise(function (resolve, reject) {
|
|
18
16
|
if (lastTimeout) {
|
|
19
17
|
clearTimeout(lastTimeout);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
lastTimeout = setTimeout(function () {
|
|
23
20
|
lastTimeout = null;
|
|
24
21
|
Promise.resolve(func.apply(void 0, args)).then(resolve).catch(reject);
|
package/cjs/lib/utils/defer.js
CHANGED
|
@@ -5,47 +5,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.defer = defer;
|
|
7
7
|
var nextMicroTask = Promise.resolve();
|
|
8
|
-
|
|
9
8
|
function defer(callback) {
|
|
10
9
|
var progress = null;
|
|
11
10
|
var cancelled = false;
|
|
12
|
-
|
|
13
11
|
var fn = function fn() {
|
|
14
12
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
13
|
args[_key] = arguments[_key];
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
if (progress !== null) {
|
|
19
16
|
return;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
progress = nextMicroTask.then(function () {
|
|
23
19
|
progress = null;
|
|
24
|
-
|
|
25
20
|
if (cancelled) {
|
|
26
21
|
cancelled = false;
|
|
27
22
|
return;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
callback.apply(void 0, args);
|
|
31
25
|
});
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
fn.wait = function () {
|
|
35
28
|
if (progress === null) {
|
|
36
29
|
throw new Error('The deferred function should be called before calling `wait()`');
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
return progress;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
fn.cancel = function () {
|
|
43
34
|
if (progress === null) {
|
|
44
35
|
return;
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
cancelled = true;
|
|
48
38
|
};
|
|
49
|
-
|
|
50
39
|
return fn;
|
|
51
40
|
}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.hasDetectedInsightsClient = hasDetectedInsightsClient;
|
|
7
|
-
|
|
8
7
|
var _safelyRunOnBrowser = require("./safelyRunOnBrowser.js");
|
|
9
|
-
|
|
10
8
|
function hasDetectedInsightsClient() {
|
|
11
9
|
return (0, _safelyRunOnBrowser.safelyRunOnBrowser)(function (_ref) {
|
|
12
10
|
var window = _ref.window;
|
|
@@ -5,19 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createDocumentationLink = createDocumentationLink;
|
|
7
7
|
exports.createDocumentationMessageGenerator = createDocumentationMessageGenerator;
|
|
8
|
-
|
|
9
8
|
function createDocumentationLink(_ref) {
|
|
10
9
|
var name = _ref.name,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
_ref$connector = _ref.connector,
|
|
11
|
+
connector = _ref$connector === void 0 ? false : _ref$connector;
|
|
13
12
|
return ['https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : ''].join('');
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
function createDocumentationMessageGenerator() {
|
|
17
15
|
for (var _len = arguments.length, widgets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
16
|
widgets[_key] = arguments[_key];
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
var links = widgets.map(function (widget) {
|
|
22
19
|
return createDocumentationLink(widget);
|
|
23
20
|
}).join(', ');
|
|
@@ -3,22 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.escapeHits = escapeHits;
|
|
7
|
-
exports.escapeFacets = escapeFacets;
|
|
8
6
|
exports.TAG_REPLACEMENT = exports.TAG_PLACEHOLDER = void 0;
|
|
9
|
-
|
|
7
|
+
exports.escapeFacets = escapeFacets;
|
|
8
|
+
exports.escapeHits = escapeHits;
|
|
10
9
|
var _escapeHtml = require("./escape-html.js");
|
|
11
|
-
|
|
12
10
|
var _isPlainObject = require("./isPlainObject.js");
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
11
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
15
|
var TAG_PLACEHOLDER = {
|
|
23
16
|
highlightPreTag: '__ais-highlight__',
|
|
24
17
|
highlightPostTag: '__/ais-highlight__'
|
|
@@ -29,50 +22,40 @@ var TAG_REPLACEMENT = {
|
|
|
29
22
|
highlightPostTag: '</mark>'
|
|
30
23
|
};
|
|
31
24
|
exports.TAG_REPLACEMENT = TAG_REPLACEMENT;
|
|
32
|
-
|
|
33
25
|
function replaceTagsAndEscape(value) {
|
|
34
26
|
return (0, _escapeHtml.escape)(value).replace(new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'), TAG_REPLACEMENT.highlightPreTag).replace(new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'), TAG_REPLACEMENT.highlightPostTag);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
function recursiveEscape(input) {
|
|
38
29
|
if ((0, _isPlainObject.isPlainObject)(input) && typeof input.value !== 'string') {
|
|
39
30
|
return Object.keys(input).reduce(function (acc, key) {
|
|
40
31
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, recursiveEscape(input[key])));
|
|
41
32
|
}, {});
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
if (Array.isArray(input)) {
|
|
45
35
|
return input.map(recursiveEscape);
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
return _objectSpread(_objectSpread({}, input), {}, {
|
|
49
38
|
value: replaceTagsAndEscape(input.value)
|
|
50
39
|
});
|
|
51
40
|
}
|
|
52
|
-
|
|
53
41
|
function escapeHits(hits) {
|
|
54
42
|
if (hits.__escaped === undefined) {
|
|
55
43
|
// We don't override the value on hit because it will mutate the raw results
|
|
56
44
|
// instead we make a shallow copy and we assign the escaped values on it.
|
|
57
45
|
hits = hits.map(function (_ref) {
|
|
58
46
|
var hit = _extends({}, _ref);
|
|
59
|
-
|
|
60
47
|
if (hit._highlightResult) {
|
|
61
48
|
hit._highlightResult = recursiveEscape(hit._highlightResult);
|
|
62
49
|
}
|
|
63
|
-
|
|
64
50
|
if (hit._snippetResult) {
|
|
65
51
|
hit._snippetResult = recursiveEscape(hit._snippetResult);
|
|
66
52
|
}
|
|
67
|
-
|
|
68
53
|
return hit;
|
|
69
54
|
});
|
|
70
55
|
hits.__escaped = true;
|
|
71
56
|
}
|
|
72
|
-
|
|
73
57
|
return hits;
|
|
74
58
|
}
|
|
75
|
-
|
|
76
59
|
function escapeFacets(facetHits) {
|
|
77
60
|
return facetHits.map(function (h) {
|
|
78
61
|
return _objectSpread(_objectSpread({}, h), {}, {
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.escape = escape;
|
|
7
7
|
exports.unescape = unescape;
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* This implementation is taken from Lodash implementation.
|
|
11
10
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
|
|
12
11
|
*/
|
|
12
|
+
|
|
13
13
|
// Used to map characters to HTML entities.
|
|
14
14
|
var htmlEntities = {
|
|
15
15
|
'&': '&',
|
|
@@ -17,42 +17,44 @@ var htmlEntities = {
|
|
|
17
17
|
'>': '>',
|
|
18
18
|
'"': '"',
|
|
19
19
|
"'": '''
|
|
20
|
-
};
|
|
20
|
+
};
|
|
21
21
|
|
|
22
|
+
// Used to match HTML entities and HTML characters.
|
|
22
23
|
var regexUnescapedHtml = /[&<>"']/g;
|
|
23
24
|
var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
26
28
|
* corresponding HTML entities.
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
30
|
function escape(value) {
|
|
30
31
|
return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
|
|
31
32
|
return htmlEntities[character];
|
|
32
33
|
}) : value;
|
|
33
34
|
}
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* This implementation is taken from Lodash implementation.
|
|
36
38
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
|
|
37
39
|
*/
|
|
38
|
-
// Used to map HTML entities to characters.
|
|
39
|
-
|
|
40
40
|
|
|
41
|
+
// Used to map HTML entities to characters.
|
|
41
42
|
var htmlCharacters = {
|
|
42
43
|
'&': '&',
|
|
43
44
|
'<': '<',
|
|
44
45
|
'>': '>',
|
|
45
46
|
'"': '"',
|
|
46
47
|
''': "'"
|
|
47
|
-
};
|
|
48
|
+
};
|
|
48
49
|
|
|
50
|
+
// Used to match HTML entities and HTML characters.
|
|
49
51
|
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
50
52
|
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
53
56
|
* characters.
|
|
54
57
|
*/
|
|
55
|
-
|
|
56
58
|
function unescape(value) {
|
|
57
59
|
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
58
60
|
return htmlCharacters[character];
|