as-model 0.2.3 → 0.2.5

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/dist/index.js CHANGED
@@ -1,801 +1,828 @@
1
1
  "use strict";
2
- (() => {
3
- // node_modules/@swc/helpers/esm/_define_property.js
4
- function _define_property(obj, key, value) {
5
- if (key in obj) {
6
- Object.defineProperty(obj, key, {
7
- value,
8
- enumerable: true,
9
- configurable: true,
10
- writable: true
11
- });
12
- } else obj[key] = value;
13
- return obj;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
15
  }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
19
 
16
- // node_modules/@swc/helpers/esm/_object_spread.js
17
- function _object_spread(target) {
18
- for (var i = 1; i < arguments.length; i++) {
19
- var source = arguments[i] != null ? arguments[i] : {};
20
- var ownKeys2 = Object.keys(source);
21
- if (typeof Object.getOwnPropertySymbols === "function") {
22
- ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
23
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
24
- }));
25
- }
26
- ownKeys2.forEach(function(key) {
27
- _define_property(target, key, source[key]);
28
- });
29
- }
30
- return target;
31
- }
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ config: () => config,
24
+ createKey: () => createKey2,
25
+ createSelector: () => createSelector,
26
+ createSignal: () => createSignal,
27
+ createStore: () => createStore2,
28
+ createStores: () => createStores2,
29
+ model: () => model,
30
+ shallowEqual: () => shallowEqual,
31
+ validations: () => validations
32
+ });
33
+ module.exports = __toCommonJS(index_exports);
32
34
 
33
- // node_modules/@swc/helpers/esm/_object_spread_props.js
34
- function ownKeys(object, enumerableOnly) {
35
- var keys = Object.keys(object);
36
- if (Object.getOwnPropertySymbols) {
37
- var symbols = Object.getOwnPropertySymbols(object);
38
- if (enumerableOnly) {
39
- symbols = symbols.filter(function(sym) {
40
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
41
- });
42
- }
43
- keys.push.apply(keys, symbols);
35
+ // node_modules/@swc/helpers/esm/_define_property.js
36
+ function _define_property(obj, key, value) {
37
+ if (key in obj) {
38
+ Object.defineProperty(obj, key, {
39
+ value,
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true
43
+ });
44
+ } else obj[key] = value;
45
+ return obj;
46
+ }
47
+
48
+ // node_modules/@swc/helpers/esm/_object_spread.js
49
+ function _object_spread(target) {
50
+ for (var i = 1; i < arguments.length; i++) {
51
+ var source = arguments[i] != null ? arguments[i] : {};
52
+ var ownKeys2 = Object.keys(source);
53
+ if (typeof Object.getOwnPropertySymbols === "function") {
54
+ ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
55
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
56
+ }));
44
57
  }
45
- return keys;
58
+ ownKeys2.forEach(function(key) {
59
+ _define_property(target, key, source[key]);
60
+ });
46
61
  }
47
- function _object_spread_props(target, source) {
48
- source = source != null ? source : {};
49
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
50
- else {
51
- ownKeys(Object(source)).forEach(function(key) {
52
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
62
+ return target;
63
+ }
64
+
65
+ // node_modules/@swc/helpers/esm/_object_spread_props.js
66
+ function ownKeys(object, enumerableOnly) {
67
+ var keys = Object.keys(object);
68
+ if (Object.getOwnPropertySymbols) {
69
+ var symbols = Object.getOwnPropertySymbols(object);
70
+ if (enumerableOnly) {
71
+ symbols = symbols.filter(function(sym) {
72
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
53
73
  });
54
74
  }
55
- return target;
75
+ keys.push.apply(keys, symbols);
76
+ }
77
+ return keys;
78
+ }
79
+ function _object_spread_props(target, source) {
80
+ source = source != null ? source : {};
81
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
82
+ else {
83
+ ownKeys(Object(source)).forEach(function(key) {
84
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
85
+ });
56
86
  }
87
+ return target;
88
+ }
57
89
 
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;
90
+ // node_modules/@swc/helpers/esm/_object_without_properties_loose.js
91
+ function _object_without_properties_loose(source, excluded) {
92
+ if (source == null) return {};
93
+ var target = {};
94
+ var sourceKeys = Object.keys(source);
95
+ var key, i;
96
+ for (i = 0; i < sourceKeys.length; i++) {
97
+ key = sourceKeys[i];
98
+ if (excluded.indexOf(key) >= 0) continue;
99
+ target[key] = source[key];
70
100
  }
101
+ return target;
102
+ }
71
103
 
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
- }
104
+ // node_modules/@swc/helpers/esm/_object_without_properties.js
105
+ function _object_without_properties(source, excluded) {
106
+ if (source == null) return {};
107
+ var target = _object_without_properties_loose(source, excluded);
108
+ var key, i;
109
+ if (Object.getOwnPropertySymbols) {
110
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
111
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
112
+ key = sourceSymbolKeys[i];
113
+ if (excluded.indexOf(key) >= 0) continue;
114
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
115
+ target[key] = source[key];
85
116
  }
86
- return target;
87
117
  }
118
+ return target;
119
+ }
88
120
 
89
- // node_modules/@swc/helpers/esm/_array_like_to_array.js
90
- function _array_like_to_array(arr, len) {
91
- if (len == null || len > arr.length) len = arr.length;
92
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
93
- return arr2;
94
- }
121
+ // node_modules/@swc/helpers/esm/_array_like_to_array.js
122
+ function _array_like_to_array(arr, len) {
123
+ if (len == null || len > arr.length) len = arr.length;
124
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
125
+ return arr2;
126
+ }
95
127
 
96
- // node_modules/@swc/helpers/esm/_array_without_holes.js
97
- function _array_without_holes(arr) {
98
- if (Array.isArray(arr)) return _array_like_to_array(arr);
99
- }
128
+ // node_modules/@swc/helpers/esm/_array_without_holes.js
129
+ function _array_without_holes(arr) {
130
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
131
+ }
100
132
 
101
- // node_modules/@swc/helpers/esm/_iterable_to_array.js
102
- function _iterable_to_array(iter) {
103
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
104
- return Array.from(iter);
105
- }
133
+ // node_modules/@swc/helpers/esm/_iterable_to_array.js
134
+ function _iterable_to_array(iter) {
135
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
136
+ return Array.from(iter);
106
137
  }
138
+ }
107
139
 
108
- // node_modules/@swc/helpers/esm/_non_iterable_spread.js
109
- function _non_iterable_spread() {
110
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
- }
140
+ // node_modules/@swc/helpers/esm/_non_iterable_spread.js
141
+ function _non_iterable_spread() {
142
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
143
+ }
112
144
 
113
- // node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js
114
- function _unsupported_iterable_to_array(o, minLen) {
115
- if (!o) return;
116
- if (typeof o === "string") return _array_like_to_array(o, minLen);
117
- var n = Object.prototype.toString.call(o).slice(8, -1);
118
- if (n === "Object" && o.constructor) n = o.constructor.name;
119
- if (n === "Map" || n === "Set") return Array.from(n);
120
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
121
- }
145
+ // node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js
146
+ function _unsupported_iterable_to_array(o, minLen) {
147
+ if (!o) return;
148
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
149
+ var n = Object.prototype.toString.call(o).slice(8, -1);
150
+ if (n === "Object" && o.constructor) n = o.constructor.name;
151
+ if (n === "Map" || n === "Set") return Array.from(n);
152
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
153
+ }
122
154
 
123
- // node_modules/@swc/helpers/esm/_to_consumable_array.js
124
- function _to_consumable_array(arr) {
125
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
126
- }
155
+ // node_modules/@swc/helpers/esm/_to_consumable_array.js
156
+ function _to_consumable_array(arr) {
157
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
158
+ }
127
159
 
128
- // node_modules/@swc/helpers/esm/_type_of.js
129
- function _type_of(obj) {
130
- "@swc/helpers - typeof";
131
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
132
- }
160
+ // node_modules/@swc/helpers/esm/_type_of.js
161
+ function _type_of(obj) {
162
+ "@swc/helpers - typeof";
163
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
164
+ }
133
165
 
134
- // src/identifiers/index.ts
135
- function modelKeyIdentifier() {
136
- return true;
137
- }
138
- function modelUsageIdentifier() {
139
- return true;
140
- }
141
- function modelStoreIdentifier() {
142
- return true;
143
- }
144
- function tokenIdentifier() {
145
- return true;
146
- }
166
+ // src/identifiers/index.ts
167
+ function modelKeyIdentifier() {
168
+ return true;
169
+ }
170
+ function modelUsageIdentifier() {
171
+ return true;
172
+ }
173
+ function modelStoreIdentifier() {
174
+ return true;
175
+ }
176
+ function tokenIdentifier() {
177
+ return true;
178
+ }
147
179
 
