mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Require requests and responses for RequestChannels be JsonValues for serialization
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
c156dcf4ae
commit
2fc30f6ce5
@ -7,7 +7,7 @@ import type { RequestChannel } from "./request-channel-injection-token";
|
|||||||
import type { RequestChannelListener } from "./request-channel-listener-injection-token";
|
import type { RequestChannelListener } from "./request-channel-listener-injection-token";
|
||||||
|
|
||||||
export type EnlistRequestChannelListener = <
|
export type EnlistRequestChannelListener = <
|
||||||
TChannel extends RequestChannel<unknown, unknown>,
|
TChannel extends RequestChannel<any, any>,
|
||||||
>(listener: RequestChannelListener<TChannel>) => () => void;
|
>(listener: RequestChannelListener<TChannel>) => () => void;
|
||||||
|
|
||||||
export const enlistRequestChannelListenerInjectionToken =
|
export const enlistRequestChannelListenerInjectionToken =
|
||||||
|
|||||||
@ -4,8 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||||
|
import type { JsonValue } from "type-fest";
|
||||||
|
|
||||||
export interface RequestChannel<Request = void, Response = void> {
|
export interface RequestChannel<
|
||||||
|
Request extends JsonValue | void = void,
|
||||||
|
Response extends JsonValue | void = void,
|
||||||
|
> {
|
||||||
id: string;
|
id: string;
|
||||||
_requestSignature?: Request;
|
_requestSignature?: Request;
|
||||||
_responseSignature?: Response;
|
_responseSignature?: Response;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import type { SetRequired } from "type-fest";
|
|||||||
import type { RequestChannel } from "./request-channel-injection-token";
|
import type { RequestChannel } from "./request-channel-injection-token";
|
||||||
|
|
||||||
export type RequestFromChannel = <
|
export type RequestFromChannel = <
|
||||||
TChannel extends RequestChannel<unknown, unknown>,
|
TChannel extends RequestChannel<any, any>,
|
||||||
>(
|
>(
|
||||||
channel: TChannel,
|
channel: TChannel,
|
||||||
...request: TChannel["_requestSignature"] extends void
|
...request: TChannel["_requestSignature"] extends void
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { requestChannelInjectionToken } from "../channel/request-channel-injecti
|
|||||||
|
|
||||||
export type SyncBoxInitialValueChannel = RequestChannel<
|
export type SyncBoxInitialValueChannel = RequestChannel<
|
||||||
void,
|
void,
|
||||||
{ id: string; value: unknown }[]
|
{ id: string; value: any }[]
|
||||||
>;
|
>;
|
||||||
|
|
||||||
const syncBoxInitialValueChannelInjectable = getInjectable({
|
const syncBoxInitialValueChannelInjectable = getInjectable({
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import requestFromChannelInjectable from "../../renderer/channel/request-from-ch
|
|||||||
export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => {
|
export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => {
|
||||||
const requestChannelListenerFakesForMain = new Map<
|
const requestChannelListenerFakesForMain = new Map<
|
||||||
string,
|
string,
|
||||||
RequestChannelListener<RequestChannel<unknown, unknown>>
|
RequestChannelListener<RequestChannel<any, any>>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
mainDi.override(
|
mainDi.override(
|
||||||
@ -27,9 +27,9 @@ export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => {
|
|||||||
requestChannelListenerFakesForMain.set(
|
requestChannelListenerFakesForMain.set(
|
||||||
listener.channel.id,
|
listener.channel.id,
|
||||||
|
|
||||||
// TODO: Figure out typingo
|
// TODO: Figure out typing
|
||||||
listener as unknown as RequestChannelListener<
|
listener as unknown as RequestChannelListener<
|
||||||
RequestChannel<unknown, unknown>
|
RequestChannel<any, any>
|
||||||
>,
|
>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user