trucoshi 8.4.0 → 8.5.1
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.
- package/dist/events.d.ts +3 -1
- package/dist/lib/utils.d.ts +6 -0
- package/dist/lib/utils.js +8 -0
- package/dist/types.d.ts +3 -1
- package/package.json +8 -2
package/dist/events.d.ts
CHANGED
|
@@ -57,10 +57,12 @@ export declare enum EClientEvent {
|
|
|
57
57
|
JOIN_ROOM = "JOIN_ROOM",
|
|
58
58
|
LEAVE_ROOM = "LEAVE_ROOM"
|
|
59
59
|
}
|
|
60
|
+
export type SayType = "mate" | "ceba_toma_mate";
|
|
60
61
|
export interface ClientToServerEvents {
|
|
61
62
|
[EClientEvent.LOGOUT]: (callback: IEventCallback<{}>) => void;
|
|
62
63
|
[EClientEvent.PING]: (clientTime: number) => void;
|
|
63
|
-
[EClientEvent.CHAT]: (matchId: string, msg: string, callback
|
|
64
|
+
[EClientEvent.CHAT]: (matchId: string, msg: string, callback?: IEventCallback<{}>) => void;
|
|
65
|
+
[EClientEvent.SAY]: (matchId: string, msg: SayType, callback?: IEventCallback<{}>) => void;
|
|
64
66
|
[EClientEvent.LEAVE_MATCH]: (matchId: string, callback?: IEventCallback<{}>) => void;
|
|
65
67
|
[EClientEvent.CREATE_MATCH]: (callback: IEventCallback<{
|
|
66
68
|
match?: IPublicMatch;
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
/// <reference types="lodash" />
|
|
1
3
|
import { IHand } from "../truco";
|
|
2
4
|
import { ICard } from "../types";
|
|
5
|
+
export declare const memoizeMinute: {
|
|
6
|
+
<T extends (...args: any) => any>(func: T, resolver?: ((...args: Parameters<T>) => any) | undefined): T & import("lodash").MemoizedFunction;
|
|
7
|
+
Cache: import("lodash").MapCacheConstructor;
|
|
8
|
+
};
|
|
3
9
|
export declare function getMaxNumberIndex<T = number>(array: Array<T>): number;
|
|
4
10
|
export declare function getMinNumberIndex<T = number>(array: Array<T>): number;
|
|
5
11
|
export declare function getCardValue(card: ICard): number;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { CARDS } from "./constants";
|
|
2
|
+
import memoize from "lodash.memoize";
|
|
3
|
+
import partialRight from "lodash.partialright";
|
|
4
|
+
export const memoizeMinute = partialRight(memoize, function memoResolver(...args) {
|
|
5
|
+
const time = new Date().getMinutes();
|
|
6
|
+
args.push({ time });
|
|
7
|
+
const cacheKey = JSON.stringify(args);
|
|
8
|
+
return cacheKey;
|
|
9
|
+
});
|
|
2
10
|
export function getMaxNumberIndex(array) {
|
|
3
11
|
return array.reduce((accumulator, current, index) => {
|
|
4
12
|
return current > array[accumulator] ? index : accumulator;
|
package/dist/types.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export interface IChatMessage {
|
|
|
112
112
|
teamIdx?: 0 | 1;
|
|
113
113
|
};
|
|
114
114
|
system?: boolean;
|
|
115
|
+
hidden?: boolean;
|
|
115
116
|
command?: boolean;
|
|
116
117
|
card?: boolean;
|
|
117
118
|
content: string;
|
|
@@ -127,7 +128,8 @@ export interface IChatRoom {
|
|
|
127
128
|
card(user: IChatMessage["user"], card: ICard, sound?: string | boolean): void;
|
|
128
129
|
command(team: 0 | 1, command: ECommand | number, sound?: string | boolean): void;
|
|
129
130
|
system(message: string, sound?: string | boolean): void;
|
|
130
|
-
|
|
131
|
+
sound(sound: string, toTeamIdx?: "0" | "1", fromUser?: IChatMessage['user']): void;
|
|
132
|
+
emit(message?: IChatMessage, teamIdxs?: string): void;
|
|
131
133
|
}
|
|
132
134
|
export declare enum EChatSystem {
|
|
133
135
|
TEAM_0 = 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trucoshi",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
4
4
|
"description": "Lightning Truco Server",
|
|
5
5
|
"main": "dist/types.js",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/chai": "^4.3.4",
|
|
44
44
|
"@types/expect": "^24.3.0",
|
|
45
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
46
|
+
"@types/lodash.memoize": "^4.1.9",
|
|
47
|
+
"@types/lodash.partialright": "^4.2.9",
|
|
48
|
+
"@types/lodash.throttle": "^4.1.9",
|
|
45
49
|
"@types/mocha": "^10.0.1",
|
|
46
50
|
"@types/node": "^18.11.18",
|
|
47
51
|
"chai": "^4.3.7",
|
|
@@ -67,7 +71,6 @@
|
|
|
67
71
|
"@prisma/client": "^4.14.1",
|
|
68
72
|
"@socket.io/redis-adapter": "^8.2.1",
|
|
69
73
|
"@types/jsonwebtoken": "^9.0.5",
|
|
70
|
-
"@types/lodash.debounce": "^4.0.9",
|
|
71
74
|
"@types/node-forge": "^1.3.11",
|
|
72
75
|
"@types/pino": "^7.0.5",
|
|
73
76
|
"@types/redis": "^4.0.11",
|
|
@@ -79,6 +82,9 @@
|
|
|
79
82
|
"jsonwebtoken": "^9.0.2",
|
|
80
83
|
"lightning-accounts": "4.3.1",
|
|
81
84
|
"lodash.debounce": "^4.0.8",
|
|
85
|
+
"lodash.memoize": "^4.1.2",
|
|
86
|
+
"lodash.partialright": "^4.2.1",
|
|
87
|
+
"lodash.throttle": "^4.1.1",
|
|
82
88
|
"node-forge": "^1.3.1",
|
|
83
89
|
"path-scurry": "^1.9.2",
|
|
84
90
|
"pino": "^9.3.2",
|