preps for release
This commit is contained in:
parent
ed50c9dab9
commit
52649b6b07
3
Changes
3
Changes
@ -1,5 +1,8 @@
|
|||||||
# Revision history for Updux
|
# Revision history for Updux
|
||||||
|
|
||||||
|
0.2.0 2019-10-24
|
||||||
|
- Converted everything to Typescript.
|
||||||
|
|
||||||
0.1.0 2019-10-22
|
0.1.0 2019-10-22
|
||||||
- Add 'actions' in the config.
|
- Add 'actions' in the config.
|
||||||
|
|
||||||
|
2
dist/actions.test.d.ts
vendored
Normal file
2
dist/actions.test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {};
|
||||||
|
//# sourceMappingURL=actions.test.d.ts.map
|
1
dist/actions.test.d.ts.map
vendored
Normal file
1
dist/actions.test.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"actions.test.d.ts","sourceRoot":"","sources":["../src/actions.test.ts"],"names":[],"mappings":""}
|
85
dist/actions.test.js
vendored
85
dist/actions.test.js
vendored
@ -1,60 +1,37 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
var _ = _interopRequireDefault(require("."));
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var _updeep = _interopRequireDefault(require("updeep"));
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const _1 = __importDefault(require("."));
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
const noopEffect = () => () => () => { };
|
||||||
|
|
||||||
test('actions defined in effects and mutations, multi-level', () => {
|
test('actions defined in effects and mutations, multi-level', () => {
|
||||||
const {
|
const { actions } = _1.default({
|
||||||
actions
|
|
||||||
} = (0, _.default)({
|
|
||||||
effects: {
|
|
||||||
foo: api => next => action => {}
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
bar: () => () => null
|
|
||||||
},
|
|
||||||
subduxes: {
|
|
||||||
mysub: {
|
|
||||||
effects: {
|
effects: {
|
||||||
baz: api => next => action => {}
|
foo: noopEffect,
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: { bar: () => () => null },
|
||||||
quux: () => () => null
|
subduxes: {
|
||||||
|
mysub: {
|
||||||
|
effects: { baz: noopEffect },
|
||||||
|
mutations: { quux: () => () => null },
|
||||||
|
actions: {
|
||||||
|
foo: (limit) => ({ limit }),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
myothersub: {
|
||||||
|
effects: {
|
||||||
|
foo: noopEffect,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
});
|
||||||
foo: limit => ({
|
const types = Object.keys(actions);
|
||||||
limit
|
types.sort();
|
||||||
})
|
expect(types).toEqual(['bar', 'baz', 'foo', 'quux']);
|
||||||
}
|
expect(actions.bar()).toEqual({ type: 'bar' });
|
||||||
},
|
expect(actions.bar('xxx')).toEqual({ type: 'bar', payload: 'xxx' });
|
||||||
myothersub: {
|
expect(actions.bar(undefined, 'yyy')).toEqual({ type: 'bar', meta: 'yyy' });
|
||||||
effects: {
|
expect(actions.foo(12)).toEqual({ type: 'foo', payload: { limit: 12 } });
|
||||||
foo: () => () => () => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const types = Object.keys(actions);
|
|
||||||
types.sort();
|
|
||||||
expect(types).toEqual(['bar', 'baz', 'foo', 'quux']);
|
|
||||||
expect(actions.bar()).toEqual({
|
|
||||||
type: 'bar'
|
|
||||||
});
|
|
||||||
expect(actions.bar('xxx')).toEqual({
|
|
||||||
type: 'bar',
|
|
||||||
payload: 'xxx'
|
|
||||||
});
|
|
||||||
expect(actions.bar(undefined, 'yyy')).toEqual({
|
|
||||||
type: 'bar',
|
|
||||||
meta: 'yyy'
|
|
||||||
});
|
|
||||||
expect(actions.foo(12)).toEqual({
|
|
||||||
type: 'foo',
|
|
||||||
payload: {
|
|
||||||
limit: 12
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=actions.test.js.map
|
1
dist/actions.test.js.map
vendored
Normal file
1
dist/actions.test.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"actions.test.js","sourceRoot":"","sources":["../src/actions.test.ts"],"names":[],"mappings":";;;;;AAAA,yCAAsB;AAGtB,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AAExC,IAAI,CAAC,uDAAuD,EAAE,GAAG,EAAE;IACjE,MAAM,EAAC,OAAO,EAAC,GAAG,UAAK,CAAC;QACtB,OAAO,EAAE;YACP,GAAG,EAAE,UAAU;SAChB;QACD,SAAS,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,EAAC;QAClC,QAAQ,EAAE;YACR,KAAK,EAAE;gBACL,OAAO,EAAE,EAAC,GAAG,EAAE,UAAU,EAAE;gBAC3B,SAAS,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,EAAC;gBACnC,OAAO,EAAE;oBACP,GAAG,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC;iBACjC;aACF;YACD,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,GAAG,EAAE,UAAU;iBAChB;aACF;SACF;KACF,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,EAAE,CAAC;IAEb,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAErD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC,CAAC;IAClE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;IAE1E,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC,EAAC,CAAC,CAAC;AACvE,CAAC,CAAC,CAAC"}
|
9
dist/buildActions/index.d.ts
vendored
Normal file
9
dist/buildActions/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Action, ActionPayloadGenerator, Dictionary } from '../types';
|
||||||
|
interface ActionCreator {
|
||||||
|
(...args: any[]): Action;
|
||||||
|
_genericAction?: boolean;
|
||||||
|
}
|
||||||
|
declare type ActionPair = [string, ActionCreator];
|
||||||
|
declare function buildActions(generators?: Dictionary<ActionPayloadGenerator>, actionNames?: string[], subActions?: ActionPair[]): Dictionary<ActionCreator>;
|
||||||
|
export default buildActions;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildActions/index.d.ts.map
vendored
Normal file
1
dist/buildActions/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildActions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtE,UAAU,aAAa;IACnB,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAI,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B;AAYD,aAAK,UAAU,GAAG,CAAE,MAAM,EAAE,aAAa,CAAE,CAAC;AAE5C,iBAAS,YAAY,CACnB,UAAU,GAAG,UAAU,CAAC,sBAAsB,CAAM,EACpD,WAAW,GAAE,MAAM,EAAO,EAC1B,UAAU,GAAG,UAAU,EAAO,GAC9B,UAAU,CAAC,aAAa,CAAC,CAmB1B;AAED,eAAe,YAAY,CAAC"}
|
47
dist/buildActions/index.js
vendored
47
dist/buildActions/index.js
vendored
@ -1,32 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
value: true
|
};
|
||||||
});
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = buildActions;
|
const fp_1 = __importDefault(require("lodash/fp"));
|
||||||
|
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
function actionFor(type) {
|
function actionFor(type) {
|
||||||
const creator = (payload = undefined, meta = undefined) => _fp.default.pickBy(v => v !== undefined)({
|
const creator = ((payload = undefined, meta = undefined) => fp_1.default.pickBy(v => v !== undefined)({ type, payload, meta }));
|
||||||
type,
|
creator._genericAction = true;
|
||||||
payload,
|
return creator;
|
||||||
meta
|
|
||||||
});
|
|
||||||
|
|
||||||
creator._genericAction = true;
|
|
||||||
return creator;
|
|
||||||
}
|
}
|
||||||
|
function buildActions(generators = {}, actionNames = [], subActions = []) {
|
||||||
function buildActions(creators = {}, mutations = {}, effects = {}, subActions = []) {
|
const [crafted, generic] = fp_1.default.partition(([type, f]) => !f._genericAction)(subActions);
|
||||||
// priority => generics => generic subs => craft subs => creators
|
const actions = [
|
||||||
const [crafted, generic] = _fp.default.partition(([type, f]) => !f._genericAction)(_fp.default.flatten(subActions.map(x => Object.entries(x))).filter(([_, f]) => f));
|
...(actionNames.map(type => [type, actionFor(type)])),
|
||||||
|
...generic,
|
||||||
const actions = [...[...Object.keys(mutations), ...Object.keys(effects)].map(type => [type, actionFor(type)]), ...generic, ...crafted, ...Object.entries(creators).map(([type, payload]) => [type, (...args) => ({
|
...crafted,
|
||||||
type,
|
...Object.entries(generators).map(([type, payload]) => [type, (...args) => ({ type, payload: payload(...args) })]),
|
||||||
payload: payload(...args)
|
];
|
||||||
})])];
|
return fp_1.default.fromPairs(actions);
|
||||||
return _fp.default.fromPairs(actions);
|
|
||||||
}
|
}
|
||||||
|
exports.default = buildActions;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildActions/index.js.map
vendored
Normal file
1
dist/buildActions/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildActions/index.ts"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAQ3B,SAAS,SAAS,CAAC,IAAW;IAC5B,MAAM,OAAO,GAAmB,CAAE,CAAC,OAAO,GAAG,SAAS,EAAE,IAAI,GAAG,SAAS,EAAE,EAAE,CAC1E,YAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAW,CACjE,CAAC;IAEF,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAE9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAID,SAAS,YAAY,CACnB,aAAkD,EAAE,EACpD,cAAwB,EAAE,EAC1B,aAA4B,EAAE;IAK9B,MAAM,CAAE,OAAO,EAAE,OAAO,CAAE,GAAG,YAAE,CAAC,SAAS,CACrC,CAAC,CAAC,IAAI,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,CAClC,CAAE,UAAU,CAAE,CAAC;IAEd,MAAM,OAAO,GAAG;QACZ,GAAG,CAAC,WAAW,CAAC,GAAG,CAAE,IAAI,CAAC,EAAE,CAAC,CAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAE,CAAE,CAAC;QACzD,GAAG,OAAO;QACV,GAAG,OAAO;QACV,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAC7B,CAAC,CAAC,IAAI,EAAE,OAAO,CAAuB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAS,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAC7G;KACJ,CAAC;IAEF,OAAO,YAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAEjC,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
1
dist/buildCreateStore.js.map
vendored
Normal file
1
dist/buildCreateStore.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"buildCreateStore.js","sourceRoot":"","sources":["../src/buildCreateStore.js"],"names":[],"mappings":";;AAAA,iCAAyE;AAEzE,SAAwB,gBAAgB,CAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAC9B,OAAO;IAC3C,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAI,mBAAgB,CAAE,OAAO,EAAE,OAAO,EAC7C,uBAAe,CAAE,UAAU,CAAC,CAC7B,CAAC;QACJ,KAAM,IAAI,CAAC,IAAI,OAAO,EAAG;YACrB,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;gBAC5B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;YACvC,CAAC,CAAC;SACL;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;AACH,CAAC;AAdD,mCAcC;AAAA,CAAC"}
|
7
dist/buildCreateStore/index.d.ts
vendored
Normal file
7
dist/buildCreateStore/index.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { Middleware, Reducer } from 'redux';
|
||||||
|
import { ActionCreator, Dictionary } from '../types';
|
||||||
|
declare function buildCreateStore<S>(reducer: Reducer<S>, initial: S, middleware: Middleware, actions: Dictionary<ActionCreator>): () => import("redux").Store<S, import("redux").AnyAction> & {
|
||||||
|
dispatch: {};
|
||||||
|
};
|
||||||
|
export default buildCreateStore;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildCreateStore/index.d.ts.map
vendored
Normal file
1
dist/buildCreateStore/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildCreateStore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,OAAO,EACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAErD,iBAAS,gBAAgB,CAAC,CAAC,EACzB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,OAAO,EAAE,CAAC,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC;;EAgBnC;AAED,eAAe,gBAAgB,CAAC"}
|
16
dist/buildCreateStore/index.js
vendored
Normal file
16
dist/buildCreateStore/index.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const redux_1 = require("redux");
|
||||||
|
function buildCreateStore(reducer, initial, middleware, actions) {
|
||||||
|
return () => {
|
||||||
|
const store = redux_1.createStore(reducer, initial, redux_1.applyMiddleware(middleware));
|
||||||
|
for (let a in actions) {
|
||||||
|
store.dispatch[a] = (...args) => {
|
||||||
|
store.dispatch(actions[a](...args));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return store;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.default = buildCreateStore;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildCreateStore/index.js.map
vendored
Normal file
1
dist/buildCreateStore/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildCreateStore/index.ts"],"names":[],"mappings":";;AAAA,iCAKe;AAGf,SAAS,gBAAgB,CACvB,OAAmB,EACnB,OAAU,EACV,UAAsB,EACtB,OAAkC;IAElC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,mBAAgB,CAC5B,OAAO,EACP,OAAO,EACP,uBAAe,CAAC,UAAU,CAAC,CAC5B,CAAC;QACF,KAAK,IAAI,CAAC,IAAI,OAAO,EAAE;YACnB,KAAK,CAAC,QAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;gBAC/C,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YACtC,CAAC,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,gBAAgB,CAAC"}
|
5
dist/buildInitial/index.d.ts
vendored
Normal file
5
dist/buildInitial/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { Dictionary } from '../types';
|
||||||
|
declare function buildInitial<S extends number | string | boolean>(initial: S, subduxes?: Dictionary<undefined>): S;
|
||||||
|
declare function buildInitial<S extends object>(initial?: Partial<S>, subduxes?: Partial<S>): S extends object ? S : never;
|
||||||
|
export default buildInitial;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildInitial/index.d.ts.map
vendored
Normal file
1
dist/buildInitial/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildInitial/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,iBAAS,YAAY,CAAC,CAAC,SAAS,MAAM,GAAC,MAAM,GAAC,OAAO,EAAG,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,GAAI,CAAC,CAAC;AAC1G,iBAAS,YAAY,CAAC,CAAC,SAAS,MAAM,EAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAI,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC;AAQrH,eAAe,YAAY,CAAC"}
|
19
dist/buildInitial/index.js
vendored
19
dist/buildInitial/index.js
vendored
@ -1,14 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
value: true
|
};
|
||||||
});
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = buildInitial;
|
const fp_1 = __importDefault(require("lodash/fp"));
|
||||||
|
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
function buildInitial(initial = {}, subduxes = {}) {
|
function buildInitial(initial = {}, subduxes = {}) {
|
||||||
return _fp.default.isPlainObject(initial) ? _fp.default.mergeAll([subduxes, initial]) : initial;
|
return fp_1.default.isPlainObject(initial) ? fp_1.default.mergeAll([subduxes, initial]) : initial;
|
||||||
}
|
}
|
||||||
|
exports.default = buildInitial;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildInitial/index.js.map
vendored
Normal file
1
dist/buildInitial/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildInitial/index.ts"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAK3B,SAAS,YAAY,CACnB,UAAgB,EAAE,EAClB,WAAiB,EAAE;IAEnB,OAAO,YAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,YAAE,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAChF,CAAC;AAED,kBAAe,YAAY,CAAC"}
|
1
dist/buildInitial/index.test-d.js.map
vendored
Normal file
1
dist/buildInitial/index.test-d.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.test-d.js","sourceRoot":"","sources":["../../src/buildInitial/index.test-d.js"],"names":[],"mappings":""}
|
1
dist/buildInitial/test-d.js.map
vendored
Normal file
1
dist/buildInitial/test-d.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test-d.js","sourceRoot":"","sources":["../../src/buildInitial/test-d.js"],"names":[],"mappings":""}
|
1
dist/buildMiddleware.js.map
vendored
Normal file
1
dist/buildMiddleware.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"buildMiddleware.js","sourceRoot":"","sources":["../src/buildMiddleware.js"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAE3B,MAAM,aAAa,GAAG,CAAC,IAAI,EAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE;IACvD,IAAI,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IAE9D,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,SAAwB,eAAe,CACnC,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,EAAE,EACZ,QAAQ,GAAG,EAAE;IAEf,OAAO,GAAG,CAAC,EAAE;QACX,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE;YACxB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;SACxE;QAED,OAAO,aAAa,CAAC,EAAE;YACrB,OAAO;gBACL,GAAG,YAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAC1C,aAAa,CAAC,IAAI,EAAC,MAAM,CAAC,CAC7B;gBACD,GAAG,YAAE,CAAC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC;aAClC;iBACE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACd,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AArBD,kCAqBC"}
|
5
dist/buildMiddleware/index.d.ts
vendored
Normal file
5
dist/buildMiddleware/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { Middleware } from 'redux';
|
||||||
|
import { Dictionary, ActionCreator, UpduxDispatch } from '../types';
|
||||||
|
declare function buildMiddleware<S = any>(effects?: Dictionary<Middleware<{}, S, UpduxDispatch>>, actions?: Dictionary<ActionCreator>, subMiddlewares?: Middleware<{}, S, UpduxDispatch>[]): Middleware<{}, S, UpduxDispatch>;
|
||||||
|
export default buildMiddleware;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildMiddleware/index.d.ts.map
vendored
Normal file
1
dist/buildMiddleware/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildMiddleware/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAA2B,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAU,aAAa,EAAE,MAAM,UAAU,CAAC;AAU5E,iBAAS,eAAe,CAAC,CAAC,GAAC,GAAG,EAC1B,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,EAAC,CAAC,EAAC,aAAa,CAAC,CAAK,EACxD,OAAO,GAAG,UAAU,CAAC,aAAa,CAAK,EACvC,cAAc,GAAE,UAAU,CAAC,EAAE,EAAC,CAAC,EAAC,aAAa,CAAC,EAAO,GACtD,UAAU,CAAC,EAAE,EAAC,CAAC,EAAC,aAAa,CAAC,CAkBhC;AAED,eAAe,eAAe,CAAC"}
|
28
dist/buildMiddleware/index.js
vendored
Normal file
28
dist/buildMiddleware/index.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const fp_1 = __importDefault(require("lodash/fp"));
|
||||||
|
const MiddlewareFor = (type, mw) => api => next => action => {
|
||||||
|
if (type !== '*' && action.type !== type)
|
||||||
|
return next(action);
|
||||||
|
return mw(api)(next)(action);
|
||||||
|
};
|
||||||
|
function buildMiddleware(effects = {}, actions = {}, subMiddlewares = []) {
|
||||||
|
return (api) => {
|
||||||
|
for (let type in actions) {
|
||||||
|
api.dispatch[type] = (...args) => api.dispatch(actions[type](...args));
|
||||||
|
}
|
||||||
|
return (original_next) => {
|
||||||
|
return [
|
||||||
|
...fp_1.default.toPairs(effects).map(([type, effect]) => MiddlewareFor(type, effect)),
|
||||||
|
...subMiddlewares
|
||||||
|
]
|
||||||
|
.filter(x => x)
|
||||||
|
.reduceRight((next, mw) => mw(api)(next), original_next);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.default = buildMiddleware;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildMiddleware/index.js.map
vendored
Normal file
1
dist/buildMiddleware/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildMiddleware/index.ts"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAK3B,MAAM,aAAa,GAAG,CAAC,IAAS,EAAE,EAAc,EAAe,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE;IACtF,IAAI,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IAE9D,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAIF,SAAS,eAAe,CACpB,UAAsD,EAAE,EACxD,UAAqC,EAAE,EACvC,iBAAmD,EAAE;IAGvD,OAAO,CAAC,GAAmC,EAAE,EAAE;QAC7C,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE;YACxB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAU,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAG,OAAe,CAAC,IAAI,CAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;SAChG;QAED,OAAO,CAAC,aAAmB,EAAC,EAAE;YAC5B,OAAO;gBACL,GAAG,YAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAC1C,aAAa,CAAC,IAAI,EAAC,MAAoB,CAAC,CAC3C;gBACD,GAAG,cAAc;aAClB;iBACE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBACd,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,eAAe,CAAC"}
|
5
dist/buildMutations/index.d.ts
vendored
Normal file
5
dist/buildMutations/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/// <reference types="lodash" />
|
||||||
|
import { Mutation, Dictionary } from '../types';
|
||||||
|
declare function buildMutations(mutations?: Dictionary<Mutation>, subduxes?: {}): import("lodash").Dictionary<Mutation<any>>;
|
||||||
|
export default buildMutations;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildMutations/index.d.ts.map
vendored
Normal file
1
dist/buildMutations/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildMutations/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAC,QAAQ,EAAU,UAAU,EAAC,MAAM,UAAU,CAAC;AAWtD,iBAAS,cAAc,CACnB,SAAS,GAAE,UAAU,CAAC,QAAQ,CAAM,EACpC,QAAQ,KAAK,8CAgDhB;AAED,eAAe,cAAc,CAAC"}
|
77
dist/buildMutations/index.js
vendored
77
dist/buildMutations/index.js
vendored
@ -1,52 +1,33 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
value: true
|
};
|
||||||
});
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = buildMutations;
|
const fp_1 = __importDefault(require("lodash/fp"));
|
||||||
|
const updeep_1 = __importDefault(require("updeep"));
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
const composeMutations = (mutations) => mutations.reduce((m1, m2) => (payload = null, action) => state => m2(payload, action)(m1(payload, action)(state)));
|
||||||
|
|
||||||
var _updeep = _interopRequireDefault(require("updeep"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
const composeMutations = mutations => mutations.reduce((m1, m2) => (payload = null, action = {}) => state => m2(payload, action)(m1(payload, action)(state)));
|
|
||||||
|
|
||||||
function buildMutations(mutations = {}, subduxes = {}) {
|
function buildMutations(mutations = {}, subduxes = {}) {
|
||||||
// we have to differentiate the subduxes with '*' than those
|
const actions = fp_1.default.uniq(Object.keys(mutations).concat(...Object.values(subduxes).map(({ mutations = {} }) => Object.keys(mutations))));
|
||||||
// without, as the root '*' is not the same as any sub-'*'
|
let mergedMutations = {};
|
||||||
const actions = _fp.default.uniq(Object.keys(mutations).concat(...Object.values(subduxes).map(({
|
let [globby, nonGlobby] = fp_1.default.partition(([_, { mutations = {} }]) => mutations['*'], Object.entries(subduxes));
|
||||||
mutations = {}
|
globby = fp_1.default.flow([
|
||||||
}) => Object.keys(mutations))));
|
fp_1.default.fromPairs,
|
||||||
|
fp_1.default.mapValues(({ reducer }) => (_, action) => (state) => reducer(state, action)),
|
||||||
let mergedMutations = {};
|
])(globby);
|
||||||
|
const globbyMutation = (payload, action) => updeep_1.default(fp_1.default.mapValues((mut) => mut(payload, action))(globby));
|
||||||
let [globby, nonGlobby] = _fp.default.partition(([_, {
|
actions.forEach(action => {
|
||||||
mutations = {}
|
mergedMutations[action] = [globbyMutation];
|
||||||
}]) => mutations['*'], Object.entries(subduxes));
|
|
||||||
|
|
||||||
globby = _fp.default.flow([_fp.default.fromPairs, _fp.default.mapValues(({
|
|
||||||
reducer
|
|
||||||
}) => (_, action = {}) => state => reducer(state, action))])(globby);
|
|
||||||
|
|
||||||
const globbyMutation = (payload, action) => (0, _updeep.default)(_fp.default.mapValues(mut => mut(payload, action))(globby));
|
|
||||||
|
|
||||||
actions.forEach(action => {
|
|
||||||
mergedMutations[action] = [globbyMutation];
|
|
||||||
});
|
|
||||||
nonGlobby.forEach(([slice, {
|
|
||||||
mutations = {},
|
|
||||||
reducer = {}
|
|
||||||
}]) => {
|
|
||||||
Object.entries(mutations).forEach(([type, mutation]) => {
|
|
||||||
const localized = (payload = null, action = {}) => _updeep.default.updateIn(slice)(mutation(payload, action));
|
|
||||||
|
|
||||||
mergedMutations[type].push(localized);
|
|
||||||
});
|
});
|
||||||
});
|
nonGlobby.forEach(([slice, { mutations = {}, reducer = {} }]) => {
|
||||||
Object.entries(mutations).forEach(([type, mutation]) => {
|
Object.entries(mutations).forEach(([type, mutation]) => {
|
||||||
mergedMutations[type].push(mutation);
|
const localized = (payload = null, action) => updeep_1.default.updateIn(slice)(mutation(payload, action));
|
||||||
});
|
mergedMutations[type].push(localized);
|
||||||
return _fp.default.mapValues(composeMutations)(mergedMutations);
|
});
|
||||||
|
});
|
||||||
|
Object.entries(mutations).forEach(([type, mutation]) => {
|
||||||
|
mergedMutations[type].push(mutation);
|
||||||
|
});
|
||||||
|
return fp_1.default.mapValues(composeMutations)(mergedMutations);
|
||||||
}
|
}
|
||||||
|
exports.default = buildMutations;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildMutations/index.js.map
vendored
Normal file
1
dist/buildMutations/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildMutations/index.ts"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAC3B,oDAAuB;AAGvB,MAAM,gBAAgB,GAAG,CAAC,SAAqB,EAAE,EAAE,CACjD,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,UAAe,IAAI,EAAE,MAAc,EAAE,EAAE,CAAC,KAAK,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AC;IAE7D,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,EAAC,SAAS,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAC,CAAO,EAAE,EAAE;QAClE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;YACrD,MAAM,SAAS,GAAG,CAAC,OAAO,GAAG,IAAI,EAAE,MAAc,EAAE,EAAE,CACnD,gBAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAE,QAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YAE7D,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;QACrD,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,OAAO,YAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,eAAe,CAAC,CAAC;AACzD,CAAC;AAED,kBAAe,cAAc,CAAC"}
|
4
dist/buildUpreducer/index.d.ts
vendored
Normal file
4
dist/buildUpreducer/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { Dictionary, Mutation, Upreducer } from '../types';
|
||||||
|
declare function buildUpreducer<S>(initial: S, mutations: Dictionary<Mutation<S>>): Upreducer<S>;
|
||||||
|
export default buildUpreducer;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/buildUpreducer/index.d.ts.map
vendored
Normal file
1
dist/buildUpreducer/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildUpreducer/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAU,SAAS,EAAE,MAAM,UAAU,CAAC;AAEnE,iBAAS,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAI,SAAS,CAAC,CAAC,CAAC,CAYxF;AAED,eAAe,cAAc,CAAC"}
|
28
dist/buildUpreducer/index.js
vendored
28
dist/buildUpreducer/index.js
vendored
@ -1,19 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
Object.defineProperty(exports, "__esModule", {
|
|
||||||
value: true
|
|
||||||
});
|
|
||||||
exports.default = buildUpreducer;
|
|
||||||
|
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
function buildUpreducer(initial, mutations) {
|
function buildUpreducer(initial, mutations) {
|
||||||
return (action = {}) => state => {
|
return (action) => (state) => {
|
||||||
if (state === null) state = initial;
|
if (state === null)
|
||||||
const a = mutations[action.type] || mutations['*'];
|
state = initial;
|
||||||
if (!a) return state;
|
const a = mutations[action.type] ||
|
||||||
return a(action.payload, action)(state);
|
mutations['*'];
|
||||||
};
|
if (!a)
|
||||||
|
return state;
|
||||||
|
return a(action.payload, action)(state);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
exports.default = buildUpreducer;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/buildUpreducer/index.js.map
vendored
Normal file
1
dist/buildUpreducer/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/buildUpreducer/index.ts"],"names":[],"mappings":";;AAIA,SAAS,cAAc,CAAI,OAAU,EAAE,SAAkC;IACvE,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,KAAQ,EAAE,EAAE;QACtC,IAAI,KAAK,KAAK,IAAI;YAAE,KAAK,GAAG,OAAO,CAAC;QAEpC,MAAM,CAAC,GACL,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;YACtB,SAAS,CAAC,GAAG,CAAC,CAAC;QAEjB,IAAG,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAEpB,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC;AAED,kBAAe,cAAc,CAAC"}
|
4
dist/index.d.ts
vendored
Normal file
4
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import Updux from './updux';
|
||||||
|
import { UpduxConfig } from './types';
|
||||||
|
export default function updux(config: UpduxConfig): Updux<any>;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
1
dist/index.d.ts.map
vendored
Normal file
1
dist/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,MAAM,EAAE,WAAW,cAEhD"}
|
23
dist/index.js
vendored
23
dist/index.js
vendored
@ -1,18 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
value: true
|
};
|
||||||
});
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = updux;
|
const updux_1 = __importDefault(require("./updux"));
|
||||||
|
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
||||||
|
|
||||||
var _updeep = _interopRequireDefault(require("updeep"));
|
|
||||||
|
|
||||||
var _updux = _interopRequireDefault(require("./updux"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
function updux(config) {
|
function updux(config) {
|
||||||
return new _updux.default(config);
|
return new updux_1.default(config);
|
||||||
}
|
}
|
||||||
|
exports.default = updux;
|
||||||
|
//# sourceMappingURL=index.js.map
|
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAGA,oDAA4B;AAI5B,SAAwB,KAAK,CAAC,MAAmB;IAC/C,OAAO,IAAI,eAAK,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAFD,wBAEC"}
|
2
dist/middleware.test.d.ts
vendored
Normal file
2
dist/middleware.test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {};
|
||||||
|
//# sourceMappingURL=middleware.test.d.ts.map
|
1
dist/middleware.test.d.ts.map
vendored
Normal file
1
dist/middleware.test.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"middleware.test.d.ts","sourceRoot":"","sources":["../src/middleware.test.ts"],"names":[],"mappings":""}
|
150
dist/middleware.test.js
vendored
150
dist/middleware.test.js
vendored
@ -1,92 +1,80 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
var _ = _interopRequireDefault(require("."));
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var _updeep = _interopRequireDefault(require("updeep"));
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const _1 = __importDefault(require("."));
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
test('simple effect', () => {
|
test('simple effect', () => {
|
||||||
const tracer = jest.fn();
|
const tracer = jest.fn();
|
||||||
const store = (0, _.default)({
|
const store = _1.default({
|
||||||
effects: {
|
effects: {
|
||||||
foo: api => next => action => {
|
foo: (api) => (next) => (action) => {
|
||||||
tracer();
|
tracer();
|
||||||
next(action);
|
next(action);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}).createStore();
|
}).createStore();
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
store.dispatch({
|
store.dispatch({ type: 'bar' });
|
||||||
type: 'bar'
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
});
|
store.dispatch.foo();
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
expect(tracer).toHaveBeenCalled();
|
||||||
store.dispatch.foo();
|
|
||||||
expect(tracer).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
test('effect and sub-effect', () => {
|
test('effect and sub-effect', () => {
|
||||||
const tracer = jest.fn();
|
const tracer = jest.fn();
|
||||||
|
const tracerEffect = (signature) => (api) => (next) => (action) => {
|
||||||
const tracerEffect = signature => api => next => action => {
|
tracer(signature);
|
||||||
tracer(signature);
|
next(action);
|
||||||
next(action);
|
};
|
||||||
};
|
const store = _1.default({
|
||||||
|
|
||||||
const store = (0, _.default)({
|
|
||||||
effects: {
|
|
||||||
foo: tracerEffect('root')
|
|
||||||
},
|
|
||||||
subduxes: {
|
|
||||||
zzz: (0, _.default)({
|
|
||||||
effects: {
|
effects: {
|
||||||
foo: tracerEffect('child')
|
foo: tracerEffect('root'),
|
||||||
}
|
},
|
||||||
})
|
subduxes: {
|
||||||
}
|
zzz: _1.default({ effects: {
|
||||||
}).createStore();
|
foo: tracerEffect('child'),
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
} })
|
||||||
store.dispatch({
|
},
|
||||||
type: 'bar'
|
}).createStore();
|
||||||
});
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
store.dispatch({ type: 'bar' });
|
||||||
store.dispatch.foo();
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
expect(tracer).toHaveBeenNthCalledWith(1, 'root');
|
store.dispatch.foo();
|
||||||
expect(tracer).toHaveBeenNthCalledWith(2, 'child');
|
expect(tracer).toHaveBeenNthCalledWith(1, 'root');
|
||||||
|
expect(tracer).toHaveBeenNthCalledWith(2, 'child');
|
||||||
});
|
});
|
||||||
test('"*" effect', () => {
|
test('"*" effect', () => {
|
||||||
const tracer = jest.fn();
|
const tracer = jest.fn();
|
||||||
const store = (0, _.default)({
|
const store = _1.default({
|
||||||
effects: {
|
effects: {
|
||||||
'*': api => next => action => {
|
'*': api => next => action => {
|
||||||
tracer();
|
tracer();
|
||||||
next(action);
|
next(action);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}).createStore();
|
}).createStore();
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
store.dispatch({
|
store.dispatch({ type: 'bar' });
|
||||||
type: 'bar'
|
expect(tracer).toHaveBeenCalled();
|
||||||
});
|
|
||||||
expect(tracer).toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
test('async effect', async () => {
|
test('async effect', async () => {
|
||||||
function timeout(ms) {
|
function timeout(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
|
||||||
|
|
||||||
const tracer = jest.fn();
|
|
||||||
const store = (0, _.default)({
|
|
||||||
effects: {
|
|
||||||
foo: api => next => async action => {
|
|
||||||
next(action);
|
|
||||||
await timeout(1000);
|
|
||||||
tracer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).createStore();
|
const tracer = jest.fn();
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
const store = _1.default({
|
||||||
store.dispatch.foo();
|
effects: {
|
||||||
expect(tracer).not.toHaveBeenCalled();
|
foo: api => next => async (action) => {
|
||||||
await timeout(1000);
|
next(action);
|
||||||
expect(tracer).toHaveBeenCalled();
|
await timeout(1000);
|
||||||
|
tracer();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).createStore();
|
||||||
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
|
store.dispatch.foo();
|
||||||
|
expect(tracer).not.toHaveBeenCalled();
|
||||||
|
await timeout(1000);
|
||||||
|
expect(tracer).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=middleware.test.js.map
|
1
dist/middleware.test.js.map
vendored
Normal file
1
dist/middleware.test.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"middleware.test.js","sourceRoot":"","sources":["../src/middleware.test.ts"],"names":[],"mappings":";;;;;AAAA,yCAAsB;AAGtB,IAAI,CAAE,eAAe,EAAE,GAAG,EAAE;IAExB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IAEzB,MAAM,KAAK,GAAG,UAAK,CAAC;QAChB,OAAO,EAAE;YACL,GAAG,EAAE,CAAC,GAAO,EAAE,EAAE,CAAC,CAAC,IAAQ,EAAE,EAAE,CAAC,CAAC,MAAU,EAAE,EAAE;gBAC3C,MAAM,EAAE,CAAC;gBACT,IAAI,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC;SACJ;KACJ,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjB,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAEtC,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAEhC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,E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AAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAEtC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACtC,CAAC,CAAC,CAAC"}
|
2
dist/splat.test.d.ts
vendored
Normal file
2
dist/splat.test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {};
|
||||||
|
//# sourceMappingURL=splat.test.d.ts.map
|
1
dist/splat.test.d.ts.map
vendored
Normal file
1
dist/splat.test.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"splat.test.d.ts","sourceRoot":"","sources":["../src/splat.test.ts"],"names":[],"mappings":""}
|
122
dist/splat.test.js
vendored
122
dist/splat.test.js
vendored
@ -1,79 +1,55 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
var _ = _interopRequireDefault(require("."));
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var _updeep = _interopRequireDefault(require("updeep"));
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const _1 = __importDefault(require("."));
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
const updeep_1 = __importDefault(require("updeep"));
|
||||||
|
const tracer = (chr) => updeep_1.default({ tracer: (s = '') => s + chr });
|
||||||
const tracer = chr => (0, _updeep.default)({
|
|
||||||
tracer: s => (s || '') + chr
|
|
||||||
});
|
|
||||||
|
|
||||||
test('mutations, simple', () => {
|
test('mutations, simple', () => {
|
||||||
const dux = (0, _.default)({
|
const dux = _1.default({
|
||||||
mutations: {
|
mutations: {
|
||||||
foo: () => tracer('a'),
|
foo: () => tracer('a'),
|
||||||
'*': (p, a) => tracer('b')
|
'*': () => tracer('b'),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const store = dux.createStore();
|
const store = dux.createStore();
|
||||||
expect(store.getState()).toEqual({
|
expect(store.getState()).toEqual({ tracer: 'b' });
|
||||||
tracer: 'b'
|
store.dispatch.foo();
|
||||||
});
|
expect(store.getState()).toEqual({ tracer: 'ba', });
|
||||||
store.dispatch.foo();
|
store.dispatch({ type: 'bar' });
|
||||||
expect(store.getState()).toEqual({
|
expect(store.getState()).toEqual({ tracer: 'bab', });
|
||||||
tracer: 'ba'
|
|
||||||
});
|
|
||||||
store.dispatch({
|
|
||||||
type: 'bar'
|
|
||||||
});
|
|
||||||
expect(store.getState()).toEqual({
|
|
||||||
tracer: 'bab'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
test('with subduxes', () => {
|
test('with subduxes', () => {
|
||||||
const dux = (0, _.default)({
|
const dux = _1.default({
|
||||||
mutations: {
|
|
||||||
foo: () => tracer('a'),
|
|
||||||
'*': (dummy, a) => tracer('b'),
|
|
||||||
bar: () => ({
|
|
||||||
bar
|
|
||||||
}) => ({
|
|
||||||
bar,
|
|
||||||
tracer: bar.tracer
|
|
||||||
})
|
|
||||||
},
|
|
||||||
subduxes: {
|
|
||||||
bar: (0, _.default)({
|
|
||||||
mutations: {
|
mutations: {
|
||||||
foo: () => tracer('d'),
|
foo: () => tracer('a'),
|
||||||
'*': (dummy, a) => tracer('e')
|
'*': () => tracer('b'),
|
||||||
}
|
bar: () => ({ bar }) => ({ bar, tracer: bar.tracer })
|
||||||
})
|
},
|
||||||
}
|
subduxes: {
|
||||||
});
|
bar: _1.default({
|
||||||
const store = dux.createStore();
|
mutations: {
|
||||||
expect(store.getState()).toEqual({
|
foo: () => tracer('d'),
|
||||||
tracer: 'b',
|
'*': () => tracer('e'),
|
||||||
bar: {
|
},
|
||||||
tracer: 'e'
|
}),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
store.dispatch.foo();
|
const store = dux.createStore();
|
||||||
expect(store.getState()).toEqual({
|
expect(store.getState()).toEqual({
|
||||||
tracer: 'ba',
|
tracer: 'b',
|
||||||
bar: {
|
bar: { tracer: 'e' }
|
||||||
tracer: 'ed'
|
});
|
||||||
}
|
store.dispatch.foo();
|
||||||
});
|
expect(store.getState()).toEqual({
|
||||||
store.dispatch({
|
tracer: 'ba',
|
||||||
type: 'bar'
|
bar: { tracer: 'ed' }
|
||||||
});
|
});
|
||||||
expect(store.getState()).toEqual({
|
store.dispatch({ type: 'bar' });
|
||||||
tracer: 'ede',
|
expect(store.getState()).toEqual({
|
||||||
bar: {
|
tracer: 'ede',
|
||||||
tracer: 'ede'
|
bar: { tracer: 'ede' }
|
||||||
}
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=splat.test.js.map
|
1
dist/splat.test.js.map
vendored
Normal file
1
dist/splat.test.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"splat.test.js","sourceRoot":"","sources":["../src/splat.test.ts"],"names":[],"mappings":";;;;;AAAA,yCAAsB;AACtB,oDAAuB;AAEvB,MAAM,MAAM,GAAG,CAAC,GAAU,EAAE,EAAE,CAAC,gBAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,GAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAEhE,IAAI,CAAE,mBAAmB,EAAE,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,UAAK,CAAC;QACd,SAAS,EAAE;YACP,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;YACtB,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;SACzB;KACJ,CAAC,CAAC;IAEJ,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAE/B,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAC,CAAC,CAAC;IAEjD,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAErB,M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CAAC;QAC7B,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;KAAE,CAAC,CAAC;IAE7B,KAAK,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;IAE9B,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC;QAC7B,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;KAAE,CAAC,CAAC;AAGlC,CAAC,CAAC,CAAC"}
|
2
dist/test.d.ts
vendored
Normal file
2
dist/test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {};
|
||||||
|
//# sourceMappingURL=test.d.ts.map
|
1
dist/test.d.ts.map
vendored
Normal file
1
dist/test.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
|
300
dist/test.js
vendored
300
dist/test.js
vendored
@ -1,205 +1,133 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
var _ = _interopRequireDefault(require("."));
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const _1 = __importDefault(require("."));
|
||||||
test('actions from mutations', () => {
|
test('actions from mutations', () => {
|
||||||
const {
|
const { actions: { foo, bar }, } = _1.default({
|
||||||
actions: {
|
mutations: {
|
||||||
foo,
|
foo: () => (x) => x,
|
||||||
bar
|
},
|
||||||
}
|
});
|
||||||
} = (0, _.default)({
|
expect(foo()).toEqual({ type: 'foo' });
|
||||||
mutations: {
|
expect(foo(true)).toEqual({ type: 'foo', payload: true });
|
||||||
foo: () => x => x
|
expect(foo({ bar: 2 }, { timestamp: 613 })).toEqual({
|
||||||
}
|
type: 'foo',
|
||||||
});
|
payload: { bar: 2 },
|
||||||
expect(foo()).toEqual({
|
meta: { timestamp: 613 },
|
||||||
type: 'foo'
|
});
|
||||||
});
|
|
||||||
expect(foo(true)).toEqual({
|
|
||||||
type: 'foo',
|
|
||||||
payload: true
|
|
||||||
});
|
|
||||||
expect(foo({
|
|
||||||
bar: 2
|
|
||||||
}, {
|
|
||||||
timestamp: 613
|
|
||||||
})).toEqual({
|
|
||||||
type: 'foo',
|
|
||||||
payload: {
|
|
||||||
bar: 2
|
|
||||||
},
|
|
||||||
meta: {
|
|
||||||
timestamp: 613
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
test('reducer', () => {
|
test('reducer', () => {
|
||||||
const {
|
const { actions, reducer } = _1.default({
|
||||||
actions,
|
initial: { counter: 1 },
|
||||||
reducer
|
mutations: {
|
||||||
} = (0, _.default)({
|
inc: () => ({ counter }) => ({ counter: counter + 1 }),
|
||||||
initial: {
|
},
|
||||||
counter: 1
|
});
|
||||||
},
|
let state = reducer(null, { type: 'noop' });
|
||||||
mutations: {
|
expect(state).toEqual({ counter: 1 });
|
||||||
inc: () => ({
|
state = reducer(state, actions.inc());
|
||||||
counter
|
expect(state).toEqual({ counter: 2 });
|
||||||
}) => ({
|
|
||||||
counter: counter + 1
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let state = reducer(null, {});
|
|
||||||
expect(state).toEqual({
|
|
||||||
counter: 1
|
|
||||||
});
|
|
||||||
state = reducer(state, actions.inc());
|
|
||||||
expect(state).toEqual({
|
|
||||||
counter: 2
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
test('sub reducers', () => {
|
test('sub reducers', () => {
|
||||||
const foo = (0, _.default)({
|
const foo = _1.default({
|
||||||
initial: 1,
|
initial: 1,
|
||||||
mutations: {
|
mutations: {
|
||||||
doFoo: () => x => x + 1,
|
doFoo: () => (x) => x + 1,
|
||||||
doAll: () => x => x + 10
|
doAll: () => (x) => x + 10,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
const bar = (0, _.default)({
|
const bar = _1.default({
|
||||||
initial: 'a',
|
initial: 'a',
|
||||||
mutations: {
|
mutations: {
|
||||||
doBar: () => x => x + 'a',
|
doBar: () => (x) => x + 'a',
|
||||||
doAll: () => x => x + 'b'
|
doAll: () => (x) => x + 'b',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const {
|
const { initial, actions, reducer } = _1.default({
|
||||||
initial,
|
subduxes: {
|
||||||
actions,
|
foo, bar
|
||||||
reducer
|
}
|
||||||
} = (0, _.default)({
|
});
|
||||||
subduxes: {
|
expect(initial).toEqual({ foo: 1, bar: 'a' });
|
||||||
foo,
|
expect(Object.keys(actions)).toHaveLength(3);
|
||||||
bar
|
let state = reducer(null, { type: 'noop' });
|
||||||
}
|
expect(state).toEqual({ foo: 1, bar: 'a' });
|
||||||
});
|
state = reducer(state, actions.doFoo());
|
||||||
expect(initial).toEqual({
|
expect(state).toEqual({ foo: 2, bar: 'a' });
|
||||||
foo: 1,
|
state = reducer(state, actions.doBar());
|
||||||
bar: 'a'
|
expect(state).toEqual({ foo: 2, bar: 'aa' });
|
||||||
});
|
state = reducer(state, actions.doAll());
|
||||||
expect(Object.keys(actions)).toHaveLength(3);
|
expect(state).toEqual({ foo: 12, bar: 'aab' });
|
||||||
let state = reducer(null, {});
|
|
||||||
expect(state).toEqual({
|
|
||||||
foo: 1,
|
|
||||||
bar: 'a'
|
|
||||||
});
|
|
||||||
state = reducer(state, actions.doFoo());
|
|
||||||
expect(state).toEqual({
|
|
||||||
foo: 2,
|
|
||||||
bar: 'a'
|
|
||||||
});
|
|
||||||
state = reducer(state, actions.doBar());
|
|
||||||
expect(state).toEqual({
|
|
||||||
foo: 2,
|
|
||||||
bar: 'aa'
|
|
||||||
});
|
|
||||||
state = reducer(state, actions.doAll());
|
|
||||||
expect(state).toEqual({
|
|
||||||
foo: 12,
|
|
||||||
bar: 'aab'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
test('precedence between root and sub-reducers', () => {
|
test('precedence between root and sub-reducers', () => {
|
||||||
const {
|
const { initial, reducer, actions, } = _1.default({
|
||||||
initial,
|
|
||||||
reducer,
|
|
||||||
actions
|
|
||||||
} = (0, _.default)({
|
|
||||||
initial: {
|
|
||||||
foo: {
|
|
||||||
bar: 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
inc: () => state => {
|
|
||||||
return { ...state,
|
|
||||||
surprise: state.foo.bar
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
subduxes: {
|
|
||||||
foo: (0, _.default)({
|
|
||||||
initial: {
|
initial: {
|
||||||
bar: 2,
|
foo: { bar: 4 },
|
||||||
quux: 3
|
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
inc: () => state => ({ ...state,
|
inc: () => (state) => {
|
||||||
bar: state.bar + 1
|
return {
|
||||||
})
|
...state,
|
||||||
|
surprise: state.foo.bar
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
subduxes: {
|
||||||
|
foo: _1.default({
|
||||||
|
initial: {
|
||||||
|
bar: 2,
|
||||||
|
quux: 3,
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
inc: () => (state) => ({ ...state, bar: state.bar + 1 })
|
||||||
|
},
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
expect(initial).toEqual({
|
||||||
});
|
foo: { bar: 4, quux: 3 }
|
||||||
expect(initial).toEqual({
|
});
|
||||||
foo: {
|
expect(reducer(null, actions.inc())).toEqual({
|
||||||
bar: 4,
|
foo: { bar: 5, quux: 3 }, surprise: 5
|
||||||
quux: 3
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
expect(reducer(null, actions.inc())).toEqual({
|
|
||||||
foo: {
|
|
||||||
bar: 5,
|
|
||||||
quux: 3
|
|
||||||
},
|
|
||||||
surprise: 5
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function timeout(ms) {
|
function timeout(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
test('middleware', async () => {
|
test('middleware', async () => {
|
||||||
const {
|
const { middleware, createStore } = _1.default({
|
||||||
middleware,
|
initial: "",
|
||||||
createStore
|
mutations: {
|
||||||
} = (0, _.default)({
|
inc: (addition) => (state) => state + addition,
|
||||||
initial: "",
|
doEeet: () => (state) => {
|
||||||
mutations: {
|
return state + 'Z';
|
||||||
inc: addition => state => state + addition,
|
},
|
||||||
doEeet: () => state => {
|
},
|
||||||
return state + 'Z';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
effects: {
|
|
||||||
doEeet: api => next => async action => {
|
|
||||||
api.dispatch.inc('a');
|
|
||||||
next(action);
|
|
||||||
await timeout(1000);
|
|
||||||
api.dispatch.inc('c');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
subduxes: {
|
|
||||||
foo: (0, _.default)({
|
|
||||||
effects: {
|
effects: {
|
||||||
doEeet: api => next => action => {
|
doEeet: api => next => async (action) => {
|
||||||
api.dispatch({
|
api.dispatch.inc('a');
|
||||||
type: 'inc',
|
next(action);
|
||||||
payload: 'b'
|
await timeout(1000);
|
||||||
});
|
api.dispatch.inc('c');
|
||||||
next(action);
|
}
|
||||||
}
|
},
|
||||||
|
subduxes: {
|
||||||
|
foo: _1.default({
|
||||||
|
effects: {
|
||||||
|
doEeet: (api) => next => action => {
|
||||||
|
api.dispatch({ type: 'inc', payload: 'b' });
|
||||||
|
next(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
const store = createStore();
|
||||||
});
|
store.dispatch.doEeet();
|
||||||
const store = createStore();
|
expect(store.getState()).toEqual('abZ');
|
||||||
store.dispatch.doEeet();
|
await timeout(1000);
|
||||||
expect(store.getState()).toEqual('abZ');
|
expect(store.getState()).toEqual('abZc');
|
||||||
await timeout(1000);
|
|
||||||
expect(store.getState()).toEqual('abZc');
|
|
||||||
});
|
});
|
||||||
|
//# sourceMappingURL=test.js.map
|
1
dist/test.js.map
vendored
Normal file
1
dist/test.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
24
dist/types.d.ts
vendored
Normal file
24
dist/types.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { Dispatch, Middleware } from 'redux';
|
||||||
|
export declare type Action = {
|
||||||
|
type: string;
|
||||||
|
payload?: any;
|
||||||
|
meta?: any;
|
||||||
|
};
|
||||||
|
export declare type Dictionary<T> = {
|
||||||
|
[key: string]: T;
|
||||||
|
};
|
||||||
|
export declare type Mutation<S = any> = (payload: any, action: Action) => (state: S) => S;
|
||||||
|
export declare type ActionPayloadGenerator = (...args: any[]) => any;
|
||||||
|
export declare type ActionCreator = (...args: any[]) => Action;
|
||||||
|
export declare type UpduxDispatch = Dispatch & Dictionary<ActionCreator>;
|
||||||
|
export declare type UpduxConfig<S = any> = Partial<{
|
||||||
|
initial: S;
|
||||||
|
subduxes: {};
|
||||||
|
actions: {
|
||||||
|
[type: string]: ActionPayloadGenerator;
|
||||||
|
};
|
||||||
|
mutations: any;
|
||||||
|
effects: Dictionary<Middleware<{}, S, UpduxDispatch>>;
|
||||||
|
}>;
|
||||||
|
export declare type Upreducer<S = any> = (action: Action) => (state: S) => S;
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
1
dist/types.d.ts.map
vendored
Normal file
1
dist/types.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7C,oBAAY,MAAM,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC;CACd,CAAA;AAED,oBAAY,UAAU,CAAC,CAAC,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,CAAC;AAEjD,oBAAY,QAAQ,CAAC,CAAC,GAAC,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAE;AAEjF,oBAAY,sBAAsB,GAAG,CAAC,GAAG,IAAI,EAAC,GAAG,EAAE,KAAK,GAAG,CAAC;AAE5D,oBAAY,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,MAAM,CAAC;AAExD,oBAAY,aAAa,GAAG,QAAQ,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;AAEjE,oBAAY,WAAW,CAAC,CAAC,GAAC,GAAG,IAAI,OAAO,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,EAAE,CAAC;IACb,OAAO,EAAE;QACL,CAAE,IAAI,EAAE,MAAM,GAAI,sBAAsB,CAAA;KAC3C,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;IACf,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,EAAC,CAAC,EAAC,aAAa,CAAC,CAAC,CAAC;CACvD,CAAC,CAAC;AAEH,oBAAY,SAAS,CAAC,CAAC,GAAC,GAAG,IAAI,CAAC,MAAM,EAAC,MAAM,KAAK,CAAC,KAAK,EAAC,CAAC,KAAK,CAAC,CAAC"}
|
3
dist/types.js
vendored
Normal file
3
dist/types.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
//# sourceMappingURL=types.js.map
|
1
dist/types.js.map
vendored
Normal file
1
dist/types.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
22
dist/updux.d.ts
vendored
Normal file
22
dist/updux.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { UpduxConfig, Dictionary, Action, ActionCreator, Mutation, Upreducer, UpduxDispatch } from './types';
|
||||||
|
import { Middleware, Store } from 'redux';
|
||||||
|
declare type StoreWithDispatchActions<S = any, Actions = {
|
||||||
|
[action: string]: (...args: any) => Action;
|
||||||
|
}> = Store<S> & {
|
||||||
|
dispatch: {
|
||||||
|
[type in keyof Actions]: (...args: any) => void;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare class Updux<S = any> {
|
||||||
|
subduxes: Dictionary<Updux>;
|
||||||
|
actions: Dictionary<ActionCreator>;
|
||||||
|
initial: S;
|
||||||
|
mutations: Dictionary<Mutation>;
|
||||||
|
upreducer: Upreducer<S>;
|
||||||
|
reducer: (state: S | undefined, action: Action) => S;
|
||||||
|
middleware: Middleware<{}, S, UpduxDispatch>;
|
||||||
|
createStore: () => StoreWithDispatchActions<S>;
|
||||||
|
constructor(config: UpduxConfig);
|
||||||
|
}
|
||||||
|
export default Updux;
|
||||||
|
//# sourceMappingURL=updux.d.ts.map
|
1
dist/updux.d.ts.map
vendored
Normal file
1
dist/updux.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"updux.d.ts","sourceRoot":"","sources":["../src/updux.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7G,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE1C,aAAK,wBAAwB,CAAC,CAAC,GAAC,GAAG,EAAC,OAAO,GAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAC,GAAG,KAAK,MAAM,CAAA;CAAE,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG;IACpG,QAAQ,EAAE;SAAI,IAAI,IAAI,MAAM,OAAO,GAAI,CAAC,GAAG,IAAI,EAAC,GAAG,KAAK,IAAI;KAAE,CAAA;CACjE,CAAC;AAEF,qBAAa,KAAK,CAAC,CAAC,GAAC,GAAG;IAEpB,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAE5B,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IAElC,OAAO,EAAE,CAAC,CAAC;IAEX,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEhC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAExB,OAAO,EAAE,CAAC,KAAK,EAAC,CAAC,GAAC,SAAS,EAAC,MAAM,EAAC,MAAM,KAAK,CAAC,CAAC;IAEhD,UAAU,EAAE,UAAU,CAAC,EAAE,EAAC,CAAC,EAAC,aAAa,CAAC,CAAC;IAE3C,WAAW,EAAE,MAAM,wBAAwB,CAAC,CAAC,CAAC,CAAC;gBAEnC,MAAM,EAAE,WAAW;CAwClC;AAED,eAAe,KAAK,CAAC"}
|
70
dist/updux.js
vendored
70
dist/updux.js
vendored
@ -1,48 +1,30 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", {
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
value: true
|
};
|
||||||
});
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.default = exports.Updux = void 0;
|
const fp_1 = __importDefault(require("lodash/fp"));
|
||||||
|
const buildActions_1 = __importDefault(require("./buildActions"));
|
||||||
var _fp = _interopRequireDefault(require("lodash/fp"));
|
const buildInitial_1 = __importDefault(require("./buildInitial"));
|
||||||
|
const buildMutations_1 = __importDefault(require("./buildMutations"));
|
||||||
var _buildActions = _interopRequireDefault(require("./buildActions"));
|
const buildCreateStore_1 = __importDefault(require("./buildCreateStore"));
|
||||||
|
const buildMiddleware_1 = __importDefault(require("./buildMiddleware"));
|
||||||
var _buildInitial = _interopRequireDefault(require("./buildInitial"));
|
const buildUpreducer_1 = __importDefault(require("./buildUpreducer"));
|
||||||
|
|
||||||
var _buildMutations = _interopRequireDefault(require("./buildMutations"));
|
|
||||||
|
|
||||||
var _buildCreateStore = _interopRequireDefault(require("./buildCreateStore"));
|
|
||||||
|
|
||||||
var _buildMiddleware = _interopRequireDefault(require("./buildMiddleware"));
|
|
||||||
|
|
||||||
var _buildUpreducer = _interopRequireDefault(require("./buildUpreducer"));
|
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
||||||
|
|
||||||
class Updux {
|
class Updux {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
this.subduxes = _fp.default.mapValues(value => _fp.default.isPlainObject(value) ? new Updux(value) : value)(_fp.default.getOr({}, 'subduxes', config));
|
this.subduxes = fp_1.default.mapValues((value) => fp_1.default.isPlainObject(value) ? new Updux(value) : value)(fp_1.default.getOr({}, 'subduxes', config));
|
||||||
this.actions = (0, _buildActions.default)(config.actions, config.mutations, config.effects, Object.values(this.subduxes).map(({
|
this.actions = buildActions_1.default(config.actions, [...Object.keys(config.mutations || {}), ...Object.keys(config.effects || {})], fp_1.default.flatten(Object.values(this.subduxes).map(({ actions }) => Object.entries(actions))));
|
||||||
actions
|
this.initial = buildInitial_1.default(config.initial, fp_1.default.mapValues(({ initial }) => initial)(this.subduxes));
|
||||||
}) => actions));
|
this.mutations = buildMutations_1.default(config.mutations, this.subduxes);
|
||||||
this.initial = (0, _buildInitial.default)(config.initial, _fp.default.mapValues(({
|
this.upreducer = buildUpreducer_1.default(this.initial, this.mutations);
|
||||||
initial
|
this.reducer = (state, action) => {
|
||||||
}) => initial)(this.subduxes));
|
return this.upreducer(action)(state);
|
||||||
this.mutations = (0, _buildMutations.default)(config.mutations, this.subduxes);
|
};
|
||||||
this.upreducer = (0, _buildUpreducer.default)(this.initial, this.mutations);
|
this.middleware = buildMiddleware_1.default(config.effects, this.actions, Object.values(this.subduxes).map(sd => sd.middleware));
|
||||||
|
const actions = this.actions;
|
||||||
this.reducer = (state, action) => {
|
this.createStore = buildCreateStore_1.default(this.reducer, this.initial, this.middleware, this.actions);
|
||||||
return this.upreducer(action)(state);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
this.middleware = (0, _buildMiddleware.default)(config.effects, this.actions, config.subduxes);
|
|
||||||
this.createStore = (0, _buildCreateStore.default)(this.reducer, this.initial, this.middleware, this.actions);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Updux = Updux;
|
exports.Updux = Updux;
|
||||||
var _default = Updux;
|
exports.default = Updux;
|
||||||
exports.default = _default;
|
//# sourceMappingURL=updux.js.map
|
1
dist/updux.js.map
vendored
Normal file
1
dist/updux.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"updux.js","sourceRoot":"","sources":["../src/updux.ts"],"names":[],"mappings":";;;;;AAAA,mDAA2B;AAC3B,kEAA0C;AAC1C,kEAA0C;AAC1C,sEAA8C;AAE9C,0EAAkD;AAClD,wEAAgD;AAChD,sEAA8C;AAS9C,MAAa,KAAK;IAkBd,YAAY,MAAmB;QAE3B,IAAI,CAAC,QAAQ,GAAG,YAAE,CAAC,SAAS,CACxB,CAAC,KAAuB,EAAE,EAAE,CAAC,YAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC,YAAE,CAAC,KAAK,CAAC,EAAE,EAAC,UAAU,EAAC,MAAM,CAAC,CAC9F,CAAC;QAGvB,IAAI,CAAC,OAAO,GAAG,sBAAY,CACvB,MAAM,CAAC,OAAO,EACd,CAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,I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I,CAAC,OAAO,CACvD,CAAC;IACzD,CAAC;CAEJ;AA1DD,sBA0DC;AAED,kBAAe,KAAK,CAAC"}
|
@ -24,7 +24,7 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/yanick/updux.git"
|
"url": "git+https://github.com/yanick/updux.git"
|
||||||
|
Loading…
Reference in New Issue
Block a user