Socket
Socket
Sign inDemoInstall

@agile-ts/core

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agile-ts/core - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

6

CHANGELOG.md
# Change Log
## 0.0.10
### Patch Changes
- 9a09652: fixted some bugs
## 0.0.9

@@ -4,0 +10,0 @@

20

dist/agile.d.ts

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

import { Runtime, Integration, State, Storage, Collection, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface } from './internal';
import { Runtime, Integration, State, Storage, Collection, CollectionConfig, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface } from './internal';
export declare class Agile {

@@ -21,3 +21,3 @@ config: AgileConfigInterface;

*/
Storage: (config: CreateStorageConfigInterface) => Storage;
createStorage(config: CreateStorageConfigInterface): Storage;
/**

@@ -29,3 +29,3 @@ * @public

*/
State: <ValueType>(initialValue: ValueType, config?: StateConfigInterface) => State<ValueType>;
createState<ValueType>(initialValue: ValueType, config?: StateConfigInterface): State<ValueType>;
/**

@@ -36,3 +36,3 @@ * @public

*/
Collection: <DataType = DefaultItem>(config?: import("./collection").CreateCollectionConfigInterface | ((collection: Collection<DataType>) => import("./collection").CreateCollectionConfigInterface) | undefined) => Collection<DataType>;
createCollection<DataType = DefaultItem>(config?: CollectionConfig<DataType>): Collection<DataType>;
/**

@@ -42,11 +42,19 @@ * @public

* @param computeFunction - Function for computing value
* @param config - Config
* @param deps - Hard coded dependencies of Computed Function
*/
Computed: <ComputedValueType = any>(computeFunction: () => ComputedValueType, deps?: (Observer<any> | State<any> | Event<DefaultEventPayload>)[] | undefined) => Computed<ComputedValueType>;
createComputed<ComputedValueType = any>(computeFunction: () => ComputedValueType, config?: StateConfigInterface, deps?: Array<Observer | State | Event>): Computed<ComputedValueType>;
/**
* @public
* Computed - Function that recomputes its value if a dependency changes
* @param computeFunction - Function for computing value
* @param deps - Hard coded dependencies of Computed Function
*/
createComputed<ComputedValueType = any>(computeFunction: () => ComputedValueType, deps?: Array<Observer | State | Event>): Computed<ComputedValueType>;
/**
* @public
* Event - Class that holds a List of Functions which can be triggered at the same time
* @param config - Config
*/
Event: <PayloadType = DefaultEventPayload>(config?: CreateEventConfigInterface | undefined) => Event<PayloadType>;
createEvent<PayloadType = DefaultEventPayload>(config?: CreateEventConfigInterface): Event<PayloadType>;
/**

@@ -53,0 +61,0 @@ * @public

@@ -12,51 +12,2 @@ "use strict";

constructor(config = {}) {
//=========================================================================================================
// Storage
//=========================================================================================================
/**
* @public
* Storage - Handy Interface for storing Items permanently
* @param config - Config
*/
this.Storage = (config) => new internal_1.Storage(config);
//=========================================================================================================
// State
//=========================================================================================================
/**
* @public
* State - Class that holds one Value and causes rerender on subscribed Components
* @param initialValue - Initial Value of the State
* @param config - Config
*/
this.State = (initialValue, config = {}) => new internal_1.State(this, initialValue, config);
//=========================================================================================================
// Collection
//=========================================================================================================
/**
* @public
* Collection - Class that holds a List of Objects with key and causes rerender on subscribed Components
* @param config - Config
*/
this.Collection = (config) => new internal_1.Collection(this, config);
//=========================================================================================================
// Computed
//=========================================================================================================
/**
* @public
* Computed - Function that recomputes its value if a dependency changes
* @param computeFunction - Function for computing value
* @param deps - Hard coded dependencies of Computed Function
*/
this.Computed = (computeFunction, deps) => new internal_1.Computed(this, computeFunction, {
computedDeps: deps,
});
//=========================================================================================================
// Event
//=========================================================================================================
/**
* @public
* Event - Class that holds a List of Functions which can be triggered at the same time
* @param config - Config
*/
this.Event = (config) => new internal_1.Event(this, config);
config = internal_1.defineConfig(config, {

@@ -85,2 +36,4 @@ localStorage: true,

Agile.logger = new internal_1.Logger(config.logConfig);
// Logging
Agile.logger.success('Created new AgileInstance ', this, Agile.logger);
// Create global instance of Agile

@@ -91,2 +44,62 @@ if (!internal_1.globalBind('__agile__', this))

//=========================================================================================================
// Storage
//=========================================================================================================
/**
* @public
* Storage - Handy Interface for storing Items permanently
* @param config - Config
*/
createStorage(config) {
return new internal_1.Storage(config);
}
//=========================================================================================================
// State
//=========================================================================================================
/**
* @public
* State - Class that holds one Value and causes rerender on subscribed Components
* @param initialValue - Initial Value of the State
* @param config - Config
*/
createState(initialValue, config = {}) {
return new internal_1.State(this, initialValue, config);
}
//=========================================================================================================
// Collection
//=========================================================================================================
/**
* @public
* Collection - Class that holds a List of Objects with key and causes rerender on subscribed Components
* @param config - Config
*/
createCollection(config) {
return new internal_1.Collection(this, config);
}
createComputed(computeFunction, configOrDeps, deps) {
let _deps;
let _config;
if (Array.isArray(configOrDeps)) {
_deps = configOrDeps;
_config = {};
}
else {
_config = configOrDeps || {};
_deps = deps || [];
}
return new internal_1.Computed(this, computeFunction, internal_1.flatMerge(_config, {
computedDeps: _deps,
}));
}
//=========================================================================================================
// Event
//=========================================================================================================
/**
* @public
* Event - Class that holds a List of Functions which can be triggered at the same time
* @param config - Config
*/
createEvent(config) {
return new internal_1.Event(this, config);
}
//=========================================================================================================
// Integrate

@@ -93,0 +106,0 @@ //=========================================================================================================

@@ -160,3 +160,3 @@ "use strict";

// Add sideEffect to default Group which adds and removes Items from the Storage depending on the Group Value
defaultGroup.addSideEffect(CollectionPersistent.defaultGroupSideEffectKey, () => this.rebuildStorageSideEffect(defaultGroup, _key));
defaultGroup.addSideEffect(CollectionPersistent.defaultGroupSideEffectKey, () => this.rebuildStorageSideEffect(defaultGroup, _key), { weight: 0 });
// Persist Collection Items

@@ -163,0 +163,0 @@ for (const itemKey of defaultGroup._value) {

@@ -286,4 +286,5 @@ import { Agile, Item, Group, GroupKey, Selector, SelectorKey, StorageKey, GroupConfigInterface, CollectionPersistent, GroupAddConfig } from '../internal';

* @param defaultGroupKey - Key/Name of Default Group that holds all collected Items
* @param initialData - Initial Data of Collection
*/
export interface CreateCollectionConfigInterface {
export interface CreateCollectionConfigInterface<DataType = DefaultItem> {
groups?: {

@@ -298,2 +299,3 @@ [key: string]: Group<any>;

defaultGroupKey?: ItemKey;
initialData?: Array<DataType>;
}

@@ -368,2 +370,2 @@ /**

}
export declare type CollectionConfig<DataType = DefaultItem> = CreateCollectionConfigInterface | ((collection: Collection<DataType>) => CreateCollectionConfigInterface);
export declare type CollectionConfig<DataType = DefaultItem> = CreateCollectionConfigInterface<DataType> | ((collection: Collection<DataType>) => CreateCollectionConfigInterface<DataType>);

@@ -40,2 +40,4 @@ "use strict";

this.initSelectors(_config.selectors);
if (_config.initialData)
this.collect(_config.initialData);
}

@@ -807,4 +809,9 @@ /**

if (createItem) {
// Create and assign Item to Collection
item = new internal_1.Item(this, _data);
this.data[itemKey] = item;
// Rebuild Groups That include ItemKey after assigning Item to Collection (otherwise it can't find Item)
this.rebuildGroupsThatIncludeItemKey(itemKey, {
background: config.background,
});
}

@@ -811,0 +818,0 @@ // Increase size of Collection

@@ -20,3 +20,9 @@ import { State, Collection, DefaultItem, StateKey, StateRuntimeJobConfigInterface } from '../internal';

*/
setKey(value: StateKey | undefined, config?: SetItemKeyConfig): this;
setKey(value: StateKey | undefined, config?: StateRuntimeJobConfigInterface): this;
/**
* @internal
* Adds rebuildGroupThatIncludeItemKey to the Item sideEffects
* @param itemKey - ItemKey at which the groups has to rebuild
*/
addRebuildGroupThatIncludeItemKeySideEffect(itemKey: StateKey): void;
}

@@ -29,7 +35,1 @@ /**

}
/**
* @param updateItemValuePrimaryKey - If the primaryKey in ItemValue gets update
*/
export interface SetItemKeyConfig extends StateRuntimeJobConfigInterface {
updateItemValuePrimaryKey?: boolean;
}

@@ -20,6 +20,4 @@ "use strict";

this.collection = () => collection;
// Reassign Key to assign sideEffects
this.setKey(data[collection.config.primaryKey], {
updateItemValuePrimaryKey: false,
});
// Add rebuildGroupsThatIncludeItemKey to sideEffects to rebuild Groups that include this Item if it mutates
this.addRebuildGroupThatIncludeItemKeySideEffect(this._key || 'unknown');
}

@@ -43,3 +41,2 @@ //=========================================================================================================

overwrite: false,
updateItemValuePrimaryKey: true,
});

@@ -50,24 +47,27 @@ if (!value)

this.removeSideEffect(Item.updateGroupSideEffectKey);
// Add rebuildGroupsThatIncludeItemKey to sideEffects to rebuild Groups that include this Item if it changes
this.addSideEffect(Item.updateGroupSideEffectKey, (config) => this.collection().rebuildGroupsThatIncludeItemKey(value, config));
// Add rebuildGroupsThatIncludeItemKey to sideEffects to rebuild Groups that include this Item if it mutates
this.addRebuildGroupThatIncludeItemKeySideEffect(value);
// Update ItemKey in ItemValue (After updating the sideEffect because otherwise it calls the old sideEffect)
if (config.updateItemValuePrimaryKey)
this.patch({ [this.collection().config.primaryKey]: value }, {
sideEffects: config.sideEffects,
background: config.background,
force: config.force,
storage: config.storage,
overwrite: config.overwrite,
});
// Initial Rebuild (not necessary if updating primaryKey in ItemValue because a sideEffect of the patch method is to rebuild the Group)
if (!config.updateItemValuePrimaryKey)
this.collection().rebuildGroupsThatIncludeItemKey(value, {
background: config.background,
force: config.force,
sideEffects: config.sideEffects,
});
this.patch({ [this.collection().config.primaryKey]: value }, {
sideEffects: config.sideEffects,
background: config.background,
force: config.force,
storage: config.storage,
overwrite: config.overwrite,
});
return this;
}
//=========================================================================================================
// Add Rebuild Group That Include ItemKey SideEffect
//=========================================================================================================
/**
* @internal
* Adds rebuildGroupThatIncludeItemKey to the Item sideEffects
* @param itemKey - ItemKey at which the groups has to rebuild
*/
addRebuildGroupThatIncludeItemKeySideEffect(itemKey) {
this.addSideEffect(Item.updateGroupSideEffectKey, (config) => this.collection().rebuildGroupsThatIncludeItemKey(itemKey, config), { weight: 100 });
}
}
exports.Item = Item;
Item.updateGroupSideEffectKey = 'rebuildGroup';

