Skip to content

Commit

Permalink
chore: more migration
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Nov 13, 2024
1 parent 350247a commit 2e55ae6
Show file tree
Hide file tree
Showing 24 changed files with 798 additions and 480 deletions.
2 changes: 1 addition & 1 deletion app/app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _: {
{
packages = {
app = jsPkgs.buildNpmPackage {
npmDepsHash = "sha256-JL4Hx04dLW4AgZE1lFlTbQvXhLgsiomfzLChn+KbPZY=";
npmDepsHash = "";
src = ./.;
sourceRoot = "app";
npmFlags = [
Expand Down
433 changes: 158 additions & 275 deletions app/package-lock.json

Large diffs are not rendered by default.

63 changes: 32 additions & 31 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,57 @@
"@cosmjs/stargate": "0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/query-core": "^5.55.4",
"@tanstack/svelte-query": "^5.55.4",
"@tanstack/svelte-table": "^8.20.5",
"@tanstack/svelte-virtual": "^3.10.7",
"@tanstack/query-core": "^5.59.20",
"@tanstack/svelte-query": "^5.59.20",
"@tanstack/svelte-table": "9.0.0-alpha.10",
"@tanstack/svelte-virtual": "^3.10.9",
"@unionlabs/client": "^0.0.39",
"@wagmi/connectors": "^5.3.5",
"@wagmi/core": "^2.14.3",
"gql.tada": "^1.8.7",
"graphql-request": "7.1.0",
"@wagmi/connectors": "^5.3.9",
"@wagmi/core": "^2.14.5",
"gql.tada": "^1.8.10",
"graphql-request": "7.1.2",
"svelte-persisted-store": "^0.12.0",
"svelte-radix": "^2.0.1",
"svelte-ux": "^0.74.7",
"svelte-ux": "^0.75.4",
"temporal-polyfill": "^0.2.5",
"three": "^0.168.0",
"valibot": "^0.41.0",
"viem": "^2.21.43"
"three": "^0.170.0",
"valibot": "^0.42.1",
"viem": "^2.21.45"
},
"devDependencies": {
"@iconify-json/fa6-solid": "^1.2.0",
"@iconify-json/logos": "^1.2.0",
"@iconify-json/lucide": "^1.2.3",
"@iconify-json/mdi": "^1.2.0",
"@iconify-json/tabler": "^1.2.1",
"@keplr-wallet/types": "^0.12.127",
"@iconify-json/fa6-solid": "^1.2.1",
"@iconify-json/logos": "^1.2.3",
"@iconify-json/lucide": "^1.2.14",
"@iconify-json/mdi": "^1.2.1",
"@iconify-json/tabler": "^1.2.7",
"@keplr-wallet/types": "^0.12.155",
"@leapwallet/types": "^0.0.5",
"@melt-ui/pp": "^0.3.2",
"@melt-ui/svelte": "^0.83.0",
"@svelte-put/shortcut": "^3.1.1",
"@melt-ui/svelte": "^0.86.0",
"@svelte-put/shortcut": "^4.0.0",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.8.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"@tanstack/svelte-query-devtools": "^5.55.4",
"@tanstack/svelte-query-devtools": "^5.59.20",
"@tanstack/table-core": "^9.0.0-alpha.10",
"@total-typescript/ts-reset": "^0.6.1",
"@types/node": "^22.5.4",
"@types/node": "^22.9.0",
"@types/postcss-import": "^14.0.3",
"@types/three": "^0.168.0",
"@types/three": "^0.170.0",
"autoprefixer": "^10.4.20",
"bits-ui": "^1.0.0-next.52",
"clsx": "^2.1.1",
"fluid-tailwind": "^1.0.3",
"fluid-tailwind": "^1.0.4",
"graphql": "^16.9.0",
"lucide-svelte": "^0.456.0",
"mode-watcher": "^0.4.1",
"paneforge": "^1.0.0-next.1",
"patch-package": "^8.0.0",
"postcss": "^8.4.45",
"postcss": "^8.4.49",
"postcss-import": "^16.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"svelte": "^5.1.16",
Expand All @@ -80,14 +81,14 @@
"svelte-sonner": "^0.3.28",
"tailwind-merge": "^2.5.4",
"tailwind-scrollbar": "^3.1.0",
"tailwind-variants": "^0.2.1",
"tailwindcss": "^3.4.10",
"tailwind-variants": "^0.3.0",
"tailwindcss": "^3.4.14",
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.7.0",
"tsx": "^4.19.0",
"tslib": "^2.8.1",
"tsx": "^4.19.2",
"typed-query-selector": "^2.12.0",
"typescript": "^5.6.2",
"unplugin-icons": "^0.19.3",
"typescript": "^5.6.3",
"unplugin-icons": "^0.20.1",
"vaul-svelte": "^1.0.0-next.2",
"vite": "^5.4.11",
"vite-plugin-inspect": "^0.8.7",
Expand Down
1 change: 1 addition & 0 deletions app/src/lib/components/chains-gate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Props {
let { children }: Props = $props()
let chains = chainsQuery()
const EMPTY_CHAINS: Array<Chain> = []
Expand Down
15 changes: 10 additions & 5 deletions app/src/lib/components/explorer-breadcrumbs.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script lang="ts">
import { page } from "$app/stores"
import LoadingLogo from "$lib/components/loading-logo.svelte"
import TablePackets from "$lib/components/tables/packets.svelte"
import { derived } from "svelte/store"
import { onMount } from 'svelte'
// import { derived } from "svelte/store"
const pathComponents = derived(page, $page => $page.url.pathname.split("/").slice(2))
// const pathComponents = derived(page, $page => $page.url.pathname.split("/").slice(2))
const pathComponents = $derived($page.url.pathname.split("/").slice(2))
onMount(() => {
console.info(pathComponents)
})
</script>

<nav>
<div class="flex overflow-x-auto text-sm">
{#each $pathComponents as pathComponent, index}
{#each pathComponents as pathComponent, index}
{@const pathUrl = $page.url.pathname.split("/").slice(0, index+3).join("/")}
<a class="block border-b px-2 py-1 border-r" href={pathUrl}>{pathComponent}</a>
{/each}
Expand Down
12 changes: 9 additions & 3 deletions app/src/lib/components/explorer-pagination.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!-- @migration-task Error while migrating Svelte code: can't migrate `$: live = $timestamp === null` to `$derived` because there's a variable named derived.
Rename the variable and try again or migrate by hand. -->
<!-- @migration-task Error while migrating Svelte code: can't migrate `$: live = $timestamp === null` to `$derived` because there's a variable named derived.
Rename the variable and try again or migrate by hand. -->
<!-- @migration-task Error while migrating Svelte code: can't migrate `$: live = $timestamp === null` to `$derived` because there's a variable named derived.
Rename the variable and try again or migrate by hand. -->
<!-- @migration-task Error while migrating Svelte code: can't migrate `$: live = $timestamp === null` to `$derived` because there's a variable named derived.
Rename the variable and try again or migrate by hand. -->
<script lang="ts">
Expand Down Expand Up @@ -45,7 +51,7 @@ const onCurrentClick = () => {
<Button
size="sm"
variant="default"
on:click={onCurrentClick}
onclick={onCurrentClick}
disabled={live}
title={live ? "Already on the newest page" : "Go to the first page"}
>
Expand All @@ -56,7 +62,7 @@ const onCurrentClick = () => {
size="sm"
variant="secondary"
title={live ? "Already on the newest page" : "Go to the previous page"}
on:click={onNewerPage}
onclick={onNewerPage}
class="pl-2"
>
<ChevronLeft class="size-6" />
Expand All @@ -67,7 +73,7 @@ const onCurrentClick = () => {
<Button
size="sm"
variant="secondary"
on:click={onOlderPage}
onclick={onOlderPage}
class="pr-2"
>
Older
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/components/explorer-table-paginated.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let { queryResult, columns, dataStore }: Props = $props()

{#if $queryResult.data}
<Table {dataStore} {columns} />
<ExplorerPagination explorerItems={dataStore} />
<!-- <ExplorerPagination explorerItems={dataStore} /> -->
{:else if $queryResult.status === "pending"}
<LoadingLogo class="size-16" />
{/if}
3 changes: 3 additions & 0 deletions app/src/lib/components/navigation/navigation.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<!-- @migration-task Error while migrating Svelte code: Cannot read properties of undefined (reading 'end') -->
<!-- @migration-task Error while migrating Svelte code: Cannot read properties of undefined (reading 'end') -->
<!-- @migration-task Error while migrating Svelte code: Cannot read properties of undefined (reading 'end') -->
<!-- @migration-task Error while migrating Svelte code: Cannot read properties of undefined (reading 'end') -->
<script lang="ts">
import { routes } from "./index.ts"
import { cn } from "$lib/utilities/shadcn.ts"
Expand Down
3 changes: 3 additions & 0 deletions app/src/lib/components/spinning-outline-logo.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- @migration-task Error while migrating Svelte code: Attribute values containing `{...}` must be enclosed in quote marks, unless the value only contains the expression -->
<!-- @migration-task Error while migrating Svelte code: Attribute values containing `{...}` must be enclosed in quote marks, unless the value only contains the expression -->
<!-- @migration-task Error while migrating Svelte code: Attribute values containing `{...}` must be enclosed in quote marks, unless the value only contains the expression -->
<script lang="ts">
import Square from './spinning-logo/square.svelte';
let cubeWidth = 64;
Expand Down
46 changes: 46 additions & 0 deletions app/src/lib/components/table/flex-render.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts" module>
import type { CellContext, ColumnDefTemplate, HeaderContext } from "@tanstack/table-core";
type TData = unknown;
type TValue = unknown;
type TContext = unknown;
</script>

<script
lang="ts"
generics="TData, TValue, TContext extends HeaderContext<TData, TValue> | CellContext<TData, TValue>"
>
import {
RenderComponentConfig,
RenderSnippetConfig,
} from "./render-helpers.js";
type Props = {
/** The cell or header field of the current cell's column definition. */
content?: TContext extends HeaderContext<TData, TValue>
? ColumnDefTemplate<HeaderContext<TData, TValue>>
: TContext extends CellContext<TData, TValue>
? ColumnDefTemplate<CellContext<TData, TValue>>
: never;
/** The result of the `getContext()` function of the header or cell */
context: TContext;
};
let { content, context }: Props = $props();
</script>

{#if typeof content === "string"}
{content}
{:else if content instanceof Function}
<!-- It's unlikely that a CellContext will be passed to a Header -->
<!-- eslint-disable-next-line @typescript-eslint/no-explicit-any -->
{@const result = content(context as any)}
{#if result instanceof RenderComponentConfig}
{@const { component: Component, props } = result}
<Component {...props} />
{:else if result instanceof RenderSnippetConfig}
{@const { snippet, params } = result}
{@render snippet(params)}
{:else}
{result}
{/if}
{/if}
4 changes: 4 additions & 0 deletions app/src/lib/components/table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as FlexRender } from "./flex-render.svelte"
export { renderComponent, renderSnippet } from "./render-helpers.js"
export { createSvelteTable } from "./table.svelte.js"
export { createVirtualizer, createWindowVirtualizer } from "./virtual.svelte.js"
111 changes: 111 additions & 0 deletions app/src/lib/components/table/render-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import type { Component, ComponentProps, Snippet } from "svelte"

/**
* A helper class to make it easy to identify Svelte components in
* `columnDef.cell` and `columnDef.header` properties.
*
* > NOTE: This class should only be used internally by the adapter. If you're
* reading this and you don't know what this is for, you probably don't need it.
*
* @example
* ```svelte
* {@const result = content(context as any)}
* {#if result instanceof RenderComponentConfig}
* {@const { component: Component, props } = result}
* <Component {...props} />
* {/if}
* ```
*/
export class RenderComponentConfig<TComponent extends Component> {
component: TComponent
props: ComponentProps<TComponent> | Record<string, never>
constructor(
component: TComponent,
props: ComponentProps<TComponent> | Record<string, never> = {}
) {
this.component = component
this.props = props
}
}

/**
* A helper class to make it easy to identify Svelte Snippets in `columnDef.cell` and `columnDef.header` properties.
*
* > NOTE: This class should only be used internally by the adapter. If you're
* reading this and you don't know what this is for, you probably don't need it.
*
* @example
* ```svelte
* {@const result = content(context as any)}
* {#if result instanceof RenderSnippetConfig}
* {@const { snippet, params } = result}
* {@render snippet(params)}
* {/if}
* ```
*/
export class RenderSnippetConfig<TProps> {
snippet: Snippet<[TProps]>
params: TProps
constructor(snippet: Snippet<[TProps]>, params: TProps) {
this.snippet = snippet
this.params = params
}
}

/**
* A helper function to help create cells from Svelte components through ColumnDef's `cell` and `header` properties.
*
* This is only to be used with Svelte Components - use `renderSnippet` for Svelte Snippets.
*
* @param component A Svelte component
* @param props The props to pass to `component`
* @returns A `RenderComponentConfig` object that helps svelte-table know how to render the header/cell component.
* @example
* ```ts
* // +page.svelte
* const defaultColumns = [
* columnHelper.accessor('name', {
* header: header => renderComponent(SortHeader, { label: 'Name', header }),
* }),
* columnHelper.accessor('state', {
* header: header => renderComponent(SortHeader, { label: 'State', header }),
* }),
* ]
* ```
* @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
*/
export function renderComponent<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends Component<any>,
Props extends ComponentProps<T>
>(component: T, props: Props) {
return new RenderComponentConfig(component, props)
}

/**
* A helper function to help create cells from Svelte Snippets through ColumnDef's `cell` and `header` properties.
*
* The snippet must only take one parameter.
*
* This is only to be used with Snippets - use `renderComponent` for Svelte Components.
*
* @param snippet
* @param params
* @returns - A `RenderSnippetConfig` object that helps svelte-table know how to render the header/cell snippet.
* @example
* ```ts
* // +page.svelte
* const defaultColumns = [
* columnHelper.accessor('name', {
* cell: cell => renderSnippet(nameSnippet, { name: cell.row.name }),
* }),
* columnHelper.accessor('state', {
* cell: cell => renderSnippet(stateSnippet, { state: cell.row.state }),
* }),
* ]
* ```
* @see {@link https://tanstack.com/table/latest/docs/guide/column-defs}
*/
export function renderSnippet<TProps>(snippet: Snippet<[TProps]>, params: TProps) {
return new RenderSnippetConfig(snippet, params)
}
Loading

0 comments on commit 2e55ae6

Please sign in to comment.