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

@aurelia/kernel

Package Overview
Dependencies
Maintainers
1
Versions
1118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurelia/kernel - npm Package Compare versions

Comparing version 2.1.0-dev.202305160723 to 2.1.0-dev.202306061010

dist/types/errors.d.ts

14

CHANGELOG.md

@@ -6,2 +6,16 @@ # Change Log

<a name="2.0.0-beta.6"></a>
# 2.0.0-beta.6 (2023-05-21)
### Features:
* **di:** ability to use newInstance()/forScope() with interface (#1767) ([a0d39e9](https://github.com/aurelia/aurelia/commit/a0d39e9))
* **bindable:** support getter/setter (#1753) ([4279851](https://github.com/aurelia/aurelia/commit/4279851))
### Refactorings:
* ***:** rename resolveAll -> onResolveAll (#1764) ([fdf0747](https://github.com/aurelia/aurelia/commit/fdf0747))
* ***:** cleanup up unused code & decouple interface from default impl (#1761) ([7a71d43](https://github.com/aurelia/aurelia/commit/7a71d43))
<a name="2.0.0-beta.5"></a>

@@ -8,0 +22,0 @@ # 2.0.0-beta.5 (2023-04-27)

1

dist/types/di.d.ts

@@ -52,2 +52,3 @@ import { Constructable, IDisposable } from './interfaces';

invoke<T extends {}, TDeps extends unknown[] = unknown[]>(key: Constructable<T>, dynamicDependencies?: TDeps): T;
hasFactory<T extends Constructable>(key: any): boolean;
getFactory<T extends Constructable>(key: T): IFactory<T>;

@@ -54,0 +55,0 @@ createChild(config?: IContainerConfiguration): IContainer;

2

dist/types/functions.d.ts

@@ -98,4 +98,4 @@ import { Constructable, Overwrite } from './interfaces';

*/
export declare const resolveAll: (...maybePromises: (void | Promise<void>)[]) => void | Promise<void>;
export declare const onResolveAll: (...maybePromises: (void | Promise<void>)[]) => void | Promise<void>;
export {};
//# sourceMappingURL=functions.d.ts.map

@@ -10,4 +10,4 @@ export { IPlatform, } from './platform';

export { EventAggregator, IEventAggregator, } from './eventaggregator';
export { isArrayIndex, camelCase, kebabCase, pascalCase, toArray, bound, mergeArrays, firstDefined, getPrototypeChain, isNativeFunction, onResolve, resolveAll, } from './functions';
export { isArrayIndex, camelCase, kebabCase, pascalCase, toArray, bound, mergeArrays, firstDefined, getPrototypeChain, isNativeFunction, onResolve, onResolveAll, } from './functions';
export { type AnyFunction, type FunctionPropNames, type MaybePromise, } from './utilities';
//# sourceMappingURL=index.d.ts.map

@@ -203,3 +203,2 @@ import { IContainer, IRegistry } from './di';

readonly config: ILogConfig;
constructor(config: ILogConfig);
createLogEvent(logger: ILogger, level: LogLevel, message: string, optionalParams: unknown[]): ILogEvent;

@@ -210,3 +209,3 @@ }

readonly handleEvent: (event: ILogEvent) => void;
constructor(p: IPlatform);
constructor(p?: IPlatform);
}

@@ -236,3 +235,3 @@ export declare class DefaultLogger {

*/
config: ILogConfig, factory: ILogEventFactory, sinks: ISink[],
config?: ILogConfig, factory?: ILogEventFactory, sinks?: readonly ISink[],
/**

@@ -239,0 +238,0 @@ * The scopes that this logger was created for, if any.

{
"name": "@aurelia/kernel",
"version": "2.1.0-dev.202305160723",
"version": "2.1.0-dev.202306061010",
"main": "dist/cjs/index.cjs",

@@ -9,3 +9,4 @@ "module": "dist/esm/index.mjs",

"require": "./dist/cjs/index.cjs",
"import": "./dist/esm/index.mjs"
"import": "./dist/esm/index.mjs",
"development": "./dist/esm/index.dev.mjs"
},

@@ -52,4 +53,4 @@ "types": "dist/types/index.d.ts",

"dependencies": {
"@aurelia/metadata": "2.1.0-dev.202305160723",
"@aurelia/platform": "2.1.0-dev.202305160723"
"@aurelia/metadata": "2.1.0-dev.202306061010",
"@aurelia/platform": "2.1.0-dev.202306061010"
},

@@ -56,0 +57,0 @@ "devDependencies": {

@@ -8,3 +8,3 @@ /* eslint-disable @typescript-eslint/no-this-alias */

import { type IResourceKind, type ResourceDefinition, type ResourceType, getAllResources, hasResources } from './resource';
import { createError, createObject, getOwnMetadata, isFunction, isString, safeString } from './utilities';
import { createObject, getOwnMetadata, isFunction, isString } from './utilities';
import {

@@ -34,2 +34,3 @@ IContainer,

} from './di';
import { ErrorNames, createMappedError } from './errors';

@@ -110,3 +111,3 @@ const InstrinsicTypeNames = new Set<string>('Array ArrayBuffer Boolean DataView Date Error EvalError Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Number Object Promise RangeError ReferenceError RegExp Set SharedArrayBuffer String SyntaxError TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array URIError WeakMap WeakSet'.split(' '));

if (++this._registerDepth === 100) {
throw registrationError(params);
throw createMappedError(ErrorNames.unable_auto_register, ...params);
}

@@ -176,3 +177,3 @@ let current: IRegistry | Record<string, IRegistry>;

if (this.res[key] !== void 0) {
throw resourceExistError(key);
throw createMappedError(ErrorNames.resource_already_exists, key);
}

@@ -320,3 +321,3 @@ this.res[key] = resolver;

throw cantResolveKeyError(key);
throw createMappedError(ErrorNames.unable_resolve_key, key);
}

@@ -370,3 +371,3 @@

if (isNativeFunction(Type)) {
throw createNativeInvocationError(Type);
throw createMappedError(ErrorNames.no_construct_native_fn, Type);
}

@@ -381,2 +382,6 @@ return dynamicDependencies === void 0

public hasFactory<T extends Constructable>(key: T): boolean {
return this._factories.has(key);
}
public getFactory<K extends Constructable>(Type: K): IFactory<K> {

@@ -386,3 +391,3 @@ let factory = this._factories.get(Type);

if (isNativeFunction(Type)) {
throw createNativeInvocationError(Type);
throw createMappedError(ErrorNames.no_construct_native_fn, Type);
}

@@ -484,7 +489,7 @@ this._factories.set(Type, factory = new Factory<K>(Type, getDependencies(Type)));

if (!isFunction(keyAsValue)) {
throw jitRegisterNonFunctionError(keyAsValue);
throw createMappedError(ErrorNames.unable_jit_non_constructor, keyAsValue);
}
if (InstrinsicTypeNames.has(keyAsValue.name)) {
throw jitInstrinsicTypeError(keyAsValue);
throw createMappedError(ErrorNames.no_jit_intrinsic_type, keyAsValue);
}

@@ -499,3 +504,3 @@

}
throw invalidResolverFromRegisterError();
throw createMappedError(ErrorNames.null_resolver_from_register, keyAsValue);
}

@@ -520,7 +525,7 @@ return registrationResolver as IResolver;

}
throw invalidResolverFromRegisterError();
throw createMappedError(ErrorNames.null_resolver_from_register, keyAsValue);
}
if (keyAsValue.$isInterface) {
throw jitInterfaceError(keyAsValue.friendlyName);
throw createMappedError(ErrorNames.no_jit_interface, keyAsValue.friendlyName);
}

