@nosto/search-js 3.15.0 → 3.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AutocompletePageProvider-CBobTZvT.cjs +1 -0
- package/dist/AutocompletePageProvider-Z4OvIKy-.js +35 -0
- package/dist/{InfiniteScrollWithObserver-BN-pDinB.cjs → InfiniteScrollWithObserver-CwWRBU3q.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-CEtMyahq.js → InfiniteScrollWithObserver-kW5lM7Jh.js} +1 -1
- package/dist/isBot-Bs99-Wlv.cjs +1 -0
- package/dist/isBot-Dt3hQTa6.js +20 -0
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +1 -1
- package/dist/preact/common/common.cjs.js +1 -1
- package/dist/preact/common/common.es.js +3 -3
- package/dist/preact/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.d.ts +2 -0
- package/dist/preact/hooks/hooks.es.js +278 -216
- package/dist/preact/hooks/src/useHistory.d.ts +1 -1
- package/dist/preact/hooks/src/useShopifyProduct/types.d.ts +72 -0
- package/dist/preact/hooks/src/useShopifyProduct/useShopifyProduct.d.ts +39 -0
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +1 -1
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +2 -2
- package/dist/useHistory-D7detcsc.cjs +1 -0
- package/dist/useHistory-DtcY_Wkt.js +23 -0
- package/dist/{useLoadMore-BR-vDmqW.js → useLoadMore-CYYoAHua.js} +1 -1
- package/dist/{useLoadMore-DPYhbXHC.cjs → useLoadMore-QOHOP_fr.cjs} +1 -1
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.es.js +1 -1
- package/package.json +5 -5
- package/dist/AutocompletePageProvider-BJxsORbo.cjs +0 -1
- package/dist/AutocompletePageProvider-DI2PONk8.js +0 -37
- package/dist/isBot-Lnmft0Z0.js +0 -20
- package/dist/isBot-iyBlT_oq.cjs +0 -1
- package/dist/useHistory-2uGnArVO.cjs +0 -1
- package/dist/useHistory-W6FQSk99.js +0 -20
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shopify product data structure from handle.js endpoint
|
|
3
|
+
*/
|
|
4
|
+
export interface ShopifyProduct {
|
|
5
|
+
id: number;
|
|
6
|
+
title: string;
|
|
7
|
+
handle: string;
|
|
8
|
+
description: string;
|
|
9
|
+
published_at: string;
|
|
10
|
+
created_at: string;
|
|
11
|
+
vendor: string;
|
|
12
|
+
type: string;
|
|
13
|
+
tags: string[];
|
|
14
|
+
price: number;
|
|
15
|
+
price_min: number;
|
|
16
|
+
price_max: number;
|
|
17
|
+
available: boolean;
|
|
18
|
+
price_varies: boolean;
|
|
19
|
+
compare_at_price: number | null;
|
|
20
|
+
compare_at_price_min: number;
|
|
21
|
+
compare_at_price_max: number;
|
|
22
|
+
compare_at_price_varies: boolean;
|
|
23
|
+
variants: ShopifyVariant[];
|
|
24
|
+
images: string[];
|
|
25
|
+
featured_image: string;
|
|
26
|
+
options: ShopifyOption[];
|
|
27
|
+
url: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ShopifyVariant {
|
|
30
|
+
id: number;
|
|
31
|
+
title: string;
|
|
32
|
+
option1: string | null;
|
|
33
|
+
option2: string | null;
|
|
34
|
+
option3: string | null;
|
|
35
|
+
sku: string;
|
|
36
|
+
requires_shipping: boolean;
|
|
37
|
+
taxable: boolean;
|
|
38
|
+
featured_image: ShopifyImage | null;
|
|
39
|
+
available: boolean;
|
|
40
|
+
name: string;
|
|
41
|
+
public_title: string;
|
|
42
|
+
options: string[];
|
|
43
|
+
price: number;
|
|
44
|
+
weight: number;
|
|
45
|
+
compare_at_price: number | null;
|
|
46
|
+
inventory_management: string;
|
|
47
|
+
barcode: string;
|
|
48
|
+
featured_media: ShopifyMedia;
|
|
49
|
+
}
|
|
50
|
+
export interface ShopifyImage {
|
|
51
|
+
id: number;
|
|
52
|
+
product_id: number;
|
|
53
|
+
position: number;
|
|
54
|
+
created_at: string;
|
|
55
|
+
updated_at: string;
|
|
56
|
+
alt: string | null;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
src: string;
|
|
60
|
+
variant_ids: number[];
|
|
61
|
+
}
|
|
62
|
+
export interface ShopifyMedia {
|
|
63
|
+
alt: string | null;
|
|
64
|
+
id: number;
|
|
65
|
+
position: number;
|
|
66
|
+
preview_image: ShopifyImage;
|
|
67
|
+
}
|
|
68
|
+
export interface ShopifyOption {
|
|
69
|
+
name: string;
|
|
70
|
+
position: number;
|
|
71
|
+
values: string[];
|
|
72
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ShopifyProduct } from './types';
|
|
2
|
+
export interface UseShopifyProductState {
|
|
3
|
+
product: ShopifyProduct | null;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Preact hook that fetches and exposes product data from Shopify's handle.js endpoint.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { useShopifyProduct } from '@nosto/search-js/preact/hooks'
|
|
13
|
+
*
|
|
14
|
+
* export default function ProductPage() {
|
|
15
|
+
* const { product, loading, error } = useShopifyProduct("my-product-handle")
|
|
16
|
+
*
|
|
17
|
+
* if (loading) return <div>Loading...</div>
|
|
18
|
+
* if (error) return <div>Error: {error}</div>
|
|
19
|
+
* if (!product) return <div>Product not found</div>
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <div>
|
|
23
|
+
* <h1>{product.title}</h1>
|
|
24
|
+
* <p>{product.description}</p>
|
|
25
|
+
* <p>Price: ${product.price / 100}</p>
|
|
26
|
+
* </div>
|
|
27
|
+
* )
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param handle - The Shopify product handle
|
|
32
|
+
* @returns Object containing product data, loading state, and error state
|
|
33
|
+
* @group Hooks
|
|
34
|
+
*/
|
|
35
|
+
export declare function useShopifyProduct(handle: string): UseShopifyProductState;
|
|
36
|
+
/**
|
|
37
|
+
* Clears the product cache (useful for testing)
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearShopifyProductCache(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-CBobTZvT.cjs"),T=require("../../CategoryPageProvider-CYRnaUx1.cjs"),h=require("../../useActions-Drtoxcu4.cjs"),I=require("../../SerpPageProvider-s4dO49Fx.cjs"),d=require("../../jsxRuntime.module-B3sGoTIU.cjs"),g=require("../../ErrorBoundary-CKn3Ecpu.cjs"),b=require("../../disableNativeAutocomplete-DI6zaZII.cjs"),P=require("../../unique-BXXNictB.cjs"),C=require("preact"),N=require("../../logger-Boh_C6Bz.cjs"),p=require("../../search-RNs4Cunh.cjs");function O(e){let n;return t=>{n&&clearTimeout(n),n=setTimeout(t,e)}}function q(e){return Array.from(document.querySelectorAll(e))}function R(e){const n=[];let t=e.parentNode;for(;t&&t!==document&&t instanceof Element;)n.push(t),t=t.parentNode;return n}function E([e,n],t){const o=r=>{const s=r.target;s instanceof HTMLElement&&e&&s!==e&&s!==n&&!R(s).includes(e)&&t()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function A(e,n){e.tabIndex=0,e.addEventListener("blur",n)}function S(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function H({selector:e,timeout:n=500}){return new Promise(t=>{const o=q(e);if(o.length>0)return t(o);const r=new MutationObserver(()=>{const i=q(e);i.length>0&&(r.disconnect(),clearTimeout(s),t(i))}),s=setTimeout(()=>{r.disconnect(),N.logger.warn(`Timed out (${n}) while waiting for element ${e}`),t([])},n);r.observe(document.body,{childList:!0,subtree:!0})})}function x(e,n,t){n.style.display="none";const o=(()=>{if(e.parentElement&&e.parentElement.classList.contains("nosto-autocomplete-wrapper"))return e.parentElement;const a=document.createElement("div");return a.className="nosto-autocomplete-wrapper",e.parentNode?.insertBefore(a,e.nextSibling),a.appendChild(e),a})(),r=S(t),s=r&&document.querySelector(r.selector);if(s){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(n),r.position==="first"?s.prepend(a):s.appendChild(a)}else o.appendChild(n);const i={index:-1,onChangeListeners:[]},c=(a,u)=>{const f=a.length;f===0&&(u=-1),i.index=u>=0?u%f:f-1,i.onChangeListeners.forEach(D=>D())},l=()=>{i.index=-1,i.onChangeListeners.forEach(a=>a())},m=()=>i.index;return{element:n,hide:()=>{n.style.display="none",l()},show:()=>{n.style.display="inherit"},isOpen:()=>n.style.display!=="none",goDown:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u+1)},goUp:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u-1)},highlight:c,highlightedIndex:m,submitHighlightedItem:a=>{Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{i.onChangeListeners.push(a)}}}function $(e,n){const t=document.createElement("div");return t.className="nosto-autocomplete-dropdown",{...x(e,t,n),element:t}}const y="nosto:search-js:history";function v(e,n,t){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...x(e,o,n),element:o,add:s=>{const c=(p.getLocalStorageItem(y)??[]).filter(l=>l!==s).slice(t?-t:0);c.push(s),p.setLocalStorageItem(y,c)},get:()=>(p.getLocalStorageItem(y)??[]).reverse().filter(i=>!!i)}}async function F(e,{config:n,dropdown:t,history:o,renderHistory:r,store:s}){const{historyEnabled:i,minQueryLength:c}=n;if(e.length<c&&i&&r&&!o.isOpen()){o.show();return}if(e.length<c)return;t.hide();const l=s.getState()?.query?.query;l&&l!==e&&await h.newSearch({config:n,store:s},{query:e}),t.show()}async function k(e,n){const{config:t,renderHistory:o,history:r}=n,{historyEnabled:s,minQueryLength:i}=t;if(!o||e.length>=i||!s||r.isOpen())return;const c=j(n);r.onHighlightChange(()=>{c(o,r.element)}),r.show();const l=P.measure("renderHistory");c(o,r.element),l()}async function Q(e,{config:n,dropdown:t,history:o,store:r,debouncer:s}){const{minQueryLength:i,historyEnabled:c}=n;if(e.length<i&&!c){t.hide(),o.hide();return}if(e.length<i&&c){t.hide(),o.show();return}o.hide(),s(async()=>{h.newSearch({config:n,store:r},{query:e}),t.show()})}function M(e,n,t){const{config:o,debouncer:r}=t;if(r(()=>{}),e.length>=o.minQueryLength)return L(n,t.dropdown,t.history);if(o.historyEnabled)return L(n,t.history,t.dropdown)}function L(e,n,t){if(!n.isOpen()&&e==="ArrowDown"){n.show(),t.hide();return}if(e==="Escape"&&n.hide(),!!n.isOpen()){if(e==="ArrowDown")n.goDown();else if(e==="ArrowUp")n.goUp();else if(e==="Enter"){const o=n.highlightedIndex();return o>=0&&n.submitHighlightedItem(o),n.hide(),o>=0}}}function U(e,{config:n,dropdown:t,history:o,onNavigateToSearch:r,store:s}){t.hide(),o.hide(),!(e.length<n.minQueryLength)&&(o.add(e),s.updateState({historyItems:o.get()}),r?.({query:e}))}async function K(e,n){const{inputCssSelector:t,timeout:o}=e,r=S(t).selector,s=await H({selector:r,timeout:o});if(s.length===0)throw new Error(`No elements found for selector: ${r}`);s.forEach(i=>{_(i,e,n)})}async function _(e,n,t){const{config:o,dropdownCssSelector:r}=n,s=$(e,r),i=v(e,r,o.historySize),c={...n,input:e,dropdown:s,history:i,store:t,debouncer:O(o.debounceDelay)};G(c),e.setAttribute("data-nosto-element","search-input"),t.updateState({historyItems:i.get()}),b.disableNativeAutocomplete(e),t.onInit(()=>{z(c)}),b.bindInput(e,{onInput:l=>Q(l,c),onFocus:l=>k(l,c),onClick:l=>F(l,c),onSubmit:l=>U(l,c),onKeyDown:(l,m)=>M(l,m,c)}),A(i.element,i.hide),A(s.element,s.hide),E([i.element,e],i.hide),E([s.element,e],s.hide)}function z(e){const{dropdown:n,renderAutocomplete:t}=e;if(!t)return;const o=j(e);n.onHighlightChange(()=>{o(t,n.element)});const r=P.measure("renderAutocomplete");o(t,n.element),r()}async function G(e){const{input:n,renderSpeechToText:t,config:o,store:r}=e;if(!t)return;const s="ns-autocomplete-voice-position";if(!!n.parentElement?.querySelector(`.${s}`))return;const c=document.createElement("div");c.className=s,n.insertAdjacentElement("afterend",c);const l=await t();C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:o,store:r,children:l})}),c)}function j(e){const{config:n,store:t}=e;return(o,r)=>C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:n,store:t,children:o()})}),r)}async function B({cssSelector:e,timeout:n,renderComponent:t}){const o=S(e).selector,r=await H({selector:o,timeout:n??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&N.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),C.render(t(),r[0])}async function J(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(T.CategoryPageProvider,{store:n,config:e.config,children:o})})})}async function V(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(I.SearchPageProvider,{store:n,config:e.config,children:o})})})}async function W({autocomplete:e,category:n,serp:t}){const o={};if(e){const r=h.createStore({query:e.query});await K({...e,config:w.makeAutocompleteConfig(e.config)},r),o.autocomplete={store:r}}if(n){const r=h.createStore({query:n.query});await J({...n,config:T.makeCategoryConfig(n.config)},r),o.category={store:r}}if(t){const r=h.createStore({query:t.query});await V({...t,config:I.makeSerpConfig(t.config)},r),o.serp={store:r}}return o}exports.init=W;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as L, m as j } from "../../AutocompletePageProvider-
|
|
1
|
+
import { A as L, m as j } from "../../AutocompletePageProvider-Z4OvIKy-.js";
|
|
2
2
|
import { C as O, m as R } from "../../CategoryPageProvider-DcQlylFg.js";
|
|
3
3
|
import { n as T, c as p } from "../../useActions-MsVW37eV.js";
|
|
4
4
|
import { S as $, m as F } from "../../SerpPageProvider-CsrFA6mA.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-Drtoxcu4.cjs"),r=require("../../InfiniteScrollWithObserver-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-Drtoxcu4.cjs"),r=require("../../InfiniteScrollWithObserver-CwWRBU3q.cjs"),t=require("../../useLoadMore-QOHOP_fr.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as t, u as a } from "../../useActions-MsVW37eV.js";
|
|
2
|
-
import { I as s, i } from "../../InfiniteScrollWithObserver-
|
|
3
|
-
import { g as p } from "../../useLoadMore-
|
|
2
|
+
import { I as s, i } from "../../InfiniteScrollWithObserver-kW5lM7Jh.js";
|
|
3
|
+
import { g as p } from "../../useLoadMore-CYYoAHua.js";
|
|
4
4
|
export {
|
|
5
5
|
s as InfiniteScrollWithObserver,
|
|
6
6
|
p as getNextPageQuery,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("./useActions-Drtoxcu4.cjs"),o=require("./search-RNs4Cunh.cjs"),a=require("preact/hooks"),s="nosto:search-js:history";function l(){return(o.getLocalStorageItem(s)??[]).slice().reverse().filter(e=>!!e)}function y(){const{updateState:t}=a.useContext(n.StoreContext),{historySize:e}=n.useAutocompleteConfig();return{addQuery:a.useCallback(r=>{const i=(o.getLocalStorageItem(s)??[]).filter(u=>u!==r).concat(r),c=e?i.slice(-e):[];o.setLocalStorageItem(s,c),t({historyItems:c.reverse()})},[e,t])}}exports.getSaved=l;exports.useHistory=y;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { S as i, a as l } from "./useActions-MsVW37eV.js";
|
|
2
|
+
import { g as a, a as m } from "./search-mArZ2PXy.js";
|
|
3
|
+
import { useContext as u, useCallback as y } from "preact/hooks";
|
|
4
|
+
const o = "nosto:search-js:history";
|
|
5
|
+
function p() {
|
|
6
|
+
return (a(o) ?? []).slice().reverse().filter((t) => !!t);
|
|
7
|
+
}
|
|
8
|
+
function I() {
|
|
9
|
+
const { updateState: e } = u(i), { historySize: t } = l();
|
|
10
|
+
return {
|
|
11
|
+
addQuery: y(
|
|
12
|
+
(s) => {
|
|
13
|
+
const c = (a(o) ?? []).filter((n) => n !== s).concat(s), r = t ? c.slice(-t) : [];
|
|
14
|
+
m(o, r), e({ historyItems: r.reverse() });
|
|
15
|
+
},
|
|
16
|
+
[t, e]
|
|
17
|
+
)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
p as g,
|
|
22
|
+
I as u
|
|
23
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as n, h as u } from "./useActions-MsVW37eV.js";
|
|
2
2
|
import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
|
|
3
|
-
import { i as m } from "./isBot-
|
|
3
|
+
import { i as m } from "./isBot-Dt3hQTa6.js";
|
|
4
4
|
function l(t = p) {
|
|
5
5
|
const e = a(n), [o, r] = c(t(e.getState()));
|
|
6
6
|
return e.onChange(t, r), i(() => () => e.clearOnChange(r), [e]), o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-Drtoxcu4.cjs"),r=require("preact/hooks"),i=require("./isBot-
|
|
1
|
+
"use strict";const n=require("./useActions-Drtoxcu4.cjs"),r=require("preact/hooks"),i=require("./isBot-Bs99-Wlv.cjs");function c(e=f){const t=r.useContext(n.StoreContext),[o,s]=r.useState(e(t.getState()));return t.onChange(e,s),r.useEffect(()=>()=>t.clearOnChange(s),[t]),o}const f=e=>e;function a({from:e,size:t,pageSize:o}){return i.isBot()?{products:{from:e+o}}:{products:{size:t+o}}}function d(e=24){const{from:t,size:o}=c(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:s}=n.useActions();return{loadMore:r.useCallback(async()=>{await s(a({from:t,size:o,pageSize:e}))},[t,o,e,s])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
|
package/dist/utils/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../disableNativeAutocomplete-DI6zaZII.cjs"),t=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),u=require("../isBot-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../disableNativeAutocomplete-DI6zaZII.cjs"),t=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),u=require("../isBot-Bs99-Wlv.cjs"),r=require("../logger-Boh_C6Bz.cjs"),s=require("../parseNumber-FsZ8w61u.cjs"),o=require("../pick-rYi1lc2m.cjs");exports.bindInput=i.bindInput;exports.disableNativeAutocomplete=i.disableNativeAutocomplete;exports.cl=t.cl;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=u.isBot;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.logger=r.logger;exports.parseNumber=s.parseNumber;exports.pick=o.pick;
|
package/dist/utils/utils.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { b as r, d as s } from "../disableNativeAutocomplete-Bkta_WR2.js";
|
|
2
2
|
import { c as p } from "../cl-CcykAxZN.js";
|
|
3
3
|
import { d as m, a as i, m as u, u as f } from "../unique-Cv2g464w.js";
|
|
4
|
-
import { i as x } from "../isBot-
|
|
4
|
+
import { i as x } from "../isBot-Dt3hQTa6.js";
|
|
5
5
|
import { i as c, a as d, l as g } from "../logger-_fg_Za9y.js";
|
|
6
6
|
import { p as q } from "../parseNumber-QA48nJLp.js";
|
|
7
7
|
import { p as N } from "../pick-DReBictn.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"prepare": "husky"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@commitlint/cli": "^
|
|
101
|
-
"@commitlint/config-conventional": "^
|
|
102
|
-
"@nosto/nosto-js": "^2.
|
|
100
|
+
"@commitlint/cli": "^20.0.0",
|
|
101
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
102
|
+
"@nosto/nosto-js": "^2.7.0",
|
|
103
103
|
"@testing-library/dom": "^10.4.1",
|
|
104
104
|
"@types/dom-speech-recognition": "^0.0.6",
|
|
105
105
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
117
117
|
"eslint-plugin-unused-imports": "^4.2.0",
|
|
118
118
|
"husky": "^9.1.7",
|
|
119
|
-
"isbot": "^5.1.
|
|
119
|
+
"isbot": "^5.1.31",
|
|
120
120
|
"jsdom": "^27.0.0",
|
|
121
121
|
"prettier": "^3.6.2",
|
|
122
122
|
"typedoc": "^0.28.13",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-Drtoxcu4.cjs"),u=require("./baseConfig-gkfFlBOL.cjs"),a=require("./useHistory-2uGnArVO.cjs"),l=require("preact/hooks"),m={...u.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function i(e={}){return{pageType:"autocomplete",...m,...e}}function f({config:e,store:s,children:c}){const t=s??r.createStore();u.useCheckClientScript();const{getSaved:n}=a.useHistory();return l.useEffect(()=>{t.updateState({historyItems:n()})},[t,n]),o.u(r.ConfigContext,{value:i(e),children:o.u(r.StoreContext,{value:t,children:[o.u(u.StoreActionsListener,{}),c]})})}exports.AutocompletePageProvider=f;exports.makeAutocompleteConfig=i;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { u as o } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as s, C as u } from "./useActions-MsVW37eV.js";
|
|
3
|
-
import { d as c, u as m, S as f } from "./baseConfig-BMc1698x.js";
|
|
4
|
-
import { u as l } from "./useHistory-W6FQSk99.js";
|
|
5
|
-
import { useEffect as p } from "preact/hooks";
|
|
6
|
-
const d = {
|
|
7
|
-
...c,
|
|
8
|
-
memoryCache: !1,
|
|
9
|
-
historyEnabled: !0,
|
|
10
|
-
historySize: 5,
|
|
11
|
-
debounceDelay: 500,
|
|
12
|
-
minQueryLength: 2
|
|
13
|
-
};
|
|
14
|
-
function C(e = {}) {
|
|
15
|
-
return {
|
|
16
|
-
pageType: "autocomplete",
|
|
17
|
-
...d,
|
|
18
|
-
...e
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function v({ config: e, store: a, children: i }) {
|
|
22
|
-
const t = a ?? n();
|
|
23
|
-
m();
|
|
24
|
-
const { getSaved: r } = l();
|
|
25
|
-
return p(() => {
|
|
26
|
-
t.updateState({
|
|
27
|
-
historyItems: r()
|
|
28
|
-
});
|
|
29
|
-
}, [t, r]), /* @__PURE__ */ o(u, { value: C(e), children: /* @__PURE__ */ o(s, { value: t, children: [
|
|
30
|
-
/* @__PURE__ */ o(f, {}),
|
|
31
|
-
i
|
|
32
|
-
] }) });
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
v as A,
|
|
36
|
-
C as m
|
|
37
|
-
};
|
package/dist/isBot-Lnmft0Z0.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var r = " daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^azure|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|agent|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|fetcher|firephp|functionize|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/", t = /bot|crawl|http|lighthouse|scan|search|spider/i, e;
|
|
2
|
-
function o() {
|
|
3
|
-
if (e instanceof RegExp)
|
|
4
|
-
return e;
|
|
5
|
-
try {
|
|
6
|
-
e = new RegExp(r, "i");
|
|
7
|
-
} catch {
|
|
8
|
-
e = t;
|
|
9
|
-
}
|
|
10
|
-
return e;
|
|
11
|
-
}
|
|
12
|
-
function s(a) {
|
|
13
|
-
return !!a && o().test(a);
|
|
14
|
-
}
|
|
15
|
-
function c() {
|
|
16
|
-
return s(navigator.userAgent);
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
c as i
|
|
20
|
-
};
|
package/dist/isBot-iyBlT_oq.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var r=" daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^azure|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|agent|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|fetcher|firephp|functionize|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/",t=/bot|crawl|http|lighthouse|scan|search|spider/i,e;function o(){if(e instanceof RegExp)return e;try{e=new RegExp(r,"i")}catch{e=t}return e}function s(a){return!!a&&o().test(a)}function c(){return s(navigator.userAgent)}exports.isBot=c;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./useActions-Drtoxcu4.cjs"),o=require("./search-RNs4Cunh.cjs"),s=require("preact/hooks"),r="nosto:search-js:history";function S(){const{updateState:c}=s.useContext(i.StoreContext),{historySize:e}=i.useAutocompleteConfig(),l=s.useCallback(t=>{const m=(o.getLocalStorageItem(r)??[]).filter(y=>y!==t).concat(t),a=e?m.slice(-e):[];o.setLocalStorageItem(r,a),c({historyItems:a.reverse()})},[e,c]),u=s.useCallback(()=>(o.getLocalStorageItem(r)??[]).slice().reverse().filter(n=>!!n),[]);return{addQuery:l,getSaved:u}}exports.useHistory=S;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { S, a as y } from "./useActions-MsVW37eV.js";
|
|
2
|
-
import { g as c, a as g } from "./search-mArZ2PXy.js";
|
|
3
|
-
import { useContext as f, useCallback as n } from "preact/hooks";
|
|
4
|
-
const o = "nosto:search-js:history";
|
|
5
|
-
function d() {
|
|
6
|
-
const { updateState: s } = f(S), { historySize: t } = y(), i = n(
|
|
7
|
-
(e) => {
|
|
8
|
-
const m = (c(o) ?? []).filter((u) => u !== e).concat(e), a = t ? m.slice(-t) : [];
|
|
9
|
-
g(o, a), s({ historyItems: a.reverse() });
|
|
10
|
-
},
|
|
11
|
-
[t, s]
|
|
12
|
-
), l = n(() => (c(o) ?? []).slice().reverse().filter((r) => !!r), []);
|
|
13
|
-
return {
|
|
14
|
-
addQuery: i,
|
|
15
|
-
getSaved: l
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
d as u
|
|
20
|
-
};
|