@tailuge/messaging 1.19.0 → 1.20.0
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/types.d.ts +11 -1
- package/dist/types.js +15 -2
- package/dist/types.js.map +1 -1
- package/package.json +9 -4
package/dist/types.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export interface PresenceMessage {
|
|
|
31
31
|
seek?: Seek;
|
|
32
32
|
meta?: Meta;
|
|
33
33
|
tableId?: string;
|
|
34
|
+
isSpectator?: boolean;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Context about a previous game for rematch challenges.
|
|
@@ -119,9 +120,18 @@ export declare function isChatMessage(msg: any): msg is ChatMessage;
|
|
|
119
120
|
export declare function canChallenge(target: PresenceMessage, currentUserId: string): boolean;
|
|
120
121
|
/**
|
|
121
122
|
* Predicate: can the current user spectate this target's game?
|
|
122
|
-
* Returns true if target is
|
|
123
|
+
* Returns true if target is a player (not spectator) at a different table
|
|
123
124
|
*/
|
|
124
125
|
export declare function canSpectate(target: PresenceMessage, currentTableId?: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Derived status of a user based on their presence state
|
|
128
|
+
*/
|
|
129
|
+
export type UserStatus = "available" | "playing" | "spectating";
|
|
130
|
+
export declare function userStatus(user: PresenceMessage): UserStatus;
|
|
131
|
+
/**
|
|
132
|
+
* Predicate: is the user in the lobby (not in a game or spectating)?
|
|
133
|
+
*/
|
|
134
|
+
export declare function isInLobby(user: PresenceMessage): boolean;
|
|
125
135
|
/**
|
|
126
136
|
* Filter: derive active games from presence list
|
|
127
137
|
* Returns unique games (one entry per tableId) with their players
|
package/dist/types.js
CHANGED
|
@@ -19,10 +19,23 @@ export function canChallenge(target, currentUserId) {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Predicate: can the current user spectate this target's game?
|
|
22
|
-
* Returns true if target is
|
|
22
|
+
* Returns true if target is a player (not spectator) at a different table
|
|
23
23
|
*/
|
|
24
24
|
export function canSpectate(target, currentTableId) {
|
|
25
|
-
return !!target.tableId && target.tableId !== currentTableId;
|
|
25
|
+
return !!target.tableId && !target.isSpectator && target.tableId !== currentTableId;
|
|
26
|
+
}
|
|
27
|
+
export function userStatus(user) {
|
|
28
|
+
if (!user.tableId)
|
|
29
|
+
return "available";
|
|
30
|
+
if (user.isSpectator)
|
|
31
|
+
return "spectating";
|
|
32
|
+
return "playing";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Predicate: is the user in the lobby (not in a game or spectating)?
|
|
36
|
+
*/
|
|
37
|
+
export function isInLobby(user) {
|
|
38
|
+
return !user.tableId;
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
28
41
|
* Filter: derive active games from presence list
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA+GA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAQ;IACxC,OAAO,GAAG,EAAE,WAAW,KAAK,UAAU,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAQ;IACzC,OAAO,GAAG,EAAE,WAAW,KAAK,WAAW,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,OAAO,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,MAAuB,EAAE,aAAqB;IACzE,OAAO,MAAM,CAAC,MAAM,KAAK,aAAa,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAuB,EAAE,cAAuB;IAC1E,OAAO,CAAC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AI,EAAE,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailuge/messaging",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A stateful messaging library for Nchan-powered real-time applications.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"test:debug": "npm run playwright",
|
|
24
24
|
"lint": "tsc --noEmit && npx oxlint src test",
|
|
25
25
|
"prettify": "npx oxfmt src test",
|
|
26
|
-
"build": "
|
|
26
|
+
"build:lit": "npx esbuild src/client/lobby.js --bundle --minify --outfile=docker/html/lobby.js && cp src/client/*.html docker/html/ && cp src/client/favicon.ico src/client/robots.txt docker/html/ 2>/dev/null || true && mkdir -p docker/html/assets && cp src/client/assets/*.png docker/html/assets/ 2>/dev/null || true",
|
|
27
|
+
"crossdeploy": "npx esbuild src/client/lobby.js --bundle --minify --outfile=../billiards/dist/lobby.js && cp src/client/lobby.html ../billiards/dist/ && cp src/client/assets/*.png ../billiards/dist/assets/",
|
|
28
|
+
"build": "tsc --declaration && node scripts/add-js-extensions.js && npx esbuild src/index.ts --bundle --format=esm --outfile=docker/html/messaging.js && npm run build:lit",
|
|
27
29
|
"release": "npm version minor --no-git-tag-version && npm run build",
|
|
28
30
|
"build:all": "npm run build && npm run docker:start",
|
|
29
31
|
"docker:start": "bash scripts/docker-nchan.sh",
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"@types/jest": "30.0.0",
|
|
48
50
|
"@types/ws": "^8.18.1",
|
|
49
51
|
"esbuild": "^0.28.0",
|
|
50
|
-
"jest": "30.
|
|
52
|
+
"jest": "^30.4.2",
|
|
51
53
|
"oxlint": "^1.63.0",
|
|
52
54
|
"testcontainers": "^11.14.0",
|
|
53
55
|
"ts-jest": "^29.4.9",
|
|
@@ -58,5 +60,8 @@
|
|
|
58
60
|
"defaults",
|
|
59
61
|
"ios >= 12",
|
|
60
62
|
"safari >= 12"
|
|
61
|
-
]
|
|
63
|
+
],
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"lit": "^3.3.2"
|
|
66
|
+
}
|
|
62
67
|
}
|