@adobe/alloy 2.21.1 → 2.22.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/babel.config.cjs +0 -1
  2. package/libEs5/baseCode/index.js +3 -2
  3. package/libEs5/components/ActivityCollector/attachClickActivityCollector.js +23 -20
  4. package/libEs5/components/ActivityCollector/configValidators.js +2 -2
  5. package/libEs5/components/ActivityCollector/createClickActivityStorage.js +11 -9
  6. package/libEs5/components/ActivityCollector/createClickedElementProperties.js +39 -32
  7. package/libEs5/components/ActivityCollector/createGetClickedElementProperties.js +28 -20
  8. package/libEs5/components/ActivityCollector/createInjectClickedElementProperties.js +24 -21
  9. package/libEs5/components/ActivityCollector/createRecallAndInjectClickedElementProperties.js +10 -8
  10. package/libEs5/components/ActivityCollector/createStorePageViewProperties.js +6 -4
  11. package/libEs5/components/ActivityCollector/getLinkName.js +19 -18
  12. package/libEs5/components/ActivityCollector/getLinkRegion.js +10 -9
  13. package/libEs5/components/ActivityCollector/index.js +61 -45
  14. package/libEs5/components/ActivityCollector/utils/activityMapExtensionEnabled.js +3 -5
  15. package/libEs5/components/ActivityCollector/utils/createTransientStorage.js +7 -6
  16. package/libEs5/components/ActivityCollector/utils/determineLinkType.js +4 -3
  17. package/libEs5/components/ActivityCollector/utils/dom/elementHasClickHandler.js +3 -2
  18. package/libEs5/components/ActivityCollector/utils/dom/extractDomain.js +5 -4
  19. package/libEs5/components/ActivityCollector/utils/dom/findClickableElement.js +4 -3
  20. package/libEs5/components/ActivityCollector/utils/dom/getAbsoluteUrlFromAnchorElement.js +11 -8
  21. package/libEs5/components/ActivityCollector/utils/dom/isButtonSubmitElement.js +3 -2
  22. package/libEs5/components/ActivityCollector/utils/dom/isDownloadLink.js +6 -5
  23. package/libEs5/components/ActivityCollector/utils/dom/isExitLink.js +6 -5
  24. package/libEs5/components/ActivityCollector/utils/dom/isInputSubmitElement.js +4 -3
  25. package/libEs5/components/ActivityCollector/utils/dom/isSupportedAnchorElement.js +3 -2
  26. package/libEs5/components/ActivityCollector/utils/dom/isSupportedTextNode.js +4 -3
  27. package/libEs5/components/ActivityCollector/utils/hasPageName.js +4 -3
  28. package/libEs5/components/ActivityCollector/utils/isDifferentDomains.js +5 -4
  29. package/libEs5/components/ActivityCollector/utils/trimQueryFromUrl.js +5 -4
  30. package/libEs5/components/ActivityCollector/utils/truncateWhiteSpace.js +3 -2
  31. package/libEs5/components/ActivityCollector/utils/urlStartsWithScheme.js +3 -2
  32. package/libEs5/components/Audiences/index.js +13 -12
  33. package/libEs5/components/Audiences/injectProcessDestinations.js +32 -35
  34. package/libEs5/components/Audiences/injectProcessResponse.js +19 -16
  35. package/libEs5/components/Context/createComponent.js +10 -13
  36. package/libEs5/components/Context/implementationDetails.js +5 -4
  37. package/libEs5/components/Context/index.js +24 -28
  38. package/libEs5/components/Context/injectDevice.js +23 -15
  39. package/libEs5/components/Context/injectEnvironment.js +17 -12
  40. package/libEs5/components/Context/injectHighEntropyUserAgentHints.js +12 -21
  41. package/libEs5/components/Context/injectPlaceContext.js +8 -7
  42. package/libEs5/components/Context/injectTimestamp.js +6 -5
  43. package/libEs5/components/Context/injectWeb.js +6 -5
  44. package/libEs5/components/DataCollector/index.js +37 -38
  45. package/libEs5/components/DataCollector/validateApplyResponse.js +6 -4
  46. package/libEs5/components/DataCollector/validateUserEventOptions.js +6 -4
  47. package/libEs5/components/DecisioningEngine/consequenceAdapters/inAppMessageConsequenceAdapter.js +11 -8
  48. package/libEs5/components/DecisioningEngine/consequenceAdapters/schemaTypeConsequenceAdapter.js +10 -7
  49. package/libEs5/components/DecisioningEngine/constants.js +3 -3
  50. package/libEs5/components/DecisioningEngine/createApplyResponse.js +15 -15
  51. package/libEs5/components/DecisioningEngine/createConsequenceAdapter.js +17 -13
  52. package/libEs5/components/DecisioningEngine/createContextProvider.js +48 -44
  53. package/libEs5/components/DecisioningEngine/createDecisionHistory.js +7 -5
  54. package/libEs5/components/DecisioningEngine/createDecisionProvider.js +16 -21
  55. package/libEs5/components/DecisioningEngine/createEvaluableRulesetPayload.js +39 -37
  56. package/libEs5/components/DecisioningEngine/createEvaluateRulesetsCommand.js +21 -19
  57. package/libEs5/components/DecisioningEngine/createEventRegistry.js +63 -67
  58. package/libEs5/components/DecisioningEngine/createOnResponseHandler.js +23 -22
  59. package/libEs5/components/DecisioningEngine/createSubscribeRulesetItems.js +100 -55
  60. package/libEs5/components/DecisioningEngine/index.js +83 -54
  61. package/libEs5/components/DecisioningEngine/utils.js +43 -38
  62. package/libEs5/components/EventMerge/createComponent.js +5 -3
  63. package/libEs5/components/EventMerge/createEventMergeId.js +3 -2
  64. package/libEs5/components/EventMerge/index.js +1 -1
  65. package/libEs5/components/Identity/addEcidQueryToPayload.js +3 -2
  66. package/libEs5/components/Identity/addEcidToPayload.js +3 -2
  67. package/libEs5/components/Identity/appendIdentityToUrl/injectAppendIdentityToUrl.js +13 -23
  68. package/libEs5/components/Identity/configValidators.js +1 -1
  69. package/libEs5/components/Identity/constants/authState.js +3 -3
  70. package/libEs5/components/Identity/createComponent.js +39 -33
  71. package/libEs5/components/Identity/createLegacyIdentity.js +29 -29
  72. package/libEs5/components/Identity/getEcidFromResponse.js +5 -7
  73. package/libEs5/components/Identity/getIdentity/createGetIdentity.js +17 -15
  74. package/libEs5/components/Identity/getIdentity/createIdentityRequest.js +10 -8
  75. package/libEs5/components/Identity/getIdentity/createIdentityRequestPayload.js +5 -4
  76. package/libEs5/components/Identity/index.js +61 -62
  77. package/libEs5/components/Identity/injectAddLegacyEcidToPayload.js +8 -6
  78. package/libEs5/components/Identity/injectAddQueryStringIdentityToPayload.js +46 -52
  79. package/libEs5/components/Identity/injectAwaitIdentityCookie.js +14 -11
  80. package/libEs5/components/Identity/injectEnsureSingleIdentity.js +25 -24
  81. package/libEs5/components/Identity/injectHandleResponseForIdSyncs.js +6 -4
  82. package/libEs5/components/Identity/injectProcessIdSyncs.js +20 -22
  83. package/libEs5/components/Identity/injectSetDomainForInitialIdentityPayload.js +7 -5
  84. package/libEs5/components/Identity/visitorService/awaitVisitorOptIn.js +8 -6
  85. package/libEs5/components/Identity/visitorService/getVisitor.js +4 -3
  86. package/libEs5/components/Identity/visitorService/injectGetEcidFromVisitor.js +15 -13
  87. package/libEs5/components/LegacyMediaAnalytics/constants/constants.js +9 -9
  88. package/libEs5/components/LegacyMediaAnalytics/constants/mediaKeysToXdmConverter.js +2 -2
  89. package/libEs5/components/LegacyMediaAnalytics/createGetInstance.js +61 -63
  90. package/libEs5/components/LegacyMediaAnalytics/createLegacyMediaComponent.js +38 -37
  91. package/libEs5/components/LegacyMediaAnalytics/createMediaHelper.js +54 -52
  92. package/libEs5/components/LegacyMediaAnalytics/index.js +32 -33
  93. package/libEs5/components/LibraryInfo/index.js +23 -30
  94. package/libEs5/components/MachineLearning/index.js +1 -1
  95. package/libEs5/components/MachineLearning/processResponse.js +5 -3
  96. package/libEs5/components/Personalization/constants/loggerMessage.js +2 -2
  97. package/libEs5/components/Personalization/constants/scopeType.js +3 -3
  98. package/libEs5/components/Personalization/constants/surface.js +4 -4
  99. package/libEs5/components/Personalization/createActionsProvider.js +37 -32
  100. package/libEs5/components/Personalization/createApplyPropositions.js +71 -81
  101. package/libEs5/components/Personalization/createClickStorage.js +30 -32
  102. package/libEs5/components/Personalization/createComponent.js +65 -74
  103. package/libEs5/components/Personalization/createFetchDataHandler.js +83 -52
  104. package/libEs5/components/Personalization/createGetPageLocation.js +6 -6
  105. package/libEs5/components/Personalization/createHandleConsentFlicker.js +15 -14
  106. package/libEs5/components/Personalization/createInteractionStorage.js +25 -39
  107. package/libEs5/components/Personalization/createNotificationHandler.js +9 -10
  108. package/libEs5/components/Personalization/createOnClickHandler.js +29 -25
  109. package/libEs5/components/Personalization/createOnDecisionHandler.js +23 -21
  110. package/libEs5/components/Personalization/createPersonalizationDetails.js +39 -45
  111. package/libEs5/components/Personalization/createPreprocessors.js +7 -7
  112. package/libEs5/components/Personalization/createSetTargetMigration.js +6 -4
  113. package/libEs5/components/Personalization/createViewCacheManager.js +29 -32
  114. package/libEs5/components/Personalization/createViewChangeHandler.js +35 -20
  115. package/libEs5/components/Personalization/dom-actions/action.js +24 -25
  116. package/libEs5/components/Personalization/dom-actions/addNonceToInlineStyleElements.js +12 -13
  117. package/libEs5/components/Personalization/dom-actions/appendHtml.js +8 -7
  118. package/libEs5/components/Personalization/dom-actions/clicks/collectClicks.js +28 -33
  119. package/libEs5/components/Personalization/dom-actions/clicks/collectInteractions.js +37 -40
  120. package/libEs5/components/Personalization/dom-actions/collectInteractions.js +3 -2
  121. package/libEs5/components/Personalization/dom-actions/createPreprocess.js +10 -11
  122. package/libEs5/components/Personalization/dom-actions/createRedirect.js +11 -13
  123. package/libEs5/components/Personalization/dom-actions/dom/createFragment.js +3 -2
  124. package/libEs5/components/Personalization/dom-actions/dom/getAttribute.js +3 -2
  125. package/libEs5/components/Personalization/dom-actions/dom/getChildNodes.js +6 -3
  126. package/libEs5/components/Personalization/dom-actions/dom/getChildren.js +6 -3
  127. package/libEs5/components/Personalization/dom-actions/dom/getElementById.js +3 -3
  128. package/libEs5/components/Personalization/dom-actions/dom/getFirstChild.js +3 -2
  129. package/libEs5/components/Personalization/dom-actions/dom/getNextSibling.js +3 -2
  130. package/libEs5/components/Personalization/dom-actions/dom/getNonce.js +7 -6
  131. package/libEs5/components/Personalization/dom-actions/dom/getParent.js +3 -2
  132. package/libEs5/components/Personalization/dom-actions/dom/helperForEq.js +7 -7
  133. package/libEs5/components/Personalization/dom-actions/dom/index.js +14 -14
  134. package/libEs5/components/Personalization/dom-actions/dom/insertAfter.js +4 -3
  135. package/libEs5/components/Personalization/dom-actions/dom/insertBefore.js +4 -3
  136. package/libEs5/components/Personalization/dom-actions/dom/isDomElement.js +2 -3
  137. package/libEs5/components/Personalization/dom-actions/dom/matchesSelectorWithEq.js +6 -5
  138. package/libEs5/components/Personalization/dom-actions/dom/removeAttribute.js +3 -2
  139. package/libEs5/components/Personalization/dom-actions/dom/selectNodesWithEq.js +39 -38
  140. package/libEs5/components/Personalization/dom-actions/dom/setAttribute.js +3 -2
  141. package/libEs5/components/Personalization/dom-actions/dom/setStyle.js +4 -3
  142. package/libEs5/components/Personalization/dom-actions/images.js +10 -9
  143. package/libEs5/components/Personalization/dom-actions/index.js +1 -1
  144. package/libEs5/components/Personalization/dom-actions/initDomActionsModules.js +40 -25
  145. package/libEs5/components/Personalization/dom-actions/insertHtmlAfter.js +9 -8
  146. package/libEs5/components/Personalization/dom-actions/insertHtmlBefore.js +8 -7
  147. package/libEs5/components/Personalization/dom-actions/prependHtml.js +13 -10
  148. package/libEs5/components/Personalization/dom-actions/rearrangeChildren.js +9 -7
  149. package/libEs5/components/Personalization/dom-actions/remapCustomCodeOffers.js +14 -9
  150. package/libEs5/components/Personalization/dom-actions/remapHeadOffers.js +16 -14
  151. package/libEs5/components/Personalization/dom-actions/replaceHtml.js +4 -3
  152. package/libEs5/components/Personalization/dom-actions/scripts.js +58 -38
  153. package/libEs5/components/Personalization/dom-actions/setAttributes.js +4 -3
  154. package/libEs5/components/Personalization/dom-actions/setHtml.js +5 -4
  155. package/libEs5/components/Personalization/dom-actions/setStyles.js +8 -8
  156. package/libEs5/components/Personalization/dom-actions/setText.js +3 -2
  157. package/libEs5/components/Personalization/dom-actions/swapImage.js +3 -2
  158. package/libEs5/components/Personalization/flicker/index.js +66 -49
  159. package/libEs5/components/Personalization/handlers/createDecorateProposition.js +16 -13
  160. package/libEs5/components/Personalization/handlers/createProcessDomAction.js +45 -50
  161. package/libEs5/components/Personalization/handlers/createProcessHtmlContent.js +30 -29
  162. package/libEs5/components/Personalization/handlers/createProcessInAppMessage.js +35 -31
  163. package/libEs5/components/Personalization/handlers/createProcessPropositions.js +109 -105
  164. package/libEs5/components/Personalization/handlers/createProcessRedirect.js +38 -28
  165. package/libEs5/components/Personalization/handlers/injectCreateProposition.js +59 -67
  166. package/libEs5/components/Personalization/handlers/processDefaultContent.js +3 -2
  167. package/libEs5/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +140 -121
  168. package/libEs5/components/Personalization/in-app-message-actions/initInAppMessageActionsModules.js +4 -5
  169. package/libEs5/components/Personalization/in-app-message-actions/utils.js +23 -19
  170. package/libEs5/components/Personalization/index.js +120 -103
  171. package/libEs5/components/Personalization/utils/addRenderAttemptedToDecisions.js +10 -10
  172. package/libEs5/components/Personalization/utils/createAsyncArray.js +10 -9
  173. package/libEs5/components/Personalization/utils/isAuthoringModeEnabled.js +3 -3
  174. package/libEs5/components/Personalization/utils/metaUtils.js +14 -19
  175. package/libEs5/components/Personalization/utils/surfaceUtils.js +27 -46
  176. package/libEs5/components/Personalization/validateApplyPropositionsOptions.js +8 -6
  177. package/libEs5/components/Privacy/computeConsentHash.js +9 -9
  178. package/libEs5/components/Privacy/createComponent.js +32 -32
  179. package/libEs5/components/Privacy/createConsentHashStore.js +27 -24
  180. package/libEs5/components/Privacy/createConsentRequest.js +10 -8
  181. package/libEs5/components/Privacy/createConsentRequestPayload.js +9 -8
  182. package/libEs5/components/Privacy/createStoredConsent.js +11 -9
  183. package/libEs5/components/Privacy/index.js +26 -23
  184. package/libEs5/components/Privacy/injectSendSetConsentRequest.js +30 -29
  185. package/libEs5/components/Privacy/parseConsentCookie.js +6 -14
  186. package/libEs5/components/StreamingMedia/createMediaEventManager.js +59 -45
  187. package/libEs5/components/StreamingMedia/createMediaRequest.js +8 -6
  188. package/libEs5/components/StreamingMedia/createMediaResponseHandler.js +22 -17
  189. package/libEs5/components/StreamingMedia/createMediaSessionCacheManager.js +22 -18
  190. package/libEs5/components/StreamingMedia/createStreamingMediaComponent.js +30 -29
  191. package/libEs5/components/StreamingMedia/createTrackMediaEvent.js +41 -36
  192. package/libEs5/components/StreamingMedia/createTrackMediaSession.js +25 -22
  193. package/libEs5/components/StreamingMedia/index.js +33 -34
  194. package/libEs5/components/StreamingMedia/validateMediaEventOptions.js +9 -12
  195. package/libEs5/components/StreamingMedia/validateMediaSessionOptions.js +6 -4
  196. package/libEs5/constants/browser.js +7 -7
  197. package/libEs5/constants/consentPurpose.js +1 -1
  198. package/libEs5/constants/consentStatus.js +3 -3
  199. package/libEs5/constants/contentType.js +2 -2
  200. package/libEs5/constants/cookieNameKey.js +3 -3
  201. package/libEs5/constants/coreCommands.js +2 -2
  202. package/libEs5/constants/decisionProvider.js +4 -3
  203. package/libEs5/constants/domain.js +2 -2
  204. package/libEs5/constants/elementAttribute.js +1 -1
  205. package/libEs5/constants/eventType.js +5 -5
  206. package/libEs5/constants/handle.js +1 -1
  207. package/libEs5/constants/httpHeaderNames.js +2 -2
  208. package/libEs5/constants/httpStatusCode.js +5 -5
  209. package/libEs5/constants/identityMapAuthenticatedState.js +3 -3
  210. package/libEs5/constants/legacyCookies.js +3 -3
  211. package/libEs5/constants/libraryVersion.js +1 -1
  212. package/libEs5/constants/propositionEventType.js +18 -12
  213. package/libEs5/constants/propositionInteractionType.js +4 -4
  214. package/libEs5/constants/schema.js +11 -11
  215. package/libEs5/constants/sessionDataKeys.js +1 -1
  216. package/libEs5/constants/tagName.js +7 -7
  217. package/libEs5/core/buildAndValidateConfig.js +55 -69
  218. package/libEs5/core/componentCreators.js +70 -41
  219. package/libEs5/core/config/createConfig.js +4 -3
  220. package/libEs5/core/config/createCoreConfigs.js +11 -12
  221. package/libEs5/core/consent/createConsent.js +16 -14
  222. package/libEs5/core/consent/createConsentStateMachine.js +27 -35
  223. package/libEs5/core/createComponentRegistry.js +28 -27
  224. package/libEs5/core/createCookieTransfer.js +18 -18
  225. package/libEs5/core/createEvent.js +39 -44
  226. package/libEs5/core/createEventManager.js +64 -69
  227. package/libEs5/core/createInstanceFunction.js +4 -11
  228. package/libEs5/core/createLifecycle.js +14 -19
  229. package/libEs5/core/createLogController.js +30 -29
  230. package/libEs5/core/createLogger.js +41 -27
  231. package/libEs5/core/edgeNetwork/handleRequestFailure.js +6 -5
  232. package/libEs5/core/edgeNetwork/injectApplyResponse.js +29 -32
  233. package/libEs5/core/edgeNetwork/injectExtractEdgeInfo.js +19 -25
  234. package/libEs5/core/edgeNetwork/injectGetLocationHint.js +11 -11
  235. package/libEs5/core/edgeNetwork/injectProcessWarningsAndErrors.js +20 -16
  236. package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +42 -38
  237. package/libEs5/core/edgeNetwork/mergeLifecycleResponses.js +8 -12
  238. package/libEs5/core/index.js +137 -133
  239. package/libEs5/core/initializeComponents.js +17 -15
  240. package/libEs5/core/injectCreateResponse.js +47 -53
  241. package/libEs5/core/injectExecuteCommand.js +39 -40
  242. package/libEs5/core/injectHandleError.js +19 -19
  243. package/libEs5/core/injectShouldTransferCookie.js +12 -12
  244. package/libEs5/core/network/getRequestRetryDelay.js +20 -18
  245. package/libEs5/core/network/injectSendNetworkRequest.js +46 -49
  246. package/libEs5/core/network/isRequestRetryable.js +9 -8
  247. package/libEs5/core/network/requestMethods/injectSendBeaconRequest.js +10 -8
  248. package/libEs5/core/network/requestMethods/injectSendFetchRequest.js +18 -19
  249. package/libEs5/core/requiredComponentCreators.js +23 -0
  250. package/libEs5/core/validateCommandOptions.js +14 -11
  251. package/libEs5/index.js +43 -22
  252. package/libEs5/standalone.js +6 -1
  253. package/libEs5/utils/areThirdPartyCookiesSupportedByDefault.js +3 -5
  254. package/libEs5/utils/assignConcatArrayValues.js +9 -18
  255. package/libEs5/utils/clone.js +2 -3
  256. package/libEs5/utils/cookieJar.js +4 -4
  257. package/libEs5/utils/crc32.js +8 -8
  258. package/libEs5/utils/createCallbackAggregator.js +7 -11
  259. package/libEs5/utils/createCollect.js +52 -0
  260. package/libEs5/utils/createLoggingCookieJar.js +14 -16
  261. package/libEs5/utils/createMerger.js +9 -10
  262. package/libEs5/utils/createSubscription.js +48 -48
  263. package/libEs5/utils/createTaskQueue.js +8 -7
  264. package/libEs5/utils/deduplicateArray.js +7 -11
  265. package/libEs5/utils/deepAssign.js +7 -11
  266. package/libEs5/utils/defer.js +5 -4
  267. package/libEs5/utils/dom/appendNode.js +3 -2
  268. package/libEs5/utils/dom/awaitSelector.js +36 -34
  269. package/libEs5/utils/dom/createNode.js +10 -15
  270. package/libEs5/utils/dom/index.js +8 -8
  271. package/libEs5/utils/dom/isShadowSelector.js +2 -3
  272. package/libEs5/utils/dom/matchesSelector.js +3 -2
  273. package/libEs5/utils/dom/querySelectorAll.js +5 -13
  274. package/libEs5/utils/dom/removeNode.js +4 -3
  275. package/libEs5/utils/dom/selectNodes.js +3 -3
  276. package/libEs5/utils/dom/selectNodesWithShadow.js +14 -23
  277. package/libEs5/utils/event.js +49 -0
  278. package/libEs5/utils/filterObject.js +14 -12
  279. package/libEs5/utils/fireImage.js +10 -9
  280. package/libEs5/utils/flattenArray.js +4 -11
  281. package/libEs5/utils/flattenObject.js +8 -18
  282. package/libEs5/utils/getApexDomain.js +7 -6
  283. package/libEs5/utils/getBrowser.js +45 -12
  284. package/libEs5/utils/getLastArrayItems.js +2 -3
  285. package/libEs5/utils/getNamespacedCookieName.js +2 -3
  286. package/libEs5/utils/groupBy.js +6 -5
  287. package/libEs5/utils/index.js +50 -113
  288. package/libEs5/utils/injectDoesIdentityCookieExist.js +7 -7
  289. package/libEs5/utils/injectFireReferrerHideableImage.js +28 -34
  290. package/libEs5/utils/injectStorage.js +13 -15
  291. package/libEs5/utils/intersection.js +2 -6
  292. package/libEs5/utils/isBlankString.js +2 -3
  293. package/libEs5/utils/isBoolean.js +2 -3
  294. package/libEs5/utils/isEmptyObject.js +2 -3
  295. package/libEs5/utils/isFunction.js +2 -3
  296. package/libEs5/utils/isInteger.js +4 -3
  297. package/libEs5/utils/isNamespacedCookieName.js +2 -3
  298. package/libEs5/utils/isNil.js +2 -3
  299. package/libEs5/utils/isNonEmptyArray.js +2 -3
  300. package/libEs5/utils/isNonEmptyString.js +2 -3
  301. package/libEs5/utils/isNumber.js +2 -4
  302. package/libEs5/utils/isObject.js +3 -4
  303. package/libEs5/utils/isString.js +2 -3
  304. package/libEs5/utils/isUnique.js +6 -5
  305. package/libEs5/utils/isValidRegExp.js +3 -2
  306. package/libEs5/utils/memoize.js +7 -6
  307. package/libEs5/utils/noop.js +2 -1
  308. package/libEs5/utils/parseUrl.js +19 -25
  309. package/libEs5/utils/prepareConfigOverridesForEdge.js +6 -5
  310. package/libEs5/utils/request/createAddIdentity.js +4 -3
  311. package/libEs5/utils/request/createDataCollectionRequest.js +15 -11
  312. package/libEs5/utils/request/createDataCollectionRequestPayload.js +9 -10
  313. package/libEs5/utils/request/createGetAssuranceValidationTokenParams.js +17 -15
  314. package/libEs5/utils/request/createHasIdentity.js +4 -5
  315. package/libEs5/utils/request/createRequest.js +26 -23
  316. package/libEs5/utils/request/createRequestParams.js +13 -13
  317. package/libEs5/utils/request/createRequestPayload.js +13 -12
  318. package/libEs5/utils/request/index.js +8 -8
  319. package/libEs5/utils/sanitizeOrgIdForCookieName.js +2 -3
  320. package/libEs5/utils/stackError.js +8 -6
  321. package/libEs5/utils/stringToBoolean.js +3 -2
  322. package/libEs5/utils/toArray.js +3 -2
  323. package/libEs5/utils/toError.js +3 -2
  324. package/libEs5/utils/toISOStringLocal.js +29 -14
  325. package/libEs5/utils/toInteger.js +5 -5
  326. package/libEs5/utils/updateErrorMessage.js +6 -4
  327. package/libEs5/utils/validation/booleanValidator.js +3 -2
  328. package/libEs5/utils/validation/callbackValidator.js +3 -2
  329. package/libEs5/utils/validation/createAnyOfValidator.js +14 -17
  330. package/libEs5/utils/validation/createArrayOfValidator.js +16 -18
  331. package/libEs5/utils/validation/createDefaultValidator.js +7 -8
  332. package/libEs5/utils/validation/createDeprecatedValidator.js +12 -14
  333. package/libEs5/utils/validation/createLiteralValidator.js +5 -6
  334. package/libEs5/utils/validation/createMapOfValuesValidator.js +20 -22
  335. package/libEs5/utils/validation/createMaximumValidator.js +5 -6
  336. package/libEs5/utils/validation/createMinimumValidator.js +5 -6
  337. package/libEs5/utils/validation/createNoUnknownFieldsValidator.js +13 -14
  338. package/libEs5/utils/validation/createNonEmptyValidator.js +9 -10
  339. package/libEs5/utils/validation/createObjectOfValidator.js +27 -29
  340. package/libEs5/utils/validation/createRenamedValidator.js +24 -27
  341. package/libEs5/utils/validation/createUniqueItemsValidator.js +4 -3
  342. package/libEs5/utils/validation/createUniqueValidator.js +5 -4
  343. package/libEs5/utils/validation/domainValidator.js +4 -3
  344. package/libEs5/utils/validation/index.js +66 -72
  345. package/libEs5/utils/validation/integerValidator.js +3 -2
  346. package/libEs5/utils/validation/matchesRegexpValidator.js +5 -6
  347. package/libEs5/utils/validation/numberValidator.js +3 -2
  348. package/libEs5/utils/validation/regexpValidator.js +3 -2
  349. package/libEs5/utils/validation/requiredValidator.js +3 -2
  350. package/libEs5/utils/validation/stringValidator.js +3 -2
  351. package/libEs5/utils/validation/utils.js +29 -35
  352. package/libEs6/components/ActivityCollector/index.js +18 -8
  353. package/libEs6/components/Context/createComponent.js +1 -3
  354. package/libEs6/components/DecisioningEngine/createApplyResponse.js +1 -1
  355. package/libEs6/components/DecisioningEngine/createSubscribeRulesetItems.js +78 -28
  356. package/libEs6/components/DecisioningEngine/index.js +22 -2
  357. package/libEs6/components/DecisioningEngine/utils.js +2 -9
  358. package/libEs6/components/Identity/createComponent.js +4 -2
  359. package/libEs6/components/Identity/getEcidFromResponse.js +1 -3
  360. package/libEs6/components/LegacyMediaAnalytics/createGetInstance.js +2 -2
  361. package/libEs6/components/LibraryInfo/index.js +4 -5
  362. package/libEs6/components/Personalization/createActionsProvider.js +4 -2
  363. package/libEs6/components/Personalization/createComponent.js +2 -2
  364. package/libEs6/components/Personalization/createFetchDataHandler.js +35 -1
  365. package/libEs6/components/Personalization/createPersonalizationDetails.js +6 -6
  366. package/libEs6/components/Personalization/createViewCacheManager.js +5 -2
  367. package/libEs6/components/Personalization/createViewChangeHandler.js +11 -1
  368. package/libEs6/components/Personalization/dom-actions/createPreprocess.js +5 -2
  369. package/libEs6/components/Personalization/dom-actions/dom/selectNodesWithEq.js +1 -3
  370. package/libEs6/components/Personalization/dom-actions/remapCustomCodeOffers.js +6 -4
  371. package/libEs6/components/Personalization/dom-actions/remapHeadOffers.js +3 -2
  372. package/libEs6/components/Personalization/dom-actions/scripts.js +18 -2
  373. package/libEs6/components/Personalization/flicker/index.js +44 -30
  374. package/libEs6/components/Personalization/handlers/createDecorateProposition.js +2 -2
  375. package/libEs6/components/Personalization/handlers/createProcessPropositions.js +29 -9
  376. package/libEs6/components/Personalization/handlers/createProcessRedirect.js +9 -0
  377. package/libEs6/components/Personalization/handlers/injectCreateProposition.js +0 -3
  378. package/libEs6/components/Personalization/in-app-message-actions/actions/displayIframeContent.js +8 -5
  379. package/libEs6/components/Personalization/in-app-message-actions/utils.js +2 -2
  380. package/libEs6/components/Personalization/index.js +9 -5
  381. package/libEs6/components/Personalization/utils/addRenderAttemptedToDecisions.js +4 -4
  382. package/libEs6/components/Personalization/utils/surfaceUtils.js +3 -3
  383. package/libEs6/constants/decisionProvider.js +1 -0
  384. package/libEs6/constants/libraryVersion.js +1 -1
  385. package/libEs6/constants/schema.js +1 -1
  386. package/libEs6/core/buildAndValidateConfig.js +8 -5
  387. package/libEs6/core/componentCreators.js +14 -43
  388. package/libEs6/core/config/createConfig.js +3 -2
  389. package/libEs6/core/createCookieTransfer.js +1 -3
  390. package/libEs6/core/createInstanceFunction.js +1 -9
  391. package/libEs6/core/createLogger.js +17 -2
  392. package/libEs6/core/edgeNetwork/injectExtractEdgeInfo.js +1 -7
  393. package/libEs6/core/index.js +11 -10
  394. package/libEs6/core/injectCreateResponse.js +1 -3
  395. package/libEs6/core/network/isRequestRetryable.js +1 -2
  396. package/libEs6/core/network/requestMethods/injectSendFetchRequest.js +1 -2
  397. package/libEs6/{utils/assignIf.js → core/requiredComponentCreators.js} +4 -8
  398. package/libEs6/index.js +26 -6
  399. package/libEs6/standalone.js +7 -1
  400. package/libEs6/utils/areThirdPartyCookiesSupportedByDefault.js +1 -2
  401. package/libEs6/utils/assignConcatArrayValues.js +1 -2
  402. package/libEs6/utils/cookieJar.js +4 -4
  403. package/libEs6/{components/Personalization → utils}/createCollect.js +3 -3
  404. package/libEs6/utils/createSubscription.js +20 -3
  405. package/libEs6/utils/dom/querySelectorAll.js +1 -10
  406. package/libEs6/utils/dom/selectNodesWithShadow.js +2 -12
  407. package/libEs6/{components/Personalization → utils}/event.js +1 -1
  408. package/libEs6/utils/index.js +1 -10
  409. package/libEs6/utils/injectStorage.js +1 -2
  410. package/libEs6/utils/intersection.js +1 -4
  411. package/libEs6/utils/isNumber.js +1 -2
  412. package/libEs6/utils/toISOStringLocal.js +14 -1
  413. package/libEs6/utils/toInteger.js +1 -2
  414. package/libEs6/utils/validation/createAnyOfValidator.js +1 -2
  415. package/libEs6/utils/validation/utils.js +3 -6
  416. package/package.json +35 -37
  417. package/rollup.config.js +115 -7
  418. package/scripts/alloyBuilder.js +89 -55
  419. package/scripts/helpers/entryPointGeneratorBabelPlugin.js +39 -0
  420. package/libEs5/components/Personalization/createCollect.js +0 -53
  421. package/libEs5/components/Personalization/event.js +0 -49
  422. package/libEs5/core/network/requestMethods/injectSendXhrRequest.js +0 -50
  423. package/libEs5/utils/assign.js +0 -16
  424. package/libEs5/utils/assignIf.js +0 -21
  425. package/libEs5/utils/endsWith.js +0 -23
  426. package/libEs5/utils/find.js +0 -30
  427. package/libEs5/utils/flatMap.js +0 -17
  428. package/libEs5/utils/includes.js +0 -23
  429. package/libEs5/utils/padStart.js +0 -27
  430. package/libEs5/utils/startsWith.js +0 -23
  431. package/libEs5/utils/values.js +0 -25
  432. package/libEs6/core/network/requestMethods/injectSendXhrRequest.js +0 -49
  433. package/libEs6/utils/assign.js +0 -14
  434. package/libEs6/utils/endsWith.js +0 -19
  435. package/libEs6/utils/find.js +0 -28
  436. package/libEs6/utils/flatMap.js +0 -14
  437. package/libEs6/utils/includes.js +0 -21
  438. package/libEs6/utils/padStart.js +0 -25
  439. package/libEs6/utils/startsWith.js +0 -19
  440. package/libEs6/utils/values.js +0 -21
  441. package/scripts/helpers/alloyComponents.js +0 -63
  442. package/scripts/helpers/conditionalBuildBabelPlugin.js +0 -57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.21.1",
