Skip to content
Open
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
62 changes: 57 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// blits file type reference
/// <reference path="./blits.d.ts" />

import {type ShaderEffect as RendererShaderEffect, type WebGlCoreShader, type RendererMainSettings} from '@lightningjs/renderer'

declare module '@lightningjs/blits' {

type RendererShaderEffect = import('@lightningjs/renderer').ShaderEffect
type WebGlCoreShader = import('@lightningjs/renderer').WebGlCoreShader
type RendererMainSettings = import('@lightningjs/renderer').RendererMainSettings

export interface AnnouncerUtteranceOptions {
/**
Expand Down Expand Up @@ -209,7 +209,7 @@ declare module '@lightningjs/blits' {
}

export interface Input {
[key: string]: (event: KeyboardEvent) => void | undefined | unknown,
[key: string]: ((event: KeyboardEvent) => unknown) | undefined,
/**
* Catch all input function
*
Expand Down Expand Up @@ -371,6 +371,29 @@ declare module '@lightningjs/blits' {
// Empty by design: extend in your app via TypeScript module augmentation.
}

export interface LanguagePlugin {
translate(key: string, ...replacements: any[]): string
readonly language: string
set(language: string): void
translations(translationsObject: Record<string, unknown>): void
load(file: string): Promise<void>
}

export interface ThemePlugin {
get<T = unknown>(key: string): T | undefined
get<T>(key: string, fallback: T): T
set(theme: string): void
}

export interface StoragePlugin {
get<T = unknown>(key: string): T | null
set(key: string, value: unknown): boolean
remove(key: string): void
clear(): void
}

export type AppStatePlugin<TState extends Record<string, unknown> = Record<string, unknown>> = TState

export interface ComponentBase extends CustomComponentProperties {
/**
* Indicates whether the component currently has focus
Expand Down Expand Up @@ -633,7 +656,7 @@ declare module '@lightningjs/blits' {
}

export interface RouterHooks {
init?: () => Promise<> | void;
init?: () => Promise<void> | void;
beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route> | void;
error?: (err: string) => string | Route | Promise<string | Route> | void;
}
Expand Down Expand Up @@ -1301,3 +1324,32 @@ declare module '@lightningjs/blits' {

export default Blits;
}

declare module '@lightningjs/blits/plugins' {
import type {
AppStatePlugin,
LanguagePlugin,
StoragePlugin,
ThemePlugin,
} from '@lightningjs/blits'

export const language: {
name: 'language'
plugin: (options?: Record<string, unknown>) => LanguagePlugin
}

export const theme: {
name: 'theme'
plugin: (config?: Record<string, unknown>) => ThemePlugin
}

export const appState: {
name: 'appState'
plugin: <TState extends Record<string, unknown>>(state?: TState) => AppStatePlugin<TState>
}

export const storage: {
name: 'storage'
plugin: () => StoragePlugin
}
}