@trackunit/react-core-contexts 2.1.42-alpha-52dc2da9c19.0 → 2.1.44
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 +40 -4
- package/index.esm.js +40 -5
- package/package.json +8 -8
- package/src/featureFlags/FeatureFlagProviderIrisApp.d.ts +5 -0
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
|
|
5
|
+
var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
|
|
6
|
+
var react = require('react');
|
|
4
7
|
var client = require('@apollo/client');
|
|
5
8
|
var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
6
|
-
var react = require('react');
|
|
7
9
|
var context = require('@apollo/client/link/context');
|
|
8
10
|
var removeTypename = require('@apollo/client/link/remove-typename');
|
|
9
11
|
var utilities = require('@apollo/client/utilities');
|
|
10
12
|
var graphql = require('graphql');
|
|
11
13
|
var graphqlSse = require('graphql-sse');
|
|
12
14
|
var error = require('@apollo/client/link/error');
|
|
13
|
-
var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
|
|
14
|
-
var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
|
|
15
15
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
16
16
|
var reactComponents = require('@trackunit/react-components');
|
|
17
17
|
var irisAppRuntimeCoreApi = require('@trackunit/iris-app-runtime-core-api');
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* This is a provider for the Featureflags.
|
|
21
|
+
*/
|
|
22
|
+
const FeatureFlagProviderIrisApp = ({ children }) => {
|
|
23
|
+
const [featureFlags, setFeatureFlags] = react.useState(null);
|
|
24
|
+
react.useEffect(() => {
|
|
25
|
+
const updateEnv = async () => {
|
|
26
|
+
try {
|
|
27
|
+
setFeatureFlags(await irisAppRuntimeCore.FeatureFlagRuntime.getFeatureFlags());
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
setFeatureFlags(null);
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.error("Could not load environment!");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
void updateEnv();
|
|
36
|
+
}, []);
|
|
37
|
+
if (!featureFlags) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return jsxRuntime.jsx(reactCoreContextsApi.FeatureFlagContextProvider, { value: featureFlags, children: children });
|
|
41
|
+
};
|
|
42
|
+
|
|
19
43
|
/**
|
|
20
44
|
* This error link is used to capture error information, i. e. traceId, graphQL errors, network errors, etc.
|
|
21
45
|
*/
|
|
@@ -349,6 +373,17 @@ const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlRepor
|
|
|
349
373
|
LegacyServicePlan: {
|
|
350
374
|
keyFields: false,
|
|
351
375
|
},
|
|
376
|
+
// Merge disjoint sub-selections of the non-normalized `latest` object instead of
|
|
377
|
+
// replacing it, so concurrent queries don't clobber each other's subtrees. Global for
|
|
378
|
+
// all cache-reading Asset.locations consumers;
|
|
379
|
+
// see libs/fleet/map-page/docs/adr/0003-asset-identity-cache-prewarm.md
|
|
380
|
+
Locations: {
|
|
381
|
+
fields: {
|
|
382
|
+
latest: {
|
|
383
|
+
merge: true,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
},
|
|
352
387
|
},
|
|
353
388
|
}),
|
|
354
389
|
defaultOptions,
|
|
@@ -949,9 +984,10 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
949
984
|
i18nLibraryTranslation.registerTranslations(translations); // Register the apps translations if passed.
|
|
950
985
|
}
|
|
951
986
|
i18nLibraryTranslation.initializeTranslationsForApp(); // Initialize all registered translations
|
|
952
|
-
return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsxRuntime.jsx(ThemeCssProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserPreferenceProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(NavigationProviderIrisApp, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(ModalDialogContextProviderIrisApp, { children: jsxRuntime.jsx(ConfirmationDialogProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(ExportDataProviderIrisApp, { children: jsxRuntime.jsx(TimeRangeProviderIrisApp, { children: jsxRuntime.jsx(WidgetConfigProviderIrisApp, { children: jsxRuntime.jsx(GeolocationProviderIrisApp, { children: jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
987
|
+
return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsxRuntime.jsx(ThemeCssProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserPreferenceProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(NavigationProviderIrisApp, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(ModalDialogContextProviderIrisApp, { children: jsxRuntime.jsx(ConfirmationDialogProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(ExportDataProviderIrisApp, { children: jsxRuntime.jsx(TimeRangeProviderIrisApp, { children: jsxRuntime.jsx(WidgetConfigProviderIrisApp, { children: jsxRuntime.jsx(GeolocationProviderIrisApp, { children: jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: jsxRuntime.jsx(FeatureFlagProviderIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
953
988
|
};
|
|
954
989
|
|
|
990
|
+
exports.FeatureFlagProviderIrisApp = FeatureFlagProviderIrisApp;
|
|
955
991
|
exports.ManagerApolloProvider = ManagerApolloProvider;
|
|
956
992
|
exports.ToastProviderIrisApp = ToastProviderIrisApp;
|
|
957
993
|
exports.TrackunitProviders = TrackunitProviders;
|
package/index.esm.js
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { FeatureFlagRuntime, ToastRuntime, AnalyticsRuntime, registerHostChangeHandler, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, ExportDataRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, GeolocationRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingRuntime, ThemeCssRuntime, TimeRangeRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
3
|
+
import { FeatureFlagContextProvider, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, ExportDataContext, FilterBarProvider, GeolocationProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-contexts-api';
|
|
4
|
+
import { useState, useEffect, useMemo, useCallback, useReducer, Suspense } from 'react';
|
|
2
5
|
import { ApolloLink, Observable, createHttpLink, from, split, ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
6
|
import { useEnvironment, useToken, useErrorHandler } from '@trackunit/react-core-hooks';
|
|
4
|
-
import { useState, useEffect, useMemo, useCallback, useReducer, Suspense } from 'react';
|
|
5
7
|
import { setContext } from '@apollo/client/link/context';
|
|
6
8
|
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';
|
|
7
9
|
import { getMainDefinition, Observable as Observable$1 } from '@apollo/client/utilities';
|
|
8
10
|
import { print } from 'graphql';
|
|
9
11
|
import { createClient } from 'graphql-sse';
|
|
10
12
|
import { onError } from '@apollo/client/link/error';
|
|
11
|
-
import { ToastRuntime, AnalyticsRuntime, registerHostChangeHandler, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, ExportDataRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, GeolocationRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingRuntime, ThemeCssRuntime, TimeRangeRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
12
|
-
import { ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, ExportDataContext, FilterBarProvider, GeolocationProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-contexts-api';
|
|
13
13
|
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
14
14
|
import { Spinner } from '@trackunit/react-components';
|
|
15
15
|
import { Channels, SortOrder, AssetSortByProperty } from '@trackunit/iris-app-runtime-core-api';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* This is a provider for the Featureflags.
|
|
19
|
+
*/
|
|
20
|
+
const FeatureFlagProviderIrisApp = ({ children }) => {
|
|
21
|
+
const [featureFlags, setFeatureFlags] = useState(null);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const updateEnv = async () => {
|
|
24
|
+
try {
|
|
25
|
+
setFeatureFlags(await FeatureFlagRuntime.getFeatureFlags());
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
setFeatureFlags(null);
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.error("Could not load environment!");
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
void updateEnv();
|
|
34
|
+
}, []);
|
|
35
|
+
if (!featureFlags) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return jsx(FeatureFlagContextProvider, { value: featureFlags, children: children });
|
|
39
|
+
};
|
|
40
|
+
|
|
17
41
|
/**
|
|
18
42
|
* This error link is used to capture error information, i. e. traceId, graphQL errors, network errors, etc.
|
|
19
43
|
*/
|
|
@@ -347,6 +371,17 @@ const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlRepor
|
|
|
347
371
|
LegacyServicePlan: {
|
|
348
372
|
keyFields: false,
|
|
349
373
|
},
|
|
374
|
+
// Merge disjoint sub-selections of the non-normalized `latest` object instead of
|
|
375
|
+
// replacing it, so concurrent queries don't clobber each other's subtrees. Global for
|
|
376
|
+
// all cache-reading Asset.locations consumers;
|
|
377
|
+
// see libs/fleet/map-page/docs/adr/0003-asset-identity-cache-prewarm.md
|
|
378
|
+
Locations: {
|
|
379
|
+
fields: {
|
|
380
|
+
latest: {
|
|
381
|
+
merge: true,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
},
|
|
350
385
|
},
|
|
351
386
|
}),
|
|
352
387
|
defaultOptions,
|
|
@@ -947,7 +982,7 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
947
982
|
registerTranslations(translations); // Register the apps translations if passed.
|
|
948
983
|
}
|
|
949
984
|
initializeTranslationsForApp(); // Initialize all registered translations
|
|
950
|
-
return (jsx(EnvironmentProviderIrisApp, { children: jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsx(ThemeCssProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserPreferenceProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(NavigationProviderIrisApp, { children: jsx(ToastProviderIrisApp, { children: jsx(ModalDialogContextProviderIrisApp, { children: jsx(ConfirmationDialogProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(ExportDataProviderIrisApp, { children: jsx(TimeRangeProviderIrisApp, { children: jsx(WidgetConfigProviderIrisApp, { children: jsx(GeolocationProviderIrisApp, { children: jsx(Suspense, { fallback: jsx(Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
985
|
+
return (jsx(EnvironmentProviderIrisApp, { children: jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsx(ThemeCssProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserPreferenceProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(NavigationProviderIrisApp, { children: jsx(ToastProviderIrisApp, { children: jsx(ModalDialogContextProviderIrisApp, { children: jsx(ConfirmationDialogProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(ExportDataProviderIrisApp, { children: jsx(TimeRangeProviderIrisApp, { children: jsx(WidgetConfigProviderIrisApp, { children: jsx(GeolocationProviderIrisApp, { children: jsx(Suspense, { fallback: jsx(Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: jsx(FeatureFlagProviderIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
951
986
|
};
|
|
952
987
|
|
|
953
|
-
export { ManagerApolloProvider, ToastProviderIrisApp, TrackunitProviders };
|
|
988
|
+
export { FeatureFlagProviderIrisApp, ManagerApolloProvider, ToastProviderIrisApp, TrackunitProviders };
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.44",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/iris-app-api": "2.0.
|
|
11
|
-
"@trackunit/iris-app-runtime-core-api": "1.16.49
|
|
12
|
-
"@trackunit/react-core-hooks": "1.17.
|
|
13
|
-
"@trackunit/i18n-library-translation": "2.0.
|
|
14
|
-
"@trackunit/react-components": "2.1.
|
|
15
|
-
"@trackunit/iris-app-runtime-core": "1.17.50
|
|
10
|
+
"@trackunit/iris-app-api": "2.0.37",
|
|
11
|
+
"@trackunit/iris-app-runtime-core-api": "1.16.49",
|
|
12
|
+
"@trackunit/react-core-hooks": "1.17.55",
|
|
13
|
+
"@trackunit/i18n-library-translation": "2.0.44",
|
|
14
|
+
"@trackunit/react-components": "2.1.43",
|
|
15
|
+
"@trackunit/iris-app-runtime-core": "1.17.50",
|
|
16
16
|
"graphql-sse": "^2.5.4",
|
|
17
|
-
"@trackunit/react-core-contexts-api": "1.17.49
|
|
17
|
+
"@trackunit/react-core-contexts-api": "1.17.49"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@apollo/client": "^3.13.8",
|
package/src/index.d.ts
CHANGED