3
+ "version": "2.22.0-alpha.1",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "type": "module",
6
6
  "main": "libEs5/index.js",
@@ -11,8 +11,7 @@
11
11
  "LICENSE_BANNER",
12
12
  "babel.config.cjs",
13
13
  "rollup.config.js",
14
- "scripts/helpers/alloyComponents.js",
15
- "scripts/helpers/conditionalBuildBabelPlugin.js",
14
+ "scripts/helpers/entryPointGeneratorBabelPlugin.js",
16
15
  "scripts/helpers/versionBabelPlugin.js"
17
16
  ],
18
17
  "bin": {
@@ -20,8 +19,8 @@
20
19
  },
21
20
  "scripts": {
22
21
  "clean": "rimraf dist distTest libEs5 libEs6",
23
- "lint": "eslint --cache --fix \"*.js\" \"{src,test,scripts}/**/*.js\"",
24
- "format": "prettier --write \"*.{html,js}\" \"{sandbox,src,test,scripts}/**/*.{html,js}\"",
22
+ "lint": "eslint --cache --fix \"*.{js,cjs,mjs,jsx}\" \"{src,test,scripts}/**/*.{js,cjs,mjs,jsx}\"",
23
+ "format": "prettier --write \"*.{html,js,cjs,mjs,jsx}\" \"{sandbox,src,test,scripts}/**/*.{html,js,cjs,mjs,jsx}\"",
25
24
  "test": "npm run test:unit && npm run test:scripts && npm run test:functional",
26
25
  "test:unit": "karma start karma.conf.cjs --single-run",
27
26
  "test:unit:debug": "karma start --browsers=Chrome --single-run=false --debug",
@@ -32,14 +31,14 @@
32
31
  "test:functional:custom": "node scripts/helpers/runFunctionalTests.js",
33
32
  "test:functional:saucelabs:dev": "NPM_PACKAGE_VERSION=$(npm pkg get version | tr -d '\"') EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" saucectl run --config ./.sauce/dev.yml",
34
33
  "test:functional:watch": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" ./scripts/watchFunctionalTests.js --browsers chrome",
35
- "test:functional:debug": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe --esm --inspect-brk chrome",
34
+ "test:functional:debug": "EDGE_BASE_PATH=\"ee-pre-prd\" ALLOY_ENV=\"int\" testcafe --inspect-brk chrome",
36
35
  "test:functional:build:int": "rollup -c --environment BASE_CODE_MIN,STANDALONE,NPM_PACKAGE_LOCAL",
37
36
  "test:functional:build:prod": "rollup -c --environment BASE_CODE_MIN,NPM_PACKAGE_PROD",
38
37
  "test:scripts": "jasmine --config=scripts/specs/jasmine.json",
39
38
  "sandbox:build": "rollup -c --environment SANDBOX && cd sandbox && npm run build",
40
39
  "dev": "concurrently --names build,sandbox \"rollup -c -w --environment SANDBOX\" \"cd sandbox && export REACT_APP_NONCE=321 && npm start\"",
41
40
  "dev:standalone": "npm run clean && rollup -c -w --environment STANDALONE",
42
- "build": "npm run clean && rollup -c --environment BASE_CODE_MIN,STANDALONE,STANDALONE_MIN && echo \"Base Code:\" && cat distTest/baseCode.min.js",
41
+ "build": "npm run clean && rollup -c --environment BASE_CODE_MIN,STANDALONE,STANDALONE_MIN,BUNDLESIZE && echo \"Base Code:\" && cat distTest/baseCode.min.js",
43
42
  "build:cli": "node scripts/build-alloy.js",
44
43
  "prepare": "husky && cd sandbox && npm install",
45
44
  "prepack": "rimraf libEs5 libEs6 && babel src -d libEs5 --env-name npmEs5 && babel src -d libEs6 --env-name npmEs6",
@@ -48,16 +47,16 @@
48
47
  "preinstall": "npx force-resolutions"
49
48
  },
