react-modal-navigation 1.1.10 → 1.2.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/dist/style.css CHANGED
@@ -117,3 +117,14 @@
117
117
  .pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}
118
118
  .pmn-dialog.pmn-has-custom-background > :not(.pmn-custom-background-layer){position:relative;z-index:1}
119
119
  .pmn-dialog.pmn-has-custom-background .pmn-main > .pmn-body{background:transparent}
120
+ .pmn-overlay.pmn-fullscreen{padding:0!important;align-items:stretch;justify-content:stretch}
121
+ .pmn-overlay.pmn-fullscreen .pmn-dialog{width:100%;max-width:100%;height:100%;max-height:100%;border-radius:0!important}
122
+ .pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:100%;max-height:100%}
123
+ .pmn-place-center .pmn-dialog{max-height:100%}
124
+ .pmn-dialog{max-width:min(100%,var(--pmn-drag-width,var(--pmn-max-width,var(--pmn-width))));max-height:min(100%,var(--pmn-max-height,100dvh))}
125
+ .pmn-dialog .pmn-resize-handle{position:absolute;z-index:5;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none;user-select:none}
126
+ .pmn-resize-left{right:0}.pmn-resize-right{left:0}
127
+ .pmn-resize-handle:hover,.pmn-resize-handle:focus-visible{background:var(--pmn-border)}
128
+ @media(max-width:640px){.pmn-mobile-fullscreen .pmn-resize-handle{display:none}}
129
+ .pmn-dialog{max-width:min(100%,var(--pmn-max-width,100%),var(--pmn-drag-width,var(--pmn-width)))}
130
+ .pmn-overlay.pmn-fullscreen .pmn-dialog{max-width:100%}
@@ -0,0 +1,5 @@
1
+ # Architecture refactor (1.1.11)
2
+
3
+ Provider now owns a stable manager, with separate host and status snapshots. Manager owns registry resolution, queue, guards, lifecycle and instance-bound callbacks. ModalHost selects the existing single/stack navigator. Legacy useModal retains reactive status; command-only consumers should use useModalCommands. Layout updates no longer update Provider state, but still update host/navigator options. Full per-instance Layout/Navigation/Header/Footer runtime migration and button-level isolation are not completed. Selector snapshots are cached per selector identity; use stable selectors and equality functions for best results. SSR hydration and real React/browser profiling remain unverified.
4
+
5
+ Validation: npm test: 82 passed, 1 skipped (83 total); typecheck command passed with skipLibCheck. Vite and Vitest unavailable; production build and React integration tests not run.
@@ -0,0 +1,8 @@
1
+ # Async race hardening
2
+
3
+ - Bind registry cancellation to the exact job; clear pending before abort dispatch, which may synchronously start another job.
4
+ - Register the active job before publishing loading; release a token returned after synchronous cancellation.
5
+ - Reject reentrant task registration for a route during its synchronous cancellation sweep. This is not a permanent route tombstone.
6
+ - Register navigateAsync result requests during navigation commit, before React dispatch, rather than after awaiting navigation.
7
+ - Cancellation remains cooperative; a non-settling underlying promise can remain pending.
8
+ - React integration and production build require installed development dependencies.
@@ -0,0 +1,9 @@
1
+ # Batch preload and explicit cache eviction
2
+
3
+ `await modal.preload('demo', ['List', 'Detail'])` validates screen names before invoking loaders and shares the existing loader Promise cache. This loads modules, not mounted React pages. Existing single-screen preload remains compatible.
4
+
5
+ `await navigation.clearCache('Detail')` or `await instance.clearCache()` excludes inactive matching routes from mounted cache until they become active again. The navigation stack, route params and pending navigation results are retained. React local state is discarded on unmount. Existing dirty and removal guards are consulted before eviction; task cancellation is scoped to matching inactive routes. Single-page mode returns false. Cache limits remain stack-recency based, not a general LRU. The operation is not a guarantee that React has committed unmount by the time the Promise resolves.
6
+
7
+ Aggregate instance snapshots retain outer reference identity until a store changes. Snapshots are shallow-frozen; nested store data must be treated as read-only. Cross-store notifications are not atomic. Async event and selected-state listener rejections are logged, not awaited.
8
+
9
+ React integration and production build require installed development dependencies.
@@ -0,0 +1,11 @@
1
+ # Controlled Modal (experimental)
2
+
3
+ `Modal` requires `ModalProvider` and uses the existing single-screen runtime.
4
+
5
+ ```jsx
6
+ <Modal open={visible} onOpenChange={setVisible} title="Settings" animation={false}>
7
+ <Settings />
8
+ </Modal>
9
+ ```
10
+
11
+ Opening follows the existing manager replacement policy. A rejected open or close calls `onBlocked(action)`; retry by toggling `open` (for close, true then false). An internal close or replacement calls `onOpenChange(false, result)`; the owner must update its state. A true value is an opening request per rising edge, not an automatic reopen loop. Unmount attempts a guarded close; if vetoed or busy, the instance can remain visible until explicitly closed or the provider unmounts. Keep the owner mounted while using guarded forms. Options are patches: removing a prop does not reset an earlier override. Do not use multiple simultaneously open declarative modals with this single-instance manager. The component does not preserve arbitrary context below the provider across the host boundary. React integration and StrictMode validation are required before production use.
@@ -0,0 +1,7 @@
1
+ # Declarative lifecycle hardening
2
+
3
+ The controller serializes open/close requests and tracks changes to the requested open state. A rejected request is not retried until the open intent changes. If a close is already committed, a newer open request creates a fresh instance. Normal closes retain guards. Owner unmount forcibly disposes its own instance (no close guards, animation or onClose/onClosed callbacks); the result and manager close event use reason `unmount`. Keep the owner mounted when unsaved data must be protected. Disposal can invalidate a concurrent replacement transition; callers must handle blocked opens.
4
+
5
+ `instance.replaceOptions(options)` replaces overrides and clears runtime layout overrides, restoring provider/definition defaults. It may reset imperative layout changes. `instance.dispose()` is explicit forced teardown, not a normal close. Both return false for stale handles. Updates rejected while manager is busy are retried on a subsequent owner render, not automatically. Options use shallow comparison; use immutable values. Host context boundary remains unchanged.
6
+
7
+ Node tests exercise the controller with the real manager and simulated navigation registration; React/StrictMode and build remain unverified until dev dependencies are installed.
@@ -0,0 +1,7 @@
1
+ # 1.2.0 development candidate — first increment
2
+
3
+ Based on 1.1.11 keepalive-test-fix. Adds opt-in typed named modal contracts, typed route parameters, push/pop/popTo/popToTop and cooperative useModalTask cancellation. Legacy untyped calls remain available. Typed modal contracts currently support positional named calls only; they do not validate registry definitions at runtime. navigate retains first-match deduplication; popTo selects the nearest matching route. pop removes pages with status removed; goBack retains returned semantics. Single-page navigation operations return false.
4
+
5
+ Task cancel aborts the signal, releases its own loading token, and prevents late callbacks; the task promise settles only when underlying work settles. Existing zero-argument tasks still work. Cancellation adds a cancelled result variant, so exhaustive consumers need to handle it.
6
+
7
+ Pending: typed page results, typed object modal calls, lifecycle API, instance API, form guard, cache policy, declarative modal, debugging. React integration/build not verified in this environment. Do not publish before local acceptance.
@@ -0,0 +1,5 @@
1
+ # Optional DevTools
2
+
3
+ Render `<ModalDevTools enabled={import.meta.env.DEV} limit={100} />` inside ModalProvider. No inspector subscriptions are installed when disabled. Alternatively use `modal.inspect({ limit: 100 })` and call `dispose()` when finished. The provider also disposes inspectors on teardown.
4
+
5
+ The inspector records metadata only: modal and route names, keys, counts, event names, sequence and timestamp. Do not encode secrets in names. History is bounded to 1–1000 entries. Task counts are sampled on events or explicit refresh, not independently reactive. History starts when attached; no replay. The panel is inline, not a portal. No raw Store snapshots, params or results are retained. React integration and production build still require validation.
@@ -0,0 +1,7 @@
1
+ # Instance events and state
2
+
3
+ `instance.on(type, listener)` returns an unsubscribe function; `off(type, listener)` also removes it. Events: `ready` (first renderer registration), `change` (individual store publication), `destroy` (runtime cleanup completed). Events are synchronous, not replayed. Use `instance.ready` for readiness even if the event already occurred, and `instance.result` for the close outcome. Observer errors are logged. Do not mutate snapshots or perform reentrant lifecycle operations in observers.
4
+
5
+ `getSnapshot()` returns the six store snapshots, or null for inactive instances. The outer object is newly allocated; it is not a React useSyncExternalStore snapshot. `subscribeState(selector, listener, equal = Object.is)` observes selected values across stores without React subscriptions. It does not invoke the listener initially. Use a primitive or stable reference selector, or supply equality for derived objects. Updates are per store, not atomic across stores. Existing getState/subscribe remain navigation-only. All subscriptions are cleared on destruction.
6
+
7
+ Global events, logical route lifecycle events, declarative Modal and advanced cache management remain pending.
@@ -0,0 +1,10 @@
1
+ # 1.1.11 remaining optimization
2
+
3
+ - Container selects only consumed layout fields, preserving screen and runtime overrides and responsive precedence.
4
+ - Fullscreen control subscribes independently of the header title.
5
+ - Inactive cached layers no longer receive unrelated page motion objects.
6
+ - `useModal({ subscribe: false })` provides command-only access; the default remains reactive. Use field-specific hooks for state.
7
+ - Restore `useModal().navigation.navigateAsync`; commit the already-calculated stack to preserve route keys for async page requests.
8
+ - Ignore old-instance errors and stale single-screen writes; prevent pending action updates after unmount and synchronous default-footer reentry.
9
+
10
+ Validation: npm test 86 passed, 1 skipped, 0 failed; typecheck command passed (skipLibCheck). Vite and Vitest unavailable; offline npm installation failed (ENOTCACHED). React integration, browser profiler, StrictMode, SSR, memory and production build are not verified. KeepAlive consumers of legacy reactive navigation/loading still update when subscribed values change. Responsive fullscreen control reflects base store rather than viewport-resolved configuration, as before. No runtime dependencies added.
@@ -0,0 +1,7 @@
1
+ # Manager events
2
+
3
+ Use `modal.on(type, listener)` or `modal.off(type, listener)` via `useModalCommands()`.
4
+ `open` means the manager has accepted a new instance, not that its renderer is ready.
5
+ `close` includes confirmed, dismissed and replaced results; vetoes and duplicate reuse do not emit lifecycle events. Provider teardown clears listeners without emitting close. `queueChange` reports waiting queue length, excluding in-flight entries.
6
+ Listeners are synchronous notifications, not guards. Async failures are logged. Operations initiated during a transition can be blocked; await the original operation before issuing another. Subscribe in an effect and return the unsubscribe function.
7
+ Controlled declarative Modal remains pending React integration validation.
@@ -0,0 +1,2 @@
1
+ # RC-1 hardening
2
+ Runtime store event batches are delivered in publication order even when a listener publishes another snapshot. This does not make stores transactional or guarantee per-command React events. Observers must not create unbounded publication loops. Removed asynchronous guards are skipped before invocation; already running guards cannot be cancelled. Registry lookups require own properties. Declarative async error callbacks have rejection handling. No new public API. Node tests: 116 passed, 1 skipped; typecheck with skipLibCheck passed. React tests and build blocked by missing Vitest and Vite. Not a release certification.
@@ -0,0 +1,3 @@
1
+ # RC-2 integration preparation
2
+
3
+ Feature freeze remains in effect. Manager now skips unregistered dirty guards and rejects inherited initial screen names. Added late-open owner teardown regression and React StrictMode owner/DevTools integration cases. Run `npm install`, `npm test`, `npm run test:react`, `npm run typecheck:consumer`, `npm run build` locally. Node tests: 117 passed, 1 skipped. Declaration check with skipLibCheck passed. Offline dependency installation failed (ENOTCACHED); React tests, strict consumer check and build are blocked by missing dependencies. No release certification or publication.
@@ -0,0 +1,9 @@
1
+ # RC-3: subscription efficiency
2
+
3
+ `instance.subscribeState(selector, listener, equal?, dependencies?)` optionally subscribes only to named runtime stores. Omit dependencies for the existing all-store behavior. Include every store read by the selector; an empty array subscribes to none. Duplicate names are deduplicated and unknown names rejected. Selectors still receive the complete snapshot.
4
+
5
+ ```js
6
+ const off = instance.subscribeState(s => s.loading.visible, console.log, Object.is, ['loading']);
7
+ ```
8
+
9
+ Route events skip Set allocations when ordered route keys and focused key are unchanged. The Node regression test publishes 10,000 unrelated toast snapshots: broad selector runs 10,001 times including initialization, narrow selector once. This is an execution count, not browser timing or heap evidence. React integration, production build and heap profiling remain pending.
@@ -0,0 +1,7 @@
1
+ # RC-3B resource hardening
2
+
3
+ Instance commands resolve the active runtime by ID rather than capturing the old runtime directly. Destroy clears store payloads and the cached aggregate snapshot without notifying destroyed subscribers. Previously exported snapshots, result promises, caller closures and manager references remain caller-owned; this is not a GC guarantee.
4
+
5
+ Committed inactive cache evictions remain excluded until the route becomes active again or is removed. Increasing the cache limit does not remount previously evicted inactive pages. This is not LRU. Automatic eviction does not run asynchronous removal guards. React integration remains unverified.
6
+
7
+ Node: 122 tests, 121 passed, 1 skipped. Typecheck with skipLibCheck passed. Vitest and Vite unavailable; browser profiling and heap verification pending.
@@ -0,0 +1,2 @@
1
+ # RC-3C
2
+ Dirty registered guards protect background routes from automatic eviction, even with keepAlive=false or a zero cache limit. Explicit clearCache still runs guards and explicit exclusions win. Protection is evaluated on navigator renders, not independently reactive; React integration is pending. Loading snapshot tracks latest token and scans only when it disappears; repeated latest-token deletion remains linear. Inspector skips unchanged refreshes but retains all recorded events within its limit. Node: 124 passed, 1 skipped; typecheck passed with skipLibCheck. React and build blocked by missing Vitest/Vite. No release performed.
@@ -0,0 +1,7 @@
1
+ # Resource isolation
2
+
3
+ - Task cancellation failures no longer interrupt runtime cleanup.
4
+ - Store and event listeners removed during dispatch are skipped; sync and async failures are logged independently.
5
+ - Explicit cache clearing targets eligible mounted background routes only, and removes their focus history.
6
+ - Removed routes release stored result events.
7
+ - No new public API or runtime dependencies. React integration and build still require local dependencies. Declarative Modal remains deferred.
@@ -0,0 +1,3 @@
1
+ # Route events
2
+
3
+ Subscribe with `instance.on('routeChange', listener)` and unsubscribe with the returned function. Events describe differences between published navigation snapshots, not React mount/unmount or individual commands. Batched commands can coalesce; no action name is inferred. Initial route, parameter/options changes, cache eviction and modal destruction do not emit route transitions. Use ready, change and destroy for those lifecycle concerns. Event order: change, routeChange, routeRemove (if any), routeBlur, routeFocus. Route identity is key, not name. Treat payloads as read-only. Listeners are synchronous notifications with asynchronous rejection isolation; do not initiate reentrant navigation in them. React integration and production build require local dependencies.
@@ -0,0 +1,5 @@
1
+ # Instance runtime migration
2
+
3
+ Manager creates and disposes one runtime per active modal. Both navigators consume its six stores. Layout updates publish to the runtime without notifying Host; the navigators still subscribe to the full layout snapshot. Route reducer, UI effects, and navigation commands remain in the renderers. Runtime owns loading tokens and pending page requests; toast timer cleanup is registered with runtime. Store destruction rejects subsequent publications. This is not a claim of complete component-level isolation or browser performance validation.
4
+
5
+ Validation: Node tests and existing declaration check run locally; Vite and Vitest unavailable in the execution environment. Run npm install, npm run test:react, npm run build before publishing.
@@ -0,0 +1,9 @@
1
+ # 1.2.0 stage 2
2
+
3
+ `useModalLifecycle` exposes React mount/unmount and focus/blur effects, plus logical removal guards for mounted pages. StrictMode can replay effects. Evicted pages unregister guards; this is not a persistent logical-route lifecycle. Guards run on navigation, close and replacement. Multiple lifecycle guards can coexist.
4
+
5
+ `openInstance` adds navigation snapshot `getState`, navigation-only `subscribe`, `navigate`, `setParams`, `setLoading`. Commands require a mounted renderer and active instance; before readiness they return false. Subscribe does not emit a final close event; await `result` for closure.
6
+
7
+ `useModalTask` registers jobs in runtime by route key. Removing a route or destroying runtime aborts jobs; blur alone does not. Cancellation remains cooperative; a task ignoring AbortSignal can delay its returned promise. Existing per-hook concurrency policy remains. No global event bus yet.
8
+
9
+ Node tests: 95 pass, 1 skip. Type declaration check passes with skipLibCheck. React integration and Vite build blocked by missing tools. No browser performance claims.
@@ -0,0 +1,9 @@
1
+ # Stability validation (1.1.11)
2
+
3
+ Changes: iterative reuse result settlement; generation and instance guards for stale lifecycle errors; skip zero-duration transition timers.
4
+
5
+ Actual Node baseline: 86 passed, 1 skipped (87 total). After changes: 91 passed, 1 skipped (92 total). Includes 1000 Manager open/close cycles checking all six store subscriptions and 10000 reuse results. These are not browser heap or render measurements.
6
+
7
+ `npm run typecheck` succeeded using existing skipLibCheck configuration. Offline dependency installation failed (ENOTCACHED); Vite and Vitest unavailable. React StrictMode integration test added but not executed. SSR, browser heap, responsive/drag/animation combinations and actualDuration remain unverified.
8
+
9
+ Before publishing: npm install; npm test; npm run typecheck; npm run test:react; npm run build; npm run pack:check. Do not treat source-level tests as browser performance certification.
@@ -0,0 +1,7 @@
1
+ # Stage 3 (initial)
2
+
3
+ `await instance.ready` returns true when navigation commands first register and the instance is still active, or false if destroyed before registration. It does not wait for lazy screen content or animations. Always check the result and avoid waiting inside a React effect that blocks mounting.
4
+
5
+ `useModalFormGuard({values, initialValues, equals, message, onBeforeDiscard})` uses immutable snapshots and Object.is by default; provide a structural comparator for object forms. `markSaved(savedValues)` updates the baseline. It does not reset form values. Initial values are captured once per mount. Existing dirty guards now coexist per route. Guards still unregister when their component unmounts.
6
+
7
+ Existing `modal.preload(name, screen)` and `maxCachedScreens` are retained. Events, declarative Modal and expanded cache policies are not implemented in this increment.
@@ -0,0 +1,7 @@
1
+ # Component and field subscriptions
2
+
3
+ Layout changes now bypass Host and Navigator for width/height and fullscreen. RuntimeContainer reads the layout snapshot and preserves screen/runtime precedence; RuntimeHeader and footer regions select only relevant fields. Navigator retains page animation, lifecycle and cache options. Header fullscreen still updates the header region. Custom footer actions have local pending state; legacy done/cancel retain shared locking. Existing global loading overlay behavior is preserved.
4
+
5
+ `useModalLayout(selector?, equal?)` reads instance base options, not responsive or screen-resolved geometry. `useModalNavigationState` and `useModalLoadingState` now accept selectors and equality; `useModalLoading` selects visible only. `shallowEqual` is for flat records. Legacy `useModal()` retains broad reactive subscriptions. KeepAlive route context and navigation reducer are unchanged.
6
+
7
+ Validation: Node tests and declaration command executed; React integration and production build require missing Vitest/Vite dependencies. No browser performance measurements claimed.
@@ -0,0 +1,18 @@
1
+ # 1.1.11 source upgrade
2
+
3
+ Existing named registration and numeric asynchronous open IDs are preserved. The provider still manages one active modal plus a queue, not simultaneous windows.
4
+
5
+ ```jsx
6
+ import { defineModal, lazyModal, useModal, useModalHeader, useModalFullscreen } from 'react-modal-navigation';
7
+ const Create = defineModal({ loader: () => import('./Create.jsx'), title: ({route}) => route.params?.title, modalOptions: { width: 460, fullscreenable: true } });
8
+ // Within a component:
9
+ const { modal } = useModal();
10
+ await modal.preload(Create);
11
+ await modal.open(Create, { title: 'Create' });
12
+ modal.setOptions({ width: 720 });
13
+ modal.toggleFullscreen();
14
+ ```
15
+
16
+ Inline definitions work with open/openAsync/enqueue/enqueueAsync. A registry may contain `settings: lazyModal(() => import('./settings/index.js'))`. Explicit loader functions must resolve to a default component export. Preload caches successful promises by loader identity and evicts rejected promises; existing React.lazy components have no public preload interface. `useModalHeader({ actions: [{key:'refresh', tooltip:'Refresh', icon: ..., onClick: refresh}] })` adds actions without replacing built-in close/back. Fullscreen uses viewport CSS, not browser fullscreen. Existing Tailwind classes must be generated by the host. Edge offsets are padding-based; top is not applied to bottom placement. `onOpened` is a mount callback, not animation completion; `onClosed` follows the close path.
17
+
18
+ Not implemented in this source revision: responsive breakpoint configuration, drag resizing, instance handles, duplicate strategies, full error fallback/retry customization, strict command-only provider subscriptions, complete generic route inference, real browser/Profiler verification. Page layout overrides are preliminary. The package is not a validated production release. Build requires installing dev dependencies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-modal-navigation",
3
- "version": "1.1.10",
3
+ "version": "1.2.0",
4
4
  "description": "React 19 modal navigation with automatic built-in CSS, Promise results and typed hooks",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,7 +29,8 @@
29
29
  "pack:check": "npm pack --dry-run",
30
30
  "typecheck": "tsc --noEmit --skipLibCheck --strict types/index.d.ts",
31
31
  "test": "node --test tests/*.test.mjs",
32
- "test:react": "vitest run tests/react-profiler.integration.test.jsx --environment jsdom"
32
+ "test:react": "vitest run tests/react-profiler.integration.test.jsx tests/rc2.integration.test.jsx --environment jsdom",
33
+ "typecheck:consumer": "tsc --noEmit --strict --lib ES2022,DOM --moduleResolution bundler --module ESNext tests/types-120.ts"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "react": "^19.0.0",