@adobe/alloy 2.19.0-beta.9 → 2.19.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.
- 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 +36 -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 +130 -0
- package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +46 -0
- package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +87 -0
- package/libEs5/components/DecisioningEngine/index.js +119 -0
- package/libEs5/components/DecisioningEngine/utils.js +90 -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/createFetchDataHandler.js +2 -17
- package/libEs5/components/Personalization/createNotificationHandler.js +33 -0
- package/libEs5/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs5/components/Personalization/createOnDecisionHandler.js +44 -0
- package/libEs5/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs5/components/Personalization/createPreprocessors.js +21 -0
- package/libEs5/components/Personalization/createViewCacheManager.js +9 -2
- package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -1
- package/libEs5/components/Personalization/event.js +25 -22
- package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +76 -0
- package/libEs5/components/Personalization/handlers/createProcessRedirect.js +5 -2
- 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 +20 -7
- package/libEs5/constants/contentType.js +18 -0
- package/libEs5/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +4 -8
- 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/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/libEs6/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +24 -0
- package/libEs6/components/DecisioningEngine/constants.js +25 -0
- package/libEs6/components/DecisioningEngine/createApplyResponse.js +31 -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 +120 -0
- package/libEs6/components/DecisioningEngine/createOnResponseHandler.js +45 -0
- package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +79 -0
- package/libEs6/components/DecisioningEngine/index.js +124 -0
- package/libEs6/components/DecisioningEngine/utils.js +83 -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/createFetchDataHandler.js +3 -18
- package/libEs6/components/Personalization/createNotificationHandler.js +29 -0
- package/libEs6/components/Personalization/createOnClickHandler.js +5 -3
- package/libEs6/components/Personalization/createOnDecisionHandler.js +42 -0
- package/libEs6/components/Personalization/createPersonalizationDetails.js +8 -5
- package/libEs6/components/Personalization/createPreprocessors.js +19 -0
- package/libEs6/components/Personalization/createViewCacheManager.js +12 -3
- package/libEs6/components/Personalization/dom-actions/createRedirect.js +10 -1
- package/libEs6/components/Personalization/event.js +14 -9
- package/libEs6/components/Personalization/handlers/createProcessInAppMessage.js +77 -0
- package/libEs6/components/Personalization/handlers/createProcessRedirect.js +5 -2
- 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 +22 -8
- package/libEs6/{components/Personalization/constants/eventType.js → constants/contentType.js} +3 -4
- package/libEs6/{components/Personalization/constants/propositionEventType.js → constants/decisionProvider.js} +2 -6
- package/libEs6/constants/eventType.js +17 -0
- package/libEs6/constants/handle.js +12 -0
- 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/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,17 @@
|
|
|
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
|
+
|
|
13
|
+
export const DISPLAY = "decisioning.propositionDisplay";
|
|
14
|
+
export const INTERACT = "decisioning.propositionInteract";
|
|
15
|
+
export const TRIGGER = "decisioning.propositionTrigger";
|
|
16
|
+
export const DISMISS = "decisioning.propositionDismiss";
|
|
17
|
+
export const EVENT_TYPE_TRUE = 1;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 const PERSONALIZATION_DECISIONS_HANDLE = "personalization:decisions";
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
|
|
13
|
+
import { DISPLAY, INTERACT, TRIGGER, DISMISS } from "./eventType";
|
|
14
|
+
export const PropositionEventType = {
|
|
15
|
+
DISPLAY: "display",
|
|
16
|
+
INTERACT: "interact",
|
|
17
|
+
TRIGGER: "trigger",
|
|
18
|
+
DISMISS: "dismiss"
|
|
19
|
+
};
|
|
20
|
+
const eventTypeToPropositionEventTypeMapping = {
|
|
21
|
+
[DISPLAY]: PropositionEventType.DISPLAY,
|
|
22
|
+
[INTERACT]: PropositionEventType.INTERACT,
|
|
23
|
+
[TRIGGER]: PropositionEventType.TRIGGER,
|
|
24
|
+
[DISMISS]: PropositionEventType.DISMISS
|
|
25
|
+
};
|
|
26
|
+
const propositionEventTypeToEventTypeMapping = {
|
|
27
|
+
[PropositionEventType.DISPLAY]: DISPLAY,
|
|
28
|
+
[PropositionEventType.INTERACT]: INTERACT,
|
|
29
|
+
[PropositionEventType.TRIGGER]: TRIGGER,
|
|
30
|
+
[PropositionEventType.DISMISS]: DISMISS
|
|
31
|
+
};
|
|
32
|
+
export const getPropositionEventType = eventType => eventTypeToPropositionEventTypeMapping[eventType];
|
|
33
|
+
export const getEventType = propositionEventType => propositionEventTypeToEventTypeMapping[propositionEventType];
|
|
@@ -14,5 +14,9 @@ export const DEFAULT_CONTENT_ITEM = "https://ns.adobe.com/personalization/defaul
|
|
|
14
14
|
export const DOM_ACTION = "https://ns.adobe.com/personalization/dom-action";
|
|
15
15
|
export const HTML_CONTENT_ITEM = "https://ns.adobe.com/personalization/html-content-item";
|
|
16
16
|
export const JSON_CONTENT_ITEM = "https://ns.adobe.com/personalization/json-content-item";
|
|
17
|
+
export const RULESET_ITEM = "https://ns.adobe.com/personalization/ruleset-item";
|
|
17
18
|
export const REDIRECT_ITEM = "https://ns.adobe.com/personalization/redirect-item";
|
|
19
|
+
export const MESSAGE_IN_APP = "https://ns.adobe.com/personalization/message/in-app";
|
|
20
|
+
export const MESSAGE_FEED_ITEM = "https://ns.adobe.com/personalization/message/feed-item";
|
|
21
|
+
export const MESSAGE_NATIVE_ALERT = "https://ns.adobe.com/personalization/message/native-alert";
|
|
18
22
|
export const MEASUREMENT_SCHEMA = "https://ns.adobe.com/personalization/measurement";
|
|
@@ -21,8 +21,9 @@ import createContext from "../components/Context";
|
|
|
21
21
|
import createPrivacy from "../components/Privacy";
|
|
22
22
|
import createEventMerge from "../components/EventMerge";
|
|
23
23
|
import createLibraryInfo from "../components/LibraryInfo";
|
|
24
|
+
import createDecisioningEngine from "../components/DecisioningEngine";
|
|
24
25
|
import createMachineLearning from "../components/MachineLearning";
|
|
25
26
|
|
|
26
27
|
// TODO: Register the Components here statically for now. They might be registered differently.
|
|
27
28
|
// TODO: Figure out how sub-components will be made available/registered
|
|
28
|
-
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning];
|
|
29
|
+
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning, createDecisioningEngine];
|
|
@@ -35,6 +35,23 @@ export default (() => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const event = {
|
|
38
|
+
hasQuery() {
|
|
39
|
+
return Object.prototype.hasOwnProperty.call(this.getContent(), "query");
|
|
40
|
+
},
|
|
41
|
+
getContent() {
|
|
42
|
+
const currentContent = JSON.parse(JSON.stringify(content));
|
|
43
|
+
if (userXdm) {
|
|
44
|
+
deepAssign(currentContent, {
|
|
45
|
+
xdm: userXdm
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (userData) {
|
|
49
|
+
deepAssign(currentContent, {
|
|
50
|
+
data: userData
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return currentContent;
|
|
54
|
+
},
|
|
38
55
|
setUserXdm(value) {
|
|
39
56
|
throwIfEventFinalized("setUserXdm");
|
|
40
57
|
userXdm = value;
|
|
@@ -51,6 +68,14 @@ export default (() => {
|
|
|
51
68
|
});
|
|
52
69
|
}
|
|
53
70
|
},
|
|
71
|
+
mergeData(data) {
|
|
72
|
+
throwIfEventFinalized("mergeData");
|
|
73
|
+
if (data) {
|
|
74
|
+
deepAssign(content, {
|
|
75
|
+
data
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
54
79
|
mergeMeta(meta) {
|
|
55
80
|
throwIfEventFinalized("mergeMeta");
|
|
56
81
|
if (meta) {
|
|
@@ -83,7 +108,7 @@ export default (() => {
|
|
|
83
108
|
content.xdm._experience.decisioning.propositions = newPropositions;
|
|
84
109
|
}
|
|
85
110
|
if (userData) {
|
|
86
|
-
|
|
111
|
+
event.mergeData(userData);
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
// the event should already be considered finalized in case onBeforeEventSend throws an error
|
|
@@ -101,6 +101,7 @@ export default (({
|
|
|
101
101
|
applyResponse(event, options = {}) {
|
|
102
102
|
const {
|
|
103
103
|
renderDecisions = false,
|
|
104
|
+
decisionContext = {},
|
|
104
105
|
responseHeaders = {},
|
|
105
106
|
responseBody = {
|
|
106
107
|
handle: []
|
|
@@ -115,6 +116,7 @@ export default (({
|
|
|
115
116
|
return lifecycle.onBeforeEvent({
|
|
116
117
|
event,
|
|
117
118
|
renderDecisions,
|
|
119
|
+
decisionContext,
|
|
118
120
|
decisionScopes: [PAGE_WIDE_SCOPE],
|
|
119
121
|
personalization,
|
|
120
122
|
onResponse: onResponseCallbackAggregator.add,
|
|
@@ -29,7 +29,10 @@ const hookNames = [
|
|
|
29
29
|
// { response } is passed as the parameter)
|
|
30
30
|
"onRequestFailure",
|
|
31
31
|
// A user clicked on an element.
|
|
32
|
-
"onClick"
|
|
32
|
+
"onClick",
|
|
33
|
+
// Called by DecisioningEngine when a ruleset is satisfied with a list of
|
|
34
|
+
// propositions
|
|
35
|
+
"onDecision"];
|
|
33
36
|
const createHook = (componentRegistry, hookName) => {
|
|
34
37
|
return (...args) => {
|
|
35
38
|
return Promise.all(componentRegistry.getLifecycleCallbacks(hookName).map(callback => {
|
|
@@ -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
|
|
3
|
+
"version": "2.19.0",
|
|
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.19",
|
|
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",
|