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

@travetto/di

Package Overview
Dependencies
Maintainers
1
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/di - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

.eslintrc

2

package.json

@@ -24,3 +24,3 @@ {

},
"version": "0.0.22"
"version": "0.0.23"
}

@@ -10,3 +10,3 @@ import { Dependency, InjectableConfig, ClassTarget, InjectableFactoryConfig } from '../types';

export interface ManagedExtra {
postConstruct?: () => any
postConstruct?: () => any;
}

@@ -26,3 +26,3 @@

} else if (isPlainObject(o.original)) {
deepAssign(o, o.original)
deepAssign(o, o.original);
}

@@ -54,2 +54,52 @@ o.original = undefined;

private async createInstance<T>(target: ClassTarget<T>, qualifier: symbol = DEFAULT_INSTANCE) {
const targetId = target.__id;
if (!this.instances.has(targetId)) {
this.instances.set(targetId, new Map());
this.instancePromises.set(targetId, new Map());
}
if (this.instancePromises.get(targetId)!.has(qualifier)) {
return this.instancePromises.get(targetId)!.get(qualifier);
}
const instancePromise = this.construct(target, qualifier);
this.instancePromises.get(targetId)!.set(qualifier, instancePromise);
const instance = await instancePromise;
if (AppEnv.watch) {
if (!this.proxies.has(targetId)) {
this.proxies.set(targetId, new Map());
this.proxyHandlers.set(targetId, new Map());
}
}
let out: any = instance;
console.debug('Creating Instance', targetId, AppEnv.watch,
!this.proxyHandlers.has(targetId),
this.proxyHandlers.has(targetId) && !this.proxyHandlers.get(targetId)!.has(qualifier));
// if in watch mode, create proxies
if (AppEnv.watch) {
if (!this.proxies.get(targetId)!.has(qualifier)) {
const handler = new RetargettingHandler(out);
const proxy = new Proxy({}, handler);
this.proxyHandlers.get(targetId)!.set(qualifier, handler);
this.proxies.get(targetId)!.set(qualifier, proxy);
out = proxy;
console.debug('Registering proxy', target.__id, qualifier);
} else {
const handler = this.proxyHandlers.get(targetId)!.get(qualifier)!;
console.debug('Updating target', target.__id, qualifier, out);
handler.target = out;
out = this.proxies.get(targetId)!.get(qualifier);
}
}
this.instances.get(targetId)!.set(qualifier, out);
}
async initialInstall() {

@@ -97,3 +147,3 @@ const finalizing = this.pendingFinalize;

const consDeps = managed.dependencies.cons || [];
const allDeps = consDeps.concat(fieldKeys.map(x => managed.dependencies.fields[x]))
const allDeps = consDeps.concat(fieldKeys.map(x => managed.dependencies.fields[x]));

@@ -127,3 +177,3 @@ for (const dep of allDeps) {

return { consValues, fields }
return { consValues, fields };
}

@@ -164,52 +214,2 @@

private async createInstance<T>(target: ClassTarget<T>, qualifier: symbol = DEFAULT_INSTANCE) {
const targetId = target.__id;
if (!this.instances.has(targetId)) {
this.instances.set(targetId, new Map());
this.instancePromises.set(targetId, new Map());
}
if (this.instancePromises.get(targetId)!.has(qualifier)) {
return this.instancePromises.get(targetId)!.get(qualifier);
}
const instancePromise = this.construct(target, qualifier);
this.instancePromises.get(targetId)!.set(qualifier, instancePromise);
const instance = await instancePromise;
if (AppEnv.watch) {
if (!this.proxies.has(targetId)) {
this.proxies.set(targetId, new Map());
this.proxyHandlers.set(targetId, new Map());
}
}
let out: any = instance;
console.debug('Creating Instance', targetId, AppEnv.watch,
!this.proxyHandlers.has(targetId),
this.proxyHandlers.has(targetId) && !this.proxyHandlers.get(targetId)!.has(qualifier))
// if in watch mode, create proxies
if (AppEnv.watch) {
if (!this.proxies.get(targetId)!.has(qualifier)) {
const handler = new RetargettingHandler(out);
const proxy = new Proxy({}, handler);
this.proxyHandlers.get(targetId)!.set(qualifier, handler);
this.proxies.get(targetId)!.set(qualifier, proxy);
out = proxy;
console.debug('Registering proxy', target.__id, qualifier);
} else {
const handler = this.proxyHandlers.get(targetId)!.get(qualifier)!;
console.debug('Updating target', target.__id, qualifier, out);
handler.target = out;
out = this.proxies.get(targetId)!.get(qualifier);
}
}
this.instances.get(targetId)!.set(qualifier, out);
}
async getInstance<T>(target: ClassTarget<T>, qualifier: symbol = DEFAULT_INSTANCE): Promise<T> {

@@ -228,3 +228,3 @@ const targetId = target.__id;

const aliasedIds = aliasMap ? Array.from(aliasMap.values()) : [];
return aliasedIds.map(id => this.get(id)!)
return aliasedIds.map(id => this.get(id)!);
}

@@ -376,3 +376,3 @@

priority: config.autoCreate.priority!
})
});
}

@@ -394,3 +394,3 @@

) {
const handler = this.proxyHandlers.get(targetId)!.get(config)
const handler = this.proxyHandlers.get(targetId)!.get(config);
if (handler) {

@@ -397,0 +397,0 @@ handler.target = null;

@@ -12,3 +12,3 @@ import { Class } from '@travetto/registry';

};
autoCreate: { priority?: number, create: boolean }
autoCreate: { priority?: number, create: boolean };
}

@@ -27,5 +27,5 @@

qualifier?: symbol;
dependencies?: Dependency<any>[]
autoCreate?: boolean
dependencies?: Dependency<any>[];
autoCreate?: boolean;
original?: Symbol | object;
}

@@ -7,3 +7,3 @@ import * as ts from 'typescript';

...ConfigLoader.get('registry.injectable'),
'@travetto/di': 'Injectable'
'@travetto/di': ['Injectable']
});

@@ -14,3 +14,3 @@

decorators: { [key: string]: ts.Expression };
import?: ts.Identifier
import?: ts.Identifier;
}

@@ -251,2 +251,2 @@

phase: 'before'
}
};

@@ -39,4 +39,4 @@ import { Injectable, Inject, InjectableFactory } from '../src';

export const SERVICE_INHERIT_2 = Symbol()
export const SERVICE_INHERIT_3 = Symbol()
export const SERVICE_INHERIT_2 = Symbol();
export const SERVICE_INHERIT_3 = Symbol();

@@ -43,0 +43,0 @@ @Injectable(SERVICE_INHERIT_2)

@@ -72,3 +72,3 @@ import { DependencyRegistry } from '../src/service';

assert(1 === 1);
console.log('hi')
console.log('hi');

@@ -75,0 +75,0 @@ assert(2 + 2 === FOUR);

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