@adobe/alloy 2.18.0 → 2.19.0-beta.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.
Files changed (75) hide show
  1. package/libEs5/components/DataCollector/index.js +4 -2
  2. package/libEs5/components/DataCollector/validateApplyResponse.js +6 -1
  3. package/libEs5/components/DataCollector/validateUserEventOptions.js +5 -1
  4. package/libEs5/components/Personalization/createApplyPropositions.js +38 -25
  5. package/libEs5/components/Personalization/createComponent.js +22 -14
  6. package/libEs5/components/Personalization/createFetchDataHandler.js +83 -18
  7. package/libEs5/components/Personalization/createOnClickHandler.js +2 -2
  8. package/libEs5/components/Personalization/createPendingNotificationsHandler.js +29 -0
  9. package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -2
  10. package/libEs5/components/Personalization/createViewCacheManager.js +60 -21
  11. package/libEs5/components/Personalization/createViewChangeHandler.js +25 -30
  12. package/libEs5/components/Personalization/dom-actions/action.js +5 -20
  13. package/{libEs6/components/Personalization/utils/composePersonalizationResultingObject.js → libEs5/components/Personalization/dom-actions/createPreprocess.js} +17 -13
  14. package/libEs5/components/Personalization/dom-actions/index.js +1 -9
  15. package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +2 -10
  16. package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
  17. package/libEs5/components/Personalization/handlers/createProcessDomAction.js +61 -0
  18. package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +43 -0
  19. package/libEs5/components/Personalization/handlers/createProcessPropositions.js +240 -0
  20. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +45 -0
  21. package/libEs5/components/Personalization/handlers/injectCreateProposition.js +124 -0
  22. package/libEs5/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +8 -4
  23. package/libEs5/components/Personalization/index.js +70 -53
  24. package/libEs5/components/Personalization/utils/createAsyncArray.js +42 -0
  25. package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +3 -2
  26. package/libEs5/constants/libraryVersion.js +1 -1
  27. package/libEs5/core/createEvent.js +31 -13
  28. package/libEs5/core/createEventManager.js +3 -2
  29. package/libEs5/{components/Personalization/utils/composePersonalizationResultingObject.js → utils/deduplicateArray.js} +16 -14
  30. package/libEs5/utils/index.js +8 -0
  31. package/libEs6/components/DataCollector/index.js +4 -2
  32. package/libEs6/components/DataCollector/validateApplyResponse.js +6 -1
  33. package/libEs6/components/DataCollector/validateUserEventOptions.js +5 -1
  34. package/libEs6/components/Personalization/createApplyPropositions.js +25 -24
  35. package/libEs6/components/Personalization/createComponent.js +23 -15
  36. package/libEs6/components/Personalization/createFetchDataHandler.js +65 -9
  37. package/libEs6/components/Personalization/createOnClickHandler.js +3 -3
  38. package/{libEs5/components/Personalization/dom-actions/click.js → libEs6/components/Personalization/createPendingNotificationsHandler.js} +11 -15
  39. package/libEs6/components/Personalization/createPersonalizationDetails.js +10 -2
  40. package/libEs6/components/Personalization/createViewCacheManager.js +55 -20
  41. package/libEs6/components/Personalization/createViewChangeHandler.js +25 -28
  42. package/libEs6/components/Personalization/dom-actions/action.js +4 -12
  43. package/libEs6/components/Personalization/dom-actions/{click.js → createPreprocess.js} +8 -11
  44. package/libEs6/components/Personalization/dom-actions/index.js +1 -2
  45. package/libEs6/components/Personalization/dom-actions/initDomActionsModules.js +3 -7
  46. package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +4 -0
  47. package/libEs6/components/Personalization/handlers/createProcessDomAction.js +53 -0
  48. package/libEs6/components/Personalization/handlers/createProcessHtmlContent.js +37 -0
  49. package/libEs6/components/Personalization/handlers/createProcessPropositions.js +202 -0
  50. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +39 -0
  51. package/libEs6/components/Personalization/handlers/injectCreateProposition.js +129 -0
  52. package/libEs6/components/Personalization/{dom-actions/clicks/index.js → handlers/processDefaultContent.js} +7 -3
  53. package/libEs6/components/Personalization/index.js +60 -40
  54. package/libEs6/components/Personalization/utils/createAsyncArray.js +37 -0
  55. package/libEs6/components/Personalization/validateApplyPropositionsOptions.js +4 -3
  56. package/libEs6/constants/libraryVersion.js +1 -1
  57. package/libEs6/core/createEvent.js +19 -3
  58. package/libEs6/core/createEventManager.js +3 -2
  59. package/libEs6/utils/deduplicateArray.js +26 -0
  60. package/libEs6/utils/index.js +1 -0
  61. package/package.json +2 -2
  62. package/libEs5/components/Personalization/createAutoRenderingHandler.js +0 -92
  63. package/libEs5/components/Personalization/createExecuteDecisions.js +0 -89
  64. package/libEs5/components/Personalization/createNonRenderingHandler.js +0 -66
  65. package/libEs5/components/Personalization/createOnResponseHandler.js +0 -73
  66. package/libEs5/components/Personalization/createRedirectHandler.js +0 -58
  67. package/libEs5/components/Personalization/dom-actions/executeActions.js +0 -75
  68. package/libEs5/components/Personalization/groupDecisions.js +0 -160
  69. package/libEs6/components/Personalization/createAutoRenderingHandler.js +0 -84
  70. package/libEs6/components/Personalization/createExecuteDecisions.js +0 -77
  71. package/libEs6/components/Personalization/createNonRenderingHandler.js +0 -56
  72. package/libEs6/components/Personalization/createOnResponseHandler.js +0 -68
  73. package/libEs6/components/Personalization/createRedirectHandler.js +0 -57
  74. package/libEs6/components/Personalization/dom-actions/executeActions.js +0 -66
  75. package/libEs6/components/Personalization/groupDecisions.js +0 -131