50
49
  "lint-staged": {
51
- "./*.js": [
50
+ "./*.{cjs,mjs,js,jsx}": [
52
51
  "eslint --cache --fix"
53
52
  ],
54
- "./{src,test,scripts}/**/*.js": [
53
+ "./{src,test,scripts}/**/*.{cjs,mjs,js,jsx}": [
55
54
  "eslint --cache --fix"
56
55
  ],
57
- "./*.{html,js}": [
56
+ "./*.{html,js,cjs,mjs,jsx}": [
58
57
  "prettier --write"
59
58
  ],
60
- "./{sandbox,src,test,scripts}/**/*.{html,js}": [
59
+ "./{sandbox,src,test,scripts}/**/*.{html,js,cjs,mjs,jsx}": [
61
60
  "prettier --write"
62
61
  ]
63
62
  },
@@ -77,32 +76,30 @@
77
76
  "@adobe/reactor-cookie": "^1.1.0",
78
77
  "@adobe/reactor-load-script": "^1.1.1",
79
78
  "@adobe/reactor-object-assign": "^1.0.0",
80
- "@adobe/reactor-query-string": "^1.0.0",
81
- "@babel/core": "^7.24.7",
82
- "@babel/eslint-parser": "^7.24.7",
79
+ "@adobe/reactor-query-string": "^2.0.0",
80
+ "@babel/core": "^7.24.9",
81
+ "@babel/eslint-parser": "^7.24.8",
83
82
  "@babel/plugin-transform-template-literals": "^7.24.7",
84
- "@babel/preset-env": "^7.24.7",
83
+ "@babel/preset-env": "^7.24.8",
85
84
  "@rollup/plugin-babel": "^6.0.4",
86
85
  "@rollup/plugin-commonjs": "^26.0.1",
87
86
  "@rollup/plugin-node-resolve": "^15.2.3",
88
87
  "@rollup/plugin-terser": "^0.4.4",
89
88
  "commander": "^12.1.0",
90
89
  "css.escape": "^1.5.1",
91
- "inquirer": "^9.2.23",
90
+ "inquirer": "^10.1.2",
92
91
  "js-cookie": "3.0.5",
93
92
  "parse-uri": "^1.0.9",
94
- "rollup": "^4.18.0",
95
- "rollup-plugin-glob-import": "^0.5.0",
96
- "rollup-plugin-istanbul": "^5.0.0",
97
- "rollup-plugin-license": "^3.5.0",
93
+ "rollup": "^4.19.0",
94
+ "rollup-plugin-license": "^3.5.2",
98
95
  "uuid": "^10.0.0"
99
96
  },
100
97
  "devDependencies": {
101
- "@adobe/alloy": "^2.21.1-beta.5",
102
- "@babel/cli": "^7.24.7",
98
+ "@adobe/alloy": "^2.22.0-alpha.0",
99
+ "@babel/cli": "^7.24.8",
103
100
  "@babel/plugin-transform-runtime": "^7.24.7",
104
- "@eslint/js": "^9.5.0",
105
- "@octokit/rest": "^21.0.0",
101
+ "@eslint/js": "^9.7.0",
102
+ "@octokit/rest": "^21.0.1",
106
103
  "bundlesize": "^0.18.2",
107
104
  "chai": "^5.1.1",
108
105
  "chalk": "^5.3.0",
@@ -114,15 +111,15 @@
114
111
  "eslint-config-prettier": "^9.1.0",
115
112
  "eslint-plugin-ban": "^1.6.0",
116
113
  "eslint-plugin-import": "^2.29.1",
117
- "eslint-plugin-prettier": "^5.1.3",
114
+ "eslint-plugin-prettier": "^5.2.1",
118
115
  "eslint-plugin-testcafe": "^0.2.1",
119
116
  "force-resolutions": "^1.0.11",
120
- "glob": "^10.4.2",
121
- "globals": "^15.6.0",
117
+ "glob": "^11.0.0",
118
+ "globals": "^15.8.0",
122
119
  "handlebars": "^4.7.8",
123
- "husky": "^9.0.11",
124
- "jasmine": "^5.1.0",
125
- "jasmine-core": "^5.1.2",
120
+ "husky": "^9.1.1",
121
+ "jasmine": "^5.2.0",
122
+ "jasmine-core": "^5.2.0",
126
123
  "karma": "^6.4.3",
127
124
  "karma-chrome-launcher": "^3.2.0",
128
125
  "karma-coverage": "^2.2.1",
@@ -136,19 +133,20 @@
136
133
  "karma-sauce-launcher": "^4.3.6",
137
134
  "karma-spec-reporter": "0.0.36",
138
135
  "lint-staged": "^15.2.7",
139
- "prettier": "^3.3.2",
140
- "promise-polyfill": "^8.3.0",
136
+ "prettier": "^3.3.3",
141
137
  "read-cache": "^1.0.0",
142
138
  "recursive-readdir": "^2.2.3",
143
139
  "request": "^2.88.0",
144
- "rimraf": "^5.0.7",
145
- "semver": "^7.6.2",
140
+ "rimraf": "^6.0.1",
141
+ "rollup-plugin-glob-import": "^0.5.0",
142
+ "rollup-plugin-istanbul": "^5.0.0",
143
+ "semver": "^7.6.3",
146
144
  "staged-git-files": "^1.3.0",
147
145
  "start-server-and-test": "^2.0.4",
148
- "testcafe": "^3.6.1",
146
+ "testcafe": "^3.6.2",
149
147
  "testcafe-browser-provider-saucelabs": "^3.0.0",
150
148
  "testcafe-reporter-junit": "^3.0.2",
151
- "testcafe-reporter-saucelabs": "^3.2.0",
149
+ "testcafe-reporter-saucelabs": "^3.3.0",
152
150
  "url-exists-nodejs": "^0.2.4",
153
151
  "url-parse": "^1.5.10"
154
152
  },
@@ -158,6 +156,6 @@
158
156
  }
159
157
  },
160
158
  "optionalDependencies": {
161
- "@rollup/rollup-linux-x64-gnu": "^4.18.0"
159
+ "@rollup/rollup-linux-x64-gnu": "^4.19.0"
162
160
  }
163
161
  }
