@saasquatch/squatch-js 2.6.0-1 → 2.6.0-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.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1689703614560" clover="3.2.0">
3
- <project timestamp="1689703614560" name="All files">
2
+ <coverage generated="1689713563033" clover="3.2.0">
3
+ <project timestamp="1689713563033" name="All files">
4
4
  <metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
5
5
  </project>
6
6
  </coverage>
@@ -289,7 +289,7 @@ export type SQHDetails = {
289
289
  <div class='footer quiet pad2 space-top1 center small'>
290
290
  Code coverage generated by
291
291
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
292
- at 2023-07-18T18:05:44.533Z
292
+ at 2023-07-18T18:59:28.021Z
293
293
  </div>
294
294
  <script src="../prettify.js"></script>
295
295
  <script>
@@ -290,12 +290,12 @@
290
290
  <span class="cline-any cline-neutral">&nbsp;</span>
291
291
  <span class="cline-any cline-neutral">&nbsp;</span>
292
292
  <span class="cline-any cline-neutral">&nbsp;</span>
293
- <span class="cline-any cline-yes">22x</span>
294
- <span class="cline-any cline-yes">22x</span>
293
+ <span class="cline-any cline-yes">29x</span>
294
+ <span class="cline-any cline-yes">29x</span>
295
295
  <span class="cline-any cline-neutral">&nbsp;</span>
296
- <span class="cline-any cline-yes">22x</span>
297
- <span class="cline-any cline-yes">22x</span>
298
- <span class="cline-any cline-yes">22x</span>
296
+ <span class="cline-any cline-yes">29x</span>
297
+ <span class="cline-any cline-yes">29x</span>
298
+ <span class="cline-any cline-yes">29x</span>
299
299
  <span class="cline-any cline-neutral">&nbsp;</span>
300
300
  <span class="cline-any cline-neutral">&nbsp;</span>
301
301
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -616,7 +616,7 @@ function <span class="fstat-no" title="function not covered" >_buildParams(</spa
616
616
  <div class='footer quiet pad2 space-top1 center small'>
617
617
  Code coverage generated by
618
618
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
619
- at 2023-07-18T18:05:44.533Z
619
+ at 2023-07-18T18:59:28.021Z
620
620
  </div>
621
621
  <script src="../prettify.js"></script>
622
622
  <script>
@@ -115,7 +115,7 @@
115
115
  <div class='footer quiet pad2 space-top1 center small'>
116
116
  Code coverage generated by
117
117
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
118
- at 2023-07-18T18:05:44.533Z
118
+ at 2023-07-18T18:59:28.021Z
119
119
  </div>
120
120
  <script src="../prettify.js"></script>
121
121
  <script>
@@ -145,7 +145,7 @@ export function <span class="fstat-no" title="function not covered" >domready(</
145
145
  <div class='footer quiet pad2 space-top1 center small'>
146
146
  Code coverage generated by
147
147
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
148
- at 2023-07-18T18:05:44.533Z
148
+ at 2023-07-18T18:59:28.021Z
149
149
  </div>
150
150
  <script src="../prettify.js"></script>
151
151
  <script>
@@ -385,7 +385,7 @@ export async function <span class="fstat-no" title="function not covered" >doPut
385
385
  <div class='footer quiet pad2 space-top1 center small'>
386
386
  Code coverage generated by
387
387
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
388
- at 2023-07-18T18:05:44.533Z
388
+ at 2023-07-18T18:59:28.021Z
389
389
  </div>
390
390
  <script src="../prettify.js"></script>
391
391
  <script>
@@ -136,24 +136,24 @@
136
136
  <span class="cline-any cline-yes">3x</span>
137
137
  <span class="cline-any cline-neutral">&nbsp;</span>
138
138
  <span class="cline-any cline-neutral">&nbsp;</span>
139
- <span class="cline-any cline-yes">44x</span>
139
+ <span class="cline-any cline-yes">58x</span>
140
140
  <span class="cline-any cline-neutral">&nbsp;</span>
141
- <span class="cline-any cline-yes">44x</span>
141
+ <span class="cline-any cline-yes">58x</span>
142
142
  <span class="cline-any cline-neutral">&nbsp;</span>
143
143
  <span class="cline-any cline-neutral">&nbsp;</span>
144
144
  <span class="cline-any cline-neutral">&nbsp;</span>
145
145
  <span class="cline-any cline-neutral">&nbsp;</span>
146
146
  <span class="cline-any cline-neutral">&nbsp;</span>
147
147
  <span class="cline-any cline-neutral">&nbsp;</span>
148
- <span class="cline-any cline-yes">44x</span>
148
+ <span class="cline-any cline-yes">58x</span>
149
149
  <span class="cline-any cline-no">&nbsp;</span>
150
- <span class="cline-any cline-yes">44x</span>
150
+ <span class="cline-any cline-yes">58x</span>
151
151
  <span class="cline-any cline-neutral">&nbsp;</span>
152
- <span class="cline-any cline-yes">44x</span>
153
- <span class="cline-any cline-yes">44x</span>
152
+ <span class="cline-any cline-yes">58x</span>
153
+ <span class="cline-any cline-yes">58x</span>
154
154
  <span class="cline-any cline-neutral">&nbsp;</span>
155
- <span class="cline-any cline-yes">44x</span>
156
- <span class="cline-any cline-yes">44x</span>
155
+ <span class="cline-any cline-yes">58x</span>
156
+ <span class="cline-any cline-yes">58x</span>
157
157
  <span class="cline-any cline-neutral">&nbsp;</span>
158
158
  <span class="cline-any cline-neutral">&nbsp;</span>
159
159
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -253,7 +253,7 @@ export function validatePasswordlessConfig(
253
253
  <div class='footer quiet pad2 space-top1 center small'>
254
254
  Code coverage generated by
255
255
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
256
- at 2023-07-18T18:05:44.533Z
256
+ at 2023-07-18T18:59:28.021Z
257
257
  </div>
258
258
  <script src="../prettify.js"></script>
259
259
  <script>
@@ -418,7 +418,7 @@ export default class EmbedWidget extends Widget {
418
418
  <div class='footer quiet pad2 space-top1 center small'>
419
419
  Code coverage generated by
420
420
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
421
- at 2023-07-18T18:05:44.533Z
421
+ at 2023-07-18T18:59:28.021Z
422
422
  </div>
423
423
  <script src="../prettify.js"></script>
424
424
  <script>
@@ -655,7 +655,7 @@ export default class PopupWidget extends Widget {
655
655
  <div class='footer quiet pad2 space-top1 center small'>
656
656
  Code coverage generated by
657
657
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
658
- at 2023-07-18T18:05:44.533Z
658
+ at 2023-07-18T18:59:28.021Z
659
659
  </div>
660
660
  <script src="../prettify.js"></script>
661
661
  <script>
@@ -1150,7 +1150,7 @@ function <span class="fstat-no" title="function not covered" >delay(</span>durat
1150
1150
  <div class='footer quiet pad2 space-top1 center small'>
1151
1151
  Code coverage generated by
1152
1152
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1153
- at 2023-07-18T18:05:44.533Z
1153
+ at 2023-07-18T18:59:28.021Z
1154
1154
  </div>
1155
1155
  <script src="../prettify.js"></script>
1156
1156
  <script>
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">73.26% </span>
26
+ <span class="strong">86.13% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>74/101</span>
28
+ <span class='fraction'>87/101</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">39.02% </span>
33
+ <span class="strong">68.29% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>16/41</span>
35
+ <span class='fraction'>28/41</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">63.63% </span>
40
+ <span class="strong">90.9% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>7/11</span>
42
+ <span class='fraction'>10/11</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">73.46% </span>
47
+ <span class="strong">85.71% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>72/98</span>
49
+ <span class='fraction'>84/98</span>
50
50
  </div>
51
51
 
52
52
 
@@ -61,7 +61,7 @@
61
61
  </div>
62
62
  </template>
63
63
  </div>
64
- <div class='status-line medium'></div>
64
+ <div class='status-line high'></div>
65
65
  <pre><table class="coverage">
66
66
  <tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
67
67
  <a name='L2'></a><a href='#L2'>2</a>
@@ -438,11 +438,11 @@
438
438
  <span class="cline-any cline-neutral">&nbsp;</span>
439
439
  <span class="cline-any cline-neutral">&nbsp;</span>
440
440
  <span class="cline-any cline-neutral">&nbsp;</span>
441
- <span class="cline-any cline-yes">22x</span>
442
- <span class="cline-any cline-yes">22x</span>
443
- <span class="cline-any cline-yes">22x</span>
444
- <span class="cline-any cline-yes">22x</span>
445
- <span class="cline-any cline-yes">22x</span>
441
+ <span class="cline-any cline-yes">29x</span>
442
+ <span class="cline-any cline-yes">29x</span>
443
+ <span class="cline-any cline-yes">29x</span>
444
+ <span class="cline-any cline-yes">29x</span>
445
+ <span class="cline-any cline-yes">29x</span>
446
446
  <span class="cline-any cline-neutral">&nbsp;</span>
447
447
  <span class="cline-any cline-neutral">&nbsp;</span>
448
448
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -580,15 +580,15 @@
580
580
  <span class="cline-any cline-neutral">&nbsp;</span>
581
581
  <span class="cline-any cline-neutral">&nbsp;</span>
582
582
  <span class="cline-any cline-neutral">&nbsp;</span>
583
- <span class="cline-any cline-yes">6x</span>
584
- <span class="cline-any cline-yes">6x</span>
583
+ <span class="cline-any cline-yes">13x</span>
584
+ <span class="cline-any cline-yes">13x</span>
585
585
  <span class="cline-any cline-neutral">&nbsp;</span>
586
586
  <span class="cline-any cline-neutral">&nbsp;</span>
587
- <span class="cline-any cline-yes">5x</span>
588
- <span class="cline-any cline-yes">5x</span>
589
- <span class="cline-any cline-yes">5x</span>
587
+ <span class="cline-any cline-yes">12x</span>
588
+ <span class="cline-any cline-yes">12x</span>
589
+ <span class="cline-any cline-yes">12x</span>
590
590
  <span class="cline-any cline-neutral">&nbsp;</span>
591
- <span class="cline-any cline-yes">5x</span>
591
+ <span class="cline-any cline-yes">12x</span>
592
592
  <span class="cline-any cline-neutral">&nbsp;</span>
593
593
  <span class="cline-any cline-neutral">&nbsp;</span>
594
594
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -597,16 +597,16 @@
597
597
  <span class="cline-any cline-neutral">&nbsp;</span>
598
598
  <span class="cline-any cline-neutral">&nbsp;</span>
599
599
  <span class="cline-any cline-neutral">&nbsp;</span>
600
- <span class="cline-any cline-yes">5x</span>
601
- <span class="cline-any cline-no">&nbsp;</span>
602
- <span class="cline-any cline-no">&nbsp;</span>
603
- <span class="cline-any cline-no">&nbsp;</span>
600
+ <span class="cline-any cline-yes">12x</span>
601
+ <span class="cline-any cline-yes">1x</span>
602
+ <span class="cline-any cline-yes">2x</span>
603
+ <span class="cline-any cline-yes">2x</span>
604
604
  <span class="cline-any cline-neutral">&nbsp;</span>
605
605
  <span class="cline-any cline-neutral">&nbsp;</span>
606
606
  <span class="cline-any cline-neutral">&nbsp;</span>
607
- <span class="cline-any cline-no">&nbsp;</span>
608
- <span class="cline-any cline-no">&nbsp;</span>
609
- <span class="cline-any cline-no">&nbsp;</span>
607
+ <span class="cline-any cline-yes">2x</span>
608
+ <span class="cline-any cline-yes">2x</span>
609
+ <span class="cline-any cline-yes">2x</span>
610
610
  <span class="cline-any cline-neutral">&nbsp;</span>
611
611
  <span class="cline-any cline-no">&nbsp;</span>
612
612
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -616,13 +616,13 @@
616
616
  <span class="cline-any cline-neutral">&nbsp;</span>
617
617
  <span class="cline-any cline-neutral">&nbsp;</span>
618
618
  <span class="cline-any cline-neutral">&nbsp;</span>
619
- <span class="cline-any cline-yes">5x</span>
620
- <span class="cline-any cline-no">&nbsp;</span>
619
+ <span class="cline-any cline-yes">12x</span>
620
+ <span class="cline-any cline-yes">1x</span>
621
621
  <span class="cline-any cline-neutral">&nbsp;</span>
622
- <span class="cline-any cline-no">&nbsp;</span>
623
- <span class="cline-any cline-no">&nbsp;</span>
624
- <span class="cline-any cline-no">&nbsp;</span>
625
- <span class="cline-any cline-no">&nbsp;</span>
622
+ <span class="cline-any cline-yes">1x</span>
623
+ <span class="cline-any cline-yes">1x</span>
624
+ <span class="cline-any cline-yes">1x</span>
625
+ <span class="cline-any cline-yes">1x</span>
626
626
  <span class="cline-any cline-no">&nbsp;</span>
627
627
  <span class="cline-any cline-neutral">&nbsp;</span>
628
628
  <span class="cline-any cline-no">&nbsp;</span>
@@ -640,19 +640,19 @@
640
640
  <span class="cline-any cline-neutral">&nbsp;</span>
641
641
  <span class="cline-any cline-neutral">&nbsp;</span>
642
642
  <span class="cline-any cline-neutral">&nbsp;</span>
643
- <span class="cline-any cline-yes">5x</span>
644
- <span class="cline-any cline-yes">2x</span>
643
+ <span class="cline-any cline-yes">12x</span>
645
644
  <span class="cline-any cline-yes">3x</span>
645
+ <span class="cline-any cline-yes">9x</span>
646
646
  <span class="cline-any cline-yes">2x</span>
647
647
  <span class="cline-any cline-yes">2x</span>
648
648
  <span class="cline-any cline-neutral">&nbsp;</span>
649
- <span class="cline-any cline-yes">1x</span>
650
- <span class="cline-any cline-yes">1x</span>
651
- <span class="cline-any cline-yes">1x</span>
652
- <span class="cline-any cline-yes">1x</span>
649
+ <span class="cline-any cline-yes">7x</span>
650
+ <span class="cline-any cline-yes">7x</span>
651
+ <span class="cline-any cline-yes">7x</span>
652
+ <span class="cline-any cline-yes">7x</span>
653
653
  <span class="cline-any cline-neutral">&nbsp;</span>
654
654
  <span class="cline-any cline-neutral">&nbsp;</span>
655
- <span class="cline-any cline-yes">5x</span>
655
+ <span class="cline-any cline-yes">12x</span>
656
656
  <span class="cline-any cline-neutral">&nbsp;</span>
657
657
  <span class="cline-any cline-neutral">&nbsp;</span>
658
658
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -663,10 +663,10 @@
663
663
  <span class="cline-any cline-neutral">&nbsp;</span>
664
664
  <span class="cline-any cline-neutral">&nbsp;</span>
665
665
  <span class="cline-any cline-neutral">&nbsp;</span>
666
- <span class="cline-any cline-yes">2x</span>
667
- <span class="cline-any cline-yes">2x</span>
666
+ <span class="cline-any cline-yes">3x</span>
667
+ <span class="cline-any cline-yes">3x</span>
668
668
  <span class="cline-any cline-neutral">&nbsp;</span>
669
- <span class="cline-any cline-yes">2x</span>
669
+ <span class="cline-any cline-yes">3x</span>
670
670
  <span class="cline-any cline-neutral">&nbsp;</span>
671
671
  <span class="cline-any cline-neutral">&nbsp;</span>
672
672
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -710,7 +710,7 @@
710
710
  <span class="cline-any cline-neutral">&nbsp;</span>
711
711
  <span class="cline-any cline-neutral">&nbsp;</span>
712
712
  <span class="cline-any cline-neutral">&nbsp;</span>
713
- <span class="cline-any cline-no">&nbsp;</span>
713
+ <span class="cline-any cline-yes">3x</span>
714
714
  <span class="cline-any cline-neutral">&nbsp;</span>
715
715
  <span class="cline-any cline-neutral">&nbsp;</span>
716
716
  <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import { debug } from "debug";
@@ -911,28 +911,28 @@ export default class Widgets {
911
911
  let widget;
912
912
  let displayOnLoad = !!config.displayOnLoad;
913
913
  let displayCTA = false;
914
- const opts = response.jsOptions || "";
914
+ const opts = response.jsOptions || {};
915
915
  &nbsp;
916
916
  const params = {
917
917
  content: response.template,
918
- type: config.widgetType || <span class="branch-1 cbranch-no" title="branch not covered" >opts.widget.defaultWidgetType,</span>
918
+ type: config.widgetType || opts.widget?.defaultWidgetType,
919
919
  api: this.api,
920
920
  domain: this.domain,
921
921
  npmCdn: this.npmCdn,
922
922
  context: context,
923
923
  };
924
924
  &nbsp;
925
- <span class="missing-if-branch" title="if path not taken" >I</span>if (opts.widgetUrlMappings) {
926
- <span class="cstat-no" title="statement not covered" > opts.widgetUrlMappings.forEach(<span class="fstat-no" title="function not covered" >(r</span>ule) =&gt; {</span>
927
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (Widgets._matchesUrl(rule.url)) {</span>
928
- <span class="cstat-no" title="statement not covered" > if (</span>
925
+ if (opts.widgetUrlMappings) {
926
+ opts.widgetUrlMappings.forEach((rule) =&gt; {
927
+ if (Widgets._matchesUrl(rule.url)) {
928
+ if (
929
929
  rule.widgetType !== "CONVERSION_WIDGET" ||
930
- (response.user.referredBy &amp;&amp; response.user.referredBy.code)
930
+ (response.user?.referredBy &amp;&amp; response.user?.referredBy?.code)
931
931
  ) {
932
- <span class="cstat-no" title="statement not covered" > displayOnLoad = rule.displayOnLoad;</span>
933
- <span class="cstat-no" title="statement not covered" > displayCTA = rule.showAsCTA;</span>
934
- <span class="cstat-no" title="statement not covered" > _log(`Display ${rule.widgetType} on ${rule.url}`);</span>
935
- } else {
932
+ displayOnLoad = rule.displayOnLoad;
933
+ displayCTA = rule.showAsCTA;
934
+ _log(`Display ${rule.widgetType} on ${rule.url}`);
935
+ } else <span class="missing-if-branch" title="else path not taken" >E</span>{
936
936
  <span class="cstat-no" title="statement not covered" > _log(</span>
937
937
  `Don't display ${rule.widgetType} when no referral on widget rule match ${rule.url}`
938
938
  );
@@ -941,13 +941,13 @@ export default class Widgets {
941
941
  });
942
942
  }
943
943
  &nbsp;
944
- <span class="missing-if-branch" title="if path not taken" >I</span>if (opts.fuelTankAutofillUrls) {
945
- <span class="cstat-no" title="statement not covered" > _log("We found a fuel tank autofill!");</span>
944
+ if (opts.fuelTankAutofillUrls) {
945
+ _log("We found a fuel tank autofill!");
946
946
  &nbsp;
947
- <span class="cstat-no" title="statement not covered" > opts.fuelTankAutofillUrls.forEach(<span class="fstat-no" title="function not covered" >({</span> url, formSelector }) =&gt; {</span>
948
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (Widgets._matchesUrl(url)) {</span>
949
- <span class="cstat-no" title="statement not covered" > _log("Fuel Tank URL matches");</span>
950
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (response.user.referredBy &amp;&amp; response.user.referredBy.code) {</span>
947
+ opts.fuelTankAutofillUrls.forEach(({ url, formSelector }) =&gt; {
948
+ if (Widgets._matchesUrl(url)) {
949
+ _log("Fuel Tank URL matches");
950
+ <span class="missing-if-branch" title="if path not taken" >I</span>if (response.user?.referredBy &amp;&amp; <span class="branch-1 cbranch-no" title="branch not covered" >response.user?.referredBy?.code)</span> {
951
951
  const formAutofill = <span class="cstat-no" title="statement not covered" >document.querySelector(formSelector);</span>
952
952
  &nbsp;
953
953
  <span class="cstat-no" title="statement not covered" > if (formAutofill) {</span>
@@ -974,7 +974,7 @@ export default class Widgets {
974
974
  _log("display popup on load");
975
975
  widget = new PopupWidget(params);
976
976
  widget.load();
977
- <span class="missing-if-branch" title="if path not taken" >I</span>if (displayOnLoad) <span class="cstat-no" title="statement not covered" >widget.open();</span>
977
+ if (displayOnLoad) widget.open();
978
978
  }
979
979
  &nbsp;
980
980
  return widget;
@@ -1033,9 +1033,9 @@ export default class Widgets {
1033
1033
  * @param {string} rule A regular expression
1034
1034
  * @returns {boolean} true if rule matches Url, false otherwise
1035
1035
  */
1036
- private <span class="fstat-no" title="function not covered" >static </span>_matchesUrl(rule) {
1036
+ private static _matchesUrl(rule) {
1037
1037
  // If there were no matches, null is returned.
1038
- <span class="cstat-no" title="statement not covered" > return window.location.href.match(new RegExp(rule)) ? true : false;</span>
1038
+ return window.location.href.match(new RegExp(rule)) ? true : <span class="branch-1 cbranch-no" title="branch not covered" >false;</span>
1039
1039
  }
1040
1040
  }
1041
1041
  &nbsp;</pre></td></tr></table></pre>
@@ -1045,7 +1045,7 @@ export default class Widgets {
1045
1045
  <div class='footer quiet pad2 space-top1 center small'>
1046
1046
  Code coverage generated by
1047
1047
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
1048
- at 2023-07-18T18:05:44.533Z
1048
+ at 2023-07-18T18:59:28.021Z
1049
1049
  </div>
1050
1050
  <script src="../prettify.js"></script>
1051
1051
  <script>
package/dist/squatch.d.ts CHANGED
@@ -74,21 +74,6 @@ export declare function ready(fn: () => any): void;
74
74
  * @returns {void}
75
75
  */
76
76
  export declare function autofill(selector: string): void;
77
- /**
78
- * Overrides the default function that submits the user email. If you have
79
- * Security enabled, the email needs to be signed before it's submitted.
80
- *
81
- * @param {function} fn Callback function for the 'submit_email' event.
82
- * @returns {void}
83
- *
84
- * @example
85
- * squatch.submitEmail(function(target, widget, email) {
86
- * // Sign email and generate jwt token
87
- * var jwt = 'token';
88
- * widget.reload(email, jwt);
89
- * });
90
- */
91
- export declare function submitEmail(fn: (target: any, widget: any, email: any) => any): void;
92
77
  /**
93
78
  * Manually set the _saasquatch cookie as a 1st party cookie if available as a URL parameter on the current page.
94
79
  * This runs automatically immediately when squatch-js is loaded, except when window.SaaSquatchDoNotAutoDrop is true.
@@ -678,6 +678,7 @@ class Widget {
678
678
  function delay(duration) {
679
679
  return new Promise(function (resolve, reject) {
680
680
  setTimeout(function () {
681
+ /* istanbul ignore next */
681
682
  resolve(() => {});
682
683
  }, duration);
683
684
  });
@@ -1221,15 +1222,17 @@ class Widgets {
1221
1222
 
1222
1223
 
1223
1224
  _renderWidget(response, config, context) {
1225
+ var _opts$widget;
1226
+
1224
1227
  _log$4("Rendering Widget...");
1225
1228
 
1226
1229
  if (!response) throw new Error("Unable to get a response");
1227
1230
  var widget;
1228
1231
  var displayOnLoad = !!config.displayOnLoad;
1229
- var opts = response.jsOptions || "";
1232
+ var opts = response.jsOptions || {};
1230
1233
  var params = {
1231
1234
  content: response.template,
1232
- type: config.widgetType || opts.widget.defaultWidgetType,
1235
+ type: config.widgetType || ((_opts$widget = opts.widget) == null ? void 0 : _opts$widget.defaultWidgetType),
1233
1236
  api: this.api,
1234
1237
  domain: this.domain,
1235
1238
  npmCdn: this.npmCdn,
@@ -1239,7 +1242,9 @@ class Widgets {
1239
1242
  if (opts.widgetUrlMappings) {
1240
1243
  opts.widgetUrlMappings.forEach(rule => {
1241
1244
  if (Widgets._matchesUrl(rule.url)) {
1242
- if (rule.widgetType !== "CONVERSION_WIDGET" || response.user.referredBy && response.user.referredBy.code) {
1245
+ var _response$user, _response$user2, _response$user2$refer;
1246
+
1247
+ if (rule.widgetType !== "CONVERSION_WIDGET" || (_response$user = response.user) != null && _response$user.referredBy && (_response$user2 = response.user) != null && (_response$user2$refer = _response$user2.referredBy) != null && _response$user2$refer.code) {
1243
1248
  displayOnLoad = rule.displayOnLoad;
1244
1249
 
1245
1250
  _log$4("Display " + rule.widgetType + " on " + rule.url);
@@ -1260,9 +1265,11 @@ class Widgets {
1260
1265
  } = _ref;
1261
1266
 
1262
1267
  if (Widgets._matchesUrl(url)) {
1268
+ var _response$user3, _response$user4, _response$user4$refer;
1269
+
1263
1270
  _log$4("Fuel Tank URL matches");
1264
1271
 
1265
- if (response.user.referredBy && response.user.referredBy.code) {
1272
+ if ((_response$user3 = response.user) != null && _response$user3.referredBy && (_response$user4 = response.user) != null && (_response$user4$refer = _response$user4.referredBy) != null && _response$user4$refer.code) {
1266
1273
  var formAutofill = document.querySelector(formSelector);
1267
1274
 
1268
1275
  if (formAutofill) {
@@ -1276,7 +1283,7 @@ class Widgets {
1276
1283
  }
1277
1284
 
1278
1285
  if (config.engagementMedium === "EMBED") {
1279
- this._renderEmbedWidget(params, params.context.container);
1286
+ widget = this._renderEmbedWidget(params, params.context.container);
1280
1287
  } else if (config.engagementMedium === "POPUP") {
1281
1288
  widget = this._renderPopupWidget(params);
1282
1289
  if (displayOnLoad) widget.open();
@@ -2009,25 +2016,6 @@ function autofill(selector) {
2009
2016
  // @ts-ignore -- will throw occasionally throw a null pointer exception at runtime
2010
2017
  widgets().autofill(selector);
2011
2018
  }
2012
- /**
2013
- * Overrides the default function that submits the user email. If you have
2014
- * Security enabled, the email needs to be signed before it's submitted.
2015
- *
2016
- * @param {function} fn Callback function for the 'submit_email' event.
2017
- * @returns {void}
2018
- *
2019
- * @example
2020
- * squatch.submitEmail(function(target, widget, email) {
2021
- * // Sign email and generate jwt token
2022
- * var jwt = 'token';
2023
- * widget.reload(email, jwt);
2024
- * });
2025
- */
2026
-
2027
- function submitEmail(fn) {
2028
- // @ts-ignore -- will throw occasionally throw a null pointer exception at runtime
2029
- widgets().submitEmail(fn);
2030
- }
2031
2019
  /**
2032
2020
  * Manually set the _saasquatch cookie as a 1st party cookie if available as a URL parameter on the current page.
2033
2021
  * This runs automatically immediately when squatch-js is loaded, except when window.SaaSquatchDoNotAutoDrop is true.
@@ -2052,5 +2040,5 @@ if (typeof document !== "undefined" && !window.SaaSquatchDoNotAutoDrop) {
2052
2040
 
2053
2041
  if (typeof document !== "undefined") asyncLoad();
2054
2042
 
2055
- export { DeclarativeEmbedWidget, DeclarativePopupWidget, EmbedWidget, PopupWidget, WidgetApi, Widgets, _auto, api, autofill, events, help, init, pushCookie, ready, submitEmail, widget, widgets };
2043
+ export { DeclarativeEmbedWidget, DeclarativePopupWidget, EmbedWidget, PopupWidget, WidgetApi, Widgets, _auto, api, autofill, events, help, init, pushCookie, ready, widget, widgets };
2056
2044
  //# sourceMappingURL=squatch.esm.js.map