@trackunit/react-core-contexts 1.9.10 → 1.9.13
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.cjs.js +18 -10
- package/index.esm.js +19 -11
- package/package.json +8 -8
- package/src/index.d.ts +1 -1
- package/src/useSubscribeToHostChanges.d.ts +3 -1
package/index.cjs.js
CHANGED
|
@@ -10,10 +10,10 @@ var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
|
10
10
|
var graphql = require('graphql');
|
|
11
11
|
var graphqlSse = require('graphql-sse');
|
|
12
12
|
var react = require('react');
|
|
13
|
+
var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
|
|
13
14
|
require('@js-temporal/polyfill');
|
|
14
15
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
15
16
|
var reactComponents = require('@trackunit/react-components');
|
|
16
|
-
var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
|
|
17
17
|
|
|
18
18
|
const generateHeaders = (token, tracingHeaders) => {
|
|
19
19
|
const headers = {
|
|
@@ -231,6 +231,14 @@ const ManagerApolloProvider = ({ children }) => {
|
|
|
231
231
|
return jsxRuntime.jsx(client.ApolloProvider, { client: client$1, children: children });
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
+
/**
|
|
235
|
+
* This is a provider for the ToastContext.
|
|
236
|
+
*/
|
|
237
|
+
const ToastProviderIrisApp = ({ children }) => {
|
|
238
|
+
const value = react.useMemo(() => ({ addToast: irisAppRuntimeCore.ToastRuntime.addToast }), []);
|
|
239
|
+
return jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: value, children: children });
|
|
240
|
+
};
|
|
241
|
+
|
|
234
242
|
/**
|
|
235
243
|
* This is a provider for the AnalyticsProvider.
|
|
236
244
|
*/
|
|
@@ -479,14 +487,6 @@ const TimeRangeProviderIrisApp = ({ children }) => {
|
|
|
479
487
|
return jsxRuntime.jsx(reactCoreHooks.TimeRangeProvider, { value: timeRangeContext, children: children });
|
|
480
488
|
};
|
|
481
489
|
|
|
482
|
-
/**
|
|
483
|
-
* This is a provider for the ToastContext.
|
|
484
|
-
*/
|
|
485
|
-
const ToastProviderIrisApp = ({ children }) => {
|
|
486
|
-
const value = react.useMemo(() => ({ addToast: irisAppRuntimeCore.ToastRuntime.addToast }), []);
|
|
487
|
-
return jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: value, children: children });
|
|
488
|
-
};
|
|
489
|
-
|
|
490
490
|
/**
|
|
491
491
|
* This is a provider for the TokenContext.
|
|
492
492
|
*/
|
|
@@ -601,7 +601,15 @@ const UserSubscriptionProviderIrisApp = ({ children }) => {
|
|
|
601
601
|
* This is a provider for the WidgetConfigContext.
|
|
602
602
|
*/
|
|
603
603
|
const WidgetConfigProviderIrisApp = ({ children }) => {
|
|
604
|
-
|
|
604
|
+
const [pollInterval, setPollInterval] = react.useState(undefined);
|
|
605
|
+
react.useEffect(() => {
|
|
606
|
+
void irisAppRuntimeCore.WidgetConfigRuntime.getPollInterval().then(pi => setPollInterval(pi));
|
|
607
|
+
}, []);
|
|
608
|
+
const methods = react.useMemo(() => ({
|
|
609
|
+
onWidgetPollIntervalChanged: setPollInterval,
|
|
610
|
+
}), [setPollInterval]);
|
|
611
|
+
useSubscribeToHostChanges(methods);
|
|
612
|
+
return jsxRuntime.jsx(reactCoreHooks.WidgetConfigProvider, { value: { ...irisAppRuntimeCore.WidgetConfigRuntime, pollInterval }, children: children });
|
|
605
613
|
};
|
|
606
614
|
|
|
607
615
|
/**
|
package/index.esm.js
CHANGED
|
@@ -4,14 +4,14 @@ import { setContext } from '@apollo/client/link/context';
|
|
|
4
4
|
import { onError } from '@apollo/client/link/error';
|
|
5
5
|
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';
|
|
6
6
|
import { getMainDefinition, Observable } from '@apollo/client/utilities';
|
|
7
|
-
import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider,
|
|
7
|
+
import { useEnvironment, useToken, useErrorHandler, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-hooks';
|
|
8
8
|
import { print } from 'graphql';
|
|
9
9
|
import { createClient } from 'graphql-sse';
|
|
10
10
|
import { useState, useMemo, useEffect, Suspense } from 'react';
|
|
11
|
+
import { ToastRuntime, AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingContextRuntime, ThemeCssRuntime, TimeRangeRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
11
12
|
import '@js-temporal/polyfill';
|
|
12
13
|
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
13
14
|
import { Spinner } from '@trackunit/react-components';
|
|
14
|
-
import { AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingContextRuntime, ThemeCssRuntime, TimeRangeRuntime, ToastRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
15
15
|
|
|
16
16
|
const generateHeaders = (token, tracingHeaders) => {
|
|
17
17
|
const headers = {
|
|
@@ -229,6 +229,14 @@ const ManagerApolloProvider = ({ children }) => {
|
|
|
229
229
|
return jsx(ApolloProvider, { client: client, children: children });
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* This is a provider for the ToastContext.
|
|
234
|
+
*/
|
|
235
|
+
const ToastProviderIrisApp = ({ children }) => {
|
|
236
|
+
const value = useMemo(() => ({ addToast: ToastRuntime.addToast }), []);
|
|
237
|
+
return jsx(ToastProvider, { value: value, children: children });
|
|
238
|
+
};
|
|
239
|
+
|
|
232
240
|
/**
|
|
233
241
|
* This is a provider for the AnalyticsProvider.
|
|
234
242
|
*/
|
|
@@ -477,14 +485,6 @@ const TimeRangeProviderIrisApp = ({ children }) => {
|
|
|
477
485
|
return jsx(TimeRangeProvider, { value: timeRangeContext, children: children });
|
|
478
486
|
};
|
|
479
487
|
|
|
480
|
-
/**
|
|
481
|
-
* This is a provider for the ToastContext.
|
|
482
|
-
*/
|
|
483
|
-
const ToastProviderIrisApp = ({ children }) => {
|
|
484
|
-
const value = useMemo(() => ({ addToast: ToastRuntime.addToast }), []);
|
|
485
|
-
return jsx(ToastProvider, { value: value, children: children });
|
|
486
|
-
};
|
|
487
|
-
|
|
488
488
|
/**
|
|
489
489
|
* This is a provider for the TokenContext.
|
|
490
490
|
*/
|
|
@@ -599,7 +599,15 @@ const UserSubscriptionProviderIrisApp = ({ children }) => {
|
|
|
599
599
|
* This is a provider for the WidgetConfigContext.
|
|
600
600
|
*/
|
|
601
601
|
const WidgetConfigProviderIrisApp = ({ children }) => {
|
|
602
|
-
|
|
602
|
+
const [pollInterval, setPollInterval] = useState(undefined);
|
|
603
|
+
useEffect(() => {
|
|
604
|
+
void WidgetConfigRuntime.getPollInterval().then(pi => setPollInterval(pi));
|
|
605
|
+
}, []);
|
|
606
|
+
const methods = useMemo(() => ({
|
|
607
|
+
onWidgetPollIntervalChanged: setPollInterval,
|
|
608
|
+
}), [setPollInterval]);
|
|
609
|
+
useSubscribeToHostChanges(methods);
|
|
610
|
+
return jsx(WidgetConfigProvider, { value: { ...WidgetConfigRuntime, pollInterval }, children: children });
|
|
603
611
|
};
|
|
604
612
|
|
|
605
613
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.13",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"@apollo/client": "3.13.8",
|
|
11
11
|
"react": "19.0.0",
|
|
12
12
|
"jest-fetch-mock": "^3.0.3",
|
|
13
|
-
"@trackunit/iris-app-api": "1.7.
|
|
14
|
-
"@trackunit/react-core-contexts-api": "1.8.
|
|
15
|
-
"@trackunit/react-core-hooks": "1.7.
|
|
16
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
17
|
-
"@trackunit/react-components": "1.9.
|
|
18
|
-
"@trackunit/iris-app-runtime-core": "1.8.
|
|
13
|
+
"@trackunit/iris-app-api": "1.7.9",
|
|
14
|
+
"@trackunit/react-core-contexts-api": "1.8.10",
|
|
15
|
+
"@trackunit/react-core-hooks": "1.7.10",
|
|
16
|
+
"@trackunit/i18n-library-translation": "1.7.11",
|
|
17
|
+
"@trackunit/react-components": "1.9.13",
|
|
18
|
+
"@trackunit/iris-app-runtime-core": "1.8.10",
|
|
19
19
|
"graphql": "^16.10.0",
|
|
20
20
|
"graphql-sse": "^2.5.4",
|
|
21
|
-
"@trackunit/react-test-setup": "1.4.
|
|
21
|
+
"@trackunit/react-test-setup": "1.4.8",
|
|
22
22
|
"@js-temporal/polyfill": "^0.5.1"
|
|
23
23
|
},
|
|
24
24
|
"module": "./index.esm.js",
|
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { setupHostConnector } from "@trackunit/iris-app-runtime-core";
|
|
2
|
+
type ChildConnectorApi = Parameters<typeof setupHostConnector>[0];
|
|
2
3
|
/**
|
|
3
4
|
* Subscribe to methods initiated by changes in the host
|
|
4
5
|
*
|
|
5
6
|
* @param methods STABLE object with the methods you'd want to subscribe to. Wrap in useMemo for instance to make it stable
|
|
6
7
|
*/
|
|
7
|
-
export declare const useSubscribeToHostChanges: (methods:
|
|
8
|
+
export declare const useSubscribeToHostChanges: (methods: ChildConnectorApi) => void;
|
|
9
|
+
export {};
|