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

@aurelia/runtime-html

Package Overview
Dependencies
Maintainers
0
Versions
1021
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurelia/runtime-html - npm Package Compare versions

Comparing version 2.0.0-beta.21 to 2.0.0-beta.22

10

dist/types/app-root.d.ts

@@ -15,2 +15,12 @@ import { InstanceProvider } from '@aurelia/kernel';

allowActionlessForm?: boolean;
/**
* Indicates strictness of expression evaluation.
*
* When strictBinding is true, standard JS behavior applies, which means accessing a property of undefined will throw an error.
* Use optional syntaxes (?./?.()/?.[]) to prevent errors.
*
* When strictBinding is false (default), the behavior is more lenient, which means accessing a property of undefined will return undefined.
* In this mode, calling an undefined function will return undefined as well.
*/
strictBinding?: boolean;
}

@@ -17,0 +27,0 @@ export interface IAppRoot<C extends object = object> extends IDisposable {

35

dist/types/aurelia.d.ts

@@ -1,2 +0,2 @@

import { IAppRoot } from './app-root';
import { IAppRoot, IAppRootConfig } from './app-root';
import type { Constructable, IContainer, IDisposable } from '@aurelia/kernel';

@@ -15,3 +15,3 @@ export interface IAurelia extends Aurelia {

register(...params: unknown[]): this;
app(config: ISinglePageAppConfig<object>): Omit<this, 'register' | 'app' | 'enhance'>;
app(config: ISinglePageAppConfig): Omit<this, 'register' | 'app' | 'enhance'>;
/**

@@ -26,21 +26,7 @@ * @param parentController - The owning controller of the view created by this enhance call

}
export interface ISinglePageAppConfig<T = unknown> {
/**
* The host element of the app
*/
host: HTMLElement;
/**
* The root component of the app
*/
component: T | Constructable<T>;
/**
* When a HTML form is submitted, the default behavior is to "redirect" the page to the action of the form
* This is not desirable for SPA applications, so by default, this behavior is prevented.
*
* This option re-enables the default behavior of HTML forms.
*/
allowActionlessForm?: boolean;
}
export interface IEnhancementConfig<T> {
export type ISinglePageAppConfig<T extends object = object> = Omit<IAppRootConfig<T>, 'strictBinding'> & {
host: Element;
};
export type IEnhancementConfig<T extends object = object> = IAppRootConfig<T> & {
host: Element;
/**

@@ -54,10 +40,3 @@ * The binding context of the enhancement. Will be instantiate by DI if a constructor is given

container?: IContainer;
/**
* When a HTML form is submitted, the default behavior is to "redirect" the page to the action of the form
* This is not desirable for SPA applications, so by default, this behavior is prevented.
*
* This option re-enables the default behavior of HTML forms.
*/
allowActionlessForm?: boolean;
}
};
//# sourceMappingURL=aurelia.d.ts.map

7

dist/types/binding/attribute-binding.d.ts
import { type IServiceLocator } from '@aurelia/kernel';
import { type IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber, ICollectionSubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import { IAstEvaluator } from '../ast.eval';
import { type IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber, ICollectionSubscriber, type IAstEvaluator, type Scope } from '@aurelia/runtime';
import type { TaskQueue } from '@aurelia/platform';

@@ -18,6 +16,7 @@ import type { INode } from '../dom';

mode: BindingMode;
strict: boolean;
isBound: boolean;
target: HTMLElement;
ast: IsBindingBehavior | ForOfStatement;
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: IsBindingBehavior | ForOfStatement, target: INode, targetAttribute: string, targetProperty: string, mode: BindingMode);
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: IsBindingBehavior | ForOfStatement, target: INode, targetAttribute: string, targetProperty: string, mode: BindingMode, strict: boolean);
updateTarget(value: unknown): void;

@@ -24,0 +23,0 @@ handleChange(): void;

import { type IServiceLocator, type Constructable } from '@aurelia/kernel';
import { type ISubscriber } from '@aurelia/runtime';
import { type ISubscriber, type Scope } from '@aurelia/runtime';
import { type IBinding, type IRateLimitOptions } from './interfaces-bindings';
import { PropertyBinding } from './property-binding';
import { type Scope } from './scope';
/**

@@ -21,7 +20,5 @@ * A subscriber that is used for subcribing to target observer & invoking `updateSource` on a binding

/**
* Turns a class into AST evaluator. For internal use only
*
* @param strict - whether the evaluation of AST nodes will be in strict mode
* Turns a class into AST evaluator with support for value converter & binding behavior. For internal use only
*/
export declare const mixinAstEvaluator: (strict?: boolean | undefined, strictFnCall?: boolean) => <T extends {
export declare const mixinAstEvaluator: <T extends {
l: IServiceLocator;

@@ -28,0 +25,0 @@ }>(target: Constructable<T>) => void;

@@ -1,6 +0,5 @@

import { IAstEvaluator } from '../ast.eval';
import { IAstEvaluator } from '@aurelia/runtime';
import { type IServiceLocator } from '@aurelia/kernel';
import type { TaskQueue } from '@aurelia/platform';
import type { ICollectionSubscriber, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import type { ICollectionSubscriber, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber, Scope } from '@aurelia/runtime';
import type { IPlatform } from '../platform';

@@ -18,6 +17,6 @@ import type { BindingMode, IBinding, IBindingController } from './interfaces-bindings';

readonly target: Text;
strict: boolean;
isBound: boolean;
readonly mode: BindingMode;
strict: boolean;
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, p: IPlatform, ast: IsExpression, target: Text);
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, p: IPlatform, ast: IsExpression, target: Text, strict: boolean);
updateTarget(value: unknown): void;

@@ -24,0 +23,0 @@ handleChange(): void;

@@ -0,5 +1,5 @@

import { TaskQueue } from '@aurelia/platform';
import { IDisposable, IServiceLocator } from '@aurelia/kernel';
import { type Scope } from '@aurelia/runtime';
import { State } from '../templating/controller';
import { type Scope } from './scope';
import { TaskQueue } from '@aurelia/platform';
export { BindingMode } from '@aurelia/template-compiler';

@@ -6,0 +6,0 @@ export interface IBindingController {

import { type IServiceLocator } from '@aurelia/kernel';
import { IAstEvaluator } from '../ast.eval';
import { IAstEvaluator } from '@aurelia/runtime';
import type { ITask, TaskQueue } from '@aurelia/platform';
import type { IAccessor, ICollectionSubscriber, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import type { IAccessor, ICollectionSubscriber, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber, Scope } from '@aurelia/runtime';
import type { IBinding, BindingMode, IBindingController } from './interfaces-bindings';

@@ -15,5 +14,6 @@ import { type Interpolation, IsExpression } from '@aurelia/expression-parser';

mode: BindingMode;
strict: boolean;
isBound: boolean;
partBindings: InterpolationPartBinding[];
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: Interpolation, target: object, targetProperty: string, mode: BindingMode);
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: Interpolation, target: object, targetProperty: string, mode: BindingMode, strict: boolean);
updateTarget(): void;

@@ -33,2 +33,3 @@ bind(_scope: Scope): void;

readonly targetProperty: string;
strict: boolean;
readonly owner: InterpolationBinding;

@@ -39,3 +40,3 @@ readonly mode: BindingMode;

isBound: boolean;
constructor(ast: IsExpression, target: object, targetProperty: string, locator: IServiceLocator, observerLocator: IObserverLocator, owner: InterpolationBinding);
constructor(ast: IsExpression, target: object, targetProperty: string, locator: IServiceLocator, observerLocator: IObserverLocator, strict: boolean, owner: InterpolationBinding);
updateTarget(): void;

@@ -42,0 +43,0 @@ handleChange(): void;

@@ -1,4 +0,2 @@

import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber, type IObservable, type IObserverLocator } from '@aurelia/runtime';
import { type Scope } from './scope';
import { type IAstEvaluator } from '../ast.eval';
import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber, type IObservable, type IObserverLocator, type Scope, type IAstEvaluator } from '@aurelia/runtime';
import type { IIndexable, IServiceLocator } from '@aurelia/kernel';

@@ -14,3 +12,4 @@ import { IsExpression } from '@aurelia/expression-parser';

target: (IObservable & IIndexable) | null;
constructor(locator: IServiceLocator, observerLocator: IObserverLocator, ast: IsExpression, targetProperty: string, toBindingContext?: boolean);
strict: boolean;
constructor(locator: IServiceLocator, observerLocator: IObserverLocator, ast: IsExpression, targetProperty: string, toBindingContext: boolean, strict: boolean);
updateTarget(): void;

@@ -17,0 +16,0 @@ handleChange(): void;

import { type IsBindingBehavior } from '@aurelia/expression-parser';
import { type IServiceLocator, IContainer } from '@aurelia/kernel';
import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import { IAstEvaluator } from '../ast.eval';
import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber, type Scope, IAstEvaluator } from '@aurelia/runtime';
import { IBinding } from './interfaces-bindings';

@@ -10,3 +8,4 @@ export declare class ListenerBindingOptions {

readonly capture: boolean;
constructor(prevent: boolean, capture?: boolean);
readonly onError: (event: Event, error: unknown) => void;
constructor(prevent: boolean, capture: boolean, onError: (event: Event, error: unknown) => void);
}

