import { Vain } from './vain'; import type { Vacuo } from './metas'; import type { DataLike, MutationLike } from './atoms'; /****************************************************************************************************** * Particles * * Chaos -> Chaos of Datar & Mutator. * * Datar -> Designed to carry the value of Data. * * Mutator -> Designed to carry the transformation of Mutation. ******************************************************************************************************/ /** * Number of particles is finite. Using a `enum` to group them is reasonable. */ export declare enum ParticleType { Chaos = "[particle Chaos]", Datar = "[particle Datar]", Mutator = "[particle Mutator]" } /****************************************************************************************************** * * Particle Predicates * ******************************************************************************************************/ /** * @param target anything * @return { boolean } whether the target is a Particle instance */ export declare const isParticle: (target: any) => target is Particle; /** * @param target anything * @return { boolean } whether the target is a Chaos instance */ export declare const isChaos: (target: any) => target is Chaos; /** * @param target anything * @return { boolean } whether target is a Datar instance */ export declare function isDatar(target: Datar): target is Datar; export declare function isDatar(target: unknown): target is Datar; /** * @param target anything * @return { boolean } whether target is a Mutator instance */ export declare function isMutator

(target: Mutator): target is Mutator; export declare function isMutator

(target: unknown): target is Mutator; /****************************************************************************************************** * * Particle Classes * ******************************************************************************************************/ /** * */ export interface BaseParticleOptions { /** * HP, aka. High Performance */ isHPMode?: boolean; } export declare const DEFAULT_BASE_PARTICLE_OPTIONS: Required; /** * Base particle class. */ export declare abstract class Particle extends Vain { isParticle: true; constructor(); abstract get particleType(): ParticleType; } /** *—————————————————————————————————————————————— Chaos Meta ———————————————————————————————————————————————————— */ /** * */ export declare class Chaos extends Particle { isChaos: true; value: Vacuo; transformation: Vacuo; constructor(); get type(): ParticleType; get particleType(): ParticleType; } /** * Global Chaos instance. * @see {@link Chaos} */ export declare const CHAOS: Chaos; /** *—————————————————————————————————————————————— Datar Meta ———————————————————————————————————————————————————— */ /** * */ export interface DatarOptions extends BaseParticleOptions { } export declare const DEFAULT_DATAR_OPTIONS: Required; /** * mutator of datar's output type should be same as datar's value type. */ declare type MutatorOfDatar = Mutator; declare type ValidMutatorOfDatar = Mutator | Chaos; /** * @return { boolean } whether the target is a valid mutator of datar */ export declare function isValidMutatorOfDatar(target: ValidMutatorOfDatar): target is ValidMutatorOfDatar; export declare function isValidMutatorOfDatar(target: unknown): target is ValidMutatorOfDatar; /** * Designed to carry the value of Data. * * @param [options.isHPMode = true] whether the datar is in HPMode, when in HPMode, * the mutator of datar will always be Chaos. */ export declare class Datar extends Particle { value: V; options: Required; mutator: ValidMutatorOfDatar; constructor(value: V, mutator?: ValidMutatorOfDatar, options?: DatarOptions); get type(): ParticleType; get particleType(): ParticleType; /** * Same as `new Datar()`. */ static of(value: V, mutator?: ValidMutatorOfDatar, options?: DatarOptions): Datar; /** * When we create a new datar instance with `Datar.empty`, its value will be `VACUO` for sure. * But the reason we create a empty datar is to contain some type of value in the future. * The `const someDatar = Datar.empty() as Datar` seems inevitable. * It is advisable to always set a initial value for any type of value. */ static empty(options?: DatarOptions): Datar; get isDatar(): true; get isEmpty(): boolean; /** * @param mutator * @return { Datar } this */ fill(mutator: MutatorOfDatar): this; /** * Rarely used, this method exists to ensure the symmetry of Datar and Mutator. * * @param mutator the mutator to be applied * @param args exists for the symmetry of Mutator.run * @return transformation function of specified mutator */ run>(mutator: M, data?: DataLike, ...args: any[]): M['transformation']; } /** *—————————————————————————————————————————————— Mutator Meta ———————————————————————————————————————————————————— */ /** * */ export declare type TransformationLiftPositions = 'unknown' | 'both' | 'left' | 'right' | 'none'; export interface TransformationLiftOptions { position?: TransformationLiftPositions; } export declare const DEFAULT_TRANSFORMATION_LIFT_OPTIONS: Required; export interface MutatorOptions extends BaseParticleOptions { lift?: TransformationLiftOptions; } export declare const DEFAULT_MUTATOR_OPTIONS: Required; export declare type MutatorTransformation

