Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ably

Package Overview
Dependencies
Maintainers
2
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ably - npm Package Compare versions

Comparing version 1.2.45 to 1.2.46

4

package.json
{
"name": "ably",
"description": "Realtime client library for Ably, the realtime messaging service",
"version": "1.2.45",
"version": "1.2.46",
"license": "Apache-2.0",

@@ -32,3 +32,3 @@ "bugs": {

"got": "^11.8.5",
"ws": "^5.1"
"ws": "^8.14.2"
},

@@ -35,0 +35,0 @@ "peerDependencies": {

@@ -15,2 +15,6 @@ 'use strict';

var ErrorInfo = function(message, code, statusCode, cause) {
return new Ably.ErrorInfo(message, code, statusCode, cause);
}
var RestPromise = function (options) {

@@ -27,5 +31,5 @@ return new Ably.Rest(promisifyOptions(options));

module.exports = {
ErrorInfo: Ably.ErrorInfo,
ErrorInfo: ErrorInfo,
Rest: RestPromise,
Realtime: RealtimePromise,
};

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

const react_1 = __importStar(require("react"));
const version = '1.2.45';
const canUseSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function';

@@ -41,3 +40,2 @@ exports.contextKey = canUseSymbol ? Symbol.for('__ABLY_CONTEXT__') : '__ABLY_CONTEXT__';

exports.getContext = getContext;
let hasSentAgent = false;
const AblyProvider = ({ client, children, id = 'default' }) => {

@@ -56,10 +54,2 @@ var _a;

}
react_1.default.useEffect(() => {
if (!hasSentAgent) {
hasSentAgent = true;
realtime.request('GET', '/time', null, null, {
'Ably-Agent': `react-hooks-time-ping/${version}`,
});
}
});
return (0, jsx_runtime_1.jsx)(context.Provider, Object.assign({ value: realtime }, { children: children }));

@@ -66,0 +56,0 @@ };

@@ -16,1 +16,9 @@ import { Types } from '../../../../ably.js';

export declare type ChannelParameters = string | ChannelNameAndOptions;
export declare const version = "1.2.46";
export declare function channelOptionsWithAgent(options?: Types.ChannelOptions): {
params: {
agent: string;
};
cipher?: Types.CipherParamOptions | Types.CipherParams;
modes?: Types.ChannelModes;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.channelOptionsWithAgent = exports.version = void 0;
exports.version = '1.2.46';
function channelOptionsWithAgent(options) {
return Object.assign(Object.assign({}, options), { params: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.params), { agent: `react-hooks/${exports.version}` }) });
}
exports.channelOptionsWithAgent = channelOptionsWithAgent;
//# sourceMappingURL=AblyReactHooks.js.map

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

const react_1 = require("react");
const AblyReactHooks_js_1 = require("../AblyReactHooks.js");
const useAbly_js_1 = require("./useAbly.js");

@@ -27,7 +28,7 @@ const useStateErrors_js_1 = require("./useStateErrors.js");

const ablyMessageCallbackRef = (0, react_1.useRef)(ablyMessageCallback);
const channel = (0, react_1.useMemo)(() => ably.channels.get(channelName, channelOptionsRef.current), [ably, channelName]);
const channel = (0, react_1.useMemo)(() => ably.channels.get(channelName, (0, AblyReactHooks_js_1.channelOptionsWithAgent)(channelOptionsRef.current)), [ably, channelName]);
const { connectionError, channelError } = (0, useStateErrors_js_1.useStateErrors)(channelHookOptions);
(0, react_1.useEffect)(() => {
if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions(channelOptions);
channel.setOptions((0, AblyReactHooks_js_1.channelOptionsWithAgent)(channelOptions));
}

@@ -34,0 +35,0 @@ channelOptionsRef.current = channelOptions;

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

const react_1 = require("react");
const AblyReactHooks_js_1 = require("../AblyReactHooks.js");
const useAbly_js_1 = require("./useAbly.js");

@@ -23,5 +24,13 @@ const useStateErrors_js_1 = require("./useStateErrors.js");

const subscribeOnly = typeof channelNameOrNameAndOptions === 'string' ? false : params.subscribeOnly;
const channel = ably.channels.get(params.channelName, params.options);
const channelOptions = params.options;
const channelOptionsRef = (0, react_1.useRef)(channelOptions);
const channel = (0, react_1.useMemo)(() => ably.channels.get(params.channelName, (0, AblyReactHooks_js_1.channelOptionsWithAgent)(channelOptionsRef.current)), [ably, params.channelName]);
const skip = params.skip;
const { connectionError, channelError } = (0, useStateErrors_js_1.useStateErrors)(params);
(0, react_1.useEffect)(() => {
if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions((0, AblyReactHooks_js_1.channelOptionsWithAgent)(channelOptions));
}
channelOptionsRef.current = channelOptions;
}, [channel, channelOptions]);
const [presenceData, updatePresenceData] = (0, react_1.useState)([]);

@@ -28,0 +37,0 @@ const updatePresence = (message) => __awaiter(this, void 0, void 0, function* () {

@@ -19,3 +19,3 @@ "use strict";

setConnectionError(null);
});
}, params.id);
(0, useChannelStateListener_js_1.useChannelStateListener)(params, ['suspended', 'failed', 'detached'], (stateChange) => {

@@ -22,0 +22,0 @@ var _a;

@@ -6,3 +6,2 @@ import { jsx as _jsx } from "react/jsx-runtime";

import React, { useMemo } from 'react';
const version = '1.2.45';
const canUseSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function';

@@ -14,3 +13,2 @@ export const contextKey = canUseSymbol ? Symbol.for('__ABLY_CONTEXT__') : '__ABLY_CONTEXT__';

}
let hasSentAgent = false;
export const AblyProvider = ({ client, children, id = 'default' }) => {

@@ -29,12 +27,4 @@ var _a;

}
React.useEffect(() => {
if (!hasSentAgent) {
hasSentAgent = true;
realtime.request('GET', '/time', null, null, {
'Ably-Agent': `react-hooks-time-ping/${version}`,
});
}
});
return _jsx(context.Provider, Object.assign({ value: realtime }, { children: children }));
};
//# sourceMappingURL=AblyProvider.js.map

