UNPKG

2.11 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var development_env_1 = tslib_1.__importDefault(require("./commons/environment/development.env"));
5var production_env_1 = tslib_1.__importDefault(require("./commons/environment/production.env"));
6var default_config_1 = tslib_1.__importDefault(require("./loader/default.config"));
7/**
8 * Main RecSys integration module.
9 *
10 * @export
11 * @abstract
12 * @class RecSys
13 */
14var RecSys = /** @class */ (function () {
15 function RecSys() {
16 }
17 /**
18 * Initialization method. This needs to be run before using any of this
19 * modules features.
20 *
21 * @static
22 * @param {Configuration} config Store configuration.
23 * @memberof RecSys
24 */
25 RecSys.init = function (config) {
26 window._RecSys = window._RecSys || {};
27 window._RecSys.Bundle = window._RecSys.Bundle; // eslint-disable-line
28 var properties = this.env(config) === "production" ? production_env_1.default : development_env_1.default;
29 window._RecSys.Bundle = {
30 Properties: properties(config.store.slug),
31 Configuration: this.mergeConfig(config),
32 Version: "__version__",
33 Environment: this.env(config),
34 };
35 };
36 /**
37 * Merge current configuration provided by the store with
38 * the default configuration, filling in the blanks.
39 *
40 * @static
41 * @param {Configuration} config Current configuration
42 * @return {Configuration}
43 * @memberof RecSys
44 */
45 RecSys.mergeConfig = function (config) {
46 return Object.assign(default_config_1.default, config);
47 };
48 /**
49 * Environment running right now.
50 * NOTE: This comes from `recsys build`.
51 *
52 * @private
53 * @static
54 * @param {Configuration} config Configuration
55 * @return {string} Current environment
56 * @memberof RecSys
57 */
58 RecSys.env = function (config) {
59 return config.environment || "__environment__";
60 };
61 return RecSys;
62}());
63exports.default = RecSys;
64//# sourceMappingURL=index.js.map
\No newline at end of file