@@ -22,2 +21,3 @@ export interface ListenerBinding extends IAstEvaluator, IObserverLocatorBasedConnectable, IServiceLocator {

targetEvent: string;
strict: boolean;
isBound: boolean;

@@ -28,4 +28,4 @@ /**

self: boolean;
constructor(locator: IServiceLocator, ast: IsBindingBehavior, target: Node, targetEvent: string, options: ListenerBindingOptions, modifiedEventHandler: IModifiedEventHandler | null);
callSource(event: Event): unknown;
constructor(locator: IServiceLocator, ast: IsBindingBehavior, target: Node, targetEvent: string, options: ListenerBindingOptions, modifiedEventHandler: IModifiedEventHandler | null, strict: boolean);
callSource(event: Event): void;
handleEvent(event: Event): void;

@@ -32,0 +32,0 @@ bind(scope: Scope): void;

@@ -1,8 +0,5 @@

import { ISubscriber } from '@aurelia/runtime';
import { IAstEvaluator } from '../ast.eval';
import { ISubscriber, IAstEvaluator, type Scope, type ICollectionSubscriber, type IObserver, type IObserverLocator, type IObserverLocatorBasedConnectable } from '@aurelia/runtime';
import { IBinding } from './interfaces-bindings';
import type { IServiceLocator } from '@aurelia/kernel';
import type { TaskQueue } from '@aurelia/platform';
import type { ICollectionSubscriber, IObserver, IObserverLocator, IObserverLocatorBasedConnectable } from '@aurelia/runtime';
import { type Scope } from './scope';
import type { BindingMode, IBindingController } from './interfaces-bindings';

@@ -17,4 +14,5 @@ import { type IsBindingBehavior, ForOfStatement } from '@aurelia/expression-parser';

mode: BindingMode;
strict: boolean;
isBound: boolean;
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: IsBindingBehavior | ForOfStatement, target: object, targetProperty: string, mode: BindingMode);
constructor(controller: IBindingController, locator: IServiceLocator, observerLocator: IObserverLocator, taskQueue: TaskQueue, ast: IsBindingBehavior | ForOfStatement, target: object, targetProperty: string, mode: BindingMode, strict: boolean);
updateTarget(value: unknown): void;

@@ -21,0 +19,0 @@ updateSource(value: unknown): void;

import type { IServiceLocator } from '@aurelia/kernel';
import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import { IAstEvaluator } from '../ast.eval';
import { type ICollectionSubscriber, type IObserverLocatorBasedConnectable, type ISubscriber, type Scope, type IAstEvaluator } from '@aurelia/runtime';
import { type IsBindingBehavior } from '@aurelia/expression-parser';

@@ -12,5 +10,6 @@ import { IBinding } from './interfaces-bindings';

target: object;
strict: boolean;
static mix: <T extends import("@aurelia/kernel").Constructable<IBinding>>(this: T) => void;
isBound: boolean;
constructor(locator: IServiceLocator, ast: IsBindingBehavior, target: object);
constructor(locator: IServiceLocator, ast: IsBindingBehavior, target: object, strict: boolean);
bind(_scope: Scope): void;

@@ -17,0 +16,0 @@ unbind(): void;

import { IExpressionParser, type IsBindingBehavior } from '@aurelia/expression-parser';
import { type IServiceLocator, type Key } from '@aurelia/kernel';
import { TaskQueue } from '@aurelia/platform';
import { IObserverLocator, IObserverLocatorBasedConnectable } from '@aurelia/runtime';
import { type IObserverLocator, type IObserverLocatorBasedConnectable, Scope, type IAstEvaluator } from '@aurelia/runtime';
import { ITemplateCompiler } from '@aurelia/template-compiler';
import { IAstEvaluator } from '../ast.eval';
import { IPlatform } from '../platform';

@@ -13,3 +12,2 @@ import { IHasController } from '../renderer';

import { IBinding, IBindingController } from './interfaces-bindings';
import { Scope } from './scope';
/**

@@ -52,4 +50,5 @@ * The public methods of this binding emulates the necessary of an IHydratableController,

ast: IsBindingBehavior;
strict: boolean;
isBound: boolean;
constructor(controller: IBindingController, target: object, targetKeys: string[], ast: IsBindingBehavior, ol: IObserverLocator, l: IServiceLocator, taskQueue: TaskQueue);
constructor(controller: IBindingController, target: object, targetKeys: string[], ast: IsBindingBehavior, ol: IObserverLocator, l: IServiceLocator, taskQueue: TaskQueue, strict: boolean);
updateTarget(): void;

@@ -56,0 +55,0 @@ handleChange(): void;

@@ -1,2 +0,1 @@

export { type IAstEvaluator, astAssign, astBind, astEvaluate, astUnbind, } from './ast.eval';
export { bindable, Bindable, BindableDefinition, type PartialBindableDefinition, coercer, } from './bindable';

@@ -25,3 +24,2 @@ export { bindingBehavior, BindingBehavior, BindingBehaviorDefinition, type PartialBindingBehaviorDefinition, type BindingBehaviorStaticAuDefinition, type BindingBehaviorKind, type BindingBehaviorDecorator, type BindingBehaviorType, type BindingBehaviorInstance, } from './resources/binding-behavior';

export { RefBinding, } from './binding/ref-binding';
export { Scope, BindingContext, type IBindingContext, type IOverrideContext } from './binding/scope';
export { IRenderer, renderer, PropertyBindingRenderer, TextBindingRenderer, ListenerBindingRenderer, IListenerBindingOptions, LetElementRenderer, TemplateControllerRenderer, AttributeBindingRenderer, CustomAttributeRenderer, CustomElementRenderer, InterpolationBindingRenderer, IteratorBindingRenderer, RefBindingRenderer, SetAttributeRenderer, SetClassAttributeRenderer, SetPropertyRenderer, SetStyleAttributeRenderer, SpreadRenderer, StylePropertyBindingRenderer, } from './renderer';

@@ -28,0 +26,0 @@ export { AttrMapper, } from './compiler/attribute-mapper';

@@ -98,2 +98,7 @@ import { type Constructable } from '@aurelia/kernel';

prevent: boolean;
/**
* The error handler for listener bindings, by default, it will dispatch an event `au-event-error` on the window object
* and if the event is not prevented, it will throw the errors caught by the listener bindings
*/
onError: (event: Event, error: unknown) => void;
}

@@ -100,0 +105,0 @@ export declare const IListenerBindingOptions: import("@aurelia/kernel").InterfaceSymbol<IListenerBindingOptions>;

import { ResourceType } from '@aurelia/kernel';
import { type Scope } from '../binding/scope';
import { type Scope } from '@aurelia/runtime';
import type { Constructable, IContainer, IServiceLocator, PartialResourceDefinition, ResourceDefinition } from '@aurelia/kernel';

@@ -4,0 +4,0 @@ import { type IResourceKind } from './resources-shared';

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

import { type Scope } from '@aurelia/runtime';
import { IBinding } from '../../binding/interfaces-bindings';
import { type Scope } from '../../binding/scope';
import { type BindingBehaviorInstance, type BindingBehaviorStaticAuDefinition } from '../binding-behavior';

@@ -4,0 +4,0 @@ export declare class AttrBindingBehavior implements BindingBehaviorInstance {

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

import { type Scope } from '@aurelia/runtime';
import { type IBinding, type BindingMode } from '../../binding/interfaces-bindings';
import { BindingBehaviorInstance, type BindingBehaviorStaticAuDefinition } from '../binding-behavior';
import { type Scope } from '../../binding/scope';
export declare abstract class BindingModeBehavior implements BindingBehaviorInstance {

@@ -5,0 +5,0 @@ abstract readonly mode: BindingMode;

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

import { type Scope } from '@aurelia/runtime';
import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition } from '../binding-behavior';
import { type Scope } from '../../binding/scope';
import { type IBinding } from '../../binding/interfaces-bindings';

@@ -4,0 +4,0 @@ export declare class DebounceBindingBehavior implements BindingBehaviorInstance {

@@ -1,2 +0,2 @@

import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { ListenerBinding } from '../../binding/listener-binding';

@@ -3,0 +3,0 @@ import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition } from '../binding-behavior';

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

import { type Scope } from '@aurelia/runtime';
import { type BindingBehaviorInstance, type BindingBehaviorStaticAuDefinition } from '../binding-behavior';
import { type Scope } from '../../binding/scope';
import { IBinding } from '../../binding/interfaces-bindings';

@@ -4,0 +4,0 @@ export declare class SignalBindingBehavior implements BindingBehaviorInstance {

@@ -1,2 +0,2 @@

import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition } from '../binding-behavior';

@@ -3,0 +3,0 @@ import { type IBinding } from '../../binding/interfaces-bindings';

@@ -1,2 +0,2 @@

import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { type IBinding } from '../../binding/interfaces-bindings';

@@ -3,0 +3,0 @@ import { type BindingBehaviorInstance, type BindingBehaviorStaticAuDefinition } from '../binding-behavior';

@@ -14,2 +14,3 @@ import type { Constructable, IContainer, ResourceType, PartialResourceDefinition, Key, ResourceDefinition, InterfaceSymbol } from '@aurelia/kernel';

readonly watches?: IWatchDefinition[];
readonly strict?: boolean;
}>;

