@adobe/alloy 2.6.4 → 2.8.0-beta.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.
Files changed (65) hide show
  1. package/libEs5/components/ActivityCollector/utils.js +1 -1
  2. package/libEs5/components/Audiences/index.js +6 -8
  3. package/libEs5/components/Audiences/injectProcessResponse.js +44 -0
  4. package/libEs5/components/MachineLearning/index.js +30 -0
  5. package/libEs5/components/MachineLearning/processResponse.js +22 -0
  6. package/libEs5/components/Personalization/createCollect.js +1 -1
  7. package/libEs5/components/Personalization/createOnClickHandler.js +1 -1
  8. package/libEs5/components/Personalization/createViewCollect.js +1 -1
  9. package/libEs5/components/Personalization/dom-actions/action.js +25 -25
  10. package/libEs5/components/Personalization/dom-actions/appendHtml.js +1 -1
  11. package/libEs5/components/Personalization/dom-actions/dom/index.js +26 -26
  12. package/libEs5/components/Personalization/dom-actions/dom/selectNodesWithEq.js +1 -1
  13. package/libEs5/components/Personalization/dom-actions/index.js +4 -4
  14. package/libEs5/components/Personalization/dom-actions/insertHtmlAfter.js +1 -1
  15. package/libEs5/components/Personalization/dom-actions/insertHtmlBefore.js +1 -1
  16. package/libEs5/components/Personalization/dom-actions/prependHtml.js +1 -1
  17. package/libEs5/components/Personalization/dom-actions/scripts.js +6 -5
  18. package/libEs5/components/Personalization/dom-actions/setStyles.js +3 -1
  19. package/libEs5/components/Personalization/event.js +2 -2
  20. package/libEs5/components/Personalization/flicker/index.js +3 -3
  21. package/libEs5/components/Personalization/groupDecisions.js +1 -1
  22. package/libEs5/components/Privacy/computeConsentHash.js +1 -1
  23. package/libEs5/components/Privacy/createConsentHashStore.js +3 -1
  24. package/libEs5/components/Privacy/parseConsentCookie.js +1 -1
  25. package/libEs5/constants/cookieNameKey.js +1 -1
  26. package/libEs5/constants/httpHeaderNames.js +1 -1
  27. package/libEs5/constants/httpStatusCode.js +1 -1
  28. package/libEs5/constants/libraryVersion.js +1 -1
  29. package/libEs5/constants/shadowSeparator.js +17 -0
  30. package/libEs5/constants/tagName.js +1 -1
  31. package/libEs5/core/componentCreators.js +3 -1
  32. package/libEs5/core/consent/createConsentStateMachine.js +1 -1
  33. package/libEs5/core/network/injectSendNetworkRequest.js +2 -2
  34. package/libEs5/utils/convertTimes.js +1 -1
  35. package/libEs5/utils/dom/awaitSelector.js +1 -1
  36. package/libEs5/utils/dom/index.js +21 -5
  37. package/libEs5/utils/dom/isShadowSelector.js +22 -0
  38. package/libEs5/utils/dom/querySelectorAll.js +22 -0
  39. package/libEs5/utils/dom/selectNodes.js +11 -2
  40. package/libEs5/utils/dom/selectNodesWithShadow.js +74 -0
  41. package/libEs5/utils/fireReferrerHideableImage.js +1 -1
  42. package/libEs5/utils/index.js +20 -20
  43. package/libEs5/utils/isObject.js +1 -1
  44. package/libEs5/utils/validation/index.js +1 -1
  45. package/libEs6/components/Audiences/index.js +5 -9
  46. package/libEs6/components/Audiences/injectProcessResponse.js +39 -0
  47. package/libEs6/components/MachineLearning/index.js +25 -0
  48. package/libEs6/components/MachineLearning/processResponse.js +17 -0
  49. package/libEs6/components/Personalization/createCollect.js +1 -1
  50. package/libEs6/components/Personalization/createOnClickHandler.js +1 -1
  51. package/libEs6/components/Personalization/createViewCollect.js +1 -1
  52. package/libEs6/components/Personalization/dom-actions/appendHtml.js +1 -1
  53. package/libEs6/components/Personalization/dom-actions/insertHtmlAfter.js +1 -1
  54. package/libEs6/components/Personalization/dom-actions/insertHtmlBefore.js +1 -1
  55. package/libEs6/components/Personalization/dom-actions/prependHtml.js +1 -1
  56. package/libEs6/components/Personalization/dom-actions/scripts.js +5 -2
  57. package/libEs6/constants/libraryVersion.js +1 -1
  58. package/libEs6/constants/shadowSeparator.js +12 -0
  59. package/libEs6/core/componentCreators.js +3 -2
  60. package/libEs6/utils/dom/index.js +3 -1
  61. package/libEs6/utils/dom/isShadowSelector.js +13 -0
  62. package/libEs6/utils/dom/querySelectorAll.js +13 -0
  63. package/libEs6/utils/dom/selectNodes.js +8 -2
  64. package/libEs6/utils/dom/selectNodesWithShadow.js +66 -0
  65. package/package.json +10 -9
