@webkrafters/react-eagleeye 1.1.0-alpha.18 → 1.1.0-alpha.19
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.
|
@@ -40,6 +40,7 @@ interface Entry {
|
|
|
40
40
|
}
|
|
41
41
|
interface Handle<W extends WeakKey> {
|
|
42
42
|
readonly resource: W;
|
|
43
|
+
release(force: boolean): void;
|
|
43
44
|
}
|
|
44
45
|
declare class ObserverHandle<W extends AbstractObservable<ObservableTemplate<W>>> implements Handle<W> {
|
|
45
46
|
private _wObs;
|
|
@@ -63,6 +64,7 @@ declare class StreamerHandle<W extends Channel> implements Handle<W> {
|
|
|
63
64
|
get size(): number;
|
|
64
65
|
dec(): void;
|
|
65
66
|
inc(): void;
|
|
67
|
+
release(force?: boolean): void;
|
|
66
68
|
}
|
|
67
69
|
interface IResource<W extends WeakKey> {
|
|
68
70
|
acquire(desc: string, resource: W): Handle<W>;
|
|
@@ -123,27 +123,25 @@ var StreamerHandle = /*#__PURE__*/function () {
|
|
|
123
123
|
}, {
|
|
124
124
|
key: "dec",
|
|
125
125
|
value: function dec() {
|
|
126
|
-
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this._entry.numConnections--;
|
|
130
|
-
if (this.size) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
this._chs.finalizer.unregister(this.resource);
|
|
134
|
-
var channel = this._entry.channel;
|
|
135
|
-
this._entry.channel = null;
|
|
136
|
-
this._chs.finalize(this._sMapHash);
|
|
137
|
-
setTimeout(function () {
|
|
138
|
-
var _channel$deref;
|
|
139
|
-
return (_channel$deref = channel.deref()) === null || _channel$deref === void 0 ? void 0 : _channel$deref.endStream();
|
|
140
|
-
}, 0);
|
|
126
|
+
this.size > 0 && this._entry.numConnections--;
|
|
141
127
|
}
|
|
142
128
|
}, {
|
|
143
129
|
key: "inc",
|
|
144
130
|
value: function inc() {
|
|
145
131
|
this.isValid && this._entry.numConnections++;
|
|
146
132
|
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "release",
|
|
135
|
+
value: function release() {
|
|
136
|
+
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
137
|
+
if (!force && this.size > 0) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.resource.endStream();
|
|
141
|
+
this._chs.finalizer.unregister(this.resource);
|
|
142
|
+
this._entry.channel = null;
|
|
143
|
+
this._chs.finalize(this._sMapHash);
|
|
144
|
+
}
|
|
147
145
|
}]);
|
|
148
146
|
}();
|
|
149
147
|
var AbstractResource = /*#__PURE__*/function () {
|
|
@@ -418,16 +416,18 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
418
416
|
ctxHandle.addChannelAt(sMapHash, ctxHandle.resource.stream(selectorMap));
|
|
419
417
|
streamHandle = ctxHandle.getChannelHandleAt(sMapHash);
|
|
420
418
|
}
|
|
421
|
-
streamHandle.inc();
|
|
422
419
|
return streamHandle;
|
|
423
420
|
}, [sMapHash, targetId]);
|
|
424
421
|
var mounted = (0, _react.useRef)(false);
|
|
425
|
-
var _useState3 = (0, _react.useState)(
|
|
422
|
+
var _useState3 = (0, _react.useState)(getCurrentUri),
|
|
423
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
424
|
+
currentUri = _useState4[0];
|
|
425
|
+
var _useState5 = (0, _react.useState)(function () {
|
|
426
426
|
return (0, _.makeStore)(handle.resource);
|
|
427
427
|
}),
|
|
428
|
-
|
|
429
|
-
store =
|
|
430
|
-
setStore =
|
|
428
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
429
|
+
store = _useState6[0],
|
|
430
|
+
setStore = _useState6[1];
|
|
431
431
|
(0, _react.useEffect)(function () {
|
|
432
432
|
var channel = handle.resource;
|
|
433
433
|
if (mounted.current) {
|
|
@@ -441,9 +441,13 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
441
441
|
}));
|
|
442
442
|
};
|
|
443
443
|
channel.addListener('data-changed', fn);
|
|
444
|
+
handle.inc();
|
|
444
445
|
return function () {
|
|
445
446
|
channel.removeListener('data-changed', fn);
|
|
446
447
|
handle.dec();
|
|
448
|
+
var uri = getCurrentUri();
|
|
449
|
+
currentUri === uri && handle.release();
|
|
450
|
+
currentUri = uri;
|
|
447
451
|
};
|
|
448
452
|
}, [handle.resource]);
|
|
449
453
|
return store;
|
|
@@ -451,6 +455,10 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
|
|
|
451
455
|
}
|
|
452
456
|
}]);
|
|
453
457
|
}();
|
|
458
|
+
function getCurrentUri() {
|
|
459
|
+
var _globalThis$location;
|
|
460
|
+
return (_globalThis$location = globalThis.location) === null || _globalThis$location === void 0 ? void 0 : _globalThis$location.pathname;
|
|
461
|
+
}
|
|
454
462
|
var Utility = exports.Utility = /*#__PURE__*/function () {
|
|
455
463
|
function Utility(context) {
|
|
456
464
|
_classCallCheck(this, Utility);
|
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.19",
|
|
130
130
|
"dependencies": {
|
|
131
131
|
"@webkrafters/eagleeye": "^1.0.8",
|
|
132
132
|
"js-sha512": "^0.9.0",
|