@@ -138,2 +139,3 @@ export type CustomElementStaticAuDefinition<TBindables extends string = string> = PartialCustomElementDefinition<TBindables> & {

readonly watches: IWatchDefinition[];
readonly strict: boolean | undefined;
readonly processContent: ProcessContentHook | null;

@@ -140,0 +142,0 @@ get type(): 'custom-element';

@@ -1,6 +0,2 @@

import { Key, IResolver } from '@aurelia/kernel';
/**
* Create a resolver for a given key that will only resolve from the nearest hydration context.
*/
export declare const fromHydrationContext: <T extends Key>(key: T) => IResolver<T | undefined>;
export {};
//# sourceMappingURL=resolvers.d.ts.map

@@ -22,3 +22,2 @@ import { IViewFactory } from '../../templating/view';

valueChanged(newValue: unknown, oldValue: unknown): void | Promise<void>;
private _swap;
dispose(): void;

@@ -25,0 +24,0 @@ accept(visitor: ControllerVisitor): void | true;

import { registrableMetadataKey } from '@aurelia/kernel';
import { Scope } from '../../binding/scope';
import { Scope } from '@aurelia/runtime';
import { INode } from '../../dom';

@@ -4,0 +4,0 @@ import { ICustomAttributeController, ICustomAttributeViewModel, IHydratableController, IHydratedController, IHydratedParentController, ISyntheticView } from '../../templating/controller';

@@ -10,3 +10,2 @@ import { IContainer } from '@aurelia/kernel';

views: ISyntheticView[];
private _oldViews;
forOf: ForOfStatement;

@@ -13,0 +12,0 @@ local: string;

@@ -1,6 +0,6 @@

import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import type { IInstruction } from '@aurelia/template-compiler';
import { CustomAttributeStaticAuDefinition } from '../custom-attribute';
import type { ICustomAttributeController, ICustomAttributeViewModel, IHydratedController, IHydratedParentController, IHydratableController, ISyntheticView, ControllerVisitor } from '../../templating/controller';
import type { INode } from '../../dom';
import type { IInstruction } from '@aurelia/template-compiler';
export declare class Switch implements ICustomAttributeViewModel {

@@ -7,0 +7,0 @@ static readonly $au: CustomAttributeStaticAuDefinition;

@@ -1,3 +0,2 @@

import { ICoercionConfiguration } from '@aurelia/runtime';
import { Scope } from '../binding/scope';
import { ICoercionConfiguration, Scope } from '@aurelia/runtime';
import { CustomAttributeDefinition } from '../resources/custom-attribute';

@@ -51,2 +50,3 @@ import { CustomElementDefinition } from '../resources/custom-element';

coercion: ICoercionConfiguration | undefined;
get strict(): boolean | undefined;
constructor(container: IContainer, vmKind: ViewModelKind, definition: CustomElementDefinition | CustomAttributeDefinition | null,

@@ -236,2 +236,3 @@ /**

readonly definition: CustomElementDefinition | null;
readonly strict: boolean | undefined | null;
readonly children: readonly IHydratedController[] | null;

@@ -344,2 +345,3 @@ addChild(controller: IController): void;

readonly definition: CustomElementDefinition;
readonly strict: boolean | undefined | null;
/**

@@ -446,2 +448,6 @@ * The scope that belongs to this custom element. This property is set immediately after the controller is created and is always guaranteed to be available.

propertyChanged?(key: PropertyKey, newValue: unknown, oldValue: unknown): void;
propertiesChanged?(changes: Record<string, {
newValue: unknown;
oldValue: unknown;
}>): void;
}

@@ -453,2 +459,6 @@ export interface ICustomAttributeViewModel extends IViewModel, IActivationHooks<IHydratedController> {

propertyChanged?(key: PropertyKey, newValue: unknown, oldValue: unknown): void;
propertiesChanged?(changes: Record<string, {
newValue: unknown;
oldValue: unknown;
}>): void;
}

@@ -471,4 +481,9 @@ export interface IHydratedCustomElementViewModel extends ICustomElementViewModel {

readonly containerless?: boolean;
/**
* When provided, the controller is used while hydrating the custom element.
* Otherwise, the host controller is resolved in the Controller; this is the default behavior.
*/
readonly hostController?: Controller | null;
}
export {};
//# sourceMappingURL=controller.d.ts.map
import { type IServiceLocator } from '@aurelia/kernel';
import { type Scope } from '../binding/scope';
import type { ICollectionSubscriber, IConnectable, IObservable, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { IsBindingBehavior } from '@aurelia/expression-parser';
import type { ICollectionSubscriber, IConnectable, IObservable, IObserverLocator, IObserverLocatorBasedConnectable, ISubscriber, Scope } from '@aurelia/runtime';
import type { IWatcherCallback } from '../watch';
import { IsBindingBehavior } from '@aurelia/expression-parser';
import { IBinding } from '../binding/interfaces-bindings';

@@ -7,0 +6,0 @@ export interface ComputedWatcher extends IObserverLocatorBasedConnectable, IServiceLocator {

{
"name": "@aurelia/runtime-html",
"version": "2.0.0-beta.21",
"version": "2.0.0-beta.22",
"main": "dist/cjs/index.cjs",

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

"dependencies": {
"@aurelia/kernel": "2.0.0-beta.21",
"@aurelia/metadata": "2.0.0-beta.21",
"@aurelia/platform": "2.0.0-beta.21",
"@aurelia/platform-browser": "2.0.0-beta.21",
"@aurelia/runtime": "2.0.0-beta.21",
"@aurelia/expression-parser": "2.0.0-beta.21",
"@aurelia/template-compiler": "2.0.0-beta.21"
"@aurelia/kernel": "2.0.0-beta.22",
"@aurelia/metadata": "2.0.0-beta.22",
"@aurelia/platform": "2.0.0-beta.22",
"@aurelia/platform-browser": "2.0.0-beta.22",
"@aurelia/runtime": "2.0.0-beta.22",
"@aurelia/expression-parser": "2.0.0-beta.22",
"@aurelia/template-compiler": "2.0.0-beta.22"
},

@@ -66,0 +66,0 @@ "devDependencies": {

@@ -25,2 +25,12 @@ import { BrowserPlatform } from '@aurelia/platform-browser';

allowActionlessForm?: boolean;
/**
* Indicates strictness of expression evaluation.
*
* When strictBinding is true, standard JS behavior applies, which means accessing a property of undefined will throw an error.
* Use optional syntaxes (?./?.()/?.[]) to prevent errors.
*
* When strictBinding is false (default), the behavior is more lenient, which means accessing a property of undefined will return undefined.
* In this mode, calling an undefined function will return undefined as well.
*/
strictBinding?: boolean;
}

@@ -109,3 +119,3 @@

const definition = enhance
? CustomElementDefinition.create({ name: generateElementName(), template: this.host, enhance: true })
? CustomElementDefinition.create({ name: generateElementName(), template: this.host, enhance: true, strict: config.strictBinding })
// leave the work of figuring out the definition to the controller

@@ -122,3 +132,3 @@ // there's proper error messages in case of failure inside the $el() call

controller._hydrateCustomElement(hydrationInst, /* root does not have hydration context */null);
controller._hydrateCustomElement(hydrationInst);
return onResolve(this._runAppTasks('hydrating'), () => {

@@ -125,0 +135,0 @@ controller._hydrate();

import { isPromise, DI, InstanceProvider, onResolve } from '@aurelia/kernel';
import { AppRoot, IAppRoot } from './app-root';
import { AppRoot, IAppRoot, IAppRootConfig } from './app-root';
import { createInterface, registerResolver } from './utilities-di';

@@ -65,3 +65,3 @@

public app(config: ISinglePageAppConfig<object>): Omit<this, 'register' | 'app' | 'enhance'> {
public app(config: ISinglePageAppConfig): Omit<this, 'register' | 'app' | 'enhance'> {
this.next = new AppRoot(config, this.container, this._rootProvider);

@@ -156,21 +156,7 @@ return this;

export interface ISinglePageAppConfig<T = unknown> {
/**
* The host element of the app
*/
host: HTMLElement;
/**
* The root component of the app
*/
component: T | Constructable<T>;
/**
* When a HTML form is submitted, the default behavior is to "redirect" the page to the action of the form
* This is not desirable for SPA applications, so by default, this behavior is prevented.
*
* This option re-enables the default behavior of HTML forms.
*/
allowActionlessForm?: boolean;
}
export type ISinglePageAppConfig<T extends object = object> = Omit<IAppRootConfig<T>, 'strictBinding'> & {
host: Element;
};
export interface IEnhancementConfig<T> {
export type IEnhancementConfig<T extends object = object> = IAppRootConfig<T> & {
host: Element;

@@ -185,9 +171,2 @@ /**

container?: IContainer;
/**
* When a HTML form is submitted, the default behavior is to "redirect" the page to the action of the form
* This is not desirable for SPA applications, so by default, this behavior is prevented.
*
* This option re-enables the default behavior of HTML forms.
*/
allowActionlessForm?: boolean;
}
};

@@ -7,11 +7,9 @@ import { type IServiceLocator, isString } from '@aurelia/kernel';

ISubscriber,
ICollectionSubscriber
} from '@aurelia/runtime';
import { type Scope } from './scope';
import {
ICollectionSubscriber,
astBind,
astEvaluate,
astUnbind,
IAstEvaluator,
} from '../ast.eval';
type IAstEvaluator,
type Scope,
} from '@aurelia/runtime';
import { activating } from '../templating/controller';

@@ -47,3 +45,3 @@ import { createPrototypeMixer, mixinAstEvaluator, mixinUseScope, mixingBindingLimited } from './binding-utils';

connectable(AttributeBinding, null!);
mixinAstEvaluator(true)(AttributeBinding);
mixinAstEvaluator(AttributeBinding);
});

@@ -100,2 +98,3 @@

public mode: BindingMode,
public strict: boolean,
) {

@@ -102,0 +101,0 @@ this.l = locator;

import { type IServiceLocator, Key, type Constructable, IDisposable, IContainer } from '@aurelia/kernel';
import { ITask } from '@aurelia/platform';
import { type ISubscriber } from '@aurelia/runtime';
import { astEvaluate } from '../ast.eval';
import { type ISubscriber, astEvaluate, type Scope } from '@aurelia/runtime';
import { type IBinding, type IRateLimitOptions } from './interfaces-bindings';
import { BindingBehavior, BindingBehaviorInstance } from '../resources/binding-behavior';
import { ValueConverter, ValueConverterInstance } from '../resources/value-converter';
import { addSignalListener, def, defineHiddenProp, removeSignalListener, tsPending } from '../utilities';
import { addSignalListener, defineHiddenProp, removeSignalListener, tsPending } from '../utilities';
import { createInterface } from '../utilities-di';

@@ -13,3 +12,2 @@ import { PropertyBinding } from './property-binding';

import { ISignaler } from '../signaler';
import { type Scope } from './scope';

@@ -70,5 +68,3 @@ /**

/**
* Turns a class into AST evaluator. For internal use only
*
* @param strict - whether the evaluation of AST nodes will be in strict mode
* Turns a class into AST evaluator with support for value converter & binding behavior. For internal use only
*/

@@ -78,45 +74,116 @@ export const mixinAstEvaluator = /*@__PURE__*/(() => {

const converterResourceLookupCache = new WeakMap<{ l: IServiceLocator }, ResourceLookup>();
const behaviorResourceLookupCache = new WeakMap<{ l: IServiceLocator }, ResourceLookup>();
class ResourceLookup {
[key: string]: ValueConverterInstance | BindingBehaviorInstance;
}
const converterResourceLookupCache = new WeakMap<{ l: IServiceLocator }, Record<string, ValueConverterInstance>>();
const behaviorResourceLookupCache = new WeakMap<{ l: IServiceLocator }, Record<string, BindingBehaviorInstance>>();
const appliedBehaviors = new WeakMap<{ l: IServiceLocator }, Record<string, boolean>>();
function evaluatorGet<T extends IHasServiceLocator>(this: T, key: Key) {
return this.l.get(key);
}
function evaluatorGetSignaler<T extends IHasServiceLocator>(this: T) {
return this.l.root.get(ISignaler);
}
function evaluatorGetConverter<T extends IHasServiceLocator>(this: T, name: string) {
let resourceLookup = converterResourceLookupCache.get(this);
function evaluatorGetBehavior<T extends IHasServiceLocator>(b: T, name: string) {
let resourceLookup = behaviorResourceLookupCache.get(b);
if (resourceLookup == null) {
converterResourceLookupCache.set(this, resourceLookup = new ResourceLookup());
behaviorResourceLookupCache.set(b, resourceLookup = new ResourceLookup() as Record<string, BindingBehaviorInstance>);
}
return resourceLookup[name] ??= ValueConverter.get(this.l as IContainer, name);
return resourceLookup[name] ??= BindingBehavior.get(b.l, name);
}
function evaluatorGetBehavior<T extends IHasServiceLocator>(this: T, name: string) {
let resourceLookup = behaviorResourceLookupCache.get(this);
function evaluatorBindBehavior<T extends IHasServiceLocator>(this: T, name: string, scope: Scope, args: unknown[]) {
const behavior = evaluatorGetBehavior(this, name);
if (behavior == null) {
throw createMappedError(ErrorNames.ast_behavior_not_found, name);
}
let applied = appliedBehaviors.get(this);
if (applied == null) {
appliedBehaviors.set(this, applied = {});
}
if (applied[name]) {
throw createMappedError(ErrorNames.ast_behavior_duplicated, name);
}
// todo: remove casting
// there should be a base "mixinAstEvaluator" factory that takes parameters to handle behaviors/converters
// so observation infra can be free of template oriented features: behaviors/converters
// or anything that is not supposed to be supporting binding behavior shouldn't be using this mixin
behavior.bind?.(scope, this as unknown as IBinding, ...args);
}
function evaluatorUnbindBehavior<T extends IHasServiceLocator>(this: T, name: string, scope: Scope) {
const behavior = evaluatorGetBehavior(this, name);
const applied = appliedBehaviors.get(this);
// todo: remove casting
// there should be a base "mixinAstEvaluator" factory that takes parameters to handle behaviors/converters
// so observation infra can be free of template oriented features: behaviors/converters
// or anything that is not supposed to be supporting binding behavior shouldn't be using this mixin
behavior?.unbind?.(scope, this as unknown as IBinding);
if (applied != null) {
applied[name] = false;
}
}
function evaluatorGetConverter<T extends IHasServiceLocator>(b: T, name: string) {
let resourceLookup = converterResourceLookupCache.get(b);
if (resourceLookup == null) {
behaviorResourceLookupCache.set(this, resourceLookup = new ResourceLookup());
converterResourceLookupCache.set(b, resourceLookup = new ResourceLookup() as Record<string, ValueConverterInstance>);
}
return resourceLookup[name] ??= BindingBehavior.get(this.l, name);
return resourceLookup[name] ??= ValueConverter.get(b.l as IContainer, name);
}
function evaluatorBindConverter<T extends IHasServiceLocator>(this: T, name: string) {
const vc = evaluatorGetConverter(this, name);
if (vc == null) {
throw createMappedError(ErrorNames.ast_converter_not_found, name);
}
const signals = vc.signals;
if (signals != null) {
const signaler = this.l.get(ISignaler);
const ii = signals.length;
let i = 0;
for (; i < ii; ++i) {
// note: the cast is expected. To connect, it just needs to be a IConnectable
// though to work with signal, it needs to have `handleChange`
// so having `handleChange` as a guard in the connectable as a safe measure is needed
// to make sure signaler works
signaler.addSignalListener(signals[i], this as unknown as ISubscriber);
}
}
}
return (strict?: boolean | undefined, strictFnCall = true) => {
return <T extends { l: IServiceLocator }>(target: Constructable<T>) => {
const proto = target.prototype;
// some evaluator may have their strict configurable in some way
// undefined to leave the property alone
if (strict != null) {
def(proto, 'strict', { enumerable: true, get: function () { return strict; } });
}
def(proto, 'strictFnCall', { enumerable: true, get: function () { return strictFnCall; } });
defineHiddenProp(proto, 'get', evaluatorGet<T>);
defineHiddenProp(proto, 'getSignaler', evaluatorGetSignaler<T>);
defineHiddenProp(proto, 'getConverter', evaluatorGetConverter<T>);
defineHiddenProp(proto, 'getBehavior', evaluatorGetBehavior<T>);
};
function evaluatorUnbindConverter<T extends IHasServiceLocator>(this: T, name: string) {
const vc = evaluatorGetConverter(this, name);
if (vc?.signals === void 0) {
return;
}
const signaler = this.l.get(ISignaler);
let i = 0;
for (; i < vc.signals.length; ++i) {
signaler.removeSignalListener(vc.signals[i], this as unknown as ISubscriber);
}
}
function evaluatorUseConverter<T extends IHasServiceLocator>(this: T, name: string, mode: 'toView' | 'fromView', value: unknown, args: unknown[]) {
const vc = evaluatorGetConverter(this, name);
if (vc == null) {
throw createMappedError(ErrorNames.ast_converter_not_found, name);
}
switch (mode) {
case 'toView':
return 'toView' in vc ? vc.toView(value, ...args) : value;
case 'fromView':
return 'fromView' in vc ? vc.fromView?.(value, ...args) : value;
}
}
return <T extends IHasServiceLocator>(target: Constructable<T>) => {
const proto = target.prototype;
defineHiddenProp(proto, 'get', evaluatorGet<T>);
defineHiddenProp(proto, 'bindBehavior', evaluatorBindBehavior<T>);
defineHiddenProp(proto, 'unbindBehavior', evaluatorUnbindBehavior<T>);
defineHiddenProp(proto, 'bindConverter', evaluatorBindConverter<T>);
defineHiddenProp(proto, 'unbindConverter', evaluatorUnbindConverter<T>);
defineHiddenProp(proto, 'useConverter', evaluatorUseConverter<T>);
};
})();
class ResourceLookup {
[key: string]: ValueConverterInstance | BindingBehaviorInstance;
}

@@ -123,0 +190,0 @@ export interface IFlushable {

import {
connectable
} from '@aurelia/runtime';
import {
connectable,
IAstEvaluator,

@@ -9,3 +7,3 @@ astBind,

astUnbind,
} from '../ast.eval';
} from '@aurelia/runtime';
import { activating } from '../templating/controller';

@@ -20,4 +18,4 @@ import { toView } from './interfaces-bindings';

ISubscriber,
Scope,
} from '@aurelia/runtime';
import { type Scope } from './scope';
import type { IPlatform } from '../platform';

@@ -45,3 +43,3 @@ import { safeString } from '../utilities';

connectable(ContentBinding, null!);
mixinAstEvaluator(void 0, false)(ContentBinding);
mixinAstEvaluator(ContentBinding);
});

@@ -83,4 +81,2 @@

public strict = true;
public constructor(

@@ -94,2 +90,3 @@ controller: IBindingController,

public readonly target: Text,
public strict: boolean,
) {

@@ -96,0 +93,0 @@ this.l = locator;

@@ -0,6 +1,6 @@

import { TaskQueue } from '@aurelia/platform';
import { IDisposable, IServiceLocator } from '@aurelia/kernel';
import { type Scope } from '@aurelia/runtime';
import { BindingMode } from '@aurelia/template-compiler';
import { State } from '../templating/controller';
import { type Scope } from './scope';
import { TaskQueue } from '@aurelia/platform';
import { BindingMode } from '@aurelia/template-compiler';

@@ -7,0 +7,0 @@ /** @internal */ export const { default: defaultMode, oneTime, toView, fromView, twoWay } = BindingMode;

import { type IServiceLocator, isArray } from '@aurelia/kernel';
import {
connectable,
} from '@aurelia/runtime';
import {
astBind,

@@ -10,3 +8,3 @@ astEvaluate,

IAstEvaluator,
} from '../ast.eval';
} from '@aurelia/runtime';
import { activating } from '../templating/controller';

@@ -24,4 +22,4 @@ import { createPrototypeMixer, mixinAstEvaluator, mixinUseScope, mixingBindingLimited } from './binding-utils';

ISubscriber,
Scope,
} from '@aurelia/runtime';
import { type Scope } from './scope';
import { atLayout } from '../utilities';

@@ -77,3 +75,4 @@ import type { IBinding, BindingMode, IBindingController } from './interfaces-bindings';

public targetProperty: string,
public mode: BindingMode
public mode: BindingMode,
public strict: boolean,
) {

@@ -89,3 +88,3 @@ this._controller = controller;

for (; ii > i; ++i) {
partBindings[i] = new InterpolationPartBinding(expressions[i], target, targetProperty, locator, observerLocator, this);
partBindings[i] = new InterpolationPartBinding(expressions[i], target, targetProperty, locator, observerLocator, strict, this);
}

@@ -192,3 +191,3 @@ }

connectable(InterpolationPartBinding, null!);
mixinAstEvaluator(true)(InterpolationPartBinding);
mixinAstEvaluator(InterpolationPartBinding);
});

@@ -224,2 +223,3 @@

observerLocator: IObserverLocator,
public strict: boolean,
public readonly owner: InterpolationBinding,

@@ -226,0 +226,0 @@ ) {

@@ -8,5 +8,3 @@ import {

type IObserverLocator,
} from '@aurelia/runtime';
import { type Scope } from './scope';
import {
type Scope,
astBind,

@@ -16,3 +14,3 @@ astEvaluate,

type IAstEvaluator,
} from '../ast.eval';
} from '@aurelia/runtime';
import { createPrototypeMixer, mixinAstEvaluator, mixinUseScope, mixingBindingLimited } from './binding-utils';

