@saasquatch/squatch-js 2.6.0-5 → 2.6.0-7

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.
@@ -23,30 +23,30 @@
23
23
  <div class='clearfix'>
24
24
 
25
25
  <div class='fl pad1y space-right2'>
26
- <span class="strong">60.93% </span>
26
+ <span class="strong">62.29% </span>
27
27
  <span class="quiet">Statements</span>
28
- <span class='fraction'>39/64</span>
28
+ <span class='fraction'>38/61</span>
29
29
  </div>
30
30
 
31
31
 
32
32
  <div class='fl pad1y space-right2'>
33
- <span class="strong">54.76% </span>
33
+ <span class="strong">58.53% </span>
34
34
  <span class="quiet">Branches</span>
35
- <span class='fraction'>23/42</span>
35
+ <span class='fraction'>24/41</span>
36
36
  </div>
37
37
 
38
38
 
39
39
  <div class='fl pad1y space-right2'>
40
- <span class="strong">41.66% </span>
40
+ <span class="strong">58.33% </span>
41
41
  <span class="quiet">Functions</span>
42
- <span class='fraction'>5/12</span>
42
+ <span class='fraction'>7/12</span>
43
43
  </div>
44
44
 
45
45
 
46
46
  <div class='fl pad1y space-right2'>
47
- <span class="strong">67.24% </span>
47
+ <span class="strong">62.5% </span>
48
48
  <span class="quiet">Lines</span>
49
- <span class='fraction'>39/58</span>
49
+ <span class='fraction'>35/56</span>
50
50
  </div>
51
51
 
52
52
 
@@ -298,8 +298,7 @@
298
298
  <a name='L233'></a><a href='#L233'>233</a>
299
299
  <a name='L234'></a><a href='#L234'>234</a>
300
300
  <a name='L235'></a><a href='#L235'>235</a>
301
- <a name='L236'></a><a href='#L236'>236</a>
302
- <a name='L237'></a><a href='#L237'>237</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
301
+ <a name='L236'></a><a href='#L236'>236</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
303
302
  <span class="cline-any cline-yes">1x</span>
304
303
  <span class="cline-any cline-yes">1x</span>
305
304
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -382,34 +381,34 @@
382
381
  <span class="cline-any cline-neutral">&nbsp;</span>
383
382
  <span class="cline-any cline-neutral">&nbsp;</span>
384
383
  <span class="cline-any cline-neutral">&nbsp;</span>
385
- <span class="cline-any cline-yes">1x</span>
386
- <span class="cline-any cline-yes">1x</span>
384
+ <span class="cline-any cline-yes">16x</span>
385
+ <span class="cline-any cline-yes">16x</span>
387
386
  <span class="cline-any cline-neutral">&nbsp;</span>
388
387
  <span class="cline-any cline-neutral">&nbsp;</span>
389
388
  <span class="cline-any cline-neutral">&nbsp;</span>
390
- <span class="cline-any cline-yes">1x</span>
391
- <span class="cline-any cline-yes">1x</span>
392
- <span class="cline-any cline-yes">1x</span>
393
- <span class="cline-any cline-yes">1x</span>
389
+ <span class="cline-any cline-yes">16x</span>
390
+ <span class="cline-any cline-yes">16x</span>
391
+ <span class="cline-any cline-yes">16x</span>
392
+ <span class="cline-any cline-yes">16x</span>
394
393
  <span class="cline-any cline-neutral">&nbsp;</span>
395
394
  <span class="cline-any cline-neutral">&nbsp;</span>
396
395
  <span class="cline-any cline-neutral">&nbsp;</span>
397
- <span class="cline-any cline-yes">1x</span>
396
+ <span class="cline-any cline-yes">5x</span>
398
397
  <span class="cline-any cline-neutral">&nbsp;</span>
399
- <span class="cline-any cline-yes">1x</span>
398
+ <span class="cline-any cline-yes">5x</span>
400
399
  <span class="cline-any cline-neutral">&nbsp;</span>
401
400
  <span class="cline-any cline-neutral">&nbsp;</span>
402
401
  <span class="cline-any cline-neutral">&nbsp;</span>
403
- <span class="cline-any cline-yes">1x</span>
402
+ <span class="cline-any cline-yes">5x</span>
404
403
  <span class="cline-any cline-neutral">&nbsp;</span>
405
404
  <span class="cline-any cline-neutral">&nbsp;</span>
406
405
  <span class="cline-any cline-neutral">&nbsp;</span>
