Skip to content

Commit

Permalink
Allow to use types for user messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jun 23, 2023
1 parent 1ff6e9a commit cfabd06
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<img src="https://github.com/jcubic/sysend.js/blob/master/assets/logo.svg?raw=true" alt="Sysend.js logo"/>
</p>

[![npm](https://img.shields.io/badge/npm-1.16.2-blue.svg)](https://www.npmjs.com/package/sysend)
![bower](https://img.shields.io/badge/bower-1.16.2-yellow.svg)
[![npm](https://img.shields.io/badge/npm-1.16.3-blue.svg)](https://www.npmjs.com/package/sysend)
![bower](https://img.shields.io/badge/bower-1.16.3-yellow.svg)
![downloads](https://img.shields.io/npm/dt/sysend.svg)
[![jsdelivr](https://img.shields.io/jsdelivr/npm/hm/sysend)](https://www.jsdelivr.com/package/npm/sysend)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sysend",
"version": "1.16.2",
"version": "1.16.3",
"description": "Communication and Synchronization between browser tabs/windows. Works cross-domain.",
"main": "sysend.js",
"typings": "sysend.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions sysend.d.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/**@license
* sysend.js - send messages between browser windows/tabs version 1.16.2
* sysend.js - send messages between browser windows/tabs version 1.16.3
*
* Copyright (C) 2014-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
*
*/
type callback = (message: unknown, event: string) => void;
type callback<T> = (message: T, event: string) => void;

interface Sysend {
id: string;
broadcast(event: string, data?: unknown): void;
broadcast<T>(event: string, data?: T): void;
emit(event: string, data?: unknown): void;
on(event: string, callback: callback): void;
off(event: string, callback?: callback): void;
on<T>(event: string, callback: callback<T>): void;
off<T>(event: string, callback?: callback<T>): void;
proxy(...args: string[]): void;
serializer(to: (data: unknown) => string, from: (data: string) => unknown): void;
serializer<T>(to: (data: T) => string, from: (data: string) => T): void;
track(event: 'open', callback: (data: {id: string, count: number, primary: boolean}) => void): void;
track(event: 'close', callback: (data: {id: string, count: number, primary: boolean, self: boolean}) => void): void;
track(event: 'primary', callback: () => void): void;
track(event: 'message', callback: (payload: {data: unknown, origin: string}) => void): void;
track<T>(event: 'message', callback: (payload: {data: T, origin: string}) => void): void;
track(event: 'secondary', callback: () => void): void;
track(event: 'update', callback: (payload: Array<{ id: string, primary: boolean }>) => void): void;
untrack(event: 'open' | 'close' | 'primary' | 'secondary' | 'message' | 'update', fn?: (input?: unknown) => void): void;
list(): Promise<Array<{ id: string, primary: boolean }>>;
post(target: string, data?: unknown): void;
post<T>(target: string, data?: T): void;
channel(...domains: string[]): void;
isPrimary(): boolean;
rpc<T extends Array<unknown>, U>(object: Record<string, (...args: T) => U>): Promise<Record<string, (id: string, ...args: T) => Promise<U>>>
Expand Down
2 changes: 1 addition & 1 deletion sysend.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**@license
* sysend.js - send messages between browser windows/tabs version 1.16.2
* sysend.js - send messages between browser windows/tabs version 1.16.3
*
* Copyright (C) 2014-2023 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
Expand Down

0 comments on commit cfabd06

Please sign in to comment.