@@ -35,3 +33,3 @@

connectable(LetBinding, null!);
mixinAstEvaluator(true)(LetBinding);
mixinAstEvaluator(LetBinding);
});

@@ -65,2 +63,4 @@

public strict: boolean;
public constructor(

@@ -71,6 +71,8 @@ locator: IServiceLocator,

public targetProperty: string,
toBindingContext: boolean = false,
toBindingContext: boolean,
strict: boolean,
) {
this.l = locator;
this.oL = observerLocator;
this.strict = strict;
this._toBindingContext = toBindingContext;

@@ -77,0 +79,0 @@ }

@@ -7,5 +7,12 @@ import { type IsBindingBehavior } from '@aurelia/expression-parser';

import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber, } from '@aurelia/runtime';
import { type Scope } from './scope';
import { astBind, astEvaluate, astUnbind, IAstEvaluator } from '../ast.eval';
import {
ICollectionSubscriber,
IObserverLocatorBasedConnectable,
ISubscriber,
type Scope,
astBind,
astEvaluate,
astUnbind,
IAstEvaluator,
} from '@aurelia/runtime';
import { IBinding } from './interfaces-bindings';

@@ -17,2 +24,3 @@

public readonly capture: boolean = false,
public readonly onError: (event: Event, error: unknown) => void,
) {}

