Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wixc3/engine-core

Package Overview
Dependencies
Maintainers
0
Versions
340
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/engine-core - npm Package Compare versions

Comparing version 49.2.0 to 49.3.0

14

dist/entities/feature.d.ts

@@ -26,2 +26,3 @@ import { SetMultiMap } from '@wixc3/patterns';

dependencies: FeatureDependencies;
optionalDependencies: FeatureDependencies;
context: Record<string, Context<unknown>>;

@@ -33,2 +34,3 @@ static runtimeInfo: undefined | RuntimeInfo;

static dependencies<T extends FeatureClass>(): InstanceType<T>['dependencies'];
static optionalDependencies<T extends FeatureClass>(): InstanceType<T>['optionalDependencies'];
static api<T extends FeatureClass>(this: T): InstanceType<T>['api'];

@@ -64,2 +66,3 @@ static context<T extends FeatureClass>(this: T): InstanceType<T>['context'];

dependencies<T extends FeatureClass>(): InstanceType<T>['dependencies'];
optionalDependencies<T extends FeatureClass>(): InstanceType<T>['optionalDependencies'];
context<T extends FeatureClass>(): InstanceType<T>['context'];

@@ -73,8 +76,13 @@ api<T extends FeatureClass>(this: T): InstanceType<T>['api'];

dependencies: FeatureDependencies;
optionalDependencies: FeatureDependencies;
context?: Record<string, Context<unknown>>;
}
export type RunningFeatures<T extends FeatureDependencies, E extends AnyEnvironment> = {
export type RunningFeatures<T extends FeatureDependencies, O extends FeatureDependencies, E extends AnyEnvironment> = {
[K in InstanceType<T[number]>['id']]: RunningInstance<Extract<InstanceType<T[number]>, {
id: K;
}>, E>;
} & {
[K in InstanceType<O[number]>['id']]: RunningInstance<Extract<InstanceType<O[number]>, {
id: K;
}>, E> | undefined;
};

@@ -90,5 +98,5 @@ export type SettingUpFeatureBase<F extends FeatureClass, E extends AnyEnvironment> = {

export type SettingUpFeature<F extends FeatureClass, E extends AnyEnvironment> = SettingUpFeatureBase<F, E> & MapVisibleInputs<InstanceType<F>['api'], GloballyProvidingEnvironments> & MapVisibleInputs<InstanceType<F>['api'], E> & MapToProxyType<GetOnlyLocalUniversalOutputs<InstanceType<F>['api']>> & MapType<GetDependenciesOutput<InstanceType<F>['api'], DeepEnvironmentDeps<E>>> & MapToProxyType<FilterNotEnv<GetRemoteOutputs<InstanceType<F>['api']>, DeepEnvironmentDeps<E>, 'providedFrom'>>;
export type SetupHandler<F extends FeatureClass, E extends AnyEnvironment> = (feature: SettingUpFeature<F, E>, runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], E>, context: MapRecordType<NonNullable<InstanceType<F>['context']>>) => RegisteringFeature<InstanceType<F>['api'], OmitCompositeEnvironment<E>>;
export type ContextHandler<F extends FeatureClass, E extends AnyEnvironment, K extends keyof InstanceType<F>['context']> = (runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], E>) => InstanceType<F>['context'][K] extends Context<infer U> ? U & {} : {};
export type SetupHandler<F extends FeatureClass, E extends AnyEnvironment> = (feature: SettingUpFeature<F, E>, runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], InstanceType<F>['optionalDependencies'], E>, context: MapRecordType<NonNullable<InstanceType<F>['context']>>) => RegisteringFeature<InstanceType<F>['api'], OmitCompositeEnvironment<E>>;
export type ContextHandler<F extends FeatureClass, E extends AnyEnvironment, K extends keyof InstanceType<F>['context']> = (runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], InstanceType<F>['optionalDependencies'], E>) => InstanceType<F>['context'][K] extends Context<infer U> ? U & {} : {};
export {};
//# sourceMappingURL=feature.d.ts.map