407
406
  <span class="cline-any cline-neutral">&nbsp;</span>
408
407
  <span class="cline-any cline-neutral">&nbsp;</span>
409
- <span class="cline-any cline-yes">1x</span>
410
- <span class="cline-any cline-yes">1x</span>
408
+ <span class="cline-any cline-no">&nbsp;</span>
409
+ <span class="cline-any cline-no">&nbsp;</span>
411
410
  <span class="cline-any cline-neutral">&nbsp;</span>
412
- <span class="cline-any cline-yes">1x</span>
411
+ <span class="cline-any cline-no">&nbsp;</span>
413
412
  <span class="cline-any cline-neutral">&nbsp;</span>
414
413
  <span class="cline-any cline-neutral">&nbsp;</span>
415
414
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -420,10 +419,10 @@
420
419
  <span class="cline-any cline-neutral">&nbsp;</span>
421
420
  <span class="cline-any cline-neutral">&nbsp;</span>
422
421
  <span class="cline-any cline-neutral">&nbsp;</span>
423
- <span class="cline-any cline-no">&nbsp;</span>
422
+ <span class="cline-any cline-yes">1x</span>
424
423
  <span class="cline-any cline-neutral">&nbsp;</span>
425
- <span class="cline-any cline-no">&nbsp;</span>
426
- <span class="cline-any cline-no">&nbsp;</span>
424
+ <span class="cline-any cline-yes">1x</span>
425
+ <span class="cline-any cline-yes">1x</span>
427
426
  <span class="cline-any cline-neutral">&nbsp;</span>
428
427
  <span class="cline-any cline-no">&nbsp;</span>
429
428
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -439,11 +438,12 @@
439
438
  <span class="cline-any cline-no">&nbsp;</span>
440
439
  <span class="cline-any cline-neutral">&nbsp;</span>
441
440
  <span class="cline-any cline-neutral">&nbsp;</span>
442
- <span class="cline-any cline-yes">1x</span>
441
+ <span class="cline-any cline-yes">16x</span>
443
442
  <span class="cline-any cline-neutral">&nbsp;</span>
444
443
  <span class="cline-any cline-neutral">&nbsp;</span>
445
444
  <span class="cline-any cline-neutral">&nbsp;</span>
446
- <span class="cline-any cline-no">&nbsp;</span>
445
+ <span class="cline-any cline-yes">4x</span>
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>
449
449
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -452,11 +452,12 @@
452
452
  <span class="cline-any cline-neutral">&nbsp;</span>
453
453
  <span class="cline-any cline-neutral">&nbsp;</span>
454
454
  <span class="cline-any cline-neutral">&nbsp;</span>
455
- <span class="cline-any cline-no">&nbsp;</span>
456
- <span class="cline-any cline-no">&nbsp;</span>
457
455
  <span class="cline-any cline-neutral">&nbsp;</span>
456
+ <span class="cline-any cline-neutral">&nbsp;</span>
457
+ <span class="cline-any cline-yes">4x</span>
458
458
  <span class="cline-any cline-no">&nbsp;</span>
459
459
  <span class="cline-any cline-neutral">&nbsp;</span>
460
+ <span class="cline-any cline-yes">4x</span>
460
461
  <span class="cline-any cline-neutral">&nbsp;</span>
461
462
  <span class="cline-any cline-neutral">&nbsp;</span>
462
463
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -466,22 +467,20 @@
466
467
  <span class="cline-any cline-neutral">&nbsp;</span>
467
468
  <span class="cline-any cline-neutral">&nbsp;</span>
468
469
  <span class="cline-any cline-neutral">&nbsp;</span>
469
- <span class="cline-any cline-yes">1x</span>
470
- <span class="cline-any cline-yes">1x</span>
471
470
  <span class="cline-any cline-neutral">&nbsp;</span>
472
- <span class="cline-any cline-yes">1x</span>
471
+ <span class="cline-any cline-no">&nbsp;</span>
472
+ <span class="cline-any cline-no">&nbsp;</span>
473
473
  <span class="cline-any cline-neutral">&nbsp;</span>
474
- <span class="cline-any cline-yes">1x</span>
475
- <span class="cline-any cline-yes">1x</span>
474
+ <span class="cline-any cline-no">&nbsp;</span>
476
475
  <span class="cline-any cline-neutral">&nbsp;</span>
477
476
  <span class="cline-any cline-no">&nbsp;</span>
477
+ <span class="cline-any cline-no">&nbsp;</span>
478
478
  <span class="cline-any cline-neutral">&nbsp;</span>
479
+ <span class="cline-any cline-no">&nbsp;</span>
479
480
  <span class="cline-any cline-neutral">&nbsp;</span>
480
- <span class="cline-any cline-yes">1x</span>
481
- <span class="cline-any cline-yes">1x</span>
482
481
  <span class="cline-any cline-neutral">&nbsp;</span>
483
- <span class="cline-any cline-yes">1x</span>
484
- <span class="cline-any cline-yes">1x</span>
482
+ <span class="cline-any cline-no">&nbsp;</span>
483
+ <span class="cline-any cline-no">&nbsp;</span>
485
484
  <span class="cline-any cline-neutral">&nbsp;</span>
486
485
  <span class="cline-any cline-neutral">&nbsp;</span>
487
486
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -496,9 +495,8 @@
496
495
  <span class="cline-any cline-neutral">&nbsp;</span>
497
496
  <span class="cline-any cline-neutral">&nbsp;</span>
498
497
  <span class="cline-any cline-neutral">&nbsp;</span>
499
- <span class="cline-any cline-yes">1x</span>
500
- <span class="cline-any cline-yes">1x</span>
501
- <span class="cline-any cline-neutral">&nbsp;</span>
498
+ <span class="cline-any cline-yes">16x</span>
499
+ <span class="cline-any cline-yes">5x</span>
502
500
  <span class="cline-any cline-neutral">&nbsp;</span>
503
501
  <span class="cline-any cline-neutral">&nbsp;</span>
504
502
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -506,10 +504,10 @@
506
504
  <span class="cline-any cline-neutral">&nbsp;</span>
507
505
  <span class="cline-any cline-neutral">&nbsp;</span>
508
506
  <span class="cline-any cline-neutral">&nbsp;</span>
509
- <span class="cline-any cline-yes">1x</span>
507
+ <span class="cline-any cline-yes">5x</span>
510
508
  <span class="cline-any cline-no">&nbsp;</span>
511
509
  <span class="cline-any cline-neutral">&nbsp;</span>
512
- <span class="cline-any cline-yes">1x</span>
510
+ <span class="cline-any cline-yes">5x</span>
513
511
  <span class="cline-any cline-neutral">&nbsp;</span>
514
512
  <span class="cline-any cline-neutral">&nbsp;</span>
515
513
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -518,7 +516,7 @@
518
516
  <span class="cline-any cline-neutral">&nbsp;</span>
519
517
  <span class="cline-any cline-neutral">&nbsp;</span>
520
518
  <span class="cline-any cline-neutral">&nbsp;</span>
521
- <span class="cline-any cline-no">&nbsp;</span>
519
+ <span class="cline-any cline-yes">1x</span>
522
520
  <span class="cline-any cline-no">&nbsp;</span>
523
521
  <span class="cline-any cline-neutral">&nbsp;</span>
524
522
  <span class="cline-any cline-neutral">&nbsp;</span>
@@ -527,13 +525,13 @@
527
525
  <span class="cline-any cline-neutral">&nbsp;</span>
528
526
  <span class="cline-any cline-neutral">&nbsp;</span>
529
527
  <span class="cline-any cline-neutral">&nbsp;</span>
530
- <span class="cline-any cline-no">&nbsp;</span>
528
+ <span class="cline-any cline-yes">1x</span>
531
529
  <span class="cline-any cline-no">&nbsp;</span>
532
530
  <span class="cline-any cline-neutral">&nbsp;</span>
533
531
  <span class="cline-any cline-neutral">&nbsp;</span>
534
- <span class="cline-any cline-yes">1x</span>
535
- <span class="cline-any cline-yes">1x</span>
536
- <span class="cline-any cline-yes">1x</span>
532
+ <span class="cline-any cline-yes">16x</span>
533
+ <span class="cline-any cline-yes">16x</span>
534
+ <span class="cline-any cline-yes">16x</span>
537
535
  <span class="cline-any cline-neutral">&nbsp;</span>
538
536
  <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">import debug from "debug";
539
537
  import AnalyticsApi from "../../api/AnalyticsApi";
@@ -641,11 +639,11 @@ export default abstract class DeclarativeWidget extends HTMLElement {
641
639
  });
642
640
  }
643
641
  &nbsp;