@@ -72,3 +72,3 @@ "use strict";

// Add SideEffect to newItem, that rebuild this Selector depending on the current Item Value
newItem.addSideEffect(Selector.rebuildSelectorSideEffectKey, (config) => this.rebuildSelector(config));
newItem.addSideEffect(Selector.rebuildSelectorSideEffectKey, (config) => this.rebuildSelector(config), { weight: 100 });
// Rebuild Selector for instantiating new 'selected' ItemKey properly

@@ -75,0 +75,0 @@ this.rebuildSelector(config);

@@ -50,3 +50,3 @@ "use strict";

// Logging
internal_1.Agile.logger.info(`Successfully integrated '${integration._key}'`);
internal_1.Agile.logger.success(`Integrated '${integration._key}' into AgileTs`);
return true;

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

@@ -26,2 +26,3 @@ export declare class Logger {

info: (...data: any[]) => void;
success: (...data: any[]) => void;
warn: (...data: any[]) => void;

@@ -43,2 +44,3 @@ error: (...data: any[]) => void;

INFO: number;
SUCCESS: number;
WARN: number;

@@ -61,2 +63,3 @@ ERROR: number;

info(...data: any[]): void;
success(...data: any[]): void;
warn(...data: any[]): void;

@@ -133,2 +136,3 @@ error(...data: any[]): void;

* @param level - Handles which Logger Categories can be Logged
* @param timestamp - Timestamp that ges written before each log of this Logger
*/

@@ -139,2 +143,3 @@ export interface LoggerConfigInterface {

level: number;
timestamp: boolean;
}

@@ -147,2 +152,3 @@ /**

* @param level - Handles which Logger Categories can be Logged
* @param timestamp - Timestamp that ges written before each log of this Logger
*/

@@ -155,2 +161,3 @@ export interface CreateLoggerConfigInterface {

level?: number;
timestamp?: boolean;
}

@@ -157,0 +164,0 @@ export declare type LoggerConfig = CreateLoggerConfigInterface | ((logger: Logger) => CreateLoggerConfigInterface);

@@ -21,2 +21,3 @@ "use strict";

level: 0,
timestamp: false,
});