@@ -574,7 +579,3 @@

if (key === null || key === void 0) {
if (__DEV__) {
throw createError(`AUR0014: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?`);
} else {
throw createError(`AUR0014`);
}
throw createMappedError(ErrorNames.null_undefined_key);
}

@@ -613,3 +614,3 @@ }

if (currentContainer == null) {
throw createInvalidResolveCallError();
throw createMappedError(ErrorNames.no_active_container_for_resolve, ...keys);
}

@@ -659,41 +660,1 @@ return keys.length === 1

isString(key) && key.indexOf(':') > 0;
const registrationError = (deps: Key[]) =>
// TODO: change to reporter.error and add various possible causes in description.
// Most likely cause is trying to register a plain object that does not have a
// register method and is not a class constructor
__DEV__
? createError(`AUR0006: Unable to autoregister dependency: [${deps.map(safeString)}]`)
: createError(`AUR0006:${deps.map(safeString)}`);
const resourceExistError = (key: Key) =>
__DEV__
? createError(`AUR0007: Resource key "${safeString(key)}" already registered`)
: createError(`AUR0007:${safeString(key)}`);
const cantResolveKeyError = (key: Key) =>
__DEV__
? createError(`AUR0008: Unable to resolve key: ${safeString(key)}`)
: createError(`AUR0008:${safeString(key)}`);
const jitRegisterNonFunctionError = (keyAsValue: Key) =>
__DEV__
? createError(`AUR0009: Attempted to jitRegister something that is not a constructor: '${safeString(keyAsValue)}'. Did you forget to register this resource?`)
: createError(`AUR0009:${safeString(keyAsValue)}`);
const jitInstrinsicTypeError = (keyAsValue: any) =>
__DEV__
? createError(`AUR0010: Attempted to jitRegister an intrinsic type: ${keyAsValue.name}. Did you forget to add @inject(Key)`)
: createError(`AUR0010:${keyAsValue.name}`);
const invalidResolverFromRegisterError = () =>
__DEV__
? createError(`AUR0011: Invalid resolver returned from the static register method`)
: createError(`AUR0011`);
const jitInterfaceError = (name: string) =>
__DEV__
? createError(`AUR0012: Attempted to jitRegister an interface: ${name}`)
: createError(`AUR0012:${name}`);
const createNativeInvocationError = (Type: Constructable): Error =>
__DEV__
? createError(`AUR0015: ${Type.name} is a native function and therefore cannot be safely constructed by DI. If this is intentional, please use a callback or cachedCallback resolver.`)
: createError(`AUR0015:${Type.name}`);
const createInvalidResolveCallError = () =>
__DEV__
? createError(`AUR0016: There is not a currently active container. Are you trying to "new Class(...)" that has a resolve(...) call?`)
: createError(`AUR0016`);

