Files
windmill/frontend/src/lib/navigation.ts
T
Ruben FiszelandClaude Opus 4.5 203f6785c4 fix: isolate SvelteKit-specific imports for library usage
Split SvelteKit-specific code into separate files to allow
windmill-components to be used as a library in non-SvelteKit
contexts (e.g., windmill-react-sdk):

- Split logout.ts into logout.ts and logoutKit.ts
- Split svelte5Utils.svelte.ts into svelte5Utils.svelte.ts and
  svelte5UtilsKit.svelte.ts (for runed/kit useSearchParams)
- Fix triggers/utils.ts type-only import resolution
- Update FlowRestartButton to use callback instead of direct navigation
- Update all route files to import from logoutKit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 00:25:32 +00:00

29 lines
760 B
TypeScript

import { goto as svelteGoto } from '$app/navigation'
import { base as svelteBase } from '$app/paths'
export function goto(path: string, options = {}) {
if (svelteBase == '' || path.startsWith('?')) {
return svelteGoto(path, options)
} else {
const fullPath = path.startsWith(svelteBase) ? path : `${svelteBase}${path}`
return svelteGoto(fullPath, options)
}
}
export async function setQuery(
url: URL,
key: string,
value: string | undefined,
currentHash: string | undefined = undefined
): Promise<void> {
if (value !== undefined) {
url.searchParams.set(key, value)
} else {
url.searchParams.delete(key)
}
let searchParams = url.searchParams.toString()
await goto(currentHash ? `?${searchParams}${currentHash}` : `?${searchParams}`)
}