mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
more integration tests
This commit is contained in:
parent
4b5f66d497
commit
decebc25c7
192 changed files with 3090 additions and 1657 deletions
|
|
@ -11,7 +11,8 @@ import { createEcmaScriptPlugin, runNodeJs } from '@bufbuild/protoplugin';
|
|||
|
||||
const HEADER = [
|
||||
'// @generated by protoc-gen-data. DO NOT EDIT.',
|
||||
'// Rollup of all proto modules + MessageInitShape param aliases for every Command_*.',
|
||||
'// Rollup of all proto modules + MessageInitShape param aliases for every Command_*,',
|
||||
'// plus type maps for Response/Event extensions grouped by scope.',
|
||||
'/* eslint-disable */',
|
||||
'',
|
||||
'',
|
||||
|
|
@ -55,6 +56,71 @@ const inner = createEcmaScriptPlugin({
|
|||
}
|
||||
f.print();
|
||||
|
||||
// ── Type maps for Response/Event extensions, grouped by extendee ────────
|
||||
//
|
||||
// Scans all messages for nested `extend` declarations and groups them by
|
||||
// which message they extend (Response, SessionEvent, RoomEvent, GameEvent).
|
||||
// Emits one `interface *Map { TypeName: TypeName; ... }` per scope.
|
||||
|
||||
/** @type {Map<string, import('@bufbuild/protobuf').DescMessage[]>} */
|
||||
const extendeeGroups = new Map();
|
||||
|
||||
for (const file of sortedFiles) {
|
||||
for (const msg of file.messages) {
|
||||
for (const ext of msg.nestedExtensions) {
|
||||
const target = ext.extendee.name;
|
||||
const group = extendeeGroups.get(target);
|
||||
if (group) {
|
||||
group.push(msg);
|
||||
} else {
|
||||
extendeeGroups.set(target, [msg]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {[string, string, import('@bufbuild/protobuf').DescMessage | null][]} */
|
||||
const maps = [
|
||||
['ResponseMap', 'Response', null],
|
||||
['SessionEventMap', 'SessionEvent', null],
|
||||
['RoomEventMap', 'RoomEvent', null],
|
||||
['GameEventMap', 'GameEvent', null],
|
||||
];
|
||||
|
||||
// Resolve the base extendee message for maps that need the base type included
|
||||
for (const file of sortedFiles) {
|
||||
for (const msg of file.messages) {
|
||||
for (const entry of maps) {
|
||||
if (msg.name === entry[1]) {
|
||||
entry[2] = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const [mapName, extendeeName, baseMsg] of maps) {
|
||||
const msgs = (extendeeGroups.get(extendeeName) || []).slice();
|
||||
msgs.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
if (msgs.length === 0 && !baseMsg) continue;
|
||||
|
||||
f.print('export interface ', mapName, ' {');
|
||||
|
||||
// Include the base extendee type itself (e.g. Response in ResponseMap)
|
||||
if (baseMsg) {
|
||||
const sym = f.import(baseMsg.name, `./proto/${baseMsg.file.name}_pb`, true);
|
||||
f.print(' ', baseMsg.name, ': ', sym, ';');
|
||||
}
|
||||
|
||||
for (const msg of msgs) {
|
||||
const sym = f.import(msg.name, `./proto/${msg.file.name}_pb`, true);
|
||||
f.print(' ', msg.name, ': ', sym, ';');
|
||||
}
|
||||
|
||||
f.print('}');
|
||||
f.print();
|
||||
}
|
||||
|
||||
// Generic extension registry infrastructure. Consolidates the three
|
||||
// near-duplicate registry types and helpers that used to live in
|
||||
// src/websocket/services/protobuf-types.ts into one generic pair.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue