@svadmin/core 0.36.1 → 0.36.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/core",
3
- "version": "0.36.1",
3
+ "version": "0.36.3",
4
4
  "author": "zuohuadong",
5
5
  "repository": {
6
6
  "type": "git",
@@ -638,10 +638,10 @@ export function useForm<
638
638
  });
639
639
  },
640
640
  onError: (error: unknown, _vars: unknown, context: unknown) => {
641
- const ctx = context as { previousQueries?: [unknown, unknown][] } | undefined;
641
+ const ctx = context as { previousQueries?: [readonly unknown[], unknown][] } | undefined;
642
642
  if (ctx?.previousQueries) {
643
643
  for (const [queryKey, data] of ctx.previousQueries) {
644
- queryClient.setQueryData(queryKey as string[], data);
644
+ queryClient.setQueryData(queryKey, data);
645
645
  }
646
646
  }
647
647
  if (error instanceof UndoError) return;
package/src/index.ts CHANGED
@@ -145,7 +145,7 @@ export {
145
145
  export { useParsed, resetGlobalPath, syncGlobalPath } from './useParsed.svelte';
146
146
  export * from './useStepsForm.svelte';
147
147
  export { createHashRouterProvider, createHistoryRouterProvider } from './router-provider';
148
- export type { RouterProvider } from './router-provider';
148
+ export type { RouterNavigationResult, RouterProvider } from './router-provider';
149
149
  export { inferFieldType, inferResource } from './inferencer';
150
150
  export type { InferResult } from './inferencer';
151
151
  export { createWebSocketLiveProvider } from './live-websocket';
@@ -88,7 +88,7 @@ export function deepMerge(target: unknown, source: unknown): unknown {
88
88
  interface MutationContext {
89
89
  _svadmin_ctx?: boolean;
90
90
  userContext?: unknown;
91
- previousQueries?: [unknown, unknown][];
91
+ previousQueries?: [readonly unknown[], unknown][];
92
92
  }
93
93
 
94
94
  interface MutationCallbacks {
@@ -359,7 +359,7 @@ export function useUpdate<TData extends BaseRecord = BaseRecord, TError = HttpEr
359
359
  const ctx = context as MutationContext | undefined;
360
360
  if (ctx?.previousQueries) {
361
361
  for (const [queryKey, data] of ctx.previousQueries) {
362
- queryClient.setQueryData(queryKey as string[], data);
362
+ queryClient.setQueryData(queryKey, data);
363
363
  }
364
364
  }
365
365
  if (error instanceof UndoError) return;
@@ -540,7 +540,7 @@ export function useDelete<TData extends BaseRecord = BaseRecord, TError = HttpEr
540
540
  const ctx = context as MutationContext | undefined;
541
541
  if (ctx?.previousQueries) {
542
542
  for (const [queryKey, data] of ctx.previousQueries) {
543
- queryClient.setQueryData(queryKey as string[], data);
543
+ queryClient.setQueryData(queryKey, data);
544
544
  }
545
545
  }
546
546
  if (error instanceof UndoError) return;
@@ -1,5 +1,7 @@
1
1
  // Router Provider — abstracts routing strategy (hash, history, SvelteKit, etc.)
2
2
 
3
+ export type RouterNavigationResult = false | ReturnType<() => void>;
4
+
3
5
  export interface RouterProvider {
4
6
  /** Navigate to a path */
5
7
  go: (options: {
@@ -7,7 +9,7 @@ export interface RouterProvider {
7
9
  query?: Record<string, string>;
8
10
  hash?: string;
9
11
  type?: 'push' | 'replace';
10
- }) => void;
12
+ }) => RouterNavigationResult | Promise<RouterNavigationResult>;
11
13
  /** Navigate back */
12
14
  back: () => void;
13
15
  /** Parse current URL into structured route info */
package/src/router.ts CHANGED
@@ -82,7 +82,8 @@ export async function navigateWithProvider(
82
82
  if (!allowed) return;
83
83
  }
84
84
  if (provider) {
85
- provider.go({ to: path, type: options?.replaceState ? 'replace' : 'push' });
85
+ const navigated = await provider.go({ to: path, type: options?.replaceState ? 'replace' : 'push' });
86
+ if (navigated === false) return;
86
87
  } else if (typeof window !== 'undefined') {
87
88
  window.location.hash = '#' + path.replace(/^#/, '');
88
89
  }