@@ -26,2 +27,3 @@ this.isActive = _config.active;

this.config = {
timestamp: _config.timestamp,
prefix: _config.prefix,

@@ -53,2 +55,3 @@ canUseCustomStyles: _config.canUseCustomStyles,

INFO: 10,
SUCCESS: 15,
WARN: 20,

@@ -72,3 +75,3 @@ ERROR: 50,

key: 'debug',
customStyle: 'color: #3c3c3c;',
customStyle: 'color: #656565;',
prefix: 'Debug',

@@ -84,2 +87,8 @@ level: Logger.level.DEBUG,

this.createLoggerCategory({
key: 'success',
customStyle: 'color: #00b300;',
prefix: 'Success',
level: Logger.level.SUCCESS,
});
this.createLoggerCategory({
key: 'warn',

@@ -118,2 +127,3 @@ prefix: 'Warn',

info: (...data) => this.info(...data),
success: (...data) => this.success(...data),
warn: (...data) => this.warn(...data),

@@ -135,2 +145,5 @@ error: (...data) => this.error(...data),

},
success: () => {
/* do nothing */
},
warn: () => {

@@ -159,2 +172,5 @@ /* do nothing */

}
success(...data) {
this.invokeConsole(data, 'success', 'log');
}
warn(...data) {

@@ -193,2 +209,4 @@ this.invokeConsole(data, 'warn', typeof console.warn !== 'undefined' ? 'warn' : 'log');

let prefix = '';
if (this.config.timestamp)
prefix = prefix.concat(`[${Date.now().toString()}] `);
if (this.config.prefix)

@@ -195,0 +213,0 @@ prefix = prefix.concat(this.config.prefix);

@@ -92,2 +92,4 @@ "use strict";

// Subscriptions that has to be updated/rerendered
// 'Set' to combine several SubscriptionContainers that are equals into one (optimizes rerender)
// Better would be to optimize the rerender based on the Component, because a Component can have multiple SubscriptionContainers
const subscriptionsToUpdate = new Set();

@@ -158,10 +160,8 @@ // Build final jobsToRerender and reset jobsToRerender Instances

getObjectBasedProps(subscriptionContainer) {
var _a;
const props = {};
// Map trough observerKeysToUpdate and build object out of Observer value
subscriptionContainer.observerKeysToUpdate.forEach((updatedKey) => {
if (subscriptionContainer.subsObject &&
subscriptionContainer.subsObject[updatedKey]['value'])
props[updatedKey] =
subscriptionContainer.subsObject[updatedKey]['value'];
});
if (subscriptionContainer.subsObject)
for (const updatedKey of subscriptionContainer.observerKeysToUpdate)
props[updatedKey] = (_a = subscriptionContainer.subsObject[updatedKey]) === null || _a === void 0 ? void 0 : _a.value;
subscriptionContainer.observerKeysToUpdate = [];

@@ -168,0 +168,0 @@ return props;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionContainer = void 0;
const internal_1 = require("../../../internal");
class SubscriptionContainer {

@@ -18,5 +19,5 @@ /**

this.subs = new Set(subs);
this.key = key;
this.key = key || internal_1.generateId();
}
}
exports.SubscriptionContainer = SubscriptionContainer;

@@ -52,3 +52,5 @@ import { Agile, Observer, SubscriptionContainer, ComponentSubscriptionContainer, CallbackSubscriptionContainer, SubscriptionContainerKeyType } from '../../internal';

* @internal
* Registers Component based Subscription
* Registers Component based Subscription and applies SubscriptionContainer to Component.
* If an instance called 'subscriptionContainers' exists in Component it will push the new SubscriptionContainer to this Array,
* otherwise it creates a new Instance called 'subscriptionContainer' which holds the new SubscriptionContainer
* @param componentInstance - Component that got subscribed by Observer/s

@@ -55,0 +57,0 @@ * @param subs - Initial Subscriptions

@@ -90,3 +90,3 @@ "use strict";

internal_1.Agile.logger.if
.tag(['core', 'subscription'])
.tag(['runtime', 'subscription'])
.info('Unregistered Callback based Subscription ', subscriptionInstance);

@@ -101,3 +101,3 @@ return;

internal_1.Agile.logger.if
.tag(['core', 'subscription'])
.tag(['runtime', 'subscription'])
.info('Unregistered Component based Subscription ', subscriptionInstance);

@@ -112,6 +112,24 @@ return;

internal_1.Agile.logger.if
.tag(['core', 'subscription'])
.tag(['runtime', 'subscription'])
.info('Unregistered Component based Subscription ', subscriptionInstance);
return;
}
// Unsubscribe component based Subscription with subscriptionInstance that holds componentSubscriptionContainers
if (subscriptionInstance.componentSubscriptionContainers &&
Array.isArray(subscriptionInstance.componentSubscriptionContainers)) {
subscriptionInstance.componentSubscriptionContainers.forEach((subContainer) => {
unsub(subContainer);
this.componentSubs.delete(subContainer);
// Logging
internal_1.Agile.logger.if
.tag(['runtime', 'subscription'])
.info('Unregistered Component based Subscription ', subscriptionInstance);
});
return;
}
// Logging
internal_1.Agile.logger.if
.tag(['runtime', 'subscription'])
.warn(`Couldn't find anything to unregister in `, subscriptionInstance);
return;
}

@@ -138,3 +156,5 @@ //=========================================================================================================

* @internal
* Registers Component based Subscription
* Registers Component based Subscription and applies SubscriptionContainer to Component.
* If an instance called 'subscriptionContainers' exists in Component it will push the new SubscriptionContainer to this Array,
* otherwise it creates a new Instance called 'subscriptionContainer' which holds the new SubscriptionContainer
* @param componentInstance - Component that got subscribed by Observer/s

@@ -154,7 +174,11 @@ * @param subs - Initial Subscriptions

componentSubscriptionContainer.ready = true;
// To have an instance of the SubscriptionContainer in the Component (necessary to unsubscribe component later)
componentInstance.componentSubscriptionContainer = componentSubscriptionContainer;
// Add subscriptionContainer to Component, to have an instance of it there (necessary to unsubscribe SubscriptionContainer later)
if (componentInstance.componentSubscriptionContainers &&
Array.isArray(componentInstance.componentSubscriptionContainers))
componentInstance.componentSubscriptionContainers.push(componentSubscriptionContainer);
else
componentInstance.componentSubscriptionContainer = componentSubscriptionContainer;
// Logging
internal_1.Agile.logger.if
.tag(['core', 'subscription'])
.tag(['runtime', 'subscription'])
.info('Registered Component based Subscription ', componentSubscriptionContainer);

@@ -179,3 +203,3 @@ return componentSubscriptionContainer;

internal_1.Agile.logger.if
.tag(['core', 'subscription'])
.tag(['runtime', 'subscription'])
.info('Registered Callback based Subscription ', callbackSubscriptionContainer);

@@ -182,0 +206,0 @@ return callbackSubscriptionContainer;

@@ -14,5 +14,3 @@ import { Agile, StorageKey, StateObserver, StatePersistent, Observer, PersistentKey, StateIngestConfigInterface, StateRuntimeJobConfigInterface } from '../internal';

sideEffects: {
[key: string]: (properties?: {
[key: string]: any;
}) => void;
[key: string]: SideEffectInterface;
};

@@ -98,3 +96,3 @@ computeMethod?: ComputeMethod<ValueType>;

*/
patch(targetWithChanges: object, config?: PatchConfigInterface): this;
patch(targetWithChanges: Object, config?: PatchConfigInterface): this;
/**

@@ -190,7 +188,6 @@ * @public

* @param key - Key/Name of SideEffect
* @param sideEffect - Callback Function that gets called on every State Value change
* @param callback - Callback Function that gets called on every State Value change
* @param config - Config
*/
addSideEffect(key: string, sideEffect: (properties?: {
[key: string]: any;
}) => void): this;
addSideEffect(key: string, callback: SideEffectFunctionType, config?: AddSideEffectConfigInterface): this;
/**

@@ -253,1 +250,18 @@ * @internal

export declare type ComputeMethod<T = any> = (value: T) => T;
export declare type SideEffectFunctionType = (properties?: {
[key: string]: any;
}) => void;
/**
* @param callback - Callback Function that gets called on every State Value change
* @param weight - When the sideEffect gets executed. The higher, the earlier it gets executed.
*/
export interface SideEffectInterface {
callback: SideEffectFunctionType;
weight: number;
}
/**
* @param weight - When the sideEffect gets executed. The higher, the earlier it gets executed.
*/
export interface AddSideEffectConfigInterface {
weight?: number;
}

@@ -399,10 +399,17 @@ "use strict";

* @param key - Key/Name of SideEffect
* @param sideEffect - Callback Function that gets called on every State Value change
* @param callback - Callback Function that gets called on every State Value change
* @param config - Config
*/
addSideEffect(key, sideEffect) {
if (!internal_1.isFunction(sideEffect)) {
addSideEffect(key, callback, config = {}) {
config = internal_1.defineConfig(config, {
weight: 10,
});
if (!internal_1.isFunction(callback)) {
internal_1.Agile.logger.error('A sideEffect function has to be a function!');
return this;
}
this.sideEffects[key] = sideEffect;
this.sideEffects[key] = {
callback: callback,
weight: config.weight,
};
return this;

@@ -409,0 +416,0 @@ }

@@ -92,3 +92,2 @@ "use strict";

state.nextStateValue = internal_1.copy(job.observer.nextStateValue);
job.observer.value = internal_1.copy(job.observer.nextStateValue);
// Overwrite old State Values

@@ -102,2 +101,6 @@ if (job.config.overwrite) {

this.sideEffects(job);
// Assign Public Value to Observer after sideEffects like 'rebuildGroup',
// because sometimes (for instance in Group) the publicValue is not the value(nextStateValue)
// and the observer value is at some point the publicValue because the end user uses it
job.observer.value = internal_1.copy(state.getPublicValue());
}

@@ -120,6 +123,11 @@ //=========================================================================================================

// Call SideEffect Functions
if ((_a = job.config) === null || _a === void 0 ? void 0 : _a.sideEffects)
for (const sideEffectKey in state.sideEffects)
if (internal_1.isFunction(state.sideEffects[sideEffectKey]))
state.sideEffects[sideEffectKey](job.config);
if ((_a = job.config) === null || _a === void 0 ? void 0 : _a.sideEffects) {
const sideEffectArray = internal_1.createArrayFromObject(state.sideEffects);
sideEffectArray.sort(function (a, b) {
return b.instance.weight - a.instance.weight;
});
for (const sideEffect of sideEffectArray)
if (internal_1.isFunction(sideEffect.instance.callback))
sideEffect.instance.callback(job.config);
}
// Ingest Dependencies of Observer into Runtime

@@ -126,0 +134,0 @@ state.observer.deps.forEach((observer) => observer instanceof StateObserver && observer.ingest({ perform: false }));

@@ -125,3 +125,3 @@ "use strict";

this.rebuildStorageSideEffect(this.state(), _key, config);
});
}, { weight: 0 });
// Rebuild Storage for saving State Value in the Storage

@@ -128,0 +128,0 @@ this.rebuildStorageSideEffect(this.state(), _key);

@@ -81,3 +81,4 @@ import { Agile } from './internal';

* @internal
* Merges items into object, be aware that the merge will only happen at the top level of the object
* Merges items into object, be aware that the merge will only happen at the top level of the object.
* Initially it adds new properties of the changes object into the source object.
* @param source - Source object

@@ -110,2 +111,13 @@ * @param changes - Changes that get merged into the source object

* @internal
* Transforms Object to Array
* @param object - Object that gets transformed
*/
export declare function createArrayFromObject<P = any>(object: {
[key: string]: P;
}): Array<{
key: string;
instance: P;
}>;
/**
* @internal
* Clones a Class

@@ -112,0 +124,0 @@ * @param instance - Instance of Class you want to clone

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.globalBind = exports.clone = exports.generateId = exports.notEqual = exports.equal = exports.flatMerge = exports.defineConfig = exports.isJsonString = exports.isValidUrl = exports.isAsyncFunction = exports.isFunction = exports.getAgileInstance = exports.normalizeArray = exports.includesArray = exports.isValidObject = exports.copy = void 0;
exports.globalBind = exports.clone = exports.createArrayFromObject = exports.generateId = exports.notEqual = exports.equal = exports.flatMerge = exports.defineConfig = exports.isJsonString = exports.isValidUrl = exports.isAsyncFunction = exports.isFunction = exports.getAgileInstance = exports.normalizeArray = exports.includesArray = exports.isValidObject = exports.copy = void 0;
const internal_1 = require("./internal");

@@ -204,3 +204,4 @@ //=========================================================================================================

* @internal
* Merges items into object, be aware that the merge will only happen at the top level of the object
* Merges items into object, be aware that the merge will only happen at the top level of the object.
* Initially it adds new properties of the changes object into the source object.
* @param source - Source object

@@ -211,7 +212,10 @@ * @param changes - Changes that get merged into the source object

function flatMerge(source, changes, config = {}) {
// Copy Source to avoid references
config = defineConfig(config, {
addNewProperties: true,
});
// Copy Source to avoid References
const _source = copy(source);
if (!_source)
return _source;
// Loop through source object an merge changes into it
// Merge Changes Object into Source Object
const keys = Object.keys(changes);

@@ -273,2 +277,21 @@ keys.forEach((property) => {

//=========================================================================================================
// Create Array From Object
//=========================================================================================================
/**
* @internal
* Transforms Object to Array
* @param object - Object that gets transformed
*/
function createArrayFromObject(object) {
const array = [];
for (const key in object) {
array.push({
key: key,
instance: object[key],
});
}
return array;
}
exports.createArrayFromObject = createArrayFromObject;
//=========================================================================================================
// Clone

@@ -285,3 +308,3 @@ //=========================================================================================================

const objectClone = Object.assign(objectCopy, instance);
// Copy Properties of Class
// Copy Properties of Class to remove flat references
for (const key in objectClone)

@@ -288,0 +311,0 @@ objectClone[key] = copy(objectClone[key]);

{
"name": "@agile-ts/core",
"version": "0.0.9",
"version": "0.0.10",
"author": "BennoDev",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -8,5 +8,5 @@ <img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/header_background.png" alt="AgileTs">

<a href="https://github.com/agile-ts/agile">
<img src="https://img.shields.io/github/license/agile-ts/agile.svg" alt="GitHub License"/></a>
<img src="https://img.shields.io/github/license/agile-ts/agile.svg?label=license&style=flat&colorA=293140&colorB=4a4872" alt="GitHub License"/></a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/core.svg" alt="npm minified size"/></a>
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/core.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>

@@ -16,6 +16,6 @@ <br />

<a href="https://github.com/agile-ts/agile/actions?query=workflow%3ARelease">
<img src="https://github.com/agile-ts/agile/workflows/Release/badge.svg?style=flat-square" alt="Build Status"/></a>
<img src="https://github.com/agile-ts/agile/workflows/Release/badge.svg" alt="Build Status"/></a>
<a href="https://github.com/agile-ts/agile/actions?query=workflow%3A%22Test+All+Packages%22">
<img src="https://github.com/agile-ts/agile/workflows/Test%20All%20Packages/badge.svg" alt="Build Status"/></a>
<a href="https://codeclimate.com/github/agile-ts/agile/coverage">
<a href="https://codeclimate.com/github/agile-ts/agile/coverage.svg">
<img src="https://codeclimate.com/github/agile-ts/agile/badges/gpa.svg" alt="Maintainability"/></a>

@@ -26,8 +26,7 @@

<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/npm/dm/@agile-ts/core.svg" alt="npm monthly downloads"/></a>
<img src="https://img.shields.io/npm/dm/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm monthly downloads"/></a>
<a href="https://npm.im/@agile-ts/core">
<img src="https://img.shields.io/npm/dt/@agile-ts/core.svg" alt="npm total downloads"/></a>
<img src="https://img.shields.io/npm/dt/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
<br />

@@ -45,12 +44,13 @@

// Than we can build our first State
const MY_FIRST_STATE = App.State("Hello Stranger!");
// Now we are able to build our first State πŸ˜ƒ
const MY_FIRST_STATE = App.createState("Hello Stranger!");
// -- myComponent.whatever ------------------------------------------
// Now we are able to bind our State to nearly any UI-Component
// Finally, we bind our just created State to our desired UI-Component
// And wolla its reactive. Everytime the State mutates the Component gets rerendered
const myFirstState = useAgile(MY_FIRST_STATE); // returns value of State ("Hello Stranger!")
```
To find out more checkout our [documentation](https://agile-ts.org/docs).
To find out more checkout our [documentation](https://agile-ts.org/docs/installation).

@@ -91,3 +91,3 @@ ### ⛳️ Sandbox

### πŸ€Έβ€ Flexible
- Works in nearly every UI-Framework. Check [here](https://agile-ts.org/docs/frameworks) if the Framework you are using is supported, too.
- Works in nearly every UI-Framework. Check [here](https://agile-ts.org/docs/installation) if your desired framework is supported, too.
- Surly behaves with the workflow that suits you best.

@@ -104,2 +104,3 @@ No need for _reducers_, _actions_, ..

A good place to start is in our [documentation](https://agile-ts.org/docs).
And I'm sure you'll be able to use AgileTs very soon.

@@ -117,5 +118,5 @@ ### πŸƒ Lightweight

To use AgileTs properly, in an UI-Framework we have to install **2** packages.
To properly use AgileTs, in an UI-Framework we need **two** packages.
- The _Core Package_, which is the brain of AgileTs and handles your States, Collections, ..
- The _Core Package_, which acts as the brain of AgileTs and manages all our States
```

@@ -125,4 +126,4 @@ npm install @agile-ts/core

- A _fitting integration_ for the UI-Framework you are using.. in my case [React](https://www.npmjs.com/package/@agile-ts/react).
Check [here](https://agile-ts/docs/framework) your Framework is supported, too.
- And a _fitting Integration_ for our preferd UI-Framework.. in my case [React](https://www.npmjs.com/package/@agile-ts/react).
Check [here](https://agile-ts.org/docs/installation) if your desired Framework is supported, too.
```

@@ -151,3 +152,5 @@ npm install @agile-ts/react

Get a part of AgileTs and start contributing. To find out more read the [CONTRIBUTING.md](https://github.com/agile-ts/agile/blob/master/CONTRIBUTING.md).
Get a part of AgileTs and start contributing.
To find out more checkout the [CONTRIBUTING.md](https://github.com/agile-ts/agile/blob/master/CONTRIBUTING.md).
We welcome any meaningful contribution πŸ˜€

@@ -154,0 +157,0 @@

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