epic-alt 0.18.6
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/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/alt.js +2086 -0
- package/package.json +27 -0
- package/scripts/build.js +125 -0
package/dist/alt.js
ADDED
|
@@ -0,0 +1,2086 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define([], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["Alt"] = factory();
|
|
8
|
+
else
|
|
9
|
+
root["Alt"] = factory();
|
|
10
|
+
})(this, function() {
|
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
+
/******/ // The module cache
|
|
13
|
+
/******/ var installedModules = {};
|
|
14
|
+
|
|
15
|
+
/******/ // The require function
|
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
|
17
|
+
|
|
18
|
+
/******/ // Check if module is in cache
|
|
19
|
+
/******/ if(installedModules[moduleId])
|
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
|
21
|
+
|
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
|
24
|
+
/******/ exports: {},
|
|
25
|
+
/******/ id: moduleId,
|
|
26
|
+
/******/ loaded: false
|
|
27
|
+
/******/ };
|
|
28
|
+
|
|
29
|
+
/******/ // Execute the module function
|
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
+
|
|
32
|
+
/******/ // Flag the module as loaded
|
|
33
|
+
/******/ module.loaded = true;
|
|
34
|
+
|
|
35
|
+
/******/ // Return the exports of the module
|
|
36
|
+
/******/ return module.exports;
|
|
37
|
+
/******/ }
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
+
/******/ __webpack_require__.m = modules;
|
|
42
|
+
|
|
43
|
+
/******/ // expose the module cache
|
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
|
45
|
+
|
|
46
|
+
/******/ // __webpack_public_path__
|
|
47
|
+
/******/ __webpack_require__.p = "";
|
|
48
|
+
|
|
49
|
+
/******/ // Load entry module and return exports
|
|
50
|
+
/******/ return __webpack_require__(0);
|
|
51
|
+
/******/ })
|
|
52
|
+
/************************************************************************/
|
|
53
|
+
/******/ ([
|
|
54
|
+
/* 0 */
|
|
55
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
56
|
+
|
|
57
|
+
module.exports = __webpack_require__(1);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/***/ }),
|
|
61
|
+
/* 1 */
|
|
62
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
63
|
+
|
|
64
|
+
"use strict";
|
|
65
|
+
|
|
66
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
67
|
+
|
|
68
|
+
var _typeof = __webpack_require__(3);
|
|
69
|
+
|
|
70
|
+
Object.defineProperty(exports, "__esModule", {
|
|
71
|
+
value: true
|
|
72
|
+
});
|
|
73
|
+
exports["default"] = void 0;
|
|
74
|
+
|
|
75
|
+
var _construct2 = _interopRequireDefault(__webpack_require__(4));
|
|
76
|
+
|
|
77
|
+
var _inherits2 = _interopRequireDefault(__webpack_require__(7));
|
|
78
|
+
|
|
79
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(8));
|
|
80
|
+
|
|
81
|
+
var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(10));
|
|
82
|
+
|
|
83
|
+
var _classCallCheck2 = _interopRequireDefault(__webpack_require__(11));
|
|
84
|
+
|
|
85
|
+
var _createClass2 = _interopRequireDefault(__webpack_require__(12));
|
|
86
|
+
|
|
87
|
+
var _flux = __webpack_require__(13);
|
|
88
|
+
|
|
89
|
+
var StateFunctions = _interopRequireWildcard(__webpack_require__(17));
|
|
90
|
+
|
|
91
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
92
|
+
|
|
93
|
+
var store = _interopRequireWildcard(__webpack_require__(19));
|
|
94
|
+
|
|
95
|
+
var utils = _interopRequireWildcard(__webpack_require__(20));
|
|
96
|
+
|
|
97
|
+
var _actions = _interopRequireDefault(__webpack_require__(25));
|
|
98
|
+
|
|
99
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
100
|
+
|
|
101
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
102
|
+
|
|
103
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
104
|
+
|
|
105
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
106
|
+
|
|
107
|
+
var Alt = /*#__PURE__*/function () {
|
|
108
|
+
function Alt() {
|
|
109
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
110
|
+
(0, _classCallCheck2["default"])(this, Alt);
|
|
111
|
+
this.config = config;
|
|
112
|
+
this.serialize = config.serialize || JSON.stringify;
|
|
113
|
+
this.deserialize = config.deserialize || JSON.parse;
|
|
114
|
+
this.dispatcher = config.dispatcher || new _flux.Dispatcher();
|
|
115
|
+
|
|
116
|
+
this.batchingFunction = config.batchingFunction || function (callback) {
|
|
117
|
+
return callback();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
this.actions = {
|
|
121
|
+
global: {}
|
|
122
|
+
};
|
|
123
|
+
this.stores = {};
|
|
124
|
+
this.storeTransforms = config.storeTransforms || [];
|
|
125
|
+
this.trapAsync = false;
|
|
126
|
+
this._actionsRegistry = {};
|
|
127
|
+
this._initSnapshot = {};
|
|
128
|
+
this._lastSnapshot = {};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
(0, _createClass2["default"])(Alt, [{
|
|
132
|
+
key: "dispatch",
|
|
133
|
+
value: function dispatch(action, data, details) {
|
|
134
|
+
var _this = this;
|
|
135
|
+
|
|
136
|
+
this.batchingFunction(function () {
|
|
137
|
+
var id = Math.random().toString(18).substr(2, 16); // support straight dispatching of FSA-style actions
|
|
138
|
+
|
|
139
|
+
if (action.hasOwnProperty('type') && action.hasOwnProperty('payload')) {
|
|
140
|
+
var fsaDetails = {
|
|
141
|
+
id: action.type,
|
|
142
|
+
namespace: action.type,
|
|
143
|
+
name: action.type
|
|
144
|
+
};
|
|
145
|
+
return _this.dispatcher.dispatch(utils.fsa(id, action.type, action.payload, fsaDetails));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (action.id && action.dispatch) {
|
|
149
|
+
return utils.dispatch(id, action, data, _this);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return _this.dispatcher.dispatch(utils.fsa(id, action, data, details));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "createUnsavedStore",
|
|
157
|
+
value: function createUnsavedStore(StoreModel) {
|
|
158
|
+
var key = StoreModel.displayName || '';
|
|
159
|
+
store.createStoreConfig(this.config, StoreModel);
|
|
160
|
+
var Store = store.transformStore(this.storeTransforms, StoreModel);
|
|
161
|
+
|
|
162
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
163
|
+
args[_key - 1] = arguments[_key];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return fn.isFunction(Store) ? store.createStoreFromClass.apply(store, [this, Store, key].concat(args)) : store.createStoreFromObject(this, Store, key);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "createStore",
|
|
170
|
+
value: function createStore(StoreModel, iden) {
|
|
171
|
+
var key = iden || StoreModel.displayName || StoreModel.name || '';
|
|
172
|
+
store.createStoreConfig(this.config, StoreModel);
|
|
173
|
+
var Store = store.transformStore(this.storeTransforms, StoreModel);
|
|
174
|
+
/* istanbul ignore next */
|
|
175
|
+
|
|
176
|
+
if (false) delete this.stores[key];
|
|
177
|
+
|
|
178
|
+
if (this.stores[key] || !key) {
|
|
179
|
+
if (this.stores[key]) {
|
|
180
|
+
utils.warn("A store named ".concat(key, " already exists, double check your store ") + "names or pass in your own custom identifier for each store");
|
|
181
|
+
} else {
|
|
182
|
+
utils.warn('Store name was not specified');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
key = utils.uid(this.stores, key);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
189
|
+
args[_key2 - 2] = arguments[_key2];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
var storeInstance = fn.isFunction(Store) ? store.createStoreFromClass.apply(store, [this, Store, key].concat(args)) : store.createStoreFromObject(this, Store, key);
|
|
193
|
+
this.stores[key] = storeInstance;
|
|
194
|
+
StateFunctions.saveInitialSnapshot(this, key);
|
|
195
|
+
return storeInstance;
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "generateActions",
|
|
199
|
+
value: function generateActions() {
|
|
200
|
+
var actions = {
|
|
201
|
+
name: 'global'
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
for (var _len3 = arguments.length, actionNames = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
205
|
+
actionNames[_key3] = arguments[_key3];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return this.createActions(actionNames.reduce(function (obj, action) {
|
|
209
|
+
obj[action] = utils.dispatchIdentity;
|
|
210
|
+
return obj;
|
|
211
|
+
}, actions));
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "createAction",
|
|
215
|
+
value: function createAction(name, implementation, obj) {
|
|
216
|
+
return (0, _actions["default"])(this, 'global', name, implementation, obj);
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
219
|
+
key: "createActions",
|
|
220
|
+
value: function createActions(ActionsClass) {
|
|
221
|
+
var _this2 = this;
|
|
222
|
+
|
|
223
|
+
var exportObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
224
|
+
var actions = {};
|
|
225
|
+
var key = utils.uid(this._actionsRegistry, ActionsClass.displayName || ActionsClass.name || 'Unknown');
|
|
226
|
+
|
|
227
|
+
if (fn.isFunction(ActionsClass)) {
|
|
228
|
+
fn.assign(actions, utils.getPrototypeChain(ActionsClass));
|
|
229
|
+
|
|
230
|
+
var ActionsGenerator = /*#__PURE__*/function (_ActionsClass) {
|
|
231
|
+
(0, _inherits2["default"])(ActionsGenerator, _ActionsClass);
|
|
232
|
+
|
|
233
|
+
var _super = _createSuper(ActionsGenerator);
|
|
234
|
+
|
|
235
|
+
function ActionsGenerator() {
|
|
236
|
+
(0, _classCallCheck2["default"])(this, ActionsGenerator);
|
|
237
|
+
|
|
238
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
239
|
+
args[_key5] = arguments[_key5];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return _super.call.apply(_super, [this].concat(args));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
(0, _createClass2["default"])(ActionsGenerator, [{
|
|
246
|
+
key: "generateActions",
|
|
247
|
+
value: function generateActions() {
|
|
248
|
+
for (var _len6 = arguments.length, actionNames = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
249
|
+
actionNames[_key6] = arguments[_key6];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
actionNames.forEach(function (actionName) {
|
|
253
|
+
actions[actionName] = utils.dispatchIdentity;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}]);
|
|
257
|
+
return ActionsGenerator;
|
|
258
|
+
}(ActionsClass);
|
|
259
|
+
|
|
260
|
+
for (var _len4 = arguments.length, argsForConstructor = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
261
|
+
argsForConstructor[_key4 - 2] = arguments[_key4];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
fn.assign(actions, (0, _construct2["default"])(ActionsGenerator, argsForConstructor));
|
|
265
|
+
} else {
|
|
266
|
+
fn.assign(actions, ActionsClass);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
this.actions[key] = this.actions[key] || {};
|
|
270
|
+
fn.eachObject(function (actionName, action) {
|
|
271
|
+
if (!fn.isFunction(action)) {
|
|
272
|
+
exportObj[actionName] = action;
|
|
273
|
+
return;
|
|
274
|
+
} // create the action
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
exportObj[actionName] = (0, _actions["default"])(_this2, key, actionName, action, exportObj); // generate a constant
|
|
278
|
+
|
|
279
|
+
var constant = utils.formatAsConstant(actionName);
|
|
280
|
+
exportObj[constant] = exportObj[actionName].id;
|
|
281
|
+
}, [actions]);
|
|
282
|
+
return exportObj;
|
|
283
|
+
}
|
|
284
|
+
}, {
|
|
285
|
+
key: "takeSnapshot",
|
|
286
|
+
value: function takeSnapshot() {
|
|
287
|
+
for (var _len7 = arguments.length, storeNames = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
288
|
+
storeNames[_key7] = arguments[_key7];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
var state = StateFunctions.snapshot(this, storeNames);
|
|
292
|
+
fn.assign(this._lastSnapshot, state);
|
|
293
|
+
return this.serialize(state);
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "rollback",
|
|
297
|
+
value: function rollback() {
|
|
298
|
+
StateFunctions.setAppState(this, this.serialize(this._lastSnapshot), function (storeInst) {
|
|
299
|
+
storeInst.lifecycle('rollback');
|
|
300
|
+
storeInst.emitChange();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "recycle",
|
|
305
|
+
value: function recycle() {
|
|
306
|
+
for (var _len8 = arguments.length, storeNames = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
307
|
+
storeNames[_key8] = arguments[_key8];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
var initialSnapshot = storeNames.length ? StateFunctions.filterSnapshots(this, this._initSnapshot, storeNames) : this._initSnapshot;
|
|
311
|
+
StateFunctions.setAppState(this, this.serialize(initialSnapshot), function (storeInst) {
|
|
312
|
+
storeInst.lifecycle('init');
|
|
313
|
+
storeInst.emitChange();
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
key: "flush",
|
|
318
|
+
value: function flush() {
|
|
319
|
+
var state = this.serialize(StateFunctions.snapshot(this));
|
|
320
|
+
this.recycle();
|
|
321
|
+
return state;
|
|
322
|
+
}
|
|
323
|
+
}, {
|
|
324
|
+
key: "bootstrap",
|
|
325
|
+
value: function bootstrap(data) {
|
|
326
|
+
StateFunctions.setAppState(this, data, function (storeInst, state) {
|
|
327
|
+
storeInst.lifecycle('bootstrap', state);
|
|
328
|
+
storeInst.emitChange();
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
key: "prepare",
|
|
333
|
+
value: function prepare(storeInst, payload) {
|
|
334
|
+
var data = {};
|
|
335
|
+
|
|
336
|
+
if (!storeInst.displayName) {
|
|
337
|
+
throw new ReferenceError('Store provided does not have a name');
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
data[storeInst.displayName] = payload;
|
|
341
|
+
return this.serialize(data);
|
|
342
|
+
} // Instance type methods for injecting alt into your application as context
|
|
343
|
+
|
|
344
|
+
}, {
|
|
345
|
+
key: "addActions",
|
|
346
|
+
value: function addActions(name, ActionsClass) {
|
|
347
|
+
for (var _len9 = arguments.length, args = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) {
|
|
348
|
+
args[_key9 - 2] = arguments[_key9];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
this.actions[name] = Array.isArray(ActionsClass) ? this.generateActions.apply(this, ActionsClass) : this.createActions.apply(this, [ActionsClass].concat(args));
|
|
352
|
+
}
|
|
353
|
+
}, {
|
|
354
|
+
key: "addStore",
|
|
355
|
+
value: function addStore(name, StoreModel) {
|
|
356
|
+
for (var _len10 = arguments.length, args = new Array(_len10 > 2 ? _len10 - 2 : 0), _key10 = 2; _key10 < _len10; _key10++) {
|
|
357
|
+
args[_key10 - 2] = arguments[_key10];
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
this.createStore.apply(this, [StoreModel, name].concat(args));
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "getActions",
|
|
364
|
+
value: function getActions(name) {
|
|
365
|
+
return this.actions[name];
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "getStore",
|
|
369
|
+
value: function getStore(name) {
|
|
370
|
+
return this.stores[name];
|
|
371
|
+
}
|
|
372
|
+
}], [{
|
|
373
|
+
key: "debug",
|
|
374
|
+
value: function debug(name, alt, win) {
|
|
375
|
+
var key = 'alt.js.org';
|
|
376
|
+
var context = win;
|
|
377
|
+
|
|
378
|
+
if (!context && typeof window !== 'undefined') {
|
|
379
|
+
context = window;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (typeof context !== 'undefined') {
|
|
383
|
+
context[key] = context[key] || [];
|
|
384
|
+
context[key].push({
|
|
385
|
+
name: name,
|
|
386
|
+
alt: alt
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return alt;
|
|
391
|
+
}
|
|
392
|
+
}]);
|
|
393
|
+
return Alt;
|
|
394
|
+
}();
|
|
395
|
+
|
|
396
|
+
var _default = Alt;
|
|
397
|
+
exports["default"] = _default;
|
|
398
|
+
|
|
399
|
+
/***/ }),
|
|
400
|
+
/* 2 */
|
|
401
|
+
/***/ (function(module, exports) {
|
|
402
|
+
|
|
403
|
+
function _interopRequireDefault(obj) {
|
|
404
|
+
return obj && obj.__esModule ? obj : {
|
|
405
|
+
"default": obj
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
410
|
+
|
|
411
|
+
/***/ }),
|
|
412
|
+
/* 3 */
|
|
413
|
+
/***/ (function(module, exports) {
|
|
414
|
+
|
|
415
|
+
function _typeof(obj) {
|
|
416
|
+
"@babel/helpers - typeof";
|
|
417
|
+
|
|
418
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
419
|
+
return typeof obj;
|
|
420
|
+
} : function (obj) {
|
|
421
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
422
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
426
|
+
|
|
427
|
+
/***/ }),
|
|
428
|
+
/* 4 */
|
|
429
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
430
|
+
|
|
431
|
+
var setPrototypeOf = __webpack_require__(5);
|
|
432
|
+
|
|
433
|
+
var isNativeReflectConstruct = __webpack_require__(6);
|
|
434
|
+
|
|
435
|
+
function _construct(Parent, args, Class) {
|
|
436
|
+
if (isNativeReflectConstruct()) {
|
|
437
|
+
module.exports = _construct = Reflect.construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
438
|
+
} else {
|
|
439
|
+
module.exports = _construct = function _construct(Parent, args, Class) {
|
|
440
|
+
var a = [null];
|
|
441
|
+
a.push.apply(a, args);
|
|
442
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
443
|
+
var instance = new Constructor();
|
|
444
|
+
if (Class) setPrototypeOf(instance, Class.prototype);
|
|
445
|
+
return instance;
|
|
446
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return _construct.apply(null, arguments);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
453
|
+
|
|
454
|
+
/***/ }),
|
|
455
|
+
/* 5 */
|
|
456
|
+
/***/ (function(module, exports) {
|
|
457
|
+
|
|
458
|
+
function _setPrototypeOf(o, p) {
|
|
459
|
+
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
460
|
+
o.__proto__ = p;
|
|
461
|
+
return o;
|
|
462
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
463
|
+
return _setPrototypeOf(o, p);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
467
|
+
|
|
468
|
+
/***/ }),
|
|
469
|
+
/* 6 */
|
|
470
|
+
/***/ (function(module, exports) {
|
|
471
|
+
|
|
472
|
+
function _isNativeReflectConstruct() {
|
|
473
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
474
|
+
if (Reflect.construct.sham) return false;
|
|
475
|
+
if (typeof Proxy === "function") return true;
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
479
|
+
return true;
|
|
480
|
+
} catch (e) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
486
|
+
|
|
487
|
+
/***/ }),
|
|
488
|
+
/* 7 */
|
|
489
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
490
|
+
|
|
491
|
+
var setPrototypeOf = __webpack_require__(5);
|
|
492
|
+
|
|
493
|
+
function _inherits(subClass, superClass) {
|
|
494
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
495
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
499
|
+
constructor: {
|
|
500
|
+
value: subClass,
|
|
501
|
+
writable: true,
|
|
502
|
+
configurable: true
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
Object.defineProperty(subClass, "prototype", {
|
|
506
|
+
writable: false
|
|
507
|
+
});
|
|
508
|
+
if (superClass) setPrototypeOf(subClass, superClass);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
512
|
+
|
|
513
|
+
/***/ }),
|
|
514
|
+
/* 8 */
|
|
515
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
516
|
+
|
|
517
|
+
var _typeof = __webpack_require__(3)["default"];
|
|
518
|
+
|
|
519
|
+
var assertThisInitialized = __webpack_require__(9);
|
|
520
|
+
|
|
521
|
+
function _possibleConstructorReturn(self, call) {
|
|
522
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
523
|
+
return call;
|
|
524
|
+
} else if (call !== void 0) {
|
|
525
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return assertThisInitialized(self);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
532
|
+
|
|
533
|
+
/***/ }),
|
|
534
|
+
/* 9 */
|
|
535
|
+
/***/ (function(module, exports) {
|
|
536
|
+
|
|
537
|
+
function _assertThisInitialized(self) {
|
|
538
|
+
if (self === void 0) {
|
|
539
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return self;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
546
|
+
|
|
547
|
+
/***/ }),
|
|
548
|
+
/* 10 */
|
|
549
|
+
/***/ (function(module, exports) {
|
|
550
|
+
|
|
551
|
+
function _getPrototypeOf(o) {
|
|
552
|
+
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
553
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
554
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
555
|
+
return _getPrototypeOf(o);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
559
|
+
|
|
560
|
+
/***/ }),
|
|
561
|
+
/* 11 */
|
|
562
|
+
/***/ (function(module, exports) {
|
|
563
|
+
|
|
564
|
+
function _classCallCheck(instance, Constructor) {
|
|
565
|
+
if (!(instance instanceof Constructor)) {
|
|
566
|
+
throw new TypeError("Cannot call a class as a function");
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
571
|
+
|
|
572
|
+
/***/ }),
|
|
573
|
+
/* 12 */
|
|
574
|
+
/***/ (function(module, exports) {
|
|
575
|
+
|
|
576
|
+
function _defineProperties(target, props) {
|
|
577
|
+
for (var i = 0; i < props.length; i++) {
|
|
578
|
+
var descriptor = props[i];
|
|
579
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
580
|
+
descriptor.configurable = true;
|
|
581
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
582
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
587
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
588
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
589
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
590
|
+
writable: false
|
|
591
|
+
});
|
|
592
|
+
return Constructor;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
596
|
+
|
|
597
|
+
/***/ }),
|
|
598
|
+
/* 13 */
|
|
599
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Copyright (c) 2014-2015, Facebook, Inc.
|
|
603
|
+
* All rights reserved.
|
|
604
|
+
*
|
|
605
|
+
* This source code is licensed under the BSD-style license found in the
|
|
606
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
607
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
module.exports.Dispatcher = __webpack_require__(14);
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
/***/ }),
|
|
614
|
+
/* 14 */
|
|
615
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
616
|
+
|
|
617
|
+
/* WEBPACK VAR INJECTION */(function(process) {/**
|
|
618
|
+
* Copyright (c) 2014-2015, Facebook, Inc.
|
|
619
|
+
* All rights reserved.
|
|
620
|
+
*
|
|
621
|
+
* This source code is licensed under the BSD-style license found in the
|
|
622
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
623
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
624
|
+
*
|
|
625
|
+
* @providesModule Dispatcher
|
|
626
|
+
*
|
|
627
|
+
* @preventMunge
|
|
628
|
+
*/
|
|
629
|
+
|
|
630
|
+
'use strict';
|
|
631
|
+
|
|
632
|
+
exports.__esModule = true;
|
|
633
|
+
|
|
634
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
|
635
|
+
|
|
636
|
+
var invariant = __webpack_require__(16);
|
|
637
|
+
|
|
638
|
+
var _prefix = 'ID_';
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Dispatcher is used to broadcast payloads to registered callbacks. This is
|
|
642
|
+
* different from generic pub-sub systems in two ways:
|
|
643
|
+
*
|
|
644
|
+
* 1) Callbacks are not subscribed to particular events. Every payload is
|
|
645
|
+
* dispatched to every registered callback.
|
|
646
|
+
* 2) Callbacks can be deferred in whole or part until other callbacks have
|
|
647
|
+
* been executed.
|
|
648
|
+
*
|
|
649
|
+
* For example, consider this hypothetical flight destination form, which
|
|
650
|
+
* selects a default city when a country is selected:
|
|
651
|
+
*
|
|
652
|
+
* var flightDispatcher = new Dispatcher();
|
|
653
|
+
*
|
|
654
|
+
* // Keeps track of which country is selected
|
|
655
|
+
* var CountryStore = {country: null};
|
|
656
|
+
*
|
|
657
|
+
* // Keeps track of which city is selected
|
|
658
|
+
* var CityStore = {city: null};
|
|
659
|
+
*
|
|
660
|
+
* // Keeps track of the base flight price of the selected city
|
|
661
|
+
* var FlightPriceStore = {price: null}
|
|
662
|
+
*
|
|
663
|
+
* When a user changes the selected city, we dispatch the payload:
|
|
664
|
+
*
|
|
665
|
+
* flightDispatcher.dispatch({
|
|
666
|
+
* actionType: 'city-update',
|
|
667
|
+
* selectedCity: 'paris'
|
|
668
|
+
* });
|
|
669
|
+
*
|
|
670
|
+
* This payload is digested by `CityStore`:
|
|
671
|
+
*
|
|
672
|
+
* flightDispatcher.register(function(payload) {
|
|
673
|
+
* if (payload.actionType === 'city-update') {
|
|
674
|
+
* CityStore.city = payload.selectedCity;
|
|
675
|
+
* }
|
|
676
|
+
* });
|
|
677
|
+
*
|
|
678
|
+
* When the user selects a country, we dispatch the payload:
|
|
679
|
+
*
|
|
680
|
+
* flightDispatcher.dispatch({
|
|
681
|
+
* actionType: 'country-update',
|
|
682
|
+
* selectedCountry: 'australia'
|
|
683
|
+
* });
|
|
684
|
+
*
|
|
685
|
+
* This payload is digested by both stores:
|
|
686
|
+
*
|
|
687
|
+
* CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
|
|
688
|
+
* if (payload.actionType === 'country-update') {
|
|
689
|
+
* CountryStore.country = payload.selectedCountry;
|
|
690
|
+
* }
|
|
691
|
+
* });
|
|
692
|
+
*
|
|
693
|
+
* When the callback to update `CountryStore` is registered, we save a reference
|
|
694
|
+
* to the returned token. Using this token with `waitFor()`, we can guarantee
|
|
695
|
+
* that `CountryStore` is updated before the callback that updates `CityStore`
|
|
696
|
+
* needs to query its data.
|
|
697
|
+
*
|
|
698
|
+
* CityStore.dispatchToken = flightDispatcher.register(function(payload) {
|
|
699
|
+
* if (payload.actionType === 'country-update') {
|
|
700
|
+
* // `CountryStore.country` may not be updated.
|
|
701
|
+
* flightDispatcher.waitFor([CountryStore.dispatchToken]);
|
|
702
|
+
* // `CountryStore.country` is now guaranteed to be updated.
|
|
703
|
+
*
|
|
704
|
+
* // Select the default city for the new country
|
|
705
|
+
* CityStore.city = getDefaultCityForCountry(CountryStore.country);
|
|
706
|
+
* }
|
|
707
|
+
* });
|
|
708
|
+
*
|
|
709
|
+
* The usage of `waitFor()` can be chained, for example:
|
|
710
|
+
*
|
|
711
|
+
* FlightPriceStore.dispatchToken =
|
|
712
|
+
* flightDispatcher.register(function(payload) {
|
|
713
|
+
* switch (payload.actionType) {
|
|
714
|
+
* case 'country-update':
|
|
715
|
+
* case 'city-update':
|
|
716
|
+
* flightDispatcher.waitFor([CityStore.dispatchToken]);
|
|
717
|
+
* FlightPriceStore.price =
|
|
718
|
+
* getFlightPriceStore(CountryStore.country, CityStore.city);
|
|
719
|
+
* break;
|
|
720
|
+
* }
|
|
721
|
+
* });
|
|
722
|
+
*
|
|
723
|
+
* The `country-update` payload will be guaranteed to invoke the stores'
|
|
724
|
+
* registered callbacks in order: `CountryStore`, `CityStore`, then
|
|
725
|
+
* `FlightPriceStore`.
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
var Dispatcher = (function () {
|
|
729
|
+
function Dispatcher() {
|
|
730
|
+
_classCallCheck(this, Dispatcher);
|
|
731
|
+
|
|
732
|
+
this._callbacks = {};
|
|
733
|
+
this._isDispatching = false;
|
|
734
|
+
this._isHandled = {};
|
|
735
|
+
this._isPending = {};
|
|
736
|
+
this._lastID = 1;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Registers a callback to be invoked with every dispatched payload. Returns
|
|
741
|
+
* a token that can be used with `waitFor()`.
|
|
742
|
+
*/
|
|
743
|
+
|
|
744
|
+
Dispatcher.prototype.register = function register(callback) {
|
|
745
|
+
var id = _prefix + this._lastID++;
|
|
746
|
+
this._callbacks[id] = callback;
|
|
747
|
+
return id;
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Removes a callback based on its token.
|
|
752
|
+
*/
|
|
753
|
+
|
|
754
|
+
Dispatcher.prototype.unregister = function unregister(id) {
|
|
755
|
+
!this._callbacks[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.unregister(...): `%s` does not map to a registered callback.', id) : invariant(false) : undefined;
|
|
756
|
+
delete this._callbacks[id];
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Waits for the callbacks specified to be invoked before continuing execution
|
|
761
|
+
* of the current callback. This method should only be used by a callback in
|
|
762
|
+
* response to a dispatched payload.
|
|
763
|
+
*/
|
|
764
|
+
|
|
765
|
+
Dispatcher.prototype.waitFor = function waitFor(ids) {
|
|
766
|
+
!this._isDispatching ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): Must be invoked while dispatching.') : invariant(false) : undefined;
|
|
767
|
+
for (var ii = 0; ii < ids.length; ii++) {
|
|
768
|
+
var id = ids[ii];
|
|
769
|
+
if (this._isPending[id]) {
|
|
770
|
+
!this._isHandled[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): Circular dependency detected while ' + 'waiting for `%s`.', id) : invariant(false) : undefined;
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
!this._callbacks[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', id) : invariant(false) : undefined;
|
|
774
|
+
this._invokeCallback(id);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Dispatches a payload to all registered callbacks.
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
Dispatcher.prototype.dispatch = function dispatch(payload) {
|
|
783
|
+
!!this._isDispatching ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.') : invariant(false) : undefined;
|
|
784
|
+
this._startDispatching(payload);
|
|
785
|
+
try {
|
|
786
|
+
for (var id in this._callbacks) {
|
|
787
|
+
if (this._isPending[id]) {
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
this._invokeCallback(id);
|
|
791
|
+
}
|
|
792
|
+
} finally {
|
|
793
|
+
this._stopDispatching();
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Is this Dispatcher currently dispatching.
|
|
799
|
+
*/
|
|
800
|
+
|
|
801
|
+
Dispatcher.prototype.isDispatching = function isDispatching() {
|
|
802
|
+
return this._isDispatching;
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Call the callback stored with the given id. Also do some internal
|
|
807
|
+
* bookkeeping.
|
|
808
|
+
*
|
|
809
|
+
* @internal
|
|
810
|
+
*/
|
|
811
|
+
|
|
812
|
+
Dispatcher.prototype._invokeCallback = function _invokeCallback(id) {
|
|
813
|
+
this._isPending[id] = true;
|
|
814
|
+
this._callbacks[id](this._pendingPayload);
|
|
815
|
+
this._isHandled[id] = true;
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Set up bookkeeping needed when dispatching.
|
|
820
|
+
*
|
|
821
|
+
* @internal
|
|
822
|
+
*/
|
|
823
|
+
|
|
824
|
+
Dispatcher.prototype._startDispatching = function _startDispatching(payload) {
|
|
825
|
+
for (var id in this._callbacks) {
|
|
826
|
+
this._isPending[id] = false;
|
|
827
|
+
this._isHandled[id] = false;
|
|
828
|
+
}
|
|
829
|
+
this._pendingPayload = payload;
|
|
830
|
+
this._isDispatching = true;
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Clear bookkeeping used for dispatching.
|
|
835
|
+
*
|
|
836
|
+
* @internal
|
|
837
|
+
*/
|
|
838
|
+
|
|
839
|
+
Dispatcher.prototype._stopDispatching = function _stopDispatching() {
|
|
840
|
+
delete this._pendingPayload;
|
|
841
|
+
this._isDispatching = false;
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
return Dispatcher;
|
|
845
|
+
})();
|
|
846
|
+
|
|
847
|
+
module.exports = Dispatcher;
|
|
848
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15)))
|
|
849
|
+
|
|
850
|
+
/***/ }),
|
|
851
|
+
/* 15 */
|
|
852
|
+
/***/ (function(module, exports) {
|
|
853
|
+
|
|
854
|
+
// shim for using process in browser
|
|
855
|
+
var process = module.exports = {};
|
|
856
|
+
|
|
857
|
+
// cached from whatever global is present so that test runners that stub it
|
|
858
|
+
// don't break things. But we need to wrap it in a try catch in case it is
|
|
859
|
+
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
860
|
+
// function because try/catches deoptimize in certain engines.
|
|
861
|
+
|
|
862
|
+
var cachedSetTimeout;
|
|
863
|
+
var cachedClearTimeout;
|
|
864
|
+
|
|
865
|
+
function defaultSetTimout() {
|
|
866
|
+
throw new Error('setTimeout has not been defined');
|
|
867
|
+
}
|
|
868
|
+
function defaultClearTimeout () {
|
|
869
|
+
throw new Error('clearTimeout has not been defined');
|
|
870
|
+
}
|
|
871
|
+
(function () {
|
|
872
|
+
try {
|
|
873
|
+
if (typeof setTimeout === 'function') {
|
|
874
|
+
cachedSetTimeout = setTimeout;
|
|
875
|
+
} else {
|
|
876
|
+
cachedSetTimeout = defaultSetTimout;
|
|
877
|
+
}
|
|
878
|
+
} catch (e) {
|
|
879
|
+
cachedSetTimeout = defaultSetTimout;
|
|
880
|
+
}
|
|
881
|
+
try {
|
|
882
|
+
if (typeof clearTimeout === 'function') {
|
|
883
|
+
cachedClearTimeout = clearTimeout;
|
|
884
|
+
} else {
|
|
885
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
886
|
+
}
|
|
887
|
+
} catch (e) {
|
|
888
|
+
cachedClearTimeout = defaultClearTimeout;
|
|
889
|
+
}
|
|
890
|
+
} ())
|
|
891
|
+
function runTimeout(fun) {
|
|
892
|
+
if (cachedSetTimeout === setTimeout) {
|
|
893
|
+
//normal enviroments in sane situations
|
|
894
|
+
return setTimeout(fun, 0);
|
|
895
|
+
}
|
|
896
|
+
// if setTimeout wasn't available but was latter defined
|
|
897
|
+
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
898
|
+
cachedSetTimeout = setTimeout;
|
|
899
|
+
return setTimeout(fun, 0);
|
|
900
|
+
}
|
|
901
|
+
try {
|
|
902
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
903
|
+
return cachedSetTimeout(fun, 0);
|
|
904
|
+
} catch(e){
|
|
905
|
+
try {
|
|
906
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
907
|
+
return cachedSetTimeout.call(null, fun, 0);
|
|
908
|
+
} catch(e){
|
|
909
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
910
|
+
return cachedSetTimeout.call(this, fun, 0);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
}
|
|
916
|
+
function runClearTimeout(marker) {
|
|
917
|
+
if (cachedClearTimeout === clearTimeout) {
|
|
918
|
+
//normal enviroments in sane situations
|
|
919
|
+
return clearTimeout(marker);
|
|
920
|
+
}
|
|
921
|
+
// if clearTimeout wasn't available but was latter defined
|
|
922
|
+
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
923
|
+
cachedClearTimeout = clearTimeout;
|
|
924
|
+
return clearTimeout(marker);
|
|
925
|
+
}
|
|
926
|
+
try {
|
|
927
|
+
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
928
|
+
return cachedClearTimeout(marker);
|
|
929
|
+
} catch (e){
|
|
930
|
+
try {
|
|
931
|
+
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
932
|
+
return cachedClearTimeout.call(null, marker);
|
|
933
|
+
} catch (e){
|
|
934
|
+
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
935
|
+
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
936
|
+
return cachedClearTimeout.call(this, marker);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
}
|
|
943
|
+
var queue = [];
|
|
944
|
+
var draining = false;
|
|
945
|
+
var currentQueue;
|
|
946
|
+
var queueIndex = -1;
|
|
947
|
+
|
|
948
|
+
function cleanUpNextTick() {
|
|
949
|
+
if (!draining || !currentQueue) {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
draining = false;
|
|
953
|
+
if (currentQueue.length) {
|
|
954
|
+
queue = currentQueue.concat(queue);
|
|
955
|
+
} else {
|
|
956
|
+
queueIndex = -1;
|
|
957
|
+
}
|
|
958
|
+
if (queue.length) {
|
|
959
|
+
drainQueue();
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function drainQueue() {
|
|
964
|
+
if (draining) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
var timeout = runTimeout(cleanUpNextTick);
|
|
968
|
+
draining = true;
|
|
969
|
+
|
|
970
|
+
var len = queue.length;
|
|
971
|
+
while(len) {
|
|
972
|
+
currentQueue = queue;
|
|
973
|
+
queue = [];
|
|
974
|
+
while (++queueIndex < len) {
|
|
975
|
+
if (currentQueue) {
|
|
976
|
+
currentQueue[queueIndex].run();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
queueIndex = -1;
|
|
980
|
+
len = queue.length;
|
|
981
|
+
}
|
|
982
|
+
currentQueue = null;
|
|
983
|
+
draining = false;
|
|
984
|
+
runClearTimeout(timeout);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
process.nextTick = function (fun) {
|
|
988
|
+
var args = new Array(arguments.length - 1);
|
|
989
|
+
if (arguments.length > 1) {
|
|
990
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
991
|
+
args[i - 1] = arguments[i];
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
queue.push(new Item(fun, args));
|
|
995
|
+
if (queue.length === 1 && !draining) {
|
|
996
|
+
runTimeout(drainQueue);
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
// v8 likes predictible objects
|
|
1001
|
+
function Item(fun, array) {
|
|
1002
|
+
this.fun = fun;
|
|
1003
|
+
this.array = array;
|
|
1004
|
+
}
|
|
1005
|
+
Item.prototype.run = function () {
|
|
1006
|
+
this.fun.apply(null, this.array);
|
|
1007
|
+
};
|
|
1008
|
+
process.title = 'browser';
|
|
1009
|
+
process.browser = true;
|
|
1010
|
+
process.env = {};
|
|
1011
|
+
process.argv = [];
|
|
1012
|
+
process.version = ''; // empty string to avoid regexp issues
|
|
1013
|
+
process.versions = {};
|
|
1014
|
+
|
|
1015
|
+
function noop() {}
|
|
1016
|
+
|
|
1017
|
+
process.on = noop;
|
|
1018
|
+
process.addListener = noop;
|
|
1019
|
+
process.once = noop;
|
|
1020
|
+
process.off = noop;
|
|
1021
|
+
process.removeListener = noop;
|
|
1022
|
+
process.removeAllListeners = noop;
|
|
1023
|
+
process.emit = noop;
|
|
1024
|
+
process.prependListener = noop;
|
|
1025
|
+
process.prependOnceListener = noop;
|
|
1026
|
+
|
|
1027
|
+
process.listeners = function (name) { return [] }
|
|
1028
|
+
|
|
1029
|
+
process.binding = function (name) {
|
|
1030
|
+
throw new Error('process.binding is not supported');
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
process.cwd = function () { return '/' };
|
|
1034
|
+
process.chdir = function (dir) {
|
|
1035
|
+
throw new Error('process.chdir is not supported');
|
|
1036
|
+
};
|
|
1037
|
+
process.umask = function() { return 0; };
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
/***/ }),
|
|
1041
|
+
/* 16 */
|
|
1042
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1043
|
+
|
|
1044
|
+
/* WEBPACK VAR INJECTION */(function(process) {/**
|
|
1045
|
+
* Copyright 2013-2015, Facebook, Inc.
|
|
1046
|
+
* All rights reserved.
|
|
1047
|
+
*
|
|
1048
|
+
* This source code is licensed under the BSD-style license found in the
|
|
1049
|
+
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1050
|
+
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1051
|
+
*
|
|
1052
|
+
* @providesModule invariant
|
|
1053
|
+
*/
|
|
1054
|
+
|
|
1055
|
+
"use strict";
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Use invariant() to assert state which your program assumes to be true.
|
|
1059
|
+
*
|
|
1060
|
+
* Provide sprintf-style format (only %s is supported) and arguments
|
|
1061
|
+
* to provide information about what broke and what you were
|
|
1062
|
+
* expecting.
|
|
1063
|
+
*
|
|
1064
|
+
* The invariant message will be stripped in production, but the invariant
|
|
1065
|
+
* will remain to ensure logic does not differ in production.
|
|
1066
|
+
*/
|
|
1067
|
+
|
|
1068
|
+
var invariant = function (condition, format, a, b, c, d, e, f) {
|
|
1069
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1070
|
+
if (format === undefined) {
|
|
1071
|
+
throw new Error('invariant requires an error message argument');
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
if (!condition) {
|
|
1076
|
+
var error;
|
|
1077
|
+
if (format === undefined) {
|
|
1078
|
+
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
1079
|
+
} else {
|
|
1080
|
+
var args = [a, b, c, d, e, f];
|
|
1081
|
+
var argIndex = 0;
|
|
1082
|
+
error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () {
|
|
1083
|
+
return args[argIndex++];
|
|
1084
|
+
}));
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
error.framesToPop = 1; // we don't care about invariant's own frame
|
|
1088
|
+
throw error;
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
module.exports = invariant;
|
|
1093
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(15)))
|
|
1094
|
+
|
|
1095
|
+
/***/ }),
|
|
1096
|
+
/* 17 */
|
|
1097
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1098
|
+
|
|
1099
|
+
"use strict";
|
|
1100
|
+
|
|
1101
|
+
var _typeof = __webpack_require__(3);
|
|
1102
|
+
|
|
1103
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1104
|
+
value: true
|
|
1105
|
+
});
|
|
1106
|
+
exports.filterSnapshots = filterSnapshots;
|
|
1107
|
+
exports.saveInitialSnapshot = saveInitialSnapshot;
|
|
1108
|
+
exports.setAppState = setAppState;
|
|
1109
|
+
exports.snapshot = snapshot;
|
|
1110
|
+
|
|
1111
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
1112
|
+
|
|
1113
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1114
|
+
|
|
1115
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1116
|
+
|
|
1117
|
+
function setAppState(instance, data, onStore) {
|
|
1118
|
+
var obj = instance.deserialize(data);
|
|
1119
|
+
fn.eachObject(function (key, value) {
|
|
1120
|
+
var store = instance.stores[key];
|
|
1121
|
+
|
|
1122
|
+
if (store) {
|
|
1123
|
+
var config = store.StoreModel.config;
|
|
1124
|
+
var state = store.state;
|
|
1125
|
+
if (config.onDeserialize) obj[key] = config.onDeserialize(value) || value;
|
|
1126
|
+
|
|
1127
|
+
if (fn.isMutableObject(state)) {
|
|
1128
|
+
fn.eachObject(function (k) {
|
|
1129
|
+
return delete state[k];
|
|
1130
|
+
}, [state]);
|
|
1131
|
+
fn.assign(state, obj[key]);
|
|
1132
|
+
} else {
|
|
1133
|
+
store.state = obj[key];
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
onStore(store, store.state);
|
|
1137
|
+
}
|
|
1138
|
+
}, [obj]);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
function snapshot(instance) {
|
|
1142
|
+
var storeNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1143
|
+
var stores = storeNames.length ? storeNames : Object.keys(instance.stores);
|
|
1144
|
+
return stores.reduce(function (obj, storeHandle) {
|
|
1145
|
+
var storeName = storeHandle.displayName || storeHandle;
|
|
1146
|
+
var store = instance.stores[storeName];
|
|
1147
|
+
var config = store.StoreModel.config;
|
|
1148
|
+
store.lifecycle('snapshot');
|
|
1149
|
+
var customSnapshot = config.onSerialize && config.onSerialize(store.state);
|
|
1150
|
+
obj[storeName] = customSnapshot ? customSnapshot : store.getState();
|
|
1151
|
+
return obj;
|
|
1152
|
+
}, {});
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function saveInitialSnapshot(instance, key) {
|
|
1156
|
+
var state = instance.deserialize(instance.serialize(instance.stores[key].state));
|
|
1157
|
+
instance._initSnapshot[key] = state;
|
|
1158
|
+
instance._lastSnapshot[key] = state;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
function filterSnapshots(instance, state, stores) {
|
|
1162
|
+
return stores.reduce(function (obj, store) {
|
|
1163
|
+
var storeName = store.displayName || store;
|
|
1164
|
+
|
|
1165
|
+
if (!state[storeName]) {
|
|
1166
|
+
throw new ReferenceError("".concat(storeName, " is not a valid store"));
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
obj[storeName] = state[storeName];
|
|
1170
|
+
return obj;
|
|
1171
|
+
}, {});
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/***/ }),
|
|
1175
|
+
/* 18 */
|
|
1176
|
+
/***/ (function(module, exports) {
|
|
1177
|
+
|
|
1178
|
+
"use strict";
|
|
1179
|
+
|
|
1180
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1181
|
+
value: true
|
|
1182
|
+
});
|
|
1183
|
+
exports.assign = assign;
|
|
1184
|
+
exports.eachObject = eachObject;
|
|
1185
|
+
exports.isFunction = void 0;
|
|
1186
|
+
exports.isMutableObject = isMutableObject;
|
|
1187
|
+
|
|
1188
|
+
var isFunction = function isFunction(x) {
|
|
1189
|
+
return typeof x === 'function';
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
exports.isFunction = isFunction;
|
|
1193
|
+
|
|
1194
|
+
function isMutableObject(target) {
|
|
1195
|
+
var Ctor = target.constructor;
|
|
1196
|
+
return !!target && Object.prototype.toString.call(target) === '[object Object]' && isFunction(Ctor) && !Object.isFrozen(target) && (Ctor instanceof Ctor || target.type === 'AltStore');
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function eachObject(f, o) {
|
|
1200
|
+
o.forEach(function (from) {
|
|
1201
|
+
Object.keys(Object(from)).forEach(function (key) {
|
|
1202
|
+
f(key, from[key]);
|
|
1203
|
+
});
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
function assign(target) {
|
|
1208
|
+
for (var _len = arguments.length, source = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1209
|
+
source[_key - 1] = arguments[_key];
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
eachObject(function (key, value) {
|
|
1213
|
+
return target[key] = value;
|
|
1214
|
+
}, source);
|
|
1215
|
+
return target;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/***/ }),
|
|
1219
|
+
/* 19 */
|
|
1220
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1221
|
+
|
|
1222
|
+
"use strict";
|
|
1223
|
+
|
|
1224
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
1225
|
+
|
|
1226
|
+
var _typeof = __webpack_require__(3);
|
|
1227
|
+
|
|
1228
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1229
|
+
value: true
|
|
1230
|
+
});
|
|
1231
|
+
exports.createStoreConfig = createStoreConfig;
|
|
1232
|
+
exports.createStoreFromClass = createStoreFromClass;
|
|
1233
|
+
exports.createStoreFromObject = createStoreFromObject;
|
|
1234
|
+
exports.transformStore = transformStore;
|
|
1235
|
+
|
|
1236
|
+
var _construct2 = _interopRequireDefault(__webpack_require__(4));
|
|
1237
|
+
|
|
1238
|
+
var _createClass2 = _interopRequireDefault(__webpack_require__(12));
|
|
1239
|
+
|
|
1240
|
+
var _classCallCheck2 = _interopRequireDefault(__webpack_require__(11));
|
|
1241
|
+
|
|
1242
|
+
var _inherits2 = _interopRequireDefault(__webpack_require__(7));
|
|
1243
|
+
|
|
1244
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(__webpack_require__(8));
|
|
1245
|
+
|
|
1246
|
+
var _getPrototypeOf2 = _interopRequireDefault(__webpack_require__(10));
|
|
1247
|
+
|
|
1248
|
+
var utils = _interopRequireWildcard(__webpack_require__(20));
|
|
1249
|
+
|
|
1250
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
1251
|
+
|
|
1252
|
+
var _AltStore = _interopRequireDefault(__webpack_require__(22));
|
|
1253
|
+
|
|
1254
|
+
var _StoreMixin = _interopRequireDefault(__webpack_require__(24));
|
|
1255
|
+
|
|
1256
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1257
|
+
|
|
1258
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1259
|
+
|
|
1260
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
1261
|
+
|
|
1262
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1263
|
+
|
|
1264
|
+
function doSetState(store, storeInstance, state) {
|
|
1265
|
+
if (!state) {
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
var config = storeInstance.StoreModel.config;
|
|
1270
|
+
var nextState = fn.isFunction(state) ? state(storeInstance.state) : state;
|
|
1271
|
+
storeInstance.state = config.setState.call(store, storeInstance.state, nextState);
|
|
1272
|
+
|
|
1273
|
+
if (!store.alt.dispatcher.isDispatching()) {
|
|
1274
|
+
store.emitChange();
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
function createPrototype(proto, alt, key, extras) {
|
|
1279
|
+
return fn.assign(proto, _StoreMixin["default"], {
|
|
1280
|
+
displayName: key,
|
|
1281
|
+
alt: alt,
|
|
1282
|
+
dispatcher: alt.dispatcher,
|
|
1283
|
+
preventDefault: function preventDefault() {
|
|
1284
|
+
this.getInstance().preventDefault = true;
|
|
1285
|
+
},
|
|
1286
|
+
boundListeners: [],
|
|
1287
|
+
lifecycleEvents: {},
|
|
1288
|
+
actionListeners: {},
|
|
1289
|
+
publicMethods: {},
|
|
1290
|
+
handlesOwnErrors: false
|
|
1291
|
+
}, extras);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
function createStoreConfig(globalConfig, StoreModel) {
|
|
1295
|
+
StoreModel.config = fn.assign({
|
|
1296
|
+
getState: function getState(state) {
|
|
1297
|
+
if (Array.isArray(state)) {
|
|
1298
|
+
return state.slice();
|
|
1299
|
+
} else if (fn.isMutableObject(state)) {
|
|
1300
|
+
return fn.assign({}, state);
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
return state;
|
|
1304
|
+
},
|
|
1305
|
+
setState: function setState(currentState, nextState) {
|
|
1306
|
+
if (fn.isMutableObject(nextState)) {
|
|
1307
|
+
return fn.assign(currentState, nextState);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
return nextState;
|
|
1311
|
+
}
|
|
1312
|
+
}, globalConfig, StoreModel.config);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
function transformStore(transforms, StoreModel) {
|
|
1316
|
+
return transforms.reduce(function (Store, transform) {
|
|
1317
|
+
return transform(Store);
|
|
1318
|
+
}, StoreModel);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
function createStoreFromObject(alt, StoreModel, key) {
|
|
1322
|
+
var storeInstance;
|
|
1323
|
+
var StoreProto = createPrototype({}, alt, key, fn.assign({
|
|
1324
|
+
getInstance: function getInstance() {
|
|
1325
|
+
return storeInstance;
|
|
1326
|
+
},
|
|
1327
|
+
setState: function setState(nextState) {
|
|
1328
|
+
doSetState(this, storeInstance, nextState);
|
|
1329
|
+
}
|
|
1330
|
+
}, StoreModel)); // bind the store listeners
|
|
1331
|
+
|
|
1332
|
+
/* istanbul ignore else */
|
|
1333
|
+
|
|
1334
|
+
if (StoreProto.bindListeners) {
|
|
1335
|
+
_StoreMixin["default"].bindListeners.call(StoreProto, StoreProto.bindListeners);
|
|
1336
|
+
}
|
|
1337
|
+
/* istanbul ignore else */
|
|
1338
|
+
|
|
1339
|
+
|
|
1340
|
+
if (StoreProto.observe) {
|
|
1341
|
+
_StoreMixin["default"].bindListeners.call(StoreProto, StoreProto.observe(alt));
|
|
1342
|
+
} // bind the lifecycle events
|
|
1343
|
+
|
|
1344
|
+
/* istanbul ignore else */
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
if (StoreProto.lifecycle) {
|
|
1348
|
+
fn.eachObject(function (eventName, event) {
|
|
1349
|
+
_StoreMixin["default"].on.call(StoreProto, eventName, event);
|
|
1350
|
+
}, [StoreProto.lifecycle]);
|
|
1351
|
+
} // create the instance and fn.assign the public methods to the instance
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
storeInstance = fn.assign(new _AltStore["default"](alt, StoreProto, StoreProto.state !== undefined ? StoreProto.state : {}, StoreModel), StoreProto.publicMethods, {
|
|
1355
|
+
displayName: key,
|
|
1356
|
+
config: StoreModel.config
|
|
1357
|
+
});
|
|
1358
|
+
return storeInstance;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
function createStoreFromClass(alt, StoreModel, key) {
|
|
1362
|
+
var storeInstance;
|
|
1363
|
+
var config = StoreModel.config; // Creating a class here so we don't overload the provided store's
|
|
1364
|
+
// prototype with the mixin behaviour and I'm extending from StoreModel
|
|
1365
|
+
// so we can inherit any extensions from the provided store.
|
|
1366
|
+
|
|
1367
|
+
var Store = /*#__PURE__*/function (_StoreModel) {
|
|
1368
|
+
(0, _inherits2["default"])(Store, _StoreModel);
|
|
1369
|
+
|
|
1370
|
+
var _super = _createSuper(Store);
|
|
1371
|
+
|
|
1372
|
+
function Store() {
|
|
1373
|
+
(0, _classCallCheck2["default"])(this, Store);
|
|
1374
|
+
|
|
1375
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1376
|
+
args[_key2] = arguments[_key2];
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
return _super.call.apply(_super, [this].concat(args));
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
return (0, _createClass2["default"])(Store);
|
|
1383
|
+
}(StoreModel);
|
|
1384
|
+
|
|
1385
|
+
createPrototype(Store.prototype, alt, key, {
|
|
1386
|
+
type: 'AltStore',
|
|
1387
|
+
getInstance: function getInstance() {
|
|
1388
|
+
return storeInstance;
|
|
1389
|
+
},
|
|
1390
|
+
setState: function setState(nextState) {
|
|
1391
|
+
doSetState(this, storeInstance, nextState);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
|
|
1395
|
+
for (var _len = arguments.length, argsForClass = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
1396
|
+
argsForClass[_key - 3] = arguments[_key];
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
var store = (0, _construct2["default"])(Store, argsForClass);
|
|
1400
|
+
/* istanbul ignore next */
|
|
1401
|
+
|
|
1402
|
+
if (config.bindListeners) store.bindListeners(config.bindListeners);
|
|
1403
|
+
/* istanbul ignore next */
|
|
1404
|
+
|
|
1405
|
+
if (config.datasource) store.registerAsync(config.datasource);
|
|
1406
|
+
storeInstance = fn.assign(new _AltStore["default"](alt, store, store.state !== undefined ? store.state : store, StoreModel), utils.getInternalMethods(StoreModel), config.publicMethods, {
|
|
1407
|
+
displayName: key
|
|
1408
|
+
});
|
|
1409
|
+
return storeInstance;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/***/ }),
|
|
1413
|
+
/* 20 */
|
|
1414
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1415
|
+
|
|
1416
|
+
"use strict";
|
|
1417
|
+
|
|
1418
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
1419
|
+
|
|
1420
|
+
var _typeof = __webpack_require__(3);
|
|
1421
|
+
|
|
1422
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1423
|
+
value: true
|
|
1424
|
+
});
|
|
1425
|
+
exports.dispatch = dispatch;
|
|
1426
|
+
exports.dispatchIdentity = dispatchIdentity;
|
|
1427
|
+
exports.formatAsConstant = formatAsConstant;
|
|
1428
|
+
exports.fsa = fsa;
|
|
1429
|
+
exports.getInternalMethods = getInternalMethods;
|
|
1430
|
+
exports.getPrototypeChain = getPrototypeChain;
|
|
1431
|
+
exports.uid = uid;
|
|
1432
|
+
exports.warn = warn;
|
|
1433
|
+
|
|
1434
|
+
var _defineProperty2 = _interopRequireDefault(__webpack_require__(21));
|
|
1435
|
+
|
|
1436
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
1437
|
+
|
|
1438
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1439
|
+
|
|
1440
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1441
|
+
|
|
1442
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1443
|
+
|
|
1444
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1445
|
+
|
|
1446
|
+
/*eslint-disable*/
|
|
1447
|
+
var builtIns = Object.getOwnPropertyNames(NoopClass);
|
|
1448
|
+
var builtInProto = Object.getOwnPropertyNames(NoopClass.prototype);
|
|
1449
|
+
/*eslint-enable*/
|
|
1450
|
+
|
|
1451
|
+
function getInternalMethods(Obj, isProto) {
|
|
1452
|
+
var excluded = isProto ? builtInProto : builtIns;
|
|
1453
|
+
var obj = isProto ? Obj.prototype : Obj;
|
|
1454
|
+
return Object.getOwnPropertyNames(obj).reduce(function (value, m) {
|
|
1455
|
+
if (excluded.indexOf(m) !== -1) {
|
|
1456
|
+
return value;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
value[m] = obj[m];
|
|
1460
|
+
return value;
|
|
1461
|
+
}, {});
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function getPrototypeChain(Obj) {
|
|
1465
|
+
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1466
|
+
return Obj === Function.prototype ? methods : getPrototypeChain(Object.getPrototypeOf(Obj), fn.assign(getInternalMethods(Obj, true), methods));
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
function warn(msg) {
|
|
1470
|
+
/* istanbul ignore else */
|
|
1471
|
+
|
|
1472
|
+
/*eslint-disable*/
|
|
1473
|
+
if (typeof console !== 'undefined') {
|
|
1474
|
+
console.warn(new ReferenceError(msg));
|
|
1475
|
+
}
|
|
1476
|
+
/*eslint-enable*/
|
|
1477
|
+
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
function uid(container, name) {
|
|
1481
|
+
var count = 0;
|
|
1482
|
+
var key = name;
|
|
1483
|
+
|
|
1484
|
+
while (Object.hasOwnProperty.call(container, key)) {
|
|
1485
|
+
key = name + String(++count);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
return key;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
function formatAsConstant(name) {
|
|
1492
|
+
return name.replace(/[a-z]([A-Z])/g, function (i) {
|
|
1493
|
+
return "".concat(i[0], "_").concat(i[1].toLowerCase());
|
|
1494
|
+
}).toUpperCase();
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
function dispatchIdentity(x) {
|
|
1498
|
+
if (x === undefined) return null;
|
|
1499
|
+
|
|
1500
|
+
for (var _len = arguments.length, a = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1501
|
+
a[_key - 1] = arguments[_key];
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
return a.length ? [x].concat(a) : x;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
function fsa(id, type, payload, details) {
|
|
1508
|
+
return {
|
|
1509
|
+
type: type,
|
|
1510
|
+
payload: payload,
|
|
1511
|
+
meta: _objectSpread({
|
|
1512
|
+
dispatchId: id
|
|
1513
|
+
}, details),
|
|
1514
|
+
id: id,
|
|
1515
|
+
action: type,
|
|
1516
|
+
data: payload,
|
|
1517
|
+
details: details
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
function dispatch(id, actionObj, payload, alt) {
|
|
1522
|
+
var data = actionObj.dispatch(payload);
|
|
1523
|
+
if (data === undefined) return null;
|
|
1524
|
+
var type = actionObj.id;
|
|
1525
|
+
var namespace = type;
|
|
1526
|
+
var name = type;
|
|
1527
|
+
var details = {
|
|
1528
|
+
id: type,
|
|
1529
|
+
namespace: namespace,
|
|
1530
|
+
name: name
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
var dispatchLater = function dispatchLater(x) {
|
|
1534
|
+
return alt.dispatch(type, x, details);
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
if (fn.isFunction(data)) return data(dispatchLater, alt); // XXX standardize this
|
|
1538
|
+
|
|
1539
|
+
return alt.dispatcher.dispatch(fsa(id, type, data, details));
|
|
1540
|
+
}
|
|
1541
|
+
/* istanbul ignore next */
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
function NoopClass() {}
|
|
1545
|
+
|
|
1546
|
+
/***/ }),
|
|
1547
|
+
/* 21 */
|
|
1548
|
+
/***/ (function(module, exports) {
|
|
1549
|
+
|
|
1550
|
+
function _defineProperty(obj, key, value) {
|
|
1551
|
+
if (key in obj) {
|
|
1552
|
+
Object.defineProperty(obj, key, {
|
|
1553
|
+
value: value,
|
|
1554
|
+
enumerable: true,
|
|
1555
|
+
configurable: true,
|
|
1556
|
+
writable: true
|
|
1557
|
+
});
|
|
1558
|
+
} else {
|
|
1559
|
+
obj[key] = value;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
return obj;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
1566
|
+
|
|
1567
|
+
/***/ }),
|
|
1568
|
+
/* 22 */
|
|
1569
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1570
|
+
|
|
1571
|
+
"use strict";
|
|
1572
|
+
|
|
1573
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
1574
|
+
|
|
1575
|
+
var _typeof = __webpack_require__(3);
|
|
1576
|
+
|
|
1577
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1578
|
+
value: true
|
|
1579
|
+
});
|
|
1580
|
+
exports["default"] = void 0;
|
|
1581
|
+
|
|
1582
|
+
var _classCallCheck2 = _interopRequireDefault(__webpack_require__(11));
|
|
1583
|
+
|
|
1584
|
+
var _createClass2 = _interopRequireDefault(__webpack_require__(12));
|
|
1585
|
+
|
|
1586
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
1587
|
+
|
|
1588
|
+
var _transmitter = _interopRequireDefault(__webpack_require__(23));
|
|
1589
|
+
|
|
1590
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1591
|
+
|
|
1592
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1593
|
+
|
|
1594
|
+
var AltStore = /*#__PURE__*/function () {
|
|
1595
|
+
function AltStore(alt, model, state, StoreModel) {
|
|
1596
|
+
var _this = this;
|
|
1597
|
+
|
|
1598
|
+
(0, _classCallCheck2["default"])(this, AltStore);
|
|
1599
|
+
var lifecycleEvents = model.lifecycleEvents;
|
|
1600
|
+
this.transmitter = (0, _transmitter["default"])();
|
|
1601
|
+
|
|
1602
|
+
this.lifecycle = function (event, x) {
|
|
1603
|
+
if (lifecycleEvents[event]) lifecycleEvents[event].publish(x);
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
this.state = state;
|
|
1607
|
+
this.alt = alt;
|
|
1608
|
+
this.preventDefault = false;
|
|
1609
|
+
this.displayName = model.displayName;
|
|
1610
|
+
this.boundListeners = model.boundListeners;
|
|
1611
|
+
this.StoreModel = StoreModel;
|
|
1612
|
+
|
|
1613
|
+
this.reduce = model.reduce || function (x) {
|
|
1614
|
+
return x;
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
this.subscriptions = [];
|
|
1618
|
+
|
|
1619
|
+
var output = model.output || function (x) {
|
|
1620
|
+
return x;
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1623
|
+
this.emitChange = function () {
|
|
1624
|
+
return _this.transmitter.publish(output(_this.state));
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
var handleDispatch = function handleDispatch(f, payload) {
|
|
1628
|
+
try {
|
|
1629
|
+
return f();
|
|
1630
|
+
} catch (e) {
|
|
1631
|
+
if (model.handlesOwnErrors) {
|
|
1632
|
+
_this.lifecycle('error', {
|
|
1633
|
+
error: e,
|
|
1634
|
+
payload: payload,
|
|
1635
|
+
state: _this.state
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
return false;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
throw e;
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
fn.assign(this, model.publicMethods); // Register dispatcher
|
|
1646
|
+
|
|
1647
|
+
this.dispatchToken = alt.dispatcher.register(function (payload) {
|
|
1648
|
+
_this.preventDefault = false;
|
|
1649
|
+
|
|
1650
|
+
_this.lifecycle('beforeEach', {
|
|
1651
|
+
payload: payload,
|
|
1652
|
+
state: _this.state
|
|
1653
|
+
});
|
|
1654
|
+
|
|
1655
|
+
var actionHandlers = model.actionListeners[payload.action];
|
|
1656
|
+
|
|
1657
|
+
if (actionHandlers || model.otherwise) {
|
|
1658
|
+
var result;
|
|
1659
|
+
|
|
1660
|
+
if (actionHandlers) {
|
|
1661
|
+
result = handleDispatch(function () {
|
|
1662
|
+
return actionHandlers.filter(Boolean).every(function (handler) {
|
|
1663
|
+
return handler.call(model, payload.data, payload.action) !== false;
|
|
1664
|
+
});
|
|
1665
|
+
}, payload);
|
|
1666
|
+
} else {
|
|
1667
|
+
result = handleDispatch(function () {
|
|
1668
|
+
return model.otherwise(payload.data, payload.action);
|
|
1669
|
+
}, payload);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
if (result !== false && !_this.preventDefault) _this.emitChange();
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
if (model.reduce) {
|
|
1676
|
+
handleDispatch(function () {
|
|
1677
|
+
var value = model.reduce(_this.state, payload);
|
|
1678
|
+
if (value !== undefined) _this.state = value;
|
|
1679
|
+
}, payload);
|
|
1680
|
+
if (!_this.preventDefault) _this.emitChange();
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
_this.lifecycle('afterEach', {
|
|
1684
|
+
payload: payload,
|
|
1685
|
+
state: _this.state
|
|
1686
|
+
});
|
|
1687
|
+
});
|
|
1688
|
+
this.lifecycle('init');
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
(0, _createClass2["default"])(AltStore, [{
|
|
1692
|
+
key: "listen",
|
|
1693
|
+
value: function listen(cb) {
|
|
1694
|
+
var _this2 = this;
|
|
1695
|
+
|
|
1696
|
+
if (!fn.isFunction(cb)) throw new TypeError('listen expects a function');
|
|
1697
|
+
|
|
1698
|
+
var _this$transmitter$sub = this.transmitter.subscribe(cb),
|
|
1699
|
+
dispose = _this$transmitter$sub.dispose;
|
|
1700
|
+
|
|
1701
|
+
this.subscriptions.push({
|
|
1702
|
+
cb: cb,
|
|
1703
|
+
dispose: dispose
|
|
1704
|
+
});
|
|
1705
|
+
return function () {
|
|
1706
|
+
_this2.lifecycle('unlisten');
|
|
1707
|
+
|
|
1708
|
+
dispose();
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
}, {
|
|
1712
|
+
key: "unlisten",
|
|
1713
|
+
value: function unlisten(cb) {
|
|
1714
|
+
this.lifecycle('unlisten');
|
|
1715
|
+
this.subscriptions.filter(function (subscription) {
|
|
1716
|
+
return subscription.cb === cb;
|
|
1717
|
+
}).forEach(function (subscription) {
|
|
1718
|
+
return subscription.dispose();
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
}, {
|
|
1722
|
+
key: "getState",
|
|
1723
|
+
value: function getState() {
|
|
1724
|
+
return this.StoreModel.config.getState.call(this, this.state);
|
|
1725
|
+
}
|
|
1726
|
+
}]);
|
|
1727
|
+
return AltStore;
|
|
1728
|
+
}();
|
|
1729
|
+
|
|
1730
|
+
var _default = AltStore;
|
|
1731
|
+
exports["default"] = _default;
|
|
1732
|
+
|
|
1733
|
+
/***/ }),
|
|
1734
|
+
/* 23 */
|
|
1735
|
+
/***/ (function(module, exports) {
|
|
1736
|
+
|
|
1737
|
+
"use strict";
|
|
1738
|
+
|
|
1739
|
+
function transmitter() {
|
|
1740
|
+
var subscriptions = [];
|
|
1741
|
+
var nowDispatching = false;
|
|
1742
|
+
var toUnsubscribe = {};
|
|
1743
|
+
|
|
1744
|
+
var unsubscribe = function unsubscribe(onChange) {
|
|
1745
|
+
var id = subscriptions.indexOf(onChange);
|
|
1746
|
+
if (id < 0) return;
|
|
1747
|
+
if (nowDispatching) {
|
|
1748
|
+
toUnsubscribe[id] = onChange;
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
subscriptions.splice(id, 1);
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
var subscribe = function subscribe(onChange) {
|
|
1755
|
+
var id = subscriptions.push(onChange);
|
|
1756
|
+
var dispose = function dispose() {
|
|
1757
|
+
return unsubscribe(onChange);
|
|
1758
|
+
};
|
|
1759
|
+
return { dispose: dispose };
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
var publish = function publish() {
|
|
1763
|
+
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
1764
|
+
args[_key] = arguments[_key];
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
nowDispatching = true;
|
|
1768
|
+
try {
|
|
1769
|
+
subscriptions.forEach(function (subscription, id) {
|
|
1770
|
+
return toUnsubscribe[id] || subscription.apply(undefined, args);
|
|
1771
|
+
});
|
|
1772
|
+
} finally {
|
|
1773
|
+
nowDispatching = false;
|
|
1774
|
+
Object.keys(toUnsubscribe).forEach(function (id) {
|
|
1775
|
+
return unsubscribe(toUnsubscribe[id]);
|
|
1776
|
+
});
|
|
1777
|
+
toUnsubscribe = {};
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
return {
|
|
1782
|
+
publish: publish,
|
|
1783
|
+
subscribe: subscribe,
|
|
1784
|
+
$subscriptions: subscriptions
|
|
1785
|
+
};
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
module.exports = transmitter;
|
|
1789
|
+
|
|
1790
|
+
/***/ }),
|
|
1791
|
+
/* 24 */
|
|
1792
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1793
|
+
|
|
1794
|
+
"use strict";
|
|
1795
|
+
|
|
1796
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
1797
|
+
|
|
1798
|
+
var _typeof = __webpack_require__(3);
|
|
1799
|
+
|
|
1800
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1801
|
+
value: true
|
|
1802
|
+
});
|
|
1803
|
+
exports["default"] = void 0;
|
|
1804
|
+
|
|
1805
|
+
var _transmitter = _interopRequireDefault(__webpack_require__(23));
|
|
1806
|
+
|
|
1807
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
1808
|
+
|
|
1809
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1810
|
+
|
|
1811
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1812
|
+
|
|
1813
|
+
var StoreMixin = {
|
|
1814
|
+
waitFor: function waitFor() {
|
|
1815
|
+
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1816
|
+
sources[_key] = arguments[_key];
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
if (!sources.length) {
|
|
1820
|
+
throw new ReferenceError('Dispatch tokens not provided');
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
var sourcesArray = sources;
|
|
1824
|
+
|
|
1825
|
+
if (sources.length === 1) {
|
|
1826
|
+
sourcesArray = Array.isArray(sources[0]) ? sources[0] : sources;
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
var tokens = sourcesArray.map(function (source) {
|
|
1830
|
+
return source.dispatchToken || source;
|
|
1831
|
+
});
|
|
1832
|
+
this.dispatcher.waitFor(tokens);
|
|
1833
|
+
},
|
|
1834
|
+
exportAsync: function exportAsync(asyncMethods) {
|
|
1835
|
+
this.registerAsync(asyncMethods);
|
|
1836
|
+
},
|
|
1837
|
+
registerAsync: function registerAsync(asyncDef) {
|
|
1838
|
+
var _this = this;
|
|
1839
|
+
|
|
1840
|
+
var loadCounter = 0;
|
|
1841
|
+
var asyncMethods = fn.isFunction(asyncDef) ? asyncDef(this.alt) : asyncDef;
|
|
1842
|
+
var toExport = Object.keys(asyncMethods).reduce(function (publicMethods, methodName) {
|
|
1843
|
+
var desc = asyncMethods[methodName];
|
|
1844
|
+
var spec = fn.isFunction(desc) ? desc(_this) : desc;
|
|
1845
|
+
var validHandlers = ['success', 'error', 'loading'];
|
|
1846
|
+
validHandlers.forEach(function (handler) {
|
|
1847
|
+
if (spec[handler] && !spec[handler].id) {
|
|
1848
|
+
throw new Error("".concat(handler, " handler must be an action function"));
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
|
|
1852
|
+
publicMethods[methodName] = function () {
|
|
1853
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1854
|
+
args[_key2] = arguments[_key2];
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
var state = _this.getInstance().getState();
|
|
1858
|
+
|
|
1859
|
+
var value = spec.local && spec.local.apply(spec, [state].concat(args));
|
|
1860
|
+
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args))
|
|
1861
|
+
/*eslint-disable*/
|
|
1862
|
+
: value == null;
|
|
1863
|
+
/*eslint-enable*/
|
|
1864
|
+
|
|
1865
|
+
var intercept = spec.interceptResponse || function (x) {
|
|
1866
|
+
return x;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
var makeActionHandler = function makeActionHandler(action, isError) {
|
|
1870
|
+
return function (x) {
|
|
1871
|
+
var fire = function fire() {
|
|
1872
|
+
loadCounter -= 1;
|
|
1873
|
+
action(intercept(x, action, args));
|
|
1874
|
+
if (isError) throw x;
|
|
1875
|
+
return x;
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
return _this.alt.trapAsync ? function () {
|
|
1879
|
+
return fire();
|
|
1880
|
+
} : fire();
|
|
1881
|
+
};
|
|
1882
|
+
}; // if we don't have it in cache then fetch it
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
if (shouldFetch) {
|
|
1886
|
+
loadCounter += 1;
|
|
1887
|
+
/* istanbul ignore else */
|
|
1888
|
+
|
|
1889
|
+
if (spec.loading) spec.loading(intercept(null, spec.loading, args));
|
|
1890
|
+
return spec.remote.apply(spec, [state].concat(args)).then(makeActionHandler(spec.success), makeActionHandler(spec.error, 1));
|
|
1891
|
+
} // otherwise emit the change now
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
_this.emitChange();
|
|
1895
|
+
|
|
1896
|
+
return value;
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
return publicMethods;
|
|
1900
|
+
}, {});
|
|
1901
|
+
this.exportPublicMethods(toExport);
|
|
1902
|
+
this.exportPublicMethods({
|
|
1903
|
+
isLoading: function isLoading() {
|
|
1904
|
+
return loadCounter > 0;
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1907
|
+
},
|
|
1908
|
+
exportPublicMethods: function exportPublicMethods(methods) {
|
|
1909
|
+
var _this2 = this;
|
|
1910
|
+
|
|
1911
|
+
fn.eachObject(function (methodName, value) {
|
|
1912
|
+
if (!fn.isFunction(value)) {
|
|
1913
|
+
throw new TypeError('exportPublicMethods expects a function');
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
_this2.publicMethods[methodName] = value;
|
|
1917
|
+
}, [methods]);
|
|
1918
|
+
},
|
|
1919
|
+
emitChange: function emitChange() {
|
|
1920
|
+
this.getInstance().emitChange();
|
|
1921
|
+
},
|
|
1922
|
+
on: function on(lifecycleEvent, handler) {
|
|
1923
|
+
if (lifecycleEvent === 'error') this.handlesOwnErrors = true;
|
|
1924
|
+
var bus = this.lifecycleEvents[lifecycleEvent] || (0, _transmitter["default"])();
|
|
1925
|
+
this.lifecycleEvents[lifecycleEvent] = bus;
|
|
1926
|
+
return bus.subscribe(handler.bind(this));
|
|
1927
|
+
},
|
|
1928
|
+
bindAction: function bindAction(symbol, handler) {
|
|
1929
|
+
if (!symbol) {
|
|
1930
|
+
throw new ReferenceError('Invalid action reference passed in');
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
if (!fn.isFunction(handler)) {
|
|
1934
|
+
throw new TypeError('bindAction expects a function');
|
|
1935
|
+
} // You can pass in the constant or the function itself
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
var key = symbol.id ? symbol.id : symbol;
|
|
1939
|
+
this.actionListeners[key] = this.actionListeners[key] || [];
|
|
1940
|
+
this.actionListeners[key].push(handler.bind(this));
|
|
1941
|
+
this.boundListeners.push(key);
|
|
1942
|
+
},
|
|
1943
|
+
bindActions: function bindActions(actions) {
|
|
1944
|
+
var _this3 = this;
|
|
1945
|
+
|
|
1946
|
+
fn.eachObject(function (action, symbol) {
|
|
1947
|
+
var matchFirstCharacter = /./;
|
|
1948
|
+
var assumedEventHandler = action.replace(matchFirstCharacter, function (x) {
|
|
1949
|
+
return "on".concat(x[0].toUpperCase());
|
|
1950
|
+
});
|
|
1951
|
+
|
|
1952
|
+
if (_this3[action] && _this3[assumedEventHandler]) {
|
|
1953
|
+
// If you have both action and onAction
|
|
1954
|
+
throw new ReferenceError("You have multiple action handlers bound to an action: " + "".concat(action, " and ").concat(assumedEventHandler));
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
var handler = _this3[action] || _this3[assumedEventHandler];
|
|
1958
|
+
|
|
1959
|
+
if (handler) {
|
|
1960
|
+
_this3.bindAction(symbol, handler);
|
|
1961
|
+
}
|
|
1962
|
+
}, [actions]);
|
|
1963
|
+
},
|
|
1964
|
+
bindListeners: function bindListeners(obj) {
|
|
1965
|
+
var _this4 = this;
|
|
1966
|
+
|
|
1967
|
+
fn.eachObject(function (methodName, symbol) {
|
|
1968
|
+
var listener = _this4[methodName];
|
|
1969
|
+
|
|
1970
|
+
if (!listener) {
|
|
1971
|
+
throw new ReferenceError("".concat(methodName, " defined but does not exist in ").concat(_this4.displayName));
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
if (Array.isArray(symbol)) {
|
|
1975
|
+
symbol.forEach(function (action) {
|
|
1976
|
+
_this4.bindAction(action, listener);
|
|
1977
|
+
});
|
|
1978
|
+
} else {
|
|
1979
|
+
_this4.bindAction(symbol, listener);
|
|
1980
|
+
}
|
|
1981
|
+
}, [obj]);
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
var _default = StoreMixin;
|
|
1985
|
+
exports["default"] = _default;
|
|
1986
|
+
|
|
1987
|
+
/***/ }),
|
|
1988
|
+
/* 25 */
|
|
1989
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
1990
|
+
|
|
1991
|
+
"use strict";
|
|
1992
|
+
|
|
1993
|
+
var _interopRequireDefault = __webpack_require__(2);
|
|
1994
|
+
|
|
1995
|
+
var _typeof = __webpack_require__(3);
|
|
1996
|
+
|
|
1997
|
+
Object.defineProperty(exports, "__esModule", {
|
|
1998
|
+
value: true
|
|
1999
|
+
});
|
|
2000
|
+
exports["default"] = makeAction;
|
|
2001
|
+
|
|
2002
|
+
var fn = _interopRequireWildcard(__webpack_require__(18));
|
|
2003
|
+
|
|
2004
|
+
var utils = _interopRequireWildcard(__webpack_require__(20));
|
|
2005
|
+
|
|
2006
|
+
var _isPromise = _interopRequireDefault(__webpack_require__(26));
|
|
2007
|
+
|
|
2008
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2009
|
+
|
|
2010
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2011
|
+
|
|
2012
|
+
function makeAction(alt, namespace, name, implementation, obj) {
|
|
2013
|
+
var id = utils.uid(alt._actionsRegistry, "".concat(namespace, ".").concat(name));
|
|
2014
|
+
alt._actionsRegistry[id] = 1;
|
|
2015
|
+
var data = {
|
|
2016
|
+
id: id,
|
|
2017
|
+
namespace: namespace,
|
|
2018
|
+
name: name
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
var dispatch = function dispatch(payload) {
|
|
2022
|
+
return alt.dispatch(id, payload, data);
|
|
2023
|
+
}; // the action itself
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
var action = function action() {
|
|
2027
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2028
|
+
args[_key] = arguments[_key];
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
var invocationResult = implementation.apply(obj, args);
|
|
2032
|
+
var actionResult = invocationResult; // async functions that return promises should not be dispatched
|
|
2033
|
+
|
|
2034
|
+
if (invocationResult !== undefined && !(0, _isPromise["default"])(invocationResult)) {
|
|
2035
|
+
if (fn.isFunction(invocationResult)) {
|
|
2036
|
+
// inner function result should be returned as an action result
|
|
2037
|
+
actionResult = invocationResult(dispatch, alt);
|
|
2038
|
+
} else {
|
|
2039
|
+
dispatch(invocationResult);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
if (invocationResult === undefined) {
|
|
2044
|
+
utils.warn('An action was called but nothing was dispatched');
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
return actionResult;
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
action.defer = function () {
|
|
2051
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2052
|
+
args[_key2] = arguments[_key2];
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
return setTimeout(function () {
|
|
2056
|
+
return action.apply(null, args);
|
|
2057
|
+
});
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
action.id = id;
|
|
2061
|
+
action.data = data; // ensure each reference is unique in the namespace
|
|
2062
|
+
|
|
2063
|
+
var container = alt.actions[namespace];
|
|
2064
|
+
var namespaceId = utils.uid(container, name);
|
|
2065
|
+
container[namespaceId] = action; // generate a constant
|
|
2066
|
+
|
|
2067
|
+
var constant = utils.formatAsConstant(namespaceId);
|
|
2068
|
+
container[constant] = id;
|
|
2069
|
+
return action;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
/***/ }),
|
|
2073
|
+
/* 26 */
|
|
2074
|
+
/***/ (function(module, exports) {
|
|
2075
|
+
|
|
2076
|
+
module.exports = isPromise;
|
|
2077
|
+
|
|
2078
|
+
function isPromise(obj) {
|
|
2079
|
+
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
|
|
2083
|
+
/***/ })
|
|
2084
|
+
/******/ ])
|
|
2085
|
+
});
|
|
2086
|
+
;
|