Upgrade svelte templates to use @kksh/svelte5 (#29)

* chore: add workspace settings in root package.json

* update dependencies

* upgrade: @kksh/svelte to @kksh/svelte5 in two svelte tempaltes

* feat: add fallback for image multiplexer

* ci: remove bun.lockb from root to avoid cloudflare error
This commit is contained in:
Huakun Shen 2024-11-21 01:57:48 -05:00 committed by GitHub
parent ad30a8c3bb
commit b7724a25ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 481 additions and 397 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "kksh", "name": "kksh",
"module": "dist/cli.js", "module": "dist/cli.js",
"version": "0.0.23", "version": "0.0.24",
"type": "module", "type": "module",
"bin": { "bin": {
"kksh": "./dist/cli.js", "kksh": "./dist/cli.js",
@ -13,16 +13,10 @@
"test": "cross-env NODE_ENV=test bun test --coverage" "test": "cross-env NODE_ENV=test bun test --coverage"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/bun": "latest", "@types/bun": "latest",
"@types/debug": "^4.1.12", "@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"cross-env": "^7.0.3", "cross-env": "^7.0.3"
"rollup": "^4.24.0",
"rollup-plugin-visualizer": "^5.12.0"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5.0.0" "typescript": "^5.0.0"
@ -41,4 +35,4 @@
"files": [ "files": [
"dist" "dist"
] ]
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "create-kunkun", "name": "create-kunkun",
"type": "module", "type": "module",
"version": "0.1.33", "version": "0.1.34",
"bin": { "bin": {
"create-kunkun": "dist/index.mjs" "create-kunkun": "dist/index.mjs"
}, },
@ -11,17 +11,9 @@
"test": "bun test --coverage" "test": "bun test --coverage"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.7",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/bun": "latest", "@types/bun": "latest",
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"get-folder-size": "^5.0.0", "get-folder-size": "^5.0.0",
"rollup": "^4.24.0",
"rollup-plugin-visualizer": "^5.12.0",
"tar": "^7.4.3", "tar": "^7.4.3",
"vitest": "^2.0.0" "vitest": "^2.0.0"
}, },
@ -29,7 +21,7 @@
"typescript": "^5.0.0" "typescript": "^5.0.0"
}, },
"dependencies": { "dependencies": {
"@inquirer/prompts": "^5.2.1", "@inquirer/prompts": "^5.5.0",
"@kksh/api": "workspace:*", "@kksh/api": "workspace:*",
"chalk": "^5.3.0", "chalk": "^5.3.0",
"commander": "^12.1.0", "commander": "^12.1.0",
@ -40,4 +32,4 @@
"files": [ "files": [
"dist" "dist"
] ]
} }

View File

@ -21,7 +21,7 @@
"turbo": "^2.3.0", "turbo": "^2.3.0",
"typescript": "5.6.3" "typescript": "5.6.3"
}, },
"packageManager": "pnpm@9.12.3", "packageManager": "pnpm@9.14.1",
"engines": { "engines": {
"node": ">=22" "node": ">=22"
}, },
@ -50,5 +50,14 @@
"tauri-plugin-system-info-api": "workspace:*", "tauri-plugin-system-info-api": "workspace:*",
"valibot": "^0.40.0", "valibot": "^0.40.0",
"zod": "^3.23.8" "zod": "^3.23.8"
} },
} "workspaces": [
"apps/*",
"packages/*",
"packages/extensions/*",
"packages/templates/*",
"packages/tauri-plugins/*",
"vendors/tauri-plugin-network",
"vendors/tauri-plugin-system-info"
]
}

View File

@ -1,3 +1,4 @@
## Permission Table ## Permission Table
<table> <table>
@ -6,6 +7,7 @@
<th>Description</th> <th>Description</th>
</tr> </tr>
<tr> <tr>
<td> <td>

View File

