Skip to content
Open
Changes from 1 commit
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
73 changes: 67 additions & 6 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 @@ -365,12 +365,44 @@ declare module '@lightningjs/blits' {
// Extension point for app- and plugin-specific fields on the component `this`.
// Add your own properties (e.g., `$telemetry`, `componentName`) via TypeScript
// module augmentation in your app, without changing core types.
// Public extension point for app/plugin augmentation via module augmentation.
// Note: `ComponentBase` extends this interface, so augmented fields appear in all
// hooks, methods, input, computed, and watch.
export interface CustomComponentProperties {
export interface ComponentCustomProperties {
// Empty by design: extend in your app via TypeScript module augmentation.
}

/**
* @deprecated Use `ComponentCustomProperties`.
*
* Kept for backwards compatibility so existing module augmentations of
* `CustomComponentProperties` continue to flow into component `this`.
*/
export interface CustomComponentProperties extends ComponentCustomProperties {}

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 +665,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 +1333,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
}
}