-
-
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.
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
- Loading branch information
Showing
12 changed files
with
391 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { mount, unmount } from 'svelte' | ||
import { ShikiMagicMove } from '../../../src/svelte' | ||
import type { RendererFactory, RendererFactoryResult } from './types' | ||
|
||
export const createRendererSvelte: RendererFactory = (options): RendererFactoryResult => { | ||
let app: any | ||
|
||
const props = $state({ | ||
onStart: options.onStart, | ||
onEnd: options.onEnd, | ||
}) | ||
|
||
return { | ||
mount: (element, payload) => { | ||
Object.assign(props, payload) | ||
if (app) | ||
return | ||
app = mount(ShikiMagicMove, { target: element, props }) | ||
// eslint-disable-next-line no-console | ||
console.log('Svelte renderer mounted') | ||
}, | ||
|
||
update: (payload) => { | ||
Object.assign(props, payload) | ||
}, | ||
|
||
dispose: () => { | ||
if (app) | ||
unmount(app) | ||
app = undefined | ||
}, | ||
} | ||
} |
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,10 +1,12 @@ | ||
import { defineConfig } from 'vite' | ||
import Vue from '@vitejs/plugin-vue' | ||
import UnoCSS from 'unocss/vite' | ||
import { svelte } from '@sveltejs/vite-plugin-svelte' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
Vue(), | ||
UnoCSS(), | ||
svelte(), | ||
], | ||
}) |
Oops, something went wrong.