@adobe/alloy 2.19.0-beta.10 → 2.19.0-beta.12
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/libEs5/components/DataCollector/index.js +3 -0
- package/libEs5/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs5/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs5/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +32 -0
- package/libEs5/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +25 -0
- package/libEs5/components/DecisioningEngine/constants.js +31 -0
- package/libEs5/components/DecisioningEngine/createApplyResponse.js +34 -0
- package/libEs5/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs5/components/DecisioningEngine/createContextProvider.js +93 -0
- package/libEs5/components/DecisioningEngine/createDecisionHistory.js +28 -0
- package/libEs5/components/DecisioningEngine/createDecisionProvider.js +51 -0
- package/libEs5/components/DecisioningEngine/createEvaluableRulesetPayload.js +80 -0
- package/libEs5/components/DecisioningEngine/createEvaluateRulesetsCommand.js +49 -0
- package/libEs5/components/DecisioningEngine/createEventRegistry.js +123 -0
- package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +43 -0
- package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +87 -0
- package/libEs5/components/DecisioningEngine/index.js +114 -0
- package/libEs5/components/DecisioningEngine/utils.js +83 -0
- package/libEs5/components/Personalization/createActionsProvider.js +72 -0
- package/libEs5/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs5/components/Personalization/createCollect.js +9 -4
- package/libEs5/components/Personalization/createComponent.js +5 -3
- package/libEs5/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs5/components/Personalization/createOnDecisionHandler.js +45 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +2 -2
- package/libEs5/components/Personalization/createPreprocessors.js +21 -0
- package/libEs5/components/Personalization/createViewCacheManager.js +1 -1
- package/libEs5/components/Personalization/event.js +25 -22
- package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
- package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +288 -0
- package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +23 -0
- package/libEs5/components/Personalization/in-app-message-actions/utils.js +53 -0
- package/libEs5/components/Personalization/index.js +17 -5
- package/libEs5/constants/contentType.js +18 -0
- package/libEs5/constants/eventType.js +25 -0
- package/libEs5/{components/Personalization/constants/eventType.js → constants/handle.js} +4 -7
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/constants/propositionEventType.js +33 -0
- package/libEs5/{components/Personalization/constants → constants}/schema.js +9 -1
- package/libEs5/core/componentCreators.js +2 -1
- package/libEs5/core/config/createCoreConfigs.js +1 -0
- package/libEs5/core/createEvent.js +26 -1
- package/libEs5/core/createEventManager.js +3 -0
- package/libEs5/core/createLifecycle.js +4 -1
- package/libEs5/utils/createSubscription.js +91 -0
- package/libEs5/utils/debounce.js +30 -0
- package/libEs5/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs5/utils/flattenArray.js +37 -0
- package/libEs5/utils/flattenObject.js +43 -0
- package/libEs5/utils/index.js +7 -0
- package/libEs5/utils/parseUrl.js +70 -0
- package/libEs6/components/DataCollector/index.js +2 -0
- package/libEs6/components/DataCollector/validateApplyResponse.js +2 -1
- package/libEs6/components/DataCollector/validateUserEventOptions.js +2 -1
- package/libEs6/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +30 -0
- package/{libEs5/components/Personalization/constants/propositionEventType.js → libEs6/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js} +13 -9
- package/libEs6/components/DecisioningEngine/constants.js +25 -0
- package/libEs6/components/DecisioningEngine/createApplyResponse.js +29 -0
- package/libEs6/components/DecisioningEngine/createConsequenceAdapter.js +29 -0
- package/libEs6/components/DecisioningEngine/createContextProvider.js +95 -0
- package/libEs6/components/DecisioningEngine/createDecisionHistory.js +25 -0
- package/libEs6/components/DecisioningEngine/createDecisionProvider.js +41 -0
- package/libEs6/components/DecisioningEngine/createEvaluableRulesetPayload.js +79 -0
- package/libEs6/components/DecisioningEngine/createEvaluateRulesetsCommand.js +45 -0
- package/libEs6/components/DecisioningEngine/createEventRegistry.js +113 -0
- package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +42 -0
- package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
- package/libEs6/components/DecisioningEngine/index.js +119 -0
- package/libEs6/components/DecisioningEngine/utils.js +74 -0
- package/libEs6/components/Personalization/createActionsProvider.js +70 -0
- package/libEs6/components/Personalization/createApplyPropositions.js +2 -2
- package/libEs6/components/Personalization/createCollect.js +7 -4
- package/libEs6/components/Personalization/createComponent.js +5 -3
- package/libEs6/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs6/components/Personalization/createOnDecisionHandler.js +43 -0
- package/libEs6/components/Personalization/createPersonalizationDetails.js +2 -2
- package/libEs6/components/Personalization/createPreprocessors.js +19 -0
- package/libEs6/components/Personalization/createViewCacheManager.js +1 -1
- package/libEs6/components/Personalization/event.js +14 -9
- package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
- package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +291 -0
- package/libEs6/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +17 -0
- package/libEs6/components/Personalization/in-app-message-actions/utils.js +49 -0
- package/libEs6/components/Personalization/index.js +19 -6
- package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
- package/libEs6/constants/eventType.js +17 -0
- package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/handle.js} +2 -6
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/constants/propositionEventType.js +33 -0
- package/libEs6/{components/Personalization/constants → constants}/schema.js +4 -0
- package/libEs6/core/componentCreators.js +2 -1
- package/libEs6/core/config/createCoreConfigs.js +1 -0
- package/libEs6/core/createEvent.js +26 -1
- package/libEs6/core/createEventManager.js +2 -0
- package/libEs6/core/createLifecycle.js +4 -1
- package/libEs6/utils/createSubscription.js +70 -0
- package/libEs6/utils/debounce.js +22 -0
- package/libEs6/utils/dom/selectNodesWithShadow.js +10 -3
- package/libEs6/utils/flattenArray.js +26 -0
- package/libEs6/utils/flattenObject.js +28 -0
- package/libEs6/utils/index.js +1 -0
- package/libEs6/utils/parseUrl.js +62 -0
- package/package.json +6 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 { values } from "./index";
|
|
13
|
+
const defaultPreprocessor = (params, ...args) => {
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
|
18
|
+
const defaultEmissionCondition = (params, ...args) => true;
|
|
19
|
+
const createSubscription = () => {
|
|
20
|
+
let preprocessor = defaultPreprocessor;
|
|
21
|
+
let emissionCondition = defaultEmissionCondition;
|
|
22
|
+
let counter = 0;
|
|
23
|
+
const subscriptions = {};
|
|
24
|
+
const createUnsubscribe = id => {
|
|
25
|
+
return () => {
|
|
26
|
+
delete subscriptions[id];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const add = (callback, params = undefined) => {
|
|
30
|
+
if (typeof callback !== "function") {
|
|
31
|
+
return () => undefined;
|
|
32
|
+
}
|
|
33
|
+
counter += 1;
|
|
34
|
+
subscriptions[counter] = {
|
|
35
|
+
callback,
|
|
36
|
+
params
|
|
37
|
+
};
|
|
38
|
+
return createUnsubscribe(counter);
|
|
39
|
+
};
|
|
40
|
+
const setEmissionPreprocessor = value => {
|
|
41
|
+
if (typeof value === "function") {
|
|
42
|
+
preprocessor = value;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const setEmissionCondition = value => {
|
|
46
|
+
if (typeof value === "function") {
|
|
47
|
+
emissionCondition = value;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const emit = (...args) => {
|
|
51
|
+
values(subscriptions).forEach(({
|
|
52
|
+
callback,
|
|
53
|
+
params
|
|
54
|
+
}) => {
|
|
55
|
+
const result = preprocessor(params, ...args);
|
|
56
|
+
if (emissionCondition(params, ...result)) {
|
|
57
|
+
callback(...result);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const hasSubscriptions = () => Object.keys(subscriptions).length > 0;
|
|
62
|
+
return {
|
|
63
|
+
add,
|
|
64
|
+
emit,
|
|
65
|
+
hasSubscriptions,
|
|
66
|
+
setEmissionPreprocessor,
|
|
67
|
+
setEmissionCondition
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export default createSubscription;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
export default ((fn, delay = 150) => {
|
|
13
|
+
let timer;
|
|
14
|
+
return (...args) => {
|
|
15
|
+
if (timer) {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
timer = setTimeout(() => {
|
|
19
|
+
fn(...args);
|
|
20
|
+
}, delay);
|
|
21
|
+
};
|
|
22
|
+
});
|
|
@@ -17,7 +17,7 @@ const splitWithShadow = selector => {
|
|
|
17
17
|
return selector.split(SHADOW_SEPARATOR);
|
|
18
18
|
};
|
|
19
19
|
const transformPrefix = (parent, selector) => {
|
|
20
|
-
const result = selector
|
|
20
|
+
const result = selector;
|
|
21
21
|
const hasChildCombinatorPrefix = startsWith(result, ">");
|
|
22
22
|
if (!hasChildCombinatorPrefix) {
|
|
23
23
|
return result;
|
|
@@ -45,8 +45,15 @@ export default ((context, selector) => {
|
|
|
45
45
|
// find each subselector element based on the previously selected node's shadowRoot
|
|
46
46
|
let parent = context;
|
|
47
47
|
for (let i = 0; i < parts.length; i += 1) {
|
|
48
|
-
const part =
|
|
49
|
-
|
|
48
|
+
const part = parts[i].trim();
|
|
49
|
+
// if part is empty, it means there's a chained :eq:shadow selector
|
|
50
|
+
if (part === "" && parent.shadowRoot) {
|
|
51
|
+
parent = parent.shadowRoot;
|
|
52
|
+
// eslint-disable-next-line no-continue
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const prefixed = transformPrefix(parent, part);
|
|
56
|
+
const partNode = querySelectorAll(parent, prefixed);
|
|
50
57
|
if (partNode.length === 0 || !partNode[0] || !partNode[0].shadowRoot) {
|
|
51
58
|
return partNode;
|
|
52
59
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
const flattenArray = (items = []) => {
|
|
13
|
+
const flat = [];
|
|
14
|
+
if (!Array.isArray(items)) {
|
|
15
|
+
return items;
|
|
16
|
+
}
|
|
17
|
+
items.forEach(item => {
|
|
18
|
+
if (Array.isArray(item)) {
|
|
19
|
+
flat.push(...flattenArray(item));
|
|
20
|
+
} else {
|
|
21
|
+
flat.push(item);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return flat;
|
|
25
|
+
};
|
|
26
|
+
export default flattenArray;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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
|
+
const isPlainObject = obj => obj !== null && typeof obj === "object" && Object.getPrototypeOf(obj) === Object.prototype;
|
|
13
|
+
const flattenObject = (obj, result = {}, keys = []) => {
|
|
14
|
+
Object.keys(obj).forEach(key => {
|
|
15
|
+
if (isPlainObject(obj[key]) || Array.isArray(obj[key])) {
|
|
16
|
+
flattenObject(obj[key], result, [...keys, key]);
|
|
17
|
+
} else {
|
|
18
|
+
result[[...keys, key].join(".")] = obj[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
export default (obj => {
|
|
24
|
+
if (!isPlainObject(obj)) {
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
return flattenObject(obj);
|
|
28
|
+
});
|
package/libEs6/utils/index.js
CHANGED
|
@@ -52,6 +52,7 @@ export { default as isString } from "./isString";
|
|
|
52
52
|
export { default as memoize } from "./memoize";
|
|
53
53
|
export { default as noop } from "./noop";
|
|
54
54
|
export { default as padStart } from "./padStart";
|
|
55
|
+
export { default as parseUrl } from "./parseUrl";
|
|
55
56
|
export { default as prepareConfigOverridesForEdge } from "./prepareConfigOverridesForEdge";
|
|
56
57
|
export { default as queryString } from "./querystring";
|
|
57
58
|
export { default as sanitizeOrgIdForCookieName } from "./sanitizeOrgIdForCookieName";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 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 parseUri from "parse-uri";
|
|
13
|
+
import isString from "./isString";
|
|
14
|
+
const parseDomainBasic = host => {
|
|
15
|
+
const result = {};
|
|
16
|
+
const domainParts = host.split(".");
|
|
17
|
+
switch (domainParts.length) {
|
|
18
|
+
case 1:
|
|
19
|
+
result.subdomain = "";
|
|
20
|
+
result.domain = host;
|
|
21
|
+
result.topLevelDomain = "";
|
|
22
|
+
break;
|
|
23
|
+
case 2:
|
|
24
|
+
result.subdomain = "";
|
|
25
|
+
result.domain = host;
|
|
26
|
+
result.topLevelDomain = domainParts[1];
|
|
27
|
+
break;
|
|
28
|
+
case 3:
|
|
29
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
30
|
+
result.domain = host;
|
|
31
|
+
result.topLevelDomain = domainParts[2];
|
|
32
|
+
break;
|
|
33
|
+
case 4:
|
|
34
|
+
result.subdomain = domainParts[0] === "www" ? "" : domainParts[0];
|
|
35
|
+
result.domain = host;
|
|
36
|
+
result.topLevelDomain = `${domainParts[2]}.${domainParts[3]}`;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
const parseUrl = (url, parseDomain = parseDomainBasic) => {
|
|
44
|
+
if (!isString(url)) {
|
|
45
|
+
// eslint-disable-next-line no-param-reassign
|
|
46
|
+
url = "";
|
|
47
|
+
}
|
|
48
|
+
const parsed = parseUri(url) || {};
|
|
49
|
+
const {
|
|
50
|
+
host = "",
|
|
51
|
+
path = "",
|
|
52
|
+
query = "",
|
|
53
|
+
anchor = ""
|
|
54
|
+
} = parsed;
|
|
55
|
+
return {
|
|
56
|
+
path,
|
|
57
|
+
query,
|
|
58
|
+
fragment: anchor,
|
|
59
|
+
...parseDomain(host)
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export default parseUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.19.0-beta.
|
|
3
|
+
"version": "2.19.0-beta.12",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"format": "prettier --write \"*.{html,js}\" \"{sandbox,src,test,scripts}/**/*.{html,js}\"",
|
|
15
15
|
"test": "npm run test:unit && npm run test:scripts && npm run test:functional",
|
|
16
16
|
"test:unit": "karma start --single-run",
|
|
17
|
+
"test:unit:debug": "karma start --browsers=Chrome --single-run=false --debug",
|
|
17
18
|
"test:unit:watch": "karma start",
|
|
18
19
|
"test:unit:saucelabs:local": "karma start karma.saucelabs.conf.js --single-run",
|
|
19
20
|
"test:unit:coverage": "karma start --single-run --reporters spec,coverage",
|
|
@@ -58,15 +59,18 @@
|
|
|
58
59
|
}
|
|
59
60
|
],
|
|
60
61
|
"dependencies": {
|
|
62
|
+
"@adobe/aep-rules-engine": "^2.0.2",
|
|
63
|
+
"@adobe/reactor-cookie": "^1.0.0",
|
|
61
64
|
"@adobe/reactor-load-script": "^1.1.1",
|
|
62
65
|
"@adobe/reactor-object-assign": "^1.0.0",
|
|
63
66
|
"@adobe/reactor-query-string": "^1.0.0",
|
|
64
67
|
"css.escape": "^1.5.1",
|
|
65
68
|
"js-cookie": "2.2.1",
|
|
69
|
+
"parse-uri": "^1.0.7",
|
|
66
70
|
"uuid": "^3.3.2"
|
|
67
71
|
},
|
|
68
72
|
"devDependencies": {
|
|
69
|
-
"@adobe/alloy": "^2.19.0-beta.
|
|
73
|
+
"@adobe/alloy": "^2.19.0-beta.11",
|
|
70
74
|
"@babel/cli": "^7.12.8",
|
|
71
75
|
"@babel/core": "^7.2.2",
|
|
72
76
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|