mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-12 08:05:44 +00:00
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>
29 lines
760 B
TypeScript
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}`)
|
|
}
|