cydran
Version:
Unobtrusive Javascript presentation framework
962 lines (958 loc) • 33.2 kB
TypeScript
// Generated by dts-bundle-generator v6.5.0
declare class IdGenerator {
private maxValue;
private major;
private minor;
private micro;
constructor(major?: number, minor?: number, micro?: number, max?: number);
generate(): string;
upperBoundary(): number;
}
export declare abstract class AbstractBehavior<M, E extends HTMLElement | Text, P> implements Behavior<M, E, P> {
private ____internal$$cydran____;
constructor();
requestDigestionSources(sources: DigestableSource[]): void;
onInit(context?: any): void;
onMount(): void;
onUnmount(): void;
onRemount(): void;
protected notify(name: string, payload: any): void;
protected notifyElement(name: string, payload: any, element: HTMLElement): void;
/**
* Get the active module instance reference by id
* @return U
*/
get<U>(id: string): U;
/**
* [message description]
* @param {string} channelName [description]
* @param {string} messageName [description]
* @param {any} payload [description]
*/
message(channelName: string, messageName: string, payload?: any): void;
tell(name: string, payload?: any): void;
/**
* Broadcast a message
* @param {string} channelName [description]
* @param {string} messageName [description]
* @param {any} payload [description]
*/
broadcast(channelName: string, messageName: string, payload?: any): void;
/**
* Broadcast a message in the Global context
* @param {string} channelName [description]
* @param {string} messageName [description]
* @param {any} payload [description]
*/
broadcastGlobally(channelName: string, messageName: string, payload?: any): void;
on(messageName: string): OnContinuation;
getParentId(): string;
getId(): string;
isFlagged(name: string): boolean;
protected setFlag(name: string): void;
protected setDefaultExpression(defaultExpression: string): void;
protected getExtractor(): Attributes;
protected getParams(): P;
protected getModelFn(): () => any;
protected getValueFn(): () => any;
protected bridge(name: string): void;
protected invoke(params?: any): void;
/**
* Get the associated {HTMLElement html element} of this behavior.
* @return {HTMLElement} [description]
*/
protected getEl(): E;
/**
* [getModule description]
* @return {Module} [description]
*/
protected getModule(): Module;
/**
* Gets the prefix of all Cydran attributes on the component.
* @return the prefix
*/
protected getPrefix(): string;
/**
* Gets the prefix for the behavior.
* @return the behavior prefix
*/
protected getBehaviorPrefix(): string;
/**
* [mediate description]
* @param {string} expression [description]
* @return {mediator} [description]
*/
protected mediate<T>(expression: string, reducerFn?: (input: any) => T): Mediator<T>;
/**
* [getModel description]
* @return {any} [description]
*/
protected getModel(): any;
/**
* [getParent description]
* @return {Component} [description]
*/
protected getParent(): Nestable;
/**
* [getMediator description]
* @return {Mediator} [description]
*/
protected getMediator(): Mediator<M>;
protected $apply(fn: Function, args: any[]): any;
/**
* Get the expression specified
* @return {string} [description]
*/
protected getExpression(): string;
/**
* Gets the logger.
* @return {Logger} logger instance
*/
protected getLogger(): Logger;
protected isMutable(): boolean;
protected isMounted(): boolean;
protected isValidated(): boolean;
protected setDefaults(defaults: P): void;
protected setValuelessDefaults(valuelessDefaults: SimpleMap<string>): void;
protected setValidations(validations: FieldValidations<HTMLElement>): void;
protected setConverters(converters: BehaviorAttributeConverters): void;
protected setLoggerName(name: string): void;
protected setReducerFn(reducerFn: (input: any) => M): void;
protected getDom(): Dom;
}
export declare abstract class AbstractValueBehavior<M, E extends HTMLElement | Text, P> extends AbstractBehavior<M, E, P> {
constructor();
onMount(): void;
protected abstract onChange(previous: M, current: M): void;
}
export declare class Component implements Nestable {
private ____internal$$cydran____;
private ____internal$$cydran$$module____;
/**
* Constructor
* @param template - string value representation of a template
* @param options - optional {@link ComponentOptions} argument
*/
constructor(template: string | HTMLElement | Renderer, options?: ComponentOptions);
/**
* Get the {@link MetadataContinuation} of the {@link Component}
*/
metadata(): MetadataContinuation;
/**
* Component has a {@link Region}
* @returns boolean - true | false
*/
hasRegion(name: string): boolean;
/**
* Get a child component from a region.
* @param name - string name value of the child {@link Component}
* @returns Component instance, or null
*/
getChild<N extends Nestable>(name: string): N;
/**
* Set a child component into a region.
* @param name - string name value of the child {@link Component}
* @param component - the {@link Component} reference
*/
setChild(name: string, component: Nestable): void;
setChildFromRegistry(name: string, componentName: string, defaultComponentName?: string): void;
message(channelName: string, messageName: string, payload?: any): void;
tell(name: string, payload?: any): void;
getParent(): Nestable;
getEl(): HTMLElement;
get<T>(id: string): T;
scope(): Scope;
getPrefix(): string;
getName(): string;
isMounted(): boolean;
isConnected(): boolean;
getId(): string;
forElement<E extends HTMLElement>(name: string): ElementOperations<E>;
forForm(name: string): FormOperations;
forForms(): FormOperations;
watch<T>(expression: string, target: (previous: T, current: T) => void, reducerFn?: (input: any) => T, context?: any): void;
evaluate<T>(expression: string): T;
getWatchContext(): any;
getProperties(): Properties;
/**
* Activity to execute when the component is mounted on the {@linkcode Stage } for the first time
*/
onMount(): void;
/**
* Activity to execute when the component is un-mounted from the {@linkcode Stage }
*/
onUnmount(): void;
/**
* Activity to execute when the component is re-mounted on the {@linkcode Stage }
*/
onRemount(): void;
/**
* Get a {@linkcode FilterBuilder} object back to create a {@linkcode Filter} of lists in the model
* @param expression - primitive string representation expression of a JS iterable/array object
* @returns
*/
withFilter(expression: string): FilterBuilder;
protected getValue<T>(): T;
protected broadcast(channelName: string, messageName: string, payload?: any): void;
protected broadcastGlobally(channelName: string, messageName: string, payload?: any): void;
protected $apply(fn?: Function, args?: any[]): void;
protected on(messageName: string): OnContinuation;
protected getLogger(): Logger;
protected getLoggerFactory(): LoggerFactory;
protected ____internal$$cydran$$init____(template: string | HTMLElement | Renderer, options: InternalComponentOptions): void;
}
export declare const JSType: {
readonly STR: "string";
readonly BOOL: "boolean";
readonly BIGINT: "bigint";
readonly NUM: "number";
readonly SYM: "symbol";
readonly FN: "function";
readonly OBJ: "object";
};
export declare const argumentsBuilder: () => ArgumentsResolversBuilder;
export declare const builder: (rootSelector: string, properties?: any) => StageBuilder;
export declare enum BehaviorFlags {
ROOT_PROHIBITED = "ROOT_PROHIBITED",
CHILD_CONSUMPTION_PROHIBITED = "CHILD_CONSUMPTION_PROHIBITED"
}
export declare enum Events {
AFTER_CHILD_ADDED = "AFTER_CHILD_ADDED",
AFTER_CHILD_CHANGED = "AFTER_CHILD_CHANGED",
AFTER_CHILD_REMOVED = "AFTER_CHILD_REMOVED",
AFTER_PARENT_ADDED = "AFTER_PARENT_ADDED",
AFTER_PARENT_CHANGED = "AFTER_PARENT_CHANGED",
AFTER_PARENT_REMOVED = "AFTER_PARENT_REMOVED",
BEFORE_CHILD_ADDED = "BEFORE_CHILD_ADDED",
BEFORE_CHILD_CHANGED = "BEFORE_CHILD_CHANGED",
BEFORE_CHILD_REMOVED = "BEFORE_CHILD_REMOVED",
BEFORE_PARENT_ADDED = "BEFORE_PARENT_ADDED",
BEFORE_PARENT_CHANGED = "BEFORE_PARENT_CHANGED",
BEFORE_PARENT_REMOVED = "BEFORE_PARENT_REMOVED",
COMPONENT_NESTING_CHANGED = "COMPONENT_NESTING_CHANGED",
CYDRAN_PREAPP_DISPOSAL = "CYDRAN_PREAPP_DISPOSAL"
}
export declare enum Ids {
STAGE = "$stage"
}
export declare enum Level {
TRACE = 0,
DEBUG = 1,
INFO = 2,
WARN = 3,
ERROR = 4,
FATAL = 5,
DISABLED = 6
}
export declare enum PropertyKeys {
CYDRAN_DIGEST_MAX_EVALUATIONS = "cydran.digest.maxEvaluations",
CYDRAN_CLONE_MAX_EVALUATIONS = "cydran.clone.maxEvaluations",
CYDRAN_EQUALS_MAX_EVALUATIONS = "cydran.equals.maxEvaluations",
CYDRAN_STARTUP_SYNCHRONOUS = "cydran.startup.synchronous",
CYDRAN_STRICT_ENABLED = "cydran.strict.enabled",
CYDRAN_STRICT_STARTPHRASE = "cydran.strict.startphrase",
CYDRAN_LAZY_STARTPHRASE = "cydran.lazy.startphrase",
CYDRAN_STRICT_MESSAGE = "cydran.strict.message",
CYDRAN_LOG_LEVEL = "cydran.logging.level",
CYDRAN_STYLES_ENABLED = "cydran.styles.enabled",
CYDRAN_OVERRIDE_WINDOW = "cydran.override.window",
CYDRAN_LOG_STRATEGY = "cydran.logging.strategy",
CYDRAN_LOG_COLOR_PREFIX = "cydran.logging.color",
CYDRAN_LOG_LABEL = "cydran.logging.label",
CYDRAN_LOG_LABEL_VISIBLE = "cydran.logging.label.visible",
CYDRAN_LOG_PREAMBLE_ORDER = "cydran.logging.pramble.order"
}
export declare function create(selector: string, initialValues?: any): void;
export declare function enumKeys<O extends object, K extends keyof O = keyof O>(obj: O): K[];
export declare function isDefined(value: any): boolean;
export declare function merge<T>(sources: any[], customizers?: SimpleMap<(currentValue: any, overlayValue: any) => any>): T;
export declare function noConflict(): any;
export declare function overlay<T>(target: T, sources: any[], customizers?: SimpleMap<(currentValue: any, overlayValue: any) => any>): T;
export declare function padLeft(text: string, desiredLength: number, padCharacter?: string): string;
export declare function padRight(text: string, desiredLength: number, padCharacter?: string): string;
export declare function requireNotNull<T>(value: T, name: string): T;
export declare function requireValid(value: string, name: string, regex: RegExp): string;
export declare function reset(): void;
export declare function setStrictTypeChecksEnabled(value: boolean): void;
export declare function stateMachineBuilder<M>(startState: string): MachineBuilder<M>;
export declare type BehaviorFunction = (el: HTMLElement) => Type<Behavior<any, HTMLElement | Text, any>>;
export declare type BiConsumer<T, U> = (value0: T, value1?: U) => void;
export declare type BiPredicate<T, U> = (value0: T, value1: U) => boolean;
export declare type Consumer<T> = (value: T) => void;
export declare type Predicate<T> = (value: T) => boolean;
export declare type VarConsumer<T, U> = (Consumer<T> | BiConsumer<T, U>);
export declare type VarPredicate<T, U> = Predicate<T> | BiPredicate<T, U>;
export interface ArgumentsResolvers {
resolve(context: any): any[];
postProcess(context: any, target: any, params: any[]): void;
}
export interface ArgumentsResolversBuilder extends Builder<ArgumentsResolvers> {
/**
* Intent to resolve a registered object in the Cydran service discovery functionality
* @param id unique string key of the registerd object
*/
with(id: string): ArgumentsResolversBuilder;
/**
* Intent to resolve a Cydran {PubSub} instance
*/
withPubSub(): ArgumentsResolversBuilder;
/**
* Intent to resolve an id instance value provided by the Cydran id generation mechanism
*/
withInstanceId(): ArgumentsResolversBuilder;
/**
* Intent to resolve the function that Cydran utilizes for instance id generation
*/
withInstanceIdFn(): ArgumentsResolversBuilder;
/**
* Intent to resolve a Cydran {Logger} instance
* @param name - of the {Logger} instance
* @param level - optional value representation of logging threshold
* @param strategy - optional argument to override default {OutputStrategy}
*/
withLogger(name: string, level?: string, strategy?: OutputStrategy): ArgumentsResolversBuilder;
/**
* Intent to resolve a logging {OutputStrategy} to be utilized
* @param id - key of the strategy
* @param straegy - mechanism of logging
*/
withLoggerOutputStrategy(id: string, strategy: OutputStrategy): ArgumentsResolversBuilder;
/**
* Intent to resolve a defined function
* @param fn function to resolve
*/
withFunction(fn: () => any): ArgumentsResolversBuilder;
/**
* Intent to resolve raw constant value
* @param value treated as a literal constant
*/
withConstant(value: any): ArgumentsResolversBuilder;
/**
* Intent to resolve a Cydran or application {Properties property} value
* @param name property key name
*/
withProperty(name: string): ArgumentsResolversBuilder;
/**
* Intent to resolve a registered object found within one of the Cydran scope contexts
* @param name key of object in the scope context
*/
withScopeItem(name: string): ArgumentsResolversBuilder;
}
export interface Attributes {
extract(element: HTMLElement, name: string): string;
remove(element: HTMLElement, name: string): void;
isEventAttribute(name: string): boolean;
isBehaviorAttribute(name: string): boolean;
extractEventName(name: string): string;
extractBehaviorName(name: string): string;
asTypePrefix(name: string): string;
getPrefix(): string;
}
export interface Behavior<M, E extends HTMLElement | Text, P> extends DigestableSource, Tellable, Messagable {
requestDigestionSources(sources: DigestableSource[]): void;
onInit(context?: any): void;
onMount(): void;
onUnmount(): void;
onRemount(): void;
isFlagged(name: string): boolean;
}
export interface BehaviorAttributeConverters extends SimpleMap<(value: any) => any> {
}
export interface BehaviorsRegistry {
register(name: string, supportedTags: string[], behaviorClass: Type<Behavior<any, HTMLElement | Text, any>>): void;
registerFunction(name: string, supportedTags: string[], behavionFunction: BehaviorFunction): void;
lookup(el: HTMLElement, type: string, tag: string): Type<Behavior<any, HTMLElement, any>>;
}
export interface Builder<T> {
build(): T;
}
export interface ComponentOptions {
metadata?: SimpleMap<any>;
prefix?: string;
}
export interface CydranContext {
getDom(): Dom;
getFactories(): Factories;
logFactory(): LoggerFactory;
idGenerator(): IdGenerator;
getBehaviorsRegistry(): BehaviorsRegistry;
}
export interface DigestableSource extends Tellable {
/**
* Get the digestable source id value
* @returns string id representation
*/
getId(): string;
}
export interface Digester {
digest(): void;
}
export interface DigestionCandidate extends Evaluatable, Notifyable {
getExpression(): string;
}
export interface DigestionCandidateConsumer {
add(key: string, behaviors: DigestionCandidate[]): void;
}
export interface DigestionContext extends DigestionCandidateConsumer {
digest(): Notifyable[];
}
export interface Disposable {
$dispose(): void;
}
/**
* Consistent interface to an HTML DOM representation
*/
export interface Dom {
/**
* Get the document reference
* @returns JS Document object
*/
getDocument(): Document;
/**
* Get the client JS Window reference
* @returns client JS Window object
*/
getWindow(): Window;
/**
* Creates an HTMLElement object
* @param tagName - html tag name
* @returns - a JS HTMLElement<E> object
*/
createElement<E extends HTMLElement>(tagName: string): E;
/**
* Create a comment object
* @param content - text for the comment
* @return - HTML Comment object
*/
createComment(content: string): Comment;
/**
* Create an HTML DocumentFragment object
* @returns - HTML DocumentFragment object
*/
createDocumentFragment(): DocumentFragment;
/**
* Create an HTML Text object
* @param text - HTML Text object for DOM inclusion
* @returns - HTML Text object
*/
createTextNode(text: string): Text;
}
export interface ElementOperations<E extends HTMLElement> {
get(): E;
focus(): void;
blur(): void;
}
export interface Evaluatable {
evaluate(): boolean;
}
export interface Factories {
createDigester(rootSource: DigestableSource, id: string, name: string, maxEvaluations: number): Digester;
createDigestionContext(): DigestionContext;
createSegmentDigester(): SegmentDigester;
}
export interface FieldValidations<C> extends SimpleMap<((field: any, instance: any, context: C) => string)[]> {
}
export interface Filter {
/**
* Get the resulting array of items after the filter has been applied
* @returns array of filtered objects
*/
items(): any[];
/**
* Extend a {Filter filter} instance
* @returns a {FilterBuilder} object
*/
extend(): FilterBuilder;
/**
* Get the inherited {@linkcode LoggerFactory | logger factory } associated with the filter
* @returns
*/
getLoggerFactory(): LoggerFactory;
}
export interface FilterBuilder {
withPredicate(expression: string, ...parameterExpressions: string[]): FilterBuilder;
withPhase(fn: (input: any[]) => any[]): FilterBuilder;
withSimplePredicate(predicate: (index: number, value: any) => boolean): FilterBuilder;
withSort(expression: string, ...parameterExpressions: string[]): FilterBuilder;
withLimit(limit: number): FilterBuilder;
with(fn: (builder: FilterBuilder) => void): FilterBuilder;
build(): Filter;
paged(): PagedFilter;
limited(): LimitOffsetFilter;
}
export interface ForChannelContinuation {
invoke(target: (payload: any) => void): void;
}
export interface FormOperations {
submit(): void;
requestSubmit(): void;
reset(): void;
}
export interface Gettable {
get<T>(id: string): T;
}
export interface InternalComponentOptions extends ComponentOptions {
itemFn?: () => any;
parentModelFn?: () => any;
module?: Module;
alwaysConnected?: boolean;
parent?: Nestable;
name?: string;
}
export interface LimitOffsetFilter extends Filter {
getLimit(): number;
setLimit(limit: number): void;
getOffset(): number;
setOffset(offset: number): void;
setLimitAndOffset(limit: number, offset: number): void;
}
export interface Logger {
/**
* Get the name of the logger
* @returns string
*/
getName(): string;
/**
* Log payload at a "trace" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
trace(payload: any, error?: Error): void;
/**
* Only if log at a "trace" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifTrace(payloadFn: () => any, error?: Error): void;
/**
* Log payload at a "debug" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
debug(payload: any, error?: Error): void;
/**
* Only if log at a "debug" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifDebug(payloadFn: () => any, error?: Error): void;
/**
* Log payload at a "info" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
info(payload: any, error?: Error): void;
/**
* Only if log at a "info" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifInfo(payloadFn: () => any, error?: Error): void;
/**
* Log payload at a "warn" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
warn(payload: any, error?: Error): void;
/**
* Only if log at a "warn" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifWarn(payloadFn: () => any, error?: Error): void;
/**
* Log payload at a "error" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
error(payload: any, error?: Error): void;
/**
* Only if log at a "error" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifError(payloadFn: () => any, error?: Error): void;
/**
* Log payload at a "fatal" level
* @param payload to be written out
* @param error optional if there is an error object with contextual data
*/
fatal(payload: any, error?: Error): void;
/**
* Only if log at a "fatal" level execute fn() to derive payload to log
* @param payloadFn to be written out
* @param error optional if there is an error object with contextual data
*/
ifFatal(payloadFn: () => any, error?: Error): void;
/**
* Attempt logging at specific level if logger level met
* @param payloadFn - anonymous function with return value if conditions met
* @param level - {@linkcode Level | level} to log at
* @param error - optional Error object
*/
ifLog(payloadFn: () => any, level: Level, error?: Error): void;
/**
* Is the log level at least at "trace" level
* @returns boolean
*/
isTrace(): boolean;
/**
* Is the log level at least at "debug" level
* @returns boolean
*/
isDebug(): boolean;
/**
* Is the log level at least at "info" level
* @returns boolean
*/
isInfo(): boolean;
/**
* Is the log level at least at "warn" level
* @returns boolean
*/
isWarn(): boolean;
/**
* Is the log level at least at "error" level
* @returns boolean
*/
isError(): boolean;
/**
* Is the log level at least at "fatal" level
* @returns boolean
*/
isFatal(): boolean;
/**
* Is the log level at least at "disabled" level
* @returns boolean
*/
isDisabled(): boolean;
/**
* Set a custom level for the logger
* @param level {Level} object denoting custom setting
*/
setLevel(level: Level): void;
/**
* Get the current {Level level} for this logger
* @returns a {Level} object
*/
getLevel(): Level;
}
export interface LoggerFactory {
/**
* Get the named {@link Logger | logger}
* @param name of the associated logger
* @param level to log at
* @returns a Logger reference
*/
getLogger(name: string, level?: string, strategy?: OutputStrategy): Logger;
registerOutputStrategy(key: string, strat: OutputStrategy): void;
removeOutputStrategy(key: string): void;
setPrefsForStrategy(key: string, props: Properties): void;
/**
* Set change/modify the log level during runtime.
* Any string not matching a valid level will cause an error message to be generated as long as logging isn't currently set above error
* Valid levels are: trace, debug, info, warn, error, fatal, disabled
* @param level NON-CASESENSITIVE string representation of a qualified level.
* @returns void
*/
updateLevel(level: string): void;
/**
* Get the current level as a string
* @returns string representation of the current logging level
*/
currentLevelAsString(): string;
/**
* Get the current level
* @returns representation of the current logging level
*/
currentLevel(): Level;
/**
* Set the preferences for the logging service
* @param props
*/
setPreferences(props: Properties): void;
}
export interface Machine<M> extends Disposable {
create(model: M): MachineContext<M>;
evaluate(input: string, context: MachineContext<M>, parameter?: any): void;
}
export interface MachineBuilder<M> {
withState(state: string, callbacks: VarConsumer<any, M>[]): MachineBuilder<M>;
withTransition(state: string, input: string, target: string, callbacks: VarConsumer<any, M>[], predicate?: VarPredicate<any, M>): MachineBuilder<M>;
build(): Machine<M>;
}
export interface MachineContext<M> extends Disposable {
getState(): string;
isState(state: string): boolean;
getModel(): M;
}
export interface Mediator<T> extends Disposable, DigestionCandidate, Tellable {
get(): T;
set(value: any): void;
watch(context: any, target: (previous: T, current: T) => void): void;
}
export interface Messagable {
message(channelName: string, messageName: string, payload?: any): void;
}
export interface MetadataContinuation {
has: (name: string) => boolean;
get: (name: string) => any;
}
export interface Module extends Register, Tellable {
getName(): string;
associate(...componentClasses: Type<Nestable>[]): Module;
disassociate(...componentClasses: Type<Nestable>[]): Module;
clear(): Module;
broadcast(channelName: string, messageName: string, payload?: any): void;
broadcastGlobally(channelName: string, messageName: string, payload?: any): void;
message(channelName: string, messageName: string, payload?: any): void;
getDefaultModule(): Module;
getModule(name: string): Module;
expose(id: string): Module;
get<T>(id: string): T;
getLocal<T>(id: string): T;
getScope(): Scope;
hasRegistration(id: string): boolean;
addStrategy(strategy: RegistryStrategy): Module;
getLogger(): Logger;
createPubSubFor(context: any): PubSub;
getProperties(): MutableProperties;
getCydranContext(): CydranContext;
}
export interface MutableProperties extends Properties {
/**
* Set a property value
* @param key - string value
* @param value - any type of object
* @returns
*/
set(key: string, value: any): MutableProperties;
/**
* Load additional properties in
* @param values - any type of object
* @returns
*/
load(values: any): MutableProperties;
/**
* Remove a specific property by key
* @param key - string value
* @returns
*/
remove(key: string): MutableProperties;
/**
* Clear the current properties instance object of all values
* @returns
*/
clear(): MutableProperties;
}
export interface Nestable extends Watchable, Messagable, Tellable {
metadata(): MetadataContinuation;
hasRegion(name: string): boolean;
getChild<N extends Nestable>(name: string): N;
setChild(name: string, component: Nestable): void;
setChildFromRegistry(name: string, componentName: string, defaultComponentName?: string): void;
getParent(): Nestable;
getEl(): HTMLElement;
get<T>(id: string): T;
scope(): Scope;
getPrefix(): string;
isMounted(): boolean;
isConnected(): boolean;
getId(): string;
getProperties(): Properties;
onMount(): void;
onUnmount(): void;
onRemount(): void;
}
export interface Notifyable {
notify(): void;
}
export interface OnContinuation {
invoke(target: (payload: any) => void): void;
forChannel(name: string): ForChannelContinuation;
}
export interface OutputStrategy {
/**
* Log the message
* @param logname name of the log
* @param level {Level} of message
* @param payload message/object to be logged
* @param error optional object or boolean to indicate +/- on whether or not to log the stack/message
*/
log(logname: string, level: Level, payload: any, errorStack?: Error | boolean): void;
/**
* Get the id of the strategy
* @returns
*/
getId(): string;
/**
* Set the preferences for the output strategy
*/
setPreferences(props: Properties): void;
/**
* Set a tag for messages
* @param tag or label of the cydran instance
*/
setTag(tag: string): void;
/**
* Set the visibility of the tag
* @param visible will the tag be visible or not; default of false;
*/
setTagVisibility(visible: boolean): void;
}
export interface PagedFilter extends Filter {
getPageSize(): number;
setPageSize(size: number): void;
getTotalPages(): number;
getPage(): number;
setPage(page: number): void;
toPrevious(): void;
toNext(): void;
toStart(): void;
toEnd(): void;
isAtBeginning(): boolean;
isAtEnd(): boolean;
isMoreBefore(): boolean;
isMoreAfter(): boolean;
}
export interface PropFlagVals {
/**
* Key value of property
*/
key: string;
/**
* If the property is writeable
*/
write: boolean;
/**
* If the property is deletable
*/
delete: boolean;
}
export interface Properties {
/**
* Get the defined property object
* @param key - property key value
* @returns - typed property object
*/
get<T>(key: string): T;
/**
* Meta information about the property
* @param key - string value
* @returns - object of meta-data
*/
attributesOf(key: string): PropFlagVals;
/**
* Get a mutable inheriting child {@link Properties} object
* @returns - properties object
*/
extend(): MutableProperties;
/**
* Is the property indexed at the "key" defined
* @param key - string value
* @returns - property existance
*/
isDefined(key: string): boolean;
/**
* Can the defined property value identified by key be expressed as "truthy"
* @param key - string value
* @returns - is truthy
*/
isTruthy(key: string): boolean;
/**
* Get keys associated with a particular key family prefix; i.e. 'cydran.logging'
* @param key - string value
* @param immuteToo - should keys representing immutable properties be included in the result. The default is false if no argument value is inlcuded (null, undefined)
* @returns - array of property keys matching the equivilant to: value.indexOf(key) === 0
*/
familyGroupKeysFrom(key: string, immuteToo: boolean): string[];
/**
* Get the string representation of the property indicated by the key
* @param key - string value
* @returns - string value representation
*/
getAsString(key: string): string;
}
export interface PubSub extends Disposable {
message(channelName: string, messageName: string, payload?: any): void;
broadcast(channelName: string, messageName: string, payload?: any): void;
broadcastGlobally(channelName: string, messageName: string, payload?: any): void;
on(messageName: string): OnContinuation;
enableGlobal(): void;
disableGlobal(): void;
isGlobalEnabled(): boolean;
}
export interface Register extends Disposable {
registerConstant(id: string, instance: any): any | void;
registerPrototype(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): any | void;
registerPrototypeWithFactory(id: string, factoryFn: () => any, resolvers?: ArgumentsResolvers): any | void;
registerSingleton(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): any | void;
registerSingletonWithFactory(id: string, factoryFn: () => any, resolvers?: ArgumentsResolvers): any | void;
}
export interface RegistryStrategy extends Disposable {
get<T>(id: string, gettable: Gettable): T;
}
export interface Renderer {
render(): HTMLElement;
}
export interface Scope {
add(name: string, item: any): void;
remove(name: string): void;
}
export interface SegmentDigester {
digestSegment(id: string, changedCandidates: DigestionCandidate[], candidates: DigestionCandidate[]): void;
}
export interface SimpleMap<T> {
[key: string]: T;
}
export interface Stage extends Disposable {
setComponent(component: Nestable): Stage;
setComponentFromRegistry(componentName: string, defaultComponentName?: string): void;
get<T>(id: string): T;
start(): Stage;
getModule(name: string): Module;
getDefaultModule(): Module;
forEach(fn: (instace: Module) => void): void;
broadcast(channelName: string, messageName: string, payload?: any): void;
registerConstant(id: string, instance: any): void;
registerPrototype(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void;
registerSingleton(id: string, classInstance: Type<any>, resolvers?: ArgumentsResolvers): void;
getScope(): Scope;
isStarted(): boolean;
getDom(): Dom;
getLoggerFactory(): LoggerFactory;
}
export interface StageBuilder extends Builder<Stage> {
getModule(name: string): Module;
getDefaultModule(): Module;
getLoggerFactory(): LoggerFactory;
forEach(fn: (instace: Module) => void): StageBuilder;
withComponentBefore(id: string, moduleName?: string): StageBuilder;
withComponentAfter(id: string, moduleName?: string): StageBuilder;
withComponent(id: string): StageBuilder;
withInitializer(callback: (stage?: Stage) => void): StageBuilder;
withDisposer(callback: (stage?: Stage) => void): StageBuilder;
withBehavior(name: string, supportedTags: string[], behaviorClass: Type<Behavior<any, HTMLElement | Text, any>>): StageBuilder;
withConstant(id: string, instance: any): StageBuilder;
withProperties(properties: any): StageBuilder;
withPrototype(id: string, classInstance: Type<any>, argumentResolvers?: ArgumentsResolvers): StageBuilder;
withPrototypeFromFactory(id: string, factoryFn: () => any, argumentResolvers?: ArgumentsResolvers): StageBuilder;
withSingleton(id: string, classInstance: Type<any>, argumentResolvers?: ArgumentsResolvers): StageBuilder;
withSingletonFromFactory(id: string, factoryFn: () => any, argumentResolvers?: ArgumentsResolvers): StageBuilder;
withImplicit(id: string, template: string, options?: ComponentOptions): StageBuilder;
withCapability(capability: (builder: StageBuilder) => void): StageBuilder;
withScopeItem(name: string, item: any): StageBuilder;
}
export interface Tellable {
tell(name: string, payload?: any): void;
}
export interface Type<T> extends Function {
new (...args: any[]): T;
}
export interface Watchable {
watch<T>(expression: string, target: (previous: T, current: T) => void, reducerFn?: (input: any) => T, context?: any): void;
evaluate<T>(expression: string): T;
getWatchContext(): any;
}
export as namespace cydran;
export {};