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
1120
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

to
2.1.0-dev.202409041326

2

dist/types/collection-length-observer.d.ts

@@ -11,2 +11,3 @@ import { Collection, IObserver } from './interfaces';

setValue(newValue: number): void;
handleDirty(): void;
handleCollectionChange(_arr: unknown[], _: IndexMap): void;

@@ -22,4 +23,5 @@ }

setValue(): void;
handleDirty(): void;
handleCollectionChange(_collection: Collection, _: IndexMap): void;
}
//# sourceMappingURL=collection-length-observer.d.ts.map

@@ -28,2 +28,3 @@ import { ICoercionConfiguration, IObserver, InterceptorFunc } from './interfaces';

useCallback(callback: (newValue: unknown, oldValue: unknown) => void): boolean;
handleDirty(): void;
handleChange(): void;

@@ -30,0 +31,0 @@ handleCollectionChange(): void;

@@ -16,6 +16,9 @@ import { IIndexable } from '@aurelia/kernel';

}
export interface IDirtySubscriber {
handleDirty(): void;
}
/**
* Interface of a subscriber or property change handler
*/
export interface ISubscriber<TValue = unknown> {
export interface ISubscriber<TValue = unknown> extends Partial<IDirtySubscriber> {
handleChange(newValue: TValue, previousValue: TValue): void;

@@ -47,2 +50,3 @@ }

notifyCollection(collection: Collection, indexMap: IndexMap): void;
notifyDirty(): void;
}

@@ -49,0 +53,0 @@ /**

10

package.json
{
"name": "@aurelia/runtime",
"version": "2.1.0-dev.202407271309",
"version": "2.1.0-dev.202409041326",
"main": "dist/cjs/index.cjs",

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

"dependencies": {
"@aurelia/kernel": "2.1.0-dev.202407271309",
"@aurelia/expression-parser": "2.1.0-dev.202407271309",
"@aurelia/metadata": "2.1.0-dev.202407271309",
"@aurelia/platform": "2.1.0-dev.202407271309"
"@aurelia/kernel": "2.1.0-dev.202409041326",
"@aurelia/expression-parser": "2.1.0-dev.202409041326",
"@aurelia/metadata": "2.1.0-dev.202409041326",
"@aurelia/platform": "2.1.0-dev.202409041326"
},

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

@@ -429,2 +429,4 @@ import {

const subs = this.subs;
subs.notifyDirty();
const indexMap = this.indexMap;

@@ -440,3 +442,3 @@ if (batching) {

this.indexMap = createIndexMap(length);
this.subs.notifyCollection(arr, indexMap);
subs.notifyCollection(arr, indexMap);
}

@@ -494,2 +496,8 @@

public handleDirty() {
if (this.value !== this.getValue()) {
this.subs.notifyDirty();
}
}
/**

@@ -506,3 +514,2 @@ * From interface `ICollectionSubscriber`

const currValue = this.value = this.getValue();
// hmm
if (prevValue !== currValue) {

@@ -509,0 +516,0 @@ this.subs.notify(currValue, prevValue);

@@ -60,2 +60,8 @@ import { Collection, IObserver, atObserver } from './interfaces';

public handleDirty() {
if (this._value !== this._obj.length) {
this.subs.notifyDirty();
}
}
public handleCollectionChange(_arr: unknown[], _: IndexMap) {

@@ -65,2 +71,3 @@ const oldValue = this._value;

if ((this._value = value) !== oldValue) {
this.subs.notifyDirty();
this.subs.notify(this._value, oldValue);

@@ -100,2 +107,8 @@ }

public handleDirty() {
if (this._value !== this._obj.size) {
this.subs.notifyDirty();
}
}
public handleCollectionChange(_collection: Collection, _: IndexMap): void {

@@ -102,0 +115,0 @@ const oldValue = this._value;

@@ -143,2 +143,9 @@ import {

public handleDirty(): void {
if (!this._isDirty) {
this._isDirty = true;
this.subs.notifyDirty();
}
}
public handleChange(): void {

@@ -145,0 +152,0 @@ this._isDirty = true;

@@ -22,6 +22,10 @@ import { DI, IIndexable, isArray } from '@aurelia/kernel';

export interface IDirtySubscriber {
handleDirty(): void;
}
/**
* Interface of a subscriber or property change handler
*/
export interface ISubscriber<TValue = unknown> {
export interface ISubscriber<TValue = unknown> extends Partial<IDirtySubscriber> {
handleChange(newValue: TValue, previousValue: TValue): void;

@@ -57,2 +61,3 @@ }

notifyCollection(collection: Collection, indexMap: IndexMap): void;
notifyDirty(): void;
}