@@ -30,3 +38,3 @@ }

mixingBindingLimited(ListenerBinding, () => 'callSource');
mixinAstEvaluator(true, true)(ListenerBinding);
mixinAstEvaluator(ListenerBinding);
});

@@ -68,2 +76,3 @@

modifiedEventHandler: IModifiedEventHandler | null,
public strict: boolean,
) {

@@ -75,7 +84,12 @@ this.l = locator;

public callSource(event: Event): unknown {
public callSource(event: Event): void {
const overrideContext = this._scope!.overrideContext;
overrideContext.$event = event;
// let result
let result = astEvaluate(this.ast, this._scope!, this, null);
// try {
// } catch (ex) {
// console.log(ex);
// }

@@ -91,4 +105,2 @@ delete overrideContext.$event;

}
return result;
}

@@ -104,3 +116,7 @@

if (this._modifiedEventHandler?.(event) !== false) {
this.callSource(event);
try {
this.callSource(event);
} catch (ex) {
this._options.onError(event, ex);
}
}

@@ -107,0 +123,0 @@ }

@@ -1,3 +0,16 @@

import { connectable, ISubscriber } from '@aurelia/runtime';
import { astAssign, astBind, astEvaluate, astUnbind, IAstEvaluator } from '../ast.eval';
import {
connectable,
ISubscriber,
astAssign,
astBind,
astEvaluate,
astUnbind,
IAstEvaluator,
type Scope,
type AccessorOrObserver,
type ICollectionSubscriber,
type IObserver,
type IObserverLocator,
type IObserverLocatorBasedConnectable,
} from '@aurelia/runtime';
import { activating } from '../templating/controller';

@@ -9,10 +22,2 @@ import { BindingTargetSubscriber, IFlushQueue, createPrototypeMixer, mixinAstEvaluator, mixinUseScope, mixingBindingLimited } from './binding-utils';

import type { ITask, QueueTaskOptions, TaskQueue } from '@aurelia/platform';
import type {
AccessorOrObserver,
ICollectionSubscriber,
IObserver,
IObserverLocator,
IObserverLocatorBasedConnectable,
} from '@aurelia/runtime';
import { type Scope } from './scope';
import type { BindingMode, IBindingController } from './interfaces-bindings';

@@ -31,3 +36,3 @@ import { createMappedError, ErrorNames } from '../errors';

connectable(PropertyBinding, null!);
mixinAstEvaluator(true, false)(PropertyBinding);
mixinAstEvaluator(PropertyBinding);
});

@@ -78,2 +83,3 @@

public mode: BindingMode,
public strict: boolean,
) {

@@ -80,0 +86,0 @@ this.l = locator;

import type { IServiceLocator } from '@aurelia/kernel';
import { ICollectionSubscriber, IObserverLocatorBasedConnectable, ISubscriber } from '@aurelia/runtime';
import { type Scope } from './scope';
import { astAssign, astBind, astEvaluate, astUnbind, IAstEvaluator } from '../ast.eval';
import {
type ICollectionSubscriber,
type IObserverLocatorBasedConnectable,
type ISubscriber,
type Scope,
astAssign,
astBind,
astEvaluate,
astUnbind,
type IAstEvaluator,
} from '@aurelia/runtime';
import { createPrototypeMixer, mixinAstEvaluator } from './binding-utils';

@@ -12,3 +20,3 @@ import { type IsBindingBehavior } from '@aurelia/expression-parser';

public static mix = /*@__PURE__*/ createPrototypeMixer(() => {
mixinAstEvaluator(false)(RefBinding);
mixinAstEvaluator(RefBinding);
});

@@ -28,2 +36,3 @@

public target: object,
public strict: boolean,
) {

@@ -30,0 +39,0 @@ this.l = locator;

import { AccessScopeExpression, IExpressionParser, type IsBindingBehavior } from '@aurelia/expression-parser';
import { isObject, type IServiceLocator, type Key, emptyArray } from '@aurelia/kernel';
import { TaskQueue } from '@aurelia/platform';
import { IObserverLocator, IObserverLocatorBasedConnectable, connectable } from '@aurelia/runtime';
import {
type IObserverLocator,
type IObserverLocatorBasedConnectable,
connectable,
Scope,
type IAstEvaluator,
astBind,
astEvaluate,
astUnbind,
} from '@aurelia/runtime';
import { BindingMode, IInstruction, ITemplateCompiler, InstructionType, SpreadElementPropBindingInstruction } from '@aurelia/template-compiler';
import { IAstEvaluator, astBind, astEvaluate, astUnbind } from '../ast.eval';
import { ErrorNames, createMappedError } from '../errors';

@@ -16,3 +24,2 @@ import { IPlatform } from '../platform';

import { PropertyBinding } from './property-binding';
import { Scope } from './scope';

@@ -165,3 +172,3 @@ /**

connectable(SpreadValueBinding, null!);
mixinAstEvaluator(true, false)(SpreadValueBinding);
mixinAstEvaluator(SpreadValueBinding);
});

@@ -212,2 +219,3 @@

taskQueue: TaskQueue,
public strict: boolean,
) {

@@ -326,3 +334,4 @@ this._controller = controller;

key,
BindingMode.toView
BindingMode.toView,
this.strict,
);

@@ -329,0 +338,0 @@ }

import { IContainer, noop } from '@aurelia/kernel';
import { ExpressionParser } from '@aurelia/expression-parser';
import { DirtyChecker, ICoercionConfiguration } from '@aurelia/runtime';

@@ -242,2 +243,3 @@ import {

instanceRegistration(ICoercionConfiguration, runtimeConfigurationOptions.coercingOptions),
ExpressionParser,
...DefaultComponents,

@@ -244,0 +246,0 @@ ...DefaultResources,

@@ -28,2 +28,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */

ast_increment_infinite_loop = 113,
ast_nullish_member_access = 114,
ast_nullish_keyed_access = 115,
ast_nullish_assignment = 116,

@@ -149,2 +152,5 @@ binding_behavior_def_not_found = 151,

[ErrorNames.ast_increment_infinite_loop]: `Ast eval error: infinite loop detected. Increment operators should only be used in event handlers.`,
[ErrorNames.ast_nullish_member_access]: `Ast eval error: cannot access property "{{0}}" of {{1}}.`,
[ErrorNames.ast_nullish_keyed_access]: `Ast eval error: cannot access key "{{0}}" of {{1}}.`,
[ErrorNames.ast_nullish_assignment]: `Ast eval error: cannot assign value to property "{{0}}" of null/undefined.`,

@@ -151,0 +157,0 @@ [ErrorNames.binding_behavior_def_not_found]: `No binding behavior definition found for type {{0:name}}`,

export {
type IAstEvaluator,
astAssign,
astBind,
astEvaluate,
astUnbind,
} from './ast.eval';
export {
bindable,

@@ -114,8 +106,2 @@ Bindable,

} from './binding/ref-binding';
export {
Scope,
BindingContext,
type IBindingContext,
type IOverrideContext
} from './binding/scope';

@@ -122,0 +108,0 @@ export {

@@ -278,2 +278,3 @@ import {

public _stop(): void {
this._value = this._oldValue = void 0;
this._collectionObserver?.unsubscribe(this);

@@ -289,2 +290,3 @@ this._valueObserver?.unsubscribe(this);

this.subs.notify(this._value, oV);
oV = void 0;
}

@@ -291,0 +293,0 @@

@@ -416,2 +416,3 @@ import {

toBindingContext,
renderingCtrl.strict ?? false,
));

@@ -435,3 +436,4 @@ ++i;

ensureExpression(exprParser, instruction.from, etIsProperty),
getRefTarget(target, instruction.to)
getRefTarget(target, instruction.to),
renderingCtrl.strict ?? false,
));

@@ -463,3 +465,4 @@ }

instruction.to,
toView
toView,
renderingCtrl.strict ?? false,
);

@@ -496,3 +499,4 @@ if (instruction.to === 'class' && (binding.target as Node).nodeType > 0) {

instruction.to,
instruction.mode
instruction.mode,
renderingCtrl.strict ?? false,
);

@@ -529,2 +533,3 @@ if (instruction.to === 'class' && (binding.target as Node).nodeType > 0) {

toView,
renderingCtrl.strict ?? false,
));

@@ -555,2 +560,3 @@ }

target as Text,
renderingCtrl.strict ?? false,
));

@@ -568,5 +574,23 @@ }

prevent: boolean;
/**
* The error handler for listener bindings, by default, it will dispatch an event `au-event-error` on the window object
* and if the event is not prevented, it will throw the errors caught by the listener bindings
*/
onError: (event: Event, error: unknown) => void;
}
export const IListenerBindingOptions = createInterface<IListenerBindingOptions>('IListenerBindingOptions', x => x.instance({
prevent: false,
export const IListenerBindingOptions = createInterface<IListenerBindingOptions>('IListenerBindingOptions', x => x.singleton(class {
/** @internal */
private readonly p = resolve(IPlatform);
public prevent = false;
public onError = (event: Event, error: unknown) => {
const errorEvent = new this.p.CustomEvent('au-event-error', { cancelable: true, detail: { event, error } });
this.p.window.dispatchEvent(errorEvent);
if (errorEvent.defaultPrevented) {
return;
}
throw error;
};
}));

@@ -598,4 +622,5 @@

instruction.to,
new ListenerBindingOptions(this._defaultOptions.prevent, instruction.capture),
new ListenerBindingOptions(this._defaultOptions.prevent, instruction.capture, this._defaultOptions.onError),
this._modifierHandler.getHandler(instruction.to, instruction.modifier),
renderingCtrl.strict ?? false,
));

@@ -688,2 +713,3 @@ }

toView,
renderingCtrl.strict ?? false,
));

@@ -702,2 +728,3 @@ return;

toView,
renderingCtrl.strict ?? false,
));

@@ -748,2 +775,3 @@ }

toView,
renderingCtrl.strict ?? false,
));

@@ -804,3 +832,4 @@ }

renderingCtrl.container,
platform.domQueue
platform.domQueue,
renderingCtrl.strict ?? false,
));

