@solidjs/router 2.0.0-next.35 → 2.0.0-next.36
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/data/action.js +4 -1
- package/dist/index.js +14 -1
- package/dist/paths.d.ts +23 -3
- package/package.json +1 -1
package/dist/data/action.js
CHANGED
|
@@ -209,7 +209,10 @@ function installRouterIntegrations() {
|
|
|
209
209
|
}
|
|
210
210
|
export function useSubmissions(fn, filter) {
|
|
211
211
|
const router = useRouter();
|
|
212
|
-
|
|
212
|
+
// Submissions are immutable records, so the same records in the same order
|
|
213
|
+
// are the same list: another action's submissions changing re-runs the
|
|
214
|
+
// filter but must not re-run this list's readers.
|
|
215
|
+
const subs = createMemo(() => router.submissions[0]().filter(s => s.url === fn.base && (!filter || filter(s.input))), { equals: (a, b) => a.length === b.length && a.every((s, i) => s === b[i]) });
|
|
213
216
|
return new Proxy([], {
|
|
214
217
|
get(_, property) {
|
|
215
218
|
if (property === $TRACK)
|
package/dist/index.js
CHANGED
|
@@ -544,6 +544,14 @@ const int = s => /^-?\d+$/.test(s);
|
|
|
544
544
|
* untyped, definitionally.
|
|
545
545
|
*/
|
|
546
546
|
|
|
547
|
+
/**
|
|
548
|
+
* Sibling routes that share a param prefix (`/posts/:id`, `/posts/:id/edit`)
|
|
549
|
+
* each contribute a call at that node, and a call on an intersection of
|
|
550
|
+
* function types resolves to its first overload only. So the call reads its
|
|
551
|
+
* result back through `this` — the whole intersection — where the
|
|
552
|
+
* continuations of every sibling with the same arity have merged.
|
|
553
|
+
*/
|
|
554
|
+
|
|
547
555
|
/**
|
|
548
556
|
* The type of a router instance's `paths` proxy for a given route tree.
|
|
549
557
|
* Requires the tree to be a literal tuple (`as const` or a `const` type
|
|
@@ -3349,7 +3357,12 @@ function installRouterIntegrations() {
|
|
|
3349
3357
|
}
|
|
3350
3358
|
function useSubmissions(fn, filter) {
|
|
3351
3359
|
const router = useRouter();
|
|
3352
|
-
|
|
3360
|
+
// Submissions are immutable records, so the same records in the same order
|
|
3361
|
+
// are the same list: another action's submissions changing re-runs the
|
|
3362
|
+
// filter but must not re-run this list's readers.
|
|
3363
|
+
const subs = createMemo(() => router.submissions[0]().filter(s => s.url === fn.base && (!filter || filter(s.input))), {
|
|
3364
|
+
equals: (a, b) => a.length === b.length && a.every((s, i) => s === b[i])
|
|
3365
|
+
});
|
|
3353
3366
|
return new Proxy([], {
|
|
3354
3367
|
get(_, property) {
|
|
3355
3368
|
if (property === $TRACK) return subs();
|
package/dist/paths.d.ts
CHANGED
|
@@ -82,9 +82,29 @@ type TuplePaths<R extends readonly unknown[], PAcc extends Params> = R extends r
|
|
|
82
82
|
...infer T extends readonly unknown[]
|
|
83
83
|
] ? RouteContrib<H, PAcc> & TuplePaths<T, PAcc> : {};
|
|
84
84
|
type PathLeaf<Sch extends SearchTypes, C, PAcc extends Params> = PathEnd<Sch, Flat<PAcc>> & ChildPaths<C, PAcc>;
|
|
85
|
-
|
|
85
|
+
declare const PARAM_NEXT: unique symbol;
|
|
86
|
+
/**
|
|
87
|
+
* Sibling routes that share a param prefix (`/posts/:id`, `/posts/:id/edit`)
|
|
88
|
+
* each contribute a call at that node, and a call on an intersection of
|
|
89
|
+
* function types resolves to its first overload only. So the call reads its
|
|
90
|
+
* result back through `this` — the whole intersection — where the
|
|
91
|
+
* continuations of every sibling with the same arity have merged.
|
|
92
|
+
*/
|
|
93
|
+
interface ParamCall<A extends readonly unknown[]> {
|
|
94
|
+
(...args: A): this extends {
|
|
95
|
+
readonly [PARAM_NEXT]: {
|
|
96
|
+
[K in A["length"]]: infer N;
|
|
97
|
+
};
|
|
98
|
+
} ? N : never;
|
|
99
|
+
}
|
|
100
|
+
type ParamCallTo<A extends readonly unknown[], N> = ParamCall<A> & {
|
|
101
|
+
readonly [PARAM_NEXT]: {
|
|
102
|
+
[K in A["length"]]: N;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
type PathNode<Segs extends readonly string[], F, Sch extends SearchTypes, C, PAcc extends Params> = Segs extends readonly [infer H extends string, ...infer R extends readonly string[]] ? H extends `:${infer N}?` ? ParamCallTo<[ParamArg<N, F>], PathNode<R, F, Sch, C, PAcc & {
|
|
86
106
|
[K in N]?: string;
|
|
87
|
-
}
|
|
107
|
+
}>> & PathNode<R, F, Sch, C, PAcc & {
|
|
88
108
|
[K in N]?: string;
|
|
89
109
|
}> : H extends `:${string}` | `*${string}` ? ParamCallNode<Segs, F, Sch, C, PAcc> : {
|
|
90
110
|
[K in H]: PathNode<R, F, Sch, C, PAcc>;
|
|
@@ -93,7 +113,7 @@ type ParamCallNode<Segs extends readonly string[], F, Sch extends SearchTypes, C
|
|
|
93
113
|
args: infer A extends readonly unknown[];
|
|
94
114
|
params: infer P2 extends Params;
|
|
95
115
|
rest: infer R2 extends readonly string[];
|
|
96
|
-
} ?
|
|
116
|
+
} ? ParamCallTo<A, PathNode<R2, F, Sch, C, PAcc & P2>> & (R2 extends readonly [] ? {
|
|
97
117
|
(...args: [...A, Sch["input"], string?]): string;
|
|
98
118
|
} : {}) & TypedPath<Flat<PAcc & P2>> : never;
|
|
99
119
|
type RouteContrib<Def, PAcc extends Params> = Def extends {
|