@nosto/search-js 3.15.0 → 3.16.0
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/{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/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/useShopifyProduct/types.d.ts +72 -0
- package/dist/preact/hooks/src/useShopifyProduct/useShopifyProduct.d.ts +39 -0
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +2 -2
- 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/isBot-Lnmft0Z0.js +0 -20
- package/dist/isBot-iyBlT_oq.cjs +0 -1
package/dist/{InfiniteScrollWithObserver-BN-pDinB.cjs → InfiniteScrollWithObserver-CwWRBU3q.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-
|
|
1
|
+
"use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-QOHOP_fr.cjs"),N=require("./logger-Boh_C6Bz.cjs"),x=require("./pick-rYi1lc2m.cjs"),u=require("preact"),h=require("preact/hooks");function E(e,r){const t=r.products?.total??0,o=e.products?.from??0,n=e.products?.size??0;return t>0&&t>o+n}function A(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function M(e,r){for(var t in r)e[t]=r[t];return e}function f(e,r){for(var t in e)if(t!=="__source"&&!(t in r))return!0;for(var o in r)if(o!=="__source"&&e[o]!==r[o])return!0;return!1}function m(e,r){this.props=e,this.context=r}function U(e,r){function t(n){var s=this.props.ref,i=s==n.ref;return!i&&s&&(s.call?s(null):s.current=null),r?!r(this.props,n)||!i:f(this.props,n)}function o(n){return this.shouldComponentUpdate=t,u.createElement(e,n)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o}(m.prototype=new u.Component).isPureReactComponent=!0,m.prototype.shouldComponentUpdate=function(e,r){return f(this.props,e)||f(this.state,r)};var y=u.options.__b;u.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),y&&y(e)};var q=u.options.__e;u.options.__e=function(e,r,t,o){if(e.then){for(var n,s=r;s=s.__;)if((n=s.__c)&&n.__c)return r.__e==null&&(r.__e=t.__e,r.__k=t.__k),n.__c(e,r)}q(e,r,t,o)};var b=u.options.unmount;function P(e,r,t){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=M({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return P(o,r,t)})),e}function R(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return R(o,r,t)}),e.__c&&e.__c.__P===r&&(e.__e&&t.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=t)),e}function p(){this.__u=0,this.o=null,this.__b=null}function S(e){var r=e.__.__c;return r&&r.__a&&r.__a(e)}function c(){this.i=null,this.l=null}u.options.unmount=function(e){var r=e.__c;r&&r.__R&&r.__R(),r&&32&e.__u&&(e.type=null),b&&b(e)},(p.prototype=new u.Component).__c=function(e,r){var t=r.__c,o=this;o.o==null&&(o.o=[]),o.o.push(t);var n=S(o.__v),s=!1,i=function(){s||(s=!0,t.__R=null,n?n(_):_())};t.__R=i;var _=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=R(l,l.__c.__P,l.__c.__O)}var a;for(o.setState({__a:o.__b=null});a=o.o.pop();)a.forceUpdate()}};o.__u++||32&r.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},p.prototype.componentWillUnmount=function(){this.o=[]},p.prototype.render=function(e,r){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=P(this.__b,t,o.__O=o.__P)}this.__b=null}var n=r.__a&&u.createElement(u.Fragment,null,e.fallback);return n&&(n.__u&=-33),[u.createElement(u.Fragment,null,r.__a?null:e.children),n]};var g=function(e,r,t){if(++t[1]===t[0]&&e.l.delete(r),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(c.prototype=new u.Component).__a=function(e){var r=this,t=S(r.__v),o=r.l.get(e);return o[0]++,function(n){var s=function(){r.props.revealOrder?(o.push(n),g(r,e,o)):n()};t?t(s):s()}},c.prototype.render=function(e){this.i=null,this.l=new Map;var r=u.toChildArray(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&r.reverse();for(var t=r.length;t--;)this.l.set(r[t],this.i=[1,0,this.i]);return e.children},c.prototype.componentDidUpdate=c.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(r,t){g(e,t,r)})};var I=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,j=/[A-Z0-9]/g,F=typeof document<"u",H=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};u.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(u.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})});var k=u.options.event;function L(){}function z(){return this.cancelBubble}function B(){return this.defaultPrevented}u.options.event=function(e){return k&&(e=k(e)),e.persist=L,e.isPropagationStopped=z,e.isDefaultPrevented=B,e.nativeEvent=e};var D={enumerable:!1,configurable:!0,get:function(){return this.class}},O=u.options.vnode;u.options.vnode=function(e){typeof e.type=="string"&&function(r){var t=r.props,o=r.type,n={},s=o.indexOf("-")===-1;for(var i in t){var _=t[i];if(!(i==="value"&&"defaultValue"in t&&_==null||F&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var l=i.toLowerCase();i==="defaultValue"&&"value"in t&&t.value==null?i="value":i==="download"&&_===!0?_="":l==="translate"&&_==="no"?_=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?i="ondblclick":l!=="onchange"||o!=="input"&&o!=="textarea"||H(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":V.test(i)&&(i=l):l=i="oninput":s&&W.test(i)?i=i.replace(j,"-$&").toLowerCase():_===null&&(_=void 0),l==="oninput"&&n[i=l]&&(i="oninputCapture"),n[i]=_}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.value.indexOf(a.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.multiple?n.defaultValue.indexOf(a.props.value)!=-1:n.defaultValue==a.props.value})),t.class&&!t.className?(n.class=t.class,Object.defineProperty(n,"className",D)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=I,O&&O(e)};var C=u.options.__r;u.options.__r=function(e){C&&C(e),e.__c};var w=u.options.diffed;u.options.diffed=function(e){w&&w(e);var r=e.props,t=e.__e;t!=null&&e.type==="textarea"&&"value"in r&&r.value!==t.value&&(t.value=r.value==null?"":r.value)};function T({children:e,pageSize:r,observerOptions:t}){const o=h.useRef(null),{query:n,response:s}=d.useNostoAppState(_=>x.pick(_,"query","response")),{loadMore:i}=d.useLoadMore(r);return h.useEffect(()=>{let _,l;return E(n,s)&&(_=o.current,l=new IntersectionObserver(a=>{a[0]?.isIntersecting&&i()},t),_&&l.observe(_)),()=>{_&&l.unobserve(_)}},[s]),v.u(u.Fragment,{children:[e,v.u("div",{ref:o,style:{height:"1px"}})]})}const $=U(T,N.isEqual);exports.InfiniteScrollWithObserver=$;exports.hasMoreResults=E;exports.intersectionObserverSupported=A;
|
package/dist/{InfiniteScrollWithObserver-CEtMyahq.js → InfiniteScrollWithObserver-kW5lM7Jh.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as y } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { a as x, u as U } from "./useLoadMore-
|
|
2
|
+
import { a as x, u as U } from "./useLoadMore-CYYoAHua.js";
|
|
3
3
|
import { i as I } from "./logger-_fg_Za9y.js";
|
|
4
4
|
import { p as A } from "./pick-DReBictn.js";
|
|
5
5
|
import { Component as c, options as l, createElement as v, Fragment as d, toChildArray as h } from "preact";
|
|
@@ -0,0 +1 @@
|
|
|
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|24x7|@[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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var r = " daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|24x7|@[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
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-CKn3Ecpu.cjs"),g=require("../../isBot-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-CKn3Ecpu.cjs"),g=require("../../isBot-Bs99-Wlv.cjs"),o=require("../../jsxRuntime.module-B3sGoTIU.cjs"),u=require("../../useLoadMore-QOHOP_fr.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-CwWRBU3q.cjs"),C=require("preact"),e=require("../../useActions-Drtoxcu4.cjs");function q({pageSize:t}){const{loadMore:r}=u.useLoadMore(t);return o.u("button",{onClick:r,children:"More results"})}function s({children:t,loadMoreComponent:r,pageSize:i}){const{loading:c,query:l,response:a}=u.useNostoAppState(f=>p.pick(f,"loading","query","response")),d=!c&&n.hasMoreResults(l,a);return o.u(C.Fragment,{children:[t,d&&(r?o.u(r,{pageSize:i}):o.u(q,{pageSize:i}))]})}const y=!g.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:s;exports.ErrorBoundary=S.ErrorBoundary;exports.StoreContext=e.StoreContext;exports.createExtendableStore=e.createExtendableStore;exports.createStore=e.createStore;exports.defaultState=e.defaultState;exports.useAutocompleteConfig=e.useAutocompleteConfig;exports.useCategoryConfig=e.useCategoryConfig;exports.useConfig=e.useConfig;exports.useSerpConfig=e.useSerpConfig;exports.InfiniteScroll=y;exports.InfiniteScrollWithLink=s;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { E as v } from "../../ErrorBoundary-DTRm_60r.js";
|
|
2
|
-
import { i as f } from "../../isBot-
|
|
2
|
+
import { i as f } from "../../isBot-Dt3hQTa6.js";
|
|
3
3
|
import { u as e } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
4
|
-
import { u as p, a as c } from "../../useLoadMore-
|
|
4
|
+
import { u as p, a as c } from "../../useLoadMore-CYYoAHua.js";
|
|
5
5
|
import { p as l } from "../../pick-DReBictn.js";
|
|
6
|
-
import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-
|
|
6
|
+
import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-kW5lM7Jh.js";
|
|
7
7
|
import { Fragment as g } from "preact";
|
|
8
8
|
import { S as B, g as O, c as W, f as F, a as N, d as R, b as j, e as w } from "../../useActions-MsVW37eV.js";
|
|
9
9
|
function C({ pageSize: r }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("../../useActions-Drtoxcu4.cjs"),P=require("../../logger-Boh_C6Bz.cjs"),h=require("../../useLoadMore-QOHOP_fr.cjs"),d=require("preact/hooks"),L=require("../../useHistory-2uGnArVO.cjs"),T=require("../../index.es-Dp6Iaxz3.cjs"),A=require("../../parseNumber-FsZ8w61u.cjs");function q(e){const s=h.useNostoAppState(t=>t.response);return e&&Array.isArray(e)||e&&P.isPlainObject(e)?e:s}function z(e,s){const t=e.data?.filter(f=>f.selected).length??0,{active:r}={active:t>0,...s},[n,c]=d.useState(r),{toggleProductFilter:u}=y.useActions(),l=d.useCallback(()=>{c(!n)},[n]);return{active:n,selectedFiltersCount:t,toggleActive:l,toggleProductFilter:u}}function X(){const{loading:e,facets:s}=h.useNostoAppState(t=>({loading:t.loading,facets:t.response?.products?.facets??[]}));return{loading:e,facets:s}}function O(e,s){const t=s-e;return!isNaN(t)&&t>0?new Array(s-e).fill(void 0).map((r,n)=>n+e):[]}function j(e){const{query:s,products:t}=h.useNostoAppState(r=>({query:r.query,products:r.response.products}));return d.useMemo(()=>{if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const r=s.products?.from??0,n=e?.width??1/0,c=Math.max(Math.floor(n-1)/2,1),u=t.size>0?Math.floor(r/t.size)+1:1,l=t.size>0?Math.ceil(t.total/t.size):0,f=F=>F>=u-c&&F<=u+c,o=r+1,i=Math.min(r+t.total,t.total),a={from:r,page:u,current:!0},p=F=>({from:(F-1)*t.size,page:F,current:F===u}),S=u>1?p(u-1):void 0,m=u<l?p(u+1):void 0,g=u-c-1>1?p(1):void 0,v=u+c+1<l?p(l):void 0,b=O(1,l+1).filter(f).map(p);return!g&&b[0]?.page===2&&b.unshift(p(1)),!v&&b[b.length-1]?.page===l-1&&b.push(p(l)),{totalPages:l,resultsFrom:o,resultsTo:i,current:a,prev:S,next:m,first:g,last:v,pages:b}},[s,t,e?.width])}function D(){const[e,s]=d.useState([]),[t,r]=d.useState([]);return d.useEffect(()=>{T.s(async n=>{const{products:c,segments:u}=await n.getSearchSessionParams();s(u??[]),r(c?.personalizationBoost??[])})},[]),{segments:e,boost:t}}function E(){const{facets:e}=h.useNostoAppState(o=>({facets:o.response.products?.facets??[]})),{replaceFilter:s,toggleProductFilter:t}=y.useActions(),r=d.useCallback(o=>{const i=e?.find(a=>a.type==="stats"&&a.field===o);if(i&&"min"in i&&"max"in i)return i},[e]),n=d.useCallback(o=>e?.find(i=>i.field===o)?.name??o,[e]),c=d.useCallback(o=>"field"in o&&(o.value instanceof Array||o.range instanceof Array),[]),u=d.useCallback(o=>({...o,range:o.range?.map(i=>({gt:i.gt?Number(i.gt):i.gt,gte:i.gte?Number(i.gte):i.gte,lt:i.lt?Number(i.lt):i.lt,lte:i.lte?Number(i.lte):i.lte}))}),[]),l=d.useCallback(o=>(o.value??[]).map(a=>({value:a,field:o.field,name:n(o.field),filter:u(o),remove:()=>{t(o.field,a,!1)}})),[u,n,t]),f=d.useCallback(o=>(o.range??[]).map(a=>{const p=a.gte??a.gt??r(o.field)?.min,S=a.lte??a.lt??r(o.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:o.field,name:n(o.field),filter:u(o),remove:()=>{s(o.field,void 0)}}}).filter(Boolean),[u,r,n,s]);return{selectFilters:c,toValueFilter:l,toRangeFilter:f}}function k(){const{filter:e}=h.useNostoAppState(l=>({filter:l.query.products?.filter??[]})),{updateSearch:s}=y.useActions(),{selectFilters:t,toValueFilter:r,toRangeFilter:n}=E(),c=d.useMemo(()=>e?e.filter(t).flatMap(l=>"value"in l?r(l):"range"in l?n(l):[]).filter(Boolean):[],[e,t,n,r]),u=d.useCallback(()=>{s({products:{filter:[]}})},[s]);return{filters:c,removeAll:u}}function R(e){const{replaceFilter:s}=y.useActions(),{query:t,products:r}=h.useNostoAppState(a=>({query:a.query,products:a.response.products})),n=r?.facets?.find(a=>a.id===e);if(!n)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const c=t.products?.filter?.find(a=>a.field===n.field),u=c?.range?c.range[0]:void 0,l=typeof u=="object"&&("gte"in u||"lte"in u)?[A.parseNumber(u.gte),A.parseNumber(u.lte)]:[void 0,void 0],f="min"in n?Math.floor(n.min):0,o="max"in n?Math.ceil(n.max):0,i=([a,p])=>{const S=a!==void 0?Math.floor(a):void 0,m=p!==void 0?Math.ceil(p):void 0,g=S!==void 0,v=m!==void 0;(f===S||!g)&&(o===m||!v)?s(n.field,void 0):(f===S||!g)&&v?s(n.field,{lte:m.toString()}):(o===m||!v)&&g?s(n.field,{gte:S.toString()}):g&&v&&s(n.field,{gte:S.toString(),lte:m.toString()})};return{min:f,max:o,range:[l[0]??f,l[1]??o],updateRange:i}}function V(e,s){const{min:t,max:r,range:n,updateRange:c}=R(e),{filters:u}=k(),l=d.useMemo(()=>{const a=u.find(g=>g?.filter?.range);let p=null;if(a){const g=a.filter.range?.[0];p=[A.parseNumber(g?.gte),A.parseNumber(g?.lte)]}const S=[];let m=Math.floor(t/s)*s;for(;m<r;){const g=m+s,v=p&&p[0]===m&&p[1]===g;S.push({min:m,max:g,selected:v}),m=g}return S},[u,t,r,s]),f=a=>{c([a,n[1]])},o=a=>{c([n[0],a])},i=t!==n[0]||r!==n[1];return{min:t,max:r,range:n,updateRange:c,ranges:l,handleMinChange:f,handleMaxChange:o,isSelected:i}}function $(){const{products:e,keywords:s}=h.useNostoAppState(t=>t.response);return{products:e??{hits:[],total:0},keywords:s??{hits:[],total:0}}}function B(){const e=h.useNostoAppState(t=>t.query.products?.filter);return d.useMemo(()=>e?e.reduce((t,r)=>t+(Array.isArray(r.value)?r.value.length:1),0):0,[e])}const _=5*60*1e3,N=new Map;function H(e){const[s,t]=d.useState({product:null,loading:!0,error:null});return d.useEffect(()=>{if(!e){t({product:null,loading:!1,error:"Product handle is required"});return}t(n=>({...n,loading:!0,error:null}));const r=I(e);if(r){t({product:r,loading:!1,error:null});return}U(e).then(n=>{Z(e,n),t({product:n,loading:!1,error:null})}).catch(n=>{t({product:null,loading:!1,error:n.message||"Failed to fetch product"})})},[e]),s}async function U(e){const s=await fetch(`/products/${e}.js`);if(!s.ok)throw new Error(`Failed to fetch product: ${s.status} ${s.statusText}`);return s.json()}function I(e){const s=N.get(e);return s?Date.now()-s.created>_?(N.delete(e),null):s.product:null}function Z(e,s){N.set(e,{product:s,created:Date.now()})}function w(e){return e&&!Number.isNaN(e)?e:0}function G(e,s){const{from:t,size:r,total:n}=h.useNostoAppState(o=>({from:w(o.query.products?.from??0),size:w(o.response?.products?.size??s),total:w(o.response?.products?.total??0)})),{updateSearch:c}=y.useActions(),u=t+r,l=d.useMemo(()=>[...e].reverse().filter(o=>o<n),[e,n]),f=d.useCallback(o=>{c({products:{size:A.parseNumber(o)}})},[c]);return{from:t,to:u,total:n,size:r,sizeOptions:l,handleSizeChange:f}}function J(e,s){return e.length!==s.length?!1:e.every(t=>s.find(r=>t.field===r.field&&t.order===r.order))}function K(e){const s=h.useNostoAppState(c=>c.query),{updateSearch:t}=y.useActions();return{activeSort:e.find(c=>J(c.value.sort,s.products?.sort||[]))?.id??e[0]?.id,setSort:c=>{const u=e.find(l=>l.id===c);u&&t({products:{sort:u.value.sort}})}}}const M=window.SpeechRecognition||window.webkitSpeechRecognition,x=!!(M&&typeof M=="function");function Q(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function W({language:e="en-US",interimResults:s=!1,onResult:t,onError:r}={}){const[n,c]=d.useState(!1),u=d.useRef(null),l=d.useCallback(()=>{const o=new M;o.lang=e,o.interimResults=s,o.onstart=()=>c(!0),t&&(o.onresult=i=>{const{transcript:a}=i.results?.[0]?.[0];t(a)}),r&&(o.onerror=i=>r(i.error)),o.onend=()=>c(!1),u.current=o,o.start()},[e,s,r,t]),f=d.useCallback(()=>{u.current?.stop()},[u]);return{listening:n,startListening:l,stopListening:f}}const Y=x?W:Q;function ee(e,s){if(!e.length||!s.length)return[];const t=s.reduce((r,n)=>(r[n]={},r),{});return e.forEach(r=>{r.customFields?.forEach(({key:n,value:c})=>{const u=n.toLowerCase();s.includes(u)&&(t[u][c]=t[u][c]||[],t[u][c].push(r))})}),Object.entries(t).filter(r=>Object.keys(r[1]).length).map(([r,n])=>({field:r,options:Object.entries(n).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function te(e,s){return e.length?e.map(({field:t,options:r})=>({field:t,options:r.map(n=>{const c=!n.skus?.some(l=>Object.entries(s).every(([f,o])=>f===t?!0:l.customFields?.find(a=>a.key.toLowerCase()===f)?.value===o)),u=s[t]===n.value;return{...n,unavailable:c,selected:u}})})):[]}const C=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function se(e){if(C.includes(e))return 1e3+C.indexOf(e);const s=parseFloat(e);return isNaN(s)?e:s}function ne(e,s){return[...s].sort((t,r)=>{const[n,c]=[t.value,r.value].map(se);return n<c?-1:1})}function oe(e=[],s=[]){const[t,r]=d.useState({}),n=d.useMemo(()=>ee(e,s).map(({field:o,options:i})=>({field:o,options:ne(o,i)})),[e,s]),c=d.useMemo(()=>te(n,t),[n,t]),u=d.useCallback((f,o)=>{r(i=>{const a={...i};return a[f]===o?delete a[f]:a[f]=o,a})},[]),l=d.useMemo(()=>Object.keys(t).filter(i=>t[i]).length===0?[]:c.filter(({field:i})=>t[i]).map(({field:i,options:a})=>{const p=t[i];return a.find(m=>m.value===p)?.skus??[]}).reduce((i,a)=>i.filter(p=>a.includes(p))),[c,t]);return{swatches:c,toggleOption:u,matchedSkus:l}}exports.useActions=y.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.useHistory=L.useHistory;exports.speechToTextSupported=x;exports.useDecoratedSearchResults=q;exports.useFacet=z;exports.useFacets=X;exports.usePagination=j;exports.usePersonalization=D;exports.useProductFilters=k;exports.useRange=R;exports.useRangeSelector=V;exports.useResponse=$;exports.useSelectedFiltersCount=B;exports.useShopifyProduct=H;exports.useSizeOptions=G;exports.useSort=K;exports.useSpeechToText=Y;exports.useSwatches=oe;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @module preact/hooks */
|
|
2
|
+
export { type SwatchField, type SwatchOption } from './src/types';
|
|
2
3
|
export { useActions } from './src/useActions';
|
|
3
4
|
export { useDecoratedSearchResults } from './src/useDecoratedSearchResults';
|
|
4
5
|
export { useFacet, type UseFacetOptions } from './src/useFacet';
|
|
@@ -13,6 +14,7 @@ export { useRange } from './src/useRange';
|
|
|
13
14
|
export { useRangeSelector } from './src/useRangeSelector';
|
|
14
15
|
export { useResponse } from './src/useResponse';
|
|
15
16
|
export { useSelectedFiltersCount } from './src/useSelectedFiltersCount';
|
|
17
|
+
export { useShopifyProduct } from './src/useShopifyProduct/useShopifyProduct';
|
|
16
18
|
export { useSizeOptions } from './src/useSizeOptions';
|
|
17
19
|
export { useSort } from './src/useSort/useSort';
|
|
18
20
|
export { type SpeechToText, speechToTextSupported, useSpeechToText } from './src/useSpeechToText';
|
|
@@ -1,143 +1,143 @@
|
|
|
1
1
|
import { h as b } from "../../useActions-MsVW37eV.js";
|
|
2
2
|
import { a as z } from "../../logger-_fg_Za9y.js";
|
|
3
|
-
import { a as
|
|
4
|
-
import { u as
|
|
5
|
-
import { useState as x, useCallback as h, useMemo as y, useEffect as
|
|
6
|
-
import { u as
|
|
7
|
-
import { s as
|
|
3
|
+
import { a as S } from "../../useLoadMore-CYYoAHua.js";
|
|
4
|
+
import { u as he } from "../../useLoadMore-CYYoAHua.js";
|
|
5
|
+
import { useState as x, useCallback as h, useMemo as y, useEffect as X, useRef as A } from "preact/hooks";
|
|
6
|
+
import { u as ve } from "../../useHistory-W6FQSk99.js";
|
|
7
|
+
import { s as N } from "../../index.es-XNBESE3P.js";
|
|
8
8
|
import { p as R } from "../../parseNumber-QA48nJLp.js";
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return
|
|
9
|
+
function te(e) {
|
|
10
|
+
const n = S((t) => t.response);
|
|
11
|
+
return e && Array.isArray(e) || e && z(e) ? e : n;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
active:
|
|
16
|
-
...
|
|
17
|
-
}, [
|
|
18
|
-
c(!
|
|
19
|
-
}, [
|
|
13
|
+
function ne(e, n) {
|
|
14
|
+
const t = e.data?.filter((d) => d.selected).length ?? 0, { active: s } = {
|
|
15
|
+
active: t > 0,
|
|
16
|
+
...n
|
|
17
|
+
}, [r, c] = x(s), { toggleProductFilter: i } = b(), l = h(() => {
|
|
18
|
+
c(!r);
|
|
19
|
+
}, [r]);
|
|
20
20
|
return {
|
|
21
21
|
/** Active value */
|
|
22
|
-
active:
|
|
22
|
+
active: r,
|
|
23
23
|
/** Selected filters count */
|
|
24
|
-
selectedFiltersCount:
|
|
24
|
+
selectedFiltersCount: t,
|
|
25
25
|
/** Toggle active function */
|
|
26
26
|
toggleActive: l,
|
|
27
27
|
/** Toggle product filter function */
|
|
28
28
|
toggleProductFilter: i
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const { loading:
|
|
33
|
-
loading:
|
|
34
|
-
facets:
|
|
31
|
+
function re() {
|
|
32
|
+
const { loading: e, facets: n } = S((t) => ({
|
|
33
|
+
loading: t.loading,
|
|
34
|
+
facets: t.response?.products?.facets ?? []
|
|
35
35
|
}));
|
|
36
36
|
return {
|
|
37
37
|
/** Loading state */
|
|
38
|
-
loading:
|
|
38
|
+
loading: e,
|
|
39
39
|
/** Array of facets*/
|
|
40
|
-
facets:
|
|
40
|
+
facets: n
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
return !isNaN(
|
|
43
|
+
function C(e, n) {
|
|
44
|
+
const t = n - e;
|
|
45
|
+
return !isNaN(t) && t > 0 ? new Array(n - e).fill(void 0).map((s, r) => r + e) : [];
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
const { query:
|
|
49
|
-
query:
|
|
50
|
-
products:
|
|
47
|
+
function oe(e) {
|
|
48
|
+
const { query: n, products: t } = S((s) => ({
|
|
49
|
+
query: s.query,
|
|
50
|
+
products: s.response.products
|
|
51
51
|
}));
|
|
52
52
|
return y(() => {
|
|
53
|
-
if (!
|
|
53
|
+
if (!t)
|
|
54
54
|
return {
|
|
55
55
|
totalPages: 0,
|
|
56
56
|
resultsFrom: 0,
|
|
57
57
|
resultsTo: 0,
|
|
58
58
|
pages: []
|
|
59
59
|
};
|
|
60
|
-
const
|
|
61
|
-
from:
|
|
60
|
+
const s = n.products?.from ?? 0, r = e?.width ?? 1 / 0, c = Math.max(Math.floor(r - 1) / 2, 1), i = t.size > 0 ? Math.floor(s / t.size) + 1 : 1, l = t.size > 0 ? Math.ceil(t.total / t.size) : 0, d = (w) => w >= i - c && w <= i + c, o = s + 1, u = Math.min(s + t.total, t.total), a = {
|
|
61
|
+
from: s,
|
|
62
62
|
page: i,
|
|
63
63
|
current: !0
|
|
64
64
|
}, f = (w) => ({
|
|
65
|
-
from: (w - 1) *
|
|
65
|
+
from: (w - 1) * t.size,
|
|
66
66
|
page: w,
|
|
67
67
|
current: w === i
|
|
68
|
-
}), m = i > 1 ? f(i - 1) : void 0, p = i < l ? f(i + 1) : void 0, g = i - c - 1 > 1 ? f(1) : void 0,
|
|
69
|
-
return !g && F[0]?.page === 2 && F.unshift(f(1)), !
|
|
68
|
+
}), m = i > 1 ? f(i - 1) : void 0, p = i < l ? f(i + 1) : void 0, g = i - c - 1 > 1 ? f(1) : void 0, v = i + c + 1 < l ? f(l) : void 0, F = C(1, l + 1).filter(d).map(f);
|
|
69
|
+
return !g && F[0]?.page === 2 && F.unshift(f(1)), !v && F[F.length - 1]?.page === l - 1 && F.push(f(l)), {
|
|
70
70
|
totalPages: l,
|
|
71
|
-
resultsFrom:
|
|
72
|
-
resultsTo:
|
|
73
|
-
current:
|
|
71
|
+
resultsFrom: o,
|
|
72
|
+
resultsTo: u,
|
|
73
|
+
current: a,
|
|
74
74
|
prev: m,
|
|
75
75
|
next: p,
|
|
76
76
|
first: g,
|
|
77
|
-
last:
|
|
77
|
+
last: v,
|
|
78
78
|
pages: F
|
|
79
79
|
};
|
|
80
|
-
}, [
|
|
80
|
+
}, [n, t, e?.width]);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const [
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
const { products: c, segments: i } = await
|
|
87
|
-
|
|
82
|
+
function se() {
|
|
83
|
+
const [e, n] = x([]), [t, s] = x([]);
|
|
84
|
+
return X(() => {
|
|
85
|
+
N(async (r) => {
|
|
86
|
+
const { products: c, segments: i } = await r.getSearchSessionParams();
|
|
87
|
+
n(i ?? []), s(c?.personalizationBoost ?? []);
|
|
88
88
|
});
|
|
89
89
|
}, []), {
|
|
90
|
-
segments:
|
|
91
|
-
boost:
|
|
90
|
+
segments: e,
|
|
91
|
+
boost: t
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const { facets:
|
|
96
|
-
facets:
|
|
97
|
-
})), { replaceFilter:
|
|
98
|
-
(
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
94
|
+
function O() {
|
|
95
|
+
const { facets: e } = S((o) => ({
|
|
96
|
+
facets: o.response.products?.facets ?? []
|
|
97
|
+
})), { replaceFilter: n, toggleProductFilter: t } = b(), s = h(
|
|
98
|
+
(o) => {
|
|
99
|
+
const u = e?.find((a) => a.type === "stats" && a.field === o);
|
|
100
|
+
if (u && "min" in u && "max" in u)
|
|
101
|
+
return u;
|
|
102
102
|
},
|
|
103
|
-
[
|
|
104
|
-
),
|
|
105
|
-
(
|
|
106
|
-
[
|
|
107
|
-
), c = h((
|
|
108
|
-
...
|
|
109
|
-
range:
|
|
110
|
-
gt:
|
|
111
|
-
gte:
|
|
112
|
-
lt:
|
|
113
|
-
lte:
|
|
103
|
+
[e]
|
|
104
|
+
), r = h(
|
|
105
|
+
(o) => e?.find((u) => u.field === o)?.name ?? o,
|
|
106
|
+
[e]
|
|
107
|
+
), c = h((o) => "field" in o && (o.value instanceof Array || o.range instanceof Array), []), i = h((o) => ({
|
|
108
|
+
...o,
|
|
109
|
+
range: o.range?.map((u) => ({
|
|
110
|
+
gt: u.gt ? Number(u.gt) : u.gt,
|
|
111
|
+
gte: u.gte ? Number(u.gte) : u.gte,
|
|
112
|
+
lt: u.lt ? Number(u.lt) : u.lt,
|
|
113
|
+
lte: u.lte ? Number(u.lte) : u.lte
|
|
114
114
|
}))
|
|
115
115
|
}), []), l = h(
|
|
116
|
-
(
|
|
117
|
-
value:
|
|
118
|
-
field:
|
|
119
|
-
name:
|
|
120
|
-
filter: i(
|
|
116
|
+
(o) => (o.value ?? []).map((a) => ({
|
|
117
|
+
value: a,
|
|
118
|
+
field: o.field,
|
|
119
|
+
name: r(o.field),
|
|
120
|
+
filter: i(o),
|
|
121
121
|
remove: () => {
|
|
122
|
-
|
|
122
|
+
t(o.field, a, !1);
|
|
123
123
|
}
|
|
124
124
|
})),
|
|
125
|
-
[i,
|
|
125
|
+
[i, r, t]
|
|
126
126
|
), d = h(
|
|
127
|
-
(
|
|
128
|
-
const f =
|
|
127
|
+
(o) => (o.range ?? []).map((a) => {
|
|
128
|
+
const f = a.gte ?? a.gt ?? s(o.field)?.min, m = a.lte ?? a.lt ?? s(o.field)?.max;
|
|
129
129
|
if (f !== void 0 && m !== void 0)
|
|
130
130
|
return {
|
|
131
131
|
value: `${f} - ${m}`,
|
|
132
|
-
field:
|
|
133
|
-
name:
|
|
134
|
-
filter: i(
|
|
132
|
+
field: o.field,
|
|
133
|
+
name: r(o.field),
|
|
134
|
+
filter: i(o),
|
|
135
135
|
remove: () => {
|
|
136
|
-
|
|
136
|
+
n(o.field, void 0);
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
}).filter(Boolean),
|
|
140
|
-
[i,
|
|
140
|
+
[i, s, r, n]
|
|
141
141
|
);
|
|
142
142
|
return {
|
|
143
143
|
selectFilters: c,
|
|
@@ -146,15 +146,15 @@ function T() {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
function k() {
|
|
149
|
-
const { filter:
|
|
149
|
+
const { filter: e } = S((l) => ({
|
|
150
150
|
filter: l.query.products?.filter ?? []
|
|
151
|
-
})), { updateSearch:
|
|
152
|
-
|
|
151
|
+
})), { updateSearch: n } = b(), { selectFilters: t, toValueFilter: s, toRangeFilter: r } = O(), c = y(() => e ? e.filter(t).flatMap((l) => "value" in l ? s(l) : "range" in l ? r(l) : []).filter(Boolean) : [], [e, t, r, s]), i = h(() => {
|
|
152
|
+
n({
|
|
153
153
|
products: {
|
|
154
154
|
filter: []
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
|
-
}, [
|
|
157
|
+
}, [n]);
|
|
158
158
|
return {
|
|
159
159
|
/** Selected filters array. */
|
|
160
160
|
filters: c,
|
|
@@ -162,12 +162,12 @@ function k() {
|
|
|
162
162
|
removeAll: i
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function q(
|
|
166
|
-
const { replaceFilter:
|
|
167
|
-
query:
|
|
168
|
-
products:
|
|
169
|
-
})),
|
|
170
|
-
if (!
|
|
165
|
+
function q(e) {
|
|
166
|
+
const { replaceFilter: n } = b(), { query: t, products: s } = S((a) => ({
|
|
167
|
+
query: a.query,
|
|
168
|
+
products: a.response.products
|
|
169
|
+
})), r = s?.facets?.find((a) => a.id === e);
|
|
170
|
+
if (!r)
|
|
171
171
|
return {
|
|
172
172
|
min: 0,
|
|
173
173
|
max: 0,
|
|
@@ -175,13 +175,13 @@ function q(t) {
|
|
|
175
175
|
updateRange: () => {
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
|
-
const c =
|
|
179
|
-
const m =
|
|
180
|
-
(d === m || !g) && (
|
|
178
|
+
const c = t.products?.filter?.find((a) => a.field === r.field), i = c?.range ? c.range[0] : void 0, l = typeof i == "object" && ("gte" in i || "lte" in i) ? [R(i.gte), R(i.lte)] : [void 0, void 0], d = "min" in r ? Math.floor(r.min) : 0, o = "max" in r ? Math.ceil(r.max) : 0, u = ([a, f]) => {
|
|
179
|
+
const m = a !== void 0 ? Math.floor(a) : void 0, p = f !== void 0 ? Math.ceil(f) : void 0, g = m !== void 0, v = p !== void 0;
|
|
180
|
+
(d === m || !g) && (o === p || !v) ? n(r.field, void 0) : (d === m || !g) && v ? n(r.field, {
|
|
181
181
|
lte: p.toString()
|
|
182
|
-
}) : (
|
|
182
|
+
}) : (o === p || !v) && g ? n(r.field, {
|
|
183
183
|
gte: m.toString()
|
|
184
|
-
}) : g &&
|
|
184
|
+
}) : g && v && n(r.field, {
|
|
185
185
|
gte: m.toString(),
|
|
186
186
|
lte: p.toString()
|
|
187
187
|
});
|
|
@@ -190,44 +190,44 @@ function q(t) {
|
|
|
190
190
|
/** Min value */
|
|
191
191
|
min: d,
|
|
192
192
|
/** Max value */
|
|
193
|
-
max:
|
|
193
|
+
max: o,
|
|
194
194
|
/** Range value */
|
|
195
|
-
range: [l[0] ?? d, l[1] ??
|
|
195
|
+
range: [l[0] ?? d, l[1] ?? o],
|
|
196
196
|
/** Update range function */
|
|
197
|
-
updateRange:
|
|
197
|
+
updateRange: u
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
const { min:
|
|
202
|
-
const
|
|
200
|
+
function ie(e, n) {
|
|
201
|
+
const { min: t, max: s, range: r, updateRange: c } = q(e), { filters: i } = k(), l = y(() => {
|
|
202
|
+
const a = i.find((g) => g?.filter?.range);
|
|
203
203
|
let f = null;
|
|
204
|
-
if (
|
|
205
|
-
const g =
|
|
204
|
+
if (a) {
|
|
205
|
+
const g = a.filter.range?.[0];
|
|
206
206
|
f = [R(g?.gte), R(g?.lte)];
|
|
207
207
|
}
|
|
208
208
|
const m = [];
|
|
209
|
-
let p = Math.floor(
|
|
210
|
-
for (; p <
|
|
211
|
-
const g = p +
|
|
209
|
+
let p = Math.floor(t / n) * n;
|
|
210
|
+
for (; p < s; ) {
|
|
211
|
+
const g = p + n, v = f && f[0] === p && f[1] === g;
|
|
212
212
|
m.push({
|
|
213
213
|
min: p,
|
|
214
214
|
max: g,
|
|
215
|
-
selected:
|
|
215
|
+
selected: v
|
|
216
216
|
}), p = g;
|
|
217
217
|
}
|
|
218
218
|
return m;
|
|
219
|
-
}, [i,
|
|
220
|
-
c([
|
|
221
|
-
},
|
|
222
|
-
c([
|
|
223
|
-
},
|
|
219
|
+
}, [i, t, s, n]), d = (a) => {
|
|
220
|
+
c([a, r[1]]);
|
|
221
|
+
}, o = (a) => {
|
|
222
|
+
c([r[0], a]);
|
|
223
|
+
}, u = t !== r[0] || s !== r[1];
|
|
224
224
|
return {
|
|
225
225
|
/** Minimum value */
|
|
226
|
-
min:
|
|
226
|
+
min: t,
|
|
227
227
|
/** Maximum value */
|
|
228
|
-
max:
|
|
228
|
+
max: s,
|
|
229
229
|
/** Range value */
|
|
230
|
-
range:
|
|
230
|
+
range: r,
|
|
231
231
|
/** Update range function */
|
|
232
232
|
updateRange: c,
|
|
233
233
|
/** Ranges */
|
|
@@ -235,37 +235,98 @@ function te(t, r) {
|
|
|
235
235
|
/** Handle min change */
|
|
236
236
|
handleMinChange: d,
|
|
237
237
|
/** Handle max change */
|
|
238
|
-
handleMaxChange:
|
|
238
|
+
handleMaxChange: o,
|
|
239
239
|
/** Is selected */
|
|
240
|
-
isSelected:
|
|
240
|
+
isSelected: u
|
|
241
241
|
};
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
const { products:
|
|
243
|
+
function ce() {
|
|
244
|
+
const { products: e, keywords: n } = S((t) => t.response);
|
|
245
245
|
return {
|
|
246
246
|
/** Array of products */
|
|
247
|
-
products:
|
|
247
|
+
products: e ?? { hits: [], total: 0 },
|
|
248
248
|
/** Array of keywords */
|
|
249
|
-
keywords:
|
|
249
|
+
keywords: n ?? { hits: [], total: 0 }
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
return y(() =>
|
|
252
|
+
function ue() {
|
|
253
|
+
const e = S((t) => t.query.products?.filter);
|
|
254
|
+
return y(() => e ? e.reduce((t, s) => t + (Array.isArray(s.value) ? s.value.length : 1), 0) : 0, [e]);
|
|
255
255
|
}
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
const j = 5 * 60 * 1e3, M = /* @__PURE__ */ new Map();
|
|
257
|
+
function ae(e) {
|
|
258
|
+
const [n, t] = x({
|
|
259
|
+
product: null,
|
|
260
|
+
loading: !0,
|
|
261
|
+
error: null
|
|
262
|
+
});
|
|
263
|
+
return X(() => {
|
|
264
|
+
if (!e) {
|
|
265
|
+
t({
|
|
266
|
+
product: null,
|
|
267
|
+
loading: !1,
|
|
268
|
+
error: "Product handle is required"
|
|
269
|
+
});
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
t((r) => ({
|
|
273
|
+
...r,
|
|
274
|
+
loading: !0,
|
|
275
|
+
error: null
|
|
276
|
+
}));
|
|
277
|
+
const s = E(e);
|
|
278
|
+
if (s) {
|
|
279
|
+
t({
|
|
280
|
+
product: s,
|
|
281
|
+
loading: !1,
|
|
282
|
+
error: null
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
D(e).then((r) => {
|
|
287
|
+
V(e, r), t({
|
|
288
|
+
product: r,
|
|
289
|
+
loading: !1,
|
|
290
|
+
error: null
|
|
291
|
+
});
|
|
292
|
+
}).catch((r) => {
|
|
293
|
+
t({
|
|
294
|
+
product: null,
|
|
295
|
+
loading: !1,
|
|
296
|
+
error: r.message || "Failed to fetch product"
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
}, [e]), n;
|
|
300
|
+
}
|
|
301
|
+
async function D(e) {
|
|
302
|
+
const n = await fetch(`/products/${e}.js`);
|
|
303
|
+
if (!n.ok)
|
|
304
|
+
throw new Error(`Failed to fetch product: ${n.status} ${n.statusText}`);
|
|
305
|
+
return n.json();
|
|
306
|
+
}
|
|
307
|
+
function E(e) {
|
|
308
|
+
const n = M.get(e);
|
|
309
|
+
return n ? Date.now() - n.created > j ? (M.delete(e), null) : n.product : null;
|
|
258
310
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
311
|
+
function V(e, n) {
|
|
312
|
+
M.set(e, {
|
|
313
|
+
product: n,
|
|
314
|
+
created: Date.now()
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
function L(e) {
|
|
318
|
+
return e && !Number.isNaN(e) ? e : 0;
|
|
319
|
+
}
|
|
320
|
+
function le(e, n) {
|
|
321
|
+
const { from: t, size: s, total: r } = S((o) => ({
|
|
322
|
+
from: L(o.query.products?.from ?? 0),
|
|
323
|
+
size: L(o.response?.products?.size ?? n),
|
|
324
|
+
total: L(o.response?.products?.total ?? 0)
|
|
325
|
+
})), { updateSearch: c } = b(), i = t + s, l = y(() => [...e].reverse().filter((o) => o < r), [e, r]), d = h(
|
|
326
|
+
(o) => {
|
|
266
327
|
c({
|
|
267
328
|
products: {
|
|
268
|
-
size: R(
|
|
329
|
+
size: R(o)
|
|
269
330
|
}
|
|
270
331
|
});
|
|
271
332
|
},
|
|
@@ -273,31 +334,31 @@ function oe(t, r) {
|
|
|
273
334
|
);
|
|
274
335
|
return {
|
|
275
336
|
/** from value */
|
|
276
|
-
from:
|
|
337
|
+
from: t,
|
|
277
338
|
/** to value */
|
|
278
339
|
to: i,
|
|
279
340
|
/** total value */
|
|
280
|
-
total:
|
|
341
|
+
total: r,
|
|
281
342
|
/** size value */
|
|
282
|
-
size:
|
|
343
|
+
size: s,
|
|
283
344
|
/** Array of size options */
|
|
284
345
|
sizeOptions: l,
|
|
285
346
|
/** Should be called when size is changed */
|
|
286
347
|
handleSizeChange: d
|
|
287
348
|
};
|
|
288
349
|
}
|
|
289
|
-
function
|
|
290
|
-
return
|
|
350
|
+
function $(e, n) {
|
|
351
|
+
return e.length !== n.length ? !1 : e.every((t) => n.find((s) => t.field === s.field && t.order === s.order));
|
|
291
352
|
}
|
|
292
|
-
function
|
|
293
|
-
const
|
|
353
|
+
function de(e) {
|
|
354
|
+
const n = S((c) => c.query), { updateSearch: t } = b();
|
|
294
355
|
return {
|
|
295
356
|
/** Active sort */
|
|
296
|
-
activeSort:
|
|
357
|
+
activeSort: e.find((c) => $(c.value.sort, n.products?.sort || []))?.id ?? e[0]?.id,
|
|
297
358
|
/** Set sort function */
|
|
298
359
|
setSort: (c) => {
|
|
299
|
-
const i =
|
|
300
|
-
i &&
|
|
360
|
+
const i = e.find((l) => l.id === c);
|
|
361
|
+
i && t({
|
|
301
362
|
products: {
|
|
302
363
|
sort: i.value.sort
|
|
303
364
|
}
|
|
@@ -305,8 +366,8 @@ function se(t) {
|
|
|
305
366
|
}
|
|
306
367
|
};
|
|
307
368
|
}
|
|
308
|
-
const
|
|
309
|
-
function
|
|
369
|
+
const P = window.SpeechRecognition || window.webkitSpeechRecognition, B = !!(P && typeof P == "function");
|
|
370
|
+
function U() {
|
|
310
371
|
return {
|
|
311
372
|
listening: !1,
|
|
312
373
|
startListening: () => {
|
|
@@ -315,39 +376,39 @@ function V() {
|
|
|
315
376
|
}
|
|
316
377
|
};
|
|
317
378
|
}
|
|
318
|
-
function
|
|
319
|
-
language:
|
|
320
|
-
interimResults:
|
|
321
|
-
onResult:
|
|
322
|
-
onError:
|
|
379
|
+
function _({
|
|
380
|
+
language: e = "en-US",
|
|
381
|
+
interimResults: n = !1,
|
|
382
|
+
onResult: t,
|
|
383
|
+
onError: s
|
|
323
384
|
} = {}) {
|
|
324
|
-
const [
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
const { transcript:
|
|
328
|
-
|
|
329
|
-
}),
|
|
330
|
-
}, [
|
|
385
|
+
const [r, c] = x(!1), i = A(null), l = h(() => {
|
|
386
|
+
const o = new P();
|
|
387
|
+
o.lang = e, o.interimResults = n, o.onstart = () => c(!0), t && (o.onresult = (u) => {
|
|
388
|
+
const { transcript: a } = u.results?.[0]?.[0];
|
|
389
|
+
t(a);
|
|
390
|
+
}), s && (o.onerror = (u) => s(u.error)), o.onend = () => c(!1), i.current = o, o.start();
|
|
391
|
+
}, [e, n, s, t]), d = h(() => {
|
|
331
392
|
i.current?.stop();
|
|
332
393
|
}, [i]);
|
|
333
394
|
return {
|
|
334
|
-
listening:
|
|
395
|
+
listening: r,
|
|
335
396
|
startListening: l,
|
|
336
397
|
stopListening: d
|
|
337
398
|
};
|
|
338
399
|
}
|
|
339
|
-
const
|
|
340
|
-
function
|
|
341
|
-
if (!
|
|
342
|
-
const
|
|
343
|
-
return
|
|
344
|
-
|
|
345
|
-
const i =
|
|
346
|
-
|
|
400
|
+
const fe = B ? _ : U;
|
|
401
|
+
function I(e, n) {
|
|
402
|
+
if (!e.length || !n.length) return [];
|
|
403
|
+
const t = n.reduce((s, r) => (s[r] = {}, s), {});
|
|
404
|
+
return e.forEach((s) => {
|
|
405
|
+
s.customFields?.forEach(({ key: r, value: c }) => {
|
|
406
|
+
const i = r.toLowerCase();
|
|
407
|
+
n.includes(i) && (t[i][c] = t[i][c] || [], t[i][c].push(s));
|
|
347
408
|
});
|
|
348
|
-
}), Object.entries(
|
|
349
|
-
field:
|
|
350
|
-
options: Object.entries(
|
|
409
|
+
}), Object.entries(t).filter((s) => Object.keys(s[1]).length).map(([s, r]) => ({
|
|
410
|
+
field: s,
|
|
411
|
+
options: Object.entries(r).map(([c, i]) => ({
|
|
351
412
|
value: c,
|
|
352
413
|
skus: i,
|
|
353
414
|
unavailable: !1,
|
|
@@ -355,65 +416,66 @@ function D(t, r) {
|
|
|
355
416
|
}))
|
|
356
417
|
}));
|
|
357
418
|
}
|
|
358
|
-
function
|
|
359
|
-
return
|
|
360
|
-
field:
|
|
361
|
-
options:
|
|
362
|
-
const c = !
|
|
419
|
+
function H(e, n) {
|
|
420
|
+
return e.length ? e.map(({ field: t, options: s }) => ({
|
|
421
|
+
field: t,
|
|
422
|
+
options: s.map((r) => {
|
|
423
|
+
const c = !r.skus?.some((l) => Object.entries(n).every(([d, o]) => d === t ? !0 : l.customFields?.find((a) => a.key.toLowerCase() === d)?.value === o)), i = n[t] === r.value;
|
|
363
424
|
return {
|
|
364
|
-
...
|
|
425
|
+
...r,
|
|
365
426
|
unavailable: c,
|
|
366
427
|
selected: i
|
|
367
428
|
};
|
|
368
429
|
})
|
|
369
430
|
})) : [];
|
|
370
431
|
}
|
|
371
|
-
const
|
|
372
|
-
function
|
|
373
|
-
if (
|
|
374
|
-
return 1e3 +
|
|
375
|
-
const
|
|
376
|
-
return isNaN(
|
|
432
|
+
const T = ["4XS", "3XS", "2XS", "XXS", "XS", "S", "M", "L", "XL", "XXL", "2XL", "XXXL", "3XL", "4XL"];
|
|
433
|
+
function Z(e) {
|
|
434
|
+
if (T.includes(e))
|
|
435
|
+
return 1e3 + T.indexOf(e);
|
|
436
|
+
const n = parseFloat(e);
|
|
437
|
+
return isNaN(n) ? e : n;
|
|
377
438
|
}
|
|
378
|
-
function
|
|
379
|
-
return [...
|
|
380
|
-
const [
|
|
381
|
-
return
|
|
439
|
+
function G(e, n) {
|
|
440
|
+
return [...n].sort((t, s) => {
|
|
441
|
+
const [r, c] = [t.value, s.value].map(Z);
|
|
442
|
+
return r < c ? -1 : 1;
|
|
382
443
|
});
|
|
383
444
|
}
|
|
384
|
-
function
|
|
385
|
-
const [
|
|
386
|
-
field:
|
|
387
|
-
options:
|
|
388
|
-
})), [
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
return
|
|
445
|
+
function ge(e = [], n = []) {
|
|
446
|
+
const [t, s] = x({}), r = y(() => I(e, n).map(({ field: o, options: u }) => ({
|
|
447
|
+
field: o,
|
|
448
|
+
options: G(o, u)
|
|
449
|
+
})), [e, n]), c = y(() => H(r, t), [r, t]), i = h((d, o) => {
|
|
450
|
+
s((u) => {
|
|
451
|
+
const a = { ...u };
|
|
452
|
+
return a[d] === o ? delete a[d] : a[d] = o, a;
|
|
392
453
|
});
|
|
393
|
-
}, []), l = y(() => Object.keys(
|
|
394
|
-
const f =
|
|
395
|
-
return
|
|
396
|
-
}).reduce((
|
|
454
|
+
}, []), l = y(() => Object.keys(t).filter((u) => t[u]).length === 0 ? [] : c.filter(({ field: u }) => t[u]).map(({ field: u, options: a }) => {
|
|
455
|
+
const f = t[u];
|
|
456
|
+
return a.find((p) => p.value === f)?.skus ?? [];
|
|
457
|
+
}).reduce((u, a) => u.filter((f) => a.includes(f))), [c, t]);
|
|
397
458
|
return { swatches: c, toggleOption: i, matchedSkus: l };
|
|
398
459
|
}
|
|
399
460
|
export {
|
|
400
|
-
|
|
461
|
+
B as speechToTextSupported,
|
|
401
462
|
b as useActions,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
463
|
+
te as useDecoratedSearchResults,
|
|
464
|
+
ne as useFacet,
|
|
465
|
+
re as useFacets,
|
|
466
|
+
ve as useHistory,
|
|
467
|
+
he as useLoadMore,
|
|
468
|
+
S as useNostoAppState,
|
|
469
|
+
oe as usePagination,
|
|
470
|
+
se as usePersonalization,
|
|
410
471
|
k as useProductFilters,
|
|
411
472
|
q as useRange,
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
473
|
+
ie as useRangeSelector,
|
|
474
|
+
ce as useResponse,
|
|
475
|
+
ue as useSelectedFiltersCount,
|
|
476
|
+
ae as useShopifyProduct,
|
|
477
|
+
le as useSizeOptions,
|
|
478
|
+
de as useSort,
|
|
479
|
+
fe as useSpeechToText,
|
|
480
|
+
ge as useSwatches
|
|
419
481
|
};
|
|
@@ -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 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,
|
|
@@ -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.0",
|
|
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",
|
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;
|