Files
windmill/frontend/src/lib/components/HighlightCode.svelte
Pyra d36760bff7 feat: workspace dependencies (#7124)
* commit raw requirements

Signed-off-by: pyranota <pyra@duck.com>

* raw requirements

Signed-off-by: pyranota <pyra@duck.com>

* implement `parse_annotation`

Signed-off-by: pyranota <pyra@duck.com>

* more progress on wdeps

Signed-off-by: pyranota <pyra@duck.com>

* more progress

Signed-off-by: pyranota <pyra@duck.com>

* fixes

Signed-off-by: pyranota <pyra@duck.com>

* more progress

Signed-off-by: pyranota <pyra@duck.com>

* fixes

Signed-off-by: pyranota <pyra@duck.com>

* cli improvements + raw deps

Signed-off-by: pyranota <pyra@duck.com>

* cleanup

Signed-off-by: pyranota <pyra@duck.com>

* fix python versions

Signed-off-by: pyranota <pyra@duck.com>

* progress

Signed-off-by: pyranota <pyra@duck.com>

* update :)

Signed-off-by: pyranota <pyra@duck.com>

* add MaybeLock

Signed-off-by: pyranota <pyra@duck.com>

* go WIP

Signed-off-by: pyranota <pyra@duck.com>

* fix python ignoring py version from requirements

Signed-off-by: pyranota <pyra@duck.com>

* optimize php

Signed-off-by: pyranota <pyra@duck.com>

* require admin to alter

Signed-off-by: pyranota <pyra@duck.com>

* fix(cli): flow generateLocks raw deps

Signed-off-by: pyranota <pyra@duck.com>

* progress in checklist

Signed-off-by: pyranota <pyra@duck.com>

* fix agent workers

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* nit: remove default features

Signed-off-by: pyranota <pyra@duck.com>

* oh-wow

Signed-off-by: pyranota <pyra@duck.com>

* remove dbg!

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* add indexes

Signed-off-by: pyranota <pyra@duck.com>

* cleanup

Signed-off-by: pyranota <pyra@duck.com>

* nits

Signed-off-by: pyranota <pyra@duck.com>

* remove todos

Signed-off-by: pyranota <pyra@duck.com>

* fix cli

Signed-off-by: pyranota <pyra@duck.com>

* add debug flag

Signed-off-by: pyranota <pyra@duck.com>

* cli: remove noise

Signed-off-by: pyranota <pyra@duck.com>

* fix cli

Signed-off-by: pyranota <pyra@duck.com>

* remove todos

Signed-off-by: pyranota <pyra@duck.com>

* trigger deps correctly

Signed-off-by: pyranota <pyra@duck.com>

* fix frontend

Signed-off-by: pyranota <pyra@duck.com>

* fix frontend again

Signed-off-by: pyranota <pyra@duck.com>

* finally fix frontend

Signed-off-by: pyranota <pyra@duck.com>

* ee repo ref

Signed-off-by: pyranota <pyra@duck.com>

* fix all

Signed-off-by: pyranota <pyra@duck.com>

* more fixes...

Signed-off-by: pyranota <pyra@duck.com>

* remove test

Signed-off-by: pyranota <pyra@duck.com>

* Update backend-test.yml

* comment out legacy test

Signed-off-by: pyranota <pyra@duck.com>

* fix ci

Signed-off-by: pyranota <pyra@duck.com>

* fix ci?

Signed-off-by: pyranota <pyra@duck.com>

* comment out thing

Signed-off-by: pyranota <pyra@duck.com>

* ignore test

Signed-off-by: pyranota <pyra@duck.com>

* ci

Signed-off-by: pyranota <pyra@duck.com>

* base fixture

Signed-off-by: pyranota <pyra@duck.com>

* fix regression

Signed-off-by: pyranota <pyra@duck.com>

* fix docs links

Signed-off-by: pyranota <pyra@duck.com>

* update min version

Signed-off-by: pyranota <pyra@duck.com>

* simplify

* implement cache for get_latest

Signed-off-by: pyranota <pyra@duck.com>

* move to workspace settings

Signed-off-by: pyranota <pyra@duck.com>

