a homebrewed DnD campaign based in the Honkai: Star Rail universe
hsr honkaistarrail dnd
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cleanup: setup oxfmt (#45)

authored by

Samantha and committed by
GitHub
8622b75a 199b3b43

+326 -170
+7
.oxfmtrc.json
··· 1 + { 2 + "$schema": "./node_modules/oxfmt/configuration_schema.json", 3 + "useTabs": true, 4 + "semi": false, 5 + "singleQuote": true, 6 + "trailingComma": "all" 7 + }
+1 -3
app/.storybook/main.ts
··· 1 1 import type { StorybookConfig } from '@storybook/sveltekit' 2 2 3 3 const config: StorybookConfig = { 4 - stories: [ 5 - '../src/stories/*.stories.@(js|ts|svelte|mdx)', 6 - ], 4 + stories: ['../src/stories/*.stories.@(js|ts|svelte|mdx)'], 7 5 staticDirs: ['../static'], 8 6 addons: [ 9 7 '@storybook/addon-docs',
+6 -3
app/src/app.d.ts
··· 10 10 11 11 interface Locals { 12 12 supabase: SupabaseClient<Database> 13 - safeGetSession: () => Promise<{ session: Session | null; user: User | null }> 13 + safeGetSession: () => Promise<{ 14 + session: Session | null 15 + user: User | null 16 + }> 14 17 session: Session | null 15 18 user: User | null 16 19 } ··· 23 26 24 27 interface Platform { 25 28 env: { 26 - YOUR_KV_NAMESPACE: KVNamespace; 27 - YOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace; 29 + YOUR_KV_NAMESPACE: KVNamespace 30 + YOUR_DURABLE_OBJECT_NAMESPACE: DurableObjectNamespace 28 31 } 29 32 } 30 33 }
+5 -3
app/src/hooks.server.ts
··· 2 2 import type { Handle } from '@sveltejs/kit' 3 3 import { sequence } from '@sveltejs/kit/hooks' 4 4 import { createServerClient } from '@supabase/ssr' 5 - import { PUBLIC_SUPABASE_PUBLISHABLE_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public' 5 + import { 6 + PUBLIC_SUPABASE_PUBLISHABLE_KEY, 7 + PUBLIC_SUPABASE_URL, 8 + } from '$env/static/public' 6 9 7 10 const supabase: Handle = async ({ event, resolve }) => { 8 11 /** ··· 64 67 * Supabase libraries use the `content-range` and `x-supabase-api-version` 65 68 * headers, so we need to tell SvelteKit to pass it through. 66 69 */ 67 - return name === 'content-range' 68 - || name === 'x-supabase-api-version' 70 + return name === 'content-range' || name === 'x-supabase-api-version' 69 71 }, 70 72 }) 71 73 }
+6 -6
app/src/lib/components/Chip/variants.ts
··· 32 32 withIcon: { 33 33 true: '', 34 34 false: '', 35 - } 35 + }, 36 36 }, 37 37 compoundVariants: [ 38 38 // size + withIcon variants ··· 171 171 172 172 export type ChipRootElement = SvelteHTMLElements['div'] 173 173 export type ChipProps = WithChildren<ChipRootElement> & { 174 - style: ChipStyle, 175 - size?: ChipSize, 176 - color?: ChipColor, 177 - withIcon?: boolean, 178 - withDot?: boolean, 174 + style: ChipStyle 175 + size?: ChipSize 176 + color?: ChipColor 177 + withIcon?: boolean 178 + withDot?: boolean 179 179 }
+4 -4
app/src/lib/components/Stepper/Step/types.ts
··· 2 2 3 3 export type StepRootElement = SvelteHTMLElements['div'] 4 4 export type StepProps = StepRootElement & { 5 - text: string, 6 - desc: string, 7 - number?: number, 8 - isActive: boolean, 5 + text: string 6 + desc: string 7 + number?: number 8 + isActive: boolean 9 9 }
+5 -9
app/src/lib/hsr/dnd.ts
··· 7 7 readonly amount: number 8 8 readonly type: number 9 9 10 - public constructor( 11 - ability: AbilityMod, 12 - amount: number, 13 - type: number 14 - ) { 10 + public constructor(ability: AbilityMod, amount: number, type: number) { 15 11 this.ability = ability 16 12 this.amount = amount 17 13 this.type = type ··· 23 19 return match === null 24 20 ? null 25 21 : new Dice( 26 - match[1] as AbilityMod, 27 - Number.parseInt(match[2]), 28 - Number.parseInt(match[3]), 29 - ) 22 + match[1] as AbilityMod, 23 + Number.parseInt(match[2]), 24 + Number.parseInt(match[3]), 25 + ) 30 26 } 31 27 }
+9 -6
app/src/lib/hsr/elements.ts
··· 17 17 | 'purple' 18 18 19 19 type ElementRecord = { 20 - text: string, 21 - color: ElementColor, 22 - icon: Component, 20 + text: string 21 + color: ElementColor 22 + icon: Component 23 23 } 24 24 25 25 const elementMap: Record<Element, ElementRecord> = { ··· 60 60 }, 61 61 } 62 62 63 - export const elementColor = (element: Element): ElementColor => elementMap[element].color 64 - export const elementText = (element: Element): string => elementMap[element].text 65 - export const elementIcon = (element: Element): Component => elementMap[element].icon 63 + export const elementColor = (element: Element): ElementColor => 64 + elementMap[element].color 65 + export const elementText = (element: Element): string => 66 + elementMap[element].text 67 + export const elementIcon = (element: Element): Component => 68 + elementMap[element].icon
+14 -12
app/src/lib/hsr/mechanic.ts
··· 15 15 import HandHelping from '@lucide/svelte/icons/hand-helping' 16 16 17 17 type MechanicRecord = { 18 - text: string, 19 - icon: Component, 18 + text: string 19 + icon: Component 20 20 } 21 21 22 22 const mechanicMap: Record<Mechanic, MechanicRecord> = { ··· 24 24 text: 'Single Target', 25 25 icon: Crosshair, 26 26 }, 27 - 'aoe': { 27 + aoe: { 28 28 text: 'AoE', 29 29 icon: CircleDotDashed, 30 30 }, 31 - 'bounce': { 31 + bounce: { 32 32 text: 'Bounce', 33 33 icon: Split, 34 34 }, 35 - 'blast': { 35 + blast: { 36 36 text: 'Blast', 37 37 icon: Bomb, 38 38 }, 39 - 'impair': { 39 + impair: { 40 40 text: 'Impair', 41 41 icon: ChevronsDown, 42 42 }, 43 - 'support': { 43 + support: { 44 44 text: 'Support', 45 45 icon: HandHelping, 46 46 }, 47 - 'restore': { 47 + restore: { 48 48 text: 'Restore', 49 49 icon: HeartPlus, 50 50 }, 51 - 'enhance': { 51 + enhance: { 52 52 text: 'Enhance', 53 53 icon: Sparkles, 54 54 }, 55 - 'defense': { 55 + defense: { 56 56 text: 'Defense', 57 57 icon: ShieldHalf, 58 58 }, 59 59 } 60 60 61 - export const mechanicLabel = (mechanic: Mechanic): string => mechanicMap[mechanic].text 62 - export const mechanicIcon = (mechanic: Mechanic): Component => mechanicMap[mechanic].icon 61 + export const mechanicLabel = (mechanic: Mechanic): string => 62 + mechanicMap[mechanic].text 63 + export const mechanicIcon = (mechanic: Mechanic): Component => 64 + mechanicMap[mechanic].icon
+4 -1
app/src/lib/supabaseClient.ts
··· 1 1 import { createClient } from '@supabase/supabase-js' 2 - import { PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_ANON_KEY } from '$env/static/public' 2 + import { 3 + PUBLIC_SUPABASE_URL, 4 + PUBLIC_SUPABASE_ANON_KEY, 5 + } from '$env/static/public' 3 6 4 7 const supabaseUrl = PUBLIC_SUPABASE_URL 5 8 const supabaseKey = PUBLIC_SUPABASE_ANON_KEY
+6 -4
app/src/lib/types.ts
··· 7 7 * 8 8 * This is intended to be used for components that use `tailwind-variants`. 9 9 */ 10 - export type ElementAttributes<T extends keyof SvelteHTMLElements> = 11 - Omit<SvelteHTMLElements[T], 'class'> & { 12 - class?: ClassNameValue | undefined | null 13 - } 10 + export type ElementAttributes<T extends keyof SvelteHTMLElements> = Omit< 11 + SvelteHTMLElements[T], 12 + 'class' 13 + > & { 14 + class?: ClassNameValue | undefined | null 15 + }
+18 -7
app/src/routes/+layout.ts
··· 1 - import { createBrowserClient, createServerClient, isBrowser } from '@supabase/ssr' 2 - import { PUBLIC_SUPABASE_PUBLISHABLE_KEY, PUBLIC_SUPABASE_URL } from '$env/static/public' 1 + import { 2 + createBrowserClient, 3 + createServerClient, 4 + isBrowser, 5 + } from '@supabase/ssr' 6 + import { 7 + PUBLIC_SUPABASE_PUBLISHABLE_KEY, 8 + PUBLIC_SUPABASE_URL, 9 + } from '$env/static/public' 3 10 import type { LayoutLoad } from './$types' 4 11 5 12 export const load: LayoutLoad = async ({ data, depends, fetch }) => { ··· 11 18 const supabase = isBrowser() 12 19 ? createBrowserClient(url, key, { global: { fetch } }) 13 20 : createServerClient(url, key, { 14 - global: { fetch }, 15 - cookies: { getAll: () => data.cookies } 16 - }) 21 + global: { fetch }, 22 + cookies: { getAll: () => data.cookies }, 23 + }) 17 24 18 - const { data: { session } } = await supabase.auth.getSession() 19 - const { data: { user } } = await supabase.auth.getUser() 25 + const { 26 + data: { session }, 27 + } = await supabase.auth.getSession() 28 + const { 29 + data: { user }, 30 + } = await supabase.auth.getUser() 20 31 return { session, supabase, user } 21 32 }
+1 -1
app/src/routes/auth/callback/+server.ts
··· 3 3 export const GET = async (event) => { 4 4 const { 5 5 url, 6 - locals: { supabase } 6 + locals: { supabase }, 7 7 } = event 8 8 9 9 const code = url.searchParams.get('code') as string
+6 -6
app/src/routes/combat/+page.ts
··· 4 4 const abilities: AbilityCardProps[] = [ 5 5 { 6 6 name: 'Overtone Hum: Chorus after Dark Tones', 7 - desc: 'Has a 100% base chance to increase the DMG taken by all enemies by 22%, lasting for 3 turn(s). At the same time, deals physical equal to 154% of Player\'s ATK to all enemies.', 7 + desc: "Has a 100% base chance to increase the DMG taken by all enemies by 22%, lasting for 3 turn(s). At the same time, deals physical equal to 154% of Player's ATK to all enemies.", 8 8 mechanic: 'aoe', 9 9 details: { 10 10 range: '30 feet', ··· 16 16 }, 17 17 { 18 18 name: 'Caressing Moonlight', 19 - desc: 'Deals lightning equal to 176% of Kafka\'s ATK to a target enemy and lightning equal to 66% of Kafka\'s ATK to enemies adjacent to it.\n\nIf the target enemy is currently receiving DoT, all DoTs currently placed on that enemy immediately produce DMG equal to 78% of their original DMG.', 19 + desc: "Deals lightning equal to 176% of Kafka's ATK to a target enemy and lightning equal to 66% of Kafka's ATK to enemies adjacent to it.\n\nIf the target enemy is currently receiving DoT, all DoTs currently placed on that enemy immediately produce DMG equal to 78% of their original DMG.", 20 20 mechanic: 'aoe', 21 21 details: { 22 22 range: '30 feet', ··· 38 38 }, 39 39 { 40 40 name: 'Ordial: Aerial Bombardment', 41 - desc: 'Consumes SAM\'s HP equal to 40% of SAM\'s Max HP and regenerates a fixed amount of Energy equal to 60% of SAM\'s Max Energy. Deals fire equal to 200% of SAM\'s ATK to a single target enemy. If the current HP is not sufficient, then SAM\'s HP is reduced to 1 when using this Skill. Enables this unit\'s next Action to be Advanced by 25%.', 41 + desc: "Consumes SAM's HP equal to 40% of SAM's Max HP and regenerates a fixed amount of Energy equal to 60% of SAM's Max Energy. Deals fire equal to 200% of SAM's ATK to a single target enemy. If the current HP is not sufficient, then SAM's HP is reduced to 1 when using this Skill. Enables this unit's next Action to be Advanced by 25%.", 42 42 mechanic: 'blast', 43 43 details: { 44 44 range: '120 feet', 45 45 hit_dc: 'CON 21', 46 46 damage: '10d8', 47 47 element: 'fire', 48 - } 49 - } 48 + }, 49 + }, 50 50 ] 51 51 52 52 // oxlint-disable-next-line eslint(no-unused-vars) 53 53 export const load: PageLoad = ({ params }) => { 54 54 return { 55 - abilities: abilities 55 + abilities: abilities, 56 56 } 57 57 }
+5 -5
app/src/routes/species/[page=species]/+page.ts
··· 2 2 import type { PageLoad } from './$types' 3 3 4 4 type Species = { 5 - name: string, 6 - urlSlug: string, 7 - abilities: AbilityMod[], 8 - desc: string[], 5 + name: string 6 + urlSlug: string 7 + abilities: AbilityMod[] 8 + desc: string[] 9 9 } 10 10 11 11 const species: Record<string, Species> = { ··· 52 52 // oxlint-disable-next-line eslint(no-unused-vars) 53 53 export const load: PageLoad = ({ params }) => { 54 54 return { 55 - species: species 55 + species: species, 56 56 } 57 57 }
+5 -1
app/src/stories/utils.ts
··· 1 - import { DefenseMechanicArray, ElementArray, OffenseMechanicArray } from '@starlight/types/hsr' 1 + import { 2 + DefenseMechanicArray, 3 + ElementArray, 4 + OffenseMechanicArray, 5 + } from '@starlight/types/hsr' 2 6 import type { InputType } from 'storybook/internal/csf' 3 7 4 8 export const ElementInputType: InputType = {
+6 -12
app/svelte.config.js
··· 10 10 export default defineConfig({ 11 11 // Consult https://svelte.dev/docs/kit/integrations 12 12 // for more information about preprocessors 13 - preprocess: [ 14 - vitePreprocess(), 15 - mdsvex(), 16 - ], 13 + preprocess: [vitePreprocess(), mdsvex()], 17 14 compilerOptions: { 18 15 preserveComments: false, 19 16 }, ··· 22 19 fallback: 'plaintext', 23 20 routes: { 24 21 include: ['/*'], 25 - exclude: ['<all>'] 22 + exclude: ['<all>'], 26 23 }, 27 24 }), 28 25 alias: { 29 - '$ui': 'src/lib/components', 30 - '$icons': 'src/lib/icons', 31 - '$patterns': 'src/lib/patterns', 26 + $ui: 'src/lib/components', 27 + $icons: 'src/lib/icons', 28 + $patterns: 'src/lib/patterns', 32 29 }, 33 30 }, 34 - extensions: [ 35 - '.svelte', 36 - '.svx', 37 - ], 31 + extensions: ['.svelte', '.svx'], 38 32 })
+1 -4
app/vite.config.ts
··· 3 3 import { sveltekit } from '@sveltejs/kit/vite' 4 4 5 5 export default defineProject({ 6 - plugins: [ 7 - tailwindcss(), 8 - sveltekit(), 9 - ], 6 + plugins: [tailwindcss(), sveltekit()], 10 7 })
+139
package-lock.json
··· 16 16 "@types/node": "^24", 17 17 "@vitest/coverage-v8": "^4.0.8", 18 18 "@vitest/ui": "^4.0.8", 19 + "oxfmt": "^0.13.0", 19 20 "oxlint": "^1.26.0", 20 21 "publint": "^0.3.15", 21 22 "tsdown": "^0.16.1", ··· 1527 1528 "funding": { 1528 1529 "url": "https://github.com/sponsors/Boshen" 1529 1530 } 1531 + }, 1532 + "node_modules/@oxfmt/darwin-arm64": { 1533 + "version": "0.13.0", 1534 + "resolved": "https://registry.npmjs.org/@oxfmt/darwin-arm64/-/darwin-arm64-0.13.0.tgz", 1535 + "integrity": "sha512-WJKGJp9t8lMG3Vmsyz77qj4GIp2Z/z5KkS4Mpbn7nfiVZLVNdxf9k85vHnuGtBZcuxIAjJIRDgitePFPD+timA==", 1536 + "cpu": [ 1537 + "arm64" 1538 + ], 1539 + "dev": true, 1540 + "license": "MIT", 1541 + "optional": true, 1542 + "os": [ 1543 + "darwin" 1544 + ] 1545 + }, 1546 + "node_modules/@oxfmt/darwin-x64": { 1547 + "version": "0.13.0", 1548 + "resolved": "https://registry.npmjs.org/@oxfmt/darwin-x64/-/darwin-x64-0.13.0.tgz", 1549 + "integrity": "sha512-b9r+uOrnsFIl8DEimw5G69/aXbY5XURzFz0j6Hr8GiAZIrp2GlMLz0B8zhylAXh882GalZGxtcVbLZt5SSe2jw==", 1550 + "cpu": [ 1551 + "x64" 1552 + ], 1553 + "dev": true, 1554 + "license": "MIT", 1555 + "optional": true, 1556 + "os": [ 1557 + "darwin" 1558 + ] 1559 + }, 1560 + "node_modules/@oxfmt/linux-arm64-gnu": { 1561 + "version": "0.13.0", 1562 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-arm64-gnu/-/linux-arm64-gnu-0.13.0.tgz", 1563 + "integrity": "sha512-v9+rE/d38wBRli0iYvhgGWlgSAgFBJnnK6kefwQ6POu6n6y/tGiQXjWIyvkBqpQhxxavGnk3z3WXP+DAJSC2eA==", 1564 + "cpu": [ 1565 + "arm64" 1566 + ], 1567 + "dev": true, 1568 + "license": "MIT", 1569 + "optional": true, 1570 + "os": [ 1571 + "linux" 1572 + ] 1573 + }, 1574 + "node_modules/@oxfmt/linux-arm64-musl": { 1575 + "version": "0.13.0", 1576 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-arm64-musl/-/linux-arm64-musl-0.13.0.tgz", 1577 + "integrity": "sha512-g9A8dOoM/XwToz70aq8XodQZMWwWWPjuTUCI9cxkB1uvpQe4JN6VcHRLMY6Ft1LLh4MIARqq3mCbuXwMVseKiA==", 1578 + "cpu": [ 1579 + "arm64" 1580 + ], 1581 + "dev": true, 1582 + "license": "MIT", 1583 + "optional": true, 1584 + "os": [ 1585 + "linux" 1586 + ] 1587 + }, 1588 + "node_modules/@oxfmt/linux-x64-gnu": { 1589 + "version": "0.13.0", 1590 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-x64-gnu/-/linux-x64-gnu-0.13.0.tgz", 1591 + "integrity": "sha512-CbMEtJ+0mVWnBHOF+Fx8CYApAs3Iywmo6E+buokXEli98167R2eJ/g7dqNiU6R8hBiO0n4KyoT4KaeYhmQp7KA==", 1592 + "cpu": [ 1593 + "x64" 1594 + ], 1595 + "dev": true, 1596 + "license": "MIT", 1597 + "optional": true, 1598 + "os": [ 1599 + "linux" 1600 + ] 1601 + }, 1602 + "node_modules/@oxfmt/linux-x64-musl": { 1603 + "version": "0.13.0", 1604 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-x64-musl/-/linux-x64-musl-0.13.0.tgz", 1605 + "integrity": "sha512-KqE6qmwLqxbC2I1t65JNqbu87qL4my3Bi1nsmwXzJBW/xFAVNS4OgZnKQwOpW9dDXw8Ng/IoBO24GgOOECkd/w==", 1606 + "cpu": [ 1607 + "x64" 1608 + ], 1609 + "dev": true, 1610 + "license": "MIT", 1611 + "optional": true, 1612 + "os": [ 1613 + "linux" 1614 + ] 1615 + }, 1616 + "node_modules/@oxfmt/win32-arm64": { 1617 + "version": "0.13.0", 1618 + "resolved": "https://registry.npmjs.org/@oxfmt/win32-arm64/-/win32-arm64-0.13.0.tgz", 1619 + "integrity": "sha512-jVvlnkgdKHT/l13zIG9511KoVwCKGAvQ4CUtiwiP4Nv4K1F586dV4IcOawcRnKpw9KHTV/Q0E8jB5m3tnz2yeQ==", 1620 + "cpu": [ 1621 + "arm64" 1622 + ], 1623 + "dev": true, 1624 + "license": "MIT", 1625 + "optional": true, 1626 + "os": [ 1627 + "win32" 1628 + ] 1629 + }, 1630 + "node_modules/@oxfmt/win32-x64": { 1631 + "version": "0.13.0", 1632 + "resolved": "https://registry.npmjs.org/@oxfmt/win32-x64/-/win32-x64-0.13.0.tgz", 1633 + "integrity": "sha512-HgC7Efv1Eqv8Ag/3LP2WjSvzIFHsxBLBaYOgMhvq4WhZMM3xG9zsb/1A3/pVqdPhvw+Kh62WaYm1WQM9J4l0lQ==", 1634 + "cpu": [ 1635 + "x64" 1636 + ], 1637 + "dev": true, 1638 + "license": "MIT", 1639 + "optional": true, 1640 + "os": [ 1641 + "win32" 1642 + ] 1530 1643 }, 1531 1644 "node_modules/@oxlint/darwin-arm64": { 1532 1645 "version": "1.26.0", ··· 5585 5698 }, 5586 5699 "engines": { 5587 5700 "node": ">= 0.8.0" 5701 + } 5702 + }, 5703 + "node_modules/oxfmt": { 5704 + "version": "0.13.0", 5705 + "resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.13.0.tgz", 5706 + "integrity": "sha512-WhWYL1nRxevnezPK3GsGlZ2uPnO+rPlJ1U44TEfET+UwDPhKDVFyqlblduAgu3PFwTMgY/GRbaZwlWugvpfbWQ==", 5707 + "dev": true, 5708 + "license": "MIT", 5709 + "bin": { 5710 + "oxfmt": "bin/oxfmt" 5711 + }, 5712 + "engines": { 5713 + "node": "^20.19.0 || >=22.12.0" 5714 + }, 5715 + "funding": { 5716 + "url": "https://github.com/sponsors/Boshen" 5717 + }, 5718 + "optionalDependencies": { 5719 + "@oxfmt/darwin-arm64": "0.13.0", 5720 + "@oxfmt/darwin-x64": "0.13.0", 5721 + "@oxfmt/linux-arm64-gnu": "0.13.0", 5722 + "@oxfmt/linux-arm64-musl": "0.13.0", 5723 + "@oxfmt/linux-x64-gnu": "0.13.0", 5724 + "@oxfmt/linux-x64-musl": "0.13.0", 5725 + "@oxfmt/win32-arm64": "0.13.0", 5726 + "@oxfmt/win32-x64": "0.13.0" 5588 5727 } 5589 5728 }, 5590 5729 "node_modules/oxlint": {
+2
package.json
··· 12 12 "dev": "npm run dev --workspace=app", 13 13 "build": "./scripts/build.sh", 14 14 "storybook": "npm run storybook --workspace=app", 15 + "fmt": "oxfmt", 15 16 "lint": "npm run lint --workspace=app", 16 17 "lint-fix": "npm run lint-fix --workspace=app", 17 18 "test": "vitest --coverage --typecheck.enabled", ··· 25 26 "@types/node": "^24", 26 27 "@vitest/coverage-v8": "^4.0.8", 27 28 "@vitest/ui": "^4.0.8", 29 + "oxfmt": "^0.13.0", 28 30 "oxlint": "^1.26.0", 29 31 "publint": "^0.3.15", 30 32 "tsdown": "^0.16.1",
+4 -4
packages/color/src/index.ts
··· 1 1 export type Number4 = [number, number, number, number] 2 2 export type ColorStop = [number, string] 3 3 export type LinearGradientOptions = { 4 - points: Number4, 5 - colorStops: ColorStop[], 4 + points: Number4 5 + colorStops: ColorStop[] 6 6 } 7 7 8 8 export type ApplyLinearGradientOptions = { 9 - gradient: CanvasGradient, 10 - fillRect: Number4, 9 + gradient: CanvasGradient 10 + fillRect: Number4 11 11 } 12 12 13 13 export const linearGradient = (
+2 -2
packages/icons/svelte.config.js
··· 5 5 export default { 6 6 preprocess: vitePreprocess(), 7 7 kit: { 8 - adapter: adapter() 9 - } 8 + adapter: adapter(), 9 + }, 10 10 }
+1 -1
packages/icons/vite.config.ts
··· 3 3 4 4 export default defineProject({ 5 5 plugins: [sveltekit()], 6 - }); 6 + })
+2 -1
packages/tokenizer/bench/tokenize.bench.ts
··· 2 2 import { tokenize } from '../src' 3 3 4 4 bench('tokenize()', () => { 5 - const text = 'Deals quantum equal to [30,35,40,45,50] of Castorice\'s Max HP to one designated enemy.' 5 + const text = 6 + "Deals quantum equal to [30,35,40,45,50] of Castorice's Max HP to one designated enemy." 6 7 tokenize(text) 7 8 })
+18 -16
packages/tokenizer/src/tokenize.ts
··· 1 1 import { isAsciiWsp } from '@nc/whatwg-infra/codePoints' 2 2 import { stripCollapseAsciiWsp } from '@nc/whatwg-infra/strings' 3 - import type { Token, TokenDmgArray, TokenElementLiteral, TokenStringLiteral } from './types' 3 + import type { 4 + Token, 5 + TokenDmgArray, 6 + TokenElementLiteral, 7 + TokenStringLiteral, 8 + } from './types' 4 9 import { isElement, splitBy } from './utils' 5 10 6 11 /** 7 12 * Tokenizes text like `[30,35,40,45,50]` 8 13 */ 9 14 const tokenizeDmgArray = (s: string): TokenDmgArray | null => { 10 - if(!(s.startsWith('[') && s.endsWith(']'))) { 15 + if (!(s.startsWith('[') && s.endsWith(']'))) { 11 16 return null 12 17 } 13 18 ··· 17 22 18 23 for (const token of tokens) { 19 24 let n = Number.parseFloat(token) 20 - if(Number.isNaN(n)) { 25 + if (Number.isNaN(n)) { 21 26 return null 22 27 } 23 28 dmg.push(n) ··· 32 37 * @returns 33 38 */ 34 39 const tokenizeElement = (s: string): TokenElementLiteral | null => { 35 - return isElement(s) 36 - ? { kind: 'ElementLiteral', value: s } 37 - : null 40 + return isElement(s) ? { kind: 'ElementLiteral', value: s } : null 38 41 } 39 42 40 43 /** ··· 46 49 */ 47 50 const tokenizeOrStringLit = <T>( 48 51 s: string, 49 - f: (t: string) => T|null, 50 - ): T|TokenStringLiteral => { 52 + f: (t: string) => T | null, 53 + ): T | TokenStringLiteral => { 51 54 let attempt = f(s) 52 - return attempt !== null 53 - ? attempt 54 - : { kind: 'StringLiteral', value: s } 55 + return attempt !== null ? attempt : { kind: 'StringLiteral', value: s } 55 56 } 56 57 57 58 const tokenizeNaive = (s: string): Token[] => { ··· 59 60 const tokens: Token[] = [] 60 61 61 62 for (const token of normalizedTokens) { 62 - if(token.startsWith('[')) { 63 + if (token.startsWith('[')) { 63 64 tokens.push(tokenizeOrStringLit(token, tokenizeDmgArray)) 64 65 continue 65 66 } ··· 71 72 72 73 const collapseTokens = ( 73 74 tokens: Token[], 74 - shouldMerge: (prev: Token, next: Token) => boolean 75 + shouldMerge: (prev: Token, next: Token) => boolean, 75 76 ): Token[] => { 76 77 const result: Token[] = [] 77 78 let lastToken: Token | null = null ··· 107 108 108 109 export const tokenize = (s: string): Token[] => { 109 110 let pass1 = tokenizeNaive(s) 110 - let pass2 = collapseTokens(pass1, (a, b) => 111 - a.kind === 'StringLiteral' && 112 - b.kind === 'StringLiteral') 111 + let pass2 = collapseTokens( 112 + pass1, 113 + (a, b) => a.kind === 'StringLiteral' && b.kind === 'StringLiteral', 114 + ) 113 115 114 116 return pass2 115 117 }
+4 -7
packages/tokenizer/src/types.ts
··· 1 1 import type { Element } from '@starlight/types/hsr' 2 2 3 - export type TokenDmgArray = { kind: 'DmgArray', value: number[] } 4 - export type TokenElementLiteral = { kind: 'ElementLiteral', value: Element } 5 - export type TokenStringLiteral = { kind: 'StringLiteral', value: string } 3 + export type TokenDmgArray = { kind: 'DmgArray'; value: number[] } 4 + export type TokenElementLiteral = { kind: 'ElementLiteral'; value: Element } 5 + export type TokenStringLiteral = { kind: 'StringLiteral'; value: string } 6 6 7 7 export type TokenKind = Token['kind'] 8 - export type Token = 9 - | TokenDmgArray 10 - | TokenElementLiteral 11 - | TokenStringLiteral 8 + export type Token = TokenDmgArray | TokenElementLiteral | TokenStringLiteral
+10 -5
packages/tokenizer/src/utils.ts
··· 2 2 import type { TokenStringLiteral } from './types' 3 3 4 4 type PredicateFn = (s: string) => boolean 5 - export function* splitBy(str: string, predicate: PredicateFn): Generator<string> { 5 + export function* splitBy( 6 + str: string, 7 + predicate: PredicateFn, 8 + ): Generator<string> { 6 9 let current = '' 7 - for(const ch of str) { 10 + for (const ch of str) { 8 11 if (predicate(ch)) { 9 12 if (current) { 10 13 yield current ··· 28 31 29 32 // oxlint-disable-next-line typescript-eslint(no-explicit-any) 30 33 export function isStringLiteral(s: any): s is TokenStringLiteral { 31 - return (typeof s === 'object') 32 - && Object.hasOwn(s, 'kind') 33 - && s['kind'] === 'StringLiteral' 34 + return ( 35 + typeof s === 'object' && 36 + Object.hasOwn(s, 'kind') && 37 + s['kind'] === 'StringLiteral' 38 + ) 34 39 }
+12 -11
packages/tokenizer/tests/tokenize.test.ts
··· 2 2 import { tokenize } from '../src' 3 3 4 4 test('tokenize()', () => { 5 - const text = 'Deals quantum equal to [30,35,40,45,50] of Castorice\'s Max HP to one designated enemy.' 5 + const text = 6 + "Deals quantum equal to [30,35,40,45,50] of Castorice's Max HP to one designated enemy." 6 7 const tokens = tokenize(text) 7 8 8 - assert.deepEqual( 9 - tokens, 10 - [ 11 - { kind: 'StringLiteral', value: 'Deals' }, 12 - { kind: 'ElementLiteral', value: 'quantum' }, 13 - { kind: 'StringLiteral', value: 'equal to' }, 14 - { kind: 'DmgArray', value: [30, 35, 40, 45, 50]}, 15 - { kind: 'StringLiteral', value: 'of Castorice\'s Max HP to one designated enemy.' }, 16 - ] 17 - ) 9 + assert.deepEqual(tokens, [ 10 + { kind: 'StringLiteral', value: 'Deals' }, 11 + { kind: 'ElementLiteral', value: 'quantum' }, 12 + { kind: 'StringLiteral', value: 'equal to' }, 13 + { kind: 'DmgArray', value: [30, 35, 40, 45, 50] }, 14 + { 15 + kind: 'StringLiteral', 16 + value: "of Castorice's Max HP to one designated enemy.", 17 + }, 18 + ]) 18 19 })
+2 -17
packages/tokenizer/tests/utilts.test.ts
··· 3 3 import { isAsciiDigit, isAsciiWsp } from '@nc/whatwg-infra/codePoints' 4 4 5 5 describe('splitBy()', () => { 6 - 7 6 test('ascii whitespace', () => { 8 7 const input = 'foo \r\nbar\n\n baz' 9 8 const tokens = splitBy(input, isAsciiWsp) 10 9 11 - assert.deepEqual( 12 - Array.from(tokens), 13 - [ 14 - 'foo', 15 - 'bar', 16 - 'baz', 17 - ], 18 - ) 10 + assert.deepEqual(Array.from(tokens), ['foo', 'bar', 'baz']) 19 11 }) 20 12 21 13 test('ascii digit', () => { 22 14 const input = 'foo123bar456baz' 23 15 const tokens = splitBy(input, isAsciiDigit) 24 16 25 - assert.deepEqual( 26 - Array.from(tokens), 27 - [ 28 - 'foo', 29 - 'bar', 30 - 'baz', 31 - ], 32 - ) 17 + assert.deepEqual(Array.from(tokens), ['foo', 'bar', 'baz']) 33 18 }) 34 19 })
+11 -4
packages/types/src/dnd.ts
··· 26 26 27 27 export type HitDc = `${AbilityMod} ${number}` 28 28 29 - export const AbilityModArray = ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA'] as const 29 + export const AbilityModArray = [ 30 + 'STR', 31 + 'DEX', 32 + 'CON', 33 + 'INT', 34 + 'WIS', 35 + 'CHA', 36 + ] as const 30 37 export const SpellComponentArray = ['V', 'S', 'M'] as const 31 38 export const SpellSchoolArray = [ 32 39 'abjuration', ··· 45 52 export const SpellSchoolEnum = z.enum(SpellSchoolArray) 46 53 47 54 /* compile-time types */ 48 - export type AbilityMod = typeof AbilityModArray[number] 49 - export type SpellComponent = typeof SpellComponentArray[number] 50 - export type SpellSchool = typeof SpellSchoolArray[number] 55 + export type AbilityMod = (typeof AbilityModArray)[number] 56 + export type SpellComponent = (typeof SpellComponentArray)[number] 57 + export type SpellSchool = (typeof SpellSchoolArray)[number]
+4 -4
packages/types/src/hsr.ts
··· 41 41 export const DefenseMechanicEnum = z.enum(DefenseMechanicArray) 42 42 43 43 /* compile-time types */ 44 - export type Element = typeof ElementArray[number] 45 - export type Species = typeof SpeciesArray[number] 46 - export type OffenseMechanic = typeof OffenseMechanicArray[number] 47 - export type DefenseMechanic = typeof DefenseMechanicArray[number] 44 + export type Element = (typeof ElementArray)[number] 45 + export type Species = (typeof SpeciesArray)[number] 46 + export type OffenseMechanic = (typeof OffenseMechanicArray)[number] 47 + export type DefenseMechanic = (typeof DefenseMechanicArray)[number] 48 48 export type Mechanic = OffenseMechanic | DefenseMechanic
+3 -3
packages/types/tests/hsr.test-d.ts
··· 12 12 }) 13 13 14 14 test('species', () => { 15 - expectTypeOf(Array.from(SpeciesArray)).toBeArray() 15 + expectTypeOf(Array.from(SpeciesArray)).toBeArray() 16 16 }) 17 17 18 18 test('defense mechanics', () => { 19 - expectTypeOf(Array.from(DefenseMechanicArray)).toBeArray() 19 + expectTypeOf(Array.from(DefenseMechanicArray)).toBeArray() 20 20 }) 21 21 22 22 test('offense mechanics', () => { 23 - expectTypeOf(Array.from(OffenseMechanicArray)).toBeArray() 23 + expectTypeOf(Array.from(OffenseMechanicArray)).toBeArray() 24 24 }) 25 25 })
+1 -1
packages/types/tsdown.config.ts
··· 1 1 import { defineConfig } from 'tsdown' 2 2 3 3 export default defineConfig({ 4 - entry: [ 'src/dnd.ts', 'src/hsr.ts' ], 4 + entry: ['src/dnd.ts', 'src/hsr.ts'], 5 5 minify: true, 6 6 dts: true, 7 7 publint: true,
+2 -7
vitest.config.ts
··· 3 3 export default defineConfig({ 4 4 test: { 5 5 coverage: { 6 - include: [ 7 - 'packages/**/src', 8 - ], 6 + include: ['packages/**/src'], 9 7 provider: 'v8', 10 8 reportsDirectory: 'dist/vitest/coverage', 11 9 }, 12 - projects: [ 13 - 'packages/*', 14 - 'app', 15 - ], 10 + projects: ['packages/*', 'app'], 16 11 outputFile: { 17 12 html: 'dist/vitest/report/index.html', 18 13 json: 'dist/vitest/report/index.json',