@returningai/widget-sdk 1.0.2 → 1.1.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.
- package/README.md +225 -89
- package/dist/rai-widget.iife.js +1 -1
- package/dist/rai-widget.js +435 -92
- package/dist/types/BaseWidget.d.ts +5 -0
- package/dist/types/core/auth.d.ts +2 -0
- package/dist/types/core/postmessage.d.ts +1 -1
- package/dist/types/types.d.ts +17 -0
- package/package.json +1 -1
|
@@ -6,17 +6,22 @@ export declare abstract class BaseWidget extends HTMLElement {
|
|
|
6
6
|
private state;
|
|
7
7
|
private loaderEl;
|
|
8
8
|
private errorEl;
|
|
9
|
+
private msgEl;
|
|
9
10
|
private cleanupListener?;
|
|
11
|
+
private intersectionObserver?;
|
|
12
|
+
private themeObserver?;
|
|
10
13
|
constructor();
|
|
11
14
|
protected abstract buildWidgetUrl(config: WidgetConfig): string;
|
|
12
15
|
connectedCallback(): void;
|
|
13
16
|
disconnectedCallback(): void;
|
|
17
|
+
private emit;
|
|
14
18
|
private renderShell;
|
|
15
19
|
private createDefaultLoader;
|
|
16
20
|
private hideLoader;
|
|
17
21
|
private showError;
|
|
18
22
|
private init;
|
|
19
23
|
private createIframe;
|
|
24
|
+
private mountWidget;
|
|
20
25
|
private scheduleRefresh;
|
|
21
26
|
private schedulePeriodicSync;
|
|
22
27
|
private logoutAndClear;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { WidgetConfig, WidgetState } from '../types';
|
|
2
2
|
export declare function authenticateServerless(config: WidgetConfig, state: WidgetState, onRefreshScheduled?: () => void): Promise<boolean>;
|
|
3
|
+
export declare function authenticateViaProxy(config: WidgetConfig, state: WidgetState, onRefreshScheduled?: () => void): Promise<boolean>;
|
|
3
4
|
export declare function refreshAccessToken(config: WidgetConfig, state: WidgetState, onRefreshScheduled?: () => void, sendToken?: () => void): Promise<boolean>;
|
|
4
5
|
export declare function getValidToken(config: WidgetConfig, state: WidgetState, onRefreshScheduled?: () => void): Promise<string>;
|
|
5
6
|
export declare function logout(config: WidgetConfig, state: WidgetState): Promise<void>;
|
|
7
|
+
export declare function validateEmbedToken(config: WidgetConfig): Promise<boolean>;
|
|
6
8
|
export declare function fetchErrorSettings(config: WidgetConfig, state: WidgetState): Promise<typeof state.errorSettings>;
|
|
7
9
|
declare function clearState(state: WidgetState): void;
|
|
8
10
|
export { clearState };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { WidgetConfig, WidgetState } from '../types';
|
|
2
2
|
export declare function sendTokenToWidget(config: WidgetConfig, state: WidgetState, iframe: HTMLIFrameElement): void;
|
|
3
|
-
export declare function setupMessageListener(config: WidgetConfig, state: WidgetState, _shadow: ShadowRoot, iframe: HTMLIFrameElement, onRefreshScheduled?: () => void, onLogout?: () => Promise<void>, hideLoader?: () => void): () => void;
|
|
3
|
+
export declare function setupMessageListener(config: WidgetConfig, state: WidgetState, _shadow: ShadowRoot, iframe: HTMLIFrameElement, onRefreshScheduled?: () => void, onLogout?: () => Promise<void>, hideLoader?: () => void, emit?: (type: string, detail?: Record<string, unknown>) => void): () => void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export interface WidgetConfig {
|
|
2
|
+
/** The community this widget belongs to. Maps to the `community-id` HTML attribute. */
|
|
3
|
+
communityId: string;
|
|
4
|
+
/** Channel widget only — the specific channel to display. Maps to the `channel-id` HTML attribute. */
|
|
5
|
+
channelId?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Alias for communityId — kept so subclass buildWidgetUrl() and widget
|
|
8
|
+
* main.tsx files that reference config.widgetId continue to work without changes.
|
|
9
|
+
* Set to the same value as communityId by readConfig().
|
|
10
|
+
*/
|
|
2
11
|
widgetId: string;
|
|
3
12
|
widgetType: 'store' | 'channel' | 'milestone' | 'social' | 'currency-view';
|
|
4
13
|
theme: 'light' | 'dark';
|
|
@@ -12,6 +21,14 @@ export interface WidgetConfig {
|
|
|
12
21
|
debug: boolean;
|
|
13
22
|
storagePrefix: string;
|
|
14
23
|
userIdentifiers: Record<string, string>;
|
|
24
|
+
maxRetries: number;
|
|
25
|
+
retryDelay: number;
|
|
26
|
+
heightDebounce: number;
|
|
27
|
+
locale?: string;
|
|
28
|
+
customData?: Record<string, unknown>;
|
|
29
|
+
authUrl?: string;
|
|
30
|
+
bundleUrl?: string;
|
|
31
|
+
embedToken?: string;
|
|
15
32
|
}
|
|
16
33
|
export interface WidgetState {
|
|
17
34
|
accessToken: string | null;
|