148
- // src/validation/index.ts
149
- var noStateAModelKey = "no-state-a-model-key";
150
- function createNoStateModel() {
151
- return function noStateModel(state) {
152
- return _define_property({}, noStateAModelKey, true);
153
- };
180
+ // src/validation/index.ts
181
+ var noStateAModelKey = "no-state-a-model-key";
182
+ function createNoStateModel() {
183
+ return function noStateModel(state) {
184
+ return _define_property({}, noStateAModelKey, true);
185
+ };
186
+ }
187
+ function isInstanceFromNoStateModel(instance) {
188
+ if (instance == null) {
189
+ return false;
154
190
  }
155
- function isInstanceFromNoStateModel(instance) {
156
- if (instance == null) {
157
- return false;
158
- }
159
- if ((typeof instance === "undefined" ? "undefined" : _type_of(instance)) !== "object") {
160
- return false;
161
- }
162
- var ins = instance;
163
- return !!ins[noStateAModelKey];
191
+ if ((typeof instance === "undefined" ? "undefined" : _type_of(instance)) !== "object") {
192
+ return false;
164
193
  }
165
- function isModelKey(data) {
166
- if (!data) {
167
- return false;
168
- }
169
- return data.modelKeyIdentifier === modelKeyIdentifier && data.modelKeyIdentifier();
194
+ var ins = instance;
195
+ return !!ins[noStateAModelKey];
196
+ }
197
+ function isModelKey(data) {
198
+ if (!data) {
199
+ return false;
170
200
  }
171
- function isModelUsage(data) {
172
- if (!data) {
173
- return false;
174
- }
175
- return data.modelUsageIdentifier === modelUsageIdentifier && data.modelUsageIdentifier();
201
+ return data.modelKeyIdentifier === modelKeyIdentifier && data.modelKeyIdentifier();
202
+ }
203
+ function isModelUsage(data) {
204
+ if (!data) {
205
+ return false;
176
206
  }
177
- function isModelStore(data) {
178
- if (!data) {
179
- return false;
180
- }
181
- return data.modelStoreIdentifier === modelStoreIdentifier && data.modelStoreIdentifier();
207
+ return data.modelUsageIdentifier === modelUsageIdentifier && data.modelUsageIdentifier();
208
+ }
209
+ function isModelStore(data) {
210
+ if (!data) {
211
+ return false;
182
212
  }
183
- function isToken(data) {
184
- if (!data) {
185
- return false;
186
- }
187
- return data.tokenIdentifier === tokenIdentifier && data.tokenIdentifier();
213
+ return data.modelStoreIdentifier === modelStoreIdentifier && data.modelStoreIdentifier();
214
+ }
215
+ function isToken(data) {
216
+ if (!data) {
217
+ return false;
188
218
  }
189
- function isStoreIndex(data) {
190
- if (!data) {
191
- return false;
192
- }
193
- return !!data.key && isModelKey(data.key);
219
+ return data.tokenIdentifier === tokenIdentifier && data.tokenIdentifier();
220
+ }
221
+ function isStoreIndex(data) {
222
+ if (!data) {
223
+ return false;
194
224
  }
195
- var validations = {
196
- isInstanceFromNoStateModel,
197
- isModelKey,
198
- isModelStore,
199
- isModelUsage,
200
- isToken,
201
- isStoreIndex
202
- };
225
+ return !!data.key && isModelKey(data.key);
226
+ }
227
+ var validations = {
228
+ isInstanceFromNoStateModel,
229
+ isModelKey,
230
+ isModelStore,
231
+ isModelUsage,
232
+ isToken,
233
+ isStoreIndex
234
+ };
203
235
 
204
- // src/tools/proxy.ts
205
- function getDescriptors(target, receiver, ownOrPrototype, handler) {
206
- var it = Object.keys(ownOrPrototype);
207
- var result = {};
208
- it.forEach(function(key) {
209
- result[key] = {
210
- get: function() {
211
- if (!handler.get) {
212
- return target[key];
213
- }
214
- return handler.get(target, key, receiver);
215
- },
216
- set: function(v) {
217
- if (!handler.set) {
218
- target[key] = v;
219
- return;
220
- }
221
- var valid = handler.set(target, key, v, receiver);
222
- if (!valid) {
223
- throw new Error("".concat(key, " in proxy target is not mutable"));
224
- }
236
+ // src/tools/proxy.ts
237
+ function getDescriptors(target, receiver, ownOrPrototype, handler) {
238
+ var it = Object.keys(ownOrPrototype);
239
+ var result = {};
240
+ it.forEach(function(key) {
241
+ result[key] = {
242
+ get: function() {
243
+ if (!handler.get) {
244
+ return target[key];
225
245
  }
226
- };
227
- });
228
- return result;
246
+ return handler.get(target, key, receiver);
247
+ },
248
+ set: function(v) {
249
+ if (!handler.set) {
250
+ target[key] = v;
251
+ return;
252
+ }
253
+ var valid = handler.set(target, key, v, receiver);
254
+ if (!valid) {
255
+ throw new Error("".concat(key, " in proxy target is not mutable"));
256
+ }
257
+ }
258
+ };
259
+ });
260
+ return result;
261
+ }
262
+ var createSimpleProxy = function(target, handler) {
263
+ var proxy = {};
264
+ var own = getDescriptors(target, proxy, target, handler);
265
+ var prototype = getDescriptors(target, proxy, Object.getPrototypeOf(target), handler);
266
+ Object.defineProperties(proxy, _object_spread({}, prototype, own));
267
+ return proxy;
268
+ };
269
+ var createProxy = function(target, handler) {
270
+ if (typeof Proxy !== "function") {
271
+ return createSimpleProxy(target, handler);
229
272
  }
230
- var createSimpleProxy = function(target, handler) {
231
- var proxy = {};
232
- var own = getDescriptors(target, proxy, target, handler);
233
- var prototype = getDescriptors(target, proxy, Object.getPrototypeOf(target), handler);
234
- Object.defineProperties(proxy, _object_spread({}, prototype, own));
235
- return proxy;
236
- };
237
- var createProxy = function(target, handler) {
238
- if (typeof Proxy !== "function") {
239
- return createSimpleProxy(target, handler);
240
- }
241
- return new Proxy(target, handler);
242
- };
273
+ return new Proxy(target, handler);
274
+ };
243
275
 
244
- // src/tools/shallowEqual.ts
245
- function isObject(data) {
246
- return data && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object";
276
+ // src/tools/shallowEqual.ts
277
+ function isObject(data) {
278
+ return data && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object";
279
+ }
280
+ function shallowEqual(prev, current) {
281
+ if (Object.is(prev, current)) {
282
+ return true;
247
283
  }
248
- function shallowEqual(prev, current) {
249
- if (Object.is(prev, current)) {
250
- return true;
251
- }
252
- if (!isObject(prev) || !isObject(current)) {
253
- return false;
254
- }
255
- var prevKeys = Object.keys(prev);
256
- var currentKeys = Object.keys(current);
257
- if (prevKeys.length !== currentKeys.length) {
258
- return false;
259
- }
260
- var pre = prev;
261
- var curr = current;
262
- var hasDiffKey = prevKeys.some(function(key) {
263
- return !Object.prototype.hasOwnProperty.call(curr, key);
264
- });
265
- if (hasDiffKey) {
266
- return false;
267
- }
268
- var hasDiffValue = currentKeys.some(function(key) {
269
- var currentValue = curr[key];
270
- var prevValue = pre[key];
271
- return !Object.is(currentValue, prevValue);
272
- });
273
- return !hasDiffValue;
284
+ if (!isObject(prev) || !isObject(current)) {
285
+ return false;
274
286
  }
275
-
276
- // src/tools/index.ts
277
- function noop() {
287
+ var prevKeys = Object.keys(prev);
288
+ var currentKeys = Object.keys(current);
289
+ if (prevKeys.length !== currentKeys.length) {
290
+ return false;
278
291
  }
279
- function simpleErrorProcess(errors) {
280
- return function wrap(callback) {
281
- return function replaced() {
282
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
283
- args[_key] = arguments[_key];
284
- }
285
- try {
286
- return callback.apply(void 0, _to_consumable_array(args));
287
- } catch (e) {
288
- errors.push(e);
289
- }
290
- };
291
- };
292
+ var pre = prev;
293
+ var curr = current;
294
+ var hasDiffKey = prevKeys.some(function(key) {
295
+ return !Object.prototype.hasOwnProperty.call(curr, key);
296
+ });
297
+ if (hasDiffKey) {
298
+ return false;
292
299
  }
300
+ var hasDiffValue = currentKeys.some(function(key) {
301
+ var currentValue = curr[key];
302
+ var prevValue = pre[key];
303
+ return !Object.is(currentValue, prevValue);
304
+ });
305
+ return !hasDiffValue;
306
+ }
293
307
 
294
- // src/updater/token.ts
295
- function createToken() {
296
- var value = {};
297
- return {
298
- isDifferent: function isDifferent(token) {
299
- if (!isToken(token)) {
300
- return true;
301
- }
302
- return token.value !== value;
303
- },
304
- value
308
+ // src/tools/index.ts
309
+ function noop() {
310
+ }
311
+ function simpleErrorProcess(errors) {
312
+ return function wrap(callback) {
313
+ return function replaced() {
314
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
315
+ args[_key] = arguments[_key];
316
+ }
317
+ try {
318
+ return callback.apply(void 0, _to_consumable_array(args));
319
+ } catch (e) {
320
+ errors.push(e);
321
+ }
305
322
  };
306
- }
323
+ };
324
+ }
307
325
 
308
- // src/updater/notifier.ts
309
- function defaultNotifyImplement(dispatches, action) {
310
- dispatches.forEach(function(callback) {
311
- callback(action);
312
- });
313
- }
314
- function generateNotifier(updater, middleWare) {
315
- function pendAction(value) {
316
- updater.mutate(function(u) {
317
- var dispatching = u.dispatching;
318
- if (!dispatching) {
319
- var wrap = {
320
- value
321
- };
322
- wrap.tail = wrap;
323
- return _object_spread_props(_object_spread({}, u), {
324
- dispatching: wrap
325
- });
326
- }
327
- var tail = dispatching.tail;
328
- if (!tail) {
329
- return u;
330
- }
331
- var current = {
332
- prev: tail,
326
+ // src/updater/token.ts
327
+ function createToken() {
328
+ var value = {};
329
+ return {
330
+ isDifferent: function isDifferent(token) {
331
+ if (!isToken(token)) {
332
+ return true;
333
+ }
334
+ return token.value !== value;
335
+ },
336
+ value
337
+ };
338
+ }
339
+
340
+ // src/updater/notifier.ts
341
+ function defaultNotifyImplement(dispatches, action) {
342
+ dispatches.forEach(function(callback) {
343
+ callback(action);
344
+ });
345
+ }
346
+ function generateNotifier(updater, middleWare) {
347
+ function pendAction(value) {
348
+ updater.mutate(function(u) {
349
+ var dispatching = u.dispatching;
350
+ if (!dispatching) {
351
+ var wrap = {
333
352
  value
334
353
  };
335
- tail.next = current;
336
- dispatching.tail = current;
354
+ wrap.tail = wrap;
337
355
  return _object_spread_props(_object_spread({}, u), {
338
- dispatching
356
+ dispatching: wrap
339
357
  });
358
+ }
359
+ var tail = dispatching.tail;
360
+ if (!tail) {
361
+ return u;
362
+ }
363
+ var current = {
364
+ prev: tail,
365
+ value
366
+ };
367
+ tail.next = current;
368
+ dispatching.tail = current;
369
+ return _object_spread_props(_object_spread({}, u), {
370
+ dispatching
340
371
  });
341
- }
342
- function unshiftAction() {
343
- return updater.mutate(function(u) {
344
- var dispatching = updater.dispatching;
345
- if (!dispatching) {
346
- return u;
347
- }
348
- var next = dispatching.next, tail = dispatching.tail;
349
- if (tail === dispatching || !next) {
350
- dispatching.tail = void 0;
351
- return _object_spread_props(_object_spread({}, u), {
352
- dispatching: void 0
353
- });
354
- }
355
- next.prev = void 0;
356
- var newFirst = next;
357
- newFirst.tail = tail;
372
+ });
373
+ }
374
+ function unshiftAction() {
375
+ return updater.mutate(function(u) {
376
+ var dispatching = updater.dispatching;
377
+ if (!dispatching) {
378
+ return u;
379
+ }
380
+ var next = dispatching.next, tail = dispatching.tail;
381
+ if (tail === dispatching || !next) {
382
+ dispatching.tail = void 0;
358
383
  return _object_spread_props(_object_spread({}, u), {
359
- dispatching: newFirst
384
+ dispatching: void 0
360
385
  });
361
- }).dispatching;
362
- }
363
- function consumeTemporaries() {
364
- var temporaryDispatches = updater.temporaryDispatches;
365
- updater.mutate(function(u) {
366
- return u.temporaryDispatches.length ? _object_spread_props(_object_spread({}, u), {
367
- dispatches: _to_consumable_array(u.dispatches).concat(_to_consumable_array(u.temporaryDispatches)),
368
- temporaryDispatches: []
369
- }) : u;
386
+ }
387
+ next.prev = void 0;
388
+ var newFirst = next;
389
+ newFirst.tail = tail;
390
+ return _object_spread_props(_object_spread({}, u), {
391
+ dispatching: newFirst
370
392
  });
371
- var initializedAction = {
372
- state: updater.state,
373
- prevState: updater.state,
374
- instance: updater.instance,
375
- prevInstance: updater.instance,
376
- type: null,
377
- method: null
378
- };
379
- temporaryDispatches.forEach(function(d) {
380
- if (!d.accessible) {
381
- return;
382
- }
383
- d.dispatch(initializedAction);
393
+ }).dispatching;
394
+ }
395
+ function consumeTemporaries() {
396
+ var temporaryDispatches = updater.temporaryDispatches;
397
+ updater.mutate(function(u) {
398
+ return u.temporaryDispatches.length ? _object_spread_props(_object_spread({}, u), {
399
+ dispatches: _to_consumable_array(u.dispatches).concat(_to_consumable_array(u.temporaryDispatches)),
400
+ temporaryDispatches: []
401
+ }) : u;
402
+ });
403
+ var initializedAction = {
404
+ state: updater.state,
405
+ prevState: updater.state,
406
+ instance: updater.instance,
407
+ prevInstance: updater.instance,
408
+ type: null,
409
+ method: null
410
+ };
411
+ temporaryDispatches.forEach(function(d) {
412
+ if (!d.accessible) {
413
+ return;
414
+ }
415
+ d.dispatch(initializedAction);
416
+ });
417
+ }
418
+ var dispatch = function dispatch2(action) {
419
+ var dispatches = updater.dispatches, controlled = updater.controlled, model2 = updater.model, config2 = updater.config;
420
+ var state = action.state;
421
+ var nextInstance = model2(state);
422
+ var nextAction = _object_spread_props(_object_spread({}, action), {
423
+ instance: nextInstance
424
+ });
425
+ if (!controlled) {
426
+ updater.mutate(function(u) {
427
+ return _object_spread_props(_object_spread({}, u), {
428
+ state,
429
+ instance: nextInstance,
430
+ version: u.version + 1,
431
+ token: createToken()
432
+ });
384
433
  });
385
434
  }
386
- var dispatch = function dispatch2(action) {
387
- var dispatches = updater.dispatches, controlled = updater.controlled, model2 = updater.model, config2 = updater.config;
388
- var state = action.state;
389
- var nextInstance = model2(state);
390
- var nextAction = _object_spread_props(_object_spread({}, action), {
391
- instance: nextInstance
392
- });
393
- if (!controlled) {
394
- updater.mutate(function(u) {
395
- return _object_spread_props(_object_spread({}, u), {
396
- state,
397
- instance: nextInstance,
398
- version: u.version + 1,
399
- token: createToken()
400
- });
401
- });
402
- }
403
- var notifyAction = function notifyAction2(act) {
404
- var errors = [];
405
- var dispatchWrap = simpleErrorProcess(errors);
406
- var dispatchCallbacks = dispatches.map(function(d) {
407
- return dispatchWrap(function dispatchCallback(ac) {
408
- if (!d.accessible) {
409
- return;
410
- }
411
- d.dispatch(ac);
412
- });
435
+ var notifyAction = function notifyAction2(act) {
436
+ var errors = [];
437
+ var dispatchWrap = simpleErrorProcess(errors);
438
+ var dispatchCallbacks = dispatches.map(function(d) {
439
+ return dispatchWrap(function dispatchCallback(ac) {
440
+ if (!d.accessible) {
441
+ return;
442
+ }
443
+ d.dispatch(ac);
413
444
  });
414
- defaultNotifyImplement(dispatchCallbacks, act);
415
- if (!errors.length) {
416
- return {
417
- errors: void 0
418
- };
419
- }
445
+ });
446
+ defaultNotifyImplement(dispatchCallbacks, act);
447
+ if (!errors.length) {
420
448
  return {
421
- errors
449
+ errors: void 0
422
450
  };
451
+ }
452
+ return {
453
+ errors
423
454
  };
424
- var notifyActionWithErrorThrow = function notifyActionWithErrorThrow2(act) {
425
- var errors = notifyAction(act).errors;
426
- if (!errors || !errors.length) {
427
- return;
428
- }
429
- throw errors[0];
430
- };
431
- try {
432
- if (typeof config2.notify === "function") {
433
- config2.notify(notifyAction, nextAction);
434
- } else {
435
- notifyActionWithErrorThrow(nextAction);
436
- }
437
- } catch (e) {
455
+ };
456
+ var notifyActionWithErrorThrow = function notifyActionWithErrorThrow2(act) {
457
+ var errors = notifyAction(act).errors;
458
+ if (!errors || !errors.length) {
459
+ return;
460
+ }
461
+ throw errors[0];
462
+ };
463
+ try {
464
+ if (typeof config2.notify === "function") {
465
+ config2.notify(notifyAction, nextAction);
466
+ } else {
467
+ notifyActionWithErrorThrow(nextAction);
468
+ }
469
+ } catch (e) {
470
+ updater.mutate(function(u) {
471
+ return _object_spread_props(_object_spread({}, u), {
472
+ dispatching: void 0
473
+ });
474
+ });
475
+ throw e;
476
+ }
477
+ };
478
+ return function notify(action) {
479
+ if (action == null || updater.isDestroyed) {
480
+ return;
481
+ }
482
+ var dispatching = updater.dispatching;
483
+ pendAction(action);
484
+ if (dispatching) {
485
+ return;
486
+ }
487
+ while (updater.dispatching) {
488
+ var wrap = updater.dispatching;
489
+ if (wrap) {
490
+ middleWare({
491
+ getState: function getState() {
492
+ return {
493
+ state: updater.state,
494
+ instance: updater.instance
495
+ };
496
+ },
497
+ dispatch: notify
498
+ })(dispatch)(wrap.value);
499
+ unshiftAction();
500
+ } else {
438
501
  updater.mutate(function(u) {
439
502
  return _object_spread_props(_object_spread({}, u), {
440
503
  dispatching: void 0
441
504
  });
442
505
  });
443
- throw e;
444
506
  }
445
- };
446
- return function notify(action) {
447
- if (action == null || updater.isDestroyed) {
448
- return;
449
- }
450
- var dispatching = updater.dispatching;
451
- pendAction(action);
452
- if (dispatching) {
453
- return;
507
+ }
508
+ consumeTemporaries();
509
+ };
510
+ }
511
+
512
+ // src/updater/tunnel.ts
513
+ function createUnInitializedUpdater() {
514
+ return {
515
+ notify: function(a) {
516
+ },
517
+ createTunnel: function(dispatcher) {
518
+ return {
519
+ connect: noop,
520
+ disconnect: noop
521
+ };
522
+ }
523
+ };
524
+ }
525
+ function destroy(updater) {
526
+ function destroyDispatching() {
527
+ updater.mutate(function(u) {
528
+ var dispatching = u.dispatching;
529
+ if (!dispatching) {
530
+ return u;
454
531
  }
455
- while (updater.dispatching) {
456
- var wrap = updater.dispatching;
457
- if (wrap) {
458
- middleWare({
459
- getState: function getState() {
460
- return {
461
- state: updater.state,
462
- instance: updater.instance
463
- };
464
- },
465
- dispatch: notify
466
- })(dispatch)(wrap.value);
467
- unshiftAction();
468
- } else {
469
- updater.mutate(function(u) {
470
- return _object_spread_props(_object_spread({}, u), {
471
- dispatching: void 0
472
- });
473
- });
532
+ var wrapper = dispatching;
533
+ while (wrapper) {
534
+ var next = wrapper.next;
535
+ wrapper.next = void 0;
536
+ wrapper.prev = void 0;
537
+ if (next) {
538
+ next.prev = void 0;
474
539
  }
540
+ wrapper = next;
475
541
  }
476
- consumeTemporaries();
477
- };
542
+ dispatching.tail = void 0;
543
+ return _object_spread_props(_object_spread({}, u), {
544
+ dispatching: void 0,
545
+ initialized: false
546
+ });
547
+ });
478
548
  }
479
-
480
- // src/updater/tunnel.ts
481
- function createUnInitializedUpdater() {
482
- return {
483
- notify: function(a) {
484
- },
485
- createTunnel: function(dispatcher) {
486
- return {
487
- connect: noop,
488
- disconnect: noop
489
- };
490
- }
549
+ updater.mutate(function(u, effect) {
550
+ var destroyed = createUnInitializedUpdater();
551
+ effect(function() {
552
+ destroyDispatching();
553
+ });
554
+ return _object_spread_props(_object_spread({}, u, destroyed), {
555
+ sidePayload: void 0,
556
+ isDestroyed: true
557
+ });
558
+ });
559
+ }
560
+ function generateTunnelCreator(updater) {
561
+ function subscribe(dispatchFn) {
562
+ var dispatches = updater.dispatches, temporaryDispatches = updater.temporaryDispatches, isControlled = updater.controlled;
563
+ var copied = _to_consumable_array(dispatches).concat(_to_consumable_array(temporaryDispatches));
564
+ var exist = copied.some(function(d) {
565
+ return d.dispatch === dispatchFn;
566
+ });
567
+ if (exist) {
568
+ return updater.mutate(function(u) {
569
+ return _object_spread_props(_object_spread({}, u), {
570
+ isDestroyed: false
571
+ });
572
+ });
573
+ }
574
+ var dispatcher = {
575
+ dispatch: dispatchFn,
576
+ accessible: true
491
577
  };
492
- }
493
- function destroy(updater) {
494
- function destroyDispatching() {
495
- updater.mutate(function(u) {
496
- var dispatching = u.dispatching;
497
- if (!dispatching) {
498
- return u;
499
- }
500
- var wrapper = dispatching;
501
- while (wrapper) {
502
- var next = wrapper.next;
503
- wrapper.next = void 0;
504
- wrapper.prev = void 0;
505
- if (next) {
506
- next.prev = void 0;
507
- }
508
- wrapper = next;
509
- }
510
- dispatching.tail = void 0;
578
+ if (isControlled) {
579
+ return updater.mutate(function(u) {
511
580
  return _object_spread_props(_object_spread({}, u), {
512
- dispatching: void 0,
513
- initialized: false
581
+ dispatches: [
582
+ dispatcher
583
+ ],
584
+ isDestroyed: false
514
585
  });
515
586
  });
516
587
  }
517
- updater.mutate(function(u, effect) {
518
- var destroyed = createUnInitializedUpdater();
519
- effect(function() {
520
- destroyDispatching();
588
+ return updater.mutate(function(u, effect) {
589
+ var tds = u.temporaryDispatches, ds = u.dispatches;
590
+ var nextTds = _to_consumable_array(tds).concat([
591
+ dispatcher
592
+ ]);
593
+ if (u.dispatching) {
594
+ return _object_spread_props(_object_spread({}, u), {
595
+ temporaryDispatches: nextTds,
596
+ isDestroyed: false
597
+ });
598
+ }
599
+ effect(function(up) {
600
+ var initializedAction = {
601
+ state: up.state,
602
+ prevState: up.state,
603
+ instance: up.instance,
604
+ prevInstance: up.instance,
605
+ type: null,
606
+ method: null
607
+ };
608
+ nextTds.forEach(function(td) {
609
+ td.dispatch(initializedAction);
610
+ });
521
611
  });
522
- return _object_spread_props(_object_spread({}, u, destroyed), {
523
- sidePayload: void 0,
524
- isDestroyed: true
612
+ return _object_spread_props(_object_spread({}, u), {
613
+ temporaryDispatches: [],
614
+ dispatches: _to_consumable_array(ds).concat(_to_consumable_array(nextTds)),
615
+ isDestroyed: false
525
616
  });
526
617
  });
527
618
  }
528
- function generateTunnelCreator(updater) {
529
- function subscribe(dispatchFn) {
530
- var dispatches = updater.dispatches, temporaryDispatches = updater.temporaryDispatches, isControlled = updater.controlled;
531
- var copied = _to_consumable_array(dispatches).concat(_to_consumable_array(temporaryDispatches));
532
- var exist = copied.some(function(d) {
533
- return d.dispatch === dispatchFn;
534
- });
535
- if (exist) {
536
- return updater.mutate(function(u) {
537
- return _object_spread_props(_object_spread({}, u), {
538
- isDestroyed: false
539
- });
540
- });
541
- }
542
- var dispatcher = {
543
- dispatch: dispatchFn,
544
- accessible: true
545
- };
546
- if (isControlled) {
547
- return updater.mutate(function(u) {
548
- return _object_spread_props(_object_spread({}, u), {
549
- dispatches: [
550
- dispatcher
551
- ],
552
- isDestroyed: false
553
- });
619
+ return function tunnel(dispatchFn) {
620
+ function disconnect() {
621
+ updater.mutate(function(u) {
622
+ var ds = u.dispatches, tds = u.temporaryDispatches;
623
+ var found = _to_consumable_array(ds).concat(_to_consumable_array(tds)).find(function(d) {
624
+ return d.dispatch === dispatchFn;
554
625
  });
555
- }
556
- return updater.mutate(function(u, effect) {
557
- var tds = u.temporaryDispatches, ds = u.dispatches;
558
- var nextTds = _to_consumable_array(tds).concat([
559
- dispatcher
560
- ]);
561
- if (u.dispatching) {
562
- return _object_spread_props(_object_spread({}, u), {
563
- temporaryDispatches: nextTds,
564
- isDestroyed: false
565
- });
626
+ if (!found) {
627
+ return u;
566
628
  }
567
- effect(function(up) {
568
- var initializedAction = {
569
- state: up.state,
570
- prevState: up.state,
571
- instance: up.instance,
572
- prevInstance: up.instance,
573
- type: null,
574
- method: null
575
- };
576
- nextTds.forEach(function(td) {
577
- td.dispatch(initializedAction);
578
- });
629
+ found.accessible = false;
630
+ var nextDs = ds.filter(function(d) {
631
+ return d !== found;
632
+ });
633
+ var nextTds = tds.filter(function(d) {
634
+ return d !== found;
579
635
  });
580
636
  return _object_spread_props(_object_spread({}, u), {
581
- temporaryDispatches: [],
582
- dispatches: _to_consumable_array(ds).concat(_to_consumable_array(nextTds)),
583
- isDestroyed: false
637
+ dispatches: nextDs,
638
+ temporaryDispatches: nextTds
584
639
  });
585
640
  });
586
641
  }
587
- return function tunnel(dispatchFn) {
588
- function disconnect() {
589
- updater.mutate(function(u) {
590
- var ds = u.dispatches, tds = u.temporaryDispatches;
591
- var found = _to_consumable_array(ds).concat(_to_consumable_array(tds)).find(function(d) {
592
- return d.dispatch === dispatchFn;
593
- });
594
- if (!found) {
595
- return u;
596
- }
597
- found.accessible = false;
598
- var nextDs = ds.filter(function(d) {
599
- return d !== found;
600
- });
601
- var nextTds = tds.filter(function(d) {
602
- return d !== found;
603
- });
604
- return _object_spread_props(_object_spread({}, u), {
605
- dispatches: nextDs,
606
- temporaryDispatches: nextTds
607
- });
608
- });
642
+ return {
643
+ connect: function connect() {
644
+ subscribe(dispatchFn);
645
+ },
646
+ disconnect: function disconnect1() {
647
+ disconnect();
609
648
  }
610
- return {
611
- connect: function connect() {
612
- subscribe(dispatchFn);
613
- },
614
- disconnect: function disconnect1() {
615
- disconnect();
616
- }
617
- };
618
649
  };
619
- }
650
+ };
651
+ }
620
652
 
621
- // src/updater/index.ts
622
- function createInitializedUpdater(updater, middleWare) {
623
- var createTunnel = generateTunnelCreator(updater);
624
- return {
625
- notify: generateNotifier(updater, middleWare),
626
- createTunnel
627
- };
628
- }
629
- function createUpdateFn(updater, middleWare) {
630
- return function update() {
631
- var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
632
- updater.mutate(function(u, effect) {
633
- var _args_model;
634
- var model2 = (_args_model = args.model) !== null && _args_model !== void 0 ? _args_model : u.model;
635
- var hasState = Object.prototype.hasOwnProperty.call(args, "state");
636
- var hasInitialState = Object.prototype.hasOwnProperty.call(args, "initialState");
637
- var state = hasState ? args.state : u.state;
638
- var isInitialize = !u.initialized || hasInitialState;
639
- var token = createToken();
640
- if (u.controlled) {
641
- var controlledState = hasInitialState && !hasState ? args.initialState : state;
642
- var instance = model2(controlledState);
643
- return _object_spread_props(_object_spread({}, u), {
644
- state: controlledState,
645
- instance,
646
- model: model2
647
- });
648
- }
649
- if (u.isDestroyed) {
650
- return u;
651
- }
652
- if (!u.initialized && !hasState && !hasInitialState) {
653
- throw new Error("The updater has not been initialized, it should be updated with a state for initializing.");
654
- }
655
- if (isInitialize) {
656
- var initialState = hasInitialState ? args.initialState : state;
657
- var instance1 = model2(initialState);
658
- var initializedUpdater = createInitializedUpdater(u, middleWare);
659
- return _object_spread(_object_spread_props(_object_spread({}, u), {
660
- model: model2,
661
- state: initialState,
662
- instance: instance1,
663
- initialized: true,
664
- token
665
- }), initializedUpdater);
666
- }
667
- if (Object.is(u.model, model2) && Object.is(u.state, state)) {
668
- return u;
669
- }
670
- effect(function(up) {
671
- up.notify({
672
- type: null,
673
- method: null,
674
- prevInstance: u.instance,
675
- instance: u.instance,
676
- prevState: u.state,
677
- state
678
- });
679
- });
653
+ // src/updater/index.ts
654
+ function createInitializedUpdater(updater, middleWare) {
655
+ var createTunnel = generateTunnelCreator(updater);
656
+ return {
657
+ notify: generateNotifier(updater, middleWare),
658
+ createTunnel
659
+ };
660
+ }
661
+ function createUpdateFn(updater, middleWare) {
662
+ return function update() {
663
+ var args = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
664
+ updater.mutate(function(u, effect) {
665
+ var _args_model;
666
+ var model2 = (_args_model = args.model) !== null && _args_model !== void 0 ? _args_model : u.model;
667
+ var hasState = Object.prototype.hasOwnProperty.call(args, "state");
668
+ var hasInitialState = Object.prototype.hasOwnProperty.call(args, "initialState");
669
+ var state = hasState ? args.state : u.state;
670
+ var isInitialize = !u.initialized || hasInitialState;
671
+ var token = createToken();
672
+ if (u.controlled) {
673
+ var controlledState = hasInitialState && !hasState ? args.initialState : state;
674
+ var instance = model2(controlledState);
680
675
  return _object_spread_props(_object_spread({}, u), {
676
+ state: controlledState,
677
+ instance,
678
+ model: model2
679
+ });
680
+ }
681
+ if (u.isDestroyed) {
682
+ return u;
683
+ }
684
+ if (!u.initialized && !hasState && !hasInitialState) {
685
+ throw new Error("The updater has not been initialized, it should be updated with a state for initializing.");
686
+ }
687
+ if (isInitialize) {
688
+ var initialState = hasInitialState ? args.initialState : state;
689
+ var instance1 = model2(initialState);
690
+ var initializedUpdater = createInitializedUpdater(u, middleWare);
691
+ return _object_spread(_object_spread_props(_object_spread({}, u), {
681
692
  model: model2,
693
+ state: initialState,
694
+ instance: instance1,
682
695
  initialized: true,
683
- cacheFields: {},
684
- cacheMethods: {}
696
+ token
697
+ }), initializedUpdater);
698
+ }
699
+ if (Object.is(u.model, model2) && Object.is(u.state, state)) {
700
+ return u;
701
+ }
702
+ effect(function(up) {
703
+ up.notify({
704
+ type: null,
705
+ method: null,
706
+ prevInstance: u.instance,
707
+ instance: u.instance,
708
+ prevState: u.state,
709
+ state
685
710
  });
686
711
  });
687
- };
688
- }
689
- var lazyModel = createNoStateModel();
690
- function createUpdater(model2, middleWare) {
691
- var config2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
692
- var hasDefaultState = "state" in config2;
693
- var controlled = config2.controlled, defaultState = config2.state;
694
- var defaultInstance = hasDefaultState ? model2(defaultState) : lazyModel(void 0);
695
- var unInitializedUpdater = createUnInitializedUpdater();
696
- var updater = _object_spread({
697
- sidePayload: void 0,
698
- version: 0,
699
- token: createToken(),
700
- isDestroyed: false,
701
- model: model2,
702
- instance: defaultInstance,
703
- dispatch: null,
704
- dispatches: [],
705
- temporaryDispatches: [],
706
- cacheMethods: {},
707
- cacheFields: {},
708
- state: defaultState,
709
- initialized: hasDefaultState,
710
- controlled: !!controlled,
711
- isSubscribing: false,
712
- config: config2,
713
- payload: function payload(setter) {
714
- if (typeof setter === "function") {
715
- updater.sidePayload = setter(updater.sidePayload);
716
- }
717
- return updater.sidePayload;
718
- },
719
- mutate: function mutate(callback) {
720
- var effects = [];
721
- var runEffects = function runEffects2(u) {
722
- effects.forEach(function(e) {
723
- return e(u);
724
- });
725
- };
726
- var result = callback(updater, function(effectFn) {
727
- return effects.push(effectFn);
728
- });
729
- if (updater === result) {
730
- runEffects(result);
731
- return updater;
732
- }
733
- Object.assign(updater, result);
734
- runEffects(updater);
735
- return updater;
736
- },
737
- update: function(args) {
738
- },
739
- destroy: function destroy1() {
740
- destroy(updater);
741
- }
742
- }, unInitializedUpdater);
743
- var initialized = createInitializedUpdater(updater, middleWare);
744
- Object.assign(updater, initialized, {
745
- update: createUpdateFn(updater, middleWare)
712
+ return _object_spread_props(_object_spread({}, u), {
713
+ model: model2,
714
+ initialized: true,
715
+ cacheFields: {},
716
+ cacheMethods: {}
717
+ });
746
718
  });
747
- return updater;
748
- }
749
-
750
- // src/store/cache.ts
751
- var cacheIdentify = {
752
- field: function field(d) {
753
- if (!d) {
754
- return false;
719
+ };
720
+ }
721
+ var lazyModel = createNoStateModel();
722
+ function createUpdater(model2, middleWare) {
723
+ var config2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
724
+ var hasDefaultState = "state" in config2;
725
+ var controlled = config2.controlled, defaultState = config2.state;
726
+ var defaultInstance = hasDefaultState ? model2(defaultState) : lazyModel(void 0);
727
+ var unInitializedUpdater = createUnInitializedUpdater();
728
+ var updater = _object_spread({
729
+ sidePayload: void 0,
730
+ version: 0,
731
+ token: createToken(),
732
+ isDestroyed: false,
733
+ model: model2,
734
+ instance: defaultInstance,
735
+ dispatch: null,
736
+ dispatches: [],
737
+ temporaryDispatches: [],
738
+ cacheMethods: {},
739
+ cacheFields: {},
740
+ state: defaultState,
741
+ initialized: hasDefaultState,
742
+ controlled: !!controlled,
743
+ isSubscribing: false,
744
+ config: config2,
745
+ payload: function payload(setter) {
746
+ if (typeof setter === "function") {
747
+ updater.sidePayload = setter(updater.sidePayload);
755
748
  }
756
- var f = d;
757
- return f.identifier === cacheIdentify.field;
749
+ return updater.sidePayload;
758
750
  },
759
- method: function method(d) {
760
- if (typeof d !== "function") {
761
- return false;
751
+ mutate: function mutate(callback) {
752
+ var effects = [];
753
+ var runEffects = function runEffects2(u) {
754
+ effects.forEach(function(e) {
755
+ return e(u);
756
+ });
757
+ };
758
+ var result = callback(updater, function(effectFn) {
759
+ return effects.push(effectFn);
760
+ });
761
+ if (updater === result) {
762
+ runEffects(result);
763
+ return updater;
762
764
  }
763
- var m = d;
764
- return m.identifier === cacheIdentify.method;
765
+ Object.assign(updater, result);
766
+ runEffects(updater);
767
+ return updater;
768
+ },
769
+ update: function(args) {
770
+ },
771
+ destroy: function destroy1() {
772
+ destroy(updater);
765
773
  }
766
- };
767
- function wrapToField(cache, propertyName, value, onGot) {
768
- var cacheFields = cache.cacheFields;
769
- if (!cacheIdentify.field(value)) {
770
- if (onGot) {
771
- onGot(propertyName, value);
772
- }
773
- return value;
774
+ }, unInitializedUpdater);
775
+ var initialized = createInitializedUpdater(updater, middleWare);
776
+ Object.assign(updater, initialized, {
777
+ update: createUpdateFn(updater, middleWare)
778
+ });
779
+ return updater;
780
+ }
781
+
782
+ // src/defaults.ts
783
+ function defaultSelector(i) {
784
+ return i();
785
+ }
786
+
787
+ // src/store/cache.ts
788
+ var cacheIdentify = {
789
+ field: function field(d) {
790
+ if (!d) {
791
+ return false;
774
792
  }
775
- var field2 = value;
776
- var cachedField = cacheFields[propertyName];
777
- if (cachedField) {
778
- return cachedField.getter;
793
+ var f = d;
794
+ return f.identifier === cacheIdentify.field;
795
+ },
796
+ method: function method(d) {
797
+ if (typeof d !== "function") {
798
+ return false;
779
799
  }
780
- var getter = {
781
- get: function get() {
782
- var currentField = cache.target[propertyName];
783
- if (!cacheIdentify.field(currentField)) {
784
- throw new Error("Field should always be field.");
785
- }
786
- var current = currentField.get();
787
- var fieldInCache = cache.cacheFields[propertyName];
788
- if (!currentField.deps || fieldInCache == null) {
789
- cacheFields[propertyName] = {
790
- getter,
791
- value: current,
792
- deps: currentField.deps
793
- };
794
- return current;
795
- }
796
- if (shallowEqual(currentField.deps, fieldInCache.deps)) {
797
- return fieldInCache.value;
798
- }
800
+ var m = d;
801
+ return m.identifier === cacheIdentify.method;
802
+ }
803
+ };
804
+ function wrapToField(cache, propertyName, value, onGot) {
805
+ var cacheFields = cache.cacheFields;
806
+ if (!cacheIdentify.field(value)) {
807
+ if (onGot) {
808
+ onGot(propertyName, value);
809
+ }
810
+ return value;
811
+ }
812
+ var field2 = value;
813
+ var cachedField = cacheFields[propertyName];
814
+ if (cachedField) {
815
+ return cachedField.getter;
816
+ }
817
+ var getter = {
818
+ get: function get() {
819
+ var currentField = cache.target[propertyName];
820
+ if (!cacheIdentify.field(currentField)) {
821
+ throw new Error("Field should always be field.");
822
+ }
823
+ var current = currentField.get();
824
+ var fieldInCache = cache.cacheFields[propertyName];
825
+ if (!currentField.deps || fieldInCache == null) {
799
826
  cacheFields[propertyName] = {
800
827
  getter,
801
828
  value: current,
@@ -803,171 +830,171 @@
803
830
  };
804
831
  return current;
805
832
  }
806
- };
807
- cacheFields[propertyName] = {
808
- getter,
809
- value: field2.value,
810
- deps: field2.deps
811
- };
812
- return getter;
833
+ if (shallowEqual(currentField.deps, fieldInCache.deps)) {
834
+ return fieldInCache.value;
835
+ }
836
+ cacheFields[propertyName] = {
837
+ getter,
838
+ value: current,
839
+ deps: currentField.deps
840
+ };
841
+ return current;
842
+ }
843
+ };
844
+ cacheFields[propertyName] = {
845
+ getter,
846
+ value: field2.value,
847
+ deps: field2.deps
848
+ };
849
+ return getter;
850
+ }
851
+ function wrapToActionMethod(cache, methodName) {
852
+ var cacheMethods = cache.cacheMethods;
853
+ var cachedMethod = cacheMethods[methodName];
854
+ if (typeof cachedMethod === "function") {
855
+ return cachedMethod;
813
856
  }
814
- function wrapToActionMethod(cache, methodName) {
815
- var cacheMethods = cache.cacheMethods;
816
- var cachedMethod = cacheMethods[methodName];
817
- if (typeof cachedMethod === "function") {
818
- return cachedMethod;
857
+ var actionMethod = function actionMethod2() {
858
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
859
+ args[_key] = arguments[_key];
819
860
  }
820
- var actionMethod = function actionMethod2() {
821
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
822
- args[_key] = arguments[_key];
823
- }
824
- var target = cache.target;
825
- var method2 = target[methodName];
826
- if (typeof method2 !== "function") {
827
- throw new Error("Can not change methods in runtime.");
861
+ var target = cache.target;
862
+ var method2 = target[methodName];
863
+ if (typeof method2 !== "function") {
864
+ throw new Error("Can not change methods in runtime.");
865
+ }
866
+ return method2.apply(void 0, _to_consumable_array(args));
867
+ };
868
+ cacheMethods[methodName] = actionMethod;
869
+ return actionMethod;
870
+ }
871
+ var cacheProperties = function(cache, onGet) {
872
+ return function createCachePropertiesProxy() {
873
+ var instance = cache.target;
874
+ var properties = Object.getOwnPropertyNames(instance);
875
+ var handleGetter = function handleGetter2(key, value) {
876
+ if (!onGet) {
877
+ return;
828
878
  }
829
- return method2.apply(void 0, _to_consumable_array(args));
879
+ onGet(key, value);
830
880
  };
831
- cacheMethods[methodName] = actionMethod;
832
- return actionMethod;
833
- }
834
- var cacheProperties = function(cache, onGet) {
835
- return function createCachePropertiesProxy() {
836
- var instance = cache.target;
837
- var properties = Object.getOwnPropertyNames(instance);
838
- var handleGetter = function handleGetter2(key, value) {
839
- if (!onGet) {
840
- return;
841
- }
842
- onGet(key, value);
843
- };
844
- return createProxy(instance, {
845
- get: function get(target, p) {
846
- var value = target[p];
847
- if (typeof value === "function" && properties.indexOf(p) >= 0) {
848
- var actionMethod = wrapToActionMethod(cache, p);
849
- Object.assign(actionMethod, value);
850
- handleGetter(p, actionMethod);
851
- return actionMethod;
852
- }
853
- return wrapToField(cache, p, value, handleGetter);
854
- },
855
- set: function set() {
856
- return false;
881
+ return createProxy(instance, {
882
+ get: function get(target, p) {
883
+ var value = target[p];
884
+ if (typeof value === "function" && properties.indexOf(p) >= 0) {
885
+ var actionMethod = wrapToActionMethod(cache, p);
886
+ Object.assign(actionMethod, value);
887
+ handleGetter(p, actionMethod);
888
+ return actionMethod;
857
889
  }
858
- });
859
- };
890
+ return wrapToField(cache, p, value, handleGetter);
891
+ },
892
+ set: function set() {
893
+ return false;
894
+ }
895
+ });
860
896
  };
897
+ };
861
898
 
862
- // src/store/instance.ts
863
- function createField(callback, deps) {
864
- var currentDeps = function computeDeps() {
865
- if (deps == null) {
866
- return deps;
867
- }
868
- if (deps.some(function(d) {
869
- return cacheIdentify.field(d) && d.deps == null;
870
- })) {
871
- return void 0;
872
- }
873
- return deps.flatMap(function(d) {
874
- if (cacheIdentify.field(d)) {
875
- return d.deps;
876
- }
877
- return d;
878
- });
879
- }();
880
- var value = callback();
881
- return {
882
- callback,
883
- deps: currentDeps,
884
- identifier: cacheIdentify.field,
885
- value,
886
- get: function get() {
887
- return value;
899
+ // src/store/instance.ts
900
+ function createField(callback, deps) {
901
+ var currentDeps = function computeDeps() {
902
+ if (deps == null) {
903
+ return deps;
904
+ }
905
+ if (deps.some(function(d) {
906
+ return cacheIdentify.field(d) && d.deps == null;
907
+ })) {
908
+ return void 0;
909
+ }
910
+ return deps.flatMap(function(d) {
911
+ if (cacheIdentify.field(d)) {
912
+ return d.deps;
888
913
  }
889
- };
914
+ return d;
915
+ });
916
+ }();
917
+ var value = callback();
918
+ return {
919
+ callback,
920
+ deps: currentDeps,
921
+ identifier: cacheIdentify.field,
922
+ value,
923
+ get: function get() {
924
+ return value;
925
+ }
926
+ };
927
+ }
928
+ function createMethod(method2) {
929
+ var replace = function replace2() {
930
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
931
+ args[_key] = arguments[_key];
932
+ }
933
+ return method2.apply(void 0, _to_consumable_array(args));
934
+ };
935
+ replace.identifier = cacheIdentify.method;
936
+ return replace;
937
+ }
938
+ function wrapToActionMethod2(updater, methodName) {
939
+ var cacheMethods = updater.cacheMethods;
940
+ var cachedMethod = cacheMethods[methodName];
941
+ if (typeof cachedMethod === "function") {
942
+ return cachedMethod;
890
943
  }
891
- function createMethod(method2) {
892
- var replace = function replace2() {
893
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
894
- args[_key] = arguments[_key];
895
- }
944
+ var actionMethod = function actionMethod2() {
945
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
946
+ args[_key] = arguments[_key];
947
+ }
948
+ var instance = updater.instance;
949
+ var method2 = instance[methodName];
950
+ if (typeof method2 !== "function") {
951
+ throw new Error("Can not change methods in runtime.");
952
+ }
953
+ if (cacheIdentify.method(method2)) {
896
954
  return method2.apply(void 0, _to_consumable_array(args));
897
- };
898
- replace.identifier = cacheIdentify.method;
899
- return replace;
900
- }
901
- function wrapToActionMethod2(updater, methodName) {
902
- var cacheMethods = updater.cacheMethods;
903
- var cachedMethod = cacheMethods[methodName];
904
- if (typeof cachedMethod === "function") {
905
- return cachedMethod;
906
955
  }
907
- var actionMethod = function actionMethod2() {
908
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
909
- args[_key] = arguments[_key];
910
- }
911
- var instance = updater.instance;
912
- var method2 = instance[methodName];
913
- if (typeof method2 !== "function") {
914
- throw new Error("Can not change methods in runtime.");
915
- }
916
- if (cacheIdentify.method(method2)) {
917
- return method2.apply(void 0, _to_consumable_array(args));
918
- }
919
- var state = method2.apply(void 0, _to_consumable_array(args));
920
- var action = {
921
- type: methodName,
922
- state,
923
- prevState: updater.state,
924
- instance: updater.instance,
925
- prevInstance: updater.instance,
926
- method: actionMethod2
927
- };
928
- updater.notify(action);
929
- return state;
956
+ var state = method2.apply(void 0, _to_consumable_array(args));
957
+ var action = {
958
+ type: methodName,
959
+ state,
960
+ prevState: updater.state,
961
+ instance: updater.instance,
962
+ prevInstance: updater.instance,
963
+ method: actionMethod2
930
964
  };
931
- cacheMethods[methodName] = actionMethod;
932
- return actionMethod;
965
+ updater.notify(action);
966
+ return state;
967
+ };
968
+ cacheMethods[methodName] = actionMethod;
969
+ return actionMethod;
970
+ }
971
+ function wrapToField2(updater, propertyName, value, onGot) {
972
+ function collect(pName, v) {
973
+ if (onGot) {
974
+ onGot(pName, v);
975
+ }
976
+ }
977
+ var cacheFields = updater.cacheFields;
978
+ if (!cacheIdentify.field(value)) {
979
+ collect(propertyName, value);
980
+ return value;
981
+ }
982
+ var field2 = value;
983
+ var cachedField = cacheFields[propertyName];
984
+ if (cachedField && (field2.deps && shallowEqual(cachedField.deps, field2.deps) || !field2.deps && cachedField.value === field2.value)) {
985
+ var cacheFieldGetter = cachedField.getter;
986
+ collect(propertyName, cacheFieldGetter);
987
+ return cacheFieldGetter;
933
988
  }
934
- function wrapToField2(updater, propertyName, value, onGot) {
935
- function collect(pName, v) {
936
- if (onGot) {
937
- onGot(pName, v);
989
+ var getter = {
990
+ get: function get() {
991
+ var currentField = updater.instance[propertyName];
992
+ if (!cacheIdentify.field(currentField)) {
993
+ throw new Error("Field should always be field.");
938
994
  }
939
- }
940
- var cacheFields = updater.cacheFields;
941
- if (!cacheIdentify.field(value)) {
942
- collect(propertyName, value);
943
- return value;
944
- }
945
- var field2 = value;
946
- var cachedField = cacheFields[propertyName];
947
- if (cachedField && (field2.deps && shallowEqual(cachedField.deps, field2.deps) || !field2.deps && cachedField.value === field2.value)) {
948
- var cacheFieldGetter = cachedField.getter;
949
- collect(propertyName, cacheFieldGetter);
950
- return cacheFieldGetter;
951
- }
952
- var getter = {
953
- get: function get() {
954
- var currentField = updater.instance[propertyName];
955
- if (!cacheIdentify.field(currentField)) {
956
- throw new Error("Field should always be field.");
957
- }
958
- var current = currentField.get();
959
- var fieldInCache = updater.cacheFields[propertyName];
960
- if (!currentField.deps || fieldInCache == null) {
961
- cacheFields[propertyName] = {
962
- getter,
963
- value: current,
964
- deps: currentField.deps
965
- };
966
- return current;
967
- }
968
- if (shallowEqual(currentField.deps, fieldInCache.deps)) {
969
- return fieldInCache.value;
970
- }
995
+ var current = currentField.get();
996
+ var fieldInCache = updater.cacheFields[propertyName];
997
+ if (!currentField.deps || fieldInCache == null) {
971
998
  cacheFields[propertyName] = {
972
999
  getter,
973
1000
  value: current,
@@ -975,29 +1002,40 @@
975
1002
  };
976
1003
  return current;
977
1004
  }
978
- };
979
- cacheFields[propertyName] = {
980
- getter,
981
- value: field2.value,
982
- deps: field2.deps
983
- };
984
- collect(propertyName, getter);
985
- return getter;
986
- }
987
- function extractInstance(updater, wrapper, cache, opts) {
988
- var onGet = (opts || {}).onGet;
989
- var handleGetter = function handleGetter2(key, value) {
990
- if (!onGet) {
991
- return;
1005
+ if (shallowEqual(currentField.deps, fieldInCache.deps)) {
1006
+ return fieldInCache.value;
992
1007
  }
993
- onGet(key, value);
994
- };
1008
+ cacheFields[propertyName] = {
1009
+ getter,
1010
+ value: current,
1011
+ deps: currentField.deps
1012
+ };
1013
+ return current;
1014
+ }
1015
+ };
1016
+ cacheFields[propertyName] = {
1017
+ getter,
1018
+ value: field2.value,
1019
+ deps: field2.deps
1020
+ };
1021
+ collect(propertyName, getter);
1022
+ return getter;
1023
+ }
1024
+ function extractInstance(updater, wrapper, cache, opts) {
1025
+ var onGet = (opts || {}).onGet;
1026
+ var handleGetter = function handleGetter2(key, value) {
1027
+ if (!onGet) {
1028
+ return;
1029
+ }
1030
+ onGet(key, value);
1031
+ };
1032
+ function generateInstance() {
995
1033
  var instance = updater.instance;
996
1034
  if ((typeof instance === "undefined" ? "undefined" : _type_of(instance)) !== "object" || !instance) {
997
1035
  throw new Error("The instance should be an object or array.");
998
1036
  }
999
1037
  var properties = Object.getOwnPropertyNames(instance);
1000
- var proxiedInstance = createProxy(instance, {
1038
+ return createProxy(instance, {
1001
1039
  get: function get(target, p) {
1002
1040
  var value = target[p];
1003
1041
  if (typeof value === "function" && properties.indexOf(p) >= 0) {
@@ -1011,435 +1049,436 @@
1011
1049
  return false;
1012
1050
  }
1013
1051
  });
1014
- function generateInstance() {
1015
- return proxiedInstance;
1016
- }
1017
- if (wrapper == null) {
1018
- return proxiedInstance;
1019
- }
1020
- var wrapped = wrapper(generateInstance);
1021
- if ((typeof wrapped === "undefined" ? "undefined" : _type_of(wrapped)) === "object" && wrapped != null) {
1022
- return cacheProperties(_object_spread_props(_object_spread({}, cache), {
1023
- target: wrapped
1024
- }), handleGetter)();
1025
- }
1026
- return wrapped;
1027
1052
  }
1053
+ var proxiedInstance = generateInstance();
1054
+ if (wrapper == null || wrapper === defaultSelector) {
1055
+ return proxiedInstance;
1056
+ }
1057
+ if (wrapper === defaultSelector) {
1058
+ return cacheProperties(_object_spread_props(_object_spread({}, cache), {
1059
+ target: proxiedInstance
1060
+ }), handleGetter)();
1061
+ }
1062
+ var wrapped = wrapper(generateInstance);
1063
+ if ((typeof wrapped === "undefined" ? "undefined" : _type_of(wrapped)) === "object" && wrapped != null) {
1064
+ return cacheProperties(_object_spread_props(_object_spread({}, cache), {
1065
+ target: wrapped
1066
+ }), handleGetter)();
1067
+ }
1068
+ return wrapped;
1069
+ }
1028
1070
 
1029
- // src/store/enhance/signal.ts
1030
- function createSignal(store) {
1031
- var signalStore = {
1032
- collection: {},
1033
- started: false,
1034
- enabled: false
1035
- };
1036
- var propertiesCache = {
1037
- target: store.getInstance(),
1038
- cacheFields: {},
1039
- cacheMethods: {}
1040
- };
1041
- var enhance = function(dispatcher) {
1042
- return function(action) {
1043
- if (!signalStore.enabled) {
1044
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher(action);
1045
- return;
1046
- }
1047
- var collection = signalStore.collection;
1048
- if (collection == null) {
1049
- return;
1071
+ // src/store/enhance/signal.ts
1072
+ function createSignal(store) {
1073
+ var signalStore = {
1074
+ collection: {},
1075
+ started: false,
1076
+ enabled: false
1077
+ };
1078
+ var propertiesCache = {
1079
+ target: store.getInstance(),
1080
+ cacheFields: {},
1081
+ cacheMethods: {}
1082
+ };
1083
+ var enhance = function(dispatcher) {
1084
+ return function(action) {
1085
+ if (!signalStore.enabled) {
1086
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher(action);
1087
+ return;
1088
+ }
1089
+ var collection = signalStore.collection;
1090
+ if (collection == null) {
1091
+ return;
1092
+ }
1093
+ var storeInstance = extractInstance(store.updater, store.key.wrapper, propertiesCache);
1094
+ var keys = Object.keys(collection);
1095
+ if (!keys.length) {
1096
+ return;
1097
+ }
1098
+ var hasChange = keys.some(function(key) {
1099
+ var field2 = storeInstance[key];
1100
+ var collectedField = collection[key];
1101
+ if (cacheIdentify.field(field2) && cacheIdentify.field(collectedField)) {
1102
+ return field2.get() !== collectedField.get();
1050
1103
  }
1051
- var storeInstance = extractInstance(store.updater, store.key.wrapper, propertiesCache);
1052
- var keys = Object.keys(collection);
1053
- if (!keys.length) {
1104
+ return field2 !== collectedField;
1105
+ });
1106
+ if (hasChange) {
1107
+ dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher(action);
1108
+ }
1109
+ };
1110
+ };
1111
+ var storeKey = store.key;
1112
+ return {
1113
+ key: storeKey,
1114
+ getToken: function getToken() {
1115
+ return store.getToken();
1116
+ },
1117
+ subscribe: function subscribe(dispatcher) {
1118
+ return store.subscribe(enhance(dispatcher));
1119
+ },
1120
+ getSignal: function getSignal() {
1121
+ var collectUsedFields = function collectUsedFields2(key, val) {
1122
+ if (!signalStore.started) {
1054
1123
  return;
1055
1124
  }
1056
- var hasChange = keys.some(function(key) {
1057
- var field2 = storeInstance[key];
1058
- var collectedField = collection[key];
1059
- if (cacheIdentify.field(field2) && cacheIdentify.field(collectedField)) {
1060
- return field2.get() !== collectedField.get();
1061
- }
1062
- return field2 !== collectedField;
1125
+ signalStore.collection[key] = val;
1126
+ };
1127
+ var getInstance = function getInstance2(options) {
1128
+ var cutOff = (options !== null && options !== void 0 ? options : {}).cutOff;
1129
+ return extractInstance(store.updater, store.key.wrapper, propertiesCache, {
1130
+ onGet: cutOff ? void 0 : collectUsedFields
1063
1131
  });
1064
- if (hasChange) {
1065
- dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher(action);
1066
- }
1067
1132
  };
1068
- };
1069
- var storeKey = store.key;
1070
- return {
1071
- key: storeKey,
1072
- getToken: function getToken() {
1073
- return store.getToken();
1074
- },
1075
- subscribe: function subscribe(dispatcher) {
1076
- return store.subscribe(enhance(dispatcher));
1077
- },
1078
- getSignal: function getSignal() {
1079
- var collectUsedFields = function collectUsedFields2(key, val) {
1080
- if (!signalStore.started) {
1081
- return;
1082
- }
1083
- signalStore.collection[key] = val;
1084
- };
1085
- var getInstance = function getInstance2(options) {
1086
- var cutOff = (options !== null && options !== void 0 ? options : {}).cutOff;
1087
- return extractInstance(store.updater, store.key.wrapper, propertiesCache, {
1088
- onGet: cutOff ? void 0 : collectUsedFields
1089
- });
1090
- };
1091
- var signal = function signal2(options) {
1092
- return getInstance(options);
1093
- };
1094
- signal.startStatistics = function startStatistics() {
1095
- signalStore.started = true;
1096
- signalStore.collection = {};
1097
- };
1098
- signal.stopStatistics = function stopStatistics() {
1099
- signalStore.started = false;
1100
- };
1101
- signal.subscribe = function subscribe(dispatchCallback) {
1102
- return store.subscribe(dispatchCallback);
1103
- };
1104
- signal.store = store;
1105
- signalStore.enabled = true;
1133
+ var signal = function signal2(options) {
1134
+ return getInstance(options);
1135
+ };
1136
+ signal.startStatistics = function startStatistics() {
1106
1137
  signalStore.started = true;
1107
- return signal;
1108
- }
1109
- };
1110
- }
1138
+ signalStore.collection = {};
1139
+ };
1140
+ signal.stopStatistics = function stopStatistics() {
1141
+ signalStore.started = false;
1142
+ };
1143
+ signal.subscribe = function subscribe(dispatchCallback) {
1144
+ return store.subscribe(dispatchCallback);
1145
+ };
1146
+ signal.store = store;
1147
+ signalStore.enabled = true;
1148
+ signalStore.started = true;
1149
+ return signal;
1150
+ }
1151
+ };
1152
+ }
1111
1153
 
1112
- // src/store/enhance/selector.ts
1113
- function createSelector(store, opts) {
1114
- var equality = (opts !== null && opts !== void 0 ? opts : {}).equality;
1115
- var selectStore = {
1116
- selectedInstance: store.getInstance()
1117
- };
1118
- var cache = {
1119
- equality,
1120
- setSelect: function setSelect(selector) {
1121
- cache.selector = selector;
1122
- if (!selector) {
1123
- return;
1124
- }
1125
- var currentSelectedInstance = selectStore.selectedInstance;
1126
- var nextSelectedInstance = selector(store.getInstance);
1127
- if (currentSelectedInstance === nextSelectedInstance || equality && equality(currentSelectedInstance, nextSelectedInstance)) {
1128
- return;
1129
- }
1130
- selectStore.selectedInstance = nextSelectedInstance;
1154
+ // src/store/enhance/selector.ts
1155
+ function createSelector(store, opts) {
1156
+ var equality = (opts !== null && opts !== void 0 ? opts : {}).equality;
1157
+ var selectStore = {
1158
+ selectedInstance: store.getInstance()
1159
+ };
1160
+ var cache = {
1161
+ equality,
1162
+ setSelect: function setSelect(selector) {
1163
+ cache.selector = selector;
1164
+ if (!selector) {
1165
+ return;
1131
1166
  }
1132
- };
1133
- var generateSelectedInstance = function generateSelectedInstance2(getInstance) {
1134
- if (cache.selector) {
1135
- return cache.selector(getInstance);
1167
+ var currentSelectedInstance = selectStore.selectedInstance;
1168
+ var nextSelectedInstance = selector(store.getInstance);
1169
+ if (currentSelectedInstance === nextSelectedInstance || equality && equality(currentSelectedInstance, nextSelectedInstance)) {
1170
+ return;
1136
1171
  }
1137
- return getInstance();
1138
- };
1139
- selectStore.selectedInstance = generateSelectedInstance(store.getInstance);
1140
- var enhance = function(dispatcher) {
1141
- return function(action) {
1142
- var currentSelectedInstance = selectStore.selectedInstance;
1143
- var nextSelectedInstance = generateSelectedInstance(store.getInstance);
1144
- if (currentSelectedInstance === nextSelectedInstance || cache.equality && cache.equality(currentSelectedInstance, nextSelectedInstance)) {
1145
- return;
1146
- }
1147
- selectStore.selectedInstance = nextSelectedInstance;
1148
- if (dispatcher == null) {
1149
- return;
1150
- }
1151
- dispatcher(action);
1152
- };
1153
- };
1154
- function select(selector) {
1155
- cache.setSelect(selector);
1156
- return selectStore.selectedInstance;
1172
+ selectStore.selectedInstance = nextSelectedInstance;
1157
1173
  }
1158
- return {
1159
- key: store.key,
1160
- getToken: function getToken() {
1161
- return store.getToken();
1162
- },
1163
- subscribe: function subscribe(dispatcher) {
1164
- return store.subscribe(enhance(dispatcher));
1165
- },
1166
- select
1167
- };
1168
- }
1169
-
1170
- // src/store/index.ts
1171
- function createPrimaryKey(modelFn) {
1172
- var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1173
- var ifModelKey = isModelKey(modelFn);
1174
- var ifModelUsage = isModelUsage(modelFn);
1175
- var model2 = ifModelKey ? modelFn.source : modelFn;
1176
- var _config_wrapper;
1177
- var wrapper = (_config_wrapper = config2.wrapper) !== null && _config_wrapper !== void 0 ? _config_wrapper : ifModelKey || ifModelUsage ? modelFn.wrapper : function defaultSelector(i) {
1178
- return i();
1179
- };
1180
- var wrapModel = function wrapModel2(state) {
1181
- return model2(state);
1182
- };
1183
- wrapModel.source = model2;
1184
- wrapModel.wrapper = wrapper;
1185
- wrapModel.modelKeyIdentifier = modelKeyIdentifier;
1186
- if ("state" in config2) {
1187
- wrapModel.defaultState = config2.state;
1174
+ };
1175
+ var generateSelectedInstance = function generateSelectedInstance2(getInstance) {
1176
+ if (cache.selector) {
1177
+ return cache.selector(getInstance);
1188
1178
  }
1189
- return wrapModel;
1190
- }
1191
- function createStore(modelLike) {
1192
- var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1193
- var ifModelKey = isModelKey(modelLike);
1194
- var model2 = ifModelKey ? modelLike.source : modelLike;
1195
- var modelKey = ifModelKey ? modelLike : void 0;
1196
- var conf = function computeConfig() {
1197
- var hasConfigState = "state" in config2;
1198
- var hasKeyState = !!modelKey && "defaultState" in modelKey;
1199
- if (hasConfigState) {
1200
- return config2;
1179
+ return getInstance();
1180
+ };
1181
+ selectStore.selectedInstance = generateSelectedInstance(store.getInstance);
1182
+ var enhance = function(dispatcher) {
1183
+ return function(action) {
1184
+ var currentSelectedInstance = selectStore.selectedInstance;
1185
+ var nextSelectedInstance = generateSelectedInstance(store.getInstance);
1186
+ if (currentSelectedInstance === nextSelectedInstance || cache.equality && cache.equality(currentSelectedInstance, nextSelectedInstance)) {
1187
+ return;
1201
1188
  }
1202
- if (hasKeyState) {
1203
- return _object_spread_props(_object_spread({}, config2), {
1204
- state: modelKey === null || modelKey === void 0 ? void 0 : modelKey.defaultState
1205
- });
1189
+ selectStore.selectedInstance = nextSelectedInstance;
1190
+ if (dispatcher == null) {
1191
+ return;
1206
1192
  }
1207
- return config2;
1208
- }();
1209
- var combinedMiddleWare = function combinedMiddleWare2(s) {
1210
- return function updaterMiddleWare(next) {
1211
- var middleWares = conf.middleWares;
1212
- if (middleWares == null) {
1213
- return next;
1214
- }
1215
- var updateMiddleWares = _to_consumable_array(middleWares).reverse().map(function(middleWare) {
1216
- return middleWare(s);
1217
- });
1218
- return updateMiddleWares.reduce(function(finalDispatcher, um) {
1219
- return um(finalDispatcher);
1220
- }, next);
1221
- };
1222
- };
1223
- var updater = createUpdater(model2, combinedMiddleWare, conf);
1224
- var key = modelKey !== null && modelKey !== void 0 ? modelKey : createPrimaryKey(model2, config2);
1225
- var propertiesCache = {
1226
- target: updater.instance,
1227
- cacheFields: {},
1228
- cacheMethods: {}
1193
+ dispatcher(action);
1229
1194
  };
1230
- var store = {
1231
- key,
1232
- getToken: function getToken() {
1233
- return updater.token;
1234
- },
1235
- subscribe: function subscribe(dispatcher) {
1236
- var _updater_createTunnel = updater.createTunnel(dispatcher || noop), connect = _updater_createTunnel.connect, disconnect = _updater_createTunnel.disconnect;
1237
- connect();
1238
- return disconnect;
1239
- },
1240
- getInstance: function getInstance() {
1241
- return extractInstance(updater, key.wrapper, propertiesCache);
1242
- },
1243
- getStoreInstance: function getStoreInstance() {
1244
- return extractInstance(updater, void 0, propertiesCache);
1245
- },
1246
- update: function update(args) {
1247
- var updateArgs = args !== null && args !== void 0 ? args : {};
1248
- if (updateArgs.key) {
1249
- var updatingKey = updateArgs.key, updatingModel = updateArgs.model, rest = _object_without_properties(updateArgs, [
1250
- "key",
1251
- "model"
1252
- ]);
1253
- updater.update(_object_spread_props(_object_spread({}, rest), {
1254
- model: updatingKey.source
1255
- }));
1256
- store.key = updatingKey;
1257
- return;
1258
- }
1259
- if (updateArgs.model) {
1260
- var updatingKey1 = updateArgs.key, updatingModel1 = updateArgs.model, rest1 = _object_without_properties(updateArgs, [
1261
- "key",
1262
- "model"
1263
- ]);
1264
- updater.update(_object_spread_props(_object_spread({}, rest1), {
1265
- model: updatingModel1
1266
- }));
1267
- store.key = createPrimaryKey(updatingModel1, config2);
1268
- return;
1269
- }
1270
- updater.update(args);
1271
- },
1272
- destroy: function destroy2() {
1273
- updater.destroy();
1274
- },
1275
- payload: function payload(callback) {
1276
- return updater.payload(callback);
1277
- },
1278
- isDestroyed: function isDestroyed() {
1279
- return updater.isDestroyed;
1280
- },
1281
- extends: function _extends(e) {
1282
- return Object.assign(store, e);
1283
- },
1284
- updater,
1285
- modelStoreIdentifier
1286
- };
1287
- return store;
1195
+ };
1196
+ function select(selector) {
1197
+ cache.setSelect(selector);
1198
+ return selectStore.selectedInstance;
1288
1199
  }
1289
- var createField2 = createField;
1290
- var createMethod2 = createMethod;
1200
+ return {
1201
+ key: store.key,
1202
+ getToken: function getToken() {
1203
+ return store.getToken();
1204
+ },
1205
+ subscribe: function subscribe(dispatcher) {
1206
+ return store.subscribe(enhance(dispatcher));
1207
+ },
1208
+ select
1209
+ };
1210
+ }
1291
1211
 
1292
- // src/key/index.ts
1293
- function createKey(model2) {
1294
- var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1295
- var wrapModel = createPrimaryKey(model2, config2);
1296
- wrapModel.createStore = function createKeyStore() {
1297
- var storeConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1298
- return createStore(wrapModel, _object_spread({}, config2, storeConfig));
1299
- };
1300
- wrapModel.extends = function extendsKey(e) {
1301
- return Object.assign(wrapModel, e);
1302
- };
1303
- return wrapModel;
1212
+ // src/store/index.ts
1213
+ function createPrimaryKey(modelFn) {
1214
+ var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1215
+ var ifModelKey = isModelKey(modelFn);
1216
+ var ifModelUsage = isModelUsage(modelFn);
1217
+ var model2 = ifModelKey ? modelFn.source : modelFn;
1218
+ var _config_wrapper;
1219
+ var wrapper = (_config_wrapper = config2.wrapper) !== null && _config_wrapper !== void 0 ? _config_wrapper : ifModelKey || ifModelUsage ? modelFn.wrapper : function defaultSelector2(i) {
1220
+ return i();
1221
+ };
1222
+ var wrapModel = function wrapModel2(state) {
1223
+ return model2(state);
1224
+ };
1225
+ wrapModel.source = model2;
1226
+ wrapModel.wrapper = wrapper;
1227
+ wrapModel.modelKeyIdentifier = modelKeyIdentifier;
1228
+ if ("state" in config2) {
1229
+ wrapModel.defaultState = config2.state;
1304
1230
  }
1305
- createKey.isModelKey = isModelKey;
1306
- function createStores(modelKeys) {
1307
- var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1308
- var state = {
1309
- destroyed: false
1231
+ return wrapModel;
1232
+ }
1233
+ function createStore(modelLike) {
1234
+ var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1235
+ var ifModelKey = isModelKey(modelLike);
1236
+ var model2 = ifModelKey ? modelLike.source : modelLike;
1237
+ var modelKey = ifModelKey ? modelLike : void 0;
1238
+ var conf = function computeConfig() {
1239
+ var hasConfigState = "state" in config2;
1240
+ var hasKeyState = !!modelKey && "defaultState" in modelKey;
1241
+ if (hasConfigState) {
1242
+ return config2;
1243
+ }
1244
+ if (hasKeyState) {
1245
+ return _object_spread_props(_object_spread({}, config2), {
1246
+ state: modelKey === null || modelKey === void 0 ? void 0 : modelKey.defaultState
1247
+ });
1248
+ }
1249
+ return config2;
1250
+ }();
1251
+ var combinedMiddleWare = function combinedMiddleWare2(s) {
1252
+ return function updaterMiddleWare(next) {
1253
+ var middleWares = conf.middleWares;
1254
+ if (middleWares == null) {
1255
+ return next;
1256
+ }
1257
+ var updateMiddleWares = _to_consumable_array(middleWares).reverse().map(function(middleWare) {
1258
+ return middleWare(s);
1259
+ });
1260
+ return updateMiddleWares.reduce(function(finalDispatcher, um) {
1261
+ return um(finalDispatcher);
1262
+ }, next);
1310
1263
  };
1311
- var storeUnits = modelKeys.map(function(modelKey) {
1312
- if (typeof modelKey === "function") {
1313
- return modelKey.createStore();
1264
+ };
1265
+ var updater = createUpdater(model2, combinedMiddleWare, conf);
1266
+ var key = modelKey !== null && modelKey !== void 0 ? modelKey : createPrimaryKey(model2, config2);
1267
+ var propertiesCache = {
1268
+ target: updater.instance,
1269
+ cacheFields: {},
1270
+ cacheMethods: {}
1271
+ };
1272
+ var store = {
1273
+ key,
1274
+ getToken: function getToken() {
1275
+ return updater.token;
1276
+ },
1277
+ subscribe: function subscribe(dispatcher) {
1278
+ var _updater_createTunnel = updater.createTunnel(dispatcher || noop), connect = _updater_createTunnel.connect, disconnect = _updater_createTunnel.disconnect;
1279
+ connect();
1280
+ return disconnect;
1281
+ },
1282
+ getInstance: function getInstance() {
1283
+ return extractInstance(updater, key.wrapper, propertiesCache);
1284
+ },
1285
+ getStoreInstance: function getStoreInstance() {
1286
+ return extractInstance(updater, void 0, propertiesCache);
1287
+ },
1288
+ update: function update(args) {
1289
+ var updateArgs = args !== null && args !== void 0 ? args : {};
1290
+ if (updateArgs.key) {
1291
+ var updatingKey = updateArgs.key, updatingModel = updateArgs.model, rest = _object_without_properties(updateArgs, [
1292
+ "key",
1293
+ "model"
1294
+ ]);
1295
+ updater.update(_object_spread_props(_object_spread({}, rest), {
1296
+ model: updatingKey.source
1297
+ }));
1298
+ store.key = updatingKey;
1299
+ return;
1314
1300
  }
1315
- var k = modelKey.key;
1316
- return createStore(k, "defaultState" in k ? _object_spread_props(_object_spread({}, config2), {
1317
- state: k.defaultState
1318
- }) : config2);
1319
- });
1320
- return {
1321
- find: function find(key) {
1322
- var found = storeUnits.find(function(c) {
1323
- if (typeof key === "function") {
1324
- return c.key === key;
1325
- }
1326
- return c.key === key.key;
1327
- });
1328
- if (!found) {
1329
- return null;
1330
- }
1331
- return found;
1332
- },
1333
- update: function update() {
1334
- for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
1335
- keys[_key] = arguments[_key];
1301
+ if (updateArgs.model) {
1302
+ var updatingKey1 = updateArgs.key, updatingModel1 = updateArgs.model, rest1 = _object_without_properties(updateArgs, [
1303
+ "key",
1304
+ "model"
1305
+ ]);
1306
+ updater.update(_object_spread_props(_object_spread({}, rest1), {
1307
+ model: updatingModel1
1308
+ }));
1309
+ store.key = createPrimaryKey(updatingModel1, config2);
1310
+ return;
1311
+ }
1312
+ updater.update(args);
1313
+ },
1314
+ destroy: function destroy2() {
1315
+ updater.destroy();
1316
+ },
1317
+ payload: function payload(callback) {
1318
+ return updater.payload(callback);
1319
+ },
1320
+ isDestroyed: function isDestroyed() {
1321
+ return updater.isDestroyed;
1322
+ },
1323
+ extends: function _extends(e) {
1324
+ return Object.assign(store, e);
1325
+ },
1326
+ updater,
1327
+ modelStoreIdentifier
1328
+ };
1329
+ return store;
1330
+ }
1331
+ var createField2 = createField;
1332
+ var createMethod2 = createMethod;
1333
+
1334
+ // src/key/index.ts
1335
+ function createKey(model2) {
1336
+ var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1337
+ var wrapModel = createPrimaryKey(model2, config2);
1338
+ wrapModel.createStore = function createKeyStore() {
1339
+ var storeConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1340
+ return createStore(wrapModel, _object_spread({}, config2, storeConfig));
1341
+ };
1342
+ wrapModel.extends = function extendsKey(e) {
1343
+ return Object.assign(wrapModel, e);
1344
+ };
1345
+ return wrapModel;
1346
+ }
1347
+ createKey.isModelKey = isModelKey;
1348
+ function createStores(modelKeys) {
1349
+ var config2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1350
+ var state = {
1351
+ destroyed: false
1352
+ };
1353
+ var storeUnits = modelKeys.map(function(modelKey) {
1354
+ if (typeof modelKey === "function") {
1355
+ return modelKey.createStore();
1356
+ }
1357
+ var k = modelKey.key;
1358
+ return createStore(k, "defaultState" in k ? _object_spread_props(_object_spread({}, config2), {
1359
+ state: k.defaultState
1360
+ }) : config2);
1361
+ });
1362
+ return {
1363
+ find: function find(key) {
1364
+ var found = storeUnits.find(function(c) {
1365
+ if (typeof key === "function") {
1366
+ return c.key === key;
1336
1367
  }
1337
- if (state.destroyed) {
1368
+ return c.key === key.key;
1369
+ });
1370
+ if (!found) {
1371
+ return null;
1372
+ }
1373
+ return found;
1374
+ },
1375
+ update: function update() {
1376
+ for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
1377
+ keys[_key] = arguments[_key];
1378
+ }
1379
+ if (state.destroyed) {
1380
+ return;
1381
+ }
1382
+ storeUnits.forEach(function(un, i) {
1383
+ var keyLike = keys[i];
1384
+ if (!keyLike) {
1338
1385
  return;
1339
1386
  }
1340
- storeUnits.forEach(function(un, i) {
1341
- var keyLike = keys[i];
1342
- if (!keyLike) {
1343
- return;
1344
- }
1345
- var ifIsModelKey = validations.isModelKey(keyLike);
1346
- var key = ifIsModelKey ? keyLike : keyLike.key;
1347
- un.update({
1348
- key
1349
- });
1350
- });
1351
- },
1352
- keys: function keys() {
1353
- return storeUnits.map(function(param) {
1354
- var key = param.key;
1355
- return key;
1356
- });
1357
- },
1358
- destroy: function destroy2() {
1359
- storeUnits.forEach(function(unit) {
1360
- unit.destroy();
1387
+ var ifIsModelKey = validations.isModelKey(keyLike);
1388
+ var key = ifIsModelKey ? keyLike : keyLike.key;
1389
+ un.update({
1390
+ key
1361
1391
  });
1362
- state.destroyed = true;
1363
- }
1364
- };
1365
- }
1392
+ });
1393
+ },
1394
+ keys: function keys() {
1395
+ return storeUnits.map(function(param) {
1396
+ var key = param.key;
1397
+ return key;
1398
+ });
1399
+ },
1400
+ destroy: function destroy2() {
1401
+ storeUnits.forEach(function(unit) {
1402
+ unit.destroy();
1403
+ });
1404
+ state.destroyed = true;
1405
+ }
1406
+ };
1407
+ }
1366
1408
 
1367
- // src/model/index.ts
1368
- function configModel(config2) {
1369
- var model2 = function model3(modelFn, wrapper) {
1370
- var currentSelector = wrapper !== null && wrapper !== void 0 ? wrapper : function defaultSelector(i) {
1371
- return i();
1372
- };
1373
- var modelWrapper = function modelWrapper2(state) {
1374
- return modelFn(state);
1375
- };
1376
- modelWrapper.produce = function produce(s) {
1377
- return model3(modelFn, s);
1378
- };
1379
- modelWrapper.createKey = function createModelKey(state) {
1380
- return createKey(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config2), {
1381
- state,
1382
- wrapper: currentSelector
1383
- }) : _object_spread_props(_object_spread({}, config2), {
1384
- wrapper: currentSelector
1385
- }));
1386
- };
1387
- modelWrapper.createStore = function createModelStore(state) {
1388
- return createStore(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config2), {
1389
- state,
1390
- wrapper: currentSelector
1391
- }) : _object_spread_props(_object_spread({}, config2), {
1392
- wrapper: currentSelector
1393
- }));
1394
- };
1395
- modelWrapper.extends = function extendsModelUsage(e) {
1396
- return Object.assign(modelWrapper, e);
1397
- };
1398
- modelWrapper.wrapper = currentSelector;
1399
- modelWrapper.modelUsageIdentifier = modelUsageIdentifier;
1400
- return modelWrapper;
1409
+ // src/model/index.ts
1410
+ function configModel(config2) {
1411
+ var model2 = function model3(modelFn, wrapper) {
1412
+ var currentSelector = wrapper !== null && wrapper !== void 0 ? wrapper : defaultSelector;
1413
+ var modelWrapper = function modelWrapper2(state) {
1414
+ return modelFn(state);
1401
1415
  };
1402
- model2.createField = createField2;
1403
- model2.createMethod = createMethod2;
1404
- return model2;
1405
- }
1406
-
1407
- // src/index.ts
1408
- function config() {
1409
- var configuration = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1410
- var createStore3 = function createStore4(modelLike, state) {
1411
- return createStore(modelLike, arguments.length > 1 ? _object_spread_props(_object_spread({}, configuration), {
1412
- state
1413
- }) : configuration);
1416
+ modelWrapper.produce = function produce(s) {
1417
+ return model3(modelFn, s);
1414
1418
  };
1415
- var createKey3 = function createKey4(model3, state) {
1416
- var isKeySetState = arguments.length > 1;
1417
- var key = createKey(model3, isKeySetState ? _object_spread_props(_object_spread({}, configuration), {
1418
- state
1419
- }) : configuration);
1420
- key.createStore = function createKeyStore(s) {
1421
- return arguments.length > 0 ? createStore3(key, s) : createStore3(key);
1422
- };
1423
- return key;
1419
+ modelWrapper.createKey = function createModelKey(state) {
1420
+ return createKey(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config2), {
1421
+ state,
1422
+ wrapper: currentSelector
1423
+ }) : _object_spread_props(_object_spread({}, config2), {
1424
+ wrapper: currentSelector
1425
+ }));
1424
1426
  };
1425
- createKey3.isModelKey = createKey.isModelKey;
1426
- var createStores3 = function createStores4() {
1427
- for (var _len = arguments.length, modelKeys = new Array(_len), _key = 0; _key < _len; _key++) {
1428
- modelKeys[_key] = arguments[_key];
1429
- }
1430
- return createStores(modelKeys, configuration);
1427
+ modelWrapper.createStore = function createModelStore(state) {
1428
+ return createStore(modelFn, arguments.length ? _object_spread_props(_object_spread({}, config2), {
1429
+ state,
1430
+ wrapper: currentSelector
1431
+ }) : _object_spread_props(_object_spread({}, config2), {
1432
+ wrapper: currentSelector
1433
+ }));
1431
1434
  };
1432
- var model2 = configModel(configuration);
1433
- return {
1434
- createStore: createStore3,
1435
- createKey: createKey3,
1436
- createStores: createStores3,
1437
- model: model2
1435
+ modelWrapper.extends = function extendsModelUsage(e) {
1436
+ return Object.assign(modelWrapper, e);
1438
1437
  };
1439
- }
1440
- var _config = config();
1441
- var createStore2 = _config.createStore;
1442
- var createKey2 = _config.createKey;
1443
- var createStores2 = _config.createStores;
1444
- var model = _config.model;
1445
- })();
1438
+ modelWrapper.wrapper = currentSelector;
1439
+ modelWrapper.modelUsageIdentifier = modelUsageIdentifier;
1440
+ return modelWrapper;
1441
+ };
1442
+ model2.createField = createField2;
1443
+ model2.createMethod = createMethod2;
1444
+ return model2;
1445
+ }
1446
+
1447
+ // src/index.ts
1448
+ function config() {
1449
+ var configuration = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1450
+ var createStore3 = function createStore4(modelLike, state) {
1451
+ return createStore(modelLike, arguments.length > 1 ? _object_spread_props(_object_spread({}, configuration), {
1452
+ state
1453
+ }) : configuration);
1454
+ };
1455
+ var createKey3 = function createKey4(model3, state) {
1456
+ var isKeySetState = arguments.length > 1;
1457
+ var key = createKey(model3, isKeySetState ? _object_spread_props(_object_spread({}, configuration), {
1458
+ state
1459
+ }) : configuration);
1460
+ key.createStore = function createKeyStore(s) {
1461
+ return arguments.length > 0 ? createStore3(key, s) : createStore3(key);
1462
+ };
1463
+ return key;
1464
+ };
1465
+ createKey3.isModelKey = createKey.isModelKey;
1466
+ var createStores3 = function createStores4() {
1467
+ for (var _len = arguments.length, modelKeys = new Array(_len), _key = 0; _key < _len; _key++) {
1468
+ modelKeys[_key] = arguments[_key];
1469
+ }
1470
+ return createStores(modelKeys, configuration);
1471
+ };
1472
+ var model2 = configModel(configuration);
1473
+ return {
1474
+ createStore: createStore3,
1475
+ createKey: createKey3,
1476
+ createStores: createStores3,
1477
+ model: model2
1478
+ };
1479
+ }
1480
+ var _config = config();
1481
+ var createStore2 = _config.createStore;
1482
+ var createKey2 = _config.createKey;
1483
+ var createStores2 = _config.createStores;
1484
+ var model = _config.model;