as-model 0.3.3 → 0.4.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/README.md +571 -558
- package/dist/index.js +66 -75
- package/esm/index.js +13 -18
- package/esm/key/index.js +2 -2
- package/index.d.ts +1 -17
- package/package.json +68 -68
package/dist/index.js
CHANGED
|
@@ -21,12 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
config: () => config,
|
|
24
|
-
createKey: () => createKey2,
|
|
25
24
|
createSelector: () => createSelector,
|
|
26
25
|
createSignal: () => createSignal,
|
|
27
|
-
createStore: () => createStore2,
|
|
28
|
-
createStores: () => createStores2,
|
|
29
|
-
model: () => model,
|
|
30
26
|
shallowEqual: () => shallowEqual,
|
|
31
27
|
validations: () => validations
|
|
32
28
|
});
|
|
@@ -420,9 +416,9 @@ function generateNotifier(updater, middleWare) {
|
|
|
420
416
|
});
|
|
421
417
|
}
|
|
422
418
|
var dispatch = function dispatch2(action) {
|
|
423
|
-
var dispatches = updater.dispatches, controlled = updater.controlled,
|
|
419
|
+
var dispatches = updater.dispatches, controlled = updater.controlled, model = updater.model, config3 = updater.config;
|
|
424
420
|
var state = action.state;
|
|
425
|
-
var nextInstance =
|
|
421
|
+
var nextInstance = model(state);
|
|
426
422
|
var nextAction = _object_spread_props(_object_spread({}, action), {
|
|
427
423
|
instance: nextInstance
|
|
428
424
|
});
|
|
@@ -465,8 +461,8 @@ function generateNotifier(updater, middleWare) {
|
|
|
465
461
|
throw errors[0];
|
|
466
462
|
};
|
|
467
463
|
try {
|
|
468
|
-
if (typeof
|
|
469
|
-
|
|
464
|
+
if (typeof config3.notify === "function") {
|
|
465
|
+
config3.notify(notifyAction, nextAction);
|
|
470
466
|
} else {
|
|
471
467
|
notifyActionWithErrorThrow(nextAction);
|
|
472
468
|
}
|
|
@@ -667,7 +663,7 @@ function createUpdateFn(updater, middleWare) {
|
|
|
667
663
|
var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
668
664
|
updater.mutate(function(u, effect) {
|
|
669
665
|
var _args_model;
|
|
670
|
-
var
|
|
666
|
+
var model = (_args_model = args.model) !== null && _args_model !== void 0 ? _args_model : u.model;
|
|
671
667
|
var hasState = Object.prototype.hasOwnProperty.call(args, "state");
|
|
672
668
|
var hasInitialState = Object.prototype.hasOwnProperty.call(args, "initialState");
|
|
673
669
|
var state = hasState ? args.state : u.state;
|
|
@@ -675,11 +671,11 @@ function createUpdateFn(updater, middleWare) {
|
|
|
675
671
|
var token = createToken();
|
|
676
672
|
if (u.controlled) {
|
|
677
673
|
var controlledState = hasInitialState && !hasState ? args.initialState : state;
|
|
678
|
-
var instance =
|
|
674
|
+
var instance = model(controlledState);
|
|
679
675
|
return _object_spread_props(_object_spread({}, u), {
|
|
680
676
|
state: controlledState,
|
|
681
677
|
instance,
|
|
682
|
-
model
|
|
678
|
+
model
|
|
683
679
|
});
|
|
684
680
|
}
|
|
685
681
|
if (u.isDestroyed) {
|
|
@@ -690,17 +686,17 @@ function createUpdateFn(updater, middleWare) {
|
|
|
690
686
|
}
|
|
691
687
|
if (isInitialize) {
|
|
692
688
|
var initialState = hasInitialState ? args.initialState : state;
|
|
693
|
-
var instance1 =
|
|
689
|
+
var instance1 = model(initialState);
|
|
694
690
|
var initializedUpdater = createInitializedUpdater(u, middleWare);
|
|
695
691
|
return _object_spread(_object_spread_props(_object_spread({}, u), {
|
|
696
|
-
model
|
|
692
|
+
model,
|
|
697
693
|
state: initialState,
|
|
698
694
|
instance: instance1,
|
|
699
695
|
initialized: true,
|
|
700
696
|
token
|
|
701
697
|
}), initializedUpdater);
|
|
702
698
|
}
|
|
703
|
-
if (Object.is(u.model,
|
|
699
|
+
if (Object.is(u.model, model) && Object.is(u.state, state)) {
|
|
704
700
|
return u;
|
|
705
701
|
}
|
|
706
702
|
effect(function(up) {
|
|
@@ -714,7 +710,7 @@ function createUpdateFn(updater, middleWare) {
|
|
|
714
710
|
});
|
|
715
711
|
});
|
|
716
712
|
return _object_spread_props(_object_spread({}, u), {
|
|
717
|
-
model
|
|
713
|
+
model,
|
|
718
714
|
initialized: true,
|
|
719
715
|
cacheFields: {},
|
|
720
716
|
cacheMethods: {}
|
|
@@ -723,18 +719,18 @@ function createUpdateFn(updater, middleWare) {
|
|
|
723
719
|
};
|
|
724
720
|
}
|
|
725
721
|
var lazyModel = createNoStateModel();
|
|
726
|
-
function createUpdater(
|
|
727
|
-
var
|
|
728
|
-
var hasDefaultState = "state" in
|
|
729
|
-
var controlled =
|
|
730
|
-
var defaultInstance = hasDefaultState ?
|
|
722
|
+
function createUpdater(model, middleWare) {
|
|
723
|
+
var config3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
724
|
+
var hasDefaultState = "state" in config3;
|
|
725
|
+
var controlled = config3.controlled, defaultState = config3.state;
|
|
726
|
+
var defaultInstance = hasDefaultState ? model(defaultState) : lazyModel(void 0);
|
|
731
727
|
var unInitializedUpdater = createUnInitializedUpdater();
|
|
732
728
|
var updater = _object_spread({
|
|
733
729
|
sidePayload: void 0,
|
|
734
730
|
version: 0,
|
|
735
731
|
token: createToken(),
|
|
736
732
|
isDestroyed: false,
|
|
737
|
-
model
|
|
733
|
+
model,
|
|
738
734
|
instance: defaultInstance,
|
|
739
735
|
dispatch: null,
|
|
740
736
|
dispatches: [],
|
|
@@ -745,7 +741,7 @@ function createUpdater(model2, middleWare) {
|
|
|
745
741
|
initialized: hasDefaultState,
|
|
746
742
|
controlled: !!controlled,
|
|
747
743
|
isSubscribing: false,
|
|
748
|
-
config:
|
|
744
|
+
config: config3,
|
|
749
745
|
payload: function payload(setter) {
|
|
750
746
|
if (typeof setter === "function") {
|
|
751
747
|
updater.sidePayload = setter(updater.sidePayload);
|
|
@@ -1222,42 +1218,42 @@ function createSelector(store, opts) {
|
|
|
1222
1218
|
|
|
1223
1219
|
// src/store/index.ts
|
|
1224
1220
|
function createPrimaryKey(modelFn) {
|
|
1225
|
-
var
|
|
1221
|
+
var config3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1226
1222
|
var ifModelKey = isModelKey(modelFn);
|
|
1227
1223
|
var ifModelUsage = isModelUsage(modelFn);
|
|
1228
|
-
var
|
|
1224
|
+
var model = ifModelKey ? modelFn.source : modelFn;
|
|
1229
1225
|
var _config_wrapper;
|
|
1230
|
-
var wrapper = (_config_wrapper =
|
|
1226
|
+
var wrapper = (_config_wrapper = config3.wrapper) !== null && _config_wrapper !== void 0 ? _config_wrapper : ifModelKey || ifModelUsage ? modelFn.wrapper : function defaultSelector2(i) {
|
|
1231
1227
|
return i();
|
|
1232
1228
|
};
|
|
1233
1229
|
var wrapModel = function wrapModel2(state) {
|
|
1234
|
-
return
|
|
1230
|
+
return model(state);
|
|
1235
1231
|
};
|
|
1236
|
-
wrapModel.source =
|
|
1232
|
+
wrapModel.source = model;
|
|
1237
1233
|
wrapModel.wrapper = wrapper;
|
|
1238
1234
|
wrapModel.modelKeyIdentifier = modelKeyIdentifier;
|
|
1239
|
-
if ("state" in
|
|
1240
|
-
wrapModel.defaultState =
|
|
1235
|
+
if ("state" in config3) {
|
|
1236
|
+
wrapModel.defaultState = config3.state;
|
|
1241
1237
|
}
|
|
1242
1238
|
return wrapModel;
|
|
1243
1239
|
}
|
|
1244
1240
|
function createStore(modelLike) {
|
|
1245
|
-
var
|
|
1241
|
+
var config3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1246
1242
|
var ifModelKey = isModelKey(modelLike);
|
|
1247
|
-
var
|
|
1243
|
+
var model = ifModelKey ? modelLike.source : modelLike;
|
|
1248
1244
|
var modelKey = ifModelKey ? modelLike : void 0;
|
|
1249
1245
|
var conf = function computeConfig() {
|
|
1250
|
-
var hasConfigState = "state" in
|
|
1246
|
+
var hasConfigState = "state" in config3;
|
|
1251
1247
|
var hasKeyState = !!modelKey && "defaultState" in modelKey;
|
|
1252
1248
|
if (hasConfigState) {
|
|
1253
|
-
return
|
|
1249
|
+
return config3;
|
|
1254
1250
|
}
|
|
1255
1251
|
if (hasKeyState) {
|
|
1256
|
-
return _object_spread_props(_object_spread({},
|
|
1252
|
+
return _object_spread_props(_object_spread({}, config3), {
|
|
1257
1253
|
state: modelKey === null || modelKey === void 0 ? void 0 : modelKey.defaultState
|
|
1258
1254
|
});
|
|
1259
1255
|
}
|
|
1260
|
-
return
|
|
1256
|
+
return config3;
|
|
1261
1257
|
}();
|
|
1262
1258
|
var combinedMiddleWare = function combinedMiddleWare2(s) {
|
|
1263
1259
|
return function updaterMiddleWare(next) {
|
|
@@ -1273,8 +1269,8 @@ function createStore(modelLike) {
|
|
|
1273
1269
|
}, next);
|
|
1274
1270
|
};
|
|
1275
1271
|
};
|
|
1276
|
-
var updater = createUpdater(
|
|
1277
|
-
var key = modelKey !== null && modelKey !== void 0 ? modelKey : createPrimaryKey(
|
|
1272
|
+
var updater = createUpdater(model, combinedMiddleWare, conf);
|
|
1273
|
+
var key = modelKey !== null && modelKey !== void 0 ? modelKey : createPrimaryKey(model, config3);
|
|
1278
1274
|
var propertiesCache = {
|
|
1279
1275
|
target: updater.instance,
|
|
1280
1276
|
cacheFields: {},
|
|
@@ -1317,7 +1313,7 @@ function createStore(modelLike) {
|
|
|
1317
1313
|
updater.update(_object_spread_props(_object_spread({}, rest1), {
|
|
1318
1314
|
model: updatingModel1
|
|
1319
1315
|
}));
|
|
1320
|
-
store.key = createPrimaryKey(updatingModel1,
|
|
1316
|
+
store.key = createPrimaryKey(updatingModel1, config3);
|
|
1321
1317
|
return;
|
|
1322
1318
|
}
|
|
1323
1319
|
updater.update(args);
|
|
@@ -1343,12 +1339,12 @@ var createField2 = createField;
|
|
|
1343
1339
|
var createMethod2 = createMethod;
|
|
1344
1340
|
|
|
1345
1341
|
// src/key/index.ts
|
|
1346
|
-
function createKey(
|
|
1347
|
-
var
|
|
1348
|
-
var wrapModel = createPrimaryKey(
|
|
1342
|
+
function createKey(model) {
|
|
1343
|
+
var config3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1344
|
+
var wrapModel = createPrimaryKey(model, config3);
|
|
1349
1345
|
wrapModel.createStore = function createKeyStore() {
|
|
1350
1346
|
var storeConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1351
|
-
return createStore(wrapModel, _object_spread({},
|
|
1347
|
+
return createStore(wrapModel, _object_spread({}, config3, storeConfig));
|
|
1352
1348
|
};
|
|
1353
1349
|
wrapModel.extends = function extendsKey(e) {
|
|
1354
1350
|
return Object.assign(wrapModel, e);
|
|
@@ -1357,18 +1353,18 @@ function createKey(model2) {
|
|
|
1357
1353
|
}
|
|
1358
1354
|
createKey.isModelKey = isModelKey;
|
|
1359
1355
|
function createStores(modelKeys) {
|
|
1360
|
-
var
|
|
1356
|
+
var config3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1361
1357
|
var state = {
|
|
1362
1358
|
destroyed: false
|
|
1363
1359
|
};
|
|
1364
1360
|
var storeUnits = modelKeys.map(function(modelKey) {
|
|
1365
|
-
if (typeof modelKey === "function") {
|
|
1361
|
+
if (typeof modelKey === "function" && typeof modelKey.createStore === "function") {
|
|
1366
1362
|
return modelKey.createStore();
|
|
1367
1363
|
}
|
|
1368
|
-
var k = modelKey.key;
|
|
1369
|
-
return createStore(k, "defaultState" in k ? _object_spread_props(_object_spread({},
|
|
1364
|
+
var k = typeof modelKey === "function" ? modelKey : modelKey.key;
|
|
1365
|
+
return createStore(k, "defaultState" in k ? _object_spread_props(_object_spread({}, config3), {
|
|
1370
1366
|
state: k.defaultState
|
|
1371
|
-
}) :
|
|
1367
|
+
}) : config3);
|
|
1372
1368
|
});
|
|
1373
1369
|
return {
|
|
1374
1370
|
find: function find(key) {
|
|
@@ -1418,28 +1414,28 @@ function createStores(modelKeys) {
|
|
|
1418
1414
|
}
|
|
1419
1415
|
|
|
1420
1416
|
// src/model/index.ts
|
|
1421
|
-
function configModel(
|
|
1422
|
-
var
|
|
1417
|
+
function configModel(config3) {
|
|
1418
|
+
var model = function model2(modelFn, wrapper) {
|
|
1423
1419
|
var currentSelector = wrapper !== null && wrapper !== void 0 ? wrapper : defaultSelector;
|
|
1424
1420
|
var modelWrapper = function modelWrapper2(state) {
|
|
1425
1421
|
return modelFn(state);
|
|
1426
1422
|
};
|
|
1427
1423
|
modelWrapper.produce = function produce(s) {
|
|
1428
|
-
return
|
|
1424
|
+
return model2(modelFn, s);
|
|
1429
1425
|
};
|
|
1430
1426
|
modelWrapper.createKey = function createModelKey(state) {
|
|
1431
|
-
return createKey(modelFn, arguments.length ? _object_spread_props(_object_spread({},
|
|
1427
|
+
return createKey(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config3), {
|
|
1432
1428
|
state,
|
|
1433
1429
|
wrapper: currentSelector
|
|
1434
|
-
}) : _object_spread_props(_object_spread({},
|
|
1430
|
+
}) : _object_spread_props(_object_spread({}, config3), {
|
|
1435
1431
|
wrapper: currentSelector
|
|
1436
1432
|
}));
|
|
1437
1433
|
};
|
|
1438
1434
|
modelWrapper.createStore = function createModelStore(state) {
|
|
1439
|
-
return createStore(modelFn, arguments.length ? _object_spread_props(_object_spread({},
|
|
1435
|
+
return createStore(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config3), {
|
|
1440
1436
|
state,
|
|
1441
1437
|
wrapper: currentSelector
|
|
1442
|
-
}) : _object_spread_props(_object_spread({},
|
|
1438
|
+
}) : _object_spread_props(_object_spread({}, config3), {
|
|
1443
1439
|
wrapper: currentSelector
|
|
1444
1440
|
}));
|
|
1445
1441
|
};
|
|
@@ -1450,46 +1446,41 @@ function configModel(config2) {
|
|
|
1450
1446
|
modelWrapper.modelUsageIdentifier = modelUsageIdentifier;
|
|
1451
1447
|
return modelWrapper;
|
|
1452
1448
|
};
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return
|
|
1449
|
+
model.createField = createField2;
|
|
1450
|
+
model.createMethod = createMethod2;
|
|
1451
|
+
return model;
|
|
1456
1452
|
}
|
|
1457
1453
|
|
|
1458
1454
|
// src/index.ts
|
|
1459
|
-
function
|
|
1455
|
+
var config = function config2() {
|
|
1460
1456
|
var configuration = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1461
|
-
var
|
|
1457
|
+
var createStore2 = function createStore3(modelLike, state) {
|
|
1462
1458
|
return createStore(modelLike, arguments.length > 1 ? _object_spread_props(_object_spread({}, configuration), {
|
|
1463
1459
|
state
|
|
1464
1460
|
}) : configuration);
|
|
1465
1461
|
};
|
|
1466
|
-
var
|
|
1462
|
+
var createKey2 = function createKey3(model2, state) {
|
|
1467
1463
|
var isKeySetState = arguments.length > 1;
|
|
1468
|
-
var key = createKey(
|
|
1464
|
+
var key = createKey(model2, isKeySetState ? _object_spread_props(_object_spread({}, configuration), {
|
|
1469
1465
|
state
|
|
1470
1466
|
}) : configuration);
|
|
1471
1467
|
key.createStore = function createKeyStore(s) {
|
|
1472
|
-
return arguments.length > 0 ?
|
|
1468
|
+
return arguments.length > 0 ? createStore2(key, s) : createStore2(key);
|
|
1473
1469
|
};
|
|
1474
1470
|
return key;
|
|
1475
1471
|
};
|
|
1476
|
-
|
|
1477
|
-
var
|
|
1472
|
+
createKey2.isModelKey = createKey.isModelKey;
|
|
1473
|
+
var createStores2 = function createStores3() {
|
|
1478
1474
|
for (var _len = arguments.length, modelKeys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1479
1475
|
modelKeys[_key] = arguments[_key];
|
|
1480
1476
|
}
|
|
1481
1477
|
return createStores(modelKeys, configuration);
|
|
1482
1478
|
};
|
|
1483
|
-
var
|
|
1479
|
+
var model = configModel(configuration);
|
|
1484
1480
|
return {
|
|
1485
|
-
createStore:
|
|
1486
|
-
createKey:
|
|
1487
|
-
createStores:
|
|
1488
|
-
model
|
|
1481
|
+
createStore: createStore2,
|
|
1482
|
+
createKey: createKey2,
|
|
1483
|
+
createStores: createStores2,
|
|
1484
|
+
model
|
|
1489
1485
|
};
|
|
1490
|
-
}
|
|
1491
|
-
var _config = config();
|
|
1492
|
-
var createStore2 = _config.createStore;
|
|
1493
|
-
var createKey2 = _config.createKey;
|
|
1494
|
-
var createStores2 = _config.createStores;
|
|
1495
|
-
var model = _config.model;
|
|
1486
|
+
};
|
package/esm/index.js
CHANGED
|
@@ -20,48 +20,43 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20
20
|
import { createStore as cs } from "./store";
|
|
21
21
|
import { createKey as ck, createStores as css } from "./key";
|
|
22
22
|
import { configModel } from "./model";
|
|
23
|
-
function
|
|
24
|
-
const
|
|
23
|
+
const config = function config2(configuration = {}) {
|
|
24
|
+
const createStore = function createStore2(modelLike, state) {
|
|
25
25
|
return cs(
|
|
26
26
|
modelLike,
|
|
27
27
|
arguments.length > 1 ? __spreadProps(__spreadValues({}, configuration), { state }) : configuration
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
|
-
const
|
|
30
|
+
const createKey = function createKey2(model2, state) {
|
|
31
31
|
const isKeySetState = arguments.length > 1;
|
|
32
32
|
const key = ck(
|
|
33
|
-
|
|
33
|
+
model2,
|
|
34
34
|
isKeySetState ? __spreadProps(__spreadValues({}, configuration), { state }) : configuration
|
|
35
35
|
);
|
|
36
36
|
key.createStore = function createKeyStore(s) {
|
|
37
|
-
return arguments.length > 0 ?
|
|
37
|
+
return arguments.length > 0 ? createStore(key, s) : createStore(key);
|
|
38
38
|
};
|
|
39
39
|
return key;
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
const
|
|
41
|
+
createKey.isModelKey = ck.isModelKey;
|
|
42
|
+
const createStores = function createStores2(...modelKeys) {
|
|
43
43
|
return css(modelKeys, configuration);
|
|
44
44
|
};
|
|
45
|
-
const
|
|
45
|
+
const model = configModel(configuration);
|
|
46
46
|
return {
|
|
47
|
-
createStore
|
|
48
|
-
createKey
|
|
49
|
-
createStores
|
|
50
|
-
model
|
|
47
|
+
createStore,
|
|
48
|
+
createKey,
|
|
49
|
+
createStores,
|
|
50
|
+
model
|
|
51
51
|
};
|
|
52
|
-
}
|
|
53
|
-
const { createStore, createKey, createStores, model } = config();
|
|
52
|
+
};
|
|
54
53
|
import { createSignal, createSelector } from "./store";
|
|
55
54
|
import { validations } from "./validation";
|
|
56
55
|
import { shallowEqual } from "./tools";
|
|
57
56
|
export {
|
|
58
57
|
config,
|
|
59
|
-
createKey,
|
|
60
58
|
createSelector,
|
|
61
59
|
createSignal,
|
|
62
|
-
createStore,
|
|
63
|
-
createStores,
|
|
64
|
-
model,
|
|
65
60
|
shallowEqual,
|
|
66
61
|
validations
|
|
67
62
|
};
|
package/esm/key/index.js
CHANGED
|
@@ -33,10 +33,10 @@ createKey.isModelKey = isModelKey;
|
|
|
33
33
|
function createStores(modelKeys, config = {}) {
|
|
34
34
|
const state = { destroyed: false };
|
|
35
35
|
const storeUnits = modelKeys.map((modelKey) => {
|
|
36
|
-
if (typeof modelKey === "function") {
|
|
36
|
+
if (typeof modelKey === "function" && typeof modelKey.createStore === "function") {
|
|
37
37
|
return modelKey.createStore();
|
|
38
38
|
}
|
|
39
|
-
const k = modelKey.key;
|
|
39
|
+
const k = typeof modelKey === "function" ? modelKey : modelKey.key;
|
|
40
40
|
return createStore(
|
|
41
41
|
k,
|
|
42
42
|
"defaultState" in k ? __spreadProps(__spreadValues({}, config), { state: k.defaultState }) : config
|
package/index.d.ts
CHANGED
|
@@ -117,12 +117,6 @@ export declare interface Store<
|
|
|
117
117
|
extends: <E extends Record<string, any>>(e: E) => Store<M, R> & E;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export declare function createStore<
|
|
121
|
-
M extends Model,
|
|
122
|
-
D extends PickState<M>,
|
|
123
|
-
R extends undefined | ((instance: () => Instance<M>) => any) = undefined
|
|
124
|
-
>(model: M | Key<M, R> | ModelUsage<M, R>, state?: D): Store<M, R>;
|
|
125
|
-
|
|
126
120
|
/** createKey * */
|
|
127
121
|
|
|
128
122
|
export declare interface ModelKey<
|
|
@@ -133,12 +127,6 @@ export declare interface ModelKey<
|
|
|
133
127
|
extends: <E extends Record<string, any>>(e: E) => ModelKey<M, R> & E;
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
export declare function createKey<
|
|
137
|
-
M extends Model = Model,
|
|
138
|
-
D extends PickState<M>,
|
|
139
|
-
R extends undefined | ((instance: () => Instance<M>) => any) = undefined
|
|
140
|
-
>(model: M | ModelUsage<M, R>, initialState?: D): ModelKey<M, R>;
|
|
141
|
-
|
|
142
130
|
/** createStores * */
|
|
143
131
|
|
|
144
132
|
export declare interface StoreCollection {
|
|
@@ -153,10 +141,6 @@ export declare interface StoreCollection {
|
|
|
153
141
|
destroy: () => void;
|
|
154
142
|
}
|
|
155
143
|
|
|
156
|
-
export declare function createStores(
|
|
157
|
-
...modelKeys: (ModelKey<any, any> | StoreIndex<any, any>)[]
|
|
158
|
-
): StoreCollection;
|
|
159
|
-
|
|
160
144
|
/** model API * */
|
|
161
145
|
|
|
162
146
|
export declare type ModelUsage<
|
|
@@ -177,7 +161,7 @@ export declare type ModelUsage<
|
|
|
177
161
|
};
|
|
178
162
|
|
|
179
163
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
180
|
-
|
|
164
|
+
declare interface model {
|
|
181
165
|
<M extends Model>(modelFn: M): ModelUsage<M, undefined>;
|
|
182
166
|
<M extends Model, R extends (instance: () => Instance<M>) => any>(
|
|
183
167
|
modelFn: M,
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": false,
|
|
3
|
-
"name": "as-model",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "This is a model state management tool",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": "Jimmy.Harding",
|
|
8
|
-
"homepage": "https://github.com/filefoxper/a-model",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/filefoxper/a-model"
|
|
12
|
-
},
|
|
13
|
-
"main": "dist/index.js",
|
|
14
|
-
"module": "esm/index.js",
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"esm",
|
|
18
|
-
"index.d.ts"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "node ./build.js",
|
|
22
|
-
"docs": "docsify serve ./docs",
|
|
23
|
-
"lint": "eslint src --fix --ext .ts,.tsx ",
|
|
24
|
-
"lint-init": "eslint --init",
|
|
25
|
-
"test": "jest --coverage"
|
|
26
|
-
},
|
|
27
|
-
"typings": "index.d.ts",
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@babel/cli": "^7.27.2",
|
|
30
|
-
"@babel/core": "^7.27.4",
|
|
31
|
-
"@babel/eslint-parser": "^7.27.5",
|
|
32
|
-
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
33
|
-
"@babel/preset-env": "^7.27.2",
|
|
34
|
-
"@babel/preset-typescript": "^7.27.1",
|
|
35
|
-
"@babel/runtime": "^7.27.6",
|
|
36
|
-
"@pmnps/plugin-publish": "4.5.0",
|
|
37
|
-
"@types/jest": "^29.5.14",
|
|
38
|
-
"babel-jest": "29.7.0",
|
|
39
|
-
"esbuild": "^0.25.0",
|
|
40
|
-
"esbuild-plugin-es5": "2.1.1",
|
|
41
|
-
"eslint": "^8.49.0",
|
|
42
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
43
|
-
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
44
|
-
"eslint-config-prettier": "^9.0.0",
|
|
45
|
-
"eslint-import-resolver-typescript": "^3.6.0",
|
|
46
|
-
"eslint-plugin-import": "^2.28.1",
|
|
47
|
-
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
48
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
49
|
-
"eslint-plugin-react": "^7.33.2",
|
|
50
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
51
|
-
"eslint-plugin-unused-imports": "^2.0.0",
|
|
52
|
-
"eslint-webpack-plugin": "^4.0.1",
|
|
53
|
-
"jest": "29.7.0",
|
|
54
|
-
"jest-environment-jsdom": "29.7.0",
|
|
55
|
-
"pmnps": "^4.5.3",
|
|
56
|
-
"prettier": "^3.0.3",
|
|
57
|
-
"prettier-eslint": "^15.0.1",
|
|
58
|
-
"prettier-eslint-cli": "^7.1.0",
|
|
59
|
-
"ts-node": "^10.8.1",
|
|
60
|
-
"typescript": "^4.9.5"
|
|
61
|
-
},
|
|
62
|
-
"keywords": [
|
|
63
|
-
"model",
|
|
64
|
-
"state",
|
|
65
|
-
"state-management",
|
|
66
|
-
"typescript"
|
|
67
|
-
]
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"private": false,
|
|
3
|
+
"name": "as-model",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"description": "This is a model state management tool",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Jimmy.Harding",
|
|
8
|
+
"homepage": "https://github.com/filefoxper/a-model",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/filefoxper/a-model"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"module": "esm/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"esm",
|
|
18
|
+
"index.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node ./build.js",
|
|
22
|
+
"docs": "docsify serve ./docs",
|
|
23
|
+
"lint": "eslint src --fix --ext .ts,.tsx ",
|
|
24
|
+
"lint-init": "eslint --init",
|
|
25
|
+
"test": "jest --coverage"
|
|
26
|
+
},
|
|
27
|
+
"typings": "index.d.ts",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@babel/cli": "^7.27.2",
|
|
30
|
+
"@babel/core": "^7.27.4",
|
|
31
|
+
"@babel/eslint-parser": "^7.27.5",
|
|
32
|
+
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
33
|
+
"@babel/preset-env": "^7.27.2",
|
|
34
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
35
|
+
"@babel/runtime": "^7.27.6",
|
|
36
|
+
"@pmnps/plugin-publish": "4.5.0",
|
|
37
|
+
"@types/jest": "^29.5.14",
|
|
38
|
+
"babel-jest": "29.7.0",
|
|
39
|
+
"esbuild": "^0.25.0",
|
|
40
|
+
"esbuild-plugin-es5": "2.1.1",
|
|
41
|
+
"eslint": "^8.49.0",
|
|
42
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
43
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
44
|
+
"eslint-config-prettier": "^9.0.0",
|
|
45
|
+
"eslint-import-resolver-typescript": "^3.6.0",
|
|
46
|
+
"eslint-plugin-import": "^2.28.1",
|
|
47
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
48
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
49
|
+
"eslint-plugin-react": "^7.33.2",
|
|
50
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
51
|
+
"eslint-plugin-unused-imports": "^2.0.0",
|
|
52
|
+
"eslint-webpack-plugin": "^4.0.1",
|
|
53
|
+
"jest": "29.7.0",
|
|
54
|
+
"jest-environment-jsdom": "29.7.0",
|
|
55
|
+
"pmnps": "^4.5.3",
|
|
56
|
+
"prettier": "^3.0.3",
|
|
57
|
+
"prettier-eslint": "^15.0.1",
|
|
58
|
+
"prettier-eslint-cli": "^7.1.0",
|
|
59
|
+
"ts-node": "^10.8.1",
|
|
60
|
+
"typescript": "^4.9.5"
|
|
61
|
+
},
|
|
62
|
+
"keywords": [
|
|
63
|
+
"model",
|
|
64
|
+
"state",
|
|
65
|
+
"state-management",
|
|
66
|
+
"typescript"
|
|
67
|
+
]
|
|
68
|
+
}
|