@solidjs/router 2.0.0-next.29 → 2.0.0-next.30

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/index.js CHANGED
@@ -553,7 +553,6 @@ function serverRouteOf(component) {
553
553
  */
554
554
  function serverRouteArgs(route, params, query) {
555
555
  const schema = route.key?.search;
556
- let search;
557
556
  if (schema) {
558
557
  const raw = {
559
558
  ...query
@@ -561,13 +560,22 @@ function serverRouteArgs(route, params, query) {
561
560
  const outcome = validateSearch(schema, raw);
562
561
  // Issues leave the raw values in place, matching useSearchParams: search
563
562
  // strings are user input, so defaults belong in the schema itself.
564
- search = outcome.issues ? raw : outcome.value;
563
+ return {
564
+ params: {
565
+ ...params
566
+ },
567
+ search: outcome.issues ? raw : outcome.value
568
+ };
565
569
  }
570
+ // No schema: leave the key out rather than carrying `search: undefined` —
571
+ // the args are sent as plain JSON by default and the runtime's JSON-safety
572
+ // check rejects explicit `undefined` (#615). Destructuring on the server
573
+ // reads the same either way, and the args-memo equality treats an absent
574
+ // key and undefined alike.
566
575
  return {
567
576
  params: {
568
577
  ...params
569
- },
570
- search
578
+ }
571
579
  };
572
580
  }
573
581
  const shallowEqual = (a, b) => a === b || !!a && !!b && typeof a === "object" && typeof b === "object" && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every(k => a[k] === b[k]);
@@ -12,15 +12,19 @@ export function serverRouteOf(component) {
12
12
  */
13
13
  export function serverRouteArgs(route, params, query) {
14
14
  const schema = route.key?.search;
15
- let search;
16
15
  if (schema) {
17
16
  const raw = { ...query };
18
17
  const outcome = validateSearch(schema, raw);
19
18
  // Issues leave the raw values in place, matching useSearchParams: search
20
19
  // strings are user input, so defaults belong in the schema itself.
21
- search = outcome.issues ? raw : outcome.value;
20
+ return { params: { ...params }, search: outcome.issues ? raw : outcome.value };
22
21
  }
23
- return { params: { ...params }, search };
22
+ // No schema: leave the key out rather than carrying `search: undefined` —
23
+ // the args are sent as plain JSON by default and the runtime's JSON-safety
24
+ // check rejects explicit `undefined` (#615). Destructuring on the server
25
+ // reads the same either way, and the args-memo equality treats an absent
26
+ // key and undefined alike.
27
+ return { params: { ...params } };
24
28
  }
25
29
  const shallowEqual = (a, b) => a === b ||
26
30
  (!!a &&
package/dist/types.d.ts CHANGED
@@ -144,12 +144,21 @@ export type RouteSectionComponent<T = unknown, P extends Params = Params> = Comp
144
144
  /**
145
145
  * What a server component route is called with (experimental): the params
146
146
  * the route's pattern (and its ancestors') declares, plus — only when the
147
- * route declares a `search` schema — that schema's validated output.
147
+ * route declares a `search` schema — that schema's validated output. Without
148
+ * a schema the `search` key is ABSENT, not `undefined`: the args travel as
149
+ * plain JSON by default, and the runtime's JSON-safety check rejects
150
+ * explicit `undefined` (#615). The type mirrors that — optional exactly when
151
+ * the search type admits undefined, required when a schema narrows it.
148
152
  */
149
- export interface ServerRouteArgs<P extends Params | TypedRouteConfig = Params, S = undefined> {
153
+ export type ServerRouteArgs<P extends Params | TypedRouteConfig = Params, S = undefined> = {
150
154
  params: ServerRouteParams<P>;
151
- search: P extends TypedRouteConfig ? SearchOutputOf<P> : S;
152
- }
155
+ } & (undefined extends ServerRouteSearch<P, S> ? {
156
+ search?: ServerRouteSearch<P, S>;
157
+ } : {
158
+ search: ServerRouteSearch<P, S>;
159
+ });
160
+ /** The search half of {@link ServerRouteArgs}: schema output when declared. */
161
+ export type ServerRouteSearch<P, S> = P extends TypedRouteConfig ? SearchOutputOf<P> : S;
153
162
  /**
154
163
  * `ServerRouteArgs<typeof route>`: a `defineFileRoute` config is a witness —
155
164
  * params from its pattern, search from its schema — the way
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "Ryan Turnquist"
7
7
  ],
8
8
  "license": "MIT",
9
- "version": "2.0.0-next.29",
9
+ "version": "2.0.0-next.30",
10
10
  "homepage": "https://github.com/solidjs/solid-router#readme",
11
11
  "repository": {
12
12
  "type": "git",