@aurelia/kernel
Advanced tools
Comparing version
@@ -6,2 +6,15 @@ # Change Log | ||
<a name="2.0.0-beta.19"></a> | ||
# 2.0.0-beta.19 (2024-06-12) | ||
### Features: | ||
* **di:** ability to deregister key (#1981) ([8eb5c36](https://github.com/aurelia/aurelia/commit/8eb5c36)) | ||
* **dialog:** ability to animate using animator instead of lifecycles (#1986) ([a2477e5](https://github.com/aurelia/aurelia/commit/a2477e5)) | ||
### Refactorings: | ||
* **projection:** use $all instead of * to include all node types (#1987) ([337cb34](https://github.com/aurelia/aurelia/commit/337cb34)) | ||
<a name="2.0.0-beta.18"></a> | ||
@@ -8,0 +21,0 @@ # 2.0.0-beta.18 (2024-05-23) |
@@ -64,2 +64,3 @@ import { Constructable, IDisposable } from './interfaces'; | ||
disposeResolvers(): void; | ||
deregister(key: Key): void; | ||
/** | ||
@@ -66,0 +67,0 @@ * Register resources from another container, an API for manually registering resources |
@@ -98,4 +98,4 @@ import { Constructable, Overwrite } from './interfaces'; | ||
*/ | ||
export declare const onResolveAll: (...maybePromises: (void | Promise<void>)[]) => void | Promise<void>; | ||
export declare const onResolveAll: (...maybePromises: unknown[]) => void | Promise<void>; | ||
export {}; | ||
//# sourceMappingURL=functions.d.ts.map |
export { IPlatform, } from './platform'; | ||
export { DI, IContainer, type IFactory, inject, type IRegistration, type IRegistry, type IResolver, IServiceLocator, type Key, type RegisterSelf, type ResolveCallback, singleton, transient, type AbstractInjectable, type Injectable, type InterfaceSymbol, InstanceProvider, type Resolved, type Transformer, type IContainerConfiguration, } from './di'; | ||
export { DI, IContainer, type IFactory, inject, type IRegistration, type IRegistry, type IResolver, type IDisposableResolver, IServiceLocator, type Key, type RegisterSelf, type ResolveCallback, singleton, transient, type AbstractInjectable, type Injectable, type InterfaceSymbol, InstanceProvider, type Resolved, type Transformer, type IContainerConfiguration, } from './di'; | ||
export { resolve, type IResolvedInjection, ContainerConfiguration, DefaultResolver, registrableMetadataKey, } from './di.container'; | ||
@@ -4,0 +4,0 @@ export { Registration, createImplementationRegister, } from './di.registration'; |
{ | ||
"name": "@aurelia/kernel", | ||
"version": "2.0.1-dev.202405230048", | ||
"version": "2.0.1-dev.202406121156", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -57,4 +57,4 @@ "module": "dist/esm/index.mjs", | ||
"dependencies": { | ||
"@aurelia/metadata": "2.0.1-dev.202405230048", | ||
"@aurelia/platform": "2.0.1-dev.202405230048" | ||
"@aurelia/metadata": "2.0.1-dev.202406121156", | ||
"@aurelia/platform": "2.0.1-dev.202406121156" | ||
}, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
@@ -18,2 +18,3 @@ /* eslint-disable @typescript-eslint/no-this-alias */ | ||
type Transformer, | ||
IDisposableResolver, | ||
} from './di'; | ||
@@ -51,4 +52,7 @@ import { aliasToRegistration, singletonRegistration } from './di.registration'; | ||
public readonly inheritParentResources: boolean, | ||
public readonly defaultResolver: (key: Key, handler: IContainer) => IResolver, | ||
) { } | ||
public readonly defaultResolver: ( | ||
key: Key, | ||
handler: IContainer | ||
) => IResolver | ||
) {} | ||
@@ -134,3 +138,2 @@ public static from(config?: IContainerConfiguration): ContainerConfiguration { | ||
this._factories = new Map<Constructable, Factory>(); | ||
} else { | ||
@@ -261,2 +264,21 @@ this.root = parent.root; | ||
public deregister(key: Key): void { | ||
validateKey(key); | ||
const resolver = this._resolvers.get(key); | ||
if (resolver != null) { | ||
this._resolvers.delete(key); | ||
if (isResourceKey(key)) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.res[key]; | ||
} | ||
if (this._disposableResolvers.has(key)) { | ||
(resolver as IDisposableResolver).dispose(); | ||
this._disposableResolvers.delete(key); | ||
} | ||
} | ||
} | ||
// public deregisterResolverFor<K extends Key>(key: K, searchAncestors: boolean): void { | ||
@@ -306,3 +328,5 @@ // validateKey(key); | ||
// seems to confuse the type checker. | ||
factory.registerTransformer(transformer as unknown as Transformer<Constructable>); | ||
factory.registerTransformer( | ||
transformer as unknown as Transformer<Constructable> | ||
); | ||
return true; | ||
@@ -309,0 +333,0 @@ } |
@@ -90,2 +90,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
disposeResolvers(): void; | ||
deregister(key: Key): void; | ||
/** | ||
@@ -92,0 +93,0 @@ * Register resources from another container, an API for manually registering resources |
import { ErrorNames, createMappedError } from './errors'; | ||
import { Constructable, Overwrite } from './interfaces'; | ||
import { createLookup, objectAssign } from './utilities'; | ||
import { createLookup, isPromise, objectAssign } from './utilities'; | ||
@@ -37,3 +37,3 @@ /** | ||
for (; i < length; ++i) { | ||
ch = charCodeAt(value, i); | ||
ch = value.charCodeAt(i); | ||
if (i === 0 && ch === 0x30 && length > 1 /* must not start with 0 */ || ch < 0x30 /* 0 */ || ch > 0x39/* 9 */) { | ||
@@ -385,3 +385,3 @@ return isNumericLookup[value] = false; | ||
*/ | ||
export const isNativeFunction = /*@__PURE__*/(function () { | ||
export const isNativeFunction = /*@__PURE__*/(() => { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
@@ -396,30 +396,5 @@ const lookup: WeakMap<Function, boolean> = new WeakMap(); | ||
isNative = lookup.get(fn); | ||
if (isNative === void 0) { | ||
sourceText = fn.toString(); | ||
i = sourceText.length; | ||
// http://www.ecma-international.org/ecma-262/#prod-NativeFunction | ||
isNative = ( | ||
// 29 is the length of 'function () { [native code] }' which is the smallest length of a native function string | ||
i >= 29 && | ||
// 100 seems to be a safe upper bound of the max length of a native function. In Chrome and FF it's 56, in Edge it's 61. | ||
i <= 100 && | ||
// This whole heuristic *could* be tricked by a comment. Do we need to care about that? | ||
charCodeAt(sourceText, i - 1) === 0x7D && // } | ||
// TODO: the spec is a little vague about the precise constraints, so we do need to test this across various browsers to make sure just one whitespace is a safe assumption. | ||
charCodeAt(sourceText, i - 2) <= 0x20 && // whitespace | ||
charCodeAt(sourceText, i - 3) === 0x5D && // ] | ||
charCodeAt(sourceText, i - 4) === 0x65 && // e | ||
charCodeAt(sourceText, i - 5) === 0x64 && // d | ||
charCodeAt(sourceText, i - 6) === 0x6F && // o | ||
charCodeAt(sourceText, i - 7) === 0x63 && // c | ||
charCodeAt(sourceText, i - 8) === 0x20 && // | ||
charCodeAt(sourceText, i - 9) === 0x65 && // e | ||
charCodeAt(sourceText, i - 10) === 0x76 && // v | ||
charCodeAt(sourceText, i - 11) === 0x69 && // i | ||
charCodeAt(sourceText, i - 12) === 0x74 && // t | ||
charCodeAt(sourceText, i - 13) === 0x61 && // a | ||
charCodeAt(sourceText, i - 14) === 0x6E && // n | ||
charCodeAt(sourceText, i - 15) === 0x5B // [ | ||
); | ||
if (isNative == null) { | ||
i = (sourceText = fn.toString()).length; | ||
isNative = i > 28 && sourceText.indexOf('[native code] }') === i - 15; | ||
lookup.set(fn, isNative); | ||
@@ -458,8 +433,6 @@ } | ||
*/ | ||
export const onResolveAll = ( | ||
...maybePromises: (void | Promise<void>)[] | ||
): void | Promise<void> => { | ||
let maybePromise: Promise<void> | void = void 0; | ||
let firstPromise: Promise<void> | void = void 0; | ||
let promises: Promise<void>[] | undefined = void 0; | ||
export const onResolveAll = (...maybePromises: unknown[]): void | Promise<void> => { | ||
let maybePromise: unknown = void 0; | ||
let firstPromise: unknown = void 0; | ||
let promises: unknown[] | undefined = void 0; | ||
let i = 0; | ||
@@ -470,3 +443,3 @@ // eslint-disable-next-line | ||
maybePromise = maybePromises[i]; | ||
if ((maybePromise = maybePromises[i]) instanceof Promise) { | ||
if (isPromise(maybePromise = maybePromises[i])) { | ||
if (firstPromise === void 0) { | ||
@@ -483,7 +456,5 @@ firstPromise = maybePromise; | ||
if (promises === void 0) { | ||
return firstPromise; | ||
return firstPromise as void | Promise<void>; | ||
} | ||
return Promise.all(promises) as unknown as Promise<void>; | ||
}; | ||
const charCodeAt = (str: string, index: number) => str.charCodeAt(index); |
@@ -13,2 +13,3 @@ export { | ||
type IResolver, | ||
type IDisposableResolver, | ||
IServiceLocator, | ||
@@ -15,0 +16,0 @@ type 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
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
1090862
-0.54%+ Added
+ Added
- Removed
- Removed