@blotoutio/edgetag-sdk-js 0.42.2 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs.js +37 -1
  2. package/index.mjs +37 -1
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -364,7 +364,7 @@ const getStandardPayload = (payload) => {
364
364
  referrer: getReferrer(),
365
365
  search: getSearch(),
366
366
  locale: getLocale(),
367
- sdkVersion: "0.42.2" ,
367
+ sdkVersion: "0.44.0" ,
368
368
  ...(payload || {}),
369
369
  };
370
370
  let storage = {};
@@ -533,6 +533,40 @@ const upsert = (map, key, update, createDefault) => {
533
533
  return map.set(key, update(currentValue));
534
534
  };
535
535
 
536
+ const expand = (str) => str.split(',').flatMap((entry) => {
537
+ if (!entry.includes('-')) {
538
+ return entry;
539
+ }
540
+ const result = [];
541
+ const [start, end] = entry.split('-').map(Number);
542
+ for (let i = start; i <= end; i++) {
543
+ result.push(i.toString());
544
+ }
545
+ return result;
546
+ });
547
+ /**
548
+ * Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
549
+ *
550
+ * In Dev Tools, select the `tbody` element containing the area codes and run the following code,
551
+ * replacing the emdash character with a simple endash:
552
+ *
553
+ * ```ts
554
+ * [...$0.querySelectorAll('td:first-child')]
555
+ * .filter(cell => cell.firstChild.nodeName != 'A')
556
+ * .map(cell => cell.textContent.trim()).join(',')
557
+ * ```
558
+ */
559
+ new Set([
560
+ ...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
561
+ ...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
562
+ ...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
563
+ ...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
564
+ ...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
565
+ ...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
566
+ ...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
567
+ ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
568
+ ]);
569
+
536
570
  let initialized = false;
537
571
  const providersPackages = {};
538
572
  const setPreferences = (preferences) => {
@@ -780,6 +814,7 @@ const handleConsent = (consent, options) => {
780
814
  }
781
815
  pkg.init({
782
816
  userId,
817
+ isNewUser: false,
783
818
  baseUrl: getUrl(),
784
819
  manifest: {
785
820
  tagName,
@@ -943,6 +978,7 @@ const handleManifest = (response, consent) => {
943
978
  if (hasConsent) {
944
979
  pkg.init({
945
980
  userId,
981
+ isNewUser: !!response.isNewUser,
946
982
  session: response.session,
947
983
  baseUrl: getUrl(),
948
984
  manifest: provider,
package/index.mjs CHANGED
@@ -362,7 +362,7 @@ const getStandardPayload = (payload) => {
362
362
  referrer: getReferrer(),
363
363
  search: getSearch(),
364
364
  locale: getLocale(),
365
- sdkVersion: "0.42.2" ,
365
+ sdkVersion: "0.44.0" ,
366
366
  ...(payload || {}),
367
367
  };
368
368
  let storage = {};
@@ -531,6 +531,40 @@ const upsert = (map, key, update, createDefault) => {
531
531
  return map.set(key, update(currentValue));
532
532
  };
533
533
 
534
+ const expand = (str) => str.split(',').flatMap((entry) => {
535
+ if (!entry.includes('-')) {
536
+ return entry;
537
+ }
538
+ const result = [];
539
+ const [start, end] = entry.split('-').map(Number);
540
+ for (let i = start; i <= end; i++) {
541
+ result.push(i.toString());
542
+ }
543
+ return result;
544
+ });
545
+ /**
546
+ * Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
547
+ *
548
+ * In Dev Tools, select the `tbody` element containing the area codes and run the following code,
549
+ * replacing the emdash character with a simple endash:
550
+ *
551
+ * ```ts
552
+ * [...$0.querySelectorAll('td:first-child')]
553
+ * .filter(cell => cell.firstChild.nodeName != 'A')
554
+ * .map(cell => cell.textContent.trim()).join(',')
555
+ * ```
556
+ */
557
+ new Set([
558
+ ...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
559
+ ...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
560
+ ...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
561
+ ...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
562
+ ...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
563
+ ...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
564
+ ...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
565
+ ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
566
+ ]);
567
+
534
568
  let initialized = false;
535
569
  const providersPackages = {};
536
570
  const setPreferences = (preferences) => {
@@ -778,6 +812,7 @@ const handleConsent = (consent, options) => {
778
812
  }
779
813
  pkg.init({
780
814
  userId,
815
+ isNewUser: false,
781
816
  baseUrl: getUrl(),
782
817
  manifest: {
783
818
  tagName,
@@ -941,6 +976,7 @@ const handleManifest = (response, consent) => {
941
976
  if (hasConsent) {
942
977
  pkg.init({
943
978
  userId,
979
+ isNewUser: !!response.isNewUser,
944
980
  session: response.session,
945
981
  baseUrl: getUrl(),
946
982
  manifest: provider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.42.2",
3
+ "version": "0.44.0",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",