@agile-ts/core
Advanced tools
Comparing version 0.1.0 to 0.1.1
# Change Log | ||
## 0.1.1 | ||
### Patch Changes | ||
- cef61b6: #### :rocket: New Feature | ||
- `react` | ||
- [#171](https://github.com/agile-ts/agile/pull/171) Add deps array to useAgile() hook ([@bennodev19](https://github.com/bennodev19)) | ||
- `core`, `event`, `react`, `vue` | ||
- [#166](https://github.com/agile-ts/agile/pull/166) Shared Agile Instance ([@bennodev19](https://github.com/bennodev19)) | ||
#### :nail_care: Polish | ||
- `api`, `core`, `event`, `logger`, `multieditor`, `react`, `utils` | ||
- [#168](https://github.com/agile-ts/agile/pull/168) Performance optimization ([@bennodev19](https://github.com/bennodev19)) | ||
- `core`, `event`, `react`, `vue` | ||
- [#166](https://github.com/agile-ts/agile/pull/166) Shared Agile Instance ([@bennodev19](https://github.com/bennodev19)) | ||
#### Committers: 1 | ||
- BennoDev ([@bennodev19](https://github.com/bennodev19)) | ||
- Updated dependencies [cef61b6] | ||
- @agile-ts/logger@0.0.6 | ||
- @agile-ts/utils@0.0.6 | ||
## 0.1.0 | ||
@@ -4,0 +30,0 @@ |
@@ -1,4 +0,5 @@ | ||
import { Runtime, Integration, State, Storage, Collection, CollectionConfig, DefaultItem, Computed, Integrations, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface, DependableAgileInstancesType, CreateComputedConfigInterface, ComputeFunctionType } from './internal'; | ||
import { Runtime, Integration, State, Storage, Collection, CollectionConfig, DefaultItem, Computed, Integrations, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, StateConfigInterface, DependableAgileInstancesType, CreateComputedConfigInterface, ComputeFunctionType, IntegrationsConfigInterface } from './internal'; | ||
export declare class Agile { | ||
config: AgileConfigInterface; | ||
key?: AgileKey; | ||
runtime: Runtime; | ||
@@ -8,4 +9,2 @@ subController: SubController; | ||
integrations: Integrations; | ||
static initialIntegrations: Integration[]; | ||
static logger: Logger; | ||
static globalKey: string; | ||
@@ -174,15 +173,5 @@ /** | ||
} | ||
export interface CreateAgileConfigInterface { | ||
export declare type AgileKey = string | number; | ||
export interface CreateAgileConfigInterface extends IntegrationsConfigInterface { | ||
/** | ||
* Configures the logging behaviour of AgileTs. | ||
* @default { | ||
prefix: 'Agile', | ||
active: true, | ||
level: Logger.level.WARN, | ||
canUseCustomStyles: true, | ||
allowedTags: ['runtime', 'storage', 'subscription', 'multieditor'], | ||
} | ||
*/ | ||
logConfig?: CreateLoggerConfigInterface; | ||
/** | ||
* Whether the Subscription Container shouldn't be ready | ||
@@ -195,3 +184,3 @@ * until the UI-Component it represents has been mounted. | ||
* Whether the Local Storage should be registered as a Agile Storage by default. | ||
* @default true | ||
* @default false | ||
*/ | ||
@@ -205,2 +194,16 @@ localStorage?: boolean; | ||
bindGlobal?: boolean; | ||
/** | ||
* Key/Name identifier of the Agile Instance. | ||
* @default undefined | ||
*/ | ||
key?: AgileKey; | ||
/** | ||
* Whether to put render events into "The bucket" of the browser, | ||
* where all events are first put in wait for the UI thread | ||
* to be done with whatever it's doing. | ||
* | ||
* [Learn more..](https://stackoverflow.com/questions/9083594/call-settimeout-without-delay) | ||
* @default true | ||
*/ | ||
bucket?: boolean; | ||
} | ||
@@ -214,2 +217,11 @@ export interface AgileConfigInterface { | ||
waitForMount: boolean; | ||
/** | ||
* Whether to put render events into "The bucket" of the browser, | ||
* where all events are first put in wait for the UI thread | ||
* to be done with whatever it's doing. | ||
* | ||
* [Learn more..](https://stackoverflow.com/questions/9083594/call-settimeout-without-delay) | ||
* @default true | ||
*/ | ||
bucket: boolean; | ||
} |
@@ -7,19 +7,11 @@ "use strict"; | ||
constructor(config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
localStorage: true, | ||
waitForMount: true, | ||
logConfig: {}, | ||
bindGlobal: false, | ||
}); | ||
config.logConfig = internal_1.defineConfig(config.logConfig, { | ||
prefix: 'Agile', | ||
active: true, | ||
level: internal_1.Logger.level.WARN, | ||
canUseCustomStyles: true, | ||
allowedTags: ['runtime', 'storage', 'subscription', 'multieditor'], | ||
}); | ||
config = Object.assign({ localStorage: false, waitForMount: true, bindGlobal: false, autoIntegrate: true, bucket: true }, config); | ||
this.config = { | ||
waitForMount: config.waitForMount, | ||
bucket: config.bucket, | ||
}; | ||
this.integrations = new internal_1.Integrations(this); | ||
this.key = config.key; | ||
this.integrations = new internal_1.Integrations(this, { | ||
autoIntegrate: config.autoIntegrate, | ||
}); | ||
this.runtime = new internal_1.Runtime(this); | ||
@@ -30,16 +22,16 @@ this.subController = new internal_1.SubController(this); | ||
}); | ||
Agile.logger = new internal_1.Logger(config.logConfig); | ||
internal_1.LogCodeManager.log('10:00:00', [], this, Agile.logger); | ||
internal_1.LogCodeManager.log('10:00:00', [], this); | ||
if (config.bindGlobal) | ||
if (!internal_1.globalBind(Agile.globalKey, this)) | ||
if (!internal_1.globalBind(Agile.globalKey, this)) { | ||
internal_1.LogCodeManager.log('10:02:00'); | ||
} | ||
} | ||
createStorage(config) { | ||
return new internal_1.Storage(config); | ||
return internal_1.createStorage(config); | ||
} | ||
createState(initialValue, config = {}) { | ||
return new internal_1.State(this, initialValue, config); | ||
return internal_1.createState(initialValue, Object.assign(Object.assign({}, config), { agileInstance: this })); | ||
} | ||
createCollection(config) { | ||
return new internal_1.Collection(this, config); | ||
return internal_1.createCollection(config, this); | ||
} | ||
@@ -51,2 +43,3 @@ createComputed(computeFunction, configOrDeps) { | ||
computedDeps: configOrDeps, | ||
agileInstance: this, | ||
}); | ||
@@ -56,5 +49,5 @@ } | ||
if (configOrDeps) | ||
_config = configOrDeps; | ||
_config = Object.assign(Object.assign({}, configOrDeps), { agileInstance: this }); | ||
} | ||
return new internal_1.Computed(this, computeFunction, _config); | ||
return internal_1.createComputed(computeFunction, _config); | ||
} | ||
@@ -77,8 +70,2 @@ integrate(integration) { | ||
exports.Agile = Agile; | ||
Agile.initialIntegrations = []; | ||
Agile.logger = new internal_1.Logger({ | ||
prefix: 'Agile', | ||
active: true, | ||
level: internal_1.Logger.level.WARN, | ||
}); | ||
Agile.globalKey = '__agile__'; |
@@ -19,7 +19,3 @@ "use strict"; | ||
}); | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
this.collection = () => collection; | ||
@@ -80,3 +76,3 @@ this.instantiatePersistent({ | ||
loadValue: false, | ||
defaultStorageKey: this.config.defaultStorageKey || undefined, | ||
defaultStorageKey: this.config.defaultStorageKey, | ||
storageKeys: this.storageKeys, | ||
@@ -83,0 +79,0 @@ followCollectionPersistKeyPattern: false, |
@@ -17,12 +17,6 @@ "use strict"; | ||
const group = this.group(); | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
}, force: false, maxTriesToUpdate: 3 }, config); | ||
if (group.isPlaceholder) { | ||
@@ -29,0 +23,0 @@ config.force = true; |
@@ -61,6 +61,3 @@ "use strict"; | ||
let newGroupValue = internal_1.copy(this.nextStateValue); | ||
config = internal_1.defineConfig(config, { | ||
method: 'push', | ||
overwrite: false, | ||
}); | ||
config = Object.assign({ method: 'push', overwrite: false }, config); | ||
_itemKeys.forEach((itemKey) => { | ||
@@ -110,8 +107,3 @@ if (!this.collection().getItem(itemKey)) | ||
} | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
followCollectionPersistKeyPattern: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
_config = Object.assign({ loadValue: true, followCollectionPersistKeyPattern: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
if (_config.followCollectionPersistKeyPattern) { | ||
@@ -118,0 +110,0 @@ key = internal_1.CollectionPersistent.getGroupStorageKey(key || this._key, this.collection()._key); |
@@ -15,8 +15,3 @@ "use strict"; | ||
let _config = typeof config === 'function' ? config(this) : config; | ||
_config = internal_1.defineConfig(_config, { | ||
primaryKey: 'id', | ||
groups: {}, | ||
selectors: {}, | ||
defaultGroupKey: 'default', | ||
}); | ||
_config = Object.assign({ primaryKey: 'id', groups: {}, selectors: {}, defaultGroupKey: 'default' }, _config); | ||
this._key = _config.key; | ||
@@ -112,8 +107,3 @@ this.config = { | ||
const primaryKey = this.config.primaryKey; | ||
config = internal_1.defineConfig(config, { | ||
method: 'push', | ||
background: false, | ||
patch: false, | ||
select: false, | ||
}); | ||
config = Object.assign({ method: 'push', background: false, patch: false, select: false }, config); | ||
if (!_groupKeys.includes(defaultGroupKey)) | ||
@@ -157,6 +147,3 @@ _groupKeys.push(defaultGroupKey); | ||
const primaryKey = this.config.primaryKey; | ||
config = internal_1.defineConfig(config, { | ||
patch: true, | ||
background: false, | ||
}); | ||
config = Object.assign({ patch: true, background: false }, config); | ||
if (item == null) { | ||
@@ -180,5 +167,3 @@ internal_1.LogCodeManager.log('1B:03:00', [itemKey, this._key]); | ||
let patchConfig = typeof config.patch === 'object' ? config.patch : {}; | ||
patchConfig = internal_1.defineConfig(patchConfig, { | ||
addNewProperties: true, | ||
}); | ||
patchConfig = Object.assign({ addNewProperties: true }, patchConfig); | ||
item.patch(changes, { | ||
@@ -220,5 +205,3 @@ background: config.background, | ||
getGroup(groupKey, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
config = Object.assign({ notExisting: false }, config); | ||
const group = groupKey ? this.groups[groupKey] : undefined; | ||
@@ -280,5 +263,3 @@ if (group == null || (!config.notExisting && !group.exists)) | ||
getSelector(selectorKey, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
config = Object.assign({ notExisting: false }, config); | ||
const selector = selectorKey ? this.selectors[selectorKey] : undefined; | ||
@@ -318,5 +299,3 @@ if (selector == null || (!config.notExisting && !selector.exists)) | ||
getItem(itemKey, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
config = Object.assign({ notExisting: false }, config); | ||
const item = itemKey != null ? this.data[itemKey] : undefined; | ||
@@ -353,5 +332,3 @@ if (item == null || (!config.notExisting && !item.exists)) | ||
getAllItems(config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
}); | ||
config = Object.assign({ notExisting: false }, config); | ||
const defaultGroup = this.getDefaultGroup(); | ||
@@ -383,7 +360,3 @@ let items = []; | ||
} | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
_config = Object.assign({ loadValue: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
if (this.persistent != null && this.isPersisted) | ||
@@ -440,5 +413,3 @@ return this; | ||
const item = this.getItem(oldItemKey, { notExisting: true }); | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
}); | ||
config = Object.assign({ background: false }, config); | ||
if (item == null || oldItemKey === newItemKey) | ||
@@ -516,6 +487,3 @@ return false; | ||
removeItems(itemKeys, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
notExisting: false, | ||
removeSelector: false, | ||
}); | ||
config = Object.assign({ notExisting: false, removeSelector: false }, config); | ||
const _itemKeys = internal_1.normalizeArray(itemKeys); | ||
@@ -552,6 +520,3 @@ _itemKeys.forEach((itemKey) => { | ||
assignData(data, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
patch: false, | ||
background: false, | ||
}); | ||
config = Object.assign({ patch: false, background: false }, config); | ||
const _data = internal_1.copy(data); | ||
@@ -588,6 +553,3 @@ const primaryKey = this.config.primaryKey; | ||
assignItem(item, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
overwrite: false, | ||
background: false, | ||
}); | ||
config = Object.assign({ overwrite: false, background: false }, config); | ||
const primaryKey = this.config.primaryKey; | ||
@@ -623,9 +585,6 @@ let itemKey = item._value[primaryKey]; | ||
rebuildGroupsThatIncludeItemKey(itemKey, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
}); | ||
} }, config); | ||
for (const groupKey in this.groups) { | ||
@@ -632,0 +591,0 @@ const group = this.getGroup(groupKey); |
@@ -19,12 +19,6 @@ "use strict"; | ||
super.setKey(value); | ||
config = internal_1.defineConfig(config, { | ||
sideEffects: { | ||
config = Object.assign({ sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
background: false, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
}); | ||
}, background: false, force: false, storage: true, overwrite: false }, config); | ||
if (value == null) | ||
@@ -48,8 +42,3 @@ return this; | ||
} | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
followCollectionPersistKeyPattern: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
_config = Object.assign({ loadValue: true, followCollectionPersistKeyPattern: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
if (_config.followCollectionPersistKeyPattern) { | ||
@@ -56,0 +45,0 @@ key = internal_1.CollectionPersistent.getItemStorageKey(key || this._key, this.collection()._key); |
@@ -7,5 +7,3 @@ "use strict"; | ||
constructor(collection, itemKey, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
isPlaceholder: false, | ||
}); | ||
config = Object.assign({ isPlaceholder: false }, config); | ||
super(collection.agileInstance(), null, config); | ||
@@ -35,12 +33,6 @@ this.collection = () => collection; | ||
var _a, _b; | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
overwrite: (_b = (_a = this._item) === null || _a === void 0 ? void 0 : _a.isPlaceholder) !== null && _b !== void 0 ? _b : false, | ||
storage: true, | ||
}); | ||
}, force: false, overwrite: (_b = (_a = this._item) === null || _a === void 0 ? void 0 : _a.isPlaceholder) !== null && _b !== void 0 ? _b : false, storage: true }, config); | ||
if ((!this.collection().isInstantiated || this.hasSelected(itemKey)) && | ||
@@ -84,4 +76,3 @@ !config.force) | ||
item.removeSideEffect(Selector.rebuildItemSideEffectKey); | ||
if (item.isPlaceholder && | ||
this._itemKey != null) | ||
if (item.isPlaceholder && this._itemKey != null) | ||
delete this.collection().data[this._itemKey]; | ||
@@ -88,0 +79,0 @@ } |
@@ -22,6 +22,3 @@ "use strict"; | ||
this.hardCodedDeps = []; | ||
config = internal_1.defineConfig(config, { | ||
computedDeps: [], | ||
autodetect: !internal_1.isAsyncFunction(computeFunction), | ||
}); | ||
config = Object.assign({ computedDeps: [], autodetect: !internal_1.isAsyncFunction(computeFunction) }, config); | ||
this.agileInstance = () => agileInstance; | ||
@@ -40,5 +37,3 @@ this.computeFunction = computeFunction; | ||
recompute(config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
autodetect: false, | ||
}); | ||
config = Object.assign({ autodetect: false }, config); | ||
this.compute({ autodetect: config.autodetect }).then((result) => { | ||
@@ -50,5 +45,3 @@ this.observers['value'].ingestValue(result, internal_1.removeProperties(config, ['autodetect'])); | ||
updateComputeFunction(computeFunction, deps = [], config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
autodetect: this.config.autodetect, | ||
}); | ||
config = Object.assign({ autodetect: this.config.autodetect }, config); | ||
this.deps.forEach((observer) => { | ||
@@ -68,5 +61,3 @@ observer.removeDependent(this.observers['value']); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
config = internal_1.defineConfig(config, { | ||
autodetect: this.config.autodetect, | ||
}); | ||
config = Object.assign({ autodetect: this.config.autodetect }, config); | ||
if (config.autodetect) | ||
@@ -73,0 +64,0 @@ internal_1.ComputedTracker.track(); |
@@ -5,3 +5,18 @@ import { Agile, Integration } from '../internal'; | ||
integrations: Set<Integration>; | ||
static initialIntegrations: Integration[]; | ||
/** | ||
* Registers the specified Integration in each existing or not-yet created Agile Instance. | ||
* | ||
* @public | ||
* @param integration - Integration to be registered in each Agile Instance. | ||
*/ | ||
static addInitialIntegration(integration: Integration): void; | ||
/** | ||
* Fires on each external added Integration. | ||
* | ||
* @public | ||
* @param callback - Callback to be fired when an Integration was externally added. | ||
*/ | ||
static onRegisterInitialIntegration(callback: (integration: Integration) => void): void; | ||
/** | ||
* The Integrations Class manages all Integrations for an Agile Instance | ||
@@ -13,4 +28,5 @@ * and provides an interface to easily update | ||
* @param agileInstance - Instance of Agile the Integrations belongs to. | ||
* @param config - Configuration object | ||
*/ | ||
constructor(agileInstance: Agile); | ||
constructor(agileInstance: Agile, config?: IntegrationsConfigInterface); | ||
/** | ||
@@ -44,1 +60,11 @@ * Integrates the specified Integration into AgileTs | ||
} | ||
export interface IntegrationsConfigInterface { | ||
/** | ||
* Whether external added Integrations | ||
* are to integrate automatically into the Integrations Class. | ||
* For example, when the package '@agile-ts/react' was installed, | ||
* whether to automatically integrate the 'reactIntegration'. | ||
* @default true | ||
*/ | ||
autoIntegrate?: boolean; | ||
} |
@@ -14,12 +14,30 @@ "use strict"; | ||
const internal_1 = require("../internal"); | ||
const onRegisterInitialIntegrationCallbacks = []; | ||
class Integrations { | ||
constructor(agileInstance) { | ||
constructor(agileInstance, config = {}) { | ||
this.integrations = new Set(); | ||
config = Object.assign({ autoIntegrate: true }, config); | ||
this.agileInstance = () => agileInstance; | ||
internal_1.Agile.initialIntegrations.forEach((integration) => this.integrate(integration)); | ||
if (config.autoIntegrate) { | ||
Integrations.onRegisterInitialIntegration((integration) => { | ||
this.integrate(integration); | ||
}); | ||
} | ||
} | ||
static addInitialIntegration(integration) { | ||
if (integration instanceof internal_1.Integration) { | ||
onRegisterInitialIntegrationCallbacks.forEach((callback) => callback(integration)); | ||
Integrations.initialIntegrations.push(integration); | ||
} | ||
} | ||
static onRegisterInitialIntegration(callback) { | ||
onRegisterInitialIntegrationCallbacks.push(callback); | ||
Integrations.initialIntegrations.forEach((integration) => { | ||
callback(integration); | ||
}); | ||
} | ||
integrate(integration) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!integration._key) { | ||
internal_1.LogCodeManager.log('18:03:00', [integration._key], integration); | ||
if (integration._key == null) { | ||
internal_1.LogCodeManager.log('18:03:00', [integration._key, this.agileInstance().key], integration); | ||
return false; | ||
@@ -33,3 +51,3 @@ } | ||
integration.integrated = true; | ||
internal_1.LogCodeManager.log('18:00:00', [integration._key], integration); | ||
internal_1.LogCodeManager.log('18:00:00', [integration._key, this.agileInstance().key], integration); | ||
return true; | ||
@@ -53,1 +71,2 @@ }); | ||
exports.Integrations = Integrations; | ||
Integrations.initialIntegrations = []; |
@@ -1,6 +0,7 @@ | ||
export * from '@agile-ts/logger'; | ||
export * from './logCodeManager'; | ||
export * from './utils'; | ||
export * from '@agile-ts/utils'; | ||
export * from './logCodeManager'; | ||
export * from './agile'; | ||
export * from './integrations'; | ||
export * from './integrations/integration'; | ||
export * from './runtime'; | ||
@@ -28,3 +29,2 @@ export * from './runtime/observer'; | ||
export * from './collection/collection.persistent'; | ||
export * from './integrations'; | ||
export * from './integrations/integration'; | ||
export * from './shared'; |
@@ -13,7 +13,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("@agile-ts/logger"), exports); | ||
__exportStar(require("./logCodeManager"), exports); | ||
__exportStar(require("./utils"), exports); | ||
__exportStar(require("@agile-ts/utils"), exports); | ||
__exportStar(require("./logCodeManager"), exports); | ||
__exportStar(require("./agile"), exports); | ||
__exportStar(require("./integrations"), exports); | ||
__exportStar(require("./integrations/integration"), exports); | ||
__exportStar(require("./runtime"), exports); | ||
@@ -41,3 +42,2 @@ __exportStar(require("./runtime/observer"), exports); | ||
__exportStar(require("./collection/collection.persistent"), exports); | ||
__exportStar(require("./integrations"), exports); | ||
__exportStar(require("./integrations/integration"), exports); | ||
__exportStar(require("./shared"), exports); |
@@ -0,1 +1,2 @@ | ||
export declare let loggerPackage: any; | ||
declare const logCodeMessages: { | ||
@@ -15,2 +16,3 @@ '10:00:00': string; | ||
'12:03:02': string; | ||
'13:00:00': string; | ||
'13:01:00': string; | ||
@@ -76,3 +78,3 @@ '13:01:01': string; | ||
* Logs the log message according to the specified log code | ||
* with the Agile Logger. | ||
* with the Agile Logger if installed or the normal console. | ||
* | ||
@@ -87,2 +89,14 @@ * @internal | ||
/** | ||
* Logs the log message according to the specified log code | ||
* with the Agile Logger if installed and the provided tags are active. | ||
* | ||
* @internal | ||
* @param tags - Tags to be active to log the logCode. | ||
* @param logCode - Log code of the message to be returned. | ||
* @param replacers - Instances that replace these '${x}' placeholders based on the index | ||
* For example: 'replacers[0]' replaces '${0}', 'replacers[1]' replaces '${1}', .. | ||
* @param data - Data to be attached to the end of the log message. | ||
*/ | ||
declare function logIfTags<T extends LogCodesArrayType<typeof logCodeMessages>>(tags: string[], logCode: T, replacers?: any[], ...data: any[]): void; | ||
/** | ||
* The Log Code Manager keeps track | ||
@@ -116,2 +130,3 @@ * and manages all important Logs of AgileTs. | ||
'12:03:02': string; | ||
'13:00:00': string; | ||
'13:01:00': string; | ||
@@ -166,2 +181,4 @@ '13:01:01': string; | ||
}; | ||
getLogger: () => any; | ||
logIfTags: typeof logIfTags; | ||
}; | ||
@@ -168,0 +185,0 @@ export declare type LogCodesArrayType<T> = { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LogCodeManager = void 0; | ||
const agile_1 = require("./agile"); | ||
exports.LogCodeManager = exports.loggerPackage = void 0; | ||
exports.loggerPackage = null; | ||
try { | ||
exports.loggerPackage = require('@agile-ts/logger'); | ||
} | ||
catch (e) { | ||
} | ||
const logCodeTypes = { | ||
@@ -14,3 +19,3 @@ '00': 'success', | ||
'10:02:00': 'Be careful when binding multiple Agile Instances globally in one application!', | ||
'11:02:00': "The 'Local Storage' is not available in your current environment." + | ||
'11:02:00': "The 'Local Storage' is not available in your current environment. " + | ||
"To use the '.persist()' functionality, please provide a custom Storage!", | ||
@@ -29,2 +34,3 @@ '11:02:01': 'The first allocated Storage for AgileTs must be set as the default Storage!', | ||
"The Storage with the key/name '${1}' doesn't exists!`", | ||
'13:00:00': "Registered new Storage '${0}'.", | ||
'13:01:00': "GET value at key '${1}' from Storage '${0}'.", | ||
@@ -53,5 +59,5 @@ '13:01:01': "SET value at key '${1}' in Storage '${0}'.", | ||
'17:03:00': "The 'perform()' method isn't set in Observer but need to be set! Observer is no stand alone class.", | ||
'18:00:00': "Integrated '${0}' into AgileTs", | ||
'18:00:00': "Integrated '${0}' into AgileTs '${1}'", | ||
'18:02:00': "Can't call the 'update()' method on a not ready Integration '${0}'!", | ||
'18:03:00': "Failed to integrate Framework '${0}'!", | ||
'18:03:00': "Failed to integrate Framework '${0}' into AgileTs '${1}'!", | ||
'19:03:00': "The 'persist()' method can't be used in the Computed Class! " + | ||
@@ -98,4 +104,4 @@ "The Computed Class has a dynamic value which shouldn't be persisted. " + | ||
let result = (_a = logCodeMessages[logCode]) !== null && _a !== void 0 ? _a : `'${logCode}' is a unknown logCode!`; | ||
for (const i in replacers) { | ||
result = result.split('${' + i + '}').join(replacers[i] + ''); | ||
for (let i = 0; i < replacers.length; i++) { | ||
result = result.replace('${' + i + '}', replacers[i]); | ||
} | ||
@@ -105,6 +111,27 @@ return result; | ||
function log(logCode, replacers = [], ...data) { | ||
const codes = logCode.split(':'); | ||
if (codes.length === 3) | ||
agile_1.Agile.logger[logCodeTypes[codes[1]]](getLog(logCode, replacers), ...data); | ||
const logger = exports.LogCodeManager.getLogger(); | ||
if (!(logger === null || logger === void 0 ? void 0 : logger.isActive)) | ||
return; | ||
const logType = logCodeTypes[logCode.substr(3, 2)]; | ||
if (typeof logType !== 'string') | ||
return; | ||
if (logger == null) { | ||
if (logType === 'error' || logType === 'warn') | ||
console[logType](getLog(logCode, replacers)); | ||
return; | ||
} | ||
logger[logType](getLog(logCode, replacers), ...data); | ||
} | ||
function logIfTags(tags, logCode, replacers = [], ...data) { | ||
const logger = exports.LogCodeManager.getLogger(); | ||
if (!(logger === null || logger === void 0 ? void 0 : logger.isActive)) | ||
return; | ||
const logType = logCodeTypes[logCode.substr(3, 2)]; | ||
if (typeof logType !== 'string') | ||
return; | ||
if (logger == null) { | ||
return; | ||
} | ||
logger.if.tag(tags)[logType](getLog(logCode, replacers), ...data); | ||
} | ||
exports.LogCodeManager = { | ||
@@ -115,2 +142,7 @@ getLog, | ||
logCodeMessages: logCodeMessages, | ||
getLogger: () => { | ||
var _a; | ||
return (_a = exports.loggerPackage === null || exports.loggerPackage === void 0 ? void 0 : exports.loggerPackage.sharedAgileLogger) !== null && _a !== void 0 ? _a : null; | ||
}, | ||
logIfTags, | ||
}; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Agile, SubscriptionContainer, RuntimeJob } from '../internal'; | ||
@@ -9,2 +10,3 @@ export declare class Runtime { | ||
isPerformingJobs: boolean; | ||
bucketTimeout: NodeJS.Timeout | null; | ||
/** | ||
@@ -11,0 +13,0 @@ * The Runtime queues and executes incoming Observer-based Jobs |
@@ -12,12 +12,9 @@ "use strict"; | ||
this.isPerformingJobs = false; | ||
this.bucketTimeout = null; | ||
this.agileInstance = () => agileInstance; | ||
} | ||
ingest(job, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
perform: !this.isPerformingJobs, | ||
}); | ||
config = Object.assign({ perform: !this.isPerformingJobs }, config); | ||
this.jobQueue.push(job); | ||
internal_1.Agile.logger.if | ||
.tag(['runtime']) | ||
.info(internal_1.LogCodeManager.getLog('16:01:00', [job._key]), job); | ||
internal_1.LogCodeManager.logIfTags(['runtime'], '16:01:00', [job._key], job); | ||
if (config.perform) { | ||
@@ -38,5 +35,3 @@ const performJob = this.jobQueue.shift(); | ||
this.currentJob = null; | ||
internal_1.Agile.logger.if | ||
.tag(['runtime']) | ||
.info(internal_1.LogCodeManager.getLog('16:01:01', [job._key]), job); | ||
internal_1.LogCodeManager.logIfTags(['runtime'], '16:01:01', [job._key], job); | ||
if (this.jobQueue.length > 0) { | ||
@@ -50,5 +45,12 @@ const performJob = this.jobQueue.shift(); | ||
if (this.jobsToRerender.length > 0) { | ||
setTimeout(() => { | ||
if (this.agileInstance().config.bucket) { | ||
if (this.bucketTimeout == null) { | ||
this.bucketTimeout = setTimeout(() => { | ||
this.bucketTimeout = null; | ||
this.updateSubscribers(); | ||
}); | ||
} | ||
} | ||
else | ||
this.updateSubscribers(); | ||
}); | ||
} | ||
@@ -71,3 +73,4 @@ } | ||
const subscriptionsToUpdate = new Set(); | ||
jobs.forEach((job) => { | ||
for (let i = 0; i < jobs.length; i++) { | ||
const job = jobs[i]; | ||
job.subscriptionContainersToUpdate.forEach((subscriptionContainer) => { | ||
@@ -96,7 +99,8 @@ let updateSubscriptionContainer = true; | ||
}); | ||
}); | ||
} | ||
return Array.from(subscriptionsToUpdate); | ||
} | ||
updateSubscriptionContainer(subscriptionsToUpdate) { | ||
subscriptionsToUpdate.forEach((subscriptionContainer) => { | ||
for (let i = 0; i < subscriptionsToUpdate.length; i++) { | ||
const subscriptionContainer = subscriptionsToUpdate[i]; | ||
if (subscriptionContainer instanceof internal_1.CallbackSubscriptionContainer) | ||
@@ -107,6 +111,4 @@ subscriptionContainer.callback(); | ||
subscriptionContainer.updatedSubscribers.clear(); | ||
}); | ||
internal_1.Agile.logger.if | ||
.tag(['runtime']) | ||
.info(internal_1.LogCodeManager.getLog('16:01:02'), subscriptionsToUpdate); | ||
} | ||
internal_1.LogCodeManager.logIfTags(['runtime'], '16:01:02', [], subscriptionsToUpdate); | ||
} | ||
@@ -113,0 +115,0 @@ getUpdatedObserverValues(subscriptionContainer) { |
@@ -10,6 +10,3 @@ "use strict"; | ||
this.subscribedTo = new Set(); | ||
config = internal_1.defineConfig(config, { | ||
dependents: [], | ||
subs: [], | ||
}); | ||
config = Object.assign({ dependents: [], subs: [] }, config); | ||
this.agileInstance = () => agileInstance; | ||
@@ -30,11 +27,6 @@ this._key = config.key; | ||
var _a; | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
}); | ||
}, force: false }, config); | ||
const job = new internal_1.RuntimeJob(this, { | ||
@@ -41,0 +33,0 @@ force: config.force, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RuntimeJob = void 0; | ||
const internal_1 = require("../internal"); | ||
class RuntimeJob { | ||
@@ -10,11 +9,6 @@ constructor(observer, config = {}) { | ||
this.performed = false; | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
}, force: false, maxTriesToUpdate: 3 }, config); | ||
this.config = { | ||
@@ -21,0 +15,0 @@ background: config.background, |
@@ -11,7 +11,3 @@ "use strict"; | ||
this.isObjectBased = false; | ||
config = internal_1.defineConfig(config, { | ||
proxyWeakMap: new WeakMap(), | ||
selectorWeakMap: new WeakMap(), | ||
key: internal_1.generateId(), | ||
}); | ||
config = Object.assign({ key: internal_1.generateId() }, config); | ||
this.subscribers = new Set(); | ||
@@ -18,0 +14,0 @@ this.key = config.key; |
@@ -13,5 +13,3 @@ "use strict"; | ||
subscribe(integrationInstance, subs, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
waitForMount: this.agileInstance().config.waitForMount, | ||
}); | ||
config = Object.assign({ waitForMount: this.agileInstance().config.waitForMount }, config); | ||
const subscriptionContainer = internal_1.isFunction(integrationInstance) | ||
@@ -39,5 +37,3 @@ ? this.createCallbackSubscriptionContainer(integrationInstance, subs, config) | ||
this.callbackSubs.delete(subscriptionInstance); | ||
internal_1.Agile.logger.if | ||
.tag(['runtime', 'subscription']) | ||
.info(internal_1.LogCodeManager.getLog('15:01:00'), subscriptionInstance); | ||
internal_1.LogCodeManager.logIfTags(['subscription'], '15:01:00', [], subscriptionInstance); | ||
return; | ||
@@ -48,5 +44,3 @@ } | ||
this.componentSubs.delete(subscriptionInstance); | ||
internal_1.Agile.logger.if | ||
.tag(['runtime', 'subscription']) | ||
.info(internal_1.LogCodeManager.getLog('15:01:01'), subscriptionInstance); | ||
internal_1.LogCodeManager.logIfTags(['subscription'], '15:01:01', [], subscriptionInstance); | ||
return; | ||
@@ -59,5 +53,3 @@ } | ||
this.componentSubs.delete(subContainer); | ||
internal_1.Agile.logger.if | ||
.tag(['runtime', 'subscription']) | ||
.info(internal_1.LogCodeManager.getLog('15:01:01'), subscriptionInstance); | ||
internal_1.LogCodeManager.logIfTags(['subscription'], '15:01:01', [], subscriptionInstance); | ||
}); | ||
@@ -83,5 +75,3 @@ return; | ||
]; | ||
internal_1.Agile.logger.if | ||
.tag(['runtime', 'subscription']) | ||
.info(internal_1.LogCodeManager.getLog('15:01:02'), componentSubscriptionContainer); | ||
internal_1.LogCodeManager.logIfTags(['subscription'], '15:01:02', [], componentSubscriptionContainer); | ||
return componentSubscriptionContainer; | ||
@@ -93,5 +83,3 @@ } | ||
callbackSubscriptionContainer.ready = true; | ||
internal_1.Agile.logger.if | ||
.tag(['runtime', 'subscription']) | ||
.info(internal_1.LogCodeManager.getLog('15:01:03'), callbackSubscriptionContainer); | ||
internal_1.LogCodeManager.logIfTags(['subscription'], '15:01:03', [], callbackSubscriptionContainer); | ||
return callbackSubscriptionContainer; | ||
@@ -98,0 +86,0 @@ } |
@@ -13,6 +13,3 @@ "use strict"; | ||
this.watchers = {}; | ||
config = internal_1.defineConfig(config, { | ||
dependents: [], | ||
isPlaceholder: false, | ||
}); | ||
config = Object.assign({ dependents: [], isPlaceholder: false }, config); | ||
this.agileInstance = () => agileInstance; | ||
@@ -59,5 +56,3 @@ this._key = config.key; | ||
set(value, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
force: false, | ||
}); | ||
config = Object.assign({ force: false }, config); | ||
const _value = internal_1.isFunction(value) | ||
@@ -99,5 +94,3 @@ ? value(internal_1.copy(this._value)) | ||
patch(targetWithChanges, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
addNewProperties: true, | ||
}); | ||
config = Object.assign({ addNewProperties: true }, config); | ||
if (!internal_1.isValidObject(this.nextStateValue, true)) { | ||
@@ -169,7 +162,3 @@ internal_1.LogCodeManager.log('14:03:02'); | ||
} | ||
_config = internal_1.defineConfig(_config, { | ||
loadValue: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
_config = Object.assign({ loadValue: true, storageKeys: [], defaultStorageKey: null }, _config); | ||
if (this.persistent != null && this.isPersisted) | ||
@@ -264,5 +253,3 @@ return this; | ||
addSideEffect(key, callback, config = {}) { | ||
config = internal_1.defineConfig(config, { | ||
weight: 10, | ||
}); | ||
config = Object.assign({ weight: 10 }, config); | ||
if (!internal_1.isFunction(callback)) { | ||
@@ -269,0 +256,0 @@ internal_1.LogCodeManager.log('00:03:01', ['Side Effect Callback', 'function']); |
@@ -25,14 +25,6 @@ "use strict"; | ||
const state = this.state(); | ||
config = internal_1.defineConfig(config, { | ||
perform: true, | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ perform: true, background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
}, force: false, storage: true, overwrite: false, maxTriesToUpdate: 3 }, config); | ||
if (state.isPlaceholder) { | ||
@@ -39,0 +31,0 @@ config.force = true; |
@@ -19,7 +19,3 @@ "use strict"; | ||
}); | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
this.state = () => state; | ||
@@ -26,0 +22,0 @@ this.instantiatePersistent({ |
@@ -8,13 +8,6 @@ "use strict"; | ||
super(observer, config); | ||
config = internal_1.defineConfig(config, { | ||
background: false, | ||
sideEffects: { | ||
config = Object.assign({ background: false, sideEffects: { | ||
enabled: true, | ||
exclude: [], | ||
}, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
maxTriesToUpdate: 3, | ||
}); | ||
}, force: false, storage: true, overwrite: false, maxTriesToUpdate: 3 }, config); | ||
this.config = { | ||
@@ -21,0 +14,0 @@ background: config.background, |
@@ -10,6 +10,3 @@ "use strict"; | ||
this.agileInstance = () => agileInstance; | ||
config = internal_1.defineConfig(config, { | ||
localStorage: false, | ||
defaultStorageKey: null, | ||
}); | ||
config = Object.assign({ localStorage: false, defaultStorageKey: null }, config); | ||
this.config = { defaultStorageKey: config.defaultStorageKey }; | ||
@@ -62,2 +59,3 @@ if (config.localStorage) | ||
}); | ||
internal_1.LogCodeManager.log('13:00:00', [storage.key], storage); | ||
return true; | ||
@@ -64,0 +62,0 @@ } |
@@ -21,7 +21,3 @@ "use strict"; | ||
this._key = Persistent.placeHolderKey; | ||
config = internal_1.defineConfig(config, { | ||
instantiate: true, | ||
storageKeys: [], | ||
defaultStorageKey: null, | ||
}); | ||
config = Object.assign({ instantiate: true, storageKeys: [], defaultStorageKey: null }, config); | ||
this.agileInstance().storages.persistentInstances.add(this); | ||
@@ -28,0 +24,0 @@ this.config = { defaultStorageKey: config.defaultStorageKey }; |
@@ -8,6 +8,3 @@ "use strict"; | ||
this.ready = false; | ||
config = internal_1.defineConfig(config, { | ||
prefix: 'agile', | ||
async: false, | ||
}); | ||
config = Object.assign({ prefix: 'agile', async: false }, config); | ||
this.key = config.key; | ||
@@ -50,5 +47,3 @@ this.methods = config.methods; | ||
const _res = internal_1.isJsonString(res) ? JSON.parse(res) : res; | ||
internal_1.Agile.logger.if | ||
.tag(['storage']) | ||
.info(internal_1.LogCodeManager.getLog('13:01:00', [this.key, this.getStorageKey(key)]), _res); | ||
internal_1.LogCodeManager.logIfTags(['storage'], '13:01:00', [this.key, this.getStorageKey(key)], _res); | ||
return _res; | ||
@@ -65,8 +60,3 @@ } | ||
const _res = internal_1.isJsonString(res) ? JSON.parse(res) : res; | ||
internal_1.Agile.logger.if | ||
.tag(['storage']) | ||
.info(internal_1.LogCodeManager.getLog('13:01:00', [ | ||
this.key, | ||
this.getStorageKey(key), | ||
]), _res); | ||
internal_1.LogCodeManager.logIfTags(['storage'], '13:01:00', [this.key, this.getStorageKey(key)], _res); | ||
resolve(_res); | ||
@@ -79,5 +69,6 @@ }).catch(reject); | ||
return; | ||
internal_1.Agile.logger.if | ||
.tag(['storage']) | ||
.info(internal_1.LogCodeManager.getLog('13:01:01', [this.key, this.getStorageKey(key)]), value); | ||
internal_1.LogCodeManager.logIfTags(['storage'], '13:01:01', [ | ||
this.key, | ||
this.getStorageKey(key), | ||
]); | ||
this.methods.set(this.getStorageKey(key), JSON.stringify(value)); | ||
@@ -88,5 +79,6 @@ } | ||
return; | ||
internal_1.Agile.logger.if | ||
.tag(['storage']) | ||
.info(internal_1.LogCodeManager.getLog('13:01:02', [this.key, this.getStorageKey(key)])); | ||
internal_1.LogCodeManager.logIfTags(['storage'], '13:01:02', [ | ||
this.key, | ||
this.getStorageKey(key), | ||
]); | ||
this.methods.remove(this.getStorageKey(key)); | ||
@@ -93,0 +85,0 @@ } |
@@ -107,1 +107,7 @@ import { Agile, Observer } from './internal'; | ||
export declare function globalBind(key: string, instance: any, overwrite?: boolean): boolean; | ||
/** | ||
* Returns a boolean indicating whether AgileTs is currently running on a server. | ||
* | ||
* @public | ||
*/ | ||
export declare const runsOnServer: () => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.globalBind = exports.optionalRequire = exports.extractRelevantObservers = exports.extractObservers = exports.getAgileInstance = void 0; | ||
exports.runsOnServer = exports.globalBind = exports.optionalRequire = exports.extractRelevantObservers = exports.extractObservers = exports.getAgileInstance = void 0; | ||
const internal_1 = require("./internal"); | ||
@@ -14,2 +14,5 @@ function getAgileInstance(instance) { | ||
} | ||
if (internal_1.shared instanceof internal_1.Agile) { | ||
return internal_1.shared; | ||
} | ||
return globalThis[internal_1.Agile.globalKey]; | ||
@@ -111,1 +114,6 @@ } | ||
exports.globalBind = globalBind; | ||
exports.runsOnServer = () => { | ||
return !(typeof window !== 'undefined' && | ||
typeof window.document !== 'undefined' && | ||
typeof window.document.createElement !== 'undefined'); | ||
}; |
{ | ||
"name": "@agile-ts/core", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "BennoDev", | ||
@@ -47,5 +47,12 @@ "license": "MIT", | ||
"dependencies": { | ||
"@agile-ts/utils": "^0.0.5", | ||
"@agile-ts/logger": "^0.0.5" | ||
"@agile-ts/utils": "^0.0.6" | ||
}, | ||
"peerDependencies": { | ||
"@agile-ts/logger": "^0.0.6" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@agile-ts/logger": { | ||
"optional": true | ||
} | ||
}, | ||
"publishConfig": { | ||
@@ -52,0 +59,0 @@ "access": "public" |
167
README.md
<img src="https://raw.githubusercontent.com/agile-ts/agile/master/static/header_background.png" alt="AgileTs"> | ||
> Global, simple, spacy State and Logic Framework | ||
> Global State and Logic Framework | ||
@@ -45,16 +45,16 @@ <br /> | ||
// 1️⃣ Create Instance of AgileTs | ||
const App = new Agile(); | ||
// 1️⃣ Create State with the initial value "Hello Friend!" | ||
const MY_FIRST_STATE = createState("Hello Friend!"); | ||
// 2️⃣ Create State with help of before defined Agile Instance | ||
const MY_FIRST_STATE = App.createState("Hello Friend!"); | ||
// -- MyComponent.whatever ------------------------------------------ | ||
// 3️⃣ Bind initialized State to desired UI-Component | ||
// And wolla, it's reactive. Everytime the State mutates the Component rerenders | ||
const myFirstState = useAgile(MY_FIRST_STATE); // Returns value of State ("Hello Friend!") | ||
// 2️⃣ Bind initialized State to the desired UI-Component. | ||
// And wolla, the Component is reactive. | ||
// Everytime the State mutates the Component re-renders. | ||
const myFirstState = useAgile(MY_FIRST_STATE); | ||
console.log(myFirstState); // Returns "Hello Friend!" | ||
``` | ||
Want to learn more? Check out our [Quick Start Guides](https://agile-ts.org/docs/Installation.md). | ||
Want to learn how to implement AgileTs in your preferred UI-Framework? | ||
Check out our [Quick Start Guides](https://agile-ts.org/docs/Installation.md). | ||
@@ -70,3 +70,3 @@ ### ⛳️ Sandbox | ||
More examples can be found in the [Example Section](https://agile-ts.org/docs/examples). | ||
More examples can be found in the [Example section](https://agile-ts.org/docs/examples). | ||
@@ -80,6 +80,9 @@ | ||
AgileTs is a global, simple, well-tested State Management Framework implemented in Typescript. | ||
AgileTs is a global State and Logic Framework implemented in Typescript. | ||
It offers a reimagined API that focuses on **developer experience** | ||
and allows you to **easily** manage your States. | ||
Besides States, AgileTs offers some other powerful APIs that make your life easier. | ||
and allows you to **easily** and **flexible** manage your application States. | ||
Besides [States](https://agile-ts.org/docs/core/state), | ||
AgileTs offers some other powerful APIs that make your life easier, | ||
such as [Collections](https://agile-ts.org/docs/core/collection) | ||
and [Computed States](https://agile-ts.org/docs/core/computed). | ||
The philosophy behind AgileTs is simple: | ||
@@ -91,45 +94,42 @@ | ||
```ts | ||
const MY_STATE = App.createState('frank'); // Create State | ||
MY_STATE.set('jeff'); // Update State value | ||
MY_STATE.undo(); // Undo latest State value change | ||
MY_STATE.is({hello: "jeff"}); // Check if State has the value '{hello: "jeff"}' | ||
MY_STATE.watch((value) => {console.log(value);}); // Watch on State changes | ||
``` | ||
// Create State with inital value 'frank' | ||
const MY_STATE = createState('frank'); | ||
**Some more straightforward syntax examples:** | ||
// Update State value from 'frank' to 'jeff' | ||
MY_STATE.set('jeff'); | ||
- Store State in any Storage, like the [Local Storage](https://www.w3schools.com/html/html5_webstorage.asp) | ||
```ts | ||
MY_STATE.persist("storage-key"); | ||
``` | ||
- Create a reactive Array of States | ||
```ts | ||
const MY_COLLECTION = App.createCollection(); | ||
MY_COLLECTION.collect({id: 1, name: "Frank"}); | ||
MY_COLLECTION.collect({id: 2, name: "Dieter"}); | ||
MY_COLLECTION.update(1, {name: "Jeff"}); | ||
``` | ||
- Compute State depending on other States | ||
```ts | ||
const MY_INTRODUCTION = App.createComputed(() => { | ||
return `Hello I am '${MY_NAME.vale}' and I use ${MY_STATE_MANAGER.value} for State Management.`; | ||
}); | ||
``` | ||
// Undo latest State value change | ||
MY_STATE.undo(); | ||
// Reset State value to its initial value | ||
MY_STATE.reset(); | ||
// Permanently store State value in an external Storage | ||
MY_STATE.persist("storage-key"); | ||
``` | ||
### 🤸 Flexible | ||
- Works in nearly any UI-Layer. Check [here](https://agile-ts.org/docs/Frameworks) if your preferred Framework is supported too. | ||
- Surly behaves with the workflow which suits you best. No need for _reducers_, _actions_, .. | ||
- Has **0** external dependencies | ||
- Works in nearly any UI-Framework (currently supported are [React](https://reactjs.org/), [React-Native](https://reactnative.dev/) and [Vue](https://vuejs.org/)). | ||
- Surly behaves with the workflow that suits you best. | ||
No need for _reducers_, _actions_, .. | ||
- Has **0** external dependencies. | ||
### ⛳️ Centralize | ||
AgileTs is designed to take all business logic out of UI-Components and put them in a central place, often called `core`. | ||
The benefit of keeping logic separate to UI-Components is to make your code more decoupled, portable, scalable, and above all, easily testable. | ||
AgileTs is designed to take all business logic out of the UI-Components | ||
and put them in a central place, often called `core`. | ||
The advantage of keeping logic separate to UI-Components, | ||
is that your code is more decoupled, portable, scalable, | ||
and above all, easily testable. | ||
You can learn more about ways to centralize your application logic with AgileTs | ||
in our [Style Guides](https://agile-ts.org/docs/style-guide). | ||
### 🎯 Easy to Use | ||
Learn the powerful tools of AgileTs in a short amount of time. An excellent place to start are | ||
our [Quick Start Guides](https://agile-ts.org/docs/Installation), or if you don't like to follow any tutorials, | ||
you can jump straight into our [Example](https://agile-ts.org/docs/examples/Introduction) Section. | ||
Learn the powerful tools of AgileTs in a short period of time. | ||
An excellent place to start are our [Quick Start Guides](https://agile-ts.org/docs/Installation), | ||
or if you don't like to follow tutorials, | ||
you can jump straight into the [Example section](https://agile-ts.org/docs/examples/Introduction). | ||
@@ -143,6 +143,6 @@ | ||
In order to properly use AgileTs, in a UI-Framework, we need to install **two** packages. | ||
In order to use AgileTs in a UI-Framework, we need to install **two packages**. | ||
- The [`core`](https://agile-ts.org/docs/core) package, which contains the State Management Logic of AgileTs | ||
and therefore offers powerful classes such as the [`State Class`](https://agile-ts.org/docs/core/state). | ||
- The [`core`](https://agile-ts.org/docs/core) package contains the State Management Logic of AgileTs | ||
and therefore provides powerful classes like the [`State Class`](https://agile-ts.org/docs/core/state). | ||
``` | ||
@@ -152,5 +152,6 @@ npm install @agile-ts/core | ||
- And on the other hand, a _fitting Integration_ for your preferred UI-Framework. | ||
In my case, the [React Integration](https://www.npmjs.com/package/@agile-ts/react). | ||
Check [here](https://agile-ts.org/docs/frameworks) if your desired Framework is supported, too. | ||
- A _fitting Integration_ for the UI-Framework of your choice, on the other hand, | ||
is an interface to the actual UI and provides useful functionalities | ||
to bind States to UI-Components for reactivity. | ||
I prefer React, so let's go with the [React Integration](https://www.npmjs.com/package/@agile-ts/react) for now. | ||
``` | ||
@@ -167,8 +168,37 @@ npm install @agile-ts/react | ||
Sounds AgileTs interesting to you? | ||
Checkout our **[documentation](https://agile-ts.org/docs/introduction)**, to learn more. | ||
And I promise you. You will be able to use AgileTs in no time. | ||
If you have any further questions, don't hesitate to join our [Community Discord](https://discord.gg/T9GzreAwPH). | ||
Does AgileTs sound interesting to you? | ||
Take a look at our **[documentation](https://agile-ts.org/docs/introduction)**, | ||
to learn more about its functionalities and capabilities. | ||
If you have any further questions, | ||
feel free to join our [Community Discord](https://discord.gg/T9GzreAwPH). | ||
We will be happy to help you. | ||
- Overview | ||
- [Introduction](https://agile-ts.org/docs/introduction/) | ||
- [Installation](https://agile-ts.org/docs/installation) | ||
- [Style Guides](https://agile-ts.org/docs/style-guide) | ||
- [Supported Frameworks](https://agile-ts.org/docs/frameworks) | ||
- [Contributing](https://agile-ts.org/docs/contributing) | ||
- Quick Start | ||
- [React](https://agile-ts.org/docs/quick-start/react) | ||
- [Vue](https://agile-ts.org/docs/quick-start/vue) | ||
- [Angular](https://agile-ts.org/docs/quick-start/angular) | ||
- Packages | ||
- [core](https://agile-ts.org/docs/core) | ||
- [Agile Instance](https://agile-ts.org/docs/core/agile-instance) | ||
- [State](https://agile-ts.org/docs/core/state) | ||
- [Collection](https://agile-ts.org/docs/core/collection) | ||
- [Computed](https://agile-ts.org/docs/core/computed) | ||
- [Storage](https://agile-ts.org/docs/core/storage) | ||
- [Integration](https://agile-ts.org/docs/core/integration) | ||
- [react](https://agile-ts.org/docs/react) | ||
- [React Hooks](https://agile-ts.org/docs/react/hooks) | ||
- [AgileHOC](https://agile-ts.org/docs/react/AgileHOC) | ||
- Examples | ||
- [React](https://agile-ts.org/docs/examples/react) | ||
- [React-Native](https://agile-ts.org/docs/examples/react-native) | ||
- [Vue](https://agile-ts.org/docs/examples/vue) | ||
- [Typescript Interfaces](https://agile-ts.org/docs/interfaces) | ||
<br /> | ||
@@ -194,13 +224,13 @@ | ||
| Name | Latest Version | Description | | ||
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | | ||
| [@agile-ts/core](/packages/core) | [![badge](https://img.shields.io/npm/v/@agile-ts/core.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/core) | State Manager | | ||
| [@agile-ts/react](/packages/react) | [![badge](https://img.shields.io/npm/v/@agile-ts/react.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/react) | React Integration | | ||
| [@agile-ts/vue](/packages/vue) | [![badge](https://img.shields.io/npm/v/@agile-ts/vue.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/vue) | Vue Integration | | ||
| [@agile-ts/api](/packages/api) | [![badge](https://img.shields.io/npm/v/@agile-ts/api.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/api) | Promise based API | | ||
| [@agile-ts/multieditor](/packages/multieditor) | [![badge](https://img.shields.io/npm/v/@agile-ts/multieditor.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/multieditor) | Simple Form Manager | | ||
| [@agile-ts/event](/packages/event) | [![badge](https://img.shields.io/npm/v/@agile-ts/event.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/event) | Handy class for emitting UI Events | | ||
| [@agile-ts/logger](/packages/logger) | [![badge](https://img.shields.io/npm/v/@agile-ts/logger.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/logger) | Manages the logging of AgileTs | | ||
| [@agile-ts/utils](/packages/utils) | [![badge](https://img.shields.io/npm/v/@agile-ts/utils.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/utils) | Util functions of AgileTs | | ||
| [@agile-ts/proxytree](/packages/proxytree) | [![badge](https://img.shields.io/npm/v/@agile-ts/proxytree.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/proxytree) | Create Proxy Tree | | ||
| Name | Latest Version | Description | | ||
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | | ||
| [@agile-ts/core](/packages/core) | [![badge](https://img.shields.io/npm/v/@agile-ts/core.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/core) | State Manager Logic | | ||
| [@agile-ts/react](/packages/react) | [![badge](https://img.shields.io/npm/v/@agile-ts/react.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/react) | React Integration | | ||
| [@agile-ts/vue](/packages/vue) | [![badge](https://img.shields.io/npm/v/@agile-ts/vue.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/vue) | Vue Integration | | ||
| [@agile-ts/api](/packages/api) | [![badge](https://img.shields.io/npm/v/@agile-ts/api.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/api) | Promise based API | | ||
| [@agile-ts/multieditor](/packages/multieditor) | [![badge](https://img.shields.io/npm/v/@agile-ts/multieditor.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/multieditor) | Simple Form Manager | | ||
| [@agile-ts/event](/packages/event) | [![badge](https://img.shields.io/npm/v/@agile-ts/event.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/event) | Handy class for emitting UI Events | | ||
| [@agile-ts/logger](/packages/logger) | [![badge](https://img.shields.io/npm/v/@agile-ts/logger.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/logger) | Logging API of AgileTs | | ||
| [@agile-ts/utils](/packages/utils) | [![badge](https://img.shields.io/npm/v/@agile-ts/utils.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/utils) | Utilities of AgileTs | | ||
| [@agile-ts/proxytree](/packages/proxytree) | [![badge](https://img.shields.io/npm/v/@agile-ts/proxytree.svg?style=flat-square)](https://www.npmjs.com/package/@agile-ts/proxytree) | Proxy Tree for tracking accessed properties | | | ||
@@ -213,2 +243,3 @@ <br /> | ||
AgileTs is inspired by [MVVM Frameworks](https://de.wikipedia.org/wiki/Model_View_ViewModel) like [MobX](https://mobx.js.org/README.html) and [PulseJs](https://github.com/pulse-framework/pulse). | ||
AgileTs is inspired by [MVVM Frameworks](https://de.wikipedia.org/wiki/Model_View_ViewModel) | ||
like [MobX](https://mobx.js.org/README.html) and [PulseJs](https://github.com/pulse-framework/pulse). |
305293
64
7104
237
+ Added@agile-ts/logger@0.0.6(transitive)
+ Added@agile-ts/utils@0.0.6(transitive)
- Removed@agile-ts/logger@^0.0.5
- Removed@agile-ts/logger@0.0.5(transitive)
- Removed@agile-ts/utils@0.0.5(transitive)
Updated@agile-ts/utils@^0.0.6