@@ -17,7 +17,8 @@ import createPersonalization from "../components/Personalization";
17
17
  import createContext from "../components/Context";
18
18
  import createPrivacy from "../components/Privacy";
19
19
  import createEventMerge from "../components/EventMerge";
20
- import createLibraryInfo from "../components/LibraryInfo"; // TODO: Register the Components here statically for now. They might be registered differently.
20
+ import createLibraryInfo from "../components/LibraryInfo";
21
+ import createMachineLearning from "../components/MachineLearning"; // TODO: Register the Components here statically for now. They might be registered differently.
21
22
  // TODO: Figure out how sub-components will be made available/registered
22
23
 
23
- export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo];
24
+ export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning];
@@ -13,5 +13,7 @@ export { default as awaitSelector } from "./awaitSelector";
13
13
  export { default as appendNode } from "./appendNode";
14
14
  export { default as createNode } from "./createNode";
15
15
  export { default as matchesSelector } from "./matchesSelector";
16
+ export { default as querySelectorAll } from "./querySelectorAll";
16
17
  export { default as removeNode } from "./removeNode";
17
- export { default as selectNodes } from "./selectNodes";
18
+ export { default as selectNodes } from "./selectNodes";
19
+ export { default as selectNodesWithShadow } from "./selectNodesWithShadow";
@@ -0,0 +1,13 @@
1
+ /*
2
+ Copyright 2022 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
+ import SHADOW_SEPARATOR from "../../constants/shadowSeparator";
13
+ export default (str => str.indexOf(SHADOW_SEPARATOR) !== -1);
@@ -0,0 +1,13 @@
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
+ import toArray from "../toArray";
13
+ export default ((context, selector) => toArray(context.querySelectorAll(selector)));
@@ -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 toArray from "../toArray";
12
+ import querySelectorAll from "./querySelectorAll";
13
+ import selectNodesWithShadow from "./selectNodesWithShadow";
14
+ import isShadowSelector from "./isShadowSelector";
13
15
  /**
14
16
  * Returns an array of matched DOM nodes.
15
17
  * @param {String} selector
@@ -18,5 +20,9 @@ import toArray from "../toArray";
18
20
  */
19
21
 
20
22
  export default ((selector, context = document) => {
21
- return toArray(context.querySelectorAll(selector));
23
+ if (!isShadowSelector(selector)) {
24
+ return querySelectorAll(context, selector);
25
+ }
26
+
27
+ return selectNodesWithShadow(context, selector);
22
28
  });
