@cclr/model 0.1.28 → 0.1.29
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/lib/cjs/index.js +3 -490
- package/lib/esm/index.js +3 -474
- package/lib/type/index.d.ts +2 -1
- package/package.json +7 -7
package/lib/cjs/index.js
CHANGED
|
@@ -1,490 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var immer = require('immer');
|
|
5
|
-
|
|
6
|
-
var middlewareConfig = {
|
|
7
|
-
showLog: true
|
|
8
|
-
};
|
|
9
|
-
var handleModelMiddlewareConfig = function handleModelMiddlewareConfig(config) {
|
|
10
|
-
Reflect.ownKeys(config).forEach(function (key) {
|
|
11
|
-
if (lang.isString(key)) {
|
|
12
|
-
lang.set(middlewareConfig, key, config[key]);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var gatter = function gatter(ctx) {
|
|
18
|
-
return function (next) {
|
|
19
|
-
return function (params) {
|
|
20
|
-
return new Promise(function ($return, $error) {
|
|
21
|
-
var action, payload, state, actions;
|
|
22
|
-
action = ctx.action, payload = ctx.payload, state = ctx.state, actions = ctx.actions;
|
|
23
|
-
return Promise.resolve(action(payload, {
|
|
24
|
-
state: state,
|
|
25
|
-
actions: actions
|
|
26
|
-
})).then(function ($await_1) {
|
|
27
|
-
try {
|
|
28
|
-
ctx.newState = $await_1;
|
|
29
|
-
return $return(next(params));
|
|
30
|
-
} catch ($boundEx) {
|
|
31
|
-
return $error($boundEx);
|
|
32
|
-
}
|
|
33
|
-
}, $error);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
var gatterSync = function gatterSync(ctx) {
|
|
39
|
-
return function (next) {
|
|
40
|
-
return function (params) {
|
|
41
|
-
var action = ctx.action,
|
|
42
|
-
payload = ctx.payload,
|
|
43
|
-
state = ctx.state,
|
|
44
|
-
actions = ctx.actions;
|
|
45
|
-
ctx.newState = action(payload, {
|
|
46
|
-
state: state,
|
|
47
|
-
actions: actions
|
|
48
|
-
});
|
|
49
|
-
return next(params);
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var logger = function logger(ctx) {
|
|
55
|
-
return function (next) {
|
|
56
|
-
return function (params) {
|
|
57
|
-
return new Promise(function ($return, $error) {
|
|
58
|
-
var showLog, r;
|
|
59
|
-
showLog = middlewareConfig.showLog;
|
|
60
|
-
if (!showLog) {
|
|
61
|
-
return $return(next(params));
|
|
62
|
-
}
|
|
63
|
-
console.log(ctx.modelName, '- action -start: ', ctx.action.name);
|
|
64
|
-
return Promise.resolve(next(params)).then(function ($await_1) {
|
|
65
|
-
try {
|
|
66
|
-
r = $await_1;
|
|
67
|
-
console.log(ctx.modelName, '- action -end: ', ctx.action.name);
|
|
68
|
-
return $return(r);
|
|
69
|
-
} catch ($boundEx) {
|
|
70
|
-
return $error($boundEx);
|
|
71
|
-
}
|
|
72
|
-
}, $error);
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
var loggerSync = function loggerSync(ctx) {
|
|
78
|
-
return function (next) {
|
|
79
|
-
return function (params) {
|
|
80
|
-
var showLog = middlewareConfig.showLog;
|
|
81
|
-
if (!showLog) {
|
|
82
|
-
return next(params);
|
|
83
|
-
}
|
|
84
|
-
console.log(ctx.modelName, '- action -start: ', ctx.action.name);
|
|
85
|
-
var r = next(params);
|
|
86
|
-
console.log(ctx.modelName, '- action -end: ', ctx.action.name);
|
|
87
|
-
return r;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 发布函数
|
|
94
|
-
* @param ctx
|
|
95
|
-
* @returns
|
|
96
|
-
*/
|
|
97
|
-
var publish = function publish(ctx) {
|
|
98
|
-
return function (next) {
|
|
99
|
-
return function (params) {
|
|
100
|
-
var subscribes = ctx.subscribes;
|
|
101
|
-
subscribes === null || subscribes === void 0 || subscribes.forEach(function (callback) {
|
|
102
|
-
callback();
|
|
103
|
-
});
|
|
104
|
-
return next(params);
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
var State = {};
|
|
110
|
-
var Actions = {};
|
|
111
|
-
var Middlewares = {};
|
|
112
|
-
var Subscribes = {
|
|
113
|
-
/*******
|
|
114
|
-
[modelName]: [
|
|
115
|
-
() => { }
|
|
116
|
-
]
|
|
117
|
-
********/
|
|
118
|
-
};
|
|
119
|
-
var GlobalModel = {
|
|
120
|
-
__MId: 1,
|
|
121
|
-
State: State,
|
|
122
|
-
Actions: Actions,
|
|
123
|
-
Subscribes: Subscribes,
|
|
124
|
-
Middlewares: Middlewares
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
var getCtx = function getCtx(modelName) {
|
|
128
|
-
return {
|
|
129
|
-
state: GlobalModel.State[modelName],
|
|
130
|
-
actions: GlobalModel.Actions[modelName],
|
|
131
|
-
subscribes: GlobalModel.Subscribes[modelName],
|
|
132
|
-
middlewares: GlobalModel.Middlewares[modelName]
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
var getState = function getState(modelName) {
|
|
136
|
-
return GlobalModel.State[modelName];
|
|
137
|
-
};
|
|
138
|
-
var getActions = function getActions(modelName) {
|
|
139
|
-
return GlobalModel.Actions[modelName];
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* action返回
|
|
144
|
-
* @param ctx
|
|
145
|
-
* @returns
|
|
146
|
-
*/
|
|
147
|
-
var returnState = function returnState(ctx) {
|
|
148
|
-
return function (_next) {
|
|
149
|
-
return function (_params) {
|
|
150
|
-
return getState(ctx.modelName);
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
var produceState = function produceState(base, recipe) {
|
|
156
|
-
return immer.produce(base, recipe);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
var setter = function setter(ctx) {
|
|
160
|
-
return function (next) {
|
|
161
|
-
return function (params) {
|
|
162
|
-
var modelName = ctx.modelName;
|
|
163
|
-
var newState = ctx.newState;
|
|
164
|
-
if (!newState) {
|
|
165
|
-
return getState(modelName);
|
|
166
|
-
}
|
|
167
|
-
if (lang.isFunction(newState)) {
|
|
168
|
-
newState = produceState(getState(modelName), newState);
|
|
169
|
-
}
|
|
170
|
-
GlobalModel.State = immer.produce(GlobalModel.State, function (draft) {
|
|
171
|
-
draft[modelName] = newState;
|
|
172
|
-
});
|
|
173
|
-
return next(params);
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
var tryCatch = function tryCatch() {
|
|
179
|
-
return function (next) {
|
|
180
|
-
return function (params) {
|
|
181
|
-
return new Promise(function ($return, $error) {
|
|
182
|
-
var _next;
|
|
183
|
-
return Promise.resolve((_next = next(params)) === null || _next === void 0 ? void 0 : _next.catch(function (e) {
|
|
184
|
-
return console.log(e);
|
|
185
|
-
})).then($return, $error);
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
var tryCatchSync = function tryCatchSync() {
|
|
191
|
-
return function (next) {
|
|
192
|
-
return function (params) {
|
|
193
|
-
try {
|
|
194
|
-
return next(params);
|
|
195
|
-
} catch (e) {
|
|
196
|
-
console.log(e);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
var presetMiddleware = [tryCatch, logger, gatter, setter, publish, returnState];
|
|
203
|
-
var presetMiddlewareSync = [tryCatchSync, loggerSync, gatterSync, setter, publish, returnState];
|
|
204
|
-
|
|
205
|
-
var applyMiddleware = function applyMiddleware() {};
|
|
206
|
-
|
|
207
|
-
function _arrayLikeToArray(r, a) {
|
|
208
|
-
(null == a || a > r.length) && (a = r.length);
|
|
209
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
210
|
-
return n;
|
|
211
|
-
}
|
|
212
|
-
function _arrayWithHoles(r) {
|
|
213
|
-
if (Array.isArray(r)) return r;
|
|
214
|
-
}
|
|
215
|
-
function _arrayWithoutHoles(r) {
|
|
216
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
217
|
-
}
|
|
218
|
-
function _defineProperty(e, r, t) {
|
|
219
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
220
|
-
value: t,
|
|
221
|
-
enumerable: true,
|
|
222
|
-
configurable: true,
|
|
223
|
-
writable: true
|
|
224
|
-
}) : e[r] = t, e;
|
|
225
|
-
}
|
|
226
|
-
function _iterableToArray(r) {
|
|
227
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
228
|
-
}
|
|
229
|
-
function _iterableToArrayLimit(r, l) {
|
|
230
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
231
|
-
if (null != t) {
|
|
232
|
-
var e,
|
|
233
|
-
n,
|
|
234
|
-
i,
|
|
235
|
-
u,
|
|
236
|
-
a = [],
|
|
237
|
-
f = true,
|
|
238
|
-
o = false;
|
|
239
|
-
try {
|
|
240
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
241
|
-
} catch (r) {
|
|
242
|
-
o = true, n = r;
|
|
243
|
-
} finally {
|
|
244
|
-
try {
|
|
245
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
246
|
-
} finally {
|
|
247
|
-
if (o) throw n;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return a;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function _nonIterableRest() {
|
|
254
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
255
|
-
}
|
|
256
|
-
function _nonIterableSpread() {
|
|
257
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
258
|
-
}
|
|
259
|
-
function ownKeys(e, r) {
|
|
260
|
-
var t = Object.keys(e);
|
|
261
|
-
if (Object.getOwnPropertySymbols) {
|
|
262
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
263
|
-
r && (o = o.filter(function (r) {
|
|
264
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
265
|
-
})), t.push.apply(t, o);
|
|
266
|
-
}
|
|
267
|
-
return t;
|
|
268
|
-
}
|
|
269
|
-
function _objectSpread2(e) {
|
|
270
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
271
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
272
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
273
|
-
_defineProperty(e, r, t[r]);
|
|
274
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
275
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
return e;
|
|
279
|
-
}
|
|
280
|
-
function _slicedToArray(r, e) {
|
|
281
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
282
|
-
}
|
|
283
|
-
function _toConsumableArray(r) {
|
|
284
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
285
|
-
}
|
|
286
|
-
function _toPrimitive(t, r) {
|
|
287
|
-
if ("object" != typeof t || !t) return t;
|
|
288
|
-
var e = t[Symbol.toPrimitive];
|
|
289
|
-
if (void 0 !== e) {
|
|
290
|
-
var i = e.call(t, r);
|
|
291
|
-
if ("object" != typeof i) return i;
|
|
292
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
293
|
-
}
|
|
294
|
-
return ("string" === r ? String : Number)(t);
|
|
295
|
-
}
|
|
296
|
-
function _toPropertyKey(t) {
|
|
297
|
-
var i = _toPrimitive(t, "string");
|
|
298
|
-
return "symbol" == typeof i ? i : i + "";
|
|
299
|
-
}
|
|
300
|
-
function _unsupportedIterableToArray(r, a) {
|
|
301
|
-
if (r) {
|
|
302
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
303
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
304
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function compose() {
|
|
309
|
-
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
310
|
-
funcs[_key] = arguments[_key];
|
|
311
|
-
}
|
|
312
|
-
if (funcs.length === 0) {
|
|
313
|
-
return function (arg) {
|
|
314
|
-
return arg;
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
if (funcs.length === 1) {
|
|
318
|
-
return funcs[0];
|
|
319
|
-
}
|
|
320
|
-
return funcs.reduce(function (a, b) {
|
|
321
|
-
return function () {
|
|
322
|
-
return a(b.apply(void 0, arguments));
|
|
323
|
-
};
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
var rebuildActions = function rebuildActions(modelName, actions) {
|
|
328
|
-
var updateActions = {};
|
|
329
|
-
Object.entries(actions).forEach(function (_ref) {
|
|
330
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
331
|
-
key = _ref2[0],
|
|
332
|
-
action = _ref2[1];
|
|
333
|
-
updateActions[key] = resetAction(action, modelName);
|
|
334
|
-
});
|
|
335
|
-
return updateActions;
|
|
336
|
-
};
|
|
337
|
-
var resetAction = function resetAction(action, modelName) {
|
|
338
|
-
return function (payload) {
|
|
339
|
-
var _getCtx = getCtx(modelName),
|
|
340
|
-
state = _getCtx.state,
|
|
341
|
-
actions = _getCtx.actions,
|
|
342
|
-
subscribes = _getCtx.subscribes,
|
|
343
|
-
middlewares = _getCtx.middlewares;
|
|
344
|
-
var ctx = {
|
|
345
|
-
payload: payload,
|
|
346
|
-
state: state,
|
|
347
|
-
actions: actions,
|
|
348
|
-
action: action,
|
|
349
|
-
subscribes: subscribes,
|
|
350
|
-
modelName: modelName,
|
|
351
|
-
newState: null,
|
|
352
|
-
setterFun: undefined
|
|
353
|
-
};
|
|
354
|
-
var middlewaresContent = middlewares.map(function (middleware) {
|
|
355
|
-
return middleware(ctx);
|
|
356
|
-
});
|
|
357
|
-
var composeFun = compose.apply(void 0, _toConsumableArray(middlewaresContent));
|
|
358
|
-
return composeFun(function () {
|
|
359
|
-
return getState(modelName);
|
|
360
|
-
})();
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
var initModel = function initModel(models) {
|
|
365
|
-
Object.entries(models).forEach(function (_ref) {
|
|
366
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
367
|
-
modelName = _ref2[0],
|
|
368
|
-
model = _ref2[1];
|
|
369
|
-
GlobalModel.__MId++;
|
|
370
|
-
initSingleModel(modelName, model);
|
|
371
|
-
});
|
|
372
|
-
};
|
|
373
|
-
var initSingleModel = function initSingleModel(modelName, model) {
|
|
374
|
-
GlobalModel.Middlewares[modelName] = model.middleware || presetMiddleware;
|
|
375
|
-
GlobalModel.State = produceState(GlobalModel.State, function (draft) {
|
|
376
|
-
draft[modelName] = model.state;
|
|
377
|
-
});
|
|
378
|
-
GlobalModel.Actions[modelName] = _objectSpread2({}, rebuildActions(modelName, model.actions));
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* 取消订阅 model 的 state 变化
|
|
383
|
-
* @param modelName
|
|
384
|
-
* @param callback
|
|
385
|
-
* @returns
|
|
386
|
-
*/
|
|
387
|
-
var unsubscribe = function unsubscribe(modelName, callback) {
|
|
388
|
-
if (!GlobalModel.Subscribes[modelName]) {
|
|
389
|
-
GlobalModel.Subscribes[modelName] = [];
|
|
390
|
-
}
|
|
391
|
-
GlobalModel.Subscribes[modelName] = GlobalModel.Subscribes[modelName].filter(function (item) {
|
|
392
|
-
return item !== callback;
|
|
393
|
-
});
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* 订阅 model 的 state 变化
|
|
398
|
-
* @param modelName
|
|
399
|
-
* @param callback
|
|
400
|
-
* @returns
|
|
401
|
-
*/
|
|
402
|
-
var subscribe = function subscribe(modelName, callback) {
|
|
403
|
-
if (!GlobalModel.Subscribes[modelName]) {
|
|
404
|
-
GlobalModel.Subscribes[modelName] = [];
|
|
405
|
-
}
|
|
406
|
-
GlobalModel.Subscribes[modelName].push(callback);
|
|
407
|
-
return function () {
|
|
408
|
-
return unsubscribe(modelName, callback);
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Model 类
|
|
414
|
-
*/
|
|
415
|
-
var Model = function Model(models) {
|
|
416
|
-
/** 初始化 */
|
|
417
|
-
initModel(models);
|
|
418
|
-
return {
|
|
419
|
-
getState: getState,
|
|
420
|
-
getActions: getActions,
|
|
421
|
-
subscribe: subscribe,
|
|
422
|
-
unsubscribe: unsubscribe,
|
|
423
|
-
applyMiddleware: applyMiddleware
|
|
424
|
-
};
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Model 类
|
|
429
|
-
*/
|
|
430
|
-
var ModelSingle = function ModelSingle(model) {
|
|
431
|
-
/** 初始化 */
|
|
432
|
-
var mId = GlobalModel.__MId++;
|
|
433
|
-
var modelName = "modelsName-".concat(mId);
|
|
434
|
-
initSingleModel(modelName, model);
|
|
435
|
-
return {
|
|
436
|
-
getState: function getState$1() {
|
|
437
|
-
return getState(modelName);
|
|
438
|
-
},
|
|
439
|
-
getActions: function getActions$1() {
|
|
440
|
-
return getActions(modelName);
|
|
441
|
-
},
|
|
442
|
-
subscribe: function subscribe$1(callback) {
|
|
443
|
-
return subscribe(modelName, callback);
|
|
444
|
-
},
|
|
445
|
-
unsubscribe: function unsubscribe$1(callback) {
|
|
446
|
-
return unsubscribe(modelName, callback);
|
|
447
|
-
},
|
|
448
|
-
applyMiddleware: applyMiddleware
|
|
449
|
-
};
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* 简化的 Model
|
|
454
|
-
* @param value
|
|
455
|
-
* @returns
|
|
456
|
-
*/
|
|
457
|
-
var ModelSimple = function ModelSimple(value) {
|
|
458
|
-
return ModelSingle({
|
|
459
|
-
state: {
|
|
460
|
-
value: value
|
|
461
|
-
},
|
|
462
|
-
actions: {
|
|
463
|
-
setValue: function setValue(value) {
|
|
464
|
-
return function (state) {
|
|
465
|
-
var newValue = value;
|
|
466
|
-
if (lang.isFunction(newValue)) {
|
|
467
|
-
newValue = newValue(state.value);
|
|
468
|
-
}
|
|
469
|
-
state.value = newValue;
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
exports.Model = Model;
|
|
477
|
-
exports.ModelSimple = ModelSimple;
|
|
478
|
-
exports.ModelSingle = ModelSingle;
|
|
479
|
-
exports.gatter = gatter;
|
|
480
|
-
exports.gatterSync = gatterSync;
|
|
481
|
-
exports.handleModelMiddlewareConfig = handleModelMiddlewareConfig;
|
|
482
|
-
exports.logger = logger;
|
|
483
|
-
exports.loggerSync = loggerSync;
|
|
484
|
-
exports.presetMiddleware = presetMiddleware;
|
|
485
|
-
exports.presetMiddlewareSync = presetMiddlewareSync;
|
|
486
|
-
exports.publish = publish;
|
|
487
|
-
exports.returnState = returnState;
|
|
488
|
-
exports.setter = setter;
|
|
489
|
-
exports.tryCatch = tryCatch;
|
|
490
|
-
exports.tryCatchSync = tryCatchSync;
|
|
1
|
+
"use strict";var t=require("@cclr/lang"),n=require("immer"),r={showLog:!0};function e(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=Array(n);r<n;r++)e[r]=t[r];return e}function o(t,n,r,e,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void r(t)}c.done?n(a):Promise.resolve(a).then(e,o)}function i(t){return function(){var n=this,r=arguments;return new Promise(function(e,i){var u=t.apply(n,r);function c(t){o(u,e,i,c,a,"next",t)}function a(t){o(u,e,i,c,a,"throw",t)}c(void 0)})}}function u(t,n,r){return(n=function(t){var n=function(t,n){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,n);if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function c(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,e)}return r}function a(){
|
|
2
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
+
var t,n,r="function"==typeof Symbol?Symbol:{},e=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,e,o,i){var a=e&&e.prototype instanceof c?e:c,s=Object.create(a.prototype);return f(s,"_invoke",function(r,e,o){var i,c,a,f=0,s=o||[],l=!1,p={p:0,n:0,v:t,a:b,f:b.bind(t,4),d:function(n,r){return i=n,c=0,a=t,p.n=r,u}};function b(r,e){for(c=r,a=e,n=0;!l&&f&&!o&&n<s.length;n++){var o,i=s[n],b=p.p,y=i[2];r>3?(o=y===e)&&(a=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=b&&((o=r<2&&b<i[1])?(c=0,p.v=e,p.n=i[1]):b<y&&(o=r<3||i[0]>e||e>y)&&(i[4]=r,i[5]=e,p.n=y,c=0))}if(o||r>1)return u;throw l=!0,e}return function(o,s,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&b(s,y),c=s,a=y;(n=c<2?t:a)||!l;){i||(c?c<3?(c>1&&(p.n=-1),b(c,a)):p.n=a:p.v=a);try{if(f=2,i){if(c||(o="next"),n=i[o]){if(!(n=n.call(i,a)))throw TypeError("iterator result is not an object");if(!n.done)return n;a=n.value,c<2&&(c=0)}else 1===c&&(n=i.return)&&n.call(i),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((n=(l=p.n<0)?a:r.call(e,p))!==u)break}catch(n){i=t,c=1,a=n}finally{f=1}}return{value:n,done:l}}}(r,o,i),!0),s}var u={};function c(){}function s(){}function l(){}n=Object.getPrototypeOf;var p=[][e]?n(n([][e]())):(f(n={},e,function(){return this}),n),b=l.prototype=c.prototype=Object.create(p);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,f(t,o,"GeneratorFunction")),t.prototype=Object.create(b),t}return s.prototype=l,f(b,"constructor",l),f(l,"constructor",s),s.displayName="GeneratorFunction",f(l,o,"GeneratorFunction"),f(b),f(b,o,"Generator"),f(b,e,function(){return this}),f(b,"toString",function(){return"[object Generator]"}),(a=function(){return{w:i,m:y}})()}function f(t,n,r,e){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}f=function(t,n,r,e){function i(n,r){f(t,n,function(t){return this._invoke(n,r,t)})}n?o?o(t,n,{value:r,enumerable:!e,configurable:!e,writable:!e}):t[n]=r:(i("next",0),i("throw",1),i("return",2))},f(t,n,r,e)}function s(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var e,o,i,u,c=[],a=!0,f=!1;try{if(i=(r=r.call(t)).next,0===n);else for(;!(a=(e=i.call(r)).done)&&(c.push(e.value),c.length!==n);a=!0);}catch(t){f=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return c}}(t,n)||p(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||p(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var b=function(t){return function(n){return function(){var r=i(a().m(function r(e){var o,i,u,c;return a().w(function(r){for(;;)switch(r.n){case 0:return o=t.action,i=t.payload,u=t.state,c=t.actions,r.n=1,o(i,{state:u,actions:c});case 1:return t.newState=r.v,r.a(2,n(e))}},r)}));return function(t){return r.apply(this,arguments)}}()}},y=function(t){return function(n){return function(r){var e=t.action,o=t.payload,i=t.state,u=t.actions;return t.newState=e(o,{state:i,actions:u}),n(r)}}},d=function(t){return function(n){return function(){var e=i(a().m(function e(o){var i;return a().w(function(e){for(;;)switch(e.n){case 0:if(r.showLog){e.n=1;break}return e.a(2,n(o));case 1:return console.log(t.modelName,"- action -start: ",t.action.name),e.n=2,n(o);case 2:return i=e.v,console.log(t.modelName,"- action -end: ",t.action.name),e.a(2,i)}},e)}));return function(t){return e.apply(this,arguments)}}()}},v=function(t){return function(n){return function(e){if(!r.showLog)return n(e);console.log(t.modelName,"- action -start: ",t.action.name);var o=n(e);return console.log(t.modelName,"- action -end: ",t.action.name),o}}},m=function(t){return function(n){return function(r){var e=t.subscribes;return null==e||e.forEach(function(t){t()}),n(r)}}},h={__MId:1,State:{},Actions:{},Subscribes:{},Middlewares:{}},g=function(t){return h.State[t]},w=function(t){return h.Actions[t]},S=function(t){return function(n){return function(n){return g(t.modelName)}}},O=function(t,r){return n.produce(t,r)},j=function(r){return function(e){return function(o){var i=r.modelName,u=r.newState;return u?(t.isFunction(u)&&(u=O(g(i),u)),h.State=n.produce(h.State,function(t){t[i]=u}),e(o)):g(i)}}},x=function(){return function(t){return function(){var n=i(a().m(function n(r){var e;return a().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,null===(e=t(r))||void 0===e?void 0:e.catch(function(t){return console.log(t)});case 1:return n.a(2,n.v)}},n)}));return function(t){return n.apply(this,arguments)}}()}},P=function(){return function(t){return function(n){try{return t(n)}catch(t){console.log(t)}}}},A=[x,d,b,j,m,S],M=[P,v,y,j,m,S],E=function(){};function _(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return 0===n.length?function(t){return t}:1===n.length?n[0]:n.reduce(function(t,n){return function(){return t(n.apply(void 0,arguments))}})}var N=function(t,n){return function(r){var e=function(t){return{state:h.State[t],actions:h.Actions[t],subscribes:h.Subscribes[t],middlewares:h.Middlewares[t]}}(n),o=e.state,i=e.actions,u=e.subscribes,c=e.middlewares,a={payload:r,state:o,actions:i,action:t,subscribes:u,modelName:n,newState:null,setterFun:void 0},f=c.map(function(t){return t(a)});return _.apply(void 0,l(f))(function(){return g(n)})()}},T=function(t,n){h.Middlewares[t]=n.middleware||A,h.State=O(h.State,function(r){r[t]=n.state}),h.Actions[t]=function(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?c(Object(r),!0).forEach(function(n){u(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}({},function(t,n){var r={};return Object.entries(n).forEach(function(n){var e=s(n,2),o=e[0],i=e[1];r[o]=N(i,t)}),r}(t,n.actions))},I=function(t,n){h.Subscribes[t]||(h.Subscribes[t]=[]),h.Subscribes[t]=h.Subscribes[t].filter(function(t){return t!==n})},F=function(t,n){return h.Subscribes[t]||(h.Subscribes[t]=[]),h.Subscribes[t].push(n),function(){return I(t,n)}},G=function(t){var n=h.__MId++,r="modelsName-".concat(n);return T(r,t),{getState:function(){return g(r)},getActions:function(){return w(r)},subscribe:function(t){return F(r,t)},unsubscribe:function(t){return I(r,t)},applyMiddleware:E}};exports.Model=function(t){return function(t){Object.entries(t).forEach(function(t){var n=s(t,2),r=n[0],e=n[1];h.__MId++,T(r,e)})}(t),{getState:g,getActions:w,subscribe:F,unsubscribe:I,applyMiddleware:E}},exports.ModelSimple=function(n){return G({state:{value:n},actions:{setValue:function(n){return function(r){var e=n;t.isFunction(e)&&(e=e(r.value)),r.value=e}}}})},exports.ModelSingle=G,exports.gatter=b,exports.gatterSync=y,exports.handleModelMiddlewareConfig=function(n){Reflect.ownKeys(n).forEach(function(e){t.isString(e)&&t.set(r,e,n[e])})},exports.logger=d,exports.loggerSync=v,exports.presetMiddleware=A,exports.presetMiddlewareSync=M,exports.publish=m,exports.returnState=S,exports.setter=j,exports.tryCatch=x,exports.tryCatchSync=P;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,474 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var middlewareConfig = {
|
|
5
|
-
showLog: true
|
|
6
|
-
};
|
|
7
|
-
var handleModelMiddlewareConfig = function handleModelMiddlewareConfig(config) {
|
|
8
|
-
Reflect.ownKeys(config).forEach(function (key) {
|
|
9
|
-
if (isString(key)) {
|
|
10
|
-
set(middlewareConfig, key, config[key]);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
var gatter = function gatter(ctx) {
|
|
16
|
-
return function (next) {
|
|
17
|
-
return function (params) {
|
|
18
|
-
return new Promise(function ($return, $error) {
|
|
19
|
-
var action, payload, state, actions;
|
|
20
|
-
action = ctx.action, payload = ctx.payload, state = ctx.state, actions = ctx.actions;
|
|
21
|
-
return Promise.resolve(action(payload, {
|
|
22
|
-
state: state,
|
|
23
|
-
actions: actions
|
|
24
|
-
})).then(function ($await_1) {
|
|
25
|
-
try {
|
|
26
|
-
ctx.newState = $await_1;
|
|
27
|
-
return $return(next(params));
|
|
28
|
-
} catch ($boundEx) {
|
|
29
|
-
return $error($boundEx);
|
|
30
|
-
}
|
|
31
|
-
}, $error);
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
var gatterSync = function gatterSync(ctx) {
|
|
37
|
-
return function (next) {
|
|
38
|
-
return function (params) {
|
|
39
|
-
var action = ctx.action,
|
|
40
|
-
payload = ctx.payload,
|
|
41
|
-
state = ctx.state,
|
|
42
|
-
actions = ctx.actions;
|
|
43
|
-
ctx.newState = action(payload, {
|
|
44
|
-
state: state,
|
|
45
|
-
actions: actions
|
|
46
|
-
});
|
|
47
|
-
return next(params);
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var logger = function logger(ctx) {
|
|
53
|
-
return function (next) {
|
|
54
|
-
return function (params) {
|
|
55
|
-
return new Promise(function ($return, $error) {
|
|
56
|
-
var showLog, r;
|
|
57
|
-
showLog = middlewareConfig.showLog;
|
|
58
|
-
if (!showLog) {
|
|
59
|
-
return $return(next(params));
|
|
60
|
-
}
|
|
61
|
-
console.log(ctx.modelName, '- action -start: ', ctx.action.name);
|
|
62
|
-
return Promise.resolve(next(params)).then(function ($await_1) {
|
|
63
|
-
try {
|
|
64
|
-
r = $await_1;
|
|
65
|
-
console.log(ctx.modelName, '- action -end: ', ctx.action.name);
|
|
66
|
-
return $return(r);
|
|
67
|
-
} catch ($boundEx) {
|
|
68
|
-
return $error($boundEx);
|
|
69
|
-
}
|
|
70
|
-
}, $error);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
var loggerSync = function loggerSync(ctx) {
|
|
76
|
-
return function (next) {
|
|
77
|
-
return function (params) {
|
|
78
|
-
var showLog = middlewareConfig.showLog;
|
|
79
|
-
if (!showLog) {
|
|
80
|
-
return next(params);
|
|
81
|
-
}
|
|
82
|
-
console.log(ctx.modelName, '- action -start: ', ctx.action.name);
|
|
83
|
-
var r = next(params);
|
|
84
|
-
console.log(ctx.modelName, '- action -end: ', ctx.action.name);
|
|
85
|
-
return r;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 发布函数
|
|
92
|
-
* @param ctx
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
95
|
-
var publish = function publish(ctx) {
|
|
96
|
-
return function (next) {
|
|
97
|
-
return function (params) {
|
|
98
|
-
var subscribes = ctx.subscribes;
|
|
99
|
-
subscribes === null || subscribes === void 0 || subscribes.forEach(function (callback) {
|
|
100
|
-
callback();
|
|
101
|
-
});
|
|
102
|
-
return next(params);
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var State = {};
|
|
108
|
-
var Actions = {};
|
|
109
|
-
var Middlewares = {};
|
|
110
|
-
var Subscribes = {
|
|
111
|
-
/*******
|
|
112
|
-
[modelName]: [
|
|
113
|
-
() => { }
|
|
114
|
-
]
|
|
115
|
-
********/
|
|
116
|
-
};
|
|
117
|
-
var GlobalModel = {
|
|
118
|
-
__MId: 1,
|
|
119
|
-
State: State,
|
|
120
|
-
Actions: Actions,
|
|
121
|
-
Subscribes: Subscribes,
|
|
122
|
-
Middlewares: Middlewares
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
var getCtx = function getCtx(modelName) {
|
|
126
|
-
return {
|
|
127
|
-
state: GlobalModel.State[modelName],
|
|
128
|
-
actions: GlobalModel.Actions[modelName],
|
|
129
|
-
subscribes: GlobalModel.Subscribes[modelName],
|
|
130
|
-
middlewares: GlobalModel.Middlewares[modelName]
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
var getState = function getState(modelName) {
|
|
134
|
-
return GlobalModel.State[modelName];
|
|
135
|
-
};
|
|
136
|
-
var getActions = function getActions(modelName) {
|
|
137
|
-
return GlobalModel.Actions[modelName];
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* action返回
|
|
142
|
-
* @param ctx
|
|
143
|
-
* @returns
|
|
144
|
-
*/
|
|
145
|
-
var returnState = function returnState(ctx) {
|
|
146
|
-
return function (_next) {
|
|
147
|
-
return function (_params) {
|
|
148
|
-
return getState(ctx.modelName);
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
var produceState = function produceState(base, recipe) {
|
|
154
|
-
return produce(base, recipe);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
var setter = function setter(ctx) {
|
|
158
|
-
return function (next) {
|
|
159
|
-
return function (params) {
|
|
160
|
-
var modelName = ctx.modelName;
|
|
161
|
-
var newState = ctx.newState;
|
|
162
|
-
if (!newState) {
|
|
163
|
-
return getState(modelName);
|
|
164
|
-
}
|
|
165
|
-
if (isFunction(newState)) {
|
|
166
|
-
newState = produceState(getState(modelName), newState);
|
|
167
|
-
}
|
|
168
|
-
GlobalModel.State = produce(GlobalModel.State, function (draft) {
|
|
169
|
-
draft[modelName] = newState;
|
|
170
|
-
});
|
|
171
|
-
return next(params);
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
var tryCatch = function tryCatch() {
|
|
177
|
-
return function (next) {
|
|
178
|
-
return function (params) {
|
|
179
|
-
return new Promise(function ($return, $error) {
|
|
180
|
-
var _next;
|
|
181
|
-
return Promise.resolve((_next = next(params)) === null || _next === void 0 ? void 0 : _next.catch(function (e) {
|
|
182
|
-
return console.log(e);
|
|
183
|
-
})).then($return, $error);
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
var tryCatchSync = function tryCatchSync() {
|
|
189
|
-
return function (next) {
|
|
190
|
-
return function (params) {
|
|
191
|
-
try {
|
|
192
|
-
return next(params);
|
|
193
|
-
} catch (e) {
|
|
194
|
-
console.log(e);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
var presetMiddleware = [tryCatch, logger, gatter, setter, publish, returnState];
|
|
201
|
-
var presetMiddlewareSync = [tryCatchSync, loggerSync, gatterSync, setter, publish, returnState];
|
|
202
|
-
|
|
203
|
-
var applyMiddleware = function applyMiddleware() {};
|
|
204
|
-
|
|
205
|
-
function _arrayLikeToArray(r, a) {
|
|
206
|
-
(null == a || a > r.length) && (a = r.length);
|
|
207
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
208
|
-
return n;
|
|
209
|
-
}
|
|
210
|
-
function _arrayWithHoles(r) {
|
|
211
|
-
if (Array.isArray(r)) return r;
|
|
212
|
-
}
|
|
213
|
-
function _arrayWithoutHoles(r) {
|
|
214
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
215
|
-
}
|
|
216
|
-
function _defineProperty(e, r, t) {
|
|
217
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
218
|
-
value: t,
|
|
219
|
-
enumerable: true,
|
|
220
|
-
configurable: true,
|
|
221
|
-
writable: true
|
|
222
|
-
}) : e[r] = t, e;
|
|
223
|
-
}
|
|
224
|
-
function _iterableToArray(r) {
|
|
225
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
226
|
-
}
|
|
227
|
-
function _iterableToArrayLimit(r, l) {
|
|
228
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
229
|
-
if (null != t) {
|
|
230
|
-
var e,
|
|
231
|
-
n,
|
|
232
|
-
i,
|
|
233
|
-
u,
|
|
234
|
-
a = [],
|
|
235
|
-
f = true,
|
|
236
|
-
o = false;
|
|
237
|
-
try {
|
|
238
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
239
|
-
} catch (r) {
|
|
240
|
-
o = true, n = r;
|
|
241
|
-
} finally {
|
|
242
|
-
try {
|
|
243
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
244
|
-
} finally {
|
|
245
|
-
if (o) throw n;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return a;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function _nonIterableRest() {
|
|
252
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
253
|
-
}
|
|
254
|
-
function _nonIterableSpread() {
|
|
255
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
256
|
-
}
|
|
257
|
-
function ownKeys(e, r) {
|
|
258
|
-
var t = Object.keys(e);
|
|
259
|
-
if (Object.getOwnPropertySymbols) {
|
|
260
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
261
|
-
r && (o = o.filter(function (r) {
|
|
262
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
263
|
-
})), t.push.apply(t, o);
|
|
264
|
-
}
|
|
265
|
-
return t;
|
|
266
|
-
}
|
|
267
|
-
function _objectSpread2(e) {
|
|
268
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
269
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
270
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
271
|
-
_defineProperty(e, r, t[r]);
|
|
272
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
273
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
return e;
|
|
277
|
-
}
|
|
278
|
-
function _slicedToArray(r, e) {
|
|
279
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
280
|
-
}
|
|
281
|
-
function _toConsumableArray(r) {
|
|
282
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
283
|
-
}
|
|
284
|
-
function _toPrimitive(t, r) {
|
|
285
|
-
if ("object" != typeof t || !t) return t;
|
|
286
|
-
var e = t[Symbol.toPrimitive];
|
|
287
|
-
if (void 0 !== e) {
|
|
288
|
-
var i = e.call(t, r);
|
|
289
|
-
if ("object" != typeof i) return i;
|
|
290
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
291
|
-
}
|
|
292
|
-
return ("string" === r ? String : Number)(t);
|
|
293
|
-
}
|
|
294
|
-
function _toPropertyKey(t) {
|
|
295
|
-
var i = _toPrimitive(t, "string");
|
|
296
|
-
return "symbol" == typeof i ? i : i + "";
|
|
297
|
-
}
|
|
298
|
-
function _unsupportedIterableToArray(r, a) {
|
|
299
|
-
if (r) {
|
|
300
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
301
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
302
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function compose() {
|
|
307
|
-
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
308
|
-
funcs[_key] = arguments[_key];
|
|
309
|
-
}
|
|
310
|
-
if (funcs.length === 0) {
|
|
311
|
-
return function (arg) {
|
|
312
|
-
return arg;
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
if (funcs.length === 1) {
|
|
316
|
-
return funcs[0];
|
|
317
|
-
}
|
|
318
|
-
return funcs.reduce(function (a, b) {
|
|
319
|
-
return function () {
|
|
320
|
-
return a(b.apply(void 0, arguments));
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
var rebuildActions = function rebuildActions(modelName, actions) {
|
|
326
|
-
var updateActions = {};
|
|
327
|
-
Object.entries(actions).forEach(function (_ref) {
|
|
328
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
329
|
-
key = _ref2[0],
|
|
330
|
-
action = _ref2[1];
|
|
331
|
-
updateActions[key] = resetAction(action, modelName);
|
|
332
|
-
});
|
|
333
|
-
return updateActions;
|
|
334
|
-
};
|
|
335
|
-
var resetAction = function resetAction(action, modelName) {
|
|
336
|
-
return function (payload) {
|
|
337
|
-
var _getCtx = getCtx(modelName),
|
|
338
|
-
state = _getCtx.state,
|
|
339
|
-
actions = _getCtx.actions,
|
|
340
|
-
subscribes = _getCtx.subscribes,
|
|
341
|
-
middlewares = _getCtx.middlewares;
|
|
342
|
-
var ctx = {
|
|
343
|
-
payload: payload,
|
|
344
|
-
state: state,
|
|
345
|
-
actions: actions,
|
|
346
|
-
action: action,
|
|
347
|
-
subscribes: subscribes,
|
|
348
|
-
modelName: modelName,
|
|
349
|
-
newState: null,
|
|
350
|
-
setterFun: undefined
|
|
351
|
-
};
|
|
352
|
-
var middlewaresContent = middlewares.map(function (middleware) {
|
|
353
|
-
return middleware(ctx);
|
|
354
|
-
});
|
|
355
|
-
var composeFun = compose.apply(void 0, _toConsumableArray(middlewaresContent));
|
|
356
|
-
return composeFun(function () {
|
|
357
|
-
return getState(modelName);
|
|
358
|
-
})();
|
|
359
|
-
};
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
var initModel = function initModel(models) {
|
|
363
|
-
Object.entries(models).forEach(function (_ref) {
|
|
364
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
365
|
-
modelName = _ref2[0],
|
|
366
|
-
model = _ref2[1];
|
|
367
|
-
GlobalModel.__MId++;
|
|
368
|
-
initSingleModel(modelName, model);
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
var initSingleModel = function initSingleModel(modelName, model) {
|
|
372
|
-
GlobalModel.Middlewares[modelName] = model.middleware || presetMiddleware;
|
|
373
|
-
GlobalModel.State = produceState(GlobalModel.State, function (draft) {
|
|
374
|
-
draft[modelName] = model.state;
|
|
375
|
-
});
|
|
376
|
-
GlobalModel.Actions[modelName] = _objectSpread2({}, rebuildActions(modelName, model.actions));
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* 取消订阅 model 的 state 变化
|
|
381
|
-
* @param modelName
|
|
382
|
-
* @param callback
|
|
383
|
-
* @returns
|
|
384
|
-
*/
|
|
385
|
-
var unsubscribe = function unsubscribe(modelName, callback) {
|
|
386
|
-
if (!GlobalModel.Subscribes[modelName]) {
|
|
387
|
-
GlobalModel.Subscribes[modelName] = [];
|
|
388
|
-
}
|
|
389
|
-
GlobalModel.Subscribes[modelName] = GlobalModel.Subscribes[modelName].filter(function (item) {
|
|
390
|
-
return item !== callback;
|
|
391
|
-
});
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* 订阅 model 的 state 变化
|
|
396
|
-
* @param modelName
|
|
397
|
-
* @param callback
|
|
398
|
-
* @returns
|
|
399
|
-
*/
|
|
400
|
-
var subscribe = function subscribe(modelName, callback) {
|
|
401
|
-
if (!GlobalModel.Subscribes[modelName]) {
|
|
402
|
-
GlobalModel.Subscribes[modelName] = [];
|
|
403
|
-
}
|
|
404
|
-
GlobalModel.Subscribes[modelName].push(callback);
|
|
405
|
-
return function () {
|
|
406
|
-
return unsubscribe(modelName, callback);
|
|
407
|
-
};
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Model 类
|
|
412
|
-
*/
|
|
413
|
-
var Model = function Model(models) {
|
|
414
|
-
/** 初始化 */
|
|
415
|
-
initModel(models);
|
|
416
|
-
return {
|
|
417
|
-
getState: getState,
|
|
418
|
-
getActions: getActions,
|
|
419
|
-
subscribe: subscribe,
|
|
420
|
-
unsubscribe: unsubscribe,
|
|
421
|
-
applyMiddleware: applyMiddleware
|
|
422
|
-
};
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Model 类
|
|
427
|
-
*/
|
|
428
|
-
var ModelSingle = function ModelSingle(model) {
|
|
429
|
-
/** 初始化 */
|
|
430
|
-
var mId = GlobalModel.__MId++;
|
|
431
|
-
var modelName = "modelsName-".concat(mId);
|
|
432
|
-
initSingleModel(modelName, model);
|
|
433
|
-
return {
|
|
434
|
-
getState: function getState$1() {
|
|
435
|
-
return getState(modelName);
|
|
436
|
-
},
|
|
437
|
-
getActions: function getActions$1() {
|
|
438
|
-
return getActions(modelName);
|
|
439
|
-
},
|
|
440
|
-
subscribe: function subscribe$1(callback) {
|
|
441
|
-
return subscribe(modelName, callback);
|
|
442
|
-
},
|
|
443
|
-
unsubscribe: function unsubscribe$1(callback) {
|
|
444
|
-
return unsubscribe(modelName, callback);
|
|
445
|
-
},
|
|
446
|
-
applyMiddleware: applyMiddleware
|
|
447
|
-
};
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* 简化的 Model
|
|
452
|
-
* @param value
|
|
453
|
-
* @returns
|
|
454
|
-
*/
|
|
455
|
-
var ModelSimple = function ModelSimple(value) {
|
|
456
|
-
return ModelSingle({
|
|
457
|
-
state: {
|
|
458
|
-
value: value
|
|
459
|
-
},
|
|
460
|
-
actions: {
|
|
461
|
-
setValue: function setValue(value) {
|
|
462
|
-
return function (state) {
|
|
463
|
-
var newValue = value;
|
|
464
|
-
if (isFunction(newValue)) {
|
|
465
|
-
newValue = newValue(state.value);
|
|
466
|
-
}
|
|
467
|
-
state.value = newValue;
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
export { Model, ModelSimple, ModelSingle, gatter, gatterSync, handleModelMiddlewareConfig, logger, loggerSync, presetMiddleware, presetMiddlewareSync, publish, returnState, setter, tryCatch, tryCatchSync };
|
|
1
|
+
import{isString as t,set as n,isFunction as r}from"@cclr/lang";import{produce as e}from"immer";var o={showLog:!0},u=function(r){Reflect.ownKeys(r).forEach(function(e){t(e)&&n(o,e,r[e])})};function i(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=Array(n);r<n;r++)e[r]=t[r];return e}function c(t,n,r,e,o,u,i){try{var c=t[u](i),a=c.value}catch(t){return void r(t)}c.done?n(a):Promise.resolve(a).then(e,o)}function a(t){return function(){var n=this,r=arguments;return new Promise(function(e,o){var u=t.apply(n,r);function i(t){c(u,e,o,i,a,"next",t)}function a(t){c(u,e,o,i,a,"throw",t)}i(void 0)})}}function f(t,n,r){return(n=function(t){var n=function(t,n){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var e=r.call(t,n);if("object"!=typeof e)return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:n+""}(n))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function s(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,e)}return r}function l(){
|
|
2
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
+
var t,n,r="function"==typeof Symbol?Symbol:{},e=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function u(r,e,o,u){var a=e&&e.prototype instanceof c?e:c,f=Object.create(a.prototype);return b(f,"_invoke",function(r,e,o){var u,c,a,f=0,s=o||[],l=!1,b={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(n,r){return u=n,c=0,a=t,b.n=r,i}};function p(r,e){for(c=r,a=e,n=0;!l&&f&&!o&&n<s.length;n++){var o,u=s[n],p=b.p,y=u[2];r>3?(o=y===e)&&(a=u[(c=u[4])?5:(c=3,3)],u[4]=u[5]=t):u[0]<=p&&((o=r<2&&p<u[1])?(c=0,b.v=e,b.n=u[1]):p<y&&(o=r<3||u[0]>e||e>y)&&(u[4]=r,u[5]=e,b.n=y,c=0))}if(o||r>1)return i;throw l=!0,e}return function(o,s,y){if(f>1)throw TypeError("Generator is already running");for(l&&1===s&&p(s,y),c=s,a=y;(n=c<2?t:a)||!l;){u||(c?c<3?(c>1&&(b.n=-1),p(c,a)):b.n=a:b.v=a);try{if(f=2,u){if(c||(o="next"),n=u[o]){if(!(n=n.call(u,a)))throw TypeError("iterator result is not an object");if(!n.done)return n;a=n.value,c<2&&(c=0)}else 1===c&&(n=u.return)&&n.call(u),c<2&&(a=TypeError("The iterator does not provide a '"+o+"' method"),c=1);u=t}else if((n=(l=b.n<0)?a:r.call(e,b))!==i)break}catch(n){u=t,c=1,a=n}finally{f=1}}return{value:n,done:l}}}(r,o,u),!0),f}var i={};function c(){}function a(){}function f(){}n=Object.getPrototypeOf;var s=[][e]?n(n([][e]())):(b(n={},e,function(){return this}),n),p=f.prototype=c.prototype=Object.create(s);function y(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,b(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return a.prototype=f,b(p,"constructor",f),b(f,"constructor",a),a.displayName="GeneratorFunction",b(f,o,"GeneratorFunction"),b(p),b(p,o,"Generator"),b(p,e,function(){return this}),b(p,"toString",function(){return"[object Generator]"}),(l=function(){return{w:u,m:y}})()}function b(t,n,r,e){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}b=function(t,n,r,e){function u(n,r){b(t,n,function(t){return this._invoke(n,r,t)})}n?o?o(t,n,{value:r,enumerable:!e,configurable:!e,writable:!e}):t[n]=r:(u("next",0),u("throw",1),u("return",2))},b(t,n,r,e)}function p(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var e,o,u,i,c=[],a=!0,f=!1;try{if(u=(r=r.call(t)).next,0===n);else for(;!(a=(e=u.call(r)).done)&&(c.push(e.value),c.length!==n);a=!0);}catch(t){f=!0,o=t}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(f)throw o}}return c}}(t,n)||v(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t,n){if(t){if("string"==typeof t)return i(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,n):void 0}}var d=function(t){return function(n){return function(){var r=a(l().m(function r(e){var o,u,i,c;return l().w(function(r){for(;;)switch(r.n){case 0:return o=t.action,u=t.payload,i=t.state,c=t.actions,r.n=1,o(u,{state:i,actions:c});case 1:return t.newState=r.v,r.a(2,n(e))}},r)}));return function(t){return r.apply(this,arguments)}}()}},m=function(t){return function(n){return function(r){var e=t.action,o=t.payload,u=t.state,i=t.actions;return t.newState=e(o,{state:u,actions:i}),n(r)}}},h=function(t){return function(n){return function(){var r=a(l().m(function r(e){var u;return l().w(function(r){for(;;)switch(r.n){case 0:if(o.showLog){r.n=1;break}return r.a(2,n(e));case 1:return console.log(t.modelName,"- action -start: ",t.action.name),r.n=2,n(e);case 2:return u=r.v,console.log(t.modelName,"- action -end: ",t.action.name),r.a(2,u)}},r)}));return function(t){return r.apply(this,arguments)}}()}},w=function(t){return function(n){return function(r){if(!o.showLog)return n(r);console.log(t.modelName,"- action -start: ",t.action.name);var e=n(r);return console.log(t.modelName,"- action -end: ",t.action.name),e}}},g=function(t){return function(n){return function(r){var e=t.subscribes;return null==e||e.forEach(function(t){t()}),n(r)}}},S={__MId:1,State:{},Actions:{},Subscribes:{},Middlewares:{}},O=function(t){return S.State[t]},j=function(t){return S.Actions[t]},P=function(t){return function(n){return function(n){return O(t.modelName)}}},A=function(t,n){return e(t,n)},E=function(t){return function(n){return function(o){var u=t.modelName,i=t.newState;return i?(r(i)&&(i=A(O(u),i)),S.State=e(S.State,function(t){t[u]=i}),n(o)):O(u)}}},_=function(){return function(t){return function(){var n=a(l().m(function n(r){var e;return l().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,null===(e=t(r))||void 0===e?void 0:e.catch(function(t){return console.log(t)});case 1:return n.a(2,n.v)}},n)}));return function(t){return n.apply(this,arguments)}}()}},N=function(){return function(t){return function(n){try{return t(n)}catch(t){console.log(t)}}}},M=[_,h,d,E,g,P],T=[N,w,m,E,g,P],I=function(){};function G(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return 0===n.length?function(t){return t}:1===n.length?n[0]:n.reduce(function(t,n){return function(){return t(n.apply(void 0,arguments))}})}var k=function(t,n){return function(r){var e=function(t){return{state:S.State[t],actions:S.Actions[t],subscribes:S.Subscribes[t],middlewares:S.Middlewares[t]}}(n),o=e.state,u=e.actions,i=e.subscribes,c=e.middlewares,a={payload:r,state:o,actions:u,action:t,subscribes:i,modelName:n,newState:null,setterFun:void 0},f=c.map(function(t){return t(a)});return G.apply(void 0,y(f))(function(){return O(n)})()}},x=function(t,n){S.Middlewares[t]=n.middleware||M,S.State=A(S.State,function(r){r[t]=n.state}),S.Actions[t]=function(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?s(Object(r),!0).forEach(function(n){f(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}({},function(t,n){var r={};return Object.entries(n).forEach(function(n){var e=p(n,2),o=e[0],u=e[1];r[o]=k(u,t)}),r}(t,n.actions))},D=function(t,n){S.Subscribes[t]||(S.Subscribes[t]=[]),S.Subscribes[t]=S.Subscribes[t].filter(function(t){return t!==n})},F=function(t,n){return S.Subscribes[t]||(S.Subscribes[t]=[]),S.Subscribes[t].push(n),function(){return D(t,n)}},L=function(t){return function(t){Object.entries(t).forEach(function(t){var n=p(t,2),r=n[0],e=n[1];S.__MId++,x(r,e)})}(t),{getState:O,getActions:j,subscribe:F,unsubscribe:D,applyMiddleware:I}},C=function(t){var n=S.__MId++,r="modelsName-".concat(n);return x(r,t),{getState:function(){return O(r)},getActions:function(){return j(r)},subscribe:function(t){return F(r,t)},unsubscribe:function(t){return D(r,t)},applyMiddleware:I}},K=function(t){return C({state:{value:t},actions:{setValue:function(t){return function(n){var e=t;r(e)&&(e=e(n.value)),n.value=e}}}})};export{L as Model,K as ModelSimple,C as ModelSingle,d as gatter,m as gatterSync,u as handleModelMiddlewareConfig,h as logger,w as loggerSync,M as presetMiddleware,T as presetMiddlewareSync,g as publish,P as returnState,E as setter,_ as tryCatch,N as tryCatchSync};
|
package/lib/type/index.d.ts
CHANGED
|
@@ -164,4 +164,5 @@ declare const ModelSimple: <T extends IState["value"]>(value: T) => TModelSimple
|
|
|
164
164
|
*/
|
|
165
165
|
declare const ModelSingle: <MT extends ModelType>(model: MT) => ModelsSingleApi<MT>;
|
|
166
166
|
|
|
167
|
-
export { Model, ModelSimple, ModelSingle,
|
|
167
|
+
export { Model, ModelSimple, ModelSingle, gatter, gatterSync, handleModelMiddlewareConfig, logger, loggerSync, presetMiddleware, presetMiddlewareSync, publish, returnState, setter, tryCatch, tryCatchSync };
|
|
168
|
+
export type { ModelType, ModelsApi, ModelsSingleApi, ModelsType, TAction, TActionMapApi, TGetActionsType, TGetStateType, TMiddleware, TSubscribesFun };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclr/model",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "前端开发状态管理",
|
|
5
5
|
"author": "cclr <18843152354@163.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "vitest",
|
|
25
25
|
"relese": "npm run test && npm publish",
|
|
26
|
-
"build": "
|
|
26
|
+
"build": "drr build",
|
|
27
27
|
"g:test": "vitest run",
|
|
28
|
-
"g:build": "
|
|
28
|
+
"g:build": "drr build"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1d49762197a47eb6aa9b2bd012fead57e38c7ad1",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cclr/lang": "0.1.
|
|
33
|
-
"@cclr/utils": "0.1.
|
|
34
|
-
"immer": "^10.
|
|
32
|
+
"@cclr/lang": "0.1.29",
|
|
33
|
+
"@cclr/utils": "0.1.29",
|
|
34
|
+
"immer": "^10.2.0"
|
|
35
35
|
}
|
|
36
36
|
}
|