Skip to content

Commit ed31baa

Browse files
committed
feat: Implement enhanced storage management with error handling and validation
- Added EnhancedStorageManager for improved storage operations with validation and error handling. - Introduced TabManager for managing tab-specific storage instances. - Implemented batch updates, query and mutation updates with deserialization. - Added subscription management for storage changes. feat: Create error recovery system with exponential backoff and circuit breaker - Developed ErrorRecovery class for retrying operations with configurable backoff strategies. - Added support for circuit breaker pattern to prevent repeated failures. - Included statistics tracking for operations and retries. feat: Implement message batching system for performance optimization - Created MessageBatcher class to handle batching of messages for efficient processing. - Added configuration options for batch size, interval, and frame rate limiting. feat: Develop type-safe message router for handling various message types - Introduced TypeSafeMessageRouter for routing messages to appropriate handlers based on type. - Implemented PostMessageRouter and ChromeRuntimeRouter for specific message handling contexts. feat: Enhance message validation system with runtime type checking - Utilized Zod for schema validation of various message types. - Implemented validation functions for different message formats. feat: Create serialization manager for complex data structures - Developed SerializationManager for safe serialization and deserialization of data. - Added MessageSerializer and StorageSerializer for handling message and storage data. feat: Implement data validation utilities for deserialized data - Created DataValidator for ensuring data integrity after deserialization.
1 parent e9b3a80 commit ed31baa

29 files changed

Lines changed: 3433 additions & 939 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ dist
1212
dist-ssr
1313
*.local
1414

15+
tsconfig.tsbuildinfo
16+
1517
# Editor directories and files
1618
.vscode/*
1719
!.vscode/extensions.json

memory-bank

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tanstack-query-chrome-devtools",
33
"private": true,
4-
"version": "0.10.0",
4+
"version": "0.11.0",
55
"type": "module",
66
"description": "TanStack Query DevTools",
77
"homepage": "https://github.com/DeeCode-inc/tanstack-query-chrome-devtools#readme",
@@ -17,7 +17,7 @@
1717
},
1818
"scripts": {
1919
"dev": "vite",
20-
"build": "vite build --mode main && vite build --mode content",
20+
"build": "tsc -b && vite build --mode main && vite build --mode content",
2121
"lint": "eslint .",
2222
"preview": "vite preview",
2323
"prettier:format": "prettier --write .",

src/background/background.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ chrome.runtime.onMessage.addListener(
3636

3737
// Handle action results from content scripts - update artificial states in storage
3838
if (message.type === "QUERY_ACTION_RESULT") {
39-
// Update artificial states in storage for TRIGGER_LOADING and TRIGGER_ERROR
39+
// Update artificial states in storage for all artificial state actions
4040
if (
4141
message.success &&
4242
(message.action === "TRIGGER_LOADING" ||
43-
message.action === "TRIGGER_ERROR") &&
43+
message.action === "TRIGGER_ERROR" ||
44+
message.action === "CANCEL_LOADING" ||
45+
message.action === "CANCEL_ERROR") &&
4446
message.queryHash
4547
) {
4648
(async () => {
@@ -54,21 +56,17 @@ chrome.runtime.onMessage.addListener(
5456
const artificialStates = { ...currentData.artificialStates };
5557

5658
if (message.action === "TRIGGER_LOADING") {
57-
if (artificialStates[queryHash] === "loading") {
58-
// Cancel loading state
59-
delete artificialStates[queryHash];
60-
} else {
61-
// Start loading state
62-
artificialStates[queryHash] = "loading";
63-
}
59+
// Start loading state
60+
artificialStates[queryHash] = "loading";
61+
} else if (message.action === "CANCEL_LOADING") {
62+
// Cancel loading state
63+
delete artificialStates[queryHash];
6464
} else if (message.action === "TRIGGER_ERROR") {
65-
if (artificialStates[queryHash] === "error") {
66-
// Cancel error state
67-
delete artificialStates[queryHash];
68-
} else {
69-
// Start error state
70-
artificialStates[queryHash] = "error";
71-
}
65+
// Start error state
66+
artificialStates[queryHash] = "error";
67+
} else if (message.action === "CANCEL_ERROR") {
68+
// Cancel error state
69+
delete artificialStates[queryHash];
7270
}
7371

7472
// Update storage with new artificial states

src/components/query/QueryActions.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ export function QueryActions({
3333
artificialStates.get(selectedQuery.queryHash) === "error";
3434

3535
// Disable all buttons when any action is loading or when artificial loading is active
36-
const shouldDisableButtons = actionLoading !== null || isArtificialLoading;
36+
const shouldDisableButtons =
37+
actionLoading !== null || isArtificialLoading || isArtificialError;
3738

3839
return (
3940
<div className="p-4 border-b border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800">
@@ -74,21 +75,30 @@ export function QueryActions({
7475
</button>
7576

7677
<button
77-
onClick={() => handleAction("TRIGGER_LOADING")}
78+
onClick={() =>
79+
handleAction(
80+
isArtificialLoading ? "CANCEL_LOADING" : "TRIGGER_LOADING",
81+
)
82+
}
83+
disabled={isArtificialError}
7884
className={buttonVariants({
7985
variant: isArtificialLoading ? "gray" : "green",
8086
})}
8187
>
8288
{actionLoading === "TRIGGER_LOADING"
8389
? "Triggering..."
84-
: isArtificialLoading
85-
? "Cancel Loading"
86-
: "Trigger Loading"}
90+
: actionLoading === "CANCEL_LOADING"
91+
? "Canceling..."
92+
: isArtificialLoading
93+
? "Cancel Loading"
94+
: "Trigger Loading"}
8795
</button>
8896

8997
<button
90-
onClick={() => handleAction("TRIGGER_ERROR")}
91-
disabled={shouldDisableButtons}
98+
onClick={() =>
99+
handleAction(isArtificialError ? "CANCEL_ERROR" : "TRIGGER_ERROR")
100+
}
101+
disabled={isArtificialLoading}
92102
className={buttonVariants({
93103
variant: isArtificialError ? "gray" : "red",
94104
})}

0 commit comments

Comments
 (0)