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

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.
Files changed (51) hide show
  1. package/.github/workflows/static.yml +89 -0
  2. package/CHANGELOG.md +3 -0
  3. package/README.md +14 -5
  4. package/coverage/clover.xml +882 -3
  5. package/coverage/coverage-final.json +21 -1
  6. package/coverage/lcov.info +1623 -0
  7. package/dist/api/WidgetApi.d.ts +3 -2
  8. package/dist/async.d.ts +5 -0
  9. package/dist/globals.d.ts +4 -0
  10. package/dist/squatch.d.ts +28 -16
  11. package/dist/squatch.esm.js +461 -244
  12. package/dist/squatch.esm.js.map +1 -1
  13. package/dist/squatch.js +460 -244
  14. package/dist/squatch.js.map +1 -1
  15. package/dist/squatch.min.js +1 -1
  16. package/dist/types.d.ts +8 -6
  17. package/dist/utils/validate.d.ts +2 -2
  18. package/dist/widgets/EmbedWidget.d.ts +9 -0
  19. package/dist/widgets/PopupWidget.d.ts +8 -3
  20. package/dist/widgets/Widgets.d.ts +21 -8
  21. package/dist/widgets/declarative/DeclarativeWidget.d.ts +72 -2
  22. package/dist/widgets/declarative/DeclarativeWidgets.d.ts +22 -0
  23. package/jest.config.ts +1 -3
  24. package/package.json +2 -2
  25. package/coverage/lcov-report/WidgetApi.ts.html +0 -631
  26. package/coverage/lcov-report/api/AnalyticsApi.ts.html +0 -304
  27. package/coverage/lcov-report/api/WidgetApi.ts.html +0 -631
  28. package/coverage/lcov-report/api/graphql.ts.html +0 -130
  29. package/coverage/lcov-report/utils/cookieUtils.ts.html +0 -415
  30. package/coverage/lcov-report/utils/decodeUserJwt.ts.html +0 -133
  31. package/coverage/lcov-report/utils/domready.ts.html +0 -160
  32. package/coverage/lcov-report/utils/io.ts.html +0 -400
  33. package/coverage/lcov-report/utils/utmUtils.ts.html +0 -277
  34. package/coverage/lcov-report/utils/validate.ts.html +0 -268
  35. package/coverage/lcov-report/validate.ts.html +0 -268
  36. package/coverage/lcov-report/widgets/EmbedWidget.ts.html +0 -433
  37. package/coverage/lcov-report/widgets/PopupWidget.ts.html +0 -670
  38. package/coverage/lcov-report/widgets/Widget.ts.html +0 -1165
  39. package/coverage/lcov-report/widgets/Widgets.ts.html +0 -1060
  40. package/coverage/lcov-report/widgets/declarative/DeclarativeWidget.ts.html +0 -499
  41. package/dist/squatch.min.js.map +0 -1
  42. package/dist/squatch.modern.js +0 -2
  43. package/dist/squatch.modern.js.map +0 -1
  44. package/dist/stats.html +0 -208
  45. package/dist/utils/domUtils.d.ts +0 -1
  46. package/dist/utils/loadEvent.d.ts +0 -2
  47. package/dist/widgets/CtaWidget.d.ts +0 -24
  48. package/dist/widgets/IREmbedWidget.d.ts +0 -29
  49. package/dist/widgets/IRPopupWidget.d.ts +0 -32
  50. package/dist/widgets/declarative/DeclarativeEmbedWidget.d.ts +0 -12
  51. package/stats.json +0 -1
@@ -26,7 +26,7 @@ export default class WidgetApi {
26
26
  */
27
27
  constructor(config?: ConfigOptions);
28
28
  /**
29
- * Creates/upserts user.
29
+ * Creates/upserts user, requests widget template.
30
30
  *
31
31
  * @param {Object} params Parameters for request
32
32
  * @param {Object?} params.user The user details
@@ -41,7 +41,7 @@ export default class WidgetApi {
41
41
  */
42
42
  upsertUser(params: WithRequired<WidgetConfig, "user">): Promise<any>;
43
43
  /**
44
- * Description here.
44
+ * Requests widget template
45
45
  *
46
46
  * @param {Object} params Parameters for request
47
47
  * @param {Object} params.user The user details
@@ -60,4 +60,5 @@ export default class WidgetApi {
60
60
  * @return {Promise<ReferralCookie>} code referral code if true.
61
61
  */
62
62
  squatchReferralCookie(): Promise<ReferralCookie>;
63
+ referralCookie: () => Promise<ReferralCookie>;
63
64
  }
package/dist/async.d.ts CHANGED
@@ -1,14 +1,19 @@
1
1
  import { ConfigOptions } from "./types";
