use-algolia
Advanced tools
+4
-1
@@ -115,7 +115,10 @@ /// <reference types="react" /> | ||
| removeStopWords?: boolean | readonly string[] | undefined; | ||
| naturalLanguages?: readonly string[] | undefined; | ||
| getRankingInfo?: boolean | undefined; | ||
| userToken?: string | undefined; | ||
| enableABTest?: boolean | undefined; | ||
| decompoundQuery?: boolean | undefined; | ||
| relevancyStrictness?: number | undefined; | ||
| }; | ||
| }, import("react").Dispatch<RequestOptions & SearchOptions>, () => void, (newConfig: Partial<Pick<SearchState<Hit>, "appId" | "searchKey" | "indexName">>) => void, (page?: number | undefined) => Promise<void>]; | ||
| }, import("react").Dispatch<RequestOptions & SearchOptions>, () => void, (newConfig: Partial<Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>>) => void, (page?: number | undefined) => Promise<void>]; | ||
| export default useAlgolia; |
@@ -10,2 +10,38 @@ 'use strict'; | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
| try { | ||
| var info = gen[key](arg); | ||
| var value = info.value; | ||
| } catch (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| if (info.done) { | ||
| resolve(value); | ||
| } else { | ||
| Promise.resolve(value).then(_next, _throw); | ||
| } | ||
| } | ||
| function _asyncToGenerator(fn) { | ||
| return function () { | ||
| var self = this, | ||
| args = arguments; | ||
| return new Promise(function (resolve, reject) { | ||
| var gen = fn.apply(self, args); | ||
| function _next(value) { | ||
| asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
| } | ||
| function _throw(err) { | ||
| asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
| } | ||
| _next(undefined); | ||
| }); | ||
| }; | ||
| } | ||
| function _extends() { | ||
@@ -29,3 +65,757 @@ _extends = Object.assign || function (target) { | ||
| function createCommonjsModule(fn, module) { | ||
| return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
| } | ||
| var runtime_1 = createCommonjsModule(function (module) { | ||
| /** | ||
| * Copyright (c) 2014-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| var runtime = (function (exports) { | ||
| var Op = Object.prototype; | ||
| var hasOwn = Op.hasOwnProperty; | ||
| var undefined$1; // More compressible than void 0. | ||
| var $Symbol = typeof Symbol === "function" ? Symbol : {}; | ||
| var iteratorSymbol = $Symbol.iterator || "@@iterator"; | ||
| var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; | ||
| var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
| function define(obj, key, value) { | ||
| Object.defineProperty(obj, key, { | ||
| value: value, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| return obj[key]; | ||
| } | ||
| try { | ||
| // IE 8 has a broken Object.defineProperty that only works on DOM objects. | ||
| define({}, ""); | ||
| } catch (err) { | ||
| define = function(obj, key, value) { | ||
| return obj[key] = value; | ||
| }; | ||
| } | ||
| function wrap(innerFn, outerFn, self, tryLocsList) { | ||
| // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. | ||
| var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; | ||
| var generator = Object.create(protoGenerator.prototype); | ||
| var context = new Context(tryLocsList || []); | ||
| // The ._invoke method unifies the implementations of the .next, | ||
| // .throw, and .return methods. | ||
| generator._invoke = makeInvokeMethod(innerFn, self, context); | ||
| return generator; | ||
| } | ||
| exports.wrap = wrap; | ||
| // Try/catch helper to minimize deoptimizations. Returns a completion | ||
| // record like context.tryEntries[i].completion. This interface could | ||
| // have been (and was previously) designed to take a closure to be | ||
| // invoked without arguments, but in all the cases we care about we | ||
| // already have an existing method we want to call, so there's no need | ||
| // to create a new function object. We can even get away with assuming | ||
| // the method takes exactly one argument, since that happens to be true | ||
| // in every case, so we don't have to touch the arguments object. The | ||
| // only additional allocation required is the completion record, which | ||
| // has a stable shape and so hopefully should be cheap to allocate. | ||
| function tryCatch(fn, obj, arg) { | ||
| try { | ||
| return { type: "normal", arg: fn.call(obj, arg) }; | ||
| } catch (err) { | ||
| return { type: "throw", arg: err }; | ||
| } | ||
| } | ||
| var GenStateSuspendedStart = "suspendedStart"; | ||
| var GenStateSuspendedYield = "suspendedYield"; | ||
| var GenStateExecuting = "executing"; | ||
| var GenStateCompleted = "completed"; | ||
| // Returning this object from the innerFn has the same effect as | ||
| // breaking out of the dispatch switch statement. | ||
| var ContinueSentinel = {}; | ||
| // Dummy constructor functions that we use as the .constructor and | ||
| // .constructor.prototype properties for functions that return Generator | ||
| // objects. For full spec compliance, you may wish to configure your | ||
| // minifier not to mangle the names of these two functions. | ||
| function Generator() {} | ||
| function GeneratorFunction() {} | ||
| function GeneratorFunctionPrototype() {} | ||
| // This is a polyfill for %IteratorPrototype% for environments that | ||
| // don't natively support it. | ||
| var IteratorPrototype = {}; | ||
| IteratorPrototype[iteratorSymbol] = function () { | ||
| return this; | ||
| }; | ||
| var getProto = Object.getPrototypeOf; | ||
| var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
| if (NativeIteratorPrototype && | ||
| NativeIteratorPrototype !== Op && | ||
| hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { | ||
| // This environment has a native %IteratorPrototype%; use it instead | ||
| // of the polyfill. | ||
| IteratorPrototype = NativeIteratorPrototype; | ||
| } | ||
| var Gp = GeneratorFunctionPrototype.prototype = | ||
| Generator.prototype = Object.create(IteratorPrototype); | ||
| GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; | ||
| GeneratorFunctionPrototype.constructor = GeneratorFunction; | ||
| GeneratorFunction.displayName = define( | ||
| GeneratorFunctionPrototype, | ||
| toStringTagSymbol, | ||
| "GeneratorFunction" | ||
| ); | ||
| // Helper for defining the .next, .throw, and .return methods of the | ||
| // Iterator interface in terms of a single ._invoke method. | ||
| function defineIteratorMethods(prototype) { | ||
| ["next", "throw", "return"].forEach(function(method) { | ||
| define(prototype, method, function(arg) { | ||
| return this._invoke(method, arg); | ||
| }); | ||
| }); | ||
| } | ||
| exports.isGeneratorFunction = function(genFun) { | ||
| var ctor = typeof genFun === "function" && genFun.constructor; | ||
| return ctor | ||
| ? ctor === GeneratorFunction || | ||
| // For the native GeneratorFunction constructor, the best we can | ||
| // do is to check its .name property. | ||
| (ctor.displayName || ctor.name) === "GeneratorFunction" | ||
| : false; | ||
| }; | ||
| exports.mark = function(genFun) { | ||
| if (Object.setPrototypeOf) { | ||
| Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); | ||
| } else { | ||
| genFun.__proto__ = GeneratorFunctionPrototype; | ||
| define(genFun, toStringTagSymbol, "GeneratorFunction"); | ||
| } | ||
| genFun.prototype = Object.create(Gp); | ||
| return genFun; | ||
| }; | ||
| // Within the body of any async function, `await x` is transformed to | ||
| // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test | ||
| // `hasOwn.call(value, "__await")` to determine if the yielded value is | ||
| // meant to be awaited. | ||
| exports.awrap = function(arg) { | ||
| return { __await: arg }; | ||
| }; | ||
| function AsyncIterator(generator, PromiseImpl) { | ||
| function invoke(method, arg, resolve, reject) { | ||
| var record = tryCatch(generator[method], generator, arg); | ||
| if (record.type === "throw") { | ||
| reject(record.arg); | ||
| } else { | ||
| var result = record.arg; | ||
| var value = result.value; | ||
| if (value && | ||
| typeof value === "object" && | ||
| hasOwn.call(value, "__await")) { | ||
| return PromiseImpl.resolve(value.__await).then(function(value) { | ||
| invoke("next", value, resolve, reject); | ||
| }, function(err) { | ||
| invoke("throw", err, resolve, reject); | ||
| }); | ||
| } | ||
| return PromiseImpl.resolve(value).then(function(unwrapped) { | ||
| // When a yielded Promise is resolved, its final value becomes | ||
| // the .value of the Promise<{value,done}> result for the | ||
| // current iteration. | ||
| result.value = unwrapped; | ||
| resolve(result); | ||
| }, function(error) { | ||
| // If a rejected Promise was yielded, throw the rejection back | ||
| // into the async generator function so it can be handled there. | ||
| return invoke("throw", error, resolve, reject); | ||
| }); | ||
| } | ||
| } | ||
| var previousPromise; | ||
| function enqueue(method, arg) { | ||
| function callInvokeWithMethodAndArg() { | ||
| return new PromiseImpl(function(resolve, reject) { | ||
| invoke(method, arg, resolve, reject); | ||
| }); | ||
| } | ||
| return previousPromise = | ||
| // If enqueue has been called before, then we want to wait until | ||
| // all previous Promises have been resolved before calling invoke, | ||
| // so that results are always delivered in the correct order. If | ||
| // enqueue has not been called before, then it is important to | ||
| // call invoke immediately, without waiting on a callback to fire, | ||
| // so that the async generator function has the opportunity to do | ||
| // any necessary setup in a predictable way. This predictability | ||
| // is why the Promise constructor synchronously invokes its | ||
| // executor callback, and why async functions synchronously | ||
| // execute code before the first await. Since we implement simple | ||
| // async functions in terms of async generators, it is especially | ||
| // important to get this right, even though it requires care. | ||
| previousPromise ? previousPromise.then( | ||
| callInvokeWithMethodAndArg, | ||
| // Avoid propagating failures to Promises returned by later | ||
| // invocations of the iterator. | ||
| callInvokeWithMethodAndArg | ||
| ) : callInvokeWithMethodAndArg(); | ||
| } | ||
| // Define the unified helper method that is used to implement .next, | ||
| // .throw, and .return (see defineIteratorMethods). | ||
| this._invoke = enqueue; | ||
| } | ||
| defineIteratorMethods(AsyncIterator.prototype); | ||
| AsyncIterator.prototype[asyncIteratorSymbol] = function () { | ||
| return this; | ||
| }; | ||
| exports.AsyncIterator = AsyncIterator; | ||
| // Note that simple async functions are implemented on top of | ||
| // AsyncIterator objects; they just return a Promise for the value of | ||
| // the final result produced by the iterator. | ||
| exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
| if (PromiseImpl === void 0) PromiseImpl = Promise; | ||
| var iter = new AsyncIterator( | ||
| wrap(innerFn, outerFn, self, tryLocsList), | ||
| PromiseImpl | ||
| ); | ||
| return exports.isGeneratorFunction(outerFn) | ||
| ? iter // If outerFn is a generator, return the full iterator. | ||
| : iter.next().then(function(result) { | ||
| return result.done ? result.value : iter.next(); | ||
| }); | ||
| }; | ||
| function makeInvokeMethod(innerFn, self, context) { | ||
| var state = GenStateSuspendedStart; | ||
| return function invoke(method, arg) { | ||
| if (state === GenStateExecuting) { | ||
| throw new Error("Generator is already running"); | ||
| } | ||
| if (state === GenStateCompleted) { | ||
| if (method === "throw") { | ||
| throw arg; | ||
| } | ||
| // Be forgiving, per 25.3.3.3.3 of the spec: | ||
| // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume | ||
| return doneResult(); | ||
| } | ||
| context.method = method; | ||
| context.arg = arg; | ||
| while (true) { | ||
| var delegate = context.delegate; | ||
| if (delegate) { | ||
| var delegateResult = maybeInvokeDelegate(delegate, context); | ||
| if (delegateResult) { | ||
| if (delegateResult === ContinueSentinel) continue; | ||
| return delegateResult; | ||
| } | ||
| } | ||
| if (context.method === "next") { | ||
| // Setting context._sent for legacy support of Babel's | ||
| // function.sent implementation. | ||
| context.sent = context._sent = context.arg; | ||
| } else if (context.method === "throw") { | ||
| if (state === GenStateSuspendedStart) { | ||
| state = GenStateCompleted; | ||
| throw context.arg; | ||
| } | ||
| context.dispatchException(context.arg); | ||
| } else if (context.method === "return") { | ||
| context.abrupt("return", context.arg); | ||
| } | ||
| state = GenStateExecuting; | ||
| var record = tryCatch(innerFn, self, context); | ||
| if (record.type === "normal") { | ||
| // If an exception is thrown from innerFn, we leave state === | ||
| // GenStateExecuting and loop back for another invocation. | ||
| state = context.done | ||
| ? GenStateCompleted | ||
| : GenStateSuspendedYield; | ||
| if (record.arg === ContinueSentinel) { | ||
| continue; | ||
| } | ||
| return { | ||
| value: record.arg, | ||
| done: context.done | ||
| }; | ||
| } else if (record.type === "throw") { | ||
| state = GenStateCompleted; | ||
| // Dispatch the exception by looping back around to the | ||
| // context.dispatchException(context.arg) call above. | ||
| context.method = "throw"; | ||
| context.arg = record.arg; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| // Call delegate.iterator[context.method](context.arg) and handle the | ||
| // result, either by returning a { value, done } result from the | ||
| // delegate iterator, or by modifying context.method and context.arg, | ||
| // setting context.delegate to null, and returning the ContinueSentinel. | ||
| function maybeInvokeDelegate(delegate, context) { | ||
| var method = delegate.iterator[context.method]; | ||
| if (method === undefined$1) { | ||
| // A .throw or .return when the delegate iterator has no .throw | ||
| // method always terminates the yield* loop. | ||
| context.delegate = null; | ||
| if (context.method === "throw") { | ||
| // Note: ["return"] must be used for ES3 parsing compatibility. | ||
| if (delegate.iterator["return"]) { | ||
| // If the delegate iterator has a return method, give it a | ||
| // chance to clean up. | ||
| context.method = "return"; | ||
| context.arg = undefined$1; | ||
| maybeInvokeDelegate(delegate, context); | ||
| if (context.method === "throw") { | ||
| // If maybeInvokeDelegate(context) changed context.method from | ||
| // "return" to "throw", let that override the TypeError below. | ||
| return ContinueSentinel; | ||
| } | ||
| } | ||
| context.method = "throw"; | ||
| context.arg = new TypeError( | ||
| "The iterator does not provide a 'throw' method"); | ||
| } | ||
| return ContinueSentinel; | ||
| } | ||
| var record = tryCatch(method, delegate.iterator, context.arg); | ||
| if (record.type === "throw") { | ||
| context.method = "throw"; | ||
| context.arg = record.arg; | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| var info = record.arg; | ||
| if (! info) { | ||
| context.method = "throw"; | ||
| context.arg = new TypeError("iterator result is not an object"); | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| if (info.done) { | ||
| // Assign the result of the finished delegate to the temporary | ||
| // variable specified by delegate.resultName (see delegateYield). | ||
| context[delegate.resultName] = info.value; | ||
| // Resume execution at the desired location (see delegateYield). | ||
| context.next = delegate.nextLoc; | ||
| // If context.method was "throw" but the delegate handled the | ||
| // exception, let the outer generator proceed normally. If | ||
| // context.method was "next", forget context.arg since it has been | ||
| // "consumed" by the delegate iterator. If context.method was | ||
| // "return", allow the original .return call to continue in the | ||
| // outer generator. | ||
| if (context.method !== "return") { | ||
| context.method = "next"; | ||
| context.arg = undefined$1; | ||
| } | ||
| } else { | ||
| // Re-yield the result returned by the delegate method. | ||
| return info; | ||
| } | ||
| // The delegate iterator is finished, so forget it and continue with | ||
| // the outer generator. | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| // Define Generator.prototype.{next,throw,return} in terms of the | ||
| // unified ._invoke helper method. | ||
| defineIteratorMethods(Gp); | ||
| define(Gp, toStringTagSymbol, "Generator"); | ||
| // A Generator should always return itself as the iterator object when the | ||
| // @@iterator function is called on it. Some browsers' implementations of the | ||
| // iterator prototype chain incorrectly implement this, causing the Generator | ||
| // object to not be returned from this call. This ensures that doesn't happen. | ||
| // See https://github.com/facebook/regenerator/issues/274 for more details. | ||
| Gp[iteratorSymbol] = function() { | ||
| return this; | ||
| }; | ||
| Gp.toString = function() { | ||
| return "[object Generator]"; | ||
| }; | ||
| function pushTryEntry(locs) { | ||
| var entry = { tryLoc: locs[0] }; | ||
| if (1 in locs) { | ||
| entry.catchLoc = locs[1]; | ||
| } | ||
| if (2 in locs) { | ||
| entry.finallyLoc = locs[2]; | ||
| entry.afterLoc = locs[3]; | ||
| } | ||
| this.tryEntries.push(entry); | ||
| } | ||
| function resetTryEntry(entry) { | ||
| var record = entry.completion || {}; | ||
| record.type = "normal"; | ||
| delete record.arg; | ||
| entry.completion = record; | ||
| } | ||
| function Context(tryLocsList) { | ||
| // The root entry object (effectively a try statement without a catch | ||
| // or a finally block) gives us a place to store values thrown from | ||
| // locations where there is no enclosing try statement. | ||
| this.tryEntries = [{ tryLoc: "root" }]; | ||
| tryLocsList.forEach(pushTryEntry, this); | ||
| this.reset(true); | ||
| } | ||
| exports.keys = function(object) { | ||
| var keys = []; | ||
| for (var key in object) { | ||
| keys.push(key); | ||
| } | ||
| keys.reverse(); | ||
| // Rather than returning an object with a next method, we keep | ||
| // things simple and return the next function itself. | ||
| return function next() { | ||
| while (keys.length) { | ||
| var key = keys.pop(); | ||
| if (key in object) { | ||
| next.value = key; | ||
| next.done = false; | ||
| return next; | ||
| } | ||
| } | ||
| // To avoid creating an additional object, we just hang the .value | ||
| // and .done properties off the next function object itself. This | ||
| // also ensures that the minifier will not anonymize the function. | ||
| next.done = true; | ||
| return next; | ||
| }; | ||
| }; | ||
| function values(iterable) { | ||
| if (iterable) { | ||
| var iteratorMethod = iterable[iteratorSymbol]; | ||
| if (iteratorMethod) { | ||
| return iteratorMethod.call(iterable); | ||
| } | ||
| if (typeof iterable.next === "function") { | ||
| return iterable; | ||
| } | ||
| if (!isNaN(iterable.length)) { | ||
| var i = -1, next = function next() { | ||
| while (++i < iterable.length) { | ||
| if (hasOwn.call(iterable, i)) { | ||
| next.value = iterable[i]; | ||
| next.done = false; | ||
| return next; | ||
| } | ||
| } | ||
| next.value = undefined$1; | ||
| next.done = true; | ||
| return next; | ||
| }; | ||
| return next.next = next; | ||
| } | ||
| } | ||
| // Return an iterator with no values. | ||
| return { next: doneResult }; | ||
| } | ||
| exports.values = values; | ||
| function doneResult() { | ||
| return { value: undefined$1, done: true }; | ||
| } | ||
| Context.prototype = { | ||
| constructor: Context, | ||
| reset: function(skipTempReset) { | ||
| this.prev = 0; | ||
| this.next = 0; | ||
| // Resetting context._sent for legacy support of Babel's | ||
| // function.sent implementation. | ||
| this.sent = this._sent = undefined$1; | ||
| this.done = false; | ||
| this.delegate = null; | ||
| this.method = "next"; | ||
| this.arg = undefined$1; | ||
| this.tryEntries.forEach(resetTryEntry); | ||
| if (!skipTempReset) { | ||
| for (var name in this) { | ||
| // Not sure about the optimal order of these conditions: | ||
| if (name.charAt(0) === "t" && | ||
| hasOwn.call(this, name) && | ||
| !isNaN(+name.slice(1))) { | ||
| this[name] = undefined$1; | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| stop: function() { | ||
| this.done = true; | ||
| var rootEntry = this.tryEntries[0]; | ||
| var rootRecord = rootEntry.completion; | ||
| if (rootRecord.type === "throw") { | ||
| throw rootRecord.arg; | ||
| } | ||
| return this.rval; | ||
| }, | ||
| dispatchException: function(exception) { | ||
| if (this.done) { | ||
| throw exception; | ||
| } | ||
| var context = this; | ||
| function handle(loc, caught) { | ||
| record.type = "throw"; | ||
| record.arg = exception; | ||
| context.next = loc; | ||
| if (caught) { | ||
| // If the dispatched exception was caught by a catch block, | ||
| // then let that catch block handle the exception normally. | ||
| context.method = "next"; | ||
| context.arg = undefined$1; | ||
| } | ||
| return !! caught; | ||
| } | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| var record = entry.completion; | ||
| if (entry.tryLoc === "root") { | ||
| // Exception thrown outside of any try block that could handle | ||
| // it, so set the completion value of the entire function to | ||
| // throw the exception. | ||
| return handle("end"); | ||
| } | ||
| if (entry.tryLoc <= this.prev) { | ||
| var hasCatch = hasOwn.call(entry, "catchLoc"); | ||
| var hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
| if (hasCatch && hasFinally) { | ||
| if (this.prev < entry.catchLoc) { | ||
| return handle(entry.catchLoc, true); | ||
| } else if (this.prev < entry.finallyLoc) { | ||
| return handle(entry.finallyLoc); | ||
| } | ||
| } else if (hasCatch) { | ||
| if (this.prev < entry.catchLoc) { | ||
| return handle(entry.catchLoc, true); | ||
| } | ||
| } else if (hasFinally) { | ||
| if (this.prev < entry.finallyLoc) { | ||
| return handle(entry.finallyLoc); | ||
| } | ||
| } else { | ||
| throw new Error("try statement without catch or finally"); | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| abrupt: function(type, arg) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.tryLoc <= this.prev && | ||
| hasOwn.call(entry, "finallyLoc") && | ||
| this.prev < entry.finallyLoc) { | ||
| var finallyEntry = entry; | ||
| break; | ||
| } | ||
| } | ||
| if (finallyEntry && | ||
| (type === "break" || | ||
| type === "continue") && | ||
| finallyEntry.tryLoc <= arg && | ||
| arg <= finallyEntry.finallyLoc) { | ||
| // Ignore the finally entry if control is not jumping to a | ||
| // location outside the try/catch block. | ||
| finallyEntry = null; | ||
| } | ||
| var record = finallyEntry ? finallyEntry.completion : {}; | ||
| record.type = type; | ||
| record.arg = arg; | ||
| if (finallyEntry) { | ||
| this.method = "next"; | ||
| this.next = finallyEntry.finallyLoc; | ||
| return ContinueSentinel; | ||
| } | ||
| return this.complete(record); | ||
| }, | ||
| complete: function(record, afterLoc) { | ||
| if (record.type === "throw") { | ||
| throw record.arg; | ||
| } | ||
| if (record.type === "break" || | ||
| record.type === "continue") { | ||
| this.next = record.arg; | ||
| } else if (record.type === "return") { | ||
| this.rval = this.arg = record.arg; | ||
| this.method = "return"; | ||
| this.next = "end"; | ||
| } else if (record.type === "normal" && afterLoc) { | ||
| this.next = afterLoc; | ||
| } | ||
| return ContinueSentinel; | ||
| }, | ||
| finish: function(finallyLoc) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.finallyLoc === finallyLoc) { | ||
| this.complete(entry.completion, entry.afterLoc); | ||
| resetTryEntry(entry); | ||
| return ContinueSentinel; | ||
| } | ||
| } | ||
| }, | ||
| "catch": function(tryLoc) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.tryLoc === tryLoc) { | ||
| var record = entry.completion; | ||
| if (record.type === "throw") { | ||
| var thrown = record.arg; | ||
| resetTryEntry(entry); | ||
| } | ||
| return thrown; | ||
| } | ||
| } | ||
| // The context.catch method must only be called with a location | ||
| // argument that corresponds to a known catch block. | ||
| throw new Error("illegal catch attempt"); | ||
| }, | ||
| delegateYield: function(iterable, resultName, nextLoc) { | ||
| this.delegate = { | ||
| iterator: values(iterable), | ||
| resultName: resultName, | ||
| nextLoc: nextLoc | ||
| }; | ||
| if (this.method === "next") { | ||
| // Deliberately forget the last sent value so that we don't | ||
| // accidentally pass it on to the delegate. | ||
| this.arg = undefined$1; | ||
| } | ||
| return ContinueSentinel; | ||
| } | ||
| }; | ||
| // Regardless of whether this script is executing as a CommonJS module | ||
| // or not, return the runtime object so that we can declare the variable | ||
| // regeneratorRuntime in the outer scope, which allows this module to be | ||
| // injected easily by `bin/regenerator --include-runtime script.js`. | ||
| return exports; | ||
| }( | ||
| // If this script is executing as a CommonJS module, use module.exports | ||
| // as the regeneratorRuntime namespace. Otherwise create a new empty | ||
| // object. Either way, the resulting object will be used to initialize | ||
| // the regeneratorRuntime variable at the top of this file. | ||
| module.exports | ||
| )); | ||
| try { | ||
| regeneratorRuntime = runtime; | ||
| } catch (accidentalStrictMode) { | ||
| // This module should not be running in strict mode, so the above | ||
| // assignment should always work unless something is misconfigured. Just | ||
| // in case runtime.js accidentally runs in strict mode, we can escape | ||
| // strict mode using a global Function call. This could conceivably fail | ||
| // if a Content Security Policy forbids using Function, but in that case | ||
| // the proper solution is to fix the accidental strict mode problem. If | ||
| // you've misconfigured your bundler to force strict mode and applied a | ||
| // CSP to forbid Function, and you're not willing to fix either of those | ||
| // problems, please detail your unique predicament in a GitHub issue. | ||
| Function("r", "regeneratorRuntime = r")(runtime); | ||
| } | ||
| }); | ||
| /** | ||
| * Creates the Algolia search client and initialises the specified index. | ||
@@ -53,3 +843,3 @@ * @param appId Algolia app ID | ||
| var gotMore = (updates === null || updates === void 0 ? void 0 : (_updates$response = updates.response) === null || _updates$response === void 0 ? void 0 : _updates$response.page) && (updates === null || updates === void 0 ? void 0 : (_updates$response2 = updates.response) === null || _updates$response2 === void 0 ? void 0 : _updates$response2.page) > 0; | ||
| var gotMore = (updates == null ? void 0 : (_updates$response = updates.response) == null ? void 0 : _updates$response.page) && (updates == null ? void 0 : (_updates$response2 = updates.response) == null ? void 0 : _updates$response2.page) > 0; | ||
| var hits = gotMore && updates.response ? [].concat(prevState.hits, updates.response.hits) : // If we’re not getting results from a new page, `hits` is set to: | ||
@@ -60,5 +850,5 @@ // 1. overwrite `hits` from `updates` (when resetting query), | ||
| // 4. an empty array | ||
| (_ref = (_ref2 = (_updates$hits = updates.hits) !== null && _updates$hits !== void 0 ? _updates$hits : (_updates$response3 = updates.response) === null || _updates$response3 === void 0 ? void 0 : _updates$response3.hits) !== null && _ref2 !== void 0 ? _ref2 : prevState.hits) !== null && _ref !== void 0 ? _ref : []; | ||
| (_ref = (_ref2 = (_updates$hits = updates.hits) != null ? _updates$hits : (_updates$response3 = updates.response) == null ? void 0 : _updates$response3.hits) != null ? _ref2 : prevState.hits) != null ? _ref : []; | ||
| var hasMore = updates.response ? updates.response.page < updates.response.nbPages - 1 : false; | ||
| return _extends({}, prevState, {}, updates, { | ||
| return _extends({}, prevState, updates, { | ||
| hits: hits, | ||
@@ -106,3 +896,3 @@ hasMore: hasMore | ||
| var _useReducer2 = react.useReducer(function (prev, updates) { | ||
| return _extends({}, prev, {}, updates); | ||
| return _extends({}, prev, updates); | ||
| }, initialRequest), | ||
@@ -114,30 +904,54 @@ request = _useReducer2[0], | ||
| var query = react.useCallback(function (page) { | ||
| try { | ||
| var _ref3; | ||
| var query = react.useCallback( /*#__PURE__*/function () { | ||
| var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(page) { | ||
| var _ref4; | ||
| if (!index) return Promise.resolve(); // Set loading | ||
| var response; | ||
| return runtime_1.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| if (index) { | ||
| _context.next = 2; | ||
| break; | ||
| } | ||
| if (typeof page === 'number' && page > 0) searchDispatch({ | ||
| loading: true | ||
| }); // If we’re not getting a new page, reset the hits | ||
| else searchDispatch({ | ||
| loading: true, | ||
| hits: [] | ||
| }); | ||
| return Promise.resolve(index.search('', _extends({}, request, { | ||
| // Allow getMore() to work even if the user | ||
| // has set page in requestDispatch | ||
| page: (_ref3 = page !== null && page !== void 0 ? page : request.page) !== null && _ref3 !== void 0 ? _ref3 : 0 | ||
| }))).then(function (response) { | ||
| searchDispatch({ | ||
| response: response, | ||
| loading: false | ||
| }); | ||
| }); | ||
| } catch (e) { | ||
| return Promise.reject(e); | ||
| } | ||
| }, [index, request]); // Get completely new query when `query` function is recreated above | ||
| return _context.abrupt("return"); | ||
| case 2: | ||
| // Set loading | ||
| if (typeof page === 'number' && page > 0) searchDispatch({ | ||
| loading: true | ||
| }); // If we’re not getting a new page, reset the hits | ||
| else searchDispatch({ | ||
| loading: true, | ||
| hits: [] | ||
| }); | ||
| _context.next = 5; | ||
| return index.search('', _extends({}, request, { | ||
| // Allow getMore() to work even if the user | ||
| // has set page in requestDispatch | ||
| page: (_ref4 = page != null ? page : request.page) != null ? _ref4 : 0 | ||
| })); | ||
| case 5: | ||
| response = _context.sent; | ||
| searchDispatch({ | ||
| response: response, | ||
| loading: false | ||
| }); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x) { | ||
| return _ref3.apply(this, arguments); | ||
| }; | ||
| }(), [index, request]); // Get completely new query when `query` function is recreated above | ||
| react.useEffect(function () { | ||
@@ -153,3 +967,3 @@ query(); | ||
| var setAlgoliaConfig = function setAlgoliaConfig(newConfig) { | ||
| var setAlgoliaConfig = react.useCallback(function (newConfig) { | ||
| var _updates$appId, _updates$searchKey, _updates$indexName; | ||
@@ -163,7 +977,6 @@ | ||
| updates.index = createAlgoliaIndex((_updates$appId = updates.appId) !== null && _updates$appId !== void 0 ? _updates$appId : searchState.appId, (_updates$searchKey = updates.searchKey) !== null && _updates$searchKey !== void 0 ? _updates$searchKey : searchState.searchKey, (_updates$indexName = updates.indexName) !== null && _updates$indexName !== void 0 ? _updates$indexName : searchState.indexName); | ||
| updates.index = createAlgoliaIndex((_updates$appId = updates.appId) != null ? _updates$appId : searchState.appId, (_updates$searchKey = updates.searchKey) != null ? _updates$searchKey : searchState.searchKey, (_updates$indexName = updates.indexName) != null ? _updates$indexName : searchState.indexName); | ||
| searchDispatch(updates); | ||
| }; // Update config when main useAlgolia props update | ||
| }, []); // Update config when main useAlgolia props update | ||
| react.useEffect(function () { | ||
@@ -170,0 +983,0 @@ setAlgoliaConfig({ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"use-algolia.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n };\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","generateSearchReducer","prevState","updates","gotMore","response","page","hits","hasMore","nbPages","useAlgolia","initialRequest","useReducer","loading","index","searchState","searchDispatch","prev","request","requestDispatch","query","useCallback","search","useEffect","getMore","setAlgoliaConfig","newConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;;IAMaA,kBAAkB,GAAG,SAArBA,kBAAqB,CAChCC,KADgC,EAEhCC,SAFgC,EAGhCC,SAHgC;AAKhC,MAAI,CAACF,KAAD,IAAU,CAACC,SAAX,IAAwB,CAACC,SAA7B,EAAwC,OAAO,IAAP;AACxC,SAAOC,aAAa,CAACH,KAAD,EAAQC,SAAR,CAAb,CAAgCG,SAAhC,CAA0CF,SAA1C,CAAP;AACD;AAsBD;;;;;;;;AAOA,IAAMG,qBAAqB,GAAG,SAAxBA,qBAAwB;AAAA,SAAW,UACvCC,SADuC,EAEvCC,OAFuC;;;AAIvC,QAAMC,OAAO,GAAG,CAAAD,OAAO,S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,GAA8B,EAA3C;;AAEA,QAAIuB,SAAS,CAAC9B,KAAd,EAAqBO,OAAO,CAACP,KAAR,GAAgB8B,SAAS,CAAC9B,KAA1B;AACrB,QAAI8B,SAAS,CAAC7B,SAAd,EAAyBM,OAAO,CAACN,SAAR,GAAoB6B,SAAS,CAAC7B,SAA9B;AACzB,QAAI6B,SAAS,CAAC5B,SAAd,EAAyBK,OAAO,CAACL,SAAR,GAAoB4B,SAAS,CAAC5B,SAA9B;;AAGzBK,IAAAA,OAAO,CAACW,KAAR,GAAgBnB,kBAAkB,mBAChCQ,OAAO,CAACP,KADwB,2DACfmB,WAAW,CAACnB,KADG,wBAEhCO,OAAO,CAACN,SAFwB,mEAEXkB,WAAW,CAAClB,SAFD,wBAGhCM,OAAO,CAACL,SAHwB,mEAGXiB,WAAW,CAACjB,SAHD,CAAlC;AAMAkB,IAAAA,cAAc,CAACb,OAAD,CAAd;AACD,GAnBD;;;AAqBAoB,EAAAA,eAAS,CAAC;AACRE,IAAAA,gBAAgB,CAAC;AAAE7B,MAAAA,KAAK,EAALA,KAAF;AAASC,MAAAA,SAAS,EAATA,SAAT;AAAoBC,MAAAA,SAAS,EAATA;AAApB,KAAD,CAAhB;AACD,GAFQ,EAEN,CAACF,KAAD,EAAQC,SAAR,EAAmBC,SAAnB,CAFM,CAAT;AAIA,SAAO,cACAiB,WADA;AACaG,IAAAA,OAAO,EAAPA;AADb,MAELC,eAFK,EAGLK,OAHK,EAILC,gBAJK,EAKLL,KALK,CAAP;AAaD;;;;;;"} | ||
| {"version":3,"file":"use-algolia.cjs.development.js","sources":["../node_modules/regenerator-runtime/runtime.js","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = useCallback(\n (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n },\n []\n );\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["undefined","createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","generateSearchReducer","prevState","updates","gotMore","response","page","hits","hasMore","nbPages","useAlgolia","initialRequest","useReducer","loading","index","searchState","searchDispatch","prev","request","requestDispatch","query","useCallback","search","useEffect","getMore","setAlgoliaConfig","newConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,IAAI,UAAU,OAAO,EAAE;AAElC;AACA,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;AAC5B,EAAE,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AACjC,EAAE,IAAIA,WAAS,CAAC;AAChB,EAAE,IAAI,OAAO,GAAG,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;AAC3D,EAAE,IAAI,cAAc,GAAG,OAAO,CAAC,QAAQ,IAAI,YAAY,CAAC;AACxD,EAAE,IAAI,mBAAmB,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAiB,CAAC;AACvE,EAAE,IAAI,iBAAiB,GAAG,OAAO,CAAC,WAAW,IAAI,eAAe,CAAC;AACjE;AACA,EAAE,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;AACnC,IAAI,MAAM,CAAC,cAAc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,GApBiC,EAqBlC,EArBkC,CAApC;;AAwBAoB,EAAAA,eAAS,CAAC;AACRE,IAAAA,gBAAgB,CAAC;AAAE7B,MAAAA,KAAK,EAALA,KAAF;AAASC,MAAAA,SAAS,EAATA,SAAT;AAAoBC,MAAAA,SAAS,EAATA;AAApB,KAAD,CAAhB;AACD,GAFQ,EAEN,CAACF,KAAD,EAAQC,SAAR,EAAmBC,SAAnB,CAFM,CAAT;AAIA,SAAO,cACAiB,WADA;AACaG,IAAAA,OAAO,EAAPA;AADb,MAELC,eAFK,EAGLK,OAHK,EAILC,gBAJK,EAKLL,KALK,CAAP;AAaD;;;;;;"} |
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,n=require("react"),r=(e=require("algoliasearch"))&&"object"==typeof e&&"default"in e?e.default:e;function o(){return(o=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var s=function(e,n,o){return e&&n&&o?r(e,n).initIndex(o):null};function a(e,r,a,i){void 0===i&&(i={});var t=n.useReducer((function(e,n){var r,s,a,i,t,l;return o({},e,{},n,{hits:(null==n||null===(r=n.response)||void 0===r?void 0:r.page)&&(null==n||null===(s=n.response)||void 0===s?void 0:s.page)>0&&n.response?[].concat(e.hits,n.response.hits):null!==(a=null!==(i=null!==(t=n.hits)&&void 0!==t?t:null===(l=n.response)||void 0===l?void 0:l.hits)&&void 0!==i?i:e.hits)&&void 0!==a?a:[],hasMore:!!n.response&&n.response.page<n.response.nbPages-1})}),{response:null,hits:[],loading:!1,hasMore:!1,appId:e,searchKey:r,indexName:a,index:s(e,r,a)}),l=t[0],u=t[1],d=l.index,p=n.useReducer((function(e,n){return o({},e,{},n)}),i),c=p[0],v=p[1],h=n.useCallback((function(e){try{var n;return d?(u("number"==typeof e&&e>0?{loading:!0}:{loading:!0,hits:[]}),Promise.resolve(d.search("",o({},c,{page:null!==(n=null!=e?e:c.page)&&void 0!==n?n:0}))).then((function(e){u({response:e,loading:!1})}))):Promise.resolve()}catch(e){return Promise.reject(e)}}),[d,c]);n.useEffect((function(){h()}),[h]);var f=function(e){var n,r,o,a={};e.appId&&(a.appId=e.appId),e.searchKey&&(a.searchKey=e.searchKey),e.indexName&&(a.indexName=e.indexName),a.index=s(null!==(n=a.appId)&&void 0!==n?n:l.appId,null!==(r=a.searchKey)&&void 0!==r?r:l.searchKey,null!==(o=a.indexName)&&void 0!==o?o:l.indexName),u(a)};return n.useEffect((function(){f({appId:e,searchKey:r,indexName:a})}),[e,r,a]),[o({},l,{request:c}),v,function(){l.response&&!l.loading&&l.hasMore&&h(l.response.page+1)},f,h]}exports.createAlgoliaIndex=s,exports.default=a,exports.useAlgolia=a; | ||
| "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),r=(t=require("algoliasearch"))&&"object"==typeof t&&"default"in t?t.default:t;function n(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var i,a=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===l)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var l={};function h(){}function f(){}function p(){}var d={};d[o]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(_([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=p.prototype=h.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,u){var c=s(t[o],t,i);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function b(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function _(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return f.prototype=g.constructor=p,p.constructor=f,f.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),u(g,a,"Generator"),g[o]=function(){return this},g.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=_,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:_(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(i={exports:{}}),i.exports),u=function(t,e,n){return t&&e&&n?r(t,e).initIndex(n):null};function c(t,r,i,c){void 0===c&&(c={});var s=e.useReducer((function(t,e){var r,n,i,a,u,c;return o({},t,e,{hits:(null==e||null==(r=e.response)?void 0:r.page)&&(null==e||null==(n=e.response)?void 0:n.page)>0&&e.response?[].concat(t.hits,e.response.hits):null!=(i=null!=(a=null!=(u=e.hits)?u:null==(c=e.response)?void 0:c.hits)?a:t.hits)?i:[],hasMore:!!e.response&&e.response.page<e.response.nbPages-1})}),{response:null,hits:[],loading:!1,hasMore:!1,appId:t,searchKey:r,indexName:i,index:u(t,r,i)}),l=s[0],h=s[1],f=l.index,p=e.useReducer((function(t,e){return o({},t,e)}),c),d=p[0],v=p[1],y=e.useCallback(function(){var t,e=(t=a.mark((function t(e){var r;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(f){t.next=2;break}return t.abrupt("return");case 2:return h("number"==typeof e&&e>0?{loading:!0}:{loading:!0,hits:[]}),t.next=5,f.search("",o({},d,{page:null!=(r=null!=e?e:d.page)?r:0}));case 5:h({response:t.sent,loading:!1});case 7:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))});return function(t){return e.apply(this,arguments)}}(),[f,d]);e.useEffect((function(){y()}),[y]);var g=e.useCallback((function(t){var e,r,n,o={};t.appId&&(o.appId=t.appId),t.searchKey&&(o.searchKey=t.searchKey),t.indexName&&(o.indexName=t.indexName),o.index=u(null!=(e=o.appId)?e:l.appId,null!=(r=o.searchKey)?r:l.searchKey,null!=(n=o.indexName)?n:l.indexName),h(o)}),[]);return e.useEffect((function(){g({appId:t,searchKey:r,indexName:i})}),[t,r,i]),[o({},l,{request:d}),v,function(){l.response&&!l.loading&&l.hasMore&&y(l.response.page+1)},g,y]}exports.createAlgoliaIndex=u,exports.default=c,exports.useAlgolia=c; | ||
| //# sourceMappingURL=use-algolia.cjs.production.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"use-algolia.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n };\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","useAlgolia","initialRequest","useReducer","prevState","updates","hits","response","page","_updates$response3","hasMore","nbPages","loading","index","searchState","searchDispatch","prev","request","requestDispatch","query","useCallback","search","useEffect","setAlgoliaConfig","newConfig"],"mappings":"8XAWaA,EAAqB,SAChCC,EACAC,EACAC,UAEKF,GAAUC,GAAcC,EACtBC,EAAcH,EAAOC,GAAWG,UAAUF,GADF,eAmEjCG,EACdL,EACAC,EACAC,EACAI,YAAAA,IAAAA,EAAiD,UAGXC,cA3CC,SACvCC,EACAC,+BAkBYD,KAAcC,GAASC,MAhBnBD,MAAAA,aAAAA,EAASE,+BAAUC,QAAQH,MAAAA,aAAAA,EAASE,+BAAUC,MAAO,GAGxDH,EAAQE,mBACXH,EAAUE,KAASD,EAAQE,SAASD,oCAMxCD,EAAQC,8BAAQD,EAAQE,6BAARE,EAAkBH,oBAAQF,EAAUE,oBAAQ,GAMzBI,UAJzBL,EAAQE,UACpBF,EAAQE,SAASC,KAAOH,EAAQE,SAASI,QAAU,MA4BrD,CACEJ,SAAU,KACVD,KAAM,GACNM,SAAS,EACTF,SAAS,EACTd,MAAAA,EACAC,UAAAA,EACAC,UAAAA,EACAe,MAAOlB,EAAmBC,EAAOC,EAAWC,KAVzCgB,OAAaC,OAaZF,EAAUC,EAAVD,QAG2BV,cACjC,SACEa,EACAX,eACSW,KAASX,KACpBH,GALKe,OAASC,OAUVC,EAAQC,wBACLZ,oBACAK,GAIHE,EADkB,iBAATP,GAAqBA,EAAO,EACtB,CAAEI,SAAS,GAER,CAAEA,SAAS,EAAMN,KAAM,qBAEpBO,EAAMQ,OAAY,QACpCJ,GAGHT,eAAMA,MAAAA,EAAAA,EAAQS,EAAQT,oBAAQ,qBAJ1BD,GAONQ,EAAe,CAAER,SAAAA,EAAUK,SAAS,+DAEtC,CAACC,EAAOI,IAIVK,aAAU,WACRH,MACC,CAACA,QAUEI,EAAmB,SACvBC,aAIMnB,EAAqC,GAEvCmB,EAAU5B,QAAOS,EAAQT,MAAQ4B,EAAU5B,OAC3C4B,EAAU3B,YAAWQ,EAAQR,UAAY2B,EAAU3B,WACnD2B,EAAU1B,YAAWO,EAAQP,UAAY0B,EAAU1B,WAGvDO,EAAQQ,MAAQlB,YACdU,EAAQT,qBAASkB,EAAYlB,gBAC7BS,EAAQR,yBAAaiB,EAAYjB,oBACjCQ,EAAQP,yBAAagB,EAAYhB,WAGnCiB,EAAeV,WAGjBiB,aAAU,WACRC,EAAiB,CAAE3B,MAAAA,EAAOC,UAAAA,EAAWC,UAAAA,MACpC,CAACF,EAAOC,EAAWC,IAEf,MACAgB,GAAaG,QAAAA,IAClBC,EAjCc,WACVJ,EAAYP,WAAaO,EAAYF,SAAWE,EAAYJ,SAC9DS,EAAML,EAAYP,SAASC,KAAO,IAiCpCe,EACAJ"} | ||
| {"version":3,"file":"use-algolia.cjs.production.min.js","sources":["../node_modules/regenerator-runtime/runtime.js","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = useCallback(\n (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n },\n []\n );\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["runtime","exports","Op","Object","prototype","hasOwn","hasOwnProperty","$Symbol","Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","define","obj","key","value","defineProperty","enumerable","configurable","writable","err","wrap","innerFn","outerFn","self","tryLocsList","generator","create","Generator","context","Context","_invoke","state","method","arg","Error","undefined","done","delegate","delegateResult","maybeInvokeDelegate","ContinueSentinel","sent","_sent","dispatchException","abrupt","record","tryCatch","type","makeInvokeMethod","fn","call","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","this","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","forEach","AsyncIterator","PromiseImpl","previousPromise","callInvokeWithMethodAndArg","resolve","reject","invoke","result","__await","then","unwrapped","error","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","length","i","doneResult","constructor","displayName","isGeneratorFunction","genFun","ctor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","iter","toString","keys","object","reverse","pop","skipTempReset","prev","charAt","slice","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","module","regeneratorRuntime","accidentalStrictMode","Function","createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","useAlgolia","initialRequest","useReducer","prevState","updates","hits","response","page","_updates$response3","hasMore","nbPages","loading","index","searchState","searchDispatch","request","requestDispatch","query","useCallback","search","useEffect","setAlgoliaConfig","newConfig"],"mappings":"wgBAOA,IAAIA,EAAW,SAAUC,GAGvB,IAAIC,EAAKC,OAAOC,UACZC,EAASH,EAAGI,eAEZC,EAA4B,mBAAXC,OAAwBA,OAAS,GAClDC,EAAiBF,EAAQG,UAAY,aACrCC,EAAsBJ,EAAQK,eAAiB,kBAC/CC,EAAoBN,EAAQO,aAAe,gBAE/C,SAASC,EAAOC,EAAKC,EAAKC,GAOxB,OANAf,OAAOgB,eAAeH,EAAKC,EAAK,CAC9BC,MAAOA,EACPE,YAAY,EACZC,cAAc,EACdC,UAAU,IAELN,EAAIC,GAEb,IAEEF,EAAO,GAAI,IACX,MAAOQ,GACPR,EAAS,SAASC,EAAKC,EAAKC,GAC1B,OAAOF,EAAIC,GAAOC,GAItB,SAASM,EAAKC,EAASC,EAASC,EAAMC,GAEpC,IACIC,EAAY1B,OAAO2B,QADFJ,GAAWA,EAAQtB,qBAAqB2B,EAAYL,EAAUK,GACtC3B,WACzC4B,EAAU,IAAIC,EAAQL,GAAe,IAMzC,OAFAC,EAAUK,QAsMZ,SAA0BT,EAASE,EAAMK,GACvC,IAAIG,EA/KuB,iBAiL3B,OAAO,SAAgBC,EAAQC,GAC7B,GAhLoB,cAgLhBF,EACF,MAAM,IAAIG,MAAM,gCAGlB,GAnLoB,cAmLhBH,EAA6B,CAC/B,GAAe,UAAXC,EACF,MAAMC,EAKR,MAoQG,CAAEnB,WAzfPqB,EAyfyBC,MAAM,GA9P/B,IAHAR,EAAQI,OAASA,EACjBJ,EAAQK,IAAMA,IAED,CACX,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,YAAWQ,EAAQR,UAAY0B,EAAU1B,WACnD0B,EAAUzB,YAAWO,EAAQP,UAAYyB,EAAUzB,WAGvDO,EAAQQ,MAAQlB,WACdU,EAAQT,SAASkB,EAAYlB,eAC7BS,EAAQR,aAAaiB,EAAYjB,mBACjCQ,EAAQP,aAAagB,EAAYhB,WAGnCiB,EAAeV,KAEjB,WAGFgB,aAAU,WACRC,EAAiB,CAAE1B,MAAAA,EAAOC,UAAAA,EAAWC,UAAAA,MACpC,CAACF,EAAOC,EAAWC,IAEf,MACAgB,GAAaE,QAAAA,IAClBC,EApCc,WACVH,EAAYP,WAAaO,EAAYF,SAAWE,EAAYJ,SAC9DQ,EAAMJ,EAAYP,SAASC,KAAO,IAoCpCc,EACAJ"} |
+846
-33
| import { useReducer, useCallback, useEffect } from 'react'; | ||
| import algoliasearch from 'algoliasearch'; | ||
| function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
| try { | ||
| var info = gen[key](arg); | ||
| var value = info.value; | ||
| } catch (error) { | ||
| reject(error); | ||
| return; | ||
| } | ||
| if (info.done) { | ||
| resolve(value); | ||
| } else { | ||
| Promise.resolve(value).then(_next, _throw); | ||
| } | ||
| } | ||
| function _asyncToGenerator(fn) { | ||
| return function () { | ||
| var self = this, | ||
| args = arguments; | ||
| return new Promise(function (resolve, reject) { | ||
| var gen = fn.apply(self, args); | ||
| function _next(value) { | ||
| asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
| } | ||
| function _throw(err) { | ||
| asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
| } | ||
| _next(undefined); | ||
| }); | ||
| }; | ||
| } | ||
| function _extends() { | ||
@@ -22,3 +58,757 @@ _extends = Object.assign || function (target) { | ||
| function createCommonjsModule(fn, module) { | ||
| return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
| } | ||
| var runtime_1 = createCommonjsModule(function (module) { | ||
| /** | ||
| * Copyright (c) 2014-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
| var runtime = (function (exports) { | ||
| var Op = Object.prototype; | ||
| var hasOwn = Op.hasOwnProperty; | ||
| var undefined$1; // More compressible than void 0. | ||
| var $Symbol = typeof Symbol === "function" ? Symbol : {}; | ||
| var iteratorSymbol = $Symbol.iterator || "@@iterator"; | ||
| var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; | ||
| var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
| function define(obj, key, value) { | ||
| Object.defineProperty(obj, key, { | ||
| value: value, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| return obj[key]; | ||
| } | ||
| try { | ||
| // IE 8 has a broken Object.defineProperty that only works on DOM objects. | ||
| define({}, ""); | ||
| } catch (err) { | ||
| define = function(obj, key, value) { | ||
| return obj[key] = value; | ||
| }; | ||
| } | ||
| function wrap(innerFn, outerFn, self, tryLocsList) { | ||
| // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. | ||
| var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; | ||
| var generator = Object.create(protoGenerator.prototype); | ||
| var context = new Context(tryLocsList || []); | ||
| // The ._invoke method unifies the implementations of the .next, | ||
| // .throw, and .return methods. | ||
| generator._invoke = makeInvokeMethod(innerFn, self, context); | ||
| return generator; | ||
| } | ||
| exports.wrap = wrap; | ||
| // Try/catch helper to minimize deoptimizations. Returns a completion | ||
| // record like context.tryEntries[i].completion. This interface could | ||
| // have been (and was previously) designed to take a closure to be | ||
| // invoked without arguments, but in all the cases we care about we | ||
| // already have an existing method we want to call, so there's no need | ||
| // to create a new function object. We can even get away with assuming | ||
| // the method takes exactly one argument, since that happens to be true | ||
| // in every case, so we don't have to touch the arguments object. The | ||
| // only additional allocation required is the completion record, which | ||
| // has a stable shape and so hopefully should be cheap to allocate. | ||
| function tryCatch(fn, obj, arg) { | ||
| try { | ||
| return { type: "normal", arg: fn.call(obj, arg) }; | ||
| } catch (err) { | ||
| return { type: "throw", arg: err }; | ||
| } | ||
| } | ||
| var GenStateSuspendedStart = "suspendedStart"; | ||
| var GenStateSuspendedYield = "suspendedYield"; | ||
| var GenStateExecuting = "executing"; | ||
| var GenStateCompleted = "completed"; | ||
| // Returning this object from the innerFn has the same effect as | ||
| // breaking out of the dispatch switch statement. | ||
| var ContinueSentinel = {}; | ||
| // Dummy constructor functions that we use as the .constructor and | ||
| // .constructor.prototype properties for functions that return Generator | ||
| // objects. For full spec compliance, you may wish to configure your | ||
| // minifier not to mangle the names of these two functions. | ||
| function Generator() {} | ||
| function GeneratorFunction() {} | ||
| function GeneratorFunctionPrototype() {} | ||
| // This is a polyfill for %IteratorPrototype% for environments that | ||
| // don't natively support it. | ||
| var IteratorPrototype = {}; | ||
| IteratorPrototype[iteratorSymbol] = function () { | ||
| return this; | ||
| }; | ||
| var getProto = Object.getPrototypeOf; | ||
| var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
| if (NativeIteratorPrototype && | ||
| NativeIteratorPrototype !== Op && | ||
| hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { | ||
| // This environment has a native %IteratorPrototype%; use it instead | ||
| // of the polyfill. | ||
| IteratorPrototype = NativeIteratorPrototype; | ||
| } | ||
| var Gp = GeneratorFunctionPrototype.prototype = | ||
| Generator.prototype = Object.create(IteratorPrototype); | ||
| GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; | ||
| GeneratorFunctionPrototype.constructor = GeneratorFunction; | ||
| GeneratorFunction.displayName = define( | ||
| GeneratorFunctionPrototype, | ||
| toStringTagSymbol, | ||
| "GeneratorFunction" | ||
| ); | ||
| // Helper for defining the .next, .throw, and .return methods of the | ||
| // Iterator interface in terms of a single ._invoke method. | ||
| function defineIteratorMethods(prototype) { | ||
| ["next", "throw", "return"].forEach(function(method) { | ||
| define(prototype, method, function(arg) { | ||
| return this._invoke(method, arg); | ||
| }); | ||
| }); | ||
| } | ||
| exports.isGeneratorFunction = function(genFun) { | ||
| var ctor = typeof genFun === "function" && genFun.constructor; | ||
| return ctor | ||
| ? ctor === GeneratorFunction || | ||
| // For the native GeneratorFunction constructor, the best we can | ||
| // do is to check its .name property. | ||
| (ctor.displayName || ctor.name) === "GeneratorFunction" | ||
| : false; | ||
| }; | ||
| exports.mark = function(genFun) { | ||
| if (Object.setPrototypeOf) { | ||
| Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); | ||
| } else { | ||
| genFun.__proto__ = GeneratorFunctionPrototype; | ||
| define(genFun, toStringTagSymbol, "GeneratorFunction"); | ||
| } | ||
| genFun.prototype = Object.create(Gp); | ||
| return genFun; | ||
| }; | ||
| // Within the body of any async function, `await x` is transformed to | ||
| // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test | ||
| // `hasOwn.call(value, "__await")` to determine if the yielded value is | ||
| // meant to be awaited. | ||
| exports.awrap = function(arg) { | ||
| return { __await: arg }; | ||
| }; | ||
| function AsyncIterator(generator, PromiseImpl) { | ||
| function invoke(method, arg, resolve, reject) { | ||
| var record = tryCatch(generator[method], generator, arg); | ||
| if (record.type === "throw") { | ||
| reject(record.arg); | ||
| } else { | ||
| var result = record.arg; | ||
| var value = result.value; | ||
| if (value && | ||
| typeof value === "object" && | ||
| hasOwn.call(value, "__await")) { | ||
| return PromiseImpl.resolve(value.__await).then(function(value) { | ||
| invoke("next", value, resolve, reject); | ||
| }, function(err) { | ||
| invoke("throw", err, resolve, reject); | ||
| }); | ||
| } | ||
| return PromiseImpl.resolve(value).then(function(unwrapped) { | ||
| // When a yielded Promise is resolved, its final value becomes | ||
| // the .value of the Promise<{value,done}> result for the | ||
| // current iteration. | ||
| result.value = unwrapped; | ||
| resolve(result); | ||
| }, function(error) { | ||
| // If a rejected Promise was yielded, throw the rejection back | ||
| // into the async generator function so it can be handled there. | ||
| return invoke("throw", error, resolve, reject); | ||
| }); | ||
| } | ||
| } | ||
| var previousPromise; | ||
| function enqueue(method, arg) { | ||
| function callInvokeWithMethodAndArg() { | ||
| return new PromiseImpl(function(resolve, reject) { | ||
| invoke(method, arg, resolve, reject); | ||
| }); | ||
| } | ||
| return previousPromise = | ||
| // If enqueue has been called before, then we want to wait until | ||
| // all previous Promises have been resolved before calling invoke, | ||
| // so that results are always delivered in the correct order. If | ||
| // enqueue has not been called before, then it is important to | ||
| // call invoke immediately, without waiting on a callback to fire, | ||
| // so that the async generator function has the opportunity to do | ||
| // any necessary setup in a predictable way. This predictability | ||
| // is why the Promise constructor synchronously invokes its | ||
| // executor callback, and why async functions synchronously | ||
| // execute code before the first await. Since we implement simple | ||
| // async functions in terms of async generators, it is especially | ||
| // important to get this right, even though it requires care. | ||
| previousPromise ? previousPromise.then( | ||
| callInvokeWithMethodAndArg, | ||
| // Avoid propagating failures to Promises returned by later | ||
| // invocations of the iterator. | ||
| callInvokeWithMethodAndArg | ||
| ) : callInvokeWithMethodAndArg(); | ||
| } | ||
| // Define the unified helper method that is used to implement .next, | ||
| // .throw, and .return (see defineIteratorMethods). | ||
| this._invoke = enqueue; | ||
| } | ||
| defineIteratorMethods(AsyncIterator.prototype); | ||
| AsyncIterator.prototype[asyncIteratorSymbol] = function () { | ||
| return this; | ||
| }; | ||
| exports.AsyncIterator = AsyncIterator; | ||
| // Note that simple async functions are implemented on top of | ||
| // AsyncIterator objects; they just return a Promise for the value of | ||
| // the final result produced by the iterator. | ||
| exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
| if (PromiseImpl === void 0) PromiseImpl = Promise; | ||
| var iter = new AsyncIterator( | ||
| wrap(innerFn, outerFn, self, tryLocsList), | ||
| PromiseImpl | ||
| ); | ||
| return exports.isGeneratorFunction(outerFn) | ||
| ? iter // If outerFn is a generator, return the full iterator. | ||
| : iter.next().then(function(result) { | ||
| return result.done ? result.value : iter.next(); | ||
| }); | ||
| }; | ||
| function makeInvokeMethod(innerFn, self, context) { | ||
| var state = GenStateSuspendedStart; | ||
| return function invoke(method, arg) { | ||
| if (state === GenStateExecuting) { | ||
| throw new Error("Generator is already running"); | ||
| } | ||
| if (state === GenStateCompleted) { | ||
| if (method === "throw") { | ||
| throw arg; | ||
| } | ||
| // Be forgiving, per 25.3.3.3.3 of the spec: | ||
| // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume | ||
| return doneResult(); | ||
| } | ||
| context.method = method; | ||
| context.arg = arg; | ||
| while (true) { | ||
| var delegate = context.delegate; | ||
| if (delegate) { | ||
| var delegateResult = maybeInvokeDelegate(delegate, context); | ||
| if (delegateResult) { | ||
| if (delegateResult === ContinueSentinel) continue; | ||
| return delegateResult; | ||
| } | ||
| } | ||
| if (context.method === "next") { | ||
| // Setting context._sent for legacy support of Babel's | ||
| // function.sent implementation. | ||
| context.sent = context._sent = context.arg; | ||
| } else if (context.method === "throw") { | ||
| if (state === GenStateSuspendedStart) { | ||
| state = GenStateCompleted; | ||
| throw context.arg; | ||
| } | ||
| context.dispatchException(context.arg); | ||
| } else if (context.method === "return") { | ||
| context.abrupt("return", context.arg); | ||
| } | ||
| state = GenStateExecuting; | ||
| var record = tryCatch(innerFn, self, context); | ||
| if (record.type === "normal") { | ||
| // If an exception is thrown from innerFn, we leave state === | ||
| // GenStateExecuting and loop back for another invocation. | ||
| state = context.done | ||
| ? GenStateCompleted | ||
| : GenStateSuspendedYield; | ||
| if (record.arg === ContinueSentinel) { | ||
| continue; | ||
| } | ||
| return { | ||
| value: record.arg, | ||
| done: context.done | ||
| }; | ||
| } else if (record.type === "throw") { | ||
| state = GenStateCompleted; | ||
| // Dispatch the exception by looping back around to the | ||
| // context.dispatchException(context.arg) call above. | ||
| context.method = "throw"; | ||
| context.arg = record.arg; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| // Call delegate.iterator[context.method](context.arg) and handle the | ||
| // result, either by returning a { value, done } result from the | ||
| // delegate iterator, or by modifying context.method and context.arg, | ||
| // setting context.delegate to null, and returning the ContinueSentinel. | ||
| function maybeInvokeDelegate(delegate, context) { | ||
| var method = delegate.iterator[context.method]; | ||
| if (method === undefined$1) { | ||
| // A .throw or .return when the delegate iterator has no .throw | ||
| // method always terminates the yield* loop. | ||
| context.delegate = null; | ||
| if (context.method === "throw") { | ||
| // Note: ["return"] must be used for ES3 parsing compatibility. | ||
| if (delegate.iterator["return"]) { | ||
| // If the delegate iterator has a return method, give it a | ||
| // chance to clean up. | ||
| context.method = "return"; | ||
| context.arg = undefined$1; | ||
| maybeInvokeDelegate(delegate, context); | ||
| if (context.method === "throw") { | ||
| // If maybeInvokeDelegate(context) changed context.method from | ||
| // "return" to "throw", let that override the TypeError below. | ||
| return ContinueSentinel; | ||
| } | ||
| } | ||
| context.method = "throw"; | ||
| context.arg = new TypeError( | ||
| "The iterator does not provide a 'throw' method"); | ||
| } | ||
| return ContinueSentinel; | ||
| } | ||
| var record = tryCatch(method, delegate.iterator, context.arg); | ||
| if (record.type === "throw") { | ||
| context.method = "throw"; | ||
| context.arg = record.arg; | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| var info = record.arg; | ||
| if (! info) { | ||
| context.method = "throw"; | ||
| context.arg = new TypeError("iterator result is not an object"); | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| if (info.done) { | ||
| // Assign the result of the finished delegate to the temporary | ||
| // variable specified by delegate.resultName (see delegateYield). | ||
| context[delegate.resultName] = info.value; | ||
| // Resume execution at the desired location (see delegateYield). | ||
| context.next = delegate.nextLoc; | ||
| // If context.method was "throw" but the delegate handled the | ||
| // exception, let the outer generator proceed normally. If | ||
| // context.method was "next", forget context.arg since it has been | ||
| // "consumed" by the delegate iterator. If context.method was | ||
| // "return", allow the original .return call to continue in the | ||
| // outer generator. | ||
| if (context.method !== "return") { | ||
| context.method = "next"; | ||
| context.arg = undefined$1; | ||
| } | ||
| } else { | ||
| // Re-yield the result returned by the delegate method. | ||
| return info; | ||
| } | ||
| // The delegate iterator is finished, so forget it and continue with | ||
| // the outer generator. | ||
| context.delegate = null; | ||
| return ContinueSentinel; | ||
| } | ||
| // Define Generator.prototype.{next,throw,return} in terms of the | ||
| // unified ._invoke helper method. | ||
| defineIteratorMethods(Gp); | ||
| define(Gp, toStringTagSymbol, "Generator"); | ||
| // A Generator should always return itself as the iterator object when the | ||
| // @@iterator function is called on it. Some browsers' implementations of the | ||
| // iterator prototype chain incorrectly implement this, causing the Generator | ||
| // object to not be returned from this call. This ensures that doesn't happen. | ||
| // See https://github.com/facebook/regenerator/issues/274 for more details. | ||
| Gp[iteratorSymbol] = function() { | ||
| return this; | ||
| }; | ||
| Gp.toString = function() { | ||
| return "[object Generator]"; | ||
| }; | ||
| function pushTryEntry(locs) { | ||
| var entry = { tryLoc: locs[0] }; | ||
| if (1 in locs) { | ||
| entry.catchLoc = locs[1]; | ||
| } | ||
| if (2 in locs) { | ||
| entry.finallyLoc = locs[2]; | ||
| entry.afterLoc = locs[3]; | ||
| } | ||
| this.tryEntries.push(entry); | ||
| } | ||
| function resetTryEntry(entry) { | ||
| var record = entry.completion || {}; | ||
| record.type = "normal"; | ||
| delete record.arg; | ||
| entry.completion = record; | ||
| } | ||
| function Context(tryLocsList) { | ||
| // The root entry object (effectively a try statement without a catch | ||
| // or a finally block) gives us a place to store values thrown from | ||
| // locations where there is no enclosing try statement. | ||
| this.tryEntries = [{ tryLoc: "root" }]; | ||
| tryLocsList.forEach(pushTryEntry, this); | ||
| this.reset(true); | ||
| } | ||
| exports.keys = function(object) { | ||
| var keys = []; | ||
| for (var key in object) { | ||
| keys.push(key); | ||
| } | ||
| keys.reverse(); | ||
| // Rather than returning an object with a next method, we keep | ||
| // things simple and return the next function itself. | ||
| return function next() { | ||
| while (keys.length) { | ||
| var key = keys.pop(); | ||
| if (key in object) { | ||
| next.value = key; | ||
| next.done = false; | ||
| return next; | ||
| } | ||
| } | ||
| // To avoid creating an additional object, we just hang the .value | ||
| // and .done properties off the next function object itself. This | ||
| // also ensures that the minifier will not anonymize the function. | ||
| next.done = true; | ||
| return next; | ||
| }; | ||
| }; | ||
| function values(iterable) { | ||
| if (iterable) { | ||
| var iteratorMethod = iterable[iteratorSymbol]; | ||
| if (iteratorMethod) { | ||
| return iteratorMethod.call(iterable); | ||
| } | ||
| if (typeof iterable.next === "function") { | ||
| return iterable; | ||
| } | ||
| if (!isNaN(iterable.length)) { | ||
| var i = -1, next = function next() { | ||
| while (++i < iterable.length) { | ||
| if (hasOwn.call(iterable, i)) { | ||
| next.value = iterable[i]; | ||
| next.done = false; | ||
| return next; | ||
| } | ||
| } | ||
| next.value = undefined$1; | ||
| next.done = true; | ||
| return next; | ||
| }; | ||
| return next.next = next; | ||
| } | ||
| } | ||
| // Return an iterator with no values. | ||
| return { next: doneResult }; | ||
| } | ||
| exports.values = values; | ||
| function doneResult() { | ||
| return { value: undefined$1, done: true }; | ||
| } | ||
| Context.prototype = { | ||
| constructor: Context, | ||
| reset: function(skipTempReset) { | ||
| this.prev = 0; | ||
| this.next = 0; | ||
| // Resetting context._sent for legacy support of Babel's | ||
| // function.sent implementation. | ||
| this.sent = this._sent = undefined$1; | ||
| this.done = false; | ||
| this.delegate = null; | ||
| this.method = "next"; | ||
| this.arg = undefined$1; | ||
| this.tryEntries.forEach(resetTryEntry); | ||
| if (!skipTempReset) { | ||
| for (var name in this) { | ||
| // Not sure about the optimal order of these conditions: | ||
| if (name.charAt(0) === "t" && | ||
| hasOwn.call(this, name) && | ||
| !isNaN(+name.slice(1))) { | ||
| this[name] = undefined$1; | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| stop: function() { | ||
| this.done = true; | ||
| var rootEntry = this.tryEntries[0]; | ||
| var rootRecord = rootEntry.completion; | ||
| if (rootRecord.type === "throw") { | ||
| throw rootRecord.arg; | ||
| } | ||
| return this.rval; | ||
| }, | ||
| dispatchException: function(exception) { | ||
| if (this.done) { | ||
| throw exception; | ||
| } | ||
| var context = this; | ||
| function handle(loc, caught) { | ||
| record.type = "throw"; | ||
| record.arg = exception; | ||
| context.next = loc; | ||
| if (caught) { | ||
| // If the dispatched exception was caught by a catch block, | ||
| // then let that catch block handle the exception normally. | ||
| context.method = "next"; | ||
| context.arg = undefined$1; | ||
| } | ||
| return !! caught; | ||
| } | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| var record = entry.completion; | ||
| if (entry.tryLoc === "root") { | ||
| // Exception thrown outside of any try block that could handle | ||
| // it, so set the completion value of the entire function to | ||
| // throw the exception. | ||
| return handle("end"); | ||
| } | ||
| if (entry.tryLoc <= this.prev) { | ||
| var hasCatch = hasOwn.call(entry, "catchLoc"); | ||
| var hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
| if (hasCatch && hasFinally) { | ||
| if (this.prev < entry.catchLoc) { | ||
| return handle(entry.catchLoc, true); | ||
| } else if (this.prev < entry.finallyLoc) { | ||
| return handle(entry.finallyLoc); | ||
| } | ||
| } else if (hasCatch) { | ||
| if (this.prev < entry.catchLoc) { | ||
| return handle(entry.catchLoc, true); | ||
| } | ||
| } else if (hasFinally) { | ||
| if (this.prev < entry.finallyLoc) { | ||
| return handle(entry.finallyLoc); | ||
| } | ||
| } else { | ||
| throw new Error("try statement without catch or finally"); | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| abrupt: function(type, arg) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.tryLoc <= this.prev && | ||
| hasOwn.call(entry, "finallyLoc") && | ||
| this.prev < entry.finallyLoc) { | ||
| var finallyEntry = entry; | ||
| break; | ||
| } | ||
| } | ||
| if (finallyEntry && | ||
| (type === "break" || | ||
| type === "continue") && | ||
| finallyEntry.tryLoc <= arg && | ||
| arg <= finallyEntry.finallyLoc) { | ||
| // Ignore the finally entry if control is not jumping to a | ||
| // location outside the try/catch block. | ||
| finallyEntry = null; | ||
| } | ||
| var record = finallyEntry ? finallyEntry.completion : {}; | ||
| record.type = type; | ||
| record.arg = arg; | ||
| if (finallyEntry) { | ||
| this.method = "next"; | ||
| this.next = finallyEntry.finallyLoc; | ||
| return ContinueSentinel; | ||
| } | ||
| return this.complete(record); | ||
| }, | ||
| complete: function(record, afterLoc) { | ||
| if (record.type === "throw") { | ||
| throw record.arg; | ||
| } | ||
| if (record.type === "break" || | ||
| record.type === "continue") { | ||
| this.next = record.arg; | ||
| } else if (record.type === "return") { | ||
| this.rval = this.arg = record.arg; | ||
| this.method = "return"; | ||
| this.next = "end"; | ||
| } else if (record.type === "normal" && afterLoc) { | ||
| this.next = afterLoc; | ||
| } | ||
| return ContinueSentinel; | ||
| }, | ||
| finish: function(finallyLoc) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.finallyLoc === finallyLoc) { | ||
| this.complete(entry.completion, entry.afterLoc); | ||
| resetTryEntry(entry); | ||
| return ContinueSentinel; | ||
| } | ||
| } | ||
| }, | ||
| "catch": function(tryLoc) { | ||
| for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
| var entry = this.tryEntries[i]; | ||
| if (entry.tryLoc === tryLoc) { | ||
| var record = entry.completion; | ||
| if (record.type === "throw") { | ||
| var thrown = record.arg; | ||
| resetTryEntry(entry); | ||
| } | ||
| return thrown; | ||
| } | ||
| } | ||
| // The context.catch method must only be called with a location | ||
| // argument that corresponds to a known catch block. | ||
| throw new Error("illegal catch attempt"); | ||
| }, | ||
| delegateYield: function(iterable, resultName, nextLoc) { | ||
| this.delegate = { | ||
| iterator: values(iterable), | ||
| resultName: resultName, | ||
| nextLoc: nextLoc | ||
| }; | ||
| if (this.method === "next") { | ||
| // Deliberately forget the last sent value so that we don't | ||
| // accidentally pass it on to the delegate. | ||
| this.arg = undefined$1; | ||
| } | ||
| return ContinueSentinel; | ||
| } | ||
| }; | ||
| // Regardless of whether this script is executing as a CommonJS module | ||
| // or not, return the runtime object so that we can declare the variable | ||
| // regeneratorRuntime in the outer scope, which allows this module to be | ||
| // injected easily by `bin/regenerator --include-runtime script.js`. | ||
| return exports; | ||
| }( | ||
| // If this script is executing as a CommonJS module, use module.exports | ||
| // as the regeneratorRuntime namespace. Otherwise create a new empty | ||
| // object. Either way, the resulting object will be used to initialize | ||
| // the regeneratorRuntime variable at the top of this file. | ||
| module.exports | ||
| )); | ||
| try { | ||
| regeneratorRuntime = runtime; | ||
| } catch (accidentalStrictMode) { | ||
| // This module should not be running in strict mode, so the above | ||
| // assignment should always work unless something is misconfigured. Just | ||
| // in case runtime.js accidentally runs in strict mode, we can escape | ||
| // strict mode using a global Function call. This could conceivably fail | ||
| // if a Content Security Policy forbids using Function, but in that case | ||
| // the proper solution is to fix the accidental strict mode problem. If | ||
| // you've misconfigured your bundler to force strict mode and applied a | ||
| // CSP to forbid Function, and you're not willing to fix either of those | ||
| // problems, please detail your unique predicament in a GitHub issue. | ||
| Function("r", "regeneratorRuntime = r")(runtime); | ||
| } | ||
| }); | ||
| /** | ||
| * Creates the Algolia search client and initialises the specified index. | ||
@@ -46,3 +836,3 @@ * @param appId Algolia app ID | ||
| var gotMore = (updates === null || updates === void 0 ? void 0 : (_updates$response = updates.response) === null || _updates$response === void 0 ? void 0 : _updates$response.page) && (updates === null || updates === void 0 ? void 0 : (_updates$response2 = updates.response) === null || _updates$response2 === void 0 ? void 0 : _updates$response2.page) > 0; | ||
| var gotMore = (updates == null ? void 0 : (_updates$response = updates.response) == null ? void 0 : _updates$response.page) && (updates == null ? void 0 : (_updates$response2 = updates.response) == null ? void 0 : _updates$response2.page) > 0; | ||
| var hits = gotMore && updates.response ? [].concat(prevState.hits, updates.response.hits) : // If we’re not getting results from a new page, `hits` is set to: | ||
@@ -53,5 +843,5 @@ // 1. overwrite `hits` from `updates` (when resetting query), | ||
| // 4. an empty array | ||
| (_ref = (_ref2 = (_updates$hits = updates.hits) !== null && _updates$hits !== void 0 ? _updates$hits : (_updates$response3 = updates.response) === null || _updates$response3 === void 0 ? void 0 : _updates$response3.hits) !== null && _ref2 !== void 0 ? _ref2 : prevState.hits) !== null && _ref !== void 0 ? _ref : []; | ||
| (_ref = (_ref2 = (_updates$hits = updates.hits) != null ? _updates$hits : (_updates$response3 = updates.response) == null ? void 0 : _updates$response3.hits) != null ? _ref2 : prevState.hits) != null ? _ref : []; | ||
| var hasMore = updates.response ? updates.response.page < updates.response.nbPages - 1 : false; | ||
| return _extends({}, prevState, {}, updates, { | ||
| return _extends({}, prevState, updates, { | ||
| hits: hits, | ||
@@ -99,3 +889,3 @@ hasMore: hasMore | ||
| var _useReducer2 = useReducer(function (prev, updates) { | ||
| return _extends({}, prev, {}, updates); | ||
| return _extends({}, prev, updates); | ||
| }, initialRequest), | ||
@@ -107,30 +897,54 @@ request = _useReducer2[0], | ||
| var query = useCallback(function (page) { | ||
| try { | ||
| var _ref3; | ||
| var query = useCallback( /*#__PURE__*/function () { | ||
| var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(page) { | ||
| var _ref4; | ||
| if (!index) return Promise.resolve(); // Set loading | ||
| var response; | ||
| return runtime_1.wrap(function _callee$(_context) { | ||
| while (1) { | ||
| switch (_context.prev = _context.next) { | ||
| case 0: | ||
| if (index) { | ||
| _context.next = 2; | ||
| break; | ||
| } | ||
| if (typeof page === 'number' && page > 0) searchDispatch({ | ||
| loading: true | ||
| }); // If we’re not getting a new page, reset the hits | ||
| else searchDispatch({ | ||
| loading: true, | ||
| hits: [] | ||
| }); | ||
| return Promise.resolve(index.search('', _extends({}, request, { | ||
| // Allow getMore() to work even if the user | ||
| // has set page in requestDispatch | ||
| page: (_ref3 = page !== null && page !== void 0 ? page : request.page) !== null && _ref3 !== void 0 ? _ref3 : 0 | ||
| }))).then(function (response) { | ||
| searchDispatch({ | ||
| response: response, | ||
| loading: false | ||
| }); | ||
| }); | ||
| } catch (e) { | ||
| return Promise.reject(e); | ||
| } | ||
| }, [index, request]); // Get completely new query when `query` function is recreated above | ||
| return _context.abrupt("return"); | ||
| case 2: | ||
| // Set loading | ||
| if (typeof page === 'number' && page > 0) searchDispatch({ | ||
| loading: true | ||
| }); // If we’re not getting a new page, reset the hits | ||
| else searchDispatch({ | ||
| loading: true, | ||
| hits: [] | ||
| }); | ||
| _context.next = 5; | ||
| return index.search('', _extends({}, request, { | ||
| // Allow getMore() to work even if the user | ||
| // has set page in requestDispatch | ||
| page: (_ref4 = page != null ? page : request.page) != null ? _ref4 : 0 | ||
| })); | ||
| case 5: | ||
| response = _context.sent; | ||
| searchDispatch({ | ||
| response: response, | ||
| loading: false | ||
| }); | ||
| case 7: | ||
| case "end": | ||
| return _context.stop(); | ||
| } | ||
| } | ||
| }, _callee); | ||
| })); | ||
| return function (_x) { | ||
| return _ref3.apply(this, arguments); | ||
| }; | ||
| }(), [index, request]); // Get completely new query when `query` function is recreated above | ||
| useEffect(function () { | ||
@@ -146,3 +960,3 @@ query(); | ||
| var setAlgoliaConfig = function setAlgoliaConfig(newConfig) { | ||
| var setAlgoliaConfig = useCallback(function (newConfig) { | ||
| var _updates$appId, _updates$searchKey, _updates$indexName; | ||
@@ -156,7 +970,6 @@ | ||
| updates.index = createAlgoliaIndex((_updates$appId = updates.appId) !== null && _updates$appId !== void 0 ? _updates$appId : searchState.appId, (_updates$searchKey = updates.searchKey) !== null && _updates$searchKey !== void 0 ? _updates$searchKey : searchState.searchKey, (_updates$indexName = updates.indexName) !== null && _updates$indexName !== void 0 ? _updates$indexName : searchState.indexName); | ||
| updates.index = createAlgoliaIndex((_updates$appId = updates.appId) != null ? _updates$appId : searchState.appId, (_updates$searchKey = updates.searchKey) != null ? _updates$searchKey : searchState.searchKey, (_updates$indexName = updates.indexName) != null ? _updates$indexName : searchState.indexName); | ||
| searchDispatch(updates); | ||
| }; // Update config when main useAlgolia props update | ||
| }, []); // Update config when main useAlgolia props update | ||
| useEffect(function () { | ||
@@ -163,0 +976,0 @@ setAlgoliaConfig({ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"use-algolia.esm.js","sources":["../src/index.ts"],"sourcesContent":["import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n };\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","generateSearchReducer","prevState","updates","gotMore","response","page","hits","hasMore","nbPages","useAlgolia","initialRequest","useReducer","loading","index","searchState","searchDispatch","prev","request","requestDispatch","query","useCallback","search","useEffect","getMore","setAlgoliaConfig","newConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;;IAMaA,kBAAkB,GAAG,SAArBA,kBAAqB,CAChCC,KADgC,EAEhCC,SAFgC,EAGhCC,SAHgC;AAKhC,MAAI,CAACF,KAAD,IAAU,CAACC,SAAX,IAAwB,CAACC,SAA7B,EAAwC,OAAO,IAAP;AACxC,SAAOC,aAAa,CAACH,KAAD,EAAQC,SAAR,CAAb,CAAgCG,SAAhC,CAA0CF,SAA1C,CAAP;AACD;AAsBD;;;;;;;;AAOA,IAAMG,qBAAqB,GAAG,SAAxBA,qBAAwB;AAAA,SAAW,UACvCC,SADuC,EAEvCC,OAFuC;;;AAIvC,QAAMC,OAAO,GAAG,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,iCAAAA,OAAO,C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B,KAAd,EAAqBO,OAAO,CAACP,KAAR,GAAgB8B,SAAS,CAAC9B,KAA1B;AACrB,QAAI8B,SAAS,CAAC7B,SAAd,EAAyBM,OAAO,CAACN,SAAR,GAAoB6B,SAAS,CAAC7B,SAA9B;AACzB,QAAI6B,SAAS,CAAC5B,SAAd,EAAyBK,OAAO,CAACL,SAAR,GAAoB4B,SAAS,CAAC5B,SAA9B;;AAGzBK,IAAAA,OAAO,CAACW,KAAR,GAAgBnB,kBAAkB,mBAChCQ,OAAO,CAACP,KADwB,2DACfmB,WAAW,CAACnB,KADG,wBAEhCO,OAAO,CAACN,SAFwB,mEAEXkB,WAAW,CAAClB,SAFD,wBAGhCM,OAAO,CAACL,SAHwB,mEAGXiB,WAAW,CAACjB,SAHD,CAAlC;AAMAkB,IAAAA,cAAc,CAACb,OAAD,CAAd;AACD,GAnBD;;;AAqBAoB,EAAAA,SAAS,CAAC;AACRE,IAAAA,gBAAgB,CAAC;AAAE7B,MAAAA,KAAK,EAALA,KAAF;AAASC,MAAAA,SAAS,EAATA,SAAT;AAAoBC,MAAAA,SAAS,EAATA;AAApB,KAAD,CAAhB;AACD,GAFQ,EAEN,CAACF,KAAD,EAAQC,SAAR,EAAmBC,SAAnB,CAFM,CAAT;AAIA,SAAO,cACAiB,WADA;AACaG,IAAAA,OAAO,EAAPA;AADb,MAELC,eAFK,EAGLK,OAHK,EAILC,gBAJK,EAKLL,KALK,CAAP;AAaD;;;;;"} | ||
| {"version":3,"file":"use-algolia.esm.js","sources":["../node_modules/regenerator-runtime/runtime.js","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n typeof module === \"object\" ? module.exports : {}\n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n","import { useReducer, useCallback, useEffect } from 'react';\nimport algoliasearch, { SearchIndex } from 'algoliasearch';\nimport { RequestOptions } from '@algolia/transporter';\nimport { SearchOptions, SearchResponse } from '@algolia/client-search';\n\n/**\n * Creates the Algolia search client and initialises the specified index.\n * @param appId Algolia app ID\n * @param searchKey API key to search this index\n * @param indexName Index to initialise\n */\nexport const createAlgoliaIndex = (\n appId?: string,\n searchKey?: string,\n indexName?: string\n) => {\n if (!appId || !searchKey || !indexName) return null;\n return algoliasearch(appId, searchKey).initIndex(indexName);\n};\n\n/** Current request state, hits retrieved, and loading status. */\ninterface SearchState<Hit> {\n /** Algolia SearchResponse object — contains only last page of hits retrieved */\n response: SearchResponse<Hit> | null;\n /** Contains all hits for search query, including all pages retrieved */\n hits: SearchResponse<Hit>['hits'];\n /** Set when loading initially or loading more hits */\n loading: boolean;\n /** Flag set if there are more pages to be retrieved */\n hasMore: boolean;\n /** Algolia App ID */\n appId: string;\n /** API key to search the index */\n searchKey: string;\n /** Algolia index to query */\n indexName: string;\n /** The Algolia search index created */\n index: SearchIndex | null;\n}\n\n/**\n * Updates hook’s internal `SearchState`. Handles:\n * - Checking if there are more pages that can be retrieved\n * - Concatenating hits if we queried a new page\n * @param prevState See `SearchState` interface\n * @param updates Updates to `SearchState`\n */\nconst generateSearchReducer = <Hit>() => (\n prevState: SearchState<Hit>,\n updates: Partial<SearchState<Hit>>\n): SearchState<Hit> => {\n const gotMore = updates?.response?.page && updates?.response?.page > 0;\n\n const hits =\n gotMore && updates.response\n ? [...prevState.hits, ...updates.response.hits]\n : // If we’re not getting results from a new page, `hits` is set to:\n // 1. overwrite `hits` from `updates` (when resetting query),\n // 2. use the latest `hits` from the response,\n // 3. use `hits` from the previous state, or\n // 4. an empty array\n updates.hits ?? updates.response?.hits ?? prevState.hits ?? [];\n\n const hasMore = updates.response\n ? updates.response.page < updates.response.nbPages - 1\n : false;\n\n return { ...prevState, ...updates, hits, hasMore };\n};\n\n/**\n * Hook to make Algolia search queries with built-in support for pagination.\n * @param appId Algolia app ID\n * @param searchKey API key to search the index\n * @param indexName Algolia index to query\n * @param initialRequest Initial `SearchOptions` object sent to Algolia request\n * @returns The following array:\n * 1. `searchState`: containing `hits` and `loading`,\n * 2. `requestDispatch` to update `SearchOptions` passed to Algolia — see\n * https://www.algolia.com/doc/api-reference/search-api-parameters/, and\n * 3. `getMore` to get the next page of results\n * 4. `setAlgoliaConfig` to update the Algolia index to use\n */\nexport function useAlgolia<Hit = any>(\n appId: string,\n searchKey: string,\n indexName: string,\n initialRequest: RequestOptions & SearchOptions = {}\n) {\n // Stores response status\n const [searchState, searchDispatch] = useReducer(\n generateSearchReducer<Hit>(),\n {\n response: null,\n hits: [],\n loading: false,\n hasMore: false,\n appId,\n searchKey,\n indexName,\n index: createAlgoliaIndex(appId, searchKey, indexName),\n }\n );\n const { index } = searchState;\n\n // Store the `SearchOptions` request object that can shallow-merge updates\n const [request, requestDispatch] = useReducer(\n (\n prev: RequestOptions & SearchOptions,\n updates: RequestOptions & SearchOptions\n ) => ({ ...prev, ...updates }),\n initialRequest\n );\n\n // Query algolia with search text + filters\n // Function will be recreated when `SearchOptions` request object changes\n const query = useCallback(\n async (page?: number) => {\n if (!index) return;\n\n // Set loading\n if (typeof page === 'number' && page > 0)\n searchDispatch({ loading: true });\n // If we’re not getting a new page, reset the hits\n else searchDispatch({ loading: true, hits: [] });\n\n const response = await index.search<Hit>('', {\n ...request,\n // Allow getMore() to work even if the user\n // has set page in requestDispatch\n page: page ?? request.page ?? 0,\n });\n\n searchDispatch({ response, loading: false });\n },\n [index, request]\n );\n\n // Get completely new query when `query` function is recreated above\n useEffect(() => {\n query();\n }, [query]);\n\n // Get more by incrementing the page. Does nothing if we’re still waiting\n // on new results to arrive or if there are no more pages to be loaded\n const getMore = () => {\n if (searchState.response && !searchState.loading && searchState.hasMore)\n query(searchState.response.page + 1);\n };\n\n // Updates Algolia config and creates a new index, then updates state\n const setAlgoliaConfig = useCallback(\n (\n newConfig: Partial<\n Pick<SearchState<Hit>, 'appId' | 'searchKey' | 'indexName'>\n >\n ) => {\n const updates: Partial<SearchState<Hit>> = {};\n // Only pass updated config items that are not undefined\n if (newConfig.appId) updates.appId = newConfig.appId;\n if (newConfig.searchKey) updates.searchKey = newConfig.searchKey;\n if (newConfig.indexName) updates.indexName = newConfig.indexName;\n\n // Generate new index with latest data\n updates.index = createAlgoliaIndex(\n updates.appId ?? searchState.appId,\n updates.searchKey ?? searchState.searchKey,\n updates.indexName ?? searchState.indexName\n );\n\n searchDispatch(updates);\n },\n []\n );\n // Update config when main useAlgolia props update\n useEffect(() => {\n setAlgoliaConfig({ appId, searchKey, indexName });\n }, [appId, searchKey, indexName]);\n\n return [\n { ...searchState, request },\n requestDispatch,\n getMore,\n setAlgoliaConfig,\n query,\n ] as [\n typeof searchState & { request: typeof request },\n typeof requestDispatch,\n typeof getMore,\n typeof setAlgoliaConfig,\n typeof query\n ];\n}\n\nexport default useAlgolia;\n"],"names":["undefined","createAlgoliaIndex","appId","searchKey","indexName","algoliasearch","initIndex","generateSearchReducer","prevState","updates","gotMore","response","page","hits","hasMore","nbPages","useAlgolia","initialRequest","useReducer","loading","index","searchState","searchDispatch","prev","request","requestDispatch","query","useCallback","search","useEffect","getMore","setAlgoliaConfig","newConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAO,IAAI,UAAU,OAAO,EAAE;AAElC;AACA,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;AAC5B,EAAE,IAAI,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC;AACjC,EAAE,IAAIA,WAAS,CAAC;AAChB,EAAE,IAAI,OAAO,GAAG,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;AAC3D,EAAE,IAAI,cAAc,GAAG,OAAO,CAAC,QAAQ,IAAI,YAAY,CAAC;AACxD,EAAE,IAAI,mBAAmB,GAAG,OAAO,CAAC,aAAa,IAAI,iBAAiB,CAAC;AACvE,EAAE,IAAI,iBAAiB,GAAG,OAAO,CAAC,WAAW,IAAI,eAAe,CAAC;AACjE;AACA,EAAE,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;AACnC,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE;AACpC,MAAM,KAAK,EAAE,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AACRE,IAAAA,gBAAgB,CAAC;AAAE7B,MAAAA,KAAK,EAALA,KAAF;AAASC,MAAAA,SAAS,EAATA,SAAT;AAAoBC,MAAAA,SAAS,EAATA;AAApB,KAAD,CAAhB;AACD,GAFQ,EAEN,CAACF,KAAD,EAAQC,SAAR,EAAmBC,SAAnB,CAFM,CAAT;AAIA,SAAO,cACAiB,WADA;AACaG,IAAAA,OAAO,EAAPA;AADb,MAELC,eAFK,EAGLK,OAHK,EAILC,gBAJK,EAKLL,KALK,CAAP;AAaD;;;;;"} |
+4
-9
@@ -12,3 +12,3 @@ { | ||
| ], | ||
| "version": "1.5.0", | ||
| "version": "1.5.1", | ||
| "license": "MIT", | ||
@@ -38,7 +38,2 @@ "author": "Sidney Alcantara", | ||
| }, | ||
| "husky": { | ||
| "hooks": { | ||
| "pre-commit": "tsdx lint" | ||
| } | ||
| }, | ||
| "prettier": { | ||
@@ -59,6 +54,6 @@ "printWidth": 80, | ||
| "react-dom": "^16.13.0", | ||
| "tsdx": "^0.12.3", | ||
| "tslib": "^1.11.1", | ||
| "typescript": "^3.8.3" | ||
| "tsdx": "^0.14.1", | ||
| "tslib": "^2.2.0", | ||
| "typescript": "^4.3.2" | ||
| } | ||
| } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
247890
293.05%1832
327.04%7
250%4
Infinity%