@webkrafters/eagleeye 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +150 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +68 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +108 -0
- package/dist/main/index.d.ts +78 -0
- package/dist/main/index.js +1062 -0
- package/dist/model/storage/index.d.ts +20 -0
- package/dist/model/storage/index.js +108 -0
- package/logo.png +0 -0
- package/package.json +104 -0
|
@@ -0,0 +1,1062 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _excluded = ["trail"],
|
|
4
|
+
_excluded2 = ["length"],
|
|
5
|
+
_excluded3 = ["length"],
|
|
6
|
+
_excluded4 = ["length"];
|
|
7
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
10
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
13
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
20
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
23
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
24
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
25
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
27
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
29
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function get() {
|
|
36
|
+
return m[k];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
Object.defineProperty(o, k2, desc);
|
|
41
|
+
} : function (o, m, k, k2) {
|
|
42
|
+
if (k2 === undefined) k2 = k;
|
|
43
|
+
o[k2] = m[k];
|
|
44
|
+
});
|
|
45
|
+
var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
|
|
46
|
+
Object.defineProperty(o, "default", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
value: v
|
|
49
|
+
});
|
|
50
|
+
} : function (o, v) {
|
|
51
|
+
o["default"] = v;
|
|
52
|
+
});
|
|
53
|
+
var __runInitializers = void 0 && (void 0).__runInitializers || function (thisArg, initializers, value) {
|
|
54
|
+
var useValue = arguments.length > 2;
|
|
55
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
56
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
57
|
+
}
|
|
58
|
+
return useValue ? value : void 0;
|
|
59
|
+
};
|
|
60
|
+
var __esDecorate = void 0 && (void 0).__esDecorate || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
61
|
+
function accept(f) {
|
|
62
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
63
|
+
return f;
|
|
64
|
+
}
|
|
65
|
+
var kind = contextIn.kind,
|
|
66
|
+
key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
67
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
68
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
69
|
+
var _,
|
|
70
|
+
done = false;
|
|
71
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
72
|
+
var context = {};
|
|
73
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
74
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
75
|
+
context.addInitializer = function (f) {
|
|
76
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
77
|
+
extraInitializers.push(accept(f || null));
|
|
78
|
+
};
|
|
79
|
+
var result = (0, decorators[i])(kind === "accessor" ? {
|
|
80
|
+
get: descriptor.get,
|
|
81
|
+
set: descriptor.set
|
|
82
|
+
} : descriptor[key], context);
|
|
83
|
+
if (kind === "accessor") {
|
|
84
|
+
if (result === void 0) continue;
|
|
85
|
+
if (result === null || _typeof(result) !== "object") throw new TypeError("Object expected");
|
|
86
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
87
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
88
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
89
|
+
} else if (_ = accept(result)) {
|
|
90
|
+
if (kind === "field") initializers.unshift(_);else descriptor[key] = _;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
94
|
+
done = true;
|
|
95
|
+
};
|
|
96
|
+
var __importStar = void 0 && (void 0).__importStar || function () {
|
|
97
|
+
var _ownKeys = function ownKeys(o) {
|
|
98
|
+
_ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
99
|
+
var ar = [];
|
|
100
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
101
|
+
return ar;
|
|
102
|
+
};
|
|
103
|
+
return _ownKeys(o);
|
|
104
|
+
};
|
|
105
|
+
return function (mod) {
|
|
106
|
+
if (mod && mod.__esModule) return mod;
|
|
107
|
+
var result = {};
|
|
108
|
+
if (mod != null) for (var k = _ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
109
|
+
__setModuleDefault(result, mod);
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
}();
|
|
113
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
114
|
+
return mod && mod.__esModule ? mod : {
|
|
115
|
+
"default": mod
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
Object.defineProperty(exports, "__esModule", {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
121
|
+
exports.EagleEyeContext = exports.Streamer = exports.ACCESS_SYM = exports.deps = void 0;
|
|
122
|
+
exports.createEagleEye = createEagleEye;
|
|
123
|
+
exports.mkReadonly = mkReadonly;
|
|
124
|
+
var lodash_isboolean_1 = __importDefault(require("lodash.isboolean"));
|
|
125
|
+
var lodash_isempty_1 = __importDefault(require("lodash.isempty"));
|
|
126
|
+
var lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
127
|
+
var lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
|
|
128
|
+
var lodash_set_1 = __importDefault(require("lodash.set"));
|
|
129
|
+
var get_property_1 = __importDefault(require("@webkrafters/get-property"));
|
|
130
|
+
var path_dotize_1 = __importDefault(require("@webkrafters/path-dotize"));
|
|
131
|
+
var auto_immutable_1 = __importDefault(require("@webkrafters/auto-immutable"));
|
|
132
|
+
var constants = __importStar(require("../constants"));
|
|
133
|
+
var storage_1 = __importDefault(require("../model/storage"));
|
|
134
|
+
var __1 = require("..");
|
|
135
|
+
var iCount = -1;
|
|
136
|
+
var createStorageKey = function createStorageKey() {
|
|
137
|
+
return "".concat(++iCount, ":").concat(Date.now(), ":").concat(Math.random());
|
|
138
|
+
};
|
|
139
|
+
exports.deps = {
|
|
140
|
+
createStorageKey: createStorageKey
|
|
141
|
+
};
|
|
142
|
+
var defaultPrehooks = Object.freeze({});
|
|
143
|
+
var FULL_STATE_SELECTOR = constants.FULL_STATE_SELECTOR;
|
|
144
|
+
exports.ACCESS_SYM = Symbol('KNOWN_ENTITY_ID');
|
|
145
|
+
var Event = /*#__PURE__*/function () {
|
|
146
|
+
function Event() {
|
|
147
|
+
_classCallCheck(this, Event);
|
|
148
|
+
this.listeners = new Set();
|
|
149
|
+
}
|
|
150
|
+
return _createClass(Event, [{
|
|
151
|
+
key: "emit",
|
|
152
|
+
value: function emit() {
|
|
153
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
154
|
+
args[_key] = arguments[_key];
|
|
155
|
+
}
|
|
156
|
+
this.listeners.forEach(function (listener) {
|
|
157
|
+
return listener.apply(void 0, args);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "addListener",
|
|
162
|
+
value: function addListener(listener) {
|
|
163
|
+
this.listeners.add(listener);
|
|
164
|
+
}
|
|
165
|
+
}, {
|
|
166
|
+
key: "removeListener",
|
|
167
|
+
value: function removeListener(listener) {
|
|
168
|
+
this.listeners["delete"](listener);
|
|
169
|
+
}
|
|
170
|
+
}]);
|
|
171
|
+
}();
|
|
172
|
+
var Streamer = function () {
|
|
173
|
+
var _a;
|
|
174
|
+
var _instanceExtraInitializers = [];
|
|
175
|
+
var _set_selectorMap_decorators;
|
|
176
|
+
var _addListener_decorators;
|
|
177
|
+
var _endStream_decorators;
|
|
178
|
+
var _removeListener_decorators;
|
|
179
|
+
var _resetState_decorators;
|
|
180
|
+
var _setState_decorators;
|
|
181
|
+
var _subscribe_decorators;
|
|
182
|
+
var _unsubscribe_decorators;
|
|
183
|
+
return _a = /*#__PURE__*/function () {
|
|
184
|
+
function Streamer(context, selectorMap) {
|
|
185
|
+
var _this = this;
|
|
186
|
+
_classCallCheck(this, Streamer);
|
|
187
|
+
this._context = (__runInitializers(this, _instanceExtraInitializers), null);
|
|
188
|
+
this._internalStore = null;
|
|
189
|
+
this._data = {};
|
|
190
|
+
this.eventMap = {
|
|
191
|
+
'data-changed': new Event(),
|
|
192
|
+
'stream-ending': new Event()
|
|
193
|
+
};
|
|
194
|
+
this._phase = __1.Phase.UN_OPENED;
|
|
195
|
+
this._selectorMap = null;
|
|
196
|
+
this._unsubClosing = null;
|
|
197
|
+
this._unsubscribe = null;
|
|
198
|
+
this._dataSourceListener = function (changes, changePathsTokens, netChanges, mayHaveChangesAt) {
|
|
199
|
+
for (var renderKeys = _this._renderKeys, rLen = renderKeys.length, r = 0; r < rLen; r++) {
|
|
200
|
+
if (renderKeys[r] !== FULL_STATE_SELECTOR && !mayHaveChangesAt((0, path_dotize_1["default"])(renderKeys[r]).split('.'))) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
return _this._updateData();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
this._updateData = function () {
|
|
207
|
+
var hasChanges = false;
|
|
208
|
+
var selectorEntries = Object.entries(_this._selectorMap);
|
|
209
|
+
var state = _this._internalStore.getState(_this._renderKeys);
|
|
210
|
+
for (var _i = 0, _selectorEntries = selectorEntries; _i < _selectorEntries.length; _i++) {
|
|
211
|
+
var _this$_data$label;
|
|
212
|
+
var _selectorEntries$_i = _slicedToArray(_selectorEntries[_i], 2),
|
|
213
|
+
label = _selectorEntries$_i[0],
|
|
214
|
+
path = _selectorEntries$_i[1];
|
|
215
|
+
if (path !== FULL_STATE_SELECTOR) {
|
|
216
|
+
var slice = (0, get_property_1["default"])(state, path)._value;
|
|
217
|
+
if (_this._data[label] === slice) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
_this._data[label] = slice;
|
|
221
|
+
hasChanges = true;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
var keys = Object.keys((_this$_data$label = _this._data[label]) !== null && _this$_data$label !== void 0 ? _this$_data$label : {});
|
|
225
|
+
var _hasChanges = keys.length !== Object.keys(state).length;
|
|
226
|
+
for (var i = keys.length, data = _this._data[label]; !_hasChanges && i--;) {
|
|
227
|
+
_hasChanges = data[keys[i]] !== state[keys[i]];
|
|
228
|
+
}
|
|
229
|
+
if (!_hasChanges) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
_this._data[label] = state;
|
|
233
|
+
hasChanges = true;
|
|
234
|
+
}
|
|
235
|
+
hasChanges && _this._refreshDataRef();
|
|
236
|
+
};
|
|
237
|
+
this._context = context;
|
|
238
|
+
this._setupInternalStore();
|
|
239
|
+
if ((0, lodash_isempty_1["default"])(selectorMap)) {
|
|
240
|
+
this._phase = __1.Phase.OPENED;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this._integrateSelectors(selectorMap);
|
|
244
|
+
this._phase = __1.Phase.OPENED;
|
|
245
|
+
}
|
|
246
|
+
return _createClass(Streamer, [{
|
|
247
|
+
key: "closed",
|
|
248
|
+
get: function get() {
|
|
249
|
+
return !this._internalStore || this._internalStore.closed;
|
|
250
|
+
}
|
|
251
|
+
}, {
|
|
252
|
+
key: "data",
|
|
253
|
+
get: function get() {
|
|
254
|
+
return this._data;
|
|
255
|
+
}
|
|
256
|
+
}, {
|
|
257
|
+
key: "phase",
|
|
258
|
+
get: function get() {
|
|
259
|
+
return this._phase;
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "streaming",
|
|
263
|
+
get: function get() {
|
|
264
|
+
return this._phase === __1.Phase.OPENED || this._phase === __1.Phase.UN_OPENED;
|
|
265
|
+
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "selectorMap",
|
|
268
|
+
set: function set(selectorMap) {
|
|
269
|
+
if (!selectorMap || (0, lodash_isempty_1["default"])(selectorMap)) {
|
|
270
|
+
selectorMap = null;
|
|
271
|
+
}
|
|
272
|
+
if (selectorMap === this._selectorMap || (0, lodash_isequal_1["default"])(selectorMap, this._selectorMap) || this._phase === __1.Phase.UN_OPENED) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this._updateInternalStore();
|
|
276
|
+
this._integrateSelectors(selectorMap);
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "addListener",
|
|
280
|
+
value: function addListener(eventType, listener) {
|
|
281
|
+
this.eventMap[eventType].addListener(listener);
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "endStream",
|
|
285
|
+
value: function endStream() {
|
|
286
|
+
this._phase = __1.Phase.CLOSING;
|
|
287
|
+
this.eventMap['stream-ending'].emit(__1.ShutdownReason.LOCAL);
|
|
288
|
+
this._internalStore.close();
|
|
289
|
+
this._reclaim();
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
key: "removeListener",
|
|
293
|
+
value: function removeListener(eventType, listener) {
|
|
294
|
+
this.eventMap[eventType].removeListener(listener);
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "resetState",
|
|
298
|
+
value: function resetState() {
|
|
299
|
+
var propertyPaths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._renderKeys;
|
|
300
|
+
propertyPaths.length && this._internalStore.resetState(propertyPaths);
|
|
301
|
+
}
|
|
302
|
+
}, {
|
|
303
|
+
key: "setState",
|
|
304
|
+
value: function setState(changes) {
|
|
305
|
+
this._internalStore.setState(changes);
|
|
306
|
+
}
|
|
307
|
+
}, {
|
|
308
|
+
key: "subscribe",
|
|
309
|
+
value: function subscribe() {
|
|
310
|
+
this._unsubscribe || (this._unsubscribe = this._internalStore.subscribe('data-updated', this._dataSourceListener));
|
|
311
|
+
}
|
|
312
|
+
}, {
|
|
313
|
+
key: "unsubscribe",
|
|
314
|
+
value: function unsubscribe() {
|
|
315
|
+
if (!this._unsubscribe) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
this._unsubscribe();
|
|
319
|
+
this._unsubscribe = null;
|
|
320
|
+
}
|
|
321
|
+
}, {
|
|
322
|
+
key: "_renderKeys",
|
|
323
|
+
get: function get() {
|
|
324
|
+
var _this$_selectorMap;
|
|
325
|
+
return Object.values((_this$_selectorMap = this._selectorMap) !== null && _this$_selectorMap !== void 0 ? _this$_selectorMap : {});
|
|
326
|
+
}
|
|
327
|
+
}, {
|
|
328
|
+
key: "_integrateSelectors",
|
|
329
|
+
value: function _integrateSelectors(selectorMap) {
|
|
330
|
+
this._selectorMap = selectorMap;
|
|
331
|
+
if (!selectorMap) {
|
|
332
|
+
this._data = {};
|
|
333
|
+
return this._refreshDataRef();
|
|
334
|
+
}
|
|
335
|
+
this.subscribe();
|
|
336
|
+
var state = this._internalStore.getState(this._renderKeys);
|
|
337
|
+
var newData = {};
|
|
338
|
+
for (var k in selectorMap) {
|
|
339
|
+
newData[k] = selectorMap[k] !== FULL_STATE_SELECTOR ? (0, get_property_1["default"])(state, selectorMap[k]).value : state;
|
|
340
|
+
}
|
|
341
|
+
this._data = newData;
|
|
342
|
+
this._refreshDataRef();
|
|
343
|
+
}
|
|
344
|
+
}, {
|
|
345
|
+
key: "_reclaim",
|
|
346
|
+
value: function _reclaim() {
|
|
347
|
+
this._selectorMap && this.unsubscribe();
|
|
348
|
+
this._unsubClosing();
|
|
349
|
+
this._context = null;
|
|
350
|
+
this._internalStore = null;
|
|
351
|
+
this.eventMap = null;
|
|
352
|
+
this._unsubClosing = null;
|
|
353
|
+
this._unsubscribe = null;
|
|
354
|
+
this._phase = __1.Phase.CLOSED;
|
|
355
|
+
}
|
|
356
|
+
}, {
|
|
357
|
+
key: "_refreshDataRef",
|
|
358
|
+
value: function _refreshDataRef() {
|
|
359
|
+
this._data = _objectSpread({}, this._data);
|
|
360
|
+
this.eventMap['data-changed'].emit();
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "_setupInternalStore",
|
|
364
|
+
value: function _setupInternalStore() {
|
|
365
|
+
var _this2 = this;
|
|
366
|
+
this._internalStore = this._context.createInternalStore(exports.ACCESS_SYM);
|
|
367
|
+
this._unsubClosing = this._internalStore.subscribe('closing', function (r) {
|
|
368
|
+
_this2._phase = __1.Phase.CLOSING;
|
|
369
|
+
_this2.eventMap['stream-ending'].emit(r);
|
|
370
|
+
_this2._reclaim();
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "_updateInternalStore",
|
|
375
|
+
value: function _updateInternalStore() {
|
|
376
|
+
this._selectorMap && this.unsubscribe();
|
|
377
|
+
this._unsubClosing();
|
|
378
|
+
this._internalStore.close();
|
|
379
|
+
this._setupInternalStore();
|
|
380
|
+
}
|
|
381
|
+
}]);
|
|
382
|
+
}(), function () {
|
|
383
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
384
|
+
_set_selectorMap_decorators = [streamable];
|
|
385
|
+
_addListener_decorators = [streamable];
|
|
386
|
+
_endStream_decorators = [streamable];
|
|
387
|
+
_removeListener_decorators = [streamable];
|
|
388
|
+
_resetState_decorators = [streamable];
|
|
389
|
+
_setState_decorators = [streamable];
|
|
390
|
+
_subscribe_decorators = [streamable];
|
|
391
|
+
_unsubscribe_decorators = [streamable];
|
|
392
|
+
__esDecorate(_a, null, _set_selectorMap_decorators, {
|
|
393
|
+
kind: "setter",
|
|
394
|
+
name: "selectorMap",
|
|
395
|
+
"static": false,
|
|
396
|
+
"private": false,
|
|
397
|
+
access: {
|
|
398
|
+
has: function has(obj) {
|
|
399
|
+
return "selectorMap" in obj;
|
|
400
|
+
},
|
|
401
|
+
set: function set(obj, value) {
|
|
402
|
+
obj.selectorMap = value;
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
metadata: _metadata
|
|
406
|
+
}, null, _instanceExtraInitializers);
|
|
407
|
+
__esDecorate(_a, null, _addListener_decorators, {
|
|
408
|
+
kind: "method",
|
|
409
|
+
name: "addListener",
|
|
410
|
+
"static": false,
|
|
411
|
+
"private": false,
|
|
412
|
+
access: {
|
|
413
|
+
has: function has(obj) {
|
|
414
|
+
return "addListener" in obj;
|
|
415
|
+
},
|
|
416
|
+
get: function get(obj) {
|
|
417
|
+
return obj.addListener;
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
metadata: _metadata
|
|
421
|
+
}, null, _instanceExtraInitializers);
|
|
422
|
+
__esDecorate(_a, null, _endStream_decorators, {
|
|
423
|
+
kind: "method",
|
|
424
|
+
name: "endStream",
|
|
425
|
+
"static": false,
|
|
426
|
+
"private": false,
|
|
427
|
+
access: {
|
|
428
|
+
has: function has(obj) {
|
|
429
|
+
return "endStream" in obj;
|
|
430
|
+
},
|
|
431
|
+
get: function get(obj) {
|
|
432
|
+
return obj.endStream;
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
metadata: _metadata
|
|
436
|
+
}, null, _instanceExtraInitializers);
|
|
437
|
+
__esDecorate(_a, null, _removeListener_decorators, {
|
|
438
|
+
kind: "method",
|
|
439
|
+
name: "removeListener",
|
|
440
|
+
"static": false,
|
|
441
|
+
"private": false,
|
|
442
|
+
access: {
|
|
443
|
+
has: function has(obj) {
|
|
444
|
+
return "removeListener" in obj;
|
|
445
|
+
},
|
|
446
|
+
get: function get(obj) {
|
|
447
|
+
return obj.removeListener;
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
metadata: _metadata
|
|
451
|
+
}, null, _instanceExtraInitializers);
|
|
452
|
+
__esDecorate(_a, null, _resetState_decorators, {
|
|
453
|
+
kind: "method",
|
|
454
|
+
name: "resetState",
|
|
455
|
+
"static": false,
|
|
456
|
+
"private": false,
|
|
457
|
+
access: {
|
|
458
|
+
has: function has(obj) {
|
|
459
|
+
return "resetState" in obj;
|
|
460
|
+
},
|
|
461
|
+
get: function get(obj) {
|
|
462
|
+
return obj.resetState;
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
metadata: _metadata
|
|
466
|
+
}, null, _instanceExtraInitializers);
|
|
467
|
+
__esDecorate(_a, null, _setState_decorators, {
|
|
468
|
+
kind: "method",
|
|
469
|
+
name: "setState",
|
|
470
|
+
"static": false,
|
|
471
|
+
"private": false,
|
|
472
|
+
access: {
|
|
473
|
+
has: function has(obj) {
|
|
474
|
+
return "setState" in obj;
|
|
475
|
+
},
|
|
476
|
+
get: function get(obj) {
|
|
477
|
+
return obj.setState;
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
metadata: _metadata
|
|
481
|
+
}, null, _instanceExtraInitializers);
|
|
482
|
+
__esDecorate(_a, null, _subscribe_decorators, {
|
|
483
|
+
kind: "method",
|
|
484
|
+
name: "subscribe",
|
|
485
|
+
"static": false,
|
|
486
|
+
"private": false,
|
|
487
|
+
access: {
|
|
488
|
+
has: function has(obj) {
|
|
489
|
+
return "subscribe" in obj;
|
|
490
|
+
},
|
|
491
|
+
get: function get(obj) {
|
|
492
|
+
return obj.subscribe;
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
metadata: _metadata
|
|
496
|
+
}, null, _instanceExtraInitializers);
|
|
497
|
+
__esDecorate(_a, null, _unsubscribe_decorators, {
|
|
498
|
+
kind: "method",
|
|
499
|
+
name: "unsubscribe",
|
|
500
|
+
"static": false,
|
|
501
|
+
"private": false,
|
|
502
|
+
access: {
|
|
503
|
+
has: function has(obj) {
|
|
504
|
+
return "unsubscribe" in obj;
|
|
505
|
+
},
|
|
506
|
+
get: function get(obj) {
|
|
507
|
+
return obj.unsubscribe;
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
metadata: _metadata
|
|
511
|
+
}, null, _instanceExtraInitializers);
|
|
512
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, {
|
|
513
|
+
enumerable: true,
|
|
514
|
+
configurable: true,
|
|
515
|
+
writable: true,
|
|
516
|
+
value: _metadata
|
|
517
|
+
});
|
|
518
|
+
}(), _a;
|
|
519
|
+
}();
|
|
520
|
+
exports.Streamer = Streamer;
|
|
521
|
+
var EagleEyeContext = function () {
|
|
522
|
+
var _a;
|
|
523
|
+
var _instanceExtraInitializers = [];
|
|
524
|
+
var _get_stream_decorators;
|
|
525
|
+
var _set_prehooks_decorators;
|
|
526
|
+
var _set_storage_decorators;
|
|
527
|
+
var _createInternalStore_decorators;
|
|
528
|
+
var _dispose_decorators;
|
|
529
|
+
var _disconnectInternalStore_decorators;
|
|
530
|
+
var _getState_decorators;
|
|
531
|
+
var _notifyClosing_decorators;
|
|
532
|
+
var _resetState_decorators;
|
|
533
|
+
var _setState_decorators;
|
|
534
|
+
var _subscribe_decorators;
|
|
535
|
+
return _a = /*#__PURE__*/function () {
|
|
536
|
+
function EagleEyeContext() {
|
|
537
|
+
var _this3 = this;
|
|
538
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
539
|
+
var prehooks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
540
|
+
var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
541
|
+
_classCallCheck(this, EagleEyeContext);
|
|
542
|
+
this._cache = __runInitializers(this, _instanceExtraInitializers);
|
|
543
|
+
this.eventMap = {
|
|
544
|
+
closing: new Event(),
|
|
545
|
+
'data-updated': new Event()
|
|
546
|
+
};
|
|
547
|
+
this.storageKey = null;
|
|
548
|
+
this._stream = function (selectorMap) {
|
|
549
|
+
return new Streamer(_this3, selectorMap);
|
|
550
|
+
};
|
|
551
|
+
if (!(value instanceof auto_immutable_1["default"])) {
|
|
552
|
+
this.inchoateValue = value;
|
|
553
|
+
this._cache = new auto_immutable_1["default"](this.inchoateValue);
|
|
554
|
+
} else {
|
|
555
|
+
this._cache = value;
|
|
556
|
+
var tConnection = this._cache.connect();
|
|
557
|
+
this.inchoateValue = tConnection.get()[constants.GLOBAL_SELECTOR];
|
|
558
|
+
tConnection.disconnect();
|
|
559
|
+
this._cacheCloseMonitor = function () {
|
|
560
|
+
_this3.notifyClosing(__1.ShutdownReason.CACHE);
|
|
561
|
+
_this3._store.close();
|
|
562
|
+
_this3._reclaim();
|
|
563
|
+
};
|
|
564
|
+
this._cache.onClose(this._cacheCloseMonitor);
|
|
565
|
+
}
|
|
566
|
+
this.prehooks = prehooks;
|
|
567
|
+
this.storage = storage;
|
|
568
|
+
this._store = this._createInternalStore();
|
|
569
|
+
var ctx = this;
|
|
570
|
+
this._storeRef = {
|
|
571
|
+
getState: function getState() {
|
|
572
|
+
var propertyPaths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
573
|
+
return ctx._store.getState(propertyPaths);
|
|
574
|
+
},
|
|
575
|
+
resetState: function resetState() {
|
|
576
|
+
var propertyPaths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
577
|
+
return ctx._store.resetState(propertyPaths);
|
|
578
|
+
},
|
|
579
|
+
setState: function setState(changes) {
|
|
580
|
+
return ctx._store.setState(changes);
|
|
581
|
+
},
|
|
582
|
+
subscribe: function subscribe(eventType, listener) {
|
|
583
|
+
return ctx._store.subscribe(eventType, listener);
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
return _createClass(EagleEyeContext, [{
|
|
588
|
+
key: "cache",
|
|
589
|
+
get: function get() {
|
|
590
|
+
return this._cache;
|
|
591
|
+
}
|
|
592
|
+
}, {
|
|
593
|
+
key: "closed",
|
|
594
|
+
get: function get() {
|
|
595
|
+
return !this._cache;
|
|
596
|
+
}
|
|
597
|
+
}, {
|
|
598
|
+
key: "prehooks",
|
|
599
|
+
get: function get() {
|
|
600
|
+
return this._prehooks;
|
|
601
|
+
},
|
|
602
|
+
set: function set(prehooks) {
|
|
603
|
+
this._prehooks = prehooks !== null && prehooks !== void 0 ? prehooks : defaultPrehooks;
|
|
604
|
+
}
|
|
605
|
+
}, {
|
|
606
|
+
key: "storage",
|
|
607
|
+
get: function get() {
|
|
608
|
+
return this._storage;
|
|
609
|
+
},
|
|
610
|
+
set: function set(storage) {
|
|
611
|
+
var _storage;
|
|
612
|
+
var data;
|
|
613
|
+
(_storage = storage) !== null && _storage !== void 0 ? _storage : storage = new storage_1["default"]();
|
|
614
|
+
if (typeof this._storage !== 'undefined') {
|
|
615
|
+
data = this._storage.getItem(this.storageKey);
|
|
616
|
+
this._storage.removeItem(this.storageKey);
|
|
617
|
+
} else {
|
|
618
|
+
data = storage.clone(this.inchoateValue);
|
|
619
|
+
this.inchoateValue = undefined;
|
|
620
|
+
}
|
|
621
|
+
this._storage = storage;
|
|
622
|
+
this.storageKey = this._storage.isKeyRequired ? exports.deps.createStorageKey() : null;
|
|
623
|
+
this._storage.setItem(this.storageKey, data);
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
key: "store",
|
|
627
|
+
get: function get() {
|
|
628
|
+
return this._storeRef;
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
key: "stream",
|
|
632
|
+
get: function get() {
|
|
633
|
+
return this._stream;
|
|
634
|
+
}
|
|
635
|
+
}, {
|
|
636
|
+
key: "createInternalStore",
|
|
637
|
+
value: function createInternalStore() {
|
|
638
|
+
var access = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
639
|
+
if (access === exports.ACCESS_SYM) {
|
|
640
|
+
return this._createInternalStore();
|
|
641
|
+
}
|
|
642
|
+
throw new Error('May not create internal stores out of context. Please use `this.store` to obtain externally available store reference.');
|
|
643
|
+
}
|
|
644
|
+
}, {
|
|
645
|
+
key: "dispose",
|
|
646
|
+
value: function dispose() {
|
|
647
|
+
this.notifyClosing(__1.ShutdownReason.CONTEXT);
|
|
648
|
+
this._cacheCloseMonitor ? this._cache.offClose(this._cacheCloseMonitor) : this._cache.close();
|
|
649
|
+
this._store.close();
|
|
650
|
+
this._reclaim();
|
|
651
|
+
}
|
|
652
|
+
}, {
|
|
653
|
+
key: "createUpdateEmitterFor",
|
|
654
|
+
value: function createUpdateEmitterFor(changes) {
|
|
655
|
+
var _this4 = this;
|
|
656
|
+
return function (netChanges, changedPathsTokens) {
|
|
657
|
+
return _this4.eventMap['data-updated'].emit(changes, changedPathsTokens, netChanges, createChangePathSearch(changedPathsTokens));
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
}, {
|
|
661
|
+
key: "disconnectInternalStore",
|
|
662
|
+
value: function disconnectInternalStore(connection) {
|
|
663
|
+
connection.disconnect();
|
|
664
|
+
}
|
|
665
|
+
}, {
|
|
666
|
+
key: "getState",
|
|
667
|
+
value: function getState(connection, propertyPaths) {
|
|
668
|
+
return _getState(connection, propertyPaths);
|
|
669
|
+
}
|
|
670
|
+
}, {
|
|
671
|
+
key: "notifyClosing",
|
|
672
|
+
value: function notifyClosing(reason) {
|
|
673
|
+
this.eventMap.closing.emit(reason);
|
|
674
|
+
}
|
|
675
|
+
}, {
|
|
676
|
+
key: "resetState",
|
|
677
|
+
value: function resetState(connection, propertyPaths) {
|
|
678
|
+
var CLEAR_TAG = constants.CLEAR_TAG,
|
|
679
|
+
DELETE_TAG = constants.DELETE_TAG,
|
|
680
|
+
FULL_STATE_SELECTOR = constants.FULL_STATE_SELECTOR,
|
|
681
|
+
GLOBAL_SELECTOR = constants.GLOBAL_SELECTOR,
|
|
682
|
+
REPLACE_TAG = constants.REPLACE_TAG;
|
|
683
|
+
var original = this.storage.clone(this.storage.getItem(this.storageKey));
|
|
684
|
+
var resetData = {};
|
|
685
|
+
if (propertyPaths.includes(FULL_STATE_SELECTOR)) {
|
|
686
|
+
resetData = (0, lodash_isempty_1["default"])(original) ? CLEAR_TAG : _defineProperty({}, REPLACE_TAG, original);
|
|
687
|
+
} else {
|
|
688
|
+
var _iterator = _createForOfIteratorHelper(propertyPaths),
|
|
689
|
+
_step;
|
|
690
|
+
try {
|
|
691
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
692
|
+
var path = _step.value;
|
|
693
|
+
var node = resetData;
|
|
694
|
+
var tokens = (0, path_dotize_1["default"])(path).split('.');
|
|
695
|
+
var _ref2 = (0, get_property_1["default"])(original, tokens),
|
|
696
|
+
trail = _ref2.trail,
|
|
697
|
+
pInfo = _objectWithoutProperties(_ref2, _excluded);
|
|
698
|
+
for (var length = trail.length, keys = _objectWithoutProperties(trail, _excluded2), k = 0; k < length; k++) {
|
|
699
|
+
if (REPLACE_TAG in node) {
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
var key = keys[k];
|
|
703
|
+
if (!(key in node)) {
|
|
704
|
+
node[key] = {};
|
|
705
|
+
}
|
|
706
|
+
node = node[key];
|
|
707
|
+
}
|
|
708
|
+
if (REPLACE_TAG in node) {
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
if (pInfo.exists) {
|
|
712
|
+
for (var _k in node) {
|
|
713
|
+
delete node[_k];
|
|
714
|
+
}
|
|
715
|
+
node[REPLACE_TAG] = pInfo._value;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
if (!(DELETE_TAG in node)) {
|
|
719
|
+
node[DELETE_TAG] = [];
|
|
720
|
+
}
|
|
721
|
+
var deletingKey = tokens[trail.length];
|
|
722
|
+
!node[DELETE_TAG].includes(deletingKey) && node[DELETE_TAG].push(deletingKey);
|
|
723
|
+
}
|
|
724
|
+
} catch (err) {
|
|
725
|
+
_iterator.e(err);
|
|
726
|
+
} finally {
|
|
727
|
+
_iterator.f();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
runPrehook(this._prehooks, 'resetState', [resetData, {
|
|
731
|
+
current: connection.get()[GLOBAL_SELECTOR],
|
|
732
|
+
original: original
|
|
733
|
+
}]) && connection.set(resetData, this.createUpdateEmitterFor(resetData));
|
|
734
|
+
}
|
|
735
|
+
}, {
|
|
736
|
+
key: "setState",
|
|
737
|
+
value: function setState(connection, changes) {
|
|
738
|
+
runPrehook(this._prehooks, 'setState', [changes]) && connection.set(changes, this.createUpdateEmitterFor(changes));
|
|
739
|
+
}
|
|
740
|
+
}, {
|
|
741
|
+
key: "subscribe",
|
|
742
|
+
value: function subscribe(eventType, listener) {
|
|
743
|
+
var event = this.eventMap[eventType];
|
|
744
|
+
event.addListener(listener);
|
|
745
|
+
return function () {
|
|
746
|
+
return event.removeListener(listener);
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
}, {
|
|
750
|
+
key: "_createInternalStore",
|
|
751
|
+
value: function _createInternalStore() {
|
|
752
|
+
var ctx = this;
|
|
753
|
+
var connection = ctx._cache.connect();
|
|
754
|
+
return {
|
|
755
|
+
close: function close() {
|
|
756
|
+
ctx.disconnectInternalStore(connection);
|
|
757
|
+
connection = null;
|
|
758
|
+
},
|
|
759
|
+
get closed() {
|
|
760
|
+
return !connection;
|
|
761
|
+
},
|
|
762
|
+
getState: function getState(propertyPaths) {
|
|
763
|
+
return ctx.getState(connection, propertyPaths);
|
|
764
|
+
},
|
|
765
|
+
resetState: function resetState(propertyPaths) {
|
|
766
|
+
return ctx.resetState(connection, propertyPaths);
|
|
767
|
+
},
|
|
768
|
+
setState: function setState(changes) {
|
|
769
|
+
return ctx.setState(connection, changes);
|
|
770
|
+
},
|
|
771
|
+
subscribe: function subscribe(eventType, listener) {
|
|
772
|
+
return ctx.subscribe(eventType, listener);
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
}, {
|
|
777
|
+
key: "_reclaim",
|
|
778
|
+
value: function _reclaim() {
|
|
779
|
+
this._storage.removeItem(this.storageKey);
|
|
780
|
+
this._cache = null;
|
|
781
|
+
this._prehooks = null;
|
|
782
|
+
this._storage = null;
|
|
783
|
+
this.eventMap = null;
|
|
784
|
+
this.inchoateValue = null;
|
|
785
|
+
this.storageKey = null;
|
|
786
|
+
this._stream = null;
|
|
787
|
+
this._cacheCloseMonitor = null;
|
|
788
|
+
}
|
|
789
|
+
}]);
|
|
790
|
+
}(), function () {
|
|
791
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
792
|
+
_get_stream_decorators = [invokable];
|
|
793
|
+
_set_prehooks_decorators = [invokable];
|
|
794
|
+
_set_storage_decorators = [invokable];
|
|
795
|
+
_createInternalStore_decorators = [invokable];
|
|
796
|
+
_dispose_decorators = [invokable];
|
|
797
|
+
_disconnectInternalStore_decorators = [invokable];
|
|
798
|
+
_getState_decorators = [invokable];
|
|
799
|
+
_notifyClosing_decorators = [invokable];
|
|
800
|
+
_resetState_decorators = [invokable];
|
|
801
|
+
_setState_decorators = [invokable];
|
|
802
|
+
_subscribe_decorators = [invokable];
|
|
803
|
+
__esDecorate(_a, null, _get_stream_decorators, {
|
|
804
|
+
kind: "getter",
|
|
805
|
+
name: "stream",
|
|
806
|
+
"static": false,
|
|
807
|
+
"private": false,
|
|
808
|
+
access: {
|
|
809
|
+
has: function has(obj) {
|
|
810
|
+
return "stream" in obj;
|
|
811
|
+
},
|
|
812
|
+
get: function get(obj) {
|
|
813
|
+
return obj.stream;
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
metadata: _metadata
|
|
817
|
+
}, null, _instanceExtraInitializers);
|
|
818
|
+
__esDecorate(_a, null, _set_prehooks_decorators, {
|
|
819
|
+
kind: "setter",
|
|
820
|
+
name: "prehooks",
|
|
821
|
+
"static": false,
|
|
822
|
+
"private": false,
|
|
823
|
+
access: {
|
|
824
|
+
has: function has(obj) {
|
|
825
|
+
return "prehooks" in obj;
|
|
826
|
+
},
|
|
827
|
+
set: function set(obj, value) {
|
|
828
|
+
obj.prehooks = value;
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
metadata: _metadata
|
|
832
|
+
}, null, _instanceExtraInitializers);
|
|
833
|
+
__esDecorate(_a, null, _set_storage_decorators, {
|
|
834
|
+
kind: "setter",
|
|
835
|
+
name: "storage",
|
|
836
|
+
"static": false,
|
|
837
|
+
"private": false,
|
|
838
|
+
access: {
|
|
839
|
+
has: function has(obj) {
|
|
840
|
+
return "storage" in obj;
|
|
841
|
+
},
|
|
842
|
+
set: function set(obj, value) {
|
|
843
|
+
obj.storage = value;
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
metadata: _metadata
|
|
847
|
+
}, null, _instanceExtraInitializers);
|
|
848
|
+
__esDecorate(_a, null, _createInternalStore_decorators, {
|
|
849
|
+
kind: "method",
|
|
850
|
+
name: "createInternalStore",
|
|
851
|
+
"static": false,
|
|
852
|
+
"private": false,
|
|
853
|
+
access: {
|
|
854
|
+
has: function has(obj) {
|
|
855
|
+
return "createInternalStore" in obj;
|
|
856
|
+
},
|
|
857
|
+
get: function get(obj) {
|
|
858
|
+
return obj.createInternalStore;
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
metadata: _metadata
|
|
862
|
+
}, null, _instanceExtraInitializers);
|
|
863
|
+
__esDecorate(_a, null, _dispose_decorators, {
|
|
864
|
+
kind: "method",
|
|
865
|
+
name: "dispose",
|
|
866
|
+
"static": false,
|
|
867
|
+
"private": false,
|
|
868
|
+
access: {
|
|
869
|
+
has: function has(obj) {
|
|
870
|
+
return "dispose" in obj;
|
|
871
|
+
},
|
|
872
|
+
get: function get(obj) {
|
|
873
|
+
return obj.dispose;
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
metadata: _metadata
|
|
877
|
+
}, null, _instanceExtraInitializers);
|
|
878
|
+
__esDecorate(_a, null, _disconnectInternalStore_decorators, {
|
|
879
|
+
kind: "method",
|
|
880
|
+
name: "disconnectInternalStore",
|
|
881
|
+
"static": false,
|
|
882
|
+
"private": false,
|
|
883
|
+
access: {
|
|
884
|
+
has: function has(obj) {
|
|
885
|
+
return "disconnectInternalStore" in obj;
|
|
886
|
+
},
|
|
887
|
+
get: function get(obj) {
|
|
888
|
+
return obj.disconnectInternalStore;
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
metadata: _metadata
|
|
892
|
+
}, null, _instanceExtraInitializers);
|
|
893
|
+
__esDecorate(_a, null, _getState_decorators, {
|
|
894
|
+
kind: "method",
|
|
895
|
+
name: "getState",
|
|
896
|
+
"static": false,
|
|
897
|
+
"private": false,
|
|
898
|
+
access: {
|
|
899
|
+
has: function has(obj) {
|
|
900
|
+
return "getState" in obj;
|
|
901
|
+
},
|
|
902
|
+
get: function get(obj) {
|
|
903
|
+
return obj.getState;
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
metadata: _metadata
|
|
907
|
+
}, null, _instanceExtraInitializers);
|
|
908
|
+
__esDecorate(_a, null, _notifyClosing_decorators, {
|
|
909
|
+
kind: "method",
|
|
910
|
+
name: "notifyClosing",
|
|
911
|
+
"static": false,
|
|
912
|
+
"private": false,
|
|
913
|
+
access: {
|
|
914
|
+
has: function has(obj) {
|
|
915
|
+
return "notifyClosing" in obj;
|
|
916
|
+
},
|
|
917
|
+
get: function get(obj) {
|
|
918
|
+
return obj.notifyClosing;
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
metadata: _metadata
|
|
922
|
+
}, null, _instanceExtraInitializers);
|
|
923
|
+
__esDecorate(_a, null, _resetState_decorators, {
|
|
924
|
+
kind: "method",
|
|
925
|
+
name: "resetState",
|
|
926
|
+
"static": false,
|
|
927
|
+
"private": false,
|
|
928
|
+
access: {
|
|
929
|
+
has: function has(obj) {
|
|
930
|
+
return "resetState" in obj;
|
|
931
|
+
},
|
|
932
|
+
get: function get(obj) {
|
|
933
|
+
return obj.resetState;
|
|
934
|
+
}
|
|
935
|
+
},
|
|
936
|
+
metadata: _metadata
|
|
937
|
+
}, null, _instanceExtraInitializers);
|
|
938
|
+
__esDecorate(_a, null, _setState_decorators, {
|
|
939
|
+
kind: "method",
|
|
940
|
+
name: "setState",
|
|
941
|
+
"static": false,
|
|
942
|
+
"private": false,
|
|
943
|
+
access: {
|
|
944
|
+
has: function has(obj) {
|
|
945
|
+
return "setState" in obj;
|
|
946
|
+
},
|
|
947
|
+
get: function get(obj) {
|
|
948
|
+
return obj.setState;
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
metadata: _metadata
|
|
952
|
+
}, null, _instanceExtraInitializers);
|
|
953
|
+
__esDecorate(_a, null, _subscribe_decorators, {
|
|
954
|
+
kind: "method",
|
|
955
|
+
name: "subscribe",
|
|
956
|
+
"static": false,
|
|
957
|
+
"private": false,
|
|
958
|
+
access: {
|
|
959
|
+
has: function has(obj) {
|
|
960
|
+
return "subscribe" in obj;
|
|
961
|
+
},
|
|
962
|
+
get: function get(obj) {
|
|
963
|
+
return obj.subscribe;
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
metadata: _metadata
|
|
967
|
+
}, null, _instanceExtraInitializers);
|
|
968
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, {
|
|
969
|
+
enumerable: true,
|
|
970
|
+
configurable: true,
|
|
971
|
+
writable: true,
|
|
972
|
+
value: _metadata
|
|
973
|
+
});
|
|
974
|
+
}(), _a;
|
|
975
|
+
}();
|
|
976
|
+
exports.EagleEyeContext = EagleEyeContext;
|
|
977
|
+
function createEagleEye() {
|
|
978
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
979
|
+
return new EagleEyeContext(props.value, props.prehooks, props.storage);
|
|
980
|
+
}
|
|
981
|
+
function createChangePathSearch(_ref3) {
|
|
982
|
+
var length = _ref3.length,
|
|
983
|
+
pathTokenGroups = _objectWithoutProperties(_ref3, _excluded3);
|
|
984
|
+
var root = {};
|
|
985
|
+
for (var g = 0; g < length; g++) {
|
|
986
|
+
for (var obj = root, tokens = pathTokenGroups[g], tLen = tokens.length, t = 0; t < tLen; t++) {
|
|
987
|
+
var key = tokens[t];
|
|
988
|
+
if (!(key in obj)) {
|
|
989
|
+
obj[key] = {};
|
|
990
|
+
}
|
|
991
|
+
obj = obj[key];
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return function (_ref4) {
|
|
995
|
+
var length = _ref4.length,
|
|
996
|
+
pathTokens = _objectWithoutProperties(_ref4, _excluded4);
|
|
997
|
+
var obj = root;
|
|
998
|
+
for (var p = 0; p < length; p++) {
|
|
999
|
+
var _key2 = pathTokens[p];
|
|
1000
|
+
if (_key2 in obj) {
|
|
1001
|
+
obj = obj[_key2];
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
return !Object.keys(obj).length;
|
|
1005
|
+
}
|
|
1006
|
+
return true;
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
function _getState(connection, propertyPaths) {
|
|
1010
|
+
var FULL_STATE_SELECTOR = constants.FULL_STATE_SELECTOR,
|
|
1011
|
+
GLOBAL_SELECTOR = constants.GLOBAL_SELECTOR;
|
|
1012
|
+
if (!propertyPaths.length || propertyPaths.indexOf(FULL_STATE_SELECTOR) !== -1) {
|
|
1013
|
+
return connection.get()[GLOBAL_SELECTOR];
|
|
1014
|
+
}
|
|
1015
|
+
var data = connection.get.apply(connection, _toConsumableArray(propertyPaths));
|
|
1016
|
+
var state = {};
|
|
1017
|
+
for (var d in data) {
|
|
1018
|
+
(0, lodash_set_1["default"])(state, d, data[d]);
|
|
1019
|
+
}
|
|
1020
|
+
return mkReadonly(state);
|
|
1021
|
+
}
|
|
1022
|
+
function mkReadonly(v) {
|
|
1023
|
+
if (Object.isFrozen(v)) {
|
|
1024
|
+
return v;
|
|
1025
|
+
}
|
|
1026
|
+
if ((0, lodash_isplainobject_1["default"])(v) || Array.isArray(v)) {
|
|
1027
|
+
for (var k in v) {
|
|
1028
|
+
v[k] = mkReadonly(v[k]);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return Object.freeze(v);
|
|
1032
|
+
}
|
|
1033
|
+
function runPrehook(prehooks, name, args) {
|
|
1034
|
+
if (!(name in prehooks)) {
|
|
1035
|
+
return true;
|
|
1036
|
+
}
|
|
1037
|
+
var res = prehooks[name].apply(prehooks, _toConsumableArray(args));
|
|
1038
|
+
if (!(0, lodash_isboolean_1["default"])(res)) {
|
|
1039
|
+
throw new TypeError("`".concat(name, "` prehook must return a boolean value."));
|
|
1040
|
+
}
|
|
1041
|
+
return res;
|
|
1042
|
+
}
|
|
1043
|
+
function invokable(method, context) {
|
|
1044
|
+
return function () {
|
|
1045
|
+
if (!this.closed) {
|
|
1046
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
|
|
1047
|
+
args[_key3] = arguments[_key3];
|
|
1048
|
+
}
|
|
1049
|
+
return method.apply(this, args);
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
function streamable(method, context) {
|
|
1054
|
+
return function () {
|
|
1055
|
+
if (this.streaming) {
|
|
1056
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
|
|
1057
|
+
args[_key4] = arguments[_key4];
|
|
1058
|
+
}
|
|
1059
|
+
return method.apply(this, args);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
}
|