Skip to content

Commit f6fc1ed

Browse files
committed
V3.1.0 - Cache and server info on the client
1 parent 2494bf4 commit f6fc1ed

30 files changed

+735
-286
lines changed

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ module.exports = {
2525
"@typescript-eslint/ban-ts-comment": "off",
2626
"@typescript-eslint/no-explicit-any": "off",
2727
"no-console": "warn",
28+
"@typescript-eslint/no-unnecessary-type-constraint": "off",
2829
},
2930
};

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ Remix Development Tools is an open-source package designed to enhance your devel
2626
![route boundaries](./assets/boundaries.png)
2727
## What's new?
2828

29+
## v3.1.0
30+
31+
- Cache information on the client side -> shows you how long and where each loader is cached for
32+
- Server execution timings => shows you all execution timings, average, minimum and maximum execution time for each loader/action
33+
- Server headers => shows you all headers that are sent from the server via actions/loaders
34+
- List of all loaders/actions that are executed on the server and their responses
35+
- UI active page tab revamp and improvements
36+
2937
## v3.0.0
3038
Remix Development Tools v3.0.0 is here! This release brings a lot of new features and improvements to the Remix Development Tools. The most notable ones are:
3139
1. The setup is completely changed (Check the getting started section for more info)
@@ -80,7 +88,8 @@ Key features include:
8088
- **URL Parameters**: Easily view and analyze the URL parameters associated with the current page.
8189
- **Server Responses**: Inspect and review the server responses received by the application for the current page.
8290
- **Loader Data**: Monitor and track the loader data used by the application during page rendering.
83-
- **Outlet boundaries** Activate the **Show Route Boundaries** option to see each Outlet and route boundaries by coloring the background. It is locked behind a flag. You can enable it by passing `useRouteBoundaries` prop to `true` in the `RemixDevTools`,first parameter of `initClient` set to `true` and second parameter of `initServer` set to `true`. This feature is experimental and can cause issues in certain scenarios. It will be considered stable with v3.0 release but until then use at your own risk.
91+
- **Route boundaries** See each Outlet and route boundaries by coloring the background.
92+
- **Server info** - See each loader min/max/avg execution time, cache info, headers info and more!
8493

8594
### Routes Tab
8695

package-lock.json

+76-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "remix-development-tools",
3-
"description": "Remix development tools.",
3+
"description": "Remix development tools - a set of tools for developing/debugging Remix.run apps",
44
"author": "Alem Tuzlak",
5-
"version": "3.0.2",
5+
"version": "3.1.0",
66
"license": "MIT",
77
"keywords": [
88
"remix",
@@ -89,6 +89,7 @@
8989
"tsup:dev-server-cjs:watch": "tsup --config tsup-dev-server-cjs.ts --watch",
9090
"tsup:dev-server-esm:watch": "tsup --config tsup-dev-server-esm.ts --watch",
9191
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
92+
"lint:fix": "eslint src --ext ts,tsx --report-unused-disable-directives --fix",
9293
"prettier": "prettier --check .",
9394
"test": "vitest run --coverage",
9495
"prepare": "husky install",
@@ -171,6 +172,7 @@
171172
"d3-selection": "^3.0.0",
172173
"d3-shape": "^3.2.0",
173174
"d3-zoom": "^3.0.0",
175+
"date-fns": "^2.30.0",
174176
"lucide-react": "^0.263.1",
175177
"tailwind-merge": "^1.14.0",
176178
"uuid": "^9.0.1",
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import add from "date-fns/add";
2+
import { CacheControl } from "../../dev-server/parser.js";
3+
import { useCountdown } from "../hooks/useCountdown.js";
4+
import formatDistance from "date-fns/formatDistance";
5+
import { Tag } from "./Tag.js";
6+
7+
interface CacheInfoProps {
8+
cacheDate: Date;
9+
cacheControl: CacheControl;
10+
}
11+
12+
const CacheInfo = ({ cacheDate, cacheControl }: CacheInfoProps) => {
13+
const { maxAge, sMaxage, private: isPrivate } = cacheControl;
14+
15+
const age = !isPrivate && !maxAge ? sMaxage : maxAge;
16+
const targetDate = add(cacheDate, { seconds: age ? parseInt(age) : 0 });
17+
const { minutes, seconds, stringRepresentation } = useCountdown(targetDate);
18+
const distance = formatDistance(targetDate, cacheDate, { addSuffix: true });
19+
if (seconds <= 0) {
20+
return;
21+
}
22+
return (
23+
<Tag color={minutes < 1 ? "RED" : "PURPLE"}>
24+
[{cacheControl.private ? "Private" : "Shared"}] Loader Cache expires {distance} ({stringRepresentation})
25+
</Tag>
26+
);
27+
};
28+
29+
export { CacheInfo };
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import clsx from "clsx";
2+
import { ReactNode } from "react";
3+
4+
export const InfoCard = ({
5+
children,
6+
title,
7+
onClear,
8+
}: {
9+
children: ReactNode;
10+
title: string;
11+
onClear?: () => void;
12+
}) => {
13+
return (
14+
<div className="rdt-mb-4 rdt-h-min rdt-rounded-lg rdt-border rdt-border-solid rdt-border-gray-500/40 rdt-px-3 rdt-py-2 rdt-text-base rdt-font-normal rdt-text-white">
15+
<h6
16+
className={clsx(
17+
"rdt-text-left rdt-text-sm",
18+
onClear ? "rdt-flex rdt-items-center rdt-justify-between rdt-gap-3" : ""
19+
)}
20+
>
21+
{title}
22+
{onClear && (
23+
<button
24+
onClick={onClear}
25+
className="rdt-cursor-pointer rdt-rounded-lg rdt-bg-red-500 rdt-px-2 rdt-py-1 rdt-text-sm rdt-font-semibold rdt-text-white"
26+
>
27+
Clear
28+
</button>
29+
)}
30+
</h6>
31+
<hr className="-rdt-mx-3 rdt-my-1 rdt-border-gray-500/40" />
32+
{children}
33+
</div>
34+
);
35+
};

0 commit comments

Comments
 (0)