Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export default tseslint.config(
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}],
},
},
{
Expand Down
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/adapters/angular.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./module-stubs.d.ts" />
import {
Component,
Input,
Expand All @@ -10,8 +12,6 @@ import {
ElementRef,
ViewChild,
ChangeDetectionStrategy,
inject,
effect,
signal,
} from '@angular/core';
import { Gracket } from '../core/Gracket';
Expand Down Expand Up @@ -50,7 +50,6 @@ export class GracketComponent implements OnInit, OnDestroy, OnChanges {
// Using signals for reactive state - Angular 18+ best practice
protected error = signal<Error | null>(null);
private gracketInstance = signal<Gracket | null>(null);
private elementRef = inject(ElementRef);

ngOnInit(): void {
// Initialize will happen after view init when container is available
Expand Down
108 changes: 108 additions & 0 deletions src/adapters/module-stubs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
/* eslint-disable @typescript-eslint/no-empty-object-type */
/* eslint-disable @typescript-eslint/no-unused-vars */
// Type stubs for optional peer dependencies during build
// These allow TypeScript to compile without having the actual packages installed
// This file provides minimal type definitions to satisfy TypeScript when peer dependencies are not installed

// Svelte 5 runes support
declare function $state<T>(initial: T): T;
declare function $effect(fn: () => void | (() => void)): void;
declare function $derived<T>(fn: () => T): T;

// Solid JSX namespace augmentation
declare namespace JSX {
interface IntrinsicElements {
div: {
ref?: any;
class?: string;
className?: string;
style?: any;
children?: any;
[key: string]: any;
};
[elemName: string]: any;
}
}

declare module '@angular/core' {
export interface Type<T> extends Function {
new (...args: any[]): T;
}
export interface SimpleChange {
firstChange: boolean;
previousValue: any;
currentValue: any;
isFirstChange(): boolean;
}
export interface SimpleChanges {
[propName: string]: SimpleChange;
}
export class EventEmitter<T> {
emit(value?: T): void;
subscribe(generatorOrNext?: any, error?: any, complete?: any): any;
}
export class ElementRef<T = any> {
nativeElement: T;
}
export interface OnInit {
ngOnInit(): void;
}
export interface OnDestroy {
ngOnDestroy(): void;
}
export interface OnChanges {
ngOnChanges(changes: SimpleChanges): void;
}
export const ChangeDetectionStrategy: {
OnPush: number;
Default: number;
};
export function Component(obj: any): any;
export function Input(obj?: any): any;
export function Output(obj?: any): any;
export function ViewChild(selector: string | Type<any>, opts?: any): any;
export function inject<T>(token: Type<T> | any): T;
export function signal<T>(initialValue: T): any;
}

declare module 'solid-js' {
export interface Component<P = {}> {
(props: P): any;
}
export namespace JSX {
export interface CSSProperties {
[key: string]: string | number | undefined;
}
export interface Element {}
export interface IntrinsicElements {
div: any;
[elemName: string]: any;
}
}
export function createSignal<T>(initialValue: T): [() => T, (v: T) => void];
export function createEffect(fn: () => void): void;
export function onMount(fn: () => void): void;
export function onCleanup(fn: () => void): void;
export function mergeProps<T extends object, U extends object>(defaults: Partial<T>, props: U): T & U;
export function mergeProps<A extends object, B extends object, C extends object>(a: A, b: B, c: C): A & B & C;
export function mergeProps(...args: any[]): any;
}

declare module 'svelte' {
export class SvelteComponent<Props = any, Events = any, Slots = any> {
constructor(options: any);
$on(event: string, handler: (e: any) => any): () => void;
$set(props: Partial<Props>): void;
$destroy(): void;
}
export function onMount(fn: () => any): void;
export function onDestroy(fn: () => any): void;
export function createEventDispatcher<T = any>(): (event: string, detail?: any) => void;
}

declare module './svelte.svelte' {
const component: any;
export default component;
}
8 changes: 5 additions & 3 deletions src/adapters/solid.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./module-stubs.d.ts" />
import {
createSignal,
createEffect,
Expand Down Expand Up @@ -27,8 +29,8 @@ export interface GracketSolidProps extends Omit<GracketOptions, 'src'> {
* SolidJS component wrapper for Gracket
* Uses modern SolidJS best practices with fine-grained reactivity
*/
export const GracketSolid: Component<GracketSolidProps> = (props) => {
const merged = mergeProps({ class: '', style: {} }, props);
export const GracketSolid: Component<GracketSolidProps> = (props: GracketSolidProps) => {
const merged = mergeProps({ class: '', style: {} as JSX.CSSProperties }, props) as Required<Pick<GracketSolidProps, 'class' | 'style'>> & GracketSolidProps;

let containerRef: HTMLDivElement | undefined;
let gracketInstance: Gracket | null = null;
Expand All @@ -40,7 +42,7 @@ export const GracketSolid: Component<GracketSolidProps> = (props) => {
if (!containerRef || !merged.data?.length) return;

try {
const { data, onInit, onError, class: _, style: __, ...options } = merged;
const { data, class: _class, style: _style, ...options } = merged;

gracketInstance = new Gracket(containerRef, {
...options,
Expand Down
32 changes: 32 additions & 0 deletions src/adapters/svelte.svelte.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Type declaration for Svelte component
import type { SvelteComponent } from 'svelte';
import type { Gracket } from '../core/Gracket';
import type { GracketOptions, TournamentData } from '../types';

export interface GracketSvelteProps {
data: TournamentData;
options?: Omit<GracketOptions, 'src'>;
className?: string;
style?: string;
}

export interface GracketSvelteEvents {
init: CustomEvent<Gracket>;
error: CustomEvent<Error>;
update: CustomEvent<TournamentData>;
}

export default class GracketSvelte extends SvelteComponent<
GracketSvelteProps,
GracketSvelteEvents
> {
updateScore(
roundIndex: number,
gameIndex: number,
teamIndex: number,
score: number
): void;
advanceRound(fromRound?: number): TournamentData | undefined;
getInstance(): Gracket | null;
destroy(): void;
}
2 changes: 2 additions & 0 deletions src/adapters/svelte.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./module-stubs.d.ts" />
import { Gracket } from '../core/Gracket';
import type { GracketOptions, TournamentData } from '../types';

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/webcomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GracketElement extends HTMLElement {
private container: HTMLDivElement | null = null;
private _data: TournamentData = [];
private _options: Omit<GracketOptions, 'src'> = {};
private shadowRoot: ShadowRoot;
declare shadowRoot: ShadowRoot;

// Observed attributes for reactive updates
static get observedAttributes() {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"declarationMap": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
Expand All @@ -24,5 +24,5 @@
"declarationDir": "./dist"
},
"include": ["src"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx", "src/adapters/svelte.svelte"]
}