From debe9a1290e1eeded615cd67ef4e5253e8fc16c3 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 20 Nov 2024 18:58:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20meilisearc?= =?UTF-8?q?h=20=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Components/GlobalSearch.razor | 48 +--- .../Components/GlobalSearch.razor.cs | 31 --- .../Components/GlobalSearch.razor.css | 238 ------------------ .../Components/GlobalSearch.razor.js | 212 ---------------- .../lib/meilisearch/meilisearch.umd.min.js | 2 - 5 files changed, 2 insertions(+), 529 deletions(-) delete mode 100644 src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.cs delete mode 100644 src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.css delete mode 100644 src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.js delete mode 100644 src/BootstrapBlazor.Server/wwwroot/lib/meilisearch/meilisearch.umd.min.js diff --git a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor b/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor index bef80a1b140..52e48b46e61 100644 --- a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor +++ b/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor @@ -1,47 +1,3 @@ -@inherits WebSiteModuleComponentBase -@attribute [JSModuleAutoLoader("Components/GlobalSearch.razor.js")] -@inject IStringLocalizer Localizer +@inject IStringLocalizer Localizer - + diff --git a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.cs b/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.cs deleted file mode 100644 index d39cddd4066..00000000000 --- a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the Apache 2.0 License -// See the LICENSE file in the project root for more information. -// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone - -using BootstrapBlazor.MeiliSearch.Options; -using Microsoft.Extensions.Options; -using System.Globalization; - -namespace BootstrapBlazor.Server.Components.Components; - -/// -/// Pre 组件 -/// -public partial class GlobalSearch -{ - [Inject, NotNull] - private IOptionsMonitor? Options { get; set; } - - /// - /// - /// - /// - protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, new - { - Options.CurrentValue?.Url, - Options.CurrentValue?.ApiKey, - Index = $"{Options.CurrentValue?.Index}-{CultureInfo.CurrentUICulture.Name}", - SearchStatus = Localizer["SearchStatus"].Value - }); -} diff --git a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.css b/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.css deleted file mode 100644 index 979c261df45..00000000000 --- a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.css +++ /dev/null @@ -1,238 +0,0 @@ -.bb-g-search { - --bb-global-search-top: 92px; - --bb-global-search-left: 10px; - --bb-global-search-right: 10px; - display: flex; - align-items: center; - color: var(--bb-header-dropdown-color); - border: var(--bs-border-width) solid var(--bb-header-dropdown-border-color); - border-radius: var(--bs-border-radius); - padding: 0.25rem 0.75rem; - width: 168px; - margin-bottom: .5rem; - font-size: .875rem; - transition: border-color .3s linear; -} - - .bb-g-search:hover { - --bb-header-dropdown-border-color: #fff; - } - - .bb-g-search input { - width: 100%; - background-color: transparent; - border: none; - line-height: 25px; - padding: 0; - margin: 0 .5rem; - cursor: pointer; - } - - .bb-g-search input::placeholder { - color: rgba(var(--bb-header-dropdown-color-rgb), 0.5); - } - - .bb-g-search i { - cursor: pointer; - } - -.search-dialog-mask { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 40; - background-color: #000; - opacity: 0.3; -} - - .search-dialog-mask:not(.show), - .search-dialog:not(.show) { - display: none; - } - -.search-dialog { - position: fixed; - top: var(--bb-global-search-top); - left: var(--bb-global-search-left); - right: var(--bb-global-search-right); - z-index: 50; - height: calc(100vh - 160px); - color: var(--bs-body-color); - background-color: var(--bs-body-bg); - border-radius: var(--bs-border-radius); - border: var(--bs-border-width) solid var(--bs-border-color); - overflow: auto; - padding: 1rem; -} - -.search-dialog-input { - border-radius: 10px; - border: var(--bs-border-width) solid var(--bs-border-color); - display: flex; - align-items: center; - padding: 0.375rem 0.75rem; - transition: border-color .3s linear; -} - - .search-dialog-input input { - background-color: transparent; - border: none; - line-height: 25px; - padding: 0; - margin: 0 .5rem; - } - - .search-dialog-input input::placeholder { - color: rgba(var(--bs-body-color-rgb), 0.5); - } - - .search-dialog-input:has(input:focus) { - border-color: var(--bb-primary-color); - } - -.search-dialog-status { - border-bottom: var(--bs-border-width) solid var(--bs-border-color); - padding: 0 1rem; - font-size: .75rem; - display: block; - margin: 0 -1rem .5rem -1rem; - color: rgba(var(--bs-body-color-rgb), 0.5); - line-height: 34px; -} - -.search-dialog-main { - display: flex; - height: calc(100% - 82px); - margin: 0 -.5rem; -} - -.search-dialog-menu { - flex-basis: 240px; - margin-inline-start: 0.5rem; - padding: .5rem .25rem; - border: var(--bs-border-width) solid var(--bs-border-color); - border-radius: var(--bs-border-radius); - font-size: 13px; - display: none; -} - - .search-dialog-menu ::deep .search-dialog-menu-item { - padding: .25rem .5rem; - display: block; - color: var(--bs-body-color); - border-radius: var(--bs-border-radius); - } - - .search-dialog-menu ::deep .search-dialog-menu-item:not(:last-child) { - margin-bottom: .125rem; - } - - .search-dialog-menu ::deep .search-dialog-menu-item:hover { - background-color: rgba(var(--bb-primary-color-rgb), 0.4); - } - - .search-dialog-menu ::deep .search-dialog-menu-item.active { - background-color: rgba(var(--bb-primary-color-rgb), 0.5); - } - -.search-dialog-list { - flex: 1; - overflow: auto; - border: var(--bs-border-width) solid var(--bs-border-color); - border-radius: var(--bs-border-radius); - padding: .25rem; -} - - .search-dialog-list .search-dialog-item { - display: block; - border: var(--bs-border-width) solid var(--bs-border-color); - border-radius: var(--bs-border-radius); - padding: .5rem; - position: relative; - transition: border-color .3s linear, background-color .3s linear; - } - - .search-dialog-list .search-dialog-item:not(:first-child) { - margin-top: .5rem; - } - - .search-dialog-list .search-dialog-item:hover { - border: var(--bs-border-width) solid var(--bs-border-color); - } - - .search-dialog-list .search-dialog-item a { - color: var(--bs-body-color); - } - - .search-dialog-list .search-dialog-item .badge { - --bs-badge-border-radius: 50%; - position: absolute; - top: 4px; - margin-inline-start: 4px; - } - - .search-dialog-list .search-dialog-item .search-dialog-item-sub { - font-size: .75rem; - margin-top: .25rem; - opacity: .8; - } - - .search-dialog-list .search-dialog-item li { - padding: .125rem; - border-radius: var(--bs-border-radius); - transition: background-color .3s linear; - } - - .search-dialog-list .search-dialog-item li:not(:first-child) { - margin-top: .125rem; - } - - .search-dialog-list .search-dialog-item li > a { - display: block; - padding: .125rem; - font-size: .75rem; - } - - .search-dialog-list .search-dialog-item li:hover { - background-color: rgba(var(--bb-primary-color-rgb), 0.5); - } - - .search-dialog-list .search-dialog-item ::deep key { - display: inline-block; - margin: 0; - color: var(--bb-primary-color); - font-weight: bold; - } - - .search-dialog-list .search-dialog-empty-template { - text-align: center; - padding: 24px; - display: block; - } - -@media (min-width: 768px) { - .search-dialog-menu.show { - display: block; - } - - .bb-g-search { - --bb-global-search-top: 72px; - --bb-global-search-left: 20px; - --bb-global-search-right: 20px; - margin-bottom: 0; - margin-inline-end: .5rem; - } - - .search-dialog { - width: 700px; - margin: 0 auto; - } -} - -@media (min-width: 992px) { - .search-dialog { - width: 900px; - } -} diff --git a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.js b/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.js deleted file mode 100644 index 916a3e8ece9..00000000000 --- a/src/BootstrapBlazor.Server/Components/Components/GlobalSearch.razor.js +++ /dev/null @@ -1,212 +0,0 @@ -import { addScript, debounce, isMobile } from "../../_content/BootstrapBlazor/modules/utility.js" -import Data from "../../_content/BootstrapBlazor/modules/data.js" -import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js" - -export async function init(id, options) { - await addScript('../../lib/meilisearch/meilisearch.umd.min.js') - - const el = document.getElementById(id); - const search = { - el, options, - searchText: 'searching ...', - status: el.querySelector('.search-dialog-status'), - menu: el.querySelector('.search-dialog-menu'), - list: el.querySelector('.search-dialog-list'), - template: el.querySelector('.search-dialog-item-template'), - blockTemplate: el.querySelector('.search-dialog-block-template'), - emptyTemplate: el.querySelector('.search-dialog-empty-template'), - dialog: el.querySelector('.search-dialog'), - mask: el.querySelector('.search-dialog-mask') - }; - Data.set(id, search); - - handlerClearButton(search); - handlerSearch(search); - handlerToggle(search); - handlerMask(search); - - resetStatus(search); - - new bootstrap.ScrollSpy(search.list, { - target: '.search-dialog-menu' - }) -} - -export function dispose(id) { - const search = Data.get(id); - Data.remove(id); - - if (search) { - const { el, menu, dialog, clearButton, input } = search; - EventHandler.off(clearButton, 'click'); - EventHandler.off(dialog, 'click'); - EventHandler.off(input, 'keyup'); - EventHandler.off(input, 'input'); - EventHandler.off(menu, 'click'); - EventHandler.off(el, 'click'); - EventHandler.off(document, 'click'); - } -} - -const handlerMask = search => { - const { mask } = search; - document.body.appendChild(mask); -} - -const handlerToggle = search => { - const { el, mask, dialog, input } = search; - EventHandler.on(dialog, 'click', e => { - e.stopPropagation(); - }); - EventHandler.on(el, 'click', e => { - mask.classList.toggle('show'); - dialog.classList.toggle('show'); - if (dialog.classList.contains('show')) { - input.focus(); - if (!isMobile()) { - input.select(); - } - } - }); - EventHandler.on(document, 'click', e => { - const element = e.target.closest('.bb-g-search'); - if (element === null) { - closeDialog(search); - } - }); -} - -const handlerClearButton = search => { - const clearButton = search.el.querySelector('.search-dialog-clear'); - EventHandler.on(clearButton, 'click', () => { - resetStatus(search); - }); - search.clearButton = clearButton; -} - -const handlerSearch = search => { - const input = search.el.querySelector('.search-dialog-input > input'); - EventHandler.on(input, 'keyup', e => { - if (e.key === 'Enter') { - doSearch(search, input.value); - if (!isMobile()) { - input.select(); - } - } - else if (e.key === 'Escape') { - resetStatus(search); - } - }); - const fn = debounce(doSearch); - EventHandler.on(input, 'input', () => { - fn(search, input.value); - }); - search.input = input; - - EventHandler.on(search.menu, 'click', '.search-dialog-menu-item', e => { - e.preventDefault(); - - const link = e.delegateTarget; - const target = link.getAttribute('href'); - if (target) { - const targetEl = document.querySelector(target); - - if (targetEl) { - targetEl.scrollIntoView(true); - } - } - }); -} - -const doSearch = async (search, query) => { - if (query) { - search.status.innerHTML = search.searchText; - const client = new MeiliSearch({ - host: search.options.url, - apiKey: search.options.apiKey, - }); - var index = client.index(search.options.index); - const result = await index.search(query); - updateStatus(search, result.estimatedTotalHits, result.processingTimeMs); - updateList(search, result); - } -} - -const updateList = (search, result) => { - const { menu, list, input, template, blockTemplate } = search; - list.innerHTML = ''; - menu.innerHTML = ''; - menu.classList.add('show'); - - const html = template.innerHTML; - const blockHtml = blockTemplate.innerHTML; - - result.hits.forEach(hit => { - const link = document.createElement('a'); - link.className = "search-dialog-menu-item"; - link.setAttribute('href', `#hit${hit.id}`); - link.innerHTML = hit.menu; - menu.appendChild(link); - - if (hit.title === '') { - return; - } - const div = document.createElement('div'); - div.innerHTML = html.replace('{url}', hit.url) - .replace('{title}', highlight(hit.title, result.query)) - .replace('{sub-title}', highlight(hit.subTitle, result.query)) - .replace('{count}', hit.demos.length); - const item = div.firstChild; - item.setAttribute("id", `hit${hit.id}`); - - if (hit.demos) { - const ul = document.createElement('ol'); - ul.classList.add('mb-0'); - ul.classList.add('mt-2') - hit.demos.forEach(block => { - const li = document.createElement('ul'); - const url = block.url || hit.url; - li.innerHTML = blockHtml.replace('{url}', url) - .replace('{title}', highlight(block.title, result.query)) - .replace('{intro}', highlight(block.intro, result.query)); - ul.appendChild(li.firstChild); - }); - item.appendChild(ul); - } - list.appendChild(item); - }); - input.focus(); - - bootstrap.ScrollSpy.getInstance(list).refresh() -} - -const highlight = (text, query) => { - const regex = new RegExp(query, 'i'); - return text.replace(regex, `${query}`); -} - -const updateStatus = (search, hits, ms) => { - const status = search.status; - status.innerHTML = `Found ${hits} results in ${ms}ms`; -} - -const resetStatus = search => { - const { options, status, input, list, menu, emptyTemplate } = search; - status.innerHTML = options.searchStatus; - - if (input.value === '') { - closeDialog(search); - } - else { - input.value = ''; - list.innerHTML = emptyTemplate.outerHTML; - menu.innerHTML = ''; - menu.classList.remove('show'); - } -} - -const closeDialog = search => { - const { mask, dialog } = search; - dialog.classList.remove('show'); - mask.classList.remove('show'); -} diff --git a/src/BootstrapBlazor.Server/wwwroot/lib/meilisearch/meilisearch.umd.min.js b/src/BootstrapBlazor.Server/wwwroot/lib/meilisearch/meilisearch.umd.min.js deleted file mode 100644 index 74f959f9e4a..00000000000 --- a/src/BootstrapBlazor.Server/wwwroot/lib/meilisearch/meilisearch.umd.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e={TASK_SUCCEEDED:"succeeded",TASK_PROCESSING:"processing",TASK_FAILED:"failed",TASK_ENQUEUED:"enqueued",TASK_CANCELED:"canceled"},n={INDEX_CREATION_FAILED:"index_creation_failed",MISSING_INDEX_UID:"missing_index_uid",INDEX_ALREADY_EXISTS:"index_already_exists",INDEX_NOT_FOUND:"index_not_found",INVALID_INDEX_UID:"invalid_index_uid",INDEX_NOT_ACCESSIBLE:"index_not_accessible",INVALID_INDEX_OFFSET:"invalid_index_offset",INVALID_INDEX_LIMIT:"invalid_index_limit",INVALID_STATE:"invalid_state",PRIMARY_KEY_INFERENCE_FAILED:"primary_key_inference_failed",INDEX_PRIMARY_KEY_ALREADY_EXISTS:"index_primary_key_already_exists",INVALID_INDEX_PRIMARY_KEY:"invalid_index_primary_key",DOCUMENTS_FIELDS_LIMIT_REACHED:"document_fields_limit_reached",MISSING_DOCUMENT_ID:"missing_document_id",INVALID_DOCUMENT_ID:"invalid_document_id",INVALID_CONTENT_TYPE:"invalid_content_type",MISSING_CONTENT_TYPE:"missing_content_type",INVALID_DOCUMENT_FIELDS:"invalid_document_fields",INVALID_DOCUMENT_LIMIT:"invalid_document_limit",INVALID_DOCUMENT_OFFSET:"invalid_document_offset",INVALID_DOCUMENT_FILTER:"invalid_document_filter",MISSING_DOCUMENT_FILTER:"missing_document_filter",INVALID_DOCUMENT_VECTORS_FIELD:"invalid_document_vectors_field",PAYLOAD_TOO_LARGE:"payload_too_large",MISSING_PAYLOAD:"missing_payload",MALFORMED_PAYLOAD:"malformed_payload",NO_SPACE_LEFT_ON_DEVICE:"no_space_left_on_device",INVALID_STORE_FILE:"invalid_store_file",INVALID_RANKING_RULES:"missing_document_id",INVALID_REQUEST:"invalid_request",INVALID_DOCUMENT_GEO_FIELD:"invalid_document_geo_field",INVALID_SEARCH_Q:"invalid_search_q",INVALID_SEARCH_OFFSET:"invalid_search_offset",INVALID_SEARCH_LIMIT:"invalid_search_limit",INVALID_SEARCH_PAGE:"invalid_search_page",INVALID_SEARCH_HITS_PER_PAGE:"invalid_search_hits_per_page",INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE:"invalid_search_attributes_to_retrieve",INVALID_SEARCH_ATTRIBUTES_TO_CROP:"invalid_search_attributes_to_crop",INVALID_SEARCH_CROP_LENGTH:"invalid_search_crop_length",INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT:"invalid_search_attributes_to_highlight",INVALID_SEARCH_SHOW_MATCHES_POSITION:"invalid_search_show_matches_position",INVALID_SEARCH_FILTER:"invalid_search_filter",INVALID_SEARCH_SORT:"invalid_search_sort",INVALID_SEARCH_FACETS:"invalid_search_facets",INVALID_SEARCH_HIGHLIGHT_PRE_TAG:"invalid_search_highlight_pre_tag",INVALID_SEARCH_HIGHLIGHT_POST_TAG:"invalid_search_highlight_post_tag",INVALID_SEARCH_CROP_MARKER:"invalid_search_crop_marker",INVALID_SEARCH_MATCHING_STRATEGY:"invalid_search_matching_strategy",INVALID_SEARCH_VECTOR:"invalid_search_vector",INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON:"invalid_search_attributes_to_search_on",BAD_REQUEST:"bad_request",DOCUMENT_NOT_FOUND:"document_not_found",INTERNAL:"internal",INVALID_API_KEY:"invalid_api_key",INVALID_API_KEY_DESCRIPTION:"invalid_api_key_description",INVALID_API_KEY_ACTIONS:"invalid_api_key_actions",INVALID_API_KEY_INDEXES:"invalid_api_key_indexes",INVALID_API_KEY_EXPIRES_AT:"invalid_api_key_expires_at",API_KEY_NOT_FOUND:"api_key_not_found",IMMUTABLE_API_KEY_UID:"immutable_api_key_uid",IMMUTABLE_API_KEY_ACTIONS:"immutable_api_key_actions",IMMUTABLE_API_KEY_INDEXES:"immutable_api_key_indexes",IMMUTABLE_API_KEY_EXPIRES_AT:"immutable_api_key_expires_at",IMMUTABLE_API_KEY_CREATED_AT:"immutable_api_key_created_at",IMMUTABLE_API_KEY_UPDATED_AT:"immutable_api_key_updated_at",MISSING_AUTHORIZATION_HEADER:"missing_authorization_header",UNRETRIEVABLE_DOCUMENT:"unretrievable_document",MAX_DATABASE_SIZE_LIMIT_REACHED:"database_size_limit_reached",TASK_NOT_FOUND:"task_not_found",DUMP_PROCESS_FAILED:"dump_process_failed",DUMP_NOT_FOUND:"dump_not_found",INVALID_SWAP_DUPLICATE_INDEX_FOUND:"invalid_swap_duplicate_index_found",INVALID_SWAP_INDEXES:"invalid_swap_indexes",MISSING_SWAP_INDEXES:"missing_swap_indexes",MISSING_MASTER_KEY:"missing_master_key",INVALID_TASK_TYPES:"invalid_task_types",INVALID_TASK_UIDS:"invalid_task_uids",INVALID_TASK_STATUSES:"invalid_task_statuses",INVALID_TASK_LIMIT:"invalid_task_limit",INVALID_TASK_FROM:"invalid_task_from",INVALID_TASK_CANCELED_BY:"invalid_task_canceled_by",MISSING_TASK_FILTERS:"missing_task_filters",TOO_MANY_OPEN_FILES:"too_many_open_files",IO_ERROR:"io_error",INVALID_TASK_INDEX_UIDS:"invalid_task_index_uids",IMMUTABLE_INDEX_UID:"immutable_index_uid",IMMUTABLE_INDEX_CREATED_AT:"immutable_index_created_at",IMMUTABLE_INDEX_UPDATED_AT:"immutable_index_updated_at",INVALID_SETTINGS_DISPLAYED_ATTRIBUTES:"invalid_settings_displayed_attributes",INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES:"invalid_settings_searchable_attributes",INVALID_SETTINGS_FILTERABLE_ATTRIBUTES:"invalid_settings_filterable_attributes",INVALID_SETTINGS_SORTABLE_ATTRIBUTES:"invalid_settings_sortable_attributes",INVALID_SETTINGS_RANKING_RULES:"invalid_settings_ranking_rules",INVALID_SETTINGS_STOP_WORDS:"invalid_settings_stop_words",INVALID_SETTINGS_SYNONYMS:"invalid_settings_synonyms",INVALID_SETTINGS_DISTINCT_ATTRIBUTE:"invalid_settings_distinct_attribute",INVALID_SETTINGS_TYPO_TOLERANCE:"invalid_settings_typo_tolerance",INVALID_SETTINGS_FACETING:"invalid_settings_faceting",INVALID_SETTINGS_PAGINATION:"invalid_settings_pagination",INVALID_SETTINGS_SEARCH_CUTOFF_MS:"invalid_settings_search_cutoff_ms",INVALID_TASK_BEFORE_ENQUEUED_AT:"invalid_task_before_enqueued_at",INVALID_TASK_AFTER_ENQUEUED_AT:"invalid_task_after_enqueued_at",INVALID_TASK_BEFORE_STARTED_AT:"invalid_task_before_started_at",INVALID_TASK_AFTER_STARTED_AT:"invalid_task_after_started_at",INVALID_TASK_BEFORE_FINISHED_AT:"invalid_task_before_finished_at",INVALID_TASK_AFTER_FINISHED_AT:"invalid_task_after_finished_at",MISSING_API_KEY_ACTIONS:"missing_api_key_actions",MISSING_API_KEY_INDEXES:"missing_api_key_indexes",MISSING_API_KEY_EXPIRES_AT:"missing_api_key_expires_at",INVALID_API_KEY_LIMIT:"invalid_api_key_limit",INVALID_API_KEY_OFFSET:"invalid_api_key_offset",INVALID_FACET_SEARCH_FACET_NAME:"invalid_facet_search_facet_name",MISSING_FACET_SEARCH_FACET_NAME:"missing_facet_search_facet_name",INVALID_FACET_SEARCH_FACET_QUERY:"invalid_facet_search_facet_query"};function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function s(t){for(var e=1;e=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return s("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),o=r.call(a,"finallyLoc");if(c&&o){if(this.prev=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&r.call(s,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var s=r.arg;D(n)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:N(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},e}function a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function c(t,e,n,r,s,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,s)}function o(t){return function(){var e=this,n=arguments;return new Promise((function(r,s){var i=t.apply(e,n);function a(t){c(i,r,s,a,u,"next",t)}function u(t){c(i,r,s,a,u,"throw",t)}a(void 0)}))}}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}var T=function(t){l(n,t);var e=A(n);function n(t){var r;return p(this,n),r=e.call(this,t),Object.setPrototypeOf(m(r),n.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(m(r),n),r}return f(n)}(x(Error)),S=function(t){l(n,t);var e=A(n);function n(t,r,s,i){var a,u,c,o;(p(this,n),d(m(a=e.call(this,t)),"statusCode",void 0),d(m(a),"errno",void 0),d(m(a),"code",void 0),d(m(a),"stack",void 0),Object.setPrototypeOf(m(a),n.prototype),a.name="MeiliSearchCommunicationError",r instanceof Response&&(a.message=r.statusText,a.statusCode=r.status),r instanceof Error&&(a.errno=r.errno,a.code=r.code),i)?(a.stack=i,a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Failed to fetch","request to ".concat(s," failed, reason: connect ECONNREFUSED")),a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace("Not Found","Not Found: ".concat(s))):Error.captureStackTrace&&Error.captureStackTrace(m(a),n);return a}return f(n)}(T),D=function(t){l(n,t);var e=A(n);function n(t,r){var s;return p(this,n),d(m(s=e.call(this,t.message)),"httpStatus",void 0),d(m(s),"code",void 0),d(m(s),"link",void 0),d(m(s),"type",void 0),d(m(s),"stack",void 0),Object.setPrototypeOf(m(s),n.prototype),s.name="MeiliSearchApiError",s.code=t.code,s.type=t.type,s.link=t.link,s.message=t.message,s.httpStatus=r,Error.captureStackTrace&&Error.captureStackTrace(m(s),n),s}return f(n)}(T);function R(t){return N.apply(this,arguments)}function N(){return(N=o(i().mark((function t(e){var n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.ok){t.next=11;break}return t.prev=1,t.next=4,e.json();case 4:n=t.sent,t.next=10;break;case 7:throw t.prev=7,t.t0=t.catch(1),new S(e.statusText,e,e.url);case 10:throw new D(n,e.status);case 11:return t.abrupt("return",e);case 12:case"end":return t.stop()}}),t,null,[[1,7]])})))).apply(this,arguments)}function O(t,e,n){if("MeiliSearchApiError"!==t.name)throw new S(t.message,t,n,e);throw t}var q=function(t){l(n,t);var e=A(n);function n(t){var r;return p(this,n),r=e.call(this,t),Object.setPrototypeOf(m(r),n.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(m(r),n),r}return f(n)}(T);function L(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function C(t){return Object.entries(t).reduce((function(t,e){var n=g(e,2),r=n[0],s=n[1];return void 0!==s&&(t[r]=s),t}),{})}function M(t){return P.apply(this,arguments)}function P(){return(P=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){return setTimeout(t,e)}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function U(t){return Object.keys(t).reduce((function(e,n){var r=t[n];return void 0===r?e:Array.isArray(r)?s(s({},e),{},d({},n,r.join(","))):r instanceof Date?s(s({},e),{},d({},n,r.toISOString())):s(s({},e),{},d({},n,r))}),{})}function F(t){var e,n,r="X-Meilisearch-Client",s="Meilisearch JavaScript (v".concat("0.39.0",")"),i=function(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,n){return e[n]=t})),e}return Object.assign({},t)}(null!==(e=null===(n=t.requestConfig)||void 0===n?void 0:n.headers)&&void 0!==e?e:{});if(t.apiKey&&!i.Authorization&&(i.Authorization="Bearer ".concat(t.apiKey)),i["Content-Type"]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var a=t.clientAgents.concat(s);i[r]=a.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new T('Meilisearch: The header "'.concat(r,'" should be an array of string(s).\n'));i[r]=s}return i}var V=function(){function t(e){p(this,t),d(this,"headers",void 0),d(this,"url",void 0),d(this,"requestConfig",void 0),d(this,"httpClient",void 0),d(this,"requestTimeout",void 0),this.headers=F(e),this.requestConfig=e.requestConfig,this.httpClient=e.httpClient,this.requestTimeout=e.timeout;try{var n=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new T("The provided host is not valid.")}var e}(e.host);this.url=new URL(n)}catch(t){throw new T("The provided host is not valid.")}}var e,n,r,a,u,c,h;return f(t,[{key:"request",value:(h=o(i().mark((function t(e){var n,r,a,u,c,o,p,h,f,d,l,v,_,y;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.method,a=e.url,u=e.params,c=e.body,o=e.config,p=void 0===o?{}:o,"undefined"==typeof fetch&&require("cross-fetch/polyfill"),h=new URL(a,this.url),u&&(f=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return f.set(t,u[t])})),h.search=f.toString()),null!==(n=p.headers)&&void 0!==n&&n["Content-Type"]||(c=JSON.stringify(c)),d=s(s({},this.headers),p.headers),t.prev=6,l=this.fetchWithTimeout(h.toString(),s(s(s({},p),this.requestConfig),{},{method:r,body:c,headers:d}),this.requestTimeout),!this.httpClient){t.next=12;break}return t.next=11,l;case 11:return t.abrupt("return",t.sent);case 12:return t.next=14,l.then((function(t){return R(t)}));case 14:return v=t.sent,t.next=17,v.json().catch((function(){}));case 17:return _=t.sent,t.abrupt("return",_);case 21:t.prev=21,t.t0=t.catch(6),y=t.t0.stack,O(t.t0,y,h.toString());case 25:case"end":return t.stop()}}),t,this,[[6,21]])}))),function(t){return h.apply(this,arguments)})},{key:"fetchWithTimeout",value:(c=o(i().mark((function t(e,n,r){var s=this;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,i){var a,u=[(s.httpClient?s.httpClient:fetch)(e,n)];if(r){var c=new Promise((function(t,e){a=setTimeout((function(){e(new Error("Error: Request Timed Out"))}),r)}));u.push(c)}Promise.race(u).then(t).catch(i).finally((function(){clearTimeout(a)}))})));case 1:case"end":return t.stop()}}),t)}))),function(t,e,n){return c.apply(this,arguments)})},{key:"get",value:(u=o(i().mark((function t(e,n,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request({method:"GET",url:e,params:n,config:r});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return u.apply(this,arguments)})},{key:"post",value:(a=o(i().mark((function t(e,n,r,s){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request({method:"POST",url:e,body:n,params:r,config:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,n,r){return a.apply(this,arguments)})},{key:"put",value:(r=o(i().mark((function t(e,n,r,s){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request({method:"PUT",url:e,body:n,params:r,config:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,n,s){return r.apply(this,arguments)})},{key:"patch",value:(n=o(i().mark((function t(e,n,r,s){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request({method:"PATCH",url:e,body:n,params:r,config:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,e,r,s){return n.apply(this,arguments)})},{key:"delete",value:(e=o(i().mark((function t(e,n,r,s){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request({method:"DELETE",url:e,body:n,params:r,config:s});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t,n,r,s){return e.apply(this,arguments)})}]),t}(),j=f((function t(e){p(this,t),d(this,"taskUid",void 0),d(this,"indexUid",void 0),d(this,"status",void 0),d(this,"type",void 0),d(this,"enqueuedAt",void 0),this.taskUid=e.taskUid,this.indexUid=e.indexUid,this.status=e.status,this.type=e.type,this.enqueuedAt=new Date(e.enqueuedAt)})),K=f((function t(e){p(this,t),d(this,"indexUid",void 0),d(this,"status",void 0),d(this,"type",void 0),d(this,"uid",void 0),d(this,"canceledBy",void 0),d(this,"details",void 0),d(this,"error",void 0),d(this,"duration",void 0),d(this,"startedAt",void 0),d(this,"enqueuedAt",void 0),d(this,"finishedAt",void 0),this.indexUid=e.indexUid,this.status=e.status,this.type=e.type,this.uid=e.uid,this.details=e.details,this.canceledBy=e.canceledBy,this.error=e.error,this.duration=e.duration,this.startedAt=new Date(e.startedAt),this.enqueuedAt=new Date(e.enqueuedAt),this.finishedAt=new Date(e.finishedAt)})),G=function(){function t(e){p(this,t),d(this,"httpRequest",void 0),this.httpRequest=new V(e)}var n,r,a,u,c,h;return f(t,[{key:"getTask",value:(h=o(i().mark((function t(e){var n,r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="tasks/".concat(e),t.next=3,this.httpRequest.get(n);case 3:return r=t.sent,t.abrupt("return",new K(r));case 5:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)})},{key:"getTasks",value:(c=o(i().mark((function t(){var e,n,r,a=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=a.length>0&&void 0!==a[0]?a[0]:{},n="tasks",t.next=4,this.httpRequest.get(n,U(e));case 4:return r=t.sent,t.abrupt("return",s(s({},r),{},{results:r.results.map((function(t){return new K(t)}))}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"waitForTask",value:(u=o(i().mark((function t(n){var r,s,a,u,c,o,p,h=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=h.length>1&&void 0!==h[1]?h[1]:{},s=r.timeOutMs,a=void 0===s?5e3:s,u=r.intervalMs,c=void 0===u?50:u,o=Date.now();case 2:if(!(Date.now()-o1&&void 0!==d[1]?d[1]:{},r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a,c=[],o=E(e),t.prev=3,o.s();case 5:if((p=o.n()).done){t.next=13;break}return h=p.value,t.next=9,this.waitForTask(h,{timeOutMs:s,intervalMs:u});case 9:f=t.sent,c.push(f);case 11:t.next=5;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(3),o.e(t.t0);case 18:return t.prev=18,o.f(),t.finish(18);case 21:return t.abrupt("return",c);case 22:case"end":return t.stop()}}),t,this,[[3,15,18,21]])}))),function(t){return a.apply(this,arguments)})},{key:"cancelTasks",value:(r=o(i().mark((function t(){var e,n,r,s=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=s.length>0&&void 0!==s[0]?s[0]:{},n="tasks/cancel",t.next=4,this.httpRequest.post(n,{},U(e));case 4:return r=t.sent,t.abrupt("return",new j(r));case 6:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"deleteTasks",value:(n=o(i().mark((function t(){var e,n,r,s=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=s.length>0&&void 0!==s[0]?s[0]:{},n="tasks",t.next=4,this.httpRequest.delete(n,{},U(e));case 4:return r=t.sent,t.abrupt("return",new j(r));case 6:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})}]),t}(),H=function(){function t(e,n,r){p(this,t),d(this,"uid",void 0),d(this,"primaryKey",void 0),d(this,"createdAt",void 0),d(this,"updatedAt",void 0),d(this,"httpRequest",void 0),d(this,"tasks",void 0),this.uid=n,this.primaryKey=r,this.httpRequest=new V(e),this.tasks=new G(e)}var e,n,r,a,c,h,l,v,_,y,w,x,m,k,A,g,I,b,E,R,N,O,q,M,P,U,F,K,H,Y,B,X,W,Q,z,J,Z,$,tt,et,nt,rt,st,it,at,ut,ct,ot,pt,ht,ft,dt,lt,vt,_t,yt,wt,xt,mt,kt,At,gt,It,bt,Et,Tt,St,Dt,Rt,Nt,Ot,qt,Lt,Ct,Mt,Pt,Ut,Ft,Vt;return f(t,[{key:"search",value:(Vt=o(i().mark((function t(e,n,r){var a;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a="indexes/".concat(this.uid,"/search"),t.next=3,this.httpRequest.post(a,C(s({q:e},n)),void 0,r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Vt.apply(this,arguments)})},{key:"searchGet",value:(Ft=o(i().mark((function t(e,n,r){var a,u,c,o,p,h,f,d,l,v;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return d="indexes/".concat(this.uid,"/search"),l=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new T("The filter query parameter should be in string format when using searchGet")},v=s(s({q:e},n),{},{filter:l(null==n?void 0:n.filter),sort:null==n||null===(a=n.sort)||void 0===a?void 0:a.join(","),facets:null==n||null===(u=n.facets)||void 0===u?void 0:u.join(","),attributesToRetrieve:null==n||null===(c=n.attributesToRetrieve)||void 0===c?void 0:c.join(","),attributesToCrop:null==n||null===(o=n.attributesToCrop)||void 0===o?void 0:o.join(","),attributesToHighlight:null==n||null===(p=n.attributesToHighlight)||void 0===p?void 0:p.join(","),vector:null==n||null===(h=n.vector)||void 0===h?void 0:h.join(","),attributesToSearchOn:null==n||null===(f=n.attributesToSearchOn)||void 0===f?void 0:f.join(",")}),t.next=5,this.httpRequest.get(d,C(v),r);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Ft.apply(this,arguments)})},{key:"searchForFacetValues",value:(Ut=o(i().mark((function t(e,n){var r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/facet-search"),t.next=3,this.httpRequest.post(r,C(e),void 0,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return Ut.apply(this,arguments)})},{key:"getRawInfo",value:(Pt=o(i().mark((function t(){var e,n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid),t.next=3,this.httpRequest.get(e);case 3:return n=t.sent,this.primaryKey=n.primaryKey,this.updatedAt=new Date(n.updatedAt),this.createdAt=new Date(n.createdAt),t.abrupt("return",n);case 8:case"end":return t.stop()}}),t,this)}))),function(){return Pt.apply(this,arguments)})},{key:"fetchInfo",value:(Mt=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return t.abrupt("return",this);case 3:case"end":return t.stop()}}),t,this)}))),function(){return Mt.apply(this,arguments)})},{key:"fetchPrimaryKey",value:(Ct=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return this.primaryKey=t.sent.primaryKey,t.abrupt("return",this.primaryKey);case 4:case"end":return t.stop()}}),t,this)}))),function(){return Ct.apply(this,arguments)})},{key:"update",value:(Lt=o(i().mark((function t(e){var n,r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="indexes/".concat(this.uid),t.next=3,this.httpRequest.patch(n,e);case 3:return(r=t.sent).enqueuedAt=new Date(r.enqueuedAt),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return Lt.apply(this,arguments)})},{key:"delete",value:(qt=o(i().mark((function t(){var e,n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid),t.next=3,this.httpRequest.delete(e);case 3:return n=t.sent,t.abrupt("return",new j(n));case 5:case"end":return t.stop()}}),t,this)}))),function(){return qt.apply(this,arguments)})},{key:"getTasks",value:(Ot=o(i().mark((function t(){var e,n=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.getTasks(s(s({},e),{},{indexUids:[this.uid]}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return Ot.apply(this,arguments)})},{key:"getTask",value:(Nt=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.getTask(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return Nt.apply(this,arguments)})},{key:"waitForTasks",value:(Rt=o(i().mark((function t(e){var n,r,s,a,u,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:{},r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a,t.next=3,this.tasks.waitForTasks(e,{timeOutMs:s,intervalMs:u});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return Rt.apply(this,arguments)})},{key:"waitForTask",value:(Dt=o(i().mark((function t(e){var n,r,s,a,u,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:{},r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a,t.next=3,this.tasks.waitForTask(e,{timeOutMs:s,intervalMs:u});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return Dt.apply(this,arguments)})},{key:"getStats",value:(St=o(i().mark((function t(){var e;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid,"/stats"),t.next=3,this.httpRequest.get(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return St.apply(this,arguments)})},{key:"getDocuments",value:(Tt=o(i().mark((function t(){var e,n,r,a,u,c,o,p=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===(e=C(e=p.length>0&&void 0!==p[0]?p[0]:{})).filter){t.next=16;break}return t.prev=3,n="indexes/".concat(this.uid,"/documents/fetch"),t.next=7,this.httpRequest.post(n,e);case 7:case 20:return t.abrupt("return",t.sent);case 10:throw t.prev=10,t.t0=t.catch(3),(t.t0 instanceof S||t.t0 instanceof D)&&(t.t0.message=L(t.t0.message,"getDocuments")),t.t0;case 14:t.next=21;break;case 16:return c="indexes/".concat(this.uid,"/documents"),o=Array.isArray(null===(r=e)||void 0===r?void 0:r.fields)?{fields:null===(a=e)||void 0===a||null===(u=a.fields)||void 0===u?void 0:u.join(",")}:{},t.next=20,this.httpRequest.get(c,s(s({},e),o));case 21:case"end":return t.stop()}}),t,this,[[3,10]])}))),function(){return Tt.apply(this,arguments)})},{key:"getDocument",value:(Et=o(i().mark((function t(e,n){var r,a;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/documents/").concat(e),a=function(){var t;if(Array.isArray(null==n?void 0:n.fields))return null==n||null===(t=n.fields)||void 0===t?void 0:t.join(",")}(),t.next=4,this.httpRequest.get(r,C(s(s({},n),{},{fields:a})));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(t,e){return Et.apply(this,arguments)})},{key:"addDocuments",value:(bt=o(i().mark((function t(e,n){var r,s;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/documents"),t.next=3,this.httpRequest.post(r,e,n);case 3:return s=t.sent,t.abrupt("return",new j(s));case 5:case"end":return t.stop()}}),t,this)}))),function(t,e){return bt.apply(this,arguments)})},{key:"addDocumentsFromString",value:(It=o(i().mark((function t(e,n,r){var s,a;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s="indexes/".concat(this.uid,"/documents"),t.next=3,this.httpRequest.post(s,e,r,{headers:{"Content-Type":n}});case 3:return a=t.sent,t.abrupt("return",new j(a));case 5:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return It.apply(this,arguments)})},{key:"addDocumentsInBatches",value:(gt=o(i().mark((function t(e){var n,r,s,a,u=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=u.length>1&&void 0!==u[1]?u[1]:1e3,r=u.length>2?u[2]:void 0,s=[],a=0;case 4:if(!(a1&&void 0!==u[1]?u[1]:1e3,r=u.length>2?u[2]:void 0,s=[],a=0;case 4:if(!(a1&&void 0!==o[1]?o[1]:{},r=o.length>2?o[2]:void 0,a="indexes",u=new V(r),t.next=6,u.post(a,s(s({},n),{},{uid:e}));case 6:return c=t.sent,t.abrupt("return",new j(c));case 8:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}(),Y=function(){function t(e){p(this,t),d(this,"config",void 0),d(this,"httpRequest",void 0),d(this,"tasks",void 0),this.config=e,this.httpRequest=new V(e),this.tasks=new G(e)}var e,r,a,u,c,h,l,v,_,y,w,x,m,k,A,g,I,b,E,T,S,D,R,N,O,q,L;return f(t,[{key:"index",value:function(t){return new H(this.config,t)}},{key:"getIndex",value:(L=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new H(this.config,e).fetchInfo());case 1:case"end":return t.stop()}}),t,this)}))),function(t){return L.apply(this,arguments)})},{key:"getRawIndex",value:(q=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new H(this.config,e).getRawInfo());case 1:case"end":return t.stop()}}),t,this)}))),function(t){return q.apply(this,arguments)})},{key:"getIndexes",value:(O=o(i().mark((function t(){var e,n,r,a=this,u=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=u.length>0&&void 0!==u[0]?u[0]:{},t.next=3,this.getRawIndexes(e);case 3:return n=t.sent,r=n.results.map((function(t){return new H(a.config,t.uid,t.primaryKey)})),t.abrupt("return",s(s({},n),{},{results:r}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return O.apply(this,arguments)})},{key:"getRawIndexes",value:(N=o(i().mark((function t(){var e,n,r=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:{},n="indexes",t.next=4,this.httpRequest.get(n,e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(){return N.apply(this,arguments)})},{key:"createIndex",value:(R=o(i().mark((function t(e){var n,r=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},t.next=3,H.create(e,n,this.config);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return R.apply(this,arguments)})},{key:"updateIndex",value:(D=o(i().mark((function t(e){var n,r=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},t.next=3,new H(this.config,e).update(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return D.apply(this,arguments)})},{key:"deleteIndex",value:(S=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new H(this.config,e).delete();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return S.apply(this,arguments)})},{key:"deleteIndexIfExists",value:(T=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.deleteIndex(e);case 3:return t.abrupt("return",!0);case 6:if(t.prev=6,t.t0=t.catch(0),t.t0.code!==n.INDEX_NOT_FOUND){t.next=10;break}return t.abrupt("return",!1);case 10:throw t.t0;case 11:case"end":return t.stop()}}),t,this,[[0,6]])}))),function(t){return T.apply(this,arguments)})},{key:"swapIndexes",value:(E=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("/swap-indexes",e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return E.apply(this,arguments)})},{key:"multiSearch",value:(b=o(i().mark((function t(e,n){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("multi-search",e,void 0,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return b.apply(this,arguments)})},{key:"getTasks",value:(I=o(i().mark((function t(){var e,n=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.getTasks(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return I.apply(this,arguments)})},{key:"getTask",value:(g=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.getTask(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return g.apply(this,arguments)})},{key:"waitForTasks",value:(A=o(i().mark((function t(e){var n,r,s,a,u,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:{},r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a,t.next=3,this.tasks.waitForTasks(e,{timeOutMs:s,intervalMs:u});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return A.apply(this,arguments)})},{key:"waitForTask",value:(k=o(i().mark((function t(e){var n,r,s,a,u,c=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=c.length>1&&void 0!==c[1]?c[1]:{},r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a,t.next=3,this.tasks.waitForTask(e,{timeOutMs:s,intervalMs:u});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return k.apply(this,arguments)})},{key:"cancelTasks",value:(m=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.cancelTasks(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return m.apply(this,arguments)})},{key:"deleteTasks",value:(x=o(i().mark((function t(){var e,n=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.deleteTasks(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return x.apply(this,arguments)})},{key:"getKeys",value:(w=o(i().mark((function t(){var e,n,r,a=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=a.length>0&&void 0!==a[0]?a[0]:{},n="keys",t.next=4,this.httpRequest.get(n,e);case 4:return(r=t.sent).results=r.results.map((function(t){return s(s({},t),{},{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)})})),t.abrupt("return",r);case 7:case"end":return t.stop()}}),t,this)}))),function(){return w.apply(this,arguments)})},{key:"getKey",value:(y=o(i().mark((function t(e){var n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="keys/".concat(e),t.next=3,this.httpRequest.get(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return y.apply(this,arguments)})},{key:"createKey",value:(_=o(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("keys",e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return _.apply(this,arguments)})},{key:"updateKey",value:(v=o(i().mark((function t(e,n){var r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="keys/".concat(e),t.next=3,this.httpRequest.patch(r,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return v.apply(this,arguments)})},{key:"deleteKey",value:(l=o(i().mark((function t(e){var n;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="keys/".concat(e),t.next=3,this.httpRequest.delete(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"health",value:(h=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("health");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return h.apply(this,arguments)})},{key:"isHealthy",value:(c=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=4,this.httpRequest.get("health");case 4:return t.abrupt("return",!0);case 7:return t.prev=7,t.t0=t.catch(0),t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(){return c.apply(this,arguments)})},{key:"getStats",value:(u=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("stats");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"getVersion",value:(a=o(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("version");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"createDump",value:(r=o(i().mark((function t(){var e;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("dumps");case 3:return e=t.sent,t.abrupt("return",new j(e));case 5:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"createSnapshot",value:(e=o(i().mark((function t(){var e;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("snapshots");case 3:return e=t.sent,t.abrupt("return",new j(e));case 5:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"generateTenantToken",value:function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))}}]),t}(),B=function(t){l(n,t);var e=A(n);function n(t){return p(this,n),e.call(this,t)}return f(n)}(Y);t.ContentTypeEnum={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},t.ErrorStatusCode=n,t.Index=H,t.MatchingStrategies={ALL:"all",LAST:"last"},t.MeiliSearch=B,t.MeiliSearchApiError=D,t.MeiliSearchCommunicationError=S,t.MeiliSearchError=T,t.MeiliSearchTimeOutError=q,t.Meilisearch=B,t.TaskStatus=e,t.TaskTypes={DOCUMENTS_ADDITION_OR_UPDATE:"documentAdditionOrUpdate",DOCUMENT_DELETION:"documentDeletion",DUMP_CREATION:"dumpCreation",INDEX_CREATION:"indexCreation",INDEX_DELETION:"indexDeletion",INDEXES_SWAP:"indexSwap",INDEX_UPDATE:"indexUpdate",SETTINGS_UPDATE:"settingsUpdate",SNAPSHOT_CREATION:"snapshotCreation",TASK_CANCELATION:"taskCancelation",TASK_DELETION:"taskDeletion"},t.default=B,t.httpErrorHandler=O,t.httpResponseErrorHandler=R,t.versionErrorHintMessage=L,Object.defineProperty(t,"__esModule",{value:!0})})); -//# sourceMappingURL=meilisearch.umd.min.js.map From df6b291fad3158720fa629f4462f5a838a1dfed9 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 20 Nov 2024 18:59:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E6=90=9C=E7=B4=A2=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Extensions/ServicesExtensions.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor.Server/Extensions/ServicesExtensions.cs b/src/BootstrapBlazor.Server/Extensions/ServicesExtensions.cs index 783f6f6797b..179e939784e 100644 --- a/src/BootstrapBlazor.Server/Extensions/ServicesExtensions.cs +++ b/src/BootstrapBlazor.Server/Extensions/ServicesExtensions.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone -using BootstrapBlazor.MeiliSearch.Options; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Options; @@ -159,8 +158,8 @@ public static IServiceCollection AddWebSiteServices(this IServiceCollection serv services.AddCascadingAuthenticationState(); services.AddScoped(); - // 增加文档搜索配置项 - services.AddOptionsMonitor(); + // 增加 MeiliSearch 服务 + services.AddBootstrapBlazorMeiliSearch(); return services; } From e626edf1c15a2eac524561fc0d2fc7172a889d8e Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 20 Nov 2024 20:20:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=8C=85=E5=A2=9E=E5=8A=A0=20MeiliSearchBox=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj index c2612e53775..499c7cd9a0f 100644 --- a/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj +++ b/src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj @@ -48,7 +48,7 @@ - + From 7b6cfd2476dfcf9c7d2caa16f5043431a2e71086 Mon Sep 17 00:00:00 2001 From: Argo-AsicoTech Date: Wed, 20 Nov 2024 20:20:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?style:=20=E6=9B=B4=E6=96=B0=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Components/Header.razor.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/BootstrapBlazor.Server/Components/Components/Header.razor.css b/src/BootstrapBlazor.Server/Components/Components/Header.razor.css index 5f7d0e5d79d..90e2a31ff18 100644 --- a/src/BootstrapBlazor.Server/Components/Components/Header.razor.css +++ b/src/BootstrapBlazor.Server/Components/Components/Header.razor.css @@ -25,6 +25,12 @@ margin-top: 2px; } +::deep .bb-g-search { + --bb-global-search-item-active-bg: rgba(var(--bb-primary-color-rgb), 0.5); + --bb-global-search-item-hover-bg: rgba(var(--bb-primary-color-rgb), 0.4); + --bb-global-search-dialog-input-focus-border-color: var(--bb-primary-color); +} + .btn-bd-download { font-weight: 600; color: var(--bb-bd-download-color);