@@ -59,0 +64,0 @@

@@ -144,2 +144,4 @@ import { CollectionSizeObserver } from './collection-length-observer';

const subs = this.subs;
subs.notifyDirty();
const indexMap = this.indexMap;

@@ -146,0 +148,0 @@ if (batching) {

@@ -199,8 +199,9 @@ import { AccessorType, IAccessor, ISubscriberCollection, atObserver } from './interfaces';

this._value = value;
this.cb?.call(this._obj, this._value, this._oldValue);
// this._value might have been updated during the callback
// we only want to notify subscribers with the latest values
value = this._oldValue;
this._oldValue = this._value;
this.subs.notify(this._value, value);
this.subs.notifyDirty();
this.subs.notify(this._value, this._oldValue);
// if the value has been changed during the notify, don't call the callback
// it's the job of the last .setValue() to call the callback
if (areEqual(value, this._value)) {
this.cb?.call(this._obj, this._value, this._oldValue);
}
}

@@ -207,0 +208,0 @@ }

@@ -104,10 +104,2 @@ import { IIndexable } from '@aurelia/kernel';

// function disableSetObservation(): void {
// for (const method of methods) {
// if (proto[method].observing === true) {
// rtDef(proto, method, { ...descriptorProps, value: native[method] });
// }
// }
// }
interface SetObserverImpl extends SetObserver {}

@@ -126,2 +118,4 @@ class SetObserverImpl {

const subs = this.subs;
subs.notifyDirty();
const indexMap = this.indexMap;

@@ -137,3 +131,3 @@ if (batching) {

this.indexMap = createIndexMap(size);
this.subs.notifyCollection(set, indexMap);
subs.notifyCollection(set, indexMap);
}

@@ -140,0 +134,0 @@

@@ -63,4 +63,11 @@ import { ICoercionConfiguration, IObserver, InterceptorFunc, atObserver } from './interfaces';

this._value = newValue;
this._callback?.(newValue, oV);
this.subs.notifyDirty();
this.subs.notify(newValue, oV);
// only call the callback if _value is the same with newValue
// which means if during subs.notify() the value of this observer is changed
// then it's the job of that setValue() to call the callback
if (areEqual(newValue, this._value)) {
this._callback?.(newValue, oV);
}
} else {

@@ -67,0 +74,0 @@ // If subscribe() has been called, the target property descriptor is replaced by these getter/setter methods,

@@ -6,2 +6,3 @@ import { rtDef, rtDefineHiddenProp, ensureProto } from './utilities';

ICollectionSubscriber,
IDirtySubscriber,
IndexMap,

@@ -57,2 +58,6 @@ ISubscriber,

private readonly _subs: T[] = [];
/** @internal */
private readonly _requestDirtySubs: IDirtySubscriber[] = [];
/** @internal */
private _hasDirtySubs = false;

@@ -64,2 +69,6 @@ public add(subscriber: T): boolean {

this._subs[this._subs.length] = subscriber;
if ('handleDirty' in subscriber) {
this._requestDirtySubs[this._requestDirtySubs.length] = subscriber as IDirtySubscriber;
this._hasDirtySubs = true;
}
++this.count;

@@ -70,5 +79,10 @@ return true;

public remove(subscriber: T): boolean {
const idx = this._subs.indexOf(subscriber);
let idx = this._subs.indexOf(subscriber);
if (idx !== -1) {
this._subs.splice(idx, 1);
idx = this._requestDirtySubs.indexOf(subscriber as IDirtySubscriber);
if (idx !== -1) {
this._requestDirtySubs.splice(idx, 1);
this._hasDirtySubs = this._requestDirtySubs.length > 0;
}
--this.count;

@@ -85,2 +99,3 @@ return true;

}
/**

@@ -93,9 +108,5 @@ * Note: change handlers may have the side-effect of adding/removing subscribers to this collection during this

*/
const _subs = this._subs.slice(0) as ISubscriber[];
const len = _subs.length;
let i = 0;
for (; i < len; ++i) {
_subs[i].handleChange(val, oldVal);
for (const sub of this._subs.slice(0) as ISubscriber[]) {
sub.handleChange(val, oldVal);
}
return;
}

@@ -112,2 +123,10 @@

}
public notifyDirty() {
if (this._hasDirtySubs) {
for (const dirtySub of this._requestDirtySubs.slice(0)) {
dirtySub.handleDirty();
}
}
}
}

@@ -114,0 +133,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