New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aurelia/runtime

Package Overview
Dependencies
Maintainers
1
Versions
1119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurelia/runtime - npm Package Compare versions

Comparing version 0.2.0-dev.20181010 to 0.2.0-dev.20181011

dist/binding/interfaces.d.ts

62

dist/binding/binding-context.d.ts

@@ -0,16 +1,56 @@

import { IIndexable } from '@aurelia/kernel';
import { StrictPrimitive } from './ast';
import { IBindScope, ObservedCollection, PropertyObserver } from './observation';
export interface IObserversLookup<TObj extends IIndexable = IIndexable, TKey extends keyof TObj = Exclude<keyof TObj, '$synthetic' | '$observers' | 'bindingContext' | 'overrideContext' | 'parentOverrideContext'>> {
}
export declare type ObserversLookup<TObj extends IIndexable = IIndexable, TKey extends keyof TObj = Exclude<keyof TObj, '$synthetic' | '$observers' | 'bindingContext' | 'overrideContext' | 'parentOverrideContext'>> = {
[P in TKey]: PropertyObserver;
} & {
getOrCreate(obj: IBindingContext | IOverrideContext, key: string): PropertyObserver;
};
export interface IBindingContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic?: true;
readonly $observers?: ObserversLookup<IOverrideContext>;
getObservers(): ObserversLookup<IOverrideContext>;
}
export interface IOverrideContext {
parentOverrideContext: IOverrideContext;
bindingContext: any;
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic?: true;
readonly $observers?: ObserversLookup<IOverrideContext>;
readonly bindingContext: IBindingContext | IBindScope;
readonly parentOverrideContext: IOverrideContext | null;
getObservers(): ObserversLookup<IOverrideContext>;
}
export interface IScope {
bindingContext: any;
overrideContext: IOverrideContext;
readonly bindingContext: IBindingContext | IBindScope;
readonly overrideContext: IOverrideContext;
}
export declare const BindingContext: {
createScope(bindingContext: any, overrideContext?: IOverrideContext): IScope;
createScopeFromOverride(overrideContext: IOverrideContext): IScope;
createScopeFromParent(parentScope: IScope, bindingContext: any): IScope;
createOverride(bindingContext?: any, parentOverrideContext?: IOverrideContext): IOverrideContext;
get(scope: IScope, name: string, ancestor: number): any;
};
export declare class BindingContext implements IBindingContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic: true;
$observers: ObserversLookup<IOverrideContext>;
private constructor();
static create(obj?: IIndexable): BindingContext;
static create(key: string, value: ObservedCollection | StrictPrimitive | IIndexable): BindingContext;
static get(scope: IScope, name: string, ancestor: number): IBindingContext | IOverrideContext | IBindScope;
getObservers(): ObserversLookup<IOverrideContext>;
}
export declare class Scope implements IScope {
readonly bindingContext: IBindingContext | IBindScope;
readonly overrideContext: IOverrideContext;
private constructor();
static create(bc: IBindingContext | IBindScope, oc: IOverrideContext | null): Scope;
static fromOverride(oc: IOverrideContext): Scope;
static fromParent(ps: IScope, bc: IBindingContext | IBindScope): Scope;
}
export declare class OverrideContext implements IOverrideContext {
readonly bindingContext: IBindingContext | IBindScope;
readonly parentOverrideContext: IOverrideContext | null;
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic: true;
private constructor();
static create(bc: IBindingContext | IBindScope, poc: IOverrideContext | null): OverrideContext;
getObservers(): ObserversLookup<IOverrideContext>;
}
//# sourceMappingURL=binding-context.d.ts.map

@@ -31,2 +31,3 @@ import { IDisposable, IIndexable } from '@aurelia/kernel';

export declare type IObservable = (IIndexable | string | Node | INode | Collection) & {
readonly $synthetic?: false;
$observers?: Record<string, AccessorOrObserver>;

@@ -33,0 +34,0 @@ };

