@adobe/alloy 2.34.2-beta.0 → 2.34.2-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/dist/alloy.js CHANGED
@@ -7552,10 +7552,10 @@
7552
7552
  governing permissions and limitations under the License.
7553
7553
  */
7554
7554
 
7555
- // The 2.34.2-beta.0 keyword will be replace at alloy build time with the package.json version.
7555
+ // The 2.34.2-beta.2 keyword will be replace at alloy build time with the package.json version.
7556
7556
  // see babel-plugin-version
7557
7557
 
7558
- var libraryVersion = "2.34.2-beta.0";
7558
+ var libraryVersion = "2.34.2-beta.2";
7559
7559
 
7560
7560
  /*
7561
7561
  Copyright 2019 Adobe. All rights reserved.
@@ -17030,10 +17030,24 @@
17030
17030
  };
17031
17031
  });
17032
17032
  };
17033
- const loadScript = (url) => {
17033
+ const loadScript = (source) => {
17034
+ const url = getAttribute(source, SRC);
17034
17035
  const script = document.createElement("script");
17035
- script.src = url;
17036
+ // Preserve all author-supplied attributes (class, type, data-*, etc.) so
17037
+ // consumers relying on them keep working.
17038
+ const { attributes } = source;
17039
+ for (let i = 0; i < attributes.length; i += 1) {
17040
+ const { name, value } = attributes[i];
17041
+ script.setAttribute(name, value);
17042
+ }
17043
+ // Override invariants last so they can't be clobbered by the source element.
17044
+ const nonce = getNonce();
17045
+ if (nonce) {
17046
+ script.setAttribute("nonce", nonce);
17047
+ }
17036
17048
  script.async = true;
17049
+ // Assign load handlers after copying attributes so a copied inline
17050
+ // onload/onerror attribute can't break load-completion tracking.
17037
17051
  const promise = getPromise(url, script);
17038
17052
  document.head.appendChild(script);
17039
17053
  return promise;
@@ -17076,7 +17090,7 @@
17076
17090
  return result;
17077
17091
  };
17078
17092
 
17079
- const getRemoteScriptsUrls = (fragment) => {
17093
+ const getRemoteScripts = (fragment) => {
17080
17094
  const scripts = selectNodes(SCRIPT, fragment);
17081
17095
  const result = [];
17082
17096
  const { length } = scripts;
@@ -17084,17 +17098,12 @@
17084
17098
  for (let i = 0; i < length; i += 1) {
17085
17099
  const element = scripts[i];
17086
17100
 
17101
+ // isRemoteScript already requires a non-empty src attribute.
17087
17102
  if (!isRemoteScript(element)) {
17088
17103
  continue;
17089
17104
  }
17090
17105
 
17091
- const url = getAttribute(element, SRC);
17092
-
17093
- if (!url) {
17094
- continue;
17095
- }
17096
-
17097
- result.push(url);
17106
+ result.push(element);
17098
17107
  }
17099
17108
 
17100
17109
  return result;
@@ -17107,8 +17116,8 @@
17107
17116
  });
17108
17117
  };
17109
17118
 
17110
- const executeRemoteScripts = (urls) => {
17111
- return Promise.all(urls.map(loadScript));
17119
+ const executeRemoteScripts = (scripts) => {
17120
+ return Promise.all(scripts.map(loadScript));
17112
17121
  };
17113
17122
 
17114
17123
  /*
@@ -17129,7 +17138,7 @@
17129
17138
  addNonceToInlineStyleElements(fragment);
17130
17139
  const elements = getChildNodes(fragment);
17131
17140
  const scripts = getInlineScripts(fragment);
17132
- const scriptsUrls = getRemoteScriptsUrls(fragment);
17141
+ const remoteScripts = getRemoteScripts(fragment);
17133
17142
 
17134
17143
  loadImages(fragment);
17135
17144
 
@@ -17141,7 +17150,7 @@
17141
17150
 
17142
17151
  executeInlineScripts(container, scripts);
17143
17152
 
17144
- return executeRemoteScripts(scriptsUrls);
17153
+ return executeRemoteScripts(remoteScripts);
17145
17154
  };
17146
17155
 
17147
17156
  /*
@@ -17187,7 +17196,7 @@
17187
17196
  addNonceToInlineStyleElements(fragment);
17188
17197
  const elements = getChildNodes(fragment);
17189
17198
  const scripts = getInlineScripts(fragment);
17190
- const scriptsUrls = getRemoteScriptsUrls(fragment);
17199
+ const remoteScripts = getRemoteScripts(fragment);
17191
17200
  const { length } = elements;
17192
17201
  let i = length - 1;
17193
17202
 
@@ -17212,7 +17221,7 @@
17212
17221
 
17213
17222
  executeInlineScripts(container, scripts);
17214
17223
 
17215
- return executeRemoteScripts(scriptsUrls);
17224
+ return executeRemoteScripts(remoteScripts);
17216
17225
  };
17217
17226
 
17218
17227
  /*
@@ -17350,7 +17359,7 @@
17350
17359
  addNonceToInlineStyleElements(fragment);
17351
17360
  const elements = getChildNodes(fragment);
17352
17361
  const scripts = getInlineScripts(fragment);
17353
- const scriptsUrls = getRemoteScriptsUrls(fragment);
17362
+ const remoteScripts = getRemoteScripts(fragment);
17354
17363
 
17355
17364
  loadImages(fragment);
17356
17365
 
@@ -17361,7 +17370,7 @@
17361
17370
 
17362
17371
  executeInlineScripts(container, scripts);
17363
17372
 
17364
- return executeRemoteScripts(scriptsUrls);
17373
+ return executeRemoteScripts(remoteScripts);
17365
17374
  };
17366
17375
 
17367
17376
  /*
@@ -17401,7 +17410,7 @@
17401
17410
  addNonceToInlineStyleElements(fragment);
17402
17411
  const elements = getChildNodes(fragment);
17403
17412
  const scripts = getInlineScripts(fragment);
17404
- const scriptsUrls = getRemoteScriptsUrls(fragment);
17413
+ const remoteScripts = getRemoteScripts(fragment);
17405
17414
 
17406
17415
  loadImages(fragment);
17407
17416
 
@@ -17415,7 +17424,7 @@
17415
17424
 
17416
17425
  executeInlineScripts(container, scripts);
17417
17426
 
17418
- return executeRemoteScripts(scriptsUrls);
17427
+ return executeRemoteScripts(remoteScripts);
17419
17428
  };
17420
17429
 
17421
17430
  /*
@@ -20865,8 +20874,9 @@
20865
20874
  );
20866
20875
 
20867
20876
  const cacheValue = `${ecid}${serializedPushSubscriptionDetails}`;
20877
+ const storedValue = await storage.getItem(SUBSCRIPTION_DETAILS);
20868
20878
 
20869
- if (cacheValue === storage.getItem(SUBSCRIPTION_DETAILS)) {
20879
+ if (cacheValue === storedValue) {
20870
20880
  logger.info(
20871
20881
  "Subscription details have not changed. Not sending to the server.",
20872
20882
  );
@@ -20920,17 +20930,16 @@
20920
20930
  *
20921
20931
  * @param {Object} options
20922
20932
  * @param {{ orgId: string, datastreamId: string, edgeDomain: string, edgeBasePath: string, pushNotifications: { vapidPublicKey: string, appId: string, trackingDatasetId: string }}} options.config
20923
- * @param {StorageCreator} options.createNamespacedStorage
20924
20933
  * @param {EventManager} options.eventManager
20925
20934
  * @param {Logger} options.logger
20926
20935
  * @param {ConsentManager} options.consent
20927
20936
  * @param {IdentityManager} options.identity
20928
20937
  * @param {function(): string} options.getBrowser
20929
20938
  * @param {EdgeRequestExecutor} options.sendEdgeNetworkRequest
20939
+ * @param {PlatformServices} options.platformServices
20930
20940
  * @returns {{ lifecycle: object, commands: { sendPushSubscription: object } }}
20931
20941
  */
20932
20942
  const createPushNotifications = ({
20933
- createNamespacedStorage,
20934
20943
  eventManager,
20935
20944
  config,
20936
20945
  logger,
@@ -20938,6 +20947,7 @@
20938
20947
  identity,
20939
20948
  getBrowser,
20940
20949
  sendEdgeNetworkRequest,
20950
+ platformServices,
20941
20951
  }) => {
20942
20952
  return {
20943
20953
  lifecycle: {
@@ -20977,7 +20987,7 @@
20977
20987
  },
20978
20988
  } = config || {};
20979
20989
 
20980
- const storage = createNamespacedStorage(
20990
+ const storage = platformServices.storage.createNamespacedStorage(
20981
20991
  `${sanitizeOrgIdForCookieName(orgId)}.pushNotifications.`,
20982
20992
  );
20983
20993