= (previous: Chaos | Datar

, current: Datar, mutation?: MutationLike, ...contexts: Contexts) => C; declare type DatarOfMutator

= Datar

; declare type ValidDatarOfMutator

= Datar

| Chaos; /** * Predicate whether the target is a valid datar of mutator, i.e. Chaos or Datar. */ export declare function isValidDatarOfMutator

(target: ValidDatarOfMutator): target is ValidDatarOfMutator; export declare function isValidDatarOfMutator

(target: unknown): target is ValidDatarOfMutator; export declare type LiftBothTransformation

= (previous: Vacuo | P, current: C, mutation?: MutationLike, ...contexts: Contexts) => C; export declare type LiftLeftTransformation

= (previous: Vacuo | P, current: Datar, mutation?: MutationLike, ...contexts: Contexts) => C; export declare type LiftRightTransformation

= (previous: Chaos | Datar

, current: C, mutation?: MutationLike, ...contexts: Contexts) => C; export declare type MutatorOriginalTransformationUnion

= MutatorTransformation | LiftBothTransformation | LiftLeftTransformation | LiftRightTransformation; /** * Designed to carry the transformation of Mutation. */ export declare class Mutator

extends Particle { transformation: MutatorTransformation; options: Required; datar: ValidDatarOfMutator; constructor(transformation: MutatorTransformation, datar?: ValidDatarOfMutator

, options?: MutatorOptions); get type(): ParticleType; get particleType(): ParticleType; static of

(transformation: MutatorTransformation, datar?: ValidDatarOfMutator

, options?: MutatorOptions): Mutator; static ofLift

(transformation: MutatorOriginalTransformationUnion, options?: MutatorOptions | TransformationLiftOptions): Mutator; static ofLiftBoth(transformation: LiftBothTransformation, options?: MutatorOptions): Mutator; static ofLiftLeft(transformation: LiftLeftTransformation, options?: MutatorOptions): Mutator; static ofLiftRight(transformation: LiftRightTransformation, options?: MutatorOptions): Mutator; static empty(options?: MutatorOptions): Mutator; get isMutator(): true; get isEmpty(): boolean; /** * Dispatch transformation to correct lift method according to the given options. * * @param transformation * @param [options = DEFAULT_TRANSFORMATION_LIFT_OPTIONS] default to `{ position: 'both' }` */ static lift

(transformation: MutatorOriginalTransformationUnion, options?: TransformationLiftOptions): MutatorTransformation; /** * Automatically unwrap both previous datar & current datar to value. * * @param transformation * @return { AnyFunction } wrapped transformation function */ static liftBoth

(transformation: LiftBothTransformation): MutatorTransformation; /** * Automatically unwrap previous datar to value, keep current datar. * * @param transformation * @return { function } wrapped transformation function */ static liftLeft

(transformation: LiftLeftTransformation): MutatorTransformation; /** * Automatically unwrap current datar to value, keep previous datar. * * @param transformation * @return { function } wrapped transformation function */ static liftRight

(transformation: LiftRightTransformation): MutatorTransformation; /** * @param datar * @return { Mutator } this */ fill(datar: DatarOfMutator): this; /** * Given Atom Flow: Data A -> Mutation -> Data B * * -> Data A is observed by Mutation, Mutation is observed by Data B; * * -> Data A emits a datar, Mutation takes that datar as the 1st parameter of its inner transformation; * * -> Mutation takes datar from Data A, then emits a mutator, Data B will take that mutator; * * -> Data B takes mutator from Mutation, then pass its own datar to that mutator's transformation as the 2nd parameter; * * -> The transformation evaluates while it has both two parameters, the result will be wrapped in a new datar; * * -> The new datar of transformation's evaluate result will be the new datar of Data B. * * @param datar the datar to be passed to the transformation as 2nd parameter * @param args the rest of the arguments (3rd and after) to be passed to the transformation * @return Return type of transformation */ run(datar: Datar, mutation?: MutationLike, ...args: any[]): C; } export {}; //# sourceMappingURL=particles.d.ts.map