-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: svelte types generation during build (#14)
Co-authored-by: mattcroat <mattcroat.dev@gmail.com> Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
- Loading branch information
1 parent
625019f
commit c135e0a
Showing
8 changed files
with
274 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vite' | ||
import Vue from '@vitejs/plugin-vue' | ||
import UnoCSS from 'unocss/vite' | ||
import { svelte } from '@sveltejs/vite-plugin-svelte' | ||
import { svelte as Svelte } from '@sveltejs/vite-plugin-svelte' | ||
|
||
export default defineConfig({ | ||
resolve: { | ||
alias: { | ||
'shiki-magic-move/core': fileURLToPath(new URL('../src/core.ts', import.meta.url)), | ||
'shiki-magic-move/renderer': fileURLToPath(new URL('../src/renderer.ts', import.meta.url)), | ||
}, | ||
}, | ||
plugins: [ | ||
Vue(), | ||
UnoCSS(), | ||
svelte(), | ||
Svelte(), | ||
], | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
<script lang="ts"> | ||
import { codeToKeyedTokens, createMagicMoveMachine } from '../core' | ||
import ShikiMagicMoveRenderer from './ShikiMagicMoveRenderer.svelte' | ||
import type { HighlighterCore } from 'shiki/core' | ||
import type { MagicMoveRenderOptions, MagicMoveDifferOptions } from '../types' | ||
interface ShikiMagicMoveProps { | ||
highlighter: HighlighterCore | ||
lang: string | ||
theme: string | ||
code: string | ||
options?: MagicMoveRenderOptions & MagicMoveDifferOptions | ||
onStart?: () => void | ||
onEnd?: () => void | ||
} | ||
<script lang='ts'> | ||
import { codeToKeyedTokens, createMagicMoveMachine } from 'shiki-magic-move/core' | ||
import type { HighlighterCore } from 'shiki/core' | ||
import type { MagicMoveDifferOptions, MagicMoveRenderOptions } from 'shiki-magic-move/types' | ||
import ShikiMagicMoveRenderer from './ShikiMagicMoveRenderer.svelte' | ||
const { highlighter, lang, theme, code, options, onStart, onEnd, ...props }: ShikiMagicMoveProps = $props() | ||
const machine = createMagicMoveMachine( | ||
(code) => codeToKeyedTokens(highlighter, code, { lang, theme }, options?.lineNumbers), | ||
options | ||
) | ||
const result = $derived(machine.commit(code)) | ||
interface ShikiMagicMoveProps { | ||
highlighter: HighlighterCore | ||
lang: string | ||
theme: string | ||
code: string | ||
options?: MagicMoveRenderOptions & MagicMoveDifferOptions | ||
onStart?: () => void | ||
onEnd?: () => void | ||
} | ||
const { highlighter, lang, theme, code, options, onStart, onEnd, ...props }: ShikiMagicMoveProps = $props() | ||
const machine = createMagicMoveMachine( | ||
code => codeToKeyedTokens(highlighter, code, { lang, theme }, options?.lineNumbers), | ||
options, | ||
) | ||
const result = $derived(machine.commit(code)) | ||
</script> | ||
|
||
<ShikiMagicMoveRenderer | ||
tokens={result.current} | ||
previous={result.previous} | ||
{options} | ||
{onStart} | ||
{onEnd} | ||
{...props} | ||
/> | ||
tokens={result.current} | ||
previous={result.previous} | ||
{options} | ||
{onStart} | ||
{onEnd} | ||
{...props} | ||
/> |
Oops, something went wrong.