@magicworks/client-party-game 0.1.0-rc.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/README.md +91 -0
- package/dist/client.d.ts +210 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +659 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +407 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +232 -0
- package/dist/protocol.js.map +1 -0
- package/dist/socket.d.ts +30 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +3 -0
- package/dist/socket.js.map +1 -0
- package/package.json +26 -0
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The party game wire protocol, shared by the server
|
|
4
|
+
* (`@magicworks/service-party-game`), the host TV (through `PartyGameClient`)
|
|
5
|
+
* and, by hand, the phone page the server hosts (`public/app.js`).
|
|
6
|
+
*
|
|
7
|
+
* Roles
|
|
8
|
+
* -----
|
|
9
|
+
* host - the ROXi TV app. Owns the video playback and therefore owns round
|
|
10
|
+
* timing. It tells the server when a round starts and ends.
|
|
11
|
+
* player - a phone browser. Only ever sends a join request, a ready and an
|
|
12
|
+
* answer.
|
|
13
|
+
*
|
|
14
|
+
* The correct answer index is sent by the host at round start and never
|
|
15
|
+
* leaves the server: players receive options only, and the server is the sole
|
|
16
|
+
* authority on who scored what.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.Feature = exports.PlayerRefusal = exports.HostRefusal = exports.GameStatus = exports.PlayerMessage = exports.HostMessage = exports.PlayerEvent = exports.HostEvent = exports.TimeEvent = exports.GameMessage = exports.GameEvent = exports.PARTY_REGIONS = exports.SPEEDTEST_SIZES = exports.ROUTING_QUERY_KEY = exports.CODE_PREFIX_LENGTH = exports.CODE_LENGTH = exports.CODE_ALPHABET = exports.GAME_READY_TIMEOUT_MS = exports.ROUND_LEAD_MS = exports.MAX_NAME_LENGTH = exports.TOTAL_ROUNDS = exports.REOPEN_WINDOW_MS = exports.MAX_PLAYERS = void 0;
|
|
20
|
+
exports.speedtestPath = speedtestPath;
|
|
21
|
+
exports.phonePageConfigScript = phonePageConfigScript;
|
|
22
|
+
exports.socketUrlForCode = socketUrlForCode;
|
|
23
|
+
exports.regionOfCode = regionOfCode;
|
|
24
|
+
exports.normaliseCode = normaliseCode;
|
|
25
|
+
exports.codePrefixOf = codePrefixOf;
|
|
26
|
+
exports.scoreForAnswer = scoreForAnswer;
|
|
27
|
+
exports.MAX_PLAYERS = 20;
|
|
28
|
+
/**
|
|
29
|
+
* How long a finished party stays worth coming back to. Opening a lobby with
|
|
30
|
+
* the code of a room touched inside this window reopens that room - same code,
|
|
31
|
+
* same players, scores back to zero - so a second game needs a tap on each
|
|
32
|
+
* phone rather than a fresh scan and everybody's name typed again. Past it the
|
|
33
|
+
* room is left where it is and a new one is opened.
|
|
34
|
+
*/
|
|
35
|
+
exports.REOPEN_WINDOW_MS = 20 * 60 * 1000;
|
|
36
|
+
exports.TOTAL_ROUNDS = 15;
|
|
37
|
+
exports.MAX_NAME_LENGTH = 16;
|
|
38
|
+
/**
|
|
39
|
+
* A round starts on the TV and the phones at once: when the host has the
|
|
40
|
+
* round's video preloaded the server picks a start time ROUND_LEAD_MS ahead -
|
|
41
|
+
* long enough for the message to reach the TV - or the host's planned start,
|
|
42
|
+
* if later. The TV plays the video at that moment by its own clock, corrected
|
|
43
|
+
* against the server's with `time:ping`, and the phones get the options then.
|
|
44
|
+
*/
|
|
45
|
+
exports.ROUND_LEAD_MS = 700;
|
|
46
|
+
/**
|
|
47
|
+
* The countdown before round 1 runs on the TV and every phone at once, and only
|
|
48
|
+
* once everybody is there for it: starting a game asks the TV and every phone
|
|
49
|
+
* in the room whether it is ready (`game:prepare`), and the countdown goes out
|
|
50
|
+
* to all of them (`game:countdown`) once they have all said so (`game:ready`)
|
|
51
|
+
* - or this long after the start, so that one device that never answers cannot
|
|
52
|
+
* keep the rest waiting.
|
|
53
|
+
*/
|
|
54
|
+
exports.GAME_READY_TIMEOUT_MS = 10000;
|
|
55
|
+
/** No I, O, 0 or 1 - codes are read off a TV screen and typed on a phone. */
|
|
56
|
+
exports.CODE_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
|
57
|
+
exports.CODE_LENGTH = 6;
|
|
58
|
+
/**
|
|
59
|
+
* A room's code starts with the prefix of the server that holds it, and the
|
|
60
|
+
* load balancer routes on it: every connection that knows its room carries
|
|
61
|
+
* the code in the `c` query parameter (ROUTING_QUERY_KEY), so it reaches that
|
|
62
|
+
* server whichever server it would otherwise have been handed to.
|
|
63
|
+
*/
|
|
64
|
+
exports.CODE_PREFIX_LENGTH = 2;
|
|
65
|
+
exports.ROUTING_QUERY_KEY = 'c';
|
|
66
|
+
/**
|
|
67
|
+
* The speed test a TV times in the lobby, to pick a video rendition it can
|
|
68
|
+
* load quickly all game: files of random bytes on the CDN that serves the
|
|
69
|
+
* phone page, closer to where the videos come from than the party servers
|
|
70
|
+
* are. One file per size, at `speedtestPath(size)`.
|
|
71
|
+
*/
|
|
72
|
+
exports.SPEEDTEST_SIZES = [
|
|
73
|
+
64 * 1024,
|
|
74
|
+
256 * 1024,
|
|
75
|
+
1024 * 1024,
|
|
76
|
+
2 * 1024 * 1024,
|
|
77
|
+
4 * 1024 * 1024,
|
|
78
|
+
8 * 1024 * 1024,
|
|
79
|
+
];
|
|
80
|
+
function speedtestPath(size) {
|
|
81
|
+
return `/speedtest/${size}.bin`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The phone page's `config.js`: where its sockets go. Written when the page
|
|
85
|
+
* is deployed, since the party servers' names depend on where; everything
|
|
86
|
+
* else the page needs from the protocol is bundled into it.
|
|
87
|
+
*/
|
|
88
|
+
function phonePageConfigScript(config) {
|
|
89
|
+
return `window.PARTY_CONFIG=${JSON.stringify(config)};`;
|
|
90
|
+
}
|
|
91
|
+
/** The socket URL for a code, by its region. */
|
|
92
|
+
function socketUrlForCode(code, config) {
|
|
93
|
+
const region = regionOfCode(code);
|
|
94
|
+
return (region && config.regionSocketUrls?.[region]) || config.socketUrl;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Which region's servers hand out the codes starting with which characters.
|
|
98
|
+
* A room lives on one server in one region, and the party servers' global
|
|
99
|
+
* name is latency-routed, so a TV and a phone in the same room can be sent
|
|
100
|
+
* to different regions: a code says which region it belongs to, and a
|
|
101
|
+
* client connects for it to that region's own name. Between them the
|
|
102
|
+
* regions cover every first character, so any code belongs somewhere.
|
|
103
|
+
*/
|
|
104
|
+
exports.PARTY_REGIONS = {
|
|
105
|
+
'us-east-1': 'ABCDEFGHJKLMNPQR',
|
|
106
|
+
'eu-west-1': 'STUVWXYZ23456789',
|
|
107
|
+
};
|
|
108
|
+
/** The region a code belongs to. */
|
|
109
|
+
function regionOfCode(code) {
|
|
110
|
+
const first = code.charAt(0).toUpperCase();
|
|
111
|
+
return (Object.keys(exports.PARTY_REGIONS).find(region => exports.PARTY_REGIONS[region].includes(first)) ?? null);
|
|
112
|
+
}
|
|
113
|
+
/** `code` tidied up the way a phone types it, or null if it cannot be a code. */
|
|
114
|
+
function normaliseCode(code) {
|
|
115
|
+
const clean = String(code ?? '')
|
|
116
|
+
.trim()
|
|
117
|
+
.toUpperCase();
|
|
118
|
+
if (clean.length !== exports.CODE_LENGTH) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return [...clean].every(c => exports.CODE_ALPHABET.includes(c)) ? clean : null;
|
|
122
|
+
}
|
|
123
|
+
/** The server prefix a code routes by. */
|
|
124
|
+
function codePrefixOf(code) {
|
|
125
|
+
return code.slice(0, exports.CODE_PREFIX_LENGTH);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Speed based scoring, mirroring the single player formula in GameCore:
|
|
129
|
+
* points scale with the time left on the clock, with a bonus for answering
|
|
130
|
+
* in the first half of the round.
|
|
131
|
+
*/
|
|
132
|
+
function scoreForAnswer(secondsLeft, totalRoundTime, modifier) {
|
|
133
|
+
const speedBonus = secondsLeft >= totalRoundTime / 2 ? 1.2 : 1.0;
|
|
134
|
+
return Math.max(1, Math.round(secondsLeft * modifier * speedBonus));
|
|
135
|
+
}
|
|
136
|
+
/* ------------------------------------------------------------ event names */
|
|
137
|
+
/** The TV or a phone -> server: here, set up, and ready for the countdown. */
|
|
138
|
+
exports.GameEvent = {
|
|
139
|
+
Ready: 'game:ready',
|
|
140
|
+
};
|
|
141
|
+
/** Server -> the TV and the phones */
|
|
142
|
+
exports.GameMessage = {
|
|
143
|
+
/** Say when you are ready for the countdown (phones: straight away). */
|
|
144
|
+
Prepare: 'game:prepare',
|
|
145
|
+
/** Everybody is: start the countdown now. */
|
|
146
|
+
Countdown: 'game:countdown',
|
|
147
|
+
};
|
|
148
|
+
/** TV -> server: the server's clock, for working out the offset to it. */
|
|
149
|
+
exports.TimeEvent = {
|
|
150
|
+
Ping: 'time:ping',
|
|
151
|
+
};
|
|
152
|
+
/** Host -> server */
|
|
153
|
+
exports.HostEvent = {
|
|
154
|
+
Create: 'host:create',
|
|
155
|
+
Start: 'host:start',
|
|
156
|
+
/** The round's options and answer, sent once the host's video is preloaded. */
|
|
157
|
+
RoundStart: 'host:round-start',
|
|
158
|
+
RoundEnd: 'host:round-end',
|
|
159
|
+
GameEnd: 'host:game-end',
|
|
160
|
+
Restart: 'host:restart',
|
|
161
|
+
/** Open, here, a room handed over by a server on its way out: see HostMessage.Move. */
|
|
162
|
+
Adopt: 'host:adopt',
|
|
163
|
+
/** To the server it is leaving: the room is open again under this code. */
|
|
164
|
+
Moved: 'host:moved',
|
|
165
|
+
};
|
|
166
|
+
/** Player -> server */
|
|
167
|
+
exports.PlayerEvent = {
|
|
168
|
+
Join: 'player:join',
|
|
169
|
+
Ready: 'player:ready',
|
|
170
|
+
Answer: 'player:answer',
|
|
171
|
+
};
|
|
172
|
+
/** Server -> host */
|
|
173
|
+
exports.HostMessage = {
|
|
174
|
+
Players: 'players',
|
|
175
|
+
AllAnswered: 'round:all-answered',
|
|
176
|
+
GameOver: 'game:over',
|
|
177
|
+
/** Play the round at `startAt` (server time). */
|
|
178
|
+
RoundGo: 'round:go',
|
|
179
|
+
/**
|
|
180
|
+
* This server is on its way out and the game is over: take the room to
|
|
181
|
+
* another one (`host:adopt` with the token, over a connection with no room
|
|
182
|
+
* in its query), then say where it went (`host:moved`).
|
|
183
|
+
*/
|
|
184
|
+
Move: 'room:move',
|
|
185
|
+
};
|
|
186
|
+
/** Server -> player */
|
|
187
|
+
exports.PlayerMessage = {
|
|
188
|
+
State: 'state',
|
|
189
|
+
Dropped: 'dropped',
|
|
190
|
+
RoundStart: 'round:start',
|
|
191
|
+
RoundResult: 'round:result',
|
|
192
|
+
GameOver: 'game:over',
|
|
193
|
+
/** The party is open under another code: connect for it and rejoin as before. */
|
|
194
|
+
Moved: 'room:moved',
|
|
195
|
+
/** The party is waiting for its TV, which is gone for now: try again in a while. */
|
|
196
|
+
Parked: 'room:parked',
|
|
197
|
+
};
|
|
198
|
+
exports.GameStatus = {
|
|
199
|
+
Lobby: 'lobby',
|
|
200
|
+
Playing: 'playing',
|
|
201
|
+
Over: 'over',
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Why a host call was refused, in its ack's `reason`.
|
|
205
|
+
*/
|
|
206
|
+
exports.HostRefusal = {
|
|
207
|
+
/**
|
|
208
|
+
* A server on its way out: it keeps the rooms it has, but opens no new ones
|
|
209
|
+
* (and past its drain deadline, starts no more games), so the host connects
|
|
210
|
+
* again without a room in its query - which the load balancer hands to a
|
|
211
|
+
* server still taking parties - and asks again.
|
|
212
|
+
*/
|
|
213
|
+
Draining: 'draining',
|
|
214
|
+
/** The room is open under another code, `movedTo`: ask again there. */
|
|
215
|
+
Moved: 'moved',
|
|
216
|
+
/** The room is on its way to another server: ask again once it is there. */
|
|
217
|
+
Moving: 'moving',
|
|
218
|
+
};
|
|
219
|
+
/** Why a phone's call was refused, in its ack's `reason`. */
|
|
220
|
+
exports.PlayerRefusal = {
|
|
221
|
+
/** The room is on its way to another server: ask again in a moment, or follow room:moved. */
|
|
222
|
+
Moving: 'moving',
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* What a host or a phone can do beyond the first version of the protocol,
|
|
226
|
+
* sent with `host:create` and `player:join`. A server only moves a room when
|
|
227
|
+
* its host and every phone in it can follow.
|
|
228
|
+
*/
|
|
229
|
+
exports.Feature = {
|
|
230
|
+
Move: 'move',
|
|
231
|
+
};
|
|
232
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;AAEU,QAAA,WAAW,GAAG,EAAE,CAAC;AAC9B;;;;;;GAMG;AACU,QAAA,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClC,QAAA,YAAY,GAAG,EAAE,CAAC;AAClB,QAAA,eAAe,GAAG,EAAE,CAAC;AAClC;;;;;;GAMG;AACU,QAAA,aAAa,GAAG,GAAG,CAAC;AACjC;;;;;;;GAOG;AACU,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAE3C,6EAA6E;AAChE,QAAA,aAAa,GAAG,kCAAkC,CAAC;AACnD,QAAA,WAAW,GAAG,CAAC,CAAC;AAC7B;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG,CAAC,CAAC;AACvB,QAAA,iBAAiB,GAAG,GAAG,CAAC;AAErC;;;;;GAKG;AACU,QAAA,eAAe,GAAG;IAC7B,EAAE,GAAG,IAAI;IACT,GAAG,GAAG,IAAI;IACV,IAAI,GAAG,IAAI;I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KAAK,EAAE,cAAc;IACrB,MAAM,EAAE,eAAe;CACf,CAAC;AAEX,qBAAqB;AACR,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,oBAAoB;IACjC,QAAQ,EAAE,WAAW;IACrB,iDAAiD;IACjD,OAAO,EAAE,UAAU;IACnB;;;;OAIG;IACH,IAAI,EAAE,WAAW;CACT,CAAC;AAEX,uBAAuB;AACV,QAAA,aAAa,GAAG;IAC3B,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,cAAc;IAC3B,QAAQ,EAAE,WAAW;IACrB,iFAAiF;IACjF,KAAK,EAAE,YAAY;IACnB,oFAAoF;IACpF,MAAM,EAAE,aAAa;CACb,CAAC;AAEE,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACJ,CAAC;AAEX;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB;;;;;OAKG;IACH,QAAQ,EAAE,UAAU;IACpB,uEAAuE;IACvE,KAAK,EAAE,OAAO;IACd,4EAA4E;IAC5E,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX,6DAA6D;AAChD,QAAA,aAAa,GAAG;IAC3B,6FAA6F;IAC7F,MAAM,EAAE,QAAQ;CACR,CAAC;AAEX;;;;GAIG;AACU,QAAA,OAAO,GAAG;IACrB,IAAI,EAAE,MAAM;CACJ,CAAC"}
|
package/dist/socket.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The little of a socket.io client socket this library uses.
|
|
3
|
+
*
|
|
4
|
+
* It is structural so the caller brings its own socket.io-client: the ROXi
|
|
5
|
+
* app ships 2.x (the server accepts it with `allowEIO3`), node and newer
|
|
6
|
+
* browsers 4.x, and either one's `io` can be handed to `PartyGameClient`
|
|
7
|
+
* as it is. Bundling one here would put a second copy in the app.
|
|
8
|
+
*/
|
|
9
|
+
export interface PartySocket {
|
|
10
|
+
readonly connected: boolean;
|
|
11
|
+
on(event: string, listener: (...args: any[]) => void): unknown;
|
|
12
|
+
emit(event: string, ...args: any[]): unknown;
|
|
13
|
+
close(): unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface PartySocketOptions {
|
|
16
|
+
transports: string[];
|
|
17
|
+
/** What the load balancer routes on: see ROUTING_QUERY_KEY. */
|
|
18
|
+
query: Record<string, string>;
|
|
19
|
+
/** Always a connection of its own, never one shared with another socket to the same URL. */
|
|
20
|
+
forceNew: boolean;
|
|
21
|
+
reconnection: boolean;
|
|
22
|
+
reconnectionDelay: number;
|
|
23
|
+
reconnectionDelayMax: number;
|
|
24
|
+
timeout: number;
|
|
25
|
+
/** socket.io-client 2.x only: no JSONP polling fallback. */
|
|
26
|
+
jsonp?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** socket.io-client's `io`, of either major version. */
|
|
29
|
+
export type PartySocketFactory = (url: string, options: PartySocketOptions) => PartySocket;
|
|
30
|
+
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC;IAC/D,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAC7C,KAAK,IAAI,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,kBAAkB,KACxB,WAAW,CAAC"}
|
package/dist/socket.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@magicworks/client-party-game",
|
|
3
|
+
"version": "0.1.0-rc.0",
|
|
4
|
+
"description": "Host TV client and wire protocol for the party game server",
|
|
5
|
+
"author": "Luis Ávila <luis.avila@faststream.network>",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "run -T tsgo",
|
|
13
|
+
"build:watch": "run -T tsgo --build --watch --preserveWatchOutput --pretty",
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"lint": "run -T biome check . && run -T sort-package-json package.json --check",
|
|
16
|
+
"lint:fix": "run -T biome check --write . && run -T sort-package-json package.json",
|
|
17
|
+
"test": "vitest --no-watch"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "24.10.4",
|
|
21
|
+
"vitest": "4.1.5"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
}
|
|
26
|
+
}
|