@@ -24,2 +24,3 @@ import { SetMultiMap } from '@wixc3/patterns';

dependencies = [];
optionalDependencies = [];
context = {};

@@ -39,2 +40,5 @@ static runtimeInfo = undefined; // each class should have its own runtime info

}
static optionalDependencies() {
return instantiateFeature(this).optionalDependencies;
}
static api() {

@@ -41,0 +45,0 @@ return instantiateFeature(this).api;

@@ -9,2 +9,3 @@ import { type AnyEnvironment, type FeatureClass } from './entities/index.js';

features: Map<FeatureClass, RuntimeFeature<any, ENV>>;
allRequiredFeatures: Set<string>;
referencedEnvs: Set<string>;

@@ -20,2 +21,3 @@ private running;

run(features: FeatureClass | FeatureClass[]): Promise<this>;
private preRun;
initFeature<T extends FeatureClass>(feature: T): RuntimeFeature<T, ENV>;

@@ -22,0 +24,0 @@ runFeature(feature: FeatureClass): Promise<void>;

@@ -10,2 +10,3 @@ import { timeout } from 'promise-assist';

features = new Map();
allRequiredFeatures = new Set();
referencedEnvs;

@@ -42,2 +43,3 @@ running;

}
this.preRun(features);
try {

@@ -66,2 +68,15 @@ for (const feature of features) {

}
preRun(entryDeps) {
// populate required features
const toProcess = [...entryDeps];
while (toProcess.length) {
const feature = toProcess.shift();
this.allRequiredFeatures.add(feature.id);
for (const dep of feature.dependencies()) {
if (this.allRequiredFeatures.has(dep.id))
continue;
toProcess.push(dep);
}
}
}
initFeature(feature) {

@@ -68,0 +83,0 @@ let instance = this.features.get(feature);

@@ -13,3 +13,3 @@ import type { RuntimeEngine } from './runtime-engine.js';

api: Running<T, ENV>;
dependencies: RunningFeatures<InstanceType<T>['dependencies'], ENV>;
dependencies: RunningFeatures<InstanceType<T>['dependencies'], InstanceType<T>['optionalDependencies'], ENV>;
environment: ENV;

@@ -22,3 +22,3 @@ private disposables;

private disposeHandlers;
constructor(feature: InstanceType<T>, api: Running<T, ENV>, dependencies: RunningFeatures<InstanceType<T>['dependencies'], ENV>, environment: ENV);
constructor(feature: InstanceType<T>, api: Running<T, ENV>, dependencies: RunningFeatures<InstanceType<T>['dependencies'], InstanceType<T>['optionalDependencies'], ENV>, environment: ENV);
addRunHandler: (fn: () => unknown) => void;

@@ -25,0 +25,0 @@ addOnDisposeHandler: (fn: DisposeFunction) => void;

@@ -79,2 +79,9 @@ import { instantiateFeature, } from './entities/feature.js';

}
for (const dep of feature.optionalDependencies) {
if (runningEngine.allRequiredFeatures.has(dep.id)) {
const instance = runningEngine.initFeature(dep);
deps[instance.feature.id] = instance;
depsApis[instance.feature.id] = instance.api;
}
}
for (const [key, entity] of apiEntries) {

@@ -81,0 +88,0 @@ const provided = entity[CREATE_RUNTIME](runningEngine, feature.id, key);

{
"name": "@wixc3/engine-core",
"version": "49.2.0",
"version": "49.3.0",
"type": "module",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -47,2 +47,3 @@ import { SetMultiMap } from '@wixc3/patterns';

public dependencies: FeatureDependencies = [];
public optionalDependencies: FeatureDependencies = [];
public context: Record<string, Context<unknown>> = {};

@@ -62,2 +63,5 @@ static runtimeInfo: undefined | RuntimeInfo = undefined; // each class should have its own runtime info

}
static optionalDependencies<T extends FeatureClass>(): InstanceType<T>['optionalDependencies'] {
return instantiateFeature(this).optionalDependencies;
}
static api<T extends FeatureClass>(this: T): InstanceType<T>['api'] {

@@ -208,2 +212,3 @@ return instantiateFeature(this).api;

dependencies<T extends FeatureClass>(): InstanceType<T>['dependencies'];
optionalDependencies<T extends FeatureClass>(): InstanceType<T>['optionalDependencies'];
context<T extends FeatureClass>(): InstanceType<T>['context'];

@@ -219,7 +224,10 @@ api<T extends FeatureClass>(this: T): InstanceType<T>['api'];

dependencies: FeatureDependencies;
optionalDependencies: FeatureDependencies;
context?: Record<string, Context<unknown>>;
}
export type RunningFeatures<T extends FeatureDependencies, E extends AnyEnvironment> = {
export type RunningFeatures<T extends FeatureDependencies, O extends FeatureDependencies, E extends AnyEnvironment> = {
[K in InstanceType<T[number]>['id']]: RunningInstance<Extract<InstanceType<T[number]>, { id: K }>, E>;
} & {
[K in InstanceType<O[number]>['id']]: RunningInstance<Extract<InstanceType<O[number]>, { id: K }>, E> | undefined;
};

@@ -245,3 +253,7 @@

feature: SettingUpFeature<F, E>,
runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], E>,
runningFeatures: RunningFeatures<
InstanceType<F>['dependencies'],
InstanceType<F>['optionalDependencies'],
E
>,
context: MapRecordType<NonNullable<InstanceType<F>['context']>>,

@@ -255,3 +267,3 @@ ) => RegisteringFeature<InstanceType<F>['api'], OmitCompositeEnvironment<E>>;

> = (
runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], E>,
runningFeatures: RunningFeatures<InstanceType<F>['dependencies'], InstanceType<F>['optionalDependencies'], E>,
) => InstanceType<F>['context'][K] extends Context<infer U> ? U & {} : {};