package/rollup.config.js CHANGED
@@ -17,7 +17,106 @@ import babel from "@rollup/plugin-babel";
17
17
  import terser from "@rollup/plugin-terser";
18
18
  import license from "rollup-plugin-license";
19
19
  import { fileURLToPath } from "url";
20
+ import { gzip, brotliCompress as br, constants as zlibConstants } from "zlib";
21
+ import { promisify } from "util";
22
+ import { readFile, writeFile } from "fs/promises";
20
23
 
24
+ const INCLUDE_BUNDLESIZE = process.env.BUNDLESIZE === "true";
25
+ /**
26
+ * @param {Object} options
27
+ * @param {string} [options.outputFile] Filepath to output the bundle size report.
28
+ * @param {boolean} [options.reportToConsole] Whether to log the bundle size report to the console in addition to writing it to a file.
29
+ * @param {number} [options.gzipCompressionLevel] The compression level to use when gzipping the bundle.
30
+ * @param {number} [options.brotliCompressionLevel] The compression level to use when brotli-compressing the bundle.
31
+ * @returns {Partial<import("rollup").PluginHooks>}
32
+ */
33
+ const bundleSizePlugin = (_options = {}) => {
34
+ const defaultOptions = {
35
+ outputFile: "bundlesize.json",
36
+ reportToConsole: false,
37
+ gzipCompressionLevel: zlibConstants.Z_DEFAULT_COMPRESSION,
38
+ brotliCompressionLevel: zlibConstants.BROTLI_DEFAULT_QUALITY,
39
+ };
40
+ const options = { ...defaultOptions, ..._options };
41
+ const gzipCompress = promisify(gzip);
42
+ const brotliCompress = promisify(br);
43
+ /**
44
+ * @param {import("node:zlib").InputType} source the source code to compress
45
+ * @param {import("node:zlib").ZlibOptions={}} options
46
+ * @returns {number} size in bytes
47
+ */
48
+ const getGzippedSize = async (source, opts = {}) => {
49
+ const compressed = await gzipCompress(source, opts);
50
+ const byteSize = Number.parseInt(compressed.byteLength, 10);
51
+ return byteSize;
52
+ };
53
+ /**
54
+ * @param {import("node:zlib").InputType} source the source code to compress
55
+ * @param {import("node:zlib").BrotliOptions={}} options
56
+ * @returns {number} size in bytes
57
+ */
58
+ const getBrotiliSize = async (source, opts = {}) => {
59
+ const compressed = await brotliCompress(source, opts);
60
+ const byteSize = Number.parseInt(compressed.byteLength, 10);
61
+ return byteSize;
62
+ };
63
+ return {
64
+ name: "bundle-size",
65
+ generateBundle: {
66
+ order: "post",
67
+ /**
68
+ * @param {import("rollup").NormalizedOutputOptions} rollupOptions
69
+ * @param {import("rollup").OutputBundle} bundle
70
+ * @returns {Promise<void>}
71
+ */
72
+ async handler(rollupOptions, bundle) {
73
+ // keep sizes in bytes until displaying them
74
+ const sizes = await Promise.all(
75
+ Object.values(bundle)
76
+ .filter((outputFile) => outputFile.type === "chunk")
77
+ .map(async (chunk) => ({
78
+ fileName: rollupOptions.file,
79
+ uncompressedSize: Buffer.from(chunk.code).byteLength,
80
+ gzippedSize: await getGzippedSize(chunk.code, {
81
+ level: options.gzipCompressionLevel,
82
+ }),
83
+ brotiliSize: await getBrotiliSize(chunk.code, {
84
+ params: {
85
+ [zlibConstants.BROTLI_PARAM_QUALITY]:
86
+ options.brotliCompressionLevel,
87
+ },
88
+ }),
89
+ })),
90
+ );
91
+ if (options.reportToConsole) {
92
+ console.table(sizes);
93
+ }
94
+ // check if the output file exists, create it if it does not exist
95
+ let report = {};
96
+ try {
97
+ const outputFile = readFile(path.resolve(options.outputFile));
98
+ report = JSON.parse(await outputFile);
99
+ } catch {
100
+ // ignore errors. They are probably due to the file not existing
101
+ }
102
+ // update the report with the new sizes
103
+ sizes
104
+ // stable sort the report by filename
105
+ .sort(({ fileName: a }, { fileName: b }) => a.localeCompare(b))
106
+ .forEach((size) => {
107
+ const { fileName } = size;
108
+ delete size.fileName;
109
+ report[fileName] = size;
110
+ });
111
+ // write the report to the file
112
+ await writeFile(
113
+ path.resolve(options.outputFile),
114
+ JSON.stringify(report, null, 2),
115
+ );
116
+ },
117
+ },
118
+ };
119
+ };
21
120
  // Set these boolean environment options to control which files are built:
