@saasquatch/squatch-js 2.6.0-0 → 2.6.0-1

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/cucumber.js CHANGED
@@ -24,7 +24,7 @@ exports.default = [
24
24
  `--parallel ${CPU_COUNT}`,
25
25
 
26
26
  // "test/**/*.feature",
27
- "../blackbox-testing/features/**/*.feature",
27
+ "test/specs/**/*.feature",
28
28
 
29
29
  `--tags "@testsuite:squatch-js and not @skip"`,
30
30
 
@@ -38,8 +38,8 @@ exports.default = [
38
38
  // "--require tests/cucumber-setup/loaders.ts",
39
39
 
40
40
  // Step definitions go last
41
- "--require test/step_definitions/**/*.ts",
42
- "--require test/step_definitions/**/*.tsx",
41
+ "--require test/step_definitions/**/steps.ts",
42
+ // "--require test/step_definitions/**/*.tsx",
43
43
 
44
44
  // '--format usage',
45
45
  ].join(" ");
@@ -36,7 +36,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
36
36
 
37
37
  debug("squatch-js:io");
38
38
 
39
- async function doQuery(url, query, variables, token) {
39
+ async function doQuery(url, query, variables, jwt) {
40
+ var token = jwt || window.squatchToken;
41
+
40
42
  var headers = _extends({
41
43
  Accept: "application/json",
42
44
  "Content-Type": "application/json"
@@ -70,7 +72,8 @@ async function doGet(url, jwt) {
70
72
  Accept: "application/json",
71
73
  "Content-Type": "application/json"
72
74
  };
73
- if (jwt) headers["X-SaaSquatch-User-Token"] = jwt;
75
+ var token = jwt || window.squatchToken;
76
+ if (token) headers["X-SaaSquatch-User-Token"] = token;
74
77
 
75
78
  try {
76
79
  var res = await fetch(url, {
@@ -90,7 +93,8 @@ async function doPost(url, data, jwt) {
90
93
  Accept: "application/json",
91
94
  "Content-Type": "application/json"
92
95
  };
93
- if (jwt) headers["X-SaaSquatch-User-Token"] = jwt;
96
+ var token = jwt || window.squatchToken;
97
+ if (token) headers["X-SaaSquatch-User-Token"] = token;
94
98
 
95
99
  try {
96
100
  var res = await fetch(url, {
@@ -111,7 +115,8 @@ async function doPut(url, data, jwt) {
111
115
  "Content-Type": "application/json",
112
116
  "X-SaaSquatch-Referrer": window ? window.location.href : ""
113
117
  };
114
- if (jwt) headers["X-SaaSquatch-User-Token"] = jwt;
118
+ var token = jwt || window.squatchToken;
119
+ if (token) headers["X-SaaSquatch-User-Token"] = token;
115
120
 
116
121
  try {
117
122
  var res = await fetch(url, {
@@ -179,8 +184,6 @@ var RENDER_WIDGET_QUERY = "\n query renderWidget ($user: UserIdInput, $engageme
179
184
  */
180
185
 
181
186
  class WidgetApi {
182
- // TODO: Support using new window variables for initialisation
183
-
184
187
  /**
185
188
  * Initialize a new {@link WidgetApi} instance.
186
189
  *
@@ -233,8 +236,8 @@ class WidgetApi {
233
236
  user
234
237
  } = clean;
235
238
  var tenantAlias = encodeURIComponent(this.tenantAlias);
236
- var accountId = encodeURIComponent(user.accountId);
237
- var userId = encodeURIComponent(user.id);
239
+ var accountId = user.accountId ? encodeURIComponent(user.accountId) : null;
240
+ var userId = user.id ? encodeURIComponent(user.id) : null;
238
241
 
239
242
  var optionalParams = _buildParams({
240
243
  widgetType,
@@ -274,8 +277,8 @@ class WidgetApi {
274
277
  user
275
278
  } = clean;
276
279
  var tenantAlias = encodeURIComponent(this.tenantAlias);
277
- var accountId = user ? encodeURIComponent(user.accountId) : null;
278
- var userId = user ? encodeURIComponent(user.id) : null;
280
+ var accountId = user != null && user.accountId ? encodeURIComponent(user.accountId) : null;
281
+ var userId = user != null && user.id ? encodeURIComponent(user.id) : null;
279
282
  var locale = (_clean$locale = clean.locale) != null ? _clean$locale : validateLocale(navigator.language.replace(/\-/g, "_"));
280
283
  var path = "/api/v1/" + tenantAlias + "/graphql";
281
284
  var url = this.domain + path;
@@ -458,6 +461,7 @@ class Widget {
458
461
  _createFrame() {
459
462
  var frame = document.createElement("iframe");
460
463
  frame["squatchJsApi"] = this;
464
+ frame.id = "squatchFrame";
461
465
  frame.width = "100%";
462
466
  frame.src = "about:blank";
463
467
  frame.scrolling = "no";
@@ -465,6 +469,13 @@ class Widget {
465
469
  return frame;
466
470
  }
467
471
 
472
+ _findFrame() {
473
+ var element = this._findElement();
474
+
475
+ var parent = element.shadowRoot || element;
476
+ return parent.querySelector("iframe#squatchFrame");
477
+ }
478
+
468
479
  _loadEvent(sqh) {
469
480
  var _this$analyticsApi$pu;
470
481
 
@@ -501,7 +512,7 @@ class Widget {
501
512
  (_this$analyticsApi$pu = this.analyticsApi.pushAnalyticsLoadEvent(params)) == null ? void 0 : _this$analyticsApi$pu.then(response => {
502
513
  _log$7(params.engagementMedium + " loaded event recorded.");
503
514
  }).catch(ex => {
504
- _log$7(new Error("pushAnalyticsLoadEvent() " + ex));
515
+ _log$7("ERROR: pushAnalyticsLoadEvent() " + ex);
505
516
  });
506
517
  }
507
518
 
@@ -516,7 +527,7 @@ class Widget {
516
527
  }).then(response => {
517
528
  _log$7(sqh.mode.widgetMode + " share " + medium + " event recorded. " + response);
518
529
  }).catch(ex => {
519
- _log$7(new Error("pushAnalyticsLoadEvent() " + ex));
530
+ _log$7("ERROR: pushAnalyticsShareClickedEvent() " + ex);
520
531
  });
521
532
  }
522
533
  } // TODO: CA: Refactor how error templates are shown
@@ -571,12 +582,16 @@ class Widget {
571
582
  */
572
583
 
573
584
 
574
- reload(frame, _ref, jwt) {
585
+ reload(_ref, jwt) {
575
586
  var {
576
587
  email,
577
588
  firstName,
578
589
  lastName
579
590
  } = _ref;
591
+
592
+ var frame = this._findFrame();
593
+
594
+ if (!frame) throw new Error("Could not find widget iframe");
580
595
  var frameWindow = frame.contentWindow;
581
596
  var engagementMedium = this.context.engagementMedium || "POPUP";
582
597
 
@@ -587,6 +602,7 @@ class Widget {
587
602
  var response;
588
603
 
589
604
  if (this.context.type === "upsert") {
605
+ if (!this.context.user) throw new Error("Can't reload without user ids");
590
606
  var userObj = {
591
607
  email: email || null,
592
608
  firstName: firstName || null,
@@ -623,9 +639,9 @@ class Widget {
623
639
  email,
624
640
  engagementMedium
625
641
  }, () => {
626
- this.load(frame); // @ts-ignore -- open exists in the PopupWidget, so this call will always exist when it's called.
642
+ this.load(); // @ts-ignore -- open exists in the PopupWidget, so this call will always exist when it's called.
627
643
 
628
- engagementMedium === "POPUP" && this.open(frame);
644
+ engagementMedium === "POPUP" && this.open();
629
645
  });
630
646
  }
631
647
  }).catch(_ref3 => {
@@ -708,12 +724,18 @@ class EmbedWidget extends Widget {
708
724
  this.hide = this.close;
709
725
  }
710
726
 
711
- async load(frame) {
727
+ async load() {
728
+ var frame = this._createFrame();
729
+
712
730
  var element = this._findElement();
713
731
 
714
732
  if (this.container) {
715
733
  if (element.shadowRoot) {
716
- element.shadowRoot.appendChild(frame);
734
+ var _element$shadowRoot$l;
735
+
736
+ if (((_element$shadowRoot$l = element.shadowRoot.lastChild) == null ? void 0 : _element$shadowRoot$l.nodeName) === "IFRAME") element.shadowRoot.replaceChild(frame, element.shadowRoot.lastChild);else {
737
+ element.shadowRoot.appendChild(frame);
738
+ }
717
739
  } // Widget reloaded - replace existing element
718
740
  else if (element.firstChild) {
719
741
  element.replaceChild(frame, element.firstChild); // Add iframe for the first time
@@ -738,17 +760,7 @@ class EmbedWidget extends Widget {
738
760
  frameDoc.write("<script src=\"" + this.npmCdn + "/resize-observer-polyfill@1.5.x\"></script>");
739
761
  frameDoc.close();
740
762
  domready(frameDoc, async () => {
741
- var _sqh = contentWindow.squatch || contentWindow.widgetIdent;
742
-
743
- var ctaElement = frameDoc.getElementById("cta");
744
-
745
- if (ctaElement) {
746
- if (!ctaElement.parentNode) {
747
- throw new Error("ctaElement needs a parentNode");
748
- }
749
-
750
- ctaElement.parentNode.removeChild(ctaElement);
751
- } // @ts-ignore -- number will be cast to string by browsers
763
+ var _sqh = contentWindow.squatch || contentWindow.widgetIdent; // @ts-ignore -- number will be cast to string by browsers
752
764
 
753
765
 
754
766
  frame.height = frameDoc.body.scrollHeight; // Adjust frame height when size of body changes
@@ -773,9 +785,11 @@ class EmbedWidget extends Widget {
773
785
  } // Un-hide if element is available and refresh data
774
786
 
775
787
 
776
- open(frame) {
788
+ open() {
777
789
  var _frame$contentDocumen, _frame$contentWindow, _frame$contentWindow2;
778
790
 
791
+ var frame = this._findFrame();
792
+
779
793
  if (!frame) return _log$6("no target element to open");
780
794
 
781
795
  var element = this._findElement();
@@ -792,7 +806,9 @@ class EmbedWidget extends Widget {
792
806
  _log$6("loaded");
793
807
  }
794
808
 
795
- close(frame) {
809
+ close() {
810
+ var frame = this._findFrame();
811
+
796
812
  if (!frame) return _log$6("no target element to close");
797
813
 
798
814
  var element = this._findElement();
@@ -855,6 +871,7 @@ class PopupWidget extends Widget {
855
871
  }
856
872
 
857
873
  _initialiseCTA(frame) {
874
+ if (!this.trigger) return;
858
875
  var triggerElement;
859
876
 
860
877
  try {
@@ -869,21 +886,18 @@ class PopupWidget extends Widget {
869
886
 
870
887
  if (triggerElement) {
871
888
  triggerElement.onclick = () => {
872
- this.open(frame);
889
+ this.open();
873
890
  };
874
- }
875
-
876
- var element = this._findElement(); // If widget is loaded with CTA, look for a 'squatchpop' element to use
891
+ } // const element = this._findElement();
892
+ // If widget is loaded with CTA, look for a 'squatchpop' element to use
877
893
  // that element as a trigger as well.
894
+ // const triggerWhenCTA = element.querySelector(".squatchpop") as HTMLElement;
895
+ // if (this.trigger === "#cta" && triggerWhenCTA) {
896
+ // triggerWhenCTA.onclick = () => {
897
+ // this.open(frame);
898
+ // };
899
+ // }
878
900
 
879
-
880
- var triggerWhenCTA = element.querySelector(".squatchpop");
881
-
882
- if (this.trigger === "#cta" && triggerWhenCTA) {
883
- triggerWhenCTA.onclick = () => {
884
- this.open(frame);
885
- };
886
- }
887
901
  }
888
902
 
889
903
  _createPopupDialog() {
@@ -899,7 +913,11 @@ class PopupWidget extends Widget {
899
913
  return dialog;
900
914
  }
901
915
 
902
- load(frame) {
916
+ load() {
917
+ var _dialogParent$lastChi;
918
+
919
+ var frame = this._createFrame();
920
+
903
921
  this._initialiseCTA(frame);
904
922
 
905
923
  var element = this._findElement();
@@ -909,7 +927,15 @@ class PopupWidget extends Widget {
909
927
  var dialog = this._createPopupDialog();
910
928
 
911
929
  dialog.appendChild(frame);
912
- dialogParent.appendChild(dialog);
930
+
931
+ if (((_dialogParent$lastChi = dialogParent.lastChild) == null ? void 0 : _dialogParent$lastChi.nodeName) === "DIALOG") {
932
+ // Was reloaded
933
+ dialogParent.replaceChild(dialog, dialogParent.lastChild);
934
+ } else {
935
+ // First time rendering
936
+ dialogParent.appendChild(dialog);
937
+ }
938
+
913
939
  var {
914
940
  contentWindow
915
941
  } = frame;
@@ -960,13 +986,17 @@ class PopupWidget extends Widget {
960
986
  });
961
987
  }
962
988
 
963
- open(frame) {
989
+ open() {
964
990
  var element = this._findElement();
965
991
 
966
992
  var parent = element.shadowRoot || element;
967
993
  var dialog = parent.querySelector("#" + this.id);
968
994
  if (!dialog) throw new Error("Could not determine container div");
969
995
  dialog.showModal();
996
+
997
+ var frame = this._findFrame();
998
+
999
+ if (!frame) throw new Error("Could not find iframe");
970
1000
  var {
971
1001
  contentWindow
972
1002
  } = frame;
@@ -987,7 +1017,10 @@ class PopupWidget extends Widget {
987
1017
  }
988
1018
 
989
1019
  close() {
990
- var dialog = document.getElementById(this.id);
1020
+ var element = this._findElement();
1021
+
1022
+ var parent = element.shadowRoot || element;
1023
+ var dialog = parent.querySelector("#" + this.id);
991
1024
  if (!dialog) throw new Error("Could not determine container div");
992
1025
  dialog.close();
993
1026
 
@@ -1090,7 +1123,7 @@ class Widgets {
1090
1123
  this._renderErrorWidget(err, config.engagementMedium);
1091
1124
  }
1092
1125
 
1093
- throw err;
1126
+ throw new Error(err);
1094
1127
  }
1095
1128
  }
1096
1129
  /**
@@ -1128,7 +1161,7 @@ class Widgets {
1128
1161
  this._renderErrorWidget(err, clean.engagementMedium);
1129
1162
  }
1130
1163
 
1131
- throw err;
1164
+ throw new Error(err);
1132
1165
  }
1133
1166
  }
1134
1167
  /**
@@ -1140,17 +1173,19 @@ class Widgets {
1140
1173
  */
1141
1174
 
1142
1175
 
1143
- autofill(selector) {
1176
+ async autofill(selector) {
1144
1177
  var input = selector;
1145
1178
 
1146
1179
  if (typeof input === "function") {
1147
- this.api.squatchReferralCookie().then(function () {
1148
- return input(...arguments);
1149
- }).catch(ex => {
1150
- _log$4("Autofill error", ex);
1180
+ try {
1181
+ var response = await this.api.squatchReferralCookie();
1182
+ input(response);
1183
+ } catch (e) {
1184
+ _log$4("Autofill error", e);
1185
+
1186
+ throw new Error(e);
1187
+ }
1151
1188
 
1152
- throw ex;
1153
- });
1154
1189
  return;
1155
1190
  }
1156
1191
 
@@ -1167,14 +1202,13 @@ class Widgets {
1167
1202
  throw new Error("Element id/class or function missing");
1168
1203
  }
1169
1204
 
1170
- this.api.squatchReferralCookie().then(_ref => {
1171
- var {
1172
- codes
1173
- } = _ref;
1174
- elem.value = codes[0];
1175
- }).catch(ex => {
1176
- throw ex;
1177
- });
1205
+ try {
1206
+ var _response = await this.api.squatchReferralCookie();
1207
+
1208
+ elem.value = _response.codes[0];
1209
+ } catch (e) {
1210
+ throw new Error(e);
1211
+ }
1178
1212
  }
1179
1213
  /**
1180
1214
  * @hidden
@@ -1219,11 +1253,11 @@ class Widgets {
1219
1253
  if (opts.fuelTankAutofillUrls) {
1220
1254
  _log$4("We found a fuel tank autofill!");
1221
1255
 
1222
- opts.fuelTankAutofillUrls.forEach(_ref2 => {
1256
+ opts.fuelTankAutofillUrls.forEach(_ref => {
1223
1257
  var {
1224
1258
  url,
1225
1259
  formSelector
1226
- } = _ref2;
1260
+ } = _ref;
1227
1261
 
1228
1262
  if (Widgets._matchesUrl(url)) {
1229
1263
  _log$4("Fuel Tank URL matches");
@@ -1259,19 +1293,14 @@ class Widgets {
1259
1293
 
1260
1294
  _renderPopupWidget(params) {
1261
1295
  var widget = new PopupWidget(params, params.context.trigger);
1262
-
1263
- var frame = widget._createFrame();
1264
-
1265
- widget.load(frame);
1296
+ widget.load();
1266
1297
  return widget;
1267
1298
  }
1268
1299
 
1269
1300
  _renderEmbedWidget(params, container) {
1270
1301
  var widget = new EmbedWidget(params);
1271
-
1272
- var frame = widget._createFrame();
1273
-
1274
- widget.load(frame);
1302
+ widget.load();
1303
+ return widget;
1275
1304
  }
1276
1305
  /**
1277
1306
  * @hidden
@@ -1309,16 +1338,10 @@ class Widgets {
1309
1338
 
1310
1339
  if (em === "EMBED") {
1311
1340
  widget = new EmbedWidget(params);
1312
-
1313
- var frame = widget._createFrame();
1314
-
1315
- widget.load(frame);
1341
+ widget.load();
1316
1342
  } else if (em === "POPUP") {
1317
1343
  widget = new PopupWidget(params);
1318
-
1319
- var _frame = widget._createFrame();
1320
-
1321
- widget.load(_frame);
1344
+ widget.load();
1322
1345
  }
1323
1346
  }
1324
1347
  /**
@@ -1332,30 +1355,6 @@ class Widgets {
1332
1355
  // If there were no matches, null is returned.
1333
1356
  return window.location.href.match(new RegExp(rule)) ? true : false;
1334
1357
  }
1335
- /**
1336
- * @hidden
1337
- * @param {Object} target Object containing the target DOM element
1338
- * @param {Widget} widget A widget (EmbedWidget, PopupWidget)
1339
- * @param {Object} params An object with valid parameters
1340
- * (e.g) {email:'email', firstName:'firstName'}
1341
- * @returns {void}
1342
- */
1343
-
1344
-
1345
- static _cb(target, widget, params) {
1346
- var paramsObj; // If params is a string, then it should be an email
1347
-
1348
- if (typeof params === "string" || params instanceof String) {
1349
- paramsObj = {
1350
- email: params
1351
- };
1352
- } else {
1353
- paramsObj = params;
1354
- } // TODO: Reload doesn't exist on all widget types
1355
-
1356
-
1357
- widget.reload(paramsObj);
1358
- }
1359
1358
 
1360
1359
  }
1361
1360
 
@@ -1660,16 +1659,14 @@ class DeclarativeWidget extends HTMLElement {
1660
1659
  this.analyticsApi = void 0;
1661
1660
  this.type = void 0;
1662
1661
  this.widgetInstance = void 0;
1663
- this.frame = void 0;
1664
1662
  this.container = void 0;
1665
1663
  this.element = void 0;
1664
+ this._hasChildren = void 0;
1666
1665
 
1667
1666
  this._setWidget = (template, config) => {
1668
1667
  var _this$config;
1669
1668
 
1670
- if (!this.widgetType) throw new Error("Widget was no specified");
1671
- var Widget = this.type === "EMBED" ? EmbedWidget : PopupWidget;
1672
- return new Widget({
1669
+ var params = {
1673
1670
  api: this.widgetApi,
1674
1671
  content: template,
1675
1672
  context: {
@@ -1680,14 +1677,19 @@ class DeclarativeWidget extends HTMLElement {
1680
1677
  domain: ((_this$config = this.config) == null ? void 0 : _this$config.domain) || DEFAULT_DOMAIN,
1681
1678
  npmCdn: DEFAULT_NPM_CDN,
1682
1679
  container: this.container || this
1683
- });
1680
+ };
1681
+
1682
+ if (this.type === "EMBED") {
1683
+ return new EmbedWidget(params);
1684
+ } else {
1685
+ return new PopupWidget(params, this.firstChild ? null : undefined);
1686
+ }
1684
1687
  };
1685
1688
 
1686
1689
  this.setErrorWidget = e => {
1687
1690
  var _this$config2;
1688
1691
 
1689
- var Widget = this.type === "EMBED" ? EmbedWidget : PopupWidget;
1690
- return new Widget({
1692
+ var params = {
1691
1693
  api: this.widgetApi,
1692
1694
  content: "error",
1693
1695
  context: {
@@ -1697,7 +1699,13 @@ class DeclarativeWidget extends HTMLElement {
1697
1699
  domain: ((_this$config2 = this.config) == null ? void 0 : _this$config2.domain) || DEFAULT_DOMAIN,
1698
1700
  npmCdn: DEFAULT_NPM_CDN,
1699
1701
  container: this.container || this
1700
- });
1702
+ };
1703
+
1704
+ if (this.type === "EMBED") {
1705
+ return new EmbedWidget(params);
1706
+ } else {
1707
+ return new PopupWidget(params, this.firstChild ? null : undefined);
1708
+ }
1701
1709
  };
1702
1710
 
1703
1711
  this.show = this.open;
@@ -1724,14 +1732,14 @@ class DeclarativeWidget extends HTMLElement {
1724
1732
  });
1725
1733
  }
1726
1734
 
1727
- renderPasswordlessVariant() {
1735
+ async renderPasswordlessVariant() {
1728
1736
  var _configs$widgetConfig, _configs$widgetConfig2;
1729
1737
 
1730
1738
  var configs = _getAutoConfig();
1731
1739
 
1732
1740
  this._setupApis(configs == null ? void 0 : configs.squatchConfig);
1733
1741
 
1734
- return this.widgetApi.render({
1742
+ return await this.widgetApi.render({
1735
1743
  engagementMedium: (configs == null ? void 0 : (_configs$widgetConfig = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig.engagementMedium) || this.type,
1736
1744
  widgetType: (configs == null ? void 0 : (_configs$widgetConfig2 = configs.widgetConfig) == null ? void 0 : _configs$widgetConfig2.widgetType) || this.widgetType
1737
1745
  }).then(res => this._setWidget(res.template, {
@@ -1740,8 +1748,6 @@ class DeclarativeWidget extends HTMLElement {
1740
1748
  }
1741
1749
 
1742
1750
  async renderUserUpsertVariant() {
1743
- if (!this.widgetType) throw new Error("Widget must be specified");
1744
-
1745
1751
  this._setupApis();
1746
1752
 
1747
1753
  var userObj = decodeUserJwt(this.token);
@@ -1775,17 +1781,15 @@ class DeclarativeWidget extends HTMLElement {
1775
1781
 
1776
1782
  async renderWidget() {
1777
1783
  await this.getWidgetInstance();
1778
- this.element = this.widgetInstance._findElement();
1779
- this.frame = this.widgetInstance._createFrame();
1780
- await this.widgetInstance.load(this.frame);
1784
+ await this.widgetInstance.load();
1781
1785
  }
1782
1786
 
1783
1787
  open() {
1784
- this.widgetInstance.open(this.frame);
1788
+ this.widgetInstance.open();
1785
1789
  }
1786
1790
 
1787
1791
  close() {
1788
- this.widgetInstance.close(this.frame);
1792
+ this.widgetInstance.close();
1789
1793
  }
1790
1794
 
1791
1795
  }
@@ -1794,7 +1798,6 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
1794
1798
  constructor() {
1795
1799
  super();
1796
1800
  this.type = "EMBED";
1797
- this.container = this.getAttribute("container") || this;
1798
1801
  }
1799
1802
 
1800
1803
  static get observedAttributes() {
@@ -1811,7 +1814,7 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
1811
1814
  // Specific to embed widgets
1812
1815
 
1813
1816
  case "container":
1814
- if (this.element) this.close();
1817
+ if (this.widgetInstance._findElement()) this.close();
1815
1818
  this.connectedCallback();
1816
1819
  break;
1817
1820
  }
@@ -1820,9 +1823,10 @@ class DeclarativeEmbedWidget extends DeclarativeWidget {
1820
1823
  async connectedCallback() {
1821
1824
  var _ref, _this$shadowRoot;
1822
1825
 
1826
+ this.container = this.getAttribute("container") || this;
1823
1827
  await this.renderWidget();
1824
1828
  var slot = (_ref = this.shadowRoot && Array.from(this.shadowRoot.children)) == null ? void 0 : _ref.find(c => c.tagName === "SLOT");
1825
- (_this$shadowRoot = this.shadowRoot) == null ? void 0 : _this$shadowRoot.removeChild(slot);
1829
+ if (slot) (_this$shadowRoot = this.shadowRoot) == null ? void 0 : _this$shadowRoot.removeChild(slot);
1826
1830
  }
1827
1831
 
1828
1832
  }
@@ -1890,7 +1894,7 @@ var _events = null;
1890
1894
  */
1891
1895
 
1892
1896
  function api() {
1893
- if (!_api) this.init({});
1897
+ if (!_api) exports.init({});
1894
1898
  return _api;
1895
1899
  }
1896
1900
  /**
@@ -1902,7 +1906,7 @@ function api() {
1902
1906
  */
1903
1907
 
1904
1908
  function widgets() {
1905
- if (!_widgets) this.init({});
1909
+ if (!_widgets) exports.init({});
1906
1910
  return _widgets;
1907
1911
  }
1908
1912
  /**
@@ -1914,7 +1918,7 @@ function widgets() {
1914
1918
  */
1915
1919
 
1916
1920
  function events() {
1917
- if (!_events) this.init({});
1921
+ if (!_events) exports.init({});
1918
1922
  return _events;
1919
1923
  }
1920
1924
  /**