5

dist/binding/observer-locator.d.ts
import { IIndexable, Primitive } from '@aurelia/kernel';
import { IBindingContext, IOverrideContext } from './binding-context';
import { IChangeSet } from './change-set';
import { IDirtyChecker } from './dirty-checker';
import { IEventManager } from './event-manager';
import { AccessorOrObserver, CollectionKind, IBindingTargetAccessor, IBindingTargetObserver, ICollectionObserver, IObservable, IObservedArray, IObservedMap, IObservedSet, CollectionObserver } from './observation';
import { AccessorOrObserver, CollectionKind, CollectionObserver, IBindingTargetAccessor, IBindingTargetObserver, ICollectionObserver, IObservable, IObservedArray, IObservedMap, IObservedSet } from './observation';
import { ISVGAnalyzer } from './svg-analyzer';

@@ -26,3 +27,3 @@ export interface IObjectObservationAdapter {

constructor(changeSet: IChangeSet, eventManager: IEventManager, dirtyChecker: IDirtyChecker, svgAnalyzer: ISVGAnalyzer);
getObserver(obj: IObservable, propertyName: string): AccessorOrObserver;
getObserver(obj: IObservable | IBindingContext | IOverrideContext, propertyName: string): AccessorOrObserver;
addAdapter(adapter: IObjectObservationAdapter): void;

@@ -29,0 +30,0 @@ getAccessor(obj: IObservable, propertyName: string): IBindingTargetAccessor;

{
"name": "@aurelia/runtime",
"version": "0.2.0-dev.20181010",
"version": "0.2.0-dev.20181011",
"main": "dist/index.umd.js",

@@ -46,3 +46,3 @@ "module": "dist/index.es6.js",

"dependencies": {
"@aurelia/kernel": "0.2.0-dev.20181010"
"@aurelia/kernel": "0.2.0-dev.20181011"
},

@@ -88,3 +88,3 @@ "devDependencies": {

},
"gitHead": "72671654f43951788cfc9252c70861e7c874dce8"
"gitHead": "c3e377931750c56e17b41d22ae3a6697883a900f"
}

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

import { Reporter } from "@aurelia/kernel";
import { IIndexable, Reporter } from '@aurelia/kernel';
import { StrictPrimitive } from './ast';
import { IBindScope, ObservedCollection, PropertyObserver } from './observation';
import { SetterObserver } from './property-observation';
export interface IOverrideContext {
parentOverrideContext: IOverrideContext;
bindingContext: any;
}
export interface IScope {
bindingContext: any;
overrideContext: IOverrideContext;
}
const enum RuntimeError {

@@ -20,42 +13,77 @@ UndefinedScope = 250, // trying to evaluate on something that's not a valid binding

export const BindingContext = {
createScope(bindingContext: any, overrideContext?: IOverrideContext): IScope {
return {
bindingContext: bindingContext,
overrideContext: overrideContext || BindingContext.createOverride(bindingContext)
};
},
export interface IObserversLookup<TObj extends IIndexable = IIndexable, TKey extends keyof TObj =
Exclude<keyof TObj, '$synthetic' | '$observers' | 'bindingContext' | 'overrideContext' | 'parentOverrideContext'>> {
createScopeFromOverride(overrideContext: IOverrideContext): IScope {
if (overrideContext === null || overrideContext === undefined) {
throw Reporter.error(RuntimeError.NilOverrideContext);
}
export type ObserversLookup<TObj extends IIndexable = IIndexable, TKey extends keyof TObj =
Exclude<keyof TObj, '$synthetic' | '$observers' | 'bindingContext' | 'overrideContext' | 'parentOverrideContext'>> =
{ [P in TKey]: PropertyObserver; } & { getOrCreate(obj: IBindingContext | IOverrideContext, key: string): PropertyObserver };
/*@internal*/
export class InternalObserversLookup {
public getOrCreate(obj: IBindingContext | IOverrideContext, key: string): PropertyObserver {
let observer = this[key];
if (observer === undefined) {
observer = this[key] = new SetterObserver(obj, key);
}
return {
bindingContext: overrideContext.bindingContext,
overrideContext
};
},
return observer;
}
}
createScopeFromParent(parentScope: IScope, bindingContext: any): IScope {
if (parentScope === null || parentScope === undefined) {
throw Reporter.error(RuntimeError.NilParentScope);
export interface IBindingContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic?: true;
readonly $observers?: ObserversLookup<IOverrideContext>;
getObservers(): ObserversLookup<IOverrideContext>;
}
export interface IOverrideContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
readonly $synthetic?: true;
readonly $observers?: ObserversLookup<IOverrideContext>;
readonly bindingContext: IBindingContext | IBindScope;
readonly parentOverrideContext: IOverrideContext | null;
getObservers(): ObserversLookup<IOverrideContext>;
}
export interface IScope {
readonly bindingContext: IBindingContext | IBindScope;
readonly overrideContext: IOverrideContext;
}
export class BindingContext implements IBindingContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
public readonly $synthetic: true = true;
public $observers: ObserversLookup<IOverrideContext>;
private constructor(keyOrObj?: string | IIndexable, value?: ObservedCollection | StrictPrimitive | IIndexable) {
if (keyOrObj !== undefined) {
if (value !== undefined) {
// if value is defined then it's just a property and a value to initialize with
// tslint:disable-next-line:no-any
this[<any>keyOrObj] = value;
} else {
// can either be some random object or another bindingContext to clone from
for (const prop in <IIndexable>keyOrObj) {
if (keyOrObj.hasOwnProperty(prop)) {
this[prop] = keyOrObj[prop];
}
}
}
}
return {
bindingContext: bindingContext,
overrideContext: BindingContext.createOverride(
bindingContext,
parentScope.overrideContext
)
};
},
}
createOverride(bindingContext?: any, parentOverrideContext?: IOverrideContext): IOverrideContext {
return {
bindingContext: bindingContext,
parentOverrideContext: parentOverrideContext || null
};
},
public static create(obj?: IIndexable): BindingContext;
public static create(key: string, value: ObservedCollection | StrictPrimitive | IIndexable): BindingContext;
public static create(keyOrObj?: string | IIndexable, value?: ObservedCollection | StrictPrimitive | IIndexable): BindingContext {
return new BindingContext(keyOrObj, value);
}
// tslint:disable-next-line:no-reserved-keywords
get(scope: IScope, name: string, ancestor: number): any {
public static get(scope: IScope, name: string, ancestor: number): IBindingContext | IOverrideContext | IBindScope {
if (scope === undefined) {

@@ -69,5 +97,8 @@ throw Reporter.error(RuntimeError.UndefinedScope);

if (ancestor) {
if (ancestor > 0) {
// jump up the required number of ancestor contexts (eg $parent.$parent requires two jumps)
while (ancestor && overrideContext) {
while (ancestor > 0) {
if (overrideContext.parentOverrideContext === null) {
return undefined;
}
ancestor--;

@@ -77,6 +108,2 @@ overrideContext = overrideContext.parentOverrideContext;

if (ancestor || !overrideContext) {
return undefined;
}
return name in overrideContext ? overrideContext : overrideContext.bindingContext;

@@ -98,2 +125,58 @@ }

}
};
public getObservers(): ObserversLookup<IOverrideContext> {
let observers = this.$observers;
if (observers === undefined) {
this.$observers = observers = new InternalObserversLookup() as ObserversLookup<this>;
}
return observers;
}
}
export class Scope implements IScope {
private constructor(
public readonly bindingContext: IBindingContext | IBindScope,
public readonly overrideContext: IOverrideContext
) { }
public static create(bc: IBindingContext | IBindScope, oc: IOverrideContext | null): Scope {
return new Scope(bc, oc === null || oc === undefined ? OverrideContext.create(bc, oc) : oc);
}
public static fromOverride(oc: IOverrideContext): Scope {
if (oc === null || oc === undefined) {
throw Reporter.error(RuntimeError.NilOverrideContext);
}
return new Scope(oc.bindingContext, oc);
}
public static fromParent(ps: IScope, bc: IBindingContext | IBindScope): Scope {
if (ps === null || ps === undefined) {
throw Reporter.error(RuntimeError.NilParentScope);
}
return new Scope(bc, OverrideContext.create(bc, ps.overrideContext));
}
}
export class OverrideContext implements IOverrideContext {
[key: string]: ObservedCollection | StrictPrimitive | IIndexable;
public readonly $synthetic: true = true;
private constructor(
public readonly bindingContext: IBindingContext | IBindScope,
public readonly parentOverrideContext: IOverrideContext | null
) { }
public static create(bc: IBindingContext | IBindScope, poc: IOverrideContext | null): OverrideContext {
return new OverrideContext(bc, poc === undefined ? null : poc);
}
public getObservers(): ObserversLookup<IOverrideContext> {
let observers = this.$observers;
if (observers === undefined) {
this.$observers = observers = new InternalObserversLookup();
}
return observers as ObserversLookup<IOverrideContext>;
}
}

@@ -51,2 +51,3 @@ import { IDisposable, IIndexable } from '@aurelia/kernel';

export type IObservable = (IIndexable | string | Node | INode | Collection) & {
readonly $synthetic?: false;
$observers?: Record<string, AccessorOrObserver>;

@@ -53,0 +54,0 @@ };

import { DI, IIndexable, inject, Primitive, Reporter } from '@aurelia/kernel';
import { DOM } from '../dom';
import { getArrayObserver } from './array-observer';
import { IBindingContext, IOverrideContext } from './binding-context';
import { IChangeSet } from './change-set';

@@ -10,7 +11,7 @@ import { createComputedObserver } from './computed-observer';

import { getMapObserver } from './map-observer';
import { AccessorOrObserver, CollectionKind, IBindingTargetAccessor, IBindingTargetObserver, ICollectionObserver, IObservable, IObservedArray, IObservedMap, IObservedSet, CollectionObserver } from './observation';
import { AccessorOrObserver, CollectionKind, CollectionObserver, IBindingTargetAccessor, IBindingTargetObserver, ICollectionObserver, IObservable, IObservedArray, IObservedMap, IObservedSet } from './observation';
import { PrimitiveObserver, SetterObserver } from './property-observation';
import { getSetObserver } from './set-observer';
import { ISVGAnalyzer } from './svg-analyzer';
import { ClassAttributeAccessor, DataAttributeAccessor, PropertyAccessor, StyleAttributeAccessor, XLinkAttributeAccessor, ElementPropertyAccessor } from './target-accessors';
import { ClassAttributeAccessor, DataAttributeAccessor, ElementPropertyAccessor, PropertyAccessor, StyleAttributeAccessor, XLinkAttributeAccessor } from './target-accessors';

@@ -60,3 +61,6 @@ const toStringTag = Object.prototype.toString;

public getObserver(obj: IObservable, propertyName: string): AccessorOrObserver {
public getObserver(obj: IObservable | IBindingContext | IOverrideContext, propertyName: string): AccessorOrObserver {
if (obj.$synthetic === true) {
return obj.getObservers().getOrCreate(obj, propertyName);
}
let observersLookup = obj.$observers;

@@ -63,0 +67,0 @@ let observer;

import { IIndexable, Primitive } from '@aurelia/kernel';
import { nativePush, nativeSplice } from './array-observer';
import { BindingFlags } from './binding-flags';

@@ -49,3 +48,3 @@ import { IBatchedCollectionSubscriber, IBatchedSubscriberCollection, IndexMap, IPropertySubscriber, ISubscriberCollection, MutationKind, MutationKindToBatchedSubscriber, MutationKindToSubscriber, SubscriberFlags } from './observation';

}
nativePush.call(this._subscribersRest, subscriber);
this._subscribersRest.push(subscriber);
return true;

@@ -75,3 +74,3 @@ }

if (subscribers[i] === subscriber) {
nativeSplice.call(subscribers, i, 1);
subscribers.splice(i, 1);
if (ii === 1) {

@@ -228,3 +227,3 @@ this._subscriberFlags &= ~SubscriberFlags.SubscribersRest;

}
nativePush.call(this._batchedSubscribersRest, subscriber);
this._batchedSubscribersRest.push(subscriber);
return true;

@@ -254,3 +253,3 @@ }

if (subscribers[i] === subscriber) {
nativeSplice.call(subscribers, i, 1);
subscribers.splice(i, 1);
if (ii === 1) {

@@ -257,0 +256,0 @@ this._batchedSubscriberFlags &= ~SubscriberFlags.SubscribersRest;

@@ -11,3 +11,3 @@ import {

} from '@aurelia/kernel';
import { BindingContext } from '../binding/binding-context';
import { BindingContext, Scope } from '../binding/binding-context';
import { BindingFlags } from '../binding/binding-flags';

@@ -149,3 +149,3 @@ import { DOM, ICustomElementHost, INode, INodeSequence, IRenderLocation } from '../dom';

this.$isBound = false;
this.$scope = BindingContext.createScope(this);
this.$scope = Scope.create(this, null); // TODO: get the parent from somewhere?
this.$projector = determineProjector(this, host, description);

@@ -152,0 +152,0 @@

import { inject } from '@aurelia/kernel';
import { Binding, BindingContext, BindingFlags, CollectionObserver, ForOfStatement, getCollectionObserver, IBatchedCollectionSubscriber, IChangeSet, IObservedArray, IScope, ObservedCollection, SetterObserver } from '../../binding';
import { Binding, BindingContext, BindingFlags, CollectionObserver, ForOfStatement, getCollectionObserver, IBatchedCollectionSubscriber, IChangeSet, IObservedArray, IScope, ObservedCollection, SetterObserver, Scope } from '../../binding';
import { INode, IRenderLocation } from '../../dom';

@@ -116,5 +116,5 @@ import { bindable } from '../bindable';

if (!!view.$scope && view.$scope.bindingContext[local] === item) {
view.$bind(flags, BindingContext.createScopeFromParent($scope, view.$scope.bindingContext));
view.$bind(flags, Scope.fromParent($scope, view.$scope.bindingContext));
} else {
view.$bind(flags, BindingContext.createScopeFromParent($scope, { [local]: item }))
view.$bind(flags, Scope.fromParent($scope, BindingContext.create(local, item)));
}

@@ -126,5 +126,5 @@ });

if (indexMap[i] === i) {
view.$bind(flags, BindingContext.createScopeFromParent($scope, view.$scope.bindingContext));
view.$bind(flags, Scope.fromParent($scope, view.$scope.bindingContext));
} else {
view.$bind(flags, BindingContext.createScopeFromParent($scope, { [local]: item }))
view.$bind(flags, Scope.fromParent($scope, BindingContext.create(local, item)));
}

@@ -131,0 +131,0 @@ });

import { inject } from '@aurelia/kernel';
import { BindingContext, IScope } from '../../binding/binding-context';
import { BindingContext, IScope, Scope } from '../../binding/binding-context';
import { BindingFlags } from '../../binding/binding-flags';

@@ -46,5 +46,5 @@ import { IRenderLocation } from '../../dom';

flags,
BindingContext.createScopeFromParent(this.$scope, this.value)
Scope.fromParent(this.$scope, this.value)
);
}
}

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

Sorry, the diff of this file is not supported yet

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

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