Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cerebral

Package Overview
Dependencies
Maintainers
5
Versions
638
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cerebral - npm Package Compare versions

Comparing version 5.0.0-1531254861331 to 5.0.0-1531922479412

26

es/BaseController.js

@@ -11,8 +11,9 @@ 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"); } }; }();

import { cleanPath, ensurePath, forceSerializable, getModule, getProviders, isDeveloping, isObject, isSerializable, throwError } from './utils';
import DebuggerProvider from './providers/Debugger';
import FunctionTree from 'function-tree';
import GetProvider from './providers/Get';
import Module from './Module';
import { ensurePath, isDeveloping, throwError, isSerializable, forceSerializable, isObject, getProviders, getModule, cleanPath } from './utils';
import DebuggerProvider from './providers/Debugger';
import ModuleProvider from './providers/Module';
import GetProvider from './providers/Get';

@@ -44,3 +45,5 @@ /*

_options$returnSequen = options.returnSequencePromise,
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen;
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen,
_options$noRethrow = options.noRethrow,
noRethrow = _options$noRethrow === undefined ? false : _options$noRethrow;

@@ -60,2 +63,3 @@

_this.throwToConsole = throwToConsole;
_this.noRethrow = noRethrow;
_this.returnSequencePromise = returnSequencePromise;

@@ -235,8 +239,12 @@

if (error.execution.isAsync) {
setTimeout(function () {
// If we already catch errors in controller.on('error'), we might not
// want errors to be thrown again.
if (!_this2.noRethrow) {
if (error.execution.isAsync) {
setTimeout(function () {
throw error;
});
} else {
throw error;
});
} else {
throw error;
}
}

@@ -243,0 +251,0 @@ }

@@ -63,3 +63,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; }; }();

_this.version = "5.0.0-1531254861331";
_this.version = "5.0.0-1531922479412";
_this.debuggerWatchMap = {};

@@ -66,0 +66,0 @@ _this.debuggerComputedMap = {};

@@ -43,3 +43,3 @@ export { _runSequence as runSequence };

var isSequence = Array.isArray(sequence) || sequence instanceof Primitive;
var controller = options.controller || new Controller(new Module(Object.assign({}, fixtures, isSequence && { sequences: { sequence: sequence } })));
var controller = options.controller || new Controller(new Module(Object.assign({}, fixtures, isSequence && { sequences: { sequence: sequence } })), { noRethrow: true });
var response = { controller: controller };

@@ -106,3 +106,3 @@

var controller = new Controller(rootModule, options);
var controller = new Controller(rootModule, Object.assign({}, { noRethrow: true }, options));
var model = controller.getModel();

@@ -109,0 +109,0 @@ return {

@@ -9,6 +9,7 @@ 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 { getChangedProps, getStateTreeProp, isComputedValue, noop, throwError } from './utils';
import Reaction from './Reaction';
import { Tag } from 'function-tree';
import { getChangedProps, throwError, getStateTreeProp, noop, isComputedValue } from './utils';
import Watch from './Watch';
import Reaction from './Reaction';

@@ -220,3 +221,3 @@ var View = function (_Watch) {

this.dynamicComputed = [];
return function (tag) {
return Object.assign(function (tag) {
var value = tag.getValue(getters);

@@ -238,3 +239,7 @@

return value;
};
}, {
path: function path(tag) {
return tag.getPath(getters);
}
});
}

@@ -241,0 +246,0 @@ /*

@@ -1,18 +0,18 @@

import { DevTools } from './devtools';
import { DevTools } from './devtools'
import {
IContext as IFunctionTreeContext,
FunctionTree,
Provider as FunctionTreeProvider,
ResolveValue,
TFunctionTreeExecutable,
Primitive
} from 'function-tree';
IContext as IFunctionTreeContext,
FunctionTree,
Provider as FunctionTreeProvider,
ResolveValue,
TFunctionTreeExecutable,
Primitive,
} from 'function-tree'
export { sequence, parallel } from 'function-tree';
export type Sequence = TFunctionTreeExecutable;
export { sequence, parallel } from 'function-tree'
export type Sequence = TFunctionTreeExecutable
export {
IBranchContext,
SequenceFactory as ChainSequenceFactory,
SequenceWithPropsFactory as ChainSequenceWithPropsFactory
} from 'function-tree/fluent';
IBranchContext,
SequenceFactory as ChainSequenceFactory,
SequenceWithPropsFactory as ChainSequenceWithPropsFactory,
} from 'function-tree/fluent'

@@ -30,3 +30,2 @@ /*

/*

@@ -36,33 +35,38 @@ State

export interface StateModel {
concat(path: any, arr: any[]): void;
increment(path: any, amount?: number): void;
get<T = any>(any?: any): T | undefined;
merge(path: any, {}): void;
pop(path: any): void;
push(path: any, value: any): void;
set(path: any, value: any): void;
shift(path: any): void;
splice(path: any, ...args: number[]): void;
toggle(path: any): void;
unset(path: any): void;
unshift(path: any, value: any): void;
concat(path: any, arr: any[]): void
increment(path: any, amount?: number): void
get<T = any>(any?: any): T | undefined
merge(path: any, {}): void
pop(path: any): void
push(path: any, value: any): void
set(path: any, value: any): void
shift(path: any): void
splice(path: any, ...args: number[]): void
toggle(path: any): void
unset(path: any): void
unshift(path: any, value: any): void
}
export interface Store {
concat<T>(path: T, arr: T): void;
increment(path: number, amount?: number): void;
merge<T>(path: T, obj: Partial<T>): void;
pop(path: any[]): void;
push<T>(path: Array<T>, value: T): void;
set<T>(path: T, value: T): void;
shift(path: any[]): void;
splice(path: any[], ...args: number[]): void;
toggle(path: boolean): void;
unset(path: any): void;
unshift<T>(path: Array<T>, value: T): void;
concat<T>(path: T, arr: T): void
increment(path: number, amount?: number): void
merge<T>(path: T, obj: Partial<T>): void
pop(path: any[]): void
push<T>(path: Array<T>, value: T): void
set<T>(path: T, value: T): void
shift(path: any[]): void
splice(path: any[], ...args: number[]): void
toggle(path: boolean): void
unset(path: any): void
unshift<T>(path: Array<T>, value: T): void
}
export interface Get {
<T>(tag: T): T
path<T>(tag: T): string
}
export interface IContext<TProps> extends IFunctionTreeContext<TProps> {
store: Store;
get: <T>(tag: T) => T;
store: Store
get: Get
}

@@ -74,59 +78,62 @@

interface ErrorClass {
new (...args: any[]): any;
new (...args: any[]): any
}
export type SequencesMap = {
[sequenceName: string]: Sequence;
};
[sequenceName: string]: Sequence
}
export interface ModuleObjectDefinition<State, Sequences, Compute> {
state?: State;
sequences?: Sequences;
computed?: Compute;
reactions?: {
[submodule: string]: void;
};
modules?: {
[submodule: string]: ModuleClass;
};
catch?: Function[][];
providers?: {
[providerName: string]: any;
};
state?: State
sequences?: Sequences
computed?: Compute
reactions?: {
[submodule: string]: void
}
modules?: {
[submodule: string]: ModuleDefinition | ModuleClass
}
catch?: Function[][]
providers?: {
[providerName: string]: any
}
}
export interface InstantiatedModuleObjectDefinition {
state?: any;
sequences?: any;
reactions?: {
[submodule: string]: void;
};
modules?: {
[submodule: string]: InstantiatedModuleObjectDefinition;
};
computed?: {
[computed: string]: any;
};
catch?: Function[][];
providers?: {
[providerName: string]: any;
};
state?: any
sequences?: any
reactions?: {
[submodule: string]: void
}
modules?: {
[submodule: string]: InstantiatedModuleObjectDefinition
}
computed?: {
[computed: string]: any
}
catch?: Function[][]
providers?: {
[providerName: string]: any
}
}
export type ModuleFunction<State = {}, Sequences = {}, Compute = {}> = (
module: { name: string; path: string; app: ControllerClass }
) => ModuleObjectDefinition<State, Sequences, Compute>;
module: { name: string; path: string; app: ControllerClass }
) => ModuleObjectDefinition<State, Sequences, Compute>
export type ModuleDefinition<State = {}, Sequences = {}, Compute = {}> =
| ModuleObjectDefinition<State, Sequences, Compute>
| ModuleFunction<State, Sequences, Compute>;
| ModuleObjectDefinition<State, Sequences, Compute>
| ModuleFunction<State, Sequences, Compute>
export class ModuleClass {
// not public API
create(controller: BaseControllerClass, path: string[]): InstantiatedModuleObjectDefinition;
// not public API
create(
controller: BaseControllerClass,
path: string[]
): InstantiatedModuleObjectDefinition
}
export function Module<State = {}, Sequences = {}, Compute = {}>(
moduleDefinition: ModuleDefinition<State, Sequences, Compute>
): ModuleClass;
moduleDefinition: ModuleDefinition<State, Sequences, Compute>
): ModuleClass

@@ -136,3 +143,3 @@ /*

*/
export type RunableSequence<T = any> = (props?: T) => void;
export type RunableSequence<T = any> = (props?: T) => void

