@adobe/alloy 2.11.0-alpha.0 → 2.11.0-alpha.3

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.
@@ -19,9 +19,14 @@ var _default = function _default(dateProvider) {
19
19
  return function (xdm) {
20
20
  var date = dateProvider();
21
21
  var placeContext = {
22
- localTime: (0, _utils.toISOStringLocal)(date),
23
- localTimezoneOffset: date.getTimezoneOffset()
22
+ localTime: (0, _utils.toISOStringLocal)(date)
24
23
  };
24
+ var localTimezoneOffset = (0, _utils.toInteger)(date.getTimezoneOffset());
25
+
26
+ if (localTimezoneOffset !== undefined) {
27
+ placeContext.localTimezoneOffset = localTimezoneOffset;
28
+ }
29
+
25
30
  (0, _utils.deepAssign)(xdm, {
26
31
  placeContext: placeContext
27
32
  });
@@ -17,8 +17,7 @@ governing permissions and limitations under the License.
17
17
  */
18
18
  var configValidators = {
19
19
  thirdPartyCookiesEnabled: (0, _validation.boolean)().default(true),
20
- idMigrationEnabled: (0, _validation.boolean)().default(true),
21
- idOverwriteEnabled: (0, _validation.boolean)().default(false)
20
+ idMigrationEnabled: (0, _validation.boolean)().default(true)
22
21
  };
23
22
  var _default = configValidators;
24
23
  exports.default = _default;
@@ -60,8 +60,7 @@ var createIdentity = function createIdentity(_ref) {
60
60
  fireReferrerHideableImage = _ref.fireReferrerHideableImage,
61
61
  sendEdgeNetworkRequest = _ref.sendEdgeNetworkRequest;
62
62
  var orgId = config.orgId,
63
- thirdPartyCookiesEnabled = config.thirdPartyCookiesEnabled,
64
- idOverwriteEnabled = config.idOverwriteEnabled;
63
+ thirdPartyCookiesEnabled = config.thirdPartyCookiesEnabled;
65
64
  var getEcidFromVisitor = (0, _injectGetEcidFromVisitor.default)({
66
65
  logger: logger,
67
66
  orgId: orgId,
@@ -93,8 +92,7 @@ var createIdentity = function createIdentity(_ref) {
93
92
  return new Date();
94
93
  },
95
94
  orgId: orgId,
96
- logger: logger,
97
- idOverwriteEnabled: idOverwriteEnabled
95
+ logger: logger
98
96
  });
99
97
  var awaitIdentityCookie = (0, _injectAwaitIdentityCookie.default)({
100
98
  doesIdentityCookieExist: doesIdentityCookieExist,
@@ -26,8 +26,7 @@ var _default = function _default(_ref) {
26
26
  var locationSearch = _ref.locationSearch,
27
27
  dateProvider = _ref.dateProvider,
28
28
  orgId = _ref.orgId,
29
- logger = _ref.logger,
30
- idOverwriteEnabled = _ref.idOverwriteEnabled;
29
+ logger = _ref.logger;
31
30
  return function (payload) {
32
31
  if (payload.hasIdentity(_ecidNamespace.default)) {
33
32
  // don't overwrite a user provided ecid identity
@@ -63,14 +62,6 @@ var _default = function _default(_ref) {
63
62
  payload.addIdentity(_ecidNamespace.default, {
64
63
  id: mcmid
65
64
  });
66
-
67
- if (idOverwriteEnabled) {
68
- payload.mergeQuery({
69
- identity: {
70
- overwriteExisting: true
71
- }
72
- });
73
- }
74
65
  } else {
75
66
  logger.info("Detected invalid or expired adobe_mc query string parameter.");
76
67
  }
@@ -21,18 +21,11 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
21
21
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
22
 
23
23
  // Trying to match ID or CSS class
24
- var CSS_IDENTIFIER_PATTERN = /(#|\.)(-?\w+)/g; // This is required to remove leading " > " from parsed pieces
25
-
26
- var SIBLING_PATTERN = /^\s*>?\s*/;
27
-
28
- var cleanUp = function cleanUp(str) {
29
- return str.replace(SIBLING_PATTERN, "").trim();
30
- }; // Here we use CSS.escape() to make sure we get
24
+ var CSS_IDENTIFIER_PATTERN = /(#|\.)(-?\w+)/g; // Here we use CSS.escape() to make sure we get
31
25
  // correct values for ID and CSS class
32
26
  // Please check: https://www.w3.org/TR/css-syntax-3/#escaping
33
27
  // CSS.escape() polyfill can be found here: https://github.com/mathiasbynens/CSS.escape
34
28
 
35
-
36
29
  var replaceIdentifier = function replaceIdentifier(_, $1, $2) {
37
30
  return "" + $1 + (0, _css.default)($2);
38
31
  };
@@ -51,7 +44,7 @@ var parseSelector = function parseSelector(rawSelector) {
51
44
  var i = 0;
52
45
 
53
46
  while (i < length) {
54
- var sel = cleanUp(parts[i]);
47
+ var sel = parts[i];
55
48
  var eq = parts[i + 1];
56
49
 
57
50
  if (eq) {
@@ -15,5 +15,5 @@ governing permissions and limitations under the License.
15
15
  */
16
16
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
17
17
  // see babel-plugin-version
18
- var _default = "2.11.0-alpha.0";
18
+ var _default = "2.11.0-alpha.3";
19
19
  exports.default = _default;
@@ -15,8 +15,22 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
15
15
  OF ANY KIND, either express or implied. See the License for the specific language
16
16
  governing permissions and limitations under the License.
17
17
  */
18
+ var SIBLING_PATTERN = /^\s*>/;
19
+
18
20
  var _default = function _default(context, selector) {
19
- return (0, _toArray.default)(context.querySelectorAll(selector));
21
+ if (!SIBLING_PATTERN.test(selector)) {
22
+ return (0, _toArray.default)(context.querySelectorAll(selector));
23
+ }
24
+
25
+ var tag = "alloy-" + Date.now(); // We could use a :scope selector here, but we want to be IE compliant
26
+ // so we add a dummy css class to be able to select the children
27
+
28
+ try {
29
+ context.classList.add(tag);
30
+ return (0, _toArray.default)(context.querySelectorAll("." + tag + " " + selector));
31
+ } finally {
32
+ context.classList.remove(tag);
33
+ }
20
34
  };
21
35
 
22
36
  exports.default = _default;
@@ -282,6 +282,12 @@ Object.defineProperty(exports, "toISOStringLocal", {
282
282
  return _toISOStringLocal.default;
283
283
  }
284
284
  });
285
+ Object.defineProperty(exports, "toInteger", {
286
+ enumerable: true,
287
+ get: function get() {
288
+ return _toInteger.default;
289
+ }
290
+ });
285
291
  Object.defineProperty(exports, "updateErrorMessage", {
286
292
  enumerable: true,
287
293
  get: function get() {
@@ -399,6 +405,8 @@ var _toArray = require("./toArray");
399
405
 
400
406
  var _toError = require("./toError");
401
407
 
408
+ var _toInteger = require("./toInteger");
409
+
402
410
  var _toISOStringLocal = require("./toISOStringLocal");
403
411
 
404
412
  var _uuid = require("./uuid");
@@ -4,6 +4,8 @@ exports.default = void 0;
4
4
 
5
5
  var _padStart = require("./padStart");
6
6
 
7
+ var _toInteger = require("./toInteger");
8
+
7
9
  /*
8
10
  Copyright 2019 Adobe. All rights reserved.
9
11
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -32,7 +34,7 @@ var _default = function _default(date) {
32
34
  // means that the offset is positive if the local timezone is behind UTC and negative if it is
33
35
  // ahead. For example, for time zone UTC+10:00, -600 will be returned.
34
36
 
35
- var timezoneOffset = date.getTimezoneOffset();
37
+ var timezoneOffset = (0, _toInteger.default)(date.getTimezoneOffset(), 0);
36
38
  var ts = timezoneOffset > 0 ? "-" : "+";
37
39
  var th = (0, _padStart.default)(Math.floor(Math.abs(timezoneOffset) / 60), 2, "0");
38
40
  var tm = (0, _padStart.default)(Math.abs(timezoneOffset) % 60, 2, "0");
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ exports.default = void 0;
4
+
5
+ /*
6
+ Copyright 2022 Adobe. All rights reserved.
7
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License. You may obtain a copy
9
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software distributed under
12
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ OF ANY KIND, either express or implied. See the License for the specific language
14
+ governing permissions and limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * coerce `value` to a number or return `defaultValue` if it cannot be.
19
+ */
20
+ var _default = function _default(value, defaultValue) {
21
+ var n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
22
+
23
+ return isNaN(n) ? defaultValue : n;
24
+ };
25
+
26
+ exports.default = _default;
@@ -9,14 +9,19 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
- import { deepAssign, toISOStringLocal } from "../../utils";
12
+ import { deepAssign, toISOStringLocal, toInteger } from "../../utils";
13
13
  export default (dateProvider => {
14
14
  return xdm => {
15
15
  const date = dateProvider();
16
16
  const placeContext = {
17
- localTime: toISOStringLocal(date),
18
- localTimezoneOffset: date.getTimezoneOffset()
17
+ localTime: toISOStringLocal(date)
19
18
  };
19
+ const localTimezoneOffset = toInteger(date.getTimezoneOffset());
20
+
21
+ if (localTimezoneOffset !== undefined) {
22
+ placeContext.localTimezoneOffset = localTimezoneOffset;
23
+ }
24
+
20
25
  deepAssign(xdm, {
21
26
  placeContext
22
27
  });
@@ -12,7 +12,6 @@ governing permissions and limitations under the License.
12
12
  import { boolean } from "../../utils/validation";
13
13
  const configValidators = {
14
14
  thirdPartyCookiesEnabled: boolean().default(true),
15
- idMigrationEnabled: boolean().default(true),
16
- idOverwriteEnabled: boolean().default(false)
15
+ idMigrationEnabled: boolean().default(true)
17
16
  };
18
17
  export default configValidators;
@@ -39,8 +39,7 @@ const createIdentity = ({
39
39
  }) => {
40
40
  const {
41
41
  orgId,
42
- thirdPartyCookiesEnabled,
43
- idOverwriteEnabled
42
+ thirdPartyCookiesEnabled
44
43
  } = config;
45
44
  const getEcidFromVisitor = injectGetEcidFromVisitor({
46
45
  logger,
@@ -71,8 +70,7 @@ const createIdentity = ({
71
70
  locationSearch: window.document.location.search,
72
71
  dateProvider: () => new Date(),
73
72
  orgId,
74
- logger,
75
- idOverwriteEnabled
73
+ logger
76
74
  });
77
75
  const awaitIdentityCookie = injectAwaitIdentityCookie({
78
76
  doesIdentityCookieExist,
@@ -9,8 +9,7 @@ export default (({
9
9
  locationSearch,
10
10
  dateProvider,
11
11
  orgId,
12
- logger,
13
- idOverwriteEnabled
12
+ logger
14
13
  }) => payload => {
15
14
  if (payload.hasIdentity(ecidNamespace)) {
16
15
  // don't overwrite a user provided ecid identity
@@ -41,14 +40,6 @@ export default (({
41
40
  payload.addIdentity(ecidNamespace, {
42
41
  id: mcmid
43
42
  });
44
-
45
- if (idOverwriteEnabled) {
46
- payload.mergeQuery({
47
- identity: {
48
- overwriteExisting: true
49
- }
50
- });
51
- }
52
43
  } else {
53
44
  logger.info("Detected invalid or expired adobe_mc query string parameter.");
54
45
  }
@@ -13,16 +13,11 @@ import escape from "css.escape";
13
13
  import { selectNodes } from "../../../../utils/dom";
14
14
  import { isNotEqSelector, splitWithEq } from "./helperForEq"; // Trying to match ID or CSS class
15
15
 
16
- const CSS_IDENTIFIER_PATTERN = /(#|\.)(-?\w+)/g; // This is required to remove leading " > " from parsed pieces
17
-
18
- const SIBLING_PATTERN = /^\s*>?\s*/;
19
-
20
- const cleanUp = str => str.replace(SIBLING_PATTERN, "").trim(); // Here we use CSS.escape() to make sure we get
16
+ const CSS_IDENTIFIER_PATTERN = /(#|\.)(-?\w+)/g; // Here we use CSS.escape() to make sure we get
21
17
  // correct values for ID and CSS class
22
18
  // Please check: https://www.w3.org/TR/css-syntax-3/#escaping
23
19
  // CSS.escape() polyfill can be found here: https://github.com/mathiasbynens/CSS.escape
24
20
 
25
-
26
21
  const replaceIdentifier = (_, $1, $2) => `${$1}${escape($2)}`;
27
22
 
28
23
  export const escapeIdentifiersInSelector = selector => {
@@ -38,7 +33,7 @@ export const parseSelector = rawSelector => {
38
33
  let i = 0;
39
34
 
40
35
  while (i < length) {
41
- const sel = cleanUp(parts[i]);
36
+ const sel = parts[i];
42
37
  const eq = parts[i + 1];
43
38
 
44
39
  if (eq) {
@@ -11,4 +11,4 @@ governing permissions and limitations under the License.
11
11
  */
12
12
  // The __VERSION__ keyword will be replace at alloy build time with the package.json version.
13
13
  // see babel-plugin-version
14
- export default "2.11.0-alpha.0";
14
+ export default "2.11.0-alpha.3";
@@ -10,4 +10,19 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  import toArray from "../toArray";
13
- export default ((context, selector) => toArray(context.querySelectorAll(selector)));
13
+ const SIBLING_PATTERN = /^\s*>/;
14
+ export default ((context, selector) => {
15
+ if (!SIBLING_PATTERN.test(selector)) {
16
+ return toArray(context.querySelectorAll(selector));
17
+ }
18
+
19
+ const tag = `alloy-${Date.now()}`; // We could use a :scope selector here, but we want to be IE compliant
20
+ // so we add a dummy css class to be able to select the children
21
+
22
+ try {
23
+ context.classList.add(tag);
24
+ return toArray(context.querySelectorAll(`.${tag} ${selector}`));
25
+ } finally {
26
+ context.classList.remove(tag);
27
+ }
28
+ });
@@ -56,6 +56,7 @@ export { default as startsWith } from "./startsWith";
56
56
  export { default as stringToBoolean } from "./stringToBoolean";
57
57
  export { default as toArray } from "./toArray";
58
58
  export { default as toError } from "./toError";
59
+ export { default as toInteger } from "./toInteger";
59
60
  export { default as toISOStringLocal } from "./toISOStringLocal";
60
61
  export { default as uuid } from "./uuid";
61
62
  export { default as updateErrorMessage } from "./updateErrorMessage";
@@ -10,6 +10,7 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  import padStart from "./padStart";
13
+ import toInteger from "./toInteger";
13
14
  /**
14
15
  * Formats the date into an ISO date-time string in the local timezone
15
16
  * @param {Date} date
@@ -27,7 +28,7 @@ export default (date => {
27
28
  // means that the offset is positive if the local timezone is behind UTC and negative if it is
28
29
  // ahead. For example, for time zone UTC+10:00, -600 will be returned.
29
30
 
30
- const timezoneOffset = date.getTimezoneOffset();
31
+ const timezoneOffset = toInteger(date.getTimezoneOffset(), 0);
31
32
  const ts = timezoneOffset > 0 ? "-" : "+";
32
33
  const th = padStart(Math.floor(Math.abs(timezoneOffset) / 60), 2, "0");
33
34
  const tm = padStart(Math.abs(timezoneOffset) % 60, 2, "0");
@@ -0,0 +1,20 @@
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
+ /*
14
+ * coerce `value` to a number or return `defaultValue` if it cannot be.
15
+ */
16
+ export default ((value, defaultValue) => {
17
+ const n = Math.round(Number(value)); // eslint-disable-next-line no-restricted-globals
18
+
19
+ return isNaN(n) ? defaultValue : n;
20
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/alloy",
3
- "version": "2.11.0-alpha.0",
3
+ "version": "2.11.0-alpha.3",
4
4
  "description": "Adobe Experience Platform Web SDK",
5
5
  "main": "libEs5/index.js",
6
6
  "module": "libEs6/index.js",
@@ -64,7 +64,7 @@
64
64
  "uuid": "^3.3.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@adobe/alloy": "^2.10.1",
67
+ "@adobe/alloy": "^2.11.0-alpha.2",
68
68
  "@babel/cli": "^7.12.8",
69
69
  "@babel/core": "^7.2.2",
70
70
  "@babel/plugin-proposal-object-rest-spread": "^7.3.2",