fimo-react-router 2.8.0-staging.4 → 2.8.0-staging.6

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.
@@ -6,7 +6,6 @@ import { useCallback, useEffect, useMemo } from 'react';
6
6
  import { ErrorBoundary } from 'react-error-boundary';
7
7
  import { useLocation, useNavigate, useRoutes } from 'react-router';
8
8
  import { AppResetScrollOnNavigate } from './AppResetScrollOnNavigate.js';
9
- import { OptionalTracking } from './OptionalTracking.js';
10
9
  const titleCase = (seg) => seg
11
10
  .replace(/[_-]+/g, ' ')
12
11
  .replace(/([a-z])([A-Z])/g, '$1 $2')
@@ -104,5 +103,5 @@ export function AppRoutesProvider({ appRoutes, children }) {
104
103
  window.removeEventListener('message', handleMessage);
105
104
  };
106
105
  }, [navigate, previewEnabled, sendRoutes, sendLocationChange]);
107
- return (_jsx(ErrorBoundary, { FallbackComponent: AppErrorBoundary, onError: onError, children: _jsx(DataSourcesProvider, { children: _jsx(ScreenshotProvider, { children: _jsx(ViteLifecycles, { children: _jsxs(RefreshContentProvider, { children: [_jsx(OptionalTracking, { routes: displayRoutes }), _jsx(AppResetScrollOnNavigate, {}), appRoutes?.length ? routing : children] }) }) }) }) }));
106
+ return (_jsx(ErrorBoundary, { FallbackComponent: AppErrorBoundary, onError: onError, children: _jsx(DataSourcesProvider, { children: _jsx(ScreenshotProvider, { children: _jsx(ViteLifecycles, { children: _jsxs(RefreshContentProvider, { children: [_jsx(AppResetScrollOnNavigate, {}), appRoutes?.length ? routing : children] }) }) }) }) }));
108
107
  }
@@ -11,7 +11,6 @@ import { UNSAFE_FrameworkContext, useLocation, useNavigate } from 'react-router'
11
11
  // @ts-ignore - virtual module provided by fimoConfigPlugin in fimo-vite
12
12
  import fimoConfig from 'virtual:fimo-config';
13
13
  import { getActiveRouterRoutes } from './active-routes.js';
14
- import { OptionalTracking } from './OptionalTracking.js';
15
14
  export { getPreviewLocationChange, getPreviewLocationPath } from 'fimo/preview';
16
15
  const titleCase = (seg) => seg
17
16
  .replace(/[_-]+/g, ' ')
@@ -159,7 +158,6 @@ export function FimoProviders({ children, locale }) {
159
158
  // of caching. A different framework runtime would swap this reader only.
160
159
  const frameworkContext = useContext(UNSAFE_FrameworkContext);
161
160
  const readRoutes = useCallback(() => getDisplayRoutes(frameworkContext?.manifest), [frameworkContext?.manifest]);
162
- const routes = readRoutes();
163
161
  const localeResolution = useMemo(() => resolveFimoLocale({ pathname: location.pathname }, fimoConfig), [location.pathname]);
164
162
  // The app is authoritative: an explicit `locale` wins over anything Fimo can
165
163
  // infer, and inference itself goes through the declared route contract.
@@ -184,5 +182,5 @@ export function FimoProviders({ children, locale }) {
184
182
  ...localeResolution,
185
183
  locale: activeLocale,
186
184
  dir: activeDir,
187
- }, children: _jsx(DataSourcesProvider, { children: _jsx(ScreenshotProvider, { children: _jsx(ViteLifecycles, { children: _jsxs(RefreshContentProvider, { children: [previewEnabled ? _jsx(PreviewBridge, { readRoutes: readRoutes, locale: activeLocale }) : null, _jsx(OptionalTracking, { routes: routes }), _jsx(Suspense, { children: children })] }) }) }) }) }) }) }));
185
+ }, children: _jsx(DataSourcesProvider, { children: _jsx(ScreenshotProvider, { children: _jsx(ViteLifecycles, { children: _jsxs(RefreshContentProvider, { children: [previewEnabled ? _jsx(PreviewBridge, { readRoutes: readRoutes, locale: activeLocale }) : null, _jsx(Suspense, { children: children })] }) }) }) }) }) }) }));
188
186
  }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ export type { DisplayRoute, FimoProvidersProps, ParamInfo } from './FimoProvider
10
10
  export type { FimoLocaleContextValue } from 'fimo-react';
11
11
  export type { FimoLocaleResolution } from 'fimo/i18n';
12
12
  export type { FimoLinkProps, FimoNavigationOptions } from './navigation.js';
13
- export { Pageview } from './Pageview.js';
14
13
  export * from './seo.js';
15
14
  export * from 'fimo/seo';
16
15
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -11,6 +11,5 @@ export { localizeFimoPath, resolveFimoLocale } from 'fimo/i18n';
11
11
  export { FimoLink, useFimoHref, useFimoNavigate } from './navigation.js';
12
12
  export { localizeFimoTo } from './navigation-utils.js';
13
13
  export { AppRoutesProvider } from './AppRoutesProvider.js';
14
- export { Pageview } from './Pageview.js';
15
14
  export * from './seo.js';
16
15
  export * from 'fimo/seo';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo-react-router",
3
- "version": "2.8.0-staging.4",
3
+ "version": "2.8.0-staging.6",
4
4
  "description": "Fimo runtime, routing and build integration for React Router projects. Pairs with the fimo package at the same version.",
