@nosto/search-js 2.2.0 → 2.4.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-BOtsS3zB.cjs → InfiniteScrollWithObserver-C3ILy8X_.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-D47sKLiT.js → InfiniteScrollWithObserver-DGZxUITY.js} +1 -1
- package/dist/baseConfig-BlLNh6Jn.cjs +1 -0
- package/dist/{baseConfig-C_tlTx1w.js → baseConfig-XyA_9NDR.js} +8 -7
- package/dist/{storeContext-jWZFJ8Kf.js → configContext-CDTtcin_.js} +19 -20
- package/dist/configContext-CGXeJcqj.cjs +1 -0
- package/dist/core/core.cjs.js +1 -1
- package/dist/core/core.es.js +1 -1
- package/dist/logger-DW5RVLX8.js +17 -0
- package/dist/logger-DbHGgDgO.cjs +1 -0
- package/dist/preact/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete.es.js +2 -2
- package/dist/preact/category.cjs.js +1 -1
- package/dist/preact/category.es.js +2 -2
- package/dist/preact/common.cjs.js +1 -1
- package/dist/preact/common.es.js +4 -4
- package/dist/preact/hooks.cjs.js +1 -1
- package/dist/preact/hooks.es.js +3 -3
- package/dist/preact/legacy.cjs.js +1 -1
- package/dist/preact/legacy.es.js +2 -2
- package/dist/preact/serp.cjs.js +1 -1
- package/dist/preact/serp.es.js +2 -2
- package/dist/preact/src/hooks/useLoadMore/getNextPageQuery.d.ts +7 -5
- package/dist/preact/src/search/resultCaching.d.ts +8 -1
- package/dist/preact/src/search/searchWithCache.d.ts +4 -0
- package/dist/search-DJ_ktWg-.cjs +1 -0
- package/dist/search-DaZVHDP9.js +44 -0
- package/dist/unique-BCAEb4ek.cjs +1 -0
- package/dist/unique-CyAMhegX.js +44 -0
- package/dist/useLoadMore-CHLvVMm8.js +293 -0
- package/dist/useLoadMore-Co6PDmam.cjs +1 -0
- package/dist/utils/src/bindInput.d.ts +14 -0
- package/dist/utils/src/logger.d.ts +6 -0
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.es.js +9 -7
- package/package.json +6 -6
- package/dist/baseConfig-DEAGSRSp.cjs +0 -1
- package/dist/search-B0-bVNMy.js +0 -43
- package/dist/search-BVJZK90N.cjs +0 -1
- package/dist/storeContext-DVs7r6Qm.cjs +0 -1
- package/dist/unique-CGVAnKZy.cjs +0 -1
- package/dist/unique-Dwtu7vXB.js +0 -44
- package/dist/useLoadMore-BbcvS5k5.js +0 -261
- package/dist/useLoadMore-VMNS8y7r.cjs +0 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { S as v, u as M } from "./configContext-CDTtcin_.js";
|
|
2
|
+
import { useContext as F, useState as N, useEffect as z, useMemo as A, useCallback as f } from "preact/hooks";
|
|
3
|
+
import { u as R, a as h, m as q, i as O } from "./unique-CyAMhegX.js";
|
|
4
|
+
import { s as y } from "./search-DaZVHDP9.js";
|
|
5
|
+
import { i as P, d as m } from "./isEqual-BzZ3d1JM.js";
|
|
6
|
+
import { l as p } from "./logger-DW5RVLX8.js";
|
|
7
|
+
function E(e = U) {
|
|
8
|
+
const r = F(v), [t, s] = N(e(r.getState()));
|
|
9
|
+
return r.onChange(e, s), z(() => () => r.clearOnChange(s), [r]), t;
|
|
10
|
+
}
|
|
11
|
+
const U = (e) => e;
|
|
12
|
+
function J(e, r) {
|
|
13
|
+
return {
|
|
14
|
+
...r,
|
|
15
|
+
products: {
|
|
16
|
+
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
17
|
+
fields: K,
|
|
18
|
+
...r.products
|
|
19
|
+
},
|
|
20
|
+
...r.keywords ? {
|
|
21
|
+
keywords: {
|
|
22
|
+
...r.keywords,
|
|
23
|
+
fields: R([...V, ...r.keywords.fields ?? []]),
|
|
24
|
+
highlight: r.keywords.highlight ?? {
|
|
25
|
+
preTag: "<strong>",
|
|
26
|
+
postTag: "</strong>"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} : {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const K = [
|
|
33
|
+
"productId",
|
|
34
|
+
"url",
|
|
35
|
+
"name",
|
|
36
|
+
"imageUrl",
|
|
37
|
+
"imageHash",
|
|
38
|
+
"thumbUrl",
|
|
39
|
+
"description",
|
|
40
|
+
"brand",
|
|
41
|
+
"variantId",
|
|
42
|
+
"availability",
|
|
43
|
+
"price",
|
|
44
|
+
"priceText",
|
|
45
|
+
"categoryIds",
|
|
46
|
+
"categories",
|
|
47
|
+
"customFields.key",
|
|
48
|
+
"customFields.value",
|
|
49
|
+
"priceCurrencyCode",
|
|
50
|
+
"datePublished",
|
|
51
|
+
"listPrice",
|
|
52
|
+
"unitPricingBaseMeasure",
|
|
53
|
+
"unitPricingUnit",
|
|
54
|
+
"unitPricingMeasure",
|
|
55
|
+
"googleCategory",
|
|
56
|
+
"gtin",
|
|
57
|
+
"ageGroup",
|
|
58
|
+
"gender",
|
|
59
|
+
"condition",
|
|
60
|
+
"alternateImageUrls",
|
|
61
|
+
"ratingValue",
|
|
62
|
+
"reviewCount",
|
|
63
|
+
"inventoryLevel",
|
|
64
|
+
"skus.id",
|
|
65
|
+
"skus.name",
|
|
66
|
+
"skus.price",
|
|
67
|
+
"skus.listPrice",
|
|
68
|
+
"skus.priceText",
|
|
69
|
+
"skus.url",
|
|
70
|
+
"skus.imageUrl",
|
|
71
|
+
"skus.inventoryLevel",
|
|
72
|
+
"skus.customFields.key",
|
|
73
|
+
"skus.customFields.value",
|
|
74
|
+
"skus.availability",
|
|
75
|
+
"pid",
|
|
76
|
+
"onDiscount",
|
|
77
|
+
"extra.key",
|
|
78
|
+
"extra.value",
|
|
79
|
+
"saleable",
|
|
80
|
+
"available",
|
|
81
|
+
"tags1",
|
|
82
|
+
"tags2",
|
|
83
|
+
"tags3"
|
|
84
|
+
], V = ["keyword", "_redirect"];
|
|
85
|
+
function L(e, r, t) {
|
|
86
|
+
const s = JSON.stringify(r);
|
|
87
|
+
try {
|
|
88
|
+
p.info("Setting storage", e, s), t.setItem(e, s);
|
|
89
|
+
} catch (a) {
|
|
90
|
+
p.warn(a);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function _(e, r) {
|
|
94
|
+
try {
|
|
95
|
+
const t = r.getItem(e);
|
|
96
|
+
if (t)
|
|
97
|
+
return JSON.parse(t);
|
|
98
|
+
} catch (t) {
|
|
99
|
+
p.warn(t);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function j(e, r) {
|
|
103
|
+
L(e, r, sessionStorage);
|
|
104
|
+
}
|
|
105
|
+
function B(e) {
|
|
106
|
+
return _(e, sessionStorage);
|
|
107
|
+
}
|
|
108
|
+
const I = "nosto:search:searchResult";
|
|
109
|
+
function D(e, r, t) {
|
|
110
|
+
if (!e)
|
|
111
|
+
return;
|
|
112
|
+
j(I, { query: r, result: t });
|
|
113
|
+
}
|
|
114
|
+
function G(e, r) {
|
|
115
|
+
if (!e)
|
|
116
|
+
return null;
|
|
117
|
+
const t = B(I);
|
|
118
|
+
if (!t || !H(t))
|
|
119
|
+
return null;
|
|
120
|
+
const s = b(t.query);
|
|
121
|
+
return P(b(r), s) ? t : null;
|
|
122
|
+
}
|
|
123
|
+
function b(e) {
|
|
124
|
+
const r = {
|
|
125
|
+
...e,
|
|
126
|
+
time: void 0,
|
|
127
|
+
products: {
|
|
128
|
+
...e.products,
|
|
129
|
+
size: void 0
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
return JSON.parse(JSON.stringify(r));
|
|
133
|
+
}
|
|
134
|
+
function H(e) {
|
|
135
|
+
return typeof e == "object" && e !== null && "query" in e && "result" in e;
|
|
136
|
+
}
|
|
137
|
+
async function W(e, r, t) {
|
|
138
|
+
const s = e.pageType !== "autocomplete" && e.persistentSearchCache, a = s ? await Q(r, t, s) : await y(r, t);
|
|
139
|
+
return D(s, r, a), a;
|
|
140
|
+
}
|
|
141
|
+
async function Q(e, r, t) {
|
|
142
|
+
var g, d, k, w, C;
|
|
143
|
+
const { from: s = 0, size: a = 0 } = e.products || {}, { result: o } = G(t, e) || {}, n = ((g = o == null ? void 0 : o.products) == null ? void 0 : g.hits) || [];
|
|
144
|
+
if (!o)
|
|
145
|
+
return await y(e, r);
|
|
146
|
+
if (a === n.length)
|
|
147
|
+
return o;
|
|
148
|
+
if (a < n.length)
|
|
149
|
+
return {
|
|
150
|
+
...o,
|
|
151
|
+
products: {
|
|
152
|
+
...o.products,
|
|
153
|
+
hits: n.slice(0, a),
|
|
154
|
+
total: ((d = o.products) == null ? void 0 : d.total) || 0
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const c = a - n.length, i = s > 0 ? s + 1 : a - c, l = {
|
|
158
|
+
...e,
|
|
159
|
+
products: {
|
|
160
|
+
...e.products,
|
|
161
|
+
from: i,
|
|
162
|
+
size: c
|
|
163
|
+
}
|
|
164
|
+
}, u = await y(l, r);
|
|
165
|
+
return {
|
|
166
|
+
...o,
|
|
167
|
+
products: {
|
|
168
|
+
...o.products,
|
|
169
|
+
hits: [...((k = o.products) == null ? void 0 : k.hits) || [], ...((w = u.products) == null ? void 0 : w.hits) || []],
|
|
170
|
+
total: (C = u.products) == null ? void 0 : C.total
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async function T(e, r, t) {
|
|
175
|
+
var l, u, g;
|
|
176
|
+
const s = h("newSearch"), a = e.config.pageType, o = a === "search" ? "serp" : a, n = m(e.store.getInitialState().query, r), c = m(e.config.search, t, {
|
|
177
|
+
track: o,
|
|
178
|
+
redirect: a !== "autocomplete",
|
|
179
|
+
isKeyword: !!(t != null && t.isKeyword)
|
|
180
|
+
});
|
|
181
|
+
e.store.updateState({
|
|
182
|
+
query: n,
|
|
183
|
+
loading: !0,
|
|
184
|
+
initialized: !0
|
|
185
|
+
});
|
|
186
|
+
const i = e.config.queryModifications(
|
|
187
|
+
{
|
|
188
|
+
...n,
|
|
189
|
+
products: {
|
|
190
|
+
...n.products,
|
|
191
|
+
// Apply filter merging to avoid overwriting base filters
|
|
192
|
+
filter: q((u = (l = e.store.getInitialState().query) == null ? void 0 : l.products) == null ? void 0 : u.filter, (g = r.products) == null ? void 0 : g.filter)
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
a
|
|
196
|
+
);
|
|
197
|
+
try {
|
|
198
|
+
const d = await W(
|
|
199
|
+
e.config,
|
|
200
|
+
J(e.config.pageType, i),
|
|
201
|
+
c
|
|
202
|
+
);
|
|
203
|
+
e.store.updateState({
|
|
204
|
+
response: d,
|
|
205
|
+
loading: !1
|
|
206
|
+
});
|
|
207
|
+
} catch (d) {
|
|
208
|
+
p.error("Search action failed", d);
|
|
209
|
+
}
|
|
210
|
+
s();
|
|
211
|
+
}
|
|
212
|
+
async function S(e, r, t) {
|
|
213
|
+
const s = h("updateSearch"), a = m(e.store.getState().query, { products: { from: 0 } }, r);
|
|
214
|
+
await T(e, a, t), s();
|
|
215
|
+
}
|
|
216
|
+
async function Y(e, r, t) {
|
|
217
|
+
var n;
|
|
218
|
+
const s = h("replaceFilter"), a = (n = e.store.getState().query.products) == null ? void 0 : n.filter, o = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
219
|
+
await S(e, {
|
|
220
|
+
products: {
|
|
221
|
+
filter: [...(a == null ? void 0 : a.filter((c) => c.field !== r)) ?? [], ...o]
|
|
222
|
+
}
|
|
223
|
+
}), s();
|
|
224
|
+
}
|
|
225
|
+
async function X(e, r, t, s) {
|
|
226
|
+
var i, l;
|
|
227
|
+
const a = h("toggleProductFilter"), o = (i = e.store.getState().query.products) == null ? void 0 : i.filter, n = o == null ? void 0 : o.find((u) => u.value instanceof Array && u.field === r), c = n != null && n.value ? {
|
|
228
|
+
...n,
|
|
229
|
+
value: [...n.value.filter((u) => !P(u, t)), ...s ? [t] : []]
|
|
230
|
+
} : s ? {
|
|
231
|
+
field: r,
|
|
232
|
+
value: [t]
|
|
233
|
+
} : void 0;
|
|
234
|
+
await S(e, {
|
|
235
|
+
products: {
|
|
236
|
+
filter: [...(o == null ? void 0 : o.filter((u) => u !== n)) ?? [], ...(l = c == null ? void 0 : c.value) != null && l.length ? [c] : []]
|
|
237
|
+
}
|
|
238
|
+
}), a();
|
|
239
|
+
}
|
|
240
|
+
function Z() {
|
|
241
|
+
const e = M(), r = F(v), t = A(
|
|
242
|
+
() => ({
|
|
243
|
+
config: e,
|
|
244
|
+
store: r
|
|
245
|
+
}),
|
|
246
|
+
[e, r]
|
|
247
|
+
), s = f(
|
|
248
|
+
(c, i) => T(t, c, i),
|
|
249
|
+
[t]
|
|
250
|
+
), a = f(
|
|
251
|
+
(c, i) => S(t, c, i),
|
|
252
|
+
[t]
|
|
253
|
+
), o = f(
|
|
254
|
+
(c, i, l) => X(t, c, i, l),
|
|
255
|
+
[t]
|
|
256
|
+
), n = f(
|
|
257
|
+
(c, i) => Y(t, c, i),
|
|
258
|
+
[t]
|
|
259
|
+
);
|
|
260
|
+
return {
|
|
261
|
+
newSearch: s,
|
|
262
|
+
updateSearch: a,
|
|
263
|
+
toggleProductFilter: o,
|
|
264
|
+
replaceFilter: n
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function $({ from: e, size: r, pageSize: t }) {
|
|
268
|
+
return O() ? {
|
|
269
|
+
products: { from: e + t }
|
|
270
|
+
} : {
|
|
271
|
+
products: { size: r + t }
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function ae(e = 24) {
|
|
275
|
+
const { from: r, size: t } = E((o) => {
|
|
276
|
+
var n, c;
|
|
277
|
+
return {
|
|
278
|
+
from: ((n = o.query.products) == null ? void 0 : n.from) ?? 0,
|
|
279
|
+
size: ((c = o.query.products) == null ? void 0 : c.size) ?? 0
|
|
280
|
+
};
|
|
281
|
+
}), { updateSearch: s } = Z();
|
|
282
|
+
return {
|
|
283
|
+
loadMore: f(async () => {
|
|
284
|
+
await s($({ from: r, size: t, pageSize: e }));
|
|
285
|
+
}, [r, t, e, s])
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
export {
|
|
289
|
+
ae as a,
|
|
290
|
+
Z as b,
|
|
291
|
+
$ as g,
|
|
292
|
+
E as u
|
|
293
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const S=require("./configContext-CGXeJcqj.cjs"),l=require("preact/hooks"),g=require("./unique-BCAEb4ek.cjs"),k=require("./search-DJ_ktWg-.cjs"),h=require("./isEqual-DQXR__da.cjs"),y=require("./logger-DbHGgDgO.cjs");function v(e=N){const r=l.useContext(S.StoreContext),[t,s]=l.useState(e(r.getState()));return r.onChange(e,s),l.useEffect(()=>()=>r.clearOnChange(s),[r]),t}const N=e=>e;function T(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:A,...r.products},...r.keywords?{keywords:{...r.keywords,fields:g.unique([...z,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const A=["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"],z=["keyword","_redirect"];function E(e,r,t){const s=JSON.stringify(r);try{y.logger.info("Setting storage",e,s),t.setItem(e,s)}catch(a){y.logger.warn(a)}}function R(e,r){try{const t=r.getItem(e);if(t)return JSON.parse(t)}catch(t){y.logger.warn(t)}}function O(e,r){E(e,r,sessionStorage)}function U(e){return R(e,sessionStorage)}const F="nosto:search:searchResult";function J(e,r,t){if(!e)return;O(F,{query:r,result:t})}function K(e,r){if(!e)return null;const t=U(F);if(!t||!L(t))return null;const s=q(t.query);return h.isEqual(q(r),s)?t:null}function q(e){const r={...e,time:void 0,products:{...e.products,size:void 0}};return JSON.parse(JSON.stringify(r))}function L(e){return typeof e=="object"&&e!==null&&"query"in e&&"result"in e}async function V(e,r,t){const s=e.pageType!=="autocomplete"&&e.persistentSearchCache,a=s?await _(r,t,s):await k.search(r,t);return J(s,r,a),a}async function _(e,r,t){var p,f,C,w,b;const{from:s=0,size:a=0}=e.products||{},{result:o}=K(t,e)||{},n=((p=o==null?void 0:o.products)==null?void 0:p.hits)||[];if(!o)return await k.search(e,r);if(a===n.length)return o;if(a<n.length)return{...o,products:{...o.products,hits:n.slice(0,a),total:((f=o.products)==null?void 0:f.total)||0}};const c=a-n.length,i=s>0?s+1:a-c,d={...e,products:{...e.products,from:i,size:c}},u=await k.search(d,r);return{...o,products:{...o.products,hits:[...((C=o.products)==null?void 0:C.hits)||[],...((w=u.products)==null?void 0:w.hits)||[]],total:(b=u.products)==null?void 0:b.total}}}async function P(e,r,t){var d,u,p;const s=g.measure("newSearch"),a=e.config.pageType,o=a==="search"?"serp":a,n=h.deepMerge(e.store.getInitialState().query,r),c=h.deepMerge(e.config.search,t,{track:o,redirect:a!=="autocomplete",isKeyword:!!(t!=null&&t.isKeyword)});e.store.updateState({query:n,loading:!0,initialized:!0});const i=e.config.queryModifications({...n,products:{...n.products,filter:g.mergeArrays((u=(d=e.store.getInitialState().query)==null?void 0:d.products)==null?void 0:u.filter,(p=r.products)==null?void 0:p.filter)}},a);try{const f=await V(e.config,T(e.config.pageType,i),c);e.store.updateState({response:f,loading:!1})}catch(f){y.logger.error("Search action failed",f)}s()}async function m(e,r,t){const s=g.measure("updateSearch"),a=h.deepMerge(e.store.getState().query,{products:{from:0}},r);await P(e,a,t),s()}async function j(e,r,t){var n;const s=g.measure("replaceFilter"),a=(n=e.store.getState().query.products)==null?void 0:n.filter,o=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await m(e,{products:{filter:[...(a==null?void 0:a.filter(c=>c.field!==r))??[],...o]}}),s()}async function B(e,r,t,s){var i,d;const a=g.measure("toggleProductFilter"),o=(i=e.store.getState().query.products)==null?void 0:i.filter,n=o==null?void 0:o.find(u=>u.value instanceof Array&&u.field===r),c=n!=null&&n.value?{...n,value:[...n.value.filter(u=>!h.isEqual(u,t)),...s?[t]:[]]}:s?{field:r,value:[t]}:void 0;await m(e,{products:{filter:[...(o==null?void 0:o.filter(u=>u!==n))??[],...(d=c==null?void 0:c.value)!=null&&d.length?[c]:[]]}}),a()}function M(){const e=S.useConfig(),r=l.useContext(S.StoreContext),t=l.useMemo(()=>({config:e,store:r}),[e,r]),s=l.useCallback((c,i)=>P(t,c,i),[t]),a=l.useCallback((c,i)=>m(t,c,i),[t]),o=l.useCallback((c,i,d)=>B(t,c,i,d),[t]),n=l.useCallback((c,i)=>j(t,c,i),[t]);return{newSearch:s,updateSearch:a,toggleProductFilter:o,replaceFilter:n}}function I({from:e,size:r,pageSize:t}){return g.isBot()?{products:{from:e+t}}:{products:{size:r+t}}}function D(e=24){const{from:r,size:t}=v(o=>{var n,c;return{from:((n=o.query.products)==null?void 0:n.from)??0,size:((c=o.query.products)==null?void 0:c.size)??0}}),{updateSearch:s}=M();return{loadMore:l.useCallback(async()=>{await s(I({from:r,size:t,pageSize:e}))},[r,t,e,s])}}exports.getNextPageQuery=I;exports.useActions=M;exports.useLoadMore=D;exports.useNostoAppState=v;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type InputBindingCallbacks = {
|
|
2
|
+
onSubmit?: (value: string) => void;
|
|
3
|
+
onInput?: (value: string) => void;
|
|
4
|
+
onFocus?: (value: string) => void;
|
|
5
|
+
onKeyDown?: (value: string, key: string) => void;
|
|
6
|
+
onClick?: (value: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export interface BindElementOptions {
|
|
9
|
+
form?: HTMLFormElement;
|
|
10
|
+
}
|
|
11
|
+
export declare function disableNativeAutocomplete(target: HTMLInputElement): void;
|
|
12
|
+
export declare function bindInput(target: HTMLInputElement, { onClick, onFocus, onInput, onKeyDown, onSubmit }: InputBindingCallbacks, { form }?: BindElementOptions): {
|
|
13
|
+
destroy: () => void;
|
|
14
|
+
};
|
package/dist/utils/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../isEqual-DQXR__da.cjs"),e=require("../unique-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../isEqual-DQXR__da.cjs"),e=require("../unique-BCAEb4ek.cjs"),i=require("../logger-DbHGgDgO.cjs"),u=require("../parseNumber-FsZ8w61u.cjs"),s=require("../pick-rYi1lc2m.cjs");exports.deepMerge=r.deepMerge;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.isBot=e.isBot;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.logger=i.logger;exports.parseNumber=u.parseNumber;exports.pick=s.pick;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { deepMerge, type MergeTests } from './src/deepMerge';
|
|
|
3
3
|
export { isBot } from './src/isBot';
|
|
4
4
|
export { isEqual } from './src/isEqual';
|
|
5
5
|
export { isPlainObject } from './src/isPlainObject';
|
|
6
|
+
export { logger } from './src/logger';
|
|
6
7
|
export { mergeArrays } from './src/mergeArrays';
|
|
7
8
|
export { parseNumber } from './src/parseNumber';
|
|
8
9
|
export { measure } from './src/performance';
|
package/dist/utils/utils.es.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { i, a as
|
|
3
|
-
import {
|
|
1
|
+
import { d as a, i as s, a as o } from "../isEqual-BzZ3d1JM.js";
|
|
2
|
+
import { i as m, a as i, m as t, u } from "../unique-CyAMhegX.js";
|
|
3
|
+
import { l as x } from "../logger-DW5RVLX8.js";
|
|
4
|
+
import { p as l } from "../parseNumber-QA48nJLp.js";
|
|
4
5
|
import { p as c } from "../pick-DReBictn.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
a as deepMerge,
|
|
8
|
+
m as isBot,
|
|
8
9
|
s as isEqual,
|
|
9
10
|
o as isPlainObject,
|
|
10
|
-
|
|
11
|
+
x as logger,
|
|
12
|
+
i as measure,
|
|
11
13
|
t as mergeArrays,
|
|
12
|
-
|
|
14
|
+
l as parseNumber,
|
|
13
15
|
c as pick,
|
|
14
16
|
u as unique
|
|
15
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"@nosto/nosto-js": "^2.0.0",
|
|
88
88
|
"@testing-library/dom": "^10.4.0",
|
|
89
89
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
90
|
-
"@types/node": "^22.
|
|
90
|
+
"@types/node": "^22.15.3",
|
|
91
91
|
"concurrently": "^9.1.2",
|
|
92
92
|
"copyfiles": "^2.4.1",
|
|
93
|
-
"eslint": "^9.25.
|
|
93
|
+
"eslint": "^9.25.1",
|
|
94
94
|
"eslint-config-prettier": "^10.1.2",
|
|
95
95
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
96
96
|
"eslint-plugin-prettier": "^5.2.6",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
100
100
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
101
101
|
"husky": "^9.1.7",
|
|
102
|
-
"isbot": "^5.1.
|
|
102
|
+
"isbot": "^5.1.27",
|
|
103
103
|
"jsdom": "^26.1.0",
|
|
104
104
|
"prettier": "^3.5.3",
|
|
105
105
|
"typedoc": "^0.28.3",
|
|
106
106
|
"typescript": "^5.8.3",
|
|
107
|
-
"typescript-eslint": "^8.
|
|
108
|
-
"vite": "^6.3.
|
|
107
|
+
"typescript-eslint": "^8.31.0",
|
|
108
|
+
"vite": "^6.3.3",
|
|
109
109
|
"vite-plugin-dts": "^4.5.3",
|
|
110
110
|
"vitest": "^3.1.2",
|
|
111
111
|
"@commitlint/cli": "^19.8.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./index.es-DlUp67LT.cjs"),o=require("preact/hooks");function s(){o.useEffect(()=>{const e=window.setTimeout(()=>{console.error("Nosto client script has not loaded after 3 seconds.")},3e3);t.s(()=>{window.clearTimeout(e)})},[])}const i={defaultCurrency:"EUR",queryModifications:e=>e};exports.defaultBaseConfig=i;exports.useCheckClientScript=s;
|
package/dist/search-B0-bVNMy.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { s } from "./index.es-B8mbAxS4.js";
|
|
2
|
-
function a(t, r) {
|
|
3
|
-
if (!t.products || !(r != null && r.length))
|
|
4
|
-
return t;
|
|
5
|
-
const e = (i) => r.reduce((u, n) => n(u), i);
|
|
6
|
-
return {
|
|
7
|
-
...t,
|
|
8
|
-
products: {
|
|
9
|
-
...t.products,
|
|
10
|
-
hits: t.products.hits.map(e)
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function o(t) {
|
|
15
|
-
return new Promise((r) => setTimeout(r, t));
|
|
16
|
-
}
|
|
17
|
-
async function f(t, r, e) {
|
|
18
|
-
const { maxRetries: i = 0, retryInterval: u = 1e3 } = e;
|
|
19
|
-
let n = 0;
|
|
20
|
-
for (; ; )
|
|
21
|
-
try {
|
|
22
|
-
return await t.search(r, e);
|
|
23
|
-
} catch (c) {
|
|
24
|
-
if (!h(c))
|
|
25
|
-
throw console.info("Skipping retry logic for", c), c;
|
|
26
|
-
if (n >= i)
|
|
27
|
-
throw c;
|
|
28
|
-
n++, await o(u);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function h(t) {
|
|
32
|
-
return !t || typeof t != "object" ? !1 : !("status" in t) || l(t.status);
|
|
33
|
-
}
|
|
34
|
-
function l(t) {
|
|
35
|
-
return typeof t == "number" && (t < 400 || t >= 500);
|
|
36
|
-
}
|
|
37
|
-
async function p(t, r = {}) {
|
|
38
|
-
const { hitDecorators: e, ...i } = r, u = await new Promise(s), n = await f(u, t, i);
|
|
39
|
-
return a(n, e);
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
p as s
|
|
43
|
-
};
|
package/dist/search-BVJZK90N.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("./index.es-DlUp67LT.cjs");function a(t,e){if(!t.products||!(e!=null&&e.length))return t;const r=i=>e.reduce((u,n)=>n(u),i);return{...t,products:{...t.products,hits:t.products.hits.map(r)}}}function o(t){return new Promise(e=>setTimeout(e,t))}async function f(t,e,r){const{maxRetries:i=0,retryInterval:u=1e3}=r;let n=0;for(;;)try{return await t.search(e,r)}catch(c){if(!h(c))throw console.info("Skipping retry logic for",c),c;if(n>=i)throw c;n++,await o(u)}}function h(t){return!t||typeof t!="object"?!1:!("status"in t)||l(t.status)}function l(t){return typeof t=="number"&&(t<400||t>=500)}async function y(t,e={}){const{hitDecorators:r,...i}=e,u=await new Promise(s.s),n=await f(u,t,i);return a(n,r)}exports.search=y;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("preact"),w=require("preact/hooks"),i=require("./isEqual-DQXR__da.cjs"),l=s.createContext(null),M=()=>{const e=w.useContext(l);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function f(e,u={}){const r=new Map;let o=i.deepMergePlain(e,u??{});const S=i.deepMergePlain(e,u);function d(t){o=t(o);for(const n of r.values())n(o)}function x(t){d(n=>({...n,...t}))}function p(){return o}function h(){return structuredClone(S)}function q(t,n){let c;r.set(n,b=>{const a=t(b);i.isEqual(a,c)||(c=a,n(a))})}function E(t){r.delete(t)}return{updateState:x,getState:p,getInitialState:h,onChange:q,clearOnChange:E}}const C={loading:!0,query:{},response:{},initialized:!1};function g(e={}){return f(C,e)}const P=s.createContext(g());exports.ConfigContext=l;exports.StoreContext=P;exports.createExtendableStore=f;exports.createStore=g;exports.defaultState=C;exports.useConfig=M;
|
package/dist/unique-CGVAnKZy.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var s=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[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/|^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/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|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|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab",i=/bot|crawl|http|lighthouse|scan|search|spider/i,t;function c(){if(t instanceof RegExp)return t;try{t=new RegExp(s,"i")}catch{t=i}return t}function d(e){return!!e&&c().test(e)}function u(){return d(navigator.userAgent)}function l(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,a)=>r.concat(a),[])}const n="nosto.search.";function p(e){var a;const r=`${n}${e}`;(a=window.performance)==null||a.mark(`${r}.start`)}function h(e){var a,o;const r=`${n}${e}`;(a=window.performance)==null||a.mark(`${r}.end`),(o=window.performance)==null||o.measure(r,`${r}.start`,`${r}.end`)}function m(e){return p(e),()=>h(e)}function w(e){return Array.from(new Set(e))}exports.isBot=u;exports.measure=m;exports.mergeArrays=l;exports.unique=w;
|
package/dist/unique-Dwtu7vXB.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var s = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[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/|^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/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|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|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab", c = /bot|crawl|http|lighthouse|scan|search|spider/i, t;
|
|
2
|
-
function i() {
|
|
3
|
-
if (t instanceof RegExp)
|
|
4
|
-
return t;
|
|
5
|
-
try {
|
|
6
|
-
t = new RegExp(s, "i");
|
|
7
|
-
} catch {
|
|
8
|
-
t = c;
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
}
|
|
12
|
-
function d(e) {
|
|
13
|
-
return !!e && i().test(e);
|
|
14
|
-
}
|
|
15
|
-
function u() {
|
|
16
|
-
return d(navigator.userAgent);
|
|
17
|
-
}
|
|
18
|
-
function h(...e) {
|
|
19
|
-
if (!e.every((r) => r == null))
|
|
20
|
-
return e.filter((r) => Array.isArray(r)).reduce((r, a) => r.concat(a), []);
|
|
21
|
-
}
|
|
22
|
-
const n = "nosto.search.";
|
|
23
|
-
function l(e) {
|
|
24
|
-
var a;
|
|
25
|
-
const r = `${n}${e}`;
|
|
26
|
-
(a = window.performance) == null || a.mark(`${r}.start`);
|
|
27
|
-
}
|
|
28
|
-
function p(e) {
|
|
29
|
-
var a, o;
|
|
30
|
-
const r = `${n}${e}`;
|
|
31
|
-
(a = window.performance) == null || a.mark(`${r}.end`), (o = window.performance) == null || o.measure(r, `${r}.start`, `${r}.end`);
|
|
32
|
-
}
|
|
33
|
-
function m(e) {
|
|
34
|
-
return l(e), () => p(e);
|
|
35
|
-
}
|
|
36
|
-
function w(e) {
|
|
37
|
-
return Array.from(new Set(e));
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
m as a,
|
|
41
|
-
u as i,
|
|
42
|
-
h as m,
|
|
43
|
-
w as u
|
|
44
|
-
};
|