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

@alwatr/signal

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alwatr/signal - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

88

CHANGELOG.md

@@ -6,6 +6,90 @@ # Change Log

## [1.0.1](https://github.com/AliMD/alwatr/compare/v1.0.0...v1.0.1) (2023-06-21)
# 1.1.0 (2023-09-12)
**Note:** Version bump only for package @alwatr/signal
# 1.0.0 (2023-06-14)
# 0.32.0 (2023-05-27)
# 0.31.0 (2023-05-08)
### Bug Fixes
* new logger api ([9d83a7d](https://github.com/AliMD/alwatr/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
* **signal:** dont receivePrevious when listener is disabled ([68ae207](https://github.com/AliMD/alwatr/commit/68ae207ce9ecf104922b24910d8dfcedb13acde7))
* **signal:** requestableContextProvider.getValue ([0a7111d](https://github.com/AliMD/alwatr/commit/0a7111da7b8eb004566922dc9b35edfc02a55147))
### Features
* **signal:** new RequestableContext with state ([b8a8e55](https://github.com/AliMD/alwatr/commit/b8a8e550d3952863d85ba9d9d87513a668a9430d))
# 0.30.0 (2023-03-06)
### Bug Fixes
* **signal:** NextCycle with own detail ([01f3c79](https://github.com/AliMD/alwatr/commit/01f3c79500927f6384a33abcc9b0cb2355794b3e))
* **signal:** nodejs compatibility ([69d8a60](https://github.com/AliMD/alwatr/commit/69d8a60ad64d44ee7c3ced002e702f13408a5a50))
* **signal:** requestableContextConsumer bind issue ([66467f6](https://github.com/AliMD/alwatr/commit/66467f6e5681d84d7f2e0b353206d4bb579b26f2))
* **signal:** requestContext dispatch issue ([e937ebd](https://github.com/AliMD/alwatr/commit/e937ebd3a90fc6a9946f5c35ef4f6f40b6ab4b00))
### Features
* **signal:** add untilChange for contextProvider ([cb44916](https://github.com/AliMD/alwatr/commit/cb4491698fd5ddfbe055032fc2cb50691de31194))
* **signal:** defineCommand return ListenerSpec ([21fecac](https://github.com/AliMD/alwatr/commit/21fecacb6aa9423da9e3c177a4bbc59952d94e35))
* **signal:** dispatch NextCycle option ([b30eb31](https://github.com/AliMD/alwatr/commit/b30eb316d92f594034fc40d195c4033e38e4d2e2))
# 0.29.0 (2023-02-10)
### Bug Fixes
* **signal/core:** _getSignalObject ([1374188](https://github.com/AliMD/alwatr/commit/1374188bdc7e689ded11d04bf4588a1162cc6d86))
* **signal:** alert [#1455](https://github.com/AliMD/alwatr/issues/1455) ([203307d](https://github.com/AliMD/alwatr/commit/203307df308a12e6c38cb9e0e2301b2015b6ff45))
* **signal:** clean old interfaces ([b2987ad](https://github.com/AliMD/alwatr/commit/b2987add7bfe0cf609fa355403fb9fb5de3f6b8a))
* **signal:** export all interfaces ([8704eac](https://github.com/AliMD/alwatr/commit/8704eac6ae7a8a45e77c24ef5e602e36af3fd21e))
* **signal:** export listeners ([fb05bfb](https://github.com/AliMD/alwatr/commit/fb05bfb9b7eb30427442783677ce1d4da5401160))
* **signal:** import types ([cc0b88b](https://github.com/AliMD/alwatr/commit/cc0b88be420b1fe057a8640bbffb1af3bf327cef))
* **signal:** interface bind type ([7b6c820](https://github.com/AliMD/alwatr/commit/7b6c820da2ba216f36e089bf79bdeccf208df3b1))
* **signal:** reported issues ([75f688f](https://github.com/AliMD/alwatr/commit/75f688faf96a056a256603d05276f5731db86aee))
* **signal:** TSignal on SignalControllerInterface ([ac42b7c](https://github.com/AliMD/alwatr/commit/ac42b7c7023549e8dd07cd3d9e189f356ffa06ee))
### Features
* **signal-manager:** enhance provider, docs ([c4583a3](https://github.com/AliMD/alwatr/commit/c4583a3b0fcbf38b5e426aaa2bc6e0f52ccac5fd))
* **signal:** alias in SignalInterface & BoundSignalInterface ([053030b](https://github.com/AliMD/alwatr/commit/053030b96c09d474794f32327d892f1d3690656c))
* **signal:** bind signal ([de49a13](https://github.com/AliMD/alwatr/commit/de49a13eaffce31660849dfc63285d97e9098c0c))
* **signal:** command handler/provider interface ([3d23683](https://github.com/AliMD/alwatr/commit/3d236837e13d8cfdcd44a1570bdc9659f48e7f47))
* **signal:** command signals ([98c1d90](https://github.com/AliMD/alwatr/commit/98c1d90978329e4c5c584e19edb1aaa365632162))
* **signal:** command trigger interface ([dda9466](https://github.com/AliMD/alwatr/commit/dda94666d9e8e490fea26038044df0e67c203583))
* **signal:** commandSignal ([5a0d7e5](https://github.com/AliMD/alwatr/commit/5a0d7e5498087620d28548ea5d90036a7b17483a))
* **signal:** context prover and consumer ([081a51a](https://github.com/AliMD/alwatr/commit/081a51a1ee88e66ebbcd0c58186c00a6aa9e1032))
* **signal:** contextProvider.expire ([7d0ce93](https://github.com/AliMD/alwatr/commit/7d0ce937f0eadcd9019e6047fbe07aa1a3b579a7))
* **signal:** event listener interface ([4ca4079](https://github.com/AliMD/alwatr/commit/4ca407938d444027cdbd435173c875fdd9ce8e28))
* **signal:** event trigger interface ([9b90597](https://github.com/AliMD/alwatr/commit/9b905979a5065640981433ec7d120ba2494966bb))
* **signal:** new contextConsumer interface ([9ee4a62](https://github.com/AliMD/alwatr/commit/9ee4a624211adb66d9c3d180470cca44ed7df382))
* **signal:** new contextProvider interface ([e5d29eb](https://github.com/AliMD/alwatr/commit/e5d29ebaa75d71bb5a87bedddb2be7600e68b210))
* **signal:** new manager interface ([f028306](https://github.com/AliMD/alwatr/commit/f028306f4d7932df65a1bbeade0d29377a370e2e))
* **signal:** new requestable context consumer interface ([bf6845f](https://github.com/AliMD/alwatr/commit/bf6845f35a98bb63bcfa42196c2f977d64aea59e))
* **signal:** new requestable context provider interface ([2c8d576](https://github.com/AliMD/alwatr/commit/2c8d57604dcb07a2831d85d4ef1e262863a5fae8))
* **signal:** new signal dynamic types ([0f1a38e](https://github.com/AliMD/alwatr/commit/0f1a38e356ab73e4e2e1a8f852585e50e86cff0e))
* **signal:** new simple api ([eb1e478](https://github.com/AliMD/alwatr/commit/eb1e47892d4478fb6c687f6d15e1a5c204b5666c))
* **signal:** refactor all generic types with Stringifyable ([bdcef63](https://github.com/AliMD/alwatr/commit/bdcef632c81fa5e7c7ae595a7a77092c53821850))
* **signal:** separate request command with response ([47a779e](https://github.com/AliMD/alwatr/commit/47a779e9a814d5d6a388f1a3e94c23e7fb977dce))
* **signal:** signal.request ([d791b3e](https://github.com/AliMD/alwatr/commit/d791b3eef846697020b76bfecfbf25a3e31eb3a5))
* **signal:** signal.untilNext ([9df78c0](https://github.com/AliMD/alwatr/commit/9df78c03dea243b467504fdf422388ab9d2b5660))
* **signal:** signals.expire ([3591efd](https://github.com/AliMD/alwatr/commit/3591efd5e42f7a981814fd59d7189b5066735302))
# 0.28.0 (2023-01-20)
# 0.27.0 (2022-12-29)
# 0.26.0 (2022-12-22)
### Bug Fixes
* set correct path ([d01ce6f](https://github.com/AliMD/alwatr/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
* tsconfig ([e96dcd3](https://github.com/AliMD/alwatr/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
### Features
* improve error debugging ([1fba504](https://github.com/AliMD/alwatr/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
# [1.0.0](https://github.com/AliMD/alwatr/compare/v0.32.0...v1.0.0) (2023-06-14)

@@ -12,0 +96,0 @@

62

core.js

@@ -47,4 +47,3 @@ import { createLogger, globalAlwatr } from '@alwatr/logger';

export const _callListeners = (signal, detail) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, '_callListeners', { signalId: signal.id, signalDetail: detail });
logger.logMethodArgs?.('_callListeners', { signalId: signal.id, signalDetail: detail });
const removeList = [];

@@ -84,8 +83,7 @@ for (const listener of signal.listenerList) {

export const subscribe = (signalId, listenerCallback, options = {}) => {
var _a, _b, _c, _d, _e;
(_a = options.once) !== null && _a !== void 0 ? _a : (options.once = false);
(_b = options.disabled) !== null && _b !== void 0 ? _b : (options.disabled = false);
(_c = options.receivePrevious) !== null && _c !== void 0 ? _c : (options.receivePrevious = 'NextCycle');
(_d = options.priority) !== null && _d !== void 0 ? _d : (options.priority = false);
(_e = logger.logMethodArgs) === null || _e === void 0 ? void 0 : _e.call(logger, 'subscribe', { signalId, options });
options.once ?? (options.once = false);
options.disabled ?? (options.disabled = false);
options.receivePrevious ?? (options.receivePrevious = 'NextCycle');
options.priority ?? (options.priority = false);
logger.logMethodArgs?.('subscribe', { signalId, options });
const signal = getSignalObject(signalId);

@@ -146,4 +144,3 @@ const listener = {

export const unsubscribe = (listener) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'unsubscribe', listener);
logger.logMethodArgs?.('unsubscribe', listener);
const signal = getSignalObject(listener.signalId);

@@ -165,4 +162,3 @@ const listenerIndex = signal.listenerList.findIndex((_listener) => _listener.id === listener.id);

export const removeAllListeners = (signalId) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'removeAllListeners', signalId);
logger.logMethodArgs?.('removeAllListeners', signalId);
const signal = getSignalObject(signalId);

@@ -186,5 +182,4 @@ if (signal.listenerList.length === 0)

export const dispatch = (signalId, detail, options = {}) => {
var _a, _b;
(_a = options.debounce) !== null && _a !== void 0 ? _a : (options.debounce = 'AnimationFrame');
(_b = logger.logMethodArgs) === null || _b === void 0 ? void 0 : _b.call(logger, 'dispatch', { signalId, detail, options });
options.debounce ?? (options.debounce = 'AnimationFrame');
logger.logMethodArgs?.('dispatch', { signalId, detail, options });
const signal = getSignalObject(signalId);

@@ -210,4 +205,3 @@ // set detail before check signal.debounced for act like throttle (call listeners with last dispatch detail).

const callListeners = () => {
var _a;
_callListeners(signal, (_a = signal.detail) !== null && _a !== void 0 ? _a : detail);
_callListeners(signal, signal.detail ?? detail);
signal.debounced = false;

@@ -247,4 +241,3 @@ };

return new Promise((resolve) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'untilNext', signalId);
logger.logMethodArgs?.('untilNext', signalId);
subscribe(signalId, resolve, {

@@ -267,7 +260,8 @@ once: true,

*/
export const setContextProvider = (signalId, signalProvider, options = {}) => {
var _a, _b, _c;
(_a = options.debounce) !== null && _a !== void 0 ? _a : (options.debounce = 'AnimationFrame');
(_b = options.receivePrevious) !== null && _b !== void 0 ? _b : (options.receivePrevious = 'AnimationFrame');
(_c = logger.logMethodArgs) === null || _c === void 0 ? void 0 : _c.call(logger, 'setContextProvider', { signalId, options });
export const setContextProvider = (signalId,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
signalProvider, options = {}) => {
options.debounce ?? (options.debounce = 'AnimationFrame');
options.receivePrevious ?? (options.receivePrevious = 'AnimationFrame');
logger.logMethodArgs?.('setContextProvider', { signalId, options });
const requestSignalId = 'request-' + signalId;

@@ -301,5 +295,4 @@ removeAllListeners(requestSignalId);

export const defineCommand = (signalId, signalProvider, options = {}) => {
var _a, _b;
(_a = options.debounce) !== null && _a !== void 0 ? _a : (options.debounce = 'AnimationFrame');
(_b = logger.logMethodArgs) === null || _b === void 0 ? void 0 : _b.call(logger, 'defineCommand', { commandId: signalId, options });
options.debounce ?? (options.debounce = 'AnimationFrame');
logger.logMethodArgs?.('defineCommand', { commandId: signalId, options });
const requestSignalId = 'request-' + signalId;

@@ -329,4 +322,3 @@ removeAllListeners(requestSignalId);

export const requestContext = (contextId, requestParam, options = {}) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'requestContext', { contextId, requestParam });
logger.logMethodArgs?.('requestContext', { contextId, requestParam });
return dispatch(`request-${contextId}`, requestParam, options);

@@ -344,4 +336,3 @@ };

export const requestCommand = (commandId, commandArgument) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'requestCommand', { commandId, commandArgument });
logger.logMethodArgs?.('requestCommand', { commandId, commandArgument });
dispatch(`request-${commandId}`, commandArgument, { debounce: 'No' });

@@ -361,4 +352,3 @@ };

export const requestCommandWithResponse = async (commandId, commandArgument) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'requestCommand', { commandId, commandArgument });
logger.logMethodArgs?.('requestCommand', { commandId, commandArgument });
const _requestSignalId = `request-${commandId}`;

@@ -387,4 +377,3 @@ const _callbackSignalId = `callback-${commandId}-${++_lastListenerAutoId}`;

export const clearDetail = (signalId) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'expire', signalId);
logger.logMethodArgs?.('expire', signalId);
const signal = getSignalObject(signalId);

@@ -405,4 +394,3 @@ delete signal.detail;

export const destroySignal = (signalId) => {
var _a;
(_a = logger.logMethodArgs) === null || _a === void 0 ? void 0 : _a.call(logger, 'destroySignal', signalId);
logger.logMethodArgs?.('destroySignal', signalId);
const signal = _signalStorage[signalId];

@@ -409,0 +397,0 @@ if (signal == null)

{
"name": "@alwatr/signal",
"version": "1.0.1",
"version": "1.1.0",
"description": "Elegant powerful event system for handle global signals and states written in tiny TypeScript module.",

@@ -32,8 +32,8 @@ "keywords": [

"dependencies": {
"@alwatr/logger": "^1.0.1",
"@alwatr/type": "^1.0.1",
"@alwatr/util": "^1.0.1",
"tslib": "^2.5.3"
"@alwatr/logger": "^1.1.0",
"@alwatr/type": "^1.1.0",
"@alwatr/util": "^1.1.0",
"tslib": "^2.6.2"
},
"gitHead": "10b9734389e27538ba4fa4ac7871ec0354ca9285"
"gitHead": "e5c3bcb9d4f391a5a94d1469c5d31cbcd102c90b"
}

@@ -40,3 +40,3 @@ import { contextConsumer } from './context-consumer.js';

*/
getValue: () => { var _a; return (_a = getDetail(contextId)) !== null && _a !== void 0 ? _a : { state: 'initial' }; },
getValue: () => getDetail(contextId) ?? { state: 'initial' },
/**

@@ -43,0 +43,0 @@ * Send new context request to the provider.

@@ -46,3 +46,3 @@ import { contextProvider } from './context-provider.js';

*/
getValue: () => { var _a; return (_a = getDetail(contextId)) !== null && _a !== void 0 ? _a : { state: 'initial' }; },
getValue: () => getDetail(contextId) ?? { state: 'initial' },
/**

@@ -49,0 +49,0 @@ * Defines the provider of the context signal that will be called when the context requested.

@@ -79,3 +79,3 @@ import type { MaybePromise, Stringifyable } from '@alwatr/type';

*/
export type ListenerSpec = {
export interface ListenerSpec {
/**

@@ -89,3 +89,3 @@ * Unique listener id

signalId: string;
};
}
/**

@@ -108,3 +108,3 @@ * Signal listeners object in storage.

*/
export type SignalObject<T extends Stringifyable> = {
export interface SignalObject<T extends Stringifyable> {
/**

@@ -130,4 +130,4 @@ * Signal id for direct access.

*/
listenerList: Array<ListenerObject<T>>;
};
listenerList: ListenerObject<T>[];
}
/**

@@ -134,0 +134,0 @@ * Signal stack storage.

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

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