From c8ff25825002c3627b9c5670a4e8083988ce99ad Mon Sep 17 00:00:00 2001 From: Josh Howenstine Date: Tue, 12 Mar 2024 11:49:04 -0700 Subject: [PATCH] fix: add ts definition for context --- .../@lightningjs/ui-components/index.d.ts | 2 +- .../src/globals/context/index.d.ts | 33 +++++++++++++++++++ .../ui-components/src/globals/index-remove.js | 21 ------------ 3 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 packages/@lightningjs/ui-components/src/globals/context/index.d.ts delete mode 100644 packages/@lightningjs/ui-components/src/globals/index-remove.js diff --git a/packages/@lightningjs/ui-components/index.d.ts b/packages/@lightningjs/ui-components/index.d.ts index eec50849c..e17c35be9 100644 --- a/packages/@lightningjs/ui-components/index.d.ts +++ b/packages/@lightningjs/ui-components/index.d.ts @@ -19,7 +19,7 @@ export * from './src/components'; export * from './src/mixins'; export * from './src/types/lui'; -// export * from './src/globals'; +export * from './src/globals'; // exports without type definitions export { default as utils } from './src/utils'; diff --git a/packages/@lightningjs/ui-components/src/globals/context/index.d.ts b/packages/@lightningjs/ui-components/src/globals/context/index.d.ts new file mode 100644 index 000000000..c4d06a146 --- /dev/null +++ b/packages/@lightningjs/ui-components/src/globals/context/index.d.ts @@ -0,0 +1,33 @@ +type ThemeObject = any; + +export class Context { + get theme(): ThemeObject; + set theme(value: ThemeObject); + get keyMetricsCallback(): object; + set keyMetricsCallback(value: object); + get debug(): boolean; + set debug(value: boolean); + + on(name: string, callback: Function): void; + off(name: string, callback?: Function): void; + emit(name: string, payload: string | object | number | boolean): void; + + log(...args: any[]): void; + info(...args: any[]): void; + warn(...args: any[]): void; + error(...args: any[]): void; + + setTheme(value: object | any[]): ThemeObject; + updateTheme(value: object | any[]): ThemeObject; + getSubTheme(subThemeName: string): ThemeObject; + setSubThemes(subThemesObj: Record): void; + setSubTheme(subThemeName: string, value: any): ThemeObject; + updateSubTheme(subThemeName: string, value: any): ThemeObject; + removeSubTheme(subThemeName: string): void; + setLogCallback(value: Function): void; + setKeyMetricsCallback(value: Function): void; + config(config: Record): Context; +} + +declare const contextInstance: Context; +export default contextInstance; diff --git a/packages/@lightningjs/ui-components/src/globals/index-remove.js b/packages/@lightningjs/ui-components/src/globals/index-remove.js deleted file mode 100644 index 753ff3fe3..000000000 --- a/packages/@lightningjs/ui-components/src/globals/index-remove.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2023 Comcast Cable Communications Management, LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -export { default as context } from './context'; -export { updateManager } from './global-update-manager/GlobalUpdateManager'; -export { default as pool } from './pool';