Comparing version 5.0.0-1514099265786 to 5.0.0-1519463520217
@@ -27,6 +27,6 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
function BaseController(rootModule, options) { | ||
function BaseController(rootModule, options, functionTreeOptions) { | ||
_classCallCheck(this, BaseController); | ||
var _this = _possibleConstructorReturn(this, (BaseController.__proto__ || Object.getPrototypeOf(BaseController)).call(this)); | ||
var _this = _possibleConstructorReturn(this, (BaseController.__proto__ || Object.getPrototypeOf(BaseController)).call(this, {}, functionTreeOptions)); | ||
@@ -39,3 +39,5 @@ var Model = options.Model, | ||
_options$throwToConso = options.throwToConsole, | ||
throwToConsole = _options$throwToConso === undefined ? true : _options$throwToConso; | ||
throwToConsole = _options$throwToConso === undefined ? true : _options$throwToConso, | ||
_options$preventIniti = options.preventInitialize, | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti; | ||
@@ -63,3 +65,5 @@ var getSignal = _this.getSignal; | ||
_this.emit('initialized:model'); | ||
if (!preventInitialize) { | ||
_this.emit('initialized:model'); | ||
} | ||
@@ -85,3 +89,3 @@ _this.contextProviders = Object.assign(_this.contextProviders, getProviders(_this.module), { | ||
if (!_this.devtools && isDeveloping() && typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent)) { | ||
console.warn('You are not using the Cerebral devtools. It is highly recommended to use it in combination with the debugger: http://cerebraljs.com/docs/get_started/debugger.html'); | ||
console.warn('You are not using the Cerebral devtools. It is highly recommended to use it in combination with the debugger: https://cerebraljs.com/docs/introduction/debugger.html'); | ||
} | ||
@@ -111,3 +115,5 @@ | ||
_this.emit('initialized'); | ||
if (!preventInitialize) { | ||
_this.emit('initialized'); | ||
} | ||
return _this; | ||
@@ -198,3 +204,3 @@ } | ||
setTimeout(function () { | ||
throw error; | ||
console.log('Cerebral is handling error "' + error.name + ': ' + error.message + '" thrown by signal "' + error.execution.name + '". Check debugger for more information.'); | ||
}); | ||
@@ -248,2 +254,6 @@ } | ||
if (!signal) { | ||
throwError('The signal on path "' + path + '" does not exist, please check path'); | ||
} | ||
return signal && signal.run; | ||
@@ -250,0 +260,0 @@ } |
@@ -23,3 +23,5 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
return Object.getOwnPropertyNames(this).reduce(function (props, key) { | ||
props[key] = _this2[key]; | ||
if (!['toJSON', 'execution', 'functionDetails'].includes(key)) { | ||
props[key] = _this2[key]; | ||
} | ||
@@ -26,0 +28,0 @@ return props; |
@@ -15,3 +15,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { delay } from '../utils'; | ||
import DevtoolsBase from 'function-tree/lib/devtools/base'; | ||
import { DevtoolsBase } from 'function-tree/devtools'; | ||
var PLACEHOLDER_INITIAL_MODEL = 'PLACEHOLDER_INITIAL_MODEL'; | ||
@@ -60,3 +60,3 @@ var PLACEHOLDER_DEBUGGING_DATA = '$$DEBUGGING_DATA$$'; | ||
_this.version = "5.0.0-1514099265786"; | ||
_this.version = "5.0.0-1519463520217"; | ||
_this.debuggerComponentsMap = {}; | ||
@@ -63,0 +63,0 @@ _this.debuggerComponentDetailsId = 1; |
@@ -1,10 +0,10 @@ | ||
import BaseControllerClass from './BaseController'; | ||
import ControllerClass from './Controller'; | ||
import UniversalControllerClass from './UniversalController'; | ||
import ModuleClass from './Module'; | ||
// Needed to test for instanceof. | ||
export { default as ModuleClass } from './Module'; | ||
export { default as ControllerClass } from './Controller'; | ||
export { default as ProviderClass } from './Provider'; | ||
export { default as BaseControllerClass } from './BaseController'; | ||
export function BaseController(rootModule, options) { | ||
return new BaseControllerClass(rootModule, options); | ||
} | ||
export function Controller(rootModule, options) { | ||
@@ -11,0 +11,0 @@ return new ControllerClass(rootModule, options); |
@@ -6,3 +6,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { throwError } from './utils'; | ||
import { Primitive } from 'function-tree/lib/primitives'; | ||
import { Primitive } from 'function-tree'; | ||
@@ -31,4 +31,4 @@ var Module = function () { | ||
var signal = module.signals[signalKey]; | ||
if (!signal || !Array.isArray(signal) && typeof signal !== 'function' && !(signal instanceof Primitive)) { | ||
throwError('Signal with name "' + signalKey + '" is not correctly defined. Please check that the signal is set to either an array or a function.'); | ||
if (!(signal && (Array.isArray(signal) || typeof signal === 'function' || signal instanceof Primitive))) { | ||
throwError('Signal with name "' + signalKey + '" is not correctly defined. Please check that the signal is either a sequence, an array or a function.'); | ||
} | ||
@@ -35,0 +35,0 @@ currentSignals[signalKey] = { |
@@ -1,17 +0,2 @@ | ||
function waitFactory(ms) { | ||
function wait(_ref) { | ||
var path = _ref.path; | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
return resolve(path ? path.continue() : null); | ||
}, ms); | ||
}); | ||
} | ||
wait.displayName = 'wait - ' + ms + 'ms'; | ||
return wait; | ||
} | ||
export default waitFactory; | ||
export { wait as default } from 'function-tree/factories'; | ||
//# sourceMappingURL=wait.js.map |
export { _runSignal as runSignal }; | ||
import Path from 'function-tree/lib/Path'; | ||
import { Primitive } from 'function-tree/lib/primitives'; | ||
import { Path, Primitive } from 'function-tree'; | ||
import { Controller, Module } from '..'; | ||
import { ensurePath, cleanPath } from '../utils'; | ||
export { default as Snapshot } from './snapshot'; | ||
export function runCompute(compute) { | ||
@@ -89,3 +90,3 @@ var fixtures = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
export function CerebralTest(rootModule) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { throwToConsole: false }; | ||
@@ -92,0 +93,0 @@ var controller = Controller(rootModule, options); |
@@ -15,6 +15,6 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function UniversalController(controllerOptions) { | ||
function UniversalController(rootModule, controllerOptions) { | ||
_classCallCheck(this, UniversalController); | ||
var _this = _possibleConstructorReturn(this, (UniversalController.__proto__ || Object.getPrototypeOf(UniversalController)).call(this, controllerOptions)); | ||
var _this = _possibleConstructorReturn(this, (UniversalController.__proto__ || Object.getPrototypeOf(UniversalController)).call(this, rootModule, controllerOptions)); | ||
@@ -21,0 +21,0 @@ _this.changes = []; |
@@ -315,3 +315,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
if (module[prop]) { | ||
return transform ? transform(Object.assign(extracted, module[prop]), module) : Object.assign(extracted, module[prop]); | ||
var extracedWithGetters = Object.keys(module[prop]).reduce(function (currentExtracted, key) { | ||
var propertyDescriptor = Object.getOwnPropertyDescriptor(module[prop], key); | ||
if (propertyDescriptor && 'get' in propertyDescriptor) { | ||
Object.defineProperty(currentExtracted, key, propertyDescriptor); | ||
} else { | ||
currentExtracted[key] = module[prop][key]; | ||
} | ||
return currentExtracted; | ||
}, extracted); | ||
return transform ? transform(extracedWithGetters, module) : extracedWithGetters; | ||
} | ||
@@ -318,0 +329,0 @@ |
@@ -79,3 +79,5 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
value: function signalGetter(path) { | ||
return this.controller.getSignal(path); | ||
try { | ||
return this.controller.getSignal(path); | ||
} catch (e) {} | ||
} | ||
@@ -329,4 +331,3 @@ /* | ||
var value = _this6.stateGetter(path); | ||
if (path.indexOf('.*') > 0) { | ||
if (path.substr(path.length - 2, 2) === '.*') { | ||
currentProps[key] = value ? Object.keys(value) : []; | ||
@@ -333,0 +334,0 @@ } else { |
134
index.d.ts
@@ -1,4 +0,10 @@ | ||
import { DevTools } from "./devtools" | ||
import { Context, FunctionTree, Payload, Provider, Resolve, ResolveValue, FunctionTreeExecutable} from 'function-tree' | ||
import { DevTools } from './devtools' | ||
import { IContext as IFunctionTreeContext, FunctionTree, IPayload, Provider as FunctionTreeProvider, IResolve, ResolveValue, TFunctionTreeExecutable, Primitive } from 'function-tree' | ||
export { sequence, parallel } from 'function-tree' | ||
export type Sequence = TFunctionTreeExecutable | ||
/* | ||
State | ||
*/ | ||
export interface StateModel { | ||
@@ -19,39 +25,38 @@ concat(path: string, arr: any[]): void | ||
export interface ActionContextBase { | ||
export interface IContext<TProps> extends IFunctionTreeContext<TProps> { | ||
controller: ControllerClass | ||
debugger: any | ||
state: StateModel | ||
} | ||
export type ActionContext<C = { props: any }> = Context<C> & ActionContextBase | ||
export interface Action<C=any,T=void> extends FunctionTreeExecutable { | ||
(context: ActionContext<C>): T | ||
/* | ||
Module | ||
*/ | ||
interface ErrorClass { | ||
new(...args: any[]): any | ||
} | ||
export type ActionFactory<T={}> = (...args: any[]) => Action<T> | ||
interface Paths extends FunctionTreeExecutable { | ||
[path: string]: Chain | ||
export type SignalsMap = { | ||
[signalName: string]: Sequence | ||
} | ||
export type Chain = FunctionTreeExecutable | FunctionTreeExecutable | ||
export type SignalChain = Chain | ||
export type ActionChain = Chain | ||
type SignalsMap = { | ||
[signalName: string]: SignalChain | ||
export interface ModuleObjectDefinition<State, Signals> { | ||
state?: State | ||
signals?: Signals | ||
modules?: { | ||
[submodule: string]: ModuleClass | ||
} | ||
catch?: [ ErrorClass, Sequence ][] | ||
providers?: { | ||
[providerName: string]: any | ||
} | ||
} | ||
interface ErrorClass { | ||
new(...args: any[]): any | ||
} | ||
interface ModuleObject { | ||
export interface InstantiatedModuleObjectDefinition { | ||
state?: any | ||
signals?: SignalsMap | ||
signals?: any | ||
modules?: { | ||
[submodule: string]: ModuleClass | ||
[submodule: string]: InstantiatedModuleObjectDefinition | ||
} | ||
catch?: [ ErrorClass, SignalChain ][] | ||
catch?: [ ErrorClass, Sequence ][] | ||
providers?: { | ||
@@ -62,28 +67,31 @@ [providerName: string]: any | ||
type ModuleFunction = (module: {name: string, path: string, controller: ControllerClass}) => ModuleObject | ||
type ModuleFunction<State, Signals> = (module: {name: string, path: string, controller: ControllerClass}) => ModuleObjectDefinition<State, Signals> | ||
export type ModuleDefinition = ModuleObject | ModuleFunction | ||
export type ModuleDefinition<State, Signals> = ModuleObjectDefinition<State, Signals> | ModuleFunction<State, Signals> | ||
export interface ModuleClass { | ||
export class ModuleClass { | ||
// not public API | ||
create(controller: ControllerClass, path: string): void | ||
create(controller: BaseControllerClass, path: string[]): InstantiatedModuleObjectDefinition | ||
} | ||
export function Module(moduleDefinition: ModuleDefinition): ModuleClass | ||
export function Module<State = {}, Signals = {}>(moduleDefinition: ModuleDefinition<State, Signals>): ModuleClass | ||
/* | ||
Connect | ||
*/ | ||
export type Signal<T=any> = (props?: T) => void | ||
/* | ||
Controller | ||
*/ | ||
export interface ControllerOptions { | ||
devtools?: DevTools | ||
// Model | ||
throwToConsole?: boolean | ||
Model?: any | ||
} | ||
export interface ControllerClass extends FunctionTree { | ||
constructor(config?: ControllerOptions): void | ||
flush(force: boolean): void | ||
updateComponents(changes: any[], force: boolean): void | ||
export interface BaseControllerClass extends FunctionTree { | ||
getModel(): StateModel | ||
getState(path?: string): any | ||
runSignal(name: string, signal: SignalChain, payload: any): void | ||
runSignal(name: string, signal: Sequence, payload: any): void | ||
getSignal<T=any>(path: string): Signal<T> | ||
@@ -96,7 +104,32 @@ // Not sure this is used anymore | ||
export class BaseControllerClass { | ||
model: any | ||
module: InstantiatedModuleObjectDefinition | ||
constructor (rootModule: ModuleClass, options: ControllerOptions, functionTreeOptions: any) | ||
} | ||
interface ControllerClass extends BaseControllerClass { | ||
constructor(config?: ControllerOptions): void | ||
flush(force: boolean): void | ||
updateComponents(changes: any[], force: boolean): void | ||
} | ||
export function Controller(rootModule: ModuleClass, config?: ControllerOptions): ControllerClass | ||
type ControllerSequence = string | Primitive | Array<Function | Primitive> | ||
export interface UniversalControllerClass extends ControllerClass { | ||
setState(path: string, value: any): void | ||
getChanges(): {[path: string]: any} | ||
getScript(): string | ||
runSequence(sequence: ControllerSequence, payload: any): Promise<any> | ||
} | ||
export function UniversalController(rootModule: ModuleClass, config?: ControllerOptions): UniversalControllerClass | ||
/* | ||
Computed | ||
*/ | ||
export type ValueResolver = <T=any>(tag: ResolveValue<T>) => T | ||
export class Computed<T=any> implements FunctionTreeExecutable { | ||
export class Computed<T=any> { | ||
constructor(...args: (any|ValueResolver)[]) | ||
@@ -106,7 +139,7 @@ getValue(getters: any): T | ||
export function compute<A,T>( | ||
export function Compute<A,T>( | ||
arg1: ResolveValue<A>, | ||
fn: (arg1: A, get: ValueResolver) => T | ||
): Computed<T> | ||
export function compute<A,B,T>( | ||
export function Compute<A,B,T>( | ||
arg1: ResolveValue<A>, | ||
@@ -116,3 +149,3 @@ arg2: ResolveValue<B>, | ||
): Computed<T> | ||
export function compute<A,B,C,T>( | ||
export function Compute<A,B,C,T>( | ||
arg1: ResolveValue<A>, | ||
@@ -124,11 +157,16 @@ arg2: ResolveValue<B>, | ||
export function compute<A,B,T>(value1: ResolveValue<A> | A, value2: ResolveValue<B> | B, fn: ( value1: A, value2: B ) => T ): Computed<T> | ||
export function compute<A,T>(value1: ResolveValue<A> | A, fn: ( value1: A ) => T ): Computed<T> | ||
export function compute<T=any>(...args: any[]): Computed<T> | ||
export function provide(name: string, provider: any): Provider | ||
export function Compute<A,B,T>(value1: ResolveValue<A> | A, value2: ResolveValue<B> | B, fn: ( value1: A, value2: B ) => T ): Computed<T> | ||
export function Compute<A,T>(value1: ResolveValue<A> | A, fn: ( value1: A ) => T ): Computed<T> | ||
export function Compute<T=any>(...args: any[]): Computed<T> | ||
export function Provider(provider: any, options?: any): FunctionTreeProvider | ||
export { sequence, parallel } from 'function-tree' | ||
export class View { | ||
constructor(config:any) | ||
constructor(config:any) | ||
} | ||
export class CerebralError { | ||
constructor(message: string, details?: any); | ||
name: string; | ||
details: any; | ||
toJSON: () => any; | ||
} |
@@ -46,6 +46,6 @@ 'use strict'; | ||
function BaseController(rootModule, options) { | ||
function BaseController(rootModule, options, functionTreeOptions) { | ||
_classCallCheck(this, BaseController); | ||
var _this = _possibleConstructorReturn(this, (BaseController.__proto__ || Object.getPrototypeOf(BaseController)).call(this)); | ||
var _this = _possibleConstructorReturn(this, (BaseController.__proto__ || Object.getPrototypeOf(BaseController)).call(this, {}, functionTreeOptions)); | ||
@@ -58,3 +58,5 @@ var Model = options.Model, | ||
_options$throwToConso = options.throwToConsole, | ||
throwToConsole = _options$throwToConso === undefined ? true : _options$throwToConso; | ||
throwToConsole = _options$throwToConso === undefined ? true : _options$throwToConso, | ||
_options$preventIniti = options.preventInitialize, | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti; | ||
@@ -82,3 +84,5 @@ var getSignal = _this.getSignal; | ||
_this.emit('initialized:model'); | ||
if (!preventInitialize) { | ||
_this.emit('initialized:model'); | ||
} | ||
@@ -104,3 +108,3 @@ _this.contextProviders = Object.assign(_this.contextProviders, (0, _utils.getProviders)(_this.module), { | ||
if (!_this.devtools && (0, _utils.isDeveloping)() && typeof navigator !== 'undefined' && /Chrome/.test(navigator.userAgent)) { | ||
console.warn('You are not using the Cerebral devtools. It is highly recommended to use it in combination with the debugger: http://cerebraljs.com/docs/get_started/debugger.html'); | ||
console.warn('You are not using the Cerebral devtools. It is highly recommended to use it in combination with the debugger: https://cerebraljs.com/docs/introduction/debugger.html'); | ||
} | ||
@@ -130,3 +134,5 @@ | ||
_this.emit('initialized'); | ||
if (!preventInitialize) { | ||
_this.emit('initialized'); | ||
} | ||
return _this; | ||
@@ -217,3 +223,3 @@ } | ||
setTimeout(function () { | ||
throw error; | ||
console.log('Cerebral is handling error "' + error.name + ': ' + error.message + '" thrown by signal "' + error.execution.name + '". Check debugger for more information.'); | ||
}); | ||
@@ -267,2 +273,6 @@ } | ||
if (!signal) { | ||
(0, _utils.throwError)('The signal on path "' + path + '" does not exist, please check path'); | ||
} | ||
return signal && signal.run; | ||
@@ -269,0 +279,0 @@ } |
@@ -33,3 +33,5 @@ 'use strict'; | ||
return Object.getOwnPropertyNames(this).reduce(function (props, key) { | ||
props[key] = _this2[key]; | ||
if (!['toJSON', 'execution', 'functionDetails'].includes(key)) { | ||
props[key] = _this2[key]; | ||
} | ||
@@ -36,0 +38,0 @@ return props; |
@@ -22,8 +22,4 @@ 'use strict'; | ||
var _base = require('function-tree/lib/devtools/base'); | ||
var _devtools = require('function-tree/devtools'); | ||
var _base2 = _interopRequireDefault(_base); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -82,3 +78,3 @@ | ||
_this.version = "5.0.0-1514099265786"; | ||
_this.version = "5.0.0-1519463520217"; | ||
_this.debuggerComponentsMap = {}; | ||
@@ -375,3 +371,3 @@ _this.debuggerComponentDetailsId = 1; | ||
return Devtools; | ||
}(_base2.default); | ||
}(_devtools.DevtoolsBase); | ||
//# sourceMappingURL=index.js.map |
@@ -6,4 +6,39 @@ 'use strict'; | ||
}); | ||
exports.throwError = exports.createDummyController = exports.View = exports.parallel = exports.sequence = exports.Compute = exports.Provider = exports.CerebralError = undefined; | ||
exports.BaseController = BaseController; | ||
exports.throwError = exports.createDummyController = exports.View = exports.parallel = exports.sequence = exports.Compute = exports.Provider = exports.CerebralError = exports.BaseControllerClass = exports.ProviderClass = exports.ControllerClass = exports.ModuleClass = undefined; | ||
var _Module = require('./Module'); | ||
Object.defineProperty(exports, 'ModuleClass', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_Module).default; | ||
} | ||
}); | ||
var _Controller = require('./Controller'); | ||
Object.defineProperty(exports, 'ControllerClass', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_Controller).default; | ||
} | ||
}); | ||
var _Provider = require('./Provider'); | ||
Object.defineProperty(exports, 'ProviderClass', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_Provider).default; | ||
} | ||
}); | ||
var _BaseController = require('./BaseController'); | ||
Object.defineProperty(exports, 'BaseControllerClass', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_BaseController).default; | ||
} | ||
}); | ||
exports.Controller = Controller; | ||
@@ -21,5 +56,2 @@ exports.UniversalController = UniversalController; | ||
}); | ||
var _Provider = require('./Provider'); | ||
Object.defineProperty(exports, 'Provider', { | ||
@@ -80,8 +112,2 @@ enumerable: true, | ||
var _BaseController = require('./BaseController'); | ||
var _BaseController2 = _interopRequireDefault(_BaseController); | ||
var _Controller = require('./Controller'); | ||
var _Controller2 = _interopRequireDefault(_Controller); | ||
@@ -93,4 +119,2 @@ | ||
var _Module = require('./Module'); | ||
var _Module2 = _interopRequireDefault(_Module); | ||
@@ -100,6 +124,2 @@ | ||
function BaseController(rootModule, options) { | ||
return new _BaseController2.default(rootModule, options); | ||
} | ||
function Controller(rootModule, options) { | ||
@@ -106,0 +126,0 @@ return new _Controller2.default(rootModule, options); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
var _primitives = require('function-tree/lib/primitives'); | ||
var _functionTree = require('function-tree'); | ||
@@ -38,4 +38,4 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var signal = module.signals[signalKey]; | ||
if (!signal || !Array.isArray(signal) && typeof signal !== 'function' && !(signal instanceof _primitives.Primitive)) { | ||
(0, _utils.throwError)('Signal with name "' + signalKey + '" is not correctly defined. Please check that the signal is set to either an array or a function.'); | ||
if (!(signal && (Array.isArray(signal) || typeof signal === 'function' || signal instanceof _functionTree.Primitive))) { | ||
(0, _utils.throwError)('Signal with name "' + signalKey + '" is not correctly defined. Please check that the signal is either a sequence, an array or a function.'); | ||
} | ||
@@ -42,0 +42,0 @@ currentSignals[signalKey] = { |
@@ -6,18 +6,11 @@ 'use strict'; | ||
}); | ||
function waitFactory(ms) { | ||
function wait(_ref) { | ||
var path = _ref.path; | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
return resolve(path ? path.continue() : null); | ||
}, ms); | ||
}); | ||
var _factories = require('function-tree/factories'); | ||
Object.defineProperty(exports, 'default', { | ||
enumerable: true, | ||
get: function get() { | ||
return _factories.wait; | ||
} | ||
wait.displayName = 'wait - ' + ms + 'ms'; | ||
return wait; | ||
} | ||
exports.default = waitFactory; | ||
}); | ||
//# sourceMappingURL=wait.js.map |
@@ -6,3 +6,12 @@ 'use strict'; | ||
}); | ||
exports.runSignal = undefined; | ||
exports.runSignal = exports.Snapshot = undefined; | ||
var _snapshot = require('./snapshot'); | ||
Object.defineProperty(exports, 'Snapshot', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_snapshot).default; | ||
} | ||
}); | ||
exports.runCompute = runCompute; | ||
@@ -12,8 +21,4 @@ exports.CerebralTest = CerebralTest; | ||
var _Path = require('function-tree/lib/Path'); | ||
var _functionTree = require('function-tree'); | ||
var _Path2 = _interopRequireDefault(_Path); | ||
var _primitives = require('function-tree/lib/primitives'); | ||
var _ = require('..'); | ||
@@ -51,3 +56,3 @@ | ||
var recordActions = options.recordActions && options.recordActions === 'byName' ? 'name' : 'functionIndex'; | ||
var isSignal = Array.isArray(signal) || signal instanceof _primitives.Primitive; | ||
var isSignal = Array.isArray(signal) || signal instanceof _functionTree.Primitive; | ||
var controller = options.controller || (0, _.Controller)((0, _.Module)(Object.assign({}, fixtures, isSignal && { signals: { signal: signal } }))); | ||
@@ -68,7 +73,7 @@ var response = { controller: controller }; | ||
var actionEnd = function actionEnd(execution, funcDetails, payload, result) { | ||
if (!result || result instanceof _Path2.default && !result.payload) { | ||
if (!result || result instanceof _functionTree.Path && !result.payload) { | ||
return; | ||
} | ||
if (options.singleAction || response[funcDetails[recordActions]]) { | ||
var output = result instanceof _Path2.default ? result.payload : result; | ||
var output = result instanceof _functionTree.Path ? result.payload : result; | ||
if (options.singleAction) { | ||
@@ -110,3 +115,3 @@ response.output = output; | ||
function CerebralTest(rootModule) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { throwToConsole: false }; | ||
@@ -113,0 +118,0 @@ var controller = (0, _.Controller)(rootModule, options); |
@@ -26,6 +26,6 @@ 'use strict'; | ||
function UniversalController(controllerOptions) { | ||
function UniversalController(rootModule, controllerOptions) { | ||
_classCallCheck(this, UniversalController); | ||
var _this = _possibleConstructorReturn(this, (UniversalController.__proto__ || Object.getPrototypeOf(UniversalController)).call(this, controllerOptions)); | ||
var _this = _possibleConstructorReturn(this, (UniversalController.__proto__ || Object.getPrototypeOf(UniversalController)).call(this, rootModule, controllerOptions)); | ||
@@ -32,0 +32,0 @@ _this.changes = []; |
@@ -344,3 +344,14 @@ 'use strict'; | ||
if (module[prop]) { | ||
return transform ? transform(Object.assign(extracted, module[prop]), module) : Object.assign(extracted, module[prop]); | ||
var extracedWithGetters = Object.keys(module[prop]).reduce(function (currentExtracted, key) { | ||
var propertyDescriptor = Object.getOwnPropertyDescriptor(module[prop], key); | ||
if (propertyDescriptor && 'get' in propertyDescriptor) { | ||
Object.defineProperty(currentExtracted, key, propertyDescriptor); | ||
} else { | ||
currentExtracted[key] = module[prop][key]; | ||
} | ||
return currentExtracted; | ||
}, extracted); | ||
return transform ? transform(extracedWithGetters, module) : extracedWithGetters; | ||
} | ||
@@ -347,0 +358,0 @@ |
@@ -91,3 +91,5 @@ 'use strict'; | ||
value: function signalGetter(path) { | ||
return this.controller.getSignal(path); | ||
try { | ||
return this.controller.getSignal(path); | ||
} catch (e) {} | ||
} | ||
@@ -341,4 +343,3 @@ /* | ||
var value = _this6.stateGetter(path); | ||
if (path.indexOf('.*') > 0) { | ||
if (path.substr(path.length - 2, 2) === '.*') { | ||
currentProps[key] = value ? Object.keys(value) : []; | ||
@@ -345,0 +346,0 @@ } else { |
import { Tag } from '../tags' | ||
import { Action } from '../' | ||
export { debounce } from 'function-tree/factories' | ||
export function concat(target: Tag, value: Tag | any[]): Action | ||
export function increment(target: Tag, amount?: Tag | number): Action | ||
export function merge(target: Tag, value: Tag | any): Action | ||
export function pop(target: Tag): Action | ||
export function push(target: Tag, value: Tag | any): Action | ||
export function set(target: Tag, value: Tag | any): Action | ||
export function shift(target: Tag): Action | ||
export function splice(target: Tag, start: number, deleteCount?: number): Action | ||
export function toggle(target: Tag): Action | ||
export function unset(target: Tag): Action | ||
export function unshift(target: Tag): Action | ||
export function concat(target: Tag, value: Tag | any[]): Function | ||
export function increment(target: Tag, amount?: Tag | number): Function | ||
export function merge(target: Tag, value: Tag | any): Function | ||
export function pop(target: Tag): Function | ||
export function push(target: Tag, value: Tag | any): Function | ||
export function set(target: Tag, value: Tag | any): Function | ||
export function shift(target: Tag): Function | ||
export function splice(target: Tag, start: number, deleteCount?: number): Function | ||
export function toggle(target: Tag): Function | ||
export function unset(target: Tag): Function | ||
export function unshift(target: Tag): Function | ||
export function equals(value: Tag): Action | ||
export function wait(time: number): Action | ||
export function when(value: Tag): Action | ||
export function when<A>(value: Tag<A> | A, check: (value: A) => boolean): Action | ||
export function when<A,B>(value1: Tag<A> | A, value2: Tag<B> | B, check: (value1: A, value2: B) => boolean): Action | ||
export function equals(value: Tag): Function | ||
export function wait(time: number): Function | ||
export function when(value: Tag): Function | ||
export function when<A>(value: Tag<A> | A, check: (value: A) => boolean): Function | ||
export function when<A,B>(value1: Tag<A> | A, value2: Tag<B> | B, check: (value1: A, value2: B) => boolean): Function | ||
export function when<A,B,C>( | ||
@@ -27,3 +26,3 @@ value1: Tag<A> | A, | ||
check: (value1: A, value2: B, value3: C) => boolean | ||
): Action | ||
export function when(value: Tag, ...args: any[]): Action | ||
): Function | ||
export function when(value: Tag, ...args: any[]): Function |
{ | ||
"name": "cerebral", | ||
"version": "5.0.0-1514099265786", | ||
"version": "5.0.0-1519463520217", | ||
"description": "A state controller with its own debugger", | ||
@@ -21,6 +21,6 @@ "main": "index.js", | ||
}, | ||
"homepage": "http://cerebral.github.io/cerebral-website", | ||
"homepage": "https://www.cerebraljs.com", | ||
"dependencies": { | ||
"es6-error": "^4.0.2", | ||
"function-tree": "^4.0.0-1514099265786" | ||
"function-tree": "^4.0.0-1519463520217" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -1,3 +0,5 @@ | ||
import { Action, Computed, ControllerClass, SignalChain, ControllerOptions } from '../' | ||
import { Computed, ControllerClass, SignalChain, ControllerOptions } from '../' | ||
type Action<P, T> = (context: { props: P }) => T | ||
export interface RunActionResult<P, T> { | ||
@@ -4,0 +6,0 @@ controller: ControllerClass |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
655958
181
6530
1