@kaltura-apps/genie-chat-react 1.3.0 → 1.3.2
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/index.esm.js +37 -12
- package/package.json +1 -1
- package/src/lib/genie-chat-provider.d.ts +1 -0
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import React, { useMemo, useContext } from 'react';
|
|
3
|
-
import { UnisphereProvider, ScopedUnisphereWorkspaceProvider, ScopedUnisphereWorkspaceContext, UnisphereRuntimeVisual } from '@unisphere/runtime-react';
|
|
3
|
+
import { UnisphereProvider, ScopedUnisphereWorkspaceProvider, UnisphereRuntimeLoader, ScopedUnisphereWorkspaceContext, UnisphereRuntimeVisual } from '@unisphere/runtime-react';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
6
|
|
|
@@ -1642,7 +1642,8 @@ const GenieChatProvider = ({
|
|
|
1642
1642
|
runtimeSettings,
|
|
1643
1643
|
lang: _lang = 'en',
|
|
1644
1644
|
theme: _theme = 'light',
|
|
1645
|
-
env: _env = 'nvp1'
|
|
1645
|
+
env: _env = 'nvp1',
|
|
1646
|
+
runtimeErrorComponent
|
|
1646
1647
|
}) => {
|
|
1647
1648
|
const [workspace, setWorkspace] = React.useState(null);
|
|
1648
1649
|
const workspaceName = useMemo(() => {
|
|
@@ -1653,14 +1654,10 @@ const GenieChatProvider = ({
|
|
|
1653
1654
|
appId: appId,
|
|
1654
1655
|
workspaceName: workspaceName,
|
|
1655
1656
|
appVersion: '0.0.0',
|
|
1656
|
-
serverUrl: `https://unisphere.${_env}.ovp.kaltura.com/v1
|
|
1657
|
-
runtimes: [{
|
|
1658
|
-
widgetName: 'unisphere.widget.genie',
|
|
1659
|
-
runtimeName: 'chat',
|
|
1660
|
-
settings: runtimeSettings
|
|
1661
|
-
}]
|
|
1657
|
+
serverUrl: `https://unisphere.${_env}.ovp.kaltura.com/v1`
|
|
1662
1658
|
};
|
|
1663
|
-
}, [_env,
|
|
1659
|
+
}, [_env, workspaceName]);
|
|
1660
|
+
const [runtimeError, setRuntimeError] = React.useState(null);
|
|
1664
1661
|
const themeProps = useMemo(() => {
|
|
1665
1662
|
if (typeof _theme === 'object') {
|
|
1666
1663
|
return {
|
|
@@ -1671,14 +1668,42 @@ const GenieChatProvider = ({
|
|
|
1671
1668
|
themeMode: _theme
|
|
1672
1669
|
};
|
|
1673
1670
|
}, [_theme]);
|
|
1671
|
+
if (!runtimeSettings) {
|
|
1672
|
+
return null;
|
|
1673
|
+
}
|
|
1674
|
+
if (runtimeError) {
|
|
1675
|
+
return runtimeErrorComponent !== null && runtimeErrorComponent !== void 0 ? runtimeErrorComponent : jsxs("div", {
|
|
1676
|
+
style: {
|
|
1677
|
+
color: 'red',
|
|
1678
|
+
padding: '1rem',
|
|
1679
|
+
width: '100%',
|
|
1680
|
+
height: '100%',
|
|
1681
|
+
textAlign: 'center',
|
|
1682
|
+
maxWidth: '25rem'
|
|
1683
|
+
},
|
|
1684
|
+
children: [jsx("p", {
|
|
1685
|
+
children: jsx("b", {
|
|
1686
|
+
children: "Error loading chat runtime"
|
|
1687
|
+
})
|
|
1688
|
+
}), jsx("p", {
|
|
1689
|
+
children: "Try again later"
|
|
1690
|
+
})]
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1674
1693
|
return jsx(UnisphereProvider, Object.assign({}, themeProps, {
|
|
1675
1694
|
language: _lang,
|
|
1676
1695
|
initialConfiguration: initialConfiguration,
|
|
1677
1696
|
onWorkspaceLoaded: setWorkspace,
|
|
1678
|
-
children: workspace &&
|
|
1697
|
+
children: workspace && jsxs(ScopedUnisphereWorkspaceProvider, {
|
|
1679
1698
|
unisphereWorkspace: workspace,
|
|
1680
1699
|
runtimeLogger: workspace.getLogger(appId),
|
|
1681
|
-
children:
|
|
1700
|
+
children: [jsx(UnisphereRuntimeLoader, {
|
|
1701
|
+
runtimeName: "chat",
|
|
1702
|
+
widgetName: "unisphere.widget.genie",
|
|
1703
|
+
runtimeSettings: runtimeSettings,
|
|
1704
|
+
workspaceName: workspace.getWorkspaceName(),
|
|
1705
|
+
onRuntimeError: setRuntimeError
|
|
1706
|
+
}), children]
|
|
1682
1707
|
})
|
|
1683
1708
|
}));
|
|
1684
1709
|
};
|
package/package.json
CHANGED
|
@@ -5,5 +5,6 @@ export type GenieChatProviderProps = {
|
|
|
5
5
|
lang?: string;
|
|
6
6
|
theme?: 'light' | 'dark' | object;
|
|
7
7
|
runtimeSettings?: Omit<ChatRuntimeSettings, 'schemaVersion'>;
|
|
8
|
+
runtimeErrorComponent?: React.ReactNode;
|
|
8
9
|
};
|
|
9
10
|
export declare const GenieChatProvider: React.FC<React.PropsWithChildren<GenieChatProviderProps>>;
|