@webkrafters/react-eagleeye 1.1.0-alpha.8 → 1.1.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.
@@ -146,7 +146,7 @@ var ObservableContext = exports.ObservableContext = /*#__PURE__*/function (_Abst
146
146
  return function () {
147
147
  return channel.endStream();
148
148
  };
149
- }, [channel]);
149
+ }, []);
150
150
  return store;
151
151
  };
152
152
  }
@@ -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>;
@@ -110,7 +112,7 @@ export declare class ObservableUniverse<T extends State> {
110
112
  provide<const ID extends string>(props?: ProviderProps<T, ID>): Point<T, ID>;
111
113
  provide<const ID extends string>(props?: ProviderPropsRaw<T, ID>): Point<T, ID>;
112
114
  provide<const ID extends string>(props?: ProviderPropsPrimitive<T, ID>): Point<T, ID>;
113
- secureResourceMapFor(requestor: Utility<T>): ObsResource<AbstractObservable<any>>;
115
+ secureResourceMapFor(requestor: Utility<T>): ObsResource<AbstractObservable<T>>;
114
116
  stream<const S extends SelectorMap>(selectorMap?: S): {
115
117
  into<P>(WrappedComponent: ComponentType<Store<T, S> & P>): FC<P>;
116
118
  };
@@ -123,11 +123,22 @@ var StreamerHandle = /*#__PURE__*/function () {
123
123
  }, {
124
124
  key: "dec",
125
125
  value: function dec() {
126
- if (!this.isValid) {
126
+ if (this.size < 1) {
127
127
  return;
128
128
  }
129
129
  this._entry.numConnections--;
130
- if (this.size) {
130
+ this.release();
131
+ }
132
+ }, {
133
+ key: "inc",
134
+ value: function inc() {
135
+ this.isValid && this._entry.numConnections++;
136
+ }
137
+ }, {
138
+ key: "release",
139
+ value: function release() {
140
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
141
+ if (!force && this.size > 0) {
131
142
  return;
132
143
  }
133
144
  this.resource.endStream();
@@ -135,11 +146,6 @@ var StreamerHandle = /*#__PURE__*/function () {
135
146
  this._entry.channel = null;
136
147
  this._chs.finalize(this._sMapHash);
137
148
  }
138
- }, {
139
- key: "inc",
140
- value: function inc() {
141
- this.isValid && this._entry.numConnections++;
142
- }
143
149
  }]);
144
150
  }();
145
151
  var AbstractResource = /*#__PURE__*/function () {
@@ -340,7 +346,7 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
340
346
  value: function defineProvider() {
341
347
  var me = this;
342
348
  function provide() {
343
- var _props$observableConf, _props$observableConf2, _props$observableConf3;
349
+ var _props$observableConf, _props$observableConf2, _props$observableConf3, _props$ref$current;
344
350
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
345
351
  var id = (0, _react.useRef)(null);
346
352
  (0, _react.useMemo)(function () {
@@ -377,12 +383,13 @@ var ObservableUniverse = exports.ObservableUniverse = /*#__PURE__*/function () {
377
383
  connection.disconnect();
378
384
  ctx.store.setState(value);
379
385
  }, [(_props$observableConf = props.observableConfig) === null || _props$observableConf === void 0 ? void 0 : _props$observableConf.value, props.targetId, props.observable, (_props$observableConf2 = props.observableConfig) === null || _props$observableConf2 === void 0 ? void 0 : _props$observableConf2.prehooks, (_props$observableConf3 = props.observableConfig) === null || _props$observableConf3 === void 0 ? void 0 : _props$observableConf3.storage]);
380
- (0, _react.useImperativeHandle)(props.ref, function () {
381
- var _props$ref$current;
382
- var c = (_props$ref$current = props.ref.current) !== null && _props$ref$current !== void 0 ? _props$ref$current : {};
383
- c.targetId = id.current;
384
- return c;
385
- }, [id.current]);
386
+ if ('ref' in props && ((_props$ref$current = props.ref.current) === null || _props$ref$current === void 0 ? void 0 : _props$ref$current.targetId) !== id.current) {
387
+ if (!props.ref.current) {
388
+ props.ref.current = {};
389
+ }
390
+ ;
391
+ props.ref.current.targetId = id.current;
392
+ }
386
393
  var Context = me._context;
387
394
  return (0, _jsxRuntime.jsx)(Context, {
388
395
  value: id.current,
package/package.json CHANGED
@@ -54,7 +54,6 @@
54
54
  "lodash.isobject": "^3.0.2",
55
55
  "lodash.isplainobject": "^4.0.6",
56
56
  "lodash.omit": "^4.5.0",
57
- "npm": "^4.0.6",
58
57
  "react": "^19.2.3",
59
58
  "react-dom": "^19.2.3",
60
59
  "setimmediate": "^1.0.5",
@@ -120,15 +119,16 @@
120
119
  },
121
120
  "scripts": {
122
121
  "build": "eslint --fix && rm -rf dist && tsc && babel dist -d dist",
122
+ "pack": "npm run build && npm pack",
123
123
  "test": "eslint --fix && jest --coverage --updateSnapshot",
124
124
  "test:clean": "jest --clearCache",
125
125
  "test:core": "jest --updateSnapshot",
126
126
  "test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
127
127
  },
128
128
  "types": "dist/index.d.ts",
129
- "version": "1.1.0-alpha.8",
129
+ "version": "1.1.0",
130
130
  "dependencies": {
131
- "@webkrafters/eagleeye": "^1.0.8",
131
+ "@webkrafters/eagleeye": "^1.0.11",
132
132
  "js-sha512": "^0.9.0",
133
133
  "safe-stable-stringify": "^2.5.0"
134
134
  }