@@ -15,2 +15,3 @@ import { timeout } from 'promise-assist';

public features = new Map<FeatureClass, RuntimeFeature<any, ENV>>();
public allRequiredFeatures = new Set<string>();
public referencedEnvs: Set<string>;

@@ -50,2 +51,3 @@ private running: Promise<void[]> | undefined;

}
this.preRun(features);
try {

@@ -73,2 +75,15 @@ for (const feature of features) {

private preRun(entryDeps: FeatureClass[]) {
// populate required features
const toProcess = [...entryDeps];
while (toProcess.length) {
const feature = toProcess.shift()!;
this.allRequiredFeatures.add(feature.id);
for (const dep of feature.dependencies()) {
if (this.allRequiredFeatures.has(dep.id)) continue;
toProcess.push(dep);
}
}
}
public initFeature<T extends FeatureClass>(feature: T): RuntimeFeature<T, ENV> {

@@ -75,0 +90,0 @@ let instance = this.features.get(feature);

@@ -26,3 +26,7 @@ import type { RuntimeEngine } from './runtime-engine.js';

public api: Running<T, ENV>,
public dependencies: RunningFeatures<InstanceType<T>['dependencies'], ENV>,
public dependencies: RunningFeatures<
InstanceType<T>['dependencies'],
InstanceType<T>['optionalDependencies'],
ENV
>,
public environment: ENV,

@@ -75,3 +79,3 @@ ) {

const feature = instantiateFeature(FeatureClass);
const deps: RunningFeatures<InstanceType<any>['dependencies'], any> = {};
const deps: RunningFeatures<InstanceType<any>['dependencies'], InstanceType<any>['optionalDependencies'], any> = {};
const depsApis: Record<string, Running<FeatureClass, E>> = {};

@@ -96,2 +100,10 @@ const runningApi: Record<string, unknown> = {};

for (const dep of feature.optionalDependencies) {
if (runningEngine.allRequiredFeatures.has(dep.id)) {
const instance = runningEngine.initFeature(dep);
deps[instance.feature.id] = instance;
depsApis[instance.feature.id] = instance.api;
}
}
for (const [key, entity] of apiEntries) {

@@ -98,0 +110,0 @@ const provided = entity[CREATE_RUNTIME](runningEngine, feature.id, key);

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc