@searchspring/snap-controller 0.66.0 → 0.66.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/cjs/Search/SearchController.d.ts.map +1 -1
- package/dist/cjs/Search/SearchController.js +3 -13
- package/dist/cjs/utils/isClickWithinProductLink.d.ts.map +1 -1
- package/dist/cjs/utils/isClickWithinProductLink.js +3 -2
- package/dist/esm/Search/SearchController.d.ts.map +1 -1
- package/dist/esm/Search/SearchController.js +3 -12
- package/dist/esm/utils/isClickWithinProductLink.d.ts.map +1 -1
- package/dist/esm/utils/isClickWithinProductLink.js +3 -2
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAa,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,gBAAgB,EAIhB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACX,kBAAkB,EAQlB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAa,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO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,CAAC,CAQ/D;CACF;AAuBD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAiBxF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM,GAAG,SAAS,CAgCvG"}
|
|
@@ -569,7 +569,7 @@ var SearchController = /** @class */ (function (_super) {
|
|
|
569
569
|
if (controller.store.loaded && !controller.store.error) {
|
|
570
570
|
products = controller.store.results.filter(function (result) { var _a; return result.type === 'product' && !((_a = _this.events.product[result.id]) === null || _a === void 0 ? void 0 : _a.render); });
|
|
571
571
|
if (products.length === 0) {
|
|
572
|
-
data = getSearchSchemaData({ params: search.request,
|
|
572
|
+
data = getSearchSchemaData({ params: search.request, response: search.response });
|
|
573
573
|
this.tracker.events[this.pageType].render({ data: data, siteId: (_a = this.config.globals) === null || _a === void 0 ? void 0 : _a.siteId });
|
|
574
574
|
}
|
|
575
575
|
products.forEach(function (result) {
|
|
@@ -750,7 +750,6 @@ function createResultSchemaMapping(_a) {
|
|
|
750
750
|
var _ = response[0], searchResponse = response[1];
|
|
751
751
|
var schema = getSearchSchemaData({
|
|
752
752
|
params: request,
|
|
753
|
-
results: [], // results added below because this would contain all results
|
|
754
753
|
response: searchResponse,
|
|
755
754
|
});
|
|
756
755
|
(_b = searchResponse.results) === null || _b === void 0 ? void 0 : _b.forEach(function (result) {
|
|
@@ -830,7 +829,7 @@ function getSearchAddtocartSchemaData(_a) {
|
|
|
830
829
|
}
|
|
831
830
|
function getSearchSchemaData(_a) {
|
|
832
831
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
833
|
-
var params = _a.params,
|
|
832
|
+
var params = _a.params, response = _a.response;
|
|
834
833
|
var filters = (_b = params.filters) === null || _b === void 0 ? void 0 : _b.reduce(function (acc, filter) {
|
|
835
834
|
var _a;
|
|
836
835
|
var _b, _c, _d, _e;
|
|
@@ -881,14 +880,5 @@ function getSearchSchemaData(_a) {
|
|
|
881
880
|
};
|
|
882
881
|
})) ||
|
|
883
882
|
undefined,
|
|
884
|
-
}, results:
|
|
885
|
-
var _a;
|
|
886
|
-
var core = (_a = result.mappings) === null || _a === void 0 ? void 0 : _a.core;
|
|
887
|
-
var position = result.position;
|
|
888
|
-
return {
|
|
889
|
-
position: position,
|
|
890
|
-
uid: core.uid || '',
|
|
891
|
-
sku: core.sku,
|
|
892
|
-
};
|
|
893
|
-
})) || [] });
|
|
883
|
+
}, results: [] });
|
|
894
884
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isClickWithinProductLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinProductLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAO,UAAU,UAAU,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"isClickWithinProductLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinProductLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAO,UAAU,UAAU,OAAO,KAAG,OAgBzE,CAAC"}
|
|
@@ -8,10 +8,11 @@ var isClickWithinProductLink = function (e, result) {
|
|
|
8
8
|
var currentElement = e.target;
|
|
9
9
|
var href = null;
|
|
10
10
|
var level = 0;
|
|
11
|
-
var
|
|
11
|
+
var resultCoreUrl = ((_b = (_a = result === null || result === void 0 ? void 0 : result.display) === null || _a === void 0 ? void 0 : _a.mappings.core) === null || _b === void 0 ? void 0 : _b.url) || '';
|
|
12
|
+
var resultDisplayUrl = ((_c = result === null || result === void 0 ? void 0 : result.mappings.core) === null || _c === void 0 ? void 0 : _c.url) || '';
|
|
12
13
|
while (currentElement && level < exports.CLICK_THROUGH_CLOSEST_MAX_LEVELS) {
|
|
13
14
|
href = currentElement.getAttribute('href');
|
|
14
|
-
if (href &&
|
|
15
|
+
if (href && ((resultCoreUrl && href.includes(resultCoreUrl)) || (resultDisplayUrl && href.includes(resultDisplayUrl)))) {
|
|
15
16
|
return true;
|
|
16
17
|
}
|
|
17
18
|
currentElement = currentElement.parentElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAa,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,gBAAgB,EAIhB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EACX,kBAAkB,EAQlB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchController.d.ts","sourceRoot":"","sources":["../../../src/Search/SearchController.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAa,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,gBAAgB,EA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AO,EAAE,kBAAkB,GAAG,kBAAkB,CAiBxF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM,GAAG,SAAS,CAgCvG"}
|
|
@@ -408,7 +408,7 @@ export class SearchController extends AbstractController {
|
|
|
408
408
|
const products = controller.store.results.filter((result) => result.type === 'product' && !this.events.product[result.id]?.render);
|
|
409
409
|
if (products.length === 0) {
|
|
410
410
|
// handle no results
|
|
411
|
-
const data = getSearchSchemaData({ params: search.request,
|
|
411
|
+
const data = getSearchSchemaData({ params: search.request, response: search.response });
|
|
412
412
|
this.tracker.events[this.pageType].render({ data, siteId: this.config.globals?.siteId });
|
|
413
413
|
}
|
|
414
414
|
products.forEach((result) => {
|
|
@@ -546,7 +546,6 @@ function createResultSchemaMapping({ request, response }) {
|
|
|
546
546
|
const [_, searchResponse] = response;
|
|
547
547
|
const schema = getSearchSchemaData({
|
|
548
548
|
params: request,
|
|
549
|
-
results: [], // results added below because this would contain all results
|
|
550
549
|
response: searchResponse,
|
|
551
550
|
});
|
|
552
551
|
searchResponse.results?.forEach((result) => {
|
|
@@ -623,7 +622,7 @@ function getSearchAddtocartSchemaData({ searchSchemaData, results, }) {
|
|
|
623
622
|
}) || [],
|
|
624
623
|
};
|
|
625
624
|
}
|
|
626
|
-
function getSearchSchemaData({ params,
|
|
625
|
+
function getSearchSchemaData({ params, response }) {
|
|
627
626
|
const filters = params.filters?.reduce((acc, filter) => {
|
|
628
627
|
const key = filter.background ? 'bgfilter' : 'filter';
|
|
629
628
|
acc[key] = acc[key] || [];
|
|
@@ -680,14 +679,6 @@ function getSearchSchemaData({ params, results, response, }) {
|
|
|
680
679
|
})) ||
|
|
681
680
|
undefined,
|
|
682
681
|
},
|
|
683
|
-
results:
|
|
684
|
-
const core = result.mappings?.core;
|
|
685
|
-
const position = result.position;
|
|
686
|
-
return {
|
|
687
|
-
position,
|
|
688
|
-
uid: core.uid || '',
|
|
689
|
-
sku: core.sku,
|
|
690
|
-
};
|
|
691
|
-
}) || [],
|
|
682
|
+
results: [],
|
|
692
683
|
};
|
|
693
684
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isClickWithinProductLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinProductLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAO,UAAU,UAAU,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"isClickWithinProductLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinProductLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE7D,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAO,UAAU,UAAU,OAAO,KAAG,OAgBzE,CAAC"}
|
|
@@ -4,10 +4,11 @@ export const isClickWithinProductLink = (e, result) => {
|
|
|
4
4
|
let currentElement = e.target;
|
|
5
5
|
let href = null;
|
|
6
6
|
let level = 0;
|
|
7
|
-
const
|
|
7
|
+
const resultCoreUrl = result?.display?.mappings.core?.url || '';
|
|
8
|
+
const resultDisplayUrl = result?.mappings.core?.url || '';
|
|
8
9
|
while (currentElement && level < CLICK_THROUGH_CLOSEST_MAX_LEVELS) {
|
|
9
10
|
href = currentElement.getAttribute('href');
|
|
10
|
-
if (href &&
|
|
11
|
+
if (href && ((resultCoreUrl && href.includes(resultCoreUrl)) || (resultDisplayUrl && href.includes(resultDisplayUrl)))) {
|
|
11
12
|
return true;
|
|
12
13
|
}
|
|
13
14
|
currentElement = currentElement.parentElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchspring/snap-controller",
|
|
3
|
-
"version": "0.66.
|
|
3
|
+
"version": "0.66.1",
|
|
4
4
|
"description": "Snap Controllers",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
"test:watch": "jest --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@searchspring/snap-toolbox": "^0.66.
|
|
23
|
+
"@searchspring/snap-toolbox": "^0.66.1",
|
|
24
24
|
"css.escape": "1.5.1",
|
|
25
25
|
"deepmerge": "4.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@searchspring/snap-client": "^0.66.
|
|
29
|
-
"@searchspring/snap-event-manager": "^0.66.
|
|
30
|
-
"@searchspring/snap-logger": "^0.66.
|
|
31
|
-
"@searchspring/snap-profiler": "^0.66.
|
|
32
|
-
"@searchspring/snap-store-mobx": "^0.66.
|
|
33
|
-
"@searchspring/snap-tracker": "^0.66.
|
|
34
|
-
"@searchspring/snap-url-manager": "^0.66.
|
|
28
|
+
"@searchspring/snap-client": "^0.66.1",
|
|
29
|
+
"@searchspring/snap-event-manager": "^0.66.1",
|
|
30
|
+
"@searchspring/snap-logger": "^0.66.1",
|
|
31
|
+
"@searchspring/snap-profiler": "^0.66.1",
|
|
32
|
+
"@searchspring/snap-store-mobx": "^0.66.1",
|
|
33
|
+
"@searchspring/snap-tracker": "^0.66.1",
|
|
34
|
+
"@searchspring/snap-url-manager": "^0.66.1"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"files": [
|
|
38
38
|
"dist/**/*"
|
|
39
39
|
],
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a9d6de5e5e144ca964e8a19d9dba5c63d9d94db6"
|
|
41
41
|
}
|