@@ -143,44 +150,63 @@ /*

export interface ControllerOptions {
devtools?: DevTools;
throwToConsole?: boolean;
Model?: any;
devtools?: DevTools
throwToConsole?: boolean
noRethrow?: boolean
stateChanges?: any
returnSequencePromise: boolean
Model?: any
}
export interface BaseControllerClass extends FunctionTree {
getModel(): StateModel;
getState(path?: string): any;
getModel(): StateModel
getState(path?: string): any
get<T>(value: T): T
runSequence(name: string, signal: Sequence, payload?: any): void;
getSequence<T = any>(path: string): RunableSequence<T>;
addModule(path: string, module: ModuleClass): void;
removeModule(path: string): void;
runSequence(name: string, signal: Sequence, payload?: any): void
getSequence<T = any>(path: string): RunableSequence<T>
addModule(path: string, module: ModuleClass): void
removeModule(path: string): void
}
export class BaseControllerClass {
model: any;
module: InstantiatedModuleObjectDefinition;
constructor(rootModule: ModuleClass, options: ControllerOptions, functionTreeOptions: any);
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;
constructor(config?: ControllerOptions): void
flush(force: boolean): void
updateComponents(changes: any[], force: boolean): void
}
export function Controller(rootModule: ModuleClass | ModuleDefinition, config?: ControllerOptions): ControllerClass;
export function Controller(
rootModule: ModuleClass | ModuleDefinition,
config?: ControllerOptions
): ControllerClass
export default function App(rootModule: ModuleClass | ModuleDefinition, config?: ControllerOptions): ControllerClass;
export default function App(
rootModule: ModuleClass | ModuleDefinition,
config?: ControllerOptions
): ControllerClass
type ControllerSequence = string | Primitive | Array<Function | Primitive>;
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>;
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;
export function UniversalController(
rootModule: ModuleClass,
config?: ControllerOptions
): UniversalControllerClass
export function UniversalApp(rootModule: ModuleClass, config?: ControllerOptions): UniversalControllerClass;
export function UniversalApp(
rootModule: ModuleClass,
config?: ControllerOptions
): UniversalControllerClass

@@ -190,26 +216,29 @@ /*

*/
export type ValueResolver = <T = any>(tag: ResolveValue<T>) => T;
export type ValueResolver = <T = any>(tag: ResolveValue<T>) => T
export class ComputedInstance<T = any> {
constructor(...args: (any | ValueResolver)[]);
getValue(getters: any): T;
constructor(...args: (any | ValueResolver)[])
getValue(getters: any): T
}
export type ComputedGetter = <T>(arg: T) => T;
export type ComputedGetter = <T>(arg: T) => T
export function Compute<K>(cb: (get: ComputedGetter) => K): K;
export function Compute<K>(cb: (get: ComputedGetter) => K): K
export function Reaction<T, K>(dependencies: T, cb: (dependencies: T & { get: ComputedGetter }) => void): void;
export function Reaction<T, K>(
dependencies: T,
cb: (dependencies: T & { get: ComputedGetter }) => void
): void
export function Provider(provider: any, options?: any): FunctionTreeProvider;
export function Provider(provider: any, options?: any): FunctionTreeProvider
export class View {
constructor(config: any);
constructor(config: any)
}
export class CerebralError {
constructor(message: string, details?: any);
name: string;
details: any;
toJSON: () => any;
constructor(message: string, details?: any)
name: string
details: any
toJSON: () => any
}

