New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@waves.exchange/config-ws

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waves.exchange/config-ws - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

2

dist/configUpdates.d.ts

@@ -6,2 +6,3 @@ import { BehaviorSubject } from '@waves.exchange/reactive';

errorsSubject: BehaviorSubject<SocketErrorEvent>;
private readonly _topicks;
private readonly _url;

@@ -18,2 +19,3 @@ private _configWebSocket;

configUpdates(filePath: string): BehaviorSubject<ConfigState>;
destroyConfigUpdates(filePath: string, ensureConfig?: boolean): void;
private ensureConfigWebSocket;

@@ -20,0 +22,0 @@ private cleanUpConfigWebSocket;

53

dist/configUpdates.js

@@ -17,2 +17,3 @@ "use strict";

this.errorsSubject = new reactive_1.BehaviorSubject({});
this._topicks = Object.create(null);
this._isOpened = false;

@@ -36,25 +37,38 @@ this._initialValueTimers = Object.create(null);

const topic = `topic://${filePath}`;
const ws = (this._configWebSocket ||
this.ensureConfigWebSocket());
this._initialValueTimers[topic] = window.setTimeout(() => {
this.errorsSubject.next({
code: 3,
message: 'Initial value socket timeout',
params: {
if (!this._topicks[filePath]) {
const ws = (this._configWebSocket ||
this.ensureConfigWebSocket());
this._initialValueTimers[topic] = window.setTimeout(() => {
this.errorsSubject.next({
code: 3,
message: 'Initial value socket timeout',
params: {
topic
}
});
}, this._timeout.initialValue);
this._topicks[filePath] = ws.multiplex(() => ({ type: 'subscribe', topic }), () => ({ type: 'unsubscribe', topic }), (message) => message.topic === topic && (message.type === 'update' || message.type === 'subscribed')).subscribe(data => {
clearTimeout(this._initialValueTimers[topic]);
const oldConfigs = this.configSubject.getValue().configs;
this.configSubject.next({
configs: Object.assign(Object.assign({}, oldConfigs), { [filePath]: data === null || data === void 0 ? void 0 : data.value }),
type: data.type,
filePath: filePath,
topic
}
});
});
}, this._timeout.initialValue);
ws.multiplex(() => ({ type: 'subscribe', topic }), () => ({ type: 'unsubscribe', topic }), (message) => message.topic === topic && (message.type === 'update' || message.type === 'subscribed')).subscribe(data => {
clearTimeout(this._initialValueTimers[topic]);
const oldConfigs = this.configSubject.getValue().configs;
this.configSubject.next({
configs: Object.assign(Object.assign({}, oldConfigs), { [filePath]: data === null || data === void 0 ? void 0 : data.value }),
type: data.type,
filePath: filePath,
topic
});
});
}
return this.configSubject;
}
destroyConfigUpdates(filePath, ensureConfig = false) {
const values = this.configSubject.getValue();
if (this._topicks[filePath]) {
this._topicks[filePath].unsubscribe();
delete this._topicks[filePath];
}
if (!ensureConfig && values != null && values.configs != null) {
delete values.configs[filePath];
}
this.configSubject.next(values);
}
ensureConfigWebSocket() {

@@ -133,2 +147,3 @@ if (!this._configWebSocket) {

Object.keys(oldConfigs).forEach(data => {
this.destroyConfigUpdates(data, true);
this.configUpdates(data);

@@ -135,0 +150,0 @@ });

{
"name": "@waves.exchange/config-ws",
"version": "0.2.3",
"version": "0.3.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts",

@@ -20,2 +20,3 @@ import { WebSocketSubject, webSocket, BehaviorSubject } from '@waves.exchange/reactive';

private readonly _topicks = Object.create(null);
private readonly _url: string;

@@ -48,38 +49,54 @@ private _configWebSocket: WebSocketSubject<unknown> | undefined;

const topic = `topic://${filePath}`;
if (!this._topicks[filePath]) {
const ws = (
this._configWebSocket ||
this.ensureConfigWebSocket()
) as WebSocketSubject<ContentUpdate | SubscribeMessage>;
const ws = (
this._configWebSocket ||
this.ensureConfigWebSocket()
) as WebSocketSubject<ContentUpdate | SubscribeMessage>;
this._initialValueTimers[topic] = window.setTimeout(() => {
this.errorsSubject.next({
code: 3,
message: 'Initial value socket timeout',
params: {
topic
}
});
}, this._timeout.initialValue);
this._initialValueTimers[topic] = window.setTimeout(() => {
this.errorsSubject.next({
code: 3,
message: 'Initial value socket timeout',
params: {
this._topicks[filePath] = ws.multiplex(
() => ({ type: 'subscribe', topic }),
() => ({ type: 'unsubscribe', topic }),
(message): message is ContentUpdate =>
message.topic === topic && (message.type === 'update' || message.type === 'subscribed'),
).subscribe(data => {
clearTimeout(this._initialValueTimers[topic]);
const oldConfigs = this.configSubject.getValue().configs;
this.configSubject.next({
configs: {
...oldConfigs,
[filePath]: data?.value
},
type: data.type,
filePath: filePath,
topic
}
});
});
}, this._timeout.initialValue);
}
return this.configSubject;
}
ws.multiplex(
() => ({ type: 'subscribe', topic }),
() => ({ type: 'unsubscribe', topic }),
(message): message is ContentUpdate =>
message.topic === topic && (message.type === 'update' || message.type === 'subscribed'),
).subscribe(data => {
clearTimeout(this._initialValueTimers[topic]);
const oldConfigs = this.configSubject.getValue().configs;
this.configSubject.next({
configs: {
...oldConfigs,
[filePath]: data?.value
},
type: data.type,
filePath: filePath,
topic
});
});
public destroyConfigUpdates(filePath: string, ensureConfig = false): void {
const values = this.configSubject.getValue();
return this.configSubject;
if (this._topicks[filePath]) {
this._topicks[filePath].unsubscribe();
delete this._topicks[filePath];
}
if (!ensureConfig && values != null && values.configs != null) {
delete values.configs[filePath];
}
this.configSubject.next(values);
}

@@ -167,2 +184,3 @@

Object.keys(oldConfigs).forEach(data => {
this.destroyConfigUpdates(data, true);
this.configUpdates(data);

@@ -169,0 +187,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc