diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..e1fcd1ea --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/erbium diff --git a/assets/banner-1544x500.png b/.wordpress-org/banner-1544x500.png similarity index 100% rename from assets/banner-1544x500.png rename to .wordpress-org/banner-1544x500.png diff --git a/assets/banner-772x250.png b/.wordpress-org/banner-772x250.png similarity index 100% rename from assets/banner-772x250.png rename to .wordpress-org/banner-772x250.png diff --git a/assets/icon-128x128.png b/.wordpress-org/icon-128x128.png similarity index 100% rename from assets/icon-128x128.png rename to .wordpress-org/icon-128x128.png diff --git a/assets/icon-256x256.png b/.wordpress-org/icon-256x256.png similarity index 100% rename from assets/icon-256x256.png rename to .wordpress-org/icon-256x256.png diff --git a/assets/screenshot-1.png b/.wordpress-org/screenshot-1.png similarity index 100% rename from assets/screenshot-1.png rename to .wordpress-org/screenshot-1.png diff --git a/assets/screenshot-2.png b/.wordpress-org/screenshot-2.png similarity index 100% rename from assets/screenshot-2.png rename to .wordpress-org/screenshot-2.png diff --git a/assets/screenshot-3.png b/.wordpress-org/screenshot-3.png similarity index 100% rename from assets/screenshot-3.png rename to .wordpress-org/screenshot-3.png diff --git a/assets/screenshot-4.png b/.wordpress-org/screenshot-4.png similarity index 100% rename from assets/screenshot-4.png rename to .wordpress-org/screenshot-4.png diff --git a/assets/screenshot-5.png b/.wordpress-org/screenshot-5.png similarity index 100% rename from assets/screenshot-5.png rename to .wordpress-org/screenshot-5.png diff --git a/README.txt b/README.txt index e7250821..1ddffd60 100644 --- a/README.txt +++ b/README.txt @@ -2,9 +2,9 @@ Contributors: WebDevStudios, williamsba1, gregrickaby, tw2113, richaber, mrasharirfan Tags: Search, Algolia, Autocomplete, instant-search, relevant search, search highlight, faceted search, find-as-you-type search, suggest, search by category, ajax search, better search, custom search Requires at least: 5.0 -Tested up to: 5.7 +Tested up to: 5.8 Requires PHP: 7.2 -Stable tag: 1.8.0 +Stable tag: 2.0.0 License: GNU General Public License v2.0, MIT License Improve search on your site. Autocomplete is included, along with full control over look, feel and relevance. @@ -106,6 +106,14 @@ WebDevStudios provides end-to-end WordPress opportunities from strategy and plan Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases). += 2.0.0 = +* Breaking changes for users with customized autocomplete.php / instantsearch.php template in their theme. +* Update autocomplete.php and instantsearch.php templates for compatibility with new JS libs. +* Update Algolia JavaScript API Client to 4.10.3 +* Update Algolia InstantSearch.js to 4.25.2 +* Update Algolia Autocomplete.js to 0.38.0 +* Update Algolia PHP API Client to 3.0.2 + = 1.8.0 = * Focus on template versioning and update messaging * Add Algolia_Template_Utils class diff --git a/algolia.php b/algolia.php index 7cfe1b49..935be952 100644 --- a/algolia.php +++ b/algolia.php @@ -3,7 +3,7 @@ * Plugin Name: WP Search with Algolia * Plugin URI: https://github.com/WebDevStudios/wp-search-with-algolia * Description: Integrate the powerful Algolia search service with WordPress - * Version: 1.8.0 + * Version: 2.0.0 * Requires at least: 5.0 * Requires PHP: 7.2 * Author: WebDevStudios @@ -26,7 +26,7 @@ } // The Algolia Search plugin version. -define( 'ALGOLIA_VERSION', '1.8.0' ); +define( 'ALGOLIA_VERSION', '2.0.0' ); // The minmum required PHP version. define( 'ALGOLIA_MIN_PHP_VERSION', '7.2' ); diff --git a/composer.json b/composer.json index 5c6f7eda..a8ce937f 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "webdevstudios/wp-search-with-algolia", - "version": "1.6.0", + "version": "2.0.0", "description": "Integrate the powerful Algolia search service with WordPress.", "authors": [ { @@ -21,17 +21,17 @@ "composer/installers": "~1.0" }, "require-dev": { - "algolia/algoliasearch-client-php": "~2.7.0", - "psr/http-message": "~1.0.0", - "psr/log": "~1.0.0", - "psr/simple-cache": "~1.0.0", - "webdevstudios/php-coding-standards": "^1.0.0", - "phpcompatibility/phpcompatibility-wp": "^2.0.0", - "slowprog/composer-copy-file": "^0.3.2" + "algolia/algoliasearch-client-php": "^3.0.2", + "psr/http-message": "~1.0.1", + "psr/log": "~1.0.2", + "psr/simple-cache": "~1.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", + "phpcompatibility/phpcompatibility-wp": "^2.1.2", + "wp-coding-standards/wpcs": "^2.3.0", + "slowprog/composer-copy-file": "^0.3.3" }, "extra": { "installer-name": "wp-search-with-algolia", - "phpcodesniffer-search-depth": 5, "copy-file": { "vendor/algolia": "includes/libraries" }, @@ -42,7 +42,7 @@ }, "scripts": { "lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --standard=phpcs.xml --extensions=php .", - "lint:fix": "vendor/bin/phpcbf", + "lint:fix": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --standard=phpcs.xml --extensions=php .", "post-install-cmd": [ "SlowProg\\CopyFile\\ScriptHandler::copy" ], diff --git a/composer.lock b/composer.lock index 57cab201..4438ed97 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "65814a969601baa2f5152e0a79a022c7", + "content-hash": "65c9239fafa762ea79239cf5d665ef61", "packages": [ { "name": "composer/installers", @@ -131,29 +131,39 @@ "zend", "zikula" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-04-07T06:57:05+00:00" } ], "packages-dev": [ { "name": "algolia/algoliasearch-client-php", - "version": "2.7.3", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/algolia/algoliasearch-client-php.git", - "reference": "142a382e4649db0cb64d9eb8893872f1a4ba8dd3" + "reference": "421abbfb085c8ae74d298a6f259ebfd69897e625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/142a382e4649db0cb64d9eb8893872f1a4ba8dd3", - "reference": "142a382e4649db0cb64d9eb8893872f1a4ba8dd3", + "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/421abbfb085c8ae74d298a6f259ebfd69897e625", + "reference": "421abbfb085c8ae74d298a6f259ebfd69897e625", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", - "php": "^5.3 || ^7.0 || ^8.0", + "php": "^7.2 || ^8.0", "psr/http-message": "^1.0", "psr/log": "^1.0", "psr/simple-cache": "^1.0" @@ -161,7 +171,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", "fzaninotto/faker": "^1.8", - "julienbourdeau/phpunit": "4.8.37", + "phpunit/phpunit": "^8.0 || ^9.0", "symfony/yaml": "^2.0 || ^4.0" }, "suggest": { @@ -203,7 +213,7 @@ "php", "search" ], - "time": "2020-12-22T11:27:03+00:00" + "time": "2021-05-04T09:15:35+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -717,6 +727,7 @@ ], "description": "In-house PHP linting and coding standards for WebDevStudios", "homepage": "https://github.com/WebDevStudios/php-coding-standards", + "abandoned": "wp-coding-standards/wpcs", "time": "2020-10-16T20:49:05+00:00" }, { diff --git a/css/algolia-instantsearch.css b/css/algolia-instantsearch.css index 99dec19a..bf87b6dc 100644 --- a/css/algolia-instantsearch.css +++ b/css/algolia-instantsearch.css @@ -14,14 +14,35 @@ .ais-facets { margin-bottom: 2rem; + padding: 0; +} + +.ais-facets ul { + list-style: none; + padding-left: 0; + margin-left: 0; +} + +.ais-facets li { + margin-left: 0; } .ais-clearfix { clear: both; } -#algolia-search-box { +.algolia-search-box-wrapper { position: relative; +} + +.algolia-search-box-wrapper .search-icon { + position: absolute; + left: 0px; + top: 14px; + fill: #21A4D7; +} + +#algolia-search-box { margin-bottom: 3rem; } @@ -43,14 +64,18 @@ -ms-appearance:none; } -#algolia-search-box .search-icon { - position: absolute; - left: 0px; - top: 14px; - fill: #21A4D7; +.ais-SearchBox-form { + display: block; + position: relative; +} + +.ais-SearchBox-submit[hidden], +.ais-SearchBox-reset[hidden], +.ais-SearchBox-loadingIndicator[hidden] { + display: none; } -.ais-search-box--powered-by { +#algolia-powered-by { position: absolute; top: 60px; right: 0; @@ -58,35 +83,28 @@ text-align: right; } -.ais-search-box--powered-by-link { - display: inline-block; - width: 64px; - height: 21px; - text-indent: 101%; - overflow: hidden; - white-space: nowrap; - background-image: url('algolia-logo.svg'); - background-repeat: no-repeat; - background-size: contain; - vertical-align: middle; -} - -.ais-stats { +.ais-Stats { position: absolute; top: 60px; font-size: 14px; } -.ais-hits--item { +.ais-Hits-list { + list-style: none; + padding-left: 0; + margin-left: 0; +} + +.ais-Hits-item { /* hit item */ - margin-bottom: 2rem; + margin: 0 0 2rem 0; } -.ais-hits--item h2 { +.ais-Hits-item h2 { margin: 0; } -.ais-hits--item em, .ais-hits--item a em { +.ais-Hits-item em, .ais-Hits-item a em { font-style: normal; background: #FFFBCC; border-radius: 2px; @@ -105,41 +123,51 @@ border-radius: 3px; } -.ais-pagination { +.ais-Pagination { margin: 0; } -.ais-pagination--item { - /* pagination item */ +.ais-Pagination-list { + margin-left: 0; +} + +.ais-Pagination-item { + /* Pagination item */ display: inline-block; padding: 3px; } -.ais-pagination--item__disabled { - /* disabled pagination item */ +.ais-Pagination-item--disabled { + /* disabled Pagination item */ display: none; } -.ais-pagination--item__active { +.ais-Pagination-item--selected { font-weight: bold; } -.ais-menu--item__active { +.ais-Menu-item--selected { /* active list item */ font-weight: bold; } -.ais-hierarchical-menu--list__lvl1 { +.ais-Menu-count, +.ais-HierarchicalMenu-count, +.ais-RefinementList-count { + margin-left: 5px; +} + +.ais-HierarchicalMenu-list--lvl1 { /* item list level 1 */ margin-left: 10px; } -.ais-hierarchical-menu--list__lvl2 { +.ais-HierarchicalMenu-list--lvl2 { /* item list level 0 */ margin-left: 10px; } -.ais-range-slider--target { +.ais-RangeSlider-target { position: relative; direction: ltr; background: #F3F4F7; @@ -148,7 +176,7 @@ margin-bottom: 2em; } -.ais-range-slider--base { +.ais-RangeSlider-base { height: 100%; position: relative; z-index: 1; @@ -158,7 +186,7 @@ border-right: 2px solid #DDD; } -.ais-range-slider--origin { +.ais-RangeSlider-origin { position: absolute; right: 0; top: 0; @@ -166,15 +194,15 @@ bottom: 0; } -.ais-range-slider--connect { +.ais-RangeSlider-connect { background: #46AEDA; } -.ais-range-slider--background { +.ais-RangeSlider-background { background: #F3F4F7; } -.ais-range-slider--handle { +.ais-RangeSlider-handle { width: 20px; height: 20px; position: relative; @@ -185,24 +213,24 @@ cursor: pointer; } -.ais-range-slider--handle-lower { +.ais-RangeSlider-handle-lower { left: -10px; bottom: 7px; } -.ais-range-slider--handle-upper { +.ais-RangeSlider-handle-upper { right: 10px; bottom: 7px; } -.ais-range-slider--tooltip { +.ais-RangeSlider-tooltip { position: absolute; background: #FFFFFF; top: -22px; font-size: .8em; } -.ais-range-slider--pips { +.ais-RangeSlider-pips { box-sizing: border-box; position: absolute; height: 3em; @@ -211,7 +239,7 @@ width: 100%; } -.ais-range-slider--value { +.ais-RangeSlider-value { width: 40px; position: absolute; text-align: center; @@ -220,12 +248,12 @@ font-size: .8em; } -.ais-range-slider--value-sub { +.ais-RangeSlider-value-sub { font-size: .8em; padding-top: 15px; } -.ais-range-slider--marker { +.ais-RangeSlider-marker { position: absolute; background: #DDD; margin-left: -1px; @@ -233,21 +261,21 @@ height: 5px; } -.ais-range-slider--marker-sub { +.ais-RangeSlider-marker-sub { background: #DDD; width: 2px; margin-left: -2px; height: 13px; } -.ais-range-slider--marker-large { +.ais-RangeSlider-marker-large { background: #DDD; width: 2px; margin-left: -2px; height: 12px; } -.ais-range-slider--marker-large:first-child { +.ais-RangeSlider-marker-large:first-child { margin-left: 0; } @@ -302,7 +330,7 @@ } /* Hierarchical Menu: Categories */ -.ais-hierarchical-menu--item__active > div > a { +.ais-HierarchicalMenu--item__active > div > a { font-weight: bold; } diff --git a/includes/admin/class-algolia-admin-page-autocomplete.php b/includes/admin/class-algolia-admin-page-autocomplete.php index 306687d8..a0ecbd75 100644 --- a/includes/admin/class-algolia-admin-page-autocomplete.php +++ b/includes/admin/class-algolia-admin-page-autocomplete.php @@ -164,9 +164,9 @@ public function autocomplete_enabled_callback() { $indices = $this->autocomplete_config->get_form_data(); $checked = 'yes' === $value ? 'checked ' : ''; $disabled = empty( $indices ) ? 'disabled ' : ''; -?> + ?> /> -slug ) ) . '">' . esc_html__( 'Settings', 'wp-search-with-algolia' ) . '', ) ); @@ -206,10 +207,10 @@ public function application_id_callback() { $settings = $this->plugin->get_settings(); $setting = $settings->get_application_id(); $disabled_html = $settings->is_application_id_in_config() ? ' disabled' : ''; -?> + ?> />

-get_search_api_key(); $disabled_html = $settings->is_search_api_key_in_config() ? ' disabled' : ''; -?> + ?> />

-plugin->get_settings(); $setting = $settings->get_api_key(); $disabled_html = $settings->is_api_key_in_config() ? ' disabled' : ''; -?> + ?> />

-plugin->get_settings(); $index_name_prefix = $settings->get_index_name_prefix(); $disabled_html = $settings->is_index_name_prefix_in_config() ? ' disabled' : ''; -?> + ?> />

- $b['position']; } ); @@ -175,14 +176,16 @@ public function get_config() { // Remove manually disabled indices. $config = array_filter( - $config, function( $item ) { + $config, + function( $item ) { return (bool) $item['enabled']; } ); // Sort the indices. usort( - $config, function( $a, $b ):int { + $config, + function( $a, $b ):int { return $a['position'] <=> $b['position']; } ); diff --git a/includes/class-algolia-plugin.php b/includes/class-algolia-plugin.php index fd2621e1..428e76d6 100644 --- a/includes/class-algolia-plugin.php +++ b/includes/class-algolia-plugin.php @@ -274,7 +274,8 @@ public function load_indices() { $searchable_post_types = get_post_types( array( 'exclude_from_search' => false, - ), 'names' + ), + 'names' ); $searchable_post_types = (array) apply_filters( 'algolia_searchable_post_types', $searchable_post_types ); $this->indices[] = new Algolia_Searchable_Posts_Index( $searchable_post_types ); @@ -353,7 +354,8 @@ public function get_indices( array $args = array() ) { if ( isset( $args['enabled'] ) && true === $args['enabled'] ) { $indices = array_filter( - $indices, function( $index ) { + $indices, + function( $index ) { return $index->is_enabled(); } ); @@ -362,7 +364,8 @@ public function get_indices( array $args = array() ) { if ( isset( $args['contains'] ) ) { $contains = (string) $args['contains']; $indices = array_filter( - $indices, function( $index ) use ( $contains ) { + $indices, + function( $index ) use ( $contains ) { return $index->contains_only( $contains ); } ); diff --git a/includes/class-algolia-scripts.php b/includes/class-algolia-scripts.php index 32d5f920..85a03290 100644 --- a/includes/class-algolia-scripts.php +++ b/includes/class-algolia-scripts.php @@ -37,9 +37,13 @@ public function register_scripts() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + $ais_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG + ? '.development' + : '.production'; + wp_register_script( 'algolia-search', - ALGOLIA_PLUGIN_URL . 'js/algoliasearch/dist/algoliasearch.jquery' . $suffix . '.js', + ALGOLIA_PLUGIN_URL . 'js/algoliasearch/dist/algoliasearch-lite.umd.js', [ 'jquery', 'underscore', @@ -73,7 +77,7 @@ public function register_scripts() { wp_register_script( 'algolia-instantsearch', - ALGOLIA_PLUGIN_URL . 'js/instantsearch.js/dist/instantsearch-preact' . $suffix . '.js', + ALGOLIA_PLUGIN_URL . 'js/instantsearch.js/dist/instantsearch' . $ais_suffix . $suffix . '.js', [ 'jquery', 'underscore', diff --git a/includes/class-algolia-template-loader.php b/includes/class-algolia-template-loader.php index 3de6a53c..a12230f2 100644 --- a/includes/class-algolia-template-loader.php +++ b/includes/class-algolia-template-loader.php @@ -76,7 +76,7 @@ public function load_algolia_config() { $autocomplete_config = $this->plugin->get_autocomplete_config(); $config = array( - 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG, + 'debug' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG, 'application_id' => $settings->get_application_id(), 'search_api_key' => $settings->get_search_api_key(), 'powered_by_enabled' => $settings->is_powered_by_enabled(), @@ -186,7 +186,8 @@ public function template_loader( $template ) { */ public function load_instantsearch_template() { add_action( - 'wp_enqueue_scripts', function () { + 'wp_enqueue_scripts', + function () { // Enqueue the instantsearch.js default styles. wp_enqueue_style( 'algolia-instantsearch' ); diff --git a/includes/factories/class-algolia-http-client-interface-factory.php b/includes/factories/class-algolia-http-client-interface-factory.php index e183a5b2..9119dc11 100644 --- a/includes/factories/class-algolia-http-client-interface-factory.php +++ b/includes/factories/class-algolia-http-client-interface-factory.php @@ -8,7 +8,7 @@ use Algolia\AlgoliaSearch\Http\Guzzle6HttpClient; use Algolia\AlgoliaSearch\Http\HttpClientInterface; -use Algolia\AlgoliaSearch\Http\Php53HttpClient; +use Algolia\AlgoliaSearch\Http\CurlHttpClient; /** * Class Algolia_Http_Client_Interface_Factory @@ -41,38 +41,79 @@ public static function create(): HttpClientInterface { return $http_client; } - $http_client = self::create_php53_http_client(); + $http_client = self::create_http_client(); return $http_client; } /** - * Create a Php53HttpClient client. + * Create HttpClientInterface. + * + * @author WebDevStudios + * @since 1.6.0 + * + * @deprecated 2.0.0 Use Algolia_Http_Client_Interface_Factory::create_http_client() + * @see Algolia_Http_Client_Interface_Factory::create_http_client() + * + * @return HttpClientInterface + */ + public static function create_php53_http_client(): HttpClientInterface { + _deprecated_function( + __METHOD__, + '2.0.0', + 'Algolia_Http_Client_Interface_Factory::create_http_client();' + ); + return self::create_http_client(); + } + + /** + * Create HttpClientInterface. + * + * Note: Algolia PHP Client 2.x used the `Php53HttpClient` class + * when Guzzle was not available. + * Algolia PHP Client v 3.x changed that class to `CurlHttpClient`. + * Ideally we would implement Guzzle support at some point, + * but we need to explore PHP Scoper or Mozart before doing so. * * @author WebDevStudios - * @since 1.6.0 + * @since 2.0.0 * - * @return Php53HttpClient + * @return HttpClientInterface */ - public static function create_php53_http_client(): Php53HttpClient { + public static function create_http_client(): HttpClientInterface { + + $options = []; + + /** + * Allow developers to override the HttpClientInterface options. + * + * @author WebDevStudios + * @since 1.6.0 + * @deprecated 2.0.0 Use {@see 'algolia_http_client_options'} instead. + * + * @param array $options Options for HttpClientInterface construction. + */ + $options = (array) apply_filters_deprecated( + 'algolia_php_53_http_client_options', + [ $options ], + '2.0.0', + 'algolia_http_client_options' + ); /** - * Allow developers to override the Php53HttpClient cURL options. + * Allow developers to override the HttpClientInterface options. * * @link https://www.algolia.com/doc/api-client/advanced/pass-options-to-the-http-client/php/?language=php#using-the-default-php53httpclient * @link https://www.algolia.com/doc/api-client/getting-started/upgrade-guides/php/#curl-options * @link https://curl.haxx.se/libcurl/c/curl_easy_setopt.html * * @author WebDevStudios - * @since 1.6.0 + * @since 2.0.0 * - * @param array $options Curl options for Php53HttpClient construction. + * @param array $options Options for HttpClientInterface construction. */ - $options = apply_filters( - 'algolia_php_53_http_client_options', - [] - ); + $options = (array) apply_filters( 'algolia_http_client_options', $options ); - return new Php53HttpClient( $options ); + return new CurlHttpClient( $options ); } } diff --git a/includes/indices/class-algolia-users-index.php b/includes/indices/class-algolia-users-index.php index b9cb4198..8e678a4f 100644 --- a/includes/indices/class-algolia-users-index.php +++ b/includes/indices/class-algolia-users-index.php @@ -84,7 +84,8 @@ protected function get_records( $item ) { $avatar_size = 32; if ( function_exists( 'get_avatar_url' ) ) { $record['avatar_url'] = get_avatar_url( - $item->ID, array( + $item->ID, + array( 'size' => $avatar_size, ) ); diff --git a/includes/libraries/algoliasearch-client-php/.circleci/config.yml b/includes/libraries/algoliasearch-client-php/.circleci/config.yml index 95cf797d..e446b1d6 100644 --- a/includes/libraries/algoliasearch-client-php/.circleci/config.yml +++ b/includes/libraries/algoliasearch-client-php/.circleci/config.yml @@ -35,18 +35,18 @@ jobs: - run: sudo docker-php-ext-install zip # Download and cache dependencies -# - restore_cache: -# keys: -# - composer-deps-<>-{{ checksum "composer.json" }} -# # fallback to using the latest cache if no exact match is found -# #- composer-deps- + - restore_cache: + keys: + - composer-deps-<>-{{ checksum "composer.json" }} + # fallback to using the latest cache if no exact match is found + #- composer-deps- - run: COMPOSER_MEMORY_LIMIT=-1 composer install -n --prefer-dist -# - save_cache: -# key: composer-deps-<>-{{ checksum "composer.json" }} -# paths: -# - ./vendor + - save_cache: + key: composer-deps-<>-{{ checksum "composer.json" }} + paths: + - ./vendor - run: name: Install PHP Client @@ -60,11 +60,15 @@ jobs: - run: name: Get API Key Dealer client - command: wget https://alg.li/algolia-keys && chmod +x algolia-keys + command: | + if [ "${CIRCLE_PR_REPONAME}" ] + then + curl -s https://algoliasearch-client-keygen.herokuapp.com | bash >> "$BASH_ENV" + fi -# - run: -# name: Check code styles -# command: vendor/bin/php-cs-fixer fix -v --dry-run + - run: + name: Check code styles + command: vendor/bin/php-cs-fixer fix -v --dry-run # Run tests with phpunit # @@ -72,19 +76,29 @@ jobs: # with the keys in the env variables # If the PR was open from a fork (community PR) # we get API keys from the API key dealer https://alg.li/api-key-dealer + # we only run the tests on dictionaries on one case to avoid concurrency problems - run: name: Run tests command: | export CI_BUILD_NUM=$CIRCLE_BUILD_NUM if [ -z ${CIRCLE_PR_REPONAME+x} ] then - php vendor/bin/phpunit + if [ "<>" == "latest" ] && [ "<>" == "guzzlehttp/guzzle:"^7.0"" ] + then + php vendor/bin/phpunit + else + php vendor/bin/phpunit --exclude-group=dictionaries + fi else export CI_PROJ_USERNAME=$CIRCLE_PR_USERNAME export CI_PROJ_REPONAME=$CIRCLE_PR_REPONAME - eval $(./algolia-keys export) - php vendor/bin/phpunit -v --testsuite Unit,Definition,Community + if [ "<>" == "latest" ] && [ "<>" == "guzzlehttp/guzzle:"^7.0"" ] + then + php vendor/bin/phpunit + else + php vendor/bin/phpunit --exclude-group=dictionaries + fi fi - run: @@ -121,12 +135,8 @@ workflows: version: "7.4" http_client: guzzlehttp/guzzle:"^6.0" - test: - name: 'Guzzle 6 - PHP 7.0' - version: "7.0" - http_client: guzzlehttp/guzzle:"^6.0" - - test: - name: 'Guzzle 6 - PHP 5.6' - version: "5.6" + name: 'Guzzle 6 - PHP 7.2' + version: "7.2" http_client: guzzlehttp/guzzle:"^6.0" - test: @@ -142,10 +152,6 @@ workflows: version: "7.4" http_client: legacy - test: - name: 'Legacy client - PHP 7.0' - version: "7.0" - http_client: legacy - - test: - name: 'Legacy client - PHP 5.6' - version: "5.6" + name: 'Legacy client - PHP 7.2' + version: "7.2" http_client: legacy diff --git a/includes/libraries/algoliasearch-client-php/.circleci/index-cleanup.php b/includes/libraries/algoliasearch-client-php/.circleci/index-cleanup.php deleted file mode 100644 index 5b0add7e..00000000 --- a/includes/libraries/algoliasearch-client-php/.circleci/index-cleanup.php +++ /dev/null @@ -1,19 +0,0 @@ -listIndices(); - -foreach(array_chunk($indices['items'], 100) as $chunk) { - $ops = array(); - foreach($chunk as $index) { - array_push($ops, [ - 'indexName' => $index['name'], - 'action' => 'delete', - ]); - } - - $client->multipleBatch($ops); -} diff --git a/includes/libraries/algoliasearch-client-php/composer.json b/includes/libraries/algoliasearch-client-php/composer.json index fd6965ef..61fbe595 100644 --- a/includes/libraries/algoliasearch-client-php/composer.json +++ b/includes/libraries/algoliasearch-client-php/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": "^5.3 || ^7.0 || ^8.0", + "php": "^7.2 || ^8.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", @@ -22,7 +22,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", "fzaninotto/faker": "^1.8", - "julienbourdeau/phpunit": "4.8.37", + "phpunit/phpunit": "^8.0 || ^9.0", "symfony/yaml": "^2.0 || ^4.0" }, "autoload": { diff --git a/includes/libraries/algoliasearch-client-php/src/AccountClient.php b/includes/libraries/algoliasearch-client-php/src/AccountClient.php index 06d1c99e..20d142c8 100644 --- a/includes/libraries/algoliasearch-client-php/src/AccountClient.php +++ b/includes/libraries/algoliasearch-client-php/src/AccountClient.php @@ -7,7 +7,7 @@ final class AccountClient { - public static function copyIndex(SearchIndex $srcIndex, SearchIndex $destIndex, $requestOptions = array()) + public static function copyIndex(SearchIndex $srcIndex, SearchIndex $destIndex, $requestOptions = []) { if ($srcIndex->getAppId() === $destIndex->getAppId()) { throw new \InvalidArgumentException('If both index are on the same app, please use SearchClient::copyIndex method instead.'); @@ -21,7 +21,7 @@ public static function copyIndex(SearchIndex $srcIndex, SearchIndex $destIndex, // All good } - $allResponses = array(); + $allResponses = []; $settings = $srcIndex->getSettings(); $allResponses[] = $destIndex->setSettings($settings); diff --git a/includes/libraries/algoliasearch-client-php/src/Algolia.php b/includes/libraries/algoliasearch-client-php/src/Algolia.php index 40f31a26..88f811f0 100644 --- a/includes/libraries/algoliasearch-client-php/src/Algolia.php +++ b/includes/libraries/algoliasearch-client-php/src/Algolia.php @@ -10,7 +10,7 @@ final class Algolia { - const VERSION = '2.7.3'; + const VERSION = '3.0.2'; /** * Holds an instance of the simple cache repository (PSR-16). @@ -97,9 +97,9 @@ public static function getHttpClient() if (null === self::$httpClient) { if (class_exists('\GuzzleHttp\Client') && 6 <= $guzzleVersion) { - self::setHttpClient(new \Algolia\AlgoliaSearch\Http\Guzzle6HttpClient()); + self::setHttpClient(new \Algolia\AlgoliaSearch\Http\GuzzleHttpClient()); } else { - self::setHttpClient(new \Algolia\AlgoliaSearch\Http\Php53HttpClient()); + self::setHttpClient(new \Algolia\AlgoliaSearch\Http\CurlHttpClient()); } } diff --git a/includes/libraries/algoliasearch-client-php/src/AnalyticsClient.php b/includes/libraries/algoliasearch-client-php/src/AnalyticsClient.php index 0329f600..780b18ba 100644 --- a/includes/libraries/algoliasearch-client-php/src/AnalyticsClient.php +++ b/includes/libraries/algoliasearch-client-php/src/AnalyticsClient.php @@ -57,7 +57,7 @@ public static function createWithConfig(AnalyticsConfig $config) * * @return array */ - public function getABTests($requestOptions = array()) + public function getABTests($requestOptions = []) { return $this->api->read('GET', api_path('/2/abtests'), $requestOptions); } @@ -72,7 +72,7 @@ public function getABTests($requestOptions = array()) * * @throws \Algolia\AlgoliaSearch\Exceptions\AlgoliaException */ - public function getABTest($abTestID, $requestOptions = array()) + public function getABTest($abTestID, $requestOptions = []) { if (!$abTestID) { throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.'); @@ -89,7 +89,7 @@ public function getABTest($abTestID, $requestOptions = array()) * * @return array Information about the creation like TaskID and date */ - public function addABTest($abTest, $requestOptions = array()) + public function addABTest($abTest, $requestOptions = []) { return $this->api->write('POST', api_path('/2/abtests'), $abTest, $requestOptions); } @@ -104,13 +104,13 @@ public function addABTest($abTest, $requestOptions = array()) * * @throws \Algolia\AlgoliaSearch\Exceptions\AlgoliaException */ - public function stopABTest($abTestID, $requestOptions = array()) + public function stopABTest($abTestID, $requestOptions = []) { if (!$abTestID) { throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.'); } - return $this->api->write('POST', api_path('/2/abtests/%s', $abTestID), array(), $requestOptions); + return $this->api->write('POST', api_path('/2/abtests/%s/stop', $abTestID), [], $requestOptions); } /** @@ -123,16 +123,16 @@ public function stopABTest($abTestID, $requestOptions = array()) * * @throws \Algolia\AlgoliaSearch\Exceptions\AlgoliaException */ - public function deleteABTest($abTestID, $requestOptions = array()) + public function deleteABTest($abTestID, $requestOptions = []) { if (!$abTestID) { throw new AlgoliaException('Cannot retrieve ABTest because the abtestID is invalid.'); } - return $this->api->write('DELETE', api_path('/2/abtests/%s', $abTestID), array(), $requestOptions); + return $this->api->write('DELETE', api_path('/2/abtests/%s', $abTestID), [], $requestOptions); } - public function custom($method, $path, $requestOptions = array(), $hosts = null) + public function custom($method, $path, $requestOptions = [], $hosts = null) { return $this->api->send($method, $path, $requestOptions, $hosts); } diff --git a/includes/libraries/algoliasearch-client-php/src/Cache/FileCacheDriver.php b/includes/libraries/algoliasearch-client-php/src/Cache/FileCacheDriver.php index 0c509849..4e4173f1 100644 --- a/includes/libraries/algoliasearch-client-php/src/Cache/FileCacheDriver.php +++ b/includes/libraries/algoliasearch-client-php/src/Cache/FileCacheDriver.php @@ -61,7 +61,7 @@ public function clear() */ public function getMultiple($keys, $default = null) { - $result = array(); + $result = []; foreach ($keys as $key) { $result[$key] = $this->get($key, $default); } diff --git a/includes/libraries/algoliasearch-client-php/src/Cache/NullCacheDriver.php b/includes/libraries/algoliasearch-client-php/src/Cache/NullCacheDriver.php index b947ae9c..0eb1d6d3 100644 --- a/includes/libraries/algoliasearch-client-php/src/Cache/NullCacheDriver.php +++ b/includes/libraries/algoliasearch-client-php/src/Cache/NullCacheDriver.php @@ -43,7 +43,7 @@ public function clear() */ public function getMultiple($keys, $default = null) { - $return = array(); + $return = []; foreach ($keys as $key) { $return[$key] = $default; diff --git a/includes/libraries/algoliasearch-client-php/src/Config/AbstractConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/AbstractConfig.php index 60ee1597..9effe4f5 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/AbstractConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/AbstractConfig.php @@ -12,7 +12,7 @@ abstract class AbstractConfig protected $defaultConnectTimeout = 2; - public function __construct(array $config = array()) + public function __construct(array $config = []) { $config += $this->getDefaultConfig(); @@ -21,15 +21,15 @@ public function __construct(array $config = array()) public function getDefaultConfig() { - return array( + return [ 'appId' => '', 'apiKey' => '', 'hosts' => null, 'readTimeout' => $this->defaultReadTimeout, 'writeTimeout' => $this->defaultWriteTimeout, 'connectTimeout' => $this->defaultConnectTimeout, - 'defaultHeaders' => array(), - ); + 'defaultHeaders' => [], + ]; } public function getAppId() diff --git a/includes/libraries/algoliasearch-client-php/src/Config/AnalyticsConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/AnalyticsConfig.php index 73a4ea0c..ece77648 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/AnalyticsConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/AnalyticsConfig.php @@ -6,11 +6,11 @@ final class AnalyticsConfig extends AbstractConfig { public static function create($appId = null, $apiKey = null, $region = null) { - $config = array( + $config = [ 'appId' => null !== $appId ? $appId : getenv('ALGOLIA_APP_ID'), 'apiKey' => null !== $apiKey ? $apiKey : getenv('ALGOLIA_API_KEY'), 'region' => null !== $region ? $region : 'us', - ); + ]; return new static($config); } diff --git a/includes/libraries/algoliasearch-client-php/src/Config/InsightsConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/InsightsConfig.php index 59c805cc..feb15b89 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/InsightsConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/InsightsConfig.php @@ -6,11 +6,11 @@ final class InsightsConfig extends AbstractConfig { public static function create($appId = null, $apiKey = null, $region = null) { - $config = array( + $config = [ 'appId' => null !== $appId ? $appId : getenv('ALGOLIA_APP_ID'), 'apiKey' => null !== $apiKey ? $apiKey : getenv('ALGOLIA_API_KEY'), 'region' => null !== $region ? $region : 'us', - ); + ]; return new static($config); } diff --git a/includes/libraries/algoliasearch-client-php/src/Config/PlacesConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/PlacesConfig.php index 8bf0384b..e2a8aabb 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/PlacesConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/PlacesConfig.php @@ -6,10 +6,10 @@ final class PlacesConfig extends AbstractConfig { public static function create($appId, $apiKey) { - $config = array( + $config = [ 'appId' => $appId, 'apiKey' => $apiKey, - ); + ]; return new static($config); } diff --git a/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php index fe36399a..b451e777 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php @@ -13,11 +13,11 @@ final class RecommendationConfig extends AbstractConfig */ public static function create($appId = null, $apiKey = null, $region = null) { - $config = array( + $config = [ 'appId' => null !== $appId ? $appId : getenv('ALGOLIA_APP_ID'), 'apiKey' => null !== $apiKey ? $apiKey : getenv('ALGOLIA_API_KEY'), 'region' => null !== $region ? $region : 'us', - ); + ]; return new self($config); } diff --git a/includes/libraries/algoliasearch-client-php/src/Config/SearchConfig.php b/includes/libraries/algoliasearch-client-php/src/Config/SearchConfig.php index 516cec58..8e2ed0e3 100644 --- a/includes/libraries/algoliasearch-client-php/src/Config/SearchConfig.php +++ b/includes/libraries/algoliasearch-client-php/src/Config/SearchConfig.php @@ -8,17 +8,17 @@ class SearchConfig extends AbstractConfig public static function create($appId = null, $apiKey = null) { - $config = array( + $config = [ 'appId' => null !== $appId ? $appId : getenv('ALGOLIA_APP_ID'), 'apiKey' => null !== $apiKey ? $apiKey : getenv('ALGOLIA_API_KEY'), - ); + ]; return new static($config); } public function getDefaultConfig() { - return array( + return [ 'appId' => '', 'apiKey' => '', 'hosts' => null, @@ -26,10 +26,10 @@ public function getDefaultConfig() 'writeTimeout' => $this->defaultWriteTimeout, 'connectTimeout' => $this->defaultConnectTimeout, 'waitTaskTimeBeforeRetry' => $this->defaultWaitTaskTimeBeforeRetry, - 'defaultHeaders' => array(), + 'defaultHeaders' => [], 'defaultForwardToReplicas' => null, 'batchSize' => 1000, - ); + ]; } public function getWaitTaskTimeBeforeRetry() diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Php53HttpClient.php b/includes/libraries/algoliasearch-client-php/src/Http/CurlHttpClient.php similarity index 93% rename from includes/libraries/algoliasearch-client-php/src/Http/Php53HttpClient.php rename to includes/libraries/algoliasearch-client-php/src/Http/CurlHttpClient.php index c9edf3ec..24b7b1e9 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Php53HttpClient.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/CurlHttpClient.php @@ -5,13 +5,13 @@ use Algolia\AlgoliaSearch\Http\Psr7\Response; use Psr\Http\Message\RequestInterface; -final class Php53HttpClient implements HttpClientInterface +final class CurlHttpClient implements HttpClientInterface { private $curlMHandle; private $curlOptions; - public function __construct($curlOptions = array()) + public function __construct($curlOptions = []) { $this->curlOptions = $curlOptions; } @@ -29,7 +29,7 @@ public function sendRequest(RequestInterface $request, $timeout, $connectTimeout $this->invalidOptions($this->curlOptions, $e->getMessage()); } - $curlHeaders = array(); + $curlHeaders = []; foreach ($request->getHeaders() as $key => $values) { $curlHeaders[] = $key.': '.implode(',', $values); } @@ -106,7 +106,7 @@ public function sendRequest(RequestInterface $request, $timeout, $connectTimeout $this->releaseMHandle($curlHandle); curl_close($curlHandle); - return new Response($statusCode, array(), $responseBody, '1.1', $error); + return new Response($statusCode, [], $responseBody, '1.1', $error); } private function getMHandle($curlHandle) @@ -124,7 +124,7 @@ private function releaseMHandle($curlHandle) curl_multi_remove_handle($this->curlMHandle, $curlHandle); } - private function invalidOptions(array $curlOptions = array(), $errorMsg = '') + private function invalidOptions(array $curlOptions = [], $errorMsg = '') { throw new \OutOfBoundsException(sprintf('AlgoliaSearch curloptions options keys are invalid. %s given. error message : %s', json_encode($curlOptions), $errorMsg)); } diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Guzzle6HttpClient.php b/includes/libraries/algoliasearch-client-php/src/Http/GuzzleHttpClient.php similarity index 64% rename from includes/libraries/algoliasearch-client-php/src/Http/Guzzle6HttpClient.php rename to includes/libraries/algoliasearch-client-php/src/Http/GuzzleHttpClient.php index 377f9221..5bdaafd1 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Guzzle6HttpClient.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/GuzzleHttpClient.php @@ -4,12 +4,13 @@ use Algolia\AlgoliaSearch\Http\Psr7\Response; use GuzzleHttp\Client as GuzzleClient; -use GuzzleHttp\Exception\RequestException as GuzzleRequestException; +use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\Exception\RequestException; use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use Psr\Http\Message\RequestInterface; -final class Guzzle6HttpClient implements HttpClientInterface +final class GuzzleHttpClient implements HttpClientInterface { private $client; @@ -21,32 +22,40 @@ public function __construct(GuzzleClient $client = null) public function sendRequest(RequestInterface $request, $timeout, $connectTimeout) { try { - $response = $this->client->send($request, array( + $response = $this->client->send($request, [ 'timeout' => $timeout, 'connect_timeout' => $connectTimeout, - )); - } catch (GuzzleRequestException $e) { + ]); + } catch (RequestException $e) { if ($e->hasResponse()) { return $e->getResponse(); } else { return new Response( 0, - array(), + [], null, '1.1', $e->getMessage() ); } + } catch (ConnectException $e) { + return new Response( + 0, + [], + null, + '1.1', + $e->getMessage() + ); } return $response; } - private static function buildClient(array $config = array()) + private static function buildClient(array $config = []) { $handlerStack = new HandlerStack(\GuzzleHttp\choose_handler()); $handlerStack->push(Middleware::prepareBody(), 'prepare_body'); - $config = array_merge(array('handler' => $handlerStack), $config); + $config = array_merge(['handler' => $handlerStack], $config); return new GuzzleClient($config); } diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/BufferStream.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/BufferStream.php index 419726b6..61124faf 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/BufferStream.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/BufferStream.php @@ -136,6 +136,6 @@ public function getMetadata($key = null) return $this->hwm; } - return $key ? null : array(); + return $key ? null : []; } } diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/PumpStream.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/PumpStream.php index 30f2298a..e1194648 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/PumpStream.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/PumpStream.php @@ -43,11 +43,11 @@ class PumpStream implements StreamInterface * - metadata: Hash of metadata to use with stream. * - size: Size of the stream, if known */ - public function __construct(callable $source, array $options = array()) + public function __construct(callable $source, array $options = []) { $this->source = $source; $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : array(); + $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; $this->buffer = new BufferStream(); } diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Request.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Request.php index d7d1db71..b4cbc16d 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Request.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Request.php @@ -24,10 +24,10 @@ class Request implements RequestInterface private $uri; /** @var array Map of all registered headers, as original name => array of values */ - private $headers = array(); + private $headers = []; /** @var array Map of lowercase header name => original name at registration */ - private $headerNames = array(); + private $headerNames = []; /** @var string */ private $protocol = '1.1'; @@ -45,7 +45,7 @@ class Request implements RequestInterface public function __construct( $method, $uri, - array $headers = array(), + array $headers = [], $body = null, $version = '1.1' ) { @@ -150,7 +150,7 @@ private function updateHostFromUri() } // Ensure Host is the first header. // See: http://tools.ietf.org/html/rfc7230#section-5.4 - $this->headers = array($header => array($host)) + $this->headers; + $this->headers = [$header => [$host]] + $this->headers; } public function getProtocolVersion() @@ -183,7 +183,7 @@ public function getHeader($header) { $header = strtolower($header); if (!isset($this->headerNames[$header])) { - return array(); + return []; } $header = $this->headerNames[$header]; @@ -198,7 +198,7 @@ public function getHeaderLine($header) public function withHeader($header, $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); $normalized = strtolower($header); @@ -215,7 +215,7 @@ public function withHeader($header, $value) public function withAddedHeader($header, $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); $normalized = strtolower($header); @@ -266,10 +266,10 @@ public function withBody(StreamInterface $body) private function setHeaders(array $headers) { - $this->headerNames = $this->headers = array(); + $this->headerNames = $this->headers = []; foreach ($headers as $header => $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); $normalized = strtolower($header); diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Response.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Response.php index e44aea91..b16f702f 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Response.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Response.php @@ -16,10 +16,10 @@ class Response implements ResponseInterface { /** @var array Map of all registered headers, as original name => array of values */ - private $headers = array(); + private $headers = []; /** @var array Map of lowercase header name => original name at registration */ - private $headerNames = array(); + private $headerNames = []; /** @var string */ private $protocol = '1.1'; @@ -28,7 +28,7 @@ class Response implements ResponseInterface private $stream; /** @var array Map of standard HTTP status code/reason phrases */ - private static $phrases = array( + private static $phrases = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -87,7 +87,7 @@ class Response implements ResponseInterface 507 => 'Insufficient Storage', 508 => 'Loop Detected', 511 => 'Network Authentication Required', - ); + ]; /** @var string */ private $reasonPhrase = ''; @@ -104,7 +104,7 @@ class Response implements ResponseInterface */ public function __construct( $status = 200, - array $headers = array(), + array $headers = [], $body = null, $version = '1.1', $reason = null @@ -179,7 +179,7 @@ public function getHeader($header) $header = strtolower($header); if (!isset($this->headerNames[$header])) { - return array(); + return []; } $header = $this->headerNames[$header]; @@ -195,7 +195,7 @@ public function getHeaderLine($header) public function withHeader($header, $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); @@ -214,7 +214,7 @@ public function withHeader($header, $value) public function withAddedHeader($header, $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); @@ -271,10 +271,10 @@ public function withBody(StreamInterface $body) private function setHeaders(array $headers) { - $this->headerNames = $this->headers = array(); + $this->headerNames = $this->headers = []; foreach ($headers as $header => $value) { if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $value = $this->trimHeaderValues($value); diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Stream.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Stream.php index 27f0b6eb..818864e0 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Stream.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Stream.php @@ -26,20 +26,20 @@ class Stream implements StreamInterface private $customMetadata; /** @var array Hash of readable and writable stream types */ - private static $readWriteHash = array( - 'read' => array( + private static $readWriteHash = [ + 'read' => [ 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, 'x+t' => true, 'c+t' => true, 'a+' => true, - ), - 'write' => array( + ], + 'write' => [ 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true, - ), - ); + ], + ]; /** * This constructor accepts an associative array of options. @@ -55,7 +55,7 @@ class Stream implements StreamInterface * * @throws \InvalidArgumentException if the stream is not a stream resource */ - public function __construct($stream, $options = array()) + public function __construct($stream, $options = []) { if (!is_resource($stream)) { throw new \InvalidArgumentException('Stream must be a resource'); @@ -67,7 +67,7 @@ public function __construct($stream, $options = array()) $this->customMetadata = isset($options['metadata']) ? $options['metadata'] - : array(); + : []; $this->stream = $stream; $meta = stream_get_meta_data($this->stream); @@ -264,7 +264,7 @@ public function write($string) public function getMetadata($key = null) { if (!isset($this->stream)) { - return $key ? null : array(); + return $key ? null : []; } elseif (!$key) { return $this->customMetadata + stream_get_meta_data($this->stream); } elseif (isset($this->customMetadata[$key])) { diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Uri.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Uri.php index 63b14cc7..10ac02a8 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Uri.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/Uri.php @@ -25,7 +25,7 @@ class Uri implements UriInterface */ const HTTP_DEFAULT_HOST = 'localhost'; - private static $defaultPorts = array( + private static $defaultPorts = [ 'http' => 80, 'https' => 443, 'ftp' => 21, @@ -37,13 +37,13 @@ class Uri implements UriInterface 'imap' => 143, 'pop' => 110, 'ldap' => 389, - ); + ]; private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; private static $charSubDelims = '!\$&\'\(\)\*\+,;='; - private static $replaceQuery = array('=' => '%3D', '&' => '%26'); + private static $replaceQuery = ['=' => '%3D', '&' => '%26']; /** @var string Uri scheme. */ private $scheme = ''; @@ -342,7 +342,7 @@ public static function withQueryValue(UriInterface $uri, $key, $value) $current = $uri->getQuery(); if ('' === $current) { - $result = array(); + $result = []; } else { $decodedKey = rawurldecode($key); $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { @@ -651,7 +651,7 @@ private function filterPath($path) return preg_replace_callback( '/(?:[^'.self::$charUnreserved.self::$charSubDelims.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/', - array($this, 'rawurlencodeMatchZero'), + [$this, 'rawurlencodeMatchZero'], $path ); } @@ -673,7 +673,7 @@ private function filterQueryAndFragment($str) return preg_replace_callback( '/(?:[^'.self::$charUnreserved.self::$charSubDelims.'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', - array($this, 'rawurlencodeMatchZero'), + [$this, 'rawurlencodeMatchZero'], $str ); } diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/UriResolver.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/UriResolver.php index 46b228e9..4d65c9c9 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/UriResolver.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/UriResolver.php @@ -30,7 +30,7 @@ public static function removeDotSegments($path) return $path; } - $results = array(); + $results = []; $segments = explode('/', $path); $segment = null; foreach ($segments as $segment) { diff --git a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/functions.php b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/functions.php index 05c50f3d..37fd9927 100644 --- a/includes/libraries/algoliasearch-client-php/src/Http/Psr7/functions.php +++ b/includes/libraries/algoliasearch-client-php/src/Http/Psr7/functions.php @@ -7,7 +7,7 @@ /** * @internal */ -function stream_for($resource = '', array $options = array()) +function stream_for($resource = '', array $options = []) { if (is_scalar($resource)) { $stream = fopen('php://temp', 'r+'); diff --git a/includes/libraries/algoliasearch-client-php/src/Insights/UserInsightsClient.php b/includes/libraries/algoliasearch-client-php/src/Insights/UserInsightsClient.php index 62c53302..cc3fc8d4 100644 --- a/includes/libraries/algoliasearch-client-php/src/Insights/UserInsightsClient.php +++ b/includes/libraries/algoliasearch-client-php/src/Insights/UserInsightsClient.php @@ -19,99 +19,99 @@ public function __construct(InsightsClient $client, $userToken) $this->userToken = $userToken; } - public function clickedFilters($eventName, $indexName, $filters, $requestOptions = array()) + public function clickedFilters($eventName, $indexName, $filters, $requestOptions = []) { - return $this->clicked(array('filters' => $filters), $eventName, $indexName, $requestOptions); + return $this->clicked(['filters' => $filters], $eventName, $indexName, $requestOptions); } - public function clickedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = array()) + public function clickedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = []) { - return $this->clicked(array('objectIDs' => $objectIDs), $eventName, $indexName, $requestOptions); + return $this->clicked(['objectIDs' => $objectIDs], $eventName, $indexName, $requestOptions); } - public function clickedObjectIDsAfterSearch($eventName, $indexName, $objectIDs, $positions, $queryID, $requestOptions = array()) + public function clickedObjectIDsAfterSearch($eventName, $indexName, $objectIDs, $positions, $queryID, $requestOptions = []) { - $event = array( + $event = [ 'objectIDs' => $objectIDs, 'positions' => $positions, 'queryID' => $queryID, - ); + ]; return $this->clicked($event, $eventName, $indexName, $requestOptions); } private function clicked($event, $eventName, $indexName, $requestOptions) { - $event = array_merge($event, array( + $event = array_merge($event, [ 'eventType' => 'click', 'eventName' => $eventName, 'index' => $indexName, - )); + ]); return $this->sendEvent($event, $requestOptions); } - public function convertedFilters($eventName, $indexName, $filters, $requestOptions = array()) + public function convertedFilters($eventName, $indexName, $filters, $requestOptions = []) { - return $this->converted(array('filters' => $filters), $eventName, $indexName, $requestOptions); + return $this->converted(['filters' => $filters], $eventName, $indexName, $requestOptions); } - public function convertedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = array()) + public function convertedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = []) { - return $this->converted(array('objectIDs' => $objectIDs), $eventName, $indexName, $requestOptions); + return $this->converted(['objectIDs' => $objectIDs], $eventName, $indexName, $requestOptions); } - public function convertedObjectIDsAfterSearch($eventName, $indexName, $objectIDs, $queryID, $requestOptions = array()) + public function convertedObjectIDsAfterSearch($eventName, $indexName, $objectIDs, $queryID, $requestOptions = []) { - $event = array( + $event = [ 'objectIDs' => $objectIDs, 'queryID' => $queryID, - ); + ]; return $this->converted($event, $eventName, $indexName, $requestOptions); } private function converted($event, $eventName, $indexName, $requestOptions) { - $event = array_merge($event, array( + $event = array_merge($event, [ 'eventType' => 'conversion', 'eventName' => $eventName, 'index' => $indexName, - )); + ]); return $this->sendEvent($event, $requestOptions); } - public function viewedFilters($eventName, $indexName, $filters, $requestOptions = array()) + public function viewedFilters($eventName, $indexName, $filters, $requestOptions = []) { - $event = array( + $event = [ 'filters' => $filters, - ); + ]; return $this->viewed($event, $eventName, $indexName, $requestOptions); } - public function viewedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = array()) + public function viewedObjectIDs($eventName, $indexName, $objectIDs, $requestOptions = []) { - $event = array( + $event = [ 'objectIDs' => $objectIDs, - ); + ]; return $this->viewed($event, $eventName, $indexName, $requestOptions); } private function viewed($event, $eventName, $indexName, $requestOptions) { - $event = array_merge($event, array( + $event = array_merge($event, [ 'eventType' => 'view', 'eventName' => $eventName, 'index' => $indexName, - )); + ]); return $this->sendEvent($event, $requestOptions); } - private function sendEvent($event, $requestOptions = array()) + private function sendEvent($event, $requestOptions = []) { return $this->client->sendEvent($this->reformatEvent($event), $requestOptions); } @@ -119,15 +119,15 @@ private function sendEvent($event, $requestOptions = array()) private function reformatEvent($e) { if (isset($e['objectIDs']) && !is_array($e['objectIDs'])) { - $e['objectIDs'] = array($e['objectIDs']); + $e['objectIDs'] = [$e['objectIDs']]; } if (isset($e['filters']) && !is_array($e['filters'])) { - $e['filters'] = array($e['filters']); + $e['filters'] = [$e['filters']]; } if (isset($e['positions']) && !is_array($e['positions'])) { - $e['positions'] = array($e['positions']); + $e['positions'] = [$e['positions']]; } $e['userToken'] = $this->userToken; diff --git a/includes/libraries/algoliasearch-client-php/src/InsightsClient.php b/includes/libraries/algoliasearch-client-php/src/InsightsClient.php index db53a50e..237f2e97 100644 --- a/includes/libraries/algoliasearch-client-php/src/InsightsClient.php +++ b/includes/libraries/algoliasearch-client-php/src/InsightsClient.php @@ -57,14 +57,14 @@ public function user($userToken) return new UserInsightsClient($this, $userToken); } - public function sendEvent($event, $requestOptions = array()) + public function sendEvent($event, $requestOptions = []) { - return $this->sendEvents(array($event), $requestOptions); + return $this->sendEvents([$event], $requestOptions); } - public function sendEvents($events, $requestOptions = array()) + public function sendEvents($events, $requestOptions = []) { - $payload = array('events' => $events); + $payload = ['events' => $events]; return $this->api->write('POST', api_path('/1/events'), $payload, $requestOptions); } diff --git a/includes/libraries/algoliasearch-client-php/src/Iterators/AbstractAlgoliaIterator.php b/includes/libraries/algoliasearch-client-php/src/Iterators/AbstractAlgoliaIterator.php index 07828494..ad11dff2 100644 --- a/includes/libraries/algoliasearch-client-php/src/Iterators/AbstractAlgoliaIterator.php +++ b/includes/libraries/algoliasearch-client-php/src/Iterators/AbstractAlgoliaIterator.php @@ -52,13 +52,13 @@ abstract protected function fetchNextPage(); */ abstract protected function formatHit(array $hit); - public function __construct($indexName, ApiWrapper $api, $requestOptions = array()) + public function __construct($indexName, ApiWrapper $api, $requestOptions = []) { $this->indexName = $indexName; $this->api = $api; - $this->requestOptions = $requestOptions + array( + $this->requestOptions = $requestOptions + [ 'hitsPerPage' => 1000, - ); + ]; $this->fetchNextPage(); } diff --git a/includes/libraries/algoliasearch-client-php/src/Iterators/ObjectIterator.php b/includes/libraries/algoliasearch-client-php/src/Iterators/ObjectIterator.php index 3d22525f..d7a3f3da 100644 --- a/includes/libraries/algoliasearch-client-php/src/Iterators/ObjectIterator.php +++ b/includes/libraries/algoliasearch-client-php/src/Iterators/ObjectIterator.php @@ -28,7 +28,7 @@ protected function fetchNextPage() return; } - $cursor = array(); + $cursor = []; if (isset($this->response['cursor'])) { $cursor['cursor'] = $this->response['cursor']; } diff --git a/includes/libraries/algoliasearch-client-php/src/Iterators/RuleIterator.php b/includes/libraries/algoliasearch-client-php/src/Iterators/RuleIterator.php index 361b801d..1317697b 100644 --- a/includes/libraries/algoliasearch-client-php/src/Iterators/RuleIterator.php +++ b/includes/libraries/algoliasearch-client-php/src/Iterators/RuleIterator.php @@ -24,7 +24,7 @@ protected function fetchNextPage() Helpers::apiPath('/1/indexes/%s/rules/search', $this->indexName), array_merge( $this->requestOptions, - array('page' => $this->page) + ['page' => $this->page] ) ); diff --git a/includes/libraries/algoliasearch-client-php/src/Iterators/SynonymIterator.php b/includes/libraries/algoliasearch-client-php/src/Iterators/SynonymIterator.php index acb8268a..d1681108 100644 --- a/includes/libraries/algoliasearch-client-php/src/Iterators/SynonymIterator.php +++ b/includes/libraries/algoliasearch-client-php/src/Iterators/SynonymIterator.php @@ -24,7 +24,7 @@ protected function fetchNextPage() Helpers::apiPath('/1/indexes/%s/synonyms/search', $this->indexName), array_merge( $this->requestOptions, - array('page' => $this->page) + ['page' => $this->page] ) ); diff --git a/includes/libraries/algoliasearch-client-php/src/Log/DebugLogger.php b/includes/libraries/algoliasearch-client-php/src/Log/DebugLogger.php index 27db1d0e..0c765407 100644 --- a/includes/libraries/algoliasearch-client-php/src/Log/DebugLogger.php +++ b/includes/libraries/algoliasearch-client-php/src/Log/DebugLogger.php @@ -38,14 +38,14 @@ public static function enable() /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) + public function log($level, $message, array $context = []) { if (self::$isEnabled) { - $logMessage = array( + $logMessage = [ 'level' => $level, 'message' => $message, 'context' => $context, - ); + ]; if (function_exists('dump')) { dump($logMessage); diff --git a/includes/libraries/algoliasearch-client-php/src/PlacesClient.php b/includes/libraries/algoliasearch-client-php/src/PlacesClient.php index 2047dda9..47522504 100644 --- a/includes/libraries/algoliasearch-client-php/src/PlacesClient.php +++ b/includes/libraries/algoliasearch-client-php/src/PlacesClient.php @@ -58,7 +58,7 @@ public static function createWithConfig(PlacesConfig $config) return new static($apiWrapper, $config); } - public function search($query, $requestOptions = array()) + public function search($query, $requestOptions = []) { $query = (string) $query; @@ -71,12 +71,12 @@ public function search($query, $requestOptions = array()) return $this->api->read('POST', api_path('/1/places/query'), $requestOptions); } - public function getObject($objectID, $requestOptions = array()) + public function getObject($objectID, $requestOptions = []) { return $this->api->read('GET', api_path('/1/places/%s', $objectID), $requestOptions); } - public function custom($method, $path, $requestOptions = array(), $hosts = null) + public function custom($method, $path, $requestOptions = [], $hosts = null) { return $this->api->send($method, $path, $requestOptions, $hosts); } diff --git a/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php b/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php index 4d82dadc..ac57630e 100644 --- a/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php +++ b/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php @@ -70,7 +70,7 @@ public static function createWithConfig(RecommendationConfig $config) * * @return array */ - public function getPersonalizationStrategy($requestOptions = array()) + public function getPersonalizationStrategy($requestOptions = []) { return $this->api->read('GET', api_path('/1/strategies/personalization'), $requestOptions); } @@ -81,7 +81,7 @@ public function getPersonalizationStrategy($requestOptions = array()) * * @return array */ - public function setPersonalizationStrategy($strategy, $requestOptions = array()) + public function setPersonalizationStrategy($strategy, $requestOptions = []) { return $this->api->write('POST', api_path('/1/strategies/personalization'), $strategy, $requestOptions); } diff --git a/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptions.php b/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptions.php index 16500f0b..45b17622 100644 --- a/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptions.php +++ b/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptions.php @@ -6,11 +6,11 @@ final class RequestOptions { - private $headers = array(); + private $headers = []; - private $query = array(); + private $query = []; - private $body = array(); + private $body = []; private $readTimeout; @@ -18,9 +18,9 @@ final class RequestOptions private $connectTimeout; - public function __construct(array $options = array()) + public function __construct(array $options = []) { - foreach (array('headers', 'query', 'body') as $name) { + foreach (['headers', 'query', 'body'] as $name) { if (isset($options[$name]) && !empty($options[$name])) { $this->{$name} = $options[$name]; } diff --git a/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptionsFactory.php b/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptionsFactory.php index 575eee47..1c43c592 100644 --- a/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptionsFactory.php +++ b/includes/libraries/algoliasearch-client-php/src/RequestOptions/RequestOptionsFactory.php @@ -9,18 +9,18 @@ final class RequestOptionsFactory { private $config; - private $validQueryParameters = array( + private $validQueryParameters = [ 'forwardToReplicas', 'replaceExistingSynonyms', 'clearExistingRules', 'getVersion', - ); + ]; - private $validHeaders = array( + private $validHeaders = [ 'Content-type', 'User-Agent', 'createIfNotExists', - ); + ]; public function __construct(AbstractConfig $config) { @@ -33,7 +33,7 @@ public function __construct(AbstractConfig $config) * * @return \Algolia\AlgoliaSearch\RequestOptions\RequestOptions */ - public function create($options, $defaults = array()) + public function create($options, $defaults = []) { if (is_array($options)) { $options += $defaults; @@ -53,35 +53,35 @@ public function create($options, $defaults = array()) return $options->addDefaultHeaders($this->config->getDefaultHeaders()); } - public function createBodyLess($options, $defaults = array()) + public function createBodyLess($options, $defaults = []) { $options = $this->create($options, $defaults); return $options ->addQueryParameters($options->getBody()) - ->setBody(array()); + ->setBody([]); } private function normalize($options) { - $normalized = array( - 'headers' => array( + $normalized = [ + 'headers' => [ 'X-Algolia-Application-Id' => $this->config->getAppId(), 'X-Algolia-API-Key' => $this->config->getApiKey(), 'User-Agent' => UserAgent::get(), 'Content-Type' => 'application/json', - ), - 'query' => array(), - 'body' => array(), + ], + 'query' => [], + 'body' => [], 'readTimeout' => $this->config->getReadTimeout(), 'writeTimeout' => $this->config->getWriteTimeout(), 'connectTimeout' => $this->config->getConnectTimeout(), - ); + ]; foreach ($options as $optionName => $value) { $type = $this->getOptionType($optionName); - if (in_array($type, array('readTimeout', 'writeTimeout', 'connectTimeout'))) { + if (in_array($type, ['readTimeout', 'writeTimeout', 'connectTimeout'])) { $normalized[$type] = $value; } else { $normalized[$type][$optionName] = $value; @@ -94,7 +94,7 @@ private function normalize($options) private function format($options) { foreach ($options as $name => $value) { - if (in_array($name, array('attributesToRetrieve', 'type'), true)) { + if (in_array($name, ['attributesToRetrieve', 'type'], true)) { if (is_array($value)) { $options[$name] = implode(',', $value); } @@ -110,7 +110,7 @@ private function getOptionType($optionName) return 'headers'; } elseif (in_array($optionName, $this->validQueryParameters, true)) { return 'query'; - } elseif (in_array($optionName, array('connectTimeout', 'readTimeout', 'writeTimeout'), true)) { + } elseif (in_array($optionName, ['connectTimeout', 'readTimeout', 'writeTimeout'], true)) { return $optionName; } else { return 'body'; diff --git a/includes/libraries/algoliasearch-client-php/src/Response/AbstractResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/AbstractResponse.php index 3150a76d..4103c70c 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/AbstractResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/AbstractResponse.php @@ -9,7 +9,7 @@ abstract class AbstractResponse implements \ArrayAccess */ protected $apiResponse; - abstract public function wait($requestOptions = array()); + abstract public function wait($requestOptions = []); /** * @return array The actual response from Algolia API diff --git a/includes/libraries/algoliasearch-client-php/src/Response/AddApiKeyResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/AddApiKeyResponse.php index d90c876b..535d0ad4 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/AddApiKeyResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/AddApiKeyResponse.php @@ -25,7 +25,7 @@ public function __construct(array $apiResponse, SearchClient $client, SearchConf $this->config = $config; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (!isset($this->client)) { return $this; diff --git a/includes/libraries/algoliasearch-client-php/src/Response/BatchIndexingResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/BatchIndexingResponse.php index e741b44f..5fdde6e5 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/BatchIndexingResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/BatchIndexingResponse.php @@ -22,7 +22,7 @@ public function __construct(array $apiResponse, SearchIndex $index) $this->index = $index; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (isset($this->index)) { foreach ($this->apiResponse as $response) { diff --git a/includes/libraries/algoliasearch-client-php/src/Response/DeleteApiKeyResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/DeleteApiKeyResponse.php index 0ea45b1d..b5a26200 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/DeleteApiKeyResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/DeleteApiKeyResponse.php @@ -31,7 +31,7 @@ public function __construct(array $apiResponse, SearchClient $client, SearchConf $this->key = $key; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (!isset($this->client)) { return $this; diff --git a/includes/libraries/algoliasearch-client-php/src/Response/DictionaryResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/DictionaryResponse.php new file mode 100644 index 00000000..c80d92bc --- /dev/null +++ b/includes/libraries/algoliasearch-client-php/src/Response/DictionaryResponse.php @@ -0,0 +1,78 @@ +apiResponse = $apiResponse; + $this->client = $client; + $this->config = $config; + } + + /** + * Wait for the task from this response to finish. + * + * @param array|RequestOptions $requestOptions + * + * @return $this + */ + public function wait($requestOptions = []) + { + $retryCount = 1; + $time = $this->config->getWaitTaskTimeBeforeRetry(); + + while (!$this->done) { + $res = $this->getTask($this->apiResponse['taskID'], $requestOptions); + + if ('published' === $res['status']) { + $this->done = true; + break; + } + + $retryCount++; + $factor = ceil($retryCount / 10); + usleep($factor * $time); // 0.1 second + } + + return $this; + } + + /** + * Get the task details. + * + * @param int|string $taskId + * @param array|RequestOptions $requestOptions + * + * @return mixed + */ + private function getTask($taskId, $requestOptions = []) + { + if (!$taskId) { + throw new \InvalidArgumentException('taskID cannot be empty'); + } + + return $this->client->custom( + 'GET', + \Algolia\AlgoliaSearch\api_path('/1/task/%s', $taskId), + $requestOptions + ); + } +} diff --git a/includes/libraries/algoliasearch-client-php/src/Response/IndexingResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/IndexingResponse.php index dcf3b697..b12ec352 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/IndexingResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/IndexingResponse.php @@ -17,7 +17,7 @@ public function __construct(array $apiResponse, SearchIndex $index) $this->index = $index; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (isset($this->index)) { $this->index->waitTask($this->apiResponse['taskID'], $requestOptions); diff --git a/includes/libraries/algoliasearch-client-php/src/Response/MultiResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/MultiResponse.php index fc42c0aa..cfeb79f0 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/MultiResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/MultiResponse.php @@ -11,7 +11,7 @@ public function __construct($responses) $this->apiResponse = $responses; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { foreach ($this->apiResponse as $response) { $response->wait(); diff --git a/includes/libraries/algoliasearch-client-php/src/Response/MultipleIndexBatchIndexingResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/MultipleIndexBatchIndexingResponse.php index 1e44d88c..ebd35fb1 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/MultipleIndexBatchIndexingResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/MultipleIndexBatchIndexingResponse.php @@ -17,7 +17,7 @@ public function __construct(array $apiResponse, SearchClient $client) $this->client = $client; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (!isset($this->client)) { return $this; diff --git a/includes/libraries/algoliasearch-client-php/src/Response/NullResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/NullResponse.php index 2fc75db0..cd16d8bd 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/NullResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/NullResponse.php @@ -6,10 +6,10 @@ final class NullResponse extends AbstractResponse { public function __construct() { - $this->apiResponse = array(); + $this->apiResponse = []; } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { return $this; } diff --git a/includes/libraries/algoliasearch-client-php/src/Response/RestoreApiKeyResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/RestoreApiKeyResponse.php index dfe02baf..917fe057 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/RestoreApiKeyResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/RestoreApiKeyResponse.php @@ -39,7 +39,7 @@ public function __construct(array $apiResponse, SearchClient $client, SearchConf /** * {@inheritdoc} */ - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (!isset($this->client)) { return $this; diff --git a/includes/libraries/algoliasearch-client-php/src/Response/UpdateApiKeyResponse.php b/includes/libraries/algoliasearch-client-php/src/Response/UpdateApiKeyResponse.php index 15d667cf..e17bec9b 100644 --- a/includes/libraries/algoliasearch-client-php/src/Response/UpdateApiKeyResponse.php +++ b/includes/libraries/algoliasearch-client-php/src/Response/UpdateApiKeyResponse.php @@ -32,7 +32,7 @@ public function __construct( $this->keyParams = $this->filterOnlyKeyParams($requestOptions); } - public function wait($requestOptions = array()) + public function wait($requestOptions = []) { if (!isset($this->client)) { return $this; @@ -75,11 +75,11 @@ private function isKeyUpdated($key, $keyParams) private function filterOnlyKeyParams($requestOptions) { - $validKeyParams = array( + $validKeyParams = [ 'acl', 'indexes', 'referers', 'restrictSources', 'queryParameters', 'description', 'validity', 'maxQueriesPerIPPerHour', 'maxHitsPerQuery', - ); + ]; return array_intersect_key($requestOptions, array_flip($validKeyParams)); } diff --git a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapper.php b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapper.php index 6c8f1a0a..3409641e 100644 --- a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapper.php +++ b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapper.php @@ -71,7 +71,7 @@ public function __construct( } } - public function read($method, $path, $requestOptions = array(), $defaultRequestOptions = array()) + public function read($method, $path, $requestOptions = [], $defaultRequestOptions = []) { if ('GET' === strtoupper($method)) { $requestOptions = $this->requestOptionsFactory->createBodyLess($requestOptions, $defaultRequestOptions); @@ -88,11 +88,11 @@ public function read($method, $path, $requestOptions = array(), $defaultRequestO ); } - public function write($method, $path, $data = array(), $requestOptions = array(), $defaultRequestOptions = array()) + public function write($method, $path, $data = [], $requestOptions = [], $defaultRequestOptions = []) { if ('DELETE' === strtoupper($method)) { $requestOptions = $this->requestOptionsFactory->createBodyLess($requestOptions, $defaultRequestOptions); - $data = array(); + $data = []; } else { $requestOptions = $this->requestOptionsFactory->create($requestOptions, $defaultRequestOptions); } @@ -107,14 +107,14 @@ public function write($method, $path, $data = array(), $requestOptions = array() ); } - public function send($method, $path, $requestOptions = array(), $hosts = null) + public function send($method, $path, $requestOptions = [], $hosts = null) { $requestOptions = $this->requestOptionsFactory->create($requestOptions); if (null === $hosts) { $hosts = $this->clusterHosts->write(); } elseif (!is_array($hosts)) { - $hosts = array($hosts); + $hosts = [$hosts]; } return $this->request( @@ -126,7 +126,7 @@ public function send($method, $path, $requestOptions = array(), $hosts = null) ); } - private function request($method, $path, RequestOptions $requestOptions, $hosts, $timeout, $data = array()) + private function request($method, $path, RequestOptions $requestOptions, $hosts, $timeout, $data = []) { $uri = $this->createUri($path) ->withQuery($requestOptions->getBuiltQueryParameters()) @@ -134,12 +134,12 @@ private function request($method, $path, RequestOptions $requestOptions, $hosts, $body = array_merge($data, $requestOptions->getBody()); - $logParams = array( + $logParams = [ 'body' => $body, 'headers' => $requestOptions->getHeaders(), 'method' => $method, 'query' => $requestOptions->getQueryParameters(), - ); + ]; $retry = 1; foreach ($hosts as $host) { @@ -171,9 +171,9 @@ private function request($method, $path, RequestOptions $requestOptions, $hosts, return $responseBody; } catch (RetriableException $e) { - $this->log(LogLevel::DEBUG, 'Host failed.', array_merge($logParams, array( + $this->log(LogLevel::DEBUG, 'Host failed.', array_merge($logParams, [ 'description' => $e->getMessage(), - ))); + ])); $this->clusterHosts->failed($host); } catch (BadRequestException $e) { @@ -238,7 +238,7 @@ private function createUri($uri) private function createRequest( $method, $uri, - array $headers = array(), + array $headers = [], $body = null, $protocolVersion = '1.1' ) { @@ -262,7 +262,7 @@ private function createRequest( * @param string $level * @param string $message */ - private function log($level, $message, array $context = array()) + private function log($level, $message, array $context = []) { $this->logger->log($level, 'Algolia API client: '.$message, $context); } diff --git a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapperInterface.php b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapperInterface.php index 7e93f803..9d2ba6f8 100644 --- a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapperInterface.php +++ b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ApiWrapperInterface.php @@ -4,9 +4,9 @@ interface ApiWrapperInterface { - public function read($method, $path, $requestOptions = array(), $defaultRequestOptions = array()); + public function read($method, $path, $requestOptions = [], $defaultRequestOptions = []); - public function write($method, $path, $data = array(), $requestOptions = array(), $defaultRequestOptions = array()); + public function write($method, $path, $data = [], $requestOptions = [], $defaultRequestOptions = []); - public function send($method, $path, $requestOptions = array(), $hosts = null); + public function send($method, $path, $requestOptions = [], $hosts = null); } diff --git a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ClusterHosts.php b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ClusterHosts.php index 7873b6d0..8c5a423e 100644 --- a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ClusterHosts.php +++ b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/ClusterHosts.php @@ -32,11 +32,11 @@ public static function create($read, $write = null) } if (is_string($read)) { - $read = array($read => 0); + $read = [$read => 0]; } if (is_string($write)) { - $write = array($write => 0); + $write = [$write => 0]; } if (array_values($read) === $read) { @@ -52,11 +52,11 @@ public static function create($read, $write = null) public static function createFromAppId($applicationId) { - $read = $write = array( + $read = $write = [ $applicationId.'-1.algolianet.com' => 0, $applicationId.'-2.algolianet.com' => 0, $applicationId.'-3.algolianet.com' => 0, - ); + ]; $read[$applicationId.'-dsn.algolia.net'] = 10; $write[$applicationId.'.algolia.net'] = 10; @@ -66,11 +66,11 @@ public static function createFromAppId($applicationId) public static function createForPlaces() { - $read = $write = array( + $read = $write = [ 'places-1.algolianet.com' => 0, 'places-2.algolianet.com' => 0, 'places-3.algolianet.com' => 0, - ); + ]; $read['places-dsn.algolia.net'] = 10; $write['places.algolia.net'] = 10; diff --git a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/HostCollection.php b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/HostCollection.php index a8191484..77dc1c4d 100644 --- a/includes/libraries/algoliasearch-client-php/src/RetryStrategy/HostCollection.php +++ b/includes/libraries/algoliasearch-client-php/src/RetryStrategy/HostCollection.php @@ -18,7 +18,7 @@ public function __construct(array $hosts) public static function create(array $urlsWithPriority) { - $hosts = array(); + $hosts = []; foreach ($urlsWithPriority as $url => $priority) { $hosts[] = new Host($url, $priority); } diff --git a/includes/libraries/algoliasearch-client-php/src/SearchClient.php b/includes/libraries/algoliasearch-client-php/src/SearchClient.php index 20a08a00..c5aee7ec 100644 --- a/includes/libraries/algoliasearch-client-php/src/SearchClient.php +++ b/includes/libraries/algoliasearch-client-php/src/SearchClient.php @@ -7,6 +7,7 @@ use Algolia\AlgoliaSearch\RequestOptions\RequestOptions; use Algolia\AlgoliaSearch\Response\AddApiKeyResponse; use Algolia\AlgoliaSearch\Response\DeleteApiKeyResponse; +use Algolia\AlgoliaSearch\Response\DictionaryResponse; use Algolia\AlgoliaSearch\Response\IndexingResponse; use Algolia\AlgoliaSearch\Response\MultipleIndexBatchIndexingResponse; use Algolia\AlgoliaSearch\Response\RestoreApiKeyResponse; @@ -85,76 +86,84 @@ public function getAppId() return $this->config->getAppId(); } - public function moveIndex($srcIndexName, $newIndexName, $requestOptions = array()) + public function moveIndex($srcIndexName, $newIndexName, $requestOptions = []) { $response = $this->api->write( 'POST', api_path('/1/indexes/%s/operation', $srcIndexName), - array( + [ 'operation' => 'move', 'destination' => $newIndexName, - ), + ], $requestOptions ); return new IndexingResponse($response, $this->initIndex($srcIndexName)); } - public function copyIndex($srcIndexName, $destIndexName, $requestOptions = array()) + public function copyIndex($srcIndexName, $destIndexName, $requestOptions = []) { $response = $this->api->write( 'POST', api_path('/1/indexes/%s/operation', $srcIndexName), - array( + [ 'operation' => 'copy', 'destination' => $destIndexName, - ), + ], $requestOptions ); return new IndexingResponse($response, $this->initIndex($srcIndexName)); } - public function copySettings($srcIndexName, $destIndexName, $requestOptions = array()) + public function copySettings($srcIndexName, $destIndexName, $requestOptions = []) { if (is_array($requestOptions)) { - $requestOptions['scope'] = array('settings'); + $requestOptions['scope'] = ['settings']; } elseif ($requestOptions instanceof RequestOptions) { - $requestOptions->addBodyParameter('scope', array('settings')); + $requestOptions->addBodyParameter('scope', ['settings']); } return $this->copyIndex($srcIndexName, $destIndexName, $requestOptions); } - public function copySynonyms($srcIndexName, $destIndexName, $requestOptions = array()) + public function copySynonyms($srcIndexName, $destIndexName, $requestOptions = []) { if (is_array($requestOptions)) { - $requestOptions['scope'] = array('synonyms'); + $requestOptions['scope'] = ['synonyms']; } elseif ($requestOptions instanceof RequestOptions) { - $requestOptions->addBodyParameter('scope', array('synonyms')); + $requestOptions->addBodyParameter('scope', ['synonyms']); } return $this->copyIndex($srcIndexName, $destIndexName, $requestOptions); } - public function copyRules($srcIndexName, $destIndexName, $requestOptions = array()) + public function copyRules($srcIndexName, $destIndexName, $requestOptions = []) { if (is_array($requestOptions)) { - $requestOptions['scope'] = array('rules'); + $requestOptions['scope'] = ['rules']; } elseif ($requestOptions instanceof RequestOptions) { - $requestOptions->addBodyParameter('scope', array('rules')); + $requestOptions->addBodyParameter('scope', ['rules']); } return $this->copyIndex($srcIndexName, $destIndexName, $requestOptions); } - public function isAlive($requestOptions = array()) + public function isAlive($requestOptions = []) { return $this->api->read('GET', api_path('/1/isalive'), $requestOptions); } - public function multipleQueries($queries, $requestOptions = array()) + public function multipleQueries($queries, $requestOptions = []) { + $queries = array_map(function ($query) { + $query['params'] = isset($query['params']) ? + Helpers::serializeQueryParameters($query['params']) : + Helpers::serializeQueryParameters([]); + + return $query; + }, $queries); + if (is_array($requestOptions)) { $requestOptions['requests'] = $queries; } elseif ($requestOptions instanceof RequestOptions) { @@ -168,19 +177,19 @@ public function multipleQueries($queries, $requestOptions = array()) ); } - public function multipleBatch($operations, $requestOptions = array()) + public function multipleBatch($operations, $requestOptions = []) { $response = $this->api->write( 'POST', api_path('/1/indexes/*/batch'), - array('requests' => $operations), + ['requests' => $operations], $requestOptions ); return new MultipleIndexBatchIndexingResponse($response, $this); } - public function multipleGetObjects($requests, $requestOptions = array()) + public function multipleGetObjects($requests, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['requests'] = $requests; @@ -195,47 +204,47 @@ public function multipleGetObjects($requests, $requestOptions = array()) ); } - public function listIndices($requestOptions = array()) + public function listIndices($requestOptions = []) { return $this->api->read('GET', api_path('/1/indexes/'), $requestOptions); } - public function listApiKeys($requestOptions = array()) + public function listApiKeys($requestOptions = []) { return $this->api->read('GET', api_path('/1/keys'), $requestOptions); } - public function getApiKey($key, $requestOptions = array()) + public function getApiKey($key, $requestOptions = []) { return $this->api->read('GET', api_path('/1/keys/%s', $key), $requestOptions); } - public function addApiKey($acl, $requestOptions = array()) + public function addApiKey($acl, $requestOptions = []) { - $acl = array('acl' => $acl); + $acl = ['acl' => $acl]; $response = $this->api->write('POST', api_path('/1/keys'), $acl, $requestOptions); return new AddApiKeyResponse($response, $this, $this->config); } - public function updateApiKey($key, $requestOptions = array()) + public function updateApiKey($key, $requestOptions = []) { - $response = $this->api->write('PUT', api_path('/1/keys/%s', $key), array(), $requestOptions); + $response = $this->api->write('PUT', api_path('/1/keys/%s', $key), [], $requestOptions); return new UpdateApiKeyResponse($response, $this, $this->config, $requestOptions); } - public function deleteApiKey($key, $requestOptions = array()) + public function deleteApiKey($key, $requestOptions = []) { - $response = $this->api->write('DELETE', api_path('/1/keys/%s', $key), array(), $requestOptions); + $response = $this->api->write('DELETE', api_path('/1/keys/%s', $key), [], $requestOptions); return new DeleteApiKeyResponse($response, $this, $this->config, $key); } - public function restoreApiKey($key, $requestOptions = array()) + public function restoreApiKey($key, $requestOptions = []) { - $response = $this->api->write('POST', api_path('/1/keys/%s/restore', $key), array(), $requestOptions); + $response = $this->api->write('POST', api_path('/1/keys/%s/restore', $key), [], $requestOptions); return new RestoreApiKeyResponse($response, $this, $this->config, $key); } @@ -253,7 +262,7 @@ public static function generateSecuredApiKey($parentApiKey, $restrictions) * @deprecated endpoint will be deprecated * @see RecommendationClient */ - public function getPersonalizationStrategy($requestOptions = array()) + public function getPersonalizationStrategy($requestOptions = []) { return $this->api->read('GET', api_path('/1/recommendation/personalization/strategy'), $requestOptions); } @@ -262,7 +271,7 @@ public function getPersonalizationStrategy($requestOptions = array()) * @deprecated endpoint will be deprecated * @see RecommendationClient */ - public function setPersonalizationStrategy($strategy, $requestOptions = array()) + public function setPersonalizationStrategy($strategy, $requestOptions = []) { $apiResponse = $this->api->write( 'POST', @@ -274,7 +283,7 @@ public function setPersonalizationStrategy($strategy, $requestOptions = array()) return $apiResponse; } - public function searchUserIds($query, $requestOptions = array()) + public function searchUserIds($query, $requestOptions = []) { $query = (string) $query; @@ -287,17 +296,17 @@ public function searchUserIds($query, $requestOptions = array()) return $this->api->read('POST', api_path('/1/clusters/mapping/search'), $requestOptions); } - public function listClusters($requestOptions = array()) + public function listClusters($requestOptions = []) { return $this->api->read('GET', api_path('/1/clusters'), $requestOptions); } - public function listUserIds($requestOptions = array()) + public function listUserIds($requestOptions = []) { return $this->api->read('GET', api_path('/1/clusters/mapping'), $requestOptions); } - public function getUserId($userId, $requestOptions = array()) + public function getUserId($userId, $requestOptions = []) { return $this->api->read('GET', api_path('/1/clusters/mapping/%s', $userId), $requestOptions); } @@ -305,7 +314,7 @@ public function getUserId($userId, $requestOptions = array()) /** * @deprecated since 2.6.1, use getTopUserIds instead. */ - public function getTopUserId($requestOptions = array()) + public function getTopUserId($requestOptions = []) { return $this->getTopUserIds($requestOptions); } @@ -317,12 +326,12 @@ public function getTopUserId($requestOptions = array()) * * @return array */ - public function getTopUserIds($requestOptions = array()) + public function getTopUserIds($requestOptions = []) { return $this->api->read('GET', api_path('/1/clusters/mapping/top'), $requestOptions); } - public function assignUserId($userId, $clusterName, $requestOptions = array()) + public function assignUserId($userId, $clusterName, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['X-Algolia-User-ID'] = $userId; @@ -333,9 +342,9 @@ public function assignUserId($userId, $clusterName, $requestOptions = array()) return $this->api->write( 'POST', api_path('/1/clusters/mapping'), - array( + [ 'cluster' => $clusterName, - ), + ], $requestOptions ); } @@ -349,20 +358,20 @@ public function assignUserId($userId, $clusterName, $requestOptions = array()) * * @return array */ - public function assignUserIds($userIds, $clusterName, $requestOptions = array()) + public function assignUserIds($userIds, $clusterName, $requestOptions = []) { return $this->api->write( 'POST', api_path('/1/clusters/mapping/batch'), - array( + [ 'users' => $userIds, 'cluster' => $clusterName, - ), + ], $requestOptions ); } - public function removeUserId($userId, $requestOptions = array()) + public function removeUserId($userId, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['X-Algolia-User-ID'] = $userId; @@ -373,31 +382,31 @@ public function removeUserId($userId, $requestOptions = array()) return $this->api->write( 'DELETE', api_path('/1/clusters/mapping'), - array(), + [], $requestOptions ); } - public function getLogs($requestOptions = array()) + public function getLogs($requestOptions = []) { return $this->api->read('GET', api_path('/1/logs'), $requestOptions); } - public function getTask($indexName, $taskId, $requestOptions = array()) + public function getTask($indexName, $taskId, $requestOptions = []) { $index = $this->initIndex($indexName); return $index->getTask($taskId, $requestOptions); } - public function waitTask($indexName, $taskId, $requestOptions = array()) + public function waitTask($indexName, $taskId, $requestOptions = []) { $index = $this->initIndex($indexName); $index->waitTask($taskId, $requestOptions); } - public function custom($method, $path, $requestOptions = array(), $hosts = null) + public function custom($method, $path, $requestOptions = [], $hosts = null) { return $this->api->send($method, $path, $requestOptions, $hosts); } @@ -433,7 +442,7 @@ public static function getSecuredApiKeyRemainingValidity($securedAPIKey) * * @return array */ - public function hasPendingMappings($requestOptions = array()) + public function hasPendingMappings($requestOptions = []) { if (isset($requestOptions['retrieveMappings']) && true === $requestOptions['retrieveMappings']) { @@ -450,4 +459,149 @@ public function hasPendingMappings($requestOptions = array()) $requestOptions ); } + + /** + * Save entries to the given dictionary. + * + * @param string $dictionary + * @param array> $entries + * @param array|RequestOptions $requestOptions + * + * @return DictionaryResponse + */ + public function saveDictionaryEntries($dictionary, $entries, $requestOptions = []) + { + $response = $this->api->write( + 'POST', + api_path('/1/dictionaries/%s/batch', $dictionary), + [ + 'clearExistingDictionaryEntries' => false, + 'requests' => Helpers::buildBatch($entries, 'addEntry'), + ], + $requestOptions + ); + + return new DictionaryResponse($response, $this, $this->config); + } + + /** + * Replace all dictionary entries. + * + * @param string $dictionary + * @param array> $entries + * @param array $requestOptions + * + * @return DictionaryResponse + */ + public function replaceDictionaryEntries($dictionary, $entries, $requestOptions = []) + { + $response = $this->api->write( + 'POST', + api_path('/1/dictionaries/%s/batch', $dictionary), + [ + 'clearExistingDictionaryEntries' => true, + 'requests' => Helpers::buildBatch($entries, 'addEntry'), + ], + $requestOptions + ); + + return new DictionaryResponse($response, $this, $this->config); + } + + /** + * Delete dictionary entries by their objectID. + * + * @param string $dictionary + * @param array $objectIDs + * @param array $requestOptions + * + * @return DictionaryResponse + */ + public function deleteDictionaryEntries($dictionary, $objectIDs, $requestOptions = []) + { + $entries = array_map(function ($objectID) { + return ['objectID' => $objectID]; + }, $objectIDs); + + $response = $this->api->write( + 'POST', + api_path('/1/dictionaries/%s/batch', $dictionary), + [ + 'clearExistingDictionaryEntries' => false, + 'requests' => Helpers::buildBatch($entries, 'deleteEntry'), + ], + $requestOptions + ); + + return new DictionaryResponse($response, $this, $this->config); + } + + /** + * Clear all entries in the given dictionary. + * + * @param string $dictionary + * @param array|RequestOptions $requestOptions + * + * @return DictionaryResponse + */ + public function clearDictionaryEntries($dictionary, $requestOptions = []) + { + return $this->replaceDictionaryEntries($dictionary, [], $requestOptions); + } + + /** + * Search the dictionary for entries. + * + * @param string $dictionary + * @param string $query + * @param array|RequestOptions $requestOptions + * + * @return mixed + */ + public function searchDictionaryEntries($dictionary, $query, $requestOptions = []) + { + return $this->api->read( + 'POST', + api_path('/1/dictionaries/%s/search', $dictionary), + ['query' => $query], + $requestOptions + ); + } + + /** + * Update the settings for all dictionaries. + * + * @param array $dictionarySettings + * @param array $requestOptions + * + * @return DictionaryResponse + */ + public function setDictionarySettings($dictionarySettings, $requestOptions = []) + { + $response = $this->api->write( + 'PUT', + api_path('/1/dictionaries/*/settings'), + $dictionarySettings, + $requestOptions + ); + + return new DictionaryResponse($response, $this, $this->config); + } + + /** + * Get the settings for all dictionaries. + * + * @param array|RequestOptions $requestOptions + * + * @return mixed + */ + public function getDictionarySettings($requestOptions = []) + { + return $this->api->read( + 'GET', + api_path('/1/dictionaries/*/settings'), + [], + $requestOptions + ); + } } diff --git a/includes/libraries/algoliasearch-client-php/src/SearchIndex.php b/includes/libraries/algoliasearch-client-php/src/SearchIndex.php index 07f65a53..656e9e36 100644 --- a/includes/libraries/algoliasearch-client-php/src/SearchIndex.php +++ b/includes/libraries/algoliasearch-client-php/src/SearchIndex.php @@ -49,7 +49,7 @@ public function getAppId() return $this->config->getAppId(); } - public function search($query, $requestOptions = array()) + public function search($query, $requestOptions = []) { $query = (string) $query; @@ -65,12 +65,12 @@ public function search($query, $requestOptions = array()) /** * @deprecated Please use searchForFacetValues instead */ - public function searchForFacetValue($facetName, $facetQuery, $requestOptions = array()) + public function searchForFacetValue($facetName, $facetQuery, $requestOptions = []) { return $this->searchForFacetValues($facetName, $facetQuery, $requestOptions); } - public function searchForFacetValues($facetName, $facetQuery, $requestOptions = array()) + public function searchForFacetValues($facetName, $facetQuery, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['facetQuery'] = $facetQuery; @@ -85,7 +85,7 @@ public function searchForFacetValues($facetName, $facetQuery, $requestOptions = ); } - public function getSettings($requestOptions = array()) + public function getSettings($requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['getVersion'] = 2; @@ -100,9 +100,9 @@ public function getSettings($requestOptions = array()) ); } - public function setSettings($settings, $requestOptions = array()) + public function setSettings($settings, $requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } @@ -118,7 +118,7 @@ public function setSettings($settings, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function getObject($objectId, $requestOptions = array()) + public function getObject($objectId, $requestOptions = []) { return $this->api->read( 'GET', @@ -127,7 +127,7 @@ public function getObject($objectId, $requestOptions = array()) ); } - public function getObjects($objectIds, $requestOptions = array()) + public function getObjects($objectIds, $requestOptions = []) { if (is_array($requestOptions)) { $attributesToRetrieve = ''; @@ -136,12 +136,12 @@ public function getObjects($objectIds, $requestOptions = array()) unset($requestOptions['attributesToRetrieve']); } - $request = array(); + $request = []; foreach ($objectIds as $id) { - $req = array( + $req = [ 'indexName' => $this->indexName, 'objectID' => (string) $id, - ); + ]; if ($attributesToRetrieve) { $req['attributesToRetrieve'] = $attributesToRetrieve; @@ -160,12 +160,12 @@ public function getObjects($objectIds, $requestOptions = array()) ); } - public function saveObject($object, $requestOptions = array()) + public function saveObject($object, $requestOptions = []) { - return $this->saveObjects(array($object), $requestOptions); + return $this->saveObjects([$object], $requestOptions); } - public function saveObjects($objects, $requestOptions = array()) + public function saveObjects($objects, $requestOptions = []) { if (isset($requestOptions['autoGenerateObjectIDIfNotExist']) && $requestOptions['autoGenerateObjectIDIfNotExist']) { @@ -192,17 +192,17 @@ public function saveObjects($objects, $requestOptions = array()) } } - protected function addObjects($objects, $requestOptions = array()) + protected function addObjects($objects, $requestOptions = []) { return $this->splitIntoBatches('addObject', $objects, $requestOptions); } - public function partialUpdateObject($object, $requestOptions = array()) + public function partialUpdateObject($object, $requestOptions = []) { - return $this->partialUpdateObjects(array($object), $requestOptions); + return $this->partialUpdateObjects([$object], $requestOptions); } - public function partialUpdateObjects($objects, $requestOptions = array()) + public function partialUpdateObjects($objects, $requestOptions = []) { $action = 'partialUpdateObjectNoCreate'; @@ -214,7 +214,7 @@ public function partialUpdateObjects($objects, $requestOptions = array()) return $this->splitIntoBatches($action, $objects, $requestOptions); } - public function replaceAllObjects($objects, $requestOptions = array()) + public function replaceAllObjects($objects, $requestOptions = []) { $safe = isset($requestOptions['safe']) && $requestOptions['safe']; unset($requestOptions['safe']); @@ -223,9 +223,9 @@ public function replaceAllObjects($objects, $requestOptions = array()) $tmpIndex = new static($tmpName, $this->api, $this->config); // Copy all index resources from production index - $copyResponse = $this->copyTo($tmpIndex->getIndexName(), array( - 'scope' => array('settings', 'synonyms', 'rules'), - )); + $copyResponse = $this->copyTo($tmpIndex->getIndexName(), [ + 'scope' => ['settings', 'synonyms', 'rules'], + ]); if ($safe) { $copyResponse->wait(); @@ -245,24 +245,24 @@ public function replaceAllObjects($objects, $requestOptions = array()) $moveResponse->wait(); } - return new MultiResponse(array($copyResponse, $batchResponse, $moveResponse)); + return new MultiResponse([$copyResponse, $batchResponse, $moveResponse]); } - public function deleteObject($objectId, $requestOptions = array()) + public function deleteObject($objectId, $requestOptions = []) { - return $this->deleteObjects(array($objectId), $requestOptions); + return $this->deleteObjects([$objectId], $requestOptions); } - public function deleteObjects($objectIds, $requestOptions = array()) + public function deleteObjects($objectIds, $requestOptions = []) { $objects = array_map(function ($id) { - return array('objectID' => $id); + return ['objectID' => $id]; }, $objectIds); return $this->splitIntoBatches('deleteObject', $objects, $requestOptions); } - public function deleteBy($filters, $requestOptions = array()) + public function deleteBy($filters, $requestOptions = []) { $response = $this->api->write( 'POST', @@ -274,39 +274,39 @@ public function deleteBy($filters, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function clearObjects($requestOptions = array()) + public function clearObjects($requestOptions = []) { $response = $this->api->write( 'POST', api_path('/1/indexes/%s/clear', $this->indexName), - array(), + [], $requestOptions ); return new IndexingResponse($response, $this); } - public function batch($requests, $requestOptions = array()) + public function batch($requests, $requestOptions = []) { $response = $this->rawBatch($requests, $requestOptions); return new IndexingResponse($response, $this); } - protected function rawBatch($requests, $requestOptions = array()) + protected function rawBatch($requests, $requestOptions = []) { return $this->api->write( 'POST', api_path('/1/indexes/%s/batch', $this->indexName), - array('requests' => $requests), + ['requests' => $requests], $requestOptions ); } - protected function splitIntoBatches($action, $objects, $requestOptions = array()) + protected function splitIntoBatches($action, $objects, $requestOptions = []) { - $allResponses = array(); - $batch = array(); + $allResponses = []; + $batch = []; $batchSize = $this->config->getBatchSize(); $count = 0; @@ -319,7 +319,7 @@ protected function splitIntoBatches($action, $objects, $requestOptions = array() Helpers::ensureObjectID($batch, 'All objects must have an unique objectID (like a primary key) to be valid.'); } $allResponses[] = $this->rawBatch(Helpers::buildBatch($batch, $action), $requestOptions); - $batch = array(); + $batch = []; $count = 0; } } @@ -341,12 +341,12 @@ protected function splitIntoBatches($action, $objects, $requestOptions = array() return new BatchIndexingResponse($allResponses, $this); } - public function browseObjects($requestOptions = array()) + public function browseObjects($requestOptions = []) { return new ObjectIterator($this->indexName, $this->api, $requestOptions); } - public function searchSynonyms($query, $requestOptions = array()) + public function searchSynonyms($query, $requestOptions = []) { $query = (string) $query; @@ -363,7 +363,7 @@ public function searchSynonyms($query, $requestOptions = array()) ); } - public function getSynonym($objectId, $requestOptions = array()) + public function getSynonym($objectId, $requestOptions = []) { return $this->api->read( 'GET', @@ -372,20 +372,20 @@ public function getSynonym($objectId, $requestOptions = array()) ); } - public function saveSynonym($synonym, $requestOptions = array()) + public function saveSynonym($synonym, $requestOptions = []) { - return $this->saveSynonyms(array($synonym), $requestOptions); + return $this->saveSynonyms([$synonym], $requestOptions); } - public function saveSynonyms($synonyms, $requestOptions = array()) + public function saveSynonyms($synonyms, $requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } if ($synonyms instanceof \Iterator) { - $iteratedOver = array(); + $iteratedOver = []; foreach ($synonyms as $r) { $iteratedOver[] = $r; } @@ -409,7 +409,7 @@ public function saveSynonyms($synonyms, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function replaceAllSynonyms($synonyms, $requestOptions = array()) + public function replaceAllSynonyms($synonyms, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['replaceExistingSynonyms'] = true; @@ -420,9 +420,9 @@ public function replaceAllSynonyms($synonyms, $requestOptions = array()) return $this->saveSynonyms($synonyms, $requestOptions); } - public function deleteSynonym($objectId, $requestOptions = array()) + public function deleteSynonym($objectId, $requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } @@ -430,7 +430,7 @@ public function deleteSynonym($objectId, $requestOptions = array()) $response = $this->api->write( 'DELETE', api_path('/1/indexes/%s/synonyms/%s', $this->indexName, $objectId), - array(), + [], $requestOptions, $default ); @@ -438,9 +438,9 @@ public function deleteSynonym($objectId, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function clearSynonyms($requestOptions = array()) + public function clearSynonyms($requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } @@ -448,7 +448,7 @@ public function clearSynonyms($requestOptions = array()) $response = $this->api->write( 'POST', api_path('/1/indexes/%s/synonyms/clear', $this->indexName), - array(), + [], $requestOptions, $default ); @@ -456,12 +456,12 @@ public function clearSynonyms($requestOptions = array()) return new IndexingResponse($response, $this); } - public function browseSynonyms($requestOptions = array()) + public function browseSynonyms($requestOptions = []) { return new SynonymIterator($this->indexName, $this->api, $requestOptions); } - public function searchRules($query, $requestOptions = array()) + public function searchRules($query, $requestOptions = []) { $query = (string) $query; @@ -478,7 +478,7 @@ public function searchRules($query, $requestOptions = array()) ); } - public function getRule($objectId, $requestOptions = array()) + public function getRule($objectId, $requestOptions = []) { return $this->api->read( 'GET', @@ -487,20 +487,20 @@ public function getRule($objectId, $requestOptions = array()) ); } - public function saveRule($rule, $requestOptions = array()) + public function saveRule($rule, $requestOptions = []) { - return $this->saveRules(array($rule), $requestOptions); + return $this->saveRules([$rule], $requestOptions); } - public function saveRules($rules, $requestOptions = array()) + public function saveRules($rules, $requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } if ($rules instanceof \Iterator) { - $iteratedOver = array(); + $iteratedOver = []; foreach ($rules as $r) { $iteratedOver[] = $r; } @@ -536,7 +536,7 @@ public function saveRules($rules, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function replaceAllRules($rules, $requestOptions = array()) + public function replaceAllRules($rules, $requestOptions = []) { if (is_array($requestOptions)) { $requestOptions['clearExistingRules'] = true; @@ -547,9 +547,9 @@ public function replaceAllRules($rules, $requestOptions = array()) return $this->saveRules($rules, $requestOptions); } - public function deleteRule($objectId, $requestOptions = array()) + public function deleteRule($objectId, $requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } @@ -557,7 +557,7 @@ public function deleteRule($objectId, $requestOptions = array()) $response = $this->api->write( 'DELETE', api_path('/1/indexes/%s/rules/%s', $this->indexName, $objectId), - array(), + [], $requestOptions, $default ); @@ -565,9 +565,9 @@ public function deleteRule($objectId, $requestOptions = array()) return new IndexingResponse($response, $this); } - public function clearRules($requestOptions = array()) + public function clearRules($requestOptions = []) { - $default = array(); + $default = []; if (is_bool($fwd = $this->config->getDefaultForwardToReplicas())) { $default['forwardToReplicas'] = $fwd; } @@ -575,7 +575,7 @@ public function clearRules($requestOptions = array()) $response = $this->api->write( 'POST', api_path('/1/indexes/%s/rules/clear', $this->indexName), - array(), + [], $requestOptions, $default ); @@ -583,12 +583,12 @@ public function clearRules($requestOptions = array()) return new IndexingResponse($response, $this); } - public function browseRules($requestOptions = array()) + public function browseRules($requestOptions = []) { return new RuleIterator($this->indexName, $this->api, $requestOptions); } - public function getTask($taskId, $requestOptions = array()) + public function getTask($taskId, $requestOptions = []) { if (!$taskId) { throw new \InvalidArgumentException('taskID cannot be empty'); @@ -601,7 +601,7 @@ public function getTask($taskId, $requestOptions = array()) ); } - public function waitTask($taskId, $requestOptions = array()) + public function waitTask($taskId, $requestOptions = []) { $retry = 1; $time = $this->config->getWaitTaskTimeBeforeRetry(); @@ -619,17 +619,17 @@ public function waitTask($taskId, $requestOptions = array()) } while (true); } - public function custom($method, $path, $requestOptions = array(), $hosts = null) + public function custom($method, $path, $requestOptions = [], $hosts = null) { return $this->api->send($method, $path, $requestOptions, $hosts); } - public function delete($requestOptions = array()) + public function delete($requestOptions = []) { $response = $this->api->write( 'DELETE', api_path('/1/indexes/%s', $this->indexName), - array(), + [], $requestOptions ); @@ -643,7 +643,7 @@ public function delete($requestOptions = array()) * * @return bool */ - public function exists($requestOptions = array()) + public function exists($requestOptions = []) { try { $this->getSettings($requestOptions); @@ -680,7 +680,7 @@ public function exists($requestOptions = array()) * * @throws ObjectNotFoundException */ - public function findObject($callback, $requestOptions = array()) + public function findObject($callback, $requestOptions = []) { $query = ''; $paginate = true; @@ -707,11 +707,11 @@ public function findObject($callback, $requestOptions = array()) $result = $this->search($query, $requestOptions); foreach ($result['hits'] as $key => $hit) { if ($callback($hit)) { - return array( + return [ 'object' => $hit, 'position' => $key, 'page' => $page, - ); + ]; } } @@ -743,30 +743,30 @@ public static function getObjectPosition($result, $objectID) return -1; } - private function copyTo($tmpIndexName, $requestOptions = array()) + private function copyTo($tmpIndexName, $requestOptions = []) { $apiResponse = $this->api->write( 'POST', api_path('/1/indexes/%s/operation', $this->indexName), - array( + [ 'operation' => 'copy', 'destination' => $tmpIndexName, - ), + ], $requestOptions ); return new IndexingResponse($apiResponse, $this); } - private function moveFrom($tmpIndexName, $requestOptions = array()) + private function moveFrom($tmpIndexName, $requestOptions = []) { $apiResponse = $this->api->write( 'POST', api_path('/1/indexes/%s/operation', $tmpIndexName), - array( + [ 'operation' => 'move', 'destination' => $this->indexName, - ), + ], $requestOptions ); diff --git a/includes/libraries/algoliasearch-client-php/src/Support/Helpers.php b/includes/libraries/algoliasearch-client-php/src/Support/Helpers.php index 39abc53a..971393a9 100644 --- a/includes/libraries/algoliasearch-client-php/src/Support/Helpers.php +++ b/includes/libraries/algoliasearch-client-php/src/Support/Helpers.php @@ -66,10 +66,10 @@ public static function buildQuery(array $args) public static function buildBatch($items, $action) { return array_map(function ($item) use ($action) { - return array( + return [ 'action' => $action, 'body' => $item, - ); + ]; }, $items); } @@ -126,4 +126,19 @@ public static function mapObjectIDs($objectIDKey, $objects) return $object; }, $objects); } + + public static function serializeQueryParameters($parameters) + { + if (is_string($parameters)) { + return $parameters; + } + + foreach ($parameters as $key => $value) { + if (is_array($value)) { + $parameters[$key] = json_encode($value, JSON_THROW_ON_ERROR); + } + } + + return http_build_query($parameters); + } } diff --git a/includes/libraries/algoliasearch-client-php/src/Support/UserAgent.php b/includes/libraries/algoliasearch-client-php/src/Support/UserAgent.php index 638e5a9f..6be12e5f 100644 --- a/includes/libraries/algoliasearch-client-php/src/Support/UserAgent.php +++ b/includes/libraries/algoliasearch-client-php/src/Support/UserAgent.php @@ -8,7 +8,7 @@ final class UserAgent { private static $value; - private static $customSegments = array(); + private static $customSegments = []; public static function get() { @@ -27,7 +27,7 @@ public static function addCustomUserAgent($segment, $version) private static function getComputedValue() { - $ua = array(); + $ua = []; $segments = array_merge(self::getDefaultSegments(), self::$customSegments); foreach ($segments as $segment => $version) { @@ -39,7 +39,7 @@ private static function getComputedValue() private static function getDefaultSegments() { - $segments = array(); + $segments = []; $segments['Algolia for PHP'] = Algolia::VERSION; $segments['PHP'] = rtrim(str_replace(PHP_EXTRA_VERSION, '', PHP_VERSION), '-'); diff --git a/includes/libraries/algoliasearch-client-php/src/functions.php b/includes/libraries/algoliasearch-client-php/src/functions.php index 1190a7b8..c852c575 100644 --- a/includes/libraries/algoliasearch-client-php/src/functions.php +++ b/includes/libraries/algoliasearch-client-php/src/functions.php @@ -2,7 +2,9 @@ namespace Algolia\AlgoliaSearch; +use Algolia\AlgoliaSearch\Support\Helpers; + function api_path($pathFormat, $args = null, $_ = null) { - return call_user_func_array(array('\Algolia\AlgoliaSearch\Support\Helpers', 'apiPath'), func_get_args()); + return call_user_func_array([Helpers::class, 'apiPath'], func_get_args()); } diff --git a/includes/watchers/class-algolia-user-changes-watcher.php b/includes/watchers/class-algolia-user-changes-watcher.php index 79534618..be716d8f 100644 --- a/includes/watchers/class-algolia-user-changes-watcher.php +++ b/includes/watchers/class-algolia-user-changes-watcher.php @@ -153,7 +153,8 @@ public function on_delete_post( $post_id ) { // Todo: this is not optimal given it would be triggered for every future triggered hook. // Todo: needs to be changed. add_action( - 'after_delete_post', function() use ( $watcher, $author_id ) { + 'after_delete_post', + function() use ( $watcher, $author_id ) { $watcher->sync_item( $author_id ); } ); diff --git a/js/algoliasearch/CHANGELOG.md b/js/algoliasearch/CHANGELOG.md deleted file mode 100644 index 346a0dfa..00000000 --- a/js/algoliasearch/CHANGELOG.md +++ /dev/null @@ -1,1228 +0,0 @@ -# CHANGELOG - -## 3.35.1 ->2019-10-08 - -* FIX: extra comma on node v8 engine (#790) - -## 3.35.0 ->2019-09-26 - -* FEAT(remaining-validity): adds remaining valitity method (#778) - * `client.getSecuredApiKeyRemainingValidity('securedAPIKey')`: Gets remaining validity seconds of an secured API Key -* FEAT(unit-testing-relevance): adds unit testing relevance methods (#777) - * `index.findObject(hit => hit.firstname == 'Jimmie')`: Find an object by the given condition - * `index.getObjectPosition(results, 'a-unique-identifier')`: Retrieve the given object position in the given results set -* FEAT(adds-assign-user-ids): adds assignUserIDs method and tests (#783) - * `client.assignUserIDs({ cluster: 'c1-test', userIDs: ['some-user-1', 'some-user-2'] })`: Assign a array of userIDs to a cluster - -## 3.34.0 ->2019-08-29 - -* FEAT(index-exists): adds exists method into index (#773) - * `index.exist()`: returns whether an index exists or not - -## 3.33.0 ->2019-05-09 - -* FEAT(api-keys): add restore api key method (#754) - * `client.restoreApiKey('APIKEY')`: restore a deleted API key - * see also https://www.algolia.com/doc/api-reference/api-methods/restore-api-key -* FIX(ua): change the User-Agent to use the new specs lib (version) (#747) - -## 3.32.1 ->2019-03-14 - -* FIX(errors): grammar change in error message (#737) -* FIX(dependencies): bump debug requirement (#746) - -## 3.32.0 ->2018-12-17 - -* FEAT(personalization): add new methods for the strategy - * `getPersonalizationStrategy(cb)`: retrieve the currently set strategy - * `setPersonalizationStrategy(strategy, cb)`: set the personalization strategy - * a `strategy` is an object containing `eventsScoring` and `facetsScoring` - * see also https://www.algolia.com/doc/rest-api/personalization - -## 3.31.0 ->2018-12-04 - -* FEAT(places): add `.reverse({ aroundLatLng: '' })` to reverse geo-code -* CHORE: deprecated `similarSearch()`, instead use `.search({ similarQuery: '' })` - -## 3.30.0 ->2018-08-01 - -* FIX(multi-query): property pass the `strategy` argument - * as in [docs](https://www.algolia.com/doc/rest-api/search#method-param-strategy) - * was originally put into url parameters instead of request body - -## 3.29.0 ->2018-06-20 - -* FEAT(analytics): add API methods for AB testing - * find more info about the new feature here: https://blog.algolia.com/ab-testing-search/ - * adds a new method on client: - import algoliasearch from 'algoliasearch'; - const client = algoliasearch('appid', 'apikey'); - const analytics = client.initAnalytics(); - analytics.getABTests().then(console.log) - * see documentation here: https://www.algolia.com/doc/api-client/ab-test/ -* CHORE(parse): remove parse build, not needed. - * You can just install and `require('algoliasearch');` - -## 3.28.0 ->2018-06-13 - -* FEAT(cache): cache the requests instead of responses (#694) - - If you pass `_useRequestCache: true` as an option to the client then the cache behaviour will change. If you launch two requests at the same time then only one request will be done while the two callbacks/promises will still be called/resolved. - - Previously, the client would have made two requests instead of one. - - This is implemented by filling the cache as soon as the request launches instead of waiting for the response to fill it. -* FIX(parse): correct path to debug module (#702) - - fixes parse build, weirdly webpack is not throwing when importing an - unknown module using target node -* TESTS: Make this CI green, fix unit and integration tests on every platform - -## 3.27.1 ->2018-05-03 - -* FIX: `client.searchForFacetValues` in older browsers - * we use the polyfill implementation of Promise.all now instead of the native in 3.27.0 -* FIX: `index.saveRule` throw when no objectID is given -* FEAT: deprecate index API key methods in favor of client ones - * these methods will be removed, since you can add index restrictions to client API keys - -## 3.27.0 ->2018-04-16 - -* FEAT: add client.searchForFacetValues - * this allows to request multiple search for facet values in a single call - * note that this will do multiple requests (one per query) - -## 3.26.0 ->2018-03-21 - -* FEAT: allow disabling of dsn - * in some cases (backend search while you do have global DSN), you want to disable DSN to avoid a round-robin around the whole world if DNS can't be resolved as expected, for example on GCP. (#675) - -## 3.25.1 ->2018-03-08 - -* FIX: fix protocol detection introduced in 3.25.0 - -## 3.25.0 ->2018-03-07 - -* FEAT: use https by default (#670) - * for very old devices https can be slow - * we defaulted to sending API requests over http on http sites - * this is now not really a performance bottleneck anymore - * https is now default, unless specified differently when initializing - -## 3.24.12 ->2018-02-28 - -* FIX: Handle Node.js network errors more precisely (#669) - -## 3.24.11 ->2017-02-08 - -* FIX: allow `index.getSettings` without any arguments - * this was a regression in 3.24.10 - * added tests - -## 3.24.10 ->2017-02-07 - -* FIX: correct `index.exportSynonyms` and `index.exportRules` - * they had the wrong implementation until now - * add some tests to prevent regression - -## 3.24.9 ->2017-12-29 - -* FIX: make sure long API keys are sent via the POST body - * this wasn't the case in 3.24.8 because of a typo - -## 3.24.8 ->2017-12-13 - -* add multi cluster management methods - * [ Assign or Move a userID to a cluster](https://algolia.com/doc/api-reference/api-methods/assign-user-id/): `assignUserID` - * [Get userID with highest number of records per cluster](https://algolia.com/doc/api-reference/api-methods/get-top-user-id/): `getTopUserID` - * [Returns the userID data stored in the mapping](https://algolia.com/doc/api-reference/api-methods/get-user-id/): `getUserID` - * [List the clusters available in a multi-clusters setup for a single appID](https://algolia.com/doc/api-reference/api-methods/list-clusters/): `listClusters` - * [List the userIDs assigned to a multi-clusters appID](https://algolia.com/doc/api-reference/api-methods/list-user-id/): `listUserIDs` - * [Remove a userID and associated data from the multi-clusters](https://algolia.com/doc/api-reference/api-methods/remove-user-id/): `removeUserID` - * [Search for userIDs](https://algolia.com/doc/api-reference/api-methods/search-user-id/): `searchUserIDs` - -## 3.24.7 ->2017-11-29 - -* don't throw an error when `copyIndex` without scope is used - * if no scope is given, `settings`, as the default will be chosen - -## 3.24.6 ->2017-11-16 - -* add `index.exportSynonyms` and `index.exportRules` - * they will get all of the synonyms or query rules on an index -* add a new `scope` argument to `copyIndex` - * this is the third argument (from, to, scope) - * it's an array with settings, synonyms or rules - * if specified, that data will also be copied if you copy the index - -## 3.24.5 ->2017-10-02 - -* feat(deleteBy): add deleteBy - * deleteByQuery is deprecated now - * the same, but now it happens at the indexing side - * no major changes should be seen, please report if any - * https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#indexdeletebyquery - -## 3.24.4 ->2017-09-22 - -* chore(build): provide jsDelivr the right file (#599) - -## 3.24.3 ->2017-07-24 - -* chore(deprecation): remove deprecation from singular/plural methods; all these methods will stay existing - * index.addObject(obj) or index.addObjects([obj]) - * index.partialUpdateObject(obj) or partialUpdateObjects([obj]) - * index.saveObject(obj) or index.saveObjects([obj]) - * index.deleteObject(objectID) or index.deleteObjects([objectID]) - * index.getObject(objectID) or index.getObjects([objectID]) - -## 3.24.2 ->2017-07-24 - -* chore(deprecation): add deprecation message to all methods that will be removed in v4 (#573) - * index.addObject(obj) --> index.addObjects([obj]) - * index.ttAdapter --> autocomplete.js - * index.partialUpdateObject(obj) --> partialUpdateObjects([obj]) - * index.saveObject(obj) --> index.saveObjects([obj]) - * index.deleteObject(objectID) --> index.deleteObjects([objectID]) - * index.getObject(objectID) --> index.getObjects([objectID]) - * see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated for more information - -## 3.24.1 ->2017-07-20 - -* feat(headers): add functions to remove and get extra headers (#572) - * client.setExtraHeader('X-cool-header','hello there'); - * client.getExtraHeader('X-cool-header'); //hello there - * client.unsetExtraHeader('X-cool-header'); - * client.getExtraHeader('X-cool-header'); //undefined -* feat(deprecation): use console.warn to be more visible -* refact(rules): Adapt to latest JSON schema for Query Rules - -## 3.24.0 ->2017-06-21 - -* feat(rules): Add query rules beta version, you cannot use this for now - -## 3.23.0 ->2017-06-08 - -* feat(places): Add places.getObject(); fixes algolia/places#381 - -## 3.22.3 ->2017-05-29 - -* fix(dependency): Do not pin debug dependency anymore -fixes #556 - -## 3.22.2 ->2017-05-18 - -* fix(partialUpdateObjects): allow createIfNotExists (#552) - Much like partialUpdateObject, allow createIfNotExists - fixes #551 - -## 3.22.1 ->2017-03-13 - -* fix(packaging): put back envify in deps - * browserify transforms are applied for node_modules/pkg - -## 3.22.0 ->2017-03-13 - - -* feat(API): rename all *userKey[s] methods to *apiKey[s] - * client/index.listUserKeys() => client/index.listApiKeys() - * client/index.getUserKeyACL() => client/index.getApiKey() - * client/index.deleteUserKey() => client/index.deleteApiKey() - * client/index.addUserKey() => client/index.addApiKey() - * client/index.udpateUserKey() => client/index.updateApiKey() -* fix(packaging): remove useless files for packaging (reduce package file size) - -## 3.21.1 ->2017-02-08 - - -* fix(browse*): use POST instead of GET to avoid limits (#503) - -## 3.21.0 ->2017-02-06 - - -* feat(x-algolia-agent): specify x-algolia-agent at search time -* fix(parse): check for `global` existence before erasing - -## 3.20.4 ->2017-01-16 - - -* fix(retry strategy): handle cases were localStorage fails after success (#474) - - Before this commit we only checked for localStorage failures at: - - page load - - localStorage.setItem - - While in some situations websites could erase localStorage for the - whole page at any moment (between requests) and we were not resilient to that. - -* chore(forwardToSlave): deprecate forwardToSlaves in favour or forwardToReplicas - -## 3.20.3 ->2017-01-04 - - -* fix(agent): ensure algolia agent is not duplicated by successive calls - -## 3.20.2 ->2016-12-19 - - -* fix(nodejs): do not use let, 0.12 does not support it - -## 3.20.1 ->2016-12-17 - - -* fix(nodejs): on timeout, destroy the right response - -## 3.20.0 ->2016-12-14 - - -* feat(retry strategy): adjust retry strategy for all implementations - - Retry strategy now shares the last known host for a specific appId across the current domain (browsers) - or the current process (browsers without localStorage, Node.js). After 2 minutes we try to target back - the first host (Usually DSN) - - Retry strategy now shares the last known timeout multiplier that worked and set it back to default - after 2 minutes - - Retry strategy on Node.js now has a connect timeout of 2s - - Retry strategy on browsers (JavaScript, not jQuery, not Angular.js, not React Native for now) now - has a connect timeout of 1s - - You can now get and set timeouts per client with .setTimeouts({connect, read, write}), .getTimeouts(). - Values are in ms. - -## 3.19.2 ->2016-11-28 - - -* fix(facet search): rename index.searchFacet to index.searchForFacetValues - -## 3.19.1 ->2016-11-11 - - -* fix(build): use regular debug module, issue with yui compressor was fixed here: -https://github.com/visionmedia/debug/pull/315 - -## 3.19.0 ->2016-10-26 - - -* feat(index.searchFacet): add method #345 - -## 3.18.1 ->2016-08-31 - - -* fix(client.search): accept very long API keys - fixes #319 - - also fix uglify-js version because it's buggy in IE8: - https://github.com/mishoo/UglifyJS2/issues/1039 - -## 3.18.0 ->2016-07-22 - - -* fix(debug): only activate debug messages on NODE_ENV==='debug' -* feat(lite): add getObjects - -## 3.17.0 ->2016-07-06 - - -* feat(errors): add statusCode to errors -* chore(shrinkwrap): completely remove shrinkwrap - -## 3.16.0 ->2016-06-22 - - -* feat(index.setSettings): add forwardToSlaves option -index.setSettings({settings}, {forwardToSlaves}, cb); -see https://www.algolia.com/doc/rest#change-index-settings - -## 3.15.1 ->2016-06-16 - - -* fix(getLogs): allow using the type parameter - The syntax is now getLogs(params[, cb]) - fixes #232 -* fix(json): avoid throwing when late JSON response - fixes #284 -* fix(nodejs): allow universal lite applications - require('algoliasearch/lite') should work to - facilitate universal applications builds using - the lite build on frontend - -fixes #283 - -## 3.15.0 ->2016-06-07 - - -* feat(synonyms): add new synonyms API - -## 3.14.6 ->2016-05-30 - - -* fix(places): allow empty credentials - -## 3.14.5 ->2016-05-26 - - -* fix(window): don't assume window is here - -When required in a node context, we may load the browser build without -using it. Just for testing other parts of it. - -## 3.14.4 ->2016-05-25 - - -* fix(lite): lite package should have browse and browseFrom - -## 3.14.3 ->2016-05-25 - - -* fix(retry): also retry on non search methods when DNS failure - - Before this commit, methods with no fallback support (basically every - method) would fail at retry if the DNS error occurred before the API - client timeout. - - The behavior is now: - - when a method with a fallback errors because of DNS failure we will - switch to JSONP right away - - when a method with no fallback errors because of DNS failure we will - still retry - - We could use the same mechanism for both (= always try all hosts - before JSONP) but I am not confident doing this change within a patch - or minor version. We have too litle data on how blocked XHRS are - triggered (async, sync?). - - fixes #250 - - * fix(request strategy): comply with retry spec, no early JSONP switch - - This commit brings more conformance with request strategy - specification by only raising timeout when there's a timeout. - - It also stop trying to switch to JSONP asap and always try all hosts - using XHRS before. - -## 3.14.2 ->2016-05-24 - - -* fix(request strategy): increments hostIndex (host address) on fallback - - When we are switching to fallback, increment host index so that JSONP - will use another host. - - This issue was caused because we cannot distinguish CORS errors from DNS - resolution errors in the browser. - - And the code for incrementing the host index was moved into the part - that switches to the fallback in - 4ec5e6a1f8cd92924ce025d60646b3a47b7d8dca. - - Truth is that the current solution is not optimal as, in the browser, - we are switching to JSONP when we can't resolve the server name. - - This is only done because we are not sure how CORS request can be - blocked (synchronously, asynchronously). - - In a next version we would drop it and wait for real issues to show up. - -## 3.14.1 ->2016-05-12 - - -* fix(retry strategy): retry on timeout was only using two hosts -* fix(errors): provide err.debugData with necessary debugging information -* fix(errors): force AlgoliaSearchError as default name -fixes #241 - -## 3.14.0 ->2016-05-04 - - -* feat(client.search): add strategy, fixes #208 -* fix(shuffle): shuffle host array like we did -* feat(filesize): reduce filesize by removing lodash - All build size down 26% (20kb => 14kb) - New search-only build "algoliasearchLite[.min].js", - weights 9.5Kb (down 50% from normal build) - Also available as require('algoliasearch/lite'); -* fix(parse): handle parse cloud env having process.env defined - -## 3.13.1 ->2016-03-24 - - -* chore(dev): use phantomjs-prebuilt instead of phantomjs -fixes #209 - -## 3.13.0 ->2016-02-23 - - -* feat(initPlaces): add a static algoliasearch.initPlaces method - -## 3.12.0 ->2016-02-05 - - -* fix(apiKey): put the apiKey in the POST body when feasible and key > 500 chars -* feat(falback): provide opts.useFallback to avoid using JSONP fallback - -## 3.11.0 ->2016-01-28 - - -* feat(partialUpdateObject): add createIfNotExists option: partialUpdateObject(object, createIfNotExists) https://www.algolia.com/doc/rest#partially-update-an-object -* chore(dev): various fixes to the dev env - -## 3.10.2 ->2015-12-14 - - -* fix(request strategy): always use XHR first then switch to fallback - - + add fallback for client.search - - Context: before this commit, when a user lost connectivity (or XHR was - blocked, we cannot distinguish those events in browsers) then we - forced using JSONP for the whole session. - - This led to a bug where you were stuck in a loop of non-available - fallback even if connectivity was restored. - - This commit fixes this bug by always trying XHRS and fallbacking to - JSONP on a per request basis. -* refactor(map): use lodash map instead of custom fn - -## 3.10.1 ->2015-12-11 - -* fix(nodejs): consistent timeouts between nodejs versions - We now use basic setTimeout functionnality instead of - req.setTimeout in nodejs to avoid inconsistencies between nodejs engines. - In node 0.10, req.setTimeout was a socket inactivity timeout - In node > 0.10? req.setTimeout is now a global timeout - + Node.js timeout is now 30s global per request (then incremental) - + Fixed an edge case where we had an uncaught exception in nodejs - + We only support 0.10+ now, node 0.8 never worked - -## 3.10.0 ->2015-12-08 - -* feat(gzip): ask the API for gzipped answers (nodejs) - -## 3.9.4 ->2015-12-04 - -* fix(process.env): set process back to normal in node v4 - -## 3.9.3 ->2015-12-01 - -* fix(parse): set default timeout to 7.5s (indexing purposes) - -## 3.9.2 ->2015-11-02 - -* feat: react native build beta - -## 3.9.1 ->2015-11-02 - -* fix: throw on really bad usage instead of silently failing -* fix: make angular build cache work - -## 3.9.0 ->2015-10-23 - -* feat: add similarSearch beta method -* feat: add new way to generate secured api key using query parameters - -## 3.8.1 ->2015-09-21 - - -* fix: disable chunked encoding on empty body DELETE requests in Node.js - -## 3.8.0 ->2015-09-01 - - -* test: node v4 is now the default testing env -* fix: always send a unique response to the user -* fix: use `lodash` by default, only use `lodash-compat` when building for the browser -* feat: add client.addAlgoliaAgent() to augment the sent x-algolia-agent -* chore: move all deps to ^version and add a shrinkwrap to allow reproducible builds - -## 3.7.8 ->2015-09-01 - - -* fix: ignore $http.defaults.headers.common in angular build -* fix: force distinct false in deleteByQuery search -* docs: precise initialization option values - -## 3.7.7 ->2015-08-27 - -* fix: listen to socket errors in nodejs keepalive strategy - -## 3.7.6 ->2015-08-24 - -* fix: encodeURIComponent(cursor) in browseFrom() - -## 3.7.5 ->2015-07-23 - -* fix: withCredentials forced to false in Angular - -## 3.7.4 ->2015-07-20 - -* fix: JSON.stringify fix when Array.prototype.toJSON is defined (prototype.js < 1.7 bug) - -## 3.7.3 ->2015-07-09 - -* fix: make https over http proxy work - -## 3.7.2 ->2015-07-08 - -* fix: remove a git clone dependency on install (debug/ms/yui compressor issue) - -## 3.7.1 ->2015-07-08 - -* fix: do not call agent.destroy when there's no such method -* fix: do not rely on any "smart" port computing - -## 3.7.0 ->2015-06-18 - -* feat: allow passing `httpAgent` option to the nodejs client -allow more flexible proxy/keepAlive agents in some more complex environments - -## 3.6.3 ->2015-06-18 - -* fix: allow getting the debug log from the outside - will be used by diag tool and possibly anyone aware of https://github.com/visionmedia/debug - -## 3.6.2 ->2015-06-17 - -* chore: add window.__algolia for easy debugging anywhere - -## 3.6.1 ->2015-06-16 - -* fix: parse cloud build fix -* fix: YUI compressor fix - fixes #113 -* test: automatic parse cloud build testing -* fix: add application id to final error message ("Cannot connect to..") - -## 3.6.0 ->2015-06-05 - -* feat: easy commonJS require of plugins - fixes #109 -* test: add dependency-check step in tests -* refactor: use lodash-compat instead of less known/used/shared modules -* chore: use uglifyjs instead of closure compiler -* feat: allow passing hosts as hosts.read, hosts.write -* feat: allow passing Algolia Agent as an option -* fix: CORS simple request for all browser builds - fixes #111 - -## 3.5.0 ->2015-06-03 - -* fix: send a descriptive timeout error when it occurs -* chore: add headers debugging -* fix: incremental wait waitTask - will now wait 100ms * loopTickNumber * loopTickNumber - fixes #102 -* fix: do not use global when we know we will be in a browser - browserify `global` is not always `window` can be
- fixes #99 -* feat: new browse()/browseFrom()/browseAll() - - `browse(query, queryParameters)` now has the same signature than - search(). You can use any `query` and `queryParameters`. - - `browseFrom(cursor)` can be used as an efficient way to - continue (next page) a previous `browse()` call. All browse responses now have a `cursor` property. - - `browseAll(query, queryParameters)` can be used to get all - the content of your index - It returns an [EventEmitter](https://nodejs.org/api/events.html). - - Available events: - - `result` - - `end` - - `error` (you should listen to it or it will throw) - - There's also `stop()` method on the event emitter so that you can - stop browsing at any point. - - fixes #101 -* fix: support typeahead 0.11 - fixes #105 - -## 3.4.0 ->2015-05-23 - -* FIX: Remove debugging messages from builds - fixes #91 - fixes #86 -* FIX: Handle badly formatted JSON - fixes #89 - fixes #90 -* FIX: Stop bytes sent/received debug on node 0.12 when socket closes -* test: Test on only 3 browsers in travis - fixes #61 -* test: split desktop/mobile into a travis matrix, reduces travis timeouts -* feat: add client.batch() -* feature: getObjects now accepts attributesToRetrieve: - signature: getObjects(objectIDs, attributesToRetrieve, callback) -* fix: send `x-algolia-agent` instead of `x-user-agent` -* fix: clone cached results hits sent - fixes #79 -* feat: New parameters for API keys - Added description, referers, queryParameters - ref: https://www.algolia.com/changes#released-## - >2015-05-08 - -* fix: IE11 xhr cache was fixed by adding cache-control: no-cache in API headers -* test: add integration testing and rework the travis tasks - -## 3.3.2 ->2015-05-14 - -* FIX: more fixes to the use of $q() in the angular build, now compatible with 1.2.xx and tested - -## 3.3.1 ->2015-05-12 - -* FIX: Compatibility with AngularJS old promise implementation - We now use $q.defer() instead of $q() - -## 3.3.0 ->2015-05-12 - -* FEATURE: expose window.algoliasearch = algoliasearch in jquery/angular plugins. So that -you can use the original algoliasearch() implem in plugins. Otherwise you would have to load both - -## 3.2.4 ->2015-05-11 - -* FIX: 15s inactivity timeout for nodejs implementation, should help high latency/low connection users -* CHORE: test on iojs2 -* CHORE: debugging messages now more focused and less verbose -* PERF: use JSON.stringify only once per request - -## 3.2.3 ->2015-05-09 - -* FIX: Parse build requires a charset on requests - -## 3.2.2 ->2015-05-06 - -* FIX : missing require (crypto) for node.js client (#84) - -## 3.2.1 ->2015-04-29 - -* add dist/ to npmjs repository, so cdnjs autoupdate works - -## 3.2.0 ->2015-04-24 - -* FEATURE: Parse build now uses V3 implementation -* FEATURE: Parse build now returns parse promises. https://parse.com/docs/js_guide#promises -* FEATURE: Automatically handle HTTP_PROXY HTTPS_PROXY environment variables -in Node.js client - -## 3.1.0 ->2015-04-14 - -* CHANGE: Node.js will now use http headers instead of inlining them into the api call as browsers are doing -* CHANGE: Ensure all headers (http, querystrings) are lowercased. Both are supported by our API, reduces FUD -* FEATURE: add index.getObjects() -* FEATURE: add index.deleteObjects() -* FIX: waitTask failure case when using promises, was not going through -* FEATURE: add index.deleteByQuery() -* FEATURE (Node.js): add client.enableRateLimitForward() -* FEATURE (Node.js): add client.disableRateLimitForward() -* FEATURE (Node.js): add client.useSecuredAPIKey() -* FEATURE (Node.js): add client.disableSecuredAPIKey() -* BREAKING CHANGE (Node.js): client.setTimeout renamed to client.setRequestTimeout -* TEST: add test around setRequestTimeout -* FEATURE (Node.js): add client.generateSecuredApiKey() -* FEATURE: - - all clients are now exposing algoliasearch.ua - - all requests are now sending x-user-agent containing for example 'Algoliasearch for vanilla JavaScript 3.0.7' -* FEATURE: add client.search() - Search against multiple indices, equivalent of, multipleQueries, or - startQueriesBatch+addQueryInBatch+sendQueriesBatch -* BREAKING CHANGE (Node.js): removed client.multipleQueries(), use client.search(queries) -* DEPRECIATION (browser): client.startQueriesBatch/addQueryInBatch/sendQueriesBatch - Use client.search(queries) -* FEATURE: new HA implementation - We now use two different DNS to perform all requests - Removed the tld option as it's no more needed nor compatible with having a new HA implementation with different tlds (.com/.net) -* DEPRECIATION: client.addUserKeyWithValidity(), index.addUserKeyWithValidity() - You can now use client.addUserKey(acls, params, cb), index.addUserKey(acls, params, cb) -* FEATURE: client|index.updateUserKey(key, acls, params, callback) - Update a user key, provide acls and optional params -* BREAKING CHANGE (Node.js): - As we now have addUserKey and updateUserKey, we removed: - - client|index.addUserKeyWithValidityAndIndexes - - client|index.updateUserKeyWithValidity - - client|index.updateUserKeyWithValidityAndIndexes - You can use client|index.addUserKey or client|index.updateUserKey to do - deal with all you keys needs - -## 3.0.7 ->2015-04-10 - -* MIGRATION: throw on V2 .search() usage: - - .search(query, cb, params) - - .search(cb, params) -* FEATURE: add client.destroy() in Node.js implementation - will destroy all keepalived connections and let the process exits if needed - -## 3.0.6 ->2015-04-03 - -* FIX: Webpack compatibility by removing packageify - webpack does not interprets for now node_modules/* browserify transforms -* MISC: add release script - -## 3.0.5 ->2015-04-02 - -* FIX: lower the build size by requiring the good version/browser.js in browser - builds. Previously we got the full `package.json` inlined - -## 3.0.4 ->2015-04-02 - -* FIX: Defaults to http when the protocol of the page is not http or - https -* FIX: XDomainRequests no more aborted in IE9 #76 - -## 3.0.3 ->2015-03-28 - - -* FIX: Handle module loaders + cdn.jsdelivr.net/algoliasearch/latest usage - When in this situation, the module loader would prevent the code - detecting and loading the V2 to execute. - Now fixed by prepending the migration-layer to the browserify bundle. - It also removes the migration-layer code from the package managers (npm, bower) builds, - where it makes no sense to have it -* FIX: load V2 using a DOMElement when V3 is loaded ASYNCHRONOUSLY with /latest/ - * tested on all majors browsers: - Chrome stable - Firefox stable - IE 8, 9, 10, 11 - * tested on corresponding customer websites -* FIX: better warning messages when using `latest` or trying to use V3 as V2 - -## 3.0.2 ->2015-03-26 - - -* temp /latest/ fix for some clients loading /latest/ in async mode - -## 3.0.1 ->2015-03-26 - - -* fix npm usage, was missing a dependency - -## 3.0.0 ->2015-03-25 - - -* V2 users, see the migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x -* BREAKING CHANGES: - * `new AlgoliaSearch()` => `algoliasearch()` #40 - - The only exported global property is now `algoliasearch` - - `opts`: - - `dsnHost` removed, use `hosts:[dsnHost, other hosts]` - - `dsn` removed, use `hosts:[non-dsn-host, non-dsn-host]` - - `requestTimeoutInMs` renamed to `timeout` - - `method` renamed to `protocol`. Protocol should be specified as `http:` or `https:` - - `hosts` behavior changed, when using custom hosts: - - no shuffling - - no dsn host is prepended to the list - - removed `AlgoliaExplainResults`, no obvious use ATM - - calling algoliasearch() without an applicationID or apiKey will throw - - Helper: `new AlgoliaSearchHelper()` => `algoliasearch.helper()`, same function signature - * no more window.ALGOLIA_VERSION - - you can find the version in algoliasearch.version - * all api methods now use the (err, content) convention #43 - It means that instead of doing: - ```js - index.search(function found(success, content) { - if (!success) { - console.log('Error was:', content); - return; - } - - console.log('OK!', content); - }); - ``` - You must do: - ```js - index.search(function found(err, content) { - if (err) { - console.log('Error was:', err); - return; - } - - console.log('OK!', content); - }); - ``` - This is in par with most asynchronous APIS accepted/de vfacto conventions. - It helps being compatible with control flow libraries like `async` and - helps reduce WTF moments of Node.JS developers used to cb(err, content) - * client.getLogs(cb[, offset, length]) is now .getLogs([offset, length, cb]) - * client.listIndexes(cb[, page]) => .listIndexes([page, cb]) - * client|index.addUserKeyWithValidity(acls, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, cb) => client|index.addUserKeyWithValidity(acls, params, cb) where params = {validity:, maxQueriesPerIPPerHour:, maxHitsPerQuery:} - * client.sendQueriesBatch(cb, delay) => client.sendQueriesBatch(cb) - * index.addObject(content[, callback, objectID]) => index.addObject(content[, objectID, callback]) - * index.getObject(objectID[, callback, attributes]) => index.getObject(objectID[, attrs, callback]) - * index.search(query, callback[, params, delay]) => index.search(query[, params callback]) or index.search(params[, cb]) with params = {query: 'some thing'} - We removed the delay option which should really be implemented by the module consumer. It's really a throttle/debounce of the search functions - * index.browse(page, cb[, hitsPerPage]) => index.browse(page[, hitsPerPage, cb]) - * no more opts.jsonp in algoliasearch() - Previously used as a way to force/disable jsonp. The request strategy is now more robust and does not - requires jsonp: param - * JSON2.js is no more included in the main build. - If you need to support IE7 <= or IE8 quirks, add this: - ```html - - ``` - * removed AlgoliaSearchHelper - Please see https://github.com/algolia/algoliasearch-helper-js if you need the helper - * NEW FEATURES: - * UMD compatibility #41 - - algoliasearch can now be used with any module loader - - build is now done with browserify - - no more grunt - * All calls are now returning promises #45 - If there's a callback given to an API call, you won't get a promise. - Here are the different promises implementations we use: - - Native promises by default (https://github.com/jakearchibald/es6-promise/) - - AngularJS promises for AngularJS plugin - - jQuery promises for jQuery plugin -* FIXES: - * do not retry when server sends 4xx or 1xx - * distinguish jQuery/AngularJS request timeouts from errors and thus retry when timeout - * JSONP fallback when jQuery/AngularJS request error -* MISC: - * Externalize plugins and request implementations - * some linting fixes - * test suite, including request strategy test suite - * IE10 should now behave as a CORS supported XMLHttpRequest browser, as it is - * running tests on many browsers, using saucelabs - * removed vendor/ - - vendor/json2.js - - vendor/jquery.typeahead.js now on cdnjs (examples) - -## 2.9.2 ->2015-02-03 - -* Fixed calls to `.search(function() {})`, `.search(null, function() {})`, `.search(undefined, function() {}) -* Fixed shared cache amongst instances - -## 2.9.1 ->2015-02-03 - -* Fixed listIndexes pagination, not working if page=0 - -## 2.9.0 ->2015-01-13 - -* Angular.js & jQuery compatibility (returning promises) -* Helper: ability to exclude facets - -## 2.8.6 ->2015-01-13 - -* Search helper: ability to set default facet filters - -## 2.8.5 ->2015-01-07 - -* Avoid CORS preflight request - -## 2.8.4 ->2014-12-31 - -* Fixed a bug in JSONP fallback on multi-queries and getObject when a secured API Key was used (X-Algolia-TagFilters parameter was not set, resulting in a 403 permission denied error) - -## 2.8.3 ->2014-12-30 - -* Helper optimization: number of nested queries is now driven by the number of refined disjunctive facets only - -## 2.8.2 ->2014-12-23 - -* Increase the request timeout after each retry - -## 2.8.1 ->2014-12-09 - -* Enabled DSN by default (is working even if only one datacenter is selected) - -## 2.8.0 ->2014-11-28 - -* Move to algolia.net by default - -## 2.7.5 ->2014-11-25 - -* Expose one option to select the TTL (prepare migration to .net, allow to gain some milliseconds compared to .io) - -## 2.7.4 ->2014-11-12 - -* Expose more options (jsonp & requestTimeoutInMs) -* Change the way the JSONP fallback works - -## 2.7.3 ->2014-10-29 - -* Reintroduced Algolia Custom Headers (X-Algolia-*) on queries. It was removed to try to remove the CORS OPTIONS query but this has no impact because this is a POST action. - -## 2.7.2 ->2014-10-27 - -* Fixed browse method (author @muertet) - -## 2.7.{0,1} ->2014-10-15 - -* Refactor the AlgoliaSearch constructor to allows optional/named arguments - -## 2.6.6 ->2014-10-07 - -* Fixed bower integration - -## 2.6.5 ->2014-09-26 - -* Optimize disjunctive queries that were retrieving useless attributes - -## 2.6.4 ->2014-09-23 - - * Fixed CORS handling issue on IE8/IE9 - -## 2.6.3 ->2014-09-23 - - * Fixed IE11-based AJAX calls - -## 2.6.2 ->2014-09-20 - - * Updated package manager description files: npm and jsdelivr - -## 2.6.1 ->2014-09-20 - - * Fixed JSONP call: 'X-Algolia-TagFilters' and 'X-Algolia-UserToken' were not included in the URL. - -## 2.6.0 ->2014-09-06 - - * Improved retry strategy with implementation of a timeout on network call. - Upgrade to this version is highly recommended - -## 2.5.4 ->2014-09-04 - -* Removed the OPTIONS request for the first isalive query of for all search queries - -## 2.5.3 ->2014-07-23 - -* AlgoliaSearchHelper: add missing getIndex/setIndex -* listIndexes is now paginable - -## 2.5.2 ->2014-06-05 - -* AlgoliaSearchHelper: add getter/setter methods - -## 2.5.1 ->2014-05-14 - -* Fixed listIndexes call (trailing slash not compatible with our API anymore) - -## 2.5.0 ->2014-05-09 - -* If CORS is not available, use JSONP - -## 2.4.7 ->2014-04-23 - -* Ability to instantiate multiple AlgoliaSearchHelper - -## 2.4.6 ->2014-04-05 - -* Fixed IE 8/9 support of secured API keys - -## 2.4.5 ->2014-03-30 - -* Improved AlgoliaExplainResults helper handling array-based attributes as well. - -## 2.4.4 ->2014-03-19 - -* Improved the `waitTask` method, ensuring it sleeps 100ms before recalling the API. - -## 2.4.3 ->2014-03-12 - -* Removed invalid character from source code (could cause a parse error in IE8/9) - -## 2.4.2 ->2014-02-24 - -* Added support of secured API Key (SecurityTags & UserToken headers) - -## 2.4.1 ->2014-02-18 - -* Removed dependency on jquery - -## 2.4.0 ->2014-02-10 - - -* Move to official Typeahead.js release (0.10.1) -* Remove getTypeAheadTransport* functions - -## 2.3.8 ->2014-01-16 - - -* Ability to customize getTypeAheadTransport parameters once instantiated - -## 2.3.7 ->2014-01-08 - - -* Remove extra encodeURI -* Travis integration - -## 2.3.6 ->2014-01-06 - - -* Missing encodeURI -* Added "distinct" documentation - -## 2.3.5 ->2013-12-06 - - -* Added browse methods - -## 2.3.4-1 ->2013-12-04 - - -* Fixed IE9 bug while reading onload's event -* Here and there typos - -## 2.3.0 ->2013-11-07 - - -* Added new ACL features (maxQueriesPerIPPerHour & maxHitsPerQuery) - -## 2.2.0 ->2013-11-07 - - -* Added clearIndex method - -## 2.1.0 ->2013-11-03 - - -* Auto-detect protocol to used based on current location -* Added auto-complete & instant-search examples - -## 2.0.1 ->2013-10-15 - - -* Gruntification -* Embed typeahead.js diff --git a/js/algoliasearch/LICENSE.txt b/js/algoliasearch/LICENSE.txt deleted file mode 100644 index 8c315f45..00000000 --- a/js/algoliasearch/LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013 Algolia -http://www.algolia.com/ - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/js/algoliasearch/README.md b/js/algoliasearch/README.md index d97c6dc5..9e227e85 100644 --- a/js/algoliasearch/README.md +++ b/js/algoliasearch/README.md @@ -6,11 +6,10 @@

The perfect starting point to integrate Algolia within your JavaScript project

- Build Status NPM version NPM downloads jsDelivr Downloads - License + License

@@ -28,28 +27,30 @@ - Thin & **minimal low-level HTTP client** to interact with Algolia's API - Works both on the **browser** and **node.js** - **UMD compatible**, you can use it with any module loader -- Contains type definitions: **[@types/algoliasearch](https://www.npmjs.com/package/@types/algoliasearch)** +- Built with TypeScript ## 💡 Getting Started First, install Algolia JavaScript API Client via the [npm](https://www.npmjs.com/get-npm) package manager: ```bash -npm install --save algoliasearch +npm install algoliasearch ``` Then, create objects on your index: ```js -const algoliasearch = require('algoliasearch'); +const algoliasearch = require("algoliasearch"); -const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey'); -const index = client.initIndex('your_index_name'); +const client = algoliasearch("YourApplicationID", "YourAdminAPIKey"); +const index = client.initIndex("your_index_name"); -const objects = [{ - objectID: 1, - name: 'Foo' -}]; +const objects = [ + { + objectID: 1, + name: "Foo" + } +]; index .saveObjects(objects) @@ -65,7 +66,7 @@ Finally, let's actually search using the `search` method: ```js index - .search('Fo') + .search("Fo") .then(({ hits }) => { console.log(hits); }) @@ -78,4 +79,4 @@ For full documentation, visit the **[online documentation](https://www.algolia.c ## 📄 License -Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE.txt). +Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE.md). diff --git a/js/algoliasearch/bower.json b/js/algoliasearch/bower.json deleted file mode 100644 index 93111c67..00000000 --- a/js/algoliasearch/bower.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "algoliasearch", - "version": "3.35.1", - "homepage": "https://github.com/algolia/algoliasearch-client-js", - "authors": [ - "Algolia Team " - ], - "description": "Algolia Search is a search API that provides hosted full-text, numerical and faceted search.", - "main": "dist/algoliasearch.js", - "keywords": [ - "js", - "algolia", - "search", - "api", - "rest" - ], - "license": "MIT", - "ignore": [ - "examples", - "node_modules", - "bower_components", - "test" - ] -} diff --git a/js/algoliasearch/dist/algoliasearch-lite.d.ts b/js/algoliasearch/dist/algoliasearch-lite.d.ts new file mode 100644 index 00000000..4c4b983d --- /dev/null +++ b/js/algoliasearch/dist/algoliasearch-lite.d.ts @@ -0,0 +1,47 @@ +import { ClientTransporterOptions } from '@algolia/client-common'; +import { FindAnswersOptions } from '@algolia/client-search'; +import { FindAnswersResponse } from '@algolia/client-search'; +import { MultipleQueriesOptions } from '@algolia/client-search'; +import { MultipleQueriesQuery } from '@algolia/client-search'; +import { MultipleQueriesResponse } from '@algolia/client-search'; +import { RequestOptions } from '@algolia/transporter'; +import { SearchClient as SearchClient_2 } from '@algolia/client-search'; +import { SearchClientOptions } from '@algolia/client-search'; +import { SearchForFacetValuesQueryParams } from '@algolia/client-search'; +import { SearchForFacetValuesResponse } from '@algolia/client-search'; +import { SearchIndex as SearchIndex_2 } from '@algolia/client-search'; +import { SearchOptions } from '@algolia/client-search'; +import { SearchResponse } from '@algolia/client-search'; + +declare function algoliasearch(appId: string, apiKey: string, options?: AlgoliaSearchOptions): SearchClient; + +declare namespace algoliasearch { + var version: string; +} +export default algoliasearch; + +export declare type AlgoliaSearchOptions = Partial & WithoutCredentials; + +declare type Credentials = { + readonly appId: string; + readonly apiKey: string; +}; + +export declare type SearchClient = SearchClient_2 & { + readonly initIndex: (indexName: string) => SearchIndex; + readonly search: (queries: readonly MultipleQueriesQuery[], requestOptions?: RequestOptions & MultipleQueriesOptions) => Readonly>>; + readonly searchForFacetValues: (queries: ReadonlyArray<{ + readonly indexName: string; + readonly params: SearchForFacetValuesQueryParams & SearchOptions; + }>, requestOptions?: RequestOptions) => Readonly>; +}; + +export declare type SearchIndex = SearchIndex_2 & { + readonly search: (query: string, requestOptions?: RequestOptions & SearchOptions) => Readonly>>; + readonly searchForFacetValues: (facetName: string, facetQuery: string, requestOptions?: RequestOptions & SearchOptions) => Readonly>; + readonly findAnswers: (query: string, queryLanguages: readonly string[], requestOptions?: RequestOptions & FindAnswersOptions) => Readonly>>; +}; + +export declare type WithoutCredentials = Omit; + +export { } diff --git a/js/algoliasearch/dist/algoliasearch-lite.esm.browser.js b/js/algoliasearch/dist/algoliasearch-lite.esm.browser.js new file mode 100644 index 00000000..89c99b68 --- /dev/null +++ b/js/algoliasearch/dist/algoliasearch-lite.esm.browser.js @@ -0,0 +1,905 @@ +function createBrowserLocalStorageCache(options) { + const namespaceKey = `algoliasearch-client-js-${options.key}`; + // eslint-disable-next-line functional/no-let + let storage; + const getStorage = () => { + if (storage === undefined) { + storage = options.localStorage || window.localStorage; + } + return storage; + }; + const getNamespace = () => { + return JSON.parse(getStorage().getItem(namespaceKey) || '{}'); + }; + return { + get(key, defaultValue, events = { + miss: () => Promise.resolve(), + }) { + return Promise.resolve() + .then(() => { + const keyAsString = JSON.stringify(key); + const value = getNamespace()[keyAsString]; + return Promise.all([value || defaultValue(), value !== undefined]); + }) + .then(([value, exists]) => { + return Promise.all([value, exists || events.miss(value)]); + }) + .then(([value]) => value); + }, + set(key, value) { + return Promise.resolve().then(() => { + const namespace = getNamespace(); + // eslint-disable-next-line functional/immutable-data + namespace[JSON.stringify(key)] = value; + getStorage().setItem(namespaceKey, JSON.stringify(namespace)); + return value; + }); + }, + delete(key) { + return Promise.resolve().then(() => { + const namespace = getNamespace(); + // eslint-disable-next-line functional/immutable-data + delete namespace[JSON.stringify(key)]; + getStorage().setItem(namespaceKey, JSON.stringify(namespace)); + }); + }, + clear() { + return Promise.resolve().then(() => { + getStorage().removeItem(namespaceKey); + }); + }, + }; +} + +// @todo Add logger on options to debug when caches go wrong. +function createFallbackableCache(options) { + const caches = [...options.caches]; + const current = caches.shift(); // eslint-disable-line functional/immutable-data + if (current === undefined) { + return createNullCache(); + } + return { + get(key, defaultValue, events = { + miss: () => Promise.resolve(), + }) { + return current.get(key, defaultValue, events).catch(() => { + return createFallbackableCache({ caches }).get(key, defaultValue, events); + }); + }, + set(key, value) { + return current.set(key, value).catch(() => { + return createFallbackableCache({ caches }).set(key, value); + }); + }, + delete(key) { + return current.delete(key).catch(() => { + return createFallbackableCache({ caches }).delete(key); + }); + }, + clear() { + return current.clear().catch(() => { + return createFallbackableCache({ caches }).clear(); + }); + }, + }; +} + +function createNullCache() { + return { + get(_key, defaultValue, events = { + miss: () => Promise.resolve(), + }) { + const value = defaultValue(); + return value + .then(result => Promise.all([result, events.miss(result)])) + .then(([result]) => result); + }, + set(_key, value) { + return Promise.resolve(value); + }, + delete(_key) { + return Promise.resolve(); + }, + clear() { + return Promise.resolve(); + }, + }; +} + +function createInMemoryCache(options = { serializable: true }) { + // eslint-disable-next-line functional/no-let + let cache = {}; + return { + get(key, defaultValue, events = { + miss: () => Promise.resolve(), + }) { + const keyAsString = JSON.stringify(key); + if (keyAsString in cache) { + return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]); + } + const promise = defaultValue(); + const miss = (events && events.miss) || (() => Promise.resolve()); + return promise.then((value) => miss(value)).then(() => promise); + }, + set(key, value) { + // eslint-disable-next-line functional/immutable-data + cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value; + return Promise.resolve(value); + }, + delete(key) { + // eslint-disable-next-line functional/immutable-data + delete cache[JSON.stringify(key)]; + return Promise.resolve(); + }, + clear() { + cache = {}; + return Promise.resolve(); + }, + }; +} + +function createAuth(authMode, appId, apiKey) { + const credentials = { + 'x-algolia-api-key': apiKey, + 'x-algolia-application-id': appId, + }; + return { + headers() { + return authMode === AuthMode.WithinHeaders ? credentials : {}; + }, + queryParameters() { + return authMode === AuthMode.WithinQueryParameters ? credentials : {}; + }, + }; +} + +// eslint-disable-next-line functional/prefer-readonly-type +function shuffle(array) { + let c = array.length - 1; // eslint-disable-line functional/no-let + // eslint-disable-next-line functional/no-loop-statement + for (c; c > 0; c--) { + const b = Math.floor(Math.random() * (c + 1)); + const a = array[c]; + array[c] = array[b]; // eslint-disable-line functional/immutable-data, no-param-reassign + array[b] = a; // eslint-disable-line functional/immutable-data, no-param-reassign + } + return array; +} +function addMethods(base, methods) { + if (!methods) { + return base; + } + Object.keys(methods).forEach(key => { + // eslint-disable-next-line functional/immutable-data, no-param-reassign + base[key] = methods[key](base); + }); + return base; +} +function encode(format, ...args) { + // eslint-disable-next-line functional/no-let + let i = 0; + return format.replace(/%s/g, () => encodeURIComponent(args[i++])); +} + +const version = '4.10.3'; + +const AuthMode = { + /** + * If auth credentials should be in query parameters. + */ + WithinQueryParameters: 0, + /** + * If auth credentials should be in headers. + */ + WithinHeaders: 1, +}; + +function createMappedRequestOptions(requestOptions, timeout) { + const options = requestOptions || {}; + const data = options.data || {}; + Object.keys(options).forEach(key => { + if (['timeout', 'headers', 'queryParameters', 'data', 'cacheable'].indexOf(key) === -1) { + data[key] = options[key]; // eslint-disable-line functional/immutable-data + } + }); + return { + data: Object.entries(data).length > 0 ? data : undefined, + timeout: options.timeout || timeout, + headers: options.headers || {}, + queryParameters: options.queryParameters || {}, + cacheable: options.cacheable, + }; +} + +const CallEnum = { + /** + * If the host is read only. + */ + Read: 1, + /** + * If the host is write only. + */ + Write: 2, + /** + * If the host is both read and write. + */ + Any: 3, +}; + +const HostStatusEnum = { + Up: 1, + Down: 2, + Timeouted: 3, +}; + +// By default, API Clients at Algolia have expiration delay +// of 5 mins. In the JavaScript client, we have 2 mins. +const EXPIRATION_DELAY = 2 * 60 * 1000; +function createStatefulHost(host, status = HostStatusEnum.Up) { + return { + ...host, + status, + lastUpdate: Date.now(), + }; +} +function isStatefulHostUp(host) { + return host.status === HostStatusEnum.Up || Date.now() - host.lastUpdate > EXPIRATION_DELAY; +} +function isStatefulHostTimeouted(host) { + return (host.status === HostStatusEnum.Timeouted && Date.now() - host.lastUpdate <= EXPIRATION_DELAY); +} + +function createStatelessHost(options) { + if (typeof options === 'string') { + return { + protocol: 'https', + url: options, + accept: CallEnum.Any, + }; + } + return { + protocol: options.protocol || 'https', + url: options.url, + accept: options.accept || CallEnum.Any, + }; +} + +const MethodEnum = { + Delete: 'DELETE', + Get: 'GET', + Post: 'POST', + Put: 'PUT', +}; + +function createRetryableOptions(hostsCache, statelessHosts) { + return Promise.all(statelessHosts.map(statelessHost => { + return hostsCache.get(statelessHost, () => { + return Promise.resolve(createStatefulHost(statelessHost)); + }); + })).then(statefulHosts => { + const hostsUp = statefulHosts.filter(host => isStatefulHostUp(host)); + const hostsTimeouted = statefulHosts.filter(host => isStatefulHostTimeouted(host)); + /** + * Note, we put the hosts that previously timeouted on the end of the list. + */ + const hostsAvailable = [...hostsUp, ...hostsTimeouted]; + const statelessHostsAvailable = hostsAvailable.length > 0 + ? hostsAvailable.map(host => createStatelessHost(host)) + : statelessHosts; + return { + getTimeout(timeoutsCount, baseTimeout) { + /** + * Imagine that you have 4 hosts, if timeouts will increase + * on the following way: 1 (timeouted) > 4 (timeouted) > 5 (200) + * + * Note that, the very next request, we start from the previous timeout + * + * 5 (timeouted) > 6 (timeouted) > 7 ... + * + * This strategy may need to be reviewed, but is the strategy on the our + * current v3 version. + */ + const timeoutMultiplier = hostsTimeouted.length === 0 && timeoutsCount === 0 + ? 1 + : hostsTimeouted.length + 3 + timeoutsCount; + return timeoutMultiplier * baseTimeout; + }, + statelessHosts: statelessHostsAvailable, + }; + }); +} + +const isNetworkError = ({ isTimedOut, status }) => { + return !isTimedOut && ~~status === 0; +}; +const isRetryable = (response) => { + const status = response.status; + const isTimedOut = response.isTimedOut; + return (isTimedOut || isNetworkError(response) || (~~(status / 100) !== 2 && ~~(status / 100) !== 4)); +}; +const isSuccess = ({ status }) => { + return ~~(status / 100) === 2; +}; +const retryDecision = (response, outcomes) => { + if (isRetryable(response)) { + return outcomes.onRetry(response); + } + if (isSuccess(response)) { + return outcomes.onSuccess(response); + } + return outcomes.onFail(response); +}; + +function retryableRequest(transporter, statelessHosts, request, requestOptions) { + const stackTrace = []; // eslint-disable-line functional/prefer-readonly-type + /** + * First we prepare the payload that do not depend from hosts. + */ + const data = serializeData(request, requestOptions); + const headers = serializeHeaders(transporter, requestOptions); + const method = request.method; + // On `GET`, the data is proxied to query parameters. + const dataQueryParameters = request.method !== MethodEnum.Get + ? {} + : { + ...request.data, + ...requestOptions.data, + }; + const queryParameters = { + 'x-algolia-agent': transporter.userAgent.value, + ...transporter.queryParameters, + ...dataQueryParameters, + ...requestOptions.queryParameters, + }; + let timeoutsCount = 0; // eslint-disable-line functional/no-let + const retry = (hosts, // eslint-disable-line functional/prefer-readonly-type + getTimeout) => { + /** + * We iterate on each host, until there is no host left. + */ + const host = hosts.pop(); // eslint-disable-line functional/immutable-data + if (host === undefined) { + throw createRetryError(stackTraceWithoutCredentials(stackTrace)); + } + const payload = { + data, + headers, + method, + url: serializeUrl(host, request.path, queryParameters), + connectTimeout: getTimeout(timeoutsCount, transporter.timeouts.connect), + responseTimeout: getTimeout(timeoutsCount, requestOptions.timeout), + }; + /** + * The stackFrame is pushed to the stackTrace so we + * can have information about onRetry and onFailure + * decisions. + */ + const pushToStackTrace = (response) => { + const stackFrame = { + request: payload, + response, + host, + triesLeft: hosts.length, + }; + // eslint-disable-next-line functional/immutable-data + stackTrace.push(stackFrame); + return stackFrame; + }; + const decisions = { + onSuccess: response => deserializeSuccess(response), + onRetry(response) { + const stackFrame = pushToStackTrace(response); + /** + * If response is a timeout, we increaset the number of + * timeouts so we can increase the timeout later. + */ + if (response.isTimedOut) { + timeoutsCount++; + } + return Promise.all([ + /** + * Failures are individually send the logger, allowing + * the end user to debug / store stack frames even + * when a retry error does not happen. + */ + transporter.logger.info('Retryable failure', stackFrameWithoutCredentials(stackFrame)), + /** + * We also store the state of the host in failure cases. If the host, is + * down it will remain down for the next 2 minutes. In a timeout situation, + * this host will be added end of the list of hosts on the next request. + */ + transporter.hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? HostStatusEnum.Timeouted : HostStatusEnum.Down)), + ]).then(() => retry(hosts, getTimeout)); + }, + onFail(response) { + pushToStackTrace(response); + throw deserializeFailure(response, stackTraceWithoutCredentials(stackTrace)); + }, + }; + return transporter.requester.send(payload).then(response => { + return retryDecision(response, decisions); + }); + }; + /** + * Finally, for each retryable host perform request until we got a non + * retryable response. Some notes here: + * + * 1. The reverse here is applied so we can apply a `pop` later on => more performant. + * 2. We also get from the retryable options a timeout multiplier that is tailored + * for the current context. + */ + return createRetryableOptions(transporter.hostsCache, statelessHosts).then(options => { + return retry([...options.statelessHosts].reverse(), options.getTimeout); + }); +} + +function createTransporter(options) { + const { hostsCache, logger, requester, requestsCache, responsesCache, timeouts, userAgent, hosts, queryParameters, headers, } = options; + const transporter = { + hostsCache, + logger, + requester, + requestsCache, + responsesCache, + timeouts, + userAgent, + headers, + queryParameters, + hosts: hosts.map(host => createStatelessHost(host)), + read(request, requestOptions) { + /** + * First, we compute the user request options. Now, keep in mind, + * that using request options the user is able to modified the intire + * payload of the request. Such as headers, query parameters, and others. + */ + const mappedRequestOptions = createMappedRequestOptions(requestOptions, transporter.timeouts.read); + const createRetryableRequest = () => { + /** + * Then, we prepare a function factory that contains the construction of + * the retryable request. At this point, we may *not* perform the actual + * request. But we want to have the function factory ready. + */ + return retryableRequest(transporter, transporter.hosts.filter(host => (host.accept & CallEnum.Read) !== 0), request, mappedRequestOptions); + }; + /** + * Once we have the function factory ready, we need to determine of the + * request is "cacheable" - should be cached. Note that, once again, + * the user can force this option. + */ + const cacheable = mappedRequestOptions.cacheable !== undefined + ? mappedRequestOptions.cacheable + : request.cacheable; + /** + * If is not "cacheable", we immediatly trigger the retryable request, no + * need to check cache implementations. + */ + if (cacheable !== true) { + return createRetryableRequest(); + } + /** + * If the request is "cacheable", we need to first compute the key to ask + * the cache implementations if this request is on progress or if the + * response already exists on the cache. + */ + const key = { + request, + mappedRequestOptions, + transporter: { + queryParameters: transporter.queryParameters, + headers: transporter.headers, + }, + }; + /** + * With the computed key, we first ask the responses cache + * implemention if this request was been resolved before. + */ + return transporter.responsesCache.get(key, () => { + /** + * If the request has never resolved before, we actually ask if there + * is a current request with the same key on progress. + */ + return transporter.requestsCache.get(key, () => { + return (transporter.requestsCache + /** + * Finally, if there is no request in progress with the same key, + * this `createRetryableRequest()` will actually trigger the + * retryable request. + */ + .set(key, createRetryableRequest()) + .then(response => Promise.all([transporter.requestsCache.delete(key), response]), err => Promise.all([transporter.requestsCache.delete(key), Promise.reject(err)])) + .then(([_, response]) => response)); + }); + }, { + /** + * Of course, once we get this response back from the server, we + * tell response cache to actually store the received response + * to be used later. + */ + miss: response => transporter.responsesCache.set(key, response), + }); + }, + write(request, requestOptions) { + /** + * On write requests, no cache mechanisms are applied, and we + * proxy the request immediately to the requester. + */ + return retryableRequest(transporter, transporter.hosts.filter(host => (host.accept & CallEnum.Write) !== 0), request, createMappedRequestOptions(requestOptions, transporter.timeouts.write)); + }, + }; + return transporter; +} + +function createUserAgent(version) { + const userAgent = { + value: `Algolia for JavaScript (${version})`, + add(options) { + const addedUserAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`; + if (userAgent.value.indexOf(addedUserAgent) === -1) { + // eslint-disable-next-line functional/immutable-data + userAgent.value = `${userAgent.value}${addedUserAgent}`; + } + return userAgent; + }, + }; + return userAgent; +} + +function deserializeSuccess(response) { + // eslint-disable-next-line functional/no-try-statement + try { + return JSON.parse(response.content); + } + catch (e) { + throw createDeserializationError(e.message, response); + } +} +function deserializeFailure({ content, status }, stackFrame) { + // eslint-disable-next-line functional/no-let + let message = content; + // eslint-disable-next-line functional/no-try-statement + try { + message = JSON.parse(content).message; + } + catch (e) { + // .. + } + return createApiError(message, status, stackFrame); +} + +function serializeUrl(host, path, queryParameters) { + const queryParametersAsString = serializeQueryParameters(queryParameters); + // eslint-disable-next-line functional/no-let + let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`; + if (queryParametersAsString.length) { + url += `?${queryParametersAsString}`; + } + return url; +} +function serializeQueryParameters(parameters) { + const isObjectOrArray = (value) => Object.prototype.toString.call(value) === '[object Object]' || + Object.prototype.toString.call(value) === '[object Array]'; + return Object.keys(parameters) + .map(key => encode('%s=%s', key, isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])) + .join('&'); +} +function serializeData(request, requestOptions) { + if (request.method === MethodEnum.Get || + (request.data === undefined && requestOptions.data === undefined)) { + return undefined; + } + const data = Array.isArray(request.data) + ? request.data + : { ...request.data, ...requestOptions.data }; + return JSON.stringify(data); +} +function serializeHeaders(transporter, requestOptions) { + const headers = { + ...transporter.headers, + ...requestOptions.headers, + }; + const serializedHeaders = {}; + Object.keys(headers).forEach(header => { + const value = headers[header]; + // @ts-ignore + // eslint-disable-next-line functional/immutable-data + serializedHeaders[header.toLowerCase()] = value; + }); + return serializedHeaders; +} + +function stackTraceWithoutCredentials(stackTrace) { + return stackTrace.map(stackFrame => stackFrameWithoutCredentials(stackFrame)); +} +function stackFrameWithoutCredentials(stackFrame) { + const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] + ? { 'x-algolia-api-key': '*****' } + : {}; + return { + ...stackFrame, + request: { + ...stackFrame.request, + headers: { + ...stackFrame.request.headers, + ...modifiedHeaders, + }, + }, + }; +} + +function createApiError(message, status, transporterStackTrace) { + return { + name: 'ApiError', + message, + status, + transporterStackTrace, + }; +} + +function createDeserializationError(message, response) { + return { + name: 'DeserializationError', + message, + response, + }; +} + +function createRetryError(transporterStackTrace) { + return { + name: 'RetryError', + message: 'Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', + transporterStackTrace, + }; +} + +const createSearchClient = options => { + const appId = options.appId; + const auth = createAuth(options.authMode !== undefined ? options.authMode : AuthMode.WithinHeaders, appId, options.apiKey); + const transporter = createTransporter({ + hosts: [ + { url: `${appId}-dsn.algolia.net`, accept: CallEnum.Read }, + { url: `${appId}.algolia.net`, accept: CallEnum.Write }, + ].concat(shuffle([ + { url: `${appId}-1.algolianet.com` }, + { url: `${appId}-2.algolianet.com` }, + { url: `${appId}-3.algolianet.com` }, + ])), + ...options, + headers: { + ...auth.headers(), + ...{ 'content-type': 'application/x-www-form-urlencoded' }, + ...options.headers, + }, + queryParameters: { + ...auth.queryParameters(), + ...options.queryParameters, + }, + }); + const base = { + transporter, + appId, + addAlgoliaAgent(segment, version) { + transporter.userAgent.add({ segment, version }); + }, + clearCache() { + return Promise.all([ + transporter.requestsCache.clear(), + transporter.responsesCache.clear(), + ]).then(() => undefined); + }, + }; + return addMethods(base, options.methods); +}; + +const initIndex = (base) => { + return (indexName, options = {}) => { + const searchIndex = { + transporter: base.transporter, + appId: base.appId, + indexName, + }; + return addMethods(searchIndex, options.methods); + }; +}; + +const multipleQueries = (base) => { + return (queries, requestOptions) => { + const requests = queries.map(query => { + return { + ...query, + params: serializeQueryParameters(query.params || {}), + }; + }); + return base.transporter.read({ + method: MethodEnum.Post, + path: '1/indexes/*/queries', + data: { + requests, + }, + cacheable: true, + }, requestOptions); + }; +}; + +const multipleSearchForFacetValues = (base) => { + return (queries, requestOptions) => { + return Promise.all(queries.map(query => { + const { facetName, facetQuery, ...params } = query.params; + return initIndex(base)(query.indexName, { + methods: { searchForFacetValues }, + }).searchForFacetValues(facetName, facetQuery, { + ...requestOptions, + ...params, + }); + })); + }; +}; + +const findAnswers = (base) => { + return (query, queryLanguages, requestOptions) => { + return base.transporter.read({ + method: MethodEnum.Post, + path: encode('1/answers/%s/prediction', base.indexName), + data: { + query, + queryLanguages, + }, + cacheable: true, + }, requestOptions); + }; +}; + +const search = (base) => { + return (query, requestOptions) => { + return base.transporter.read({ + method: MethodEnum.Post, + path: encode('1/indexes/%s/query', base.indexName), + data: { + query, + }, + cacheable: true, + }, requestOptions); + }; +}; + +const searchForFacetValues = (base) => { + return (facetName, facetQuery, requestOptions) => { + return base.transporter.read({ + method: MethodEnum.Post, + path: encode('1/indexes/%s/facets/%s/query', base.indexName, facetName), + data: { + facetQuery, + }, + cacheable: true, + }, requestOptions); + }; +}; + +const LogLevelEnum = { + Debug: 1, + Info: 2, + Error: 3, +}; + +/* eslint no-console: 0 */ +function createConsoleLogger(logLevel) { + return { + debug(message, args) { + if (LogLevelEnum.Debug >= logLevel) { + console.debug(message, args); + } + return Promise.resolve(); + }, + info(message, args) { + if (LogLevelEnum.Info >= logLevel) { + console.info(message, args); + } + return Promise.resolve(); + }, + error(message, args) { + console.error(message, args); + return Promise.resolve(); + }, + }; +} + +function createBrowserXhrRequester() { + return { + send(request) { + return new Promise((resolve) => { + const baseRequester = new XMLHttpRequest(); + baseRequester.open(request.method, request.url, true); + Object.keys(request.headers).forEach(key => baseRequester.setRequestHeader(key, request.headers[key])); + const createTimeout = (timeout, content) => { + return setTimeout(() => { + baseRequester.abort(); + resolve({ + status: 0, + content, + isTimedOut: true, + }); + }, timeout * 1000); + }; + const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout'); + // eslint-disable-next-line functional/no-let + let responseTimeout; + // eslint-disable-next-line functional/immutable-data + baseRequester.onreadystatechange = () => { + if (baseRequester.readyState > baseRequester.OPENED && responseTimeout === undefined) { + clearTimeout(connectTimeout); + responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout'); + } + }; + // eslint-disable-next-line functional/immutable-data + baseRequester.onerror = () => { + // istanbul ignore next + if (baseRequester.status === 0) { + clearTimeout(connectTimeout); + clearTimeout(responseTimeout); + resolve({ + content: baseRequester.responseText || 'Network request failed', + status: baseRequester.status, + isTimedOut: false, + }); + } + }; + // eslint-disable-next-line functional/immutable-data + baseRequester.onload = () => { + clearTimeout(connectTimeout); + clearTimeout(responseTimeout); + resolve({ + content: baseRequester.responseText, + status: baseRequester.status, + isTimedOut: false, + }); + }; + baseRequester.send(request.data); + }); + }, + }; +} + +function algoliasearch(appId, apiKey, options) { + const commonOptions = { + appId, + apiKey, + timeouts: { + connect: 1, + read: 2, + write: 30, + }, + requester: createBrowserXhrRequester(), + logger: createConsoleLogger(LogLevelEnum.Error), + responsesCache: createInMemoryCache(), + requestsCache: createInMemoryCache({ serializable: false }), + hostsCache: createFallbackableCache({ + caches: [ + createBrowserLocalStorageCache({ key: `${version}-${appId}` }), + createInMemoryCache(), + ], + }), + userAgent: createUserAgent(version).add({ + segment: 'Browser', + version: 'lite', + }), + authMode: AuthMode.WithinQueryParameters, + }; + return createSearchClient({ + ...commonOptions, + ...options, + methods: { + search: multipleQueries, + searchForFacetValues: multipleSearchForFacetValues, + multipleQueries, + multipleSearchForFacetValues, + initIndex: base => (indexName) => { + return initIndex(base)(indexName, { + methods: { search, searchForFacetValues, findAnswers }, + }); + }, + }, + }); +} +// eslint-disable-next-line functional/immutable-data +algoliasearch.version = version; + +export default algoliasearch; diff --git a/js/algoliasearch/dist/algoliasearch-lite.umd.js b/js/algoliasearch/dist/algoliasearch-lite.umd.js new file mode 100644 index 00000000..b2082e12 --- /dev/null +++ b/js/algoliasearch/dist/algoliasearch-lite.umd.js @@ -0,0 +1,2 @@ +/*! algoliasearch-lite.umd.js | 4.10.3 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).algoliasearch=t()}(this,(function(){"use strict";function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function a(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then((function(){var r=JSON.stringify(e),n=a()[r];return Promise.all([n||t(),void 0!==n])})).then((function(e){var t=o(e,2),n=t[0],a=t[1];return Promise.all([n,a||r.miss(n)])})).then((function(e){return o(e,1)[0]}))},set:function(e,t){return Promise.resolve().then((function(){var o=a();return o[JSON.stringify(e)]=t,n().setItem(r,JSON.stringify(o)),t}))},delete:function(e){return Promise.resolve().then((function(){var t=a();delete t[JSON.stringify(e)],n().setItem(r,JSON.stringify(t))}))},clear:function(){return Promise.resolve().then((function(){n().removeItem(r)}))}}}function i(e){var t=a(e.caches),r=t.shift();return void 0===r?{get:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},n=t();return n.then((function(e){return Promise.all([e,r.miss(e)])})).then((function(e){return o(e,1)[0]}))},set:function(e,t){return Promise.resolve(t)},delete:function(e){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return r.get(e,n,o).catch((function(){return i({caches:t}).get(e,n,o)}))},set:function(e,n){return r.set(e,n).catch((function(){return i({caches:t}).set(e,n)}))},delete:function(e){return r.delete(e).catch((function(){return i({caches:t}).delete(e)}))},clear:function(){return r.clear().catch((function(){return i({caches:t}).clear()}))}}}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serializable:!0},t={};return{get:function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},a=JSON.stringify(r);if(a in t)return Promise.resolve(e.serializable?JSON.parse(t[a]):t[a]);var u=n(),i=o&&o.miss||function(){return Promise.resolve()};return u.then((function(e){return i(e)})).then((function(){return u}))},set:function(r,n){return t[JSON.stringify(r)]=e.serializable?JSON.stringify(n):n,Promise.resolve(n)},delete:function(e){return delete t[JSON.stringify(e)],Promise.resolve()},clear:function(){return t={},Promise.resolve()}}}function c(e){for(var t=e.length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}function l(e,t){return t?(Object.keys(t).forEach((function(r){e[r]=t[r](e)})),e):e}function f(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n0?n:void 0,timeout:r.timeout||t,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var m={Read:1,Write:2,Any:3},p=1,v=2,y=3;function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:p;return r(r({},e),{},{status:t,lastUpdate:Date.now()})}function b(e){return"string"==typeof e?{protocol:"https",url:e,accept:m.Any}:{protocol:e.protocol||"https",url:e.url,accept:e.accept||m.Any}}var O="GET",P="POST";function q(e,t){return Promise.all(t.map((function(t){return e.get(t,(function(){return Promise.resolve(g(t))}))}))).then((function(e){var r=e.filter((function(e){return function(e){return e.status===p||Date.now()-e.lastUpdate>12e4}(e)})),n=e.filter((function(e){return function(e){return e.status===y&&Date.now()-e.lastUpdate<=12e4}(e)})),o=[].concat(a(r),a(n));return{getTimeout:function(e,t){return(0===n.length&&0===e?1:n.length+3+e)*t},statelessHosts:o.length>0?o.map((function(e){return b(e)})):t}}))}function j(e,t,n,o){var u=[],i=function(e,t){if(e.method===O||void 0===e.data&&void 0===t.data)return;var n=Array.isArray(e.data)?e.data:r(r({},e.data),t.data);return JSON.stringify(n)}(n,o),s=function(e,t){var n=r(r({},e.headers),t.headers),o={};return Object.keys(n).forEach((function(e){var t=n[e];o[e.toLowerCase()]=t})),o}(e,o),c=n.method,l=n.method!==O?{}:r(r({},n.data),o.data),f=r(r(r({"x-algolia-agent":e.userAgent.value},e.queryParameters),l),o.queryParameters),h=0,d=function t(r,a){var l=r.pop();if(void 0===l)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:A(u)};var d={data:i,headers:s,method:c,url:S(l,n.path,f),connectTimeout:a(h,e.timeouts.connect),responseTimeout:a(h,o.timeout)},m=function(e){var t={request:d,response:e,host:l,triesLeft:r.length};return u.push(t),t},p={onSuccess:function(e){return function(e){try{return JSON.parse(e.content)}catch(t){throw function(e,t){return{name:"DeserializationError",message:e,response:t}}(t.message,e)}}(e)},onRetry:function(n){var o=m(n);return n.isTimedOut&&h++,Promise.all([e.logger.info("Retryable failure",x(o)),e.hostsCache.set(l,g(l,n.isTimedOut?y:v))]).then((function(){return t(r,a)}))},onFail:function(e){throw m(e),function(e,t){var r=e.content,n=e.status,o=r;try{o=JSON.parse(r).message}catch(e){}return function(e,t,r){return{name:"ApiError",message:e,status:t,transporterStackTrace:r}}(o,n,t)}(e,A(u))}};return e.requester.send(d).then((function(e){return function(e,t){return function(e){var t=e.status;return e.isTimedOut||function(e){var t=e.isTimedOut,r=e.status;return!t&&0==~~r}(e)||2!=~~(t/100)&&4!=~~(t/100)}(e)?t.onRetry(e):2==~~(e.status/100)?t.onSuccess(e):t.onFail(e)}(e,p)}))};return q(e.hostsCache,t).then((function(e){return d(a(e.statelessHosts).reverse(),e.getTimeout)}))}function w(e){var t={value:"Algolia for JavaScript (".concat(e,")"),add:function(e){var r="; ".concat(e.segment).concat(void 0!==e.version?" (".concat(e.version,")"):"");return-1===t.value.indexOf(r)&&(t.value="".concat(t.value).concat(r)),t}};return t}function S(e,t,r){var n=T(r),o="".concat(e.protocol,"://").concat(e.url,"/").concat("/"===t.charAt(0)?t.substr(1):t);return n.length&&(o+="?".concat(n)),o}function T(e){return Object.keys(e).map((function(t){return f("%s=%s",t,(r=e[t],"[object Object]"===Object.prototype.toString.call(r)||"[object Array]"===Object.prototype.toString.call(r)?JSON.stringify(e[t]):e[t]));var r})).join("&")}function A(e){return e.map((function(e){return x(e)}))}function x(e){var t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return r(r({},e),{},{request:r(r({},e.request),{},{headers:r(r({},e.request.headers),t)})})}var N=function(e){var t=e.appId,n=function(e,t,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":t};return{headers:function(){return e===h.WithinHeaders?n:{}},queryParameters:function(){return e===h.WithinQueryParameters?n:{}}}}(void 0!==e.authMode?e.authMode:h.WithinHeaders,t,e.apiKey),a=function(e){var t=e.hostsCache,r=e.logger,n=e.requester,a=e.requestsCache,u=e.responsesCache,i=e.timeouts,s=e.userAgent,c=e.hosts,l=e.queryParameters,f={hostsCache:t,logger:r,requester:n,requestsCache:a,responsesCache:u,timeouts:i,userAgent:s,headers:e.headers,queryParameters:l,hosts:c.map((function(e){return b(e)})),read:function(e,t){var r=d(t,f.timeouts.read),n=function(){return j(f,f.hosts.filter((function(e){return 0!=(e.accept&m.Read)})),e,r)};if(!0!==(void 0!==r.cacheable?r.cacheable:e.cacheable))return n();var a={request:e,mappedRequestOptions:r,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(a,(function(){return f.requestsCache.get(a,(function(){return f.requestsCache.set(a,n()).then((function(e){return Promise.all([f.requestsCache.delete(a),e])}),(function(e){return Promise.all([f.requestsCache.delete(a),Promise.reject(e)])})).then((function(e){var t=o(e,2);t[0];return t[1]}))}))}),{miss:function(e){return f.responsesCache.set(a,e)}})},write:function(e,t){return j(f,f.hosts.filter((function(e){return 0!=(e.accept&m.Write)})),e,d(t,f.timeouts.write))}};return f}(r(r({hosts:[{url:"".concat(t,"-dsn.algolia.net"),accept:m.Read},{url:"".concat(t,".algolia.net"),accept:m.Write}].concat(c([{url:"".concat(t,"-1.algolianet.com")},{url:"".concat(t,"-2.algolianet.com")},{url:"".concat(t,"-3.algolianet.com")}]))},e),{},{headers:r(r(r({},n.headers()),{"content-type":"application/x-www-form-urlencoded"}),e.headers),queryParameters:r(r({},n.queryParameters()),e.queryParameters)}));return l({transporter:a,appId:t,addAlgoliaAgent:function(e,t){a.userAgent.add({segment:e,version:t})},clearCache:function(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then((function(){}))}},e.methods)},C=function(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={transporter:e.transporter,appId:e.appId,indexName:t};return l(n,r.methods)}},k=function(e){return function(t,n){var o=t.map((function(e){return r(r({},e),{},{params:T(e.params||{})})}));return e.transporter.read({method:P,path:"1/indexes/*/queries",data:{requests:o},cacheable:!0},n)}},J=function(e){return function(t,o){return Promise.all(t.map((function(t){var a=t.params,u=a.facetName,i=a.facetQuery,s=n(a,["facetName","facetQuery"]);return C(e)(t.indexName,{methods:{searchForFacetValues:F}}).searchForFacetValues(u,i,r(r({},o),s))})))}},E=function(e){return function(t,r,n){return e.transporter.read({method:P,path:f("1/answers/%s/prediction",e.indexName),data:{query:t,queryLanguages:r},cacheable:!0},n)}},I=function(e){return function(t,r){return e.transporter.read({method:P,path:f("1/indexes/%s/query",e.indexName),data:{query:t},cacheable:!0},r)}},F=function(e){return function(t,r,n){return e.transporter.read({method:P,path:f("1/indexes/%s/facets/%s/query",e.indexName,t),data:{facetQuery:r},cacheable:!0},n)}},R=1,D=2,W=3;function H(e,t,n){var o,a={appId:e,apiKey:t,timeouts:{connect:1,read:2,write:30},requester:{send:function(e){return new Promise((function(t){var r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((function(t){return r.setRequestHeader(t,e.headers[t])}));var n,o=function(e,n){return setTimeout((function(){r.abort(),t({status:0,content:n,isTimedOut:!0})}),1e3*e)},a=o(e.connectTimeout,"Connection timeout");r.onreadystatechange=function(){r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=o(e.responseTimeout,"Socket timeout"))},r.onerror=function(){0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=function(){clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},logger:(o=W,{debug:function(e,t){return R>=o&&console.debug(e,t),Promise.resolve()},info:function(e,t){return D>=o&&console.info(e,t),Promise.resolve()},error:function(e,t){return console.error(e,t),Promise.resolve()}}),responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:i({caches:[u({key:"".concat("4.10.3","-").concat(e)}),s()]}),userAgent:w("4.10.3").add({segment:"Browser",version:"lite"}),authMode:h.WithinQueryParameters};return N(r(r(r({},a),n),{},{methods:{search:k,searchForFacetValues:J,multipleQueries:k,multipleSearchForFacetValues:J,initIndex:function(e){return function(t){return C(e)(t,{methods:{search:I,searchForFacetValues:F,findAnswers:E}})}}}}))}return H.version="4.10.3",H})); diff --git a/js/algoliasearch/dist/algoliasearch.angular.js b/js/algoliasearch/dist/algoliasearch.angular.js deleted file mode 100644 index 2856434f..00000000 --- a/js/algoliasearch/dist/algoliasearch.angular.js +++ /dev/null @@ -1,7398 +0,0 @@ -/*! algoliasearch 3.35.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */ -(function(f){var g;if(typeof window!=='undefined'){g=window}else if(typeof self!=='undefined'){g=self}g.ALGOLIA_MIGRATION_LAYER=f()})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;owindow.ALGOLIA_SUPPORTS_DOCWRITE = true\x3C/script>'); - - if (window.ALGOLIA_SUPPORTS_DOCWRITE === true) { - document.write('\x3Cscript src="' + v2ScriptUrl + '">\x3C/script>'); - scriptLoaded('document.write')(); - } else { - loadScript(v2ScriptUrl, scriptLoaded('DOMElement')); - } - } catch (e) { - loadScript(v2ScriptUrl, scriptLoaded('DOMElement')); - } -} - -function scriptLoaded(method) { - return function log() { - var message = 'AlgoliaSearch: loaded V2 script using ' + method; - - if (window.console && window.console.log) { - window.console.log(message); - } - }; -} - -},{"1":1}],4:[function(require,module,exports){ -'use strict'; - -/* eslint no-unused-vars: [2, {"vars": "local"}] */ - -module.exports = oldGlobals; - -// put old window.AlgoliaSearch.. into window. again so that -// users upgrading to V3 without changing their code, will be warned -function oldGlobals() { - var message = '-- AlgoliaSearch V2 => V3 error --\n' + - 'You are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\n' + - 'Please read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n' + - '-- /AlgoliaSearch V2 => V3 error --'; - - window.AlgoliaSearch = function() { - throw new Error(message); - }; - - window.AlgoliaSearchHelper = function() { - throw new Error(message); - }; - - window.AlgoliaExplainResults = function() { - throw new Error(message); - }; -} - -},{}],5:[function(require,module,exports){ -'use strict'; - -// This script will be browserified and prepended to the normal build -// directly in window, not wrapped in any module definition -// To avoid cases where we are loaded with /latest/ along with -migrationLayer("algoliasearch.angular"); - -// Now onto the V2 related code: -// If the client is using /latest/$BUILDNAME.min.js, load V2 of the library -// -// Otherwise, setup a migration layer that will throw on old constructors like -// new AlgoliaSearch(). -// So that users upgrading from v2 to v3 will have a clear information -// message on what to do if they did not read the migration guide -function migrationLayer(buildName) { - var isUsingLatest = require(2); - var loadV2 = require(3); - var oldGlobals = require(4); - - if (isUsingLatest(buildName)) { - loadV2(buildName); - } else { - oldGlobals(); - } -} - -},{"2":2,"3":3,"4":4}]},{},[5])(5) -});(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; - } - - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs(args) { - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return; - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} - -}).call(this,require(12)) -},{"12":12,"2":2}],2:[function(require,module,exports){ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require(9); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - -exports.formatters = {}; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ - -function selectColor(namespace) { - var hash = 0, i; - - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return exports.colors[Math.abs(hash) % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function createDebug(namespace) { - - function debug() { - // disabled? - if (!debug.enabled) return; - - var self = debug; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); - - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); - - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } - - return debug; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - exports.names = []; - exports.skips = []; - - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} - -},{"9":9}],3:[function(require,module,exports){ -(function (process,global){ -/*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version 4.1.1 - */ - -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.ES6Promise = factory()); -}(this, (function () { 'use strict'; - -function objectOrFunction(x) { - var type = typeof x; - return x !== null && (type === 'object' || type === 'function'); -} - -function isFunction(x) { - return typeof x === 'function'; -} - -var _isArray = undefined; -if (Array.isArray) { - _isArray = Array.isArray; -} else { - _isArray = function (x) { - return Object.prototype.toString.call(x) === '[object Array]'; - }; -} - -var isArray = _isArray; - -var len = 0; -var vertxNext = undefined; -var customSchedulerFn = undefined; - -var asap = function asap(callback, arg) { - queue[len] = callback; - queue[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 2, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - if (customSchedulerFn) { - customSchedulerFn(flush); - } else { - scheduleFlush(); - } - } -}; - -function setScheduler(scheduleFn) { - customSchedulerFn = scheduleFn; -} - -function setAsap(asapFn) { - asap = asapFn; -} - -var browserWindow = typeof window !== 'undefined' ? window : undefined; -var browserGlobal = browserWindow || {}; -var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; -var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]'; - -// test for web worker but not in IE10 -var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; - -// node -function useNextTick() { - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // see https://github.com/cujojs/when/issues/410 for details - return function () { - return process.nextTick(flush); - }; -} - -// vertx -function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); - }; - } - - return useSetTimeout(); -} - -function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); - - return function () { - node.data = iterations = ++iterations % 2; - }; -} - -// web worker -function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; -} - -function useSetTimeout() { - // Store setTimeout reference so es6-promise will be unaffected by - // other code modifying setTimeout (like sinon.useFakeTimers()) - var globalSetTimeout = setTimeout; - return function () { - return globalSetTimeout(flush, 1); - }; -} - -var queue = new Array(1000); -function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue[i]; - var arg = queue[i + 1]; - - callback(arg); - - queue[i] = undefined; - queue[i + 1] = undefined; - } - - len = 0; -} - -function attemptVertx() { - try { - var r = require; - var vertx = r('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } -} - -var scheduleFlush = undefined; -// Decide what async method to use to triggering processing of queued callbacks: -if (isNode) { - scheduleFlush = useNextTick(); -} else if (BrowserMutationObserver) { - scheduleFlush = useMutationObserver(); -} else if (isWorker) { - scheduleFlush = useMessageChannel(); -} else if (browserWindow === undefined && typeof require === 'function') { - scheduleFlush = attemptVertx(); -} else { - scheduleFlush = useSetTimeout(); -} - -function then(onFulfillment, onRejection) { - var _arguments = arguments; - - var parent = this; - - var child = new this.constructor(noop); - - if (child[PROMISE_ID] === undefined) { - makePromise(child); - } - - var _state = parent._state; - - if (_state) { - (function () { - var callback = _arguments[_state - 1]; - asap(function () { - return invokeCallback(_state, child, callback, parent._result); - }); - })(); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } - - return child; -} - -/** - `Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @static - @param {Any} value value that the returned promise will be resolved with - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` -*/ -function resolve$1(object) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - var promise = new Constructor(noop); - resolve(promise, object); - return promise; -} - -var PROMISE_ID = Math.random().toString(36).substring(16); - -function noop() {} - -var PENDING = void 0; -var FULFILLED = 1; -var REJECTED = 2; - -var GET_THEN_ERROR = new ErrorObject(); - -function selfFulfillment() { - return new TypeError("You cannot resolve a promise with itself"); -} - -function cannotReturnOwn() { - return new TypeError('A promises callback cannot return that same promise.'); -} - -function getThen(promise) { - try { - return promise.then; - } catch (error) { - GET_THEN_ERROR.error = error; - return GET_THEN_ERROR; - } -} - -function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { - try { - then$$1.call(value, fulfillmentHandler, rejectionHandler); - } catch (e) { - return e; - } -} - -function handleForeignThenable(promise, thenable, then$$1) { - asap(function (promise) { - var sealed = false; - var error = tryThen(then$$1, thenable, function (value) { - if (sealed) { - return; - } - sealed = true; - if (thenable !== value) { - resolve(promise, value); - } else { - fulfill(promise, value); - } - }, function (reason) { - if (sealed) { - return; - } - sealed = true; - - reject(promise, reason); - }, 'Settle: ' + (promise._label || ' unknown promise')); - - if (!sealed && error) { - sealed = true; - reject(promise, error); - } - }, promise); -} - -function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } -} - -function handleMaybeThenable(promise, maybeThenable, then$$1) { - if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$1 === GET_THEN_ERROR) { - reject(promise, GET_THEN_ERROR.error); - GET_THEN_ERROR.error = null; - } else if (then$$1 === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$1)) { - handleForeignThenable(promise, maybeThenable, then$$1); - } else { - fulfill(promise, maybeThenable); - } - } -} - -function resolve(promise, value) { - if (promise === value) { - reject(promise, selfFulfillment()); - } else if (objectOrFunction(value)) { - handleMaybeThenable(promise, value, getThen(value)); - } else { - fulfill(promise, value); - } -} - -function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._result); - } - - publish(promise); -} - -function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } - - promise._result = value; - promise._state = FULFILLED; - - if (promise._subscribers.length !== 0) { - asap(publish, promise); - } -} - -function reject(promise, reason) { - if (promise._state !== PENDING) { - return; - } - promise._state = REJECTED; - promise._result = reason; - - asap(publishRejection, promise); -} - -function subscribe(parent, child, onFulfillment, onRejection) { - var _subscribers = parent._subscribers; - var length = _subscribers.length; - - parent._onerror = null; - - _subscribers[length] = child; - _subscribers[length + FULFILLED] = onFulfillment; - _subscribers[length + REJECTED] = onRejection; - - if (length === 0 && parent._state) { - asap(publish, parent); - } -} - -function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; - - if (subscribers.length === 0) { - return; - } - - var child = undefined, - callback = undefined, - detail = promise._result; - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } - - promise._subscribers.length = 0; -} - -function ErrorObject() { - this.error = null; -} - -var TRY_CATCH_ERROR = new ErrorObject(); - -function tryCatch(callback, detail) { - try { - return callback(detail); - } catch (e) { - TRY_CATCH_ERROR.error = e; - return TRY_CATCH_ERROR; - } -} - -function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = undefined, - error = undefined, - succeeded = undefined, - failed = undefined; - - if (hasCallback) { - value = tryCatch(callback, detail); - - if (value === TRY_CATCH_ERROR) { - failed = true; - error = value.error; - value.error = null; - } else { - succeeded = true; - } - - if (promise === value) { - reject(promise, cannotReturnOwn()); - return; - } - } else { - value = detail; - succeeded = true; - } - - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (failed) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } -} - -function initializePromise(promise, resolver) { - try { - resolver(function resolvePromise(value) { - resolve(promise, value); - }, function rejectPromise(reason) { - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); - } -} - -var id = 0; -function nextId() { - return id++; -} - -function makePromise(promise) { - promise[PROMISE_ID] = id++; - promise._state = undefined; - promise._result = undefined; - promise._subscribers = []; -} - -function Enumerator$1(Constructor, input) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop); - - if (!this.promise[PROMISE_ID]) { - makePromise(this.promise); - } - - if (isArray(input)) { - this.length = input.length; - this._remaining = input.length; - - this._result = new Array(this.length); - - if (this.length === 0) { - fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(input); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } - } - } else { - reject(this.promise, validationError()); - } -} - -function validationError() { - return new Error('Array Methods must be provided an Array'); -} - -Enumerator$1.prototype._enumerate = function (input) { - for (var i = 0; this._state === PENDING && i < input.length; i++) { - this._eachEntry(input[i], i); - } -}; - -Enumerator$1.prototype._eachEntry = function (entry, i) { - var c = this._instanceConstructor; - var resolve$$1 = c.resolve; - - if (resolve$$1 === resolve$1) { - var _then = getThen(entry); - - if (_then === then && entry._state !== PENDING) { - this._settledAt(entry._state, i, entry._result); - } else if (typeof _then !== 'function') { - this._remaining--; - this._result[i] = entry; - } else if (c === Promise$2) { - var promise = new c(noop); - handleMaybeThenable(promise, entry, _then); - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve$$1) { - return resolve$$1(entry); - }), i); - } - } else { - this._willSettleAt(resolve$$1(entry), i); - } -}; - -Enumerator$1.prototype._settledAt = function (state, i, value) { - var promise = this.promise; - - if (promise._state === PENDING) { - this._remaining--; - - if (state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = value; - } - } - - if (this._remaining === 0) { - fulfill(promise, this._result); - } -}; - -Enumerator$1.prototype._willSettleAt = function (promise, i) { - var enumerator = this; - - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); -}; - -/** - `Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = resolve(2); - let promise3 = resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = reject(new Error("2")); - let promise3 = reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static -*/ -function all$1(entries) { - return new Enumerator$1(this, entries).promise; -} - -/** - `Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} promises array of promises to observe - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. -*/ -function race$1(entries) { - /*jshint validthis:true */ - var Constructor = this; - - if (!isArray(entries)) { - return new Constructor(function (_, reject) { - return reject(new TypeError('You must pass an array to race.')); - }); - } else { - return new Constructor(function (resolve, reject) { - var length = entries.length; - for (var i = 0; i < length; i++) { - Constructor.resolve(entries[i]).then(resolve, reject); - } - }); - } -} - -/** - `Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {Any} reason value that the returned promise will be rejected with. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. -*/ -function reject$1(reason) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop); - reject(promise, reason); - return promise; -} - -function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); -} - -function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); -} - -/** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } - } - }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {function} resolver - Useful for tooling. - @constructor -*/ -function Promise$2(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise$2 ? initializePromise(this, resolver) : needsNew(); - } -} - -Promise$2.all = all$1; -Promise$2.race = race$1; -Promise$2.resolve = resolve$1; -Promise$2.reject = reject$1; -Promise$2._setScheduler = setScheduler; -Promise$2._setAsap = setAsap; -Promise$2._asap = asap; - -Promise$2.prototype = { - constructor: Promise$2, - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - - Chaining - -------- - - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - - Assimilation - ------------ - - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - - If the assimliated promise rejects, then the downstream promise will also reject. - - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - - Simple Example - -------------- - - Synchronous Example - - ```javascript - let result; - - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - findResult(function(result, err){ - if (err) { - // failure - } else { - // success - } - }); - ``` - - Promise Example; - - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - - Advanced Example - -------------- - - Synchronous Example - - ```javascript - let author, books; - - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure - } - ``` - - Errback Example - - ```js - - function foundBooks(books) { - - } - - function failure(reason) { - - } - - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - - Promise Example; - - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - then: then, - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ - 'catch': function _catch(onRejection) { - return this.then(null, onRejection); - } -}; - -/*global self*/ -function polyfill$1() { - var local = undefined; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; - } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } - } - - var P = local.Promise; - - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } - - if (promiseToString === '[object Promise]' && !P.cast) { - return; - } - } - - local.Promise = Promise$2; -} - -// Strange compat.. -Promise$2.polyfill = polyfill$1; -Promise$2.Promise = Promise$2; - -return Promise$2; - -}))); - - - -}).call(this,require(12),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"12":12}],4:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - -},{}],5:[function(require,module,exports){ - -var hasOwn = Object.prototype.hasOwnProperty; -var toString = Object.prototype.toString; - -module.exports = function forEach (obj, fn, ctx) { - if (toString.call(fn) !== '[object Function]') { - throw new TypeError('iterator must be a function'); - } - var l = obj.length; - if (l === +l) { - for (var i = 0; i < l; i++) { - fn.call(ctx, obj[i], i, obj); - } - } else { - for (var k in obj) { - if (hasOwn.call(obj, k)) { - fn.call(ctx, obj[k], k, obj); - } - } - } -}; - - -},{}],6:[function(require,module,exports){ -(function (global){ -var win; - -if (typeof window !== "undefined") { - win = window; -} else if (typeof global !== "undefined") { - win = global; -} else if (typeof self !== "undefined"){ - win = self; -} else { - win = {}; -} - -module.exports = win; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],7:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - -},{}],8:[function(require,module,exports){ -var toString = {}.toString; - -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; - -},{}],9:[function(require,module,exports){ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} [options] - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options) { - options = options || {}; - var type = typeof val; - if (type === 'string' && val.length > 0) { - return parse(val); - } else if (type === 'number' && isNaN(val) === false) { - return options.long ? fmtLong(val) : fmtShort(val); - } - throw new Error( - 'val is not a non-empty string or a valid number. val=' + - JSON.stringify(val) - ); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = String(str); - if (str.length > 100) { - return; - } - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( - str - ); - if (!match) { - return; - } - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - default: - return undefined; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtShort(ms) { - if (ms >= d) { - return Math.round(ms / d) + 'd'; - } - if (ms >= h) { - return Math.round(ms / h) + 'h'; - } - if (ms >= m) { - return Math.round(ms / m) + 'm'; - } - if (ms >= s) { - return Math.round(ms / s) + 's'; - } - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function fmtLong(ms) { - return plural(ms, d, 'day') || - plural(ms, h, 'hour') || - plural(ms, m, 'minute') || - plural(ms, s, 'second') || - ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) { - return; - } - if (ms < n * 1.5) { - return Math.floor(ms / n) + ' ' + name; - } - return Math.ceil(ms / n) + ' ' + name + 's'; -} - -},{}],10:[function(require,module,exports){ -'use strict'; - -// modified from https://github.com/es-shims/es5-shim -var has = Object.prototype.hasOwnProperty; -var toStr = Object.prototype.toString; -var slice = Array.prototype.slice; -var isArgs = require(11); -var isEnumerable = Object.prototype.propertyIsEnumerable; -var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); -var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); -var dontEnums = [ - 'toString', - 'toLocaleString', - 'valueOf', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'constructor' -]; -var equalsConstructorPrototype = function (o) { - var ctor = o.constructor; - return ctor && ctor.prototype === o; -}; -var excludedKeys = { - $console: true, - $external: true, - $frame: true, - $frameElement: true, - $frames: true, - $innerHeight: true, - $innerWidth: true, - $outerHeight: true, - $outerWidth: true, - $pageXOffset: true, - $pageYOffset: true, - $parent: true, - $scrollLeft: true, - $scrollTop: true, - $scrollX: true, - $scrollY: true, - $self: true, - $webkitIndexedDB: true, - $webkitStorageInfo: true, - $window: true -}; -var hasAutomationEqualityBug = (function () { - /* global window */ - if (typeof window === 'undefined') { return false; } - for (var k in window) { - try { - if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { - try { - equalsConstructorPrototype(window[k]); - } catch (e) { - return true; - } - } - } catch (e) { - return true; - } - } - return false; -}()); -var equalsConstructorPrototypeIfNotBuggy = function (o) { - /* global window */ - if (typeof window === 'undefined' || !hasAutomationEqualityBug) { - return equalsConstructorPrototype(o); - } - try { - return equalsConstructorPrototype(o); - } catch (e) { - return false; - } -}; - -var keysShim = function keys(object) { - var isObject = object !== null && typeof object === 'object'; - var isFunction = toStr.call(object) === '[object Function]'; - var isArguments = isArgs(object); - var isString = isObject && toStr.call(object) === '[object String]'; - var theKeys = []; - - if (!isObject && !isFunction && !isArguments) { - throw new TypeError('Object.keys called on a non-object'); - } - - var skipProto = hasProtoEnumBug && isFunction; - if (isString && object.length > 0 && !has.call(object, 0)) { - for (var i = 0; i < object.length; ++i) { - theKeys.push(String(i)); - } - } - - if (isArguments && object.length > 0) { - for (var j = 0; j < object.length; ++j) { - theKeys.push(String(j)); - } - } else { - for (var name in object) { - if (!(skipProto && name === 'prototype') && has.call(object, name)) { - theKeys.push(String(name)); - } - } - } - - if (hasDontEnumBug) { - var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); - - for (var k = 0; k < dontEnums.length; ++k) { - if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { - theKeys.push(dontEnums[k]); - } - } - } - return theKeys; -}; - -keysShim.shim = function shimObjectKeys() { - if (Object.keys) { - var keysWorksWithArguments = (function () { - // Safari 5.0 bug - return (Object.keys(arguments) || '').length === 2; - }(1, 2)); - if (!keysWorksWithArguments) { - var originalKeys = Object.keys; - Object.keys = function keys(object) { - if (isArgs(object)) { - return originalKeys(slice.call(object)); - } else { - return originalKeys(object); - } - }; - } - } else { - Object.keys = keysShim; - } - return Object.keys || keysShim; -}; - -module.exports = keysShim; - -},{"11":11}],11:[function(require,module,exports){ -'use strict'; - -var toStr = Object.prototype.toString; - -module.exports = function isArguments(value) { - var str = toStr.call(value); - var isArgs = str === '[object Arguments]'; - if (!isArgs) { - isArgs = str !== '[object Array]' && - value !== null && - typeof value === 'object' && - typeof value.length === 'number' && - value.length >= 0 && - toStr.call(value.callee) === '[object Function]'; - } - return isArgs; -}; - -},{}],12:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],13:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; - - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } - - var regexp = /\+/g; - qs = qs.split(sep); - - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } - - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } - - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; - - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } - - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); - - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } - - return obj; -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -},{}],14:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; - - case 'boolean': - return v ? 'true' : 'false'; - - case 'number': - return isFinite(v) ? v : ''; - - default: - return ''; - } -}; - -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } - - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); - - } - - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; - -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; - -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} - -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; - -},{}],15:[function(require,module,exports){ -'use strict'; - -exports.decode = exports.parse = require(13); -exports.encode = exports.stringify = require(14); - -},{"13":13,"14":14}],16:[function(require,module,exports){ -module.exports = AlgoliaSearch; - -var Index = require(18); -var deprecate = require(29); -var deprecatedMessage = require(30); -var AlgoliaSearchCore = require(17); -var inherits = require(7); -var errors = require(31); - -function AlgoliaSearch() { - AlgoliaSearchCore.apply(this, arguments); -} - -inherits(AlgoliaSearch, AlgoliaSearchCore); - -/* - * Delete an index - * - * @param indexName the name of index to delete - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer that contains the task ID - */ -AlgoliaSearch.prototype.deleteIndex = function(indexName, callback) { - return this._jsonRequest({ - method: 'DELETE', - url: '/1/indexes/' + encodeURIComponent(indexName), - hostType: 'write', - callback: callback - }); -}; - -/** - * Move an existing index. - * @param srcIndexName the name of index to copy. - * @param dstIndexName the new index name that will contains a copy of - * srcIndexName (destination will be overriten if it already exist). - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer that contains the task ID - */ -AlgoliaSearch.prototype.moveIndex = function(srcIndexName, dstIndexName, callback) { - var postObj = { - operation: 'move', destination: dstIndexName - }; - return this._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/** - * Copy an existing index. - * @param srcIndexName the name of index to copy. - * @param dstIndexName the new index name that will contains a copy - * of srcIndexName (destination will be overriten if it already exist). - * @param scope an array of scopes to copy: ['settings', 'synonyms', 'rules'] - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer that contains the task ID - */ -AlgoliaSearch.prototype.copyIndex = function(srcIndexName, dstIndexName, scopeOrCallback, _callback) { - var postObj = { - operation: 'copy', - destination: dstIndexName - }; - var callback = _callback; - if (typeof scopeOrCallback === 'function') { - // oops, old behaviour of third argument being a function - callback = scopeOrCallback; - } else if (Array.isArray(scopeOrCallback) && scopeOrCallback.length > 0) { - postObj.scope = scopeOrCallback; - } else if (typeof scopeOrCallback !== 'undefined') { - throw new Error('the scope given to `copyIndex` was not an array with settings, synonyms or rules'); - } - return this._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(srcIndexName) + '/operation', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/** - * Return last log entries. - * @param offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry). - * @param length Specify the maximum number of entries to retrieve starting - * at offset. Maximum allowed value: 1000. - * @param type Specify the maximum number of entries to retrieve starting - * at offset. Maximum allowed value: 1000. - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer that contains the task ID - */ -AlgoliaSearch.prototype.getLogs = function(offset, length, callback) { - var clone = require(27); - var params = {}; - if (typeof offset === 'object') { - // getLogs(params) - params = clone(offset); - callback = length; - } else if (arguments.length === 0 || typeof offset === 'function') { - // getLogs([cb]) - callback = offset; - } else if (arguments.length === 1 || typeof length === 'function') { - // getLogs(1, [cb)] - callback = length; - params.offset = offset; - } else { - // getLogs(1, 2, [cb]) - params.offset = offset; - params.length = length; - } - - if (params.offset === undefined) params.offset = 0; - if (params.length === undefined) params.length = 10; - - return this._jsonRequest({ - method: 'GET', - url: '/1/logs?' + this._getSearchParams(params, ''), - hostType: 'read', - callback: callback - }); -}; - -/* - * List all existing indexes (paginated) - * - * @param page The page to retrieve, starting at 0. - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer with index list - */ -AlgoliaSearch.prototype.listIndexes = function(page, callback) { - var params = ''; - - if (page === undefined || typeof page === 'function') { - callback = page; - } else { - params = '?page=' + page; - } - - return this._jsonRequest({ - method: 'GET', - url: '/1/indexes' + params, - hostType: 'read', - callback: callback - }); -}; - -/* - * Get the index object initialized - * - * @param indexName the name of index - * @param callback the result callback with one argument (the Index instance) - */ -AlgoliaSearch.prototype.initIndex = function(indexName) { - return new Index(this, indexName); -}; - -AlgoliaSearch.prototype.initAnalytics = function(opts) { - // the actual require must be inside the function, when put outside then you have a cyclic dependency - // not well resolved that ends up making the main "./index.js" (main module, the agloliasearch function) - // export an object instead of a function - // Other workarounds: - // - rewrite the lib in ES6, cyclic dependencies may be better supported - // - move initAnalytics to a property on the main module (algoliasearch.initAnalytics), - // same as places. - // The current API was made mostly to mimic the one made in PHP - var createAnalyticsClient = require(28); - return createAnalyticsClient(this.applicationID, this.apiKey, opts); -}; - -/* - * @deprecated use client.listApiKeys - */ -AlgoliaSearch.prototype.listUserKeys = deprecate(function(callback) { - return this.listApiKeys(callback); -}, deprecatedMessage('client.listUserKeys()', 'client.listApiKeys()')); - -/* - * List all existing api keys with their associated ACLs - * - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer with api keys list - */ -AlgoliaSearch.prototype.listApiKeys = function(callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/keys', - hostType: 'read', - callback: callback - }); -}; - -/* - * @deprecated see client.getApiKey - */ -AlgoliaSearch.prototype.getUserKeyACL = deprecate(function(key, callback) { - return this.getApiKey(key, callback); -}, deprecatedMessage('client.getUserKeyACL()', 'client.getApiKey()')); - -/* - * Get an API key - * - * @param key - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer with the right API key - */ -AlgoliaSearch.prototype.getApiKey = function(key, callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/keys/' + key, - hostType: 'read', - callback: callback - }); -}; - -/* - * @deprecated see client.deleteApiKey - */ -AlgoliaSearch.prototype.deleteUserKey = deprecate(function(key, callback) { - return this.deleteApiKey(key, callback); -}, deprecatedMessage('client.deleteUserKey()', 'client.deleteApiKey()')); - -/* - * Delete an existing API key - * @param key - * @param callback the result callback called with two arguments - * error: null or Error('message') - * content: the server answer with the date of deletion - */ -AlgoliaSearch.prototype.deleteApiKey = function(key, callback) { - return this._jsonRequest({ - method: 'DELETE', - url: '/1/keys/' + key, - hostType: 'write', - callback: callback - }); -}; - -/** - * Restore a deleted API key - * - * @param {String} key - The key to restore - * @param {Function} callback - The result callback called with two arguments - * error: null or Error('message') - * content: the server answer with the restored API key - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.restoreApiKey('APIKEY') - * @see {@link https://www.algolia.com/doc/rest-api/search/#restore-api-key|Algolia REST API Documentation} - */ -AlgoliaSearch.prototype.restoreApiKey = function(key, callback) { - return this._jsonRequest({ - method: 'POST', - url: '/1/keys/' + key + '/restore', - hostType: 'write', - callback: callback - }); -}; - -/* - @deprecated see client.addApiKey - */ -AlgoliaSearch.prototype.addUserKey = deprecate(function(acls, params, callback) { - return this.addApiKey(acls, params, callback); -}, deprecatedMessage('client.addUserKey()', 'client.addApiKey()')); - -/* - * Add a new global API key - * - * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that - * can contains the following values: - * - search: allow to search (https and http) - * - addObject: allows to add/update an object in the index (https only) - * - deleteObject : allows to delete an existing object (https only) - * - deleteIndex : allows to delete index content (https only) - * - settings : allows to get index settings (https only) - * - editSettings : allows to change index settings (https only) - * @param {Object} [params] - Optionnal parameters to set for the key - * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key) - * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour - * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call - * @param {string[]} params.indexes - Allowed targeted indexes for this key - * @param {string} params.description - A description for your key - * @param {string[]} params.referers - A list of authorized referers - * @param {Object} params.queryParameters - Force the key to use specific query parameters - * @param {Function} callback - The result callback called with two arguments - * error: null or Error('message') - * content: the server answer with the added API key - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.addApiKey(['search'], { - * validity: 300, - * maxQueriesPerIPPerHour: 2000, - * maxHitsPerQuery: 3, - * indexes: ['fruits'], - * description: 'Eat three fruits', - * referers: ['*.algolia.com'], - * queryParameters: { - * tagFilters: ['public'], - * } - * }) - * @see {@link https://www.algolia.com/doc/rest_api#AddKey|Algolia REST API Documentation} - */ -AlgoliaSearch.prototype.addApiKey = function(acls, params, callback) { - var isArray = require(8); - var usage = 'Usage: client.addApiKey(arrayOfAcls[, params, callback])'; - - if (!isArray(acls)) { - throw new Error(usage); - } - - if (arguments.length === 1 || typeof params === 'function') { - callback = params; - params = null; - } - - var postObj = { - acl: acls - }; - - if (params) { - postObj.validity = params.validity; - postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; - postObj.maxHitsPerQuery = params.maxHitsPerQuery; - postObj.indexes = params.indexes; - postObj.description = params.description; - - if (params.queryParameters) { - postObj.queryParameters = this._getSearchParams(params.queryParameters, ''); - } - - postObj.referers = params.referers; - } - - return this._jsonRequest({ - method: 'POST', - url: '/1/keys', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/** - * @deprecated Please use client.addApiKey() - */ -AlgoliaSearch.prototype.addUserKeyWithValidity = deprecate(function(acls, params, callback) { - return this.addApiKey(acls, params, callback); -}, deprecatedMessage('client.addUserKeyWithValidity()', 'client.addApiKey()')); - -/** - * @deprecated Please use client.updateApiKey() - */ -AlgoliaSearch.prototype.updateUserKey = deprecate(function(key, acls, params, callback) { - return this.updateApiKey(key, acls, params, callback); -}, deprecatedMessage('client.updateUserKey()', 'client.updateApiKey()')); - -/** - * Update an existing API key - * @param {string} key - The key to update - * @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that - * can contains the following values: - * - search: allow to search (https and http) - * - addObject: allows to add/update an object in the index (https only) - * - deleteObject : allows to delete an existing object (https only) - * - deleteIndex : allows to delete index content (https only) - * - settings : allows to get index settings (https only) - * - editSettings : allows to change index settings (https only) - * @param {Object} [params] - Optionnal parameters to set for the key - * @param {number} params.validity - Number of seconds after which the key will be automatically removed (0 means no time limit for this key) - * @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour - * @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call - * @param {string[]} params.indexes - Allowed targeted indexes for this key - * @param {string} params.description - A description for your key - * @param {string[]} params.referers - A list of authorized referers - * @param {Object} params.queryParameters - Force the key to use specific query parameters - * @param {Function} callback - The result callback called with two arguments - * error: null or Error('message') - * content: the server answer with the modified API key - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.updateApiKey('APIKEY', ['search'], { - * validity: 300, - * maxQueriesPerIPPerHour: 2000, - * maxHitsPerQuery: 3, - * indexes: ['fruits'], - * description: 'Eat three fruits', - * referers: ['*.algolia.com'], - * queryParameters: { - * tagFilters: ['public'], - * } - * }) - * @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation} - */ -AlgoliaSearch.prototype.updateApiKey = function(key, acls, params, callback) { - var isArray = require(8); - var usage = 'Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])'; - - if (!isArray(acls)) { - throw new Error(usage); - } - - if (arguments.length === 2 || typeof params === 'function') { - callback = params; - params = null; - } - - var putObj = { - acl: acls - }; - - if (params) { - putObj.validity = params.validity; - putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; - putObj.maxHitsPerQuery = params.maxHitsPerQuery; - putObj.indexes = params.indexes; - putObj.description = params.description; - - if (params.queryParameters) { - putObj.queryParameters = this._getSearchParams(params.queryParameters, ''); - } - - putObj.referers = params.referers; - } - - return this._jsonRequest({ - method: 'PUT', - url: '/1/keys/' + key, - body: putObj, - hostType: 'write', - callback: callback - }); -}; - -/** - * Initialize a new batch of search queries - * @deprecated use client.search() - */ -AlgoliaSearch.prototype.startQueriesBatch = deprecate(function startQueriesBatchDeprecated() { - this._batch = []; -}, deprecatedMessage('client.startQueriesBatch()', 'client.search()')); - -/** - * Add a search query in the batch - * @deprecated use client.search() - */ -AlgoliaSearch.prototype.addQueryInBatch = deprecate(function addQueryInBatchDeprecated(indexName, query, args) { - this._batch.push({ - indexName: indexName, - query: query, - params: args - }); -}, deprecatedMessage('client.addQueryInBatch()', 'client.search()')); - -/** - * Launch the batch of queries using XMLHttpRequest. - * @deprecated use client.search() - */ -AlgoliaSearch.prototype.sendQueriesBatch = deprecate(function sendQueriesBatchDeprecated(callback) { - return this.search(this._batch, callback); -}, deprecatedMessage('client.sendQueriesBatch()', 'client.search()')); - -/** - * Perform write operations across multiple indexes. - * - * To reduce the amount of time spent on network round trips, - * you can create, update, or delete several objects in one call, - * using the batch endpoint (all operations are done in the given order). - * - * Available actions: - * - addObject - * - updateObject - * - partialUpdateObject - * - partialUpdateObjectNoCreate - * - deleteObject - * - * https://www.algolia.com/doc/rest_api#Indexes - * @param {Object[]} operations An array of operations to perform - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.batch([{ - * action: 'addObject', - * indexName: 'clients', - * body: { - * name: 'Bill' - * } - * }, { - * action: 'udpateObject', - * indexName: 'fruits', - * body: { - * objectID: '29138', - * name: 'banana' - * } - * }], cb) - */ -AlgoliaSearch.prototype.batch = function(operations, callback) { - var isArray = require(8); - var usage = 'Usage: client.batch(operations[, callback])'; - - if (!isArray(operations)) { - throw new Error(usage); - } - - return this._jsonRequest({ - method: 'POST', - url: '/1/indexes/*/batch', - body: { - requests: operations - }, - hostType: 'write', - callback: callback - }); -}; - -/** - * Assign or Move a userID to a cluster - * - * @param {string} data.userID The userID to assign to a new cluster - * @param {string} data.cluster The cluster to assign the user to - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.assignUserID({ cluster: 'c1-test', userID: 'some-user' }); - */ -AlgoliaSearch.prototype.assignUserID = function(data, callback) { - if (!data.userID || !data.cluster) { - throw new errors.AlgoliaSearchError('You have to provide both a userID and cluster', data); - } - return this._jsonRequest({ - method: 'POST', - url: '/1/clusters/mapping', - hostType: 'write', - body: {cluster: data.cluster}, - callback: callback, - headers: { - 'x-algolia-user-id': data.userID - } - }); -}; - -/** - * Assign a array of userIDs to a cluster. - * - * @param {Array} data.userIDs The array of userIDs to assign to a new cluster - * @param {string} data.cluster The cluster to assign the user to - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.assignUserIDs({ cluster: 'c1-test', userIDs: ['some-user-1', 'some-user-2'] }); - */ -AlgoliaSearch.prototype.assignUserIDs = function(data, callback) { - if (!data.userIDs || !data.cluster) { - throw new errors.AlgoliaSearchError('You have to provide both an array of userIDs and cluster', data); - } - return this._jsonRequest({ - method: 'POST', - url: '/1/clusters/mapping/batch', - hostType: 'write', - body: { - cluster: data.cluster, - users: data.userIDs - }, - callback: callback - }); -}; - -/** - * Get the top userIDs - * - * (the callback is the second argument) - * - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.getTopUserID(); - */ -AlgoliaSearch.prototype.getTopUserID = function(callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/clusters/mapping/top', - hostType: 'read', - callback: callback - }); -}; - -/** - * Get userID - * - * @param {string} data.userID The userID to get info about - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.getUserID({ userID: 'some-user' }); - */ -AlgoliaSearch.prototype.getUserID = function(data, callback) { - if (!data.userID) { - throw new errors.AlgoliaSearchError('You have to provide a userID', {debugData: data}); - } - return this._jsonRequest({ - method: 'GET', - url: '/1/clusters/mapping/' + data.userID, - hostType: 'read', - callback: callback - }); -}; - -/** - * List all the clusters - * - * (the callback is the second argument) - * - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.listClusters(); - */ -AlgoliaSearch.prototype.listClusters = function(callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/clusters', - hostType: 'read', - callback: callback - }); -}; - -/** - * List the userIDs - * - * (the callback is the second argument) - * - * @param {string} data.hitsPerPage How many hits on every page - * @param {string} data.page The page to retrieve - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.listClusters(); - * client.listClusters({ page: 3, hitsPerPage: 30}); - */ -AlgoliaSearch.prototype.listUserIDs = function(data, callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/clusters/mapping', - body: data, - hostType: 'read', - callback: callback - }); -}; - -/** - * Remove an userID - * - * @param {string} data.userID The userID to assign to a new cluster - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.removeUserID({ userID: 'some-user' }); - */ -AlgoliaSearch.prototype.removeUserID = function(data, callback) { - if (!data.userID) { - throw new errors.AlgoliaSearchError('You have to provide a userID', {debugData: data}); - } - return this._jsonRequest({ - method: 'DELETE', - url: '/1/clusters/mapping', - hostType: 'write', - callback: callback, - headers: { - 'x-algolia-user-id': data.userID - } - }); -}; - -/** - * Search for userIDs - * - * @param {string} data.cluster The cluster to target - * @param {string} data.query The query to execute - * @param {string} data.hitsPerPage How many hits on every page - * @param {string} data.page The page to retrieve - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.searchUserIDs({ cluster: 'c1-test', query: 'some-user' }); - * client.searchUserIDs({ - * cluster: "c1-test", - * query: "some-user", - * page: 3, - * hitsPerPage: 2 - * }); - */ -AlgoliaSearch.prototype.searchUserIDs = function(data, callback) { - return this._jsonRequest({ - method: 'POST', - url: '/1/clusters/mapping/search', - body: data, - hostType: 'read', - callback: callback - }); -}; - -/** - * Set strategy for personalization - * - * @param {Object} data - * @param {Object} data.eventsScoring Associate a score to an event - * @param {Object} data.eventsScoring. The name of the event - * @param {Number} data.eventsScoring..score The score to associate to - * @param {String} data.eventsScoring..type Either "click", "conversion" or "view" - * @param {Object} data.facetsScoring Associate a score to a facet - * @param {Object} data.facetsScoring. The name of the facet - * @param {Number} data.facetsScoring..score The score to associate to - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.setPersonalizationStrategy({ - * eventsScoring: { - * "Add to cart": { score: 50, type: "conversion" }, - * Purchase: { score: 100, type: "conversion" } - * }, - * facetsScoring: { - * brand: { score: 100 }, - * categories: { score: 10 } - * } - * }); - */ -AlgoliaSearch.prototype.setPersonalizationStrategy = function(data, callback) { - return this._jsonRequest({ - method: 'POST', - url: '/1/recommendation/personalization/strategy', - body: data, - hostType: 'write', - callback: callback - }); -}; - -/** - * Get strategy for personalization - * - * @return {Promise|undefined} Returns a promise if no callback given - * @example - * client.getPersonalizationStrategy(); - */ - -AlgoliaSearch.prototype.getPersonalizationStrategy = function(callback) { - return this._jsonRequest({ - method: 'GET', - url: '/1/recommendation/personalization/strategy', - hostType: 'read', - callback: callback - }); -}; - -// environment specific methods -AlgoliaSearch.prototype.destroy = notImplemented; -AlgoliaSearch.prototype.enableRateLimitForward = notImplemented; -AlgoliaSearch.prototype.disableRateLimitForward = notImplemented; -AlgoliaSearch.prototype.useSecuredAPIKey = notImplemented; -AlgoliaSearch.prototype.disableSecuredAPIKey = notImplemented; -AlgoliaSearch.prototype.generateSecuredApiKey = notImplemented; -AlgoliaSearch.prototype.getSecuredApiKeyRemainingValidity = notImplemented; - -function notImplemented() { - var message = 'Not implemented in this environment.\n' + - 'If you feel this is a mistake, write to support@algolia.com'; - - throw new errors.AlgoliaSearchError(message); -} - -},{"17":17,"18":18,"27":27,"28":28,"29":29,"30":30,"31":31,"7":7,"8":8}],17:[function(require,module,exports){ -(function (process){ -module.exports = AlgoliaSearchCore; - -var errors = require(31); -var exitPromise = require(32); -var IndexCore = require(20); -var store = require(37); - -// We will always put the API KEY in the JSON body in case of too long API KEY, -// to avoid query string being too long and failing in various conditions (our server limit, browser limit, -// proxies limit) -var MAX_API_KEY_LENGTH = 500; -var RESET_APP_DATA_TIMER = - process.env.RESET_APP_DATA_TIMER && parseInt(process.env.RESET_APP_DATA_TIMER, 10) || - 60 * 2 * 1000; // after 2 minutes reset to first host - -/* - * Algolia Search library initialization - * https://www.algolia.com/ - * - * @param {string} applicationID - Your applicationID, found in your dashboard - * @param {string} apiKey - Your API key, found in your dashboard - * @param {Object} [opts] - * @param {number} [opts.timeout=2000] - The request timeout set in milliseconds, - * another request will be issued after this timeout - * @param {string} [opts.protocol='https:'] - The protocol used to query Algolia Search API. - * Set to 'http:' to force using http. - * @param {Object|Array} [opts.hosts={ - * read: [this.applicationID + '-dsn.algolia.net'].concat([ - * this.applicationID + '-1.algolianet.com', - * this.applicationID + '-2.algolianet.com', - * this.applicationID + '-3.algolianet.com'] - * ]), - * write: [this.applicationID + '.algolia.net'].concat([ - * this.applicationID + '-1.algolianet.com', - * this.applicationID + '-2.algolianet.com', - * this.applicationID + '-3.algolianet.com'] - * ]) - The hosts to use for Algolia Search API. - * If you provide them, you will less benefit from our HA implementation - */ -function AlgoliaSearchCore(applicationID, apiKey, opts) { - var debug = require(1)('algoliasearch'); - - var clone = require(27); - var isArray = require(8); - var map = require(33); - - var usage = 'Usage: algoliasearch(applicationID, apiKey, opts)'; - - if (opts._allowEmptyCredentials !== true && !applicationID) { - throw new errors.AlgoliaSearchError('Please provide an application ID. ' + usage); - } - - if (opts._allowEmptyCredentials !== true && !apiKey) { - throw new errors.AlgoliaSearchError('Please provide an API key. ' + usage); - } - - this.applicationID = applicationID; - this.apiKey = apiKey; - - this.hosts = { - read: [], - write: [] - }; - - opts = opts || {}; - - this._timeouts = opts.timeouts || { - connect: 1 * 1000, // 500ms connect is GPRS latency - read: 2 * 1000, - write: 30 * 1000 - }; - - // backward compat, if opts.timeout is passed, we use it to configure all timeouts like before - if (opts.timeout) { - this._timeouts.connect = this._timeouts.read = this._timeouts.write = opts.timeout; - } - - var protocol = opts.protocol || 'https:'; - // while we advocate for colon-at-the-end values: 'http:' for `opts.protocol` - // we also accept `http` and `https`. It's a common error. - if (!/:$/.test(protocol)) { - protocol = protocol + ':'; - } - - if (protocol !== 'http:' && protocol !== 'https:') { - throw new errors.AlgoliaSearchError('protocol must be `http:` or `https:` (was `' + opts.protocol + '`)'); - } - - this._checkAppIdData(); - - if (!opts.hosts) { - var defaultHosts = map(this._shuffleResult, function(hostNumber) { - return applicationID + '-' + hostNumber + '.algolianet.com'; - }); - - // no hosts given, compute defaults - var mainSuffix = (opts.dsn === false ? '' : '-dsn') + '.algolia.net'; - this.hosts.read = [this.applicationID + mainSuffix].concat(defaultHosts); - this.hosts.write = [this.applicationID + '.algolia.net'].concat(defaultHosts); - } else if (isArray(opts.hosts)) { - // when passing custom hosts, we need to have a different host index if the number - // of write/read hosts are different. - this.hosts.read = clone(opts.hosts); - this.hosts.write = clone(opts.hosts); - } else { - this.hosts.read = clone(opts.hosts.read); - this.hosts.write = clone(opts.hosts.write); - } - - // add protocol and lowercase hosts - this.hosts.read = map(this.hosts.read, prepareHost(protocol)); - this.hosts.write = map(this.hosts.write, prepareHost(protocol)); - - this.extraHeaders = {}; - - // In some situations you might want to warm the cache - this.cache = opts._cache || {}; - - this._ua = opts._ua; - this._useCache = opts._useCache === undefined || opts._cache ? true : opts._useCache; - this._useRequestCache = this._useCache && opts._useRequestCache; - this._useFallback = opts.useFallback === undefined ? true : opts.useFallback; - - this._setTimeout = opts._setTimeout; - - debug('init done, %j', this); -} - -/* - * Get the index object initialized - * - * @param indexName the name of index - * @param callback the result callback with one argument (the Index instance) - */ -AlgoliaSearchCore.prototype.initIndex = function(indexName) { - return new IndexCore(this, indexName); -}; - -/** -* Add an extra field to the HTTP request -* -* @param name the header field name -* @param value the header field value -*/ -AlgoliaSearchCore.prototype.setExtraHeader = function(name, value) { - this.extraHeaders[name.toLowerCase()] = value; -}; - -/** -* Get the value of an extra HTTP header -* -* @param name the header field name -*/ -AlgoliaSearchCore.prototype.getExtraHeader = function(name) { - return this.extraHeaders[name.toLowerCase()]; -}; - -/** -* Remove an extra field from the HTTP request -* -* @param name the header field name -*/ -AlgoliaSearchCore.prototype.unsetExtraHeader = function(name) { - delete this.extraHeaders[name.toLowerCase()]; -}; - -/** -* Augment sent x-algolia-agent with more data, each agent part -* is automatically separated from the others by a semicolon; -* -* @param algoliaAgent the agent to add -*/ -AlgoliaSearchCore.prototype.addAlgoliaAgent = function(algoliaAgent) { - var algoliaAgentWithDelimiter = '; ' + algoliaAgent; - - if (this._ua.indexOf(algoliaAgentWithDelimiter) === -1) { - this._ua += algoliaAgentWithDelimiter; - } -}; - -/* - * Wrapper that try all hosts to maximize the quality of service - */ -AlgoliaSearchCore.prototype._jsonRequest = function(initialOpts) { - this._checkAppIdData(); - - var requestDebug = require(1)('algoliasearch:' + initialOpts.url); - - - var body; - var cacheID; - var additionalUA = initialOpts.additionalUA || ''; - var cache = initialOpts.cache; - var client = this; - var tries = 0; - var usingFallback = false; - var hasFallback = client._useFallback && client._request.fallback && initialOpts.fallback; - var headers; - - if ( - this.apiKey.length > MAX_API_KEY_LENGTH && - initialOpts.body !== undefined && - (initialOpts.body.params !== undefined || // index.search() - initialOpts.body.requests !== undefined) // client.search() - ) { - initialOpts.body.apiKey = this.apiKey; - headers = this._computeRequestHeaders({ - additionalUA: additionalUA, - withApiKey: false, - headers: initialOpts.headers - }); - } else { - headers = this._computeRequestHeaders({ - additionalUA: additionalUA, - headers: initialOpts.headers - }); - } - - if (initialOpts.body !== undefined) { - body = safeJSONStringify(initialOpts.body); - } - - requestDebug('request start'); - var debugData = []; - - - function doRequest(requester, reqOpts) { - client._checkAppIdData(); - - var startTime = new Date(); - - if (client._useCache && !client._useRequestCache) { - cacheID = initialOpts.url; - } - - // as we sometime use POST requests to pass parameters (like query='aa'), - // the cacheID must also include the body to be different between calls - if (client._useCache && !client._useRequestCache && body) { - cacheID += '_body_' + reqOpts.body; - } - - // handle cache existence - if (isCacheValidWithCurrentID(!client._useRequestCache, cache, cacheID)) { - requestDebug('serving response from cache'); - - var responseText = cache[cacheID]; - - // Cache response must match the type of the original one - return client._promise.resolve({ - body: JSON.parse(responseText), - responseText: responseText - }); - } - - // if we reached max tries - if (tries >= client.hosts[initialOpts.hostType].length) { - if (!hasFallback || usingFallback) { - requestDebug('could not get any response'); - // then stop - return client._promise.reject(new errors.AlgoliaSearchError( - 'Cannot connect to the AlgoliaSearch API.' + - ' Send an email to support@algolia.com to report and resolve the issue.' + - ' Application id was: ' + client.applicationID, {debugData: debugData} - )); - } - - requestDebug('switching to fallback'); - - // let's try the fallback starting from here - tries = 0; - - // method, url and body are fallback dependent - reqOpts.method = initialOpts.fallback.method; - reqOpts.url = initialOpts.fallback.url; - reqOpts.jsonBody = initialOpts.fallback.body; - if (reqOpts.jsonBody) { - reqOpts.body = safeJSONStringify(reqOpts.jsonBody); - } - // re-compute headers, they could be omitting the API KEY - headers = client._computeRequestHeaders({ - additionalUA: additionalUA, - headers: initialOpts.headers - }); - - reqOpts.timeouts = client._getTimeoutsForRequest(initialOpts.hostType); - client._setHostIndexByType(0, initialOpts.hostType); - usingFallback = true; // the current request is now using fallback - return doRequest(client._request.fallback, reqOpts); - } - - var currentHost = client._getHostByType(initialOpts.hostType); - - var url = currentHost + reqOpts.url; - var options = { - body: reqOpts.body, - jsonBody: reqOpts.jsonBody, - method: reqOpts.method, - headers: headers, - timeouts: reqOpts.timeouts, - debug: requestDebug, - forceAuthHeaders: reqOpts.forceAuthHeaders - }; - - requestDebug('method: %s, url: %s, headers: %j, timeouts: %d', - options.method, url, options.headers, options.timeouts); - - if (requester === client._request.fallback) { - requestDebug('using fallback'); - } - - // `requester` is any of this._request or this._request.fallback - // thus it needs to be called using the client as context - return requester.call(client, url, options).then(success, tryFallback); - - function success(httpResponse) { - // compute the status of the response, - // - // When in browser mode, using XDR or JSONP, we have no statusCode available - // So we rely on our API response `status` property. - // But `waitTask` can set a `status` property which is not the statusCode (it's the task status) - // So we check if there's a `message` along `status` and it means it's an error - // - // That's the only case where we have a response.status that's not the http statusCode - var status = httpResponse && httpResponse.body && httpResponse.body.message && httpResponse.body.status || - - // this is important to check the request statusCode AFTER the body eventual - // statusCode because some implementations (jQuery XDomainRequest transport) may - // send statusCode 200 while we had an error - httpResponse.statusCode || - - // When in browser mode, using XDR or JSONP - // we default to success when no error (no response.status && response.message) - // If there was a JSON.parse() error then body is null and it fails - httpResponse && httpResponse.body && 200; - - requestDebug('received response: statusCode: %s, computed statusCode: %d, headers: %j', - httpResponse.statusCode, status, httpResponse.headers); - - var httpResponseOk = Math.floor(status / 100) === 2; - - var endTime = new Date(); - debugData.push({ - currentHost: currentHost, - headers: removeCredentials(headers), - content: body || null, - contentLength: body !== undefined ? body.length : null, - method: reqOpts.method, - timeouts: reqOpts.timeouts, - url: reqOpts.url, - startTime: startTime, - endTime: endTime, - duration: endTime - startTime, - statusCode: status - }); - - if (httpResponseOk) { - if (client._useCache && !client._useRequestCache && cache) { - cache[cacheID] = httpResponse.responseText; - } - - return { - responseText: httpResponse.responseText, - body: httpResponse.body - }; - } - - var shouldRetry = Math.floor(status / 100) !== 4; - - if (shouldRetry) { - tries += 1; - return retryRequest(); - } - - requestDebug('unrecoverable error'); - - // no success and no retry => fail - var unrecoverableError = new errors.AlgoliaSearchError( - httpResponse.body && httpResponse.body.message, {debugData: debugData, statusCode: status} - ); - - return client._promise.reject(unrecoverableError); - } - - function tryFallback(err) { - // error cases: - // While not in fallback mode: - // - CORS not supported - // - network error - // While in fallback mode: - // - timeout - // - network error - // - badly formatted JSONP (script loaded, did not call our callback) - // In both cases: - // - uncaught exception occurs (TypeError) - requestDebug('error: %s, stack: %s', err.message, err.stack); - - var endTime = new Date(); - debugData.push({ - currentHost: currentHost, - headers: removeCredentials(headers), - content: body || null, - contentLength: body !== undefined ? body.length : null, - method: reqOpts.method, - timeouts: reqOpts.timeouts, - url: reqOpts.url, - startTime: startTime, - endTime: endTime, - duration: endTime - startTime - }); - - if (!(err instanceof errors.AlgoliaSearchError)) { - err = new errors.Unknown(err && err.message, err); - } - - tries += 1; - - // stop the request implementation when: - if ( - // we did not generate this error, - // it comes from a throw in some other piece of code - err instanceof errors.Unknown || - - // server sent unparsable JSON - err instanceof errors.UnparsableJSON || - - // max tries and already using fallback or no fallback - tries >= client.hosts[initialOpts.hostType].length && - (usingFallback || !hasFallback)) { - // stop request implementation for this command - err.debugData = debugData; - return client._promise.reject(err); - } - - // When a timeout occurred, retry by raising timeout - if (err instanceof errors.RequestTimeout) { - return retryRequestWithHigherTimeout(); - } - - return retryRequest(); - } - - function retryRequest() { - requestDebug('retrying request'); - client._incrementHostIndex(initialOpts.hostType); - return doRequest(requester, reqOpts); - } - - function retryRequestWithHigherTimeout() { - requestDebug('retrying request with higher timeout'); - client._incrementHostIndex(initialOpts.hostType); - client._incrementTimeoutMultipler(); - reqOpts.timeouts = client._getTimeoutsForRequest(initialOpts.hostType); - return doRequest(requester, reqOpts); - } - } - - function isCacheValidWithCurrentID( - useRequestCache, - currentCache, - currentCacheID - ) { - return ( - client._useCache && - useRequestCache && - currentCache && - currentCache[currentCacheID] !== undefined - ); - } - - - function interopCallbackReturn(request, callback) { - if (isCacheValidWithCurrentID(client._useRequestCache, cache, cacheID)) { - request.catch(function() { - // Release the cache on error - delete cache[cacheID]; - }); - } - - if (typeof initialOpts.callback === 'function') { - // either we have a callback - request.then(function okCb(content) { - exitPromise(function() { - initialOpts.callback(null, callback(content)); - }, client._setTimeout || setTimeout); - }, function nookCb(err) { - exitPromise(function() { - initialOpts.callback(err); - }, client._setTimeout || setTimeout); - }); - } else { - // either we are using promises - return request.then(callback); - } - } - - if (client._useCache && client._useRequestCache) { - cacheID = initialOpts.url; - } - - // as we sometime use POST requests to pass parameters (like query='aa'), - // the cacheID must also include the body to be different between calls - if (client._useCache && client._useRequestCache && body) { - cacheID += '_body_' + body; - } - - if (isCacheValidWithCurrentID(client._useRequestCache, cache, cacheID)) { - requestDebug('serving request from cache'); - - var maybePromiseForCache = cache[cacheID]; - - // In case the cache is warmup with value that is not a promise - var promiseForCache = typeof maybePromiseForCache.then !== 'function' - ? client._promise.resolve({responseText: maybePromiseForCache}) - : maybePromiseForCache; - - return interopCallbackReturn(promiseForCache, function(content) { - // In case of the cache request, return the original value - return JSON.parse(content.responseText); - }); - } - - var request = doRequest( - client._request, { - url: initialOpts.url, - method: initialOpts.method, - body: body, - jsonBody: initialOpts.body, - timeouts: client._getTimeoutsForRequest(initialOpts.hostType), - forceAuthHeaders: initialOpts.forceAuthHeaders - } - ); - - if (client._useCache && client._useRequestCache && cache) { - cache[cacheID] = request; - } - - return interopCallbackReturn(request, function(content) { - // In case of the first request, return the JSON value - return content.body; - }); -}; - -/* -* Transform search param object in query string -* @param {object} args arguments to add to the current query string -* @param {string} params current query string -* @return {string} the final query string -*/ -AlgoliaSearchCore.prototype._getSearchParams = function(args, params) { - if (args === undefined || args === null) { - return params; - } - for (var key in args) { - if (key !== null && args[key] !== undefined && args.hasOwnProperty(key)) { - params += params === '' ? '' : '&'; - params += key + '=' + encodeURIComponent(Object.prototype.toString.call(args[key]) === '[object Array]' ? safeJSONStringify(args[key]) : args[key]); - } - } - return params; -}; - -/** - * Compute the headers for a request - * - * @param [string] options.additionalUA semi-colon separated string with other user agents to add - * @param [boolean=true] options.withApiKey Send the api key as a header - * @param [Object] options.headers Extra headers to send - */ -AlgoliaSearchCore.prototype._computeRequestHeaders = function(options) { - var forEach = require(5); - - var ua = options.additionalUA ? - this._ua + '; ' + options.additionalUA : - this._ua; - - var requestHeaders = { - 'x-algolia-agent': ua, - 'x-algolia-application-id': this.applicationID - }; - - // browser will inline headers in the url, node.js will use http headers - // but in some situations, the API KEY will be too long (big secured API keys) - // so if the request is a POST and the KEY is very long, we will be asked to not put - // it into headers but in the JSON body - if (options.withApiKey !== false) { - requestHeaders['x-algolia-api-key'] = this.apiKey; - } - - if (this.userToken) { - requestHeaders['x-algolia-usertoken'] = this.userToken; - } - - if (this.securityTags) { - requestHeaders['x-algolia-tagfilters'] = this.securityTags; - } - - forEach(this.extraHeaders, function addToRequestHeaders(value, key) { - requestHeaders[key] = value; - }); - - if (options.headers) { - forEach(options.headers, function addToRequestHeaders(value, key) { - requestHeaders[key] = value; - }); - } - - return requestHeaders; -}; - -/** - * Search through multiple indices at the same time - * @param {Object[]} queries An array of queries you want to run. - * @param {string} queries[].indexName The index name you want to target - * @param {string} [queries[].query] The query to issue on this index. Can also be passed into `params` - * @param {Object} queries[].params Any search param like hitsPerPage, .. - * @param {Function} callback Callback to be called - * @return {Promise|undefined} Returns a promise if no callback given - */ -AlgoliaSearchCore.prototype.search = function(queries, opts, callback) { - var isArray = require(8); - var map = require(33); - - var usage = 'Usage: client.search(arrayOfQueries[, callback])'; - - if (!isArray(queries)) { - throw new Error(usage); - } - - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - var client = this; - - var postObj = { - requests: map(queries, function prepareRequest(query) { - var params = ''; - - // allow query.query - // so we are mimicing the index.search(query, params) method - // {indexName:, query:, params:} - if (query.query !== undefined) { - params += 'query=' + encodeURIComponent(query.query); - } - - return { - indexName: query.indexName, - params: client._getSearchParams(query.params, params) - }; - }) - }; - - var JSONPParams = map(postObj.requests, function prepareJSONPParams(request, requestId) { - return requestId + '=' + - encodeURIComponent( - '/1/indexes/' + encodeURIComponent(request.indexName) + '?' + - request.params - ); - }).join('&'); - - var url = '/1/indexes/*/queries'; - - if (opts.strategy !== undefined) { - postObj.strategy = opts.strategy; - } - - return this._jsonRequest({ - cache: this.cache, - method: 'POST', - url: url, - body: postObj, - hostType: 'read', - fallback: { - method: 'GET', - url: '/1/indexes/*', - body: { - params: JSONPParams - } - }, - callback: callback - }); -}; - -/** -* Search for facet values -* https://www.algolia.com/doc/rest-api/search#search-for-facet-values -* This is the top-level API for SFFV. -* -* @param {object[]} queries An array of queries to run. -* @param {string} queries[].indexName Index name, name of the index to search. -* @param {object} queries[].params Query parameters. -* @param {string} queries[].params.facetName Facet name, name of the attribute to search for values in. -* Must be declared as a facet -* @param {string} queries[].params.facetQuery Query for the facet search -* @param {string} [queries[].params.*] Any search parameter of Algolia, -* see https://www.algolia.com/doc/api-client/javascript/search#search-parameters -* Pagination is not supported. The page and hitsPerPage parameters will be ignored. -*/ -AlgoliaSearchCore.prototype.searchForFacetValues = function(queries) { - var isArray = require(8); - var map = require(33); - - var usage = 'Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])'; // eslint-disable-line max-len - - if (!isArray(queries)) { - throw new Error(usage); - } - - var client = this; - - return client._promise.all(map(queries, function performQuery(query) { - if ( - !query || - query.indexName === undefined || - query.params.facetName === undefined || - query.params.facetQuery === undefined - ) { - throw new Error(usage); - } - - var clone = require(27); - var omit = require(35); - - var indexName = query.indexName; - var params = query.params; - - var facetName = params.facetName; - var filteredParams = omit(clone(params), function(keyName) { - return keyName === 'facetName'; - }); - var searchParameters = client._getSearchParams(filteredParams, ''); - - return client._jsonRequest({ - cache: client.cache, - method: 'POST', - url: - '/1/indexes/' + - encodeURIComponent(indexName) + - '/facets/' + - encodeURIComponent(facetName) + - '/query', - hostType: 'read', - body: {params: searchParameters} - }); - })); -}; - -/** - * Set the extra security tagFilters header - * @param {string|array} tags The list of tags defining the current security filters - */ -AlgoliaSearchCore.prototype.setSecurityTags = function(tags) { - if (Object.prototype.toString.call(tags) === '[object Array]') { - var strTags = []; - for (var i = 0; i < tags.length; ++i) { - if (Object.prototype.toString.call(tags[i]) === '[object Array]') { - var oredTags = []; - for (var j = 0; j < tags[i].length; ++j) { - oredTags.push(tags[i][j]); - } - strTags.push('(' + oredTags.join(',') + ')'); - } else { - strTags.push(tags[i]); - } - } - tags = strTags.join(','); - } - - this.securityTags = tags; -}; - -/** - * Set the extra user token header - * @param {string} userToken The token identifying a uniq user (used to apply rate limits) - */ -AlgoliaSearchCore.prototype.setUserToken = function(userToken) { - this.userToken = userToken; -}; - -/** - * Clear all queries in client's cache - * @return undefined - */ -AlgoliaSearchCore.prototype.clearCache = function() { - this.cache = {}; -}; - -/** -* Set the number of milliseconds a request can take before automatically being terminated. -* @deprecated -* @param {Number} milliseconds -*/ -AlgoliaSearchCore.prototype.setRequestTimeout = function(milliseconds) { - if (milliseconds) { - this._timeouts.connect = this._timeouts.read = this._timeouts.write = milliseconds; - } -}; - -/** -* Set the three different (connect, read, write) timeouts to be used when requesting -* @param {Object} timeouts -*/ -AlgoliaSearchCore.prototype.setTimeouts = function(timeouts) { - this._timeouts = timeouts; -}; - -/** -* Get the three different (connect, read, write) timeouts to be used when requesting -* @param {Object} timeouts -*/ -AlgoliaSearchCore.prototype.getTimeouts = function() { - return this._timeouts; -}; - -AlgoliaSearchCore.prototype._getAppIdData = function() { - var data = store.get(this.applicationID); - if (data !== null) this._cacheAppIdData(data); - return data; -}; - -AlgoliaSearchCore.prototype._setAppIdData = function(data) { - data.lastChange = (new Date()).getTime(); - this._cacheAppIdData(data); - return store.set(this.applicationID, data); -}; - -AlgoliaSearchCore.prototype._checkAppIdData = function() { - var data = this._getAppIdData(); - var now = (new Date()).getTime(); - if (data === null || now - data.lastChange > RESET_APP_DATA_TIMER) { - return this._resetInitialAppIdData(data); - } - - return data; -}; - -AlgoliaSearchCore.prototype._resetInitialAppIdData = function(data) { - var newData = data || {}; - newData.hostIndexes = {read: 0, write: 0}; - newData.timeoutMultiplier = 1; - newData.shuffleResult = newData.shuffleResult || shuffle([1, 2, 3]); - return this._setAppIdData(newData); -}; - -AlgoliaSearchCore.prototype._cacheAppIdData = function(data) { - this._hostIndexes = data.hostIndexes; - this._timeoutMultiplier = data.timeoutMultiplier; - this._shuffleResult = data.shuffleResult; -}; - -AlgoliaSearchCore.prototype._partialAppIdDataUpdate = function(newData) { - var foreach = require(5); - var currentData = this._getAppIdData(); - foreach(newData, function(value, key) { - currentData[key] = value; - }); - - return this._setAppIdData(currentData); -}; - -AlgoliaSearchCore.prototype._getHostByType = function(hostType) { - return this.hosts[hostType][this._getHostIndexByType(hostType)]; -}; - -AlgoliaSearchCore.prototype._getTimeoutMultiplier = function() { - return this._timeoutMultiplier; -}; - -AlgoliaSearchCore.prototype._getHostIndexByType = function(hostType) { - return this._hostIndexes[hostType]; -}; - -AlgoliaSearchCore.prototype._setHostIndexByType = function(hostIndex, hostType) { - var clone = require(27); - var newHostIndexes = clone(this._hostIndexes); - newHostIndexes[hostType] = hostIndex; - this._partialAppIdDataUpdate({hostIndexes: newHostIndexes}); - return hostIndex; -}; - -AlgoliaSearchCore.prototype._incrementHostIndex = function(hostType) { - return this._setHostIndexByType( - (this._getHostIndexByType(hostType) + 1) % this.hosts[hostType].length, hostType - ); -}; - -AlgoliaSearchCore.prototype._incrementTimeoutMultipler = function() { - var timeoutMultiplier = Math.max(this._timeoutMultiplier + 1, 4); - return this._partialAppIdDataUpdate({timeoutMultiplier: timeoutMultiplier}); -}; - -AlgoliaSearchCore.prototype._getTimeoutsForRequest = function(hostType) { - return { - connect: this._timeouts.connect * this._timeoutMultiplier, - complete: this._timeouts[hostType] * this._timeoutMultiplier - }; -}; - -function prepareHost(protocol) { - return function prepare(host) { - return protocol + '//' + host.toLowerCase(); - }; -} - -// Prototype.js < 1.7, a widely used library, defines a weird -// Array.prototype.toJSON function that will fail to stringify our content -// appropriately -// refs: -// - https://groups.google.com/forum/#!topic/prototype-core/E-SAVvV_V9Q -// - https://github.com/sstephenson/prototype/commit/038a2985a70593c1a86c230fadbdfe2e4898a48c -// - http://stackoverflow.com/a/3148441/147079 -function safeJSONStringify(obj) { - /* eslint no-extend-native:0 */ - - if (Array.prototype.toJSON === undefined) { - return JSON.stringify(obj); - } - - var toJSON = Array.prototype.toJSON; - delete Array.prototype.toJSON; - var out = JSON.stringify(obj); - Array.prototype.toJSON = toJSON; - - return out; -} - -function shuffle(array) { - var currentIndex = array.length; - var temporaryValue; - var randomIndex; - - // While there remain elements to shuffle... - while (currentIndex !== 0) { - // Pick a remaining element... - randomIndex = Math.floor(Math.random() * currentIndex); - currentIndex -= 1; - - // And swap it with the current element. - temporaryValue = array[currentIndex]; - array[currentIndex] = array[randomIndex]; - array[randomIndex] = temporaryValue; - } - - return array; -} - -function removeCredentials(headers) { - var newHeaders = {}; - - for (var headerName in headers) { - if (Object.prototype.hasOwnProperty.call(headers, headerName)) { - var value; - - if (headerName === 'x-algolia-api-key' || headerName === 'x-algolia-application-id') { - value = '**hidden for security purposes**'; - } else { - value = headers[headerName]; - } - - newHeaders[headerName] = value; - } - } - - return newHeaders; -} - -}).call(this,require(12)) -},{"1":1,"12":12,"20":20,"27":27,"31":31,"32":32,"33":33,"35":35,"37":37,"5":5,"8":8}],18:[function(require,module,exports){ -var inherits = require(7); -var IndexCore = require(20); -var deprecate = require(29); -var deprecatedMessage = require(30); -var exitPromise = require(32); -var errors = require(31); - -var deprecateForwardToSlaves = deprecate( - function() {}, - deprecatedMessage('forwardToSlaves', 'forwardToReplicas') -); - -module.exports = Index; - -function Index() { - IndexCore.apply(this, arguments); -} - -inherits(Index, IndexCore); - -/* -* Add an object in this index -* -* @param content contains the javascript object to add inside the index -* @param objectID (optional) an objectID you want to attribute to this object -* (if the attribute already exist the old object will be overwrite) -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that contains 3 elements: createAt, taskId and objectID -*/ -Index.prototype.addObject = function(content, objectID, callback) { - var indexObj = this; - - if (arguments.length === 1 || typeof objectID === 'function') { - callback = objectID; - objectID = undefined; - } - - return this.as._jsonRequest({ - method: objectID !== undefined ? - 'PUT' : // update or create - 'POST', // create (API generates an objectID) - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + // create - (objectID !== undefined ? '/' + encodeURIComponent(objectID) : ''), // update or create - body: content, - hostType: 'write', - callback: callback - }); -}; - -/* -* Add several objects -* -* @param objects contains an array of objects to add -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that updateAt and taskID -*/ -Index.prototype.addObjects = function(objects, callback) { - var isArray = require(8); - var usage = 'Usage: index.addObjects(arrayOfObjects[, callback])'; - - if (!isArray(objects)) { - throw new Error(usage); - } - - var indexObj = this; - var postObj = { - requests: [] - }; - for (var i = 0; i < objects.length; ++i) { - var request = { - action: 'addObject', - body: objects[i] - }; - postObj.requests.push(request); - } - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/* -* Update partially an object (only update attributes passed in argument) -* -* @param partialObject contains the javascript attributes to override, the -* object must contains an objectID attribute -* @param createIfNotExists (optional) if false, avoid an automatic creation of the object -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that contains 3 elements: createAt, taskId and objectID -*/ -Index.prototype.partialUpdateObject = function(partialObject, createIfNotExists, callback) { - if (arguments.length === 1 || typeof createIfNotExists === 'function') { - callback = createIfNotExists; - createIfNotExists = undefined; - } - - var indexObj = this; - var url = '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(partialObject.objectID) + '/partial'; - if (createIfNotExists === false) { - url += '?createIfNotExists=false'; - } - - return this.as._jsonRequest({ - method: 'POST', - url: url, - body: partialObject, - hostType: 'write', - callback: callback - }); -}; - -/* -* Partially Override the content of several objects -* -* @param objects contains an array of objects to update (each object must contains a objectID attribute) -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that updateAt and taskID -*/ -Index.prototype.partialUpdateObjects = function(objects, createIfNotExists, callback) { - if (arguments.length === 1 || typeof createIfNotExists === 'function') { - callback = createIfNotExists; - createIfNotExists = true; - } - - var isArray = require(8); - var usage = 'Usage: index.partialUpdateObjects(arrayOfObjects[, callback])'; - - if (!isArray(objects)) { - throw new Error(usage); - } - - var indexObj = this; - var postObj = { - requests: [] - }; - for (var i = 0; i < objects.length; ++i) { - var request = { - action: createIfNotExists === true ? 'partialUpdateObject' : 'partialUpdateObjectNoCreate', - objectID: objects[i].objectID, - body: objects[i] - }; - postObj.requests.push(request); - } - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/* -* Override the content of object -* -* @param object contains the javascript object to save, the object must contains an objectID attribute -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that updateAt and taskID -*/ -Index.prototype.saveObject = function(object, callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'PUT', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(object.objectID), - body: object, - hostType: 'write', - callback: callback - }); -}; - -/* -* Override the content of several objects -* -* @param objects contains an array of objects to update (each object must contains a objectID attribute) -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that updateAt and taskID -*/ -Index.prototype.saveObjects = function(objects, callback) { - var isArray = require(8); - var usage = 'Usage: index.saveObjects(arrayOfObjects[, callback])'; - - if (!isArray(objects)) { - throw new Error(usage); - } - - var indexObj = this; - var postObj = { - requests: [] - }; - for (var i = 0; i < objects.length; ++i) { - var request = { - action: 'updateObject', - objectID: objects[i].objectID, - body: objects[i] - }; - postObj.requests.push(request); - } - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/* -* Delete an object from the index -* -* @param objectID the unique identifier of object to delete -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that contains 3 elements: createAt, taskId and objectID -*/ -Index.prototype.deleteObject = function(objectID, callback) { - if (typeof objectID === 'function' || typeof objectID !== 'string' && typeof objectID !== 'number') { - var err = new errors.AlgoliaSearchError( - objectID && typeof objectID !== 'function' - ? 'ObjectID must be a string' - : 'Cannot delete an object without an objectID' - ); - callback = objectID; - if (typeof callback === 'function') { - return callback(err); - } - - return this.as._promise.reject(err); - } - - var indexObj = this; - return this.as._jsonRequest({ - method: 'DELETE', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID), - hostType: 'write', - callback: callback - }); -}; - -/* -* Delete several objects from an index -* -* @param objectIDs contains an array of objectID to delete -* @param callback (optional) the result callback called with two arguments: -* error: null or Error('message') -* content: the server answer that contains 3 elements: createAt, taskId and objectID -*/ -Index.prototype.deleteObjects = function(objectIDs, callback) { - var isArray = require(8); - var map = require(33); - - var usage = 'Usage: index.deleteObjects(arrayOfObjectIDs[, callback])'; - - if (!isArray(objectIDs)) { - throw new Error(usage); - } - - var indexObj = this; - var postObj = { - requests: map(objectIDs, function prepareRequest(objectID) { - return { - action: 'deleteObject', - objectID: objectID, - body: { - objectID: objectID - } - }; - }) - }; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/batch', - body: postObj, - hostType: 'write', - callback: callback - }); -}; - -/* -* Delete all objects matching a query -* -* @param query the query string -* @param params the optional query parameters -* @param callback (optional) the result callback called with one argument -* error: null or Error('message') -* @deprecated see index.deleteBy -*/ -Index.prototype.deleteByQuery = deprecate(function(query, params, callback) { - var clone = require(27); - var map = require(33); - - var indexObj = this; - var client = indexObj.as; - - if (arguments.length === 1 || typeof params === 'function') { - callback = params; - params = {}; - } else { - params = clone(params); - } - - params.attributesToRetrieve = 'objectID'; - params.hitsPerPage = 1000; - params.distinct = false; - - // when deleting, we should never use cache to get the - // search results - this.clearCache(); - - // there's a problem in how we use the promise chain, - // see how waitTask is done - var promise = this - .search(query, params) - .then(stopOrDelete); - - function stopOrDelete(searchContent) { - // stop here - if (searchContent.nbHits === 0) { - // return indexObj.as._request.resolve(); - return searchContent; - } - - // continue and do a recursive call - var objectIDs = map(searchContent.hits, function getObjectID(object) { - return object.objectID; - }); - - return indexObj - .deleteObjects(objectIDs) - .then(waitTask) - .then(doDeleteByQuery); - } - - function waitTask(deleteObjectsContent) { - return indexObj.waitTask(deleteObjectsContent.taskID); - } - - function doDeleteByQuery() { - return indexObj.deleteByQuery(query, params); - } - - if (!callback) { - return promise; - } - - promise.then(success, failure); - - function success() { - exitPromise(function exit() { - callback(null); - }, client._setTimeout || setTimeout); - } - - function failure(err) { - exitPromise(function exit() { - callback(err); - }, client._setTimeout || setTimeout); - } -}, deprecatedMessage('index.deleteByQuery()', 'index.deleteBy()')); - -/** -* Delete all objects matching a query -* -* the query parameters that can be used are: -* - filters (numeric, facet, tag) -* - geo -* -* you can not send an empty query or filters -* -* @param params the optional query parameters -* @param callback (optional) the result callback called with one argument -* error: null or Error('message') -*/ -Index.prototype.deleteBy = function(params, callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/deleteByQuery', - body: {params: indexObj.as._getSearchParams(params, '')}, - hostType: 'write', - callback: callback - }); -}; - -/* -* Browse all content from an index using events. Basically this will do -* .browse() -> .browseFrom -> .browseFrom -> .. until all the results are returned -* -* @param {string} query - The full text query -* @param {Object} [queryParameters] - Any search query parameter -* @return {EventEmitter} -* @example -* var browser = index.browseAll('cool songs', { -* tagFilters: 'public,comments', -* hitsPerPage: 500 -* }); -* -* browser.on('result', function resultCallback(content) { -* console.log(content.hits); -* }); -* -* // if any error occurs, you get it -* browser.on('error', function(err) { -* throw err; -* }); -* -* // when you have browsed the whole index, you get this event -* browser.on('end', function() { -* console.log('finished'); -* }); -* -* // at any point if you want to stop the browsing process, you can stop it manually -* // otherwise it will go on and on -* browser.stop(); -* -* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} -*/ -Index.prototype.browseAll = function(query, queryParameters) { - if (typeof query === 'object') { - queryParameters = query; - query = undefined; - } - - var merge = require(34); - - var IndexBrowser = require(19); - - var browser = new IndexBrowser(); - var client = this.as; - var index = this; - var params = client._getSearchParams( - merge({}, queryParameters || {}, { - query: query - }), '' - ); - - // start browsing - browseLoop(); - - function browseLoop(cursor) { - if (browser._stopped) { - return; - } - - var body; - - if (cursor !== undefined) { - body = { - cursor: cursor - }; - } else { - body = { - params: params - }; - } - - client._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(index.indexName) + '/browse', - hostType: 'read', - body: body, - callback: browseCallback - }); - } - - function browseCallback(err, content) { - if (browser._stopped) { - return; - } - - if (err) { - browser._error(err); - return; - } - - browser._result(content); - - // no cursor means we are finished browsing - if (content.cursor === undefined) { - browser._end(); - return; - } - - browseLoop(content.cursor); - } - - return browser; -}; - -/* -* Get a Typeahead.js adapter -* @param searchParams contains an object with query parameters (see search for details) -*/ -Index.prototype.ttAdapter = deprecate(function(params) { - var self = this; - return function ttAdapter(query, syncCb, asyncCb) { - var cb; - - if (typeof asyncCb === 'function') { - // typeahead 0.11 - cb = asyncCb; - } else { - // pre typeahead 0.11 - cb = syncCb; - } - - self.search(query, params, function searchDone(err, content) { - if (err) { - cb(err); - return; - } - - cb(content.hits); - }); - }; -}, -'ttAdapter is not necessary anymore and will be removed in the next version,\n' + -'have a look at autocomplete.js (https://github.com/algolia/autocomplete.js)'); - -/* -* Wait the publication of a task on the server. -* All server task are asynchronous and you can check with this method that the task is published. -* -* @param taskID the id of the task returned by server -* @param callback the result callback with with two arguments: -* error: null or Error('message') -* content: the server answer that contains the list of results -*/ -Index.prototype.waitTask = function(taskID, callback) { - // wait minimum 100ms before retrying - var baseDelay = 100; - // wait maximum 5s before retrying - var maxDelay = 5000; - var loop = 0; - - // waitTask() must be handled differently from other methods, - // it's a recursive method using a timeout - var indexObj = this; - var client = indexObj.as; - - var promise = retryLoop(); - - function retryLoop() { - return client._jsonRequest({ - method: 'GET', - hostType: 'read', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/task/' + taskID - }).then(function success(content) { - loop++; - var delay = baseDelay * loop * loop; - if (delay > maxDelay) { - delay = maxDelay; - } - - if (content.status !== 'published') { - return client._promise.delay(delay).then(retryLoop); - } - - return content; - }); - } - - if (!callback) { - return promise; - } - - promise.then(successCb, failureCb); - - function successCb(content) { - exitPromise(function exit() { - callback(null, content); - }, client._setTimeout || setTimeout); - } - - function failureCb(err) { - exitPromise(function exit() { - callback(err); - }, client._setTimeout || setTimeout); - } -}; - -/* -* This function deletes the index content. Settings and index specific API keys are kept untouched. -* -* @param callback (optional) the result callback called with two arguments -* error: null or Error('message') -* content: the settings object or the error message if a failure occurred -*/ -Index.prototype.clearIndex = function(callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/clear', - hostType: 'write', - callback: callback - }); -}; - -/* -* Get settings of this index -* -* @param opts an object of options to add -* @param opts.advanced get more settings like nbShards (useful for Enterprise) -* @param callback (optional) the result callback called with two arguments -* error: null or Error('message') -* content: the settings object or the error message if a failure occurred -*/ -Index.prototype.getSettings = function(opts, callback) { - if (arguments.length === 1 && typeof opts === 'function') { - callback = opts; - opts = {}; - } - opts = opts || {}; - - var indexName = encodeURIComponent(this.indexName); - return this.as._jsonRequest({ - method: 'GET', - url: - '/1/indexes/' + - indexName + - '/settings?getVersion=2' + - (opts.advanced ? '&advanced=' + opts.advanced : ''), - hostType: 'read', - callback: callback - }); -}; - -Index.prototype.searchSynonyms = function(params, callback) { - if (typeof params === 'function') { - callback = params; - params = {}; - } else if (params === undefined) { - params = {}; - } - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/search', - body: params, - hostType: 'read', - callback: callback - }); -}; - -function exportData(method, _hitsPerPage, callback) { - function search(page, _previous) { - var options = { - page: page || 0, - hitsPerPage: _hitsPerPage || 100 - }; - var previous = _previous || []; - - return method(options).then(function(result) { - var hits = result.hits; - var nbHits = result.nbHits; - var current = hits.map(function(s) { - delete s._highlightResult; - return s; - }); - var synonyms = previous.concat(current); - if (synonyms.length < nbHits) { - return search(options.page + 1, synonyms); - } - return synonyms; - }); - } - return search().then(function(data) { - if (typeof callback === 'function') { - callback(data); - return undefined; - } - return data; - }); -} - -/** - * Retrieve all the synonyms in an index - * @param [number=100] hitsPerPage The amount of synonyms to retrieve per batch - * @param [function] callback will be called after all synonyms are retrieved - */ -Index.prototype.exportSynonyms = function(hitsPerPage, callback) { - return exportData(this.searchSynonyms.bind(this), hitsPerPage, callback); -}; - -Index.prototype.saveSynonym = function(synonym, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); - var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'PUT', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(synonym.objectID) + - '?forwardToReplicas=' + forwardToReplicas, - body: synonym, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.getSynonym = function(objectID, callback) { - return this.as._jsonRequest({ - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(objectID), - hostType: 'read', - callback: callback - }); -}; - -Index.prototype.deleteSynonym = function(objectID, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); - var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'DELETE', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/' + encodeURIComponent(objectID) + - '?forwardToReplicas=' + forwardToReplicas, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.clearSynonyms = function(opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); - var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/clear' + - '?forwardToReplicas=' + forwardToReplicas, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.batchSynonyms = function(synonyms, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); - var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/synonyms/batch' + - '?forwardToReplicas=' + forwardToReplicas + - '&replaceExistingSynonyms=' + (opts.replaceExistingSynonyms ? 'true' : 'false'), - hostType: 'write', - body: synonyms, - callback: callback - }); -}; - -Index.prototype.searchRules = function(params, callback) { - if (typeof params === 'function') { - callback = params; - params = {}; - } else if (params === undefined) { - params = {}; - } - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/search', - body: params, - hostType: 'read', - callback: callback - }); -}; -/** - * Retrieve all the query rules in an index - * @param [number=100] hitsPerPage The amount of query rules to retrieve per batch - * @param [function] callback will be called after all query rules are retrieved - * error: null or Error('message') - */ -Index.prototype.exportRules = function(hitsPerPage, callback) { - return exportData(this.searchRules.bind(this), hitsPerPage, callback); -}; - -Index.prototype.saveRule = function(rule, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - if (!rule.objectID) { - throw new errors.AlgoliaSearchError('Missing or empty objectID field for rule'); - } - - var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'PUT', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(rule.objectID) + - '?forwardToReplicas=' + forwardToReplicas, - body: rule, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.getRule = function(objectID, callback) { - return this.as._jsonRequest({ - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(objectID), - hostType: 'read', - callback: callback - }); -}; - -Index.prototype.deleteRule = function(objectID, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'DELETE', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/' + encodeURIComponent(objectID) + - '?forwardToReplicas=' + forwardToReplicas, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.clearRules = function(opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/clear' + - '?forwardToReplicas=' + forwardToReplicas, - hostType: 'write', - callback: callback - }); -}; - -Index.prototype.batchRules = function(rules, opts, callback) { - if (typeof opts === 'function') { - callback = opts; - opts = {}; - } else if (opts === undefined) { - opts = {}; - } - - var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false'; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/rules/batch' + - '?forwardToReplicas=' + forwardToReplicas + - '&clearExistingRules=' + (opts.clearExistingRules === true ? 'true' : 'false'), - hostType: 'write', - body: rules, - callback: callback - }); -}; - -Index.prototype.exists = function(callback) { - var result = this.getSettings().then(function() { - return true; - }).catch(function(err) { - if (err instanceof errors.AlgoliaSearchError && err.statusCode === 404) { - return false; - } - - throw err; - }); - - if (typeof callback !== 'function') { - return result; - } - - result.then(function(res) { - callback(null, res); - }).catch(function(err) { - callback(err); - }); -}; - -Index.prototype.findObject = function(findCallback, requestOptions, callback) { - requestOptions = requestOptions === undefined ? {} : requestOptions; - var paginate = requestOptions.paginate !== undefined ? requestOptions.paginate : true; - var query = requestOptions.query !== undefined ? requestOptions.query : ''; - - var that = this; - var page = 0; - - var paginateLoop = function() { - requestOptions.page = page; - - return that.search(query, requestOptions).then(function(result) { - var hits = result.hits; - - for (var position = 0; position < hits.length; position++) { - var hit = hits[position]; - if (findCallback(hit)) { - return { - object: hit, - position: position, - page: page - }; - } - } - - page += 1; - - // paginate if option was set and has next page - if (!paginate || page >= result.nbPages) { - throw new errors.ObjectNotFound('Object not found'); - } - - return paginateLoop(); - }); - }; - - var promise = paginateLoop(page); - - if (callback === undefined) { - return promise; - } - - promise - .then(function(res) { - callback(null, res); - }) - .catch(function(err) { - callback(err); - }); -}; - -Index.prototype.getObjectPosition = function(result, objectID) { - var hits = result.hits; - - for (var position = 0; position < hits.length; position++) { - if (hits[position].objectID === objectID) { - return position; - } - } - - return -1; -}; - -/* -* Set settings for this index -* -* @param settings the settings object that can contains : -* - minWordSizefor1Typo: (integer) the minimum number of characters to accept one typo (default = 3). -* - minWordSizefor2Typos: (integer) the minimum number of characters to accept two typos (default = 7). -* - hitsPerPage: (integer) the number of hits per page (default = 10). -* - attributesToRetrieve: (array of strings) default list of attributes to retrieve in objects. -* If set to null, all attributes are retrieved. -* - attributesToHighlight: (array of strings) default list of attributes to highlight. -* If set to null, all indexed attributes are highlighted. -* - attributesToSnippet**: (array of strings) default list of attributes to snippet alongside the number -* of words to return (syntax is attributeName:nbWords). -* By default no snippet is computed. If set to null, no snippet is computed. -* - attributesToIndex: (array of strings) the list of fields you want to index. -* If set to null, all textual and numerical attributes of your objects are indexed, -* but you should update it to get optimal results. -* This parameter has two important uses: -* - Limit the attributes to index: For example if you store a binary image in base64, -* you want to store it and be able to -* retrieve it but you don't want to search in the base64 string. -* - Control part of the ranking*: (see the ranking parameter for full explanation) -* Matches in attributes at the beginning of -* the list will be considered more important than matches in attributes further down the list. -* In one attribute, matching text at the beginning of the attribute will be -* considered more important than text after, you can disable -* this behavior if you add your attribute inside `unordered(AttributeName)`, -* for example attributesToIndex: ["title", "unordered(text)"]. -* - attributesForFaceting: (array of strings) The list of fields you want to use for faceting. -* All strings in the attribute selected for faceting are extracted and added as a facet. -* If set to null, no attribute is used for faceting. -* - attributeForDistinct: (string) The attribute name used for the Distinct feature. -* This feature is similar to the SQL "distinct" keyword: when enabled -* in query with the distinct=1 parameter, all hits containing a duplicate -* value for this attribute are removed from results. -* For example, if the chosen attribute is show_name and several hits have -* the same value for show_name, then only the best one is kept and others are removed. -* - ranking: (array of strings) controls the way results are sorted. -* We have six available criteria: -* - typo: sort according to number of typos, -* - geo: sort according to decreassing distance when performing a geo-location based search, -* - proximity: sort according to the proximity of query words in hits, -* - attribute: sort according to the order of attributes defined by attributesToIndex, -* - exact: -* - if the user query contains one word: sort objects having an attribute -* that is exactly the query word before others. -* For example if you search for the "V" TV show, you want to find it -* with the "V" query and avoid to have all popular TV -* show starting by the v letter before it. -* - if the user query contains multiple words: sort according to the -* number of words that matched exactly (and not as a prefix). -* - custom: sort according to a user defined formula set in **customRanking** attribute. -* The standard order is ["typo", "geo", "proximity", "attribute", "exact", "custom"] -* - customRanking: (array of strings) lets you specify part of the ranking. -* The syntax of this condition is an array of strings containing attributes -* prefixed by asc (ascending order) or desc (descending order) operator. -* For example `"customRanking" => ["desc(population)", "asc(name)"]` -* - queryType: Select how the query words are interpreted, it can be one of the following value: -* - prefixAll: all query words are interpreted as prefixes, -* - prefixLast: only the last word is interpreted as a prefix (default behavior), -* - prefixNone: no query word is interpreted as a prefix. This option is not recommended. -* - highlightPreTag: (string) Specify the string that is inserted before -* the highlighted parts in the query result (default to ""). -* - highlightPostTag: (string) Specify the string that is inserted after -* the highlighted parts in the query result (default to ""). -* - optionalWords: (array of strings) Specify a list of words that should -* be considered as optional when found in the query. -* @param callback (optional) the result callback called with two arguments -* error: null or Error('message') -* content: the server answer or the error message if a failure occurred -*/ -Index.prototype.setSettings = function(settings, opts, callback) { - if (arguments.length === 1 || typeof opts === 'function') { - callback = opts; - opts = {}; - } - - if (opts.forwardToSlaves !== undefined) deprecateForwardToSlaves(); - var forwardToReplicas = (opts.forwardToSlaves || opts.forwardToReplicas) ? 'true' : 'false'; - - var indexObj = this; - return this.as._jsonRequest({ - method: 'PUT', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/settings?forwardToReplicas=' - + forwardToReplicas, - hostType: 'write', - body: settings, - callback: callback - }); -}; - -/* -* @deprecated see client.listApiKeys() -*/ -Index.prototype.listUserKeys = deprecate(function(callback) { - return this.listApiKeys(callback); -}, deprecatedMessage('index.listUserKeys()', 'client.listApiKeys()')); - -/* -* List all existing API keys to this index -* -* @param callback the result callback called with two arguments -* error: null or Error('message') -* content: the server answer with API keys belonging to the index -* -* @deprecated see client.listApiKeys() -*/ -Index.prototype.listApiKeys = deprecate(function(callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys', - hostType: 'read', - callback: callback - }); -}, deprecatedMessage('index.listApiKeys()', 'client.listApiKeys()')); - -/* -* @deprecated see client.getApiKey() -*/ -Index.prototype.getUserKeyACL = deprecate(function(key, callback) { - return this.getApiKey(key, callback); -}, deprecatedMessage('index.getUserKeyACL()', 'client.getApiKey()')); - - -/* -* Get an API key from this index -* -* @param key -* @param callback the result callback called with two arguments -* error: null or Error('message') -* content: the server answer with the right API key -* -* @deprecated see client.getApiKey() -*/ -Index.prototype.getApiKey = deprecate(function(key, callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key, - hostType: 'read', - callback: callback - }); -}, deprecatedMessage('index.getApiKey()', 'client.getApiKey()')); - -/* -* @deprecated see client.deleteApiKey() -*/ -Index.prototype.deleteUserKey = deprecate(function(key, callback) { - return this.deleteApiKey(key, callback); -}, deprecatedMessage('index.deleteUserKey()', 'client.deleteApiKey()')); - -/* -* Delete an existing API key associated to this index -* -* @param key -* @param callback the result callback called with two arguments -* error: null or Error('message') -* content: the server answer with the deletion date -* -* @deprecated see client.deleteApiKey() -*/ -Index.prototype.deleteApiKey = deprecate(function(key, callback) { - var indexObj = this; - return this.as._jsonRequest({ - method: 'DELETE', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/keys/' + key, - hostType: 'write', - callback: callback - }); -}, deprecatedMessage('index.deleteApiKey()', 'client.deleteApiKey()')); - -/* -* @deprecated see client.addApiKey() -*/ -Index.prototype.addUserKey = deprecate(function(acls, params, callback) { - return this.addApiKey(acls, params, callback); -}, deprecatedMessage('index.addUserKey()', 'client.addApiKey()')); - -/* -* Add a new API key to this index -* -* @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that -* can contains the following values: -* - search: allow to search (https and http) -* - addObject: allows to add/update an object in the index (https only) -* - deleteObject : allows to delete an existing object (https only) -* - deleteIndex : allows to delete index content (https only) -* - settings : allows to get index settings (https only) -* - editSettings : allows to change index settings (https only) -* @param {Object} [params] - Optionnal parameters to set for the key -* @param {number} params.validity - Number of seconds after which the key will -* be automatically removed (0 means no time limit for this key) -* @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour -* @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call -* @param {string} params.description - A description for your key -* @param {string[]} params.referers - A list of authorized referers -* @param {Object} params.queryParameters - Force the key to use specific query parameters -* @param {Function} callback - The result callback called with two arguments -* error: null or Error('message') -* content: the server answer with the added API key -* @return {Promise|undefined} Returns a promise if no callback given -* @example -* index.addUserKey(['search'], { -* validity: 300, -* maxQueriesPerIPPerHour: 2000, -* maxHitsPerQuery: 3, -* description: 'Eat three fruits', -* referers: ['*.algolia.com'], -* queryParameters: { -* tagFilters: ['public'], -* } -* }) -* @see {@link https://www.algolia.com/doc/rest_api#AddIndexKey|Algolia REST API Documentation} -* -* @deprecated see client.addApiKey() -*/ -Index.prototype.addApiKey = deprecate(function(acls, params, callback) { - var isArray = require(8); - var usage = 'Usage: index.addApiKey(arrayOfAcls[, params, callback])'; - - if (!isArray(acls)) { - throw new Error(usage); - } - - if (arguments.length === 1 || typeof params === 'function') { - callback = params; - params = null; - } - - var postObj = { - acl: acls - }; - - if (params) { - postObj.validity = params.validity; - postObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; - postObj.maxHitsPerQuery = params.maxHitsPerQuery; - postObj.description = params.description; - - if (params.queryParameters) { - postObj.queryParameters = this.as._getSearchParams(params.queryParameters, ''); - } - - postObj.referers = params.referers; - } - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys', - body: postObj, - hostType: 'write', - callback: callback - }); -}, deprecatedMessage('index.addApiKey()', 'client.addApiKey()')); - -/** -* @deprecated use client.addApiKey() -*/ -Index.prototype.addUserKeyWithValidity = deprecate(function deprecatedAddUserKeyWithValidity(acls, params, callback) { - return this.addApiKey(acls, params, callback); -}, deprecatedMessage('index.addUserKeyWithValidity()', 'client.addApiKey()')); - -/* -* @deprecated see client.updateApiKey() -*/ -Index.prototype.updateUserKey = deprecate(function(key, acls, params, callback) { - return this.updateApiKey(key, acls, params, callback); -}, deprecatedMessage('index.updateUserKey()', 'client.updateApiKey()')); - -/** -* Update an existing API key of this index -* @param {string} key - The key to update -* @param {string[]} acls - The list of ACL for this key. Defined by an array of strings that -* can contains the following values: -* - search: allow to search (https and http) -* - addObject: allows to add/update an object in the index (https only) -* - deleteObject : allows to delete an existing object (https only) -* - deleteIndex : allows to delete index content (https only) -* - settings : allows to get index settings (https only) -* - editSettings : allows to change index settings (https only) -* @param {Object} [params] - Optionnal parameters to set for the key -* @param {number} params.validity - Number of seconds after which the key will -* be automatically removed (0 means no time limit for this key) -* @param {number} params.maxQueriesPerIPPerHour - Number of API calls allowed from an IP address per hour -* @param {number} params.maxHitsPerQuery - Number of hits this API key can retrieve in one call -* @param {string} params.description - A description for your key -* @param {string[]} params.referers - A list of authorized referers -* @param {Object} params.queryParameters - Force the key to use specific query parameters -* @param {Function} callback - The result callback called with two arguments -* error: null or Error('message') -* content: the server answer with user keys list -* @return {Promise|undefined} Returns a promise if no callback given -* @example -* index.updateApiKey('APIKEY', ['search'], { -* validity: 300, -* maxQueriesPerIPPerHour: 2000, -* maxHitsPerQuery: 3, -* description: 'Eat three fruits', -* referers: ['*.algolia.com'], -* queryParameters: { -* tagFilters: ['public'], -* } -* }) -* @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation} -* -* @deprecated see client.updateApiKey() -*/ -Index.prototype.updateApiKey = deprecate(function(key, acls, params, callback) { - var isArray = require(8); - var usage = 'Usage: index.updateApiKey(key, arrayOfAcls[, params, callback])'; - - if (!isArray(acls)) { - throw new Error(usage); - } - - if (arguments.length === 2 || typeof params === 'function') { - callback = params; - params = null; - } - - var putObj = { - acl: acls - }; - - if (params) { - putObj.validity = params.validity; - putObj.maxQueriesPerIPPerHour = params.maxQueriesPerIPPerHour; - putObj.maxHitsPerQuery = params.maxHitsPerQuery; - putObj.description = params.description; - - if (params.queryParameters) { - putObj.queryParameters = this.as._getSearchParams(params.queryParameters, ''); - } - - putObj.referers = params.referers; - } - - return this.as._jsonRequest({ - method: 'PUT', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/keys/' + key, - body: putObj, - hostType: 'write', - callback: callback - }); -}, deprecatedMessage('index.updateApiKey()', 'client.updateApiKey()')); - -},{"19":19,"20":20,"27":27,"29":29,"30":30,"31":31,"32":32,"33":33,"34":34,"7":7,"8":8}],19:[function(require,module,exports){ -'use strict'; - -// This is the object returned by the `index.browseAll()` method - -module.exports = IndexBrowser; - -var inherits = require(7); -var EventEmitter = require(4).EventEmitter; - -function IndexBrowser() { -} - -inherits(IndexBrowser, EventEmitter); - -IndexBrowser.prototype.stop = function() { - this._stopped = true; - this._clean(); -}; - -IndexBrowser.prototype._end = function() { - this.emit('end'); - this._clean(); -}; - -IndexBrowser.prototype._error = function(err) { - this.emit('error', err); - this._clean(); -}; - -IndexBrowser.prototype._result = function(content) { - this.emit('result', content); -}; - -IndexBrowser.prototype._clean = function() { - this.removeAllListeners('stop'); - this.removeAllListeners('end'); - this.removeAllListeners('error'); - this.removeAllListeners('result'); -}; - -},{"4":4,"7":7}],20:[function(require,module,exports){ -var buildSearchMethod = require(26); -var deprecate = require(29); -var deprecatedMessage = require(30); - -module.exports = IndexCore; - -/* -* Index class constructor. -* You should not use this method directly but use initIndex() function -*/ -function IndexCore(algoliasearch, indexName) { - this.indexName = indexName; - this.as = algoliasearch; - this.typeAheadArgs = null; - this.typeAheadValueOption = null; - - // make sure every index instance has it's own cache - this.cache = {}; -} - -/* -* Clear all queries in cache -*/ -IndexCore.prototype.clearCache = function() { - this.cache = {}; -}; - -/* -* Search inside the index using XMLHttpRequest request (Using a POST query to -* minimize number of OPTIONS queries: Cross-Origin Resource Sharing). -* -* @param {string} [query] the full text query -* @param {object} [args] (optional) if set, contains an object with query parameters: -* - page: (integer) Pagination parameter used to select the page to retrieve. -* Page is zero-based and defaults to 0. Thus, -* to retrieve the 10th page you need to set page=9 -* - hitsPerPage: (integer) Pagination parameter used to select the number of hits per page. Defaults to 20. -* - attributesToRetrieve: a string that contains the list of object attributes -* you want to retrieve (let you minimize the answer size). -* Attributes are separated with a comma (for example "name,address"). -* You can also use an array (for example ["name","address"]). -* By default, all attributes are retrieved. You can also use '*' to retrieve all -* values when an attributesToRetrieve setting is specified for your index. -* - attributesToHighlight: a string that contains the list of attributes you -* want to highlight according to the query. -* Attributes are separated by a comma. You can also use an array (for example ["name","address"]). -* If an attribute has no match for the query, the raw value is returned. -* By default all indexed text attributes are highlighted. -* You can use `*` if you want to highlight all textual attributes. -* Numerical attributes are not highlighted. -* A matchLevel is returned for each highlighted attribute and can contain: -* - full: if all the query terms were found in the attribute, -* - partial: if only some of the query terms were found, -* - none: if none of the query terms were found. -* - attributesToSnippet: a string that contains the list of attributes to snippet alongside -* the number of words to return (syntax is `attributeName:nbWords`). -* Attributes are separated by a comma (Example: attributesToSnippet=name:10,content:10). -* You can also use an array (Example: attributesToSnippet: ['name:10','content:10']). -* By default no snippet is computed. -* - minWordSizefor1Typo: the minimum number of characters in a query word to accept one typo in this word. -* Defaults to 3. -* - minWordSizefor2Typos: the minimum number of characters in a query word -* to accept two typos in this word. Defaults to 7. -* - getRankingInfo: if set to 1, the result hits will contain ranking -* information in _rankingInfo attribute. -* - aroundLatLng: search for entries around a given -* latitude/longitude (specified as two floats separated by a comma). -* For example aroundLatLng=47.316669,5.016670). -* You can specify the maximum distance in meters with the aroundRadius parameter (in meters) -* and the precision for ranking with aroundPrecision -* (for example if you set aroundPrecision=100, two objects that are distant of -* less than 100m will be considered as identical for "geo" ranking parameter). -* At indexing, you should specify geoloc of an object with the _geoloc attribute -* (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}}) -* - insideBoundingBox: search entries inside a given area defined by the two extreme points -* of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng). -* For example insideBoundingBox=47.3165,4.9665,47.3424,5.0201). -* At indexing, you should specify geoloc of an object with the _geoloc attribute -* (in the form {"_geoloc":{"lat":48.853409, "lng":2.348800}}) -* - numericFilters: a string that contains the list of numeric filters you want to -* apply separated by a comma. -* The syntax of one filter is `attributeName` followed by `operand` followed by `value`. -* Supported operands are `<`, `<=`, `=`, `>` and `>=`. -* You can have multiple conditions on one attribute like for example numericFilters=price>100,price<1000. -* You can also use an array (for example numericFilters: ["price>100","price<1000"]). -* - tagFilters: filter the query by a set of tags. You can AND tags by separating them by commas. -* To OR tags, you must add parentheses. For example, tags=tag1,(tag2,tag3) means tag1 AND (tag2 OR tag3). -* You can also use an array, for example tagFilters: ["tag1",["tag2","tag3"]] -* means tag1 AND (tag2 OR tag3). -* At indexing, tags should be added in the _tags** attribute -* of objects (for example {"_tags":["tag1","tag2"]}). -* - facetFilters: filter the query by a list of facets. -* Facets are separated by commas and each facet is encoded as `attributeName:value`. -* For example: `facetFilters=category:Book,author:John%20Doe`. -* You can also use an array (for example `["category:Book","author:John%20Doe"]`). -* - facets: List of object attributes that you want to use for faceting. -* Comma separated list: `"category,author"` or array `['category','author']` -* Only attributes that have been added in **attributesForFaceting** index setting -* can be used in this parameter. -* You can also use `*` to perform faceting on all attributes specified in **attributesForFaceting**. -* - queryType: select how the query words are interpreted, it can be one of the following value: -* - prefixAll: all query words are interpreted as prefixes, -* - prefixLast: only the last word is interpreted as a prefix (default behavior), -* - prefixNone: no query word is interpreted as a prefix. This option is not recommended. -* - optionalWords: a string that contains the list of words that should -* be considered as optional when found in the query. -* Comma separated and array are accepted. -* - distinct: If set to 1, enable the distinct feature (disabled by default) -* if the attributeForDistinct index setting is set. -* This feature is similar to the SQL "distinct" keyword: when enabled -* in a query with the distinct=1 parameter, -* all hits containing a duplicate value for the attributeForDistinct attribute are removed from results. -* For example, if the chosen attribute is show_name and several hits have -* the same value for show_name, then only the best -* one is kept and others are removed. -* - restrictSearchableAttributes: List of attributes you want to use for -* textual search (must be a subset of the attributesToIndex index setting) -* either comma separated or as an array -* @param {function} [callback] the result callback called with two arguments: -* error: null or Error('message'). If false, the content contains the error. -* content: the server answer that contains the list of results. -*/ -IndexCore.prototype.search = buildSearchMethod('query'); - -/* -* -- BETA -- -* Search a record similar to the query inside the index using XMLHttpRequest request (Using a POST query to -* minimize number of OPTIONS queries: Cross-Origin Resource Sharing). -* -* @param {string} [query] the similar query -* @param {object} [args] (optional) if set, contains an object with query parameters. -* All search parameters are supported (see search function), restrictSearchableAttributes and facetFilters -* are the two most useful to restrict the similar results and get more relevant content -*/ -IndexCore.prototype.similarSearch = deprecate( - buildSearchMethod('similarQuery'), - deprecatedMessage( - 'index.similarSearch(query[, callback])', - 'index.search({ similarQuery: query }[, callback])' - ) -); - -/* -* Browse index content. The response content will have a `cursor` property that you can use -* to browse subsequent pages for this query. Use `index.browseFrom(cursor)` when you want. -* -* @param {string} query - The full text query -* @param {Object} [queryParameters] - Any search query parameter -* @param {Function} [callback] - The result callback called with two arguments -* error: null or Error('message') -* content: the server answer with the browse result -* @return {Promise|undefined} Returns a promise if no callback given -* @example -* index.browse('cool songs', { -* tagFilters: 'public,comments', -* hitsPerPage: 500 -* }, callback); -* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} -*/ -IndexCore.prototype.browse = function(query, queryParameters, callback) { - var merge = require(34); - - var indexObj = this; - - var page; - var hitsPerPage; - - // we check variadic calls that are not the one defined - // .browse()/.browse(fn) - // => page = 0 - if (arguments.length === 0 || arguments.length === 1 && typeof arguments[0] === 'function') { - page = 0; - callback = arguments[0]; - query = undefined; - } else if (typeof arguments[0] === 'number') { - // .browse(2)/.browse(2, 10)/.browse(2, fn)/.browse(2, 10, fn) - page = arguments[0]; - if (typeof arguments[1] === 'number') { - hitsPerPage = arguments[1]; - } else if (typeof arguments[1] === 'function') { - callback = arguments[1]; - hitsPerPage = undefined; - } - query = undefined; - queryParameters = undefined; - } else if (typeof arguments[0] === 'object') { - // .browse(queryParameters)/.browse(queryParameters, cb) - if (typeof arguments[1] === 'function') { - callback = arguments[1]; - } - queryParameters = arguments[0]; - query = undefined; - } else if (typeof arguments[0] === 'string' && typeof arguments[1] === 'function') { - // .browse(query, cb) - callback = arguments[1]; - queryParameters = undefined; - } - - // otherwise it's a .browse(query)/.browse(query, queryParameters)/.browse(query, queryParameters, cb) - - // get search query parameters combining various possible calls - // to .browse(); - queryParameters = merge({}, queryParameters || {}, { - page: page, - hitsPerPage: hitsPerPage, - query: query - }); - - var params = this.as._getSearchParams(queryParameters, ''); - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/browse', - body: {params: params}, - hostType: 'read', - callback: callback - }); -}; - -/* -* Continue browsing from a previous position (cursor), obtained via a call to `.browse()`. -* -* @param {string} query - The full text query -* @param {Object} [queryParameters] - Any search query parameter -* @param {Function} [callback] - The result callback called with two arguments -* error: null or Error('message') -* content: the server answer with the browse result -* @return {Promise|undefined} Returns a promise if no callback given -* @example -* index.browseFrom('14lkfsakl32', callback); -* @see {@link https://www.algolia.com/doc/rest_api#Browse|Algolia REST API Documentation} -*/ -IndexCore.prototype.browseFrom = function(cursor, callback) { - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + encodeURIComponent(this.indexName) + '/browse', - body: {cursor: cursor}, - hostType: 'read', - callback: callback - }); -}; - -/* -* Search for facet values -* https://www.algolia.com/doc/rest-api/search#search-for-facet-values -* -* @param {string} params.facetName Facet name, name of the attribute to search for values in. -* Must be declared as a facet -* @param {string} params.facetQuery Query for the facet search -* @param {string} [params.*] Any search parameter of Algolia, -* see https://www.algolia.com/doc/api-client/javascript/search#search-parameters -* Pagination is not supported. The page and hitsPerPage parameters will be ignored. -* @param callback (optional) -*/ -IndexCore.prototype.searchForFacetValues = function(params, callback) { - var clone = require(27); - var omit = require(35); - var usage = 'Usage: index.searchForFacetValues({facetName, facetQuery, ...params}[, callback])'; - - if (params.facetName === undefined || params.facetQuery === undefined) { - throw new Error(usage); - } - - var facetName = params.facetName; - var filteredParams = omit(clone(params), function(keyName) { - return keyName === 'facetName'; - }); - var searchParameters = this.as._getSearchParams(filteredParams, ''); - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/' + - encodeURIComponent(this.indexName) + '/facets/' + encodeURIComponent(facetName) + '/query', - hostType: 'read', - body: {params: searchParameters}, - callback: callback - }); -}; - -IndexCore.prototype.searchFacet = deprecate(function(params, callback) { - return this.searchForFacetValues(params, callback); -}, deprecatedMessage( - 'index.searchFacet(params[, callback])', - 'index.searchForFacetValues(params[, callback])' -)); - -IndexCore.prototype._search = function(params, url, callback, additionalUA) { - return this.as._jsonRequest({ - cache: this.cache, - method: 'POST', - url: url || '/1/indexes/' + encodeURIComponent(this.indexName) + '/query', - body: {params: params}, - hostType: 'read', - fallback: { - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(this.indexName), - body: {params: params} - }, - callback: callback, - additionalUA: additionalUA - }); -}; - -/* -* Get an object from this index -* -* @param objectID the unique identifier of the object to retrieve -* @param attrs (optional) if set, contains the array of attribute names to retrieve -* @param callback (optional) the result callback called with two arguments -* error: null or Error('message') -* content: the object to retrieve or the error message if a failure occurred -*/ -IndexCore.prototype.getObject = function(objectID, attrs, callback) { - var indexObj = this; - - if (arguments.length === 1 || typeof attrs === 'function') { - callback = attrs; - attrs = undefined; - } - - var params = ''; - if (attrs !== undefined) { - params = '?attributes='; - for (var i = 0; i < attrs.length; ++i) { - if (i !== 0) { - params += ','; - } - params += attrs[i]; - } - } - - return this.as._jsonRequest({ - method: 'GET', - url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/' + encodeURIComponent(objectID) + params, - hostType: 'read', - callback: callback - }); -}; - -/* -* Get several objects from this index -* -* @param objectIDs the array of unique identifier of objects to retrieve -*/ -IndexCore.prototype.getObjects = function(objectIDs, attributesToRetrieve, callback) { - var isArray = require(8); - var map = require(33); - - var usage = 'Usage: index.getObjects(arrayOfObjectIDs[, callback])'; - - if (!isArray(objectIDs)) { - throw new Error(usage); - } - - var indexObj = this; - - if (arguments.length === 1 || typeof attributesToRetrieve === 'function') { - callback = attributesToRetrieve; - attributesToRetrieve = undefined; - } - - var body = { - requests: map(objectIDs, function prepareRequest(objectID) { - var request = { - indexName: indexObj.indexName, - objectID: objectID - }; - - if (attributesToRetrieve) { - request.attributesToRetrieve = attributesToRetrieve.join(','); - } - - return request; - }) - }; - - return this.as._jsonRequest({ - method: 'POST', - url: '/1/indexes/*/objects', - hostType: 'read', - body: body, - callback: callback - }); -}; - -IndexCore.prototype.as = null; -IndexCore.prototype.indexName = null; -IndexCore.prototype.typeAheadArgs = null; -IndexCore.prototype.typeAheadValueOption = null; - -},{"26":26,"27":27,"29":29,"30":30,"33":33,"34":34,"35":35,"8":8}],21:[function(require,module,exports){ -(function (process){ -'use strict'; - -// This is the AngularJS Algolia Search module -// It's using $http to do requests with a JSONP fallback -// $q promises are returned - -var inherits = require(7); - -var forEach = require(5); - -var AlgoliaSearch = require(16); -var errors = require(31); -var inlineHeaders = require(24); -var jsonpRequest = require(25); -var places = require(36); - -// expose original algoliasearch fn in window -window.algoliasearch = require(22); - -if (process.env.NODE_ENV === 'debug') { - require(1).enable('algoliasearch*'); -} - -window.angular.module('algoliasearch', []) - .service('algolia', ['$http', '$q', '$timeout', function algoliaSearchService($http, $q, $timeout) { - function algoliasearch(applicationID, apiKey, opts) { - var cloneDeep = require(27); - - opts = cloneDeep(opts || {}); - - opts._ua = opts._ua || algoliasearch.ua; - - return new AlgoliaSearchAngular(applicationID, apiKey, opts); - } - - algoliasearch.version = require(38); - - algoliasearch.ua = - 'Algolia for JavaScript (' + algoliasearch.version + '); ' + - 'AngularJS (' + window.angular.version.full + ')'; - - algoliasearch.initPlaces = places(algoliasearch); - - // we expose into window no matter how we are used, this will allow - // us to easily debug any website running algolia - window.__algolia = { - debug: require(1), - algoliasearch: algoliasearch - }; - - function AlgoliaSearchAngular() { - // call AlgoliaSearch constructor - AlgoliaSearch.apply(this, arguments); - } - - inherits(AlgoliaSearchAngular, AlgoliaSearch); - - AlgoliaSearchAngular.prototype._request = function request(url, opts) { - // Support most Angular.js versions by using $q.defer() instead - // of the new $q() constructor everywhere we need a promise - var deferred = $q.defer(); - var resolve = deferred.resolve; - var reject = deferred.reject; - - var timedOut; - var body = opts.body; - - url = inlineHeaders(url, opts.headers); - - var timeoutDeferred = $q.defer(); - var timeoutPromise = timeoutDeferred.promise; - - $timeout(function timedout() { - timedOut = true; - // will cancel the xhr - timeoutDeferred.resolve('test'); - reject(new errors.RequestTimeout()); - }, opts.timeouts.complete); - - var requestHeaders = {}; - - // "remove" (set to undefined) possible globally set headers - // in $httpProvider.defaults.headers.common - // otherwise we might fail sometimes - // ref: https://github.com/algolia/algoliasearch-client-js/issues/135 - forEach( - $http.defaults.headers.common, - function removeIt(headerValue, headerName) { - requestHeaders[headerName] = undefined; - } - ); - - requestHeaders.accept = 'application/json'; - - if (body) { - if (opts.method === 'POST') { - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests - requestHeaders['content-type'] = 'application/x-www-form-urlencoded'; - } else { - requestHeaders['content-type'] = 'application/json'; - } - } - - $http({ - url: url, - method: opts.method, - data: body, - cache: false, - timeout: timeoutPromise, - headers: requestHeaders, - transformResponse: transformResponse, - // if client uses $httpProvider.defaults.withCredentials = true, - // we revert it to false to avoid CORS failure - withCredentials: false - }).then(success, error); - - function success(response) { - resolve({ - statusCode: response.status, - headers: response.headers, - body: JSON.parse(response.data), - responseText: response.data - }); - } - - // we force getting the raw data because we need it so - // for cache keys - function transformResponse(data) { - return data; - } - - function error(response) { - if (timedOut) { - return; - } - - // network error - if (response.status === 0) { - reject( - new errors.Network({ - more: response - }) - ); - return; - } - - resolve({ - body: JSON.parse(response.data), - statusCode: response.status - }); - } - - return deferred.promise; - }; - - // using IE8 or IE9 we will always end up here - // AngularJS does not fallback to XDomainRequest - AlgoliaSearchAngular.prototype._request.fallback = function requestFallback(url, opts) { - url = inlineHeaders(url, opts.headers); - - var deferred = $q.defer(); - var resolve = deferred.resolve; - var reject = deferred.reject; - - jsonpRequest(url, opts, function jsonpRequestDone(err, content) { - if (err) { - reject(err); - return; - } - - resolve(content); - }); - - return deferred.promise; - }; - - AlgoliaSearchAngular.prototype._promise = { - reject: function(val) { - return $q.reject(val); - }, - resolve: function(val) { - // http://www.bennadel.com/blog/2735-q-when-is-the-missing-q-resolve-method-in-angularjs.htm - return $q.when(val); - }, - delay: function(ms) { - var deferred = $q.defer(); - var resolve = deferred.resolve; - - $timeout(resolve, ms); - - return deferred.promise; - }, - all: function(promises) { - return $q.all(promises); - } - }; - - return { - Client: function(applicationID, apiKey, options) { - return algoliasearch(applicationID, apiKey, options); - }, - ua: algoliasearch.ua, - version: algoliasearch.version - }; - }]); - -}).call(this,require(12)) -},{"1":1,"12":12,"16":16,"22":22,"24":24,"25":25,"27":27,"31":31,"36":36,"38":38,"5":5,"7":7}],22:[function(require,module,exports){ -'use strict'; - -var AlgoliaSearch = require(16); -var createAlgoliasearch = require(23); - -module.exports = createAlgoliasearch(AlgoliaSearch, 'Browser'); - -},{"16":16,"23":23}],23:[function(require,module,exports){ -(function (process){ -'use strict'; - -var global = require(6); -var Promise = global.Promise || require(3).Promise; - -// This is the standalone browser build entry point -// Browser implementation of the Algolia Search JavaScript client, -// using XMLHttpRequest, XDomainRequest and JSONP as fallback -module.exports = function createAlgoliasearch(AlgoliaSearch, uaSuffix) { - var inherits = require(7); - var errors = require(31); - var inlineHeaders = require(24); - var jsonpRequest = require(25); - var places = require(36); - uaSuffix = uaSuffix || ''; - - if (process.env.NODE_ENV === 'debug') { - require(1).enable('algoliasearch*'); - } - - function algoliasearch(applicationID, apiKey, opts) { - var cloneDeep = require(27); - - opts = cloneDeep(opts || {}); - - opts._ua = opts._ua || algoliasearch.ua; - - return new AlgoliaSearchBrowser(applicationID, apiKey, opts); - } - - algoliasearch.version = require(38); - - algoliasearch.ua = - 'Algolia for JavaScript (' + algoliasearch.version + '); ' + uaSuffix; - - algoliasearch.initPlaces = places(algoliasearch); - - // we expose into window no matter how we are used, this will allow - // us to easily debug any website running algolia - global.__algolia = { - debug: require(1), - algoliasearch: algoliasearch - }; - - var support = { - hasXMLHttpRequest: 'XMLHttpRequest' in global, - hasXDomainRequest: 'XDomainRequest' in global - }; - - if (support.hasXMLHttpRequest) { - support.cors = 'withCredentials' in new XMLHttpRequest(); - } - - function AlgoliaSearchBrowser() { - // call AlgoliaSearch constructor - AlgoliaSearch.apply(this, arguments); - } - - inherits(AlgoliaSearchBrowser, AlgoliaSearch); - - AlgoliaSearchBrowser.prototype._request = function request(url, opts) { - return new Promise(function wrapRequest(resolve, reject) { - // no cors or XDomainRequest, no request - if (!support.cors && !support.hasXDomainRequest) { - // very old browser, not supported - reject(new errors.Network('CORS not supported')); - return; - } - - url = inlineHeaders(url, opts.headers); - - var body = opts.body; - var req = support.cors ? new XMLHttpRequest() : new XDomainRequest(); - var reqTimeout; - var timedOut; - var connected = false; - - reqTimeout = setTimeout(onTimeout, opts.timeouts.connect); - // we set an empty onprogress listener - // so that XDomainRequest on IE9 is not aborted - // refs: - // - https://github.com/algolia/algoliasearch-client-js/issues/76 - // - https://social.msdn.microsoft.com/Forums/ie/en-US/30ef3add-767c-4436-b8a9-f1ca19b4812e/ie9-rtm-xdomainrequest-issued-requests-may-abort-if-all-event-handlers-not-specified?forum=iewebdevelopment - req.onprogress = onProgress; - if ('onreadystatechange' in req) req.onreadystatechange = onReadyStateChange; - req.onload = onLoad; - req.onerror = onError; - - // do not rely on default XHR async flag, as some analytics code like hotjar - // breaks it and set it to false by default - if (req instanceof XMLHttpRequest) { - req.open(opts.method, url, true); - - // The Analytics API never accepts Auth headers as query string - // this option exists specifically for them. - if (opts.forceAuthHeaders) { - req.setRequestHeader( - 'x-algolia-application-id', - opts.headers['x-algolia-application-id'] - ); - req.setRequestHeader( - 'x-algolia-api-key', - opts.headers['x-algolia-api-key'] - ); - } - } else { - req.open(opts.method, url); - } - - // headers are meant to be sent after open - if (support.cors) { - if (body) { - if (opts.method === 'POST') { - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests - req.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); - } else { - req.setRequestHeader('content-type', 'application/json'); - } - } - req.setRequestHeader('accept', 'application/json'); - } - - if (body) { - req.send(body); - } else { - req.send(); - } - - // event object not received in IE8, at least - // but we do not use it, still important to note - function onLoad(/* event */) { - // When browser does not supports req.timeout, we can - // have both a load and timeout event, since handled by a dumb setTimeout - if (timedOut) { - return; - } - - clearTimeout(reqTimeout); - - var out; - - try { - out = { - body: JSON.parse(req.responseText), - responseText: req.responseText, - statusCode: req.status, - // XDomainRequest does not have any response headers - headers: req.getAllResponseHeaders && req.getAllResponseHeaders() || {} - }; - } catch (e) { - out = new errors.UnparsableJSON({ - more: req.responseText - }); - } - - if (out instanceof errors.UnparsableJSON) { - reject(out); - } else { - resolve(out); - } - } - - function onError(event) { - if (timedOut) { - return; - } - - clearTimeout(reqTimeout); - - // error event is trigerred both with XDR/XHR on: - // - DNS error - // - unallowed cross domain request - reject( - new errors.Network({ - more: event - }) - ); - } - - function onTimeout() { - timedOut = true; - req.abort(); - - reject(new errors.RequestTimeout()); - } - - function onConnect() { - connected = true; - clearTimeout(reqTimeout); - reqTimeout = setTimeout(onTimeout, opts.timeouts.complete); - } - - function onProgress() { - if (!connected) onConnect(); - } - - function onReadyStateChange() { - if (!connected && req.readyState > 1) onConnect(); - } - }); - }; - - AlgoliaSearchBrowser.prototype._request.fallback = function requestFallback(url, opts) { - url = inlineHeaders(url, opts.headers); - - return new Promise(function wrapJsonpRequest(resolve, reject) { - jsonpRequest(url, opts, function jsonpRequestDone(err, content) { - if (err) { - reject(err); - return; - } - - resolve(content); - }); - }); - }; - - AlgoliaSearchBrowser.prototype._promise = { - reject: function rejectPromise(val) { - return Promise.reject(val); - }, - resolve: function resolvePromise(val) { - return Promise.resolve(val); - }, - delay: function delayPromise(ms) { - return new Promise(function resolveOnTimeout(resolve/* , reject*/) { - setTimeout(resolve, ms); - }); - }, - all: function all(promises) { - return Promise.all(promises); - } - }; - - return algoliasearch; -}; - -}).call(this,require(12)) -},{"1":1,"12":12,"24":24,"25":25,"27":27,"3":3,"31":31,"36":36,"38":38,"6":6,"7":7}],24:[function(require,module,exports){ -'use strict'; - -module.exports = inlineHeaders; - -var encode = require(14); - -function inlineHeaders(url, headers) { - if (/\?/.test(url)) { - url += '&'; - } else { - url += '?'; - } - - return url + encode(headers); -} - -},{"14":14}],25:[function(require,module,exports){ -'use strict'; - -module.exports = jsonpRequest; - -var errors = require(31); - -var JSONPCounter = 0; - -function jsonpRequest(url, opts, cb) { - if (opts.method !== 'GET') { - cb(new Error('Method ' + opts.method + ' ' + url + ' is not supported by JSONP.')); - return; - } - - opts.debug('JSONP: start'); - - var cbCalled = false; - var timedOut = false; - - JSONPCounter += 1; - var head = document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - var cbName = 'algoliaJSONP_' + JSONPCounter; - var done = false; - - window[cbName] = function(data) { - removeGlobals(); - - if (timedOut) { - opts.debug('JSONP: Late answer, ignoring'); - return; - } - - cbCalled = true; - - clean(); - - cb(null, { - body: data, - responseText: JSON.stringify(data)/* , - // We do not send the statusCode, there's no statusCode in JSONP, it will be - // computed using data.status && data.message like with XDR - statusCode*/ - }); - }; - - // add callback by hand - url += '&callback=' + cbName; - - // add body params manually - if (opts.jsonBody && opts.jsonBody.params) { - url += '&' + opts.jsonBody.params; - } - - var ontimeout = setTimeout(timeout, opts.timeouts.complete); - - // script onreadystatechange needed only for - // <= IE8 - // https://github.com/angular/angular.js/issues/4523 - script.onreadystatechange = readystatechange; - script.onload = success; - script.onerror = error; - - script.async = true; - script.defer = true; - script.src = url; - head.appendChild(script); - - function success() { - opts.debug('JSONP: success'); - - if (done || timedOut) { - return; - } - - done = true; - - // script loaded but did not call the fn => script loading error - if (!cbCalled) { - opts.debug('JSONP: Fail. Script loaded but did not call the callback'); - clean(); - cb(new errors.JSONPScriptFail()); - } - } - - function readystatechange() { - if (this.readyState === 'loaded' || this.readyState === 'complete') { - success(); - } - } - - function clean() { - clearTimeout(ontimeout); - script.onload = null; - script.onreadystatechange = null; - script.onerror = null; - head.removeChild(script); - } - - function removeGlobals() { - try { - delete window[cbName]; - delete window[cbName + '_loaded']; - } catch (e) { - window[cbName] = window[cbName + '_loaded'] = undefined; - } - } - - function timeout() { - opts.debug('JSONP: Script timeout'); - timedOut = true; - clean(); - cb(new errors.RequestTimeout()); - } - - function error() { - opts.debug('JSONP: Script error'); - - if (done || timedOut) { - return; - } - - clean(); - cb(new errors.JSONPScriptError()); - } -} - -},{"31":31}],26:[function(require,module,exports){ -module.exports = buildSearchMethod; - -var errors = require(31); - -/** - * Creates a search method to be used in clients - * @param {string} queryParam the name of the attribute used for the query - * @param {string} url the url - * @return {function} the search method - */ -function buildSearchMethod(queryParam, url) { - /** - * The search method. Prepares the data and send the query to Algolia. - * @param {string} query the string used for query search - * @param {object} args additional parameters to send with the search - * @param {function} [callback] the callback to be called with the client gets the answer - * @return {undefined|Promise} If the callback is not provided then this methods returns a Promise - */ - return function search(query, args, callback) { - // warn V2 users on how to search - if (typeof query === 'function' && typeof args === 'object' || - typeof callback === 'object') { - // .search(query, params, cb) - // .search(cb, params) - throw new errors.AlgoliaSearchError('index.search usage is index.search(query, params, cb)'); - } - - // Normalizing the function signature - if (arguments.length === 0 || typeof query === 'function') { - // Usage : .search(), .search(cb) - callback = query; - query = ''; - } else if (arguments.length === 1 || typeof args === 'function') { - // Usage : .search(query/args), .search(query, cb) - callback = args; - args = undefined; - } - // At this point we have 3 arguments with values - - // Usage : .search(args) // careful: typeof null === 'object' - if (typeof query === 'object' && query !== null) { - args = query; - query = undefined; - } else if (query === undefined || query === null) { // .search(undefined/null) - query = ''; - } - - var params = ''; - - if (query !== undefined) { - params += queryParam + '=' + encodeURIComponent(query); - } - - var additionalUA; - if (args !== undefined) { - if (args.additionalUA) { - additionalUA = args.additionalUA; - delete args.additionalUA; - } - // `_getSearchParams` will augment params, do not be fooled by the = versus += from previous if - params = this.as._getSearchParams(args, params); - } - - - return this._search(params, url, callback, additionalUA); - }; -} - -},{"31":31}],27:[function(require,module,exports){ -module.exports = function clone(obj) { - return JSON.parse(JSON.stringify(obj)); -}; - -},{}],28:[function(require,module,exports){ -module.exports = createAnalyticsClient; - -var algoliasearch = require(22); - -function createAnalyticsClient(appId, apiKey, opts) { - var analytics = {}; - - opts = opts || {}; - // there need to be 4 hosts, like on the client, since if requests fail, - // the counter goes up by 1, so we need to have the same amount of hosts - // 4 because: -dsn, -1, -2, -3 - // This is done because the APPID used for search will be the same for the analytics client created, - // and since the state of available hosts is shared by APPID globally for the module, we had issues - // where the hostIndex would be 1 while the array was only one entry (you got an empty host) - opts.hosts = opts.hosts || [ - 'analytics.algolia.com', - 'analytics.algolia.com', - 'analytics.algolia.com', - 'analytics.algolia.com' - ]; - opts.protocol = opts.protocol || 'https:'; - - analytics.as = algoliasearch(appId, apiKey, opts); - - analytics.getABTests = function(_params, callback) { - var params = params || {}; - var offset = params.offset || 0; - var limit = params.limit || 10; - - return this.as._jsonRequest({ - method: 'GET', - url: '/2/abtests?offset=' + encodeURIComponent(offset) + '&limit=' + encodeURIComponent(limit), - hostType: 'read', - forceAuthHeaders: true, - callback: callback - }); - }; - - analytics.getABTest = function(abTestID, callback) { - return this.as._jsonRequest({ - method: 'GET', - url: '/2/abtests/' + encodeURIComponent(abTestID), - hostType: 'read', - forceAuthHeaders: true, - callback: callback - }); - }; - - analytics.addABTest = function(abTest, callback) { - return this.as._jsonRequest({ - method: 'POST', - url: '/2/abtests', - body: abTest, - hostType: 'read', - forceAuthHeaders: true, - callback: callback - }); - }; - - analytics.stopABTest = function(abTestID, callback) { - return this.as._jsonRequest({ - method: 'POST', - url: '/2/abtests/' + encodeURIComponent(abTestID) + '/stop', - hostType: 'read', - forceAuthHeaders: true, - callback: callback - }); - }; - - analytics.deleteABTest = function(abTestID, callback) { - return this.as._jsonRequest({ - method: 'DELETE', - url: '/2/abtests/' + encodeURIComponent(abTestID), - hostType: 'write', - forceAuthHeaders: true, - callback: callback - }); - }; - - analytics.waitTask = function(indexName, taskID, callback) { - return this.as.initIndex(indexName).waitTask(taskID, callback); - }; - - return analytics; -} - -},{"22":22}],29:[function(require,module,exports){ -module.exports = function deprecate(fn, message) { - var warned = false; - - function deprecated() { - if (!warned) { - /* eslint no-console:0 */ - console.warn(message); - warned = true; - } - - return fn.apply(this, arguments); - } - - return deprecated; -}; - -},{}],30:[function(require,module,exports){ -module.exports = function deprecatedMessage(previousUsage, newUsage) { - var githubAnchorLink = previousUsage.toLowerCase() - .replace(/[\.\(\)]/g, ''); - - return 'algoliasearch: `' + previousUsage + '` was replaced by `' + newUsage + - '`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#' + githubAnchorLink; -}; - -},{}],31:[function(require,module,exports){ -'use strict'; - -// This file hosts our error definitions -// We use custom error "types" so that we can act on them when we need it -// e.g.: if error instanceof errors.UnparsableJSON then.. - -var inherits = require(7); - -function AlgoliaSearchError(message, extraProperties) { - var forEach = require(5); - - var error = this; - - // try to get a stacktrace - if (typeof Error.captureStackTrace === 'function') { - Error.captureStackTrace(this, this.constructor); - } else { - error.stack = (new Error()).stack || 'Cannot get a stacktrace, browser is too old'; - } - - this.name = 'AlgoliaSearchError'; - this.message = message || 'Unknown error'; - - if (extraProperties) { - forEach(extraProperties, function addToErrorObject(value, key) { - error[key] = value; - }); - } -} - -inherits(AlgoliaSearchError, Error); - -function createCustomError(name, message) { - function AlgoliaSearchCustomError() { - var args = Array.prototype.slice.call(arguments, 0); - - // custom message not set, use default - if (typeof args[0] !== 'string') { - args.unshift(message); - } - - AlgoliaSearchError.apply(this, args); - this.name = 'AlgoliaSearch' + name + 'Error'; - } - - inherits(AlgoliaSearchCustomError, AlgoliaSearchError); - - return AlgoliaSearchCustomError; -} - -// late exports to let various fn defs and inherits take place -module.exports = { - AlgoliaSearchError: AlgoliaSearchError, - UnparsableJSON: createCustomError( - 'UnparsableJSON', - 'Could not parse the incoming response as JSON, see err.more for details' - ), - RequestTimeout: createCustomError( - 'RequestTimeout', - 'Request timed out before getting a response' - ), - Network: createCustomError( - 'Network', - 'Network issue, see err.more for details' - ), - JSONPScriptFail: createCustomError( - 'JSONPScriptFail', - '"),window.ALGOLIA_SUPPORTS_DOCWRITE===!0?(document.write(''),n("document.write")()):r(o,n("DOMElement"))}catch(s){r(o,n("DOMElement"))}}function n(e){return function(){var t="AlgoliaSearch: loaded V2 script using "+e;window.console&&window.console.log&&window.console.log(t)}}t.exports=o},{1:1}],4:[function(e,t,r){"use strict";function o(){var e="-- AlgoliaSearch V2 => V3 error --\nYou are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\nPlease read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n-- /AlgoliaSearch V2 => V3 error --";window.AlgoliaSearch=function(){throw new Error(e)},window.AlgoliaSearchHelper=function(){throw new Error(e)},window.AlgoliaExplainResults=function(){throw new Error(e)}}t.exports=o},{}],5:[function(e,t,r){"use strict";function o(t){var r=e(2),o=e(3),n=e(4);r(t)?o(t):n()}o("algoliasearch.angular")},{2:2,3:3,4:4}]},{},[5])(5)}),function e(t,r,o){function n(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return n(r?r:e)},l,l.exports,e,t,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,o)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function c(){var e;try{e=r.storage.debug}catch(t){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e(2),r.log=s,r.formatArgs=i,r.save=a,r.load=c,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(c())}).call(this,e(12))},{12:12,2:2}],2:[function(e,t,r){function o(e){var t,o=0;for(t in e)o=(o<<5)-o+e.charCodeAt(t),o|=0;return r.colors[Math.abs(o)%r.colors.length]}function n(e){function t(){if(t.enabled){var e=t,o=+new Date,n=o-(u||o);e.diff=n,e.prev=u,e.curr=o,u=o;for(var i=new Array(arguments.length),s=0;s0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},o.prototype.removeListener=function(e,t){var r,o,i,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],i=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=i;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},o.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],5:[function(e,t,r){var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var s=0;s100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*c;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=u?Math.round(e/u)+"h":e>=c?Math.round(e/c)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,l,"day")||s(e,u,"hour")||s(e,c,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,r){if(!(e0)return o(e);if("number"===r&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],10:[function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,s=e(11),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},d={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),f=function(e){if("undefined"==typeof window||!h)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===n.call(e),i=s(e),a=t&&"[object String]"===n.call(e),p=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=u&&r;if(a&&e.length>0&&!o.call(e,0))for(var h=0;h0)for(var y=0;y=0&&"[object Function]"===o.call(e.callee)),r}},{}],12:[function(e,t,r){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===o||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(d===clearTimeout)return clearTimeout(e);if((d===n||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){m&&f&&(m=!1,f.length?y=f.concat(y):v=-1,y.length&&c())}function c(){if(!m){var e=i(a);m=!0;for(var t=y.length;t;){for(f=y,y=[];++v1)for(var r=1;r0&&u>c&&(u=c);for(var l=0;l=0?(p=y.substr(0,m),d=y.substr(m+1)):(p=y,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),o(s,h)?n(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],14:[function(e,t,r){"use strict";function o(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o0)n.scope=r;else if("undefined"!=typeof r)throw new Error("the scope given to `copyIndex` was not an array with settings, synonyms or rules");return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:n,hostType:"write",callback:i})},o.prototype.getLogs=function(t,r,o){var n=e(27),i={};return"object"==typeof t?(i=n(t),o=r):0===arguments.length||"function"==typeof t?o=t:1===arguments.length||"function"==typeof r?(o=r,i.offset=t):(i.offset=t,i.length=r),void 0===i.offset&&(i.offset=0),void 0===i.length&&(i.length=10),this._jsonRequest({method:"GET",url:"/1/logs?"+this._getSearchParams(i,""),hostType:"read",callback:o})},o.prototype.listIndexes=function(e,t){var r="";return void 0===e||"function"==typeof e?t=e:r="?page="+e,this._jsonRequest({method:"GET",url:"/1/indexes"+r,hostType:"read",callback:t})},o.prototype.initIndex=function(e){return new i(this,e)},o.prototype.initAnalytics=function(t){var r=e(28);return r(this.applicationID,this.apiKey,t)},o.prototype.listUserKeys=s(function(e){return this.listApiKeys(e)},a("client.listUserKeys()","client.listApiKeys()")),o.prototype.listApiKeys=function(e){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:e})},o.prototype.getUserKeyACL=s(function(e,t){return this.getApiKey(e,t)},a("client.getUserKeyACL()","client.getApiKey()")),o.prototype.getApiKey=function(e,t){return this._jsonRequest({method:"GET",url:"/1/keys/"+e,hostType:"read",callback:t})},o.prototype.deleteUserKey=s(function(e,t){return this.deleteApiKey(e,t)},a("client.deleteUserKey()","client.deleteApiKey()")),o.prototype.deleteApiKey=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+e,hostType:"write",callback:t})},o.prototype.restoreApiKey=function(e,t){return this._jsonRequest({method:"POST",url:"/1/keys/"+e+"/restore",hostType:"write",callback:t})},o.prototype.addUserKey=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKey()","client.addApiKey()")),o.prototype.addApiKey=function(t,r,o){var n=e(8),i="Usage: client.addApiKey(arrayOfAcls[, params, callback])";if(!n(t))throw new Error(i);1!==arguments.length&&"function"!=typeof r||(o=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.indexes=r.indexes,s.description=r.description,r.queryParameters&&(s.queryParameters=this._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this._jsonRequest({method:"POST",url:"/1/keys",body:s,hostType:"write",callback:o})},o.prototype.addUserKeyWithValidity=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKeyWithValidity()","client.addApiKey()")),o.prototype.updateUserKey=s(function(e,t,r,o){return this.updateApiKey(e,t,r,o)},a("client.updateUserKey()","client.updateApiKey()")),o.prototype.updateApiKey=function(t,r,o,n){var i=e(8),s="Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])";if(!i(r))throw new Error(s);2!==arguments.length&&"function"!=typeof o||(n=o,o=null);var a={acl:r};return o&&(a.validity=o.validity,a.maxQueriesPerIPPerHour=o.maxQueriesPerIPPerHour,a.maxHitsPerQuery=o.maxHitsPerQuery,a.indexes=o.indexes,a.description=o.description,o.queryParameters&&(a.queryParameters=this._getSearchParams(o.queryParameters,"")),a.referers=o.referers),this._jsonRequest({method:"PUT",url:"/1/keys/"+t,body:a,hostType:"write",callback:n})},o.prototype.startQueriesBatch=s(function(){this._batch=[]},a("client.startQueriesBatch()","client.search()")),o.prototype.addQueryInBatch=s(function(e,t,r){this._batch.push({indexName:e,query:t,params:r})},a("client.addQueryInBatch()","client.search()")),o.prototype.sendQueriesBatch=s(function(e){return this.search(this._batch,e)},a("client.sendQueriesBatch()","client.search()")),o.prototype.batch=function(t,r){var o=e(8),n="Usage: client.batch(operations[, callback])";if(!o(t))throw new Error(n);return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:t},hostType:"write",callback:r})},o.prototype.assignUserID=function(e,t){if(!e.userID||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both a userID and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping",hostType:"write",body:{cluster:e.cluster},callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.assignUserIDs=function(e,t){if(!e.userIDs||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both an array of userIDs and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/batch",hostType:"write",body:{cluster:e.cluster,users:e.userIDs},callback:t})},o.prototype.getTopUserID=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/top",hostType:"read",callback:e})},o.prototype.getUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/"+e.userID,hostType:"read",callback:t})},o.prototype.listClusters=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters",hostType:"read",callback:e})},o.prototype.listUserIDs=function(e,t){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping",body:e,hostType:"read",callback:t})},o.prototype.removeUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"DELETE",url:"/1/clusters/mapping",hostType:"write",callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.searchUserIDs=function(e,t){return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/search",body:e,hostType:"read",callback:t})},o.prototype.setPersonalizationStrategy=function(e,t){return this._jsonRequest({method:"POST",url:"/1/recommendation/personalization/strategy",body:e,hostType:"write",callback:t})},o.prototype.getPersonalizationStrategy=function(e){return this._jsonRequest({method:"GET",url:"/1/recommendation/personalization/strategy",hostType:"read",callback:e})},o.prototype.destroy=n,o.prototype.enableRateLimitForward=n,o.prototype.disableRateLimitForward=n,o.prototype.useSecuredAPIKey=n,o.prototype.disableSecuredAPIKey=n,o.prototype.generateSecuredApiKey=n,o.prototype.getSecuredApiKeyRemainingValidity=n},{17:17,18:18,27:27,28:28,29:29,30:30,31:31,7:7,8:8}],17:[function(e,t,r){(function(r){function o(t,r,o){var i=e(1)("algoliasearch"),s=e(27),a=e(8),u=e(33),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(o._allowEmptyCredentials!==!0&&!t)throw new c.AlgoliaSearchError("Please provide an application ID. "+l);if(o._allowEmptyCredentials!==!0&&!r)throw new c.AlgoliaSearchError("Please provide an API key. "+l); -this.applicationID=t,this.apiKey=r,this.hosts={read:[],write:[]},o=o||{},this._timeouts=o.timeouts||{connect:1e3,read:2e3,write:3e4},o.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=o.timeout);var p=o.protocol||"https:";if(/:$/.test(p)||(p+=":"),"http:"!==p&&"https:"!==p)throw new c.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+o.protocol+"`)");if(this._checkAppIdData(),o.hosts)a(o.hosts)?(this.hosts.read=s(o.hosts),this.hosts.write=s(o.hosts)):(this.hosts.read=s(o.hosts.read),this.hosts.write=s(o.hosts.write));else{var d=u(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"}),h=(o.dsn===!1?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+h].concat(d),this.hosts.write=[this.applicationID+".algolia.net"].concat(d)}this.hosts.read=u(this.hosts.read,n(p)),this.hosts.write=u(this.hosts.write,n(p)),this.extraHeaders={},this.cache=o._cache||{},this._ua=o._ua,this._useCache=!(void 0!==o._useCache&&!o._cache)||o._useCache,this._useRequestCache=this._useCache&&o._useRequestCache,this._useFallback=void 0===o.useFallback||o.useFallback,this._setTimeout=o._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var r=JSON.stringify(e);return Array.prototype.toJSON=t,r}function s(e){for(var t,r,o=e.length;0!==o;)r=Math.floor(Math.random()*o),o-=1,t=e[o],e[o]=e[r],e[r]=t;return e}function a(e){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o;o="x-algolia-api-key"===r||"x-algolia-application-id"===r?"**hidden for security purposes**":e[r],t[r]=o}return t}t.exports=o;var c=e(31),u=e(32),l=e(20),p=e(37),d=500,h=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;o.prototype.initIndex=function(e){return new l(this,e)},o.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},o.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},o.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},o.prototype.addAlgoliaAgent=function(e){var t="; "+e;this._ua.indexOf(t)===-1&&(this._ua+=t)},o.prototype._jsonRequest=function(t){function r(e,n){function u(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;h("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var r=2===Math.floor(t/100),o=new Date;if(w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:o,duration:o-x,statusCode:t}),r)return m._useCache&&!m._useRequestCache&&y&&(y[l]=e.responseText),{responseText:e.responseText,body:e.body};var i=4!==Math.floor(t/100);if(i)return v+=1,_();h("unrecoverable error");var u=new c.AlgoliaSearchError(e.body&&e.body.message,{debugData:w,statusCode:t});return m._promise.reject(u)}function d(e){h("error: %s, stack: %s",e.message,e.stack);var r=new Date;return w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:r,duration:r-x}),e instanceof c.AlgoliaSearchError||(e=new c.Unknown(e&&e.message,e)),v+=1,e instanceof c.Unknown||e instanceof c.UnparsableJSON||v>=m.hosts[t.hostType].length&&(g||!b)?(e.debugData=w,m._promise.reject(e)):e instanceof c.RequestTimeout?T():_()}function _(){return h("retrying request"),m._incrementHostIndex(t.hostType),r(e,n)}function T(){return h("retrying request with higher timeout"),m._incrementHostIndex(t.hostType),m._incrementTimeoutMultipler(),n.timeouts=m._getTimeoutsForRequest(t.hostType),r(e,n)}m._checkAppIdData();var x=new Date;if(m._useCache&&!m._useRequestCache&&(l=t.url),m._useCache&&!m._useRequestCache&&s&&(l+="_body_"+n.body),o(!m._useRequestCache,y,l)){h("serving response from cache");var R=y[l];return m._promise.resolve({body:JSON.parse(R),responseText:R})}if(v>=m.hosts[t.hostType].length)return!b||g?(h("could not get any response"),m._promise.reject(new c.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+m.applicationID,{debugData:w}))):(h("switching to fallback"),v=0,n.method=t.fallback.method,n.url=t.fallback.url,n.jsonBody=t.fallback.body,n.jsonBody&&(n.body=i(n.jsonBody)),p=m._computeRequestHeaders({additionalUA:f,headers:t.headers}),n.timeouts=m._getTimeoutsForRequest(t.hostType),m._setHostIndexByType(0,t.hostType),g=!0,r(m._request.fallback,n));var A=m._getHostByType(t.hostType),j=A+n.url,S={body:n.body,jsonBody:n.jsonBody,method:n.method,headers:p,timeouts:n.timeouts,debug:h,forceAuthHeaders:n.forceAuthHeaders};return h("method: %s, url: %s, headers: %j, timeouts: %d",S.method,j,S.headers,S.timeouts),e===m._request.fallback&&h("using fallback"),e.call(m,j,S).then(u,d)}function o(e,t,r){return m._useCache&&e&&t&&void 0!==t[r]}function n(e,r){return o(m._useRequestCache,y,l)&&e["catch"](function(){delete y[l]}),"function"!=typeof t.callback?e.then(r):void e.then(function(e){u(function(){t.callback(null,r(e))},m._setTimeout||setTimeout)},function(e){u(function(){t.callback(e)},m._setTimeout||setTimeout)})}this._checkAppIdData();var s,l,p,h=e(1)("algoliasearch:"+t.url),f=t.additionalUA||"",y=t.cache,m=this,v=0,g=!1,b=m._useFallback&&m._request.fallback&&t.fallback;this.apiKey.length>d&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,p=this._computeRequestHeaders({additionalUA:f,withApiKey:!1,headers:t.headers})):p=this._computeRequestHeaders({additionalUA:f,headers:t.headers}),void 0!==t.body&&(s=i(t.body)),h("request start");var w=[];if(m._useCache&&m._useRequestCache&&(l=t.url),m._useCache&&m._useRequestCache&&s&&(l+="_body_"+s),o(m._useRequestCache,y,l)){h("serving request from cache");var _=y[l],T="function"!=typeof _.then?m._promise.resolve({responseText:_}):_;return n(T,function(e){return JSON.parse(e.responseText)})}var x=r(m._request,{url:t.url,method:t.method,body:s,jsonBody:t.body,timeouts:m._getTimeoutsForRequest(t.hostType),forceAuthHeaders:t.forceAuthHeaders});return m._useCache&&m._useRequestCache&&y&&(y[l]=x),n(x,function(e){return e.body})},o.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var r in e)null!==r&&void 0!==e[r]&&e.hasOwnProperty(r)&&(t+=""===t?"":"&",t+=r+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[r])?i(e[r]):e[r]));return t},o.prototype._computeRequestHeaders=function(t){var r=e(5),o=t.additionalUA?this._ua+"; "+t.additionalUA:this._ua,n={"x-algolia-agent":o,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),r(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&r(t.headers,function(e,t){n[t]=e}),n},o.prototype.search=function(t,r,o){var n=e(8),i=e(33),s="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(s);"function"==typeof r?(o=r,r={}):void 0===r&&(r={});var a=this,c={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}})},u=i(c.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==r.strategy&&(c.strategy=r.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:c,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:o})},o.prototype.searchForFacetValues=function(t){var r=e(8),o=e(33),n="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!r(t))throw new Error(n);var i=this;return i._promise.all(o(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(n);var r=e(27),o=e(35),s=t.indexName,a=t.params,c=a.facetName,u=o(r(a),function(e){return"facetName"===e}),l=i._getSearchParams(u,"");return i._jsonRequest({cache:i.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(s)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})}))},o.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],r=0;rh?this._resetInitialAppIdData(e):e},o.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||s([1,2,3]),this._setAppIdData(t)},o.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},o.prototype._partialAppIdDataUpdate=function(t){var r=e(5),o=this._getAppIdData();return r(t,function(e,t){o[t]=e}),this._setAppIdData(o)},o.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},o.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},o.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},o.prototype._setHostIndexByType=function(t,r){var o=e(27),n=o(this._hostIndexes);return n[r]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},o.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},o.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},o.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(12))},{1:1,12:12,20:20,27:27,31:31,32:32,33:33,35:35,37:37,5:5,8:8}],18:[function(e,t,r){function o(){s.apply(this,arguments)}function n(e,t,r){function o(r,n){var i={page:r||0,hitsPerPage:t||100},s=n||[];return e(i).then(function(e){var t=e.hits,r=e.nbHits,n=t.map(function(e){return delete e._highlightResult,e}),a=s.concat(n);return a.lengths&&(t=s),"published"!==e.status?l._promise.delay(t).then(r):e})}function o(e){u(function(){t(null,e)},l._setTimeout||setTimeout)}function n(e){u(function(){t(e)},l._setTimeout||setTimeout)}var i=100,s=5e3,a=0,c=this,l=c.as,p=r();return t?void p.then(o,n):p},o.prototype.clearIndex=function(e){var t=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(t.indexName)+"/clear",hostType:"write",callback:e})},o.prototype.getSettings=function(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),e=e||{};var r=encodeURIComponent(this.indexName);return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+r+"/settings?getVersion=2"+(e.advanced?"&advanced="+e.advanced:""),hostType:"read",callback:t})},o.prototype.searchSynonyms=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/search",body:e,hostType:"read",callback:t})},o.prototype.exportSynonyms=function(e,t){return n(this.searchSynonyms.bind(this),e,t)},o.prototype.saveSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getSynonym=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearSynonyms=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),void 0!==e.forwardToSlaves&&p();var r=e.forwardToSlaves||e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchSynonyms=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/batch?forwardToReplicas="+o+"&replaceExistingSynonyms="+(t.replaceExistingSynonyms?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.searchRules=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/search",body:e,hostType:"read",callback:t})},o.prototype.exportRules=function(e,t){return n(this.searchRules.bind(this),e,t)},o.prototype.saveRule=function(e,t,r){if("function"==typeof t?(r=t,t={}):void 0===t&&(t={}),!e.objectID)throw new l.AlgoliaSearchError("Missing or empty objectID field for rule");var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getRule=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteRule=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearRules=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={});var r=e.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchRules=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/batch?forwardToReplicas="+o+"&clearExistingRules="+(t.clearExistingRules===!0?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.exists=function(e){var t=this.getSettings().then(function(){return!0})["catch"](function(e){if(e instanceof l.AlgoliaSearchError&&404===e.statusCode)return!1;throw e});return"function"!=typeof e?t:void t.then(function(t){e(null,t)})["catch"](function(t){e(t)})},o.prototype.findObject=function(e,t,r){t=void 0===t?{}:t;var o=void 0===t.paginate||t.paginate,n=void 0!==t.query?t.query:"",i=this,s=0,a=function(){return t.page=s,i.search(n,t).then(function(t){for(var r=t.hits,n=0;n=t.nbPages)throw new l.ObjectNotFound("Object not found");return a()})},c=a(s);return void 0===r?c:void c.then(function(e){r(null,e)})["catch"](function(e){r(e)})},o.prototype.getObjectPosition=function(e,t){for(var r=e.hits,o=0;o1&&a()}if(!h.cors&&!h.hasXDomainRequest)return void o(new u.Network("CORS not supported"));e=l(e,t.headers);var d,f,y=t.body,m=h.cors?new XMLHttpRequest:new XDomainRequest,v=!1;d=setTimeout(s,t.timeouts.connect),m.onprogress=c,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?(m.open(t.method,e,!0),t.forceAuthHeaders&&(m.setRequestHeader("x-algolia-application-id",t.headers["x-algolia-application-id"]),m.setRequestHeader("x-algolia-api-key",t.headers["x-algolia-api-key"]))):m.open(t.method,e),h.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),y?m.send(y):m.send()})},a.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(r,o){p(e,t,function(e,t){return e?void o(e):void r(t)})})},a.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})},all:function(e){return n.all(e)}},s}}).call(this,e(12))},{1:1,12:12,24:24,25:25,27:27,3:3,31:31,36:36,38:38,6:6,7:7}],24:[function(e,t,r){"use strict";function o(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=o;var n=e(14)},{14:14}],25:[function(e,t,r){"use strict";function o(e,t,r){function o(){t.debug("JSONP: success"),m||d||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"),a(),r(new n.JSONPScriptFail)))}function s(){"loaded"!==this.readyState&&"complete"!==this.readyState||o()}function a(){clearTimeout(v),f.onload=null,f.onreadystatechange=null,f.onerror=null,h.removeChild(f)}function c(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function u(){t.debug("JSONP: Script timeout"),d=!0,a(),r(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||d||(a(),r(new n.JSONPScriptError))}if("GET"!==t.method)return void r(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,d=!1;i+=1;var h=document.getElementsByTagName("head")[0],f=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return c(),d?void t.debug("JSONP: Late answer, ignoring"):(p=!0,a(),void r(null,{body:e,responseText:JSON.stringify(e)}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var v=setTimeout(u,t.timeouts.complete);f.onreadystatechange=s,f.onload=o,f.onerror=l,f.async=!0,f.defer=!0,f.src=e,h.appendChild(f)}t.exports=o;var n=e(31),i=0},{31:31}],26:[function(e,t,r){function o(e,t){return function(r,o,i){if("function"==typeof r&&"object"==typeof o||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof r?(i=r,r=""):1!==arguments.length&&"function"!=typeof o||(i=o,o=void 0),"object"==typeof r&&null!==r?(o=r,r=void 0):void 0!==r&&null!==r||(r="");var s="";void 0!==r&&(s+=e+"="+encodeURIComponent(r));var a;return void 0!==o&&(o.additionalUA&&(a=o.additionalUA,delete o.additionalUA),s=this.as._getSearchParams(o,s)),this._search(s,t,i,a)}}t.exports=o;var n=e(31)},{31:31}],27:[function(e,t,r){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],28:[function(e,t,r){function o(e,t,r){var o={};return r=r||{},r.hosts=r.hosts||["analytics.algolia.com","analytics.algolia.com","analytics.algolia.com","analytics.algolia.com"],r.protocol=r.protocol||"https:",o.as=n(e,t,r),o.getABTests=function(e,t){var r=r||{},o=r.offset||0,n=r.limit||10;return this.as._jsonRequest({method:"GET",url:"/2/abtests?offset="+encodeURIComponent(o)+"&limit="+encodeURIComponent(n),hostType:"read",forceAuthHeaders:!0,callback:t})},o.getABTest=function(e,t){return this.as._jsonRequest({method:"GET",url:"/2/abtests/"+encodeURIComponent(e),hostType:"read",forceAuthHeaders:!0,callback:t})},o.addABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests",body:e,hostType:"read",forceAuthHeaders:!0,callback:t})},o.stopABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests/"+encodeURIComponent(e)+"/stop",hostType:"read",forceAuthHeaders:!0,callback:t})},o.deleteABTest=function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/2/abtests/"+encodeURIComponent(e),hostType:"write",forceAuthHeaders:!0,callback:t})},o.waitTask=function(e,t,r){return this.as.initIndex(e).waitTask(t,r)},o}t.exports=o;var n=e(22)},{22:22}],29:[function(e,t,r){t.exports=function(e,t){function r(){return o||(console.warn(t),o=!0),e.apply(this,arguments)}var o=!1;return r}},{}],30:[function(e,t,r){t.exports=function(e,t){var r=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+r}},{}],31:[function(e,t,r){"use strict";function o(t,r){var o=e(5),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",r&&o(r,function(e,t){n[t]=e})}function n(e,t){function r(){var r=Array.prototype.slice.call(arguments,0);"string"!=typeof r[0]&&r.unshift(t),o.apply(this,r),this.name="AlgoliaSearch"+e+"Error"}return i(r,o),r}var i=e(7);i(o,Error),t.exports={AlgoliaSearchError:o,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timed out before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail",""),window.ALGOLIA_SUPPORTS_DOCWRITE===!0?(document.write(''),n("document.write")()):r(o,n("DOMElement"))}catch(s){r(o,n("DOMElement"))}}function n(e){return function(){var t="AlgoliaSearch: loaded V2 script using "+e;window.console&&window.console.log&&window.console.log(t)}}t.exports=o},{1:1}],4:[function(e,t,r){"use strict";function o(){var e="-- AlgoliaSearch V2 => V3 error --\nYou are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\nPlease read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n-- /AlgoliaSearch V2 => V3 error --";window.AlgoliaSearch=function(){throw new Error(e)},window.AlgoliaSearchHelper=function(){throw new Error(e)},window.AlgoliaExplainResults=function(){throw new Error(e)}}t.exports=o},{}],5:[function(e,t,r){"use strict";function o(t){var r=e(2),o=e(3),n=e(4);r(t)?o(t):n()}o("algoliasearch.jquery")},{2:2,3:3,4:4}]},{},[5])(5)}),function e(t,r,o){function n(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return n(r?r:e)},l,l.exports,e,t,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,o)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function c(){var e;try{e=r.storage.debug}catch(t){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e(2),r.log=s,r.formatArgs=i,r.save=a,r.load=c,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(c())}).call(this,e(12))},{12:12,2:2}],2:[function(e,t,r){function o(e){var t,o=0;for(t in e)o=(o<<5)-o+e.charCodeAt(t),o|=0;return r.colors[Math.abs(o)%r.colors.length]}function n(e){function t(){if(t.enabled){var e=t,o=+new Date,n=o-(u||o);e.diff=n,e.prev=u,e.curr=o,u=o;for(var i=new Array(arguments.length),s=0;s0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},o.prototype.removeListener=function(e,t){var r,o,i,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],i=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=i;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},o.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],5:[function(e,t,r){var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var s=0;s100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*c;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=u?Math.round(e/u)+"h":e>=c?Math.round(e/c)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,l,"day")||s(e,u,"hour")||s(e,c,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,r){if(!(e0)return o(e);if("number"===r&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],10:[function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,s=e(11),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},d={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),f=function(e){if("undefined"==typeof window||!h)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===n.call(e),i=s(e),a=t&&"[object String]"===n.call(e),p=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=u&&r;if(a&&e.length>0&&!o.call(e,0))for(var h=0;h0)for(var y=0;y=0&&"[object Function]"===o.call(e.callee)),r}},{}],12:[function(e,t,r){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===o||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(d===clearTimeout)return clearTimeout(e);if((d===n||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){m&&f&&(m=!1,f.length?y=f.concat(y):v=-1,y.length&&c())}function c(){if(!m){var e=i(a);m=!0;for(var t=y.length;t;){for(f=y,y=[];++v1)for(var r=1;r0&&u>c&&(u=c);for(var l=0;l=0?(p=y.substr(0,m),d=y.substr(m+1)):(p=y,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),o(s,h)?n(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],14:[function(e,t,r){"use strict";function o(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o0)n.scope=r;else if("undefined"!=typeof r)throw new Error("the scope given to `copyIndex` was not an array with settings, synonyms or rules");return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:n,hostType:"write",callback:i})},o.prototype.getLogs=function(t,r,o){var n=e(27),i={};return"object"==typeof t?(i=n(t),o=r):0===arguments.length||"function"==typeof t?o=t:1===arguments.length||"function"==typeof r?(o=r,i.offset=t):(i.offset=t,i.length=r),void 0===i.offset&&(i.offset=0),void 0===i.length&&(i.length=10),this._jsonRequest({method:"GET",url:"/1/logs?"+this._getSearchParams(i,""),hostType:"read",callback:o})},o.prototype.listIndexes=function(e,t){var r="";return void 0===e||"function"==typeof e?t=e:r="?page="+e,this._jsonRequest({method:"GET",url:"/1/indexes"+r,hostType:"read",callback:t})},o.prototype.initIndex=function(e){return new i(this,e)},o.prototype.initAnalytics=function(t){var r=e(28);return r(this.applicationID,this.apiKey,t)},o.prototype.listUserKeys=s(function(e){return this.listApiKeys(e)},a("client.listUserKeys()","client.listApiKeys()")),o.prototype.listApiKeys=function(e){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:e})},o.prototype.getUserKeyACL=s(function(e,t){return this.getApiKey(e,t)},a("client.getUserKeyACL()","client.getApiKey()")),o.prototype.getApiKey=function(e,t){return this._jsonRequest({method:"GET",url:"/1/keys/"+e,hostType:"read",callback:t})},o.prototype.deleteUserKey=s(function(e,t){return this.deleteApiKey(e,t)},a("client.deleteUserKey()","client.deleteApiKey()")),o.prototype.deleteApiKey=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+e,hostType:"write",callback:t})},o.prototype.restoreApiKey=function(e,t){return this._jsonRequest({method:"POST",url:"/1/keys/"+e+"/restore",hostType:"write",callback:t})},o.prototype.addUserKey=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKey()","client.addApiKey()")),o.prototype.addApiKey=function(t,r,o){var n=e(8),i="Usage: client.addApiKey(arrayOfAcls[, params, callback])";if(!n(t))throw new Error(i);1!==arguments.length&&"function"!=typeof r||(o=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.indexes=r.indexes,s.description=r.description,r.queryParameters&&(s.queryParameters=this._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this._jsonRequest({method:"POST",url:"/1/keys",body:s,hostType:"write",callback:o})},o.prototype.addUserKeyWithValidity=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKeyWithValidity()","client.addApiKey()")),o.prototype.updateUserKey=s(function(e,t,r,o){return this.updateApiKey(e,t,r,o)},a("client.updateUserKey()","client.updateApiKey()")),o.prototype.updateApiKey=function(t,r,o,n){var i=e(8),s="Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])";if(!i(r))throw new Error(s);2!==arguments.length&&"function"!=typeof o||(n=o,o=null);var a={acl:r};return o&&(a.validity=o.validity,a.maxQueriesPerIPPerHour=o.maxQueriesPerIPPerHour,a.maxHitsPerQuery=o.maxHitsPerQuery,a.indexes=o.indexes,a.description=o.description,o.queryParameters&&(a.queryParameters=this._getSearchParams(o.queryParameters,"")),a.referers=o.referers),this._jsonRequest({method:"PUT",url:"/1/keys/"+t,body:a,hostType:"write",callback:n})},o.prototype.startQueriesBatch=s(function(){this._batch=[]},a("client.startQueriesBatch()","client.search()")),o.prototype.addQueryInBatch=s(function(e,t,r){this._batch.push({indexName:e,query:t,params:r})},a("client.addQueryInBatch()","client.search()")),o.prototype.sendQueriesBatch=s(function(e){return this.search(this._batch,e)},a("client.sendQueriesBatch()","client.search()")),o.prototype.batch=function(t,r){var o=e(8),n="Usage: client.batch(operations[, callback])";if(!o(t))throw new Error(n);return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:t},hostType:"write",callback:r})},o.prototype.assignUserID=function(e,t){if(!e.userID||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both a userID and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping",hostType:"write",body:{cluster:e.cluster},callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.assignUserIDs=function(e,t){if(!e.userIDs||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both an array of userIDs and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/batch",hostType:"write",body:{cluster:e.cluster,users:e.userIDs},callback:t})},o.prototype.getTopUserID=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/top",hostType:"read",callback:e})},o.prototype.getUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/"+e.userID,hostType:"read",callback:t})},o.prototype.listClusters=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters",hostType:"read",callback:e})},o.prototype.listUserIDs=function(e,t){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping",body:e,hostType:"read",callback:t})},o.prototype.removeUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"DELETE",url:"/1/clusters/mapping",hostType:"write",callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.searchUserIDs=function(e,t){return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/search",body:e,hostType:"read",callback:t})},o.prototype.setPersonalizationStrategy=function(e,t){return this._jsonRequest({method:"POST",url:"/1/recommendation/personalization/strategy",body:e,hostType:"write",callback:t})},o.prototype.getPersonalizationStrategy=function(e){return this._jsonRequest({method:"GET",url:"/1/recommendation/personalization/strategy",hostType:"read",callback:e})},o.prototype.destroy=n,o.prototype.enableRateLimitForward=n,o.prototype.disableRateLimitForward=n,o.prototype.useSecuredAPIKey=n,o.prototype.disableSecuredAPIKey=n,o.prototype.generateSecuredApiKey=n,o.prototype.getSecuredApiKeyRemainingValidity=n},{17:17,18:18,27:27,28:28,29:29,30:30,31:31,7:7,8:8}],17:[function(e,t,r){(function(r){function o(t,r,o){var i=e(1)("algoliasearch"),s=e(27),a=e(8),u=e(33),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(o._allowEmptyCredentials!==!0&&!t)throw new c.AlgoliaSearchError("Please provide an application ID. "+l);if(o._allowEmptyCredentials!==!0&&!r)throw new c.AlgoliaSearchError("Please provide an API key. "+l); -this.applicationID=t,this.apiKey=r,this.hosts={read:[],write:[]},o=o||{},this._timeouts=o.timeouts||{connect:1e3,read:2e3,write:3e4},o.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=o.timeout);var p=o.protocol||"https:";if(/:$/.test(p)||(p+=":"),"http:"!==p&&"https:"!==p)throw new c.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+o.protocol+"`)");if(this._checkAppIdData(),o.hosts)a(o.hosts)?(this.hosts.read=s(o.hosts),this.hosts.write=s(o.hosts)):(this.hosts.read=s(o.hosts.read),this.hosts.write=s(o.hosts.write));else{var d=u(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"}),h=(o.dsn===!1?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+h].concat(d),this.hosts.write=[this.applicationID+".algolia.net"].concat(d)}this.hosts.read=u(this.hosts.read,n(p)),this.hosts.write=u(this.hosts.write,n(p)),this.extraHeaders={},this.cache=o._cache||{},this._ua=o._ua,this._useCache=!(void 0!==o._useCache&&!o._cache)||o._useCache,this._useRequestCache=this._useCache&&o._useRequestCache,this._useFallback=void 0===o.useFallback||o.useFallback,this._setTimeout=o._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var r=JSON.stringify(e);return Array.prototype.toJSON=t,r}function s(e){for(var t,r,o=e.length;0!==o;)r=Math.floor(Math.random()*o),o-=1,t=e[o],e[o]=e[r],e[r]=t;return e}function a(e){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o;o="x-algolia-api-key"===r||"x-algolia-application-id"===r?"**hidden for security purposes**":e[r],t[r]=o}return t}t.exports=o;var c=e(31),u=e(32),l=e(20),p=e(37),d=500,h=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;o.prototype.initIndex=function(e){return new l(this,e)},o.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},o.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},o.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},o.prototype.addAlgoliaAgent=function(e){var t="; "+e;this._ua.indexOf(t)===-1&&(this._ua+=t)},o.prototype._jsonRequest=function(t){function r(e,n){function u(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;h("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var r=2===Math.floor(t/100),o=new Date;if(w.push({currentHost:R,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:o,duration:o-x,statusCode:t}),r)return m._useCache&&!m._useRequestCache&&y&&(y[l]=e.responseText),{responseText:e.responseText,body:e.body};var i=4!==Math.floor(t/100);if(i)return v+=1,_();h("unrecoverable error");var u=new c.AlgoliaSearchError(e.body&&e.body.message,{debugData:w,statusCode:t});return m._promise.reject(u)}function d(e){h("error: %s, stack: %s",e.message,e.stack);var r=new Date;return w.push({currentHost:R,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:r,duration:r-x}),e instanceof c.AlgoliaSearchError||(e=new c.Unknown(e&&e.message,e)),v+=1,e instanceof c.Unknown||e instanceof c.UnparsableJSON||v>=m.hosts[t.hostType].length&&(g||!b)?(e.debugData=w,m._promise.reject(e)):e instanceof c.RequestTimeout?T():_()}function _(){return h("retrying request"),m._incrementHostIndex(t.hostType),r(e,n)}function T(){return h("retrying request with higher timeout"),m._incrementHostIndex(t.hostType),m._incrementTimeoutMultipler(),n.timeouts=m._getTimeoutsForRequest(t.hostType),r(e,n)}m._checkAppIdData();var x=new Date;if(m._useCache&&!m._useRequestCache&&(l=t.url),m._useCache&&!m._useRequestCache&&s&&(l+="_body_"+n.body),o(!m._useRequestCache,y,l)){h("serving response from cache");var j=y[l];return m._promise.resolve({body:JSON.parse(j),responseText:j})}if(v>=m.hosts[t.hostType].length)return!b||g?(h("could not get any response"),m._promise.reject(new c.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+m.applicationID,{debugData:w}))):(h("switching to fallback"),v=0,n.method=t.fallback.method,n.url=t.fallback.url,n.jsonBody=t.fallback.body,n.jsonBody&&(n.body=i(n.jsonBody)),p=m._computeRequestHeaders({additionalUA:f,headers:t.headers}),n.timeouts=m._getTimeoutsForRequest(t.hostType),m._setHostIndexByType(0,t.hostType),g=!0,r(m._request.fallback,n));var R=m._getHostByType(t.hostType),A=R+n.url,S={body:n.body,jsonBody:n.jsonBody,method:n.method,headers:p,timeouts:n.timeouts,debug:h,forceAuthHeaders:n.forceAuthHeaders};return h("method: %s, url: %s, headers: %j, timeouts: %d",S.method,A,S.headers,S.timeouts),e===m._request.fallback&&h("using fallback"),e.call(m,A,S).then(u,d)}function o(e,t,r){return m._useCache&&e&&t&&void 0!==t[r]}function n(e,r){return o(m._useRequestCache,y,l)&&e["catch"](function(){delete y[l]}),"function"!=typeof t.callback?e.then(r):void e.then(function(e){u(function(){t.callback(null,r(e))},m._setTimeout||setTimeout)},function(e){u(function(){t.callback(e)},m._setTimeout||setTimeout)})}this._checkAppIdData();var s,l,p,h=e(1)("algoliasearch:"+t.url),f=t.additionalUA||"",y=t.cache,m=this,v=0,g=!1,b=m._useFallback&&m._request.fallback&&t.fallback;this.apiKey.length>d&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,p=this._computeRequestHeaders({additionalUA:f,withApiKey:!1,headers:t.headers})):p=this._computeRequestHeaders({additionalUA:f,headers:t.headers}),void 0!==t.body&&(s=i(t.body)),h("request start");var w=[];if(m._useCache&&m._useRequestCache&&(l=t.url),m._useCache&&m._useRequestCache&&s&&(l+="_body_"+s),o(m._useRequestCache,y,l)){h("serving request from cache");var _=y[l],T="function"!=typeof _.then?m._promise.resolve({responseText:_}):_;return n(T,function(e){return JSON.parse(e.responseText)})}var x=r(m._request,{url:t.url,method:t.method,body:s,jsonBody:t.body,timeouts:m._getTimeoutsForRequest(t.hostType),forceAuthHeaders:t.forceAuthHeaders});return m._useCache&&m._useRequestCache&&y&&(y[l]=x),n(x,function(e){return e.body})},o.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var r in e)null!==r&&void 0!==e[r]&&e.hasOwnProperty(r)&&(t+=""===t?"":"&",t+=r+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[r])?i(e[r]):e[r]));return t},o.prototype._computeRequestHeaders=function(t){var r=e(5),o=t.additionalUA?this._ua+"; "+t.additionalUA:this._ua,n={"x-algolia-agent":o,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),r(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&r(t.headers,function(e,t){n[t]=e}),n},o.prototype.search=function(t,r,o){var n=e(8),i=e(33),s="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(s);"function"==typeof r?(o=r,r={}):void 0===r&&(r={});var a=this,c={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}})},u=i(c.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==r.strategy&&(c.strategy=r.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:c,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:o})},o.prototype.searchForFacetValues=function(t){var r=e(8),o=e(33),n="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!r(t))throw new Error(n);var i=this;return i._promise.all(o(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(n);var r=e(27),o=e(35),s=t.indexName,a=t.params,c=a.facetName,u=o(r(a),function(e){return"facetName"===e}),l=i._getSearchParams(u,"");return i._jsonRequest({cache:i.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(s)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})}))},o.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],r=0;rh?this._resetInitialAppIdData(e):e},o.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||s([1,2,3]),this._setAppIdData(t)},o.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},o.prototype._partialAppIdDataUpdate=function(t){var r=e(5),o=this._getAppIdData();return r(t,function(e,t){o[t]=e}),this._setAppIdData(o)},o.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},o.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},o.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},o.prototype._setHostIndexByType=function(t,r){var o=e(27),n=o(this._hostIndexes);return n[r]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},o.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},o.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},o.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(12))},{1:1,12:12,20:20,27:27,31:31,32:32,33:33,35:35,37:37,5:5,8:8}],18:[function(e,t,r){function o(){s.apply(this,arguments)}function n(e,t,r){function o(r,n){var i={page:r||0,hitsPerPage:t||100},s=n||[];return e(i).then(function(e){var t=e.hits,r=e.nbHits,n=t.map(function(e){return delete e._highlightResult,e}),a=s.concat(n);return a.lengths&&(t=s),"published"!==e.status?l._promise.delay(t).then(r):e})}function o(e){u(function(){t(null,e)},l._setTimeout||setTimeout)}function n(e){u(function(){t(e)},l._setTimeout||setTimeout)}var i=100,s=5e3,a=0,c=this,l=c.as,p=r();return t?void p.then(o,n):p},o.prototype.clearIndex=function(e){var t=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(t.indexName)+"/clear",hostType:"write",callback:e})},o.prototype.getSettings=function(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),e=e||{};var r=encodeURIComponent(this.indexName);return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+r+"/settings?getVersion=2"+(e.advanced?"&advanced="+e.advanced:""),hostType:"read",callback:t})},o.prototype.searchSynonyms=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/search",body:e,hostType:"read",callback:t})},o.prototype.exportSynonyms=function(e,t){return n(this.searchSynonyms.bind(this),e,t)},o.prototype.saveSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getSynonym=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearSynonyms=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),void 0!==e.forwardToSlaves&&p();var r=e.forwardToSlaves||e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchSynonyms=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/batch?forwardToReplicas="+o+"&replaceExistingSynonyms="+(t.replaceExistingSynonyms?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.searchRules=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/search",body:e,hostType:"read",callback:t})},o.prototype.exportRules=function(e,t){return n(this.searchRules.bind(this),e,t)},o.prototype.saveRule=function(e,t,r){if("function"==typeof t?(r=t,t={}):void 0===t&&(t={}),!e.objectID)throw new l.AlgoliaSearchError("Missing or empty objectID field for rule");var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getRule=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteRule=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearRules=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={});var r=e.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchRules=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/batch?forwardToReplicas="+o+"&clearExistingRules="+(t.clearExistingRules===!0?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.exists=function(e){var t=this.getSettings().then(function(){return!0})["catch"](function(e){if(e instanceof l.AlgoliaSearchError&&404===e.statusCode)return!1;throw e});return"function"!=typeof e?t:void t.then(function(t){e(null,t)})["catch"](function(t){e(t)})},o.prototype.findObject=function(e,t,r){t=void 0===t?{}:t;var o=void 0===t.paginate||t.paginate,n=void 0!==t.query?t.query:"",i=this,s=0,a=function(){return t.page=s,i.search(n,t).then(function(t){for(var r=t.hits,n=0;n=t.nbPages)throw new l.ObjectNotFound("Object not found");return a()})},c=a(s);return void 0===r?c:void c.then(function(e){r(null,e)})["catch"](function(e){r(e)})},o.prototype.getObjectPosition=function(e,t){for(var r=e.hits,o=0;o1&&a()}if(!h.cors&&!h.hasXDomainRequest)return void o(new u.Network("CORS not supported")); -e=l(e,t.headers);var d,f,y=t.body,m=h.cors?new XMLHttpRequest:new XDomainRequest,v=!1;d=setTimeout(s,t.timeouts.connect),m.onprogress=c,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?(m.open(t.method,e,!0),t.forceAuthHeaders&&(m.setRequestHeader("x-algolia-application-id",t.headers["x-algolia-application-id"]),m.setRequestHeader("x-algolia-api-key",t.headers["x-algolia-api-key"]))):m.open(t.method,e),h.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),y?m.send(y):m.send()})},a.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(r,o){p(e,t,function(e,t){return e?void o(e):void r(t)})})},a.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})},all:function(e){return n.all(e)}},s}}).call(this,e(12))},{1:1,12:12,24:24,25:25,27:27,3:3,31:31,36:36,38:38,6:6,7:7}],24:[function(e,t,r){"use strict";function o(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=o;var n=e(14)},{14:14}],25:[function(e,t,r){"use strict";function o(e,t,r){function o(){t.debug("JSONP: success"),m||d||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"),a(),r(new n.JSONPScriptFail)))}function s(){"loaded"!==this.readyState&&"complete"!==this.readyState||o()}function a(){clearTimeout(v),f.onload=null,f.onreadystatechange=null,f.onerror=null,h.removeChild(f)}function c(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function u(){t.debug("JSONP: Script timeout"),d=!0,a(),r(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||d||(a(),r(new n.JSONPScriptError))}if("GET"!==t.method)return void r(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,d=!1;i+=1;var h=document.getElementsByTagName("head")[0],f=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return c(),d?void t.debug("JSONP: Late answer, ignoring"):(p=!0,a(),void r(null,{body:e,responseText:JSON.stringify(e)}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var v=setTimeout(u,t.timeouts.complete);f.onreadystatechange=s,f.onload=o,f.onerror=l,f.async=!0,f.defer=!0,f.src=e,h.appendChild(f)}t.exports=o;var n=e(31),i=0},{31:31}],26:[function(e,t,r){function o(e,t){return function(r,o,i){if("function"==typeof r&&"object"==typeof o||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof r?(i=r,r=""):1!==arguments.length&&"function"!=typeof o||(i=o,o=void 0),"object"==typeof r&&null!==r?(o=r,r=void 0):void 0!==r&&null!==r||(r="");var s="";void 0!==r&&(s+=e+"="+encodeURIComponent(r));var a;return void 0!==o&&(o.additionalUA&&(a=o.additionalUA,delete o.additionalUA),s=this.as._getSearchParams(o,s)),this._search(s,t,i,a)}}t.exports=o;var n=e(31)},{31:31}],27:[function(e,t,r){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],28:[function(e,t,r){function o(e,t,r){var o={};return r=r||{},r.hosts=r.hosts||["analytics.algolia.com","analytics.algolia.com","analytics.algolia.com","analytics.algolia.com"],r.protocol=r.protocol||"https:",o.as=n(e,t,r),o.getABTests=function(e,t){var r=r||{},o=r.offset||0,n=r.limit||10;return this.as._jsonRequest({method:"GET",url:"/2/abtests?offset="+encodeURIComponent(o)+"&limit="+encodeURIComponent(n),hostType:"read",forceAuthHeaders:!0,callback:t})},o.getABTest=function(e,t){return this.as._jsonRequest({method:"GET",url:"/2/abtests/"+encodeURIComponent(e),hostType:"read",forceAuthHeaders:!0,callback:t})},o.addABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests",body:e,hostType:"read",forceAuthHeaders:!0,callback:t})},o.stopABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests/"+encodeURIComponent(e)+"/stop",hostType:"read",forceAuthHeaders:!0,callback:t})},o.deleteABTest=function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/2/abtests/"+encodeURIComponent(e),hostType:"write",forceAuthHeaders:!0,callback:t})},o.waitTask=function(e,t,r){return this.as.initIndex(e).waitTask(t,r)},o}t.exports=o;var n=e(22)},{22:22}],29:[function(e,t,r){t.exports=function(e,t){function r(){return o||(console.warn(t),o=!0),e.apply(this,arguments)}var o=!1;return r}},{}],30:[function(e,t,r){t.exports=function(e,t){var r=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+r}},{}],31:[function(e,t,r){"use strict";function o(t,r){var o=e(5),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",r&&o(r,function(e,t){n[t]=e})}function n(e,t){function r(){var r=Array.prototype.slice.call(arguments,0);"string"!=typeof r[0]&&r.unshift(t),o.apply(this,r),this.name="AlgoliaSearch"+e+"Error"}return i(r,o),r}var i=e(7);i(o,Error),t.exports={AlgoliaSearchError:o,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timed out before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail",""),window.ALGOLIA_SUPPORTS_DOCWRITE===!0?(document.write(''),n("document.write")()):r(o,n("DOMElement"))}catch(s){r(o,n("DOMElement"))}}function n(e){return function(){var t="AlgoliaSearch: loaded V2 script using "+e;window.console&&window.console.log&&window.console.log(t)}}t.exports=o},{1:1}],4:[function(e,t,r){"use strict";function o(){var e="-- AlgoliaSearch V2 => V3 error --\nYou are trying to use a new version of the AlgoliaSearch JavaScript client with an old notation.\nPlease read our migration guide at https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x\n-- /AlgoliaSearch V2 => V3 error --";window.AlgoliaSearch=function(){throw new Error(e)},window.AlgoliaSearchHelper=function(){throw new Error(e)},window.AlgoliaExplainResults=function(){throw new Error(e)}}t.exports=o},{}],5:[function(e,t,r){"use strict";function o(t){var r=e(2),o=e(3),n=e(4);r(t)?o(t):n()}o("algoliasearch")},{2:2,3:3,4:4}]},{},[5])(5)}),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.algoliasearch=e()}}(function(){var e;return function t(e,r,o){function n(s,a){if(!r[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return n(r?r:t)},l,l.exports,t,e,r,o)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,o)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function c(){var e;try{e=r.storage.debug}catch(t){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e(2),r.log=s,r.formatArgs=i,r.save=a,r.load=c,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(c())}).call(this,e(12))},{12:12,2:2}],2:[function(e,t,r){function o(e){var t,o=0;for(t in e)o=(o<<5)-o+e.charCodeAt(t),o|=0;return r.colors[Math.abs(o)%r.colors.length]}function n(e){function t(){if(t.enabled){var e=t,o=+new Date,n=o-(u||o);e.diff=n,e.prev=u,e.curr=o,u=o;for(var i=new Array(arguments.length),s=0;s0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},o.prototype.on=o.prototype.addListener,o.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},o.prototype.removeListener=function(e,t){var r,o,i,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],i=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=i;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},o.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},o.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},o.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},o.listenerCount=function(e,t){return e.listenerCount(t)}},{}],5:[function(e,t,r){var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var s=0;s100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*c;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=u?Math.round(e/u)+"h":e>=c?Math.round(e/c)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,l,"day")||s(e,u,"hour")||s(e,c,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,r){if(!(e0)return o(e);if("number"===r&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],10:[function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,s=e(11),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},d={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),f=function(e){if("undefined"==typeof window||!h)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===n.call(e),i=s(e),a=t&&"[object String]"===n.call(e),p=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var d=u&&r;if(a&&e.length>0&&!o.call(e,0))for(var h=0;h0)for(var y=0;y=0&&"[object Function]"===o.call(e.callee)),r}},{}],12:[function(e,t,r){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===o||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(d===clearTimeout)return clearTimeout(e);if((d===n||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){m&&f&&(m=!1,f.length?y=f.concat(y):v=-1,y.length&&c())}function c(){if(!m){var e=i(a);m=!0;for(var t=y.length;t;){for(f=y,y=[];++v1)for(var r=1;r0&&u>c&&(u=c);for(var l=0;l=0?(p=y.substr(0,m),d=y.substr(m+1)):(p=y,d=""),h=decodeURIComponent(p),f=decodeURIComponent(d),o(s,h)?n(s[h])?s[h].push(f):s[h]=[s[h],f]:s[h]=f}return s};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],14:[function(e,t,r){"use strict";function o(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o0)n.scope=r;else if("undefined"!=typeof r)throw new Error("the scope given to `copyIndex` was not an array with settings, synonyms or rules");return this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(e)+"/operation",body:n,hostType:"write",callback:i})},o.prototype.getLogs=function(t,r,o){var n=e(26),i={};return"object"==typeof t?(i=n(t),o=r):0===arguments.length||"function"==typeof t?o=t:1===arguments.length||"function"==typeof r?(o=r,i.offset=t):(i.offset=t,i.length=r),void 0===i.offset&&(i.offset=0),void 0===i.length&&(i.length=10),this._jsonRequest({method:"GET",url:"/1/logs?"+this._getSearchParams(i,""),hostType:"read",callback:o})},o.prototype.listIndexes=function(e,t){var r="";return void 0===e||"function"==typeof e?t=e:r="?page="+e,this._jsonRequest({method:"GET",url:"/1/indexes"+r,hostType:"read",callback:t})},o.prototype.initIndex=function(e){return new i(this,e)},o.prototype.initAnalytics=function(t){var r=e(27);return r(this.applicationID,this.apiKey,t)},o.prototype.listUserKeys=s(function(e){return this.listApiKeys(e)},a("client.listUserKeys()","client.listApiKeys()")),o.prototype.listApiKeys=function(e){return this._jsonRequest({method:"GET",url:"/1/keys",hostType:"read",callback:e})},o.prototype.getUserKeyACL=s(function(e,t){return this.getApiKey(e,t)},a("client.getUserKeyACL()","client.getApiKey()")),o.prototype.getApiKey=function(e,t){return this._jsonRequest({method:"GET",url:"/1/keys/"+e,hostType:"read",callback:t})},o.prototype.deleteUserKey=s(function(e,t){return this.deleteApiKey(e,t)},a("client.deleteUserKey()","client.deleteApiKey()")),o.prototype.deleteApiKey=function(e,t){return this._jsonRequest({method:"DELETE",url:"/1/keys/"+e,hostType:"write",callback:t})},o.prototype.restoreApiKey=function(e,t){return this._jsonRequest({method:"POST",url:"/1/keys/"+e+"/restore",hostType:"write",callback:t})},o.prototype.addUserKey=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKey()","client.addApiKey()")),o.prototype.addApiKey=function(t,r,o){var n=e(8),i="Usage: client.addApiKey(arrayOfAcls[, params, callback])";if(!n(t))throw new Error(i);1!==arguments.length&&"function"!=typeof r||(o=r,r=null);var s={acl:t};return r&&(s.validity=r.validity,s.maxQueriesPerIPPerHour=r.maxQueriesPerIPPerHour,s.maxHitsPerQuery=r.maxHitsPerQuery,s.indexes=r.indexes,s.description=r.description,r.queryParameters&&(s.queryParameters=this._getSearchParams(r.queryParameters,"")),s.referers=r.referers),this._jsonRequest({method:"POST",url:"/1/keys",body:s,hostType:"write",callback:o})},o.prototype.addUserKeyWithValidity=s(function(e,t,r){return this.addApiKey(e,t,r)},a("client.addUserKeyWithValidity()","client.addApiKey()")),o.prototype.updateUserKey=s(function(e,t,r,o){return this.updateApiKey(e,t,r,o)},a("client.updateUserKey()","client.updateApiKey()")),o.prototype.updateApiKey=function(t,r,o,n){var i=e(8),s="Usage: client.updateApiKey(key, arrayOfAcls[, params, callback])";if(!i(r))throw new Error(s);2!==arguments.length&&"function"!=typeof o||(n=o,o=null);var a={acl:r};return o&&(a.validity=o.validity,a.maxQueriesPerIPPerHour=o.maxQueriesPerIPPerHour,a.maxHitsPerQuery=o.maxHitsPerQuery,a.indexes=o.indexes,a.description=o.description,o.queryParameters&&(a.queryParameters=this._getSearchParams(o.queryParameters,"")),a.referers=o.referers),this._jsonRequest({method:"PUT",url:"/1/keys/"+t,body:a,hostType:"write",callback:n})},o.prototype.startQueriesBatch=s(function(){this._batch=[]},a("client.startQueriesBatch()","client.search()")),o.prototype.addQueryInBatch=s(function(e,t,r){this._batch.push({indexName:e,query:t,params:r})},a("client.addQueryInBatch()","client.search()")),o.prototype.sendQueriesBatch=s(function(e){return this.search(this._batch,e)},a("client.sendQueriesBatch()","client.search()")),o.prototype.batch=function(t,r){var o=e(8),n="Usage: client.batch(operations[, callback])";if(!o(t))throw new Error(n);return this._jsonRequest({method:"POST",url:"/1/indexes/*/batch",body:{requests:t},hostType:"write",callback:r})},o.prototype.assignUserID=function(e,t){if(!e.userID||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both a userID and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping",hostType:"write",body:{cluster:e.cluster},callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.assignUserIDs=function(e,t){if(!e.userIDs||!e.cluster)throw new l.AlgoliaSearchError("You have to provide both an array of userIDs and cluster",e);return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/batch",hostType:"write",body:{cluster:e.cluster,users:e.userIDs},callback:t})},o.prototype.getTopUserID=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/top",hostType:"read",callback:e})},o.prototype.getUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"GET",url:"/1/clusters/mapping/"+e.userID,hostType:"read",callback:t})},o.prototype.listClusters=function(e){return this._jsonRequest({method:"GET",url:"/1/clusters",hostType:"read",callback:e})},o.prototype.listUserIDs=function(e,t){return this._jsonRequest({method:"GET",url:"/1/clusters/mapping",body:e,hostType:"read",callback:t})},o.prototype.removeUserID=function(e,t){if(!e.userID)throw new l.AlgoliaSearchError("You have to provide a userID",{debugData:e});return this._jsonRequest({method:"DELETE",url:"/1/clusters/mapping",hostType:"write",callback:t,headers:{"x-algolia-user-id":e.userID}})},o.prototype.searchUserIDs=function(e,t){return this._jsonRequest({method:"POST",url:"/1/clusters/mapping/search",body:e,hostType:"read",callback:t})},o.prototype.setPersonalizationStrategy=function(e,t){return this._jsonRequest({method:"POST",url:"/1/recommendation/personalization/strategy",body:e,hostType:"write",callback:t})},o.prototype.getPersonalizationStrategy=function(e){return this._jsonRequest({method:"GET",url:"/1/recommendation/personalization/strategy",hostType:"read",callback:e})},o.prototype.destroy=n,o.prototype.enableRateLimitForward=n,o.prototype.disableRateLimitForward=n,o.prototype.useSecuredAPIKey=n,o.prototype.disableSecuredAPIKey=n,o.prototype.generateSecuredApiKey=n,o.prototype.getSecuredApiKeyRemainingValidity=n},{17:17,18:18,26:26,27:27,28:28,29:29,30:30,7:7,8:8}],17:[function(e,t,r){ -(function(r){function o(t,r,o){var i=e(1)("algoliasearch"),s=e(26),a=e(8),u=e(32),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(o._allowEmptyCredentials!==!0&&!t)throw new c.AlgoliaSearchError("Please provide an application ID. "+l);if(o._allowEmptyCredentials!==!0&&!r)throw new c.AlgoliaSearchError("Please provide an API key. "+l);this.applicationID=t,this.apiKey=r,this.hosts={read:[],write:[]},o=o||{},this._timeouts=o.timeouts||{connect:1e3,read:2e3,write:3e4},o.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=o.timeout);var p=o.protocol||"https:";if(/:$/.test(p)||(p+=":"),"http:"!==p&&"https:"!==p)throw new c.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+o.protocol+"`)");if(this._checkAppIdData(),o.hosts)a(o.hosts)?(this.hosts.read=s(o.hosts),this.hosts.write=s(o.hosts)):(this.hosts.read=s(o.hosts.read),this.hosts.write=s(o.hosts.write));else{var d=u(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"}),h=(o.dsn===!1?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+h].concat(d),this.hosts.write=[this.applicationID+".algolia.net"].concat(d)}this.hosts.read=u(this.hosts.read,n(p)),this.hosts.write=u(this.hosts.write,n(p)),this.extraHeaders={},this.cache=o._cache||{},this._ua=o._ua,this._useCache=!(void 0!==o._useCache&&!o._cache)||o._useCache,this._useRequestCache=this._useCache&&o._useRequestCache,this._useFallback=void 0===o.useFallback||o.useFallback,this._setTimeout=o._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var r=JSON.stringify(e);return Array.prototype.toJSON=t,r}function s(e){for(var t,r,o=e.length;0!==o;)r=Math.floor(Math.random()*o),o-=1,t=e[o],e[o]=e[r],e[r]=t;return e}function a(e){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o;o="x-algolia-api-key"===r||"x-algolia-application-id"===r?"**hidden for security purposes**":e[r],t[r]=o}return t}t.exports=o;var c=e(30),u=e(31),l=e(20),p=e(36),d=500,h=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;o.prototype.initIndex=function(e){return new l(this,e)},o.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},o.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},o.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},o.prototype.addAlgoliaAgent=function(e){var t="; "+e;this._ua.indexOf(t)===-1&&(this._ua+=t)},o.prototype._jsonRequest=function(t){function r(e,n){function u(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;h("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var r=2===Math.floor(t/100),o=new Date;if(w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:o,duration:o-x,statusCode:t}),r)return m._useCache&&!m._useRequestCache&&y&&(y[l]=e.responseText),{responseText:e.responseText,body:e.body};var i=4!==Math.floor(t/100);if(i)return v+=1,_();h("unrecoverable error");var u=new c.AlgoliaSearchError(e.body&&e.body.message,{debugData:w,statusCode:t});return m._promise.reject(u)}function d(e){h("error: %s, stack: %s",e.message,e.stack);var r=new Date;return w.push({currentHost:A,headers:a(p),content:s||null,contentLength:void 0!==s?s.length:null,method:n.method,timeouts:n.timeouts,url:n.url,startTime:x,endTime:r,duration:r-x}),e instanceof c.AlgoliaSearchError||(e=new c.Unknown(e&&e.message,e)),v+=1,e instanceof c.Unknown||e instanceof c.UnparsableJSON||v>=m.hosts[t.hostType].length&&(g||!b)?(e.debugData=w,m._promise.reject(e)):e instanceof c.RequestTimeout?T():_()}function _(){return h("retrying request"),m._incrementHostIndex(t.hostType),r(e,n)}function T(){return h("retrying request with higher timeout"),m._incrementHostIndex(t.hostType),m._incrementTimeoutMultipler(),n.timeouts=m._getTimeoutsForRequest(t.hostType),r(e,n)}m._checkAppIdData();var x=new Date;if(m._useCache&&!m._useRequestCache&&(l=t.url),m._useCache&&!m._useRequestCache&&s&&(l+="_body_"+n.body),o(!m._useRequestCache,y,l)){h("serving response from cache");var R=y[l];return m._promise.resolve({body:JSON.parse(R),responseText:R})}if(v>=m.hosts[t.hostType].length)return!b||g?(h("could not get any response"),m._promise.reject(new c.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+m.applicationID,{debugData:w}))):(h("switching to fallback"),v=0,n.method=t.fallback.method,n.url=t.fallback.url,n.jsonBody=t.fallback.body,n.jsonBody&&(n.body=i(n.jsonBody)),p=m._computeRequestHeaders({additionalUA:f,headers:t.headers}),n.timeouts=m._getTimeoutsForRequest(t.hostType),m._setHostIndexByType(0,t.hostType),g=!0,r(m._request.fallback,n));var A=m._getHostByType(t.hostType),j=A+n.url,S={body:n.body,jsonBody:n.jsonBody,method:n.method,headers:p,timeouts:n.timeouts,debug:h,forceAuthHeaders:n.forceAuthHeaders};return h("method: %s, url: %s, headers: %j, timeouts: %d",S.method,j,S.headers,S.timeouts),e===m._request.fallback&&h("using fallback"),e.call(m,j,S).then(u,d)}function o(e,t,r){return m._useCache&&e&&t&&void 0!==t[r]}function n(e,r){return o(m._useRequestCache,y,l)&&e["catch"](function(){delete y[l]}),"function"!=typeof t.callback?e.then(r):void e.then(function(e){u(function(){t.callback(null,r(e))},m._setTimeout||setTimeout)},function(e){u(function(){t.callback(e)},m._setTimeout||setTimeout)})}this._checkAppIdData();var s,l,p,h=e(1)("algoliasearch:"+t.url),f=t.additionalUA||"",y=t.cache,m=this,v=0,g=!1,b=m._useFallback&&m._request.fallback&&t.fallback;this.apiKey.length>d&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,p=this._computeRequestHeaders({additionalUA:f,withApiKey:!1,headers:t.headers})):p=this._computeRequestHeaders({additionalUA:f,headers:t.headers}),void 0!==t.body&&(s=i(t.body)),h("request start");var w=[];if(m._useCache&&m._useRequestCache&&(l=t.url),m._useCache&&m._useRequestCache&&s&&(l+="_body_"+s),o(m._useRequestCache,y,l)){h("serving request from cache");var _=y[l],T="function"!=typeof _.then?m._promise.resolve({responseText:_}):_;return n(T,function(e){return JSON.parse(e.responseText)})}var x=r(m._request,{url:t.url,method:t.method,body:s,jsonBody:t.body,timeouts:m._getTimeoutsForRequest(t.hostType),forceAuthHeaders:t.forceAuthHeaders});return m._useCache&&m._useRequestCache&&y&&(y[l]=x),n(x,function(e){return e.body})},o.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var r in e)null!==r&&void 0!==e[r]&&e.hasOwnProperty(r)&&(t+=""===t?"":"&",t+=r+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[r])?i(e[r]):e[r]));return t},o.prototype._computeRequestHeaders=function(t){var r=e(5),o=t.additionalUA?this._ua+"; "+t.additionalUA:this._ua,n={"x-algolia-agent":o,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),r(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&r(t.headers,function(e,t){n[t]=e}),n},o.prototype.search=function(t,r,o){var n=e(8),i=e(32),s="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(s);"function"==typeof r?(o=r,r={}):void 0===r&&(r={});var a=this,c={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}})},u=i(c.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==r.strategy&&(c.strategy=r.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:c,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:o})},o.prototype.searchForFacetValues=function(t){var r=e(8),o=e(32),n="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!r(t))throw new Error(n);var i=this;return i._promise.all(o(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(n);var r=e(26),o=e(34),s=t.indexName,a=t.params,c=a.facetName,u=o(r(a),function(e){return"facetName"===e}),l=i._getSearchParams(u,"");return i._jsonRequest({cache:i.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(s)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})}))},o.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],r=0;rh?this._resetInitialAppIdData(e):e},o.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||s([1,2,3]),this._setAppIdData(t)},o.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},o.prototype._partialAppIdDataUpdate=function(t){var r=e(5),o=this._getAppIdData();return r(t,function(e,t){o[t]=e}),this._setAppIdData(o)},o.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},o.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},o.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},o.prototype._setHostIndexByType=function(t,r){var o=e(26),n=o(this._hostIndexes);return n[r]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},o.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},o.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},o.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(12))},{1:1,12:12,20:20,26:26,30:30,31:31,32:32,34:34,36:36,5:5,8:8}],18:[function(e,t,r){function o(){s.apply(this,arguments)}function n(e,t,r){function o(r,n){var i={page:r||0,hitsPerPage:t||100},s=n||[];return e(i).then(function(e){var t=e.hits,r=e.nbHits,n=t.map(function(e){return delete e._highlightResult,e}),a=s.concat(n);return a.lengths&&(t=s),"published"!==e.status?l._promise.delay(t).then(r):e})}function o(e){u(function(){t(null,e)},l._setTimeout||setTimeout)}function n(e){u(function(){t(e)},l._setTimeout||setTimeout)}var i=100,s=5e3,a=0,c=this,l=c.as,p=r();return t?void p.then(o,n):p},o.prototype.clearIndex=function(e){var t=this;return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(t.indexName)+"/clear",hostType:"write",callback:e})},o.prototype.getSettings=function(e,t){1===arguments.length&&"function"==typeof e&&(t=e,e={}),e=e||{};var r=encodeURIComponent(this.indexName);return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+r+"/settings?getVersion=2"+(e.advanced?"&advanced="+e.advanced:""),hostType:"read",callback:t})},o.prototype.searchSynonyms=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/search",body:e,hostType:"read",callback:t})},o.prototype.exportSynonyms=function(e,t){return n(this.searchSynonyms.bind(this),e,t)},o.prototype.saveSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getSynonym=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteSynonym=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearSynonyms=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),void 0!==e.forwardToSlaves&&p();var r=e.forwardToSlaves||e.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchSynonyms=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={}),void 0!==t.forwardToSlaves&&p();var o=t.forwardToSlaves||t.forwardToReplicas?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/synonyms/batch?forwardToReplicas="+o+"&replaceExistingSynonyms="+(t.replaceExistingSynonyms?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.searchRules=function(e,t){return"function"==typeof e?(t=e,e={}):void 0===e&&(e={}),this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/search",body:e,hostType:"read",callback:t})},o.prototype.exportRules=function(e,t){return n(this.searchRules.bind(this),e,t)},o.prototype.saveRule=function(e,t,r){if("function"==typeof t?(r=t,t={}):void 0===t&&(t={}),!e.objectID)throw new l.AlgoliaSearchError("Missing or empty objectID field for rule");var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e.objectID)+"?forwardToReplicas="+o,body:e,hostType:"write",callback:r})},o.prototype.getRule=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e),hostType:"read",callback:t})},o.prototype.deleteRule=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/"+encodeURIComponent(e)+"?forwardToReplicas="+o,hostType:"write",callback:r})},o.prototype.clearRules=function(e,t){"function"==typeof e?(t=e,e={}):void 0===e&&(e={});var r=e.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/clear?forwardToReplicas="+r,hostType:"write",callback:t})},o.prototype.batchRules=function(e,t,r){"function"==typeof t?(r=t,t={}):void 0===t&&(t={});var o=t.forwardToReplicas===!0?"true":"false";return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/rules/batch?forwardToReplicas="+o+"&clearExistingRules="+(t.clearExistingRules===!0?"true":"false"),hostType:"write",body:e,callback:r})},o.prototype.exists=function(e){var t=this.getSettings().then(function(){return!0})["catch"](function(e){if(e instanceof l.AlgoliaSearchError&&404===e.statusCode)return!1;throw e});return"function"!=typeof e?t:void t.then(function(t){e(null,t)})["catch"](function(t){e(t)})},o.prototype.findObject=function(e,t,r){t=void 0===t?{}:t;var o=void 0===t.paginate||t.paginate,n=void 0!==t.query?t.query:"",i=this,s=0,a=function(){return t.page=s,i.search(n,t).then(function(t){for(var r=t.hits,n=0;n=t.nbPages)throw new l.ObjectNotFound("Object not found");return a()})},c=a(s);return void 0===r?c:void c.then(function(e){r(null,e)})["catch"](function(e){r(e)})},o.prototype.getObjectPosition=function(e,t){for(var r=e.hits,o=0;o1&&a()}if(!h.cors&&!h.hasXDomainRequest)return void o(new u.Network("CORS not supported"));e=l(e,t.headers);var d,f,y=t.body,m=h.cors?new XMLHttpRequest:new XDomainRequest,v=!1;d=setTimeout(s,t.timeouts.connect),m.onprogress=c,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?(m.open(t.method,e,!0),t.forceAuthHeaders&&(m.setRequestHeader("x-algolia-application-id",t.headers["x-algolia-application-id"]),m.setRequestHeader("x-algolia-api-key",t.headers["x-algolia-api-key"]))):m.open(t.method,e),h.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),y?m.send(y):m.send()})},a.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(r,o){p(e,t,function(e,t){return e?void o(e):void r(t)})})},a.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})},all:function(e){return n.all(e)}},s}}).call(this,e(12))},{1:1,12:12,23:23,24:24,26:26,3:3,30:30,35:35,37:37,6:6,7:7}],23:[function(e,t,r){"use strict";function o(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=o;var n=e(14)},{14:14}],24:[function(e,t,r){"use strict";function o(e,t,r){function o(){t.debug("JSONP: success"),m||d||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"), -a(),r(new n.JSONPScriptFail)))}function s(){"loaded"!==this.readyState&&"complete"!==this.readyState||o()}function a(){clearTimeout(v),f.onload=null,f.onreadystatechange=null,f.onerror=null,h.removeChild(f)}function c(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function u(){t.debug("JSONP: Script timeout"),d=!0,a(),r(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||d||(a(),r(new n.JSONPScriptError))}if("GET"!==t.method)return void r(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,d=!1;i+=1;var h=document.getElementsByTagName("head")[0],f=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return c(),d?void t.debug("JSONP: Late answer, ignoring"):(p=!0,a(),void r(null,{body:e,responseText:JSON.stringify(e)}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var v=setTimeout(u,t.timeouts.complete);f.onreadystatechange=s,f.onload=o,f.onerror=l,f.async=!0,f.defer=!0,f.src=e,h.appendChild(f)}t.exports=o;var n=e(30),i=0},{30:30}],25:[function(e,t,r){function o(e,t){return function(r,o,i){if("function"==typeof r&&"object"==typeof o||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof r?(i=r,r=""):1!==arguments.length&&"function"!=typeof o||(i=o,o=void 0),"object"==typeof r&&null!==r?(o=r,r=void 0):void 0!==r&&null!==r||(r="");var s="";void 0!==r&&(s+=e+"="+encodeURIComponent(r));var a;return void 0!==o&&(o.additionalUA&&(a=o.additionalUA,delete o.additionalUA),s=this.as._getSearchParams(o,s)),this._search(s,t,i,a)}}t.exports=o;var n=e(30)},{30:30}],26:[function(e,t,r){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],27:[function(e,t,r){function o(e,t,r){var o={};return r=r||{},r.hosts=r.hosts||["analytics.algolia.com","analytics.algolia.com","analytics.algolia.com","analytics.algolia.com"],r.protocol=r.protocol||"https:",o.as=n(e,t,r),o.getABTests=function(e,t){var r=r||{},o=r.offset||0,n=r.limit||10;return this.as._jsonRequest({method:"GET",url:"/2/abtests?offset="+encodeURIComponent(o)+"&limit="+encodeURIComponent(n),hostType:"read",forceAuthHeaders:!0,callback:t})},o.getABTest=function(e,t){return this.as._jsonRequest({method:"GET",url:"/2/abtests/"+encodeURIComponent(e),hostType:"read",forceAuthHeaders:!0,callback:t})},o.addABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests",body:e,hostType:"read",forceAuthHeaders:!0,callback:t})},o.stopABTest=function(e,t){return this.as._jsonRequest({method:"POST",url:"/2/abtests/"+encodeURIComponent(e)+"/stop",hostType:"read",forceAuthHeaders:!0,callback:t})},o.deleteABTest=function(e,t){return this.as._jsonRequest({method:"DELETE",url:"/2/abtests/"+encodeURIComponent(e),hostType:"write",forceAuthHeaders:!0,callback:t})},o.waitTask=function(e,t,r){return this.as.initIndex(e).waitTask(t,r)},o}t.exports=o;var n=e(21)},{21:21}],28:[function(e,t,r){t.exports=function(e,t){function r(){return o||(console.warn(t),o=!0),e.apply(this,arguments)}var o=!1;return r}},{}],29:[function(e,t,r){t.exports=function(e,t){var r=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+r}},{}],30:[function(e,t,r){"use strict";function o(t,r){var o=e(5),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",r&&o(r,function(e,t){n[t]=e})}function n(e,t){function r(){var r=Array.prototype.slice.call(arguments,0);"string"!=typeof r[0]&&r.unshift(t),o.apply(this,r),this.name="AlgoliaSearch"+e+"Error"}return i(r,o),r}var i=e(7);i(o,Error),t.exports={AlgoliaSearchError:o,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timed out before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail"," + diff --git a/js/autocomplete.js/test/unit/hits_spec.js b/js/autocomplete.js/test/unit/hits_spec.js new file mode 100644 index 00000000..a8f83bb5 --- /dev/null +++ b/js/autocomplete.js/test/unit/hits_spec.js @@ -0,0 +1,176 @@ +'use strict'; + +/* eslint-env mocha, jasmine */ + +describe('hits', function () { + var hitsSource = require('../../src/sources/hits.js'); + var version = require('../../version.js'); + + var client = { + _ua: 'javascript wrong agent', + search: function search(requests) { + return window.Promise.resolve({ + results: requests.map(function (request) { + return { + index: request.indexName, + hits: [ + {value: 'Q1-' + request.indexName}, + {value: 'Q2-' + request.indexName}, + {value: 'Q3-' + request.indexName} + ] + }; + }) + }); + } + }; + + it('returns results from one index', function () { + var suggestions = []; + + var f = hitsSource( + { + as: client, + indexName: 'products' + }, + {hitsPerPage: 3} + ); + + // wait only on one promise, this asserts that our "promise.resolve" trick works + f('q', function cb1(hits) { + suggestions = suggestions.concat(hits); + }); + + // force the rest of our test to be more than a microtask behind + return new Promise(function (res) { + setTimeout(res, 0); + }).then(function () { + expect(suggestions.length).toEqual(3); + expect(suggestions[0].value).toEqual('Q1-products'); + expect(suggestions[1].value).toEqual('Q2-products'); + expect(suggestions[2].value).toEqual('Q3-products'); + }); + }); + + it('returns results from multiple indices', function () { + var suggestions1 = []; + var suggestions2 = []; + + var f1 = hitsSource( + { + as: client, + indexName: 'products' + }, + {hitsPerPage: 3} + ); + var f2 = hitsSource( + { + as: client, + indexName: 'other' + }, + {hitsPerPage: 3} + ); + + f1('q', function cb1(hits) { + suggestions1 = suggestions1.concat(hits); + }); + f2('q', function cb2(hits) { + suggestions2 = suggestions2.concat(hits); + }); + + // force the rest of our test to be more than a microtask behind + return new Promise(function (res) { + setTimeout(res, 0); + }).then(function () { + expect(suggestions1.length).toEqual(3); + expect(suggestions1[0].value).toEqual('Q1-products'); + expect(suggestions1[1].value).toEqual('Q2-products'); + expect(suggestions1[2].value).toEqual('Q3-products'); + + expect(suggestions2.length).toEqual(3); + expect(suggestions2[0].value).toEqual('Q1-other'); + expect(suggestions2[1].value).toEqual('Q2-other'); + expect(suggestions2[2].value).toEqual('Q3-other'); + }); + }); + + it('calls client.search only once', function () { + var suggestions1 = []; + var suggestions2 = []; + + var searchSpy = spyOn(client, 'search').and.callThrough(); + + var f1 = hitsSource( + { + as: client, + indexName: 'products' + }, + {hitsPerPage: 3} + ); + var f2 = hitsSource( + { + as: client, + indexName: 'other' + }, + {hitsPerPage: 3} + ); + + // wait only on one promise, this asserts that our "promise.resolve" trick works + f1('q', function cb1(hits) { + suggestions1 = suggestions1.concat(hits); + }); + f2('q', function cb2(hits) { + suggestions2 = suggestions2.concat(hits); + }); + + // force the rest of our test to be more than a microtask behind + return new Promise(function (res) { + setTimeout(res, 0); + }).then(function () { + expect(searchSpy).toHaveBeenCalledTimes(1); + }); + }); + + it('does not augment the _ua if not JS client v3', function () { + expect(client._ua).toEqual('javascript wrong agent'); + + hitsSource( + { + as: client, + indexName: 'products' + }, + {hitsPerPage: 3} + ); + + expect(client._ua).toEqual('javascript wrong agent'); + }); + + it('augments the _ua once', function () { + client._ua = 'Algolia for JavaScript (3.35.0)'; + + expect(client._ua).toEqual('Algolia for JavaScript (3.35.0)'); + + hitsSource( + { + as: client, + indexName: 'products' + }, + {hitsPerPage: 3} + ); + + expect(client._ua).toEqual( + 'Algolia for JavaScript (3.35.0); autocomplete.js ' + version + ); + + hitsSource( + { + as: client, + indexName: 'something' + }, + {hitsPerPage: 70} + ); + + expect(client._ua).toEqual( + 'Algolia for JavaScript (3.35.0); autocomplete.js ' + version + ); + }); +}); diff --git a/js/autocomplete.js/version.js b/js/autocomplete.js/version.js index 09e98fbb..34aebb2a 100644 --- a/js/autocomplete.js/version.js +++ b/js/autocomplete.js/version.js @@ -1 +1 @@ -module.exports = "0.37.1"; +module.exports = "0.38.0"; diff --git a/js/autocomplete.js/yarn.lock b/js/autocomplete.js/yarn.lock deleted file mode 100644 index fef4edac..00000000 --- a/js/autocomplete.js/yarn.lock +++ /dev/null @@ -1,5485 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -JSONStream@^1.0.4: - version "1.3.0" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.0.tgz#680ab9ac6572a8a1a207e0b38721db1c77b215e5" - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -abbrev@1, abbrev@1.0.x: - version "1.0.9" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" - -accepts@1.3.3, accepts@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca" - dependencies: - mime-types "~2.1.11" - negotiator "0.6.1" - -acorn@^3.0.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" - -add-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" - -after@0.8.2: - version "0.8.2" - resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" - -align-text@^0.1.1, align-text@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" - dependencies: - kind-of "^3.0.2" - longest "^1.0.1" - repeat-string "^1.5.2" - -alphabet@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/alphabet/-/alphabet-1.0.0.tgz#0d8f81ca3f78355126d724d145487e1e4ef377c0" - -amdefine@>=0.0.4: - version "1.0.1" - resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" - -anchor-markdown-header@^0.5.5: - version "0.5.6" - resolved "https://registry.yarnpkg.com/anchor-markdown-header/-/anchor-markdown-header-0.5.6.tgz#587c9d3c0c182e01a49d1f6d5a2877cf3e887872" - -angular-mocks@^1.6.4: - version "1.6.4" - resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.6.4.tgz#47fdf50921cf24fb489f100a8cf2ad99d0538f40" - -angular@^1.6.4: - version "1.6.4" - resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.4.tgz#03b7b15c01a0802d7e2cf593240e604054dc77fb" - -annois@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/annois/-/annois-0.3.0.tgz#05c5bc5900e8286817e88684b8e7e348a9e24344" - -annois@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/annois/-/annois-0.3.2.tgz#6f6169ee374f84d0fd00db589c5b403db4f94b05" - -annotate@^0.9.1: - version "0.9.1" - resolved "https://registry.yarnpkg.com/annotate/-/annotate-0.9.1.tgz#38303e656844e4cc174760e3443b23bf65472bd3" - dependencies: - annois "0.3.0" - -annozip@^0.2.6: - version "0.2.6" - resolved "https://registry.yarnpkg.com/annozip/-/annozip-0.2.6.tgz#e18a2bc3e2871f061e0beca1c1d1a8cd0465099b" - dependencies: - annois "^0.3.2" - annotate "^0.9.1" - -ansi-regex@^0.2.0, ansi-regex@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" - -ansi-regex@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-1.1.1.tgz#41c847194646375e6a1a5d10c3ca054ef9fc980d" - -ansi-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.0.0.tgz#c5061b6e0ef8a81775e50f5d66151bf6bf371107" - -ansi-styles@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - -ansicolors@~0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.2.1.tgz#be089599097b74a5c9c4a84a0cdbcdb62bd87aef" - -anymatch@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" - dependencies: - arrify "^1.0.0" - micromatch "^2.1.5" - -aproba@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.0.4.tgz#2713680775e7614c8ba186c065d4e2e52d1072c0" - -archiver@~0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/archiver/-/archiver-0.10.1.tgz#c88a50fe114f744d059a07dfc4690f3a204146e4" - dependencies: - buffer-crc32 "~0.2.1" - file-utils "~0.2.0" - lazystream "~0.1.0" - lodash "~2.4.1" - readable-stream "~1.0.26" - tar-stream "~0.4.0" - zip-stream "~0.3.0" - -are-we-there-yet@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" - dependencies: - delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" - -argparse@^1.0.2, argparse@^1.0.7: - version "1.0.9" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" - dependencies: - sprintf-js "~1.0.2" - -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - -arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" - -array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" - -array-flatten@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" - -array-ify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" - -array-slice@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" - -array-union@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" - dependencies: - array-uniq "^1.0.1" - -array-uniq@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" - -array-unique@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - -arraybuffer.slice@0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" - -arrify@^1.0.0, arrify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - -asn1@0.1.11: - version "0.1.11" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.1.11.tgz#559be18376d08a4ec4dbe80877d27818639b2df7" - -asn1@~0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" - -assert-plus@^0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.1.5.tgz#ee74009413002d84cec7219c6ac811812e723160" - -assert-plus@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" - -assert-plus@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - -assert@^1.1.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" - dependencies: - util "0.10.3" - -assertion-error@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.0.2.tgz#13ca515d86206da0bac66e834dd397d87581094c" - -async-each@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" - -async@1.5.2, async@1.x, async@^1.2.1, async@^1.3.0, async@^1.4.0, async@^1.5.0, async@^1.5.2, async@~1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - -async@^0.9.0, async@~0.9.0: - version "0.9.2" - resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" - -async@~0.2.6: - version "0.2.10" - resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - -atoa@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/atoa/-/atoa-1.0.0.tgz#0cc0e91a480e738f923ebc103676471779b34a49" - -aws-sign2@~0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63" - -aws-sign2@~0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" - -aws4@^1.2.1: - version "1.5.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" - -babel-code-frame@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" - dependencies: - chalk "^1.1.0" - esutils "^2.0.2" - js-tokens "^3.0.0" - -babel-eslint@^7.2.3: - version "7.2.3" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827" - dependencies: - babel-code-frame "^6.22.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.17.0" - -babel-generator@^6.18.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.21.0.tgz#605f1269c489a1c75deeca7ea16d43d4656c8494" - dependencies: - babel-messages "^6.8.0" - babel-runtime "^6.20.0" - babel-types "^6.21.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" - -babel-messages@^6.23.0, babel-messages@^6.8.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - dependencies: - babel-runtime "^6.22.0" - -babel-runtime@^6.20.0, babel-runtime@^6.22.0, babel-runtime@^6.9.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.10.0" - -babel-template@^6.16.0: - version "6.16.0" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.16.0.tgz#e149dd1a9f03a35f817ddbc4d0481988e7ebc8ca" - dependencies: - babel-runtime "^6.9.0" - babel-traverse "^6.16.0" - babel-types "^6.16.0" - babylon "^6.11.0" - lodash "^4.2.0" - -babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.23.1: - version "6.23.1" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" - dependencies: - babel-code-frame "^6.22.0" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.23.0" - babylon "^6.15.0" - debug "^2.2.0" - globals "^9.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - -babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.21.0, babel-types@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" - dependencies: - babel-runtime "^6.22.0" - esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^1.0.1" - -babylon@^6.11.0, babylon@^6.13.0, babylon@^6.15.0: - version "6.16.1" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" - -babylon@^6.17.0: - version "6.17.1" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.1.tgz#17f14fddf361b695981fe679385e4f1c01ebd86f" - -backo2@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" - -bail@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.1.tgz#912579de8b391aadf3c5fdf4cd2a0fc225df3bc2" - -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" - -base64-arraybuffer@0.1.5: - version "0.1.5" - resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" - -base64-js@^1.0.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" - -base64id@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" - -basic-auth@~1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/basic-auth/-/basic-auth-1.0.4.tgz#030935b01de7c9b94a824b29f3fccb750d3a5290" - -batch@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/batch/-/batch-0.5.3.tgz#3f3414f380321743bfc1042f9a83ff1d5824d464" - -bcrypt-pbkdf@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz#3ca76b85241c7170bf7d9703e7b9aa74630040d4" - dependencies: - tweetnacl "^0.14.3" - -better-assert@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" - dependencies: - callsite "1.0.0" - -big.js@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978" - -binary-extensions@^1.0.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" - -bl@^0.9.0: - version "0.9.5" - resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054" - dependencies: - readable-stream "~1.0.26" - -bl@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.1.2.tgz#fdca871a99713aa00d19e3bbba41c44787a65398" - dependencies: - readable-stream "~2.0.5" - -blob@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" - -block-stream@*: - version "0.0.9" - resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" - dependencies: - inherits "~2.0.0" - -bluebird@^3.3.0: - version "3.4.7" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" - -body-parser@^1.16.1: - version "1.16.1" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.16.1.tgz#51540d045adfa7a0c6995a014bb6b1ed9b802329" - dependencies: - bytes "2.4.0" - content-type "~1.0.2" - debug "2.6.1" - depd "~1.1.0" - http-errors "~1.5.1" - iconv-lite "0.4.15" - on-finished "~2.3.0" - qs "6.2.1" - raw-body "~2.2.0" - type-is "~1.6.14" - -body-parser@~1.14.0: - version "1.14.2" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.14.2.tgz#1015cb1fe2c443858259581db53332f8d0cf50f9" - dependencies: - bytes "2.2.0" - content-type "~1.0.1" - debug "~2.2.0" - depd "~1.1.0" - http-errors "~1.3.1" - iconv-lite "0.4.13" - on-finished "~2.3.0" - qs "5.2.0" - raw-body "~2.1.5" - type-is "~1.6.10" - -boom@0.4.x: - version "0.4.2" - resolved "https://registry.yarnpkg.com/boom/-/boom-0.4.2.tgz#7a636e9ded4efcefb19cef4947a3c67dfaee911b" - dependencies: - hoek "0.9.x" - -boom@2.x.x: - version "2.10.1" - resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" - dependencies: - hoek "2.x.x" - -boundary@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/boundary/-/boundary-1.0.1.tgz#4d67dc2602c0cc16dd9bce7ebf87e948290f5812" - -brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" - dependencies: - balanced-match "^0.4.1" - concat-map "0.0.1" - -braces@^0.1.2: - version "0.1.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" - dependencies: - expand-range "^0.1.0" - -braces@^1.8.2: - version "1.8.5" - resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" - -browser-stdout@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" - -browserify-aes@0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-0.4.0.tgz#067149b668df31c4b58533e02d01e806d8608e2c" - dependencies: - inherits "^2.0.1" - -browserify-zlib@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d" - dependencies: - pako "~0.2.0" - -buffer-crc32@~0.2.1: - version "0.2.13" - resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" - -buffer-shims@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - -buffer@^4.9.0: - version "4.9.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.1.tgz#6d1bb601b07a4efced97094132093027c95bc298" - dependencies: - base64-js "^1.0.2" - ieee754 "^1.1.4" - isarray "^1.0.0" - -builtin-modules@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" - -builtin-status-codes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" - -bytes@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.2.0.tgz#fd35464a403f6f9117c2de3609ecff9cae000588" - -bytes@2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.3.0.tgz#d5b680a165b6201739acb611542aabc2d8ceb070" - -bytes@2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339" - -callsite@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" - -camelcase-keys@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" - dependencies: - camelcase "^2.0.0" - map-obj "^1.0.0" - -camelcase@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" - -camelcase@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" - -cardinal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-1.0.0.tgz#50e21c1b0aa37729f9377def196b5a9cec932ee9" - dependencies: - ansicolors "~0.2.1" - redeyed "~1.0.0" - -caseless@~0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" - -ccount@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.1.tgz#665687945168c218ec77ff61a4155ae00227a96c" - -center-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" - dependencies: - align-text "^0.1.3" - lazy-cache "^1.0.3" - -chai@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-3.5.0.tgz#4d02637b067fe958bdbfdd3a40ec56fef7373247" - dependencies: - assertion-error "^1.0.1" - deep-eql "^0.1.3" - type-detect "^1.0.0" - -chalk@^0.5.0, chalk@^0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" - dependencies: - ansi-styles "^1.1.0" - escape-string-regexp "^1.0.0" - has-ansi "^0.1.0" - strip-ansi "^0.3.0" - supports-color "^0.2.0" - -chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3, chalk@~1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -character-entities-html4@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/character-entities-html4/-/character-entities-html4-1.1.0.tgz#1ab08551d3ce1fa1df08d00fb9ca1defb147a06c" - -character-entities-legacy@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/character-entities-legacy/-/character-entities-legacy-1.1.0.tgz#b18aad98f6b7bcc646c1e4c81f9f1956376a561a" - -character-entities@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/character-entities/-/character-entities-1.2.0.tgz#a683e2cf75dbe8b171963531364e58e18a1b155f" - -character-reference-invalid@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.0.tgz#dec9ad1dfb9f8d06b4fcdaa2adc3c4fd97af1e68" - -chokidar@^1.0.0, chokidar@^1.4.1: - version "1.6.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" - dependencies: - anymatch "^1.3.0" - async-each "^1.0.0" - glob-parent "^2.0.0" - inherits "^2.0.1" - is-binary-path "^1.0.0" - is-glob "^2.0.0" - path-is-absolute "^1.0.0" - readdirp "^2.0.0" - optionalDependencies: - fsevents "^1.0.0" - -circular-json@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" - -cli-table@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" - dependencies: - colors "1.0.3" - -cli-usage@^0.1.2: - version "0.1.4" - resolved "https://registry.yarnpkg.com/cli-usage/-/cli-usage-0.1.4.tgz#7c01e0dc706c234b39c933838c8e20b2175776e2" - dependencies: - marked "^0.3.6" - marked-terminal "^1.6.2" - -cli-width@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-1.1.1.tgz#a4d293ef67ebb7b88d4a4d42c0ccf00c4d1e366d" - -cliui@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" - dependencies: - center-align "^0.1.1" - right-align "^0.1.1" - wordwrap "0.0.2" - -clone-function@>=1.0.1: - version "1.0.6" - resolved "https://registry.yarnpkg.com/clone-function/-/clone-function-1.0.6.tgz#428471937750bca9c48ecbfbc16f6e232f74a03d" - -clone-stats@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" - -clone@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" - -clone@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - -coffee-script@~1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.10.0.tgz#12938bcf9be1948fa006f92e0c4c9e81705108c0" - -collapse-white-space@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.2.tgz#9c463fb9c6d190d2dcae21a356a01bcae9eeef6d" - -colors@0.5.x: - version "0.5.1" - resolved "https://registry.yarnpkg.com/colors/-/colors-0.5.1.tgz#7d0023eaeb154e8ee9fce75dcb923d0ed1667774" - -colors@1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" - -colors@>=0.6.0, colors@^1.1.0, colors@^1.1.2, colors@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" - -combine-lists@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/combine-lists/-/combine-lists-1.0.1.tgz#458c07e09e0d900fc28b70a3fec2dacd1d2cb7f6" - dependencies: - lodash "^4.5.0" - -combined-stream@^1.0.5, combined-stream@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" - dependencies: - delayed-stream "~1.0.0" - -combined-stream@~0.0.4: - version "0.0.7" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-0.0.7.tgz#0137e657baa5a7541c57ac37ac5fc07d73b4dc1f" - dependencies: - delayed-stream "0.0.5" - -commander@2.9.0, commander@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" - -compare-func@^1.3.1: - version "1.3.2" - resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" - dependencies: - array-ify "^1.0.0" - dot-prop "^3.0.0" - -component-bind@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" - -component-emitter@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.1.2.tgz#296594f2753daa63996d2af08d15a95116c9aec3" - -component-emitter@1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" - -component-inherit@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" - -compressible@~2.0.8: - version "2.0.9" - resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.9.tgz#6daab4e2b599c2770dd9e21e7a891b1c5a755425" - dependencies: - mime-db ">= 1.24.0 < 2" - -compression@^1.5.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/compression/-/compression-1.6.2.tgz#cceb121ecc9d09c52d7ad0c3350ea93ddd402bc3" - dependencies: - accepts "~1.3.3" - bytes "2.3.0" - compressible "~2.0.8" - debug "~2.2.0" - on-headers "~1.0.1" - vary "~1.1.0" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -concat-stream@1.5.0, concat-stream@^1.4.1, concat-stream@^1.4.6: - version "1.5.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.0.tgz#53f7d43c51c5e43f81c8fdd03321c631be68d611" - dependencies: - inherits "~2.0.1" - readable-stream "~2.0.0" - typedarray "~0.0.5" - -configstore@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/configstore/-/configstore-0.3.2.tgz#25e4c16c3768abf75c5a65bc61761f495055b459" - dependencies: - graceful-fs "^3.0.1" - js-yaml "^3.1.0" - mkdirp "^0.5.0" - object-assign "^2.0.0" - osenv "^0.1.0" - user-home "^1.0.0" - uuid "^2.0.1" - xdg-basedir "^1.0.0" - -connect-history-api-fallback@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.3.0.tgz#e51d17f8f0ef0db90a64fdb47de3051556e9f169" - -connect-livereload@^0.5.0: - version "0.5.4" - resolved "https://registry.yarnpkg.com/connect-livereload/-/connect-livereload-0.5.4.tgz#80157d1371c9f37cc14039ab1895970d119dc3bc" - -connect@^3.4.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.5.0.tgz#b357525a0b4c1f50599cd983e1d9efeea9677198" - dependencies: - debug "~2.2.0" - finalhandler "0.5.0" - parseurl "~1.3.1" - utils-merge "1.0.0" - -connect@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.0.tgz#f09a4f7dcd17324b663b725c815bdb1c4158a46e" - dependencies: - debug "2.6.1" - finalhandler "1.0.0" - parseurl "~1.3.1" - utils-merge "1.0.0" - -console-browserify@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.1.0.tgz#f0241c45730a9fc6323b206dbf38edc741d0bb10" - dependencies: - date-now "^0.1.4" - -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - -constants-browserify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" - -content-disposition@0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.1.tgz#87476c6a67c8daa87e32e87616df883ba7fb071b" - -content-type@~1.0.1, content-type@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.2.tgz#b7d113aee7a8dd27bd21133c4dc2529df1721eed" - -contra@^1.6.8: - version "1.9.4" - resolved "https://registry.yarnpkg.com/contra/-/contra-1.9.4.tgz#f53bde42d7e5b5985cae4d99a8d610526de8f28d" - dependencies: - atoa "1.0.0" - ticky "1.0.1" - -conventional-changelog-angular@^1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.3.4.tgz#7d7cdfbd358948312904d02229a61fd6075cf455" - dependencies: - compare-func "^1.3.1" - github-url-from-git "^1.4.0" - q "^1.4.1" - -conventional-changelog-atom@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.1.0.tgz#67a47c66a42b2f8909ef1587c9989ae1de730b92" - dependencies: - q "^1.4.1" - -conventional-changelog-cli@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-cli/-/conventional-changelog-cli-1.3.1.tgz#1cd5a9dbae25ffb5ffe67afef1e136eaceefd2d5" - dependencies: - add-stream "^1.0.0" - conventional-changelog "^1.1.3" - lodash "^4.1.0" - meow "^3.7.0" - tempfile "^1.1.1" - -conventional-changelog-codemirror@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.1.0.tgz#7577a591dbf9b538e7a150a7ee62f65a2872b334" - dependencies: - q "^1.4.1" - -conventional-changelog-core@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-1.9.0.tgz#de5dfbc091847656508d4a389e35c9a1bc49e7f4" - dependencies: - conventional-changelog-writer "^1.1.0" - conventional-commits-parser "^1.0.0" - dateformat "^1.0.12" - get-pkg-repo "^1.0.0" - git-raw-commits "^1.2.0" - git-remote-origin-url "^2.0.0" - git-semver-tags "^1.2.0" - lodash "^4.0.0" - normalize-package-data "^2.3.5" - q "^1.4.1" - read-pkg "^1.1.0" - read-pkg-up "^1.0.1" - through2 "^2.0.0" - -conventional-changelog-ember@^0.2.6: - version "0.2.6" - resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.2.6.tgz#8b7355419f5127493c4c562473ab2fc792f1c2b6" - dependencies: - q "^1.4.1" - -conventional-changelog-eslint@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-0.1.0.tgz#a52411e999e0501ce500b856b0a643d0330907e2" - dependencies: - q "^1.4.1" - -conventional-changelog-express@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.1.0.tgz#55c6c841c811962036c037bdbd964a54ae310fce" - dependencies: - q "^1.4.1" - -conventional-changelog-jquery@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" - dependencies: - q "^1.4.1" - -conventional-changelog-jscs@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" - dependencies: - q "^1.4.1" - -conventional-changelog-jshint@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.1.0.tgz#00cab8e9a3317487abd94c4d84671342918d2a07" - dependencies: - compare-func "^1.3.1" - q "^1.4.1" - -conventional-changelog-writer@^1.1.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-1.4.1.tgz#3f4cb4d003ebb56989d30d345893b52a43639c8e" - dependencies: - compare-func "^1.3.1" - conventional-commits-filter "^1.0.0" - dateformat "^1.0.11" - handlebars "^4.0.2" - json-stringify-safe "^5.0.1" - lodash "^4.0.0" - meow "^3.3.0" - semver "^5.0.1" - split "^1.0.0" - through2 "^2.0.0" - -conventional-changelog@^1.1.3: - version "1.1.4" - resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.4.tgz#108bc750c2a317e200e2f9b413caaa1f8c7efa3b" - dependencies: - conventional-changelog-angular "^1.3.4" - conventional-changelog-atom "^0.1.0" - conventional-changelog-codemirror "^0.1.0" - conventional-changelog-core "^1.9.0" - conventional-changelog-ember "^0.2.6" - conventional-changelog-eslint "^0.1.0" - conventional-changelog-express "^0.1.0" - conventional-changelog-jquery "^0.1.0" - conventional-changelog-jscs "^0.1.0" - conventional-changelog-jshint "^0.1.0" - -conventional-commits-filter@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.0.0.tgz#6fc2a659372bc3f2339cf9ffff7e1b0344b93039" - dependencies: - is-subset "^0.1.1" - modify-values "^1.0.0" - -conventional-commits-parser@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-1.3.0.tgz#e327b53194e1a7ad5dc63479ee9099a52b024865" - dependencies: - JSONStream "^1.0.4" - is-text-path "^1.0.0" - lodash "^4.2.1" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - trim-off-newlines "^1.0.0" - -convert-source-map@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" - -cookie-signature@1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" - -cookie@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" - -core-js@^2.2.0, core-js@^2.4.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - -coveralls@~2.11.2: - version "2.11.15" - resolved "https://registry.yarnpkg.com/coveralls/-/coveralls-2.11.15.tgz#37d3474369d66c14f33fa73a9d25cee6e099fca0" - dependencies: - js-yaml "3.6.1" - lcov-parse "0.0.10" - log-driver "1.2.5" - minimist "1.2.0" - request "2.75.0" - -crc32-stream@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-0.2.0.tgz#5c80d480c8682f904b6f15530dbbe0b8c063dbbe" - dependencies: - buffer-crc32 "~0.2.1" - readable-stream "~1.0.24" - -cryptiles@0.2.x: - version "0.2.2" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-0.2.2.tgz#ed91ff1f17ad13d3748288594f8a48a0d26f325c" - dependencies: - boom "0.4.x" - -cryptiles@2.x.x: - version "2.0.5" - resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" - dependencies: - boom "2.x.x" - -crypto-browserify@3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.3.0.tgz#b9fc75bb4a0ed61dcf1cd5dae96eb30c9c3e506c" - dependencies: - browserify-aes "0.4.0" - pbkdf2-compat "2.0.1" - ripemd160 "0.2.0" - sha.js "2.2.6" - -ctype@0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f" - -currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" - dependencies: - array-find-index "^1.0.1" - -custom-event@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" - -d@^0.1.1, d@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/d/-/d-0.1.1.tgz#da184c535d18d8ee7ba2aa229b914009fae11309" - dependencies: - es5-ext "~0.10.2" - -dargs@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" - dependencies: - number-is-nan "^1.0.0" - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - dependencies: - assert-plus "^1.0.0" - -date-now@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" - -dateformat@^1.0.11, dateformat@^1.0.12, dateformat@^1.0.6, dateformat@~1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" - dependencies: - get-stdin "^4.0.1" - meow "^3.3.0" - -debug@0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" - -debug@2.2.0, debug@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" - dependencies: - ms "0.7.1" - -debug@2.3.3, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0: - version "2.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" - dependencies: - ms "0.7.2" - -debug@2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.0.tgz#bc596bcabe7617f11d9fa15361eded5608b8499b" - dependencies: - ms "0.7.2" - -debug@2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" - dependencies: - ms "0.7.2" - -debug@~1.0.2: - version "1.0.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-1.0.4.tgz#5b9c256bd54b6ec02283176fa8a0ede6d154cbf8" - dependencies: - ms "0.6.2" - -decamelize@^1.0.0, decamelize@^1.1.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - -deep-eql@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-0.1.3.tgz#ef558acab8de25206cd713906d74e56930eb69f2" - dependencies: - type-detect "0.1.1" - -deep-extend@~0.2.5: - version "0.2.11" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.2.11.tgz#7a16ba69729132340506170494bc83f7076fe08f" - -deep-extend@~0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" - -deep-is@~0.1.2, deep-is@~0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" - -defaults@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - dependencies: - clone "^1.0.2" - -define-properties@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94" - dependencies: - foreach "^2.0.5" - object-keys "^1.0.8" - -deflate-crc32-stream@~0.1.0: - version "0.1.2" - resolved "https://registry.yarnpkg.com/deflate-crc32-stream/-/deflate-crc32-stream-0.1.2.tgz#975ea0e7303b75d85232198ab7b405c2d47baad5" - dependencies: - buffer-crc32 "~0.2.1" - -del@^2.0.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" - dependencies: - globby "^5.0.0" - is-path-cwd "^1.0.0" - is-path-in-cwd "^1.0.0" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - rimraf "^2.2.8" - -delayed-stream@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-0.0.5.tgz#d4b1f43a93e8296dfe02694f4680bc37a313c73f" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - -delegates@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - -depd@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.0.tgz#e1bd82c6aab6ced965b97b88b17ed3e528ca18c3" - -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" - -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - dependencies: - repeating "^2.0.0" - -di@^0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" - -diff@3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" - -doctoc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-1.3.0.tgz#7f0839851dd58c808a2cae55d9504e012d08ee30" - dependencies: - anchor-markdown-header "^0.5.5" - htmlparser2 "~3.9.2" - markdown-to-ast "~3.4.0" - minimist "~1.2.0" - underscore "~1.8.3" - update-section "^0.3.0" - -doctrine@^0.7.0: - version "0.7.2" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" - dependencies: - esutils "^1.1.6" - isarray "0.0.1" - -dom-serialize@^2.2.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" - dependencies: - custom-event "~1.0.0" - ent "~2.2.0" - extend "^3.0.0" - void-elements "^2.0.0" - -dom-serializer@0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" - dependencies: - domelementtype "~1.1.1" - entities "~1.1.1" - -domain-browser@^1.1.1: - version "1.1.7" - resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" - -domelementtype@1, domelementtype@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" - -domelementtype@~1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" - -domhandler@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" - dependencies: - domelementtype "1" - -domutils@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" - dependencies: - dom-serializer "0" - domelementtype "1" - -dot-prop@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" - dependencies: - is-obj "^1.0.0" - -duplexify@^3.1.2, duplexify@^3.2.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.0.tgz#1aa773002e1578457e9d9d4a50b0ccaaebcbd604" - dependencies: - end-of-stream "1.0.0" - inherits "^2.0.1" - readable-stream "^2.0.0" - stream-shift "^1.0.0" - -ecc-jsbn@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" - dependencies: - jsbn "~0.1.0" - -ee-first@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" - -emojis-list@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" - -encodeurl@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" - -end-of-stream@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.0.0.tgz#d4596e702734a93e40e9af864319eabd99ff2f0e" - dependencies: - once "~1.3.0" - -end-of-stream@^1.0.0, end-of-stream@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.1.0.tgz#e9353258baa9108965efc41cb0ef8ade2f3cfb07" - dependencies: - once "~1.3.0" - -engine.io-client@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.3.tgz#1798ed93451246453d4c6f635d7a201fe940d5ab" - dependencies: - component-emitter "1.2.1" - component-inherit "0.0.3" - debug "2.3.3" - engine.io-parser "1.3.2" - has-cors "1.1.0" - indexof "0.0.1" - parsejson "0.0.3" - parseqs "0.0.5" - parseuri "0.0.5" - ws "1.1.2" - xmlhttprequest-ssl "1.5.3" - yeast "0.1.2" - -engine.io-parser@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-1.3.2.tgz#937b079f0007d0893ec56d46cb220b8cb435220a" - dependencies: - after "0.8.2" - arraybuffer.slice "0.0.6" - base64-arraybuffer "0.1.5" - blob "0.0.4" - has-binary "0.1.7" - wtf-8 "1.0.0" - -engine.io@1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.3.tgz#8de7f97895d20d39b85f88eeee777b2bd42b13d4" - dependencies: - accepts "1.3.3" - base64id "1.0.0" - cookie "0.3.1" - debug "2.3.3" - engine.io-parser "1.3.2" - ws "1.1.2" - -enhanced-resolve@~0.9.0: - version "0.9.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" - dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.2.0" - tapable "^0.1.8" - -ent@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - -entities@^1.1.1, entities@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" - -errno@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d" - dependencies: - prr "~0.0.0" - -error-ex@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.0.tgz#e67b43f3e82c96ea3a584ffee0b9fc3325d802d9" - dependencies: - is-arrayish "^0.2.1" - -es5-ext@^0.10.7, es5-ext@^0.10.8, es5-ext@~0.10.11, es5-ext@~0.10.2, es5-ext@~0.10.7: - version "0.10.12" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.12.tgz#aa84641d4db76b62abba5e45fd805ecbab140047" - dependencies: - es6-iterator "2" - es6-symbol "~3.1" - -es6-iterator@2: - version "2.0.0" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.0.tgz#bd968567d61635e33c0b80727613c9cb4b096bac" - dependencies: - d "^0.1.1" - es5-ext "^0.10.7" - es6-symbol "3" - -es6-map@^0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-map/-/es6-map-0.1.4.tgz#a34b147be224773a4d7da8072794cefa3632b897" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-set "~0.1.3" - es6-symbol "~3.1.0" - event-emitter "~0.3.4" - -es6-promise@~4.0.3: - version "4.0.5" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.0.5.tgz#7882f30adde5b240ccfa7f7d78c548330951ae42" - -es6-set@~0.1.3: - version "0.1.4" - resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.4.tgz#9516b6761c2964b92ff479456233a247dc707ce8" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - es6-iterator "2" - es6-symbol "3" - event-emitter "~0.3.4" - -es6-symbol@3, es6-symbol@~3.1, es6-symbol@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.0.tgz#94481c655e7a7cad82eba832d97d5433496d7ffa" - dependencies: - d "~0.1.1" - es5-ext "~0.10.11" - -es6-weak-map@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.1.tgz#0d2bbd8827eb5fb4ba8f97fbfea50d43db21ea81" - dependencies: - d "^0.1.1" - es5-ext "^0.10.8" - es6-iterator "2" - es6-symbol "3" - -escape-html@~1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - -escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - -escodegen@1.8.x: - version "1.8.1" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" - dependencies: - esprima "^2.7.1" - estraverse "^1.9.1" - esutils "^2.0.2" - optionator "^0.8.1" - optionalDependencies: - source-map "~0.2.0" - -escope@^3.2.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3" - dependencies: - es6-map "^0.1.3" - es6-weak-map "^2.0.1" - esrecurse "^4.1.0" - estraverse "^4.1.1" - -eslint-config-airbnb@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-0.1.0.tgz#5c6a122508050659a9446b69ac0ad4e701bfb2e0" - -eslint-config-algolia@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-config-algolia/-/eslint-config-algolia-3.0.0.tgz#ef25eae4f95007e2128647303c98d1378845caa1" - dependencies: - strip-json-comments "1.0.4" - -eslint@1.5.1, eslint@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-1.5.1.tgz#bb9e161f0161d71b85dc48163bf14a86f202562b" - dependencies: - chalk "^1.0.0" - concat-stream "^1.4.6" - debug "^2.1.1" - doctrine "^0.7.0" - escape-string-regexp "^1.0.2" - escope "^3.2.0" - espree "^2.2.4" - estraverse "^4.1.0" - estraverse-fb "^1.3.1" - file-entry-cache "^1.1.1" - glob "^5.0.14" - globals "^8.6.0" - handlebars "^4.0.0" - inquirer "^0.9.0" - is-my-json-valid "^2.10.0" - is-resolvable "^1.0.0" - js-yaml "^3.2.5" - lodash.clonedeep "^3.0.1" - lodash.merge "^3.3.2" - lodash.omit "^3.1.0" - minimatch "^2.0.1" - mkdirp "^0.5.0" - object-assign "^2.0.0" - optionator "^0.5.0" - path-is-absolute "^1.0.0" - path-is-inside "^1.0.1" - shelljs "^0.3.0" - strip-json-comments "~1.0.1" - text-table "~0.2.0" - to-double-quotes "^1.0.1" - to-single-quotes "^1.0.3" - user-home "^1.0.0" - xml-escape "~1.0.0" - -espree@^2.2.4: - version "2.2.5" - resolved "https://registry.yarnpkg.com/espree/-/espree-2.2.5.tgz#df691b9310889402aeb29cc066708c56690b854b" - -esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: - version "2.7.3" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" - -esprima@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.0.0.tgz#53cf247acda77313e551c3aa2e73342d3fb4f7d9" - -esrecurse@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" - dependencies: - estraverse "~4.1.0" - object-assign "^4.0.1" - -estraverse-fb@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/estraverse-fb/-/estraverse-fb-1.3.1.tgz#160e75a80e605b08ce894bcce2fe3e429abf92bf" - -estraverse@^1.9.1: - version "1.9.3" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" - -estraverse@^4.1.0, estraverse@^4.1.1: - version "4.2.0" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" - -estraverse@~4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2" - -esutils@^1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" - -esutils@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - -etag@~1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/etag/-/etag-1.7.0.tgz#03d30b5f67dd6e632d2945d30d6652731a34d5d8" - -event-emitter@~0.3.4: - version "0.3.4" - resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.4.tgz#8d63ddfb4cfe1fae3b32ca265c4c720222080bb5" - dependencies: - d "~0.1.1" - es5-ext "~0.10.7" - -eventemitter2@~0.4.13: - version "0.4.14" - resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-0.4.14.tgz#8f61b75cde012b2e9eb284d4545583b5643b61ab" - -eventemitter3@1.x.x: - version "1.2.0" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" - -events@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" - -eventsource@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/eventsource/-/eventsource-0.1.6.tgz#0acede849ed7dd1ccc32c811bb11b944d4f29232" - dependencies: - original ">=0.0.5" - -exit@~0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - -expand-braces@^0.1.1: - version "0.1.2" - resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" - dependencies: - array-slice "^0.2.3" - array-unique "^0.2.1" - braces "^0.1.2" - -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" - dependencies: - is-posix-bracket "^0.1.0" - -expand-range@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" - dependencies: - is-number "^0.1.1" - repeat-string "^0.2.2" - -expand-range@^1.8.1: - version "1.8.2" - resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" - dependencies: - fill-range "^2.1.0" - -express@^4.13.3: - version "4.14.0" - resolved "https://registry.yarnpkg.com/express/-/express-4.14.0.tgz#c1ee3f42cdc891fb3dc650a8922d51ec847d0d66" - dependencies: - accepts "~1.3.3" - array-flatten "1.1.1" - content-disposition "0.5.1" - content-type "~1.0.2" - cookie "0.3.1" - cookie-signature "1.0.6" - debug "~2.2.0" - depd "~1.1.0" - encodeurl "~1.0.1" - escape-html "~1.0.3" - etag "~1.7.0" - finalhandler "0.5.0" - fresh "0.3.0" - merge-descriptors "1.0.1" - methods "~1.1.2" - on-finished "~2.3.0" - parseurl "~1.3.1" - path-to-regexp "0.1.7" - proxy-addr "~1.1.2" - qs "6.2.0" - range-parser "~1.2.0" - send "0.14.1" - serve-static "~1.11.1" - type-is "~1.6.13" - utils-merge "1.0.0" - vary "~1.1.0" - -extend@^3.0.0, extend@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" - -extglob@^0.3.1: - version "0.3.2" - resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" - dependencies: - is-extglob "^1.0.0" - -extract-zip@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.5.0.tgz#92ccf6d81ef70a9fa4c1747114ccef6d8688a6c4" - dependencies: - concat-stream "1.5.0" - debug "0.7.4" - mkdirp "0.5.0" - yauzl "2.4.1" - -extsprintf@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" - -fast-levenshtein@~1.0.0: - version "1.0.7" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.0.7.tgz#0178dcdee023b92905193af0959e8a7639cfdcb9" - -fast-levenshtein@~2.0.4: - version "2.0.6" - resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - -faye-websocket@^0.10.0, faye-websocket@~0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" - dependencies: - websocket-driver ">=0.5.1" - -faye-websocket@~0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.0.tgz#d9ccf0e789e7db725d74bc4877d23aa42972ac50" - dependencies: - websocket-driver ">=0.5.1" - -fd-slicer@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" - dependencies: - pend "~1.2.0" - -figures@^1.0.1, figures@^1.3.5: - version "1.7.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" - dependencies: - escape-string-regexp "^1.0.5" - object-assign "^4.1.0" - -file-entry-cache@^1.1.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-1.3.1.tgz#44c61ea607ae4be9c1402f41f44270cbfe334ff8" - dependencies: - flat-cache "^1.2.1" - object-assign "^4.0.1" - -file-utils@~0.2.0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/file-utils/-/file-utils-0.2.2.tgz#4b7967bb2079ada4d4a7f5454206ecb5c0d4c589" - dependencies: - findup-sync "^0.2.1" - glob "^4.3.5" - iconv-lite "^0.4.3" - isbinaryfile "^2.0.1" - lodash "^2.4.1" - minimatch "^2.0.1" - rimraf "^2.2.2" - -filename-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" - -fill-range@^2.1.0: - version "2.2.3" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" - -finalhandler@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-0.5.0.tgz#e9508abece9b6dba871a6942a1d7911b91911ac7" - dependencies: - debug "~2.2.0" - escape-html "~1.0.3" - on-finished "~2.3.0" - statuses "~1.3.0" - unpipe "~1.0.0" - -finalhandler@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.0.0.tgz#b5691c2c0912092f18ac23e9416bde5cd7dc6755" - dependencies: - debug "2.6.1" - encodeurl "~1.0.1" - escape-html "~1.0.3" - on-finished "~2.3.0" - parseurl "~1.3.1" - statuses "~1.3.1" - unpipe "~1.0.0" - -find-index@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" - -find-up@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" - dependencies: - path-exists "^2.0.0" - pinkie-promise "^2.0.0" - -findup-sync@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.2.1.tgz#e0a90a450075c49466ee513732057514b81e878c" - dependencies: - glob "~4.3.0" - -findup-sync@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" - dependencies: - glob "~5.0.0" - -first-chunk-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" - -flat-cache@^1.2.1: - version "1.2.2" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96" - dependencies: - circular-json "^0.3.1" - del "^2.0.2" - graceful-fs "^4.1.2" - write "^0.2.1" - -for-in@^0.1.5: - version "0.1.6" - resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8" - -for-own@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.4.tgz#0149b41a39088c7515f51ebe1c1386d45f935072" - dependencies: - for-in "^0.1.5" - -foreach@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" - -forever-agent@~0.5.0: - version "0.5.2" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.5.2.tgz#6d0e09c4921f94a27f63d3b49c5feff1ea4c5130" - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - -form-data@~0.1.0: - version "0.1.4" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.1.4.tgz#91abd788aba9702b1aabfa8bc01031a2ac9e3b12" - dependencies: - async "~0.9.0" - combined-stream "~0.0.4" - mime "~1.2.11" - -form-data@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.0.0.tgz#6f0aebadcc5da16c13e1ecc11137d85f9b883b25" - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.11" - -form-data@~2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.12" - -formatio@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" - dependencies: - samsam "~1.1" - -forwarded@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.0.tgz#19ef9874c4ae1c297bcf078fde63a09b66a84363" - -fresh@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.3.0.tgz#651f838e22424e7566de161d8358caa199f83d4f" - -fs-access@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" - dependencies: - null-check "^1.0.0" - -fs-extra@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" - dependencies: - graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - -fsevents@^1.0.0: - version "1.0.17" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.0.17.tgz#8537f3f12272678765b4fd6528c0f1f66f8f4558" - dependencies: - nan "^2.3.0" - node-pre-gyp "^0.6.29" - -fstream-ignore@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" - dependencies: - fstream "^1.0.0" - inherits "2" - minimatch "^3.0.0" - -fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.10.tgz#604e8a92fe26ffd9f6fae30399d4984e1ab22822" - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - -function-bind@^1.0.2, function-bind@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771" - -gauge@~2.7.1: - version "2.7.2" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.2.tgz#15cecc31b02d05345a5d6b0e171cdb3ad2307774" - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - supports-color "^0.2.0" - wide-align "^1.1.0" - -gaze@^0.5.1: - version "0.5.2" - resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" - dependencies: - globule "~0.1.0" - -gaze@^1.0.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/gaze/-/gaze-1.1.2.tgz#847224677adb8870d679257ed3388fdb61e40105" - dependencies: - globule "^1.0.0" - -generate-function@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" - -generate-object-property@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" - dependencies: - is-property "^1.0.0" - -get-pkg-repo@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.3.0.tgz#43c6b4c048b75dd604fc5388edecde557f6335df" - dependencies: - hosted-git-info "^2.1.4" - meow "^3.3.0" - normalize-package-data "^2.3.0" - parse-github-repo-url "^1.3.0" - through2 "^2.0.0" - -get-stdin@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-3.0.2.tgz#c1ced24b9039b38ded85bdf161e57713b6dd4abe" - -get-stdin@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" - -getobject@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/getobject/-/getobject-0.1.0.tgz#047a449789fa160d018f5486ed91320b6ec7885c" - -getpass@^0.1.1: - version "0.1.6" - resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" - dependencies: - assert-plus "^1.0.0" - -git-raw-commits@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.2.0.tgz#0f3a8bfd99ae0f2d8b9224d58892975e9a52d03c" - dependencies: - dargs "^4.0.1" - lodash.template "^4.0.2" - meow "^3.3.0" - split2 "^2.0.0" - through2 "^2.0.0" - -git-remote-origin-url@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" - dependencies: - gitconfiglocal "^1.0.0" - pify "^2.3.0" - -git-semver-tags@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.2.0.tgz#b31fd02c8ab578bd6c9b5cacca5e1c64c1177ac1" - dependencies: - meow "^3.3.0" - semver "^5.0.1" - -gitconfiglocal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" - dependencies: - ini "^1.3.2" - -github-url-from-git@^1.4.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/github-url-from-git/-/github-url-from-git-1.5.0.tgz#f985fedcc0a9aa579dc88d7aff068d55cc6251a0" - -glob-base@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" - -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" - dependencies: - is-glob "^2.0.0" - -glob-stream@^3.1.5: - version "3.1.18" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" - dependencies: - glob "^4.3.1" - glob2base "^0.0.12" - minimatch "^2.0.1" - ordered-read-streams "^0.1.0" - through2 "^0.6.1" - unique-stream "^1.0.0" - -glob-watcher@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" - dependencies: - gaze "^0.5.1" - -glob2base@^0.0.12: - version "0.0.12" - resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" - dependencies: - find-index "^0.1.1" - -glob@7.1.1, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@~7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.2" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^4.3.1, glob@^4.3.5: - version "4.5.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "^2.0.1" - once "^1.3.0" - -glob@^5.0.14, glob@^5.0.15, glob@~5.0.0: - version "5.0.15" - resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "2 || 3" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@~3.1.21: - version "3.1.21" - resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" - dependencies: - graceful-fs "~1.2.0" - inherits "1" - minimatch "~0.2.11" - -glob@~4.3.0: - version "4.3.5" - resolved "https://registry.yarnpkg.com/glob/-/glob-4.3.5.tgz#80fbb08ca540f238acce5d11d1e9bc41e75173d3" - dependencies: - inflight "^1.0.4" - inherits "2" - minimatch "^2.0.1" - once "^1.3.0" - -glob@~7.0.0: - version "7.0.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.2" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^8.6.0: - version "8.18.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-8.18.0.tgz#93d4a62bdcac38cfafafc47d6b034768cb0ffcb4" - -globals@^9.0.0: - version "9.14.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.14.0.tgz#8859936af0038741263053b39d0e76ca241e4034" - -globby@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" - dependencies: - array-union "^1.0.1" - arrify "^1.0.0" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -globule@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/globule/-/globule-1.1.0.tgz#c49352e4dc183d85893ee825385eb994bb6df45f" - dependencies: - glob "~7.1.1" - lodash "~4.16.4" - minimatch "~3.0.2" - -globule@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" - dependencies: - glob "~3.1.21" - lodash "~1.0.1" - minimatch "~0.2.11" - -got@^3.2.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/got/-/got-3.3.1.tgz#e5d0ed4af55fc3eef4d56007769d98192bcb2eca" - dependencies: - duplexify "^3.2.0" - infinity-agent "^2.0.0" - is-redirect "^1.0.0" - is-stream "^1.0.0" - lowercase-keys "^1.0.0" - nested-error-stacks "^1.0.0" - object-assign "^3.0.0" - prepend-http "^1.0.0" - read-all-stream "^3.0.0" - timed-out "^2.0.0" - -graceful-fs@^3.0.0, graceful-fs@^3.0.1: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - dependencies: - natives "^1.1.0" - -graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: - version "4.1.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" - -graceful-fs@~1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" - -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - -growl@1.9.2: - version "1.9.2" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" - -grunt-banner@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/grunt-banner/-/grunt-banner-0.6.0.tgz#3f879021d123fa58a7ba5a0b6fb6be412b5885ac" - dependencies: - chalk "^1.1.0" - -grunt-cli@1.2.0, grunt-cli@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/grunt-cli/-/grunt-cli-1.2.0.tgz#562b119ebb069ddb464ace2845501be97b35b6a8" - dependencies: - findup-sync "~0.3.0" - grunt-known-options "~1.1.0" - nopt "~3.0.6" - resolve "~1.1.0" - -grunt-concurrent@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/grunt-concurrent/-/grunt-concurrent-2.3.1.tgz#1e3db38ccef5a3da1195e61d631fe7e321344d23" - dependencies: - arrify "^1.0.1" - async "^1.2.1" - indent-string "^2.0.0" - pad-stream "^1.0.0" - -grunt-contrib-clean@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/grunt-contrib-clean/-/grunt-contrib-clean-1.1.0.tgz#564abf2d0378a983a15b9e3f30ee75b738c40638" - dependencies: - async "^1.5.2" - rimraf "^2.5.1" - -grunt-contrib-concat@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz#61509863084e871d7e86de48c015259ed97745bd" - dependencies: - chalk "^1.0.0" - source-map "^0.5.3" - -grunt-contrib-connect@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/grunt-contrib-connect/-/grunt-contrib-connect-1.0.2.tgz#5cf933b91a67386044273c0b2444603cd98879ba" - dependencies: - async "^1.5.2" - connect "^3.4.0" - connect-livereload "^0.5.0" - http2 "^3.3.4" - morgan "^1.6.1" - opn "^4.0.0" - portscanner "^1.0.0" - serve-index "^1.7.1" - serve-static "^1.10.0" - -grunt-contrib-uglify@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/grunt-contrib-uglify/-/grunt-contrib-uglify-2.2.0.tgz#9e67c2469b4774daa3345840511d51fc4fb34f19" - dependencies: - chalk "^1.0.0" - maxmin "^1.1.0" - object.assign "^4.0.4" - uglify-js "~2.8.3" - uri-path "^1.0.0" - -grunt-contrib-watch@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/grunt-contrib-watch/-/grunt-contrib-watch-1.0.0.tgz#84a1a7a1d6abd26ed568413496c73133e990018f" - dependencies: - async "^1.5.0" - gaze "^1.0.0" - lodash "^3.10.1" - tiny-lr "^0.2.1" - -grunt-eslint@^17.2.0: - version "17.3.2" - resolved "https://registry.yarnpkg.com/grunt-eslint/-/grunt-eslint-17.3.2.tgz#36a8b3be6ccde88c8b58f909745d75db19e5d4b0" - dependencies: - chalk "^1.0.0" - eslint "^1.5.1" - -grunt-exec@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/grunt-exec/-/grunt-exec-1.0.1.tgz#e5d53a39c5f346901305edee5c87db0f2af999c4" - -grunt-known-options@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/grunt-known-options/-/grunt-known-options-1.1.0.tgz#a4274eeb32fa765da5a7a3b1712617ce3b144149" - -grunt-legacy-log-utils@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/grunt-legacy-log-utils/-/grunt-legacy-log-utils-1.0.0.tgz#a7b8e2d0fb35b5a50f4af986fc112749ebc96f3d" - dependencies: - chalk "~1.1.1" - lodash "~4.3.0" - -grunt-legacy-log@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/grunt-legacy-log/-/grunt-legacy-log-1.0.0.tgz#fb86f1809847bc07dc47843f9ecd6cacb62df2d5" - dependencies: - colors "~1.1.2" - grunt-legacy-log-utils "~1.0.0" - hooker "~0.2.3" - lodash "~3.10.1" - underscore.string "~3.2.3" - -grunt-legacy-util@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/grunt-legacy-util/-/grunt-legacy-util-1.0.0.tgz#386aa78dc6ed50986c2b18957265b1b48abb9b86" - dependencies: - async "~1.5.2" - exit "~0.1.1" - getobject "~0.1.0" - hooker "~0.2.3" - lodash "~4.3.0" - underscore.string "~3.2.3" - which "~1.2.1" - -grunt-sed@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/grunt-sed/-/grunt-sed-0.1.1.tgz#2613d486909319b3f8f4bd75dafb46a642ec3f82" - dependencies: - replace "~0.2.4" - -grunt-step@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/grunt-step/-/grunt-step-1.0.0.tgz#ee53787874e51829db4f3f4742d20b31fa5831c9" - -grunt-umd@^2.3.6: - version "2.4.0" - resolved "https://registry.yarnpkg.com/grunt-umd/-/grunt-umd-2.4.0.tgz#d1318c645ba4734c10c20c1dd6923467d81b05ef" - dependencies: - libumd "^0.7.0" - xtend "^4.0.0" - -grunt-webpack@^1.0.14: - version "1.0.18" - resolved "https://registry.yarnpkg.com/grunt-webpack/-/grunt-webpack-1.0.18.tgz#ff26c43ff35bae6cca707a93c4bcdd950a3ecbb7" - dependencies: - lodash "^4.7.0" - -grunt@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/grunt/-/grunt-1.0.1.tgz#e8778764e944b18f32bb0f10b9078475c9dfb56b" - dependencies: - coffee-script "~1.10.0" - dateformat "~1.0.12" - eventemitter2 "~0.4.13" - exit "~0.1.1" - findup-sync "~0.3.0" - glob "~7.0.0" - grunt-cli "~1.2.0" - grunt-known-options "~1.1.0" - grunt-legacy-log "~1.0.0" - grunt-legacy-util "~1.0.0" - iconv-lite "~0.4.13" - js-yaml "~3.5.2" - minimatch "~3.0.0" - nopt "~3.0.6" - path-is-absolute "~1.0.0" - rimraf "~2.2.8" - -gzip-size@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-1.0.0.tgz#66cf8b101047227b95bace6ea1da0c177ed5c22f" - dependencies: - browserify-zlib "^0.1.4" - concat-stream "^1.4.1" - -handlebars@^4.0.0, handlebars@^4.0.1, handlebars@^4.0.2: - version "4.0.6" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.6.tgz#2ce4484850537f9c97a8026d5399b935c4ed4ed7" - dependencies: - async "^1.4.0" - optimist "^0.6.1" - source-map "^0.4.4" - optionalDependencies: - uglify-js "^2.6" - -har-validator@~2.0.6: - version "2.0.6" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" - dependencies: - chalk "^1.1.1" - commander "^2.9.0" - is-my-json-valid "^2.12.4" - pinkie-promise "^2.0.0" - -harmony-reflect@~1.1.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.1.3.tgz#f0e6d345c5f28f5e3e13b9450ee8a4aa5e959053" - -has-ansi@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" - dependencies: - ansi-regex "^0.2.0" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - -has-binary@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/has-binary/-/has-binary-0.1.7.tgz#68e61eb16210c9545a0a5cce06a873912fe1e68c" - dependencies: - isarray "0.0.1" - -has-cors@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" - -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - -has@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" - dependencies: - function-bind "^1.0.2" - -hasha@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" - dependencies: - is-stream "^1.0.1" - pinkie-promise "^2.0.0" - -hawk@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-1.0.0.tgz#b90bb169807285411da7ffcb8dd2598502d3b52d" - dependencies: - boom "0.4.x" - cryptiles "0.2.x" - hoek "0.9.x" - sntp "0.2.x" - -hawk@~3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" - dependencies: - boom "2.x.x" - cryptiles "2.x.x" - hoek "2.x.x" - sntp "1.x.x" - -hoek@0.9.x: - version "0.9.1" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-0.9.1.tgz#3d322462badf07716ea7eb85baf88079cddce505" - -hoek@2.x.x: - version "2.16.3" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" - -hooker@~0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/hooker/-/hooker-0.2.3.tgz#b834f723cc4a242aa65963459df6d984c5d3d959" - -hosted-git-info@^2.1.4: - version "2.1.5" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" - -htmlparser2@~3.9.2: - version "3.9.2" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" - dependencies: - domelementtype "^1.3.0" - domhandler "^2.3.0" - domutils "^1.5.1" - entities "^1.1.1" - inherits "^2.0.1" - readable-stream "^2.0.2" - -http-errors@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.3.1.tgz#197e22cdebd4198585e8694ef6786197b91ed942" - dependencies: - inherits "~2.0.1" - statuses "1" - -http-errors@~1.5.0, http-errors@~1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.5.1.tgz#788c0d2c1de2c81b9e6e8c01843b6b97eb920750" - dependencies: - inherits "2.0.3" - setprototypeof "1.0.2" - statuses ">= 1.3.1 < 2" - -http-proxy-middleware@~0.17.1: - version "0.17.3" - resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-0.17.3.tgz#940382147149b856084f5534752d5b5a8168cd1d" - dependencies: - http-proxy "^1.16.2" - is-glob "^3.1.0" - lodash "^4.17.2" - micromatch "^2.3.11" - -http-proxy@^1.13.0, http-proxy@^1.16.2: - version "1.16.2" - resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" - dependencies: - eventemitter3 "1.x.x" - requires-port "1.x.x" - -http-signature@~0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.10.1.tgz#4fbdac132559aa8323121e540779c0a012b27e66" - dependencies: - asn1 "0.1.11" - assert-plus "^0.1.5" - ctype "0.5.3" - -http-signature@~1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" - dependencies: - assert-plus "^0.2.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -http2@^3.3.4: - version "3.3.6" - resolved "https://registry.yarnpkg.com/http2/-/http2-3.3.6.tgz#7df06227e02b5b5a5841deea08239b3198d04bec" - -https-browserify@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82" - -iconv-lite@0.4.13: - version "0.4.13" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" - -iconv-lite@0.4.15, iconv-lite@^0.4.3, iconv-lite@~0.4.13: - version "0.4.15" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" - -ieee754@^1.1.4: - version "1.1.8" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" - -immediate@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.2.3.tgz#d140fa8f614659bd6541233097ddaac25cdd991c" - -indent-string@^2.0.0, indent-string@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" - dependencies: - repeating "^2.0.0" - -indexof@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" - -infinity-agent@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/infinity-agent/-/infinity-agent-2.0.3.tgz#45e0e2ff7a9eb030b27d62b74b3744b7a7ac4216" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" - -inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - -inherits@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" - -ini@^1.3.2, ini@~1.3.0: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" - -inquirer@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.9.0.tgz#7366e38a331e61904958ace5b2da4a9a5f636798" - dependencies: - ansi-regex "^2.0.0" - chalk "^1.0.0" - cli-width "^1.0.1" - figures "^1.3.5" - lodash "^3.3.1" - readline2 "^0.1.1" - run-async "^0.1.0" - rx-lite "^2.5.2" - strip-ansi "^3.0.0" - through "^2.3.6" - -interpret@^0.6.4: - version "0.6.6" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b" - -invariant@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" - dependencies: - loose-envify "^1.0.0" - -ipaddr.js@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.1.1.tgz#c791d95f52b29c1247d5df80ada39b8a73647230" - -is-alphabetical@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-alphabetical/-/is-alphabetical-1.0.0.tgz#e2544c13058255f2144cb757066cd3342a1c8c46" - -is-alphanumerical@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-alphanumerical/-/is-alphanumerical-1.0.0.tgz#e06492e719c1bf15dec239e4f1af5f67b4d6e7bf" - dependencies: - is-alphabetical "^1.0.0" - is-decimal "^1.0.0" - -is-arrayish@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - -is-binary-path@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" - dependencies: - binary-extensions "^1.0.0" - -is-buffer@^1.0.2: - version "1.1.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" - -is-builtin-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" - dependencies: - builtin-modules "^1.0.0" - -is-decimal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-decimal/-/is-decimal-1.0.0.tgz#940579b6ea63c628080a69e62bda88c8470b4fe0" - -is-dotfile@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - -is-extglob@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - -is-finite@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - dependencies: - number-is-nan "^1.0.0" - -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" - -is-glob@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - dependencies: - is-extglob "^2.1.0" - -is-hexadecimal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-hexadecimal/-/is-hexadecimal-1.0.0.tgz#5c459771d2af9a2e3952781fd54fcb1bcfe4113c" - -is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: - version "2.15.0" - resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" - dependencies: - generate-function "^2.0.0" - generate-object-property "^1.1.0" - jsonpointer "^4.0.0" - xtend "^4.0.0" - -is-npm@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" - -is-number@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" - -is-number@^2.0.2, is-number@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" - -is-obj@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" - -is-path-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" - -is-path-in-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" - dependencies: - is-path-inside "^1.0.0" - -is-path-inside@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.0.tgz#fc06e5a1683fbda13de667aff717bbc10a48f37f" - dependencies: - path-is-inside "^1.0.1" - -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" - -is-property@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" - -is-redirect@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" - -is-resolvable@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.0.tgz#8df57c61ea2e3c501408d100fb013cf8d6e0cc62" - dependencies: - tryit "^1.0.1" - -is-stream@^1.0.0, is-stream@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" - -is-subset@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" - -is-text-path@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" - dependencies: - text-extensions "^1.0.0" - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - -is-utf8@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - -isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isbinaryfile@^2.0.1: - version "2.0.4" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-2.0.4.tgz#d23592e6a6f093efb84c2e6152056be294e414a1" - -isbinaryfile@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.2.tgz#4a3e974ec0cba9004d3fc6cde7209ea69368a621" - -isexe@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0" - -isobject@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - dependencies: - isarray "1.0.0" - -isstream@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - -istanbul-instrumenter-loader@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/istanbul-instrumenter-loader/-/istanbul-instrumenter-loader-1.2.0.tgz#bef469049b81b23581d0d4db37a271206033cc52" - dependencies: - convert-source-map "^1.3.0" - istanbul-lib-instrument "^1.1.3" - loader-utils "^0.2.16" - object-assign "^4.1.0" - -istanbul-lib-coverage@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.0.tgz#c3f9b6d226da12424064cce87fce0fb57fdfa7a2" - -istanbul-lib-instrument@^1.1.3: - version "1.4.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.4.2.tgz#0e2fdfac93c1dabf2e31578637dc78a19089f43e" - dependencies: - babel-generator "^6.18.0" - babel-template "^6.16.0" - babel-traverse "^6.18.0" - babel-types "^6.18.0" - babylon "^6.13.0" - istanbul-lib-coverage "^1.0.0" - semver "^5.3.0" - -istanbul@^0.4.0: - version "0.4.5" - resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b" - dependencies: - abbrev "1.0.x" - async "1.x" - escodegen "1.8.x" - esprima "2.7.x" - glob "^5.0.15" - handlebars "^4.0.1" - js-yaml "3.x" - mkdirp "0.5.x" - nopt "3.x" - once "1.x" - resolve "1.1.x" - supports-color "^3.1.0" - which "^1.1.1" - wordwrap "^1.0.0" - -jasmine-core@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.6.2.tgz#74ea1f7cf428691af201107d631234027a09daab" - -jasmine-jquery@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/jasmine-jquery/-/jasmine-jquery-2.1.1.tgz#d4095e646944a26763235769ab018d9f30f0d47b" - -jodid25519@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" - dependencies: - jsbn "~0.1.0" - -jquery@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787" - -js-tokens@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" - -js-tokens@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" - -js-yaml@3.6.1, js-yaml@3.x, js-yaml@^3.1.0, js-yaml@^3.2.5: - version "3.6.1" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.6.1.tgz#6e5fe67d8b205ce4d22fad05b7781e8dadcc4b30" - dependencies: - argparse "^1.0.7" - esprima "^2.6.0" - -js-yaml@~3.5.2: - version "3.5.5" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.5.5.tgz#0377c38017cabc7322b0d1fbcd25a491641f2fbe" - dependencies: - argparse "^1.0.2" - esprima "^2.6.0" - -jsbn@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd" - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - -json-schema@0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - -json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.0, json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - -json3@3.3.2, json3@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" - -json5@^0.5.0: - version "0.5.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" - -json@^9.0.6: - version "9.0.6" - resolved "https://registry.yarnpkg.com/json/-/json-9.0.6.tgz#7972c2a5a48a42678db2730c7c2c4ee6e4e24585" - -jsonfile@^2.1.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" - optionalDependencies: - graceful-fs "^4.1.6" - -jsonparse@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.2.0.tgz#5c0c5685107160e72fe7489bddea0b44c2bc67bd" - -jsonpointer@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" - -jsprim@^1.2.2: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" - dependencies: - extsprintf "1.0.2" - json-schema "0.2.3" - verror "1.3.6" - -karma-chrome-launcher@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.1.1.tgz#216879c68ac04d8d5140e99619ba04b59afd46cf" - dependencies: - fs-access "^1.0.0" - which "^1.2.1" - -karma-coverage@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/karma-coverage/-/karma-coverage-1.1.1.tgz#5aff8b39cf6994dc22de4c84362c76001b637cf6" - dependencies: - dateformat "^1.0.6" - istanbul "^0.4.0" - lodash "^3.8.0" - minimatch "^3.0.0" - source-map "^0.5.1" - -karma-coveralls@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/karma-coveralls/-/karma-coveralls-1.1.2.tgz#6f960ee738793b087ba99284a854ef6be4d32ae0" - dependencies: - coveralls "~2.11.2" - glob "~5.0.0" - -karma-firefox-launcher@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-1.0.1.tgz#ce58f47c2013a88156d55a5d61337c099cf5bb51" - -karma-jasmine@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.0.tgz#22e4c06bf9a182e5294d1f705e3733811b810acf" - -karma-opera-launcher@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/karma-opera-launcher/-/karma-opera-launcher-1.0.0.tgz#fa51628531a1d0be84b2d8dc0d7ee209fc8ff91a" - -karma-phantomjs-launcher@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" - dependencies: - lodash "^4.0.1" - phantomjs-prebuilt "^2.1.7" - -karma-safari-launcher@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz#96982a2cc47d066aae71c553babb28319115a2ce" - -karma-sinon@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/karma-sinon/-/karma-sinon-1.0.5.tgz#4e3443f2830fdecff624d3747163f1217daa2a9a" - -karma-sourcemap-loader@^0.3.7: - version "0.3.7" - resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8" - dependencies: - graceful-fs "^4.1.2" - -karma-webpack@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-2.0.3.tgz#39cebf5ca2580139b27f9ae69b78816b9c82fae6" - dependencies: - async "~0.9.0" - loader-utils "^0.2.5" - lodash "^3.8.0" - source-map "^0.1.41" - webpack-dev-middleware "^1.0.11" - -karma@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/karma/-/karma-1.7.0.tgz#6f7a1a406446fa2e187ec95398698f4cee476269" - dependencies: - bluebird "^3.3.0" - body-parser "^1.16.1" - chokidar "^1.4.1" - colors "^1.1.0" - combine-lists "^1.0.0" - connect "^3.6.0" - core-js "^2.2.0" - di "^0.0.1" - dom-serialize "^2.2.0" - expand-braces "^0.1.1" - glob "^7.1.1" - graceful-fs "^4.1.2" - http-proxy "^1.13.0" - isbinaryfile "^3.0.0" - lodash "^3.8.0" - log4js "^0.6.31" - mime "^1.3.4" - minimatch "^3.0.2" - optimist "^0.6.1" - qjobs "^1.1.4" - range-parser "^1.2.0" - rimraf "^2.6.0" - safe-buffer "^5.0.1" - socket.io "1.7.3" - source-map "^0.5.3" - tmp "0.0.31" - useragent "^2.1.12" - -kew@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" - -kind-of@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" - dependencies: - is-buffer "^1.0.2" - -klaw@^1.0.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" - optionalDependencies: - graceful-fs "^4.1.9" - -latest-version@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-1.0.1.tgz#72cfc46e3e8d1be651e1ebb54ea9f6ea96f374bb" - dependencies: - package-json "^1.0.0" - -lazy-cache@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" - -lazystream@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-0.1.0.tgz#1b25d63c772a4c20f0a5ed0a9d77f484b6e16920" - dependencies: - readable-stream "~1.0.2" - -lcov-parse@0.0.10: - version "0.0.10" - resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" - -levn@~0.2.5: - version "0.2.5" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.2.5.tgz#ba8d339d0ca4a610e3a3f145b9caf48807155054" - dependencies: - prelude-ls "~1.1.0" - type-check "~0.3.1" - -levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - -libumd@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/libumd/-/libumd-0.7.0.tgz#f43efae6ad984ce4928c1f356f519d12ec8f9b76" - dependencies: - alphabet "^1.0.0" - annois "^0.3.2" - annozip "^0.2.6" - handlebars "^4.0.2" - object-merge "^2.5.1" - -livereload-js@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/livereload-js/-/livereload-js-2.2.2.tgz#6c87257e648ab475bc24ea257457edcc1f8d0bc2" - -load-json-file@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" - dependencies: - graceful-fs "^4.1.2" - parse-json "^2.2.0" - pify "^2.0.0" - pinkie-promise "^2.0.0" - strip-bom "^2.0.0" - -loader-utils@^0.2.11, loader-utils@^0.2.16, loader-utils@^0.2.5: - version "0.2.16" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d" - dependencies: - big.js "^3.1.3" - emojis-list "^2.0.0" - json5 "^0.5.0" - object-assign "^4.0.1" - -lodash._arraycopy@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1" - -lodash._arrayeach@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz#bab156b2a90d3f1bbd5c653403349e5e5933ef9e" - -lodash._arraymap@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._arraymap/-/lodash._arraymap-3.0.0.tgz#1a8fd0f4c0df4b61dea076d717cdc97f0a3c3e66" - -lodash._baseassign@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" - dependencies: - lodash._basecopy "^3.0.0" - lodash.keys "^3.0.0" - -lodash._baseclone@^3.0.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/lodash._baseclone/-/lodash._baseclone-3.3.0.tgz#303519bf6393fe7e42f34d8b630ef7794e3542b7" - dependencies: - lodash._arraycopy "^3.0.0" - lodash._arrayeach "^3.0.0" - lodash._baseassign "^3.0.0" - lodash._basefor "^3.0.0" - lodash.isarray "^3.0.0" - lodash.keys "^3.0.0" - -lodash._basecopy@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" - -lodash._basecreate@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" - -lodash._basedifference@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basedifference/-/lodash._basedifference-3.0.3.tgz#f2c204296c2a78e02b389081b6edcac933cf629c" - dependencies: - lodash._baseindexof "^3.0.0" - lodash._cacheindexof "^3.0.0" - lodash._createcache "^3.0.0" - -lodash._baseflatten@^3.0.0: - version "3.1.4" - resolved "https://registry.yarnpkg.com/lodash._baseflatten/-/lodash._baseflatten-3.1.4.tgz#0770ff80131af6e34f3b511796a7ba5214e65ff7" - dependencies: - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - -lodash._basefor@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2" - -lodash._baseindexof@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" - -lodash._bindcallback@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" - -lodash._cacheindexof@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" - -lodash._createassigner@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz#838a5bae2fdaca63ac22dee8e19fa4e6d6970b11" - dependencies: - lodash._bindcallback "^3.0.0" - lodash._isiterateecall "^3.0.0" - lodash.restparam "^3.0.0" - -lodash._createcache@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" - dependencies: - lodash._getnative "^3.0.0" - -lodash._getnative@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" - -lodash._isiterateecall@^3.0.0: - version "3.0.9" - resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" - -lodash._pickbyarray@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash._pickbyarray/-/lodash._pickbyarray-3.0.2.tgz#1f898d9607eb560b0e167384b77c7c6d108aa4c5" - -lodash._pickbycallback@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._pickbycallback/-/lodash._pickbycallback-3.0.0.tgz#ff61b9a017a7b3af7d30e6c53de28afa19b8750a" - dependencies: - lodash._basefor "^3.0.0" - lodash.keysin "^3.0.0" - -lodash._reinterpolate@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - -lodash.assign@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" - -lodash.clonedeep@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-3.0.2.tgz#a0a1e40d82a5ea89ff5b147b8444ed63d92827db" - dependencies: - lodash._baseclone "^3.0.0" - lodash._bindcallback "^3.0.0" - -lodash.create@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" - dependencies: - lodash._baseassign "^3.0.0" - lodash._basecreate "^3.0.0" - lodash._isiterateecall "^3.0.0" - -lodash.isarguments@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" - -lodash.isarray@^3.0.0: - version "3.0.4" - resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" - -lodash.isplainobject@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz#9a8238ae16b200432960cd7346512d0123fbf4c5" - dependencies: - lodash._basefor "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.keysin "^3.0.0" - -lodash.istypedarray@^3.0.0: - version "3.0.6" - resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62" - -lodash.keys@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" - dependencies: - lodash._getnative "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - -lodash.keysin@^3.0.0: - version "3.0.8" - resolved "https://registry.yarnpkg.com/lodash.keysin/-/lodash.keysin-3.0.8.tgz#22c4493ebbedb1427962a54b445b2c8a767fb47f" - dependencies: - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - -lodash.merge@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-3.3.2.tgz#0d90d93ed637b1878437bb3e21601260d7afe994" - dependencies: - lodash._arraycopy "^3.0.0" - lodash._arrayeach "^3.0.0" - lodash._createassigner "^3.0.0" - lodash._getnative "^3.0.0" - lodash.isarguments "^3.0.0" - lodash.isarray "^3.0.0" - lodash.isplainobject "^3.0.0" - lodash.istypedarray "^3.0.0" - lodash.keys "^3.0.0" - lodash.keysin "^3.0.0" - lodash.toplainobject "^3.0.0" - -lodash.omit@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-3.1.0.tgz#897fe382e6413d9ac97c61f78ed1e057a00af9f3" - dependencies: - lodash._arraymap "^3.0.0" - lodash._basedifference "^3.0.0" - lodash._baseflatten "^3.0.0" - lodash._bindcallback "^3.0.0" - lodash._pickbyarray "^3.0.0" - lodash._pickbycallback "^3.0.0" - lodash.keysin "^3.0.0" - lodash.restparam "^3.0.0" - -lodash.restparam@^3.0.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" - -lodash.template@^4.0.2: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" - dependencies: - lodash._reinterpolate "~3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" - dependencies: - lodash._reinterpolate "~3.0.0" - -lodash.toplainobject@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz#28790ad942d293d78aa663a07ecf7f52ca04198d" - dependencies: - lodash._basecopy "^3.0.0" - lodash.keysin "^3.0.0" - -lodash@^2.4.1, lodash@~2.4.1: - version "2.4.2" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e" - -lodash@^3.10.1, lodash@^3.3.1, lodash@^3.8.0, lodash@~3.10.1: - version "3.10.1" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" - -lodash@^4.0.0, lodash@^4.0.1, lodash@^4.1.0, lodash@^4.17.2, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.5.0, lodash@^4.7.0: - version "4.17.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" - -lodash@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" - -lodash@~4.16.4: - version "4.16.6" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777" - -lodash@~4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4" - -log-driver@1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" - -log4js@^0.6.31: - version "0.6.38" - resolved "https://registry.yarnpkg.com/log4js/-/log4js-0.6.38.tgz#2c494116695d6fb25480943d3fc872e662a522fd" - dependencies: - readable-stream "~1.0.2" - semver "~4.3.3" - -lolex@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" - -longest-streak@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-1.0.0.tgz#d06597c4d4c31b52ccb1f5d8f8fe7148eafd6965" - -longest@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" - -loose-envify@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" - dependencies: - js-tokens "^2.0.0" - -loud-rejection@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" - dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.0" - -lowercase-keys@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" - -lru-cache@2, lru-cache@2.2.x: - version "2.2.4" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d" - -map-obj@^1.0.0, map-obj@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" - -markdown-table@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-0.4.0.tgz#890c2c1b3bfe83fb00e4129b8e4cfe645270f9d1" - -markdown-to-ast@~3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/markdown-to-ast/-/markdown-to-ast-3.4.0.tgz#0e2cba81390b0549a9153ec3b0d915b61c164be7" - dependencies: - debug "^2.1.3" - remark "^5.0.1" - structured-source "^3.0.2" - traverse "^0.6.6" - -marked-terminal@^1.6.2: - version "1.7.0" - resolved "https://registry.yarnpkg.com/marked-terminal/-/marked-terminal-1.7.0.tgz#c8c460881c772c7604b64367007ee5f77f125904" - dependencies: - cardinal "^1.0.0" - chalk "^1.1.3" - cli-table "^0.3.1" - lodash.assign "^4.2.0" - node-emoji "^1.4.1" - -marked@^0.3.6: - version "0.3.6" - resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.6.tgz#b2c6c618fccece4ef86c4fc6cb8a7cbf5aeda8d7" - -maxmin@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/maxmin/-/maxmin-1.1.0.tgz#71365e84a99dd8f8b3f7d5fde2f00d1e7f73be61" - dependencies: - chalk "^1.0.0" - figures "^1.0.1" - gzip-size "^1.0.0" - pretty-bytes "^1.0.0" - -media-typer@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" - -memory-fs@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" - -memory-fs@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.3.0.tgz#7bcc6b629e3a43e871d7e29aca6ae8a7f15cbb20" - dependencies: - errno "^0.1.3" - readable-stream "^2.0.1" - -memory-fs@~0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" - dependencies: - errno "^0.1.3" - readable-stream "^2.0.1" - -meow@^3.0.0, meow@^3.1.0, meow@^3.3.0, meow@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" - dependencies: - camelcase-keys "^2.0.0" - decamelize "^1.1.2" - loud-rejection "^1.0.0" - map-obj "^1.0.1" - minimist "^1.1.3" - normalize-package-data "^2.3.4" - object-assign "^4.0.1" - read-pkg-up "^1.0.1" - redent "^1.0.0" - trim-newlines "^1.0.0" - -merge-descriptors@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" - -methods@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" - -micromatch@^2.1.5, micromatch@^2.3.11: - version "2.3.11" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -"mime-db@>= 1.24.0 < 2", mime-db@~1.25.0: - version "1.25.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392" - -mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.13, mime-types@~2.1.7: - version "2.1.13" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88" - dependencies: - mime-db "~1.25.0" - -mime@1.3.4, mime@>=1.2.9, mime@^1.3.4: - version "1.3.4" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53" - -mime@~1.2.11, mime@~1.2.9: - version "1.2.11" - resolved "https://registry.yarnpkg.com/mime/-/mime-1.2.11.tgz#58203eed86e3a5ef17aed2b7d9ebd47f0a60dd10" - -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@~3.0.0, minimatch@~3.0.2: - version "3.0.3" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" - dependencies: - brace-expansion "^1.0.0" - -minimatch@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-1.0.0.tgz#e0dd2120b49e1b724ce8d714c520822a9438576d" - dependencies: - lru-cache "2" - sigmund "~1.0.0" - -minimatch@^2.0.1: - version "2.0.10" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" - dependencies: - brace-expansion "^1.0.0" - -minimatch@~0.2.11, minimatch@~0.2.9: - version "0.2.14" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" - dependencies: - lru-cache "2" - sigmund "~1.0.0" - -minimist@0.0.8, minimist@~0.0.1, minimist@~0.0.7: - version "0.0.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -minimist@1.2.0, minimist@^1.1.3, minimist@^1.2.0, minimist@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - -minimist@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.2.0.tgz#4dffe525dae2b864c66c2e23c6271d7afdecefce" - -mkdirp@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" - dependencies: - minimist "0.0.8" - -mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1: - version "0.5.1" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -mocha@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.4.1.tgz#a3802b4aa381934cacb38de70cf771621da8f9af" - dependencies: - browser-stdout "1.3.0" - commander "2.9.0" - debug "2.6.0" - diff "3.2.0" - escape-string-regexp "1.0.5" - glob "7.1.1" - growl "1.9.2" - json3 "3.3.2" - lodash.create "3.1.1" - mkdirp "0.5.1" - supports-color "3.1.2" - -modify-values@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.0.tgz#e2b6cdeb9ce19f99317a53722f3dbf5df5eaaab2" - -monocle-js@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/monocle-js/-/monocle-js-1.0.2.tgz#2b5e43861833de4a3cf65d92449ede0795d4943e" - dependencies: - harmony-reflect "~1.1.1" - underscore "~1.4.4" - -morgan@^1.6.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/morgan/-/morgan-1.7.0.tgz#eb10ca8e50d1abe0f8d3dad5c0201d052d981c62" - dependencies: - basic-auth "~1.0.3" - debug "~2.2.0" - depd "~1.1.0" - on-finished "~2.3.0" - on-headers "~1.0.1" - -ms@0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.6.2.tgz#d89c2124c6fdc1353d65a8b77bf1aac4b193708c" - -ms@0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - -ms@0.7.2: - version "0.7.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" - -mute-stream@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" - -mversion@^1.10.1: - version "1.10.1" - resolved "https://registry.yarnpkg.com/mversion/-/mversion-1.10.1.tgz#9322d1a4f11f6670de0024d1823a32a615a3d40e" - dependencies: - chalk "^0.5.0" - cli-usage "^0.1.2" - contra "^1.6.8" - minimatch "^1.0.0" - minimist "^0.2.0" - rc "^0.5.0" - semver "^4.0.3" - through2 "^1.0.0" - update-notifier "^0.2.2" - vinyl-fs "^0.3.4" - -nan@^2.3.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.0.tgz#aa8f1e34531d807e9e27755b234b4a6ec0c152a8" - -natives@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" - -negotiator@0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" - -nested-error-stacks@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/nested-error-stacks/-/nested-error-stacks-1.0.2.tgz#19f619591519f096769a5ba9a86e6eeec823c3cf" - dependencies: - inherits "~2.0.1" - -node-emoji@^1.4.1: - version "1.5.0" - resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.5.0.tgz#9a0d9fe03fd43afa357d6d8e439aa31e599959b7" - dependencies: - string.prototype.codepointat "^0.2.0" - -node-libs-browser@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-0.7.0.tgz#3e272c0819e308935e26674408d7af0e1491b83b" - dependencies: - assert "^1.1.1" - browserify-zlib "^0.1.4" - buffer "^4.9.0" - console-browserify "^1.1.0" - constants-browserify "^1.0.0" - crypto-browserify "3.3.0" - domain-browser "^1.1.1" - events "^1.0.0" - https-browserify "0.0.1" - os-browserify "^0.2.0" - path-browserify "0.0.0" - process "^0.11.0" - punycode "^1.2.4" - querystring-es3 "^0.2.0" - readable-stream "^2.0.5" - stream-browserify "^2.0.1" - stream-http "^2.3.1" - string_decoder "^0.10.25" - timers-browserify "^2.0.2" - tty-browserify "0.0.0" - url "^0.11.0" - util "^0.10.3" - vm-browserify "0.0.4" - -node-pre-gyp@^0.6.29: - version "0.6.32" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz#fc452b376e7319b3d255f5f34853ef6fd8fe1fd5" - dependencies: - mkdirp "~0.5.1" - nopt "~3.0.6" - npmlog "^4.0.1" - rc "~1.1.6" - request "^2.79.0" - rimraf "~2.5.4" - semver "~5.3.0" - tar "~2.2.1" - tar-pack "~3.3.0" - -node-static@^0.7.8: - version "0.7.9" - resolved "https://registry.yarnpkg.com/node-static/-/node-static-0.7.9.tgz#9bb69fce2281f7ae3cd1fb983e9ea0ec0cd9fecb" - dependencies: - colors ">=0.6.0" - mime ">=1.2.9" - optimist ">=0.3.4" - -node-uuid@~1.4.0, node-uuid@~1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f" - -nomnom@1.6.x: - version "1.6.2" - resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.6.2.tgz#84a66a260174408fc5b77a18f888eccc44fb6971" - dependencies: - colors "0.5.x" - underscore "~1.4.4" - -nopt@3.x, nopt@~3.0.6: - version "3.0.6" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" - dependencies: - abbrev "1" - -normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: - version "2.3.5" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" - dependencies: - hosted-git-info "^2.1.4" - is-builtin-module "^1.0.0" - semver "2 || 3 || 4 || 5" - validate-npm-package-license "^3.0.1" - -normalize-path@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" - -npmlog@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.1" - set-blocking "~2.0.0" - -null-check@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - -oauth-sign@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.3.0.tgz#cb540f93bb2b22a7d5941691a288d60e8ea9386e" - -oauth-sign@~0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" - -object-assign@4.1.0, object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" - -object-assign@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" - -object-assign@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" - -object-component@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" - -object-foreach@>=0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/object-foreach/-/object-foreach-0.1.2.tgz#d7421c5b40e3b6a3ef57ac624368d21d8f8d2dec" - -object-keys@^1.0.10, object-keys@^1.0.8: - version "1.0.11" - resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" - -object-merge@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/object-merge/-/object-merge-2.5.1.tgz#077e8915ce38ea7294788448c5dd339e34df4227" - dependencies: - clone-function ">=1.0.1" - object-foreach ">=0.1.2" - -object.assign@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc" - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.0" - object-keys "^1.0.10" - -object.omit@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - dependencies: - ee-first "1.1.1" - -on-headers@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7" - -once@1.x, once@^1.3.0, once@^1.3.1, once@^1.3.3: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - dependencies: - wrappy "1" - -once@~1.3.0, once@~1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" - dependencies: - wrappy "1" - -open@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc" - -opn@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" - dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" - -optimist@>=0.3.4, optimist@^0.6.1, optimist@~0.6.0, optimist@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" - dependencies: - minimist "~0.0.1" - wordwrap "~0.0.2" - -optionator@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.5.0.tgz#b75a8995a2d417df25b6e4e3862f50aa88651368" - dependencies: - deep-is "~0.1.2" - fast-levenshtein "~1.0.0" - levn "~0.2.5" - prelude-ls "~1.1.1" - type-check "~0.3.1" - wordwrap "~0.0.2" - -optionator@^0.8.1: - version "0.8.2" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.4" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - wordwrap "~1.0.0" - -options@>=0.0.5: - version "0.0.6" - resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" - -ordered-read-streams@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" - -original@>=0.0.5: - version "1.0.0" - resolved "https://registry.yarnpkg.com/original/-/original-1.0.0.tgz#9147f93fa1696d04be61e01bd50baeaca656bd3b" - dependencies: - url-parse "1.0.x" - -os-browserify@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.2.1.tgz#63fc4ccee5d2d7763d26bbf8601078e6c2e0044f" - -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - -os-tmpdir@^1.0.0, os-tmpdir@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - -osenv@^0.1.0: - version "0.1.4" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - -package-json@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/package-json/-/package-json-1.2.0.tgz#c8ecac094227cdf76a316874ed05e27cc939a0e0" - dependencies: - got "^3.2.0" - registry-url "^3.0.0" - -pad-stream@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/pad-stream/-/pad-stream-1.2.0.tgz#631dcc9f79810b705965e89dedea6cff0fc1dfc9" - dependencies: - meow "^3.0.0" - pumpify "^1.3.3" - repeating "^2.0.0" - split2 "^1.0.0" - through2 "^2.0.0" - -pako@~0.2.0: - version "0.2.9" - resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75" - -parse-entities@^1.0.2: - version "1.1.0" - resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-1.1.0.tgz#4bc58f35fdc8e65dded35a12f2e40223ca24a3f7" - dependencies: - character-entities "^1.0.0" - character-entities-legacy "^1.0.0" - character-reference-invalid "^1.0.0" - has "^1.0.1" - is-alphanumerical "^1.0.0" - is-decimal "^1.0.0" - is-hexadecimal "^1.0.0" - -parse-github-repo-url@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.3.0.tgz#d4de02d68e2e60f0d6a182e7a8cb21b6f38c730b" - -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" - dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" - -parse-json@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" - dependencies: - error-ex "^1.2.0" - -parsejson@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/parsejson/-/parsejson-0.0.3.tgz#ab7e3759f209ece99437973f7d0f1f64ae0e64ab" - dependencies: - better-assert "~1.0.0" - -parseqs@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" - dependencies: - better-assert "~1.0.0" - -parseuri@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" - dependencies: - better-assert "~1.0.0" - -parseurl@~1.3.0, parseurl@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56" - -path-browserify@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.0.tgz#a0b870729aae214005b7d5032ec2cbbb0fb4451a" - -path-exists@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" - dependencies: - pinkie-promise "^2.0.0" - -path-is-absolute@^1.0.0, path-is-absolute@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - -path-is-inside@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - -path-to-regexp@0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" - -path-type@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" - dependencies: - graceful-fs "^4.1.2" - pify "^2.0.0" - pinkie-promise "^2.0.0" - -pbkdf2-compat@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz#b6e0c8fa99494d94e0511575802a59a5c142f288" - -pend@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" - -phantomjs-prebuilt@^2.1.12, phantomjs-prebuilt@^2.1.7: - version "2.1.14" - resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.14.tgz#d53d311fcfb7d1d08ddb24014558f1188c516da0" - dependencies: - es6-promise "~4.0.3" - extract-zip "~1.5.0" - fs-extra "~1.0.0" - hasha "~2.2.0" - kew "~0.7.0" - progress "~1.1.8" - request "~2.79.0" - request-progress "~2.0.1" - which "~1.2.10" - -pify@^2.0.0, pify@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" - -pinkie-promise@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" - dependencies: - pinkie "^2.0.0" - -pinkie@^2.0.0: - version "2.0.4" - resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" - -portscanner@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/portscanner/-/portscanner-1.2.0.tgz#b14bbda257d14c310fa9cc09682af02d40961802" - dependencies: - async "1.5.2" - -prelude-ls@~1.1.0, prelude-ls@~1.1.1, prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - -prepend-http@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - -preserve@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - -pretty-bytes@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84" - dependencies: - get-stdin "^4.0.1" - meow "^3.1.0" - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - -process@^0.11.0: - version "0.11.9" - resolved "https://registry.yarnpkg.com/process/-/process-0.11.9.tgz#7bd5ad21aa6253e7da8682264f1e11d11c0318c1" - -progress@~1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" - -proxy-addr@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.2.tgz#b4cc5f22610d9535824c123aef9d3cf73c40ba37" - dependencies: - forwarded "~0.1.0" - ipaddr.js "1.1.1" - -prr@~0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a" - -pump@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.2.tgz#3b3ee6512f94f0e575538c17995f9f16990a5d51" - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pumpify@^1.3.3: - version "1.3.5" - resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.3.5.tgz#1b671c619940abcaeac0ad0e3a3c164be760993b" - dependencies: - duplexify "^3.1.2" - inherits "^2.0.1" - pump "^1.0.0" - -punycode@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - -punycode@^1.2.4, punycode@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - -q@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" - -q@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/q/-/q-1.0.1.tgz#11872aeedee89268110b10a718448ffb10112a14" - -qjobs@^1.1.4: - version "1.1.5" - resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.1.5.tgz#659de9f2cf8dcc27a1481276f205377272382e73" - -qs@5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.0.tgz#a9f31142af468cb72b25b30136ba2456834916be" - -qs@6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.0.tgz#3b7848c03c2dece69a9522b0fae8c4126d745f3b" - -qs@6.2.1, qs@~6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625" - -qs@~0.6.0: - version "0.6.6" - resolved "https://registry.yarnpkg.com/qs/-/qs-0.6.6.tgz#6e015098ff51968b8a3c819001d5f2c89bc4b107" - -qs@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-5.1.0.tgz#4d932e5c7ea411cca76a312d39a606200fd50cd9" - -qs@~6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" - -querystring-es3@^0.2.0: - version "0.2.1" - resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" - -querystring@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - -querystringify@0.0.x: - version "0.0.4" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-0.0.4.tgz#0cf7f84f9463ff0ae51c4c4b142d95be37724d9c" - -randomatic@^1.1.3: - version "1.1.6" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" - dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" - -range-parser@^1.0.3, range-parser@^1.2.0, range-parser@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" - -raw-body@~2.1.5: - version "2.1.7" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.1.7.tgz#adfeace2e4fb3098058014d08c072dcc59758774" - dependencies: - bytes "2.4.0" - iconv-lite "0.4.13" - unpipe "1.0.0" - -raw-body@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.2.0.tgz#994976cf6a5096a41162840492f0bdc5d6e7fb96" - dependencies: - bytes "2.4.0" - iconv-lite "0.4.15" - unpipe "1.0.0" - -rc@^0.5.0: - version "0.5.5" - resolved "https://registry.yarnpkg.com/rc/-/rc-0.5.5.tgz#541cc3300f464b6dfe6432d756f0f2dd3e9eb199" - dependencies: - deep-extend "~0.2.5" - ini "~1.3.0" - minimist "~0.0.7" - strip-json-comments "0.1.x" - -rc@^1.0.1, rc@~1.1.6: - version "1.1.6" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.1.6.tgz#43651b76b6ae53b5c802f1151fa3fc3b059969c9" - dependencies: - deep-extend "~0.4.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~1.0.4" - -read-all-stream@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/read-all-stream/-/read-all-stream-3.1.0.tgz#35c3e177f2078ef789ee4bfafa4373074eaef4fa" - dependencies: - pinkie-promise "^2.0.0" - readable-stream "^2.0.0" - -read-pkg-up@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" - dependencies: - find-up "^1.0.0" - read-pkg "^1.0.0" - -read-pkg@^1.0.0, read-pkg@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" - dependencies: - load-json-file "^1.0.0" - normalize-package-data "^2.3.2" - path-type "^1.0.0" - -"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.2, readable-stream@~1.0.24, readable-stream@~1.0.26: - version "1.0.34" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -"readable-stream@>=1.1.13-1 <1.2.0-0", readable-stream@^1.0.27-1: - version "1.1.13" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "0.0.1" - string_decoder "~0.10.x" - -readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.1.0, readable-stream@^2.1.5: - version "2.2.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e" - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readable-stream@~2.0.0, readable-stream@~2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readable-stream@~2.1.4: - version "2.1.5" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readdirp@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" - dependencies: - graceful-fs "^4.1.2" - minimatch "^3.0.2" - readable-stream "^2.0.2" - set-immediate-shim "^1.0.1" - -readline2@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/readline2/-/readline2-0.1.1.tgz#99443ba6e83b830ef3051bfd7dc241a82728d568" - dependencies: - mute-stream "0.0.4" - strip-ansi "^2.0.1" - -redent@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" - dependencies: - indent-string "^2.1.0" - strip-indent "^1.0.1" - -redeyed@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-1.0.1.tgz#e96c193b40c0816b00aec842698e61185e55498a" - dependencies: - esprima "~3.0.0" - -regenerator-runtime@^0.10.0: - version "0.10.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.1.tgz#257f41961ce44558b18f7814af48c17559f9faeb" - -regex-cache@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" - dependencies: - is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" - -registry-url@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" - dependencies: - rc "^1.0.1" - -remark-parse@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-1.1.0.tgz#c3ca10f9a8da04615c28f09aa4e304510526ec21" - dependencies: - collapse-white-space "^1.0.0" - extend "^3.0.0" - parse-entities "^1.0.2" - repeat-string "^1.5.4" - trim "0.0.1" - trim-trailing-lines "^1.0.0" - unherit "^1.0.4" - unist-util-remove-position "^1.0.0" - vfile-location "^2.0.0" - -remark-stringify@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/remark-stringify/-/remark-stringify-1.1.0.tgz#a7105e25b9ee2bf9a49b75d2c423f11b06ae2092" - dependencies: - ccount "^1.0.0" - extend "^3.0.0" - longest-streak "^1.0.0" - markdown-table "^0.4.0" - parse-entities "^1.0.2" - repeat-string "^1.5.4" - stringify-entities "^1.0.1" - unherit "^1.0.4" - -remark@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/remark/-/remark-5.1.0.tgz#cb463bd3dbcb4b99794935eee1cf71d7a8e3068c" - dependencies: - remark-parse "^1.1.0" - remark-stringify "^1.1.0" - unified "^4.1.1" - -repeat-element@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" - -repeat-string@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" - -repeat-string@^1.5.2, repeat-string@^1.5.4: - version "1.6.1" - resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - dependencies: - is-finite "^1.0.0" - -replace@~0.2.4: - version "0.2.10" - resolved "https://registry.yarnpkg.com/replace/-/replace-0.2.10.tgz#1123397e995b3bfef9985fc63cddcf79a014fd64" - dependencies: - colors "0.5.x" - minimatch "~0.2.9" - nomnom "1.6.x" - -request-progress@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" - dependencies: - throttleit "^1.0.0" - -request@2.75.0: - version "2.75.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - bl "~1.1.2" - caseless "~0.11.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.0.0" - har-validator "~2.0.6" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - node-uuid "~1.4.7" - oauth-sign "~0.8.1" - qs "~6.2.0" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" - -request@^2.79.0, request@~2.79.0: - version "2.79.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - caseless "~0.11.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.1.1" - har-validator "~2.0.6" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - oauth-sign "~0.8.1" - qs "~6.3.0" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" - uuid "^3.0.0" - -request@~2.36.0: - version "2.36.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.36.0.tgz#28c6c04262c7b9ffdd21b9255374517ee6d943f5" - dependencies: - forever-agent "~0.5.0" - json-stringify-safe "~5.0.0" - mime "~1.2.9" - node-uuid "~1.4.0" - qs "~0.6.0" - optionalDependencies: - aws-sign2 "~0.5.0" - form-data "~0.1.0" - hawk "~1.0.0" - http-signature "~0.10.0" - oauth-sign "~0.3.0" - tough-cookie ">=0.12.0" - tunnel-agent "~0.4.0" - -requires-port@1.0.x, requires-port@1.x.x: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - -resolve@1.1.x, resolve@~1.1.0: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" - -right-align@^0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" - dependencies: - align-text "^0.1.1" - -rimraf@2, rimraf@^2.2.2, rimraf@^2.2.8, rimraf@^2.6.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" - dependencies: - glob "^7.0.5" - -rimraf@^2.5.1, rimraf@~2.5.1, rimraf@~2.5.4: - version "2.5.4" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" - dependencies: - glob "^7.0.5" - -rimraf@~2.2.8: - version "2.2.8" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" - -ripemd160@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-0.2.0.tgz#2bf198bde167cacfa51c0a928e84b68bbe171fce" - -run-async@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" - dependencies: - once "^1.3.0" - -rx-lite@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-2.5.2.tgz#5fef42d4d6e76bab5199d2171327db709e58e634" - -safe-buffer@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" - -samsam@1.1.2, samsam@~1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" - -saucelabs@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-0.1.1.tgz#5e0ea1cf3d735d6ea15fde94b5bda6bc15d2c06d" - -semver-diff@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" - dependencies: - semver "^5.0.3" - -"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.3.0, semver@~5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" - -semver@^4.0.3, semver@~4.3.3: - version "4.3.6" - resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" - -send@0.14.1: - version "0.14.1" - resolved "https://registry.yarnpkg.com/send/-/send-0.14.1.tgz#a954984325392f51532a7760760e459598c89f7a" - dependencies: - debug "~2.2.0" - depd "~1.1.0" - destroy "~1.0.4" - encodeurl "~1.0.1" - escape-html "~1.0.3" - etag "~1.7.0" - fresh "0.3.0" - http-errors "~1.5.0" - mime "1.3.4" - ms "0.7.1" - on-finished "~2.3.0" - range-parser "~1.2.0" - statuses "~1.3.0" - -serve-index@^1.7.1, serve-index@^1.7.2: - version "1.8.0" - resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.8.0.tgz#7c5d96c13fb131101f93c1c5774f8516a1e78d3b" - dependencies: - accepts "~1.3.3" - batch "0.5.3" - debug "~2.2.0" - escape-html "~1.0.3" - http-errors "~1.5.0" - mime-types "~2.1.11" - parseurl "~1.3.1" - -serve-static@^1.10.0, serve-static@~1.11.1: - version "1.11.1" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.11.1.tgz#d6cce7693505f733c759de57befc1af76c0f0805" - dependencies: - encodeurl "~1.0.1" - escape-html "~1.0.3" - parseurl "~1.3.1" - send "0.14.1" - -set-blocking@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - -set-immediate-shim@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" - -setimmediate@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - -setprototypeof@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.2.tgz#81a552141ec104b88e89ce383103ad5c66564d08" - -sha.js@2.2.6: - version "2.2.6" - resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba" - -shelljs@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1" - -sigmund@~1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" - -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - -sinon@^1.17.6: - version "1.17.7" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" - dependencies: - formatio "1.1.1" - lolex "1.3.2" - samsam "1.1.2" - util ">=0.10.3 <1" - -sntp@0.2.x: - version "0.2.4" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-0.2.4.tgz#fb885f18b0f3aad189f824862536bceeec750900" - dependencies: - hoek "0.9.x" - -sntp@1.x.x: - version "1.0.9" - resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" - dependencies: - hoek "2.x.x" - -socket.io-adapter@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz#cb6d4bb8bec81e1078b99677f9ced0046066bb8b" - dependencies: - debug "2.3.3" - socket.io-parser "2.3.1" - -socket.io-client@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.3.tgz#b30e86aa10d5ef3546601c09cde4765e381da377" - dependencies: - backo2 "1.0.2" - component-bind "1.0.0" - component-emitter "1.2.1" - debug "2.3.3" - engine.io-client "1.8.3" - has-binary "0.1.7" - indexof "0.0.1" - object-component "0.0.3" - parseuri "0.0.5" - socket.io-parser "2.3.1" - to-array "0.1.4" - -socket.io-parser@2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-2.3.1.tgz#dd532025103ce429697326befd64005fcfe5b4a0" - dependencies: - component-emitter "1.1.2" - debug "2.2.0" - isarray "0.0.1" - json3 "3.3.2" - -socket.io@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.3.tgz#b8af9caba00949e568e369f1327ea9be9ea2461b" - dependencies: - debug "2.3.3" - engine.io "1.8.3" - has-binary "0.1.7" - object-assign "4.1.0" - socket.io-adapter "0.5.0" - socket.io-client "1.7.3" - socket.io-parser "2.3.1" - -sockjs-client@^1.0.3: - version "1.1.2" - resolved "https://registry.yarnpkg.com/sockjs-client/-/sockjs-client-1.1.2.tgz#f0212a8550e4c9468c8cceaeefd2e3493c033ad5" - dependencies: - debug "^2.2.0" - eventsource "0.1.6" - faye-websocket "~0.11.0" - inherits "^2.0.1" - json3 "^3.3.2" - url-parse "^1.1.1" - -sockjs@^0.3.15: - version "0.3.18" - resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.18.tgz#d9b289316ca7df77595ef299e075f0f937eb4207" - dependencies: - faye-websocket "^0.10.0" - uuid "^2.0.2" - -source-list-map@~0.1.7: - version "0.1.7" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.7.tgz#d4b5ce2a46535c72c7e8527c71a77d250618172e" - -source-map@^0.1.41: - version "0.1.43" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" - dependencies: - amdefine ">=0.0.4" - -source-map@^0.4.4, source-map@~0.4.1: - version "0.4.4" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" - dependencies: - amdefine ">=0.0.4" - -source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@~0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - -source-map@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" - dependencies: - amdefine ">=0.0.4" - -spdx-correct@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" - dependencies: - spdx-license-ids "^1.0.2" - -spdx-expression-parse@~1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" - -spdx-license-ids@^1.0.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" - -split2@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/split2/-/split2-1.1.1.tgz#162d9b18865f02ab2f2ad9585522db9b54c481f9" - dependencies: - through2 "~2.0.0" - -split2@^2.0.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/split2/-/split2-2.1.1.tgz#7a1f551e176a90ecd3345f7246a0cfe175ef4fd0" - dependencies: - through2 "^2.0.2" - -split@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/split/-/split-1.0.0.tgz#c4395ce683abcd254bc28fe1dabb6e5c27dcffae" - dependencies: - through "2" - -sprintf-js@~1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - -sshpk@^1.7.0: - version "1.10.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.1.tgz#30e1a5d329244974a1af61511339d595af6638b0" - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - dashdash "^1.12.0" - getpass "^0.1.1" - optionalDependencies: - bcrypt-pbkdf "^1.0.0" - ecc-jsbn "~0.1.1" - jodid25519 "^1.0.0" - jsbn "~0.1.0" - tweetnacl "~0.14.0" - -statuses@1, "statuses@>= 1.3.1 < 2", statuses@~1.3.0, statuses@~1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" - -stream-browserify@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" - dependencies: - inherits "~2.0.1" - readable-stream "^2.0.2" - -stream-cache@~0.0.1: - version "0.0.2" - resolved "https://registry.yarnpkg.com/stream-cache/-/stream-cache-0.0.2.tgz#1ac5ad6832428ca55667dbdee395dad4e6db118f" - -stream-http@^2.3.1: - version "2.6.0" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.6.0.tgz#adf3309ced17624ebfb7ef13e6ac4cfe405a8b12" - dependencies: - builtin-status-codes "^3.0.0" - inherits "^2.0.1" - readable-stream "^2.1.0" - to-arraybuffer "^1.0.0" - xtend "^4.0.0" - -stream-shift@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" - -string-length@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac" - dependencies: - strip-ansi "^3.0.0" - -string-width@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -string.prototype.codepointat@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/string.prototype.codepointat/-/string.prototype.codepointat-0.2.0.tgz#6b26e9bd3afcaa7be3b4269b526de1b82000ac78" - -string_decoder@^0.10.25, string_decoder@~0.10.x: - version "0.10.31" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - -stringify-entities@^1.0.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/stringify-entities/-/stringify-entities-1.3.0.tgz#2244a516c4f1e8e01b73dad01023016776abd917" - dependencies: - character-entities-html4 "^1.0.0" - character-entities-legacy "^1.0.0" - has "^1.0.1" - is-alphanumerical "^1.0.0" - is-hexadecimal "^1.0.0" - -stringstream@~0.0.4: - version "0.0.5" - resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" - -strip-ansi@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" - dependencies: - ansi-regex "^0.2.1" - -strip-ansi@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-2.0.1.tgz#df62c1aa94ed2f114e1d0f21fd1d50482b79a60e" - dependencies: - ansi-regex "^1.0.0" - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - dependencies: - ansi-regex "^2.0.0" - -strip-bom@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" - dependencies: - first-chunk-stream "^1.0.0" - is-utf8 "^0.2.0" - -strip-bom@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" - dependencies: - is-utf8 "^0.2.0" - -strip-indent@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" - dependencies: - get-stdin "^4.0.1" - -strip-json-comments@0.1.x: - version "0.1.3" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-0.1.3.tgz#164c64e370a8a3cc00c9e01b539e569823f0ee54" - -strip-json-comments@1.0.4, strip-json-comments@~1.0.1, strip-json-comments@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" - -structured-source@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/structured-source/-/structured-source-3.0.2.tgz#dd802425e0f53dc4a6e7aca3752901a1ccda7af5" - dependencies: - boundary "^1.0.1" - -supports-color@3.1.2, supports-color@^3.1.0, supports-color@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" - dependencies: - has-flag "^1.0.0" - -supports-color@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - -tapable@^0.1.8, tapable@~0.1.8: - version "0.1.10" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" - -tar-pack@~3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" - dependencies: - debug "~2.2.0" - fstream "~1.0.10" - fstream-ignore "~1.0.5" - once "~1.3.3" - readable-stream "~2.1.4" - rimraf "~2.5.1" - tar "~2.2.1" - uid-number "~0.0.6" - -tar-stream@~0.4.0: - version "0.4.7" - resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-0.4.7.tgz#1f1d2ce9ebc7b42765243ca0e8f1b7bfda0aadcd" - dependencies: - bl "^0.9.0" - end-of-stream "^1.0.0" - readable-stream "^1.0.27-1" - xtend "^4.0.0" - -tar@~2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" - dependencies: - block-stream "*" - fstream "^1.0.2" - inherits "2" - -tempfile@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2" - dependencies: - os-tmpdir "^1.0.0" - uuid "^2.0.1" - -text-extensions@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.4.0.tgz#c385d2e80879fe6ef97893e1709d88d9453726e9" - -text-table@~0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - -throttleit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" - -through2@^0.6.1: - version "0.6.5" - resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" - dependencies: - readable-stream ">=1.0.33-1 <1.1.0-0" - xtend ">=4.0.0 <4.1.0-0" - -through2@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/through2/-/through2-1.1.1.tgz#0847cbc4449f3405574dbdccd9bb841b83ac3545" - dependencies: - readable-stream ">=1.1.13-1 <1.2.0-0" - xtend ">=4.0.0 <4.1.0-0" - -through2@^2.0.0, through2@^2.0.2, through2@~2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" - dependencies: - readable-stream "^2.1.5" - xtend "~4.0.1" - -through@2, "through@>=2.2.7 <3", through@^2.3.6: - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - -ticky@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ticky/-/ticky-1.0.1.tgz#b7cfa71e768f1c9000c497b9151b30947c50e46d" - -timed-out@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-2.0.0.tgz#f38b0ae81d3747d628001f41dafc652ace671c0a" - -timers-browserify@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.2.tgz#ab4883cf597dcd50af211349a00fbca56ac86b86" - dependencies: - setimmediate "^1.0.4" - -tiny-lr@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tiny-lr/-/tiny-lr-0.2.1.tgz#b3fdba802e5d56a33c2f6f10794b32e477ac729d" - dependencies: - body-parser "~1.14.0" - debug "~2.2.0" - faye-websocket "~0.10.0" - livereload-js "^2.2.0" - parseurl "~1.3.0" - qs "~5.1.0" - -tmp@0.0.31, tmp@0.0.x: - version "0.0.31" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.31.tgz#8f38ab9438e17315e5dbd8b3657e8bfb277ae4a7" - dependencies: - os-tmpdir "~1.0.1" - -to-array@0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" - -to-arraybuffer@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" - -to-double-quotes@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/to-double-quotes/-/to-double-quotes-1.0.2.tgz#bb6ed36c78634c3d64fd87a51ad5860dc594edfd" - dependencies: - get-stdin "^3.0.0" - -to-fast-properties@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" - -to-single-quotes@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/to-single-quotes/-/to-single-quotes-1.0.4.tgz#2eea8199af26ca1171f5357c59e192d565ee5313" - dependencies: - get-stdin "^3.0.0" - -tough-cookie@>=0.12.0, tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" - dependencies: - punycode "^1.4.1" - -traverse@^0.6.6: - version "0.6.6" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" - -trim-newlines@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" - -trim-off-newlines@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" - -trim-trailing-lines@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/trim-trailing-lines/-/trim-trailing-lines-1.1.0.tgz#7aefbb7808df9d669f6da2e438cac8c46ada7684" - -trim@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd" - -trough@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.0.tgz#6bdedfe7f2aa49a6f3c432257687555957f342fd" - -tryit@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb" - -tty-browserify@0.0.0: - version "0.0.0" - resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" - -tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: - version "0.4.3" - resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - -type-check@~0.3.1, type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - dependencies: - prelude-ls "~1.1.2" - -type-detect@0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" - -type-detect@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2" - -type-is@~1.6.10, type-is@~1.6.13, type-is@~1.6.14: - version "1.6.14" - resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.14.tgz#e219639c17ded1ca0789092dd54a03826b817cb2" - dependencies: - media-typer "0.3.0" - mime-types "~2.1.13" - -typedarray@~0.0.5: - version "0.0.6" - resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" - -uglify-js@^2.6, uglify-js@~2.8.3: - version "2.8.18" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.18.tgz#925d14bae48ab62d1883b41afe6e2261662adb8e" - dependencies: - source-map "~0.5.1" - yargs "~3.10.0" - optionalDependencies: - uglify-to-browserify "~1.0.0" - -uglify-js@~2.7.3: - version "2.7.5" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.7.5.tgz#4612c0c7baaee2ba7c487de4904ae122079f2ca8" - dependencies: - async "~0.2.6" - source-map "~0.5.1" - uglify-to-browserify "~1.0.0" - yargs "~3.10.0" - -uglify-to-browserify@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" - -uid-number@~0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" - -ultron@1.0.x: - version "1.0.2" - resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" - -underscore.string@~2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-2.3.3.tgz#71c08bf6b428b1133f37e78fa3a21c82f7329b0d" - -underscore.string@~3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.2.3.tgz#806992633665d5e5fcb4db1fb3a862eb68e9e6da" - -underscore@~1.4.4: - version "1.4.4" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.4.4.tgz#61a6a32010622afa07963bf325203cf12239d604" - -underscore@~1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8" - -underscore@~1.8.3: - version "1.8.3" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" - -unherit@^1.0.4: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.0.tgz#6b9aaedfbf73df1756ad9e316dd981885840cd7d" - dependencies: - inherits "^2.0.1" - xtend "^4.0.1" - -unified@^4.1.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/unified/-/unified-4.2.1.tgz#76ff43aa8da430f6e7e4a55c84ebac2ad2cfcd2e" - dependencies: - bail "^1.0.0" - extend "^3.0.0" - has "^1.0.1" - once "^1.3.3" - trough "^1.0.0" - vfile "^1.0.0" - -unique-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" - -unist-util-remove-position@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/unist-util-remove-position/-/unist-util-remove-position-1.1.0.tgz#2444fedc344bc5f540dab6353e013b6d78101dc2" - dependencies: - unist-util-visit "^1.1.0" - -unist-util-visit@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-1.1.1.tgz#e917a3b137658b335cb4420c7da2e74d928e4e94" - -unpipe@1.0.0, unpipe@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" - -update-notifier@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-0.2.2.tgz#e69b3a784b4e686a2acd98f5e66944591996e187" - dependencies: - chalk "^0.5.1" - configstore "^0.3.1" - is-npm "^1.0.0" - latest-version "^1.0.0" - semver-diff "^2.0.0" - string-length "^1.0.0" - -update-section@^0.3.0: - version "0.3.3" - resolved "https://registry.yarnpkg.com/update-section/-/update-section-0.3.3.tgz#458f17820d37820dc60e20b86d94391b00123158" - -uri-path@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/uri-path/-/uri-path-1.0.0.tgz#9747f018358933c31de0fccfd82d138e67262e32" - -url-parse@1.0.x: - version "1.0.5" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.0.5.tgz#0854860422afdcfefeb6c965c662d4800169927b" - dependencies: - querystringify "0.0.x" - requires-port "1.0.x" - -url-parse@^1.1.1: - version "1.1.7" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.1.7.tgz#025cff999653a459ab34232147d89514cc87d74a" - dependencies: - querystringify "0.0.x" - requires-port "1.0.x" - -url@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" - dependencies: - punycode "1.3.2" - querystring "0.2.0" - -user-home@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - -useragent@^2.1.12: - version "2.1.12" - resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.1.12.tgz#aa7da6cdc48bdc37ba86790871a7321d64edbaa2" - dependencies: - lru-cache "2.2.x" - tmp "0.0.x" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - -util@0.10.3, "util@>=0.10.3 <1", util@^0.10.3: - version "0.10.3" - resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" - dependencies: - inherits "2.0.1" - -utils-merge@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.0.tgz#0294fb922bb9375153541c4f7096231f287c8af8" - -uuid@^2.0.1, uuid@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" - -uuid@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" - -validate-npm-package-license@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" - dependencies: - spdx-correct "~1.0.0" - spdx-expression-parse "~1.0.0" - -vargs@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/vargs/-/vargs-0.1.0.tgz#6b6184da6520cc3204ce1b407cac26d92609ebff" - -vary@~1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.0.tgz#e1e5affbbd16ae768dd2674394b9ad3022653140" - -verror@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" - dependencies: - extsprintf "1.0.2" - -vfile-location@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-2.0.1.tgz#0bf8816f732b0f8bd902a56fda4c62c8e935dc52" - -vfile@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/vfile/-/vfile-1.4.0.tgz#c0fd6fa484f8debdb771f68c31ed75d88da97fe7" - -vinyl-fs@^0.3.4: - version "0.3.14" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" - dependencies: - defaults "^1.0.0" - glob-stream "^3.1.5" - glob-watcher "^0.0.6" - graceful-fs "^3.0.0" - mkdirp "^0.5.0" - strip-bom "^1.0.0" - through2 "^0.6.1" - vinyl "^0.4.0" - -vinyl@^0.4.0: - version "0.4.6" - resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" - dependencies: - clone "^0.2.0" - clone-stats "^0.0.1" - -vm-browserify@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-0.0.4.tgz#5d7ea45bbef9e4a6ff65f95438e0a87c357d5a73" - dependencies: - indexof "0.0.1" - -void-elements@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" - -watchpack@^0.2.1: - version "0.2.9" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-0.2.9.tgz#62eaa4ab5e5ba35fdfc018275626e3c0f5e3fb0b" - dependencies: - async "^0.9.0" - chokidar "^1.0.0" - graceful-fs "^4.1.2" - -wd@~0.2.22: - version "0.2.27" - resolved "https://registry.yarnpkg.com/wd/-/wd-0.2.27.tgz#db25a671e14d76e4886a0c5014606acde065f4cf" - dependencies: - archiver "~0.10.0" - async "~0.9.0" - lodash "~2.4.1" - q "~1.0.1" - request "~2.36.0" - underscore.string "~2.3.3" - vargs "~0.1.0" - -webpack-core@~0.6.9: - version "0.6.9" - resolved "https://registry.yarnpkg.com/webpack-core/-/webpack-core-0.6.9.tgz#fc571588c8558da77be9efb6debdc5a3b172bdc2" - dependencies: - source-list-map "~0.1.7" - source-map "~0.4.1" - -webpack-dev-middleware@^1.0.11, webpack-dev-middleware@^1.4.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.9.0.tgz#a1c67a3dfd8a5c5d62740aa0babe61758b4c84aa" - dependencies: - memory-fs "~0.4.1" - mime "^1.3.4" - path-is-absolute "^1.0.0" - range-parser "^1.0.3" - -webpack-dev-server@^1.16.1: - version "1.16.3" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-1.16.3.tgz#cbb6a0d3e7c8eb5453b3e9befcbe843219f62661" - dependencies: - compression "^1.5.2" - connect-history-api-fallback "^1.3.0" - express "^4.13.3" - http-proxy-middleware "~0.17.1" - open "0.0.5" - optimist "~0.6.1" - serve-index "^1.7.2" - sockjs "^0.3.15" - sockjs-client "^1.0.3" - stream-cache "~0.0.1" - strip-ansi "^3.0.0" - supports-color "^3.1.1" - webpack-dev-middleware "^1.4.0" - -webpack@^1.13.2: - version "1.14.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-1.14.0.tgz#54f1ffb92051a328a5b2057d6ae33c289462c823" - dependencies: - acorn "^3.0.0" - async "^1.3.0" - clone "^1.0.2" - enhanced-resolve "~0.9.0" - interpret "^0.6.4" - loader-utils "^0.2.11" - memory-fs "~0.3.0" - mkdirp "~0.5.0" - node-libs-browser "^0.7.0" - optimist "~0.6.0" - supports-color "^3.1.0" - tapable "~0.1.8" - uglify-js "~2.7.3" - watchpack "^0.2.1" - webpack-core "~0.6.9" - -websocket-driver@>=0.5.1: - version "0.6.5" - resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36" - dependencies: - websocket-extensions ">=0.1.1" - -websocket-extensions@>=0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.1.tgz#76899499c184b6ef754377c2dbb0cd6cb55d29e7" - -which@^1.1.1, which@^1.2.1, which@~1.2.1, which@~1.2.10: - version "1.2.12" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192" - dependencies: - isexe "^1.1.1" - -wide-align@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" - dependencies: - string-width "^1.0.1" - -window-size@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" - -wordwrap@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" - -wordwrap@^1.0.0, wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - -write@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" - dependencies: - mkdirp "^0.5.1" - -ws@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.2.tgz#8a244fa052401e08c9886cf44a85189e1fd4067f" - dependencies: - options ">=0.0.5" - ultron "1.0.x" - -wtf-8@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" - -xdg-basedir@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-1.0.1.tgz#14ff8f63a4fdbcb05d5b6eea22b36f3033b9f04e" - dependencies: - user-home "^1.0.0" - -xml-escape@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/xml-escape/-/xml-escape-1.0.0.tgz#00963d697b2adf0c185c4e04e73174ba9b288eb2" - -xmlhttprequest-ssl@1.5.3: - version "1.5.3" - resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" - -"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" - -yargs@~3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" - dependencies: - camelcase "^1.0.2" - cliui "^2.1.0" - decamelize "^1.0.0" - window-size "0.1.0" - -yauzl@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" - dependencies: - fd-slicer "~1.0.1" - -yeast@0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" - -yiewd@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/yiewd/-/yiewd-0.6.0.tgz#9aaa27fb2d37c95faba00cc8644965d8e233a83d" - dependencies: - monocle-js "~1.0.0" - saucelabs "~0.1.1" - underscore "~1.6.0" - wd "~0.2.22" - -zip-stream@~0.3.0: - version "0.3.7" - resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-0.3.7.tgz#c84d057eb0bcc0139747bd3c6c97280bcf5f2bb2" - dependencies: - buffer-crc32 "~0.2.1" - crc32-stream "~0.2.0" - debug "~1.0.2" - deflate-crc32-stream "~0.1.0" - lodash "~2.4.1" - readable-stream "~1.0.26" diff --git a/js/instantsearch.js/CHANGELOG.md b/js/instantsearch.js/CHANGELOG.md index 59890640..ba4dd19d 100644 --- a/js/instantsearch.js/CHANGELOG.md +++ b/js/instantsearch.js/CHANGELOG.md @@ -1,30 +1,1695 @@ - -## [1.12.1](https://github.com/algolia/instantsearch.js/compare/v1.11.15...v1.12.1) (2018-05-16) +## [4.25.2](https://github.com/algolia/instantsearch.js/compare/v4.25.1...v4.25.2) (2021-07-20) ### Bug Fixes -* **doc:** Absolute URLs for meta images ([b453bb4](https://github.com/algolia/instantsearch.js/commit/b453bb4)) +* **build:** ensure build fails when types building fails ([#4812](https://github.com/algolia/instantsearch.js/issues/4812)) ([b37e23b](https://github.com/algolia/instantsearch.js/commit/b37e23b5819abbc03049124bc3a29120f91aeb8c)) +* **types:** export widget's types ([#4813](https://github.com/algolia/instantsearch.js/issues/4813)) ([e9764e9](https://github.com/algolia/instantsearch.js/commit/e9764e9273e5b7bacd86f8d1cb751e87bd75eb75)) + + + +## [4.25.1](https://github.com/algolia/instantsearch.js/compare/v4.25.0...v4.25.1) (2021-07-13) + + +### Bug Fixes + +* **deps:** force a lower version of qs ([#4805](https://github.com/algolia/instantsearch.js/issues/4805)) ([07b7e08](https://github.com/algolia/instantsearch.js/commit/07b7e086282f8cc6a17aee822902d97204c1d2da)) + + + +# [4.25.0](https://github.com/algolia/instantsearch.js/compare/v4.24.3...v4.25.0) (2021-07-06) + + +### Features + +* **facets:** apply result from facet ordering ([#4784](https://github.com/algolia/instantsearch.js/issues/4784)) ([9e9d839](https://github.com/algolia/instantsearch.js/commit/9e9d8394067bec35425b7d66f94fcce504faee7f)) + + + +## [4.24.3](https://github.com/algolia/instantsearch.js/compare/v4.24.2...v4.24.3) (2021-07-05) + + +### Bug Fixes + +* **dynamicWidgets:** read from facetOrdering.facets ([42d6c6c](https://github.com/algolia/instantsearch.js/commit/42d6c6cefc5f009a3cfc63ab3d628ed2811f1700)) +* **ts:** make template types consistent ([#4785](https://github.com/algolia/instantsearch.js/issues/4785)) ([e0fbd55](https://github.com/algolia/instantsearch.js/commit/e0fbd55b6b98dd64301f113fd394dce57552d94c)) + + + +## [4.24.2](https://github.com/algolia/instantsearch.js/compare/v4.24.1...v4.24.2) (2021-06-29) + + +### Bug Fixes + +* **index:** export `IndexWidgetParams` type ([#4793](https://github.com/algolia/instantsearch.js/issues/4793)) ([91bdea1](https://github.com/algolia/instantsearch.js/commit/91bdea18f3768265937e2d3aca4acaa05c24e426)) +* **onStateChange:** propagate change to middleware ([#4796](https://github.com/algolia/instantsearch.js/issues/4796)) ([57c32c0](https://github.com/algolia/instantsearch.js/commit/57c32c0a43bd2c6cbdd3f8ea7eac8109e3024f2a)) +* **relevantSort:** export `RelevantSortWidgetParams` type ([#4794](https://github.com/algolia/instantsearch.js/issues/4794)) ([1a10b59](https://github.com/algolia/instantsearch.js/commit/1a10b59938c6121f58510726b67ee6dfa1aa1b7c)) +* **sortBy:** do not write the default state ([#4798](https://github.com/algolia/instantsearch.js/issues/4798)) ([1d8a40e](https://github.com/algolia/instantsearch.js/commit/1d8a40ecc8e6e48746113ec3ec0d975e14bec1ea)) + + + +## [4.24.1](https://github.com/algolia/instantsearch.js/compare/v4.24.0...v4.24.1) (2021-06-23) + + +### Bug Fixes + +* **mainHelper:** allow a mainHelper to be set before start ([#4790](https://github.com/algolia/instantsearch.js/issues/4790)) ([e8329ae](https://github.com/algolia/instantsearch.js/commit/e8329aecb386755a039cf10850e394d0d71f29f4)) + + + +# [4.24.0](https://github.com/algolia/instantsearch.js/compare/v4.23.0...v4.24.0) (2021-06-15) + + +### Bug Fixes + +* **clearRefinements:** do not throw when widgetParams is not given ([#4778](https://github.com/algolia/instantsearch.js/issues/4778)) ([6b1a375](https://github.com/algolia/instantsearch.js/commit/6b1a375ed7139c0b98993c0cb7ab40838e1f2288)) +* **ts:** make `CSSClasses` types consistent ([#4774](https://github.com/algolia/instantsearch.js/issues/4774)) ([99008a9](https://github.com/algolia/instantsearch.js/commit/99008a985ddc61ce197200df51fdcf385914064d)) + + +### Features + +* **dynamicWidgets:** add default attributesToRender & transformItems ([#4776](https://github.com/algolia/instantsearch.js/issues/4776)) ([44dab44](https://github.com/algolia/instantsearch.js/commit/44dab44282da58b36a707ad80aff4c18477abccd)) +* **ts:** convert pagination widget and component ([#4765](https://github.com/algolia/instantsearch.js/issues/4765)) ([34eb950](https://github.com/algolia/instantsearch.js/commit/34eb9500a2d7072814fd715e1c2217ed22de30d1)) +* **ts:** convert rangeInput widget and component ([#4766](https://github.com/algolia/instantsearch.js/issues/4766)) ([40b1a82](https://github.com/algolia/instantsearch.js/commit/40b1a82f9df4b16708fceefbba77a8fb49c7dc41)) + + + +# [4.23.0](https://github.com/algolia/instantsearch.js/compare/v4.22.0...v4.23.0) (2021-05-25) + + +### Bug Fixes + +* **range:** reset the page on refine ([#4760](https://github.com/algolia/instantsearch.js/issues/4760)) ([24e3b34](https://github.com/algolia/instantsearch.js/commit/24e3b34c944ec32b414e845550e9c6c02b39cb92)), closes [#4759](https://github.com/algolia/instantsearch.js/issues/4759) + + +### Features + +* **ts:** convert poweredBy widget ([#4756](https://github.com/algolia/instantsearch.js/issues/4756)) ([142660a](https://github.com/algolia/instantsearch.js/commit/142660a2bc0ab7212265a9ff6dadf7a7f1081c69)) + + + +# [4.22.0](https://github.com/algolia/instantsearch.js/compare/v4.21.0...v4.22.0) (2021-05-05) + + +### Bug Fixes + +* **insights:** do not throw when userToken is not given ([#4724](https://github.com/algolia/instantsearch.js/issues/4724)) ([8241b29](https://github.com/algolia/instantsearch.js/commit/8241b2909c981a6bb52e9f4f9b6bacb7bc60263b)) +* **insights:** use getUserToken method instead of _get ([#4744](https://github.com/algolia/instantsearch.js/issues/4744)) ([05d05a9](https://github.com/algolia/instantsearch.js/commit/05d05a9a8ad79e4ec8b183a3d17c2360430c302e)) +* **relevantSort:** remove "relevantSort" nesting, since there's only one property ([#4735](https://github.com/algolia/instantsearch.js/issues/4735)) ([f742083](https://github.com/algolia/instantsearch.js/commit/f74208396159524086341be4acf84d2af2b44135)) +* **connectToggleRefinement:** nest getRenderState per attribute ([#4743](https://github.com/algolia/instantsearch.js/issues/4743)) ([b9c884d](https://github.com/algolia/instantsearch.js/commit/b9c884daa406e1be63482ed198674b2ba22e66f2)) +* **connectToggleRefinement:** remove search parameters from render state ([#4743](https://github.com/algolia/instantsearch.js/issues/4743)) ([b9c884d](https://github.com/algolia/instantsearch.js/commit/b9c884daa406e1be63482ed198674b2ba22e66f2)) + + +### Features + +* **core:** add getUiState function ([#4750](https://github.com/algolia/instantsearch.js/issues/4750)) ([adce212](https://github.com/algolia/instantsearch.js/commit/adce2127de6c652ee6364e889a525d9d0ff6efdd)) +* **dynamicWidgets:** implementation ([#4687](https://github.com/algolia/instantsearch.js/issues/4687)) ([2e7ccc9](https://github.com/algolia/instantsearch.js/commit/2e7ccc91c8d2e4aa50c82a186cce057907042ed4)) +* **ts:** migrate toggleRefinement & connectToggleRefinement ([#4743](https://github.com/algolia/instantsearch.js/issues/4743)) ([b9c884d](https://github.com/algolia/instantsearch.js/commit/b9c884daa406e1be63482ed198674b2ba22e66f2)) +* **widget:** add access to "parent" in dispose ([#4745](https://github.com/algolia/instantsearch.js/issues/4745)) ([3fca986](https://github.com/algolia/instantsearch.js/commit/3fca986542e8b18312a6c6be810bf5fb986804a4)) + + + +# [4.21.0](https://github.com/algolia/instantsearch.js/compare/v4.20.0...v4.21.0) (2021-04-12) + + +### Bug Fixes + +* **infiniteHits:** fix wrong behavior of showPrevious regarding cachedHits ([#4725](https://github.com/algolia/instantsearch.js/issues/4725)) ([40b27b6](https://github.com/algolia/instantsearch.js/commit/40b27b668ec1dcb8608b299c941e0003b43911d3)) +* **ratingMenu:** use url in default template ([#4728](https://github.com/algolia/instantsearch.js/issues/4728)) ([31d9c50](https://github.com/algolia/instantsearch.js/commit/31d9c50344818cd4f4e62993a981ec3616d8b88e)) + + +### Features + +* **middleware:** accept partial methods ([#4673](https://github.com/algolia/instantsearch.js/issues/4673)) ([8f2aad2](https://github.com/algolia/instantsearch.js/commit/8f2aad2f0465cc883681143f350a11c24ce694e2)) +* **ts:** convert hierarchical-menu to TypeScript ([#4711](https://github.com/algolia/instantsearch.js/issues/4711)) ([870e2f7](https://github.com/algolia/instantsearch.js/commit/870e2f7285d58c48196356cd88fb4aca66feb7aa)) +* **ts:** convert RefinementList component to TypeScript ([#4702](https://github.com/algolia/instantsearch.js/issues/4702)) ([fd562de](https://github.com/algolia/instantsearch.js/commit/fd562de5e50e3889abaa9ef8151faa1b5179d7f6)) +* **ts:** convert search-box to TypeScript ([#4710](https://github.com/algolia/instantsearch.js/issues/4710)) ([e73257a](https://github.com/algolia/instantsearch.js/commit/e73257a466082207c0289f22bad523334d101aae)) + + + +# [4.20.0](https://github.com/algolia/instantsearch.js/compare/v4.19.0...v4.20.0) (2021-04-06) + + +### Features + +* **clearRefinements:** implement canRefine ([#4684](https://github.com/algolia/instantsearch.js/issues/4684)) ([a898f09](https://github.com/algolia/instantsearch.js/commit/a898f09bddca5db1f6782104375df3873d49c688)) +* **currentRefinements:** implement canRefine ([#4697](https://github.com/algolia/instantsearch.js/issues/4697)) ([4db75ba](https://github.com/algolia/instantsearch.js/commit/4db75baa9ff2e18f871547511d8f1234eea9d41b)) +* **hierarchicalMenu:** implement canRefine ([#4685](https://github.com/algolia/instantsearch.js/issues/4685)) ([0d2e450](https://github.com/algolia/instantsearch.js/commit/0d2e450aed2aaac72ae7ff7f1bb322ce6992c8ba)) +* **middleware:** add unuse method ([#4708](https://github.com/algolia/instantsearch.js/issues/4708)) ([8e3c406](https://github.com/algolia/instantsearch.js/commit/8e3c406c8f29bcae56d2f82f07cbd087043346fe)) +* **pagination:** implement canRefine ([#4683](https://github.com/algolia/instantsearch.js/issues/4683)) ([3ae51e6](https://github.com/algolia/instantsearch.js/commit/3ae51e60543984463a13b25e64aa2f879c91313e)) +* **range:** implement canRefine ([#4686](https://github.com/algolia/instantsearch.js/issues/4686)) ([a99ab6f](https://github.com/algolia/instantsearch.js/commit/a99ab6f968b791ffa31cd17dda598c293e73b88e)) +* **ratingMenu:** implement canRefine ([#4691](https://github.com/algolia/instantsearch.js/issues/4691)) ([42191a0](https://github.com/algolia/instantsearch.js/commit/42191a097a048a325234dd3f40f7799145628cd6)) +* **toggleRefinement:** implement canRefine ([#4689](https://github.com/algolia/instantsearch.js/issues/4689)) ([48dc7f8](https://github.com/algolia/instantsearch.js/commit/48dc7f8423c92b21bcd59856bf2fc685ae4aba69)) +* **ts:** convert rating-menu to TypeScript ([#4701](https://github.com/algolia/instantsearch.js/issues/4701)) ([f14ca08](https://github.com/algolia/instantsearch.js/commit/f14ca0891237a7a49b09d881cddedb93efc3a266)) +* **ts:** convert Template component to TypeScript ([#4703](https://github.com/algolia/instantsearch.js/issues/4703)) ([0688571](https://github.com/algolia/instantsearch.js/commit/068857137b85d1065bc5997514461d72fe595130)) + + + +# [4.19.0](https://github.com/algolia/instantsearch.js/compare/v4.18.0...v4.19.0) (2021-03-30) + + +### Bug Fixes + +* **setUiState:** make sure previous ui state is stored ([#4699](https://github.com/algolia/instantsearch.js/issues/4699)) ([0f5d688](https://github.com/algolia/instantsearch.js/commit/0f5d6888c5e77c750d264ed19be3418d920266af)) + + +### Features + +* **relevantSort:** implement canRefine ([#4693](https://github.com/algolia/instantsearch.js/issues/4693)) ([24d9ded](https://github.com/algolia/instantsearch.js/commit/24d9ded0c0e3246b91fe16ab1d1d579c17d68731)) +* **currentRefinements:** implement canRefine ([#4690](https://github.com/algolia/instantsearch.js/issues/4690)) ([f02416c](https://github.com/algolia/instantsearch.js/commit/f02416cf226ec3f7c2238b3e0902ec6f78381515)) +* **ts:** convert sortBy, connectSortBy ([#4700](https://github.com/algolia/instantsearch.js/issues/4700)) ([86de1e0](https://github.com/algolia/instantsearch.js/commit/86de1e0a675c91b75e72463e6b11df62739d69b5)) + + + +# [4.18.0](https://github.com/algolia/instantsearch.js/compare/v4.17.0...v4.18.0) (2021-03-24) + + +### Bug Fixes + +* **createURL:** correctly remove page in state ([#4679](https://github.com/algolia/instantsearch.js/issues/4679)) ([48c080e](https://github.com/algolia/instantsearch.js/commit/48c080ef85b974e68e1c80ceffea7a0138407a1e)) +* **utils:** circular dependency in createSendEventForHits ([#4680](https://github.com/algolia/instantsearch.js/issues/4680)) ([045f33b](https://github.com/algolia/instantsearch.js/commit/045f33bc6184fb04501e39a5a97e1e969095389a)) + + +### Features + +* **metadata:** expose client's algolia agent ([#4694](https://github.com/algolia/instantsearch.js/issues/4694)) ([3d0cb5b](https://github.com/algolia/instantsearch.js/commit/3d0cb5b69056674246efb1acf33e143ac7ae4915)) +* **ts:** convert connectRefinementList, refinementList ([#4658](https://github.com/algolia/instantsearch.js/issues/4658)) ([794b2d3](https://github.com/algolia/instantsearch.js/commit/794b2d3316ae7ee79cfa0643565b65e5bec5c7c1)) +* **ts:** convert stats, connectStats ([#4681](https://github.com/algolia/instantsearch.js/issues/4681)) ([37bbd01](https://github.com/algolia/instantsearch.js/commit/37bbd016a83d5cb66d1f78c0865f7677fa7098fb)) +* **ts:** update to typescript 4 ([#4654](https://github.com/algolia/instantsearch.js/issues/4654)) ([638e437](https://github.com/algolia/instantsearch.js/commit/638e437fdd80af0cfd38818f9da37a50f8f4343f)) + + + +# [4.17.0](https://github.com/algolia/instantsearch.js/compare/v4.16.1...v4.17.0) (2021-03-09) + + +### Bug Fixes + +* **bindEvent:** escape payload correctly ([#4670](https://github.com/algolia/instantsearch.js/issues/4670)) ([c1cbaf4](https://github.com/algolia/instantsearch.js/commit/c1cbaf49f6af9784535df80d024cdad56f3ddb84)) + + +### Features + +* **insights:** add hits and attributes to InsightsEvent ([#4667](https://github.com/algolia/instantsearch.js/issues/4667)) ([17ef71c](https://github.com/algolia/instantsearch.js/commit/17ef71c32586d0a93bb3905696b6ff7c7be1f3f9)) + + + +## [4.16.1](https://github.com/algolia/instantsearch.js/compare/v4.16.0...v4.16.1) (2021-03-03) + + +### Bug Fixes + +* **relevantSort:** rename smartSort to relevantSort ([#4668](https://github.com/algolia/instantsearch.js/issues/4668)) ([579eee8](https://github.com/algolia/instantsearch.js/commit/579eee8d38effe067407a269e493400c460eb842)) + + + +# [4.16.0](https://github.com/algolia/instantsearch.js/compare/v4.15.0...v4.16.0) (2021-03-01) + + +### Bug Fixes + +* **relevantSort:** export the widget and the connector ([#4663](https://github.com/algolia/instantsearch.js/issues/4663)) ([e7aaa8c](https://github.com/algolia/instantsearch.js/commit/e7aaa8ceb47b8cafc3a3a323ebe47f45f3841ba4)) + + +### Features + +* **answers:** add `EXPERIMENTAL_answers` widget ([#4581](https://github.com/algolia/instantsearch.js/issues/4581)) ([e4c9070](https://github.com/algolia/instantsearch.js/commit/e4c9070250779d7d3afabe7f9a19644717bc12c8)), closes [#4635](https://github.com/algolia/instantsearch.js/issues/4635) + + + +# [4.15.0](https://github.com/algolia/instantsearch.js/compare/v4.14.2...v4.15.0) (2021-02-23) + + +### Features + +* **relevantSort:** add widget ([#4648](https://github.com/algolia/instantsearch.js/issues/4648)) ([89c6e86](https://github.com/algolia/instantsearch.js/commit/89c6e868f490e9b6e507dd70c215e962f4c69ccb)) +* **stats:** apply nbSortedHits ([#4649](https://github.com/algolia/instantsearch.js/issues/4649)) ([34478c1](https://github.com/algolia/instantsearch.js/commit/34478c198dcafbd45fd101db0cd2fbe6328272b8)) +* **ts:** convert menu ([#4652](https://github.com/algolia/instantsearch.js/issues/4652)) ([2271b43](https://github.com/algolia/instantsearch.js/commit/2271b4379918e865a1b0cea09c139e517df97bc5)) + + + +## [4.14.2](https://github.com/algolia/instantsearch.js/compare/v4.14.1...v4.14.2) (2021-02-17) + + +### Bug Fixes + +* **insights:** don't reset page ([#4655](https://github.com/algolia/instantsearch.js/issues/4655)) ([2b31250](https://github.com/algolia/instantsearch.js/commit/2b312508e8be59284180e7f490ce0aac80f9c2b6)) + + + +## [4.14.1](https://github.com/algolia/instantsearch.js/compare/v4.14.0...v4.14.1) (2021-02-16) + + +### Bug Fixes + +* **compat:** remove references to window ([#4651](https://github.com/algolia/instantsearch.js/issues/4651)) ([1ede1ae](https://github.com/algolia/instantsearch.js/commit/1ede1ae392d3a12f5b0fe29075ffeb05e572a874)), closes [#4650](https://github.com/algolia/instantsearch.js/issues/4650) + + + +# [4.14.0](https://github.com/algolia/instantsearch.js/compare/v4.13.2...v4.14.0) (2021-02-09) + + +### Features + +* **queryRuleContext:** allow to make refinements based on query ([#4638](https://github.com/algolia/instantsearch.js/issues/4638)) ([dd033fc](https://github.com/algolia/instantsearch.js/commit/dd033fc58ff11027e4f4b6157aedf0aea0326af3)) + + + +## [4.13.2](https://github.com/algolia/instantsearch.js/compare/v4.13.1...v4.13.2) (2021-02-03) + + +### Bug Fixes + +* **range:** don't go out of bounds with min or max given ([#4627](https://github.com/algolia/instantsearch.js/issues/4627)) ([8327ec0](https://github.com/algolia/instantsearch.js/commit/8327ec01c3940dfc20f5f1c8e3e0fc85f29af690)) + + + +## [4.13.1](https://github.com/algolia/instantsearch.js/compare/v4.13.0...v4.13.1) (2021-01-26) + + +### Bug Fixes + +* **index:** only set listeners on init once ([#4634](https://github.com/algolia/instantsearch.js/issues/4634)) ([730b49d](https://github.com/algolia/instantsearch.js/commit/730b49d43782b98c5119a5d3dbfec09073bde1d0)) + + + +# [4.13.0](https://github.com/algolia/instantsearch.js/compare/v4.12.0...v4.13.0) (2021-01-26) + + +### Features + +* **ratingMenu:** Add support for floats in values ([#4611](https://github.com/algolia/instantsearch.js/issues/4611)) ([3f52784](https://github.com/algolia/instantsearch.js/commit/3f52784862b72ef59acfc0735fe482cbfa6ad1f5)) + + + +# [4.12.0](https://github.com/algolia/instantsearch.js/compare/v4.11.0...v4.12.0) (2021-01-20) + + +### Code Refactoring + +* rename all references to widgetOptions as widgetParams ([#4612](https://github.com/algolia/instantsearch.js/issues/4612)) ([ff9a18d](https://github.com/algolia/instantsearch.js/commit/ff9a18d31635013ee4bc242291f121c8e5827f38)) + + +### Features + +* **core:** expose metadata of widgets ([#4604](https://github.com/algolia/instantsearch.js/issues/4604)) ([1fcf716](https://github.com/algolia/instantsearch.js/commit/1fcf71657b176b14067df36765a38e32d2a6dd9b)) +* **widgets:** annotate widget instances with $$widgetType ([#4624](https://github.com/algolia/instantsearch.js/issues/4624)) ([df3f478](https://github.com/algolia/instantsearch.js/commit/df3f47867e65a2e56c6da968d7a154471172adce)) + + +### BREAKING CHANGES + +* if you're using experimental-typescript and importing a type of the form `...WidgetOptions`, this now becomes `...WidgetParams` (eg. replace `HitsWidgetOptions` with `HitsWidgetParams`) + + + +# [4.11.0](https://github.com/algolia/instantsearch.js/compare/v4.10.0...v4.11.0) (2021-01-14) + + +### Bug Fixes + +* **index:** do not warn for nested index widget ([#4620](https://github.com/algolia/instantsearch.js/issues/4620)) ([7502744](https://github.com/algolia/instantsearch.js/commit/7502744cd546181ec4429cd6b8144200ba2a8f82)) +* **insights:** don't quote values ([#4619](https://github.com/algolia/instantsearch.js/issues/4619)) ([ac2444c](https://github.com/algolia/instantsearch.js/commit/ac2444c36c6f41e35ed6d1a6d045479b35416576)) + + +### Features + +* **insights:** accept initParams for insightsClient ([#4608](https://github.com/algolia/instantsearch.js/issues/4608)) ([0a0ae2b](https://github.com/algolia/instantsearch.js/commit/0a0ae2bf10a4e210373b8fde635949a56c86e52e)) + + + +# [4.10.0](https://github.com/algolia/instantsearch.js/compare/v4.9.2...v4.10.0) (2021-01-05) + + +### Features + +* **index:** expose createURL ([#4603](https://github.com/algolia/instantsearch.js/issues/4603)) ([f57e9c5](https://github.com/algolia/instantsearch.js/commit/f57e9c5a46e927b8dd38f167ee5c467151334a08)) +* **index:** expose scoped results getter ([#4609](https://github.com/algolia/instantsearch.js/issues/4609)) ([a41b1e4](https://github.com/algolia/instantsearch.js/commit/a41b1e46bb195e6ef1f9bdbdde64d9300246c22f)) +* **reverseHighlight/reverseSnippet:** Implements reverseHighlight and reverseSnippet ([#4592](https://github.com/algolia/instantsearch.js/issues/4592)) ([718bf45](https://github.com/algolia/instantsearch.js/commit/718bf458152bb55bab1efb542adb8e31298c0c3c)) + + + +## [4.9.2](https://github.com/algolia/instantsearch.js/compare/v4.9.1...v4.9.2) (2020-12-15) + + +### Bug Fixes + +* warn about invalid userToken ([#4605](https://github.com/algolia/instantsearch.js/issues/4605)) ([5fce769](https://github.com/algolia/instantsearch.js/commit/5fce769f42fe5b44f73eb68f3858a6ea1ec2d854)) +* **types:** correct type for queryHook return ([#4602](https://github.com/algolia/instantsearch.js/issues/4602)) ([acff8db](https://github.com/algolia/instantsearch.js/commit/acff8db3a2238edf40da1ee6b44e93a94e090698)) + + + +## [4.9.1](https://github.com/algolia/instantsearch.js/compare/v4.9.0...v4.9.1) (2020-12-08) + + +### Bug Fixes + +* **range:** consistently convert min & max to numbers ([#4587](https://github.com/algolia/instantsearch.js/issues/4587)) ([ccf159e](https://github.com/algolia/instantsearch.js/commit/ccf159efcb94e9c8c04c558fcb69e2e3d8d79729)) + + + +# [4.9.0](https://github.com/algolia/instantsearch.js/compare/v4.8.7...v4.9.0) (2020-12-01) + + +### Bug Fixes + +* remove a warning about insights that is not relevant anymore ([#4593](https://github.com/algolia/instantsearch.js/issues/4593)) ([b5f6a47](https://github.com/algolia/instantsearch.js/commit/b5f6a479ff1b9b692c733f51e39eade724ff3413)) + + +### Features + +* **autocomplete:** implement `getWidgetRenderState` ([#4466](https://github.com/algolia/instantsearch.js/issues/4466)) ([c215836](https://github.com/algolia/instantsearch.js/commit/c2158364a63d0f05bb820f802871a2f093e041ec)) +* **breadcrumb:** implement `getWidgetRenderState` ([#4467](https://github.com/algolia/instantsearch.js/issues/4467)) ([80b348e](https://github.com/algolia/instantsearch.js/commit/80b348ef1a6a29b1897f5ee1d680dcbaba5fa4fe)) +* **clearRefinements:** implement `getWidgetRenderState` ([#4468](https://github.com/algolia/instantsearch.js/issues/4468)) ([2b3117c](https://github.com/algolia/instantsearch.js/commit/2b3117c34207514967ff453b6f5d8275a6b0b0ec)) +* **configure:** getRenderState for multiple configure widgets ([#4582](https://github.com/algolia/instantsearch.js/issues/4582)) ([5432af1](https://github.com/algolia/instantsearch.js/commit/5432af1df3c1ee4e62b87ede76acda7b749f38dd)) +* **configure:** implement `getWidgetRenderState` ([#4469](https://github.com/algolia/instantsearch.js/issues/4469)) ([3a1b325](https://github.com/algolia/instantsearch.js/commit/3a1b32556f3d5a6a3330b404688e06d5815a2390)) +* **connectPagination:** add getWidgetRenderState & refactor to TS ([#4574](https://github.com/algolia/instantsearch.js/issues/4574)) ([1553aa3](https://github.com/algolia/instantsearch.js/commit/1553aa36c8bb8664b5e74fd2378ea2ef45a52acf)) +* **core:** introduce `getWidgetRenderState` (2/n) ([#4457](https://github.com/algolia/instantsearch.js/issues/4457)) ([4839bb6](https://github.com/algolia/instantsearch.js/commit/4839bb61e4c8ee6083710195d5db5684c7b0889f)) +* **core:** introduce `getWidgetUiState` lifecycle hook (1/n) ([#4454](https://github.com/algolia/instantsearch.js/issues/4454)) ([cf21ea4](https://github.com/algolia/instantsearch.js/commit/cf21ea4cb580ed523828c926b7ba724c46eed8a4)) +* **currentRefinements:** implement `getWidgetRenderState` ([#4470](https://github.com/algolia/instantsearch.js/issues/4470)) ([b8df824](https://github.com/algolia/instantsearch.js/commit/b8df824e26a164280d9da9b3c3ce41ad56962439)) +* **connectQueryRules:** getWidgetRenderState ([#4572](https://github.com/algolia/instantsearch.js/issues/4572)) ([edcc4a4](https://github.com/algolia/instantsearch.js/commit/edcc4a463d32af21bb73acbca879d4982ae9006f)) +* **connectGeoSearch:** support getWidgetRenderState ([#4564](https://github.com/algolia/instantsearch.js/issues/4564)) ([8d06fba](https://github.com/algolia/instantsearch.js/commit/8d06fba40be0392daa1b48f235d93d92bb6b5e93)) +* **hierarchicalMenu:** implement `getWidgetRenderState` ([#4471](https://github.com/algolia/instantsearch.js/issues/4471)) ([9fd3cd0](https://github.com/algolia/instantsearch.js/commit/9fd3cd06dfc3b5302c00ee1820ff58be2a37c3b7)) +* **highlight:** accept array for attribute ([#4588](https://github.com/algolia/instantsearch.js/issues/4588)) ([b0c3a3a](https://github.com/algolia/instantsearch.js/commit/b0c3a3a960646bff22b2d28e21aa2675484a354b)) +* **hits:** implement `getWidgetRenderState` ([#4525](https://github.com/algolia/instantsearch.js/issues/4525)) ([3391ff7](https://github.com/algolia/instantsearch.js/commit/3391ff7bac8b406ab474e712408bda2be69934c9)) +* **hitsPerPage:** implement `getRenderState` and `getWidgetRenderState` ([#4532](https://github.com/algolia/instantsearch.js/issues/4532)) ([7ad10ea](https://github.com/algolia/instantsearch.js/commit/7ad10ea648f48766061153994da90920a5194103)) +* **infinite-hits:** implement `getRenderState` and `getWidgetRenderState` ([#4535](https://github.com/algolia/instantsearch.js/issues/4535)) ([98c70d9](https://github.com/algolia/instantsearch.js/commit/98c70d980bc1036057a2dd99dc6aeee8343e4472)) +* **menu:** implement `getRenderState` and `getWidgetRenderState` ([#4540](https://github.com/algolia/instantsearch.js/issues/4540)) ([239906c](https://github.com/algolia/instantsearch.js/commit/239906c7fdb36c691b9a9aca343802a8ccc616c8)) +* **panel:** spread widgetRenderState in the options in panel ([#4527](https://github.com/algolia/instantsearch.js/issues/4527)) ([8f82eaa](https://github.com/algolia/instantsearch.js/commit/8f82eaa34e7abe9070e404a5a45d352af61d940a)), closes [#4558](https://github.com/algolia/instantsearch.js/issues/4558) +* **poweredBy:** getWidgetRenderState ([#4551](https://github.com/algolia/instantsearch.js/issues/4551)) ([cd816a4](https://github.com/algolia/instantsearch.js/commit/cd816a41afe0704eab3cbd1f019fc660ca5d255e)) +* **range:** implement `getRenderState` and `getWidgetRenderState` ([#4536](https://github.com/algolia/instantsearch.js/issues/4536)) ([d67bfcd](https://github.com/algolia/instantsearch.js/commit/d67bfcdb828cc8b35a5c959e54823b6d3c37b087)) +* **rating-menu:** implement `getRenderState` and `getWidgetRenderState` ([#4548](https://github.com/algolia/instantsearch.js/issues/4548)) ([166a96c](https://github.com/algolia/instantsearch.js/commit/166a96c170c137e78b3fe3b9f69f73744f4fcb8b)) +* **refinement-list:** implement `getRenderState` and `getWidgetRenderState` ([#4549](https://github.com/algolia/instantsearch.js/issues/4549)) ([c824bd0](https://github.com/algolia/instantsearch.js/commit/c824bd074d388e44e99b53592167cffcacae3377)) +* **numeric-menu:** add `getRenderState` ([#4550](https://github.com/algolia/instantsearch.js/issues/4550)) ([5385edf](https://github.com/algolia/instantsearch.js/commit/5385edf39d3ac1515845b5e20ce179a2869ab86d)) +* **sortBy:** implement `getRenderState` and `getWidgetRenderState` ([#4568](https://github.com/algolia/instantsearch.js/issues/4568)) ([fd249f7](https://github.com/algolia/instantsearch.js/commit/fd249f700854d1f11e97cb5dac2c1b3964c59e29)) +* **stats:** implement `getRenderState` and `getWidgetRenderState` ([#4565](https://github.com/algolia/instantsearch.js/issues/4565)) ([b8dfd6d](https://github.com/algolia/instantsearch.js/commit/b8dfd6dbb8c462b0d0571e9f0499df6e4dda7745)) +* **toggleRefinement:** implement `getRenderState` and `getWidgetRenderState` ([#4569](https://github.com/algolia/instantsearch.js/issues/4569)) ([f2c9a10](https://github.com/algolia/instantsearch.js/commit/f2c9a102cba9abe21ed08b18e979713156e10901)) +* **voice-search:** implement `getRenderState` and `getWidgetRenderState` ([#4557](https://github.com/algolia/instantsearch.js/issues/4557)) ([d308da1](https://github.com/algolia/instantsearch.js/commit/d308da1ab892cc5185616cd5b8a4a3f488e708c4)) + + + +## [4.8.7](https://github.com/algolia/instantsearch.js/compare/v4.8.6...v4.8.7) (2020-11-19) + + +### Bug Fixes + +* **insights:** use internal `find` util method ([#4580](https://github.com/algolia/instantsearch.js/issues/4580)) ([61b855b](https://github.com/algolia/instantsearch.js/commit/61b855b28282992a55795db88f8bfef2e5825cb3)) + + + +## [4.8.6](https://github.com/algolia/instantsearch.js/compare/v4.8.5...v4.8.6) (2020-11-17) + + +### Bug Fixes + +* **insights:** do not throw when sending event right after creating insights middleware ([#4575](https://github.com/algolia/instantsearch.js/issues/4575)) ([d963f8d](https://github.com/algolia/instantsearch.js/commit/d963f8d6155e6bb56f852e00528ed10dc9bcc461)) + + + +## [4.8.5](https://github.com/algolia/instantsearch.js/compare/v4.8.4...v4.8.5) (2020-11-10) + + +### Bug Fixes + +* **configure:** pass the latest state to onStateChange ([#4555](https://github.com/algolia/instantsearch.js/issues/4555)) ([6ab76e8](https://github.com/algolia/instantsearch.js/commit/6ab76e82f93e8c7bb2bfdde267b6d7f4f9b333ff)) + + + +## [4.8.4](https://github.com/algolia/instantsearch.js/compare/v4.8.3...v4.8.4) (2020-10-27) + + +### Bug Fixes + +* **infiniteHits:** do not cache the cached hits inside the connector ([#4534](https://github.com/algolia/instantsearch.js/issues/4534)) ([c97395e](https://github.com/algolia/instantsearch.js/commit/c97395e2d3443651e628617f0974703a100a988e)) +* **insights:** show deprecation warnings for old insights related properties and functions ([#4524](https://github.com/algolia/instantsearch.js/issues/4524)) ([c93e1cf](https://github.com/algolia/instantsearch.js/commit/c93e1cfcad06b327066078088410eb7d51972790)) + + + +## [4.8.3](https://github.com/algolia/instantsearch.js/compare/v4.8.2...v4.8.3) (2020-09-29) + + +### Bug Fixes + +* **middleware:** rename EXPERIMENTAL_use to use ([#4450](https://github.com/algolia/instantsearch.js/issues/4450)) ([87ecb99](https://github.com/algolia/instantsearch.js/commit/87ecb99f33ab4930d8ec1996ddba9db0a9d07da4)) +* **refinementList:** cap `maxFacetHits` to 100 for SFFV ([#4523](https://github.com/algolia/instantsearch.js/issues/4523)) ([baf1f02](https://github.com/algolia/instantsearch.js/commit/baf1f027fc2436e86536fffbee11a595cfd7dac0)) + + + +## [4.8.2](https://github.com/algolia/instantsearch.js/compare/v4.8.1...v4.8.2) (2020-09-22) + + +### Bug Fixes + +* **insights:** fix the regression that it didn't send events with instantsearch.insights() ([#4519](https://github.com/algolia/instantsearch.js/issues/4519)) ([10e38df](https://github.com/algolia/instantsearch.js/commit/10e38df02608071cd7272e829b6748be41b9c2c0)) + + + +## [4.8.1](https://github.com/algolia/instantsearch.js/compare/v4.8.0...v4.8.1) (2020-09-15) + + +### Bug Fixes + +* **hitsPerPage:** update link to hitsPerPage widget ([#4513](https://github.com/algolia/instantsearch.js/issues/4513)) ([daa4bb9](https://github.com/algolia/instantsearch.js/commit/daa4bb944065dede46d716308325039c3602d9dc)) +* **infiniteHits:** compute `isLastPage` based on cached pages ([#4509](https://github.com/algolia/instantsearch.js/issues/4509)) ([b6fb1ab](https://github.com/algolia/instantsearch.js/commit/b6fb1abcf5ac456dc39adaeb97945665cad8fa11)) + + + +# [4.8.0](https://github.com/algolia/instantsearch.js/compare/v4.7.2...v4.8.0) (2020-09-08) + + +### Features + +* **insights:** introduce `insights` middleware ([#4446](https://github.com/algolia/instantsearch.js/issues/4446)) ([9bc6359](https://github.com/algolia/instantsearch.js/commit/9bc635986097736272aac8c5d3380a255488fdb7)) + + + +## [4.7.2](https://github.com/algolia/instantsearch.js/compare/v4.7.1...v4.7.2) (2020-08-31) + + +### Bug Fixes + +* **bundlesize:** remove prop-type imports ([#4491](https://github.com/algolia/instantsearch.js/issues/4491)) ([8361cd6](https://github.com/algolia/instantsearch.js/commit/8361cd63b3bac15eb6250e9f509fb15c1fc57f48)) +* **router:** skip router write on duplicate entries ([#4487](https://github.com/algolia/instantsearch.js/issues/4487)) ([9296022](https://github.com/algolia/instantsearch.js/commit/9296022fecadfbf82f15e837c215a1356eac4bc5)) +* **searchBox:** pass "spellcheck" property correctly to input ([#4483](https://github.com/algolia/instantsearch.js/issues/4483)) ([3cf43c7](https://github.com/algolia/instantsearch.js/commit/3cf43c7187841cf961a0280307af1a5f7a4e8da7)) + + + +# [4.7.1](https://github.com/algolia/instantsearch.js/compare/v4.7.0...v4.7.1) (2020-08-19) + + +### Bug Fixes + +* **configureRelatedItems:** support nested attributes ([#4480](https://github.com/algolia/instantsearch.js/issues/4480)) ([2266004](https://github.com/algolia/instantsearch.js/commit/2266004f274138b45640f000a5da8aa14e419e6c)) +* **connectToggleRefinement:** fix onFacetValue/offFacetValue on render when using arrays for on/off ([#4449](https://github.com/algolia/instantsearch.js/issues/4449)) ([fd3e83f](https://github.com/algolia/instantsearch.js/commit/fd3e83f2cf2e5b44b7d29eb4c67526e55c18d708)) +* **index:** don't show a development warning for inconsistent UI state in `connectRange` ([#4440](https://github.com/algolia/instantsearch.js/issues/4440)) ([eb8c8b3](https://github.com/algolia/instantsearch.js/commit/eb8c8b3494cb66dbef1d03e7d74374dc49059345)), closes [#4437](https://github.com/algolia/instantsearch.js/issues/4437) +* **infiniteHits:** work with controlled mode ([#4435](https://github.com/algolia/instantsearch.js/issues/4435)) ([68b20f4](https://github.com/algolia/instantsearch.js/commit/68b20f487fcd54fd7dec11b4c494b6aa94a18516)) +* **typescript:** correct dummy v4 client ([#4459](https://github.com/algolia/instantsearch.js/issues/4459)) ([ca0c394](https://github.com/algolia/instantsearch.js/commit/ca0c3946608bb8ec5dcf5378d8d382d809a4d86f)) +* **typescript:** jsDoc comments which conform to Connector definition ([#4458](https://github.com/algolia/instantsearch.js/issues/4458)) ([5209bdb](https://github.com/algolia/instantsearch.js/commit/5209bdb9189e7cbbf9514b62fde55f923b2b3273)) +* **typescript:** export correct types ([#4476](https://github.com/algolia/instantsearch.js/issues/4476)) ([5fb4c5b](https://github.com/algolia/instantsearch.js/commit/5fb4c5b9d6ac75636e94514598ef5d5a86affafd)) + + + +# [4.7.0](https://github.com/algolia/instantsearch.js/compare/v4.6.0...v4.7.0) (2020-06-15) + + +### Bug Fixes + +* **rangeInput:** clear input when refinement is cleared ([#4429](https://github.com/algolia/instantsearch.js/issues/4429)) ([a2c7663](https://github.com/algolia/instantsearch.js/commit/a2c7663424c5cd59e17ed841e12abaa19e524b14)) + + +### Features + +* **infiniteHits:** support cache ([#4431](https://github.com/algolia/instantsearch.js/issues/4431)) ([008c01c](https://github.com/algolia/instantsearch.js/commit/008c01c7cd09e4fcecdf53a4b299960de2b7a026)) + + + +# [4.6.0](https://github.com/algolia/instantsearch.js/compare/v4.5.0...v4.6.0) (2020-06-08) + + +### Bug Fixes + +* **connectPagination:** set `isLastPage` to `true` when no results ([#4422](https://github.com/algolia/instantsearch.js/issues/4422)) ([92bcc02](https://github.com/algolia/instantsearch.js/commit/92bcc0271927f0239083366fff920530977e32cd)) +* **rangeInput:** support typing float numbers ([#4418](https://github.com/algolia/instantsearch.js/issues/4418)) ([61b19b8](https://github.com/algolia/instantsearch.js/commit/61b19b87ae3afdabde8ef355e3b727059ae59911)) + + +### Features + +* **connectToggleRefinement:** add support for array values ([#4420](https://github.com/algolia/instantsearch.js/issues/4420)) ([fe1fbee](https://github.com/algolia/instantsearch.js/commit/fe1fbee4ad59c5f24831ed38a419906bbd7d2c15)) + + + +# [4.5.0](https://github.com/algolia/instantsearch.js/compare/v4.4.1...v4.5.0) (2020-05-13) + + +### Bug Fixes + +* **middleware:** subscribe middleware after `init` ([#4322](https://github.com/algolia/instantsearch.js/issues/4322)) ([f61fc4d](https://github.com/algolia/instantsearch.js/commit/f61fc4d133c118cfe8f2a2ba2e02d037a21cf8e0)) + + +### Features + +* **index:** support adding index widget with initial UI state ([#4359](https://github.com/algolia/instantsearch.js/issues/4359)) ([5ff4c83](https://github.com/algolia/instantsearch.js/commit/5ff4c8307c2be7bde7fb53aa9935a243e6532fe2)) +* **voice:** allow custom voice helper ([#4363](https://github.com/algolia/instantsearch.js/issues/4363)) ([4a00fa6](https://github.com/algolia/instantsearch.js/commit/4a00fa607354aefaae468735b590e237a2d46f9b)) + + + +## [4.4.1](https://github.com/algolia/instantsearch.js/compare/v4.4.0...v4.4.1) (2020-04-29) + + +### Bug Fixes + +* **range:** fix range calculation when step is set ([#4398](https://github.com/algolia/instantsearch.js/issues/4398)) ([a36b4e0](https://github.com/algolia/instantsearch.js/commit/a36b4e0a64afaa9dfa3048c802d010d569c821a9)) +* **router:** don't write an existing URL ([#4392](https://github.com/algolia/instantsearch.js/issues/4392)) ([ee6a9c6](https://github.com/algolia/instantsearch.js/commit/ee6a9c657c97adebba9fb9404eae454c3996b86d)) + + + +# [4.4.0](https://github.com/algolia/instantsearch.js/compare/v4.3.1...v4.4.0) (2020-04-08) + + +### Features + +* introduce controlled mode APIs with `onStateChange` and `setUiState` ([#4362](https://github.com/algolia/instantsearch.js/issues/4362)) ([4953324](https://github.com/algolia/instantsearch.js/commit/4953324ac8a3af4c6a8be411ca9e7cc673ee6561)) + + + +## [4.3.1](https://github.com/algolia/instantsearch.js/compare/v4.3.0...v4.3.1) (2020-03-06) + +This versions fixes a [Cross-Site Scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) (XSS) vulnerability ([#4344](https://github.com/algolia/instantsearch.js/issues/4344)) when using the [`refinementList`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/) widget when relying on its default [`item`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/#widget-param-item) template and [routing](https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-routing). **We recommend all users to upgrade to this version**. We now escape the `refinementList` `item` template by default, which avoids HTML to be injected. If ever you were relying on this behavior, **which we do not recommend**, you can copy the [previous `item` template](https://github.com/algolia/instantsearch.js/blob/933d9ffb3c0a396a047eeb4b44733b17aa31d081/src/widgets/refinement-list/defaultTemplates.js#L2-L9) into your widget. + +You were not vulnerable to this XSS if: + +- You didn't use [routing](https://www.algolia.com/doc/api-reference/widgets/instantsearch/js/#widget-param-routing) +- You didn't use use the [`refinementList`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/) widget ([`connectRefinementList`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/#connector) is not subject to this issue) +- You used a custom `item` template for your [`refinementList`](https://www.algolia.com/doc/api-reference/widgets/refinement-list/js/) widget that does not rely on the triple-brace Hogan.js syntax (e.g., `{{{highlighted}}}`) + + +### Bug Fixes + +* **refinementList:** prevent XSS via routing ([#4344](https://github.com/algolia/instantsearch.js/issues/4344)) ([8552221](https://github.com/algolia/instantsearch.js/commit/8552221eff17a4ae5ba9c454054b0eb6e002934d)) + + + +# [4.3.0](https://github.com/algolia/instantsearch.js/compare/v4.2.0...v4.3.0) (2020-02-25) + + +### Bug Fixes + +* **deps:** update dependency algoliasearch-helper to v3.1.1 that fixes a case where refinements for a facet with a name that matches a substring of another facet could be cleared by mistake ([algolia/algoliasearch-helper-js/pull/760](https://github.com/algolia/algoliasearch-helper-js/pull/760)) ([#4335](https://github.com/algolia/instantsearch.js/issues/4335)) ([9bc66cf](https://github.com/algolia/instantsearch.js/commit/381cda05c9c51dc9d3245a6d926e3c919245b723)) + + +### Features + +* **highlight:** add cssClasses to snippet & highlight helper ([#4306](https://github.com/algolia/instantsearch.js/issues/4306)) ([ece0aa6](https://github.com/algolia/instantsearch.js/commit/ece0aa60f05c2c687a23f9219d62ace0d5b866f9)) + + +# [4.2.0](https://github.com/algolia/instantsearch.js/compare/v4.1.1...v4.2.0) (2020-01-23) + + +### Features + +* **algoliasearch:** add support for algoliasearch v4 ([#4294](https://github.com/algolia/instantsearch.js/issues/4294)) ([73f1584](https://github.com/algolia/instantsearch.js/commit/73f158428c7d4de1e3d1bc40bf4342362f275829)) +* **insights:** add getInsightsAnonymousUserToken helper ([#4279](https://github.com/algolia/instantsearch.js/issues/4279)) ([4653f95](https://github.com/algolia/instantsearch.js/commit/4653f95b436a0715ce1489e0b83c00a87e4a02f0)) + + + +## [4.1.1](https://github.com/algolia/instantsearch.js/compare/v4.1.0...v4.1.1) (2019-12-20) + + +### Bug Fixes + +* **configureRelatedItems:** use `facetFilters` to exclude `obje… ([#4264](https://github.com/algolia/instantsearch.js/issues/4264)) ([9bc66cf](https://github.com/algolia/instantsearch.js/commit/9bc66cfb8b13a44840c687a1631696c85e45845f)) +* **index:** fix warning for widgets sharing connectors ([#4260](https://github.com/algolia/instantsearch.js/issues/4260)) ([ec97b4a](https://github.com/algolia/instantsearch.js/commit/ec97b4a07e5d1f9a967f5ee5925ebd3b447e1b02)) +* **insights:** export Insights helper in the ESM build ([#4261](https://github.com/algolia/instantsearch.js/issues/4261)) ([20649af](https://github.com/algolia/instantsearch.js/commit/20649aff54a3150050866038cd3718d6010c353b)) +* **insights:** move 'insightsClient not provided error' to wrapper level ([#4254](https://github.com/algolia/instantsearch.js/issues/4254)) ([15d38dd](https://github.com/algolia/instantsearch.js/commit/15d38ddb87fbd6323f350d42f791c4d7a1505eeb)) + + +### Features + +* **insights:** add hogan helper ([#4253](https://github.com/algolia/instantsearch.js/issues/4253)) ([85739d7](https://github.com/algolia/instantsearch.js/commit/85739d782ae1fad3b87612e4a410eada0ca4fe54)) + + + +# [4.1.0](https://github.com/algolia/instantsearch.js/compare/v4.0.1...v4.1.0) (2019-12-10) + +The [4.0.1](#4.0.1) release contained experimental TypeScript definitions in the ESM build by accident. We rolled this back in 4.1.0 because types will first be released on an experimental tag: `experimental-typescript`. + + +### Bug Fixes + +* **core:** display correct object types in messages ([#4249](https://github.com/algolia/instantsearch.js/issues/4249)) ([fb2c3c9](https://github.com/algolia/instantsearch.js/commit/fb2c3c9c37fd8d28cd4712486c5c637e237fe83b)) +* **insights:** detect clicks on children of `[data-insights]` HTML elements ([#4197](https://github.com/algolia/instantsearch.js/issues/4197)) ([9cac5a3](https://github.com/algolia/instantsearch.js/commit/9cac5a3aa4af616ec7913c17ed7388134c5e7f0a)) +* **insights:** display docs URL when missing ([#4231](https://github.com/algolia/instantsearch.js/issues/4231)) ([9df1e7f](https://github.com/algolia/instantsearch.js/commit/9df1e7f762333bd31b5840b35378d56605fe4844)) +* **widgets:** override connectors' `$$type` ([#4227](https://github.com/algolia/instantsearch.js/issues/4227)) ([50f4af3](https://github.com/algolia/instantsearch.js/commit/50f4af3006a44cd08dd99b3a72bd410340c2e48a)) + + +### Features + +* **middleware:** introduce `EXPERIMENTAL_use` to plug middleware into InstantSearch ([#4224](https://github.com/algolia/instantsearch.js/issues/4224)) ([9d1f7be](https://github.com/algolia/instantsearch.js/commit/9d1f7be9df304a4bc2d07dbd253a73580a0593c3)) +* **router:** plug router as a middleware ([#4224](https://github.com/algolia/instantsearch.js/issues/4224)) ([9d1f7be](https://github.com/algolia/instantsearch.js/commit/9d1f7be9df304a4bc2d07dbd253a73580a0593c3)) +* **insights:** detect window.aa when available on global scope and a function ([#4191](https://github.com/algolia/instantsearch.js/issues/4191)) ([d6df5af](https://github.com/algolia/instantsearch.js/commit/d6df5affc4111aaf2c82f847ffe877793faac86c)) +* **typescript:** add declaration files (experimental) ([#4220](https://github.com/algolia/instantsearch.js/issues/4220)) ([ebacfe5](https://github.com/algolia/instantsearch.js/commit/ebacfe55bc0fddf9ca217eca8c8a207b220ab93d)) +* **widgets:** introduce Related Items widgets as experimental (`EXPERIMENTAL_configureRelatedItems` and `EXPERIMENTAL_connectConfigureRelatedItems`) ([#4233](https://github.com/algolia/instantsearch.js/issues/4233)) ([f811f4e](https://github.com/algolia/instantsearch.js/commit/f811f4efa3e58a2b868d11ec338248715a7596c9)) + + + +## [4.0.1](https://github.com/algolia/instantsearch.js/compare/v4.0.0...v4.0.1) (2019-11-28) + + +### Bug Fixes + +* widget name in documentation link for index ([#4172](https://github.com/algolia/instantsearch.js/issues/4172)) ([fe7e588](https://github.com/algolia/instantsearch.js/commit/fe7e588d252ad6bd7de2f49d52ca022099f3e959)) +* **helper:** rely on stable version of algoliasearch-helper ([#4200](https://github.com/algolia/instantsearch.js/issues/4200)) ([ff11731](https://github.com/algolia/instantsearch.js/commit/ff117314d786c4509edabcb1ddbac73f55930511)) +* **infiniteHits:** correct widget options types ([#4222](https://github.com/algolia/instantsearch.js/issues/4222)) ([bb1b327](https://github.com/algolia/instantsearch.js/commit/bb1b327e26b5faad3358a00d174dc48fd4b73356)) +* **queryHook:** restore behaviour of queryHook ([#4202](https://github.com/algolia/instantsearch.js/issues/4202)) ([7bf96cb](https://github.com/algolia/instantsearch.js/commit/7bf96cb6eafd5349cdf2f32114d5e6ef5dde1328)), closes [/github.com/algolia/instantsearch.js/commit/c073a9acb51fff3c15278fcd563e47fec55c8365#diff-530222e0c4597f2110dc6ba173a306b0L98](https://github.com//github.com/algolia/instantsearch.js/commit/c073a9acb51fff3c15278fcd563e47fec55c8365/issues/diff-530222e0c4597f2110dc6ba173a306b0L98) + + +### Features + +* **transformers:** add tests ([#4153](https://github.com/algolia/instantsearch.js/issues/4153)) ([5a28415](https://github.com/algolia/instantsearch.js/commit/5a28415c39bf5a3a65c61d8f0d444ea6f4e0e17a)) + + + +# [4.0.0](https://github.com/algolia/instantsearch.js/compare/v3.7.0...v4.0.0) (2019-10-23) + +This release is focused on two main features: Federated search, and bundle size reduction. + +Federated search, is the feature where you search through multiple types of content with the same experience, but with separate result lists. In the past we have also called this feature "multi-index search". This feature helps you make more efficient UIs with multiple result lists, autocomplete, nested interfaces and query suggestions. You can read more about the new index widget [in the documentation](https://www.algolia.com/doc/api-reference/widgets/index-widget/js/). + +The second main feature is bundle size reduction. This is a bottom-up process where we started by removing Lodash from our bundle. While the library has many useful features, it was a major part of our compiled code. We have also updated to Preact X, the latest version of Preact internally. This allows us to use more modern (p)react features in the future, which have a more efficient bundling pattern. + +You can read more details on our choices by following [the original posts](https://discourse.algolia.com/t/instantsearch-js-v4-beta-0-is-released/8461) about the beta releases. + +Even though all this internally were major refactors, this should not have a big impact on how you are using InstantSearch. For the few things which did change, a migration guide can be found in [the documentation](https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-from-v3-to-v4). Don't hesitate to reach out if anything is unclear from that guide, so we can fix it for everyone. + +Note, if you are using the [places.js](https://github.com/algolia/places) InstantSearch widget, it is not compatible with InstantSearch v4. However, we took this opportunity to make it a real part of InstantSearch.js, and is now accessible as a widget of InstantSearch. You can use it with a `placesReference`. + +### Bug Fixes + +* **configure:** merge with the previous parameters ([#4085](https://github.com/algolia/instantsearch.js/issues/4085)) ([a215d0c](https://github.com/algolia/instantsearch.js/commit/a215d0c)) +* **configure:** update lifecycle state ([#3994](https://github.com/algolia/instantsearch.js/issues/3994)) ([3d8d967](https://github.com/algolia/instantsearch.js/commit/3d8d967)) +* **connectInfiniteHits:** fix page state when adding or removing widgets ([#4104](https://github.com/algolia/instantsearch.js/issues/4104)) ([1077340](https://github.com/algolia/instantsearch.js/commit/1077340)) +* **connectInfiniteHits:** fix state when navigating or adding/removing widgets ([#4123](https://github.com/algolia/instantsearch.js/issues/4123)) ([9cbd24a](https://github.com/algolia/instantsearch.js/commit/9cbd24a)) +* **createURL:** support multi-index ([#4082](https://github.com/algolia/instantsearch.js/issues/4082)) ([179a6e5](https://github.com/algolia/instantsearch.js/commit/179a6e5)) +* **defer:** recover from error ([#3933](https://github.com/algolia/instantsearch.js/issues/3933)) ([f22b9e2](https://github.com/algolia/instantsearch.js/commit/f22b9e2)) +* **helper:** expose .lastResults to .helper ([#4170](https://github.com/algolia/instantsearch.js/issues/4170)) ([236eb7b](https://github.com/algolia/instantsearch.js/commit/236eb7b)) +* **history:** avoid empty query string ([#4130](https://github.com/algolia/instantsearch.js/issues/4130)) ([18fee7c](https://github.com/algolia/instantsearch.js/commit/18fee7c)) +* **hits:** update lifecycle state ([#3977](https://github.com/algolia/instantsearch.js/issues/3977)) ([6e55ba6](https://github.com/algolia/instantsearch.js/commit/6e55ba6)) +* **hitsPerPage:** avoid sync default value ([#4086](https://github.com/algolia/instantsearch.js/issues/4086)) ([3f8b958](https://github.com/algolia/instantsearch.js/commit/3f8b958)) +* **hitsPerPage:** update lifecycle state ([#3978](https://github.com/algolia/instantsearch.js/issues/3978)) ([d21d620](https://github.com/algolia/instantsearch.js/commit/d21d620)) +* **index:** ensure that we always use the index set by widgets ([#4125](https://github.com/algolia/instantsearch.js/issues/4125)) ([952dc70](https://github.com/algolia/instantsearch.js/commit/952dc70)), closes [/github.com/algolia/algoliasearch-helper-js/blob/5a0352aa233c5ea932df6b054a16989c8d302404/src/algoliasearch.helper.js#L124](https://github.com//github.com/algolia/algoliasearch-helper-js/blob/5a0352aa233c5ea932df6b054a16989c8d302404/src/algoliasearch.helper.js/issues/L124) +* **index:** prevent render without results ([#3932](https://github.com/algolia/instantsearch.js/issues/3932)) ([1b9b5f4](https://github.com/algolia/instantsearch.js/commit/1b9b5f4)) +* **index:** subscribe to state change only after init for uiState ([#4003](https://github.com/algolia/instantsearch.js/issues/4003)) ([9490ca9](https://github.com/algolia/instantsearch.js/commit/9490ca9)) +* **index:** support custom UI params in UI state warning ([#4165](https://github.com/algolia/instantsearch.js/issues/4165)) ([80d32fc](https://github.com/algolia/instantsearch.js/commit/80d32fc)) +* **index:** warn for inconsistent UI state in development mode ([#4140](https://github.com/algolia/instantsearch.js/issues/4140)) ([7e277dc](https://github.com/algolia/instantsearch.js/commit/7e277dc)) +* **infiniteHits:** update lifecycle state ([#3983](https://github.com/algolia/instantsearch.js/issues/3983)) ([4b8bee5](https://github.com/algolia/instantsearch.js/commit/4b8bee5)) +* **instantsearch:** return instance in widgets methods ([#4143](https://github.com/algolia/instantsearch.js/issues/4143)) ([77ffb93](https://github.com/algolia/instantsearch.js/commit/77ffb93)) +* **InstantSearch:** cancel scheduled operations ([#3930](https://github.com/algolia/instantsearch.js/issues/3930)) ([3aafbad](https://github.com/algolia/instantsearch.js/commit/3aafbad)) +* **InstantSearch:** fix initialUIState when refinements are already present in the route ([#4103](https://github.com/algolia/instantsearch.js/issues/4103)) ([079db57](https://github.com/algolia/instantsearch.js/commit/079db57)) +* **InstantSearch:** remove useless walk/duplicate request ([#4127](https://github.com/algolia/instantsearch.js/issues/4127)) ([70163a8](https://github.com/algolia/instantsearch.js/commit/70163a8)) +* **menu:** apply & remove refinement ([#4027](https://github.com/algolia/instantsearch.js/issues/4027)) ([85de2cf](https://github.com/algolia/instantsearch.js/commit/85de2cf)) +* **menu:** prevent error on stale search ([#3934](https://github.com/algolia/instantsearch.js/issues/3934)) ([5f9e138](https://github.com/algolia/instantsearch.js/commit/5f9e138)) +* **numericMenu:** take array into account for empty state ([#4084](https://github.com/algolia/instantsearch.js/issues/4084)) ([2c05a01](https://github.com/algolia/instantsearch.js/commit/2c05a01)) +* **pagination:** update lifecycle state ([#3979](https://github.com/algolia/instantsearch.js/issues/3979)) ([2b08344](https://github.com/algolia/instantsearch.js/commit/2b08344)) +* **pagination:** update no refinement behavior ([#4124](https://github.com/algolia/instantsearch.js/issues/4124)) ([8d222ad](https://github.com/algolia/instantsearch.js/commit/8d222ad)) +* **range:** clear widget state on empty refinements ([#4157](https://github.com/algolia/instantsearch.js/issues/4157)) ([23cd112](https://github.com/algolia/instantsearch.js/commit/23cd112)) +* **ratingMenu:** update lifecycle state ([#3987](https://github.com/algolia/instantsearch.js/issues/3987)) ([ffadf64](https://github.com/algolia/instantsearch.js/commit/ffadf64)) +* **RefinementList:** remove root css class on sublists ([#4117](https://github.com/algolia/instantsearch.js/issues/4117)) ([ceddd42](https://github.com/algolia/instantsearch.js/commit/ceddd42)), closes [/github.com/algolia/instantsearch.js/blob/v2/src/decorators/headerFooter.js#L22](https://github.com//github.com/algolia/instantsearch.js/blob/v2/src/decorators/headerFooter.js/issues/L22) +* **searchBox:** update lifecycle state ([#3981](https://github.com/algolia/instantsearch.js/issues/3981)) ([0ea4950](https://github.com/algolia/instantsearch.js/commit/0ea4950)) +* **sortBy:** ensure a return value for getWidgetSearchParameters ([#4126](https://github.com/algolia/instantsearch.js/issues/4126)) ([569d573](https://github.com/algolia/instantsearch.js/commit/569d573)) +* **sortBy:** read initial index name from parent index ([#4079](https://github.com/algolia/instantsearch.js/issues/4079)) ([fe23c55](https://github.com/algolia/instantsearch.js/commit/fe23c55)) +* display warnings only in development ([#4150](https://github.com/algolia/instantsearch.js/issues/4150)) ([44f69a0](https://github.com/algolia/instantsearch.js/commit/44f69a0)) +* remove useless types ([#3958](https://github.com/algolia/instantsearch.js/issues/3958)) ([ddebf53](https://github.com/algolia/instantsearch.js/commit/ddebf53)) +* **stories:** hide Places ([#4152](https://github.com/algolia/instantsearch.js/issues/4152)) ([7ff843f](https://github.com/algolia/instantsearch.js/commit/7ff843f)) +* **toggleRefinement:** update lifecycle state ([#3993](https://github.com/algolia/instantsearch.js/issues/3993)) ([f1beff6](https://github.com/algolia/instantsearch.js/commit/f1beff6)) +* **voiceSearch:** update lifecycle state ([#3982](https://github.com/algolia/instantsearch.js/issues/3982)) ([798e3c1](https://github.com/algolia/instantsearch.js/commit/798e3c1)) +* **warnings:** remove v3 warnings ([#4134](https://github.com/algolia/instantsearch.js/issues/4134)) ([7eb6810](https://github.com/algolia/instantsearch.js/commit/7eb6810)) + + +### Features + +* **autocomplete:** leverage scoped results ([#3975](https://github.com/algolia/instantsearch.js/issues/3975)) ([8f05968](https://github.com/algolia/instantsearch.js/commit/8f05968)) +* **autocomplete:** participate in routing ([#4029](https://github.com/algolia/instantsearch.js/issues/4029)) ([a9ca0c5](https://github.com/algolia/instantsearch.js/commit/a9ca0c5)) +* **autocomplete:** provide indexId ([#4142](https://github.com/algolia/instantsearch.js/issues/4142)) ([b641e23](https://github.com/algolia/instantsearch.js/commit/b641e23)) +* **clearRefinements:** support multiple indices ([#4036](https://github.com/algolia/instantsearch.js/issues/4036)) ([3611b11](https://github.com/algolia/instantsearch.js/commit/3611b11)) +* **connectAutocomplete:** add default value on getConfiguration ([#3836](https://github.com/algolia/instantsearch.js/issues/3836)) ([724b83f](https://github.com/algolia/instantsearch.js/commit/724b83f)) +* **connectAutocomplete:** clear the state on dispose ([#3815](https://github.com/algolia/instantsearch.js/issues/3815)) ([8ae87d8](https://github.com/algolia/instantsearch.js/commit/8ae87d8)) +* **connectHierarchicalMenu:** update getWidgetSearchParameters ([#4053](https://github.com/algolia/instantsearch.js/issues/4053)) ([c99f822](https://github.com/algolia/instantsearch.js/commit/c99f822)) +* **connectHits:** clear the state on dispose ([#3816](https://github.com/algolia/instantsearch.js/issues/3816)) ([c4de730](https://github.com/algolia/instantsearch.js/commit/c4de730)) +* **connectHits:** implement getWidgetSearchParameters ([#4001](https://github.com/algolia/instantsearch.js/issues/4001)) ([c77cf66](https://github.com/algolia/instantsearch.js/commit/c77cf66)) +* **connectHitsPerPage:** clear the state on dispose ([#3818](https://github.com/algolia/instantsearch.js/issues/3818)) ([d7a5c89](https://github.com/algolia/instantsearch.js/commit/d7a5c89)) +* **connectInfiniteHits:** add default value on getConfiguration ([#3837](https://github.com/algolia/instantsearch.js/issues/3837)) ([8c65249](https://github.com/algolia/instantsearch.js/commit/8c65249)) +* **connectInfiniteHits:** clear the state on dispose ([#3819](https://github.com/algolia/instantsearch.js/issues/3819)) ([60ce151](https://github.com/algolia/instantsearch.js/commit/60ce151)) +* **connectMenu:** update getWidgetSearchParameters ([#4054](https://github.com/algolia/instantsearch.js/issues/4054)) ([7d001e7](https://github.com/algolia/instantsearch.js/commit/7d001e7)) +* **connectNumericMenu:** update state lifecycle ([#4013](https://github.com/algolia/instantsearch.js/issues/4013)) ([2620c90](https://github.com/algolia/instantsearch.js/commit/2620c90)) +* **connectPagination:** add default value on getConfiguration ([#3838](https://github.com/algolia/instantsearch.js/issues/3838)) ([aa4602c](https://github.com/algolia/instantsearch.js/commit/aa4602c)) +* **connectPagination:** clear the state on dispose ([#3821](https://github.com/algolia/instantsearch.js/issues/3821)) ([5b8ef49](https://github.com/algolia/instantsearch.js/commit/5b8ef49)) +* **connectPagination:** update getWidgetSearchParameters ([#4004](https://github.com/algolia/instantsearch.js/issues/4004)) ([eed7e77](https://github.com/algolia/instantsearch.js/commit/eed7e77)) +* **connectRange:** default `precision` to 0 ([#3953](https://github.com/algolia/instantsearch.js/issues/3953)) ([632e06b](https://github.com/algolia/instantsearch.js/commit/632e06b)) +* **connectRatingMenu:** update getWidgetSearchParameters ([#4008](https://github.com/algolia/instantsearch.js/issues/4008)) ([d3c96bf](https://github.com/algolia/instantsearch.js/commit/d3c96bf)) +* **connectRefinementList:** update getWidgetSearchParameters ([#4010](https://github.com/algolia/instantsearch.js/issues/4010)) ([ddc8fc4](https://github.com/algolia/instantsearch.js/commit/ddc8fc4)) +* **connectSearchBox:** clear the state on dispose ([#3822](https://github.com/algolia/instantsearch.js/issues/3822)) ([940522c](https://github.com/algolia/instantsearch.js/commit/940522c)) +* **connectSearchBox:** mount with a default query ([#3840](https://github.com/algolia/instantsearch.js/issues/3840)) ([c3a7d69](https://github.com/algolia/instantsearch.js/commit/c3a7d69)) +* **connectSearchBox:** update getWidgetSearchParameters ([#4002](https://github.com/algolia/instantsearch.js/issues/4002)) ([5c6fcd8](https://github.com/algolia/instantsearch.js/commit/5c6fcd8)) +* **connectVoiceSearch:** add default value on getConfiguration ([#3841](https://github.com/algolia/instantsearch.js/issues/3841)) ([fb70363](https://github.com/algolia/instantsearch.js/commit/fb70363)) +* **connectVoiceSearch:** clear the state on dispose ([#3823](https://github.com/algolia/instantsearch.js/issues/3823)) ([705b3e6](https://github.com/algolia/instantsearch.js/commit/705b3e6)) +* **connectVoiceSearch:** update getWidgetSearchParameters ([#4055](https://github.com/algolia/instantsearch.js/issues/4055)) ([b8c669f](https://github.com/algolia/instantsearch.js/commit/b8c669f)) +* **core:** deprecate addWidget & removeWidget ([#4131](https://github.com/algolia/instantsearch.js/issues/4131)) ([e5dafef](https://github.com/algolia/instantsearch.js/commit/e5dafef)) +* **currentRefinements:** support multiple indices ([#4012](https://github.com/algolia/instantsearch.js/issues/4012)) ([e997728](https://github.com/algolia/instantsearch.js/commit/e997728)) +* **defer:** implement cancellable callback ([#3916](https://github.com/algolia/instantsearch.js/issues/3916)) ([43a0bf8](https://github.com/algolia/instantsearch.js/commit/43a0bf8)) +* **federated:** keep a consistent state in the RefinementList life cycle ([#3976](https://github.com/algolia/instantsearch.js/issues/3976)) ([31d0fd6](https://github.com/algolia/instantsearch.js/commit/31d0fd6)) +* **hitsPerPage:** support new routing system ([#4038](https://github.com/algolia/instantsearch.js/issues/4038)) ([02502cb](https://github.com/algolia/instantsearch.js/commit/02502cb)), closes [#4069](https://github.com/algolia/instantsearch.js/issues/4069) +* **index:** accept indexId ([#4070](https://github.com/algolia/instantsearch.js/issues/4070)) ([b74f8e3](https://github.com/algolia/instantsearch.js/commit/b74f8e3)) +* **index:** add mergeSearchParameters function ([#3917](https://github.com/algolia/instantsearch.js/issues/3917)) ([c0fe7bb](https://github.com/algolia/instantsearch.js/commit/c0fe7bb)) +* **index:** add widget ([dbbda0f](https://github.com/algolia/instantsearch.js/commit/dbbda0f)), closes [#3892](https://github.com/algolia/instantsearch.js/issues/3892) [#3893](https://github.com/algolia/instantsearch.js/issues/3893) [#3914](https://github.com/algolia/instantsearch.js/issues/3914) +* **index:** compute local uiState ([#3997](https://github.com/algolia/instantsearch.js/issues/3997)) ([997c0f4](https://github.com/algolia/instantsearch.js/commit/997c0f4)) +* **index:** merge `ruleContexts` search parameter ([#3944](https://github.com/algolia/instantsearch.js/issues/3944)) ([e94752d](https://github.com/algolia/instantsearch.js/commit/e94752d)) +* **index:** provide scoped results to render hook ([#3964](https://github.com/algolia/instantsearch.js/issues/3964)) ([37c6aad](https://github.com/algolia/instantsearch.js/commit/37c6aad)) +* **index:** replicate searchFunction hack ([#4078](https://github.com/algolia/instantsearch.js/issues/4078)) ([1d2a816](https://github.com/algolia/instantsearch.js/commit/1d2a816)), closes [/github.com/algolia/instantsearch.js/blob/509513c0feafaad522f6f18d87a441559f4aa050/src/lib/RoutingManager.ts#L113-L130](https://github.com//github.com/algolia/instantsearch.js/blob/509513c0feafaad522f6f18d87a441559f4aa050/src/lib/RoutingManager.ts/issues/L113-L130) +* **index:** reset page of child indexes ([#3962](https://github.com/algolia/instantsearch.js/issues/3962)) ([131b1ce](https://github.com/algolia/instantsearch.js/commit/131b1ce)) +* **index:** resolve parent SearchParameters ([#3937](https://github.com/algolia/instantsearch.js/issues/3937)) ([2611da5](https://github.com/algolia/instantsearch.js/commit/2611da5)) +* **index:** use uiState driven SearchParameters ([#4059](https://github.com/algolia/instantsearch.js/issues/4059)) ([b12bb9f](https://github.com/algolia/instantsearch.js/commit/b12bb9f)) +* **infiniteHits:** support new routing system ([#4040](https://github.com/algolia/instantsearch.js/issues/4040)) ([49315cf](https://github.com/algolia/instantsearch.js/commit/49315cf)) +* **instantsearch:** add onStateChange method ([#4080](https://github.com/algolia/instantsearch.js/issues/4080)) ([9f68da5](https://github.com/algolia/instantsearch.js/commit/9f68da5)) +* **InstantSearch:** switch to DerivedHelper only ([#3885](https://github.com/algolia/instantsearch.js/issues/3885)) ([d6fc317](https://github.com/algolia/instantsearch.js/commit/d6fc317)) +* **places:** add Places widget ([#4167](https://github.com/algolia/instantsearch.js/issues/4167)) ([1d754d1](https://github.com/algolia/instantsearch.js/commit/1d754d1)) +* drop support of searchParameters for initialUiState ([#4081](https://github.com/algolia/instantsearch.js/issues/4081)) ([571efeb](https://github.com/algolia/instantsearch.js/commit/571efeb)) +* **range:** support new routing system ([#4039](https://github.com/algolia/instantsearch.js/issues/4039)) ([8cba05a](https://github.com/algolia/instantsearch.js/commit/8cba05a)) +* **routing:** add a "single index" compatibility mode ([#4087](https://github.com/algolia/instantsearch.js/issues/4087)) ([842eb0f](https://github.com/algolia/instantsearch.js/commit/842eb0f)) +* **RoutingManager:** update state on route update ([#4100](https://github.com/algolia/instantsearch.js/issues/4100)) ([88f2615](https://github.com/algolia/instantsearch.js/commit/88f2615)) +* **toggleRefinement:** support new routing system ([#4037](https://github.com/algolia/instantsearch.js/issues/4037)) ([6a9d99f](https://github.com/algolia/instantsearch.js/commit/6a9d99f)) +* **types:** DerivedHelper ([#3887](https://github.com/algolia/instantsearch.js/issues/3887)) ([0f38b4a](https://github.com/algolia/instantsearch.js/commit/0f38b4a)) +* **types:** rename RenderOptions -> RendererOptions ([#3867](https://github.com/algolia/instantsearch.js/issues/3867)) ([05c6f72](https://github.com/algolia/instantsearch.js/commit/05c6f72)) +* **utils:** implement defer ([#3882](https://github.com/algolia/instantsearch.js/issues/3882)) ([8af470e](https://github.com/algolia/instantsearch.js/commit/8af470e)) +* **voice:** add additional query parameters ([#3738](https://github.com/algolia/instantsearch.js/issues/3738)) ([c555255](https://github.com/algolia/instantsearch.js/commit/c555255)) +* drop suppot for onHistoryChange ([#3941](https://github.com/algolia/instantsearch.js/issues/3941)) ([697f609](https://github.com/algolia/instantsearch.js/commit/697f609)) +* introduce initialUiState option ([#4074](https://github.com/algolia/instantsearch.js/issues/4074)) ([de00707](https://github.com/algolia/instantsearch.js/commit/de00707)) +* update UiState definition ([#4075](https://github.com/algolia/instantsearch.js/issues/4075)) ([9e7d3d8](https://github.com/algolia/instantsearch.js/commit/9e7d3d8)) +* **widgets:** add `$$type` to widgets definition ([#3960](https://github.com/algolia/instantsearch.js/issues/3960)) ([344d1b7](https://github.com/algolia/instantsearch.js/commit/344d1b7)) + + + +# [3.7.0](https://github.com/algolia/instantsearch.js/compare/v3.5.4...v3.7.0) (2019-10-08) + + +### Bug Fixes + +* **clearRefinements:** reset page to 0 ([#3936](https://github.com/algolia/instantsearch.js/issues/3936)) ([7378a0a](https://github.com/algolia/instantsearch.js/commit/7378a0a)) +* **connectSortBy:** never update the initial index ([#4015](https://github.com/algolia/instantsearch.js/issues/4015)) ([bc0f9e2](https://github.com/algolia/instantsearch.js/commit/bc0f9e2)) +* **deps:** update dependency instantsearch.js to v3.5.4 ([#3929](https://github.com/algolia/instantsearch.js/issues/3929)) ([eff84c5](https://github.com/algolia/instantsearch.js/commit/eff84c5)) +* **deps:** update dependency instantsearch.js to v3.6.0 ([#4021](https://github.com/algolia/instantsearch.js/issues/4021)) ([7719bba](https://github.com/algolia/instantsearch.js/commit/7719bba)) +* **enhanceConfiguration:** deduplicate the hierarchicalFacets ([#3966](https://github.com/algolia/instantsearch.js/issues/3966)) ([baf8a35](https://github.com/algolia/instantsearch.js/commit/baf8a35)) +* **examples:** fix IE11 compatibility for e-commerce demo ([#4049](https://github.com/algolia/instantsearch.js/issues/4049)) ([dc6f350](https://github.com/algolia/instantsearch.js/commit/dc6f350)) +* **examples:** fix missing polyfill in e-commerce demo ([#4076](https://github.com/algolia/instantsearch.js/issues/4076)) ([4bf3ab3](https://github.com/algolia/instantsearch.js/commit/4bf3ab3)) +* **hierarchicalFacets:** prevent different rootPath on same attribute ([#3965](https://github.com/algolia/instantsearch.js/issues/3965)) ([5ee79fa](https://github.com/algolia/instantsearch.js/commit/5ee79fa)) +* **instantsearch:** warn deprecated usage of `searchParameters` ([#4151](https://github.com/algolia/instantsearch.js/issues/4151)) ([18e1c36](https://github.com/algolia/instantsearch.js/commit/18e1c36)) +* **menuSelect:** unmount component ([#3911](https://github.com/algolia/instantsearch.js/issues/3911)) ([f6debce](https://github.com/algolia/instantsearch.js/commit/f6debce)) +* **rangeInput:** unmount component ([#3910](https://github.com/algolia/instantsearch.js/issues/3910)) ([f6c29e8](https://github.com/algolia/instantsearch.js/commit/f6c29e8)) +* **refinementList:** fix showMore button to work after search ([#3082](https://github.com/algolia/instantsearch.js/issues/3082)) ([23e46b6](https://github.com/algolia/instantsearch.js/commit/23e46b6)) +* pass noop as default value to unmountFn at connectors ([#3955](https://github.com/algolia/instantsearch.js/issues/3955)) ([7c38744](https://github.com/algolia/instantsearch.js/commit/7c38744)) + + + +# [3.6.0](https://github.com/algolia/instantsearch.js/compare/v3.5.4...v3.6.0) (2019-07-30) + + +### Bug Fixes + +* **clearRefinements:** reset page to 0 ([#3936](https://github.com/algolia/instantsearch.js/issues/3936)) ([7378a0a](https://github.com/algolia/instantsearch.js/commit/7378a0a)) +* pass noop as default value to unmountFn at connectors ([#3955](https://github.com/algolia/instantsearch.js/issues/3955)) ([7c38744](https://github.com/algolia/instantsearch.js/commit/7c38744)) +* **enhanceConfiguration:** deduplicate the hierarchicalFacets ([#3966](https://github.com/algolia/instantsearch.js/issues/3966)) ([baf8a35](https://github.com/algolia/instantsearch.js/commit/baf8a35)) +* **hierarchicalFacets:** prevent different rootPath on same attribute ([#3965](https://github.com/algolia/instantsearch.js/issues/3965)) ([5ee79fa](https://github.com/algolia/instantsearch.js/commit/5ee79fa)) +* **menuSelect:** unmount component ([#3911](https://github.com/algolia/instantsearch.js/issues/3911)) ([f6debce](https://github.com/algolia/instantsearch.js/commit/f6debce)) +* **rangeInput:** unmount component ([#3910](https://github.com/algolia/instantsearch.js/issues/3910)) ([f6c29e8](https://github.com/algolia/instantsearch.js/commit/f6c29e8)) +* **refinementList:** fix showMore button to work after search ([#3082](https://github.com/algolia/instantsearch.js/issues/3082)) ([23e46b6](https://github.com/algolia/instantsearch.js/commit/23e46b6)) + + + +## [3.5.4](https://github.com/algolia/instantsearch.js/compare/v3.5.3...v3.5.4) (2019-07-01) + + +### Bug Fixes + +* **connectSortBy:** do not throw with wrong indexes ([#3824](https://github.com/algolia/instantsearch.js/issues/3824)) ([2a84ee2](https://github.com/algolia/instantsearch.js/commit/2a84ee2)) +* **deps:** update dependency instantsearch.js to v3.5.3 ([#3877](https://github.com/algolia/instantsearch.js/issues/3877)) ([463f3bb](https://github.com/algolia/instantsearch.js/commit/463f3bb)) +* **escape:** make sure that __escaped does not get removed ([#3830](https://github.com/algolia/instantsearch.js/issues/3830)) ([fbafd22](https://github.com/algolia/instantsearch.js/commit/fbafd22)) +* **getRefinements:** check for facet before accessing its data ([#3842](https://github.com/algolia/instantsearch.js/issues/3842)) ([aadc769](https://github.com/algolia/instantsearch.js/commit/aadc769)) +* **panel:** return value from dispose ([#3895](https://github.com/algolia/instantsearch.js/issues/3895)) ([bceb78f](https://github.com/algolia/instantsearch.js/commit/bceb78f)) +* **voiceSearch:** remove event listeners on stop ([#3845](https://github.com/algolia/instantsearch.js/issues/3845)) ([688e36a](https://github.com/algolia/instantsearch.js/commit/688e36a)) + + + +## [3.5.3](https://github.com/algolia/instantsearch.js/compare/v3.5.1...v3.5.3) (2019-05-28) + + +### Bug Fixes + +* **voiceSearch:** let the connector handle the default value of searchAsYouSpeak when it's not given ([#3817](https://github.com/algolia/instantsearch.js/issues/3817)) ([9d3e91b](https://github.com/algolia/instantsearch.js/commit/9d3e91b)) +* **getTag:** use object version of toString ([#3820](https://github.com/algolia/instantsearch.js/issues/3820)) ([a7348ea](https://github.com/algolia/instantsearch.js/commit/a7348ea)) +* **types:** fix cssClasses of voiceSearch ([#3783](https://github.com/algolia/instantsearch.js/issues/3783)) ([f016326](https://github.com/algolia/instantsearch.js/commit/f016326)) + + + +# [3.5.1](https://github.com/algolia/instantsearch.js/compare/v3.4.0...v3.5.1) (2019-05-20) + + +### Bug Fixes + +* **types:** improve types for voiceSearch ([#3778](https://github.com/algolia/instantsearch.js/issues/3778)) ([ed2d61a](https://github.com/algolia/instantsearch.js/commit/ed2d61a)) +* **types:** update UiState type ([#3777](https://github.com/algolia/instantsearch.js/issues/3777)) ([36e3a3d](https://github.com/algolia/instantsearch.js/commit/36e3a3d)) +* **voiceSearch:** remove event listeners on dispose ([#3779](https://github.com/algolia/instantsearch.js/issues/3779)) ([0e988cc](https://github.com/algolia/instantsearch.js/commit/0e988cc)) +* **hitsPerPage:** improve warning for missing state value ([#3707](https://github.com/algolia/instantsearch.js/issues/3707)) ([93d8432](https://github.com/algolia/instantsearch.js/commit/93d8432)) +* **numericMenu:** prevent refinement reset on checked radio click ([#3749](https://github.com/algolia/instantsearch.js/issues/3749)) ([e4a6e75](https://github.com/algolia/instantsearch.js/commit/e4a6e75)) +* **rangeSlider:** round the slider pit value ([#3758](https://github.com/algolia/instantsearch.js/issues/3758)) ([6edee3e](https://github.com/algolia/instantsearch.js/commit/6edee3e)), closes [#2904](https://github.com/algolia/instantsearch.js/issues/2904) +* **types:** improve UiState types ([#3763](https://github.com/algolia/instantsearch.js/issues/3763)) ([e8ea57b](https://github.com/algolia/instantsearch.js/commit/e8ea57b)) +* **voice:** import correct noop ([#3766](https://github.com/algolia/instantsearch.js/issues/3766)) ([6a80422](https://github.com/algolia/instantsearch.js/commit/6a80422)) + + +### Features + +* **voiceSearch:** add connector and widget ([#3601](https://github.com/algolia/instantsearch.js/issues/3601)) ([21e4d81](https://github.com/algolia/instantsearch.js/commit/21e4d81)) + + +### Reverts + +* chore(build): remove PropTypes from builds ([#3697](https://github.com/algolia/instantsearch.js/issues/3697)) ([#3776](https://github.com/algolia/instantsearch.js/issues/3776)) ([1e6be79](https://github.com/algolia/instantsearch.js/commit/1e6be79)) + + +# [3.4.0](https://github.com/algolia/instantsearch.js/compare/v3.3.0...v3.4.0) (2019-04-17) + + +### Bug Fixes + +* **storybook:** fix Hierarchical menu separator in Breadcrumb story ([#3695](https://github.com/algolia/instantsearch.js/issues/3695)) ([b3bf8ac](https://github.com/algolia/instantsearch.js/commit/b3bf8ac)) +* **tools:** use commonjs in bump-package-version.js ([#3699](https://github.com/algolia/instantsearch.js/issues/3699)) ([6a6dbe1](https://github.com/algolia/instantsearch.js/commit/6a6dbe1)) +* **types:** fix wrong typing in getWidgetState ([#3693](https://github.com/algolia/instantsearch.js/issues/3693)) ([b3c2154](https://github.com/algolia/instantsearch.js/commit/b3c2154)) +* **types:** remove unused Without type ([#3694](https://github.com/algolia/instantsearch.js/issues/3694)) ([656d000](https://github.com/algolia/instantsearch.js/commit/656d000)) + + +### Features + +* **infiniteHits:** add previous button ([#3675](https://github.com/algolia/instantsearch.js/issues/3675)) ([2e6137b](https://github.com/algolia/instantsearch.js/commit/2e6137b)) +* **Insights:** Insights inside Instantsearch ([#3598](https://github.com/algolia/instantsearch.js/issues/3598)) ([387f41f](https://github.com/algolia/instantsearch.js/commit/387f41f)) + + + +# [3.3.0](https://github.com/algolia/instantsearch.js/compare/v3.2.1...v3.3.0) (2019-04-11) + + +### Bug Fixes + +* **connectQueryRules:** improve tracked refinement type ([#3648](https://github.com/algolia/instantsearch.js/issues/3648)) ([e16ad57](https://github.com/algolia/instantsearch.js/commit/e16ad57)) +* **currentRefinements:** don't rely on `_objectSpread` ([#3672](https://github.com/algolia/instantsearch.js/issues/3672)) ([cd64bcf](https://github.com/algolia/instantsearch.js/commit/cd64bcf)) +* **queryRuleCustomData:** add default template ([#3650](https://github.com/algolia/instantsearch.js/issues/3650)) ([83e9eaa](https://github.com/algolia/instantsearch.js/commit/83e9eaa)) +* **QueryRuleCustomData:** pass data as object to templates ([#3647](https://github.com/algolia/instantsearch.js/issues/3647)) ([b8f8b4e](https://github.com/algolia/instantsearch.js/commit/b8f8b4e)) +* **queryRules:** fix types and stories ([#3670](https://github.com/algolia/instantsearch.js/issues/3670)) ([ba6e2e6](https://github.com/algolia/instantsearch.js/commit/ba6e2e6)) +* **routing:** apply windowTitle on first load ([#3669](https://github.com/algolia/instantsearch.js/issues/3669)) ([d553502](https://github.com/algolia/instantsearch.js/commit/d553502)), closes [#3667](https://github.com/algolia/instantsearch.js/issues/3667) +* **routing:** support parsing URLs with up to 100 refinements ([#3671](https://github.com/algolia/instantsearch.js/issues/3671)) ([6ddcfb6](https://github.com/algolia/instantsearch.js/commit/6ddcfb6)) +* **RoutingManager:** avoid stale uiState ([#3630](https://github.com/algolia/instantsearch.js/issues/3630)) ([e1588aa](https://github.com/algolia/instantsearch.js/commit/e1588aa)) +* **types:** improve InstantSearch types ([#3651](https://github.com/algolia/instantsearch.js/issues/3651)) ([db9b91e](https://github.com/algolia/instantsearch.js/commit/db9b91e)) +* **ua:** Update the User-Agent to use the new format ([#3616](https://github.com/algolia/instantsearch.js/issues/3616)) ([ab84c57](https://github.com/algolia/instantsearch.js/commit/ab84c57)) + + +### Features + +* **infiniteHits:** add previous button ([#3645](https://github.com/algolia/instantsearch.js/issues/3645)) ([2c9e38d](https://github.com/algolia/instantsearch.js/commit/2c9e38d)) +* **queryRules:** add connectQueryRules connector ([#3597](https://github.com/algolia/instantsearch.js/issues/3597)) ([924cd99](https://github.com/algolia/instantsearch.js/commit/924cd99)), closes [#3599](https://github.com/algolia/instantsearch.js/issues/3599) [#3600](https://github.com/algolia/instantsearch.js/issues/3600) +* **queryRules:** add context features to Query Rules ([#3617](https://github.com/algolia/instantsearch.js/issues/3617)) ([922879e](https://github.com/algolia/instantsearch.js/commit/922879e)), closes [#3602](https://github.com/algolia/instantsearch.js/issues/3602) + + +### Reverts + +* feat(infiniteHits): add previous button ([214c0fc](https://github.com/algolia/instantsearch.js/commit/214c0fc)) + + + +## [3.2.1](https://github.com/algolia/instantsearch.js/compare/v3.1.0...v3.2.1) (2019-03-18) + + +### Bug Fixes + +* **connectToggleRefinement:** keep user provided, but falsy values ([#3526](https://github.com/algolia/instantsearch.js/issues/3526)) ([958a151](https://github.com/algolia/instantsearch.js/commit/958a151)) +* **instantsearch:** update usage errors ([#3543](https://github.com/algolia/instantsearch.js/issues/3543)) ([a2a800b](https://github.com/algolia/instantsearch.js/commit/a2a800b)) +* **panel:** append panel body as a child element ([#3561](https://github.com/algolia/instantsearch.js/issues/3561)) ([3de59a3](https://github.com/algolia/instantsearch.js/commit/3de59a3)) +* **poweredBy:** remove TypeScript extension in import ([#3530](https://github.com/algolia/instantsearch.js/issues/3530)) ([99ecc0b](https://github.com/algolia/instantsearch.js/commit/99ecc0b)), closes [#3528](https://github.com/algolia/instantsearch.js/issues/3528) +* **release:** update doctoc script ([e07c654](https://github.com/algolia/instantsearch.js/commit/e07c654)) +* **searchbox:** unmount component on dispose ([#3563](https://github.com/algolia/instantsearch.js/issues/3563)) ([c3f0435](https://github.com/algolia/instantsearch.js/commit/c3f0435)) +* **searchBox:** add reusable SearchBox component ([#3489](https://github.com/algolia/instantsearch.js/issues/3489)) ([c073a9a](https://github.com/algolia/instantsearch.js/commit/c073a9a)) + + +### Features + +* **panel:** implement collapsed feature ([#3575](https://github.com/algolia/instantsearch.js/issues/3575)) ([e84b02b](https://github.com/algolia/instantsearch.js/commit/e84b02b)) + + + +# [3.2.0](https://github.com/algolia/instantsearch.js/compare/v3.1.0...v3.2.0) (2019-03-14) + + +### Bug Fixes + +* **instantsearch:** update usage errors ([#3543](https://github.com/algolia/instantsearch.js/issues/3543)) ([a2a800b](https://github.com/algolia/instantsearch.js/commit/a2a800b)) +* **searchBox:** add reusable SearchBox component ([#3489](https://github.com/algolia/instantsearch.js/issues/3489)) ([c073a9a](https://github.com/algolia/instantsearch.js/commit/c073a9a)) + + +### Features + +* **panel:** implement collapsed feature ([#3575](https://github.com/algolia/instantsearch.js/issues/3575)) ([e84b02b](https://github.com/algolia/instantsearch.js/commit/e84b02b)) + + + + +## [3.1.1](https://github.com/algolia/instantsearch.js/compare/v3.1.0...v3.1.1) (2019-02-14) + + +### Bug Fixes + +* **connectToggleRefinement:** keep user provided, but falsy values ([#3526](https://github.com/algolia/instantsearch.js/issues/3526)) ([958a151](https://github.com/algolia/instantsearch.js/commit/958a151)) +* **poweredBy:** remove TypeScript extension in import ([#3530](https://github.com/algolia/instantsearch.js/issues/3530)) ([99ecc0b](https://github.com/algolia/instantsearch.js/commit/99ecc0b)), closes [#3528](https://github.com/algolia/instantsearch.js/issues/3528) +* **release:** update doctoc script ([e07c654](https://github.com/algolia/instantsearch.js/commit/e07c654)) + + + + +## [3.1.0](https://github.com/algolia/instantsearch.js/compare/v3.0.0...v3.1.0) (2019-02-13) + +### Features + +* **connectCurrentRefinements**: add a root label ([#3515](https://github.com/algolia/instantsearch.js/pull/3515)) ([b8f774f](https://github.com/algolia/instantsearch.js/commit/b8f774f)) +* Update error messages ([#3516](https://github.com/algolia/instantsearch.js/pull/3516)) +* **InstantSearch**: remove event listeners on dispose ([#3420](https://github.com/algolia/instantsearch.js/pull/3420)) +* **InstantSearch**: set helper to `null` on dispose ([#3415](https://github.com/algolia/instantsearch.js/pull/3415)) +* **utils**: warn only in development ([#3367](https://github.com/algolia/instantsearch.js/pull/3367)) + +### Bug Fixes + +* **InstantSearch**: set helper to `null` on dispose ([#3415](https://github.com/algolia/instantsearch.js/pull/3415)) +* **utils**: warn only in development ([#3367](https://github.com/algolia/instantsearch.js/pull/3367)) + + +## [3.0.0](https://github.com/algolia/instantsearch.js/compare/v2.10.3...v3.0.0) (2018-12-20) + +Check the [migration guide](https://github.com/algolia/instantsearch.js/blob/879aa20d3c1e2fe906bc526b05c57f6847c433be/docgen/src/guides/v3-migration.md). + + +## [2.10.4](https://github.com/algolia/instantsearch.js/compare/v2.10.3...v2.10.4) (2018-10-30) + + +### Bug Fixes + +* **getRefinements:** provide attributeName for type: query ([6a58b99](https://github.com/algolia/instantsearch.js/commit/6a58b99)), closes [#3205](https://github.com/algolia/instantsearch.js/issues/3205) + + + +## [2.10.3](https://github.com/algolia/instantsearch.js/compare/v2.10.2...v2.10.3) (2018-10-29) + + +### Bug Fixes + +* **deps:** unpin production dependencies ([257ecb7](https://github.com/algolia/instantsearch.js/commit/257ecb7)) +* **InstantSearch:** avoid useless search on addWidgets ([#3178](https://github.com/algolia/instantsearch.js/issues/3178)) ([961626d](https://github.com/algolia/instantsearch.js/commit/961626d)) +* **numericselector:** default value can be undefined ([#3139](https://github.com/algolia/instantsearch.js/issues/3139)) ([39d22f5](https://github.com/algolia/instantsearch.js/commit/39d22f5)) + + +### Features + +* **utils:** add warn function ([#3147](https://github.com/algolia/instantsearch.js/issues/3147)) ([9de87bb](https://github.com/algolia/instantsearch.js/commit/9de87bb)) + + + + +## [2.10.2](https://github.com/algolia/instantsearch.js/compare/v2.10.1...v2.10.2) (2018-09-10) + + +### Bug Fixes + +* **searchbox:** Add missing color to searchbox input field ([#3086](https://github.com/algolia/instantsearch.js/issues/3086)) ([62b852a](https://github.com/algolia/instantsearch.js/commit/62b852a)), closes [#3075](https://github.com/algolia/instantsearch.js/issues/3075) +* **Stats:** let the widget render on all values ([#3070](https://github.com/algolia/instantsearch.js/issues/3070)) ([cd8f17e](https://github.com/algolia/instantsearch.js/commit/cd8f17e)), closes [#3056](https://github.com/algolia/instantsearch.js/issues/3056) + + + + +## [2.10.1](https://github.com/algolia/instantsearch.js/compare/v2.10.0...v2.10.1) (2018-08-17) + + +### Bug Fixes + +* **connectBreadcrumb:** ensure that data is an array ([#3067](https://github.com/algolia/instantsearch.js/issues/3067)) ([759f709](https://github.com/algolia/instantsearch.js/commit/759f709)) + + + + +# [2.10.0](https://github.com/algolia/instantsearch.js/compare/v2.9.0...v2.10.0) (2018-08-08) + + +### Bug Fixes + +* **release:** provide interactive TTY for npm publish ([#3053](https://github.com/algolia/instantsearch.js/issues/3053)) ([ede9460](https://github.com/algolia/instantsearch.js/commit/ede9460)) + + +### Features + +* Implement `transformItems` API ([#3042](https://github.com/algolia/instantsearch.js/issues/3042)) ([1510a94](https://github.com/algolia/instantsearch.js/commit/1510a94)) + + + + +# [2.9.0](https://github.com/algolia/instantsearch.js/compare/v2.8.1...v2.9.0) (2018-07-18) + + +### Features + +* **infiniteHits:** add showmoreButton to cssClasses ([#3026](https://github.com/algolia/instantsearch.js/issues/3026)) ([8287de0](https://github.com/algolia/instantsearch.js/commit/8287de0)) + + + + +## [2.8.1](https://github.com/algolia/instantsearch.js/compare/v2.8.0...v2.8.1) (2018-07-03) + + +### Bug Fixes + +* **connectHitsPerPage:** default value should not break the API ([#3006](https://github.com/algolia/instantsearch.js/issues/3006)) ([6635304](https://github.com/algolia/instantsearch.js/commit/6635304)), closes [#2732](https://github.com/algolia/instantsearch.js/issues/2732) +* **connectRefinementList:** throw error with usage ([#2962](https://github.com/algolia/instantsearch.js/issues/2962)) ([f60222d](https://github.com/algolia/instantsearch.js/commit/f60222d)) +* **sourcemap:** provide good url ([#3011](https://github.com/algolia/instantsearch.js/issues/3011)) ([9632ade](https://github.com/algolia/instantsearch.js/commit/9632ade)) +* **warning:** make sure suggested import is possible ([#3014](https://github.com/algolia/instantsearch.js/issues/3014)) ([eb27152](https://github.com/algolia/instantsearch.js/commit/eb27152)) + + + + +# [2.8.0](https://github.com/algolia/instantsearch.js/compare/v2.7.6...v2.8.0) (2018-05-30) + + +### Features + +* **connectors:** add connectAutocomplete ([#2841](https://github.com/algolia/instantsearch.js/issues/2841)) ([4bec81e](https://github.com/algolia/instantsearch.js/commit/4bec81e)), closes [/github.com/algolia/instantsearch.js/pull/2841#discussion_r188383882](https://github.com//github.com/algolia/instantsearch.js/pull/2841/issues/discussion_r188383882) [#2313](https://github.com/algolia/instantsearch.js/issues/2313) +* **search-client:** Add support for Universal Search Clients ([#2894](https://github.com/algolia/instantsearch.js/issues/2894)) ([5df3c74](https://github.com/algolia/instantsearch.js/commit/5df3c74)), closes [#2905](https://github.com/algolia/instantsearch.js/issues/2905) + + + + +## [2.7.6](https://github.com/algolia/instantsearch.js/compare/v2.7.5...v2.7.6) (2018-05-29) + + +### Bug Fixes + +* **connectConfigure:** ensure we do not extend `SearchParameters` ([#2945](https://github.com/algolia/instantsearch.js/issues/2945)) ([fdb4a7a](https://github.com/algolia/instantsearch.js/commit/fdb4a7a)) +* **infinite-hits:** fix [#2543](https://github.com/algolia/instantsearch.js/issues/2543) ([#2948](https://github.com/algolia/instantsearch.js/issues/2948)) ([bbf9f8f](https://github.com/algolia/instantsearch.js/commit/bbf9f8f)) + + + + +## [2.7.5](https://github.com/algolia/instantsearch.js/compare/v2.7.4...v2.7.5) (2018-05-28) + + +### Bug Fixes + +* **clear-all:** apply excludeAttribute correctly with clearsQuery ([#2935](https://github.com/algolia/instantsearch.js/issues/2935)) ([e782ab8](https://github.com/algolia/instantsearch.js/commit/e782ab8)) +* **connectInfiniteHits:** fix [#2928](https://github.com/algolia/instantsearch.js/issues/2928) ([#2939](https://github.com/algolia/instantsearch.js/issues/2939)) ([0293a31](https://github.com/algolia/instantsearch.js/commit/0293a31)) + + + + +## [2.7.4](https://github.com/algolia/instantsearch.js/compare/v2.7.3...v2.7.4) (2018-05-03) + + +### Bug Fixes + +* **searchFunction:** Fix unresolved returned Promise ([#2913](https://github.com/algolia/instantsearch.js/issues/2913)) ([5286c7c](https://github.com/algolia/instantsearch.js/commit/5286c7c)) + + + + +## [2.7.3](https://github.com/algolia/instantsearch.js/compare/v2.7.2...v2.7.3) (2018-04-26) + + +### Bug Fixes + +* **index.es6:** avoid use of Object.assign for IE ([#2908](https://github.com/algolia/instantsearch.js/issues/2908)) ([228b02e](https://github.com/algolia/instantsearch.js/commit/228b02e)) + + + + +## [2.7.2](https://github.com/algolia/instantsearch.js/compare/v2.7.1...v2.7.2) (2018-04-18) + +### Bug Fixes + +* **routing:** should apply stateMapping when doing initial write ([#2892](https://github.com/algolia/instantsearch.js/issues/2892)) ([7f62e6dc](https://github.com/algolia/instantsearch.js/commit/7f62e6dc)) +* **ie:** do not rely on Object.assign ([#2885](https://github.com/algolia/instantsearch.js/issues/2885)) ([88497e56](https://github.com/algolia/instantsearch.js/commit/88497e56)) + + + + +## [2.7.1](https://github.com/algolia/instantsearch.js/compare/v2.7.0...v2.7.1) (2018-04-11) + + +### Bug Fixes + +* **history:** provide location and use named parameters ([#2877](https://github.com/algolia/instantsearch.js/issues/2877)) ([761ffa4](https://github.com/algolia/instantsearch.js/commit/761ffa4)) + + + + +# [2.7.0](https://github.com/algolia/instantsearch.js/compare/v2.6.3...v2.7.0) (2018-04-09) + + +### Bug Fixes + +* pagination padding ([#2866](https://github.com/algolia/instantsearch.js/issues/2866)) ([e8c58cc](https://github.com/algolia/instantsearch.js/commit/e8c58cc)) +* **geosearch:** avoid reset map when it already moved ([#2870](https://github.com/algolia/instantsearch.js/issues/2870)) ([f171b8a](https://github.com/algolia/instantsearch.js/commit/f171b8a)) +* **removeWidget:** check for widgets.length on next tick ([#2831](https://github.com/algolia/instantsearch.js/issues/2831)) ([7e639d6](https://github.com/algolia/instantsearch.js/commit/7e639d6)) + + +### Features + +* **connetConfigure:** add a connector to create a connector widget ([8fdf752](https://github.com/algolia/instantsearch.js/commit/8fdf752)) +* **routing:** provide a mechanism to synchronize the search ([#2829](https://github.com/algolia/instantsearch.js/issues/2829)) ([75b2ca3](https://github.com/algolia/instantsearch.js/commit/75b2ca3)), closes [#2849](https://github.com/algolia/instantsearch.js/issues/2849) [#2849](https://github.com/algolia/instantsearch.js/issues/2849) +* **size:** add sideEffects false to package.json ([#2861](https://github.com/algolia/instantsearch.js/issues/2861)) ([f5d1ab1](https://github.com/algolia/instantsearch.js/commit/f5d1ab1)), closes [#2859](https://github.com/algolia/instantsearch.js/issues/2859) + + + + +## [2.6.3](https://github.com/algolia/instantsearch.js/compare/v2.6.2...v2.6.3) (2018-03-30) + + +### Bug Fixes + +* **rangeSlider:** handles were blocked ([#2849](https://github.com/algolia/instantsearch.js/issues/2849)) ([a2af4f0](https://github.com/algolia/instantsearch.js/commit/a2af4f0)) + + + + +## [2.6.2](https://github.com/algolia/instantsearch.js/compare/v2.6.1...v2.6.2) (2018-03-29) + + +### Bug Fixes + +* **connectGeoSearch:** correctly dispose the connector ([#2845](https://github.com/algolia/instantsearch.js/issues/2845)) ([a4eafd2](https://github.com/algolia/instantsearch.js/commit/a4eafd2)) +* **GeoSearch:** correctly unmount the widget ([#2846](https://github.com/algolia/instantsearch.js/issues/2846)) ([f31ef3c](https://github.com/algolia/instantsearch.js/commit/f31ef3c)) + + + + +## [2.6.1](https://github.com/algolia/instantsearch.js/compare/v2.6.0...v2.6.1) (2018-03-28) + + +### Bug Fixes + +* **connectBreadcrumb:** allow unmounting ([#2815](https://github.com/algolia/instantsearch.js/issues/2815)) ([c6c353a](https://github.com/algolia/instantsearch.js/commit/c6c353a)) +* **connectBreadcrumb:** update typo in property type items ([#2782](https://github.com/algolia/instantsearch.js/issues/2782)) ([79ebd66](https://github.com/algolia/instantsearch.js/commit/79ebd66)) +* **docgen:** pass the relatedTypes to the struct mixin in connectors layout ([#2780](https://github.com/algolia/instantsearch.js/issues/2780)) ([f7f8b05](https://github.com/algolia/instantsearch.js/commit/f7f8b05)) +* **GeoSearch:** update typo in property type cssClasses ([#2781](https://github.com/algolia/instantsearch.js/issues/2781)) ([419c2ab](https://github.com/algolia/instantsearch.js/commit/419c2ab)) +* **main:** correctly import EventEmitter ([#2814](https://github.com/algolia/instantsearch.js/issues/2814)) ([8fa3649](https://github.com/algolia/instantsearch.js/commit/8fa3649)), closes [#2730](https://github.com/algolia/instantsearch.js/issues/2730) + + + + +# [2.6.0](https://github.com/algolia/instantsearch.js/compare/v2.5.2...v2.6.0) (2018-03-06) + + +### Bug Fixes + +* **GeoSearch:** add apiKey for Google Maps ([#2773](https://github.com/algolia/instantsearch.js/issues/2773)) ([6c1846f](https://github.com/algolia/instantsearch.js/commit/6c1846f)) +* **GeoSearch:** override button style ([#2772](https://github.com/algolia/instantsearch.js/issues/2772)) ([4d69b50](https://github.com/algolia/instantsearch.js/commit/4d69b50)) + + +### Features + +* **configure:** add the Configure widget ([#2698](https://github.com/algolia/instantsearch.js/issues/2698)) ([94daabc](https://github.com/algolia/instantsearch.js/commit/94daabc)) +* add GeoSearch widget & connector ([#2743](https://github.com/algolia/instantsearch.js/issues/2743)) ([7fa17ff](https://github.com/algolia/instantsearch.js/commit/7fa17ff)) + + + + +## [2.5.2](https://github.com/algolia/instantsearch.js/compare/v2.5.1...v2.5.2) (2018-02-26) + + +### Bug Fixes + +* **Template:** harden Symbol checks ([#2749](https://github.com/algolia/instantsearch.js/issues/2749)) ([fab66bc](https://github.com/algolia/instantsearch.js/commit/fab66bc)) +* **yarnrc:** use empty string for save-prefix ([#2739](https://github.com/algolia/instantsearch.js/issues/2739)) ([979e0cd](https://github.com/algolia/instantsearch.js/commit/979e0cd)) + + + + +## [2.5.1](https://github.com/algolia/instantsearch.js/compare/v2.5.0...v2.5.1) (2018-02-13) + + +### Bug Fixes + +* **perf:** only compute snappoints when step is provided ([#2699](https://github.com/algolia/instantsearch.js/issues/2699)) ([ce9ca19](https://github.com/algolia/instantsearch.js/commit/ce9ca19)), closes [#2662](https://github.com/algolia/instantsearch.js/issues/2662) + + + + +# [2.5.0](https://github.com/algolia/instantsearch.js/compare/v2.4.1...v2.5.0) (2018-02-06) + + +### Bug Fixes + +* **doc:** add maximum width to images (fix [#2685](https://github.com/algolia/instantsearch.js/issues/2685)) ([#2686](https://github.com/algolia/instantsearch.js/issues/2686)) ([f4b5377](https://github.com/algolia/instantsearch.js/commit/f4b5377)) + + +### Features + +* support for algolia insights ([#2689](https://github.com/algolia/instantsearch.js/issues/2689)) ([96b8d61](https://github.com/algolia/instantsearch.js/commit/96b8d61)) + + + + +## [2.4.1](https://github.com/algolia/instantsearch.js/compare/v2.4.0...v2.4.1) (2018-01-04) + + +### Bug Fixes + +* **core:** correct escape highlight for arrays and nested objects ([#2646](https://github.com/algolia/instantsearch.js/issues/2646)) ([ed0ee73](https://github.com/algolia/instantsearch.js/commit/ed0ee73)) + + + + +# [2.4.0](https://github.com/algolia/instantsearch.js/compare/v2.3.3...v2.4.0) (2018-01-02) + + +### Bug Fixes + +* **pagination:** disable buttons if not results ([#2643](https://github.com/algolia/instantsearch.js/issues/2643)) ([9017b72](https://github.com/algolia/instantsearch.js/commit/9017b72)), closes [#2014](https://github.com/algolia/instantsearch.js/issues/2014) +* **theme:** fix height of pagination ([#2641](https://github.com/algolia/instantsearch.js/issues/2641)) ([b3185e5](https://github.com/algolia/instantsearch.js/commit/b3185e5)) + + +### Features + +* **core:** add a reload method on the InstantSearch component ([#2637](https://github.com/algolia/instantsearch.js/issues/2637)) ([e73ff13](https://github.com/algolia/instantsearch.js/commit/e73ff13)) +* **core:** add an error event to monitor error from Algolia ([#2642](https://github.com/algolia/instantsearch.js/issues/2642)) ([71c2d68](https://github.com/algolia/instantsearch.js/commit/71c2d68)), closes [#1585](https://github.com/algolia/instantsearch.js/issues/1585) +* **core:** rename `reload` to `refresh` ([#2645](https://github.com/algolia/instantsearch.js/issues/2645)) ([9b8ac65](https://github.com/algolia/instantsearch.js/commit/9b8ac65)) +* **wrapWithHits:** enable async init ([#2635](https://github.com/algolia/instantsearch.js/issues/2635)) ([08a8747](https://github.com/algolia/instantsearch.js/commit/08a8747)) + + + + +## [2.3.3](https://github.com/algolia/instantsearch.js/compare/v2.3.2...v2.3.3) (2017-12-11) + + +### Bug Fixes + +* **core:** search is stalled at init ([#2623](https://github.com/algolia/instantsearch.js/issues/2623)) ([e3dd577](https://github.com/algolia/instantsearch.js/commit/e3dd577)), closes [#2616](https://github.com/algolia/instantsearch.js/issues/2616) + + + + +## [2.3.2](https://github.com/algolia/instantsearch.js/compare/v2.3.1...v2.3.2) (2017-12-06) + + +### Bug Fixes + +* React reference: Breadcrumb & RangeInput components ([#2618](https://github.com/algolia/instantsearch.js/issues/2618)) ([7f32161](https://github.com/algolia/instantsearch.js/commit/7f32161)) + + + + +## [2.3.1](https://github.com/algolia/instantsearch.js/compare/v2.3.0...v2.3.1) (2017-12-04) + + +### Bug Fixes + +* **connectors:** check facet is refined before removing it. hierarchicalMenu / menu ([67ae035](https://github.com/algolia/instantsearch.js/commit/67ae035)) +* **poweredBy:** minify slightly and make into correct URL ([#2615](https://github.com/algolia/instantsearch.js/issues/2615)) ([2b7d747](https://github.com/algolia/instantsearch.js/commit/2b7d747)), closes [#2613](https://github.com/algolia/instantsearch.js/issues/2613) + + + + +# [2.3.0](https://github.com/algolia/instantsearch.js/compare/v2.3.0-beta.7...v2.3.0) (2017-11-30) + + +### Bug Fixes + +* **InstantSearch.dispose:** dont call `getConfiguration` of URLSync widget ([#2604](https://github.com/algolia/instantsearch.js/issues/2604)) ([3234b12](https://github.com/algolia/instantsearch.js/commit/3234b12)) +* **connectors:** prefer wrappers over bind ([#2575](https://github.com/algolia/instantsearch.js/issues/2575)) ([f8e0e00](https://github.com/algolia/instantsearch.js/commit/f8e0e00)) +* **connectHierarchicalMenu:** do not return if facet not set ([#2521](https://github.com/algolia/instantsearch.js/issues/2521)) ([26e99fb](https://github.com/algolia/instantsearch.js/commit/26e99fb)) + + + +### Features + +* **core:** provide information about stalled search to widgets ([#2569](https://github.com/algolia/instantsearch.js/issues/2569)) ([d104be1](https://github.com/algolia/instantsearch.js/commit/d104be1)) +* **core:** InstantSearch hot remove/add widgets ([#2384](https://github.com/algolia/instantsearch.js/issues/2384)) ([cfc1710](https://github.com/algolia/instantsearch.js/commit/cfc1710)) +* **refinementList:** add escapeFacetHits parameter ([#2507](https://github.com/algolia/instantsearch.js/issues/2507)) ([9b1b7ee](https://github.com/algolia/instantsearch.js/commit/9b1b7ee)) +* **breadcrumb:** Add the breadcrumb widget ([#2451](https://github.com/algolia/instantsearch.js/issues/2451)) ([11d78f0](https://github.com/algolia/instantsearch.js/commit/11d78f0)), closes [#2299](https://github.com/algolia/instantsearch.js/issues/2299) +* **connectRange:** round the range based on precision ([#2498](https://github.com/algolia/instantsearch.js/issues/2498)) ([d4df45d](https://github.com/algolia/instantsearch.js/commit/d4df45d)) +* **rangeInput:** add rangeInput widget ([#2440](https://github.com/algolia/instantsearch.js/issues/2440)) ([7916d16](https://github.com/algolia/instantsearch.js/commit/7916d16)) + + + + +## [2.2.5](https://github.com/algolia/instantsearch.js/compare/v2.2.4...v2.2.5) (2017-11-20) + + +### Bug Fixes + +* **searchbox:** fix usage of custom reset template ([#2585](https://github.com/algolia/instantsearch.js/issues/2585)) ([aad92b9](https://github.com/algolia/instantsearch.js/commit/aad92b9)), closes [#2528](https://github.com/algolia/instantsearch.js/issues/2528) + + + + +## [2.2.4](https://github.com/algolia/instantsearch.js/compare/v2.2.3...v2.2.4) (2017-11-13) + + +### Bug Fixes + +* **numericSelector:** make default value possible ([#2565](https://github.com/algolia/instantsearch.js/issues/2565)) ([5664f98](https://github.com/algolia/instantsearch.js/commit/5664f98)) + + + + +## [2.2.3](https://github.com/algolia/instantsearch.js/compare/v2.2.2...v2.2.3) (2017-11-07) + + +### Bug Fixes + +* **connectRefinementList:** add label to searched items ([#2553](https://github.com/algolia/instantsearch.js/issues/2553)) ([ec810fa](https://github.com/algolia/instantsearch.js/commit/ec810fa)) +* **refinementList:** fix facet exhaustivity check ([#2554](https://github.com/algolia/instantsearch.js/issues/2554)) ([0f1bf08](https://github.com/algolia/instantsearch.js/commit/0f1bf08)), closes [#2552](https://github.com/algolia/instantsearch.js/issues/2552) +* **theme:** searchbar should have normal size input ([#2545](https://github.com/algolia/instantsearch.js/issues/2545)) ([50d99f0](https://github.com/algolia/instantsearch.js/commit/50d99f0)) + + + + +## [2.2.2](https://github.com/algolia/instantsearch.js/compare/v2.2.1...v2.2.2) (2017-10-30) + + +### Bug Fixes + +* **connectRefinementList:** set default value for limit ([#2517](https://github.com/algolia/instantsearch.js/issues/2517)) ([32918c9](https://github.com/algolia/instantsearch.js/commit/32918c9)) +* **MenuSelect:** switch from react to preact-compat ([#2513](https://github.com/algolia/instantsearch.js/issues/2513)) ([06aa626](https://github.com/algolia/instantsearch.js/commit/06aa626)) +* **range-slider:** add option `collapsible` ([#2502](https://github.com/algolia/instantsearch.js/issues/2502)) ([e78399d](https://github.com/algolia/instantsearch.js/commit/e78399d)), closes [#2501](https://github.com/algolia/instantsearch.js/issues/2501) +* **url-sync:** make URLSync consistent even if search is tampered ([392927e](https://github.com/algolia/instantsearch.js/commit/392927e)), closes [#2523](https://github.com/algolia/instantsearch.js/issues/2523) + + + + +## [2.2.1](https://github.com/algolia/instantsearch.js/compare/v2.2.0...v2.2.1) (2017-10-16) + + +### Bug Fixes + +* **connectRangeSlider:** only clear the refinement on the current attribute ([#2459](https://github.com/algolia/instantsearch.js/issues/2459)) ([7cebf58](https://github.com/algolia/instantsearch.js/commit/7cebf58)) +* **menuSelect:** select in userCssClasses ([#2455](https://github.com/algolia/instantsearch.js/issues/2455)) ([0eb3dc8](https://github.com/algolia/instantsearch.js/commit/0eb3dc8)) +* **menuSelect:** use preact instead of React ([#2460](https://github.com/algolia/instantsearch.js/issues/2460)) ([35ccae8](https://github.com/algolia/instantsearch.js/commit/35ccae8)) +* **test:** correctly reset the wired dependency ([#2461](https://github.com/algolia/instantsearch.js/issues/2461)) ([1f7f4ed](https://github.com/algolia/instantsearch.js/commit/1f7f4ed)) + + + + +# [2.2.0](https://github.com/algolia/instantsearch.js/compare/v2.1.6...v2.2.0) (2017-10-03) + + +### Bug Fixes + +* **build:** minify css with `csso` instead of unminify css ([#2419](https://github.com/algolia/instantsearch.js/issues/2419)) ([12f96b8](https://github.com/algolia/instantsearch.js/commit/12f96b8)), closes [#2375](https://github.com/algolia/instantsearch.js/issues/2375) +* **clear-all:** display the query when clearsQuery is true ([#2414](https://github.com/algolia/instantsearch.js/issues/2414)) ([6921895](https://github.com/algolia/instantsearch.js/commit/6921895)) +* **range-slider:** Fix slider boundaries ([#2408](https://github.com/algolia/instantsearch.js/issues/2408)) ([bea43db](https://github.com/algolia/instantsearch.js/commit/bea43db)), closes [#2386](https://github.com/algolia/instantsearch.js/issues/2386) +* **selector:** root classname is applied twice ([#2423](https://github.com/algolia/instantsearch.js/issues/2423)) ([44dca11](https://github.com/algolia/instantsearch.js/commit/44dca11)), closes [#2396](https://github.com/algolia/instantsearch.js/issues/2396) [#2397](https://github.com/algolia/instantsearch.js/issues/2397) +* **webpack.dev:** sourcemaps in dev ([#2422](https://github.com/algolia/instantsearch.js/issues/2422)) ([ba6ca0a](https://github.com/algolia/instantsearch.js/commit/ba6ca0a)) + + +### Features + +* **menu-select:** add menu select widget ([#2316](https://github.com/algolia/instantsearch.js/issues/2316)) ([680f9bd](https://github.com/algolia/instantsearch.js/commit/680f9bd)) + + + + +# [2.2.0-beta.1](https://github.com/algolia/instantsearch.js/compare/v2.1.4...v2.2.0-beta.1) (2017-09-18) + + +### Features + +* **analytics:** Push pagination ([#2337](https://github.com/algolia/instantsearch.js/issues/2337)) ([94ce086](https://github.com/algolia/instantsearch.js/commit/94ce086)) +* **hitsPerPageSelector:** default hits per page setting ([4efd43e](https://github.com/algolia/instantsearch.js/commit/4efd43e)) +* **hitsPerPageSelector:** default hits per page setting ([355f080](https://github.com/algolia/instantsearch.js/commit/355f080)) + + + + +## [2.1.6](https://github.com/algolia/instantsearch.js/compare/v2.1.5...v2.1.6) (2017-09-26) + + +### Bug Fixes + +* **deps:** update dependency documentation to v^5.0.0 ([#2355](https://github.com/algolia/instantsearch.js/issues/2355)) ([489647a](https://github.com/algolia/instantsearch.js/commit/489647a)) +* **searchbox:** use initial input value if provided in the dom ([#2342](https://github.com/algolia/instantsearch.js/issues/2342)) ([180902a](https://github.com/algolia/instantsearch.js/commit/180902a)), closes [#2289](https://github.com/algolia/instantsearch.js/issues/2289) + + + + +## [2.1.5](https://github.com/algolia/instantsearch.js/compare/v2.1.4...v2.1.5) (2017-09-25) + + +### Bug Fixes + +* **deps:** update dependency algolia-frontend-components to v^0.0.33 ([#2341](https://github.com/algolia/instantsearch.js/issues/2341)) ([16994d8](https://github.com/algolia/instantsearch.js/commit/16994d8)) +* **price-ranges:** update call to refine ([#2377](https://github.com/algolia/instantsearch.js/issues/2377)) ([34915d7](https://github.com/algolia/instantsearch.js/commit/34915d7)) +* **slider:** Fix range slider pips and value 0 ([#2350](https://github.com/algolia/instantsearch.js/issues/2350)) ([fa0dc09](https://github.com/algolia/instantsearch.js/commit/fa0dc09)), closes [#2343](https://github.com/algolia/instantsearch.js/issues/2343) + + + + +## [2.1.4](https://github.com/algolia/instantsearch.js/compare/v2.1.3...v2.1.4) (2017-09-14) + + +### Bug Fixes + +* **release-script:** Add the generation of changelog for the release ([#2333](https://github.com/algolia/instantsearch.js/issues/2333)) ([9a2f70b](https://github.com/algolia/instantsearch.js/commit/9a2f70b)) +* **slider:** edge case when min > max ([#2336](https://github.com/algolia/instantsearch.js/issues/2336)) ([8830ab0](https://github.com/algolia/instantsearch.js/commit/8830ab0)) +* **slider:** Fix range slider dev env ([#2320](https://github.com/algolia/instantsearch.js/issues/2320)) ([e78de70](https://github.com/algolia/instantsearch.js/commit/e78de70)) +* **slider:** use algolia fork of rheostat ([#2335](https://github.com/algolia/instantsearch.js/issues/2335)) ([9eae009](https://github.com/algolia/instantsearch.js/commit/9eae009)) + + + + +## [2.1.3](https://github.com/algolia/instantsearch.js/compare/v2.1.2...v2.1.3) (2017-09-05) + + +### Bug Fixes + +* **Pagination:** add `autohideContainerHOC` to ([#2296](https://github.com/algolia/instantsearch.js/issues/2296)) ([545f076](https://github.com/algolia/instantsearch.js/commit/545f076)) +* **sffv:** no error when not providing noResults and no results ([#2310](https://github.com/algolia/instantsearch.js/issues/2310)) ([cc02b71](https://github.com/algolia/instantsearch.js/commit/cc02b71)), closes [#2087](https://github.com/algolia/instantsearch.js/issues/2087) + + + + +## [2.1.2](https://github.com/algolia/instantsearch.js/compare/v2.1.1...v2.1.2) (2017-08-24) + + +### Bug Fixes + +* **es:** wrong path to files ([#2295](https://github.com/algolia/instantsearch.js/issues/2295)) ([a437e19](https://github.com/algolia/instantsearch.js/commit/a437e19)) + + + + +## [2.1.1](https://github.com/algolia/instantsearch.js/compare/v2.1.0...v2.1.1) (2017-08-23) + + +### Bug Fixes + +* **build:** provide unminified css as well ([#2292](https://github.com/algolia/instantsearch.js/issues/2292)) ([a79e067](https://github.com/algolia/instantsearch.js/commit/a79e067)) + + + + +# [2.1.0](https://github.com/algolia/instantsearch.js/compare/v2.1.0-beta.4...v2.1.0) (2017-08-21) + + +### Bug Fixes + +* **nvmrc:** upgrade nodejs version ([#2291](https://github.com/algolia/instantsearch.js/issues/2291)) ([94529d4](https://github.com/algolia/instantsearch.js/commit/94529d4)) + + + + +## [2.0.2](https://github.com/algolia/instantsearch.js/compare/v2.0.1...v2.0.2) (2017-07-24) + + +### Bug Fixes + +* **doc:** Cosmetic change ([48bb128](https://github.com/algolia/instantsearch.js/commit/48bb128)) +* **search-box:** fix magnifier and reset customization ([4adfade](https://github.com/algolia/instantsearch.js/commit/4adfade)) +* **theme:** enforce box-sizing: border-box ([e26e50d](https://github.com/algolia/instantsearch.js/commit/e26e50d)) +* **url-sync:** remove is_v from url ([f19a1d5](https://github.com/algolia/instantsearch.js/commit/f19a1d5)), closes [#2233](https://github.com/algolia/instantsearch.js/issues/2233) + + + + +## [2.0.1](https://github.com/algolia/instantsearch.js/compare/v2.0.0...v2.0.1) (2017-07-12) + + + + +# [2.0.0](https://github.com/algolia/instantsearch.js/compare/v1.11.15...v2.0.0) (2017-07-01) + + +### Bug Fixes + +* **argos-ci:** blur the active element ([66d0551](https://github.com/algolia/instantsearch.js/commit/66d0551)) +* **connectNumericRefinementList:** reset page on refine ([22ec08d](https://github.com/algolia/instantsearch.js/commit/22ec08d)) +* **doc.build:** watch & rebuild `.pug` ([16d8542](https://github.com/algolia/instantsearch.js/commit/16d8542)) +* **doc.build/autoprefixer:** update mtime for onlyChanged plugin ([3b83e58](https://github.com/algolia/instantsearch.js/commit/3b83e58)) +* **escapeHits:** dont apply configuration if not requested ([c89f99d](https://github.com/algolia/instantsearch.js/commit/c89f99d)) + + +### Features + +* **searchFunction:** make search function provide a better API ([8fc0831](https://github.com/algolia/instantsearch.js/commit/8fc0831)) + + + + +# [2.0.0-beta.5](https://github.com/algolia/instantsearch.js/compare/v1.11.12...v2.0.0-beta.5) (2017-06-01) + + +### Bug Fixes + +* **Slider:** dont call `refine()` when it's disabled ([f1eabc9](https://github.com/algolia/instantsearch.js/commit/f1eabc9)) ### Features -* **algolia:** update the algolia dependencies ([8c17361](https://github.com/algolia/instantsearch.js/commit/8c17361)) +* **hits:** opt-in xss filtering for hits and infinite hits. FIX #2138 ([4f67b48](https://github.com/algolia/instantsearch.js/commit/4f67b48)), closes [#2138](https://github.com/algolia/instantsearch.js/issues/2138) + + + + +# [2.0.0-beta.4](https://github.com/algolia/instantsearch.js/compare/v1.11.11...v2.0.0-beta.4) (2017-05-24) + + +### Bug Fixes + +* **misc:** IE 11 support ([072edfe](https://github.com/algolia/instantsearch.js/commit/072edfe)) +* **misc:** IE11 support without using transpiler ([324f062](https://github.com/algolia/instantsearch.js/commit/324f062)) +* **show-more:** should hide button when show more is not available (#2161) ([fbca3e6](https://github.com/algolia/instantsearch.js/commit/fbca3e6)), closes [#2160](https://github.com/algolia/instantsearch.js/issues/2160) +* **Slider:** handle edge case where `min === max` ([22a5614](https://github.com/algolia/instantsearch.js/commit/22a5614)) +* **Slider:** restore `slider--handle-lower` && `slider--handle-upper` ([64d7ad2](https://github.com/algolia/instantsearch.js/commit/64d7ad2)) - -# [1.12.0](https://github.com/algolia/instantsearch.js/compare/v1.11.15...v1.12.0) (2018-05-16) + +# [2.0.0-beta.2](https://github.com/algolia/instantsearch.js/compare/v1.11.9...v2.0.0-beta.2) (2017-05-17) ### Bug Fixes -* **doc:** Absolute URLs for meta images ([b453bb4](https://github.com/algolia/instantsearch.js/commit/b453bb4)) +* **autoHideContainer:** dont prevent render with `shouldComponentUpdate` ([8c4b13f](https://github.com/algolia/instantsearch.js/commit/8c4b13f)) +* **clearsQuery:** not applied when only the query was not empty ([e7976ad](https://github.com/algolia/instantsearch.js/commit/e7976ad)) +* **connectors:** ensure `widgetParams` is at least an `{}` ([0c0e98f](https://github.com/algolia/instantsearch.js/commit/0c0e98f)) +* **connectRefinementList:** currentRefinements: return an array instead of first item ([a53223a](https://github.com/algolia/instantsearch.js/commit/a53223a)), closes [#2102](https://github.com/algolia/instantsearch.js/issues/2102) +* **dev:docs:** dont watch `/docgen/rootFiles` ([ab1a7f5](https://github.com/algolia/instantsearch.js/commit/ab1a7f5)) +* **doc:** add doc for isFirstRendering ([cea6739](https://github.com/algolia/instantsearch.js/commit/cea6739)) +* **docs:** dont filter out `p.type.type` ([881659a](https://github.com/algolia/instantsearch.js/commit/881659a)) +* **documentation.js:** Support for record types ([219ecd9](https://github.com/algolia/instantsearch.js/commit/219ecd9)) +* **documentationjs:** add support litteral string types in type format ([2a08e7d](https://github.com/algolia/instantsearch.js/commit/2a08e7d)) +* **documentationjs:** deeper related types ([6e3121e](https://github.com/algolia/instantsearch.js/commit/6e3121e)) +* **documentationjs:** find related type in TypeApplication ([e0487ee](https://github.com/algolia/instantsearch.js/commit/e0487ee)) +* **documentationjs:** fix 2+ depth structs ([4c8b7ec](https://github.com/algolia/instantsearch.js/commit/4c8b7ec)) +* **documentationjs:** fixed default value parameter ([b62cbc7](https://github.com/algolia/instantsearch.js/commit/b62cbc7)) +* **documentationjs:** records display with , ([8a968f2](https://github.com/algolia/instantsearch.js/commit/8a968f2)) +* **documentationjs:** Updgrade to RC + fixes ([e9f0361](https://github.com/algolia/instantsearch.js/commit/e9f0361)) +* **infinite-hits:** Remove hitsPerPage option (#2128) ([c13e377](https://github.com/algolia/instantsearch.js/commit/c13e377)) +* **live-example:** adapt regex for matching connectors ([774254c](https://github.com/algolia/instantsearch.js/commit/774254c)) +* **pagination:** fix zealous find/replace ([e269d87](https://github.com/algolia/instantsearch.js/commit/e269d87)) +* **price-ranges:** fix test ([fd65cb3](https://github.com/algolia/instantsearch.js/commit/fd65cb3)) +* **price-ranges:** New API uses ranges ([a5a6916](https://github.com/algolia/instantsearch.js/commit/a5a6916)) +* **refinementList:** reimplement show more on refinement list ([72655ab](https://github.com/algolia/instantsearch.js/commit/72655ab)) +* **refinementList:** sffv fix thanks [@julienpa](https://github.com/julienpa) ([30e0e9a](https://github.com/algolia/instantsearch.js/commit/30e0e9a)) +* **sffv:** Fix exhaustive facets ([0cadcc3](https://github.com/algolia/instantsearch.js/commit/0cadcc3)) +* **sortby:** Consistent across widget / connectors + migration ([8e366cc](https://github.com/algolia/instantsearch.js/commit/8e366cc)) +* **widgets/price-ranges:** wrong compute of `templateProps` ([be5e063](https://github.com/algolia/instantsearch.js/commit/be5e063)) ### Features -* **algolia:** update the algolia dependencies ([8c17361](https://github.com/algolia/instantsearch.js/commit/8c17361)) +* **connectHierarchicalMenu:** remove `currentRefinement` ([3912aaf](https://github.com/algolia/instantsearch.js/commit/3912aaf)) +* **connectHits:** typo `widgetOptions` -> `widgetParams` ([4420231](https://github.com/algolia/instantsearch.js/commit/4420231)) +* **connector:** Add hierarchical menu connector ([f727949](https://github.com/algolia/instantsearch.js/commit/f727949)) +* **connector:** add infinite hits connector ([cdf8675](https://github.com/algolia/instantsearch.js/commit/cdf8675)) +* **connector:** add instantsearchInstance to pagination render ([4fa96dc](https://github.com/algolia/instantsearch.js/commit/4fa96dc)) +* **connector:** add missing jsDoc descriptions ([e26e8e2](https://github.com/algolia/instantsearch.js/commit/e26e8e2)) +* **connector:** add range-slider ([1a02798](https://github.com/algolia/instantsearch.js/commit/1a02798)) +* **connector:** add tests for connectClearAll and connectHierarchicalMenu ([0eb29ec](https://github.com/algolia/instantsearch.js/commit/0eb29ec)) +* **connector:** Adds hits and menu connectors ([77083b7](https://github.com/algolia/instantsearch.js/commit/77083b7)) +* **connector:** Clear and CurrentRefinedValues ([02f7d3e](https://github.com/algolia/instantsearch.js/commit/02f7d3e)) +* **connector:** clearAll connector (iteration 2) ([90aa02e](https://github.com/algolia/instantsearch.js/commit/90aa02e)) +* **connector:** clearAll jsDoc + eslint fixes ([430a420](https://github.com/algolia/instantsearch.js/commit/430a420)) +* **connector:** complete jsdoc + pass instantsearch to view ([e125931](https://github.com/algolia/instantsearch.js/commit/e125931)) +* **connector:** connectClearAll documentation ([9b153aa](https://github.com/algolia/instantsearch.js/commit/9b153aa)) +* **connector:** connectClearAll iteration 2 (fix) ([03653f1](https://github.com/algolia/instantsearch.js/commit/03653f1)) +* **connector:** connectClearAll test ([5409157](https://github.com/algolia/instantsearch.js/commit/5409157)) +* **connector:** connectCurrentRefinedValues (iteration 2) ([68408de](https://github.com/algolia/instantsearch.js/commit/68408de)) +* **connector:** connectHierarchicalMenu (iteration 2) ([589454c](https://github.com/algolia/instantsearch.js/commit/589454c)) +* **connector:** connectHierarchicalMenu jsDoc ([e166090](https://github.com/algolia/instantsearch.js/commit/e166090)) +* **connector:** connectHits (iteration 2) ([bca09af](https://github.com/algolia/instantsearch.js/commit/bca09af)) +* **connector:** connectHitsPerPageSelector (iteration 2) ([26bb273](https://github.com/algolia/instantsearch.js/commit/26bb273)) +* **connector:** connectInfiniteHits (iteration 2) ([410459c](https://github.com/algolia/instantsearch.js/commit/410459c)) +* **connector:** connectNumericRefinementList (iteration 2) ([bfcf860](https://github.com/algolia/instantsearch.js/commit/bfcf860)) +* **connector:** connectNumericSelector (iteration 2) ([1eda8a2](https://github.com/algolia/instantsearch.js/commit/1eda8a2)) +* **connector:** connectNumericSelector jsDoc ([760fcea](https://github.com/algolia/instantsearch.js/commit/760fcea)) +* **connector:** connectRefinementList jsdoc + start document bool isFirstRendering ([52d13de](https://github.com/algolia/instantsearch.js/commit/52d13de)) +* **connector:** connectStats second iteration ([82b1cb3](https://github.com/algolia/instantsearch.js/commit/82b1cb3)) +* **connector:** connectToggle second iteration ([73b0878](https://github.com/algolia/instantsearch.js/commit/73b0878)) +* **connector:** fix createURL usage to generate correct urls ([fdf59d7](https://github.com/algolia/instantsearch.js/commit/fdf59d7)) +* **connector:** fix no param usage on custom infiniteHits ([961348a](https://github.com/algolia/instantsearch.js/commit/961348a)) +* **connector:** fix parameter consistency in connectClearAll ([9ddffd8](https://github.com/algolia/instantsearch.js/commit/9ddffd8)) +* **connector:** Fix parameters for toggle connector ([f96671c](https://github.com/algolia/instantsearch.js/commit/f96671c)) +* **connector:** hits-per-page-selector connector refactoring ([dd794e0](https://github.com/algolia/instantsearch.js/commit/dd794e0)) +* **connector:** jsDoc + check rendering function ([86f9739](https://github.com/algolia/instantsearch.js/commit/86f9739)) +* **connector:** jsDoc connectPagination ([3b284de](https://github.com/algolia/instantsearch.js/commit/3b284de)) +* **connector:** jsDoc for connectMenu ([626d5f1](https://github.com/algolia/instantsearch.js/commit/626d5f1)) +* **connector:** jsDoc updates ([c924043](https://github.com/algolia/instantsearch.js/commit/c924043)) +* **connector:** move clearAll as a rendering option ([ce41cde](https://github.com/algolia/instantsearch.js/commit/ce41cde)) +* **connector:** Numeric selector ([0dc42d2](https://github.com/algolia/instantsearch.js/commit/0dc42d2)) +* **connector:** numericRefinementList connector ([918d971](https://github.com/algolia/instantsearch.js/commit/918d971)) +* **connector:** pagination connector ([7a876f3](https://github.com/algolia/instantsearch.js/commit/7a876f3)) +* **connector:** price ranges connector ([d8bed96](https://github.com/algolia/instantsearch.js/commit/d8bed96)) +* **connector:** provide consistent interface for searchbox renderer ([17d8301](https://github.com/algolia/instantsearch.js/commit/17d8301)) +* **connector:** provide instantsearch instance at render ([12a7935](https://github.com/algolia/instantsearch.js/commit/12a7935)) +* **connector:** refactor search function ([618dca2](https://github.com/algolia/instantsearch.js/commit/618dca2)) +* **connector:** refinement list connector ([c8fcf4e](https://github.com/algolia/instantsearch.js/commit/c8fcf4e)) +* **connector:** remove legacy implementation of toggle ([04437b0](https://github.com/algolia/instantsearch.js/commit/04437b0)) +* **connector:** remove non relevant instantsearch API from test ([c5dce5c](https://github.com/algolia/instantsearch.js/commit/c5dce5c)) +* **connector:** remove unused parameter to searchbox connector ([e639f65](https://github.com/algolia/instantsearch.js/commit/e639f65)) +* **connector:** searchbox connector ([70f8e1f](https://github.com/algolia/instantsearch.js/commit/70f8e1f)) +* **connector:** small internal refactoring for SFFV ([cb5c1fa](https://github.com/algolia/instantsearch.js/commit/cb5c1fa)) +* **connector:** sort by selector connector ([b9847cf](https://github.com/algolia/instantsearch.js/commit/b9847cf)) +* **connector:** star rating connector ([9996b4d](https://github.com/algolia/instantsearch.js/commit/9996b4d)) +* **connector:** stats connector ([680743b](https://github.com/algolia/instantsearch.js/commit/680743b)) +* **connector:** test connectHits ([89c86a5](https://github.com/algolia/instantsearch.js/commit/89c86a5)) +* **connector:** test connectHitsPerPageSelector ([9caab02](https://github.com/algolia/instantsearch.js/commit/9caab02)) +* **connector:** test connectInfiniteHits ([e67e75e](https://github.com/algolia/instantsearch.js/commit/e67e75e)) +* **connector:** test connectMenu ([03c6f11](https://github.com/algolia/instantsearch.js/commit/03c6f11)) +* **connector:** test connectNumericRefinementList ([2f26251](https://github.com/algolia/instantsearch.js/commit/2f26251)) +* **connector:** test connectNumericSelector ([182779b](https://github.com/algolia/instantsearch.js/commit/182779b)) +* **connector:** test connectPagination ([6f125b7](https://github.com/algolia/instantsearch.js/commit/6f125b7)) +* **connector:** test connectPriceRanges ([f5dfba7](https://github.com/algolia/instantsearch.js/commit/f5dfba7)) +* **connector:** test connectRangeSlider ([4f6c180](https://github.com/algolia/instantsearch.js/commit/4f6c180)) +* **connector:** test connectSearchBox ([b4d7e1b](https://github.com/algolia/instantsearch.js/commit/b4d7e1b)) +* **connector:** test connectSortBySelector ([e8825df](https://github.com/algolia/instantsearch.js/commit/e8825df)) +* **connector:** test connectStarRating ([0c16f15](https://github.com/algolia/instantsearch.js/commit/0c16f15)), closes [#2002](https://github.com/algolia/instantsearch.js/issues/2002) +* **connector:** test connectStats ([c992288](https://github.com/algolia/instantsearch.js/commit/c992288)) +* **connector:** test connectToggle ([441293d](https://github.com/algolia/instantsearch.js/commit/441293d)) +* **connector:** toggle connector ([bf9a9c0](https://github.com/algolia/instantsearch.js/commit/bf9a9c0)) +* **connector:** update doc, move setValue to refine in SortBySelector ([2486f36](https://github.com/algolia/instantsearch.js/commit/2486f36)) +* **connector:** update jsDoc descriptions ([f83022a](https://github.com/algolia/instantsearch.js/commit/f83022a)) +* **connectors:** `refinement-list` widget (iteration2) ([1c6c3a5](https://github.com/algolia/instantsearch.js/commit/1c6c3a5)) +* **connectors:** `setValue()` -> `refine()` / `currentValue` -> `currentRefinement` ([ec7806c](https://github.com/algolia/instantsearch.js/commit/ec7806c)) +* **connectors:** `sortBy` to `['isRefined', 'count:desc']` ([01219f1](https://github.com/algolia/instantsearch.js/commit/01219f1)) +* **connectors:** add `currentRefinement` on `hierarchical-menu` ([154cdb5](https://github.com/algolia/instantsearch.js/commit/154cdb5)) +* **connectors:** connectPagination (iteration2) ([8a615f6](https://github.com/algolia/instantsearch.js/commit/8a615f6)) +* **connectors:** connectPriceRanges (iteration2) ([e34968e](https://github.com/algolia/instantsearch.js/commit/e34968e)) +* **connectors:** connectRangeSlider (iteration2) ([6073d94](https://github.com/algolia/instantsearch.js/commit/6073d94)) +* **connectors:** connectSearchBox (iteration2) ([3161c9b](https://github.com/algolia/instantsearch.js/commit/3161c9b)) +* **connectors:** connectSortBySelector (iteration 2) ([dec2d31](https://github.com/algolia/instantsearch.js/commit/dec2d31)) +* **connectors:** connectStarRating (iteration2) ([7ef7b6b](https://github.com/algolia/instantsearch.js/commit/7ef7b6b)) +* **connectors:** connectToggle, forward initial options to render ([704a455](https://github.com/algolia/instantsearch.js/commit/704a455)) +* **connectors:** dissociate logic & view for `menu` widget ([5a02c88](https://github.com/algolia/instantsearch.js/commit/5a02c88)) +* **connectors:** expose connectors on `instantsearch` instance ([ff799d0](https://github.com/algolia/instantsearch.js/commit/ff799d0)) +* **connectors:** forward `widgetParams` to `renderFn` ([54222a3](https://github.com/algolia/instantsearch.js/commit/54222a3)) +* **connectors:** jsDoc connectHitsPerPageSelector ([75243b0](https://github.com/algolia/instantsearch.js/commit/75243b0)) +* **connectors:** provide `currentRefinement` on menu ([fb7bc5e](https://github.com/algolia/instantsearch.js/commit/fb7bc5e)) +* **connectors:** provide `currentRefinement` on numeric refinement list ([91f7928](https://github.com/algolia/instantsearch.js/commit/91f7928)) +* **connectors.numeric-selector:** `currentValue` -> `currentRefinement` / `setValue()` -> `refine()` ([998faf1](https://github.com/algolia/instantsearch.js/commit/998faf1)) +* **connectors.price-ranges:** provides `currentRefiment` value ([39af437](https://github.com/algolia/instantsearch.js/commit/39af437)) +* **connectors.refinement-list:** provide `currentRefinement` to `renderFn` ([7e86be3](https://github.com/algolia/instantsearch.js/commit/7e86be3)) +* **connectors.star-rating:** provide `currentRefinement` value ([c08b3e4](https://github.com/algolia/instantsearch.js/commit/c08b3e4)) +* **connectRefinementList:** first good iteration ([88fd6d5](https://github.com/algolia/instantsearch.js/commit/88fd6d5)) +* **doc:** re-bootstrap doc based on instantsearch-android ([e4e816e](https://github.com/algolia/instantsearch.js/commit/e4e816e)) +* **docs:** bootstrap v2 docs ([0db6caf](https://github.com/algolia/instantsearch.js/commit/0db6caf)) +* **docs:** pages structure ([fe89dcf](https://github.com/algolia/instantsearch.js/commit/fe89dcf)) +* **getting-started:** add `.zip` boilerplate ([7d3769c](https://github.com/algolia/instantsearch.js/commit/7d3769c)) +* **getting-started:** add result example of guide ([78d9017](https://github.com/algolia/instantsearch.js/commit/78d9017)) +* **live-example:** add support of connectors ([e4f3158](https://github.com/algolia/instantsearch.js/commit/e4f3158)) +* **live-example:** include jquery on connectors example pages ([f32936f](https://github.com/algolia/instantsearch.js/commit/f32936f)) +* **main:** export all the widgets at once ([4bc2d21](https://github.com/algolia/instantsearch.js/commit/4bc2d21)) +* **numeric-refinement-list:** `facetValues` -> `items` / `toggleRefinement` -> `refine` ([eb2c993](https://github.com/algolia/instantsearch.js/commit/eb2c993)) +* **pagination:** `setPage()` -> `refine()` / `currentPage` -> `currentRefinement` ([f783fea](https://github.com/algolia/instantsearch.js/commit/f783fea)) +* **range-slider:** use `rheostat` as slider component (#2142) ([910a0a0](https://github.com/algolia/instantsearch.js/commit/910a0a0)) +* **searchFunction:** Update API, fix #1924 ([c7beb1d](https://github.com/algolia/instantsearch.js/commit/c7beb1d)), closes [#1924](https://github.com/algolia/instantsearch.js/issues/1924) +* **sort-by-selector:** `currentValue` -> `currentRefinement` ([e94c8c7](https://github.com/algolia/instantsearch.js/commit/e94c8c7)) +* **Template:** remove support for react element ([ca2ab44](https://github.com/algolia/instantsearch.js/commit/ca2ab44)) diff --git a/js/instantsearch.js/README.md b/js/instantsearch.js/README.md index ef12f31d..442121e8 100644 --- a/js/instantsearch.js/README.md +++ b/js/instantsearch.js/README.md @@ -1,36 +1,174 @@ +

+ + InstantSearch.js + + +

+ InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia. +

+

+ +--- + +[![Version][version-svg]][package-url] +[![License][license-image]][license-url] +[![Build Status][ci-svg]][ci-url] +[![Pull reminders][pull-reminders-svg]][pull-reminders-url] + +InstantSearch.js is a vanilla JavaScript library that lets you create an instant-search result experience using [Algolia][algolia-website]’s search API. It is part of the InstantSearch family: + +**InstantSearch.js** | [React InstantSearch][react-instantsearch-github] | [Vue InstantSearch][vue-instantsearch-github] | [Angular InstantSearch][instantsearch-angular-github] | [React InstantSearch Native][react-instantsearch-github] | [InstantSearch Android][instantsearch-android-github] | [InstantSearch iOS][instantsearch-ios-github] + +
+ Table of contents + -**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [InstantSearch.js](#instantsearchjs) + +- [Why](#why) +- [Getting started](#getting-started) +- [Installation](#installation) - [Documentation](#documentation) -- [Contributing, dev, release](#contributing-dev-release) +- [Demos](#demos) +- [Playground](#playground) +- [Browser support](#browser-support) +- [Troubleshooting](#troubleshooting) +- [Contributing](#contributing) +- [License](#license) -[![InstantSearch.js logo][logo]][website] +
+ +## Why + +You should be using InstantSearch if you want to: -InstantSearch projects: **InstantSearch.js** | [React InstantSearch][react-instantsearch-github] | [InstantSearch Android][instantsearch-android-github]. +- Design search experiences with best practices +- Customize your components at will +- Remain independent from external frameworks -## InstantSearch.js +## Getting started -> ⚡ Lightning-fast search for your apps +Using InstantSearch.js is as simple as adding this JavaScript code to your page: -Built by [Algolia][algolia-website]. +```javascript +// 1. Instantiate the search +const search = instantsearch({ + indexName: 'instant_search', + searchClient: algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76'), +}); -This repository holds the code for the InstantSearch.js project. +search.addWidgets([ + // 2. Create an interactive search box + instantsearch.widgets.searchBox({ + container: '#searchbox', + placeholder: 'Search for products', + }), + + // 3. Plug the search results into the product container + instantsearch.widgets.hits({ + container: '#products', + templates: { + item: '{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}', + }, + }), + + // 4. Make the brands refinable + instantsearch.widgets.refinementList({ + container: '#brand', + attribute: 'brand', + }), +]); + +// 5. Start the search! +search.start(); +``` + +

+ + Edit on CodeSandbox + +

+ +To learn more about the library, follow the [getting started](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/) guide or check how to [add it to your own project](https://www.algolia.com/doc/guides/building-search-ui/installation/js/). + +## Installation + +```sh +npm install instantsearch.js algoliasearch +# or +yarn add instantsearch.js algoliasearch +``` ## Documentation -There's a dedicated documentation available at . +The documentation is available on the [Algolia website](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/). + +## Demos + +| E-commerce | Media | Travel | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| E-commerce demo preview | Media demo preview | Tourism demo preview | + +See more demos [on the website](https://www.algolia.com/doc/guides/building-search-ui/resources/demos/js/). + +## Playground + +You can get to know InstantSearch.js on [this playground](https://codesandbox.io/s/github/algolia/create-instantsearch-app/tree/templates/instantsearch.js). + +Start by [adding widgets](https://www.algolia.com/doc/guides/building-search-ui/widgets/showcase/js/) and tweaking the display. Once you feel familiar with the library, we recommend following the [getting started guide](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/). + +## Browser support + +We support the **last two versions of major browsers** (Chrome, Edge, Firefox, Safari). + +Please refer to the [browser support](https://www.algolia.com/doc/guides/building-search-ui/installation/js/#browser-support) section in the documentation to use InstantSearch.js on other browsers. + +## Troubleshooting + +Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/guides/building-search-ui/troubleshooting/faq/js/) where you will find answers for the most common issues and gotchas with the library. + +## Contributing + +We welcome all contributors, from casual to regular 💙 + +- **Bug report**. Is something not working as expected? [Send a bug report](https://github.com/algolia/instantsearch.js/issues/new?template=Bug_report.md). +- **Feature request**. Would you like to add something to the library? [Send a feature request](https://github.com/algolia/instantsearch.js/issues/new?template=Feature_request.md). +- **Documentation**. Did you find a typo in the doc? [Open an issue](https://github.com/algolia/instantsearch.js/issues/new) and we'll take care of it. +- **Development**. If you don't know where to start, you can check the open issues that are [tagged easy](https://github.com/algolia/instantsearch.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22Difficulty%3A++++++%E2%9D%84%EF%B8%8F+easy%22), the [bugs](https://github.com/algolia/instantsearch.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22%E2%9D%A4+Bug%22) or [chores](https://github.com/algolia/instantsearch.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22%E2%9C%A8+Chore%22). + +To start contributing to code, you need to: + +1. [Fork the project](https://help.github.com/articles/fork-a-repo/) +1. [Clone the repository](https://help.github.com/articles/cloning-a-repository/) +1. Install the dependencies: `yarn` +1. Run the development mode: `yarn start` +1. [Open the stories](http://localhost:6006) + +Please read [our contribution process](CONTRIBUTING.md) to learn more. + +## License + +InstantSearch.js is [MIT licensed][license-url]. + + -## Contributing, dev, release +[version-svg]: https://img.shields.io/npm/v/instantsearch.js.svg?style=flat-square +[package-url]: https://npmjs.org/package/instantsearch.js +[ci-svg]: https://img.shields.io/circleci/project/github/algolia/instantsearch.js.svg?style=flat-square +[ci-url]: https://circleci.com/gh/algolia/instantsearch.js +[pull-reminders-svg]: https://img.shields.io/badge/pull%20reminders-✓-success.svg?style=flat-square +[pull-reminders-url]: https://pullreminders.com?ref=badge +[license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square +[license-url]: LICENSE -We welcome all contributors, from casual to regular. You are only -one command away to start the developer environment, [read our CONTRIBUTING guide](CONTRIBUTING.md). + -[logo]: ./docs/readme-logo.png -[website]: https://community.algolia.com/instantsearch.js -[algolia-website]: https://www.algolia.com/ +[algolia-website]: https://www.algolia.com/?utm_source=instantsearch.js&utm_campaign=repository [react-instantsearch-github]: https://github.com/algolia/react-instantsearch/ +[vue-instantsearch-github]: https://github.com/algolia/vue-instantsearch [instantsearch-android-github]: https://github.com/algolia/instantsearch-android +[instantsearch-ios-github]: https://github.com/algolia/instantsearch-ios +[instantsearch-angular-github]: https://github.com/algolia/angular-instantsearch diff --git a/js/instantsearch.js/cjs/components/Answers/Answers.js b/js/instantsearch.js/cjs/components/Answers/Answers.js new file mode 100644 index 00000000..fea1ae4b --- /dev/null +++ b/js/instantsearch.js/cjs/components/Answers/Answers.js @@ -0,0 +1,63 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +var Answers = function Answers(_ref) { + var hits = _ref.hits, + isLoading = _ref.isLoading, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps; + return (0, _preact.h)("div", { + className: (0, _classnames.default)(cssClasses.root, _defineProperty({}, cssClasses.emptyRoot, hits.length === 0)) + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "header", + rootProps: { + className: cssClasses.header + }, + data: { + hits: hits, + isLoading: isLoading + } + })), isLoading ? (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "loader", + rootProps: { + className: cssClasses.loader + } + })) : (0, _preact.h)("ul", { + className: cssClasses.list + }, hits.map(function (hit, position) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "item", + rootTagName: "li", + rootProps: { + className: cssClasses.item + }, + key: hit.objectID, + data: _objectSpread(_objectSpread({}, hit), {}, { + __hitIndex: position + }) + })); + }))); +}; + +var _default = Answers; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Breadcrumb/Breadcrumb.js b/js/instantsearch.js/cjs/components/Breadcrumb/Breadcrumb.js new file mode 100644 index 00000000..9e23f6ab --- /dev/null +++ b/js/instantsearch.js/cjs/components/Breadcrumb/Breadcrumb.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +var Breadcrumb = function Breadcrumb(_ref) { + var items = _ref.items, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps, + createURL = _ref.createURL, + refine = _ref.refine; + return (0, _preact.h)("div", { + className: (0, _classnames.default)(cssClasses.root, _defineProperty({}, cssClasses.noRefinementRoot, items.length === 0)) + }, (0, _preact.h)("ul", { + className: cssClasses.list + }, (0, _preact.h)("li", { + className: (0, _classnames.default)(cssClasses.item, _defineProperty({}, cssClasses.selectedItem, items.length === 0)) + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "home", + rootTagName: "a", + rootProps: { + className: cssClasses.link, + href: createURL(undefined), + onClick: function onClick(event) { + event.preventDefault(); + refine(undefined); + } + } + }))), items.map(function (item, idx) { + var isLast = idx === items.length - 1; + return (0, _preact.h)("li", { + key: item.label + idx, + className: (0, _classnames.default)(cssClasses.item, _defineProperty({}, cssClasses.selectedItem, isLast)) + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "separator", + rootTagName: "span", + rootProps: { + className: cssClasses.separator, + 'aria-hidden': true + } + })), isLast ? item.label : (0, _preact.h)("a", { + className: cssClasses.link, + href: createURL(item.value), + onClick: function onClick(event) { + event.preventDefault(); + refine(item.value); + } + }, item.label)); + }))); +}; + +var _default = Breadcrumb; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/ClearRefinements/ClearRefinements.js b/js/instantsearch.js/cjs/components/ClearRefinements/ClearRefinements.js new file mode 100644 index 00000000..a6f1d4df --- /dev/null +++ b/js/instantsearch.js/cjs/components/ClearRefinements/ClearRefinements.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +var ClearRefinements = function ClearRefinements(_ref) { + var hasRefinements = _ref.hasRefinements, + refine = _ref.refine, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "resetLabel", + rootTagName: "button", + rootProps: { + className: (0, _classnames.default)(cssClasses.button, _defineProperty({}, cssClasses.disabledButton, !hasRefinements)), + onClick: refine, + disabled: !hasRefinements + }, + data: { + hasRefinements: hasRefinements + } + }))); +}; + +var _default = ClearRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/CurrentRefinements/CurrentRefinements.js b/js/instantsearch.js/cjs/components/CurrentRefinements/CurrentRefinements.js new file mode 100644 index 00000000..a269d8b7 --- /dev/null +++ b/js/instantsearch.js/cjs/components/CurrentRefinements/CurrentRefinements.js @@ -0,0 +1,62 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _utils = require("../../lib/utils"); + +/** @jsx h */ +var createItemKey = function createItemKey(_ref) { + var attribute = _ref.attribute, + value = _ref.value, + type = _ref.type, + operator = _ref.operator; + return [attribute, type, value, operator].map(function (key) { + return key; + }).filter(Boolean).join(':'); +}; + +var handleClick = function handleClick(callback) { + return function (event) { + if ((0, _utils.isSpecialClick)(event)) { + return; + } + + event.preventDefault(); + callback(); + }; +}; + +var CurrentRefinements = function CurrentRefinements(_ref2) { + var items = _ref2.items, + cssClasses = _ref2.cssClasses; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)("ul", { + className: cssClasses.list + }, items.map(function (item, index) { + return (0, _preact.h)("li", { + key: "".concat(item.indexName, "-").concat(item.attribute, "-").concat(index), + className: cssClasses.item + }, (0, _preact.h)("span", { + className: cssClasses.label + }, (0, _utils.capitalize)(item.label), ":"), item.refinements.map(function (refinement) { + return (0, _preact.h)("span", { + key: createItemKey(refinement), + className: cssClasses.category + }, (0, _preact.h)("span", { + className: cssClasses.categoryLabel + }, refinement.attribute === 'query' ? (0, _preact.h)("q", null, refinement.label) : refinement.label), (0, _preact.h)("button", { + className: cssClasses.delete, + onClick: handleClick(item.refine.bind(null, refinement)) + }, "\u2715")); + })); + }))); +}; + +var _default = CurrentRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchButton.js b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchButton.js new file mode 100644 index 00000000..c85a2ca6 --- /dev/null +++ b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchButton.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +/** @jsx h */ +var GeoSearchButton = function GeoSearchButton(_ref) { + var className = _ref.className, + _ref$disabled = _ref.disabled, + disabled = _ref$disabled === void 0 ? false : _ref$disabled, + onClick = _ref.onClick, + children = _ref.children; + return (0, _preact.h)("button", { + className: className, + onClick: onClick, + disabled: disabled + }, children); +}; + +var _default = GeoSearchButton; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchControls.js b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchControls.js new file mode 100644 index 00000000..72815d1a --- /dev/null +++ b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchControls.js @@ -0,0 +1,72 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +var _GeoSearchButton = _interopRequireDefault(require("./GeoSearchButton")); + +var _GeoSearchToggle = _interopRequireDefault(require("./GeoSearchToggle")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +var GeoSearchControls = function GeoSearchControls(_ref) { + var cssClasses = _ref.cssClasses, + enableRefine = _ref.enableRefine, + enableRefineControl = _ref.enableRefineControl, + enableClearMapRefinement = _ref.enableClearMapRefinement, + isRefineOnMapMove = _ref.isRefineOnMapMove, + isRefinedWithMap = _ref.isRefinedWithMap, + hasMapMoveSinceLastRefine = _ref.hasMapMoveSinceLastRefine, + onRefineToggle = _ref.onRefineToggle, + onRefineClick = _ref.onRefineClick, + onClearClick = _ref.onClearClick, + templateProps = _ref.templateProps; + return (0, _preact.h)(_preact.Fragment, null, enableRefine && (0, _preact.h)("div", null, enableRefineControl && (0, _preact.h)("div", { + className: cssClasses.control + }, isRefineOnMapMove || !hasMapMoveSinceLastRefine ? (0, _preact.h)(_GeoSearchToggle.default, { + classNameLabel: (0, _classnames.default)(cssClasses.label, _defineProperty({}, cssClasses.selectedLabel, isRefineOnMapMove)), + classNameInput: cssClasses.input, + checked: isRefineOnMapMove, + onToggle: onRefineToggle + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "toggle", + rootTagName: "span" + }))) : (0, _preact.h)(_GeoSearchButton.default, { + className: cssClasses.redo, + disabled: !hasMapMoveSinceLastRefine, + onClick: onRefineClick + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "redo", + rootTagName: "span" + })))), !enableRefineControl && !isRefineOnMapMove && (0, _preact.h)("div", { + className: cssClasses.control + }, (0, _preact.h)(_GeoSearchButton.default, { + className: (0, _classnames.default)(cssClasses.redo, _defineProperty({}, cssClasses.disabledRedo, !hasMapMoveSinceLastRefine)), + disabled: !hasMapMoveSinceLastRefine, + onClick: onRefineClick + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "redo", + rootTagName: "span" + })))), enableClearMapRefinement && isRefinedWithMap && (0, _preact.h)(_GeoSearchButton.default, { + className: cssClasses.reset, + onClick: onClearClick + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "reset", + rootTagName: "span" + }))))); +}; + +var _default = GeoSearchControls; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchToggle.js b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchToggle.js new file mode 100644 index 00000000..6aff622f --- /dev/null +++ b/js/instantsearch.js/cjs/components/GeoSearchControls/GeoSearchToggle.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +/** @jsx h */ +var GeoSearchToggle = function GeoSearchToggle(_ref) { + var classNameLabel = _ref.classNameLabel, + classNameInput = _ref.classNameInput, + checked = _ref.checked, + onToggle = _ref.onToggle, + children = _ref.children; + return (0, _preact.h)("label", { + className: classNameLabel + }, (0, _preact.h)("input", { + className: classNameInput, + type: "checkbox", + checked: checked, + onChange: onToggle + }), children); +}; + +var _default = GeoSearchToggle; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Hits/Hits.js b/js/instantsearch.js/cjs/components/Hits/Hits.js new file mode 100644 index 00000000..328da5ad --- /dev/null +++ b/js/instantsearch.js/cjs/components/Hits/Hits.js @@ -0,0 +1,68 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +var Hits = function Hits(_ref) { + var results = _ref.results, + hits = _ref.hits, + bindEvent = _ref.bindEvent, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps; + + if (results.hits.length === 0) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "empty", + rootProps: { + className: (0, _classnames.default)(cssClasses.root, cssClasses.emptyRoot) + }, + data: results + })); + } + + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)("ol", { + className: cssClasses.list + }, hits.map(function (hit, index) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "item", + rootTagName: "li", + rootProps: { + className: cssClasses.item + }, + key: hit.objectID, + data: _objectSpread(_objectSpread({}, hit), {}, { + __hitIndex: index + }), + bindEvent: bindEvent + })); + }))); +}; + +Hits.defaultProps = { + results: { + hits: [] + }, + hits: [] +}; +var _default = Hits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/InfiniteHits/InfiniteHits.js b/js/instantsearch.js/cjs/components/InfiniteHits/InfiniteHits.js new file mode 100644 index 00000000..5017d8a7 --- /dev/null +++ b/js/instantsearch.js/cjs/components/InfiniteHits/InfiniteHits.js @@ -0,0 +1,83 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +var InfiniteHits = function InfiniteHits(_ref) { + var results = _ref.results, + hits = _ref.hits, + bindEvent = _ref.bindEvent, + hasShowPrevious = _ref.hasShowPrevious, + showPrevious = _ref.showPrevious, + showMore = _ref.showMore, + isFirstPage = _ref.isFirstPage, + isLastPage = _ref.isLastPage, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps; + + if (results.hits.length === 0) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "empty", + rootProps: { + className: (0, _classnames.default)(cssClasses.root, cssClasses.emptyRoot) + }, + data: results + })); + } + + return (0, _preact.h)("div", { + className: cssClasses.root + }, hasShowPrevious && (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "showPreviousText", + rootTagName: "button", + rootProps: { + className: (0, _classnames.default)(cssClasses.loadPrevious, _defineProperty({}, cssClasses.disabledLoadPrevious, isFirstPage)), + disabled: isFirstPage, + onClick: showPrevious + } + })), (0, _preact.h)("ol", { + className: cssClasses.list + }, hits.map(function (hit, position) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "item", + rootTagName: "li", + rootProps: { + className: cssClasses.item + }, + key: hit.objectID, + data: _objectSpread(_objectSpread({}, hit), {}, { + __hitIndex: position + }), + bindEvent: bindEvent + })); + })), (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "showMoreText", + rootTagName: "button", + rootProps: { + className: (0, _classnames.default)(cssClasses.loadMore, _defineProperty({}, cssClasses.disabledLoadMore, isLastPage)), + disabled: isLastPage, + onClick: showMore + } + }))); +}; + +var _default = InfiniteHits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/MenuSelect/MenuSelect.js b/js/instantsearch.js/cjs/components/MenuSelect/MenuSelect.js new file mode 100644 index 00000000..4dc6560c --- /dev/null +++ b/js/instantsearch.js/cjs/components/MenuSelect/MenuSelect.js @@ -0,0 +1,65 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +function MenuSelect(_ref) { + var cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps, + items = _ref.items, + refine = _ref.refine; + + var _ref2 = (0, _utils.find)(items, function (item) { + return item.isRefined; + }) || { + value: '' + }, + selectedValue = _ref2.value; + + return (0, _preact.h)("div", { + className: (0, _classnames.default)(cssClasses.root, _defineProperty({}, cssClasses.noRefinementRoot, items.length === 0)) + }, (0, _preact.h)("select", { + className: cssClasses.select, + value: selectedValue, + onChange: function onChange(event) { + refine(event.target.value); + } + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "defaultOption", + rootTagName: "option", + rootProps: { + value: '', + className: cssClasses.option + } + })), items.map(function (item) { + return (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "item", + rootTagName: "option", + rootProps: { + value: item.value, + className: cssClasses.option + }, + key: item.value, + data: item + })); + }))); +} + +var _default = MenuSelect; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Pagination/Pagination.js b/js/instantsearch.js/cjs/components/Pagination/Pagination.js new file mode 100644 index 00000000..087034f6 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Pagination/Pagination.js @@ -0,0 +1,189 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _PaginationLink = _interopRequireDefault(require("./PaginationLink")); + +var _utils = require("../../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var defaultProps = { + currentPage: 0, + nbPages: 0, + pages: [] +}; + +var Pagination = /*#__PURE__*/function (_Component) { + _inherits(Pagination, _Component); + + var _super = _createSuper(Pagination); + + function Pagination() { + var _this; + + _classCallCheck(this, Pagination); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "handleClick", function (pageNumber, event) { + if ((0, _utils.isSpecialClick)(event)) { + // do not alter the default browser behavior + // if one special key is down + return; + } + + event.preventDefault(); + + _this.props.setCurrentPage(pageNumber); + }); + + _defineProperty(_assertThisInitialized(_this), "previousPageLink", function () { + return _this.pageLink({ + ariaLabel: 'Previous', + additionalClassName: _this.props.cssClasses.previousPageItem, + isDisabled: _this.props.isFirstPage, + label: _this.props.templates.previous, + pageNumber: _this.props.currentPage - 1, + createURL: _this.props.createURL + }); + }); + + _defineProperty(_assertThisInitialized(_this), "nextPageLink", function () { + return _this.pageLink({ + ariaLabel: 'Next', + additionalClassName: _this.props.cssClasses.nextPageItem, + isDisabled: _this.props.isLastPage, + label: _this.props.templates.next, + pageNumber: _this.props.currentPage + 1, + createURL: _this.props.createURL + }); + }); + + _defineProperty(_assertThisInitialized(_this), "firstPageLink", function () { + return _this.pageLink({ + ariaLabel: 'First', + additionalClassName: _this.props.cssClasses.firstPageItem, + isDisabled: _this.props.isFirstPage, + label: _this.props.templates.first, + pageNumber: 0, + createURL: _this.props.createURL + }); + }); + + _defineProperty(_assertThisInitialized(_this), "lastPageLink", function () { + return _this.pageLink({ + ariaLabel: 'Last', + additionalClassName: _this.props.cssClasses.lastPageItem, + isDisabled: _this.props.isLastPage, + label: _this.props.templates.last, + pageNumber: _this.props.nbPages - 1, + createURL: _this.props.createURL + }); + }); + + _defineProperty(_assertThisInitialized(_this), "pages", function () { + return _this.props.pages.map(function (pageNumber) { + return _this.pageLink({ + ariaLabel: "".concat(pageNumber + 1), + additionalClassName: _this.props.cssClasses.pageItem, + isSelected: pageNumber === _this.props.currentPage, + label: "".concat(pageNumber + 1), + pageNumber: pageNumber, + createURL: _this.props.createURL + }); + }); + }); + + return _this; + } + + _createClass(Pagination, [{ + key: "pageLink", + value: function pageLink(_ref) { + var label = _ref.label, + ariaLabel = _ref.ariaLabel, + pageNumber = _ref.pageNumber, + _ref$additionalClassN = _ref.additionalClassName, + additionalClassName = _ref$additionalClassN === void 0 ? null : _ref$additionalClassN, + _ref$isDisabled = _ref.isDisabled, + isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled, + _ref$isSelected = _ref.isSelected, + isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected, + createURL = _ref.createURL; + var cssClasses = { + item: (0, _classnames.default)(this.props.cssClasses.item, additionalClassName), + link: this.props.cssClasses.link + }; + + if (isDisabled) { + cssClasses.item = (0, _classnames.default)(cssClasses.item, this.props.cssClasses.disabledItem); + } else if (isSelected) { + cssClasses.item = (0, _classnames.default)(cssClasses.item, this.props.cssClasses.selectedItem); + } + + var url = !isDisabled ? createURL(pageNumber) : '#'; + return (0, _preact.h)(_PaginationLink.default, { + ariaLabel: ariaLabel, + cssClasses: cssClasses, + handleClick: this.handleClick, + isDisabled: isDisabled, + key: label + pageNumber + ariaLabel, + label: label, + pageNumber: pageNumber, + url: url + }); + } + }, { + key: "render", + value: function render() { + return (0, _preact.h)("div", { + className: (0, _classnames.default)(this.props.cssClasses.root, _defineProperty({}, this.props.cssClasses.noRefinementRoot, this.props.nbPages <= 1)) + }, (0, _preact.h)("ul", { + className: this.props.cssClasses.list + }, this.props.showFirst && this.firstPageLink(), this.props.showPrevious && this.previousPageLink(), this.pages(), this.props.showNext && this.nextPageLink(), this.props.showLast && this.lastPageLink())); + } + }]); + + return Pagination; +}(_preact.Component); + +_defineProperty(Pagination, "defaultProps", defaultProps); + +var _default = Pagination; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Pagination/PaginationLink.js b/js/instantsearch.js/cjs/components/Pagination/PaginationLink.js new file mode 100644 index 00000000..ef43734f --- /dev/null +++ b/js/instantsearch.js/cjs/components/Pagination/PaginationLink.js @@ -0,0 +1,47 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +/** @jsx h */ +var PaginationLink = function PaginationLink(_ref) { + var cssClasses = _ref.cssClasses, + label = _ref.label, + ariaLabel = _ref.ariaLabel, + url = _ref.url, + isDisabled = _ref.isDisabled, + handleClick = _ref.handleClick, + pageNumber = _ref.pageNumber; + + if (isDisabled) { + return (0, _preact.h)("li", { + className: cssClasses.item + }, (0, _preact.h)("span", { + className: cssClasses.link, + dangerouslySetInnerHTML: { + __html: label + } + })); + } + + return (0, _preact.h)("li", { + className: cssClasses.item + }, (0, _preact.h)("a", { + className: cssClasses.link, + "aria-label": ariaLabel, + href: url, + onClick: function onClick(event) { + return handleClick(pageNumber, event); + }, + dangerouslySetInnerHTML: { + __html: label + } + })); +}; + +var _default = PaginationLink; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Panel/Panel.js b/js/instantsearch.js/cjs/components/Panel/Panel.js new file mode 100644 index 00000000..81305645 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Panel/Panel.js @@ -0,0 +1,102 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _hooks = require("preact/hooks"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function Panel(props) { + var _cx; + + var _useState = (0, _hooks.useState)(props.isCollapsed), + _useState2 = _slicedToArray(_useState, 2), + isCollapsed = _useState2[0], + setIsCollapsed = _useState2[1]; + + var _useState3 = (0, _hooks.useState)(false), + _useState4 = _slicedToArray(_useState3, 2), + isControlled = _useState4[0], + setIsControlled = _useState4[1]; + + var bodyRef = (0, _hooks.useRef)(null); + (0, _hooks.useEffect)(function () { + if (!bodyRef.current) { + return undefined; + } + + bodyRef.current.appendChild(props.bodyElement); + return function () { + bodyRef.current.removeChild(props.bodyElement); + }; + }, [bodyRef, props.bodyElement]); + + if (!isControlled && props.isCollapsed !== isCollapsed) { + setIsCollapsed(props.isCollapsed); + } + + return (0, _preact.h)("div", { + className: (0, _classnames.default)(props.cssClasses.root, (_cx = {}, _defineProperty(_cx, props.cssClasses.noRefinementRoot, props.hidden), _defineProperty(_cx, props.cssClasses.collapsibleRoot, props.collapsible), _defineProperty(_cx, props.cssClasses.collapsedRoot, isCollapsed), _cx)), + hidden: props.hidden + }, props.templates.header && (0, _preact.h)("div", { + className: props.cssClasses.header + }, (0, _preact.h)(_Template.default, { + templates: props.templates, + templateKey: "header", + rootTagName: "span", + data: props.data + }), props.collapsible && (0, _preact.h)("button", { + className: props.cssClasses.collapseButton, + "aria-expanded": !isCollapsed, + onClick: function onClick(event) { + event.preventDefault(); + setIsControlled(true); + setIsCollapsed(function (prevIsCollapsed) { + return !prevIsCollapsed; + }); + } + }, (0, _preact.h)(_Template.default, { + templates: props.templates, + templateKey: "collapseButtonText", + rootTagName: "span", + data: { + collapsed: isCollapsed + } + }))), (0, _preact.h)("div", { + className: props.cssClasses.body, + ref: bodyRef + }), props.templates.footer && (0, _preact.h)(_Template.default, { + templates: props.templates, + templateKey: "footer", + rootProps: { + className: props.cssClasses.footer + }, + data: props.data + })); +} + +var _default = Panel; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/PoweredBy/PoweredBy.js b/js/instantsearch.js/cjs/components/PoweredBy/PoweredBy.js new file mode 100644 index 00000000..c426c2f8 --- /dev/null +++ b/js/instantsearch.js/cjs/components/PoweredBy/PoweredBy.js @@ -0,0 +1,52 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +/** @jsx h */ +var _ref2 = (0, _preact.h)("path", { + fill: "#5468FF", + d: "M78.99.94h16.6a2.97 2.97 0 012.96 2.96v16.6a2.97 2.97 0 01-2.97 2.96h-16.6a2.97 2.97 0 01-2.96-2.96V3.9A2.96 2.96 0 0179 .94" +}); + +var _ref3 = (0, _preact.h)("path", { + fill: "#FFF", + d: "M89.63 5.97v-.78a.98.98 0 00-.98-.97h-2.28a.98.98 0 00-.97.97V6c0 .09.08.15.17.13a7.13 7.13 0 013.9-.02c.08.02.16-.04.16-.13m-6.25 1L83 6.6a.98.98 0 00-1.38 0l-.46.46a.97.97 0 000 1.38l.38.39c.06.06.15.04.2-.02a7.49 7.49 0 011.63-1.62c.07-.04.08-.14.02-.2m4.16 2.45v3.34c0 .1.1.17.2.12l2.97-1.54c.06-.03.08-.12.05-.18a3.7 3.7 0 00-3.08-1.87c-.07 0-.14.06-.14.13m0 8.05a4.49 4.49 0 110-8.98 4.49 4.49 0 010 8.98m0-10.85a6.37 6.37 0 100 12.74 6.37 6.37 0 000-12.74" +}); + +var PoweredBy = function PoweredBy(_ref) { + var url = _ref.url, + theme = _ref.theme, + cssClasses = _ref.cssClasses; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)("a", { + href: url, + target: "_blank", + className: cssClasses.link, + "aria-label": "Search by Algolia", + rel: "noopener noreferrer" + }, (0, _preact.h)("svg", { + height: "1.2em", + className: cssClasses.logo, + viewBox: "0 0 168 24" // This style is necessary as long as it's not included in InstantSearch.css. + // For now, InstantSearch.css sets a maximum width of 70px. + , + style: { + width: 'auto' + } + }, (0, _preact.h)("path", { + fill: theme === 'dark' ? '#FFF' : '#5D6494', + d: "M6.97 6.68V8.3a4.47 4.47 0 00-2.42-.67 2.2 2.2 0 00-1.38.4c-.34.26-.5.6-.5 1.02 0 .43.16.77.49 1.03.33.25.83.53 1.51.83a7.04 7.04 0 011.9 1.08c.34.24.58.54.73.89.15.34.23.74.23 1.18 0 .95-.33 1.7-1 2.24a4 4 0 01-2.6.81 5.71 5.71 0 01-2.94-.68v-1.71c.84.63 1.81.94 2.92.94.58 0 1.05-.14 1.39-.4.34-.28.5-.65.5-1.13 0-.29-.1-.55-.3-.8a2.2 2.2 0 00-.65-.53 23.03 23.03 0 00-1.64-.78 13.67 13.67 0 01-1.11-.64c-.12-.1-.28-.22-.46-.4a1.72 1.72 0 01-.39-.5 4.46 4.46 0 01-.22-.6c-.07-.23-.1-.48-.1-.75 0-.91.33-1.63 1-2.17a4 4 0 012.57-.8c.97 0 1.8.18 2.47.52zm7.47 5.7v-.3a2.26 2.26 0 00-.5-1.44c-.3-.35-.74-.53-1.32-.53-.53 0-.99.2-1.37.58a2.9 2.9 0 00-.72 1.68h3.91zm1 2.79v1.4c-.6.34-1.38.51-2.36.51a4.02 4.02 0 01-3-1.13 4.04 4.04 0 01-1.11-2.97c0-1.3.34-2.32 1.02-3.06a3.38 3.38 0 012.6-1.1c1.03 0 1.85.32 2.46.96.6.64.9 1.57.9 2.78 0 .33-.03.68-.09 1.04h-5.31c.1.7.4 1.24.89 1.61.49.38 1.1.56 1.85.56.86 0 1.58-.2 2.15-.6zm6.61-1.78h-1.21c-.6 0-1.05.12-1.35.36-.3.23-.46.53-.46.89 0 .37.12.66.36.88.23.2.57.32 1.02.32.5 0 .9-.15 1.2-.43.3-.28.44-.65.44-1.1v-.92zm-4.07-2.55V9.33a4.96 4.96 0 012.5-.55c2.1 0 3.17 1.03 3.17 3.08V17H22.1v-.96c-.42.68-1.15 1.02-2.19 1.02-.76 0-1.38-.22-1.84-.66-.46-.44-.7-1-.7-1.68 0-.78.3-1.38.88-1.81.59-.43 1.4-.65 2.46-.65h1.34v-.46c0-.55-.13-.97-.4-1.25-.26-.29-.7-.43-1.32-.43-.86 0-1.65.24-2.35.72zm9.34-1.93v1.42c.39-1 1.1-1.5 2.12-1.5.15 0 .31.02.5.05v1.53c-.23-.1-.48-.14-.76-.14-.54 0-.99.24-1.34.71a2.8 2.8 0 00-.52 1.71V17h-1.57V8.91h1.57zm5 4.09a3 3 0 00.76 2.01c.47.53 1.14.8 2 .8.64 0 1.24-.18 1.8-.53v1.4c-.53.32-1.2.48-2 .48a3.98 3.98 0 01-4.17-4.18c0-1.16.38-2.15 1.14-2.98a4 4 0 013.1-1.23c.7 0 1.34.15 1.92.44v1.44a3.24 3.24 0 00-1.77-.5A2.65 2.65 0 0032.33 13zm7.92-7.28v4.58c.46-1 1.3-1.5 2.5-1.5.8 0 1.42.24 1.9.73.48.5.72 1.17.72 2.05V17H43.8v-5.1c0-.56-.14-.99-.43-1.29-.28-.3-.65-.45-1.1-.45-.54 0-1 .2-1.42.6-.4.4-.61 1.02-.61 1.85V17h-1.56V5.72h1.56zM55.2 15.74c.6 0 1.1-.25 1.5-.76.4-.5.6-1.16.6-1.95 0-.92-.2-1.62-.6-2.12-.4-.5-.92-.74-1.55-.74-.56 0-1.05.22-1.5.67-.44.45-.66 1.13-.66 2.06 0 .96.22 1.67.64 2.14.43.47.95.7 1.57.7zM53 5.72v4.42a2.74 2.74 0 012.43-1.34c1.03 0 1.86.38 2.51 1.15.65.76.97 1.78.97 3.05 0 1.13-.3 2.1-.92 2.9-.62.81-1.47 1.21-2.54 1.21s-1.9-.45-2.46-1.34V17h-1.58V5.72H53zm9.9 11.1l-3.22-7.9h1.74l1 2.62 1.26 3.42c.1-.32.48-1.46 1.15-3.42l.91-2.63h1.66l-2.92 7.87c-.78 2.07-1.96 3.1-3.56 3.1-.28 0-.53-.02-.73-.07v-1.34c.17.04.35.06.54.06 1.03 0 1.76-.57 2.17-1.7z" + }), _ref2, _ref3, (0, _preact.h)("path", { + fill: theme === 'dark' ? '#FFF' : '#5468FF', + d: "M120.92 18.8c-4.38.02-4.38-3.54-4.38-4.1V1.36l2.67-.42v13.25c0 .32 0 2.36 1.71 2.37v2.24zm-10.84-2.18c.82 0 1.43-.04 1.85-.12v-2.72a5.48 5.48 0 00-1.57-.2c-.3 0-.6.02-.9.07-.3.04-.57.12-.81.24-.24.11-.44.28-.58.49a.93.93 0 00-.22.65c0 .63.22 1 .61 1.23.4.24.94.36 1.62.36zm-.23-9.7c.88 0 1.62.11 2.23.33.6.22 1.09.53 1.44.92.36.4.61.92.76 1.48.16.56.23 1.17.23 1.85v6.87a21.69 21.69 0 01-4.68.5c-.69 0-1.32-.07-1.9-.2a4 4 0 01-1.46-.63 3.3 3.3 0 01-.96-1.13 4.3 4.3 0 01-.34-1.8 3.13 3.13 0 011.43-2.63c.45-.3.95-.5 1.54-.62a8.8 8.8 0 013.79.05v-.44c0-.3-.04-.6-.11-.87a1.78 1.78 0 00-1.1-1.22 3.2 3.2 0 00-1.15-.2 9.75 9.75 0 00-2.95.46l-.33-2.19a11.43 11.43 0 013.56-.53zm52.84 9.63c.82 0 1.43-.05 1.85-.13V13.7a5.42 5.42 0 00-1.57-.2c-.3 0-.6.02-.9.07-.3.04-.57.12-.81.24-.24.12-.44.28-.58.5a.93.93 0 00-.22.65c0 .63.22.99.61 1.23.4.24.94.36 1.62.36zm-.23-9.7c.88 0 1.63.11 2.23.33.6.22 1.1.53 1.45.92.35.39.6.92.76 1.48.15.56.23 1.18.23 1.85v6.88c-.41.08-1.03.19-1.87.31-.83.12-1.77.18-2.81.18-.7 0-1.33-.06-1.9-.2a4 4 0 01-1.47-.63c-.4-.3-.72-.67-.95-1.13a4.3 4.3 0 01-.34-1.8c0-.66.13-1.08.38-1.53.26-.45.61-.82 1.05-1.1.44-.3.95-.5 1.53-.62a8.8 8.8 0 013.8.05v-.43c0-.31-.04-.6-.12-.88-.07-.28-.2-.52-.38-.73a1.78 1.78 0 00-.73-.5c-.3-.1-.68-.2-1.14-.2a9.85 9.85 0 00-2.95.47l-.32-2.19a11.63 11.63 0 013.55-.53zm-8.03-1.27a1.62 1.62 0 000-3.24 1.62 1.62 0 100 3.24zm1.35 13.22h-2.7V7.27l2.7-.42V18.8zm-4.72 0c-4.38.02-4.38-3.54-4.38-4.1l-.01-13.34 2.67-.42v13.25c0 .32 0 2.36 1.72 2.37v2.24zm-8.7-5.9a4.7 4.7 0 00-.74-2.79 2.4 2.4 0 00-2.07-1 2.4 2.4 0 00-2.06 1 4.7 4.7 0 00-.74 2.8c0 1.16.25 1.94.74 2.62a2.4 2.4 0 002.07 1.02c.88 0 1.57-.34 2.07-1.02a4.2 4.2 0 00.73-2.63zm2.74 0a6.46 6.46 0 01-1.52 4.23c-.49.53-1.07.94-1.76 1.22-.68.29-1.73.45-2.26.45a6.6 6.6 0 01-2.25-.45 5.1 5.1 0 01-2.88-3.13 7.3 7.3 0 01-.01-4.84 5.13 5.13 0 012.9-3.1 5.67 5.67 0 012.22-.42c.81 0 1.56.14 2.24.42.69.29 1.28.69 1.75 1.22.49.52.87 1.15 1.14 1.89a7 7 0 01.43 2.5zm-20.14 0c0 1.11.25 2.36.74 2.88.5.52 1.13.78 1.91.78a4.07 4.07 0 002.12-.6V9.33c-.19-.04-.99-.2-1.76-.23a2.67 2.67 0 00-2.23 1 4.73 4.73 0 00-.78 2.8zm7.44 5.27c0 1.82-.46 3.16-1.4 4-.94.85-2.37 1.27-4.3 1.27-.7 0-2.17-.13-3.34-.4l.43-2.11c.98.2 2.27.26 2.95.26 1.08 0 1.84-.22 2.3-.66.46-.43.68-1.08.68-1.94v-.44a5.2 5.2 0 01-2.54.6 5.6 5.6 0 01-2.01-.36 4.2 4.2 0 01-2.58-2.71 9.88 9.88 0 01.02-5.35 4.92 4.92 0 012.93-2.96 6.6 6.6 0 012.43-.46 19.64 19.64 0 014.43.66v10.6z" + })))); +}; + +var _default = PoweredBy; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js b/js/instantsearch.js/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js new file mode 100644 index 00000000..4fc0b81d --- /dev/null +++ b/js/instantsearch.js/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx h */ +var QueryRuleCustomData = function QueryRuleCustomData(_ref) { + var cssClasses = _ref.cssClasses, + templates = _ref.templates, + items = _ref.items; + return (0, _preact.h)(_Template.default, { + templateKey: "default", + templates: templates, + rootProps: { + className: cssClasses.root + }, + data: { + items: items + } + }); +}; + +var _default = QueryRuleCustomData; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/RangeInput/RangeInput.js b/js/instantsearch.js/cjs/components/RangeInput/RangeInput.js new file mode 100644 index 00000000..c5bd6c71 --- /dev/null +++ b/js/instantsearch.js/cjs/components/RangeInput/RangeInput.js @@ -0,0 +1,155 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var RangeInput = /*#__PURE__*/function (_Component) { + _inherits(RangeInput, _Component); + + var _super = _createSuper(RangeInput); + + function RangeInput() { + var _this; + + _classCallCheck(this, RangeInput); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + min: _this.props.values.min, + max: _this.props.values.max + }); + + _defineProperty(_assertThisInitialized(_this), "onInput", function (key) { + return function (event) { + var _ref = event.currentTarget, + value = _ref.value; + + _this.setState(_defineProperty({}, key, Number(value))); + }; + }); + + _defineProperty(_assertThisInitialized(_this), "onSubmit", function (event) { + event.preventDefault(); + + _this.props.refine([_this.state.min, _this.state.max]); + }); + + return _this; + } + + _createClass(RangeInput, [{ + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + this.setState({ + min: nextProps.values.min, + max: nextProps.values.max + }); + } + }, { + key: "render", + value: function render() { + var _this$state = this.state, + minValue = _this$state.min, + maxValue = _this$state.max; + var _this$props = this.props, + min = _this$props.min, + max = _this$props.max, + step = _this$props.step, + cssClasses = _this$props.cssClasses, + templateProps = _this$props.templateProps; + var isDisabled = min && max ? min >= max : false; + var hasRefinements = Boolean(minValue || maxValue); + var rootClassNames = (0, _classnames.default)(cssClasses.root, _defineProperty({}, cssClasses.noRefinement, !hasRefinements)); + return (0, _preact.h)("div", { + className: rootClassNames + }, (0, _preact.h)("form", { + className: cssClasses.form, + onSubmit: this.onSubmit + }, (0, _preact.h)("label", { + className: cssClasses.label + }, (0, _preact.h)("input", { + className: (0, _classnames.default)(cssClasses.input, cssClasses.inputMin), + type: "number", + min: min, + max: max, + step: step, + value: minValue !== null && minValue !== void 0 ? minValue : '', + onInput: this.onInput('min'), + placeholder: min === null || min === void 0 ? void 0 : min.toString(), + disabled: isDisabled + })), (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "separatorText", + rootTagName: "span", + rootProps: { + className: cssClasses.separator + } + })), (0, _preact.h)("label", { + className: cssClasses.label + }, (0, _preact.h)("input", { + className: (0, _classnames.default)(cssClasses.input, cssClasses.inputMax), + type: "number", + min: min, + max: max, + step: step, + value: maxValue !== null && maxValue !== void 0 ? maxValue : '', + onInput: this.onInput('max'), + placeholder: max === null || max === void 0 ? void 0 : max.toString(), + disabled: isDisabled + })), (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "submitText", + rootTagName: "button", + rootProps: { + type: 'submit', + className: cssClasses.submit, + disabled: isDisabled + } + })))); + } + }]); + + return RangeInput; +}(_preact.Component); + +var _default = RangeInput; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/RefinementList/RefinementList.js b/js/instantsearch.js/cjs/components/RefinementList/RefinementList.js new file mode 100644 index 00000000..5534e2d7 --- /dev/null +++ b/js/instantsearch.js/cjs/components/RefinementList/RefinementList.js @@ -0,0 +1,287 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +var _RefinementListItem = _interopRequireDefault(require("./RefinementListItem")); + +var _SearchBox = _interopRequireDefault(require("../SearchBox/SearchBox")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var defaultProps = { + cssClasses: {}, + depth: 0 +}; + +function isHierarchicalMenuItem(facetValue) { + return facetValue.data !== undefined; +} + +var RefinementList = /*#__PURE__*/function (_Component) { + _inherits(RefinementList, _Component); + + var _super = _createSuper(RefinementList); + + function RefinementList(props) { + var _this; + + _classCallCheck(this, RefinementList); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "searchBox", (0, _preact.createRef)()); + + _this.handleItemClick = _this.handleItemClick.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(RefinementList, [{ + key: "shouldComponentUpdate", + value: function shouldComponentUpdate(nextProps) { + var areFacetValuesDifferent = !(0, _utils.isEqual)(this.props.facetValues, nextProps.facetValues); + return areFacetValuesDifferent; + } + }, { + key: "refine", + value: function refine(facetValueToRefine) { + this.props.toggleRefinement(facetValueToRefine); + } + }, { + key: "_generateFacetItem", + value: function _generateFacetItem(facetValue) { + var _cx; + + var subItems; + + if (isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) { + var _this$props$cssClasse = this.props.cssClasses, + root = _this$props$cssClasse.root, + cssClasses = _objectWithoutProperties(_this$props$cssClasse, ["root"]); + + subItems = (0, _preact.h)(RefinementList, _extends({}, this.props, { + // We want to keep `root` required for external usage but not for the + // sub items. + cssClasses: cssClasses, + depth: this.props.depth + 1, + facetValues: facetValue.data, + showMore: false, + className: this.props.cssClasses.childList + })); + } + + var url = this.props.createURL(facetValue.value); + + var templateData = _objectSpread(_objectSpread({}, facetValue), {}, { + url: url, + attribute: this.props.attribute, + cssClasses: this.props.cssClasses, + isFromSearch: this.props.isFromSearch + }); + + var key = facetValue.value; + + if (facetValue.isRefined !== undefined) { + key += "/".concat(facetValue.isRefined); + } + + if (facetValue.count !== undefined) { + key += "/".concat(facetValue.count); + } + + var refinementListItemClassName = (0, _classnames.default)(this.props.cssClasses.item, (_cx = {}, _defineProperty(_cx, this.props.cssClasses.selectedItem, facetValue.isRefined), _defineProperty(_cx, this.props.cssClasses.disabledItem, !facetValue.count), _defineProperty(_cx, this.props.cssClasses.parentItem, isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0), _cx)); + return (0, _preact.h)(_RefinementListItem.default, { + templateKey: "item", + key: key, + facetValueToRefine: facetValue.value, + handleClick: this.handleItemClick, + isRefined: facetValue.isRefined, + className: refinementListItemClassName, + subItems: subItems, + templateData: templateData, + templateProps: this.props.templateProps + }); + } // Click events on DOM tree like LABEL > INPUT will result in two click events + // instead of one. + // No matter the framework, see https://www.google.com/search?q=click+label+twice + // + // Thus making it hard to distinguish activation from deactivation because both click events + // are very close. Debounce is a solution but hacky. + // + // So the code here checks if the click was done on or in a LABEL. If this LABEL + // has a checkbox inside, we ignore the first click event because we will get another one. + // + // We also check if the click was done inside a link and then e.preventDefault() because we already + // handle the url + // + // Finally, we always stop propagation of the event to avoid multiple levels RefinementLists to fail: click + // on child would click on parent also + + }, { + key: "handleItemClick", + value: function handleItemClick(_ref) { + var facetValueToRefine = _ref.facetValueToRefine, + isRefined = _ref.isRefined, + originalEvent = _ref.originalEvent; + + if ((0, _utils.isSpecialClick)(originalEvent)) { + // do not alter the default browser behavior + // if one special key is down + return; + } + + if (!(originalEvent.target instanceof HTMLElement) || !(originalEvent.target.parentNode instanceof HTMLElement)) { + return; + } + + if (isRefined && originalEvent.target.parentNode.querySelector('input[type="radio"]:checked')) { + // Prevent refinement for being reset if the user clicks on an already checked radio button + return; + } + + if (originalEvent.target.tagName === 'INPUT') { + this.refine(facetValueToRefine); + return; + } + + var parent = originalEvent.target; + + while (parent !== originalEvent.currentTarget) { + if (parent.tagName === 'LABEL' && (parent.querySelector('input[type="checkbox"]') || parent.querySelector('input[type="radio"]'))) { + return; + } + + if (parent.tagName === 'A' && parent.href) { + originalEvent.preventDefault(); + } + + parent = parent.parentNode; + } + + originalEvent.stopPropagation(); + this.refine(facetValueToRefine); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + if (this.searchBox.current && !nextProps.isFromSearch) { + this.searchBox.current.resetInput(); + } + } + }, { + key: "refineFirstValue", + value: function refineFirstValue() { + var firstValue = this.props.facetValues && this.props.facetValues[0]; + + if (firstValue) { + var actualValue = firstValue.value; + this.props.toggleRefinement(actualValue); + } + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var showMoreButtonClassName = (0, _classnames.default)(this.props.cssClasses.showMore, _defineProperty({}, this.props.cssClasses.disabledShowMore, !(this.props.showMore === true && this.props.canToggleShowMore))); + var showMoreButton = this.props.showMore === true && (0, _preact.h)(_Template.default, _extends({}, this.props.templateProps, { + templateKey: "showMoreText", + rootTagName: "button", + rootProps: { + className: showMoreButtonClassName, + disabled: !this.props.canToggleShowMore, + onClick: this.props.toggleShowMore + }, + data: { + isShowingMore: this.props.isShowingMore + } + })); + var shouldDisableSearchBox = this.props.searchIsAlwaysActive !== true && !(this.props.isFromSearch || !this.props.hasExhaustiveItems); + var searchBox = this.props.searchFacetValues && (0, _preact.h)("div", { + className: this.props.cssClasses.searchBox + }, (0, _preact.h)(_SearchBox.default, { + ref: this.searchBox, + placeholder: this.props.searchPlaceholder, + disabled: shouldDisableSearchBox, + cssClasses: this.props.cssClasses.searchable, + templates: this.props.searchBoxTemplateProps.templates, + onChange: function onChange(event) { + return _this2.props.searchFacetValues(event.target.value); + }, + onReset: function onReset() { + return _this2.props.searchFacetValues(''); + }, + onSubmit: function onSubmit() { + return _this2.refineFirstValue(); + } // This sets the search box to a controlled state because + // we don't rely on the `refine` prop but on `onChange`. + , + searchAsYouType: false + })); + var facetValues = this.props.facetValues && this.props.facetValues.length > 0 && (0, _preact.h)("ul", { + className: this.props.cssClasses.list + }, this.props.facetValues.map(this._generateFacetItem, this)); + var noResults = this.props.searchFacetValues && this.props.isFromSearch && (!this.props.facetValues || this.props.facetValues.length === 0) && (0, _preact.h)(_Template.default, _extends({}, this.props.templateProps, { + templateKey: "searchableNoResults", + rootProps: { + className: this.props.cssClasses.noResults + } + })); + var rootClassName = (0, _classnames.default)(this.props.cssClasses.root, _defineProperty({}, this.props.cssClasses.noRefinementRoot, !this.props.facetValues || this.props.facetValues.length === 0), this.props.className); + return (0, _preact.h)("div", { + className: rootClassName + }, this.props.children, searchBox, facetValues, noResults, showMoreButton); + } + }]); + + return RefinementList; +}(_preact.Component); + +_defineProperty(RefinementList, "defaultProps", defaultProps); + +var _default = RefinementList; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/RefinementList/RefinementListItem.js b/js/instantsearch.js/cjs/components/RefinementList/RefinementListItem.js new file mode 100644 index 00000000..2731ccc7 --- /dev/null +++ b/js/instantsearch.js/cjs/components/RefinementList/RefinementListItem.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +function RefinementListItem(_ref) { + var className = _ref.className, + handleClick = _ref.handleClick, + facetValueToRefine = _ref.facetValueToRefine, + isRefined = _ref.isRefined, + templateProps = _ref.templateProps, + templateKey = _ref.templateKey, + templateData = _ref.templateData, + subItems = _ref.subItems; + return (0, _preact.h)("li", { + className: className, + onClick: function onClick(originalEvent) { + handleClick({ + facetValueToRefine: facetValueToRefine, + isRefined: isRefined, + originalEvent: originalEvent + }); + } + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: templateKey, + data: templateData + })), subItems); +} + +var _default = RefinementListItem; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/RelevantSort/RelevantSort.js b/js/instantsearch.js/cjs/components/RelevantSort/RelevantSort.js new file mode 100644 index 00000000..4e3e7ed2 --- /dev/null +++ b/js/instantsearch.js/cjs/components/RelevantSort/RelevantSort.js @@ -0,0 +1,53 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx h */ +var RelevantSort = function RelevantSort(_ref) { + var cssClasses = _ref.cssClasses, + templates = _ref.templates, + isRelevantSorted = _ref.isRelevantSorted, + isVirtualReplica = _ref.isVirtualReplica, + refine = _ref.refine; + return isVirtualReplica ? (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)(_Template.default, { + templateKey: "text", + templates: templates, + rootProps: { + className: cssClasses.text + }, + data: { + isRelevantSorted: isRelevantSorted + } + }), (0, _preact.h)("button", { + type: "button", + className: cssClasses.button, + onClick: function onClick() { + if (isRelevantSorted) { + refine(0); + } else { + refine(undefined); + } + } + }, (0, _preact.h)(_Template.default, { + rootTagName: "span", + templateKey: "button", + templates: templates, + data: { + isRelevantSorted: isRelevantSorted + } + }))) : null; +}; + +var _default = RelevantSort; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/SearchBox/SearchBox.js b/js/instantsearch.js/cjs/components/SearchBox/SearchBox.js new file mode 100644 index 00000000..0cb198fc --- /dev/null +++ b/js/instantsearch.js/cjs/components/SearchBox/SearchBox.js @@ -0,0 +1,265 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _utils = require("../../lib/utils"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var defaultProps = { + query: '', + showSubmit: true, + showReset: true, + showLoadingIndicator: true, + autofocus: false, + searchAsYouType: true, + isSearchStalled: false, + disabled: false, + onChange: _utils.noop, + onSubmit: _utils.noop, + onReset: _utils.noop, + refine: _utils.noop +}; + +var SearchBox = /*#__PURE__*/function (_Component) { + _inherits(SearchBox, _Component); + + var _super = _createSuper(SearchBox); + + function SearchBox() { + var _this; + + _classCallCheck(this, SearchBox); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + query: _this.props.query, + focused: false + }); + + _defineProperty(_assertThisInitialized(_this), "input", (0, _preact.createRef)()); + + _defineProperty(_assertThisInitialized(_this), "onInput", function (event) { + var _this$props = _this.props, + searchAsYouType = _this$props.searchAsYouType, + refine = _this$props.refine, + onChange = _this$props.onChange; + var query = event.target.value; + + if (searchAsYouType) { + refine(query); + } + + _this.setState({ + query: query + }); + + onChange(event); + }); + + _defineProperty(_assertThisInitialized(_this), "onSubmit", function (event) { + var _this$props2 = _this.props, + searchAsYouType = _this$props2.searchAsYouType, + refine = _this$props2.refine, + onSubmit = _this$props2.onSubmit; + event.preventDefault(); + event.stopPropagation(); + + if (_this.input.current) { + _this.input.current.blur(); + } + + if (!searchAsYouType) { + refine(_this.state.query); + } + + onSubmit(event); + return false; + }); + + _defineProperty(_assertThisInitialized(_this), "onReset", function (event) { + var _this$props3 = _this.props, + refine = _this$props3.refine, + onReset = _this$props3.onReset; + var query = ''; + + if (_this.input.current) { + _this.input.current.focus(); + } + + refine(query); + + _this.setState({ + query: query + }); + + onReset(event); + }); + + _defineProperty(_assertThisInitialized(_this), "onBlur", function () { + _this.setState({ + focused: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onFocus", function () { + _this.setState({ + focused: true + }); + }); + + return _this; + } + + _createClass(SearchBox, [{ + key: "resetInput", + value: + /** + * This public method is used in the RefinementList SFFV search box + * to reset the input state when an item is selected. + * + * @see RefinementList#componentWillReceiveProps + * @return {undefined} + */ + function resetInput() { + this.setState({ + query: '' + }); + } + }, { + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + /** + * when the user is typing, we don't want to replace the query typed + * by the user (state.query) with the query exposed by the connector (props.query) + * see: https://github.com/algolia/instantsearch.js/issues/4141 + */ + if (!this.state.focused && nextProps.query !== this.state.query) { + this.setState({ + query: nextProps.query + }); + } + } + }, { + key: "render", + value: function render() { + var _this$props4 = this.props, + cssClasses = _this$props4.cssClasses, + placeholder = _this$props4.placeholder, + autofocus = _this$props4.autofocus, + showSubmit = _this$props4.showSubmit, + showReset = _this$props4.showReset, + showLoadingIndicator = _this$props4.showLoadingIndicator, + templates = _this$props4.templates, + isSearchStalled = _this$props4.isSearchStalled; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)("form", { + action: "", + role: "search", + className: cssClasses.form, + noValidate: true, + onSubmit: this.onSubmit // @ts-expect-error `onReset` attibute is missing in preact 10.0.0 JSX types + , + onReset: this.onReset + }, (0, _preact.h)("input", { + ref: this.input, + value: this.state.query, + disabled: this.props.disabled, + className: cssClasses.input, + type: "search", + placeholder: placeholder, + autoFocus: autofocus, + autoComplete: "off", + autoCorrect: "off" // @ts-expect-error `autoCapitalize` attibute is missing in preact 10.0.0 JSX types + , + autoCapitalize: "off", + spellCheck: "false", + maxLength: 512, + onInput: this.onInput, + onBlur: this.onBlur, + onFocus: this.onFocus + }), (0, _preact.h)(_Template.default, { + templateKey: "submit", + rootTagName: "button", + rootProps: { + className: cssClasses.submit, + type: 'submit', + title: 'Submit the search query.', + hidden: !showSubmit + }, + templates: templates, + data: { + cssClasses: cssClasses + } + }), (0, _preact.h)(_Template.default, { + templateKey: "reset", + rootTagName: "button", + rootProps: { + className: cssClasses.reset, + type: 'reset', + title: 'Clear the search query.', + hidden: !(showReset && this.state.query.trim() && !isSearchStalled) + }, + templates: templates, + data: { + cssClasses: cssClasses + } + }), showLoadingIndicator && (0, _preact.h)(_Template.default, { + templateKey: "loadingIndicator", + rootTagName: "span", + rootProps: { + className: cssClasses.loadingIndicator, + hidden: !isSearchStalled + }, + templates: templates, + data: { + cssClasses: cssClasses + } + }))); + } + }]); + + return SearchBox; +}(_preact.Component); + +_defineProperty(SearchBox, "defaultProps", defaultProps); + +var _default = SearchBox; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Selector/Selector.js b/js/instantsearch.js/cjs/components/Selector/Selector.js new file mode 100644 index 00000000..b89220d8 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Selector/Selector.js @@ -0,0 +1,36 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx h */ +function Selector(_ref) { + var currentValue = _ref.currentValue, + options = _ref.options, + cssClasses = _ref.cssClasses, + setValue = _ref.setValue; + return (0, _preact.h)("select", { + className: (0, _classnames.default)(cssClasses.select), + onChange: function onChange(event) { + return setValue(event.target.value); + }, + value: "".concat(currentValue) + }, options.map(function (option) { + return (0, _preact.h)("option", { + className: (0, _classnames.default)(cssClasses.option), + key: option.label + option.value, + value: "".concat(option.value) + }, option.label); + })); +} + +var _default = Selector; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Slider/Pit.js b/js/instantsearch.js/cjs/components/Slider/Pit.js new file mode 100644 index 00000000..cccf081a --- /dev/null +++ b/js/instantsearch.js/cjs/components/Slider/Pit.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var Pit = function Pit(_ref) { + var style = _ref.style, + children = _ref.children; + // first, end & middle + var positionValue = Math.round(parseFloat(style.left)); + var shouldDisplayValue = [0, 50, 100].includes(positionValue); + var value = children; + var pitValue = Math.round(parseInt(value, 10) * 100) / 100; + return (0, _preact.h)("div", { + style: _objectSpread(_objectSpread({}, style), {}, { + marginLeft: positionValue === 100 ? '-2px' : 0 + }), + className: (0, _classnames.default)('rheostat-marker', 'rheostat-marker-horizontal', { + 'rheostat-marker-large': shouldDisplayValue + }) + }, shouldDisplayValue && (0, _preact.h)("div", { + className: 'rheostat-value' + }, pitValue)); +}; + +var _default = Pit; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Slider/Rheostat.js b/js/instantsearch.js/cjs/components/Slider/Rheostat.js new file mode 100644 index 00000000..697ab9e8 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Slider/Rheostat.js @@ -0,0 +1,708 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +var KEYS = { + DOWN: 40, + END: 35, + ESC: 27, + HOME: 36, + LEFT: 37, + PAGE_DOWN: 34, + PAGE_UP: 33, + RIGHT: 39, + UP: 38 +}; +var PERCENT_EMPTY = 0; +var PERCENT_FULL = 100; + +function getPosition(value, min, max) { + return (value - min) / (max - min) * 100; +} + +function getValue(pos, min, max) { + var decimal = pos / 100; + + if (pos === 0) { + return min; + } else if (pos === 100) { + return max; + } + + return Math.round((max - min) * decimal + min); +} + +function getClassName(props) { + var orientation = props.orientation === 'vertical' ? 'rheostat-vertical' : 'rheostat-horizontal'; + return ['rheostat', orientation].concat(props.className.split(' ')).join(' '); +} + +function getHandleFor(ev) { + return Number(ev.currentTarget.getAttribute('data-handle-key')); +} + +function killEvent(ev) { + ev.stopPropagation(); + ev.preventDefault(); +} + +function Button(props) { + return (0, _preact.h)("button", _extends({}, props, { + type: "button" + })); +} // Preact doesn't have builtin types for Style, h.JSX.HTMLAttributes['style'] is just object +// maybe migrate to csstype later? + + +var _ref6 = (0, _preact.h)("div", { + className: "rheostat-background" +}); + +var Rheostat = /*#__PURE__*/function (_Component) { + _inherits(Rheostat, _Component); + + var _super = _createSuper(Rheostat); + + function Rheostat(props) { + var _this; + + _classCallCheck(this, Rheostat); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "state", { + className: getClassName(_this.props), + // non-null thanks to defaultProps + handlePos: _this.props.values.map(function (value) { + return getPosition(value, _this.props.min, _this.props.max); + }), + handleDimensions: 0, + mousePos: null, + sliderBox: {}, + slidingIndex: null, + // non-null thanks to defaultProps + values: _this.props.values + }); + + _defineProperty(_assertThisInitialized(_this), "rheostat", (0, _preact.createRef)()); + + _this.getPublicState = _this.getPublicState.bind(_assertThisInitialized(_this)); + _this.getSliderBoundingBox = _this.getSliderBoundingBox.bind(_assertThisInitialized(_this)); + _this.getProgressStyle = _this.getProgressStyle.bind(_assertThisInitialized(_this)); + _this.getMinValue = _this.getMinValue.bind(_assertThisInitialized(_this)); + _this.getMaxValue = _this.getMaxValue.bind(_assertThisInitialized(_this)); + _this.getHandleDimensions = _this.getHandleDimensions.bind(_assertThisInitialized(_this)); + _this.getClosestSnapPoint = _this.getClosestSnapPoint.bind(_assertThisInitialized(_this)); + _this.getSnapPosition = _this.getSnapPosition.bind(_assertThisInitialized(_this)); + _this.getNextPositionForKey = _this.getNextPositionForKey.bind(_assertThisInitialized(_this)); + _this.getNextState = _this.getNextState.bind(_assertThisInitialized(_this)); + _this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this)); + _this.getClosestHandle = _this.getClosestHandle.bind(_assertThisInitialized(_this)); + _this.setStartSlide = _this.setStartSlide.bind(_assertThisInitialized(_this)); + _this.startMouseSlide = _this.startMouseSlide.bind(_assertThisInitialized(_this)); + _this.startTouchSlide = _this.startTouchSlide.bind(_assertThisInitialized(_this)); + _this.handleMouseSlide = _this.handleMouseSlide.bind(_assertThisInitialized(_this)); + _this.handleTouchSlide = _this.handleTouchSlide.bind(_assertThisInitialized(_this)); + _this.handleSlide = _this.handleSlide.bind(_assertThisInitialized(_this)); + _this.endSlide = _this.endSlide.bind(_assertThisInitialized(_this)); + _this.handleKeydown = _this.handleKeydown.bind(_assertThisInitialized(_this)); + _this.validatePosition = _this.validatePosition.bind(_assertThisInitialized(_this)); + _this.validateValues = _this.validateValues.bind(_assertThisInitialized(_this)); + _this.canMove = _this.canMove.bind(_assertThisInitialized(_this)); + _this.fireChangeEvent = _this.fireChangeEvent.bind(_assertThisInitialized(_this)); + _this.slideTo = _this.slideTo.bind(_assertThisInitialized(_this)); + _this.updateNewValues = _this.updateNewValues.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Rheostat, [{ + key: "componentWillReceiveProps", + value: function componentWillReceiveProps(nextProps) { + var _this$props = this.props, + className = _this$props.className, + disabled = _this$props.disabled, + min = _this$props.min, + max = _this$props.max, + orientation = _this$props.orientation; + var _this$state = this.state, + values = _this$state.values, + slidingIndex = _this$state.slidingIndex; + var minMaxChanged = nextProps.min !== min || nextProps.max !== max; + var valuesChanged = values.length !== nextProps.values.length || values.some(function (value, idx) { + return nextProps.values[idx] !== value; + }); + var orientationChanged = nextProps.className !== className || nextProps.orientation !== orientation; + var willBeDisabled = nextProps.disabled && !disabled; + + if (orientationChanged) { + this.setState({ + className: getClassName(nextProps) + }); + } + + if (minMaxChanged || valuesChanged) this.updateNewValues(nextProps); + + if (willBeDisabled && slidingIndex !== null) { + this.endSlide(); + } + } + }, { + key: "getPublicState", + value: function getPublicState() { + var _this$props2 = this.props, + min = _this$props2.min, + max = _this$props2.max; + var values = this.state.values; + return { + max: max, + min: min, + values: values + }; + } + }, { + key: "getSliderBoundingBox", + value: function getSliderBoundingBox() { + // only gets called after render, so it will always be defined + var node = this.rheostat.current; + var rect = node.getBoundingClientRect(); + return { + height: rect.height || node.clientHeight, + left: rect.left, + top: rect.top, + width: rect.width || node.clientWidth + }; + } + }, { + key: "getProgressStyle", + value: function getProgressStyle(idx) { + var handlePos = this.state.handlePos; + var value = handlePos[idx]; + + if (idx === 0) { + return this.props.orientation === 'vertical' ? { + height: "".concat(value, "%"), + top: 0 + } : { + left: 0, + width: "".concat(value, "%") + }; + } + + var prevValue = handlePos[idx - 1]; + var diffValue = value - prevValue; + return this.props.orientation === 'vertical' ? { + height: "".concat(diffValue, "%"), + top: "".concat(prevValue, "%") + } : { + left: "".concat(prevValue, "%"), + width: "".concat(diffValue, "%") + }; + } + }, { + key: "getMinValue", + value: function getMinValue(idx) { + return this.state.values[idx - 1] ? Math.max(this.props.min, this.state.values[idx - 1]) : this.props.min; + } + }, { + key: "getMaxValue", + value: function getMaxValue(idx) { + return this.state.values[idx + 1] ? Math.min(this.props.max, this.state.values[idx + 1]) : this.props.max; + } + }, { + key: "getHandleDimensions", + value: function getHandleDimensions(ev, sliderBox) { + var handleNode = ev.currentTarget || null; + if (!handleNode) return 0; + return this.props.orientation === 'vertical' ? handleNode.clientHeight / sliderBox.height * PERCENT_FULL / 2 : handleNode.clientWidth / sliderBox.width * PERCENT_FULL / 2; + } + }, { + key: "getClosestSnapPoint", + value: function getClosestSnapPoint(value) { + // non-null thanks to defaultProps + if (!this.props.snapPoints.length) return value; + return this.props.snapPoints.reduce(function (snapTo, snap) { + return Math.abs(snapTo - value) < Math.abs(snap - value) ? snapTo : snap; + }); + } + }, { + key: "getSnapPosition", + value: function getSnapPosition(positionPercent) { + if (!this.props.snap) return positionPercent; + var _ref = this.props, + max = _ref.max, + min = _ref.min; + var value = getValue(positionPercent, min, max); + var snapValue = this.getClosestSnapPoint(value); + return getPosition(snapValue, min, max); + } + }, { + key: "getNextPositionForKey", + value: function getNextPositionForKey(idx, keyCode) { + var _stepMultiplier; + + var _this$state2 = this.state, + handlePos = _this$state2.handlePos, + values = _this$state2.values; + var _ref2 = this.props, + max = _ref2.max, + min = _ref2.min, + snapPoints = _ref2.snapPoints; + var shouldSnap = this.props.snap; + var proposedValue = values[idx]; + var proposedPercentage = handlePos[idx]; + var originalPercentage = proposedPercentage; + var stepValue = 1; + + if (max >= 100) { + proposedPercentage = Math.round(proposedPercentage); + } else { + stepValue = 100 / (max - min); + } + + var currentIndex = null; + + if (shouldSnap) { + currentIndex = snapPoints.indexOf(this.getClosestSnapPoint(values[idx])); + } + + var stepMultiplier = (_stepMultiplier = {}, _defineProperty(_stepMultiplier, KEYS.LEFT, function (v) { + return v * -1; + }), _defineProperty(_stepMultiplier, KEYS.RIGHT, function (v) { + return v; + }), _defineProperty(_stepMultiplier, KEYS.UP, function (v) { + return v; + }), _defineProperty(_stepMultiplier, KEYS.DOWN, function (v) { + return v * -1; + }), _defineProperty(_stepMultiplier, KEYS.PAGE_DOWN, function (v) { + return v > 1 ? -v : v * -10; + }), _defineProperty(_stepMultiplier, KEYS.PAGE_UP, function (v) { + return v > 1 ? v : v * 10; + }), _stepMultiplier); + + if (Object.prototype.hasOwnProperty.call(stepMultiplier, keyCode)) { + proposedPercentage += stepMultiplier[keyCode](stepValue); + + if (shouldSnap) { + if (!currentIndex) {// nothing happens + } else if (proposedPercentage > originalPercentage) { + // move cursor right unless overflow + if (currentIndex < snapPoints.length - 1) { + proposedValue = snapPoints[currentIndex + 1]; + } // move cursor left unless there is overflow + + } else if (currentIndex > 0) { + proposedValue = snapPoints[currentIndex - 1]; + } + } + } else if (keyCode === KEYS.HOME) { + proposedPercentage = PERCENT_EMPTY; + + if (shouldSnap) { + proposedValue = snapPoints[0]; + } + } else if (keyCode === KEYS.END) { + proposedPercentage = PERCENT_FULL; + + if (shouldSnap) { + proposedValue = snapPoints[snapPoints.length - 1]; + } + } else { + return null; + } + + return shouldSnap ? getPosition(proposedValue, min, max) : proposedPercentage; + } + }, { + key: "getNextState", + value: function getNextState(idx, proposedPosition) { + var handlePos = this.state.handlePos; + var _ref3 = this.props, + max = _ref3.max, + min = _ref3.min; + var actualPosition = this.validatePosition(idx, proposedPosition); + var nextHandlePos = handlePos.map(function (pos, index) { + return index === idx ? actualPosition : pos; + }); + return { + handlePos: nextHandlePos, + values: nextHandlePos.map(function (pos) { + return getValue(pos, min, max); + }) + }; + } + }, { + key: "getClosestHandle", + value: function getClosestHandle(positionPercent) { + var handlePos = this.state.handlePos; + return handlePos.reduce(function (closestIdx, _node, idx) { + var challenger = Math.abs(handlePos[idx] - positionPercent); + var current = Math.abs(handlePos[closestIdx] - positionPercent); + return challenger < current ? idx : closestIdx; + }, 0); + } + }, { + key: "setStartSlide", + value: function setStartSlide(ev, x, y) { + var sliderBox = this.getSliderBoundingBox(); + this.setState({ + handleDimensions: this.getHandleDimensions(ev, sliderBox), + mousePos: { + x: x, + y: y + }, + sliderBox: sliderBox, + slidingIndex: getHandleFor(ev) + }); + } + }, { + key: "startMouseSlide", + value: function startMouseSlide(ev) { + this.setStartSlide(ev, ev.clientX, ev.clientY); + document.addEventListener('mousemove', this.handleMouseSlide, false); + document.addEventListener('mouseup', this.endSlide, false); + killEvent(ev); + } + }, { + key: "startTouchSlide", + value: function startTouchSlide(ev) { + if (ev.changedTouches.length > 1) return; + var touch = ev.changedTouches[0]; + this.setStartSlide(ev, touch.clientX, touch.clientY); + document.addEventListener('touchmove', this.handleTouchSlide, false); + document.addEventListener('touchend', this.endSlide, false); + if (this.props.onSliderDragStart) this.props.onSliderDragStart(); + killEvent(ev); + } + }, { + key: "handleMouseSlide", + value: function handleMouseSlide(ev) { + if (this.state.slidingIndex === null) return; + this.handleSlide(ev.clientX, ev.clientY); + killEvent(ev); + } + }, { + key: "handleTouchSlide", + value: function handleTouchSlide(ev) { + if (this.state.slidingIndex === null) return; + + if (ev.changedTouches.length > 1) { + this.endSlide(); + return; + } + + var touch = ev.changedTouches[0]; + this.handleSlide(touch.clientX, touch.clientY); + killEvent(ev); + } + }, { + key: "handleSlide", + value: function handleSlide(x, y) { + var _this$state3 = this.state, + idx = _this$state3.slidingIndex, + sliderBox = _this$state3.sliderBox; + var positionPercent = this.props.orientation === 'vertical' ? (y - sliderBox.top) / sliderBox.height * PERCENT_FULL : (x - sliderBox.left) / sliderBox.width * PERCENT_FULL; + this.slideTo(idx, positionPercent); + + if (this.canMove(idx, positionPercent)) { + // update mouse positions + this.setState({ + mousePos: { + x: x, + y: y + } + }); + if (this.props.onSliderDragMove) this.props.onSliderDragMove(); + } + } + }, { + key: "endSlide", + value: function endSlide() { + var _this2 = this; + + var idx = this.state.slidingIndex; + this.setState({ + slidingIndex: null + }); + document.removeEventListener('mouseup', this.endSlide, false); + document.removeEventListener('touchend', this.endSlide, false); + document.removeEventListener('touchmove', this.handleTouchSlide, false); + document.removeEventListener('mousemove', this.handleMouseSlide, false); + if (this.props.onSliderDragEnd) this.props.onSliderDragEnd(); + + if (this.props.snap) { + var positionPercent = this.getSnapPosition(this.state.handlePos[idx]); + this.slideTo(idx, positionPercent, function () { + return _this2.fireChangeEvent(); + }); + } else { + this.fireChangeEvent(); + } + } + }, { + key: "handleClick", + value: function handleClick(ev) { + var _this3 = this; + + if (ev.target.getAttribute('data-handle-key')) { + return; + } // Calculate the position of the slider on the page so we can determine + // the position where you click in relativity. + + + var sliderBox = this.getSliderBoundingBox(); + var positionDecimal = this.props.orientation === 'vertical' ? (ev.clientY - sliderBox.top) / sliderBox.height : (ev.clientX - sliderBox.left) / sliderBox.width; + var positionPercent = positionDecimal * PERCENT_FULL; + var handleId = this.getClosestHandle(positionPercent); + var validPositionPercent = this.getSnapPosition(positionPercent); // Move the handle there + + this.slideTo(handleId, validPositionPercent, function () { + return _this3.fireChangeEvent(); + }); + if (this.props.onClick) this.props.onClick(); + } + }, { + key: "handleKeydown", + value: function handleKeydown(ev) { + var _this4 = this; + + var idx = getHandleFor(ev); + + if (ev.keyCode === KEYS.ESC) { + ev.currentTarget.blur(); + return; + } + + var proposedPercentage = this.getNextPositionForKey(idx, ev.keyCode); + if (proposedPercentage === null) return; + + if (this.canMove(idx, proposedPercentage)) { + this.slideTo(idx, proposedPercentage, function () { + return _this4.fireChangeEvent(); + }); + if (this.props.onKeyPress) this.props.onKeyPress(); + } + + killEvent(ev); + } // Make sure the proposed position respects the bounds and + // does not collide with other handles too much. + + }, { + key: "validatePosition", + value: function validatePosition(idx, proposedPosition) { + var _this$state4 = this.state, + handlePos = _this$state4.handlePos, + handleDimensions = _this$state4.handleDimensions; + return Math.max(Math.min(proposedPosition, handlePos[idx + 1] !== undefined ? handlePos[idx + 1] - handleDimensions : PERCENT_FULL // 100% is the highest value + ), handlePos[idx - 1] !== undefined ? handlePos[idx - 1] + handleDimensions : PERCENT_EMPTY // 0% is the lowest value + ); + } + }, { + key: "validateValues", + value: function validateValues(proposedValues, props) { + var _ref4 = props || this.props, + max = _ref4.max, + min = _ref4.min; + + return proposedValues.map(function (value, idx, values) { + var realValue = Math.max(Math.min(value, max), min); + + if (values.length && realValue < values[idx - 1]) { + return values[idx - 1]; + } + + return realValue; + }); + } + }, { + key: "canMove", + value: function canMove(idx, proposedPosition) { + var _this$state5 = this.state, + handlePos = _this$state5.handlePos, + handleDimensions = _this$state5.handleDimensions; + if (proposedPosition < PERCENT_EMPTY) return false; + if (proposedPosition > PERCENT_FULL) return false; + var nextHandlePosition = handlePos[idx + 1] !== undefined ? handlePos[idx + 1] - handleDimensions : Infinity; + if (proposedPosition > nextHandlePosition) return false; + var prevHandlePosition = handlePos[idx - 1] !== undefined ? handlePos[idx - 1] + handleDimensions : -Infinity; + if (proposedPosition < prevHandlePosition) return false; + return true; + } + }, { + key: "fireChangeEvent", + value: function fireChangeEvent() { + var onChange = this.props.onChange; + if (onChange) onChange(this.getPublicState()); + } + }, { + key: "slideTo", + value: function slideTo(idx, proposedPosition, onAfterSet) { + var _this5 = this; + + var nextState = this.getNextState(idx, proposedPosition); + this.setState(nextState, function () { + var onValuesUpdated = _this5.props.onValuesUpdated; + if (onValuesUpdated) onValuesUpdated(_this5.getPublicState()); + if (onAfterSet) onAfterSet(); + }); + } + }, { + key: "updateNewValues", + value: function updateNewValues(nextProps) { + var _this6 = this; + + var slidingIndex = this.state.slidingIndex; // Don't update while the slider is sliding + + if (slidingIndex !== null) { + return; + } + + var max = nextProps.max, + min = nextProps.min, + values = nextProps.values; + var nextValues = this.validateValues(values, nextProps); + this.setState({ + handlePos: nextValues.map(function (value) { + return getPosition(value, min, max); + }), + values: nextValues + }, function () { + return _this6.fireChangeEvent(); + }); + } + }, { + key: "render", + value: function render() { + var _this7 = this; + + var _ref5 = this.props, + children = _ref5.children, + disabled = _ref5.disabled, + Handle = _ref5.handle, + max = _ref5.max, + min = _ref5.min, + orientation = _ref5.orientation, + PitComponent = _ref5.pitComponent, + pitPoints = _ref5.pitPoints, + ProgressBar = _ref5.progressBar; // all required thanks to defaultProps + + var _this$state6 = this.state, + className = _this$state6.className, + handlePos = _this$state6.handlePos, + values = _this$state6.values; + return (0, _preact.h)("div", { + className: className, + ref: this.rheostat, + onClick: disabled ? undefined : this.handleClick, + style: { + position: 'relative' + } + }, _ref6, handlePos.map(function (pos, idx) { + var handleStyle = orientation === 'vertical' ? { + top: "".concat(pos, "%"), + position: 'absolute' + } : { + left: "".concat(pos, "%"), + position: 'absolute' + }; + return (0, _preact.h)(Handle, { + "aria-valuemax": _this7.getMaxValue(idx), + "aria-valuemin": _this7.getMinValue(idx), + "aria-valuenow": values[idx], + "aria-disabled": disabled, + "data-handle-key": idx, + className: "rheostat-handle", + key: "handle-".concat(idx), + onClick: killEvent, + onKeyDown: disabled ? undefined : _this7.handleKeydown, + onMouseDown: disabled ? undefined : _this7.startMouseSlide, + onTouchStart: disabled ? undefined : _this7.startTouchSlide, + role: "slider", + style: handleStyle, + tabIndex: 0 + }); + }), handlePos.map(function (_node, idx, arr) { + if (idx === 0 && arr.length > 1) { + return null; + } + + return (0, _preact.h)(ProgressBar, { + className: "rheostat-progress", + key: "progress-bar-".concat(idx), + style: _this7.getProgressStyle(idx) + }); + }), PitComponent && pitPoints.map(function (n) { + var pos = getPosition(n, min, max); + var pitStyle = orientation === 'vertical' ? { + top: "".concat(pos, "%"), + position: 'absolute' + } : { + left: "".concat(pos, "%"), + position: 'absolute' + }; + return (0, _preact.h)(PitComponent, { + key: "pit-".concat(n), + style: pitStyle + }, n); + }), children); + } + }]); + + return Rheostat; +}(_preact.Component); + +_defineProperty(Rheostat, "defaultProps", { + className: '', + children: null, + disabled: false, + handle: Button, + max: PERCENT_FULL, + min: PERCENT_EMPTY, + onClick: null, + onChange: null, + onKeyPress: null, + onSliderDragEnd: null, + onSliderDragMove: null, + onSliderDragStart: null, + onValuesUpdated: null, + orientation: 'horizontal', + pitComponent: null, + pitPoints: [], + progressBar: 'div', + snap: false, + snapPoints: [], + values: [PERCENT_EMPTY] +}); + +var _default = Rheostat; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Slider/Slider.js b/js/instantsearch.js/cjs/components/Slider/Slider.js new file mode 100644 index 00000000..cfdb4de9 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Slider/Slider.js @@ -0,0 +1,186 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Rheostat = _interopRequireDefault(require("./Rheostat")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _Pit = _interopRequireDefault(require("./Pit")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +function _extends() { _extends = Object.assign || 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); } + +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); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var Slider = /*#__PURE__*/function (_Component) { + _inherits(Slider, _Component); + + var _super = _createSuper(Slider); + + function Slider() { + var _this; + + _classCallCheck(this, Slider); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (_ref) { + var values = _ref.values; + + if (!_this.isDisabled) { + _this.props.refine(values); + } + }); + + _defineProperty(_assertThisInitialized(_this), "createHandleComponent", function (tooltips) { + return function (props) { + // display only two decimals after comma, + // and apply `tooltips.format()` if any + var roundedValue = Math.round( // have to cast as a string, as the value given to the prop is a number, but becomes a string when read + parseFloat(props['aria-valuenow']) * 100) / 100; + var value = _typeof(tooltips) === 'object' && tooltips.format ? tooltips.format(roundedValue) : roundedValue; + var className = (0, _classnames.default)(props.className, { + 'rheostat-handle-lower': props['data-handle-key'] === 0, + 'rheostat-handle-upper': props['data-handle-key'] === 1 + }); + return (0, _preact.h)("div", _extends({}, props, { + className: className + }), tooltips && (0, _preact.h)("div", { + className: "rheostat-tooltip" + }, value)); + }; + }); + + return _this; + } + + _createClass(Slider, [{ + key: "isDisabled", + get: function get() { + return this.props.min >= this.props.max; + } + }, { + key: "computeDefaultPitPoints", + value: // creates an array number where to display a pit point on the slider + function computeDefaultPitPoints(_ref2) { + var min = _ref2.min, + max = _ref2.max; + var totalLength = max - min; + var steps = 34; + var stepsLength = totalLength / steps; + var pitPoints = [min].concat(_toConsumableArray((0, _utils.range)({ + end: steps - 1 + }).map(function (step) { + return min + stepsLength * (step + 1); + })), [max]); + return pitPoints; + } // creates an array of values where the slider should snap to + + }, { + key: "computeSnapPoints", + value: function computeSnapPoints(_ref3) { + var min = _ref3.min, + max = _ref3.max, + step = _ref3.step; + if (!step) return undefined; + return [].concat(_toConsumableArray((0, _utils.range)({ + start: min, + end: max, + step: step + })), [max]); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + tooltips = _this$props.tooltips, + step = _this$props.step, + pips = _this$props.pips, + values = _this$props.values, + cssClasses = _this$props.cssClasses; // @TODO: figure out why this.props needs to be non-null asserted + + var _ref4 = this.isDisabled ? { + min: this.props.min, + max: this.props.max + 0.001 + } : this.props, + min = _ref4.min, + max = _ref4.max; + + var snapPoints = this.computeSnapPoints({ + min: min, + max: max, + step: step + }); + var pitPoints = pips === false ? [] : this.computeDefaultPitPoints({ + min: min, + max: max + }); + return (0, _preact.h)("div", { + className: (0, _classnames.default)(cssClasses.root, _defineProperty({}, cssClasses.disabledRoot, this.isDisabled)) + }, (0, _preact.h)(_Rheostat.default, { + handle: this.createHandleComponent(tooltips), + onChange: this.handleChange, + min: min, + max: max, + pitComponent: _Pit.default, + pitPoints: pitPoints, + snap: true, + snapPoints: snapPoints, + values: this.isDisabled ? [min, max] : values, + disabled: this.isDisabled + })); + } + }]); + + return Slider; +}(_preact.Component); + +var _default = Slider; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Stats/Stats.js b/js/instantsearch.js/cjs/components/Stats/Stats.js new file mode 100644 index 00000000..e9fb2915 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Stats/Stats.js @@ -0,0 +1,58 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var Stats = function Stats(_ref) { + var nbHits = _ref.nbHits, + nbSortedHits = _ref.nbSortedHits, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps, + rest = _objectWithoutProperties(_ref, ["nbHits", "nbSortedHits", "cssClasses", "templateProps"]); + + return (0, _preact.h)("div", { + className: (0, _classnames.default)(cssClasses.root) + }, (0, _preact.h)(_Template.default, _extends({}, templateProps, { + templateKey: "text", + rootTagName: "span", + rootProps: { + className: cssClasses.text + }, + data: _objectSpread({ + hasManySortedResults: nbSortedHits && nbSortedHits > 1, + hasNoSortedResults: nbSortedHits === 0, + hasOneSortedResults: nbSortedHits === 1, + hasManyResults: nbHits > 1, + hasNoResults: nbHits === 0, + hasOneResult: nbHits === 1, + nbHits: nbHits, + nbSortedHits: nbSortedHits, + cssClasses: cssClasses + }, rest) + }))); +}; + +var _default = Stats; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/Template/Template.js b/js/instantsearch.js/cjs/components/Template/Template.js new file mode 100644 index 00000000..935f5148 --- /dev/null +++ b/js/instantsearch.js/cjs/components/Template/Template.js @@ -0,0 +1,98 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _utils = require("../../lib/utils"); + +function _extends() { _extends = Object.assign || 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); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var defaultProps = { + data: {}, + rootTagName: 'div', + useCustomCompileOptions: {}, + templates: {}, + templatesConfig: {} +}; + +// @TODO: Template should be a generic and receive TData to pass to Templates (to avoid TTemplateData to be set as `any`) +var Template = /*#__PURE__*/function (_Component) { + _inherits(Template, _Component); + + var _super = _createSuper(Template); + + function Template() { + _classCallCheck(this, Template); + + return _super.apply(this, arguments); + } + + _createClass(Template, [{ + key: "shouldComponentUpdate", + value: function shouldComponentUpdate(nextProps) { + return !(0, _utils.isEqual)(this.props.data, nextProps.data) || this.props.templateKey !== nextProps.templateKey || !(0, _utils.isEqual)(this.props.rootProps, nextProps.rootProps); + } + }, { + key: "render", + value: function render() { + var RootTagName = this.props.rootTagName; + var useCustomCompileOptions = this.props.useCustomCompileOptions[this.props.templateKey]; + var compileOptions = useCustomCompileOptions ? this.props.templatesConfig.compileOptions : {}; + var content = (0, _utils.renderTemplate)({ + templates: this.props.templates, + templateKey: this.props.templateKey, + compileOptions: compileOptions, + helpers: this.props.templatesConfig.helpers, + data: this.props.data, + bindEvent: this.props.bindEvent + }); + + if (content === null) { + // Adds a noscript to the DOM but virtual DOM is null + // See http://facebook.github.io/react/docs/component-specs.html#render + return null; + } + + return (0, _preact.h)(RootTagName, _extends({}, this.props.rootProps, { + dangerouslySetInnerHTML: { + __html: content + } + })); + } + }]); + + return Template; +}(_preact.Component); + +_defineProperty(Template, "defaultProps", defaultProps); + +var _default = Template; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/ToggleRefinement/ToggleRefinement.js b/js/instantsearch.js/cjs/components/ToggleRefinement/ToggleRefinement.js new file mode 100644 index 00000000..605a9fd3 --- /dev/null +++ b/js/instantsearch.js/cjs/components/ToggleRefinement/ToggleRefinement.js @@ -0,0 +1,45 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +var ToggleRefinement = function ToggleRefinement(_ref) { + var currentRefinement = _ref.currentRefinement, + refine = _ref.refine, + cssClasses = _ref.cssClasses, + templateProps = _ref.templateProps; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)("label", { + className: cssClasses.label + }, (0, _preact.h)("input", { + className: cssClasses.checkbox, + type: "checkbox", + checked: currentRefinement.isRefined, + onChange: function onChange(event) { + return refine({ + isRefined: !event.target.checked + }); + } + }), (0, _preact.h)(_Template.default, _extends({}, templateProps, { + rootTagName: "span", + rootProps: { + className: cssClasses.labelText + }, + templateKey: "labelText", + data: currentRefinement + })))); +}; + +var _default = ToggleRefinement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/components/VoiceSearch/VoiceSearch.js b/js/instantsearch.js/cjs/components/VoiceSearch/VoiceSearch.js new file mode 100644 index 00000000..51c28c1e --- /dev/null +++ b/js/instantsearch.js/cjs/components/VoiceSearch/VoiceSearch.js @@ -0,0 +1,74 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _Template = _interopRequireDefault(require("../Template/Template")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** @jsx h */ +var VoiceSearch = function VoiceSearch(_ref) { + var cssClasses = _ref.cssClasses, + isBrowserSupported = _ref.isBrowserSupported, + isListening = _ref.isListening, + toggleListening = _ref.toggleListening, + voiceListeningState = _ref.voiceListeningState, + templates = _ref.templates; + + var handleClick = function handleClick(event) { + if (event.currentTarget instanceof HTMLElement) { + event.currentTarget.blur(); + } + + toggleListening(); + }; + + var status = voiceListeningState.status, + transcript = voiceListeningState.transcript, + isSpeechFinal = voiceListeningState.isSpeechFinal, + errorCode = voiceListeningState.errorCode; + return (0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)(_Template.default, { + templateKey: "buttonText", + rootTagName: "button", + rootProps: { + className: cssClasses.button, + type: 'button', + title: "Search by voice".concat(isBrowserSupported ? '' : ' (not supported on this browser)'), + onClick: handleClick, + disabled: !isBrowserSupported + }, + data: { + status: status, + errorCode: errorCode, + isListening: isListening, + transcript: transcript, + isSpeechFinal: isSpeechFinal, + isBrowserSupported: isBrowserSupported + }, + templates: templates + }), (0, _preact.h)(_Template.default, { + templateKey: "status", + rootProps: { + className: cssClasses.status + }, + data: { + status: status, + errorCode: errorCode, + isListening: isListening, + transcript: transcript, + isSpeechFinal: isSpeechFinal, + isBrowserSupported: isBrowserSupported + }, + templates: templates + })); +}; + +var _default = VoiceSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/answers/connectAnswers.js b/js/instantsearch.js/cjs/connectors/answers/connectAnswers.js new file mode 100644 index 00000000..8d162e6d --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/answers/connectAnswers.js @@ -0,0 +1,146 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function hasFindAnswersMethod(answersIndex) { + return typeof answersIndex.findAnswers === 'function'; +} + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'answers', + connector: true +}); + +var connectAnswers = function connectAnswers(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + queryLanguages = _ref.queryLanguages, + attributesForPrediction = _ref.attributesForPrediction, + _ref$nbHits = _ref.nbHits, + nbHits = _ref$nbHits === void 0 ? 1 : _ref$nbHits, + _ref$renderDebounceTi = _ref.renderDebounceTime, + renderDebounceTime = _ref$renderDebounceTi === void 0 ? 100 : _ref$renderDebounceTi, + _ref$searchDebounceTi = _ref.searchDebounceTime, + searchDebounceTime = _ref$searchDebounceTi === void 0 ? 100 : _ref$searchDebounceTi, + _ref$escapeHTML = _ref.escapeHTML, + escapeHTML = _ref$escapeHTML === void 0 ? true : _ref$escapeHTML, + _ref$extraParameters = _ref.extraParameters, + extraParameters = _ref$extraParameters === void 0 ? {} : _ref$extraParameters; // @ts-ignore checking for the wrong value + + + if (!queryLanguages || queryLanguages.length === 0) { + throw new Error(withUsage('The `queryLanguages` expects an array of strings.')); + } + + var runConcurrentSafePromise = (0, _utils.createConcurrentSafePromise)(); + var lastResult; + var isLoading = false; + var debouncedRender = (0, _utils.debounce)(renderFn, renderDebounceTime); // this does not directly use DebouncedFunction, since then the generic will disappear + + var debouncedRefine; + return { + $$type: 'ais.answers', + init: function init(initOptions) { + var state = initOptions.state, + instantSearchInstance = initOptions.instantSearchInstance; + var answersIndex = instantSearchInstance.client.initIndex(state.index); + + if (!hasFindAnswersMethod(answersIndex)) { + throw new Error(withUsage('`algoliasearch` >= 4.8.0 required.')); + } + + debouncedRefine = (0, _utils.debounce)(answersIndex.findAnswers, searchDebounceTime); + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var _this = this; + + var query = renderOptions.state.query; + + if (!query) { + // renders nothing with empty query + lastResult = {}; + isLoading = false; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + return; + } // render the loader + + + lastResult = {}; + isLoading = true; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); // call /answers API + + runConcurrentSafePromise(debouncedRefine(query, queryLanguages, _objectSpread(_objectSpread({}, extraParameters), {}, { + nbHits: nbHits, + attributesForPrediction: attributesForPrediction + }))).then(function (results) { + if (!results) { + // It's undefined when it's debounced. + return; + } + + if (escapeHTML && results.hits.length > 0) { + results.hits = (0, _utils.escapeHits)(results.hits); + } + + var initialEscaped = results.hits.__escaped; + results.hits = (0, _utils.addAbsolutePosition)(results.hits, 0, nbHits); + results.hits = (0, _utils.addQueryID)(results.hits, results.queryID); // Make sure the escaped tag stays, even after mapping over the hits. + // This prevents the hits from being double-escaped if there are multiple + // hits widgets mounted on the page. + + results.hits.__escaped = initialEscaped; + lastResult = results; + isLoading = false; + debouncedRender(_objectSpread(_objectSpread({}, _this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + answers: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState() { + var _lastResult; + + return { + hits: ((_lastResult = lastResult) === null || _lastResult === void 0 ? void 0 : _lastResult.hits) || [], + isLoading: isLoading, + widgetParams: widgetParams + }; + }, + dispose: function dispose(_ref2) { + var state = _ref2.state; + unmountFn(); + return state; + }, + getWidgetSearchParameters: function getWidgetSearchParameters(state) { + return state; + } + }; + }; +}; + +var _default = connectAnswers; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/autocomplete/connectAutocomplete.js b/js/instantsearch.js/cjs/connectors/autocomplete/connectAutocomplete.js new file mode 100644 index 00000000..d2640379 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/autocomplete/connectAutocomplete.js @@ -0,0 +1,138 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'autocomplete', + connector: true +}); + +var connectAutocomplete = function connectAutocomplete(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + _ref$escapeHTML = _ref.escapeHTML, + escapeHTML = _ref$escapeHTML === void 0 ? true : _ref$escapeHTML; + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(!widgetParams.indices, "\nThe option `indices` has been removed from the Autocomplete connector.\n\nThe indices to target are now inferred from the widgets tree.\n".concat(Array.isArray(widgetParams.indices) ? "\nAn alternative would be:\n\nconst autocomplete = connectAutocomplete(renderer);\n\nsearch.addWidgets([\n ".concat(widgetParams.indices.map(function (_ref2) { + var value = _ref2.value; + return "index({ indexName: '".concat(value, "' }),"); + }).join('\n '), "\n autocomplete()\n]);\n") : '', "\n ")) : void 0; + var connectorState = {}; + return { + $$type: 'ais.autocomplete', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + var renderState = this.getWidgetRenderState(renderOptions); + renderState.indices.forEach(function (_ref3) { + var sendEvent = _ref3.sendEvent, + hits = _ref3.hits; + sendEvent('view', hits); + }); + renderFn(_objectSpread(_objectSpread({}, renderState), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + autocomplete: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref4) { + var _this = this; + + var helper = _ref4.helper, + scopedResults = _ref4.scopedResults, + instantSearchInstance = _ref4.instantSearchInstance; + + if (!connectorState.refine) { + connectorState.refine = function (query) { + helper.setQuery(query).search(); + }; + } + + var indices = scopedResults.map(function (scopedResult) { + // We need to escape the hits because highlighting + // exposes HTML tags to the end-user. + scopedResult.results.hits = escapeHTML ? (0, _utils.escapeHits)(scopedResult.results.hits) : scopedResult.results.hits; + var sendEvent = (0, _utils.createSendEventForHits)({ + instantSearchInstance: instantSearchInstance, + index: scopedResult.results.index, + widgetType: _this.$$type + }); + return { + indexId: scopedResult.indexId, + indexName: scopedResult.results.index, + hits: scopedResult.results.hits, + results: scopedResult.results, + sendEvent: sendEvent + }; + }); + return { + currentRefinement: helper.state.query || '', + indices: indices, + refine: connectorState.refine, + widgetParams: widgetParams + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref5) { + var searchParameters = _ref5.searchParameters; + var query = searchParameters.query || ''; + + if (query === '' || uiState && uiState.query === query) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + query: query + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) { + var uiState = _ref6.uiState; + var parameters = { + query: uiState.query || '' + }; + + if (!escapeHTML) { + return searchParameters.setQueryParameters(parameters); + } + + return searchParameters.setQueryParameters(_objectSpread(_objectSpread({}, parameters), _utils.TAG_PLACEHOLDER)); + }, + dispose: function dispose(_ref7) { + var state = _ref7.state; + unmountFn(); + var stateWithoutQuery = state.setQueryParameter('query', undefined); + + if (!escapeHTML) { + return stateWithoutQuery; + } + + return stateWithoutQuery.setQueryParameters(Object.keys(_utils.TAG_PLACEHOLDER).reduce(function (acc, key) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, undefined)); + }, {})); + } + }; + }; +}; + +var _default = connectAutocomplete; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/breadcrumb/connectBreadcrumb.js b/js/instantsearch.js/cjs/connectors/breadcrumb/connectBreadcrumb.js new file mode 100644 index 00000000..ad130231 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/breadcrumb/connectBreadcrumb.js @@ -0,0 +1,175 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'breadcrumb', + connector: true +}); + +var connectBreadcrumb = function connectBreadcrumb(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + var connectorState = {}; + return function (widgetParams) { + var _ref = widgetParams || {}, + attributes = _ref.attributes, + _ref$separator = _ref.separator, + separator = _ref$separator === void 0 ? ' > ' : _ref$separator, + _ref$rootPath = _ref.rootPath, + rootPath = _ref$rootPath === void 0 ? null : _ref$rootPath, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (!attributes || !Array.isArray(attributes) || attributes.length === 0) { + throw new Error(withUsage('The `attributes` option expects an array of strings.')); + } + + var _attributes = _slicedToArray(attributes, 1), + hierarchicalFacetName = _attributes[0]; + + function getRefinedState(state, facetValue) { + if (!facetValue) { + var breadcrumb = state.getHierarchicalFacetBreadcrumb(hierarchicalFacetName); + + if (breadcrumb.length > 0) { + return state.resetPage().toggleFacetRefinement(hierarchicalFacetName, breadcrumb[0]); + } + } + + return state.resetPage().toggleFacetRefinement(hierarchicalFacetName, facetValue); + } + + return { + $$type: 'ais.breadcrumb', + init: function init(initOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }, + dispose: function dispose() { + unmountFn(); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + breadcrumb: _objectSpread(_objectSpread({}, renderState.breadcrumb), {}, _defineProperty({}, hierarchicalFacetName, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var helper = _ref2.helper, + createURL = _ref2.createURL, + results = _ref2.results, + state = _ref2.state; + + function getItems() { + if (!results) { + return []; + } + + var _state$hierarchicalFa = _slicedToArray(state.hierarchicalFacets, 1), + facetName = _state$hierarchicalFa[0].name; + + var facetValues = results.getFacetValues(facetName, {}); + var data = Array.isArray(facetValues.data) ? facetValues.data : []; + var items = transformItems(shiftItemsValues(prepareItems(data))); + return items; + } + + var items = getItems(); + + if (!connectorState.createURL) { + connectorState.createURL = function (facetValue) { + return createURL(getRefinedState(helper.state, facetValue)); + }; + } + + if (!connectorState.refine) { + connectorState.refine = function (facetValue) { + helper.setState(getRefinedState(helper.state, facetValue)).search(); + }; + } + + return { + canRefine: items.length > 0, + createURL: connectorState.createURL, + items: items, + refine: connectorState.refine, + widgetParams: widgetParams + }; + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters) { + if (searchParameters.isHierarchicalFacet(hierarchicalFacetName)) { + var facet = searchParameters.getHierarchicalFacetByName(hierarchicalFacetName); + process.env.NODE_ENV === 'development' ? (0, _utils.warning)((0, _utils.isEqual)(facet.attributes, attributes) && facet.separator === separator && facet.rootPath === rootPath, 'Using Breadcrumb and HierarchicalMenu on the same facet with different options overrides the configuration of the HierarchicalMenu.') : void 0; + return searchParameters; + } + + return searchParameters.addHierarchicalFacet({ + name: hierarchicalFacetName, + attributes: attributes, + separator: separator, + rootPath: rootPath + }); + } + }; + }; +}; + +function prepareItems(data) { + return data.reduce(function (result, currentItem) { + if (currentItem.isRefined) { + result.push({ + label: currentItem.name, + value: currentItem.path + }); + + if (Array.isArray(currentItem.data)) { + result = result.concat(prepareItems(currentItem.data)); + } + } + + return result; + }, []); +} + +function shiftItemsValues(array) { + return array.map(function (x, idx) { + return { + label: x.label, + value: idx + 1 === array.length ? null : array[idx + 1].value + }; + }); +} + +var _default = connectBreadcrumb; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/clear-refinements/connectClearRefinements.js b/js/instantsearch.js/cjs/connectors/clear-refinements/connectClearRefinements.js new file mode 100644 index 00000000..9cae06ea --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/clear-refinements/connectClearRefinements.js @@ -0,0 +1,163 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'clear-refinements', + connector: true +}); + +var connectClearRefinements = function connectClearRefinements(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + _ref$includedAttribut = _ref.includedAttributes, + includedAttributes = _ref$includedAttribut === void 0 ? [] : _ref$includedAttribut, + _ref$excludedAttribut = _ref.excludedAttributes, + excludedAttributes = _ref$excludedAttribut === void 0 ? ['query'] : _ref$excludedAttribut, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (widgetParams && widgetParams.includedAttributes && widgetParams.excludedAttributes) { + throw new Error(withUsage('The options `includedAttributes` and `excludedAttributes` cannot be used together.')); + } + + var connectorState = { + refine: _utils.noop, + createURL: function createURL() { + return ''; + }, + attributesToClear: [] + }; + + var cachedRefine = function cachedRefine() { + return connectorState.refine(); + }; + + var cachedCreateURL = function cachedCreateURL() { + return connectorState.createURL(); + }; + + return { + $$type: 'ais.clearRefinements', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose() { + unmountFn(); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + clearRefinements: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var createURL = _ref2.createURL, + scopedResults = _ref2.scopedResults; + connectorState.attributesToClear = scopedResults.reduce(function (results, scopedResult) { + return results.concat(getAttributesToClear({ + scopedResult: scopedResult, + includedAttributes: includedAttributes, + excludedAttributes: excludedAttributes, + transformItems: transformItems + })); + }, []); + + connectorState.refine = function () { + connectorState.attributesToClear.forEach(function (_ref3) { + var indexHelper = _ref3.helper, + items = _ref3.items; + indexHelper.setState((0, _utils.clearRefinements)({ + helper: indexHelper, + attributesToClear: items + })).search(); + }); + }; + + connectorState.createURL = function () { + return createURL(_utils.mergeSearchParameters.apply(void 0, _toConsumableArray(connectorState.attributesToClear.map(function (_ref4) { + var indexHelper = _ref4.helper, + items = _ref4.items; + return (0, _utils.clearRefinements)({ + helper: indexHelper, + attributesToClear: items + }); + })))); + }; + + var canRefine = connectorState.attributesToClear.some(function (attributeToClear) { + return attributeToClear.items.length > 0; + }); + return { + canRefine: canRefine, + hasRefinements: canRefine, + refine: cachedRefine, + createURL: cachedCreateURL, + widgetParams: widgetParams + }; + } + }; + }; +}; + +function getAttributesToClear(_ref5) { + var scopedResult = _ref5.scopedResult, + includedAttributes = _ref5.includedAttributes, + excludedAttributes = _ref5.excludedAttributes, + transformItems = _ref5.transformItems; + var includesQuery = includedAttributes.indexOf('query') !== -1 || excludedAttributes.indexOf('query') === -1; + return { + helper: scopedResult.helper, + items: transformItems((0, _utils.uniq)((0, _utils.getRefinements)(scopedResult.results, scopedResult.helper.state, includesQuery).map(function (refinement) { + return refinement.attribute; + }).filter(function (attribute) { + return (// If the array is empty (default case), we keep all the attributes + includedAttributes.length === 0 || // Otherwise, only add the specified attributes + includedAttributes.indexOf(attribute) !== -1 + ); + }).filter(function (attribute) { + return (// If the query is included, we ignore the default `excludedAttributes = ['query']` + attribute === 'query' && includesQuery || // Otherwise, ignore the excluded attributes + excludedAttributes.indexOf(attribute) === -1 + ); + }))) + }; +} + +var _default = connectClearRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js b/js/instantsearch.js/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js new file mode 100644 index 00000000..3414bafe --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js @@ -0,0 +1,107 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper")); + +var _utils = require("../../lib/utils"); + +var _connectConfigure = _interopRequireDefault(require("../configure/connectConfigure")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'configure-related-items', + connector: true +}); + +function createOptionalFilter(_ref) { + var attributeName = _ref.attributeName, + attributeValue = _ref.attributeValue, + attributeScore = _ref.attributeScore; + return "".concat(attributeName, ":").concat(attributeValue, ""); +} + +var connectConfigureRelatedItems = function connectConfigureRelatedItems(renderFn, unmountFn) { + return function (widgetParams) { + var _ref2 = widgetParams || {}, + hit = _ref2.hit, + matchingPatterns = _ref2.matchingPatterns, + _ref2$transformSearch = _ref2.transformSearchParameters, + transformSearchParameters = _ref2$transformSearch === void 0 ? function (x) { + return x; + } : _ref2$transformSearch; + + if (!hit) { + throw new Error(withUsage('The `hit` option is required.')); + } + + if (!matchingPatterns) { + throw new Error(withUsage('The `matchingPatterns` option is required.')); + } + + var optionalFilters = Object.keys(matchingPatterns).reduce(function (acc, attributeName) { + var attribute = matchingPatterns[attributeName]; + var attributeValue = (0, _utils.getPropertyByPath)(hit, attributeName); + var attributeScore = attribute.score; + + if (Array.isArray(attributeValue)) { + return [].concat(_toConsumableArray(acc), [attributeValue.map(function (attributeSubValue) { + return createOptionalFilter({ + attributeName: attributeName, + attributeValue: attributeSubValue, + attributeScore: attributeScore + }); + })]); + } + + if (typeof attributeValue === 'string') { + return [].concat(_toConsumableArray(acc), [createOptionalFilter({ + attributeName: attributeName, + attributeValue: attributeValue, + attributeScore: attributeScore + })]); + } + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "\nThe `matchingPatterns` option returned a value of type ".concat((0, _utils.getObjectType)(attributeValue), " for the \"").concat(attributeName, "\" key. This value was not sent to Algolia because `optionalFilters` only supports strings and array of strings.\n\nYou can remove the \"").concat(attributeName, "\" key from the `matchingPatterns` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/\n ")) : void 0; + return acc; + }, []); + + var searchParameters = _objectSpread({}, transformSearchParameters(new _algoliasearchHelper.default.SearchParameters({ + sumOrFiltersScores: true, + facetFilters: ["objectID:-".concat(hit.objectID)], + optionalFilters: optionalFilters + }))); + + var makeWidget = (0, _connectConfigure.default)(renderFn, unmountFn); + return _objectSpread(_objectSpread({}, makeWidget({ + searchParameters: searchParameters + })), {}, { + $$type: 'ais.configureRelatedItems' + }); + }; +}; + +var _default = connectConfigureRelatedItems; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/configure/connectConfigure.js b/js/instantsearch.js/cjs/connectors/configure/connectConfigure.js new file mode 100644 index 00000000..3b398d92 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/configure/connectConfigure.js @@ -0,0 +1,113 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper")); + +var _utils = require("../../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'configure', + connector: true +}); + +function getInitialSearchParameters(state, widgetParams) { + // We leverage the helper internals to remove the `widgetParams` from + // the state. The function `setQueryParameters` omits the values that + // are `undefined` on the next state. + return state.setQueryParameters(Object.keys(widgetParams.searchParameters).reduce(function (acc, key) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, undefined)); + }, {})); +} + +var connectConfigure = function connectConfigure() { + var renderFn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _utils.noop; + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + return function (widgetParams) { + if (!widgetParams || !(0, _utils.isPlainObject)(widgetParams.searchParameters)) { + throw new Error(withUsage('The `searchParameters` option expects an object.')); + } + + var connectorState = {}; + + function refine(helper) { + return function (searchParameters) { + // Merge new `searchParameters` with the ones set from other widgets + var actualState = getInitialSearchParameters(helper.state, widgetParams); + var nextSearchParameters = (0, _utils.mergeSearchParameters)(actualState, new _algoliasearchHelper.default.SearchParameters(searchParameters)); // Update original `widgetParams.searchParameters` to the new refined one + + widgetParams.searchParameters = searchParameters; // Trigger a search with the resolved search parameters + + helper.setState(nextSearchParameters).search(); + }; + } + + return { + $$type: 'ais.configure', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref) { + var state = _ref.state; + unmountFn(); + return getInitialSearchParameters(state, widgetParams); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + var _renderState$configur; + + var widgetRenderState = this.getWidgetRenderState(renderOptions); + return _objectSpread(_objectSpread({}, renderState), {}, { + configure: _objectSpread(_objectSpread({}, widgetRenderState), {}, { + widgetParams: _objectSpread(_objectSpread({}, widgetRenderState.widgetParams), {}, { + searchParameters: (0, _utils.mergeSearchParameters)(new _algoliasearchHelper.default.SearchParameters((_renderState$configur = renderState.configure) === null || _renderState$configur === void 0 ? void 0 : _renderState$configur.widgetParams.searchParameters), new _algoliasearchHelper.default.SearchParameters(widgetRenderState.widgetParams.searchParameters)).getQueryParams() + }) + }) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var helper = _ref2.helper; + + if (!connectorState.refine) { + connectorState.refine = refine(helper); + } + + return { + refine: connectorState.refine, + widgetParams: widgetParams + }; + }, + getWidgetSearchParameters: function getWidgetSearchParameters(state, _ref3) { + var uiState = _ref3.uiState; + return (0, _utils.mergeSearchParameters)(state, new _algoliasearchHelper.default.SearchParameters(_objectSpread(_objectSpread({}, uiState.configure), widgetParams.searchParameters))); + }, + getWidgetUiState: function getWidgetUiState(uiState) { + return _objectSpread(_objectSpread({}, uiState), {}, { + configure: _objectSpread(_objectSpread({}, uiState.configure), widgetParams.searchParameters) + }); + } + }; + }; +}; + +var _default = connectConfigure; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/current-refinements/connectCurrentRefinements.js b/js/instantsearch.js/cjs/connectors/current-refinements/connectCurrentRefinements.js new file mode 100644 index 00000000..9d555bbb --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/current-refinements/connectCurrentRefinements.js @@ -0,0 +1,219 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'current-refinements', + connector: true +}); + +var connectCurrentRefinements = function connectCurrentRefinements(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + if ((widgetParams || {}).includedAttributes && (widgetParams || {}).excludedAttributes) { + throw new Error(withUsage('The options `includedAttributes` and `excludedAttributes` cannot be used together.')); + } + + var _ref = widgetParams || {}, + includedAttributes = _ref.includedAttributes, + _ref$excludedAttribut = _ref.excludedAttributes, + excludedAttributes = _ref$excludedAttribut === void 0 ? ['query'] : _ref$excludedAttribut, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + return { + $$type: 'ais.currentRefinements', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose() { + unmountFn(); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + currentRefinements: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var results = _ref2.results, + scopedResults = _ref2.scopedResults, + _createURL = _ref2.createURL, + helper = _ref2.helper; + + function getItems() { + if (!results) { + return transformItems(getRefinementsItems({ + results: {}, + helper: helper, + includedAttributes: includedAttributes, + excludedAttributes: excludedAttributes + })); + } + + return scopedResults.reduce(function (accResults, scopedResult) { + return accResults.concat(transformItems(getRefinementsItems({ + results: scopedResult.results, + helper: scopedResult.helper, + includedAttributes: includedAttributes, + excludedAttributes: excludedAttributes + }))); + }, []); + } + + var items = getItems(); + return { + items: items, + canRefine: items.length > 0, + refine: function refine(refinement) { + return clearRefinement(helper, refinement); + }, + createURL: function createURL(refinement) { + return _createURL(clearRefinementFromState(helper.state, refinement)); + }, + widgetParams: widgetParams + }; + } + }; + }; +}; + +function getRefinementsItems(_ref3) { + var results = _ref3.results, + helper = _ref3.helper, + includedAttributes = _ref3.includedAttributes, + excludedAttributes = _ref3.excludedAttributes; + var includesQuery = (includedAttributes || []).indexOf('query') !== -1 || (excludedAttributes || []).indexOf('query') === -1; + var filterFunction = includedAttributes ? function (item) { + return includedAttributes.indexOf(item.attribute) !== -1; + } : function (item) { + return excludedAttributes.indexOf(item.attribute) === -1; + }; + var items = (0, _utils.getRefinements)(results, helper.state, includesQuery).map(normalizeRefinement).filter(filterFunction); + return items.reduce(function (allItems, currentItem) { + return [].concat(_toConsumableArray(allItems.filter(function (item) { + return item.attribute !== currentItem.attribute; + })), [{ + indexName: helper.state.index, + attribute: currentItem.attribute, + label: currentItem.attribute, + refinements: items.filter(function (result) { + return result.attribute === currentItem.attribute; + }) // We want to keep the order of refinements except the numeric ones. + .sort(function (a, b) { + return a.type === 'numeric' ? a.value - b.value : 0; + }), + refine: function refine(refinement) { + return clearRefinement(helper, refinement); + } + }]); + }, []); +} + +function clearRefinementFromState(state, refinement) { + switch (refinement.type) { + case 'facet': + return state.removeFacetRefinement(refinement.attribute, String(refinement.value)); + + case 'disjunctive': + return state.removeDisjunctiveFacetRefinement(refinement.attribute, String(refinement.value)); + + case 'hierarchical': + return state.removeHierarchicalFacetRefinement(refinement.attribute); + + case 'exclude': + return state.removeExcludeRefinement(refinement.attribute, String(refinement.value)); + + case 'numeric': + return state.removeNumericRefinement(refinement.attribute, refinement.operator, String(refinement.value)); + + case 'tag': + return state.removeTagRefinement(String(refinement.value)); + + case 'query': + return state.setQueryParameter('query', ''); + + default: + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "The refinement type \"".concat(refinement.type, "\" does not exist and cannot be cleared from the current refinements.")) : void 0; + return state; + } +} + +function clearRefinement(helper, refinement) { + helper.setState(clearRefinementFromState(helper.state, refinement)).search(); +} + +function getOperatorSymbol(operator) { + switch (operator) { + case '>=': + return '≥'; + + case '<=': + return '≤'; + + default: + return operator; + } +} + +function normalizeRefinement(refinement) { + var value = refinement.type === 'numeric' ? Number(refinement.name) : refinement.name; + var label = refinement.operator ? "".concat(getOperatorSymbol(refinement.operator), " ").concat(refinement.name) : refinement.name; + var normalizedRefinement = { + attribute: refinement.attribute, + type: refinement.type, + value: value, + label: label + }; + + if (refinement.operator !== undefined) { + normalizedRefinement.operator = refinement.operator; + } + + if (refinement.count !== undefined) { + normalizedRefinement.count = refinement.count; + } + + if (refinement.exhaustive !== undefined) { + normalizedRefinement.exhaustive = refinement.exhaustive; + } + + return normalizedRefinement; +} + +var _default = connectCurrentRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js b/js/instantsearch.js/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js new file mode 100644 index 00000000..1f5e8a77 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js @@ -0,0 +1,140 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +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); } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'dynamic-widgets', + connector: true +}); + +var connectDynamicWidgets = function connectDynamicWidgets(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var widgets = widgetParams.widgets, + _widgetParams$transfo = widgetParams.transformItems, + transformItems = _widgetParams$transfo === void 0 ? function (items) { + return items; + } : _widgetParams$transfo; + + if (!widgets || !Array.isArray(widgets) || widgets.some(function (widget) { + return _typeof(widget) !== 'object'; + })) { + throw new Error(withUsage('The `widgets` option expects an array of widgets.')); + } + + if (!widgets || !Array.isArray(widgets) || widgets.some(function (widget) { + return _typeof(widget) !== 'object'; + })) { + throw new Error(withUsage('The `widgets` option expects an array of widgets.')); + } + + var localWidgets = new Map(); + return { + $$type: 'ais.dynamicWidgets', + init: function init(initOptions) { + widgets.forEach(function (widget) { + var attribute = (0, _utils.getWidgetAttribute)(widget, initOptions); + localWidgets.set(attribute, { + widget: widget, + isMounted: true + }); + }); + initOptions.parent.addWidgets(widgets); + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var parent = renderOptions.parent; + var renderState = this.getWidgetRenderState(renderOptions); + var widgetsToUnmount = []; + var widgetsToMount = []; + localWidgets.forEach(function (_ref, attribute) { + var widget = _ref.widget, + isMounted = _ref.isMounted; + var shouldMount = renderState.attributesToRender.indexOf(attribute) > -1; + + if (!isMounted && shouldMount) { + widgetsToMount.push(widget); + localWidgets.set(attribute, { + widget: widget, + isMounted: true + }); + } else if (isMounted && !shouldMount) { + widgetsToUnmount.push(widget); + localWidgets.set(attribute, { + widget: widget, + isMounted: false + }); + } + }); + parent.addWidgets(widgetsToMount); // make sure this only happens after the regular render, otherwise it + // happens too quick, since render is "deferred" for the next microtask, + // so this needs to be a whole task later + + setTimeout(function () { + return parent.removeWidgets(widgetsToUnmount); + }, 0); + renderFn(_objectSpread(_objectSpread({}, renderState), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }, + dispose: function dispose(_ref2) { + var parent = _ref2.parent; + var toRemove = []; + localWidgets.forEach(function (_ref3) { + var widget = _ref3.widget, + isMounted = _ref3.isMounted; + + if (isMounted) { + toRemove.push(widget); + } + }); + parent.removeWidgets(toRemove); + unmountFn(); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + dynamicWidgets: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref4) { + var _results$renderingCon, _results$renderingCon2, _results$renderingCon3, _results$renderingCon4; + + var results = _ref4.results; + + if (!results) { + return { + attributesToRender: [], + widgetParams: widgetParams + }; + } + + var attributesToRender = (_results$renderingCon = (_results$renderingCon2 = results.renderingContent) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.facetOrdering) === null || _results$renderingCon3 === void 0 ? void 0 : (_results$renderingCon4 = _results$renderingCon3.facets) === null || _results$renderingCon4 === void 0 ? void 0 : _results$renderingCon4.order) !== null && _results$renderingCon !== void 0 ? _results$renderingCon : []; + return { + attributesToRender: transformItems(attributesToRender, { + results: results + }), + widgetParams: widgetParams + }; + } + }; + }; +}; + +var _default = connectDynamicWidgets; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/geo-search/connectGeoSearch.js b/js/instantsearch.js/cjs/connectors/geo-search/connectGeoSearch.js new file mode 100644 index 00000000..9303165d --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/geo-search/connectGeoSearch.js @@ -0,0 +1,235 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'geo-search', + connector: true +}); // in this connector, we assume insideBoundingBox is only a string, +// even though in the helper it's defined as number[][] alone. +// This can be done, since the connector assumes "control" of the parameter + +function getBoundingBoxAsString(state) { + return state.insideBoundingBox || ''; +} + +function setBoundingBoxAsString(state, value) { + return state.setQueryParameter('insideBoundingBox', value); +} + +var $$type = 'ais.geoSearch'; + +/** + * The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example). + * + * @requirements + * + * Note that the GeoSearch connector uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia. Your hits **must** have a `_geoloc` attribute in order to be passed to the rendering function. + * + * Currently, the feature is not compatible with multiple values in the _geoloc attribute. + */ +var connectGeoSearch = function connectGeoSearch(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + _ref$enableRefineOnMa = _ref.enableRefineOnMapMove, + enableRefineOnMapMove = _ref$enableRefineOnMa === void 0 ? true : _ref$enableRefineOnMa, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + var widgetState = { + isRefineOnMapMove: enableRefineOnMapMove, + // @MAJOR hasMapMoveSinceLastRefine -> hasMapMovedSinceLastRefine + hasMapMoveSinceLastRefine: false, + lastRefinePosition: '', + lastRefineBoundingBox: '', + internalToggleRefineOnMapMove: _utils.noop, + internalSetMapMoveSinceLastRefine: _utils.noop + }; + + var getPositionFromState = function getPositionFromState(state) { + return state.aroundLatLng ? (0, _utils.aroundLatLngToPosition)(state.aroundLatLng) : undefined; + }; + + var getCurrentRefinementFromState = function getCurrentRefinementFromState(state) { + return state.insideBoundingBox && (0, _utils.insideBoundingBoxToBoundingBox)(state.insideBoundingBox); + }; + + var refine = function refine(helper) { + return function (_ref2) { + var ne = _ref2.northEast, + sw = _ref2.southWest; + var boundingBox = [ne.lat, ne.lng, sw.lat, sw.lng].join(); + helper.setState(setBoundingBoxAsString(helper.state, boundingBox).resetPage()).search(); + widgetState.hasMapMoveSinceLastRefine = false; + widgetState.lastRefineBoundingBox = boundingBox; + }; + }; + + var clearMapRefinement = function clearMapRefinement(helper) { + return function () { + helper.setQueryParameter('insideBoundingBox', undefined).search(); + }; + }; + + var isRefinedWithMap = function isRefinedWithMap(state) { + return function () { + return Boolean(state.insideBoundingBox); + }; + }; + + var toggleRefineOnMapMove = function toggleRefineOnMapMove() { + return widgetState.internalToggleRefineOnMapMove(); + }; + + var createInternalToggleRefinementOnMapMove = function createInternalToggleRefinementOnMapMove(renderOptions, render) { + return function () { + widgetState.isRefineOnMapMove = !widgetState.isRefineOnMapMove; + render(renderOptions); + }; + }; + + var isRefineOnMapMove = function isRefineOnMapMove() { + return widgetState.isRefineOnMapMove; + }; + + var setMapMoveSinceLastRefine = function setMapMoveSinceLastRefine() { + return widgetState.internalSetMapMoveSinceLastRefine(); + }; + + var createInternalSetMapMoveSinceLastRefine = function createInternalSetMapMoveSinceLastRefine(renderOptions, render) { + return function () { + var shouldTriggerRender = widgetState.hasMapMoveSinceLastRefine !== true; + widgetState.hasMapMoveSinceLastRefine = true; + + if (shouldTriggerRender) { + render(renderOptions); + } + }; + }; + + var hasMapMoveSinceLastRefine = function hasMapMoveSinceLastRefine() { + return widgetState.hasMapMoveSinceLastRefine; + }; + + var sendEvent; + return { + $$type: $$type, + init: function init(initArgs) { + var instantSearchInstance = initArgs.instantSearchInstance; + var isFirstRendering = true; + widgetState.internalToggleRefineOnMapMove = createInternalToggleRefinementOnMapMove(initArgs, _utils.noop); + widgetState.internalSetMapMoveSinceLastRefine = createInternalSetMapMoveSinceLastRefine(initArgs, _utils.noop); + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initArgs)), {}, { + instantSearchInstance: instantSearchInstance + }), isFirstRendering); + }, + render: function render(renderArgs) { + var helper = renderArgs.helper, + instantSearchInstance = renderArgs.instantSearchInstance; + var isFirstRendering = false; // We don't use the state provided by the render function because we need + // to be sure that the state is the latest one for the following condition + + var state = helper.state; + var positionChangedSinceLastRefine = Boolean(state.aroundLatLng) && Boolean(widgetState.lastRefinePosition) && state.aroundLatLng !== widgetState.lastRefinePosition; + var boundingBoxChangedSinceLastRefine = !state.insideBoundingBox && Boolean(widgetState.lastRefineBoundingBox) && state.insideBoundingBox !== widgetState.lastRefineBoundingBox; + + if (positionChangedSinceLastRefine || boundingBoxChangedSinceLastRefine) { + widgetState.hasMapMoveSinceLastRefine = false; + } + + widgetState.lastRefinePosition = state.aroundLatLng || ''; + widgetState.lastRefineBoundingBox = getBoundingBoxAsString(state); + widgetState.internalToggleRefineOnMapMove = createInternalToggleRefinementOnMapMove(renderArgs, this.render.bind(this)); + widgetState.internalSetMapMoveSinceLastRefine = createInternalSetMapMoveSinceLastRefine(renderArgs, this.render.bind(this)); + var widgetRenderState = this.getWidgetRenderState(renderArgs); + sendEvent('view', widgetRenderState.items); + renderFn(_objectSpread(_objectSpread({}, widgetRenderState), {}, { + instantSearchInstance: instantSearchInstance + }), isFirstRendering); + }, + getWidgetRenderState: function getWidgetRenderState(renderOptions) { + var helper = renderOptions.helper, + results = renderOptions.results, + instantSearchInstance = renderOptions.instantSearchInstance; + var state = helper.state; + var items = results ? transformItems(results.hits.filter(function (hit) { + return hit._geoloc; + })) : []; + + if (!sendEvent) { + sendEvent = (0, _utils.createSendEventForHits)({ + instantSearchInstance: instantSearchInstance, + index: helper.getIndex(), + widgetType: $$type + }); + } + + return { + items: items, + position: getPositionFromState(state), + currentRefinement: getCurrentRefinementFromState(state), + refine: refine(helper), + sendEvent: sendEvent, + clearMapRefinement: clearMapRefinement(helper), + isRefinedWithMap: isRefinedWithMap(state), + toggleRefineOnMapMove: toggleRefineOnMapMove, + isRefineOnMapMove: isRefineOnMapMove, + setMapMoveSinceLastRefine: setMapMoveSinceLastRefine, + hasMapMoveSinceLastRefine: hasMapMoveSinceLastRefine, + widgetParams: widgetParams + }; + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + geoSearch: this.getWidgetRenderState(renderOptions) + }); + }, + dispose: function dispose(_ref3) { + var state = _ref3.state; + unmountFn(); + return state.setQueryParameter('insideBoundingBox', undefined); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref4) { + var searchParameters = _ref4.searchParameters; + var boundingBox = getBoundingBoxAsString(searchParameters); + + if (!boundingBox || uiState && uiState.geoSearch && uiState.geoSearch.boundingBox === boundingBox) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + geoSearch: { + boundingBox: boundingBox + } + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) { + var uiState = _ref5.uiState; + + if (!uiState || !uiState.geoSearch) { + return searchParameters.setQueryParameter('insideBoundingBox', undefined); + } + + return setBoundingBoxAsString(searchParameters, uiState.geoSearch.boundingBox); + } + }; + }; +}; + +var _default = connectGeoSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js b/js/instantsearch.js/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js new file mode 100644 index 00000000..49e12048 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js @@ -0,0 +1,264 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hierarchical-menu', + connector: true +}); +var DEFAULT_SORT = ['name:asc']; + +/** + * **HierarchicalMenu** connector provides the logic to build a custom widget + * that will give the user the ability to explore facets in a tree-like structure. + * + * This is commonly used for multi-level categorization of products on e-commerce + * websites. From a UX point of view, we suggest not displaying more than two + * levels deep. + * + * @type {Connector} + * @param {function(HierarchicalMenuRenderingOptions, boolean)} renderFn Rendering function for the custom **HierarchicalMenu** widget. + * @param {function} unmountFn Unmount function called when the widget is disposed. + * @return {function(CustomHierarchicalMenuWidgetParams)} Re-usable widget factory for a custom **HierarchicalMenu** widget. + */ +var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + attributes = _ref.attributes, + _ref$separator = _ref.separator, + separator = _ref$separator === void 0 ? ' > ' : _ref$separator, + _ref$rootPath = _ref.rootPath, + rootPath = _ref$rootPath === void 0 ? null : _ref$rootPath, + _ref$showParentLevel = _ref.showParentLevel, + showParentLevel = _ref$showParentLevel === void 0 ? true : _ref$showParentLevel, + _ref$limit = _ref.limit, + limit = _ref$limit === void 0 ? 10 : _ref$limit, + _ref$showMore = _ref.showMore, + showMore = _ref$showMore === void 0 ? false : _ref$showMore, + _ref$showMoreLimit = _ref.showMoreLimit, + showMoreLimit = _ref$showMoreLimit === void 0 ? 20 : _ref$showMoreLimit, + _ref$sortBy = _ref.sortBy, + sortBy = _ref$sortBy === void 0 ? DEFAULT_SORT : _ref$sortBy, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (!attributes || !Array.isArray(attributes) || attributes.length === 0) { + throw new Error(withUsage('The `attributes` option expects an array of strings.')); + } + + if (showMore === true && showMoreLimit <= limit) { + throw new Error(withUsage('The `showMoreLimit` option must be greater than `limit`.')); + } + + // we need to provide a hierarchicalFacet name for the search state + // so that we can always map $hierarchicalFacetName => real attributes + // we use the first attribute name + var _attributes = _slicedToArray(attributes, 1), + hierarchicalFacetName = _attributes[0]; + + var sendEvent; // Provide the same function to the `renderFn` so that way the user + // has to only bind it once when `isFirstRendering` for instance + + var toggleShowMore = function toggleShowMore() {}; + + function cachedToggleShowMore() { + toggleShowMore(); + } + + var _refine; + + var isShowingMore = false; + + function createToggleShowMore(renderOptions, widget) { + return function () { + isShowingMore = !isShowingMore; + widget.render(renderOptions); + }; + } + + function getLimit() { + return isShowingMore ? showMoreLimit : limit; + } + + function _prepareFacetValues(facetValues) { + return facetValues.slice(0, getLimit()).map(function (_ref2) { + var label = _ref2.name, + value = _ref2.path, + data = _ref2.data, + subValue = _objectWithoutProperties(_ref2, ["name", "path", "data"]); + + var item = _objectSpread(_objectSpread({}, subValue), {}, { + label: label, + value: value, + data: null + }); + + if (Array.isArray(data)) { + item.data = _prepareFacetValues(data); + } + + return item; + }); + } + + return { + $$type: 'ais.hierarchicalMenu', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + toggleShowMore = createToggleShowMore(renderOptions, this); + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref3) { + var state = _ref3.state; + unmountFn(); + return state.removeHierarchicalFacet(hierarchicalFacetName).setQueryParameter('maxValuesPerFacet', undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + hierarchicalMenu: _objectSpread(_objectSpread({}, renderState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref4) { + var results = _ref4.results, + state = _ref4.state, + createURL = _ref4.createURL, + instantSearchInstance = _ref4.instantSearchInstance, + helper = _ref4.helper; + var items = []; + var canToggleShowMore = false; // Bind createURL to this specific attribute + + function _createURL(facetValue) { + return createURL(state.resetPage().toggleFacetRefinement(hierarchicalFacetName, facetValue)); + } + + if (!sendEvent) { + sendEvent = (0, _utils.createSendEventForFacet)({ + instantSearchInstance: instantSearchInstance, + helper: helper, + attribute: hierarchicalFacetName, + widgetType: this.$$type + }); + } + + if (!_refine) { + _refine = function _refine(facetValue) { + sendEvent('click', facetValue); + helper.toggleFacetRefinement(hierarchicalFacetName, facetValue).search(); + }; + } + + if (results) { + var facetValues = results.getFacetValues(hierarchicalFacetName, { + sortBy: sortBy, + facetOrdering: sortBy === DEFAULT_SORT + }); + var facetItems = facetValues && !Array.isArray(facetValues) && facetValues.data ? facetValues.data : []; // If the limit is the max number of facet retrieved it is impossible to know + // if the facets are exhaustive. The only moment we are sure it is exhaustive + // is when it is strictly under the number requested unless we know that another + // widget has requested more values (maxValuesPerFacet > getLimit()). + // Because this is used for making the search of facets unable or not, it is important + // to be conservative here. + + var hasExhaustiveItems = (state.maxValuesPerFacet || 0) > getLimit() ? facetItems.length <= getLimit() : facetItems.length < getLimit(); + canToggleShowMore = showMore && (isShowingMore || !hasExhaustiveItems); + items = transformItems(_prepareFacetValues(facetItems)); + } + + return { + items: items, + refine: _refine, + canRefine: items.length > 0, + createURL: _createURL, + sendEvent: sendEvent, + widgetParams: widgetParams, + isShowingMore: isShowingMore, + toggleShowMore: cachedToggleShowMore, + canToggleShowMore: canToggleShowMore + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref5) { + var searchParameters = _ref5.searchParameters; + var path = searchParameters.getHierarchicalFacetBreadcrumb(hierarchicalFacetName); + + if (!path.length) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + hierarchicalMenu: _objectSpread(_objectSpread({}, uiState.hierarchicalMenu), {}, _defineProperty({}, hierarchicalFacetName, path)) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) { + var uiState = _ref6.uiState; + var values = uiState.hierarchicalMenu && uiState.hierarchicalMenu[hierarchicalFacetName]; + + if (searchParameters.isHierarchicalFacet(hierarchicalFacetName)) { + var facet = searchParameters.getHierarchicalFacetByName(hierarchicalFacetName); + process.env.NODE_ENV === 'development' ? (0, _utils.warning)((0, _utils.isEqual)(facet.attributes, attributes) && facet.separator === separator && facet.rootPath === rootPath, 'Using Breadcrumb and HierarchicalMenu on the same facet with different options overrides the configuration of the HierarchicalMenu.') : void 0; + } + + var withFacetConfiguration = searchParameters.removeHierarchicalFacet(hierarchicalFacetName).addHierarchicalFacet({ + name: hierarchicalFacetName, + attributes: attributes, + separator: separator, + rootPath: rootPath, + // @ts-ignore `showParentLevel` is missing in the SearchParameters.HierarchicalFacet declaration + showParentLevel: showParentLevel + }); + var currentMaxValuesPerFacet = withFacetConfiguration.maxValuesPerFacet || 0; + var nextMaxValuesPerFacet = Math.max(currentMaxValuesPerFacet, showMore ? showMoreLimit : limit); + var withMaxValuesPerFacet = withFacetConfiguration.setQueryParameter('maxValuesPerFacet', nextMaxValuesPerFacet); + + if (!values) { + return withMaxValuesPerFacet.setQueryParameters({ + hierarchicalFacetsRefinements: _objectSpread(_objectSpread({}, withMaxValuesPerFacet.hierarchicalFacetsRefinements), {}, _defineProperty({}, hierarchicalFacetName, [])) + }); + } + + return withMaxValuesPerFacet.addHierarchicalFacetRefinement(hierarchicalFacetName, values.join(separator)); + } + }; + }; +}; + +var _default = connectHierarchicalMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/hits-per-page/connectHitsPerPage.js b/js/instantsearch.js/cjs/connectors/hits-per-page/connectHitsPerPage.js new file mode 100644 index 00000000..bff78405 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/hits-per-page/connectHitsPerPage.js @@ -0,0 +1,164 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hits-per-page', + connector: true +}); + +var connectHitsPerPage = function connectHitsPerPage(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + userItems = _ref.items, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (!Array.isArray(userItems)) { + throw new Error(withUsage('The `items` option expects an array of objects.')); + } + + var items = userItems; + var defaultItems = items.filter(function (item) { + return item.default === true; + }); + + if (defaultItems.length === 0) { + throw new Error(withUsage("A default value must be specified in `items`.")); + } + + if (defaultItems.length > 1) { + throw new Error(withUsage('More than one default value is specified in `items`.')); + } + + var defaultItem = defaultItems[0]; + + var normalizeItems = function normalizeItems(_ref2) { + var hitsPerPage = _ref2.hitsPerPage; + return items.map(function (item) { + return _objectSpread(_objectSpread({}, item), {}, { + isRefined: Number(item.value) === Number(hitsPerPage) + }); + }); + }; + + var connectorState = { + getRefine: function getRefine(helper) { + return function (value) { + return !value && value !== 0 ? helper.setQueryParameter('hitsPerPage', undefined).search() : helper.setQueryParameter('hitsPerPage', value).search(); + }; + }, + createURLFactory: function createURLFactory(_ref3) { + var state = _ref3.state, + createURL = _ref3.createURL; + return function (value) { + return createURL(state.resetPage().setQueryParameter('hitsPerPage', !value && value !== 0 ? undefined : value)); + }; + } + }; + return { + $$type: 'ais.hitsPerPage', + init: function init(initOptions) { + var state = initOptions.state, + instantSearchInstance = initOptions.instantSearchInstance; + var isCurrentInOptions = items.some(function (item) { + return Number(state.hitsPerPage) === Number(item.value); + }); + + if (!isCurrentInOptions) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(state.hitsPerPage !== undefined, "\n`hitsPerPage` is not defined.\nThe option `hitsPerPage` needs to be set using the `configure` widget.\n\nLearn more: https://www.algolia.com/doc/api-reference/widgets/hits-per-page/js/\n ") : void 0; + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "\nThe `items` option of `hitsPerPage` does not contain the \"hits per page\" value coming from the state: ".concat(state.hitsPerPage, ".\n\nYou may want to add another entry to the `items` option with this value.")) : void 0; + items = [// The helper will convert the empty string to `undefined`. + { + value: '', + label: '' + }].concat(_toConsumableArray(items)); + } + + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref4) { + var state = _ref4.state; + unmountFn(); + return state.setQueryParameter('hitsPerPage', undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + hitsPerPage: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref5) { + var state = _ref5.state, + results = _ref5.results, + createURL = _ref5.createURL, + helper = _ref5.helper; + return { + items: transformItems(normalizeItems(state)), + refine: connectorState.getRefine(helper), + createURL: connectorState.createURLFactory({ + state: state, + createURL: createURL + }), + hasNoResults: results ? results.nbHits === 0 : true, + widgetParams: widgetParams + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref6) { + var searchParameters = _ref6.searchParameters; + var hitsPerPage = searchParameters.hitsPerPage; + + if (hitsPerPage === undefined || hitsPerPage === defaultItem.value) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + hitsPerPage: hitsPerPage + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref7) { + var uiState = _ref7.uiState; + return searchParameters.setQueryParameters({ + hitsPerPage: uiState.hitsPerPage || defaultItem.value + }); + } + }; + }; +}; + +var _default = connectHitsPerPage; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/hits/connectHits.js b/js/instantsearch.js/cjs/connectors/hits/connectHits.js new file mode 100644 index 00000000..7cb303f2 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/hits/connectHits.js @@ -0,0 +1,128 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hits', + connector: true +}); + +var connectHits = function connectHits(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + _ref$escapeHTML = _ref.escapeHTML, + escapeHTML = _ref$escapeHTML === void 0 ? true : _ref$escapeHTML, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + var sendEvent; + var bindEvent; + return { + $$type: 'ais.hits', + init: function init(initOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var renderState = this.getWidgetRenderState(renderOptions); + renderState.sendEvent('view', renderState.hits); + renderFn(_objectSpread(_objectSpread({}, renderState), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + hits: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var results = _ref2.results, + helper = _ref2.helper, + instantSearchInstance = _ref2.instantSearchInstance; + + if (!sendEvent) { + sendEvent = (0, _utils.createSendEventForHits)({ + instantSearchInstance: instantSearchInstance, + index: helper.getIndex(), + widgetType: this.$$type + }); + } + + if (!bindEvent) { + bindEvent = (0, _utils.createBindEventForHits)({ + index: helper.getIndex(), + widgetType: this.$$type + }); + } + + if (!results) { + return { + hits: [], + results: undefined, + sendEvent: sendEvent, + bindEvent: bindEvent, + widgetParams: widgetParams + }; + } + + if (escapeHTML && results.hits.length > 0) { + results.hits = (0, _utils.escapeHits)(results.hits); + } + + var initialEscaped = results.hits.__escaped; + results.hits = (0, _utils.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage); + results.hits = (0, _utils.addQueryID)(results.hits, results.queryID); + results.hits = transformItems(results.hits); // Make sure the escaped tag stays, even after mapping over the hits. + // This prevents the hits from being double-escaped if there are multiple + // hits widgets mounted on the page. + + results.hits.__escaped = initialEscaped; + return { + hits: results.hits, + results: results, + sendEvent: sendEvent, + bindEvent: bindEvent, + widgetParams: widgetParams + }; + }, + dispose: function dispose(_ref3) { + var state = _ref3.state; + unmountFn(); + + if (!escapeHTML) { + return state; + } + + return state.setQueryParameters(Object.keys(_utils.TAG_PLACEHOLDER).reduce(function (acc, key) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, undefined)); + }, {})); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(state) { + if (!escapeHTML) { + return state; + } + + return state.setQueryParameters(_utils.TAG_PLACEHOLDER); + } + }; + }; +}; + +var _default = connectHits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/hits/connectHitsWithInsights.js b/js/instantsearch.js/cjs/connectors/hits/connectHitsWithInsights.js new file mode 100644 index 00000000..b4f9b2f6 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/hits/connectHitsWithInsights.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _insights = require("../../lib/insights"); + +var _connectHits = _interopRequireDefault(require("./connectHits")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var connectHitsWithInsights = (0, _insights.withInsights)(_connectHits.default); +var _default = connectHitsWithInsights; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/index.js b/js/instantsearch.js/cjs/connectors/index.js new file mode 100644 index 00000000..6953169a --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/index.js @@ -0,0 +1,239 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "connectClearRefinements", { + enumerable: true, + get: function get() { + return _connectClearRefinements.default; + } +}); +Object.defineProperty(exports, "connectCurrentRefinements", { + enumerable: true, + get: function get() { + return _connectCurrentRefinements.default; + } +}); +Object.defineProperty(exports, "connectHierarchicalMenu", { + enumerable: true, + get: function get() { + return _connectHierarchicalMenu.default; + } +}); +Object.defineProperty(exports, "connectHits", { + enumerable: true, + get: function get() { + return _connectHits.default; + } +}); +Object.defineProperty(exports, "connectHitsWithInsights", { + enumerable: true, + get: function get() { + return _connectHitsWithInsights.default; + } +}); +Object.defineProperty(exports, "connectHitsPerPage", { + enumerable: true, + get: function get() { + return _connectHitsPerPage.default; + } +}); +Object.defineProperty(exports, "connectInfiniteHits", { + enumerable: true, + get: function get() { + return _connectInfiniteHits.default; + } +}); +Object.defineProperty(exports, "connectInfiniteHitsWithInsights", { + enumerable: true, + get: function get() { + return _connectInfiniteHitsWithInsights.default; + } +}); +Object.defineProperty(exports, "connectMenu", { + enumerable: true, + get: function get() { + return _connectMenu.default; + } +}); +Object.defineProperty(exports, "connectNumericMenu", { + enumerable: true, + get: function get() { + return _connectNumericMenu.default; + } +}); +Object.defineProperty(exports, "connectPagination", { + enumerable: true, + get: function get() { + return _connectPagination.default; + } +}); +Object.defineProperty(exports, "connectRange", { + enumerable: true, + get: function get() { + return _connectRange.default; + } +}); +Object.defineProperty(exports, "connectRefinementList", { + enumerable: true, + get: function get() { + return _connectRefinementList.default; + } +}); +Object.defineProperty(exports, "connectSearchBox", { + enumerable: true, + get: function get() { + return _connectSearchBox.default; + } +}); +Object.defineProperty(exports, "connectSortBy", { + enumerable: true, + get: function get() { + return _connectSortBy.default; + } +}); +Object.defineProperty(exports, "connectRatingMenu", { + enumerable: true, + get: function get() { + return _connectRatingMenu.default; + } +}); +Object.defineProperty(exports, "connectStats", { + enumerable: true, + get: function get() { + return _connectStats.default; + } +}); +Object.defineProperty(exports, "connectToggleRefinement", { + enumerable: true, + get: function get() { + return _connectToggleRefinement.default; + } +}); +Object.defineProperty(exports, "connectBreadcrumb", { + enumerable: true, + get: function get() { + return _connectBreadcrumb.default; + } +}); +Object.defineProperty(exports, "connectGeoSearch", { + enumerable: true, + get: function get() { + return _connectGeoSearch.default; + } +}); +Object.defineProperty(exports, "connectPoweredBy", { + enumerable: true, + get: function get() { + return _connectPoweredBy.default; + } +}); +Object.defineProperty(exports, "connectConfigure", { + enumerable: true, + get: function get() { + return _connectConfigure.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_connectConfigureRelatedItems", { + enumerable: true, + get: function get() { + return _connectConfigureRelatedItems.default; + } +}); +Object.defineProperty(exports, "connectAutocomplete", { + enumerable: true, + get: function get() { + return _connectAutocomplete.default; + } +}); +Object.defineProperty(exports, "connectQueryRules", { + enumerable: true, + get: function get() { + return _connectQueryRules.default; + } +}); +Object.defineProperty(exports, "connectVoiceSearch", { + enumerable: true, + get: function get() { + return _connectVoiceSearch.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_connectAnswers", { + enumerable: true, + get: function get() { + return _connectAnswers.default; + } +}); +Object.defineProperty(exports, "connectRelevantSort", { + enumerable: true, + get: function get() { + return _connectRelevantSort.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_connectDynamicWidgets", { + enumerable: true, + get: function get() { + return _connectDynamicWidgets.default; + } +}); + +var _connectClearRefinements = _interopRequireDefault(require("./clear-refinements/connectClearRefinements")); + +var _connectCurrentRefinements = _interopRequireDefault(require("./current-refinements/connectCurrentRefinements")); + +var _connectHierarchicalMenu = _interopRequireDefault(require("./hierarchical-menu/connectHierarchicalMenu")); + +var _connectHits = _interopRequireDefault(require("./hits/connectHits")); + +var _connectHitsWithInsights = _interopRequireDefault(require("./hits/connectHitsWithInsights")); + +var _connectHitsPerPage = _interopRequireDefault(require("./hits-per-page/connectHitsPerPage")); + +var _connectInfiniteHits = _interopRequireDefault(require("./infinite-hits/connectInfiniteHits")); + +var _connectInfiniteHitsWithInsights = _interopRequireDefault(require("./infinite-hits/connectInfiniteHitsWithInsights")); + +var _connectMenu = _interopRequireDefault(require("./menu/connectMenu")); + +var _connectNumericMenu = _interopRequireDefault(require("./numeric-menu/connectNumericMenu")); + +var _connectPagination = _interopRequireDefault(require("./pagination/connectPagination")); + +var _connectRange = _interopRequireDefault(require("./range/connectRange")); + +var _connectRefinementList = _interopRequireDefault(require("./refinement-list/connectRefinementList")); + +var _connectSearchBox = _interopRequireDefault(require("./search-box/connectSearchBox")); + +var _connectSortBy = _interopRequireDefault(require("./sort-by/connectSortBy")); + +var _connectRatingMenu = _interopRequireDefault(require("./rating-menu/connectRatingMenu")); + +var _connectStats = _interopRequireDefault(require("./stats/connectStats")); + +var _connectToggleRefinement = _interopRequireDefault(require("./toggle-refinement/connectToggleRefinement")); + +var _connectBreadcrumb = _interopRequireDefault(require("./breadcrumb/connectBreadcrumb")); + +var _connectGeoSearch = _interopRequireDefault(require("./geo-search/connectGeoSearch")); + +var _connectPoweredBy = _interopRequireDefault(require("./powered-by/connectPoweredBy")); + +var _connectConfigure = _interopRequireDefault(require("./configure/connectConfigure")); + +var _connectConfigureRelatedItems = _interopRequireDefault(require("./configure-related-items/connectConfigureRelatedItems")); + +var _connectAutocomplete = _interopRequireDefault(require("./autocomplete/connectAutocomplete")); + +var _connectQueryRules = _interopRequireDefault(require("./query-rules/connectQueryRules")); + +var _connectVoiceSearch = _interopRequireDefault(require("./voice-search/connectVoiceSearch")); + +var _connectAnswers = _interopRequireDefault(require("./answers/connectAnswers")); + +var _connectRelevantSort = _interopRequireDefault(require("./relevant-sort/connectRelevantSort")); + +var _connectDynamicWidgets = _interopRequireDefault(require("./dynamic-widgets/connectDynamicWidgets")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHits.js b/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHits.js new file mode 100644 index 00000000..572cf632 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHits.js @@ -0,0 +1,268 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'infinite-hits', + connector: true +}); + +function getStateWithoutPage(state) { + var _ref = state || {}, + page = _ref.page, + rest = _objectWithoutProperties(_ref, ["page"]); + + return rest; +} + +function getInMemoryCache() { + var cachedHits = null; + var cachedState = null; + return { + read: function read(_ref2) { + var state = _ref2.state; + return (0, _utils.isEqual)(cachedState, getStateWithoutPage(state)) ? cachedHits : null; + }, + write: function write(_ref3) { + var state = _ref3.state, + hits = _ref3.hits; + cachedState = getStateWithoutPage(state); + cachedHits = hits; + } + }; +} + +function extractHitsFromCachedHits(cachedHits) { + return Object.keys(cachedHits).map(Number).sort(function (a, b) { + return a - b; + }).reduce(function (acc, page) { + return acc.concat(cachedHits[page]); + }, []); +} + +var connectInfiniteHits = function connectInfiniteHits(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref4 = widgetParams || {}, + _ref4$escapeHTML = _ref4.escapeHTML, + escapeHTML = _ref4$escapeHTML === void 0 ? true : _ref4$escapeHTML, + _ref4$transformItems = _ref4.transformItems, + transformItems = _ref4$transformItems === void 0 ? function (items) { + return items; + } : _ref4$transformItems, + _ref4$cache = _ref4.cache, + cache = _ref4$cache === void 0 ? getInMemoryCache() : _ref4$cache; + + var showPrevious; + var showMore; + var sendEvent; + var bindEvent; + + var getFirstReceivedPage = function getFirstReceivedPage(state, cachedHits) { + var _state$page = state.page, + page = _state$page === void 0 ? 0 : _state$page; + var pages = Object.keys(cachedHits).map(Number); + + if (pages.length === 0) { + return page; + } else { + return Math.min.apply(Math, [page].concat(_toConsumableArray(pages))); + } + }; + + var getLastReceivedPage = function getLastReceivedPage(state, cachedHits) { + var _state$page2 = state.page, + page = _state$page2 === void 0 ? 0 : _state$page2; + var pages = Object.keys(cachedHits).map(Number); + + if (pages.length === 0) { + return page; + } else { + return Math.max.apply(Math, [page].concat(_toConsumableArray(pages))); + } + }; + + var getShowPrevious = function getShowPrevious(helper) { + return function () { + // Using the helper's `overrideStateWithoutTriggeringChangeEvent` method + // avoid updating the browser URL when the user displays the previous page. + helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, { + page: getFirstReceivedPage(helper.state, cache.read({ + state: helper.state + }) || {}) - 1 + })).searchWithoutTriggeringOnStateChange(); + }; + }; + + var getShowMore = function getShowMore(helper) { + return function () { + helper.setPage(getLastReceivedPage(helper.state, cache.read({ + state: helper.state + }) || {}) + 1).search(); + }; + }; + + return { + $$type: 'ais.infiniteHits', + init: function init(initOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + var widgetRenderState = this.getWidgetRenderState(renderOptions); + sendEvent('view', widgetRenderState.currentPageHits); + renderFn(_objectSpread(_objectSpread({}, widgetRenderState), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + infiniteHits: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref5) { + var results = _ref5.results, + helper = _ref5.helper, + state = _ref5.state, + instantSearchInstance = _ref5.instantSearchInstance; + var isFirstPage; + var currentPageHits = []; + var cachedHits = cache.read({ + state: state + }) || {}; + + if (!results) { + showPrevious = getShowPrevious(helper); + showMore = getShowMore(helper); + sendEvent = (0, _utils.createSendEventForHits)({ + instantSearchInstance: instantSearchInstance, + index: helper.getIndex(), + widgetType: this.$$type + }); + bindEvent = (0, _utils.createBindEventForHits)({ + index: helper.getIndex(), + widgetType: this.$$type + }); + isFirstPage = helper.state.page === undefined || getFirstReceivedPage(helper.state, cachedHits) === 0; + } else { + var _state$page3 = state.page, + _page = _state$page3 === void 0 ? 0 : _state$page3; + + if (escapeHTML && results.hits.length > 0) { + results.hits = (0, _utils.escapeHits)(results.hits); + } + + var initialEscaped = results.hits.__escaped; + results.hits = (0, _utils.addAbsolutePosition)(results.hits, results.page, results.hitsPerPage); + results.hits = (0, _utils.addQueryID)(results.hits, results.queryID); + results.hits = transformItems(results.hits); // Make sure the escaped tag stays after mapping over the hits. + // This prevents the hits from being double-escaped if there are multiple + // hits widgets mounted on the page. + + results.hits.__escaped = initialEscaped; + + if (cachedHits[_page] === undefined) { + cachedHits[_page] = results.hits; + cache.write({ + state: state, + hits: cachedHits + }); + } + + currentPageHits = results.hits; + isFirstPage = getFirstReceivedPage(state, cachedHits) === 0; + } + + var hits = extractHitsFromCachedHits(cachedHits); + var isLastPage = results ? results.nbPages <= getLastReceivedPage(state, cachedHits) + 1 : true; + return { + hits: hits, + currentPageHits: currentPageHits, + sendEvent: sendEvent, + bindEvent: bindEvent, + results: results, + showPrevious: showPrevious, + showMore: showMore, + isFirstPage: isFirstPage, + isLastPage: isLastPage, + widgetParams: widgetParams + }; + }, + dispose: function dispose(_ref6) { + var state = _ref6.state; + unmountFn(); + var stateWithoutPage = state.setQueryParameter('page', undefined); + + if (!escapeHTML) { + return stateWithoutPage; + } + + return stateWithoutPage.setQueryParameters(Object.keys(_utils.TAG_PLACEHOLDER).reduce(function (acc, key) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, undefined)); + }, {})); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref7) { + var searchParameters = _ref7.searchParameters; + var page = searchParameters.page || 0; + + if (!page) { + // return without adding `page` to uiState + // because we don't want `page=1` in the URL + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + // The page in the UI state is incremented by one + // to expose the user value (not `0`). + page: page + 1 + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref8) { + var uiState = _ref8.uiState; + var widgetSearchParameters = searchParameters; + + if (escapeHTML) { + widgetSearchParameters = searchParameters.setQueryParameters(_utils.TAG_PLACEHOLDER); + } // The page in the search parameters is decremented by one + // to get to the actual parameter value from the UI state. + + + var page = uiState.page ? uiState.page - 1 : 0; + return widgetSearchParameters.setQueryParameter('page', page); + } + }; + }; +}; + +var _default = connectInfiniteHits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js b/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js new file mode 100644 index 00000000..7e655cbb --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _insights = require("../../lib/insights"); + +var _connectInfiniteHits = _interopRequireDefault(require("./connectInfiniteHits")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var connectInfiniteHitsWithInsights = (0, _insights.withInsights)(_connectInfiniteHits.default); +var _default = connectInfiniteHitsWithInsights; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/menu/connectMenu.js b/js/instantsearch.js/cjs/connectors/menu/connectMenu.js new file mode 100644 index 00000000..1307e16d --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/menu/connectMenu.js @@ -0,0 +1,233 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'menu', + connector: true +}); +var DEFAULT_SORT = ['isRefined', 'name:asc']; + +/** + * **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories. + * + * This connector provides a `toggleShowMore()` function to display more or less items and a `refine()` + * function to select an item. While selecting a new element, the `refine` will also unselect the + * one that is currently selected. + * + * **Requirement:** the attribute passed as `attribute` must be present in "attributes for faceting" on the Algolia dashboard or configured as attributesForFaceting via a set settings call to the Algolia API. + */ +var connectMenu = function connectMenu(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + attribute = _ref.attribute, + _ref$limit = _ref.limit, + limit = _ref$limit === void 0 ? 10 : _ref$limit, + _ref$showMore = _ref.showMore, + showMore = _ref$showMore === void 0 ? false : _ref$showMore, + _ref$showMoreLimit = _ref.showMoreLimit, + showMoreLimit = _ref$showMoreLimit === void 0 ? 20 : _ref$showMoreLimit, + _ref$sortBy = _ref.sortBy, + sortBy = _ref$sortBy === void 0 ? DEFAULT_SORT : _ref$sortBy, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (!attribute) { + throw new Error(withUsage('The `attribute` option is required.')); + } + + if (showMore === true && showMoreLimit <= limit) { + throw new Error(withUsage('The `showMoreLimit` option must be greater than `limit`.')); + } + + var sendEvent; + + var _createURL; + + var _refine; // Provide the same function to the `renderFn` so that way the user + // has to only bind it once when `isFirstRendering` for instance + + + var isShowingMore = false; + + var toggleShowMore = function toggleShowMore() {}; + + function createToggleShowMore(renderOptions, widget) { + return function () { + isShowingMore = !isShowingMore; + widget.render(renderOptions); + }; + } + + function cachedToggleShowMore() { + toggleShowMore(); + } + + function getLimit() { + return isShowingMore ? showMoreLimit : limit; + } + + return { + $$type: 'ais.menu', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref2) { + var state = _ref2.state; + unmountFn(); + return state.removeHierarchicalFacet(attribute).setQueryParameter('maxValuesPerFacet', undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + menu: _objectSpread(_objectSpread({}, renderState.menu), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(renderOptions) { + var results = renderOptions.results, + createURL = renderOptions.createURL, + instantSearchInstance = renderOptions.instantSearchInstance, + helper = renderOptions.helper; + var items = []; + var canToggleShowMore = false; + + if (!sendEvent) { + sendEvent = (0, _utils.createSendEventForFacet)({ + instantSearchInstance: instantSearchInstance, + helper: helper, + attribute: attribute, + widgetType: this.$$type + }); + } + + if (!_createURL) { + _createURL = function _createURL(facetValue) { + return createURL(helper.state.resetPage().toggleFacetRefinement(attribute, facetValue)); + }; + } + + if (!_refine) { + _refine = function _refine(facetValue) { + var _helper$getHierarchic = helper.getHierarchicalFacetBreadcrumb(attribute), + _helper$getHierarchic2 = _slicedToArray(_helper$getHierarchic, 1), + refinedItem = _helper$getHierarchic2[0]; + + sendEvent('click', facetValue ? facetValue : refinedItem); + helper.toggleFacetRefinement(attribute, facetValue ? facetValue : refinedItem).search(); + }; + } + + if (renderOptions.results) { + toggleShowMore = createToggleShowMore(renderOptions, this); + } + + if (results) { + var facetValues = results.getFacetValues(attribute, { + sortBy: sortBy, + facetOrdering: sortBy === DEFAULT_SORT + }); + var facetItems = facetValues && !Array.isArray(facetValues) && facetValues.data ? facetValues.data : []; + canToggleShowMore = showMore && (isShowingMore || facetItems.length > getLimit()); + items = transformItems(facetItems.slice(0, getLimit()).map(function (_ref3) { + var label = _ref3.name, + value = _ref3.path, + item = _objectWithoutProperties(_ref3, ["name", "path"]); + + return _objectSpread(_objectSpread({}, item), {}, { + label: label, + value: value + }); + })); + } + + return { + items: items, + createURL: _createURL, + refine: _refine, + sendEvent: sendEvent, + canRefine: items.length > 0, + widgetParams: widgetParams, + isShowingMore: isShowingMore, + toggleShowMore: cachedToggleShowMore, + canToggleShowMore: canToggleShowMore + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref4) { + var searchParameters = _ref4.searchParameters; + + var _searchParameters$get = searchParameters.getHierarchicalFacetBreadcrumb(attribute), + _searchParameters$get2 = _slicedToArray(_searchParameters$get, 1), + value = _searchParameters$get2[0]; + + if (!value) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + menu: _objectSpread(_objectSpread({}, uiState.menu), {}, _defineProperty({}, attribute, value)) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) { + var uiState = _ref5.uiState; + var value = uiState.menu && uiState.menu[attribute]; + var withFacetConfiguration = searchParameters.removeHierarchicalFacet(attribute).addHierarchicalFacet({ + name: attribute, + attributes: [attribute] + }); + var currentMaxValuesPerFacet = withFacetConfiguration.maxValuesPerFacet || 0; + var nextMaxValuesPerFacet = Math.max(currentMaxValuesPerFacet, showMore ? showMoreLimit : limit); + var withMaxValuesPerFacet = withFacetConfiguration.setQueryParameter('maxValuesPerFacet', nextMaxValuesPerFacet); + + if (!value) { + return withMaxValuesPerFacet.setQueryParameters({ + hierarchicalFacetsRefinements: _objectSpread(_objectSpread({}, withMaxValuesPerFacet.hierarchicalFacetsRefinements), {}, _defineProperty({}, attribute, [])) + }); + } + + return withMaxValuesPerFacet.addHierarchicalFacetRefinement(attribute, value); + } + }; + }; +}; + +var _default = connectMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/numeric-menu/connectNumericMenu.js b/js/instantsearch.js/cjs/connectors/numeric-menu/connectNumericMenu.js new file mode 100644 index 00000000..d0cb3728 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/numeric-menu/connectNumericMenu.js @@ -0,0 +1,323 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'numeric-menu', + connector: true +}); +var $$type = 'ais.numericMenu'; + +var createSendEvent = function createSendEvent(_ref) { + var instantSearchInstance = _ref.instantSearchInstance, + helper = _ref.helper, + attribute = _ref.attribute; + return function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 1) { + instantSearchInstance.sendEventToInsights(args[0]); + return; + } + + var eventType = args[0], + facetValue = args[1], + _args$ = args[2], + eventName = _args$ === void 0 ? 'Filter Applied' : _args$; + + if (eventType !== 'click') { + return; + } // facetValue === "%7B%22start%22:5,%22end%22:10%7D" + + + var filters = (0, _utils.convertNumericRefinementsToFilters)(getRefinedState(helper.state, attribute, facetValue), attribute); + + if (filters && filters.length > 0) { + /* + filters === ["price<=10", "price>=5"] + */ + instantSearchInstance.sendEventToInsights({ + insightsMethod: 'clickedFilters', + widgetType: $$type, + eventType: eventType, + payload: { + eventName: eventName, + index: helper.getIndex(), + filters: filters + }, + attribute: attribute + }); + } + }; +}; + +var connectNumericMenu = function connectNumericMenu(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref2 = widgetParams || {}, + _ref2$attribute = _ref2.attribute, + attribute = _ref2$attribute === void 0 ? '' : _ref2$attribute, + _ref2$items = _ref2.items, + items = _ref2$items === void 0 ? [] : _ref2$items, + _ref2$transformItems = _ref2.transformItems, + transformItems = _ref2$transformItems === void 0 ? function (x) { + return x; + } : _ref2$transformItems; + + if (attribute === '') { + throw new Error(withUsage('The `attribute` option is required.')); + } + + if (!items || items.length === 0) { + throw new Error(withUsage('The `items` option expects an array of objects.')); + } + + var prepareItems = function prepareItems(state) { + return items.map(function (_ref3) { + var start = _ref3.start, + end = _ref3.end, + label = _ref3.label; + return { + label: label, + value: encodeURI(JSON.stringify({ + start: start, + end: end + })), + isRefined: isRefined(state, attribute, { + start: start, + end: end, + label: label + }) + }; + }); + }; + + var connectorState = {}; + return { + $$type: $$type, + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref4) { + var state = _ref4.state; + unmountFn(); + return state.clearRefinements(attribute); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref5) { + var searchParameters = _ref5.searchParameters; + var values = searchParameters.getNumericRefinements(attribute); + var equal = values['='] && values['='][0]; + + if (equal || equal === 0) { + return _objectSpread(_objectSpread({}, uiState), {}, { + numericMenu: _objectSpread(_objectSpread({}, uiState.numericMenu), {}, _defineProperty({}, attribute, "".concat(values['=']))) + }); + } + + var min = values['>='] && values['>='][0] || ''; + var max = values['<='] && values['<='][0] || ''; + + if (min === '' && max === '') { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + numericMenu: _objectSpread(_objectSpread({}, uiState.numericMenu), {}, _defineProperty({}, attribute, "".concat(min, ":").concat(max))) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) { + var uiState = _ref6.uiState; + var value = uiState.numericMenu && uiState.numericMenu[attribute]; + var withoutRefinements = searchParameters.clearRefinements(attribute); + + if (!value) { + return withoutRefinements.setQueryParameters({ + numericRefinements: _objectSpread(_objectSpread({}, withoutRefinements.numericRefinements), {}, _defineProperty({}, attribute, {})) + }); + } + + var isExact = value.indexOf(':') === -1; + + if (isExact) { + return withoutRefinements.addNumericRefinement(attribute, '=', Number(value)); + } + + var _value$split$map = value.split(':').map(parseFloat), + _value$split$map2 = _slicedToArray(_value$split$map, 2), + min = _value$split$map2[0], + max = _value$split$map2[1]; + + var withMinRefinement = (0, _utils.isFiniteNumber)(min) ? withoutRefinements.addNumericRefinement(attribute, '>=', min) : withoutRefinements; + var withMaxRefinement = (0, _utils.isFiniteNumber)(max) ? withMinRefinement.addNumericRefinement(attribute, '<=', max) : withMinRefinement; + return withMaxRefinement; + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + numericMenu: _objectSpread(_objectSpread({}, renderState.numericMenu), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref7) { + var results = _ref7.results, + state = _ref7.state, + instantSearchInstance = _ref7.instantSearchInstance, + helper = _ref7.helper, + createURL = _ref7.createURL; + + if (!connectorState.refine) { + connectorState.refine = function (facetValue) { + var refinedState = getRefinedState(helper.state, attribute, facetValue); + connectorState.sendEvent('click', facetValue); + helper.setState(refinedState).search(); + }; + } + + if (!connectorState.createURL) { + connectorState.createURL = function (newState) { + return function (facetValue) { + return createURL(getRefinedState(newState, attribute, facetValue)); + }; + }; + } + + if (!connectorState.sendEvent) { + connectorState.sendEvent = createSendEvent({ + instantSearchInstance: instantSearchInstance, + helper: helper, + attribute: attribute + }); + } + + return { + createURL: connectorState.createURL(state), + items: transformItems(prepareItems(state)), + hasNoResults: results ? results.nbHits === 0 : true, + refine: connectorState.refine, + sendEvent: connectorState.sendEvent, + widgetParams: widgetParams + }; + } + }; + }; +}; + +function isRefined(state, attribute, option) { + // @TODO: same as another spot, why is this mixing arrays & elements? + var currentRefinements = state.getNumericRefinements(attribute); + + if (option.start !== undefined && option.end !== undefined) { + if (option.start === option.end) { + return hasNumericRefinement(currentRefinements, '=', option.start); + } + } + + if (option.start !== undefined) { + return hasNumericRefinement(currentRefinements, '>=', option.start); + } + + if (option.end !== undefined) { + return hasNumericRefinement(currentRefinements, '<=', option.end); + } + + if (option.start === undefined && option.end === undefined) { + return Object.keys(currentRefinements).every(function (operator) { + return (currentRefinements[operator] || []).length === 0; + }); + } + + return false; +} + +function getRefinedState(state, attribute, facetValue) { + var resolvedState = state; + var refinedOption = JSON.parse(decodeURI(facetValue)); // @TODO: why is array / element mixed here & hasRefinements; seems wrong? + + var currentRefinements = resolvedState.getNumericRefinements(attribute); + + if (refinedOption.start === undefined && refinedOption.end === undefined) { + return resolvedState.removeNumericRefinement(attribute); + } + + if (!isRefined(resolvedState, attribute, refinedOption)) { + resolvedState = resolvedState.removeNumericRefinement(attribute); + } + + if (refinedOption.start !== undefined && refinedOption.end !== undefined) { + if (refinedOption.start > refinedOption.end) { + throw new Error('option.start should be > to option.end'); + } + + if (refinedOption.start === refinedOption.end) { + if (hasNumericRefinement(currentRefinements, '=', refinedOption.start)) { + resolvedState = resolvedState.removeNumericRefinement(attribute, '=', refinedOption.start); + } else { + resolvedState = resolvedState.addNumericRefinement(attribute, '=', refinedOption.start); + } + + return resolvedState; + } + } + + if (refinedOption.start !== undefined) { + if (hasNumericRefinement(currentRefinements, '>=', refinedOption.start)) { + resolvedState = resolvedState.removeNumericRefinement(attribute, '>=', refinedOption.start); + } else { + resolvedState = resolvedState.addNumericRefinement(attribute, '>=', refinedOption.start); + } + } + + if (refinedOption.end !== undefined) { + if (hasNumericRefinement(currentRefinements, '<=', refinedOption.end)) { + resolvedState = resolvedState.removeNumericRefinement(attribute, '<=', refinedOption.end); + } else { + resolvedState = resolvedState.addNumericRefinement(attribute, '<=', refinedOption.end); + } + } + + if (typeof resolvedState.page === 'number') { + resolvedState.page = 0; + } + + return resolvedState; +} + +function hasNumericRefinement(currentRefinements, operator, value) { + return currentRefinements[operator] !== undefined && currentRefinements[operator].includes(value); +} + +var _default = connectNumericMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/pagination/Paginator.js b/js/instantsearch.js/cjs/connectors/pagination/Paginator.js new file mode 100644 index 00000000..345a2e62 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/pagination/Paginator.js @@ -0,0 +1,91 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +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; } + +var Paginator = /*#__PURE__*/function () { + function Paginator(params) { + _classCallCheck(this, Paginator); + + _defineProperty(this, "currentPage", void 0); + + _defineProperty(this, "total", void 0); + + _defineProperty(this, "padding", void 0); + + this.currentPage = params.currentPage; + this.total = params.total; + this.padding = params.padding; + } + + _createClass(Paginator, [{ + key: "pages", + value: function pages() { + var total = this.total, + currentPage = this.currentPage, + padding = this.padding; + if (total === 0) return [0]; + var totalDisplayedPages = this.nbPagesDisplayed(padding, total); + + if (totalDisplayedPages === total) { + return (0, _utils.range)({ + end: total + }); + } + + var paddingLeft = this.calculatePaddingLeft(currentPage, padding, total, totalDisplayedPages); + var paddingRight = totalDisplayedPages - paddingLeft; + var first = currentPage - paddingLeft; + var last = currentPage + paddingRight; + return (0, _utils.range)({ + start: first, + end: last + }); + } + }, { + key: "nbPagesDisplayed", + value: function nbPagesDisplayed(padding, total) { + return Math.min(2 * padding + 1, total); + } + }, { + key: "calculatePaddingLeft", + value: function calculatePaddingLeft(current, padding, total, totalDisplayedPages) { + if (current <= padding) { + return current; + } + + if (current >= total - padding) { + return totalDisplayedPages - (total - current); + } + + return padding; + } + }, { + key: "isLastPage", + value: function isLastPage() { + return this.currentPage === this.total - 1 || this.total === 0; + } + }, { + key: "isFirstPage", + value: function isFirstPage() { + return this.currentPage === 0; + } + }]); + + return Paginator; +}(); + +var _default = Paginator; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/pagination/connectPagination.js b/js/instantsearch.js/cjs/connectors/pagination/connectPagination.js new file mode 100644 index 00000000..56191077 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/pagination/connectPagination.js @@ -0,0 +1,139 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +var _Paginator = _interopRequireDefault(require("./Paginator")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'pagination', + connector: true +}); + +/** + * **Pagination** connector provides the logic to build a widget that will let the user + * choose the current page of the results. + * + * When using the pagination with Algolia, you should be aware that the engine won't provide you pages + * beyond the 1000th hits by default. You can find more information on the [Algolia documentation](https://www.algolia.com/doc/guides/searching/pagination/#pagination-limitations). + */ +var connectPagination = function connectPagination(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + totalPages = _ref.totalPages, + _ref$padding = _ref.padding, + padding = _ref$padding === void 0 ? 3 : _ref$padding; + + var pager = new _Paginator.default({ + currentPage: 0, + total: 0, + padding: padding + }); + var connectorState = {}; + + function getMaxPage(_ref2) { + var nbPages = _ref2.nbPages; + return totalPages !== undefined ? Math.min(totalPages, nbPages) : nbPages; + } + + return { + $$type: 'ais.pagination', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref3) { + var state = _ref3.state; + unmountFn(); + return state.setQueryParameter('page', undefined); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref4) { + var searchParameters = _ref4.searchParameters; + var page = searchParameters.page || 0; + + if (!page) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + page: page + 1 + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) { + var uiState = _ref5.uiState; + var page = uiState.page ? uiState.page - 1 : 0; + return searchParameters.setQueryParameter('page', page); + }, + getWidgetRenderState: function getWidgetRenderState(_ref6) { + var results = _ref6.results, + helper = _ref6.helper, + createURL = _ref6.createURL; + + if (!connectorState.refine) { + connectorState.refine = function (page) { + helper.setPage(page); + helper.search(); + }; + } + + if (!connectorState.createURL) { + connectorState.createURL = function (state) { + return function (page) { + return createURL(state.setPage(page)); + }; + }; + } + + var state = helper.state; + var page = state.page || 0; + var nbPages = getMaxPage(results || { + nbPages: 0 + }); + pager.currentPage = page; + pager.total = nbPages; + return { + createURL: connectorState.createURL(state), + refine: connectorState.refine, + canRefine: nbPages > 1, + currentRefinement: page, + nbHits: (results === null || results === void 0 ? void 0 : results.nbHits) || 0, + nbPages: nbPages, + pages: results ? pager.pages() : [], + isFirstPage: pager.isFirstPage(), + isLastPage: pager.isLastPage(), + widgetParams: widgetParams + }; + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + pagination: this.getWidgetRenderState(renderOptions) + }); + } + }; + }; +}; + +var _default = connectPagination; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/powered-by/connectPoweredBy.js b/js/instantsearch.js/cjs/connectors/powered-by/connectPoweredBy.js new file mode 100644 index 00000000..3a0ce63e --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/powered-by/connectPoweredBy.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'powered-by', + connector: true +}); + +/** + * **PoweredBy** connector provides the logic to build a custom widget that will displays + * the logo to redirect to Algolia. + */ +var connectPoweredBy = function connectPoweredBy(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + var defaultUrl = 'https://www.algolia.com/?' + 'utm_source=instantsearch.js&' + 'utm_medium=website&' + "utm_content=".concat(typeof window !== 'undefined' && window.location ? window.location.hostname : '', "&") + 'utm_campaign=poweredby'; + return function (widgetParams) { + var _ref = widgetParams || {}, + _ref$url = _ref.url, + url = _ref$url === void 0 ? defaultUrl : _ref$url; + + return { + $$type: 'ais.poweredBy', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + poweredBy: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState() { + return { + url: url, + widgetParams: widgetParams + }; + }, + dispose: function dispose() { + unmountFn(); + } + }; + }; +}; + +var _default = connectPoweredBy; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/query-rules/connectQueryRules.js b/js/instantsearch.js/cjs/connectors/query-rules/connectQueryRules.js new file mode 100644 index 00000000..8198f891 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/query-rules/connectQueryRules.js @@ -0,0 +1,191 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'query-rules', + connector: true +}); + +function hasStateRefinements(state) { + return [state.disjunctiveFacetsRefinements, state.facetsRefinements, state.hierarchicalFacetsRefinements, state.numericRefinements].some(function (refinement) { + return Boolean(refinement && Object.keys(refinement).length > 0); + }); +} // A context rule must consist only of alphanumeric characters, hyphens, and underscores. +// See https://www.algolia.com/doc/guides/managing-results/refine-results/merchandising-and-promoting/in-depth/implementing-query-rules/#context + + +function escapeRuleContext(ruleName) { + return ruleName.replace(/[^a-z0-9-_]+/gi, '_'); +} + +function getRuleContextsFromTrackedFilters(_ref) { + var helper = _ref.helper, + sharedHelperState = _ref.sharedHelperState, + trackedFilters = _ref.trackedFilters; + var ruleContexts = Object.keys(trackedFilters).reduce(function (facets, facetName) { + var facetRefinements = (0, _utils.getRefinements)(helper.lastResults || {}, sharedHelperState, true).filter(function (refinement) { + return refinement.attribute === facetName; + }).map(function (refinement) { + return refinement.numericValue || refinement.name; + }); + var getTrackedFacetValues = trackedFilters[facetName]; + var trackedFacetValues = getTrackedFacetValues(facetRefinements); + return [].concat(_toConsumableArray(facets), _toConsumableArray(facetRefinements.filter(function (facetRefinement) { + return trackedFacetValues.includes(facetRefinement); + }).map(function (facetValue) { + return escapeRuleContext("ais-".concat(facetName, "-").concat(facetValue)); + }))); + }, []); + return ruleContexts; +} + +function applyRuleContexts(event) { + var helper = this.helper, + initialRuleContexts = this.initialRuleContexts, + trackedFilters = this.trackedFilters, + transformRuleContexts = this.transformRuleContexts; + var sharedHelperState = event.state; + var previousRuleContexts = sharedHelperState.ruleContexts || []; + var newRuleContexts = getRuleContextsFromTrackedFilters({ + helper: helper, + sharedHelperState: sharedHelperState, + trackedFilters: trackedFilters + }); + var nextRuleContexts = [].concat(_toConsumableArray(initialRuleContexts), _toConsumableArray(newRuleContexts)); + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(nextRuleContexts.length <= 10, "\nThe maximum number of `ruleContexts` is 10. They have been sliced to that limit.\nConsider using `transformRuleContexts` to minimize the number of rules sent to Algolia.\n") : void 0; + var ruleContexts = transformRuleContexts(nextRuleContexts).slice(0, 10); + + if (!(0, _utils.isEqual)(previousRuleContexts, ruleContexts)) { + helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, sharedHelperState), {}, { + ruleContexts: ruleContexts + })); + } +} + +var connectQueryRules = function connectQueryRules(_render) { + var unmount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(_render, withUsage()); + return function (widgetParams) { + var _ref2 = widgetParams || {}, + _ref2$trackedFilters = _ref2.trackedFilters, + trackedFilters = _ref2$trackedFilters === void 0 ? {} : _ref2$trackedFilters, + _ref2$transformRuleCo = _ref2.transformRuleContexts, + transformRuleContexts = _ref2$transformRuleCo === void 0 ? function (rules) { + return rules; + } : _ref2$transformRuleCo, + _ref2$transformItems = _ref2.transformItems, + transformItems = _ref2$transformItems === void 0 ? function (items) { + return items; + } : _ref2$transformItems; + + Object.keys(trackedFilters).forEach(function (facetName) { + if (typeof trackedFilters[facetName] !== 'function') { + throw new Error(withUsage("'The \"".concat(facetName, "\" filter value in the `trackedFilters` option expects a function."))); + } + }); + var hasTrackedFilters = Object.keys(trackedFilters).length > 0; // We store the initial rule contexts applied before creating the widget + // so that we do not override them with the rules created from `trackedFilters`. + + var initialRuleContexts = []; + var onHelperChange; + return { + $$type: 'ais.queryRules', + init: function init(initOptions) { + var helper = initOptions.helper, + state = initOptions.state, + instantSearchInstance = initOptions.instantSearchInstance; + initialRuleContexts = state.ruleContexts || []; + onHelperChange = applyRuleContexts.bind({ + helper: helper, + initialRuleContexts: initialRuleContexts, + trackedFilters: trackedFilters, + transformRuleContexts: transformRuleContexts + }); + + if (hasTrackedFilters) { + // We need to apply the `ruleContexts` based on the `trackedFilters` + // before the helper changes state in some cases: + // - Some filters are applied on the first load (e.g. using `configure`) + // - The `transformRuleContexts` option sets initial `ruleContexts`. + if (hasStateRefinements(state) || Boolean(widgetParams.transformRuleContexts)) { + onHelperChange({ + state: state + }); + } // We track every change in the helper to override its state and add + // any `ruleContexts` needed based on the `trackedFilters`. + + + helper.on('change', onHelperChange); + } + + _render(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + + _render(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getWidgetRenderState: function getWidgetRenderState(_ref3) { + var results = _ref3.results; + + var _ref4 = results || {}, + _ref4$userData = _ref4.userData, + userData = _ref4$userData === void 0 ? [] : _ref4$userData; + + var items = transformItems(userData); + return { + items: items, + widgetParams: widgetParams + }; + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + queryRules: this.getWidgetRenderState(renderOptions) + }); + }, + dispose: function dispose(_ref5) { + var helper = _ref5.helper, + state = _ref5.state; + unmount(); + + if (hasTrackedFilters) { + helper.removeListener('change', onHelperChange); + return state.setQueryParameter('ruleContexts', initialRuleContexts); + } + + return state; + } + }; + }; +}; + +var _default = connectQueryRules; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/range/connectRange.js b/js/instantsearch.js/cjs/connectors/range/connectRange.js new file mode 100644 index 00000000..f858f64a --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/range/connectRange.js @@ -0,0 +1,388 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'range-input', + connector: true +}, { + name: 'range-slider', + connector: true +}); +var $$type = 'ais.range'; + +function toPrecision(_ref) { + var min = _ref.min, + max = _ref.max, + precision = _ref.precision; + var pow = Math.pow(10, precision); + return { + min: min ? Math.floor(min * pow) / pow : min, + max: max ? Math.ceil(max * pow) / pow : max + }; +} +/** + * **Range** connector provides the logic to create custom widget that will let + * the user refine results using a numeric range. + * + * This connectors provides a `refine()` function that accepts bounds. It will also provide + * information about the min and max bounds for the current result set. + */ + + +var connectRange = function connectRange(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref2 = widgetParams || {}, + _ref2$attribute = _ref2.attribute, + attribute = _ref2$attribute === void 0 ? '' : _ref2$attribute, + minBound = _ref2.min, + maxBound = _ref2.max, + _ref2$precision = _ref2.precision, + precision = _ref2$precision === void 0 ? 0 : _ref2$precision; + + if (!attribute) { + throw new Error(withUsage('The `attribute` option is required.')); + } + + if ((0, _utils.isFiniteNumber)(minBound) && (0, _utils.isFiniteNumber)(maxBound) && minBound > maxBound) { + throw new Error(withUsage("The `max` option can't be lower than `min`.")); + } + + var formatToNumber = function formatToNumber(v) { + return Number(Number(v).toFixed(precision)); + }; + + var rangeFormatter = { + from: function from(v) { + return v.toLocaleString(); + }, + to: function to(v) { + return formatToNumber(v).toLocaleString(); + } + }; // eslint-disable-next-line complexity + + var getRefinedState = function getRefinedState(helper, currentRange, nextMin, nextMax) { + var resolvedState = helper.state; + var currentRangeMin = currentRange.min, + currentRangeMax = currentRange.max; + + var _ref3 = resolvedState.getNumericRefinement(attribute, '>=') || [], + _ref4 = _slicedToArray(_ref3, 1), + min = _ref4[0]; + + var _ref5 = resolvedState.getNumericRefinement(attribute, '<=') || [], + _ref6 = _slicedToArray(_ref5, 1), + max = _ref6[0]; + + var isResetMin = nextMin === undefined || nextMin === ''; + var isResetMax = nextMax === undefined || nextMax === ''; + + var _toPrecision = toPrecision({ + min: !isResetMin ? parseFloat(nextMin) : undefined, + max: !isResetMax ? parseFloat(nextMax) : undefined, + precision: precision + }), + nextMinAsNumber = _toPrecision.min, + nextMaxAsNumber = _toPrecision.max; + + var newNextMin; + + if (!(0, _utils.isFiniteNumber)(minBound) && currentRangeMin === nextMinAsNumber) { + newNextMin = undefined; + } else if ((0, _utils.isFiniteNumber)(minBound) && isResetMin) { + newNextMin = minBound; + } else { + newNextMin = nextMinAsNumber; + } + + var newNextMax; + + if (!(0, _utils.isFiniteNumber)(maxBound) && currentRangeMax === nextMaxAsNumber) { + newNextMax = undefined; + } else if ((0, _utils.isFiniteNumber)(maxBound) && isResetMax) { + newNextMax = maxBound; + } else { + newNextMax = nextMaxAsNumber; + } + + var isResetNewNextMin = newNextMin === undefined; + var isGreaterThanCurrentRange = (0, _utils.isFiniteNumber)(currentRangeMin) && currentRangeMin <= newNextMin; + var isMinValid = isResetNewNextMin || (0, _utils.isFiniteNumber)(newNextMin) && (!(0, _utils.isFiniteNumber)(currentRangeMin) || isGreaterThanCurrentRange); + var isResetNewNextMax = newNextMax === undefined; + var isLowerThanRange = (0, _utils.isFiniteNumber)(newNextMax) && currentRangeMax >= newNextMax; + var isMaxValid = isResetNewNextMax || (0, _utils.isFiniteNumber)(newNextMax) && (!(0, _utils.isFiniteNumber)(currentRangeMax) || isLowerThanRange); + var hasMinChange = min !== newNextMin; + var hasMaxChange = max !== newNextMax; + + if ((hasMinChange || hasMaxChange) && isMinValid && isMaxValid) { + resolvedState = resolvedState.removeNumericRefinement(attribute); + + if ((0, _utils.isFiniteNumber)(newNextMin)) { + resolvedState = resolvedState.addNumericRefinement(attribute, '>=', newNextMin); + } + + if ((0, _utils.isFiniteNumber)(newNextMax)) { + resolvedState = resolvedState.addNumericRefinement(attribute, '<=', newNextMax); + } + + return resolvedState.resetPage(); + } + + return null; + }; + + var sendEventWithRefinedState = function sendEventWithRefinedState(refinedState, instantSearchInstance, helper) { + var eventName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'Filter Applied'; + var filters = (0, _utils.convertNumericRefinementsToFilters)(refinedState, attribute); + + if (filters && filters.length > 0) { + instantSearchInstance.sendEventToInsights({ + insightsMethod: 'clickedFilters', + widgetType: $$type, + eventType: 'click', + payload: { + eventName: eventName, + index: helper.getIndex(), + filters: filters + }, + attribute: attribute + }); + } + }; + + var createSendEvent = function createSendEvent(instantSearchInstance, helper, currentRange) { + return function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 1) { + instantSearchInstance.sendEventToInsights(args[0]); + return; + } + + var eventType = args[0], + facetValue = args[1], + eventName = args[2]; + + if (eventType !== 'click') { + return; + } + + var _facetValue = _slicedToArray(facetValue, 2), + nextMin = _facetValue[0], + nextMax = _facetValue[1]; + + var refinedState = getRefinedState(helper, currentRange, nextMin, nextMax); + sendEventWithRefinedState(refinedState, instantSearchInstance, helper, eventName); + }; + }; + + function _getCurrentRange(stats) { + var min; + + if ((0, _utils.isFiniteNumber)(minBound)) { + min = minBound; + } else if ((0, _utils.isFiniteNumber)(stats.min)) { + min = stats.min; + } else { + min = 0; + } + + var max; + + if ((0, _utils.isFiniteNumber)(maxBound)) { + max = maxBound; + } else if ((0, _utils.isFiniteNumber)(stats.max)) { + max = stats.max; + } else { + max = 0; + } + + return toPrecision({ + min: min, + max: max, + precision: precision + }); + } + + function _getCurrentRefinement(helper) { + var _ref7 = helper.getNumericRefinement(attribute, '>=') || [], + _ref8 = _slicedToArray(_ref7, 1), + minValue = _ref8[0]; + + var _ref9 = helper.getNumericRefinement(attribute, '<=') || [], + _ref10 = _slicedToArray(_ref9, 1), + maxValue = _ref10[0]; + + var min = (0, _utils.isFiniteNumber)(minValue) ? minValue : -Infinity; + var max = (0, _utils.isFiniteNumber)(maxValue) ? maxValue : Infinity; + return [min, max]; + } + + function _refine(instantSearchInstance, helper, currentRange) { + return function () { + var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [undefined, undefined], + _ref12 = _slicedToArray(_ref11, 2), + nextMin = _ref12[0], + nextMax = _ref12[1]; + + var refinedState = getRefinedState(helper, currentRange, nextMin, nextMax); + + if (refinedState) { + sendEventWithRefinedState(refinedState, instantSearchInstance, helper); + helper.setState(refinedState).search(); + } + }; + } + + return { + $$type: $$type, + init: function init(initOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + range: _objectSpread(_objectSpread({}, renderState.range), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref13) { + var results = _ref13.results, + helper = _ref13.helper, + instantSearchInstance = _ref13.instantSearchInstance; + var facetsFromResults = results && results.disjunctiveFacets || []; + var facet = (0, _utils.find)(facetsFromResults, function (facetResult) { + return facetResult.name === attribute; + }); + var stats = facet && facet.stats || { + min: undefined, + max: undefined + }; + + var currentRange = _getCurrentRange(stats); + + var start = _getCurrentRefinement(helper); + + var refine; + + if (!results) { + // On first render pass an empty range + // to be able to bypass the validation + // related to it + refine = _refine(instantSearchInstance, helper, { + min: undefined, + max: undefined + }); + } else { + refine = _refine(instantSearchInstance, helper, currentRange); + } + + return { + refine: refine, + canRefine: currentRange.min !== currentRange.max, + format: rangeFormatter, + range: currentRange, + sendEvent: createSendEvent(instantSearchInstance, helper, currentRange), + widgetParams: _objectSpread(_objectSpread({}, widgetParams), {}, { + precision: precision + }), + start: start + }; + }, + dispose: function dispose(_ref14) { + var state = _ref14.state; + unmountFn(); + return state.removeDisjunctiveFacet(attribute).removeNumericRefinement(attribute); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref15) { + var searchParameters = _ref15.searchParameters; + + var _searchParameters$get = searchParameters.getNumericRefinements(attribute), + _searchParameters$get2 = _searchParameters$get['>='], + min = _searchParameters$get2 === void 0 ? [] : _searchParameters$get2, + _searchParameters$get3 = _searchParameters$get['<='], + max = _searchParameters$get3 === void 0 ? [] : _searchParameters$get3; + + if (min.length === 0 && max.length === 0) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + range: _objectSpread(_objectSpread({}, uiState.range), {}, _defineProperty({}, attribute, "".concat(min, ":").concat(max))) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref16) { + var uiState = _ref16.uiState; + var widgetSearchParameters = searchParameters.addDisjunctiveFacet(attribute).setQueryParameters({ + numericRefinements: _objectSpread(_objectSpread({}, searchParameters.numericRefinements), {}, _defineProperty({}, attribute, {})) + }); + + if ((0, _utils.isFiniteNumber)(minBound)) { + widgetSearchParameters = widgetSearchParameters.addNumericRefinement(attribute, '>=', minBound); + } + + if ((0, _utils.isFiniteNumber)(maxBound)) { + widgetSearchParameters = widgetSearchParameters.addNumericRefinement(attribute, '<=', maxBound); + } + + var value = uiState.range && uiState.range[attribute]; + + if (!value || value.indexOf(':') === -1) { + return widgetSearchParameters; + } + + var _value$split$map = value.split(':').map(parseFloat), + _value$split$map2 = _slicedToArray(_value$split$map, 2), + lowerBound = _value$split$map2[0], + upperBound = _value$split$map2[1]; + + if ((0, _utils.isFiniteNumber)(lowerBound) && (!(0, _utils.isFiniteNumber)(minBound) || minBound < lowerBound)) { + widgetSearchParameters = widgetSearchParameters.removeNumericRefinement(attribute, '>='); + widgetSearchParameters = widgetSearchParameters.addNumericRefinement(attribute, '>=', lowerBound); + } + + if ((0, _utils.isFiniteNumber)(upperBound) && (!(0, _utils.isFiniteNumber)(maxBound) || upperBound < maxBound)) { + widgetSearchParameters = widgetSearchParameters.removeNumericRefinement(attribute, '<='); + widgetSearchParameters = widgetSearchParameters.addNumericRefinement(attribute, '<=', upperBound); + } + + return widgetSearchParameters; + } + }; + }; +}; + +var _default = connectRange; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/rating-menu/connectRatingMenu.js b/js/instantsearch.js/cjs/connectors/rating-menu/connectRatingMenu.js new file mode 100644 index 00000000..d1cd032f --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/rating-menu/connectRatingMenu.js @@ -0,0 +1,322 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'rating-menu', + connector: true +}); +var $$type = 'ais.ratingMenu'; +var MAX_VALUES_PER_FACET_API_LIMIT = 1000; +var STEP = 1; + +var createSendEvent = function createSendEvent(_ref) { + var instantSearchInstance = _ref.instantSearchInstance, + helper = _ref.helper, + getRefinedStar = _ref.getRefinedStar, + attribute = _ref.attribute; + return function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 1) { + instantSearchInstance.sendEventToInsights(args[0]); + return; + } + + var eventType = args[0], + facetValue = args[1], + _args$ = args[2], + eventName = _args$ === void 0 ? 'Filter Applied' : _args$; + + if (eventType !== 'click') { + return; + } + + var isRefined = getRefinedStar() === Number(facetValue); + + if (!isRefined) { + instantSearchInstance.sendEventToInsights({ + insightsMethod: 'clickedFilters', + widgetType: $$type, + eventType: eventType, + payload: { + eventName: eventName, + index: helper.getIndex(), + filters: ["".concat(attribute, ">=").concat(facetValue)] + }, + attribute: attribute + }); + } + }; +}; + +/** + * **StarRating** connector provides the logic to build a custom widget that will let + * the user refine search results based on ratings. + * + * The connector provides to the rendering: `refine()` to select a value and + * `items` that are the values that can be selected. `refine` should be used + * with `items.value`. + */ +var connectRatingMenu = function connectRatingMenu(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref2 = widgetParams || {}, + attribute = _ref2.attribute, + _ref2$max = _ref2.max, + max = _ref2$max === void 0 ? 5 : _ref2$max; + + var sendEvent; + + if (!attribute) { + throw new Error(withUsage('The `attribute` option is required.')); + } + + var _getRefinedStar = function getRefinedStar(state) { + var _values$; + + var values = state.getNumericRefinements(attribute); + + if (!((_values$ = values['>=']) !== null && _values$ !== void 0 && _values$.length)) { + return undefined; + } + + return values['>='][0]; + }; + + var getFacetsMaxDecimalPlaces = function getFacetsMaxDecimalPlaces(facetResults) { + var maxDecimalPlaces = 0; + facetResults.forEach(function (facetResult) { + var _facetResult$name$spl = facetResult.name.split('.'), + _facetResult$name$spl2 = _slicedToArray(_facetResult$name$spl, 2), + _facetResult$name$spl3 = _facetResult$name$spl2[1], + decimal = _facetResult$name$spl3 === void 0 ? '' : _facetResult$name$spl3; + + maxDecimalPlaces = Math.max(maxDecimalPlaces, decimal.length); + }); + return maxDecimalPlaces; + }; + + var getFacetValuesWarningMessage = function getFacetValuesWarningMessage(_ref3) { + var maxDecimalPlaces = _ref3.maxDecimalPlaces, + maxFacets = _ref3.maxFacets, + maxValuesPerFacet = _ref3.maxValuesPerFacet; + var maxDecimalPlacesInRange = Math.max(0, Math.floor(Math.log10(MAX_VALUES_PER_FACET_API_LIMIT / max))); + var maxFacetsInRange = Math.min(MAX_VALUES_PER_FACET_API_LIMIT, Math.pow(10, maxDecimalPlacesInRange) * max); + var solutions = []; + + if (maxFacets > MAX_VALUES_PER_FACET_API_LIMIT) { + solutions.push("- Update your records to lower the precision of the values in the \"".concat(attribute, "\" attribute (for example: ").concat(5.123456789.toPrecision(maxDecimalPlaces + 1), " to ").concat(5.123456789.toPrecision(maxDecimalPlacesInRange + 1), ")")); + } + + if (maxValuesPerFacet < maxFacetsInRange) { + solutions.push("- Increase the maximum number of facet values to ".concat(maxFacetsInRange, " using the \"configure\" widget ").concat((0, _utils.createDocumentationLink)({ + name: 'configure' + }), " and the \"maxValuesPerFacet\" parameter https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/")); + } + + return "The ".concat(attribute, " attribute can have ").concat(maxFacets, " different values (0 to ").concat(max, " with a maximum of ").concat(maxDecimalPlaces, " decimals = ").concat(maxFacets, ") but you retrieved only ").concat(maxValuesPerFacet, " facet values. Therefore the number of results that match the refinements can be incorrect.\n ").concat(solutions.length ? "To resolve this problem you can:\n".concat(solutions.join('\n')) : ""); + }; + + function getRefinedState(state, facetValue) { + var isRefined = _getRefinedStar(state) === Number(facetValue); + var emptyState = state.resetPage().removeNumericRefinement(attribute); + + if (!isRefined) { + return emptyState.addNumericRefinement(attribute, '<=', max).addNumericRefinement(attribute, '>=', Number(facetValue)); + } + + return emptyState; + } + + var toggleRefinement = function toggleRefinement(helper, facetValue) { + sendEvent('click', facetValue); + helper.setState(getRefinedState(helper.state, facetValue)).search(); + }; + + var connectorState = { + toggleRefinementFactory: function toggleRefinementFactory(helper) { + return toggleRefinement.bind(null, helper); + }, + createURLFactory: function createURLFactory(_ref4) { + var state = _ref4.state, + createURL = _ref4.createURL; + return function (value) { + return createURL(getRefinedState(state, value)); + }; + } + }; + return { + $$type: $$type, + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + ratingMenu: _objectSpread(_objectSpread({}, renderState.ratingMenu), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref5) { + var helper = _ref5.helper, + results = _ref5.results, + state = _ref5.state, + instantSearchInstance = _ref5.instantSearchInstance, + createURL = _ref5.createURL; + var facetValues = []; + + if (!sendEvent) { + sendEvent = createSendEvent({ + instantSearchInstance: instantSearchInstance, + helper: helper, + getRefinedStar: function getRefinedStar() { + return _getRefinedStar(helper.state); + }, + attribute: attribute + }); + } + + if (results) { + var facetResults = results.getFacetValues(attribute, {}); + var maxValuesPerFacet = facetResults.length; + var maxDecimalPlaces = getFacetsMaxDecimalPlaces(facetResults); + var maxFacets = Math.pow(10, maxDecimalPlaces) * max; + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(maxFacets <= maxValuesPerFacet, getFacetValuesWarningMessage({ + maxDecimalPlaces: maxDecimalPlaces, + maxFacets: maxFacets, + maxValuesPerFacet: maxValuesPerFacet + })) : void 0; + + var refinedStar = _getRefinedStar(state); + + var _loop = function _loop(star) { + var isRefined = refinedStar === star; + var count = facetResults.filter(function (f) { + return Number(f.name) >= star && Number(f.name) <= max; + }).map(function (f) { + return f.count; + }).reduce(function (sum, current) { + return sum + current; + }, 0); + + if (refinedStar && !isRefined && count === 0) { + // skip count==0 when at least 1 refinement is enabled + // eslint-disable-next-line no-continue + return "continue"; + } + + var stars = _toConsumableArray(new Array(Math.floor(max / STEP))).map(function (_v, i) { + return i * STEP < star; + }); + + facetValues.push({ + stars: stars, + name: String(star), + label: String(star), + value: String(star), + count: count, + isRefined: isRefined + }); + }; + + for (var star = STEP; star < max; star += STEP) { + var _ret = _loop(star); + + if (_ret === "continue") continue; + } + } + + facetValues = facetValues.reverse(); + return { + items: facetValues, + hasNoResults: results ? results.nbHits === 0 : true, + canRefine: facetValues.length > 0, + refine: connectorState.toggleRefinementFactory(helper), + sendEvent: sendEvent, + createURL: connectorState.createURLFactory({ + state: state, + createURL: createURL + }), + widgetParams: widgetParams + }; + }, + dispose: function dispose(_ref6) { + var state = _ref6.state; + unmountFn(); + return state.removeNumericRefinement(attribute); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref7) { + var searchParameters = _ref7.searchParameters; + + var value = _getRefinedStar(searchParameters); + + if (typeof value !== 'number') { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + ratingMenu: _objectSpread(_objectSpread({}, uiState.ratingMenu), {}, _defineProperty({}, attribute, value)) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref8) { + var uiState = _ref8.uiState; + var value = uiState.ratingMenu && uiState.ratingMenu[attribute]; + var withoutRefinements = searchParameters.clearRefinements(attribute); + var withDisjunctiveFacet = withoutRefinements.addDisjunctiveFacet(attribute); + + if (!value) { + return withDisjunctiveFacet.setQueryParameters({ + numericRefinements: _objectSpread(_objectSpread({}, withDisjunctiveFacet.numericRefinements), {}, _defineProperty({}, attribute, {})) + }); + } + + return withDisjunctiveFacet.addNumericRefinement(attribute, '<=', max).addNumericRefinement(attribute, '>=', value); + } + }; + }; +}; + +var _default = connectRatingMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/refinement-list/connectRefinementList.js b/js/instantsearch.js/cjs/connectors/refinement-list/connectRefinementList.js new file mode 100644 index 00000000..3e3227a1 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/refinement-list/connectRefinementList.js @@ -0,0 +1,295 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'refinement-list', + connector: true +}); +var DEFAULT_SORT = ['isRefined', 'count:desc', 'name:asc']; + +/** + * **RefinementList** connector provides the logic to build a custom widget that + * will let the user filter the results based on the values of a specific facet. + * + * **Requirement:** the attribute passed as `attribute` must be present in + * attributesForFaceting of the searched index. + * + * This connector provides: + * - a `refine()` function to select an item. + * - a `toggleShowMore()` function to display more or less items + * - a `searchForItems()` function to search within the items. + */ +var connectRefinementList = function connectRefinementList(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + attribute = _ref.attribute, + _ref$operator = _ref.operator, + operator = _ref$operator === void 0 ? 'or' : _ref$operator, + _ref$limit = _ref.limit, + limit = _ref$limit === void 0 ? 10 : _ref$limit, + _ref$showMore = _ref.showMore, + showMore = _ref$showMore === void 0 ? false : _ref$showMore, + _ref$showMoreLimit = _ref.showMoreLimit, + showMoreLimit = _ref$showMoreLimit === void 0 ? 20 : _ref$showMoreLimit, + _ref$sortBy = _ref.sortBy, + sortBy = _ref$sortBy === void 0 ? DEFAULT_SORT : _ref$sortBy, + _ref$escapeFacetValue = _ref.escapeFacetValues, + escapeFacetValues = _ref$escapeFacetValue === void 0 ? true : _ref$escapeFacetValue, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (items) { + return items; + } : _ref$transformItems; + + if (!attribute) { + throw new Error(withUsage('The `attribute` option is required.')); + } + + if (!/^(and|or)$/.test(operator)) { + throw new Error(withUsage("The `operator` must one of: `\"and\"`, `\"or\"` (got \"".concat(operator, "\")."))); + } + + if (showMore === true && showMoreLimit <= limit) { + throw new Error(withUsage('`showMoreLimit` should be greater than `limit`.')); + } + + var formatItems = function formatItems(_ref2) { + var label = _ref2.name, + item = _objectWithoutProperties(_ref2, ["name"]); + + return _objectSpread(_objectSpread({}, item), {}, { + label: label, + value: label, + highlighted: label + }); + }; + + var lastResultsFromMainSearch; + var lastItemsFromMainSearch = []; + var hasExhaustiveItems = true; + var triggerRefine; + var sendEvent; + var isShowingMore = false; // Provide the same function to the `renderFn` so that way the user + // has to only bind it once when `isFirstRendering` for instance + + var toggleShowMore = function toggleShowMore() {}; + + function cachedToggleShowMore() { + toggleShowMore(); + } + + function createToggleShowMore(renderOptions, widget) { + return function () { + isShowingMore = !isShowingMore; + widget.render(renderOptions); + }; + } + + function getLimit() { + return isShowingMore ? showMoreLimit : limit; + } + + var searchForFacetValues = function searchForFacetValues() { + return function () {}; + }; + + var createSearchForFacetValues = function createSearchForFacetValues(helper, widget) { + return function (renderOptions) { + return function (query) { + var instantSearchInstance = renderOptions.instantSearchInstance; + + if (query === '' && lastItemsFromMainSearch) { + // render with previous data from the helper. + renderFn(_objectSpread(_objectSpread({}, widget.getWidgetRenderState(_objectSpread(_objectSpread({}, renderOptions), {}, { + results: lastResultsFromMainSearch + }))), {}, { + instantSearchInstance: instantSearchInstance + }), false); + } else { + var tags = { + highlightPreTag: escapeFacetValues ? _utils.TAG_PLACEHOLDER.highlightPreTag : _utils.TAG_REPLACEMENT.highlightPreTag, + highlightPostTag: escapeFacetValues ? _utils.TAG_PLACEHOLDER.highlightPostTag : _utils.TAG_REPLACEMENT.highlightPostTag + }; + helper.searchForFacetValues(attribute, query, // We cap the `maxFacetHits` value to 100 because the Algolia API + // doesn't support a greater number. + // See https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits/ + Math.min(getLimit(), 100), tags).then(function (results) { + var facetValues = escapeFacetValues ? (0, _utils.escapeFacets)(results.facetHits) : results.facetHits; + var normalizedFacetValues = transformItems(facetValues.map(function (_ref3) { + var value = _ref3.value, + item = _objectWithoutProperties(_ref3, ["value"]); + + return _objectSpread(_objectSpread({}, item), {}, { + value: value, + label: value + }); + })); + renderFn(_objectSpread(_objectSpread({}, widget.getWidgetRenderState(_objectSpread(_objectSpread({}, renderOptions), {}, { + results: lastResultsFromMainSearch + }))), {}, { + items: normalizedFacetValues, + canToggleShowMore: false, + canRefine: true, + isFromSearch: true, + instantSearchInstance: instantSearchInstance + }), false); + }); + } + }; + }; + }; + + return { + $$type: 'ais.refinementList', + init: function init(initOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: initOptions.instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: renderOptions.instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + refinementList: _objectSpread(_objectSpread({}, renderState.refinementList), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(renderOptions) { + var results = renderOptions.results, + state = renderOptions.state, + _createURL = renderOptions.createURL, + instantSearchInstance = renderOptions.instantSearchInstance, + helper = renderOptions.helper; + var items = []; + var facetValues = []; + + if (!sendEvent || !triggerRefine || !searchForFacetValues) { + sendEvent = (0, _utils.createSendEventForFacet)({ + instantSearchInstance: instantSearchInstance, + helper: helper, + attribute: attribute, + widgetType: this.$$type + }); + + triggerRefine = function triggerRefine(facetValue) { + sendEvent('click', facetValue); + helper.toggleFacetRefinement(attribute, facetValue).search(); + }; + + searchForFacetValues = createSearchForFacetValues(helper, this); + } + + if (results) { + var values = results.getFacetValues(attribute, { + sortBy: sortBy, + facetOrdering: sortBy === DEFAULT_SORT + }); + facetValues = values && Array.isArray(values) ? values : []; + items = transformItems(facetValues.slice(0, getLimit()).map(formatItems)); + var maxValuesPerFacetConfig = state.maxValuesPerFacet; + var currentLimit = getLimit(); // If the limit is the max number of facet retrieved it is impossible to know + // if the facets are exhaustive. The only moment we are sure it is exhaustive + // is when it is strictly under the number requested unless we know that another + // widget has requested more values (maxValuesPerFacet > getLimit()). + // Because this is used for making the search of facets unable or not, it is important + // to be conservative here. + + hasExhaustiveItems = maxValuesPerFacetConfig > currentLimit ? facetValues.length <= currentLimit : facetValues.length < currentLimit; + lastResultsFromMainSearch = results; + lastItemsFromMainSearch = items; + + if (renderOptions.results) { + toggleShowMore = createToggleShowMore(renderOptions, this); + } + } // Do not mistake searchForFacetValues and searchFacetValues which is the actual search + // function + + + var searchFacetValues = searchForFacetValues && searchForFacetValues(renderOptions); + var canShowLess = isShowingMore && lastItemsFromMainSearch.length > limit; + var canShowMore = showMore && !hasExhaustiveItems; + var canToggleShowMore = canShowLess || canShowMore; + return { + createURL: function createURL(facetValue) { + return _createURL(state.resetPage().toggleFacetRefinement(attribute, facetValue)); + }, + items: items, + refine: triggerRefine, + searchForItems: searchFacetValues, + isFromSearch: false, + canRefine: items.length > 0, + widgetParams: widgetParams, + isShowingMore: isShowingMore, + canToggleShowMore: canToggleShowMore, + toggleShowMore: cachedToggleShowMore, + sendEvent: sendEvent, + hasExhaustiveItems: hasExhaustiveItems + }; + }, + dispose: function dispose(_ref4) { + var state = _ref4.state; + unmountFn(); + var withoutMaxValuesPerFacet = state.setQueryParameter('maxValuesPerFacet', undefined); + + if (operator === 'and') { + return withoutMaxValuesPerFacet.removeFacet(attribute); + } + + return withoutMaxValuesPerFacet.removeDisjunctiveFacet(attribute); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref5) { + var searchParameters = _ref5.searchParameters; + var values = operator === 'or' ? searchParameters.getDisjunctiveRefinements(attribute) : searchParameters.getConjunctiveRefinements(attribute); + + if (!values.length) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + refinementList: _objectSpread(_objectSpread({}, uiState.refinementList), {}, _defineProperty({}, attribute, values)) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) { + var uiState = _ref6.uiState; + var isDisjunctive = operator === 'or'; + var values = uiState.refinementList && uiState.refinementList[attribute]; + var withoutRefinements = searchParameters.clearRefinements(attribute); + var withFacetConfiguration = isDisjunctive ? withoutRefinements.addDisjunctiveFacet(attribute) : withoutRefinements.addFacet(attribute); + var currentMaxValuesPerFacet = withFacetConfiguration.maxValuesPerFacet || 0; + var nextMaxValuesPerFacet = Math.max(currentMaxValuesPerFacet, showMore ? showMoreLimit : limit); + var withMaxValuesPerFacet = withFacetConfiguration.setQueryParameter('maxValuesPerFacet', nextMaxValuesPerFacet); + + if (!values) { + var key = isDisjunctive ? 'disjunctiveFacetsRefinements' : 'facetsRefinements'; + return withMaxValuesPerFacet.setQueryParameters(_defineProperty({}, key, _objectSpread(_objectSpread({}, withMaxValuesPerFacet[key]), {}, _defineProperty({}, attribute, [])))); + } + + return values.reduce(function (parameters, value) { + return isDisjunctive ? parameters.addDisjunctiveFacetRefinement(attribute, value) : parameters.addFacetRefinement(attribute, value); + }, withMaxValuesPerFacet); + } + }; + }; +}; + +var _default = connectRefinementList; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/relevant-sort/connectRelevantSort.js b/js/instantsearch.js/cjs/connectors/relevant-sort/connectRelevantSort.js new file mode 100644 index 00000000..1ab7b798 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/relevant-sort/connectRelevantSort.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var connectRelevantSort = function connectRelevantSort() { + var renderFn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _utils.noop; + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + return function (widgetParams) { + var connectorState = {}; + return { + $$type: 'ais.relevantSort', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref) { + var state = _ref.state; + unmountFn(); + return state.setQueryParameter('relevancyStrictness', undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + relevantSort: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref2) { + var results = _ref2.results, + helper = _ref2.helper; + + if (!connectorState.refine) { + connectorState.refine = function (relevancyStrictness) { + helper.setQueryParameter('relevancyStrictness', relevancyStrictness).search(); + }; + } + + var _ref3 = results || {}, + appliedRelevancyStrictness = _ref3.appliedRelevancyStrictness; + + var isVirtualReplica = appliedRelevancyStrictness !== undefined; + return { + isRelevantSorted: typeof appliedRelevancyStrictness !== 'undefined' && appliedRelevancyStrictness > 0, + isVirtualReplica: isVirtualReplica, + canRefine: isVirtualReplica, + refine: connectorState.refine, + widgetParams: widgetParams + }; + }, + getWidgetSearchParameters: function getWidgetSearchParameters(state, _ref4) { + var _uiState$relevantSort; + + var uiState = _ref4.uiState; + return state.setQueryParameter('relevancyStrictness', (_uiState$relevantSort = uiState.relevantSort) !== null && _uiState$relevantSort !== void 0 ? _uiState$relevantSort : state.relevancyStrictness); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref5) { + var searchParameters = _ref5.searchParameters; + return _objectSpread(_objectSpread({}, uiState), {}, { + relevantSort: searchParameters.relevancyStrictness || uiState.relevantSort + }); + } + }; + }; +}; + +var _default = connectRelevantSort; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/search-box/connectSearchBox.js b/js/instantsearch.js/cjs/connectors/search-box/connectSearchBox.js new file mode 100644 index 00000000..619a9039 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/search-box/connectSearchBox.js @@ -0,0 +1,123 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'search-box', + connector: true +}); + +/** + * **SearchBox** connector provides the logic to build a widget that will let the user search for a query. + * + * The connector provides to the rendering: `refine()` to set the query. The behaviour of this function + * may be impacted by the `queryHook` widget parameter. + */ +var connectSearchBox = function connectSearchBox(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref = widgetParams || {}, + queryHook = _ref.queryHook; + + function clear(helper) { + return function () { + helper.setQuery('').search(); + }; + } + + var _refine; + + var _clear = function _clear() {}; + + function _cachedClear() { + _clear(); + } + + return { + $$type: 'ais.searchBox', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref2) { + var state = _ref2.state; + unmountFn(); + return state.setQueryParameter('query', undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + searchBox: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref3) { + var helper = _ref3.helper, + searchMetadata = _ref3.searchMetadata; + + if (!_refine) { + var setQueryAndSearch = function setQueryAndSearch(query) { + if (query !== helper.state.query) { + helper.setQuery(query).search(); + } + }; + + _refine = function _refine(query) { + if (queryHook) { + queryHook(query, setQueryAndSearch); + return; + } + + setQueryAndSearch(query); + }; + } + + _clear = clear(helper); + return { + query: helper.state.query || '', + refine: _refine, + clear: _cachedClear, + widgetParams: widgetParams, + isSearchStalled: searchMetadata.isSearchStalled + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref4) { + var searchParameters = _ref4.searchParameters; + var query = searchParameters.query || ''; + + if (query === '' || uiState && uiState.query === query) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + query: query + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) { + var uiState = _ref5.uiState; + return searchParameters.setQueryParameter('query', uiState.query || ''); + } + }; + }; +}; + +var _default = connectSearchBox; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/sort-by/connectSortBy.js b/js/instantsearch.js/cjs/connectors/sort-by/connectSortBy.js new file mode 100644 index 00000000..cf018f41 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/sort-by/connectSortBy.js @@ -0,0 +1,111 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'sort-by', + connector: true +}); +/** + * The **SortBy** connector provides the logic to build a custom widget that will display a + * list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows + * a user to change how the hits are being sorted. + */ + +var connectSortBy = function connectSortBy(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + var connectorState = {}; + return function (widgetParams) { + var _ref = widgetParams || {}, + items = _ref.items, + _ref$transformItems = _ref.transformItems, + transformItems = _ref$transformItems === void 0 ? function (x) { + return x; + } : _ref$transformItems; + + if (!Array.isArray(items)) { + throw new Error(withUsage('The `items` option expects an array of objects.')); + } + + return { + $$type: 'ais.sortBy', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + var widgetRenderState = this.getWidgetRenderState(initOptions); + var currentIndex = widgetRenderState.currentRefinement; + var isCurrentIndexInItems = (0, _utils.find)(items, function (item) { + return item.value === currentIndex; + }); + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(isCurrentIndexInItems !== undefined, "The index named \"".concat(currentIndex, "\" is not listed in the `items` of `sortBy`.")) : void 0; + renderFn(_objectSpread(_objectSpread({}, widgetRenderState), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref2) { + var state = _ref2.state; + unmountFn(); + return connectorState.initialIndex ? state.setIndex(connectorState.initialIndex) : state; + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + sortBy: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref3) { + var results = _ref3.results, + helper = _ref3.helper, + parent = _ref3.parent; + + if (!connectorState.initialIndex && parent) { + connectorState.initialIndex = parent.getIndexName(); + } + + if (!connectorState.setIndex) { + connectorState.setIndex = function (indexName) { + helper.setIndex(indexName).search(); + }; + } + + return { + currentRefinement: helper.state.index, + options: transformItems(items), + refine: connectorState.setIndex, + hasNoResults: results ? results.nbHits === 0 : true, + widgetParams: widgetParams + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref4) { + var searchParameters = _ref4.searchParameters; + var currentIndex = searchParameters.index; + return _objectSpread(_objectSpread({}, uiState), {}, { + sortBy: currentIndex !== connectorState.initialIndex ? currentIndex : undefined + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) { + var uiState = _ref5.uiState; + return searchParameters.setQueryParameter('index', uiState.sortBy || connectorState.initialIndex || searchParameters.index); + } + }; + }; +}; + +var _default = connectSortBy; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/stats/connectStats.js b/js/instantsearch.js/cjs/connectors/stats/connectStats.js new file mode 100644 index 00000000..846ab518 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/stats/connectStats.js @@ -0,0 +1,86 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'stats', + connector: true +}); +/** + * **Stats** connector provides the logic to build a custom widget that will displays + * search statistics (hits number and processing time). + */ + +var connectStats = function connectStats(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + return { + $$type: 'ais.stats', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose() { + unmountFn(); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + stats: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref) { + var results = _ref.results, + helper = _ref.helper; + + if (!results) { + return { + hitsPerPage: helper.state.hitsPerPage, + nbHits: 0, + nbSortedHits: undefined, + areHitsSorted: false, + nbPages: 0, + page: helper.state.page || 0, + processingTimeMS: -1, + query: helper.state.query || '', + widgetParams: widgetParams + }; + } + + return { + hitsPerPage: results.hitsPerPage, + nbHits: results.nbHits, + nbSortedHits: results.nbSortedHits, + areHitsSorted: typeof results.appliedRelevancyStrictness !== 'undefined' && results.appliedRelevancyStrictness > 0 && results.nbSortedHits !== results.nbHits, + nbPages: results.nbPages, + page: results.page, + processingTimeMS: results.processingTimeMS, + query: results.query, + widgetParams: widgetParams + }; + } + }; + }; +}; + +var _default = connectStats; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/toggle-refinement/connectToggleRefinement.js b/js/instantsearch.js/cjs/connectors/toggle-refinement/connectToggleRefinement.js new file mode 100644 index 00000000..898f2045 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/toggle-refinement/connectToggleRefinement.js @@ -0,0 +1,327 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'toggle-refinement', + connector: true +}); +var $$type = 'ais.toggleRefinement'; + +var createSendEvent = function createSendEvent(_ref) { + var instantSearchInstance = _ref.instantSearchInstance, + helper = _ref.helper, + attribute = _ref.attribute, + on = _ref.on; + + var sendEventForToggle = function sendEventForToggle() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 1) { + instantSearchInstance.sendEventToInsights(args[0]); + return; + } + + var eventType = args[0], + isRefined = args[1], + _args$ = args[2], + eventName = _args$ === void 0 ? 'Filter Applied' : _args$; + + if (eventType !== 'click' || on === undefined) { + return; + } // only send an event when the refinement gets applied, + // not when it gets removed + + + if (!isRefined) { + instantSearchInstance.sendEventToInsights({ + insightsMethod: 'clickedFilters', + widgetType: $$type, + eventType: eventType, + payload: { + eventName: eventName, + index: helper.getIndex(), + filters: on.map(function (value) { + return "".concat(attribute, ":").concat(value); + }) + }, + attribute: attribute + }); + } + }; + + return sendEventForToggle; +}; + +/** + * **Toggle** connector provides the logic to build a custom widget that will provide + * an on/off filtering feature based on an attribute value or values. + * + * Two modes are implemented in the custom widget: + * - with or without the value filtered + * - switch between two values. + */ +var connectToggleRefinement = function connectToggleRefinement(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _ref2 = widgetParams || {}, + attribute = _ref2.attribute, + _ref2$on = _ref2.on, + userOn = _ref2$on === void 0 ? true : _ref2$on, + userOff = _ref2.off; + + if (!attribute) { + throw new Error(withUsage('The `attribute` option is required.')); + } + + var hasAnOffValue = userOff !== undefined; + var on = (0, _utils.toArray)(userOn).map(_utils.escapeRefinement); + var off = hasAnOffValue ? (0, _utils.toArray)(userOff).map(_utils.escapeRefinement) : undefined; + var sendEvent; + + var toggleRefinementFactory = function toggleRefinementFactory(helper) { + return function () { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { + isRefined: false + }, + isRefined = _ref3.isRefined; + + if (!isRefined) { + sendEvent('click', isRefined); + + if (hasAnOffValue) { + off.forEach(function (v) { + return helper.removeDisjunctiveFacetRefinement(attribute, v); + }); + } + + on.forEach(function (v) { + return helper.addDisjunctiveFacetRefinement(attribute, v); + }); + } else { + on.forEach(function (v) { + return helper.removeDisjunctiveFacetRefinement(attribute, v); + }); + + if (hasAnOffValue) { + off.forEach(function (v) { + return helper.addDisjunctiveFacetRefinement(attribute, v); + }); + } + } + + helper.search(); + }; + }; + + var connectorState = { + createURLFactory: function createURLFactory(isRefined, _ref4) { + var state = _ref4.state, + createURL = _ref4.createURL; + return function () { + state = state.resetPage(); + var valuesToRemove = isRefined ? on : off; + + if (valuesToRemove) { + valuesToRemove.forEach(function (v) { + state = state.removeDisjunctiveFacetRefinement(attribute, v); + }); + } + + var valuesToAdd = isRefined ? off : on; + + if (valuesToAdd) { + valuesToAdd.forEach(function (v) { + state = state.addDisjunctiveFacetRefinement(attribute, v); + }); + } + + return createURL(state); + }; + } + }; + return { + $$type: $$type, + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + dispose: function dispose(_ref5) { + var state = _ref5.state; + unmountFn(); + return state.removeDisjunctiveFacet(attribute); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + toggleRefinement: _objectSpread(_objectSpread({}, renderState.toggleRefinement), {}, _defineProperty({}, attribute, this.getWidgetRenderState(renderOptions))) + }); + }, + getWidgetRenderState: function getWidgetRenderState(_ref6) { + var state = _ref6.state, + helper = _ref6.helper, + results = _ref6.results, + createURL = _ref6.createURL, + instantSearchInstance = _ref6.instantSearchInstance; + var isRefined = results ? on.every(function (v) { + return helper.state.isDisjunctiveFacetRefined(attribute, v); + }) : on.every(function (v) { + return state.isDisjunctiveFacetRefined(attribute, v); + }); + var onFacetValue = { + isRefined: isRefined, + count: 0 + }; + var offFacetValue = { + isRefined: hasAnOffValue && !isRefined, + count: 0 + }; + + if (results) { + var offValue = (0, _utils.toArray)(off || false); + var allFacetValues = results.getFacetValues(attribute, {}) || []; + var onData = on.map(function (v) { + return (0, _utils.find)(allFacetValues, function (_ref7) { + var name = _ref7.name; + return name === (0, _utils.unescapeRefinement)(v); + }); + }).filter(function (v) { + return v !== undefined; + }); + var offData = hasAnOffValue ? offValue.map(function (v) { + return (0, _utils.find)(allFacetValues, function (_ref8) { + var name = _ref8.name; + return name === (0, _utils.unescapeRefinement)(v); + }); + }).filter(function (v) { + return v !== undefined; + }) : []; + onFacetValue = { + isRefined: onData.length ? onData.every(function (v) { + return v.isRefined; + }) : false, + count: onData.reduce(function (acc, v) { + return acc + v.count; + }, 0) || null + }; + offFacetValue = { + isRefined: offData.length ? offData.every(function (v) { + return v.isRefined; + }) : false, + count: offData.reduce(function (acc, v) { + return acc + v.count; + }, 0) || allFacetValues.reduce(function (total, _ref9) { + var count = _ref9.count; + return total + count; + }, 0) + }; + } else if (hasAnOffValue && !isRefined) { + if (off) { + off.forEach(function (v) { + return helper.addDisjunctiveFacetRefinement(attribute, v); + }); + } + + helper.setPage(helper.state.page); + } + + if (!sendEvent) { + sendEvent = createSendEvent({ + instantSearchInstance: instantSearchInstance, + attribute: attribute, + on: on, + helper: helper + }); + } + + var nextRefinement = isRefined ? offFacetValue : onFacetValue; + return { + value: { + name: attribute, + isRefined: isRefined, + count: results ? nextRefinement.count : null, + onFacetValue: onFacetValue, + offFacetValue: offFacetValue + }, + createURL: connectorState.createURLFactory(isRefined, { + state: state, + createURL: createURL + }), + sendEvent: sendEvent, + canRefine: Boolean(results ? nextRefinement.count : null), + refine: toggleRefinementFactory(helper), + widgetParams: widgetParams + }; + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref10) { + var searchParameters = _ref10.searchParameters; + var isRefined = on && on.every(function (v) { + return searchParameters.isDisjunctiveFacetRefined(attribute, v); + }); + + if (!isRefined) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + toggle: _objectSpread(_objectSpread({}, uiState.toggle), {}, _defineProperty({}, attribute, isRefined)) + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref11) { + var uiState = _ref11.uiState; + var withFacetConfiguration = searchParameters.clearRefinements(attribute).addDisjunctiveFacet(attribute); + var isRefined = Boolean(uiState.toggle && uiState.toggle[attribute]); + + if (isRefined) { + if (on) { + on.forEach(function (v) { + withFacetConfiguration = withFacetConfiguration.addDisjunctiveFacetRefinement(attribute, v); + }); + } + + return withFacetConfiguration; + } // It's not refined with an `off` value + + + if (hasAnOffValue) { + if (off) { + off.forEach(function (v) { + withFacetConfiguration = withFacetConfiguration.addDisjunctiveFacetRefinement(attribute, v); + }); + } + + return withFacetConfiguration; + } // It's not refined without an `off` value + + + return withFacetConfiguration.setQueryParameters({ + disjunctiveFacetsRefinements: _objectSpread(_objectSpread({}, searchParameters.disjunctiveFacetsRefinements), {}, _defineProperty({}, attribute, [])) + }); + } + }; + }; +}; + +var _default = connectToggleRefinement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/toggle-refinement/types.js b/js/instantsearch.js/cjs/connectors/toggle-refinement/types.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/toggle-refinement/types.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/connectors/voice-search/connectVoiceSearch.js b/js/instantsearch.js/cjs/connectors/voice-search/connectVoiceSearch.js new file mode 100644 index 00000000..95a76c4c --- /dev/null +++ b/js/instantsearch.js/cjs/connectors/voice-search/connectVoiceSearch.js @@ -0,0 +1,170 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +var _voiceSearchHelper2 = _interopRequireDefault(require("../../lib/voiceSearchHelper")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'voice-search', + connector: true +}); + +var connectVoiceSearch = function connectVoiceSearch(renderFn) { + var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _utils.noop; + (0, _utils.checkRendering)(renderFn, withUsage()); + return function (widgetParams) { + var _widgetParams$searchA = widgetParams.searchAsYouSpeak, + searchAsYouSpeak = _widgetParams$searchA === void 0 ? false : _widgetParams$searchA, + language = widgetParams.language, + additionalQueryParameters = widgetParams.additionalQueryParameters, + _widgetParams$createV = widgetParams.createVoiceSearchHelper, + createVoiceSearchHelper = _widgetParams$createV === void 0 ? _voiceSearchHelper2.default : _widgetParams$createV; + return { + $$type: 'ais.voiceSearch', + init: function init(initOptions) { + var instantSearchInstance = initOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(initOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), true); + }, + render: function render(renderOptions) { + var instantSearchInstance = renderOptions.instantSearchInstance; + renderFn(_objectSpread(_objectSpread({}, this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + voiceSearch: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState(renderOptions) { + var _this = this; + + var helper = renderOptions.helper, + instantSearchInstance = renderOptions.instantSearchInstance; + + if (!this._refine) { + this._refine = function (query) { + if (query !== helper.state.query) { + var queryLanguages = language ? [language.split('-')[0]] : undefined; + helper.setQueryParameter('queryLanguages', queryLanguages); + + if (typeof additionalQueryParameters === 'function') { + helper.setState(helper.state.setQueryParameters(_objectSpread({ + ignorePlurals: true, + removeStopWords: true, + // @ts-ignore (optionalWords only allows array, while string is also valid) + optionalWords: query + }, additionalQueryParameters({ + query: query + })))); + } + + helper.setQuery(query).search(); + } + }; + } + + if (!this._voiceSearchHelper) { + this._voiceSearchHelper = createVoiceSearchHelper({ + searchAsYouSpeak: searchAsYouSpeak, + language: language, + onQueryChange: function onQueryChange(query) { + return _this._refine(query); + }, + onStateChange: function onStateChange() { + renderFn(_objectSpread(_objectSpread({}, _this.getWidgetRenderState(renderOptions)), {}, { + instantSearchInstance: instantSearchInstance + }), false); + } + }); + } + + var _voiceSearchHelper = this._voiceSearchHelper, + isBrowserSupported = _voiceSearchHelper.isBrowserSupported, + isListening = _voiceSearchHelper.isListening, + startListening = _voiceSearchHelper.startListening, + stopListening = _voiceSearchHelper.stopListening, + getState = _voiceSearchHelper.getState; + return { + isBrowserSupported: isBrowserSupported(), + isListening: isListening(), + toggleListening: function toggleListening() { + if (!isBrowserSupported()) { + return; + } + + if (isListening()) { + stopListening(); + } else { + startListening(); + } + }, + voiceListeningState: getState(), + widgetParams: widgetParams + }; + }, + dispose: function dispose(_ref) { + var state = _ref.state; + + this._voiceSearchHelper.dispose(); + + unmountFn(); + var newState = state; + + if (typeof additionalQueryParameters === 'function') { + var additional = additionalQueryParameters({ + query: '' + }); + var toReset = additional ? Object.keys(additional).reduce(function (acc, current) { + // @ts-ignore search parameters is typed as readonly + acc[current] = undefined; + return acc; + }, {}) : {}; + newState = state.setQueryParameters(_objectSpread({ + // @ts-ignore (queryLanguages is not yet added to algoliasearch) + queryLanguages: undefined, + ignorePlurals: undefined, + removeStopWords: undefined, + optionalWords: undefined + }, toReset)); + } + + return newState.setQueryParameter('query', undefined); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref2) { + var searchParameters = _ref2.searchParameters; + var query = searchParameters.query || ''; + + if (!query) { + return uiState; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + query: query + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref3) { + var uiState = _ref3.uiState; + return searchParameters.setQueryParameter('query', uiState.query || ''); + } + }; + }; +}; + +var _default = connectVoiceSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/get-insights-anonymous-user-token.js b/js/instantsearch.js/cjs/helpers/get-insights-anonymous-user-token.js new file mode 100644 index 00000000..116258b2 --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/get-insights-anonymous-user-token.js @@ -0,0 +1,45 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getInsightsAnonymousUserTokenInternal = getInsightsAnonymousUserTokenInternal; +exports.default = getInsightsAnonymousUserToken; +exports.ANONYMOUS_TOKEN_COOKIE_KEY = void 0; + +var _utils = require("../lib/utils"); + +var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA'; +exports.ANONYMOUS_TOKEN_COOKIE_KEY = ANONYMOUS_TOKEN_COOKIE_KEY; + +function getCookie(name) { + var prefix = "".concat(name, "="); + var cookies = document.cookie.split(';'); + + for (var i = 0; i < cookies.length; i++) { + var cookie = cookies[i]; + + while (cookie.charAt(0) === ' ') { + cookie = cookie.substring(1); + } + + if (cookie.indexOf(prefix) === 0) { + return cookie.substring(prefix.length, cookie.length); + } + } + + return undefined; +} + +function getInsightsAnonymousUserTokenInternal() { + return getCookie(ANONYMOUS_TOKEN_COOKIE_KEY); +} +/** + * @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/ + */ + + +function getInsightsAnonymousUserToken() { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`getInsightsAnonymousUserToken` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") : void 0; + return getInsightsAnonymousUserTokenInternal(); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/highlight.js b/js/instantsearch.js/cjs/helpers/highlight.js new file mode 100644 index 00000000..59e20d6a --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/highlight.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = highlight; + +var _suit = require("../lib/suit"); + +var _utils = require("../lib/utils"); + +var suit = (0, _suit.component)('Highlight'); + +function highlight(_ref) { + var attribute = _ref.attribute, + _ref$highlightedTagNa = _ref.highlightedTagName, + highlightedTagName = _ref$highlightedTagNa === void 0 ? 'mark' : _ref$highlightedTagNa, + hit = _ref.hit, + _ref$cssClasses = _ref.cssClasses, + cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses; + + var _ref2 = (0, _utils.getPropertyByPath)(hit._highlightResult, attribute) || {}, + _ref2$value = _ref2.value, + attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular + + + var className = suit({ + descendantName: 'highlighted' + }) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : ''); + return attributeValue.replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPreTag, 'g'), "<".concat(highlightedTagName, " class=\"").concat(className, "\">")).replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPostTag, 'g'), "")); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/index.js b/js/instantsearch.js/cjs/helpers/index.js new file mode 100644 index 00000000..ff51dcb0 --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/index.js @@ -0,0 +1,124 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var _exportNames = { + highlight: true, + reverseHighlight: true, + snippet: true, + reverseSnippet: true, + insights: true, + getInsightsAnonymousUserToken: true, + getInsightsAnonymousUserTokenInternal: true +}; +Object.defineProperty(exports, "highlight", { + enumerable: true, + get: function get() { + return _highlight.default; + } +}); +Object.defineProperty(exports, "reverseHighlight", { + enumerable: true, + get: function get() { + return _reverseHighlight.default; + } +}); +Object.defineProperty(exports, "snippet", { + enumerable: true, + get: function get() { + return _snippet.default; + } +}); +Object.defineProperty(exports, "reverseSnippet", { + enumerable: true, + get: function get() { + return _reverseSnippet.default; + } +}); +Object.defineProperty(exports, "insights", { + enumerable: true, + get: function get() { + return _insights.default; + } +}); +Object.defineProperty(exports, "getInsightsAnonymousUserToken", { + enumerable: true, + get: function get() { + return _getInsightsAnonymousUserToken.default; + } +}); +Object.defineProperty(exports, "getInsightsAnonymousUserTokenInternal", { + enumerable: true, + get: function get() { + return _getInsightsAnonymousUserToken.getInsightsAnonymousUserTokenInternal; + } +}); + +var _highlight = _interopRequireWildcard(require("./highlight")); + +Object.keys(_highlight).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _highlight[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _highlight[key]; + } + }); +}); + +var _reverseHighlight = _interopRequireWildcard(require("./reverseHighlight")); + +Object.keys(_reverseHighlight).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _reverseHighlight[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _reverseHighlight[key]; + } + }); +}); + +var _snippet = _interopRequireWildcard(require("./snippet")); + +Object.keys(_snippet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _snippet[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _snippet[key]; + } + }); +}); + +var _reverseSnippet = _interopRequireWildcard(require("./reverseSnippet")); + +Object.keys(_reverseSnippet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _reverseSnippet[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _reverseSnippet[key]; + } + }); +}); + +var _insights = _interopRequireDefault(require("./insights")); + +var _getInsightsAnonymousUserToken = _interopRequireWildcard(require("./get-insights-anonymous-user-token")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/insights.js b/js/instantsearch.js/cjs/helpers/insights.js new file mode 100644 index 00000000..192f03a0 --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/insights.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.readDataAttributes = readDataAttributes; +exports.hasDataAttributes = hasDataAttributes; +exports.writeDataAttributes = writeDataAttributes; +exports.default = insights; + +var _utils = require("../lib/utils"); + +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); } + +function readDataAttributes(domElement) { + var method = domElement.getAttribute('data-insights-method'); + var serializedPayload = domElement.getAttribute('data-insights-payload'); + + if (typeof serializedPayload !== 'string') { + throw new Error('The insights helper expects `data-insights-payload` to be a base64-encoded JSON string.'); + } + + try { + var payload = (0, _utils.deserializePayload)(serializedPayload); + return { + method: method, + payload: payload + }; + } catch (error) { + throw new Error('The insights helper was unable to parse `data-insights-payload`.'); + } +} + +function hasDataAttributes(domElement) { + return domElement.hasAttribute('data-insights-method'); +} + +function writeDataAttributes(_ref) { + var method = _ref.method, + payload = _ref.payload; + + if (_typeof(payload) !== 'object') { + throw new Error("The insights helper expects the payload to be an object."); + } + + var serializedPayload; + + try { + serializedPayload = (0, _utils.serializePayload)(payload); + } catch (error) { + throw new Error("Could not JSON serialize the payload object."); + } + + return "data-insights-method=\"".concat(method, "\" data-insights-payload=\"").concat(serializedPayload, "\""); +} +/** + * @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/ + */ + + +function insights(method, payload) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`insights` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") : void 0; + return writeDataAttributes({ + method: method, + payload: payload + }); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/reverseHighlight.js b/js/instantsearch.js/cjs/helpers/reverseHighlight.js new file mode 100644 index 00000000..648592c1 --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/reverseHighlight.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = reverseHighlight; + +var _utils = require("../lib/utils"); + +var _suit = require("../lib/suit"); + +var suit = (0, _suit.component)('ReverseHighlight'); + +function reverseHighlight(_ref) { + var attribute = _ref.attribute, + _ref$highlightedTagNa = _ref.highlightedTagName, + highlightedTagName = _ref$highlightedTagNa === void 0 ? 'mark' : _ref$highlightedTagNa, + hit = _ref.hit, + _ref$cssClasses = _ref.cssClasses, + cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses; + + var _ref2 = (0, _utils.getPropertyByPath)(hit._highlightResult, attribute) || {}, + _ref2$value = _ref2.value, + attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular + + + var className = suit({ + descendantName: 'highlighted' + }) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : ''); + var reverseHighlightedValue = (0, _utils.concatHighlightedParts)((0, _utils.reverseHighlightedParts)((0, _utils.getHighlightedParts)(attributeValue))); + return reverseHighlightedValue.replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPreTag, 'g'), "<".concat(highlightedTagName, " class=\"").concat(className, "\">")).replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPostTag, 'g'), "")); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/reverseSnippet.js b/js/instantsearch.js/cjs/helpers/reverseSnippet.js new file mode 100644 index 00000000..e9262919 --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/reverseSnippet.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = reverseSnippet; + +var _utils = require("../lib/utils"); + +var _suit = require("../lib/suit"); + +var suit = (0, _suit.component)('ReverseSnippet'); + +function reverseSnippet(_ref) { + var attribute = _ref.attribute, + _ref$highlightedTagNa = _ref.highlightedTagName, + highlightedTagName = _ref$highlightedTagNa === void 0 ? 'mark' : _ref$highlightedTagNa, + hit = _ref.hit, + _ref$cssClasses = _ref.cssClasses, + cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses; + + var _ref2 = (0, _utils.getPropertyByPath)(hit._snippetResult, attribute) || {}, + _ref2$value = _ref2.value, + attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular + + + var className = suit({ + descendantName: 'highlighted' + }) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : ''); + var reverseHighlightedValue = (0, _utils.concatHighlightedParts)((0, _utils.reverseHighlightedParts)((0, _utils.getHighlightedParts)(attributeValue))); + return reverseHighlightedValue.replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPreTag, 'g'), "<".concat(highlightedTagName, " class=\"").concat(className, "\">")).replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPostTag, 'g'), "")); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/helpers/snippet.js b/js/instantsearch.js/cjs/helpers/snippet.js new file mode 100644 index 00000000..fdc2f1cb --- /dev/null +++ b/js/instantsearch.js/cjs/helpers/snippet.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = snippet; + +var _suit = require("../lib/suit"); + +var _utils = require("../lib/utils"); + +var suit = (0, _suit.component)('Snippet'); + +function snippet(_ref) { + var attribute = _ref.attribute, + _ref$highlightedTagNa = _ref.highlightedTagName, + highlightedTagName = _ref$highlightedTagNa === void 0 ? 'mark' : _ref$highlightedTagNa, + hit = _ref.hit, + _ref$cssClasses = _ref.cssClasses, + cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses; + + var _ref2 = (0, _utils.getPropertyByPath)(hit._snippetResult, attribute) || {}, + _ref2$value = _ref2.value, + attributeValue = _ref2$value === void 0 ? '' : _ref2$value; // cx is not used, since it would be bundled as a dependency for Vue & Angular + + + var className = suit({ + descendantName: 'highlighted' + }) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : ''); + return attributeValue.replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPreTag, 'g'), "<".concat(highlightedTagName, " class=\"").concat(className, "\">")).replace(new RegExp(_utils.TAG_REPLACEMENT.highlightPostTag, 'g'), "")); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/index.js b/js/instantsearch.js/cjs/index.js new file mode 100644 index 00000000..5d91212a --- /dev/null +++ b/js/instantsearch.js/cjs/index.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _main = _interopRequireDefault(require("./lib/main")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = _main.default; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/InstantSearch.js b/js/instantsearch.js/cjs/lib/InstantSearch.js new file mode 100644 index 00000000..1afa39e7 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/InstantSearch.js @@ -0,0 +1,578 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper")); + +var _events = _interopRequireDefault(require("events")); + +var _index = _interopRequireWildcard(require("../widgets/index/index")); + +var _version = _interopRequireDefault(require("./version")); + +var _createHelpers = _interopRequireDefault(require("./createHelpers")); + +var _utils = require("./utils"); + +var _createRouterMiddleware = require("../middlewares/createRouterMiddleware"); + +var _createMetadataMiddleware = require("../middlewares/createMetadataMiddleware"); + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'instantsearch' +}); + +function defaultCreateURL() { + return '#'; +} +/** + * Global options for an InstantSearch instance. + */ + + +/** + * The actual implementation of the InstantSearch. This is + * created using the `instantsearch` factory function. + * It emits the 'render' event every time a search is done + */ +var InstantSearch = /*#__PURE__*/function (_EventEmitter) { + _inherits(InstantSearch, _EventEmitter); + + var _super = _createSuper(InstantSearch); + + function InstantSearch(options) { + var _this; + + _classCallCheck(this, InstantSearch); + + _this = _super.call(this); + + _defineProperty(_assertThisInitialized(_this), "client", void 0); + + _defineProperty(_assertThisInitialized(_this), "indexName", void 0); + + _defineProperty(_assertThisInitialized(_this), "insightsClient", void 0); + + _defineProperty(_assertThisInitialized(_this), "onStateChange", null); + + _defineProperty(_assertThisInitialized(_this), "helper", void 0); + + _defineProperty(_assertThisInitialized(_this), "mainHelper", void 0); + + _defineProperty(_assertThisInitialized(_this), "mainIndex", void 0); + + _defineProperty(_assertThisInitialized(_this), "started", void 0); + + _defineProperty(_assertThisInitialized(_this), "templatesConfig", void 0); + + _defineProperty(_assertThisInitialized(_this), "renderState", {}); + + _defineProperty(_assertThisInitialized(_this), "_stalledSearchDelay", void 0); + + _defineProperty(_assertThisInitialized(_this), "_searchStalledTimer", void 0); + + _defineProperty(_assertThisInitialized(_this), "_isSearchStalled", void 0); + + _defineProperty(_assertThisInitialized(_this), "_initialUiState", void 0); + + _defineProperty(_assertThisInitialized(_this), "_createURL", void 0); + + _defineProperty(_assertThisInitialized(_this), "_searchFunction", void 0); + + _defineProperty(_assertThisInitialized(_this), "_mainHelperSearch", void 0); + + _defineProperty(_assertThisInitialized(_this), "middleware", []); + + _defineProperty(_assertThisInitialized(_this), "sendEventToInsights", void 0); + + _defineProperty(_assertThisInitialized(_this), "scheduleSearch", (0, _utils.defer)(function () { + if (_this.started) { + _this.mainHelper.search(); + } + })); + + _defineProperty(_assertThisInitialized(_this), "scheduleRender", (0, _utils.defer)(function () { + if (!_this.mainHelper.hasPendingRequests()) { + clearTimeout(_this._searchStalledTimer); + _this._searchStalledTimer = null; + _this._isSearchStalled = false; + } + + _this.mainIndex.render({ + instantSearchInstance: _assertThisInitialized(_this) + }); + + _this.emit('render'); + })); + + _defineProperty(_assertThisInitialized(_this), "onInternalStateChange", (0, _utils.defer)(function () { + var nextUiState = _this.mainIndex.getWidgetUiState({}); + + _this.middleware.forEach(function (_ref) { + var instance = _ref.instance; + instance.onStateChange({ + uiState: nextUiState + }); + }); + })); + + var _options$indexName = options.indexName, + indexName = _options$indexName === void 0 ? null : _options$indexName, + numberLocale = options.numberLocale, + _options$initialUiSta = options.initialUiState, + initialUiState = _options$initialUiSta === void 0 ? {} : _options$initialUiSta, + _options$routing = options.routing, + routing = _options$routing === void 0 ? null : _options$routing, + searchFunction = options.searchFunction, + _options$stalledSearc = options.stalledSearchDelay, + stalledSearchDelay = _options$stalledSearc === void 0 ? 200 : _options$stalledSearc, + _options$searchClient = options.searchClient, + searchClient = _options$searchClient === void 0 ? null : _options$searchClient, + _options$insightsClie = options.insightsClient, + insightsClient = _options$insightsClie === void 0 ? null : _options$insightsClie, + _options$onStateChang = options.onStateChange, + onStateChange = _options$onStateChang === void 0 ? null : _options$onStateChang; + + if (indexName === null) { + throw new Error(withUsage('The `indexName` option is required.')); + } + + if (searchClient === null) { + throw new Error(withUsage('The `searchClient` option is required.')); + } + + if (typeof searchClient.search !== 'function') { + throw new Error("The `searchClient` must implement a `search` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/"); + } + + if (typeof searchClient.addAlgoliaAgent === 'function') { + searchClient.addAlgoliaAgent("instantsearch.js (".concat(_version.default, ")")); + } + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(insightsClient === null, "`insightsClient` property has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") : void 0; + + if (insightsClient && typeof insightsClient !== 'function') { + throw new Error(withUsage('The `insightsClient` option should be a function.')); + } + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(!options.searchParameters, "The `searchParameters` option is deprecated and will not be supported in InstantSearch.js 4.x.\n\nYou can replace it with the `configure` widget:\n\n```\nsearch.addWidgets([\n configure(".concat(JSON.stringify(options.searchParameters, null, 2), ")\n]);\n```\n\nSee ").concat((0, _utils.createDocumentationLink)({ + name: 'configure' + }))) : void 0; + _this.client = searchClient; + _this.insightsClient = insightsClient; + _this.indexName = indexName; + _this.helper = null; + _this.mainHelper = null; + _this.mainIndex = (0, _index.default)({ + indexName: indexName + }); + _this.onStateChange = onStateChange; + _this.started = false; + _this.templatesConfig = { + helpers: (0, _createHelpers.default)({ + numberLocale: numberLocale + }), + compileOptions: {} + }; + _this._stalledSearchDelay = stalledSearchDelay; + _this._searchStalledTimer = null; + _this._isSearchStalled = false; + _this._createURL = defaultCreateURL; + _this._initialUiState = initialUiState; + + if (searchFunction) { + _this._searchFunction = searchFunction; + } + + _this.sendEventToInsights = _utils.noop; + + if (routing) { + var routerOptions = typeof routing === 'boolean' ? undefined : routing; + + _this.use((0, _createRouterMiddleware.createRouterMiddleware)(routerOptions)); + } + + if ((0, _createMetadataMiddleware.isMetadataEnabled)()) { + _this.use((0, _createMetadataMiddleware.createMetadataMiddleware)()); + } + + return _this; + } + /** + * Hooks a middleware into the InstantSearch lifecycle. + */ + + + _createClass(InstantSearch, [{ + key: "use", + value: function use() { + var _this2 = this; + + for (var _len = arguments.length, middleware = new Array(_len), _key = 0; _key < _len; _key++) { + middleware[_key] = arguments[_key]; + } + + var newMiddlewareList = middleware.map(function (fn) { + var newMiddleware = _objectSpread({ + subscribe: _utils.noop, + unsubscribe: _utils.noop, + onStateChange: _utils.noop + }, fn({ + instantSearchInstance: _this2 + })); + + _this2.middleware.push({ + creator: fn, + instance: newMiddleware + }); + + return newMiddleware; + }); // If the instance has already started, we directly subscribe the + // middleware so they're notified of changes. + + if (this.started) { + newMiddlewareList.forEach(function (m) { + m.subscribe(); + }); + } + + return this; + } + /** + * Removes a middleware from the InstantSearch lifecycle. + */ + + }, { + key: "unuse", + value: function unuse() { + for (var _len2 = arguments.length, middlewareToUnuse = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + middlewareToUnuse[_key2] = arguments[_key2]; + } + + this.middleware.filter(function (m) { + return middlewareToUnuse.includes(m.creator); + }).forEach(function (m) { + return m.instance.unsubscribe(); + }); + this.middleware = this.middleware.filter(function (m) { + return !middlewareToUnuse.includes(m.creator); + }); + return this; + } // @major we shipped with EXPERIMENTAL_use, but have changed that to just `use` now + + }, { + key: "EXPERIMENTAL_use", + value: function EXPERIMENTAL_use() { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, 'The middleware API is now considered stable, so we recommend replacing `EXPERIMENTAL_use` with `use` before upgrading to the next major version.') : void 0; + return this.use.apply(this, arguments); + } + /** + * Adds a widget to the search instance. + * A widget can be added either before or after InstantSearch has started. + * @param widget The widget to add to InstantSearch. + * + * @deprecated This method will still be supported in 4.x releases, but not further. It is replaced by `addWidgets([widget])`. + */ + + }, { + key: "addWidget", + value: function addWidget(widget) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, 'addWidget will still be supported in 4.x releases, but not further. It is replaced by `addWidgets([widget])`') : void 0; + return this.addWidgets([widget]); + } + /** + * Adds multiple widgets to the search instance. + * Widgets can be added either before or after InstantSearch has started. + * @param widgets The array of widgets to add to InstantSearch. + */ + + }, { + key: "addWidgets", + value: function addWidgets(widgets) { + if (!Array.isArray(widgets)) { + throw new Error(withUsage('The `addWidgets` method expects an array of widgets. Please use `addWidget`.')); + } + + if (widgets.some(function (widget) { + return typeof widget.init !== 'function' && typeof widget.render !== 'function'; + })) { + throw new Error(withUsage('The widget definition expects a `render` and/or an `init` method.')); + } + + this.mainIndex.addWidgets(widgets); + return this; + } + /** + * Removes a widget from the search instance. + * @deprecated This method will still be supported in 4.x releases, but not further. It is replaced by `removeWidgets([widget])` + * @param widget The widget instance to remove from InstantSearch. + * + * The widget must implement a `dispose()` method to clear its state. + */ + + }, { + key: "removeWidget", + value: function removeWidget(widget) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, 'removeWidget will still be supported in 4.x releases, but not further. It is replaced by `removeWidgets([widget])`') : void 0; + return this.removeWidgets([widget]); + } + /** + * Removes multiple widgets from the search instance. + * @param widgets Array of widgets instances to remove from InstantSearch. + * + * The widgets must implement a `dispose()` method to clear their states. + */ + + }, { + key: "removeWidgets", + value: function removeWidgets(widgets) { + if (!Array.isArray(widgets)) { + throw new Error(withUsage('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.')); + } + + if (widgets.some(function (widget) { + return typeof widget.dispose !== 'function'; + })) { + throw new Error(withUsage('The widget definition expects a `dispose` method.')); + } + + this.mainIndex.removeWidgets(widgets); + return this; + } + /** + * Ends the initialization of InstantSearch.js and triggers the + * first search. This method should be called after all widgets have been added + * to the instance of InstantSearch.js. InstantSearch.js also supports adding and removing + * widgets after the start as an **EXPERIMENTAL** feature. + */ + + }, { + key: "start", + value: function start() { + var _this3 = this; + + if (this.started) { + throw new Error(withUsage('The `start` method has already been called once.')); + } // This Helper is used for the queries, we don't care about its state. The + // states are managed at the `index` level. We use this Helper to create + // DerivedHelper scoped into the `index` widgets. + // In Vue InstantSearch' hydrate, a main helper gets set before start, so + // we need to respect this helper as a way to keep all listeners correct. + + + var mainHelper = this.mainHelper || (0, _algoliasearchHelper.default)(this.client, this.indexName); + + mainHelper.search = function () { + // This solution allows us to keep the exact same API for the users but + // under the hood, we have a different implementation. It should be + // completely transparent for the rest of the codebase. Only this module + // is impacted. + return mainHelper.searchOnlyWithDerivedHelpers(); + }; + + if (this._searchFunction) { + // this client isn't used to actually search, but required for the helper + // to not throw errors + var fakeClient = { + search: function search() { + return new Promise(_utils.noop); + } + }; + this._mainHelperSearch = mainHelper.search.bind(mainHelper); + + mainHelper.search = function () { + var mainIndexHelper = _this3.mainIndex.getHelper(); + + var searchFunctionHelper = (0, _algoliasearchHelper.default)(fakeClient, mainIndexHelper.state.index, mainIndexHelper.state); + searchFunctionHelper.once('search', function (_ref2) { + var state = _ref2.state; + mainIndexHelper.overrideStateWithoutTriggeringChangeEvent(state); + + _this3._mainHelperSearch(); + }); // Forward state changes from `searchFunctionHelper` to `mainIndexHelper` + + searchFunctionHelper.on('change', function (_ref3) { + var state = _ref3.state; + mainIndexHelper.setState(state); + }); + + _this3._searchFunction(searchFunctionHelper); + + return mainHelper; + }; + } // Only the "main" Helper emits the `error` event vs the one for `search` + // and `results` that are also emitted on the derived one. + + + mainHelper.on('error', function (_ref4) { + var error = _ref4.error; + + _this3.emit('error', { + error: error + }); + }); + this.mainHelper = mainHelper; + this.mainIndex.init({ + instantSearchInstance: this, + parent: null, + uiState: this._initialUiState + }); + this.middleware.forEach(function (_ref5) { + var instance = _ref5.instance; + instance.subscribe(); + }); + mainHelper.search(); // Keep the previous reference for legacy purpose, some pattern use + // the direct Helper access `search.helper` (e.g multi-index). + + this.helper = this.mainIndex.getHelper(); // track we started the search if we add more widgets, + // to init them directly after add + + this.started = true; + } + /** + * Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature, + * if you find an issue with it, please + * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20dispose). + * @return {undefined} This method does not return anything + */ + + }, { + key: "dispose", + value: function dispose() { + this.scheduleSearch.cancel(); + this.scheduleRender.cancel(); + clearTimeout(this._searchStalledTimer); + this.removeWidgets(this.mainIndex.getWidgets()); + this.mainIndex.dispose(); // You can not start an instance two times, therefore a disposed instance + // needs to set started as false otherwise this can not be restarted at a + // later point. + + this.started = false; // The helper needs to be reset to perform the next search from a fresh state. + // If not reset, it would use the state stored before calling `dispose()`. + + this.removeAllListeners(); + this.mainHelper.removeAllListeners(); + this.mainHelper = null; + this.helper = null; + this.middleware.forEach(function (_ref6) { + var instance = _ref6.instance; + instance.unsubscribe(); + }); + } + }, { + key: "scheduleStalledRender", + value: function scheduleStalledRender() { + var _this4 = this; + + if (!this._searchStalledTimer) { + this._searchStalledTimer = setTimeout(function () { + _this4._isSearchStalled = true; + + _this4.scheduleRender(); + }, this._stalledSearchDelay); + } + } + }, { + key: "setUiState", + value: function setUiState(uiState) { + if (!this.mainHelper) { + throw new Error(withUsage('The `start` method needs to be called before `setUiState`.')); + } // We refresh the index UI state to update the local UI state that the + // main index passes to the function form of `setUiState`. + + + this.mainIndex.refreshUiState(); + var nextUiState = typeof uiState === 'function' ? uiState(this.mainIndex.getWidgetUiState({})) : uiState; + + var setIndexHelperState = function setIndexHelperState(indexWidget) { + if (process.env.NODE_ENV === 'development') { + (0, _utils.checkIndexUiState)({ + index: indexWidget, + indexUiState: nextUiState[indexWidget.getIndexId()] + }); + } + + indexWidget.getHelper().setState(indexWidget.getWidgetSearchParameters(indexWidget.getHelper().state, { + uiState: nextUiState[indexWidget.getIndexId()] + })); + indexWidget.getWidgets().filter(_index.isIndexWidget).forEach(setIndexHelperState); + }; + + setIndexHelperState(this.mainIndex); + this.scheduleSearch(); + this.onInternalStateChange(); + } + }, { + key: "getUiState", + value: function getUiState() { + if (this.started) { + // We refresh the index UI state to make sure changes from `refine` are taken in account + this.mainIndex.refreshUiState(); + } + + return this.mainIndex.getWidgetUiState({}); + } + }, { + key: "createURL", + value: function createURL() { + var nextState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + if (!this.started) { + throw new Error(withUsage('The `start` method needs to be called before `createURL`.')); + } + + return this._createURL(nextState); + } + }, { + key: "refresh", + value: function refresh() { + if (!this.mainHelper) { + throw new Error(withUsage('The `start` method needs to be called before `refresh`.')); + } + + this.mainHelper.clearCache().search(); + } + }]); + + return InstantSearch; +}(_events.default); + +var _default = InstantSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/createHelpers.js b/js/instantsearch.js/cjs/lib/createHelpers.js new file mode 100644 index 00000000..fba518b8 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/createHelpers.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = hoganHelpers; + +var _helpers = require("../helpers"); + +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; } + +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; } + +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; } + +function hoganHelpers(_ref) { + var numberLocale = _ref.numberLocale; + return { + formatNumber: function formatNumber(value, render) { + return Number(render(value)).toLocaleString(numberLocale); + }, + highlight: function highlight(options, render) { + try { + var highlightOptions = JSON.parse(options); + return render((0, _helpers.highlight)(_objectSpread(_objectSpread({}, highlightOptions), {}, { + hit: this + }))); + } catch (error) { + throw new Error("\nThe highlight helper expects a JSON object of the format:\n{ \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }"); + } + }, + reverseHighlight: function reverseHighlight(options, render) { + try { + var reverseHighlightOptions = JSON.parse(options); + return render((0, _helpers.reverseHighlight)(_objectSpread(_objectSpread({}, reverseHighlightOptions), {}, { + hit: this + }))); + } catch (error) { + throw new Error("\n The reverseHighlight helper expects a JSON object of the format:\n { \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }"); + } + }, + snippet: function snippet(options, render) { + try { + var snippetOptions = JSON.parse(options); + return render((0, _helpers.snippet)(_objectSpread(_objectSpread({}, snippetOptions), {}, { + hit: this + }))); + } catch (error) { + throw new Error("\nThe snippet helper expects a JSON object of the format:\n{ \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }"); + } + }, + reverseSnippet: function reverseSnippet(options, render) { + try { + var reverseSnippetOptions = JSON.parse(options); + return render((0, _helpers.reverseSnippet)(_objectSpread(_objectSpread({}, reverseSnippetOptions), {}, { + hit: this + }))); + } catch (error) { + throw new Error("\n The reverseSnippet helper expects a JSON object of the format:\n { \"attribute\": \"name\", \"highlightedTagName\": \"mark\" }"); + } + }, + insights: function insights(options, render) { + try { + var _JSON$parse = JSON.parse(options), + method = _JSON$parse.method, + payload = _JSON$parse.payload; + + return render((0, _helpers.insights)(method, _objectSpread({ + objectIDs: [this.objectID] + }, payload))); + } catch (error) { + throw new Error("\nThe insights helper expects a JSON object of the format:\n{ \"method\": \"method-name\", \"payload\": { \"eventName\": \"name of the event\" } }"); + } + } + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/infiniteHitsCache/index.js b/js/instantsearch.js/cjs/lib/infiniteHitsCache/index.js new file mode 100644 index 00000000..9e843530 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/infiniteHitsCache/index.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "createInfiniteHitsSessionStorageCache", { + enumerable: true, + get: function get() { + return _sessionStorage.default; + } +}); + +var _sessionStorage = _interopRequireDefault(require("./sessionStorage")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/infiniteHitsCache/sessionStorage.js b/js/instantsearch.js/cjs/lib/infiniteHitsCache/sessionStorage.js new file mode 100644 index 00000000..64e3243f --- /dev/null +++ b/js/instantsearch.js/cjs/lib/infiniteHitsCache/sessionStorage.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = createInfiniteHitsSessionStorageCache; + +var _utils = require("../utils"); + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function getStateWithoutPage(state) { + var _ref = state || {}, + page = _ref.page, + rest = _objectWithoutProperties(_ref, ["page"]); + + return rest; +} + +var KEY = 'ais.infiniteHits'; + +function hasSessionStorage() { + return typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined'; +} + +function createInfiniteHitsSessionStorageCache() { + return { + read: function read(_ref2) { + var state = _ref2.state; + + if (!hasSessionStorage()) { + return null; + } + + try { + var cache = JSON.parse( // @ts-expect-error JSON.parse() requires a string, but it actually accepts null, too. + window.sessionStorage.getItem(KEY)); + return cache && (0, _utils.isEqual)(cache.state, getStateWithoutPage(state)) ? cache.hits : null; + } catch (error) { + if (error instanceof SyntaxError) { + try { + window.sessionStorage.removeItem(KEY); + } catch (err) {// do nothing + } + } + + return null; + } + }, + write: function write(_ref3) { + var state = _ref3.state, + hits = _ref3.hits; + + if (!hasSessionStorage()) { + return; + } + + try { + window.sessionStorage.setItem(KEY, JSON.stringify({ + state: getStateWithoutPage(state), + hits: hits + })); + } catch (error) {// do nothing + } + } + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/insights/client.js b/js/instantsearch.js/cjs/lib/insights/client.js new file mode 100644 index 00000000..8a6f9e95 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/insights/client.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = withInsights; +exports.inferPayload = void 0; + +var _utils = require("../utils"); + +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; } + +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; } + +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; } + +var getSelectedHits = function getSelectedHits(hits, selectedObjectIDs) { + return selectedObjectIDs.map(function (objectID) { + var hit = (0, _utils.find)(hits, function (h) { + return h.objectID === objectID; + }); + + if (typeof hit === 'undefined') { + throw new Error("Could not find objectID \"".concat(objectID, "\" passed to `clickedObjectIDsAfterSearch` in the returned hits. This is necessary to infer the absolute position and the query ID.")); + } + + return hit; + }); +}; + +var getQueryID = function getQueryID(selectedHits) { + var queryIDs = (0, _utils.uniq)(selectedHits.map(function (hit) { + return hit.__queryID; + })); + + if (queryIDs.length > 1) { + throw new Error('Insights currently allows a single `queryID`. The `objectIDs` provided map to multiple `queryID`s.'); + } + + var queryID = queryIDs[0]; + + if (typeof queryID !== 'string') { + throw new Error("Could not infer `queryID`. Ensure InstantSearch `clickAnalytics: true` was added with the Configure widget.\n\nSee: https://alg.li/lNiZZ7"); + } + + return queryID; +}; + +var getPositions = function getPositions(selectedHits) { + return selectedHits.map(function (hit) { + return hit.__position; + }); +}; + +var inferPayload = function inferPayload(_ref) { + var method = _ref.method, + results = _ref.results, + hits = _ref.hits, + objectIDs = _ref.objectIDs; + var index = results.index; + var selectedHits = getSelectedHits(hits, objectIDs); + var queryID = getQueryID(selectedHits); + + switch (method) { + case 'clickedObjectIDsAfterSearch': + { + var positions = getPositions(selectedHits); + return { + index: index, + queryID: queryID, + objectIDs: objectIDs, + positions: positions + }; + } + + case 'convertedObjectIDsAfterSearch': + return { + index: index, + queryID: queryID, + objectIDs: objectIDs + }; + + default: + throw new Error("Unsupported method passed to insights: \"".concat(method, "\".")); + } +}; + +exports.inferPayload = inferPayload; + +var wrapInsightsClient = function wrapInsightsClient(aa, results, hits) { + return function (method, payload) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`insights` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") : void 0; + + if (!aa) { + var withInstantSearchUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'instantsearch' + }); + throw new Error(withInstantSearchUsage('The `insightsClient` option has not been provided to `instantsearch`.')); + } + + if (!Array.isArray(payload.objectIDs)) { + throw new TypeError('Expected `objectIDs` to be an array.'); + } + + var inferredPayload = inferPayload({ + method: method, + results: results, + hits: hits, + objectIDs: payload.objectIDs + }); + aa(method, _objectSpread(_objectSpread({}, inferredPayload), payload)); + }; +}; +/** + * @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/ + * It passes `insights` to `HitsWithInsightsListener` and `InfiniteHitsWithInsightsListener`. + */ + + +function withInsights(connector) { + return function (renderFn, unmountFn) { + return connector(function (renderOptions, isFirstRender) { + var results = renderOptions.results, + hits = renderOptions.hits, + instantSearchInstance = renderOptions.instantSearchInstance; + + if (results && hits && instantSearchInstance) { + var insights = wrapInsightsClient(instantSearchInstance.insightsClient, results, hits); + return renderFn(_objectSpread(_objectSpread({}, renderOptions), {}, { + insights: insights + }), isFirstRender); + } + + return renderFn(renderOptions, isFirstRender); + }, unmountFn); + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/insights/index.js b/js/instantsearch.js/cjs/lib/insights/index.js new file mode 100644 index 00000000..bc62bf25 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/insights/index.js @@ -0,0 +1,35 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "withInsights", { + enumerable: true, + get: function get() { + return _client.default; + } +}); +Object.defineProperty(exports, "inferInsightsPayload", { + enumerable: true, + get: function get() { + return _client.inferPayload; + } +}); +Object.defineProperty(exports, "withInsightsListener", { + enumerable: true, + get: function get() { + return _listener.default; + } +}); + +var _client = _interopRequireWildcard(require("./client")); + +var _listener = _interopRequireDefault(require("./listener")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/insights/listener.js b/js/instantsearch.js/cjs/lib/insights/listener.js new file mode 100644 index 00000000..2db497ab --- /dev/null +++ b/js/instantsearch.js/cjs/lib/insights/listener.js @@ -0,0 +1,81 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _utils = require("../utils"); + +var _insights = require("../../helpers/insights"); + +/** @jsx h */ +var findInsightsTarget = function findInsightsTarget(startElement, endElement, validator) { + var element = startElement; + + while (element && !validator(element)) { + if (element === endElement) { + return null; + } + + element = element.parentElement; + } + + return element; +}; + +var parseInsightsEvent = function parseInsightsEvent(element) { + var serializedPayload = element.getAttribute('data-insights-event'); + + if (typeof serializedPayload !== 'string') { + throw new Error('The insights middleware expects `data-insights-event` to be a base64-encoded JSON string.'); + } + + try { + return (0, _utils.deserializePayload)(serializedPayload); + } catch (error) { + throw new Error('The insights middleware was unable to parse `data-insights-event`.'); + } +}; + +var insightsListener = function insightsListener(BaseComponent) { + function WithInsightsListener(props) { + var handleClick = function handleClick(event) { + if (props.sendEvent) { + // new way with insights middleware + var targetWithEvent = findInsightsTarget(event.target, event.currentTarget, function (element) { + return element.hasAttribute('data-insights-event'); + }); + + if (targetWithEvent) { + var payload = parseInsightsEvent(targetWithEvent); + props.sendEvent(payload); + } + } // old way, e.g. instantsearch.insights("clickedObjectIDsAfterSearch", { .. }) + + + var insightsTarget = findInsightsTarget(event.target, event.currentTarget, function (element) { + return (0, _insights.hasDataAttributes)(element); + }); + + if (insightsTarget) { + var _readDataAttributes = (0, _insights.readDataAttributes)(insightsTarget), + method = _readDataAttributes.method, + _payload = _readDataAttributes.payload; + + props.insights(method, _payload); + } + }; + + return (0, _preact.h)("div", { + onClick: handleClick + }, (0, _preact.h)(BaseComponent, props)); + } + + return WithInsightsListener; +}; + +var _default = insightsListener; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/main.js b/js/instantsearch.js/cjs/lib/main.js new file mode 100644 index 00000000..e2a981ae --- /dev/null +++ b/js/instantsearch.js/cjs/lib/main.js @@ -0,0 +1,68 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _InstantSearch = _interopRequireDefault(require("./InstantSearch")); + +var _version = _interopRequireDefault(require("./version")); + +var connectors = _interopRequireWildcard(require("../connectors/index")); + +var widgets = _interopRequireWildcard(require("../widgets/index")); + +var helpers = _interopRequireWildcard(require("../helpers/index")); + +var middlewares = _interopRequireWildcard(require("../middlewares/index")); + +var routers = _interopRequireWildcard(require("./routers/index")); + +var stateMappings = _interopRequireWildcard(require("./stateMappings/index")); + +var _index7 = require("./infiniteHitsCache/index"); + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * InstantSearch is the main component of InstantSearch.js. This object + * manages the widget and lets you add new ones. + * + * Two parameters are required to get you started with InstantSearch.js: + * - `indexName`: the main index that you will use for your new search UI + * - `searchClient`: the search client to plug to InstantSearch.js + * + * The [search client provided by Algolia](https://github.com/algolia/algoliasearch-client-javascript) + * needs an `appId` and an `apiKey`. Those parameters can be found in your + * [Algolia dashboard](https://www.algolia.com/api-keys). + * + * If you want to get up and running quickly with InstantSearch.js, have a + * look at the [getting started](getting-started.html). + * @function instantsearch + * @param {InstantSearchOptions} options The options + */ +var instantsearch = function instantsearch(options) { + return new _InstantSearch.default(options); +}; + +instantsearch.routers = routers; +instantsearch.stateMappings = stateMappings; +instantsearch.connectors = connectors; +instantsearch.widgets = widgets; +instantsearch.version = _version.default; +instantsearch.createInfiniteHitsSessionStorageCache = _index7.createInfiniteHitsSessionStorageCache; +instantsearch.highlight = helpers.highlight; +instantsearch.reverseHighlight = helpers.reverseHighlight; +instantsearch.snippet = helpers.snippet; +instantsearch.reverseSnippet = helpers.reverseSnippet; +instantsearch.insights = helpers.insights; +instantsearch.middlewares = middlewares; +var _default = instantsearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/routers/history.js b/js/instantsearch.js/cjs/lib/routers/history.js new file mode 100644 index 00000000..1ad35fd9 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/routers/history.js @@ -0,0 +1,204 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _default; + +var _qs = _interopRequireDefault(require("qs")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +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; } + +var defaultCreateURL = function defaultCreateURL(_ref) { + var qsModule = _ref.qsModule, + routeState = _ref.routeState, + location = _ref.location; + var protocol = location.protocol, + hostname = location.hostname, + _location$port = location.port, + port = _location$port === void 0 ? '' : _location$port, + pathname = location.pathname, + hash = location.hash; + var queryString = qsModule.stringify(routeState); + var portWithPrefix = port === '' ? '' : ":".concat(port); // IE <= 11 has no proper `location.origin` so we cannot rely on it. + + if (!queryString) { + return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname).concat(hash); + } + + return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname, "?").concat(queryString).concat(hash); +}; + +var defaultParseURL = function defaultParseURL(_ref2) { + var qsModule = _ref2.qsModule, + location = _ref2.location; + // `qs` by default converts arrays with more than 20 items to an object. + // We want to avoid this because the data structure manipulated can therefore vary. + // Setting the limit to `100` seems a good number because the engine's default is 100 + // (it can go up to 1000 but it is very unlikely to select more than 100 items in the UI). + // + // Using an `arrayLimit` of `n` allows `n + 1` items. + // + // See: + // - https://github.com/ljharb/qs#parsing-arrays + // - https://www.algolia.com/doc/api-reference/api-parameters/maxValuesPerFacet/ + return qsModule.parse(location.search.slice(1), { + arrayLimit: 99 + }); +}; + +var setWindowTitle = function setWindowTitle(title) { + if (title) { + window.document.title = title; + } +}; + +var BrowserHistory = /*#__PURE__*/function () { + /** + * Initializes a new storage provider that syncs the search state to the URL + * using web APIs (`window.location.pushState` and `onpopstate` event). + */ + function BrowserHistory() { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + windowTitle = _ref3.windowTitle, + _ref3$writeDelay = _ref3.writeDelay, + writeDelay = _ref3$writeDelay === void 0 ? 400 : _ref3$writeDelay, + _ref3$createURL = _ref3.createURL, + createURL = _ref3$createURL === void 0 ? defaultCreateURL : _ref3$createURL, + _ref3$parseURL = _ref3.parseURL, + parseURL = _ref3$parseURL === void 0 ? defaultParseURL : _ref3$parseURL; + + _classCallCheck(this, BrowserHistory); + + _defineProperty(this, "windowTitle", void 0); + + _defineProperty(this, "writeDelay", void 0); + + _defineProperty(this, "_createURL", void 0); + + _defineProperty(this, "parseURL", void 0); + + _defineProperty(this, "writeTimer", void 0); + + this.windowTitle = windowTitle; + this.writeTimer = undefined; + this.writeDelay = writeDelay; + this._createURL = createURL; + this.parseURL = parseURL; + var title = this.windowTitle && this.windowTitle(this.read()); + setWindowTitle(title); + } + /** + * Reads the URL and returns a syncable UI search state. + */ + + + _createClass(BrowserHistory, [{ + key: "read", + value: function read() { + return this.parseURL({ + qsModule: _qs.default, + location: window.location + }); + } + /** + * Pushes a search state into the URL. + */ + + }, { + key: "write", + value: function write(routeState) { + var _this = this; + + var url = this.createURL(routeState); + var title = this.windowTitle && this.windowTitle(routeState); + + if (this.writeTimer) { + window.clearTimeout(this.writeTimer); + } + + this.writeTimer = window.setTimeout(function () { + setWindowTitle(title); + window.history.pushState(routeState, title || '', url); + _this.writeTimer = undefined; + }, this.writeDelay); + } + /** + * Sets a callback on the `onpopstate` event of the history API of the current page. + * It enables the URL sync to keep track of the changes. + */ + + }, { + key: "onUpdate", + value: function onUpdate(callback) { + var _this2 = this; + + this._onPopState = function (event) { + if (_this2.writeTimer) { + window.clearTimeout(_this2.writeTimer); + _this2.writeTimer = undefined; + } + + var routeState = event.state; // At initial load, the state is read from the URL without update. + // Therefore the state object is not available. + // In this case, we fallback and read the URL. + + if (!routeState) { + callback(_this2.read()); + } else { + callback(routeState); + } + }; + + window.addEventListener('popstate', this._onPopState); + } + /** + * Creates a complete URL from a given syncable UI state. + * + * It always generates the full URL, not a relative one. + * This allows to handle cases like using a . + * See: https://github.com/algolia/instantsearch.js/issues/790 + */ + + }, { + key: "createURL", + value: function createURL(routeState) { + return this._createURL({ + qsModule: _qs.default, + routeState: routeState, + location: window.location + }); + } + /** + * Removes the event listener and cleans up the URL. + */ + + }, { + key: "dispose", + value: function dispose() { + if (this._onPopState) { + window.removeEventListener('popstate', this._onPopState); + } + + if (this.writeTimer) { + window.clearTimeout(this.writeTimer); + } + + this.write({}); + } + }]); + + return BrowserHistory; +}(); + +function _default(props) { + return new BrowserHistory(props); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/routers/index.js b/js/instantsearch.js/cjs/lib/routers/index.js new file mode 100644 index 00000000..30b57c84 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/routers/index.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "history", { + enumerable: true, + get: function get() { + return _history.default; + } +}); + +var _history = _interopRequireDefault(require("./history")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/stateMappings/index.js b/js/instantsearch.js/cjs/lib/stateMappings/index.js new file mode 100644 index 00000000..80271755 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/stateMappings/index.js @@ -0,0 +1,23 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "simple", { + enumerable: true, + get: function get() { + return _simple.default; + } +}); +Object.defineProperty(exports, "singleIndex", { + enumerable: true, + get: function get() { + return _singleIndex.default; + } +}); + +var _simple = _interopRequireDefault(require("./simple")); + +var _singleIndex = _interopRequireDefault(require("./singleIndex")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/stateMappings/simple.js b/js/instantsearch.js/cjs/lib/stateMappings/simple.js new file mode 100644 index 00000000..21eceb1c --- /dev/null +++ b/js/instantsearch.js/cjs/lib/stateMappings/simple.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = simpleStateMapping; + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function getIndexStateWithoutConfigure(uiState) { + var configure = uiState.configure, + trackedUiState = _objectWithoutProperties(uiState, ["configure"]); + + return trackedUiState; +} // technically a URL could contain any key, since users provide it, +// which is why the input to this function is UiState, not something +// which excludes "configure" as this function does. + + +function simpleStateMapping() { + return { + stateToRoute: function stateToRoute(uiState) { + return Object.keys(uiState).reduce(function (state, indexId) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, indexId, getIndexStateWithoutConfigure(uiState[indexId]))); + }, {}); + }, + routeToState: function routeToState() { + var routeState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return Object.keys(routeState).reduce(function (state, indexId) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, indexId, getIndexStateWithoutConfigure(routeState[indexId]))); + }, {}); + } + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/stateMappings/singleIndex.js b/js/instantsearch.js/cjs/lib/stateMappings/singleIndex.js new file mode 100644 index 00000000..c797e169 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/stateMappings/singleIndex.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = singleIndexStateMapping; + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function getIndexStateWithoutConfigure(uiState) { + var configure = uiState.configure, + trackedUiState = _objectWithoutProperties(uiState, ["configure"]); + + return trackedUiState; +} + +function singleIndexStateMapping(indexName) { + return { + stateToRoute: function stateToRoute(uiState) { + return getIndexStateWithoutConfigure(uiState[indexName] || {}); + }, + routeToState: function routeToState() { + var routeState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return _defineProperty({}, indexName, getIndexStateWithoutConfigure(routeState)); + } + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/suit.js b/js/instantsearch.js/cjs/lib/suit.js new file mode 100644 index 00000000..1d0fbd67 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/suit.js @@ -0,0 +1,21 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.component = void 0; +var NAMESPACE = 'ais'; + +var component = function component(componentName) { + return function () { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + descendantName = _ref.descendantName, + modifierName = _ref.modifierName; + + var descendent = descendantName ? "-".concat(descendantName) : ''; + var modifier = modifierName ? "--".concat(modifierName) : ''; + return "".concat(NAMESPACE, "-").concat(componentName).concat(descendent).concat(modifier); + }; +}; + +exports.component = component; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/capitalize.js b/js/instantsearch.js/cjs/lib/utils/capitalize.js new file mode 100644 index 00000000..b0ca1b54 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/capitalize.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function capitalize(text) { + return text.toString().charAt(0).toUpperCase() + text.toString().slice(1); +} + +var _default = capitalize; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/checkIndexUiState.js b/js/instantsearch.js/cjs/lib/utils/checkIndexUiState.js new file mode 100644 index 00000000..e79aa79a --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/checkIndexUiState.js @@ -0,0 +1,180 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.checkIndexUiState = checkIndexUiState; + +var _capitalize = _interopRequireDefault(require("./capitalize")); + +var _logger = require("./logger"); + +var _typedObject = require("./typedObject"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +// Some connectors are responsible for multiple widgets so we need +// to map them. +function getWidgetNames(connectorName) { + switch (connectorName) { + case 'range': + return []; + + case 'menu': + return ['menu', 'menuSelect']; + + default: + return [connectorName]; + } +} + +var stateToWidgetsMap = { + query: { + connectors: ['connectSearchBox'], + widgets: ['ais.searchBox', 'ais.autocomplete', 'ais.voiceSearch'] + }, + refinementList: { + connectors: ['connectRefinementList'], + widgets: ['ais.refinementList'] + }, + menu: { + connectors: ['connectMenu'], + widgets: ['ais.menu'] + }, + hierarchicalMenu: { + connectors: ['connectHierarchicalMenu'], + widgets: ['ais.hierarchicalMenu'] + }, + numericMenu: { + connectors: ['connectNumericMenu'], + widgets: ['ais.numericMenu'] + }, + ratingMenu: { + connectors: ['connectRatingMenu'], + widgets: ['ais.ratingMenu'] + }, + range: { + connectors: ['connectRange'], + widgets: ['ais.rangeInput', 'ais.rangeSlider', 'ais.range'] + }, + toggle: { + connectors: ['connectToggleRefinement'], + widgets: ['ais.toggleRefinement'] + }, + geoSearch: { + connectors: ['connectGeoSearch'], + widgets: ['ais.geoSearch'] + }, + sortBy: { + connectors: ['connectSortBy'], + widgets: ['ais.sortBy'] + }, + page: { + connectors: ['connectPagination'], + widgets: ['ais.pagination', 'ais.infiniteHits'] + }, + hitsPerPage: { + connectors: ['connectHitsPerPage'], + widgets: ['ais.hitsPerPage'] + }, + configure: { + connectors: ['connectConfigure'], + widgets: ['ais.configure'] + }, + places: { + connectors: [], + widgets: ['ais.places'] + } +}; + +function checkIndexUiState(_ref) { + var index = _ref.index, + indexUiState = _ref.indexUiState; + var mountedWidgets = index.getWidgets().map(function (widget) { + return widget.$$type; + }).filter(Boolean); + var missingWidgets = (0, _typedObject.keys)(indexUiState).reduce(function (acc, parameter) { + var widgetUiState = stateToWidgetsMap[parameter]; + + if (!widgetUiState) { + return acc; + } + + var requiredWidgets = widgetUiState.widgets; + + if (requiredWidgets && !requiredWidgets.some(function (requiredWidget) { + return mountedWidgets.includes(requiredWidget); + })) { + acc.push([parameter, { + connectors: widgetUiState.connectors, + widgets: widgetUiState.widgets.map(function (widgetIdentifier) { + return widgetIdentifier.split('ais.')[1]; + }) + }]); + } + + return acc; + }, []); + 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) { + var _ref4; + + var _ref3 = _slicedToArray(_ref2, 2), + stateParameter = _ref3[0], + widgets = _ref3[1].widgets; + + return "- `".concat(stateParameter, "` needs one of these widgets: ").concat((_ref4 = []).concat.apply(_ref4, _toConsumableArray(widgets.map(function (name) { + return getWidgetNames(name); + }))).map(function (name) { + return "\"".concat(name, "\""); + }).join(', ')); + }).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) { + var _ref6 = _slicedToArray(_ref5, 2), + _stateParameter = _ref6[0], + connectors = _ref6[1].connectors; + + return connectors.length > 0; + }).map(function (_ref7) { + var _ref8 = _slicedToArray(_ref7, 2), + _stateParameter = _ref8[0], + _ref8$ = _ref8[1], + connectors = _ref8$.connectors, + widgets = _ref8$.widgets; + + var capitalizedWidget = (0, _capitalize.default)(widgets[0]); + var connectorName = connectors[0]; + return "const virtual".concat(capitalizedWidget, " = ").concat(connectorName, "(() => null);"); + }).join('\n'), "\n\nsearch.addWidgets([\n ").concat(missingWidgets.filter(function (_ref9) { + var _ref10 = _slicedToArray(_ref9, 2), + _stateParameter = _ref10[0], + connectors = _ref10[1].connectors; + + return connectors.length > 0; + }).map(function (_ref11) { + var _ref12 = _slicedToArray(_ref11, 2), + _stateParameter = _ref12[0], + widgets = _ref12[1].widgets; + + var capitalizedWidget = (0, _capitalize.default)(widgets[0]); + return "virtual".concat(capitalizedWidget, "({ /* ... */ })"); + }).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; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/checkRendering.js b/js/instantsearch.js/cjs/lib/utils/checkRendering.js new file mode 100644 index 00000000..61f496ca --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/checkRendering.js @@ -0,0 +1,19 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _getObjectType = _interopRequireDefault(require("./getObjectType")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function checkRendering(rendering, usage) { + if (rendering === undefined || typeof rendering !== 'function') { + throw new Error("The render function is not valid (received type ".concat((0, _getObjectType.default)(rendering), ").\n\n").concat(usage)); + } +} + +var _default = checkRendering; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/clearRefinements.js b/js/instantsearch.js/cjs/lib/utils/clearRefinements.js new file mode 100644 index 00000000..a75c77d9 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/clearRefinements.js @@ -0,0 +1,50 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** + * Clears the refinements of a SearchParameters object based on rules provided. + * The included attributes list is applied before the excluded attributes list. If the list + * is not provided, this list of all the currently refined attributes is used as included attributes. + * @param {object} $0 parameters + * @param {Helper} $0.helper instance of the Helper + * @param {string[]} [$0.attributesToClear = []] list of parameters to clear + * @returns {SearchParameters} search parameters with refinements cleared + */ +function clearRefinements(_ref) { + var helper = _ref.helper, + _ref$attributesToClea = _ref.attributesToClear, + attributesToClear = _ref$attributesToClea === void 0 ? [] : _ref$attributesToClea; + var finalState = helper.state.setPage(0); + finalState = attributesToClear.reduce(function (state, attribute) { + if (finalState.isNumericRefined(attribute)) { + return state.removeNumericRefinement(attribute); + } + + if (finalState.isHierarchicalFacet(attribute)) { + return state.removeHierarchicalFacetRefinement(attribute); + } + + if (finalState.isDisjunctiveFacet(attribute)) { + return state.removeDisjunctiveFacetRefinement(attribute); + } + + if (finalState.isConjunctiveFacet(attribute)) { + return state.removeFacetRefinement(attribute); + } + + return state; + }, finalState); + + if (attributesToClear.indexOf('query') !== -1) { + finalState = finalState.setQuery(''); + } + + return finalState; +} + +var _default = clearRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/concatHighlightedParts.js b/js/instantsearch.js/cjs/lib/utils/concatHighlightedParts.js new file mode 100644 index 00000000..44d83e0b --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/concatHighlightedParts.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = concatHighlightedParts; + +var _escapeHighlight = require("./escape-highlight"); + +function concatHighlightedParts(parts) { + var highlightPreTag = _escapeHighlight.TAG_REPLACEMENT.highlightPreTag, + highlightPostTag = _escapeHighlight.TAG_REPLACEMENT.highlightPostTag; + return parts.map(function (part) { + return part.isHighlighted ? highlightPreTag + part.value + highlightPostTag : part.value; + }).join(''); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/convertNumericRefinementsToFilters.js b/js/instantsearch.js/cjs/lib/utils/convertNumericRefinementsToFilters.js new file mode 100644 index 00000000..27cbf83e --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/convertNumericRefinementsToFilters.js @@ -0,0 +1,31 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.convertNumericRefinementsToFilters = convertNumericRefinementsToFilters; + +function convertNumericRefinementsToFilters(state, attribute) { + if (!state) { + return null; + } + + var filtersObj = state.numericRefinements[attribute]; + /* + filtersObj === { + "<=": [10], + "=": [], + ">=": [5] + } + */ + + var filters = []; + Object.keys(filtersObj).filter(function (operator) { + return Array.isArray(filtersObj[operator]) && filtersObj[operator].length > 0; + }).forEach(function (operator) { + filtersObj[operator].forEach(function (value) { + filters.push("".concat(attribute).concat(operator).concat(value)); + }); + }); + return filters; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/createConcurrentSafePromise.js b/js/instantsearch.js/cjs/lib/utils/createConcurrentSafePromise.js new file mode 100644 index 00000000..197d2e38 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/createConcurrentSafePromise.js @@ -0,0 +1,46 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createConcurrentSafePromise = createConcurrentSafePromise; + +// copied from +// https://github.com/algolia/autocomplete.js/blob/307a7acc4283e10a19cb7d067f04f1bea79dc56f/packages/autocomplete-core/src/utils/createConcurrentSafePromise.ts#L1:L1 + +/** + * Creates a runner that executes promises in a concurrent-safe way. + * + * This is useful to prevent older promises to resolve after a newer promise, + * otherwise resulting in stale resolved values. + */ +function createConcurrentSafePromise() { + var basePromiseId = -1; + var latestResolvedId = -1; + var latestResolvedValue = undefined; + return function runConcurrentSafePromise(promise) { + var currentPromiseId = ++basePromiseId; + return Promise.resolve(promise).then(function (x) { + // The promise might take too long to resolve and get outdated. This would + // result in resolving stale values. + // When this happens, we ignore the promise value and return the one + // coming from the latest resolved value. + // + // +----------------------------------+ + // | 100ms | + // | run(1) +---> R1 | + // | 300ms | + // | run(2) +-------------> R2 (SKIP) | + // | 200ms | + // | run(3) +--------> R3 | + // +----------------------------------+ + if (latestResolvedValue && currentPromiseId < latestResolvedId) { + return latestResolvedValue; + } + + latestResolvedId = currentPromiseId; + latestResolvedValue = x; + return x; + }); + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/createSendEventForFacet.js b/js/instantsearch.js/cjs/lib/utils/createSendEventForFacet.js new file mode 100644 index 00000000..b0d6e411 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/createSendEventForFacet.js @@ -0,0 +1,53 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createSendEventForFacet = createSendEventForFacet; + +var _isFacetRefined = _interopRequireDefault(require("./isFacetRefined")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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); } + +function createSendEventForFacet(_ref) { + var instantSearchInstance = _ref.instantSearchInstance, + helper = _ref.helper, + attribute = _ref.attribute, + widgetType = _ref.widgetType; + + var sendEventForFacet = function sendEventForFacet() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var eventType = args[0], + facetValue = args[1], + _args$ = args[2], + eventName = _args$ === void 0 ? 'Filter Applied' : _args$; + + if (args.length === 1 && _typeof(args[0]) === 'object') { + instantSearchInstance.sendEventToInsights(args[0]); + } else if (eventType === 'click' && (args.length === 2 || args.length === 3)) { + if (!(0, _isFacetRefined.default)(helper, attribute, facetValue)) { + // send event only when the facet is being checked "ON" + instantSearchInstance.sendEventToInsights({ + insightsMethod: 'clickedFilters', + widgetType: widgetType, + eventType: eventType, + payload: { + eventName: eventName, + index: helper.getIndex(), + filters: ["".concat(attribute, ":").concat(facetValue)] + }, + attribute: attribute + }); + } + } else if (process.env.NODE_ENV === 'development') { + 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"); + } + }; + + return sendEventForFacet; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/createSendEventForHits.js b/js/instantsearch.js/cjs/lib/utils/createSendEventForHits.js new file mode 100644 index 00000000..75253bc5 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/createSendEventForHits.js @@ -0,0 +1,155 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createSendEventForHits = createSendEventForHits; +exports.createBindEventForHits = createBindEventForHits; + +var _serializer = require("../../lib/utils/serializer"); + +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); } + +var buildPayload = function buildPayload(_ref) { + var index = _ref.index, + widgetType = _ref.widgetType, + methodName = _ref.methodName, + args = _ref.args; + + if (args.length === 1 && _typeof(args[0]) === 'object') { + return args[0]; + } + + var eventType = args[0]; + var hits = args[1]; + var eventName = args[2]; + + if (!hits) { + if (process.env.NODE_ENV === 'development') { + throw new Error("You need to pass hit or hits as the second argument like:\n ".concat(methodName, "(eventType, hit);\n ")); + } else { + return null; + } + } + + if ((eventType === 'click' || eventType === 'conversion') && !eventName) { + if (process.env.NODE_ENV === 'development') { + 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 ")); + } else { + return null; + } + } + + var hitsArray = Array.isArray(hits) ? removeEscapedFromHits(hits) : [hits]; + + if (hitsArray.length === 0) { + return null; + } + + var queryID = hitsArray[0].__queryID; + var objectIDs = hitsArray.map(function (hit) { + return hit.objectID; + }); + var positions = hitsArray.map(function (hit) { + return hit.__position; + }); + + if (eventType === 'view') { + return { + insightsMethod: 'viewedObjectIDs', + widgetType: widgetType, + eventType: eventType, + payload: { + eventName: eventName || 'Hits Viewed', + index: index, + objectIDs: objectIDs + }, + hits: hitsArray + }; + } else if (eventType === 'click') { + return { + insightsMethod: 'clickedObjectIDsAfterSearch', + widgetType: widgetType, + eventType: eventType, + payload: { + eventName: eventName, + index: index, + queryID: queryID, + objectIDs: objectIDs, + positions: positions + }, + hits: hitsArray + }; + } else if (eventType === 'conversion') { + return { + insightsMethod: 'convertedObjectIDsAfterSearch', + widgetType: widgetType, + eventType: eventType, + payload: { + eventName: eventName, + index: index, + queryID: queryID, + objectIDs: objectIDs + }, + hits: hitsArray + }; + } else if (process.env.NODE_ENV === 'development') { + throw new Error("eventType(\"".concat(eventType, "\") is not supported.\n If you want to send a custom payload, you can pass one object: ").concat(methodName, "(customPayload);\n ")); + } else { + return null; + } +}; + +function removeEscapedFromHits(hits) { + // this returns without `hits.__escaped` + // and this way it doesn't mutate the original `hits` + return hits.map(function (hit) { + return hit; + }); +} + +function createSendEventForHits(_ref2) { + var instantSearchInstance = _ref2.instantSearchInstance, + index = _ref2.index, + widgetType = _ref2.widgetType; + + var sendEventForHits = function sendEventForHits() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var payload = buildPayload({ + widgetType: widgetType, + index: index, + methodName: 'sendEvent', + args: args + }); + + if (payload) { + instantSearchInstance.sendEventToInsights(payload); + } + }; + + return sendEventForHits; +} + +function createBindEventForHits(_ref3) { + var index = _ref3.index, + widgetType = _ref3.widgetType; + + var bindEventForHits = function bindEventForHits() { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var payload = buildPayload({ + widgetType: widgetType, + index: index, + methodName: 'bindEvent', + args: args + }); + return payload ? "data-insights-event=".concat((0, _serializer.serializePayload)(payload)) : ''; + }; + + return bindEventForHits; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/debounce.js b/js/instantsearch.js/cjs/lib/utils/debounce.js new file mode 100644 index 00000000..1e867487 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/debounce.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.debounce = debounce; + +// Debounce a function call to the trailing edge. +// The debounced function returns a promise. +function debounce(func, wait) { + var lastTimeout = null; + return function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return new Promise(function (resolve, reject) { + if (lastTimeout) { + clearTimeout(lastTimeout); + } + + lastTimeout = setTimeout(function () { + lastTimeout = null; + Promise.resolve(func.apply(void 0, args)).then(resolve).catch(reject); + }, wait); + }); + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/defer.js b/js/instantsearch.js/cjs/lib/utils/defer.js new file mode 100644 index 00000000..0108f9d9 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/defer.js @@ -0,0 +1,54 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var nextMicroTask = Promise.resolve(); + +var defer = function defer(callback) { + var progress = null; + var cancelled = false; + + var fn = function fn() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (progress !== null) { + return; + } + + progress = nextMicroTask.then(function () { + progress = null; + + if (cancelled) { + cancelled = false; + return; + } + + callback.apply(void 0, args); + }); + }; + + fn.wait = function () { + if (progress === null) { + throw new Error('The deferred function should be called before calling `wait()`'); + } + + return progress; + }; + + fn.cancel = function () { + if (progress === null) { + return; + } + + cancelled = true; + }; + + return fn; +}; + +var _default = defer; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/detect-insights-client.js b/js/instantsearch.js/cjs/lib/utils/detect-insights-client.js new file mode 100644 index 00000000..1cda2a4e --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/detect-insights-client.js @@ -0,0 +1,10 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = hasDetectedInsightsClient; + +function hasDetectedInsightsClient() { + return typeof window !== 'undefined' && Boolean(window.AlgoliaAnalyticsObject); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/documentation.js b/js/instantsearch.js/cjs/lib/utils/documentation.js new file mode 100644 index 00000000..3b0b7012 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/documentation.js @@ -0,0 +1,30 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createDocumentationMessageGenerator = exports.createDocumentationLink = void 0; + +var createDocumentationLink = function createDocumentationLink(_ref) { + var name = _ref.name, + _ref$connector = _ref.connector, + connector = _ref$connector === void 0 ? false : _ref$connector; + return ['https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : ''].join(''); +}; + +exports.createDocumentationLink = createDocumentationLink; + +var createDocumentationMessageGenerator = function createDocumentationMessageGenerator() { + for (var _len = arguments.length, widgets = new Array(_len), _key = 0; _key < _len; _key++) { + widgets[_key] = arguments[_key]; + } + + var links = widgets.map(function (widget) { + return createDocumentationLink(widget); + }).join(', '); + return function (message) { + return [message, "See documentation: ".concat(links)].filter(Boolean).join('\n\n'); + }; +}; + +exports.createDocumentationMessageGenerator = createDocumentationMessageGenerator; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/escape-highlight.js b/js/instantsearch.js/cjs/lib/utils/escape-highlight.js new file mode 100644 index 00000000..144a9845 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/escape-highlight.js @@ -0,0 +1,84 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.escapeHits = escapeHits; +exports.escapeFacets = escapeFacets; +exports.TAG_REPLACEMENT = exports.TAG_PLACEHOLDER = void 0; + +var _escape = _interopRequireDefault(require("./escape")); + +var _isPlainObject = _interopRequireDefault(require("./isPlainObject")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _extends() { _extends = Object.assign || 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); } + +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; } + +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; } + +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; } + +var TAG_PLACEHOLDER = { + highlightPreTag: '__ais-highlight__', + highlightPostTag: '__/ais-highlight__' +}; +exports.TAG_PLACEHOLDER = TAG_PLACEHOLDER; +var TAG_REPLACEMENT = { + highlightPreTag: '', + highlightPostTag: '' +}; +exports.TAG_REPLACEMENT = TAG_REPLACEMENT; + +function replaceTagsAndEscape(value) { + return (0, _escape.default)(value).replace(new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'), TAG_REPLACEMENT.highlightPreTag).replace(new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'), TAG_REPLACEMENT.highlightPostTag); +} + +function recursiveEscape(input) { + if ((0, _isPlainObject.default)(input) && typeof input.value !== 'string') { + return Object.keys(input).reduce(function (acc, key) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, recursiveEscape(input[key]))); + }, {}); + } + + if (Array.isArray(input)) { + return input.map(recursiveEscape); + } + + return _objectSpread(_objectSpread({}, input), {}, { + value: replaceTagsAndEscape(input.value) + }); +} + +function escapeHits(hits) { + if (hits.__escaped === undefined) { + // We don't override the value on hit because it will mutate the raw results + // instead we make a shallow copy and we assign the escaped values on it. + hits = hits.map(function (_ref) { + var hit = _extends({}, _ref); + + if (hit._highlightResult) { + hit._highlightResult = recursiveEscape(hit._highlightResult); + } + + if (hit._snippetResult) { + hit._snippetResult = recursiveEscape(hit._snippetResult); + } + + return hit; + }); + hits.__escaped = true; + } + + return hits; +} + +function escapeFacets(facetHits) { + return facetHits.map(function (h) { + return _objectSpread(_objectSpread({}, h), {}, { + highlighted: replaceTagsAndEscape(h.highlighted) + }); + }); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/escape.js b/js/instantsearch.js/cjs/lib/utils/escape.js new file mode 100644 index 00000000..daab85b9 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/escape.js @@ -0,0 +1,35 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +/** + * This implementation is taken from Lodash implementation. + * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js + */ +// Used to map characters to HTML entities. +var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' +}; // Used to match HTML entities and HTML characters. + +var regexUnescapedHtml = /[&<>"']/g; +var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source); +/** + * Converts the characters "&", "<", ">", '"', and "'" in `string` to their + * corresponding HTML entities. + */ + +function escape(value) { + return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) { + return htmlEscapes[character]; + }) : value; +} + +var _default = escape; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/escapeRefinement.js b/js/instantsearch.js/cjs/lib/utils/escapeRefinement.js new file mode 100644 index 00000000..e9232130 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/escapeRefinement.js @@ -0,0 +1,17 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function escapeRefinement(value) { + if (typeof value === 'number' && value < 0) { + value = String(value).replace(/^-/, '\\-'); + } + + return value; +} + +var _default = escapeRefinement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/find.js b/js/instantsearch.js/cjs/lib/utils/find.js new file mode 100644 index 00000000..c33e35a8 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/find.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +// We aren't using the native `Array.prototype.find` because the refactor away from Lodash is not +// published as a major version. +// Relying on the `find` polyfill on user-land, which before was only required for niche use-cases, +// was decided as too risky. +// @MAJOR Replace with the native `Array.prototype.find` method +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find +function find(items, predicate) { + var value; + + for (var i = 0; i < items.length; i++) { + value = items[i]; // inlined for performance: if (Call(predicate, thisArg, [value, i, list])) { + + if (predicate(value, i, items)) { + return value; + } + } + + return undefined; +} + +var _default = find; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/findIndex.js b/js/instantsearch.js/cjs/lib/utils/findIndex.js new file mode 100644 index 00000000..7f27f0e3 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/findIndex.js @@ -0,0 +1,29 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +// We aren't using the native `Array.prototype.findIndex` because the refactor away from Lodash is not +// published as a major version. +// Relying on the `findIndex` polyfill on user-land, which before was only required for niche use-cases, +// was decided as too risky. +// @MAJOR Replace with the native `Array.prototype.findIndex` method +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex +function findIndex(array, comparator) { + if (!Array.isArray(array)) { + return -1; + } + + for (var i = 0; i < array.length; i++) { + if (comparator(array[i])) { + return i; + } + } + + return -1; +} + +var _default = findIndex; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/geo-search.js b/js/instantsearch.js/cjs/lib/utils/geo-search.js new file mode 100644 index 00000000..3fb51bb4 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/geo-search.js @@ -0,0 +1,99 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.aroundLatLngToPosition = aroundLatLngToPosition; +exports.insideBoundingBoxToBoundingBox = insideBoundingBoxToBoundingBox; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/; + +function aroundLatLngToPosition(value) { + var pattern = value.match(latLngRegExp); // Since the value provided is the one send with the request, the API should + // throw an error due to the wrong format. So throw an error should be safe. + + if (!pattern) { + throw new Error("Invalid value for \"aroundLatLng\" parameter: \"".concat(value, "\"")); + } + + return { + lat: parseFloat(pattern[1]), + lng: parseFloat(pattern[2]) + }; +} + +function insideBoundingBoxArrayToBoundingBox(value) { + var _value = _slicedToArray(value, 1), + _value$ = _value[0]; + + _value$ = _value$ === void 0 ? [undefined, undefined, undefined, undefined] : _value$; + + var _value$2 = _slicedToArray(_value$, 4), + neLat = _value$2[0], + neLng = _value$2[1], + swLat = _value$2[2], + swLng = _value$2[3]; // Since the value provided is the one send with the request, the API should + // throw an error due to the wrong format. So throw an error should be safe. + + + if (!neLat || !neLng || !swLat || !swLng) { + throw new Error("Invalid value for \"insideBoundingBox\" parameter: [".concat(value, "]")); + } + + return { + northEast: { + lat: neLat, + lng: neLng + }, + southWest: { + lat: swLat, + lng: swLng + } + }; +} + +function insideBoundingBoxStringToBoundingBox(value) { + var _value$split$map = value.split(',').map(parseFloat), + _value$split$map2 = _slicedToArray(_value$split$map, 4), + neLat = _value$split$map2[0], + neLng = _value$split$map2[1], + swLat = _value$split$map2[2], + swLng = _value$split$map2[3]; // Since the value provided is the one send with the request, the API should + // throw an error due to the wrong format. So throw an error should be safe. + + + if (!neLat || !neLng || !swLat || !swLng) { + throw new Error("Invalid value for \"insideBoundingBox\" parameter: \"".concat(value, "\"")); + } + + return { + northEast: { + lat: neLat, + lng: neLng + }, + southWest: { + lat: swLat, + lng: swLng + } + }; +} + +function insideBoundingBoxToBoundingBox(value) { + if (Array.isArray(value)) { + return insideBoundingBoxArrayToBoundingBox(value); + } + + return insideBoundingBoxStringToBoundingBox(value); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getAppIdAndApiKey.js b/js/instantsearch.js/cjs/lib/utils/getAppIdAndApiKey.js new file mode 100644 index 00000000..17ca7954 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getAppIdAndApiKey.js @@ -0,0 +1,24 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getAppIdAndApiKey = getAppIdAndApiKey; + +// typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect +function getAppIdAndApiKey(searchClient) { + if (searchClient.transporter) { + // searchClient v4 + var _searchClient$transpo = searchClient.transporter, + headers = _searchClient$transpo.headers, + queryParameters = _searchClient$transpo.queryParameters; + var APP_ID = 'x-algolia-application-id'; + var API_KEY = 'x-algolia-api-key'; + var appId = headers[APP_ID] || queryParameters[APP_ID]; + var apiKey = headers[API_KEY] || queryParameters[API_KEY]; + return [appId, apiKey]; + } else { + // searchClient v3 + return [searchClient.applicationID, searchClient.apiKey]; + } +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getContainerNode.js b/js/instantsearch.js/cjs/lib/utils/getContainerNode.js new file mode 100644 index 00000000..8517f3f8 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getContainerNode.js @@ -0,0 +1,39 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _isDomElement = _interopRequireDefault(require("./isDomElement")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Return the container. If it's a string, it is considered a + * css selector and retrieves the first matching element. Otherwise + * test if it validates that it's a correct DOMElement. + * + * @param {string|HTMLElement} selectorOrHTMLElement CSS Selector or container node. + * @return {HTMLElement} Container node + * @throws Error when the type is not correct + */ +function getContainerNode(selectorOrHTMLElement) { + var isSelectorString = typeof selectorOrHTMLElement === 'string'; + var domElement = isSelectorString ? document.querySelector(selectorOrHTMLElement) : selectorOrHTMLElement; + + if (!(0, _isDomElement.default)(domElement)) { + var errorMessage = 'Container must be `string` or `HTMLElement`.'; + + if (isSelectorString) { + errorMessage += " Unable to find ".concat(selectorOrHTMLElement); + } + + throw new Error(errorMessage); + } + + return domElement; +} + +var _default = getContainerNode; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getHighlightFromSiblings.js b/js/instantsearch.js/cjs/lib/utils/getHighlightFromSiblings.js new file mode 100644 index 00000000..bb769527 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getHighlightFromSiblings.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = getHighlightFromSiblings; + +var _unescape = _interopRequireDefault(require("./unescape")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var hasAlphanumeric = new RegExp(/\w/i); + +function getHighlightFromSiblings(parts, i) { + var _parts, _parts2; + + var current = parts[i]; + var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true; + var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true; + + if (!hasAlphanumeric.test((0, _unescape.default)(current.value)) && isPreviousHighlighted === isNextHighlighted) { + return isPreviousHighlighted; + } + + return current.isHighlighted; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getHighlightedParts.js b/js/instantsearch.js/cjs/lib/utils/getHighlightedParts.js new file mode 100644 index 00000000..cb74bd0e --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getHighlightedParts.js @@ -0,0 +1,34 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = getHighlightedParts; + +var _escapeHighlight = require("./escape-highlight"); + +function getHighlightedParts(highlightedValue) { + var highlightPostTag = _escapeHighlight.TAG_REPLACEMENT.highlightPostTag, + highlightPreTag = _escapeHighlight.TAG_REPLACEMENT.highlightPreTag; + var splitByPreTag = highlightedValue.split(highlightPreTag); + var firstValue = splitByPreTag.shift(); + var elements = !firstValue ? [] : [{ + value: firstValue, + isHighlighted: false + }]; + splitByPreTag.forEach(function (split) { + var splitByPostTag = split.split(highlightPostTag); + elements.push({ + value: splitByPostTag[0], + isHighlighted: true + }); + + if (splitByPostTag[1] !== '') { + elements.push({ + value: splitByPostTag[1], + isHighlighted: false + }); + } + }); + return elements; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getObjectType.js b/js/instantsearch.js/cjs/lib/utils/getObjectType.js new file mode 100644 index 00000000..11378830 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getObjectType.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function getObjectType(object) { + return Object.prototype.toString.call(object).slice(8, -1); +} + +var _default = getObjectType; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getPropertyByPath.js b/js/instantsearch.js/cjs/lib/utils/getPropertyByPath.js new file mode 100644 index 00000000..2380c8e7 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getPropertyByPath.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function getPropertyByPath(object, path) { + var parts = Array.isArray(path) ? path : path.split('.'); + return parts.reduce(function (current, key) { + return current && current[key]; + }, object); +} + +var _default = getPropertyByPath; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getRefinements.js b/js/instantsearch.js/cjs/lib/utils/getRefinements.js new file mode 100644 index 00000000..8905e8bf --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getRefinements.js @@ -0,0 +1,150 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _find = _interopRequireDefault(require("./find")); + +var _unescapeRefinement = _interopRequireDefault(require("./unescapeRefinement")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function getRefinement(state, type, attribute, name) { + var resultsFacets = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : []; + var res = { + type: type, + attribute: attribute, + name: name + }; + var facet = (0, _find.default)(resultsFacets, function (resultsFacet) { + return resultsFacet.name === attribute; + }); + var count; + + if (type === 'hierarchical') { + (function () { + var facetDeclaration = state.getHierarchicalFacetByName(attribute); + var nameParts = name.split(facetDeclaration.separator); + + var getFacetRefinement = function getFacetRefinement(facetData) { + return function (refinementKey) { + return facetData[refinementKey]; + }; + }; + + var _loop = function _loop(i) { + facet = facet && facet.data && (0, _find.default)(Object.keys(facet.data).map(getFacetRefinement(facet.data)), function (refinement) { + return refinement.name === nameParts[i]; + }); + }; + + for (var i = 0; facet !== undefined && i < nameParts.length; ++i) { + _loop(i); + } + + count = facet && facet.count; + })(); + } else { + count = facet && facet.data && facet.data[res.name]; + } + + var exhaustive = facet && facet.exhaustive; + + if (count !== undefined) { + res.count = count; + } + + if (exhaustive !== undefined) { + res.exhaustive = exhaustive; + } + + return res; +} + +function getRefinements(results, state) { + var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + var refinements = []; + var _state$facetsRefineme = state.facetsRefinements, + facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme, + _state$facetsExcludes = state.facetsExcludes, + facetsExcludes = _state$facetsExcludes === void 0 ? {} : _state$facetsExcludes, + _state$disjunctiveFac = state.disjunctiveFacetsRefinements, + disjunctiveFacetsRefinements = _state$disjunctiveFac === void 0 ? {} : _state$disjunctiveFac, + _state$hierarchicalFa = state.hierarchicalFacetsRefinements, + hierarchicalFacetsRefinements = _state$hierarchicalFa === void 0 ? {} : _state$hierarchicalFa, + _state$numericRefinem = state.numericRefinements, + numericRefinements = _state$numericRefinem === void 0 ? {} : _state$numericRefinem, + _state$tagRefinements = state.tagRefinements, + tagRefinements = _state$tagRefinements === void 0 ? [] : _state$tagRefinements; + Object.keys(facetsRefinements).forEach(function (attribute) { + var refinementNames = facetsRefinements[attribute]; + refinementNames.forEach(function (refinementName) { + refinements.push(getRefinement(state, 'facet', attribute, refinementName, results.facets)); + }); + }); + Object.keys(facetsExcludes).forEach(function (attribute) { + var refinementNames = facetsExcludes[attribute]; + refinementNames.forEach(function (refinementName) { + refinements.push({ + type: 'exclude', + attribute: attribute, + name: refinementName, + exclude: true + }); + }); + }); + Object.keys(disjunctiveFacetsRefinements).forEach(function (attribute) { + var refinementNames = disjunctiveFacetsRefinements[attribute]; + refinementNames.forEach(function (refinementName) { + refinements.push(getRefinement(state, 'disjunctive', attribute, // We unescape any disjunctive refined values with `unescapeRefinement` because + // they can be escaped on negative numeric values with `escapeRefinement`. + (0, _unescapeRefinement.default)(refinementName), results.disjunctiveFacets)); + }); + }); + Object.keys(hierarchicalFacetsRefinements).forEach(function (attribute) { + var refinementNames = hierarchicalFacetsRefinements[attribute]; + refinementNames.forEach(function (refinement) { + refinements.push(getRefinement(state, 'hierarchical', attribute, refinement, results.hierarchicalFacets)); + }); + }); + Object.keys(numericRefinements).forEach(function (attribute) { + var operators = numericRefinements[attribute]; + Object.keys(operators).forEach(function (operatorOriginal) { + var operator = operatorOriginal; + var valueOrValues = operators[operator]; + var refinementNames = Array.isArray(valueOrValues) ? valueOrValues : [valueOrValues]; + refinementNames.forEach(function (refinementName) { + refinements.push({ + type: 'numeric', + attribute: attribute, + name: "".concat(refinementName), + numericValue: refinementName, + operator: operator + }); + }); + }); + }); + tagRefinements.forEach(function (refinementName) { + refinements.push({ + type: 'tag', + attribute: '_tags', + name: refinementName + }); + }); + + if (includesQuery && state.query && state.query.trim()) { + refinements.push({ + attribute: 'query', + type: 'query', + name: state.query, + query: state.query + }); + } + + return refinements; +} + +var _default = getRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/getWidgetAttribute.js b/js/instantsearch.js/cjs/lib/utils/getWidgetAttribute.js new file mode 100644 index 00000000..0148d264 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/getWidgetAttribute.js @@ -0,0 +1,20 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getWidgetAttribute = getWidgetAttribute; + +function getWidgetAttribute(widget, initOptions) { + try { + // assume the type to be the correct one, but throw a nice error if it isn't the case + var _getWidgetRenderState = widget.getWidgetRenderState(initOptions), + widgetParams = _getWidgetRenderState.widgetParams; + + var attribute = 'attribute' in widgetParams ? widgetParams.attribute : widgetParams.attributes[0]; + if (typeof attribute !== 'string') throw new Error(); + return attribute; + } catch (e) { + throw new Error("Could not find the attribute of the widget:\n\n".concat(JSON.stringify(widget), "\n\nPlease check whether the widget's getWidgetRenderState returns widgetParams.attribute correctly.")); + } +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/hits-absolute-position.js b/js/instantsearch.js/cjs/lib/utils/hits-absolute-position.js new file mode 100644 index 00000000..b67355ca --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/hits-absolute-position.js @@ -0,0 +1,20 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.addAbsolutePosition = addAbsolutePosition; + +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; } + +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; } + +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; } + +function addAbsolutePosition(hits, page, hitsPerPage) { + return hits.map(function (hit, idx) { + return _objectSpread(_objectSpread({}, hit), {}, { + __position: hitsPerPage * page + idx + 1 + }); + }); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/hits-query-id.js b/js/instantsearch.js/cjs/lib/utils/hits-query-id.js new file mode 100644 index 00000000..43fa5ac3 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/hits-query-id.js @@ -0,0 +1,24 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.addQueryID = addQueryID; + +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; } + +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; } + +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; } + +function addQueryID(hits, queryID) { + if (!queryID) { + return hits; + } + + return hits.map(function (hit) { + return _objectSpread(_objectSpread({}, hit), {}, { + __queryID: queryID + }); + }); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/index.js b/js/instantsearch.js/cjs/lib/utils/index.js new file mode 100644 index 00000000..9c8e1dc7 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/index.js @@ -0,0 +1,491 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +var _exportNames = { + capitalize: true, + defer: true, + isDomElement: true, + getContainerNode: true, + isSpecialClick: true, + prepareTemplateProps: true, + renderTemplate: true, + getRefinements: true, + clearRefinements: true, + escapeRefinement: true, + unescapeRefinement: true, + checkRendering: true, + checkIndexUiState: true, + getPropertyByPath: true, + getObjectType: true, + noop: true, + isFiniteNumber: true, + isPlainObject: true, + uniq: true, + range: true, + isEqual: true, + escape: true, + unescape: true, + concatHighlightedParts: true, + getHighlightedParts: true, + getHighlightFromSiblings: true, + reverseHighlightedParts: true, + find: true, + findIndex: true, + mergeSearchParameters: true, + resolveSearchParameters: true, + toArray: true, + warning: true, + deprecate: true, + escapeHits: true, + TAG_PLACEHOLDER: true, + TAG_REPLACEMENT: true, + escapeFacets: true, + createDocumentationLink: true, + createDocumentationMessageGenerator: true, + aroundLatLngToPosition: true, + insideBoundingBoxToBoundingBox: true, + addAbsolutePosition: true, + addQueryID: true, + isFacetRefined: true, + getAppIdAndApiKey: true, + convertNumericRefinementsToFilters: true, + createConcurrentSafePromise: true, + debounce: true, + serializePayload: true, + deserializePayload: true, + getWidgetAttribute: true +}; +Object.defineProperty(exports, "capitalize", { + enumerable: true, + get: function get() { + return _capitalize.default; + } +}); +Object.defineProperty(exports, "defer", { + enumerable: true, + get: function get() { + return _defer.default; + } +}); +Object.defineProperty(exports, "isDomElement", { + enumerable: true, + get: function get() { + return _isDomElement.default; + } +}); +Object.defineProperty(exports, "getContainerNode", { + enumerable: true, + get: function get() { + return _getContainerNode.default; + } +}); +Object.defineProperty(exports, "isSpecialClick", { + enumerable: true, + get: function get() { + return _isSpecialClick.default; + } +}); +Object.defineProperty(exports, "prepareTemplateProps", { + enumerable: true, + get: function get() { + return _prepareTemplateProps.default; + } +}); +Object.defineProperty(exports, "renderTemplate", { + enumerable: true, + get: function get() { + return _renderTemplate.default; + } +}); +Object.defineProperty(exports, "getRefinements", { + enumerable: true, + get: function get() { + return _getRefinements.default; + } +}); +Object.defineProperty(exports, "clearRefinements", { + enumerable: true, + get: function get() { + return _clearRefinements.default; + } +}); +Object.defineProperty(exports, "escapeRefinement", { + enumerable: true, + get: function get() { + return _escapeRefinement.default; + } +}); +Object.defineProperty(exports, "unescapeRefinement", { + enumerable: true, + get: function get() { + return _unescapeRefinement.default; + } +}); +Object.defineProperty(exports, "checkRendering", { + enumerable: true, + get: function get() { + return _checkRendering.default; + } +}); +Object.defineProperty(exports, "checkIndexUiState", { + enumerable: true, + get: function get() { + return _checkIndexUiState.checkIndexUiState; + } +}); +Object.defineProperty(exports, "getPropertyByPath", { + enumerable: true, + get: function get() { + return _getPropertyByPath.default; + } +}); +Object.defineProperty(exports, "getObjectType", { + enumerable: true, + get: function get() { + return _getObjectType.default; + } +}); +Object.defineProperty(exports, "noop", { + enumerable: true, + get: function get() { + return _noop.default; + } +}); +Object.defineProperty(exports, "isFiniteNumber", { + enumerable: true, + get: function get() { + return _isFiniteNumber.default; + } +}); +Object.defineProperty(exports, "isPlainObject", { + enumerable: true, + get: function get() { + return _isPlainObject.default; + } +}); +Object.defineProperty(exports, "uniq", { + enumerable: true, + get: function get() { + return _uniq.default; + } +}); +Object.defineProperty(exports, "range", { + enumerable: true, + get: function get() { + return _range.default; + } +}); +Object.defineProperty(exports, "isEqual", { + enumerable: true, + get: function get() { + return _isEqual.default; + } +}); +Object.defineProperty(exports, "escape", { + enumerable: true, + get: function get() { + return _escape.default; + } +}); +Object.defineProperty(exports, "unescape", { + enumerable: true, + get: function get() { + return _unescape.default; + } +}); +Object.defineProperty(exports, "concatHighlightedParts", { + enumerable: true, + get: function get() { + return _concatHighlightedParts.default; + } +}); +Object.defineProperty(exports, "getHighlightedParts", { + enumerable: true, + get: function get() { + return _getHighlightedParts.default; + } +}); +Object.defineProperty(exports, "getHighlightFromSiblings", { + enumerable: true, + get: function get() { + return _getHighlightFromSiblings.default; + } +}); +Object.defineProperty(exports, "reverseHighlightedParts", { + enumerable: true, + get: function get() { + return _reverseHighlightedParts.default; + } +}); +Object.defineProperty(exports, "find", { + enumerable: true, + get: function get() { + return _find.default; + } +}); +Object.defineProperty(exports, "findIndex", { + enumerable: true, + get: function get() { + return _findIndex.default; + } +}); +Object.defineProperty(exports, "mergeSearchParameters", { + enumerable: true, + get: function get() { + return _mergeSearchParameters.default; + } +}); +Object.defineProperty(exports, "resolveSearchParameters", { + enumerable: true, + get: function get() { + return _resolveSearchParameters.default; + } +}); +Object.defineProperty(exports, "toArray", { + enumerable: true, + get: function get() { + return _toArray.default; + } +}); +Object.defineProperty(exports, "warning", { + enumerable: true, + get: function get() { + return _logger.warning; + } +}); +Object.defineProperty(exports, "deprecate", { + enumerable: true, + get: function get() { + return _logger.deprecate; + } +}); +Object.defineProperty(exports, "escapeHits", { + enumerable: true, + get: function get() { + return _escapeHighlight.escapeHits; + } +}); +Object.defineProperty(exports, "TAG_PLACEHOLDER", { + enumerable: true, + get: function get() { + return _escapeHighlight.TAG_PLACEHOLDER; + } +}); +Object.defineProperty(exports, "TAG_REPLACEMENT", { + enumerable: true, + get: function get() { + return _escapeHighlight.TAG_REPLACEMENT; + } +}); +Object.defineProperty(exports, "escapeFacets", { + enumerable: true, + get: function get() { + return _escapeHighlight.escapeFacets; + } +}); +Object.defineProperty(exports, "createDocumentationLink", { + enumerable: true, + get: function get() { + return _documentation.createDocumentationLink; + } +}); +Object.defineProperty(exports, "createDocumentationMessageGenerator", { + enumerable: true, + get: function get() { + return _documentation.createDocumentationMessageGenerator; + } +}); +Object.defineProperty(exports, "aroundLatLngToPosition", { + enumerable: true, + get: function get() { + return _geoSearch.aroundLatLngToPosition; + } +}); +Object.defineProperty(exports, "insideBoundingBoxToBoundingBox", { + enumerable: true, + get: function get() { + return _geoSearch.insideBoundingBoxToBoundingBox; + } +}); +Object.defineProperty(exports, "addAbsolutePosition", { + enumerable: true, + get: function get() { + return _hitsAbsolutePosition.addAbsolutePosition; + } +}); +Object.defineProperty(exports, "addQueryID", { + enumerable: true, + get: function get() { + return _hitsQueryId.addQueryID; + } +}); +Object.defineProperty(exports, "isFacetRefined", { + enumerable: true, + get: function get() { + return _isFacetRefined.default; + } +}); +Object.defineProperty(exports, "getAppIdAndApiKey", { + enumerable: true, + get: function get() { + return _getAppIdAndApiKey.getAppIdAndApiKey; + } +}); +Object.defineProperty(exports, "convertNumericRefinementsToFilters", { + enumerable: true, + get: function get() { + return _convertNumericRefinementsToFilters.convertNumericRefinementsToFilters; + } +}); +Object.defineProperty(exports, "createConcurrentSafePromise", { + enumerable: true, + get: function get() { + return _createConcurrentSafePromise.createConcurrentSafePromise; + } +}); +Object.defineProperty(exports, "debounce", { + enumerable: true, + get: function get() { + return _debounce.debounce; + } +}); +Object.defineProperty(exports, "serializePayload", { + enumerable: true, + get: function get() { + return _serializer.serializePayload; + } +}); +Object.defineProperty(exports, "deserializePayload", { + enumerable: true, + get: function get() { + return _serializer.deserializePayload; + } +}); +Object.defineProperty(exports, "getWidgetAttribute", { + enumerable: true, + get: function get() { + return _getWidgetAttribute.getWidgetAttribute; + } +}); + +var _capitalize = _interopRequireDefault(require("./capitalize")); + +var _defer = _interopRequireDefault(require("./defer")); + +var _isDomElement = _interopRequireDefault(require("./isDomElement")); + +var _getContainerNode = _interopRequireDefault(require("./getContainerNode")); + +var _isSpecialClick = _interopRequireDefault(require("./isSpecialClick")); + +var _prepareTemplateProps = _interopRequireDefault(require("./prepareTemplateProps")); + +var _renderTemplate = _interopRequireDefault(require("./renderTemplate")); + +var _getRefinements = _interopRequireDefault(require("./getRefinements")); + +var _clearRefinements = _interopRequireDefault(require("./clearRefinements")); + +var _escapeRefinement = _interopRequireDefault(require("./escapeRefinement")); + +var _unescapeRefinement = _interopRequireDefault(require("./unescapeRefinement")); + +var _checkRendering = _interopRequireDefault(require("./checkRendering")); + +var _checkIndexUiState = require("./checkIndexUiState"); + +var _getPropertyByPath = _interopRequireDefault(require("./getPropertyByPath")); + +var _getObjectType = _interopRequireDefault(require("./getObjectType")); + +var _noop = _interopRequireDefault(require("./noop")); + +var _isFiniteNumber = _interopRequireDefault(require("./isFiniteNumber")); + +var _isPlainObject = _interopRequireDefault(require("./isPlainObject")); + +var _uniq = _interopRequireDefault(require("./uniq")); + +var _range = _interopRequireDefault(require("./range")); + +var _isEqual = _interopRequireDefault(require("./isEqual")); + +var _escape = _interopRequireDefault(require("./escape")); + +var _unescape = _interopRequireDefault(require("./unescape")); + +var _concatHighlightedParts = _interopRequireDefault(require("./concatHighlightedParts")); + +var _getHighlightedParts = _interopRequireDefault(require("./getHighlightedParts")); + +var _getHighlightFromSiblings = _interopRequireDefault(require("./getHighlightFromSiblings")); + +var _reverseHighlightedParts = _interopRequireDefault(require("./reverseHighlightedParts")); + +var _find = _interopRequireDefault(require("./find")); + +var _findIndex = _interopRequireDefault(require("./findIndex")); + +var _mergeSearchParameters = _interopRequireDefault(require("./mergeSearchParameters")); + +var _resolveSearchParameters = _interopRequireDefault(require("./resolveSearchParameters")); + +var _toArray = _interopRequireDefault(require("./toArray")); + +var _logger = require("./logger"); + +var _escapeHighlight = require("./escape-highlight"); + +var _documentation = require("./documentation"); + +var _geoSearch = require("./geo-search"); + +var _hitsAbsolutePosition = require("./hits-absolute-position"); + +var _hitsQueryId = require("./hits-query-id"); + +var _isFacetRefined = _interopRequireDefault(require("./isFacetRefined")); + +var _createSendEventForFacet = require("./createSendEventForFacet"); + +Object.keys(_createSendEventForFacet).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _createSendEventForFacet[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _createSendEventForFacet[key]; + } + }); +}); + +var _createSendEventForHits = require("./createSendEventForHits"); + +Object.keys(_createSendEventForHits).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; + if (key in exports && exports[key] === _createSendEventForHits[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _createSendEventForHits[key]; + } + }); +}); + +var _getAppIdAndApiKey = require("./getAppIdAndApiKey"); + +var _convertNumericRefinementsToFilters = require("./convertNumericRefinementsToFilters"); + +var _createConcurrentSafePromise = require("./createConcurrentSafePromise"); + +var _debounce = require("./debounce"); + +var _serializer = require("./serializer"); + +var _getWidgetAttribute = require("./getWidgetAttribute"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isDomElement.js b/js/instantsearch.js/cjs/lib/utils/isDomElement.js new file mode 100644 index 00000000..5e2685ad --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isDomElement.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function isDomElement(object) { + return object instanceof HTMLElement || Boolean(object) && object.nodeType > 0; +} + +var _default = isDomElement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isEqual.js b/js/instantsearch.js/cjs/lib/utils/isEqual.js new file mode 100644 index 00000000..43478497 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isEqual.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function isPrimitive(obj) { + return obj !== Object(obj); +} + +function isEqual(first, second) { + if (first === second) { + return true; + } + + if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') { + return first === second; + } + + if (Object.keys(first).length !== Object.keys(second).length) { + return false; + } + + for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) { + var key = _Object$keys[_i]; + + if (!(key in second)) { + return false; + } + + if (!isEqual(first[key], second[key])) { + return false; + } + } + + return true; +} + +var _default = isEqual; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isFacetRefined.js b/js/instantsearch.js/cjs/lib/utils/isFacetRefined.js new file mode 100644 index 00000000..49f271a3 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isFacetRefined.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = isFacetRefined; + +function isFacetRefined(helper, facet, value) { + if (helper.state.isHierarchicalFacet(facet)) { + return helper.state.isHierarchicalFacetRefined(facet, value); + } else if (helper.state.isConjunctiveFacet(facet)) { + return helper.state.isFacetRefined(facet, value); + } else { + return helper.state.isDisjunctiveFacetRefined(facet, value); + } +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isFiniteNumber.js b/js/instantsearch.js/cjs/lib/utils/isFiniteNumber.js new file mode 100644 index 00000000..be982c51 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isFiniteNumber.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +// This is the `Number.isFinite()` polyfill recommended by MDN. +// We do not provide any tests for this function. +// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#Polyfill +function isFiniteNumber(value) { + return typeof value === 'number' && isFinite(value); +} + +var _default = isFiniteNumber; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isPlainObject.js b/js/instantsearch.js/cjs/lib/utils/isPlainObject.js new file mode 100644 index 00000000..ecc7a676 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isPlainObject.js @@ -0,0 +1,52 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +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); } + +/** + * This implementation is taken from Lodash implementation. + * See: https://github.com/lodash/lodash/blob/master/isPlainObject.js + */ +function getTag(value) { + if (value === null) { + return value === undefined ? '[object Undefined]' : '[object Null]'; + } + + return Object.prototype.toString.call(value); +} + +function isObjectLike(value) { + return _typeof(value) === 'object' && value !== null; +} +/** + * Checks if `value` is a plain object. + * + * A plain object is an object created by the `Object` + * constructor or with a `[[Prototype]]` of `null`. + */ + + +function isPlainObject(value) { + if (!isObjectLike(value) || getTag(value) !== '[object Object]') { + return false; + } + + if (Object.getPrototypeOf(value) === null) { + return true; + } + + var proto = value; + + while (Object.getPrototypeOf(proto) !== null) { + proto = Object.getPrototypeOf(proto); + } + + return Object.getPrototypeOf(value) === proto; +} + +var _default = isPlainObject; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/isSpecialClick.js b/js/instantsearch.js/cjs/lib/utils/isSpecialClick.js new file mode 100644 index 00000000..c9f75fb3 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/isSpecialClick.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function isSpecialClick(event) { + var isMiddleClick = event.button === 1; + return isMiddleClick || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; +} + +var _default = isSpecialClick; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/logger.js b/js/instantsearch.js/cjs/lib/utils/logger.js new file mode 100644 index 00000000..caabdba3 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/logger.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.warning = exports.deprecate = exports.warn = void 0; + +var _noop = _interopRequireDefault(require("./noop")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Logs a warning when this function is called, in development environment only. + */ +var deprecate = function deprecate(fn) { + return fn; +}; +/** + * Logs a warning + * This is used to log issues in development environment only. + */ + + +exports.deprecate = deprecate; +var warn = _noop.default; +/** + * Logs a warning if the condition is not met. + * This is used to log issues in development environment only. + */ + +exports.warn = warn; +var _warning = _noop.default; +exports.warning = _warning; + +if (process.env.NODE_ENV === 'development') { + exports.warn = warn = function warn(message) { + // eslint-disable-next-line no-console + console.warn("[InstantSearch.js]: ".concat(message.trim())); + }; + + exports.deprecate = deprecate = function deprecate(fn, message) { + var hasAlreadyPrinted = false; + return function () { + if (!hasAlreadyPrinted) { + hasAlreadyPrinted = true; + warn(message); + } + + return fn.apply(void 0, arguments); + }; + }; + + exports.warning = _warning = function warning(condition, message) { + if (condition) { + return; + } + + var hasAlreadyPrinted = _warning.cache[message]; + + if (!hasAlreadyPrinted) { + _warning.cache[message] = true; + warn(message); + } + }; + + _warning.cache = {}; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/mergeSearchParameters.js b/js/instantsearch.js/cjs/lib/utils/mergeSearchParameters.js new file mode 100644 index 00000000..4bd5900a --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/mergeSearchParameters.js @@ -0,0 +1,141 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _findIndex = _interopRequireDefault(require("./findIndex")); + +var _uniq = _interopRequireDefault(require("./uniq")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var mergeWithRest = function mergeWithRest(left, right) { + var facets = right.facets, + disjunctiveFacets = right.disjunctiveFacets, + facetsRefinements = right.facetsRefinements, + facetsExcludes = right.facetsExcludes, + disjunctiveFacetsRefinements = right.disjunctiveFacetsRefinements, + numericRefinements = right.numericRefinements, + tagRefinements = right.tagRefinements, + hierarchicalFacets = right.hierarchicalFacets, + hierarchicalFacetsRefinements = right.hierarchicalFacetsRefinements, + ruleContexts = right.ruleContexts, + rest = _objectWithoutProperties(right, ["facets", "disjunctiveFacets", "facetsRefinements", "facetsExcludes", "disjunctiveFacetsRefinements", "numericRefinements", "tagRefinements", "hierarchicalFacets", "hierarchicalFacetsRefinements", "ruleContexts"]); + + return left.setQueryParameters(rest); +}; // Merge facets + + +var mergeFacets = function mergeFacets(left, right) { + return right.facets.reduce(function (_, name) { + return _.addFacet(name); + }, left); +}; + +var mergeDisjunctiveFacets = function mergeDisjunctiveFacets(left, right) { + return right.disjunctiveFacets.reduce(function (_, name) { + return _.addDisjunctiveFacet(name); + }, left); +}; + +var mergeHierarchicalFacets = function mergeHierarchicalFacets(left, right) { + return left.setQueryParameters({ + hierarchicalFacets: right.hierarchicalFacets.reduce(function (facets, facet) { + var index = (0, _findIndex.default)(facets, function (_) { + return _.name === facet.name; + }); + + if (index === -1) { + return facets.concat(facet); + } + + var nextFacets = facets.slice(); + nextFacets.splice(index, 1, facet); + return nextFacets; + }, left.hierarchicalFacets) + }); +}; // Merge facet refinements + + +var mergeTagRefinements = function mergeTagRefinements(left, right) { + return right.tagRefinements.reduce(function (_, value) { + return _.addTagRefinement(value); + }, left); +}; + +var mergeFacetRefinements = function mergeFacetRefinements(left, right) { + return left.setQueryParameters({ + facetsRefinements: _objectSpread(_objectSpread({}, left.facetsRefinements), right.facetsRefinements) + }); +}; + +var mergeFacetsExcludes = function mergeFacetsExcludes(left, right) { + return left.setQueryParameters({ + facetsExcludes: _objectSpread(_objectSpread({}, left.facetsExcludes), right.facetsExcludes) + }); +}; + +var mergeDisjunctiveFacetsRefinements = function mergeDisjunctiveFacetsRefinements(left, right) { + return left.setQueryParameters({ + disjunctiveFacetsRefinements: _objectSpread(_objectSpread({}, left.disjunctiveFacetsRefinements), right.disjunctiveFacetsRefinements) + }); +}; + +var mergeNumericRefinements = function mergeNumericRefinements(left, right) { + return left.setQueryParameters({ + numericRefinements: _objectSpread(_objectSpread({}, left.numericRefinements), right.numericRefinements) + }); +}; + +var mergeHierarchicalFacetsRefinements = function mergeHierarchicalFacetsRefinements(left, right) { + return left.setQueryParameters({ + hierarchicalFacetsRefinements: _objectSpread(_objectSpread({}, left.hierarchicalFacetsRefinements), right.hierarchicalFacetsRefinements) + }); +}; + +var mergeRuleContexts = function mergeRuleContexts(left, right) { + var ruleContexts = (0, _uniq.default)([].concat(left.ruleContexts).concat(right.ruleContexts).filter(Boolean)); + + if (ruleContexts.length > 0) { + return left.setQueryParameters({ + ruleContexts: ruleContexts + }); + } + + return left; +}; + +var merge = function merge() { + for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) { + parameters[_key] = arguments[_key]; + } + + return parameters.reduce(function (left, right) { + var hierarchicalFacetsRefinementsMerged = mergeHierarchicalFacetsRefinements(left, right); + var hierarchicalFacetsMerged = mergeHierarchicalFacets(hierarchicalFacetsRefinementsMerged, right); + var tagRefinementsMerged = mergeTagRefinements(hierarchicalFacetsMerged, right); + var numericRefinementsMerged = mergeNumericRefinements(tagRefinementsMerged, right); + var disjunctiveFacetsRefinementsMerged = mergeDisjunctiveFacetsRefinements(numericRefinementsMerged, right); + var facetsExcludesMerged = mergeFacetsExcludes(disjunctiveFacetsRefinementsMerged, right); + var facetRefinementsMerged = mergeFacetRefinements(facetsExcludesMerged, right); + var disjunctiveFacetsMerged = mergeDisjunctiveFacets(facetRefinementsMerged, right); + var ruleContextsMerged = mergeRuleContexts(disjunctiveFacetsMerged, right); + var facetsMerged = mergeFacets(ruleContextsMerged, right); + return mergeWithRest(facetsMerged, right); + }); +}; + +var _default = merge; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/noop.js b/js/instantsearch.js/cjs/lib/utils/noop.js new file mode 100644 index 00000000..6da6ee9a --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/noop.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function noop() {} + +var _default = noop; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/prepareTemplateProps.js b/js/instantsearch.js/cjs/lib/utils/prepareTemplateProps.js new file mode 100644 index 00000000..ef20519a --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/prepareTemplateProps.js @@ -0,0 +1,65 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _uniq = _interopRequireDefault(require("./uniq")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +function prepareTemplates( // can not use = {} here, since the template could have different constraints +defaultTemplates) { + var templates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var allKeys = (0, _uniq.default)([].concat(_toConsumableArray(Object.keys(defaultTemplates || {})), _toConsumableArray(Object.keys(templates)))); + return allKeys.reduce(function (config, key) { + var defaultTemplate = defaultTemplates ? defaultTemplates[key] : undefined; + var customTemplate = templates[key]; + var isCustomTemplate = customTemplate !== undefined && customTemplate !== defaultTemplate; + config.templates[key] = isCustomTemplate ? customTemplate // typescript doesn't recognize that this condition asserts customTemplate is defined + : defaultTemplate; + config.useCustomCompileOptions[key] = isCustomTemplate; + return config; + }, { + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + templates: {}, + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + useCustomCompileOptions: {} + }); +} +/** + * Prepares an object to be passed to the Template widget + */ + + +function prepareTemplateProps(_ref) { + var defaultTemplates = _ref.defaultTemplates, + templates = _ref.templates, + templatesConfig = _ref.templatesConfig; + var preparedTemplates = prepareTemplates(defaultTemplates, templates); + return _objectSpread({ + templatesConfig: templatesConfig + }, preparedTemplates); +} + +var _default = prepareTemplateProps; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/range.js b/js/instantsearch.js/cjs/lib/utils/range.js new file mode 100644 index 00000000..a01a6f4c --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/range.js @@ -0,0 +1,40 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +function range(_ref) { + var _ref$start = _ref.start, + start = _ref$start === void 0 ? 0 : _ref$start, + end = _ref.end, + _ref$step = _ref.step, + step = _ref$step === void 0 ? 1 : _ref$step; + // We can't divide by 0 so we re-assign the step to 1 if it happens. + var limitStep = step === 0 ? 1 : step; // In some cases the array to create has a decimal length. + // We therefore need to round the value. + // Example: + // { start: 1, end: 5000, step: 500 } + // => Array length = (5000 - 1) / 500 = 9.998 + + var arrayLength = Math.round((end - start) / limitStep); + return _toConsumableArray(Array(arrayLength)).map(function (_, current) { + return start + current * limitStep; + }); +} + +var _default = range; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/renderTemplate.js b/js/instantsearch.js/cjs/lib/utils/renderTemplate.js new file mode 100644 index 00000000..55e21d94 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/renderTemplate.js @@ -0,0 +1,69 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _hogan = _interopRequireDefault(require("hogan.js")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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); } + +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; } + +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; } + +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; } + +// We add all our template helper methods to the template as lambdas. Note +// that lambdas in Mustache are supposed to accept a second argument of +// `render` to get the rendered value, not the literal `{{value}}`. But +// this is currently broken (see https://github.com/twitter/hogan.js/issues/222). +function transformHelpersToHogan() { + var helpers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var compileOptions = arguments.length > 1 ? arguments[1] : undefined; + var data = arguments.length > 2 ? arguments[2] : undefined; + return Object.keys(helpers).reduce(function (acc, helperKey) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, helperKey, function () { + var _this = this; + + return function (text) { + var render = function render(value) { + return _hogan.default.compile(value, compileOptions).render(_this); + }; + + return helpers[helperKey].call(data, text, render); + }; + })); + }, {}); +} + +function renderTemplate(_ref) { + var templates = _ref.templates, + templateKey = _ref.templateKey, + compileOptions = _ref.compileOptions, + helpers = _ref.helpers, + data = _ref.data, + bindEvent = _ref.bindEvent; + var template = templates[templateKey]; + + if (typeof template !== 'string' && typeof template !== 'function') { + throw new Error("Template must be 'string' or 'function', was '".concat(_typeof(template), "' (key: ").concat(templateKey, ")")); + } + + if (typeof template === 'function') { + return template(data, bindEvent); + } + + var transformedHelpers = transformHelpersToHogan(helpers, compileOptions, data); + return _hogan.default.compile(template, compileOptions).render(_objectSpread(_objectSpread({}, data), {}, { + helpers: transformedHelpers + })).replace(/[ \n\r\t\f\xA0]+/g, function (spaces) { + return spaces.replace(/(^|\xA0+)[^\xA0]+/g, '$1 '); + }).trim(); +} + +var _default = renderTemplate; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/resolveSearchParameters.js b/js/instantsearch.js/cjs/lib/utils/resolveSearchParameters.js new file mode 100644 index 00000000..bfdc5569 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/resolveSearchParameters.js @@ -0,0 +1,21 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var resolveSearchParameters = function resolveSearchParameters(current) { + var parent = current.getParent(); + var states = [current.getHelper().state]; + + while (parent !== null) { + states = [parent.getHelper().state].concat(states); + parent = parent.getParent(); + } + + return states; +}; + +var _default = resolveSearchParameters; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/reverseHighlightedParts.js b/js/instantsearch.js/cjs/lib/utils/reverseHighlightedParts.js new file mode 100644 index 00000000..8a73368b --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/reverseHighlightedParts.js @@ -0,0 +1,34 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = reverseHighlightedParts; + +var _getHighlightFromSiblings = _interopRequireDefault(require("./getHighlightFromSiblings")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function reverseHighlightedParts(parts) { + if (!parts.some(function (part) { + return part.isHighlighted; + })) { + return parts.map(function (part) { + return _objectSpread(_objectSpread({}, part), {}, { + isHighlighted: false + }); + }); + } + + return parts.map(function (part, i) { + return _objectSpread(_objectSpread({}, part), {}, { + isHighlighted: !(0, _getHighlightFromSiblings.default)(parts, i) + }); + }); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/serializer.js b/js/instantsearch.js/cjs/lib/utils/serializer.js new file mode 100644 index 00000000..1bf520d1 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/serializer.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.serializePayload = serializePayload; +exports.deserializePayload = deserializePayload; + +function serializePayload(payload) { + return btoa(encodeURIComponent(JSON.stringify(payload))); +} + +function deserializePayload(payload) { + return JSON.parse(decodeURIComponent(atob(payload))); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/toArray.js b/js/instantsearch.js/cjs/lib/utils/toArray.js new file mode 100644 index 00000000..1d7a9542 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/toArray.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function toArray(value) { + return Array.isArray(value) ? value : [value]; +} + +var _default = toArray; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/typedObject.js b/js/instantsearch.js/cjs/lib/utils/typedObject.js new file mode 100644 index 00000000..999f38cb --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/typedObject.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.keys = void 0; + +/** + * A typed version of Object.keys, to use when looping over a static object + * inspired from https://stackoverflow.com/a/65117465/3185307 + */ +var keys = Object.keys; +exports.keys = keys; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/unescape.js b/js/instantsearch.js/cjs/lib/utils/unescape.js new file mode 100644 index 00000000..35306e7f --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/unescape.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = unescape; + +/** + * This implementation is taken from Lodash implementation. + * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js + */ +// Used to map HTML entities to characters. +var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'" +}; // Used to match HTML entities and HTML characters. + +var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g; +var regexHasEscapedHtml = RegExp(regexEscapedHtml.source); +/** + * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their + * characters. + */ + +function unescape(value) { + return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) { + return htmlEscapes[character]; + }) : value; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/unescapeRefinement.js b/js/instantsearch.js/cjs/lib/utils/unescapeRefinement.js new file mode 100644 index 00000000..18195657 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/unescapeRefinement.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function unescapeRefinement(value) { + return String(value).replace(/^\\-/, '-'); +} + +var _default = unescapeRefinement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/utils/uniq.js b/js/instantsearch.js/cjs/lib/utils/uniq.js new file mode 100644 index 00000000..16ef1006 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/utils/uniq.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function uniq(array) { + return array.filter(function (value, index, self) { + return self.indexOf(value) === index; + }); +} + +var _default = uniq; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/version.js b/js/instantsearch.js/cjs/lib/version.js new file mode 100644 index 00000000..a1e54cad --- /dev/null +++ b/js/instantsearch.js/cjs/lib/version.js @@ -0,0 +1,8 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _default = '4.25.2'; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/voiceSearchHelper/index.js b/js/instantsearch.js/cjs/lib/voiceSearchHelper/index.js new file mode 100644 index 00000000..857c009c --- /dev/null +++ b/js/instantsearch.js/cjs/lib/voiceSearchHelper/index.js @@ -0,0 +1,147 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +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; } + +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; } + +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; } + +/* global SpeechRecognition SpeechRecognitionEvent */ +var createVoiceSearchHelper = function createVoiceSearchHelper(_ref) { + var searchAsYouSpeak = _ref.searchAsYouSpeak, + language = _ref.language, + onQueryChange = _ref.onQueryChange, + onStateChange = _ref.onStateChange; + var SpeechRecognitionAPI = window.webkitSpeechRecognition || window.SpeechRecognition; + + var getDefaultState = function getDefaultState(status) { + return { + status: status, + transcript: '', + isSpeechFinal: false, + errorCode: undefined + }; + }; + + var state = getDefaultState('initial'); + var recognition; + + var isBrowserSupported = function isBrowserSupported() { + return Boolean(SpeechRecognitionAPI); + }; + + var isListening = function isListening() { + return state.status === 'askingPermission' || state.status === 'waiting' || state.status === 'recognizing'; + }; + + var setState = function setState() { + var newState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + state = _objectSpread(_objectSpread({}, state), newState); + onStateChange(); + }; + + var getState = function getState() { + return state; + }; + + var resetState = function resetState() { + var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initial'; + setState(getDefaultState(status)); + }; + + var onStart = function onStart() { + setState({ + status: 'waiting' + }); + }; + + var onError = function onError(event) { + setState({ + status: 'error', + errorCode: event.error + }); + }; + + var onResult = function onResult(event) { + setState({ + status: 'recognizing', + transcript: event.results[0] && event.results[0][0] && event.results[0][0].transcript || '', + isSpeechFinal: event.results[0] && event.results[0].isFinal + }); + + if (searchAsYouSpeak && state.transcript) { + onQueryChange(state.transcript); + } + }; + + var onEnd = function onEnd() { + if (!state.errorCode && state.transcript && !searchAsYouSpeak) { + onQueryChange(state.transcript); + } + + if (state.status !== 'error') { + setState({ + status: 'finished' + }); + } + }; + + var startListening = function startListening() { + recognition = new SpeechRecognitionAPI(); + + if (!recognition) { + return; + } + + resetState('askingPermission'); + recognition.interimResults = true; + + if (language) { + recognition.lang = language; + } + + recognition.addEventListener('start', onStart); + recognition.addEventListener('error', onError); + recognition.addEventListener('result', onResult); + recognition.addEventListener('end', onEnd); + recognition.start(); + }; + + var dispose = function dispose() { + if (!recognition) { + return; + } + + recognition.stop(); + recognition.removeEventListener('start', onStart); + recognition.removeEventListener('error', onError); + recognition.removeEventListener('result', onResult); + recognition.removeEventListener('end', onEnd); + recognition = undefined; + }; + + var stopListening = function stopListening() { + dispose(); // Because `dispose` removes event listeners, `end` listener is not called. + // So we're setting the `status` as `finished` here. + // If we don't do it, it will be still `waiting` or `recognizing`. + + resetState('finished'); + }; + + return { + getState: getState, + isBrowserSupported: isBrowserSupported, + isListening: isListening, + startListening: startListening, + stopListening: stopListening, + dispose: dispose + }; +}; + +var _default = createVoiceSearchHelper; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/lib/voiceSearchHelper/types.js b/js/instantsearch.js/cjs/lib/voiceSearchHelper/types.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/lib/voiceSearchHelper/types.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/middlewares/createInsightsMiddleware.js b/js/instantsearch.js/cjs/middlewares/createInsightsMiddleware.js new file mode 100644 index 00000000..fd528668 --- /dev/null +++ b/js/instantsearch.js/cjs/middlewares/createInsightsMiddleware.js @@ -0,0 +1,154 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createInsightsMiddleware = void 0; + +var _helpers = require("../helpers"); + +var _utils = require("../lib/utils"); + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var createInsightsMiddleware = function createInsightsMiddleware(props) { + var _ref = props || {}, + _insightsClient = _ref.insightsClient, + insightsInitParams = _ref.insightsInitParams, + onEvent = _ref.onEvent; + + if (_insightsClient !== null && !_insightsClient) { + if (process.env.NODE_ENV === 'development') { + throw new Error("The `insightsClient` option is required if you want userToken to be automatically set in search calls. If you don't want this behaviour, set it to `null`."); + } else { + throw new Error('The `insightsClient` option is required. To disable, set it to `null`.'); + } + } + + var hasInsightsClient = Boolean(_insightsClient); + var insightsClient = _insightsClient === null ? _utils.noop : _insightsClient; + return function (_ref2) { + var instantSearchInstance = _ref2.instantSearchInstance; + + var _getAppIdAndApiKey = (0, _utils.getAppIdAndApiKey)(instantSearchInstance.client), + _getAppIdAndApiKey2 = _slicedToArray(_getAppIdAndApiKey, 2), + appId = _getAppIdAndApiKey2[0], + apiKey = _getAppIdAndApiKey2[1]; + + var queuedUserToken = undefined; + var userTokenBeforeInit = undefined; + + if (Array.isArray(insightsClient.queue)) { + // Context: The umd build of search-insights is asynchronously loaded by the snippet. + // + // When user calls `aa('setUserToken', 'my-user-token')` before `search-insights` is loaded, + // ['setUserToken', 'my-user-token'] gets stored in `aa.queue`. + // Whenever `search-insights` is finally loaded, it will process the queue. + // + // But here's the reason why we handle it here: + // At this point, even though `search-insights` is not loaded yet, + // we still want to read the token from the queue. + // Otherwise, the first search call will be fired without the token. + var _ref3 = (0, _utils.find)(insightsClient.queue.slice().reverse(), function (_ref5) { + var _ref6 = _slicedToArray(_ref5, 1), + method = _ref6[0]; + + return method === 'setUserToken'; + }) || []; + + var _ref4 = _slicedToArray(_ref3, 2); + + queuedUserToken = _ref4[1]; + } + + insightsClient('getUserToken', null, function (_error, userToken) { + // If user has called `aa('setUserToken', 'my-user-token')` before creating + // the `insights` middleware, we store them temporarily and + // set it later on. + // + // Otherwise, the `init` call might override it with anonymous user token. + userTokenBeforeInit = userToken; + }); + insightsClient('init', _objectSpread({ + appId: appId, + apiKey: apiKey + }, insightsInitParams)); + return { + onStateChange: function onStateChange() {}, + subscribe: function subscribe() { + insightsClient('addAlgoliaAgent', 'insights-middleware'); // At the time this middleware is subscribed, `mainIndex.init()` is already called. + // It means `mainIndex.getHelper()` exists. + + var helper = instantSearchInstance.mainIndex.getHelper(); + + var setUserTokenToSearch = function setUserTokenToSearch(userToken) { + if (userToken) { + helper.setState(helper.state.setQueryParameter('userToken', userToken)); + } + }; + + var hasUserToken = function hasUserToken() { + return Boolean(helper.state.userToken); + }; + + helper.setState(helper.state.setQueryParameter('clickAnalytics', true)); + var anonymousUserToken = (0, _helpers.getInsightsAnonymousUserTokenInternal)(); + + if (hasInsightsClient && anonymousUserToken) { + // When `aa('init', { ... })` is called, it creates an anonymous user token in cookie. + // We can set it as userToken. + setUserTokenToSearch(anonymousUserToken); + } // We consider the `userToken` coming from a `init` call to have a higher + // importance than the one coming from the queue. + + + if (userTokenBeforeInit) { + insightsClient('setUserToken', userTokenBeforeInit); + } else if (queuedUserToken) { + insightsClient('setUserToken', queuedUserToken); + } // This updates userToken which is set explicitly by `aa('setUserToken', userToken)` + + + insightsClient('onUserTokenChange', setUserTokenToSearch, { + immediate: true + }); + + instantSearchInstance.sendEventToInsights = function (event) { + if (onEvent) { + onEvent(event, _insightsClient); + } else if (event.insightsMethod) { + if (hasUserToken()) { + insightsClient(event.insightsMethod, event.payload); + } else { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "\nCannot send event to Algolia Insights because `userToken` is not set.\n\nSee documentation: https://www.algolia.com/doc/guides/building-search-ui/going-further/send-insights-events/js/#setting-the-usertoken\n") : void 0; + } + } else { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, 'Cannot send event to Algolia Insights because `insightsMethod` option is missing.') : void 0; + } + }; + }, + unsubscribe: function unsubscribe() { + insightsClient('onUserTokenChange', undefined); + instantSearchInstance.sendEventToInsights = _utils.noop; + } + }; + }; +}; + +exports.createInsightsMiddleware = createInsightsMiddleware; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/middlewares/createMetadataMiddleware.js b/js/instantsearch.js/cjs/middlewares/createMetadataMiddleware.js new file mode 100644 index 00000000..a23d6182 --- /dev/null +++ b/js/instantsearch.js/cjs/middlewares/createMetadataMiddleware.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isMetadataEnabled = isMetadataEnabled; +exports.createMetadataMiddleware = createMetadataMiddleware; + +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); } + +function extractPayload(widgets, instantSearchInstance, payload) { + var parent = instantSearchInstance.mainIndex; + var initOptions = { + instantSearchInstance: instantSearchInstance, + parent: parent, + scopedResults: [], + state: parent.getHelper().state, + helper: parent.getHelper(), + createURL: parent.createURL, + uiState: instantSearchInstance._initialUiState, + renderState: instantSearchInstance.renderState, + templatesConfig: instantSearchInstance.templatesConfig, + searchMetadata: { + isSearchStalled: instantSearchInstance._isSearchStalled + } + }; + widgets.forEach(function (widget) { + var widgetParams = {}; + + if (widget.getWidgetRenderState) { + var renderState = widget.getWidgetRenderState(initOptions); + + if (renderState && _typeof(renderState.widgetParams) === 'object') { + widgetParams = renderState.widgetParams; + } + } // since we destructure in all widgets, the parameters with defaults are set to "undefined" + + + var params = Object.keys(widgetParams).filter(function (key) { + return widgetParams[key] !== undefined; + }); + payload.widgets.push({ + type: widget.$$type, + widgetType: widget.$$widgetType, + params: params + }); + + if (widget.$$type === 'ais.index') { + extractPayload(widget.getWidgets(), instantSearchInstance, payload); + } + }); +} + +function isMetadataEnabled() { + return typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Algolia Crawler') > -1; +} +/** + * Exposes the metadata of mounted widgets in a custom + * `` tag. The metadata per widget is: + * - applied parameters + * - widget name + * - connector name + */ + + +function createMetadataMiddleware() { + return function (_ref) { + var instantSearchInstance = _ref.instantSearchInstance; + var payload = { + widgets: [] + }; + var payloadContainer = document.createElement('meta'); + var refNode = document.querySelector('head'); + payloadContainer.name = 'instantsearch:widgets'; + return { + onStateChange: function onStateChange() {}, + subscribe: function subscribe() { + // using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue) + setTimeout(function () { + var client = instantSearchInstance.client; + payload.ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua; + extractPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload); + payloadContainer.content = JSON.stringify(payload); + refNode.appendChild(payloadContainer); + }, 0); + }, + unsubscribe: function unsubscribe() { + payloadContainer.remove(); + } + }; + }; +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/middlewares/createRouterMiddleware.js b/js/instantsearch.js/cjs/middlewares/createRouterMiddleware.js new file mode 100644 index 00000000..9a2056e9 --- /dev/null +++ b/js/instantsearch.js/cjs/middlewares/createRouterMiddleware.js @@ -0,0 +1,64 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createRouterMiddleware = void 0; + +var _simple = _interopRequireDefault(require("../lib/stateMappings/simple")); + +var _history = _interopRequireDefault(require("../lib/routers/history")); + +var _utils = require("../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var createRouterMiddleware = function createRouterMiddleware() { + var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var _props$router = props.router, + router = _props$router === void 0 ? (0, _history.default)() : _props$router, + _props$stateMapping = props.stateMapping, + stateMapping = _props$stateMapping === void 0 ? (0, _simple.default)() : _props$stateMapping; + return function (_ref) { + var instantSearchInstance = _ref.instantSearchInstance; + + function topLevelCreateURL(nextState) { + var uiState = Object.keys(nextState).reduce(function (acc, indexId) { + return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, indexId, nextState[indexId])); + }, instantSearchInstance.mainIndex.getWidgetUiState({})); + var route = stateMapping.stateToRoute(uiState); + return router.createURL(route); + } + + instantSearchInstance._createURL = topLevelCreateURL; + instantSearchInstance._initialUiState = _objectSpread(_objectSpread({}, instantSearchInstance._initialUiState), stateMapping.routeToState(router.read())); + var lastRouteState = undefined; + return { + onStateChange: function onStateChange(_ref2) { + var uiState = _ref2.uiState; + var routeState = stateMapping.stateToRoute(uiState); + + if (lastRouteState === undefined || !(0, _utils.isEqual)(lastRouteState, routeState)) { + router.write(routeState); + lastRouteState = routeState; + } + }, + subscribe: function subscribe() { + router.onUpdate(function (route) { + instantSearchInstance.setUiState(stateMapping.routeToState(route)); + }); + }, + unsubscribe: function unsubscribe() { + router.dispose(); + } + }; + }; +}; + +exports.createRouterMiddleware = createRouterMiddleware; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/middlewares/index.js b/js/instantsearch.js/cjs/middlewares/index.js new file mode 100644 index 00000000..0feaf0af --- /dev/null +++ b/js/instantsearch.js/cjs/middlewares/index.js @@ -0,0 +1,44 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createInsightsMiddleware = require("./createInsightsMiddleware"); + +Object.keys(_createInsightsMiddleware).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _createInsightsMiddleware[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _createInsightsMiddleware[key]; + } + }); +}); + +var _createRouterMiddleware = require("./createRouterMiddleware"); + +Object.keys(_createRouterMiddleware).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _createRouterMiddleware[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _createRouterMiddleware[key]; + } + }); +}); + +var _createMetadataMiddleware = require("./createMetadataMiddleware"); + +Object.keys(_createMetadataMiddleware).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _createMetadataMiddleware[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _createMetadataMiddleware[key]; + } + }); +}); \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/algoliasearch.js b/js/instantsearch.js/cjs/types/algoliasearch.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/algoliasearch.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/component.js b/js/instantsearch.js/cjs/types/component.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/component.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/connector.js b/js/instantsearch.js/cjs/types/connector.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/connector.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/index.js b/js/instantsearch.js/cjs/types/index.js new file mode 100644 index 00000000..a96de124 --- /dev/null +++ b/js/instantsearch.js/cjs/types/index.js @@ -0,0 +1,187 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _utils = require("./utils"); + +Object.keys(_utils).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _utils[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _utils[key]; + } + }); +}); + +var _algoliasearch = require("./algoliasearch"); + +Object.keys(_algoliasearch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _algoliasearch[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _algoliasearch[key]; + } + }); +}); + +var _results = require("./results"); + +Object.keys(_results).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _results[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _results[key]; + } + }); +}); + +var _component = require("./component"); + +Object.keys(_component).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _component[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _component[key]; + } + }); +}); + +var _instantsearch = require("./instantsearch"); + +Object.keys(_instantsearch).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _instantsearch[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _instantsearch[key]; + } + }); +}); + +var _middleware = require("./middleware"); + +Object.keys(_middleware).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _middleware[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _middleware[key]; + } + }); +}); + +var _router = require("./router"); + +Object.keys(_router).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _router[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _router[key]; + } + }); +}); + +var _insights = require("./insights"); + +Object.keys(_insights).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _insights[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _insights[key]; + } + }); +}); + +var _connector = require("./connector"); + +Object.keys(_connector).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _connector[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _connector[key]; + } + }); +}); + +var _widgetFactory = require("./widget-factory"); + +Object.keys(_widgetFactory).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _widgetFactory[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _widgetFactory[key]; + } + }); +}); + +var _widget = require("./widget"); + +Object.keys(_widget).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _widget[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _widget[key]; + } + }); +}); + +var _uiState = require("./ui-state"); + +Object.keys(_uiState).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _uiState[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _uiState[key]; + } + }); +}); + +var _renderState = require("./render-state"); + +Object.keys(_renderState).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _renderState[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _renderState[key]; + } + }); +}); + +var _templates = require("./templates"); + +Object.keys(_templates).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + if (key in exports && exports[key] === _templates[key]) return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function get() { + return _templates[key]; + } + }); +}); \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/insights.js b/js/instantsearch.js/cjs/types/insights.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/insights.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/instantsearch.js b/js/instantsearch.js/cjs/types/instantsearch.js new file mode 100644 index 00000000..adfa508c --- /dev/null +++ b/js/instantsearch.js/cjs/types/instantsearch.js @@ -0,0 +1,25 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "InstantSearch", { + enumerable: true, + get: function get() { + return _InstantSearch.default; + } +}); +Object.defineProperty(exports, "InstantSearchOptions", { + enumerable: true, + get: function get() { + return _InstantSearch.InstantSearchOptions; + } +}); + +var _InstantSearch = _interopRequireWildcard(require("../lib/InstantSearch")); + +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/middleware.js b/js/instantsearch.js/cjs/types/middleware.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/middleware.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/render-state.js b/js/instantsearch.js/cjs/types/render-state.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/render-state.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/results.js b/js/instantsearch.js/cjs/types/results.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/results.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/router.js b/js/instantsearch.js/cjs/types/router.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/router.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/templates.js b/js/instantsearch.js/cjs/types/templates.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/templates.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/ui-state.js b/js/instantsearch.js/cjs/types/ui-state.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/ui-state.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/utils.js b/js/instantsearch.js/cjs/types/utils.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/utils.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/widget-factory.js b/js/instantsearch.js/cjs/types/widget-factory.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/widget-factory.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/types/widget.js b/js/instantsearch.js/cjs/types/widget.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/types/widget.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/analytics/analytics.js b/js/instantsearch.js/cjs/widgets/analytics/analytics.js new file mode 100644 index 00000000..8ab98ffd --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/analytics/analytics.js @@ -0,0 +1,187 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'analytics' +}); + +// @major this widget will be removed from the next major version. +var analytics = function analytics(widgetParams) { + var _ref = widgetParams || {}, + pushFunction = _ref.pushFunction, + _ref$delay = _ref.delay, + delay = _ref$delay === void 0 ? 3000 : _ref$delay, + _ref$triggerOnUIInter = _ref.triggerOnUIInteraction, + triggerOnUIInteraction = _ref$triggerOnUIInter === void 0 ? false : _ref$triggerOnUIInter, + _ref$pushInitialSearc = _ref.pushInitialSearch, + pushInitialSearch = _ref$pushInitialSearc === void 0 ? true : _ref$pushInitialSearc, + _ref$pushPagination = _ref.pushPagination, + pushPagination = _ref$pushPagination === void 0 ? false : _ref$pushPagination; + + if (!pushFunction) { + throw new Error(withUsage('The `pushFunction` option is required.')); + } + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`analytics` widget has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor the migration, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#analytics-widget") : void 0; + var cachedState = null; + + var serializeRefinements = function serializeRefinements(parameters) { + var refinements = []; + + for (var parameter in parameters) { + if (parameters.hasOwnProperty(parameter)) { + var values = parameters[parameter].join('+'); + refinements.push("".concat(encodeURIComponent(parameter), "=").concat(encodeURIComponent(parameter), "_").concat(encodeURIComponent(values))); + } + } + + return refinements.join('&'); + }; + + var serializeNumericRefinements = function serializeNumericRefinements(numericRefinements) { + var refinements = []; + + for (var attribute in numericRefinements) { + if (numericRefinements.hasOwnProperty(attribute)) { + var filter = numericRefinements[attribute]; + + if (filter.hasOwnProperty('>=') && filter.hasOwnProperty('<=')) { + if (filter['>='] && filter['>='][0] === filter['<='] && filter['<='][0]) { + refinements.push("".concat(attribute, "=").concat(attribute, "_").concat(filter['>='])); + } else { + refinements.push("".concat(attribute, "=").concat(attribute, "_").concat(filter['>='], "to").concat(filter['<='])); + } + } else if (filter.hasOwnProperty('>=')) { + refinements.push("".concat(attribute, "=").concat(attribute, "_from").concat(filter['>='])); + } else if (filter.hasOwnProperty('<=')) { + refinements.push("".concat(attribute, "=").concat(attribute, "_to").concat(filter['<='])); + } else if (filter.hasOwnProperty('=')) { + var equals = []; + + for (var equal in filter['=']) { + // eslint-disable-next-line max-depth + if (filter['='].hasOwnProperty(equal)) { + // @ts-ignore somehow 'equal' is a string, even though it's a number? + equals.push(filter['='][equal]); + } + } + + refinements.push("".concat(attribute, "=").concat(attribute, "_").concat(equals.join('-'))); + } + } + } + + return refinements.join('&'); + }; + + var lastSentData = ''; + + var sendAnalytics = function sendAnalytics(analyticsState) { + if (analyticsState === null) { + return; + } + + var serializedParams = []; + var serializedRefinements = serializeRefinements(_objectSpread(_objectSpread(_objectSpread({}, analyticsState.state.disjunctiveFacetsRefinements), analyticsState.state.facetsRefinements), analyticsState.state.hierarchicalFacetsRefinements)); + var serializedNumericRefinements = serializeNumericRefinements(analyticsState.state.numericRefinements); + + if (serializedRefinements !== '') { + serializedParams.push(serializedRefinements); + } + + if (serializedNumericRefinements !== '') { + serializedParams.push(serializedNumericRefinements); + } + + var stringifiedParams = serializedParams.join('&'); + var dataToSend = "Query: ".concat(analyticsState.state.query || '', ", ").concat(stringifiedParams); + + if (pushPagination === true) { + dataToSend += ", Page: ".concat(analyticsState.state.page || 0); + } + + if (lastSentData !== dataToSend) { + pushFunction(stringifiedParams, analyticsState.state, analyticsState.results); + lastSentData = dataToSend; + } + }; + + var pushTimeout; + var isInitialSearch = true; + + if (pushInitialSearch === true) { + isInitialSearch = false; + } + + var onClick = function onClick() { + sendAnalytics(cachedState); + }; + + var onUnload = function onUnload() { + sendAnalytics(cachedState); + }; + + return { + $$type: 'ais.analytics', + $$widgetType: 'ais.analytics', + init: function init() { + if (triggerOnUIInteraction === true) { + document.addEventListener('click', onClick); + window.addEventListener('beforeunload', onUnload); + } + }, + render: function render(_ref2) { + var results = _ref2.results, + state = _ref2.state; + + if (isInitialSearch === true) { + isInitialSearch = false; + return; + } + + cachedState = { + results: results, + state: state + }; + + if (pushTimeout) { + clearTimeout(pushTimeout); + } + + pushTimeout = window.setTimeout(function () { + return sendAnalytics(cachedState); + }, delay); + }, + dispose: function dispose() { + if (triggerOnUIInteraction === true) { + document.removeEventListener('click', onClick); + window.removeEventListener('beforeunload', onUnload); + } + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + analytics: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState() { + return { + widgetParams: widgetParams + }; + } + }; +}; + +var _default = analytics; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/answers/answers.js b/js/instantsearch.js/cjs/widgets/answers/answers.js new file mode 100644 index 00000000..87a777c3 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/answers/answers.js @@ -0,0 +1,124 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _Answers = _interopRequireDefault(require("../../components/Answers/Answers")); + +var _connectAnswers = _interopRequireDefault(require("../../connectors/answers/connectAnswers")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'answers' +}); +var suit = (0, _suit.component)('Answers'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var hits = _ref2.hits, + isLoading = _ref2.isLoading, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_Answers.default, { + cssClasses: cssClasses, + hits: hits, + isLoading: isLoading, + templateProps: renderState.templateProps + }), containerNode); + }; +}; + +var answersWidget = function answersWidget(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attributesForPrediction = _ref3.attributesForPrediction, + queryLanguages = _ref3.queryLanguages, + nbHits = _ref3.nbHits, + searchDebounceTime = _ref3.searchDebounceTime, + renderDebounceTime = _ref3.renderDebounceTime, + escapeHTML = _ref3.escapeHTML, + extraParameters = _ref3.extraParameters, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + emptyRoot: (0, _classnames.default)(suit({ + modifierName: 'empty' + }), userCssClasses.emptyRoot), + header: (0, _classnames.default)(suit({ + descendantName: 'header' + }), userCssClasses.header), + loader: (0, _classnames.default)(suit({ + descendantName: 'loader' + }), userCssClasses.loader), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + renderState: {} + }); + var makeWidget = (0, _connectAnswers.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attributesForPrediction: attributesForPrediction, + queryLanguages: queryLanguages, + nbHits: nbHits, + searchDebounceTime: searchDebounceTime, + renderDebounceTime: renderDebounceTime, + escapeHTML: escapeHTML, + extraParameters: extraParameters + })), {}, { + $$widgetType: 'ais.answers' + }); +}; + +var _default = answersWidget; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/answers/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/answers/defaultTemplates.js new file mode 100644 index 00000000..c94670d6 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/answers/defaultTemplates.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + header: '', + loader: '', + item: function item(_item) { + return JSON.stringify(_item); + } +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/breadcrumb/breadcrumb.js b/js/instantsearch.js/cjs/widgets/breadcrumb/breadcrumb.js new file mode 100644 index 00000000..c68ddb25 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/breadcrumb/breadcrumb.js @@ -0,0 +1,126 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Breadcrumb = _interopRequireDefault(require("../../components/Breadcrumb/Breadcrumb")); + +var _connectBreadcrumb = _interopRequireDefault(require("../../connectors/breadcrumb/connectBreadcrumb")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'breadcrumb' +}); +var suit = (0, _suit.component)('Breadcrumb'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var canRefine = _ref2.canRefine, + createURL = _ref2.createURL, + instantSearchInstance = _ref2.instantSearchInstance, + items = _ref2.items, + refine = _ref2.refine; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_Breadcrumb.default, { + canRefine: canRefine, + cssClasses: cssClasses, + createURL: createURL, + items: items, + refine: refine, + templateProps: renderState.templateProps + }), containerNode); + }; +}; + +var breadcrumb = function breadcrumb(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attributes = _ref3.attributes, + separator = _ref3.separator, + rootPath = _ref3.rootPath, + transformItems = _ref3.transformItems, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + separator: (0, _classnames.default)(suit({ + descendantName: 'separator' + }), userCssClasses.separator), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectBreadcrumb.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attributes: attributes, + separator: separator, + rootPath: rootPath, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.breadcrumb' + }); +}; + +var _default = breadcrumb; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/breadcrumb/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/breadcrumb/defaultTemplates.js new file mode 100644 index 00000000..91aae428 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/breadcrumb/defaultTemplates.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + home: 'Home', + separator: '>' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/clear-refinements/clear-refinements.js b/js/instantsearch.js/cjs/widgets/clear-refinements/clear-refinements.js new file mode 100644 index 00000000..5c8f36cd --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/clear-refinements/clear-refinements.js @@ -0,0 +1,108 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _ClearRefinements = _interopRequireDefault(require("../../components/ClearRefinements/ClearRefinements")); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _connectClearRefinements = _interopRequireDefault(require("../../connectors/clear-refinements/connectClearRefinements")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'clear-refinements' +}); +var suit = (0, _suit.component)('ClearRefinements'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + hasRefinements = _ref2.hasRefinements, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_ClearRefinements.default, { + refine: refine, + cssClasses: cssClasses, + hasRefinements: hasRefinements, + templateProps: renderState.templateProps + }), containerNode); + }; +}; + +var clearRefinements = function clearRefinements(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + includedAttributes = _ref3.includedAttributes, + excludedAttributes = _ref3.excludedAttributes, + transformItems = _ref3.transformItems, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + button: (0, _classnames.default)(suit({ + descendantName: 'button' + }), userCssClasses.button), + disabledButton: (0, _classnames.default)(suit({ + descendantName: 'button', + modifierName: 'disabled' + }), userCssClasses.disabledButton) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectClearRefinements.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + includedAttributes: includedAttributes, + excludedAttributes: excludedAttributes, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.clearRefinements' + }); +}; + +var _default = clearRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/clear-refinements/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/clear-refinements/defaultTemplates.js new file mode 100644 index 00000000..d1783968 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/clear-refinements/defaultTemplates.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + resetLabel: 'Clear refinements' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/configure-related-items/configure-related-items.js b/js/instantsearch.js/cjs/widgets/configure-related-items/configure-related-items.js new file mode 100644 index 00000000..7e47f824 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/configure-related-items/configure-related-items.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +var _connectConfigureRelatedItems = _interopRequireDefault(require("../../connectors/configure-related-items/connectConfigureRelatedItems")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var configureRelatedItems = function configureRelatedItems(widgetParams) { + var makeWidget = (0, _connectConfigureRelatedItems.default)(_utils.noop); + return _objectSpread(_objectSpread({}, makeWidget(widgetParams)), {}, { + $$widgetType: 'ais.configureRelatedItems' + }); +}; + +var _default = configureRelatedItems; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/configure/configure.js b/js/instantsearch.js/cjs/widgets/configure/configure.js new file mode 100644 index 00000000..bc6de454 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/configure/configure.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _connectConfigure = _interopRequireDefault(require("../../connectors/configure/connectConfigure")); + +var _utils = require("../../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var configure = function configure(widgetParams) { + // This is a renderless widget that falls back to the connector's + // noop render and unmount functions. + var makeWidget = (0, _connectConfigure.default)(_utils.noop); + return _objectSpread(_objectSpread({}, makeWidget({ + searchParameters: widgetParams + })), {}, { + $$widgetType: 'ais.configure' + }); +}; + +var _default = configure; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/current-refinements/current-refinements.js b/js/instantsearch.js/cjs/widgets/current-refinements/current-refinements.js new file mode 100644 index 00000000..75744e75 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/current-refinements/current-refinements.js @@ -0,0 +1,100 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _CurrentRefinements = _interopRequireDefault(require("../../components/CurrentRefinements/CurrentRefinements")); + +var _connectCurrentRefinements = _interopRequireDefault(require("../../connectors/current-refinements/connectCurrentRefinements")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'current-refinements' +}); +var suit = (0, _suit.component)('CurrentRefinements'); + +var renderer = function renderer(_ref, isFirstRender) { + var items = _ref.items, + widgetParams = _ref.widgetParams; + + if (isFirstRender) { + return; + } + + var _ref2 = widgetParams, + container = _ref2.container, + cssClasses = _ref2.cssClasses; + (0, _preact.render)((0, _preact.h)(_CurrentRefinements.default, { + cssClasses: cssClasses, + items: items + }), container); +}; + +var currentRefinements = function currentRefinements(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + includedAttributes = _ref3.includedAttributes, + excludedAttributes = _ref3.excludedAttributes, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + category: (0, _classnames.default)(suit({ + descendantName: 'category' + }), userCssClasses.category), + categoryLabel: (0, _classnames.default)(suit({ + descendantName: 'categoryLabel' + }), userCssClasses.categoryLabel), + delete: (0, _classnames.default)(suit({ + descendantName: 'delete' + }), userCssClasses.delete) + }; + var makeWidget = (0, _connectCurrentRefinements.default)(renderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + container: containerNode, + cssClasses: cssClasses, + includedAttributes: includedAttributes, + excludedAttributes: excludedAttributes, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.currentRefinements' + }); +}; + +var _default = currentRefinements; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/dynamic-widgets/dynamic-widgets.js b/js/instantsearch.js/cjs/widgets/dynamic-widgets/dynamic-widgets.js new file mode 100644 index 00000000..de73f991 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/dynamic-widgets/dynamic-widgets.js @@ -0,0 +1,90 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _connectDynamicWidgets = _interopRequireDefault(require("../../connectors/dynamic-widgets/connectDynamicWidgets")); + +var _suit = require("../../lib/suit"); + +var _utils = require("../../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'dynamic-widgets' +}); +var suit = (0, _suit.component)('DynamicWidgets'); + +var dynamicWidgets = function dynamicWidgets(widgetParams) { + var _ref = widgetParams || {}, + containerSelector = _ref.container, + transformItems = _ref.transformItems, + widgets = _ref.widgets; + + if (!containerSelector) { + throw new Error(withUsage('The `container` option is required.')); + } + + if (!widgets || !Array.isArray(widgets) || widgets.some(function (widget) { + return typeof widget !== 'function'; + })) { + throw new Error(withUsage('The `widgets` option expects an array of callbacks.')); + } + + var userContainer = (0, _utils.getContainerNode)(containerSelector); + var rootContainer = document.createElement('div'); + rootContainer.className = suit(); + var containers = new Map(); + var connectorWidgets = []; + var makeWidget = (0, _connectDynamicWidgets.default)(function (_ref2, isFirstRender) { + var attributesToRender = _ref2.attributesToRender; + + if (isFirstRender) { + userContainer.appendChild(rootContainer); + } + + attributesToRender.forEach(function (attribute) { + if (!containers.has(attribute)) { + return; + } + + var container = containers.get(attribute); + rootContainer.appendChild(container); + }); + }, function () { + userContainer.removeChild(rootContainer); + }); + var widget = makeWidget({ + transformItems: transformItems, + widgets: connectorWidgets + }); + return _objectSpread(_objectSpread({}, widget), {}, { + init: function init(initOptions) { + widgets.forEach(function (cb) { + var container = document.createElement('div'); + container.className = suit({ + descendantName: 'widget' + }); + rootContainer.appendChild(container); + var childWidget = cb(container); + var attribute = (0, _utils.getWidgetAttribute)(childWidget, initOptions); + containers.set(attribute, container); + connectorWidgets.push(childWidget); + }); + widget.init(initOptions); + }, + $$widgetType: 'ais.dynamicWidgets' + }); +}; + +var _default = dynamicWidgets; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.d.js b/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.d.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.d.js @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.js b/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.js new file mode 100644 index 00000000..7bacde49 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/geo-search/GeoSearchRenderer.js @@ -0,0 +1,233 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _utils = require("../../lib/utils"); + +var _GeoSearchControls = _interopRequireDefault(require("../../components/GeoSearchControls/GeoSearchControls")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var refineWithMap = function refineWithMap(_ref) { + var refine = _ref.refine, + mapInstance = _ref.mapInstance; + return refine({ + northEast: mapInstance.getBounds().getNorthEast().toJSON(), + southWest: mapInstance.getBounds().getSouthWest().toJSON() + }); +}; + +var collectMarkersForNextRender = function collectMarkersForNextRender(markers, nextIds) { + return markers.reduce(function (_ref2, marker) { + var _ref3 = _slicedToArray(_ref2, 2), + update = _ref3[0], + exit = _ref3[1]; + + var persist = nextIds.includes(marker.__id); + return persist ? [update.concat(marker), exit] : [update, exit.concat(marker)]; + }, [[], []]); +}; + +var createBoundingBoxFromMarkers = function createBoundingBoxFromMarkers(google, markers) { + var latLngBounds = markers.reduce(function (acc, marker) { + return acc.extend(marker.getPosition()); + }, new google.maps.LatLngBounds()); + return { + northEast: latLngBounds.getNorthEast().toJSON(), + southWest: latLngBounds.getSouthWest().toJSON() + }; +}; + +var lockUserInteraction = function lockUserInteraction(renderState, functionThatAltersTheMapPosition) { + renderState.isUserInteraction = false; + functionThatAltersTheMapPosition(); + renderState.isUserInteraction = true; +}; + +var renderer = function renderer(_ref4, isFirstRendering) { + var items = _ref4.items, + position = _ref4.position, + currentRefinement = _ref4.currentRefinement, + refine = _ref4.refine, + clearMapRefinement = _ref4.clearMapRefinement, + toggleRefineOnMapMove = _ref4.toggleRefineOnMapMove, + isRefineOnMapMove = _ref4.isRefineOnMapMove, + setMapMoveSinceLastRefine = _ref4.setMapMoveSinceLastRefine, + hasMapMoveSinceLastRefine = _ref4.hasMapMoveSinceLastRefine, + isRefinedWithMap = _ref4.isRefinedWithMap, + widgetParams = _ref4.widgetParams, + instantSearchInstance = _ref4.instantSearchInstance; + var container = widgetParams.container, + googleReference = widgetParams.googleReference, + cssClasses = widgetParams.cssClasses, + templates = widgetParams.templates, + initialZoom = widgetParams.initialZoom, + initialPosition = widgetParams.initialPosition, + enableRefine = widgetParams.enableRefine, + enableClearMapRefinement = widgetParams.enableClearMapRefinement, + enableRefineControl = widgetParams.enableRefineControl, + mapOptions = widgetParams.mapOptions, + createMarker = widgetParams.createMarker, + markerOptions = widgetParams.markerOptions, + renderState = widgetParams.renderState; + + if (isFirstRendering) { + renderState.isUserInteraction = true; + renderState.isPendingRefine = false; + renderState.markers = []; + var rootElement = document.createElement('div'); + rootElement.className = cssClasses.root; + container.appendChild(rootElement); + var mapElement = document.createElement('div'); + mapElement.className = cssClasses.map; + rootElement.appendChild(mapElement); + var treeElement = document.createElement('div'); + treeElement.className = cssClasses.tree; + rootElement.appendChild(treeElement); + renderState.mapInstance = new googleReference.maps.Map(mapElement, _objectSpread({ + mapTypeControl: false, + fullscreenControl: false, + streetViewControl: false, + clickableIcons: false, + zoomControlOptions: { + position: googleReference.maps.ControlPosition.LEFT_TOP + } + }, mapOptions)); + + var setupListenersWhenMapIsReady = function setupListenersWhenMapIsReady() { + var onChange = function onChange() { + if (renderState.isUserInteraction && enableRefine) { + setMapMoveSinceLastRefine(); + + if (isRefineOnMapMove()) { + renderState.isPendingRefine = true; + } + } + }; + + renderState.mapInstance.addListener('center_changed', onChange); + renderState.mapInstance.addListener('zoom_changed', onChange); + renderState.mapInstance.addListener('dragstart', onChange); + renderState.mapInstance.addListener('idle', function () { + if (renderState.isUserInteraction && renderState.isPendingRefine) { + renderState.isPendingRefine = false; + refineWithMap({ + mapInstance: renderState.mapInstance, + refine: refine + }); + } + }); + }; + + googleReference.maps.event.addListenerOnce(renderState.mapInstance, 'idle', setupListenersWhenMapIsReady); + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } // Collect markers that need to be updated or removed + + + var nextItemsIds = items.map(function (_) { + return _.objectID; + }); + + var _collectMarkersForNex = collectMarkersForNextRender(renderState.markers, nextItemsIds), + _collectMarkersForNex2 = _slicedToArray(_collectMarkersForNex, 2), + updateMarkers = _collectMarkersForNex2[0], + exitMarkers = _collectMarkersForNex2[1]; // Collect items that will be added + + + var updateMarkerIds = updateMarkers.map(function (_) { + return _.__id; + }); + var nextPendingItems = items.filter(function (item) { + return !updateMarkerIds.includes(item.objectID); + }); // Remove all markers that need to be removed + + exitMarkers.forEach(function (marker) { + return marker.setMap(null); + }); // Create the markers from the items + + renderState.markers = updateMarkers.concat(nextPendingItems.map(function (item) { + var marker = createMarker({ + map: renderState.mapInstance, + item: item + }); + Object.keys(markerOptions.events).forEach(function (eventName) { + marker.addListener(eventName, function (event) { + markerOptions.events[eventName]({ + map: renderState.mapInstance, + event: event, + item: item, + marker: marker + }); + }); + }); + return marker; + })); + var shouldUpdate = !hasMapMoveSinceLastRefine(); // We use this value for differentiate the padding to apply during + // fitBounds. When we don't have a currenRefinement (boundingBox) + // we let Google Maps compute the automatic padding. But when we + // provide the currentRefinement we explicitly set the padding + // to `0` otherwise the map will decrease the zoom on each refine. + + var boundingBoxPadding = currentRefinement ? 0 : null; + var boundingBox = !currentRefinement && Boolean(renderState.markers.length) ? createBoundingBoxFromMarkers(googleReference, renderState.markers) : currentRefinement; + + if (boundingBox && shouldUpdate) { + lockUserInteraction(renderState, function () { + renderState.mapInstance.fitBounds(new googleReference.maps.LatLngBounds(boundingBox.southWest, boundingBox.northEast), boundingBoxPadding); + }); + } else if (shouldUpdate) { + lockUserInteraction(renderState, function () { + renderState.mapInstance.setCenter(position || initialPosition); + renderState.mapInstance.setZoom(initialZoom); + }); + } + + (0, _preact.render)((0, _preact.h)(_GeoSearchControls.default, { + cssClasses: cssClasses, + enableRefine: enableRefine, + enableRefineControl: enableRefineControl, + enableClearMapRefinement: enableClearMapRefinement, + isRefineOnMapMove: isRefineOnMapMove(), + isRefinedWithMap: isRefinedWithMap(), + hasMapMoveSinceLastRefine: hasMapMoveSinceLastRefine(), + onRefineToggle: toggleRefineOnMapMove, + onRefineClick: function onRefineClick() { + return refineWithMap({ + mapInstance: renderState.mapInstance, + refine: refine + }); + }, + onClearClick: clearMapRefinement, + templateProps: renderState.templateProps + }), container.querySelector(".".concat(cssClasses.tree))); +}; + +var _default = renderer; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/geo-search/createHTMLMarker.js b/js/instantsearch.js/cjs/widgets/geo-search/createHTMLMarker.js new file mode 100644 index 00000000..56012fc0 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/geo-search/createHTMLMarker.js @@ -0,0 +1,153 @@ +"use strict"; + +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); } + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +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; } + +/* global google EventListener */ +var createHTMLMarker = function createHTMLMarker(googleReference) { + var HTMLMarker = /*#__PURE__*/function (_googleReference$maps) { + _inherits(HTMLMarker, _googleReference$maps); + + var _super = _createSuper(HTMLMarker); + + function HTMLMarker(_ref) { + var _this; + + var __id = _ref.__id, + position = _ref.position, + map = _ref.map, + template = _ref.template, + className = _ref.className, + _ref$anchor = _ref.anchor, + anchor = _ref$anchor === void 0 ? { + x: 0, + y: 0 + } : _ref$anchor; + + _classCallCheck(this, HTMLMarker); + + _this = _super.call(this); + + _defineProperty(_assertThisInitialized(_this), "__id", void 0); + + _defineProperty(_assertThisInitialized(_this), "anchor", void 0); + + _defineProperty(_assertThisInitialized(_this), "offset", void 0); + + _defineProperty(_assertThisInitialized(_this), "listeners", void 0); + + _defineProperty(_assertThisInitialized(_this), "latLng", void 0); + + _defineProperty(_assertThisInitialized(_this), "element", void 0); + + _this.__id = __id; + _this.anchor = anchor; + _this.listeners = {}; + _this.latLng = new googleReference.maps.LatLng(position); + _this.element = document.createElement('div'); + _this.element.className = className; + _this.element.style.position = 'absolute'; + _this.element.innerHTML = template; + + _this.setMap(map); + + return _this; + } + + _createClass(HTMLMarker, [{ + key: "onAdd", + value: function onAdd() { + // Append the element to the map + this.getPanes().overlayMouseTarget.appendChild(this.element); // Compute the offset onAdd & cache it because afterwards + // it won't retrieve the correct values, we also avoid + // to read the values on every draw + + var bbBox = this.element.getBoundingClientRect(); + this.offset = { + x: this.anchor.x + bbBox.width / 2, + y: this.anchor.y + bbBox.height + }; // Force the width of the element will avoid the + // content to collapse when we move the map + + this.element.style.width = "".concat(bbBox.width, "px"); + } + }, { + key: "draw", + value: function draw() { + var position = this.getProjection().fromLatLngToDivPixel(this.latLng); + this.element.style.left = "".concat(Math.round(position.x - this.offset.x), "px"); + this.element.style.top = "".concat(Math.round(position.y - this.offset.y), "px"); // Markers to the south are in front of markers to the north + // This is the default behaviour of Google Maps + + this.element.style.zIndex = String(parseInt(this.element.style.top, 10)); + } + }, { + key: "onRemove", + value: function onRemove() { + var _this2 = this; + + if (this.element) { + this.element.parentNode.removeChild(this.element); + Object.keys(this.listeners).forEach(function (eventName) { + _this2.element.removeEventListener(eventName, _this2.listeners[eventName]); + }); // after onRemove the class is no longer used, thus it can be deleted + // @ts-expect-error + + delete this.element; // @ts-expect-error + + delete this.listeners; + } + } + }, { + key: "addListener", + value: function addListener(eventName, listener) { + this.listeners[eventName] = listener; + var element = this.element; + element.addEventListener(eventName, listener); + return { + remove: function remove() { + return element.removeEventListener(eventName, listener); + } + }; + } + }, { + key: "getPosition", + value: function getPosition() { + return this.latLng; + } + }]); + + return HTMLMarker; + }(googleReference.maps.OverlayView); + + return HTMLMarker; +}; + +var _default = createHTMLMarker; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/geo-search/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/geo-search/defaultTemplates.js new file mode 100644 index 00000000..7ba20e7e --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/geo-search/defaultTemplates.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + HTMLMarker: '

Your custom HTML Marker

', + reset: 'Clear the map refinement', + toggle: 'Search as I move the map', + redo: 'Redo search here' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/geo-search/geo-search.js b/js/instantsearch.js/cjs/widgets/geo-search/geo-search.js new file mode 100644 index 00000000..0c57bb00 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/geo-search/geo-search.js @@ -0,0 +1,199 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _classnames = _interopRequireDefault(require("classnames")); + +var _preact = require("preact"); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _connectGeoSearch = _interopRequireDefault(require("../../connectors/geo-search/connectGeoSearch")); + +var _GeoSearchRenderer = _interopRequireDefault(require("./GeoSearchRenderer")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _createHTMLMarker = _interopRequireDefault(require("./createHTMLMarker")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'geo-search' +}); +var suit = (0, _suit.component)('GeoSearch'); + +/** + * The **GeoSearch** widget displays the list of results from the search on a Google Maps. It also provides a way to search for results based on their position. The widget also provide some of the common GeoSearch patterns like search on map interaction. + * + * @requirements + * + * Note that the GeoSearch widget uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia. Your hits **must** have a `_geoloc` attribute in order to be displayed on the map. + * + * Currently, the feature is not compatible with multiple values in the _geoloc attribute. + * + * You are also responsible for loading the Google Maps library, it's not shipped with InstantSearch. You need to load the Google Maps library and pass a reference to the widget. You can find more information about how to install the library in [the Google Maps documentation](https://developers.google.com/maps/documentation/javascript/tutorial). + * + * Don't forget to explicitly set the `height` of the map container (default class `.ais-geo-search--map`), otherwise it won't be shown (it's a requirement of Google Maps). + */ +var geoSearch = function geoSearch(widgetParams) { + var _ref = widgetParams || {}, + _ref$initialZoom = _ref.initialZoom, + initialZoom = _ref$initialZoom === void 0 ? 1 : _ref$initialZoom, + _ref$initialPosition = _ref.initialPosition, + initialPosition = _ref$initialPosition === void 0 ? { + lat: 0, + lng: 0 + } : _ref$initialPosition, + _ref$templates = _ref.templates, + userTemplates = _ref$templates === void 0 ? {} : _ref$templates, + _ref$cssClasses = _ref.cssClasses, + userCssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses, + _ref$builtInMarker = _ref.builtInMarker, + userBuiltInMarker = _ref$builtInMarker === void 0 ? {} : _ref$builtInMarker, + userCustomHTMLMarker = _ref.customHTMLMarker, + _ref$enableRefine = _ref.enableRefine, + enableRefine = _ref$enableRefine === void 0 ? true : _ref$enableRefine, + _ref$enableClearMapRe = _ref.enableClearMapRefinement, + enableClearMapRefinement = _ref$enableClearMapRe === void 0 ? true : _ref$enableClearMapRe, + _ref$enableRefineCont = _ref.enableRefineControl, + enableRefineControl = _ref$enableRefineCont === void 0 ? true : _ref$enableRefineCont, + container = _ref.container, + googleReference = _ref.googleReference, + otherWidgetParams = _objectWithoutProperties(_ref, ["initialZoom", "initialPosition", "templates", "cssClasses", "builtInMarker", "customHTMLMarker", "enableRefine", "enableClearMapRefinement", "enableRefineControl", "container", "googleReference"]); + + var defaultBuiltInMarker = { + createOptions: function createOptions() { + return {}; + }, + events: {} + }; + var defaultCustomHTMLMarker = { + createOptions: function createOptions() { + return {}; + }, + events: {} + }; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + if (!googleReference) { + throw new Error(withUsage('The `googleReference` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + // Required only to mount / unmount the Preact tree + tree: suit({ + descendantName: 'tree' + }), + map: (0, _classnames.default)(suit({ + descendantName: 'map' + }), userCssClasses.map), + control: (0, _classnames.default)(suit({ + descendantName: 'control' + }), userCssClasses.control), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + selectedLabel: (0, _classnames.default)(suit({ + descendantName: 'label', + modifierName: 'selected' + }), userCssClasses.selectedLabel), + input: (0, _classnames.default)(suit({ + descendantName: 'input' + }), userCssClasses.input), + redo: (0, _classnames.default)(suit({ + descendantName: 'redo' + }), userCssClasses.redo), + disabledRedo: (0, _classnames.default)(suit({ + descendantName: 'redo', + modifierName: 'disabled' + }), userCssClasses.disabledRedo), + reset: (0, _classnames.default)(suit({ + descendantName: 'reset' + }), userCssClasses.reset) + }; + + var templates = _objectSpread(_objectSpread({}, _defaultTemplates.default), userTemplates); + + var builtInMarker = _objectSpread(_objectSpread({}, defaultBuiltInMarker), userBuiltInMarker); + + var isCustomHTMLMarker = Boolean(userCustomHTMLMarker) || Boolean(userTemplates.HTMLMarker); + + var customHTMLMarker = isCustomHTMLMarker && _objectSpread(_objectSpread({}, defaultCustomHTMLMarker), userCustomHTMLMarker); + + var createBuiltInMarker = function createBuiltInMarker(_ref2) { + var item = _ref2.item, + rest = _objectWithoutProperties(_ref2, ["item"]); + + return new googleReference.maps.Marker(_objectSpread(_objectSpread(_objectSpread({}, builtInMarker.createOptions(item)), rest), {}, { + // @ts-expect-error @types/googlemaps doesn't document this + __id: item.objectID, + position: item._geoloc + })); + }; + + var HTMLMarker = (0, _createHTMLMarker.default)(googleReference); + + var createCustomHTMLMarker = function createCustomHTMLMarker(_ref3) { + var item = _ref3.item, + rest = _objectWithoutProperties(_ref3, ["item"]); + + return new HTMLMarker(_objectSpread(_objectSpread(_objectSpread({}, customHTMLMarker.createOptions(item)), rest), {}, { + __id: item.objectID, + position: item._geoloc, + className: (0, _classnames.default)(suit({ + descendantName: 'marker' + })), + template: (0, _utils.renderTemplate)({ + templateKey: 'HTMLMarker', + templates: templates, + data: item + }) + })); + }; + + var createMarker = !customHTMLMarker ? createBuiltInMarker : createCustomHTMLMarker; + var markerOptions = !customHTMLMarker ? builtInMarker : customHTMLMarker; + var makeWidget = (0, _connectGeoSearch.default)(_GeoSearchRenderer.default, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget(_objectSpread(_objectSpread({}, otherWidgetParams), {}, { + renderState: {}, + container: containerNode, + googleReference: googleReference, + initialZoom: initialZoom, + initialPosition: initialPosition, + templates: templates, + cssClasses: cssClasses, + createMarker: createMarker, + markerOptions: markerOptions, + enableRefine: enableRefine, + enableClearMapRefinement: enableClearMapRefinement, + enableRefineControl: enableRefineControl + }))), {}, { + $$widgetType: 'ais.geoSearch' + }); +}; + +var _default = geoSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/hierarchical-menu/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/hierarchical-menu/defaultTemplates.js new file mode 100644 index 00000000..69d663eb --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/hierarchical-menu/defaultTemplates.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: '' + '{{label}}' + '{{#helpers.formatNumber}}{{count}}{{/helpers.formatNumber}}' + '', + showMoreText: "\n {{#isShowingMore}}\n Show less\n {{/isShowingMore}}\n {{^isShowingMore}}\n Show more\n {{/isShowingMore}}\n " +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/hierarchical-menu/hierarchical-menu.js b/js/instantsearch.js/cjs/widgets/hierarchical-menu/hierarchical-menu.js new file mode 100644 index 00000000..65cada9e --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/hierarchical-menu/hierarchical-menu.js @@ -0,0 +1,214 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RefinementList = _interopRequireDefault(require("../../components/RefinementList/RefinementList")); + +var _connectHierarchicalMenu = _interopRequireDefault(require("../../connectors/hierarchical-menu/connectHierarchicalMenu")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hierarchical-menu' +}); +var suit = (0, _suit.component)('HierarchicalMenu'); + +var renderer = function renderer(_ref) { + var cssClasses = _ref.cssClasses, + containerNode = _ref.containerNode, + showMore = _ref.showMore, + templates = _ref.templates, + renderState = _ref.renderState; + return function (_ref2, isFirstRendering) { + var createURL = _ref2.createURL, + items = _ref2.items, + refine = _ref2.refine, + instantSearchInstance = _ref2.instantSearchInstance, + isShowingMore = _ref2.isShowingMore, + toggleShowMore = _ref2.toggleShowMore, + canToggleShowMore = _ref2.canToggleShowMore; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_RefinementList.default, { + createURL: createURL, + cssClasses: cssClasses, + facetValues: items, + templateProps: renderState.templateProps, + toggleRefinement: refine, + showMore: showMore, + toggleShowMore: toggleShowMore, + isShowingMore: isShowingMore, + canToggleShowMore: canToggleShowMore + }), containerNode); + }; +}; +/** + * The hierarchical menu widget is used to create a navigation based on a hierarchy of facet attributes. + * + * It is commonly used for categories with subcategories. + * + * All attributes (lvl0, lvl1 here) must be declared as [attributes for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) in your + * Algolia settings. + * + * By default, the separator we expect is ` > ` (with spaces) but you can use + * a different one by using the `separator` option. + * @requirements + * Your objects must be formatted in a specific way to be + * able to display hierarchical menus. Here's an example: + * + * ```javascript + * { + * "objectID": "123", + * "name": "orange", + * "categories": { + * "lvl0": "fruits", + * "lvl1": "fruits > citrus" + * } + * } + * ``` + * + * Every level must be specified entirely. + * It's also possible to have multiple values per level, for example: + * + * ```javascript + * { + * "objectID": "123", + * "name": "orange", + * "categories": { + * "lvl0": ["fruits", "vitamins"], + * "lvl1": ["fruits > citrus", "vitamins > C"] + * } + * } + * ``` + * @type {WidgetFactory} + * @devNovel HierarchicalMenu + * @category filter + * @param {HierarchicalMenuWidgetParams} widgetParams The HierarchicalMenu widget options. + * @return {Widget} A new HierarchicalMenu widget instance. + * @example + * search.addWidgets([ + * instantsearch.widgets.hierarchicalMenu({ + * container: '#hierarchical-categories', + * attributes: ['hierarchicalCategories.lvl0', 'hierarchicalCategories.lvl1', 'hierarchicalCategories.lvl2'], + * }) + * ]); + */ + + +var hierarchicalMenu = function hierarchicalMenu(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attributes = _ref3.attributes, + separator = _ref3.separator, + rootPath = _ref3.rootPath, + showParentLevel = _ref3.showParentLevel, + limit = _ref3.limit, + _ref3$showMore = _ref3.showMore, + showMore = _ref3$showMore === void 0 ? false : _ref3$showMore, + showMoreLimit = _ref3.showMoreLimit, + sortBy = _ref3.sortBy, + transformItems = _ref3.transformItems, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + childList: (0, _classnames.default)(suit({ + descendantName: 'list', + modifierName: 'child' + }), userCssClasses.childList), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + parentItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'parent' + }), userCssClasses.parentItem), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + count: (0, _classnames.default)(suit({ + descendantName: 'count' + }), userCssClasses.count), + showMore: (0, _classnames.default)(suit({ + descendantName: 'showMore' + }), userCssClasses.showMore), + disabledShowMore: (0, _classnames.default)(suit({ + descendantName: 'showMore', + modifierName: 'disabled' + }), userCssClasses.disabledShowMore) + }; + var specializedRenderer = renderer({ + cssClasses: cssClasses, + containerNode: containerNode, + templates: templates, + showMore: showMore, + renderState: {} + }); + var makeWidget = (0, _connectHierarchicalMenu.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attributes: attributes, + separator: separator, + rootPath: rootPath, + showParentLevel: showParentLevel, + limit: limit, + showMore: showMore, + showMoreLimit: showMoreLimit, + sortBy: sortBy, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.hierarchicalMenu' + }); +}; + +var _default = hierarchicalMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/hits-per-page/hits-per-page.js b/js/instantsearch.js/cjs/widgets/hits-per-page/hits-per-page.js new file mode 100644 index 00000000..dd8982b2 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/hits-per-page/hits-per-page.js @@ -0,0 +1,96 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Selector = _interopRequireDefault(require("../../components/Selector/Selector")); + +var _connectHitsPerPage = _interopRequireDefault(require("../../connectors/hits-per-page/connectHitsPerPage")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hits-per-page' +}); +var suit = (0, _suit.component)('HitsPerPage'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses; + return function (_ref2, isFirstRendering) { + var items = _ref2.items, + refine = _ref2.refine; + if (isFirstRendering) return; + + var _ref3 = (0, _utils.find)(items, function (_ref4) { + var isRefined = _ref4.isRefined; + return isRefined; + }) || {}, + currentValue = _ref3.value; + + (0, _preact.render)((0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)(_Selector.default, { + cssClasses: cssClasses, + currentValue: currentValue, + options: items, + setValue: refine + })), containerNode); + }; +}; + +var hitsPerPage = function hitsPerPage(widgetParams) { + var _ref5 = widgetParams || {}, + container = _ref5.container, + items = _ref5.items, + _ref5$cssClasses = _ref5.cssClasses, + userCssClasses = _ref5$cssClasses === void 0 ? {} : _ref5$cssClasses, + transformItems = _ref5.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + select: (0, _classnames.default)(suit({ + descendantName: 'select' + }), userCssClasses.select), + option: (0, _classnames.default)(suit({ + descendantName: 'option' + }), userCssClasses.option) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses + }); + var makeWidget = (0, _connectHitsPerPage.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + items: items, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.hitsPerPage' + }); +}; + +var _default = hitsPerPage; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/widgets/infinite-hits/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/hits/defaultTemplates.js similarity index 56% rename from js/instantsearch.js/dist-es5-module/src/widgets/infinite-hits/defaultTemplates.js rename to js/instantsearch.js/cjs/widgets/hits/defaultTemplates.js index 3244efc7..c9ba195c 100644 --- a/js/instantsearch.js/dist-es5-module/src/widgets/infinite-hits/defaultTemplates.js +++ b/js/instantsearch.js/cjs/widgets/hits/defaultTemplates.js @@ -1,11 +1,14 @@ -'use strict'; +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = { +exports.default = void 0; +var defaultTemplates = { empty: 'No results', item: function item(data) { return JSON.stringify(data, null, 2); } -}; \ No newline at end of file +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/hits/hits.js b/js/instantsearch.js/cjs/widgets/hits/hits.js new file mode 100644 index 00000000..d4fadab3 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/hits/hits.js @@ -0,0 +1,118 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _connectHits = _interopRequireDefault(require("../../connectors/hits/connectHits")); + +var _Hits = _interopRequireDefault(require("../../components/Hits/Hits")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _insights = require("../../lib/insights"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'hits' +}); +var suit = (0, _suit.component)('Hits'); +var HitsWithInsightsListener = (0, _insights.withInsightsListener)(_Hits.default); + +var renderer = function renderer(_ref) { + var renderState = _ref.renderState, + cssClasses = _ref.cssClasses, + containerNode = _ref.containerNode, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var receivedHits = _ref2.hits, + results = _ref2.results, + instantSearchInstance = _ref2.instantSearchInstance, + insights = _ref2.insights, + bindEvent = _ref2.bindEvent; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(HitsWithInsightsListener, { + cssClasses: cssClasses, + hits: receivedHits, + results: results, + templateProps: renderState.templateProps, + insights: insights, + sendEvent: function sendEvent(event) { + instantSearchInstance.sendEventToInsights(event); + }, + bindEvent: bindEvent + }), containerNode); + }; +}; + +var hits = function hits(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + escapeHTML = _ref3.escapeHTML, + transformItems = _ref3.transformItems, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + emptyRoot: (0, _classnames.default)(suit({ + modifierName: 'empty' + }), userCssClasses.emptyRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _insights.withInsights)(_connectHits.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + escapeHTML: escapeHTML, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.hits' + }); +}; + +var _default = hits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/index.js b/js/instantsearch.js/cjs/widgets/index.js new file mode 100644 index 00000000..75ec6ad4 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/index.js @@ -0,0 +1,271 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "analytics", { + enumerable: true, + get: function get() { + return _analytics.default; + } +}); +Object.defineProperty(exports, "breadcrumb", { + enumerable: true, + get: function get() { + return _breadcrumb.default; + } +}); +Object.defineProperty(exports, "clearRefinements", { + enumerable: true, + get: function get() { + return _clearRefinements.default; + } +}); +Object.defineProperty(exports, "configure", { + enumerable: true, + get: function get() { + return _configure.default; + } +}); +Object.defineProperty(exports, "currentRefinements", { + enumerable: true, + get: function get() { + return _currentRefinements.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_answers", { + enumerable: true, + get: function get() { + return _answers.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_configureRelatedItems", { + enumerable: true, + get: function get() { + return _configureRelatedItems.default; + } +}); +Object.defineProperty(exports, "EXPERIMENTAL_dynamicWidgets", { + enumerable: true, + get: function get() { + return _dynamicWidgets.default; + } +}); +Object.defineProperty(exports, "geoSearch", { + enumerable: true, + get: function get() { + return _geoSearch.default; + } +}); +Object.defineProperty(exports, "hierarchicalMenu", { + enumerable: true, + get: function get() { + return _hierarchicalMenu.default; + } +}); +Object.defineProperty(exports, "hits", { + enumerable: true, + get: function get() { + return _hits.default; + } +}); +Object.defineProperty(exports, "hitsPerPage", { + enumerable: true, + get: function get() { + return _hitsPerPage.default; + } +}); +Object.defineProperty(exports, "index", { + enumerable: true, + get: function get() { + return _index.default; + } +}); +Object.defineProperty(exports, "infiniteHits", { + enumerable: true, + get: function get() { + return _infiniteHits.default; + } +}); +Object.defineProperty(exports, "menu", { + enumerable: true, + get: function get() { + return _menu.default; + } +}); +Object.defineProperty(exports, "menuSelect", { + enumerable: true, + get: function get() { + return _menuSelect.default; + } +}); +Object.defineProperty(exports, "numericMenu", { + enumerable: true, + get: function get() { + return _numericMenu.default; + } +}); +Object.defineProperty(exports, "pagination", { + enumerable: true, + get: function get() { + return _pagination.default; + } +}); +Object.defineProperty(exports, "panel", { + enumerable: true, + get: function get() { + return _panel.default; + } +}); +Object.defineProperty(exports, "places", { + enumerable: true, + get: function get() { + return _places.default; + } +}); +Object.defineProperty(exports, "poweredBy", { + enumerable: true, + get: function get() { + return _poweredBy.default; + } +}); +Object.defineProperty(exports, "queryRuleContext", { + enumerable: true, + get: function get() { + return _queryRuleContext.default; + } +}); +Object.defineProperty(exports, "queryRuleCustomData", { + enumerable: true, + get: function get() { + return _queryRuleCustomData.default; + } +}); +Object.defineProperty(exports, "rangeInput", { + enumerable: true, + get: function get() { + return _rangeInput.default; + } +}); +Object.defineProperty(exports, "rangeSlider", { + enumerable: true, + get: function get() { + return _rangeSlider.default; + } +}); +Object.defineProperty(exports, "ratingMenu", { + enumerable: true, + get: function get() { + return _ratingMenu.default; + } +}); +Object.defineProperty(exports, "refinementList", { + enumerable: true, + get: function get() { + return _refinementList.default; + } +}); +Object.defineProperty(exports, "relevantSort", { + enumerable: true, + get: function get() { + return _relevantSort.default; + } +}); +Object.defineProperty(exports, "searchBox", { + enumerable: true, + get: function get() { + return _searchBox.default; + } +}); +Object.defineProperty(exports, "sortBy", { + enumerable: true, + get: function get() { + return _sortBy.default; + } +}); +Object.defineProperty(exports, "stats", { + enumerable: true, + get: function get() { + return _stats.default; + } +}); +Object.defineProperty(exports, "toggleRefinement", { + enumerable: true, + get: function get() { + return _toggleRefinement.default; + } +}); +Object.defineProperty(exports, "voiceSearch", { + enumerable: true, + get: function get() { + return _voiceSearch.default; + } +}); + +var _analytics = _interopRequireDefault(require("./analytics/analytics")); + +var _breadcrumb = _interopRequireDefault(require("./breadcrumb/breadcrumb")); + +var _clearRefinements = _interopRequireDefault(require("./clear-refinements/clear-refinements")); + +var _configure = _interopRequireDefault(require("./configure/configure")); + +var _currentRefinements = _interopRequireDefault(require("./current-refinements/current-refinements")); + +var _answers = _interopRequireDefault(require("./answers/answers")); + +var _configureRelatedItems = _interopRequireDefault(require("./configure-related-items/configure-related-items")); + +var _dynamicWidgets = _interopRequireDefault(require("./dynamic-widgets/dynamic-widgets")); + +var _geoSearch = _interopRequireDefault(require("./geo-search/geo-search")); + +var _hierarchicalMenu = _interopRequireDefault(require("./hierarchical-menu/hierarchical-menu")); + +var _hits = _interopRequireDefault(require("./hits/hits")); + +var _hitsPerPage = _interopRequireDefault(require("./hits-per-page/hits-per-page")); + +var _index = _interopRequireDefault(require("./index/index")); + +var _infiniteHits = _interopRequireDefault(require("./infinite-hits/infinite-hits")); + +var _menu = _interopRequireDefault(require("./menu/menu")); + +var _menuSelect = _interopRequireDefault(require("./menu-select/menu-select")); + +var _numericMenu = _interopRequireDefault(require("./numeric-menu/numeric-menu")); + +var _pagination = _interopRequireDefault(require("./pagination/pagination")); + +var _panel = _interopRequireDefault(require("./panel/panel")); + +var _places = _interopRequireDefault(require("./places/places")); + +var _poweredBy = _interopRequireDefault(require("./powered-by/powered-by")); + +var _queryRuleContext = _interopRequireDefault(require("./query-rule-context/query-rule-context")); + +var _queryRuleCustomData = _interopRequireDefault(require("./query-rule-custom-data/query-rule-custom-data")); + +var _rangeInput = _interopRequireDefault(require("./range-input/range-input")); + +var _rangeSlider = _interopRequireDefault(require("./range-slider/range-slider")); + +var _ratingMenu = _interopRequireDefault(require("./rating-menu/rating-menu")); + +var _refinementList = _interopRequireDefault(require("./refinement-list/refinement-list")); + +var _relevantSort = _interopRequireDefault(require("./relevant-sort/relevant-sort")); + +var _searchBox = _interopRequireDefault(require("./search-box/search-box")); + +var _sortBy = _interopRequireDefault(require("./sort-by/sort-by")); + +var _stats = _interopRequireDefault(require("./stats/stats")); + +var _toggleRefinement = _interopRequireDefault(require("./toggle-refinement/toggle-refinement")); + +var _voiceSearch = _interopRequireDefault(require("./voice-search/voice-search")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/index/index.js b/js/instantsearch.js/cjs/widgets/index/index.js new file mode 100644 index 00000000..242404e4 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/index/index.js @@ -0,0 +1,572 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isIndexWidget = isIndexWidget; +exports.default = void 0; + +var _algoliasearchHelper = _interopRequireDefault(require("algoliasearch-helper")); + +var _utils = require("../../lib/utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +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."); } + +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); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'index-widget' +}); + +function isIndexWidget(widget) { + return widget.$$type === 'ais.index'; +} +/** + * This is the same content as helper._change / setState, but allowing for extra + * UiState to be synchronized. + * see: https://github.com/algolia/algoliasearch-helper-js/blob/6b835ffd07742f2d6b314022cce6848f5cfecd4a/src/algoliasearch.helper.js#L1311-L1324 + */ + + +function privateHelperSetState(helper, _ref) { + var state = _ref.state, + isPageReset = _ref.isPageReset, + _uiState = _ref._uiState; + + if (state !== helper.state) { + helper.state = state; + helper.emit('change', { + state: helper.state, + results: helper.lastResults, + isPageReset: isPageReset, + _uiState: _uiState + }); + } +} + +function getLocalWidgetsUiState(widgets, widgetStateOptions) { + var initialUiState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + return widgets.reduce(function (uiState, widget) { + if (isIndexWidget(widget)) { + return uiState; + } + + if (!widget.getWidgetUiState && !widget.getWidgetState) { + return uiState; + } + + if (widget.getWidgetUiState) { + return widget.getWidgetUiState(uiState, widgetStateOptions); + } + + return widget.getWidgetState(uiState, widgetStateOptions); + }, initialUiState); +} + +function getLocalWidgetsSearchParameters(widgets, widgetSearchParametersOptions) { + var initialSearchParameters = widgetSearchParametersOptions.initialSearchParameters, + rest = _objectWithoutProperties(widgetSearchParametersOptions, ["initialSearchParameters"]); + + return widgets.filter(function (widget) { + return !isIndexWidget(widget); + }).reduce(function (state, widget) { + if (!widget.getWidgetSearchParameters) { + return state; + } + + return widget.getWidgetSearchParameters(state, rest); + }, initialSearchParameters); +} + +function resetPageFromWidgets(widgets) { + var indexWidgets = widgets.filter(isIndexWidget); + + if (indexWidgets.length === 0) { + return; + } + + indexWidgets.forEach(function (widget) { + var widgetHelper = widget.getHelper(); + privateHelperSetState(widgetHelper, { + state: widgetHelper.state.resetPage(), + isPageReset: true + }); + resetPageFromWidgets(widget.getWidgets()); + }); +} + +function resolveScopedResultsFromWidgets(widgets) { + var indexWidgets = widgets.filter(isIndexWidget); + return indexWidgets.reduce(function (scopedResults, current) { + return scopedResults.concat.apply(scopedResults, [{ + indexId: current.getIndexId(), + results: current.getResults(), + helper: current.getHelper() + }].concat(_toConsumableArray(resolveScopedResultsFromWidgets(current.getWidgets())))); + }, []); +} + +var index = function index(widgetParams) { + if (widgetParams === undefined || widgetParams.indexName === undefined) { + throw new Error(withUsage('The `indexName` option is required.')); + } + + var indexName = widgetParams.indexName, + _widgetParams$indexId = widgetParams.indexId, + indexId = _widgetParams$indexId === void 0 ? indexName : _widgetParams$indexId; + var localWidgets = []; + var localUiState = {}; + var localInstantSearchInstance = null; + var localParent = null; + var helper = null; + var derivedHelper = null; + return { + $$type: 'ais.index', + $$widgetType: 'ais.index', + getIndexName: function getIndexName() { + return indexName; + }, + getIndexId: function getIndexId() { + return indexId; + }, + getHelper: function getHelper() { + return helper; + }, + getResults: function getResults() { + return derivedHelper && derivedHelper.lastResults; + }, + getScopedResults: function getScopedResults() { + var widgetParent = this.getParent(); // If the widget is the root, we consider itself as the only sibling. + + var widgetSiblings = widgetParent ? widgetParent.getWidgets() : [this]; + return resolveScopedResultsFromWidgets(widgetSiblings); + }, + getParent: function getParent() { + return localParent; + }, + createURL: function createURL(nextState) { + return localInstantSearchInstance._createURL(_defineProperty({}, indexId, getLocalWidgetsUiState(localWidgets, { + searchParameters: nextState, + helper: helper + }))); + }, + getWidgets: function getWidgets() { + return localWidgets; + }, + addWidgets: function addWidgets(widgets) { + var _this = this; + + if (!Array.isArray(widgets)) { + throw new Error(withUsage('The `addWidgets` method expects an array of widgets.')); + } + + if (widgets.some(function (widget) { + return typeof widget.init !== 'function' && typeof widget.render !== 'function'; + })) { + throw new Error(withUsage('The widget definition expects a `render` and/or an `init` method.')); + } + + localWidgets = localWidgets.concat(widgets); + + if (localInstantSearchInstance && Boolean(widgets.length)) { + privateHelperSetState(helper, { + state: getLocalWidgetsSearchParameters(localWidgets, { + uiState: localUiState, + initialSearchParameters: helper.state + }), + _uiState: localUiState + }); // We compute the render state before calling `init` in a separate loop + // to construct the whole render state object that is then passed to + // `init`. + + widgets.forEach(function (widget) { + if (widget.getRenderState) { + var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, { + uiState: localInstantSearchInstance._initialUiState, + helper: _this.getHelper(), + parent: _this, + instantSearchInstance: localInstantSearchInstance, + state: helper.state, + renderState: localInstantSearchInstance.renderState, + templatesConfig: localInstantSearchInstance.templatesConfig, + createURL: _this.createURL, + scopedResults: [], + searchMetadata: { + isSearchStalled: localInstantSearchInstance._isSearchStalled + } + }); + storeRenderState({ + renderState: renderState, + instantSearchInstance: localInstantSearchInstance, + parent: _this + }); + } + }); + widgets.forEach(function (widget) { + if (widget.init) { + widget.init({ + helper: helper, + parent: _this, + uiState: localInstantSearchInstance._initialUiState, + instantSearchInstance: localInstantSearchInstance, + state: helper.state, + renderState: localInstantSearchInstance.renderState, + templatesConfig: localInstantSearchInstance.templatesConfig, + createURL: _this.createURL, + scopedResults: [], + searchMetadata: { + isSearchStalled: localInstantSearchInstance._isSearchStalled + } + }); + } + }); + localInstantSearchInstance.scheduleSearch(); + } + + return this; + }, + removeWidgets: function removeWidgets(widgets) { + var _this2 = this; + + if (!Array.isArray(widgets)) { + throw new Error(withUsage('The `removeWidgets` method expects an array of widgets.')); + } + + if (widgets.some(function (widget) { + return typeof widget.dispose !== 'function'; + })) { + throw new Error(withUsage('The widget definition expects a `dispose` method.')); + } + + localWidgets = localWidgets.filter(function (widget) { + return widgets.indexOf(widget) === -1; + }); + + if (localInstantSearchInstance && Boolean(widgets.length)) { + var nextState = widgets.reduce(function (state, widget) { + // the `dispose` method exists at this point we already assert it + var next = widget.dispose({ + helper: helper, + state: state, + parent: _this2 + }); + return next || state; + }, helper.state); + localUiState = getLocalWidgetsUiState(localWidgets, { + searchParameters: nextState, + helper: helper + }); + helper.setState(getLocalWidgetsSearchParameters(localWidgets, { + uiState: localUiState, + initialSearchParameters: nextState + })); + + if (localWidgets.length) { + localInstantSearchInstance.scheduleSearch(); + } + } + + return this; + }, + init: function init(_ref2) { + var _this3 = this; + + var instantSearchInstance = _ref2.instantSearchInstance, + parent = _ref2.parent, + uiState = _ref2.uiState; + + if (helper !== null) { + // helper is already initialized, therefore we do not need to set up + // any listeners + return; + } + + localInstantSearchInstance = instantSearchInstance; + localParent = parent; + localUiState = uiState[indexId] || {}; // The `mainHelper` is already defined at this point. The instance is created + // inside InstantSearch at the `start` method, which occurs before the `init` + // step. + + var mainHelper = instantSearchInstance.mainHelper; + var parameters = getLocalWidgetsSearchParameters(localWidgets, { + uiState: localUiState, + initialSearchParameters: new _algoliasearchHelper.default.SearchParameters({ + index: indexName + }) + }); // This Helper is only used for state management we do not care about the + // `searchClient`. Only the "main" Helper created at the `InstantSearch` + // level is aware of the client. + + helper = (0, _algoliasearchHelper.default)({}, parameters.index, parameters); // We forward the call to `search` to the "main" instance of the Helper + // which is responsible for managing the queries (it's the only one that is + // aware of the `searchClient`). + + helper.search = function () { + if (instantSearchInstance.onStateChange) { + instantSearchInstance.onStateChange({ + uiState: instantSearchInstance.mainIndex.getWidgetUiState({}), + setUiState: instantSearchInstance.setUiState.bind(instantSearchInstance) + }); // We don't trigger a search when controlled because it becomes the + // responsibility of `setUiState`. + + return mainHelper; + } + + return mainHelper.search(); + }; + + helper.searchWithoutTriggeringOnStateChange = function () { + return mainHelper.search(); + }; // We use the same pattern for the `searchForFacetValues`. + + + helper.searchForFacetValues = function (facetName, facetValue, maxFacetHits, userState) { + var state = helper.state.setQueryParameters(userState); + return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state); + }; + + derivedHelper = mainHelper.derive(function () { + return _utils.mergeSearchParameters.apply(void 0, _toConsumableArray((0, _utils.resolveSearchParameters)(_this3))); + }); // Subscribe to the Helper state changes for the page before widgets + // are initialized. This behavior mimics the original one of the Helper. + // It makes sense to replicate it at the `init` step. We have another + // listener on `change` below, once `init` is done. + + helper.on('change', function (_ref3) { + var isPageReset = _ref3.isPageReset; + + if (isPageReset) { + resetPageFromWidgets(localWidgets); + } + }); + derivedHelper.on('search', function () { + // The index does not manage the "staleness" of the search. This is the + // responsibility of the main instance. It does not make sense to manage + // it at the index level because it's either: all of them or none of them + // that are stalled. The queries are performed into a single network request. + instantSearchInstance.scheduleStalledRender(); + + if (process.env.NODE_ENV === 'development') { + (0, _utils.checkIndexUiState)({ + index: _this3, + indexUiState: localUiState + }); + } + }); + derivedHelper.on('result', function (_ref4) { + var results = _ref4.results; + // The index does not render the results it schedules a new render + // to let all the other indices emit their own results. It allows us to + // run the render process in one pass. + instantSearchInstance.scheduleRender(); // the derived helper is the one which actually searches, but the helper + // which is exposed e.g. via instance.helper, doesn't search, and thus + // does not have access to lastResults, which it used to in pre-federated + // search behavior. + + helper.lastResults = results; + }); // We compute the render state before calling `init` in a separate loop + // to construct the whole render state object that is then passed to + // `init`. + + localWidgets.forEach(function (widget) { + if (widget.getRenderState) { + var renderState = widget.getRenderState(instantSearchInstance.renderState[_this3.getIndexId()] || {}, { + uiState: uiState, + helper: helper, + parent: _this3, + instantSearchInstance: instantSearchInstance, + state: helper.state, + renderState: instantSearchInstance.renderState, + templatesConfig: instantSearchInstance.templatesConfig, + createURL: _this3.createURL, + scopedResults: [], + searchMetadata: { + isSearchStalled: instantSearchInstance._isSearchStalled + } + }); + storeRenderState({ + renderState: renderState, + instantSearchInstance: instantSearchInstance, + parent: _this3 + }); + } + }); + localWidgets.forEach(function (widget) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)( // if it has NO getWidgetState or if it has getWidgetUiState, we don't warn + // aka we warn if there's _only_ getWidgetState + !widget.getWidgetState || Boolean(widget.getWidgetUiState), 'The `getWidgetState` method is renamed `getWidgetUiState` and will no longer exist under that name in InstantSearch.js 5.x. Please use `getWidgetUiState` instead.') : void 0; + + if (widget.init) { + widget.init({ + uiState: uiState, + helper: helper, + parent: _this3, + instantSearchInstance: instantSearchInstance, + state: helper.state, + renderState: instantSearchInstance.renderState, + templatesConfig: instantSearchInstance.templatesConfig, + createURL: _this3.createURL, + scopedResults: [], + searchMetadata: { + isSearchStalled: instantSearchInstance._isSearchStalled + } + }); + } + }); // Subscribe to the Helper state changes for the `uiState` once widgets + // are initialized. Until the first render, state changes are part of the + // configuration step. This is mainly for backward compatibility with custom + // widgets. When the subscription happens before the `init` step, the (static) + // configuration of the widget is pushed in the URL. That's what we want to avoid. + // https://github.com/algolia/instantsearch.js/pull/994/commits/4a672ae3fd78809e213de0368549ef12e9dc9454 + + helper.on('change', function (event) { + var state = event.state; + var _uiState = event._uiState; + localUiState = getLocalWidgetsUiState(localWidgets, { + searchParameters: state, + helper: helper + }, _uiState || {}); // We don't trigger an internal change when controlled because it + // becomes the responsibility of `setUiState`. + + if (!instantSearchInstance.onStateChange) { + instantSearchInstance.onInternalStateChange(); + } + }); + }, + render: function render(_ref5) { + var _this4 = this; + + var instantSearchInstance = _ref5.instantSearchInstance; + + if (!this.getResults()) { + return; + } + + localWidgets.forEach(function (widget) { + if (widget.getRenderState) { + var renderState = widget.getRenderState(instantSearchInstance.renderState[_this4.getIndexId()] || {}, { + helper: _this4.getHelper(), + parent: _this4, + instantSearchInstance: instantSearchInstance, + results: _this4.getResults(), + scopedResults: _this4.getScopedResults(), + state: _this4.getResults()._state, + renderState: instantSearchInstance.renderState, + templatesConfig: instantSearchInstance.templatesConfig, + createURL: _this4.createURL, + searchMetadata: { + isSearchStalled: instantSearchInstance._isSearchStalled + } + }); + storeRenderState({ + renderState: renderState, + instantSearchInstance: instantSearchInstance, + parent: _this4 + }); + } + }); + localWidgets.forEach(function (widget) { + // At this point, all the variables used below are set. Both `helper` + // and `derivedHelper` have been created at the `init` step. The attribute + // `lastResults` might be `null` though. It's possible that a stalled render + // happens before the result e.g with a dynamically added index the request might + // be delayed. The render is triggered for the complete tree but some parts do + // not have results yet. + if (widget.render) { + widget.render({ + helper: helper, + parent: _this4, + instantSearchInstance: instantSearchInstance, + results: _this4.getResults(), + scopedResults: _this4.getScopedResults(), + state: _this4.getResults()._state, + renderState: instantSearchInstance.renderState, + templatesConfig: instantSearchInstance.templatesConfig, + createURL: _this4.createURL, + searchMetadata: { + isSearchStalled: instantSearchInstance._isSearchStalled + } + }); + } + }); + }, + dispose: function dispose() { + var _this5 = this; + + localWidgets.forEach(function (widget) { + if (widget.dispose) { + // The dispose function is always called once the instance is started + // (it's an effect of `removeWidgets`). The index is initialized and + // the Helper is available. We don't care about the return value of + // `dispose` because the index is removed. We can't call `removeWidgets` + // because we want to keep the widgets on the instance, to allow idempotent + // operations on `add` & `remove`. + widget.dispose({ + helper: helper, + state: helper.state, + parent: _this5 + }); + } + }); + localInstantSearchInstance = null; + localParent = null; + helper.removeAllListeners(); + helper = null; + derivedHelper.detach(); + derivedHelper = null; + }, + getWidgetUiState: function getWidgetUiState(uiState) { + return localWidgets.filter(isIndexWidget).reduce(function (previousUiState, innerIndex) { + return innerIndex.getWidgetUiState(previousUiState); + }, _objectSpread(_objectSpread({}, uiState), {}, _defineProperty({}, this.getIndexId(), localUiState))); + }, + getWidgetState: function getWidgetState(uiState) { + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, 'The `getWidgetState` method is renamed `getWidgetUiState` and will no longer exist under that name in InstantSearch.js 5.x. Please use `getWidgetUiState` instead.') : void 0; + return this.getWidgetUiState(uiState); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) { + var uiState = _ref6.uiState; + return getLocalWidgetsSearchParameters(localWidgets, { + uiState: uiState, + initialSearchParameters: searchParameters + }); + }, + refreshUiState: function refreshUiState() { + localUiState = getLocalWidgetsUiState(localWidgets, { + searchParameters: this.getHelper().state, + helper: this.getHelper() + }); + } + }; +}; + +var _default = index; +exports.default = _default; + +function storeRenderState(_ref7) { + var renderState = _ref7.renderState, + instantSearchInstance = _ref7.instantSearchInstance, + parent = _ref7.parent; + var parentIndexName = parent ? parent.getIndexId() : instantSearchInstance.mainIndex.getIndexId(); + instantSearchInstance.renderState = _objectSpread(_objectSpread({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread(_objectSpread({}, instantSearchInstance.renderState[parentIndexName]), renderState))); +} \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/infinite-hits/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/infinite-hits/defaultTemplates.js new file mode 100644 index 00000000..e62d14ef --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/infinite-hits/defaultTemplates.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + empty: 'No results', + showPreviousText: 'Show previous results', + showMoreText: 'Show more results', + item: function item(data) { + return JSON.stringify(data, null, 2); + } +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/infinite-hits/infinite-hits.js b/js/instantsearch.js/cjs/widgets/infinite-hits/infinite-hits.js new file mode 100644 index 00000000..06214182 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/infinite-hits/infinite-hits.js @@ -0,0 +1,147 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _InfiniteHits = _interopRequireDefault(require("../../components/InfiniteHits/InfiniteHits")); + +var _connectInfiniteHits = _interopRequireDefault(require("../../connectors/infinite-hits/connectInfiniteHits")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _insights = require("../../lib/insights"); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'infinite-hits' +}); +var suit = (0, _suit.component)('InfiniteHits'); +var InfiniteHitsWithInsightsListener = (0, _insights.withInsightsListener)(_InfiniteHits.default); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates, + hasShowPrevious = _ref.showPrevious; + return function (_ref2, isFirstRendering) { + var hits = _ref2.hits, + results = _ref2.results, + showMore = _ref2.showMore, + showPrevious = _ref2.showPrevious, + isFirstPage = _ref2.isFirstPage, + isLastPage = _ref2.isLastPage, + instantSearchInstance = _ref2.instantSearchInstance, + insights = _ref2.insights, + bindEvent = _ref2.bindEvent; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(InfiniteHitsWithInsightsListener, { + cssClasses: cssClasses, + hits: hits, + results: results, + hasShowPrevious: hasShowPrevious, + showPrevious: showPrevious, + showMore: showMore, + templateProps: renderState.templateProps, + isFirstPage: isFirstPage, + isLastPage: isLastPage, + insights: insights, + sendEvent: function sendEvent(event) { + instantSearchInstance.sendEventToInsights(event); + }, + bindEvent: bindEvent + }), containerNode); + }; +}; + +var infiniteHits = function infiniteHits(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + escapeHTML = _ref3.escapeHTML, + transformItems = _ref3.transformItems, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + showPrevious = _ref3.showPrevious, + cache = _ref3.cache; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + emptyRoot: (0, _classnames.default)(suit({ + modifierName: 'empty' + }), userCssClasses.emptyRoot), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + loadPrevious: (0, _classnames.default)(suit({ + descendantName: 'loadPrevious' + }), userCssClasses.loadPrevious), + disabledLoadPrevious: (0, _classnames.default)(suit({ + descendantName: 'loadPrevious', + modifierName: 'disabled' + }), userCssClasses.disabledLoadPrevious), + loadMore: (0, _classnames.default)(suit({ + descendantName: 'loadMore' + }), userCssClasses.loadMore), + disabledLoadMore: (0, _classnames.default)(suit({ + descendantName: 'loadMore', + modifierName: 'disabled' + }), userCssClasses.disabledLoadMore) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + showPrevious: showPrevious, + renderState: {} + }); + var makeWidget = (0, _insights.withInsights)(_connectInfiniteHits.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + escapeHTML: escapeHTML, + transformItems: transformItems, + showPrevious: showPrevious, + cache: cache + })), {}, { + $$widgetType: 'ais.infiniteHits' + }); +}; + +var _default = infiniteHits; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/menu-select/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/menu-select/defaultTemplates.js new file mode 100644 index 00000000..31f77794 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/menu-select/defaultTemplates.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: '{{label}} ({{#helpers.formatNumber}}{{count}}{{/helpers.formatNumber}})', + defaultOption: 'See all' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/menu-select/menu-select.js b/js/instantsearch.js/cjs/widgets/menu-select/menu-select.js new file mode 100644 index 00000000..6ad51874 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/menu-select/menu-select.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _connectMenu = _interopRequireDefault(require("../../connectors/menu/connectMenu")); + +var _MenuSelect = _interopRequireDefault(require("../../components/MenuSelect/MenuSelect")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'menu-select' +}); +var suit = (0, _suit.component)('MenuSelect'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + items = _ref2.items, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_MenuSelect.default, { + cssClasses: cssClasses, + items: items, + refine: refine, + templateProps: renderState.templateProps + }), containerNode); + }; +}; + +var menuSelect = function menuSelect(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + _ref3$sortBy = _ref3.sortBy, + sortBy = _ref3$sortBy === void 0 ? ['name:asc'] : _ref3$sortBy, + _ref3$limit = _ref3.limit, + limit = _ref3$limit === void 0 ? 10 : _ref3$limit, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + select: (0, _classnames.default)(suit({ + descendantName: 'select' + }), userCssClasses.select), + option: (0, _classnames.default)(suit({ + descendantName: 'option' + }), userCssClasses.option) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectMenu.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + limit: limit, + sortBy: sortBy, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.menuSelect' + }); +}; + +var _default = menuSelect; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/menu/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/menu/defaultTemplates.js new file mode 100644 index 00000000..69d663eb --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/menu/defaultTemplates.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: '' + '{{label}}' + '{{#helpers.formatNumber}}{{count}}{{/helpers.formatNumber}}' + '', + showMoreText: "\n {{#isShowingMore}}\n Show less\n {{/isShowingMore}}\n {{^isShowingMore}}\n Show more\n {{/isShowingMore}}\n " +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/menu/menu.js b/js/instantsearch.js/cjs/widgets/menu/menu.js new file mode 100644 index 00000000..84c912fb --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/menu/menu.js @@ -0,0 +1,152 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RefinementList = _interopRequireDefault(require("../../components/RefinementList/RefinementList")); + +var _connectMenu = _interopRequireDefault(require("../../connectors/menu/connectMenu")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'menu' +}); +var suit = (0, _suit.component)('Menu'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates, + showMore = _ref.showMore; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + items = _ref2.items, + createURL = _ref2.createURL, + instantSearchInstance = _ref2.instantSearchInstance, + isShowingMore = _ref2.isShowingMore, + toggleShowMore = _ref2.toggleShowMore, + canToggleShowMore = _ref2.canToggleShowMore; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + var facetValues = items.map(function (facetValue) { + return _objectSpread(_objectSpread({}, facetValue), {}, { + url: createURL(facetValue.value) + }); + }); + (0, _preact.render)((0, _preact.h)(_RefinementList.default, { + createURL: createURL, + cssClasses: cssClasses, + facetValues: facetValues, + showMore: showMore, + templateProps: renderState.templateProps, + toggleRefinement: refine, + toggleShowMore: toggleShowMore, + isShowingMore: isShowingMore, + canToggleShowMore: canToggleShowMore + }), containerNode); + }; +}; + +var menu = function menu(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + sortBy = _ref3.sortBy, + limit = _ref3.limit, + showMore = _ref3.showMore, + showMoreLimit = _ref3.showMoreLimit, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + count: (0, _classnames.default)(suit({ + descendantName: 'count' + }), userCssClasses.count), + showMore: (0, _classnames.default)(suit({ + descendantName: 'showMore' + }), userCssClasses.showMore), + disabledShowMore: (0, _classnames.default)(suit({ + descendantName: 'showMore', + modifierName: 'disabled' + }), userCssClasses.disabledShowMore) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates, + showMore: showMore + }); + var makeWidget = (0, _connectMenu.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + limit: limit, + showMore: showMore, + showMoreLimit: showMoreLimit, + sortBy: sortBy, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.menu' + }); +}; + +var _default = menu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/numeric-menu/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/numeric-menu/defaultTemplates.js new file mode 100644 index 00000000..99019cb7 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/numeric-menu/defaultTemplates.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: "" +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/numeric-menu/numeric-menu.js b/js/instantsearch.js/cjs/widgets/numeric-menu/numeric-menu.js new file mode 100644 index 00000000..978dfd91 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/numeric-menu/numeric-menu.js @@ -0,0 +1,128 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RefinementList = _interopRequireDefault(require("../../components/RefinementList/RefinementList")); + +var _connectNumericMenu = _interopRequireDefault(require("../../connectors/numeric-menu/connectNumericMenu")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'numeric-menu' +}); +var suit = (0, _suit.component)('NumericMenu'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + attribute = _ref.attribute, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var createURL = _ref2.createURL, + instantSearchInstance = _ref2.instantSearchInstance, + refine = _ref2.refine, + items = _ref2.items; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_RefinementList.default, { + createURL: createURL, + cssClasses: cssClasses, + facetValues: items, + templateProps: renderState.templateProps, + toggleRefinement: refine, + attribute: attribute + }), containerNode); + }; +}; + +var numericMenu = function numericMenu(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + items = _ref3.items, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + radio: (0, _classnames.default)(suit({ + descendantName: 'radio' + }), userCssClasses.radio), + labelText: (0, _classnames.default)(suit({ + descendantName: 'labelText' + }), userCssClasses.labelText) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + attribute: attribute, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectNumericMenu.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + items: items, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.numericMenu' + }); +}; + +var _default = numericMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/pagination/pagination.js b/js/instantsearch.js/cjs/widgets/pagination/pagination.js new file mode 100644 index 00000000..6d52064f --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/pagination/pagination.js @@ -0,0 +1,179 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Pagination = _interopRequireDefault(require("../../components/Pagination/Pagination")); + +var _connectPagination = _interopRequireDefault(require("../../connectors/pagination/connectPagination")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var suit = (0, _suit.component)('Pagination'); +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'pagination' +}); +var defaultTemplates = { + previous: '‹', + next: '›', + first: '«', + last: '»' +}; + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates, + showFirst = _ref.showFirst, + showLast = _ref.showLast, + showPrevious = _ref.showPrevious, + showNext = _ref.showNext, + scrollToNode = _ref.scrollToNode; + return function (_ref2, isFirstRendering) { + var createURL = _ref2.createURL, + currentRefinement = _ref2.currentRefinement, + nbPages = _ref2.nbPages, + pages = _ref2.pages, + isFirstPage = _ref2.isFirstPage, + isLastPage = _ref2.isLastPage, + refine = _ref2.refine; + if (isFirstRendering) return; + + var setCurrentPage = function setCurrentPage(pageNumber) { + refine(pageNumber); + + if (scrollToNode !== false) { + scrollToNode.scrollIntoView(); + } + }; + + (0, _preact.render)((0, _preact.h)(_Pagination.default, { + createURL: createURL, + cssClasses: cssClasses, + currentPage: currentRefinement, + templates: templates, + nbPages: nbPages, + pages: pages, + isFirstPage: isFirstPage, + isLastPage: isLastPage, + setCurrentPage: setCurrentPage, + showFirst: showFirst, + showLast: showLast, + showPrevious: showPrevious, + showNext: showNext + }), containerNode); + }; +}; + +var pagination = function pagination(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$templates = _ref3.templates, + userTemplates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + totalPages = _ref3.totalPages, + padding = _ref3.padding, + _ref3$showFirst = _ref3.showFirst, + showFirst = _ref3$showFirst === void 0 ? true : _ref3$showFirst, + _ref3$showLast = _ref3.showLast, + showLast = _ref3$showLast === void 0 ? true : _ref3$showLast, + _ref3$showPrevious = _ref3.showPrevious, + showPrevious = _ref3$showPrevious === void 0 ? true : _ref3$showPrevious, + _ref3$showNext = _ref3.showNext, + showNext = _ref3$showNext === void 0 ? true : _ref3$showNext, + _ref3$scrollTo = _ref3.scrollTo, + userScrollTo = _ref3$scrollTo === void 0 ? 'body' : _ref3$scrollTo; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var scrollTo = userScrollTo === true ? 'body' : userScrollTo; + var scrollToNode = scrollTo !== false ? (0, _utils.getContainerNode)(scrollTo) : false; + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + firstPageItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'firstPage' + }), userCssClasses.firstPageItem), + lastPageItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'lastPage' + }), userCssClasses.lastPageItem), + previousPageItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'previousPage' + }), userCssClasses.previousPageItem), + nextPageItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'nextPage' + }), userCssClasses.nextPageItem), + pageItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'page' + }), userCssClasses.pageItem), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + disabledItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'disabled' + }), userCssClasses.disabledItem), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link) + }; + + var templates = _objectSpread(_objectSpread({}, defaultTemplates), userTemplates); + + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + showFirst: showFirst, + showLast: showLast, + showPrevious: showPrevious, + showNext: showNext, + scrollToNode: scrollToNode + }); + var makeWidget = (0, _connectPagination.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + totalPages: totalPages, + padding: padding + })), {}, { + $$widgetType: 'ais.pagination' + }); +}; + +var _default = pagination; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/panel/panel.js b/js/instantsearch.js/cjs/widgets/panel/panel.js new file mode 100644 index 00000000..e4f5e37d --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/panel/panel.js @@ -0,0 +1,181 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _Panel = _interopRequireDefault(require("../../components/Panel/Panel")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'panel' +}); +var suit = (0, _suit.component)('Panel'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + bodyContainerNode = _ref.bodyContainerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates; + return function (_ref2) { + var options = _ref2.options, + hidden = _ref2.hidden, + collapsible = _ref2.collapsible, + collapsed = _ref2.collapsed; + (0, _preact.render)((0, _preact.h)(_Panel.default, { + cssClasses: cssClasses, + hidden: hidden, + collapsible: collapsible, + isCollapsed: collapsed, + templates: templates, + data: options, + bodyElement: bodyContainerNode + }), containerNode); + }; +}; + +/** + * The panel widget wraps other widgets in a consistent panel design. + * It also reacts, indicates and sets CSS classes when widgets are no longer relevant for refining. + */ +var panel = function panel(panelWidgetParams) { + var _ref3 = panelWidgetParams || {}, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$hidden = _ref3.hidden, + hidden = _ref3$hidden === void 0 ? function () { + return false; + } : _ref3$hidden, + collapsed = _ref3.collapsed, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses; + + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(typeof hidden === 'function', "The `hidden` option in the \"panel\" widget expects a function returning a boolean (received type ".concat((0, _utils.getObjectType)(hidden), ").")) : void 0; + process.env.NODE_ENV === 'development' ? (0, _utils.warning)(typeof collapsed === 'undefined' || typeof collapsed === 'function', "The `collapsed` option in the \"panel\" widget expects a function returning a boolean (received type ".concat((0, _utils.getObjectType)(collapsed), ").")) : void 0; + var bodyContainerNode = document.createElement('div'); + var collapsible = Boolean(collapsed); + var collapsedFn = typeof collapsed === 'function' ? collapsed : function () { + return false; + }; + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + collapsibleRoot: (0, _classnames.default)(suit({ + modifierName: 'collapsible' + }), userCssClasses.collapsibleRoot), + collapsedRoot: (0, _classnames.default)(suit({ + modifierName: 'collapsed' + }), userCssClasses.collapsedRoot), + collapseButton: (0, _classnames.default)(suit({ + descendantName: 'collapseButton' + }), userCssClasses.collapseButton), + collapseIcon: (0, _classnames.default)(suit({ + descendantName: 'collapseIcon' + }), userCssClasses.collapseIcon), + body: (0, _classnames.default)(suit({ + descendantName: 'body' + }), userCssClasses.body), + header: (0, _classnames.default)(suit({ + descendantName: 'header' + }), userCssClasses.header), + footer: (0, _classnames.default)(suit({ + descendantName: 'footer' + }), userCssClasses.footer) + }; + return function (widgetFactory) { + return function (widgetParams) { + if (!(widgetParams && widgetParams.container)) { + throw new Error(withUsage("The `container` option is required in the widget within the panel.")); + } + + var containerNode = (0, _utils.getContainerNode)(widgetParams.container); + var defaultTemplates = { + header: '', + footer: '', + collapseButtonText: function collapseButtonText(_ref4) { + var isCollapsed = _ref4.collapsed; + return "\n \n "); + } + }; + var renderPanel = renderer({ + containerNode: containerNode, + bodyContainerNode: bodyContainerNode, + cssClasses: cssClasses, + templates: _objectSpread(_objectSpread({}, defaultTemplates), templates) + }); + renderPanel({ + options: {}, + hidden: true, + collapsible: collapsible, + collapsed: false + }); + var widget = widgetFactory(_objectSpread(_objectSpread({}, widgetParams), {}, { + container: bodyContainerNode + })); // TypeScript somehow loses track of the ...widget type, since it's + // not directly returned. Eventually the "as ReturnType" + // will not be needed anymore. + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + + return _objectSpread(_objectSpread({}, widget), {}, { + dispose: function dispose() { + (0, _preact.render)(null, containerNode); + + if (typeof widget.dispose === 'function') { + var _widget$dispose; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return (_widget$dispose = widget.dispose).call.apply(_widget$dispose, [this].concat(args)); + } + + return undefined; + }, + render: function render() { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var renderOptions = args[0]; + + var options = _objectSpread(_objectSpread({}, widget.getWidgetRenderState ? widget.getWidgetRenderState(renderOptions) : {}), renderOptions); + + renderPanel({ + options: options, + hidden: Boolean(hidden(options)), + collapsible: collapsible, + collapsed: Boolean(collapsedFn(options)) + }); + + if (typeof widget.render === 'function') { + var _widget$render; + + (_widget$render = widget.render).call.apply(_widget$render, [this].concat(args)); + } + } + }); + }; + }; +}; + +var _default = panel; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/places/places.js b/js/instantsearch.js/cjs/widgets/places/places.js new file mode 100644 index 00000000..cad19dc6 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/places/places.js @@ -0,0 +1,122 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +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; } + +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; } + +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; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/** @ts-ignore */ +// using the type like this requires only one ts-ignore + +/** + * This widget sets the geolocation value for the search based on the selected + * result in the Algolia Places autocomplete. + */ +var placesWidget = function placesWidget(widgetParams) { + var _ref = widgetParams || {}, + placesReference = _ref.placesReference, + _ref$defaultPosition = _ref.defaultPosition, + defaultPosition = _ref$defaultPosition === void 0 ? [] : _ref$defaultPosition, + placesOptions = _objectWithoutProperties(_ref, ["placesReference", "defaultPosition"]); + + if (typeof placesReference !== 'function') { + throw new Error('The `placesReference` option requires a valid Places.js reference.'); + } + + var placesAutocomplete = placesReference(placesOptions); + var state = { + query: '', + initialLatLngViaIP: undefined, + isInitialLatLngViaIPSet: false + }; + return { + $$type: 'ais.places', + $$widgetType: 'ais.places', + init: function init(_ref2) { + var helper = _ref2.helper; + placesAutocomplete.on('change', function (eventOptions) { + var _eventOptions$suggest = eventOptions.suggestion, + value = _eventOptions$suggest.value, + _eventOptions$suggest2 = _eventOptions$suggest.latlng, + lat = _eventOptions$suggest2.lat, + lng = _eventOptions$suggest2.lng; + state.query = value; + helper.setQueryParameter('insideBoundingBox', undefined).setQueryParameter('aroundLatLngViaIP', false).setQueryParameter('aroundLatLng', "".concat(lat, ",").concat(lng)).search(); + }); + placesAutocomplete.on('clear', function () { + state.query = ''; + helper.setQueryParameter('insideBoundingBox', undefined); + + if (defaultPosition.length > 1) { + helper.setQueryParameter('aroundLatLngViaIP', false).setQueryParameter('aroundLatLng', defaultPosition.join(',')); + } else { + helper.setQueryParameter('aroundLatLngViaIP', state.initialLatLngViaIP).setQueryParameter('aroundLatLng', undefined); + } + + helper.search(); + }); + }, + getWidgetUiState: function getWidgetUiState(uiState, _ref3) { + var searchParameters = _ref3.searchParameters; + var position = searchParameters.aroundLatLng || defaultPosition.join(','); + var hasPositionSet = position !== defaultPosition.join(','); + + if (!hasPositionSet && !state.query) { + var places = uiState.places, + uiStateWithoutPlaces = _objectWithoutProperties(uiState, ["places"]); + + return uiStateWithoutPlaces; + } + + return _objectSpread(_objectSpread({}, uiState), {}, { + places: { + query: state.query, + position: position + } + }); + }, + getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref4) { + var uiState = _ref4.uiState; + + var _ref5 = uiState.places || {}, + _ref5$query = _ref5.query, + query = _ref5$query === void 0 ? '' : _ref5$query, + _ref5$position = _ref5.position, + position = _ref5$position === void 0 ? defaultPosition.join(',') : _ref5$position; + + state.query = query; + + if (!state.isInitialLatLngViaIPSet) { + state.isInitialLatLngViaIPSet = true; + state.initialLatLngViaIP = searchParameters.aroundLatLngViaIP; + } + + placesAutocomplete.setVal(query); + placesAutocomplete.close(); + return searchParameters.setQueryParameter('insideBoundingBox', undefined).setQueryParameter('aroundLatLngViaIP', false).setQueryParameter('aroundLatLng', position || undefined); + }, + getRenderState: function getRenderState(renderState, renderOptions) { + return _objectSpread(_objectSpread({}, renderState), {}, { + places: this.getWidgetRenderState(renderOptions) + }); + }, + getWidgetRenderState: function getWidgetRenderState() { + return { + widgetParams: widgetParams + }; + } + }; +}; + +var _default = placesWidget; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/powered-by/powered-by.js b/js/instantsearch.js/cjs/widgets/powered-by/powered-by.js new file mode 100644 index 00000000..fa46309b --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/powered-by/powered-by.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _PoweredBy = _interopRequireDefault(require("../../components/PoweredBy/PoweredBy")); + +var _connectPoweredBy = _interopRequireDefault(require("../../connectors/powered-by/connectPoweredBy")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var suit = (0, _suit.component)('PoweredBy'); +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'powered-by' +}); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses; + return function (_ref2, isFirstRendering) { + var url = _ref2.url, + widgetParams = _ref2.widgetParams; + + if (isFirstRendering) { + var _widgetParams$theme = widgetParams.theme, + theme = _widgetParams$theme === void 0 ? 'light' : _widgetParams$theme; + (0, _preact.render)((0, _preact.h)(_PoweredBy.default, { + cssClasses: cssClasses, + url: url, + theme: theme + }), containerNode); + return; + } + }; +}; + +var poweredBy = function poweredBy(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$theme = _ref3.theme, + theme = _ref3$theme === void 0 ? 'light' : _ref3$theme; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), suit({ + modifierName: theme === 'dark' ? 'dark' : 'light' + }), userCssClasses.root), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link), + logo: (0, _classnames.default)(suit({ + descendantName: 'logo' + }), userCssClasses.logo) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses + }); + var makeWidget = (0, _connectPoweredBy.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + theme: theme + })), {}, { + $$widgetType: 'ais.poweredBy' + }); +}; + +var _default = poweredBy; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/query-rule-context/query-rule-context.js b/js/instantsearch.js/cjs/widgets/query-rule-context/query-rule-context.js new file mode 100644 index 00000000..bc4d22d4 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/query-rule-context/query-rule-context.js @@ -0,0 +1,37 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _utils = require("../../lib/utils"); + +var _connectQueryRules = _interopRequireDefault(require("../../connectors/query-rules/connectQueryRules")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'query-rule-context' +}); + +var queryRuleContext = function queryRuleContext() { + var widgetParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + if (!widgetParams.trackedFilters) { + throw new Error(withUsage('The `trackedFilters` option is required.')); + } + + return _objectSpread(_objectSpread({}, (0, _connectQueryRules.default)(_utils.noop)(widgetParams)), {}, { + $$widgetType: 'ais.queryRuleContext' + }); +}; + +var _default = queryRuleContext; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js b/js/instantsearch.js/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js new file mode 100644 index 00000000..09b35e05 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js @@ -0,0 +1,94 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.defaultTemplates = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _connectQueryRules = _interopRequireDefault(require("../../connectors/query-rules/connectQueryRules")); + +var _QueryRuleCustomData = _interopRequireDefault(require("../../components/QueryRuleCustomData/QueryRuleCustomData")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var defaultTemplates = { + default: function _default(_ref) { + var items = _ref.items; + return JSON.stringify(items, null, 2); + } +}; +exports.defaultTemplates = defaultTemplates; +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'query-rule-custom-data' +}); +var suit = (0, _suit.component)('QueryRuleCustomData'); + +var renderer = function renderer(_ref2) { + var containerNode = _ref2.containerNode, + cssClasses = _ref2.cssClasses, + templates = _ref2.templates; + return function (_ref3) { + var items = _ref3.items; + (0, _preact.render)((0, _preact.h)(_QueryRuleCustomData.default, { + cssClasses: cssClasses, + templates: templates, + items: items + }), containerNode); + }; +}; + +var queryRuleCustomData = function queryRuleCustomData(widgetParams) { + var _ref4 = widgetParams || {}, + container = _ref4.container, + _ref4$cssClasses = _ref4.cssClasses, + userCssClasses = _ref4$cssClasses === void 0 ? {} : _ref4$cssClasses, + _ref4$templates = _ref4.templates, + userTemplates = _ref4$templates === void 0 ? {} : _ref4$templates, + _ref4$transformItems = _ref4.transformItems, + transformItems = _ref4$transformItems === void 0 ? function (items) { + return items; + } : _ref4$transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root) + }; + var containerNode = (0, _utils.getContainerNode)(container); + + var templates = _objectSpread(_objectSpread({}, defaultTemplates), userTemplates); + + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectQueryRules.default)(specializedRenderer, function () { + (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.queryRuleCustomData' + }); +}; + +var _default2 = queryRuleCustomData; +exports.default = _default2; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/range-input/range-input.js b/js/instantsearch.js/cjs/widgets/range-input/range-input.js new file mode 100644 index 00000000..c36a6adf --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/range-input/range-input.js @@ -0,0 +1,162 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RangeInput = _interopRequireDefault(require("../../components/RangeInput/RangeInput")); + +var _connectRange = _interopRequireDefault(require("../../connectors/range/connectRange")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'range-input' +}); +var suit = (0, _suit.component)('RangeInput'); +var defaultTemplates = { + separatorText: 'to', + submitText: 'Go' +}; + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + range = _ref2.range, + start = _ref2.start, + widgetParams = _ref2.widgetParams, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: defaultTemplates, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + var rangeMin = range.min, + rangeMax = range.max; + + var _start = _slicedToArray(start, 2), + minValue = _start[0], + maxValue = _start[1]; + + var step = 1 / Math.pow(10, widgetParams.precision || 0); + var values = { + min: minValue !== -Infinity && minValue !== rangeMin ? minValue : undefined, + max: maxValue !== Infinity && maxValue !== rangeMax ? maxValue : undefined + }; + (0, _preact.render)((0, _preact.h)(_RangeInput.default, { + min: rangeMin, + max: rangeMax, + step: step, + values: values, + cssClasses: cssClasses, + refine: refine, + templateProps: renderState.templateProps + }), containerNode); + }; +}; + +var rangeInput = function rangeInput(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + min = _ref3.min, + max = _ref3.max, + _ref3$precision = _ref3.precision, + precision = _ref3$precision === void 0 ? 0 : _ref3$precision, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinement: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + })), + form: (0, _classnames.default)(suit({ + descendantName: 'form' + }), userCssClasses.form), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + input: (0, _classnames.default)(suit({ + descendantName: 'input' + }), userCssClasses.input), + inputMin: (0, _classnames.default)(suit({ + descendantName: 'input', + modifierName: 'min' + }), userCssClasses.inputMin), + inputMax: (0, _classnames.default)(suit({ + descendantName: 'input', + modifierName: 'max' + }), userCssClasses.inputMax), + separator: (0, _classnames.default)(suit({ + descendantName: 'separator' + }), userCssClasses.separator), + submit: (0, _classnames.default)(suit({ + descendantName: 'submit' + }), userCssClasses.submit) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + renderState: {} + }); + var makeWidget = (0, _connectRange.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + min: min, + max: max, + precision: precision + })), {}, { + $$type: 'ais.rangeInput', + $$widgetType: 'ais.rangeInput' + }); +}; + +var _default = rangeInput; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/range-slider/range-slider.js b/js/instantsearch.js/cjs/widgets/range-slider/range-slider.js new file mode 100644 index 00000000..0c98f7d1 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/range-slider/range-slider.js @@ -0,0 +1,147 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Slider = _interopRequireDefault(require("../../components/Slider/Slider")); + +var _connectRange = _interopRequireDefault(require("../../connectors/range/connectRange")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +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."); } + +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); } + +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; } + +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; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'range-slider' +}); +var suit = (0, _suit.component)('RangeSlider'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + pips = _ref.pips, + step = _ref.step, + tooltips = _ref.tooltips; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + range = _ref2.range, + start = _ref2.start; + + if (isFirstRendering) { + // There's no information at this point, let's render nothing. + return; + } + + var minRange = range.min, + maxRange = range.max; + + var _start = _slicedToArray(start, 2), + minStart = _start[0], + maxStart = _start[1]; + + var minFinite = minStart === -Infinity ? minRange : minStart; + var maxFinite = maxStart === Infinity ? maxRange : maxStart; // Clamp values to the range for avoid extra rendering & refinement + // Should probably be done on the connector side, but we need to stay + // backward compatible so we still need to pass [-Infinity, Infinity] + + var values = [minFinite > maxRange ? maxRange : minFinite, maxFinite < minRange ? minRange : maxFinite]; + (0, _preact.render)((0, _preact.h)(_Slider.default, { + cssClasses: cssClasses, + refine: refine, + min: minRange, + max: maxRange, + values: values, + tooltips: tooltips, + step: step, + pips: pips + }), containerNode); + }; +}; + +/** + * The range slider is a widget which provides a user-friendly way to filter the + * results based on a single numeric range. + * + * @requirements + * The attribute passed to `attribute` must be declared as an + * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) + * in your Algolia settings. + * + * The values inside this attribute must be JavaScript numbers (not strings). + */ +var rangeSlider = function rangeSlider(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + min = _ref3.min, + max = _ref3.max, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + step = _ref3.step, + _ref3$pips = _ref3.pips, + pips = _ref3$pips === void 0 ? true : _ref3$pips, + _ref3$precision = _ref3.precision, + precision = _ref3$precision === void 0 ? 0 : _ref3$precision, + _ref3$tooltips = _ref3.tooltips, + tooltips = _ref3$tooltips === void 0 ? true : _ref3$tooltips; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + disabledRoot: (0, _classnames.default)(suit({ + modifierName: 'disabled' + }), userCssClasses.disabledRoot) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + step: step, + pips: pips, + tooltips: tooltips, + cssClasses: cssClasses + }); + var makeWidget = (0, _connectRange.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + min: min, + max: max, + precision: precision + })), {}, { + $$type: 'ais.rangeSlider', + $$widgetType: 'ais.rangeSlider' + }); +}; + +var _default = rangeSlider; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/rating-menu/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/rating-menu/defaultTemplates.js new file mode 100644 index 00000000..5fdc1d42 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/rating-menu/defaultTemplates.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: "{{#count}}{{/count}}{{^count}}{{/count}}" +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/rating-menu/rating-menu.js b/js/instantsearch.js/cjs/widgets/rating-menu/rating-menu.js new file mode 100644 index 00000000..0cc2b690 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/rating-menu/rating-menu.js @@ -0,0 +1,187 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RefinementList = _interopRequireDefault(require("../../components/RefinementList/RefinementList")); + +var _connectRatingMenu = _interopRequireDefault(require("../../connectors/rating-menu/connectRatingMenu")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'rating-menu' +}); +var suit = (0, _suit.component)('RatingMenu'); + +var _ref3 = (0, _preact.h)("path", { + d: "M12 .288l2.833 8.718h9.167l-7.417 5.389 2.833 8.718-7.416-5.388-7.417 5.388 2.833-8.718-7.416-5.389h9.167z" +}); + +var _ref4 = (0, _preact.h)("path", { + d: "M12 6.76l1.379 4.246h4.465l-3.612 2.625 1.379 4.246-3.611-2.625-3.612 2.625 1.379-4.246-3.612-2.625h4.465l1.38-4.246zm0-6.472l-2.833 8.718h-9.167l7.416 5.389-2.833 8.718 7.417-5.388 7.416 5.388-2.833-8.718 7.417-5.389h-9.167l-2.833-8.718z" +}); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates, + renderState = _ref.renderState; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + items = _ref2.items, + createURL = _ref2.createURL, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_RefinementList.default, { + createURL: createURL, + cssClasses: cssClasses, + facetValues: items, + templateProps: renderState.templateProps, + toggleRefinement: refine + }, (0, _preact.h)("svg", { + xmlns: "http://www.w3.org/2000/svg", + style: "display:none;" + }, (0, _preact.h)("symbol", { + id: suit({ + descendantName: 'starSymbol' + }), + viewBox: "0 0 24 24" + }, _ref3), (0, _preact.h)("symbol", { + id: suit({ + descendantName: 'starEmptySymbol' + }), + viewBox: "0 0 24 24" + }, _ref4))), containerNode); + }; +}; +/** + * Rating menu is used for displaying grade like filters. The values are normalized within boundaries. + * + * The maximum value can be set (with `max`), the minimum is always 0. + * + * @requirements + * The attribute passed to `attribute` must be declared as an + * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) + * in your Algolia settings. + * + * The values inside this attribute must be JavaScript numbers (not strings). + * + * @type {WidgetFactory} + * @devNovel RatingMenu + * @category filter + * @param {RatingMenuWidgetParams} widgetParams RatingMenu widget options. + * @return {Widget} A new RatingMenu widget instance. + * @example + * search.addWidgets([ + * instantsearch.widgets.ratingMenu({ + * container: '#stars', + * attribute: 'rating', + * max: 5, + * }) + * ]); + */ + + +var ratingMenu = function ratingMenu(widgetParams) { + var _ref5 = widgetParams || {}, + container = _ref5.container, + attribute = _ref5.attribute, + _ref5$max = _ref5.max, + max = _ref5$max === void 0 ? 5 : _ref5$max, + _ref5$cssClasses = _ref5.cssClasses, + userCssClasses = _ref5$cssClasses === void 0 ? {} : _ref5$cssClasses, + _ref5$templates = _ref5.templates, + templates = _ref5$templates === void 0 ? {} : _ref5$templates; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + disabledItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'disabled' + }), userCssClasses.disabledItem), + link: (0, _classnames.default)(suit({ + descendantName: 'link' + }), userCssClasses.link), + starIcon: (0, _classnames.default)(suit({ + descendantName: 'starIcon' + }), userCssClasses.starIcon), + fullStarIcon: (0, _classnames.default)(suit({ + descendantName: 'starIcon', + modifierName: 'full' + }), userCssClasses.fullStarIcon), + emptyStarIcon: (0, _classnames.default)(suit({ + descendantName: 'starIcon', + modifierName: 'empty' + }), userCssClasses.emptyStarIcon), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + count: (0, _classnames.default)(suit({ + descendantName: 'count' + }), userCssClasses.count) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectRatingMenu.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + max: max + })), {}, { + $$widgetType: 'ais.ratingMenu' + }); +}; + +var _default = ratingMenu; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/refinement-list/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/refinement-list/defaultTemplates.js new file mode 100644 index 00000000..bba09be2 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/refinement-list/defaultTemplates.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + item: "", + showMoreText: "\n {{#isShowingMore}}\n Show less\n {{/isShowingMore}}\n {{^isShowingMore}}\n Show more\n {{/isShowingMore}}\n ", + searchableNoResults: 'No results' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/refinement-list/refinement-list.js b/js/instantsearch.js/cjs/widgets/refinement-list/refinement-list.js new file mode 100644 index 00000000..7a1b34d8 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/refinement-list/refinement-list.js @@ -0,0 +1,243 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _RefinementList = _interopRequireDefault(require("../../components/RefinementList/RefinementList")); + +var _connectRefinementList = _interopRequireDefault(require("../../connectors/refinement-list/connectRefinementList")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _defaultTemplates = _interopRequireDefault(require("../search-box/defaultTemplates")); + +var _defaultTemplates2 = _interopRequireDefault(require("./defaultTemplates")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'refinement-list' +}); +var suit = (0, _suit.component)('RefinementList'); +var searchBoxSuit = (0, _suit.component)('SearchBox'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates, + searchBoxTemplates = _ref.searchBoxTemplates, + renderState = _ref.renderState, + showMore = _ref.showMore, + searchable = _ref.searchable, + searchablePlaceholder = _ref.searchablePlaceholder, + searchableIsAlwaysActive = _ref.searchableIsAlwaysActive; + return function (_ref2, isFirstRendering) { + var refine = _ref2.refine, + items = _ref2.items, + createURL = _ref2.createURL, + searchForItems = _ref2.searchForItems, + isFromSearch = _ref2.isFromSearch, + instantSearchInstance = _ref2.instantSearchInstance, + toggleShowMore = _ref2.toggleShowMore, + isShowingMore = _ref2.isShowingMore, + hasExhaustiveItems = _ref2.hasExhaustiveItems, + canToggleShowMore = _ref2.canToggleShowMore; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates2.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + renderState.searchBoxTemplateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: searchBoxTemplates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_RefinementList.default, { + createURL: createURL, + cssClasses: cssClasses, + facetValues: items, + templateProps: renderState.templateProps, + searchBoxTemplateProps: renderState.searchBoxTemplateProps, + toggleRefinement: refine, + searchFacetValues: searchable ? searchForItems : undefined, + searchPlaceholder: searchablePlaceholder, + searchIsAlwaysActive: searchableIsAlwaysActive, + isFromSearch: isFromSearch, + showMore: showMore && !isFromSearch && items.length > 0, + toggleShowMore: toggleShowMore, + isShowingMore: isShowingMore, + hasExhaustiveItems: hasExhaustiveItems, + canToggleShowMore: canToggleShowMore + }), containerNode); + }; +}; + +/** + * The refinement list widget is one of the most common widget that you can find + * in a search UI. With this widget, the user can filter the dataset based on facets. + * + * The refinement list displays only the most relevant facets for the current search + * context. The sort option only affects the facet that are returned by the engine, + * not which facets are returned. + * + * This widget also implements search for facet values, which is a mini search inside the + * values of the facets. This makes easy to deal with uncommon facet values. + * + * @requirements + * + * The attribute passed to `attribute` must be declared as an + * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) + * in your Algolia settings. + * + * If you also want to use search for facet values on this attribute, you need to make it searchable using the [dashboard](https://www.algolia.com/explorer/display/) or using the [API](https://www.algolia.com/doc/guides/searching/faceting/#search-for-facet-values). + */ +var refinementList = function refinementList(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + operator = _ref3.operator, + sortBy = _ref3.sortBy, + limit = _ref3.limit, + showMore = _ref3.showMore, + showMoreLimit = _ref3.showMoreLimit, + _ref3$searchable = _ref3.searchable, + searchable = _ref3$searchable === void 0 ? false : _ref3$searchable, + _ref3$searchablePlace = _ref3.searchablePlaceholder, + searchablePlaceholder = _ref3$searchablePlace === void 0 ? 'Search...' : _ref3$searchablePlace, + _ref3$searchableEscap = _ref3.searchableEscapeFacetValues, + searchableEscapeFacetValues = _ref3$searchableEscap === void 0 ? true : _ref3$searchableEscap, + _ref3$searchableIsAlw = _ref3.searchableIsAlwaysActive, + searchableIsAlwaysActive = _ref3$searchableIsAlw === void 0 ? true : _ref3$searchableIsAlw, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var escapeFacetValues = searchable ? Boolean(searchableEscapeFacetValues) : false; + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + noRefinementRoot: (0, _classnames.default)(suit({ + modifierName: 'noRefinement' + }), userCssClasses.noRefinementRoot), + list: (0, _classnames.default)(suit({ + descendantName: 'list' + }), userCssClasses.list), + item: (0, _classnames.default)(suit({ + descendantName: 'item' + }), userCssClasses.item), + selectedItem: (0, _classnames.default)(suit({ + descendantName: 'item', + modifierName: 'selected' + }), userCssClasses.selectedItem), + searchBox: (0, _classnames.default)(suit({ + descendantName: 'searchBox' + }), userCssClasses.searchBox), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + checkbox: (0, _classnames.default)(suit({ + descendantName: 'checkbox' + }), userCssClasses.checkbox), + labelText: (0, _classnames.default)(suit({ + descendantName: 'labelText' + }), userCssClasses.labelText), + count: (0, _classnames.default)(suit({ + descendantName: 'count' + }), userCssClasses.count), + noResults: (0, _classnames.default)(suit({ + descendantName: 'noResults' + }), userCssClasses.noResults), + showMore: (0, _classnames.default)(suit({ + descendantName: 'showMore' + }), userCssClasses.showMore), + disabledShowMore: (0, _classnames.default)(suit({ + descendantName: 'showMore', + modifierName: 'disabled' + }), userCssClasses.disabledShowMore), + searchable: { + root: (0, _classnames.default)(searchBoxSuit(), userCssClasses.searchableRoot), + form: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'form' + }), userCssClasses.searchableForm), + input: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'input' + }), userCssClasses.searchableInput), + submit: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'submit' + }), userCssClasses.searchableSubmit), + submitIcon: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'submitIcon' + }), userCssClasses.searchableSubmitIcon), + reset: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'reset' + }), userCssClasses.searchableReset), + resetIcon: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'resetIcon' + }), userCssClasses.searchableResetIcon), + loadingIndicator: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'loadingIndicator' + }), userCssClasses.searchableLoadingIndicator), + loadingIcon: (0, _classnames.default)(searchBoxSuit({ + descendantName: 'loadingIcon' + }), userCssClasses.searchableLoadingIcon) + } + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + searchBoxTemplates: { + submit: templates.searchableSubmit, + reset: templates.searchableReset, + loadingIndicator: templates.searchableLoadingIndicator + }, + renderState: {}, + searchable: searchable, + searchablePlaceholder: searchablePlaceholder, + searchableIsAlwaysActive: searchableIsAlwaysActive, + showMore: showMore + }); + var makeWidget = (0, _connectRefinementList.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + operator: operator, + limit: limit, + showMore: showMore, + showMoreLimit: showMoreLimit, + sortBy: sortBy, + escapeFacetValues: escapeFacetValues, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.refinementList' + }); +}; + +var _default = refinementList; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/relevant-sort/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/relevant-sort/defaultTemplates.js new file mode 100644 index 00000000..ae5ffd22 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/relevant-sort/defaultTemplates.js @@ -0,0 +1,15 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + text: '', + button: function button(_ref) { + var isRelevantSorted = _ref.isRelevantSorted; + return isRelevantSorted ? 'See all results' : 'See relevant results'; + } +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/relevant-sort/relevant-sort.js b/js/instantsearch.js/cjs/widgets/relevant-sort/relevant-sort.js new file mode 100644 index 00000000..45af675c --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/relevant-sort/relevant-sort.js @@ -0,0 +1,92 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _connectRelevantSort = _interopRequireDefault(require("../../connectors/relevant-sort/connectRelevantSort")); + +var _RelevantSort = _interopRequireDefault(require("../../components/RelevantSort/RelevantSort")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'relevant-sort' +}); +var suit = (0, _suit.component)('RelevantSort'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates; + return function (_ref2) { + var isRelevantSorted = _ref2.isRelevantSorted, + isVirtualReplica = _ref2.isVirtualReplica, + refine = _ref2.refine; + (0, _preact.render)((0, _preact.h)(_RelevantSort.default, { + cssClasses: cssClasses, + templates: templates, + isRelevantSorted: isRelevantSorted, + isVirtualReplica: isVirtualReplica, + refine: refine + }), containerNode); + }; +}; + +var relevantSort = function relevantSort(widgetParams) { + var container = widgetParams.container, + _widgetParams$templat = widgetParams.templates, + userTemplates = _widgetParams$templat === void 0 ? {} : _widgetParams$templat, + _widgetParams$cssClas = widgetParams.cssClasses, + userCssClasses = _widgetParams$cssClas === void 0 ? {} : _widgetParams$cssClas; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + text: (0, _classnames.default)(suit({ + descendantName: 'text' + }), userCssClasses.text), + button: (0, _classnames.default)(suit({ + descendantName: 'button' + }), userCssClasses.button) + }; + + var templates = _objectSpread(_objectSpread({}, _defaultTemplates.default), userTemplates); + + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectRelevantSort.default)(specializedRenderer, function () { + (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({})), {}, { + $$widgetType: 'ais.relevantSort' + }); +}; + +var _default = relevantSort; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/search-box/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/search-box/defaultTemplates.js new file mode 100644 index 00000000..281f7c9e --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/search-box/defaultTemplates.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplate = { + reset: "\n\n \n\n ", + submit: "\n\n \n\n ", + loadingIndicator: "\n\n \n \n \n \n \n \n \n \n\n " +}; +var _default = defaultTemplate; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/search-box/search-box.js b/js/instantsearch.js/cjs/widgets/search-box/search-box.js new file mode 100644 index 00000000..fbe9d9d6 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/search-box/search-box.js @@ -0,0 +1,152 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _connectSearchBox = _interopRequireDefault(require("../../connectors/search-box/connectSearchBox")); + +var _SearchBox = _interopRequireDefault(require("../../components/SearchBox/SearchBox")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'search-box' +}); +var suit = (0, _suit.component)('SearchBox'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + placeholder = _ref.placeholder, + templates = _ref.templates, + autofocus = _ref.autofocus, + searchAsYouType = _ref.searchAsYouType, + showReset = _ref.showReset, + showSubmit = _ref.showSubmit, + showLoadingIndicator = _ref.showLoadingIndicator; + return function (_ref2) { + var refine = _ref2.refine, + query = _ref2.query, + isSearchStalled = _ref2.isSearchStalled; + (0, _preact.render)((0, _preact.h)(_SearchBox.default, { + query: query, + placeholder: placeholder, + autofocus: autofocus, + refine: refine, + searchAsYouType: searchAsYouType, + templates: templates, + showSubmit: showSubmit, + showReset: showReset, + showLoadingIndicator: showLoadingIndicator, + isSearchStalled: isSearchStalled, + cssClasses: cssClasses + }), containerNode); + }; +}; +/** + * The searchbox widget is used to let the user set a text based query. + * + * This is usually the main entry point to start the search in an instantsearch context. For that + * reason is usually placed on top, and not hidden so that the user can start searching right + * away. + * + */ + + +var searchBox = function searchBox(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$placeholder = _ref3.placeholder, + placeholder = _ref3$placeholder === void 0 ? '' : _ref3$placeholder, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$autofocus = _ref3.autofocus, + autofocus = _ref3$autofocus === void 0 ? false : _ref3$autofocus, + _ref3$searchAsYouType = _ref3.searchAsYouType, + searchAsYouType = _ref3$searchAsYouType === void 0 ? true : _ref3$searchAsYouType, + _ref3$showReset = _ref3.showReset, + showReset = _ref3$showReset === void 0 ? true : _ref3$showReset, + _ref3$showSubmit = _ref3.showSubmit, + showSubmit = _ref3$showSubmit === void 0 ? true : _ref3$showSubmit, + _ref3$showLoadingIndi = _ref3.showLoadingIndicator, + showLoadingIndicator = _ref3$showLoadingIndi === void 0 ? true : _ref3$showLoadingIndi, + queryHook = _ref3.queryHook, + _ref3$templates = _ref3.templates, + userTemplates = _ref3$templates === void 0 ? {} : _ref3$templates; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + form: (0, _classnames.default)(suit({ + descendantName: 'form' + }), userCssClasses.form), + input: (0, _classnames.default)(suit({ + descendantName: 'input' + }), userCssClasses.input), + submit: (0, _classnames.default)(suit({ + descendantName: 'submit' + }), userCssClasses.submit), + submitIcon: (0, _classnames.default)(suit({ + descendantName: 'submitIcon' + }), userCssClasses.submitIcon), + reset: (0, _classnames.default)(suit({ + descendantName: 'reset' + }), userCssClasses.reset), + resetIcon: (0, _classnames.default)(suit({ + descendantName: 'resetIcon' + }), userCssClasses.resetIcon), + loadingIndicator: (0, _classnames.default)(suit({ + descendantName: 'loadingIndicator' + }), userCssClasses.loadingIndicator), + loadingIcon: (0, _classnames.default)(suit({ + descendantName: 'loadingIcon' + }), userCssClasses.loadingIcon) + }; + + var templates = _objectSpread(_objectSpread({}, _defaultTemplates.default), userTemplates); + + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + placeholder: placeholder, + templates: templates, + autofocus: autofocus, + searchAsYouType: searchAsYouType, + showReset: showReset, + showSubmit: showSubmit, + showLoadingIndicator: showLoadingIndicator + }); + var makeWidget = (0, _connectSearchBox.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + queryHook: queryHook + })), {}, { + $$widgetType: 'ais.searchBox' + }); +}; + +var _default = searchBox; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/sort-by/sort-by.js b/js/instantsearch.js/cjs/widgets/sort-by/sort-by.js new file mode 100644 index 00000000..115e8dc5 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/sort-by/sort-by.js @@ -0,0 +1,100 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Selector = _interopRequireDefault(require("../../components/Selector/Selector")); + +var _connectSortBy = _interopRequireDefault(require("../../connectors/sort-by/connectSortBy")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'sort-by' +}); +var suit = (0, _suit.component)('SortBy'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses; + return function (_ref2, isFirstRendering) { + var currentRefinement = _ref2.currentRefinement, + options = _ref2.options, + refine = _ref2.refine; + + if (isFirstRendering) { + return; + } + + (0, _preact.render)((0, _preact.h)("div", { + className: cssClasses.root + }, (0, _preact.h)(_Selector.default, { + cssClasses: cssClasses, + currentValue: currentRefinement, + options: options, + setValue: refine + })), containerNode); + }; +}; +/** + * Sort by selector is a widget used for letting the user choose between different + * indices that contains the same data with a different order / ranking formula. + */ + + +var sortBy = function sortBy(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + items = _ref3.items, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + transformItems = _ref3.transformItems; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + select: (0, _classnames.default)(suit({ + descendantName: 'select' + }), userCssClasses.select), + option: (0, _classnames.default)(suit({ + descendantName: 'option' + }), userCssClasses.option) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses + }); + var makeWidget = (0, _connectSortBy.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + container: containerNode, + items: items, + transformItems: transformItems + })), {}, { + $$widgetType: 'ais.sortBy' + }); +}; + +var _default = sortBy; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/stats/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/stats/defaultTemplates.js new file mode 100644 index 00000000..6e7680e6 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/stats/defaultTemplates.js @@ -0,0 +1,13 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "default", { + enumerable: true, + get: function get() { + return _stats.defaultTemplates; + } +}); + +var _stats = require("./stats"); \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/stats/stats.js b/js/instantsearch.js/cjs/widgets/stats/stats.js new file mode 100644 index 00000000..8b0d4b20 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/stats/stats.js @@ -0,0 +1,118 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.defaultTemplates = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _Stats = _interopRequireDefault(require("../../components/Stats/Stats")); + +var _connectStats = _interopRequireDefault(require("../../connectors/stats/connectStats")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'stats' +}); +var suit = (0, _suit.component)('Stats'); +var defaultTemplates = { + text: "\n {{#areHitsSorted}}\n {{#hasNoSortedResults}}No relevant results{{/hasNoSortedResults}}\n {{#hasOneSortedResults}}1 relevant result{{/hasOneSortedResults}}\n {{#hasManySortedResults}}{{#helpers.formatNumber}}{{nbSortedHits}}{{/helpers.formatNumber}} relevant results{{/hasManySortedResults}}\n sorted out of {{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}}\n {{/areHitsSorted}}\n {{^areHitsSorted}}\n {{#hasNoResults}}No results{{/hasNoResults}}\n {{#hasOneResult}}1 result{{/hasOneResult}}\n {{#hasManyResults}}{{#helpers.formatNumber}}{{nbHits}}{{/helpers.formatNumber}} results{{/hasManyResults}}\n {{/areHitsSorted}}\n found in {{processingTimeMS}}ms" +}; +exports.defaultTemplates = defaultTemplates; + +var renderer = function renderer(_ref) { + var renderState = _ref.renderState, + cssClasses = _ref.cssClasses, + containerNode = _ref.containerNode, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var hitsPerPage = _ref2.hitsPerPage, + nbHits = _ref2.nbHits, + nbSortedHits = _ref2.nbSortedHits, + areHitsSorted = _ref2.areHitsSorted, + nbPages = _ref2.nbPages, + page = _ref2.page, + processingTimeMS = _ref2.processingTimeMS, + query = _ref2.query, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: defaultTemplates, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_Stats.default, { + cssClasses: cssClasses, + hitsPerPage: hitsPerPage, + nbHits: nbHits, + nbSortedHits: nbSortedHits, + areHitsSorted: areHitsSorted, + nbPages: nbPages, + page: page, + processingTimeMS: processingTimeMS, + query: query, + templateProps: renderState.templateProps + }), containerNode); + }; +}; +/** + * The `stats` widget is used to display useful insights about the current results. + * + * By default, it will display the **number of hits** and the time taken to compute the + * results inside the engine. + */ + + +var stats = function stats(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + text: (0, _classnames.default)(suit({ + descendantName: 'text' + }), userCssClasses.text) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates, + renderState: {} + }); + var makeWidget = (0, _connectStats.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({})), {}, { + $$widgetType: 'ais.stats' + }); +}; + +var _default = stats; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/toggle-refinement/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/toggle-refinement/defaultTemplates.js new file mode 100644 index 00000000..e1ae8b9b --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/toggle-refinement/defaultTemplates.js @@ -0,0 +1,11 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var defaultTemplates = { + labelText: '{{name}}' +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/toggle-refinement/toggle-refinement.js b/js/instantsearch.js/cjs/widgets/toggle-refinement/toggle-refinement.js new file mode 100644 index 00000000..a680eeb8 --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/toggle-refinement/toggle-refinement.js @@ -0,0 +1,123 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _ToggleRefinement = _interopRequireDefault(require("../../components/ToggleRefinement/ToggleRefinement")); + +var _connectToggleRefinement = _interopRequireDefault(require("../../connectors/toggle-refinement/connectToggleRefinement")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'toggle-refinement' +}); +var suit = (0, _suit.component)('ToggleRefinement'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + renderState = _ref.renderState, + templates = _ref.templates; + return function (_ref2, isFirstRendering) { + var value = _ref2.value, + refine = _ref2.refine, + instantSearchInstance = _ref2.instantSearchInstance; + + if (isFirstRendering) { + renderState.templateProps = (0, _utils.prepareTemplateProps)({ + defaultTemplates: _defaultTemplates.default, + templatesConfig: instantSearchInstance.templatesConfig, + templates: templates + }); + return; + } + + (0, _preact.render)((0, _preact.h)(_ToggleRefinement.default, { + cssClasses: cssClasses, + currentRefinement: value, + templateProps: renderState.templateProps, + refine: refine + }), containerNode); + }; +}; + +/** + * The toggleRefinement widget lets the user either: + * - switch between two values for a single facetted attribute (free_shipping / not_free_shipping) + * - toggleRefinement a faceted value on and off (only 'canon' for brands) + * + * This widget is particularly useful if you have a boolean value in the records. + * + * @requirements + * The attribute passed to `attribute` must be declared as an + * [attribute for faceting](https://www.algolia.com/doc/guides/searching/faceting/#declaring-attributes-for-faceting) + * in your Algolia settings. + */ +var toggleRefinement = function toggleRefinement(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + attribute = _ref3.attribute, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + templates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$on = _ref3.on, + on = _ref3$on === void 0 ? true : _ref3$on, + off = _ref3.off; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + label: (0, _classnames.default)(suit({ + descendantName: 'label' + }), userCssClasses.label), + checkbox: (0, _classnames.default)(suit({ + descendantName: 'checkbox' + }), userCssClasses.checkbox), + labelText: (0, _classnames.default)(suit({ + descendantName: 'labelText' + }), userCssClasses.labelText) + }; + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + renderState: {}, + templates: templates + }); + var makeWidget = (0, _connectToggleRefinement.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + attribute: attribute, + on: on, + off: off + })), {}, { + $$widgetType: 'ais.toggleRefinement' + }); +}; + +var _default = toggleRefinement; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/voice-search/defaultTemplates.js b/js/instantsearch.js/cjs/widgets/voice-search/defaultTemplates.js new file mode 100644 index 00000000..be7a70ad --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/voice-search/defaultTemplates.js @@ -0,0 +1,26 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var getButtonInnerElement = function getButtonInnerElement(status, errorCode, isListening) { + if (status === 'error' && errorCode === 'not-allowed') { + return "\n \n \n \n "; + } + + return "\n \n \n \n "); +}; + +var defaultTemplates = { + buttonText: function buttonText(_ref) { + var status = _ref.status, + errorCode = _ref.errorCode, + isListening = _ref.isListening; + return "\n ".concat(getButtonInnerElement(status, errorCode, isListening), "\n "); + }, + status: "

{{transcript}}

" +}; +var _default = defaultTemplates; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/cjs/widgets/voice-search/voice-search.js b/js/instantsearch.js/cjs/widgets/voice-search/voice-search.js new file mode 100644 index 00000000..88f12fcd --- /dev/null +++ b/js/instantsearch.js/cjs/widgets/voice-search/voice-search.js @@ -0,0 +1,107 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _preact = require("preact"); + +var _classnames = _interopRequireDefault(require("classnames")); + +var _utils = require("../../lib/utils"); + +var _suit = require("../../lib/suit"); + +var _connectVoiceSearch = _interopRequireDefault(require("../../connectors/voice-search/connectVoiceSearch")); + +var _VoiceSearch = _interopRequireDefault(require("../../components/VoiceSearch/VoiceSearch")); + +var _defaultTemplates = _interopRequireDefault(require("./defaultTemplates")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } + +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; } + +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; } + +var withUsage = (0, _utils.createDocumentationMessageGenerator)({ + name: 'voice-search' +}); +var suit = (0, _suit.component)('VoiceSearch'); + +var renderer = function renderer(_ref) { + var containerNode = _ref.containerNode, + cssClasses = _ref.cssClasses, + templates = _ref.templates; + return function (_ref2) { + var isBrowserSupported = _ref2.isBrowserSupported, + isListening = _ref2.isListening, + toggleListening = _ref2.toggleListening, + voiceListeningState = _ref2.voiceListeningState; + (0, _preact.render)((0, _preact.h)(_VoiceSearch.default, { + cssClasses: cssClasses, + templates: templates, + isBrowserSupported: isBrowserSupported, + isListening: isListening, + toggleListening: toggleListening, + voiceListeningState: voiceListeningState + }), containerNode); + }; +}; + +var voiceSearch = function voiceSearch(widgetParams) { + var _ref3 = widgetParams || {}, + container = _ref3.container, + _ref3$cssClasses = _ref3.cssClasses, + userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses, + _ref3$templates = _ref3.templates, + userTemplates = _ref3$templates === void 0 ? {} : _ref3$templates, + _ref3$searchAsYouSpea = _ref3.searchAsYouSpeak, + searchAsYouSpeak = _ref3$searchAsYouSpea === void 0 ? false : _ref3$searchAsYouSpea, + language = _ref3.language, + additionalQueryParameters = _ref3.additionalQueryParameters, + createVoiceSearchHelper = _ref3.createVoiceSearchHelper; + + if (!container) { + throw new Error(withUsage('The `container` option is required.')); + } + + var containerNode = (0, _utils.getContainerNode)(container); + var cssClasses = { + root: (0, _classnames.default)(suit(), userCssClasses.root), + button: (0, _classnames.default)(suit({ + descendantName: 'button' + }), userCssClasses.button), + status: (0, _classnames.default)(suit({ + descendantName: 'status' + }), userCssClasses.status) + }; + + var templates = _objectSpread(_objectSpread({}, _defaultTemplates.default), userTemplates); + + var specializedRenderer = renderer({ + containerNode: containerNode, + cssClasses: cssClasses, + templates: templates + }); + var makeWidget = (0, _connectVoiceSearch.default)(specializedRenderer, function () { + return (0, _preact.render)(null, containerNode); + }); + return _objectSpread(_objectSpread({}, makeWidget({ + container: containerNode, + cssClasses: cssClasses, + templates: templates, + searchAsYouSpeak: searchAsYouSpeak, + language: language, + additionalQueryParameters: additionalQueryParameters, + createVoiceSearchHelper: createVoiceSearchHelper + })), {}, { + $$widgetType: 'ais.voiceSearch' + }); +}; + +var _default = voiceSearch; +exports.default = _default; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/index.js b/js/instantsearch.js/dist-es5-module/index.js deleted file mode 100644 index 281447e6..00000000 --- a/js/instantsearch.js/dist-es5-module/index.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var _main = require('./src/lib/main.js'); - -var _main2 = _interopRequireDefault(_main); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -module.exports = _main2.default; // we need to export using commonjs for ease of usage in all -// JavaScript environments - -/* eslint-disable import/no-commonjs */ diff --git a/js/instantsearch.js/dist-es5-module/src/components/ClearAll/ClearAll.js b/js/instantsearch.js/dist-es5-module/src/components/ClearAll/ClearAll.js deleted file mode 100644 index dfe7fc5c..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/ClearAll/ClearAll.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _utils = require('../../lib/utils.js'); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var ClearAll = function (_React$Component) { - _inherits(ClearAll, _React$Component); - - function ClearAll() { - _classCallCheck(this, ClearAll); - - return _possibleConstructorReturn(this, (ClearAll.__proto__ || Object.getPrototypeOf(ClearAll)).apply(this, arguments)); - } - - _createClass(ClearAll, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleClick = this.handleClick.bind(this); - } - }, { - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return this.props.url !== nextProps.url || this.props.hasRefinements !== nextProps.hasRefinements; - } - }, { - key: 'handleClick', - value: function handleClick(e) { - if ((0, _utils.isSpecialClick)(e)) { - // do not alter the default browser behavior - // if one special key is down - return; - } - e.preventDefault(); - this.props.clearAll(); - } - }, { - key: 'render', - value: function render() { - var data = { - hasRefinements: this.props.hasRefinements - }; - - return _react2.default.createElement( - 'a', - { - className: this.props.cssClasses.link, - href: this.props.url, - onClick: this.handleClick - }, - _react2.default.createElement(_Template2.default, _extends({ - data: data, - templateKey: 'link' - }, this.props.templateProps)) - ); - } - }]); - - return ClearAll; -}(_react2.default.Component); - -exports.default = ClearAll; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/ClearAll/__tests__/ClearAll-test.js b/js/instantsearch.js/dist-es5-module/src/components/ClearAll/__tests__/ClearAll-test.js deleted file mode 100644 index e0e31ccb..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/ClearAll/__tests__/ClearAll-test.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _ClearAll = require('../ClearAll'); - -var _ClearAll2 = _interopRequireDefault(_ClearAll); - -var _Template = require('../../Template'); - -var _Template2 = _interopRequireDefault(_Template); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - -describe('ClearAll', function () { - var renderer = void 0; - var defaultProps = { - clearAll: function clearAll() {}, - cssClasses: { - link: 'custom-link' - }, - hasRefinements: false, - templateProps: {}, - url: '#all-cleared!' - }; - - beforeEach(function () { - renderer = createRenderer(); - }); - - it('should render ', function () { - var out = render(); - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement( - 'a', - { - className: 'custom-link', - href: '#all-cleared!', - onClick: function onClick() {} - }, - _react2.default.createElement(_Template2.default, { - data: { hasRefinements: false }, - templateKey: 'link' - }) - )); - }); - - it('should handle clicks (and special clicks)', function () { - var props = { - clearAll: _sinon2.default.spy() - }; - var preventDefault = _sinon2.default.spy(); - var component = new _ClearAll2.default(props); - ['ctrlKey', 'shiftKey', 'altKey', 'metaKey'].forEach(function (e) { - var event = { preventDefault: preventDefault }; - event[e] = true; - component.handleClick(event); - (0, _expect2.default)(props.clearAll.called).toBe(false, 'clearAll never called'); - (0, _expect2.default)(preventDefault.called).toBe(false, 'preventDefault never called'); - }); - component.handleClick({ preventDefault: preventDefault }); - (0, _expect2.default)(props.clearAll.calledOnce).toBe(true, 'clearAll called once'); - (0, _expect2.default)(preventDefault.calledOnce).toBe(true, 'preventDefault called once'); - }); - - function render() { - var extraProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var props = _extends({}, defaultProps, extraProps); - renderer.render(_react2.default.createElement(_ClearAll2.default, props)); - return renderer.getRenderOutput(); - } -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/CurrentRefinedValues.js b/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/CurrentRefinedValues.js deleted file mode 100644 index 33bb83a1..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/CurrentRefinedValues.js +++ /dev/null @@ -1,160 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _utils = require('../../lib/utils.js'); - -var _map = require('lodash/map'); - -var _map2 = _interopRequireDefault(_map); - -var _cloneDeep = require('lodash/cloneDeep'); - -var _cloneDeep2 = _interopRequireDefault(_cloneDeep); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var CurrentRefinedValues = function (_React$Component) { - _inherits(CurrentRefinedValues, _React$Component); - - function CurrentRefinedValues() { - _classCallCheck(this, CurrentRefinedValues); - - return _possibleConstructorReturn(this, (CurrentRefinedValues.__proto__ || Object.getPrototypeOf(CurrentRefinedValues)).apply(this, arguments)); - } - - _createClass(CurrentRefinedValues, [{ - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return !(0, _isEqual2.default)(this.props.refinements, nextProps.refinements); - } - }, { - key: '_clearAllElement', - value: function _clearAllElement(position, requestedPosition) { - if (requestedPosition !== position) { - return undefined; - } - return _react2.default.createElement( - 'a', - { - className: this.props.cssClasses.clearAll, - href: this.props.clearAllURL, - onClick: handleClick(this.props.clearAllClick) - }, - _react2.default.createElement(_Template2.default, _extends({ templateKey: 'clearAll' }, this.props.templateProps)) - ); - } - }, { - key: '_refinementElement', - value: function _refinementElement(refinement, i) { - var attribute = this.props.attributes[refinement.attributeName] || {}; - var templateData = getTemplateData(attribute, refinement, this.props.cssClasses); - var customTemplateProps = getCustomTemplateProps(attribute); - var key = refinement.attributeName + (refinement.operator ? refinement.operator : ':') + (refinement.exclude ? refinement.exclude : '') + refinement.name; - return _react2.default.createElement( - 'div', - { - className: this.props.cssClasses.item, - key: key - }, - _react2.default.createElement( - 'a', - { - className: this.props.cssClasses.link, - href: this.props.clearRefinementURLs[i], - onClick: handleClick(this.props.clearRefinementClicks[i]) - }, - _react2.default.createElement(_Template2.default, _extends({ data: templateData, templateKey: 'item' }, this.props.templateProps, customTemplateProps)) - ) - ); - } - }, { - key: 'render', - value: function render() { - return _react2.default.createElement( - 'div', - null, - this._clearAllElement('before', this.props.clearAllPosition), - _react2.default.createElement( - 'div', - { className: this.props.cssClasses.list }, - (0, _map2.default)(this.props.refinements, this._refinementElement.bind(this)) - ), - this._clearAllElement('after', this.props.clearAllPosition) - ); - } - }]); - - return CurrentRefinedValues; -}(_react2.default.Component); - -function getCustomTemplateProps(attribute) { - var customTemplateProps = {}; - if (attribute.template !== undefined) { - customTemplateProps.templates = { - item: attribute.template - }; - } - if (attribute.transformData !== undefined) { - customTemplateProps.transformData = attribute.transformData; - } - return customTemplateProps; -} - -function getTemplateData(attribute, _refinement, cssClasses) { - var templateData = (0, _cloneDeep2.default)(_refinement); - - templateData.cssClasses = cssClasses; - if (attribute.label !== undefined) { - templateData.label = attribute.label; - } - if (templateData.operator !== undefined) { - templateData.displayOperator = templateData.operator; - if (templateData.operator === '>=') { - templateData.displayOperator = '≥'; - } - if (templateData.operator === '<=') { - templateData.displayOperator = '≤'; - } - } - - return templateData; -} - -function handleClick(cb) { - return function (e) { - if ((0, _utils.isSpecialClick)(e)) { - // do not alter the default browser behavior - // if one special key is down - return; - } - e.preventDefault(); - cb(); - }; -} - -exports.default = CurrentRefinedValues; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/__tests__/CurrentRefinedValues-test.js b/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/__tests__/CurrentRefinedValues-test.js deleted file mode 100644 index d2b47738..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/CurrentRefinedValues/__tests__/CurrentRefinedValues-test.js +++ /dev/null @@ -1,526 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ -/* eslint react/no-multi-comp: 0 */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _forEach = require('lodash/forEach'); - -var _forEach2 = _interopRequireDefault(_forEach); - -var _map = require('lodash/map'); - -var _map2 = _interopRequireDefault(_map); - -var _CurrentRefinedValues = require('../CurrentRefinedValues.js'); - -var _CurrentRefinedValues2 = _interopRequireDefault(_CurrentRefinedValues); - -var _Template = require('../../Template'); - -var _Template2 = _interopRequireDefault(_Template); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -describe('CurrentRefinedValues', function () { - var renderer = void 0; - - var defaultTemplates = void 0; - - var cssClasses = void 0; - var templateProps = void 0; - var refinements = void 0; - var refinementKeys = void 0; - var clearRefinementURLs = void 0; - var refinementTemplateData = void 0; - var refinementTemplateProps = void 0; - - var parameters = void 0; - - var listProps = void 0; - var clearAllLinkProps = void 0; - var clearAllTemplateProps = void 0; - var itemProps = void 0; - var itemLinkProps = void 0; - var itemTemplateProps = void 0; - - function render() { - renderer.render(_react2.default.createElement(_CurrentRefinedValues2.default, parameters)); - return renderer.getRenderOutput(); - } - - function buildList() { - return _react2.default.createElement( - 'div', - listProps, - (0, _map2.default)(refinements, function (refinement, i) { - return _react2.default.createElement( - 'div', - _extends({ key: refinementKeys[i] }, itemProps), - _react2.default.createElement( - 'a', - _extends({ href: clearRefinementURLs[i] }, itemLinkProps), - _react2.default.createElement(_Template2.default, _extends({ - data: refinementTemplateData[i] - }, itemTemplateProps, templateProps, refinementTemplateProps[i])) - ) - ); - }) - ); - } - - function build() { - var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'before'; - - if (position === 'before') { - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'a', - clearAllLinkProps, - _react2.default.createElement(_Template2.default, clearAllTemplateProps) - ), - buildList() - ); - } - if (position === 'after') { - return _react2.default.createElement( - 'div', - null, - buildList(), - _react2.default.createElement( - 'a', - clearAllLinkProps, - _react2.default.createElement(_Template2.default, clearAllTemplateProps) - ) - ); - } - return _react2.default.createElement( - 'div', - null, - buildList() - ); - } - - beforeEach(function () { - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - - defaultTemplates = { - header: 'DEFAULT HEADER TEMPLATE', - clearAll: 'DEFAULT CLEAR ALL TEMPLATE', - item: 'DEFAULT ITEM TEMPLATE', - footer: 'DEFAULT FOOTER TEMPLATE' - }; - - templateProps = { - templates: { - clearAll: 'CLEAR ALL', - item: '{{attributeName}}: {{name}}' - }, - defaultTemplates: defaultTemplates - }; - - cssClasses = { - clearAll: 'clear-all-class', - list: 'list-class', - item: 'item-class', - link: 'link-class', - count: 'count-class' - }; - - refinements = [{ type: 'facet', attributeName: 'facet', name: 'facet-val1', count: 1, exhaustive: true }, { type: 'facet', attributeName: 'facet', name: 'facet-val2', count: 2, exhaustive: true }, { type: 'exclude', attributeName: 'facetExclude', name: 'disjunctiveFacet-val1', exclude: true }, { type: 'disjunctive', attributeName: 'disjunctiveFacet', name: 'disjunctiveFacet-val1' }, { type: 'hierarchical', attributeName: 'hierarchicalFacet', name: 'hierarchicalFacet-val1' }, { type: 'numeric', attributeName: 'numericFacet', name: 'numericFacet-val1', operator: '>=' }, { type: 'tag', attributeName: '_tags', name: 'tag1' }]; - - refinementKeys = ['facet:facet-val1', 'facet:facet-val2', 'facetExclude:-facetExclude-val1', 'disjunctiveFacet:disjunctiveFacet-val1', 'hierarchical:hierarchicalFacet-val1', 'numericFacet>=numericFacet-val1', '_tags:tag1']; - - clearRefinementURLs = ['#cleared-facet-val1', '#cleared-facet-val2', '#cleared-facetExclude-val1', '#cleared-disjunctiveFacet-val1', '#cleared-hierarchicalFacet-val1', '#cleared-numericFacet-val1', '#cleared-tag1']; - - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0]), _extends({ cssClasses: cssClasses }, refinements[1]), _extends({ cssClasses: cssClasses }, refinements[2]), _extends({ cssClasses: cssClasses }, refinements[3]), _extends({ cssClasses: cssClasses }, refinements[4]), _extends({ displayOperator: '≥', cssClasses: cssClasses }, refinements[5]), _extends({ cssClasses: cssClasses }, refinements[6])]; - - refinementTemplateProps = [{}, {}, {}, {}, {}, {}, {}]; - - parameters = { - attributes: { - facet: { name: 'facet' }, - facetExclude: { name: 'facetExclude' }, - disjunctiveFacet: { name: 'disjunctiveFacet' }, - hierarchicalFacet: { name: 'hierarchicalFacet' }, - numericFacet: { name: 'numericFacet' }, - _tags: { name: '_tags' } - }, - clearAllClick: function clearAllClick() {}, - clearAllPosition: 'before', - clearAllURL: '#cleared-all', - clearRefinementClicks: [function () {}, function () {}, function () {}, function () {}, function () {}, function () {}, function () {}], - clearRefinementURLs: clearRefinementURLs, - cssClasses: cssClasses, - refinements: refinements, - templateProps: templateProps - }; - - listProps = { - className: 'list-class' - }; - clearAllLinkProps = { - className: 'clear-all-class', - href: '#cleared-all', - onClick: function onClick() {} - }; - clearAllTemplateProps = _extends({ - templateKey: 'clearAll' - }, templateProps); - itemProps = { - className: 'item-class' - }; - itemLinkProps = { - className: 'link-class', - onClick: function onClick() {} - }; - itemTemplateProps = _extends({ - templateKey: 'item' - }, templateProps); - }); - - it('should render twice all elements', function () { - var out1 = render(); - var out2 = render(); - - var expected = build(); - - (0, _expect2.default)(out1).toEqualJSX(expected); - (0, _expect2.default)(out2).toEqualJSX(expected); - }); - - context('options.attributes', function () { - it('uses label', function () { - parameters.attributes.facet = { name: 'facet', label: 'label' }; - - var out = render(); - - (0, _forEach2.default)(refinementTemplateData, function (data) { - if (data.attributeName === 'facet') { - data.label = 'label'; - } - }); - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('uses template', function () { - parameters.attributes.facet = { name: 'facet', template: 'CUSTOM TEMPLATE' }; - - var out = render(); - - (0, _forEach2.default)(refinements, function (refinement, i) { - if (refinement.attributeName === 'facet') { - refinementTemplateProps[i].templates = { - item: 'CUSTOM TEMPLATE' - }; - } - }); - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('uses transformData', function () { - var transformData = function transformData() { - return { transform: 'data' }; - }; - parameters.attributes.facet = { name: 'facet', transformData: transformData }; - (0, _forEach2.default)(refinements, function (refinement, i) { - if (refinement.attributeName === 'facet') { - refinementTemplateProps[i].transformData = transformData; - } - }); - - // expectJSX doesn't compare functions - var usedTransformData = render().props.children[1].props.children[0].props.children.props.children.props.transformData; - - (0, _expect2.default)(usedTransformData).toBe(transformData); - }); - - it('doesn\'t use another attribute', function () { - parameters.attributes.facet = { name: 'facet', randomAttribute: 'RANDOM VALUE' }; - (0, _expect2.default)(render()).toEqualJSX(build()); - }); - }); - - context('options.clearAllClick', function () { - beforeEach(function () { - // Not perfect since we depend on an internal - _CurrentRefinedValues2.default.__Rewire__('handleClick', function (cb) { - return cb; - }); - }); - - it('is used in the clearAll element before', function () { - parameters.clearAllPosition = 'before'; - - // expectJSX doesn't compare functions - var usedOnClick = render().props.children[0].props.onClick; - - (0, _expect2.default)(usedOnClick).toBe(parameters.clearAllClick); - }); - - it('is used in the clearAll element after', function () { - parameters.clearAllPosition = 'after'; - - // expectJSX doesn't compare functions - var usedOnClick = render().props.children[2].props.onClick; - - (0, _expect2.default)(usedOnClick).toBe(parameters.clearAllClick); - }); - - afterEach(function () { - _CurrentRefinedValues2.default.__ResetDependency__('handleClick'); - }); - }); - - context('options.clearAllPosition', function () { - it('\'before\'', function () { - parameters.clearAllPosition = 'before'; - (0, _expect2.default)(render()).toEqualJSX(build('before')); - }); - - it('\'after\'', function () { - parameters.clearAllPosition = 'after'; - (0, _expect2.default)(render()).toEqualJSX(build('after')); - }); - - it('false', function () { - parameters.clearAllPosition = false; - (0, _expect2.default)(render()).toEqualJSX(build(false)); - }); - }); - - context('options.clearAllURL', function () { - it('is used in the clearAll element before', function () { - parameters.clearAllPosition = 'before'; - parameters.clearAllURL = '#custom-clear-all'; - - var out = render(); - - clearAllLinkProps.href = '#custom-clear-all'; - - (0, _expect2.default)(out).toEqualJSX(build('before')); - }); - - it('is used in the clearAll element after', function () { - parameters.clearAllPosition = 'after'; - parameters.clearAllURL = '#custom-clear-all'; - - var out = render(); - - clearAllLinkProps.href = '#custom-clear-all'; - - (0, _expect2.default)(out).toEqualJSX(build('after')); - }); - }); - - context('options.clearRefinementClicks', function () { - beforeEach(function () { - // Not perfect since we depend on an internal - _CurrentRefinedValues2.default.__Rewire__('handleClick', function (cb) { - return cb; - }); - }); - - it('is used in an item element', function () { - // expectJSX doesn't compare functions - var usedOnClick = render().props.children[1].props.children[1].props.children.props.onClick; - - (0, _expect2.default)(usedOnClick).toBe(parameters.clearRefinementClicks[1]); - }); - - afterEach(function () { - _CurrentRefinedValues2.default.__ResetDependency__('handleClick'); - }); - }); - - context('options.clearRefinementURLs', function () { - it('is used in an item element', function () { - parameters.clearRefinementURLs[1] = '#custom-clear-specific'; - - var out = render(); - - clearRefinementURLs[1] = '#custom-clear-specific'; - (0, _expect2.default)(out).toEqualJSX(build()); - }); - }); - - context('options.cssClasses', function () { - it('uses clearAll', function () { - parameters.cssClasses.clearAll = 'custom-clear-all-class'; - - var out = render(); - - clearAllLinkProps.className = 'custom-clear-all-class'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('uses list', function () { - parameters.cssClasses.list = 'custom-list-class'; - - var out = render(); - - listProps.className = 'custom-list-class'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('uses item', function () { - parameters.cssClasses.item = 'custom-item-class'; - - var out = render(); - - itemProps.className = 'custom-item-class'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('uses link', function () { - parameters.cssClasses.link = 'custom-link-class'; - - var out = render(); - - itemLinkProps.className = 'custom-link-class'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('passes them to the item template', function () { - parameters.cssClasses.count = 'custom-count-class'; - - var out = render(); - - refinementTemplateData[0].cssClasses.count = 'custom-count-class'; - refinementTemplateData[1].cssClasses.count = 'custom-count-class'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - }); - - context('options.refinements', function () { - beforeEach(function () { - parameters.attributes = {}; - parameters.clearRefinementURLs = ['#cleared-custom']; - parameters.clearRefinementClicks = [function () {}]; - - refinementKeys = []; - clearRefinementURLs = ['#cleared-custom']; - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - refinementTemplateProps = [_extends({}, templateProps)]; - }); - - it('can be used with a facet', function () { - refinements = [{ type: 'facet', attributeName: 'customFacet', name: 'val1' }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push('customFacet:val1'); - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('can be used with an exclude', function () { - refinements = [{ type: 'exclude', attributeName: 'customExcludeFacet', name: 'val1', exclude: true }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push('customExcludeFacet:-val1'); - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('can be used with a disjunctive facet', function () { - refinements = [{ type: 'disjunctive', attributeName: 'customDisjunctiveFacet', name: 'val1' }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push('customDisjunctiveFacet:val1'); - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('can be used with a hierarchical facet', function () { - refinements = [{ type: 'hierarchical', attributeName: 'customHierarchicalFacet', name: 'val1' }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push('customHierarchicalFacet:val1'); - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('can be used with numeric filters', function () { - refinements = [{ type: 'numeric', attributeName: 'customNumericFilter', operator: '=', name: 'val1' }, { type: 'numeric', attributeName: 'customNumericFilter', operator: '<=', name: 'val2' }, { type: 'numeric', attributeName: 'customNumericFilter', operator: '>=', name: 'val3' }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push(['customNumericFilter=val1', 'customNumericFilter<=val2', 'customNumericFilter>=val3']); - refinementTemplateData = [_extends({ cssClasses: cssClasses, displayOperator: '=' }, refinements[0]), _extends({ cssClasses: cssClasses, displayOperator: '≤' }, refinements[1]), _extends({ cssClasses: cssClasses, displayOperator: '≥' }, refinements[2])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - - it('can be used with a tag', function () { - refinements = [{ type: 'tag', attributeName: '_tags', name: 'tag1' }]; - - parameters.refinements = refinements; - - var out = render(); - - refinementKeys.push('_tags:tag1'); - refinementTemplateData = [_extends({ cssClasses: cssClasses }, refinements[0])]; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - }); - - context('options.templateProps', function () { - it('passes a custom template if given', function () { - parameters.templateProps.templates.item = 'CUSTOM ITEM TEMPLATE'; - - var out = render(); - - clearAllTemplateProps.templates.item = 'CUSTOM ITEM TEMPLATE'; - itemTemplateProps.templates.item = 'CUSTOM ITEM TEMPLATE'; - - (0, _expect2.default)(out).toEqualJSX(build()); - }); - }); -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Hits.js b/js/instantsearch.js/dist-es5-module/src/components/Hits.js deleted file mode 100644 index 1fb038b0..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Hits.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _map = require('lodash/map'); - -var _map2 = _interopRequireDefault(_map); - -var _Template = require('./Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _has = require('lodash/has'); - -var _has2 = _interopRequireDefault(_has); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Hits = function (_React$Component) { - _inherits(Hits, _React$Component); - - function Hits() { - _classCallCheck(this, Hits); - - return _possibleConstructorReturn(this, (Hits.__proto__ || Object.getPrototypeOf(Hits)).apply(this, arguments)); - } - - _createClass(Hits, [{ - key: 'renderWithResults', - value: function renderWithResults() { - var _this2 = this; - - var renderedHits = (0, _map2.default)(this.props.hits, function (hit, position) { - var data = _extends({}, hit, { - __hitIndex: position - }); - return _react2.default.createElement(_Template2.default, _extends({ - data: data, - key: data.objectID, - rootProps: { className: _this2.props.cssClasses.item }, - templateKey: 'item' - }, _this2.props.templateProps)); - }); - - return _react2.default.createElement( - 'div', - { className: this.props.cssClasses.root }, - renderedHits - ); - } - }, { - key: 'renderAllResults', - value: function renderAllResults() { - var className = (0, _classnames2.default)(this.props.cssClasses.root, this.props.cssClasses.allItems); - - return _react2.default.createElement(_Template2.default, _extends({ - data: this.props.results, - rootProps: { className: className }, - templateKey: 'allItems' - }, this.props.templateProps)); - } - }, { - key: 'renderNoResults', - value: function renderNoResults() { - var className = (0, _classnames2.default)(this.props.cssClasses.root, this.props.cssClasses.empty); - return _react2.default.createElement(_Template2.default, _extends({ - data: this.props.results, - rootProps: { className: className }, - templateKey: 'empty' - }, this.props.templateProps)); - } - }, { - key: 'render', - value: function render() { - var hasResults = this.props.results.hits.length > 0; - var hasAllItemsTemplate = (0, _has2.default)(this.props, 'templateProps.templates.allItems'); - - if (!hasResults) { - return this.renderNoResults(); - } - - // If a allItems template is defined, it takes precedence over our looping - // through hits - if (hasAllItemsTemplate) { - return this.renderAllResults(); - } - - return this.renderWithResults(); - } - }]); - - return Hits; -}(_react2.default.Component); - -Hits.defaultProps = { - results: { hits: [] } -}; - -exports.default = Hits; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/InfiniteHits.js b/js/instantsearch.js/dist-es5-module/src/components/InfiniteHits.js deleted file mode 100644 index 0d03230e..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/InfiniteHits.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Hits = require('./Hits.js'); - -var _Hits2 = _interopRequireDefault(_Hits); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var InfiniteHits = function (_React$Component) { - _inherits(InfiniteHits, _React$Component); - - function InfiniteHits() { - _classCallCheck(this, InfiniteHits); - - return _possibleConstructorReturn(this, (InfiniteHits.__proto__ || Object.getPrototypeOf(InfiniteHits)).apply(this, arguments)); - } - - _createClass(InfiniteHits, [{ - key: 'render', - value: function render() { - var _props = this.props, - cssClasses = _props.cssClasses, - hits = _props.hits, - results = _props.results, - showMore = _props.showMore, - showMoreLabel = _props.showMoreLabel, - templateProps = _props.templateProps; - - var btn = this.props.isLastPage ? _react2.default.createElement( - 'button', - { disabled: true }, - showMoreLabel - ) : _react2.default.createElement( - 'button', - { onClick: showMore }, - showMoreLabel - ); - - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement(_Hits2.default, { - cssClasses: cssClasses, - hits: hits, - results: results, - templateProps: templateProps - }), - _react2.default.createElement( - 'div', - { className: cssClasses.showmore }, - btn - ) - ); - } - }]); - - return InfiniteHits; -}(_react2.default.Component); - -exports.default = InfiniteHits; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Pagination/Pagination.js b/js/instantsearch.js/dist-es5-module/src/components/Pagination/Pagination.js deleted file mode 100644 index 89e1c94f..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Pagination/Pagination.js +++ /dev/null @@ -1,205 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _forEach = require('lodash/forEach'); - -var _forEach2 = _interopRequireDefault(_forEach); - -var _defaultsDeep = require('lodash/defaultsDeep'); - -var _defaultsDeep2 = _interopRequireDefault(_defaultsDeep); - -var _utils = require('../../lib/utils.js'); - -var _Paginator = require('./Paginator.js'); - -var _Paginator2 = _interopRequireDefault(_Paginator); - -var _PaginationLink = require('./PaginationLink.js'); - -var _PaginationLink2 = _interopRequireDefault(_PaginationLink); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Pagination = function (_React$Component) { - _inherits(Pagination, _React$Component); - - function Pagination(props) { - _classCallCheck(this, Pagination); - - var _this = _possibleConstructorReturn(this, (Pagination.__proto__ || Object.getPrototypeOf(Pagination)).call(this, (0, _defaultsDeep2.default)(props, Pagination.defaultProps))); - - _this.handleClick = _this.handleClick.bind(_this); - return _this; - } - - _createClass(Pagination, [{ - key: 'pageLink', - value: function pageLink(_ref) { - var label = _ref.label, - ariaLabel = _ref.ariaLabel, - pageNumber = _ref.pageNumber, - _ref$additionalClassN = _ref.additionalClassName, - additionalClassName = _ref$additionalClassN === undefined ? null : _ref$additionalClassN, - _ref$isDisabled = _ref.isDisabled, - isDisabled = _ref$isDisabled === undefined ? false : _ref$isDisabled, - _ref$isActive = _ref.isActive, - isActive = _ref$isActive === undefined ? false : _ref$isActive, - createURL = _ref.createURL; - - var cssClasses = { - item: (0, _classnames2.default)(this.props.cssClasses.item, additionalClassName), - link: (0, _classnames2.default)(this.props.cssClasses.link) - }; - if (isDisabled) { - cssClasses.item = (0, _classnames2.default)(cssClasses.item, this.props.cssClasses.disabled); - } else if (isActive) { - cssClasses.item = (0, _classnames2.default)(cssClasses.item, this.props.cssClasses.active); - } - - var url = createURL && !isDisabled ? createURL(pageNumber) : '#'; - - return _react2.default.createElement(_PaginationLink2.default, { - ariaLabel: ariaLabel, - cssClasses: cssClasses, - handleClick: this.handleClick, - isDisabled: isDisabled, - key: label + pageNumber, - label: label, - pageNumber: pageNumber, - url: url - }); - } - }, { - key: 'previousPageLink', - value: function previousPageLink(pager, createURL) { - return this.pageLink({ - ariaLabel: 'Previous', - additionalClassName: this.props.cssClasses.previous, - isDisabled: pager.isFirstPage(), - label: this.props.labels.previous, - pageNumber: pager.currentPage - 1, - createURL: createURL - }); - } - }, { - key: 'nextPageLink', - value: function nextPageLink(pager, createURL) { - return this.pageLink({ - ariaLabel: 'Next', - additionalClassName: this.props.cssClasses.next, - isDisabled: pager.isLastPage(), - label: this.props.labels.next, - pageNumber: pager.currentPage + 1, - createURL: createURL - }); - } - }, { - key: 'firstPageLink', - value: function firstPageLink(pager, createURL) { - return this.pageLink({ - ariaLabel: 'First', - additionalClassName: this.props.cssClasses.first, - isDisabled: pager.isFirstPage(), - label: this.props.labels.first, - pageNumber: 0, - createURL: createURL - }); - } - }, { - key: 'lastPageLink', - value: function lastPageLink(pager, createURL) { - return this.pageLink({ - ariaLabel: 'Last', - additionalClassName: this.props.cssClasses.last, - isDisabled: pager.isLastPage(), - label: this.props.labels.last, - pageNumber: pager.total - 1, - createURL: createURL - }); - } - }, { - key: 'pages', - value: function pages(pager, createURL) { - var _this2 = this; - - var pages = []; - - (0, _forEach2.default)(pager.pages(), function (pageNumber) { - var isActive = pageNumber === pager.currentPage; - - pages.push(_this2.pageLink({ - ariaLabel: pageNumber + 1, - additionalClassName: _this2.props.cssClasses.page, - isActive: isActive, - label: pageNumber + 1, - pageNumber: pageNumber, - createURL: createURL - })); - }); - - return pages; - } - }, { - key: 'handleClick', - value: function handleClick(pageNumber, event) { - if ((0, _utils.isSpecialClick)(event)) { - // do not alter the default browser behavior - // if one special key is down - return; - } - event.preventDefault(); - this.props.setCurrentPage(pageNumber); - } - }, { - key: 'render', - value: function render() { - var pager = new _Paginator2.default({ - currentPage: this.props.currentPage, - total: this.props.nbPages, - padding: this.props.padding - }); - - var createURL = this.props.createURL; - - return _react2.default.createElement( - 'ul', - { className: this.props.cssClasses.root }, - this.props.showFirstLast ? this.firstPageLink(pager, createURL) : null, - this.previousPageLink(pager, createURL), - this.pages(pager, createURL), - this.nextPageLink(pager, createURL), - this.props.showFirstLast ? this.lastPageLink(pager, createURL) : null - ); - } - }]); - - return Pagination; -}(_react2.default.Component); - -Pagination.defaultProps = { - nbHits: 0, - currentPage: 0, - nbPages: 0 -}; - -exports.default = Pagination; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Pagination/PaginationLink.js b/js/instantsearch.js/dist-es5-module/src/components/Pagination/PaginationLink.js deleted file mode 100644 index b79e1e1d..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Pagination/PaginationLink.js +++ /dev/null @@ -1,93 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var PaginationLink = function (_React$Component) { - _inherits(PaginationLink, _React$Component); - - function PaginationLink() { - _classCallCheck(this, PaginationLink); - - return _possibleConstructorReturn(this, (PaginationLink.__proto__ || Object.getPrototypeOf(PaginationLink)).apply(this, arguments)); - } - - _createClass(PaginationLink, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleClick = this.handleClick.bind(this); - } - }, { - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return !(0, _isEqual2.default)(this.props, nextProps); - } - }, { - key: 'handleClick', - value: function handleClick(e) { - this.props.handleClick(this.props.pageNumber, e); - } - }, { - key: 'render', - value: function render() { - var _props = this.props, - cssClasses = _props.cssClasses, - label = _props.label, - ariaLabel = _props.ariaLabel, - url = _props.url, - isDisabled = _props.isDisabled; - - - var tagName = 'span'; - var attributes = { - className: cssClasses.link, - dangerouslySetInnerHTML: { - __html: label - } - }; - - // "Enable" the element, by making it a link - if (!isDisabled) { - tagName = 'a'; - attributes = _extends({}, attributes, { - 'aria-label': ariaLabel, - 'href': url, - 'onClick': this.handleClick - }); - } - - var element = _react2.default.createElement(tagName, attributes); - - return _react2.default.createElement( - 'li', - { className: cssClasses.item }, - element - ); - } - }]); - - return PaginationLink; -}(_react2.default.Component); - -exports.default = PaginationLink; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Pagination-test.js b/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Pagination-test.js deleted file mode 100644 index 469c3a4b..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Pagination-test.js +++ /dev/null @@ -1,179 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _Pagination = require('../Pagination'); - -var _Pagination2 = _interopRequireDefault(_Pagination); - -var _PaginationLink = require('../PaginationLink'); - -var _PaginationLink2 = _interopRequireDefault(_PaginationLink); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -describe('Pagination', function () { - var renderer = void 0; - - beforeEach(function () { - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - }); - - it('should render five elements', function () { - var out = render(); - - (0, _expect2.default)(out.props.children.length).toEqual(5); - }); - - it('should not display the first/last link by default', function () { - var out = render(); - - (0, _expect2.default)(out.props.children[0]).toEqual(null); - (0, _expect2.default)(out.props.children[4]).toEqual(null); - }); - - it('should display the first/last link', function () { - var out = render({ showFirstLast: true }); - - (0, _expect2.default)(out.props.children[0]).toNotEqual(null); - (0, _expect2.default)(out.props.children[4]).toNotEqual(null); - }); - - it('should display the right number of pages', function () { - var padding = 4; - var out = render({ padding: padding }); - - (0, _expect2.default)(out.props.children[2].length).toEqual(padding + 1 + padding); - }); - - it('should flag the current page as active', function () { - var out = render({ currentPage: 0 }); - - (0, _expect2.default)(out.props.children[2][0].props.cssClasses.item).toBe('item page active'); - (0, _expect2.default)(out.props.children[2][1].props.cssClasses.item).toBe('item page'); - }); - - it('should disable the first page if already on it', function () { - var out = render({ currentPage: 0, showFirstLast: true }); - - (0, _expect2.default)(out.props.children[0].props.cssClasses.item).toBe('item first disabled'); - }); - - it('should build the associated URL', function () { - var createURL = _sinon2.default.stub().returns('/page'); - var out = new _Pagination2.default({ cssClasses: {} }).pageLink({ - label: 'test', - pageNumber: 8, - createURL: createURL - }); - - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement(_PaginationLink2.default, { - ariaLabel: undefined, - cssClasses: { item: '', link: '' }, - handleClick: function handleClick() {}, - isDisabled: false, - key: 'test8', - label: 'test', - pageNumber: 8, - url: '/page' - })); - (0, _expect2.default)(createURL.calledOnce).toBe(true, 'createURL should be called once'); - }); - - it('should not build the URL of disabled page', function () { - var createURL = _sinon2.default.spy(); - var out = new _Pagination2.default({ cssClasses: {} }).pageLink({ - label: 'test', - isDisabled: true, - pageNumber: 8, - createURL: createURL - }); - - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement(_PaginationLink2.default, { - ariaLabel: undefined, - cssClasses: { item: '', link: '' }, - handleClick: function handleClick() {}, - isDisabled: true, - key: 'test8', - label: 'test', - pageNumber: 8, - url: '#' - })); - (0, _expect2.default)(createURL.called).toBe(false, 'createURL should not be called'); - }); - - it('should disable last page if already on it', function () { - var out = render({ currentPage: 19, showFirstLast: true }); - - (0, _expect2.default)(out.props.children[4].props.cssClasses.item).toBe('item last disabled'); - }); - - it('should handle special clicks', function () { - var props = { - setCurrentPage: _sinon2.default.spy() - }; - var preventDefault = _sinon2.default.spy(); - var component = new _Pagination2.default(props); - ['ctrlKey', 'shiftKey', 'altKey', 'metaKey'].forEach(function (e) { - var event = { preventDefault: preventDefault }; - event[e] = true; - component.handleClick(42, event); - (0, _expect2.default)(props.setCurrentPage.called).toBe(false, 'setCurrentPage never called'); - (0, _expect2.default)(preventDefault.called).toBe(false, 'preventDefault never called'); - }); - component.handleClick(42, { preventDefault: preventDefault }); - (0, _expect2.default)(props.setCurrentPage.calledOnce).toBe(true, 'setCurrentPage called once'); - (0, _expect2.default)(preventDefault.calledOnce).toBe(true, 'preventDefault called once'); - }); - - function render() { - var extraProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var props = _extends({ - cssClasses: { - root: 'root', - item: 'item', - page: 'page', - previous: 'previous', - next: 'next', - first: 'first', - last: 'last', - active: 'active', - disabled: 'disabled' - }, - labels: { first: '', last: '', next: '', previous: '' }, - currentPage: 0, - nbHits: 200, - nbPages: 20, - padding: 3, - setCurrentPage: function setCurrentPage() {} - }, extraProps); - - renderer.render(_react2.default.createElement(_Pagination2.default, props)); - return renderer.getRenderOutput(); - } -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Paginator-test.js b/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Paginator-test.js deleted file mode 100644 index 81d45bf5..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Pagination/__tests__/Paginator-test.js +++ /dev/null @@ -1,169 +0,0 @@ -'use strict'; - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _Paginator = require('../Paginator'); - -var _Paginator2 = _interopRequireDefault(_Paginator); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* eslint-env mocha */ - -describe('paginator: simple cases', function () { - context('on the first page', function () { - var pager = new _Paginator2.default({ - currentPage: 0, - total: 10, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(5); - (0, _expect2.default)(pages).toEqual([0, 1, 2, 3, 4]); - }); - - it('should be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(true); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(false); - }); - }); - - context('on 3rd page', function () { - var pager = new _Paginator2.default({ - currentPage: 2, - total: 10, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(5); - (0, _expect2.default)(pages).toEqual([0, 1, 2, 3, 4]); - }); - - it('should not be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(false); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(false); - }); - }); - - context('on 5th page', function () { - var pager = new _Paginator2.default({ - currentPage: 5, - total: 10, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(5); - (0, _expect2.default)(pages).toEqual([3, 4, 5, 6, 7]); - }); - - it('should not be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(false); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(false); - }); - }); - - context('on the page before the last', function () { - var pager = new _Paginator2.default({ - currentPage: 8, - total: 10, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(5); - (0, _expect2.default)(pages).toEqual([5, 6, 7, 8, 9]); - }); - - it('should not be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(false); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(false); - }); - }); - - context('on last page', function () { - var pager = new _Paginator2.default({ - currentPage: 9, - total: 10, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(5); - (0, _expect2.default)(pages).toEqual([5, 6, 7, 8, 9]); - }); - - it('should not be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(false); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(true); - }); - }); -}); - -describe('paginator: number of pages is less than 2*padding+1', function () { - var pager = new _Paginator2.default({ - currentPage: 0, - total: 1, - padding: 2 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(1); - (0, _expect2.default)(pages).toEqual([0]); - }); - - it('should be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(true); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(true); - }); -}); - -describe('paginator: bug #668', function () { - var pager = new _Paginator2.default({ - currentPage: 4, - total: 6, - padding: 3 - }); - - it('should return the pages', function () { - var pages = pager.pages(); - (0, _expect2.default)(pages.length).toBe(6); - (0, _expect2.default)(pages).toEqual([0, 1, 2, 3, 4, 5]); - }); - - it('should be the first page', function () { - (0, _expect2.default)(pager.isFirstPage()).toBe(false); - }); - - it('should not be the last page', function () { - (0, _expect2.default)(pager.isLastPage()).toBe(false); - }); -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRanges.js b/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRanges.js deleted file mode 100644 index d20dbd82..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRanges.js +++ /dev/null @@ -1,140 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _PriceRangesForm = require('./PriceRangesForm.js'); - -var _PriceRangesForm2 = _interopRequireDefault(_PriceRangesForm); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var PriceRanges = function (_React$Component) { - _inherits(PriceRanges, _React$Component); - - function PriceRanges() { - _classCallCheck(this, PriceRanges); - - return _possibleConstructorReturn(this, (PriceRanges.__proto__ || Object.getPrototypeOf(PriceRanges)).apply(this, arguments)); - } - - _createClass(PriceRanges, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.refine = this.refine.bind(this); - } - }, { - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return !(0, _isEqual2.default)(this.props.facetValues, nextProps.facetValues); - } - }, { - key: 'getForm', - value: function getForm() { - var labels = _extends({ - currency: this.props.currency - }, this.props.labels); - - var currentRefinement = void 0; - if (this.props.facetValues.length === 1) { - currentRefinement = { - from: this.props.facetValues[0].from !== undefined ? this.props.facetValues[0].from : '', - to: this.props.facetValues[0].to !== undefined ? this.props.facetValues[0].to : '' - }; - } else { - currentRefinement = { from: '', to: '' }; - } - - return _react2.default.createElement(_PriceRangesForm2.default, { - cssClasses: this.props.cssClasses, - currentRefinement: currentRefinement, - labels: labels, - refine: this.refine - }); - } - }, { - key: 'getItemFromFacetValue', - value: function getItemFromFacetValue(facetValue) { - var cssClassItem = (0, _classnames2.default)(this.props.cssClasses.item, _defineProperty({}, this.props.cssClasses.active, facetValue.isRefined)); - var key = facetValue.from + '_' + facetValue.to; - var handleClick = this.refine.bind(this, facetValue.from, facetValue.to); - var data = _extends({ - currency: this.props.currency - }, facetValue); - return _react2.default.createElement( - 'div', - { className: cssClassItem, key: key }, - _react2.default.createElement( - 'a', - { - className: this.props.cssClasses.link, - href: facetValue.url, - onClick: handleClick - }, - _react2.default.createElement(_Template2.default, _extends({ data: data, templateKey: 'item' }, this.props.templateProps)) - ) - ); - } - }, { - key: 'refine', - value: function refine(from, to, event) { - event.preventDefault(); - this.props.refine(from, to); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - return _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'div', - { className: this.props.cssClasses.list }, - this.props.facetValues.map(function (facetValue) { - return _this2.getItemFromFacetValue(facetValue); - }) - ), - this.getForm() - ); - } - }]); - - return PriceRanges; -}(_react2.default.Component); - -PriceRanges.defaultProps = { - cssClasses: {} -}; - -exports.default = PriceRanges; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRangesForm.js b/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRangesForm.js deleted file mode 100644 index ea11d49f..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/PriceRangesForm.js +++ /dev/null @@ -1,118 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var PriceRangesForm = function (_React$Component) { - _inherits(PriceRangesForm, _React$Component); - - function PriceRangesForm(props) { - _classCallCheck(this, PriceRangesForm); - - var _this = _possibleConstructorReturn(this, (PriceRangesForm.__proto__ || Object.getPrototypeOf(PriceRangesForm)).call(this, props)); - - _this.state = { - from: props.currentRefinement.from, - to: props.currentRefinement.to - }; - return _this; - } - - _createClass(PriceRangesForm, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleSubmit = this.handleSubmit.bind(this); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - this.setState({ - from: props.currentRefinement.from, - to: props.currentRefinement.to - }); - } - }, { - key: 'getInput', - value: function getInput(type) { - var _this2 = this; - - return _react2.default.createElement( - 'label', - { className: this.props.cssClasses.label }, - _react2.default.createElement( - 'span', - { className: this.props.cssClasses.currency }, - this.props.labels.currency, - ' ' - ), - _react2.default.createElement('input', { - className: this.props.cssClasses.input, - onChange: function onChange(e) { - return _this2.setState(_defineProperty({}, type, e.target.value)); - }, - ref: type, - type: 'number', - value: this.state[type] - }) - ); - } - }, { - key: 'handleSubmit', - value: function handleSubmit(event) { - var from = this.refs.from.value !== '' ? parseInt(this.refs.from.value, 10) : undefined; - var to = this.refs.to.value !== '' ? parseInt(this.refs.to.value, 10) : undefined; - this.props.refine(from, to, event); - } - }, { - key: 'render', - value: function render() { - var fromInput = this.getInput('from'); - var toInput = this.getInput('to'); - var onSubmit = this.handleSubmit; - return _react2.default.createElement( - 'form', - { className: this.props.cssClasses.form, onSubmit: onSubmit, ref: 'form' }, - fromInput, - _react2.default.createElement( - 'span', - { className: this.props.cssClasses.separator }, - ' ', - this.props.labels.separator, - ' ' - ), - toInput, - _react2.default.createElement( - 'button', - { className: this.props.cssClasses.button, type: 'submit' }, - this.props.labels.button - ) - ); - } - }]); - - return PriceRangesForm; -}(_react2.default.Component); - -PriceRangesForm.defaultProps = { - cssClasses: {}, - labels: {} -}; - -exports.default = PriceRangesForm; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRanges-test.js b/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRanges-test.js deleted file mode 100644 index f13b9a7c..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRanges-test.js +++ /dev/null @@ -1,259 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -var _Template = require('../../Template'); - -var _Template2 = _interopRequireDefault(_Template); - -var _PriceRanges = require('../PriceRanges'); - -var _PriceRanges2 = _interopRequireDefault(_PriceRanges); - -var _PriceRangesForm = require('../PriceRangesForm'); - -var _PriceRangesForm2 = _interopRequireDefault(_PriceRangesForm); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -var _ref = _react2.default.createElement('span', null); - -var _ref2 = _react2.default.createElement('form', null); - -var _ref3 = _react2.default.createElement( - 'div', - null, - _react2.default.createElement( - 'div', - { className: 'list' }, - _react2.default.createElement('span', null), - _react2.default.createElement('span', null), - _react2.default.createElement('span', null), - _react2.default.createElement('span', null) - ), - _react2.default.createElement('form', null) -); - -describe('PriceRanges', function () { - var renderer = void 0; - var stubbedMethods = void 0; - - beforeEach(function () { - stubbedMethods = []; - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - }); - - afterEach(function () { - // Restore all stubbed methods - stubbedMethods.forEach(function (name) { - _PriceRanges2.default.prototype[name].restore(); - }); - }); - - function render() { - var extraProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var props = _extends({}, extraProps); - renderer.render(_react2.default.createElement(_PriceRanges2.default, props)); - return renderer.getRenderOutput(); - } - - function getComponentWithMockRendering(extraProps) { - var props = _extends({}, extraProps); - return _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_PriceRanges2.default, props)); - } - - function stubMethod(methodName) { - var returnValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - stubbedMethods.push(methodName); - return _sinon2.default.stub(_PriceRanges2.default.prototype, methodName).returns(returnValue); - } - - context('individual methods', function () { - beforeEach(function () { - stubMethod('render'); - }); - - context('getItemFromFacetValue', function () { - var props = void 0; - var facetValue = void 0; - - beforeEach(function () { - props = { - cssClasses: { - item: 'item', - link: 'link', - active: 'active' - }, - currency: '$' - }; - facetValue = { - from: 1, - to: 10, - isRefined: false, - url: 'url' - }; - }); - - it('should display one range item correctly', function () { - // Given - var component = getComponentWithMockRendering(props); - - // When - var item = component.getItemFromFacetValue(facetValue); - - // Then - (0, _expect2.default)(item).toEqualJSX(_react2.default.createElement( - 'div', - { className: 'item', key: '1_10' }, - _react2.default.createElement( - 'a', - { className: 'link', href: 'url', onClick: function onClick() {} }, - _react2.default.createElement(_Template2.default, { data: _extends({ currency: '$' }, facetValue), templateKey: 'item' }) - ) - )); - }); - it('should display one active range item correctly', function () { - // Given - var component = getComponentWithMockRendering(props); - facetValue.isRefined = true; - - // When - var item = component.getItemFromFacetValue(facetValue); - - // Then - (0, _expect2.default)(item).toEqualJSX(_react2.default.createElement( - 'div', - { className: 'item active', key: '1_10' }, - _react2.default.createElement( - 'a', - { className: 'link', href: 'url', onClick: function onClick() {} }, - _react2.default.createElement(_Template2.default, { data: _extends({ currency: '$' }, facetValue), templateKey: 'item' }) - ) - )); - }); - }); - - context('refine', function () { - it('should call refine from props', function () { - // Given - var mockEvent = { preventDefault: _sinon2.default.spy() }; - var props = { - refine: _sinon2.default.spy() - }; - var component = getComponentWithMockRendering(props); - - // When - component.refine(1, 10, mockEvent); - - // Then - (0, _expect2.default)(mockEvent.preventDefault.called).toBe(true); - (0, _expect2.default)(props.refine.calledWith(1, 10)).toBe(true); - }); - }); - - context('getForm', function () { - it('should call the PriceRangesForm', function () { - // Given - var props = { - cssClasses: 'cssClasses', - labels: { button: 'hello' }, - currency: '$', - refine: 'refine', - facetValues: [{ from: 0, to: 10 }, { from: 10, to: 20 }] - }; - var component = getComponentWithMockRendering(props); - - // When - var form = component.getForm(); - - // Then - (0, _expect2.default)(form).toEqualJSX(_react2.default.createElement(_PriceRangesForm2.default, { - cssClasses: props.cssClasses, - currentRefinement: { from: '', to: '' }, - labels: { button: 'hello', currency: '$' }, - refine: function refine() {} - })); - }); - }); - }); - - context('render', function () { - it('should have the right number of items', function () { - // Given - var mockedGetItem = stubMethod('getItemFromFacetValue'); - var props = { - facetValues: [{}, {}, {}, {}] - }; - - // When - render(props); - - // Then - (0, _expect2.default)(mockedGetItem.called).toBe(true); - (0, _expect2.default)(mockedGetItem.callCount).toBe(4); - }); - it('should wrap the output in a list CSS class', function () { - // Given - stubMethod('getItemFromFacetValue', _ref); - stubMethod('getForm', _ref2); - var props = { - cssClasses: { - list: 'list' - }, - facetValues: [{}, {}, {}, {}] - }; - - // When - var out = render(props); - - // Then - (0, _expect2.default)(out).toEqualJSX(_ref3); - }); - it('starts a refine on click', function () { - // Given - var mockRefined = stubMethod('refine'); - var props = { - facetValues: [{ from: 1, to: 10, isRefined: false }], - templateProps: { - templates: { - item: 'item' - } - } - }; - var component = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_PriceRanges2.default, props)); - var link = _reactAddonsTestUtils2.default.findRenderedDOMComponentWithTag(component, 'a'); - - // When - _reactAddonsTestUtils2.default.Simulate.click(link); - - // Then - (0, _expect2.default)(mockRefined.called).toBe(true); - }); - }); -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRangesForm-test.js b/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRangesForm-test.js deleted file mode 100644 index 699a0184..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/PriceRanges/__tests__/PriceRangesForm-test.js +++ /dev/null @@ -1,140 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -var _PriceRangesForm = require('../PriceRangesForm'); - -var _PriceRangesForm2 = _interopRequireDefault(_PriceRangesForm); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -var _ref = _react2.default.createElement( - 'span', - { className: 'currency' }, - '$ ' -); - -var _ref2 = _react2.default.createElement( - 'span', - { className: 'separator' }, - ' to ' -); - -var _ref3 = _react2.default.createElement( - 'span', - { className: 'currency' }, - '$ ' -); - -var _ref4 = _react2.default.createElement( - 'button', - { className: 'button', type: 'submit' }, - 'Go' -); - -describe('PriceRangesForm', function () { - var renderer = void 0; - beforeEach(function () { - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - }); - - function render() { - var extraProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var props = _extends({}, extraProps); - renderer.render(_react2.default.createElement(_PriceRangesForm2.default, props)); - return renderer.getRenderOutput(); - } - - context('display', function () { - it('should pass all css classes and labels', function () { - var out = render({ - labels: { - currency: '$', - separator: 'to', - button: 'Go' - }, - cssClasses: { - form: 'form', - label: 'label', - input: 'input', - currency: 'currency', - separator: 'separator', - button: 'button' - }, - currentRefinement: { - from: 10, - to: 20 - } - }); - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement( - 'form', - { className: 'form', onSubmit: function onSubmit() {}, ref: 'form' }, - _react2.default.createElement( - 'label', - { className: 'label' }, - _ref, - _react2.default.createElement('input', { className: 'input', onChange: function onChange() {}, ref: 'from', type: 'number', value: 10 }) - ), - _ref2, - _react2.default.createElement( - 'label', - { className: 'label' }, - _ref3, - _react2.default.createElement('input', { className: 'input', onChange: function onChange() {}, ref: 'to', type: 'number', value: 20 }) - ), - _ref4 - )); - }); - }); - - context('submit', function () { - it('starts a refine on submit', function () { - // Given - var refine = _sinon2.default.spy(); - var handleSubmitMock = _sinon2.default.spy(_PriceRangesForm2.default.prototype, 'handleSubmit'); - var component = _reactAddonsTestUtils2.default.renderIntoDocument(_react2.default.createElement(_PriceRangesForm2.default, { - currentRefinement: { - from: 10, - to: 20 - }, - refine: refine - })); - - // When - component.refs.from.value = 10; - _reactAddonsTestUtils2.default.Simulate.change(component.refs.from); - component.refs.to.value = 20; - _reactAddonsTestUtils2.default.Simulate.change(component.refs.to); - _reactAddonsTestUtils2.default.Simulate.submit(component.refs.form); - - // Then - (0, _expect2.default)(handleSubmitMock.calledOnce).toBe(true); - (0, _expect2.default)(refine.calledWith(10, 20)).toBe(true); - }); - }); -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementList.js b/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementList.js deleted file mode 100644 index a1cbf1b5..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementList.js +++ /dev/null @@ -1,248 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _classnames = require('classnames'); - -var _classnames2 = _interopRequireDefault(_classnames); - -var _utils = require('../../lib/utils.js'); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _RefinementListItem = require('./RefinementListItem.js'); - -var _RefinementListItem2 = _interopRequireDefault(_RefinementListItem); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -var _SearchBox = require('../SearchBox'); - -var _SearchBox2 = _interopRequireDefault(_SearchBox); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -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; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var RefinementList = function (_React$Component) { - _inherits(RefinementList, _React$Component); - - function RefinementList(props) { - _classCallCheck(this, RefinementList); - - var _this = _possibleConstructorReturn(this, (RefinementList.__proto__ || Object.getPrototypeOf(RefinementList)).call(this, props)); - - _this.state = { - isShowMoreOpen: false - }; - _this.handleItemClick = _this.handleItemClick.bind(_this); - _this.handleClickShowMore = _this.handleClickShowMore.bind(_this); - return _this; - } - - _createClass(RefinementList, [{ - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps, nextState) { - var isStateDifferent = nextState !== this.state; - var isFacetValuesDifferent = !(0, _isEqual2.default)(this.props.facetValues, nextProps.facetValues); - var shouldUpdate = isStateDifferent || isFacetValuesDifferent; - return shouldUpdate; - } - }, { - key: 'refine', - value: function refine(facetValueToRefine, isRefined) { - this.props.toggleRefinement(facetValueToRefine, isRefined); - } - }, { - key: '_generateFacetItem', - value: function _generateFacetItem(facetValue) { - var subItems = void 0; - var hasChildren = facetValue.data && facetValue.data.length > 0; - if (hasChildren) { - subItems = _react2.default.createElement(RefinementList, _extends({}, this.props, { - depth: this.props.depth + 1, - facetValues: facetValue.data - })); - } - - var url = this.props.createURL(facetValue[this.props.attributeNameKey]); - var templateData = _extends({}, facetValue, { url: url, cssClasses: this.props.cssClasses }); - - var cssClassItem = (0, _classnames2.default)(this.props.cssClasses.item, _defineProperty({}, this.props.cssClasses.active, facetValue.isRefined)); - - var key = facetValue[this.props.attributeNameKey]; - if (facetValue.isRefined !== undefined) { - key += '/' + facetValue.isRefined; - } - - if (facetValue.count !== undefined) { - key += '/' + facetValue.count; - } - - return _react2.default.createElement(_RefinementListItem2.default, { - facetValueToRefine: facetValue[this.props.attributeNameKey], - handleClick: this.handleItemClick, - isRefined: facetValue.isRefined, - itemClassName: cssClassItem, - key: key, - subItems: subItems, - templateData: templateData, - templateKey: 'item', - templateProps: this.props.templateProps - }); - } - - // Click events on DOM tree like LABEL > INPUT will result in two click events - // instead of one. - // No matter the framework, see https://www.google.com/search?q=click+label+twice - // - // Thus making it hard to distinguish activation from deactivation because both click events - // are very close. Debounce is a solution but hacky. - // - // So the code here checks if the click was done on or in a LABEL. If this LABEL - // has a checkbox inside, we ignore the first click event because we will get another one. - // - // We also check if the click was done inside a link and then e.preventDefault() because we already - // handle the url - // - // Finally, we always stop propagation of the event to avoid multiple levels RefinementLists to fail: click - // on child would click on parent also - - }, { - key: 'handleItemClick', - value: function handleItemClick(_ref) { - var facetValueToRefine = _ref.facetValueToRefine, - originalEvent = _ref.originalEvent, - isRefined = _ref.isRefined; - - if ((0, _utils.isSpecialClick)(originalEvent)) { - // do not alter the default browser behavior - // if one special key is down - return; - } - - if (originalEvent.target.tagName === 'INPUT') { - this.refine(facetValueToRefine, isRefined); - return; - } - - var parent = originalEvent.target; - - while (parent !== originalEvent.currentTarget) { - if (parent.tagName === 'LABEL' && (parent.querySelector('input[type="checkbox"]') || parent.querySelector('input[type="radio"]'))) { - return; - } - - if (parent.tagName === 'A' && parent.href) { - originalEvent.preventDefault(); - } - - parent = parent.parentNode; - } - - originalEvent.stopPropagation(); - - this.refine(facetValueToRefine, isRefined); - } - }, { - key: 'handleClickShowMore', - value: function handleClickShowMore() { - var isShowMoreOpen = !this.state.isShowMoreOpen; - this.setState({ isShowMoreOpen: isShowMoreOpen }); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(nextProps) { - if (this.searchbox && !nextProps.isFromSearch) { - this.searchbox.clearInput(); - } - } - }, { - key: 'refineFirstValue', - value: function refineFirstValue() { - var firstValue = this.props.facetValues[0]; - if (firstValue) { - var actualValue = firstValue[this.props.attributeNameKey]; - this.props.toggleRefinement(actualValue); - } - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - // Adding `-lvl0` classes - var cssClassList = [this.props.cssClasses.list]; - if (this.props.cssClasses.depth) { - cssClassList.push('' + this.props.cssClasses.depth + this.props.depth); - } - - var limit = this.state.isShowMoreOpen ? this.props.limitMax : this.props.limitMin; - var displayedFacetValues = this.props.facetValues.slice(0, limit); - var displayShowMore = this.props.showMore === true && - // "Show more" - this.props.facetValues.length > displayedFacetValues.length || - // "Show less", but hide it if the result set changed - this.state.isShowMoreOpen && displayedFacetValues.length > this.props.limitMin; - - var showMoreBtn = displayShowMore ? _react2.default.createElement(_Template2.default, _extends({ - rootProps: { onClick: this.handleClickShowMore }, - templateKey: 'show-more-' + (this.state.isShowMoreOpen ? 'active' : 'inactive') - }, this.props.templateProps)) : undefined; - - var shouldDisableSearchInput = this.props.searchIsAlwaysActive !== true && !(this.props.isFromSearch || displayedFacetValues.length >= limit); - var searchInput = this.props.searchFacetValues ? _react2.default.createElement(_SearchBox2.default, { ref: function ref(i) { - _this2.searchbox = i; - }, - placeholder: this.props.searchPlaceholder, - onChange: this.props.searchFacetValues, - onValidate: function onValidate() { - return _this2.refineFirstValue(); - }, - disabled: shouldDisableSearchInput }) : null; - - var noResults = this.props.searchFacetValues && this.props.isFromSearch && this.props.facetValues.length === 0 ? _react2.default.createElement(_Template2.default, _extends({ - templateKey: 'noResults' - }, this.props.templateProps)) : null; - - return _react2.default.createElement( - 'div', - { className: (0, _classnames2.default)(cssClassList) }, - searchInput, - displayedFacetValues.map(this._generateFacetItem, this), - noResults, - showMoreBtn - ); - } - }]); - - return RefinementList; -}(_react2.default.Component); - -RefinementList.defaultProps = { - cssClasses: {}, - depth: 0, - attributeNameKey: 'name' -}; - -exports.default = RefinementList; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementListItem.js b/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementListItem.js deleted file mode 100644 index 4cdb8c47..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/RefinementListItem.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var RefinementListItem = function (_React$Component) { - _inherits(RefinementListItem, _React$Component); - - function RefinementListItem() { - _classCallCheck(this, RefinementListItem); - - return _possibleConstructorReturn(this, (RefinementListItem.__proto__ || Object.getPrototypeOf(RefinementListItem)).apply(this, arguments)); - } - - _createClass(RefinementListItem, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleClick = this.handleClick.bind(this); - } - }, { - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return !(0, _isEqual2.default)(this.props, nextProps); - } - }, { - key: 'handleClick', - value: function handleClick(originalEvent) { - this.props.handleClick({ - facetValueToRefine: this.props.facetValueToRefine, - isRefined: this.props.isRefined, - originalEvent: originalEvent - }); - } - }, { - key: 'render', - value: function render() { - return _react2.default.createElement( - 'div', - { - className: this.props.itemClassName, - onClick: this.handleClick - }, - _react2.default.createElement(_Template2.default, _extends({ - data: this.props.templateData, - templateKey: this.props.templateKey - }, this.props.templateProps)), - this.props.subItems - ); - } - }]); - - return RefinementListItem; -}(_react2.default.Component); - -exports.default = RefinementListItem; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementList-test.js b/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementList-test.js deleted file mode 100644 index 03b077a9..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementList-test.js +++ /dev/null @@ -1,357 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _enzyme = require('enzyme'); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _RefinementList = require('../RefinementList'); - -var _RefinementList2 = _interopRequireDefault(_RefinementList); - -var _RefinementListItem = require('../RefinementListItem'); - -var _RefinementListItem2 = _interopRequireDefault(_RefinementListItem); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -describe('RefinementList', function () { - var createURL = void 0; - - function shallowRender() { - var extraProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - createURL = _sinon2.default.spy(); - var props = _extends({ - createURL: createURL, - facetValues: [] - }, extraProps); - return (0, _enzyme.shallow)(_react2.default.createElement(_RefinementList2.default, props)); - } - - describe('cssClasses', function () { - it('should add the `list` class to the root element', function () { - // Given - var props = { - cssClasses: { - list: 'list' - } - }; - - // When - var actual = shallowRender(props); - - // Then - (0, _expect2.default)(actual.hasClass('list')).toEqual(true); - }); - - it('should set item classes to the refinements', function () { - // Given - var props = { - cssClasses: { - item: 'item' - }, - facetValues: [{ name: 'foo', isRefined: true }] - }; - - // When - var actual = shallowRender(props).find(_RefinementListItem2.default); - - // Then - (0, _expect2.default)(actual.props().itemClassName).toContain('item'); - }); - - it('should set active classes to the active refinements', function () { - // Given - var props = { - cssClasses: { - active: 'active' - }, - facetValues: [{ name: 'foo', isRefined: true }, { name: 'bar', isRefined: false }] - }; - - // When - var activeItem = shallowRender(props).find({ isRefined: true }); - var inactiveItem = shallowRender(props).find({ isRefined: false }); - - // Then - (0, _expect2.default)(activeItem.props().itemClassName).toContain('active'); - (0, _expect2.default)(inactiveItem.props().itemClassName).toNotContain('active'); - }); - }); - - describe('items', function () { - it('should have the correct names', function () { - // Given - var props = { - facetValues: [{ name: 'foo', isRefined: false }, { name: 'bar', isRefined: false }] - }; - - // When - var items = shallowRender(props).find(_RefinementListItem2.default); - var firstItem = items.at(0); - var secondItem = items.at(1); - - // Then - (0, _expect2.default)(firstItem.props().facetValueToRefine).toEqual('foo'); - (0, _expect2.default)(secondItem.props().facetValueToRefine).toEqual('bar'); - }); - - it('understands attributeNameKey', function () { - // Given - var props = { - facetValues: [{ name: 'no', youpiName: 'hello' }], - attributeNameKey: 'youpiName' - }; - - // When - var items = shallowRender(props).find(_RefinementListItem2.default); - var item = items.at(0); - - // Then - (0, _expect2.default)(item.props().facetValueToRefine).toEqual('hello'); - (0, _expect2.default)(createURL.calledOnce).toBe(true); - (0, _expect2.default)(createURL.args[0][0]).toBe('hello'); - }); - - it('should correctly set if refined or not', function () { - // Given - var props = { - facetValues: [{ name: 'foo', isRefined: false }, { name: 'bar', isRefined: true }] - }; - - // When - var items = shallowRender(props).find(_RefinementListItem2.default); - var firstItem = items.at(0); - var secondItem = items.at(1); - - // Then - (0, _expect2.default)(firstItem.props().isRefined).toEqual(false); - (0, _expect2.default)(secondItem.props().isRefined).toEqual(true); - }); - }); - - describe('count', function () { - it('should pass the count to the templateData', function () { - // Given - var props = { - facetValues: [{ name: 'foo', count: 42 }, { name: 'bar', count: 16 }] - }; - - // When - var items = shallowRender(props).find(_RefinementListItem2.default); - var firstItem = items.at(0); - var secondItem = items.at(1); - - // Then - (0, _expect2.default)(firstItem.props().templateData.count).toEqual(42); - (0, _expect2.default)(secondItem.props().templateData.count).toEqual(16); - }); - }); - - describe('showMore', function () { - it('displays a number of items equal to the limit when showMore: false', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: false, - limitMin: 2 - }; - - // When - var actual = shallowRender(props).find(_RefinementListItem2.default); - - // Then - (0, _expect2.default)(actual.length).toEqual(2); - }); - - it('displays a number of items equal to the limit when showMore: true but not enabled', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: true, - limitMin: 2, - limitMax: 3 - }; - - // When - var actual = shallowRender(props).find(_RefinementListItem2.default); - - // Then - (0, _expect2.default)(actual.length).toEqual(2); - }); - - it('displays a number of items equal to the showMore limit when showMore: true and enabled', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - limitMin: 2, - limitMax: 3, - showMore: true - }; - - // When - var root = shallowRender(props); - root.setState({ isShowMoreOpen: true }); - var actual = root.find(_RefinementListItem2.default); - - // Then - (0, _expect2.default)(actual.length).toEqual(3); - }); - - it('adds a showMore link when the feature is enabled', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: true, - limitMin: 2, - limitMax: 3 - }; - - // When - var root = shallowRender(props); - var actual = root.find('[templateKey="show-more-inactive"]'); - - // Then - (0, _expect2.default)(actual.length).toEqual(1); - }); - - it('does not add a showMore link when the feature is disabled', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: false, - limitMin: 2, - limitMax: 3 - }; - - // When - var root = shallowRender(props); - var actual = root.find('Template').filter({ templateKey: 'show-more-inactive' }); - - // Then - (0, _expect2.default)(actual.length).toEqual(0); - }); - - it('no showMore when: state = open -> values change -> values <= limitMin ', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: true, - limitMin: 2, - limitMax: 5 - }; - - // When - var root = shallowRender(props); - root.instance().handleClickShowMore(); - root.setProps({ facetValues: props.facetValues.slice(2) }); - - // Then - (0, _expect2.default)(root.find({ templateKey: 'show-more-active' }).length).toEqual(0); - }); - - it('does not add a showMore link when the facet values length is equal to the minLimit', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - showMore: true, - limitMin: 3, - limitMax: 4 - }; - - // When - var root = shallowRender(props); - var actual = root.find('Template').filter({ templateKey: 'show-more-inactive' }); - - // Then - (0, _expect2.default)(actual.length).toEqual(0); - }); - - it('changing the state will toggle the number of items displayed', function () { - // Given - var props = { - facetValues: [{ name: 'foo' }, { name: 'bar' }, { name: 'baz' }], - limitMin: 2, - limitMax: 3, - showMore: true - }; - - // When - var root = shallowRender(props); - - // Then: Not opened, initial number displayed - (0, _expect2.default)(root.find(_RefinementListItem2.default).length).toEqual(2); - - // Then: Toggling the state, display the limitMax - root.setState({ isShowMoreOpen: true }); - (0, _expect2.default)(root.find(_RefinementListItem2.default).length).toEqual(3); - - // Then: Toggling the state again, back to the limitMin - root.setState({ isShowMoreOpen: false }); - (0, _expect2.default)(root.find(_RefinementListItem2.default).length).toEqual(2); - }); - }); - - describe('sublist', function () { - it('should create a subList with the sub values', function () { - // Given - var props = { - facetValues: [{ - name: 'foo', - data: [{ name: 'bar' }, { name: 'baz' }] - }] - }; - - // When - var root = shallowRender(props); - var mainItem = root.find(_RefinementListItem2.default).at(0); - var subList = (0, _enzyme.shallow)(mainItem.props().subItems); - var subItems = subList.find(_RefinementListItem2.default); - - // Then - (0, _expect2.default)(mainItem.props().facetValueToRefine).toEqual('foo'); - (0, _expect2.default)(subItems.at(0).props().facetValueToRefine).toEqual('bar'); - (0, _expect2.default)(subItems.at(1).props().facetValueToRefine).toEqual('baz'); - }); - - it('should add depth class for each depth', function () { - // Given - var props = { - cssClasses: { - depth: 'depth-' - }, - facetValues: [{ - name: 'foo', - data: [{ name: 'bar' }, { name: 'baz' }] - }] - }; - - // When - var root = shallowRender(props); - var mainItem = root.find(_RefinementListItem2.default).at(0); - var subList = (0, _enzyme.shallow)(mainItem.props().subItems); - - // Then - (0, _expect2.default)(root.props().className).toContain('depth-0'); - (0, _expect2.default)(subList.props().className).toContain('depth-1'); - }); - }); -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementListItem-test.js b/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementListItem-test.js deleted file mode 100644 index 5bee22ce..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/RefinementList/__tests__/RefinementListItem-test.js +++ /dev/null @@ -1,81 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _RefinementListItem = require('../RefinementListItem'); - -var _RefinementListItem2 = _interopRequireDefault(_RefinementListItem); - -var _Template = require('../../Template'); - -var _Template2 = _interopRequireDefault(_Template); - -var _sinon = require('sinon'); - -var _sinon2 = _interopRequireDefault(_sinon); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -var _ref = _react2.default.createElement('div', null); - -describe('RefinementListItem', function () { - var renderer = void 0; - var props = void 0; - - beforeEach(function () { - props = { - facetValue: 'Hello', - handleClick: _sinon2.default.spy(), - itemClassName: 'item class', - templateData: { template: 'data' }, - templateKey: 'item key', - templateProps: { template: 'props' }, - subItems: _ref - }; - renderer = (0, _reactAddonsTestUtils.createRenderer)(); - }); - - it('renders an item', function () { - var out = render(props); - - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement( - 'div', - { - className: props.itemClassName, - onClick: props.handleClick - }, - _react2.default.createElement(_Template2.default, _extends({ - data: props.templateData, - templateKey: props.templateKey - }, props.templateProps)), - props.subItems - )); - }); - - it('calls the right function', function () { - var out = render(props); - out.props.onClick(); - (0, _expect2.default)(props.handleClick.calledOnce).toBe(true); - }); - - function render(askedProps) { - renderer.render(_react2.default.createElement(_RefinementListItem2.default, askedProps)); - return renderer.getRenderOutput(); - } -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/SearchBox/index.js b/js/instantsearch.js/dist-es5-module/src/components/SearchBox/index.js deleted file mode 100644 index 792991e8..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/SearchBox/index.js +++ /dev/null @@ -1,127 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable max-len, no-extra-parens */ - - -var _ref = _react2.default.createElement( - 'symbol', - { xmlns: 'http://www.w3.org/2000/svg', id: 'sbx-icon-search-12', viewBox: '0 0 40 41' }, - _react2.default.createElement('path', { d: 'M30.967 27.727l-.03-.03c-.778-.777-2.038-.777-2.815 0l-1.21 1.21c-.78.78-.778 2.04 0 2.817l.03.03 4.025-4.027zm1.083 1.084L39.24 36c.778.778.78 2.037 0 2.816l-1.21 1.21c-.777.778-2.038.78-2.816 0l-7.19-7.19 4.026-4.025zM15.724 31.45c8.684 0 15.724-7.04 15.724-15.724C31.448 7.04 24.408 0 15.724 0 7.04 0 0 7.04 0 15.724c0 8.684 7.04 15.724 15.724 15.724zm0-3.93c6.513 0 11.793-5.28 11.793-11.794 0-6.513-5.28-11.793-11.793-11.793C9.21 3.93 3.93 9.21 3.93 15.725c0 6.513 5.28 11.793 11.794 11.793z', - fillRule: 'evenodd' }) -); - -var _ref2 = _react2.default.createElement( - 'symbol', - { xmlns: 'http://www.w3.org/2000/svg', id: 'sbx-icon-clear-2', viewBox: '0 0 20 20' }, - _react2.default.createElement('path', { d: 'M8.96 10L.52 1.562 0 1.042 1.04 0l.522.52L10 8.96 18.438.52l.52-.52L20 1.04l-.52.522L11.04 10l8.44 8.438.52.52L18.96 20l-.522-.52L10 11.04l-8.438 8.44-.52.52L0 18.96l.52-.522L8.96 10z', fillRule: 'evenodd' }) -); - -var _ref3 = _react2.default.createElement( - 'button', - { type: 'submit', title: 'Submit your search query.', className: 'sbx-sffv__submit' }, - _react2.default.createElement( - 'svg', - { role: 'img', 'aria-label': 'Search' }, - _react2.default.createElement('use', { xlinkHref: '#sbx-icon-search-12' }) - ) -); - -var _ref4 = _react2.default.createElement( - 'button', - { type: 'reset', title: 'Clear the search query.', className: 'sbx-sffv__reset' }, - _react2.default.createElement( - 'svg', - { role: 'img', 'aria-label': 'Reset' }, - _react2.default.createElement('use', { xlinkHref: '#sbx-icon-clear-2' }) - ) -); - -var SearchBox = function (_React$Component) { - _inherits(SearchBox, _React$Component); - - function SearchBox() { - _classCallCheck(this, SearchBox); - - return _possibleConstructorReturn(this, (SearchBox.__proto__ || Object.getPrototypeOf(SearchBox)).apply(this, arguments)); - } - - _createClass(SearchBox, [{ - key: 'clearInput', - value: function clearInput() { - if (this.input) { - this.input.value = ''; - } - } - }, { - key: 'validateSearch', - value: function validateSearch(e) { - e.preventDefault(); - if (this.input) { - var inputValue = this.input.value; - if (inputValue) this.props.onValidate(); - } - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - placeholder = _props.placeholder, - _onChange = _props.onChange; - - var inputCssClasses = this.props.disabled ? 'sbx-sffv__input sbx-sffv__input-disabled' : 'sbx-sffv__input'; - var formCssClasses = this.props.disabled ? 'searchbox sbx-sffv sbx-sffv-disabled' : 'searchbox sbx-sffv'; - - return _react2.default.createElement( - 'form', - { noValidate: 'novalidate', - className: formCssClasses, - onReset: function onReset() { - _onChange(''); - }, - onSubmit: function onSubmit(e) { - return _this2.validateSearch(e); - } - }, - _react2.default.createElement( - 'svg', - { xmlns: 'http://www.w3.org/2000/svg', style: { display: 'none' } }, - _ref, - _ref2 - ), - _react2.default.createElement( - 'div', - { role: 'search', className: 'sbx-sffv__wrapper' }, - _react2.default.createElement('input', { type: 'search', name: 'search', placeholder: placeholder, autoComplete: 'off', required: 'required', className: inputCssClasses, onChange: function onChange(e) { - return _onChange(e.target.value); - }, ref: function ref(i) { - _this2.input = i; - }, disabled: this.props.disabled }), - _ref3, - _ref4 - ) - ); - } - }]); - - return SearchBox; -}(_react2.default.Component); - -exports.default = SearchBox; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Selector.js b/js/instantsearch.js/dist-es5-module/src/components/Selector.js deleted file mode 100644 index a39a5462..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Selector.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Selector = function (_React$Component) { - _inherits(Selector, _React$Component); - - function Selector() { - _classCallCheck(this, Selector); - - return _possibleConstructorReturn(this, (Selector.__proto__ || Object.getPrototypeOf(Selector)).apply(this, arguments)); - } - - _createClass(Selector, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleChange = this.handleChange.bind(this); - } - }, { - key: 'handleChange', - value: function handleChange(event) { - this.props.setValue(event.target.value); - } - }, { - key: 'render', - value: function render() { - var _this2 = this; - - var _props = this.props, - currentValue = _props.currentValue, - options = _props.options; - - - return _react2.default.createElement( - 'select', - { - className: this.props.cssClasses.root, - onChange: this.handleChange, - value: currentValue - }, - options.map(function (option) { - return _react2.default.createElement( - 'option', - { - className: _this2.props.cssClasses.item, - key: option.value, - value: option.value }, - option.label - ); - }) - ); - } - }]); - - return Selector; -}(_react2.default.Component); - -exports.default = Selector; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Slider/Slider.js b/js/instantsearch.js/dist-es5-module/src/components/Slider/Slider.js deleted file mode 100644 index 5f9c3a6f..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Slider/Slider.js +++ /dev/null @@ -1,113 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _omit = require('lodash/omit'); - -var _omit2 = _interopRequireDefault(_omit); - -var _reactNouislider = require('react-nouislider'); - -var _reactNouislider2 = _interopRequireDefault(_reactNouislider); - -var _isEqual = require('lodash/isEqual'); - -var _isEqual2 = _interopRequireDefault(_isEqual); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var cssPrefix = 'ais-range-slider--'; - -var Slider = function (_React$Component) { - _inherits(Slider, _React$Component); - - function Slider() { - _classCallCheck(this, Slider); - - return _possibleConstructorReturn(this, (Slider.__proto__ || Object.getPrototypeOf(Slider)).apply(this, arguments)); - } - - _createClass(Slider, [{ - key: 'componentWillMount', - value: function componentWillMount() { - this.handleChange = this.handleChange.bind(this); - } - }, { - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return !(0, _isEqual2.default)(this.props.range, nextProps.range) || !(0, _isEqual2.default)(this.props.start, nextProps.start); - } - - // we are only interested in rawValues - - }, { - key: 'handleChange', - value: function handleChange(formattedValues, handleId, rawValues) { - this.props.onChange(rawValues); - } - }, { - key: 'render', - value: function render() { - // display a `disabled` state of the `NoUiSlider` when range.min === range.max - var _props$range = this.props.range, - min = _props$range.min, - max = _props$range.max; - - var isDisabled = min === max; - - // when range.min === range.max, we only want to add a little more to the max - // to display the same value in the UI, but the `NoUiSlider` wont - // throw an error since they are not the same value. - var range = isDisabled ? { min: min, max: min + 0.0001 } : { min: min, max: max }; - - // setup pips - var pips = void 0; - if (this.props.pips === false) { - pips = undefined; - } else if (this.props.pips === true || typeof this.props.pips === 'undefined') { - pips = { - mode: 'positions', - density: 3, - values: [0, 50, 100], - stepped: true - }; - } else { - pips = this.props.pips; - } - - return _react2.default.createElement(_reactNouislider2.default - // NoUiSlider also accepts a cssClasses prop, but we don't want to - // provide one. - , _extends({}, (0, _omit2.default)(this.props, ['cssClasses', 'range']), { - animate: false, - behaviour: 'snap', - connect: true, - cssPrefix: cssPrefix, - onChange: this.handleChange, - range: range, - disabled: isDisabled, - pips: pips - })); - } - }]); - - return Slider; -}(_react2.default.Component); - -exports.default = Slider; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Slider/__tests__/Slider-test.js b/js/instantsearch.js/dist-es5-module/src/components/Slider/__tests__/Slider-test.js deleted file mode 100644 index 7efc65ce..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Slider/__tests__/Slider-test.js +++ /dev/null @@ -1,94 +0,0 @@ -'use strict'; - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -var _Slider = require('../Slider'); - -var _Slider2 = _interopRequireDefault(_Slider); - -var _reactNouislider = require('react-nouislider'); - -var _reactNouislider2 = _interopRequireDefault(_reactNouislider); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* eslint-env mocha */ - -_expect2.default.extend(_expectJsx2.default); - -describe('Slider', function () { - // to ensure the global.window is set - - var renderer = void 0; - var props = void 0; - - beforeEach(function () { - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - - props = { - range: { min: 0, max: 5000 }, - format: { to: function to() {}, from: function from() {} } - }; - }); - - it('should render ', function () { - var out = render(); - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement(_reactNouislider2.default, { - animate: false, - behaviour: 'snap', - connect: true, - cssPrefix: 'ais-range-slider--', - format: { to: function to() {}, from: function from() {} }, - onChange: function onChange() {}, - pips: { - density: 3, - mode: 'positions', - stepped: true, - values: [0, 50, 100] - }, - range: props.range - })); - }); - - it('should render when ranges are equal', function () { - props.range.min = props.range.max = 8; - var out = render(); - (0, _expect2.default)(out).toEqualJSX(_react2.default.createElement(_reactNouislider2.default, { - animate: false, - behaviour: 'snap', - connect: true, - cssPrefix: 'ais-range-slider--', - format: { to: function to() {}, from: function from() {} }, - onChange: function onChange() {}, - pips: { - density: 3, - mode: 'positions', - stepped: true, - values: [0, 50, 100] - }, - range: { min: props.range.min, max: props.range.min + 0.0001 }, - disabled: true - })); - }); - - function render() { - renderer.render(_react2.default.createElement(_Slider2.default, props)); - return renderer.getRenderOutput(); - } -}); \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Stats/Stats.js b/js/instantsearch.js/dist-es5-module/src/components/Stats/Stats.js deleted file mode 100644 index 683f5a03..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Stats/Stats.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || 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; }; - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _Template = require('../Template.js'); - -var _Template2 = _interopRequireDefault(_Template); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var Stats = function (_React$Component) { - _inherits(Stats, _React$Component); - - function Stats() { - _classCallCheck(this, Stats); - - return _possibleConstructorReturn(this, (Stats.__proto__ || Object.getPrototypeOf(Stats)).apply(this, arguments)); - } - - _createClass(Stats, [{ - key: 'shouldComponentUpdate', - value: function shouldComponentUpdate(nextProps) { - return this.props.nbHits !== nextProps.hits || this.props.processingTimeMS !== nextProps.processingTimeMS; - } - }, { - key: 'render', - value: function render() { - var data = { - hasManyResults: this.props.nbHits > 1, - hasNoResults: this.props.nbHits === 0, - hasOneResult: this.props.nbHits === 1, - hitsPerPage: this.props.hitsPerPage, - nbHits: this.props.nbHits, - nbPages: this.props.nbPages, - page: this.props.page, - processingTimeMS: this.props.processingTimeMS, - query: this.props.query, - cssClasses: this.props.cssClasses - }; - - return _react2.default.createElement(_Template2.default, _extends({ data: data, templateKey: 'body' }, this.props.templateProps)); - } - }]); - - return Stats; -}(_react2.default.Component); - -exports.default = Stats; \ No newline at end of file diff --git a/js/instantsearch.js/dist-es5-module/src/components/Stats/__tests__/Stats-test.js b/js/instantsearch.js/dist-es5-module/src/components/Stats/__tests__/Stats-test.js deleted file mode 100644 index 832e4599..00000000 --- a/js/instantsearch.js/dist-es5-module/src/components/Stats/__tests__/Stats-test.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -var _extends = Object.assign || 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; }; /* eslint-env mocha */ - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _expect = require('expect'); - -var _expect2 = _interopRequireDefault(_expect); - -var _reactAddonsTestUtils = require('react-addons-test-utils'); - -var _reactAddonsTestUtils2 = _interopRequireDefault(_reactAddonsTestUtils); - -var _Stats = require('../Stats'); - -var _Stats2 = _interopRequireDefault(_Stats); - -var _Template = require('../../Template'); - -var _Template2 = _interopRequireDefault(_Template); - -var _expectJsx = require('expect-jsx'); - -var _expectJsx2 = _interopRequireDefault(_expectJsx); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -_expect2.default.extend(_expectJsx2.default); - -describe('Stats', function () { - var renderer = void 0; - - beforeEach(function () { - var createRenderer = _reactAddonsTestUtils2.default.createRenderer; - - renderer = createRenderer(); - }); - - it('should render