fix(server-*): should export more types, and for module:announced should ignore self

This commit is contained in:
Neko Ayaka
2026-03-29 01:10:11 +08:00
committed by Rin
parent d5be1a079e
commit 6f8f049b01
3 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -574,7 +574,7 @@ interface ModuleCompatibilityResultEvent {
reason?: string
}
interface RegistryModulesSyncEvent {
export interface RegistryModulesSyncEvent {
modules: Array<{
name: string
index?: number
@@ -599,7 +599,7 @@ interface ModuleAnnounceEvent<C = undefined> {
configSchema?: ModuleConfigSchema
dependencies?: ModuleDependency[]
}
interface ModuleAnnouncedEvent {
export interface ModuleAnnouncedEvent {
name: string
index?: number
identity: ModuleIdentity
+4 -1
View File
@@ -426,7 +426,10 @@ export function setupApp(options?: AppOptions): { app: H3, closeAllPeers: () =>
// broadcast module:announced to all authenticated peers
for (const other of peers.values()) {
if (other.authenticated) {
// only send to
// 1. authenticated peers
// 2. other peers except the announcing peer itself
if (other.authenticated && !(other.peer.id === peer.id)) {
send(other.peer, {
type: 'module:announced',
data: { name, index, identity },
@@ -3,7 +3,9 @@ import type { RouteTargetExpression } from '@proj-airi/server-shared/types'
import type { AuthenticatedPeer } from '../../types'
function globToRegExp(glob: string) {
// eslint-disable-next-line e18e/prefer-static-regex
const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&')
// eslint-disable-next-line e18e/prefer-static-regex
const pattern = `^${escaped.replace(/\*/g, '.*')}$`
return new RegExp(pattern)
}