clear-react-router 1.4.8 → 1.4.9
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 +5 -4
- package/dist/utils/adapter.d.ts +2 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -733,20 +733,21 @@ var adapter = {
|
|
|
733
733
|
parse: (params) => params.map((param) => new Date(Number(param))),
|
|
734
734
|
serialize: (args) => args.map((arg) => String(arg.getTime()))
|
|
735
735
|
},
|
|
736
|
-
zodSchema: {
|
|
737
|
-
parse: (
|
|
736
|
+
zodSchema: (schema) => ({
|
|
737
|
+
parse: (params) => {
|
|
738
738
|
let parsed;
|
|
739
739
|
try {
|
|
740
|
-
parsed = JSON.parse(params[0]
|
|
740
|
+
parsed = params[0] ? JSON.parse(params[0]) : void 0;
|
|
741
741
|
} catch {
|
|
742
742
|
throw new Error("Invalid JSON");
|
|
743
743
|
}
|
|
744
|
+
if (parsed === void 0) return void 0;
|
|
744
745
|
const result = schema.safeParse(parsed);
|
|
745
746
|
if (!result.success) throw new Error("Invalid schema");
|
|
746
747
|
return result.data;
|
|
747
748
|
},
|
|
748
749
|
serialize: JSON.stringify
|
|
749
|
-
}
|
|
750
|
+
})
|
|
750
751
|
};
|
|
751
752
|
//#endregion
|
|
752
753
|
export { Link, Router, RouterProvider, adapter, createRouter, useBeforeUnload, useBlocker, useHistoricalTrail, useLoaderState, useLocation, useNavigate, useParams, useQueryParam, useRouterContext, useSearchParams };
|
package/dist/utils/adapter.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Adapter } from '../types/global';
|
|
1
2
|
type ZodInterface<T> = {
|
|
2
3
|
safeParse(input: unknown): {
|
|
3
4
|
success: true;
|
|
@@ -45,12 +46,6 @@ export declare const adapter: {
|
|
|
45
46
|
parse: (params: string[]) => Date[];
|
|
46
47
|
serialize: (args: Date[]) => string[];
|
|
47
48
|
};
|
|
48
|
-
zodSchema:
|
|
49
|
-
parse: <T>(schema: ZodInterface<T>) => (params: string[]) => T;
|
|
50
|
-
serialize: {
|
|
51
|
-
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
52
|
-
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
49
|
+
zodSchema: <T>(schema: ZodInterface<T>) => Adapter<T>;
|
|
55
50
|
};
|
|
56
51
|
export {};
|