@@ -21,6 +21,7 @@ export { default as createLoggingCookieJar } from "./createLoggingCookieJar";
21
21
  export { default as createTaskQueue } from "./createTaskQueue";
22
22
  export { default as crc32 } from "./crc32";
23
23
  export { default as defer } from "./defer";
24
+ export { default as deduplicateArray } from "./deduplicateArray";
24
25
  export { default as deepAssign } from "./deepAssign";
25
26
  export { default as endsWith } from "./endsWith";
26
27
  export { default as find } from "./find";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.18.0",
3
+ "version": "2.19.0-beta.0",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -66,7 +66,7 @@
66
66
  "uuid": "^3.3.2"
67
67
  },
68
68
  "devDependencies": {
69
- "@adobe/alloy": "^2.18.0-beta.3",
69
+ "@adobe/alloy": "^2.18.0",
70
70
  "@babel/cli": "^7.12.8",
71
71
  "@babel/core": "^7.2.2",
72
72
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _addRenderAttemptedToDecisions = require("./utils/addRenderAttemptedToDecisions");
6
-
7
- var _isNonEmptyArray = require("../../utils/isNonEmptyArray");
8
-
9
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
-
11
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
-
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
-
17
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
-
19
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
-
21
- var getPropositions = function getPropositions(_ref) {
22
- var viewCache = _ref.viewCache,
23
- viewName = _ref.viewName,
24
- pageWideScopeDecisions = _ref.pageWideScopeDecisions;
25
-
26
- if (!viewName) {
27
- return {
28
- pageWideScopeDecisions: pageWideScopeDecisions,
29
- viewPropositions: []
30
- };
31
- }
32
-
33
- return viewCache.getView(viewName).then(function (viewPropositions) {
34
- return {
35
- pageWideScopeDecisions: pageWideScopeDecisions,
36
- viewPropositions: viewPropositions
37
- };
38
- });
39
- };
40
-
41
- var _default = function _default(_ref2) {
42
- var viewCache = _ref2.viewCache,
43
- executeDecisions = _ref2.executeDecisions,
44
- showContainers = _ref2.showContainers,
45
- collect = _ref2.collect;
46
- return function (_ref3) {
47
- var viewName = _ref3.viewName,
48
- pageWideScopeDecisions = _ref3.pageWideScopeDecisions,
49
- nonAutoRenderableDecisions = _ref3.nonAutoRenderableDecisions;
50
- return Promise.resolve(pageWideScopeDecisions).then(function (propositions) {
51
- return getPropositions({
52
- viewCache: viewCache,
53
- viewName: viewName,
54
- executeDecisions: executeDecisions,
55
- pageWideScopeDecisions: propositions
56
- });
57
- }).then(function (propositions) {
58
- executeDecisions(propositions.pageWideScopeDecisions).then(function (decisionsMeta) {
59
- if ((0, _isNonEmptyArray.default)(decisionsMeta)) {
60
- collect({
61
- decisionsMeta: decisionsMeta
62
- });
63
- }
64
- });
65
-
66
- if (viewName) {
67
- executeDecisions(propositions.viewPropositions).then(function (decisionsMeta) {
68
- collect({
69
- decisionsMeta: decisionsMeta,
70
- viewName: viewName
71
- });
72
- });
73
- }
74
-
75
- showContainers();
76
- return [].concat(_toConsumableArray(propositions.pageWideScopeDecisions), _toConsumableArray(propositions.viewPropositions));
77
- }).then(function (renderablePropositions) {
78
- return {
79
- decisions: _toConsumableArray(nonAutoRenderableDecisions),
80
- propositions: [].concat(_toConsumableArray((0, _addRenderAttemptedToDecisions.default)({
81
- decisions: renderablePropositions,
82
- renderAttempted: true
83
- })), _toConsumableArray((0, _addRenderAttemptedToDecisions.default)({
84
- decisions: nonAutoRenderableDecisions,
85
- renderAttempted: false
86
- })))
87
- };
88
- });
89
- };
90
- };
91
-
92
- exports.default = _default;
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _utils = require("../../utils");
6
-
7
- /*
8
- Copyright 2020 Adobe. All rights reserved.
9
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License. You may obtain a copy
11
- of the License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software distributed under
14
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- OF ANY KIND, either express or implied. See the License for the specific language
16
- governing permissions and limitations under the License.
17
- */
18
- var DEFAULT_ACTION_TYPE = "defaultContent";
19
-
20
- var identity = function identity(item) {
21
- return item;
22
- };
23
-
24
- var getItemMeta = function getItemMeta(item, decisionMeta) {
25
- return item.characteristics && item.characteristics.trackingLabel ? (0, _utils.assign)({
26
- trackingLabel: item.characteristics.trackingLabel
27
- }, decisionMeta) : decisionMeta;
28
- };
29
-
30
- var buildActions = function buildActions(decision) {
31
- var decisionMeta = {
32
- id: decision.id,
33
- scope: decision.scope,
34
- scopeDetails: decision.scopeDetails
35
- };
36
- return decision.items.map(function (item) {
37
- return (0, _utils.assign)({
38
- type: DEFAULT_ACTION_TYPE
39
- }, item.data, {
40
- meta: getItemMeta(item, decisionMeta)
41
- });
42
- });
43
- };
44
-
45
- var processMetas = function processMetas(logger, actionResults) {
46
- var results = (0, _utils.flatMap)(actionResults, identity);
47
- var finalMetas = [];
48
- var set = new Set();
49
- results.forEach(function (item) {
50
- // for click actions we don't return an item
51
- if (!item) {
52
- return;
53
- }
54
-
55
- if (item.error) {
56
- logger.warn(item);
57
- return;
58
- }
59
-
60
- var meta = item.meta;
61
-
62
- if (set.has(meta.id)) {
63
- return;
64
- }
65
-
66
- set.add(meta.id);
67
- finalMetas.push(meta);
68
- });
69
- return finalMetas;
70
- };
71
-
72
- var _default = function _default(_ref) {
73
- var modules = _ref.modules,
74
- logger = _ref.logger,
75
- executeActions = _ref.executeActions;
76
- return function (decisions) {
77
- var actionResultsPromises = decisions.map(function (decision) {
78
- var actions = buildActions(decision);
79
- return executeActions(actions, modules, logger);
80
- });
81
- return Promise.all(actionResultsPromises).then(function (results) {
82
- return processMetas(logger, results);
83
- }).catch(function (error) {
84
- logger.error(error);
85
- });
86
- };
87
- };
88
-
89
- exports.default = _default;
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _addRenderAttemptedToDecisions = require("./utils/addRenderAttemptedToDecisions");
6
-
7
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
-
9
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
-
11
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
-
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
-
15
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
-
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
-
19
- var getViewPropositions = function getViewPropositions(_ref) {
20
- var viewCache = _ref.viewCache,
21
- viewName = _ref.viewName,
22
- propositions = _ref.propositions;
23
-
24
- if (!viewName) {
25
- return propositions;
26
- }
27
-
28
- return viewCache.getView(viewName).then(function (viewPropositions) {
29
- return [].concat(_toConsumableArray(viewPropositions), _toConsumableArray(propositions));
30
- });
31
- };
32
-
33
- var buildFinalResult = function buildFinalResult(_ref2) {
34
- var propositions = _ref2.propositions;
35
- return {
36
- decisions: propositions,
37
- propositions: (0, _addRenderAttemptedToDecisions.default)({
38
- decisions: propositions,
39
- renderAttempted: false
40
- })
41
- };
42
- };
43
-
44
- var _default = function _default(_ref3) {
45
- var viewCache = _ref3.viewCache;
46
- return function (_ref4) {
47
- var viewName = _ref4.viewName,
48
- redirectDecisions = _ref4.redirectDecisions,
49
- pageWideScopeDecisions = _ref4.pageWideScopeDecisions,
50
- nonAutoRenderableDecisions = _ref4.nonAutoRenderableDecisions;
51
- var propositions = [].concat(_toConsumableArray(redirectDecisions), _toConsumableArray(pageWideScopeDecisions), _toConsumableArray(nonAutoRenderableDecisions));
52
- return Promise.resolve(propositions).then(function (items) {
53
- return getViewPropositions({
54
- viewCache: viewCache,
55
- viewName: viewName,
56
- propositions: items
57
- });
58
- }).then(function (items) {
59
- return buildFinalResult({
60
- propositions: items
61
- });
62
- });
63
- };
64
- };
65
-
66
- exports.default = _default;
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _isNonEmptyArray = require("../../utils/isNonEmptyArray");
6
-
7
- /*
8
- Copyright 2020 Adobe. All rights reserved.
9
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License. You may obtain a copy
11
- of the License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software distributed under
14
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- OF ANY KIND, either express or implied. See the License for the specific language
16
- governing permissions and limitations under the License.
17
- */
18
- var DECISIONS_HANDLE = "personalization:decisions";
19
-
20
- var _default = function _default(_ref) {
21
- var autoRenderingHandler = _ref.autoRenderingHandler,
22
- nonRenderingHandler = _ref.nonRenderingHandler,
23
- groupDecisions = _ref.groupDecisions,
24
- handleRedirectDecisions = _ref.handleRedirectDecisions,
25
- showContainers = _ref.showContainers;
26
- return function (_ref2) {
27
- var decisionsDeferred = _ref2.decisionsDeferred,
28
- personalizationDetails = _ref2.personalizationDetails,
29
- response = _ref2.response;
30
- var unprocessedDecisions = response.getPayloadsByType(DECISIONS_HANDLE);
31
- var viewName = personalizationDetails.getViewName(); // if personalization payload is empty return empty decisions array
32
-
33
- if (unprocessedDecisions.length === 0) {
34
- showContainers();
35
- decisionsDeferred.resolve({});
36
- return {
37
- decisions: [],
38
- propositions: []
39
- };
40
- }
41
-
42
- var _groupDecisions = groupDecisions(unprocessedDecisions),
43
- redirectDecisions = _groupDecisions.redirectDecisions,
44
- pageWideScopeDecisions = _groupDecisions.pageWideScopeDecisions,
45
- viewDecisions = _groupDecisions.viewDecisions,
46
- nonAutoRenderableDecisions = _groupDecisions.nonAutoRenderableDecisions;
47
-
48
- if (personalizationDetails.isRenderDecisions() && (0, _isNonEmptyArray.default)(redirectDecisions)) {
49
- decisionsDeferred.resolve({});
50
- return handleRedirectDecisions(redirectDecisions);
51
- } // save decisions for views in local cache
52
-
53
-
54
- decisionsDeferred.resolve(viewDecisions);
55
-
56
- if (personalizationDetails.isRenderDecisions()) {
57
- return autoRenderingHandler({
58
- viewName: viewName,
59
- pageWideScopeDecisions: pageWideScopeDecisions,
60
- nonAutoRenderableDecisions: nonAutoRenderableDecisions
61
- });
62
- }
63
-
64
- return nonRenderingHandler({
65
- viewName: viewName,
66
- redirectDecisions: redirectDecisions,
67
- pageWideScopeDecisions: pageWideScopeDecisions,
68
- nonAutoRenderableDecisions: nonAutoRenderableDecisions
69
- });
70
- };
71
- };
72
-
73
- exports.default = _default;
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _loggerMessage = require("./constants/loggerMessage");
6
-
7
- /*
8
- Copyright 2021 Adobe. All rights reserved.
9
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License. You may obtain a copy
11
- of the License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software distributed under
14
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- OF ANY KIND, either express or implied. See the License for the specific language
16
- governing permissions and limitations under the License.
17
- */
18
- var getRedirectDetails = function getRedirectDetails(redirectDecisions) {
19
- var decision = redirectDecisions[0];
20
- var items = decision.items,
21
- id = decision.id,
22
- scope = decision.scope,
23
- scopeDetails = decision.scopeDetails;
24
- var content = items[0].data.content;
25
- return {
26
- content: content,
27
- decisions: [{
28
- id: id,
29
- scope: scope,
30
- scopeDetails: scopeDetails
31
- }]
32
- };
33
- };
34
-
35
- var _default = function _default(_ref) {
36
- var collect = _ref.collect,
37
- window = _ref.window,
38
- logger = _ref.logger,
39
- showContainers = _ref.showContainers;
40
- return function (redirectDecisions) {
41
- var _getRedirectDetails = getRedirectDetails(redirectDecisions),
42
- content = _getRedirectDetails.content,
43
- decisions = _getRedirectDetails.decisions;
44
-
45
- var documentMayUnload = true;
46
- return collect({
47
- decisionsMeta: decisions,
48
- documentMayUnload: documentMayUnload
49
- }).then(function () {
50
- window.location.replace(content);
51
- }).catch(function () {
52
- showContainers();
53
- logger.warn(_loggerMessage.REDIRECT_EXECUTION_ERROR);
54
- });
55
- };
56
- };
57
-
58
- exports.default = _default;
@@ -1,75 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _remapHeadOffers = require("./remapHeadOffers");
6
-
7
- var _utils = require("../../../utils");
8
-
9
- var _remapCustomCodeOffers = require("./remapCustomCodeOffers");
10
-
11
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
-
13
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
-
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
-
17
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
-
19
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
-
21
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
-
23
- var logActionError = function logActionError(logger, action, error) {
24
- if (logger.enabled) {
25
- var details = JSON.stringify(action);
26
- var message = error.message,
27
- stack = error.stack;
28
- var errorMessage = "Failed to execute action " + details + ". " + message + " " + (stack ? "\n " + stack : "");
29
- logger.error(errorMessage);
30
- }
31
- };
32
-
33
- var logActionCompleted = function logActionCompleted(logger, action) {
34
- if (logger.enabled) {
35
- var details = JSON.stringify(action);
36
- logger.info("Action " + details + " executed.");
37
- }
38
- };
39
-
40
- var executeAction = function executeAction(logger, modules, type, args) {
41
- var execute = modules[type];
42
-
43
- if (!execute) {
44
- var error = new Error("DOM action \"" + type + "\" not found");
45
- logActionError(logger, args[0], error);
46
- throw error;
47
- }
48
-
49
- return execute.apply(void 0, _toConsumableArray(args));
50
- };
51
-
52
- var PREPROCESSORS = [_remapHeadOffers.default, _remapCustomCodeOffers.default];
53
-
54
- var preprocess = function preprocess(action) {
55
- return PREPROCESSORS.reduce(function (processed, fn) {
56
- return (0, _utils.assign)(processed, fn(processed));
57
- }, action);
58
- };
59
-
60
- var _default = function _default(actions, modules, logger) {
61
- var actionPromises = actions.map(function (action) {
62
- var processedAction = preprocess(action);
63
- var type = processedAction.type;
64
- return executeAction(logger, modules, type, [processedAction]).then(function (result) {
65
- logActionCompleted(logger, processedAction);
66
- return result;
67
- }).catch(function (error) {
68
- logActionError(logger, processedAction, error);
69
- throw error;
70
- });
71
- });
72
- return Promise.all(actionPromises);
73
- };
74
-
75
- exports.default = _default;
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
-
5
- var _utils = require("../../utils");
6
-
7
- var _isPageWideScope = require("./utils/isPageWideScope");
8
-
9
- var _schema = require("./constants/schema");
10
-
11
- var _scopeType = require("./constants/scopeType");
12
-
13
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
-
15
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
-
17
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
18
-
19
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
-
21
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
-
23
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
-
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
-
27
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
28
-
29
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
30
-
31
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
-
33
- var splitItems = function splitItems(items, schemas) {
34
- var matched = [];
35
- var nonMatched = [];
36
- items.forEach(function (item) {
37
- if ((0, _utils.includes)(schemas, item.schema)) {
38
- matched.push(item);
39
- } else {
40
- nonMatched.push(item);
41
- }
42
- });
43
- return [matched, nonMatched];
44
- };
45
-
46
- var createDecision = function createDecision(decision, items) {
47
- return {
48
- id: decision.id,
49
- scope: decision.scope,
50
- items: items,
51
- scopeDetails: decision.scopeDetails
52
- };
53
- };
54
-
55
- var splitMergedMetricDecisions = function splitMergedMetricDecisions(decisions) {
56
- var matchedDecisions = decisions.filter(function (decision) {
57
- var _decision$items = decision.items,
58
- items = _decision$items === void 0 ? [] : _decision$items;
59
- return items.some(function (item) {
60
- return item.schema === _schema.MEASUREMENT_SCHEMA;
61
- });
62
- });
63
- var unmatchedDecisions = decisions.filter(function (decision) {
64
- return !(0, _utils.includes)(matchedDecisions, decision);
65
- });
66
- return {
67
- matchedDecisions: matchedDecisions,
68
- unmatchedDecisions: unmatchedDecisions
69
- };
70
- };
71
-
72
- var splitDecisions = function splitDecisions(decisions) {
73
- for (var _len = arguments.length, schemas = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
74
- schemas[_key - 1] = arguments[_key];
75
- }
76
-
77
- var matchedDecisions = [];
78
- var unmatchedDecisions = [];
79
- decisions.forEach(function (decision) {
80
- var _decision$items2 = decision.items,
81
- items = _decision$items2 === void 0 ? [] : _decision$items2;
82
-
83
- var _splitItems = splitItems(items, schemas),
84
- _splitItems2 = _slicedToArray(_splitItems, 2),
85
- matchedItems = _splitItems2[0],
86
- nonMatchedItems = _splitItems2[1];
87
-
88
- if ((0, _utils.isNonEmptyArray)(matchedItems)) {
89
- matchedDecisions.push(createDecision(decision, matchedItems));
90
- }
91
-
92
- if ((0, _utils.isNonEmptyArray)(nonMatchedItems)) {
93
- unmatchedDecisions.push(createDecision(decision, nonMatchedItems));
94
- }
95
- });
96
- return {
97
- matchedDecisions: matchedDecisions,
98
- unmatchedDecisions: unmatchedDecisions
99
- };
100
- };
101
-
102
- var appendScopeDecision = function appendScopeDecision(scopeDecisions, decision) {
103
- if (!scopeDecisions[decision.scope]) {
104
- scopeDecisions[decision.scope] = [];
105
- }
106
-
107
- scopeDecisions[decision.scope].push(decision);
108
- };
109
-
110
- var isViewScope = function isViewScope(scopeDetails) {
111
- return scopeDetails.characteristics && scopeDetails.characteristics.scopeType && scopeDetails.characteristics.scopeType === _scopeType.VIEW_SCOPE_TYPE;
112
- };
113
-
114
- var extractDecisionsByScope = function extractDecisionsByScope(decisions) {
115
- var pageWideScopeDecisions = [];
116
- var nonPageWideScopeDecisions = [];
117
- var viewScopeDecisions = {};
118
-
119
- if ((0, _utils.isNonEmptyArray)(decisions)) {
120
- decisions.forEach(function (decision) {
121
- if ((0, _isPageWideScope.default)(decision.scope)) {
122
- pageWideScopeDecisions.push(decision);
123
- } else if (isViewScope(decision.scopeDetails)) {
124
- appendScopeDecision(viewScopeDecisions, decision);
125
- } else {
126
- nonPageWideScopeDecisions.push(decision);
127
- }
128
- });
129
- }
130
-
131
- return {
132
- pageWideScopeDecisions: pageWideScopeDecisions,
133
- nonPageWideScopeDecisions: nonPageWideScopeDecisions,
134
- viewScopeDecisions: viewScopeDecisions
135
- };
136
- };
137
-
138
- var groupDecisions = function groupDecisions(unprocessedDecisions) {
139
- // split redirect decisions
140
- var decisionsGroupedByRedirectItemSchema = splitDecisions(unprocessedDecisions, _schema.REDIRECT_ITEM); // split merged measurement decisions
141
-
142
- var mergedMetricDecisions = splitMergedMetricDecisions(decisionsGroupedByRedirectItemSchema.unmatchedDecisions); // split renderable decisions
143
-
144
- var decisionsGroupedByRenderableSchemas = splitDecisions(mergedMetricDecisions.unmatchedDecisions, _schema.DOM_ACTION, _schema.DEFAULT_CONTENT_ITEM); // group renderable decisions by scope
145
-
146
- var _extractDecisionsBySc = extractDecisionsByScope(decisionsGroupedByRenderableSchemas.matchedDecisions),
147
- pageWideScopeDecisions = _extractDecisionsBySc.pageWideScopeDecisions,
148
- nonPageWideScopeDecisions = _extractDecisionsBySc.nonPageWideScopeDecisions,
149
- viewScopeDecisions = _extractDecisionsBySc.viewScopeDecisions;
150
-
151
- return {
152
- redirectDecisions: decisionsGroupedByRedirectItemSchema.matchedDecisions,
153
- pageWideScopeDecisions: pageWideScopeDecisions,
154
- viewDecisions: viewScopeDecisions,
155
- nonAutoRenderableDecisions: [].concat(_toConsumableArray(mergedMetricDecisions.matchedDecisions), _toConsumableArray(decisionsGroupedByRenderableSchemas.unmatchedDecisions), _toConsumableArray(nonPageWideScopeDecisions))
156
- };
157
- };
158
-
159
- var _default = groupDecisions;
160
- exports.default = _default;