@okyrychenko-dev/react-action-guard-router 0.2.4 → 1.0.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,228 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ [Release history](https://github.com/okyrychenko-dev/react-action-guard/releases/tag/@okyrychenko-dev/react-action-guard-router@1.0.0)
6
+
7
+ ### Minor Changes
8
+
9
+ - b4945b0: Restore TanStack navigation blocking using native useBlocker. Confirmed transitions keep protection armed, failed confirmations deny navigation, and superseded or unmounted attempts cannot allow navigation. Require TanStack Router >=1.170.41 within v1, the verified compatibility floor, and use native unload protection with a one-shot bypass after accepted document navigation, avoiding a duplicate browser prompt.
10
+
11
+ Invalidate pending confirmations when when or scope changes, including replacements that leave the computed blocking state active.
12
+
13
+ Preserve pending confirmations when observer callbacks onBlock or onAllow change during a rerender.
14
+
15
+ Compare scopes by normalized contents so equivalent arrays, including reordered or duplicated entries, preserve pending confirmations while effective scope changes invalidate them.
16
+
17
+ Document and test the native not-found limitation at TanStack Router 1.170.41: unmatched-to-matched navigation skips adapter callbacks even with an active condition or scope; subsequent matched-route navigation remains guarded.
18
+
19
+ - bd1dc3b: Publish format-specific ESM and CommonJS declarations so NodeNext CommonJS consumers can use the supported public imports. Correct Core's legacy main/module paths and resolve Next's router.js entry so native Node ESM can load the Next adapter. Require React Router DOM >=6.19.0 within v6 or v7 because earlier v6 releases do not export the stable useBlocker API. This excludes previously declared unsupported versions and releases the pre-1.0 router package as a minor change. Consumers on older v6 must upgrade before adopting this release; no new runtime dependency is added. Publish evidence-labelled capabilities and packed peer/provider checks, and clarify App Router and application-owned payment cancellation limits.
20
+
21
+ ### Patch Changes
22
+
23
+ - 06df6f3: Use shared confirmation ownership in React Router so only the latest attached navigation attempt can proceed or notify permission. Invalidate pending answers when the evaluated protection state, scope, or message changes, while preserving them across callback rerenders and equivalent scopes.
24
+
25
+ Reset the current blocked transition and clear its pending confirmation when protection configuration changes, without resuming stale approvals or resetting superseding attempts.
26
+
27
+ Retain ownership of synchronous denials and silent blocking when they replace an async prompt, so later protection changes reset the current blocked transition rather than consulting the obsolete prompt.
28
+
29
+ - 0d3c1f7: Complete the Blocking lifecycle architecture migration. Remove mutable blocker and middleware maps,
30
+ named middleware registration, direct event dispatch, and compatibility restore contracts. Observe
31
+ lifecycle transitions through ownership-safe anonymous leases and read readonly BlockerInfo snapshots.
32
+ Devtools sessions release only their observations; manual observation is now additive on every store.
33
+ Centralize guarded-control state and accessible reasons while retaining public hooks, state mappers,
34
+ state utilities, and distinct link behavior. Consolidate shared TanStack coverage at its coordination
35
+ interface and document migration from removed interfaces. Retain react-zustand-toolkit as the state
36
+ management base.
37
+ - dd13e1b: Evaluate pure navigation predicates on every React render, including stable functions reading refs or external state. Remove misleading useCallback guidance: changing a ref alone still requires a React rerender to refresh protection. Preserve scope OR semantics and router-specific navigation and unload capabilities.
38
+ - 369b2c0: Prevent stale Pages Router confirmations from resuming navigation and notify permission once across async acceptance and route replay.
39
+ - 6d59289: Skip scheduled windows that have already elapsed when a delayed start timer runs, and retain long windows without overflowing their end timers. Share router protection scope keys, remove unused internal confirmation handling, and correct the documented public router types.
40
+ - 26cc31e: Align packaged README requirements with the Core ^2.0.0 release cohort and use durable repository URLs for migration, observability and Next runtime evidence. Declare the Query adapter's existing Node.js >=20 requirement inherited from type-utils. Reconcile superseded intermediate compatibility descriptions in pending release notes.
41
+
42
+ Include CHANGELOG.md in every package so the packaged README changelog links resolve. Generate versioned API references and advance changelog links as part of the Changesets version command.
43
+
44
+ - 691ea3e: Settle pending custom confirmation dialogs as false on effect teardown, including unmount and hiding a preserved React Activity subtree. Clear preserved dialog state so it cannot reappear after effects reconnect. Dialog-specific resolvers now close their own dialog exactly once and cannot affect a replacement dialog. Stable hook-level controls continue to act on the current dialog.
45
+ - 6230733: Adopt `@okyrychenko-dev/type-utils` 0.1.2 for internal type guards, assertions, and utility types, replacing equivalent hand-rolled checks, a duplicated `assertNever` helper, and inline nullable/optional unions. Runtime behavior is unchanged; some public function signatures now show the package's equivalent utility types. Adds `@okyrychenko-dev/type-utils` as a new dependency and explicitly requires Node.js 20 or newer; Node.js 18 is EOL and unsupported.
46
+ - Updated dependencies [6a08414]
47
+ - Updated dependencies [39fb3de]
48
+ - Updated dependencies [32264e4]
49
+ - Updated dependencies [5d403d8]
50
+ - Updated dependencies [3db526a]
51
+ - Updated dependencies [64145c9]
52
+ - Updated dependencies [0d3c1f7]
53
+ - Updated dependencies [083a5b7]
54
+ - Updated dependencies [690a3a9]
55
+ - Updated dependencies [a1b83db]
56
+ - Updated dependencies [d07b65a]
57
+ - Updated dependencies [bd1dc3b]
58
+ - Updated dependencies [6513e1e]
59
+ - Updated dependencies [6d59289]
60
+ - Updated dependencies [26cc31e]
61
+ - Updated dependencies [b987ed1]
62
+ - Updated dependencies [743c6f4]
63
+ - Updated dependencies [303abc3]
64
+ - Updated dependencies [eefba30]
65
+ - Updated dependencies [4363609]
66
+ - Updated dependencies [40e8420]
67
+ - Updated dependencies [6230733]
68
+ - @okyrychenko-dev/react-action-guard@2.0.0
69
+
70
+ All notable changes to this project will be documented in this file.
71
+
72
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
73
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
74
+
75
+ ## [Unreleased]
76
+
77
+ ## [0.2.4] - 2026-05-27
78
+
79
+ ### Changed
80
+
81
+ - Raised `@okyrychenko-dev/react-action-guard` compatibility to the `1.0.4` line.
82
+ - Updated the transitive toolkit override to `react-zustand-toolkit@^0.4.1`.
83
+
84
+ ## [0.2.3] - 2026-05-09
85
+
86
+ ### Changed
87
+
88
+ - Raised `@okyrychenko-dev/react-action-guard` compatibility to the `1.0.3` line.
89
+ - Prepared package metadata for the coordinated `react-action-guard` stability release.
90
+
91
+ ## [0.2.2] - 2026-04-18
92
+
93
+ ### Changed
94
+
95
+ - Raised `@okyrychenko-dev/react-action-guard` compatibility to the `1.0.2` line
96
+ - Updated the transitive toolkit override to `react-zustand-toolkit@^0.4.0`
97
+
98
+ ## [0.2.1] - 2026-03-08
99
+
100
+ ### Fixed
101
+
102
+ - Restored Storybook production build by switching internal Storybook component imports back to local relative paths
103
+
104
+ ## [0.2.0] - 2026-03-08
105
+
106
+ ### Changed
107
+
108
+ - Normalized `useNavigationBlocker` semantics across adapters so `isBlocking` consistently means the blocking condition is armed
109
+ - Added optional `isIntercepting` for adapters that can expose an active interception state directly
110
+ - Tightened the public confirmation API to the parts that are actually supported end-to-end
111
+ - Clarified README guidance around adapter capabilities, async confirmation behavior, and Next.js App Router limitations
112
+ - Aligned package scripts and Storybook component exports with the current package structure
113
+
114
+ ### Fixed
115
+
116
+ - Async `onConfirm` handlers are now evaluated once per blocked navigation attempt across adapters
117
+ - Storybook barrel exports and imports now match the reusable components and utilities shipped with the package
118
+
119
+ ## [0.1.0] - 2026-01-25
120
+
121
+ ### Added
122
+
123
+ - 🚀 Initial release of `@okyrychenko-dev/react-action-guard-router`
124
+ - **React Router v6+ Integration**
125
+ - `useNavigationBlocker` hook for blocking navigation
126
+ - `usePrompt` hook for simple confirmation dialogs
127
+ - Full support for React Router's `useBlocker` API
128
+ - Scope-based and condition-based blocking
129
+ - **TanStack Router Integration**
130
+ - `useNavigationBlocker` hook using TanStack Router's history blocking
131
+ - Support for modern TanStack Router applications
132
+ - Scope-based and condition-based blocking
133
+ - **Next.js Integration**
134
+ - Pages Router support with full navigation blocking (Next.js 9+)
135
+ - App Router support with documented limitations (Next.js 13.4+ for stable support)
136
+ - Separate exports for each router type
137
+ - **Core Utilities**
138
+ - `useBeforeUnload` hook for browser unload protection
139
+ - Utility functions for condition resolution and scope handling
140
+ - Shared types and interfaces
141
+ - **Features**
142
+ - Automatic integration with `react-action-guard` scope system
143
+ - **Custom Dialog Support** via `onConfirm` callback
144
+ - Support for both synchronous and asynchronous dialog handlers
145
+ - Race condition prevention in React Router adapter with sequence tracking
146
+ - Error logging for debugging Promise rejections
147
+ - **useDialogState Helper Hook**
148
+ - Simplifies custom dialog state management
149
+ - Generic type support for custom message data
150
+ - Promise-based confirmation flow
151
+ - Browser `beforeunload` event protection
152
+ - Customizable confirmation dialogs
153
+ - TypeScript-friendly API surface
154
+ - Tree-shakeable with subpath exports
155
+ - Callbacks for block/allow events
156
+ - Automatic cleanup on unmount
157
+
158
+ - 📚 **Comprehensive Storybook Documentation** (12 interactive stories):
159
+ - **React Router stories** (7 examples):
160
+ - `AsyncConfirm` - Asynchronous confirmation dialogs
161
+ - `CombinedSources` - Combining multiple blocking sources
162
+ - `CustomDialog` - Custom dialog implementations
163
+ - `PrioritizedBlockers` - Priority-based blocking scenarios
164
+ - `ScopeSync` - Multi-component scope synchronization
165
+ - `UsePrompt` - Simple prompt hook usage
166
+ - `WindowConfirm` - Browser native confirmation dialogs
167
+ - **Next.js stories** (2 examples):
168
+ - `NextAppRouterDemo` - App Router navigation blocking
169
+ - `NextPagesRouterDemo` - Pages Router navigation blocking
170
+ - **TanStack Router stories** (1 example):
171
+ - `TanStackRouterDemo` - TanStack Router navigation blocking
172
+ - **Core utilities story**:
173
+ - `BrowserUnload` - Browser unload protection demo
174
+ - **Introduction story** with package overview
175
+
176
+ - 🧩 **Storybook Components Library** (14 reusable components):
177
+ - `ActionButtons` - Standardized action button layouts
178
+ - `BlockerItem` - Blocker information display with utilities
179
+ - `CodeBlock` - Syntax-highlighted code examples
180
+ - `ConfirmDialog` - Customizable confirmation dialog with CSS
181
+ - `DebugPanel` - Real-time blocker state visualization with CSS
182
+ - `FormField` - Form input components
183
+ - `InfoBox` - Information callouts
184
+ - `MockRouterProvider` - React Router test provider
185
+ - `MockTanStackRouterProvider` - TanStack Router test provider
186
+ - `NavigationSimulator` - Navigation interaction simulator with CSS
187
+ - `StatusDisplay` - Blocking status indicator
188
+ - `StoryContainer` - Story wrapper layout
189
+ - `ScopeSync` - Scope coordination styles (CSS)
190
+ - Shared CSS styles for consistent presentation
191
+
192
+ ### Documentation
193
+
194
+ - 📖 Comprehensive README with examples for all router types
195
+ - 💻 JSDoc comments for all public APIs
196
+ - 📚 Usage examples for common scenarios
197
+ - 🎨 Custom dialog integration examples (Material-UI, Radix UI)
198
+ - 🗺️ Migration guide for different routers
199
+ - 📘 Interactive Storybook documentation with live examples
200
+
201
+ ### Testing
202
+
203
+ - ✅ Full test coverage with vitest
204
+ - 🧪 Added `handleConfirmation` utility tests
205
+ - 🔬 Enhanced core utility function tests
206
+ - 🛠️ Test helpers for all router types
207
+
208
+ ### Development
209
+
210
+ - 📦 Storybook integration with development scripts (`storybook`, `build-storybook`)
211
+ - 🔧 ESLint configuration with `curly: ["error", "all"]` rule
212
+ - 🧰 Dev dependencies: Storybook packages, `clsx`, `remark-gfm`
213
+
214
+ ### Requirements
215
+
216
+ - **Peer Dependencies**:
217
+ - `@okyrychenko-dev/react-action-guard` ^1.0.4
218
+ - `react` ^18.0.0 || ^19.0.0
219
+ - One of: `react-router-dom` ^6.0.0, `@tanstack/react-router` ^1.0.0, or `next` ^13.4.0
220
+
221
+ [Unreleased]: https://github.com/okyrychenko-dev/react-action-guard/compare/@okyrychenko-dev/react-action-guard-router@1.0.0...HEAD
222
+ [0.2.4]: https://github.com/okyrychenko-dev/react-action-guard-router/compare/v0.2.3...v0.2.4
223
+ [0.2.3]: https://github.com/okyrychenko-dev/react-action-guard-router/compare/v0.2.2...v0.2.3
224
+ [0.2.2]: https://github.com/okyrychenko-dev/react-action-guard-router/compare/v0.2.1...v0.2.2
225
+ [0.2.1]: https://github.com/okyrychenko-dev/react-action-guard-router/releases/tag/v0.2.1
226
+ [0.2.0]: https://github.com/okyrychenko-dev/react-action-guard-router/releases/tag/v0.2.0
227
+ [0.1.0]: https://github.com/okyrychenko-dev/react-action-guard-router/releases/tag/v0.1.0
228
+ [1.0.0]: https://github.com/okyrychenko-dev/react-action-guard/releases/tag/@okyrychenko-dev/react-action-guard-router@1.0.0