5
5
  "files": [
6
6
  "dist/",
@@ -39,18 +39,17 @@
39
39
  "test:watch": "vitest"
40
40
  },
41
41
  "dependencies": {
42
- "fimo-analytics": "2.8.0-staging.4",
43
42
  "react-error-boundary": "^6.0.0"
44
43
  },
45
44
  "devDependencies": {
46
- "@fimo/tsconfig": "2.8.0-staging.4",
45
+ "@fimo/tsconfig": "2.8.0-staging.6",
47
46
  "@tanstack/react-query": "^5.80.6",
48
47
  "@types/node": "22.18.6",
49
48
  "@types/react": "19.2.14",
50
49
  "@types/react-dom": "19.2.3",
51
- "fimo": "2.8.0-staging.4",
52
- "fimo-react": "2.8.0-staging.4",
53
- "fimo-vite": "2.8.0-staging.4",
50
+ "fimo": "2.8.0-staging.6",
51
+ "fimo-react": "2.8.0-staging.6",
52
+ "fimo-vite": "2.8.0-staging.6",
54
53
  "react": "19.2.4",
55
54
  "react-dom": "19.2.4",
56
55
  "react-router": "7.18.2",
@@ -60,7 +59,7 @@
60
59
  },
61
60
  "peerDependencies": {
62
61
  "@tanstack/react-query": "^5.80.6",
63
- "fimo": "2.8.0-staging.4",
62
+ "fimo": "2.8.0-staging.6",
64
63
  "fimo-react": ">=2.0.1",
65
64
  "fimo-vite": ">=2.0.1",
66
65
  "react": "^18.2.0 || ^19.0.0",
@@ -1,13 +0,0 @@
1
- import type { Pageview } from './Pageview.js';
2
- type PageviewComponent = typeof Pageview;
3
- type PageviewModule = {
4
- Pageview: PageviewComponent;
5
- };
6
- type PageviewLoader = () => Promise<PageviewModule>;
7
- type DisplayRoute = Parameters<PageviewComponent>[0]['routes'][number];
8
- export declare function loadPageviewComponent(loadPageview?: PageviewLoader): Promise<typeof Pageview | null>;
9
- export declare function OptionalTracking({ routes }: {
10
- routes: DisplayRoute[];
11
- }): import("react/jsx-runtime").JSX.Element | null;
12
- export {};
13
- //# sourceMappingURL=OptionalTracking.d.ts.map
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
3
- const defaultLoadPageview = () => import('./Pageview.js');
4
- export async function loadPageviewComponent(loadPageview = defaultLoadPageview) {
5
- try {
6
- return (await loadPageview()).Pageview;
7
- }
8
- catch {
9
- return null;
10
- }
11
- }
12
- export function OptionalTracking({ routes }) {
13
- const [PageviewComponent, setPageviewComponent] = useState(null);
14
- useEffect(() => {
15
- let cancelled = false;
16
- loadPageviewComponent()
17
- .then((component) => {
18
- if (!cancelled) {
19
- setPageviewComponent(() => component);
20
- }
21
- })
22
- .catch(() => { });
23
- return () => {
24
- cancelled = true;
25
- };
26
- }, []);
27
- return PageviewComponent ? _jsx(PageviewComponent, { routes: routes }) : null;
28
- }
@@ -1,9 +0,0 @@
1
- type DisplayRoute = {
2
- path: string;
3
- name: string;
4
- };
5
- export declare function Pageview({ routes }: {
6
- routes: DisplayRoute[];
7
- }): import("react/jsx-runtime").JSX.Element;
8
- export {};
9
- //# sourceMappingURL=Pageview.d.ts.map
package/dist/Pageview.js DELETED
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Analytics } from 'fimo-analytics/react-router';
3
- import { useLocation } from 'react-router';
4
- const viteEnv = import.meta.env;
5
- const API_BASE_URL = viteEnv?.VITE_API_URL?.replace(/\/$/, '');
6
- const ENABLE_ANALYTICS = (viteEnv?.VITE_ENABLE_ANALYTICS ?? '').toLowerCase() === 'true';
7
- function normalizePath(path) {
8
- const trimmed = path.trim();
9
- if (!trimmed) {
10
- return '/';
11
- }
12
- if (trimmed === '/') {
13
- return '/';
14
- }
15
- return trimmed.replace(/\/+$/, '');
16
- }
17
- function findRouteName(pathname, routes) {
18
- const currentPath = normalizePath(pathname);
19
- const exactMatch = routes.find((route) => normalizePath(route.path) === currentPath);
20
- if (exactMatch) {
21
- return exactMatch.name;
22
- }
23
- const dynamicMatch = routes.find((route) => {
24
- const normalizedPattern = normalizePath(route.path);
25
- const regex = new RegExp(`^${normalizedPattern.replace(/:\w+/g, '[^/]+')}$`);
26
- return regex.test(currentPath);
27
- });
28
- if (dynamicMatch) {
29
- return dynamicMatch.name;
30
- }
31
- return null;
32
- }
33
- export function Pageview({ routes }) {
34
- const { pathname } = useLocation();
35
- return (_jsx(Analytics, { endpoint: API_BASE_URL ? `${API_BASE_URL}/e/p` : '', enabled: Boolean(API_BASE_URL) && ENABLE_ANALYTICS, pageName: findRouteName(pathname, routes) ?? normalizePath(pathname) }));
36
- }