@wixc3/engine-core
Advanced tools
Comparing version 5.0.1 to 6.0.0
import { Message } from './message-types'; | ||
import { AsyncApi, EnvironmentInstanceToken, SerializableArguments, Target, WindowHost } from './types'; | ||
import { EndpointType, Environment, NodeEnvironment, SingleEndpointContextualEnvironment } from '../entities/env'; | ||
import { Environment, NodeEnvironment, SingleEndpointContextualEnvironment } from '../entities/env'; | ||
import { IDTag } from '../types'; | ||
@@ -9,3 +9,4 @@ export interface ICommunicationOptions { | ||
/** | ||
* Main class that manage all api registration and message forwarding in each execution context. | ||
* Manages all API registrations and message forwarding | ||
* in each execution context. | ||
*/ | ||
@@ -43,3 +44,3 @@ export declare class Communication { | ||
getEnvironmentContext(endPoint: SingleEndpointContextualEnvironment<string, Environment[]>): string; | ||
spawn(endPoint: Environment<string, EndpointType>, host?: WindowHost): Promise<{ | ||
spawn(endPoint: Environment, host?: WindowHost): Promise<{ | ||
id: string; | ||
@@ -46,0 +47,0 @@ }>; |
@@ -10,3 +10,4 @@ "use strict"; | ||
/** | ||
* Main class that manage all api registration and message forwarding in each execution context. | ||
* Manages all API registrations and message forwarding | ||
* in each execution context. | ||
*/ | ||
@@ -13,0 +14,0 @@ class Communication { |
@@ -22,3 +22,3 @@ import { EnvironmentTypes } from '../com/types'; | ||
} | ||
export declare class SingleEndpointContextualEnvironment<ID extends string, T extends Array<Environment<string, EndpointType>>> extends Environment<ID, 'single'> { | ||
export declare class SingleEndpointContextualEnvironment<ID extends string, T extends Environment[]> extends Environment<ID, 'single'> { | ||
environments: T; | ||
@@ -25,0 +25,0 @@ envType: "context"; |
@@ -7,5 +7,5 @@ import { AsyncApi, EnvironmentInstanceToken } from '../com/types'; | ||
import { FeatureOutput } from './output'; | ||
declare type ServiceRuntime<Type, ProvidedFrom> = ProvidedFrom extends Environment<string, 'single'> ? AsyncApi<Type> : ProvidedFrom extends Environment<string, 'multi'> ? { | ||
get(token: EnvironmentInstanceToken): AsyncApi<Type>; | ||
} : AsyncApi<Type>; | ||
export declare type ServiceRuntime<T, ProvidedFrom> = ProvidedFrom extends Environment<string, 'single'> ? AsyncApi<T> : ProvidedFrom extends Environment<string, 'multi'> ? { | ||
get(token: EnvironmentInstanceToken): AsyncApi<T>; | ||
} : AsyncApi<T>; | ||
export declare class Service<T, PT, ProvidedFrom extends EnvVisibility, VisibleAt extends EnvVisibility, RemoteAccess extends boolean> extends FeatureOutput<T, PT, ProvidedFrom, VisibleAt, RemoteAccess> { | ||
@@ -24,3 +24,2 @@ providedFrom: ProvidedFrom; | ||
} | ||
export {}; | ||
//# sourceMappingURL=service.d.ts.map |
@@ -23,5 +23,2 @@ "use strict"; | ||
} | ||
// public allowRemoteAccess<U extends ServiceRuntime<T, ProvidedFrom>> = ServiceRuntime<T, ProvidedFrom>>() { | ||
// return new Service<T, U, ProvidedFrom, AllEnvironments>(this.providedFrom, AllEnvironments, true) | ||
// } | ||
[symbols_1.REGISTER_VALUE](runtimeEngine, providedValue, inputValue, featureID, entityKey) { | ||
@@ -48,3 +45,2 @@ if (this.remoteAccess) { | ||
} | ||
// TODO: here! | ||
getApiProxy(context, serviceKey) { | ||
@@ -51,0 +47,0 @@ const { communication } = context.getCOM().api; |
{ | ||
"name": "@wixc3/engine-core", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"main": "cjs/index.js", | ||
@@ -5,0 +5,0 @@ "types": "cjs/index.d.ts", |
@@ -29,3 +29,3 @@ import { | ||
import { SetMultiMap } from '@file-services/utils'; | ||
import { EndpointType, Environment, NodeEnvironment, SingleEndpointContextualEnvironment } from '../entities/env'; | ||
import { Environment, NodeEnvironment, SingleEndpointContextualEnvironment } from '../entities/env'; | ||
import { IDTag } from '../types'; | ||
@@ -40,3 +40,4 @@ import { BaseHost } from './base-host'; | ||
/** | ||
* Main class that manage all api registration and message forwarding in each execution context. | ||
* Manages all API registrations and message forwarding | ||
* in each execution context. | ||
*/ | ||
@@ -58,2 +59,3 @@ export class Communication { | ||
private options: Required<ICommunicationOptions>; | ||
constructor( | ||
@@ -87,2 +89,3 @@ host: Target, | ||
} | ||
/** | ||
@@ -116,3 +119,3 @@ * Registers local api implementation of the remote service. | ||
public async spawn(endPoint: Environment<string, EndpointType>, host?: WindowHost) { | ||
public async spawn(endPoint: Environment, host?: WindowHost) { | ||
const { endpointType, env, envType } = endPoint; | ||
@@ -131,2 +134,3 @@ | ||
} | ||
/** | ||
@@ -157,2 +161,3 @@ * Connects to a remote NodeEnvironment | ||
} | ||
/** | ||
@@ -186,2 +191,3 @@ * Creates a Proxy for a remote service api. | ||
} | ||
/** | ||
@@ -222,2 +228,3 @@ * Generate client id for newly spawned environment. | ||
} | ||
/** | ||
@@ -323,2 +330,3 @@ * handles Communication incoming message. | ||
} | ||
private apiCall(from: string, api: string, method: string, args: unknown[]): unknown { | ||
@@ -356,2 +364,3 @@ if (this.apisOverrides[api] && this.apisOverrides[api][method]) { | ||
} | ||
private resolveMessageTarget(envId: string): Target { | ||
@@ -427,2 +436,3 @@ // TODO: make this more logical | ||
} | ||
private async handleCall(message: CallMessage): Promise<void> { | ||
@@ -447,2 +457,3 @@ try { | ||
} | ||
private handleCallback(message: CallbackMessage): void { | ||
@@ -457,2 +468,3 @@ const rec = message.callbackId ? this.callbacks[message.callbackId] : null; | ||
} | ||
private createDispatcher(envId: string, message: ListenMessage): SerializableMethod { | ||
@@ -470,2 +482,3 @@ const id = message.data.handlerId; | ||
} | ||
private isListenCall(args: unknown[]): boolean { | ||
@@ -479,2 +492,3 @@ return typeof args[0] === 'function' && args.length === 1; | ||
}; | ||
private createHandlerRecord( | ||
@@ -528,2 +542,3 @@ envId: string, | ||
} | ||
private injectScript(win: Window, rootComId: string, scriptUrl: string) { | ||
@@ -530,0 +545,0 @@ return new Promise<Window>((res, rej) => { |
@@ -27,6 +27,6 @@ import { EnvironmentTypes } from '../com/types'; | ||
export class SingleEndpointContextualEnvironment< | ||
ID extends string, | ||
T extends Array<Environment<string, EndpointType>> | ||
> extends Environment<ID, 'single'> { | ||
export class SingleEndpointContextualEnvironment<ID extends string, T extends Environment[]> extends Environment< | ||
ID, | ||
'single' | ||
> { | ||
public envType = 'context' as const; | ||
@@ -33,0 +33,0 @@ constructor(env: ID, public environments: T) { |
@@ -8,9 +8,9 @@ import { AsyncApi, EnvironmentInstanceToken } from '../com/types'; | ||
type ServiceRuntime<Type, ProvidedFrom> = ProvidedFrom extends Environment<string, 'single'> | ||
? AsyncApi<Type> | ||
export type ServiceRuntime<T, ProvidedFrom> = ProvidedFrom extends Environment<string, 'single'> | ||
? AsyncApi<T> | ||
: ProvidedFrom extends Environment<string, 'multi'> | ||
? { | ||
get(token: EnvironmentInstanceToken): AsyncApi<Type>; | ||
get(token: EnvironmentInstanceToken): AsyncApi<T>; | ||
} | ||
: AsyncApi<Type>; | ||
: AsyncApi<T>; | ||
@@ -39,8 +39,9 @@ export class Service< | ||
public allowRemoteAccess() { | ||
type U = ServiceRuntime<T, ProvidedFrom>; | ||
return new Service<T, U, ProvidedFrom, Environment, true>(this.providedFrom, AllEnvironments, true); | ||
return new Service<T, ServiceRuntime<T, ProvidedFrom>, ProvidedFrom, Environment, true>( | ||
this.providedFrom, | ||
AllEnvironments, | ||
true | ||
); | ||
} | ||
// public allowRemoteAccess<U extends ServiceRuntime<T, ProvidedFrom>> = ServiceRuntime<T, ProvidedFrom>>() { | ||
// return new Service<T, U, ProvidedFrom, AllEnvironments>(this.providedFrom, AllEnvironments, true) | ||
// } | ||
public [REGISTER_VALUE]( | ||
@@ -69,2 +70,3 @@ runtimeEngine: RuntimeEngine, | ||
} | ||
public [CREATE_RUNTIME](context: RuntimeEngine, featureID: string, entityKey: string) { | ||
@@ -75,3 +77,3 @@ if (this.remoteAccess) { | ||
} | ||
// TODO: here! | ||
public getApiProxy(context: RuntimeEngine, serviceKey: string): any { | ||
@@ -91,2 +93,3 @@ const { communication } = context.getCOM().api; | ||
} | ||
function getSingleInstanceId(providedFrom: any): string | void { | ||
@@ -93,0 +96,0 @@ if (isSingleInstance(providedFrom)) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
254505
4305