2
2
  declare global {
3
3
  interface Window {
4
+ __squatchjsNamespace?: string;
4
5
  _squatch?: {
5
6
  ready: any[];
6
7
  };
8
+ impactOnReady?: () => {};
9
+ squatchOnReady?: () => {};
7
10
  squatch: any;
8
11
  widgetIdent: any;
9
12
  squatchTenant: string;
10
13
  squatchToken: string;
11
14
  squatchConfig: Omit<ConfigOptions, "tenantAlias">;
15
+ impactToken: string;
16
+ impactConfig: Omit<ConfigOptions, "tenantAlias">;
12
17
  }
13
18
  }
14
19
  /** @hidden */
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_DOMAIN = "https://app.referralsaasquatch.com";
2
+ export declare const DEFAULT_NPM_CDN = "https://fast.ssqt.io/npm";
3
+ export declare const DEFAULT_NAMESPACE = "squatch";
4
+ export declare const IMPACT_NAMESPACE = "impact";
package/dist/squatch.d.ts CHANGED
@@ -14,6 +14,10 @@ export { Widgets, EmbedWidget, PopupWidget, DeclarativeEmbedWidget, DeclarativeP
14
14
  * Read the {@link WidgetApi} docs.
15
15
  *
16
16
  * @returns WidgetApi static instance
17
+ * @example
18
+ * squatch.api().render({ ... })
19
+ * squatch.api().upsertUser({ ... })
20
+ * squatch.api().squatchReferralCookie()
17
21
  */
18
22
  export declare function api(): WidgetApi | null;
19
23
  /**
@@ -22,6 +26,10 @@ export declare function api(): WidgetApi | null;
22
26
  * Read the {@link Widgets} docs.
23
27
  *
24
28
  * @returns static instance
29
+ * @example
30
+ * squatch.widgets().render({ widgetType: "w/widget-type" })
31
+ * squatch.widgets().upsertUser({ user: { ... }, widgetType: "w/widget-type" })
32
+ * squatch.widgets().autofill(".referral-code")
25
33
  */
26
34
  export declare function widgets(): Widgets | null;
27
35
  /**
@@ -30,14 +38,27 @@ export declare function widgets(): Widgets | null;
30
38
  * Read the {@link EventsApi} docs.
31
39
  *
32
40
  * @returns EventsApi static instance
41
+ *
42
+ * @example
43
+ * squatch.events().track({ ... })
33
44
  */
34
45
  export declare function events(): EventsApi | null;
35
46
  /**
36
47
  * Entry-point for high level API to render a widget using the instance of {@link Widgets} created when you call {@link #init init}.
48
+ *
49
+ * Read the {@link Widgets.render} docs.
50
+ *
51
+ * @example
52
+ * squatch.widget().then(res => {
53
+ * const widget = res.widget
54
+ * }).catch(e => console.error("Did not render widget:", e))
37
55
  */
38
56
  export declare function widget(widgetConfig: WidgetConfig): Promise<WidgetResult | undefined> | undefined;
39
57
  /**
40
58
  * Extracts widget configuration from `_saasquatchExtra` UTM parameter. Initialises `squatch` and renders the widget as a {@link PopupWidget} via static instanct of {@link Widgets}.
59
+ *
60
+ * Called by default on startup via the loader script.
61
+ * @private
41
62
  */
42
63
  export declare function _auto(configIn: ConfigOptions): Promise<WidgetResult | undefined> | undefined;
43
64
  /**
@@ -50,7 +71,9 @@ export declare function _auto(configIn: ConfigOptions): Promise<WidgetResult | u
50
71
  * @param config Configuration details
51
72
  *
52
73
  * @example
53
- * squatch.init({tenantAlias:'test_basbtabstq51v'});
74
+ * squatch.init({
75
+ * tenantAlias:'test_basbtabstq51v',
76
+ * });
54
77
  */
55
78
  export declare function init(configIn: ConfigOptions): void;
56
79
  /**
@@ -62,7 +85,7 @@ export declare function init(configIn: ConfigOptions): void;
62
85
  * @example
63
86
  * squatch.ready(function() {
64
87
  * console.log("ready!");
65
- * squatch.api().upsertUser();
88
+ * squatch.api().upsertUser({ ... });
66
89
  * });
67
90
  */
68
91
  export declare function ready(fn: () => any): void;
@@ -72,23 +95,12 @@ export declare function ready(fn: () => any): void;
72
95
  *
73
96
  * @param {string} selector Element class/id
74
97
  * @returns {void}
75
- */
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
98
  *
84
99
  * @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
- * });
100
+ * squatch.autofill("input.referral-code")
101
+ * squatch.autofill("input#referral-code")
90
102
  */
91
- export declare function submitEmail(fn: (target: any, widget: any, email: any) => any): void;
103
+ export declare function autofill(selector: string): void;
92
104
  /**
93
105
  * Manually set the _saasquatch cookie as a 1st party cookie if available as a URL parameter on the current page.
94
106
  * This runs automatically immediately when squatch-js is loaded, except when window.SaaSquatchDoNotAutoDrop is true.