@@ -16,1 +16,9 @@ import { Types } from '../../../../ably.js';

export declare type ChannelParameters = string | ChannelNameAndOptions;
export declare const version = "1.2.46";
export declare function channelOptionsWithAgent(options?: Types.ChannelOptions): {
params: {
agent: string;
};
cipher?: Types.CipherParamOptions | Types.CipherParams;
modes?: Types.ChannelModes;
};

@@ -1,2 +0,5 @@

export {};
export const version = '1.2.46';
export function channelOptionsWithAgent(options) {
return Object.assign(Object.assign({}, options), { params: Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.params), { agent: `react-hooks/${version}` }) });
}
//# sourceMappingURL=AblyReactHooks.js.map

@@ -11,2 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { useEffect, useMemo, useRef } from 'react';
import { channelOptionsWithAgent } from '../AblyReactHooks.js';
import { useAbly } from './useAbly.js';

@@ -24,7 +25,7 @@ import { useStateErrors } from './useStateErrors.js';

const ablyMessageCallbackRef = useRef(ablyMessageCallback);
const channel = useMemo(() => ably.channels.get(channelName, channelOptionsRef.current), [ably, channelName]);
const channel = useMemo(() => ably.channels.get(channelName, channelOptionsWithAgent(channelOptionsRef.current)), [ably, channelName]);
const { connectionError, channelError } = useStateErrors(channelHookOptions);
useEffect(() => {
if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions(channelOptions);
channel.setOptions(channelOptionsWithAgent(channelOptions));
}

@@ -31,0 +32,0 @@ channelOptionsRef.current = channelOptions;

@@ -10,3 +10,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { useCallback, useEffect, useState } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { channelOptionsWithAgent } from '../AblyReactHooks.js';
import { useAbly } from './useAbly.js';

@@ -20,5 +21,13 @@ import { useStateErrors } from './useStateErrors.js';

const subscribeOnly = typeof channelNameOrNameAndOptions === 'string' ? false : params.subscribeOnly;
const channel = ably.channels.get(params.channelName, params.options);
const channelOptions = params.options;
const channelOptionsRef = useRef(channelOptions);
const channel = useMemo(() => ably.channels.get(params.channelName, channelOptionsWithAgent(channelOptionsRef.current)), [ably, params.channelName]);
const skip = params.skip;
const { connectionError, channelError } = useStateErrors(params);
useEffect(() => {
if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions(channelOptionsWithAgent(channelOptions));
}
channelOptionsRef.current = channelOptions;
}, [channel, channelOptions]);
const [presenceData, updatePresenceData] = useState([]);

@@ -25,0 +34,0 @@ const updatePresence = (message) => __awaiter(this, void 0, void 0, function* () {

@@ -16,3 +16,3 @@ import { useState } from 'react';

setConnectionError(null);
});
}, params.id);
useChannelStateListener(params, ['suspended', 'failed', 'detached'], (stateChange) => {

@@ -19,0 +19,0 @@ var _a;

@@ -270,3 +270,3 @@ # [Ably](https://www.ably.com)

channel.presence.enterClient('myClientId', 'status', function(err) { ... });
// and similiarly, updateClient and leaveClient
// and similarly, updateClient and leaveClient
```

@@ -273,0 +273,0 @@

@@ -188,3 +188,16 @@ import ProtocolMessage from '../types/protocolmessage';

_shouldReattachToSetOptions(options?: API.Types.ChannelOptions) {
return (this.state === 'attached' || this.state === 'attaching') && (options?.params || options?.modes);
if (!(this.state === 'attached' || this.state === 'attaching')) {
return false;
}
if (options?.params) {
if (!this.params || !Utils.shallowEquals(this.params, options.params)) {
return true;
}
}
if (options?.modes) {
if (!this.modes || !Utils.arrEquals(options.modes, this.modes)) {
return true;
}
}
return false;
}

@@ -191,0 +204,0 @@

@@ -226,6 +226,4 @@ import * as Utils from '../util/utils';

);
const presence = PresenceMessage.fromValues({
action: 'leave',
data: data,
});
const presence = PresenceMessage.fromData(data);
presence.action = 'leave';
if (clientId) {

@@ -232,0 +230,0 @@ presence.clientId = clientId;

@@ -321,6 +321,6 @@ import Platform from 'common/platform';

export const arrEvery = (Array.prototype.every as unknown)
? function <T>(arr: Array<T>, fn: (value: T, index?: number, arr?: Array<T>) => boolean) {
? function <T>(arr: Array<T>, fn: (value: T, index: number, arr: Array<T>) => boolean) {
return arr.every(fn);
}
: function <T>(arr: Array<T>, fn: (value: T, index?: number, arr?: Array<T>) => boolean) {
: function <T>(arr: Array<T>, fn: (value: T, index: number, arr: Array<T>) => boolean) {
const len = arr.length;

@@ -608,1 +608,10 @@ for (let i = 0; i < len; i++) {

}
export function arrEquals(a: any[], b: any[]) {
return (
a.length === b.length &&
arrEvery(a, function (val, i) {
return val === b[i];
})
);
}

@@ -19,1 +19,13 @@ import { Types } from '../../../../ably.js';

export type ChannelParameters = string | ChannelNameAndOptions;
export const version = '1.2.46';
export function channelOptionsWithAgent(options?: Types.ChannelOptions) {
return {
...options,
params: {
...options?.params,
agent: `react-hooks/${version}`,
},
};
}
import { Types } from '../../../../../ably.js';
import { useEffect, useMemo, useRef } from 'react';
import { ChannelParameters } from '../AblyReactHooks.js';
import { channelOptionsWithAgent, ChannelParameters } from '../AblyReactHooks.js';
import { useAbly } from './useAbly.js';

@@ -48,3 +48,6 @@ import { useStateErrors } from './useStateErrors.js';

const channel = useMemo(() => ably.channels.get(channelName, channelOptionsRef.current), [ably, channelName]);
const channel = useMemo(
() => ably.channels.get(channelName, channelOptionsWithAgent(channelOptionsRef.current)),
[ably, channelName]
);

@@ -55,3 +58,3 @@ const { connectionError, channelError } = useStateErrors(channelHookOptions);

if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions(channelOptions);
channel.setOptions(channelOptionsWithAgent(channelOptions));
}

@@ -58,0 +61,0 @@ channelOptionsRef.current = channelOptions;

import { Types } from '../../../../../ably.js';
import { useCallback, useEffect, useState } from 'react';
import { ChannelParameters } from '../AblyReactHooks.js';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { channelOptionsWithAgent, ChannelParameters } from '../AblyReactHooks.js';
import { useAbly } from './useAbly.js';

@@ -31,3 +31,9 @@ import { useStateErrors } from './useStateErrors.js';

const channel = ably.channels.get(params.channelName, params.options);
const channelOptions = params.options;
const channelOptionsRef = useRef(channelOptions);
const channel = useMemo(
() => ably.channels.get(params.channelName, channelOptionsWithAgent(channelOptionsRef.current)),
[ably, params.channelName]
);
const skip = params.skip;

@@ -37,2 +43,9 @@

useEffect(() => {
if (channelOptionsRef.current !== channelOptions && channelOptions) {
channel.setOptions(channelOptionsWithAgent(channelOptions));
}
channelOptionsRef.current = channelOptions;
}, [channel, channelOptions]);
const [presenceData, updatePresenceData] = useState<Array<PresenceMessage<T>>>([]);

@@ -39,0 +52,0 @@

@@ -22,5 +22,9 @@ import { Types } from '../../../../../ably.js';

useConnectionStateListener(['connected', 'closed'], () => {
setConnectionError(null);
});
useConnectionStateListener(
['connected', 'closed'],
() => {
setConnectionError(null);
},
params.id
);

@@ -27,0 +31,0 @@ useChannelStateListener(params, ['suspended', 'failed', 'detached'], (stateChange) => {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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