@webkrafters/react-eagleeye 1.1.0-alpha.19 → 1.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/index.js +1 -7
- package/dist/main/universe/index.js +28 -30
- package/package.json +1 -1
package/dist/main/index.js
CHANGED
|
@@ -134,16 +134,10 @@ var ObservableContext = exports.ObservableContext = /*#__PURE__*/function (_Abst
|
|
|
134
134
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
135
135
|
store = _useState4[0],
|
|
136
136
|
setStore = _useState4[1];
|
|
137
|
-
var mounted = (0, _react.useRef)(false);
|
|
138
137
|
(0, _react.useEffect)(function () {
|
|
139
138
|
channel.selectorMap = selectorMap;
|
|
140
139
|
}, [selectorMap]);
|
|
141
140
|
(0, _react.useEffect)(function () {
|
|
142
|
-
if (mounted.current) {
|
|
143
|
-
setStore(makeStore(channel));
|
|
144
|
-
} else {
|
|
145
|
-
mounted.current = true;
|
|
146
|
-
}
|
|
147
141
|
channel.addListener('data-changed', function () {
|
|
148
142
|
return setStore(_objectSpread(_objectSpread({}, store), {}, {
|
|
149
143
|
data: channel.data
|
|
@@ -152,7 +146,7 @@ var ObservableContext = exports.ObservableContext = /*#__PURE__*/function (_Abst
|
|
|
152
146
|
return function () {
|
|
153
147
|
return channel.endStream();
|
|
154
148
|
};
|
|
155
|
-
}, [
|
|
149
|
+
}, []);
|
|
156
150
|
return store;
|
|
157
151
|
};
|
|
158
152
|
}
|
|
@@ -399,26 +399,13 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
399
399
|
value: function defineStreamHook() {
|
|
400
400
|
var _this4 = this;
|
|
401
401
|
return function (selectorMap) {
|
|
402
|
+
var mounted = (0, _react.useRef)(false);
|
|
403
|
+
var targetId = (0, _react.use)(_this4._context);
|
|
402
404
|
var _useState = (0, _react.useState)(function () {
|
|
403
|
-
return _this4._util.hashSelectorMap(selectorMap);
|
|
405
|
+
return getStreamHandle(_this4._obs.createHandleFor(targetId), selectorMap, _this4._util.hashSelectorMap(selectorMap));
|
|
404
406
|
}),
|
|
405
|
-
_useState2 = _slicedToArray(_useState,
|
|
406
|
-
|
|
407
|
-
updateSMapHash = _useState2[1];
|
|
408
|
-
(0, _react.useEffect)(function () {
|
|
409
|
-
return updateSMapHash(_this4._util.hashSelectorMap(selectorMap));
|
|
410
|
-
}, [selectorMap]);
|
|
411
|
-
var targetId = (0, _react.use)(_this4._context);
|
|
412
|
-
var handle = (0, _react.useMemo)(function () {
|
|
413
|
-
var ctxHandle = _this4._obs.createHandleFor(targetId);
|
|
414
|
-
var streamHandle = ctxHandle.getChannelHandleAt(sMapHash);
|
|
415
|
-
if (!streamHandle.isValid) {
|
|
416
|
-
ctxHandle.addChannelAt(sMapHash, ctxHandle.resource.stream(selectorMap));
|
|
417
|
-
streamHandle = ctxHandle.getChannelHandleAt(sMapHash);
|
|
418
|
-
}
|
|
419
|
-
return streamHandle;
|
|
420
|
-
}, [sMapHash, targetId]);
|
|
421
|
-
var mounted = (0, _react.useRef)(false);
|
|
407
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
408
|
+
handle = _useState2[0];
|
|
422
409
|
var _useState3 = (0, _react.useState)(getCurrentUri),
|
|
423
410
|
_useState4 = _slicedToArray(_useState3, 1),
|
|
424
411
|
currentUri = _useState4[0];
|
|
@@ -429,12 +416,17 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
429
416
|
store = _useState6[0],
|
|
430
417
|
setStore = _useState6[1];
|
|
431
418
|
(0, _react.useEffect)(function () {
|
|
432
|
-
|
|
419
|
+
if (!mounted.current) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
throw new Error('Selector map change not supported in SSR Mode.');
|
|
423
|
+
}, [selectorMap]);
|
|
424
|
+
(0, _react.useEffect)(function () {
|
|
433
425
|
if (mounted.current) {
|
|
434
|
-
|
|
435
|
-
} else {
|
|
436
|
-
mounted.current = true;
|
|
426
|
+
return;
|
|
437
427
|
}
|
|
428
|
+
mounted.current = true;
|
|
429
|
+
var channel = handle.resource;
|
|
438
430
|
var fn = function fn() {
|
|
439
431
|
return setStore(_objectSpread(_objectSpread({}, store), {}, {
|
|
440
432
|
data: channel.data
|
|
@@ -445,20 +437,14 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
445
437
|
return function () {
|
|
446
438
|
channel.removeListener('data-changed', fn);
|
|
447
439
|
handle.dec();
|
|
448
|
-
|
|
449
|
-
currentUri === uri && handle.release();
|
|
450
|
-
currentUri = uri;
|
|
440
|
+
currentUri === getCurrentUri() && handle.release();
|
|
451
441
|
};
|
|
452
|
-
}, [
|
|
442
|
+
}, []);
|
|
453
443
|
return store;
|
|
454
444
|
};
|
|
455
445
|
}
|
|
456
446
|
}]);
|
|
457
447
|
}();
|
|
458
|
-
function getCurrentUri() {
|
|
459
|
-
var _globalThis$location;
|
|
460
|
-
return (_globalThis$location = globalThis.location) === null || _globalThis$location === void 0 ? void 0 : _globalThis$location.pathname;
|
|
461
|
-
}
|
|
462
448
|
var Utility = exports.Utility = /*#__PURE__*/function () {
|
|
463
449
|
function Utility(context) {
|
|
464
450
|
_classCallCheck(this, Utility);
|
|
@@ -522,4 +508,16 @@ var Utility = exports.Utility = /*#__PURE__*/function () {
|
|
|
522
508
|
}();
|
|
523
509
|
function createContext() {
|
|
524
510
|
return new ObservableUniverse();
|
|
511
|
+
}
|
|
512
|
+
function getCurrentUri() {
|
|
513
|
+
var _globalThis$location;
|
|
514
|
+
return (_globalThis$location = globalThis.location) === null || _globalThis$location === void 0 ? void 0 : _globalThis$location.pathname;
|
|
515
|
+
}
|
|
516
|
+
function getStreamHandle(contextHandle, selectorMap, sMapHash) {
|
|
517
|
+
var streamHandle = contextHandle.getChannelHandleAt(sMapHash);
|
|
518
|
+
if (!streamHandle.isValid) {
|
|
519
|
+
contextHandle.addChannelAt(sMapHash, contextHandle.resource.stream(selectorMap));
|
|
520
|
+
streamHandle = contextHandle.getChannelHandleAt(sMapHash);
|
|
521
|
+
}
|
|
522
|
+
return streamHandle;
|
|
525
523
|
}
|
package/package.json
CHANGED
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
|
|
127
127
|
},
|
|
128
128
|
"types": "dist/index.d.ts",
|
|
129
|
-
"version": "1.1.0-alpha.
|
|
129
|
+
"version": "1.1.0-alpha.20",
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@webkrafters/eagleeye": "^1.0.8",
|
|
132
132
|
"js-sha512": "^0.9.0",
|