as-model 0.1.16 → 0.1.17
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 +483 -483
- package/dist/index.js +59 -7
- package/esm/key/index.js +1 -2
- package/esm/store/index.js +25 -0
- package/esm/updater/index.js +3 -1
- package/esm/updater/notifier.js +1 -2
- package/esm/validation/index.js +5 -1
- package/index.d.ts +298 -298
- package/package.json +68 -68
package/dist/index.js
CHANGED
|
@@ -55,6 +55,37 @@
|
|
|
55
55
|
return target;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// node_modules/@swc/helpers/esm/_object_without_properties_loose.js
|
|
59
|
+
function _object_without_properties_loose(source, excluded) {
|
|
60
|
+
if (source == null) return {};
|
|
61
|
+
var target = {};
|
|
62
|
+
var sourceKeys = Object.keys(source);
|
|
63
|
+
var key, i;
|
|
64
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
65
|
+
key = sourceKeys[i];
|
|
66
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
67
|
+
target[key] = source[key];
|
|
68
|
+
}
|
|
69
|
+
return target;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// node_modules/@swc/helpers/esm/_object_without_properties.js
|
|
73
|
+
function _object_without_properties(source, excluded) {
|
|
74
|
+
if (source == null) return {};
|
|
75
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
76
|
+
var key, i;
|
|
77
|
+
if (Object.getOwnPropertySymbols) {
|
|
78
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
79
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
80
|
+
key = sourceSymbolKeys[i];
|
|
81
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
82
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
83
|
+
target[key] = source[key];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
|
|
58
89
|
// node_modules/@swc/helpers/esm/_array_like_to_array.js
|
|
59
90
|
function _array_like_to_array(arr, len) {
|
|
60
91
|
if (len == null || len > arr.length) len = arr.length;
|
|
@@ -228,9 +259,8 @@
|
|
|
228
259
|
call(initializedAction);
|
|
229
260
|
});
|
|
230
261
|
}
|
|
231
|
-
var config2 = updater.config, model2 = updater.model;
|
|
232
262
|
var dispatch = function dispatch2(action) {
|
|
233
|
-
var dispatches = updater.dispatches, controlled = updater.controlled;
|
|
263
|
+
var dispatches = updater.dispatches, controlled = updater.controlled, model2 = updater.model, config2 = updater.config;
|
|
234
264
|
var dispatchCallbacks = _to_consumable_array(dispatches);
|
|
235
265
|
var state = action.state;
|
|
236
266
|
var nextInstance = model2(state);
|
|
@@ -560,7 +590,9 @@
|
|
|
560
590
|
state,
|
|
561
591
|
model: model2,
|
|
562
592
|
instance: instance2,
|
|
563
|
-
initialized: true
|
|
593
|
+
initialized: true,
|
|
594
|
+
cacheFields: {},
|
|
595
|
+
cacheMethods: {}
|
|
564
596
|
});
|
|
565
597
|
});
|
|
566
598
|
};
|
|
@@ -1095,6 +1127,29 @@
|
|
|
1095
1127
|
},
|
|
1096
1128
|
getInstance,
|
|
1097
1129
|
update: function update(args) {
|
|
1130
|
+
var updateArgs = args !== null && args !== void 0 ? args : {};
|
|
1131
|
+
if ("key" in updateArgs && updateArgs.key) {
|
|
1132
|
+
var updatingKey = updateArgs.key, updatingModel = updateArgs.model, rest = _object_without_properties(updateArgs, [
|
|
1133
|
+
"key",
|
|
1134
|
+
"model"
|
|
1135
|
+
]);
|
|
1136
|
+
updater.update(_object_spread_props(_object_spread({}, rest), {
|
|
1137
|
+
model: updatingKey.source
|
|
1138
|
+
}));
|
|
1139
|
+
store.key = updatingKey;
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
if ("model" in updateArgs && updateArgs.model) {
|
|
1143
|
+
var updatingKey1 = updateArgs.key, updatingModel1 = updateArgs.model, rest1 = _object_without_properties(updateArgs, [
|
|
1144
|
+
"key",
|
|
1145
|
+
"model"
|
|
1146
|
+
]);
|
|
1147
|
+
updater.update(_object_spread_props(_object_spread({}, rest1), {
|
|
1148
|
+
model: updatingModel1
|
|
1149
|
+
}));
|
|
1150
|
+
store.key = createPrimaryKey(updatingModel1, config2);
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1098
1153
|
updater.update(args);
|
|
1099
1154
|
},
|
|
1100
1155
|
destroy: function destroy2() {
|
|
@@ -1172,11 +1227,8 @@
|
|
|
1172
1227
|
}
|
|
1173
1228
|
var ifIsModelKey = validations.isModelKey(keyLike);
|
|
1174
1229
|
var key = ifIsModelKey ? keyLike : keyLike.key;
|
|
1175
|
-
Object.assign(un, {
|
|
1176
|
-
key
|
|
1177
|
-
});
|
|
1178
1230
|
un.update({
|
|
1179
|
-
|
|
1231
|
+
key
|
|
1180
1232
|
});
|
|
1181
1233
|
});
|
|
1182
1234
|
},
|
package/esm/key/index.js
CHANGED
|
@@ -66,9 +66,8 @@ function createStores(modelKeys, config = {}) {
|
|
|
66
66
|
}
|
|
67
67
|
const ifIsModelKey = validations.isModelKey(keyLike);
|
|
68
68
|
const key = ifIsModelKey ? keyLike : keyLike.key;
|
|
69
|
-
Object.assign(un, { key });
|
|
70
69
|
un.update({
|
|
71
|
-
|
|
70
|
+
key
|
|
72
71
|
});
|
|
73
72
|
});
|
|
74
73
|
},
|
package/esm/store/index.js
CHANGED
|
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
20
32
|
import { createUpdater } from "../updater";
|
|
21
33
|
import { isModelKey, isModelUsage } from "../validation";
|
|
22
34
|
import { modelKeyIdentifier, modelStoreIdentifier } from "../identifiers";
|
|
@@ -87,6 +99,19 @@ function createStore(modelLike, config = {}) {
|
|
|
87
99
|
},
|
|
88
100
|
getInstance,
|
|
89
101
|
update(args) {
|
|
102
|
+
const updateArgs = args != null ? args : {};
|
|
103
|
+
if ("key" in updateArgs && updateArgs.key) {
|
|
104
|
+
const _a = updateArgs, { key: updatingKey, model: updatingModel } = _a, rest = __objRest(_a, ["key", "model"]);
|
|
105
|
+
updater.update(__spreadProps(__spreadValues({}, rest), { model: updatingKey.source }));
|
|
106
|
+
store.key = updatingKey;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if ("model" in updateArgs && updateArgs.model) {
|
|
110
|
+
const _b = updateArgs, { key: updatingKey, model: updatingModel } = _b, rest = __objRest(_b, ["key", "model"]);
|
|
111
|
+
updater.update(__spreadProps(__spreadValues({}, rest), { model: updatingModel }));
|
|
112
|
+
store.key = createPrimaryKey(updatingModel, config);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
90
115
|
updater.update(args);
|
|
91
116
|
},
|
|
92
117
|
destroy() {
|
package/esm/updater/index.js
CHANGED
package/esm/updater/notifier.js
CHANGED
|
@@ -78,9 +78,8 @@ function generateNotifier(updater, middleWare) {
|
|
|
78
78
|
call(initializedAction);
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
const { config, model } = updater;
|
|
82
81
|
const dispatch = function dispatch2(action) {
|
|
83
|
-
const { dispatches, controlled } = updater;
|
|
82
|
+
const { dispatches, controlled, model, config } = updater;
|
|
84
83
|
const dispatchCallbacks = [...dispatches];
|
|
85
84
|
const { state } = action;
|
|
86
85
|
const nextInstance = model(state);
|
package/esm/validation/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
modelKeyIdentifier,
|
|
3
|
+
modelStoreIdentifier,
|
|
4
|
+
modelUsageIdentifier
|
|
5
|
+
} from "../identifiers";
|
|
2
6
|
const noStateAModelKey = "no-state-a-model-key";
|
|
3
7
|
function createNoStateModel() {
|
|
4
8
|
return function noStateModel(state) {
|