@@ -11,2 +11,8 @@ 'use strict';

var _utils = require('./utils');
var _Debugger = require('./providers/Debugger');
var _Debugger2 = _interopRequireDefault(_Debugger);
var _functionTree = require('function-tree');

@@ -16,2 +22,6 @@

var _Get = require('./providers/Get');
var _Get2 = _interopRequireDefault(_Get);
var _Module = require('./Module');

@@ -21,8 +31,2 @@

var _utils = require('./utils');
var _Debugger = require('./providers/Debugger');
var _Debugger2 = _interopRequireDefault(_Debugger);
var _Module3 = require('./providers/Module');

@@ -32,6 +36,2 @@

var _Get = require('./providers/Get');
var _Get2 = _interopRequireDefault(_Get);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -69,3 +69,5 @@

_options$returnSequen = options.returnSequencePromise,
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen;
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen,
_options$noRethrow = options.noRethrow,
noRethrow = _options$noRethrow === undefined ? false : _options$noRethrow;

@@ -85,2 +87,3 @@

_this.throwToConsole = throwToConsole;
_this.noRethrow = noRethrow;
_this.returnSequencePromise = returnSequencePromise;

@@ -260,8 +263,12 @@

if (error.execution.isAsync) {
setTimeout(function () {
// If we already catch errors in controller.on('error'), we might not
// want errors to be thrown again.
if (!_this2.noRethrow) {
if (error.execution.isAsync) {
setTimeout(function () {
throw error;
});
} else {
throw error;
});
} else {
throw error;
}
}

@@ -268,0 +275,0 @@ }

