@saasquatch/squatch-js 2.7.0-3 → 2.7.0

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 (49) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/squatch.cjs.js +2119 -7
  3. package/dist/squatch.cjs.js.map +1 -1
  4. package/dist/squatch.esm.js +2161 -0
  5. package/dist/squatch.esm.js.map +1 -0
  6. package/dist/squatch.js +2125 -9
  7. package/dist/squatch.js.map +1 -1
  8. package/dist/squatch.min.js +6 -0
  9. package/package.json +10 -9
  10. package/vite.config.ts +10 -3
  11. package/coverage/clover.xml +0 -917
  12. package/coverage/coverage-final.json +0 -21
  13. package/coverage/lcov-report/base.css +0 -224
  14. package/coverage/lcov-report/block-navigation.js +0 -87
  15. package/coverage/lcov-report/favicon.png +0 -0
  16. package/coverage/lcov-report/prettify.css +0 -1
  17. package/coverage/lcov-report/prettify.js +0 -2
  18. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  19. package/coverage/lcov-report/sorter.js +0 -196
  20. package/coverage/lcov.info +0 -1669
  21. package/dist/squatch.es.js +0 -1623
  22. package/dist/squatch.es.js.map +0 -1
  23. package/dist copy/api/AnalyticsApi.d.ts +0 -32
  24. package/dist copy/api/EventsApi.d.ts +0 -52
  25. package/dist copy/api/WidgetApi.d.ts +0 -64
  26. package/dist copy/api/graphql.d.ts +0 -1
  27. package/dist copy/async.d.ts +0 -20
  28. package/dist copy/docs.d.ts +0 -1
  29. package/dist copy/globals.d.ts +0 -4
  30. package/dist copy/squatch.cjs.js +0 -48
  31. package/dist copy/squatch.d.ts +0 -122
  32. package/dist copy/squatch.es.js +0 -1622
  33. package/dist copy/squatch.esm.js +0 -2317
  34. package/dist copy/squatch.esm.js.map +0 -1
  35. package/dist copy/squatch.js +0 -2337
  36. package/dist copy/squatch.js.map +0 -1
  37. package/dist copy/types.d.ts +0 -109
  38. package/dist copy/utils/cookieUtils.d.ts +0 -3
  39. package/dist copy/utils/decodeUserJwt.d.ts +0 -2
  40. package/dist copy/utils/domready.d.ts +0 -6
  41. package/dist copy/utils/io.d.ts +0 -5
  42. package/dist copy/utils/utmUtils.d.ts +0 -14
  43. package/dist copy/utils/validate.d.ts +0 -12
  44. package/dist copy/widgets/EmbedWidget.d.ts +0 -25
  45. package/dist copy/widgets/PopupWidget.d.ts +0 -30
  46. package/dist copy/widgets/Widget.d.ts +0 -57
  47. package/dist copy/widgets/Widgets.d.ts +0 -112
  48. package/dist copy/widgets/declarative/DeclarativeWidget.d.ts +0 -100
  49. package/dist copy/widgets/declarative/DeclarativeWidgets.d.ts +0 -35
@@ -1,112 +0,0 @@
1
- import WidgetApi from "../api/WidgetApi";
2
- import { ConfigOptions, WidgetConfig, WidgetResult, WithRequired } from "../types";
3
- /**
4
- * `Widgets` is a factory for creating widgets. It's possible to build your own widgets using the
5
- * {@link WidgetApi} but most people will prefer to use these easy methods.
6
- * @class
7
- */
8
- export default class Widgets {
9
- /**
10
- * Instance of {@link WidgetApi}
11
- */
12
- api: WidgetApi;
13
- /**
14
- * Tenant alias of SaaSquatch tenant
15
- */
16
- tenantAlias: string;
17
- /**
18
- * SaaSquatch domain for API requests
19
- * @default "https://app.referralsaasquatch.com"
20
- */
21
- domain: string;
22
- /**
23
- * Hosted CDN for npm packages
24
- * @default "https://fast.ssqt.io/npm"
25
- */
26
- npmCdn: string;
27
- /**
28
- * Initialize a new {@link Widgets} instance.
29
- *
30
- * @param {ConfigOptions} config Config details
31
- *
32
- * @example <caption>Browser example</caption>
33
- * var widgets = new squatch.Widgets({tenantAlias:'test_12b5bo1b25125'});
34
- *
35
- * @example <caption>Browserify/Webpack example</caption>
36
- * var Widgets = require('@saasquatch/squatch-js').Widgets;
37
- * var widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
38
- *
39
- * @example <caption>Babel+Browserify/Webpack example</caption>
40
- * import {Widgets} from '@saasquatch/squatch-js';
41
- * let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});
42
- */
43
- constructor(configin: ConfigOptions);
44
- /**
45
- * This function calls the {@link WidgetApi.upsertUser} method, and it renders
46
- * the widget if it is successful. Otherwise it shows the "error" widget.
47
- *
48
- * @param {Object} config Config details
49
- * @param {Object} config.user The user details
50
- * @param {string} config.user.id The user id
51
- * @param {string} config.user.accountId The user account id
52
- * @param {WidgetType} config.widgetType The content of the widget
53
- * @param {EngagementMedium} config.engagementMedium How to display the widget
54
- * @param {string} config.jwt the JSON Web Token (JWT) that is used to validate the data (can be disabled)
55
- * @param {HTMLElement | string | undefined} config.container Element to load the widget into
56
- * @param {string | undefined} config.trigger Trigger element for opening the popup widget
57
- *
58
- * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
59
- */
60
- upsertUser(config: WithRequired<WidgetConfig, "user">): Promise<{
61
- widget: any;
62
- user: any;
63
- }>;
64
- /**
65
- * This function calls the {@link WidgetApi.render} method, and it renders
66
- * the widget if it is successful. Otherwise it shows the "error" widget.
67
- *
68
- * @param {Object} config Config details
69
- * @param {Object} config.user The user details
70
- * @param {string} config.user.id The user id
71
- * @param {string} config.user.accountId The user account id
72
- * @param {WidgetType} config.widgetType The content of the widget
73
- * @param {EngagementMedium} config.engagementMedium How to display the widget
74
- * @param {string} config.jwt the JSON Web Token (JWT) that is used
75
- * to validate the data (can be disabled)
76
- *
77
- * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
78
- */
79
- render(config: WidgetConfig): Promise<WidgetResult | undefined>;
80
- /**
81
- * Autofills a referral code into an element when someone has been referred.
82
- * Uses {@link WidgetApi.squatchReferralCookie} behind the scenes.
83
- *
84
- * @param selector Element class/id selector, or a callback function
85
- * @returns
86
- */
87
- autofill(selector: string | Function): Promise<void>;
88
- /**
89
- * @hidden
90
- * @param {Object} response The json object return from the WidgetApi
91
- * @param {Object} config Config details
92
- * @param {string} config.widgetType The widget type (REFERRER_WIDGET, CONVERSION_WIDGET)
93
- * @param {string} config.engagementMedium (POPUP, EMBED)
94
- * @returns {Widget} widget (PopupWidget or EmbedWidget)
95
- */
96
- private _renderWidget;
97
- private _renderPopupWidget;
98
- private _renderEmbedWidget;
99
- /**
100
- * @hidden
101
- * @param {Object} error The json object containing the error details
102
- * @param {string} em The engagementMedium
103
- * @returns {void}
104
- */
105
- private _renderErrorWidget;
106
- /**
107
- * @hidden
108
- * @param {string} rule A regular expression
109
- * @returns {boolean} true if rule matches Url, false otherwise
110
- */
111
- private static _matchesUrl;
112
- }
@@ -1,100 +0,0 @@
1
- import AnalyticsApi from "../../api/AnalyticsApi";
2
- import WidgetApi from "../../api/WidgetApi";
3
- import { DeclarativeConfigOptions } from "../../types";
4
- import EmbedWidget from "../EmbedWidget";
5
- import PopupWidget from "../PopupWidget";
6
- /**
7
- * Abstract class for building web-components that render SaaSquatch widgets to the DOM
8
- * @abstract
9
- * @example
10
- * class TestWidgetElement extends DeclarativeWidget {}
11
- * const testWidget = new TestWidgetElement()
12
- * testWidget.widgetType = 'w/widget-type'
13
- * testWidget.type = 'EMBED'
14
- * testWidget.renderWidget()
15
- */
16
- export default abstract class DeclarativeWidget extends HTMLElement {
17
- /**
18
- * Configuration overrides
19
- * @default window.squatchConfig
20
- */
21
- config: DeclarativeConfigOptions | undefined;
22
- /**
23
- * Signed JWT containing user information
24
- * @default window.squatchToken
25
- */
26
- token: string | undefined;
27
- /**
28
- * Tenant alias of SaaSquatch tenant
29
- * @default window.squatchTenant
30
- */
31
- tenant: string | undefined;
32
- /**
33
- * widgetType of widget to load
34
- */
35
- widgetType: string | undefined;
36
- /**
37
- * Locale to render the widget in
38
- */
39
- locale: string | undefined;
40
- /**
41
- * Instance of {@link WidgetApi}
42
- */
43
- widgetApi: WidgetApi;
44
- /**
45
- * Instance of {@link AnalyticsApi}
46
- */
47
- analyticsApi: AnalyticsApi;
48
- /**
49
- * Instance of {@link EmbedWidget} or {@link PopupWidget}
50
- */
51
- widgetInstance: EmbedWidget | PopupWidget;
52
- /**
53
- * Determines whether to render the widget as an embedding widget or popup widget
54
- */
55
- type: "EMBED" | "POPUP";
56
- /**
57
- * Container element to contain the widget iframe
58
- * @default this
59
- */
60
- container: string | HTMLElement | undefined | null;
61
- element: HTMLElement | undefined;
62
- /**
63
- * Flag for if the component has been loaded or not
64
- * @hidden
65
- */
66
- loaded: boolean;
67
- constructor();
68
- private _setupApis;
69
- private renderPasswordlessVariant;
70
- private renderUserUpsertVariant;
71
- private _setWidget;
72
- /**
73
- * Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
74
- * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
75
- * @throws Throws an Error if `widgetType` is undefined
76
- */
77
- getWidgetInstance(): Promise<EmbedWidget | PopupWidget>;
78
- /**
79
- * Calls {@link getWidgetInstance} to build the Widget instance and loads the widget iframe into the DOM
80
- */
81
- renderWidget(): Promise<void>;
82
- /**
83
- * Builds a Widget instance for the default error widget
84
- * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
85
- */
86
- setErrorWidget: (e: Error) => EmbedWidget | PopupWidget;
87
- /**
88
- * Calls `open` method of `widgetInstance`
89
- * @throws Throws an Error if called before the widget has loaded
90
- */
91
- open(): void;
92
- /**
93
- * Calls `close` method of `widgetInstance`
94
- * @throws Throws an Error if called before the widget has loaded
95
- */
96
- close(): void;
97
- reload: () => Promise<void>;
98
- show: () => void;
99
- hide: () => void;
100
- }
@@ -1,35 +0,0 @@
1
- import DeclarativeWidget from "./DeclarativeWidget";
2
- /**
3
- * Base class for `squatch-embed` web-component
4
- * @extends {DeclarativeWidget}
5
- * @class
6
- * @example
7
- * window.createCustomElement('squatch-embed', DeclarativeEmbedWidget)
8
- * const widget = document.querySelector('squatch-embed') as DeclarativeEmbedWidget
9
- * widget.open()
10
- * widget.close()
11
- * widget.reload()
12
- */
13
- export declare class DeclarativeEmbedWidget extends DeclarativeWidget {
14
- constructor();
15
- static get observedAttributes(): string[];
16
- attributeChangedCallback(attr: string, oldVal: string, newVal: string): void;
17
- connectedCallback(): Promise<void>;
18
- }
19
- /**
20
- * Base class for `squatch-popup` web-component
21
- * @extends {DeclarativeWidget}
22
- * @class
23
- * @example
24
- * window.createCustomElement('squatch-popup', DeclarativePopupWidget)
25
- * const widget = document.querySelector('squatch-popup') as DeclarativePopupWidget
26
- * widget.open()
27
- * widget.close()
28
- * widget.reload()
29
- */
30
- export declare class DeclarativePopupWidget extends DeclarativeWidget {
31
- constructor();
32
- static get observedAttributes(): string[];
33
- attributeChangedCallback(attr: string, oldVal: string, newVal: string): void;
34
- connectedCallback(): Promise<void>;
35
- }