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

overmind

Package Overview
Dependencies
Maintainers
4
Versions
886
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overmind - npm Package Compare versions

Comparing version 28.0.2 to 28.0.3-1687088878294

4

es/Devtools.d.ts
import { LogLevel } from './internalTypes';
export declare type Message = {
export type Message = {
type: string;
data?: object;
};
export declare type DevtoolsMessage = {
export type DevtoolsMessage = {
type: string;

@@ -8,0 +8,0 @@ appName: string;

import { IFlushCallback, IMutation, IMutationTree, ITrackStateTree } from 'proxy-state-tree';
import { IAction, IOperator } from './types';
export declare type SubType<Base, Condition> = Pick<Base, {
export type SubType<Base, Condition> = Pick<Base, {
[Key in keyof Base]: Base[Key] extends Condition | undefined ? Key : never;
}[keyof Base]>;
export declare type NestedPartial<T> = T extends Function ? T : Partial<{
export type NestedPartial<T> = T extends Function ? T : Partial<{
[P in keyof T]: NestedPartial<T[P]>;
}>;
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
export declare type Options = {
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
export type Options = {
delimiter?: string;

@@ -20,6 +20,6 @@ name?: string;

};
export declare type DefaultMode = {
export type DefaultMode = {
mode: Symbol;
};
export declare type TestMode = {
export type TestMode = {
mode: Symbol;

@@ -35,3 +35,3 @@ options: {

};
export declare type SSRMode = {
export type SSRMode = {
mode: Symbol;

@@ -54,3 +54,3 @@ };

}
export declare type Execution = {
export type Execution = {
actionId: number;

@@ -138,6 +138,6 @@ executionId: number;

}
declare type NestedActions = {
type NestedActions = {
[key: string]: Function | NestedActions;
};
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? {
export type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? {
[K in keyof T]: ResolveAction<T[K]>;

@@ -144,0 +144,0 @@ } : never;

@@ -7,3 +7,3 @@ import { IMutation } from 'proxy-state-tree';

}
export declare type Serializable = Serialize | {
export type Serializable = Serialize | {
toJSON: () => {

@@ -13,12 +13,12 @@ [SERIALIZE]: boolean;

};
declare type SerializableValue = Serializable | Array<Serializable> | {
type SerializableValue = Serializable | Array<Serializable> | {
[key: string]: Serializable;
} | null;
declare type FilteredKeys<T, U> = {
type FilteredKeys<T, U> = {
[P in keyof T]: T[P] extends U ? P : never;
}[keyof T];
declare type ExcludeNever<T extends {}> = {
type ExcludeNever<T extends {}> = {
[P in keyof T]: T[P] extends never ? never : P;
}[keyof T];
declare type ExtracType<T extends {}, K> = {
type ExtracType<T extends {}, K> = {
[P in FilteredKeys<T, K | {}>]: T[P] extends SerializableValue ? (data: any) => Serializable : T[P] extends {} ? ExtracType<T[P], K> extends {

@@ -28,6 +28,6 @@ [key: string]: never;

};
declare type ExtractDeepType<T extends {}, K, U = ExtracType<T, K>> = {
type ExtractDeepType<T extends {}, K, U extends {} = ExtracType<T, K>> = {
[P in ExcludeNever<U>]: U[P];
};
declare type StateNode = {
type StateNode = {
[key: string]: any;

@@ -34,0 +34,0 @@ };

import { IState } from '.';
declare type TState = {
type TState = {
current: string;
} & TBaseState;
declare type TBaseState = {
type TBaseState = {
[key: string]: IState | Statemachine<any, any, any>;
};
declare type TEvents = {
type TEvents = {
type: string;
data?: any;
};
export declare type StatemachineTransitions<States extends TState, Events extends TEvents, BaseState extends TBaseState> = ([BaseState] extends [never] ? (event: Events, state: States) => States | void : (event: Events, state: States & BaseState) => States | void) | {
export type StatemachineTransitions<States extends TState, Events extends TEvents, BaseState extends TBaseState> = ([BaseState] extends [never] ? (event: Events, state: States) => States | void : (event: Events, state: States & BaseState) => States | void) | {
[State in States['current']]: {

@@ -35,3 +35,3 @@ [Type in Events['type']]?: [BaseState] extends [never] ? ((event: Events extends {

}
export declare type Statemachine<States extends TState, Events extends TEvents, BaseState extends TBaseState = never> = [BaseState] extends [never] ? States & MachineMethods<States, Events, BaseState> : States & BaseState & MachineMethods<States, Events, BaseState>;
export type Statemachine<States extends TState, Events extends TEvents, BaseState extends TBaseState = never> = [BaseState] extends [never] ? States & MachineMethods<States, Events, BaseState> : States & BaseState & MachineMethods<States, Events, BaseState>;
declare const INITIAL_STATE: unique symbol;

@@ -59,3 +59,3 @@ declare const TRANSITIONS: unique symbol;

}
export declare type StatemachineFactory<States extends TState, Events extends TEvents, BaseState extends TBaseState> = [BaseState] extends [never] ? {
export type StatemachineFactory<States extends TState, Events extends TEvents, BaseState extends TBaseState> = [BaseState] extends [never] ? {
create(state: States): Statemachine<States, Events, {}>;

@@ -62,0 +62,0 @@ } : {

@@ -39,13 +39,2 @@ var _a, _b;

export class StateMachine {
constructor(transitions, state, baseState) {
this[_a] = [];
this[_b] = false;
this[STATE] = state;
this[BASE_STATE] = baseState;
this[INITIAL_STATE] = state.current;
this[BASE_STATE] = baseState;
this[TRANSITIONS] = transitions;
this[CURRENT_KEYS] = Object.keys(state);
Object.assign(this, state, baseState);
}
clone() {

@@ -63,2 +52,13 @@ return new StateMachine(this[TRANSITIONS], deepCopy(this[STATE]), deepCopy(this[BASE_STATE]));

}
constructor(transitions, state, baseState) {
this[_a] = [];
this[_b] = false;
this[STATE] = state;
this[BASE_STATE] = baseState;
this[INITIAL_STATE] = state.current;
this[BASE_STATE] = baseState;
this[TRANSITIONS] = transitions;
this[CURRENT_KEYS] = Object.keys(state);
Object.assign(this, state, baseState);
}
send(type, data) {

@@ -65,0 +65,0 @@ if (this[VALUE][IS_DISPOSED]) {

@@ -7,3 +7,3 @@ import { ResolveAction, ContextFunction } from './internalTypes';

export { EventType } from './internalTypes';
export declare type IConfiguration = {
export type IConfiguration = {
state?: {};

@@ -13,6 +13,6 @@ effects?: {};

};
export declare type IState = {
export type IState = {
[key: string]: IState | string | number | boolean | object | null | undefined;
};
export declare type IContext<T extends IConfiguration> = {
export type IContext<T extends IConfiguration> = {
state: T['state'];

@@ -19,0 +19,0 @@ actions: {

@@ -5,3 +5,3 @@ import { IMutation } from 'proxy-state-tree';

actions: any;
}, instance: any) => Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
}, instance: any) => Promise<any[]>;
export declare const ENVIRONMENT: string;

@@ -8,0 +8,0 @@ export declare const IS_TEST: boolean;

@@ -18,3 +18,3 @@ "use strict";

};
const merged = _1.merge(configA, configB);
const merged = (0, _1.merge)(configA, configB);
expect(merged.state.foo).toEqual('bar');

@@ -34,3 +34,3 @@ expect(merged.state.bar).toEqual('baz');

};
const merged = _1.namespaced({ configA, configB });
const merged = (0, _1.namespaced)({ configA, configB });
expect(merged.state.configA.foo).toEqual('bar');

@@ -55,3 +55,3 @@ expect(merged.state.configB.bar).toEqual('baz');

});
const merged = _1.merge({
const merged = (0, _1.merge)({
actions: {

@@ -62,3 +62,3 @@ loadConfigB: ({ actions }) => {

},
}, _1.lazy({ configA, configB }));
}, (0, _1.lazy)({ configA, configB }));
const app = new __1.Overmind(merged);

@@ -88,3 +88,3 @@ return Promise.all([

};
const merged = _1.merge(configA, _1.namespaced({ configB }));
const merged = (0, _1.merge)(configA, (0, _1.namespaced)({ configB }));
expect(merged.state.foo).toEqual('bar');

@@ -100,3 +100,3 @@ expect(merged.state.configB.bar).toEqual('baz');

};
const merged = _1.merge(configA, _1.namespaced({ configB }));
const merged = (0, _1.merge)(configA, (0, _1.namespaced)({ configB }));
expect(merged.state.configB.bar).toEqual('baz');

@@ -115,3 +115,3 @@ });

};
const overmind = __1.createOvermindMock(_1.lazy({
const overmind = (0, __1.createOvermindMock)((0, _1.lazy)({
config: () => Promise.resolve(config),

@@ -118,0 +118,0 @@ }));

@@ -11,3 +11,3 @@ "use strict";

}
if (is_plain_obj_1.default(source[key])) {
if ((0, is_plain_obj_1.default)(source[key])) {
aggr[key] = copy(target[key] || {}, source[key]);

@@ -14,0 +14,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

foo: 'bar',
upperFoo: _1.derived((state) => state.foo.toUpperCase()),
upperFoo: (0, _1.derived)((state) => state.foo.toUpperCase()),
};

@@ -29,3 +29,3 @@ const config = {

foo: 'bar',
upperFoo: _1.derived((state) => state.foo.toUpperCase()),
upperFoo: (0, _1.derived)((state) => state.foo.toUpperCase()),
};

@@ -62,3 +62,3 @@ const actions = {

const addDerived = ({ state }) => {
state.upperFoo = _1.derived((state) => state.foo.toUpperCase());
state.upperFoo = (0, _1.derived)((state) => state.foo.toUpperCase());
};

@@ -100,3 +100,3 @@ const changeFoo = ({ state }) => {

foo: 'bar',
upperFoo: _1.derived(() => function () {
upperFoo: (0, _1.derived)(() => function () {
const state = this[proxy_state_tree_1.PROXY_TREE].state;

@@ -133,3 +133,3 @@ return state.foo.toUpperCase();

foo: 'bar',
upperFoo: _1.derived((state) => state.foo.toUpperCase()),
upperFoo: (0, _1.derived)((state) => state.foo.toUpperCase()),
};

@@ -161,3 +161,3 @@ const actions = {

foo: 'bar',
upperFoo: _1.derived((state) => state.foo.toUpperCase()),
upperFoo: (0, _1.derived)((state) => state.foo.toUpperCase()),
};

@@ -186,3 +186,3 @@ const changeFoo = ({ state }) => {

foo: 'bar',
upperFoo: _1.derived((_, parent) => parent.foo.toUpperCase()),
upperFoo: (0, _1.derived)((_, parent) => parent.foo.toUpperCase()),
};

@@ -209,3 +209,3 @@ const actions = {

foo: 'bar',
upperFoo: _1.derived((parent) => parent.foo.toUpperCase()),
upperFoo: (0, _1.derived)((parent) => parent.foo.toUpperCase()),
},

@@ -240,3 +240,3 @@ };

constructor() {
this.foo = _1.derived((state) => state.bar + '!');
this.foo = (0, _1.derived)((state) => state.bar + '!');
this.bar = 'foo';

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

import { LogLevel } from './internalTypes';
export declare type Message = {
export type Message = {
type: string;
data?: object;
};
export declare type DevtoolsMessage = {
export type DevtoolsMessage = {
type: string;

@@ -8,0 +8,0 @@ appName: string;

@@ -74,3 +74,3 @@ "use strict";

const rehydrateAction = ({ state }, newState) => {
_1.rehydrate(state, newState, {
(0, _1.rehydrate)(state, newState, {
value: StateValue.fromJSON,

@@ -336,3 +336,3 @@ });

};
const config = Object.assign({}, config_1.namespaced({
const config = Object.assign({}, (0, config_1.namespaced)({
foo,

@@ -349,3 +349,3 @@ bar,

const result = [];
const app = new _1.Overmind(config_1.namespaced({
const app = new _1.Overmind((0, config_1.namespaced)({
foo: {

@@ -352,0 +352,0 @@ actions: {

import { IFlushCallback, IMutation, IMutationTree, ITrackStateTree } from 'proxy-state-tree';
import { IAction, IOperator } from './types';
export declare type SubType<Base, Condition> = Pick<Base, {
export type SubType<Base, Condition> = Pick<Base, {
[Key in keyof Base]: Base[Key] extends Condition | undefined ? Key : never;
}[keyof Base]>;
export declare type NestedPartial<T> = T extends Function ? T : Partial<{
export type NestedPartial<T> = T extends Function ? T : Partial<{
[P in keyof T]: NestedPartial<T[P]>;
}>;
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
export declare type Options = {
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
export type Options = {
delimiter?: string;

@@ -20,6 +20,6 @@ name?: string;

};
export declare type DefaultMode = {
export type DefaultMode = {
mode: Symbol;
};
export declare type TestMode = {
export type TestMode = {
mode: Symbol;

@@ -35,3 +35,3 @@ options: {

};
export declare type SSRMode = {
export type SSRMode = {
mode: Symbol;

@@ -54,3 +54,3 @@ };

}
export declare type Execution = {
export type Execution = {
actionId: number;

@@ -138,6 +138,6 @@ executionId: number;

}
declare type NestedActions = {
type NestedActions = {
[key: string]: Function | NestedActions;
};
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? {
export type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? {
[K in keyof T]: ResolveAction<T[K]>;

@@ -144,0 +144,0 @@ } : never;

@@ -21,3 +21,3 @@ "use strict";

};
const overmind = _1.createOvermindMock(config, {
const overmind = (0, _1.createOvermindMock)(config, {
effect(arg) {

@@ -52,3 +52,3 @@ return arg + '!!!';

};
const overmind = _1.createOvermindMock(config, {
const overmind = (0, _1.createOvermindMock)(config, {
effect() {

@@ -82,3 +82,3 @@ return 'bar3';

const config = { state, actions };
const mock = _1.createOvermindMock(config);
const mock = (0, _1.createOvermindMock)(config);
yield mock.actions.updateValue();

@@ -94,3 +94,3 @@ expect(mock.state.valuePlusTwo).toEqual(17);

const config = { state };
const mock = _1.createOvermindMock(config, (state) => {
const mock = (0, _1.createOvermindMock)(config, (state) => {
state.value = 1;

@@ -118,3 +118,3 @@ });

};
const mock = _1.createOvermindMock(config, {
const mock = (0, _1.createOvermindMock)(config, {
foo() {

@@ -121,0 +121,0 @@ return 'bar2';

@@ -7,3 +7,3 @@ "use strict";

function action(operation) {
return createMutationOperator('action', utils_1.getFunctionName(operation), (err, context, value, next) => {
return createMutationOperator('action', (0, utils_1.getFunctionName)(operation), (err, context, value, next) => {
if (err)

@@ -13,3 +13,3 @@ next(err, value);

const result = operation(context, value);
if (utils_1.isPromise(result)) {
if ((0, utils_1.isPromise)(result)) {
next(null, result.then((resolvedValue) => resolvedValue));

@@ -68,3 +68,3 @@ }

const mutationTrees = [];
return Object.assign(Object.assign({}, context), { actions: utils_1.createActionsProxy(context.actions[utils_1.ORIGINAL_ACTIONS] || context.actions, (action) => {
return Object.assign(Object.assign({}, context), { actions: (0, utils_1.createActionsProxy)(context.actions[utils_1.ORIGINAL_ACTIONS] || context.actions, (action) => {
return (value) => action(value, newExecution.isRunning ? newExecution : null);

@@ -71,0 +71,0 @@ }), value, execution: newExecution, effects: context.execution.trackEffects(newExecution), flush: context.parentExecution

@@ -9,3 +9,3 @@ "use strict";

function toUpperCase() {
return operator_1.createOperator('toUpperCase', '', (err, _, value, next) => {
return (0, operator_1.createOperator)('toUpperCase', '', (err, _, value, next) => {
if (err)

@@ -17,3 +17,3 @@ next(err, value);

}
const test = _1.pipe(({ state }) => state.foo, toUpperCase(), ({ state }, val) => {
const test = (0, _1.pipe)(({ state }) => state.foo, toUpperCase(), ({ state }, val) => {
state.foo = val;

@@ -40,3 +40,3 @@ });

function catchError(operation) {
return operator_1.createOperator('catchError', operation.name, (err, _, value, next) => {
return (0, operator_1.createOperator)('catchError', operation.name, (err, _, value, next) => {
if (err)

@@ -48,3 +48,3 @@ next(null, operation(err));

}
const test = _1.pipe(() => {
const test = (0, _1.pipe)(() => {
throw new Error('wut');

@@ -74,3 +74,3 @@ }, () => {

function whenBananaOrApple(paths) {
return operator_1.createOperator('whenBananaOrApple', '', (err, _, value, next) => {
return (0, operator_1.createOperator)('whenBananaOrApple', '', (err, _, value, next) => {
if (err)

@@ -113,3 +113,3 @@ next(err, value);

function changeState(operation) {
return operator_1.createMutationOperator('changeState', operation.name, (err, context, value, next) => {
return (0, operator_1.createMutationOperator)('changeState', operation.name, (err, context, value, next) => {
if (err)

@@ -143,3 +143,3 @@ next(err, value);

function waitForMutation(operation) {
return operator_1.createOperator('waitForMutation', operation.name, (err, context, value, next) => {
return (0, operator_1.createOperator)('waitForMutation', operation.name, (err, context, value, next) => {
if (err)

@@ -161,3 +161,3 @@ next(err, value);

});
const test = _1.pipe(waitForFoo);
const test = (0, _1.pipe)(waitForFoo);
const mutateFoo = ({ state }) => {

@@ -184,3 +184,3 @@ state.foo = 'hihihi';

function waitUntilTrue(operation) {
return operator_1.createOperator('waitUntilTrue', operation.name, (err, context, value, next) => {
return (0, operator_1.createOperator)('waitUntilTrue', operation.name, (err, context, value, next) => {
if (err)

@@ -201,3 +201,3 @@ next(err, value);

const waitForFoo = waitUntilTrue((state) => state.foo.bar === 'hihihi');
const test = _1.pipe(waitForFoo);
const test = (0, _1.pipe)(waitForFoo);
const mutateBar = ({ state }) => {

@@ -204,0 +204,0 @@ state.foo.bar = 'hihihi';

@@ -18,3 +18,3 @@ "use strict";

? operator
: operator_1.action(operator)
: (0, operator_1.action)(operator)
: next;

@@ -46,3 +46,3 @@ try {

? operator
: operator_1.action(operator)
: (0, operator_1.action)(operator)
: (err, finalContext, finalNext, finalFinal) => {

@@ -85,14 +85,14 @@ next(err, Object.assign(Object.assign({}, finalContext), { value: context.value }), finalNext, finalFinal);

if (!evaluatingCount) {
operator_1.operatorStopped(context, results);
next(null, operator_1.createContext(lastContext, results, lastContext.execution.path &&
(0, operator_1.operatorStopped)(context, results);
next(null, (0, operator_1.createContext)(lastContext, results, lastContext.execution.path &&
lastContext.execution.path.slice(0, lastContext.execution.path.length - 1)));
}
};
operator_1.operatorStarted('parallel', '', context);
(0, operator_1.operatorStarted)('parallel', '', context);
operators.forEach((operator, index) => {
lastContext = operator_1.createContext(lastContext || context, context.value, context.execution.path && context.execution.path.concat(String(index)));
const nextWithPath = operator_1.createNextPath(evaluate.bind(undefined, index));
lastContext = (0, operator_1.createContext)(lastContext || context, context.value, context.execution.path && context.execution.path.concat(String(index)));
const nextWithPath = (0, operator_1.createNextPath)(evaluate.bind(undefined, index));
const operatorToRun = operator[utils.IS_OPERATOR]
? operator
: operator_1.action(operator);
: (0, operator_1.action)(operator);
// @ts-ignore

@@ -108,3 +108,3 @@ operatorToRun(null, lastContext, nextWithPath);

function noop() {
return operator_1.createOperator('noop', '', (err, context, value, next) => {
return (0, operator_1.createOperator)('noop', '', (err, context, value, next) => {
if (err)

@@ -118,3 +118,3 @@ next(err, value);

function filter(operation) {
return operator_1.createOperator('filter', utils.getFunctionName(operation), (err, context, value, next, final) => {
return (0, operator_1.createOperator)('filter', utils.getFunctionName(operation), (err, context, value, next, final) => {
if (err)

@@ -130,3 +130,3 @@ next(err, value);

function catchError(operation) {
return operator_1.createMutationOperator('catchError', utils.getFunctionName(operation), (err, context, value, next) => {
return (0, operator_1.createMutationOperator)('catchError', utils.getFunctionName(operation), (err, context, value, next) => {
if (err)

@@ -147,12 +147,12 @@ next(null, operation(context, err));

const evaluateCatch = (err, catchContext) => {
operator_1.operatorStopped(context, context.value);
next(err, operator_1.createContext(catchContext, context.value));
(0, operator_1.operatorStopped)(context, context.value);
next(err, (0, operator_1.createContext)(catchContext, context.value));
};
const evaluateTry = (err, tryContext) => {
if (err) {
const newContext = operator_1.createContext(tryContext, err, context.execution.path && context.execution.path.concat('catch'));
const nextWithPath = operator_1.createNextPath(evaluateCatch);
const newContext = (0, operator_1.createContext)(tryContext, err, context.execution.path && context.execution.path.concat('catch'));
const nextWithPath = (0, operator_1.createNextPath)(evaluateCatch);
const operatorToRun = paths.try[utils.IS_OPERATOR]
? paths.catch
: operator_1.action(paths.catch);
: (0, operator_1.action)(paths.catch);
// @ts-ignore

@@ -162,12 +162,12 @@ operatorToRun(null, newContext, nextWithPath);

else {
operator_1.operatorStopped(context, context.value);
next(null, operator_1.createContext(tryContext, context.value));
(0, operator_1.operatorStopped)(context, context.value);
next(null, (0, operator_1.createContext)(tryContext, context.value));
}
};
operator_1.operatorStarted('tryCatch', '', context);
const newContext = operator_1.createContext(context, context.value, context.execution.path && context.execution.path.concat('try'));
const nextWithPath = operator_1.createNextPath(evaluateTry);
(0, operator_1.operatorStarted)('tryCatch', '', context);
const newContext = (0, operator_1.createContext)(context, context.value, context.execution.path && context.execution.path.concat('try'));
const nextWithPath = (0, operator_1.createNextPath)(evaluateTry);
const operatorToRun = paths.try[utils.IS_OPERATOR]
? paths.try
: operator_1.action(paths.try);
: (0, operator_1.action)(paths.try);
// @ts-ignore

@@ -182,3 +182,3 @@ operatorToRun(null, newContext, nextWithPath);

function fork(key, paths) {
return operator_1.createOperator('fork', String(key), (err, context, value, next) => {
return (0, operator_1.createOperator)('fork', String(key), (err, context, value, next) => {
if (err)

@@ -198,3 +198,3 @@ next(err, value);

function when(operation, paths) {
return operator_1.createOperator('when', utils.getFunctionName(operation), (err, context, value, next) => {
return (0, operator_1.createOperator)('when', utils.getFunctionName(operation), (err, context, value, next) => {
if (err)

@@ -220,3 +220,3 @@ next(err, value);

function wait(ms) {
return operator_1.createOperator('wait', String(ms), (err, context, value, next) => {
return (0, operator_1.createOperator)('wait', String(ms), (err, context, value, next) => {
if (err)

@@ -232,3 +232,3 @@ next(err, value);

let previousFinal;
return operator_1.createOperator('debounce', String(ms), (err, context, value, next, final) => {
return (0, operator_1.createOperator)('debounce', String(ms), (err, context, value, next, final) => {
if (err)

@@ -254,3 +254,3 @@ next(err, value);

let currentNext;
return operator_1.createOperator('throttle', String(ms), (err, context, value, next, final) => {
return (0, operator_1.createOperator)('throttle', String(ms), (err, context, value, next, final) => {
if (err)

@@ -276,3 +276,3 @@ next(err, value);

function waitUntil(operation) {
return operator_1.createOperator('waitUntil', operation.name, (err, context, value, next) => {
return (0, operator_1.createOperator)('waitUntil', operation.name, (err, context, value, next) => {
if (err)

@@ -279,0 +279,0 @@ next(err, value);

@@ -12,3 +12,3 @@ "use strict";

const actions = {
test: _1.pipe(_1.branch((_, value) => value.toUpperCase()), ({ state }, value) => {
test: (0, _1.pipe)((0, _1.branch)((_, value) => value.toUpperCase()), ({ state }, value) => {
state.foo = value;

@@ -31,3 +31,3 @@ }),

const actions = {
test: _1.pipe((_, value) => value.toUpperCase(), ({ state }, value) => {
test: (0, _1.pipe)((_, value) => value.toUpperCase(), ({ state }, value) => {
state.foo = value;

@@ -46,3 +46,3 @@ }),

expect.assertions(1);
const test = _1.pipe((_, value) => Promise.resolve(value.toUpperCase()), ({ state }, value) => {
const test = (0, _1.pipe)((_, value) => Promise.resolve(value.toUpperCase()), ({ state }, value) => {
state.foo = value;

@@ -72,3 +72,3 @@ });

const actions = {
test: _1.parallel(operatorA, operatorB),
test: (0, _1.parallel)(operatorA, operatorB),
};

@@ -84,3 +84,3 @@ const config = {

expect.assertions(1);
const test = _1.pipe(_1.filter((_, value) => value === 'foo'), ({ state }, value) => (state.foo = value.toUpperCase()));
const test = (0, _1.pipe)((0, _1.filter)((_, value) => value === 'foo'), ({ state }, value) => (state.foo = value.toUpperCase()));
const state = {

@@ -102,3 +102,3 @@ foo: 'bar',

test('filter - falsy', () => {
const test = _1.pipe(_1.filter((_, value) => value === 'bar'), ({ state }, value) => (state.foo = value.toUpperCase()));
const test = (0, _1.pipe)((0, _1.filter)((_, value) => value === 'bar'), ({ state }, value) => (state.foo = value.toUpperCase()));
const state = {

@@ -121,3 +121,3 @@ foo: 'bar',

expect.assertions(1);
const test = _1.pipe(() => ({ type: 'foo' }), _1.fork('type', {
const test = (0, _1.pipe)(() => ({ type: 'foo' }), (0, _1.fork)('type', {
foo: () => {

@@ -149,3 +149,3 @@ return 'FOO';

expect.assertions(1);
const test = _1.when(() => true, {
const test = (0, _1.when)(() => true, {
true: ({ state }, value) => {

@@ -175,3 +175,3 @@ state.foo = value.toUpperCase();

const runTime = Date.now();
const test = _1.wait(500);
const test = (0, _1.wait)(500);
const actions = { test };

@@ -188,3 +188,3 @@ const config = {

expect.assertions(1);
const test = _1.pipe(_1.debounce(100), ({ state }) => state.runCount++);
const test = (0, _1.pipe)((0, _1.debounce)(100), ({ state }) => state.runCount++);
const state = {

@@ -207,3 +207,3 @@ runCount: 0,

expect.assertions(1);
const test = _1.pipe(_1.throttle(0), ({ state }) => state.runCount++);
const test = (0, _1.pipe)((0, _1.throttle)(0), ({ state }) => state.runCount++);
const state = {

@@ -226,3 +226,3 @@ runCount: 0,

expect.assertions(3);
const test = _1.pipe((() => {
const test = (0, _1.pipe)((() => {
throw new Error('wut?!?');

@@ -232,3 +232,3 @@ }), ({ state }, payload) => {

return payload;
}, _1.catchError(({ state }, error) => {
}, (0, _1.catchError)(({ state }, error) => {
state.error = error.message;

@@ -260,3 +260,3 @@ return 'hm';

expect.assertions(1);
const test = _1.tryCatch({
const test = (0, _1.tryCatch)({
try: ({ state }, value) => {

@@ -284,3 +284,3 @@ state.foo = value;

expect.assertions(1);
const test = _1.tryCatch({
const test = (0, _1.tryCatch)({
try: (() => {

@@ -310,4 +310,4 @@ throw new Error('ehm');

expect.assertions(1);
const increaseCount = _1.pipe(({ state }) => state.runCount++);
const test = _1.pipe(_1.waitUntil((state) => state.runCount === 1), ({ state }) => (state.hasRun = true));
const increaseCount = (0, _1.pipe)(({ state }) => state.runCount++);
const test = (0, _1.pipe)((0, _1.waitUntil)((state) => state.runCount === 1), ({ state }) => (state.hasRun = true));
const state = {

@@ -314,0 +314,0 @@ runCount: 0,

@@ -336,3 +336,3 @@ "use strict";

}
else if (is_plain_obj_1.default(value)) {
else if ((0, is_plain_obj_1.default)(value)) {
return Object.assign({}, ...Object.keys(value).map((key) => ({

@@ -470,3 +470,3 @@ [key]: this.proxyStateTreeInstance.rescope(value[key], tree),

}
return proxyfyEffects_1.proxifyEffects(this.effects, (effect) => {
return (0, proxyfyEffects_1.proxifyEffects)(this.effects, (effect) => {
let result;

@@ -555,3 +555,3 @@ try {

.reduce((aggr, key) => aggr[key], this.proxyStateTreeInstance.state);
if (is_plain_obj_1.default(value)) {
if ((0, is_plain_obj_1.default)(value)) {
Object.keys(value).forEach((key) => value[key]);

@@ -561,3 +561,3 @@ }

value.forEach((item) => {
if (is_plain_obj_1.default(item)) {
if ((0, is_plain_obj_1.default)(item)) {
Object.keys(item).forEach((key) => item[key]);

@@ -645,3 +645,3 @@ }

// We change the state to match the new structure
rehydrate_1.rehydrate(mutationTree.state, changeMutations);
(0, rehydrate_1.rehydrate)(mutationTree.state, changeMutations);
// We run any mutations ran during the session, it might fail though

@@ -652,3 +652,3 @@ // as the state structure might have changed, but no worries we just

try {
rehydrate_1.rehydrate(mutationTree.state, [mutation]);
(0, rehydrate_1.rehydrate)(mutationTree.state, [mutation]);
}

@@ -655,0 +655,0 @@ catch (error) {

@@ -7,3 +7,3 @@ import { IMutation } from 'proxy-state-tree';

}
export declare type Serializable = Serialize | {
export type Serializable = Serialize | {
toJSON: () => {

@@ -13,12 +13,12 @@ [SERIALIZE]: boolean;

};
declare type SerializableValue = Serializable | Array<Serializable> | {
type SerializableValue = Serializable | Array<Serializable> | {
[key: string]: Serializable;
} | null;
declare type FilteredKeys<T, U> = {
type FilteredKeys<T, U> = {
[P in keyof T]: T[P] extends U ? P : never;
}[keyof T];
declare type ExcludeNever<T extends {}> = {
type ExcludeNever<T extends {}> = {
[P in keyof T]: T[P] extends never ? never : P;
}[keyof T];
declare type ExtracType<T extends {}, K> = {
type ExtracType<T extends {}, K> = {
[P in FilteredKeys<T, K | {}>]: T[P] extends SerializableValue ? (data: any) => Serializable : T[P] extends {} ? ExtracType<T[P], K> extends {

@@ -28,6 +28,6 @@ [key: string]: never;

};
declare type ExtractDeepType<T extends {}, K, U = ExtracType<T, K>> = {
type ExtractDeepType<T extends {}, K, U extends {} = ExtracType<T, K>> = {
[P in ExcludeNever<U>]: U[P];
};
declare type StateNode = {
type StateNode = {
[key: string]: any;

@@ -34,0 +34,0 @@ };

@@ -10,3 +10,3 @@ "use strict";

};
_1.rehydrate(state, {
(0, _1.rehydrate)(state, {
foo: 'bar2',

@@ -23,3 +23,3 @@ });

};
_1.rehydrate(state, [
(0, _1.rehydrate)(state, [
{

@@ -57,3 +57,3 @@ method: 'set',

};
_1.rehydrate(state, {
(0, _1.rehydrate)(state, {
user: {

@@ -91,3 +91,3 @@ name: 'Bob2',

};
_1.rehydrate(state, {
(0, _1.rehydrate)(state, {
users: [

@@ -120,3 +120,3 @@ {

};
_1.rehydrate(state, {
(0, _1.rehydrate)(state, {
users: {

@@ -123,0 +123,0 @@ id1: {

@@ -12,3 +12,3 @@ "use strict";

};
const overmind = _1.createOvermindSSR(config);
const overmind = (0, _1.createOvermindSSR)(config);
overmind.state.foo = 'bar2';

@@ -26,3 +26,3 @@ expect(overmind.state).toEqual({

};
const overmind = _1.createOvermindSSR(config);
const overmind = (0, _1.createOvermindSSR)(config);
overmind.state.foo = 'bar2';

@@ -41,3 +41,3 @@ const mutations = overmind.hydrate();

onInitializeOvermind: ({ state }) => {
_1.rehydrate(state, mutations);
(0, _1.rehydrate)(state, mutations);
},

@@ -49,7 +49,7 @@ };

};
const overmindSsr = _1.createOvermindSSR(config);
const overmindSsr = (0, _1.createOvermindSSR)(config);
overmindSsr.state.foo = 'bar2';
mutations = overmindSsr.hydrate();
const overmind = new _1.Overmind(config);
expect(_1.json(overmind.state)).toEqual({
expect((0, _1.json)(overmind.state)).toEqual({
foo: 'bar2',

@@ -56,0 +56,0 @@ });

import { IState } from '.';
declare type TState = {
type TState = {
current: string;
} & TBaseState;
declare type TBaseState = {
type TBaseState = {
[key: string]: IState | Statemachine<any, any, any>;
};
declare type TEvents = {
type TEvents = {
type: string;
data?: any;
};
export declare type StatemachineTransitions<States extends TState, Events extends TEvents, BaseState extends TBaseState> = ([BaseState] extends [never] ? (event: Events, state: States) => States | void : (event: Events, state: States & BaseState) => States | void) | {
export type StatemachineTransitions<States extends TState, Events extends TEvents, BaseState extends TBaseState> = ([BaseState] extends [never] ? (event: Events, state: States) => States | void : (event: Events, state: States & BaseState) => States | void) | {
[State in States['current']]: {

@@ -35,3 +35,3 @@ [Type in Events['type']]?: [BaseState] extends [never] ? ((event: Events extends {

}
export declare type Statemachine<States extends TState, Events extends TEvents, BaseState extends TBaseState = never> = [BaseState] extends [never] ? States & MachineMethods<States, Events, BaseState> : States & BaseState & MachineMethods<States, Events, BaseState>;
export type Statemachine<States extends TState, Events extends TEvents, BaseState extends TBaseState = never> = [BaseState] extends [never] ? States & MachineMethods<States, Events, BaseState> : States & BaseState & MachineMethods<States, Events, BaseState>;
declare const INITIAL_STATE: unique symbol;

@@ -59,3 +59,3 @@ declare const TRANSITIONS: unique symbol;

}
export declare type StatemachineFactory<States extends TState, Events extends TEvents, BaseState extends TBaseState> = [BaseState] extends [never] ? {
export type StatemachineFactory<States extends TState, Events extends TEvents, BaseState extends TBaseState> = [BaseState] extends [never] ? {
create(state: States): Statemachine<States, Events, {}>;

@@ -62,0 +62,0 @@ } : {

@@ -20,3 +20,3 @@ "use strict";

}
else if (is_plain_obj_1.default(obj)) {
else if ((0, is_plain_obj_1.default)(obj)) {
return Object.keys(obj).reduce((aggr, key) => {

@@ -45,13 +45,2 @@ if (key === '__esModule') {

class StateMachine {
constructor(transitions, state, baseState) {
this[_a] = [];
this[_b] = false;
this[STATE] = state;
this[BASE_STATE] = baseState;
this[INITIAL_STATE] = state.current;
this[BASE_STATE] = baseState;
this[TRANSITIONS] = transitions;
this[CURRENT_KEYS] = Object.keys(state);
Object.assign(this, state, baseState);
}
clone() {

@@ -69,2 +58,13 @@ return new StateMachine(this[TRANSITIONS], deepCopy(this[STATE]), deepCopy(this[BASE_STATE]));

}
constructor(transitions, state, baseState) {
this[_a] = [];
this[_b] = false;
this[STATE] = state;
this[BASE_STATE] = baseState;
this[INITIAL_STATE] = state.current;
this[BASE_STATE] = baseState;
this[TRANSITIONS] = transitions;
this[CURRENT_KEYS] = Object.keys(state);
Object.assign(this, state, baseState);
}
send(type, data) {

@@ -71,0 +71,0 @@ if (this[proxy_state_tree_1.VALUE][IS_DISPOSED]) {

@@ -7,3 +7,3 @@ "use strict";

test('should set initial state', () => {
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {},

@@ -17,7 +17,7 @@ BAR: {},

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
expect(overmind.state.current).toBe('FOO');
});
test('should set base state', () => {
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {},

@@ -33,3 +33,3 @@ BAR: {},

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
expect(overmind.state.current).toBe('FOO');

@@ -39,3 +39,3 @@ expect(overmind.state.foo).toBe('bar');

test('should transition state using function', () => {
const state = statemachine_1.statemachine((_, state) => {
const state = (0, statemachine_1.statemachine)((_, state) => {
return { current: state.current === 'FOO' ? 'BAR' : 'FOO' };

@@ -55,3 +55,3 @@ }).create({

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
overmind.actions.transition();

@@ -61,3 +61,3 @@ expect(overmind.state.current).toBe('BAR');

test('should remove state when transitioning', () => {
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {

@@ -83,3 +83,3 @@ TOGGLE: () => ({ current: 'BAR' }),

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
const fooContext = overmind.state.matches('FOO');

@@ -93,3 +93,3 @@ expect(overmind.state.current).toBe('FOO');

test('should block mutations in strict mode', () => {
const state = statemachine_1.statemachine((_, state) => {
const state = (0, statemachine_1.statemachine)((_, state) => {
if (state.current === 'FOO') {

@@ -116,3 +116,3 @@ return { current: 'BAR' };

};
const overmind = _1.createOvermind(config, {
const overmind = (0, _1.createOvermind)(config, {
devtools: false,

@@ -125,3 +125,3 @@ strict: true,

test('should ignore transition when no state returned', () => {
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {

@@ -146,3 +146,3 @@ TOGGLE: () => { },

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
overmind.actions.transition();

@@ -153,3 +153,3 @@ expect(overmind.state.current).toBe('FOO');

expect.assertions(1);
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {

@@ -172,3 +172,3 @@ TOGGLE: () => ({ current: 'BAR' }),

};
const overmind = _1.createOvermind(config);
const overmind = (0, _1.createOvermind)(config);
overmind.reaction((state) => state.current, (value) => {

@@ -180,3 +180,3 @@ expect(value).toEqual('BAR');

test('should make copy of statemachine during tests', () => {
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {

@@ -202,7 +202,7 @@ TEST: () => { },

};
const overmind = _1.createOvermindMock(config);
const overmind = (0, _1.createOvermindMock)(config);
// @ts-ignore
overmind.actions.changeFoo();
expect(overmind.state.obj.foo).toBe('bar2');
const overmind2 = _1.createOvermindMock(config);
const overmind2 = (0, _1.createOvermindMock)(config);
expect(overmind2.state.obj.foo).toBe('bar');

@@ -212,3 +212,3 @@ });

expect.assertions(1);
const state = statemachine_1.statemachine({
const state = (0, statemachine_1.statemachine)({
FOO: {

@@ -232,3 +232,3 @@ TOGGLE: () => ({ current: 'BAR' }),

};
const overmind = _1.createOvermind(config);
const overmind = (0, _1.createOvermind)(config);
overmind.actions.transition();

@@ -235,0 +235,0 @@ });

@@ -7,3 +7,3 @@ import { ResolveAction, ContextFunction } from './internalTypes';

export { EventType } from './internalTypes';
export declare type IConfiguration = {
export type IConfiguration = {
state?: {};

@@ -13,6 +13,6 @@ effects?: {};

};
export declare type IState = {
export type IState = {
[key: string]: IState | string | number | boolean | object | null | undefined;
};
export declare type IContext<T extends IConfiguration> = {
export type IContext<T extends IConfiguration> = {
state: T['state'];

@@ -19,0 +19,0 @@ actions: {

@@ -5,3 +5,3 @@ import { IMutation } from 'proxy-state-tree';

actions: any;
}, instance: any) => Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
}, instance: any) => Promise<any[]>;
export declare const ENVIRONMENT: string;

@@ -8,0 +8,0 @@ export declare const IS_TEST: boolean;

@@ -45,3 +45,3 @@ "use strict";

const json = (obj) => {
return statemachine_1.deepCopy(obj && obj[proxy_state_tree_1.IS_PROXY] ? obj[proxy_state_tree_1.VALUE] : obj);
return (0, statemachine_1.deepCopy)(obj && obj[proxy_state_tree_1.IS_PROXY] ? obj[proxy_state_tree_1.VALUE] : obj);
};

@@ -67,3 +67,3 @@ exports.json = json;

const value = state[key];
if (is_plain_obj_1.default(value)) {
if ((0, is_plain_obj_1.default)(value)) {
aggr[key] = processState(value);

@@ -75,3 +75,3 @@ }

return aggr;
}, is_plain_obj_1.default(state) ? {} : state);
}, (0, is_plain_obj_1.default)(state) ? {} : state);
}

@@ -99,3 +99,3 @@ exports.processState = processState;

stateBKeys.forEach((key) => {
if (is_plain_obj_1.default(stateA[key]) && is_plain_obj_1.default(stateB[key])) {
if ((0, is_plain_obj_1.default)(stateA[key]) && (0, is_plain_obj_1.default)(stateB[key])) {
getChangeMutations(stateA[key], stateB[key], path.concat(key), mutations);

@@ -102,0 +102,0 @@ }

@@ -13,3 +13,3 @@ "use strict";

};
const copy = utils_1.deepCopy(original);
const copy = (0, utils_1.deepCopy)(original);
copy.value = 15;

@@ -27,3 +27,3 @@ expect(copy.valuePlusTwo).toBe(17);

};
const mutations = utils_1.getChangeMutations(stateA, stateB);
const mutations = (0, utils_1.getChangeMutations)(stateA, stateB);
expect(mutations[0].path).toBe('foo');

@@ -47,3 +47,3 @@ expect(mutations[0].args[0]).toBe('bar2');

};
const mutations = utils_1.getChangeMutations(stateA, stateB);
const mutations = (0, utils_1.getChangeMutations)(stateA, stateB);
expect(mutations.length).toBe(1);

@@ -66,3 +66,3 @@ expect(mutations[0].path).toBe('foo.bar.baz');

};
const mutations = utils_1.getChangeMutations(stateA, stateB);
const mutations = (0, utils_1.getChangeMutations)(stateA, stateB);
expect(mutations.length).toBe(1);

@@ -69,0 +69,0 @@ expect(mutations[0].path).toBe('foo.bar.baz');

{
"name": "overmind",
"version": "28.0.2",
"version": "28.0.3-1687088878294",
"description": "Frictionless state management",

@@ -38,11 +38,11 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>",

"is-plain-obj": "^1.1.0",
"betsy": "1.0.2",
"betsy": "1.0.2-1687088878294",
"tslib": "^2.3.0",
"proxy-state-tree": "6.3.0"
"proxy-state-tree": "6.3.0-1687088878294"
},
"devDependencies": {
"@types/node": "^12.11.6",
"@types/node": "^20.3.1",
"bundlesize": "^0.17.2",
"terser-webpack-plugin": "^1.3.0",
"webpack": "^4.35.0"
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.87.0"
},

@@ -49,0 +49,0 @@ "bundlesize": [

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

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