@ -40,23 +40,23 @@
}, },
"dependencies": { "dependencies": {
"@kksh/api": "workspace:*", "@kksh/api": "workspace:*",
"@kksh/svelte": "0.1.4", "@kksh/svelte5": "0.1.10",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"lucide-svelte": "^0.416.0", "lucide-svelte": "^0.460.1",
"tailwind-merge": "^2.4.0", "tailwind-merge": "^2.5.4",
"tailwind-variants": "^0.2.1" "tailwind-variants": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.1",
"@tsconfig/svelte": "^5.0.4", "@tsconfig/svelte": "^5.0.4",
"svelte": "^5.0.3", "svelte": "^5.2.7",
"svelte-check": "^4.0.5", "svelte-check": "^4.0.9",
"tslib": "^2.8.0", "tslib": "^2.8.1",
"typescript": "~5.6.2", "typescript": "~5.6.3",
"vite": "^5.4.9", "vite": "^5.4.11",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.20",
"postcss": "^8.4.38", "postcss": "^8.4.49",
"tailwindcss": "^3.4.4" "tailwindcss": "^3.4.15"
}, },
"files": [ "files": [
"dist", "dist",

View File

@ -3,12 +3,12 @@
import { import {
Button, Button,
Command, Command,
CommandFooter, // CommandFooter,
ModeWatcher, ModeWatcher,
Separator, Separator,
ThemeWrapper, ThemeWrapper,
updateTheme updateTheme
} from "@kksh/svelte" } from "@kksh/svelte5"
import ThemeCustomizer from "$lib/components/ThemeCustomizer.svelte" import ThemeCustomizer from "$lib/components/ThemeCustomizer.svelte"
import { import {
Calculator, Calculator,
@ -49,23 +49,22 @@
<Command.List> <Command.List>
<Command.Empty>No results found.</Command.Empty> <Command.Empty>No results found.</Command.Empty>
<Command.Group heading="Suggestions"> <Command.Group heading="Suggestions">
<Command.Item onSelect={(v) => console.log("selected:", v)}> <Command.Item>
<Calendar class="mr-2 h-4 w-4" /> <Calendar class="mr-2 h-4 w-4" />
<span>Calendar</span> <span>Calendar</span>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log("selected:", v)}> <Command.Item>
<Smile class="mr-2 h-4 w-4" /> <Smile class="mr-2 h-4 w-4" />
<span>Search Emoji</span> <span>Search Emoji</span>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log("selected:", v)}> <Command.Item>
<Calculator class="mr-2 h-4 w-4" /> <Calculator class="mr-2 h-4 w-4" />
<span>Calculator</span> <span>Calculator</span>
</Command.Item> </Command.Item>
</Command.Group> </Command.Group>
<Command.Separator /> <Command.Separator />
<Command.Group heading="Settings"> <Command.Group heading="Settings">
<Command.Item onSelect={(v) => console.log("selected:", v)}> <Command.Item>
<User class="mr-2 h-4 w-4" /> <User class="mr-2 h-4 w-4" />
<span>Profile</span> <span>Profile</span>
<Command.Shortcut>⌘P</Command.Shortcut> <Command.Shortcut>⌘P</Command.Shortcut>
@ -75,7 +74,7 @@
<span>Billing</span> <span>Billing</span>
<Command.Shortcut>⌘B</Command.Shortcut> <Command.Shortcut>⌘B</Command.Shortcut>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log("selected:", v)}> <Command.Item>
<Settings class="mr-2 h-4 w-4" /> <Settings class="mr-2 h-4 w-4" />
<span>Settings</span> <span>Settings</span>
<Command.Shortcut>⌘S</Command.Shortcut> <Command.Shortcut>⌘S</Command.Shortcut>
@ -83,7 +82,7 @@
</Command.Group> </Command.Group>
</Command.List> </Command.List>
</div> </div>
<CommandFooter> <div class="flex items-center justify-between">
<SettingsIcon class="ml-2 h-4 w-4" /> <SettingsIcon class="ml-2 h-4 w-4" />
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<Button variant="ghost" size="sm"> <Button variant="ghost" size="sm">
@ -93,6 +92,6 @@
<Separator orientation="vertical" /> <Separator orientation="vertical" />
<ThemeCustomizer /> <ThemeCustomizer />
</div> </div>
</CommandFooter> </div>
</Command.Root> </Command.Root>
</ThemeWrapper> </ThemeWrapper>

View File

@ -1,4 +1,4 @@
@import url("@kksh/svelte/themes"); @import url("@kksh/svelte5/themes");
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { ui } from "@kksh/api/ui/iframe" import { ui } from "@kksh/api/ui/iframe"
import { ThemeCustomizerButton, updateTheme, type ThemeConfig } from "@kksh/svelte" import { ThemeCustomizerButton, updateTheme, type ThemeConfig } from "@kksh/svelte5"
import { onMount } from "svelte" import { onMount } from "svelte"
let config: ThemeConfig = { let config: ThemeConfig = {

View File

@ -5,7 +5,7 @@ const config: Config = {
darkMode: ["class"], darkMode: ["class"],
content: [ content: [
"./src/**/*.{html,js,svelte,ts}", "./src/**/*.{html,js,svelte,ts}",
"./node_modules/@kksh/svelte/dist/**/*.{html,js,svelte,ts}" "./node_modules/@kksh/svelte5/dist/**/*.{html,js,svelte,ts}"
], ],
safelist: ["dark"], safelist: ["dark"],
theme: { theme: {

View File

@ -46,35 +46,35 @@
}, },
"dependencies": { "dependencies": {
"@kksh/api": "workspace:*", "@kksh/api": "workspace:*",
"@kksh/svelte": "0.1.4", "@kksh/svelte5": "0.1.10",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"lucide-svelte": "^0.416.0", "lucide-svelte": "^0.460.1",
"mode-watcher": "^0.4.0", "mode-watcher": "^0.5.0",
"tailwind-merge": "^2.4.0", "tailwind-merge": "^2.5.4",
"tailwind-variants": "^0.2.1" "tailwind-variants": "^0.3.0"
}, },
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0", "@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/kit": "^2.0.0", "@sveltejs/kit": "^2.8.1",
"@sveltejs/vite-plugin-svelte": "^4.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.1",
"svelte": "^5.0.0", "svelte": "^5.2.7",
"svelte-check": "^4.0.0", "svelte-check": "^4.0.9",
"typescript": "^5.0.0", "typescript": "^5.6.3",
"vite": "^5.0.3", "vite": "^5.4.11",
"@sveltejs/adapter-static": "^3.0.6", "@sveltejs/adapter-static": "^3.0.6",
"@tailwindcss/typography": "^0.5.13", "@tailwindcss/typography": "^0.5.15",
"@types/eslint": "^9.6.0", "@types/eslint": "^9.6.1",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.20",
"eslint": "^9.0.0", "eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0", "eslint-plugin-svelte": "^2.46.0",
"globals": "^15.0.0", "globals": "^15.12.0",
"postcss": "^8.4.38", "postcss": "^8.4.49",
"prettier": "^3.1.1", "prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.1.2", "prettier-plugin-svelte": "^3.2.8",
"prettier-plugin-tailwindcss": "^0.6.4", "prettier-plugin-tailwindcss": "^0.6.9",
"tailwindcss": "^3.4.4", "tailwindcss": "^3.4.15",
"typescript-eslint": "^8.0.0-alpha.20" "typescript-eslint": "^8.15.0"
}, },
"type": "module", "type": "module",
"files": [ "files": [

View File

@ -1,4 +1,4 @@
@import url("@kksh/svelte/themes"); @import url("@kksh/svelte5/themes");
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { ThemeCustomizerButton, type ThemeConfig, updateTheme } from '@kksh/svelte'; import { ThemeCustomizerButton, type ThemeConfig, updateTheme } from '@kksh/svelte5';
import { ui } from '@kksh/api/ui/iframe'; import { ui } from '@kksh/api/ui/iframe';
import { onMount } from 'svelte'; import { onMount } from 'svelte';

View File

@ -1,7 +1,7 @@
<script> <script>
import '../app.css'; import '../app.css';
import { ModeWatcher } from 'mode-watcher'; import { ModeWatcher } from 'mode-watcher';
import { ThemeWrapper, updateTheme } from '@kksh/svelte'; import { ThemeWrapper, updateTheme } from '@kksh/svelte5';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { ui } from '@kksh/api/ui/iframe'; import { ui } from '@kksh/api/ui/iframe';

View File

@ -5,12 +5,11 @@
ModeToggle, ModeToggle,
Button, Button,
Command, Command,
CommandFooter,
ModeWatcher, ModeWatcher,
Separator, Separator,
ThemeWrapper, ThemeWrapper,
updateTheme updateTheme
} from '@kksh/svelte'; } from '@kksh/svelte5';
import ThemeCustomizer from '$lib/components/ThemeCustomizer.svelte'; import ThemeCustomizer from '$lib/components/ThemeCustomizer.svelte';
import { import {
Calculator, Calculator,
@ -44,23 +43,23 @@
<Command.List> <Command.List>
<Command.Empty>No results found.</Command.Empty> <Command.Empty>No results found.</Command.Empty>
<Command.Group heading="Suggestions"> <Command.Group heading="Suggestions">
<Command.Item onSelect={(v) => console.log('selected:', v)}> <Command.Item>
<Calendar class="mr-2 h-4 w-4" /> <Calendar class="mr-2 h-4 w-4" />
<span>Calendar</span> <span>Calendar</span>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log('selected:', v)}> <Command.Item>
<Smile class="mr-2 h-4 w-4" /> <Smile class="mr-2 h-4 w-4" />
<span>Search Emoji</span> <span>Search Emoji</span>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log('selected:', v)}> <Command.Item>
<Calculator class="mr-2 h-4 w-4" /> <Calculator class="mr-2 h-4 w-4" />
<span>Calculator</span> <span>Calculator</span>
</Command.Item> </Command.Item>
</Command.Group> </Command.Group>
<Command.Separator /> <Command.Separator />
<Command.Group heading="Settings"> <Command.Group heading="Settings">
<Command.Item onSelect={(v) => console.log('selected:', v)}> <Command.Item>
<User class="mr-2 h-4 w-4" /> <User class="mr-2 h-4 w-4" />
<span>Profile</span> <span>Profile</span>
<Command.Shortcut>⌘P</Command.Shortcut> <Command.Shortcut>⌘P</Command.Shortcut>
@ -70,7 +69,7 @@
<span>Billing</span> <span>Billing</span>
<Command.Shortcut>⌘B</Command.Shortcut> <Command.Shortcut>⌘B</Command.Shortcut>
</Command.Item> </Command.Item>
<Command.Item onSelect={(v) => console.log('selected:', v)}> <Command.Item>
<Settings class="mr-2 h-4 w-4" /> <Settings class="mr-2 h-4 w-4" />
<span>Settings</span> <span>Settings</span>
<Command.Shortcut>⌘S</Command.Shortcut> <Command.Shortcut>⌘S</Command.Shortcut>
@ -78,7 +77,7 @@
</Command.Group> </Command.Group>
</Command.List> </Command.List>
</div> </div>
<CommandFooter> <div class="flex items-center justify-between">
<SettingsIcon class="ml-2 h-4 w-4" /> <SettingsIcon class="ml-2 h-4 w-4" />
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<Button variant="ghost" size="sm"> <Button variant="ghost" size="sm">
@ -88,7 +87,7 @@
<Separator orientation="vertical" /> <Separator orientation="vertical" />
<a href="{base}/about"><Button>About Page</Button></a> <a href="{base}/about"><Button>About Page</Button></a>
<Button <Button
on:click={async () => { onclick={async () => {
toast.success(await clipboard.readText()); toast.success(await clipboard.readText());
}} }}
> >
@ -97,6 +96,6 @@
<ModeToggle /> <ModeToggle />
<ThemeCustomizer /> <ThemeCustomizer />
</div> </div>
</CommandFooter> </div>
</Command.Root> </Command.Root>
</ThemeWrapper> </ThemeWrapper>

View File

@ -1,6 +1,6 @@
<script> <script>
import { base } from '$app/paths'; import { base } from '$app/paths';
import { Alert, Button, ThemeWrapper } from '@kksh/svelte'; import { Alert, Button, ThemeWrapper } from '@kksh/svelte5';
</script> </script>
<ThemeWrapper> <ThemeWrapper>

View File

@ -5,7 +5,7 @@ const config: Config = {
darkMode: ['class'], darkMode: ['class'],
content: [ content: [
'./src/**/*.{html,js,svelte,ts}', './src/**/*.{html,js,svelte,ts}',
'node_modules/@kksh/svelte/dist/**/*.{html,js,svelte,ts}' 'node_modules/@kksh/svelte5/dist/**/*.{html,js,svelte,ts}'
], ],
safelist: ['dark'], safelist: ['dark'],
theme: { theme: {

View File

@ -9,16 +9,29 @@
class: className, class: className,
...restProps ...restProps
}: { icon: TIcon; class?: string; [key: string]: any } = $props() }: { icon: TIcon; class?: string; [key: string]: any } = $props()
let remoteIconError = $state(false)
</script> </script>
{#if icon.type === IconEnum.RemoteUrl} {#if icon.type === IconEnum.RemoteUrl}
<img {#if !remoteIconError}
loading="lazy" <img
class={cn("", className, { invert: icon.invert })} loading="lazy"
src={icon.value} class={cn("", className, { invert: icon.invert })}
alt="" src={icon.value}
{...restProps} alt=""
/> onerror={() => {
remoteIconError = true
}}
{...restProps}
/>
{:else}
<Icon
icon="carbon:unknown-filled"
class={cn("", className, { invert: icon.invert })}
{...restProps}
/>
{/if}
{:else if icon.type === IconEnum.Iconify} {:else if icon.type === IconEnum.Iconify}
<Icon icon={icon.value} class={cn("", className, { invert: icon.invert })} {...restProps} /> <Icon icon={icon.value} class={cn("", className, { invert: icon.invert })} {...restProps} />
{:else if icon.type === IconEnum.Base64PNG} {:else if icon.type === IconEnum.Base64PNG}

View File

@ -3,7 +3,7 @@
import { Command } from "@kksh/svelte5" import { Command } from "@kksh/svelte5"
import { IconMultiplexer } from "../../common" import { IconMultiplexer } from "../../common"
let { item, onSelect }: { item: ListSchema.Item; onSelect?: () => void } = $props() const { item, onSelect }: { item: ListSchema.Item; onSelect?: () => void } = $props()
</script> </script>
<Command.Item class="gap-2" {onSelect} value={JSON.stringify(item)}> <Command.Item class="gap-2" {onSelect} value={JSON.stringify(item)}>

View File

@ -7,6 +7,7 @@
import { type PaneAPI } from "paneforge" import { type PaneAPI } from "paneforge"
import { onMount, type Snippet } from "svelte" import { onMount, type Snippet } from "svelte"
import { StrikeSeparator } from "../../common" import { StrikeSeparator } from "../../common"
import { DraggableCommandGroup } from "../../custom"
import ListDetail from "./list-detail.svelte" import ListDetail from "./list-detail.svelte"
import ListItem from "./list-item.svelte" import ListItem from "./list-item.svelte"
@ -58,6 +59,10 @@
highlightedValue = value highlightedValue = value
} }
$effect(() => {
console.log("onListItemSelected", onListItemSelected)
})
$effect(() => { $effect(() => {
if (highlightedValue.startsWith("{")) { if (highlightedValue.startsWith("{")) {
onHighlightedItemChanged?.(JSON.parse(highlightedValue).value) onHighlightedItemChanged?.(JSON.parse(highlightedValue).value)
@ -138,19 +143,14 @@
<Command.List class="h-full max-h-screen" onscroll={onScroll}> <Command.List class="h-full max-h-screen" onscroll={onScroll}>
<Command.Empty>No results found.</Command.Empty> <Command.Empty>No results found.</Command.Empty>
{#each listViewContent.sections || [] as section} {#each listViewContent.sections || [] as section}
<Command.Group heading={section.title}> <DraggableCommandGroup heading={section.title}>
{#each section.items as item} {#each section.items as item}
<ListItem {item} /> <ListItem {item} onSelect={() => onListItemSelected?.(item.value)} />
{/each} {/each}
</Command.Group> </DraggableCommandGroup>
{/each} {/each}
{#each listViewContent.items || [] as item} {#each listViewContent.items || [] as item}
<ListItem <ListItem {item} onSelect={() => onListItemSelected?.(item.value)} />
{item}
onSelect={() => {
onListItemSelected?.(item.value)
}}
/>
{/each} {/each}
{#if loading} {#if loading}
<StrikeSeparator class="h-20"> <StrikeSeparator class="h-20">

658
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,4 @@ packages:
- "packages/tauri-plugins/*" - "packages/tauri-plugins/*"
- "vendors/tauri-plugin-network" - "vendors/tauri-plugin-network"
- "vendors/tauri-plugin-system-info" - "vendors/tauri-plugin-system-info"
- "vendors/kkrpc/packages/kkrpc"
- "vendors/tauri-api-adapter/packages/tauri-api-adapter"