@adobe/alloy 2.32.1-beta.0 → 2.33.0-beta.2
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/components.json +9 -0
- package/dist/alloy.js +13696 -12143
- package/dist/alloy.min.js +1 -1
- package/dist/alloyServiceWorker.js +8 -20
- package/dist/alloyServiceWorker.min.js +1 -1
- package/dist/types/browser/src/allOptionalComponents.d.ts +2 -0
- package/dist/types/{core → browser}/src/components/Advertising/constants/index.d.ts +3 -0
- package/dist/types/{core → browser}/src/components/Advertising/handlers/createOnBeforeSendEventHandler.d.ts +4 -1
- package/dist/types/{core → browser}/src/components/Advertising/handlers/sendAdConversion.d.ts +3 -1
- package/dist/types/{core → browser}/src/components/Advertising/handlers/viewThroughHandler.d.ts +3 -1
- package/dist/types/{core → browser}/src/components/Advertising/identities/collectAllIdentities.d.ts +1 -1
- package/dist/types/browser/src/components/Advertising/identities/collectSurferId.d.ts +15 -0
- package/dist/types/browser/src/components/Advertising/identities/createHashedIpHandler.d.ts +9 -0
- package/dist/types/browser/src/components/Advertising/identities/initiateAdvertisingIdentityCall.d.ts +5 -0
- package/dist/types/{core → browser}/src/components/Advertising/utils/helpers.d.ts +14 -0
- package/dist/types/browser/src/components/Advertising/utils/murmurHash128GuavaHex.d.ts +2 -0
- package/dist/types/browser/src/components/Personalization/constants/surface.d.ts +4 -0
- package/dist/types/browser/src/components/Personalization/dom-actions/dom/isDomElement.d.ts +2 -0
- package/dist/types/browser/src/components/Personalization/utils/addRenderAttemptedToDecisions.d.ts +5 -0
- package/dist/types/browser/src/components/Personalization/utils/surfaceUtils.d.ts +3 -0
- package/dist/types/{core → browser}/src/components/PushNotifications/helpers/saveToIndexedDb.d.ts +1 -1
- package/dist/types/{core → browser}/src/components/PushNotifications/index.d.ts +6 -6
- package/dist/types/{core → browser}/src/components/PushNotifications/request/createSendPushSubscriptionPayload.d.ts +2 -2
- package/dist/types/browser/src/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +6 -0
- package/dist/types/{core → browser}/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.d.ts +6 -6
- package/dist/types/{core → browser}/src/components/PushNotifications/types.d.ts +1 -1
- package/dist/types/browser/src/components/componentCreators.d.ts +4 -0
- package/dist/types/browser/src/components/requiredComponentCreators.d.ts +1 -0
- package/dist/types/browser/src/index.d.ts +4 -2
- package/dist/types/browser/src/initializeStandalone.d.ts +4 -0
- package/dist/types/core/src/components/Identity/injectAddQueryStringIdentityToPayload.d.ts +2 -1
- package/dist/types/core/src/components/MediaAnalyticsBridge/createGetInstance.d.ts +1 -1
- package/dist/types/core/src/components/MediaAnalyticsBridge/createMediaHelper.d.ts +7 -56
- package/dist/types/core/src/core/componentCreators.d.ts +0 -4
- package/dist/types/core/src/core/requiredComponentCreators.d.ts +0 -1
- package/dist/types/core/src/types.d.ts +0 -4
- package/dist/utils/createEventMergeId.js +38 -30
- package/dist/utils/deepAssign.js +10 -4
- package/package.json +9 -13
- package/rollup.config.js +9 -15
- package/scripts/alloyBuilder.js +34 -42
- package/scripts/helpers/componentMetadata.js +25 -0
- package/scripts/helpers/generateEntryPoint.js +29 -0
- package/src/allOptionalComponents.js +14 -0
- package/src/components/ActivityCollector/attachClickActivityCollector.js +55 -0
- package/src/components/ActivityCollector/configValidators.js +52 -0
- package/src/components/ActivityCollector/createClickActivityStorage.js +33 -0
- package/src/components/ActivityCollector/createClickedElementProperties.js +224 -0
- package/src/components/ActivityCollector/createGetClickedElementProperties.js +68 -0
- package/src/components/ActivityCollector/createInjectClickedElementProperties.js +80 -0
- package/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +45 -0
- package/src/components/ActivityCollector/createStorePageViewProperties.js +20 -0
- package/src/components/ActivityCollector/getLinkName.js +145 -0
- package/src/components/ActivityCollector/getLinkRegion.js +65 -0
- package/src/components/ActivityCollector/index.js +132 -0
- package/src/components/ActivityCollector/utils/activityMapExtensionEnabled.js +16 -0
- package/src/components/ActivityCollector/utils/createTransientStorage.js +26 -0
- package/src/components/ActivityCollector/utils/determineLinkType.js +27 -0
- package/src/components/ActivityCollector/utils/dom/elementHasClickHandler.js +15 -0
- package/src/components/ActivityCollector/utils/dom/extractDomain.js +20 -0
- package/src/components/ActivityCollector/utils/dom/findClickableElement.js +36 -0
- package/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +25 -0
- package/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +15 -0
- package/src/components/ActivityCollector/utils/dom/isDownloadLink.js +27 -0
- package/src/components/ActivityCollector/utils/dom/isExitLink.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isInputSubmitElement.js +26 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +24 -0
- package/src/components/ActivityCollector/utils/dom/isSupportedTextNode.js +27 -0
- package/src/components/ActivityCollector/utils/hasPageName.js +23 -0
- package/src/components/ActivityCollector/utils/isDifferentDomains.js +19 -0
- package/src/components/ActivityCollector/utils/trimQueryFromUrl.js +31 -0
- package/src/components/ActivityCollector/utils/truncateWhiteSpace.js +22 -0
- package/src/components/ActivityCollector/validateClickCollectionConfig.js +47 -0
- package/src/components/Advertising/configValidators.js +32 -0
- package/src/components/Advertising/constants/index.js +80 -0
- package/src/components/Advertising/createComponent.js +24 -0
- package/src/components/Advertising/handlers/clickThroughHandler.js +94 -0
- package/src/components/Advertising/handlers/createAdConversionHandler.js +50 -0
- package/src/components/Advertising/handlers/createOnBeforeSendEventHandler.js +177 -0
- package/src/components/Advertising/handlers/sendAdConversion.js +74 -0
- package/src/components/Advertising/handlers/viewThroughHandler.js +107 -0
- package/src/components/Advertising/identities/collectAllIdentities.js +57 -0
- package/src/components/Advertising/identities/collectID5Id.js +133 -0
- package/src/components/Advertising/identities/collectRampId.js +265 -0
- package/src/components/Advertising/identities/collectSurferId.js +72 -0
- package/src/components/Advertising/identities/createHashedIpHandler.js +36 -0
- package/src/components/Advertising/identities/initiateAdvertisingIdentityCall.js +153 -0
- package/src/components/Advertising/index.js +109 -0
- package/src/components/Advertising/utils/advertisingCookieManager.js +92 -0
- package/src/components/Advertising/utils/helpers.js +190 -0
- package/src/components/Advertising/utils/murmurHash128GuavaHex.js +195 -0
- package/src/components/Context/createComponent.js +35 -0
- package/src/components/Context/implementationDetails.js +23 -0
- package/src/components/Context/index.js +56 -0
- package/src/components/Context/injectDevice.js +77 -0
- package/src/components/Context/injectEnvironment.js +38 -0
- package/src/components/Context/injectHighEntropyUserAgentHints.js +55 -0
- package/src/components/Context/injectOneTimeAnalyticsReferrer.js +61 -0
- package/src/components/Context/injectPlaceContext.js +38 -0
- package/src/components/Context/injectWeb.js +26 -0
- package/src/components/Personalization/constants/loggerMessage.js +14 -0
- package/src/components/Personalization/constants/scopeType.js +15 -0
- package/src/components/Personalization/constants/surface.js +16 -0
- package/src/components/Personalization/createApplyPropositions.js +136 -0
- package/src/components/Personalization/createClickStorage.js +56 -0
- package/src/components/Personalization/createComponent.js +133 -0
- package/src/components/Personalization/createFetchDataHandler.js +149 -0
- package/src/components/Personalization/createGetPageLocation.js +16 -0
- package/src/components/Personalization/createHandleConsentFlicker.js +22 -0
- package/src/components/Personalization/createInteractionStorage.js +104 -0
- package/src/components/Personalization/createNotificationHandler.js +49 -0
- package/src/components/Personalization/createOnClickHandler.js +102 -0
- package/src/components/Personalization/createOnDecisionHandler.js +98 -0
- package/src/components/Personalization/createPersonalizationDetails.js +138 -0
- package/src/components/Personalization/createSetTargetMigration.js +22 -0
- package/src/components/Personalization/createViewCacheManager.js +101 -0
- package/src/components/Personalization/createViewChangeHandler.js +53 -0
- package/src/components/Personalization/dom-actions/action.js +97 -0
- package/src/components/Personalization/dom-actions/addNonceToInlineStyleElements.js +37 -0
- package/src/components/Personalization/dom-actions/appendHtml.js +42 -0
- package/src/components/Personalization/dom-actions/clicks/collectClicks.js +89 -0
- package/src/components/Personalization/dom-actions/clicks/collectInteractions.js +113 -0
- package/src/components/Personalization/dom-actions/collectInteractions.js +15 -0
- package/src/components/Personalization/dom-actions/createPreprocess.js +21 -0
- package/src/components/Personalization/dom-actions/createRedirect.js +23 -0
- package/src/components/Personalization/dom-actions/dom/createFragment.js +18 -0
- package/src/components/Personalization/dom-actions/dom/getAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getChildNodes.js +23 -0
- package/src/components/Personalization/dom-actions/dom/getChildren.js +23 -0
- package/src/components/Personalization/dom-actions/dom/getElementById.js +21 -0
- package/src/components/Personalization/dom-actions/dom/getFirstChild.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getNextSibling.js +15 -0
- package/src/components/Personalization/dom-actions/dom/getNonce.js +33 -0
- package/src/components/Personalization/dom-actions/dom/getParent.js +15 -0
- package/src/components/Personalization/dom-actions/dom/helperForEq.js +22 -0
- package/src/components/Personalization/dom-actions/dom/index.js +26 -0
- package/src/components/Personalization/dom-actions/dom/insertAfter.js +26 -0
- package/src/components/Personalization/dom-actions/dom/insertBefore.js +25 -0
- package/src/components/Personalization/dom-actions/dom/isDomElement.js +13 -0
- package/src/components/Personalization/dom-actions/dom/matchesSelectorWithEq.js +37 -0
- package/src/components/Personalization/dom-actions/dom/removeAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/selectNodesWithEq.js +101 -0
- package/src/components/Personalization/dom-actions/dom/setAttribute.js +15 -0
- package/src/components/Personalization/dom-actions/dom/setStyle.js +23 -0
- package/src/components/Personalization/dom-actions/dom/util.js +17 -0
- package/src/components/Personalization/dom-actions/images.js +34 -0
- package/src/components/Personalization/dom-actions/index.js +13 -0
- package/src/components/Personalization/dom-actions/initDomActionsModules.js +67 -0
- package/src/components/Personalization/dom-actions/insertHtmlAfter.js +43 -0
- package/src/components/Personalization/dom-actions/insertHtmlBefore.js +40 -0
- package/src/components/Personalization/dom-actions/move.js +28 -0
- package/src/components/Personalization/dom-actions/prependHtml.js +60 -0
- package/src/components/Personalization/dom-actions/rearrangeChildren.js +34 -0
- package/src/components/Personalization/dom-actions/remapCustomCodeOffers.js +33 -0
- package/src/components/Personalization/dom-actions/remapHeadOffers.js +63 -0
- package/src/components/Personalization/dom-actions/replaceHtml.js +20 -0
- package/src/components/Personalization/dom-actions/resize.js +28 -0
- package/src/components/Personalization/dom-actions/scripts.js +106 -0
- package/src/components/Personalization/dom-actions/setAttributes.js +21 -0
- package/src/components/Personalization/dom-actions/setHtml.js +27 -0
- package/src/components/Personalization/dom-actions/setStyles.js +23 -0
- package/src/components/Personalization/dom-actions/setText.js +16 -0
- package/src/components/Personalization/dom-actions/swapImage.js +32 -0
- package/src/components/Personalization/flicker/index.js +106 -0
- package/src/components/Personalization/handlers/createDecorateProposition.js +100 -0
- package/src/components/Personalization/handlers/createProcessDomAction.js +79 -0
- package/src/components/Personalization/handlers/createProcessHtmlContent.js +60 -0
- package/src/components/Personalization/handlers/createProcessInAppMessage.js +91 -0
- package/src/components/Personalization/handlers/createProcessPropositions.js +228 -0
- package/src/components/Personalization/handlers/createProcessRedirect.js +54 -0
- package/src/components/Personalization/handlers/createRenderStatusHandler.js +62 -0
- package/src/components/Personalization/handlers/injectCreateProposition.js +121 -0
- package/src/components/Personalization/handlers/processDefaultContent.js +20 -0
- package/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +309 -0
- package/src/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +18 -0
- package/src/components/Personalization/in-app-message-actions/utils.js +55 -0
- package/src/components/Personalization/index.js +223 -0
- package/src/components/Personalization/utils/addRenderAttemptedToDecisions.js +15 -0
- package/src/components/Personalization/utils/createAsyncArray.js +37 -0
- package/src/components/Personalization/utils/isAuthoringModeEnabled.js +15 -0
- package/src/components/Personalization/utils/metaUtils.js +27 -0
- package/src/components/Personalization/utils/surfaceUtils.js +120 -0
- package/src/components/Personalization/validateApplyPropositionsOptions.js +56 -0
- package/src/components/PushNotifications/helpers/constants.js +16 -0
- package/src/components/PushNotifications/helpers/getPushSubscriptionDetails.js +122 -0
- package/src/components/PushNotifications/helpers/readFromIndexedDb.js +50 -0
- package/src/components/PushNotifications/helpers/saveToIndexedDb.js +64 -0
- package/src/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.js +84 -0
- package/src/components/PushNotifications/helpers/serviceWorkerPushListener.js +72 -0
- package/src/components/PushNotifications/index.js +128 -0
- package/src/components/PushNotifications/request/createSendPushSubscriptionPayload.js +66 -0
- package/src/components/PushNotifications/request/createSendPushSubscriptionRequest.js +35 -0
- package/src/components/PushNotifications/request/makeSendPushSubscriptionRequest.js +98 -0
- package/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.js +154 -0
- package/src/components/PushNotifications/types.js +104 -0
- package/src/components/componentCreators.js +16 -0
- package/src/components/requiredComponentCreators.js +13 -0
- package/src/createEventListeners.js +81 -0
- package/src/index.js +14 -2
- package/src/initializeStandalone.js +34 -0
- package/src/serviceWorker.js +2 -2
- package/src/standalone.js +3 -26
- package/.browserslistrc +0 -2
- package/babel.config.js +0 -76
- package/dist/types/core/src/components/Advertising/identities/collectSurferId.d.ts +0 -2
- package/dist/types/core/src/components/PushNotifications/request/createSendPushSubscriptionRequest.d.ts +0 -6
- package/dist/types/core/src/constants/sessionDataKeys.d.ts +0 -1
- package/scripts/helpers/entryPointGeneratorBabelPlugin.js +0 -101
- /package/dist/types/{core → browser}/src/components/ActivityCollector/attachClickActivityCollector.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/configValidators.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickActivityStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createGetClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createRecallAndInjectClickedElementProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/createStorePageViewProperties.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/getLinkRegion.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/activityMapExtensionEnabled.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/createTransientStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/determineLinkType.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/elementHasClickHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/extractDomain.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/findClickableElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isButtonSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isDownloadLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isExitLink.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isInputSubmitElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedAnchorElement.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/dom/isSupportedTextNode.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/hasPageName.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/isDifferentDomains.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/trimQueryFromUrl.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/utils/truncateWhiteSpace.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/ActivityCollector/validateClickCollectionConfig.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/configValidators.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/handlers/clickThroughHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/handlers/createAdConversionHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/identities/collectID5Id.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/identities/collectRampId.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Advertising/utils/advertisingCookieManager.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/implementationDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectDevice.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectEnvironment.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectHighEntropyUserAgentHints.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectOneTimeAnalyticsReferrer.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectPlaceContext.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Context/injectWeb.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/constants/loggerMessage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/constants/scopeType.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createApplyPropositions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createClickStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createComponent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createFetchDataHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createGetPageLocation.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createHandleConsentFlicker.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createInteractionStorage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createNotificationHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createOnClickHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createOnDecisionHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createPersonalizationDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createSetTargetMigration.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createViewCacheManager.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/createViewChangeHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/action.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/addNonceToInlineStyleElements.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/appendHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/clicks/collectClicks.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/clicks/collectInteractions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/collectInteractions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/createPreprocess.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/createRedirect.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/createFragment.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getChildNodes.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getChildren.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getElementById.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getFirstChild.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getNextSibling.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getNonce.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/getParent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/helperForEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/insertAfter.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/insertBefore.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/matchesSelectorWithEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/removeAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/selectNodesWithEq.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/setAttribute.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/setStyle.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/dom/util.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/images.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/initDomActionsModules.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/insertHtmlAfter.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/insertHtmlBefore.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/move.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/prependHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/rearrangeChildren.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/remapCustomCodeOffers.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/remapHeadOffers.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/replaceHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/resize.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/scripts.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setAttributes.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setHtml.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setStyles.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/setText.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/dom-actions/swapImage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/flicker/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createDecorateProposition.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessDomAction.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessHtmlContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessInAppMessage.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessPropositions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createProcessRedirect.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/createRenderStatusHandler.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/injectCreateProposition.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/handlers/processDefaultContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/actions/displayIframeContent.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/in-app-message-actions/utils.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/index.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/createAsyncArray.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/isAuthoringModeEnabled.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/utils/metaUtils.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/Personalization/validateApplyPropositionsOptions.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/constants.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/getPushSubscriptionDetails.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/readFromIndexedDb.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/serviceWorkerNotificationClickListener.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/helpers/serviceWorkerPushListener.d.ts +0 -0
- /package/dist/types/{core → browser}/src/components/PushNotifications/request/makeSendServiceWorkerTrackingData.d.ts +0 -0
- /package/dist/types/{core → browser}/src/createEventListeners.d.ts +0 -0
- /package/dist/types/core/src/{components/Context → utils}/injectTimestamp.d.ts +0 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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 {
|
|
14
|
+
anyOf,
|
|
15
|
+
boolean,
|
|
16
|
+
literal,
|
|
17
|
+
objectOf,
|
|
18
|
+
string,
|
|
19
|
+
} from "@adobe/alloy-core/utils/validation";
|
|
20
|
+
import createComponent from "./createComponent.js";
|
|
21
|
+
import { initDomActionsModules } from "./dom-actions/index.js";
|
|
22
|
+
import createCollect from "@adobe/alloy-core/utils/createCollect.js";
|
|
23
|
+
import { createHideContainers, createShowContainers } from "./flicker/index.js";
|
|
24
|
+
import createFetchDataHandler from "./createFetchDataHandler.js";
|
|
25
|
+
import collectClicks from "./dom-actions/clicks/collectClicks.js";
|
|
26
|
+
import isAuthoringModeEnabled from "./utils/isAuthoringModeEnabled.js";
|
|
27
|
+
import {
|
|
28
|
+
mergeDecisionsMeta,
|
|
29
|
+
mergeQuery,
|
|
30
|
+
} from "@adobe/alloy-core/utils/event.js";
|
|
31
|
+
import createOnClickHandler from "./createOnClickHandler.js";
|
|
32
|
+
import createViewCacheManager from "./createViewCacheManager.js";
|
|
33
|
+
import createViewChangeHandler from "./createViewChangeHandler.js";
|
|
34
|
+
import createClickStorage from "./createClickStorage.js";
|
|
35
|
+
import createInteractionStorage from "./createInteractionStorage.js";
|
|
36
|
+
import createApplyPropositions from "./createApplyPropositions.js";
|
|
37
|
+
import createGetPageLocation from "./createGetPageLocation.js";
|
|
38
|
+
import createSetTargetMigration from "./createSetTargetMigration.js";
|
|
39
|
+
import remapCustomCodeOffers from "./dom-actions/remapCustomCodeOffers.js";
|
|
40
|
+
import remapHeadOffers from "./dom-actions/remapHeadOffers.js";
|
|
41
|
+
import createPreprocess from "./dom-actions/createPreprocess.js";
|
|
42
|
+
import injectCreateProposition from "./handlers/injectCreateProposition.js";
|
|
43
|
+
import createAsyncArray from "./utils/createAsyncArray.js";
|
|
44
|
+
import * as schema from "@adobe/alloy-core/constants/schema.js";
|
|
45
|
+
import processDefaultContent from "./handlers/processDefaultContent.js";
|
|
46
|
+
import { isPageWideSurface } from "@adobe/alloy-core/utils/surfaceUtils.js";
|
|
47
|
+
import createProcessDomAction from "./handlers/createProcessDomAction.js";
|
|
48
|
+
import createProcessHtmlContent from "./handlers/createProcessHtmlContent.js";
|
|
49
|
+
import createProcessRedirect from "./handlers/createProcessRedirect.js";
|
|
50
|
+
import createProcessPropositions from "./handlers/createProcessPropositions.js";
|
|
51
|
+
import createOnDecisionHandler from "./createOnDecisionHandler.js";
|
|
52
|
+
import createProcessInAppMessage from "./handlers/createProcessInAppMessage.js";
|
|
53
|
+
import initInAppMessageActionsModules from "./in-app-message-actions/initInAppMessageActionsModules.js";
|
|
54
|
+
import createRedirect from "./dom-actions/createRedirect.js";
|
|
55
|
+
import createNotificationHandler from "./createNotificationHandler.js";
|
|
56
|
+
import createHandleConsentFlicker from "./createHandleConsentFlicker.js";
|
|
57
|
+
import collectInteractions from "./dom-actions/clicks/collectInteractions.js";
|
|
58
|
+
import {
|
|
59
|
+
ALWAYS,
|
|
60
|
+
NEVER,
|
|
61
|
+
PROPOSITION_INTERACTION_TYPES,
|
|
62
|
+
} from "@adobe/alloy-core/constants/propositionInteractionType.js";
|
|
63
|
+
import {
|
|
64
|
+
ADOBE_JOURNEY_OPTIMIZER,
|
|
65
|
+
ADOBE_TARGET,
|
|
66
|
+
} from "@adobe/alloy-core/constants/decisionProvider.js";
|
|
67
|
+
|
|
68
|
+
const createPersonalization = ({ config, logger, eventManager, consent }) => {
|
|
69
|
+
const {
|
|
70
|
+
targetMigrationEnabled,
|
|
71
|
+
prehidingStyle,
|
|
72
|
+
autoCollectPropositionInteractions,
|
|
73
|
+
} = config;
|
|
74
|
+
const collect = createCollect({
|
|
75
|
+
eventManager,
|
|
76
|
+
mergeDecisionsMeta,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const showContainers = createShowContainers(logger);
|
|
80
|
+
const hideContainers = createHideContainers(logger);
|
|
81
|
+
|
|
82
|
+
const { storeInteractionMeta, getInteractionMetas } =
|
|
83
|
+
createInteractionStorage();
|
|
84
|
+
|
|
85
|
+
const { storeClickMeta, getClickSelectors, getClickMetas } =
|
|
86
|
+
createClickStorage();
|
|
87
|
+
|
|
88
|
+
const getPageLocation = createGetPageLocation({ window });
|
|
89
|
+
const domActionsModules = initDomActionsModules();
|
|
90
|
+
|
|
91
|
+
const preprocess = createPreprocess([remapHeadOffers, remapCustomCodeOffers]);
|
|
92
|
+
const createProposition = injectCreateProposition({
|
|
93
|
+
preprocess,
|
|
94
|
+
isPageWideSurface,
|
|
95
|
+
});
|
|
96
|
+
const viewCache = createViewCacheManager({ createProposition });
|
|
97
|
+
|
|
98
|
+
const executeRedirect = createRedirect(window);
|
|
99
|
+
const schemaProcessors = {
|
|
100
|
+
[schema.DEFAULT_CONTENT_ITEM]: processDefaultContent,
|
|
101
|
+
[schema.DOM_ACTION]: createProcessDomAction({
|
|
102
|
+
modules: domActionsModules,
|
|
103
|
+
logger,
|
|
104
|
+
storeInteractionMeta,
|
|
105
|
+
storeClickMeta,
|
|
106
|
+
autoCollectPropositionInteractions,
|
|
107
|
+
}),
|
|
108
|
+
[schema.HTML_CONTENT_ITEM]: createProcessHtmlContent({
|
|
109
|
+
modules: domActionsModules,
|
|
110
|
+
logger,
|
|
111
|
+
storeInteractionMeta,
|
|
112
|
+
autoCollectPropositionInteractions,
|
|
113
|
+
}),
|
|
114
|
+
[schema.REDIRECT_ITEM]: createProcessRedirect({
|
|
115
|
+
logger,
|
|
116
|
+
executeRedirect,
|
|
117
|
+
collect,
|
|
118
|
+
}),
|
|
119
|
+
[schema.MESSAGE_IN_APP]: createProcessInAppMessage({
|
|
120
|
+
modules: initInAppMessageActionsModules(collect),
|
|
121
|
+
logger,
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const processPropositions = createProcessPropositions({
|
|
126
|
+
schemaProcessors,
|
|
127
|
+
logger,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const renderedPropositions = createAsyncArray();
|
|
131
|
+
const notificationHandler = createNotificationHandler(
|
|
132
|
+
collect,
|
|
133
|
+
renderedPropositions,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const fetchDataHandler = createFetchDataHandler({
|
|
137
|
+
prehidingStyle,
|
|
138
|
+
showContainers,
|
|
139
|
+
hideContainers,
|
|
140
|
+
mergeQuery,
|
|
141
|
+
processPropositions,
|
|
142
|
+
createProposition,
|
|
143
|
+
notificationHandler,
|
|
144
|
+
consent,
|
|
145
|
+
logger,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const onClickHandler = createOnClickHandler({
|
|
149
|
+
mergeDecisionsMeta,
|
|
150
|
+
collectInteractions,
|
|
151
|
+
collectClicks,
|
|
152
|
+
getInteractionMetas,
|
|
153
|
+
getClickMetas,
|
|
154
|
+
getClickSelectors,
|
|
155
|
+
autoCollectPropositionInteractions,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const viewChangeHandler = createViewChangeHandler({
|
|
159
|
+
processPropositions,
|
|
160
|
+
viewCache,
|
|
161
|
+
logger,
|
|
162
|
+
});
|
|
163
|
+
const applyPropositions = createApplyPropositions({
|
|
164
|
+
processPropositions,
|
|
165
|
+
createProposition,
|
|
166
|
+
renderedPropositions,
|
|
167
|
+
viewCache,
|
|
168
|
+
});
|
|
169
|
+
const setTargetMigration = createSetTargetMigration({
|
|
170
|
+
targetMigrationEnabled,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const onDecisionHandler = createOnDecisionHandler({
|
|
174
|
+
processPropositions,
|
|
175
|
+
createProposition,
|
|
176
|
+
notificationHandler,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const handleConsentFlicker = createHandleConsentFlicker({
|
|
180
|
+
showContainers,
|
|
181
|
+
consent,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return createComponent({
|
|
185
|
+
getPageLocation,
|
|
186
|
+
logger,
|
|
187
|
+
fetchDataHandler,
|
|
188
|
+
viewChangeHandler,
|
|
189
|
+
onClickHandler,
|
|
190
|
+
isAuthoringModeEnabled,
|
|
191
|
+
mergeQuery,
|
|
192
|
+
viewCache,
|
|
193
|
+
showContainers,
|
|
194
|
+
applyPropositions,
|
|
195
|
+
setTargetMigration,
|
|
196
|
+
mergeDecisionsMeta,
|
|
197
|
+
renderedPropositions,
|
|
198
|
+
onDecisionHandler,
|
|
199
|
+
handleConsentFlicker,
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
createPersonalization.namespace = "Personalization";
|
|
204
|
+
|
|
205
|
+
const interactionConfigOptions = PROPOSITION_INTERACTION_TYPES.map(
|
|
206
|
+
(propositionInteractionType) => literal(propositionInteractionType),
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
createPersonalization.configValidators = objectOf({
|
|
210
|
+
prehidingStyle: string().nonEmpty(),
|
|
211
|
+
targetMigrationEnabled: boolean().default(false),
|
|
212
|
+
autoCollectPropositionInteractions: objectOf({
|
|
213
|
+
[ADOBE_JOURNEY_OPTIMIZER]: anyOf(interactionConfigOptions).default(ALWAYS),
|
|
214
|
+
[ADOBE_TARGET]: anyOf(interactionConfigOptions).default(NEVER),
|
|
215
|
+
})
|
|
216
|
+
.default({
|
|
217
|
+
[ADOBE_JOURNEY_OPTIMIZER]: ALWAYS,
|
|
218
|
+
[ADOBE_TARGET]: NEVER,
|
|
219
|
+
})
|
|
220
|
+
.noUnknownFields(),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
export default createPersonalization;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export default ({ decisions, renderAttempted }) => {
|
|
14
|
+
return decisions.map((decision) => ({ renderAttempted, ...decision }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 () => {
|
|
13
|
+
let latest = Promise.resolve([]);
|
|
14
|
+
return {
|
|
15
|
+
concat(promise) {
|
|
16
|
+
latest = latest.then((existingPropositions) => {
|
|
17
|
+
return promise
|
|
18
|
+
.then((newPropositions) => {
|
|
19
|
+
return existingPropositions.concat(newPropositions);
|
|
20
|
+
})
|
|
21
|
+
.catch(() => {
|
|
22
|
+
return existingPropositions;
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Clears the saved propositions, waiting until the next propositions are resolved and available.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<Array>} A promise that resolves to the latest propositions.
|
|
30
|
+
*/
|
|
31
|
+
clear() {
|
|
32
|
+
const oldLatest = latest;
|
|
33
|
+
latest = Promise.resolve([]);
|
|
34
|
+
return oldLatest;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2019 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 default (doc = document) => {
|
|
14
|
+
return doc.location.href.indexOf("adobe_authoring_enabled") !== -1;
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 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 cleanMetas = (metas) =>
|
|
13
|
+
metas.map((meta) => {
|
|
14
|
+
const { trackingLabel, scopeType, ...rest } = meta;
|
|
15
|
+
return rest;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const dedupeMetas = (metas) =>
|
|
19
|
+
metas.filter((meta, index) => {
|
|
20
|
+
const stringifiedMeta = JSON.stringify(meta);
|
|
21
|
+
return (
|
|
22
|
+
index ===
|
|
23
|
+
metas.findIndex(
|
|
24
|
+
(innerMeta) => JSON.stringify(innerMeta) === stringifiedMeta,
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
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 {
|
|
14
|
+
WEB,
|
|
15
|
+
WEBAPP,
|
|
16
|
+
SURFACE_TYPE_DELIMITER,
|
|
17
|
+
FRAGMENT_DELIMITER,
|
|
18
|
+
} from "../constants/surface.js";
|
|
19
|
+
import { isNil, isNonEmptyString } from "@adobe/alloy-core/utils";
|
|
20
|
+
|
|
21
|
+
const SURFACE_REGEX = /^(\w+):\/\/([^/#]+)(\/[^#]*)?(#.*)?$/;
|
|
22
|
+
const AUTHORITY_REGEX =
|
|
23
|
+
/^(?:.*@)?(?:[a-z\d\u00a1-\uffff.-]+|\[[a-f\d:]+])(?::\d+)?$/;
|
|
24
|
+
const PATH_REGEX = /^\/(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})*$/;
|
|
25
|
+
const FRAGMENT_REGEX = /^#(?:[/\w\u00a1-\uffff-.~]|%[a-fA-F\d]{2})+$/;
|
|
26
|
+
|
|
27
|
+
const normalizePath = (path = "/") => {
|
|
28
|
+
let end = path.length;
|
|
29
|
+
while (end > 0 && "/".indexOf(path.charAt(end - 1)) !== -1) {
|
|
30
|
+
end -= 1;
|
|
31
|
+
}
|
|
32
|
+
return path.substring(0, end) || "/";
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getSurfaceType = (surfaceTypeMatch) =>
|
|
36
|
+
isNonEmptyString(surfaceTypeMatch) ? surfaceTypeMatch.toLowerCase() : "";
|
|
37
|
+
|
|
38
|
+
const getAuthority = (authorityMatch) =>
|
|
39
|
+
isNonEmptyString(authorityMatch) ? authorityMatch.toLowerCase() : "";
|
|
40
|
+
|
|
41
|
+
const getPath = (pathMatch) =>
|
|
42
|
+
isNonEmptyString(pathMatch) ? normalizePath(pathMatch) : "/";
|
|
43
|
+
|
|
44
|
+
const parseSurface = (surfaceString) => {
|
|
45
|
+
const matched = surfaceString.match(SURFACE_REGEX);
|
|
46
|
+
return matched
|
|
47
|
+
? {
|
|
48
|
+
surfaceType: getSurfaceType(matched[1]),
|
|
49
|
+
authority: getAuthority(matched[2]),
|
|
50
|
+
path: getPath(matched[3]),
|
|
51
|
+
fragment: matched[4],
|
|
52
|
+
}
|
|
53
|
+
: null;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const stringifySurface = (surface) =>
|
|
57
|
+
`${surface.surfaceType}${SURFACE_TYPE_DELIMITER}${
|
|
58
|
+
surface.authority
|
|
59
|
+
}${surface.path || ""}${surface.fragment || ""}`;
|
|
60
|
+
|
|
61
|
+
export const buildPageSurface = (getPageLocation) => {
|
|
62
|
+
const location = getPageLocation();
|
|
63
|
+
const host = location.host.toLowerCase();
|
|
64
|
+
const path = location.pathname;
|
|
65
|
+
return WEB + SURFACE_TYPE_DELIMITER + host + normalizePath(path);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const expandFragmentSurface = (surface, getPageLocation) =>
|
|
69
|
+
surface.startsWith(FRAGMENT_DELIMITER)
|
|
70
|
+
? buildPageSurface(getPageLocation) + surface
|
|
71
|
+
: surface;
|
|
72
|
+
|
|
73
|
+
const validateSurface = (surface, getPageLocation, logger) => {
|
|
74
|
+
const invalidateSurface = (validationError) => {
|
|
75
|
+
logger.warn(validationError);
|
|
76
|
+
return null;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (!isNonEmptyString(surface)) {
|
|
80
|
+
return invalidateSurface(`Invalid surface: ${surface}`);
|
|
81
|
+
}
|
|
82
|
+
const expanded = expandFragmentSurface(surface, getPageLocation);
|
|
83
|
+
const parsed = parseSurface(expanded);
|
|
84
|
+
if (parsed === null) {
|
|
85
|
+
return invalidateSurface(`Invalid surface: ${surface}`);
|
|
86
|
+
}
|
|
87
|
+
if (![WEB, WEBAPP].includes(parsed.surfaceType)) {
|
|
88
|
+
return invalidateSurface(
|
|
89
|
+
`Unsupported surface type ${parsed.surfaceType} in surface: ${surface}`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (!parsed.authority || !AUTHORITY_REGEX.test(parsed.authority)) {
|
|
93
|
+
return invalidateSurface(
|
|
94
|
+
`Invalid authority ${parsed.authority} in surface: ${surface}`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (parsed.path && !PATH_REGEX.test(parsed.path)) {
|
|
98
|
+
return invalidateSurface(
|
|
99
|
+
`Invalid path ${parsed.path} in surface: ${surface}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (parsed.fragment && !FRAGMENT_REGEX.test(parsed.fragment)) {
|
|
103
|
+
return invalidateSurface(
|
|
104
|
+
`Invalid fragment ${parsed.fragment} in surface: ${surface}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return parsed;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const isPageWideSurface = (scope) =>
|
|
111
|
+
!!scope &&
|
|
112
|
+
scope.indexOf(WEB + SURFACE_TYPE_DELIMITER) === 0 &&
|
|
113
|
+
scope.indexOf(FRAGMENT_DELIMITER) === -1;
|
|
114
|
+
|
|
115
|
+
// eslint-disable-next-line default-param-last
|
|
116
|
+
export const normalizeSurfaces = (surfaces = [], getPageLocation, logger) =>
|
|
117
|
+
surfaces
|
|
118
|
+
.map((surface) => validateSurface(surface, getPageLocation, logger))
|
|
119
|
+
.filter((surface) => !isNil(surface))
|
|
120
|
+
.map(stringifySurface);
|
|
@@ -0,0 +1,56 @@
|
|
|
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 {
|
|
13
|
+
anything,
|
|
14
|
+
objectOf,
|
|
15
|
+
arrayOf,
|
|
16
|
+
string,
|
|
17
|
+
} from "@adobe/alloy-core/utils/validation";
|
|
18
|
+
|
|
19
|
+
export const EMPTY_PROPOSITIONS = { propositions: [] };
|
|
20
|
+
|
|
21
|
+
export default ({ logger, options }) => {
|
|
22
|
+
const applyPropositionsOptionsValidator = objectOf({
|
|
23
|
+
propositions: arrayOf(
|
|
24
|
+
objectOf({
|
|
25
|
+
id: string().required(),
|
|
26
|
+
scope: string().required(),
|
|
27
|
+
scopeDetails: objectOf({
|
|
28
|
+
decisionProvider: string().required(),
|
|
29
|
+
}).required(),
|
|
30
|
+
items: arrayOf(
|
|
31
|
+
objectOf({
|
|
32
|
+
id: string().required(),
|
|
33
|
+
schema: string().required(),
|
|
34
|
+
data: objectOf(anything()),
|
|
35
|
+
}),
|
|
36
|
+
)
|
|
37
|
+
.nonEmpty()
|
|
38
|
+
.required(),
|
|
39
|
+
}).required(),
|
|
40
|
+
)
|
|
41
|
+
.nonEmpty()
|
|
42
|
+
.required(),
|
|
43
|
+
metadata: objectOf(anything()),
|
|
44
|
+
viewName: string(),
|
|
45
|
+
}).required();
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
return applyPropositionsOptionsValidator(options);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
logger.warn(
|
|
51
|
+
"Invalid options for applyPropositions. No propositions will be applied.",
|
|
52
|
+
e,
|
|
53
|
+
);
|
|
54
|
+
return EMPTY_PROPOSITIONS;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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 DB_NAME = "alloyPushNotifications";
|
|
14
|
+
export const DB_VERSION = 1;
|
|
15
|
+
export const STORE_NAME = "config";
|
|
16
|
+
export const INDEX_KEY = "alloyConfig";
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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 { PushSubscription } from '../types.js' */
|
|
14
|
+
|
|
15
|
+
import { base64ToBytes, bytesToBase64 } from "@adobe/alloy-core/utils";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets push subscription details for the current browser.
|
|
19
|
+
*
|
|
20
|
+
* @async
|
|
21
|
+
* @function
|
|
22
|
+
*
|
|
23
|
+
* @param {object} options
|
|
24
|
+
* @param {string} options.vapidPublicKey - The VAPID public key in base64 format used for push notification authentication.
|
|
25
|
+
* @param {Window} options.window
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<PushSubscription>} A promise that resolves to an object containing the push subscription details.
|
|
28
|
+
|
|
29
|
+
* @throws {Error} Throws an error if service workers are not supported in the browser.
|
|
30
|
+
* @throws {Error} Throws an error if user didn't approve push notifications for the domain.
|
|
31
|
+
* @throws {Error} Throws an error if push notifications are not supported in the browser.
|
|
32
|
+
* @throws {Error} Throws an error if no VAPID public key was provided.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Get subscription details with VAPID key
|
|
36
|
+
* const vapidKey = "BEl62iUYgUivxIkv69yViEuiBIa40HI5hmjHbKPlXO...";
|
|
37
|
+
* const subscription = await getPushSubscriptionDetails(vapidKey);
|
|
38
|
+
* console.log(subscription.endpoint); // "https://fcm.googleapis.com/fcm/send/..."
|
|
39
|
+
*/
|
|
40
|
+
const getPushSubscriptionDetails = async ({ vapidPublicKey, window }) => {
|
|
41
|
+
if (!("serviceWorker" in window.navigator)) {
|
|
42
|
+
throw new Error("Service workers are not supported in this browser.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!("PushManager" in window) || !("Notification" in window)) {
|
|
46
|
+
throw new Error("Push notifications are not supported in this browser.");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @type {object} */
|
|
50
|
+
const notification = window.Notification;
|
|
51
|
+
if (notification.permission !== "granted") {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"The user has not given permission to send push notifications.",
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const serviceWorkerRegistration =
|
|
58
|
+
// eslint-disable-next-line compat/compat -- Service worker support is required for push notifications
|
|
59
|
+
await window.navigator.serviceWorker.getRegistration();
|
|
60
|
+
|
|
61
|
+
if (!serviceWorkerRegistration) {
|
|
62
|
+
throw new Error("No service worker registration was found.");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Even `applicationServerKey` is not required in the spec, some browsers like Chrome are requiring it.
|
|
66
|
+
if (!vapidPublicKey) {
|
|
67
|
+
throw new Error("No VAPID public key was provided.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const subscriptionOptions = {
|
|
71
|
+
userVisibleOnly: true,
|
|
72
|
+
applicationServerKey: base64ToBytes(vapidPublicKey),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Push subscription handling strategy:
|
|
76
|
+
//
|
|
77
|
+
// 1. We always call subscribe() to either get the current subscription or create a new one.
|
|
78
|
+
// - If called with the same VAPID key as an existing subscription, it returns that subscription
|
|
79
|
+
// - If called with a different VAPID key when a subscription exists, it throws an error
|
|
80
|
+
//
|
|
81
|
+
// 2. Error handling approach:
|
|
82
|
+
// - Browser error messages vary and don't clearly indicate VAPID key conflicts
|
|
83
|
+
// - When subscribe() fails, we assume it's likely due to a VAPID key mismatch
|
|
84
|
+
// - We attempt recovery by unsubscribing the existing subscription and retrying
|
|
85
|
+
// - If the retry also fails, we re-throw the original error
|
|
86
|
+
//
|
|
87
|
+
// This strategy ensures we can handle both new subscriptions and VAPID key changes
|
|
88
|
+
// while gracefully falling back to error reporting when recovery isn't possible.
|
|
89
|
+
try {
|
|
90
|
+
const subscription =
|
|
91
|
+
await serviceWorkerRegistration.pushManager.subscribe(
|
|
92
|
+
subscriptionOptions,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
endpoint: subscription.endpoint,
|
|
97
|
+
keys: {
|
|
98
|
+
p256dh: bytesToBase64(new Uint8Array(subscription.getKey("p256dh")), {
|
|
99
|
+
urlSafe: true,
|
|
100
|
+
}),
|
|
101
|
+
auth: bytesToBase64(new Uint8Array(subscription.getKey("auth")), {
|
|
102
|
+
urlSafe: true,
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
} catch (e) {
|
|
107
|
+
const subscription =
|
|
108
|
+
await serviceWorkerRegistration.pushManager.getSubscription();
|
|
109
|
+
if (!subscription) {
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const unsubscribeResult = await subscription.unsubscribe();
|
|
114
|
+
if (!unsubscribeResult) {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return getPushSubscriptionDetails({ vapidPublicKey, window });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default getPushSubscriptionDetails;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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 { ServiceWorkerLogger } from '../types.js' */
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
getFromIndexedDbStore,
|
|
17
|
+
openIndexedDb,
|
|
18
|
+
} from "@adobe/alloy-core/utils/indexedDb.js";
|
|
19
|
+
import { DB_NAME, DB_VERSION, STORE_NAME, INDEX_KEY } from "./constants.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {ServiceWorkerLogger} logger
|
|
23
|
+
* @returns {Promise<Object|undefined>}
|
|
24
|
+
* @throws {Error}
|
|
25
|
+
*/
|
|
26
|
+
export default async (logger) => {
|
|
27
|
+
try {
|
|
28
|
+
const db = await openIndexedDb(
|
|
29
|
+
DB_NAME,
|
|
30
|
+
DB_VERSION,
|
|
31
|
+
(/** @type {IDBDatabase} */ db) => {
|
|
32
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
33
|
+
db.createObjectStore(STORE_NAME, { keyPath: "id" });
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const existingConfigData = await getFromIndexedDbStore(
|
|
39
|
+
db,
|
|
40
|
+
STORE_NAME,
|
|
41
|
+
INDEX_KEY,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
db.close();
|
|
45
|
+
|
|
46
|
+
return existingConfigData;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
logger.error("Failed to read data from IndexedDB", { error });
|
|
49
|
+
}
|
|
50
|
+
};
|