* sqlx + migration

Signed-off-by: pyranota <pyra@duck.com>

* more migrations

Signed-off-by: pyranota <pyra@duck.com>

* use box pin

Signed-off-by: pyranota <pyra@duck.com>

* nit

Signed-off-by: pyranota <pyra@duck.com>

---------

Signed-off-by: pyranota <pyra@duck.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2025-11-28 16:00:11 +00:00

148 lines
3.6 KiB
Svelte

<script lang="ts">
import Highlight, { LineNumbers } from 'svelte-highlight'
import python from 'svelte-highlight/languages/python'
import typescript from 'svelte-highlight/languages/typescript'
import go from 'svelte-highlight/languages/go'
import shell from 'svelte-highlight/languages/shell'
import graphql from 'svelte-highlight/languages/graphql'
import javascript from 'svelte-highlight/languages/javascript'
import sql from 'svelte-highlight/languages/sql'
import powershell from 'svelte-highlight/languages/powershell'
import php from 'svelte-highlight/languages/php'
import rust from 'svelte-highlight/languages/rust'
import csharp from 'svelte-highlight/languages/csharp'
import yaml from 'svelte-highlight/languages/yaml'
import java from 'svelte-highlight/languages/java'
import ruby from 'svelte-highlight/languages/ruby'
import type { Script } from '$lib/gen'
import { Button } from './common'
import { copyToClipboard } from '$lib/utils'
import { ClipboardCopy } from 'lucide-svelte'
import HighlightTheme from './HighlightTheme.svelte'
import { json, type LanguageType } from 'svelte-highlight/languages'
interface Props {
code?: string
language: Script['language'] | 'bunnative' | 'frontend' | 'json' | undefined
highlightLanguage?: LanguageType<string> | undefined
lines?: boolean
className?: string
onApplyCode?: () => void
showApplyButton?: boolean
applyButtonIcon?: typeof ClipboardCopy
}
let {
code = '',
language,
highlightLanguage = undefined,
lines = false,
className = '',
onApplyCode = undefined,
showApplyButton = false,
applyButtonIcon = undefined
}: Props = $props()
function getLang(lang: Script['language'] | 'bunnative' | 'frontend' | 'json' | undefined) {
switch (lang) {
case 'python3':
return python
case 'deno':
return typescript
case 'nativets':
return typescript
case 'bun':
return typescript
case 'bunnative':
return typescript
case 'go':
return go
case 'bash':
return shell
case 'frontend':
return javascript
case 'graphql':
return graphql
case 'mysql':
return sql
case 'postgresql':
return sql
case 'snowflake':
return sql
case 'bigquery':
return sql
case 'oracledb':
return sql
case 'duckdb':
return sql
case 'powershell':
return powershell
case 'php':
return php
case 'rust':
return rust
case 'csharp':
return csharp
case 'nu':
return python
case 'ansible':
return yaml
case 'java':
return java
case 'ruby':
return ruby
case 'json':
return json
// for related places search: ADD_NEW_LANG
default:
return typescript
}
}
const lang = $derived(highlightLanguage ?? getLang(language))
</script>
<HighlightTheme />
<div class="relative">
<Button
wrapperClasses="absolute top-2 right-2 z-20"
onclick={() => copyToClipboard(code)}
color="light"
size="xs2"
startIcon={{
icon: ClipboardCopy
}}
iconOnly
title="Copy to clipboard"
/>
{#if showApplyButton}
<Button
wrapperClasses="absolute top-2 right-10 z-20"
onclick={onApplyCode}
color="light"
size="xs2"
startIcon={{
icon: applyButtonIcon
}}
iconOnly
title="Apply code"
/>
{/if}
<div class="overflow-x-auto">
{#if code?.length < 10000}
{#if !lines}
<Highlight class="nowrap {className}" language={lang} {code} />
{:else}
<Highlight class="nowrap {className}" language={lang} {code} let:highlighted>
<LineNumbers {highlighted} />
</Highlight>
{/if}
{:else}
<pre class="overflow-auto max-h-screen text-xs {className}"
><code class="language-{language}">{code}</code></pre
>
{/if}
</div>
</div>