644
- private async renderPasswordlessVariant() {
645
- const configs = _getAutoConfig();
646
- this._setupApis(configs?.squatchConfig);
642
+ private <span class="fstat-no" title="function not covered" >async </span>renderPasswordlessVariant() {
643
+ const configs = <span class="cstat-no" title="statement not covered" >_getAutoConfig();</span>
644
+ <span class="cstat-no" title="statement not covered" > this._setupApis(configs?.squatchConfig);</span>
647
645
  &nbsp;
648
- return await this.widgetApi
646
+ <span class="cstat-no" title="statement not covered" > return await this.widgetApi</span>
649
647
  .render({
650
648
  engagementMedium: configs?.widgetConfig?.engagementMedium || this.type,
651
649
  widgetType: configs?.widgetConfig?.widgetType || this.widgetType,
@@ -655,11 +653,11 @@ export default abstract class DeclarativeWidget extends HTMLElement {
655
653
  .catch(this.setErrorWidget);
656
654
  }
657
655
  &nbsp;
658
- private <span class="fstat-no" title="function not covered" >async </span>renderUserUpsertVariant() {
659
- <span class="cstat-no" title="statement not covered" > this._setupApis();</span>
656
+ private async renderUserUpsertVariant() {
657
+ this._setupApis();
660
658
  &nbsp;
661
- const userObj = <span class="cstat-no" title="statement not covered" >decodeUserJwt(this.token!);</span>
662
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (!userObj) <span class="cstat-no" title="statement not covered" >throw new Error("Could not load user information from jwt");</span></span>
659
+ const userObj = decodeUserJwt(this.token!);
660
+ if (!userObj) throw new Error("Could not load user information from jwt");
663
661
  &nbsp;
664
662
  const widgetInstance = <span class="cstat-no" title="statement not covered" >await this.widgetApi</span>
665
663
  .upsertUser({
@@ -675,23 +673,26 @@ export default abstract class DeclarativeWidget extends HTMLElement {
675
673
  <span class="cstat-no" title="statement not covered" > return widgetInstance;</span>
676
674
  }
677
675
  &nbsp;
678
- private _setWidget = <span class="fstat-no" title="function not covered" >(</span>
676
+ private _setWidget = (
679
677
  template: any,
680
678
  config: { type: "upsert" | "passwordless" }
681
679
  ) =&gt; {
682
- const params = <span class="cstat-no" title="statement not covered" >{</span>
680
+ const params = {
683
681
  api: this.widgetApi,
684
682
  content: template,
685
- context: { type: config.type, engagementMedium: this.type },
683
+ context: {
684
+ type: config.type,
685
+ container: this.container || this,
686
+ engagementMedium: this.type,
687
+ },
686
688
  type: this.widgetType!,
687
689
  domain: this.config?.domain || DEFAULT_DOMAIN,
688
690
  npmCdn: DEFAULT_NPM_CDN,
689
- container: this.container || this,
690
691
  };
691
- <span class="cstat-no" title="statement not covered" > if (this.type === "EMBED") {</span>
692
- <span class="cstat-no" title="statement not covered" > return new EmbedWidget(params);</span>
692
+ <span class="missing-if-branch" title="if path not taken" >I</span>if (this.type === "EMBED") {
693
+ <span class="cstat-no" title="statement not covered" > return new EmbedWidget(params, params.context.container);</span>
693
694
  } else {
694
- <span class="cstat-no" title="statement not covered" > return new PopupWidget(params, this.firstChild ? null : undefined);</span>
695
+ return new PopupWidget(params, this.firstChild ? <span class="branch-0 cbranch-no" title="branch not covered" >null </span>: undefined);
695
696
  }
696
697
  };
697
698
  &nbsp;
@@ -700,24 +701,21 @@ export default abstract class DeclarativeWidget extends HTMLElement {
700
701
  * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
701
702
  * @throws Throws an Error if `widgetType` is undefined
702
703
  */
703
- async getWidgetInstance() {
704
+ <span class="fstat-no" title="function not covered" > async </span>getWidgetInstance() {
704
705
  let widgetInstance: EmbedWidget | PopupWidget;
705
- this.widgetType = this.getAttribute("widget") || <span class="branch-1 cbranch-no" title="branch not covered" >undefined;</span>
706
- this.locale = this.getAttribute("locale") || this.locale;
706
+ <span class="cstat-no" title="statement not covered" > this.widgetType = this.getAttribute("widget") || undefined;</span>
707
+ <span class="cstat-no" title="statement not covered" > this.locale = this.getAttribute("locale") || this.locale;</span>
707
708
  &nbsp;
708
- <span class="missing-if-branch" title="if path not taken" >I</span>if (!this.widgetType) <span class="cstat-no" title="statement not covered" >throw new Error("No widget has been specified");</span>
709
+ <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (!this.widgetType) <span class="cstat-no" title="statement not covered" >throw new Error("No widget has been specified");</span></span>
709
710
  &nbsp;
710
- if (!this.token) {
711
- widgetInstance = await this.renderPasswordlessVariant();
712
- } else <span class="missing-if-branch" title="else path not taken" >E</span>{
711
+ <span class="cstat-no" title="statement not covered" > if (!this.token) {</span>
712
+ <span class="cstat-no" title="statement not covered" > widgetInstance = await this.renderPasswordlessVariant();</span>
713
+ } else {
713
714
  <span class="cstat-no" title="statement not covered" > widgetInstance = await this.renderUserUpsertVariant();</span>
714
715
  }
715
716
  &nbsp;
716
- console.log(widgetInstance);
717
- <span class="missing-if-branch" title="if path not taken" >I</span>if (!widgetInstance) <span class="cstat-no" title="statement not covered" >throw new Error("Could not create widget.");</span>
718
- &nbsp;
719
- this.widgetInstance = widgetInstance;
720
- return widgetInstance;
717
+ <span class="cstat-no" title="statement not covered" > this.widgetInstance = widgetInstance;</span>
718
+ <span class="cstat-no" title="statement not covered" > return widgetInstance;</span>
721
719
  }
722
720
  &nbsp;
723
721
  /**
@@ -736,16 +734,15 @@ export default abstract class DeclarativeWidget extends HTMLElement {
736
734
  const params = {
737
735
  api: this.widgetApi,
738
736
  content: "error",
739
- context: { type: "error" as const },
737
+ context: { type: "error" as const, container: this.container || this },
740
738
  type: "ERROR_WIDGET",
741
739
  domain: this.config?.domain || DEFAULT_DOMAIN,
742
740
  npmCdn: DEFAULT_NPM_CDN,
743
- container: this.container || <span class="branch-1 cbranch-no" title="branch not covered" >this,</span>
744
741
  };
745
742
  <span class="missing-if-branch" title="if path not taken" >I</span>if (this.type === "EMBED") {
746
- <span class="cstat-no" title="statement not covered" > return new EmbedWidget(params);</span>
743
+ <span class="cstat-no" title="statement not covered" > return new EmbedWidget(params, params.context.container);</span>
747
744
  } else {
748
- return new PopupWidget(params, this.firstChild ? <span class="branch-0 cbranch-no" title="branch not covered" >null </span>: undefined);
745
+ return new PopupWidget(params, this.firstChild ? null : undefined);
749
746
  }
750
747
  };
751
748
  &nbsp;
@@ -753,8 +750,8 @@ export default abstract class DeclarativeWidget extends HTMLElement {
753
750
  * Calls `open` method of `widgetInstance`
754
751
  * @throws Throws an Error if called before the widget has loaded
755
752
  */
756
- <span class="fstat-no" title="function not covered" > open(</span>) {
757
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (!this.widgetInstance) <span class="cstat-no" title="statement not covered" >throw new Error("Widget has not loaded yet");</span></span>
753
+ open() {
754
+ if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
758
755
  <span class="cstat-no" title="statement not covered" > this.widgetInstance.open();</span>
759
756
  }
760
757
  &nbsp;
@@ -762,8 +759,8 @@ export default abstract class DeclarativeWidget extends HTMLElement {
762
759
  * Calls `close` method of `widgetInstance`
763
760
  * @throws Throws an Error if called before the widget has loaded
764
761
  */
765
- <span class="fstat-no" title="function not covered" > close(</span>) {
766
- <span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (!this.widgetInstance) <span class="cstat-no" title="statement not covered" >throw new Error("Widget has not loaded yet");</span></span>
762
+ close() {
763
+ if (!this.widgetInstance) throw new Error("Widget has not loaded yet");
767
764
  <span class="cstat-no" title="statement not covered" > this.widgetInstance.close();</span>
768
765
  }
769
766
  &nbsp;
@@ -778,7 +775,7 @@ export default abstract class DeclarativeWidget extends HTMLElement {
778
775
  <div class='footer quiet pad2 space-top1 center small'>
779
776
  Code coverage generated by
780
777
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
781
- at 2023-07-21T18:05:37.786Z
778
+ at 2023-07-24T22:01:41.987Z
782
779
  </div>
783
780
  <script src="../../prettify.js"></script>
784
781
  <script>