@@ -0,0 +1,66 @@
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
+ import querySelectorAll from "./querySelectorAll";
13
+ import startsWith from "../startsWith";
14
+ import SHADOW_SEPARATOR from "../../constants/shadowSeparator";
15
+
16
+ const splitWithShadow = selector => {
17
+ return selector.split(SHADOW_SEPARATOR);
18
+ };
19
+
20
+ const transformPrefix = (parent, selector) => {
21
+ const result = selector.trim();
22
+ const hasChildCombinatorPrefix = startsWith(result, ">");
23
+
24
+ if (!hasChildCombinatorPrefix) {
25
+ return result;
26
+ } // IE doesn't support :scope
27
+
28
+
29
+ if (window.document.documentMode) {
30
+ return result.substring(1).trim();
31
+ }
32
+
33
+ const prefix = parent instanceof Element || parent instanceof HTMLDocument ? ":scope" : ":host"; // see https://bugs.webkit.org/show_bug.cgi?id=233380
34
+
35
+ return `${prefix} ${result}`;
36
+ };
37
+
38
+ export default ((context, selector) => {
39
+ // Shadow DOM should be supported
40
+ if (!window.document.documentElement.attachShadow) {
41
+ return querySelectorAll(context, selector.replace(SHADOW_SEPARATOR, ""));
42
+ }
43
+
44
+ const parts = splitWithShadow(selector);
45
+
46
+ if (parts.length < 2) {
47
+ return querySelectorAll(context, selector);
48
+ } // split the selector into parts separated by :shadow pseudo-selectors
49
+ // find each subselector element based on the previously selected node's shadowRoot
50
+
51
+
52
+ let parent = context;
53
+
54
+ for (let i = 0; i < parts.length; i += 1) {
55
+ const part = transformPrefix(parent, parts[i]);
56
+ const partNode = querySelectorAll(parent, part);
57
+
58
+ if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
59
+ return partNode;
60
+ }
61
+
62
+ parent = partNode[0].shadowRoot;
63
+ }
64
+
65
+ return undefined;
66
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.6.4",
3
+ "version": "2.8.0-beta.1",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -19,6 +19,7 @@
19
19
  "test:unit:coverage": "karma start --single-run --reporters spec,coverage",
20
20
  "test:functional": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe chrome",
21
21
  "test:functional:watch": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" ./scripts/watchFunctionalTests.js --browsers chrome",
22
+ "test:functional:debug": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe --inspect-brk chrome",
22
23
  "test:functional:build:int": "rollup -c --environment BASE_CODE_MIN,STANDALONE,NPM_PACKAGE_LOCAL",
23
24
  "test:functional:build:prod": "rollup -c --environment BASE_CODE_MIN,NPM_PACKAGE_PROD",
24
25
  "test:scripts": "jasmine --config=scripts/specs/jasmine.json",
@@ -63,20 +64,21 @@
63
64
  "uuid": "^3.3.2"
64
65
  },
65
66
  "devDependencies": {
66
- "@adobe/alloy": "^2.6.4-beta.4",
67
+ "@adobe/alloy": "^2.8.0-beta.0",
67
68
  "@babel/cli": "^7.12.8",
68
69
  "@babel/core": "^7.2.2",
69
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
71
+ "@babel/plugin-transform-runtime": "^7.16.4",
70
72
  "@babel/plugin-transform-template-literals": "^7.4.4",
71
73
  "@babel/preset-env": "^7.4.5",
72
74
  "@octokit/rest": "^18.3.5",
73
75
  "babel-plugin-version": "^0.2.3",
74
76
  "bundlesize": "^0.18.0",
75
77
  "chalk": "^2.4.2",
76
- "concurrently": "^5.3.0",
78
+ "concurrently": "^6.5.0",
77
79
  "date-fns": "^2.23.0",
78
80
  "dotenv": "^8.1.0",
79
- "eslint": "^7.25.0",
81
+ "eslint": "^7.32.0",
80
82
  "eslint-config-airbnb-base": "^14.0.0",
81
83
  "eslint-config-prettier": "^6.4.0",
82
84
  "eslint-plugin-ban": "^1.5.2",
@@ -86,7 +88,7 @@
86
88
  "glob": "^7.1.3",
87
89
  "husky": "^6.0.0",
88
90
  "jasmine-core": "^3.4.0",
89
- "karma": "^4.0.0",
91
+ "karma": "^6.3.9",
90
92
  "karma-chrome-launcher": "^3.1.0",
91
93
  "karma-coverage": "^2.0.1",
92
94
  "karma-firefox-launcher": "^2.1.0",
@@ -95,7 +97,7 @@
95
97
  "karma-jasmine-matchers": "^4.0.1",
96
98
  "karma-rollup-preprocessor": "^7.0.5",
97
99
  "karma-safari-launcher": "^1.0.0",
98
- "karma-sauce-launcher": "^4.3.5",
100
+ "karma-sauce-launcher": "^4.3.6",
99
101
  "karma-spec-reporter": "0.0.32",
100
102
  "lint-staged": "^10.5.4",
101
103
  "prettier": "^1.16.4",
@@ -113,10 +115,9 @@
113
115
  "rollup-plugin-node-resolve": "^5.2.0",
114
116
  "rollup-plugin-terser": "^7.0.2",
115
117
  "start-server-and-test": "^1.10.6",
116
- "testcafe": "^1.12.0",
117
- "testcafe-browser-provider-saucelabs": "^1.8.1",
118
+ "testcafe": "^1.17.1",
119
+ "testcafe-browser-provider-saucelabs": "^1.8.3",
118
120
  "testcafe-reporter-testrail": "^0.6.3",
119
- "ua-parser": "^0.3.5",
120
121
  "url-exists-nodejs": "^0.1.0",
121
122
  "url-parse": "^1.4.7",
122
123
  "yargs": "^16.2.0"