@blotoutio/providers-blotout-wallet-sdk 0.55.0 → 0.55.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/index.cjs.js +56 -22
- package/index.js +56 -22
- package/index.mjs +56 -22
- package/package.json +1 -1
- package/stores/shopify/index.cjs.js +1 -3
- package/stores/shopify/index.js +1 -3
- package/stores/shopify/index.mjs +1 -3
package/index.cjs.js
CHANGED
@@ -48,6 +48,7 @@ const customAttributes = {
|
|
48
48
|
type: 'text',
|
49
49
|
defaultValue: "Hey! Your cart has expired!<br>But we've got you covered! \u{1F609}",
|
50
50
|
},
|
51
|
+
title: { type: 'text', defaultValue: '' },
|
51
52
|
inputLabel: { type: 'text', defaultValue: 'Enter your email ID' },
|
52
53
|
restoreLabel: { type: 'text', defaultValue: 'Restore Cart' },
|
53
54
|
rejectionLabel: {
|
@@ -59,7 +60,6 @@ const customAttributes = {
|
|
59
60
|
const packageName = 'blotoutWallet';
|
60
61
|
const cartTokenCookie = 'cart';
|
61
62
|
const cartTokenTwoCookie = 'cart2';
|
62
|
-
const cartCurrencyCookie = 'cart_currency';
|
63
63
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
64
64
|
|
65
65
|
const getCookieValue = (key) => {
|
@@ -168,7 +168,6 @@ const tag = ({ eventName }) => {
|
|
168
168
|
switch (platform) {
|
169
169
|
case 'SHOPIFY': {
|
170
170
|
let cartToken = getCookieValue(cartTokenCookie);
|
171
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
172
171
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
173
172
|
if (!cartToken) {
|
174
173
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -179,7 +178,7 @@ const tag = ({ eventName }) => {
|
|
179
178
|
if (cartTokenLink) {
|
180
179
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
181
180
|
}
|
182
|
-
return { cartToken,
|
181
|
+
return { cartToken, cartTokenLink };
|
183
182
|
}
|
184
183
|
default: {
|
185
184
|
return {};
|
@@ -433,6 +432,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
433
432
|
this.hasEmail = false;
|
434
433
|
this.lastExpiredCart = undefined;
|
435
434
|
this.state = 'ready';
|
435
|
+
this.isStylesheetInjected = false;
|
436
436
|
this.transitionTo = (newState) => {
|
437
437
|
return flipOut(this.dialog)
|
438
438
|
.then(() => (this.state = newState))
|
@@ -480,6 +480,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
480
480
|
if (!response.ok) {
|
481
481
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
482
482
|
}
|
483
|
+
// Redirect to custom path
|
484
|
+
if (this.restoreRedirect) {
|
485
|
+
try {
|
486
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
487
|
+
window.location.href = redirect.href;
|
488
|
+
}
|
489
|
+
catch (e) {
|
490
|
+
console.error('Invalid redirect URL', e);
|
491
|
+
}
|
492
|
+
}
|
483
493
|
})
|
484
494
|
.catch((err) => {
|
485
495
|
console.error(err);
|
@@ -512,19 +522,23 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
512
522
|
ev.stopPropagation();
|
513
523
|
};
|
514
524
|
this.expiredCartContent = () => {
|
515
|
-
var _a, _b, _c, _d;
|
525
|
+
var _a, _b, _c, _d, _e;
|
516
526
|
return x `<form
|
517
527
|
class="restore-form"
|
518
528
|
method="dialog"
|
519
529
|
@submit=${this.onSubmit}
|
520
530
|
>
|
521
|
-
|
522
|
-
|
531
|
+
${((_a = this.theme) === null || _a === void 0 ? void 0 : _a.title)
|
532
|
+
? x `<h1 class="title">${this.theme.title}</h1>`
|
533
|
+
: T}
|
534
|
+
<div class="text">
|
535
|
+
${formatString(((_b = this.theme) === null || _b === void 0 ? void 0 : _b.text) || customAttributes.text.defaultValue)}
|
523
536
|
</div>
|
524
537
|
<input
|
525
538
|
type="email"
|
526
539
|
name="email"
|
527
|
-
|
540
|
+
class="email"
|
541
|
+
placeholder=${((_c = this.theme) === null || _c === void 0 ? void 0 : _c.inputLabel) ||
|
528
542
|
customAttributes.inputLabel.defaultValue}
|
529
543
|
?required=${!this.hasEmail}
|
530
544
|
style=${o$1({
|
@@ -532,12 +546,12 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
532
546
|
})}
|
533
547
|
/>
|
534
548
|
<button class="restore" type="submit">
|
535
|
-
${((
|
549
|
+
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.restoreLabel) ||
|
536
550
|
customAttributes.restoreLabel.defaultValue}
|
537
551
|
</button>
|
538
552
|
</form>
|
539
|
-
<button class="
|
540
|
-
${((
|
553
|
+
<button class="reject" type="button" @click=${this.skipCarts}>
|
554
|
+
${((_e = this.theme) === null || _e === void 0 ? void 0 : _e.rejectionLabel) ||
|
541
555
|
customAttributes.rejectionLabel.defaultValue}
|
542
556
|
</button> `;
|
543
557
|
};
|
@@ -560,7 +574,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
560
574
|
<form method="dialog" @submit=${this.onSubmit}>
|
561
575
|
<button class="restore" type="submit">Try Again</button>
|
562
576
|
</form>
|
563
|
-
<button class="
|
577
|
+
<button class="reject" @click=${this.skipCarts}>Dismiss</button>
|
564
578
|
`;
|
565
579
|
};
|
566
580
|
}
|
@@ -580,7 +594,14 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
580
594
|
}).catch(logger.error);
|
581
595
|
}
|
582
596
|
connectedCallback() {
|
597
|
+
var _a;
|
583
598
|
super.connectedCallback();
|
599
|
+
if (!this.isStylesheetInjected && ((_a = this.theme) === null || _a === void 0 ? void 0 : _a.css)) {
|
600
|
+
const sheet = new CSSStyleSheet();
|
601
|
+
sheet.replaceSync(this.theme.css);
|
602
|
+
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
603
|
+
this.isStylesheetInjected = true;
|
604
|
+
}
|
584
605
|
if (!this.userId) {
|
585
606
|
logger.error('No UserId set');
|
586
607
|
return;
|
@@ -634,8 +655,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
634
655
|
getUrl(path) {
|
635
656
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
636
657
|
if (this.storeApi) {
|
637
|
-
const { cartToken
|
638
|
-
url.searchParams.set('c', cartCurrency);
|
658
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
639
659
|
url.searchParams.set('t', cartToken);
|
640
660
|
}
|
641
661
|
return url;
|
@@ -658,7 +678,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
658
678
|
if (this.isPopUpDismissed) {
|
659
679
|
return T;
|
660
680
|
}
|
661
|
-
return x
|
681
|
+
return x ` <dialog class="popup" @click=${this.onDialogClick}>
|
662
682
|
<div @click=${this.onWrapperClick}>
|
663
683
|
<div
|
664
684
|
class="centered"
|
@@ -714,7 +734,7 @@ BlotoutWallet.styles = [
|
|
714
734
|
cursor: pointer;
|
715
735
|
}
|
716
736
|
|
717
|
-
|
737
|
+
.popup {
|
718
738
|
width: 430px;
|
719
739
|
max-width: 100vw;
|
720
740
|
color: var(--primary);
|
@@ -725,19 +745,32 @@ BlotoutWallet.styles = [
|
|
725
745
|
text-align: center;
|
726
746
|
}
|
727
747
|
|
728
|
-
|
748
|
+
.popup::backdrop {
|
729
749
|
background: var(--backdrop);
|
730
750
|
backdrop-filter: blur(4px);
|
731
751
|
}
|
732
752
|
|
733
|
-
|
753
|
+
.restore-form {
|
734
754
|
display: flex;
|
735
755
|
flex-direction: column;
|
736
756
|
gap: 16px;
|
737
757
|
width: 100%;
|
738
758
|
}
|
739
759
|
|
740
|
-
|
760
|
+
.title {
|
761
|
+
margin: 0;
|
762
|
+
padding: 0;
|
763
|
+
font-size: 20px;
|
764
|
+
font-weight: bold;
|
765
|
+
line-height: 30px;
|
766
|
+
}
|
767
|
+
|
768
|
+
.text {
|
769
|
+
margin: 0;
|
770
|
+
padding: 0;
|
771
|
+
}
|
772
|
+
|
773
|
+
.email {
|
741
774
|
width: 100%;
|
742
775
|
border: 1px solid var(--input-border);
|
743
776
|
color: var(--input-foreground);
|
@@ -746,12 +779,12 @@ BlotoutWallet.styles = [
|
|
746
779
|
border-radius: 5px;
|
747
780
|
}
|
748
781
|
|
749
|
-
|
782
|
+
.email::placeholder {
|
750
783
|
color: var(--input-foreground);
|
751
784
|
color: color(from var(--input-foreground) srgb r g b / 0.7);
|
752
785
|
}
|
753
786
|
|
754
|
-
:is(
|
787
|
+
:is(.email, button):focus-visible {
|
755
788
|
outline-color: var(--primary);
|
756
789
|
}
|
757
790
|
|
@@ -764,7 +797,7 @@ BlotoutWallet.styles = [
|
|
764
797
|
padding: 12px 20px;
|
765
798
|
}
|
766
799
|
|
767
|
-
.
|
800
|
+
.reject {
|
768
801
|
font-size: 14px;
|
769
802
|
line-height: 20px;
|
770
803
|
color: var(--secondary);
|
@@ -813,7 +846,7 @@ BlotoutWallet = __decorate([
|
|
813
846
|
], BlotoutWallet);
|
814
847
|
|
815
848
|
const init = (params) => {
|
816
|
-
var _a, _b, _c, _d;
|
849
|
+
var _a, _b, _c, _d, _e;
|
817
850
|
if (
|
818
851
|
// if loaded in non-browser SDKs
|
819
852
|
!window ||
|
@@ -842,6 +875,7 @@ const init = (params) => {
|
|
842
875
|
element.theme = theme;
|
843
876
|
element.edgeURL = params.baseUrl;
|
844
877
|
element.userId = params.userId;
|
878
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
845
879
|
document.body.append(element);
|
846
880
|
}
|
847
881
|
};
|
package/index.js
CHANGED
@@ -49,6 +49,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
49
49
|
type: 'text',
|
50
50
|
defaultValue: "Hey! Your cart has expired!<br>But we've got you covered! \u{1F609}",
|
51
51
|
},
|
52
|
+
title: { type: 'text', defaultValue: '' },
|
52
53
|
inputLabel: { type: 'text', defaultValue: 'Enter your email ID' },
|
53
54
|
restoreLabel: { type: 'text', defaultValue: 'Restore Cart' },
|
54
55
|
rejectionLabel: {
|
@@ -60,7 +61,6 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
60
61
|
const packageName = 'blotoutWallet';
|
61
62
|
const cartTokenCookie = 'cart';
|
62
63
|
const cartTokenTwoCookie = 'cart2';
|
63
|
-
const cartCurrencyCookie = 'cart_currency';
|
64
64
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
65
65
|
|
66
66
|
const getCookieValue = (key) => {
|
@@ -169,7 +169,6 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
169
169
|
switch (platform) {
|
170
170
|
case 'SHOPIFY': {
|
171
171
|
let cartToken = getCookieValue(cartTokenCookie);
|
172
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
173
172
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
174
173
|
if (!cartToken) {
|
175
174
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -180,7 +179,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
180
179
|
if (cartTokenLink) {
|
181
180
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
182
181
|
}
|
183
|
-
return { cartToken,
|
182
|
+
return { cartToken, cartTokenLink };
|
184
183
|
}
|
185
184
|
default: {
|
186
185
|
return {};
|
@@ -434,6 +433,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
434
433
|
this.hasEmail = false;
|
435
434
|
this.lastExpiredCart = undefined;
|
436
435
|
this.state = 'ready';
|
436
|
+
this.isStylesheetInjected = false;
|
437
437
|
this.transitionTo = (newState) => {
|
438
438
|
return flipOut(this.dialog)
|
439
439
|
.then(() => (this.state = newState))
|
@@ -481,6 +481,16 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
481
481
|
if (!response.ok) {
|
482
482
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
483
483
|
}
|
484
|
+
// Redirect to custom path
|
485
|
+
if (this.restoreRedirect) {
|
486
|
+
try {
|
487
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
488
|
+
window.location.href = redirect.href;
|
489
|
+
}
|
490
|
+
catch (e) {
|
491
|
+
console.error('Invalid redirect URL', e);
|
492
|
+
}
|
493
|
+
}
|
484
494
|
})
|
485
495
|
.catch((err) => {
|
486
496
|
console.error(err);
|
@@ -513,19 +523,23 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
513
523
|
ev.stopPropagation();
|
514
524
|
};
|
515
525
|
this.expiredCartContent = () => {
|
516
|
-
var _a, _b, _c, _d;
|
526
|
+
var _a, _b, _c, _d, _e;
|
517
527
|
return x `<form
|
518
528
|
class="restore-form"
|
519
529
|
method="dialog"
|
520
530
|
@submit=${this.onSubmit}
|
521
531
|
>
|
522
|
-
|
523
|
-
|
532
|
+
${((_a = this.theme) === null || _a === void 0 ? void 0 : _a.title)
|
533
|
+
? x `<h1 class="title">${this.theme.title}</h1>`
|
534
|
+
: T}
|
535
|
+
<div class="text">
|
536
|
+
${formatString(((_b = this.theme) === null || _b === void 0 ? void 0 : _b.text) || customAttributes.text.defaultValue)}
|
524
537
|
</div>
|
525
538
|
<input
|
526
539
|
type="email"
|
527
540
|
name="email"
|
528
|
-
|
541
|
+
class="email"
|
542
|
+
placeholder=${((_c = this.theme) === null || _c === void 0 ? void 0 : _c.inputLabel) ||
|
529
543
|
customAttributes.inputLabel.defaultValue}
|
530
544
|
?required=${!this.hasEmail}
|
531
545
|
style=${o$1({
|
@@ -533,12 +547,12 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
533
547
|
})}
|
534
548
|
/>
|
535
549
|
<button class="restore" type="submit">
|
536
|
-
${((
|
550
|
+
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.restoreLabel) ||
|
537
551
|
customAttributes.restoreLabel.defaultValue}
|
538
552
|
</button>
|
539
553
|
</form>
|
540
|
-
<button class="
|
541
|
-
${((
|
554
|
+
<button class="reject" type="button" @click=${this.skipCarts}>
|
555
|
+
${((_e = this.theme) === null || _e === void 0 ? void 0 : _e.rejectionLabel) ||
|
542
556
|
customAttributes.rejectionLabel.defaultValue}
|
543
557
|
</button> `;
|
544
558
|
};
|
@@ -561,7 +575,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
561
575
|
<form method="dialog" @submit=${this.onSubmit}>
|
562
576
|
<button class="restore" type="submit">Try Again</button>
|
563
577
|
</form>
|
564
|
-
<button class="
|
578
|
+
<button class="reject" @click=${this.skipCarts}>Dismiss</button>
|
565
579
|
`;
|
566
580
|
};
|
567
581
|
}
|
@@ -581,7 +595,14 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
581
595
|
}).catch(logger.error);
|
582
596
|
}
|
583
597
|
connectedCallback() {
|
598
|
+
var _a;
|
584
599
|
super.connectedCallback();
|
600
|
+
if (!this.isStylesheetInjected && ((_a = this.theme) === null || _a === void 0 ? void 0 : _a.css)) {
|
601
|
+
const sheet = new CSSStyleSheet();
|
602
|
+
sheet.replaceSync(this.theme.css);
|
603
|
+
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
604
|
+
this.isStylesheetInjected = true;
|
605
|
+
}
|
585
606
|
if (!this.userId) {
|
586
607
|
logger.error('No UserId set');
|
587
608
|
return;
|
@@ -635,8 +656,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
635
656
|
getUrl(path) {
|
636
657
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
637
658
|
if (this.storeApi) {
|
638
|
-
const { cartToken
|
639
|
-
url.searchParams.set('c', cartCurrency);
|
659
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
640
660
|
url.searchParams.set('t', cartToken);
|
641
661
|
}
|
642
662
|
return url;
|
@@ -659,7 +679,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
659
679
|
if (this.isPopUpDismissed) {
|
660
680
|
return T;
|
661
681
|
}
|
662
|
-
return x
|
682
|
+
return x ` <dialog class="popup" @click=${this.onDialogClick}>
|
663
683
|
<div @click=${this.onWrapperClick}>
|
664
684
|
<div
|
665
685
|
class="centered"
|
@@ -715,7 +735,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
715
735
|
cursor: pointer;
|
716
736
|
}
|
717
737
|
|
718
|
-
|
738
|
+
.popup {
|
719
739
|
width: 430px;
|
720
740
|
max-width: 100vw;
|
721
741
|
color: var(--primary);
|
@@ -726,19 +746,32 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
726
746
|
text-align: center;
|
727
747
|
}
|
728
748
|
|
729
|
-
|
749
|
+
.popup::backdrop {
|
730
750
|
background: var(--backdrop);
|
731
751
|
backdrop-filter: blur(4px);
|
732
752
|
}
|
733
753
|
|
734
|
-
|
754
|
+
.restore-form {
|
735
755
|
display: flex;
|
736
756
|
flex-direction: column;
|
737
757
|
gap: 16px;
|
738
758
|
width: 100%;
|
739
759
|
}
|
740
760
|
|
741
|
-
|
761
|
+
.title {
|
762
|
+
margin: 0;
|
763
|
+
padding: 0;
|
764
|
+
font-size: 20px;
|
765
|
+
font-weight: bold;
|
766
|
+
line-height: 30px;
|
767
|
+
}
|
768
|
+
|
769
|
+
.text {
|
770
|
+
margin: 0;
|
771
|
+
padding: 0;
|
772
|
+
}
|
773
|
+
|
774
|
+
.email {
|
742
775
|
width: 100%;
|
743
776
|
border: 1px solid var(--input-border);
|
744
777
|
color: var(--input-foreground);
|
@@ -747,12 +780,12 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
747
780
|
border-radius: 5px;
|
748
781
|
}
|
749
782
|
|
750
|
-
|
783
|
+
.email::placeholder {
|
751
784
|
color: var(--input-foreground);
|
752
785
|
color: color(from var(--input-foreground) srgb r g b / 0.7);
|
753
786
|
}
|
754
787
|
|
755
|
-
:is(
|
788
|
+
:is(.email, button):focus-visible {
|
756
789
|
outline-color: var(--primary);
|
757
790
|
}
|
758
791
|
|
@@ -765,7 +798,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
765
798
|
padding: 12px 20px;
|
766
799
|
}
|
767
800
|
|
768
|
-
.
|
801
|
+
.reject {
|
769
802
|
font-size: 14px;
|
770
803
|
line-height: 20px;
|
771
804
|
color: var(--secondary);
|
@@ -814,7 +847,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
814
847
|
], BlotoutWallet);
|
815
848
|
|
816
849
|
const init = (params) => {
|
817
|
-
var _a, _b, _c, _d;
|
850
|
+
var _a, _b, _c, _d, _e;
|
818
851
|
if (
|
819
852
|
// if loaded in non-browser SDKs
|
820
853
|
!window ||
|
@@ -843,6 +876,7 @@ var ProvidersBlotoutWalletSdk = (function () {
|
|
843
876
|
element.theme = theme;
|
844
877
|
element.edgeURL = params.baseUrl;
|
845
878
|
element.userId = params.userId;
|
879
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
846
880
|
document.body.append(element);
|
847
881
|
}
|
848
882
|
};
|
package/index.mjs
CHANGED
@@ -46,6 +46,7 @@ const customAttributes = {
|
|
46
46
|
type: 'text',
|
47
47
|
defaultValue: "Hey! Your cart has expired!<br>But we've got you covered! \u{1F609}",
|
48
48
|
},
|
49
|
+
title: { type: 'text', defaultValue: '' },
|
49
50
|
inputLabel: { type: 'text', defaultValue: 'Enter your email ID' },
|
50
51
|
restoreLabel: { type: 'text', defaultValue: 'Restore Cart' },
|
51
52
|
rejectionLabel: {
|
@@ -57,7 +58,6 @@ const customAttributes = {
|
|
57
58
|
const packageName = 'blotoutWallet';
|
58
59
|
const cartTokenCookie = 'cart';
|
59
60
|
const cartTokenTwoCookie = 'cart2';
|
60
|
-
const cartCurrencyCookie = 'cart_currency';
|
61
61
|
const cartTokenLinkCookie = 'bwCartLinkToken';
|
62
62
|
|
63
63
|
const getCookieValue = (key) => {
|
@@ -166,7 +166,6 @@ const tag = ({ eventName }) => {
|
|
166
166
|
switch (platform) {
|
167
167
|
case 'SHOPIFY': {
|
168
168
|
let cartToken = getCookieValue(cartTokenCookie);
|
169
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
170
169
|
const cartTokenLink = getCookieValue(cartTokenLinkCookie);
|
171
170
|
if (!cartToken) {
|
172
171
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
@@ -177,7 +176,7 @@ const tag = ({ eventName }) => {
|
|
177
176
|
if (cartTokenLink) {
|
178
177
|
setCookie(cartTokenLinkCookie, '', { maxAge: 0 });
|
179
178
|
}
|
180
|
-
return { cartToken,
|
179
|
+
return { cartToken, cartTokenLink };
|
181
180
|
}
|
182
181
|
default: {
|
183
182
|
return {};
|
@@ -431,6 +430,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
431
430
|
this.hasEmail = false;
|
432
431
|
this.lastExpiredCart = undefined;
|
433
432
|
this.state = 'ready';
|
433
|
+
this.isStylesheetInjected = false;
|
434
434
|
this.transitionTo = (newState) => {
|
435
435
|
return flipOut(this.dialog)
|
436
436
|
.then(() => (this.state = newState))
|
@@ -478,6 +478,16 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
478
478
|
if (!response.ok) {
|
479
479
|
throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
|
480
480
|
}
|
481
|
+
// Redirect to custom path
|
482
|
+
if (this.restoreRedirect) {
|
483
|
+
try {
|
484
|
+
const redirect = new URL(this.restoreRedirect, window.location.origin);
|
485
|
+
window.location.href = redirect.href;
|
486
|
+
}
|
487
|
+
catch (e) {
|
488
|
+
console.error('Invalid redirect URL', e);
|
489
|
+
}
|
490
|
+
}
|
481
491
|
})
|
482
492
|
.catch((err) => {
|
483
493
|
console.error(err);
|
@@ -510,19 +520,23 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
510
520
|
ev.stopPropagation();
|
511
521
|
};
|
512
522
|
this.expiredCartContent = () => {
|
513
|
-
var _a, _b, _c, _d;
|
523
|
+
var _a, _b, _c, _d, _e;
|
514
524
|
return x `<form
|
515
525
|
class="restore-form"
|
516
526
|
method="dialog"
|
517
527
|
@submit=${this.onSubmit}
|
518
528
|
>
|
519
|
-
|
520
|
-
|
529
|
+
${((_a = this.theme) === null || _a === void 0 ? void 0 : _a.title)
|
530
|
+
? x `<h1 class="title">${this.theme.title}</h1>`
|
531
|
+
: T}
|
532
|
+
<div class="text">
|
533
|
+
${formatString(((_b = this.theme) === null || _b === void 0 ? void 0 : _b.text) || customAttributes.text.defaultValue)}
|
521
534
|
</div>
|
522
535
|
<input
|
523
536
|
type="email"
|
524
537
|
name="email"
|
525
|
-
|
538
|
+
class="email"
|
539
|
+
placeholder=${((_c = this.theme) === null || _c === void 0 ? void 0 : _c.inputLabel) ||
|
526
540
|
customAttributes.inputLabel.defaultValue}
|
527
541
|
?required=${!this.hasEmail}
|
528
542
|
style=${o$1({
|
@@ -530,12 +544,12 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
530
544
|
})}
|
531
545
|
/>
|
532
546
|
<button class="restore" type="submit">
|
533
|
-
${((
|
547
|
+
${((_d = this.theme) === null || _d === void 0 ? void 0 : _d.restoreLabel) ||
|
534
548
|
customAttributes.restoreLabel.defaultValue}
|
535
549
|
</button>
|
536
550
|
</form>
|
537
|
-
<button class="
|
538
|
-
${((
|
551
|
+
<button class="reject" type="button" @click=${this.skipCarts}>
|
552
|
+
${((_e = this.theme) === null || _e === void 0 ? void 0 : _e.rejectionLabel) ||
|
539
553
|
customAttributes.rejectionLabel.defaultValue}
|
540
554
|
</button> `;
|
541
555
|
};
|
@@ -558,7 +572,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
558
572
|
<form method="dialog" @submit=${this.onSubmit}>
|
559
573
|
<button class="restore" type="submit">Try Again</button>
|
560
574
|
</form>
|
561
|
-
<button class="
|
575
|
+
<button class="reject" @click=${this.skipCarts}>Dismiss</button>
|
562
576
|
`;
|
563
577
|
};
|
564
578
|
}
|
@@ -578,7 +592,14 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
578
592
|
}).catch(logger.error);
|
579
593
|
}
|
580
594
|
connectedCallback() {
|
595
|
+
var _a;
|
581
596
|
super.connectedCallback();
|
597
|
+
if (!this.isStylesheetInjected && ((_a = this.theme) === null || _a === void 0 ? void 0 : _a.css)) {
|
598
|
+
const sheet = new CSSStyleSheet();
|
599
|
+
sheet.replaceSync(this.theme.css);
|
600
|
+
this.shadowRoot.adoptedStyleSheets.push(sheet);
|
601
|
+
this.isStylesheetInjected = true;
|
602
|
+
}
|
582
603
|
if (!this.userId) {
|
583
604
|
logger.error('No UserId set');
|
584
605
|
return;
|
@@ -632,8 +653,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
632
653
|
getUrl(path) {
|
633
654
|
const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
|
634
655
|
if (this.storeApi) {
|
635
|
-
const { cartToken
|
636
|
-
url.searchParams.set('c', cartCurrency);
|
656
|
+
const { cartToken } = this.storeApi.getCartInfo();
|
637
657
|
url.searchParams.set('t', cartToken);
|
638
658
|
}
|
639
659
|
return url;
|
@@ -656,7 +676,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
|
|
656
676
|
if (this.isPopUpDismissed) {
|
657
677
|
return T;
|
658
678
|
}
|
659
|
-
return x
|
679
|
+
return x ` <dialog class="popup" @click=${this.onDialogClick}>
|
660
680
|
<div @click=${this.onWrapperClick}>
|
661
681
|
<div
|
662
682
|
class="centered"
|
@@ -712,7 +732,7 @@ BlotoutWallet.styles = [
|
|
712
732
|
cursor: pointer;
|
713
733
|
}
|
714
734
|
|
715
|
-
|
735
|
+
.popup {
|
716
736
|
width: 430px;
|
717
737
|
max-width: 100vw;
|
718
738
|
color: var(--primary);
|
@@ -723,19 +743,32 @@ BlotoutWallet.styles = [
|
|
723
743
|
text-align: center;
|
724
744
|
}
|
725
745
|
|
726
|
-
|
746
|
+
.popup::backdrop {
|
727
747
|
background: var(--backdrop);
|
728
748
|
backdrop-filter: blur(4px);
|
729
749
|
}
|
730
750
|
|
731
|
-
|
751
|
+
.restore-form {
|
732
752
|
display: flex;
|
733
753
|
flex-direction: column;
|
734
754
|
gap: 16px;
|
735
755
|
width: 100%;
|
736
756
|
}
|
737
757
|
|
738
|
-
|
758
|
+
.title {
|
759
|
+
margin: 0;
|
760
|
+
padding: 0;
|
761
|
+
font-size: 20px;
|
762
|
+
font-weight: bold;
|
763
|
+
line-height: 30px;
|
764
|
+
}
|
765
|
+
|
766
|
+
.text {
|
767
|
+
margin: 0;
|
768
|
+
padding: 0;
|
769
|
+
}
|
770
|
+
|
771
|
+
.email {
|
739
772
|
width: 100%;
|
740
773
|
border: 1px solid var(--input-border);
|
741
774
|
color: var(--input-foreground);
|
@@ -744,12 +777,12 @@ BlotoutWallet.styles = [
|
|
744
777
|
border-radius: 5px;
|
745
778
|
}
|
746
779
|
|
747
|
-
|
780
|
+
.email::placeholder {
|
748
781
|
color: var(--input-foreground);
|
749
782
|
color: color(from var(--input-foreground) srgb r g b / 0.7);
|
750
783
|
}
|
751
784
|
|
752
|
-
:is(
|
785
|
+
:is(.email, button):focus-visible {
|
753
786
|
outline-color: var(--primary);
|
754
787
|
}
|
755
788
|
|
@@ -762,7 +795,7 @@ BlotoutWallet.styles = [
|
|
762
795
|
padding: 12px 20px;
|
763
796
|
}
|
764
797
|
|
765
|
-
.
|
798
|
+
.reject {
|
766
799
|
font-size: 14px;
|
767
800
|
line-height: 20px;
|
768
801
|
color: var(--secondary);
|
@@ -811,7 +844,7 @@ BlotoutWallet = __decorate([
|
|
811
844
|
], BlotoutWallet);
|
812
845
|
|
813
846
|
const init = (params) => {
|
814
|
-
var _a, _b, _c, _d;
|
847
|
+
var _a, _b, _c, _d, _e;
|
815
848
|
if (
|
816
849
|
// if loaded in non-browser SDKs
|
817
850
|
!window ||
|
@@ -840,6 +873,7 @@ const init = (params) => {
|
|
840
873
|
element.theme = theme;
|
841
874
|
element.edgeURL = params.baseUrl;
|
842
875
|
element.userId = params.userId;
|
876
|
+
element.restoreRedirect = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e['restoreRedirect'];
|
843
877
|
document.body.append(element);
|
844
878
|
}
|
845
879
|
};
|
package/package.json
CHANGED
@@ -36,7 +36,6 @@ new Set([
|
|
36
36
|
|
37
37
|
const cartTokenCookie = 'cart';
|
38
38
|
const cartTokenTwoCookie = 'cart2';
|
39
|
-
const cartCurrencyCookie = 'cart_currency';
|
40
39
|
|
41
40
|
var _a;
|
42
41
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -120,11 +119,10 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
120
119
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
121
120
|
getCartInfo() {
|
122
121
|
let cartToken = getCookieValue(cartTokenCookie);
|
123
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
124
122
|
if (!cartToken) {
|
125
123
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
126
124
|
}
|
127
|
-
return { cartToken
|
125
|
+
return { cartToken };
|
128
126
|
},
|
129
127
|
});
|
130
128
|
window[registryKey].storeAPIFactory = createShopApi;
|
package/stores/shopify/index.js
CHANGED
@@ -37,7 +37,6 @@
|
|
37
37
|
|
38
38
|
const cartTokenCookie = 'cart';
|
39
39
|
const cartTokenTwoCookie = 'cart2';
|
40
|
-
const cartCurrencyCookie = 'cart_currency';
|
41
40
|
|
42
41
|
var _a;
|
43
42
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -121,11 +120,10 @@
|
|
121
120
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
122
121
|
getCartInfo() {
|
123
122
|
let cartToken = getCookieValue(cartTokenCookie);
|
124
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
125
123
|
if (!cartToken) {
|
126
124
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
127
125
|
}
|
128
|
-
return { cartToken
|
126
|
+
return { cartToken };
|
129
127
|
},
|
130
128
|
});
|
131
129
|
window[registryKey].storeAPIFactory = createShopApi;
|
package/stores/shopify/index.mjs
CHANGED
@@ -34,7 +34,6 @@ new Set([
|
|
34
34
|
|
35
35
|
const cartTokenCookie = 'cart';
|
36
36
|
const cartTokenTwoCookie = 'cart2';
|
37
|
-
const cartCurrencyCookie = 'cart_currency';
|
38
37
|
|
39
38
|
var _a;
|
40
39
|
const registryKey = Symbol.for('blotout-wallet');
|
@@ -118,11 +117,10 @@ const createShopApi = (fetchOverride = window.fetch) => ({
|
|
118
117
|
// duplicated this on tag call, as this was not being set before tag call gets initiated
|
119
118
|
getCartInfo() {
|
120
119
|
let cartToken = getCookieValue(cartTokenCookie);
|
121
|
-
const cartCurrency = getCookieValue(cartCurrencyCookie);
|
122
120
|
if (!cartToken) {
|
123
121
|
cartToken = getCookieValue(cartTokenTwoCookie);
|
124
122
|
}
|
125
|
-
return { cartToken
|
123
|
+
return { cartToken };
|
126
124
|
},
|
127
125
|
});
|
128
126
|
window[registryKey].storeAPIFactory = createShopApi;
|