@nosto/search-js 3.25.4 → 3.25.6
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-D48n1GB-.js +37 -0
- package/dist/AutocompletePageProvider-DzjwKsBp.cjs +1 -0
- package/dist/BaseElement-BnP6tQrH.cjs +1 -0
- package/dist/BaseElement-C25wjvSR.js +19 -0
- package/dist/CategoryPageProvider-B6w4FHhB.cjs +1 -0
- package/dist/CategoryPageProvider-BYw7KGoS.js +30 -0
- package/dist/ErrorBoundary-BtAe8lXu.cjs +1 -0
- package/dist/ErrorBoundary-Bxyssvki.js +11 -0
- package/dist/InfiniteScrollWithObserver-8imjYGGz.js +226 -0
- package/dist/InfiniteScrollWithObserver-k7oYk4f9.cjs +1 -0
- package/dist/SerpPageProvider-BgRZJNth.cjs +1 -0
- package/dist/SerpPageProvider-fg14kNV9.js +30 -0
- package/dist/baseConfig-Che6Adb6.js +50 -0
- package/dist/baseConfig-jLd7jchq.cjs +1 -0
- package/dist/cl-CYT5y6Dn.cjs +1 -0
- package/dist/cl-G5KK1qHD.js +6 -0
- package/dist/core/core.cjs.js +1 -1
- package/dist/core/core.es.js +8 -8
- package/dist/currencies/currencies.cjs.js +1 -1
- package/dist/currencies/currencies.es.js +61 -65
- package/dist/disableNativeAutocomplete-CcR_Ek_P.js +26 -0
- package/dist/disableNativeAutocomplete-CjBGhRWW.cjs +1 -0
- package/dist/eventBusDispatch-B6VswTu8.cjs +1 -0
- package/dist/eventBusDispatch-DnFmEqYe.js +15 -0
- package/dist/eventBusSubscribe-C6qT1aOO.js +22 -0
- package/dist/eventBusSubscribe-c9a_PP0j.cjs +1 -0
- package/dist/index.es-Ba4tuzxb.cjs +1 -0
- package/dist/index.es-jSYcbRvi.js +25 -0
- package/dist/{isBot-B05pQGIe.js → isBot-CPesLwHL.js} +18 -17
- package/dist/isBot-CkyQfegP.cjs +1 -0
- package/dist/jsxRuntime.module-BRdvPAre.js +30 -0
- package/dist/jsxRuntime.module-Ba9fccPy.cjs +1 -0
- package/dist/parseNumber-BH_92pM8.cjs +1 -0
- package/dist/parseNumber-DFsrGj64.js +9 -0
- package/dist/pick-0KNFTqKn.cjs +1 -0
- package/dist/pick-B8ymxJme.js +6 -0
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +49 -42
- package/dist/preact/category/category.cjs.js +1 -1
- package/dist/preact/category/category.es.js +9 -4
- package/dist/preact/common/common.cjs.js +1 -1
- package/dist/preact/common/common.es.js +27 -31
- package/dist/preact/events/events.cjs.js +1 -1
- package/dist/preact/events/events.es.js +3 -8
- package/dist/preact/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.es.js +495 -508
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +318 -301
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +8 -10
- package/dist/preact/serp/serp.cjs.js +1 -1
- package/dist/preact/serp/serp.es.js +28 -18
- package/dist/search-BeFE0Ezr.cjs +1 -0
- package/dist/search-C2WGFf4C.js +155 -0
- package/dist/storage-B3FIcJQv.cjs +1 -0
- package/dist/storage-DeAo7M3s.js +115 -0
- package/dist/thumbnails/thumbnails.cjs.js +1 -1
- package/dist/thumbnails/thumbnails.es.js +93 -97
- package/dist/unique-BXFI_-3F.cjs +1 -0
- package/dist/unique-DSDxyj90.js +37 -0
- package/dist/useActions-BmWNZAES.js +182 -0
- package/dist/useActions-boQy-Vp0.cjs +1 -0
- package/dist/useHistory-BMkSr69f.js +24 -0
- package/dist/useHistory-GRnuHgQ5.cjs +1 -0
- package/dist/useLoadMore-B9LiuhfV.cjs +1 -0
- package/dist/useLoadMore-BkJV7F21.js +38 -0
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.es.js +9 -28
- package/package.json +5 -5
- package/dist/AutocompletePageProvider-CFEbt11-.cjs +0 -1
- package/dist/AutocompletePageProvider-CQePqAhB.js +0 -35
- package/dist/BaseElement-CIHACCWd.cjs +0 -1
- package/dist/BaseElement-DD_4UwDm.js +0 -24
- package/dist/CategoryPageProvider-037sXEh9.cjs +0 -1
- package/dist/CategoryPageProvider-DVL9lsCU.js +0 -26
- package/dist/ErrorBoundary-DFs5vnv-.js +0 -11
- package/dist/ErrorBoundary-DNPL7EwP.cjs +0 -1
- package/dist/InfiniteScrollWithObserver-BliG4dEl.cjs +0 -1
- package/dist/InfiniteScrollWithObserver-DvkEUZUE.js +0 -205
- package/dist/SerpPageProvider-BzrNPc7g.js +0 -26
- package/dist/SerpPageProvider-CxqiX9Zo.cjs +0 -1
- package/dist/baseConfig-BOOw0mWW.cjs +0 -1
- package/dist/baseConfig-Cf28X268.js +0 -48
- package/dist/cl-B00bZ7jc.cjs +0 -1
- package/dist/cl-CcykAxZN.js +0 -6
- package/dist/disableNativeAutocomplete-Bkta_WR2.js +0 -27
- package/dist/disableNativeAutocomplete-DI6zaZII.cjs +0 -1
- package/dist/eventBusDispatch-BKQcSHAB.cjs +0 -1
- package/dist/eventBusDispatch-DPR2Vwd4.js +0 -20
- package/dist/eventBusSubscribe-B5E7dTzk.js +0 -26
- package/dist/eventBusSubscribe-C4H9Nv1Z.cjs +0 -1
- package/dist/index.es-Dp6Iaxz3.cjs +0 -1
- package/dist/index.es-XNBESE3P.js +0 -26
- package/dist/isBot-C-qPIZyF.cjs +0 -1
- package/dist/jsxRuntime.module-B3sGoTIU.cjs +0 -1
- package/dist/jsxRuntime.module-Bzuv3cXw.js +0 -13
- package/dist/parseNumber-FsZ8w61u.cjs +0 -1
- package/dist/parseNumber-QA48nJLp.js +0 -11
- package/dist/pick-DReBictn.js +0 -9
- package/dist/pick-rYi1lc2m.cjs +0 -1
- package/dist/search-BchLEATK.cjs +0 -1
- package/dist/search-D1jQPG6P.js +0 -156
- package/dist/storage-9KuhFI9v.cjs +0 -1
- package/dist/storage-B97DRj5i.js +0 -121
- package/dist/unique-C1G3v2Y8.cjs +0 -1
- package/dist/unique-CCu7ChUL.js +0 -39
- package/dist/useActions-BD6dgsX8.js +0 -260
- package/dist/useActions-DIlSparF.cjs +0 -1
- package/dist/useHistory-DLCyHMo1.cjs +0 -1
- package/dist/useHistory-sjFYeR68.js +0 -27
- package/dist/useLoadMore-BMOT8Dfn.js +0 -33
- package/dist/useLoadMore-vCpwy6JC.cjs +0 -1
package/dist/storage-B97DRj5i.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { s as I } from "./index.es-XNBESE3P.js";
|
|
2
|
-
function c(e) {
|
|
3
|
-
return String(e) === "[object Object]";
|
|
4
|
-
}
|
|
5
|
-
function g(e) {
|
|
6
|
-
if (!c(e))
|
|
7
|
-
return !1;
|
|
8
|
-
const t = e.constructor;
|
|
9
|
-
if (t === void 0)
|
|
10
|
-
return !0;
|
|
11
|
-
const r = t.prototype;
|
|
12
|
-
return !(!c(r) || !r.hasOwnProperty("isPrototypeOf"));
|
|
13
|
-
}
|
|
14
|
-
function u(e, t) {
|
|
15
|
-
if (e === t)
|
|
16
|
-
return !0;
|
|
17
|
-
if (e instanceof Date && t instanceof Date)
|
|
18
|
-
return e.getTime() === t.getTime();
|
|
19
|
-
if (Array.isArray(e) && Array.isArray(t))
|
|
20
|
-
return e.length !== t.length ? !1 : e.every((r, n) => u(r, t[n]));
|
|
21
|
-
if (g(e) && g(t)) {
|
|
22
|
-
const r = Object.entries(e);
|
|
23
|
-
return r.length !== Object.keys(t).length ? !1 : r.every(([n, S]) => u(S, t[n]));
|
|
24
|
-
}
|
|
25
|
-
return !1;
|
|
26
|
-
}
|
|
27
|
-
function f() {
|
|
28
|
-
const e = /* @__PURE__ */ new Map();
|
|
29
|
-
return {
|
|
30
|
-
getItem(t) {
|
|
31
|
-
return e.get(t) ?? null;
|
|
32
|
-
},
|
|
33
|
-
setItem(t, r) {
|
|
34
|
-
e.set(t, r);
|
|
35
|
-
},
|
|
36
|
-
removeItem(t) {
|
|
37
|
-
e.delete(t);
|
|
38
|
-
},
|
|
39
|
-
clear() {
|
|
40
|
-
e.clear();
|
|
41
|
-
},
|
|
42
|
-
key(t) {
|
|
43
|
-
return Array.from(e.keys())[t] ?? null;
|
|
44
|
-
},
|
|
45
|
-
get length() {
|
|
46
|
-
return e.size;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function a(e) {
|
|
51
|
-
return (...t) => {
|
|
52
|
-
I((r) => {
|
|
53
|
-
(r.internal.context.mode.isPreview() ? console[e] : r.internal.logger[e])(...t);
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const i = {
|
|
58
|
-
debug: a("debug"),
|
|
59
|
-
info: a("info"),
|
|
60
|
-
warn: a("warn"),
|
|
61
|
-
error: a("error")
|
|
62
|
-
};
|
|
63
|
-
function l(e, t, r) {
|
|
64
|
-
try {
|
|
65
|
-
const n = JSON.stringify(t);
|
|
66
|
-
r.setItem(e, n);
|
|
67
|
-
} catch (n) {
|
|
68
|
-
i.warn(n);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function m(e, t) {
|
|
72
|
-
try {
|
|
73
|
-
const r = t.getItem(e);
|
|
74
|
-
if (r)
|
|
75
|
-
return JSON.parse(r);
|
|
76
|
-
} catch (r) {
|
|
77
|
-
i.warn(r);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function y(e, t) {
|
|
81
|
-
try {
|
|
82
|
-
t.removeItem(e);
|
|
83
|
-
} catch (r) {
|
|
84
|
-
i.warn(r);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
let o, s;
|
|
88
|
-
try {
|
|
89
|
-
o = window.localStorage, s = window.sessionStorage;
|
|
90
|
-
} catch (e) {
|
|
91
|
-
i.warn(e), o = f(), s = f();
|
|
92
|
-
}
|
|
93
|
-
function h(e, t) {
|
|
94
|
-
l(e, t, o);
|
|
95
|
-
}
|
|
96
|
-
function d(e, t) {
|
|
97
|
-
l(e, t, s);
|
|
98
|
-
}
|
|
99
|
-
function p(e) {
|
|
100
|
-
return m(e, o);
|
|
101
|
-
}
|
|
102
|
-
function O(e) {
|
|
103
|
-
return m(e, s);
|
|
104
|
-
}
|
|
105
|
-
function v(e) {
|
|
106
|
-
y(e, o);
|
|
107
|
-
}
|
|
108
|
-
function j(e) {
|
|
109
|
-
y(e, s);
|
|
110
|
-
}
|
|
111
|
-
export {
|
|
112
|
-
O as a,
|
|
113
|
-
g as b,
|
|
114
|
-
j as c,
|
|
115
|
-
d,
|
|
116
|
-
p as g,
|
|
117
|
-
u as i,
|
|
118
|
-
i as l,
|
|
119
|
-
v as r,
|
|
120
|
-
h as s
|
|
121
|
-
};
|
package/dist/unique-C1G3v2Y8.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("./storage-9KuhFI9v.cjs");function s(...e){return i(...e)}function i(...e){return e.reduce((r,n)=>c(r,n))}function c(e,r){return u.isPlainObject(e)&&u.isPlainObject(r)?Object.entries(r).reduce((n,[t,o])=>(n[t]=c(n[t],o),n),{...e}):u.isPlainObject(e)?e:r}function f(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,n)=>r.concat(n),[])}const a="nosto.search.";function d(e){const r=`${a}${e}`;window.performance?.mark(`${r}.start`)}function m(e){const r=`${a}${e}`;window.performance?.mark(`${r}.end`),window.performance?.measure(r,`${r}.start`,`${r}.end`)}function l(e){return d(e),()=>m(e)}function $(e){return Array.from(new Set(e))}exports.deepMerge=s;exports.deepMergePlain=i;exports.measure=l;exports.mergeArrays=f;exports.unique=$;
|
package/dist/unique-CCu7ChUL.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { b as u } from "./storage-B97DRj5i.js";
|
|
2
|
-
function d(...r) {
|
|
3
|
-
return c(...r);
|
|
4
|
-
}
|
|
5
|
-
function c(...r) {
|
|
6
|
-
return r.reduce((e, n) => i(e, n));
|
|
7
|
-
}
|
|
8
|
-
function i(r, e) {
|
|
9
|
-
return u(r) && u(e) ? Object.entries(e).reduce(
|
|
10
|
-
(n, [t, o]) => (n[t] = i(n[t], o), n),
|
|
11
|
-
{ ...r }
|
|
12
|
-
) : u(r) ? r : e;
|
|
13
|
-
}
|
|
14
|
-
function l(...r) {
|
|
15
|
-
if (!r.every((e) => e == null))
|
|
16
|
-
return r.filter((e) => Array.isArray(e)).reduce((e, n) => e.concat(n), []);
|
|
17
|
-
}
|
|
18
|
-
const a = "nosto.search.";
|
|
19
|
-
function f(r) {
|
|
20
|
-
const e = `${a}${r}`;
|
|
21
|
-
window.performance?.mark(`${e}.start`);
|
|
22
|
-
}
|
|
23
|
-
function s(r) {
|
|
24
|
-
const e = `${a}${r}`;
|
|
25
|
-
window.performance?.mark(`${e}.end`), window.performance?.measure(e, `${e}.start`, `${e}.end`);
|
|
26
|
-
}
|
|
27
|
-
function $(r) {
|
|
28
|
-
return f(r), () => s(r);
|
|
29
|
-
}
|
|
30
|
-
function w(r) {
|
|
31
|
-
return Array.from(new Set(r));
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
l as a,
|
|
35
|
-
c as b,
|
|
36
|
-
d,
|
|
37
|
-
$ as m,
|
|
38
|
-
w as u
|
|
39
|
-
};
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { createContext as S } from "preact";
|
|
2
|
-
import { useContext as k, useMemo as I, useCallback as d } from "preact/hooks";
|
|
3
|
-
import { b as w, u as M, m as f, d as h, a as E } from "./unique-CCu7ChUL.js";
|
|
4
|
-
import { i as b, l as A } from "./storage-B97DRj5i.js";
|
|
5
|
-
import { s as U } from "./search-D1jQPG6P.js";
|
|
6
|
-
const q = S(null);
|
|
7
|
-
function p() {
|
|
8
|
-
const e = k(q);
|
|
9
|
-
if (!e)
|
|
10
|
-
throw new Error("useConfig must be used within a ConfigProvider");
|
|
11
|
-
return e;
|
|
12
|
-
}
|
|
13
|
-
function R() {
|
|
14
|
-
const e = p();
|
|
15
|
-
if (e.pageType !== "search")
|
|
16
|
-
throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");
|
|
17
|
-
return e;
|
|
18
|
-
}
|
|
19
|
-
function W() {
|
|
20
|
-
const e = p();
|
|
21
|
-
if (e.pageType !== "category")
|
|
22
|
-
throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
function X() {
|
|
26
|
-
const e = p();
|
|
27
|
-
if (e.pageType !== "autocomplete")
|
|
28
|
-
throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");
|
|
29
|
-
return e;
|
|
30
|
-
}
|
|
31
|
-
function Q(e, r = {}) {
|
|
32
|
-
const t = /* @__PURE__ */ new Map();
|
|
33
|
-
let a = w(e, r ?? {});
|
|
34
|
-
const s = w(e, r);
|
|
35
|
-
function c(u) {
|
|
36
|
-
a = u(a);
|
|
37
|
-
for (const l of t.values())
|
|
38
|
-
l(a);
|
|
39
|
-
}
|
|
40
|
-
function n(u) {
|
|
41
|
-
c((l) => ({ ...l, ...u }));
|
|
42
|
-
}
|
|
43
|
-
function i() {
|
|
44
|
-
return a;
|
|
45
|
-
}
|
|
46
|
-
function o() {
|
|
47
|
-
return structuredClone(s);
|
|
48
|
-
}
|
|
49
|
-
function g(u, l) {
|
|
50
|
-
let C = u(a);
|
|
51
|
-
t.set(l, (T) => {
|
|
52
|
-
const y = u(T);
|
|
53
|
-
b(y, C) || (C = y, l(y));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function P(u) {
|
|
57
|
-
g(
|
|
58
|
-
(l) => l.initialized,
|
|
59
|
-
(l) => {
|
|
60
|
-
l && u();
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
function F(u) {
|
|
65
|
-
t.delete(u);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
updateState: n,
|
|
69
|
-
getState: i,
|
|
70
|
-
getInitialState: o,
|
|
71
|
-
onChange: g,
|
|
72
|
-
onInit: P,
|
|
73
|
-
clearOnChange: F
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
const z = {
|
|
77
|
-
loading: !0,
|
|
78
|
-
query: {},
|
|
79
|
-
response: {},
|
|
80
|
-
initialized: !1
|
|
81
|
-
};
|
|
82
|
-
function K(e = {}) {
|
|
83
|
-
return Q(z, e);
|
|
84
|
-
}
|
|
85
|
-
const N = S(K());
|
|
86
|
-
function B(e, r) {
|
|
87
|
-
return {
|
|
88
|
-
...r,
|
|
89
|
-
products: {
|
|
90
|
-
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
91
|
-
fields: D,
|
|
92
|
-
...r.products
|
|
93
|
-
},
|
|
94
|
-
...r.keywords ? {
|
|
95
|
-
keywords: {
|
|
96
|
-
...r.keywords,
|
|
97
|
-
fields: M([...L, ...r.keywords.fields ?? []]),
|
|
98
|
-
highlight: r.keywords.highlight ?? {
|
|
99
|
-
preTag: "<strong>",
|
|
100
|
-
postTag: "</strong>"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} : {}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const D = [
|
|
107
|
-
"productId",
|
|
108
|
-
"url",
|
|
109
|
-
"name",
|
|
110
|
-
"imageUrl",
|
|
111
|
-
"imageHash",
|
|
112
|
-
"thumbUrl",
|
|
113
|
-
"description",
|
|
114
|
-
"brand",
|
|
115
|
-
"variantId",
|
|
116
|
-
"availability",
|
|
117
|
-
"price",
|
|
118
|
-
"priceText",
|
|
119
|
-
"categoryIds",
|
|
120
|
-
"categories",
|
|
121
|
-
"customFields.key",
|
|
122
|
-
"customFields.value",
|
|
123
|
-
"priceCurrencyCode",
|
|
124
|
-
"datePublished",
|
|
125
|
-
"listPrice",
|
|
126
|
-
"unitPricingBaseMeasure",
|
|
127
|
-
"unitPricingUnit",
|
|
128
|
-
"unitPricingMeasure",
|
|
129
|
-
"googleCategory",
|
|
130
|
-
"gtin",
|
|
131
|
-
"ageGroup",
|
|
132
|
-
"gender",
|
|
133
|
-
"condition",
|
|
134
|
-
"alternateImageUrls",
|
|
135
|
-
"ratingValue",
|
|
136
|
-
"reviewCount",
|
|
137
|
-
"inventoryLevel",
|
|
138
|
-
"skus.id",
|
|
139
|
-
"skus.name",
|
|
140
|
-
"skus.price",
|
|
141
|
-
"skus.listPrice",
|
|
142
|
-
"skus.priceText",
|
|
143
|
-
"skus.url",
|
|
144
|
-
"skus.imageUrl",
|
|
145
|
-
"skus.inventoryLevel",
|
|
146
|
-
"skus.customFields.key",
|
|
147
|
-
"skus.customFields.value",
|
|
148
|
-
"skus.availability",
|
|
149
|
-
"pid",
|
|
150
|
-
"onDiscount",
|
|
151
|
-
"extra.key",
|
|
152
|
-
"extra.value",
|
|
153
|
-
"saleable",
|
|
154
|
-
"available",
|
|
155
|
-
"tags1",
|
|
156
|
-
"tags2",
|
|
157
|
-
"tags3"
|
|
158
|
-
], L = ["keyword", "_redirect"];
|
|
159
|
-
async function v(e, r, t) {
|
|
160
|
-
const a = f("newSearch"), s = e.config.pageType, c = s === "search" ? "serp" : s, n = h(e.store.getInitialState().query, r), i = h(e.config.search, t, {
|
|
161
|
-
track: c,
|
|
162
|
-
redirect: s !== "autocomplete",
|
|
163
|
-
isKeyword: !!t?.isKeyword,
|
|
164
|
-
usePersistentCache: e.config.pageType !== "autocomplete" && e.config.persistentSearchCache,
|
|
165
|
-
useMemoryCache: e.config.pageType === "autocomplete" && e.config.memoryCache
|
|
166
|
-
});
|
|
167
|
-
e.config.onBeforeSearch?.(e, i), e.store.updateState({
|
|
168
|
-
query: n,
|
|
169
|
-
loading: !0,
|
|
170
|
-
initialized: !0
|
|
171
|
-
});
|
|
172
|
-
const o = e.config.queryModifications(
|
|
173
|
-
{
|
|
174
|
-
...n,
|
|
175
|
-
products: {
|
|
176
|
-
...n.products,
|
|
177
|
-
// Apply filter merging to avoid overwriting base filters
|
|
178
|
-
filter: E(e.store.getInitialState().query?.products?.filter, r.products?.filter)
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
s
|
|
182
|
-
);
|
|
183
|
-
try {
|
|
184
|
-
const g = await U(B(e.config.pageType, o), i);
|
|
185
|
-
e.store.updateState({
|
|
186
|
-
response: g,
|
|
187
|
-
loading: !1
|
|
188
|
-
});
|
|
189
|
-
} catch (g) {
|
|
190
|
-
A.error("Search action failed", g), e.config.onSearchError?.(g, o, i, s);
|
|
191
|
-
}
|
|
192
|
-
a();
|
|
193
|
-
}
|
|
194
|
-
async function m(e, r, t) {
|
|
195
|
-
const a = f("updateSearch"), s = h(e.store.getState().query, { products: { from: 0 } }, r);
|
|
196
|
-
await v(e, s, t), a();
|
|
197
|
-
}
|
|
198
|
-
async function O(e, r, t) {
|
|
199
|
-
const a = f("replaceFilter"), s = e.store.getState().query.products?.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
200
|
-
await m(e, {
|
|
201
|
-
products: {
|
|
202
|
-
filter: [...s?.filter((n) => n.field !== r) ?? [], ...c]
|
|
203
|
-
}
|
|
204
|
-
}), a();
|
|
205
|
-
}
|
|
206
|
-
async function V(e, r, t, a) {
|
|
207
|
-
const s = f("toggleProductFilter"), c = e.store.getState().query.products?.filter, n = c?.find((o) => o.value instanceof Array && o.field === r), i = n?.value ? {
|
|
208
|
-
...n,
|
|
209
|
-
value: [...n.value.filter((o) => !b(o, t)), ...a ? [t] : []]
|
|
210
|
-
} : a ? {
|
|
211
|
-
field: r,
|
|
212
|
-
value: [t]
|
|
213
|
-
} : void 0;
|
|
214
|
-
await m(e, {
|
|
215
|
-
products: {
|
|
216
|
-
filter: [...c?.filter((o) => o !== n) ?? [], ...i?.value?.length ? [i] : []]
|
|
217
|
-
}
|
|
218
|
-
}), s();
|
|
219
|
-
}
|
|
220
|
-
function Y() {
|
|
221
|
-
const e = p(), r = k(N), t = I(
|
|
222
|
-
() => ({
|
|
223
|
-
config: e,
|
|
224
|
-
store: r
|
|
225
|
-
}),
|
|
226
|
-
[e, r]
|
|
227
|
-
), a = d(
|
|
228
|
-
(i, o) => v(t, i, o),
|
|
229
|
-
[t]
|
|
230
|
-
), s = d(
|
|
231
|
-
(i, o) => m(t, i, o),
|
|
232
|
-
[t]
|
|
233
|
-
), c = d(
|
|
234
|
-
(i, o, g) => V(t, i, o, g),
|
|
235
|
-
[t]
|
|
236
|
-
), n = d(
|
|
237
|
-
(i, o) => O(t, i, o),
|
|
238
|
-
[t]
|
|
239
|
-
);
|
|
240
|
-
return {
|
|
241
|
-
newSearch: a,
|
|
242
|
-
updateSearch: s,
|
|
243
|
-
toggleProductFilter: c,
|
|
244
|
-
replaceFilter: n
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
export {
|
|
248
|
-
q as C,
|
|
249
|
-
N as S,
|
|
250
|
-
X as a,
|
|
251
|
-
p as b,
|
|
252
|
-
K as c,
|
|
253
|
-
Q as d,
|
|
254
|
-
z as e,
|
|
255
|
-
W as f,
|
|
256
|
-
R as g,
|
|
257
|
-
Y as h,
|
|
258
|
-
v as n,
|
|
259
|
-
m as u
|
|
260
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const w=require("preact"),f=require("preact/hooks"),u=require("./unique-C1G3v2Y8.cjs"),C=require("./storage-9KuhFI9v.cjs"),E=require("./search-BchLEATK.cjs"),k=w.createContext(null);function p(){const e=f.useContext(k);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function A(){const e=p();if(e.pageType!=="search")throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");return e}function I(){const e=p();if(e.pageType!=="category")throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");return e}function U(){const e=p();if(e.pageType!=="autocomplete")throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");return e}function b(e,r={}){const t=new Map;let n=u.deepMergePlain(e,r??{});const i=u.deepMergePlain(e,r);function c(l){n=l(n);for(const g of t.values())g(n)}function s(l){c(g=>({...g,...l}))}function a(){return n}function o(){return structuredClone(i)}function d(l,g){let m=l(n);t.set(g,M=>{const y=l(M);C.isEqual(y,m)||(m=y,g(y))})}function T(l){d(g=>g.initialized,g=>{g&&l()})}function q(l){t.delete(l)}return{updateState:s,getState:a,getInitialState:o,onChange:d,onInit:T,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function P(e={}){return b(v,e)}const F=w.createContext(P());function Q(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:z,...r.products},...r.keywords?{keywords:{...r.keywords,fields:u.unique([...K,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const z=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],K=["keyword","_redirect"];async function S(e,r,t){const n=u.measure("newSearch"),i=e.config.pageType,c=i==="search"?"serp":i,s=u.deepMerge(e.store.getInitialState().query,r),a=u.deepMerge(e.config.search,t,{track:c,redirect:i!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,a),e.store.updateState({query:s,loading:!0,initialized:!0});const o=e.config.queryModifications({...s,products:{...s.products,filter:u.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},i);try{const d=await E.search(Q(e.config.pageType,o),a);e.store.updateState({response:d,loading:!1})}catch(d){C.logger.error("Search action failed",d),e.config.onSearchError?.(d,o,a,i)}n()}async function h(e,r,t){const n=u.measure("updateSearch"),i=u.deepMerge(e.store.getState().query,{products:{from:0}},r);await S(e,i,t),n()}async function N(e,r,t){const n=u.measure("replaceFilter"),i=e.store.getState().query.products?.filter,c=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await h(e,{products:{filter:[...i?.filter(s=>s.field!==r)??[],...c]}}),n()}async function x(e,r,t,n){const i=u.measure("toggleProductFilter"),c=e.store.getState().query.products?.filter,s=c?.find(o=>o.value instanceof Array&&o.field===r),a=s?.value?{...s,value:[...s.value.filter(o=>!C.isEqual(o,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await h(e,{products:{filter:[...c?.filter(o=>o!==s)??[],...a?.value?.length?[a]:[]]}}),i()}function B(){const e=p(),r=f.useContext(F),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((a,o)=>S(t,a,o),[t]),i=f.useCallback((a,o)=>h(t,a,o),[t]),c=f.useCallback((a,o,d)=>x(t,a,o,d),[t]),s=f.useCallback((a,o)=>N(t,a,o),[t]);return{newSearch:n,updateSearch:i,toggleProductFilter:c,replaceFilter:s}}exports.ConfigContext=k;exports.StoreContext=F;exports.createExtendableStore=b;exports.createStore=P;exports.defaultState=v;exports.newSearch=S;exports.updateSearch=h;exports.useActions=B;exports.useAutocompleteConfig=U;exports.useCategoryConfig=I;exports.useConfig=p;exports.useSerpConfig=A;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("./useActions-DIlSparF.cjs"),o=require("./storage-9KuhFI9v.cjs"),i=require("preact/hooks"),s="nosto:search-js:history";function u({value:e,historySize:t,store:r}){const l=(o.getLocalStorageItem(s)??[]).filter(y=>y!==e).concat(e),n=t?l.slice(-t):[];o.setLocalStorageItem(s,n),r.updateState({historyItems:n.reverse()})}function d(){return(o.getLocalStorageItem(s)??[]).slice().reverse().filter(t=>!!t)}function g(){const e=i.useContext(a.StoreContext),{historySize:t}=a.useAutocompleteConfig();return{addQuery:i.useCallback(c=>{u({value:c,historySize:t,store:e})},[t,e])}}exports.addToHistory=u;exports.getSavedHistory=d;exports.useHistory=g;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { S as l, a as m } from "./useActions-BD6dgsX8.js";
|
|
2
|
-
import { g as c, s as u } from "./storage-B97DRj5i.js";
|
|
3
|
-
import { useContext as y, useCallback as f } from "preact/hooks";
|
|
4
|
-
const e = "nosto:search-js:history";
|
|
5
|
-
function g({ value: o, historySize: t, store: s }) {
|
|
6
|
-
const n = (c(e) ?? []).filter((i) => i !== o).concat(o), a = t ? n.slice(-t) : [];
|
|
7
|
-
u(e, a), s.updateState({ historyItems: a.reverse() });
|
|
8
|
-
}
|
|
9
|
-
function p() {
|
|
10
|
-
return (c(e) ?? []).slice().reverse().filter((t) => !!t);
|
|
11
|
-
}
|
|
12
|
-
function I() {
|
|
13
|
-
const o = y(l), { historySize: t } = m();
|
|
14
|
-
return {
|
|
15
|
-
addQuery: f(
|
|
16
|
-
(r) => {
|
|
17
|
-
g({ value: r, historySize: t, store: o });
|
|
18
|
-
},
|
|
19
|
-
[t, o]
|
|
20
|
-
)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
g as a,
|
|
25
|
-
p as g,
|
|
26
|
-
I as u
|
|
27
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { S as n, h as u } from "./useActions-BD6dgsX8.js";
|
|
2
|
-
import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
|
|
3
|
-
import { i as m } from "./isBot-B05pQGIe.js";
|
|
4
|
-
function l(t = p) {
|
|
5
|
-
const e = a(n), [o, r] = c(t(e.getState()));
|
|
6
|
-
return e.onChange(t, r), i(() => () => e.clearOnChange(r), [e]), o;
|
|
7
|
-
}
|
|
8
|
-
function p(t) {
|
|
9
|
-
return t;
|
|
10
|
-
}
|
|
11
|
-
function d({ from: t, size: e, pageSize: o }) {
|
|
12
|
-
return m() ? {
|
|
13
|
-
products: { from: t + o }
|
|
14
|
-
} : {
|
|
15
|
-
products: { size: e + o }
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function x(t = 24) {
|
|
19
|
-
const { from: e, size: o } = l((s) => ({
|
|
20
|
-
from: s.query.products?.from ?? 0,
|
|
21
|
-
size: s.query.products?.size ?? 0
|
|
22
|
-
})), { updateSearch: r } = u();
|
|
23
|
-
return {
|
|
24
|
-
loadMore: f(async () => {
|
|
25
|
-
await r(d({ from: e, size: o, pageSize: t }));
|
|
26
|
-
}, [e, o, t, r])
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
l as a,
|
|
31
|
-
d as g,
|
|
32
|
-
x as u
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-DIlSparF.cjs"),s=require("preact/hooks"),i=require("./isBot-C-qPIZyF.cjs");function c(e=f){const t=s.useContext(n.StoreContext),[o,r]=s.useState(e(t.getState()));return t.onChange(e,r),s.useEffect(()=>()=>t.clearOnChange(r),[t]),o}function f(e){return 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:r}=n.useActions();return{loadMore:s.useCallback(async()=>{await r(a({from:t,size:o,pageSize:e}))},[t,o,e,r])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
|