reactant-model 0.78.0 → 0.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/build/index.js +0 -2
- package/build/index.js.map +0 -1
- package/build/model.js +0 -51
- package/build/model.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactant-model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"description": "A model lib for Reactant",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"unpkg": "dist/index.umd.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"mutative": "^0.4.2",
|
|
29
|
-
"reactant-module": "^0.
|
|
29
|
+
"reactant-module": "^0.80.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/build/index.js
DELETED
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
package/build/model.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { __assign, __read, __spreadArray } from "tslib";
|
|
2
|
-
import { create } from 'mutative';
|
|
3
|
-
import { storeKey, stateKey, actionIdentifier, enablePatchesKey, enableAutoFreezeKey, identifierKey, nameKey, strictKey, } from 'reactant-module';
|
|
4
|
-
export var model = function (scheme) {
|
|
5
|
-
var _a;
|
|
6
|
-
var module;
|
|
7
|
-
Object.keys(scheme.actions).forEach(function (key) {
|
|
8
|
-
var _a;
|
|
9
|
-
var fn = scheme.actions[key];
|
|
10
|
-
Object.assign(scheme.actions, (_a = {},
|
|
11
|
-
_a[key] = function () {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
var _c;
|
|
14
|
-
var args = [];
|
|
15
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
-
args[_i] = arguments[_i];
|
|
17
|
-
}
|
|
18
|
-
var state;
|
|
19
|
-
var patches;
|
|
20
|
-
var inversePatches;
|
|
21
|
-
if (module[enablePatchesKey]) {
|
|
22
|
-
_a = __read(create(module[stateKey], function (draftState) {
|
|
23
|
-
fn.apply(void 0, __spreadArray([], __read(args), false))(draftState);
|
|
24
|
-
}, {
|
|
25
|
-
enablePatches: true,
|
|
26
|
-
strict: module[strictKey],
|
|
27
|
-
enableAutoFreeze: module[enableAutoFreezeKey],
|
|
28
|
-
}), 3), state = _a[0], patches = _a[1], inversePatches = _a[2];
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
state = create(module[stateKey], function (draftState) {
|
|
32
|
-
fn.apply(void 0, __spreadArray([], __read(args), false))(draftState);
|
|
33
|
-
}, {
|
|
34
|
-
strict: module[strictKey],
|
|
35
|
-
enableAutoFreeze: module[enableAutoFreezeKey],
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
var lastState = (_c = module[storeKey]) === null || _c === void 0 ? void 0 : _c.getState();
|
|
39
|
-
module[storeKey].dispatch(__assign({ type: module[identifierKey], method: key, state: __assign(__assign({}, lastState), (_b = {}, _b[module[identifierKey]] = state, _b)), _reactant: actionIdentifier }, (module[enablePatchesKey]
|
|
40
|
-
? {
|
|
41
|
-
_patches: patches,
|
|
42
|
-
_inversePatches: inversePatches,
|
|
43
|
-
}
|
|
44
|
-
: {})));
|
|
45
|
-
},
|
|
46
|
-
_a));
|
|
47
|
-
});
|
|
48
|
-
module = __assign((_a = {}, _a[nameKey] = scheme.name, _a[stateKey] = __assign({}, scheme.state), _a), scheme.actions);
|
|
49
|
-
return module;
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=model.js.map
|
package/build/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA,OA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