@athoscommerce/snap-controller 1.0.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/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/cjs/Abstract/AbstractController.d.ts +42 -0
- package/dist/cjs/Abstract/AbstractController.d.ts.map +1 -0
- package/dist/cjs/Abstract/AbstractController.js +305 -0
- package/dist/cjs/Autocomplete/AutocompleteController.d.ts +59 -0
- package/dist/cjs/Autocomplete/AutocompleteController.d.ts.map +1 -0
- package/dist/cjs/Autocomplete/AutocompleteController.js +1091 -0
- package/dist/cjs/Finder/FinderController.d.ts +15 -0
- package/dist/cjs/Finder/FinderController.d.ts.map +1 -0
- package/dist/cjs/Finder/FinderController.js +336 -0
- package/dist/cjs/Recommendation/RecommendationController.d.ts +27 -0
- package/dist/cjs/Recommendation/RecommendationController.d.ts.map +1 -0
- package/dist/cjs/Recommendation/RecommendationController.js +447 -0
- package/dist/cjs/Search/SearchController.d.ts +41 -0
- package/dist/cjs/Search/SearchController.d.ts.map +1 -0
- package/dist/cjs/Search/SearchController.js +993 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/types.d.ts +87 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/utils/getParams.d.ts +3 -0
- package/dist/cjs/utils/getParams.d.ts.map +1 -0
- package/dist/cjs/utils/getParams.js +70 -0
- package/dist/cjs/utils/isClickWithinBannerLink.d.ts +2 -0
- package/dist/cjs/utils/isClickWithinBannerLink.d.ts.map +1 -0
- package/dist/cjs/utils/isClickWithinBannerLink.js +21 -0
- package/dist/cjs/utils/isClickWithinProductLink.d.ts +5 -0
- package/dist/cjs/utils/isClickWithinProductLink.d.ts.map +1 -0
- package/dist/cjs/utils/isClickWithinProductLink.js +25 -0
- package/dist/esm/Abstract/AbstractController.d.ts +42 -0
- package/dist/esm/Abstract/AbstractController.d.ts.map +1 -0
- package/dist/esm/Abstract/AbstractController.js +208 -0
- package/dist/esm/Autocomplete/AutocompleteController.d.ts +59 -0
- package/dist/esm/Autocomplete/AutocompleteController.d.ts.map +1 -0
- package/dist/esm/Autocomplete/AutocompleteController.js +882 -0
- package/dist/esm/Finder/FinderController.d.ts +15 -0
- package/dist/esm/Finder/FinderController.d.ts.map +1 -0
- package/dist/esm/Finder/FinderController.js +218 -0
- package/dist/esm/Recommendation/RecommendationController.d.ts +27 -0
- package/dist/esm/Recommendation/RecommendationController.d.ts.map +1 -0
- package/dist/esm/Recommendation/RecommendationController.js +342 -0
- package/dist/esm/Search/SearchController.d.ts +41 -0
- package/dist/esm/Search/SearchController.d.ts.map +1 -0
- package/dist/esm/Search/SearchController.js +795 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/types.d.ts +87 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +7 -0
- package/dist/esm/utils/getParams.d.ts +3 -0
- package/dist/esm/utils/getParams.d.ts.map +1 -0
- package/dist/esm/utils/getParams.js +67 -0
- package/dist/esm/utils/isClickWithinBannerLink.d.ts +2 -0
- package/dist/esm/utils/isClickWithinBannerLink.d.ts.map +1 -0
- package/dist/esm/utils/isClickWithinBannerLink.js +17 -0
- package/dist/esm/utils/isClickWithinProductLink.d.ts +5 -0
- package/dist/esm/utils/isClickWithinProductLink.d.ts.map +1 -0
- package/dist/esm/utils/isClickWithinProductLink.js +19 -0
- package/package.json +41 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FinderController } from './Finder/FinderController';
|
|
2
|
+
export { SearchController } from './Search/SearchController';
|
|
3
|
+
export { AutocompleteController, INPUT_DELAY } from './Autocomplete/AutocompleteController';
|
|
4
|
+
export { RecommendationController } from './Recommendation/RecommendationController';
|
|
5
|
+
export { AbstractController } from './Abstract/AbstractController';
|
|
6
|
+
export * from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AbstractController = exports.RecommendationController = exports.INPUT_DELAY = exports.AutocompleteController = exports.SearchController = exports.FinderController = void 0;
|
|
18
|
+
var FinderController_1 = require("./Finder/FinderController");
|
|
19
|
+
Object.defineProperty(exports, "FinderController", { enumerable: true, get: function () { return FinderController_1.FinderController; } });
|
|
20
|
+
var SearchController_1 = require("./Search/SearchController");
|
|
21
|
+
Object.defineProperty(exports, "SearchController", { enumerable: true, get: function () { return SearchController_1.SearchController; } });
|
|
22
|
+
var AutocompleteController_1 = require("./Autocomplete/AutocompleteController");
|
|
23
|
+
Object.defineProperty(exports, "AutocompleteController", { enumerable: true, get: function () { return AutocompleteController_1.AutocompleteController; } });
|
|
24
|
+
Object.defineProperty(exports, "INPUT_DELAY", { enumerable: true, get: function () { return AutocompleteController_1.INPUT_DELAY; } });
|
|
25
|
+
var RecommendationController_1 = require("./Recommendation/RecommendationController");
|
|
26
|
+
Object.defineProperty(exports, "RecommendationController", { enumerable: true, get: function () { return RecommendationController_1.RecommendationController; } });
|
|
27
|
+
var AbstractController_1 = require("./Abstract/AbstractController");
|
|
28
|
+
Object.defineProperty(exports, "AbstractController", { enumerable: true, get: function () { return AbstractController_1.AbstractController; } });
|
|
29
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { AbstractController, AutocompleteController, SearchController, FinderController, RecommendationController } from './index';
|
|
2
|
+
import type { EventManager, Middleware } from '@athoscommerce/snap-event-manager';
|
|
3
|
+
import type { Client } from '@athoscommerce/snap-client';
|
|
4
|
+
import type { SearchStore, AutocompleteStore, FinderStore, RecommendationStore, StoreConfig, SearchStoreConfig, FinderStoreConfig, AutocompleteStoreConfig, RecommendationStoreConfig } from '@athoscommerce/snap-store-mobx';
|
|
5
|
+
import type { Tracker, ProductViewEvent } from '@athoscommerce/snap-tracker';
|
|
6
|
+
import type { Profiler } from '@athoscommerce/snap-profiler';
|
|
7
|
+
import type { UrlManager } from '@athoscommerce/snap-url-manager';
|
|
8
|
+
import type { Logger } from '@athoscommerce/snap-logger';
|
|
9
|
+
import type { AutocompleteRequestModel, SearchRequestModel } from '@athoscommerce/snapi-types';
|
|
10
|
+
export type PluginFunction = (cntrlr: AbstractController, ...args: any) => Promise<void> | void;
|
|
11
|
+
export type PluginGrouping = [func: PluginFunction, ...args: unknown[]];
|
|
12
|
+
export type BeforeSearchObj = {
|
|
13
|
+
controller: AbstractController;
|
|
14
|
+
request: any;
|
|
15
|
+
};
|
|
16
|
+
export type SearchAfterSearchObj = {
|
|
17
|
+
controller: SearchController;
|
|
18
|
+
response: any;
|
|
19
|
+
request: SearchRequestModel;
|
|
20
|
+
};
|
|
21
|
+
export type AutocompleteAfterSearchObj = {
|
|
22
|
+
controller: AutocompleteController;
|
|
23
|
+
response: any;
|
|
24
|
+
request: AutocompleteRequestModel;
|
|
25
|
+
};
|
|
26
|
+
export type FinderAfterSearchObj = {
|
|
27
|
+
controller: FinderController;
|
|
28
|
+
response: any;
|
|
29
|
+
request: SearchRequestModel;
|
|
30
|
+
};
|
|
31
|
+
export type AfterSearchObj = SearchAfterSearchObj | AutocompleteAfterSearchObj | FinderAfterSearchObj;
|
|
32
|
+
export type AfterStoreObj = {
|
|
33
|
+
controller: AbstractController;
|
|
34
|
+
request: any;
|
|
35
|
+
response: any;
|
|
36
|
+
};
|
|
37
|
+
export type RestorePositionObj = {
|
|
38
|
+
controller: AbstractController;
|
|
39
|
+
element?: ElementPositionObj;
|
|
40
|
+
};
|
|
41
|
+
export type ElementPositionObj = {
|
|
42
|
+
href?: string;
|
|
43
|
+
selector?: string;
|
|
44
|
+
domRect?: DOMRect;
|
|
45
|
+
};
|
|
46
|
+
export declare enum ControllerTypes {
|
|
47
|
+
search = "search",
|
|
48
|
+
autocomplete = "autocomplete",
|
|
49
|
+
finder = "finder",
|
|
50
|
+
recommendation = "recommendation"
|
|
51
|
+
}
|
|
52
|
+
export type Controllers = SearchController | AutocompleteController | FinderController | RecommendationController;
|
|
53
|
+
export type ControllerServices = {
|
|
54
|
+
client: Client;
|
|
55
|
+
store: SearchStore | AutocompleteStore | FinderStore | RecommendationStore;
|
|
56
|
+
urlManager: UrlManager;
|
|
57
|
+
eventManager: EventManager;
|
|
58
|
+
profiler: Profiler;
|
|
59
|
+
logger: Logger;
|
|
60
|
+
tracker: Tracker;
|
|
61
|
+
};
|
|
62
|
+
export type Attachments = {
|
|
63
|
+
middleware?: {
|
|
64
|
+
[eventName: string]: Middleware<any> | Middleware<any>[];
|
|
65
|
+
};
|
|
66
|
+
plugins?: PluginGrouping[];
|
|
67
|
+
[any: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
export type ContextVariables = {
|
|
70
|
+
shopper?: {
|
|
71
|
+
id: string;
|
|
72
|
+
cart?: ProductViewEvent[];
|
|
73
|
+
[variable: string]: any;
|
|
74
|
+
};
|
|
75
|
+
page?: PageContextVariable;
|
|
76
|
+
[variable: string]: any;
|
|
77
|
+
};
|
|
78
|
+
export type PageContextVariable = {
|
|
79
|
+
type: 'search' | 'category';
|
|
80
|
+
};
|
|
81
|
+
export type ControllerConfig = StoreConfig & Attachments;
|
|
82
|
+
export type SearchControllerConfig = ControllerConfig & SearchStoreConfig;
|
|
83
|
+
export type FinderControllerConfig = ControllerConfig & FinderStoreConfig;
|
|
84
|
+
export type AutocompleteControllerConfig = ControllerConfig & AutocompleteStoreConfig;
|
|
85
|
+
export type RecommendationControllerConfig = ControllerConfig & RecommendationStoreConfig;
|
|
86
|
+
export type ControllerConfigs = SearchControllerConfig | AutocompleteControllerConfig | FinderControllerConfig | RecommendationControllerConfig;
|
|
87
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACxI,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACX,WAAW,EAC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,MAAM,MAAM,gBAAgB,GAAG;IAC9B,OAAO,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;KACxB,CAAC;IACF,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,CAAC;AAGzD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE1E,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE1E,MAAM,MAAM,4BAA4B,GAAG,gBAAgB,GAAG,uBAAuB,CAAC;AAEtF,MAAM,MAAM,8BAA8B,GAAG,gBAAgB,GAAG,yBAAyB,CAAC;AAE1F,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,GAAG,4BAA4B,GAAG,sBAAsB,GAAG,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerTypes = void 0;
|
|
4
|
+
var ControllerTypes;
|
|
5
|
+
(function (ControllerTypes) {
|
|
6
|
+
ControllerTypes["search"] = "search";
|
|
7
|
+
ControllerTypes["autocomplete"] = "autocomplete";
|
|
8
|
+
ControllerTypes["finder"] = "finder";
|
|
9
|
+
ControllerTypes["recommendation"] = "recommendation";
|
|
10
|
+
})(ControllerTypes || (exports.ControllerTypes = ControllerTypes = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getParams.d.ts","sourceRoot":"","sources":["../../../src/utils/getParams.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAgF7E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSearchParams = getSearchParams;
|
|
4
|
+
function getSearchParams(state) {
|
|
5
|
+
var params = {};
|
|
6
|
+
if (state.tag) {
|
|
7
|
+
params.merchandising = params.merchandising || {};
|
|
8
|
+
params.merchandising.landingPage = state.tag;
|
|
9
|
+
}
|
|
10
|
+
if (state.query) {
|
|
11
|
+
params.search = params.search || {};
|
|
12
|
+
params.search.query = params.search.query || {};
|
|
13
|
+
params.search.query.string = state.query;
|
|
14
|
+
}
|
|
15
|
+
if (state.rq) {
|
|
16
|
+
params.search = params.search || {};
|
|
17
|
+
params.search.subQuery = state.rq;
|
|
18
|
+
}
|
|
19
|
+
if (state.fallbackQuery) {
|
|
20
|
+
params.search = params.search || {};
|
|
21
|
+
params.search.fallbackQuery = state.fallbackQuery;
|
|
22
|
+
}
|
|
23
|
+
if (state.page) {
|
|
24
|
+
params.pagination = params.pagination || {};
|
|
25
|
+
params.pagination.page = state.page;
|
|
26
|
+
}
|
|
27
|
+
if (state.pageSize) {
|
|
28
|
+
params.pagination = params.pagination || {};
|
|
29
|
+
params.pagination.pageSize = state.pageSize;
|
|
30
|
+
}
|
|
31
|
+
if (state.sort) {
|
|
32
|
+
params.sorts = params.sorts || [];
|
|
33
|
+
var sorts = Array.isArray(state.sort) ? state.sort : [state.sort];
|
|
34
|
+
var sort = sorts[0];
|
|
35
|
+
if (sort && sort.field && sort.direction) {
|
|
36
|
+
params.sorts.push({
|
|
37
|
+
field: sort.field,
|
|
38
|
+
direction: sort.direction,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (state.filter) {
|
|
43
|
+
params.filters = params.filters || [];
|
|
44
|
+
Object.keys(state.filter).forEach(function (field) {
|
|
45
|
+
if (typeof field != 'string') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var filter = state.filter[field];
|
|
49
|
+
// ensure values are an array
|
|
50
|
+
var values = Array.isArray(filter) ? filter : [filter];
|
|
51
|
+
values.forEach(function (value) {
|
|
52
|
+
if (typeof value != 'object') {
|
|
53
|
+
params.filters.push({
|
|
54
|
+
type: 'value',
|
|
55
|
+
field: field,
|
|
56
|
+
value: value,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (typeof value.low != 'undefined' && typeof value.high != 'undefined') {
|
|
60
|
+
params.filters.push({
|
|
61
|
+
type: 'range',
|
|
62
|
+
field: field,
|
|
63
|
+
value: value,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return params;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isClickWithinBannerLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinBannerLink.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,MAAO,UAAU,KAAG,OAcvD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClickWithinBannerLink = void 0;
|
|
4
|
+
var isClickWithinProductLink_1 = require("./isClickWithinProductLink");
|
|
5
|
+
var TRACKING_ATTRIBUTE = 'sstracking';
|
|
6
|
+
var isClickWithinBannerLink = function (e) {
|
|
7
|
+
var currentElement = e.target;
|
|
8
|
+
var href = null;
|
|
9
|
+
var level = 0;
|
|
10
|
+
while (currentElement && (level < isClickWithinProductLink_1.CLICK_THROUGH_CLOSEST_MAX_LEVELS || !currentElement.getAttribute(TRACKING_ATTRIBUTE))) {
|
|
11
|
+
href = currentElement.getAttribute('href');
|
|
12
|
+
var isAnchor = currentElement.tagName.toLowerCase() === 'a';
|
|
13
|
+
if (href && isAnchor) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
currentElement = currentElement.parentElement;
|
|
17
|
+
level++;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
exports.isClickWithinBannerLink = isClickWithinBannerLink;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Product } from '@athoscommerce/snap-store-mobx';
|
|
2
|
+
export declare const CLICK_DUPLICATION_TIMEOUT = 300;
|
|
3
|
+
export declare const CLICK_THROUGH_CLOSEST_MAX_LEVELS = 12;
|
|
4
|
+
export declare const isClickWithinProductLink: (e: MouseEvent, result: Product) => boolean;
|
|
5
|
+
//# sourceMappingURL=isClickWithinProductLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isClickWithinProductLink.d.ts","sourceRoot":"","sources":["../../../src/utils/isClickWithinProductLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAE9D,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,MAAO,UAAU,UAAU,OAAO,KAAG,OAoBzE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClickWithinProductLink = exports.CLICK_THROUGH_CLOSEST_MAX_LEVELS = exports.CLICK_DUPLICATION_TIMEOUT = void 0;
|
|
4
|
+
exports.CLICK_DUPLICATION_TIMEOUT = 300;
|
|
5
|
+
exports.CLICK_THROUGH_CLOSEST_MAX_LEVELS = 12;
|
|
6
|
+
var isClickWithinProductLink = function (e, result) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
var resultDisplayUrl = ((_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) || '';
|
|
9
|
+
var resultCoreUrl = ((_c = result === null || result === void 0 ? void 0 : result.mappings.core) === null || _c === void 0 ? void 0 : _c.url) || '';
|
|
10
|
+
// Get the composed path to handle shadow DOM elements
|
|
11
|
+
var path = e.composedPath ? e.composedPath() : [e.target];
|
|
12
|
+
// Check up to CLICK_THROUGH_CLOSEST_MAX_LEVELS elements in the path
|
|
13
|
+
var elementsToCheck = path.slice(0, exports.CLICK_THROUGH_CLOSEST_MAX_LEVELS);
|
|
14
|
+
for (var _i = 0, elementsToCheck_1 = elementsToCheck; _i < elementsToCheck_1.length; _i++) {
|
|
15
|
+
var element = elementsToCheck_1[_i];
|
|
16
|
+
if (element instanceof Element) {
|
|
17
|
+
var href = element.getAttribute('href');
|
|
18
|
+
if (href && ((resultCoreUrl && href.includes(resultCoreUrl)) || (resultDisplayUrl && href.includes(resultDisplayUrl)))) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
exports.isClickWithinProductLink = isClickWithinProductLink;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DomTargeter } from '@athoscommerce/snap-toolbox';
|
|
2
|
+
import type { Client } from '@athoscommerce/snap-client';
|
|
3
|
+
import type { AbstractStore } from '@athoscommerce/snap-store-mobx';
|
|
4
|
+
import type { UrlManager } from '@athoscommerce/snap-url-manager';
|
|
5
|
+
import type { EventManager, Middleware } from '@athoscommerce/snap-event-manager';
|
|
6
|
+
import type { Profiler } from '@athoscommerce/snap-profiler';
|
|
7
|
+
import type { Logger } from '@athoscommerce/snap-logger';
|
|
8
|
+
import type { Tracker } from '@athoscommerce/snap-tracker';
|
|
9
|
+
import type { Target, OnTarget } from '@athoscommerce/snap-toolbox';
|
|
10
|
+
import type { ControllerServices, ControllerConfig, Attachments, ContextVariables, PluginFunction } from '../types';
|
|
11
|
+
export declare abstract class AbstractController {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
config: ControllerConfig;
|
|
15
|
+
client: Client;
|
|
16
|
+
store: AbstractStore;
|
|
17
|
+
urlManager: UrlManager;
|
|
18
|
+
eventManager: EventManager;
|
|
19
|
+
profiler: Profiler;
|
|
20
|
+
log: Logger;
|
|
21
|
+
tracker: Tracker;
|
|
22
|
+
context: ContextVariables;
|
|
23
|
+
targeters: {
|
|
24
|
+
[key: string]: DomTargeter;
|
|
25
|
+
};
|
|
26
|
+
protected _initialized: boolean;
|
|
27
|
+
get initialized(): boolean;
|
|
28
|
+
handleError: (err: unknown, details?: {
|
|
29
|
+
[any: string]: unknown;
|
|
30
|
+
}) => void;
|
|
31
|
+
constructor(config: ControllerConfig, { client, store, urlManager, eventManager, profiler, logger, tracker }: ControllerServices, context?: ContextVariables);
|
|
32
|
+
createTargeter(target: Target, onTarget: OnTarget, document?: Document): DomTargeter | undefined;
|
|
33
|
+
addTargeter(target: DomTargeter): DomTargeter | undefined;
|
|
34
|
+
init(): Promise<void>;
|
|
35
|
+
retarget(): void;
|
|
36
|
+
abstract search(): Promise<void>;
|
|
37
|
+
plugin(func: PluginFunction, ...args: unknown[]): Promise<void>;
|
|
38
|
+
on<T>(event: string, ...func: Middleware<T>[]): void;
|
|
39
|
+
use(attachments: Attachments): void;
|
|
40
|
+
setConfig(newConfig: any): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=AbstractController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractController.d.ts","sourceRoot":"","sources":["../../../src/Abstract/AbstractController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B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E,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,kBAAkB,EAC1F,OAAO,GAAE,gBAAqB;IA2DxB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,SAAS;IAIhG,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,SAAS;IASnD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD3B,QAAQ,IAAI,IAAI;aAMP,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAE1B,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAIpD,GAAG,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAqC1C,SAAS,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI;CAI/B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { DomTargeter } from '@athoscommerce/snap-toolbox';
|
|
2
|
+
export class AbstractController {
|
|
3
|
+
get initialized() {
|
|
4
|
+
return this._initialized;
|
|
5
|
+
}
|
|
6
|
+
constructor(config, { client, store, urlManager, eventManager, profiler, logger, tracker }, context = {}) {
|
|
7
|
+
this.type = 'abstract';
|
|
8
|
+
this.targeters = {};
|
|
9
|
+
this._initialized = false;
|
|
10
|
+
this.handleError = (err, details) => {
|
|
11
|
+
let event;
|
|
12
|
+
if (err instanceof ErrorEvent) {
|
|
13
|
+
event = err;
|
|
14
|
+
}
|
|
15
|
+
else if (err instanceof Error) {
|
|
16
|
+
event = new ErrorEvent('error', {
|
|
17
|
+
error: err,
|
|
18
|
+
message: err.message,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else if (typeof err === 'string' || typeof err == 'number') {
|
|
22
|
+
event = new ErrorEvent('error', {
|
|
23
|
+
error: new Error(err.toString()),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else if (typeof err === 'object' && Object.keys(err).length) {
|
|
27
|
+
try {
|
|
28
|
+
event = new ErrorEvent('error', {
|
|
29
|
+
error: new Error(JSON.stringify(err)),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) { }
|
|
33
|
+
}
|
|
34
|
+
if (event) {
|
|
35
|
+
const { filename, colno, lineno, error: { stack }, message, timeStamp, } = event;
|
|
36
|
+
const beaconPayload = {
|
|
37
|
+
filename,
|
|
38
|
+
stack,
|
|
39
|
+
message,
|
|
40
|
+
colno,
|
|
41
|
+
lineno,
|
|
42
|
+
errortimestamp: timeStamp,
|
|
43
|
+
details,
|
|
44
|
+
context: {
|
|
45
|
+
controller: {
|
|
46
|
+
id: this.id,
|
|
47
|
+
type: this.type,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
this.tracker.track.error(beaconPayload);
|
|
52
|
+
this.eventManager.fire('error', { controller: this, error: err });
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
if (typeof config != 'object' || typeof config.id != 'string' || !config.id.match(/^[a-zA-Z0-9_-]*$/)) {
|
|
56
|
+
throw new Error(`Invalid config passed to controller. The "id" attribute must be an alphanumeric string.`);
|
|
57
|
+
}
|
|
58
|
+
if (typeof client != 'object' || typeof client.search != 'function') {
|
|
59
|
+
throw new Error(`Invalid service 'client' passed to controller. Missing "search" function.`);
|
|
60
|
+
}
|
|
61
|
+
if (typeof store != 'object' || typeof store.update != 'function') {
|
|
62
|
+
throw new Error(`Invalid service 'store' passed to controller. Missing "update" function.`);
|
|
63
|
+
}
|
|
64
|
+
if (typeof urlManager != 'object' || typeof urlManager.subscribe != 'function') {
|
|
65
|
+
throw new Error(`Invalid service 'urlManager' passed to controller. Missing "subscribe" function.`);
|
|
66
|
+
}
|
|
67
|
+
if (typeof eventManager != 'object' || typeof eventManager.on != 'function') {
|
|
68
|
+
throw new Error(`Invalid service 'eventManager' passed to controller. Missing "on" function.`);
|
|
69
|
+
}
|
|
70
|
+
if (typeof eventManager != 'object' || typeof eventManager.fire != 'function') {
|
|
71
|
+
throw new Error(`Invalid service 'eventManager' passed to controller. Missing "fire" function.`);
|
|
72
|
+
}
|
|
73
|
+
if (typeof profiler != 'object' || typeof profiler.setNamespace != 'function') {
|
|
74
|
+
throw new Error(`Invalid service 'profiler' passed to controller. Missing "setNamespace" function.`);
|
|
75
|
+
}
|
|
76
|
+
if (typeof profiler != 'object' || typeof profiler.create != 'function') {
|
|
77
|
+
throw new Error(`Invalid service 'profiler' passed to controller. Missing "create" function.`);
|
|
78
|
+
}
|
|
79
|
+
if (typeof logger != 'object' || typeof logger.dev != 'function') {
|
|
80
|
+
throw new Error(`Invalid service 'logger' passed to controller. Missing "dev" function.`);
|
|
81
|
+
}
|
|
82
|
+
if (typeof tracker != 'object' || typeof tracker.track != 'object') {
|
|
83
|
+
throw new Error(`Invalid service 'tracker' passed to controller. Missing "track" object.`);
|
|
84
|
+
}
|
|
85
|
+
this.id = config.id;
|
|
86
|
+
this.config = config;
|
|
87
|
+
this.client = client;
|
|
88
|
+
this.store = store;
|
|
89
|
+
this.urlManager = urlManager;
|
|
90
|
+
this.eventManager = eventManager;
|
|
91
|
+
this.profiler = profiler;
|
|
92
|
+
this.log = logger;
|
|
93
|
+
this.tracker = tracker;
|
|
94
|
+
this.context = context;
|
|
95
|
+
// configure the logger
|
|
96
|
+
this.log.setNamespace(this.config.id);
|
|
97
|
+
// set namespaces
|
|
98
|
+
this.profiler.setNamespace(this.config.id);
|
|
99
|
+
}
|
|
100
|
+
createTargeter(target, onTarget, document) {
|
|
101
|
+
return this.addTargeter(new DomTargeter([target], onTarget, document));
|
|
102
|
+
}
|
|
103
|
+
addTargeter(target) {
|
|
104
|
+
const firstTarget = target.getTargets()[0];
|
|
105
|
+
const targetName = firstTarget?.name ?? firstTarget?.selector;
|
|
106
|
+
if (targetName && !this.targeters[targetName]) {
|
|
107
|
+
this.targeters[targetName] = target;
|
|
108
|
+
return target;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async init() {
|
|
112
|
+
if (this._initialized) {
|
|
113
|
+
this.log.warn(`'init' middleware recalled`);
|
|
114
|
+
}
|
|
115
|
+
const initProfile = this.profiler.create({ type: 'event', name: 'init', context: this.config }).start();
|
|
116
|
+
try {
|
|
117
|
+
try {
|
|
118
|
+
await this.eventManager.fire('init', {
|
|
119
|
+
controller: this,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (err?.message == 'cancelled') {
|
|
124
|
+
this.log.warn(`'init' middleware cancelled`);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.log.error(`error in 'init' middleware`);
|
|
128
|
+
throw err;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
if (err) {
|
|
134
|
+
console.error(err);
|
|
135
|
+
this.handleError(err);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!this._initialized) {
|
|
139
|
+
// subscribe to urlManager changes
|
|
140
|
+
this.urlManager.subscribe((prev, next) => {
|
|
141
|
+
try {
|
|
142
|
+
const prevString = JSON.stringify(prev);
|
|
143
|
+
const nextString = JSON.stringify(next);
|
|
144
|
+
if (prevString !== nextString) {
|
|
145
|
+
this.search();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
this.log.error('URL state is invalid', err);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
this._initialized = true;
|
|
153
|
+
}
|
|
154
|
+
initProfile.stop();
|
|
155
|
+
this.log.profile(initProfile);
|
|
156
|
+
}
|
|
157
|
+
retarget() {
|
|
158
|
+
Object.keys(this.targeters).forEach((target) => {
|
|
159
|
+
this.targeters[target].retarget();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async plugin(func, ...args) {
|
|
163
|
+
await func(this, ...args);
|
|
164
|
+
}
|
|
165
|
+
on(event, ...func) {
|
|
166
|
+
this.eventManager.on(event, ...func);
|
|
167
|
+
}
|
|
168
|
+
use(attachments) {
|
|
169
|
+
// attach plugins
|
|
170
|
+
if (attachments?.plugins) {
|
|
171
|
+
try {
|
|
172
|
+
if (!Array.isArray(attachments?.plugins)) {
|
|
173
|
+
throw 'invalid format';
|
|
174
|
+
}
|
|
175
|
+
attachments?.plugins.forEach((plugin) => {
|
|
176
|
+
if (!Array.isArray(plugin)) {
|
|
177
|
+
throw 'invalid format';
|
|
178
|
+
}
|
|
179
|
+
const [func, ...args] = plugin;
|
|
180
|
+
this.plugin(func, ...args);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
this.log.warn('plugins not attached - use format [func, ...args?][]');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// attach event middleware
|
|
188
|
+
if (attachments?.middleware) {
|
|
189
|
+
Object.keys(attachments.middleware).forEach((eventName) => {
|
|
190
|
+
const eventMiddleware = attachments.middleware[eventName];
|
|
191
|
+
let middlewareArray;
|
|
192
|
+
if (Array.isArray(eventMiddleware)) {
|
|
193
|
+
middlewareArray = eventMiddleware;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
middlewareArray = [eventMiddleware];
|
|
197
|
+
}
|
|
198
|
+
middlewareArray.forEach((middleware) => {
|
|
199
|
+
this.on(eventName, middleware);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
setConfig(newConfig) {
|
|
205
|
+
this.config = newConfig;
|
|
206
|
+
this.store.setConfig(newConfig);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { StorageStore, Product, Banner, MerchandisingContentBanner } from '@athoscommerce/snap-store-mobx';
|
|
2
|
+
import { AbstractController } from '../Abstract/AbstractController';
|
|
3
|
+
import { ControllerTypes } from '../types';
|
|
4
|
+
import { AutocompleteStore } from '@athoscommerce/snap-store-mobx';
|
|
5
|
+
import type { AutocompleteControllerConfig, ControllerServices, ContextVariables } from '../types';
|
|
6
|
+
import type { AutocompleteRequestModel } from '@athoscommerce/snapi-types';
|
|
7
|
+
export declare const INPUT_DELAY = 200;
|
|
8
|
+
type AutocompleteTrackMethods = {
|
|
9
|
+
banner: {
|
|
10
|
+
click: (e: MouseEvent, merchandisingBanner: MerchandisingContentBanner) => void;
|
|
11
|
+
clickThrough: (e: MouseEvent, merchandisingBanner: MerchandisingContentBanner) => void;
|
|
12
|
+
impression: (merchandisingBanner: MerchandisingContentBanner) => void;
|
|
13
|
+
};
|
|
14
|
+
product: {
|
|
15
|
+
clickThrough: (e: MouseEvent, result: Product | Banner) => void;
|
|
16
|
+
click: (e: MouseEvent, result: Product | Banner) => void;
|
|
17
|
+
impression: (result: Product | Banner) => void;
|
|
18
|
+
addToCart: (results: Product) => void;
|
|
19
|
+
};
|
|
20
|
+
redirect: ({ redirectURL, responseId }: {
|
|
21
|
+
redirectURL: string;
|
|
22
|
+
responseId: string;
|
|
23
|
+
}) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare class AutocompleteController extends AbstractController {
|
|
26
|
+
type: ControllerTypes;
|
|
27
|
+
store: AutocompleteStore;
|
|
28
|
+
config: AutocompleteControllerConfig;
|
|
29
|
+
storage: StorageStore;
|
|
30
|
+
private events;
|
|
31
|
+
constructor(config: AutocompleteControllerConfig, { client, store, urlManager, eventManager, profiler, logger, tracker }: ControllerServices, context?: ContextVariables);
|
|
32
|
+
track: AutocompleteTrackMethods;
|
|
33
|
+
get params(): AutocompleteRequestModel;
|
|
34
|
+
setFocused(inputElement?: HTMLInputElement): Promise<void>;
|
|
35
|
+
reset(): void;
|
|
36
|
+
handlers: {
|
|
37
|
+
input: {
|
|
38
|
+
enterKey: (e: KeyboardEvent) => Promise<boolean | undefined>;
|
|
39
|
+
escKey: (e: KeyboardEvent) => void;
|
|
40
|
+
focus: (e: FocusEvent) => void;
|
|
41
|
+
formSubmit: (e: React.FormEvent<HTMLInputElement>) => Promise<void>;
|
|
42
|
+
formElementChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
43
|
+
input: (e: Event) => void;
|
|
44
|
+
timeoutDelay: undefined | ReturnType<typeof setTimeout>;
|
|
45
|
+
};
|
|
46
|
+
document: {
|
|
47
|
+
click: (e: MouseEvent) => void;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
unbind(): void;
|
|
51
|
+
bind(): Promise<void>;
|
|
52
|
+
searchTrending: (options?: {
|
|
53
|
+
limit?: number;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
search: () => Promise<void>;
|
|
56
|
+
addToCart: (_products: Product[] | Product) => Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=AutocompleteController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutocompleteController.d.ts","sourceRoot":"","sources":["../../../src/Autocomplete/AutocompleteController.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAa,OAAO,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACtH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAA6C,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE9I,OAAO,KAAK,EAAE,wBAAwB,EAA4C,MAAM,4BAA4B,CAAC;AAkBrH,eAAO,MAAM,WAAW,MAAM,CAAC;AAiC/B,KAAK,wBAAwB,GAAG;IAC/B,MA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