@plumile/router 0.1.14 → 0.1.18
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/README.md +87 -422
- package/lib/esm/builder.d.ts +5 -5
- package/lib/esm/builder.d.ts.map +1 -1
- package/lib/esm/builder.js +1 -1
- package/lib/esm/index.d.ts +0 -4
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -5
- package/lib/esm/routing/Link.d.ts +3 -3
- package/lib/esm/routing/Link.d.ts.map +1 -1
- package/lib/esm/routing/Link.js +3 -8
- package/lib/esm/routing/RouteComponentWrapper.d.ts +6 -5
- package/lib/esm/routing/RouteComponentWrapper.d.ts.map +1 -1
- package/lib/esm/routing/RouteComponentWrapper.js +1 -1
- package/lib/esm/routing/RouterRenderer.d.ts.map +1 -1
- package/lib/esm/routing/RouterRenderer.js +1 -1
- package/lib/esm/routing/createRouter.d.ts +5 -6
- package/lib/esm/routing/createRouter.d.ts.map +1 -1
- package/lib/esm/routing/createRouter.js +458 -444
- package/lib/esm/routing/index.d.ts +2 -6
- package/lib/esm/routing/index.d.ts.map +1 -1
- package/lib/esm/routing/index.js +3 -7
- package/lib/esm/routing/useAllQuery.d.ts +7 -0
- package/lib/esm/routing/useAllQuery.d.ts.map +1 -0
- package/lib/esm/routing/useAllQuery.js +31 -0
- package/lib/esm/routing/useFilterDiagnostics.d.ts +2 -0
- package/lib/esm/routing/useFilterDiagnostics.d.ts.map +1 -0
- package/lib/esm/routing/useFilterDiagnostics.js +11 -0
- package/lib/esm/routing/useFilters.d.ts +16 -0
- package/lib/esm/routing/useFilters.d.ts.map +1 -0
- package/lib/esm/routing/useFilters.js +83 -0
- package/lib/esm/routing/useNavigate.d.ts +2 -9
- package/lib/esm/routing/useNavigate.d.ts.map +1 -1
- package/lib/esm/routing/useNavigate.js +1 -1
- package/lib/esm/routing/useQueryState.d.ts +1 -1
- package/lib/esm/routing/useQueryState.d.ts.map +1 -1
- package/lib/esm/routing/useQueryState.js +2 -2
- package/lib/esm/routing/useTypedQuery.js +1 -1
- package/lib/esm/tools/buildCombinedSearch.d.ts +11 -0
- package/lib/esm/tools/buildCombinedSearch.d.ts.map +1 -0
- package/lib/esm/tools/buildCombinedSearch.js +28 -0
- package/lib/esm/tools/buildSearch.d.ts +2 -8
- package/lib/esm/tools/buildSearch.d.ts.map +1 -1
- package/lib/esm/tools/buildSearch.js +12 -216
- package/lib/esm/tools.d.ts +6 -2
- package/lib/esm/tools.d.ts.map +1 -1
- package/lib/esm/tools.js +1 -1
- package/lib/esm/type-tests/routes-inference.test-d.d.ts +2 -0
- package/lib/esm/type-tests/routes-inference.test-d.d.ts.map +1 -0
- package/lib/esm/type-tests/routes-inference.test-d.js +49 -0
- package/lib/esm/types.d.ts +64 -38
- package/lib/esm/types.d.ts.map +1 -1
- package/lib/esm/types.js +1 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/builder.d.ts +5 -5
- package/lib/types/builder.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -4
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/routing/Link.d.ts +3 -3
- package/lib/types/routing/Link.d.ts.map +1 -1
- package/lib/types/routing/RouteComponentWrapper.d.ts +6 -5
- package/lib/types/routing/RouteComponentWrapper.d.ts.map +1 -1
- package/lib/types/routing/RouterRenderer.d.ts.map +1 -1
- package/lib/types/routing/createRouter.d.ts +5 -6
- package/lib/types/routing/createRouter.d.ts.map +1 -1
- package/lib/types/routing/index.d.ts +2 -6
- package/lib/types/routing/index.d.ts.map +1 -1
- package/lib/types/routing/useAllQuery.d.ts +7 -0
- package/lib/types/routing/useAllQuery.d.ts.map +1 -0
- package/lib/types/routing/useFilterDiagnostics.d.ts +2 -0
- package/lib/types/routing/useFilterDiagnostics.d.ts.map +1 -0
- package/lib/types/routing/useFilters.d.ts +16 -0
- package/lib/types/routing/useFilters.d.ts.map +1 -0
- package/lib/types/routing/useNavigate.d.ts +2 -9
- package/lib/types/routing/useNavigate.d.ts.map +1 -1
- package/lib/types/routing/useQueryState.d.ts +1 -1
- package/lib/types/routing/useQueryState.d.ts.map +1 -1
- package/lib/types/tools/buildCombinedSearch.d.ts +11 -0
- package/lib/types/tools/buildCombinedSearch.d.ts.map +1 -0
- package/lib/types/tools/buildSearch.d.ts +2 -8
- package/lib/types/tools/buildSearch.d.ts.map +1 -1
- package/lib/types/tools.d.ts +6 -2
- package/lib/types/tools.d.ts.map +1 -1
- package/lib/types/type-tests/routes-inference.test-d.d.ts +2 -0
- package/lib/types/type-tests/routes-inference.test-d.d.ts.map +1 -0
- package/lib/types/types.d.ts +64 -38
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +6 -5
- package/lib/esm/routing/devtools.d.ts +0 -21
- package/lib/esm/routing/devtools.d.ts.map +0 -1
- package/lib/esm/routing/devtools.js +0 -690
- package/lib/esm/routing/filters.d.ts +0 -97
- package/lib/esm/routing/filters.d.ts.map +0 -1
- package/lib/esm/routing/filters.js +0 -557
- package/lib/esm/routing/useActiveFilters.d.ts +0 -9
- package/lib/esm/routing/useActiveFilters.d.ts.map +0 -1
- package/lib/esm/routing/useActiveFilters.js +0 -38
- package/lib/esm/routing/useFilterState.d.ts +0 -10
- package/lib/esm/routing/useFilterState.d.ts.map +0 -1
- package/lib/esm/routing/useFilterState.js +0 -14
- package/lib/esm/routing/useNavigateWithQuery.d.ts +0 -15
- package/lib/esm/routing/useNavigateWithQuery.d.ts.map +0 -1
- package/lib/esm/routing/useNavigateWithQuery.js +0 -95
- package/lib/esm/routing/useQueryObject.d.ts +0 -18
- package/lib/esm/routing/useQueryObject.d.ts.map +0 -1
- package/lib/esm/routing/useQueryObject.js +0 -107
- package/lib/esm/routing/useStableRefEquality.d.ts +0 -5
- package/lib/esm/routing/useStableRefEquality.d.ts.map +0 -1
- package/lib/esm/routing/useStableRefEquality.js +0 -47
- package/lib/types/routing/devtools.d.ts +0 -21
- package/lib/types/routing/devtools.d.ts.map +0 -1
- package/lib/types/routing/filters.d.ts +0 -97
- package/lib/types/routing/filters.d.ts.map +0 -1
- package/lib/types/routing/useActiveFilters.d.ts +0 -9
- package/lib/types/routing/useActiveFilters.d.ts.map +0 -1
- package/lib/types/routing/useFilterState.d.ts +0 -10
- package/lib/types/routing/useFilterState.d.ts.map +0 -1
- package/lib/types/routing/useNavigateWithQuery.d.ts +0 -15
- package/lib/types/routing/useNavigateWithQuery.d.ts.map +0 -1
- package/lib/types/routing/useQueryObject.d.ts +0 -18
- package/lib/types/routing/useQueryObject.d.ts.map +0 -1
- package/lib/types/routing/useStableRefEquality.d.ts +0 -5
- package/lib/types/routing/useStableRefEquality.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -37,9 +37,6 @@ import { Route, getResourcePage } from '@plumile/router';
|
|
|
37
37
|
const routes: Route<any, any>[] = [
|
|
38
38
|
{
|
|
39
39
|
path: '/',
|
|
40
|
-
|
|
41
|
-
## Advanced Hooks Deep Dive & Combined Examples
|
|
42
|
-
|
|
43
40
|
resourcePage: getResourcePage('Home', () => import('./pages/Home')),
|
|
44
41
|
},
|
|
45
42
|
{
|
|
@@ -147,9 +144,6 @@ Navigation component that handles client-side routing.
|
|
|
147
144
|
|
|
148
145
|
- `to`: string - Destination path
|
|
149
146
|
- `exact?`: boolean - Exact path matching for active state
|
|
150
|
-
|
|
151
|
-
### Combined Example: Products Listing Page
|
|
152
|
-
|
|
153
147
|
- `activeClassName?`: string - CSS class when link is active
|
|
154
148
|
- `className?`: string - Base CSS class
|
|
155
149
|
- `preload?`: boolean - Preload route on hover
|
|
@@ -236,6 +230,50 @@ Type helper for strongly-typed route definitions.
|
|
|
236
230
|
|
|
237
231
|
## Advanced Usage
|
|
238
232
|
|
|
233
|
+
### Per-Route Prepared Data & Typed Navigate
|
|
234
|
+
|
|
235
|
+
Each route created with `r({...})` now preserves:
|
|
236
|
+
|
|
237
|
+
- Prepared data type (return of `prepare`)
|
|
238
|
+
- URL parameter type
|
|
239
|
+
- Inferred typed query shape from its `query` schema
|
|
240
|
+
|
|
241
|
+
This enables discriminated narrowing using `entry.route?.path` and compile-time validation of `navigate` query objects.
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
import { r, q, createRouter } from '@plumile/router';
|
|
245
|
+
|
|
246
|
+
const plans = r({
|
|
247
|
+
path: '/plans',
|
|
248
|
+
query: { page: q.number() } as const,
|
|
249
|
+
prepare: ({ query }) => ({ page: query.page }),
|
|
250
|
+
});
|
|
251
|
+
const user = r<{ userId: string }, { id: string }>({
|
|
252
|
+
path: '/users/:id',
|
|
253
|
+
prepare: ({ variables }) => ({ userId: variables.id }),
|
|
254
|
+
});
|
|
255
|
+
const { context } = createRouter([plans, user] as const);
|
|
256
|
+
|
|
257
|
+
const entry = context.get();
|
|
258
|
+
if (entry.route?.path === '/plans') {
|
|
259
|
+
const prepared = context.getPrepared('/plans');
|
|
260
|
+
// prepared?.page inferred as number | undefined
|
|
261
|
+
const typed = context.getTypedQuery('/plans');
|
|
262
|
+
// typed?.page inferred
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Typed navigate – query validated against the route schema
|
|
266
|
+
context.navigate({ pathname: '/plans', query: { page: 2 } });
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
APIs:
|
|
270
|
+
|
|
271
|
+
- `context.getPrepared(path)` → prepared object for that matched path (if present).
|
|
272
|
+
- `context.getTypedQuery(path)` → typed query for path.
|
|
273
|
+
- `context.navigate({...})` → enforces schema shape when `pathname` matches a known literal path.
|
|
274
|
+
|
|
275
|
+
If a path is dynamic or no schema exists, the untyped fallback remains available.
|
|
276
|
+
|
|
239
277
|
### Typed Query Parameters (DSL)
|
|
240
278
|
|
|
241
279
|
The router provides a lightweight schema DSL for parsing, typing, normalizing and serializing query strings.
|
|
@@ -482,118 +520,64 @@ Extending: if you need more (e.g. trigger navigations) you can wrap `createRoute
|
|
|
482
520
|
|
|
483
521
|
Production: the symbol is not defined; accessing it will yield `undefined`. Never ship logic depending on it; keep usage inside `if (process.env.NODE_ENV !== 'production')` blocks or guarded optional checks.
|
|
484
522
|
|
|
485
|
-
###
|
|
486
|
-
|
|
487
|
-
To encourage consistent usage of the query hooks, a custom rule is provided inside the router package to flag raw `window.location.search` access.
|
|
488
|
-
|
|
489
|
-
Add to your flat ESLint config:
|
|
490
|
-
|
|
491
|
-
````js
|
|
492
|
-
import noDirectWindowLocationSearch from '@plumile/router/lib/eslint-rules/no-direct-window-location-search.js';
|
|
493
|
-
|
|
494
|
-
export default [
|
|
495
|
-
{
|
|
496
|
-
|
|
497
|
-
## Batched Navigation & Provisional typedQuery Contract
|
|
498
|
-
|
|
499
|
-
The router supports two batching modes:
|
|
500
|
-
|
|
501
|
-
- Manual batching: pass `batch: true` in successive `navigate` calls within the same microtask.
|
|
502
|
-
- Auto batching: enable `createRouter(routes, { autoBatch: true })` and omit `immediate: true` to coalesce navigations scheduled in the same microtask.
|
|
503
|
-
|
|
504
|
-
During a batched sequence, the final history update (a single `push`/`set`) is deferred to a queued microtask. Some code (tests, imperative flows) may need to synchronously observe the merged query state before the flush occurs. To support this, the router performs a provisional in‑memory update of the current route entry on each batched `navigate`:
|
|
505
|
-
|
|
506
|
-
Guarantees (provisional phase):
|
|
507
|
-
|
|
508
|
-
1. `context.get()` returns an entry whose `location.search`, `rawSearch`, `query` (raw parsed) and `typedQuery` reflect the merged state of all batched calls so far.
|
|
509
|
-
2. Each additional batched call merges query keys (last write wins) and overwrites the entire filters object (they are considered atomic state) before recomputing `typedQuery`.
|
|
510
|
-
3. The provisional `typedQuery` uses the deepest route schema of the eventual target pathname (if a batched navigation changes pathname, subsequent calls resolve the schema for that new path).
|
|
511
|
-
4. Normalization (e.g. clamping `page < 1`) is only applied at the final flush listener step; the provisional `typedQuery` may briefly contain unnormalized values until flush.
|
|
512
|
-
5. Subscribers (`context.subscribe`) are **not** notified until the actual history update fires (asynchronously). Reading inside the same tick requires using `context.get()` directly, not relying on subscription callbacks.
|
|
513
|
-
|
|
514
|
-
Non‑guarantees / caveats:
|
|
523
|
+
### Filter Schema & useFilters (Integration with @plumile/filter-query)
|
|
515
524
|
|
|
516
|
-
|
|
517
|
-
- If later batched calls change the pathname, earlier provisional `typedQuery` objects become stale; always re‑read after your final batched mutation if you need the merged result.
|
|
518
|
-
- Filters batching (from `useFilters` helpers) coalesces multiple `set/patch/clear` calls in the same microtask via an internal microtask queue. These feed into the outer navigation batching so a burst of filter helper calls plus other `navigate` calls still produce a single history entry.
|
|
519
|
-
|
|
520
|
-
Edge cases:
|
|
521
|
-
|
|
522
|
-
- Calling `navigate({ immediate: true })` inside an active batch forces an immediate flush, bypassing batching for that specific call.
|
|
523
|
-
- Interleaving manual `batch: true` and autoBatch calls: if autoBatch is enabled and you explicitly pass `batch: false`, that call flushes immediately; otherwise the presence of any manual `batch: true` call within the tick keeps coalescing active until flush.
|
|
524
|
-
|
|
525
|
-
Recommended usage pattern inside effects or event handlers:
|
|
525
|
+
The router can parse and serialize structured filter expressions using the `@plumile/filter-query` package. Define a `filterSchema` on the deepest route (same precedence rule as `query`). Each filter key is encoded as `field.operator=value`.
|
|
526
526
|
|
|
527
527
|
```ts
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
context.navigate({ filters: { status: { in: ['active'] } }, filterSchema, batch: true });
|
|
531
|
-
context.navigate({ query: { tag: 'green' }, batch: true });
|
|
532
|
-
// Synchronous inspection (provisional)
|
|
533
|
-
const merged = context.get().typedQuery; // already includes page=1, tag=green, status filter
|
|
534
|
-
````
|
|
535
|
-
|
|
536
|
-
Testing note: tests asserting final URL should poll or await a microtask / tick rather than expecting synchronous `window.location.search` updates when batching is involved.
|
|
537
|
-
|
|
538
|
-
Future evolution: if normalization or additional query transformations grow more complex, the provisional recompute will remain a best‑effort mirror; code relying on _final_ normalized values should subscribe or await the flush boundary.
|
|
539
|
-
|
|
540
|
-
Summary: Provisional batching gives synchronous, allocation‑minimal read access to the in‑flight merged query & typedQuery without sacrificing a single history entry – use `context.get()` for immediate reads, and rely on subscriptions or hooks for React render updates.
|
|
541
|
-
|
|
542
|
-
## Route-Level Filter Schemas
|
|
528
|
+
import { r, q, useFilters } from '@plumile/router';
|
|
529
|
+
import { defineSchema, numberField, stringField } from '@plumile/filter-query';
|
|
543
530
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
```ts
|
|
549
|
-
import { r, defineFilters, numberFilter, stringFilter } from '@plumile/router';
|
|
531
|
+
const filterSchema = defineSchema({
|
|
532
|
+
price: numberField(), // operators: gt,gte,lt,lte,eq,neq,between,in,nin
|
|
533
|
+
name: stringField(), // operators: contains,sw,ew,eq,neq,in,nin
|
|
534
|
+
});
|
|
550
535
|
|
|
551
|
-
|
|
536
|
+
const routes = [
|
|
552
537
|
r({
|
|
553
|
-
path: '/
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
children: [
|
|
558
|
-
r({
|
|
559
|
-
path: '/:id',
|
|
560
|
-
filterSchema: defineFilters({
|
|
561
|
-
name: stringFilter({ operators: ['contains'] }),
|
|
562
|
-
}),
|
|
563
|
-
}),
|
|
564
|
-
],
|
|
538
|
+
path: '/items',
|
|
539
|
+
query: { page: q.default(q.number(), 1) },
|
|
540
|
+
filterSchema,
|
|
541
|
+
render: () => null,
|
|
565
542
|
}),
|
|
566
543
|
];
|
|
544
|
+
|
|
545
|
+
// Inside a component rendered under /items
|
|
546
|
+
const [filters, actions] = useFilters();
|
|
547
|
+
actions.set('price', 'gt', 10); // ?page=1&price.gt=10
|
|
548
|
+
actions.set('price', 'eq', 15); // ?page=1&price.gt=10&price.eq=15
|
|
549
|
+
actions.remove('price', 'gt'); // remove only that operator
|
|
550
|
+
actions.clear(); // remove all filter segments
|
|
567
551
|
```
|
|
568
552
|
|
|
569
|
-
|
|
553
|
+
`navigate({ filters })` is also available for programmatic changes alongside query updates. Serialization keeps query parameters first, then filter segments, both deterministically ordered.
|
|
570
554
|
|
|
571
|
-
|
|
555
|
+
Diagnostics (unknown field/operator, invalid values, etc.) are accessible via `useFilterDiagnostics()` for debugging tooling or UI feedback.
|
|
572
556
|
|
|
573
|
-
|
|
574
|
-
- No deep merge inside a field definition.
|
|
575
|
-
- Omitted routes: ignored.
|
|
557
|
+
### ESLint Rule: no-direct-window-location-search
|
|
576
558
|
|
|
577
|
-
|
|
559
|
+
To encourage consistent usage of the query hooks, a custom rule is provided inside the router package to flag raw `window.location.search` access.
|
|
578
560
|
|
|
579
|
-
|
|
580
|
-
- Empty filters object with route-level schema is treated as “no change” (no extra keys added).
|
|
561
|
+
Add to your flat ESLint config:
|
|
581
562
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
'@plumile-router/dx': {
|
|
585
|
-
rules: {
|
|
586
|
-
'no-direct-window-location-search': noDirectWindowLocationSearch,
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
rules: {
|
|
591
|
-
'@plumile-router/dx/no-direct-window-location-search': 'warn',
|
|
592
|
-
},
|
|
593
|
-
},
|
|
594
|
-
];
|
|
563
|
+
```js
|
|
564
|
+
import noDirectWindowLocationSearch from '@plumile/router/lib/eslint-rules/no-direct-window-location-search.js';
|
|
595
565
|
|
|
596
|
-
|
|
566
|
+
export default [
|
|
567
|
+
{
|
|
568
|
+
plugins: {
|
|
569
|
+
'@plumile-router/dx': {
|
|
570
|
+
rules: {
|
|
571
|
+
'no-direct-window-location-search': noDirectWindowLocationSearch,
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
rules: {
|
|
576
|
+
'@plumile-router/dx/no-direct-window-location-search': 'warn',
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
];
|
|
580
|
+
```
|
|
597
581
|
|
|
598
582
|
Optional configuration:
|
|
599
583
|
|
|
@@ -605,7 +589,7 @@ rules: {
|
|
|
605
589
|
{ allowInFiles: ['legacy-entry.ts'] },
|
|
606
590
|
],
|
|
607
591
|
},
|
|
608
|
-
|
|
592
|
+
```
|
|
609
593
|
|
|
610
594
|
When triggered, replace patterns like:
|
|
611
595
|
|
|
@@ -663,242 +647,6 @@ Behavior:
|
|
|
663
647
|
Options:
|
|
664
648
|
`{ defaultValue?, omitIfDefault?: boolean = true, replace?: boolean, raw?: boolean }`
|
|
665
649
|
|
|
666
|
-
### Filters DSL (Experimental Advanced Filtering)
|
|
667
|
-
|
|
668
|
-
Structured multi‑operator filtering can be expressed via query keys using the pattern `field.operator`.
|
|
669
|
-
|
|
670
|
-
1. Define a schema
|
|
671
|
-
|
|
672
|
-
```ts
|
|
673
|
-
import { defineFilters, numberFilter, stringFilter } from '@plumile/router';
|
|
674
|
-
|
|
675
|
-
export const filters = defineFilters({
|
|
676
|
-
price: numberFilter(), // numeric: eq, neq, gt, gte, lt, lte, in, nin, between, exists
|
|
677
|
-
status: stringFilter({ operators: ['eq', 'in', 'nin'] }),
|
|
678
|
-
name: stringFilter({ operators: ['contains', 'starts', 'ends'] }),
|
|
679
|
-
// Provide default operator values to omit them from serialization when matched
|
|
680
|
-
availability: numberFilter({
|
|
681
|
-
operators: ['exists'],
|
|
682
|
-
defaults: { exists: true },
|
|
683
|
-
}),
|
|
684
|
-
priceRange: numberFilter({
|
|
685
|
-
operators: ['between'],
|
|
686
|
-
defaults: { between: [[0, 100]] },
|
|
687
|
-
}),
|
|
688
|
-
});
|
|
689
|
-
```
|
|
690
|
-
|
|
691
|
-
2. Read & update filters
|
|
692
|
-
|
|
693
|
-
```tsx
|
|
694
|
-
import { useFilters } from '@plumile/router';
|
|
695
|
-
|
|
696
|
-
function Products() {
|
|
697
|
-
const [f, { patch, clear }] = useFilters(filters);
|
|
698
|
-
// f.price.gt => number[] | undefined
|
|
699
|
-
// f.status.in => string[] | undefined
|
|
700
|
-
return (
|
|
701
|
-
<button
|
|
702
|
-
onClick={() => {
|
|
703
|
-
patch({ price: { gt: [10] } });
|
|
704
|
-
}}
|
|
705
|
-
>
|
|
706
|
-
Price > 10
|
|
707
|
-
</button>
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
3. Narrow to a single operator
|
|
713
|
-
|
|
714
|
-
```tsx
|
|
715
|
-
import { useFilterState } from '@plumile/router';
|
|
716
|
-
|
|
717
|
-
function PriceGt() {
|
|
718
|
-
const [gt, setGt] = useFilterState(filters, 'price', 'gt');
|
|
719
|
-
return (
|
|
720
|
-
<input
|
|
721
|
-
value={gt?.[0] ?? ''}
|
|
722
|
-
onChange={(e) => setGt([Number(e.target.value)])}
|
|
723
|
-
/>
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
```
|
|
727
|
-
|
|
728
|
-
4. Supported operators
|
|
729
|
-
|
|
730
|
-
| Kind | Operators |
|
|
731
|
-
| ------ | ------------------------------------------------------------------------------------ |
|
|
732
|
-
| number | eq, neq, gt, gte, lt, lte, in, nin, between (tuples), exists |
|
|
733
|
-
| string | eq, neq, in, nin, between (tuples of strings), exists, contains, starts, ends, regex |
|
|
734
|
-
|
|
735
|
-
`exists` expects a boolean; presence of key defaults to `true` if value unrecognized.
|
|
736
|
-
|
|
737
|
-
5. Query string format
|
|
738
|
-
|
|
739
|
-
```
|
|
740
|
-
?price.gt=10&price.between=10&price.between=20&price.between=30&price.between=40&status.in=active&status.in=pending
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
6. Between operator
|
|
744
|
-
|
|
745
|
-
Pairs of values create ranges: four values → two ranges. Odd final value is ignored.
|
|
746
|
-
|
|
747
|
-
7. Clearing
|
|
748
|
-
|
|
749
|
-
`clear()` → remove all filters. `clear(['price'])` → remove only price.\* keys.
|
|
750
|
-
|
|
751
|
-
8. Patching
|
|
752
|
-
|
|
753
|
-
`patch({ price: { gt: [20], between: [[10,20]] } })` merges at field level, replacing individual operator arrays.
|
|
754
|
-
|
|
755
|
-
9. Serialization rules
|
|
756
|
-
|
|
757
|
-
- Previous filter keys (`field.op`) are dropped before adding new ones.
|
|
758
|
-
- Multiple values produce repeated keys (same as existing query arrays).
|
|
759
|
-
- Boolean `exists` serialized as `1` / `0`.
|
|
760
|
-
- Optional omission of default operator values: if a filter definition supplies a `defaults` object
|
|
761
|
-
(e.g. `{ defaults: { gt: [10] } }` or `{ defaults: { exists: true } }`), and the current operator
|
|
762
|
-
value is shallow‑equal to that default, the `field.operator` key is skipped during serialization.
|
|
763
|
-
Applies to array operators (exact ordered match) and `exists` boolean. `between` defaults compare
|
|
764
|
-
tuple pairs (`[[a,b]]`) element-wise.
|
|
765
|
-
|
|
766
|
-
10. Type inference
|
|
767
|
-
|
|
768
|
-
`InferFilters<typeof filters.schema>` gives `{ price: { gt?: number[]; between?: [number, number][]; ... } }`.
|
|
769
|
-
|
|
770
|
-
11. Opt‑in / Backward Compatible
|
|
771
|
-
|
|
772
|
-
No change to existing query parameter behavior. Filter keys are just additional query entries; legacy code reading raw `useQuery()` continues to function.
|
|
773
|
-
|
|
774
|
-
12. Limitations / Future
|
|
775
|
-
|
|
776
|
-
- Sorting deliberately excluded (would be separate DSL).
|
|
777
|
-
- No date operator specialization yet.
|
|
778
|
-
- Regex values are passed through verbatim (URL decoding handled upstream).
|
|
779
|
-
- Default omission currently uses shallow equality (ordered array match). For number arrays
|
|
780
|
-
canonicalization (sorting + optional dedupe) happens prior to comparison, ensuring stable omission.
|
|
781
|
-
|
|
782
|
-
Tests cover parsing (including multiple ranges) and building; extend as needed for your domain.
|
|
783
|
-
|
|
784
|
-
### New Hooks (Phase 4)
|
|
785
|
-
|
|
786
|
-
#### `useQueryObject(opts?)`
|
|
787
|
-
|
|
788
|
-
High-level accessor returning the entire current query object (typed when the matched deepest route declares a `query` schema). It also returns a stable setter that merges partial updates.
|
|
789
|
-
|
|
790
|
-
```tsx
|
|
791
|
-
import { useQueryObject } from '@plumile/router';
|
|
792
|
-
|
|
793
|
-
function Panel() {
|
|
794
|
-
const [query, setQuery] = useQueryObject({ omitDefaults: true });
|
|
795
|
-
// query: typed (if schema) else raw record
|
|
796
|
-
return (
|
|
797
|
-
<button
|
|
798
|
-
onClick={() => {
|
|
799
|
-
setQuery({ page: (query.page ?? 1) + 1 });
|
|
800
|
-
}}
|
|
801
|
-
>
|
|
802
|
-
Next page
|
|
803
|
-
</button>
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
```
|
|
807
|
-
|
|
808
|
-
Options:
|
|
809
|
-
|
|
810
|
-
- `raw?: boolean` Use aggregated raw query even if a schema exists.
|
|
811
|
-
- `replace?: boolean` Default navigation mode for all subsequent `setQuery` calls.
|
|
812
|
-
- `omitDefaults?: boolean` When true, schema keys whose value equals their declared default are omitted from the URL.
|
|
813
|
-
|
|
814
|
-
Setter semantics:
|
|
815
|
-
|
|
816
|
-
- Accepts an object or function `(prev) => next`.
|
|
817
|
-
- Keys set to `undefined` are removed from the URL.
|
|
818
|
-
- Partial objects are shallow‑merged with previous query state (post-merge omission rules are applied if `omitDefaults` is enabled).
|
|
819
|
-
|
|
820
|
-
#### `useActiveFilters(filterSchema)`
|
|
821
|
-
|
|
822
|
-
Returns a flat array of currently active filter operator entries derived from the structured filters state returned by `useFilters`.
|
|
823
|
-
|
|
824
|
-
```tsx
|
|
825
|
-
import { useActiveFilters } from '@plumile/router';
|
|
826
|
-
import { filters } from './filters-schema';
|
|
827
|
-
|
|
828
|
-
function ActiveChips() {
|
|
829
|
-
const active = useActiveFilters(filters);
|
|
830
|
-
return (
|
|
831
|
-
<ul>
|
|
832
|
-
{active.map((f) => (
|
|
833
|
-
<li key={f.field + f.operator}>
|
|
834
|
-
{f.field}.{f.operator}: {f.values.join(', ')}
|
|
835
|
-
</li>
|
|
836
|
-
))}
|
|
837
|
-
</ul>
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
```
|
|
841
|
-
|
|
842
|
-
Each entry: `{ field: string; operator: string; values: any[] }` where `values` is the already normalized array (for non‑array primitives a singleton array is produced). Empty arrays / undefined operators are skipped.
|
|
843
|
-
|
|
844
|
-
#### `useNavigateWithQuery(opts?)`
|
|
845
|
-
|
|
846
|
-
Convenience wrapper combining current query (typed if possible) with partial updates before invoking `navigate`.
|
|
847
|
-
|
|
848
|
-
```tsx
|
|
849
|
-
import { useNavigateWithQuery } from '@plumile/router';
|
|
850
|
-
|
|
851
|
-
function Incrementer() {
|
|
852
|
-
const update = useNavigateWithQuery({ omitDefaults: true });
|
|
853
|
-
return (
|
|
854
|
-
<button
|
|
855
|
-
onClick={() => {
|
|
856
|
-
update((prev) => ({ page: (prev.page ?? 1) + 1 }));
|
|
857
|
-
}}
|
|
858
|
-
>
|
|
859
|
-
Next
|
|
860
|
-
</button>
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
```
|
|
864
|
-
|
|
865
|
-
Behavior:
|
|
866
|
-
|
|
867
|
-
- Reads existing (typed or raw) query as base.
|
|
868
|
-
- Accepts object or functional update.
|
|
869
|
-
- Keys set to `undefined` are removed.
|
|
870
|
-
- `omitDefaults` removes schema-default valued keys.
|
|
871
|
-
- `raw` forces ignoring the schema (raw aggregation base).
|
|
872
|
-
- `replace` option (global or per call) controls history mode.
|
|
873
|
-
|
|
874
|
-
#### `useStableRefEquality(value, areEqual?)`
|
|
875
|
-
|
|
876
|
-
Utility hook that preserves the reference of the latest value (object or array) as long as shallow equality holds. When a new value is passed whose own enumerable keys (and their primitive or reference-equal values) match the previous one, the previous stable reference is returned. If they differ, the new value becomes the stored reference.
|
|
877
|
-
|
|
878
|
-
Designed for niche interop cases (e.g. passing derived objects to dependency arrays of third-party hooks) where you can't or don't want the upstream producer to handle memoization. Most consumers of the router do NOT need this because `useQuery`, `useTypedQuery`, `useFilters` already return stable references.
|
|
879
|
-
|
|
880
|
-
```ts
|
|
881
|
-
import { useStableRefEquality } from '@plumile/router';
|
|
882
|
-
|
|
883
|
-
function Chart({ data }) {
|
|
884
|
-
// Avoid re-renders in a heavy child when parent recreates equivalent arrays
|
|
885
|
-
const stableData = useStableRefEquality(data);
|
|
886
|
-
return <ExpensiveChart data={stableData} />;
|
|
887
|
-
}
|
|
888
|
-
```
|
|
889
|
-
|
|
890
|
-
Custom comparator:
|
|
891
|
-
|
|
892
|
-
```ts
|
|
893
|
-
const value = useStableRefEquality(complex, (a, b) => deepCustomCompare(a, b));
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
Notes:
|
|
897
|
-
|
|
898
|
-
- Only shallow by default (no deep traversal) for perf.
|
|
899
|
-
- Non-object/array inputs are returned as-is (no caching layer needed).
|
|
900
|
-
- Avoid overuse; prefer structuring code so sources themselves are stable.
|
|
901
|
-
|
|
902
650
|
### Data Preloading
|
|
903
651
|
|
|
904
652
|
```typescript
|
|
@@ -946,89 +694,6 @@ function MyComponent() {
|
|
|
946
694
|
}
|
|
947
695
|
```
|
|
948
696
|
|
|
949
|
-
### Navigation With Filters & Batching (Phase 5)
|
|
950
|
-
|
|
951
|
-
You can atomically update query parameters and structured filters via the extended `navigate` API and related hooks.
|
|
952
|
-
|
|
953
|
-
```tsx
|
|
954
|
-
import {
|
|
955
|
-
useNavigate,
|
|
956
|
-
useFilters,
|
|
957
|
-
defineFilters,
|
|
958
|
-
numberFilter,
|
|
959
|
-
} from '@plumile/router';
|
|
960
|
-
|
|
961
|
-
const filterSchema = defineFilters({ price: numberFilter() });
|
|
962
|
-
|
|
963
|
-
function PriceBump() {
|
|
964
|
-
const navigate = useNavigate();
|
|
965
|
-
const [filters, { patch }] = useFilters(filterSchema);
|
|
966
|
-
return (
|
|
967
|
-
<button
|
|
968
|
-
onClick={() => {
|
|
969
|
-
// Update both query & filters in a single URL change
|
|
970
|
-
navigate({
|
|
971
|
-
query: { page: 1 },
|
|
972
|
-
filters: { price: { gt: [10] } },
|
|
973
|
-
filterSchema,
|
|
974
|
-
});
|
|
975
|
-
}}
|
|
976
|
-
>
|
|
977
|
-
Apply
|
|
978
|
-
</button>
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
```
|
|
982
|
-
|
|
983
|
-
Batch multiple navigations issued during the same micro‑task into _one_ history update by passing `batch: true`:
|
|
984
|
-
|
|
985
|
-
```tsx
|
|
986
|
-
function ComplexMutation() {
|
|
987
|
-
const navigate = useNavigate();
|
|
988
|
-
return (
|
|
989
|
-
<button
|
|
990
|
-
onClick={() => {
|
|
991
|
-
navigate({ query: { page: 1 }, batch: true });
|
|
992
|
-
navigate({
|
|
993
|
-
filters: { price: { gt: [20] } },
|
|
994
|
-
filterSchema,
|
|
995
|
-
batch: true,
|
|
996
|
-
});
|
|
997
|
-
navigate({
|
|
998
|
-
filters: { price: {} /* clear price */ },
|
|
999
|
-
filterSchema,
|
|
1000
|
-
batch: true,
|
|
1001
|
-
});
|
|
1002
|
-
// All three coalesce into one push
|
|
1003
|
-
}}
|
|
1004
|
-
>
|
|
1005
|
-
Run sequence
|
|
1006
|
-
</button>
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
```
|
|
1010
|
-
|
|
1011
|
-
Hooks `useQueryObject` and `useFilters` also accept a `batch` flag in their nav options:
|
|
1012
|
-
|
|
1013
|
-
```tsx
|
|
1014
|
-
const [query, setQuery] = useQueryObject();
|
|
1015
|
-
const [f, { patch, clear }] = useFilters(filterSchema);
|
|
1016
|
-
|
|
1017
|
-
// Coalesce three operations
|
|
1018
|
-
setQuery({ page: 2 }, { batch: true });
|
|
1019
|
-
patch({ price: { gt: [30] } }, { batch: true });
|
|
1020
|
-
clear(['price'], { batch: true });
|
|
1021
|
-
```
|
|
1022
|
-
|
|
1023
|
-
Notes:
|
|
1024
|
-
|
|
1025
|
-
- Batching is opt‑in: default behavior is immediate navigation (backward compatible).
|
|
1026
|
-
- The last non‑undefined `replace` flag wins inside a batch group.
|
|
1027
|
-
- The last provided `query` object and `filters` snapshot in the batch are used for serialization.
|
|
1028
|
-
- Provide `filterSchema` whenever you include `filters`.
|
|
1029
|
-
|
|
1030
|
-
`buildSearch(query, schema, { filters, filterSchema })` merges filters deterministically with query keys (schema‑ordered keys first, then extras).
|
|
1031
|
-
|
|
1032
697
|
### Route Preloading
|
|
1033
698
|
|
|
1034
699
|
```tsx
|
package/lib/esm/builder.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type MatchFunction, type ParamData } from 'path-to-regexp';
|
|
2
|
-
import type { FlatRouteInput, Redirect,
|
|
2
|
+
import type { FlatRouteInput, Redirect, AnyRoute } from './types.js';
|
|
3
3
|
export declare class FlatRoute<TParams extends ParamData> {
|
|
4
4
|
path: string;
|
|
5
|
-
routes:
|
|
5
|
+
routes: AnyRoute[];
|
|
6
6
|
matchFunction: MatchFunction<TParams>;
|
|
7
7
|
redirectTo?: string;
|
|
8
8
|
constructor(input: FlatRouteInput<TParams>);
|
|
9
9
|
}
|
|
10
|
-
export declare function isRedirect(route:
|
|
11
|
-
export declare function buildRoute(routeConfig: (
|
|
12
|
-
export declare function buildRoutes(routeConfig:
|
|
10
|
+
export declare function isRedirect(route: AnyRoute | Redirect): route is Redirect;
|
|
11
|
+
export declare function buildRoute(routeConfig: (AnyRoute | Redirect)[], parentRoutes?: AnyRoute[], prefix?: string): FlatRoute<ParamData>[];
|
|
12
|
+
export declare function buildRoutes(routeConfig: AnyRoute[]): FlatRoute<ParamData>[];
|
|
13
13
|
//# sourceMappingURL=builder.d.ts.map
|
package/lib/esm/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ5E,qBAAa,SAAS,CAAC,OAAO,SAAS,SAAS;IAEvC,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,QAAQ,EAAE,CAAC;IAGnB,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAGtC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAOR,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC;CAOlD;AAQD,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAGxE;AAYD,wBAAgB,UAAU,CACxB,WAAW,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,EACpC,YAAY,GAAE,QAAQ,EAAO,EAC7B,MAAM,SAAK,GACV,SAAS,CAAC,SAAS,CAAC,EAAE,CAkExB;AASD,wBAAgB,WAAW,CAAC,WAAW,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,EAAE,CAE3E"}
|
package/lib/esm/builder.js
CHANGED
|
@@ -68,4 +68,4 @@ export function buildRoute(routeConfig, parentRoutes = [], prefix = '') {
|
|
|
68
68
|
export function buildRoutes(routeConfig) {
|
|
69
69
|
return buildRoute(routeConfig);
|
|
70
70
|
}
|
|
71
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLEVBQXNDLE1BQU0sZ0JBQWdCLENBQUM7QUFVM0UsTUFBTSxPQUFPLFNBQVM7SUFFYixJQUFJLENBQVM7SUFHYixNQUFNLENBQWE7SUFHbkIsYUFBYSxDQUF5QjtJQUd0QyxVQUFVLENBQVU7SUFPM0IsWUFBbUIsS0FBOEI7UUFDL0MsTUFBTSxFQUFFLGFBQWEsRU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hcyBBbnlSb3V0ZVtdLFxuICAgICAgICB9KSxcbiAgICAgICk7XG4gICAgfSBlbHNlIHtcbiAgICAgIGZsYXRSb3V0ZXMucHVzaChcbiAgICAgICAgbmV3IEZsYXRSb3V0ZSh7XG4gICAgICAgICAgcGF0aCxcbiAgICAgICAgICBtYXRjaEZ1bmN0aW9uLFxuICAgICAgICAgIHJvdXRlczogWy4uLnBhcmVudFJvdXRlcywgcm91dGVdIGFzIEFueVJvdXRlW10sXG4gICAgICAgIH0pLFxuICAgICAgKTtcbiAgICB9XG4gIH1cblxuICByZXR1cm4gZmxhdFJvdXRlcztcbn1cblxuLyoqXG4gKiBCdWlsZHMgYSBmbGF0IHJvdXRlIGxpc3QgZnJvbSB0aGUgZ2l2ZW4gcm91dGUgY29uZmlndXJhdGlvbi5cbiAqIFRoaXMgaXMgdGhlIG1haW4gZW50cnkgcG9pbnQgZm9yIHJvdXRlIGJ1aWxkaW5nLlxuICpcbiAqIEBwYXJhbSByb3V0ZUNvbmZpZyAtIEFycmF5IG9mIHJvdXRlIGNvbmZpZ3VyYXRpb25zIHRvIGZsYXR0ZW5cbiAqIEByZXR1cm5zIEFycmF5IG9mIGZsYXR0ZW5lZCByb3V0ZXMgcmVhZHkgZm9yIG1hdGNoaW5nXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBidWlsZFJvdXRlcyhyb3V0ZUNvbmZpZzogQW55Um91dGVbXSk6IEZsYXRSb3V0ZTxQYXJhbURhdGE+W10ge1xuICByZXR1cm4gYnVpbGRSb3V0ZShyb3V0ZUNvbmZpZyk7XG59XG4iXX0=
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -5,9 +5,5 @@ export * from './builder.js';
|
|
|
5
5
|
export * from './ResourcePage.js';
|
|
6
6
|
export * from './tools.js';
|
|
7
7
|
export { q, parseTypedQuery } from './tools/query-dsl.js';
|
|
8
|
-
export { defineFilters, numberFilter, stringFilter, useFilters, useQueryFilters, } from './routing/filters.js';
|
|
9
|
-
export { default as useFilterState } from './routing/useFilterState.js';
|
|
10
|
-
export { default as useActiveFilters } from './routing/useActiveFilters.js';
|
|
11
|
-
export { default as useQueryObject } from './routing/useQueryObject.js';
|
|
12
8
|
export type * from './types.js';
|
|
13
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG1D,mBAAmB,YAAY,CAAC"}
|