@searchcraft/javascript-sdk 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/defineCustomElements.js +2 -0
- package/dist/components/index.d.ts +238 -120
- package/dist/components/index.js +10 -5
- package/dist/components/index.js.map +1 -1
- package/dist/components/{p-3f63fa14.js → p-0077f677.js} +4 -4
- package/dist/components/p-0077f677.js.map +1 -0
- package/dist/components/{p-e72d0167.js → p-13e81b5d.js} +3 -3
- package/dist/components/p-13e81b5d.js.map +1 -0
- package/dist/components/{p-39e70a00.js → p-172a848d.js} +29 -3
- package/dist/components/p-172a848d.js.map +1 -0
- package/dist/components/{p-f8df3d49.js → p-17c646e2.js} +101 -65
- package/dist/components/p-17c646e2.js.map +1 -0
- package/dist/components/{p-d361b781.js → p-2be1a382.js} +4 -4
- package/dist/components/{p-d361b781.js.map → p-2be1a382.js.map} +1 -1
- package/dist/components/{p-c317a36a.js → p-3e65aa91.js} +6 -6
- package/dist/components/p-3e65aa91.js.map +1 -0
- package/dist/components/{p-8aa0fff5.js → p-5d17ace0.js} +13 -13
- package/dist/components/p-5d17ace0.js.map +1 -0
- package/dist/components/p-84e2cbd6.js +46 -0
- package/dist/components/p-84e2cbd6.js.map +1 -0
- package/dist/components/{p-bc9e0e40.js → p-868803f9.js} +3 -3
- package/dist/components/{p-bc9e0e40.js.map → p-868803f9.js.map} +1 -1
- package/dist/components/{p-34a32648.js → p-a62a2e74.js} +4 -4
- package/dist/components/{p-34a32648.js.map → p-a62a2e74.js.map} +1 -1
- package/dist/components/searchcraft-ad.js +1 -1
- package/dist/components/searchcraft-facet-list.js +1 -1
- package/dist/components/searchcraft-filter-panel.js +5 -5
- package/dist/components/searchcraft-filter-panel.js.map +1 -1
- package/dist/components/searchcraft-input-form.js +1 -1
- package/dist/components/searchcraft-pagination.js +1 -1
- package/dist/components/searchcraft-pagination.js.map +1 -1
- package/dist/components/searchcraft-popover-button.js +95 -3
- package/dist/components/searchcraft-popover-button.js.map +1 -1
- package/dist/components/searchcraft-popover-footer.d.ts +11 -0
- package/dist/components/searchcraft-popover-footer.js +8 -0
- package/dist/components/searchcraft-popover-footer.js.map +1 -0
- package/dist/components/searchcraft-popover-form.js +34 -24
- package/dist/components/searchcraft-popover-form.js.map +1 -1
- package/dist/components/searchcraft-popover-list-item.js +1 -1
- package/dist/components/searchcraft-popover-list-view.js +1 -1
- package/dist/components/searchcraft-results-info.js +1 -8
- package/dist/components/searchcraft-results-info.js.map +1 -1
- package/dist/components/searchcraft-search-result.js +1 -1
- package/dist/components/searchcraft-search-results-per-page.js +1 -1
- package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
- package/dist/components/searchcraft-search-results.js +3 -3
- package/dist/components/searchcraft-search-results.js.map +1 -1
- package/dist/components/searchcraft-slider.js +1 -1
- package/dist/components/searchcraft-theme.js +2 -2
- package/dist/components/searchcraft-theme.js.map +1 -1
- package/dist/components/searchcraft-toggle-button.js +1 -1
- package/dist/hydrate/index.js +298 -109
- package/dist/hydrate/index.mjs +298 -109
- package/dist/themes/hologram.css +1 -0
- package/dist/themes/hologram.css.map +1 -0
- package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +4 -3
- package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +4 -3
- package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +4 -3
- package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +49 -5
- package/dist/types/components/searchcraft-popover-footer/searchcraft-popover-footer.d.ts +13 -0
- package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +4 -3
- package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +3 -3
- package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +6 -10
- package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +3 -0
- package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +5 -4
- package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +4 -3
- package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +4 -3
- package/dist/types/components.d.ts +231 -120
- package/dist/types/store/SearchcraftStore.types.d.ts +3 -0
- package/package.json +7 -3
- package/dist/components/p-39e70a00.js.map +0 -1
- package/dist/components/p-3f63fa14.js.map +0 -1
- package/dist/components/p-8aa0fff5.js.map +0 -1
- package/dist/components/p-c317a36a.js.map +0 -1
- package/dist/components/p-e72d0167.js.map +0 -1
- package/dist/components/p-f8df3d49.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
2
|
var q = (r, e, n) => e in r ? B(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
3
|
var h = (r, e, n) => q(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
var
|
|
5
|
-
class
|
|
4
|
+
var D = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INFO", r[r.WARN = 2] = "WARN", r[r.ERROR = 3] = "ERROR", r))(D || {});
|
|
5
|
+
class ve {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
h(this, "logLevel");
|
|
8
8
|
h(this, "logFormatter");
|
|
9
9
|
this.logLevel = e.logLevel || 1, this.logFormatter = e.logFormatter || this.defaultFormatter;
|
|
10
10
|
}
|
|
11
11
|
defaultFormatter(e, n) {
|
|
12
|
-
return `[${
|
|
12
|
+
return `[${D[e]}] ${( new Date()).toISOString()}: ${n}`;
|
|
13
13
|
}
|
|
14
14
|
debug(e) {
|
|
15
15
|
this.logLevel <= 0 && console.log(this.logFormatter(0, e));
|
|
@@ -124,17 +124,17 @@ function y(r, e) {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
var b = { exclude: [] },
|
|
128
|
-
typeof window < "u" && (
|
|
127
|
+
var b = { exclude: [] }, O = {}, N = { timeout: "true" }, v = function(r, e) {
|
|
128
|
+
typeof window < "u" && (O[r] = e);
|
|
129
129
|
}, j = function() {
|
|
130
|
-
return Object.fromEntries(Object.entries(
|
|
130
|
+
return Object.fromEntries(Object.entries(O).filter(function(r) {
|
|
131
131
|
var e, n = r[0];
|
|
132
132
|
return !(!((e = b == null ? void 0 : b.exclude) === null || e === void 0) && e.includes(n));
|
|
133
133
|
}).map(function(r) {
|
|
134
134
|
return [r[0], (0, r[1])()];
|
|
135
135
|
}));
|
|
136
136
|
};
|
|
137
|
-
function
|
|
137
|
+
function A(r) {
|
|
138
138
|
return r ^= r >>> 16, r = Math.imul(r, 2246822507), r ^= r >>> 13, r = Math.imul(r, 3266489909), (r ^= r >>> 16) >>> 0;
|
|
139
139
|
}
|
|
140
140
|
var m = new Uint32Array([597399067, 2869860233, 951274213, 2716044179]);
|
|
@@ -185,23 +185,23 @@ function M(r, e) {
|
|
|
185
185
|
c[0] = c[0] ^ s[0] << 0, c[0] = Math.imul(c[0], m[0]), c[0] = g(c[0], 15), c[0] = Math.imul(c[0], m[1]), t[0] = t[0] ^ c[0];
|
|
186
186
|
}
|
|
187
187
|
}(r, o), function(i, t) {
|
|
188
|
-
t[0] = t[0] ^ i.byteLength, t[1] = t[1] ^ i.byteLength, t[2] = t[2] ^ i.byteLength, t[3] = t[3] ^ i.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] =
|
|
188
|
+
t[0] = t[0] ^ i.byteLength, t[1] = t[1] ^ i.byteLength, t[2] = t[2] ^ i.byteLength, t[3] = t[3] ^ i.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] = A(t[0]), t[1] = A(t[1]), t[2] = A(t[2]), t[3] = A(t[3]), t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0;
|
|
189
189
|
}(r, o);
|
|
190
190
|
var a = new Uint8Array(o.buffer);
|
|
191
191
|
return Array.from(a).map(function(i) {
|
|
192
192
|
return i.toString(16).padStart(2, "0");
|
|
193
193
|
}).join("");
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function V(r, e) {
|
|
196
196
|
return new Promise(function(n) {
|
|
197
197
|
setTimeout(function() {
|
|
198
198
|
return n(e);
|
|
199
199
|
}, r);
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function G(r, e, n) {
|
|
203
203
|
return Promise.all(r.map(function(o) {
|
|
204
|
-
return Promise.race([o,
|
|
204
|
+
return Promise.race([o, V(e, n)]);
|
|
205
205
|
}));
|
|
206
206
|
}
|
|
207
207
|
function W() {
|
|
@@ -210,13 +210,13 @@ function W() {
|
|
|
210
210
|
return y(this, function(i) {
|
|
211
211
|
switch (i.label) {
|
|
212
212
|
case 0:
|
|
213
|
-
return i.trys.push([0, 2, , 3]), r = j(), e = Object.keys(r), [4,
|
|
213
|
+
return i.trys.push([0, 2, , 3]), r = j(), e = Object.keys(r), [4, G(Object.values(r), (b == null ? void 0 : b.timeout) || 1e3, N)];
|
|
214
214
|
case 1:
|
|
215
215
|
return n = i.sent(), o = n.filter(function(t) {
|
|
216
216
|
return t !== void 0;
|
|
217
217
|
}), a = {}, o.forEach(function(t, u) {
|
|
218
218
|
a[e[u]] = t;
|
|
219
|
-
}), [2,
|
|
219
|
+
}), [2, U(a, b.exclude || [])];
|
|
220
220
|
case 2:
|
|
221
221
|
throw i.sent();
|
|
222
222
|
case 3:
|
|
@@ -225,13 +225,13 @@ function W() {
|
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function U(r, e) {
|
|
229
229
|
var n = {}, o = function(i) {
|
|
230
230
|
if (r.hasOwnProperty(i)) {
|
|
231
231
|
var t = r[i];
|
|
232
232
|
if (typeof t != "object" || Array.isArray(t)) e.includes(i) || (n[i] = t);
|
|
233
233
|
else {
|
|
234
|
-
var u =
|
|
234
|
+
var u = U(t, e.map(function(l) {
|
|
235
235
|
return l.startsWith(i + ".") ? l.slice(i.length + 1) : l;
|
|
236
236
|
}));
|
|
237
237
|
Object.keys(u).length > 0 && (n[i] = u);
|
|
@@ -262,7 +262,7 @@ function H(r) {
|
|
|
262
262
|
for (var e = 0, n = 0; n < r.length; ++n) e += Math.abs(r[n]);
|
|
263
263
|
return e;
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function L(r, e, n) {
|
|
266
266
|
for (var o = [], a = 0; a < r[0].data.length; a++) {
|
|
267
267
|
for (var i = [], t = 0; t < r.length; t++) i.push(r[t].data[a]);
|
|
268
268
|
o.push(Q(i));
|
|
@@ -304,14 +304,14 @@ v("audio", function() {
|
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
|
-
var z = E().name !== "SamsungBrowser" ? 1 : 3,
|
|
307
|
+
var z = E().name !== "SamsungBrowser" ? 1 : 3, k = 280, F = 20;
|
|
308
308
|
E().name != "Firefox" && v("canvas", function() {
|
|
309
309
|
return document.createElement("canvas").getContext("2d"), new Promise(function(r) {
|
|
310
310
|
var e = Array.from({ length: z }, function() {
|
|
311
311
|
return function() {
|
|
312
312
|
var n = document.createElement("canvas"), o = n.getContext("2d");
|
|
313
313
|
if (!o) return new ImageData(1, 1);
|
|
314
|
-
n.width =
|
|
314
|
+
n.width = k, n.height = F;
|
|
315
315
|
var a = o.createLinearGradient(0, 0, n.width, n.height);
|
|
316
316
|
a.addColorStop(0, "red"), a.addColorStop(0.16666666666666666, "orange"), a.addColorStop(0.3333333333333333, "yellow"), a.addColorStop(0.5, "green"), a.addColorStop(0.6666666666666666, "blue"), a.addColorStop(0.8333333333333334, "indigo"), a.addColorStop(1, "violet"), o.fillStyle = a, o.fillRect(0, 0, n.width, n.height);
|
|
317
317
|
var i = "Random Text WMwmil10Oo";
|
|
@@ -320,15 +320,15 @@ E().name != "Firefox" && v("canvas", function() {
|
|
|
320
320
|
return t;
|
|
321
321
|
}();
|
|
322
322
|
});
|
|
323
|
-
r({ commonImageDataHash: M(
|
|
323
|
+
r({ commonImageDataHash: M(L(e, k, F).data.toString()).toString() });
|
|
324
324
|
});
|
|
325
325
|
});
|
|
326
|
-
var
|
|
327
|
-
function
|
|
326
|
+
var _, K = ["Arial", "Arial Black", "Arial Narrow", "Arial Rounded MT", "Arimo", "Archivo", "Barlow", "Bebas Neue", "Bitter", "Bookman", "Calibri", "Cabin", "Candara", "Century", "Century Gothic", "Comic Sans MS", "Constantia", "Courier", "Courier New", "Crimson Text", "DM Mono", "DM Sans", "DM Serif Display", "DM Serif Text", "Dosis", "Droid Sans", "Exo", "Fira Code", "Fira Sans", "Franklin Gothic Medium", "Garamond", "Geneva", "Georgia", "Gill Sans", "Helvetica", "Impact", "Inconsolata", "Indie Flower", "Inter", "Josefin Sans", "Karla", "Lato", "Lexend", "Lucida Bright", "Lucida Console", "Lucida Sans Unicode", "Manrope", "Merriweather", "Merriweather Sans", "Montserrat", "Myriad", "Noto Sans", "Nunito", "Nunito Sans", "Open Sans", "Optima", "Orbitron", "Oswald", "Pacifico", "Palatino", "Perpetua", "PT Sans", "PT Serif", "Poppins", "Prompt", "Public Sans", "Quicksand", "Rajdhani", "Recursive", "Roboto", "Roboto Condensed", "Rockwell", "Rubik", "Segoe Print", "Segoe Script", "Segoe UI", "Sora", "Source Sans Pro", "Space Mono", "Tahoma", "Taviraj", "Times", "Times New Roman", "Titillium Web", "Trebuchet MS", "Ubuntu", "Varela Round", "Verdana", "Work Sans"], J = ["monospace", "sans-serif", "serif"];
|
|
327
|
+
function P(r, e) {
|
|
328
328
|
if (!r) throw new Error("Canvas context not supported");
|
|
329
329
|
return r.font = "72px ".concat(e), r.measureText("WwMmLli0Oo").width;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Y() {
|
|
332
332
|
var r, e = document.createElement("canvas"), n = (r = e.getContext("webgl")) !== null && r !== void 0 ? r : e.getContext("experimental-webgl");
|
|
333
333
|
if (n && "getParameter" in n) try {
|
|
334
334
|
var o = (n.getParameter(n.VENDOR) || "").toString(), a = (n.getParameter(n.RENDERER) || "").toString(), i = { vendor: o, renderer: a, version: (n.getParameter(n.VERSION) || "").toString(), shadingLanguageVersion: (n.getParameter(n.SHADING_LANGUAGE_VERSION) || "").toString() };
|
|
@@ -416,10 +416,10 @@ E().name != "Firefox" && v("fonts", function() {
|
|
|
416
416
|
return w(r, void 0, void 0, function() {
|
|
417
417
|
var i, t, u, l;
|
|
418
418
|
return y(this, function(c) {
|
|
419
|
-
return i = a.createElement("canvas"), t = i.getContext("2d"), u =
|
|
420
|
-
return
|
|
419
|
+
return i = a.createElement("canvas"), t = i.getContext("2d"), u = J.map(function(s) {
|
|
420
|
+
return P(t, s);
|
|
421
421
|
}), l = {}, K.forEach(function(s) {
|
|
422
|
-
var f =
|
|
422
|
+
var f = P(t, s);
|
|
423
423
|
u.includes(f) || (l[s] = f);
|
|
424
424
|
}), e(l), [2];
|
|
425
425
|
});
|
|
@@ -432,7 +432,7 @@ E().name != "Firefox" && v("fonts", function() {
|
|
|
432
432
|
}), v("hardware", function() {
|
|
433
433
|
return new Promise(function(r, e) {
|
|
434
434
|
var n = navigator.deviceMemory !== void 0 ? navigator.deviceMemory : 0, o = window.performance && window.performance.memory ? window.performance.memory : 0;
|
|
435
|
-
r({ videocard:
|
|
435
|
+
r({ videocard: Y(), architecture: X(), deviceMemory: n.toString() || "undefined", jsHeapSizeLimit: o.jsHeapSizeLimit || 0 });
|
|
436
436
|
});
|
|
437
437
|
}), v("locales", function() {
|
|
438
438
|
return new Promise(function(r) {
|
|
@@ -442,14 +442,14 @@ E().name != "Firefox" && v("fonts", function() {
|
|
|
442
442
|
return w(this, void 0, void 0, function() {
|
|
443
443
|
var r;
|
|
444
444
|
return y(this, function(e) {
|
|
445
|
-
return
|
|
445
|
+
return _ = (b == null ? void 0 : b.permissions_to_check) || ["accelerometer", "accessibility", "accessibility-events", "ambient-light-sensor", "background-fetch", "background-sync", "bluetooth", "camera", "clipboard-read", "clipboard-write", "device-info", "display-capture", "gyroscope", "geolocation", "local-fonts", "magnetometer", "microphone", "midi", "nfc", "notifications", "payment-handler", "persistent-storage", "push", "speaker", "storage-access", "top-level-storage-access", "window-management", "query"], r = Array.from({ length: (b == null ? void 0 : b.retries) || 3 }, function() {
|
|
446
446
|
return function() {
|
|
447
447
|
return w(this, void 0, void 0, function() {
|
|
448
448
|
var n, o, a, i, t;
|
|
449
449
|
return y(this, function(u) {
|
|
450
450
|
switch (u.label) {
|
|
451
451
|
case 0:
|
|
452
|
-
n = {}, o = 0, a =
|
|
452
|
+
n = {}, o = 0, a = _, u.label = 1;
|
|
453
453
|
case 1:
|
|
454
454
|
if (!(o < a.length)) return [3, 6];
|
|
455
455
|
i = a[o], u.label = 2;
|
|
@@ -468,7 +468,7 @@ E().name != "Firefox" && v("fonts", function() {
|
|
|
468
468
|
});
|
|
469
469
|
}();
|
|
470
470
|
}), [2, Promise.all(r).then(function(n) {
|
|
471
|
-
return Z(n,
|
|
471
|
+
return Z(n, _);
|
|
472
472
|
})];
|
|
473
473
|
});
|
|
474
474
|
});
|
|
@@ -525,19 +525,19 @@ v("webgl", function() {
|
|
|
525
525
|
var f = s * c;
|
|
526
526
|
l[4 * s] = 0, l[4 * s + 1] = 0, l[4 * s + 2] = Math.cos(f) * (p.width / 2), l[4 * s + 3] = Math.sin(f) * (p.height / 2);
|
|
527
527
|
}
|
|
528
|
-
var
|
|
529
|
-
d.bindBuffer(d.ARRAY_BUFFER,
|
|
530
|
-
var
|
|
531
|
-
d.enableVertexAttribArray(
|
|
532
|
-
var
|
|
533
|
-
return d.readPixels(0, 0, p.width, p.height, d.RGBA, d.UNSIGNED_BYTE,
|
|
528
|
+
var C = d.createBuffer();
|
|
529
|
+
d.bindBuffer(d.ARRAY_BUFFER, C), d.bufferData(d.ARRAY_BUFFER, l, d.STATIC_DRAW);
|
|
530
|
+
var R = d.getAttribLocation(t, "position");
|
|
531
|
+
d.enableVertexAttribArray(R), d.vertexAttribPointer(R, 2, d.FLOAT, !1, 0, 0), d.viewport(0, 0, p.width, p.height), d.clearColor(0, 0, 0, 1), d.clear(d.COLOR_BUFFER_BIT), d.drawArrays(d.LINES, 0, 2 * u);
|
|
532
|
+
var x = new Uint8ClampedArray(p.width * p.height * 4);
|
|
533
|
+
return d.readPixels(0, 0, p.width, p.height, d.RGBA, d.UNSIGNED_BYTE, x), new ImageData(x, p.width, p.height);
|
|
534
534
|
} catch {
|
|
535
535
|
return new ImageData(1, 1);
|
|
536
536
|
} finally {
|
|
537
537
|
d && (d.bindBuffer(d.ARRAY_BUFFER, null), d.useProgram(null), d.viewport(0, 0, d.drawingBufferWidth, d.drawingBufferHeight), d.clearColor(0, 0, 0, 0));
|
|
538
538
|
}
|
|
539
539
|
}();
|
|
540
|
-
}), [2, { commonImageHash: M(
|
|
540
|
+
}), [2, { commonImageHash: M(L(r, p.width, p.height).data.toString()).toString() }];
|
|
541
541
|
} catch {
|
|
542
542
|
return [2, { webgl: "unsupported" }];
|
|
543
543
|
}
|
|
@@ -558,13 +558,13 @@ v("math", function() {
|
|
|
558
558
|
});
|
|
559
559
|
});
|
|
560
560
|
const re = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
561
|
-
let
|
|
561
|
+
let T = (r = 21) => {
|
|
562
562
|
let e = "", n = crypto.getRandomValues(new Uint8Array(r |= 0));
|
|
563
563
|
for (; r--; )
|
|
564
564
|
e += re[n[r] & 63];
|
|
565
565
|
return e;
|
|
566
566
|
};
|
|
567
|
-
class
|
|
567
|
+
class I {
|
|
568
568
|
constructor(e) {
|
|
569
569
|
h(this, "config");
|
|
570
570
|
this.config = e;
|
|
@@ -583,7 +583,7 @@ class _ {
|
|
|
583
583
|
async onAdContainerViewed(e) {
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
class oe extends
|
|
586
|
+
class oe extends I {
|
|
587
587
|
/**
|
|
588
588
|
* Gets ads from the adMarketplace API based on the search term.
|
|
589
589
|
*/
|
|
@@ -600,13 +600,13 @@ class oe extends _ {
|
|
|
600
600
|
"results-pa": `${this.config.admProductAdQuantity || 0}`
|
|
601
601
|
}).toString()}`, i = await (await fetch(o, { method: "GET" })).json(), t = i.product_ads.map(
|
|
602
602
|
(c) => ({
|
|
603
|
-
id:
|
|
603
|
+
id: T(),
|
|
604
604
|
adSource: "adMarketplace",
|
|
605
605
|
admAdType: "adm-product-ad",
|
|
606
606
|
admAd: c
|
|
607
607
|
})
|
|
608
608
|
), u = i.text_ads.map((c) => ({
|
|
609
|
-
id:
|
|
609
|
+
id: T(),
|
|
610
610
|
adSource: "adMarketplace",
|
|
611
611
|
admAdType: "adm-text-ad",
|
|
612
612
|
admAd: c
|
|
@@ -619,13 +619,13 @@ class oe extends _ {
|
|
|
619
619
|
(o = n.admAd) != null && o.impression_url && fetch(n.admAd.impression_url);
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
|
-
class ie extends
|
|
622
|
+
class ie extends I {
|
|
623
623
|
async getAdsForSearchParams(e) {
|
|
624
624
|
return [];
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
const ae = 1e3;
|
|
628
|
-
class se extends
|
|
628
|
+
class se extends I {
|
|
629
629
|
constructor(n) {
|
|
630
630
|
super(n);
|
|
631
631
|
h(this, "adCallTimeout");
|
|
@@ -669,7 +669,7 @@ class se extends _ {
|
|
|
669
669
|
n && document.head.removeChild(n);
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
const ce =
|
|
672
|
+
const ce = 600;
|
|
673
673
|
class ue {
|
|
674
674
|
constructor(e, n, o) {
|
|
675
675
|
h(this, "measureRequestTimeout");
|
|
@@ -685,7 +685,7 @@ class ue {
|
|
|
685
685
|
* @param {Partial<MeasureRequestProperties>} properties - Additional properties to send with the event.
|
|
686
686
|
* @param {Partial<MeasureRequestUser>} user - Additional user properites to send with the event.
|
|
687
687
|
*/
|
|
688
|
-
h(this, "sendMeasureEvent", (e, n = {}, o = {}) => {
|
|
688
|
+
h(this, "sendMeasureEvent", async (e, n = {}, o = {}) => {
|
|
689
689
|
const a = {
|
|
690
690
|
event_name: e,
|
|
691
691
|
properties: {
|
|
@@ -698,8 +698,8 @@ class ue {
|
|
|
698
698
|
...o
|
|
699
699
|
}
|
|
700
700
|
};
|
|
701
|
-
|
|
702
|
-
const i = JSON.stringify(
|
|
701
|
+
if (e === "document_clicked") {
|
|
702
|
+
const i = JSON.stringify(a), t = `${this.baseMeasureUrl}/event`;
|
|
703
703
|
try {
|
|
704
704
|
const u = await fetch(t, {
|
|
705
705
|
method: "POST",
|
|
@@ -715,14 +715,34 @@ class ue {
|
|
|
715
715
|
throw new Error(
|
|
716
716
|
`Failed to send request: ${u.status} ${u.statusText}`
|
|
717
717
|
);
|
|
718
|
-
this.measureRequestsBatched = [];
|
|
719
|
-
return;
|
|
720
718
|
} catch (u) {
|
|
721
719
|
throw console.error("Error sending MeasureRequest:", u), u;
|
|
722
720
|
}
|
|
723
|
-
}
|
|
721
|
+
} else
|
|
722
|
+
this.measureRequestsBatched.push(a), clearTimeout(this.measureRequestTimeout), this.measureRequestTimeout = setTimeout(async () => {
|
|
723
|
+
const i = JSON.stringify({ items: this.measureRequestsBatched }), t = `${this.baseMeasureUrl}/batch`;
|
|
724
|
+
try {
|
|
725
|
+
const u = await fetch(t, {
|
|
726
|
+
method: "POST",
|
|
727
|
+
headers: {
|
|
728
|
+
"Content-Type": "application/json",
|
|
729
|
+
Authorization: this.config.readKey,
|
|
730
|
+
"X-Sc-User-Id": this.userId
|
|
731
|
+
},
|
|
732
|
+
body: i,
|
|
733
|
+
keepalive: !0
|
|
734
|
+
});
|
|
735
|
+
if (this.measureRequestsBatched = [], !u.ok)
|
|
736
|
+
throw new Error(
|
|
737
|
+
`Failed to send request: ${u.status} ${u.statusText}`
|
|
738
|
+
);
|
|
739
|
+
return;
|
|
740
|
+
} catch (u) {
|
|
741
|
+
throw this.measureRequestsBatched = [], console.error("Error sending MeasureRequest:", u), u;
|
|
742
|
+
}
|
|
743
|
+
}, ce);
|
|
724
744
|
});
|
|
725
|
-
this.config = e, this.sdkInfo = n, this.userId = o, this.sessionId =
|
|
745
|
+
this.config = e, this.sdkInfo = n, this.userId = o, this.sessionId = T(), this.sendMeasureEvent("sdk_initialized");
|
|
726
746
|
}
|
|
727
747
|
/**
|
|
728
748
|
* Getter for the base url used by the /measure endpoints.
|
|
@@ -785,12 +805,13 @@ const le = (r) => r.endsWith("/") ? r.slice(0, -1) : r, he = (r) => {
|
|
|
785
805
|
"The search term contains an uneven number of quote characters."
|
|
786
806
|
);
|
|
787
807
|
return e;
|
|
788
|
-
};
|
|
789
|
-
class
|
|
808
|
+
}, fe = 500;
|
|
809
|
+
class me {
|
|
790
810
|
constructor(e, n, o) {
|
|
791
811
|
h(this, "config");
|
|
792
812
|
h(this, "userId");
|
|
793
813
|
h(this, "parent");
|
|
814
|
+
h(this, "searchCompletedEventTimeout");
|
|
794
815
|
/**
|
|
795
816
|
* Performs a search operation.
|
|
796
817
|
* @param {SearchParams} searchParams - The parameters for the search.
|
|
@@ -832,7 +853,13 @@ class fe {
|
|
|
832
853
|
return (i = this.parent.measureClient) == null || i.sendMeasureEvent("search_response_received", {
|
|
833
854
|
search_term: n,
|
|
834
855
|
number_of_documents: f.data.count
|
|
835
|
-
}), this.
|
|
856
|
+
}), clearTimeout(this.searchCompletedEventTimeout), this.searchCompletedEventTimeout = setTimeout(() => {
|
|
857
|
+
var C;
|
|
858
|
+
(C = this.parent.measureClient) == null || C.sendMeasureEvent("search_completed", {
|
|
859
|
+
search_term: n,
|
|
860
|
+
number_of_documents: f.data.count
|
|
861
|
+
});
|
|
862
|
+
}, fe), this.parent.emitEvent("query_fetched", {
|
|
836
863
|
name: "query_fetched",
|
|
837
864
|
data: {
|
|
838
865
|
searchTerm: n
|
|
@@ -853,7 +880,7 @@ class fe {
|
|
|
853
880
|
return `${this.config.endpointURL}/index/${this.config.index.join(",")}/search`;
|
|
854
881
|
}
|
|
855
882
|
}
|
|
856
|
-
class
|
|
883
|
+
class we {
|
|
857
884
|
constructor(e, n) {
|
|
858
885
|
h(this, "config");
|
|
859
886
|
h(this, "measureClient");
|
|
@@ -874,7 +901,7 @@ class ve {
|
|
|
874
901
|
throw new Error("Search client was not initialized.");
|
|
875
902
|
const t = (l = i.data.hits || []) == null ? void 0 : l.map((c) => c.doc).filter((c) => !!c).map((c) => ({
|
|
876
903
|
type: "SearchDocument",
|
|
877
|
-
id:
|
|
904
|
+
id: T(),
|
|
878
905
|
document: c
|
|
879
906
|
}));
|
|
880
907
|
n(i, t);
|
|
@@ -918,7 +945,7 @@ class ve {
|
|
|
918
945
|
let a = !1;
|
|
919
946
|
for (const i of n)
|
|
920
947
|
i.type === "childList" && i.addedNodes.forEach((t) => {
|
|
921
|
-
t.nodeType === 1 && t.
|
|
948
|
+
t.nodeType === 1 && (t.getAttribute("class") || "").toLowerCase() === "searchcraft-input-form" && (a = !0);
|
|
922
949
|
});
|
|
923
950
|
a && this.initInputForms();
|
|
924
951
|
}).observe(document.body, { childList: !0, subtree: !0 });
|
|
@@ -926,7 +953,7 @@ class ve {
|
|
|
926
953
|
initClients(e, n) {
|
|
927
954
|
setTimeout(async () => {
|
|
928
955
|
let o = this.config.userId;
|
|
929
|
-
switch (o || (o = await $()), this.measureClient = new ue(e, n, o), this.searchClient = new
|
|
956
|
+
switch (o || (o = await $()), this.measureClient = new ue(e, n, o), this.searchClient = new me(this, e, o), e.adSource) {
|
|
930
957
|
case "adMarketplace":
|
|
931
958
|
this.adClient = new oe(e);
|
|
932
959
|
break;
|
|
@@ -1615,6 +1642,8 @@ Object.keys(react).forEach(function (k) {
|
|
|
1615
1642
|
const initialSearchcraftStateValues = {
|
|
1616
1643
|
adClientResponseItems: [],
|
|
1617
1644
|
core: undefined,
|
|
1645
|
+
hotkey: 'k',
|
|
1646
|
+
hotkeyModifier: 'meta',
|
|
1618
1647
|
logger: undefined,
|
|
1619
1648
|
facetPathsForIndexFields: {},
|
|
1620
1649
|
isPopoverVisible: false,
|
|
@@ -1651,7 +1680,7 @@ const searchcraftStore = zustand.createStore((set, get) => {
|
|
|
1651
1680
|
initialize: (searchcraftInstance, debug = false) => {
|
|
1652
1681
|
const core = searchcraftInstance;
|
|
1653
1682
|
const logger = debug
|
|
1654
|
-
? new
|
|
1683
|
+
? new ve({ logLevel: D.DEBUG })
|
|
1655
1684
|
: undefined;
|
|
1656
1685
|
set({
|
|
1657
1686
|
core,
|
|
@@ -1684,12 +1713,12 @@ const searchcraftStore = zustand.createStore((set, get) => {
|
|
|
1684
1713
|
},
|
|
1685
1714
|
search: async () => {
|
|
1686
1715
|
const state = get();
|
|
1687
|
-
state.logger?.log(
|
|
1716
|
+
state.logger?.log(D.INFO, `Starting search with search term: "${state.searchTerm}"`);
|
|
1688
1717
|
if (!state.core) {
|
|
1689
1718
|
throw new Error('Searchcraft instance is not initialized.');
|
|
1690
1719
|
}
|
|
1691
1720
|
if (!state.searchTerm.trim()) {
|
|
1692
|
-
state.logger?.log(
|
|
1721
|
+
state.logger?.log(D.INFO, 'No search request was made: search term was empty.');
|
|
1693
1722
|
set({
|
|
1694
1723
|
searchClientResponseItems: [],
|
|
1695
1724
|
searchResultsCount: 0,
|
|
@@ -1717,8 +1746,8 @@ const searchcraftStore = zustand.createStore((set, get) => {
|
|
|
1717
1746
|
if (facetsFromResponse) {
|
|
1718
1747
|
set({ searchResponseFacetPrime: facetsFromResponse });
|
|
1719
1748
|
}
|
|
1720
|
-
state.logger?.log(
|
|
1721
|
-
state.logger?.log(
|
|
1749
|
+
state.logger?.log(D.DEBUG, `Search results: ${JSON.stringify(items)}`);
|
|
1750
|
+
state.logger?.log(D.DEBUG, `Facets from response: ${JSON.stringify(facetsFromResponse)}`);
|
|
1722
1751
|
};
|
|
1723
1752
|
const handleAdResponse = (adClientResponseItems) => {
|
|
1724
1753
|
set({ adClientResponseItems });
|
|
@@ -1768,6 +1797,13 @@ const searchcraftStore = zustand.createStore((set, get) => {
|
|
|
1768
1797
|
set({ searchResultsPerPage: perPage });
|
|
1769
1798
|
await functions.search();
|
|
1770
1799
|
},
|
|
1800
|
+
setHotKeyAndHotKeyModifier: (hotkey, hotkeyModifier) => {
|
|
1801
|
+
const { hotkey: initialHotkey, hotkeyModifier: initialHotkeyModifier } = initialSearchcraftStateValues;
|
|
1802
|
+
set({
|
|
1803
|
+
hotkey: hotkey || initialHotkey,
|
|
1804
|
+
hotkeyModifier: hotkeyModifier || initialHotkeyModifier,
|
|
1805
|
+
});
|
|
1806
|
+
},
|
|
1771
1807
|
};
|
|
1772
1808
|
const stateObject = {
|
|
1773
1809
|
...initialSearchcraftStateValues,
|
|
@@ -1776,6 +1812,6 @@ const searchcraftStore = zustand.createStore((set, get) => {
|
|
|
1776
1812
|
return stateObject;
|
|
1777
1813
|
});
|
|
1778
1814
|
|
|
1779
|
-
export { searchcraftStore as s,
|
|
1815
|
+
export { searchcraftStore as s, we as w };
|
|
1780
1816
|
|
|
1781
|
-
//# sourceMappingURL=p-
|
|
1817
|
+
//# sourceMappingURL=p-17c646e2.js.map
|