@blotoutio/providers-blotout-wallet-sdk 0.45.4 → 0.46.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.
- package/index.cjs.js +644 -2
- package/index.js +644 -2
- package/index.mjs +644 -2
- package/package.json +1 -1
- package/stores/shopify/index.cjs.js +72 -0
- package/stores/shopify/index.js +72 -0
- package/stores/shopify/index.mjs +72 -0
package/package.json
CHANGED
@@ -1,9 +1,72 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
const expand = (str) => str.split(',').flatMap((entry) => {
|
4
|
+
if (!entry.includes('-')) {
|
5
|
+
return entry;
|
6
|
+
}
|
7
|
+
const result = [];
|
8
|
+
const [start, end] = entry.split('-').map(Number);
|
9
|
+
for (let i = start; i <= end; i++) {
|
10
|
+
result.push(i.toString());
|
11
|
+
}
|
12
|
+
return result;
|
13
|
+
});
|
14
|
+
/**
|
15
|
+
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
16
|
+
*
|
17
|
+
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
18
|
+
* replacing the emdash character with a simple endash:
|
19
|
+
*
|
20
|
+
* ```ts
|
21
|
+
* [...$0.querySelectorAll('td:first-child')]
|
22
|
+
* .filter(cell => cell.firstChild.nodeName != 'A')
|
23
|
+
* .map(cell => cell.textContent.trim()).join(',')
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
new Set([
|
27
|
+
...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'),
|
28
|
+
...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'),
|
29
|
+
...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'),
|
30
|
+
...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'),
|
31
|
+
...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'),
|
32
|
+
...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'),
|
33
|
+
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
34
|
+
...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'),
|
35
|
+
]);
|
36
|
+
|
37
|
+
const cartTokenCookie = 'cart';
|
38
|
+
const cartTokenTwoCookie = 'cart2';
|
39
|
+
const cartCurrencyCookie = 'cart_currency';
|
40
|
+
|
3
41
|
var _a;
|
4
42
|
const registryKey = Symbol.for('blotout-wallet');
|
5
43
|
(_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
|
6
44
|
|
45
|
+
const getCookieValue = (key) => {
|
46
|
+
try {
|
47
|
+
if (!document || !document.cookie) {
|
48
|
+
return '';
|
49
|
+
}
|
50
|
+
const name = `${key}=`;
|
51
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
52
|
+
const ca = decodedCookie.split(';');
|
53
|
+
for (let i = 0; i < ca.length; i++) {
|
54
|
+
let c = ca[i];
|
55
|
+
while (c.charAt(0) === ' ') {
|
56
|
+
c = c.substring(1);
|
57
|
+
}
|
58
|
+
if (c.indexOf(name) === 0) {
|
59
|
+
return c.substring(name.length, c.length);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return '';
|
63
|
+
}
|
64
|
+
catch {
|
65
|
+
return '';
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
7
70
|
const createShopApi = (fetchOverride = window.fetch) => ({
|
8
71
|
addItems(items) {
|
9
72
|
return fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
|
@@ -54,6 +117,15 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
54
117
|
price: price,
|
55
118
|
})));
|
56
119
|
},
|
120
|
+
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
121
|
+
getCartInfo() {
|
122
|
+
let cartToken = getCookieValue(cartTokenCookie);
|
123
|
+
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
124
|
+
if (!cartToken) {
|
125
|
+
cartToken = getCookieValue(cartTokenTwoCookie);
|
126
|
+
}
|
127
|
+
return { cartToken, cartCurrency };
|
128
|
+
},
|
57
129
|
});
|
58
130
|
window[registryKey].storeAPIFactory = createShopApi;
|
59
131
|
window[registryKey].platform = 'SHOPIFY';
|
package/stores/shopify/index.js
CHANGED
@@ -1,10 +1,73 @@
|
|
1
1
|
(function () {
|
2
2
|
'use strict';
|
3
3
|
|
4
|
+
const expand = (str) => str.split(',').flatMap((entry) => {
|
5
|
+
if (!entry.includes('-')) {
|
6
|
+
return entry;
|
7
|
+
}
|
8
|
+
const result = [];
|
9
|
+
const [start, end] = entry.split('-').map(Number);
|
10
|
+
for (let i = start; i <= end; i++) {
|
11
|
+
result.push(i.toString());
|
12
|
+
}
|
13
|
+
return result;
|
14
|
+
});
|
15
|
+
/**
|
16
|
+
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
17
|
+
*
|
18
|
+
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
19
|
+
* replacing the emdash character with a simple endash:
|
20
|
+
*
|
21
|
+
* ```ts
|
22
|
+
* [...$0.querySelectorAll('td:first-child')]
|
23
|
+
* .filter(cell => cell.firstChild.nodeName != 'A')
|
24
|
+
* .map(cell => cell.textContent.trim()).join(',')
|
25
|
+
* ```
|
26
|
+
*/
|
27
|
+
new Set([
|
28
|
+
...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'),
|
29
|
+
...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'),
|
30
|
+
...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'),
|
31
|
+
...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'),
|
32
|
+
...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'),
|
33
|
+
...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'),
|
34
|
+
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
35
|
+
...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'),
|
36
|
+
]);
|
37
|
+
|
38
|
+
const cartTokenCookie = 'cart';
|
39
|
+
const cartTokenTwoCookie = 'cart2';
|
40
|
+
const cartCurrencyCookie = 'cart_currency';
|
41
|
+
|
4
42
|
var _a;
|
5
43
|
const registryKey = Symbol.for('blotout-wallet');
|
6
44
|
(_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
|
7
45
|
|
46
|
+
const getCookieValue = (key) => {
|
47
|
+
try {
|
48
|
+
if (!document || !document.cookie) {
|
49
|
+
return '';
|
50
|
+
}
|
51
|
+
const name = `${key}=`;
|
52
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
53
|
+
const ca = decodedCookie.split(';');
|
54
|
+
for (let i = 0; i < ca.length; i++) {
|
55
|
+
let c = ca[i];
|
56
|
+
while (c.charAt(0) === ' ') {
|
57
|
+
c = c.substring(1);
|
58
|
+
}
|
59
|
+
if (c.indexOf(name) === 0) {
|
60
|
+
return c.substring(name.length, c.length);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return '';
|
64
|
+
}
|
65
|
+
catch {
|
66
|
+
return '';
|
67
|
+
}
|
68
|
+
};
|
69
|
+
|
70
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
8
71
|
const createShopApi = (fetchOverride = window.fetch) => ({
|
9
72
|
addItems(items) {
|
10
73
|
return fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
|
@@ -55,6 +118,15 @@
|
|
55
118
|
price: price,
|
56
119
|
})));
|
57
120
|
},
|
121
|
+
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
122
|
+
getCartInfo() {
|
123
|
+
let cartToken = getCookieValue(cartTokenCookie);
|
124
|
+
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
125
|
+
if (!cartToken) {
|
126
|
+
cartToken = getCookieValue(cartTokenTwoCookie);
|
127
|
+
}
|
128
|
+
return { cartToken, cartCurrency };
|
129
|
+
},
|
58
130
|
});
|
59
131
|
window[registryKey].storeAPIFactory = createShopApi;
|
60
132
|
window[registryKey].platform = 'SHOPIFY';
|
package/stores/shopify/index.mjs
CHANGED
@@ -1,7 +1,70 @@
|
|
1
|
+
const expand = (str) => str.split(',').flatMap((entry) => {
|
2
|
+
if (!entry.includes('-')) {
|
3
|
+
return entry;
|
4
|
+
}
|
5
|
+
const result = [];
|
6
|
+
const [start, end] = entry.split('-').map(Number);
|
7
|
+
for (let i = start; i <= end; i++) {
|
8
|
+
result.push(i.toString());
|
9
|
+
}
|
10
|
+
return result;
|
11
|
+
});
|
12
|
+
/**
|
13
|
+
* Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
|
14
|
+
*
|
15
|
+
* In Dev Tools, select the `tbody` element containing the area codes and run the following code,
|
16
|
+
* replacing the emdash character with a simple endash:
|
17
|
+
*
|
18
|
+
* ```ts
|
19
|
+
* [...$0.querySelectorAll('td:first-child')]
|
20
|
+
* .filter(cell => cell.firstChild.nodeName != 'A')
|
21
|
+
* .map(cell => cell.textContent.trim()).join(',')
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
new Set([
|
25
|
+
...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'),
|
26
|
+
...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'),
|
27
|
+
...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'),
|
28
|
+
...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'),
|
29
|
+
...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'),
|
30
|
+
...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'),
|
31
|
+
...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
|
32
|
+
...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'),
|
33
|
+
]);
|
34
|
+
|
35
|
+
const cartTokenCookie = 'cart';
|
36
|
+
const cartTokenTwoCookie = 'cart2';
|
37
|
+
const cartCurrencyCookie = 'cart_currency';
|
38
|
+
|
1
39
|
var _a;
|
2
40
|
const registryKey = Symbol.for('blotout-wallet');
|
3
41
|
(_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
|
4
42
|
|
43
|
+
const getCookieValue = (key) => {
|
44
|
+
try {
|
45
|
+
if (!document || !document.cookie) {
|
46
|
+
return '';
|
47
|
+
}
|
48
|
+
const name = `${key}=`;
|
49
|
+
const decodedCookie = decodeURIComponent(document.cookie);
|
50
|
+
const ca = decodedCookie.split(';');
|
51
|
+
for (let i = 0; i < ca.length; i++) {
|
52
|
+
let c = ca[i];
|
53
|
+
while (c.charAt(0) === ' ') {
|
54
|
+
c = c.substring(1);
|
55
|
+
}
|
56
|
+
if (c.indexOf(name) === 0) {
|
57
|
+
return c.substring(name.length, c.length);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return '';
|
61
|
+
}
|
62
|
+
catch {
|
63
|
+
return '';
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
// eslint-disable-next-line @nx/enforce-module-boundaries
|
5
68
|
const createShopApi = (fetchOverride = window.fetch) => ({
|
6
69
|
addItems(items) {
|
7
70
|
return fetchOverride(`${window.Shopify.routes.root}cart/add.js`, {
|
@@ -52,6 +115,15 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
52
115
|
price: price,
|
53
116
|
})));
|
54
117
|
},
|
118
|
+
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
119
|
+
getCartInfo() {
|
120
|
+
let cartToken = getCookieValue(cartTokenCookie);
|
121
|
+
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
122
|
+
if (!cartToken) {
|
123
|
+
cartToken = getCookieValue(cartTokenTwoCookie);
|
124
|
+
}
|
125
|
+
return { cartToken, cartCurrency };
|
126
|
+
},
|
55
127
|
});
|
56
128
|
window[registryKey].storeAPIFactory = createShopApi;
|
57
129
|
window[registryKey].platform = 'SHOPIFY';
|