@@ -807,0 +836,0 @@ } else {

import { firstDefined, getResourceKeyFor, mergeArrays, resource, resourceBaseName, ResourceType, isFunction, isString } from '@aurelia/kernel';
import { type Scope } from '../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { objectFreeze } from '../utilities';

@@ -4,0 +4,0 @@ import { aliasRegistration, singletonRegistration } from '../utilities-di';

@@ -0,5 +1,6 @@

import { type Scope } from '@aurelia/runtime';
import { IBinding } from '../../binding/interfaces-bindings';
import { attrAccessor } from '../../observation/data-attribute-accessor';
import { type Scope } from '../../binding/scope';
import { PropertyBinding } from '../../binding/property-binding';

@@ -6,0 +7,0 @@ import { ErrorNames, createMappedError } from '../../errors';

@@ -0,6 +1,5 @@

import { type Scope } from '@aurelia/runtime';
import { type IBinding, fromView, oneTime, toView, twoWay, type BindingMode } from '../../binding/interfaces-bindings';
import { BindingBehaviorInstance, behaviorTypeName, type BindingBehaviorStaticAuDefinition } from '../binding-behavior';
import { type Scope } from '../../binding/scope';
const originalModesMap = new Map<IBinding & { mode: BindingMode }, BindingMode>();

@@ -7,0 +6,0 @@ const createConfig = (name: string): BindingBehaviorStaticAuDefinition => ({ type: behaviorTypeName, name });

import { isString, type IDisposable, IPlatform, emptyArray, resolve } from '@aurelia/kernel';
import { type Scope } from '@aurelia/runtime';
import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition, behaviorTypeName } from '../binding-behavior';
import { type Scope } from '../../binding/scope';
import { type IBinding, type IRateLimitOptions } from '../../binding/interfaces-bindings';

@@ -6,0 +6,0 @@

@@ -1,2 +0,2 @@

import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { ListenerBinding } from '../../binding/listener-binding';

@@ -3,0 +3,0 @@ import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition, behaviorTypeName } from '../binding-behavior';

@@ -0,7 +1,6 @@

import { resolve } from '@aurelia/kernel';
import { type Scope, type ISubscriber } from '@aurelia/runtime';
import { ISignaler } from '../../signaler';
import { type BindingBehaviorInstance, type BindingBehaviorStaticAuDefinition, behaviorTypeName } from '../binding-behavior';
import { addSignalListener, removeSignalListener } from '../../utilities';
import { type ISubscriber } from '@aurelia/runtime';
import { resolve } from '@aurelia/kernel';
import { type Scope } from '../../binding/scope';
import { ErrorNames, createMappedError } from '../../errors';

@@ -8,0 +7,0 @@ import { IBinding } from '../../binding/interfaces-bindings';

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

import { TaskQueue } from '@aurelia/platform';
import { isString, IPlatform, type IDisposable, emptyArray, resolve } from '@aurelia/kernel';
import { TaskQueue } from '@aurelia/platform';
import { type Scope } from '../../binding/scope';
import { type Scope } from '@aurelia/runtime';
import { type BindingBehaviorInstance, BindingBehaviorStaticAuDefinition, behaviorTypeName } from '../binding-behavior';

@@ -5,0 +5,0 @@ import { type IBinding, type IRateLimitOptions } from '../../binding/interfaces-bindings';

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

import { INodeObserverLocator, IObserverLocator } from '@aurelia/runtime';
import { type Scope } from '../../binding/scope';
import { resolve } from '@aurelia/kernel';
import { type Scope, INodeObserverLocator, IObserverLocator } from '@aurelia/runtime';
import { type IBinding, fromView } from '../../binding/interfaces-bindings';

@@ -8,3 +8,2 @@ import { NodeObserverLocator } from '../../observation/observer-locator';

import { PropertyBinding } from '../../binding/property-binding';
import { resolve } from '@aurelia/kernel';
import { ErrorNames, createMappedError } from '../../errors';

@@ -11,0 +10,0 @@

@@ -48,2 +48,3 @@ import {

readonly watches?: IWatchDefinition[];
readonly strict?: boolean;
}>;

@@ -229,2 +230,3 @@

public readonly watches: IWatchDefinition[],
public readonly strict: boolean | undefined,
public readonly processContent: ProcessContentHook | null,

@@ -287,3 +289,6 @@ ) { }

fromDefinitionOrDefault('watches', def as CustomElementDefinition, returnEmptyArray),
// casting is incorrect, but it's good enough
fromDefinitionOrDefault('strict', def, returnUndefined as () => boolean),
fromAnnotationOrTypeOrDefault('processContent', Type, returnNull as () => ProcessContentHook | null),
);

@@ -318,2 +323,3 @@ }

mergeArrays(Watch.getDefinitions(Type), Type.watches),
fromAnnotationOrTypeOrDefault('strict', Type, returnUndefined as () => boolean),
fromAnnotationOrTypeOrDefault('processContent', Type, returnNull as () => ProcessContentHook | null),

@@ -356,2 +362,3 @@ );

mergeArrays(nameOrDef.watches, Watch.getDefinitions(Type), Type.watches),
fromAnnotationOrDefinitionOrTypeOrDefault('strict', nameOrDef, Type, returnUndefined as () => boolean),
fromAnnotationOrDefinitionOrTypeOrDefault('processContent', nameOrDef, Type, returnNull),

@@ -411,2 +418,3 @@ );

const returnNull = <T>(): T | null => null;
const returnUndefined = <T>(): T | undefined => void 0;
const returnFalse = () => false;

@@ -413,0 +421,0 @@ const returnTrue = () => true;

import { isFunction, isPromise, type Constructable, IContainer, InstanceProvider, type MaybePromise, emptyArray, onResolve, resolve, transient } from '@aurelia/kernel';
import { IObserverLocator } from '@aurelia/runtime';
import { Scope } from '../../binding/scope';
import { IExpressionParser } from '@aurelia/expression-parser';
import { IObserverLocator, Scope } from '@aurelia/runtime';
import { HydrateElementInstruction, IInstruction, ITemplateCompiler, AttrSyntax } from '@aurelia/template-compiler';
import { INode, IRenderLocation, convertToRenderLocation, registerHostNode } from '../../dom';

@@ -13,4 +14,2 @@ import { IPlatform } from '../../platform';

import { SpreadBinding } from '../../binding/spread-binding';
import { HydrateElementInstruction, IInstruction, ITemplateCompiler, AttrSyntax } from '@aurelia/template-compiler';
import { IExpressionParser } from '@aurelia/expression-parser';

@@ -17,0 +16,0 @@ /**

@@ -1,2 +0,4 @@

import { Scope } from '../../binding/scope';
import { IContainer, InstanceProvider, Writable, emptyArray, onResolve, resolve } from '@aurelia/kernel';
import { Scope } from '@aurelia/runtime';
import { IInstruction, type HydrateElementInstruction } from '@aurelia/template-compiler';
import { IRenderLocation } from '../../dom';

@@ -9,4 +11,2 @@ import { CustomElementDefinition, CustomElementStaticAuDefinition, elementTypeName } from '../custom-element';

import { IInstruction, type HydrateElementInstruction } from '@aurelia/template-compiler';
import { IContainer, InstanceProvider, Writable, emptyArray, onResolve, resolve } from '@aurelia/kernel';
import type { ControllerVisitor, ICustomElementController, ICustomElementViewModel, IHydratedController, IHydratedParentController, ISyntheticView } from '../../templating/controller';

@@ -13,0 +13,0 @@ import type { IViewFactory } from '../../templating/view';

@@ -6,2 +6,4 @@ import { Key, IResolver, own } from '@aurelia/kernel';

* Create a resolver for a given key that will only resolve from the nearest hydration context.
*
* @internal
*/

@@ -8,0 +10,0 @@ export const fromHydrationContext = <T extends Key>(key: T): IResolver<T | undefined> => ({

@@ -65,2 +65,3 @@ /* eslint-disable @typescript-eslint/strict-boolean-expressions */

/** @internal */
private _swap(value: unknown): void | Promise<void> {

@@ -67,0 +68,0 @@ const currView = this.view;

import { Task, TaskAbortError } from '@aurelia/platform';
import { ILogger, onResolve, onResolveAll, resolve, isPromise, registrableMetadataKey } from '@aurelia/kernel';
import { Scope } from '../../binding/scope';
import { Scope } from '@aurelia/runtime';
import { INode, IRenderLocation } from '../../dom';

@@ -5,0 +5,0 @@ import { IPlatform } from '../../platform';

@@ -18,3 +18,2 @@ import {

BindingBehaviorExpression,
DestructuringAssignmentExpression,
ForOfStatement,

@@ -30,12 +29,8 @@ type IsBindingBehavior,

createIndexMap,
} from '@aurelia/runtime';
import {
astEvaluate,
astAssign,
} from '../../ast.eval';
import {
Scope,
BindingContext,
type IOverrideContext,
} from '../../binding/scope';
} from '@aurelia/runtime';
import { IExpressionParser } from '@aurelia/expression-parser';

@@ -74,4 +69,2 @@ import { IRenderLocation } from '../../dom';

public views: ISyntheticView[] = [];
private _oldViews: ISyntheticView[] = [];
public forOf!: ForOfStatement;

@@ -85,4 +78,6 @@ public local!: string;

/** @internal */ private readonly _keyMap: Map<unknown, unknown> = new Map();
/** @internal */ private readonly _scopeMap: Map<unknown, Scope> = new Map();
/** @internal */ private _oldViews: ISyntheticView[] = [];
/** @internal */ private _scopes: Scope[] = [];
/** @internal */ private _oldScopes: Scope[] = [];
/** @internal */ private _scopeMap: Map<unknown, Scope | Scope[]> = new Map();
/** @internal */ private _observer?: CollectionObserver = void 0;

@@ -159,2 +154,3 @@ /** @internal */ private _innerItems: Items<C> | null;

this._normalizeToArray();
this._createScopes();

@@ -178,3 +174,2 @@ return this._activateAllViews(initiator, this._normalizedItems ?? emptyArray);

this._scopeMap.clear();
this._keyMap.clear();
}

@@ -189,3 +184,4 @@

this._normalizeToArray();
this._applyIndexMap(this.items!, void 0);
this._createScopes();
this._applyIndexMap(void 0);
}

