1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Move types of injectable and injectable-react to the library

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2021-11-19 15:38:24 +02:00
parent c9503c1d14
commit 7b6a7059bf
4 changed files with 11 additions and 138 deletions

View File

@ -188,8 +188,8 @@
"@kubernetes/client-node": "^0.15.1",
"@sentry/electron": "^2.5.4",
"@sentry/integrations": "^6.15.0",
"@ogre-tools/injectable": "^1.1.0",
"@ogre-tools/injectable-react": "^1.2.0",
"@ogre-tools/injectable": "^1.2.1",
"@ogre-tools/injectable-react": "^1.2.1",
"abort-controller": "^3.0.0",
"auto-bind": "^4.0.0",
"autobind-decorator": "^2.4.0",

View File

@ -1,42 +0,0 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/// <reference types="react" />
declare module "@ogre-tools/injectable-react" {
import type { DependencyInjectionContainer, Injectable } from "@ogre-tools/injectable";
interface DependencyInjectionContainerProviderProps {
di: DependencyInjectionContainer;
}
export const DiContextProvider: React.Provider<DependencyInjectionContainerProviderProps>;
export const Inject: <
TComponentInjectable extends Injectable<any>,
>({
Component,
injectableKey,
getPlaceholder,
...props
}: Parameters<TComponentInjectable["instantiate"]>[1] & {
injectableKey: TComponentInjectable;
getPlaceholder?: () => JSX.Element | null;
}) => JSX.Element;
}

View File

@ -1,85 +0,0 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
declare module "@ogre-tools/injectable" {
type Awaited<TMaybePromise> = TMaybePromise extends PromiseLike<infer TValue>
? TValue
: TMaybePromise;
export interface DependencyInjectionContainer {
inject: <
TInjectable extends Injectable<TInstance, TDependencies>,
TInstance,
TDependencies,
TMaybePromiseInstance = ReturnType<TInjectable["instantiate"]>,
>(
injectableKey: TInjectable,
) => TMaybePromiseInstance extends PromiseLike<any>
? Awaited<TMaybePromiseInstance>
: TMaybePromiseInstance;
}
export interface ConfigurableDependencyInjectionContainer
extends DependencyInjectionContainer {
register: (injectable: Injectable<any>) => void;
preventSideEffects: () => void;
override: <TInjectable extends Injectable<TInstance, any>, TInstance>(
injectable: TInjectable,
overrider:
| ReturnType<TInjectable["instantiate"]>
| jest.MockInstance<
ReturnType<TInjectable["instantiate"]>,
ReturnType<TInjectable["getDependencies"]>
>,
) => void;
}
export interface Injectable<
TInstance,
TDependencies extends object = {},
TInstantiationParameter extends object = {},
> {
id?: string;
getDependencies: (
di?: DependencyInjectionContainer,
) => TDependencies | Promise<TDependencies>;
lifecycle?: lifecycleEnum;
instantiate: (
dependencies: TDependencies,
instantiationParameter: TInstantiationParameter,
) => Promise<TInstance> | TInstance;
causesSideEffects?: boolean;
}
export enum lifecycleEnum {
singleton,
transient,
scopedTransient,
}
// eslint-disable-next-line unused-imports/no-unused-vars-ts
export const createContainer = (...getRequireContexts: any[]) =>
ConfigurableDependencyInjectionContainer;
}

View File

@ -953,19 +953,19 @@
dependencies:
lodash "^4.17.21"
"@ogre-tools/injectable-react@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-1.2.0.tgz#1634f702bf017f934d06e4332505c2c4aa0d87d6"
integrity sha512-T4GEuK0HBIHgE5B2WoibDaeQvhn1jgwwsR1K6fy5sYkNnU5Qa4LlciCuxHU7j7dKy6cDVwNWQVg/OXocb0h0lA==
"@ogre-tools/injectable-react@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable-react/-/injectable-react-1.2.1.tgz#886fbb9f9816d68daf41b6fd7ff5def6eae833b4"
integrity sha512-kr9Q2T/VyhtUG8EbfzpFPk2ndwKQl9WHzqEfp8fasAXMNmUfUnyWs6iPNoJiuy2gh4/CNBvlFB8c647ls6/jUA==
dependencies:
"@ogre-tools/fp" "^1.0.2"
"@ogre-tools/injectable" "^1.1.0"
"@ogre-tools/injectable" "^1.2.1"
lodash "^4.17.21"
"@ogre-tools/injectable@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-1.1.0.tgz#095c9d12001d03dd96c98d8986392b0fee05262c"
integrity sha512-ViuFC2iHM86os87W2qubUCAlPYzdxmZwtPBAExb2SLNMHk8Z8dRx9BGDk8AcfCd8aPUw5GHIgf7wxCAMWcyvlw==
"@ogre-tools/injectable@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@ogre-tools/injectable/-/injectable-1.2.1.tgz#f3eb481806dd6e53af8d9d37f8b20f3c0d875a60"
integrity sha512-bfTlnT08uDydE0i5GxJ9SIoRKfNYVabQRrZfBraZi2rs3zx+DOpcZrJjhjDoSCzIr6C2azySuyxn1h8x8CMUPw==
dependencies:
"@ogre-tools/fp" "^1.0.2"
lodash "^4.17.21"