@wixc3/engine-runtime-node
Advanced tools
Comparing version 22.3.2 to 23.0.0-alpha.0
import { EnvironmentTypes } from '@wixc3/engine-core'; | ||
import type { IEnvironment, IStaticFeatureDefinition } from './types'; | ||
export declare function resolveEnvironments(featureName: string, features: Map<string, Required<IStaticFeatureDefinition>>, envTypes?: EnvironmentTypes[] | EnvironmentTypes, filterByContext?: boolean): Set<IEnvironment>; | ||
import type { IEnvironmentDescriptor, IStaticFeatureDefinition } from './types'; | ||
export declare function resolveEnvironments(featureName: string, features: Map<string, Required<IStaticFeatureDefinition>>, envTypes?: EnvironmentTypes[] | EnvironmentTypes, filterByContext?: boolean): Set<IEnvironmentDescriptor<import("@wixc3/engine-core").AnyEnvironment>>; | ||
//# sourceMappingURL=environments.d.ts.map |
@@ -1,8 +0,8 @@ | ||
import { IFeatureLoader, RuntimeEngine } from '@wixc3/engine-core'; | ||
import type { IEnvironment, StartEnvironmentOptions, IStaticFeatureDefinition } from './types'; | ||
export declare function runNodeEnvironment({ featureName, childEnvName, features, config, name, type, options, host, externalFeatures, context, }: StartEnvironmentOptions): Promise<{ | ||
import { IFeatureLoader, RuntimeEngine, AnyEnvironment } from '@wixc3/engine-core'; | ||
import type { IEnvironmentDescriptor, StartEnvironmentOptions, IStaticFeatureDefinition } from './types'; | ||
export declare function runNodeEnvironment<ENV extends AnyEnvironment>({ featureName, childEnvName, features, config, name, type, options, host, externalFeatures, context, env, }: StartEnvironmentOptions<ENV>): Promise<{ | ||
dispose: () => Promise<void>; | ||
engine: RuntimeEngine; | ||
engine: RuntimeEngine<ENV>; | ||
}>; | ||
export declare function createFeatureLoaders(features: Map<string, Required<IStaticFeatureDefinition>>, { name: envName, childEnvName }: IEnvironment): Record<string, IFeatureLoader>; | ||
export declare function createFeatureLoaders(features: Map<string, Required<IStaticFeatureDefinition>>, { childEnvName, name: envName, env }: IEnvironmentDescriptor): Record<string, IFeatureLoader>; | ||
//# sourceMappingURL=node-environment.d.ts.map |
@@ -24,4 +24,4 @@ "use strict"; | ||
const engine_core_1 = require("@wixc3/engine-core"); | ||
const extrenal_request_mapper_1 = require("./extrenal-request-mapper"); | ||
async function runNodeEnvironment({ featureName, childEnvName, features, config = [], name, type, options, host, externalFeatures = [], context, }) { | ||
const external_request_mapper_1 = require("./external-request-mapper"); | ||
async function runNodeEnvironment({ featureName, childEnvName, features, config = [], name, type, options, host, externalFeatures = [], context, env, }) { | ||
if (host) { | ||
@@ -39,2 +39,3 @@ config.push(engine_core_1.COM.use({ | ||
type, | ||
env, | ||
}); | ||
@@ -56,3 +57,3 @@ const rootFeatureLoader = featureLoaders[featureName]; | ||
// mapping all found feature file requests to the current running context, so that external features, when importing feature files, will evaluate the files under the current context | ||
[...features.values()].map(([, { packageName }]) => (0, extrenal_request_mapper_1.remapToUserLibrary)({ | ||
[...features.values()].map(([, { packageName }]) => (0, external_request_mapper_1.remapToUserLibrary)({ | ||
test: (request) => request.includes(packageName), | ||
@@ -62,3 +63,3 @@ context, | ||
// mapping all features to be evaluated from the context of their package location | ||
externalFeatures.map(({ packageName, packageBasePath }) => (0, extrenal_request_mapper_1.remapToUserLibrary)({ | ||
externalFeatures.map(({ packageName, packageBasePath }) => (0, external_request_mapper_1.remapToUserLibrary)({ | ||
test: (request) => request.includes(packageName), | ||
@@ -68,3 +69,3 @@ context: packageBasePath, | ||
// initializing our module system tricks to be able to load all features from their proper context, so that features will not be loaded twice | ||
(0, extrenal_request_mapper_1.init)(); | ||
(0, external_request_mapper_1.init)(); | ||
} | ||
@@ -83,3 +84,3 @@ for (const { scopedName: externalFeatureName, envEntries } of externalFeatures) { | ||
if (context) { | ||
(0, extrenal_request_mapper_1.clear)(); | ||
(0, external_request_mapper_1.clear)(); | ||
} | ||
@@ -89,5 +90,5 @@ const runtimeEngine = (0, engine_core_1.runEngineApp)({ | ||
options: new Map(options), | ||
envName: name, | ||
features: runningFeatures, | ||
resolvedContexts, | ||
env, | ||
}); | ||
@@ -97,3 +98,3 @@ return runtimeEngine; | ||
exports.runNodeEnvironment = runNodeEnvironment; | ||
function createFeatureLoaders(features, { name: envName, childEnvName }) { | ||
function createFeatureLoaders(features, { childEnvName, name: envName, env }) { | ||
const featureLoaders = {}; | ||
@@ -129,5 +130,7 @@ for (const { scopedName, filePath, dependencies, envFilePaths, contextFilePaths, resolvedContexts, preloadFilePaths, } of features.values()) { | ||
} | ||
const envFilePath = envFilePaths[envName]; | ||
if (envFilePath) { | ||
await Promise.resolve().then(() => __importStar(require(envFilePath))); | ||
for (const { env: envName } of new Set([env, ...env.dependencies])) { | ||
const envFilePath = envFilePaths[envName]; | ||
if (envFilePath) { | ||
await Promise.resolve().then(() => __importStar(require(envFilePath))); | ||
} | ||
} | ||
@@ -134,0 +137,0 @@ return (await Promise.resolve().then(() => __importStar(require(filePath)))).default; |
import io from 'socket.io'; | ||
import { TopLevelConfig, SetMultiMap, Communication, BaseHost, Message } from '@wixc3/engine-core'; | ||
import { IConfigDefinition, IEnvironment, TopLevelConfigProvider, IExternalFeatureNodeDescriptor, IStaticFeatureDefinition } from './types'; | ||
import { IConfigDefinition, IEnvironmentDescriptor, TopLevelConfigProvider, IExternalFeatureNodeDescriptor, IStaticFeatureDefinition } from './types'; | ||
export interface OverrideConfig { | ||
@@ -45,3 +45,3 @@ configName?: string; | ||
export interface ILaunchEnvironmentOptions { | ||
nodeEnv: IEnvironment; | ||
nodeEnv: IEnvironmentDescriptor; | ||
featureName: string; | ||
@@ -48,0 +48,0 @@ config: TopLevelConfig; |
@@ -27,2 +27,3 @@ "use strict"; | ||
const connectedEnvironments = {}; | ||
//TODO: check | ||
for (const [envName, config] of (_a = message.data.config) !== null && _a !== void 0 ? _a : []) { | ||
@@ -29,0 +30,0 @@ if (envName === engine_core_1.COM.id) { |
@@ -1,4 +0,4 @@ | ||
import type { EnvironmentTypes, TopLevelConfig, BaseHost } from '@wixc3/engine-core'; | ||
import type { EnvironmentTypes, TopLevelConfig, BaseHost, Environment, AnyEnvironment, MultiEnvironment } from '@wixc3/engine-core'; | ||
export declare type TopLevelConfigProvider = (envName: string) => TopLevelConfig; | ||
export interface IExtenalFeatureDescriptor { | ||
export interface IExternalFeatureDescriptor { | ||
envEntries: Record<string, Record<string, string>>; | ||
@@ -25,8 +25,8 @@ packageBasePath: string; | ||
filePath: string; | ||
exportedEnvs?: IEnvironment[]; | ||
exportedEnvs?: IEnvironmentDescriptor<AnyEnvironment>[]; | ||
} | ||
export interface IExternalFeatureNodeDescriptor extends IExtenalFeatureDescriptor, IStaticFeatureDefinition { | ||
export interface IExternalFeatureNodeDescriptor extends IExternalFeatureDescriptor, IStaticFeatureDefinition { | ||
} | ||
export declare const isProcessMessage: (value: unknown) => value is IProcessMessage<unknown>; | ||
export interface StartEnvironmentOptions extends IEnvironment { | ||
export interface StartEnvironmentOptions<ENV extends AnyEnvironment = AnyEnvironment> extends IEnvironmentDescriptor<ENV> { | ||
featureName: string; | ||
@@ -72,3 +72,3 @@ config?: TopLevelConfig; | ||
id: 'start'; | ||
data: StartEnvironmentOptions; | ||
data: StartEnvironmentOptions<Environment>; | ||
} | ||
@@ -81,6 +81,8 @@ export interface RemoteProcess { | ||
} | ||
export interface IEnvironment { | ||
export interface IEnvironmentDescriptor<ENV extends AnyEnvironment = AnyEnvironment> { | ||
type: EnvironmentTypes; | ||
name: string; | ||
childEnvName?: string; | ||
flatDependencies?: IEnvironmentDescriptor<MultiEnvironment<ENV['envType']>>[]; | ||
env: ENV; | ||
} | ||
@@ -87,0 +89,0 @@ export declare const isEnvironmentStartMessage: (message: ICommunicationMessage) => message is IEnvironmentStartMessage; |
@@ -6,3 +6,3 @@ import type io from 'socket.io'; | ||
start: () => Promise<{ | ||
runtimeEngine: import("@wixc3/engine-core").RuntimeEngine; | ||
runtimeEngine: import("@wixc3/engine-core").RuntimeEngine<import("@wixc3/engine-core").AnyEnvironment>; | ||
close: () => Promise<void>; | ||
@@ -9,0 +9,0 @@ host: WsServerHost; |
{ | ||
"name": "@wixc3/engine-runtime-node", | ||
"version": "22.3.2", | ||
"version": "23.0.0-alpha.0", | ||
"main": "dist/index.js", | ||
@@ -10,5 +10,5 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@wixc3/cross-performance": "^22.2.1", | ||
"@wixc3/engine-core": "^22.3.2", | ||
"@wixc3/engine-core-node": "^22.3.2", | ||
"@wixc3/cross-performance": "^23.0.0-alpha.0", | ||
"@wixc3/engine-core": "^23.0.0-alpha.0", | ||
"@wixc3/engine-core-node": "^23.0.0-alpha.0", | ||
"create-listening-server": "^1.0.0", | ||
@@ -15,0 +15,0 @@ "minimist": "^1.2.5", |
import { flattenTree, EnvironmentTypes } from '@wixc3/engine-core'; | ||
import type { IEnvironment, IStaticFeatureDefinition } from './types'; | ||
import type { IEnvironmentDescriptor, IStaticFeatureDefinition } from './types'; | ||
@@ -11,3 +11,3 @@ export function resolveEnvironments( | ||
const environmentTypesToFilterBy = Array.isArray(envTypes) ? envTypes : [envTypes]; | ||
const filteredEnvironments = new Set<IEnvironment>(); | ||
const filteredEnvironments = new Set<IEnvironmentDescriptor>(); | ||
@@ -14,0 +14,0 @@ const featureDefinition = features.get(featureName); |
@@ -9,8 +9,9 @@ import { | ||
IPreloadModule, | ||
AnyEnvironment, | ||
} from '@wixc3/engine-core'; | ||
import { init, remapToUserLibrary, clear } from './extrenal-request-mapper'; | ||
import { init, remapToUserLibrary, clear } from './external-request-mapper'; | ||
import type { IEnvironment, StartEnvironmentOptions, IStaticFeatureDefinition } from './types'; | ||
import type { IEnvironmentDescriptor, StartEnvironmentOptions, IStaticFeatureDefinition } from './types'; | ||
export async function runNodeEnvironment({ | ||
export async function runNodeEnvironment<ENV extends AnyEnvironment>({ | ||
featureName, | ||
@@ -26,5 +27,6 @@ childEnvName, | ||
context, | ||
}: StartEnvironmentOptions): Promise<{ | ||
env, | ||
}: StartEnvironmentOptions<ENV>): Promise<{ | ||
dispose: () => Promise<void>; | ||
engine: RuntimeEngine; | ||
engine: RuntimeEngine<ENV>; | ||
}> { | ||
@@ -46,2 +48,3 @@ if (host) { | ||
type, | ||
env, | ||
}); | ||
@@ -106,5 +109,5 @@ const rootFeatureLoader = featureLoaders[featureName]; | ||
options: new Map(options), | ||
envName: name, | ||
features: runningFeatures, | ||
resolvedContexts, | ||
env, | ||
}); | ||
@@ -117,3 +120,3 @@ | ||
features: Map<string, Required<IStaticFeatureDefinition>>, | ||
{ name: envName, childEnvName }: IEnvironment | ||
{ childEnvName, name: envName, env }: IEnvironmentDescriptor | ||
) { | ||
@@ -159,6 +162,7 @@ const featureLoaders: Record<string, IFeatureLoader> = {}; | ||
} | ||
const envFilePath = envFilePaths[envName]; | ||
if (envFilePath) { | ||
await import(envFilePath); | ||
for (const { env: envName } of new Set([env, ...env.dependencies])) { | ||
const envFilePath = envFilePaths[envName]; | ||
if (envFilePath) { | ||
await import(envFilePath); | ||
} | ||
} | ||
@@ -165,0 +169,0 @@ return ((await import(filePath)) as { default: Feature }).default; |
@@ -21,3 +21,3 @@ import type { Socket } from 'net'; | ||
IConfigDefinition, | ||
IEnvironment, | ||
IEnvironmentDescriptor, | ||
IEnvironmentMessage, | ||
@@ -110,3 +110,3 @@ IEnvironmentStartMessage, | ||
export interface ILaunchEnvironmentOptions { | ||
nodeEnv: IEnvironment; | ||
nodeEnv: IEnvironmentDescriptor; | ||
featureName: string; | ||
@@ -190,3 +190,3 @@ config: TopLevelConfig; | ||
const envHostMapping = new Map<IEnvironment, ChildBaseHost>(); | ||
const envHostMapping = new Map<IEnvironmentDescriptor, ChildBaseHost>(); | ||
for (const nodeEnv of nodeEnvironments) { | ||
@@ -193,0 +193,0 @@ const host = new ChildBaseHost(baseHost); |
@@ -40,2 +40,3 @@ import type io from 'socket.io'; | ||
const connectedEnvironments: Record<string, ConfigEnvironmentRecord> = {}; | ||
//TODO: check | ||
for (const [envName, config] of message.data.config ?? []) { | ||
@@ -42,0 +43,0 @@ if (envName === COM.id) { |
@@ -1,6 +0,13 @@ | ||
import type { EnvironmentTypes, TopLevelConfig, BaseHost } from '@wixc3/engine-core'; | ||
import type { | ||
EnvironmentTypes, | ||
TopLevelConfig, | ||
BaseHost, | ||
Environment, | ||
AnyEnvironment, | ||
MultiEnvironment, | ||
} from '@wixc3/engine-core'; | ||
export type TopLevelConfigProvider = (envName: string) => TopLevelConfig; | ||
export interface IExtenalFeatureDescriptor { | ||
export interface IExternalFeatureDescriptor { | ||
envEntries: Record<string, Record<string, string>>; | ||
@@ -28,6 +35,6 @@ packageBasePath: string; | ||
filePath: string; | ||
exportedEnvs?: IEnvironment[]; | ||
exportedEnvs?: IEnvironmentDescriptor<AnyEnvironment>[]; | ||
} | ||
export interface IExternalFeatureNodeDescriptor extends IExtenalFeatureDescriptor, IStaticFeatureDefinition {} | ||
export interface IExternalFeatureNodeDescriptor extends IExternalFeatureDescriptor, IStaticFeatureDefinition {} | ||
@@ -37,3 +44,4 @@ export const isProcessMessage = (value: unknown): value is IProcessMessage<unknown> => | ||
export interface StartEnvironmentOptions extends IEnvironment { | ||
export interface StartEnvironmentOptions<ENV extends AnyEnvironment = AnyEnvironment> | ||
extends IEnvironmentDescriptor<ENV> { | ||
featureName: string; | ||
@@ -96,3 +104,3 @@ config?: TopLevelConfig; | ||
id: 'start'; | ||
data: StartEnvironmentOptions; | ||
data: StartEnvironmentOptions<Environment>; | ||
} | ||
@@ -107,6 +115,8 @@ | ||
export interface IEnvironment { | ||
export interface IEnvironmentDescriptor<ENV extends AnyEnvironment = AnyEnvironment> { | ||
type: EnvironmentTypes; | ||
name: string; | ||
childEnvName?: string; | ||
flatDependencies?: IEnvironmentDescriptor<MultiEnvironment<ENV['envType']>>[]; | ||
env: ENV; | ||
} | ||
@@ -113,0 +123,0 @@ |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
151413
2487
2
2
+ Added@wixc3/cross-performance@23.0.0(transitive)
+ Added@wixc3/engine-core@23.2.0(transitive)
+ Added@wixc3/engine-core-node@23.2.0(transitive)
- Removed@wixc3/cross-performance@22.3.3(transitive)
- Removed@wixc3/engine-core@22.4.1(transitive)
- Removed@wixc3/engine-core-node@22.4.1(transitive)