@@ -81,3 +81,3 @@ 'use strict';

_this.version = "5.0.0-1531254861331";
_this.version = "5.0.0-1531922479412";
_this.debuggerWatchMap = {};

@@ -84,0 +84,0 @@ _this.debuggerComputedMap = {};

@@ -67,3 +67,3 @@ 'use strict';

var isSequence = Array.isArray(sequence) || sequence instanceof _functionTree.Primitive;
var controller = options.controller || new _Controller2.default(new _Module2.default(Object.assign({}, fixtures, isSequence && { sequences: { sequence: sequence } })));
var controller = options.controller || new _Controller2.default(new _Module2.default(Object.assign({}, fixtures, isSequence && { sequences: { sequence: sequence } })), { noRethrow: true });
var response = { controller: controller };

@@ -131,3 +131,3 @@

var controller = new _Controller2.default(rootModule, options);
var controller = new _Controller2.default(rootModule, Object.assign({}, { noRethrow: true }, options));
var model = controller.getModel();

@@ -134,0 +134,0 @@ return {

@@ -9,6 +9,10 @@ 'use strict';

var _utils = require('./utils');
var _Reaction = require('./Reaction');
var _Reaction2 = _interopRequireDefault(_Reaction);
var _functionTree = require('function-tree');
var _utils = require('./utils');
var _Watch2 = require('./Watch');

@@ -18,6 +22,2 @@

var _Reaction = require('./Reaction');
var _Reaction2 = _interopRequireDefault(_Reaction);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -236,3 +236,3 @@

this.dynamicComputed = [];
return function (tag) {
return Object.assign(function (tag) {
var value = tag.getValue(getters);

@@ -254,3 +254,7 @@

return value;
};
}, {
path: function path(tag) {
return tag.getPath(getters);
}
});
}

@@ -257,0 +261,0 @@ /*

{
"name": "cerebral",
"version": "5.0.0-1531254861331",
"version": "5.0.0-1531922479412",
"description": "A state controller with its own debugger",

@@ -24,3 +24,3 @@ "main": "index.js",

"es6-error": "^4.0.2",
"function-tree": "^3.3.0-1531254861331"
"function-tree": "^3.3.0-1531922479412"
},

@@ -27,0 +27,0 @@ "scripts": {

@@ -17,3 +17,3 @@ import {

mockRejectedPromise: (path: string, value: any) => SnapshotTest
run: (signal: string, payload: {}) => Promise<any>
run: (sequence: string, payload: {}) => Promise<any>
}

@@ -30,7 +30,7 @@

interface RunSignalResult0<P, T0> {
interface RunSequenceResult0<P, T0> {
'0': RunActionResult<P, T0>
}
interface RunSignalResult1<P, T0, T1> {
interface RunSequenceResult1<P, T0, T1> {
'0': RunActionResult<P, T0>

@@ -40,3 +40,3 @@ '1': RunActionResult<P, T1>

interface RunSignalResult2<P, T0, T1, T2> {
interface RunSequenceResult2<P, T0, T1, T2> {
'0': RunActionResult<P, T0>

@@ -54,16 +54,16 @@ '1': RunActionResult<P, T1>

export function runSignal<P, T0>(
signal: [Action<P, Promise<T0> | T0>],
export function runSequence<P, T0>(
sequence: [Action<P, Promise<T0> | T0>],
fixtures?: { props: P & any } & any,
options?: any
): Promise<RunSignalResult0<P, T0>>
): Promise<RunSequenceResult0<P, T0>>
export function runSignal<P, T0, T1>(
signal: [Action<P, Promise<T0> | T0>, Action<any, Promise<T1> | T1>],
export function runSequence<P, T0, T1>(
sequence: [Action<P, Promise<T0> | T0>, Action<any, Promise<T1> | T1>],
fixtures?: { props: P & any } & any,
options?: any
): Promise<RunSignalResult1<P, T0, T1>>
): Promise<RunSequenceResult1<P, T0, T1>>
export function runSignal<P, T0, T1, T2>(
signal: [
export function runSequence<P, T0, T1, T2>(
sequence: [
Action<P, Promise<T0> | T0>,

@@ -75,6 +75,6 @@ Action<any, Promise<T1> | T1>,

options?: any
): Promise<RunSignalResult2<P, T0, T1, T2>>
): Promise<RunSequenceResult2<P, T0, T1, T2>>
export function runSignal(
signal: Sequence,
export function runSequence(
sequence: Sequence,
fixtures?: any,

@@ -81,0 +81,0 @@ options?: any

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc