@adobe/alloy 2.14.0-alpha.19 → 2.14.0-alpha.20

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.
@@ -4,6 +4,10 @@ exports.default = void 0;
4
4
 
5
5
  var _remapHeadOffers = require("./remapHeadOffers");
6
6
 
7
+ var _utils = require("../../../utils");
8
+
9
+ var _remapCustomCodeOffers = require("./remapCustomCodeOffers");
10
+
7
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
12
 
9
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."); }
@@ -45,9 +49,17 @@ var executeAction = function executeAction(logger, modules, type, args) {
45
49
  return execute.apply(void 0, _toConsumableArray(args));
46
50
  };
47
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
+
48
60
  var _default = function _default(actions, modules, logger) {
49
61
  var actionPromises = actions.map(function (action) {
50
- var processedAction = (0, _remapHeadOffers.default)(action);
62
+ var processedAction = preprocess(action);
51
63
  var type = processedAction.type;
52
64
  return executeAction(logger, modules, type, [processedAction]).then(function (result) {
53
65
  logActionCompleted(logger, processedAction);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+
5
+ var _utils = require("../../../utils");
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
+
19
+ /*
20
+ * Preprocess customCode actions before rendering, so that offer selectors are remapped appropriately for
21
+ * target offers, to align with the way it works in at.js.
22
+ */
23
+ var ACTION_CUSTOM_CODE = "customCode";
24
+ var TARGET_BODY_SELECTOR = "BODY > *:eq(0)";
25
+
26
+ var _default = function _default(action) {
27
+ var selector = action.selector,
28
+ type = action.type;
29
+
30
+ if (type !== ACTION_CUSTOM_CODE) {
31
+ return action;
32
+ }
33
+
34
+ if (selector !== TARGET_BODY_SELECTOR) {
35
+ return action;
36
+ }
37
+
38
+ return (0, _utils.assign)({}, action, {
39
+ selector: "BODY"
40
+ });
41
+ };
42
+
43
+ exports.default = _default;
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
15
15
  */
16
16
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
17
17
  // see babel-plugin-version
18
- var _default = "2.14.0-alpha.19";
18
+ var _default = "2.14.0-alpha.20";
19
19
  exports.default = _default;
@@ -9,7 +9,9 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import preprocess from "./remapHeadOffers";
12
+ import remapHeadOffers from "./remapHeadOffers";
13
+ import { assign } from "../../../utils";
14
+ import remapCustomCodeOffers from "./remapCustomCodeOffers";
13
15
 
14
16
  const logActionError = (logger, action, error) => {
15
17
  if (logger.enabled) {
@@ -42,6 +44,10 @@ const executeAction = (logger, modules, type, args) => {
42
44
  return execute(...args);
43
45
  };
44
46
 
47
+ const PREPROCESSORS = [remapHeadOffers, remapCustomCodeOffers];
48
+
49
+ const preprocess = action => PREPROCESSORS.reduce((processed, fn) => assign(processed, fn(processed)), action);
50
+
45
51
  export default ((actions, modules, logger) => {
46
52
  const actionPromises = actions.map(action => {
47
53
  const processedAction = preprocess(action);
@@ -0,0 +1,37 @@
1
+ /*
2
+ Copyright 2021 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ /*
14
+ * Preprocess customCode actions before rendering, so that offer selectors are remapped appropriately for
15
+ * target offers, to align with the way it works in at.js.
16
+ */
17
+ import { assign } from "../../../utils";
18
+ const ACTION_CUSTOM_CODE = "customCode";
19
+ const TARGET_BODY_SELECTOR = "BODY > *:eq(0)";
20
+ export default (action => {
21
+ const {
22
+ selector,
23
+ type
24
+ } = action;
25
+
26
+ if (type !== ACTION_CUSTOM_CODE) {
27
+ return action;
28
+ }
29
+
30
+ if (selector !== TARGET_BODY_SELECTOR) {
31
+ return action;
32
+ }
33
+
34
+ return assign({}, action, {
35
+ selector: "BODY"
36
+ });
37
+ });
@@ -11,4 +11,4 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
13
13
  // see babel-plugin-version
14
- export default "2.14.0-alpha.19";
14
+ export default "2.14.0-alpha.20";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.14.0-alpha.19",
3
+ "version": "2.14.0-alpha.20",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@adobe/alloy": "^2.14.0-alpha.18",
67
+ "@adobe/alloy": "^2.14.0-alpha.19",
68
68
  "@babel/cli": "^7.12.8",
69
69
  "@babel/core": "^7.2.2",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
@@ -118,7 +118,7 @@
118
118
  "rollup-plugin-terser": "^7.0.2",
119
119
  "semver": "^7.3.7",
120
120
  "start-server-and-test": "^1.10.6",
121
- "testcafe": "^1.19.0",
121
+ "testcafe": "^2.2.0",
122
122
  "testcafe-browser-provider-saucelabs": "^1.9.0",
123
123
  "testcafe-reporter-junit": "^3.0.2",
124
124
  "url-exists-nodejs": "^0.1.0",