@@ -209,7 +205,8 @@

this._normalizeToArray();
this._applyIndexMap(collection, indexMap);
this._createScopes();
this._applyIndexMap(indexMap);
}
/** @internal */
private _applyIndexMap(collection: Collection, indexMap: IndexMap | undefined): void {
private _applyIndexMap(indexMap: IndexMap | undefined): void {
const oldViews = this.views;

@@ -221,2 +218,5 @@ this._oldViews = oldViews.slice();

const oldScopes = this._oldScopes;
const newScopes = this._scopes;
if (hasKey || indexMap === void 0) {

@@ -241,149 +241,58 @@ const local = this.local;

// Only remove old views
if (hasDestructuredLocal) {
for (i = 0; i < oldLen; ++i) {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(astEvaluate(dec, oldViews[i].scope, binding, null) as IIndexable);
}
} else {
for (i = 0; i < oldLen; ++i) {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(oldViews[i].scope.bindingContext[local]);
}
for (i = 0; i < oldLen; ++i) {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(getItem(hasDestructuredLocal, dec, oldScopes[i], binding, local));
}
} else {
const oldItems = Array<IIndexable>(oldLen);
} else if (hasKey) {
const oldKeys = Array<unknown>(oldLen);
if (hasDestructuredLocal) {
for (i = 0; i < oldLen; ++i) {
oldItems[i] = astEvaluate(dec, oldViews[i].scope, binding, null) as IIndexable;
}
} else {
for (i = 0; i < oldLen; ++i) {
oldItems[i] = oldViews[i].scope.bindingContext[local];
}
for (i = 0; i < oldLen; ++i) {
oldKeys[i] = getKeyValue(hasDestructuredLocal, key, dec, oldScopes[i], binding, local);
}
let oldItem: unknown;
let newItem: unknown;
let oldKey: unknown;
let newKey: unknown;
let j = 0;
const oldEnd = oldLen - 1;
const newEnd = newLen - 1;
const newKeys = Array<unknown>(oldLen);
const oldIndices = new Map<unknown, number>();
const newIndices = new Map<unknown, number>();
const keyMap = this._keyMap;
const scopeMap = this._scopeMap;
const parentScope = this.$controller.scope;
i = 0;
// Step 1: narrow down the loop range as much as possible by checking the start and end for key equality
outer: {
// views with same key at start
// eslint-disable-next-line no-constant-condition
while (true) {
if (hasKey) {
oldItem = oldItems[i];
newItem = newItems[i];
oldKey = getKeyValue(keyMap, key, oldItem, getScope(scopeMap, oldItem, forOf, parentScope, binding, local, hasDestructuredLocal), binding);
newKey = getKeyValue(keyMap, key, newItem, getScope(scopeMap, newItem, forOf, parentScope, binding, local, hasDestructuredLocal), binding);
} else {
oldItem = oldKey = ensureUnique(oldItems[i], i);
newItem = newKey = ensureUnique(newItems[i], i);
}
if (oldKey !== newKey) {
keyMap.set(oldItem, oldKey);
keyMap.set(newItem, newKey);
break;
}
++i;
if (i > oldEnd || i > newEnd) {
break outer;
}
}
// TODO(perf): might be able to remove this condition with some offset magic?
if (oldEnd !== newEnd) {
break outer;
}
// views with same key at end
j = newEnd;
// eslint-disable-next-line no-constant-condition
while (true) {
if (hasKey) {
oldItem = oldItems[j];
newItem = newItems[j];
oldKey = getKeyValue(keyMap, key, oldItem, getScope(scopeMap, oldItem, forOf, parentScope, binding, local, hasDestructuredLocal), binding);
newKey = getKeyValue(keyMap, key, newItem, getScope(scopeMap, newItem, forOf, parentScope, binding, local, hasDestructuredLocal), binding);
} else {
oldItem = oldKey = ensureUnique(oldItems[i], i);
newItem = newKey = ensureUnique(newItems[i], i);
}
if (oldKey !== newKey) {
keyMap.set(oldItem, oldKey);
keyMap.set(newItem, newKey);
break;
}
--j;
if (i > j) {
break outer;
}
}
for (i = 0; i < newLen; ++i) {
newKeys[i] = getKeyValue(hasDestructuredLocal, key, dec, newScopes[i], binding, local);
}
// Step 2: map keys to indices and adjust the indexMap
const oldStart = i;
const newStart = i;
for (i = newStart; i <= newEnd; ++i) {
if (keyMap.has(newItem = hasKey ? newItems[i] : ensureUnique(newItems[i], i))) {
newKey = keyMap.get(newItem);
for (i = 0; i < newLen; ++i) {
if (oldKeys.includes(newKeys[i])) {
indexMap[i] = oldKeys.indexOf(newKeys[i]);
} else {
newKey = hasKey
? getKeyValue(keyMap, key, newItem, getScope(scopeMap, newItem, forOf, parentScope, binding, local, hasDestructuredLocal), binding)
: newItem;
keyMap.set(newItem, newKey);
indexMap[i] = -2;
}
newIndices.set(newKey, i);
}
for (i = oldStart; i <= oldEnd; ++i) {
if (keyMap.has(oldItem = hasKey ? oldItems[i] : ensureUnique(oldItems[i], i))) {
oldKey = keyMap.get(oldItem);
} else {
oldKey = hasKey
? getKeyValue(keyMap, key, oldItem, oldViews[i].scope, binding)
: oldItem;
for (i = 0; i < oldLen; ++i) {
if (!newKeys.includes(oldKeys[i])) {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(getItem(hasDestructuredLocal, dec, oldScopes[i], binding, local));
}
oldIndices.set(oldKey, i);
if (newIndices.has(oldKey)) {
indexMap[newIndices.get(oldKey)!] = i;
}
} else {
for (i = 0; i < newLen; ++i) {
if (oldScopes.includes(newScopes[i])) {
indexMap[i] = oldScopes.indexOf(newScopes[i]);
} else {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(oldItem);
indexMap[i] = -2;
}
}
for (i = newStart; i <= newEnd; ++i) {
if (!oldIndices.has(keyMap.get(hasKey ? newItems[i] : ensureUnique(newItems[i], i)))) {
indexMap[i] = -2;
for (i = 0; i < oldLen; ++i) {
if (!newScopes.includes(oldScopes[i])) {
indexMap.deletedIndices.push(i);
indexMap.deletedItems.push(getItem(hasDestructuredLocal, dec, oldScopes[i], binding, local));
}
}
oldIndices.clear();
newIndices.clear();
}
}
if (indexMap === void 0) {
// first detach+unbind+(remove from array) the deleted view indices
if (indexMap.deletedIndices.length > 0) {
const ret = onResolve(
this._deactivateAllViews(null),
this._deactivateAndRemoveViewsByKey(indexMap),
() => {
// TODO(fkleuver): add logic to the controller that ensures correct handling of race conditions and add a variety of `if` integration tests
return this._activateAllViews(null, this._normalizedItems ?? emptyArray);
return this._createAndActivateAndSortViewsByKey(indexMap);
},

@@ -393,17 +302,5 @@ );

} else {
// first detach+unbind+(remove from array) the deleted view indices
if (indexMap.deletedIndices.length > 0) {
const ret = onResolve(
this._deactivateAndRemoveViewsByKey(indexMap),
() => {
// TODO(fkleuver): add logic to the controller that ensures correct handling of race conditions and add a variety of `if` integration tests
return this._createAndActivateAndSortViewsByKey(oldLen, indexMap);
},
);
if (isPromise(ret)) { ret.catch(rethrow); }
} else {
// TODO(fkleuver): add logic to the controller that ensures correct handling of race conditions and add integration tests
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._createAndActivateAndSortViewsByKey(oldLen, indexMap);
}
// TODO(fkleuver): add logic to the controller that ensures correct handling of race conditions and add integration tests
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._createAndActivateAndSortViewsByKey(indexMap);
}

@@ -441,2 +338,27 @@ }

/** @internal */
private _createScopes(): void {
const oldScopes = this._scopes;
this._oldScopes = oldScopes.slice();
const items = this._normalizedItems!;
const len = items.length;
const scopes = this._scopes = Array(items.length);
const oldScopeMap = this._scopeMap;
const newScopeMap = new Map<unknown, Scope | Scope[]>();
const parentScope = this.$controller.scope;
const binding = this._forOfBinding;
const forOf = this.forOf;
const local = this.local;
const hasDestructuredLocal = this._hasDestructuredLocal;
for (let i = 0; i < len; ++i) {
scopes[i] = getScope(oldScopeMap, newScopeMap, items[i], forOf, parentScope, binding, local, hasDestructuredLocal);
}
oldScopeMap.clear();
this._scopeMap = newScopeMap;
}
/** @internal */
private _normalizeToArray(): void {

@@ -464,23 +386,22 @@ const items = this.items;

let view: ISyntheticView;
let viewScope: Scope;
let scope: Scope;
const { $controller, _factory, local, _location, _scopeMap, _forOfBinding, forOf, _hasDestructuredLocal } = this;
const parentScope = $controller.scope;
const { $controller, _factory, _location, _scopes } = this;
const newLen = $items.length;
const views = this.views = Array(newLen);
$items.forEach((item, i) => {
for (let i = 0; i < newLen; ++i) {
view = views[i] = _factory.create().setLocation(_location);
view.nodes.unlink();
viewScope = getScope(_scopeMap, item as IIndexable, forOf, parentScope, _forOfBinding, local, _hasDestructuredLocal);
setContextualProperties(viewScope.overrideContext as IRepeatOverrideContext, i, newLen);
scope = _scopes[i];
ret = view.activate(initiator ?? view, $controller, viewScope);
setContextualProperties(scope.overrideContext as RepeatOverrideContext, i, newLen);
ret = view.activate(initiator ?? view, $controller, scope);
if (isPromise(ret)) {
(promises ??= []).push(ret);
}
});
}
if (promises !== void 0) {
return (promises as Promise<void>[]).length === 1
return promises.length === 1
? promises[0]

@@ -555,3 +476,2 @@ : Promise.all(promises) as unknown as Promise<void>;

private _createAndActivateAndSortViewsByKey(
oldLength: number,
indexMap: IndexMap,

@@ -562,9 +482,8 @@ ): void | Promise<void> {

let view: ISyntheticView;
let viewScope: Scope;
let i = 0;
const { $controller, _factory, local, _normalizedItems, _location, views, _hasDestructuredLocal, _forOfBinding, _scopeMap, _oldViews, forOf } = this;
const mapLen = indexMap.length;
const { $controller, _factory, _location, views, _scopes, _oldViews } = this;
const newLen = indexMap.length;
for (; mapLen > i; ++i) {
for (; newLen > i; ++i) {
if (indexMap[i] === -2) {

@@ -576,8 +495,6 @@ view = _factory.create();

if (views.length !== mapLen) {
throw createMappedError(ErrorNames.repeat_mismatch_length, [views.length, mapLen]);
if (views.length !== newLen) {
throw createMappedError(ErrorNames.repeat_mismatch_length, [views.length, newLen]);
}
const parentScope = $controller.scope;
const newLen = indexMap.length;
let source = 0;

@@ -596,3 +513,2 @@ i = 0;

const dec = forOf.declaration as DestructuringAssignmentExpression;
let next: ISyntheticView;

@@ -608,7 +524,5 @@ let j = seqLen - 1;

if (indexMap[i] === -2) {
viewScope = getScope(_scopeMap, _normalizedItems![i] as IIndexable, forOf, parentScope, _forOfBinding, local, _hasDestructuredLocal);
setContextualProperties(viewScope.overrideContext as IRepeatOverrideContext, i, newLen);
view.setLocation(_location);
ret = view.activate(view, $controller, viewScope);
setContextualProperties(_scopes[i].overrideContext as RepeatOverrideContext, i, newLen);
ret = view.activate(view, $controller, _scopes[i]);
if (isPromise(ret)) {

@@ -618,18 +532,6 @@ (promises ?? (promises = [])).push(ret);

} else if (j < 0 || seqLen === 1 || i !== seq[j]) {
if (_hasDestructuredLocal) {
astAssign(dec, view.scope, _forOfBinding, _normalizedItems![i]);
} else {
view.scope.bindingContext[local] = _normalizedItems![i];
}
setContextualProperties(view.scope.overrideContext as IRepeatOverrideContext, i, newLen);
setContextualProperties(view.scope.overrideContext as RepeatOverrideContext, i, newLen);
view.nodes.insertBefore(view.location!);
} else {
if (_hasDestructuredLocal) {
astAssign(dec, view.scope, _forOfBinding, _normalizedItems![i]);
} else {
view.scope.bindingContext[local] = _normalizedItems![i];
}
if (oldLength !== newLen) {
setContextualProperties(view.scope.overrideContext as IRepeatOverrideContext, i, newLen);
}
setContextualProperties(view.scope.overrideContext as RepeatOverrideContext, i, newLen);
--j;

@@ -745,12 +647,27 @@ }

class RepeatOverrideContext implements IRepeatOverrideContext {
public get $odd(): boolean {
return !this.$even;
}
public get $even(): boolean {
return this.$index % 2 === 0;
}
public get $first(): boolean {
return this.$index === 0;
}
public get $middle(): boolean {
return !this.$first && !this.$last;
}
public get $last(): boolean {
return this.$index === this.$length - 1;
}
public constructor(
public readonly $index: number = 0,
public readonly $length: number = 1,
) {}
}
const setContextualProperties = (oc: IRepeatOverrideContext, index: number, length: number): void => {
const isFirst = index === 0;
const isLast = index === length - 1;
const isEven = index % 2 === 0;
oc.$index = index;
oc.$first = isFirst;
oc.$last = isLast;
oc.$middle = !isFirst && !isLast;
oc.$even = isEven;
oc.$odd = !isEven;
oc.$length = length;

@@ -907,24 +824,46 @@ };

const setItem = (
hasDestructuredLocal: boolean,
dec: ForOfStatement['declaration'],
scope: Scope,
binding: PropertyBinding,
local: string,
item: unknown,
) => {
if (hasDestructuredLocal) {
astAssign(dec, scope, binding, item);
} else {
scope.bindingContext[local] = item;
}
};
const getItem = (
hasDestructuredLocal: boolean,
dec: ForOfStatement['declaration'],
scope: Scope,
binding: PropertyBinding,
local: string,
): unknown => {
return hasDestructuredLocal ? astEvaluate(dec, scope, binding, null) : scope.bindingContext[local];
};
const getKeyValue = (
keyMap: Map<unknown, unknown>,
hasDestructuredLocal: boolean,
key: string | IsBindingBehavior,
item: unknown,
dec: ForOfStatement['declaration'],
scope: Scope,
binding: PropertyBinding,
local: string,
) => {
if (typeof key === 'string') {
const item = getItem(hasDestructuredLocal, dec, scope, binding, local);
return (item as IIndexable)[key];
}
let value = keyMap.get(item);
if (value === void 0) {
if (typeof key === 'string') {
value = (item as IIndexable)[key];
} else {
value = astEvaluate(key, scope, binding, null);
}
keyMap.set(item, value);
}
return value;
return astEvaluate(key, scope, binding, null);
};
const getScope = (
scopeMap: Map<unknown, Scope>,
oldScopeMap: Map<unknown, Scope | Scope[]>,
newScopeMap: Map<unknown, Scope | Scope[]>,
item: unknown,

@@ -937,31 +876,44 @@ forOf: ForOfStatement,

) => {
let scope = scopeMap.get(item);
// let scope = void 0 as Scope | Scope[] | undefined;
let scope = oldScopeMap.get(item);
if (scope === void 0) {
if (hasDestructuredLocal) {
astAssign(forOf.declaration as DestructuringAssignmentExpression, scope = Scope.fromParent(parentScope, new BindingContext()), binding, item);
scope = createScope(item, forOf, parentScope, binding, local, hasDestructuredLocal);
} else if (scope instanceof Scope) {
oldScopeMap.delete(item);
} else if (scope.length === 1) {
scope = scope[0];
oldScopeMap.delete(item);
} else {
scope = scope.shift()!;
}
if (newScopeMap.has(item)) {
const entry = newScopeMap.get(item)!;
if (entry instanceof Scope) {
newScopeMap.set(item, [entry, scope]);
} else {
scope = Scope.fromParent(parentScope, new BindingContext(local, item));
entry.push(scope);
}
scopeMap.set(item, scope);
} else {
newScopeMap.set(item, scope);
}
setItem(hasDestructuredLocal, forOf.declaration, scope, binding, local, item);
return scope;
};
const ensureUnique = <T>(item: T, index: number): T | string => {
const type = typeof item;
switch (type) {
case 'object':
if (item !== null) return item;
// falls through
case 'string':
case 'number':
case 'bigint':
case 'undefined':
case 'boolean':
return `${index}${type}${item}`;
default:
return item;
const createScope = (
item: unknown,
forOf: ForOfStatement,
parentScope: Scope,
binding: PropertyBinding,
local: string,
hasDestructuredLocal: boolean,
) => {
if (hasDestructuredLocal) {
const scope = Scope.fromParent(parentScope, new BindingContext(), new RepeatOverrideContext());
astAssign(forOf.declaration, scope, binding, item);
}
return Scope.fromParent(parentScope, new BindingContext(local, item), new RepeatOverrideContext());
};
const compareNumber = (a: number, b: number): number => a - b;

@@ -12,4 +12,5 @@ import {

IObserverLocator,
type Scope,
} from '@aurelia/runtime';
import { type Scope } from '../../binding/scope';
import type { IInstruction } from '@aurelia/template-compiler';
import { IRenderLocation } from '../../dom';

@@ -22,3 +23,2 @@ import { attrTypeName, CustomAttributeStaticAuDefinition, defineAttribute } from '../custom-attribute';

import type { INode } from '../../dom';
import type { IInstruction } from '@aurelia/template-compiler';
import { createMappedError, ErrorNames } from '../../errors';

@@ -25,0 +25,0 @@ import { PartialBindableDefinition } from '../../bindable';

@@ -1,2 +0,3 @@

import { Scope } from '../../binding/scope';
import { resolve } from '@aurelia/kernel';
import { Scope } from '@aurelia/runtime';
import { IRenderLocation } from '../../dom';

@@ -6,3 +7,2 @@ import { IViewFactory } from '../../templating/view';

import type { ICustomAttributeController, ICustomAttributeViewModel, IHydratedController, IHydratedParentController, ControllerVisitor } from '../../templating/controller';
import { resolve } from '@aurelia/kernel';

@@ -9,0 +9,0 @@ export class With implements ICustomAttributeViewModel {

import { areEqual, type IServiceLocator } from '@aurelia/kernel';
import { IsBindingBehavior } from '@aurelia/expression-parser';
import {

@@ -6,8 +7,5 @@ connectable,

ProxyObservable,
astEvaluate,
} from '@aurelia/runtime';
import {
astEvaluate,
} from '../ast.eval';
import { mixinAstEvaluator } from '../binding/binding-utils';
import { type Scope } from '../binding/scope';

@@ -21,5 +19,5 @@ import type {

ISubscriber,
Scope,
} from '@aurelia/runtime';
import type { IWatcherCallback } from '../watch';
import { IsBindingBehavior } from '@aurelia/expression-parser';
import { IBinding } from '../binding/interfaces-bindings';

@@ -128,3 +126,3 @@

connectable(ExpressionWatcher, null!);
mixinAstEvaluator(true)(ExpressionWatcher);
mixinAstEvaluator(ExpressionWatcher);
}

@@ -131,0 +129,0 @@

@@ -51,4 +51,4 @@ import {

for (let i = 0, ii = aliases.length; i < ii; ++i) {
Registration.aliasTo(key, resource.keyFrom(aliases[i])).register(container);
aliasRegistration(key, resource.keyFrom(aliases[i])).register(container);
}
}

@@ -76,3 +76,3 @@ import { emptyArray, isFunction } from '@aurelia/kernel';

}
} else if (!isFunction(target)) {
} else if (!isFunction(target) || context.static) {
throw createMappedError(ErrorNames.watch_non_method_decorator_usage, context.name);

@@ -89,4 +89,9 @@ }

} else {
// instance method decorator initializer is called for each instance
let added = false;
context.addInitializer(function (this: T) {
addDefinition(this.constructor as Constructable);
if (!added) {
added = true;
addDefinition(this.constructor as Constructable);
}
});

@@ -93,0 +98,0 @@ }

Sorry, the diff of this file is too big to display

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

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

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

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 too big to display

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