@@ -5,3 +5,2 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { applyMetadataPolyfill } from '@aurelia/metadata';

@@ -12,10 +11,12 @@

import { isArrayIndex } from './functions';
import { Container, resolve } from './di.container';
import { Constructable, IDisposable, Writable } from './interfaces';
import { Container } from './di.container';
import { Constructable, IDisposable } from './interfaces';
import { appendAnnotation, getAnnotationKeyFor, IResourceKind, ResourceDefinition, ResourceType } from './resource';
import { createError, defineMetadata, getOwnMetadata, isFunction, isString, safeString } from './utilities';
import { defineMetadata, getOwnMetadata, isFunction, isString, safeString } from './utilities';
import { instanceRegistration, singletonRegistration, transientRegistation, callbackRegistration, cachedCallbackRegistration, aliasToRegistration, deferRegistration, cacheCallbackResult } from './di.registration';
import { ErrorNames, createMappedError } from './errors';
export type ResolveCallback<T = any> = (handler: IContainer, requestor: IContainer, resolver: IResolver<T>) => T;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type InterfaceSymbol<K = any> = (target: Injectable | AbstractInjectable, property: string | symbol | undefined, index?: number) => void;

@@ -79,2 +80,4 @@

invoke<T extends {}, TDeps extends unknown[] = unknown[]>(key: Constructable<T>, dynamicDependencies?: TDeps): T;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
hasFactory<T extends Constructable>(key: any): boolean;
getFactory<T extends Constructable>(key: T): IFactory<T>;

@@ -175,3 +178,3 @@ createChild(config?: IContainerConfiguration): IContainer;

none(key: Key): IResolver {
throw noResolverForKeyError(key);
throw createMappedError(ErrorNames.none_resolver_found, key);
},

@@ -182,7 +185,2 @@ singleton: (key: Key): IResolver => new Resolver(key, ResolverStrategy.singleton, key),

