Skip to content

Commit 1d029f5

Browse files
authored
Merge pull request #75 from cmgriffing/next
Voting Period Changes
2 parents fc4a0cb + 433128b commit 1d029f5

35 files changed

+1045
-505
lines changed

.github/workflows/format.yml

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ jobs:
2121
# This is important to fetch the changes to the previous commit
2222
fetch-depth: 0
2323

24+
steps:
25+
- uses: pnpm/action-setup@v4
26+
with:
27+
version: 9
28+
run_install: true
29+
2430
- name: Prettier Action
2531
uses: creyD/[email protected]
2632
with:

.prettierrc

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
{
2-
"trailingComma": "all",
3-
"tabWidth": 2,
4-
"printWidth": 100,
5-
"semi": false,
6-
"singleQuote": true,
7-
"useTabs": false,
8-
"arrowParens": "avoid",
9-
"bracketSpacing": true
2+
"trailingComma": "all",
3+
"tabWidth": 2,
4+
"printWidth": 100,
5+
"semi": false,
6+
"singleQuote": true,
7+
"useTabs": false,
8+
"arrowParens": "avoid",
9+
"bracketSpacing": true,
10+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
11+
"importOrder": [
12+
"^solid-js(.*)$",
13+
"^solid-(.*)$",
14+
"^shiki(.*)$",
15+
"^~/components/ui/(.*)$",
16+
"^~/(.*)$",
17+
"^[./]"
18+
],
19+
"importOrderGroupNamespaceSpecifiers": true,
20+
"importOrderSeparation": true,
21+
"importOrderSortSpecifiers": true
1022
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"scripts": {
1010
"postinstall": "pnpm build",
1111
"dev": "pnpm run --filter ./playgrounds/app dev",
12-
"build": "cd packages/shikicode && pnpm build && cd ../shiki-magic-move && pnpm build && cd ../../playgrounds/app && pnpm build",
12+
"build": "cd packages/shikicode && pnpm build && cd ../shiki-magic-move && pnpm build",
1313
"test": "turbo run test --filter=./packages/*",
1414
"typecheck": "turbo run typecheck --filter=./packages/*",
1515
"build-test": "turbo run build test --filter=./packages/*",
@@ -22,6 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@changesets/cli": "^2.26.0",
25+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
2526
"@types/node": "^18.11.18",
2627
"concurrently": "^7.6.0",
2728
"jsdom": "^21.0.0",

packages/shiki-magic-move/src/solid/ShikiMagicMove.tsx

+27-18
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,40 @@ export interface ShikiMagicMoveProps {
1919
}
2020

2121
export function ShikiMagicMove(props: ShikiMagicMoveProps) {
22-
const codeToTokens = (code: string, lineNumbers?: boolean) =>
23-
codeToKeyedTokens(
24-
props.highlighter,
25-
code,
26-
{
27-
lang: props.lang,
28-
theme: props.theme,
29-
},
30-
lineNumbers,
31-
)
22+
const codeToTokens = createMemo(() => {
23+
return (code: string, lineNumbers?: boolean) =>
24+
codeToKeyedTokens(
25+
props.highlighter,
26+
code,
27+
{
28+
lang: props.lang,
29+
theme: props.theme,
30+
},
31+
lineNumbers,
32+
)
33+
})
3234

33-
const machine = createMagicMoveMachine((code, lineNumbers) => codeToTokens(code, lineNumbers))
35+
const machine = createMemo(() => {
36+
const newCodeToTokens = codeToTokens()
37+
return createMagicMoveMachine((code, lineNumbers) => newCodeToTokens(code, lineNumbers))
38+
})
3439

3540
const result = createMemo(() => {
3641
const lineNumbers = props.options?.lineNumbers ?? false
3742
if (
38-
props.code === machine.current.code &&
39-
props.theme === machine.current.themeName &&
40-
props.lang === machine.current.lang &&
41-
lineNumbers === machine.current.lineNumbers
43+
props.code === machine().current.code &&
44+
props.theme === machine().current.themeName &&
45+
props.lang === machine().current.lang &&
46+
lineNumbers === machine().current.lineNumbers
4247
) {
43-
return machine
48+
return machine()
49+
}
50+
try {
51+
return machine().commit(props.code, props.options)
52+
// eslint-disable-next-line unused-imports/no-unused-vars
53+
} catch (e) {
54+
return machine()
4455
}
45-
46-
return machine.commit(props.code, props.options)
4756
})
4857

4958
return (

packages/shiki-magic-move/src/solid/ShikiMagicMoveRenderer.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,38 @@ export interface ShikiMagicMoveRendererProps {
2121
* A wrapper component to `MagicMoveRenderer`
2222
*/
2323
export function ShikiMagicMoveRenderer(props: ShikiMagicMoveRendererProps) {
24-
let container: HTMLPreElement
25-
let renderer: Renderer
24+
// eslint-disable-next-line no-undef-init, prefer-const
25+
let container: HTMLPreElement | undefined = undefined
26+
// eslint-disable-next-line no-undef-init
27+
let renderer: Renderer | undefined = undefined
2628
const [isMounted, setIsMounted] = createSignal(false)
2729

2830
createEffect(() => {
29-
if (!container) return
30-
if (!isMounted()) {
31+
if (container !== undefined && !isMounted()) {
3132
// Remove previous content
32-
container.innerHTML = ''
33+
;(container as HTMLPreElement).innerHTML = ''
3334
setIsMounted(true)
3435
renderer = new Renderer(container)
3536
}
3637
})
3738

3839
createEffect(() => {
3940
async function render() {
40-
if (!renderer) return
41+
if (!renderer) {
42+
return
43+
}
4144

4245
Object.assign(renderer.options, props.options)
4346

4447
if (props.animate === undefined || props.animate === true) {
45-
if (props.previous) renderer.replace(props.previous)
48+
if (props.previous) {
49+
renderer.replace(props.previous)
50+
}
4651

4752
props.onStart?.()
4853
await renderer.render(props.tokens)
4954
props.onEnd?.()
55+
// eslint-disable-next-line style/brace-style
5056
} else {
5157
renderer.replace(props.tokens)
5258
}
@@ -57,7 +63,6 @@ export function ShikiMagicMoveRenderer(props: ShikiMagicMoveRendererProps) {
5763

5864
return (
5965
<pre
60-
// @ts-expect-error - TS doesn't know that `container` is a ref
6166
ref={container}
6267
class={`shiki-magic-move-container ${props.class || ''}`.trim()}
6368
style={props.style}

playgrounds/app/app.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ import { defineConfig } from '@solidjs/start/config'
22

33
export default defineConfig({
44
ssr: false,
5+
vite: {
6+
optimizeDeps: { exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util'] },
7+
},
58
})

playgrounds/app/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
},
1717
"dependencies": {
1818
"@corvu/resizable": "^0.2.3",
19+
"@ffmpeg/core": "^0.12.6",
20+
"@ffmpeg/ffmpeg": "^0.12.10",
21+
"@ffmpeg/util": "^0.12.1",
1922
"@fontsource/bungee-inline": "^5.1.0",
2023
"@fontsource/roboto": "^5.1.0",
2124
"@kobalte/core": "^0.13.7",
2225
"@libsql/client": "^0.14.0",
26+
"@solid-primitives/media": "^2.2.9",
2327
"@solid-primitives/storage": "^4.2.1",
2428
"@solidjs/meta": "^0.29.4",
2529
"@solidjs/router": "^0.14.7",
@@ -31,6 +35,7 @@
3135
"diff-match-patch-es": "^0.1.0",
3236
"dotenv": "^16.4.5",
3337
"drizzle-orm": "^0.35.3",
38+
"idb": "^8.0.0",
3439
"jsonwebtoken": "^9.0.2",
3540
"modern-gif": "^2.0.3",
3641
"nanoid": "^5.0.7",
@@ -54,6 +59,7 @@
5459
"node": ">=18"
5560
},
5661
"devDependencies": {
62+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
5763
"@types/jsonwebtoken": "^9.0.7",
5864
"drizzle-kit": "^0.26.2",
5965
"tsx": "^4.19.1"

playgrounds/app/src/app.css

+25-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@
102102

103103
body {
104104
@apply bg-background text-foreground;
105-
font-feature-settings:
106-
'rlig' 1,
107-
'calt' 1;
105+
font-feature-settings: 'rlig' 1, 'calt' 1;
108106
}
109107
}
110108

@@ -148,3 +146,27 @@
148146
#app {
149147
@apply min-h-screen flex flex-col;
150148
}
149+
150+
.collapsible__content {
151+
overflow: hidden;
152+
animation: slideUp 300ms ease-out;
153+
}
154+
.collapsible__content[data-expanded] {
155+
animation: slideDown 300ms ease-out;
156+
}
157+
@keyframes slideDown {
158+
from {
159+
height: 0;
160+
}
161+
to {
162+
height: var(--kb-collapsible-content-height);
163+
}
164+
}
165+
@keyframes slideUp {
166+
from {
167+
height: var(--kb-collapsible-content-height);
168+
}
169+
to {
170+
height: 0;
171+
}
172+
}

playgrounds/app/src/app.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { Suspense } from 'solid-js'
1+
import '@fontsource/bungee-inline'
2+
import '@fontsource/roboto'
23
import { Router } from '@solidjs/router'
34
import { FileRoutes } from '@solidjs/start/router'
5+
6+
import { Suspense } from 'solid-js'
7+
48
import { Toaster } from 'solid-sonner'
9+
510
import Header from '~/components/Header'
6-
import Footer from './components/Footer'
7-
import '@fontsource/bungee-inline'
8-
import '@fontsource/roboto'
11+
912
import './app.css'
1013

1114
export default function App() {

0 commit comments

Comments
 (0)