22
121
  // build the snippet that must be add to the page
23
122
  const BASE_CODE = "BASE_CODE";
@@ -29,6 +128,8 @@ const SANDBOX = "SANDBOX";
29
128
  const NPM_PACKAGE_LOCAL = "NPM_PACKAGE_LOCAL";
30
129
  // build from the published npm package
31
130
  const NPM_PACKAGE_PROD = "NPM_PACKAGE_PROD";
131
+ // build the standalone distrobution, but exclude some (specified) modules
132
+ const CUSTOM_BUILD = "CUSTOM_BUILD";
32
133
  // Add "_MIN" to the end of the option name to build the minified version
33
134
 
34
135
  const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -50,6 +151,14 @@ const buildPlugins = ({ variant, minify, babelPlugins }) => {
50
151
  }),
51
152
  ];
52
153
 
154
+ if (INCLUDE_BUNDLESIZE) {
155
+ plugins.push(
156
+ bundleSizePlugin({
157
+ output: "bundlesize.json",
158
+ }),
159
+ );
160
+ }
161
+
53
162
  if (minify) {
54
163
  if (variant === BASE_CODE) {
55
164
  plugins.push(
@@ -68,7 +177,7 @@ const buildPlugins = ({ variant, minify, babelPlugins }) => {
68
177
  plugins.push(terser());
69
178
  }
70
179
  }
71
- if (variant === STANDALONE) {
180
+ if (variant === STANDALONE || variant === CUSTOM_BUILD) {
72
181
  plugins.push(
73
182
  license({
74
183
  cwd: dirname,
@@ -107,7 +216,11 @@ export const buildConfig = ({
107
216
  plugins,
108
217
  };
109
218
  }
110
- if (variant === STANDALONE || variant === SANDBOX) {
219
+ if (
220
+ variant === STANDALONE ||
221
+ variant === SANDBOX ||
222
+ variant === CUSTOM_BUILD
223
+ ) {
111
224
  const destDirectory = variant === SANDBOX ? "sandbox/public/" : "dist/";
112
225
 
113
226
  return {
@@ -116,11 +229,6 @@ export const buildConfig = ({
116
229
  {
117
230
  file: file || `${destDirectory}alloy${minifiedExtension}.js`,
118
231
  format: "iife",
119
- intro:
120
- "if (document.documentMode && document.documentMode < 11) {\n" +
121
- " console.warn('The Adobe Experience Cloud Web SDK does not support IE 10 and below.');\n" +
122
- " return;\n" +
123
- "}\n",
124
232
  sourcemap: variant === SANDBOX,
125
233
  },
126
234
  ],
@@ -17,48 +17,63 @@ import { rollup } from "rollup";
17
17
  import { Command, Option, InvalidOptionArgumentError } from "commander";
18
18
  import inquirer from "inquirer";
19
19
  import { fileURLToPath } from "url";
20
+ import babel from "@babel/core";
20
21
  import { buildConfig } from "../rollup.config.js";
21
- import conditionalBuildBabelPlugin from "./helpers/conditionalBuildBabelPlugin.js";
22
- import components from "./helpers/alloyComponents.js";
22
+ import entryPointGeneratorBabelPlugin from "./helpers/entryPointGeneratorBabelPlugin.js";
23
23
 
24
24
  const dirname = path.dirname(fileURLToPath(import.meta.url));
25
25
 
26
+ const packageJsonContent = fs.readFileSync(
27
+ `${dirname}/../package.json`,
28
+ "utf8",
29
+ );
30
+ const { version } = JSON.parse(packageJsonContent);
31
+
26
32
  let sourceRootPath = `${dirname}/../src`;
27
33
  if (!fs.existsSync(sourceRootPath)) {
28
34
  sourceRootPath = `${dirname}/../libEs6`;
29
35
  }
30
36
 
31
- const getOptionalComponents = (() => {
32
- const componentCreatorsPath = `${sourceRootPath}/core/componentCreators.js`;
37
+ const arrayDifference = (arr1, arr2) => arr1.filter((x) => !arr2.includes(x));
33
38
 
34
- // Read componentCreators.js
35
- const componentCreatorsContent = fs.readFileSync(
36
- componentCreatorsPath,
37
- "utf8",
38
- );
39
+ const camelCaseToTitleCase = (str) => {
40
+ return str.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
41
+ };
42
+
43
+ const getComponents = (() => {
44
+ const components = {};
45
+ [
46
+ {
47
+ filePath: `${sourceRootPath}/core/componentCreators.js`,
48
+ key: "optional",
49
+ },
50
+ {
51
+ filePath: `${sourceRootPath}/core/requiredComponentCreators.js`,
52
+ key: "required",
53
+ },
54
+ ].forEach(({ filePath, key }) => {
55
+ const code = fs.readFileSync(filePath, "utf-8");
56
+ const c = [];
57
+
58
+ babel.traverse(babel.parse(code), {
59
+ Identifier(p) {
60
+ if (p.node.name !== "default") {
61
+ c.push(p.node.name);
62
+ }
63
+ },
64
+ });
39
65
 
40
- // Extract optional components based on @skipwhen directive
41
- const optionalComponents = componentCreatorsContent
42
- .split("\n")
43
- .filter((line) => line.trim().startsWith("/* @skipwhen"))
44
- .map((line) => {
45
- const match = line.match(/ENV\.alloy_([a-zA-Z0-9]+) === false/);
46
- if (match) {
47
- const [, componentName] = match;
48
- return componentName.toLowerCase(); // Ensure this matches the expected format for exclusion
49
- }
50
- return null;
51
- })
52
- .filter(Boolean);
53
-
54
- return () => optionalComponents;
66
+ components[key] = c;
67
+ });
68
+
69
+ return () => components;
55
70
  })();
56
71
 
57
72
  const getDefaultPath = () => {
58
73
  return process.cwd();
59
74
  };
60
75
 
61
- const getFile = (argv) => {
76
+ const getOutputFilePath = (argv) => {
62
77
  return `${[argv.outputDir, `alloy${argv.minify ? ".min" : ""}.js`].join(path.sep)}`;
63
78
  };
64
79
 
@@ -68,23 +83,41 @@ const getFileSizeInKB = (filePath) => {
68
83
  return `${(fileSizeInBytes / 1024).toFixed(2)} K`;
69
84
  };
70
85
 
86
+ const generateInputEntryFile = ({
87
+ inputPath,
88
+ outputFile = "input.js",
89
+ includedModules,
90
+ }) => {
91
+ const output = babel.transformFileSync(inputPath, {
92
+ plugins: [entryPointGeneratorBabelPlugin(babel.types, includedModules)],
93
+ }).code;
94
+
95
+ const destinationDirectory = path.dirname(inputPath);
96
+ const outputPath = path.join(destinationDirectory, outputFile);
97
+
98
+ fs.writeFileSync(outputPath, output);
99
+
100
+ return outputPath;
101
+ };
102
+
71
103
  const build = async (argv) => {
104
+ const input = generateInputEntryFile({
105
+ inputPath: `${sourceRootPath}/standalone.js`,
106
+ includedModules: argv.include,
107
+ });
108
+
72
109
  const rollupConfig = buildConfig({
73
- input: `${sourceRootPath}/standalone.js`,
74
- file: getFile(argv),
110
+ variant: "CUSTOM_BUILD",
111
+ input,
112
+ file: getOutputFilePath(argv),
75
113
  minify: argv.minify,
76
- babelPlugins: [
77
- conditionalBuildBabelPlugin(
78
- argv.exclude.reduce((acc, module) => {
79
- acc[`alloy_${module}`] = "false";
80
- return acc;
81
- }, {}),
82
- ),
83
- ],
84
114
  });
85
115
 
86
116
  const bundle = await rollup(rollupConfig);
87
117
  await bundle.write(rollupConfig.output[0]);
118
+
119
+ fs.unlinkSync(input);
120
+
88
121
  console.log(
89
122
  `🎉 Wrote ${
90
123
  path.isAbsolute(argv.outputDir)
@@ -94,23 +127,24 @@ const build = async (argv) => {
94
127
  );
95
128
  };
96
129
 
97
- const getMakeBuildCommand = () =>
98
- new Command("build")
130
+ const getMakeBuildCommand = () => {
131
+ const optionalComponentsParameters = getComponents().optional;
132
+ return new Command("build")
99
133
  .description("Build a custom version of the alloy.js library.")
100
134
  .addOption(
101
135
  new Option(
102
136
  "-e, --exclude <modules...>",
103
137
  "optional components that can be excluded from the build",
104
138
  )
105
- .choices(getOptionalComponents())
139
+ .choices(optionalComponentsParameters)
106
140
  .default([])
107
141
  .argParser((value) => {
108
142
  const modules = value.split(",");
109
143
 
110
144
  modules.forEach((module) => {
111
- if (!getOptionalComponents().includes(module))
145
+ if (!optionalComponentsParameters.includes(module))
112
146
  throw new InvalidOptionArgumentError(
113
- `Module "${module}" does not exists. Allowed choices are "${getOptionalComponents().join('", "')}".`,
147
+ `Module "${module}" does not exists. Allowed choices are "${optionalComponentsParameters.join('", "')}".`,
114
148
  );
115
149
  });
116
150
 
@@ -145,9 +179,15 @@ const getMakeBuildCommand = () =>
145
179
  return value.replace(new RegExp(`${path.sep}+$`, "g"), "");
146
180
  }),
147
181
  )
148
- .action(async (opts) => {
149
- await build(opts);
182
+ .action((opts) => {
183
+ const { exclude } = opts;
184
+ const optionalComponents = getComponents().optional;
185
+ delete opts.exclude;
186
+
187
+ opts.include = arrayDifference(optionalComponents, exclude);
188
+ return build(opts);
150
189
  });
190
+ };
151
191
 
152
192
  const getInteractiveBuildCommand = () =>
153
193
  new Command("interactive-build")
@@ -161,7 +201,11 @@ const getInteractiveBuildCommand = () =>
161
201
  type: "checkbox",
162
202
  name: "include",
163
203
  message: "What components should be included in your Alloy build?",
164
- choices: components,
204
+ choices: getComponents().optional.map((value) => ({
205
+ name: camelCaseToTitleCase(value),
206
+ checked: true,
207
+ value,
208
+ })),
165
209
  },
166
210
  {
167
211
  type: "list",
@@ -179,17 +223,7 @@ const getInteractiveBuildCommand = () =>
179
223
  default: process.cwd(),
180
224
  },
181
225
  ])
182
- .then(async (opts) => {
183
- const { include } = opts;
184
- const exclude = components
185
- .map((v) => v.value)
186
- .filter((component) => !include.includes(component));
187
-
188
- opts.exclude = exclude;
189
- delete opts.include;
190
-
191
- await build(opts);
192
- })
226
+ .then(async (opts) => build(opts))
193
227
  .catch((error) => {
194
228
  if (error.isTtyError) {
195
229
  console.error(
@@ -208,7 +242,7 @@ program
208
242
  .description(
209
243
  "Tool for generating custom Adobe Experience Platform Web SDK builds.",
210
244
  )
211
- .version("1.0.0");
245
+ .version(version);
212
246
 
213
247
  program.addCommand(getMakeBuildCommand());
214
248
  program.addCommand(getInteractiveBuildCommand(), { isDefault: true });
@@ -0,0 +1,39 @@
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
+
13
+ export default (t, includedModules) => ({
14
+ visitor: {
15
+ CallExpression(path) {
16
+ if (path.node.callee.name === "core") {
17
+ path.replaceWith(
18
+ t.CallExpression(t.Identifier("core"), [
19
+ t.ObjectExpression([
20
+ t.ObjectProperty(
21
+ t.Identifier("components"),
22
+ t.ArrayExpression(
23
+ includedModules.map((module) =>
24
+ t.MemberExpression(
25
+ t.Identifier("components"),
26
+ t.Identifier(module),
27
+ ),
28
+ ),
29
+ ),
30
+ ),
31
+ ]),
32
+ ]),
33
+ );
34
+
35
+ path.stop();
36
+ }
37
+ },
38
+ },
39
+ });
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- exports.default = void 0;
4
- var _eventType = require("../../constants/eventType.js");
5
- var _propositionEventType = require("../../constants/propositionEventType.js");
6
- var _index = require("../../utils/index.js");
7
- /*
8
- Copyright 2020 Adobe. All rights reserved.
9
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- you may not use this file except in compliance with the License. You may obtain a copy
11
- of the License at http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software distributed under
14
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- OF ANY KIND, either express or implied. See the License for the specific language
16
- governing permissions and limitations under the License.
17
- */
18
- var _default = exports.default = function _default(_ref) {
19
- var eventManager = _ref.eventManager,
20
- mergeDecisionsMeta = _ref.mergeDecisionsMeta;
21
- // Called when a decision is auto-rendered for the __view__ scope or a SPA view(display and empty display notification)
22
- return function (_ref2) {
23
- var _ref2$decisionsMeta = _ref2.decisionsMeta,
24
- decisionsMeta = _ref2$decisionsMeta === void 0 ? [] : _ref2$decisionsMeta,
25
- propositionAction = _ref2.propositionAction,
26
- _ref2$documentMayUnlo = _ref2.documentMayUnload,
27
- documentMayUnload = _ref2$documentMayUnlo === void 0 ? false : _ref2$documentMayUnlo,
28
- _ref2$eventType = _ref2.eventType,
29
- eventType = _ref2$eventType === void 0 ? _eventType.DISPLAY : _ref2$eventType,
30
- _ref2$propositionEven = _ref2.propositionEventTypes,
31
- propositionEventTypes = _ref2$propositionEven === void 0 ? [(0, _propositionEventType.getPropositionEventType)(eventType)] : _ref2$propositionEven,
32
- viewName = _ref2.viewName;
33
- var event = eventManager.createEvent();
34
- var data = {
35
- eventType: eventType
36
- };
37
- if (viewName) {
38
- data.web = {
39
- webPageDetails: {
40
- viewName: viewName
41
- }
42
- };
43
- }
44
- if ((0, _index.isNonEmptyArray)(decisionsMeta)) {
45
- mergeDecisionsMeta(event, decisionsMeta, propositionEventTypes, propositionAction);
46
- }
47
- event.mergeXdm(data);
48
- if (documentMayUnload) {
49
- event.documentMayUnload();
50
- }
51
- return eventManager.sendEvent(event);
52
- };
53
- };