const noResolverForKeyError = (key: Key) =>
__DEV__
? createError(`AUR0002: ${safeString(key)} not registered, did you forget to add @singleton()?`)
: createError(`AUR0002:${safeString(key)}`);
export class ContainerConfiguration implements IContainerConfiguration {

@@ -316,3 +314,3 @@ public static readonly DEFAULT: ContainerConfiguration = ContainerConfiguration.from({});

if (target == null || new.target !== undefined) {
throw createNoRegistrationError(friendlyName);
throw createMappedError(ErrorNames.no_registration_for_interface, friendlyName);
}

@@ -334,6 +332,2 @@ const annotationParamtypes = getOrCreateAnnotationParamTypes(target as Injectable);

};
const createNoRegistrationError = (name: string) =>
__DEV__
? createError(`AUR0001: No registration for interface: '${name}'`)
: createError(`AUR0001:${name}`);

@@ -513,2 +507,3 @@ export const DI = {

*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function transient<T extends Constructable>(): typeof transientDecorator;

@@ -547,3 +542,5 @@ /**

*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function singleton<T extends Constructable>(): typeof singletonDecorator;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function singleton<T extends Constructable>(options?: SingletonOptions): typeof singletonDecorator;

@@ -743,2 +740,19 @@ /**

const createNewInstance = (key: any, handler: IContainer, requestor: IContainer) => {
// 1. if there's a factory registration for the key
if (handler.hasFactory(key)) {
return handler.getFactory(key).construct(requestor);
}
// 2. if key is an interface
if (isInterface(key)) {
const hasDefault = isFunction((key as unknown as IRegistry).register);
const resolver = handler.getResolver(key, hasDefault) as IResolver<Constructable<typeof key>>;
const factory = resolver?.getFactory?.(handler);
// 2.1 and has factory
if (factory != null) {
return factory.construct(requestor);
}
// 2.2 cannot instantiate a dummy interface
throw createMappedError(ErrorNames.invalid_new_instance_on_interface, key);
}
// 3. jit factory, in case of newInstanceOf(SomeClass)
return handler.getFactory(key).construct(requestor);

@@ -780,3 +794,3 @@ };

if (this.resolving) {
throw cyclicDependencyError(this._state.name);
throw createMappedError(ErrorNames.cyclic_dependency, this._state.name);
}

@@ -793,3 +807,3 @@ this.resolving = true;

if (factory === null) {
throw nullFactoryError(this._key);
throw createMappedError(ErrorNames.no_factory, this._key);
}

@@ -805,3 +819,3 @@ return factory.construct(requestor);

default:
throw invalidResolverStrategyError(this._strategy);
throw createMappedError(ErrorNames.invalid_resolver_strategy, this._strategy);
}

@@ -822,14 +836,2 @@ }

}
const cyclicDependencyError = (name: string) =>
__DEV__
? createError(`AUR0003: Cyclic dependency found: ${name}`)
: createError(`AUR0003:${name}`);
const nullFactoryError = (key: Key) =>
__DEV__
? createError(`AUR0004: Resolver for ${safeString(key)} returned a null factory`)
: createError(`AUR0004:${safeString(key)}`);
const invalidResolverStrategyError = (strategy: ResolverStrategy) =>
__DEV__
? createError(`AUR0005: Invalid resolver strategy specified: ${strategy}.`)
: createError(`AUR0005:${strategy}`);

@@ -991,3 +993,3 @@ /** @internal */

if (this._instance == null) {
throw noInstanceError(this._name);
throw createMappedError(ErrorNames.no_instance_provided, this._name);
}

@@ -1002,8 +1004,2 @@ return this._instance;

const noInstanceError = (name?: string) => {
if (__DEV__) {
return createError(`AUR0013: Cannot call resolve ${name} before calling prepare or after calling dispose.`);
} else {
return createError(`AUR0013:${name}`);
}
};
const isInterface = <K>(key: any): key is InterfaceSymbol<K> => isFunction(key) && key.$isInterface === true;
import { createInterface } from './di';
import { ErrorNames, createMappedError } from './errors';
import { Constructable, IDisposable } from './interfaces';
import { createError, isString } from './utilities';
import { isString } from './utilities';

@@ -57,3 +58,3 @@ /**

if (!channelOrInstance) {
throw createError(`Invalid channel name or instance: ${channelOrInstance}.`);
throw createMappedError(ErrorNames.event_aggregator_publish_invalid_event_name, channelOrInstance);
}

@@ -107,3 +108,3 @@

if (!channelOrType) {
throw createError(`Invalid channel name or type: ${channelOrType}.`);
throw createMappedError(ErrorNames.event_aggregator_subscribe_invalid_event_name, channelOrType);
}

@@ -110,0 +111,0 @@

@@ -0,3 +1,4 @@

import { ErrorNames, createMappedError } from './errors';
import { Constructable, Overwrite } from './interfaces';
import { createError, createObject } from './utilities';
import { createObject } from './utilities';

@@ -285,3 +286,3 @@ const isNumericLookup: Record<string, boolean> = {};

}
throw createError(`No default value found`);
throw createMappedError(ErrorNames.first_defined_no_value);
};

@@ -451,3 +452,3 @@

*/
export const resolveAll = (
export const onResolveAll = (
...maybePromises: (void | Promise<void>)[]

@@ -454,0 +455,0 @@ ): void | Promise<void> => {

@@ -121,3 +121,3 @@ export {

onResolve,
resolveAll,
onResolveAll,
} from './functions';

@@ -124,0 +124,0 @@

import { Metadata } from '@aurelia/metadata';
import { all, createInterface, IContainer, ignore, IRegistry, optional } from './di';
import { all, createInterface, IContainer, IRegistry, optional } from './di';
import { instanceRegistration, singletonRegistration } from './di.registration';

@@ -9,2 +9,3 @@ import { bound, toLookup } from './functions';

import { createObject, defineMetadata, isFunction } from './utilities';
import { resolve } from './di.container';

@@ -318,5 +319,3 @@ export const enum LogLevel {

export class DefaultLogEventFactory implements ILogEventFactory {
public constructor(
@ILogConfig public readonly config: ILogConfig,
) {}
public readonly config = resolve(ILogConfig);

@@ -336,3 +335,3 @@ public createLogEvent(logger: ILogger, level: LogLevel, message: string, optionalParams: unknown[]): ILogEvent {

public constructor(
@IPlatform p: IPlatform,
p = resolve(IPlatform),
) {

@@ -421,2 +420,3 @@ const $console = p.console as {

/* eslint-disable default-param-last */
public constructor(

@@ -426,11 +426,12 @@ /**

*/
@ILogConfig config: ILogConfig,
@ILogEventFactory factory: ILogEventFactory,
@all(ISink) sinks: ISink[],
config = resolve(ILogConfig),
factory = resolve(ILogEventFactory),
sinks = resolve(all(ISink)),
/**
* The scopes that this logger was created for, if any.
*/
@optional(ILogScopes) public readonly scope: string[] = [],
@ignore parent: DefaultLogger | null = null,
public readonly scope: string[] = resolve(optional(ILogScopes)) ?? [],
parent: DefaultLogger | null = null,
) {
/* eslint-enable default-param-last */
let traceSinks: ISink[];

@@ -681,3 +682,3 @@ let debugSinks: ISink[];

if (scopedLogger === void 0) {
scopedLogger = scopedLoggers[name] = new DefaultLogger(this.config, this._factory, (void 0)!, this.scope.concat(name), this);
scopedLogger = scopedLoggers[name] = new DefaultLogger(this.config, this._factory, null!, this.scope.concat(name), this);
}

@@ -684,0 +685,0 @@ return scopedLogger;

import { createInterface } from './di';
import { emptyArray } from './platform';
import { getAllResources } from './resource';
import { createError, isFunction } from './utilities';
import { isFunction } from './utilities';

@@ -9,2 +9,3 @@ import type { IRegistry } from './di';

import type { ResourceDefinition } from './resource';
import { ErrorNames, createMappedError } from './errors';

@@ -40,3 +41,3 @@ export interface IModule {

} else {
throw createError(`Invalid input: ${String(objOrPromise)}. Expected Promise or Object.`);
throw createMappedError(ErrorNames.invalid_module_transform_input, objOrPromise);
}

@@ -81,3 +82,3 @@ }

private _analyze(m: TMod): AnalyzedModule<TMod> {
if (m == null) throw new Error(`Invalid input: ${String(m)}. Expected Object.`);
if (m == null) throw createMappedError(ErrorNames.invalid_module_transform_input, m);
if (typeof m !== 'object') return new AnalyzedModule(m, []);

@@ -84,0 +85,0 @@ let value: unknown;

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

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