@ikonai/sdk-react-ui 1.0.56 → 1.0.58
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/app/connection-state-renderer.d.ts +23 -8
- package/app/ikon-app.d.ts +55 -0
- package/app/index.d.ts +2 -0
- package/app/use-ikon-app.d.ts +6 -0
- package/app/use-ikon-debug.d.ts +41 -0
- package/index.d.ts +1 -1
- package/index.js +1539 -1402
- package/package.json +1 -1
|
@@ -14,25 +14,33 @@ export interface ConnectedRenderProps {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Props for the ConnectionStateRenderer component.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Prefer {@link IkonApp} which renders the surface continuously and layers
|
|
19
|
+
* overlays on top of it. `ConnectionStateRenderer` remains as a back-compat shim for apps
|
|
20
|
+
* pinned to the old callback-per-state API.
|
|
17
21
|
*/
|
|
18
22
|
export interface ConnectionStateRendererProps {
|
|
19
23
|
connectionState: ConnectionState;
|
|
20
24
|
error: string | null;
|
|
21
25
|
isReady: boolean;
|
|
26
|
+
isConnectingSlow?: boolean;
|
|
22
27
|
stores: ReadonlyMap<string, IkonUiStoreEntry> | undefined;
|
|
23
28
|
registry: IkonUiRegistry | null;
|
|
24
29
|
client: IkonClient | null;
|
|
25
30
|
onAction: (actionId: string, payload: unknown) => void;
|
|
26
31
|
/**
|
|
27
|
-
*
|
|
32
|
+
* @deprecated The runtime no longer emits `'idle'`; this callback never fires. The
|
|
33
|
+
* prop stays for source-compatibility with apps that already pass it.
|
|
28
34
|
*/
|
|
29
35
|
renderIdle: () => ReactNode;
|
|
30
36
|
/**
|
|
31
|
-
* Render when connecting (initial connection attempt
|
|
37
|
+
* Render when connecting (initial connection attempt and the slow-connection
|
|
38
|
+
* threshold has not yet elapsed).
|
|
32
39
|
*/
|
|
33
40
|
renderConnecting: () => ReactNode;
|
|
34
41
|
/**
|
|
35
|
-
* Render when connection is taking longer than expected.
|
|
42
|
+
* Render when connection is taking longer than expected. Fires when
|
|
43
|
+
* `connectionState === 'connecting'` and `isConnectingSlow === true`.
|
|
36
44
|
*/
|
|
37
45
|
renderConnectingSlow: () => ReactNode;
|
|
38
46
|
/**
|
|
@@ -41,16 +49,23 @@ export interface ConnectionStateRendererProps {
|
|
|
41
49
|
*/
|
|
42
50
|
renderConnected: (props: ConnectedRenderProps) => ReactNode;
|
|
43
51
|
/**
|
|
44
|
-
* Render when
|
|
52
|
+
* Render when offline and no error message is attached. Full-page replacement.
|
|
45
53
|
*/
|
|
46
54
|
renderOffline: () => ReactNode;
|
|
47
55
|
/**
|
|
48
|
-
* Render when
|
|
56
|
+
* Render when offline with an error message attached. Full-page replacement.
|
|
57
|
+
* Previously fired only for the dropped `'offlineError'` state; now fires when
|
|
58
|
+
* `connectionState === 'offline'` and `error` (or `client.lastError`) is set.
|
|
49
59
|
*/
|
|
50
60
|
renderError: (error: string | null) => ReactNode;
|
|
51
61
|
}
|
|
52
62
|
/**
|
|
53
|
-
* Headless component that handles connection state logic
|
|
54
|
-
*
|
|
63
|
+
* Headless component that handles connection state logic by invoking one of the supplied
|
|
64
|
+
* render callbacks based on the current state.
|
|
65
|
+
*
|
|
66
|
+
* @deprecated Prefer {@link IkonApp} for new code. `IkonApp` mounts the UI surface once
|
|
67
|
+
* and layers overlays on top, which gives a smoother UX through `reconnecting` / `offline`
|
|
68
|
+
* transitions. This component remains as a back-compat shim so existing apps continue to
|
|
69
|
+
* work without changes when they upgrade the SDK.
|
|
55
70
|
*/
|
|
56
|
-
export declare function ConnectionStateRenderer({ connectionState, error, isReady, stores, registry, client, onAction, renderIdle, renderConnecting, renderConnectingSlow, renderConnected, renderOffline, renderError, }: ConnectionStateRendererProps): ReactNode;
|
|
71
|
+
export declare function ConnectionStateRenderer({ connectionState, error, isReady, isConnectingSlow, stores, registry, client, onAction, renderIdle: _renderIdle, renderConnecting, renderConnectingSlow, renderConnected, renderOffline, renderError, }: ConnectionStateRendererProps): ReactNode;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { UseIkonAppResult } from './use-ikon-app';
|
|
3
|
+
/**
|
|
4
|
+
* Overlay rendered during `connecting`. If a function, it receives `isSlow` so the overlay
|
|
5
|
+
* can stay invisible during fast connections and reveal a chip once the slow threshold trips.
|
|
6
|
+
*/
|
|
7
|
+
export type ConnectingOverlayProp = ReactNode | ((isSlow: boolean) => ReactNode);
|
|
8
|
+
/** Overlay rendered during `reconnecting` (always on top of the cached surface). */
|
|
9
|
+
export type ReconnectingOverlayProp = ReactNode | (() => ReactNode);
|
|
10
|
+
/**
|
|
11
|
+
* Overlay rendered during `offline`. The function form receives the optional error string
|
|
12
|
+
* (the synthetic-internal-error case), so the overlay can render a message line when present.
|
|
13
|
+
*/
|
|
14
|
+
export type OfflineOverlayProp = ReactNode | ((error: string | null) => ReactNode);
|
|
15
|
+
/**
|
|
16
|
+
* Full-page screen rendered when `accessDeniedReason` is set. The function form receives the
|
|
17
|
+
* server-provided reason string so the screen can surface it to the user.
|
|
18
|
+
*/
|
|
19
|
+
export type AccessDeniedScreenProp = ReactNode | ((reason: string) => ReactNode);
|
|
20
|
+
export interface IkonAppProps extends UseIkonAppResult {
|
|
21
|
+
/** Overlay rendered during `connecting` (and `waitingForExternalConnectUrl`). */
|
|
22
|
+
connectingOverlay?: ConnectingOverlayProp;
|
|
23
|
+
/** Overlay rendered during `reconnecting`. */
|
|
24
|
+
reconnectingOverlay?: ReconnectingOverlayProp;
|
|
25
|
+
/** Overlay rendered during `offline`. Receives the optional error message. */
|
|
26
|
+
offlineOverlay?: OfflineOverlayProp;
|
|
27
|
+
/**
|
|
28
|
+
* Full-page screen rendered when the backend denied access (HTTP 403 — e.g. domain
|
|
29
|
+
* allowlist mismatch). Takes priority over all overlays. If omitted, nothing is rendered
|
|
30
|
+
* for the access-denied case; pass a screen (or handle it upstream) for a real UI.
|
|
31
|
+
*/
|
|
32
|
+
accessDeniedScreen?: AccessDeniedScreenProp;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* High-level shell that mounts the Ikon UI surface and layers an overlay on top
|
|
36
|
+
* based on the connection state. Always renders the surface once it has been populated
|
|
37
|
+
* for the first time, so the UI stays visible through `reconnecting` and `offline`.
|
|
38
|
+
*
|
|
39
|
+
* Usage:
|
|
40
|
+
* ```tsx
|
|
41
|
+
* const app = useIkonApp({ modules: [...] });
|
|
42
|
+
*
|
|
43
|
+
* <IkonApp
|
|
44
|
+
* {...app}
|
|
45
|
+
* connectingOverlay={(isSlow) => isSlow ? <ConnectingChip /> : null}
|
|
46
|
+
* reconnectingOverlay={<ReconnectingOverlay />}
|
|
47
|
+
* offlineOverlay={(error) => <OfflineOverlay error={error} />}
|
|
48
|
+
* />
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* Debug keyboard shortcuts (Ctrl+Shift+1..6, 0, E) are wired up automatically when SDK
|
|
52
|
+
* debug mode is on (URL has `?ikon-debug=true`). See `useIkonDebug` for the full map.
|
|
53
|
+
* No on-screen indicator is rendered for active overrides.
|
|
54
|
+
*/
|
|
55
|
+
export declare function IkonApp(props: IkonAppProps): ReactNode;
|
package/app/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { ConnectionStateRenderer, type ConnectedRenderProps, type ConnectionStateRendererProps } from './connection-state-renderer';
|
|
2
2
|
export { useIkonApp, type IkonUiModuleRegistration, type UseIkonAppOptions, type UseIkonAppResult } from './use-ikon-app';
|
|
3
|
+
export { IkonApp, type IkonAppProps, type ConnectingOverlayProp, type ReconnectingOverlayProp, type OfflineOverlayProp, type AccessDeniedScreenProp } from './ikon-app';
|
|
4
|
+
export { useIkonDebug, type UseIkonDebugResult } from './use-ikon-debug';
|
package/app/use-ikon-app.d.ts
CHANGED
|
@@ -126,6 +126,12 @@ export interface UseIkonAppResult {
|
|
|
126
126
|
* Whether the connection is ready to render UI.
|
|
127
127
|
*/
|
|
128
128
|
isReady: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* True after `connectionState === 'connecting'` has lasted longer than the slow-connection
|
|
131
|
+
* threshold (default 5s, configurable via `timeouts.slowConnectionThresholdMs`). The connecting
|
|
132
|
+
* overlay can use this signal to delay showing feedback so a fast connection doesn't flash a chip.
|
|
133
|
+
*/
|
|
134
|
+
isConnectingSlow: boolean;
|
|
129
135
|
/**
|
|
130
136
|
* All WebRTC video streams keyed by track index.
|
|
131
137
|
*/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ConnectionState } from '../../../sdk/src/index.ts';
|
|
2
|
+
import { UseIkonAppResult } from './use-ikon-app';
|
|
3
|
+
/**
|
|
4
|
+
* Result of useIkonDebug — same shape as the input `UseIkonAppResult` (so it can be spread
|
|
5
|
+
* straight into `<IkonApp />`), plus diagnostic fields the host may surface itself.
|
|
6
|
+
*/
|
|
7
|
+
export interface UseIkonDebugResult {
|
|
8
|
+
/**
|
|
9
|
+
* The (possibly overridden) app value. Spread into `<IkonApp />` to apply forced states.
|
|
10
|
+
* When no override is active, this is the original `app` reference unchanged.
|
|
11
|
+
*/
|
|
12
|
+
app: UseIkonAppResult;
|
|
13
|
+
/** Non-null when a state override is active. */
|
|
14
|
+
forcedState: ConnectionState | null;
|
|
15
|
+
/** True when the empty-stores override is active (forces the "no UI ever rendered" path). */
|
|
16
|
+
emptyStores: boolean;
|
|
17
|
+
/** Non-null when a synthetic error is being injected into the offline overlay. */
|
|
18
|
+
forcedError: string | null;
|
|
19
|
+
/** Non-null when the access-denied override is active. */
|
|
20
|
+
forcedAccessDenied: string | null;
|
|
21
|
+
/** True when the debug shortcuts are active in this environment. */
|
|
22
|
+
debugEnabled: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Listens for `Ctrl+Shift+<key>` shortcuts (active only when SDK debug mode is on, i.e. the
|
|
26
|
+
* URL has `?ikon-debug=true`) and returns an overridden app result that forces connection
|
|
27
|
+
* states / surface emptiness / error messages. Render-time effects only — no on-screen
|
|
28
|
+
* indicator. `<IkonApp />` calls this hook internally; you only need it if you bypass
|
|
29
|
+
* `<IkonApp />` and want the same behavior.
|
|
30
|
+
*
|
|
31
|
+
* Shortcut map (all require Ctrl+Shift, `event.code`-based so layout-independent):
|
|
32
|
+
* - Digit1 → force `connecting` (an internal 5s timer flips isConnectingSlow to true so you can see both phases without a second shortcut)
|
|
33
|
+
* - Digit2 → force `connected`
|
|
34
|
+
* - Digit3 → force `reconnecting`
|
|
35
|
+
* - Digit4 → force `offline` (no error)
|
|
36
|
+
* - Digit5 → force `offline` with synthetic error
|
|
37
|
+
* - Digit6 → force access-denied (synthetic reason — exercises the accessDeniedScreen path)
|
|
38
|
+
* - Digit0 → clear all state overrides
|
|
39
|
+
* - KeyE → toggle empty-stores override (simulates "initial connection never produced UI")
|
|
40
|
+
*/
|
|
41
|
+
export declare function useIkonDebug(app: UseIkonAppResult): UseIkonDebugResult;
|
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type { UiComponentRenderer, UiComponentLibrary, UiNode, UiRenderContext,
|
|
|
13
13
|
export { UiStreamStore, type UiStylePayload } from '../../sdk-ui/src/index.ts';
|
|
14
14
|
export { renderMotionLetters } from './shared/render-motion-letters';
|
|
15
15
|
export { type AuthConfig, type AuthContextValue, type AuthSession, type AuthState, type AuthUser, type LoginMethod, clearAuthSession, loadAuthSession, saveAuthSession, sessionToUser, authenticateAnonymous, buildOAuthRedirectUrl, clearOAuthParams, parseOAuthCallback, parseOAuthError, sendLoginCode, verifyLoginCode, type OAuthCallbackResult, type SendLoginCodeOptions, type VerifyLoginCodeOptions, AuthProvider, useAuth, useAuthOptional, type AuthProviderProps, useAuthGuard, type UseAuthGuardOptions, type UseAuthGuardResult, } from './auth';
|
|
16
|
-
export { ConnectionStateRenderer, type ConnectedRenderProps, type ConnectionStateRendererProps, useIkonApp, type IkonUiModuleRegistration, type UseIkonAppOptions, type UseIkonAppResult, } from './app';
|
|
16
|
+
export { ConnectionStateRenderer, type ConnectedRenderProps, type ConnectionStateRendererProps, useIkonApp, type IkonUiModuleRegistration, type UseIkonAppOptions, type UseIkonAppResult, IkonApp, type IkonAppProps, type ConnectingOverlayProp, type ReconnectingOverlayProp, type OfflineOverlayProp, type AccessDeniedScreenProp, useIkonDebug, type UseIkonDebugResult, } from './app';
|
|
17
17
|
export { useLazyFont, useToasts, useIkonReactive, useReactive, type Toast } from './hooks';
|
|
18
18
|
export { I18nProvider, useI18n, type I18nContextValue, type I18nProviderProps } from './i18n';
|
|
19
19
|
export { InspectOverlay, type InspectElementPayload } from './inspect/inspect-overlay';
|