@dexteel/mesf-core 7.14.0 → 7.15.1

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.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "7.14.0"
2
+ ".": "7.15.1"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [7.15.1](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.15.0...@dexteel/mesf-core-v7.15.1) (2026-03-04)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Poll for updates:** add snackbar to mesf-core-frontend ([#615](https://github.com/dexteel/mesf-core-frontend/issues/615)) ([1c9f355](https://github.com/dexteel/mesf-core-frontend/commit/1c9f355fa362140f3b644a8a2585e99b10317b96))
9
+
10
+ ## [7.15.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.14.0...@dexteel/mesf-core-v7.15.0) (2026-03-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * **version-check:** add frontend polling hook for update notifications ([feaf9ff](https://github.com/dexteel/mesf-core-frontend/commit/feaf9ff9cec2e0d167f9b256cbc8789d5b6c8dc5))
16
+
3
17
  ## [7.14.0](https://github.com/dexteel/mesf-core-frontend/compare/@dexteel/mesf-core-v7.13.3...@dexteel/mesf-core-v7.14.0) (2026-02-26)
4
18
 
5
19
 
@@ -14,6 +14,9 @@ interface Props {
14
14
  plantAssetId?: number;
15
15
  theme?: any;
16
16
  logbookSettings?: Partial<LogbookSettingsState>;
17
+ enableFrontendVersionCheck?: boolean;
18
+ frontendVersionCheckIntervalMs?: number;
19
+ frontendVersionEndpoint?: string;
17
20
  }
18
- declare function MESFMain({ authentication, routes, navbar, navbarTitle, configurations, showAreaSelector, showTrendingsV2Icon, byPassHeaderRoutes, plantAssetId, theme, logbookSettings, }: Props): React.JSX.Element;
21
+ declare function MESFMain({ authentication, routes, navbar, navbarTitle, configurations, showAreaSelector, showTrendingsV2Icon, byPassHeaderRoutes, plantAssetId, theme, logbookSettings, enableFrontendVersionCheck, frontendVersionCheckIntervalMs, frontendVersionEndpoint, }: Props): React.JSX.Element;
19
22
  export { MESFMain };
@@ -0,0 +1,17 @@
1
+ type FrontendVersionResponse = {
2
+ hash: string;
3
+ lastModifiedUtc?: string;
4
+ };
5
+ type UseFrontendVersionCheckOptions = {
6
+ endpoint?: string;
7
+ intervalMs?: number;
8
+ enabled?: boolean;
9
+ onUpdate?: (response: FrontendVersionResponse) => void;
10
+ };
11
+ type UseFrontendVersionCheckResult = {
12
+ isUpdateAvailable: boolean;
13
+ currentHash: string | null;
14
+ error: Error | null;
15
+ };
16
+ export declare const useFrontendVersionCheck: ({ endpoint, intervalMs, enabled, onUpdate, }?: UseFrontendVersionCheckOptions) => UseFrontendVersionCheckResult;
17
+ export {};
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export * from "./controls";
23
23
  export * from "./css/themeMESF";
24
24
  export { HelmetDexteel } from "./helmet/HelmetDexteel";
25
25
  export * from "./hooks/useMesfRealtime";
26
+ export * from "./hooks/useFrontendVersionCheck";
26
27
  export * from "./MESFMain";
27
28
  export { logbookNavbar, logbookRoutesMESF } from "./pages/logbook";
28
29
  export { sectionLogbookNavbar, sectionLogbookRoutesMESF, } from "./pages/section-logbook";
package/dist/index.esm.js CHANGED
@@ -9591,6 +9591,77 @@ const UTLSettingsProvider = ({ children }) => {
9591
9591
  return (React__default.createElement(UTLSettingsContext.Provider, { value: { state, actions, isLoading } }, children));
9592
9592
  };
9593
9593
 
9594
+ const useFrontendVersionCheck = ({ endpoint = "/frontend/version", intervalMs = 60000, enabled = true, onUpdate, } = {}) => {
9595
+ const [isUpdateAvailable, setIsUpdateAvailable] = useState(false);
9596
+ const [currentHash, setCurrentHash] = useState(null);
9597
+ const [error, setError] = useState(null);
9598
+ const initialHashRef = useRef(null);
9599
+ useEffect(() => {
9600
+ if (!enabled || isUpdateAvailable) {
9601
+ return;
9602
+ }
9603
+ let isDisposed = false;
9604
+ let intervalId = null;
9605
+ const loadVersion = () => __awaiter(void 0, void 0, void 0, function* () {
9606
+ try {
9607
+ const separator = endpoint.includes("?") ? "&" : "?";
9608
+ const response = yield fetch(`${endpoint}${separator}_t=${Date.now()}`, {
9609
+ cache: "no-store",
9610
+ });
9611
+ if (!response.ok) {
9612
+ throw new Error(`Version check failed with status ${response.status}`);
9613
+ }
9614
+ const payload = (yield response.json());
9615
+ if (!(payload === null || payload === void 0 ? void 0 : payload.hash)) {
9616
+ throw new Error("Version check response does not include a hash");
9617
+ }
9618
+ if (isDisposed) {
9619
+ return;
9620
+ }
9621
+ setError(null);
9622
+ setCurrentHash(payload.hash);
9623
+ if (!initialHashRef.current) {
9624
+ initialHashRef.current = payload.hash;
9625
+ return;
9626
+ }
9627
+ if (initialHashRef.current !== payload.hash) {
9628
+ setIsUpdateAvailable(true);
9629
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(payload);
9630
+ if (intervalId !== null) {
9631
+ window.clearInterval(intervalId);
9632
+ }
9633
+ }
9634
+ }
9635
+ catch (requestError) {
9636
+ if (isDisposed) {
9637
+ return;
9638
+ }
9639
+ if (requestError instanceof Error) {
9640
+ setError(requestError);
9641
+ }
9642
+ else {
9643
+ setError(new Error("Unexpected error while checking frontend version"));
9644
+ }
9645
+ }
9646
+ });
9647
+ void loadVersion();
9648
+ intervalId = window.setInterval(() => {
9649
+ void loadVersion();
9650
+ }, intervalMs);
9651
+ return () => {
9652
+ isDisposed = true;
9653
+ if (intervalId !== null) {
9654
+ window.clearInterval(intervalId);
9655
+ }
9656
+ };
9657
+ }, [enabled, endpoint, intervalMs, isUpdateAvailable, onUpdate]);
9658
+ return {
9659
+ isUpdateAvailable,
9660
+ currentHash,
9661
+ error,
9662
+ };
9663
+ };
9664
+
9594
9665
  const RouterContext = createContext(() => React__default.createElement(React__default.Fragment, null));
9595
9666
  const ConfigurationContext = createContext([
9596
9667
  [],
@@ -15387,7 +15458,14 @@ const queryClient = new QueryClient({
15387
15458
  },
15388
15459
  },
15389
15460
  });
15390
- function MESFMain({ authentication, routes, navbar, navbarTitle = "MESF", configurations, showAreaSelector = false, showTrendingsV2Icon = true, byPassHeaderRoutes = [], plantAssetId = 1, theme = themeMESF, logbookSettings = {}, }) {
15461
+ function MESFMain({ authentication, routes, navbar, navbarTitle = "MESF", configurations, showAreaSelector = false, showTrendingsV2Icon = true, byPassHeaderRoutes = [], plantAssetId = 1, theme = themeMESF, logbookSettings = {}, enableFrontendVersionCheck = true, frontendVersionCheckIntervalMs = 60000, frontendVersionEndpoint = "/frontend/version", }) {
15462
+ const [isVersionMessageDismissed, setIsVersionMessageDismissed] = useState(false);
15463
+ const { isUpdateAvailable } = useFrontendVersionCheck({
15464
+ enabled: enableFrontendVersionCheck,
15465
+ intervalMs: frontendVersionCheckIntervalMs,
15466
+ endpoint: frontendVersionEndpoint,
15467
+ });
15468
+ const showVersionAlert = isUpdateAvailable && !isVersionMessageDismissed;
15391
15469
  return (React__default.createElement(React__default.Fragment, null,
15392
15470
  React__default.createElement(CssBaseline, null),
15393
15471
  React__default.createElement(StyledEngineProvider, { injectFirst: true },
@@ -15410,7 +15488,14 @@ function MESFMain({ authentication, routes, navbar, navbarTitle = "MESF", config
15410
15488
  React__default.createElement(BrowserRouter, { basename: base },
15411
15489
  React__default.createElement(Routes, null,
15412
15490
  React__default.createElement(Route, { path: "/logout", element: React__default.createElement(Logout, null) })),
15413
- React__default.createElement(Navigation, { showAreaSelector: showAreaSelector, navbarTitle: navbarTitle, byPassHeaderRoutes: byPassHeaderRoutes, showTrendingsV2Icon: showTrendingsV2Icon })))))))))))))))))))));
15491
+ React__default.createElement(Navigation, { showAreaSelector: showAreaSelector, navbarTitle: navbarTitle, byPassHeaderRoutes: byPassHeaderRoutes, showTrendingsV2Icon: showTrendingsV2Icon }))))))))))))))))))),
15492
+ React__default.createElement(Snackbar, { open: showVersionAlert, onClose: (_, reason) => {
15493
+ if (reason === "clickaway") {
15494
+ return;
15495
+ }
15496
+ setIsVersionMessageDismissed(true);
15497
+ }, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
15498
+ React__default.createElement(Alert$1, { severity: "info", action: React__default.createElement(Button, { color: "inherit", size: "small", onClick: () => window.location.reload() }, "Reload") }, "There is a new version. Please reload the page."))));
15414
15499
  }
15415
15500
 
15416
15501
  const ExcelButton = ({ handleExportToExcel, disabled }) => {
@@ -20169,5 +20254,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
20169
20254
  AreaSelector: AreaSelector
20170
20255
  });
20171
20256
 
20172
- export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES$1 as ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry$1 as MESFLogbookEntry, MESFLogbookReport$1 as MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries$1 as getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry$1 as routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useEntries$1 as useEntries, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
20257
+ export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES$1 as ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry$1 as MESFLogbookEntry, MESFLogbookReport$1 as MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries$1 as getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry$1 as routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useEntries$1 as useEntries, useFrontendVersionCheck, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
20173
20258
  //# sourceMappingURL=index.esm.js.map